UNPKG

ractive

Version:

Next-generation DOM manipulation

2 lines 48.4 kB
(function(t){"use strict";var e,n,i,r,o,s,a,h,c,u,l,p,d,f,g,v,m,y,w,x,b,_,k,N,F,E,S,M,O,L,R,A,T,P,C,j,B,D,V,q,I,z,U,Y,H,J,G,W,X,$,K,Z,Q,te,ee,ne,ie,re=t.document||null,oe={},se={},ae={},he={},ce=function(){},ue={},le="Missing Ractive.parse - cannot parse template. Either preparse or use the version that includes the parser",pe=1,de=2,fe=3,ge=4,ve=7,me=8,ye=30,we={unset:!0},xe={html:"http://www.w3.org/1999/xhtml",mathml:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};try{Object.defineProperty({},"test",{value:0}),Object.defineProperties({},{test:{value:0}}),L=Object.defineProperty,R=Object.defineProperties}catch(be){L=function(t,e,n){t[e]=n.value},R=function(t,e){var n;for(n in e)e.hasOwnProperty(n)&&L(t,n,e[n])}}try{Object.create(null),A=Object.create,T=function(){return Object.create(null)}}catch(be){A=function(){var t=function(){};return function(e,n){var i;return t.prototype=e,i=new t,n&&Object.defineProperties(i,n),i}}(),T=function(){return{}}}var _e,ke,Ne,Fe=function(t){return t.replace(/[A-Z]/g,function(t){return"-"+t.toLowerCase()})};(function(){var t;re&&(t=re.createElement("div"),void 0!==t.style.transition?(ke="transition",Ne="transitionend",_e=!0):void 0!==t.style.webkitTransition?(ke="webkitTransition",Ne="webkitTransitionEnd",_e=!0):_e=!1)})(),F=function(t,n,i,r,o){var s,a,h,c,u;"string"==typeof t?s=t:(s=t.n,t.a?a=t.a:t.d&&(h=new TextFragment({descriptor:t.d,root:n,owner:i,contextStack:parentFragment.contextStack}),a=h.toJson(),h.teardown())),u=n.transitions[s]||e.transitions[s],u&&(c=n._transitionManager,c.push(),u.call(n,i.node,c.pop,a,c.info,o))},k=function(t,e){var n,i=[];for(n=re.createElement("div"),n.innerHTML=t;n.firstChild;)i[i.length]=n.firstChild,e.appendChild(n.firstChild);return i},$=function(t,e){var n,i,r;r=t.parentFragment=e.parentFragment,t.root=r.root,t.contextStack=r.contextStack,t.descriptor=e.descriptor,t.index=e.index||0,t.priority=e.descriptor.p||0,r.parentNode&&(t.parentNode=r.parentNode),t.type=e.descriptor.t,e.descriptor.r&&(r.indexRefs&&void 0!==r.indexRefs[e.descriptor.r]?(i=r.indexRefs[e.descriptor.r],t.indexRef=e.descriptor.r,t.value=i,t.render(t.value)):(n=f(t.root,e.descriptor.r,t.contextStack),n?t.resolve(n):(t.ref=e.descriptor.r,t.root._pendingResolution[t.root._pendingResolution.length]=t,t.descriptor.n&&t.render(!1)))),e.descriptor.x&&(t.expressionResolver=new J(t))},K=function(){var t;t=this.root.get(this.keypath,!0),b(t,this.value)||(this.render(t),this.value=t)},Z=function(t){this.keypath=t,c(this),this.update(),this.expressionResolver&&(this.expressionResolver=null)},function(){var t,e,n;N=function(e,n,i,r,o){var s,a,h,c,u,l,p;for(h=n.descriptor.i,s=i;r>s;s+=1)a=n.fragments[s],c=s-o,u=s,l=n.keypath+"."+(s-o),p=n.keypath+"."+s,a.index+=o,t(a,h,c,u,o,l,p);g(e)},t=function(i,r,o,s,a,h,c){var u,l,p;for(i.indexRefs&&void 0!==i.indexRefs[r]&&(i.indexRefs[r]=s),u=i.contextStack.length;u--;)p=i.contextStack[u],p.substr(0,h.length)===h&&(i.contextStack[u]=p.replace(h,c));for(u=i.items.length;u--;)switch(l=i.items[u],l.type){case ve:e(l,r,o,s,a,h,c);break;case me:t(l.fragment,r,o,s,a,h,c);break;case ge:case de:case fe:n(l,r,o,s,a,h,c)}},e=function(e,n,i,r,o,s,a){var h,c;for(h=e.attributes.length;h--;)c=e.attributes[h],c.fragment&&(t(c.fragment,n,i,r,o,s,a),c.twoway&&c.updateBindings());if(e.proxyFrags)for(h=e.proxyFrags.length;h--;)t(e.proxyFrags[h],n,i,r,o,s,a);e.node._ractive&&(e.node._ractive.keypath.substr(0,s.length)===s&&(e.node._ractive.keypath=e.node._ractive.keypath.replace(s,a)),e.node._ractive.index[n]=r),e.fragment&&t(e.fragment,n,i,r,o,s,a)},n=function(e,n,i,r,o,s,a){var h;if(e.descriptor.x&&(e.keypath&&u(e),e.expressionResolver&&e.expressionResolver.teardown(),e.expressionResolver=new J(e)),e.keypath?e.keypath.substr(0,s.length)===s&&(u(e),e.keypath=e.keypath.replace(s,a),c(e)):e.indexRef===n&&(e.value=r,e.render(r)),e.fragments)for(h=e.fragments.length;h--;)t(e.fragments[h],n,i,r,o,s,a)}}(),function(t){var e,n;G=function(t,i,r,o,s){var a,h;for(this.root=t,this.keypath=i,this.fn=n(r,o.length),this.values=[],this.refs=[],a=o.length;a--;)h=o[a],h[0]?this.values[a]=h[1]:this.refs[this.refs.length]=new e(t,h[1],this,a,s);this.selfUpdating=1>=this.refs.length,this.update()},G.prototype={bubble:function(){this.selfUpdating?this.update():this.deferred||(this.root._defEvals[this.root._defEvals.length]=this,this.deferred=!0)},update:function(){var t;try{t=this.fn.apply(null,this.values)}catch(e){if(this.root.debug)throw e;t=void 0}return b(t,this.value)||(h(this.root,this.keypath),this.root._cache[this.keypath]=t,l(this.root,this.keypath),this.value=t),this},teardown:function(){for(;this.refs.length;)this.refs.pop().teardown();h(this.root,this.keypath),this.root._evaluators[this.keypath]=null},refresh:function(){this.selfUpdating||(this.deferred=!0);for(var t=this.refs.length;t--;)this.refs[t].update();this.deferred&&(this.update(),this.deferred=!1)}},e=function(t,e,n,i,r){this.evaluator=n,this.keypath=e,this.root=t,this.argNum=i,this.type=ye,this.priority=r,this.value=n.values[i]=t.get(e),c(this)},e.prototype={update:function(){var t=this.root.get(this.keypath);b(t,this.value)||(this.evaluator.values[this.argNum]=t,this.evaluator.bubble(),this.value=t)},teardown:function(){u(this)}},n=function(e,n){var i,r;if(e=e.replace(/❖/g,"_"),t[e])return t[e];for(r=[];n--;)r[n]="_"+n;return i=Function(r.join(","),"return("+e+")"),t[e]=i,i}}({}),function(){var t,e;J=function(e){var n,i,r,o,s;for(this.root=e.root,this.mustache=e,this.args=[],this.scouts=[],n=e.descriptor.x,s=e.parentFragment.indexRefs,this.str=n.s,r=this.unresolved=n.r?n.r.length:0,r||this.init(),i=0;r>i;i+=1)o=n.r[i],s&&void 0!==s[o]?this.resolveRef(i,!0,s[o]):this.scouts[this.scouts.length]=new t(this,o,e.contextStack,i)},J.prototype={init:function(){this.keypath=e(this.str,this.args),this.createEvaluator(),this.mustache.resolve(this.keypath)},teardown:function(){for(;this.scouts.length;)this.scouts.pop().teardown()},resolveRef:function(t,e,n){this.args[t]=[e,n],--this.unresolved||this.init()},createEvaluator:function(){this.root._evaluators[this.keypath]?this.root._evaluators[this.keypath].refresh():this.root._evaluators[this.keypath]=new G(this.root,this.keypath,this.str,this.args,this.mustache.priority)}},t=function(t,e,n,i){var r,o;o=this.root=t.root,r=f(o,e,n),r?t.resolveRef(i,!1,r):(this.ref=e,this.argNum=i,this.resolver=t,this.contextStack=n,o._pendingResolution[o._pendingResolution.length]=this)},t.prototype={resolve:function(t){this.keypath=t,this.resolver.resolveRef(this.argNum,!1,t)},teardown:function(){this.keypath||a(this)}},e=function(t,e){var n;return n=t.replace(/❖([0-9]+)/g,function(t,n){return e[n][1]}),"("+n.replace(/[\.\[\]]/g,"-")+")"}}(),function(){var t,n;E=function(i,r){var o,s;if(s=t(i,r))return s;if(s=t(e,r))return s;if(re&&(o=re.getElementById(r),o&&"SCRIPT"===o.tagName)){if(!e.parse)throw Error(le);e.partials[r]=e.parse(o.innerHTML)}return s=e.partials[r],s?n(s):(i.debug&&console&&console.warn&&console.warn('Could not find descriptor for partial "'+r+'"'),[])},t=function(t,i){if(t.partials[i]){if("string"==typeof t.partials[i]){if(!e.parse)throw Error(le);t.partials[i]=e.parse(t.partials[i])}return n(t.partials[i])}},n=function(t){return 1===t.length&&"string"==typeof t[0]?t[0]:t}}(),Q=function(t,e){var n,i,r,o,s;if(t.owner=e.owner,t.root=e.root,t.parentNode=e.parentNode,t.contextStack=e.contextStack||[],t.owner.type===ge&&(t.index=e.index),t.owner.parentFragment&&(o=t.owner.parentFragment.indexRefs)){t.indexRefs=T();for(s in o)t.indexRefs[s]=o[s]}for(e.indexRef&&(t.indexRefs||(t.indexRefs={}),t.indexRefs[e.indexRef]=e.index),t.items=[],r={parentFragment:t},n=e.descriptor?e.descriptor.length:0,i=0;n>i;i+=1)r.descriptor=e.descriptor[i],r.index=i,t.items[t.items.length]=t.createItem(r)},function(){var t,e,n;te=function(i,r){var o;return o={descriptor:i.descriptor.f,root:i.root,parentNode:i.parentNode,owner:i},i.descriptor.n?(n(i,r,!0,o),void 0):(y(r)?t(i,r,o):w(r)?e(i,o):n(i,r,!1,o),void 0)},t=function(t,e,n){var i,r;if(e.length<t.length)for(r=t.fragments.splice(e.length,t.length-e.length);r.length;)r.pop().teardown(!0);else if(e.length>t.length)for(i=t.length;e.length>i;i+=1)n.contextStack=t.contextStack.concat(t.keypath+"."+i),n.index=i,t.descriptor.i&&(n.indexRef=t.descriptor.i),t.fragments[i]=t.createFragment(n);t.length=e.length},e=function(t,e){t.length||(e.contextStack=t.contextStack.concat(t.keypath),e.index=0,t.fragments[0]=t.createFragment(e),t.length=1)},n=function(t,e,n,i){var r,o,s;if(o=y(e)&&0===e.length,r=n?o||!e:e&&!o){if(t.length||(i.contextStack=t.contextStack,i.index=0,t.fragments[0]=t.createFragment(i),t.length=1),t.length>1)for(s=t.fragments.splice(1);s.length;)s.pop().teardown(!0)}else t.length&&(t.teardownFragments(!0),t.length=0)}}(),function(t){var e=function(t,e,n){var i;if("string"==typeof e&&x(n)){if(i=t.get(e),void 0===i&&(i=0),x(i))t.set(e,i+n);else if(t.debug)throw Error("Cannot add to a non-numeric value")}else if(t.debug)throw Error("Bad arguments")};t.add=function(t,n){e(this,t,void 0===n?1:n)},t.subtract=function(t,n){e(this,t,void 0===n?-1:-n)},t.toggle=function(t){var e;if("string"==typeof t)e=this.get(t),this.set(t,!e);else if(this.debug)throw Error("Bad arguments")}}(oe),function(t){var n,i;t.animate=function(t,e,i){var r,o,s;if("object"==typeof t){i=e||{},s=[];for(r in t)t.hasOwnProperty(r)&&(s[s.length]=n(this,r,t[r],i));return{stop:function(){for(;s.length;)s.pop().stop()}}}return i=i||{},o=n(this,t,e,i),{stop:function(){o.stop()}}},i={stop:ce},n=function(t,n,r,o){var s,a,h,c,u;if(u=t.get(n),b(u,r))return i;for(c=ee.animations.length;c--;)ee.animations[c].keypath===n&&ee.animations[c].stop();return o.easing&&(s="function"==typeof o.easing?o.easing:t.easing&&t.easing[o.easing]?t.easing[o.easing]:e.easing[o.easing],"function"!=typeof s&&(s=null)),a=void 0===o.duration?400:o.duration,h=new W({keypath:n,from:u,to:r,root:t,duration:a,easing:s,step:o.step,complete:o.complete}),ee.push(h),t._animations[t._animations.length]=h,h}}(oe),oe.bind=function(t){var e=this._bound;-1===e.indexOf(t)&&(e[e.length]=t,t.init(this))},oe.cancelFullscreen=function(){e.cancelFullscreen(this.el)},oe.fire=function(t){var e,n,i,r=this._subs[t];if(r)for(e=Array.prototype.slice.call(arguments,1),n=0,i=r.length;i>n;n+=1)r[n].apply(this,e)},oe.get=function(t){var e,n,i,r,o,s,a,h,c;if(!t)return this.data;if(e=this._cache,y(t)){if(!t.length)return this.data;i=t.slice(),r=i.join("."),c=!0}else{if(e.hasOwnProperty(t)&&e[t]!==we)return e[t];i=v(t),r=i.join(".")}return!e.hasOwnProperty(r)||e[r]===we||void 0===e[r]&&c?this._evaluators[r]?(h=this._evaluators[r].value,e[r]=h,h):(o=i.pop(),s=i.join("."),a=i.length?this.get(i):this.data,null!==a&&"object"==typeof a&&a!==we?((n=this._cacheMap[s])?-1===n.indexOf(r)&&(n[n.length]=r):this._cacheMap[s]=[r],h=a[o],this.modifyArrays&&("("===r.charAt(0)||!y(h)||h._ractive&&h._ractive.setting||ne(h,r,this)),e[r]=h,h):void 0):e[r]},h=function(t,e){var n,i;if(t.modifyArrays&&"("!==e.charAt(0)&&(n=t._cache[e],y(n)&&!n._ractive.setting&&ie(n,e,t)),t._cache[e]=we,i=t._cacheMap[e])for(;i.length;)h(t,i.pop())},l=function(t,e,n){var i;for(i=0;t._deps.length>i;i+=1)d(t,e,i,n)},d=function(t,e,n,i){var r,o,s,a;if(r=t._deps[n]){if(o=r[e])for(s=o.length;s--;)o[s].update();if(!i&&(a=t._depsMap[e]))for(s=a.length;s--;)d(t,a[s],n)}},p=function(t,e,n){var i,r,o;for(o=e.length,i=0;t._deps.length>i;i+=1)if(t._deps[i])for(r=o;r--;)d(t,e[r],i,n)},g=function(t){for(var e,n;t._defEvals.length;)e=t._defEvals.pop(),e.update().deferred=!1;for(;t._defAttrs.length;)n=t._defAttrs.pop(),n.update().deferred=!1},c=function(t){var e,n,i,r,o,s,a,h;for(s=t.root,a=t.keypath,h=t.priority,e=s._deps[h]||(s._deps[h]={}),n=e[a]||(e[a]=[]),n[n.length]=t,i=v(a);i.length;)i.pop(),r=i.join("."),o=s._depsMap[r]||(s._depsMap[r]=[]),void 0===o[a]&&(o[a]=0,o[o.length]=a),o[a]+=1,a=r},X=function(t,e){var n,i;n=e.el?_(e.el):t.el,n&&!e.append&&(n.innerHTML=""),t._transitionManager=i=S(t,e.complete),t.fragment=new P({descriptor:t.template,root:t,owner:t,parentNode:n}),n&&n.appendChild(t.fragment.docFrag),t.ready=!0,t._transitionManager=null,i.ready=!0,i.active||i.complete()},f=function(t,e,n){var i,r,o,s,a,h;if("."===e)return n[n.length-1];if("."===e.charAt(0))return n[n.length-1]+e;for(i=v(e),r=i.pop(),n=n.concat();n.length;)if(o=n.pop(),s=v(o),a=t.get(s.concat(i)),"object"==typeof a&&null!==a&&a.hasOwnProperty(r)){h=o+"."+e;break}return h||void 0===t.get(e)||(h=e),h},a=function(t){if(t.keypath)u(t);else{var e=t.root._pendingResolution.indexOf(t);-1!==e&&t.root._pendingResolution.splice(e,1)}},u=function(t){var e,n,i,r,o,s,a;for(o=t.root,s=t.keypath,a=t.priority,e=o._deps[a][s],e.splice(e.indexOf(t),1),n=v(s);n.length;)n.pop(),i=n.join("."),r=o._depsMap[i],r[s]-=1,r[s]||(r.splice(r.indexOf(s),1),r[s]=void 0),s=i},oe.link=function(t){var e=this;return function(n){e.set(t,n)}},function(t){var e,n;t.observe=function(t,n,i){var r,o=[];if("object"==typeof t){i=n;for(r in t)t.hasOwnProperty(r)&&(n=t[r],o[o.length]=e(this,r,n,i));return{cancel:function(){for(;o.length;)o.pop().cancel()}}}return e(this,t,n,i)},e=function(t,e,i,r){var o;return o=new n(t,e,i,r),r&&r.init===!1||o.update(),c(o),{cancel:function(){u(o)}}},n=function(t,e,n,i){this.root=t,this.keypath=e,this.callback=n,this.priority=0,this.context=i&&i.context?i.context:t},n.prototype={update:function(){var t;if(t=this.root.get(this.keypath,!0),!b(t,this.value)){try{this.callback.call(this.context,t,this.value)}catch(e){if(this.root.debug)throw e}this.value=t}}}}(oe),oe.off=function(t,e){var n,i;e||(t?this._subs[t]=[]:this._subs={}),n=this._subs[t],n&&(i=n.indexOf(e),-1!==i&&n.splice(i,1))},oe.on=function(t,e){var n,i,r=this;if("object"==typeof t){n=[];for(i in t)t.hasOwnProperty(i)&&(n[n.length]=this.on(i,t[i]));return{cancel:function(){for(;n.length;)n.pop().cancel()}}}return this._subs[t]?this._subs[t].push(e):this._subs[t]=[e],{cancel:function(){r.off(t,e)}}},oe.renderHTML=function(){return console.log(this.fragment),""+this.fragment},oe.requestFullscreen=function(){e.requestFullscreen(this.el)},function(t){var e,n;t.set=function(t,i,r){var o,s,a,h,c,u,l;if(s=[""],o=[],w(t)&&(r=i),u=this._transitionManager,this._transitionManager=l=S(this,r),w(t))for(a in t)t.hasOwnProperty(a)&&(c=v(a),h=c.join("."),i=t[a],e(this,h,c,i,o,s));else c=v(t),h=c.join("."),e(this,h,c,i,o,s);return o.length&&this._pendingResolution.length&&n(this),s.length&&p(this,s,!0),o.length&&p(this,o),g(this),this._transitionManager=u,l.ready=!0,l.active||l.complete(),this.setting||(this.setting=!0,"object"==typeof t?this.fire("set",t):this.fire("set",t,i),this.setting=!1),this},e=function(t,e,n,i,r,o){var s,a,c,u,l,p;if(u=n.slice(),l=[],s=t.get(e),s!==i){for(c=t.data;n.length>1;)a=l[l.length]=n.shift(),c[a]||(p||(p=l.join(".")),c[a]=/^\s*[0-9]+\s*$/.test(n[0])?[]:{}),c=c[a];a=n[0],c[a]=i}else if("object"!=typeof i)return;for(h(t,p||e),r[r.length]=e;u.length>1;)u.pop(),e=u.join("."),-1===o.indexOf(e)&&(o[o.length]=e)},n=function(t){var e,n,i;for(e=t._pendingResolution.length;e--;)n=t._pendingResolution.splice(e,1)[0],(i=f(t,n.ref,n.contextStack))?n.resolve(i):t._pendingResolution[t._pendingResolution.length]=n}}(oe),oe.teardown=function(t){var e,n,i;for(this.fire("teardown"),i=this._transitionManager,this._transitionManager=n=S(this,t),this.fragment.teardown(!0);this._animations[0];)this._animations[0].stop();for(e in this._cache)h(this,e);for(;this._bound.length;)this.unbind(this._bound.pop());this._transitionManager=i,n.ready=!0,n.active||n.complete()},oe.toggleFullscreen=function(){e.isFullscreen(this.el)?this.cancelFullscreen():this.requestFullscreen()},oe.unbind=function(t){var e,n=this._bound;e=n.indexOf(t),-1!==e&&(n.splice(e,1),t.teardown(this))},oe.update=function(t,e){var n,i;return"function"==typeof t&&(e=t),i=this._transitionManager,this._transitionManager=n=S(this,e),h(this,t||""),l(this,t||""),g(this),this._transitionManager=i,n.ready=!0,n.active||n.complete(),"string"==typeof t?this.fire("update",t):this.fire("update"),this},se.backbone=function(t,e){var n,i,r,o,s,a,h;return e&&(e+=".",s=RegExp("^"+e.replace(/\./g,"\\.")),a=e.length),{init:function(c){e?(h=function(t){var n,i;i={};for(n in t)t.hasOwnProperty(n)&&(i[e+n]=t[n]);return i},o=function(t){n||(i=!0,c.set(h(t.changed)),i=!1)},r=function(e,r){i||s.test(e)&&(n=!0,t.set(e.substring(a),r),n=!1)}):(o=function(t){n||(i=!0,c.set(t.changed),i=!1)},r=function(e,r){i||(n=!0,t.set(e,r),n=!1)}),t.on("change",o),c.on("set",r),c.set(e?h(t.attributes):t.attributes)},teardown:function(e){t.off("change",o),e.off("set",r)}}},se.statesman=function(t,e){var n,i,r,o,s,a,h;return e&&(e+=".",s=RegExp("^"+e.replace(/\./g,"\\.")),a=e.length,h=function(t){var n,i;if(t){i={};for(n in t)t.hasOwnProperty(n)&&(i[e+n]=t[n]);return i}}),{init:function(c){var u;e?(o=function(t){n||(i=!0,t=h(t),c.set(t),i=!1)},c.twoway&&(r=function(e,r){i||s.test(e)&&(n=!0,t.set(e.substring(a),r),n=!1)})):(o=function(t){n||(i=!0,c.set(t),i=!1)},c.twoway&&(r=function(e,r){i||(n=!0,t.set(e,r),n=!1)})),t.on("change",o),c.twoway&&c.on("set",r),u=e?h(t.get()):t.get(),u&&c.set(e?h(t.get()):t.get())},teardown:function(e){t.off("change",o),e.off("set",r)}}},n={linear:function(t){return t},easeIn:function(t){return Math.pow(t,3)},easeOut:function(t){return Math.pow(t-1,3)+1},easeInOut:function(t){return 1>(t/=.5)?.5*Math.pow(t,3):.5*(Math.pow(t-2,3)+2)}},ae.tap=function(t,e){var n,i,r,o;return r=5,o=400,n=function(t){var n,i,s,a,h,c;i=t.clientX,s=t.clientY,n=this,a=function(t){e({node:n,original:t}),c()},h=function(t){(Math.abs(t.clientX-i)>=r||Math.abs(t.clientY-s)>=r)&&c()},c=function(){window.removeEventListener("mousemove",h),window.removeEventListener("mouseup",a)},window.addEventListener("mousemove",h),window.addEventListener("mouseup",a),setTimeout(c,o)},t.addEventListener("mousedown",n),i=function(t){var n,i,s,a,h,c,u,l;1===t.touches.length&&(a=t.touches[0],i=a.clientX,s=a.clientY,n=this,h=a.identifier,u=function(t){var i;i=t.changedTouches[0],i.identifier!==h&&l(),t.preventDefault(),e({node:n,original:t}),l()},c=function(t){var e;(1!==t.touches.length||t.touches[0].identifier!==h)&&l(),e=t.touches[0],(Math.abs(e.clientX-i)>=r||Math.abs(e.clientY-s)>=r)&&l()},l=function(){window.removeEventListener("touchmove",c),window.removeEventListener("touchend",u),window.removeEventListener("touchcancel",l)},window.addEventListener("touchmove",c),window.addEventListener("touchend",u),window.addEventListener("touchcancel",l),setTimeout(l,o))},t.addEventListener("touchstart",i),{teardown:function(){t.removeEventListener("mousedown",n),t.removeEventListener("touchstart",i)}}},function(){var t,n,r,o,s,a,h,c,u,l,p,d,f;i=function(t){var n,i;return n=this,i=function(t){l(this,i,t||{})},i.prototype=A(n.prototype),n!==e&&o(i,n),a(i,t),h(i),c(i,t),u(i),i.extend=n.extend,i},p=["data","partials","transitions","eventDefinitions"],d=["el","template","complete","modifyArrays","twoway","lazy","append","preserveWhitespace","sanitize"],f=p.concat(d),o=function(t,e){p.forEach(function(i){e[i]&&(t[i]=n(e[i]))}),d.forEach(function(n){void 0!==e[n]&&(t[n]=e[n])})},s=function(t,e){return/_super/.test(t)?function(){var n=this._super;this._super=e,t.apply(this,arguments),this._super=n}:t},a=function(t,e){var n,i;p.forEach(function(n){var i=e[n];i&&(t[n]?r(t[n],i):t[n]=i)}),d.forEach(function(n){void 0!==e[n]&&(t[n]=e[n])});for(n in e)e.hasOwnProperty(n)&&!t.prototype.hasOwnProperty(n)&&-1===f.indexOf(n)&&(i=e[n],t.prototype[n]="function"==typeof i&&"function"==typeof t.prototype[n]?s(i,t.prototype[n]):i)},h=function(t){var n;if("string"==typeof t.template){if(!e.parse)throw Error(le);if("#"===t.template.charAt(0)&&re){if(n=re.getElementById(t.template.substring(1)),!n||"SCRIPT"!==n.tagName)throw Error("Could not find template element ("+t.template+")");t.template=e.parse(n.innerHTML,t)}else t.template=e.parse(t.template,t)}},c=function(t,e){w(t.template)&&(t.partials||(t.partials={}),r(t.partials,t.template.partials),e.partials&&r(t.partials,e.partials),t.template=t.template.template)},u=function(t){var n,i;if(t.partials)for(n in t.partials)if(t.partials.hasOwnProperty(n)){if("string"==typeof t.partials[n]){if(!e.parse)throw Error(le);i=e.parse(t.partials[n],t)}else i=t.partials[n];t.partials[n]=i}},l=function(i,r,o){!o.template&&r.template&&(o.template=r.template),p.forEach(function(e){o[e]?t(o[e],r[e]):r[e]&&(o[e]=n(r[e]))}),d.forEach(function(t){void 0===o[t]&&void 0!==r[t]&&(o[t]=r[t])}),e.call(i,o),i.init&&i.init.call(i,o)},t=function(t,e){var n;for(n in e)e.hasOwnProperty(n)&&!t.hasOwnProperty(n)&&(t[n]=e[n])},n=function(t){var e,n={};for(e in t)t.hasOwnProperty(e)&&(n[e]=t[e]);return n},r=function(t,e){var n;for(n in e)e.hasOwnProperty(n)&&(t[n]=e[n])}}(),o=function(t,n){return x(t)&&x(n)?e.interpolators.number(+t,+n):y(t)&&y(n)?e.interpolators.array(t,n):w(t)&&w(n)?e.interpolators.object(t,n):function(){return n}},s={number:function(t,e){var n=e-t;return n?function(e){return t+e*n}:function(){return t}},array:function(t,n){var i,r,o,s;for(i=[],r=[],s=o=Math.min(t.length,n.length);s--;)r[s]=e.interpolate(t[s],n[s]);for(s=o;t.length>s;s+=1)i[s]=t[s];for(s=o;n.length>s;s+=1)i[s]=n[s];return function(t){for(var e=o;e--;)i[e]=r[e](t);return i}},object:function(t,n){var i,r,o,s,a=[];o={},r={};for(s in t)t.hasOwnProperty(s)&&(n.hasOwnProperty(s)?(a[a.length]=s,r[s]=e.interpolate(t[s],n[s])):o[s]=t[s]);for(s in n)n.hasOwnProperty(s)&&!t.hasOwnProperty(s)&&(o[s]=n[s]);return i=a.length,function(t){for(var e,n=i;n--;)e=a[n],o[e]=r[e](t);return o}}};var Ee=T();R(Ee,{preserveWhitespace:{enumerable:!0,value:!1},append:{enumerable:!0,value:!1},twoway:{enumerable:!0,value:!0},modifyArrays:{enumerable:!0,value:!0},data:{enumerable:!0,value:{}},lazy:{enumerable:!0,value:!1},debug:{enumerable:!0,value:!1},transitions:{enumerable:!0,value:{}},eventDefinitions:{enumerable:!0,value:{}}}),e=function(t){var n,i,r,o,s,a;for(n in Ee)t.hasOwnProperty(n)||(t[n]="object"==typeof Ee[n]?{}:Ee[n]);if(R(this,{_guid:{value:"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e,n;return e=0|16*Math.random(),n="x"==t?e:8|3&e,n.toString(16)})},_subs:{value:T()},_cache:{value:{}},_cacheMap:{value:T()},_deps:{value:[]},_depsMap:{value:T()},_pendingResolution:{value:[]},_defAttrs:{value:[]},_defEvals:{value:[]},_proxies:{value:T()},_customProxies:{value:T()},_evaluators:{value:T()},_bound:{value:[]},_transitionManager:{value:null,writable:!0},_animations:{value:[]},nodes:{value:{}}}),this.modifyArrays=t.modifyArrays,this.twoway=t.twoway,this.lazy=t.lazy,this.debug=t.debug,t.el&&(this.el=_(t.el),!this.el&&this.debug))throw Error("Could not find container element");if(this.data=t.data||{},this.partials={},this.transitions=t.transitions,this.eventDefinitions=t.eventDefinitions,t.bindings)if(y(t.bindings))for(r=0;t.bindings.length>r;r+=1)this.bind(t.bindings[r]);else this.bind(t.bindings);if(o=t.template,"string"==typeof o){if(!e.parse)throw Error(le);if("#"===o.charAt(0)&&re){if(s=re.getElementById(o.substring(1)),!s)throw Error("Could not find template element ("+o+")");a=e.parse(s.innerHTML,t)}else a=e.parse(o,t)}else a=o;if(w(a)&&(this.partials=a.partials,a=a.template),a&&1===a.length&&"string"==typeof a[0]&&(a=a[0]),this.template=a,t.partials)for(n in t.partials)if(t.partials.hasOwnProperty(n)){if(i=t.partials[n],"string"==typeof i){if(!e.parse)throw Error(le);i=e.parse(i,t)}this.partials[n]=i}for(n in this.partials)this.partials.hasOwnProperty(n)&&1===this.partials[n].length&&"string"==typeof this.partials[n][0]&&(this.partials[n]=this.partials[n][0]);X(this,{el:this.el,append:t.append,complete:t.complete})},function(){var t,e,i,r;re&&(t=function(t,e){var n,i={};for(n=e.length;n--;)i[e[n]]=t[e[n]];return i},e=function(t,e,n,i){for(var r,o=e.length;o--;)r=e[o],t.style[r]=n&&n[r]?"function"==typeof n[r]?n[r](i):n[r]:0},i=function(t,e){var n;if(!e)return t;for(n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t},r=function(r,o,s,a){return"string"==typeof r&&(r=[r]),function(h,c,u,l,p){var d,f,g,v,m,y,w,x,b,_,k;u=Se(u),y=u.duration||o.duration,n=Fe(u.easing||o.easing),w=(u.delay||o.delay||0)+(u.stagger||o.stagger||0)*l.i,x=p?s:a,b=p?a:s,f=window.getComputedStyle(h),m=h.getAttribute("style"),p?(_=h.style.position,k=h.style.visibility,h.style.position="absolute",h.style.visibility="hidden",setTimeout(function(){g=t(f,r),x=s,b=i(g,a),h.style.position=_,h.style.visibility=k,e(h,r,x,u),setTimeout(v,0)},w)):setTimeout(function(){g=t(f,r),x=i(g,a),b=s,e(h,r,x,u),setTimeout(v,0)},w),v=function(){h.style[ke+"Duration"]=y/1e3+"s",h.style[ke+"Properties"]=r.map(Fe).join(","),h.style[ke+"TimingFunction"]=n,d=function(){h.removeEventListener(Ne,d),p&&h.setAttribute("style",m||""),c()},h.addEventListener(Ne,d),e(h,r,b,u)}}},he.slide=r(["height","borderTopWidth","borderBottomWidth","paddingTop","paddingBottom","overflowY"],{duration:400,easing:"easeInOut"},{overflowY:"hidden"},{overflowY:"hidden"}),he.fade=r("opacity",{duration:300,easing:"linear"}),he.fly=r(["opacity","left","position"],{duration:400,easing:"easeOut"},{position:"relative",left:"-500px"},{position:"relative",left:0}))}();var Se=function(t){return"fast"===t?{duration:200}:"slow"===t?{duration:600}:x(t)?{duration:+t}:t||{}};(function(t){var e,n,i;re&&(n=function(t,e,r){var o,s;return 3===t.nodeType?(i(t,e,r),void 0):(o=Array.prototype.slice.call(t.childNodes),s=function(){return o.length?(n(o.shift(),s,r),void 0):(e(),void 0)},s(),void 0)},i=function(t,e,n){var i,r,o,s;return i=t._hiddenData,(r=i.length)?(s=0,o=setInterval(function(){var n,a,h,c,u;n=i.substr(0,s),a=i.substring(s),h=/^\w+/.exec(a),c=h?h[0].length:0,u=Array(c+1).join(" "),t.data=n+u,s===r&&(clearInterval(o),delete t._hiddenData,e()),s+=1},n),void 0):(e(),void 0)},e=function(t,e,i){var r,o,s,a;i=Se(i),r=i.interval||(i.speed?1e3/i.speed:i.duration?t.textContent.length/i.duration:4),o=t.getAttribute("style"),s=window.getComputedStyle(t),t.style.visibility="hidden",setTimeout(function(){var h,c,u;c=s.width,h=s.height,u=s.visibility,a(t),setTimeout(function(){t.style.width=c,t.style.height=h,t.style.visibility="visible",n(t,function(){t.setAttribute("style",o||""),e()},r)},i.delay||0)}),a=function(t){var e,n;if(3===t.nodeType)return t._hiddenData=""+t.data,t.data="",void 0;for(e=Array.prototype.slice.call(t.childNodes),n=e.length;n--;)a(e[n])}},t.typewriter=e)})(he),function(t){var e,n,i,r;if(re){if(t.fullscreenEnabled=re.fullscreenEnabled||re.mozFullScreenEnabled||re.webkitFullscreenEnabled,!t.fullscreenEnabled)return t.requestFullscreen=t.cancelFullscreen=ce,void 0;r=re.createElement("div"),r.requestFullscreen?e="requestFullscreen":r.mozRequestFullScreen?e="mozRequestFullScreen":r.webkitRequestFullscreen&&(e="webkitRequestFullscreen"),t.requestFullscreen=function(t){t[e]&&t[e]()},re.cancelFullscreen?n="cancelFullscreen":re.mozCancelFullScreen?n="mozCancelFullScreen":re.webkitCancelFullScreen&&(n="webkitCancelFullScreen"),t.cancelFullscreen=function(){re[n]()},void 0!==re.fullscreenElement?i="fullscreenElement":void 0!==re.mozFullScreenElement?i="mozFullScreenElement":void 0!==re.webkitFullscreenElement&&(i="webkitFullscreenElement"),t.isFullscreen=function(t){return t===re[i]}}}(e),W=function(t){var n;this.startTime=Date.now();for(n in t)t.hasOwnProperty(n)&&(this[n]=t[n]);this.interpolator=e.interpolate(this.from,this.to),this.running=!0},W.prototype={tick:function(){var t,e,n,i,r;return this.running?(i=Date.now(),t=i-this.startTime,t>=this.duration?(this.root.set(this.keypath,this.to),this.step&&this.step(1,this.to),this.complete&&this.complete(1,this.to),r=this.root._animations.indexOf(this),-1===r&&console&&console.warn&&console.warn("Animation was not found"),this.root._animations.splice(r,1),this.running=!1,!1):(e=this.easing?this.easing(t/this.duration):t/this.duration,n=this.interpolator(e),this.root.set(this.keypath,n),this.step&&this.step(e,n),!0)):!1},stop:function(){var t;this.running=!1,t=this.root._animations.indexOf(this),-1===t&&console&&console.warn&&console.warn("Animation was not found"),this.root._animations.splice(t,1)}},ee={animations:[],tick:function(){var e,n;for(e=0;this.animations.length>e;e+=1)n=this.animations[e],n.tick()||this.animations.splice(e--,1);this.animations.length?t.requestAnimationFrame(this.boundTick):this.running=!1},boundTick:function(){ee.tick()},push:function(t){this.animations[this.animations.length]=t,this.running||(this.running=!0,this.tick())}},function(t,e,n){var i;if(n.requestAnimationFrame)return M=n.requestAnimationFrame,O=n.cancelAnimationFrame,void 0;for(i=0;t.length>i&&!M;++i)M=n[t[i]+"RequestAnimationFrame"],O=n[t[i]+"CancelAnimationFrame"]||n[t[i]+"CancelRequestAnimationFrame"];M||(M=function(t){var i,r,o;return i=Date.now(),r=Math.max(0,16-(i-e)),o=n.setTimeout(function(){t(i+r)},r),e=i+r,o}),O||(O=function(t){n.clearTimeout(t)})}(["ms","moz","webkit","o"],0,t),function(){var t,e,n,i,r,o;ne=function(t,n,i){var r,o,s;t._ractive?(r=t._ractive.roots,o=t._ractive.keypathsByGuid,o[i._guid]||(r[r.length]=i,o[i._guid]=[]),s=o[i._guid],-1===s.indexOf(n)&&(s[s.length]=n)):(L(t,"_ractive",{value:{roots:[i],keypathsByGuid:{}},configurable:!0}),t._ractive.keypathsByGuid[i._guid]=[n],e(t))},ie=function(t,e,i){var r,o,s,a;if(!t._ractive)throw Error("Attempted to remove keypath from non-wrapped array. This error is unexpected - please send a bug report to @rich_harris");if(r=t._ractive.roots,o=t._ractive.keypathsByGuid,!o[i._guid])throw Error("Ractive instance was not listed as a dependent of this array. This error is unexpected - please send a bug report to @rich_harris");if(s=o[i._guid],a=s.indexOf(e),-1===a)throw Error("Attempted to unlink non-linked keypath from array. This error is unexpected - please send a bug report to @rich_harris");s.splice(a,1),s.length||(r.splice(r.indexOf(i),1),o[i._guid]=null),r.length||n(t)},t=function(t,e,n){var i,r,o,s,a,c;c=t._ractive.keypathsByGuid,i=function(t){for(var e=t.length;e--;)r(t[e])},r=function(t){var e=t._transitionManager;t._transitionManager=S(t,ce),o(t,c[t._guid]),t._transitionManager=e},o=function(t,e){for(var n=e.length;n--;)s(t,e[n])},s=function(t,i){var r,o,s,c,u,l,d;for(h(t,i),u=[],l=[],d=0;t._deps.length>d;d+=1)if(r=t._deps[d],r&&(o=r[i])){for(a(t,i,o,u,l),g(t);u.length;)u.pop().smartUpdate(e,n);for(;l.length;)l.pop().update()}for(g(t),c=[],s=v(i);s.length;)s.pop(),c[c.length]=s.join(".");c[c.length]=i+".length",p(t,c,!0)},a=function(t,e,n,i,r){var o,s;for(o=n.length;o--;)s=n[o],s.type===ye?s.update():s.keypath===e&&s.type===ge?i[i.length]=s:r[r.length]=s},i(t._ractive.roots)},i=[],o=["pop","push","reverse","shift","sort","splice","unshift"],o.forEach(function(e){var n=function(){var n=Array.prototype[e].apply(this,arguments);return this._ractive.setting=!0,t(this,e,arguments),this._ractive.setting=!1,n};L(i,e,{value:n})}),r={},r.__proto__?(e=function(t){t.__proto__=i},n=function(t){delete t._ractive,t.__proto__=Array.prototype}):(e=function(t){var e,n;for(e=o.length;e--;)n=o[e],L(t,n,{value:i[n]})},n=function(t){var e;for(e=o.length;e--;)delete t[o[e]];delete t._ractive})}(),function(){var t;t={"accept-charset":"acceptCharset",accesskey:"accessKey",bgcolor:"bgColor","class":"className",codebase:"codeBase",colspan:"colSpan",contenteditable:"contentEditable",datetime:"dateTime",dirname:"dirName","for":"htmlFor","http-equiv":"httpEquiv",ismap:"isMap",maxlength:"maxLength",novalidate:"noValidate",pubdate:"pubDate",readonly:"readOnly",rowspan:"rowSpan",tabindex:"tabIndex",usemap:"useMap"},j=function(e){var n,i,r,o,s,a,h,c,u,l,p;if(n=e.name,i=e.value,r=n.indexOf(":"),-1!==r&&(o=n.substr(0,r),"xmlns"!==o&&(n=n.substring(r+1),this.namespace=xe[o],!this.namespace)))throw'Unknown namespace ("'+o+'")';if(null===i||"string"==typeof i)return e.parentNode&&(this.namespace?e.parentNode.setAttributeNS(this.namespace,n,i):e.parentNode.setAttribute(n,i),"id"===n.toLowerCase()&&(e.root.nodes[i]=e.parentNode)),this.name=n,this.value=i,void 0; if(this.root=e.root,this.element=e.element,this.parentNode=e.parentNode,this.name=n,this.lcName=n.toLowerCase(),this.parentFragment=this.element.parentFragment,this.fragment=new z({descriptor:i,root:this.root,owner:this,contextStack:e.contextStack}),this.parentNode){for(this.parentNode&&!this.namespace&&e.parentNode.namespaceURI===xe.html&&(h=this.lcName,c=t[h]||h,void 0!==e.parentNode[c]&&(this.propertyName=c),("boolean"==typeof e.parentNode[c]||"value"===c)&&(this.useProperty=!0)),this.selfUpdating=!0,u=this.fragment.items.length;u--;)if(l=this.fragment.items[u],l.type!==pe){if(l.type!==de){this.selfUpdating=!1;break}if(p){this.selfUpdating=!1;break}p=!0}this.root.twoway&&(s=this.element.descriptor.e.toLowerCase(),a=!("name"!==c&&"value"!==c&&"checked"!==c||"input"!==s&&"textarea"!==s&&"select"!==s)),a&&(this.isBindable=!0,"name"===c&&(this.isTwowayNameAttr=!0)),this.ready=!0}},j.prototype={bind:function(t){var e,n,i,r,o=this,s=this.parentNode;if(!this.fragment)return!1;if(1!==this.fragment.items.length||this.fragment.items[0].type!==de||!this.fragment.items[0].keypath&&!this.fragment.items[0].ref)return this.root.debug&&console&&console.warn&&console.warn("Not a valid two-way data binding candidate - must be a single interpolator:",this.fragment.items),!1;if(this.interpolator=this.fragment.items[0],this.keypath=this.interpolator.keypath||this.interpolator.descriptor.r,"SELECT"===s.tagName&&"value"===this.propertyName)for(e=s.getElementsByTagName("option"),r=e.length,i=0;r>i;i+=1)if(n=e[i],n.hasAttribute("selected")){this.root.set(this.keypath,n.value);break}"checkbox"===s.type||"radio"===s.type?"name"===this.propertyName?(s.name="{{"+this.keypath+"}}",this.updateViewModel=function(){s.checked&&o.root.set(o.keypath,s.value)}):"checked"===this.propertyName&&(this.updateViewModel=function(){o.root.set(o.keypath,s.checked)}):this.updateViewModel=function(){var t;t=s.value,"0"===t?t=0:""!==t&&(t=+t||t),o.root.set(o.keypath,t)},this.updateViewModel&&(this.twoway=!0,s.addEventListener("change",this.updateViewModel),s.addEventListener("click",this.updateViewModel),s.addEventListener("blur",this.updateViewModel),t||(s.addEventListener("keyup",this.updateViewModel),s.addEventListener("keydown",this.updateViewModel),s.addEventListener("keypress",this.updateViewModel),s.addEventListener("input",this.updateViewModel)))},updateBindings:function(){this.keypath=this.interpolator.keypath||this.interpolator.r,"name"===this.propertyName&&(this.parentNode.name="{{"+this.keypath+"}}")},teardown:function(){this.updateViewModel&&(this.parentNode.removeEventListener("change",this.updateViewModel),this.parentNode.removeEventListener("click",this.updateViewModel),this.parentNode.removeEventListener("blur",this.updateViewModel),this.parentNode.removeEventListener("keyup",this.updateViewModel),this.parentNode.removeEventListener("keydown",this.updateViewModel),this.parentNode.removeEventListener("keypress",this.updateViewModel),this.parentNode.removeEventListener("input",this.updateViewModel)),this.fragment&&this.fragment.teardown()},bubble:function(){this.selfUpdating?this.update():!this.deferred&&this.ready&&(this.root._defAttrs[this.root._defAttrs.length]=this,this.deferred=!0)},update:function(){var t,e;if(!this.ready)return this;if(this.twoway){if(e=this.lcName,t=this.interpolator.value,"name"===e&&("checkbox"===this.parentNode.type||"radio"===this.parentNode.type))return this.parentNode.checked=t===this.parentNode.value?!0:!1,this;if(re.activeElement===this.parentNode)return this}if(t=this.fragment.getValue(),void 0===t&&(t=""),t!==this.value){if(this.useProperty)return this.parentNode[this.propertyName]=t,this;if(this.namespace)return this.parentNode.setAttributeNS(this.namespace,this.name,t),this;"id"===this.lcName&&(void 0!==this.value&&(this.root.nodes[this.value]=void 0),this.root.nodes[t]=this.parentNode),this.parentNode.setAttribute(this.name,t),this.value=t}return this},toString:function(){var t;return null===this.value?this.name:this.fragment?(t=""+this.fragment,this.name+"="+JSON.stringify(t)):this.name+"="+JSON.stringify(this.value)}}}(),C=function(t,e){var n,i,r,o,s,a,h,c,u,l,p,d;if(this.type=ve,n=this.parentFragment=t.parentFragment,i=this.descriptor=t.descriptor,this.root=d=n.root,this.parentNode=n.parentNode,this.index=t.index,this.eventListeners=[],this.customEventListeners=[],this.parentNode){if(i.a&&i.a.xmlns){if(r=i.a.xmlns,"string"!=typeof r)throw Error("Namespace attribute cannot contain mustaches")}else r="svg"===i.e.toLowerCase()?xe.svg:this.parentNode.namespaceURI;this.node=re.createElementNS(r,i.e)}if(i.f&&("string"!=typeof i.f||this.node&&this.node.namespaceURI!==xe.html?(this.fragment=new P({descriptor:i.f,root:d,parentNode:this.node,contextStack:n.contextStack,owner:this}),e&&this.node.appendChild(this.fragment.docFrag)):(this.html=i.f,e&&(this.node.innerHTML=this.html))),e&&i.v)for(o in i.v)if(i.v.hasOwnProperty(o))for(s=o.split("-"),a=s.length;a--;)this.addEventProxy(s[a],i.v[o],n.contextStack);this.attributes=[],l=[];for(c in i.a)i.a.hasOwnProperty(c)&&(u=i.a[c],h=new j({element:this,name:c,value:void 0===u?null:u,root:d,parentNode:this.node,contextStack:n.contextStack}),this.attributes[this.attributes.length]=h,h.isBindable&&l.push(h),h.isTwowayNameAttr?p=h:h.update());if(e){for(;l.length;)l.pop().bind(this.root.lazy);p&&(p.updateViewModel(),p.update()),e.appendChild(this.node),i.t1&&F(i.t1,d,this,n.contextStack,!0)}},C.prototype={addEventProxy:function(t,n,i){var r,o,s,a,h,c,u,l=this.root;if(this.node._ractive||L(this.node,"_ractive",{value:{keypath:i.length?i[i.length-1]:"",index:this.parentFragment.indexRefs}}),r="string"==typeof n?n:n.n,u=t+"="+r,n.a?o=n.a:n.d&&(s=!0,o=new z({descriptor:n.d,root:this.root,owner:this,contextStack:i}),this.proxyFrags||(this.proxyFrags=[]),this.proxyFrags[this.proxyFrags.length]=o),void 0!==o){if(this.node._ractive[u])throw Error("You cannot have two proxy events with the same trigger event ("+u+")");this.node._ractive[u]={dynamic:s,payload:o}}return(a=l.eventDefinitions[t]||e.eventDefinitions[t])?(l._customProxies[u]||(l._customProxies[u]=function(t){var e,n;if(!t.node)throw Error("Proxy event definitions must fire events with a `node` property");t.keypath=t.node._ractive.keypath,t.context=l.get(t.keypath),t.index=t.node._ractive.index,t.node._ractive[u]&&(e=t.node._ractive[u],n=e.dynamic?e.payload.toJson():e.payload),l.fire(r,t,n)}),c=l._customProxies[u],h=a(this.node,c),this.customEventListeners[this.customEventListeners.length]=h,void 0):(void 0!==this.node["on"+t]&&l.debug&&console&&console.warn&&console.warn("Invalid event handler ("+t+")"),l._proxies[u]||(l._proxies[u]=function(t){var e,n,i={node:this,original:t,keypath:this._ractive.keypath,context:l.get(this._ractive.keypath),index:this._ractive.index};this._ractive&&this._ractive[u]&&(e=this._ractive[u],n=e.dynamic?e.payload.toJson():e.payload),l.fire(r,i,n)}),c=l._proxies[u],this.eventListeners[this.eventListeners.length]={n:t,h:c},this.node.addEventListener(t,c),void 0)},teardown:function(t){var e,n=this;for(n.fragment&&n.fragment.teardown(!1);n.attributes.length;)n.attributes.pop().teardown();for(;n.eventListeners.length;)e=n.eventListeners.pop(),n.node.removeEventListener(e.n,e.h);for(;n.customEventListeners.length;)n.customEventListeners.pop().teardown();if(this.proxyFrags)for(;this.proxyFrags.length;)this.proxyFrags.pop().teardown();this.descriptor.t2&&F(this.descriptor.t2,this.root,this,this.parentFragment.contextStack,!1),t&&this.root._transitionManager.nodesToDetach.push(this.node)},firstNode:function(){return this.node},findNextNode:function(){return null},bubble:function(){},toString:function(){var t,e,n;for(t="<"+this.descriptor.e,n=this.attributes.length,e=0;n>e;e+=1)t+=" "+(""+this.attributes[e]);return t+=">",this.html?t+=this.html:this.fragment&&(t+=""+this.fragment),t+="</"+this.descriptor.e+">"}},P=function(t){return t.parentNode&&(this.docFrag=re.createDocumentFragment()),"string"==typeof t.descriptor?(this.html=t.descriptor,this.docFrag&&(this.nodes=k(t.descriptor,this.docFrag)),void 0):(Q(this,t),void 0)},P.prototype={createItem:function(t){if("string"==typeof t.descriptor)return new I(t,this.docFrag);switch(t.descriptor.t){case de:return new D(t,this.docFrag);case ge:return new q(t,this.docFrag);case fe:return new V(t,this.docFrag);case ve:return new C(t,this.docFrag);case me:return new B(t,this.docFrag);default:throw"WTF? not sure what happened here..."}},teardown:function(t){var e;if(t&&this.nodes)for(;this.nodes.length;)e=this.nodes.pop(),e.parentNode.removeChild(e);else if(this.items)for(;this.items.length;)this.items.pop().teardown(t)},firstNode:function(){return this.items&&this.items[0]?this.items[0].firstNode():this.nodes?this.nodes[0]||null:null},findNextNode:function(t){var e=t.index;return this.items[e+1]?this.items[e+1].firstNode():this.owner===this.root?null:this.owner.findNextNode(this)},toString:function(){var t,e,n,i;if(this.html)return this.html;if(t="",!this.items)return t;for(n=this.items.length,e=0;n>e;e+=1)i=this.items[e],t+=""+i;return t}},D=function(t,e){this.type=de,e&&(this.node=re.createTextNode(""),e.appendChild(this.node)),$(this,t)},D.prototype={update:K,resolve:Z,teardown:function(t){a(this),t&&this.parentNode.removeChild(this.node)},render:function(t){this.node&&(this.node.data=void 0===t?"":t)},firstNode:function(){return this.node},toString:function(){var t=void 0!==this.value?""+this.value:"";return t.replace("<","&lt;").replace(">","&gt;")}},B=function(t,e){var n,i=this.parentFragment=t.parentFragment;this.type=me,this.name=t.descriptor.r,n=E(i.root,t.descriptor.r),this.fragment=new P({descriptor:n,root:i.root,parentNode:i.parentNode,contextStack:i.contextStack,owner:this}),e&&e.appendChild(this.fragment.docFrag)},B.prototype={findNextNode:function(){return this.parentFragment.findNextNode(this)},teardown:function(t){this.fragment.teardown(t)},toString:function(){return""+this.fragment}},q=function(t,e){this.type=ge,this.fragments=[],this.length=0,e&&(this.docFrag=re.createDocumentFragment()),this.initialising=!0,$(this,t),e&&e.appendChild(this.docFrag),this.initialising=!1},q.prototype={update:K,resolve:Z,smartUpdate:function(t,e){var n;("push"===t||"unshift"===t||"splice"===t)&&(n={descriptor:this.descriptor.f,root:this.root,parentNode:this.parentNode,owner:this},this.descriptor.i&&(n.indexRef=this.descriptor.i)),this[t]&&this[t](n,e)},pop:function(){this.length&&(this.fragments.pop().teardown(!0),this.length-=1)},push:function(t,e){var n,i,r;for(n=this.length,i=n+e.length,r=n;i>r;r+=1)t.contextStack=this.contextStack.concat(this.keypath+"."+r),t.index=r,this.fragments[r]=this.createFragment(t);this.length+=e.length,this.parentNode.insertBefore(this.docFrag,this.parentFragment.findNextNode(this))},shift:function(){this.splice(null,[0,1])},unshift:function(t,e){this.splice(t,[0,0].concat(Array(e.length)))},splice:function(t,e){var n,i,r,o,s,a,h,c,u;if(e.length&&(a=+(0>e[0]?this.length+e[0]:e[0]),i=Math.max(0,e.length-2),r=void 0!==e[1]?e[1]:this.length-a,o=i-r)){if(0>o){for(h=a-o,s=a;h>s;s+=1)this.fragments[s].teardown(!0);this.fragments.splice(a,-o)}else{for(h=a+o,n=this.fragments[a]?this.fragments[a].firstNode():this.parentFragment.findNextNode(this),c=[a,0].concat(Array(o)),this.fragments.splice.apply(this.fragments,c),s=a;h>s;s+=1)t.contextStack=this.contextStack.concat(this.keypath+"."+s),t.index=s,this.fragments[s]=this.createFragment(t);this.parentNode.insertBefore(this.docFrag,n)}this.length+=o,u=a+i,reassignAffectedFragments(this.root,this,u,this.length,o)}},teardown:function(t){this.teardownFragments(t),a(this)},firstNode:function(){return this.fragments[0]?this.fragments[0].firstNode():this.parentFragment.findNextNode(this)},findNextNode:function(t){return this.fragments[t.index+1]?this.fragments[t.index+1].firstNode():this.parentFragment.findNextNode(this)},teardownFragments:function(t){for(;this.fragments.length;)this.fragments.shift().teardown(t)},render:function(t){te(this,t),this.initialising||this.parentNode.insertBefore(this.docFrag,this.parentFragment.findNextNode(this))},createFragment:function(t){var e=new P(t);return this.docFrag&&this.docFrag.appendChild(e.docFrag),e},toString:function(){var t,e,n;for(t="",e=0,n=this.length,e=0;n>e;e+=1)t+=""+this.fragments[e];return t}},I=function(t,e){this.type=pe,this.descriptor=t.descriptor,e&&(this.node=re.createTextNode(t.descriptor),this.parentNode=t.parentFragment.parentNode,e.appendChild(this.node))},I.prototype={teardown:function(t){t&&this.parentNode.removeChild(this.node)},firstNode:function(){return this.node},toString:function(){return(""+this.descriptor).replace("<","&lt;").replace(">","&gt;")}},V=function(t,e){this.type=fe,e&&(this.nodes=[],this.docFrag=re.createDocumentFragment()),this.initialising=!0,$(this,t),e&&e.appendChild(this.docFrag),this.initialising=!1},V.prototype={update:K,resolve:Z,teardown:function(t){if(t)for(;this.nodes.length;)this.parentNode.removeChild(this.nodes.pop());a(this)},firstNode:function(){return this.nodes[0]?this.nodes[0]:this.parentFragment.findNextNode(this)},render:function(t){for(;this.nodes.length;)this.parentNode.removeChild(this.nodes.pop());return void 0===t?(this.nodes=[],void 0):(this.nodes=k(t,this.docFrag),this.initialising||this.parentNode.insertBefore(this.docFrag,this.parentFragment.findNextNode(this)),void 0)},toString:function(){return void 0!==this.value?this.value:""}},z=function(t){Q(this,t)},z.prototype={createItem:function(t){if("string"==typeof t.descriptor)return new H(t.descriptor);switch(t.descriptor.t){case de:return new U(t);case fe:return new U(t);case ge:return new Y(t);default:throw"Something went wrong in a rather interesting way"}},bubble:function(){this.owner.bubble()},teardown:function(){var t,e;for(t=this.items.length,e=0;t>e;e+=1)this.items[e].teardown()},getValue:function(){var t;return 1===this.items.length&&this.items[0].type===de&&(t=this.items[0].value,void 0!==t)?t:""+this},toString:function(){return this.items.join("")},toJson:function(){var t,e;t=""+this;try{e=JSON.parse(t)}catch(n){e=t}return e}},U=function(t){this.type=de,$(this,t)},U.prototype={update:K,resolve:Z,render:function(t){this.value=t,this.parentFragment.bubble()},teardown:function(){a(this)},toString:function(){return void 0===this.value?"":this.value}},Y=function(t){this.type=ge,this.fragments=[],this.length=0,$(this,t)},Y.prototype={update:K,resolve:Z,teardown:function(){this.teardownFragments(),a(this)},teardownFragments:function(){for(;this.fragments.length;)this.fragments.shift().teardown();this.length=0},bubble:function(){this.value=this.fragments.join(""),this.parentFragment.bubble()},render:function(t){te(this,t),this.parentFragment.bubble()},createFragment:function(t){return new z(t)},toString:function(){return this.fragments.join("")}},H=function(t){this.type=pe,this.text=t},H.prototype={toString:function(){return this.text},teardown:function(){}},_=function(t){var e;return"undefined"!=typeof window&&re&&t?t.nodeType?t:"string"==typeof t&&(e=re.getElementById(t),!e&&re.querySelector&&(e=re.querySelector(t)),e.nodeType)?e:t[0]&&t[0].nodeType?t[0]:null:null},m=Object.prototype.toString,y=function(t){return"[object Array]"===m.call(t)},b=function(t,e){return null===t&&null===e?!0:"object"==typeof t||"object"==typeof e?!1:t===e},x=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},w=function(t){return"[object Object]"===m.call(t)&&"function"!=typeof t},S=function(t,e){var n;return n={active:0,info:{i:0},push:function(){n.active+=1,n.info.i+=1},pop:function(){n.active-=1,!n.active&&n.ready&&n.complete()},complete:function(){var i,r;for(i=n.nodesToDetach.length;i--;)r=n.nodesToDetach.pop(),r.parentNode.removeChild(r);e&&e.call(t)},nodesToDetach:[]}},v=function(t){var e,n,i,r,o;if(ue[t])return ue[t].concat();for(i=[],r=t,n=0;r.length;){if(e=r.indexOf(".",n),-1===e)o=r,r="";else{if("\\"===r.charAt(e-1)&&"\\"!==r.charAt(e-2)){n=e+1;continue}o=r.substr(0,e),n=0}/\[/.test(o)?i=i.concat(o.replace(/\[\s*([0-9]+)\s*\]/g,".$1").split(".")):i[i.length]=o,r=r.substring(e+1)}return ue[t]=i,i.concat()},e.prototype=oe,e.adaptors=se,e.eventDefinitions=ae,e.partials={},e.easing=n,e.extend=i,e.interpolate=o,e.interpolators=s,e.parse=r,e.transitions=he,"undefined"!=typeof module&&module.exports?module.exports=e:"function"==typeof define&&define.amd?define(function(){return e}):t.Ractive=e})(this);