-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathriot.min.js
2 lines (2 loc) · 17.9 KB
/
riot.min.js
1
2
/* Riot v2.3.1, @license MIT, (c) 2015 Muut Inc. + contributors */
(function(e,t){"use strict";var n={version:"v2.3.1",settings:{}},r=0,i=[],o={},f="riot-",u=f+"tag",a="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 f=0;f<i;f++){o[f]=arguments[f+1]}n(r,function(n){var r=(t[n]||[]).slice(0);for(var i=0,f;f=r[i];++i){if(f.busy)return;f.busy=1;try{f.apply(e,f.typed?[n].concat(o):o)}catch(u){}if(r[i]!==f){i--}f.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,f="hasAttribute",u="replace",a="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,y,w,x,_=[],N=0;function L(e){return e.split(/[\/?#]/)}function C(e,t){var n=new RegExp("^"+t[u](/\*/g,"([^/?#]+?)")[u](/\.\./,".*")+"$"),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 T(e){return e[u](/^\/|\/$/,"")}function E(e){return typeof e=="string"}function S(e){return(e||d.href)[u](n,"")}function $(e){return b[0]=="#"?(e||d.href).split(b)[1]||"":S(e)[u](b,"")}function k(e){var t=N==0;if(c<=N)return;N++;_.push(function(){var t=$();if(e||t!=y){m[s]("emit",t);y=t}});if(t){while(_.length){_[0]();_.shift()}N=0}}function A(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[f]("download")||!t[f]("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])return;O($(t.href),t.title||p.title)}e.preventDefault()}function O(e,t){t=t||p.title;history.pushState(null,t,b+T(e));p.title=t;k()}g.m=function(e,t){if(E(e)&&(!t||E(t)))O(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=="@"?w:x)(T(e),T(t));if(n){this[s].apply(null,[t].concat(n));return true}},this)};g.r=function(e,t){if(e!="@"){e="/"+T(e);this.$.push(e)}this.on(e,t)};var H=new M;var j=H.m.bind(H);j.create=function(){var e=new M;e.m.stop=e.s.bind(e);return e.m.bind(e)};j.base=function(e){b=e||"#";y=$()};j.exec=function(){k(true)};j.parser=function(e,t){if(!e&&!t){w=L;x=C}if(e)w=e;if(t)x=t};j.query=function(){var e={};d.href[u](/[?&](.+?)=([^&]*)/g,function(t,n,r){e[n]=r});return e};j.stop=function(){if(v){l[i](a,k);p[i](h,A);m[s]("stop");v=false}};j.start=function(e){if(!v){l[o](a,k);p[o](h,A);v=true}if(e)k(true)};j.base();j.parser();t.route=j})(n);var h=function(e){var t="g",r=/\/\*[^*]*\*+(?:[^*\/][^*]*\*+)*\//g,i=/"[^"\\]*(?:\\[\S\s][^"\\]*)*"|'[^'\\]*(?:\\[\S\s][^'\\]*)*'/g,o=i.source+"|"+/(?:[$\w\)\]]|\+\+|--)\s*(\/)(?![*\/])/.source+"|"+/\/(?=[^*\/])[^[\/\\]*(?:(?:\[(?:\\.|[^\]\\]*)*\]|\\.)[^[\/\\]*)*?(\/)[gim]*/.source,f="{ }",u={"(":l("([()])|"+o,t),"[":l("([[\\]])|"+o,t),"{":l("([{}])|"+o,t)};var a=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||f;if(e!==c[8]){var n=e.split(" ");if(e===f){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]=l(/^\s*{\^?\s*([$\w]+)(?:\s*,\s*(\S+))?\s+in\s+(\S+)\s*}/);c[8]=e}v.settings.brackets=a=e}function h(e){if(a!==e){g(e)}}function v(e){h(v.settings.brackets);return e instanceof RegExp?s(e):c[e]}v.split=function m(e,t){var n=[],r,i,o,f,a=v(6);i=o=a.lastIndex=0;while(r=a.exec(e)){f=r.index;if(i){if(r[2]){a.lastIndex=l(r[2],a.lastIndex);continue}if(!r[3])continue}if(!r[1]){s(e.slice(o,f));o=a.lastIndex;a=c[6+(i^=1)];a.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=u[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}};v.hasExpr=function b(e){return v(4).test(e)};v.loopKeys=function y(e){var t=e.match(v(9));return t?{key:t[1],pos:t[2],val:c[0]+t[3]+c[1]}:{val:e.trim()}};v.array=function w(e){if(e!=null)g(e);return c};v.settings=typeof n!=="undefined"&&n.settings||{};v.set=h;v.R_STRINGS=i;v.R_MLCOMMS=r;v.S_QBLOCKS=o;g(v.settings.brackets);return v}();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=a(e);if(t.slice(0,11)!=="try{return ")t="return "+t;return new Function("E",t+";")}var f=new RegExp(h.S_QBLOCKS,"g"),u=/\x01(\d+)~/g;function a(e){var t=[],n,r=h.split(e,1);if(r.length>2||r[0]){var i,o,f=[];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,'\\"')+'"'))f[o++]=n}n=o<2?f[0]:"["+f.join(",")+'].join("")'}else{n=l(r[1],0,t)}if(t[0])n=n.replace(u,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(f,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 u,a,c=/,|([[{(])|$/g;e=RegExp.rightContext;u=o[2]?n[o[2]].slice(1,-1).trim().replace(/\s+/g," "):o[1];while(a=(o=c.exec(e))[1])l(a,c);a=e.slice(0,o.index);e=RegExp.rightContext;r[i++]=g(a,1,u)}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]+)/),f=o&&o[1].toLowerCase(),u=t[f]||n,a=W(u);a.stub=true;if(e&&f&&(o=f.match(p)))i(a,r,f,!!o[1]);else a.innerHTML=r;return a}function i(e,t,r,i){var o=W(n),f=i?"select>":"table>",u;o.innerHTML="<"+f+t+"</"+f;u=ee(r,o);if(u)e.appendChild(u)}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){B(e,n,t)});else B(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 f=i.nextSibling;t.insertBefore(i,n._root);i=f}}function N(e,t,n){A(e,"each");var r=typeof H(e,"no-reorder")!==a||A(e,"no-reorder"),i=P(e),f=o[i]||{tmpl:e.outerHTML},u=p.test(i),s=e.parentNode,c=p.test(i),l=document.createTextNode(""),d=I(e),g=[],h=[],m,N=e.tagName=="VIRTUAL";n=v.loopKeys(n);s.insertBefore(l,e);t.one("before-mount",function(){e.parentNode.removeChild(e);if(s.stub)s=t.root}).on("update",function(){var a=v(n.val,t),p=document.createDocumentFragment();if(!q(a)){m=a?JSON.stringify(a):"";a=!a?[]:Object.keys(a).map(function(e){return b(n,e,a[e])})}$(a,function(a,c){var l=r&&a instanceof Object,v=h.indexOf(a),y=~v&&l?v:c,L=g[y];a=!m&&n.key?b(n,a,c):a;if(!l&&!L||l&&!~v||!L){L=new M(f,{parent:t,isLoop:true,hasImpl:!!o[i],root:u?s:e.cloneNode(),item:a},e.innerHTML);L.mount();if(N)L._root=L.root.firstChild;if(c==g.length){if(N)x(L,p);else p.appendChild(L.root)}else{if(N)x(L,s,g[c]);else s.insertBefore(L.root,g[c].root);h.splice(c,0,a)}g.splice(c,0,L);y=c}else L.update(a);if(y!==c&&l){if(N)_(L,s,g[c],e.childNodes.length);else s.insertBefore(L.root,g[c].root);if(n.pos)L[n.pos]=c;g.splice(c,0,g.splice(y,1)[0]);h.splice(c,0,h.splice(y,1)[0]);if(!d)w(L,c)}L._item=a;D(L,"_parent",t)});y(a,g);if(c)s.appendChild(p);else s.insertBefore(p,l);if(d)t.tags[i]=g;h=a.slice()})}function L(e,t,n,r){Q(e,function(e){if(e.nodeType==1){e.isLoop=e.isLoop||(e.parentNode&&e.parentNode.isLoop||H(e,"each"))?1:0;if(n){var i=I(e);if(i&&!e.isLoop)n.push(K(i,{root:e,parent:t},e.innerHTML,t))}if(!e.isLoop||r)re(e,t,[])}})}function C(e,t,n){function r(e,t,r){if(v.hasExpr(t)){var i={dom:e,expr:t};n.push(U(i,r))}}Q(e,function(e){var n=e.nodeType;if(n==3&&e.parentNode.tagName!="STYLE")r(e,e.nodeValue);if(n!=1)return;var i=H(e,"each");if(i){N(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){A(e,n);return false}});if(I(e))return false})}function M(e,o,f){var u=n.observable(this),l=te(o.opts)||{},p=m(e.tmpl),g=o.parent,h=o.isLoop,b=o.hasImpl,y=Z(o.item),w=[],x=[],_=o.root,N=e.fn,M=_.tagName.toLowerCase(),T={},E=[];if(N&&_._tag)_._tag.unmount(true);this.isMounted=false;_.isLoop=h;_._tag=this;D(this,"_riot_id",++r);U(this,{parent:g,root:_,opts:l,tags:{}},y);$(_.attributes,function(e){var t=e.value;if(v.hasExpr(t))T[e.name]=t});if(p.innerHTML&&!/^(select|optgroup|table|tbody|tr|col(?:group)?)$/.test(M))p.innerHTML=X(p.innerHTML,f);function H(){var e=b&&h?u:g||u;$(_.attributes,function(t){l[O(t.name)]=v(t.value,e)});$(Object.keys(T),function(t){l[O(t)]=v(T[t],e)})}function I(e){for(var t in y){if(typeof u[t]!==c&&z(u,t))u[t]=e[t]}}function R(){if(!u.parent||!h)return;$(Object.keys(u.parent),function(e){var t=!V(d,e)&&V(E,e);if(typeof u[e]===c||t){if(!t)E.push(e);u[e]=u.parent[e]}})}D(this,"update",function(e){e=Z(e);R();if(e&&typeof y===s){I(e);y=e}U(u,e);H();u.trigger("update",e);S(w,u);u.trigger("updated");return this});D(this,"mixin",function(){$(arguments,function(e){e=typeof e===a?n.mixin(e):e;$(Object.keys(e),function(t){if(t!="init")u[t]=k(e[t])?e[t].bind(u):e[t]});if(e.init)e.init.bind(u)()});return this});D(this,"mount",function(){H();if(N)N.call(u,l);C(p,u,w);B(true);if(e.attrs||b){G(e.attrs,function(e,t){j(_,e,t)});C(u.root,u,w)}if(!u.parent||h)u.update(y);u.trigger("before-mount");if(h&&!b){u.root=_=p.firstChild}else{while(p.firstChild)_.appendChild(p.firstChild);if(_.stub)u.root=_=g.root}if(h)L(u.root,u.parent,null,true);if(!u.parent||u.parent.isMounted){u.isMounted=true;u.trigger("mount")}else u.parent.one("mount",function(){if(!J(u.root)){u.parent.isMounted=u.isMounted=true;u.trigger("mount")}})});D(this,"unmount",function(e){var n=_,r=n.parentNode,o;u.trigger("before-unmount");i.splice(i.indexOf(u),1);if(this._virts){$(this._virts,function(e){e.parentNode.removeChild(e)})}if(r){if(g){o=F(g);if(q(o.tags[M]))$(o.tags[M],function(e,t){if(e._riot_id==u._riot_id)o.tags[M].splice(t,1)});else o.tags[M]=t}else while(n.firstChild)n.removeChild(n.firstChild);if(!e)r.removeChild(n);else A(r,"riot-tag")}u.trigger("unmount");B();u.off("*");u.isMounted=false;_._tag=null});function B(e){$(x,function(t){t[e?"mount":"unmount"]()});if(g){var t=e?"on":"off";if(h)g[t]("unmount",u.unmount);else g[t]("update",u.update)[t]("unmount",u.unmount)}}L(p,this,x)}function T(t,n,r,i){r[t]=function(t){var o=i._parent,f=i._item,u;if(!f)while(o&&!f){f=o._item;o=o._parent}t=t||e.event;if(z(t,"currentTarget"))t.currentTarget=r;if(z(t,"target"))t.target=t.srcElement;if(z(t,"which"))t.which=t.charCode||t.keyCode;t.item=f;if(n.call(i,t)!==true&&!/radio|check/.test(r.type)){if(t.preventDefault)t.preventDefault();t.returnValue=false}if(!t.preventUpdate){u=f?F(o):i;u.update()}}}function E(e,t,n){if(e){e.insertBefore(n,t);e.removeChild(t)}}function S(e,t){$(e,function(e,n){var r=e.dom,i=e.attr,o=v(e.expr,t),a=e.dom.parentNode;if(e.bool)o=o?i:false;else if(o==null)o="";if(a&&a.tagName=="TEXTAREA")o=(""+o).replace(/riot-/g,"");if(e.value===o)return;e.value=o;if(!i){r.nodeValue=""+o;return}A(r,i);if(k(o)){T(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)){Q(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,f)&&i!=u){if(o)j(r,i.slice(f.length),o)}else{if(e.bool){r[i]=o;if(!o)return}if(typeof o!==s)j(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 A(e,t){e.removeAttribute(t)}function O(e){return e.replace(/(\-\w)/g,function(e){return e.toUpperCase().replace("-","")})}function H(e,t){return e.getAttribute(t)}function j(e,t,n){e.setAttribute(t,n)}function I(e){return e.tagName&&o[H(e,u)||e.tagName.toLowerCase()]}function R(e,t,n){var r=n.tags[t];if(r){if(!q(r))if(r!==e)n.tags[t]=[r];if(!V(n.tags[t],e))n.tags[t].push(e)}else{n.tags[t]=e}}function B(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 R(e,t,r)}function K(e,t,n,r){var i=new M(e,t,n),o=P(t.root),f=F(r);i.parent=f;i._parent=r;R(i,o,f);if(f!==r)R(i,o,r);t.root.innerHTML="";return i}function F(e){var t=e;while(!I(t.root)){if(!t.parent)break;t=t.parent}return t}function D(e,t,n,r){Object.defineProperty(e,t,U({value:n,enumerable:false,writable:false,configurable:false},r));return e}function P(e){var t=I(e),n=H(e,"name"),r=n&&!v.hasExpr(n)?n:t?t.name:e.tagName.toLowerCase();return r}function U(e){var t,n=arguments;for(var r=1;r<n.length;++r){if(t=n[r]){for(var i in t){if(z(e,i))e[i]=t[i]}}}return e}function V(e,t){return~e.indexOf(t)}function q(e){return Array.isArray(e)||e instanceof Array}function z(e,t){var n=Object.getOwnPropertyDescriptor(e,t);return typeof e[t]===c||n&&n.writable}function Z(e){if(!(e instanceof M)&&!(e&&typeof e.trigger==l))return e;var t={};for(var n in e){if(!V(d,n))t[n]=e[n]}return t}function Q(e,t){if(e){if(t(e)===false)return;else{e=e.firstChild;while(e){Q(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 W(e){return document.createElement(e)}function X(e,t){return e.replace(/<(yield)\/?>(<\/\1>)?/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 H(e,"id")||H(e,"name")}function re(e,t,n){var r=ne(e),i=function(i){if(V(n,r))return;var o=q(i);if(!i)t[r]=e;else if(!o||o&&!V(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=W("style"),n=ee("style[type=riot]");j(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 fe(e,t,n){var r=o[t],f=e._innerHTML=e._innerHTML||e.innerHTML;e.innerHTML="";if(r&&e)r=new M(r,{root:e,opts:n},f);if(r&&r.mount){r.mount();if(!V(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,f){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,f=[];function c(e){var t="";$(e,function(e){t+=", *["+u+'="'+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=H(e,u))||r!=t))j(e,u,t);var i=fe(e,t||e.getAttribute(u)||e.tagName.toLowerCase(),n);if(i)f.push(i)}else if(e.length)$(e,p)}if(typeof t===s){n=t;t=0}if(typeof e===a){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 f};n.update=function(){return $(i,function(e){e.update()})};n.Tag=M;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);