forked from riot/riot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathriot.min.js
2 lines (2 loc) · 24.2 KB
/
riot.min.js
1
2
/* Riot WIP, @license MIT */
var t,e;t=this,e=function(t){"use strict";var _=[],f={},s="yield",x="__global_mixin",b="riot-",u=["ref","data-ref"],p="data-is",h="if",d="each",n="no-reorder",g="show",m="hide",i="key",w="__riot-events__",o="string",A="object",e="undefined",r="function",a="http://www.w3.org/1999/xlink",l="http://www.w3.org/2000/svg",c=/^xlink:(\w+)/,v=typeof window===e?void 0:window,y=/^on/,O=/([-\w]+) ?= ?(?:"([^"]*)|'([^']*)|({[^}]*}))/g,N={viewbox:"viewBox"},C=/^(?:disabled|checked|readonly|required|allowfullscreen|auto(?:focus|play)|compact|controls|default|formnovalidate|hidden|ismap|itemscope|loop|multiple|muted|no(?:resize|shade|validate|wrap)?|open|reversed|seamless|selected|sortable|truespeed|typemustmatch)$/,j=0|(v&&v.document||{}).documentMode;function E(t){return C.test(t)}function T(t){return typeof t===r}function L(t){return t&&typeof t===A}function k(t){return typeof t===e}function M(t){return typeof t===o}function S(t){return k(t)||null===t||""===t}function I(t){return Array.isArray(t)||t instanceof Array}function R(t,e){var n=Object.getOwnPropertyDescriptor(t,e);return k(t[e])||n&&n.writable}var P=Object.freeze({isBoolAttr:E,isFunction:T,isObject:L,isUndefined:k,isString:M,isBlank:S,isArray:I,isWritable:R});function $(t,e){return Array.prototype.slice.call((e||document).querySelectorAll(t))}function H(t,e){return(e||document).querySelector(t)}function V(){return document.createDocumentFragment()}function U(){return document.createTextNode("")}function B(t){return!!t.ownerSVGElement}function z(t){return"svg"===t?document.createElementNS(l,t):document.createElement(t)}function F(t,e){if(k(t.innerHTML)){var n=(new DOMParser).parseFromString(e,"application/xml"),r=t.ownerDocument.importNode(n.documentElement,!0);t.appendChild(r)}else t.innerHTML=e}function D(t,e){t.style.display=e?"":"none",t.hidden=!e}function K(t,e){t.removeAttribute(e)}function q(n){return Object.keys(n).reduce(function(t,e){return t+" "+e+": "+n[e]+";"},"")}function W(t,e){return t.getAttribute(e)}function Z(t,e,n){var r=c.exec(e);r&&r[1]?t.setAttributeNS(a,r[1],n):t.setAttribute(e,n)}function G(t,e,n){t.insertBefore(e,n.parentNode&&n)}function Q(t,e){if(t)for(var n;n=O.exec(t);)e(n[1].toLowerCase(),n[2]||n[3]||n[4])}function J(t,e,n){if(t){var r,i=e(t,n);if(!1===i)return;for(t=t.firstChild;t;)r=t.nextSibling,J(t,e,i),t=r}}var X,Y,tt=Object.freeze({$$:$,$:H,createFrag:V,createDOMPlaceholder:U,isSvg:B,mkEl:z,setInnerHTML:F,toggleVisibility:D,remAttr:K,styleObjectToString:q,getAttr:W,setAttr:Z,safeInsert:G,walkAttrs:Q,walkNodes:J}),et={},nt=[],rt=!1;v&&(X=function(){var t=z("style");Z(t,"type","text/css");var e=H("style[type=riot]");return e?(e.id&&(t.id=e.id),e.parentNode.replaceChild(t,e)):document.getElementsByTagName("head")[0].appendChild(t),t}(),Y=X.styleSheet);var it,ot,at,st,ut={styleNode:X,add:function(t,e){e?et[e]=t:nt.push(t),rt=!0},inject:function(){if(v&&rt){rt=!1;var t=Object.keys(et).map(function(t){return et[t]}).concat(nt).join("\n");Y?Y.cssText=t:X.innerHTML=t}}},lt=(ot=(it=["case","default","do","else","in","instanceof","prefix","return","typeof","void","yield"]).reduce(function(t,e){return t+e.slice(-1)},""),at=/^\/(?=[^*>/])[^[/\\]*(?:(?:\\.|\[(?:\\.|[^\]\\]*)*\])[^[\\/]*)*?\/[gimuy]*/,st=/[$\w]/,function(t,e){var n=/.*/g,r=n.lastIndex=e++,i=n.exec(t)[0].match(at);if(i){var o=r+i[0].length,a=t[r=ct(t,r)];if(r<0||~"[{(,;:?=|&!^~>%*/".indexOf(a))return o;if("."===a)"."===t[r-1]&&(e=o);else if("+"===a||"-"===a)(t[--r]!==a||(r=ct(t,r))<0||!st.test(t[r]))&&(e=o);else if(~ot.indexOf(a)){for(var s=r+1;0<=--r&&st.test(t[r]););~it.indexOf(t.slice(r+1,s))&&(e=o)}}return e});function ct(t,e){for(;0<=--e&&/\s/.test(t[e]););return e}var ft,pt,ht,dt,gt,mt,vt,yt,_t,xt,bt,wt,Ot,Nt=(ht="g",gt=(dt=/"[^"\\]*(?:\\[\S\s][^"\\]*)*"|'[^'\\]*(?:\\[\S\s][^'\\]*)*'|`[^`\\]*(?:\\[\S\s][^`\\]*)*`/g).source+"|"+/(?:\breturn\s+|(?:[$\w\)\]]|\+\+|--)\s*(\/)(?![*\/]))/.source+"|"+/\/(?=[^*\/])[^[\/\\]*(?:(?:\[(?:\\.|[^\]\\]*)*\]|\\.)[^[\/\\]*)*?([^<]\/)[gim]*/.source,mt=RegExp("[\\x00-\\x1F<>a-zA-Z0-9'\",;\\\\]"),vt=/(?=[[\]()*+?.^$|])/g,yt=dt.source+"|"+/(\/)(?![*\/])/.source,_t={"(":RegExp("([()])|"+yt,ht),"[":RegExp("([[\\]])|"+yt,ht),"{":RegExp("([{}])|"+yt,ht)},xt="{ }",bt=["{","}","{","}",/{[^}]*}/,/\\([{}])/g,/\\({)|{/g,RegExp("\\\\(})|([[({])|(})|"+yt,ht),xt,/^\s*{\^?\s*([$\w]+)(?:\s*,\s*(\S+))?\s+in\s+(\S.*)\s*}/,/(^|[^\\]){=[\S\s]*?}/],wt=void 0,Ot=[],Tt.split=function(r,i,e){var t,n,o,a,s,u,l=[],c=(e=e||Ot)[6],f=[],p="";for(n=o=c.lastIndex=0;t=c.exec(r);){if(u=c.lastIndex,a=t.index,n){if(t[2]){var h=t[2],d=_t[h],g=1;for(d.lastIndex=u;t=d.exec(r);)if(t[1]){if(t[1]===h)++g;else if(!--g)break}else d.lastIndex=v(t.index,d.lastIndex,t[2]);c.lastIndex=g?r.length:d.lastIndex;continue}if(!t[3]){c.lastIndex=v(a,u,t[4]);continue}}t[1]||(m(r.slice(o,a)),o=c.lastIndex,(c=e[6+(n^=1)]).lastIndex=o)}return r&&o<r.length&&m(r.slice(o)),l.qblocks=f,l;function m(t){p&&(t=p+t,p=""),i||n?l.push(t&&t.replace(e[5],"$1")):l.push(t)}function v(t,e,n){return n&&(e=lt(r,t)),i&&t+2<e&&(s="⁗"+f.length+"~",f.push(r.slice(t,e)),p+=r.slice(o,t)+s,o=e),e}},Tt.hasExpr=function(t){return Ot[4].test(t)},Tt.loopKeys=function(t){var e=t.match(Ot[9]);return e?{key:e[1],pos:e[2],val:Ot[0]+e[3].trim()+Ot[1]}:{val:t.trim()}},Tt.array=function(t){return t?Et(t):Ot},Object.defineProperty(Tt,"settings",{set:function(t){var e;e=(t=t||{}).brackets,Object.defineProperty(t,"brackets",{set:At,get:function(){return wt},enumerable:!0}),pt=t,At(e)},get:function(){return pt}}),Tt.settings="undefined"!=typeof riot&&riot.settings||{},Tt.set=At,Tt.skipRegex=lt,Tt.R_STRINGS=dt,Tt.R_MLCOMMS=/\/\*[^*]*\*+(?:[^*\/][^*]*\*+)*\//g,Tt.S_QBLOCKS=gt,Tt.S_QBLOCK2=yt,Tt);function Ct(t){return t}function jt(t,e){return e=e||Ot,new RegExp(t.source.replace(/{/g,e[2]).replace(/}/g,e[3]),t.global?ht:"")}function Et(t){if(t===xt)return bt;var e=t.split(" ");if(2!==e.length||mt.test(t))throw new Error('Unsupported brackets "'+t+'"');return(e=e.concat(t.replace(vt,"\\").split(" ")))[4]=jt(1<e[1].length?/{[\S\s]*?}/:bt[4],e),e[5]=jt(3<t.length?/\\({|})/g:bt[5],e),e[6]=jt(bt[6],e),e[7]=RegExp("\\\\("+e[3]+")|([[({])|("+e[3]+")|"+yt,ht),e[8]=t,e}function Tt(t){return t instanceof RegExp?ft(t):Ot[t]}function At(t){(t=t||xt)!==Ot[8]&&(Ot=Et(t),ft=t===xt?Ct:jt,Ot[9]=ft(bt[9])),wt=t}var Lt=function(){var n={};function r(t,e){return t?(n[t]||(n[t]=function(t){var e=function(t){var e,n=Nt.split(t.replace(s,'"'),1),r=n.qblocks;if(2<n.length||n[0]){var i,o,a=[];for(i=o=0;i<n.length;++i)(e=(e=n[i])&&(1&i?l(e,1,r):'"'+e.replace(/\\/g,"\\\\").replace(/\r\n?|\n/g,"\\n").replace(/"/g,'\\"')+'"'))&&(a[o++]=e);e=o<2?a[0]:"["+a.join(",")+'].join("")'}else e=l(n[1],0,r);r.length&&(e=e.replace(u,function(t,e){return r[e].replace(/\r/g,"\\r").replace(/\n/g,"\\n")}));return e}(t);"try{return "!==e.slice(0,11)&&(e="return "+e);return new Function("E",e+";")}(t))).call(e,function(t,e){t.riotData={tagName:e&&e.__&&e.__.tagName,_riot_id:e&&e._riot_id},r.errorHandler?r.errorHandler(t):"undefined"!=typeof console&&"function"==typeof console.error&&(console.error(t.message),console.log("<%s> %s",t.riotData.tagName||"Unknown tag",this.tmpl),console.log(this.data))}.bind({data:e,tmpl:t})):t}r.hasExpr=Nt.hasExpr,r.loopKeys=Nt.loopKeys,r.clearCache=function(){n={}},r.errorHandler=null;var s=/\u2057/g,u=/\u2057(\d+)~/g;var c=/^(?:(-?[_A-Za-z\xA0-\xFF][-\w\xA0-\xFF]*)|\u2057(\d+)~):/,f={"(":/[()]/g,"[":/[[\]]/g,"{":/[{}]/g};function l(o,t,e){if(o=o.replace(/\s+/g," ").trim().replace(/\ ?([[\({},?\.:])\ ?/g,"$1")){for(var n,r=[],i=0;o&&(n=o.match(c))&&!n.index;){var a,s,u=/,|([[{(])|$/g;for(o=RegExp.rightContext,a=n[2]?e[n[2]].slice(1,-1).trim().replace(/\s+/g," "):n[1];s=(n=u.exec(o))[1];)l(s,u);s=o.slice(0,n.index),o=RegExp.rightContext,r[i++]=h(s,1,a)}o=i?1<i?"["+r.join(",")+'].join(" ").trim()':r[0]:h(o,t)}return o;function l(t,e){var n,r=1,i=f[t];for(i.lastIndex=e.lastIndex;n=i.exec(o);)if(n[0]===t)++r;else if(!--r)break;e.lastIndex=r?o.length:i.lastIndex}}var a='"in this?this:'+("object"!=typeof window?"global":"window")+").",i=/[,{][\$\w]+(?=:)|(^ *|[^$\w\.{])(?!(?:typeof|true|false|null|undefined|in|instanceof|is(?:Finite|NaN)|void|NaN|new|Date|RegExp|Math)(?![$\w]))([$_A-Za-z][$\w]*)/g,p=/^(?=(\.[$\w]+))\1(?:[^.[(]|$)/;function h(t,e,n){var o;return t=t.replace(i,function(t,e,n,r,i){return n&&(r=o?0:r+t.length,"this"!==n&&"global"!==n&&"window"!==n?(t=e+'("'+n+a+n,r&&(o="."===(i=i[r])||"("===i||"["===i)):r&&(o=!p.test(i.slice(r)))),t}),o&&(t="try{return "+t+"}catch(e){E(e,this)}"),n?t=(o?"function(){"+t+"}.call(this)":"("+t+")")+'?"'+n+'":""':e&&(t="function(v){"+(o?t.replace("return ","v="):"v=("+t+")")+';return v||v===0?v:""}.call(this)'),t}return r.version=Nt.version="v3.0.8",r}(),kt=function(s){s=s||{};var u={},l=Array.prototype.slice;return Object.defineProperties(s,{on:{value:function(t,e){return"function"==typeof e&&(u[t]=u[t]||[]).push(e),s},enumerable:!1,writable:!1,configurable:!1},off:{value:function(t,e){if("*"!=t||e)if(e)for(var n,r=u[t],i=0;n=r&&r[i];++i)n==e&&r.splice(i--,1);else delete u[t];else u={};return s},enumerable:!1,writable:!1,configurable:!1},one:{value:function(e,n){return s.on(e,function t(){s.off(e,t),n.apply(s,arguments)})},enumerable:!1,writable:!1,configurable:!1},trigger:{value:function(t){var e,n,r,i=arguments,o=arguments.length-1,a=new Array(o);for(r=0;r<o;r++)a[r]=i[r+1];for(e=l.call(u[t]||[],0),r=0;n=e[r];++r)n.apply(s,a);return u["*"]&&"*"!=t&&s.trigger.apply(s,["*",t].concat(a)),s},enumerable:!1,writable:!1,configurable:!1}}),s};function Mt(t,e){for(var n=t?t.length:0,r=0;r<n;++r)e(t[r],r);return t}function St(t,e){return-1!==t.indexOf(e)}function It(t){return t.replace(/-(\w)/g,function(t,e){return e.toUpperCase()})}function Rt(t,e){return t.slice(0,e.length)===e}function Pt(t,e,n,r){return Object.defineProperty(t,e,$t({value:n,enumerable:!1,writable:!1,configurable:!0},r)),t}function $t(t){for(var e,n=arguments,r=1;r<n.length;++r)if(e=n[r])for(var i in e)R(t,i)&&(t[i]=e[i]);return t}var Ht=Object.freeze({each:Mt,contains:St,toCamel:It,startsWith:Rt,defineProperty:Pt,extend:$t}),Vt=$t(Object.create(Nt.settings),{skipAnonymousTags:!0,autoUpdate:!0});function Ut(t,e,n,r){var i,o=function(t,e,n){var r=this.__.parent,i=this.__.item;if(!i)for(;r&&!i;)i=r.__.item,r=r.__.parent;if(R(n,"currentTarget")&&(n.currentTarget=t),R(n,"target")&&(n.target=n.srcElement),R(n,"which")&&(n.which=n.charCode||n.keyCode),n.item=i,e.call(this,n),Vt.autoUpdate&&!n.preventUpdate){var o=Ne(this);o.isMounted&&o.update()}}.bind(r,n,e);n[t]=null,i=t.replace(y,""),St(r.__.listeners,n)||r.__.listeners.push(n),n[w]||(n[w]={}),n[w][t]&&n.removeEventListener(i,n[w][t]),n[w][t]=o,n.addEventListener(i,o,!1)}function Bt(t){if(!this.root||!W(this.root,"virtualized")){var e,n,r,i=t.dom,o=function(t){return t?(t=t.replace(b,""),N[t]&&(t=N[t]),t):null}(t.attr),a=St([g,m],o),s=t.root&&"VIRTUAL"===t.root.tagName,u=i&&(t.parent||i.parentNode),l="style"===o,c="class"===o;if(t._riot_id)t.__.wasCreated?t.update():(t.mount(),s&&Le(t,t.root));else{if(t.update)return t.update();if(e=!S(r=Lt(t.expr,a?$t({},Object.create(this.parent),this):this)),(n=L(r))&&(n=!c&&!l,c?r=Lt(JSON.stringify(r),this):l&&(r=q(r))),!t.attr||t.isAttrRemoved&&e&&!1!==r||(K(i,t.attr),t.isAttrRemoved=!0),t.bool&&(r=!!r&&o),t.isRtag)return function(t,e,n){var r,i=t.tag||t.dom._tag,o=(i?i.__:{}).head,a="VIRTUAL"===t.dom.tagName;i&&t.tagName===n?i.update():(i&&(a&&(r=U(),o.parentNode.insertBefore(r,o)),i.unmount(!0)),M(n)&&(t.impl=f[n],t.impl&&(t.tag=i=Oe(t.impl,{root:t.dom,parent:e,tagName:n},t.dom.innerHTML,e),Mt(t.attrs,function(t){return Z(i.root,t.name,t.value)}),t.tagName=n,i.mount(),a&&Le(i,r||i.root),e.__.onUnmount=function(){var t=i.opts.dataIs;Te(i.parent.tags,t,i),Te(i.__.parent.tags,t,i),i.unmount()})))}(t,this,r);if((!t.wasParsedOnce||t.value!==r)&&(t.value=r,t.wasParsedOnce=!0,!n||a)){if(S(r)&&(r=""),!o)return r+="",void(u&&("TEXTAREA"===(t.parent=u).tagName?(u.value=r,j||(i.nodeValue=r)):i.nodeValue=r));T(r)?Ut(o,r,i,this):a?D(i,o===m?!r:r):(t.bool&&(i[o]=r),"value"===o&&i.value!==r?i.value=r:e&&!1!==r&&Z(i,o,r),l&&i.hidden&&D(i,!1))}}}}function zt(t){Mt(t,Bt.bind(this))}var Ft={init:function(t,e,n){K(t,h),this.tag=e,this.expr=n,this.stub=U();var r=(this.pristine=t).parentNode;return r.insertBefore(this.stub,t),r.removeChild(t),this},update:function(){this.value=Lt(this.expr,this.tag),this.value&&!this.current?(this.current=this.pristine.cloneNode(!0),this.stub.parentNode.insertBefore(this.current,this.stub),this.expressions=[],Zt.apply(this.tag,[this.current,this.expressions,!0])):!this.value&&this.current&&(Ce(this.expressions),this.current._tag?this.current._tag.unmount():this.current.parentNode&&this.current.parentNode.removeChild(this.current),this.current=null,this.expressions=[]),this.value&&zt.call(this.tag,this.expressions)},unmount:function(){Ce(this.expressions||[])}},Dt={init:function(t,e,n,r){return this.dom=t,this.attr=n,this.rawValue=r,this.parent=e,this.hasExp=Lt.hasExpr(r),this},update:function(){var t=this.value,e=this.parent&&Ne(this.parent),n=this.dom.__ref||this.tag||this.dom;this.value=this.hasExp?Lt(this.rawValue,this.parent):this.rawValue,!S(t)&&e&&Te(e.refs,t,n),!S(this.value)&&M(this.value)?(e&&Ee(e.refs,this.value,n,null,this.parent.__.index),this.value!==t&&Z(this.dom,this.attr,this.value)):K(this.dom,this.attr),this.dom.__ref||(this.dom.__ref=n)},unmount:function(){var t=this.tag||this.dom,e=this.parent&&Ne(this.parent);!S(this.value)&&e&&Te(e.refs,this.value,t)}};function Kt(t,e,n,r){var i=r?Object.create(r):{};return i[t.key]=e,t.pos&&(i[t.pos]=n),i}function qt(t,e){t.splice(e,1),this.unmount(),Te(this.parent,this,this.__.tagName,!0)}function Wt(g,m,v){var y,_=typeof W(g,n)!==o||K(g,n),x=W(g,i),b=!!x&&Lt.hasExpr(x),w=je(g),O=f[w],t=g.parentNode,e=U(),N=xe(g),r=W(g,h),C=[],j=!f[w],E="VIRTUAL"===g.tagName,T=[];return K(g,d),K(g,i),(v=Lt.loopKeys(v)).isLoop=!0,r&&K(g,h),t.insertBefore(e,g),t.removeChild(g),v.update=function(){v.value=Lt(v.val,m);var f=v.value,p=V(),n=!I(f)&&!M(f),h=e.parentNode,d=[];h&&(n?f=(y=f||!1)?Object.keys(f).map(function(t){return Kt(v,f[t],t)}):[]:y=!1,r&&(f=f.filter(function(t,e){return v.key&&!n?!!Lt(r,Kt(v,t,e,m)):!!Lt(r,$t(Object.create(m),t))})),Mt(f,function(t,e){var n=!y&&v.key?Kt(v,t,e):t,r=function(t,e,n,r){return t?r?Lt(t,n):e[t]:e}(x,t,n,b),i=_&&typeof t===A&&!y,o=T.indexOf(r),a=-1===o,s=!a&&i?o:e,u=C[s],l=e>=T.length,c=i&&a||!i&&!u;c?((u=new _e(O,{parent:m,isLoop:!0,isAnonymous:j,tagName:w,root:g.cloneNode(j),item:n,index:e},g.innerHTML)).mount(),l?function(t,e){e?ke.call(this,t):t.appendChild(this.root)}.apply(u,[p||h,E]):function(t,e,n){n?ke.apply(this,[t,e]):G(t,this.root,e.root)}.apply(u,[h,C[e],E]),l||T.splice(e,0,n),C.splice(e,0,u),N&&Ee(m.tags,w,u,!0)):s!==e&&i&&((x||St(f,T[s]))&&(function(t,e,n){n?Me.apply(this,[t,e]):G(t,this.root,e.root)}.apply(u,[h,C[e],E]),C.splice(e,0,C.splice(s,1)[0]),T.splice(e,0,T.splice(s,1)[0])),v.pos&&(u[v.pos]=e),!N&&u.tags&&function(e){var n=this;Mt(Object.keys(this.tags),function(t){we.apply(n.tags[t],[t,e])})}.call(u,e)),u.__.item=n,u.__.index=e,u.__.parent=m,d[e]=r,c||u.update(n)}),function(t,e){for(var n=e.length,r=t.length;r<n;)qt.apply(e[--n],[e,n])}(f,C),T=d.slice(),h.insertBefore(p,e))},v.unmount=function(){Mt(C,function(t){t.unmount()})},v}function Zt(l,t,c){var f=this;J(l,function(t,e){var n,r,i,o=t.nodeType,a=e.parent;if(!c&&t===l)return{parent:a};if(3===o&&"STYLE"!==t.parentNode.tagName&&Lt.hasExpr(t.nodeValue)&&a.children.push({dom:t,expr:t.nodeValue}),1!==o)return e;var s="VIRTUAL"===t.tagName;if(n=W(t,d))return s&&Z(t,"loopVirtual",!0),a.children.push(Wt(t,f,n)),!1;if(n=W(t,h))return a.children.push(Object.create(Ft).init(t,f,n)),!1;if((r=W(t,p))&&Lt.hasExpr(r))return a.children.push({isRtag:!0,expr:r,dom:t,attrs:[].slice.call(t.attributes)}),!1;if(i=xe(t),s&&(W(t,"virtualized")&&t.parentElement.removeChild(t),i||W(t,"virtualized")||W(t,"loopVirtual")||(i={tmpl:t.outerHTML})),i&&(t!==l||c)){if(!s||W(t,p))return a.children.push(Oe(i,{root:t,parent:f},t.innerHTML,f)),!1;Z(t,"virtualized",!0);var u=new _e({tmpl:t.outerHTML},{root:t,parent:f},t.innerHTML);a.children.push(u)}return Gt.apply(f,[t,t.attributes,function(t,e){e&&a.children.push(e)}]),{parent:a}},{parent:{children:t}})}function Gt(i,t,o){var a=this;Mt(t,function(t){if(!t)return!1;var e,n=t.name,r=E(n);St(u,n)&&i.tagName.toLowerCase()!==s?e=Object.create(Dt).init(i,a,n,t.value):Lt.hasExpr(t.value)&&(e={dom:i,expr:t.value,attr:n,bool:r}),o(t,e)})}var Qt=/<yield\b/i,Jt=/<yield\s*(?:\/>|>([\S\s]*?)<\/yield\s*>|>)/gi,Xt=/<yield\s+to=['"]([^'">]*)['"]\s*>([\S\s]*?)<\/yield\s*>/gi,Yt=/<yield\s+from=['"]?([-\w]+)['"]?\s*(?:\/>|>([\S\s]*?)<\/yield\s*>)/gi,te={tr:"tbody",th:"tr",td:"tr",col:"colgroup"},ee=j&&j<10?/^(?:t(?:body|head|foot|[rhd])|caption|col(?:group)?|opt(?:ion|group))$/:/^(?:t(?:body|head|foot|[rhd])|caption|col(?:group)?)$/,ne="div",re="svg";function ie(t,e,n){var r=t&&t.match(/^\s*<([-\w]+)/),i=r&&r[1].toLowerCase(),o=z(n?re:ne);return t=function(t,n){if(!Qt.test(t))return t;var r={};return n=n&&n.replace(Xt,function(t,e,n){return r[e]=r[e]||n,""}).trim(),t.replace(Yt,function(t,e,n){return r[e]||n||""}).replace(Jt,function(t,e){return n||e||""})}(t,e),ee.test(i)?o=function(t,e,n){var r="o"===n[0],i=r?"select>":"table>";if(t.innerHTML="<"+i+e.trim()+"</"+i,i=t.firstChild,r)i.selectedIndex=-1;else{var o=te[n];o&&1===i.childElementCount&&(i=H(o,i))}return i}(o,t,i):F(o,t),o}function oe(t,e){var n=this,r=n.name,i=n.tmpl,o=n.css,a=n.attrs,s=n.onCreate;return f[r]||(ae(r,i,o,a,s),f[r].class=this.constructor),Ae(t,r,e,this),o&&ut.inject(),this}function ae(t,e,n,r,i){return T(r)&&(i=r,/^[\w-]+\s?=/.test(n)?(r=n,n=""):r=""),n&&(T(n)?i=n:ut.add(n)),t=t.toLowerCase(),f[t]={name:t,tmpl:e,attrs:r,fn:i},t}function se(t,e,n,r,i){return n&&ut.add(n,t),f[t]={name:t,tmpl:e,attrs:r,fn:i},t}function ue(t,i,o){var e,n,a=[];if(ut.inject(),L(i)&&(o=i,i=0),e=M(t)?(t="*"===t?n=Se():t+Se(t.split(/, */)))?$(t):[]:t,"*"===i){if(i=n||Se(),e.tagName)e=$(i,e);else{var r=[];Mt(e,function(t){return r.push($(i,t))}),e=r}i=0}return function t(e){if(e.tagName){var n,r=W(e,p);i&&r!==i&&Z(e,p,r=i),(n=Ae(e,r||e.tagName.toLowerCase(),o))&&a.push(n)}else e.length&&Mt(e,t)}(e),a}var le={},ce=le[x]={},fe=0;function pe(t,e,n){if(L(t))pe("__"+fe+++"__",t,!0);else{var r=n?ce:le;if(!e){if(k(r[t]))throw new Error("Unregistered mixin: "+t);return r[t]}r[t]=T(e)?$t(e.prototype,r[t]||{})&&e:$t(r[t]||{},e)}}function he(){return Mt(_,function(t){return t.update()})}function de(t){f[t]=null}var ge=Object.freeze({Tag:oe,tag:ae,tag2:se,mount:ue,mixin:pe,update:he,unregister:de,version:"WIP"}),me=0;function ve(t,e,n,r,i){if(!t||!n){var o=!n&&t?this:e||this;Mt(i,function(t){t.expr&&zt.call(o,[t.expr]),r[It(t.name).replace(b,"")]=t.expr?t.expr.value:t.value})}}function ye(t){var e=this.__.isAnonymous;Pt(this,"isMounted",t),e||(t?this.trigger("mount"):(this.trigger("unmount"),this.off("*"),this.__.wasCreated=!1))}function _e(a,t,e){void 0===a&&(a={}),void 0===t&&(t={});var i,s=$t({},t.opts),u=t.parent,o=t.isLoop,l=!!t.isAnonymous,c=Vt.skipAnonymousTags&&l,f=t.item,n=t.index,p=[],h=[],d=[],g=t.root,m=t.tagName||je(g),v="virtual"===m,y=!v&&!a.tmpl,r=[];c||kt(this),a.name&&g._tag&&g._tag.unmount(!0),Pt(this,"isMounted",!1),Pt(this,"__",{isAnonymous:l,instAttrs:p,innerHTML:e,tagName:m,index:n,isLoop:o,isInline:y,listeners:[],virts:[],wasCreated:!1,tail:null,head:null,parent:null,item:null}),Pt(this,"_riot_id",++me),Pt(this,"root",g),$t(this,{opts:s},f),Pt(this,"parent",u||null),Pt(this,"tags",{}),Pt(this,"refs",{}),i=y||o&&l?g:(v||(g.innerHTML=""),ie(a.tmpl,e,B(g))),Pt(this,"update",function(t){var e={},n=this.isMounted&&!c;return $t(this,t),ve.apply(this,[o,u,l,e,p]),n&&this.isMounted&&T(this.shouldUpdate)&&!this.shouldUpdate(t,e)||(o&&l&&be.apply(this,[this.parent,r]),$t(s,e),n&&this.trigger("update",t),zt.call(this,d),n&&this.trigger("updated")),this}.bind(this)),Pt(this,"mixin",function(){var a=this;return Mt(arguments,function(t){var r,e,n=[],i=["init","__proto__"];t=M(t)?pe(t):t,r=T(t)?new t:t;for(var o=Object.getPrototypeOf(r);n=n.concat(Object.getOwnPropertyNames(e||r)),e=Object.getPrototypeOf(e||r););Mt(n,function(t){if(!St(i,t)){var e=Object.getOwnPropertyDescriptor(r,t)||Object.getOwnPropertyDescriptor(o,t),n=e&&(e.get||e.set);!a.hasOwnProperty(t)&&n?Object.defineProperty(a,t,e):a[t]=T(r[t])?r[t].bind(a):r[t]}}),r.init&&r.init.bind(a)(s)}),this}.bind(this)),Pt(this,"mount",function(){var n=this;g._tag=this,Gt.apply(u,[g,g.attributes,function(t,e){!l&&Dt.isPrototypeOf(e)&&(e.tag=n),t.expr=e,p.push(t)}]),h=[],Q(a.attrs,function(t,e){h.push({name:t,value:e})}),Gt.apply(this,[g,h,function(t,e){e?d.push(e):Z(g,t.name,t.value)}]),ve.apply(this,[o,u,l,s,p]);var t=pe(x);if(t&&!c)for(var e in t)t.hasOwnProperty(e)&&n.mixin(t[e]);if(a.fn&&a.fn.call(this,s),c||this.trigger("before-mount"),Zt.apply(this,[i,d,l]),this.update(f),!l&&!y)for(;i.firstChild;)g.appendChild(i.firstChild);if(Pt(this,"root",g),!c&&this.parent){var r=Ne(this.parent);r.one(r.isMounted?"updated":"mount",function(){ye.call(n,!0)})}else ye.call(this,!0);return this.__.wasCreated=!0,this}.bind(this)),Pt(this,"unmount",function(t){var e,n=this,r=this.root,i=r.parentNode,o=_.indexOf(this);return c||this.trigger("before-unmount"),Q(a.attrs,function(t){Rt(t,b)&&(t=t.slice(b.length)),K(g,t)}),this.__.listeners.forEach(function(e){Object.keys(e[w]).forEach(function(t){e.removeEventListener(t,e[w][t])})}),-1!==o&&_.splice(o,1),(i||v)&&(u?(e=Ne(u),v?Object.keys(this.tags).forEach(function(t){Te(e.tags,t,n.tags[t])}):(Te(e.tags,m,this),u!==e&&Te(u.tags,m,this))):F(r,""),i&&!t&&i.removeChild(r)),this.__.virts&&Mt(this.__.virts,function(t){t.parentNode&&t.parentNode.removeChild(t)}),Ce(d),Mt(p,function(t){return t.expr&&t.expr.unmount&&t.expr.unmount()}),this.__.onUnmount&&this.__.onUnmount(),this.isMounted||ye.call(this,!0),ye.call(this,!1),delete this.root._tag,this}.bind(this))}function xe(t){return t.tagName&&f[W(t,p)||W(t,p)||t.tagName.toLowerCase()]}function be(n,r){var i=this;Mt(Object.keys(n),function(t){var e=St(r,t);(k(i[t])||e)&&(e||r.push(t),i[t]=n[t])})}function we(t,e){var n,r=this.parent;r&&(I(n=r.tags[t])?n.splice(e,0,n.splice(n.indexOf(this),1)[0]):Ee(r.tags,t,this))}function Oe(t,e,n,r){var i=new _e(t,e,n),o=e.tagName||je(e.root,!0),a=Ne(r);return Pt(i,"parent",a),i.__.parent=r,Ee(a.tags,o,i),a!==r&&Ee(r.tags,o,i),i}function Ne(t){for(var e=t;e.__.isAnonymous&&e.parent;)e=e.parent;return e}function Ce(t){Mt(t,function(t){t instanceof _e?t.unmount(!0):t.tagName?t.tag.unmount(!0):t.unmount&&t.unmount()})}function je(t,e){var n=xe(t),r=!e&&W(t,p);return r&&!Lt.hasExpr(r)?r:n?n.name:t.tagName.toLowerCase()}function Ee(t,e,n,r,i){var o=t[e],a=I(o),s=!k(i);if(!o||o!==n)if(!o&&r)t[e]=[n];else if(o)if(a){var u=o.indexOf(n);if(u===i)return;-1!==u&&o.splice(u,1),s?o.splice(i,0,n):o.push(n)}else t[e]=[o,n];else t[e]=n}function Te(t,e,n,r){if(I(t[e])){var i=t[e].indexOf(n);-1!==i&&t[e].splice(i,1),t[e].length?1!==t[e].length||r||(t[e]=t[e][0]):delete t[e]}else delete t[e]}function Ae(t,e,n,r){var i=f[e],o=f[e].class,a=r||(o?Object.create(o.prototype):{}),s=t._innerHTML=t._innerHTML||t.innerHTML,u=$t({root:t,opts:n},{parent:n?n.parent:null});return i&&t&&_e.apply(a,[i,u,s]),a&&a.mount&&(a.mount(!0),St(_,a)||_.push(a)),a}function Le(t,e){var n=V();ke.call(t,n),e.parentNode.replaceChild(n,e)}function ke(t,e){var n,r,i=U(),o=U(),a=V();for(this.root.insertBefore(i,this.root.firstChild),this.root.appendChild(o),this.__.head=r=i,this.__.tail=o;r;)n=r.nextSibling,a.appendChild(r),this.__.virts.push(r),r=n;e?t.insertBefore(a,e.__.head):t.appendChild(a)}function Me(t,e){for(var n,r=this.__.head,i=V();r;)if(n=r.nextSibling,i.appendChild(r),(r=n)===this.__.tail){i.appendChild(r),t.insertBefore(i,e.__.head);break}}function Se(t){if(t)return t.filter(function(t){return!/[^-\w]/.test(t)}).reduce(function(t,e){var n=e.trim().toLowerCase();return t+",["+p+'="'+n+'"]'},"");var e=Object.keys(f);return e+Se(e)}var Ie=Object.freeze({getTag:xe,inheritFrom:be,moveChildTag:we,initChildTag:Oe,getImmediateCustomParentTag:Ne,unmountAll:Ce,getTagName:je,arrayishAdd:Ee,arrayishRemove:Te,mountTo:Ae,makeReplaceVirtual:Le,makeVirtual:ke,moveVirtual:Me,selectTags:Se}),Re=Vt,Pe={tmpl:Lt,brackets:Nt,styleManager:ut,vdom:_,styleNode:ut.styleNode,dom:tt,check:P,misc:Ht,tags:Ie},$e=oe,He=ae,Ve=se,Ue=ue,Be=pe,ze=he,Fe=de,De=kt,Ke=$t({},ge,{observable:kt,settings:Re,util:Pe});t.settings=Re,t.util=Pe,t.Tag=$e,t.tag=He,t.tag2=Ve,t.mount=Ue,t.mixin=Be,t.update=ze,t.unregister=Fe,t.version="WIP",t.observable=De,t.default=Ke,Object.defineProperty(t,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.riot={});