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){thrownewError("Knockback: Dependency alert! Knockout.js must be included before this file")}if(!this.Backbone){thrownewError("Knockback: Dependency alert! Backbone.js must be included before this file")}if(!this._||!this._.VERSION){thrownewError("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){thrownewError("Knockback: _kb_observable missing from your instance")}returna._kb_observable};Knockback.setToDefault=function(a){if(a&&a.setToDefault){returna.setToDefault()}};Knockback.vmSetToDefault=function(b){varc,d,a;a=[];for(cinb){d=b[c];a.push(kb.setToDefault(d))}returna};Knockback.vmRelease=function(a){if(ainstanceofkb.ViewModel_RCBase){a.release();return}returnKnockback.vmReleaseObservables(a)};Knockback.vmReleaseObservables=function(b,d){varc,e,a;a=[];for(cinb){e=b[c];if(!e){continue}if(!(ko.isObservable(e)||(einstanceofkb.Observables)||(einstanceofkb.ViewModel_RCBase))){continue}if(d&&!_.contains(d,c)){continue}b[c]=null;a.push(kb.vmReleaseObservable(e))}returna};Knockback.vmReleaseObservable=function(a){if(!(ko.isObservable(a)||(ainstanceofkb.Observables)||(ainstanceofkb.ViewModel_RCBase))){return}if(a.destroy){returna.destroy()}else{if(a.dispose){returna.dispose()}else{if(a.release){returna.release()}}}};var__bind=function(a,b){returnfunction(){returna.apply(b,arguments)}},__hasProp=Object.prototype.hasOwnProperty,__extends=function(d,b){for(varainb){if(__hasProp.call(b,a)){d[a]=b[a]}}functionc(){this.constructor=d}c.prototype=b.prototype;d.prototype=newc;d.__super__=b.prototype;returnd};if(!this.Knockback){thrownewError("Knockback: Dependency alert! knockback_core.js must be included before this file")}Knockback.CollectionObservable=(function(){functiona(j,i,l){varb,d,g,f,k,c,h,e;this.vm_observable_array=i;if(l==null){l={}}if(!j){thrownewError("CollectionObservable: collection is missing")}if(l.hasOwnProperty("view_model")){l.view_model_constructor=l.view_model;deletel.view_model}if(this.vm_observable_array||l.view_model_create||l.view_model_constructor){if(!this.vm_observable_array){thrownewError("CollectionObservable: vm_observable_array is missing")}}if(l.hasOwnProperty("defer")){b=l.defer;deletel.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});returnkb.wrappedObservable(this)}a.prototype.destroy=function(){vare,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;returnthis.options=null};a.prototype.collection=function(){this._kb_value_observable();returnthis._kb_collection};a.prototype.sortedIndex=function(e,b,c){vard;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){returnthis.trigger("resort",this.vm_observable_array())}},this);if(c.defer){_.defer(d)}else{d()}returnthis};a.prototype.sortAttribute=function(c,d,b){returnthis.sortedIndex(d,c,b)};a.prototype._sortAttributeFn=function(b){returnfunction(d,c){return_.sortedIndex(d,c,function(e){returne.get(b)})}};a.prototype.viewModelByModel=function(c){varb;if(!this.vm_observable_array){thrownewError("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){returnd.__kb_model[b]===c[b]})};a.prototype.eachViewModel=function(e){vard,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))}returnb};a.prototype._onGetValue=function(){returnthis._kb_value_observable()};a.prototype._onCollectionReset=function(){returnthis._collectionResync()};a.prototype._onCollectionResort=function(b){if(this.options.sorted_index){thrownewError("CollectionObservable: collection sorted_index unexpected")}if(_.isArray(b)){this._collectionResync(true);returnthis.trigger("resort",this.vm_observable_array())}else{returnthis._onModelResort(b)}};a.prototype._onModelAdd=function(d){varb,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){returnthis.trigger("add",c,this.vm_observable_array())}};a.prototype._onModelRemove=function(c){varb;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);returnb.__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)}returnthis._kb_value_observable.valueHasMutated()};a.prototype._onModelResort=function(d){varb,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){returnthis.trigger("resort",c,this.vm_observable_array(),b)}};a.prototype._clearViewModels=function(e){vard,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))}returnb}};a.prototype._collectionResync=function(j){varb,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){returnthis.trigger("add",this.vm_observable_array())}}};a.prototype._viewModelCreate=function(c){varb;if(this.options.view_model_create){b=this.options.view_model_create(c)}else{if(this.options.view_model_constructor){b=newthis.options.view_model_constructor(c)}else{b=kb.viewModel(c)}}b.__kb_model=c;returnb};returna})();__extends(Knockback.CollectionObservable.prototype,Backbone.Events);Knockback.collectionObservable=function(b,c,a){returnnewKnockback.CollectionObservable(b,c,a)};Knockback.viewModelGetModel=Knockback.vmModel=function(a){if(a){returna.__kb_model}else{returnnull}};Knockback.sortedIndexWrapAttr=Knockback.siwa=function(a,b){returnfunction(d,c){return_.sortedIndex(d,c,function(e){returnnewb(e.get(a))})}};var__bind=function(a,b){returnfunction(){returna.apply(b,arguments)}};if(!this.Knockback){thrownewError("Knockback: Dependency alert! knockback_core.js must be included before this file")}Knockback.DefaultWrapper=(function(){functiona(c,b){this.default_value=b;_.bindAll(this,"destroy","setToDefault");this._kb_observable=ko.dependentObservable({read:__bind(function(){vard;d=ko.utils.unwrapObservable(c());if(!d){returnko.utils.unwrapObservable(this.default_value)}else{returnd}},this),write:function(d){returnc(d)},owner:{}});this._kb_observable.destroy=this.destroy;this._kb_observable.setToDefault=this.setToDefault;returnkb.wrappedObservable(this)}a.prototype.destroy=function(){this._kb_observable=null;returnthis.default_value=null};a.prototype.setToDefault=function(){returnthis._kb_observable(this.default_value)};returna})();Knockback.defaultWrapper=function(b,a){returnnewKnockback.DefaultWrapper(b,a)};if(!this.Knockback){thrownewError("Knockback: Dependency alert! knockback_core.js must be included before this file")}Knockback.toFormattedString=function(g){varb,e,d,c,a,f;a=g.slice();e=Array.prototype.slice.call(arguments,1);for(dine){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)}}returna};Knockback.parseFormattedString=function(h,m){vari,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=newRegExp(b);g=l.exec(h);if(g){g.shift()}if(!g||(g.length!==p)){return_.map((function(){c=[];for(varq=1;1<=i?q<=i:q>=i;1<=i?q++:q--){c.push(q)}returnc}).apply(this),function(){return""})}n=_.sortBy(_.keys(f),function(q,r){returnparseInt(q,10)});a={};for(kinn){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++}returne};Knockback.formattedObservable=function(d,c){varb,a;b=Array.prototype.slice.call(arguments,1);a=ko.dependentObservable({read:function(){vare,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))}returnkb.toFormattedString.apply(null,c)},write:function(h){varf,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++)}returne},owner:{}});returna};if(!this.Knockback){thrownewError("Knockback: Dependency alert! knockback_core.js must be included before this file")}Knockback.LocalizedObservable=(function(){functiona(d,c,b){this.value=d;this.options=c!=null?c:{};this.view_model=b;if(!(this.options.read||this.read)){thrownewError("LocalizedObservable: options.read is missing")}if(this.options.read&&this.read){thrownewError("LocalizedObservable: options.read and read class function exist. You need to choose one.")}if(this.options.write&&this.write){thrownewError("LocalizedObservable: options.write and write class function exist. You need to choose one.")}if(!kb.locale_manager){thrownewError("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)){thrownewError("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);returnkb.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={};returnthis.view_model=null};a.prototype.setToDefault=function(){varc,b;if(!this._kb_default){return}b=this._getDefaultValue();c=this._kb_value_observable();if(c!==b){returnthis._onSetValue(b)}else{returnthis._kb_value_observable.valueHasMutated()}};a.prototype.resetToCurrent=function(){this._kb_value_observable(null);returnthis._onSetValue(this._getCurrentValue())};a.prototype.observedValue=function(b){if(arguments.length===0){returnthis.value}this.value=b;this._onLocaleChange();returnthis};a.prototype._getDefaultValue=function(){if(!this._kb_default){return""}if(_.isFunction(this._kb_default)){returnthis._kb_default()}else{returnthis._kb_default}};a.prototype._getCurrentValue=function(){if(!(this.value&&this._kb_observable)){returnthis._getDefaultValue()}returnthis._kb_read.call(this,ko.utils.unwrapObservable(this.value),this._kb_observable)};a.prototype._onGetValue=function(){if(this.value){ko.utils.unwrapObservable(this.value)}returnthis._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){returnthis.options.onChange(b)}};a.prototype._onLocaleChange=function(){varb;b=this._kb_read.call(this,ko.utils.unwrapObservable(this.value),this._kb_observable);this._kb_value_observable(b);if(this.options.onChange){returnthis.options.onChange(b)}};returna})();Knockback.localizedObservable=function(c,b,a){returnnewKnockback.LocalizedObservable(c,b,a)};if(!this.Knockback){thrownewError("Knockback: Dependency alert! knockback_core.js must be included before this file")}Knockback.Observable=(function(){functiona(d,c,b){this.model=d;this.options=c;this.view_model=b;if(!this.model){thrownewError("Observable: model is missing")}if(!this.options){thrownewError("Observable: options is missing")}if(_.isString(this.options)||ko.isObservable(this.options)){this.options={key:this.options}}if(!this.options.key){thrownewError("Observable: options.key is missing")}_.bindAll(this,"destroy","setToDefault","_onGetValue","_onSetValue","_onModelChange","_onModelLoaded","_onModelUnloaded");if(Backbone.ModelRef&&(this.modelinstanceofBackbone.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=newthis.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)}returnkb.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;returnthis.view_model=null};a.prototype.setToDefault=function(){varb;b=this._getDefaultValue();if(this._kb_localizer){this._kb_localizer.observedValue(b);b=this._kb_localizer()}returnthis._kb_value_observable(b)};a.prototype._getDefaultValue=function(){if(!this.options.hasOwnProperty("default")){return""}if(_.isFunction(this.options["default"])){returnthis.options["default"]()}else{returnthis.options["default"]}};a.prototype._getCurrentValue=function(){varb,d,e,g,c,f;if(!this.model){returnthis._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){returnthis.options.read.apply(this.view_model,d)}else{returnthis.model.get.apply(this.model,d)}};a.prototype._onGetValue=function(){varb,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()}returnf};a.prototype._onSetValue=function(h){varb,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){returnthis._kb_value_observable(this._kb_localizer())}else{returnthis._kb_value_observable(h)}};a.prototype._onModelLoaded=function(b){this.model=b;this.model.bind("change",this._onModelChange);returnthis._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);returnthis.model=null};a.prototype._onModelChange=function(){if((this.model&&this.model.hasChanged)&&!this.model.hasChanged(ko.utils.unwrapObservable(this.options.key))){return}returnthis._updateValue()};a.prototype._updateValue=function(){varb;b=this._getCurrentValue();if(this._kb_localizer){this._kb_localizer.observedValue(b);b=this._kb_localizer()}returnthis._kb_value_observable(b)};returna})();Knockback.observable=function(c,b,a){returnnewKnockback.Observable(c,b,a)};if(!this.Knockback){thrownewError("Knockback: Dependency alert! knockback_core.js must be included before this file")}Knockback.Observables=(function(){functiona(e,f,k,d){varg,h,i,j,c,b;this.model=e;this.mappings_info=f;this.view_model=k;if(!this.model){thrownewError("Observables: model is missing")}if(!this.mappings_info){thrownewError("Observables: mappings_info is missing")}if(!!d&&((_.isBoolean(d)&&d)||!!d.write)){j=_.isBoolean(d)?d:!!d.write;c=this.mappings_info;for(iinc){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(iinb){h=b[i];this.view_model[i]=kb.observable(this.model,h,this.view_model)}}}a.prototype.destroy=function(){varb,d,c;c=this.mappings_info;for(dinc){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;returnthis.model=null};a.prototype.setToDefault=function(){varc,e,d,b;d=this.mappings_info;b=[];for(eind){c=d[e];b.push(this.view_model[e].setToDefault())}returnb};returna})();Knockback.observables=function(c,d,a,b){returnnewKnockback.Observables(c,d,a,b)};if(!this.Knockback){thrownewError("Knockback: Dependency alert! knockback_core.js must be included before this file")}Knockback.TriggeredObservable=(function(){functiona(b,c){this.model=b;this.event_name=c;if(!this.model){thrownewError("Observable: model is missing")}if(!this.event_name){thrownewError("Observable: event_name is missing")}_.bindAll(this,"destroy","_onGetValue","_onValueChange","_onModelLoaded","_onModelUnloaded");if(Backbone.ModelRef&&(this.modelinstanceofBackbone.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)}returnkb.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;returnthis.view_model=null};a.prototype._onGetValue=function(){returnthis._kb_value_observable()};a.prototype._onModelLoaded=function(b){this.model=b;this.model.bind(this.event_name,this._onValueChange);returnthis._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);returnthis.model=null};a.prototype._onValueChange=function(){varb;b=this._kb_value_observable();if(b!==this.model){returnthis._kb_value_observable(this.model)}else{returnthis._kb_value_observable.valueHasMutated()}};returna})();Knockback.triggeredObservable=function(a,b){returnnewKnockback.TriggeredObservable(a,b)};varAttributeConnector;var__bind=function(a,b){returnfunction(){returna.apply(b,arguments)}},__hasProp=Object.prototype.hasOwnProperty,__extends=function(d,b){for(varainb){if(__hasProp.call(b,a)){d[a]=b[a]}}functionc(){this.constructor=d}c.prototype=b.prototype;d.prototype=newc;d.__super__=b.prototype;returnd};if(!this.Knockback){thrownewError("Knockback: Dependency alert! knockback_core.js must be included before this file")}AttributeConnector=(function(){functiona(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){vare;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;returnthis.model.set(e)}}},this));this._kb_observable.destroy=this.destroy;this._kb_observable.update=this.update;this.update(b);returnkb.wrappedObservable(this)}a.prototype.destroy=function(){this.model=null;returnthis._kb_observable=null};a.prototype.update=function(b){varc,d;if(b){d=b.get(this.key);c=(this.model!==b)||!_.isEqual(this._kb_observable(),d);this.model=b;if(c){returnthis._kb_observable(d)}}else{returnthis.model=null}};returna})();Knockback.ViewModel_RCBase=(function(){functiona(){this._kb_vm={};this._kb_vm.ref_count=1}a.extend=Backbone.Model.extend;a.prototype.__destroy=function(){returnkb.vmReleaseObservables(this)};a.prototype.retain=function(){if(this._kb_vm.ref_count<=0){thrownewError("ViewModel: ref_count is corrupt: "+this._kb_vm.ref_count)}this._kb_vm.ref_count++;returnthis};a.prototype.release=function(){if(this._kb_vm.ref_count<=0){thrownewError("ViewModel: ref_count is corrupt: "+this._kb_vm.ref_count)}this._kb_vm.ref_count--;if(!this._kb_vm.ref_count){this.__destroy()}returnthis};a.prototype.refCount=function(){returnthis._kb_vm.ref_count};returna})();Knockback.ViewModel=(function(){__extends(a,kb.ViewModel_RCBase);functiona(e,d,c){varg,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){thrownewError("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.modelinstanceofBackbone.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){returnthis}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(){varb;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){returnthis._kb_vm.observables=null}};a.prototype._kb_vm_onModelLoaded=function(c){vard,b;this._kb_vm.model=c;this._kb_vm.model.bind("change",this._kb_vm_onModelChange);b=[];for(dinthis._kb_vm.model.attributes){b.push(this._updateAttributeObservor(this._kb_vm.model,d))}returnb};a.prototype._kb_vm_onModelUnloaded=function(c){vard,b;this._kb_vm.model.unbind("change",this._kb_vm_onModelChange);c=this._kb_vm.model;this._kb_vm.model=null;b=[];for(dinc.attributes){b.push(this._updateAttributeObservor(this._kb_vm.model,d))}returnb};a.prototype._kb_vm_onModelChange=function(){vard,b,c;if(this._kb_vm.model._changed){b=[];for(dinthis._kb_vm.model.attributes){b.push((this._kb_vm.model.hasChanged(d)?this._updateAttributeObservor(this._kb_vm.model,d):void0))}returnb}else{if(this._kb_vm.model.changed){c=[];for(dinthis._kb_vm.model.changed){c.push(this._updateAttributeObservor(this._kb_vm.model,d))}returnc}}};a.prototype._updateAttributeObservor=function(b,d){varc;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]){returnthis._kb_vm.view_model[c].update(b)}}else{if(this._kb_vm.observables){this._kb_vm.observables.push(c)}returnthis._kb_vm.view_model[c]=newAttributeConnector(b,d,this._kb_vm.options.read_only)}};returna})();Knockback.viewModel=function(c,b,a){returnnewKnockback.ViewModel(c,b,a)};
\ No newline at end of file
varBackbone,Knockback,kb,ko,_;if(typeofexports!=="undefined"){Knockback=kb=exports}else{this.Knockback=this.kb={}}Knockback.VERSION="0.15.1";_=!this._&&(typeofrequire!=="undefined")?require("underscore"):this._;Backbone=!this.Backbone&&(typeofrequire!=="undefined")?require("backbone"):this.Backbone;ko=!this.ko&&(typeofrequire!=="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){varb;kb._legacy_warnings||(kb._legacy_warnings={});(b=kb._legacy_warnings)[a]||(b[a]=0);kb._legacy_warnings[a]++;returnconsole.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)){thrownewError("Knockback: instance is not wrapping an observable")}returna.__kb.observable}if(!a){thrownewError("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}returnb};Knockback.wrappedObservable=function(a){kb.utils.legacyWarning("kb.wrappedObservable","0.16.0","Please use kb.utils.wrappedObservable instead");returnkb.utils.wrappedObservable(a)};Knockback.utils.observableInstanceOf=function(b,a){if(!b){returnfalse}if(!(b.__kb&&b.__kb.instance)){returnfalse}returnb.__kb.instanceinstanceofa};Knockback.utils.wrappedModel=function(a,b){if(arguments.length===1){if(a&&a.__kb&&a.__kb.hasOwnProperty("model")){returna.__kb.model}else{returna}}if(!a){thrownewError("Knockback: no view_model for wrapping a model")}a.__kb||(a.__kb={});a.__kb.model=b;returnb};Knockback.viewModelGetModel=Knockback.vmModel=function(a){kb.utils.legacyWarning("kb.vmModel","0.16.0","Please use kb.utils.wrappedModel instead");returnkb.utils.wrappedModel(a)};Knockback.utils.setToDefault=function(d){varb,c,a;if(!d){return}if(ko.isObservable(d)){returntypeofd.setToDefault==="function"?d.setToDefault():void0}else{if(_.isObject(d)){a=[];for(bind){c=d[b];a.push(c&&(b!=="__kb")?kb.utils.setToDefault(c):void0)}returna}}};Knockback.vmSetToDefault=function(a){kb.utils.legacyWarning("kb.vmSetToDefault","0.16.0","Please use kb.utils.release instead");returnkb.utils.setToDefault(a)};Knockback.utils.release=function(c){vara,b;if(!c){returnfalse}if(ko.isObservable(c)||(cinstanceofkb.Observables)||(typeofc.release==="function")||(typeofc.destroy==="function")){if(c.release){c.release()}else{if(c.destroy){c.destroy()}else{if(c.dispose){c.dispose()}}}returntrue}else{if(_.isObject(c)&&!(typeofc==="function")){for(ainc){b=c[a];if(!b||(a==="__kb")){continue}if(kb.utils.release(b)){c[a]=null}}returntrue}}returnfalse};Knockback.vmRelease=function(a){kb.utils.legacyWarning("kb.vmRelease","0.16.0","Please use kb.utils.release instead");returnkb.utils.release(a)};Knockback.vmReleaseObservable=function(a){kb.utils.legacyWarning("kb.vmReleaseObservable","0.16.0","Please use kb.utils.release instead");returnkb.utils.release(a)};kb.utils.optionsCreateClear=function(a){deletea.create;deletea.children;deletea.view_model;returndeletea.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;functiona(){this.__kb||(this.__kb={});this.__kb.ref_count=1}a.prototype.__destroy=function(){};a.prototype.retain=function(){if(this.__kb.ref_count<=0){thrownewError("RefCountable: ref_count is corrupt: "+this.__kb.ref_count)}this.__kb.ref_count++;returnthis};a.prototype.release=function(){if(this.__kb.ref_count<=0){thrownewError("RefCountable: ref_count is corrupt: "+this.__kb.ref_count)}this.__kb.ref_count--;if(!this.__kb.ref_count){this.__destroy()}returnthis};a.prototype.refCount=function(){returnthis.__kb.ref_count};returna})();Knockback.Store=(function(){a.name="Store";functiona(){this.keys=[];this.values=[]}a.prototype.destroy=function(){varc,e,d,b;this.keys=null;d=this.values;for(cind){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(cinb){e=b[c];if(!e){continue}this.values[c]=null;if(einstanceofkb.RefCountable){while(e.refCount()>0){e.release()}}else{kb.utils.release(e)}}returnthis.values=null};a.prototype.registerValue=function(c,d){varb;if(dinstanceofkb.RefCountable){d.retain()}b=_.indexOf(this.keys,c);if(b>=0){this.values[b]=d}else{this.keys.push(c);this.values.push(d)}returnd};a.prototype.resolveValue=function(d,f,c){varb,e;b=_.indexOf(this.keys,d);if(b>=0){if(this.values[b]){if((this.values[b]instanceofkb.RefCountable)&&(this.values[b].refCount()<=0)){this.values[b]=null}else{if(this.values[b]instanceofkb.RefCountable){returnthis.values[b].retain()}else{returnthis.values[b]}}}}else{b=this.keys.length;this.keys.push(d);this.values.push(void0)}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(einstanceofkb.RefCountable){e.retain()}this.values[b]=e}}returne};a.prototype.releaseValue=function(c){varb;if(!(cinstanceofkb.RefCountable)){return}c.release();if(c.refCount()>0){return}b=_.indexOf(this.values,c);if(!(b>=0)){return}returnthis.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}returnb.store.registerValue(b.store_key,c)};returna})();var__hasProp={}.hasOwnProperty,__extends=function(d,b){for(varainb){if(__hasProp.call(b,a)){d[a]=b[a]}}functionc(){this.constructor=d}c.prototype=b.prototype;d.prototype=newc;d.__super__=b.prototype;returnd};Knockback.CollectionObservable=(function(b){__extends(a,b);a.name="CollectionObservable";functiona(f,c){vare,d,g=this;if(c==null){c={}}if(!f){thrownewError("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=newkb.Store();this.__kb.store_is_owned=true}if(c.hasOwnProperty("view_model")){if(!c.view_model){thrownewError("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){thrownewError("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){thrownewError("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){thrownewError("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(){returnkb.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});returnd}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){returnkb.stats.collection_observables--}};a.prototype.retain=function(){a.__super__.retain.apply(this,arguments);returnkb.utils.wrappedObservable(this)};a.prototype.release=function(){varc;c=kb.utils.wrappedObservable(this);a.__super__.release.apply(this,arguments);returnc};a.prototype.collection=function(g,c){varf,d,e;f=kb.utils.wrappedObservable(this);if(arguments.length===0){f();returnthis.__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);returnthis.sortedIndex(this.sorted_index,this.sort_attribute,c)}};a.prototype.sortedIndex=function(g,c,d){vare,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(){varh;h=kb.utils.wrappedObservable(f);if((f.__kb.collection.models.length===0)&&(h().length===0)){return}f._collectionResync(true);if(!d.silent){returnf.trigger("resort",h())}};if(d.defer){_.defer(e)}else{e()}returnthis};a.prototype.sortAttribute=function(d,e,c){returnthis.sortedIndex(e,d,c)};a.prototype.viewModelByModel=function(d){varc,e;if(!this.hasViewModels()){returnnull}e=kb.utils.wrappedObservable(this);c=d.hasOwnProperty(d.idAttribute)?d.idAttribute:"cid";return_.find(e(),function(f){returnf.__kb.model[c]===d[c]})};a.prototype.hasViewModels=function(){return!!this.view_model_create_fn};a.prototype._collectionBind=function(j){varg,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)}returnj.bind("change",this.__kb._onModelChange)};a.prototype._collectionUnbind=function(j){varg,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)}returnj.unbind("change",this.__kb._onModelChange)};a.prototype._onCollectionReset=function(){returnthis._collectionResync()};a.prototype._onCollectionResort=function(d){varc;if(this.sorted_index){thrownewError("CollectionObservable: collection sorted_index unexpected")}if(_.isArray(d)){c=kb.utils.wrappedObservable(this);returnthis.trigger("resort",c())}else{returnthis._onModelResort(d)}};a.prototype._onModelAdd=function(d){varc,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);returnthis.trigger("add",e,f())};a.prototype._onModelRemove=function(c){vare,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()){returnthis.__kb.store.releaseValue(d)}};a.prototype._onModelChange=function(c){if(this.sorted_index&&(!this.sort_attribute||c.hasChanged(this.sort_attribute))){returnthis._onModelResort(c)}};a.prototype._onModelResort=function(d){varc,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);returnthis.trigger("resort",e,g(),c)};a.prototype._clear=function(f){vari,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))}returnc}};a.prototype._collectionResync=function(k){vard,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){returnh._createTarget(m)}):_.clone(this.__kb.collection.models)}c(i);if(!k){returnthis.trigger("add",c())}};a.prototype._sortAttributeFn=function(c){if(this.hasViewModels()){returnfunction(e,d){return_.sortedIndex(e,d,function(f){returnkb.utils.wrappedModel(f).get(c)})}}else{returnfunction(e,d){return_.sortedIndex(e,d,function(f){returnf.get(c)})}}};a.prototype._createTarget=function(c){vare,d=this;e=function(){varh,g,f;g=d.__kb.store.addResolverToOptions({},c);h=kb.utils.wrappedObservable(d);f=d.view_model_create_with_new?newd.view_model_create_fn(c,g,h):d.view_model_create_fn(c,g,h);kb.utils.wrappedModel(f,c);returnf};if(this.hasViewModels()){returnthis.__kb.store.resolveValue(c,e)}else{returnc}};returna})(kb.RefCountable);__extends(Knockback.CollectionObservable.prototype,Backbone.Events);Knockback.collectionObservable=function(c,b,a){returnnewKnockback.CollectionObservable(c,b,a)};Knockback.sortedIndexWrapAttr=Knockback.siwa=function(a,b){returnfunction(d,c){return_.sortedIndex(d,c,function(e){returnnewb(kb.utils.wrappedModel(e).get(a))})}};if(!this.Knockback){thrownewError("Knockback: Dependency alert! knockback_core.js must be included before this file")}Knockback.DefaultWrapper=(function(){a.name="DefaultWrapper";functiona(b,e){varc,d=this;this.default_value_observable=e;this.__kb={};c=kb.utils.wrappedObservable(this,ko.dependentObservable({read:function(){varg,f;f=ko.utils.unwrapObservable(b());g=ko.utils.unwrapObservable(d.default_value_observable);if(!f){returng}else{returnf}},write:function(f){returnb(f)}}));c.destroy=_.bind(this.destroy,this);c.setToDefault=_.bind(this.setToDefault,this);returnc}a.prototype.destroy=function(){kb.utils.wrappedObservable(this,null);returnthis.default_value=null};a.prototype.setToDefault=function(){varb;b=kb.utils.wrappedObservable(this);returnb(this.default_value_observable)};returna})();Knockback.defaultWrapper=function(b,a){returnnewKnockback.DefaultWrapper(b,a)};Knockback.toFormattedString=function(g){varb,e,d,c,a,f;a=g.slice();e=Array.prototype.slice.call(arguments,1);for(dine){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)}}returna};Knockback.parseFormattedString=function(h,m){vari,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=newRegExp(b);g=l.exec(h);if(g){g.shift()}if(!g||(g.length!==p)){return_.map((function(){c=[];for(varq=1;1<=i?q<=i:q>=i;1<=i?q++:q--){c.push(q)}returnc}).apply(this),function(){return""})}n=_.sortBy(_.keys(f),function(q,r){returnparseInt(q,10)});a={};for(kinn){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++}returne};Knockback.FormattedObservable=(function(){a.name="FormattedObservable";functiona(e,c){vard,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(){varf,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))}returnkb.toFormattedString.apply(null,c)},write:function(i){varg,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++)}returnf}}));returnd}a.prototype.destroy=function(){returnkb.utils.wrappedObservable(this,null)};returna})();Knockback.formattedObservable=function(b,a){returnnewKnockback.FormattedObservable(b,Array.prototype.slice.call(arguments,1))};Knockback.LocalizedObservable=(function(){a.name="LocalizedObservable";a.extend=Backbone.Model.extend;functiona(d,c,b){vare;this.value=d;this.options=c!=null?c:{};this.view_model=b!=null?b:{};if(!(this.options.read||this.read)){thrownewError("LocalizedObservable: options.read is missing")}if(this.options.read&&this.read){thrownewError("LocalizedObservable: options.read and read class function exist. You need to choose one.")}if(this.options.write&&this.write){thrownewError("LocalizedObservable: options.write and write class function exist. You need to choose one.")}if(!kb.locale_manager){thrownewError("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&&!(typeofthis.write==="function")){thrownewError("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(){thrownewError("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);returne}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;returnthis.__kb=null};a.prototype.setToDefault=function(){varc,b;if(!this["default"]){return}b=this._getDefaultValue();c=this.__kb.value_observable();if(c!==b){returnthis._onSetValue(b)}else{returnthis.__kb.value_observable.valueHasMutated()}};a.prototype.resetToCurrent=function(){this.__kb.value_observable(null);returnthis._onSetValue(this._getCurrentValue())};a.prototype.observedValue=function(b){if(arguments.length===0){returnthis.value}this.value=b;this._onLocaleChange();returnthis};a.prototype._getDefaultValue=function(){if(!this["default"]){return""}if(typeofthis["default"]==="function"){returnthis["default"]()}else{returnthis["default"]}};a.prototype._getCurrentValue=function(){varb;b=kb.utils.wrappedObservable(this);if(!(this.value&&b)){returnthis._getDefaultValue()}returnthis.read.call(this,ko.utils.unwrapObservable(this.value))};a.prototype._onGetValue=function(){if(this.value){ko.utils.unwrapObservable(this.value)}returnthis.__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){returnthis.options.onChange(b)}};a.prototype._onLocaleChange=function(){varb;b=this.read.call(this,ko.utils.unwrapObservable(this.value));this.__kb.value_observable(b);if(this.options.onChange){returnthis.options.onChange(b)}};returna})();Knockback.localizedObservable=function(c,b,a){returnnewKnockback.LocalizedObservable(c,b,a)};Knockback.Observable=(function(){a.name="Observable";functiona(c,d,b){vare,f=this;this.model=c;this.mapping_info=d;this.view_model=b!=null?b:{};if(!this.model){thrownewError("Observable: model is missing")}if(!this.mapping_info){thrownewError("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){thrownewError("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.modelinstanceofBackbone.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=newthis.mapping_info.localizer(this._getCurrentValue())}e=kb.utils.wrappedObservable(this,ko.dependentObservable({read:_.bind(this._onGetValue,this),write:this.mapping_info.read_only?(function(){thrownewError("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)}returne}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;returnthis.__kb=null};a.prototype.setToDefault=function(){varb;b=this._getDefaultValue();if(this.__kb.localizer){this.__kb.localizer.observedValue(b);b=this.__kb.localizer()}returnthis.__kb.value_observable(b)};a.prototype._getDefaultValue=function(){if(!this.mapping_info.hasOwnProperty("default")){return""}if(typeofthis.mapping_info["default"]==="function"){returnthis.mapping_info["default"]()}else{returnthis.mapping_info["default"]}};a.prototype._getCurrentValue=function(){varb,d,e,g,c,f;if(!this.model){returnthis._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){returnthis.mapping_info.read.apply(this.view_model,d)}else{returnthis.model.get.apply(this.model,d)}};a.prototype._onGetValue=function(){varb,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()}returnf};a.prototype._onSetValue=function(h){varb,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=typeofthis.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(typeofthis.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){returnthis.__kb.value_observable(this.__kb.localizer())}else{returnthis.__kb.value_observable(h)}};a.prototype._modelBind=function(b){if(!b){return}b.bind("change",this.__kb._onModelChange);if(Backbone.RelationalModel&&(binstanceofBackbone.RelationalModel)){b.bind("add",this.__kb._onModelChange);b.bind("remove",this.__kb._onModelChange);returnb.bind("update",this.__kb._onModelChange)}};a.prototype._modelUnbind=function(b){if(!b){return}b.unbind("change",this.__kb._onModelChange);if(Backbone.RelationalModel&&(binstanceofBackbone.RelationalModel)){b.unbind("add",this.__kb._onModelChange);b.unbind("remove",this.__kb._onModelChange);returnb.unbind("update",this.__kb._onModelChange)}};a.prototype._onModelLoaded=function(b){this.model=b;this._modelBind(b);returnthis._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);returnthis.model=null};a.prototype._onModelChange=function(){if((this.model&&this.model.hasChanged)&&!this.model.hasChanged(ko.utils.unwrapObservable(this.mapping_info.key))){return}returnthis._updateValue()};a.prototype._updateValue=function(){varb;b=this._getCurrentValue();if(this.__kb.localizer){this.__kb.localizer.observedValue(b);b=this.__kb.localizer()}returnthis.__kb.value_observable(b)};returna})();Knockback.observable=function(b,c,a){returnnewKnockback.Observable(b,c,a)};Knockback.Observables=(function(){a.name="Observables";functiona(e,g,k,j){varh,i,f,c,d,b;if(!e){thrownewError("Observables: model is missing")}if(!g||!_.isObject(g)){thrownewError("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;deletej.write}if(!_.isUndefined(j)){c=_.isBoolean(j)?j:j.read_only;d=this.__kb.mappings_info;for(find){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(finb){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(){varc,b,d;d=this.__kb.mappings_info;for(bind){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;returnthis.__kb.model=null};a.prototype.setToDefault=function(){vard,b,e,c;e=this.__kb.mappings_info;c=[];for(bine){d=e[b];c.push(this.__kb.view_model[b].setToDefault())}returnc};returna})();Knockback.observables=function(c,d,a,b){returnnewKnockback.Observables(c,d,a,b)};Knockback.TriggeredObservable=(function(){a.name="TriggeredObservable";functiona(b,d){varc;this.model=b;this.event_name=d;if(!this.model){thrownewError("Observable: model is missing")}if(!this.event_name){thrownewError("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.modelinstanceofBackbone.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)}returnc}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;returnthis.__kb=null};a.prototype._onGetValue=function(){returnthis.__kb.value_observable()};a.prototype._onModelLoaded=function(b){this.model=b;this.model.bind(this.event_name,this.__kb._onValueChange);returnthis._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);returnthis.model=null};a.prototype._onValueChange=function(){varb;b=this.__kb.value_observable();if(b!==this.model){returnthis.__kb.value_observable(this.model)}else{returnthis.__kb.value_observable.valueHasMutated()}};returna})();Knockback.triggeredObservable=function(a,b){returnnewKnockback.TriggeredObservable(a,b)};var__hasProp={}.hasOwnProperty,__extends=function(d,b){for(varainb){if(__hasProp.call(b,a)){d[a]=b[a]}}functionc(){this.constructor=d}c.prototype=b.prototype;d.prototype=newc;d.__super__=b.prototype;returnd};Knockback.AttributeConnector=(function(){a.name="AttributeConnector";functiona(c,d,b){vare;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;returne}a.prototype.destroy=function(){this.__kb.value_observable=null;kb.utils.wrappedObservable(this).dispose();returnkb.utils.wrappedObservable(this,null)};a.prototype.read=function(){returnthis.__kb.value_observable()};a.prototype.write=function(d){varc,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;returnc.set(b)}};a.prototype.model=function(b){varc;c=kb.utils.wrappedModel(this);if(arguments.length===0){returnc}if(c===b){return}kb.utils.wrappedModel(this,b);returnthis.update()};a.inferType=function(b,c){vard,e;e=b.get(c);if(!e){if(!(Backbone.RelationalModel&&(binstanceofBackbone.RelationalModel))){return"simple"}d=_.find(b.getRelations(),function(f){returnf.key===c});if(!d){return"simple"}if(d.collectionKey){return"collection"}else{return"model"}}if(einstanceofBackbone.Collection){return"collection"}if((einstanceofBackbone.Model)||(Backbone.ModelRef&&(einstanceofBackbone.ModelRef))){return"model"}return"simple"};a.createByType=function(e,c,d,b){varf;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))}returnkb.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))}returnkb.viewModelAttributeConnector(c,d,f);default:returnkb.simpleAttributeConnector(c,d,b)}};a.createOrUpdate=function(f,c,d,b){varg,e;if(f){if(kb.utils.observableInstanceOf(f,kb.AttributeConnector)){if(f.model()!==c){f.model(c)}else{f.update()}}returnf}if(!c){returnkb.simpleAttributeConnector(c,d,b)}if(b.hasOwnProperty("create")){if(!b.create){thrownewError("Knockback.AttributeConnector: options.create is empty")}returnb.create(c,d,b.options||{})}e=c.get(d);if(b.hasOwnProperty("view_model")){if(!b.view_model){thrownewError("Knockback.AttributeConnector: options.view_model is empty")}returnnewb.view_model(e,b.options||{})}else{if(b.hasOwnProperty("view_model_create")){if(!b.view_model_create){thrownewError("Knockback.AttributeConnector: options.view_model_create is empty")}returnb.view_model_create(e,b.options||{})}else{if(b.hasOwnProperty("children")){if(!b.children){thrownewError("Knockback.AttributeConnector: options.children is empty")}if(typeofb.children==="function"){g={view_model:b.children}}else{g=b.children||{}}returnkb.collectionAttributeConnector(c,d,g)}}}returnthis.createByType(this.inferType(c,d),c,d,b)};returna})();Knockback.SimpleAttributeConnector=(function(b){__extends(a,b);a.name="SimpleAttributeConnector";functiona(){a.__super__.constructor.apply(this,arguments);returnkb.utils.wrappedObservable(this)}a.prototype.destroy=function(){this.current_value=null;returna.__super__.destroy.apply(this,arguments)};a.prototype.update=function(){vard,c,e;c=kb.utils.wrappedModel(this);if(!c){return}e=c.get(this.key);d=this.__kb.value_observable();if(!_.isEqual(d,e)){returnthis.__kb.value_observable(e)}};a.prototype.write=function(d){varc;c=kb.utils.wrappedModel(this);if(!c){this.__kb.value_observable(d);return}returna.__super__.write.apply(this,arguments)};returna})(Knockback.AttributeConnector);Knockback.simpleAttributeConnector=function(b,c,a){returnnewKnockback.SimpleAttributeConnector(b,c,a)};Knockback.CollectionAttributeConnector=(function(a){__extends(b,a);b.name="CollectionAttributeConnector";functionb(){b.__super__.constructor.apply(this,arguments);returnkb.utils.wrappedObservable(this)}b.prototype.destroy=function(){varc;c=this.__kb.value_observable();if(c&&(typeofc.refCount==="function")&&(c.refCount()>0)){c.release()}returnb.__super__.destroy.apply(this,arguments)};b.prototype.update=function(){vard,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){returnthis.__kb.value_observable(this.options.store.resolveValue(e,function(){returnkb.collectionObservable(e,f.options)}))}else{returnthis.__kb.value_observable(kb.collectionObservable(e,this.options))}}else{if(d.collection()!==e){d.collection(e);returnthis.__kb.value_observable.valueHasMutated()}}};b.prototype.read=function(){varc;c=this.__kb.value_observable();if(c){returnc()}else{return}};returnb})(Knockback.AttributeConnector);Knockback.collectionAttributeConnector=function(b,c,a){returnnewKnockback.CollectionAttributeConnector(b,c,a)};Knockback.ViewModelAttributeConnector=(function(b){__extends(a,b);a.name="ViewModelAttributeConnector";functiona(){a.__super__.constructor.apply(this,arguments);returnkb.utils.wrappedObservable(this)}a.prototype.destroy=function(){varc;c=this.__kb.value_observable();if(c&&(typeofc.refCount==="function")&&(c.refCount()>0)){c.release()}returna.__super__.destroy.apply(this,arguments)};a.prototype.update=function(){vard,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){returnthis.__kb.value_observable(f.store.resolveValue(e,function(){if(g.options.view_model){returnnewg.options.view_model(e,f)}else{returng.options.view_model_create(e,f)}}))}else{returnthis.__kb.value_observable(this.options.view_model?newthis.options.view_model(e,f):this.options.view_model_create(e,f))}}else{if(!(d.model&&(typeofd.model==="function"))){thrownewError("Knockback.viewModelAttributeConnector: unknown how to model a view model")}if(d.model()!==e){d.model(e);returnthis.__kb.value_observable.valueHasMutated()}}};returna})(Knockback.AttributeConnector);Knockback.viewModelAttributeConnector=function(b,c,a){returnnewKnockback.ViewModelAttributeConnector(b,c,a)};var__hasProp={}.hasOwnProperty,__extends=function(d,b){for(varainb){if(__hasProp.call(b,a)){d[a]=b[a]}}functionc(){this.constructor=d}c.prototype=b.prototype;d.prototype=newc;d.__super__=b.prototype;returnd};Knockback.ViewModel_RCBase=(function(b){__extends(a,b);a.name="ViewModel_RCBase";functiona(){returna.__super__.constructor.apply(this,arguments)}a.prototype.__destroy=function(){vard,e,c;c=[];for(dinthis){e=this[d];if(!e||(d==="__kb")){continue}if(kb.utils.release(e)){c.push(this[d]=null)}else{c.push(void0)}}returnc};returna})(Knockback.RefCountable);Knockback.ViewModel=(function(b){__extends(a,b);a.name="ViewModel";functiona(e,d){varg,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=newkb.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&&(einstanceofBackbone.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){returnthis}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(){varc;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){returnkb.stats.view_models--}};a.prototype.model=function(c){vard;d=kb.utils.wrappedModel(this);if(arguments.length===0){returnd}if(c===d){return}if(d){this._onModelUnloaded(d)}if(c){returnthis._onModelLoaded(c)}};a.prototype._modelBind=function(c){if(!c){return}c.bind("change",this.__kb._onModelChange);if(Backbone.RelationalModel&&(cinstanceofBackbone.RelationalModel)){c.bind("add",this.__kb._onModelChange);c.bind("remove",this.__kb._onModelChange);returnc.bind("update",this.__kb._onModelChange)}};a.prototype._modelUnbind=function(c){if(!c){return}c.unbind("change",this.__kb._onModelChange);if(Backbone.RelationalModel&&(cinstanceofBackbone.RelationalModel)){c.unbind("add",this.__kb._onModelChange);c.unbind("remove",this.__kb._onModelChange);returnc.unbind("update",this.__kb._onModelChange)}};a.prototype._onModelLoaded=function(d){vare,c;kb.utils.wrappedModel(this,d);this._modelBind(d);c=[];for(einthis.__kb.model.attributes){c.push(this._updateAttributeConnector(this.__kb.model,e))}returnc};a.prototype._onModelUnloaded=function(d){vare,c;this._modelUnbind(d);kb.utils.wrappedModel(this,null);c=[];for(eind.attributes){c.push(this._updateAttributeConnector(null,e))}returnc};a.prototype._onModelChange=function(){vare,c,d;if(this.__kb.model._changed){c=[];for(einthis.__kb.model.attributes){c.push(this.__kb.model.hasChanged(e)?this._updateAttributeConnector(this.__kb.model,e):void0)}returnc}else{if(this.__kb.model.changed){d=[];for(einthis.__kb.model.changed){d.push(this._updateAttributeConnector(this.__kb.model,e))}returnd}}};a.prototype._updateAttributeConnector=function(c,e){vard;d=this.__kb.internals&&_.contains(this.__kb.internals,e)?"_"+e:e;returnthis[d]=kb.AttributeConnector.createOrUpdate(this[d],c,e,this._createOptions(e))};a.prototype._createOptions=function(d){varc;if(this.__kb.children){if(this.__kb.children.hasOwnProperty(d)){c=this.__kb.children[d];if(typeofc==="function"){c={view_model:c}}c.options={read_only:this.__kb.read_only,store:this.__kb.store};returnc}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}};returna})(Knockback.ViewModel_RCBase);Knockback.viewModel=function(b,a){returnnewKnockback.ViewModel(b,a)};
ga:function(a){returnr.a.fb(a,document)},s:function(e,b,f){if("undefined"!=typeofjQuery){if(a(e,b))vard=f,f=function(a,e){varb=this.checked;if(e)this.checked=e.Ya!==m;d.call(this,a);this.checked=b};jQuery(e).bind(b,f)}else"function"==typeofe.addEventListener?e.addEventListener(b,f,p):"undefined"!=typeofe.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"!=typeofjQuery){vard=[];a(b,f)&&d.push({Ya:b.checked});jQuery(b).trigger(f,d)}elseif("function"==typeofdocument.createEvent)"function"==typeofb.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"));elseif("undefined"!=typeofb.fireEvent){if("click"==f&&"INPUT"==b.tagName&&("checkbox"==b.type.toLowerCase()||"radio"==b.type.toLowerCase()))b.checked=
b.checked!==m;b.fireEvent("on"+f)}elsec(Error("Browser doesn't support triggering events"))},d:function(a){returnr.V(a)?a():a},eb:function(a,e){return0<=r.a.k((a.className||"").split(/\s+/),e)},Qa:function(a,e,b){varf=r.a.eb(a,e);if(b&&!f)a.className=(a.className||"")+""+e;elseif(f&&!b){for(varb=(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){vare=a.outerHTML;if("string"==typeofe)returne}e=window.document.createElement("div");
e}:function(a){returne.test(a.name)},d=[],h=b.length-1;0<=h;h--)f(b[h])&&d.push(b[h]);returnd},vb:function(a){return"string"==typeofa&&(a=r.a.z(a))?window.JSON&&window.JSON.parse?window.JSON.parse(a):(newFunction("return "+a))():o},qa:function(a){("undefined"==typeofJSON||"undefined"==typeofJSON.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"));
r.a.A=newfunction(){functiona(a,b){varh=r.a.e.get(a,d);h===l&&b&&(h=[],r.a.e.set(a,d,h));returnh}functionb(e){varb=a(e,p);if(b)for(varb=b.slice(0),d=0;d<b.length;d++)b[d](e);r.a.e.clear(e);"function"==typeofjQuery&&"function"==typeofjQuery.cleanData&&jQuery.cleanData([e])}vard="__ko_domNodeDisposal__"+(newDate).getTime();return{va:function(e,b){"function"!=typeofb&&c(Error("Callback must be a function"));a(e,m).push(b)},Ia:function(e,b){varh=a(e,p);h&&(r.a.ca(h,b),0==h.length&&r.a.e.set(e,
r.r=function(){functiona(){return(4294967296*(1+Math.random())|0).toString(16).substring(1)}functionb(a,f){if(a)if(8==a.nodeType){vard=r.r.Ga(a.nodeValue);d!=o&&f.push({cb:a,tb:d})}elseif(1==a.nodeType)for(vard=0,g=a.childNodes,i=g.length;d<i;d++)b(g[d],f)}vard={};return{ka:function(b){"function"!=typeofb&&c(Error("You can only pass a function to ko.memoization.memoize()"));varf=a()+a();d[f]=b;return"<\!--[ko_memo:"+f+"]--\>"},Ra:function(a,b){varh=d[a];h===l&&c(Error("Couldn't find any memo with ID "+
a+". Perhaps it's already been unmemoized."));try{returnh.apply(o,b||[]),m}finally{deleted[a]}},Sa:function(a,f){vard=[];b(a,d);for(varg=0,i=d.length;g<i;g++){varj=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.Ea=function(a){return"function"==typeofa.ra&&"function"==typeofa.notifySubscribers};r.b("ko.subscribable",r.R);r.b("ko.isSubscribable",r.Ea);r.T=function(){vara=[];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){vard=a[a.length-1];0<=r.a.k(d.za,b)||(d.za.push(b),d.da(b))}}}}();varB={undefined:m,"boolean":m,number:m,string:m};
r.Q=function(a){0==arguments.length&&(a=[]);a!==o&&a!==l&&!("length"ina)&&c(Error("The argument passed when initializing an observable array must be an array, or null, or undefined."));varb=newr.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);returnb};
r.a.n(["slice"],function(a){r.Q.fn[a]=function(){varb=this();returnb[a].apply(b,arguments)}});r.b("ko.observableArray",r.Q);functionC(a,b){a&&"object"==typeofa?b=a:(b=b||{},b.read=a||b.read);"function"!=typeofb.read&&c("Pass a function that returns the value of the dependentObservable");returnb}
r.i=function(a,b,d){functione(){r.a.n(q,function(a){a.v()});q=[]}functionf(){vara=g.throttleEvaluation;a&&0<=a?(clearTimeout(v),v=setTimeout(h,a)):h()}functionh(){if(j&&"function"==typeofd.disposeWhen&&d.disposeWhen())g.v();else{try{e();r.T.Xa(function(a){q.push(a.ra(f))});vara=d.read.call(d.owner||b);g.notifySubscribers(i,"beforeChange");i=a}finally{r.T.end()}g.notifySubscribers(i);j=m}}functiong(){if(0<arguments.length)"function"===typeofd.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.");
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);return0<=d?b[d]:l}}r.Pa=function(b){0==arguments.length&&c(Error("When calling ko.toJS, pass the object you want to convert."));returna(b,function(a){for(varb=0;r.V(a)&&10>b;b++)a=a();returna})};r.toJSON=function(a){a=r.Pa(a);returnr.a.qa(a)}})();r.b("ko.toJS",r.Pa);r.b("ko.toJSON",r.toJSON);
(function(){functiona(a){return8==a.nodeType&&(f?a.text:a.nodeValue).match(h)}functionb(a){return8==a.nodeType&&(f?a.text:a.nodeValue).match(g)}functiond(e,d){for(varf=e,g=1,h=[];f=f.nextSibling;){if(b(f)&&(g--,0===g))returnh;h.push(f);a(f)&&g++}d||c(Error("Cannot find closing comment tag to match: "+e.nodeValue));returno}functione(a,b){vare=d(a,b);returne?0<e.length?e[e.length-1].nextSibling:a.nextSibling:o}varf="<\!--test--\>"===document.createComment("test").text,h=f?/^<\!--\s*ko\s+(.*\:.*)\s*--\>$/:
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"==typeofw.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(sinn)(w=r.c[s])&&"function"==typeofw.update&&(0,w.update)(a,i(s),j,v,q)}},o,{disposeWhenNodeIsRemoved:a});
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){case1:case8:varb=r.Na(a);if(b)returnb;if(a.parentNode)returnr.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.c.submit={init:function(a,b,d,e){"function"!=typeofb()&&c(Error("The value for a submit binding must be a function"));r.a.s(a,"submit",function(d){varh,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){vard=r.a.d(b()),e="none"!=a.style.display;if(d&&!e)a.style.display="";elseif(!d&&e)a.style.display="none"}};
r.c.options={update:function(a,b,d){"SELECT"!=a.tagName&&c(Error("options binding applies only to SELECT elements"));vare=0==a.length,f=r.a.ba(r.a.aa(a.childNodes,function(a){returna.tagName&&"OPTION"==a.tagName&&a.selected}),function(a){returnr.h.q(a)||a.innerText||a.textContent}),h=a.scrollTop;a.scrollTop=0;for(varg=r.a.d(b());0<a.length;)r.F(a.options[0]),a.remove(0);if(g){d=d();"number"!=typeofg.length&&(g=[g]);if(d.optionsCaption){vari=document.createElement("OPTION");r.a.Z(i,d.optionsCaption);
r.c.selectedOptions={Da:function(a){for(varb=[],a=a.childNodes,d=0,e=a.length;d<e;d++){varf=a[d];"OPTION"==f.tagName&&f.selected&&b.push(r.h.q(f))}returnb},init:function(a,b,d){r.a.s(a,"change",function(){vara=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"));vard=r.a.d(b());if(d&&
r.$=function(){functiona(a,b,d){for(vara=r.j.Y(a),g=r.j.D,i=0;i<a.length;i++){varj=a[i].key;if(g.hasOwnProperty(j)){vark=g[j];"function"===typeofk?(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)+" } })() })";returnd.createJavaScriptEvaluatorBlock(a)+b}varb=/(<[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){returnr.$.ub(a,b)})},ub:function(e,f){returne.replace(b,function(b,e,d,j,k,n,t){returna(t,e,f)}).replace(d,function(b,e){returna(e,"<\!-- ko --\>",f)})},Ua:function(a){returnr.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};
(function(){functiona(a,b,d){for(varg=0;node=a[g];g++)node.parentNode===b&&(1===node.nodeType||8===node.nodeType)&&d(node)}functionb(a,b,h,g,i){vari=i||{},j=i.templateEngine||d;r.$.gb(h,j);h=j.renderTemplate(h,g,i);("number"!=typeofh.length||0<h.length&&"number"!=typeofh[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));returnh}vard;r.pa=function(a){a!=l&&!(ainstanceofr.t)&&c("templateEngine must inherit from ko.templateEngine");d=a};r.ua=function(b,d){varh=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){varj=g.nodeType?g:0<g.length?g[0]:o;returnnewr.i(function(){vard=
"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);
(function(){r.ja=function(){vara=this.qb=function(){if("undefined"==typeofjQuery||!jQuery.tmpl)return0;try{if(0<=jQuery.tmpl.tag.tmpl.open.toString().indexOf("__"))return2}catch(a){}return1}();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."));varh=d.data("precompiled");h||(h=d.text()||"",h=jQuery.template(o,"{{ko_with $item.koBindingContext}}"+h+"{{/ko_with}}"),d.data("precompiled",h));
n:function(a,c,e){varf=i&&k[c];if(!f&&"undefined"!=typeofjQuery){if(b(a,c))varg=e,e=function(a,b){varc=this.checked;b&&(this.checked=b.fb!==p);g.call(this,a);this.checked=c};jQuery(a).bind(c,e)}else!f&&"function"==typeofa.addEventListener?a.addEventListener(c,e,t):"undefined"!=typeofa.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"!=typeofjQuery){vare=[];b(a,c)&&e.push({fb:a.checked});jQuery(a).trigger(c,e)}else"function"==typeofdocument.createEvent?"function"==typeofa.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"!=typeofa.fireEvent?(b(a,c)&&(a.checked=a.checked!==p),a.fireEvent("on"+c)):m(Error("Browser doesn't support triggering events"))},d:function(b){returna.la(b)?
e,c){("undefined"==typeofJSON||"undefined"==typeofJSON.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"));returnJSON.stringify(a.a.d(b),e,c)},Cb:function(b,e,c){varc=c||{},f=c.params||{},g=c.includeFields||this.Ca,d=b;if("object"==typeofb&&"form"===a.a.o(b))for(vard=b.action,h=g.length-1;0<=h;h--)for(vark=a.a.Da(b,g[h]),
jQuery.cleanData([e]);if(g[e.nodeType])for(f=e.firstChild;e=f;)f=e.nextSibling,8===e.nodeType&&c(e)}vard="__ko_domNodeDisposal__"+(newDate).getTime(),f={1:p,8:p,9:p},g={1:p,9:p};return{wa:function(a,c){"function"!=typeofc&&m(Error("Callback must be a function"));b(a,p).push(c)},Ma:function(c,f){varg=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])){vard=[];a.a.N(d,b.getElementsByTagName("*"));for(varb=0,j=d.length;b<j;b++)c(d[b])}},
j;e++)c(d[e],g)}vard={};return{na:function(a){"function"!=typeofa&&m(Error("You can only pass a function to ko.memoization.memoize()"));varc=b()+b();d[c]=a;return"<\!--[ko_memo:"+c+"]--\>"},Va:function(a,b){varc=d[a];c===n&&m(Error("Couldn't find any memo with ID "+a+". Perhaps it's already been unmemoized."));try{returnc.apply(s,b||[]),p}finally{deleted[a]}},Wa:function(b,d){vare=[];c(b,e);for(varh=0,j=e.length;h<j;h++){vark=e[h].jb,i=[k];d&&a.a.N(i,d);a.s.Va(e[h].yb,i);k.nodeValue="";k.parentNode&&
end:function(){b.pop()},La:function(c){a.Ga(c)||m(Error("Only subscribable things can act as dependencies"));if(0<b.length){vard=b[b.length-1];0<=a.a.j(d.Aa,c)||(d.Aa.push(c),d.ca(c))}}}}();varG={undefined:p,"boolean":p,number:p,string:p};a.m=function(b){functionc(){if(0<arguments.length){if(!c.equalityComparer||!c.equalityComparer(d,arguments[0]))c.I(),d=arguments[0],c.H();returnthis}a.U.La(c);returnd}vard=b;a.R.call(c);c.H=function(){c.notifySubscribers(d)};c.I=function(){c.notifySubscribers(d,
a.Ha);a.Q=function(b){0==arguments.length&&(b=[]);b!==s&&(b!==n&&!("length"inb))&&m(Error("The argument passed when initializing an observable array must be an array, or null, or undefined."));varc=a.m(b);a.a.extend(c,a.Q.fn);returnc};a.Q.fn={remove:function(a){for(varc=this(),d=[],f="function"==typeofa?a:function(c){returnc===a},g=0;g<c.length;g++){vare=c[g];f(e)&&(0===d.length&&this.I(),d.push(e),c.splice(g,1),g--)}d.length&&this.H();returnd},removeAll:function(b){if(b===n){varc=this(),
p;try{varb=a.a.T(v,function(a){returna.target});a.U.bb(function(c){vare;0<=(e=a.a.j(b,c))?b[e]=n:v.push(c.ta(g))});for(vare=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}}functionh(){if(0<arguments.length)j.apply(h,arguments);elsereturni||e(),a.U.La(h),k}functionj(){"function"===typeofo?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."))}
vark,i=t,l=t,q=b;q&&"object"==typeofq?(d=q,q=d.read):(d=d||{},q||(q=d.read));"function"!=typeofq&&m(Error("Pass a function that returns the value of the ko.computed"));varo=d.write;c||(c=d.owner);varv=[],u=f,r="object"==typeofd.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);vary=w,w=function(){return!a.a.fa(r)||y()}}varx=s;h.nb=function(){returnv.length};h.pb="function"===typeofd.write;h.A=function(){u()};
d;break;case"object":case"undefined":vari=e.get(d);h[c]=i!==n?i:b(d,g,e)}});returnh}functionc(a,b){if(ainstanceofArray){for(varc=0;c<a.length;c++)b(c);"function"==typeofa.toJSON&&b("toJSON")}elsefor(cina)b(c)}functiond(){varb=[],c=[];this.save=function(e,d){varj=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);return0<=e?c[e]:n}}a.Ta=function(c){0==arguments.length&&m(Error("When calling ko.toJS, pass the object you want to convert."));returnb(c,function(b){for(varc=
a.g.ka);(function(){functionb(a){return8==a.nodeType&&(g?a.text:a.nodeValue).match(e)}functionc(a){return8==a.nodeType&&(g?a.text:a.nodeValue).match(h)}functiond(a,e){for(vard=a,f=1,g=[];d=d.nextSibling;){if(c(d)&&(f--,0===f))returng;g.push(d);b(d)&&f++}e||m(Error("Cannot find closing comment tag to match: "+a.nodeValue));returns}functionf(a,b){varc=d(a,b);returnc?0<c.length?c[c.length-1].nextSibling:a.nextSibling:s}varg="<\!--test--\>"===document.createComment("test").text,e=g?/^<\!--\s*ko\s+(.*\:.*)\s*--\>$/:
typeofc?c():c)||a.J.instance.getBindings(b,o)){if(0===i){i=1;for(varuinl){varr=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"==typeofr.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(uinl)(r=a.c[u])&&"function"==
"__ko_bindingContext__",c);elsereturna.a.f.get(b,"__ko_bindingContext__")};a.ya=function(b,c,e){1===b.nodeType&&a.e.Ia(b);returnd(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){case1:case8:varc=a.Ra(b);if(c)returnc;if(b.parentNode)returna.ea(b.parentNode)}};
d();try{varq=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"!=typeofc()&&m(Error("The value for a submit binding must be a function"));a.a.n(b,"submit",function(a){vare,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){vard=
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(varf=0==b.length,g=a.a.T(a.a.aa(b.childNodes,function(b){returnb.tagName&&"option"===a.a.o(b)&&b.selected}),function(b){returna.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"!=typeofh.length&&(h=[h]);if(d.optionsCaption){varj=document.createElement("option");a.a.Y(j,
a.c.options.oa="__ko.optionValueDomData__";a.c.selectedOptions={Ea:function(b){for(varc=[],b=b.childNodes,d=0,f=b.length;d<f;d++){varg=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)))}returnc},init:function(b,c,d){a.a.n(b,"change",function(){varb=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"));
update:function(b,c,d,f,g){returna.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"==typeofb){varc=c||document,d=c.getElementById(b);d||m(Error("Cannot find template with ID "+b));returnnewa.l.i(d)}if(1==
p);!(d&&d!=document)&&"string"==typeofa&&(this.V=this.V||{},this.V[a]=p)};a.b("templateEngine",a.t);a.Z=function(){functionb(b,c,e){for(varb=a.g.W(b),d=a.g.D,j=0;j<b.length;j++){vark=b[j].key;if(d.hasOwnProperty(k)){vari=d[k];"function"===typeofi?(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)+
" } })() })";returne.createJavaScriptEvaluatorBlock(b)+c}varc=/(<[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){returna.Z.zb(b,c)},e)},zb:function(a,g){returna.replace(c,function(a,c,d,f,i,l,q){returnb(q,c,g)}).replace(d,function(a,c){returnb(c,"<\!-- ko --\>",g)})},Za:function(b){returna.s.na(function(c,
g;a.Z.mb(j,q,l);j=q.renderTemplate(j,k,i,l);("number"!=typeofj.length||0<j.length&&"number"!=typeofj[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));returnj}varg;a.ra=function(b){b!=n&&!(binstanceofa.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){varl=d(k);returna.h(function(){varg=c&&cinstanceofa.z?c:newa.z(a.a.d(c)),o="function"==typeofb?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})}returna.s.na(function(d){a.qa(b,c,j,d,"replaceNode")})};a.Fb=function(b,
"function"==typeofc.A&&c.A();a.a.f.set(b,"__ko__templateSubscriptionDomDataKey__",g)}};a.g.D.template=function(b){b=a.g.W(b);return1==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)returna.a.O(b,c,1)||a.a.O(b,c,10)||a.a.O(b,c,Number.MAX_VALUE);for(varb=b||[],c=c||[],f=b,g=c,e=[],h=0;h<=g.length;h++)e[h]=
if(c)returna.a.L(c.cloneNode(p).childNodes);b=b.text();returna.a.pa(b)};a.q.K=newa.q;a.ra(a.q.K);a.b("nativeTemplateEngine",a.q);(function(){a.ma=function(){vara=this.vb=function(){if("undefined"==typeofjQuery||!jQuery.tmpl)return0;try{if(0<=jQuery.tmpl.tag.tmpl.open.toString().indexOf("__"))return2}catch(a){}return1}();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."));vare=b.data("precompiled");