/* Riot v4.0.0-alpha.6, @license MIT */(function(a,b){"object"==typeof exports&&"undefined"!=typeof module?b(exports):"function"==typeof define&&define.amd?define(["exports"],b):(a=a||self,b(a.riot={}))})(this,function(a){"use strict";function b(a){return Array.isArray(a)?a:/^\[object (HTMLCollection|NodeList|Object)\]$/.test(Object.prototype.toString.call(a))&&"number"==typeof a.length?Array.from(a):[a]}function c(a,c,d){const e="string"==typeof c?[c]:c;return la(b(a).map(a=>la(e.map(b=>a[d](b)))))}function d(a,c,d){const e="object"==typeof c?c:{[c]:d},f=Object.keys(e);return b(a).forEach(a=>{f.forEach(b=>a.setAttribute(b,e[b]))}),a}function e(a,b){return c(a,b,"getAttribute")}function f(a){return Array.from(a.attributes).reduce((a,b)=>(a[b.name]=b.value,a),{})}function g(a){return e(a,ga)||a.tagName.toLowerCase()}function h(a,b){return typeof a===b}function i(a){return h(a,"function")}function j(a){throw new Error(a)}function k(a){return i(a)?a.prototype&&a.prototype.constructor?new a:a():a}function l(a,b){return Object.entries(b).forEach(([b,c])=>{a[b]||(a[b]=c)}),a}function m(){return this}function n(a,b){return b.forEach(b=>{a[b]=a[b].bind(a)}),a}function o(a,b,c,d={}){return Object.defineProperty(a,b,{value:c,enumerable:!1,writable:!1,configurable:!0,...d}),a}function p(a,b,c){return Object.entries(b).forEach(([b,d])=>{o(a,b,d,c)}),a}function q(a,b){return a.reduce((a,c)=>{const d=c.evaluate(b);return a[c.name]=d,a},{})}function r(a){const b=a.childNodes;b.forEach(b=>a.removeChild(b))}function s(a,b){return!!a&&!1===!!a(b)}function t({itemName:a,indexName:b,index:c,item:d,scope:e}){const f={[a]:d,...e};return b?{[b]:c,...f}:f}function u(a,b,c){const{condition:d,template:e,childrenMap:f,itemName:g,getKey:h,indexName:j,root:k}=c,l=new Set,m=new Map,n=[],o=[];return a.forEach((a,c)=>{const i=c-l.size,p=t({itemName:g,indexName:j,index:i,item:a,scope:b}),q=h?h(p):i,r=f.get(q);if(s(d,p))return void l.add(r);const u=r?r.tag:e.clone(),v=r?u.el:k.cloneNode();r?n.push(()=>u.update(p)):n.push(()=>u.mount(v,p)),o.push(v),m.set(q,{tag:u,context:p,index:i})}),{newChildrenMap:m,batches:n,futureNodes:o}}function v(a,b){const c=b.parentNode;c.insertBefore(a,b),c.removeChild(b)}function w(a,b){Object.entries(b).forEach(([b,c])=>y(a,{name:b},c))}function x(a,b){Object.keys(b).forEach(b=>a.removeAttribute(b))}function y(a,{name:b},c,d){return b?void("boolean"==typeof c&&(a[b]=c),a[z(c)](b,A(b,c))):void(c?w(a,c):d&&x(a,d))}function z(a){return a&&"object"!=typeof a?Ra:Qa}function A(a,b){return!0===b?a:b}function B(a){return null==a?"":a}function C(a,b){return Sa[a.type](a.node,a,b,a.value)}function D(a,b){return{...Ta,...b,node:a}}function E(a,b,c){return b.reduce((b,d)=>({...b,[d]:b=>a.map(a=>a[d](b))&&c}),{})}function F(a,b=[],c=[]){return a?a({slots:b,attributes:c}):Q(H(b),[...G(b),{expressions:c.map(a=>({type:La,...a}))}])}function G(a){return a.reduce((a,{bindings:b})=>a.concat(b),[])}function H(a){return a.reduce((a,b)=>a+b.html,"")}function I(a,b){const{selector:c,type:d,redundantAttribute:e,expressions:f}=b,g=c?a.querySelector(c):a;return e&&g.removeAttribute(e),(Va[d]||Va[oa])(g,{...b,expressions:f||[]})}function J(a){const b=a.ownerSVGElement;return!!b||null===b}function K(a){const b=document.createElement("template");return b.innerHTML=a,b.content}function L(a,b){const c=b.ownerDocument.importNode(new window.DOMParser().parseFromString(``,"application/xml").documentElement,!0);return c}function M(a,b){return J(a)?L(b,a):K(b)}function N(a,b){a.firstChild&&(b.appendChild(a.firstChild),N(a,b))}function O(a,b){Wa.test(a.tagName)?N(b,a):a.appendChild(b)}function P(a,b){return b&&("string"==typeof b?M(a,b):b)}function Q(a,b=[]){return{...Xa,html:a,bindingsData:b}}function R(a,c){return b("string"==typeof a?(c||document).querySelectorAll(a):a)}function S(a){a.firstChild&&(a.parentNode.insertBefore(a.firstChild,a),S(a)),a.parentNode&&a.parentNode.removeChild(a)}function T(a,b,{name:c,slots:d}){const e=d.find(({id:a})=>a===c);return{...Ya,node:b,name:c,template:e&&Q(e.html,e.bindings).createDOM(a)}}function U(a,b){const c=R("slot",a),d=c.map(c=>{const d=e(c,"name")||"default";return T(a,c,{name:d,slots:b})});return{mount(a){return d.forEach(b=>b.mount(a)),this},update(a){return d.forEach(b=>b.update(a)),this},unmount(a){return d.forEach(b=>b.unmount(a)),this}}}function V(a,...b){return(...c)=>(c=[...b,...c],c.length{const h=X({css:a,template:b,tag:c,name:d})({slots:e,attributes:f,props:g});return{mount(a,b,c){return h.mount(a,c,b)},update(a,b){return h.update(b,a)},unmount(){return h.unmount()}}}}function X({css:a,template:b,tag:c,name:d}){const e=k(c)||{},f=$(e.components);return a&&d&&ab.add(d,a),V(ba)(p(l(e,{...cb,state:{}}),{slots:null,root:null,...bb,css:a,template:b?b(Q,Pa,qa,a=>f[a]||da.get(a)):db}))}function Y(a,b=[],c,d={}){return b.length?c?q(b,c):d:f(a)}function Z(a){return Q(null,[{expressions:(a||[]).map(a=>({type:Pa.ATTRIBUTE,...a}))}])}function $(a={}){return Object.entries(k(a)).reduce((a,[b,c])=>(a[b]=W({name:b,...c}),a),{})}function _(a){return[...fa].reduce((a,b)=>b(a)||a,a)}function aa(a,b){return{...a,...k(b)}}function ba(a,{slots:b,attributes:c,props:d}){const e=Z(c);return n(_(p(Object.create(a),{mount(a,f={},g){return this.props={...d,...Y(a,c,g)},this.state=aa(this.state,f),this[ia]=this.template.createDOM(a).clone(),this[ha]=e.createDOM(a).clone(),a[ea]=this,o(this,"root",a),this.onBeforeMount(this.state,this.props),this[ha].mount(a,g),this[ia].mount(a,this),this[ja]=U(a,b||[]).mount(g),this.onMounted(this.state,this.props),this},update(a={},b){const d=Y(this.root,c,b,this.props);if(!1!==this.shouldUpdate(d,this.props))return this.props=d,this.state=aa(this.state,a),this.onBeforeUpdate(this.state,this.props),b&&(this[ha].update(b),this[ja].update(b)),this[ia].update(this),this.onUpdated(this.state,this.props),this},unmount(a){return this.onBeforeUnmount(this.state,this.props),this[ha].unmount(),this[ja].unmount(),this[ia].unmount(this,!0===a),this.onUnmounted(this.state,this.props),this}})),Object.keys(a).filter(b=>i(a[b])))}function ca(a,b,c){const d=c||g(a);da.has(d)||j(`The component named "${d}" was never registered`);const e=da.get(d)({props:b});return e.mount(a)}const da=new Map,ea=Symbol("riot-component"),fa=new Set,ga="is",ha=Symbol("attributes"),ia=Symbol("template"),ja=Symbol("slots");var ka=Object.freeze({COMPONENTS_IMPLEMENTATION_MAP:da,DOM_COMPONENT_INSTANCE_PROPERTY:ea,PLUGINS_SET:fa,IS_DIRECTIVE:"is",ATTRIBUTES_KEY_SYMBOL:ha,TEMPLATE_KEY_SYMBOL:ia,SLOTS_KEY_SYMBOL:ja});const la=a=>1===a.length?a[0]:a,ma=0,na=1,oa=2,pa=3;var qa={EACH:ma,IF:na,SIMPLE:oa,TAG:pa},ra={};/*! (c) Andrea Giammarchi - ISC */try{ra.Map=Map}catch(a){ra.Map=function(){function a(a){return b=c.indexOf(a),-1{if(2>e-d)b.insertBefore(a(c[d],1),f);else{const g=b.ownerDocument.createDocumentFragment();for(;dc==a,va=a=>a,wa=(a,b,c,d,e,f,g)=>{const h=f-e;if(1>h)return-1;for(;c-b>=h;){let h=b,i=e;for(;h{for(;dc{if(2>e-d)b.removeChild(a(c[d],-1));else{const f=b.ownerDocument.createRange();f.setStartBefore(a(c[d],-1)),f.setEndAfter(a(c[e-1],-1)),f.deleteContents()}},Aa=-1,Ba=1,Ca=0,Da=(a,b,c,d,e,f,g,h)=>{let j=0,l=dg;)--j;l=h+d-j;const p=Array(l);let q=m[j];for(--c;q;){const{newi:a,oldi:b}=q;for(;c>a;)p[--l]=Ba,--c;for(;g>b;)p[--l]=Aa,--g;p[--l]=Ca,--c,--g,q=q.prev}for(;c>=b;)p[--l]=Ba,--c;for(;g>=f;)p[--l]=Aa,--g;return p},Ea=(a,b,e,f,g,h,i)=>{const j=e+h,l=[];let m,n,o,p,q,s,t;outer:for(m=0;m<=j;m++){if(m>50)return null;for(t=m-1,q=m?l[m-1]:[0,0],s=l[m]=[],n=-m;n<=m;n+=2){for(p=n===-m||n!==m&&q[t+n-1]{const k=new sa,l=a.length;let m=g,n=0;for(;n{let d=1,e=b;for(;d>>0;c{Fa(Ea(c,d,f,g,h,j,l)||Da(c,d,e,f,g,h,i,j),a,b,c,d,g,h,k,m)},Ia=(a,b,c,d)=>{d||(d={});const e=d.compare||ua,f=d.node||va,g=null==d.before?null:f(d.before,0),h=b.length;let j=h,k=0,l=c.length,m=0;for(;kp||2>q?(ta(f,a,c,m,l,f(b[k],0)),za(f,a,b,k,j),c):p===q&&xa(c,l,b,k,j,e)?(ta(f,a,c,m,l,ya(f,b,j,h,g)),c):(Ha(f,a,c,m,l,q,b,k,j,p,h,e,g),c)},Ja=Object.seal({childrenMap:null,node:null,root:null,condition:null,evaluate:null,template:null,tags:[],getKey:null,indexName:null,itemName:null,afterPlaceholder:null,placeholder:null,mount(a){return this.update(a)},update(a){const{placeholder:b}=this,c=this.evaluate(a),d=c?Array.from(c):[],e=b.parentNode,{newChildrenMap:f,batches:g,futureNodes:h}=u(d,a,this),i=this.tags[this.tags.length-1];return Ia(e,this.tags,h,{before:i?i.nextSibling:b.nextSibling}),g.forEach(a=>a()),this.childrenMap=f,this.tags=h,this},unmount(){return Array.from(this.childrenMap.values()).forEach(({tag:a,context:b})=>{a.unmount(b,!0)}),this.childrenMap=new Map,this.tags=[],this}}),Ka=Object.seal({node:null,evaluate:null,placeholder:null,template:"",mount(a){return v(this.placeholder,this.node),this.update(a)},update(a){const b=!!this.evaluate(a),c=!this.value&&b,d=this.value&&!b;switch(!0){case c:v(this.node,this.placeholder),this.template&&(this.template=this.template.clone(),this.template.mount(this.node,a));break;case d:v(this.placeholder,this.node),this.unmount(a);break;default:b&&this.template.update(a);}return this.value=b,this},unmount(a){const{template:b}=this;return b&&b.unmount(a),this}}),La=0,Ma=1,Na=2,Oa=3;var Pa={ATTRIBUTE:La,EVENT:Ma,TEXT:Na,VALUE:Oa};const Qa="removeAttribute",Ra="setAttribute";var Sa={[La]:y,[Ma]:function(a,{name:b},c){a[b]=c},[Na]:function(a,{childNodeIndex:b},c){const d=a.childNodes[b],e=B(c);if(d.nodeType===Node.COMMENT_NODE){const b=document.createTextNode(e);a.replaceChild(b,d)}else d.data=B(e)},[Oa]:function(a,b,c){a.value=c}};const Ta=Object.seal({node:null,value:null,mount(a){return this.value=this.evaluate(a),C(this,this.value),this},update(a){const b=this.evaluate(a);return this.value!==b&&(C(this,b),this.value=b),this},unmount(){return this}}),Ua=Object.seal({node:null,evaluate:null,name:null,slots:null,tag:null,attributes:null,getComponent:null,mount(a){return this.update(a)},update(a){const b=this.evaluate(a);return b===this.name?this.tag.update(a):(this.tag&&this.tag.unmount(a),this.name=b,this.tag=F(this.getComponent(b),this.slots,this.attributes),this.tag.mount(this.node,a)),this},unmount(a){return this.tag&&this.tag.unmount(a),this}});var Va={[na]:function(a,{evaluate:b,template:c}){return{...Ka,node:a,evaluate:b,placeholder:document.createTextNode(""),template:c.createDOM(a)}},[oa]:function(a,{expressions:b}){return{...E(b.map(b=>D(a,b)),["mount","update","unmount"])}},[ma]:function(a,{evaluate:b,condition:c,itemName:d,indexName:e,getKey:f,template:g}){const h=document.createTextNode(""),i=a.parentNode,j=a.cloneNode(),k=Array.from(i.childNodes).indexOf(a);return i.insertBefore(h,a),i.removeChild(a),{...Ja,childrenMap:new Map,node:a,root:j,offset:k,condition:c,evaluate:b,template:g.createDOM(a),getKey:f,indexName:e,itemName:d,placeholder:h}},[pa]:function(a,{evaluate:b,getComponent:c,slots:d,attributes:e}){return{...Ua,node:a,evaluate:b,slots:d,attributes:e,getComponent:c}}};const Wa=/svg/i,Xa=Object.freeze({bindings:null,bindingsData:null,html:null,dom:null,el:null,createDOM(a){return this.dom=this.dom||P(a,this.html),this},mount(a,c){if(!a)throw new Error("Please provide DOM node to mount properly your template");return this.el&&this.unmount(c),this.el=a,this.createDOM(a),this.dom&&O(a,this.dom.cloneNode(!0)),this.bindings=this.bindingsData.map(a=>I(this.el,a)),this.bindings.forEach(a=>a.mount(c)),this},update(a){return this.bindings.forEach(c=>c.update(a)),this},unmount(a,b){return this.el&&(this.bindings.forEach(c=>c.unmount(a)),r(this.el),b&&this.el.parentNode.removeChild(this.el),this.el=null),this},clone(){return{...this,el:null}}}),Ya=Object.seal({node:null,name:null,template:null,mount(a){return this.template?(this.template.mount(this.node,a),S(this.node)):this.node.parentNode.removeChild(this.node),this},update(a){return this.template?(this.template.update(a),this):this},unmount(a){return this.template?(this.template.unmount(a),this):this}}),Za=function(){return"undefined"==typeof window?void 0:window}(),$a=new Map,_a=Za&&(()=>{const a=document.createElement("style");return d(a,"type","text/css"),document.head.appendChild(a),a})();var ab={add(a,b){return $a.has(a)||$a.set(a,b),this.inject(),this},inject(){return _a?(_a.innerHTML=[...$a.values()].join("\n"),this):this},remove(a){return _a?($a.has(a)&&($a.delete(a),this.inject()),this):this}};const bb=Object.freeze({$(a){return R(a,this.root)[0]},$$(a){return R(a,this.root)},ref(a){return R(a,this.root).map(a=>a[ea]||a)}}),cb=Object.freeze({shouldUpdate:m,onBeforeMount:m,onMounted:m,onBeforeUpdate:m,onUpdated:m,onBeforeUnmount:m,onUnmounted:m}),db={update:m,mount:m,unmount:m,clone:m,createDOM:m};const{DOM_COMPONENT_INSTANCE_PROPERTY:eb,COMPONENTS_IMPLEMENTATION_MAP:fb,PLUGINS_SET:gb}=ka,hb=((...a)=>a.reduce((a,b)=>(...c)=>a(b(...c))))(a=>a({}),W);a.register=function(a,{css:b,template:c,tag:d}){return fb.has(a)&&j(`The component "${a}" was already registered`),fb.set(a,W({name:a,css:b,template:c,tag:d})),fb},a.unregister=function(a){return fb.has(a)||j(`The component "${a}" was never registered`),fb.delete(a),ab.remove(a),fb},a.mount=function(a,b,c){return R(a).map(a=>ca(a,b,c))},a.unmount=function(a){return R(a).map(a=>(a[eb]&&a[eb].unmount(),a))},a.install=function(a){return i(a)||j("Plugins must be of type function"),gb.has(a)&&j("This plugin was already install"),gb.add(a),gb},a.uninstall=function(a){return gb.has(a)||j("This plugin was never installed"),gb.delete(a),gb},a.component=hb,a.version="v4.0.0-alpha.6",a.__={cssManager:ab,defineComponent:X,globals:ka},Object.defineProperty(a,"__esModule",{value:!0})});