Commit 2b4a9d49 authored by Kevin Malakoff's avatar Kevin Malakoff Committed by Sindre Sorhus

Close GH-165: Updated Knockback to 0.15.1 and Knockout to 2.1.0.

parent b461a23c
......@@ -30,10 +30,7 @@
</ul>
</section>
<footer id="footer" data-bind="block: todos.tasks_exist">
<span id="todo-count">
<strong data-bind="text: footer.remaining_count"></strong>
<span data-bind="text: footer.remaining_text"></span>
</span>
<span id="todo-count" data-bind="html: footer.remaining_text"></span>
<ul id="filters">
<li>
<a href="#/" data-bind="css: {selected: settings.list_filter_mode()==''}">All</a>
......@@ -63,7 +60,7 @@
<!-- Knockback Dependencies -->
<script src="js/lib/underscore-min.js"></script>
<script src="js/lib/backbone-min.js"></script>
<script src="js/lib/knockout-2.0.0.js"></script>
<script src="js/lib/knockout-2.1.0.js"></script>
<script src="js/lib/knockback.min.js"></script>
<!-- More Demo Dependencies -->
<script src="js/lib/backbone.localStorage-min.js"></script>
......@@ -76,7 +73,6 @@
<script src="js/viewmodels/footer.js"></script>
<script src="js/routers/app.js"></script>
<!-- The Demo -->
<script src="../../assets/base.js"></script>
<script src="js/app.js"></script>
</body>
</html>
\ No newline at end of file
// Generated by CoffeeScript 1.3.1
(function() {
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
$(function() {
var todos;
ko.bindingHandlers.dblclick = {
......@@ -20,17 +21,18 @@
});
},
update: function(element, value_accessor) {
var _this = this;
ko.utils.unwrapObservable(value_accessor());
return _.defer(__bind(function() {
return _.defer(function() {
return ko.bindingHandlers.hasfocus.update(element, value_accessor);
}, this));
});
}
};
window.app = {
viewmodels: {}
};
app.viewmodels.settings = new SettingsViewModel();
todos = new TodosCollection();
todos = new TodoCollection();
app.viewmodels.header = new HeaderViewModel(todos);
app.viewmodels.todos = new TodosViewModel(todos);
app.viewmodels.footer = new FooterViewModel(todos);
......@@ -39,4 +41,5 @@
Backbone.history.start();
return todos.fetch();
});
}).call(this);
// Generated by CoffeeScript 1.3.1
/*
knockback.js 0.14.2
knockback.js 0.15.1
(c) 2011 Kevin Malakoff.
Knockback.js is freely distributable under the MIT license.
See the following for full license details:
......@@ -7,4 +8,4 @@
Dependencies: Knockout.js, Backbone.js, and Underscore.js.
Optional dependency: Backbone.ModelRef.js.
*/
if(!this.ko){throw new Error("Knockback: Dependency alert! Knockout.js must be included before this file")}if(!this.Backbone){throw new Error("Knockback: Dependency alert! Backbone.js must be included before this file")}if(!this._||!this._.VERSION){throw new Error("Knockback: Dependency alert! Underscore.js must be included before this file")}this.Knockback||(this.Knockback={});this.kb||(this.kb=this.Knockback);Knockback.VERSION="0.14.2";Knockback.locale_manager;Knockback.wrappedObservable=function(a){if(!a._kb_observable){throw new Error("Knockback: _kb_observable missing from your instance")}return a._kb_observable};Knockback.setToDefault=function(a){if(a&&a.setToDefault){return a.setToDefault()}};Knockback.vmSetToDefault=function(b){var c,d,a;a=[];for(c in b){d=b[c];a.push(kb.setToDefault(d))}return a};Knockback.vmRelease=function(a){if(a instanceof kb.ViewModel_RCBase){a.release();return}return Knockback.vmReleaseObservables(a)};Knockback.vmReleaseObservables=function(b,d){var c,e,a;a=[];for(c in b){e=b[c];if(!e){continue}if(!(ko.isObservable(e)||(e instanceof kb.Observables)||(e instanceof kb.ViewModel_RCBase))){continue}if(d&&!_.contains(d,c)){continue}b[c]=null;a.push(kb.vmReleaseObservable(e))}return a};Knockback.vmReleaseObservable=function(a){if(!(ko.isObservable(a)||(a instanceof kb.Observables)||(a instanceof kb.ViewModel_RCBase))){return}if(a.destroy){return a.destroy()}else{if(a.dispose){return a.dispose()}else{if(a.release){return a.release()}}}};var __bind=function(a,b){return function(){return a.apply(b,arguments)}},__hasProp=Object.prototype.hasOwnProperty,__extends=function(d,b){for(var a in b){if(__hasProp.call(b,a)){d[a]=b[a]}}function c(){this.constructor=d}c.prototype=b.prototype;d.prototype=new c;d.__super__=b.prototype;return d};if(!this.Knockback){throw new Error("Knockback: Dependency alert! knockback_core.js must be included before this file")}Knockback.CollectionObservable=(function(){function a(j,i,l){var b,d,g,f,k,c,h,e;this.vm_observable_array=i;if(l==null){l={}}if(!j){throw new Error("CollectionObservable: collection is missing")}if(l.hasOwnProperty("view_model")){l.view_model_constructor=l.view_model;delete l.view_model}if(this.vm_observable_array||l.view_model_create||l.view_model_constructor){if(!this.vm_observable_array){throw new Error("CollectionObservable: vm_observable_array is missing")}}if(l.hasOwnProperty("defer")){b=l.defer;delete l.defer}this.options=_.clone(l);_.bindAll(this,"destroy","collection","sortedIndex","sortAttribute","viewModelByModel","eachViewModel","bind","unbind","trigger");_.bindAll(this,"_onGetValue","_onCollectionReset","_onCollectionResort","_onModelAdd","_onModelRemove","_onModelChanged");this._kb_collection=j;if(this._kb_collection.retain){this._kb_collection.retain()}this._kb_collection.bind("reset",this._onCollectionReset);if(!this.options.sorted_index){this._kb_collection.bind("resort",this._onCollectionResort)}h=["new","add"];for(g=0,k=h.length;g<k;g++){d=h[g];this._kb_collection.bind(d,this._onModelAdd)}e=["remove","destroy"];for(f=0,c=e.length;f<c;f++){d=e[f];this._kb_collection.bind(d,this._onModelRemove)}this._kb_collection.bind("change",this._onModelChanged);this._kb_value_observable=ko.observableArray([]);this._kb_observable=ko.dependentObservable(this._onGetValue);this._kb_observable.destroy=this.destroy;this._kb_observable.collection=this.collection;this._kb_observable.viewModelByModel=this.viewModelByModel;this._kb_observable.eachViewModel=this.eachViewModel;this._kb_observable.sortedIndex=this.sortedIndex;this._kb_observable.sortAttribute=this.sortAttribute;this._kb_observable.bind=this.bind;this._kb_observable.unbind=this.unbind;this._kb_observable.trigger=this.trigger;this.sortedIndex(this.options.sorted_index,this.options.sort_attribute,{silent:true,defer:b});return kb.wrappedObservable(this)}a.prototype.destroy=function(){var e,g,d,c,b,f,h;this._clearViewModels();this._kb_collection.unbind("reset",this._onCollectionReset);if(!this.options.sorted_index){this._kb_collection.unbind("resort",this._onCollectionResort)}f=["new","add"];for(g=0,c=f.length;g<c;g++){e=f[g];this._kb_collection.unbind(e,this._onModelAdd)}h=["remove","destroy"];for(d=0,b=h.length;d<b;d++){e=h[d];this._kb_collection.unbind(e,this._onModelRemove)}this._kb_collection.unbind("change",this._onModelChanged);if(this._kb_collection.release){this._kb_collection.release()}this._kb_collection=null;this._kb_value_observable=null;this._kb_observable.dispose();this._kb_observable=null;return this.options=null};a.prototype.collection=function(){this._kb_value_observable();return this._kb_collection};a.prototype.sortedIndex=function(e,b,c){var d;if(c==null){c={}}if(e){this.options.sorted_index=e;this.options.sort_attribute=b}else{if(b){this.options.sort_attribute=b;this.options.sorted_index=this._sortAttributeFn(b)}else{this.options.sort_attribute=null;this.options.sorted_index=null}}d=__bind(function(){if((this._kb_collection.models.length===0)&&(this._kb_value_observable().length===0)){return}this._collectionResync(true);if(!c.silent){return this.trigger("resort",this.vm_observable_array())}},this);if(c.defer){_.defer(d)}else{d()}return this};a.prototype.sortAttribute=function(c,d,b){return this.sortedIndex(d,c,b)};a.prototype._sortAttributeFn=function(b){return function(d,c){return _.sortedIndex(d,c,function(e){return e.get(b)})}};a.prototype.viewModelByModel=function(c){var b;if(!this.vm_observable_array){throw new Error("CollectionObservable: cannot get a view model if vm_observable_array was not supplied")}b=c.hasOwnProperty(c.idAttribute)?c.idAttribute:"cid";return _.find(this.vm_observable_array(),function(d){return d.__kb_model[b]===c[b]})};a.prototype.eachViewModel=function(e){var d,g,c,f,b;f=this.vm_observable_array();b=[];for(g=0,c=f.length;g<c;g++){d=f[g];b.push(e(d))}return b};a.prototype._onGetValue=function(){return this._kb_value_observable()};a.prototype._onCollectionReset=function(){return this._collectionResync()};a.prototype._onCollectionResort=function(b){if(this.options.sorted_index){throw new Error("CollectionObservable: collection sorted_index unexpected")}if(_.isArray(b)){this._collectionResync(true);return this.trigger("resort",this.vm_observable_array())}else{return this._onModelResort(b)}};a.prototype._onModelAdd=function(d){var b,e,c;if(this.options.sorted_index){e=_.pluck(this.vm_observable_array(),"__kb_model");b=this.options.sorted_index(e,d)}else{b=this._kb_collection.indexOf(d)}if(this.vm_observable_array){c=this._viewModelCreate(d);this.vm_observable_array.splice(b,0,c)}this._kb_value_observable.splice(b,0,d);if(this.vm_observable_array){return this.trigger("add",c,this.vm_observable_array())}};a.prototype._onModelRemove=function(c){var b;this._kb_value_observable.remove(c);if(this.vm_observable_array){b=this.viewModelByModel(c);if(!b){return}this.vm_observable_array.remove(b);this.trigger("remove",b,this.vm_observable_array());kb.vmRelease(b);return b.__kb_model=null}};a.prototype._onModelChanged=function(b){if(this.options.sorted_index&&(!this.options.sort_attribute||b.hasChanged(this.options.sort_attribute))){this._onModelResort(b)}return this._kb_value_observable.valueHasMutated()};a.prototype._onModelResort=function(d){var b,f,e,c;f=this._kb_value_observable.indexOf(d);if(this.options.sorted_index){e=_.clone(this._kb_value_observable());e.splice(f,1);b=this.options.sorted_index(e,d)}else{b=this._kb_collection.indexOf(d)}if(f===b){return}if(this.vm_observable_array){c=this.viewModelByModel(d);this.vm_observable_array.splice(f,1);this.vm_observable_array.splice(b,0,c)}this._kb_value_observable.splice(f,1);this._kb_value_observable.splice(b,0,d);if(this.vm_observable_array){return this.trigger("resort",c,this.vm_observable_array(),b)}};a.prototype._clearViewModels=function(e){var d,f,g,c,b;if(this.vm_observable_array){if(!e){this.trigger("remove",this.vm_observable_array())}f=this.vm_observable_array.removeAll();b=[];for(g=0,c=f.length;g<c;g++){d=f[g];b.push(kb.vmRelease(d))}return b}};a.prototype._collectionResync=function(j){var b,i,d,e,g,f,k,c,h;this._clearViewModels(j);this._kb_value_observable.removeAll();if(this.options.sorted_index){d=[];h=this._kb_collection.models;for(g=0,k=h.length;g<k;g++){i=h[g];b=this.options.sorted_index(d,i);d.splice(b,0,i)}}else{d=_.clone(this._kb_collection.models)}if(this.vm_observable_array){e=[];for(f=0,c=d.length;f<c;f++){i=d[f];e.push(this._viewModelCreate(i))}this.vm_observable_array(e)}this._kb_value_observable(d);if(this.vm_observable_array){if(!j){return this.trigger("add",this.vm_observable_array())}}};a.prototype._viewModelCreate=function(c){var b;if(this.options.view_model_create){b=this.options.view_model_create(c)}else{if(this.options.view_model_constructor){b=new this.options.view_model_constructor(c)}else{b=kb.viewModel(c)}}b.__kb_model=c;return b};return a})();__extends(Knockback.CollectionObservable.prototype,Backbone.Events);Knockback.collectionObservable=function(b,c,a){return new Knockback.CollectionObservable(b,c,a)};Knockback.viewModelGetModel=Knockback.vmModel=function(a){if(a){return a.__kb_model}else{return null}};Knockback.sortedIndexWrapAttr=Knockback.siwa=function(a,b){return function(d,c){return _.sortedIndex(d,c,function(e){return new b(e.get(a))})}};var __bind=function(a,b){return function(){return a.apply(b,arguments)}};if(!this.Knockback){throw new Error("Knockback: Dependency alert! knockback_core.js must be included before this file")}Knockback.DefaultWrapper=(function(){function a(c,b){this.default_value=b;_.bindAll(this,"destroy","setToDefault");this._kb_observable=ko.dependentObservable({read:__bind(function(){var d;d=ko.utils.unwrapObservable(c());if(!d){return ko.utils.unwrapObservable(this.default_value)}else{return d}},this),write:function(d){return c(d)},owner:{}});this._kb_observable.destroy=this.destroy;this._kb_observable.setToDefault=this.setToDefault;return kb.wrappedObservable(this)}a.prototype.destroy=function(){this._kb_observable=null;return this.default_value=null};a.prototype.setToDefault=function(){return this._kb_observable(this.default_value)};return a})();Knockback.defaultWrapper=function(b,a){return new Knockback.DefaultWrapper(b,a)};if(!this.Knockback){throw new Error("Knockback: Dependency alert! knockback_core.js must be included before this file")}Knockback.toFormattedString=function(g){var b,e,d,c,a,f;a=g.slice();e=Array.prototype.slice.call(arguments,1);for(d in e){b=e[d];f=ko.utils.unwrapObservable(b);if(!f){f=""}c=g.indexOf("{"+d+"}");while(c>=0){a=a.replace("{"+d+"}",f);c=g.indexOf("{"+d+"}",c+1)}}return a};Knockback.parseFormattedString=function(h,m){var i,a,j,k,g,p,o,f,l,b,e,n,d,c;b=m.slice();j=0;p=0;f={};while(b.search("\\{"+j+"\\}")>=0){o=m.indexOf("{"+j+"}");while(o>=0){b=b.replace("{"+j+"}","(.*)");f[o]=j;p++;o=m.indexOf("{"+j+"}",o+1)}j++}i=j;l=new RegExp(b);g=l.exec(h);if(g){g.shift()}if(!g||(g.length!==p)){return _.map((function(){c=[];for(var q=1;1<=i?q<=i:q>=i;1<=i?q++:q--){c.push(q)}return c}).apply(this),function(){return""})}n=_.sortBy(_.keys(f),function(q,r){return parseInt(q,10)});a={};for(k in n){o=n[k];j=f[o];if(a.hasOwnProperty(j)){continue}a[j]=k}e=[];j=0;while(j<i){e.push(g[a[j]]);j++}return e};Knockback.formattedObservable=function(d,c){var b,a;b=Array.prototype.slice.call(arguments,1);a=ko.dependentObservable({read:function(){var e,g,f;c=[ko.utils.unwrapObservable(d)];for(g=0,f=b.length;g<f;g++){e=b[g];c.push(ko.utils.unwrapObservable(e))}return kb.toFormattedString.apply(null,c)},write:function(h){var f,g,i,e;g=kb.parseFormattedString(h,ko.utils.unwrapObservable(d));i=Math.min(b.length,g.length);f=0;e=[];while(f<i){b[f](g[f]);e.push(f++)}return e},owner:{}});return a};if(!this.Knockback){throw new Error("Knockback: Dependency alert! knockback_core.js must be included before this file")}Knockback.LocalizedObservable=(function(){function a(d,c,b){this.value=d;this.options=c!=null?c:{};this.view_model=b;if(!(this.options.read||this.read)){throw new Error("LocalizedObservable: options.read is missing")}if(this.options.read&&this.read){throw new Error("LocalizedObservable: options.read and read class function exist. You need to choose one.")}if(this.options.write&&this.write){throw new Error("LocalizedObservable: options.write and write class function exist. You need to choose one.")}if(!kb.locale_manager){throw new Error("LocalizedObservable: Knockback.locale_manager is not defined")}_.bindAll(this,"destroy","setToDefault","resetToCurrent","observedValue","_onGetValue","_onSetValue","_onLocaleChange");this._kb_read=this.options.read?this.options.read:this.read;this._kb_write=this.options.write?this.options.write:this.write;this._kb_default=this.options["default"]?this.options["default"]:this["default"];if(this.value){d=ko.utils.unwrapObservable(this.value)}this._kb_value_observable=ko.observable(!d?this._getDefaultValue():this._kb_read.call(this,d,null));if(this._kb_write){if(!this.view_model){this.view_model={}}if(!_.isFunction(this._kb_write)){throw new Error("LocalizedObservable: options.write is not a function for read_write model attribute")}this._kb_observable=ko.dependentObservable({read:this._onGetValue,write:this._onSetValue,owner:this.view_model})}else{this._kb_observable=ko.dependentObservable(this._onGetValue)}this._kb_observable.destroy=this.destroy;this._kb_observable.observedValue=this.observedValue;this._kb_observable.setToDefault=this.setToDefault;this._kb_observable.resetToCurrent=this.resetToCurrent;kb.locale_manager.bind("change",this._onLocaleChange);return kb.wrappedObservable(this)}a.prototype.destroy=function(){kb.locale_manager.unbind("change",this._onLocaleChange);this._kb_value_observable=null;this._kb_observable.dispose();this._kb_observable=null;this.options={};return this.view_model=null};a.prototype.setToDefault=function(){var c,b;if(!this._kb_default){return}b=this._getDefaultValue();c=this._kb_value_observable();if(c!==b){return this._onSetValue(b)}else{return this._kb_value_observable.valueHasMutated()}};a.prototype.resetToCurrent=function(){this._kb_value_observable(null);return this._onSetValue(this._getCurrentValue())};a.prototype.observedValue=function(b){if(arguments.length===0){return this.value}this.value=b;this._onLocaleChange();return this};a.prototype._getDefaultValue=function(){if(!this._kb_default){return""}if(_.isFunction(this._kb_default)){return this._kb_default()}else{return this._kb_default}};a.prototype._getCurrentValue=function(){if(!(this.value&&this._kb_observable)){return this._getDefaultValue()}return this._kb_read.call(this,ko.utils.unwrapObservable(this.value),this._kb_observable)};a.prototype._onGetValue=function(){if(this.value){ko.utils.unwrapObservable(this.value)}return this._kb_value_observable()};a.prototype._onSetValue=function(b){this._kb_write.call(this,b,ko.utils.unwrapObservable(this.value),this._kb_observable);b=this._kb_read.call(this,ko.utils.unwrapObservable(this.value),this._kb_observable);this._kb_value_observable(b);if(this.options.onChange){return this.options.onChange(b)}};a.prototype._onLocaleChange=function(){var b;b=this._kb_read.call(this,ko.utils.unwrapObservable(this.value),this._kb_observable);this._kb_value_observable(b);if(this.options.onChange){return this.options.onChange(b)}};return a})();Knockback.localizedObservable=function(c,b,a){return new Knockback.LocalizedObservable(c,b,a)};if(!this.Knockback){throw new Error("Knockback: Dependency alert! knockback_core.js must be included before this file")}Knockback.Observable=(function(){function a(d,c,b){this.model=d;this.options=c;this.view_model=b;if(!this.model){throw new Error("Observable: model is missing")}if(!this.options){throw new Error("Observable: options is missing")}if(_.isString(this.options)||ko.isObservable(this.options)){this.options={key:this.options}}if(!this.options.key){throw new Error("Observable: options.key is missing")}_.bindAll(this,"destroy","setToDefault","_onGetValue","_onSetValue","_onModelChange","_onModelLoaded","_onModelUnloaded");if(Backbone.ModelRef&&(this.model instanceof Backbone.ModelRef)){this.model_ref=this.model;this.model_ref.retain();this.model_ref.bind("loaded",this._onModelLoaded);this.model_ref.bind("unloaded",this._onModelUnloaded);this.model=this.model_ref.getModel()}this._kb_value_observable=ko.observable();if(this.options.localizer){this._kb_localizer=new this.options.localizer(this._getCurrentValue())}if(this.options.write){if(!this.view_model){this.view_model={}}this._kb_observable=ko.dependentObservable({read:this._onGetValue,write:this._onSetValue,owner:this.view_model})}else{this._kb_observable=ko.dependentObservable(this._onGetValue)}this._kb_observable.destroy=this.destroy;this._kb_observable.setToDefault=this.setToDefault;if(!this.model_ref||this.model_ref.isLoaded()){this.model.bind("change",this._onModelChange)}return kb.wrappedObservable(this)}a.prototype.destroy=function(){this._kb_value_observable=null;this._kb_observable.dispose();this._kb_observable=null;if(this.model){this._onModelUnloaded(this.model)}if(this.model_ref){this.model_ref.unbind("loaded",this._onModelLoaded);this.model_ref.unbind("unloaded",this._onModelUnloaded);this.model_ref.release();this.model_ref=null}this.options=null;return this.view_model=null};a.prototype.setToDefault=function(){var b;b=this._getDefaultValue();if(this._kb_localizer){this._kb_localizer.observedValue(b);b=this._kb_localizer()}return this._kb_value_observable(b)};a.prototype._getDefaultValue=function(){if(!this.options.hasOwnProperty("default")){return""}if(_.isFunction(this.options["default"])){return this.options["default"]()}else{return this.options["default"]}};a.prototype._getCurrentValue=function(){var b,d,e,g,c,f;if(!this.model){return this._getDefaultValue()}e=ko.utils.unwrapObservable(this.options.key);d=[e];if(!_.isUndefined(this.options.args)){if(_.isArray(this.options.args)){f=this.options.args;for(g=0,c=f.length;g<c;g++){b=f[g];d.push(ko.utils.unwrapObservable(b))}}else{d.push(ko.utils.unwrapObservable(this.options.args))}}if(this.options.read){return this.options.read.apply(this.view_model,d)}else{return this.model.get.apply(this.model,d)}};a.prototype._onGetValue=function(){var b,f,e,c,d;this._kb_value_observable();ko.utils.unwrapObservable(this.options.key);if(!_.isUndefined(this.options.args)){if(_.isArray(this.options.args)){d=this.options.args;for(e=0,c=d.length;e<c;e++){b=d[e];ko.utils.unwrapObservable(b)}}else{ko.utils.unwrapObservable(this.options.args)}}f=this._getCurrentValue();if(this._kb_localizer){this._kb_localizer.observedValue(f);f=this._kb_localizer()}return f};a.prototype._onSetValue=function(h){var b,e,d,g,c,f;if(this._kb_localizer){this._kb_localizer(h);h=this._kb_localizer.observedValue()}if(this.model){d={};d[ko.utils.unwrapObservable(this.options.key)]=h;e=_.isFunction(this.options.write)?[h]:[d];if(!_.isUndefined(this.options.args)){if(_.isArray(this.options.args)){f=this.options.args;for(g=0,c=f.length;g<c;g++){b=f[g];e.push(ko.utils.unwrapObservable(b))}}else{e.push(ko.utils.unwrapObservable(this.options.args))}}if(_.isFunction(this.options.write)){this.options.write.apply(this.view_model,e)}else{this.model.set.apply(this.model,e)}}if(this._kb_localizer){return this._kb_value_observable(this._kb_localizer())}else{return this._kb_value_observable(h)}};a.prototype._onModelLoaded=function(b){this.model=b;this.model.bind("change",this._onModelChange);return this._updateValue()};a.prototype._onModelUnloaded=function(b){if(this._kb_localizer&&this._kb_localizer.destroy){this._kb_localizer.destroy();this._kb_localizer=null}this.model.unbind("change",this._onModelChange);return this.model=null};a.prototype._onModelChange=function(){if((this.model&&this.model.hasChanged)&&!this.model.hasChanged(ko.utils.unwrapObservable(this.options.key))){return}return this._updateValue()};a.prototype._updateValue=function(){var b;b=this._getCurrentValue();if(this._kb_localizer){this._kb_localizer.observedValue(b);b=this._kb_localizer()}return this._kb_value_observable(b)};return a})();Knockback.observable=function(c,b,a){return new Knockback.Observable(c,b,a)};if(!this.Knockback){throw new Error("Knockback: Dependency alert! knockback_core.js must be included before this file")}Knockback.Observables=(function(){function a(e,f,k,d){var g,h,i,j,c,b;this.model=e;this.mappings_info=f;this.view_model=k;if(!this.model){throw new Error("Observables: model is missing")}if(!this.mappings_info){throw new Error("Observables: mappings_info is missing")}if(!!d&&((_.isBoolean(d)&&d)||!!d.write)){j=_.isBoolean(d)?d:!!d.write;c=this.mappings_info;for(i in c){h=c[i];g=_.isString(h);if(g||!h.hasOwnProperty(j)){h=g?{key:h,write:j}:_.extend({write:j},h)}this.view_model[i]=kb.observable(this.model,h,this.view_model)}}else{b=this.mappings_info;for(i in b){h=b[i];this.view_model[i]=kb.observable(this.model,h,this.view_model)}}}a.prototype.destroy=function(){var b,d,c;c=this.mappings_info;for(d in c){b=c[d];if(this.view_model[d]){this.view_model[d].destroy()}this.view_model[d]=null}this.view_model=null;this.mappings_info=null;return this.model=null};a.prototype.setToDefault=function(){var c,e,d,b;d=this.mappings_info;b=[];for(e in d){c=d[e];b.push(this.view_model[e].setToDefault())}return b};return a})();Knockback.observables=function(c,d,a,b){return new Knockback.Observables(c,d,a,b)};if(!this.Knockback){throw new Error("Knockback: Dependency alert! knockback_core.js must be included before this file")}Knockback.TriggeredObservable=(function(){function a(b,c){this.model=b;this.event_name=c;if(!this.model){throw new Error("Observable: model is missing")}if(!this.event_name){throw new Error("Observable: event_name is missing")}_.bindAll(this,"destroy","_onGetValue","_onValueChange","_onModelLoaded","_onModelUnloaded");if(Backbone.ModelRef&&(this.model instanceof Backbone.ModelRef)){this.model_ref=this.model;this.model_ref.retain();this.model_ref.bind("loaded",this._onModelLoaded);this.model_ref.bind("unloaded",this._onModelUnloaded);this.model=this.model_ref.getModel()}this._kb_value_observable=ko.observable();this._kb_observable=ko.dependentObservable(this._onGetValue);this._kb_observable.destroy=this.destroy;if(!this.model_ref||this.model_ref.isLoaded()){this._onModelLoaded(this.model)}return kb.wrappedObservable(this)}a.prototype.destroy=function(){this._kb_observable.dispose();this._kb_observable=null;this._kb_value_observable=null;if(this.model){this._onModelUnloaded(this.model)}if(this.model_ref){this.model_ref.unbind("loaded",this._onModelLoaded);this.model_ref.unbind("unloaded",this._onModelUnloaded);this.model_ref.release();this.model_ref=null}this.options=null;return this.view_model=null};a.prototype._onGetValue=function(){return this._kb_value_observable()};a.prototype._onModelLoaded=function(b){this.model=b;this.model.bind(this.event_name,this._onValueChange);return this._onValueChange()};a.prototype._onModelUnloaded=function(){if(this._kb_localizer&&this._kb_localizer.destroy){this._kb_localizer.destroy();this._kb_localizer=null}this.model.unbind(this.event_name,this._onValueChange);return this.model=null};a.prototype._onValueChange=function(){var b;b=this._kb_value_observable();if(b!==this.model){return this._kb_value_observable(this.model)}else{return this._kb_value_observable.valueHasMutated()}};return a})();Knockback.triggeredObservable=function(a,b){return new Knockback.TriggeredObservable(a,b)};var AttributeConnector;var __bind=function(a,b){return function(){return a.apply(b,arguments)}},__hasProp=Object.prototype.hasOwnProperty,__extends=function(d,b){for(var a in b){if(__hasProp.call(b,a)){d[a]=b[a]}}function c(){this.constructor=d}c.prototype=b.prototype;d.prototype=new c;d.__super__=b.prototype;return d};if(!this.Knockback){throw new Error("Knockback: Dependency alert! knockback_core.js must be included before this file")}AttributeConnector=(function(){function a(b,c,d){this.key=c;this.read_only=d;_.bindAll(this,"destroy","update");this._kb_observable=ko.observable();this._kb_observable.subscription=this._kb_observable.subscribe(__bind(function(f){var e;if(this.read_only){if(this.model){f=this.model.get(this.key);if(this._kb_observable()===f){return}this._kb_observable(f)}throw"Cannot write a value to a dependentObservable unless you specify a 'write' option. If you wish to read the current value, don't pass any parameters."}else{if(this.model){e={};e[this.key]=f;return this.model.set(e)}}},this));this._kb_observable.destroy=this.destroy;this._kb_observable.update=this.update;this.update(b);return kb.wrappedObservable(this)}a.prototype.destroy=function(){this.model=null;return this._kb_observable=null};a.prototype.update=function(b){var c,d;if(b){d=b.get(this.key);c=(this.model!==b)||!_.isEqual(this._kb_observable(),d);this.model=b;if(c){return this._kb_observable(d)}}else{return this.model=null}};return a})();Knockback.ViewModel_RCBase=(function(){function a(){this._kb_vm={};this._kb_vm.ref_count=1}a.extend=Backbone.Model.extend;a.prototype.__destroy=function(){return kb.vmReleaseObservables(this)};a.prototype.retain=function(){if(this._kb_vm.ref_count<=0){throw new Error("ViewModel: ref_count is corrupt: "+this._kb_vm.ref_count)}this._kb_vm.ref_count++;return this};a.prototype.release=function(){if(this._kb_vm.ref_count<=0){throw new Error("ViewModel: ref_count is corrupt: "+this._kb_vm.ref_count)}this._kb_vm.ref_count--;if(!this._kb_vm.ref_count){this.__destroy()}return this};a.prototype.refCount=function(){return this._kb_vm.ref_count};return a})();Knockback.ViewModel=(function(){__extends(a,kb.ViewModel_RCBase);function a(e,d,c){var g,f,h,b;if(d==null){d={}}a.__super__.constructor.apply(this,arguments);this._kb_vm.model=e;this._kb_vm.options=d;this._kb_vm.view_model=c;if(!this._kb_vm.model){throw new Error("ViewModel: model is missing")}_.bindAll(this,"_kb_vm_onModelChange","_kb_vm_onModelLoaded","_kb_vm_onModelUnloaded");if(!this._kb_vm.view_model){this._kb_vm.view_model=this}else{this._kb_vm.observables=[]}if(Backbone.ModelRef&&(this._kb_vm.model instanceof Backbone.ModelRef)){this._kb_vm.model_ref=this._kb_vm.model;this._kb_vm.model_ref.retain();this._kb_vm.model_ref.bind("loaded",this._kb_vm_onModelLoaded);this._kb_vm.model_ref.bind("unloaded",this._kb_vm_onModelUnloaded);this._kb_vm.model=this._kb_vm.model_ref.getModel()}if(!this._kb_vm.model_ref||this._kb_vm.model_ref.isLoaded()){this._kb_vm_onModelLoaded(this._kb_vm.model)}if(!this._kb_vm.options.internals&&!this._kb_vm.options.requires){return this}f=_.union((this._kb_vm.options.internals?this._kb_vm.options.internals:[]),(this._kb_vm.options.requires?this._kb_vm.options.requires:[]));if(!this._kb_vm.model_ref||this._kb_vm.model_ref.isLoaded()){f=_.difference(f,_.keys(this._kb_vm.model.attributes))}for(h=0,b=f.length;h<b;h++){g=f[h];this._updateAttributeObservor(this._kb_vm.model,g)}}a.prototype.__destroy=function(){var b;if(this._kb_vm.model){this._kb_vm.model.unbind("change",this._kb_vm_onModelChange);this._kb_vm.model=null}b=this._kb_vm.view_model;this._kb_vm.view_model=null;kb.vmReleaseObservables(b,this._kb_vm.observables);if(this._kb_vm.observables){return this._kb_vm.observables=null}};a.prototype._kb_vm_onModelLoaded=function(c){var d,b;this._kb_vm.model=c;this._kb_vm.model.bind("change",this._kb_vm_onModelChange);b=[];for(d in this._kb_vm.model.attributes){b.push(this._updateAttributeObservor(this._kb_vm.model,d))}return b};a.prototype._kb_vm_onModelUnloaded=function(c){var d,b;this._kb_vm.model.unbind("change",this._kb_vm_onModelChange);c=this._kb_vm.model;this._kb_vm.model=null;b=[];for(d in c.attributes){b.push(this._updateAttributeObservor(this._kb_vm.model,d))}return b};a.prototype._kb_vm_onModelChange=function(){var d,b,c;if(this._kb_vm.model._changed){b=[];for(d in this._kb_vm.model.attributes){b.push((this._kb_vm.model.hasChanged(d)?this._updateAttributeObservor(this._kb_vm.model,d):void 0))}return b}else{if(this._kb_vm.model.changed){c=[];for(d in this._kb_vm.model.changed){c.push(this._updateAttributeObservor(this._kb_vm.model,d))}return c}}};a.prototype._updateAttributeObservor=function(b,d){var c;c=this._kb_vm.options.internals&&_.contains(this._kb_vm.options.internals,d)?"_"+d:d;if(this._kb_vm.view_model.hasOwnProperty(c)){if(this._kb_vm.view_model[c]){return this._kb_vm.view_model[c].update(b)}}else{if(this._kb_vm.observables){this._kb_vm.observables.push(c)}return this._kb_vm.view_model[c]=new AttributeConnector(b,d,this._kb_vm.options.read_only)}};return a})();Knockback.viewModel=function(c,b,a){return new Knockback.ViewModel(c,b,a)};
\ No newline at end of file
var Backbone,Knockback,kb,ko,_;if(typeof exports!=="undefined"){Knockback=kb=exports}else{this.Knockback=this.kb={}}Knockback.VERSION="0.15.1";_=!this._&&(typeof require!=="undefined")?require("underscore"):this._;Backbone=!this.Backbone&&(typeof require!=="undefined")?require("backbone"):this.Backbone;ko=!this.ko&&(typeof require!=="undefined")?require("knockout"):this.ko;Knockback.locale_manager;Knockback.stats={collection_observables:0,view_models:0};Knockback.stats_on=false;Knockback.utils={};Knockback.utils.legacyWarning=function(a,d,c){var b;kb._legacy_warnings||(kb._legacy_warnings={});(b=kb._legacy_warnings)[a]||(b[a]=0);kb._legacy_warnings[a]++;return console.warn("Legacy warning! '"+a+"' has been deprecated (will be removed in Knockback "+d+"). "+c+".")};Knockback.utils.wrappedObservable=function(a,b){if(arguments.length===1){if(!(a&&a.__kb&&a.__kb.observable)){throw new Error("Knockback: instance is not wrapping an observable")}return a.__kb.observable}if(!a){throw new Error("Knockback: no instance for wrapping a observable")}a.__kb||(a.__kb={});if(a.__kb.observable&&a.__kb.observable.__kb){a.__kb.observable.__kb.instance=null}a.__kb.observable=b;if(b){b.__kb||(b.__kb={});b.__kb.instance=a}return b};Knockback.wrappedObservable=function(a){kb.utils.legacyWarning("kb.wrappedObservable","0.16.0","Please use kb.utils.wrappedObservable instead");return kb.utils.wrappedObservable(a)};Knockback.utils.observableInstanceOf=function(b,a){if(!b){return false}if(!(b.__kb&&b.__kb.instance)){return false}return b.__kb.instance instanceof a};Knockback.utils.wrappedModel=function(a,b){if(arguments.length===1){if(a&&a.__kb&&a.__kb.hasOwnProperty("model")){return a.__kb.model}else{return a}}if(!a){throw new Error("Knockback: no view_model for wrapping a model")}a.__kb||(a.__kb={});a.__kb.model=b;return b};Knockback.viewModelGetModel=Knockback.vmModel=function(a){kb.utils.legacyWarning("kb.vmModel","0.16.0","Please use kb.utils.wrappedModel instead");return kb.utils.wrappedModel(a)};Knockback.utils.setToDefault=function(d){var b,c,a;if(!d){return}if(ko.isObservable(d)){return typeof d.setToDefault==="function"?d.setToDefault():void 0}else{if(_.isObject(d)){a=[];for(b in d){c=d[b];a.push(c&&(b!=="__kb")?kb.utils.setToDefault(c):void 0)}return a}}};Knockback.vmSetToDefault=function(a){kb.utils.legacyWarning("kb.vmSetToDefault","0.16.0","Please use kb.utils.release instead");return kb.utils.setToDefault(a)};Knockback.utils.release=function(c){var a,b;if(!c){return false}if(ko.isObservable(c)||(c instanceof kb.Observables)||(typeof c.release==="function")||(typeof c.destroy==="function")){if(c.release){c.release()}else{if(c.destroy){c.destroy()}else{if(c.dispose){c.dispose()}}}return true}else{if(_.isObject(c)&&!(typeof c==="function")){for(a in c){b=c[a];if(!b||(a==="__kb")){continue}if(kb.utils.release(b)){c[a]=null}}return true}}return false};Knockback.vmRelease=function(a){kb.utils.legacyWarning("kb.vmRelease","0.16.0","Please use kb.utils.release instead");return kb.utils.release(a)};Knockback.vmReleaseObservable=function(a){kb.utils.legacyWarning("kb.vmReleaseObservable","0.16.0","Please use kb.utils.release instead");return kb.utils.release(a)};kb.utils.optionsCreateClear=function(a){delete a.create;delete a.children;delete a.view_model;return delete a.view_model_create};kb.utils.optionsCreateOverride=function(a,b){kb.utils.optionsCreateClear(a);return _.extend(a,b)};Knockback.RefCountable=(function(){a.name="RefCountable";a.extend=Backbone.Model.extend;function a(){this.__kb||(this.__kb={});this.__kb.ref_count=1}a.prototype.__destroy=function(){};a.prototype.retain=function(){if(this.__kb.ref_count<=0){throw new Error("RefCountable: ref_count is corrupt: "+this.__kb.ref_count)}this.__kb.ref_count++;return this};a.prototype.release=function(){if(this.__kb.ref_count<=0){throw new Error("RefCountable: ref_count is corrupt: "+this.__kb.ref_count)}this.__kb.ref_count--;if(!this.__kb.ref_count){this.__destroy()}return this};a.prototype.refCount=function(){return this.__kb.ref_count};return a})();Knockback.Store=(function(){a.name="Store";function a(){this.keys=[];this.values=[]}a.prototype.destroy=function(){var c,e,d,b;this.keys=null;d=this.values;for(c in d){e=d[c];if(!kb.utils.observableInstanceOf(e,kb.CollectionObservable)){continue}this.values[c]=null;while(e.refCount()>0){e.release()}}b=this.values;for(c in b){e=b[c];if(!e){continue}this.values[c]=null;if(e instanceof kb.RefCountable){while(e.refCount()>0){e.release()}}else{kb.utils.release(e)}}return this.values=null};a.prototype.registerValue=function(c,d){var b;if(d instanceof kb.RefCountable){d.retain()}b=_.indexOf(this.keys,c);if(b>=0){this.values[b]=d}else{this.keys.push(c);this.values.push(d)}return d};a.prototype.resolveValue=function(d,f,c){var b,e;b=_.indexOf(this.keys,d);if(b>=0){if(this.values[b]){if((this.values[b] instanceof kb.RefCountable)&&(this.values[b].refCount()<=0)){this.values[b]=null}else{if(this.values[b] instanceof kb.RefCountable){return this.values[b].retain()}else{return this.values[b]}}}}else{b=this.keys.length;this.keys.push(d);this.values.push(void 0)}e=f.apply(null,Array.prototype.slice.call(arguments,2));if(this.keys[b]!==d){this.registerValue(d,e)}else{if(!this.values[b]){if(e instanceof kb.RefCountable){e.retain()}this.values[b]=e}}return e};a.prototype.releaseValue=function(c){var b;if(!(c instanceof kb.RefCountable)){return}c.release();if(c.refCount()>0){return}b=_.indexOf(this.values,c);if(!(b>=0)){return}return this.values[b]=0};a.prototype.addResolverToOptions=function(b,c){return _.extend(b,{store:this,store_key:c})};a.resolveFromOptions=function(b,c){if(!(b.store&&b.store_key)){return}return b.store.registerValue(b.store_key,c)};return a})();var __hasProp={}.hasOwnProperty,__extends=function(d,b){for(var a in b){if(__hasProp.call(b,a)){d[a]=b[a]}}function c(){this.constructor=d}c.prototype=b.prototype;d.prototype=new c;d.__super__=b.prototype;return d};Knockback.CollectionObservable=(function(b){__extends(a,b);a.name="CollectionObservable";function a(f,c){var e,d,g=this;if(c==null){c={}}if(!f){throw new Error("CollectionObservable: collection is missing")}a.__super__.constructor.apply(this,arguments);if(Knockback.stats_on){kb.stats.collection_observables++}if(ko.isObservable(c)&&c.hasOwnProperty("indexOf")){kb.utils.legacyWarning("kb.collectionObservable with an external ko.observableArray","0.16.0","Please use the kb.collectionObservable directly instead of passing a ko.observableArray");d=kb.utils.wrappedObservable(this,c);c=arguments[2]||{};e=true}else{d=kb.utils.wrappedObservable(this,ko.observableArray([]))}if(!c.store_skip_resolve){kb.Store.resolveFromOptions(c,kb.utils.wrappedObservable(this))}if(c.store){this.__kb.store=c.store}else{this.__kb.store=new kb.Store();this.__kb.store_is_owned=true}if(c.hasOwnProperty("view_model")){if(!c.view_model){throw new Error("Knockback.CollectionObservable: options.view_model is empty")}this.view_model_create_fn=c.view_model;this.view_model_create_with_new=true}else{if(c.hasOwnProperty("view_model_constructor")){if(!c.view_model_constructor){throw new Error("Knockback.CollectionObservable: options.view_model_constructor is empty")}kb.utils.legacyWarning("kb.collectionObservable option view_model_constructor","0.16.0","Please use view_model option instead");this.view_model_create_fn=c.view_model_constructor;this.view_model_create_with_new=true}else{if(c.hasOwnProperty("view_model_create")){if(!c.view_model_create){throw new Error("Knockback.CollectionObservable: options.view_model_create is empty")}this.view_model_create_fn=c.view_model_create}else{if(c.hasOwnProperty("create")){if(!c.create){throw new Error("Knockback.CollectionObservable: options.create is empty")}this.view_model_create_fn=c.create}}}}this.sort_attribute=c.sort_attribute;this.sorted_index=c.sorted_index;this.__kb._onCollectionReset=_.bind(this._onCollectionReset,this);this.__kb._onCollectionResort=_.bind(this._onCollectionResort,this);this.__kb._onModelAdd=_.bind(this._onModelAdd,this);this.__kb._onModelRemove=_.bind(this._onModelRemove,this);this.__kb._onModelChange=_.bind(this._onModelChange,this);if(e&&f){f.bind("change",function(){return kb.utils.wrappedObservable(g).valueHasMutated()})}d.retain=_.bind(this.retain,this);d.refCount=_.bind(this.refCount,this);d.release=_.bind(this.release,this);d.collection=_.bind(this.collection,this);d.viewModelByModel=_.bind(this.viewModelByModel,this);d.sortedIndex=_.bind(this.sortedIndex,this);d.sortAttribute=_.bind(this.sortAttribute,this);d.hasViewModels=_.bind(this.hasViewModels,this);d.bind=_.bind(this.bind,this);d.unbind=_.bind(this.unbind,this);d.trigger=_.bind(this.trigger,this);this.collection(f,{silent:true,defer:c.defer});return d}a.prototype.__destroy=function(){this.collection(null);if(this.hasViewModels()&&this.__kb.store_is_owned){this.__kb.store.destroy();this.__kb.store=null}this.view_model_create_fn=null;this.__kb.collection=null;kb.utils.wrappedObservable(this,null);a.__super__.__destroy.apply(this,arguments);if(Knockback.stats_on){return kb.stats.collection_observables--}};a.prototype.retain=function(){a.__super__.retain.apply(this,arguments);return kb.utils.wrappedObservable(this)};a.prototype.release=function(){var c;c=kb.utils.wrappedObservable(this);a.__super__.release.apply(this,arguments);return c};a.prototype.collection=function(g,c){var f,d,e;f=kb.utils.wrappedObservable(this);if(arguments.length===0){f();return this.__kb.collection}if(g===this.__kb.collection){return}if(this.__kb.collection){this._clear();this._collectionUnbind(this.__kb.collection);if(typeof(d=this.__kb.collection).release==="function"){d.release()}this.__kb.collection=null}this.__kb.collection=g;if(this.__kb.collection){if(typeof(e=this.__kb.collection).retain==="function"){e.retain()}this._collectionBind(this.__kb.collection);return this.sortedIndex(this.sorted_index,this.sort_attribute,c)}};a.prototype.sortedIndex=function(g,c,d){var e,f=this;if(d==null){d={}}if(g){this.sorted_index=g;this.sort_attribute=c}else{if(c){this.sort_attribute=c;this.sorted_index=this._sortAttributeFn(c)}else{this.sort_attribute=null;this.sorted_index=null}}e=function(){var h;h=kb.utils.wrappedObservable(f);if((f.__kb.collection.models.length===0)&&(h().length===0)){return}f._collectionResync(true);if(!d.silent){return f.trigger("resort",h())}};if(d.defer){_.defer(e)}else{e()}return this};a.prototype.sortAttribute=function(d,e,c){return this.sortedIndex(e,d,c)};a.prototype.viewModelByModel=function(d){var c,e;if(!this.hasViewModels()){return null}e=kb.utils.wrappedObservable(this);c=d.hasOwnProperty(d.idAttribute)?d.idAttribute:"cid";return _.find(e(),function(f){return f.__kb.model[c]===d[c]})};a.prototype.hasViewModels=function(){return !!this.view_model_create_fn};a.prototype._collectionBind=function(j){var g,i,f,e,d,h,c;if(!j){return}j.bind("reset",this.__kb._onCollectionReset);if(!this.sorted_index){j.bind("resort",this.__kb._onCollectionResort)}h=["new","add"];for(i=0,e=h.length;i<e;i++){g=h[i];j.bind(g,this.__kb._onModelAdd)}c=["remove","destroy"];for(f=0,d=c.length;f<d;f++){g=c[f];j.bind(g,this.__kb._onModelRemove)}return j.bind("change",this.__kb._onModelChange)};a.prototype._collectionUnbind=function(j){var g,i,f,e,d,h,c;if(!j){return}j.unbind("reset",this.__kb._onCollectionReset);if(!this.sorted_index){j.unbind("resort",this.__kb._onCollectionResort)}h=["new","add"];for(i=0,e=h.length;i<e;i++){g=h[i];j.unbind(g,this.__kb._onModelAdd)}c=["remove","destroy"];for(f=0,d=c.length;f<d;f++){g=c[f];j.unbind(g,this.__kb._onModelRemove)}return j.unbind("change",this.__kb._onModelChange)};a.prototype._onCollectionReset=function(){return this._collectionResync()};a.prototype._onCollectionResort=function(d){var c;if(this.sorted_index){throw new Error("CollectionObservable: collection sorted_index unexpected")}if(_.isArray(d)){c=kb.utils.wrappedObservable(this);return this.trigger("resort",c())}else{return this._onModelResort(d)}};a.prototype._onModelAdd=function(d){var c,f,e;e=this.hasViewModels()?this._createTarget(d):d;f=kb.utils.wrappedObservable(this);if(this.sorted_index){c=this.sorted_index(f(),e)}else{c=this.__kb.collection.indexOf(d)}f.splice(c,0,e);return this.trigger("add",e,f())};a.prototype._onModelRemove=function(c){var e,d;d=this.hasViewModels()?this.viewModelByModel(c):c;if(!d){return}e=kb.utils.wrappedObservable(this);e.remove(d);this.trigger("remove",d,e);if(this.hasViewModels()){return this.__kb.store.releaseValue(d)}};a.prototype._onModelChange=function(c){if(this.sorted_index&&(!this.sort_attribute||c.hasChanged(this.sort_attribute))){return this._onModelResort(c)}};a.prototype._onModelResort=function(d){var c,g,f,h,e;g=kb.utils.wrappedObservable(this);e=this.hasViewModels()?this.viewModelByModel(d):d;f=g.indexOf(e);if(this.sorted_index){h=_.clone(g());h.splice(f,1);c=this.sorted_index(h,e)}else{c=this.__kb.collection.indexOf(d)}if(f===c){return}g.splice(f,1);g.splice(c,0,e);return this.trigger("resort",e,g(),c)};a.prototype._clear=function(f){var i,h,e,g,d,c;i=kb.utils.wrappedObservable(this);if(!f){this.trigger("remove",i())}e=i.removeAll();if(this.hasViewModels()){c=[];for(g=0,d=e.length;g<d;g++){h=e[g];c.push(this.__kb.store.releaseValue(h))}return c}};a.prototype._collectionResync=function(k){var d,g,c,j,i,e,l,f,h=this;this._clear(k);c=kb.utils.wrappedObservable(this);if(this.sorted_index){i=[];f=this.__kb.collection.models;for(e=0,l=f.length;e<l;e++){g=f[e];j=this._createTarget(g);d=this.sorted_index(i,j);i.splice(d,0,j)}}else{i=this.hasViewModels()?_.map(this.__kb.collection.models,function(m){return h._createTarget(m)}):_.clone(this.__kb.collection.models)}c(i);if(!k){return this.trigger("add",c())}};a.prototype._sortAttributeFn=function(c){if(this.hasViewModels()){return function(e,d){return _.sortedIndex(e,d,function(f){return kb.utils.wrappedModel(f).get(c)})}}else{return function(e,d){return _.sortedIndex(e,d,function(f){return f.get(c)})}}};a.prototype._createTarget=function(c){var e,d=this;e=function(){var h,g,f;g=d.__kb.store.addResolverToOptions({},c);h=kb.utils.wrappedObservable(d);f=d.view_model_create_with_new?new d.view_model_create_fn(c,g,h):d.view_model_create_fn(c,g,h);kb.utils.wrappedModel(f,c);return f};if(this.hasViewModels()){return this.__kb.store.resolveValue(c,e)}else{return c}};return a})(kb.RefCountable);__extends(Knockback.CollectionObservable.prototype,Backbone.Events);Knockback.collectionObservable=function(c,b,a){return new Knockback.CollectionObservable(c,b,a)};Knockback.sortedIndexWrapAttr=Knockback.siwa=function(a,b){return function(d,c){return _.sortedIndex(d,c,function(e){return new b(kb.utils.wrappedModel(e).get(a))})}};if(!this.Knockback){throw new Error("Knockback: Dependency alert! knockback_core.js must be included before this file")}Knockback.DefaultWrapper=(function(){a.name="DefaultWrapper";function a(b,e){var c,d=this;this.default_value_observable=e;this.__kb={};c=kb.utils.wrappedObservable(this,ko.dependentObservable({read:function(){var g,f;f=ko.utils.unwrapObservable(b());g=ko.utils.unwrapObservable(d.default_value_observable);if(!f){return g}else{return f}},write:function(f){return b(f)}}));c.destroy=_.bind(this.destroy,this);c.setToDefault=_.bind(this.setToDefault,this);return c}a.prototype.destroy=function(){kb.utils.wrappedObservable(this,null);return this.default_value=null};a.prototype.setToDefault=function(){var b;b=kb.utils.wrappedObservable(this);return b(this.default_value_observable)};return a})();Knockback.defaultWrapper=function(b,a){return new Knockback.DefaultWrapper(b,a)};Knockback.toFormattedString=function(g){var b,e,d,c,a,f;a=g.slice();e=Array.prototype.slice.call(arguments,1);for(d in e){b=e[d];f=ko.utils.unwrapObservable(b);if(!f){f=""}c=g.indexOf("{"+d+"}");while(c>=0){a=a.replace("{"+d+"}",f);c=g.indexOf("{"+d+"}",c+1)}}return a};Knockback.parseFormattedString=function(h,m){var i,a,j,k,g,p,o,f,l,b,e,n,d,c;b=m.slice();j=0;p=0;f={};while(b.search("\\{"+j+"\\}")>=0){o=m.indexOf("{"+j+"}");while(o>=0){b=b.replace("{"+j+"}","(.*)");f[o]=j;p++;o=m.indexOf("{"+j+"}",o+1)}j++}i=j;l=new RegExp(b);g=l.exec(h);if(g){g.shift()}if(!g||(g.length!==p)){return _.map((function(){c=[];for(var q=1;1<=i?q<=i:q>=i;1<=i?q++:q--){c.push(q)}return c}).apply(this),function(){return""})}n=_.sortBy(_.keys(f),function(q,r){return parseInt(q,10)});a={};for(k in n){o=n[k];j=f[o];if(a.hasOwnProperty(j)){continue}a[j]=k}e=[];j=0;while(j<i){e.push(g[a[j]]);j++}return e};Knockback.FormattedObservable=(function(){a.name="FormattedObservable";function a(e,c){var d,b;this.__kb={};if(_.isArray(c)){e=e;b=c}else{b=Array.prototype.slice.call(arguments,1)}d=kb.utils.wrappedObservable(this,ko.dependentObservable({read:function(){var f,h,g;c=[ko.utils.unwrapObservable(e)];for(h=0,g=b.length;h<g;h++){f=b[h];c.push(ko.utils.unwrapObservable(f))}return kb.toFormattedString.apply(null,c)},write:function(i){var g,h,j,f;h=kb.parseFormattedString(i,ko.utils.unwrapObservable(e));j=Math.min(b.length,h.length);g=0;f=[];while(g<j){b[g](h[g]);f.push(g++)}return f}}));return d}a.prototype.destroy=function(){return kb.utils.wrappedObservable(this,null)};return a})();Knockback.formattedObservable=function(b,a){return new Knockback.FormattedObservable(b,Array.prototype.slice.call(arguments,1))};Knockback.LocalizedObservable=(function(){a.name="LocalizedObservable";a.extend=Backbone.Model.extend;function a(d,c,b){var e;this.value=d;this.options=c!=null?c:{};this.view_model=b!=null?b:{};if(!(this.options.read||this.read)){throw new Error("LocalizedObservable: options.read is missing")}if(this.options.read&&this.read){throw new Error("LocalizedObservable: options.read and read class function exist. You need to choose one.")}if(this.options.write&&this.write){throw new Error("LocalizedObservable: options.write and write class function exist. You need to choose one.")}if(!kb.locale_manager){throw new Error("LocalizedObservable: Knockback.locale_manager is not defined")}this.__kb={};this.__kb._onLocaleChange=_.bind(this._onLocaleChange,this);if(this.value){d=ko.utils.unwrapObservable(this.value)}this.__kb.value_observable=ko.observable(!d?this._getDefaultValue():this.read.call(this,d,null));if(this.write&&!(typeof this.write==="function")){throw new Error("LocalizedObservable: options.write is not a function for read_write model attribute")}e=kb.utils.wrappedObservable(this,ko.dependentObservable({read:_.bind(this._onGetValue,this),write:this.write?_.bind(this._onSetValue,this):(function(){throw new Error("Knockback.LocalizedObservable: value is read only")}),owner:this.view_model}));e.destroy=_.bind(this.destroy,this);e.observedValue=_.bind(this.observedValue,this);e.setToDefault=_.bind(this.setToDefault,this);e.resetToCurrent=_.bind(this.resetToCurrent,this);kb.locale_manager.bind("change",this.__kb._onLocaleChange);return e}a.prototype.destroy=function(){kb.locale_manager.unbind("change",this.__kb._onLocaleChange);this.__kb.value_observable=null;kb.utils.wrappedObservable(this).dispose();kb.utils.wrappedObservable(this,null);this.options={};this.view_model=null;return this.__kb=null};a.prototype.setToDefault=function(){var c,b;if(!this["default"]){return}b=this._getDefaultValue();c=this.__kb.value_observable();if(c!==b){return this._onSetValue(b)}else{return this.__kb.value_observable.valueHasMutated()}};a.prototype.resetToCurrent=function(){this.__kb.value_observable(null);return this._onSetValue(this._getCurrentValue())};a.prototype.observedValue=function(b){if(arguments.length===0){return this.value}this.value=b;this._onLocaleChange();return this};a.prototype._getDefaultValue=function(){if(!this["default"]){return""}if(typeof this["default"]==="function"){return this["default"]()}else{return this["default"]}};a.prototype._getCurrentValue=function(){var b;b=kb.utils.wrappedObservable(this);if(!(this.value&&b)){return this._getDefaultValue()}return this.read.call(this,ko.utils.unwrapObservable(this.value))};a.prototype._onGetValue=function(){if(this.value){ko.utils.unwrapObservable(this.value)}return this.__kb.value_observable()};a.prototype._onSetValue=function(b){this.write.call(this,b,ko.utils.unwrapObservable(this.value));b=this.read.call(this,ko.utils.unwrapObservable(this.value));this.__kb.value_observable(b);if(this.options.onChange){return this.options.onChange(b)}};a.prototype._onLocaleChange=function(){var b;b=this.read.call(this,ko.utils.unwrapObservable(this.value));this.__kb.value_observable(b);if(this.options.onChange){return this.options.onChange(b)}};return a})();Knockback.localizedObservable=function(c,b,a){return new Knockback.LocalizedObservable(c,b,a)};Knockback.Observable=(function(){a.name="Observable";function a(c,d,b){var e,f=this;this.model=c;this.mapping_info=d;this.view_model=b!=null?b:{};if(!this.model){throw new Error("Observable: model is missing")}if(!this.mapping_info){throw new Error("Observable: mapping_info is missing")}if(_.isString(this.mapping_info)||ko.isObservable(this.mapping_info)){this.mapping_info={key:this.mapping_info}}if(!this.mapping_info.key){throw new Error("Observable: mapping_info.key is missing")}this.__kb={};this.__kb._onModelChange=_.bind(this._onModelChange,this);this.__kb._onModelLoaded=_.bind(this._onModelLoaded,this);this.__kb._onModelUnloaded=_.bind(this._onModelUnloaded,this);if(this.mapping_info.hasOwnProperty("write")&&_.isBoolean(this.mapping_info.write)){this.mapping_info=_.clone(this.mapping_info);this.mapping_info.read_only=!this.mapping_info.write}if(Backbone.ModelRef&&(this.model instanceof Backbone.ModelRef)){this.model_ref=this.model;this.model_ref.retain();this.model_ref.bind("loaded",this.__kb._onModelLoaded);this.model_ref.bind("unloaded",this.__kb._onModelUnloaded);this.model=this.model_ref.getModel()}this.__kb.value_observable=ko.observable();if(this.mapping_info.localizer){this.__kb.localizer=new this.mapping_info.localizer(this._getCurrentValue())}e=kb.utils.wrappedObservable(this,ko.dependentObservable({read:_.bind(this._onGetValue,this),write:this.mapping_info.read_only?(function(){throw new Error("Knockback.Observable: "+f.mapping_info.key+" is read only")}):_.bind(this._onSetValue,this),owner:this.view_model}));e.destroy=_.bind(this.destroy,this);e.setToDefault=_.bind(this.setToDefault,this);if(!this.model_ref||this.model_ref.isLoaded()){this.model.bind("change",this.__kb._onModelChange)}return e}a.prototype.destroy=function(){this.__kb.value_observable=null;kb.utils.wrappedObservable(this).dispose();kb.utils.wrappedObservable(this,null);if(this.model){this.__kb._onModelUnloaded(this.model)}if(this.model_ref){this.model_ref.unbind("loaded",this.__kb._onModelLoaded);this.model_ref.unbind("unloaded",this.__kb._onModelUnloaded);this.model_ref.release();this.model_ref=null}this.mapping_info=null;this.view_model=null;return this.__kb=null};a.prototype.setToDefault=function(){var b;b=this._getDefaultValue();if(this.__kb.localizer){this.__kb.localizer.observedValue(b);b=this.__kb.localizer()}return this.__kb.value_observable(b)};a.prototype._getDefaultValue=function(){if(!this.mapping_info.hasOwnProperty("default")){return""}if(typeof this.mapping_info["default"]==="function"){return this.mapping_info["default"]()}else{return this.mapping_info["default"]}};a.prototype._getCurrentValue=function(){var b,d,e,g,c,f;if(!this.model){return this._getDefaultValue()}e=ko.utils.unwrapObservable(this.mapping_info.key);d=[e];if(!_.isUndefined(this.mapping_info.args)){if(_.isArray(this.mapping_info.args)){f=this.mapping_info.args;for(g=0,c=f.length;g<c;g++){b=f[g];d.push(ko.utils.unwrapObservable(b))}}else{d.push(ko.utils.unwrapObservable(this.mapping_info.args))}}if(this.mapping_info.read){return this.mapping_info.read.apply(this.view_model,d)}else{return this.model.get.apply(this.model,d)}};a.prototype._onGetValue=function(){var b,f,e,c,d;this.__kb.value_observable();ko.utils.unwrapObservable(this.mapping_info.key);if(!_.isUndefined(this.mapping_info.args)){if(_.isArray(this.mapping_info.args)){d=this.mapping_info.args;for(e=0,c=d.length;e<c;e++){b=d[e];ko.utils.unwrapObservable(b)}}else{ko.utils.unwrapObservable(this.mapping_info.args)}}f=this._getCurrentValue();if(this.__kb.localizer){this.__kb.localizer.observedValue(f);f=this.__kb.localizer()}return f};a.prototype._onSetValue=function(h){var b,e,d,g,c,f;if(this.__kb.localizer){this.__kb.localizer(h);h=this.__kb.localizer.observedValue()}if(this.model){d={};d[ko.utils.unwrapObservable(this.mapping_info.key)]=h;e=typeof this.mapping_info.write==="function"?[h]:[d];if(!_.isUndefined(this.mapping_info.args)){if(_.isArray(this.mapping_info.args)){f=this.mapping_info.args;for(g=0,c=f.length;g<c;g++){b=f[g];e.push(ko.utils.unwrapObservable(b))}}else{e.push(ko.utils.unwrapObservable(this.mapping_info.args))}}if(typeof this.mapping_info.write==="function"){this.mapping_info.write.apply(this.view_model,e)}else{this.model.set.apply(this.model,e)}}if(this.__kb.localizer){return this.__kb.value_observable(this.__kb.localizer())}else{return this.__kb.value_observable(h)}};a.prototype._modelBind=function(b){if(!b){return}b.bind("change",this.__kb._onModelChange);if(Backbone.RelationalModel&&(b instanceof Backbone.RelationalModel)){b.bind("add",this.__kb._onModelChange);b.bind("remove",this.__kb._onModelChange);return b.bind("update",this.__kb._onModelChange)}};a.prototype._modelUnbind=function(b){if(!b){return}b.unbind("change",this.__kb._onModelChange);if(Backbone.RelationalModel&&(b instanceof Backbone.RelationalModel)){b.unbind("add",this.__kb._onModelChange);b.unbind("remove",this.__kb._onModelChange);return b.unbind("update",this.__kb._onModelChange)}};a.prototype._onModelLoaded=function(b){this.model=b;this._modelBind(b);return this._updateValue()};a.prototype._onModelUnloaded=function(b){if(this.__kb.localizer&&this.__kb.localizer.destroy){this.__kb.localizer.destroy();this.__kb.localizer=null}this._modelUnbind(b);return this.model=null};a.prototype._onModelChange=function(){if((this.model&&this.model.hasChanged)&&!this.model.hasChanged(ko.utils.unwrapObservable(this.mapping_info.key))){return}return this._updateValue()};a.prototype._updateValue=function(){var b;b=this._getCurrentValue();if(this.__kb.localizer){this.__kb.localizer.observedValue(b);b=this.__kb.localizer()}return this.__kb.value_observable(b)};return a})();Knockback.observable=function(b,c,a){return new Knockback.Observable(b,c,a)};Knockback.Observables=(function(){a.name="Observables";function a(e,g,k,j){var h,i,f,c,d,b;if(!e){throw new Error("Observables: model is missing")}if(!g||!_.isObject(g)){throw new Error("Observables: mappings_info is missing")}this.__kb||(this.__kb={});this.__kb.model=e;this.__kb.mappings_info=g;this.__kb.view_model=_.isUndefined(k)?this:k;if(!_.isUndefined(j)&&j.hasOwnProperty("write")){kb.utils.legacyWarning("Knockback.Observables option.write","0.16.0","Now default is writable so only supply read_only as required");j.read_only=!j.write;delete j.write}if(!_.isUndefined(j)){c=_.isBoolean(j)?j:j.read_only;d=this.__kb.mappings_info;for(f in d){i=d[f];h=_.isString(i);if(h){i=!_.isUndefined(c)?{key:i,read_only:c}:{key:i}}else{if(!_.isUndefined(c)&&!(i.hasOwnProperty("read_only")||i.hasOwnProperty("write"))){i.read_only=c}}if(!i.hasOwnProperty("key")){i.key=f}this[f]=this.__kb.view_model[f]=kb.observable(this.__kb.model,i,this.__kb.view_model)}}else{b=this.__kb.mappings_info;for(f in b){i=b[f];if(i.hasOwnProperty("write")){kb.utils.legacyWarning("Knockback.Observables option.write","0.16.0","Now default is writable so only supply read_only as required")}if(!i.hasOwnProperty("key")){i.key=f}this[f]=this.__kb.view_model[f]=kb.observable(this.__kb.model,i,this.__kb.view_model)}}}a.prototype.destroy=function(){var c,b,d;d=this.__kb.mappings_info;for(b in d){c=d[b];if(this.__kb.view_model[b]){this.__kb.view_model[b].destroy()}this.__kb.view_model[b]=null;this[b]=null}this.__kb.view_model=null;this.__kb.mappings_info=null;return this.__kb.model=null};a.prototype.setToDefault=function(){var d,b,e,c;e=this.__kb.mappings_info;c=[];for(b in e){d=e[b];c.push(this.__kb.view_model[b].setToDefault())}return c};return a})();Knockback.observables=function(c,d,a,b){return new Knockback.Observables(c,d,a,b)};Knockback.TriggeredObservable=(function(){a.name="TriggeredObservable";function a(b,d){var c;this.model=b;this.event_name=d;if(!this.model){throw new Error("Observable: model is missing")}if(!this.event_name){throw new Error("Observable: event_name is missing")}this.__kb={};this.__kb._onValueChange=_.bind(this._onValueChange,this);this.__kb._onModelLoaded=_.bind(this._onModelLoaded,this);this.__kb._onModelUnloaded=_.bind(this._onModelUnloaded,this);if(Backbone.ModelRef&&(this.model instanceof Backbone.ModelRef)){this.model_ref=this.model;this.model_ref.retain();this.model_ref.bind("loaded",this.__kb._onModelLoaded);this.model_ref.bind("unloaded",this.__kb._onModelUnloaded);this.model=this.model_ref.getModel()}this.__kb.value_observable=ko.observable();c=kb.utils.wrappedObservable(this,ko.dependentObservable(_.bind(this._onGetValue,this)));c.destroy=_.bind(this.destroy,this);if(!this.model_ref||this.model_ref.isLoaded()){this._onModelLoaded(this.model)}return c}a.prototype.destroy=function(){kb.utils.wrappedObservable(this).dispose();kb.utils.wrappedObservable(this,null);this.__kb.value_observable=null;if(this.model){this._onModelUnloaded(this.model)}if(this.model_ref){this.model_ref.unbind("loaded",this.__kb._onModelLoaded);this.model_ref.unbind("unloaded",this.__kb._onModelUnloaded);this.model_ref.release();this.model_ref=null}this.options=null;this.view_model=null;return this.__kb=null};a.prototype._onGetValue=function(){return this.__kb.value_observable()};a.prototype._onModelLoaded=function(b){this.model=b;this.model.bind(this.event_name,this.__kb._onValueChange);return this._onValueChange()};a.prototype._onModelUnloaded=function(){if(this.__kb.localizer&&this.__kb.localizer.destroy){this.__kb.localizer.destroy();this.__kb.localizer=null}this.model.unbind(this.event_name,this.__kb._onValueChange);return this.model=null};a.prototype._onValueChange=function(){var b;b=this.__kb.value_observable();if(b!==this.model){return this.__kb.value_observable(this.model)}else{return this.__kb.value_observable.valueHasMutated()}};return a})();Knockback.triggeredObservable=function(a,b){return new Knockback.TriggeredObservable(a,b)};var __hasProp={}.hasOwnProperty,__extends=function(d,b){for(var a in b){if(__hasProp.call(b,a)){d[a]=b[a]}}function c(){this.constructor=d}c.prototype=b.prototype;d.prototype=new c;d.__super__=b.prototype;return d};Knockback.AttributeConnector=(function(){a.name="AttributeConnector";function a(c,d,b){var e;this.key=d;this.options=b!=null?b:{};kb.utils.wrappedModel(this,c);this.options=_.clone(this.options);this.__kb.value_observable=ko.observable();e=kb.utils.wrappedObservable(this,ko.dependentObservable({read:_.bind(this.read,this),write:_.bind(this.write,this)}));e.destroy=_.bind(this.destroy,this);e.model=_.bind(this.model,this);e.update=_.bind(this.update,this);this.__kb.initializing=true;this.update();this.__kb.initializing=false;return e}a.prototype.destroy=function(){this.__kb.value_observable=null;kb.utils.wrappedObservable(this).dispose();return kb.utils.wrappedObservable(this,null)};a.prototype.read=function(){return this.__kb.value_observable()};a.prototype.write=function(d){var c,b;c=kb.utils.wrappedModel(this);if(!c){return}if(this.options.read_only){if(!this.__kb.initializing){throw"Cannot write a value to a dependentObservable unless you specify a 'write' option. If you wish to read the current value, don't pass any parameters."}}else{b={};b[this.key]=d;return c.set(b)}};a.prototype.model=function(b){var c;c=kb.utils.wrappedModel(this);if(arguments.length===0){return c}if(c===b){return}kb.utils.wrappedModel(this,b);return this.update()};a.inferType=function(b,c){var d,e;e=b.get(c);if(!e){if(!(Backbone.RelationalModel&&(b instanceof Backbone.RelationalModel))){return"simple"}d=_.find(b.getRelations(),function(f){return f.key===c});if(!d){return"simple"}if(d.collectionKey){return"collection"}else{return"model"}}if(e instanceof Backbone.Collection){return"collection"}if((e instanceof Backbone.Model)||(Backbone.ModelRef&&(e instanceof Backbone.ModelRef))){return"model"}return"simple"};a.createByType=function(e,c,d,b){var f;switch(e){case"collection":f=b?_.clone(b):{};if(!(b.view_model||b.view_model_create||b.children||b.create)){f.view_model=kb.ViewModel}if(b.store){b.store.addResolverToOptions(f,c.get(d))}return kb.collectionAttributeConnector(c,d,f);case"model":f=b?_.clone(b):{};if(!f.options){f.options={}}if(!(b.view_model||b.view_model_create||b.children||b.create)){f.view_model=kb.ViewModel}if(b.store){b.store.addResolverToOptions(f.options,c.get(d))}return kb.viewModelAttributeConnector(c,d,f);default:return kb.simpleAttributeConnector(c,d,b)}};a.createOrUpdate=function(f,c,d,b){var g,e;if(f){if(kb.utils.observableInstanceOf(f,kb.AttributeConnector)){if(f.model()!==c){f.model(c)}else{f.update()}}return f}if(!c){return kb.simpleAttributeConnector(c,d,b)}if(b.hasOwnProperty("create")){if(!b.create){throw new Error("Knockback.AttributeConnector: options.create is empty")}return b.create(c,d,b.options||{})}e=c.get(d);if(b.hasOwnProperty("view_model")){if(!b.view_model){throw new Error("Knockback.AttributeConnector: options.view_model is empty")}return new b.view_model(e,b.options||{})}else{if(b.hasOwnProperty("view_model_create")){if(!b.view_model_create){throw new Error("Knockback.AttributeConnector: options.view_model_create is empty")}return b.view_model_create(e,b.options||{})}else{if(b.hasOwnProperty("children")){if(!b.children){throw new Error("Knockback.AttributeConnector: options.children is empty")}if(typeof b.children==="function"){g={view_model:b.children}}else{g=b.children||{}}return kb.collectionAttributeConnector(c,d,g)}}}return this.createByType(this.inferType(c,d),c,d,b)};return a})();Knockback.SimpleAttributeConnector=(function(b){__extends(a,b);a.name="SimpleAttributeConnector";function a(){a.__super__.constructor.apply(this,arguments);return kb.utils.wrappedObservable(this)}a.prototype.destroy=function(){this.current_value=null;return a.__super__.destroy.apply(this,arguments)};a.prototype.update=function(){var d,c,e;c=kb.utils.wrappedModel(this);if(!c){return}e=c.get(this.key);d=this.__kb.value_observable();if(!_.isEqual(d,e)){return this.__kb.value_observable(e)}};a.prototype.write=function(d){var c;c=kb.utils.wrappedModel(this);if(!c){this.__kb.value_observable(d);return}return a.__super__.write.apply(this,arguments)};return a})(Knockback.AttributeConnector);Knockback.simpleAttributeConnector=function(b,c,a){return new Knockback.SimpleAttributeConnector(b,c,a)};Knockback.CollectionAttributeConnector=(function(a){__extends(b,a);b.name="CollectionAttributeConnector";function b(){b.__super__.constructor.apply(this,arguments);return kb.utils.wrappedObservable(this)}b.prototype.destroy=function(){var c;c=this.__kb.value_observable();if(c&&(typeof c.refCount==="function")&&(c.refCount()>0)){c.release()}return b.__super__.destroy.apply(this,arguments)};b.prototype.update=function(){var d,c,e,f=this;c=kb.utils.wrappedModel(this);if(!c){return}e=c.get(this.key);d=this.__kb.value_observable();if(!d){if(this.options.store){return this.__kb.value_observable(this.options.store.resolveValue(e,function(){return kb.collectionObservable(e,f.options)}))}else{return this.__kb.value_observable(kb.collectionObservable(e,this.options))}}else{if(d.collection()!==e){d.collection(e);return this.__kb.value_observable.valueHasMutated()}}};b.prototype.read=function(){var c;c=this.__kb.value_observable();if(c){return c()}else{return}};return b})(Knockback.AttributeConnector);Knockback.collectionAttributeConnector=function(b,c,a){return new Knockback.CollectionAttributeConnector(b,c,a)};Knockback.ViewModelAttributeConnector=(function(b){__extends(a,b);a.name="ViewModelAttributeConnector";function a(){a.__super__.constructor.apply(this,arguments);return kb.utils.wrappedObservable(this)}a.prototype.destroy=function(){var c;c=this.__kb.value_observable();if(c&&(typeof c.refCount==="function")&&(c.refCount()>0)){c.release()}return a.__super__.destroy.apply(this,arguments)};a.prototype.update=function(){var d,c,e,f,g=this;c=kb.utils.wrappedModel(this);if(!c){return}e=c.get(this.key);d=this.__kb.value_observable();if(!d){f=this.options.options?_.clone(this.options.options):{};if(f.store){return this.__kb.value_observable(f.store.resolveValue(e,function(){if(g.options.view_model){return new g.options.view_model(e,f)}else{return g.options.view_model_create(e,f)}}))}else{return this.__kb.value_observable(this.options.view_model?new this.options.view_model(e,f):this.options.view_model_create(e,f))}}else{if(!(d.model&&(typeof d.model==="function"))){throw new Error("Knockback.viewModelAttributeConnector: unknown how to model a view model")}if(d.model()!==e){d.model(e);return this.__kb.value_observable.valueHasMutated()}}};return a})(Knockback.AttributeConnector);Knockback.viewModelAttributeConnector=function(b,c,a){return new Knockback.ViewModelAttributeConnector(b,c,a)};var __hasProp={}.hasOwnProperty,__extends=function(d,b){for(var a in b){if(__hasProp.call(b,a)){d[a]=b[a]}}function c(){this.constructor=d}c.prototype=b.prototype;d.prototype=new c;d.__super__=b.prototype;return d};Knockback.ViewModel_RCBase=(function(b){__extends(a,b);a.name="ViewModel_RCBase";function a(){return a.__super__.constructor.apply(this,arguments)}a.prototype.__destroy=function(){var d,e,c;c=[];for(d in this){e=this[d];if(!e||(d==="__kb")){continue}if(kb.utils.release(e)){c.push(this[d]=null)}else{c.push(void 0)}}return c};return a})(Knockback.RefCountable);Knockback.ViewModel=(function(b){__extends(a,b);a.name="ViewModel";function a(e,d){var g,f,h,c;if(d==null){d={}}a.__super__.constructor.apply(this,arguments);if(Knockback.stats_on){kb.stats.view_models++}if(!d.store_skip_resolve){kb.Store.resolveFromOptions(d,this)}if(d.store){this.__kb.store=d.store}else{this.__kb.store=new kb.Store();this.__kb.store_is_owned=true}this.__kb._onModelChange=_.bind(this._onModelChange,this);this.__kb._onModelLoaded=_.bind(this._onModelLoaded,this);this.__kb._onModelUnloaded=_.bind(this._onModelUnloaded,this);this.__kb.internals=d.internals;this.__kb.requires=d.requires;this.__kb.children=d.children;this.__kb.create=d.create;this.__kb.read_only=d.read_only;kb.utils.wrappedModel(this,e);if(Backbone.ModelRef&&(e instanceof Backbone.ModelRef)){this.__kb.model_ref=e;this.__kb.model_ref.retain();kb.utils.wrappedModel(this,this.__kb.model_ref.getModel());this.__kb.model_ref.bind("loaded",this.__kb._onModelLoaded);this.__kb.model_ref.bind("unloaded",this.__kb._onModelUnloaded)}if(this.__kb.model){this._onModelLoaded(this.__kb.model)}if(!this.__kb.internals&&!this.__kb.requires){return this}f=_.union((this.__kb.internals?this.__kb.internals:[]),(this.__kb.requires?this.__kb.requires:[]));if(!this.__kb.model_ref||this.__kb.model_ref.isLoaded()){f=_.difference(f,_.keys(this.__kb.model.attributes))}for(h=0,c=f.length;h<c;h++){g=f[h];this._updateAttributeConnector(this.__kb.model,g)}}a.prototype.__destroy=function(){var c;c=this.__kb.model;kb.utils.wrappedModel(this,null);this._modelUnbind(c);if(this.__kb.store_is_owned){this.__kb.store.destroy()}this.__kb.store=null;a.__super__.__destroy.apply(this,arguments);if(Knockback.stats_on){return kb.stats.view_models--}};a.prototype.model=function(c){var d;d=kb.utils.wrappedModel(this);if(arguments.length===0){return d}if(c===d){return}if(d){this._onModelUnloaded(d)}if(c){return this._onModelLoaded(c)}};a.prototype._modelBind=function(c){if(!c){return}c.bind("change",this.__kb._onModelChange);if(Backbone.RelationalModel&&(c instanceof Backbone.RelationalModel)){c.bind("add",this.__kb._onModelChange);c.bind("remove",this.__kb._onModelChange);return c.bind("update",this.__kb._onModelChange)}};a.prototype._modelUnbind=function(c){if(!c){return}c.unbind("change",this.__kb._onModelChange);if(Backbone.RelationalModel&&(c instanceof Backbone.RelationalModel)){c.unbind("add",this.__kb._onModelChange);c.unbind("remove",this.__kb._onModelChange);return c.unbind("update",this.__kb._onModelChange)}};a.prototype._onModelLoaded=function(d){var e,c;kb.utils.wrappedModel(this,d);this._modelBind(d);c=[];for(e in this.__kb.model.attributes){c.push(this._updateAttributeConnector(this.__kb.model,e))}return c};a.prototype._onModelUnloaded=function(d){var e,c;this._modelUnbind(d);kb.utils.wrappedModel(this,null);c=[];for(e in d.attributes){c.push(this._updateAttributeConnector(null,e))}return c};a.prototype._onModelChange=function(){var e,c,d;if(this.__kb.model._changed){c=[];for(e in this.__kb.model.attributes){c.push(this.__kb.model.hasChanged(e)?this._updateAttributeConnector(this.__kb.model,e):void 0)}return c}else{if(this.__kb.model.changed){d=[];for(e in this.__kb.model.changed){d.push(this._updateAttributeConnector(this.__kb.model,e))}return d}}};a.prototype._updateAttributeConnector=function(c,e){var d;d=this.__kb.internals&&_.contains(this.__kb.internals,e)?"_"+e:e;return this[d]=kb.AttributeConnector.createOrUpdate(this[d],c,e,this._createOptions(e))};a.prototype._createOptions=function(d){var c;if(this.__kb.children){if(this.__kb.children.hasOwnProperty(d)){c=this.__kb.children[d];if(typeof c==="function"){c={view_model:c}}c.options={read_only:this.__kb.read_only,store:this.__kb.store};return c}else{if(this.__kb.children.hasOwnProperty("create")){return{create:this.__kb.children.create,options:{read_only:this.__kb.read_only,store:this.__kb.store}}}}}else{if(this.__kb.create){return{create:this.__kb.create,options:{read_only:this.__kb.read_only,store:this.__kb.store}}}}return{read_only:this.__kb.read_only,store:this.__kb.store}};return a})(Knockback.ViewModel_RCBase);Knockback.viewModel=function(b,a){return new Knockback.ViewModel(b,a)};
\ No newline at end of file
// Knockout JavaScript library v2.0.0
// (c) Steven Sanderson - http://knockoutjs.com/
// License: MIT (http://www.opensource.org/licenses/mit-license.php)
(function(window,undefined){
function c(a){throw a;}var l=void 0,m=!0,o=null,p=!1,r=window.ko={};r.b=function(a,b){for(var d=a.split("."),e=window,f=0;f<d.length-1;f++)e=e[d[f]];e[d[d.length-1]]=b};r.l=function(a,b,d){a[b]=d};
r.a=new function(){function a(a,e){if("INPUT"!=a.tagName||!a.type)return p;if("click"!=e.toLowerCase())return p;var b=a.type.toLowerCase();return"checkbox"==b||"radio"==b}var b=/^(\s|\u00A0)+|(\s|\u00A0)+$/g,d={},e={};d[/Firefox\/2/i.test(navigator.userAgent)?"KeyboardEvent":"UIEvents"]=["keyup","keydown","keypress"];d.MouseEvents="click,dblclick,mousedown,mouseup,mousemove,mouseover,mouseout,mouseenter,mouseleave".split(",");for(var f in d){var h=d[f];if(h.length)for(var g=0,i=h.length;g<i;g++)e[h[g]]=
f}var j=function(){for(var a=3,e=document.createElement("div"),b=e.getElementsByTagName("i");e.innerHTML="<\!--[if gt IE "+ ++a+"]><i></i><![endif]--\>",b[0];);return 4<a?a:l}();return{Ba:["authenticity_token",/^__RequestVerificationToken(_.*)?$/],n:function(a,e){for(var b=0,f=a.length;b<f;b++)e(a[b])},k:function(a,e){if("function"==typeof Array.prototype.indexOf)return Array.prototype.indexOf.call(a,e);for(var b=0,f=a.length;b<f;b++)if(a[b]===e)return b;return-1},Wa:function(a,e,b){for(var f=0,d=
a.length;f<d;f++)if(e.call(b,a[f]))return a[f];return o},ca:function(a,e){var b=r.a.k(a,e);0<=b&&a.splice(b,1)},ya:function(a){for(var a=a||[],e=[],b=0,f=a.length;b<f;b++)0>r.a.k(e,a[b])&&e.push(a[b]);return e},ba:function(a,e){for(var a=a||[],b=[],f=0,d=a.length;f<d;f++)b.push(e(a[f]));return b},aa:function(a,e){for(var a=a||[],b=[],f=0,d=a.length;f<d;f++)e(a[f])&&b.push(a[f]);return b},J:function(a,e){for(var b=0,f=e.length;b<f;b++)a.push(e[b]);return a},extend:function(a,e){for(var b in e)e.hasOwnProperty(b)&&
(a[b]=e[b]);return a},U:function(a){for(;a.firstChild;)r.removeNode(a.firstChild)},oa:function(a,e){r.a.U(a);e&&r.a.n(e,function(e){a.appendChild(e)})},Ja:function(a,e){var b=a.nodeType?[a]:a;if(0<b.length){for(var f=b[0],d=f.parentNode,h=0,g=e.length;h<g;h++)d.insertBefore(e[h],f);h=0;for(g=b.length;h<g;h++)r.removeNode(b[h])}},La:function(a,e){0<=navigator.userAgent.indexOf("MSIE 6")?a.setAttribute("selected",e):a.selected=e},z:function(a){return(a||"").replace(b,"")},Db:function(a,e){for(var b=
[],f=(a||"").split(e),d=0,h=f.length;d<h;d++){var g=r.a.z(f[d]);""!==g&&b.push(g)}return b},Cb:function(a,e){a=a||"";return e.length>a.length?p:a.substring(0,e.length)===e},hb:function(a){for(var e=Array.prototype.slice.call(arguments,1),b="return ("+a+")",f=0;f<e.length;f++)e[f]&&"object"==typeof e[f]&&(b="with(sc["+f+"]) { "+b+" } ");return(new Function("sc",b))(e)},fb:function(a,e){if(e.compareDocumentPosition)return 16==(e.compareDocumentPosition(a)&16);for(;a!=o;){if(a==e)return m;a=a.parentNode}return p},
ga:function(a){return r.a.fb(a,document)},s:function(e,b,f){if("undefined"!=typeof jQuery){if(a(e,b))var d=f,f=function(a,e){var b=this.checked;if(e)this.checked=e.Ya!==m;d.call(this,a);this.checked=b};jQuery(e).bind(b,f)}else"function"==typeof e.addEventListener?e.addEventListener(b,f,p):"undefined"!=typeof e.attachEvent?e.attachEvent("on"+b,function(a){f.call(e,a)}):c(Error("Browser doesn't support addEventListener or attachEvent"))},sa:function(b,f){(!b||!b.nodeType)&&c(Error("element must be a DOM node when calling triggerEvent"));
if("undefined"!=typeof jQuery){var d=[];a(b,f)&&d.push({Ya:b.checked});jQuery(b).trigger(f,d)}else if("function"==typeof document.createEvent)"function"==typeof b.dispatchEvent?(d=document.createEvent(e[f]||"HTMLEvents"),d.initEvent(f,m,m,window,0,0,0,0,0,p,p,p,p,0,b),b.dispatchEvent(d)):c(Error("The supplied element doesn't support dispatchEvent"));else if("undefined"!=typeof b.fireEvent){if("click"==f&&"INPUT"==b.tagName&&("checkbox"==b.type.toLowerCase()||"radio"==b.type.toLowerCase()))b.checked=
b.checked!==m;b.fireEvent("on"+f)}else c(Error("Browser doesn't support triggering events"))},d:function(a){return r.V(a)?a():a},eb:function(a,e){return 0<=r.a.k((a.className||"").split(/\s+/),e)},Qa:function(a,e,b){var f=r.a.eb(a,e);if(b&&!f)a.className=(a.className||"")+" "+e;else if(f&&!b){for(var b=(a.className||"").split(/\s+/),f="",d=0;d<b.length;d++)b[d]!=e&&(f+=b[d]+" ");a.className=r.a.z(f)}},outerHTML:function(a){if(j===l){var e=a.outerHTML;if("string"==typeof e)return e}e=window.document.createElement("div");
e.appendChild(a.cloneNode(m));return e.innerHTML},Ma:function(a,e){var b=r.a.d(e);if(b===o||b===l)b="";"innerText"in a?a.innerText=b:a.textContent=b;if(9<=j)a.innerHTML=a.innerHTML},yb:function(a,e){for(var a=r.a.d(a),e=r.a.d(e),b=[],f=a;f<=e;f++)b.push(f);return b},X:function(a){for(var e=[],b=0,f=a.length;b<f;b++)e.push(a[b]);return e},ob:6===j,pb:7===j,Ca:function(a,e){for(var b=r.a.X(a.getElementsByTagName("INPUT")).concat(r.a.X(a.getElementsByTagName("TEXTAREA"))),f="string"==typeof e?function(a){return a.name===
e}:function(a){return e.test(a.name)},d=[],h=b.length-1;0<=h;h--)f(b[h])&&d.push(b[h]);return d},vb:function(a){return"string"==typeof a&&(a=r.a.z(a))?window.JSON&&window.JSON.parse?window.JSON.parse(a):(new Function("return "+a))():o},qa:function(a){("undefined"==typeof JSON||"undefined"==typeof JSON.stringify)&&c(Error("Cannot find JSON.stringify(). Some browsers (e.g., IE < 8) don't support it natively, but you can overcome this by adding a script reference to json2.js, downloadable from http://www.json.org/json2.js"));
return JSON.stringify(r.a.d(a))},wb:function(a,e,b){var b=b||{},f=b.params||{},d=b.includeFields||this.Ba,h=a;if("object"==typeof a&&"FORM"==a.tagName)for(var h=a.action,g=d.length-1;0<=g;g--)for(var j=r.a.Ca(a,d[g]),i=j.length-1;0<=i;i--)f[j[i].name]=j[i].value;var e=r.a.d(e),u=document.createElement("FORM");u.style.display="none";u.action=h;u.method="post";for(var y in e)a=document.createElement("INPUT"),a.name=y,a.value=r.a.qa(r.a.d(e[y])),u.appendChild(a);for(y in f)a=document.createElement("INPUT"),
a.name=y,a.value=f[y],u.appendChild(a);document.body.appendChild(u);b.submitter?b.submitter(u):u.submit();setTimeout(function(){u.parentNode.removeChild(u)},0)}}};r.b("ko.utils",r.a);
r.a.n([["arrayForEach",r.a.n],["arrayFirst",r.a.Wa],["arrayFilter",r.a.aa],["arrayGetDistinctValues",r.a.ya],["arrayIndexOf",r.a.k],["arrayMap",r.a.ba],["arrayPushAll",r.a.J],["arrayRemoveItem",r.a.ca],["extend",r.a.extend],["fieldsIncludedWithJsonPost",r.a.Ba],["getFormFields",r.a.Ca],["postJson",r.a.wb],["parseJson",r.a.vb],["registerEventHandler",r.a.s],["stringifyJson",r.a.qa],["range",r.a.yb],["toggleDomNodeCssClass",r.a.Qa],["triggerEvent",r.a.sa],["unwrapObservable",r.a.d]],function(a){r.b("ko.utils."+
a[0],a[1])});Function.prototype.bind||(Function.prototype.bind=function(a){var b=this,d=Array.prototype.slice.call(arguments),a=d.shift();return function(){return b.apply(a,d.concat(Array.prototype.slice.call(arguments)))}});
r.a.e=new function(){var a=0,b="__ko__"+(new Date).getTime(),d={};return{get:function(a,b){var d=r.a.e.getAll(a,p);return d===l?l:d[b]},set:function(a,b,d){d===l&&r.a.e.getAll(a,p)===l||(r.a.e.getAll(a,m)[b]=d)},getAll:function(e,f){var h=e[b];if(!(h&&"null"!==h)){if(!f)return;h=e[b]="ko"+a++;d[h]={}}return d[h]},clear:function(a){var f=a[b];f&&(delete d[f],a[b]=o)}}};r.b("ko.utils.domData",r.a.e);r.b("ko.utils.domData.clear",r.a.e.clear);
r.a.A=new function(){function a(a,b){var h=r.a.e.get(a,d);h===l&&b&&(h=[],r.a.e.set(a,d,h));return h}function b(e){var b=a(e,p);if(b)for(var b=b.slice(0),d=0;d<b.length;d++)b[d](e);r.a.e.clear(e);"function"==typeof jQuery&&"function"==typeof jQuery.cleanData&&jQuery.cleanData([e])}var d="__ko_domNodeDisposal__"+(new Date).getTime();return{va:function(e,b){"function"!=typeof b&&c(Error("Callback must be a function"));a(e,m).push(b)},Ia:function(e,b){var h=a(e,p);h&&(r.a.ca(h,b),0==h.length&&r.a.e.set(e,
d,l))},F:function(a){if(!(1!=a.nodeType&&9!=a.nodeType)){b(a);var f=[];r.a.J(f,a.getElementsByTagName("*"));for(var a=0,d=f.length;a<d;a++)b(f[a])}},removeNode:function(a){r.F(a);a.parentNode&&a.parentNode.removeChild(a)}}};r.F=r.a.A.F;r.removeNode=r.a.A.removeNode;r.b("ko.cleanNode",r.F);r.b("ko.removeNode",r.removeNode);r.b("ko.utils.domNodeDisposal",r.a.A);r.b("ko.utils.domNodeDisposal.addDisposeCallback",r.a.A.va);r.b("ko.utils.domNodeDisposal.removeDisposeCallback",r.a.A.Ia);
r.a.ma=function(a){var b;if("undefined"!=typeof jQuery){if((b=jQuery.clean([a]))&&b[0]){for(a=b[0];a.parentNode&&11!==a.parentNode.nodeType;)a=a.parentNode;a.parentNode&&a.parentNode.removeChild(a)}}else{var d=r.a.z(a).toLowerCase();b=document.createElement("div");d=d.match(/^<(thead|tbody|tfoot)/)&&[1,"<table>","</table>"]||!d.indexOf("<tr")&&[2,"<table><tbody>","</tbody></table>"]||(!d.indexOf("<td")||!d.indexOf("<th"))&&[3,"<table><tbody><tr>","</tr></tbody></table>"]||[0,"",""];a="ignored<div>"+
d[1]+a+d[2]+"</div>";for("function"==typeof window.innerShiv?b.appendChild(window.innerShiv(a)):b.innerHTML=a;d[0]--;)b=b.lastChild;b=r.a.X(b.lastChild.childNodes)}return b};r.a.Z=function(a,b){r.a.U(a);if(b!==o&&b!==l)if("string"!=typeof b&&(b=b.toString()),"undefined"!=typeof jQuery)jQuery(a).html(b);else for(var d=r.a.ma(b),e=0;e<d.length;e++)a.appendChild(d[e])};r.b("ko.utils.parseHtmlFragment",r.a.ma);r.b("ko.utils.setHtml",r.a.Z);
r.r=function(){function a(){return(4294967296*(1+Math.random())|0).toString(16).substring(1)}function b(a,f){if(a)if(8==a.nodeType){var d=r.r.Ga(a.nodeValue);d!=o&&f.push({cb:a,tb:d})}else if(1==a.nodeType)for(var d=0,g=a.childNodes,i=g.length;d<i;d++)b(g[d],f)}var d={};return{ka:function(b){"function"!=typeof b&&c(Error("You can only pass a function to ko.memoization.memoize()"));var f=a()+a();d[f]=b;return"<\!--[ko_memo:"+f+"]--\>"},Ra:function(a,b){var h=d[a];h===l&&c(Error("Couldn't find any memo with ID "+
a+". Perhaps it's already been unmemoized."));try{return h.apply(o,b||[]),m}finally{delete d[a]}},Sa:function(a,f){var d=[];b(a,d);for(var g=0,i=d.length;g<i;g++){var j=d[g].cb,k=[j];f&&r.a.J(k,f);r.r.Ra(d[g].tb,k);j.nodeValue="";j.parentNode&&j.parentNode.removeChild(j)}},Ga:function(a){return(a=a.match(/^\[ko_memo\:(.*?)\]$/))?a[1]:o}}}();r.b("ko.memoization",r.r);r.b("ko.memoization.memoize",r.r.ka);r.b("ko.memoization.unmemoize",r.r.Ra);r.b("ko.memoization.parseMemoText",r.r.Ga);
r.b("ko.memoization.unmemoizeDomNodeAndDescendants",r.r.Sa);r.Aa={throttle:function(a,b){a.throttleEvaluation=b;var d=o;return r.i({read:a,write:function(e){clearTimeout(d);d=setTimeout(function(){a(e)},b)}})},notify:function(a,b){a.equalityComparer="always"==b?function(){return p}:r.w.fn.equalityComparer;return a}};r.b("ko.extenders",r.Aa);r.Oa=function(a,b){this.da=a;this.bb=b;r.l(this,"dispose",this.v)};r.Oa.prototype.v=function(){this.nb=m;this.bb()};
r.R=function(){this.u={};r.a.extend(this,r.R.fn);r.l(this,"subscribe",this.ra);r.l(this,"extend",this.extend);r.l(this,"getSubscriptionsCount",this.kb)};
r.R.fn={ra:function(a,b,d){var d=d||"change",a=b?a.bind(b):a,e=new r.Oa(a,function(){r.a.ca(this.u[d],e)}.bind(this));this.u[d]||(this.u[d]=[]);this.u[d].push(e);return e},notifySubscribers:function(a,b){b=b||"change";this.u[b]&&r.a.n(this.u[b].slice(0),function(b){b&&b.nb!==m&&b.da(a)})},kb:function(){var a=0,b;for(b in this.u)this.u.hasOwnProperty(b)&&(a+=this.u[b].length);return a},extend:function(a){var b=this;if(a)for(var d in a){var e=r.Aa[d];"function"==typeof e&&(b=e(b,a[d]))}return b}};
r.Ea=function(a){return"function"==typeof a.ra&&"function"==typeof a.notifySubscribers};r.b("ko.subscribable",r.R);r.b("ko.isSubscribable",r.Ea);r.T=function(){var a=[];return{Xa:function(b){a.push({da:b,za:[]})},end:function(){a.pop()},Ha:function(b){r.Ea(b)||c("Only subscribable things can act as dependencies");if(0<a.length){var d=a[a.length-1];0<=r.a.k(d.za,b)||(d.za.push(b),d.da(b))}}}}();var B={undefined:m,"boolean":m,number:m,string:m};
r.w=function(a){function b(){if(0<arguments.length){if(!b.equalityComparer||!b.equalityComparer(d,arguments[0]))b.H(),d=arguments[0],b.G();return this}r.T.Ha(b);return d}var d=a;r.R.call(b);b.G=function(){b.notifySubscribers(d)};b.H=function(){b.notifySubscribers(d,"beforeChange")};r.a.extend(b,r.w.fn);r.l(b,"valueHasMutated",b.G);r.l(b,"valueWillMutate",b.H);return b};r.w.fn={B:r.w,equalityComparer:function(a,b){return a===o||typeof a in B?a===b:p}};
r.V=function(a){return a===o||a===l||a.B===l?p:a.B===r.w?m:r.V(a.B)};r.P=function(a){return"function"==typeof a&&a.B===r.w?m:"function"==typeof a&&a.B===r.i&&a.lb?m:p};r.b("ko.observable",r.w);r.b("ko.isObservable",r.V);r.b("ko.isWriteableObservable",r.P);
r.Q=function(a){0==arguments.length&&(a=[]);a!==o&&a!==l&&!("length"in a)&&c(Error("The argument passed when initializing an observable array must be an array, or null, or undefined."));var b=new r.w(a);r.a.extend(b,r.Q.fn);r.l(b,"remove",b.remove);r.l(b,"removeAll",b.zb);r.l(b,"destroy",b.fa);r.l(b,"destroyAll",b.ab);r.l(b,"indexOf",b.indexOf);r.l(b,"replace",b.replace);return b};
r.Q.fn={remove:function(a){for(var b=this(),d=[],e="function"==typeof a?a:function(b){return b===a},f=0;f<b.length;f++){var h=b[f];e(h)&&(0===d.length&&this.H(),d.push(h),b.splice(f,1),f--)}d.length&&this.G();return d},zb:function(a){if(a===l){var b=this(),d=b.slice(0);this.H();b.splice(0,b.length);this.G();return d}return!a?[]:this.remove(function(b){return 0<=r.a.k(a,b)})},fa:function(a){var b=this(),d="function"==typeof a?a:function(b){return b===a};this.H();for(var e=b.length-1;0<=e;e--)d(b[e])&&
(b[e]._destroy=m);this.G()},ab:function(a){return a===l?this.fa(function(){return m}):!a?[]:this.fa(function(b){return 0<=r.a.k(a,b)})},indexOf:function(a){var b=this();return r.a.k(b,a)},replace:function(a,b){var d=this.indexOf(a);0<=d&&(this.H(),this()[d]=b,this.G())}};r.a.n("pop,push,reverse,shift,sort,splice,unshift".split(","),function(a){r.Q.fn[a]=function(){var b=this();this.H();b=b[a].apply(b,arguments);this.G();return b}});
r.a.n(["slice"],function(a){r.Q.fn[a]=function(){var b=this();return b[a].apply(b,arguments)}});r.b("ko.observableArray",r.Q);function C(a,b){a&&"object"==typeof a?b=a:(b=b||{},b.read=a||b.read);"function"!=typeof b.read&&c("Pass a function that returns the value of the dependentObservable");return b}
r.i=function(a,b,d){function e(){r.a.n(q,function(a){a.v()});q=[]}function f(){var a=g.throttleEvaluation;a&&0<=a?(clearTimeout(v),v=setTimeout(h,a)):h()}function h(){if(j&&"function"==typeof d.disposeWhen&&d.disposeWhen())g.v();else{try{e();r.T.Xa(function(a){q.push(a.ra(f))});var a=d.read.call(d.owner||b);g.notifySubscribers(i,"beforeChange");i=a}finally{r.T.end()}g.notifySubscribers(i);j=m}}function g(){if(0<arguments.length)"function"===typeof d.write?d.write.apply(d.owner||b,arguments):c("Cannot write a value to a dependentObservable unless you specify a 'write' option. If you wish to read the current value, don't pass any parameters.");
else return j||h(),r.T.Ha(g),i}var i,j=p,d=C(a,d),k="object"==typeof d.disposeWhenNodeIsRemoved?d.disposeWhenNodeIsRemoved:o,n=o;if(k){n=function(){g.v()};r.a.A.va(k,n);var t=d.disposeWhen;d.disposeWhen=function(){return!r.a.ga(k)||"function"==typeof t&&t()}}var q=[],v=o;g.jb=function(){return q.length};g.lb="function"===typeof d.write;g.v=function(){k&&r.a.A.Ia(k,n);e()};r.R.call(g);r.a.extend(g,r.i.fn);d.deferEvaluation!==m&&h();r.l(g,"dispose",g.v);r.l(g,"getDependenciesCount",g.jb);return g};
r.i.fn={B:r.i};r.i.B=r.w;r.b("ko.dependentObservable",r.i);r.b("ko.computed",r.i);
(function(){function a(e,f,h){h=h||new d;e=f(e);if(!("object"==typeof e&&e!==o&&e!==l&&!(e instanceof Date)))return e;var g=e instanceof Array?[]:{};h.save(e,g);b(e,function(b){var d=f(e[b]);switch(typeof d){case "boolean":case "number":case "string":case "function":g[b]=d;break;case "object":case "undefined":var k=h.get(d);g[b]=k!==l?k:a(d,f,h)}});return g}function b(a,b){if(a instanceof Array)for(var d=0;d<a.length;d++)b(d);else for(d in a)b(d)}function d(){var a=[],b=[];this.save=function(d,g){var i=
r.a.k(a,d);0<=i?b[i]=g:(a.push(d),b.push(g))};this.get=function(d){d=r.a.k(a,d);return 0<=d?b[d]:l}}r.Pa=function(b){0==arguments.length&&c(Error("When calling ko.toJS, pass the object you want to convert."));return a(b,function(a){for(var b=0;r.V(a)&&10>b;b++)a=a();return a})};r.toJSON=function(a){a=r.Pa(a);return r.a.qa(a)}})();r.b("ko.toJS",r.Pa);r.b("ko.toJSON",r.toJSON);
r.h={q:function(a){return"OPTION"==a.tagName?a.__ko__hasDomDataOptionValue__===m?r.a.e.get(a,r.c.options.la):a.getAttribute("value"):"SELECT"==a.tagName?0<=a.selectedIndex?r.h.q(a.options[a.selectedIndex]):l:a.value},S:function(a,b){if("OPTION"==a.tagName)switch(typeof b){case "string":r.a.e.set(a,r.c.options.la,l);"__ko__hasDomDataOptionValue__"in a&&delete a.__ko__hasDomDataOptionValue__;a.value=b;break;default:r.a.e.set(a,r.c.options.la,b),a.__ko__hasDomDataOptionValue__=m,a.value="number"===typeof b?
b:""}else if("SELECT"==a.tagName)for(var d=a.options.length-1;0<=d;d--){if(r.h.q(a.options[d])==b){a.selectedIndex=d;break}}else{if(b===o||b===l)b="";a.value=b}}};r.b("ko.selectExtensions",r.h);r.b("ko.selectExtensions.readValue",r.h.q);r.b("ko.selectExtensions.writeValue",r.h.S);
r.j=function(){function a(a,e){for(var d=o;a!=d;)d=a,a=a.replace(b,function(a,b){return e[b]});return a}var b=/\@ko_token_(\d+)\@/g,d=/^[\_$a-z][\_$a-z0-9]*(\[.*?\])*(\.[\_$a-z][\_$a-z0-9]*(\[.*?\])*)*$/i,e=["true","false"];return{D:[],Y:function(b){var e=r.a.z(b);if(3>e.length)return[];"{"===e.charAt(0)&&(e=e.substring(1,e.length-1));for(var b=[],d=o,i,j=0;j<e.length;j++){var k=e.charAt(j);if(d===o)switch(k){case '"':case "'":case "/":d=j,i=k}else if(k==i&&"\\"!==e.charAt(j-1)){k=e.substring(d,j+
1);b.push(k);var n="@ko_token_"+(b.length-1)+"@",e=e.substring(0,d)+n+e.substring(j+1),j=j-(k.length-n.length),d=o}}i=d=o;for(var t=0,q=o,j=0;j<e.length;j++){k=e.charAt(j);if(d===o)switch(k){case "{":d=j;q=k;i="}";break;case "(":d=j;q=k;i=")";break;case "[":d=j,q=k,i="]"}k===q?t++:k===i&&(t--,0===t&&(k=e.substring(d,j+1),b.push(k),n="@ko_token_"+(b.length-1)+"@",e=e.substring(0,d)+n+e.substring(j+1),j-=k.length-n.length,d=o))}i=[];e=e.split(",");d=0;for(j=e.length;d<j;d++)t=e[d],q=t.indexOf(":"),
0<q&&q<t.length-1?(k=t.substring(q+1),i.push({key:a(t.substring(0,q),b),value:a(k,b)})):i.push({unknown:a(t,b)});return i},ia:function(a){for(var b="string"===typeof a?r.j.Y(a):a,g=[],a=[],i,j=0;i=b[j];j++)if(0<g.length&&g.push(","),i.key){var k;a:{k=i.key;var n=r.a.z(k);switch(n.length&&n.charAt(0)){case "'":case '"':break a;default:k="'"+n+"'"}}i=i.value;g.push(k);g.push(":");g.push(i);n=r.a.z(i);if(0<=r.a.k(e,r.a.z(n).toLowerCase())?0:n.match(d)!==o)0<a.length&&a.push(", "),a.push(k+" : function(__ko_value) { "+
i+" = __ko_value; }")}else i.unknown&&g.push(i.unknown);b=g.join("");0<a.length&&(b=b+", '_ko_property_writers' : { "+a.join("")+" } ");return b},rb:function(a,b){for(var e=0;e<a.length;e++)if(r.a.z(a[e].key)==b)return m;return p}}}();r.b("ko.jsonExpressionRewriting",r.j);r.b("ko.jsonExpressionRewriting.bindingRewriteValidators",r.j.D);r.b("ko.jsonExpressionRewriting.parseObjectLiteral",r.j.Y);r.b("ko.jsonExpressionRewriting.insertPropertyAccessorsIntoJson",r.j.ia);
(function(){function a(a){return 8==a.nodeType&&(f?a.text:a.nodeValue).match(h)}function b(a){return 8==a.nodeType&&(f?a.text:a.nodeValue).match(g)}function d(e,d){for(var f=e,g=1,h=[];f=f.nextSibling;){if(b(f)&&(g--,0===g))return h;h.push(f);a(f)&&g++}d||c(Error("Cannot find closing comment tag to match: "+e.nodeValue));return o}function e(a,b){var e=d(a,b);return e?0<e.length?e[e.length-1].nextSibling:a.nextSibling:o}var f="<\!--test--\>"===document.createComment("test").text,h=f?/^<\!--\s*ko\s+(.*\:.*)\s*--\>$/:
/^\s*ko\s+(.*\:.*)\s*$/,g=f?/^<\!--\s*\/ko\s*--\>$/:/^\s*\/ko\s*$/,i={ul:m,ol:m};r.f={C:{},childNodes:function(b){return a(b)?d(b):b.childNodes},ha:function(b){if(a(b))for(var b=r.f.childNodes(b),e=0,d=b.length;e<d;e++)r.removeNode(b[e]);else r.a.U(b)},oa:function(b,e){if(a(b)){r.f.ha(b);for(var d=b.nextSibling,f=0,g=e.length;f<g;f++)d.parentNode.insertBefore(e[f],d)}else r.a.oa(b,e)},xb:function(b,e){a(b)?b.parentNode.insertBefore(e,b.nextSibling):b.firstChild?b.insertBefore(e,b.firstChild):b.appendChild(e)},
mb:function(b,e,d){a(b)?b.parentNode.insertBefore(e,d.nextSibling):d.nextSibling?b.insertBefore(e,d.nextSibling):b.appendChild(e)},nextSibling:function(d){return a(d)?e(d).nextSibling:d.nextSibling&&b(d.nextSibling)?l:d.nextSibling},ta:function(b){return(b=a(b))?b[1]:o},ib:function(a){if(r.f.ta(a)){var b;b=r.f.childNodes(a);for(var e=[],d=0,f=b.length;d<f;d++)r.a.A.F(b[d]),e.push(r.a.outerHTML(b[d]));b=String.prototype.concat.apply("",e);r.f.ha(a);(new r.m.I(a)).text(b)}},Fa:function(d){if(i[d.tagName.toLowerCase()]){var f=
d.firstChild;if(f){do if(1===f.nodeType){var g;g=f.firstChild;var h=o;if(g){do if(h)h.push(g);else if(a(g)){var q=e(g,m);q?g=q:h=[g]}else b(g)&&(h=[g]);while(g=g.nextSibling)}if(g=h){h=f.nextSibling;for(q=0;q<g.length;q++)h?d.insertBefore(g[q],h):d.appendChild(g[q])}}while(f=f.nextSibling)}}}}})();r.L=function(){};
r.a.extend(r.L.prototype,{nodeHasBindings:function(a){switch(a.nodeType){case 1:return a.getAttribute("data-bind")!=o;case 8:return r.f.ta(a)!=o;default:return p}},getBindings:function(a,b){var d=this.getBindingsString(a,b);return d?this.parseBindingsString(d,b):o},getBindingsString:function(a){switch(a.nodeType){case 1:return a.getAttribute("data-bind");case 8:return r.f.ta(a);default:return o}},parseBindingsString:function(a,b){try{var d=b.$data,e=" { "+r.j.ia(a)+" } ";return r.a.hb(e,d===o?window:
d,b)}catch(f){c(Error("Unable to parse bindings.\nMessage: "+f+";\nBindings value: "+a))}}});r.L.instance=new r.L;r.b("ko.bindingProvider",r.L);
(function(){function a(a,d){for(var h,g=d.childNodes[0];h=g;)g=r.f.nextSibling(h),b(a,h,p)}function b(b,f,h){var g=m,i=1==f.nodeType;i&&r.f.Fa(f);if(i&&h||r.L.instance.nodeHasBindings(f))g=d(f,o,b,h).Bb;i&&g&&a(b,f)}function d(a,b,d,g){function i(a){return function(){return n[a]}}function j(){return n}var k=0;r.f.ib(a);var n,t;new r.i(function(){var q=d&&d instanceof r.K?d:new r.K(r.a.d(d)),v=q.$data;g&&r.Na(a,q);if(n=("function"==typeof b?b():b)||r.L.instance.getBindings(a,q)){if(0===k){k=1;for(var s in n){var w=
r.c[s];w&&8===a.nodeType&&!r.f.C[s]&&c(Error("The binding '"+s+"' cannot be used with virtual elements"));if(w&&"function"==typeof w.init&&(w=(0,w.init)(a,i(s),j,v,q))&&w.controlsDescendantBindings)t!==l&&c(Error("Multiple bindings ("+t+" and "+s+") are trying to control descendant bindings of the same element. You cannot use these bindings together on the same element.")),t=s}k=2}if(2===k)for(s in n)(w=r.c[s])&&"function"==typeof w.update&&(0,w.update)(a,i(s),j,v,q)}},o,{disposeWhenNodeIsRemoved:a});
return{Bb:t===l}}r.c={};r.K=function(a,b){this.$data=a;b?(this.$parent=b.$data,this.$parents=(b.$parents||[]).slice(0),this.$parents.unshift(this.$parent),this.$root=b.$root):(this.$parents=[],this.$root=a)};r.K.prototype.createChildContext=function(a){return new r.K(a,this)};r.Na=function(a,b){if(2==arguments.length)r.a.e.set(a,"__ko_bindingContext__",b);else return r.a.e.get(a,"__ko_bindingContext__")};r.xa=function(a,b,h){1===a.nodeType&&r.f.Fa(a);return d(a,b,h,m)};r.Ta=function(b,d){1===d.nodeType&&
a(b,d)};r.wa=function(a,d){d&&1!==d.nodeType&&8!==d.nodeType&&c(Error("ko.applyBindings: first parameter should be your view model; second parameter should be a DOM node"));d=d||window.document.body;b(a,d,m)};r.ea=function(a){switch(a.nodeType){case 1:case 8:var b=r.Na(a);if(b)return b;if(a.parentNode)return r.ea(a.parentNode)}};r.$a=function(a){return(a=r.ea(a))?a.$data:l};r.b("ko.bindingHandlers",r.c);r.b("ko.applyBindings",r.wa);r.b("ko.applyBindingsToDescendants",r.Ta);r.b("ko.applyBindingsToNode",
r.xa);r.b("ko.contextFor",r.ea);r.b("ko.dataFor",r.$a)})();r.a.n(["click"],function(a){r.c[a]={init:function(b,d,e,f){return r.c.event.init.call(this,b,function(){var b={};b[a]=d();return b},e,f)}}});
r.c.event={init:function(a,b,d,e){var f=b()||{},h;for(h in f)(function(){var f=h;"string"==typeof f&&r.a.s(a,f,function(a){var h,k=b()[f];if(k){var n=d();try{var t=r.a.X(arguments);t.unshift(e);h=k.apply(e,t)}finally{if(h!==m)a.preventDefault?a.preventDefault():a.returnValue=p}if(n[f+"Bubble"]===p)a.cancelBubble=m,a.stopPropagation&&a.stopPropagation()}})})()}};
r.c.submit={init:function(a,b,d,e){"function"!=typeof b()&&c(Error("The value for a submit binding must be a function"));r.a.s(a,"submit",function(d){var h,g=b();try{h=g.call(e,a)}finally{if(h!==m)d.preventDefault?d.preventDefault():d.returnValue=p}})}};r.c.visible={update:function(a,b){var d=r.a.d(b()),e="none"!=a.style.display;if(d&&!e)a.style.display="";else if(!d&&e)a.style.display="none"}};
r.c.enable={update:function(a,b){var d=r.a.d(b());if(d&&a.disabled)a.removeAttribute("disabled");else if(!d&&!a.disabled)a.disabled=m}};r.c.disable={update:function(a,b){r.c.enable.update(a,function(){return!r.a.d(b())})}};function D(a,b,d){d&&b!==r.h.q(a)&&r.h.S(a,b);b!==r.h.q(a)&&r.a.sa(a,"change")}
r.c.value={init:function(a,b,d){var e=["change"],f=d().valueUpdate;f&&("string"==typeof f&&(f=[f]),r.a.J(e,f),e=r.a.ya(e));r.a.n(e,function(e){var f=p;r.a.Cb(e,"after")&&(f=m,e=e.substring(5));var i=f?function(a){setTimeout(a,0)}:function(a){a()};r.a.s(a,e,function(){i(function(){var e=b(),f=r.h.q(a);r.P(e)?e(f):(e=d(),e._ko_property_writers&&e._ko_property_writers.value&&e._ko_property_writers.value(f))})})})},update:function(a,b){var d=r.a.d(b()),e=r.h.q(a),f=d!=e;0===d&&0!==e&&"0"!==e&&(f=m);f&&
(e=function(){r.h.S(a,d)},e(),"SELECT"==a.tagName&&setTimeout(e,0));"SELECT"==a.tagName&&0<a.length&&D(a,d,p)}};
r.c.options={update:function(a,b,d){"SELECT"!=a.tagName&&c(Error("options binding applies only to SELECT elements"));var e=0==a.length,f=r.a.ba(r.a.aa(a.childNodes,function(a){return a.tagName&&"OPTION"==a.tagName&&a.selected}),function(a){return r.h.q(a)||a.innerText||a.textContent}),h=a.scrollTop;a.scrollTop=0;for(var g=r.a.d(b());0<a.length;)r.F(a.options[0]),a.remove(0);if(g){d=d();"number"!=typeof g.length&&(g=[g]);if(d.optionsCaption){var i=document.createElement("OPTION");r.a.Z(i,d.optionsCaption);
r.h.S(i,l);a.appendChild(i)}for(var b=0,j=g.length;b<j;b++){var i=document.createElement("OPTION"),k="string"==typeof d.optionsValue?g[b][d.optionsValue]:g[b],k=r.a.d(k);r.h.S(i,k);var n=d.optionsText,k="function"==typeof n?n(g[b]):"string"==typeof n?g[b][n]:k;if(k===o||k===l)k="";r.a.Ma(i,k);a.appendChild(i)}g=a.getElementsByTagName("OPTION");b=i=0;for(j=g.length;b<j;b++)0<=r.a.k(f,r.h.q(g[b]))&&(r.a.La(g[b],m),i++);if(h)a.scrollTop=h;e&&"value"in d&&D(a,r.a.d(d.value),m)}}};r.c.options.la="__ko.optionValueDomData__";
r.c.selectedOptions={Da:function(a){for(var b=[],a=a.childNodes,d=0,e=a.length;d<e;d++){var f=a[d];"OPTION"==f.tagName&&f.selected&&b.push(r.h.q(f))}return b},init:function(a,b,d){r.a.s(a,"change",function(){var a=b();r.P(a)?a(r.c.selectedOptions.Da(this)):(a=d(),a._ko_property_writers&&a._ko_property_writers.value&&a._ko_property_writers.value(r.c.selectedOptions.Da(this)))})},update:function(a,b){"SELECT"!=a.tagName&&c(Error("values binding applies only to SELECT elements"));var d=r.a.d(b());if(d&&
"number"==typeof d.length)for(var e=a.childNodes,f=0,h=e.length;f<h;f++){var g=e[f];"OPTION"==g.tagName&&r.a.La(g,0<=r.a.k(d,r.h.q(g)))}}};r.c.text={update:function(a,b){r.a.Ma(a,b())}};r.c.html={init:function(){return{controlsDescendantBindings:m}},update:function(a,b){var d=r.a.d(b());r.a.Z(a,d)}};r.c.css={update:function(a,b){var d=r.a.d(b()||{}),e;for(e in d)if("string"==typeof e){var f=r.a.d(d[e]);r.a.Qa(a,e,f)}}};
r.c.style={update:function(a,b){var d=r.a.d(b()||{}),e;for(e in d)if("string"==typeof e){var f=r.a.d(d[e]);a.style[e]=f||""}}};r.c.uniqueName={init:function(a,b){if(b())a.name="ko_unique_"+ ++r.c.uniqueName.Za,(r.a.ob||r.a.pb)&&a.mergeAttributes(document.createElement("<input name='"+a.name+"'/>"),p)}};r.c.uniqueName.Za=0;
r.c.checked={init:function(a,b,d){r.a.s(a,"click",function(){var e;if("checkbox"==a.type)e=a.checked;else if("radio"==a.type&&a.checked)e=a.value;else return;var f=b();"checkbox"==a.type&&r.a.d(f)instanceof Array?(e=r.a.k(r.a.d(f),a.value),a.checked&&0>e?f.push(a.value):!a.checked&&0<=e&&f.splice(e,1)):r.P(f)?f()!==e&&f(e):(f=d(),f._ko_property_writers&&f._ko_property_writers.checked&&f._ko_property_writers.checked(e))});"radio"==a.type&&!a.name&&r.c.uniqueName.init(a,function(){return m})},update:function(a,
b){var d=r.a.d(b());if("checkbox"==a.type)a.checked=d instanceof Array?0<=r.a.k(d,a.value):d;else if("radio"==a.type)a.checked=a.value==d}};r.c.attr={update:function(a,b){var d=r.a.d(b())||{},e;for(e in d)if("string"==typeof e){var f=r.a.d(d[e]);f===p||f===o||f===l?a.removeAttribute(e):a.setAttribute(e,f.toString())}}};
r.c.hasfocus={init:function(a,b,d){function e(a){var e=b();a!=r.a.d(e)&&(r.P(e)?e(a):(e=d(),e._ko_property_writers&&e._ko_property_writers.hasfocus&&e._ko_property_writers.hasfocus(a)))}r.a.s(a,"focus",function(){e(m)});r.a.s(a,"focusin",function(){e(m)});r.a.s(a,"blur",function(){e(p)});r.a.s(a,"focusout",function(){e(p)})},update:function(a,b){var d=r.a.d(b());d?a.focus():a.blur();r.a.sa(a,d?"focusin":"focusout")}};
r.c["with"]={o:function(a){return function(){var b=a();return{"if":b,data:b,templateEngine:r.p.M}}},init:function(a,b){return r.c.template.init(a,r.c["with"].o(b))},update:function(a,b,d,e,f){return r.c.template.update(a,r.c["with"].o(b),d,e,f)}};r.j.D["with"]=p;r.f.C["with"]=m;r.c["if"]={o:function(a){return function(){return{"if":a(),templateEngine:r.p.M}}},init:function(a,b){return r.c.template.init(a,r.c["if"].o(b))},update:function(a,b,d,e,f){return r.c.template.update(a,r.c["if"].o(b),d,e,f)}};
r.j.D["if"]=p;r.f.C["if"]=m;r.c.ifnot={o:function(a){return function(){return{ifnot:a(),templateEngine:r.p.M}}},init:function(a,b){return r.c.template.init(a,r.c.ifnot.o(b))},update:function(a,b,d,e,f){return r.c.template.update(a,r.c.ifnot.o(b),d,e,f)}};r.j.D.ifnot=p;r.f.C.ifnot=m;
r.c.foreach={o:function(a){return function(){var b=r.a.d(a());return!b||"number"==typeof b.length?{foreach:b,templateEngine:r.p.M}:{foreach:b.data,includeDestroyed:b.includeDestroyed,afterAdd:b.afterAdd,beforeRemove:b.beforeRemove,afterRender:b.afterRender,templateEngine:r.p.M}}},init:function(a,b){return r.c.template.init(a,r.c.foreach.o(b))},update:function(a,b,d,e,f){return r.c.template.update(a,r.c.foreach.o(b),d,e,f)}};r.j.D.foreach=p;r.f.C.foreach=m;r.b("ko.allowedVirtualElementBindings",r.f.C);
r.t=function(){};r.t.prototype.renderTemplateSource=function(){c("Override renderTemplateSource")};r.t.prototype.createJavaScriptEvaluatorBlock=function(){c("Override createJavaScriptEvaluatorBlock")};r.t.prototype.makeTemplateSource=function(a){if("string"==typeof a){var b=document.getElementById(a);b||c(Error("Cannot find template with ID "+a));return new r.m.g(b)}if(1==a.nodeType||8==a.nodeType)return new r.m.I(a);c(Error("Unknown template type: "+a))};
r.t.prototype.renderTemplate=function(a,b,d){return this.renderTemplateSource(this.makeTemplateSource(a),b,d)};r.t.prototype.isTemplateRewritten=function(a){return this.allowTemplateRewriting===p?m:this.W&&this.W[a]?m:this.makeTemplateSource(a).data("isRewritten")};r.t.prototype.rewriteTemplate=function(a,b){var d=this.makeTemplateSource(a),e=b(d.text());d.text(e);d.data("isRewritten",m);if("string"==typeof a)this.W=this.W||{},this.W[a]=m};r.b("ko.templateEngine",r.t);
r.$=function(){function a(a,b,d){for(var a=r.j.Y(a),g=r.j.D,i=0;i<a.length;i++){var j=a[i].key;if(g.hasOwnProperty(j)){var k=g[j];"function"===typeof k?(j=k(a[i].value))&&c(Error(j)):k||c(Error("This template engine does not support the '"+j+"' binding within its templates"))}}a="ko.templateRewriting.applyMemoizedBindingsToNextSibling(function() { return (function() { return { "+r.j.ia(a)+" } })() })";return d.createJavaScriptEvaluatorBlock(a)+b}var b=/(<[a-z]+\d*(\s+(?!data-bind=)[a-z0-9\-]+(=(\"[^\"]*\"|\'[^\']*\'))?)*\s+)data-bind=(["'])([\s\S]*?)\5/gi,
d=/<\!--\s*ko\b\s*([\s\S]*?)\s*--\>/g;return{gb:function(a,b){b.isTemplateRewritten(a)||b.rewriteTemplate(a,function(a){return r.$.ub(a,b)})},ub:function(e,f){return e.replace(b,function(b,e,d,j,k,n,t){return a(t,e,f)}).replace(d,function(b,e){return a(e,"<\!-- ko --\>",f)})},Ua:function(a){return r.r.ka(function(b,d){b.nextSibling&&r.xa(b.nextSibling,a,d)})}}}();r.b("ko.templateRewriting",r.$);r.b("ko.templateRewriting.applyMemoizedBindingsToNextSibling",r.$.Ua);r.m={};r.m.g=function(a){this.g=a};
r.m.g.prototype.text=function(){if(0==arguments.length)return"script"==this.g.tagName.toLowerCase()?this.g.text:this.g.innerHTML;var a=arguments[0];"script"==this.g.tagName.toLowerCase()?this.g.text=a:r.a.Z(this.g,a)};r.m.g.prototype.data=function(a){if(1===arguments.length)return r.a.e.get(this.g,"templateSourceData_"+a);r.a.e.set(this.g,"templateSourceData_"+a,arguments[1])};r.m.I=function(a){this.g=a};r.m.I.prototype=new r.m.g;
r.m.I.prototype.text=function(){if(0==arguments.length)return r.a.e.get(this.g,"__ko_anon_template__");r.a.e.set(this.g,"__ko_anon_template__",arguments[0])};r.b("ko.templateSources",r.m);r.b("ko.templateSources.domElement",r.m.g);r.b("ko.templateSources.anonymousTemplate",r.m.I);
(function(){function a(a,b,d){for(var g=0;node=a[g];g++)node.parentNode===b&&(1===node.nodeType||8===node.nodeType)&&d(node)}function b(a,b,h,g,i){var i=i||{},j=i.templateEngine||d;r.$.gb(h,j);h=j.renderTemplate(h,g,i);("number"!=typeof h.length||0<h.length&&"number"!=typeof h[0].nodeType)&&c("Template engine must return an array of DOM nodes");j=p;switch(b){case "replaceChildren":r.f.oa(a,h);j=m;break;case "replaceNode":r.a.Ja(a,h);j=m;break;case "ignoreTargetNode":break;default:c(Error("Unknown renderMode: "+
b))}j&&(r.ua(h,g),i.afterRender&&i.afterRender(h,g.$data));return h}var d;r.pa=function(a){a!=l&&!(a instanceof r.t)&&c("templateEngine must inherit from ko.templateEngine");d=a};r.ua=function(b,d){var h=r.a.J([],b),g=0<b.length?b[0].parentNode:o;a(h,g,function(a){r.wa(d,a)});a(h,g,function(a){r.r.Sa(a,[d])})};r.na=function(a,f,h,g,i){h=h||{};(h.templateEngine||d)==l&&c("Set a template engine before calling renderTemplate");i=i||"replaceChildren";if(g){var j=g.nodeType?g:0<g.length?g[0]:o;return new r.i(function(){var d=
f&&f instanceof r.K?f:new r.K(r.a.d(f)),n="function"==typeof a?a(d.$data):a,d=b(g,i,n,d,h);"replaceNode"==i&&(g=d,j=g.nodeType?g:0<g.length?g[0]:o)},o,{disposeWhen:function(){return!j||!r.a.ga(j)},disposeWhenNodeIsRemoved:j&&"replaceNode"==i?j.parentNode:j})}return r.r.ka(function(b){r.na(a,f,h,b,"replaceNode")})};r.Ab=function(a,d,h,g,i){function j(a,b){var d=k(a);r.ua(b,d);h.afterRender&&h.afterRender(b,d.$data)}function k(a){return i.createChildContext(r.a.d(a))}return new r.i(function(){var i=
r.a.d(d)||[];"undefined"==typeof i.length&&(i=[i]);i=r.a.aa(i,function(a){return h.includeDestroyed||a===l||a===o||!r.a.d(a._destroy)});r.a.Ka(g,i,function(d){var f="function"==typeof a?a(d):a;return b(o,"ignoreTargetNode",f,k(d),h)},h,j)},o,{disposeWhenNodeIsRemoved:g})};r.c.template={init:function(a,b){var d=r.a.d(b());"string"!=typeof d&&!d.name&&1==a.nodeType&&((new r.m.I(a)).text(a.innerHTML),r.a.U(a));return{controlsDescendantBindings:m}},update:function(a,b,d,g,i){b=r.a.d(b());g=m;"string"==
typeof b?d=b:(d=b.name,"if"in b&&(g=g&&r.a.d(b["if"])),"ifnot"in b&&(g=g&&!r.a.d(b.ifnot)));var j=o;"object"===typeof b&&"foreach"in b?j=r.Ab(d||a,g&&b.foreach||[],b,a,i):g?(i="object"==typeof b&&"data"in b?i.createChildContext(r.a.d(b.data)):i,j=r.na(d||a,i,b,a)):r.f.ha(a);i=j;(b=r.a.e.get(a,"__ko__templateSubscriptionDomDataKey__"))&&"function"==typeof b.v&&b.v();r.a.e.set(a,"__ko__templateSubscriptionDomDataKey__",i)}};r.j.D.template=function(a){a=r.j.Y(a);return 1==a.length&&a[0].unknown?o:r.j.rb(a,
"name")?o:"This template engine does not support anonymous templates nested within its templates"};r.f.C.template=m})();r.b("ko.setTemplateEngine",r.pa);r.b("ko.renderTemplate",r.na);
r.a.N=function(a,b,d){if(d===l)return r.a.N(a,b,1)||r.a.N(a,b,10)||r.a.N(a,b,Number.MAX_VALUE);for(var a=a||[],b=b||[],e=a,f=b,h=[],g=0;g<=f.length;g++)h[g]=[];for(var g=0,i=Math.min(e.length,d);g<=i;g++)h[0][g]=g;g=1;for(i=Math.min(f.length,d);g<=i;g++)h[g][0]=g;for(var i=e.length,j,k=f.length,g=1;g<=i;g++){j=Math.max(1,g-d);for(var n=Math.min(k,g+d);j<=n;j++)h[j][g]=e[g-1]===f[j-1]?h[j-1][g-1]:Math.min(h[j-1][g]===l?Number.MAX_VALUE:h[j-1][g]+1,h[j][g-1]===l?Number.MAX_VALUE:h[j][g-1]+1)}d=a.length;
e=b.length;f=[];g=h[e][d];if(g===l)h=o;else{for(;0<d||0<e;){i=h[e][d];k=0<e?h[e-1][d]:g+1;n=0<d?h[e][d-1]:g+1;j=0<e&&0<d?h[e-1][d-1]:g+1;if(k===l||k<i-1)k=g+1;if(n===l||n<i-1)n=g+1;j<i-1&&(j=g+1);k<=n&&k<j?(f.push({status:"added",value:b[e-1]}),e--):(n<k&&n<j?f.push({status:"deleted",value:a[d-1]}):(f.push({status:"retained",value:a[d-1]}),e--),d--)}h=f.reverse()}return h};r.b("ko.utils.compareArrays",r.a.N);
(function(){function a(a){if(2<a.length){for(var b=a[0],f=a[a.length-1],h=[b];b!==f;){b=b.nextSibling;if(!b)return;h.push(b)}Array.prototype.splice.apply(a,[0,a.length].concat(h))}}function b(b,e,f,h){var g=[],b=r.i(function(){var b=e(f)||[];0<g.length&&(a(g),r.a.Ja(g,b),h&&h(f,b));g.splice(0,g.length);r.a.J(g,b)},o,{disposeWhenNodeIsRemoved:b,disposeWhen:function(){return 0==g.length||!r.a.ga(g[0])}});return{sb:g,i:b}}r.a.Ka=function(d,e,f,h,g){for(var e=e||[],h=h||{},i=r.a.e.get(d,"setDomNodeChildrenFromArrayMapping_lastMappingResult")===
l,j=r.a.e.get(d,"setDomNodeChildrenFromArrayMapping_lastMappingResult")||[],k=r.a.ba(j,function(a){return a.Va}),n=r.a.N(k,e),e=[],t=0,q=[],k=[],v=o,s=0,w=n.length;s<w;s++)switch(n[s].status){case "retained":var x=j[t];e.push(x);0<x.O.length&&(v=x.O[x.O.length-1]);t++;break;case "deleted":j[t].i.v();a(j[t].O);r.a.n(j[t].O,function(a){q.push({element:a,index:s,value:n[s].value});v=a});t++;break;case "added":var x=n[s].value,z=b(d,f,x,g),u=z.sb;e.push({Va:n[s].value,O:u,i:z.i});for(var z=0,y=u.length;z<
y;z++){var A=u[z];k.push({element:A,index:s,value:n[s].value});v==o?r.f.xb(d,A):r.f.mb(d,A,v);v=A}g&&g(x,u)}r.a.n(q,function(a){r.F(a.element)});f=p;if(!i){if(h.afterAdd)for(s=0;s<k.length;s++)h.afterAdd(k[s].element,k[s].index,k[s].value);if(h.beforeRemove){for(s=0;s<q.length;s++)h.beforeRemove(q[s].element,q[s].index,q[s].value);f=m}}f||r.a.n(q,function(a){r.removeNode(a.element)});r.a.e.set(d,"setDomNodeChildrenFromArrayMapping_lastMappingResult",e)}})();
r.b("ko.utils.setDomNodeChildrenFromArrayMapping",r.a.Ka);r.p=function(){this.allowTemplateRewriting=p};r.p.prototype=new r.t;r.p.prototype.renderTemplateSource=function(a){a=a.text();return r.a.ma(a)};r.p.M=new r.p;r.pa(r.p.M);r.b("ko.nativeTemplateEngine",r.p);
(function(){r.ja=function(){var a=this.qb=function(){if("undefined"==typeof jQuery||!jQuery.tmpl)return 0;try{if(0<=jQuery.tmpl.tag.tmpl.open.toString().indexOf("__"))return 2}catch(a){}return 1}();this.renderTemplateSource=function(d,e,f){f=f||{};2>a&&c(Error("Your version of jQuery.tmpl is too old. Please upgrade to jQuery.tmpl 1.0.0pre or later."));var h=d.data("precompiled");h||(h=d.text()||"",h=jQuery.template(o,"{{ko_with $item.koBindingContext}}"+h+"{{/ko_with}}"),d.data("precompiled",h));
d=[e.$data];e=jQuery.extend({koBindingContext:e},f.templateOptions);e=jQuery.tmpl(h,d,e);e.appendTo(document.createElement("div"));jQuery.fragments={};return e};this.createJavaScriptEvaluatorBlock=function(a){return"{{ko_code ((function() { return "+a+" })()) }}"};this.addTemplate=function(a,b){document.write("<script type='text/html' id='"+a+"'>"+b+"<\/script>")};if(0<a)jQuery.tmpl.tag.ko_code={open:"__.push($1 || '');"},jQuery.tmpl.tag.ko_with={open:"with($1) {",close:"} "}};r.ja.prototype=new r.t;
var a=new r.ja;0<a.qb&&r.pa(a);r.b("ko.jqueryTmplTemplateEngine",r.ja)})();
})(window);
// Knockout JavaScript library v2.1.0
// (c) Steven Sanderson - http://knockoutjs.com/
// License: MIT (http://www.opensource.org/licenses/mit-license.php)
(function(window,document,navigator,undefined){
function m(w){throw w;}var n=void 0,p=!0,s=null,t=!1;function A(w){return function(){return w}};function E(w){function B(b,c,d){d&&c!==a.k.r(b)&&a.k.S(b,c);c!==a.k.r(b)&&a.a.va(b,"change")}var a="undefined"!==typeof w?w:{};a.b=function(b,c){for(var d=b.split("."),f=a,g=0;g<d.length-1;g++)f=f[d[g]];f[d[d.length-1]]=c};a.B=function(a,c,d){a[c]=d};a.version="2.1.0";a.b("version",a.version);a.a=new function(){function b(b,c){if("input"!==a.a.o(b)||!b.type||"click"!=c.toLowerCase())return t;var e=b.type;return"checkbox"==e||"radio"==e}var c=/^(\s|\u00A0)+|(\s|\u00A0)+$/g,d={},f={};d[/Firefox\/2/i.test(navigator.userAgent)?
"KeyboardEvent":"UIEvents"]=["keyup","keydown","keypress"];d.MouseEvents="click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave".split(" ");for(var g in d){var e=d[g];if(e.length)for(var h=0,j=e.length;h<j;h++)f[e[h]]=g}var k={propertychange:p},i=function(){for(var a=3,b=document.createElement("div"),c=b.getElementsByTagName("i");b.innerHTML="<\!--[if gt IE "+ ++a+"]><i></i><![endif]--\>",c[0];);return 4<a?a:n}();return{Ca:["authenticity_token",/^__RequestVerificationToken(_.*)?$/],
v:function(a,b){for(var c=0,e=a.length;c<e;c++)b(a[c])},j:function(a,b){if("function"==typeof Array.prototype.indexOf)return Array.prototype.indexOf.call(a,b);for(var c=0,e=a.length;c<e;c++)if(a[c]===b)return c;return-1},ab:function(a,b,c){for(var e=0,f=a.length;e<f;e++)if(b.call(c,a[e]))return a[e];return s},ba:function(b,c){var e=a.a.j(b,c);0<=e&&b.splice(e,1)},za:function(b){for(var b=b||[],c=[],e=0,f=b.length;e<f;e++)0>a.a.j(c,b[e])&&c.push(b[e]);return c},T:function(a,b){for(var a=a||[],c=[],
e=0,f=a.length;e<f;e++)c.push(b(a[e]));return c},aa:function(a,b){for(var a=a||[],c=[],e=0,f=a.length;e<f;e++)b(a[e])&&c.push(a[e]);return c},N:function(a,b){if(b instanceof Array)a.push.apply(a,b);else for(var c=0,e=b.length;c<e;c++)a.push(b[c]);return a},extend:function(a,b){if(b)for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return a},ga:function(b){for(;b.firstChild;)a.removeNode(b.firstChild)},Ab:function(b){for(var b=a.a.L(b),c=document.createElement("div"),e=0,f=b.length;e<f;e++)a.F(b[e]),
c.appendChild(b[e]);return c},X:function(b,c){a.a.ga(b);if(c)for(var e=0,f=c.length;e<f;e++)b.appendChild(c[e])},Na:function(b,c){var e=b.nodeType?[b]:b;if(0<e.length){for(var f=e[0],d=f.parentNode,g=0,h=c.length;g<h;g++)d.insertBefore(c[g],f);g=0;for(h=e.length;g<h;g++)a.removeNode(e[g])}},Pa:function(a,b){0<=navigator.userAgent.indexOf("MSIE 6")?a.setAttribute("selected",b):a.selected=b},w:function(a){return(a||"").replace(c,"")},Ib:function(b,c){for(var e=[],f=(b||"").split(c),g=0,d=f.length;g<
d;g++){var h=a.a.w(f[g]);""!==h&&e.push(h)}return e},Hb:function(a,b){a=a||"";return b.length>a.length?t:a.substring(0,b.length)===b},eb:function(a,b){for(var c="return ("+a+")",e=0;e<b;e++)c="with(sc["+e+"]) { "+c+" } ";return new Function("sc",c)},kb:function(a,b){if(b.compareDocumentPosition)return 16==(b.compareDocumentPosition(a)&16);for(;a!=s;){if(a==b)return p;a=a.parentNode}return t},fa:function(b){return a.a.kb(b,b.ownerDocument)},o:function(a){return a&&a.tagName&&a.tagName.toLowerCase()},
n:function(a,c,e){var f=i&&k[c];if(!f&&"undefined"!=typeof jQuery){if(b(a,c))var g=e,e=function(a,b){var c=this.checked;b&&(this.checked=b.fb!==p);g.call(this,a);this.checked=c};jQuery(a).bind(c,e)}else!f&&"function"==typeof a.addEventListener?a.addEventListener(c,e,t):"undefined"!=typeof a.attachEvent?a.attachEvent("on"+c,function(b){e.call(a,b)}):m(Error("Browser doesn't support addEventListener or attachEvent"))},va:function(a,c){(!a||!a.nodeType)&&m(Error("element must be a DOM node when calling triggerEvent"));
if("undefined"!=typeof jQuery){var e=[];b(a,c)&&e.push({fb:a.checked});jQuery(a).trigger(c,e)}else"function"==typeof document.createEvent?"function"==typeof a.dispatchEvent?(e=document.createEvent(f[c]||"HTMLEvents"),e.initEvent(c,p,p,window,0,0,0,0,0,t,t,t,t,0,a),a.dispatchEvent(e)):m(Error("The supplied element doesn't support dispatchEvent")):"undefined"!=typeof a.fireEvent?(b(a,c)&&(a.checked=a.checked!==p),a.fireEvent("on"+c)):m(Error("Browser doesn't support triggering events"))},d:function(b){return a.la(b)?
b():b},Ua:function(b,c,e){var f=(b.className||"").split(/\s+/),g=0<=a.a.j(f,c);if(e&&!g)b.className+=(f[0]?" ":"")+c;else if(g&&!e){e="";for(g=0;g<f.length;g++)f[g]!=c&&(e+=f[g]+" ");b.className=a.a.w(e)}},Qa:function(b,c){var e=a.a.d(c);if(e===s||e===n)e="";"innerText"in b?b.innerText=e:b.textContent=e;9<=i&&(b.style.display=b.style.display)},lb:function(a){if(9<=i){var b=a.style.width;a.style.width=0;a.style.width=b}},Eb:function(b,e){for(var b=a.a.d(b),e=a.a.d(e),c=[],f=b;f<=e;f++)c.push(f);return c},
L:function(a){for(var b=[],e=0,c=a.length;e<c;e++)b.push(a[e]);return b},tb:6===i,ub:7===i,ja:i,Da:function(b,e){for(var c=a.a.L(b.getElementsByTagName("input")).concat(a.a.L(b.getElementsByTagName("textarea"))),f="string"==typeof e?function(a){return a.name===e}:function(a){return e.test(a.name)},g=[],d=c.length-1;0<=d;d--)f(c[d])&&g.push(c[d]);return g},Bb:function(b){return"string"==typeof b&&(b=a.a.w(b))?window.JSON&&window.JSON.parse?window.JSON.parse(b):(new Function("return "+b))():s},sa:function(b,
e,c){("undefined"==typeof JSON||"undefined"==typeof JSON.stringify)&&m(Error("Cannot find JSON.stringify(). Some browsers (e.g., IE < 8) don't support it natively, but you can overcome this by adding a script reference to json2.js, downloadable from http://www.json.org/json2.js"));return JSON.stringify(a.a.d(b),e,c)},Cb:function(b,e,c){var c=c||{},f=c.params||{},g=c.includeFields||this.Ca,d=b;if("object"==typeof b&&"form"===a.a.o(b))for(var d=b.action,h=g.length-1;0<=h;h--)for(var k=a.a.Da(b,g[h]),
j=k.length-1;0<=j;j--)f[k[j].name]=k[j].value;var e=a.a.d(e),i=document.createElement("form");i.style.display="none";i.action=d;i.method="post";for(var z in e)b=document.createElement("input"),b.name=z,b.value=a.a.sa(a.a.d(e[z])),i.appendChild(b);for(z in f)b=document.createElement("input"),b.name=z,b.value=f[z],i.appendChild(b);document.body.appendChild(i);c.submitter?c.submitter(i):i.submit();setTimeout(function(){i.parentNode.removeChild(i)},0)}}};a.b("utils",a.a);a.b("utils.arrayForEach",a.a.v);
a.b("utils.arrayFirst",a.a.ab);a.b("utils.arrayFilter",a.a.aa);a.b("utils.arrayGetDistinctValues",a.a.za);a.b("utils.arrayIndexOf",a.a.j);a.b("utils.arrayMap",a.a.T);a.b("utils.arrayPushAll",a.a.N);a.b("utils.arrayRemoveItem",a.a.ba);a.b("utils.extend",a.a.extend);a.b("utils.fieldsIncludedWithJsonPost",a.a.Ca);a.b("utils.getFormFields",a.a.Da);a.b("utils.postJson",a.a.Cb);a.b("utils.parseJson",a.a.Bb);a.b("utils.registerEventHandler",a.a.n);a.b("utils.stringifyJson",a.a.sa);a.b("utils.range",a.a.Eb);
a.b("utils.toggleDomNodeCssClass",a.a.Ua);a.b("utils.triggerEvent",a.a.va);a.b("utils.unwrapObservable",a.a.d);Function.prototype.bind||(Function.prototype.bind=function(a){var c=this,d=Array.prototype.slice.call(arguments),a=d.shift();return function(){return c.apply(a,d.concat(Array.prototype.slice.call(arguments)))}});a.a.f=new function(){var b=0,c="__ko__"+(new Date).getTime(),d={};return{get:function(b,c){var e=a.a.f.getAll(b,t);return e===n?n:e[c]},set:function(b,c,e){e===n&&a.a.f.getAll(b,
t)===n||(a.a.f.getAll(b,p)[c]=e)},getAll:function(a,g){var e=a[c];if(!(e&&"null"!==e)){if(!g)return;e=a[c]="ko"+b++;d[e]={}}return d[e]},clear:function(a){var b=a[c];b&&(delete d[b],a[c]=s)}}};a.b("utils.domData",a.a.f);a.b("utils.domData.clear",a.a.f.clear);a.a.G=new function(){function b(b,c){var f=a.a.f.get(b,d);f===n&&c&&(f=[],a.a.f.set(b,d,f));return f}function c(e){var f=b(e,t);if(f)for(var f=f.slice(0),d=0;d<f.length;d++)f[d](e);a.a.f.clear(e);"function"==typeof jQuery&&"function"==typeof jQuery.cleanData&&
jQuery.cleanData([e]);if(g[e.nodeType])for(f=e.firstChild;e=f;)f=e.nextSibling,8===e.nodeType&&c(e)}var d="__ko_domNodeDisposal__"+(new Date).getTime(),f={1:p,8:p,9:p},g={1:p,9:p};return{wa:function(a,c){"function"!=typeof c&&m(Error("Callback must be a function"));b(a,p).push(c)},Ma:function(c,f){var g=b(c,t);g&&(a.a.ba(g,f),0==g.length&&a.a.f.set(c,d,n))},F:function(b){if(f[b.nodeType]&&(c(b),g[b.nodeType])){var d=[];a.a.N(d,b.getElementsByTagName("*"));for(var b=0,j=d.length;b<j;b++)c(d[b])}},
removeNode:function(b){a.F(b);b.parentNode&&b.parentNode.removeChild(b)}}};a.F=a.a.G.F;a.removeNode=a.a.G.removeNode;a.b("cleanNode",a.F);a.b("removeNode",a.removeNode);a.b("utils.domNodeDisposal",a.a.G);a.b("utils.domNodeDisposal.addDisposeCallback",a.a.G.wa);a.b("utils.domNodeDisposal.removeDisposeCallback",a.a.G.Ma);(function(){a.a.pa=function(b){var c;if("undefined"!=typeof jQuery){if((c=jQuery.clean([b]))&&c[0]){for(b=c[0];b.parentNode&&11!==b.parentNode.nodeType;)b=b.parentNode;b.parentNode&&
b.parentNode.removeChild(b)}}else{var d=a.a.w(b).toLowerCase();c=document.createElement("div");d=d.match(/^<(thead|tbody|tfoot)/)&&[1,"<table>","</table>"]||!d.indexOf("<tr")&&[2,"<table><tbody>","</tbody></table>"]||(!d.indexOf("<td")||!d.indexOf("<th"))&&[3,"<table><tbody><tr>","</tr></tbody></table>"]||[0,"",""];b="ignored<div>"+d[1]+b+d[2]+"</div>";for("function"==typeof window.innerShiv?c.appendChild(window.innerShiv(b)):c.innerHTML=b;d[0]--;)c=c.lastChild;c=a.a.L(c.lastChild.childNodes)}return c};
a.a.Y=function(b,c){a.a.ga(b);if(c!==s&&c!==n)if("string"!=typeof c&&(c=c.toString()),"undefined"!=typeof jQuery)jQuery(b).html(c);else for(var d=a.a.pa(c),f=0;f<d.length;f++)b.appendChild(d[f])}})();a.b("utils.parseHtmlFragment",a.a.pa);a.b("utils.setHtml",a.a.Y);a.s=function(){function b(){return(4294967296*(1+Math.random())|0).toString(16).substring(1)}function c(b,g){if(b)if(8==b.nodeType){var e=a.s.Ja(b.nodeValue);e!=s&&g.push({jb:b,yb:e})}else if(1==b.nodeType)for(var e=0,d=b.childNodes,j=d.length;e<
j;e++)c(d[e],g)}var d={};return{na:function(a){"function"!=typeof a&&m(Error("You can only pass a function to ko.memoization.memoize()"));var c=b()+b();d[c]=a;return"<\!--[ko_memo:"+c+"]--\>"},Va:function(a,b){var c=d[a];c===n&&m(Error("Couldn't find any memo with ID "+a+". Perhaps it's already been unmemoized."));try{return c.apply(s,b||[]),p}finally{delete d[a]}},Wa:function(b,d){var e=[];c(b,e);for(var h=0,j=e.length;h<j;h++){var k=e[h].jb,i=[k];d&&a.a.N(i,d);a.s.Va(e[h].yb,i);k.nodeValue="";k.parentNode&&
k.parentNode.removeChild(k)}},Ja:function(a){return(a=a.match(/^\[ko_memo\:(.*?)\]$/))?a[1]:s}}}();a.b("memoization",a.s);a.b("memoization.memoize",a.s.na);a.b("memoization.unmemoize",a.s.Va);a.b("memoization.parseMemoText",a.s.Ja);a.b("memoization.unmemoizeDomNodeAndDescendants",a.s.Wa);a.Ba={throttle:function(b,c){b.throttleEvaluation=c;var d=s;return a.h({read:b,write:function(a){clearTimeout(d);d=setTimeout(function(){b(a)},c)}})},notify:function(b,c){b.equalityComparer="always"==c?A(t):a.m.fn.equalityComparer;
return b}};a.b("extenders",a.Ba);a.Sa=function(b,c,d){this.target=b;this.ca=c;this.ib=d;a.B(this,"dispose",this.A)};a.Sa.prototype.A=function(){this.sb=p;this.ib()};a.R=function(){this.u={};a.a.extend(this,a.R.fn);a.B(this,"subscribe",this.ta);a.B(this,"extend",this.extend);a.B(this,"getSubscriptionsCount",this.ob)};a.R.fn={ta:function(b,c,d){var d=d||"change",b=c?b.bind(c):b,f=new a.Sa(this,b,function(){a.a.ba(this.u[d],f)}.bind(this));this.u[d]||(this.u[d]=[]);this.u[d].push(f);return f},notifySubscribers:function(b,
c){c=c||"change";this.u[c]&&a.a.v(this.u[c].slice(0),function(a){a&&a.sb!==p&&a.ca(b)})},ob:function(){var a=0,c;for(c in this.u)this.u.hasOwnProperty(c)&&(a+=this.u[c].length);return a},extend:function(b){var c=this;if(b)for(var d in b){var f=a.Ba[d];"function"==typeof f&&(c=f(c,b[d]))}return c}};a.Ga=function(a){return"function"==typeof a.ta&&"function"==typeof a.notifySubscribers};a.b("subscribable",a.R);a.b("isSubscribable",a.Ga);a.U=function(){var b=[];return{bb:function(a){b.push({ca:a,Aa:[]})},
end:function(){b.pop()},La:function(c){a.Ga(c)||m(Error("Only subscribable things can act as dependencies"));if(0<b.length){var d=b[b.length-1];0<=a.a.j(d.Aa,c)||(d.Aa.push(c),d.ca(c))}}}}();var G={undefined:p,"boolean":p,number:p,string:p};a.m=function(b){function c(){if(0<arguments.length){if(!c.equalityComparer||!c.equalityComparer(d,arguments[0]))c.I(),d=arguments[0],c.H();return this}a.U.La(c);return d}var d=b;a.R.call(c);c.H=function(){c.notifySubscribers(d)};c.I=function(){c.notifySubscribers(d,
"beforeChange")};a.a.extend(c,a.m.fn);a.B(c,"valueHasMutated",c.H);a.B(c,"valueWillMutate",c.I);return c};a.m.fn={equalityComparer:function(a,c){return a===s||typeof a in G?a===c:t}};var x=a.m.Db="__ko_proto__";a.m.fn[x]=a.m;a.ia=function(b,c){return b===s||b===n||b[x]===n?t:b[x]===c?p:a.ia(b[x],c)};a.la=function(b){return a.ia(b,a.m)};a.Ha=function(b){return"function"==typeof b&&b[x]===a.m||"function"==typeof b&&b[x]===a.h&&b.pb?p:t};a.b("observable",a.m);a.b("isObservable",a.la);a.b("isWriteableObservable",
a.Ha);a.Q=function(b){0==arguments.length&&(b=[]);b!==s&&(b!==n&&!("length"in b))&&m(Error("The argument passed when initializing an observable array must be an array, or null, or undefined."));var c=a.m(b);a.a.extend(c,a.Q.fn);return c};a.Q.fn={remove:function(a){for(var c=this(),d=[],f="function"==typeof a?a:function(c){return c===a},g=0;g<c.length;g++){var e=c[g];f(e)&&(0===d.length&&this.I(),d.push(e),c.splice(g,1),g--)}d.length&&this.H();return d},removeAll:function(b){if(b===n){var c=this(),
d=c.slice(0);this.I();c.splice(0,c.length);this.H();return d}return!b?[]:this.remove(function(c){return 0<=a.a.j(b,c)})},destroy:function(a){var c=this(),d="function"==typeof a?a:function(c){return c===a};this.I();for(var f=c.length-1;0<=f;f--)d(c[f])&&(c[f]._destroy=p);this.H()},destroyAll:function(b){return b===n?this.destroy(A(p)):!b?[]:this.destroy(function(c){return 0<=a.a.j(b,c)})},indexOf:function(b){var c=this();return a.a.j(c,b)},replace:function(a,c){var d=this.indexOf(a);0<=d&&(this.I(),
this()[d]=c,this.H())}};a.a.v("pop push reverse shift sort splice unshift".split(" "),function(b){a.Q.fn[b]=function(){var a=this();this.I();a=a[b].apply(a,arguments);this.H();return a}});a.a.v(["slice"],function(b){a.Q.fn[b]=function(){var a=this();return a[b].apply(a,arguments)}});a.b("observableArray",a.Q);a.h=function(b,c,d){function f(){a.a.v(v,function(a){a.A()});v=[]}function g(){var a=h.throttleEvaluation;a&&0<=a?(clearTimeout(x),x=setTimeout(e,a)):e()}function e(){if(!l)if(i&&w())u();else{l=
p;try{var b=a.a.T(v,function(a){return a.target});a.U.bb(function(c){var e;0<=(e=a.a.j(b,c))?b[e]=n:v.push(c.ta(g))});for(var e=q.call(c),f=b.length-1;0<=f;f--)b[f]&&v.splice(f,1)[0].A();i=p;h.notifySubscribers(k,"beforeChange");k=e}finally{a.U.end()}h.notifySubscribers(k);l=t}}function h(){if(0<arguments.length)j.apply(h,arguments);else return i||e(),a.U.La(h),k}function j(){"function"===typeof o?o.apply(c,arguments):m(Error("Cannot write a value to a ko.computed unless you specify a 'write' option. If you wish to read the current value, don't pass any parameters."))}
var k,i=t,l=t,q=b;q&&"object"==typeof q?(d=q,q=d.read):(d=d||{},q||(q=d.read));"function"!=typeof q&&m(Error("Pass a function that returns the value of the ko.computed"));var o=d.write;c||(c=d.owner);var v=[],u=f,r="object"==typeof d.disposeWhenNodeIsRemoved?d.disposeWhenNodeIsRemoved:s,w=d.disposeWhen||A(t);if(r){u=function(){a.a.G.Ma(r,arguments.callee);f()};a.a.G.wa(r,u);var y=w,w=function(){return!a.a.fa(r)||y()}}var x=s;h.nb=function(){return v.length};h.pb="function"===typeof d.write;h.A=function(){u()};
a.R.call(h);a.a.extend(h,a.h.fn);d.deferEvaluation!==p&&e();a.B(h,"dispose",h.A);a.B(h,"getDependenciesCount",h.nb);return h};a.rb=function(b){return a.ia(b,a.h)};w=a.m.Db;a.h[w]=a.m;a.h.fn={};a.h.fn[w]=a.h;a.b("dependentObservable",a.h);a.b("computed",a.h);a.b("isComputed",a.rb);(function(){function b(a,g,e){e=e||new d;a=g(a);if(!("object"==typeof a&&a!==s&&a!==n&&!(a instanceof Date)))return a;var h=a instanceof Array?[]:{};e.save(a,h);c(a,function(c){var d=g(a[c]);switch(typeof d){case "boolean":case "number":case "string":case "function":h[c]=
d;break;case "object":case "undefined":var i=e.get(d);h[c]=i!==n?i:b(d,g,e)}});return h}function c(a,b){if(a instanceof Array){for(var c=0;c<a.length;c++)b(c);"function"==typeof a.toJSON&&b("toJSON")}else for(c in a)b(c)}function d(){var b=[],c=[];this.save=function(e,d){var j=a.a.j(b,e);0<=j?c[j]=d:(b.push(e),c.push(d))};this.get=function(e){e=a.a.j(b,e);return 0<=e?c[e]:n}}a.Ta=function(c){0==arguments.length&&m(Error("When calling ko.toJS, pass the object you want to convert."));return b(c,function(b){for(var c=
0;a.la(b)&&10>c;c++)b=b();return b})};a.toJSON=function(b,c,e){b=a.Ta(b);return a.a.sa(b,c,e)}})();a.b("toJS",a.Ta);a.b("toJSON",a.toJSON);(function(){a.k={r:function(b){switch(a.a.o(b)){case "option":return b.__ko__hasDomDataOptionValue__===p?a.a.f.get(b,a.c.options.oa):b.getAttribute("value");case "select":return 0<=b.selectedIndex?a.k.r(b.options[b.selectedIndex]):n;default:return b.value}},S:function(b,c){switch(a.a.o(b)){case "option":switch(typeof c){case "string":a.a.f.set(b,a.c.options.oa,
n);"__ko__hasDomDataOptionValue__"in b&&delete b.__ko__hasDomDataOptionValue__;b.value=c;break;default:a.a.f.set(b,a.c.options.oa,c),b.__ko__hasDomDataOptionValue__=p,b.value="number"===typeof c?c:""}break;case "select":for(var d=b.options.length-1;0<=d;d--)if(a.k.r(b.options[d])==c){b.selectedIndex=d;break}break;default:if(c===s||c===n)c="";b.value=c}}}})();a.b("selectExtensions",a.k);a.b("selectExtensions.readValue",a.k.r);a.b("selectExtensions.writeValue",a.k.S);a.g=function(){function b(a,b){for(var d=
s;a!=d;)d=a,a=a.replace(c,function(a,c){return b[c]});return a}var c=/\@ko_token_(\d+)\@/g,d=/^[\_$a-z][\_$a-z0-9]*(\[.*?\])*(\.[\_$a-z][\_$a-z0-9]*(\[.*?\])*)*$/i,f=["true","false"];return{D:[],W:function(c){var e=a.a.w(c);if(3>e.length)return[];"{"===e.charAt(0)&&(e=e.substring(1,e.length-1));for(var c=[],d=s,f,k=0;k<e.length;k++){var i=e.charAt(k);if(d===s)switch(i){case '"':case "'":case "/":d=k,f=i}else if(i==f&&"\\"!==e.charAt(k-1)){i=e.substring(d,k+1);c.push(i);var l="@ko_token_"+(c.length-
1)+"@",e=e.substring(0,d)+l+e.substring(k+1),k=k-(i.length-l.length),d=s}}f=d=s;for(var q=0,o=s,k=0;k<e.length;k++){i=e.charAt(k);if(d===s)switch(i){case "{":d=k;o=i;f="}";break;case "(":d=k;o=i;f=")";break;case "[":d=k,o=i,f="]"}i===o?q++:i===f&&(q--,0===q&&(i=e.substring(d,k+1),c.push(i),l="@ko_token_"+(c.length-1)+"@",e=e.substring(0,d)+l+e.substring(k+1),k-=i.length-l.length,d=s))}f=[];e=e.split(",");d=0;for(k=e.length;d<k;d++)q=e[d],o=q.indexOf(":"),0<o&&o<q.length-1?(i=q.substring(o+1),f.push({key:b(q.substring(0,
o),c),value:b(i,c)})):f.push({unknown:b(q,c)});return f},ka:function(b){for(var c="string"===typeof b?a.g.W(b):b,h=[],b=[],j,k=0;j=c[k];k++)if(0<h.length&&h.push(","),j.key){var i;a:{i=j.key;var l=a.a.w(i);switch(l.length&&l.charAt(0)){case "'":case '"':break a;default:i="'"+l+"'"}}j=j.value;h.push(i);h.push(":");h.push(j);l=a.a.w(j);if(0<=a.a.j(f,a.a.w(l).toLowerCase())?0:l.match(d)!==s)0<b.length&&b.push(", "),b.push(i+" : function(__ko_value) { "+j+" = __ko_value; }")}else j.unknown&&h.push(j.unknown);
c=h.join("");0<b.length&&(c=c+", '_ko_property_writers' : { "+b.join("")+" } ");return c},wb:function(b,c){for(var d=0;d<b.length;d++)if(a.a.w(b[d].key)==c)return p;return t},$:function(b,c,d,f,k){if(!b||!a.Ha(b)){if((b=c()._ko_property_writers)&&b[d])b[d](f)}else(!k||b()!==f)&&b(f)}}}();a.b("jsonExpressionRewriting",a.g);a.b("jsonExpressionRewriting.bindingRewriteValidators",a.g.D);a.b("jsonExpressionRewriting.parseObjectLiteral",a.g.W);a.b("jsonExpressionRewriting.insertPropertyAccessorsIntoJson",
a.g.ka);(function(){function b(a){return 8==a.nodeType&&(g?a.text:a.nodeValue).match(e)}function c(a){return 8==a.nodeType&&(g?a.text:a.nodeValue).match(h)}function d(a,e){for(var d=a,f=1,g=[];d=d.nextSibling;){if(c(d)&&(f--,0===f))return g;g.push(d);b(d)&&f++}e||m(Error("Cannot find closing comment tag to match: "+a.nodeValue));return s}function f(a,b){var c=d(a,b);return c?0<c.length?c[c.length-1].nextSibling:a.nextSibling:s}var g="<\!--test--\>"===document.createComment("test").text,e=g?/^<\!--\s*ko\s+(.*\:.*)\s*--\>$/:
/^\s*ko\s+(.*\:.*)\s*$/,h=g?/^<\!--\s*\/ko\s*--\>$/:/^\s*\/ko\s*$/,j={ul:p,ol:p};a.e={C:{},childNodes:function(a){return b(a)?d(a):a.childNodes},ha:function(c){if(b(c))for(var c=a.e.childNodes(c),e=0,d=c.length;e<d;e++)a.removeNode(c[e]);else a.a.ga(c)},X:function(c,e){if(b(c)){a.e.ha(c);for(var d=c.nextSibling,f=0,g=e.length;f<g;f++)d.parentNode.insertBefore(e[f],d)}else a.a.X(c,e)},Ka:function(a,c){b(a)?a.parentNode.insertBefore(c,a.nextSibling):a.firstChild?a.insertBefore(c,a.firstChild):a.appendChild(c)},
Fa:function(a,c,e){b(a)?a.parentNode.insertBefore(c,e.nextSibling):e.nextSibling?a.insertBefore(c,e.nextSibling):a.appendChild(c)},firstChild:function(a){return!b(a)?a.firstChild:!a.nextSibling||c(a.nextSibling)?s:a.nextSibling},nextSibling:function(a){b(a)&&(a=f(a));return a.nextSibling&&c(a.nextSibling)?s:a.nextSibling},Xa:function(a){return(a=b(a))?a[1]:s},Ia:function(e){if(j[a.a.o(e)]){var d=e.firstChild;if(d){do if(1===d.nodeType){var g;g=d.firstChild;var h=s;if(g){do if(h)h.push(g);else if(b(g)){var o=
f(g,p);o?g=o:h=[g]}else c(g)&&(h=[g]);while(g=g.nextSibling)}if(g=h){h=d.nextSibling;for(o=0;o<g.length;o++)h?e.insertBefore(g[o],h):e.appendChild(g[o])}}while(d=d.nextSibling)}}}}})();a.b("virtualElements",a.e);a.b("virtualElements.allowedBindings",a.e.C);a.b("virtualElements.emptyNode",a.e.ha);a.b("virtualElements.insertAfter",a.e.Fa);a.b("virtualElements.prepend",a.e.Ka);a.b("virtualElements.setDomNodeChildren",a.e.X);(function(){a.J=function(){this.cb={}};a.a.extend(a.J.prototype,{nodeHasBindings:function(b){switch(b.nodeType){case 1:return b.getAttribute("data-bind")!=
s;case 8:return a.e.Xa(b)!=s;default:return t}},getBindings:function(a,c){var d=this.getBindingsString(a,c);return d?this.parseBindingsString(d,c):s},getBindingsString:function(b){switch(b.nodeType){case 1:return b.getAttribute("data-bind");case 8:return a.e.Xa(b);default:return s}},parseBindingsString:function(b,c){try{var d=c.$data,d="object"==typeof d&&d!=s?[d,c]:[c],f=d.length,g=this.cb,e=f+"_"+b,h;if(!(h=g[e])){var j=" { "+a.g.ka(b)+" } ";h=g[e]=a.a.eb(j,f)}return h(d)}catch(k){m(Error("Unable to parse bindings.\nMessage: "+
k+";\nBindings value: "+b))}}});a.J.instance=new a.J})();a.b("bindingProvider",a.J);(function(){function b(b,d,e){for(var h=a.e.firstChild(d);d=h;)h=a.e.nextSibling(d),c(b,d,e)}function c(c,g,e){var h=p,j=1===g.nodeType;j&&a.e.Ia(g);if(j&&e||a.J.instance.nodeHasBindings(g))h=d(g,s,c,e).Gb;h&&b(c,g,!j)}function d(b,c,e,d){function j(a){return function(){return l[a]}}function k(){return l}var i=0,l,q;a.h(function(){var o=e&&e instanceof a.z?e:new a.z(a.a.d(e)),v=o.$data;d&&a.Ra(b,o);if(l=("function"==
typeof c?c():c)||a.J.instance.getBindings(b,o)){if(0===i){i=1;for(var u in l){var r=a.c[u];r&&8===b.nodeType&&!a.e.C[u]&&m(Error("The binding '"+u+"' cannot be used with virtual elements"));if(r&&"function"==typeof r.init&&(r=(0,r.init)(b,j(u),k,v,o))&&r.controlsDescendantBindings)q!==n&&m(Error("Multiple bindings ("+q+" and "+u+") are trying to control descendant bindings of the same element. You cannot use these bindings together on the same element.")),q=u}i=2}if(2===i)for(u in l)(r=a.c[u])&&"function"==
typeof r.update&&(0,r.update)(b,j(u),k,v,o)}},s,{disposeWhenNodeIsRemoved:b});return{Gb:q===n}}a.c={};a.z=function(b,c){c?(a.a.extend(this,c),this.$parentContext=c,this.$parent=c.$data,this.$parents=(c.$parents||[]).slice(0),this.$parents.unshift(this.$parent)):(this.$parents=[],this.$root=b);this.$data=b};a.z.prototype.createChildContext=function(b){return new a.z(b,this)};a.z.prototype.extend=function(b){var c=a.a.extend(new a.z,this);return a.a.extend(c,b)};a.Ra=function(b,c){if(2==arguments.length)a.a.f.set(b,
"__ko_bindingContext__",c);else return a.a.f.get(b,"__ko_bindingContext__")};a.ya=function(b,c,e){1===b.nodeType&&a.e.Ia(b);return d(b,c,e,p)};a.Ya=function(a,c){(1===c.nodeType||8===c.nodeType)&&b(a,c,p)};a.xa=function(a,b){b&&(1!==b.nodeType&&8!==b.nodeType)&&m(Error("ko.applyBindings: first parameter should be your view model; second parameter should be a DOM node"));b=b||window.document.body;c(a,b,p)};a.ea=function(b){switch(b.nodeType){case 1:case 8:var c=a.Ra(b);if(c)return c;if(b.parentNode)return a.ea(b.parentNode)}};
a.hb=function(b){return(b=a.ea(b))?b.$data:n};a.b("bindingHandlers",a.c);a.b("applyBindings",a.xa);a.b("applyBindingsToDescendants",a.Ya);a.b("applyBindingsToNode",a.ya);a.b("contextFor",a.ea);a.b("dataFor",a.hb)})();a.a.v(["click"],function(b){a.c[b]={init:function(c,d,f,g){return a.c.event.init.call(this,c,function(){var a={};a[b]=d();return a},f,g)}}});a.c.event={init:function(b,c,d,f){var g=c()||{},e;for(e in g)(function(){var g=e;"string"==typeof g&&a.a.n(b,g,function(b){var e,i=c()[g];if(i){var l=
d();try{var q=a.a.L(arguments);q.unshift(f);e=i.apply(f,q)}finally{e!==p&&(b.preventDefault?b.preventDefault():b.returnValue=t)}l[g+"Bubble"]===t&&(b.cancelBubble=p,b.stopPropagation&&b.stopPropagation())}})})()}};a.c.submit={init:function(b,c,d,f){"function"!=typeof c()&&m(Error("The value for a submit binding must be a function"));a.a.n(b,"submit",function(a){var e,d=c();try{e=d.call(f,b)}finally{e!==p&&(a.preventDefault?a.preventDefault():a.returnValue=t)}})}};a.c.visible={update:function(b,c){var d=
a.a.d(c()),f="none"!=b.style.display;d&&!f?b.style.display="":!d&&f&&(b.style.display="none")}};a.c.enable={update:function(b,c){var d=a.a.d(c());d&&b.disabled?b.removeAttribute("disabled"):!d&&!b.disabled&&(b.disabled=p)}};a.c.disable={update:function(b,c){a.c.enable.update(b,function(){return!a.a.d(c())})}};a.c.value={init:function(b,c,d){function f(){var e=c(),f=a.k.r(b);a.g.$(e,d,"value",f,p)}var g=["change"],e=d().valueUpdate;e&&("string"==typeof e&&(e=[e]),a.a.N(g,e),g=a.a.za(g));if(a.a.ja&&
("input"==b.tagName.toLowerCase()&&"text"==b.type&&"off"!=b.autocomplete&&(!b.form||"off"!=b.form.autocomplete))&&-1==a.a.j(g,"propertychange")){var h=t;a.a.n(b,"propertychange",function(){h=p});a.a.n(b,"blur",function(){if(h){h=t;f()}})}a.a.v(g,function(c){var e=f;if(a.a.Hb(c,"after")){e=function(){setTimeout(f,0)};c=c.substring(5)}a.a.n(b,c,e)})},update:function(b,c){var d="select"===a.a.o(b),f=a.a.d(c()),g=a.k.r(b),e=f!=g;0===f&&(0!==g&&"0"!==g)&&(e=p);e&&(g=function(){a.k.S(b,f)},g(),d&&setTimeout(g,
0));d&&0<b.length&&B(b,f,t)}};a.c.options={update:function(b,c,d){"select"!==a.a.o(b)&&m(Error("options binding applies only to SELECT elements"));for(var f=0==b.length,g=a.a.T(a.a.aa(b.childNodes,function(b){return b.tagName&&"option"===a.a.o(b)&&b.selected}),function(b){return a.k.r(b)||b.innerText||b.textContent}),e=b.scrollTop,h=a.a.d(c());0<b.length;)a.F(b.options[0]),b.remove(0);if(h){d=d();"number"!=typeof h.length&&(h=[h]);if(d.optionsCaption){var j=document.createElement("option");a.a.Y(j,
d.optionsCaption);a.k.S(j,n);b.appendChild(j)}for(var c=0,k=h.length;c<k;c++){var j=document.createElement("option"),i="string"==typeof d.optionsValue?h[c][d.optionsValue]:h[c],i=a.a.d(i);a.k.S(j,i);var l=d.optionsText,i="function"==typeof l?l(h[c]):"string"==typeof l?h[c][l]:i;if(i===s||i===n)i="";a.a.Qa(j,i);b.appendChild(j)}h=b.getElementsByTagName("option");c=j=0;for(k=h.length;c<k;c++)0<=a.a.j(g,a.k.r(h[c]))&&(a.a.Pa(h[c],p),j++);b.scrollTop=e;f&&"value"in d&&B(b,a.a.d(d.value),p);a.a.lb(b)}}};
a.c.options.oa="__ko.optionValueDomData__";a.c.selectedOptions={Ea:function(b){for(var c=[],b=b.childNodes,d=0,f=b.length;d<f;d++){var g=b[d],e=a.a.o(g);"option"==e&&g.selected?c.push(a.k.r(g)):"optgroup"==e&&(g=a.c.selectedOptions.Ea(g),Array.prototype.splice.apply(c,[c.length,0].concat(g)))}return c},init:function(b,c,d){a.a.n(b,"change",function(){var b=c(),g=a.c.selectedOptions.Ea(this);a.g.$(b,d,"value",g)})},update:function(b,c){"select"!=a.a.o(b)&&m(Error("values binding applies only to SELECT elements"));
var d=a.a.d(c());if(d&&"number"==typeof d.length)for(var f=b.childNodes,g=0,e=f.length;g<e;g++){var h=f[g];"option"===a.a.o(h)&&a.a.Pa(h,0<=a.a.j(d,a.k.r(h)))}}};a.c.text={update:function(b,c){a.a.Qa(b,c())}};a.c.html={init:function(){return{controlsDescendantBindings:p}},update:function(b,c){var d=a.a.d(c());a.a.Y(b,d)}};a.c.css={update:function(b,c){var d=a.a.d(c()||{}),f;for(f in d)if("string"==typeof f){var g=a.a.d(d[f]);a.a.Ua(b,f,g)}}};a.c.style={update:function(b,c){var d=a.a.d(c()||{}),f;
for(f in d)if("string"==typeof f){var g=a.a.d(d[f]);b.style[f]=g||""}}};a.c.uniqueName={init:function(b,c){c()&&(b.name="ko_unique_"+ ++a.c.uniqueName.gb,(a.a.tb||a.a.ub)&&b.mergeAttributes(document.createElement("<input name='"+b.name+"'/>"),t))}};a.c.uniqueName.gb=0;a.c.checked={init:function(b,c,d){a.a.n(b,"click",function(){var f;if("checkbox"==b.type)f=b.checked;else if("radio"==b.type&&b.checked)f=b.value;else return;var g=c();"checkbox"==b.type&&a.a.d(g)instanceof Array?(f=a.a.j(a.a.d(g),b.value),
b.checked&&0>f?g.push(b.value):!b.checked&&0<=f&&g.splice(f,1)):a.g.$(g,d,"checked",f,p)});"radio"==b.type&&!b.name&&a.c.uniqueName.init(b,A(p))},update:function(b,c){var d=a.a.d(c());"checkbox"==b.type?b.checked=d instanceof Array?0<=a.a.j(d,b.value):d:"radio"==b.type&&(b.checked=b.value==d)}};var F={"class":"className","for":"htmlFor"};a.c.attr={update:function(b,c){var d=a.a.d(c())||{},f;for(f in d)if("string"==typeof f){var g=a.a.d(d[f]),e=g===t||g===s||g===n;e&&b.removeAttribute(f);8>=a.a.ja&&
f in F?(f=F[f],e?b.removeAttribute(f):b[f]=g):e||b.setAttribute(f,g.toString())}}};a.c.hasfocus={init:function(b,c,d){function f(b){var e=c();a.g.$(e,d,"hasfocus",b,p)}a.a.n(b,"focus",function(){f(p)});a.a.n(b,"focusin",function(){f(p)});a.a.n(b,"blur",function(){f(t)});a.a.n(b,"focusout",function(){f(t)})},update:function(b,c){var d=a.a.d(c());d?b.focus():b.blur();a.a.va(b,d?"focusin":"focusout")}};a.c["with"]={p:function(b){return function(){var c=b();return{"if":c,data:c,templateEngine:a.q.K}}},
init:function(b,c){return a.c.template.init(b,a.c["with"].p(c))},update:function(b,c,d,f,g){return a.c.template.update(b,a.c["with"].p(c),d,f,g)}};a.g.D["with"]=t;a.e.C["with"]=p;a.c["if"]={p:function(b){return function(){return{"if":b(),templateEngine:a.q.K}}},init:function(b,c){return a.c.template.init(b,a.c["if"].p(c))},update:function(b,c,d,f,g){return a.c.template.update(b,a.c["if"].p(c),d,f,g)}};a.g.D["if"]=t;a.e.C["if"]=p;a.c.ifnot={p:function(b){return function(){return{ifnot:b(),templateEngine:a.q.K}}},
init:function(b,c){return a.c.template.init(b,a.c.ifnot.p(c))},update:function(b,c,d,f,g){return a.c.template.update(b,a.c.ifnot.p(c),d,f,g)}};a.g.D.ifnot=t;a.e.C.ifnot=p;a.c.foreach={p:function(b){return function(){var c=a.a.d(b());return!c||"number"==typeof c.length?{foreach:c,templateEngine:a.q.K}:{foreach:c.data,includeDestroyed:c.includeDestroyed,afterAdd:c.afterAdd,beforeRemove:c.beforeRemove,afterRender:c.afterRender,templateEngine:a.q.K}}},init:function(b,c){return a.c.template.init(b,a.c.foreach.p(c))},
update:function(b,c,d,f,g){return a.c.template.update(b,a.c.foreach.p(c),d,f,g)}};a.g.D.foreach=t;a.e.C.foreach=p;a.t=function(){};a.t.prototype.renderTemplateSource=function(){m(Error("Override renderTemplateSource"))};a.t.prototype.createJavaScriptEvaluatorBlock=function(){m(Error("Override createJavaScriptEvaluatorBlock"))};a.t.prototype.makeTemplateSource=function(b,c){if("string"==typeof b){var c=c||document,d=c.getElementById(b);d||m(Error("Cannot find template with ID "+b));return new a.l.i(d)}if(1==
b.nodeType||8==b.nodeType)return new a.l.M(b);m(Error("Unknown template type: "+b))};a.t.prototype.renderTemplate=function(a,c,d,f){return this.renderTemplateSource(this.makeTemplateSource(a,f),c,d)};a.t.prototype.isTemplateRewritten=function(a,c){return this.allowTemplateRewriting===t||!(c&&c!=document)&&this.V&&this.V[a]?p:this.makeTemplateSource(a,c).data("isRewritten")};a.t.prototype.rewriteTemplate=function(a,c,d){var f=this.makeTemplateSource(a,d),c=c(f.text());f.text(c);f.data("isRewritten",
p);!(d&&d!=document)&&"string"==typeof a&&(this.V=this.V||{},this.V[a]=p)};a.b("templateEngine",a.t);a.Z=function(){function b(b,c,e){for(var b=a.g.W(b),d=a.g.D,j=0;j<b.length;j++){var k=b[j].key;if(d.hasOwnProperty(k)){var i=d[k];"function"===typeof i?(k=i(b[j].value))&&m(Error(k)):i||m(Error("This template engine does not support the '"+k+"' binding within its templates"))}}b="ko.templateRewriting.applyMemoizedBindingsToNextSibling(function() { return (function() { return { "+a.g.ka(b)+
" } })() })";return e.createJavaScriptEvaluatorBlock(b)+c}var c=/(<[a-z]+\d*(\s+(?!data-bind=)[a-z0-9\-]+(=(\"[^\"]*\"|\'[^\']*\'))?)*\s+)data-bind=(["'])([\s\S]*?)\5/gi,d=/<\!--\s*ko\b\s*([\s\S]*?)\s*--\>/g;return{mb:function(b,c,e){c.isTemplateRewritten(b,e)||c.rewriteTemplate(b,function(b){return a.Z.zb(b,c)},e)},zb:function(a,g){return a.replace(c,function(a,c,d,f,i,l,q){return b(q,c,g)}).replace(d,function(a,c){return b(c,"<\!-- ko --\>",g)})},Za:function(b){return a.s.na(function(c,
e){c.nextSibling&&a.ya(c.nextSibling,b,e)})}}}();a.b("templateRewriting",a.Z);a.b("templateRewriting.applyMemoizedBindingsToNextSibling",a.Z.Za);(function(){a.l={};a.l.i=function(a){this.i=a};a.l.i.prototype.text=function(){var b=a.a.o(this.i),b="script"===b?"text":"textarea"===b?"value":"innerHTML";if(0==arguments.length)return this.i[b];var c=arguments[0];"innerHTML"===b?a.a.Y(this.i,c):this.i[b]=c};a.l.i.prototype.data=function(b){if(1===arguments.length)return a.a.f.get(this.i,"templateSourceData_"+
b);a.a.f.set(this.i,"templateSourceData_"+b,arguments[1])};a.l.M=function(a){this.i=a};a.l.M.prototype=new a.l.i;a.l.M.prototype.text=function(){if(0==arguments.length){var b=a.a.f.get(this.i,"__ko_anon_template__")||{};b.ua===n&&b.da&&(b.ua=b.da.innerHTML);return b.ua}a.a.f.set(this.i,"__ko_anon_template__",{ua:arguments[0]})};a.l.i.prototype.nodes=function(){if(0==arguments.length)return(a.a.f.get(this.i,"__ko_anon_template__")||{}).da;a.a.f.set(this.i,"__ko_anon_template__",{da:arguments[0]})};
a.b("templateSources",a.l);a.b("templateSources.domElement",a.l.i);a.b("templateSources.anonymousTemplate",a.l.M)})();(function(){function b(b,c,d){for(var f,c=a.e.nextSibling(c);b&&(f=b)!==c;)b=a.e.nextSibling(f),(1===f.nodeType||8===f.nodeType)&&d(f)}function c(c,d){if(c.length){var f=c[0],g=c[c.length-1];b(f,g,function(b){a.xa(d,b)});b(f,g,function(b){a.s.Wa(b,[d])})}}function d(a){return a.nodeType?a:0<a.length?a[0]:s}function f(b,f,j,k,i){var i=i||{},l=b&&d(b),l=l&&l.ownerDocument,q=i.templateEngine||
g;a.Z.mb(j,q,l);j=q.renderTemplate(j,k,i,l);("number"!=typeof j.length||0<j.length&&"number"!=typeof j[0].nodeType)&&m(Error("Template engine must return an array of DOM nodes"));l=t;switch(f){case "replaceChildren":a.e.X(b,j);l=p;break;case "replaceNode":a.a.Na(b,j);l=p;break;case "ignoreTargetNode":break;default:m(Error("Unknown renderMode: "+f))}l&&(c(j,k),i.afterRender&&i.afterRender(j,k.$data));return j}var g;a.ra=function(b){b!=n&&!(b instanceof a.t)&&m(Error("templateEngine must inherit from ko.templateEngine"));
g=b};a.qa=function(b,c,j,k,i){j=j||{};(j.templateEngine||g)==n&&m(Error("Set a template engine before calling renderTemplate"));i=i||"replaceChildren";if(k){var l=d(k);return a.h(function(){var g=c&&c instanceof a.z?c:new a.z(a.a.d(c)),o="function"==typeof b?b(g.$data):b,g=f(k,i,o,g,j);"replaceNode"==i&&(k=g,l=d(k))},s,{disposeWhen:function(){return!l||!a.a.fa(l)},disposeWhenNodeIsRemoved:l&&"replaceNode"==i?l.parentNode:l})}return a.s.na(function(d){a.qa(b,c,j,d,"replaceNode")})};a.Fb=function(b,
d,g,k,i){function l(a,b){c(b,o);g.afterRender&&g.afterRender(b,a)}function q(c,d){var h="function"==typeof b?b(c):b;o=i.createChildContext(a.a.d(c));o.$index=d;return f(s,"ignoreTargetNode",h,o,g)}var o;return a.h(function(){var b=a.a.d(d)||[];"undefined"==typeof b.length&&(b=[b]);b=a.a.aa(b,function(b){return g.includeDestroyed||b===n||b===s||!a.a.d(b._destroy)});a.a.Oa(k,b,q,g,l)},s,{disposeWhenNodeIsRemoved:k})};a.c.template={init:function(b,c){var d=a.a.d(c());if("string"!=typeof d&&!d.name&&
(1==b.nodeType||8==b.nodeType))d=1==b.nodeType?b.childNodes:a.e.childNodes(b),d=a.a.Ab(d),(new a.l.M(b)).nodes(d);return{controlsDescendantBindings:p}},update:function(b,c,d,f,g){c=a.a.d(c());f=p;"string"==typeof c?d=c:(d=c.name,"if"in c&&(f=f&&a.a.d(c["if"])),"ifnot"in c&&(f=f&&!a.a.d(c.ifnot)));var l=s;"object"===typeof c&&"foreach"in c?l=a.Fb(d||b,f&&c.foreach||[],c,b,g):f?(g="object"==typeof c&&"data"in c?g.createChildContext(a.a.d(c.data)):g,l=a.qa(d||b,g,c,b)):a.e.ha(b);g=l;(c=a.a.f.get(b,"__ko__templateSubscriptionDomDataKey__"))&&
"function"==typeof c.A&&c.A();a.a.f.set(b,"__ko__templateSubscriptionDomDataKey__",g)}};a.g.D.template=function(b){b=a.g.W(b);return 1==b.length&&b[0].unknown||a.g.wb(b,"name")?s:"This template engine does not support anonymous templates nested within its templates"};a.e.C.template=p})();a.b("setTemplateEngine",a.ra);a.b("renderTemplate",a.qa);(function(){a.a.O=function(b,c,d){if(d===n)return a.a.O(b,c,1)||a.a.O(b,c,10)||a.a.O(b,c,Number.MAX_VALUE);for(var b=b||[],c=c||[],f=b,g=c,e=[],h=0;h<=g.length;h++)e[h]=
[];for(var h=0,j=Math.min(f.length,d);h<=j;h++)e[0][h]=h;h=1;for(j=Math.min(g.length,d);h<=j;h++)e[h][0]=h;for(var j=f.length,k,i=g.length,h=1;h<=j;h++){k=Math.max(1,h-d);for(var l=Math.min(i,h+d);k<=l;k++)e[k][h]=f[h-1]===g[k-1]?e[k-1][h-1]:Math.min(e[k-1][h]===n?Number.MAX_VALUE:e[k-1][h]+1,e[k][h-1]===n?Number.MAX_VALUE:e[k][h-1]+1)}d=b.length;f=c.length;g=[];h=e[f][d];if(h===n)e=s;else{for(;0<d||0<f;){j=e[f][d];i=0<f?e[f-1][d]:h+1;l=0<d?e[f][d-1]:h+1;k=0<f&&0<d?e[f-1][d-1]:h+1;if(i===n||i<j-1)i=
h+1;if(l===n||l<j-1)l=h+1;k<j-1&&(k=h+1);i<=l&&i<k?(g.push({status:"added",value:c[f-1]}),f--):(l<i&&l<k?g.push({status:"deleted",value:b[d-1]}):(g.push({status:"retained",value:b[d-1]}),f--),d--)}e=g.reverse()}return e}})();a.b("utils.compareArrays",a.a.O);(function(){function b(a){if(2<a.length){for(var b=a[0],c=a[a.length-1],e=[b];b!==c;){b=b.nextSibling;if(!b)return;e.push(b)}Array.prototype.splice.apply(a,[0,a.length].concat(e))}}function c(c,f,g,e,h){var j=[],c=a.h(function(){var c=f(g,h)||
[];0<j.length&&(b(j),a.a.Na(j,c),e&&e(g,c));j.splice(0,j.length);a.a.N(j,c)},s,{disposeWhenNodeIsRemoved:c,disposeWhen:function(){return 0==j.length||!a.a.fa(j[0])}});return{xb:j,h:c}}a.a.Oa=function(d,f,g,e,h){for(var f=f||[],e=e||{},j=a.a.f.get(d,"setDomNodeChildrenFromArrayMapping_lastMappingResult")===n,k=a.a.f.get(d,"setDomNodeChildrenFromArrayMapping_lastMappingResult")||[],i=a.a.T(k,function(a){return a.$a}),l=a.a.O(i,f),f=[],q=0,o=[],v=0,i=[],u=s,r=0,w=l.length;r<w;r++)switch(l[r].status){case "retained":var y=
k[q];y.qb(v);v=f.push(y);0<y.P.length&&(u=y.P[y.P.length-1]);q++;break;case "deleted":k[q].h.A();b(k[q].P);a.a.v(k[q].P,function(a){o.push({element:a,index:r,value:l[r].value});u=a});q++;break;case "added":for(var y=l[r].value,x=a.m(v),v=c(d,g,y,h,x),C=v.xb,v=f.push({$a:l[r].value,P:C,h:v.h,qb:x}),z=0,B=C.length;z<B;z++){var D=C[z];i.push({element:D,index:r,value:l[r].value});u==s?a.e.Ka(d,D):a.e.Fa(d,D,u);u=D}h&&h(y,C,x)}a.a.v(o,function(b){a.F(b.element)});g=t;if(!j){if(e.afterAdd)for(r=0;r<i.length;r++)e.afterAdd(i[r].element,
i[r].index,i[r].value);if(e.beforeRemove){for(r=0;r<o.length;r++)e.beforeRemove(o[r].element,o[r].index,o[r].value);g=p}}if(!g&&o.length)for(r=0;r<o.length;r++)e=o[r].element,e.parentNode&&e.parentNode.removeChild(e);a.a.f.set(d,"setDomNodeChildrenFromArrayMapping_lastMappingResult",f)}})();a.b("utils.setDomNodeChildrenFromArrayMapping",a.a.Oa);a.q=function(){this.allowTemplateRewriting=t};a.q.prototype=new a.t;a.q.prototype.renderTemplateSource=function(b){var c=!(9>a.a.ja)&&b.nodes?b.nodes():s;
if(c)return a.a.L(c.cloneNode(p).childNodes);b=b.text();return a.a.pa(b)};a.q.K=new a.q;a.ra(a.q.K);a.b("nativeTemplateEngine",a.q);(function(){a.ma=function(){var a=this.vb=function(){if("undefined"==typeof jQuery||!jQuery.tmpl)return 0;try{if(0<=jQuery.tmpl.tag.tmpl.open.toString().indexOf("__"))return 2}catch(a){}return 1}();this.renderTemplateSource=function(b,f,g){g=g||{};2>a&&m(Error("Your version of jQuery.tmpl is too old. Please upgrade to jQuery.tmpl 1.0.0pre or later."));var e=b.data("precompiled");
e||(e=b.text()||"",e=jQuery.template(s,"{{ko_with $item.koBindingContext}}"+e+"{{/ko_with}}"),b.data("precompiled",e));b=[f.$data];f=jQuery.extend({koBindingContext:f},g.templateOptions);f=jQuery.tmpl(e,b,f);f.appendTo(document.createElement("div"));jQuery.fragments={};return f};this.createJavaScriptEvaluatorBlock=function(a){return"{{ko_code ((function() { return "+a+" })()) }}"};this.addTemplate=function(a,b){document.write("<script type='text/html' id='"+a+"'>"+b+"<\/script>")};0<a&&(jQuery.tmpl.tag.ko_code=
{open:"__.push($1 || '');"},jQuery.tmpl.tag.ko_with={open:"with($1) {",close:"} "})};a.ma.prototype=new a.t;var b=new a.ma;0<b.vb&&a.ra(b);a.b("jqueryTmplTemplateEngine",a.ma)})()}"function"===typeof require&&"object"===typeof exports&&"object"===typeof module?E(module.exports||exports):"function"===typeof define&&define.amd?define(["exports"],E):E(window.ko={});p;
})(window,document,navigator);
// Generated by CoffeeScript 1.3.1
(function() {
var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
function ctor() { this.constructor = child; }
ctor.prototype = parent.prototype;
child.prototype = new ctor;
child.__super__ = parent.prototype;
return child;
};
window.Todo = (function() {
__extends(Todo, Backbone.Model);
var __hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
window.Todo = (function(_super) {
__extends(Todo, _super);
Todo.name = 'Todo';
function Todo() {
Todo.__super__.constructor.apply(this, arguments);
return Todo.__super__.constructor.apply(this, arguments);
}
Todo.prototype.completed = function(completed) {
if (arguments.length === 0) {
return !!this.get('completed');
......@@ -20,6 +21,9 @@
completed: completed ? new Date() : null
});
};
return Todo;
})();
})(Backbone.Model);
}).call(this);
// Generated by CoffeeScript 1.3.1
(function() {
var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
function ctor() { this.constructor = child; }
ctor.prototype = parent.prototype;
child.prototype = new ctor;
child.__super__ = parent.prototype;
return child;
};
window.TodosCollection = (function() {
__extends(TodosCollection, Backbone.Collection);
function TodosCollection() {
TodosCollection.__super__.constructor.apply(this, arguments);
var __hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
window.TodoCollection = (function(_super) {
__extends(TodoCollection, _super);
TodoCollection.name = 'TodoCollection';
function TodoCollection() {
return TodoCollection.__super__.constructor.apply(this, arguments);
}
TodosCollection.prototype.localStorage = new Store('todos-knockback');
TodosCollection.prototype.model = Todo;
TodosCollection.prototype.completedCount = function() {
TodoCollection.prototype.localStorage = new Store('todos-knockback');
TodoCollection.prototype.model = Todo;
TodoCollection.prototype.completedCount = function() {
return this.models.reduce((function(prev, cur) {
return prev + (cur.completed() ? 1 : 0);
}), 0);
};
TodosCollection.prototype.remainingCount = function() {
TodoCollection.prototype.remainingCount = function() {
return this.models.length - this.completedCount();
};
TodosCollection.prototype.completeAll = function(completed) {
TodoCollection.prototype.completeAll = function(completed) {
return this.each(function(todo) {
return todo.completed(completed);
});
};
TodosCollection.prototype.destroyCompleted = function() {
TodoCollection.prototype.destroyCompleted = function() {
var completed_tasks, model, _i, _len, _results;
completed_tasks = this.filter(function(todo) {
return todo.completed();
......@@ -39,6 +45,9 @@
}
return _results;
};
return TodosCollection;
})();
return TodoCollection;
})(Backbone.Collection);
}).call(this);
// Generated by CoffeeScript 1.3.1
(function() {
var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
function ctor() { this.constructor = child; }
ctor.prototype = parent.prototype;
child.prototype = new ctor;
child.__super__ = parent.prototype;
return child;
};
window.AppRouter = (function() {
__extends(AppRouter, Backbone.Router);
var __hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
window.AppRouter = (function(_super) {
__extends(AppRouter, _super);
AppRouter.name = 'AppRouter';
function AppRouter() {
AppRouter.__super__.constructor.apply(this, arguments);
return AppRouter.__super__.constructor.apply(this, arguments);
}
AppRouter.prototype.routes = {
"": "all",
"active": "active",
"completed": "completed"
};
AppRouter.prototype.all = function() {
return app.viewmodels.settings.list_filter_mode('');
};
AppRouter.prototype.active = function() {
return app.viewmodels.settings.list_filter_mode('active');
};
AppRouter.prototype.completed = function() {
return app.viewmodels.settings.list_filter_mode('completed');
};
return AppRouter;
})();
})(Backbone.Router);
}).call(this);
// Generated by CoffeeScript 1.3.1
(function() {
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
window.FooterViewModel = function(todos) {
this.collection_observable = kb.collectionObservable(todos);
this.remaining_count = ko.computed(__bind(function() {
return this.collection_observable.collection().remainingCount();
}, this));
this.remaining_text = ko.computed(__bind(function() {
return "" + (this.collection_observable.collection().remainingCount() === 1 ? 'item' : 'items') + " left";
}, this));
this.clear_text = ko.computed(__bind(function() {
var _this = this;
this.todos = kb.collectionObservable(todos);
this.todos.collection().bind('change', function() {
return _this.todos.valueHasMutated();
});
this.remaining_text = ko.computed(function() {
return "<strong>" + (_this.todos.collection().remainingCount()) + "</strong> " + (_this.todos.collection().remainingCount() === 1 ? 'item' : 'items') + " left";
});
this.clear_text = ko.computed(function() {
var count;
count = this.collection_observable.collection().completedCount();
count = _this.todos.collection().completedCount();
if (count) {
return "Clear completed (" + count + ")";
} else {
return '';
}
}, this));
this.onDestroyCompleted = __bind(function() {
});
this.onDestroyCompleted = function() {
return todos.destroyCompleted();
}, this);
};
return this;
};
}).call(this);
// Generated by CoffeeScript 1.3.1
(function() {
var ENTER_KEY;
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
ENTER_KEY = 13;
window.HeaderViewModel = function(todos) {
var _this = this;
this.title = ko.observable('');
this.onAddTodo = __bind(function(view_model, event) {
if (!$.trim(this.title()) || (event.keyCode !== ENTER_KEY)) {
this.onAddTodo = function(view_model, event) {
if (!$.trim(_this.title()) || (event.keyCode !== ENTER_KEY)) {
return true;
}
todos.create({
title: $.trim(this.title())
title: $.trim(_this.title())
});
return this.title('');
}, this);
return _this.title('');
};
return this;
};
}).call(this);
// Generated by CoffeeScript 1.3.1
(function() {
window.SettingsViewModel = function() {
this.list_filter_mode = ko.observable('');
return this;
};
}).call(this);
// Generated by CoffeeScript 1.3.1
(function() {
var TodoViewModel;
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
TodoViewModel = function(model) {
var _this = this;
this.editing = ko.observable(false);
this.completed = kb.observable(model, {
key: 'completed',
read: (function() {
return model.completed();
}),
write: (function(completed) {
return model.save({
completed: completed
});
return model.completed(completed);
})
}, this);
this.visible = ko.computed(__bind(function() {
this.visible = ko.computed(function() {
switch (app.viewmodels.settings.list_filter_mode()) {
case 'active':
return !this.completed();
return !_this.completed();
case 'completed':
return this.completed();
return _this.completed();
default:
return true;
}
}, this));
});
this.title = kb.observable(model, {
key: 'title',
write: (__bind(function(title) {
write: (function(title) {
if ($.trim(title)) {
model.save({
title: $.trim(title)
......@@ -33,42 +36,47 @@
return model.destroy();
});
}
return this.editing(false);
}, this))
return _this.editing(false);
})
}, this);
this.onDestroyTodo = __bind(function() {
this.onDestroyTodo = function() {
return model.destroy();
}, this);
this.onCheckEditBegin = __bind(function() {
if (!this.editing() && !this.completed()) {
this.editing(true);
};
this.onCheckEditBegin = function() {
if (!_this.editing() && !_this.completed()) {
_this.editing(true);
return $('.todo-input').focus();
}
}, this);
this.onCheckEditEnd = __bind(function(view_model, event) {
};
this.onCheckEditEnd = function(view_model, event) {
if ((event.keyCode === 13) || (event.type === 'blur')) {
$('.todo-input').blur();
return this.editing(false);
return _this.editing(false);
}
}, this);
};
return this;
};
window.TodosViewModel = function(todos) {
this.todos = ko.observableArray([]);
this.collection_observable = kb.collectionObservable(todos, this.todos, {
var _this = this;
this.todos = kb.collectionObservable(todos, {
view_model: TodoViewModel
});
this.tasks_exist = ko.computed(__bind(function() {
return this.collection_observable().length;
}, this));
this.todos.collection().bind('change', function() {
return _this.todos.valueHasMutated();
});
this.tasks_exist = ko.computed(function() {
return _this.todos().length;
});
this.all_completed = ko.computed({
read: __bind(function() {
return !this.collection_observable.collection().remainingCount();
}, this),
write: __bind(function(completed) {
return this.collection_observable.collection().completeAll(completed);
}, this)
read: function() {
return !_this.todos.collection().remainingCount();
},
write: function(completed) {
return _this.todos.collection().completeAll(completed);
}
});
return this;
};
}).call(this);
......@@ -15,7 +15,7 @@ $ ->
# Create and bind the app viewmodels
window.app = {viewmodels: {}}
app.viewmodels.settings = new SettingsViewModel()
todos = new TodosCollection()
todos = new TodoCollection()
app.viewmodels.header = new HeaderViewModel(todos)
app.viewmodels.todos = new TodosViewModel(todos)
app.viewmodels.footer = new FooterViewModel(todos)
......
class window.TodosCollection extends Backbone.Collection
class window.TodoCollection extends Backbone.Collection
localStorage: new Store('todos-knockback') # Save all of the todos under the `"todos-knockback"` namespace.
model: Todo
......
window.FooterViewModel = (todos) ->
@collection_observable = kb.collectionObservable(todos)
@todos = kb.collectionObservable(todos)
@todos.collection().bind('change', => @todos.valueHasMutated()) # get notified of changes to any models
@remaining_count = ko.computed(=> return @collection_observable.collection().remainingCount())
@remaining_text = ko.computed(=> return "#{if @collection_observable.collection().remainingCount() == 1 then 'item' else 'items'} left")
@remaining_text = ko.computed(=> return "<strong>#{@todos.collection().remainingCount()}</strong> #{if @todos.collection().remainingCount() == 1 then 'item' else 'items'} left")
@clear_text = ko.computed(=>
count = @collection_observable.collection().completedCount()
count = @todos.collection().completedCount()
return if count then "Clear completed (#{count})" else ''
)
......
TodoViewModel = (model) ->
# Task UI state
@editing = ko.observable(false)
@completed = kb.observable(model, {key: 'completed', write: ((completed) -> model.save(completed: completed)) }, @)
@completed = kb.observable(model, {key: 'completed', read: (-> return model.completed()), write: ((completed) -> model.completed(completed)) }, @)
@visible = ko.computed(=>
switch app.viewmodels.settings.list_filter_mode()
when 'active' then return not @completed()
......@@ -24,13 +24,13 @@ TodoViewModel = (model) ->
@
window.TodosViewModel = (todos) ->
@todos = ko.observableArray([])
@collection_observable = kb.collectionObservable(todos, @todos, view_model: TodoViewModel)
@todos = kb.collectionObservable(todos, {view_model: TodoViewModel})
@todos.collection().bind('change', => @todos.valueHasMutated()) # get notified of changes to any models
@tasks_exist = ko.computed(=> @collection_observable().length)
@tasks_exist = ko.computed(=> @todos().length)
@all_completed = ko.computed(
read: => return not @collection_observable.collection().remainingCount()
write: (completed) => @collection_observable.collection().completeAll(completed)
read: => return not @todos.collection().remainingCount()
write: (completed) => @todos.collection().completeAll(completed)
)
@
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment