| 12 |
- /* Riot v2.3.11, @license MIT, (c) 2015 Muut Inc. + contributors */
- (function(e,t){"use strict";var n={version:"v2.3.11",settings:{}},r=0,i=[],o={},a="riot-",f=a+"tag",u="string",s="object",c="undefined",l="function",p=/^(?:opt(ion|group)|tbody|col|t[rhd])$/,d=["_item","_id","_parent","update","root","mount","unmount","mixin","isMounted","isLoop","tags","parent","opts","trigger","on","off","one"],g=(e&&e.document||{}).documentMode|0;n.observable=function(e){e=e||{};var t={},n=function(e,t){e.replace(/\S+/g,t)},r=function(t,n){Object.defineProperty(e,t,{value:n,enumerable:false,writable:false,configurable:false})};r("on",function(r,i){if(typeof i!="function")return e;n(r,function(e,n){(t[e]=t[e]||[]).push(i);i.typed=n>0});return e});r("off",function(r,i){if(r=="*")t={};else{n(r,function(e){if(i){var n=t[e];for(var r=0,o;o=n&&n[r];++r){if(o==i)n.splice(r--,1)}}else delete t[e]})}return e});r("one",function(t,n){function r(){e.off(t,r);n.apply(e,arguments)}return e.on(t,r)});r("trigger",function(r){var i=arguments.length-1,o=new Array(i);for(var a=0;a<i;a++){o[a]=arguments[a+1]}n(r,function(n){var r=(t[n]||[]).slice(0);for(var i=0,a;a=r[i];++i){if(a.busy)return;a.busy=1;try{a.apply(e,a.typed?[n].concat(o):o)}catch(f){e.trigger("error",f)}if(r[i]!==a){i--}a.busy=0}if(t.all&&n!="all")e.trigger.apply(e,["all",n].concat(o))});return e});return e};(function(t){if(!e)return;var n=/^.+?\/+[^\/]+/,r="EventListener",i="remove"+r,o="add"+r,a="hasAttribute",f="replace",u="popstate",s="trigger",c=3,l=e,p=document,d=l.history.location||l.location,g=M.prototype,h=p&&p.ontouchstart?"touchstart":"click",v=false,m=t.observable(),b=false,y,w,x,_,S=[],C=0;function L(e){return e.split(/[\/?#]/)}function N(e,t){var n=new RegExp("^"+t[f](/\*/g,"([^/?#]+?)")[f](/\.\./,".*")+"$"),r=e.match(n);if(r)return r.slice(1)}function M(){this.$=[];t.observable(this);m.on("stop",this.s.bind(this));m.on("emit",this.e.bind(this))}function E(e){return e[f](/^\/|\/$/,"")}function T(e){return typeof e=="string"}function $(e){return(e||d.href)[f](n,"")}function k(e){return y[0]=="#"?(e||d.href).split(y)[1]||"":$(e)[f](y,"")}function O(e){var t=C==0;if(c<=C)return;C++;S.push(function(){var t=k();if(e||t!=w){m[s]("emit",t);w=t}});if(t){while(S.length){S[0]();S.shift()}C=0}}function j(e){if(e.which!=1||e.metaKey||e.ctrlKey||e.shiftKey||e.defaultPrevented)return;var t=e.target;while(t&&t.nodeName!="A")t=t.parentNode;if(!t||t.nodeName!="A"||t[a]("download")||!t[a]("href")||t.target&&t.target!="_self"||t.href.indexOf(d.href.match(n)[0])==-1)return;if(t.href!=d.href){if(t.href.split("#")[0]==d.href.split("#")[0]||y!="#"&&$(t.href).indexOf(y)!==0||!A(k(t.href),t.title||p.title))return}e.preventDefault()}function A(e,t){t=t||p.title;history.pushState(null,t,y+E(e));p.title=t;b=false;O();return b}g.m=function(e,t){if(T(e)&&(!t||T(t)))A(e,t);else if(t)this.r(e,t);else this.r("@",e)};g.s=function(){this.off("*");this.$=[]};g.e=function(e){this.$.concat("@").some(function(t){var n=(t=="@"?x:_)(E(e),E(t));if(n){this[s].apply(null,[t].concat(n));return b=true}},this)};g.r=function(e,t){if(e!="@"){e="/"+E(e);this.$.push(e)}this.on(e,t)};var I=new M;var R=I.m.bind(I);R.create=function(){var e=new M;e.m.stop=e.s.bind(e);return e.m.bind(e)};R.base=function(e){y=e||"#";w=k()};R.exec=function(){O(true)};R.parser=function(e,t){if(!e&&!t){x=L;_=N}if(e)x=e;if(t)_=t};R.query=function(){var e={};d.href[f](/[?&](.+?)=([^&]*)/g,function(t,n,r){e[n]=r});return e};R.stop=function(){if(v){l[i](u,O);p[i](h,j);m[s]("stop");v=false}};R.start=function(e){if(!v){l[o](u,O);p[o](h,j);v=true}if(e)O(true)};R.base();R.parser();t.route=R})(n);var h=function(e){var t="g",r=/\/\*[^*]*\*+(?:[^*\/][^*]*\*+)*\//g,i=/"[^"\\]*(?:\\[\S\s][^"\\]*)*"|'[^'\\]*(?:\\[\S\s][^'\\]*)*'/g,o=i.source+"|"+/(?:[$\w\)\]]|\+\+|--)\s*(\/)(?![*\/])/.source+"|"+/\/(?=[^*\/])[^[\/\\]*(?:(?:\[(?:\\.|[^\]\\]*)*\]|\\.)[^[\/\\]*)*?(\/)[gim]*/.source,a="{ }",f={"(":l("([()])|"+o,t),"[":l("([[\\]])|"+o,t),"{":l("([{}])|"+o,t)};var u=e,s,c=[];function l(e,t){return new RegExp(e,t)}function p(e){return e}function d(e){return new RegExp(e.source.replace(/{/g,c[2]).replace(/}/g,c[3]),e.global?t:"")}function g(e){e=e||a;if(e!==c[8]){var n=e.split(" ");if(e===a){c=n.concat(n);s=p}else{if(n.length!==2||/[\x00-\x1F<>a-zA-Z0-9'",;\\]/.test(e)){throw new Error('Unsupported brackets "'+e+'"')}c=n.concat(e.replace(/(?=[[\]()*+?.^$|])/g,"\\").split(" "));s=d}c[4]=s(c[1].length>1?/(?:^|[^\\]){[\S\s]*?}/:/(?:^|[^\\]){[^}]*}/);c[5]=s(/\\({|})/g);c[6]=s(/(\\?)({)/g);c[7]=l("(\\\\?)(?:([[({])|("+c[3]+"))|"+o,t);c[9]=s(/^\s*{\^?\s*([$\w]+)(?:\s*,\s*(\S+))?\s+in\s+(\S+)\s*}/);c[8]=e}h.settings.brackets=u=e}function h(e){g(h.settings.brackets);return e instanceof RegExp?s(e):c[e]}h.split=function v(e,t){var n=[],r,i,o,a,u=h(6);i=o=u.lastIndex=0;while(r=u.exec(e)){a=r.index;if(i){if(r[2]){u.lastIndex=l(r[2],u.lastIndex);continue}if(!r[3])continue}if(!r[1]){s(e.slice(o,a));o=u.lastIndex;u=c[6+(i^=1)];u.lastIndex=o}}if(e&&o<e.length){s(e.slice(o))}return n;function s(e){if(t||i)n.push(e&&e.replace(c[5],"$1"));else n.push(e)}function l(t,n){var r,i=f[t],o=1;i.lastIndex=n;while(r=i.exec(e)){if(r[1]&&!(r[1]===t?++o:--o))break}return r?i.lastIndex:e.length}};h.hasExpr=function m(e){return h(4).test(e)};h.loopKeys=function b(e){var t=e.match(h(9));return t?{key:t[1],pos:t[2],val:c[0]+t[3]+c[1]}:{val:e.trim()}};h.array=function y(e){g(e||h.settings.brackets);return c};h.settings=typeof n!=="undefined"&&n.settings||{};h.set=g;h.R_STRINGS=i;h.R_MLCOMMS=r;h.S_QBLOCKS=o;g(h.settings.brackets);return h}();var v=function(){var t=!1,n={};function r(e,t){if(!e)return e;return(n[e]||(n[e]=o(e))).call(t,i)}r.hasExpr=h.hasExpr;r.loopKeys=h.loopKeys;r.errorHandler=t;function i(e,t){if(r.errorHandler){e.riotData={tagName:t&&t.root&&t.root.tagName,_riot_id:t&&t._riot_id};r.errorHandler(e)}}function o(e){var t=u(e);if(t.slice(0,11)!=="try{return ")t="return "+t;return new Function("E",t+";")}var a=new RegExp(h.S_QBLOCKS,"g"),f=/\x01(\d+)~/g;function u(e){var t=[],n,r=h.split(e,1);if(r.length>2||r[0]){var i,o,a=[];for(i=o=0;i<r.length;++i){n=r[i];if(n&&(n=i&1?l(n,1,t):'"'+n.replace(/\\/g,"\\\\").replace(/\r\n?|\n/g,"\\n").replace(/"/g,'\\"')+'"'))a[o++]=n}n=o<2?a[0]:"["+a.join(",")+'].join("")'}else{n=l(r[1],0,t)}if(t[0])n=n.replace(f,function(e,n){return t[n].replace(/\r/g,"\\r").replace(/\n/g,"\\n")});return n}var s=/^(?:(-?[_A-Za-z\xA0-\xFF][-\w\xA0-\xFF]*)|\x01(\d+)~):/,c=/,|([[{(])|$/g;function l(e,t,n){e=e.replace(a,function(e,t){return e.length>2&&!t?""+(n.push(e)-1)+"~":e}).replace(/\s+/g," ").trim().replace(/\ ?([[\({},?\.:])\ ?/g,"$1");if(e){var r=[],i=0,o;while(e&&(o=e.match(s))&&!o.index){var f,u,c=/,|([[{(])|$/g;e=RegExp.rightContext;f=o[2]?n[o[2]].slice(1,-1).trim().replace(/\s+/g," "):o[1];while(u=(o=c.exec(e))[1])l(u,c);u=e.slice(0,o.index);e=RegExp.rightContext;r[i++]=g(u,1,f)}e=!i?g(e,t):i>1?"["+r.join(",")+'].join(" ").trim()':r[0]}return e;function l(t,n){var r,i=1,o=t==="("?/[()]/g:t==="["?/[[\]]/g:/[{}]/g;o.lastIndex=n.lastIndex;while(r=o.exec(e)){if(r[0]===t)++i;else if(!--i)break}n.lastIndex=i?e.length:o.lastIndex}}var p='"in this?this:'+(typeof e!=="object"?"global":"window")+").";var d=/[,{][$\w]+:|(^ *|[^$\w\.])(?!(?:typeof|true|false|null|undefined|in|instanceof|is(?:Finite|NaN)|void|NaN|new|Date|RegExp|Math)(?![$\w]))([$_A-Za-z][$\w]*)/g;function g(e,n,r){var i=t;e=e.replace(d,function(e,t,n,r,o){if(n){r=i?0:r+e.length;if(n!=="this"&&n!=="global"&&n!=="window"){e=t+'("'+n+p+n;if(r)i=(o=o[r])==="."||o==="("||o==="["}else if(r)i=!/^(?=(\.[$\w]+))\1(?:[^.[(]|$)/.test(o.slice(r))}return e});if(i){e="try{return "+e+"}catch(e){E(e,this)}"}if(r){e=(i?"function(){"+e+"}.call(this)":"("+e+")")+'?"'+r+'":""'}else if(n){e="function(v){"+(i?e.replace("return ","v="):"v=("+e+")")+';return v||v===0?v:""}.call(this)'}return e}r.parse=function(e){return e};return r}();var m=function(e){var t={tr:"tbody",th:"tr",td:"tr",tbody:"table",col:"colgroup"},n="div";e=e&&e<10;function r(r){var o=r&&r.match(/^\s*<([-\w]+)/),a=o&&o[1].toLowerCase(),f=t[a]||n,u=X(f);u.stub=true;if(e&&a&&(o=a.match(p)))i(u,r,a,!!o[1]);else u.innerHTML=r;return u}function i(e,t,r,i){var o=X(n),a=i?"select>":"table>",f;o.innerHTML="<"+a+t+"</"+a;f=ee(r,o);if(f)e.appendChild(f)}return r}(g);function b(e,t,n){var r={};r[e.key]=t;if(e.pos)r[e.pos]=n;return r}function y(e,t){var n=t.length,r=e.length;while(n>r){var i=t[--n];t.splice(n,1);i.unmount()}}function w(e,t){Object.keys(e.tags).forEach(function(n){var r=e.tags[n];if(Q(r))$(r,function(e){F(e,n,t)});else F(r,n,t)})}function x(e,t,n){var r=e._root;e._virts=[];while(r){var i=r.nextSibling;if(n)t.insertBefore(r,n._root);else t.appendChild(r);e._virts.push(r);r=i}}function _(e,t,n,r){var i=e._root;for(var o=0;o<r;o++){var a=i.nextSibling;t.insertBefore(i,n._root);i=a}}function S(e,t,n){O(e,"each");var r=typeof A(e,"no-reorder")!==u||O(e,"no-reorder"),i=D(e),a=o[i]||{tmpl:e.outerHTML},f=p.test(i),s=e.parentNode,c=document.createTextNode(""),l=R(e),d=/option/gi.test(i),g=[],h=[],m,S=e.tagName=="VIRTUAL";n=v.loopKeys(n);s.insertBefore(c,e);t.one("before-mount",function(){e.parentNode.removeChild(e);if(s.stub)s=t.root}).on("update",function(){var u=v(n.val,t),p=document.createDocumentFragment();if(!Q(u)){m=u||false;u=m?Object.keys(u).map(function(e){return b(n,e,u[e])}):[]}$(u,function(u,c){var d=r&&u instanceof Object,v=h.indexOf(u),y=~v&&d?v:c,C=g[y];u=!m&&n.key?b(n,u,c):u;if(!d&&!C||d&&!~v||!C){C=new N(a,{parent:t,isLoop:true,hasImpl:!!o[i],root:f?s:e.cloneNode(),item:u},e.innerHTML);C.mount();if(S)C._root=C.root.firstChild;if(c==g.length){if(S)x(C,p);else p.appendChild(C.root)}else{if(S)x(C,s,g[c]);else s.insertBefore(C.root,g[c].root);h.splice(c,0,u)}g.splice(c,0,C);y=c}else C.update(u);if(y!==c&&d){if(S)_(C,s,g[c],e.childNodes.length);else s.insertBefore(C.root,g[c].root);if(n.pos)C[n.pos]=c;g.splice(c,0,g.splice(y,1)[0]);h.splice(c,0,h.splice(y,1)[0]);if(!l)w(C,c)}C._item=u;q(C,"_parent",t)});y(u,g);if(d)s.appendChild(p);else s.insertBefore(p,c);if(l)t.tags[i]=g;h=u.slice()})}function C(e,t,n,r){Z(e,function(e){if(e.nodeType==1){e.isLoop=e.isLoop||(e.parentNode&&e.parentNode.isLoop||A(e,"each"))?1:0;if(n){var i=R(e);if(i&&!e.isLoop)n.push(B(i,{root:e,parent:t},e.innerHTML,t))}if(!e.isLoop||r)re(e,t,[])}})}function L(e,t,n){function r(e,t,r){if(v.hasExpr(t)){var i={dom:e,expr:t};n.push(P(i,r))}}Z(e,function(e){var n=e.nodeType;if(n==3&&e.parentNode.tagName!="STYLE")r(e,e.nodeValue);if(n!=1)return;var i=A(e,"each");if(i){S(e,t,i);return false}$(e.attributes,function(t){var n=t.name,i=n.split("__")[1];r(e,t.value,{attr:i||n,bool:i});if(i){O(e,n);return false}});if(R(e))return false})}function N(e,o,a){var f=n.observable(this),l=te(o.opts)||{},p=m(e.tmpl),g=o.parent,h=o.isLoop,b=o.hasImpl,y=V(o.item),w=[],x=[],_=o.root,S=e.fn,N=_.tagName.toLowerCase(),M={},E=[];if(S&&_._tag)_._tag.unmount(true);this.isMounted=false;_.isLoop=h;_._tag=this;q(this,"_riot_id",++r);P(this,{parent:g,root:_,opts:l,tags:{}},y);$(_.attributes,function(e){var t=e.value;if(v.hasExpr(t))M[e.name]=t});if(p.innerHTML&&!/^(select|optgroup|table|tbody|tr|col(?:group)?)$/.test(N))p.innerHTML=W(p.innerHTML,a);function A(){var e=b&&h?f:g||f;$(_.attributes,function(t){l[j(t.name)]=v(t.value,e)});$(Object.keys(M),function(t){l[j(t)]=v(M[t],e)})}function R(e){for(var t in y){if(typeof f[t]!==c&&U(f,t))f[t]=e[t]}}function H(){if(!f.parent||!h)return;$(Object.keys(f.parent),function(e){var t=!z(d,e)&&z(E,e);if(typeof f[e]===c||t){if(!t)E.push(e);f[e]=f.parent[e]}})}q(this,"update",function(e){e=V(e);H();if(e&&typeof y===s){R(e);y=e}P(f,e);A();f.trigger("update",e);T(w,f);f.trigger("updated");return this});q(this,"mixin",function(){$(arguments,function(e){e=typeof e===u?n.mixin(e):e;$(Object.keys(e),function(t){if(t!="init")f[t]=k(e[t])?e[t].bind(f):e[t]});if(e.init)e.init.bind(f)()});return this});q(this,"mount",function(){A();if(S)S.call(f,l);L(p,f,w);F(true);if(e.attrs||b){G(e.attrs,function(e,t){I(_,e,t)});L(f.root,f,w)}if(!f.parent||h)f.update(y);f.trigger("before-mount");if(h&&!b){f.root=_=p.firstChild}else{while(p.firstChild)_.appendChild(p.firstChild);if(_.stub)f.root=_=g.root}if(h)C(f.root,f.parent,null,true);if(!f.parent||f.parent.isMounted){f.isMounted=true;f.trigger("mount")}else f.parent.one("mount",function(){if(!J(f.root)){f.parent.isMounted=f.isMounted=true;f.trigger("mount")}})});q(this,"unmount",function(e){var n=_,r=n.parentNode,o;f.trigger("before-unmount");i.splice(i.indexOf(f),1);if(this._virts){$(this._virts,function(e){e.parentNode.removeChild(e)})}if(r){if(g){o=K(g);if(Q(o.tags[N]))$(o.tags[N],function(e,t){if(e._riot_id==f._riot_id)o.tags[N].splice(t,1)});else o.tags[N]=t}else while(n.firstChild)n.removeChild(n.firstChild);if(!e)r.removeChild(n);else O(r,"riot-tag")}f.trigger("unmount");F();f.off("*");f.isMounted=false;_._tag=null});function F(e){$(x,function(t){t[e?"mount":"unmount"]()});if(g){var t=e?"on":"off";if(h)g[t]("unmount",f.unmount);else g[t]("update",f.update)[t]("unmount",f.unmount)}}C(p,this,x)}function M(t,n,r,i){r[t]=function(t){var o=i._parent,a=i._item,f;if(!a)while(o&&!a){a=o._item;o=o._parent}t=t||e.event;if(U(t,"currentTarget"))t.currentTarget=r;if(U(t,"target"))t.target=t.srcElement;if(U(t,"which"))t.which=t.charCode||t.keyCode;t.item=a;if(n.call(i,t)!==true&&!/radio|check/.test(r.type)){if(t.preventDefault)t.preventDefault();t.returnValue=false}if(!t.preventUpdate){f=a?K(o):i;f.update()}}}function E(e,t,n){if(e){e.insertBefore(n,t);e.removeChild(t)}}function T(e,t){$(e,function(e,n){var r=e.dom,i=e.attr,o=v(e.expr,t),u=e.dom.parentNode;if(e.bool)o=o?i:false;else if(o==null)o="";if(u&&u.tagName=="TEXTAREA")o=(""+o).replace(/riot-/g,"");if(e.value===o)return;e.value=o;if(!i){r.nodeValue=""+o;return}O(r,i);if(k(o)){M(i,o,r,t)}else if(i=="if"){var c=e.stub,l=function(){E(c.parentNode,c,r)},p=function(){E(r.parentNode,r,c)};if(o){if(c){l();r.inStub=false;if(!J(r)){Z(r,function(e){if(e._tag&&!e._tag.isMounted)e._tag.isMounted=!!e._tag.trigger("mount")})}}}else{c=e.stub=c||document.createTextNode("");if(r.parentNode)p();else(t.parent||t).one("updated",p);r.inStub=true}}else if(/^(show|hide)$/.test(i)){if(i=="hide")o=!o;r.style.display=o?"":"none"}else if(i=="value"){r.value=o}else if(ie(i,a)&&i!=f){if(o)I(r,i.slice(a.length),o)}else{if(e.bool){r[i]=o;if(!o)return}if(typeof o!==s)I(r,i,o)}})}function $(e,t){for(var n=0,r=(e||[]).length,i;n<r;n++){i=e[n];if(i!=null&&t(i,n)===false)n--}return e}function k(e){return typeof e===l||false}function O(e,t){e.removeAttribute(t)}function j(e){return e.replace(/(\-\w)/g,function(e){return e.toUpperCase().replace("-","")})}function A(e,t){return e.getAttribute(t)}function I(e,t,n){e.setAttribute(t,n)}function R(e){return e.tagName&&o[A(e,f)||e.tagName.toLowerCase()]}function H(e,t,n){var r=n.tags[t];if(r){if(!Q(r))if(r!==e)n.tags[t]=[r];if(!z(n.tags[t],e))n.tags[t].push(e)}else{n.tags[t]=e}}function F(e,t,n){var r=e.parent,i;if(!r)return;i=r.tags[t];if(Q(i))i.splice(n,0,i.splice(i.indexOf(e),1)[0]);else H(e,t,r)}function B(e,t,n,r){var i=new N(e,t,n),o=D(t.root),a=K(r);i.parent=a;i._parent=r;H(i,o,a);if(a!==r)H(i,o,r);t.root.innerHTML="";return i}function K(e){var t=e;while(!R(t.root)){if(!t.parent)break;t=t.parent}return t}function q(e,t,n,r){Object.defineProperty(e,t,P({value:n,enumerable:false,writable:false,configurable:false},r));return e}function D(e){var t=R(e),n=A(e,"name"),r=n&&!v.hasExpr(n)?n:t?t.name:e.tagName.toLowerCase();return r}function P(e){var t,n=arguments;for(var r=1;r<n.length;++r){if(t=n[r]){for(var i in t){if(U(e,i))e[i]=t[i]}}}return e}function z(e,t){return~e.indexOf(t)}function Q(e){return Array.isArray(e)||e instanceof Array}function U(e,t){var n=Object.getOwnPropertyDescriptor(e,t);return typeof e[t]===c||n&&n.writable}function V(e){if(!(e instanceof N)&&!(e&&typeof e.trigger==l))return e;var t={};for(var n in e){if(!z(d,n))t[n]=e[n]}return t}function Z(e,t){if(e){if(t(e)===false)return;else{e=e.firstChild;while(e){Z(e,t);e=e.nextSibling}}}}function G(e,t){var n,r=/([-\w]+) ?= ?(?:"([^"]*)|'([^']*)|({[^}]*}))/g;while(n=r.exec(e)){t(n[1].toLowerCase(),n[2]||n[3]||n[4])}}function J(e){while(e){if(e.inStub)return true;e=e.parentNode}return false}function X(e){return document.createElement(e)}function W(e,t){return e.replace(/<yield\s*(?:\/>|>\s*<\/yield\s*>)/gi,t||"")}function Y(e,t){return(t||document).querySelectorAll(e)}function ee(e,t){return(t||document).querySelector(e)}function te(e){function t(){}t.prototype=e;return new t}function ne(e){return A(e,"id")||A(e,"name")}function re(e,t,n){var r=ne(e),i=function(i){if(z(n,r))return;var o=Q(i);if(!i)t[r]=e;else if(!o||o&&!z(i,e)){if(o)i.push(e);else t[r]=[i,e]}};if(!r)return;if(v.hasExpr(r))t.one("updated",function(){r=ne(e);i(t[r])});else i(t[r])}function ie(e,t){return e.slice(0,t.length)===t}var oe=function(){if(!e)return;var t=X("style"),n=ee("style[type=riot]");I(t,"type","text/css");if(n){n.parentNode.replaceChild(t,n);n=null}else document.getElementsByTagName("head")[0].appendChild(t);return t.styleSheet?function(e){t.styleSheet.cssText+=e}:function(e){t.innerHTML+=e}}();function ae(e,t,n){var r=o[t],a=e._innerHTML=e._innerHTML||e.innerHTML;e.innerHTML="";if(r&&e)r=new N(r,{root:e,opts:n},a);if(r&&r.mount){r.mount();if(!z(i,r))i.push(r)}return r}n.util={brackets:h,tmpl:v};n.mixin=function(){var e={};return function(t,n){if(!n)return e[t];e[t]=n}}();n.tag=function(e,t,n,r,i){if(k(r)){i=r;if(/^[\w\-]+\s?=/.test(n)){r=n;n=""}else r=""}if(n){if(k(n))i=n;else if(oe)oe(n)}o[e]={name:e,tmpl:t,attrs:r,fn:i};return e};n.tag2=function(e,t,n,r,i,a){if(n&&oe)oe(n);o[e]={name:e,tmpl:t,attrs:r,fn:i};return e};n.mount=function(e,t,n){var r,i,a=[];function c(e){var t="";$(e,function(e){t+=", *["+f+'="'+e.trim()+'"]'});return t}function l(){var e=Object.keys(o);return e+c(e)}function p(e){var r;if(e.tagName){if(t&&(!(r=A(e,f))||r!=t))I(e,f,t);var i=ae(e,t||e.getAttribute(f)||e.tagName.toLowerCase(),n);if(i)a.push(i)}else if(e.length)$(e,p)}if(typeof t===s){n=t;t=0}if(typeof e===u){if(e==="*")e=i=l();else e+=c(e.split(","));r=e?Y(e):[]}else r=e;if(t==="*"){t=i||l();if(r.tagName)r=Y(t,r);else{var d=[];$(r,function(e){d.push(Y(t,e))});r=d}t=0}if(r.tagName)p(r);else $(r,p);return a};n.update=function(){return $(i,function(e){e.update()})};n.Tag=N;var fe=function(){var t={};function n(n,r){switch(n){case"coffee":r="CoffeeScript";break;case"es6":r="babel";break;default:if(!r)r=n;break}return t[n]=e[r]}function r(e,r){return e in t?t[e]:n(e,r)}var i={jade:function(e,t){return r("jade").render(e,P({pretty:true,doctype:"html"},t))}};var o={stylus:function(e,t,n){var i=r("stylus"),o=r("nib");return o?i(t).use(o()).import("nib").render():i.render(t)}};var a={none:function(e,t){return e},livescript:function(e,t){return r("livescript").compile(e,P({bare:true,header:false},t))},typescript:function(e,t){return r("typescript")(e,t).replace(/\r\n?/g,"\n")},es6:function(e,t){return r("es6").transform(e,P({blacklist:["useStrict","strict","react"],sourceMaps:false,comments:false},t)).code},babel:function(e,t){e="function __parser_babel_wrapper__(){"+e+"}";return r("babel").transform(e,P({presets:["es2015"]},t)).code.replace(/["']use strict["'];[\r\n]+/,"").slice(38,-2)},coffee:function(e,t){return r("coffee").compile(e,P({bare:true},t))}};a.javascript=a.none;a.coffeescript=a.coffee;return{html:i,css:o,js:a,_req:r}}();n.parsers=fe;var ue=function(){var e=n.util.brackets;function t(e,t){return new RegExp(e,t)}var r=t("^(?:disabled|checked|readonly|required|allowfullscreen|auto(?:focus|play)|"+"compact|controls|default|formnovalidate|hidden|inert|ismap|itemscope|loop|"+"multiple|muted|no(?:resize|shade|validate|wrap)?|open|reversed|seamless|"+"selected|sortable|truespeed|typemustmatch)$"),i=["style","src","d"],o=/^(?:input|img|br|wbr|hr|area|base|col|embed|keygen|link|meta|param|source|track)$/,a=/\s*([-\w:\.\xA0-\xFF]+)\s*(?:=\s*('[^']+'|"[^"]+"|\S+))?/g,f=/[ \t]+$/gm,u=null;function s(e){return"'"+(e?e.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r"):"")+"'"}function c(e,t,n,r,i,o){var a=", ",f="}"+(o.length?", "+s(u[8]):"")+");";if(i&&i.slice(-1)!=="\n")f="\n"+f;return"riot.tag2('"+e+"'"+a+s(t)+a+s(n)+a+s(r)+", function(opts) {\n"+i+f}function l(e,t){for(var n in t){if(t.hasOwnProperty(n)){e[n]=t[n]}}return e}function p(e){var t=[],n,o,f,s='"';a.lastIndex=0;while(n=a.exec(e)){o=n[1].toLowerCase();f=n[2];if(!f){t.push(o)}else{if(f[0]!==s)f=s+(f[0]==="'"?f.slice(1,-1):f)+s;if(o==="type"&&f.toLowerCase()==='"number"'){f=s+u[0]+"'number'"+u[1]+s}else if(/\u0001\d/.test(f)){if(r.test(o)){o="__"+o}else if(~i.indexOf(o)){o="riot-"+o}}t.push(o+"="+f)}}return t.join(" ")}function d(t,n,r){if(t&&u[4].test(t)){var i=n.expr&&(n.parser||n.type)?x:0,o=e.split(t),a;for(var f=1;f<o.length;f+=2){a=o[f];if(a[0]==="^")a=a.slice(1);else if(i){a=i(a,n);if(/;\s*$/.test(a))a=a.slice(0,a.search(/;\s*$/))}o[f]=""+(r.push(a.replace(/[\r\n]+/g," ").trim())-1)+u[1]}t=o.join("")}return t}function g(e,t){if(t.length){e=e.replace(/\u0001(\d+)/g,function(e,n){return u[0]+t[n].replace(/"/g,""")})}return e}var h=/<!--(?!>)[\S\s]*?-->/g,v=/<([-\w]+)\s*([^"'\/>]*(?:(?:"[^"]*"|'[^']*'|\/[^>])[^'"\/>]*)*)(\/?)>/g;function m(t,n,r,i){if(!i){u=e.array(n.brackets);t=t.replace(/\r\n?/g,"\n").replace(h,"").replace(f,"")}if(!r)r=[];t=d(t,n,r).replace(v,function(e,t,n,r){t=t.toLowerCase();r=r&&!o.test(t)?"></"+t:"";if(n)t+=" "+p(n);return"<"+t+r+">"});if(!n.whitespace){var a=[],s=/<pre(?:\s+[^'">]+(?:(?:"[^"]*"|'[^']*')[^'">]*)*|\s*)>[\s\S]*<\/pre\s*>/gi;t=t.replace(s,function(e){return""+(a.push(e)-1)+"~"}).trim().replace(/\s+/g," ");if(a.length)t=t.replace(/\u0002(\d+)~/g,function(e,t){return a[t]})}if(n.compact)t=t.replace(/> <([-\w\/])/g,"><$1");return g(t,r)}var b=t("("+e.S_QBLOCKS+")|"+e.R_MLCOMMS.source+"|//[^\r\n]*","g"),y=/^([ \t]*)([$_A-Za-z][$\w]*)\s*(\([^()]*\)\s*{)/m;function w(n){var r,i,o=[],a;n=n.replace(b,function(e,t){return t?e:" "});while(r=n.match(y)){o.push(RegExp.leftContext);n=RegExp.rightContext;a=f(n);i=!/^(?:if|while|for|switch|catch|function)$/.test(r[2]);if(i)r[0]=r[1]+"this."+r[2]+" = function"+r[3];o.push(r[0],n.slice(0,a));n=n.slice(a);if(i&&!/^\s*.\s*bind\b/.test(n))o.push(".bind(this)")}return o.length?o.join("")+n:n;function f(n){var r=t("([{}])|"+e.S_QBLOCKS,"g"),i=1,o;while(i&&(o=r.exec(n))){if(o[1])o[1]==="{"?++i:--i}return i?n.length:r.lastIndex}}function x(e,t,n,r){if(!e)return"";if(!n)n=t.type;var i=t.parser||(n?fe.js[n]:w);if(!i)throw new Error('JS parser not found: "'+n+'"');return i(e,r).replace(f,"")}var _=t("(}|{|^)[ ;]*([^@ ;{}][^{}]*)(?={)|"+e.R_STRINGS.source,"g");function S(e,t){var n=":scope";return t.replace(_,function(t,r,i){if(!i)return t;i=i.replace(/[^,]+/g,function(t){var r=t.trim();if(r&&r!=="from"&&r!=="to"&&r.slice(-1)!=="%"){if(r.indexOf(n)<0)r=n+" "+r;r=r.replace(n,e)+","+r.replace(n,'[riot-tag="'+e+'"]')}return t.slice(-1)===" "?r+" ":r});return r?r+" "+i:i})}function C(t,n,r,i,o){if(r){if(r==="scoped-css"){i=true}else if(fe.css[r]){t=fe.css[r](n,t,o)}else if(r!=="css"){throw new Error('CSS parser not found: "'+r+'"')}}t=t.replace(e.R_MLCOMMS,"").replace(/\s+/g," ").trim();return i?S(n,t):t}var L=/\stype\s*=\s*(?:(['"])(.+?)\1|(\S+))/i,N=/\s*=\s*("(?:\\[\S\s]|[^"\\]*)*"|'(?:\\[\S\s]|[^'\\]*)*'|\{[^}]+}|\S+)/.source;function M(e){if(e){var t=e.match(L);e=t&&(t[2]||t[3])}return e?e.replace("text/",""):""}function E(e,n){if(e){var r=t("\\s"+n+N,"i"),i=e.match(r);e=i&&i[1];if(e)return/^['"]/.test(e)?e.slice(1,-1):e}return""}function T(e){var t=E(e,"options");if(t)t=JSON.parse(t);return t}function $(e,t,n,r){var i=M(n),o=T(n);var a=E(n,"src");if(a&&r){var f=E(n,"charset"),u=path.resolve(path.dirname(r),a);e=require("fs").readFileSync(u,{encoding:f||"utf8"})}return x(e,t,i,o)}var k=/\/>\n|^<(?:\/[\w\-]+\s*|[\w\-]+(?:\s+(?:[-\w:\xA0-\xFF][\S\s]*?)?)?)>\n/;function O(e){var t,n;if(e[e.length-1]===">")return[e,""];t=e.lastIndexOf("<");while(~t){if(n=e.slice(t).match(k)){t+=n.index+n[0].length;return[e.slice(0,t),e.slice(t)]}t=e.lastIndexOf("<",t-1)}return["",e]}function j(e,t,n){var r=fe.html[e];if(!r)throw new Error('Template parser not found: "'+e+'"');return r(t,n)}var A=/^([ \t]*)<([-\w]+)(?:\s+([^'"\/>]+(?:(?:"[^"]*"|'[^']*'|\/[^>])[^'"\/>]*)*)|\s*)?(?:\/>|>[ \t]*\n?([\s\S]*)^\1<\/\2\s*>|>(.*)<\/\2\s*>)/gim,I=/<style(\s+[^>]*)?>\n?([^<]*(?:<(?!\/style\s*>)[^<]*)*)<\/style\s*>/gi,R=t(I.source.replace(/tyle/g,"cript"),"gi");function H(n,r,i){var o,a=[];if(!r)r={};u=e.array(r.brackets);if(r.template)n=j(r.template,n,r.templateOptions);o=i?"//src: "+i+"\n":"";n=o+n.replace(/\r\n?/g,"\n").replace(A,function(e,n,i,o,u,s){var l="",v="",b="",y=[];i=i.toLowerCase();o=!o?"":g(p(d(o,r,y)),y);if(s)u=s;if(u&&(u=u.replace(h,""))&&/\S/.test(u)){if(s)b=m(s,r,y,1);else{u=u.replace(t("^"+n,"gm"),"");u=u.replace(I,function(e,t,n){var o=t&&/\sscoped(\s|=|$)/i.test(t),a=M(t)||r.style;v+=(v?" ":"")+C(n,i,a,o,T(t));return""});u=u.replace(R,function(e,t,n){l+=(l?"\n":"")+$(n,r,t);return""});var w=O(u.replace(f,""));u=w[0];if(u)b=m(u,r,y,1);u=w[1];if(/\S/.test(u))l+=(l?"\n":"")+x(u,r)}}l=/\S/.test(l)?l.replace(/\n{3,}/g,"\n\n"):"";if(r.entities){a.push({tagName:i,html:b,css:v,attribs:o,js:l});return""}return c(i,b,v,o,l,y)});return r.entities?a:n}return H}();n.compile=function(){var r=e.document,i,o;function a(e,t,n){var r=new XMLHttpRequest;r.onreadystatechange=function(){if(r.readyState===4&&(r.status===200||!r.status&&r.responseText.length))t(r.responseText,n,e)};r.open("GET",e,true);r.send("")}function f(e){var t=r.createElement("script"),n=r.documentElement;t.text=e;n.appendChild(t);n.removeChild(t)}function u(e,t){var n=r.querySelectorAll('script[type="riot/tag"]'),u=n.length;function s(){i.trigger("ready");o=true;if(e)e()}function c(e,t,n){f(ue(e,t,n));if(!--u)s()}if(!u)s();else{for(var l=0;l<n.length;++l){var p=n[l],d={template:p.getAttribute("template")},g=p.getAttribute("src");if(t)d=P(d,t);g?a(g,c,d):c(p.innerHTML,d)}}}return function(e,r,s){if(typeof e==="string"){if(typeof r==="object"){s=r;r=false}if(/^\s*</.test(e)){var c=ue(e,s);if(!r)f(c);return c}a(e,function(t){var n=ue(t,s,e);f(n);if(r)r(n,t)})}else{if(typeof e==="function"){s=r;r=e}else{s=e;r=t}if(o)return r&&r();if(i){if(r)i.on("ready",r)}else{i=n.observable();u(r,s)}}}}();var se=n.mount;n.mount=function(e,t,r){var i;n.compile(function(){i=se(e,t,r)});return i};if(typeof exports===s)module.exports=n;else if(typeof define==="function"&&define.amd)define(function(){return e.riot=n});else e.riot=n})(typeof window!="undefined"?window:void 0);
|