ractive
Version:
Next-generation DOM manipulation
12 lines (9 loc) • 137 kB
JavaScript
/*
Ractive.js v0.4.0
2014-04-08 - commit 276c0e2b
http://ractivejs.org
http://twitter.com/RactiveJS
Released under the MIT License.
*/
!function(a){"use strict";var b=a.Ractive,c=void 0,d=function(){var a,b;return a={el:null,template:"",complete:null,preserveWhitespace:!1,append:!1,twoway:!0,modifyArrays:!0,lazy:!1,debug:!1,noIntro:!1,transitionsEnabled:!0,magic:!1,noCssTransform:!1,adapt:[],sanitize:!1,stripComments:!0,isolated:!1,delimiters:["{{","}}"],tripleDelimiters:["{{{","}}}"],computed:null},b={keys:Object.keys(a),defaults:a}}(c),e=function(){return"undefined"!=typeof document?document&&document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure","1.1"):void 0}(),f={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/"},g=function(a,b){return a?function(a,c){return c&&c!==b.html?document.createElementNS(c,a):document.createElement(a)}:function(a,c){if(c&&c!==b.html)throw"This browser does not support namespaces other than http://www.w3.org/1999/xhtml. The most likely cause of this error is that you're trying to render SVG in an older browser. See http://docs.ractivejs.org/latest/svg-and-older-browsers for more information";return document.createElement(a)}}(e,f),h="object"==typeof document,i=function(a){try{return Object.defineProperty({},"test",{value:0}),a&&Object.defineProperty(document.createElement("div"),"test",{value:0}),Object.defineProperty}catch(b){return function(a,b,c){a[b]=c.value}}}(h),j=function(a,b,c){try{try{Object.defineProperties({},{test:{value:0}})}catch(d){throw d}return c&&Object.defineProperties(a("div"),{test:{value:0}}),Object.defineProperties}catch(d){return function(a,c){var d;for(d in c)c.hasOwnProperty(d)&&b(a,d,c[d])}}}(g,i,h),k=function(a){return!isNaN(parseFloat(a))&&isFinite(a)},l=function(a){return function(b,c,d){var e;if("string"!=typeof c||!a(d))throw new Error("Bad arguments");if(e=+b.get(c)||0,!a(e))throw new Error("Cannot add to a non-numeric value");return b.set(c,e+d)}}(k),m=function(a){return function(b,c){return a(this,b,void 0===c?1:+c)}}(l),n=function(a,b){return null===a&&null===b?!0:"object"==typeof a||"object"==typeof b?!1:a===b},o=function(){function a(a){setTimeout(a,0)}function b(a,b){return function(){for(var c;c=a.shift();)c(b)}}function c(a,b,e,f){var g;if(b===a)throw new TypeError("A promise's fulfillment handler cannot return the same promise");if(b instanceof d)b.then(e,f);else if(!b||"object"!=typeof b&&"function"!=typeof b)e(b);else{try{g=b.then}catch(h){return void f(h)}if("function"==typeof g){var i,j,k;j=function(b){i||(i=!0,c(a,b,e,f))},k=function(a){i||(i=!0,f(a))};try{g.call(b,j,k)}catch(h){if(!i)return f(h),void(i=!0)}}else e(b)}}var d,e={},f={},g={};return d=function(h){var i,j,k,l,m,n,o=[],p=[],q=e;return k=function(c){return function(d){q===e&&(i=d,q=c,j=b(q===f?o:p,i),a(j))}},l=k(f),m=k(g),h(l,m),n={then:function(b,f){var g=new d(function(d,h){var i=function(a,b,e){b.push("function"==typeof a?function(b){var e;try{e=a(b),c(g,e,d,h)}catch(f){h(f)}}:e)};i(b,o,d),i(f,p,h),q!==e&&a(j)});return g}},n["catch"]=function(a){return this.then(null,a)},n},d.all=function(a){return new d(function(b,c){var d,e,f,g=[];if(!a.length)return void b(g);for(f=function(e){a[e].then(function(a){g[e]=a,--d||b(g)},c)},d=e=a.length;e--;)f(e)})},d.resolve=function(a){return new d(function(b){b(a)})},d.reject=function(a){return new d(function(b,c){c(a)})},d}(),p=function(){var a=/\[\s*(\*|[0-9]|[1-9][0-9]+)\s*\]/g;return function(b){return(b||"").replace(a,".$1")}}(),q=["o","ms","moz","webkit"],r=function(a){return"undefined"!=typeof window?(function(a,b,c){var d,e;if(!c.requestAnimationFrame){for(d=0;d<a.length&&!c.requestAnimationFrame;++d)c.requestAnimationFrame=c[a[d]+"RequestAnimationFrame"];c.requestAnimationFrame||(e=c.setTimeout,c.requestAnimationFrame=function(a){var c,d,f;return c=Date.now(),d=Math.max(0,16-(c-b)),f=e(function(){a(c+d)},d),b=c+d,f})}}(a,0,window),window.requestAnimationFrame):void 0}(q),s=function(){return"undefined"!=typeof window&&window.performance&&"function"==typeof window.performance.now?function(){return window.performance.now()}:function(){return Date.now()}}(),t=[],u=function(a,b){var c=a.indexOf(b);-1!==c&&a.splice(c,1)},v=function(a,b,c){var d,e,f,g,h,i="/* Ractive.js component styles */\n",j={},k=[];if(b)return a.push(function(){d=a.runloop}),e=document.createElement("style"),e.type="text/css",f=document.getElementsByTagName("head")[0],h=!1,g=e.styleSheet,{add:function(a){a.css&&(j[a._guid]||(j[a._guid]=0,k.push(a.css),d.scheduleCssUpdate()),j[a._guid]+=1)},remove:function(a){a.css&&(j[a._guid]-=1,j[a._guid]||(c(k,a.css),d.scheduleCssUpdate()))},update:function(){var a;k.length?(a=i+k.join(" "),g?g.cssText=a:e.innerHTML=a,h||f.appendChild(e)):h&&f.removeChild(e)}}}(t,h,u),w=function(a,b){var c,d,e,f,g,h;for(c=[],h=a._rendering?a.fragment.docFrag:a.el,d=h.querySelectorAll('input[type="checkbox"][name="{{'+b+'}}"]'),f=d.length,g=0;f>g;g+=1)e=d[g],(e.hasAttribute("checked")||e.checked)&&c.push(e._ractive.value);return c},x=Object.prototype.hasOwnProperty,y=function(a){do if(a.context)return a.context;while(a=a.parent);return""},z=function(a,b,c,d){var e,f='Could not resolve reference - too many "../" prefixes';return a.push(function(){e=a.get}),function(a,g,h){var i,j,k,l,m,n,o,p,q;if(g=b(g),"."===g)return d(h);if("."===g.charAt(0)){if(i=d(h),j=i?i.split("."):[],"../"===g.substr(0,3)){for(;"../"===g.substr(0,3);){if(!j.length)throw new Error(f);j.pop(),g=g.substring(3)}return j.push(g),j.join(".")}return i?i+g:g.substring(1)}k=g.split("."),l=k.pop(),m=k.length?"."+k.join("."):"";do if(i=h.context,i&&(q=!0,n=i+m,o=e(a,n),(p=a._wrapped[n])&&(o=p.get()),o&&("object"==typeof o||"function"==typeof o)&&l in o))return i+"."+g;while(h=h.parent);return q||a._parent&&!a.isolated?c.call(a.data,g)?g:void 0!==e(a,g)?g:void 0:g}}(t,p,x,y),A=function(a){var b,c,d,e,f=[""];for(b=a.length;b--;)for(c=a[b],d=c.split(".");d.length>1;)d.pop(),e=d.join("."),f[e]!==!0&&(f.push(e),f[e]=!0);return f},B=function(){function a(a,c,d){var f;for(a._patternObservers.length&&e(a,c,c,d,!0),f=0;f<a._deps.length;f+=1)b(a,c,f,d)}function b(a,b,e,f){var g=a._deps[e];g&&(c(g[b]),f||d(a._depsMap[b],a,e))}function c(a){var b,c;if(a)for(c=a.length,b=0;c>b;b+=1)a[b].update()}function d(a,c,d,e){var f;if(a)for(f=a.length;f--;)b(c,a[f],d,e)}function e(a,b,c,d,g){var i,j,k,l,m,n,o,p;for(i=a._patternObservers.length;i--;)j=a._patternObservers[i],j.regex.test(c)&&j.update(c);d||(p=function(b){if(k=a._depsMap[b])for(i=k.length;i--;)l=k[i],m=h.exec(l)[0],n=c?c+"."+m:m,e(a,l,n)},g?(o=f(c),o.forEach(p)):p(b))}function f(a){var b,c,d,e,f,h;for(b=a.split("."),c=g(b.length),f=[],d=function(a,c){return a?"*":b[c]},e=c.length;e--;)h=c[e].map(d).join("."),f[h]||(f.push(h),f[h]=!0);return f}function g(a){var b,c,d,e,f,g="";if(!i[a]){for(d=[];g.length<a;)g+=1;for(b=parseInt(g,2),e=function(a){return"1"===a},f=0;b>=f;f+=1){for(c=f.toString(2);c.length<a;)c="0"+c;d[f]=Array.prototype.map.call(c,e)}i[a]=d}return i[a]}var h,i={};return h=/[^\.]+$/,a.multiple=function(a,c,d){var f,g,h;if(h=c.length,a._patternObservers.length)for(f=h;f--;)e(a,c[f],c[f],d,!0);for(f=0;f<a._deps.length;f+=1)if(a._deps[f])for(g=h;g--;)b(a,c[g],f,d)},a}(),C=function(a){var b,c,d,e;return b=function(a,b){var f=[];return f.detachQueue=[],f.remove=d,f.init=e,f._check=c,f._callback=a,f._previous=b,b&&b.push(f),f},c=function(){var a;if(this._ready&&!this.length){for(;a=this.detachQueue.pop();)a.detach();"function"==typeof this._callback&&this._callback(),this._previous&&this._previous.remove(this)}},d=function(b){a(this,b),this._check()},e=function(){this._ready=!0,this._check()},b}(u),D=function(a,b,c,d,e,f,g,h){function i(){var a,c,d;for(t&&(t.focus(),t=null);a=y.pop();)a.update().deferred=!1;for(;a=u.pop();)a._sort();for(;a=v.pop();)a.init();for(;a=w.pop();)a.init();for(;a=x.pop();)a.update();for(;a=z.pop();)a.active=!1;for(;a=H.pop();)if(H[a._guid]=!1,a._changes.length){for(d={};c=a._changes.pop();)d[c]=m(a,c);a.fire("change",d)}o&&(b.update(),o=!1)}function j(){var a,b,c;for(c=H.length;c--;)a=H[c],a._changes.length&&(b=f(a._changes),g.multiple(a,b,!0));for(k();q;){for(q=!1;a=B.pop();)a.update();for(;a=A.pop();)a.update().deferred=!1;for(;a=C.pop();)a.deferredUpdate();for(;a=E.pop();)n(a.root,a.keypath,d(a.root,a.keypath));for(;a=F.pop();)a.update()}}function k(){var a,b,c;if(G.length)for(a=G.splice(0,G.length);b=a.pop();)b.keypath||(c=e(b.root,b.ref,b.parentFragment),void 0!==c?b.resolve(c):G.push(b))}a.push(function(){m=a.get,n=a.set});var l,m,n,o,p,q=!1,r=!1,s=0,t=null,u=[],v=[],w=[],x=[],y=[],z=[],A=[],B=[],C=[],D={},E=[],F=[],G=[],H=[];return l={start:function(a,b){this.addInstance(a),r||(s+=1,p=h(b,p))},end:function(){return r?void k():(--s||(r=!0,j(),r=!1,i()),p.init(),void(p=p._previous))},trigger:function(){return s||r?void k():(r=!0,j(),r=!1,void i())},focus:function(a){t=a},addInstance:function(a){a&&!H[a._guid]&&(H.push(a),H[H._guid]=!0)},addLiveQuery:function(a){u.push(a)},addDecorator:function(a){v.push(a)},addTransition:function(a){a._manager=p,p.push(a),w.push(a)},addObserver:function(a){x.push(a)},addAttribute:function(a){y.push(a)},addBinding:function(a){a.active=!0,z.push(a)},scheduleCssUpdate:function(){s||r?o=!0:b.update()},addEvaluator:function(a){q=!0,A.push(a)},addComputation:function(a){q=!0,B.push(a)},addSelectValue:function(a){q=!0,C.push(a)},addCheckbox:function(a){D[a.keypath]||(q=!0,E.push(a))},addRadio:function(a){q=!0,F.push(a)},addUnresolved:function(a){q=!0,G.push(a)},removeUnresolved:function(a){c(G,a)},detachWhenReady:function(a){p.detachQueue.push(a)}},a.runloop=l,l}(t,v,u,w,z,A,B,C),E=function(a,b,c){var d=[],e={tick:function(){var f,g,h;for(h=b(),c.start(),f=0;f<d.length;f+=1)g=d[f],g.tick(h)||d.splice(f--,1);c.end(),d.length?a(e.tick):e.running=!1},add:function(b){d.push(b),e.running||(e.running=!0,a(e.tick))},abort:function(a,b){for(var c,e=d.length;e--;)c=d[e],c.root===b&&c.keypath===a&&c.stop()}};return e}(r,s,D),F=function(){var a=Object.prototype.toString;return function(b){return"[object Array]"===a.call(b)}}(),G=function(a){return function(b){var c,d;if(!b||"object"!=typeof b)return b;if(a(b))return b.slice();c={};for(d in b)b.hasOwnProperty(d)&&(c[d]=b[d]);return c}}(F),H={},I=function(a,b,c){switch(b){case"splice":return c;case"sort":case"reverse":return null;case"pop":return a.length?[-1]:null;case"push":return[a.length,0].concat(c);case"shift":return[0,1];case"unshift":return[0,0].concat(c)}},J=function(a,b){var c,d,e,f;return b?(c=+(b[0]<0?a.length+b[0]:b[0]),d=Math.max(0,b.length-2),e=void 0!==b[1]?b[1]:a.length-c,e=Math.min(e,a.length-c),f=d-e,{start:c,balance:f,added:d,removed:e}):null},K={TEXT:1,INTERPOLATOR:2,TRIPLE:3,SECTION:4,INVERTED:5,CLOSING:6,ELEMENT:7,PARTIAL:8,COMMENT:9,DELIMCHANGE:10,MUSTACHE:11,TAG:12,ATTRIBUTE:13,COMPONENT:15,NUMBER_LITERAL:20,STRING_LITERAL:21,ARRAY_LITERAL:22,OBJECT_LITERAL:23,BOOLEAN_LITERAL:24,GLOBAL:26,KEY_VALUE_PAIR:27,REFERENCE:30,REFINEMENT:31,MEMBER:32,PREFIX_OPERATOR:33,BRACKETED:34,CONDITIONAL:35,INFIX_OPERATOR:36,INVOCATION:40},L=function mf(a,b,c){var d,e;if(c||(e=a._wrapped[b])&&e.teardown()!==!1&&(a._wrapped[b]=null),a._cache[b]=void 0,d=a._cacheMap[b])for(;d.length;)mf(a,d.pop())},M=function(){var a=/^\s*[0-9]+\s*$/;return function(b){return a.test(b)?[]:{}}}(),N=function(a,b,c,d,e){function f(a,h,i,j){var k,l,m,n,o,p,q,r;b(a._cache[h],i)||(o=a._computations[h],p=a._wrapped[h],q=a._evaluators[h],o&&!o.setting&&o.set(i),p&&p.reset&&(r=p.reset(i)!==!1,r&&(i=p.get())),q&&(q.value=i),o||q||r||(k=h.split("."),l=k.pop(),m=k.join("."),p=a._wrapped[m],p&&p.set?p.set(l,i):(n=p?p.get():g(a,m),n||(n=c(l),f(a,m,n,!0)),n[l]=i)),d(a,h,r),j||(a._changes.push(h),e(a,h)))}var g;return a.push(function(){g=a.get}),a.set=f,f}(t,n,M,L,B),O=function(a,b,c,d){return function(e,f,g,h){var i,j,k,l,m,n,o,p,q,r;if(i=e.root,j=e.keypath,i._changes.push(j),"sort"===g||"reverse"===g)return void d(i,j,f);if(h){for(k=h.balance?f.length-Math.min(h.balance,0):h.added,m=h.start;k>m;m+=1)b(i,j+"."+m);if(l=function(b){b.keypath===j&&b.type===a.SECTION&&!b.inverted&&b.docFrag?b.splice(h):b.update()},i._deps.forEach(function(a){var b=a[j];b&&b.forEach(l)}),h.added&&h.removed)for(n=Math.max(h.added,h.removed),o=h.start,p=o+n,r=h.added===h.removed,m=o;p>m;m+=1)q=j+"."+m,c(i,q);r||(b(i,j+".length"),c(i,j+".length",!0))}}}(K,L,B,N),P=function(a,b,c,d,e){var f,g,h,i=[],j=["pop","push","reverse","shift","sort","splice","unshift"];return j.forEach(function(f){var g=function(){var b,g,h,i,j;for(b=c(this,f,Array.prototype.slice.call(arguments)),g=d(this,b),h=Array.prototype[f].apply(this,arguments),this._ractive.setting=!0,j=this._ractive.wrappers.length;j--;)i=this._ractive.wrappers[j],a.start(i.root),e(i,this,f,g),a.end();return this._ractive.setting=!1,h};b(i,f,{value:g})}),f={},f.__proto__?(g=function(a){a.__proto__=i},h=function(a){a.__proto__=Array.prototype}):(g=function(a){var c,d;for(c=j.length;c--;)d=j[c],b(a,d,{value:i[d],configurable:!0})},h=function(a){var b;for(b=j.length;b--;)delete a[j[b]]}),g.unpatch=h,g}(D,i,I,J,O),Q=function(a,b,c){var d,e,f;return d={filter:function(a){return b(a)&&(!a._ractive||!a._ractive.setting)},wrap:function(a,b,c){return new e(a,b,c)}},e=function(b,d,e){this.root=b,this.value=d,this.keypath=e,d._ractive||(a(d,"_ractive",{value:{wrappers:[],instances:[],setting:!1},configurable:!0}),c(d)),d._ractive.instances[b._guid]||(d._ractive.instances[b._guid]=0,d._ractive.instances.push(b)),d._ractive.instances[b._guid]+=1,d._ractive.wrappers.push(this)},e.prototype={get:function(){return this.value},teardown:function(){var a,b,d,e,g;if(a=this.value,b=a._ractive,d=b.wrappers,e=b.instances,b.setting)return!1;if(g=d.indexOf(this),-1===g)throw new Error(f);if(d.splice(g,1),d.length){if(e[this.root._guid]-=1,!e[this.root._guid]){if(g=e.indexOf(this.root),-1===g)throw new Error(f);e.splice(g,1)}}else delete a._ractive,c.unpatch(this.value)}},f="Something went wrong in a rather interesting way",d}(i,F,P),R=function(a,b,c,d,e){function f(b,c,f){function g(b){var f,g;b.value=c,b.updating||(g=b.ractive,f=b.keypath,b.updating=!0,a.start(g),g._changes.push(f),d(g,f),e(g,f),a.end(),b.updating=!1)}var h,i,j,k,l,m;if(h=b.obj,i=b.prop,f&&!f.configurable){if("length"===i)return;throw new Error('Cannot use magic mode with property "'+i+'" - object is not configurable')}f&&(j=f.get,k=f.set),l=j||function(){return c},m=function(a){k&&k(a),c=j?j():a,m._ractiveWrappers.forEach(g)},m._ractiveWrappers=[b],Object.defineProperty(h,i,{get:l,set:m,enumerable:!0,configurable:!0})}var g,h;try{Object.defineProperty({},"test",{value:0})}catch(i){return!1}return g={filter:function(a,b,d){var e,f,g,h,i;return b?(e=b.split("."),f=e.pop(),g=e.join("."),(h=d._wrapped[g])&&!h.magic?!1:(i=d.get(g),c(i)&&/^[0-9]+$/.test(f)?!1:i&&("object"==typeof i||"function"==typeof i))):!1},wrap:function(a,b,c){return new h(a,b,c)}},h=function(a,b,c){var d,e,g,h;return this.magic=!0,this.ractive=a,this.keypath=c,this.value=b,d=c.split("."),this.prop=d.pop(),e=d.join("."),this.obj=e?a.get(e):a.data,g=this.originalDescriptor=Object.getOwnPropertyDescriptor(this.obj,this.prop),g&&g.set&&(h=g.set._ractiveWrappers)?void(-1===h.indexOf(this)&&h.push(this)):void f(this,b,g)},h.prototype={get:function(){return this.value},reset:function(a){this.updating||(this.updating=!0,this.obj[this.prop]=a,d(this.ractive,this.keypath),this.updating=!1)},set:function(a,c){this.updating||(this.obj[this.prop]||(this.updating=!0,this.obj[this.prop]=b(a),this.updating=!1),this.obj[this.prop][a]=c)},teardown:function(){var a,b,c,d,e;return this.updating?!1:(a=Object.getOwnPropertyDescriptor(this.obj,this.prop),b=a&&a.set,void(b&&(d=b._ractiveWrappers,e=d.indexOf(this),-1!==e&&d.splice(e,1),d.length||(c=this.obj[this.prop],Object.defineProperty(this.obj,this.prop,this.originalDescriptor||{writable:!0,enumerable:!0,configurable:!0}),this.obj[this.prop]=c))))}},g}(D,M,F,L,B),S=function(a,b){if(!a)return!1;var c,d;return c={filter:function(c,d,e){return a.filter(c,d,e)&&b.filter(c)},wrap:function(a,b,c){return new d(a,b,c)}},d=function(c,d,e){this.value=d,this.magic=!0,this.magicWrapper=a.wrap(c,d,e),this.arrayWrapper=b.wrap(c,d,e)},d.prototype={get:function(){return this.value},teardown:function(){this.arrayWrapper.teardown(),this.magicWrapper.teardown()},reset:function(a){return this.magicWrapper.reset(a)}},c}(R,Q),T=function(a,b,c,d){function e(a,b){var c,d={};if(!b)return a;b+=".";for(c in a)a.hasOwnProperty(c)&&(d[b+c]=a[c]);return d}function f(a){var b;return g[a]||(b=a?a+".":"",g[a]=function(c,d){var f;return"string"==typeof c?(f={},f[b+c]=d,f):"object"==typeof c?b?e(c,a):c:void 0}),g[a]}var g={};return function(e,g,h,i){var j,k,l,m;for(j=e.adapt.length,k=0;j>k;k+=1){if(l=e.adapt[k],"string"==typeof l){if(!a[l])throw new Error('Missing adaptor "'+l+'"');l=e.adapt[k]=a[l]}if(l.filter(h,g,e))return m=e._wrapped[g]=l.wrap(e,h,g,f(g)),m.value=h,h}return i||(e.magic?d.filter(h,g,e)?e._wrapped[g]=d.wrap(e,h,g):c.filter(h,g,e)&&(e._wrapped[g]=c.wrap(e,h,g)):e.modifyArrays&&b.filter(h,g,e)&&(e._wrapped[g]=b.wrap(e,h,g))),h}}(H,Q,R,S),U=function(){function a(a,b){var c,d,e;for(c=b.split(".");c.length;)c.pop(),d=c.join("."),e=a._depsMap[d]||(a._depsMap[d]=[]),void 0===e[b]&&(e[b]=0,e[e.length]=b),e[b]+=1,b=d}return function(b){var c,d,e,f,g;e=b.root,f=b.keypath,g=b.priority,c=e._deps[g]||(e._deps[g]={}),d=c[f]||(c[f]=[]),d.push(b),b.registered=!0,f&&a(e,f)}}(),V=function(){function a(a,b){var c,d,e;for(c=b.split(".");c.length;)c.pop(),d=c.join("."),e=a._depsMap[d],e[b]-=1,e[b]||(e.splice(e.indexOf(b),1),e[b]=void 0),b=d}return function(b){var c,d,e,f,g;if(e=b.root,f=b.keypath,g=b.priority,c=e._deps[g][f],d=c.indexOf(b),-1===d||!b.registered)throw new Error("Attempted to remove a dependant that was no longer registered! This should not happen. If you are seeing this bug in development please raise an issue at https://github.com/RactiveJS/Ractive/issues - thanks");c.splice(d,1),b.registered=!1,f&&a(e,f)}}(),W=function(a,b,c,d,e,f){var g,h;a.push(function(){g=a.get,h=a.set});var i=function(a,b,c,d,f){this.root=a,this.keypath=b,this.priority=f,this.otherInstance=c,this.otherKeypath=d,e(this),this.value=g(this.root,this.keypath)};return i.prototype={update:function(){var a;this.updating||this.counterpart&&this.counterpart.updating||(a=g(this.root,this.keypath),c(a)&&a._ractive&&a._ractive.setting||d(a,this.value)||(this.updating=!0,b.addInstance(this.otherInstance),h(this.otherInstance,this.otherKeypath,a),this.value=a,this.updating=!1))},reassign:function(a){f(this),f(this.counterpart),this.keypath=a,this.counterpart.otherKeypath=a,e(this),e(this.counterpart)},teardown:function(){f(this)}},function(a,b,c,d){var e,f,g,h,j,k;e=c+"="+d,g=a.bindings,g[e]||(g[e]=!0,f=a.instance,h=a.parentFragment.priority,j=new i(b,c,f,d,h),g.push(j),f.twoway&&(k=new i(f,d,b,c,1),g.push(k),j.counterpart=k,k.counterpart=j))}}(t,D,F,n,U,V),X=function(a,b,c){function d(a,d,e,f,g){c(d,f,g,!0),b(d.component,a,e,f)}var e;return a.push(function(){e=a.get}),function(a,b){var c,f,g,h,i;if(c=a._parent,f=a.component.parentFragment,f.indexRefs&&void 0!==(i=f.indexRefs[b]))return a.component.indexRefBindings[b]=b,i;do if(f.context&&(g=f.context+"."+b,h=e(c,g),void 0!==h))return d(c,a,g,b,h),h;while(f=f.parent);return h=e(c,b),void 0!==h?(d(c,a,b,b,h),h):void 0}}(t,W,N),Y={FAILED_LOOKUP:!0},Z=function(a,b,c,d,e,f){function g(a,b,c){var g,i,j,k,l=a._cache;return void 0===l[b]?((i=a._computations[b])?g=i.value:(j=a._wrapped[b])?g=j.value:b?g=(k=a._evaluators[b])?k.value:h(a,b):(d(a,"",a.data),g=a.data),l[b]=g):g=l[b],g===f&&(g=a._parent&&!a.isolated?e(a,b,c):void 0),c&&c.evaluateWrapped&&(j=a._wrapped[b])&&(g=j.get()),g}function h(a,e){var h,i,j,k,l,m,n,o;return h=e.split("."),i=h.pop(),j=h.join("."),k=g(a,j),(n=a._wrapped[j])&&(k=n.get()),null!==k&&void 0!==k?((l=a._cacheMap[j])?-1===l.indexOf(e)&&l.push(e):a._cacheMap[j]=[e],"object"!=typeof k||i in k?(o=!b.call(k,i),m=o?c(k[i]):k[i],m=d(a,e,m,!1),a._cache[e]=m,m):a._cache[e]=f):void 0}return a.get=g,g}(t,x,G,T,X,Y),$=function(){return"undefined"!=typeof console&&"function"==typeof console.warn&&"function"==typeof console.warn.apply?function(){console.warn.apply(console,arguments)}:function(){}}(),_=function(){var a=Object.prototype.toString;return function(b){return"object"==typeof b&&"[object Object]"===a.call(b)}}(),ab=function(a,b,c,d,e){var f,g,h;return a.push(function(){g=a.interpolate}),h=/^([+-]?[0-9]+\.?(?:[0-9]+)?)(px|em|ex|%|in|cm|mm|pt|pc)$/,f={number:function(a,b){var c;return e(a)&&e(b)?(a=+a,b=+b,c=b-a,c?function(b){return a+b*c}:function(){return a}):null},array:function(a,b){var d,e,f,h;if(!c(a)||!c(b))return null;for(d=[],e=[],h=f=Math.min(a.length,b.length);h--;)e[h]=g(a[h],b[h]);for(h=f;h<a.length;h+=1)d[h]=a[h];for(h=f;h<b.length;h+=1)d[h]=b[h];return function(a){for(var b=f;b--;)d[b]=e[b](a);return d}},object:function(a,c){var e,f,h,i,j;if(!d(a)||!d(c))return null;e=[],i={},h={};for(j in a)b.call(a,j)&&(b.call(c,j)?(e.push(j),h[j]=g(a[j],c[j])):i[j]=a[j]);for(j in c)b.call(c,j)&&!b.call(a,j)&&(i[j]=c[j]);return f=e.length,function(a){for(var b,c=f;c--;)b=e[c],i[b]=h[b](a);return i}},cssLength:function(a,b){var c,d,e,f,g,i,j,k;return 0!==a&&"string"!=typeof a||0!==b&&"string"!=typeof b?null:(c=h.exec(a),d=h.exec(b),e=c?c[2]:"",f=d?d[2]:"",e&&f&&e!==f?null:(j=e||f,g=c?+c[1]:0,i=d?+d[1]:0,k=i-g,k?function(a){return g+a*k+j}:function(){return g+j}))}}}(t,x,F,_,k),bb=function(a,b,c){function d(a){return function(){return a}}var e=function(a,e,f,g){if(a===e)return d(e);if(g){if(f.interpolators[g])return f.interpolators[g](a,e)||d(e);b('Missing "'+g+'" interpolator. You may need to download a plugin from [TODO]')}return c.number(a,e)||c.array(a,e)||c.object(a,e)||c.cssLength(a,e)||d(e)};return a.interpolate=e,e}(t,$,ab),cb=function(a,b,c,d){var e=function(a){var b;this.startTime=Date.now();for(b in a)a.hasOwnProperty(b)&&(this[b]=a[b]);this.interpolator=c(this.from,this.to,this.root,this.interpolator),this.running=!0};return e.prototype={tick:function(){var c,e,f,g,h,i;return i=this.keypath,this.running?(g=Date.now(),c=g-this.startTime,c>=this.duration?(null!==i&&(b.start(this.root),d(this.root,i,this.to),b.end()),this.step&&this.step(1,this.to),this.complete(this.to),h=this.root._animations.indexOf(this),-1===h&&a("Animation was not found"),this.root._animations.splice(h,1),this.running=!1,!1):(e=this.easing?this.easing(c/this.duration):c/this.duration,null!==i&&(f=this.interpolator(e),b.start(this.root),d(this.root,i,f),b.end()),this.step&&this.step(e,f),!0)):!1},stop:function(){var b;this.running=!1,b=this.root._animations.indexOf(this),-1===b&&a("Animation was not found"),this.root._animations.splice(b,1)}},e}($,D,bb,N),db=function(a,b,c,d,e,f){function g(b,g,h,j){var k,l,m,n;return g&&(g=c(g)),null!==g&&(n=e(b,g)),d.abort(g,b),a(n,h)?(j.complete&&j.complete(j.to),i):(j.easing&&(k="function"==typeof j.easing?j.easing:b.easing[j.easing],"function"!=typeof k&&(k=null)),l=void 0===j.duration?400:j.duration,m=new f({keypath:g,from:n,to:h,root:b,duration:l,easing:k,interpolator:j.interpolator,step:j.step,complete:j.complete}),d.add(m),b._animations.push(m),m)}var h=function(){},i={stop:h};return function(a,c,d){var e,f,i,j,k,l,m,n,o,p,q,r,s,t;if(e=new b(function(a){f=a}),"object"==typeof a){d=c||{},l=d.easing,m=d.duration,k=[],n=d.step,o=d.complete,(n||o)&&(q={},d.step=null,d.complete=null,p=function(a){return function(b,c){q[a]=c}});for(i in a)a.hasOwnProperty(i)&&((n||o)&&(r=p(i),d={easing:l,duration:m},n&&(d.step=r)),d.complete=o?r:h,k.push(g(this,i,a[i],d)));return(n||o)&&(t={easing:l,duration:m},n&&(t.step=function(a){n(a,q)}),o&&e.then(function(a){o(a,q)}),t.complete=f,s=g(this,null,null,t),k.push(s)),{stop:function(){for(var a;a=k.pop();)a.stop();s&&s.stop()}}}return d=d||{},d.complete&&e.then(d.complete),d.complete=f,j=g(this,a,c,d),e.stop=function(){j.stop()},e}}(n,o,p,E,Z,cb),eb=function(){return this.fragment.detach()},fb=function(a){return this.el?this.fragment.find(a):null},gb=function(a,b,c){var d,e,f,g,h,i,j;if(a){for(d=c("div"),e=["matches","matchesSelector"],j=function(a){return function(b,c){return b[a](c)}},h=e.length;h--;){if(f=e[h],d[f])return j(f);for(i=b.length;i--;)if(g=b[h]+f.substr(0,1).toUpperCase()+f.substring(1),d[g])return j(g)}return function(a,b){var c,d;for(c=(a.parentNode||a.document).querySelectorAll(b),d=c.length;d--;)if(c[d]===a)return!0;return!1}}}(h,q,g),hb=function(a){return function(b,c){var d=this._isComponentQuery?!this.selector||b.name===this.selector:a(b.node,this.selector);return d?(this.push(b.node||b.instance),c||this._makeDirty(),!0):void 0}}(gb),ib=function(){var a,b,c;a=this._root[this._isComponentQuery?"liveComponentQueries":"liveQueries"],b=this.selector,c=a.indexOf(b),-1!==c&&(a.splice(c,1),a[b]=null)},jb=function(){function a(a){var b;return(b=a.parentFragment)?b.owner:a.component&&(b=a.component.parentFragment)?b.owner:void 0}function b(b){var c,d;for(c=[b],d=a(b);d;)c.push(d),d=a(d);return c}return function(a,c){var d,e,f,g,h,i,j,k,l,m;for(d=b(a.component||a._ractive.proxy),e=b(c.component||c._ractive.proxy),f=d[d.length-1],g=e[e.length-1];f&&f===g;)d.pop(),e.pop(),h=f,f=d[d.length-1],g=e[e.length-1];if(f=f.component||f,g=g.component||g,l=f.parentFragment,m=g.parentFragment,l===m)return i=l.items.indexOf(f),j=m.items.indexOf(g),i-j||d.length-e.length;if(k=h.fragments)return i=k.indexOf(l),j=k.indexOf(m),i-j||d.length-e.length;throw new Error("An unexpected condition was met while comparing the position of two components. Please file an issue at https://github.com/RactiveJS/Ractive/issues - thanks!")}}(),kb=function(a){return function(b,c){var d;return b.compareDocumentPosition?(d=b.compareDocumentPosition(c),2&d?1:-1):a(b,c)}}(jb),lb=function(a,b){return function(){this.sort(this._isComponentQuery?b:a),this._dirty=!1}}(kb,jb),mb=function(a){return function(){this._dirty||(a.addLiveQuery(this),this._dirty=!0)}}(D),nb=function(a){var b=this.indexOf(this._isComponentQuery?a.instance:a);-1!==b&&this.splice(b,1)},ob=function(a,b,c,d,e,f){return function(g,h,i,j){var k=[];return a(k,{selector:{value:h},live:{value:i},_isComponentQuery:{value:j},_test:{value:b}}),i?(a(k,{cancel:{value:c},_root:{value:g},_sort:{value:d},_makeDirty:{value:e},_remove:{value:f},_dirty:{value:!1,writable:!0}}),k):k}}(j,hb,ib,lb,mb,nb),pb=function(a){return function(b,c){var d,e;return this.el?(c=c||{},d=this._liveQueries,(e=d[b])?c&&c.live?e:e.slice():(e=a(this,b,!!c.live,!1),e.live&&(d.push(b),d[b]=e),this.fragment.findAll(b,e),e)):[]}}(ob),qb=function(a){return function(b,c){var d,e;return c=c||{},d=this._liveComponentQueries,(e=d[b])?c&&c.live?e:e.slice():(e=a(this,b,!!c.live,!0),e.live&&(d.push(b),d[b]=e),this.fragment.findAllComponents(b,e),e)}}(ob),rb=function(a){return this.fragment.findComponent(a)},sb=function(a){var b,c,d,e=this._subs[a];if(e)for(b=Array.prototype.slice.call(arguments,1),c=0,d=e.length;d>c;c+=1)e[c].apply(this,b)},tb=function(a,b,c,d){var e,f={};a.push(function(){e=a.get});var g=function(a,b){this.root=a,this.ref=b,this.parentFragment=f,a._unresolvedImplicitDependencies[b]=!0,a._unresolvedImplicitDependencies.push(this),c.addUnresolved(this)};return g.prototype={resolve:function(){var a=this.root;d(a,this.ref),a._unresolvedImplicitDependencies[this.ref]=!1,b(a._unresolvedImplicitDependencies,this)},teardown:function(){c.removeUnresolved(this)}},g}(t,u,D,B),ub=function(a,b,c){var d={isTopLevel:!0};return function(e){var f;return e=a(e),f=b(this,e,d),this._captured&&this._captured[e]!==!0&&(this._captured.push(e),this._captured[e]=!0,void 0===f&&this._unresolvedImplicitDependencies[e]!==!0&&new c(this,e)),f}}(p,Z,tb),vb=function(a){var b;return"undefined"!=typeof window&&document&&a?a.nodeType?a:"string"==typeof a&&(b=document.getElementById(a),!b&&document.querySelector&&(b=document.querySelector(a)),b&&b.nodeType)?b:a[0]&&a[0].nodeType?a[0]:null:null},wb=function(a){return function(b,c){if(b=a(b),c=a(c)||null,!b)throw new Error("You must specify a valid target to insert into");b.insertBefore(this.detach(),c),this.fragment.pNode=this.el=b}}(vb),xb=function(a,b){var c,d,e,f;return c={},d=0,e=a.map(function(a,e){var g,h,i;h=d,i=b.length;do{if(g=b.indexOf(a,h),-1===g)return f=!0,-1;h=g+1}while(c[g]&&i>h);return g===d&&(d+=1),g!==e&&(f=!0),c[g]=!0,g}),e.unchanged=!f,e},yb=function(a,b){return function(c,d,e,f){var g;c._changes.push(d),g=function(b){b.type===a.REFERENCE?b.update():b.keypath===d&&b.type===a.SECTION&&!b.inverted&&b.docFrag?b.merge(e):b.update()},c._deps.forEach(function(a){var b=a[d];b&&b.forEach(g)}),f||b(c,d+".length",!0)}}(K,B),zb=function(a,b,c,d,e,f,g){function h(a){return JSON.stringify(a)}function i(a){if(a===!0)return h;if("string"==typeof a)return j[a]||(j[a]=function(b){return b[a]}),j[a];if("function"==typeof a)return a;throw new Error("The `compare` option must be a function, or a string representing an identifying field (or `true` to use JSON.stringify)")}var j={};return function(h,j,k){var l,m,n,o,p,q,r,s;if(l=this.get(h),!c(l)||!c(j))return this.set(h,j,k&&k.complete);if(p=l.length===j.length,k&&k.compare){o=i(k.compare);try{m=l.map(o),n=j.map(o)}catch(t){if(this.debug)throw t;b("Merge operation: comparison failed. Falling back to identity checking"),m=l,n=j}}else m=l,n=j;return q=f(m,n),r=new d(function(a){s=a}),a.start(this,s),e(this,h,j,!0),g(this,h,q,p),a.end(),k&&k.complete&&r.then(k.complete),r}}(D,$,F,o,N,xb,yb),Ab=function(a,b,c){var d=function(a,b,c,d){var e=this;this.root=a,this.keypath=b,this.callback=c,this.defer=d.defer,this.debug=d.debug,this.proxy={update:function(){e.reallyUpdate()}},this.priority=0,this.context=d&&d.context?d.context:a};return d.prototype={init:function(a){a!==!1?this.update():this.value=c(this.root,this.keypath)},update:function(){return this.defer&&this.ready?void a.addObserver(this.proxy):void this.reallyUpdate()},reallyUpdate:function(){var a,d;if(a=this.value,d=c(this.root,this.keypath),this.value=d,!this.updating){if(this.updating=!0,!b(d,a)||!this.ready)try{this.callback.call(this.context,d,a,this.keypath)}catch(e){if(this.debug||this.root.debug)throw e}this.updating=!1}}},d}(D,n,Z),Bb=function(a){return function(b,c){var d,e,f,g,h,i,j;for(d=c.split("."),g=[],i=function(c){var d,e;d=b._wrapped[c]?b._wrapped[c].get():b.get(c);for(e in d)!d.hasOwnProperty(e)||"_ractive"===e&&a(d)||h.push(c+"."+e)},j=function(a){return a+"."+e};e=d.shift();)"*"===e?(h=[],g.forEach(i),g=h):g[0]?g=g.map(j):g[0]=e;return f={},g.forEach(function(a){f[a]=b.get(a)}),f}}(F),Cb=function(a,b,c,d){var e,f=/\*/;return e=function(a,b,c,d){this.root=a,this.callback=c,this.defer=d.defer,this.debug=d.debug,this.keypath=b,this.regex=new RegExp("^"+b.replace(/\./g,"\\.").replace(/\*/g,"[^\\.]+")+"$"),this.values={},this.defer&&(this.proxies=[]),this.priority="pattern",this.context=d&&d.context?d.context:a},e.prototype={init:function(a){var b,c;if(b=d(this.root,this.keypath),a!==!1)for(c in b)b.hasOwnProperty(c)&&this.update(c);else this.values=b},update:function(b){var c;{if(!f.test(b))return this.defer&&this.ready?void a.addObserver(this.getProxy(b)):void this.reallyUpdate(b);c=d(this.root,b);for(b in c)c.hasOwnProperty(b)&&this.update(b)}},reallyUpdate:function(a){var d=c(this.root,a);if(this.updating)return void(this.values[a]=d);if(this.updating=!0,!b(d,this.values[a])||!this.ready){try{this.callback.call(this.context,d,this.values[a],a)}catch(e){if(this.debug||this.root.debug)throw e}this.values[a]=d}this.updating=!1},getProxy:function(a){var b=this;return this.proxies[a]||(this.proxies[a]={update:function(){b.reallyUpdate(a)}}),this.proxies[a]}},e}(D,n,Z,Bb),Db=function(a,b,c,d,e){var f=/\*/,g={};return function(h,i,j,k){var l,m;return i=a(i),k=k||g,f.test(i)?(l=new e(h,i,j,k),h._patternObservers.push(l),m=!0):l=new d(h,i,j,k),b(l),l.init(k.init),l.ready=!0,{cancel:function(){var a;m&&(a=h._patternObservers.indexOf(l),-1!==a&&h._patternObservers.splice(a,1)),c(l)}}}}(p,U,V,Ab,Cb),Eb=function(a,b){return function(c,d,e){var f,g,h,i;
if(a(c)){e=d,g=c,f=[];for(c in g)g.hasOwnProperty(c)&&(d=g[c],f.push(this.observe(c,d,e)));return{cancel:function(){for(;f.length;)f.pop().cancel()}}}if("function"==typeof c)return e=d,d=c,c="",b(this,c,d,e);if(h=c.split(" "),1===h.length)return b(this,c,d,e);for(f=[],i=h.length;i--;)c=h[i],c&&f.push(b(this,c,d,e));return{cancel:function(){for(;f.length;)f.pop().cancel()}}}}(_,Db),Fb=function(a,b){var c,d;if(!b)if(a)this._subs[a]=[];else for(a in this._subs)delete this._subs[a];c=this._subs[a],c&&(d=c.indexOf(b),-1!==d&&c.splice(d,1))},Gb=function(a,b){var c,d,e=this;if("object"==typeof a){c=[];for(d in a)a.hasOwnProperty(d)&&c.push(this.on(d,a[d]));return{cancel:function(){for(var a;a=c.pop();)a.cancel()}}}return this._subs[a]?this._subs[a].push(b):this._subs[a]=[b],{cancel:function(){e.off(a,b)}}},Hb=function(){var a;try{Object.create(null),a=Object.create}catch(b){a=function(){var a=function(){};return function(b,c){var d;return null===b?{}:(a.prototype=b,d=new a,c&&Object.defineProperties(d,c),d)}}()}return a}(),Ib=function(a,b){return function(c,d){var e,f,g,h,i;if(c.owner=d.owner,g=c.parent=c.owner.parentFragment,c.root=d.root,c.pNode=d.pNode,c.pElement=d.pElement,c.context=d.context,c.owner.type===a.SECTION&&(c.index=d.index),g&&(h=g.indexRefs)){c.indexRefs=b(null);for(i in h)c.indexRefs[i]=h[i]}for(c.priority=g?g.priority+1:1,d.indexRef&&(c.indexRefs||(c.indexRefs={}),c.indexRefs[d.indexRef]=d.index),c.items=[],e=d.descriptor?d.descriptor.length:0,f=0;e>f;f+=1)c.items[c.items.length]=c.createItem({parentFragment:c,pElement:d.pElement,descriptor:d.descriptor[f],index:f})}}(K,Hb),Jb=function(a,b){return a.substr(0,b.length+1)===b+"."},Kb=function(a){return function(b,c){return b===c||a(b,c)}}(Jb),Lb=function(a){return function(b,c,d){return b===c?d:a(b,c)?b.replace(c+".",d+"."):void 0}}(Jb),Mb=function(a,b){return function(c,d,e,f){c[d]&&!a(c[d],f)&&(c[d]=b(c[d],e,f))}}(Kb,Lb),Nb=function(a){return function(b,c,d,e){void 0===this.html&&(a(this,"context",d,e),this.indexRefs&&void 0!==this.indexRefs[b]&&this.indexRefs[b]!==c&&(this.indexRefs[b]=c),this.items.forEach(function(a){a.reassign(b,c,d,e)}))}}(Mb),Ob=function(a,b){return{init:a,reassign:b}}(Ib,Nb),Pb=function(a,b){function c(a){return f[a]||(f[a]=b(a))}var d,e,f={};try{b("table").innerHTML="foo"}catch(g){d=!0,e={TABLE:['<table class="x">',"</table>"],THEAD:['<table><thead class="x">',"</thead></table>"],TBODY:['<table><tbody class="x">',"</tbody></table>"],TR:['<table><tr class="x">',"</tr></table>"],SELECT:['<select class="x">',"</select>"]}}return function(b,f,g,h){var i,j,k=[];if(b)for(d&&(j=e[f])?(i=c("DIV"),i.innerHTML=j[0]+b+j[1],i=i.querySelector(".x")):g===a.svg?(i=c("DIV"),i.innerHTML='<svg class="x">'+b+"</svg>",i=i.querySelector(".x")):(i=c(f),i.innerHTML=b);i.firstChild;)k.push(i.firstChild),h.appendChild(i.firstChild);return k}}(f,g),Qb=function(){var a,b=this.node;return b&&(a=b.parentNode)?(a.removeChild(b),b):void 0},Rb=function(a,b){var c,d,e;return d=/</g,e=/>/g,c=function(b,c){this.type=a.TEXT,this.descriptor=b.descriptor,c&&(this.node=document.createTextNode(b.descriptor),c.appendChild(this.node))},c.prototype={detach:b,reassign:function(){},teardown:function(a){a&&this.detach()},firstNode:function(){return this.node},toString:function(){return(""+this.descriptor).replace(d,"<").replace(e,">")}},c}(K,Qb),Sb=function(a,b){return function(c){c.keypath?b(c):a.removeUnresolved(c)}}(D,V),Tb=function(a){var b=function(b,c,d,e){this.root=b,this.ref=c,this.parentFragment=d,this.resolve=e,a.addUnresolved(this)};return b.prototype={teardown:function(){a.removeUnresolved(this)}},b}(D),Ub=function(a,b,c,d,e){function f(a,b,d){var e,f,g;if(!h.test(a.toString()))return c(a,"_nowrap",{value:!0}),a;if(!a["_"+b._guid]){c(a,"_"+b._guid,{value:function(){var c,d,e,g;if(c=b._captured,c||(b._captured=[]),d=a.apply(b,arguments),b._captured.length)for(e=f.length;e--;)g=f[e],g.updateSoftDependencies(b._captured);return b._captured=c,d},writable:!0});for(e in a)a.hasOwnProperty(e)&&(a["_"+b._guid][e]=a[e]);a["_"+b._guid+"_evaluators"]=[]}return f=a["_"+b._guid+"_evaluators"],g=f.indexOf(d),-1===g&&f.push(d),a["_"+b._guid]}var g,h;return h=/this/,g=function(b,c,e,g,h){var i;this.evaluator=e,this.keypath=c,this.root=b,this.argNum=g,this.type=a.REFERENCE,this.priority=h,i=b.get(c),"function"==typeof i&&(i=f(i,b,e)),this.value=e.values[g]=i,d(this)},g.prototype={update:function(){var a=this.root.get(this.keypath);"function"!=typeof a||a._nowrap||(a=f(a,this.root,this.evaluator)),b(a,this.value)||(this.evaluator.values[this.argNum]=a,this.evaluator.bubble(),this.value=a)},teardown:function(){e(this)}},g}(K,n,i,U,V),Vb=function(a,b,c){var d=function(a,c,d){this.root=a,this.keypath=c,this.priority=d.priority,this.evaluator=d,b(this)};return d.prototype={update:function(){var b=this.root.get(this.keypath);a(b,this.value)||(this.evaluator.bubble(),this.value=b)},teardown:function(){c(this)}},d}(n,U,V),Wb=function(a,b,c,d,e,f,g,h){function i(a,b){var c,d;if(a=a.replace(/\$\{([0-9]+)\}/g,"_$1"),k[a])return k[a];for(d=[];b--;)d[b]="_"+b;return c=new Function(d.join(","),"return("+a+")"),k[a]=c,c}var j,k={};return j=function(a,b,c,d,e,f){var h=this;h.root=a,h.uniqueString=c,h.keypath=b,h.priority=f,h.fn=i(d,e.length),h.values=[],h.refs=[],e.forEach(function(b,c){b&&(b.indexRef?h.values[c]=b.value:h.refs.push(new g(a,b.keypath,h,c,f)))}),h.selfUpdating=h.refs.length<=1},j.prototype={bubble:function(){this.selfUpdating?this.update():this.deferred||(a.addEvaluator(this),this.deferred=!0)},update:function(){var a;if(this.evaluating)return this;this.evaluating=!0;try{a=this.fn.apply(null,this.values)}catch(g){this.root.debug&&b('Error evaluating "'+this.uniqueString+'": '+g.message||g),a=void 0}return c(a,this.value)||(this.value=a,d(this.root,this.keypath),f(this.root,this.keypath,a,!0),e(this.root,this.keypath)),this.evaluating=!1,this},teardown:function(){for(;this.refs.length;)this.refs.pop().teardown();d(this.root,this.keypath),this.root._evaluators[this.keypath]=null},refresh:function(){this.selfUpdating||(this.deferred=!0);for(var a=this.refs.length;a--;)this.refs[a].update();this.deferred&&(this.update(),this.deferred=!1)},updateSoftDependencies:function(a){var b,c,d;for(this.softRefs||(this.softRefs=[]),b=this.softRefs.length;b--;)d=this.softRefs[b],a[d.keypath]||(this.softRefs.splice(b,1),this.softRefs[d.keypath]=!1,d.teardown());for(b=a.length;b--;)c=a[b],this.softRefs[c]||(d=new h(this.root,c,this),this.softRefs.push(d),this.softRefs[c]=!0);this.selfUpdating=this.refs.length+this.softRefs.length<=1}},j}(D,$,n,L,B,T,Ub,Vb),Xb=function(a,b,c,d,e){function f(a,b){return a.replace(/\$\{([0-9]+)\}/g,function(a,c){return b[c]?b[c].value||b[c].keypath:"undefined"})}function g(a){return"${"+a.replace(/[\.\[\]]/g,"-")+"}"}var h=function(d,e,f,g){var h,i,j,k=this;return h=d.root,this.root=h,this.callback=g,this.owner=d,this.str=f.s,this.args=j=[],this.unresolved=[],this.pending=0,i=e.indexRefs,f.r&&f.r.length?(f.r.forEach(function(d,f){var g,l,m;return i&&void 0!==(g=i[d])?void(j[f]={indexRef:d,value:g}):(l=b(h,d,e))?void(j[f]={keypath:l}):(j[f]=void 0,k.pending+=1,m=new c(h,d,e,function(b){k.resolve(f,b),a(k.unresolved,m)}),void k.unresolved.push(m))}),this.ready=!0,void this.bubble()):(this.resolved=this.ready=!0,void this.bubble())};return h.prototype={bubble:function(){this.ready&&(this.uniqueString=f(this.str,this.args),this.keypath=g(this.uniqueString),this.createEvaluator(),this.callback(this.keypath))},teardown:function(){for(var a;a=this.unresolved.pop();)a.teardown()},resolve:function(a,b){this.args[a]={keypath:b},this.bubble(),this.resolved=!--this.pending},createEvaluator:function(){var a;this.root._evaluators[this.keypath]?this.root._evaluators[this.keypath].refresh():(a=new d(this.root,this.keypath,this.uniqueString,this.str,this.args,this.owner.priority),this.root._evaluators[this.keypath]=a,a.update())},reassign:function(a,b,c,d){var f;this.args.forEach(function(g){var h;g.keypath&&(h=e(g.keypath,c,d))?(g.keypath=h,f=!0):g.indexRef===a&&(g.value=b,f=!0)}),f&&this.bubble()}},h}(u,z,Tb,Wb,Lb),Yb=function(a,b,c,d,e,f,g){var h=function(e,f,h){var j,k,l,m,n,o=this;return j=e.root,k=e.parentFragment,this.ref=f.r,this.root=e.root,this.mustache=e,this.callback=h,this.pending=0,this.unresolved=[],n=this.members=[],this.indexRefMembers=[],this.keypathObservers=[],this.expressionResolvers=[],f.m.forEach(function(f,h){var p,q,r,s,t,u;return"string"==typeof f?void(o.members[h]=f):f.t===a.REFERENCE?(p=f.n,q=k.indexRefs,q&&void 0!==(r=q[p])?(n[h]=r,void o.indexRefMembers.push({ref:p,index:h})):(m=!0,s=function(a){var b=new i(j,a,e.priority,o,h);o.keypathObservers.push(b)},(l=c(j,p,k))?void s(l):(n[h]=void 0,o.pending+=1,t=new d(j,p,k,function(a){o.resolve(h,a),b(o.unresolved,t)}),o.unresolved.push(t),null))):(m=!0,o.pending+=1,u=new g(o,k,f,function(a){o.resolve(h,a),b(o.unresolved,u)}),void o.unresolved.push(u))}),m?(this.ready=!0,void this.bubble()):(l=this.getKeypath(),void h(l))};h.prototype={getKeypath:function(){return this.ref+"."+this.members.join(".")},bubble:function(){this.ready&&!this.pending&&this.callback(this.getKeypath())},resolve:function(a,b){var c=new i(this.root,b,this.mustache.priority,this,a);c.update(),this.keypathObservers.push(c),this.resolved=!--this.pending,this.bubble()},teardown:function(){for(var a;a=this.unresolved.pop();)a.teardown()},reassign:function(a,b){var c,d,e;for(d=this.indexRefMembers.length;d--;)e=this.indexRefMembers[d],e.ref===a&&(c=!0,this.members[e.index]=b);c&&this.bubble()}};var i=function(a,b,c,d,f){this.root=a,this.keypath=b,this.priority=c,this.resolver=d,this.index=f,e(this),this.update()};return i.prototype={update:function(){var a=this.resolver;a.members[this.index]=this.root.get(this.keypath),a.bubble()},teardown:function(){f(this)}},h}(K,u,z,Tb,U,V,Xb),Zb=function(a,b,c,d){return function(e,f){var g,h,i,j,k,l,m;k=f.parentFragment,l=f.descriptor,e.root=k.root,e.parentFragment=k,e.descriptor=f.descriptor,e.index=f.index||0,e.priority=k.priority,e.type=f.descriptor.t,m=function(a){e.resolve(a)},(g=l.r)&&(i=k.indexRefs,i&&void 0!==(j=i[g])?(e.indexRef=g,e.value=j,e.render(e.value)):(h=b(e.root,g,e.parentFragment),void 0!==h?m(h):(e.ref=g,a.addUnresolved(e)))),f.descriptor.x&&(e.resolver=new d(e,k,f.descriptor.x,m)),f.descriptor.kx&&(e.resolver=new c(e,f.descriptor.kx,m)),e.descriptor.n&&!e.hasOwnProperty("value")&&e.render(void 0)}}(D,z,Yb,Xb),$b=function(a,b){var c={evaluateWrapped:!0};return function(){var d=b(this.root,this.keypath,c);a(d,this.value)||(this.render(d),this.value=d)}}(n,Z),_b=function(a,b,c){return function(d){var e;if(d!==this.keypath){if(this.registered&&(c(this),this.type===a.SECTION))for(e=this.fragments.length;e--;)this.fragments[e].reassign(null,null,this.keypath,d);this.keypath=d,b(this),this.update()}}}(K,U,V),ac=function(a){return function(b,c,d,e){var f,g;if(this.resolver?this.resolver.reassign(b,c,d,e):this.keypath?(f=a(this.keypath,d,e),f&&this.resolve(f)):void 0!==b&&this.indexRef===b&&(this.value=c,this.render(c)),this.fragments)for(g=this.fragments.length;g--;)this.fragments[g].reassign(b,c,d,e)}}(Lb),bc=function(a,b,c,d){return{init:a,update:b,resolve:c,reassign:d}}(Zb,$b,_b,ac),cc=function(a,b,c,d){var e,f,g;return f=/</g,g=/>/g,e=function(b,d){this.type=a.INTERPOLATOR,d&&(this.node=document.createTextNode(""),d.appendChild(this.node)),c.init(this,b)},e.prototype={update:c.update,resolve:c.resolve,reassign:c.reassign,detach:d,teardown:function(a){a&&this.detach(),b(this)},render:function(a){this.node&&(this.node.data=void 0==a?"":a)},firstNode:function(){return this.node},toString:function(){var a=void 0!=this.value?""+this.value:"";return a.replace(f,"<").replace(g,">")}},e}(K,Sb,bc,Qb),dc=function(){var a=[];return function(b){var c,d,e,f,g,h,i,j,k=this;for(c=this.parentFragment,g=[],b.forEach(function(b,c){var e,f,h,i;return b===c?void(g[b]=k.fragments[c]):(void 0===d&&(d=c),-1===b?void a.push(k.fragments[c]):(e=k.fragments[c],f=b-c,h=k.keypath+"."+c,i=k.keypath+"."+b,e.reassign(k.descriptor.i,c,b,f,h,i),void(g[b]=e)))});i=a.pop();)i.teardown(!0);if(void 0===d&&(d=this.length),this.length=f=this.root.get(this.keypath).length,f!==d){for(h={descriptor:this.descriptor.f,root:this.root,pNode:c.pNode,owner:this},this.descriptor.i&&(h.indexRef=this.descriptor.i),e=d;f>e;e+=1)(i=g[e])?this.docFrag.appendChild(i.detach(!1)):(h.context=this.keypath+"."+e,h.index=e,i=this.createFragment(h)),this.fragments[e]=i;j=c.findNextNode(this),c.pNode.insertBefore(this.docFrag,j)}}}(),ec=function(a,b){function c(a,b,c){var d,e,f;if(e=b.length,e<a.length)for(f=a.fragments.splice(e,a.length-e);f.length;)f.pop().teardown(!0);else if(e>a.length)for(d=a.length;e>d;d+=1)c.context=a.keypath+"."+d,c.index=d,a.descriptor.i&&(c.indexRef=a.descriptor.i),a.fragments[d]=a.createFragment(c);a.length=e}function d(a,b,c){var d,e,f,g;for(f=a.hasKey||(a.hasKey={}),e=a.fragments.length;e--;)g=a.fragments[e],g.index in b||(a.fragments[e].teardown(!0),a.fragments.splice(e,1),f[g.index]=!1);for(d in b)f[d]||(c.context=a.keypath+"."+d,c.index=d,a.descriptor.i&&(c.indexRef=a.descriptor.i),a.fragments.push(a.createFragment(c)),f[d]=!0);a.length=a.fragments.length}function e(a,b){a.length||(b.context=a.keypath,b.index=0,a.fragments[0]=a.createFragment(b),a.length=1)}function f(b,c,d,e){var f,g,h,i;if(g=a(c)&&0===c.length,f=d?g||!c:c&&!g){if(b.length||(e.index=0,b.fragments[0]=b.createFragment(e),b.length=1),b.length>1)for(h=b.fragments.splice(1);i=h.pop();)i.teardown(!0)}else b.length&&(b.teardownFragments(!0),b.length=0)}return function(g,h){var i={descriptor:g.descriptor.f,root:g.root,pNode:g.parentFragment.pNode,pElement:g.parentFragment.pElement,owner:g};return g.descriptor.n?void f(g,h,!0,i):void(a(h)?c(g,h,i):b(h)||"function"==typeof h?g.descriptor.i?d(g,h,i):e(g,i):f(g,h,!1,i))}}(F,_),fc=function(a,b){return function(c){var d,e;(e=this.root._wrapped[this.keypath])&&(c=e.get()),this.rendering||(this.rendering=!0,b(this,c),this.rendering=!1,(!this.docFrag||this.docFrag.childNodes.length)&&!this.initialising&&a&&(d=this.parentFragment.findNextNode(this),d&&d.parentNode===this.parentFragment.pNode?this.parentFragment.pNode.insertBefore(this.docFrag,d):this.parentFragment.pNode.appendChild(this.docFrag)))}}(h,ec),gc=function(a,b,c,d){var e,f,g,h,i;for(g=a.descriptor.i,e=b;c>e;e+=1)f=a.fragments[e],h=a.keypath+"."+(e-d),i=a.keypath+"."+e,f.index=e,f.reassign(g,e,h,i)},hc=function(a){function b(a){a.teardown(!0)}function c(a,b,c){var d,e,f;for(a.rendering=!0,d={descriptor:a.descriptor.f,root:a.root,pNode:a.parentFragment.pNode,owner:a,indexRef:a.descriptor.i},e=b;c>e;e+=1)d.context=a.keypath+"."+e,d.index=e,a.fragments[e]=a.createFragment(d);f=a.fragments[c]?a.fragments[c].firstNode():a.parentFragment.findNextNode(a),a.parentFragment.pNode.insertBefore(a.docFrag,f),a.rendering=!1}return function(d){var e,f,g,h,i,j=this;if(e=d.balance){if(f=d.start,j.length+=e,0>e)return j.fragments.splice(f,-e).forEach(b),void a(j,f,j.length,e);g=f+d.removed,h=f+d.added,i=[g,0],i.length+=e,j.fragments.splice.apply(j.fragments,i),a(j,h,j.length,e),c(j,g,h)}}}(gc),ic=function(a,b,c,d,e,f,g){var h,i;return g.push(function(){i=g.DomFragment}),h=function(c,d){this.type=a.SECTION,this.inverted=!!c.descriptor.n,this.fragments=[],this.length=0,d&&(this.docFrag=document.createDocumentFragment()),this.initialising=!0,b.init(this,c),d&&d.appendChild(this.docFrag),this.initialising=!1},h.prototype={update:b.update,resolve:b.resolve,reassign:b.reassign,splice:e,merge:c,detach:function(){var a,b;if(this.docFrag){for(b=this.fragments.length,a=0;b>a;a+=1)this.docFrag.appendChild(this.fragments[a].detach());return this.docFrag}},teardown:function(a){this.teardownFragments(a),f(this)},firstNode:function(){return this.fragments[0]?this.fragments[0].firstNode():this.parentFragment.findNextNode(this)},findNextNode:function(a){return this.fragments[a.index+1]?this.fragments[a.index+1].firstNode():this.parentFragment.findNextNode(this)},teardownFragments:function(a){for(var b;b=this.fragments.shift();)b.teardown(a)},render:d,createFragment:function(a){var b=new i(a);return this.docFrag&&this.docFrag.appendChild(b.docFrag),b},toString:function(){var a,b,c;for(a="",b=0,c=this.length,b=0;c>b;b+=1)a+=this.fragments[b].toString();return a},find:function(a){var b,c,d;for(c=this.fragments.length,b=0;c>b;b+=1)if(d=this.fragments[b].find(a))return d;return null},findAll:function(a,b){var c,d;for(d=this.fragments.length,c=0;d>c;c+=1)this.fragments[c].findAll(a,b)},findComponent:function(a){var b,c,d;for(c=this.fragments.length,b=0;c>b;b+=1)if(d=this.fragments[b].findComponent(a))return d;return null},findAllComponents:function(a,b){var c,d;for(d=this.fragments.length,c=0;d>c;c+=1)this.fragments[c].findAllComponents(a,b)}},h}(K,bc,dc,fc,hc,Sb,t),jc=function(a,b,c,d,e){var f=function(b,d){this.type=a.TRIPLE,d&&(this.nodes=[],this.docFrag=document.createDocumentFragment()),this.initialising=!0,c.init(this,b),d&&d.appendChild(this.docFrag),this.initialising=!1};return f.prototype={update:c.update,resolve:c.resolve,reassign:c.reassign,detach:function(){var a,b;if(this.docFrag){for(a=this.nodes.length,b=0;a>b;b+=1)this.docFrag.appendChild(this.nodes[b]);return this.docFrag}},teardown:function(a){a&&(this.detach(),this.docFrag=this.nodes=null),e(this)},firstNode:function(){return this.nodes[0]?this.nodes[0]:this.parentFragment.findNextNode(this)},render:function(a){var b,c;if(this.nodes){for(;this.nodes.length;)b=this.nodes.pop(),b.parentNode.removeChild(b);if(!a)return void(this.nodes=[]);c=this.parentFragment.pNode,this.nodes=d(a,c.tagName,c.namespaceURI,this.docFrag),this.initialising||c.insertBefore(this.docFrag,this.parentFragment.findNextNode(this)),"SELECT"===c.tagName&&c._ractive&&c._ractive.binding&&c._ractive.binding.update()}},t