forked from kmalakoff/knockback
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathknockback-core-stack.min.js
97 lines (96 loc) · 123 KB
/
knockback-core-stack.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*
knockback-core-stack.js 0.17.3
(c) 2011-2013 Kevin Malakoff - http://kmalakoff.github.com/knockback/
License: MIT (http://www.opensource.org/licenses/mit-license.php)
Dependencies: Knockout.js, Backbone.js, and Underscore.js.
*/
(function(){var n=this,t=n._,r={},e=Array.prototype,u=Object.prototype,i=Function.prototype,a=e.push,o=e.slice,c=e.concat,l=u.toString,f=u.hasOwnProperty,s=e.forEach,p=e.map,h=e.reduce,v=e.reduceRight,d=e.filter,g=e.every,m=e.some,y=e.indexOf,b=e.lastIndexOf,x=Array.isArray,_=Object.keys,j=i.bind,w=function(n){return n instanceof w?n:this instanceof w?(this._wrapped=n,void 0):new w(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=w),exports._=w):n._=w,w.VERSION="1.4.4";var A=w.each=w.forEach=function(n,t,e){if(null!=n)if(s&&n.forEach===s)n.forEach(t,e);else if(n.length===+n.length){for(var u=0,i=n.length;i>u;u++)if(t.call(e,n[u],u,n)===r)return}else for(var a in n)if(w.has(n,a)&&t.call(e,n[a],a,n)===r)return};w.map=w.collect=function(n,t,r){var e=[];return null==n?e:p&&n.map===p?n.map(t,r):(A(n,function(n,u,i){e[e.length]=t.call(r,n,u,i)}),e)};var O="Reduce of empty array with no initial value";w.reduce=w.foldl=w.inject=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),h&&n.reduce===h)return e&&(t=w.bind(t,e)),u?n.reduce(t,r):n.reduce(t);if(A(n,function(n,i,a){u?r=t.call(e,r,n,i,a):(r=n,u=!0)}),!u)throw new TypeError(O);return r},w.reduceRight=w.foldr=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),v&&n.reduceRight===v)return e&&(t=w.bind(t,e)),u?n.reduceRight(t,r):n.reduceRight(t);var i=n.length;if(i!==+i){var a=w.keys(n);i=a.length}if(A(n,function(o,c,l){c=a?a[--i]:--i,u?r=t.call(e,r,n[c],c,l):(r=n[c],u=!0)}),!u)throw new TypeError(O);return r},w.find=w.detect=function(n,t,r){var e;return E(n,function(n,u,i){return t.call(r,n,u,i)?(e=n,!0):void 0}),e},w.filter=w.select=function(n,t,r){var e=[];return null==n?e:d&&n.filter===d?n.filter(t,r):(A(n,function(n,u,i){t.call(r,n,u,i)&&(e[e.length]=n)}),e)},w.reject=function(n,t,r){return w.filter(n,function(n,e,u){return!t.call(r,n,e,u)},r)},w.every=w.all=function(n,t,e){t||(t=w.identity);var u=!0;return null==n?u:g&&n.every===g?n.every(t,e):(A(n,function(n,i,a){return(u=u&&t.call(e,n,i,a))?void 0:r}),!!u)};var E=w.some=w.any=function(n,t,e){t||(t=w.identity);var u=!1;return null==n?u:m&&n.some===m?n.some(t,e):(A(n,function(n,i,a){return u||(u=t.call(e,n,i,a))?r:void 0}),!!u)};w.contains=w.include=function(n,t){return null==n?!1:y&&n.indexOf===y?n.indexOf(t)!=-1:E(n,function(n){return n===t})},w.invoke=function(n,t){var r=o.call(arguments,2),e=w.isFunction(t);return w.map(n,function(n){return(e?t:n[t]).apply(n,r)})},w.pluck=function(n,t){return w.map(n,function(n){return n[t]})},w.where=function(n,t,r){return w.isEmpty(t)?r?null:[]:w[r?"find":"filter"](n,function(n){for(var r in t)if(t[r]!==n[r])return!1;return!0})},w.findWhere=function(n,t){return w.where(n,t,!0)},w.max=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.max.apply(Math,n);if(!t&&w.isEmpty(n))return-1/0;var e={computed:-1/0,value:-1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;a>=e.computed&&(e={value:n,computed:a})}),e.value},w.min=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.min.apply(Math,n);if(!t&&w.isEmpty(n))return 1/0;var e={computed:1/0,value:1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;e.computed>a&&(e={value:n,computed:a})}),e.value},w.shuffle=function(n){var t,r=0,e=[];return A(n,function(n){t=w.random(r++),e[r-1]=e[t],e[t]=n}),e};var k=function(n){return w.isFunction(n)?n:function(t){return t[n]}};w.sortBy=function(n,t,r){var e=k(t);return w.pluck(w.map(n,function(n,t,u){return{value:n,index:t,criteria:e.call(r,n,t,u)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.index<t.index?-1:1}),"value")};var F=function(n,t,r,e){var u={},i=k(t||w.identity);return A(n,function(t,a){var o=i.call(r,t,a,n);e(u,o,t)}),u};w.groupBy=function(n,t,r){return F(n,t,r,function(n,t,r){(w.has(n,t)?n[t]:n[t]=[]).push(r)})},w.countBy=function(n,t,r){return F(n,t,r,function(n,t){w.has(n,t)||(n[t]=0),n[t]++})},w.sortedIndex=function(n,t,r,e){r=null==r?w.identity:k(r);for(var u=r.call(e,t),i=0,a=n.length;a>i;){var o=i+a>>>1;u>r.call(e,n[o])?i=o+1:a=o}return i},w.toArray=function(n){return n?w.isArray(n)?o.call(n):n.length===+n.length?w.map(n,w.identity):w.values(n):[]},w.size=function(n){return null==n?0:n.length===+n.length?n.length:w.keys(n).length},w.first=w.head=w.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:o.call(n,0,t)},w.initial=function(n,t,r){return o.call(n,0,n.length-(null==t||r?1:t))},w.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:o.call(n,Math.max(n.length-t,0))},w.rest=w.tail=w.drop=function(n,t,r){return o.call(n,null==t||r?1:t)},w.compact=function(n){return w.filter(n,w.identity)};var R=function(n,t,r){return A(n,function(n){w.isArray(n)?t?a.apply(r,n):R(n,t,r):r.push(n)}),r};w.flatten=function(n,t){return R(n,t,[])},w.without=function(n){return w.difference(n,o.call(arguments,1))},w.uniq=w.unique=function(n,t,r,e){w.isFunction(t)&&(e=r,r=t,t=!1);var u=r?w.map(n,r,e):n,i=[],a=[];return A(u,function(r,e){(t?e&&a[a.length-1]===r:w.contains(a,r))||(a.push(r),i.push(n[e]))}),i},w.union=function(){return w.uniq(c.apply(e,arguments))},w.intersection=function(n){var t=o.call(arguments,1);return w.filter(w.uniq(n),function(n){return w.every(t,function(t){return w.indexOf(t,n)>=0})})},w.difference=function(n){var t=c.apply(e,o.call(arguments,1));return w.filter(n,function(n){return!w.contains(t,n)})},w.zip=function(){for(var n=o.call(arguments),t=w.max(w.pluck(n,"length")),r=Array(t),e=0;t>e;e++)r[e]=w.pluck(n,""+e);return r},w.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},w.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=w.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}if(y&&n.indexOf===y)return n.indexOf(t,r);for(;u>e;e++)if(n[e]===t)return e;return-1},w.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=null!=r;if(b&&n.lastIndexOf===b)return e?n.lastIndexOf(t,r):n.lastIndexOf(t);for(var u=e?r:n.length;u--;)if(n[u]===t)return u;return-1},w.range=function(n,t,r){1>=arguments.length&&(t=n||0,n=0),r=arguments[2]||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=0,i=Array(e);e>u;)i[u++]=n,n+=r;return i},w.bind=function(n,t){if(n.bind===j&&j)return j.apply(n,o.call(arguments,1));var r=o.call(arguments,2);return function(){return n.apply(t,r.concat(o.call(arguments)))}},w.partial=function(n){var t=o.call(arguments,1);return function(){return n.apply(this,t.concat(o.call(arguments)))}},w.bindAll=function(n){var t=o.call(arguments,1);return 0===t.length&&(t=w.functions(n)),A(t,function(t){n[t]=w.bind(n[t],n)}),n},w.memoize=function(n,t){var r={};return t||(t=w.identity),function(){var e=t.apply(this,arguments);return w.has(r,e)?r[e]:r[e]=n.apply(this,arguments)}},w.delay=function(n,t){var r=o.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},w.defer=function(n){return w.delay.apply(w,[n,1].concat(o.call(arguments,1)))},w.throttle=function(n,t){var r,e,u,i,a=0,o=function(){a=new Date,u=null,i=n.apply(r,e)};return function(){var c=new Date,l=t-(c-a);return r=this,e=arguments,0>=l?(clearTimeout(u),u=null,a=c,i=n.apply(r,e)):u||(u=setTimeout(o,l)),i}},w.debounce=function(n,t,r){var e,u;return function(){var i=this,a=arguments,o=function(){e=null,r||(u=n.apply(i,a))},c=r&&!e;return clearTimeout(e),e=setTimeout(o,t),c&&(u=n.apply(i,a)),u}},w.once=function(n){var t,r=!1;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},w.wrap=function(n,t){return function(){var r=[n];return a.apply(r,arguments),t.apply(this,r)}},w.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length-1;r>=0;r--)t=[n[r].apply(this,t)];return t[0]}},w.after=function(n,t){return 0>=n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},w.keys=_||function(n){if(n!==Object(n))throw new TypeError("Invalid object");var t=[];for(var r in n)w.has(n,r)&&(t[t.length]=r);return t},w.values=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push(n[r]);return t},w.pairs=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push([r,n[r]]);return t},w.invert=function(n){var t={};for(var r in n)w.has(n,r)&&(t[n[r]]=r);return t},w.functions=w.methods=function(n){var t=[];for(var r in n)w.isFunction(n[r])&&t.push(r);return t.sort()},w.extend=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]=t[r]}),n},w.pick=function(n){var t={},r=c.apply(e,o.call(arguments,1));return A(r,function(r){r in n&&(t[r]=n[r])}),t},w.omit=function(n){var t={},r=c.apply(e,o.call(arguments,1));for(var u in n)w.contains(r,u)||(t[u]=n[u]);return t},w.defaults=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)null==n[r]&&(n[r]=t[r])}),n},w.clone=function(n){return w.isObject(n)?w.isArray(n)?n.slice():w.extend({},n):n},w.tap=function(n,t){return t(n),n};var I=function(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof w&&(n=n._wrapped),t instanceof w&&(t=t._wrapped);var u=l.call(n);if(u!=l.call(t))return!1;switch(u){case"[object String]":return n==t+"";case"[object Number]":return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object RegExp]":return n.source==t.source&&n.global==t.global&&n.multiline==t.multiline&&n.ignoreCase==t.ignoreCase}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]==n)return e[i]==t;r.push(n),e.push(t);var a=0,o=!0;if("[object Array]"==u){if(a=n.length,o=a==t.length)for(;a--&&(o=I(n[a],t[a],r,e)););}else{var c=n.constructor,f=t.constructor;if(c!==f&&!(w.isFunction(c)&&c instanceof c&&w.isFunction(f)&&f instanceof f))return!1;for(var s in n)if(w.has(n,s)&&(a++,!(o=w.has(t,s)&&I(n[s],t[s],r,e))))break;if(o){for(s in t)if(w.has(t,s)&&!a--)break;o=!a}}return r.pop(),e.pop(),o};w.isEqual=function(n,t){return I(n,t,[],[])},w.isEmpty=function(n){if(null==n)return!0;if(w.isArray(n)||w.isString(n))return 0===n.length;for(var t in n)if(w.has(n,t))return!1;return!0},w.isElement=function(n){return!(!n||1!==n.nodeType)},w.isArray=x||function(n){return"[object Array]"==l.call(n)},w.isObject=function(n){return n===Object(n)},A(["Arguments","Function","String","Number","Date","RegExp"],function(n){w["is"+n]=function(t){return l.call(t)=="[object "+n+"]"}}),w.isArguments(arguments)||(w.isArguments=function(n){return!(!n||!w.has(n,"callee"))}),"function"!=typeof/./&&(w.isFunction=function(n){return"function"==typeof n}),w.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},w.isNaN=function(n){return w.isNumber(n)&&n!=+n},w.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"==l.call(n)},w.isNull=function(n){return null===n},w.isUndefined=function(n){return n===void 0},w.has=function(n,t){return f.call(n,t)},w.noConflict=function(){return n._=t,this},w.identity=function(n){return n},w.times=function(n,t,r){for(var e=Array(n),u=0;n>u;u++)e[u]=t.call(r,u);return e},w.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))};var M={escape:{"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"}};M.unescape=w.invert(M.escape);var S={escape:RegExp("["+w.keys(M.escape).join("")+"]","g"),unescape:RegExp("("+w.keys(M.unescape).join("|")+")","g")};w.each(["escape","unescape"],function(n){w[n]=function(t){return null==t?"":(""+t).replace(S[n],function(t){return M[n][t]})}}),w.result=function(n,t){if(null==n)return null;var r=n[t];return w.isFunction(r)?r.call(n):r},w.mixin=function(n){A(w.functions(n),function(t){var r=w[t]=n[t];w.prototype[t]=function(){var n=[this._wrapped];return a.apply(n,arguments),D.call(this,r.apply(w,n))}})};var N=0;w.uniqueId=function(n){var t=++N+"";return n?n+t:t},w.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var T=/(.)^/,q={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},B=/\\|'|\r|\n|\t|\u2028|\u2029/g;w.template=function(n,t,r){var e;r=w.defaults({},r,w.templateSettings);var u=RegExp([(r.escape||T).source,(r.interpolate||T).source,(r.evaluate||T).source].join("|")+"|$","g"),i=0,a="__p+='";n.replace(u,function(t,r,e,u,o){return a+=n.slice(i,o).replace(B,function(n){return"\\"+q[n]}),r&&(a+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'"),e&&(a+="'+\n((__t=("+e+"))==null?'':__t)+\n'"),u&&(a+="';\n"+u+"\n__p+='"),i=o+t.length,t}),a+="';\n",r.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{e=Function(r.variable||"obj","_",a)}catch(o){throw o.source=a,o}if(t)return e(t,w);var c=function(n){return e.call(this,n,w)};return c.source="function("+(r.variable||"obj")+"){\n"+a+"}",c},w.chain=function(n){return w(n).chain()};var D=function(n){return this._chain?w(n).chain():n};w.mixin(w),A(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=e[n];w.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!=n&&"splice"!=n||0!==r.length||delete r[0],D.call(this,r)}}),A(["concat","join","slice"],function(n){var t=e[n];w.prototype[n]=function(){return D.call(this,t.apply(this._wrapped,arguments))}}),w.extend(w.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this);(function(){var root=this;var previousBackbone=root.Backbone;var array=[];var push=array.push;var slice=array.slice;var splice=array.splice;var Backbone;if(typeof exports!=="undefined"){Backbone=exports}else{Backbone=root.Backbone={}}Backbone.VERSION="1.0.0";var _=root._;if(!_&&typeof require!=="undefined")_=require("underscore");Backbone.$=root.jQuery||root.Zepto||root.ender||root.$;Backbone.noConflict=function(){root.Backbone=previousBackbone;return this};Backbone.emulateHTTP=false;Backbone.emulateJSON=false;var Events=Backbone.Events={on:function(name,callback,context){if(!eventsApi(this,"on",name,[callback,context])||!callback)return this;this._events||(this._events={});var events=this._events[name]||(this._events[name]=[]);events.push({callback:callback,context:context,ctx:context||this});return this},once:function(name,callback,context){if(!eventsApi(this,"once",name,[callback,context])||!callback)return this;var self=this;var once=_.once(function(){self.off(name,once);callback.apply(this,arguments)});once._callback=callback;return this.on(name,once,context)},off:function(name,callback,context){var retain,ev,events,names,i,l,j,k;if(!this._events||!eventsApi(this,"off",name,[callback,context]))return this;if(!name&&!callback&&!context){this._events={};return this}names=name?[name]:_.keys(this._events);for(i=0,l=names.length;i<l;i++){name=names[i];if(events=this._events[name]){this._events[name]=retain=[];if(callback||context){for(j=0,k=events.length;j<k;j++){ev=events[j];if(callback&&callback!==ev.callback&&callback!==ev.callback._callback||context&&context!==ev.context){retain.push(ev)}}}if(!retain.length)delete this._events[name]}}return this},trigger:function(name){if(!this._events)return this;var args=slice.call(arguments,1);if(!eventsApi(this,"trigger",name,args))return this;var events=this._events[name];var allEvents=this._events.all;if(events)triggerEvents(events,args);if(allEvents)triggerEvents(allEvents,arguments);return this},stopListening:function(obj,name,callback){var listeners=this._listeners;if(!listeners)return this;var deleteListener=!name&&!callback;if(typeof name==="object")callback=this;if(obj)(listeners={})[obj._listenerId]=obj;for(var id in listeners){listeners[id].off(name,callback,this);if(deleteListener)delete this._listeners[id]}return this}};var eventSplitter=/\s+/;var eventsApi=function(obj,action,name,rest){if(!name)return true;if(typeof name==="object"){for(var key in name){obj[action].apply(obj,[key,name[key]].concat(rest))}return false}if(eventSplitter.test(name)){var names=name.split(eventSplitter);for(var i=0,l=names.length;i<l;i++){obj[action].apply(obj,[names[i]].concat(rest))}return false}return true};var triggerEvents=function(events,args){var ev,i=-1,l=events.length,a1=args[0],a2=args[1],a3=args[2];switch(args.length){case 0:while(++i<l)(ev=events[i]).callback.call(ev.ctx);return;case 1:while(++i<l)(ev=events[i]).callback.call(ev.ctx,a1);return;case 2:while(++i<l)(ev=events[i]).callback.call(ev.ctx,a1,a2);return;case 3:while(++i<l)(ev=events[i]).callback.call(ev.ctx,a1,a2,a3);return;default:while(++i<l)(ev=events[i]).callback.apply(ev.ctx,args)}};var listenMethods={listenTo:"on",listenToOnce:"once"};_.each(listenMethods,function(implementation,method){Events[method]=function(obj,name,callback){var listeners=this._listeners||(this._listeners={});var id=obj._listenerId||(obj._listenerId=_.uniqueId("l"));listeners[id]=obj;if(typeof name==="object")callback=this;obj[implementation](name,callback,this);return this}});Events.bind=Events.on;Events.unbind=Events.off;_.extend(Backbone,Events);var Model=Backbone.Model=function(attributes,options){var defaults;var attrs=attributes||{};options||(options={});this.cid=_.uniqueId("c");this.attributes={};_.extend(this,_.pick(options,modelOptions));if(options.parse)attrs=this.parse(attrs,options)||{};if(defaults=_.result(this,"defaults")){attrs=_.defaults({},attrs,defaults)}this.set(attrs,options);this.changed={};this.initialize.apply(this,arguments)};var modelOptions=["url","urlRoot","collection"];_.extend(Model.prototype,Events,{changed:null,validationError:null,idAttribute:"id",initialize:function(){},toJSON:function(options){return _.clone(this.attributes)},sync:function(){return Backbone.sync.apply(this,arguments)},get:function(attr){return this.attributes[attr]},escape:function(attr){return _.escape(this.get(attr))},has:function(attr){return this.get(attr)!=null},set:function(key,val,options){var attr,attrs,unset,changes,silent,changing,prev,current;if(key==null)return this;if(typeof key==="object"){attrs=key;options=val}else{(attrs={})[key]=val}options||(options={});if(!this._validate(attrs,options))return false;unset=options.unset;silent=options.silent;changes=[];changing=this._changing;this._changing=true;if(!changing){this._previousAttributes=_.clone(this.attributes);this.changed={}}current=this.attributes,prev=this._previousAttributes;if(this.idAttribute in attrs)this.id=attrs[this.idAttribute];for(attr in attrs){val=attrs[attr];if(!_.isEqual(current[attr],val))changes.push(attr);if(!_.isEqual(prev[attr],val)){this.changed[attr]=val}else{delete this.changed[attr]}unset?delete current[attr]:current[attr]=val}if(!silent){if(changes.length)this._pending=true;for(var i=0,l=changes.length;i<l;i++){this.trigger("change:"+changes[i],this,current[changes[i]],options)}}if(changing)return this;if(!silent){while(this._pending){this._pending=false;this.trigger("change",this,options)}}this._pending=false;this._changing=false;return this},unset:function(attr,options){return this.set(attr,void 0,_.extend({},options,{unset:true}))},clear:function(options){var attrs={};for(var key in this.attributes)attrs[key]=void 0;return this.set(attrs,_.extend({},options,{unset:true}))},hasChanged:function(attr){if(attr==null)return!_.isEmpty(this.changed);return _.has(this.changed,attr)},changedAttributes:function(diff){if(!diff)return this.hasChanged()?_.clone(this.changed):false;var val,changed=false;var old=this._changing?this._previousAttributes:this.attributes;for(var attr in diff){if(_.isEqual(old[attr],val=diff[attr]))continue;(changed||(changed={}))[attr]=val}return changed},previous:function(attr){if(attr==null||!this._previousAttributes)return null;return this._previousAttributes[attr]},previousAttributes:function(){return _.clone(this._previousAttributes)},fetch:function(options){options=options?_.clone(options):{};if(options.parse===void 0)options.parse=true;var model=this;var success=options.success;options.success=function(resp){if(!model.set(model.parse(resp,options),options))return false;if(success)success(model,resp,options);model.trigger("sync",model,resp,options)};wrapError(this,options);return this.sync("read",this,options)},save:function(key,val,options){var attrs,method,xhr,attributes=this.attributes;if(key==null||typeof key==="object"){attrs=key;options=val}else{(attrs={})[key]=val}if(attrs&&(!options||!options.wait)&&!this.set(attrs,options))return false;options=_.extend({validate:true},options);if(!this._validate(attrs,options))return false;if(attrs&&options.wait){this.attributes=_.extend({},attributes,attrs)}if(options.parse===void 0)options.parse=true;var model=this;var success=options.success;options.success=function(resp){model.attributes=attributes;var serverAttrs=model.parse(resp,options);if(options.wait)serverAttrs=_.extend(attrs||{},serverAttrs);if(_.isObject(serverAttrs)&&!model.set(serverAttrs,options)){return false}if(success)success(model,resp,options);model.trigger("sync",model,resp,options)};wrapError(this,options);method=this.isNew()?"create":options.patch?"patch":"update";if(method==="patch")options.attrs=attrs;xhr=this.sync(method,this,options);if(attrs&&options.wait)this.attributes=attributes;return xhr},destroy:function(options){options=options?_.clone(options):{};var model=this;var success=options.success;var destroy=function(){model.trigger("destroy",model,model.collection,options)};options.success=function(resp){if(options.wait||model.isNew())destroy();if(success)success(model,resp,options);if(!model.isNew())model.trigger("sync",model,resp,options)};if(this.isNew()){options.success();return false}wrapError(this,options);var xhr=this.sync("delete",this,options);if(!options.wait)destroy();return xhr},url:function(){var base=_.result(this,"urlRoot")||_.result(this.collection,"url")||urlError();if(this.isNew())return base;return base+(base.charAt(base.length-1)==="/"?"":"/")+encodeURIComponent(this.id)},parse:function(resp,options){return resp},clone:function(){return new this.constructor(this.attributes)},isNew:function(){return this.id==null},isValid:function(options){return this._validate({},_.extend(options||{},{validate:true}))},_validate:function(attrs,options){if(!options.validate||!this.validate)return true;attrs=_.extend({},this.attributes,attrs);var error=this.validationError=this.validate(attrs,options)||null;if(!error)return true;this.trigger("invalid",this,error,_.extend(options||{},{validationError:error}));return false}});var modelMethods=["keys","values","pairs","invert","pick","omit"];_.each(modelMethods,function(method){Model.prototype[method]=function(){var args=slice.call(arguments);args.unshift(this.attributes);return _[method].apply(_,args)}});var Collection=Backbone.Collection=function(models,options){options||(options={});if(options.url)this.url=options.url;if(options.model)this.model=options.model;if(options.comparator!==void 0)this.comparator=options.comparator;this._reset();this.initialize.apply(this,arguments);if(models)this.reset(models,_.extend({silent:true},options))};var setOptions={add:true,remove:true,merge:true};var addOptions={add:true,merge:false,remove:false};_.extend(Collection.prototype,Events,{model:Model,initialize:function(){},toJSON:function(options){return this.map(function(model){return model.toJSON(options)})},sync:function(){return Backbone.sync.apply(this,arguments)},add:function(models,options){return this.set(models,_.defaults(options||{},addOptions))},remove:function(models,options){models=_.isArray(models)?models.slice():[models];options||(options={});var i,l,index,model;for(i=0,l=models.length;i<l;i++){model=this.get(models[i]);if(!model)continue;delete this._byId[model.id];delete this._byId[model.cid];index=this.indexOf(model);this.models.splice(index,1);this.length--;if(!options.silent){options.index=index;model.trigger("remove",model,this,options)}this._removeReference(model)}return this},set:function(models,options){options=_.defaults(options||{},setOptions);if(options.parse)models=this.parse(models,options);if(!_.isArray(models))models=models?[models]:[];var i,l,model,attrs,existing,sort;var at=options.at;var sortable=this.comparator&&at==null&&options.sort!==false;var sortAttr=_.isString(this.comparator)?this.comparator:null;var toAdd=[],toRemove=[],modelMap={};for(i=0,l=models.length;i<l;i++){if(!(model=this._prepareModel(models[i],options)))continue;if(existing=this.get(model)){if(options.remove)modelMap[existing.cid]=true;if(options.merge){existing.set(model.attributes,options);if(sortable&&!sort&&existing.hasChanged(sortAttr))sort=true}}else if(options.add){toAdd.push(model);model.on("all",this._onModelEvent,this);this._byId[model.cid]=model;if(model.id!=null)this._byId[model.id]=model}}if(options.remove){for(i=0,l=this.length;i<l;++i){if(!modelMap[(model=this.models[i]).cid])toRemove.push(model)}if(toRemove.length)this.remove(toRemove,options)}if(toAdd.length){if(sortable)sort=true;this.length+=toAdd.length;if(at!=null){splice.apply(this.models,[at,0].concat(toAdd))}else{push.apply(this.models,toAdd)}}if(sort)this.sort({silent:true});if(options.silent)return this;for(i=0,l=toAdd.length;i<l;i++){(model=toAdd[i]).trigger("add",model,this,options)}if(sort)this.trigger("sort",this,options);return this},reset:function(models,options){options||(options={});for(var i=0,l=this.models.length;i<l;i++){this._removeReference(this.models[i])}options.previousModels=this.models;this._reset();this.add(models,_.extend({silent:true},options));if(!options.silent)this.trigger("reset",this,options);return this},push:function(model,options){model=this._prepareModel(model,options);this.add(model,_.extend({at:this.length},options));return model},pop:function(options){var model=this.at(this.length-1);this.remove(model,options);return model},unshift:function(model,options){model=this._prepareModel(model,options);this.add(model,_.extend({at:0},options));return model},shift:function(options){var model=this.at(0);this.remove(model,options);return model},slice:function(begin,end){return this.models.slice(begin,end)},get:function(obj){if(obj==null)return void 0;return this._byId[obj.id!=null?obj.id:obj.cid||obj]},at:function(index){return this.models[index]},where:function(attrs,first){if(_.isEmpty(attrs))return first?void 0:[];return this[first?"find":"filter"](function(model){for(var key in attrs){if(attrs[key]!==model.get(key))return false}return true})},findWhere:function(attrs){return this.where(attrs,true)},sort:function(options){if(!this.comparator)throw new Error("Cannot sort a set without a comparator");options||(options={});if(_.isString(this.comparator)||this.comparator.length===1){this.models=this.sortBy(this.comparator,this)}else{this.models.sort(_.bind(this.comparator,this))}if(!options.silent)this.trigger("sort",this,options);return this},sortedIndex:function(model,value,context){value||(value=this.comparator);var iterator=_.isFunction(value)?value:function(model){return model.get(value)};return _.sortedIndex(this.models,model,iterator,context)},pluck:function(attr){return _.invoke(this.models,"get",attr)},fetch:function(options){options=options?_.clone(options):{};if(options.parse===void 0)options.parse=true;var success=options.success;var collection=this;options.success=function(resp){var method=options.reset?"reset":"set";collection[method](resp,options);if(success)success(collection,resp,options);collection.trigger("sync",collection,resp,options)};wrapError(this,options);return this.sync("read",this,options)},create:function(model,options){options=options?_.clone(options):{};if(!(model=this._prepareModel(model,options)))return false;if(!options.wait)this.add(model,options);var collection=this;var success=options.success;options.success=function(resp){if(options.wait)collection.add(model,options);if(success)success(model,resp,options)};model.save(null,options);return model},parse:function(resp,options){return resp},clone:function(){return new this.constructor(this.models)},_reset:function(){this.length=0;this.models=[];this._byId={}},_prepareModel:function(attrs,options){if(attrs instanceof Model){if(!attrs.collection)attrs.collection=this;return attrs}options||(options={});options.collection=this;var model=new this.model(attrs,options);if(!model._validate(attrs,options)){this.trigger("invalid",this,attrs,options);return false}return model},_removeReference:function(model){if(this===model.collection)delete model.collection;model.off("all",this._onModelEvent,this)},_onModelEvent:function(event,model,collection,options){if((event==="add"||event==="remove")&&collection!==this)return;if(event==="destroy")this.remove(model,options);if(model&&event==="change:"+model.idAttribute){delete this._byId[model.previous(model.idAttribute)];if(model.id!=null)this._byId[model.id]=model}this.trigger.apply(this,arguments)}});var methods=["forEach","each","map","collect","reduce","foldl","inject","reduceRight","foldr","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","max","min","toArray","size","first","head","take","initial","rest","tail","drop","last","without","indexOf","shuffle","lastIndexOf","isEmpty","chain"];_.each(methods,function(method){Collection.prototype[method]=function(){var args=slice.call(arguments);args.unshift(this.models);return _[method].apply(_,args)}});var attributeMethods=["groupBy","countBy","sortBy"];_.each(attributeMethods,function(method){Collection.prototype[method]=function(value,context){var iterator=_.isFunction(value)?value:function(model){return model.get(value)};return _[method](this.models,iterator,context)}});var View=Backbone.View=function(options){this.cid=_.uniqueId("view");this._configure(options||{});this._ensureElement();this.initialize.apply(this,arguments);this.delegateEvents()};var delegateEventSplitter=/^(\S+)\s*(.*)$/;var viewOptions=["model","collection","el","id","attributes","className","tagName","events"];_.extend(View.prototype,Events,{tagName:"div",$:function(selector){return this.$el.find(selector)},initialize:function(){},render:function(){return this},remove:function(){this.$el.remove();this.stopListening();return this},setElement:function(element,delegate){if(this.$el)this.undelegateEvents();this.$el=element instanceof Backbone.$?element:Backbone.$(element);this.el=this.$el[0];if(delegate!==false)this.delegateEvents();return this},delegateEvents:function(events){if(!(events||(events=_.result(this,"events"))))return this;this.undelegateEvents();for(var key in events){var method=events[key];if(!_.isFunction(method))method=this[events[key]];if(!method)continue;var match=key.match(delegateEventSplitter);var eventName=match[1],selector=match[2];method=_.bind(method,this);eventName+=".delegateEvents"+this.cid;if(selector===""){this.$el.on(eventName,method)}else{this.$el.on(eventName,selector,method)}}return this},undelegateEvents:function(){this.$el.off(".delegateEvents"+this.cid);return this},_configure:function(options){if(this.options)options=_.extend({},_.result(this,"options"),options);_.extend(this,_.pick(options,viewOptions));this.options=options},_ensureElement:function(){if(!this.el){var attrs=_.extend({},_.result(this,"attributes"));if(this.id)attrs.id=_.result(this,"id");if(this.className)attrs["class"]=_.result(this,"className");var $el=Backbone.$("<"+_.result(this,"tagName")+">").attr(attrs);this.setElement($el,false)}else{this.setElement(_.result(this,"el"),false)}}});Backbone.sync=function(method,model,options){var type=methodMap[method];_.defaults(options||(options={}),{emulateHTTP:Backbone.emulateHTTP,emulateJSON:Backbone.emulateJSON});var params={type:type,dataType:"json"};if(!options.url){params.url=_.result(model,"url")||urlError()}if(options.data==null&&model&&(method==="create"||method==="update"||method==="patch")){params.contentType="application/json";params.data=JSON.stringify(options.attrs||model.toJSON(options))}if(options.emulateJSON){params.contentType="application/x-www-form-urlencoded";params.data=params.data?{model:params.data}:{}}if(options.emulateHTTP&&(type==="PUT"||type==="DELETE"||type==="PATCH")){params.type="POST";if(options.emulateJSON)params.data._method=type;var beforeSend=options.beforeSend;options.beforeSend=function(xhr){xhr.setRequestHeader("X-HTTP-Method-Override",type);if(beforeSend)return beforeSend.apply(this,arguments)}}if(params.type!=="GET"&&!options.emulateJSON){params.processData=false}if(params.type==="PATCH"&&window.ActiveXObject&&!(window.external&&window.external.msActiveXFilteringEnabled)){params.xhr=function(){return new ActiveXObject("Microsoft.XMLHTTP")}}var xhr=options.xhr=Backbone.ajax(_.extend(params,options));model.trigger("request",model,xhr,options);return xhr};var methodMap={create:"POST",update:"PUT",patch:"PATCH","delete":"DELETE",read:"GET"};Backbone.ajax=function(){return Backbone.$.ajax.apply(Backbone.$,arguments)};var Router=Backbone.Router=function(options){options||(options={});if(options.routes)this.routes=options.routes;this._bindRoutes();this.initialize.apply(this,arguments)};var optionalParam=/\((.*?)\)/g;var namedParam=/(\(\?)?:\w+/g;var splatParam=/\*\w+/g;var escapeRegExp=/[\-{}\[\]+?.,\\\^$|#\s]/g;_.extend(Router.prototype,Events,{initialize:function(){},route:function(route,name,callback){if(!_.isRegExp(route))route=this._routeToRegExp(route);if(_.isFunction(name)){callback=name;name=""}if(!callback)callback=this[name];var router=this;Backbone.history.route(route,function(fragment){var args=router._extractParameters(route,fragment);callback&&callback.apply(router,args);router.trigger.apply(router,["route:"+name].concat(args));router.trigger("route",name,args);Backbone.history.trigger("route",router,name,args)});return this},navigate:function(fragment,options){Backbone.history.navigate(fragment,options);return this},_bindRoutes:function(){if(!this.routes)return;this.routes=_.result(this,"routes");var route,routes=_.keys(this.routes);while((route=routes.pop())!=null){this.route(route,this.routes[route])}},_routeToRegExp:function(route){route=route.replace(escapeRegExp,"\\$&").replace(optionalParam,"(?:$1)?").replace(namedParam,function(match,optional){return optional?match:"([^/]+)"}).replace(splatParam,"(.*?)");return new RegExp("^"+route+"$")},_extractParameters:function(route,fragment){var params=route.exec(fragment).slice(1);return _.map(params,function(param){return param?decodeURIComponent(param):null})}});var History=Backbone.History=function(){this.handlers=[];_.bindAll(this,"checkUrl");if(typeof window!=="undefined"){this.location=window.location;this.history=window.history}};var routeStripper=/^[#\/]|\s+$/g;var rootStripper=/^\/+|\/+$/g;var isExplorer=/msie [\w.]+/;var trailingSlash=/\/$/;History.started=false;_.extend(History.prototype,Events,{interval:50,getHash:function(window){var match=(window||this).location.href.match(/#(.*)$/);return match?match[1]:""},getFragment:function(fragment,forcePushState){if(fragment==null){if(this._hasPushState||!this._wantsHashChange||forcePushState){fragment=this.location.pathname;var root=this.root.replace(trailingSlash,"");if(!fragment.indexOf(root))fragment=fragment.substr(root.length)}else{fragment=this.getHash()}}return fragment.replace(routeStripper,"")},start:function(options){if(History.started)throw new Error("Backbone.history has already been started");History.started=true;this.options=_.extend({},{root:"/"},this.options,options);this.root=this.options.root;this._wantsHashChange=this.options.hashChange!==false;this._wantsPushState=!!this.options.pushState;this._hasPushState=!!(this.options.pushState&&this.history&&this.history.pushState);var fragment=this.getFragment();var docMode=document.documentMode;var oldIE=isExplorer.exec(navigator.userAgent.toLowerCase())&&(!docMode||docMode<=7);this.root=("/"+this.root+"/").replace(rootStripper,"/");if(oldIE&&this._wantsHashChange){this.iframe=Backbone.$('<iframe src="javascript:0" tabindex="-1" />').hide().appendTo("body")[0].contentWindow;this.navigate(fragment)}if(this._hasPushState){Backbone.$(window).on("popstate",this.checkUrl)}else if(this._wantsHashChange&&"onhashchange"in window&&!oldIE){Backbone.$(window).on("hashchange",this.checkUrl)}else if(this._wantsHashChange){this._checkUrlInterval=setInterval(this.checkUrl,this.interval)}this.fragment=fragment;var loc=this.location;var atRoot=loc.pathname.replace(/[^\/]$/,"$&/")===this.root;if(this._wantsHashChange&&this._wantsPushState&&!this._hasPushState&&!atRoot){this.fragment=this.getFragment(null,true);this.location.replace(this.root+this.location.search+"#"+this.fragment);return true}else if(this._wantsPushState&&this._hasPushState&&atRoot&&loc.hash){this.fragment=this.getHash().replace(routeStripper,"");this.history.replaceState({},document.title,this.root+this.fragment+loc.search)}if(!this.options.silent)return this.loadUrl()},stop:function(){Backbone.$(window).off("popstate",this.checkUrl).off("hashchange",this.checkUrl);clearInterval(this._checkUrlInterval);History.started=false},route:function(route,callback){this.handlers.unshift({route:route,callback:callback})},checkUrl:function(e){var current=this.getFragment();if(current===this.fragment&&this.iframe){current=this.getFragment(this.getHash(this.iframe))}if(current===this.fragment)return false;if(this.iframe)this.navigate(current);this.loadUrl()||this.loadUrl(this.getHash())},loadUrl:function(fragmentOverride){var fragment=this.fragment=this.getFragment(fragmentOverride);var matched=_.any(this.handlers,function(handler){if(handler.route.test(fragment)){handler.callback(fragment);return true}});return matched},navigate:function(fragment,options){if(!History.started)return false;if(!options||options===true)options={trigger:options};fragment=this.getFragment(fragment||"");if(this.fragment===fragment)return;this.fragment=fragment;var url=this.root+fragment;if(this._hasPushState){this.history[options.replace?"replaceState":"pushState"]({},document.title,url)}else if(this._wantsHashChange){this._updateHash(this.location,fragment,options.replace);if(this.iframe&&fragment!==this.getFragment(this.getHash(this.iframe))){if(!options.replace)this.iframe.document.open().close();this._updateHash(this.iframe.location,fragment,options.replace)}}else{return this.location.assign(url)}if(options.trigger)this.loadUrl(fragment)},_updateHash:function(location,fragment,replace){if(replace){var href=location.href.replace(/(javascript:|#).*$/,"");location.replace(href+"#"+fragment)}else{location.hash="#"+fragment}}});Backbone.history=new History;var extend=function(protoProps,staticProps){var parent=this;var child;if(protoProps&&_.has(protoProps,"constructor")){child=protoProps.constructor}else{child=function(){return parent.apply(this,arguments)}}_.extend(child,parent,staticProps);var Surrogate=function(){this.constructor=child};Surrogate.prototype=parent.prototype;child.prototype=new Surrogate;if(protoProps)_.extend(child.prototype,protoProps);child.__super__=parent.prototype;return child};Model.extend=Collection.extend=Router.extend=View.extend=History.extend=extend;var urlError=function(){throw new Error('A "url" property or function must be specified')};var wrapError=function(model,options){var error=options.error;options.error=function(resp){if(error)error(model,resp,options);model.trigger("error",model,resp,options)}}}).call(this);
/*
//@ sourceMappingURL=backbone-min.map
*/// Knockout JavaScript library v2.2.1
// (c) Steven Sanderson - http://knockoutjs.com/
// License: MIT (http://www.opensource.org/licenses/mit-license.php)
(function() {function k(j){throw j;}var n=!0,r=null,t=!1;function J(j){return function(){return j}};(function(j){var z=this||(0,eval)("this"),u=z.document,V=z.navigator,q=z.jQuery,H=z.JSON;!function(j){"function"===typeof require&&"object"===typeof exports&&"object"===typeof module?j(module.exports||exports):"function"===typeof define&&define.amd?define(["exports"],j):j(z.ko={})}(function(v){function na(a,d,c,e,f){var g=[];a=b.j(function(){var a=d(c,f)||[];0<g.length&&(b.a.$a(M(g),a),e&&b.r.L(e,r,[c,a,f]));g.splice(0,g.length);b.a.Q(g,a)},r,{Y:a,Ma:function(){return!b.a.nb(g)}});return{N:g,j:a.qa()?
a:j}}function M(a){for(;a.length&&!b.a.Z(a[0]);)a.splice(0,1);if(1<a.length){for(var d=a[0],c=a[a.length-1],e=[d];d!==c;){d=d.nextSibling;if(!d)return;e.push(d)}Array.prototype.splice.apply(a,[0,a.length].concat(e))}return a}function W(a,b,c,e,f){var g=Math.min,h=Math.max,l=[],m,A=a.length,p,j=b.length,w=j-A||1,F=A+j+1,q,u,x;for(m=0;m<=A;m++){u=q;l.push(q=[]);x=g(j,m+w);for(p=h(0,m-1);p<=x;p++)q[p]=p?m?a[m-1]===b[p-1]?u[p-1]:g(u[p]||F,q[p-1]||F)+1:p+1:m+1}g=[];h=[];w=[];m=A;for(p=j;m||p;)j=l[m][p]-
1,p&&j===l[m][p-1]?h.push(g[g.length]={status:c,value:b[--p],index:p}):m&&j===l[m-1][p]?w.push(g[g.length]={status:e,value:a[--m],index:m}):(g.push({status:"retained",value:b[--p]}),--m);if(h.length&&w.length){a=10*A;var s;for(b=c=0;(f||b<a)&&(s=h[c]);c++){for(e=0;l=w[e];e++)if(s.value===l.value){s.moved=l.index;l.moved=s.index;w.splice(e,1);b=e=0;break}b+=e}}return g.reverse()}function X(a,d,c,e,f){f=f||{};var g=a&&O(a),g=g&&g.ownerDocument,h=f.templateEngine||P;b.Aa.yb(c,h,g);c=h.renderTemplate(c,
e,f,g);("number"!=typeof c.length||0<c.length&&"number"!=typeof c[0].nodeType)&&k(Error("Template engine must return an array of DOM nodes"));g=t;switch(d){case "replaceChildren":b.e.O(a,c);g=n;break;case "replaceNode":b.a.$a(a,c);g=n;break;case "ignoreTargetNode":break;default:k(Error("Unknown renderMode: "+d))}g&&(Y(c,e),f.afterRender&&b.r.L(f.afterRender,r,[c,e.$data]));return c}function O(a){return a.nodeType?a:0<a.length?a[0]:r}function Y(a,d){if(a.length){var c=a[0],e=a[a.length-1];Z(c,e,function(a){b.Ea(d,
a)});Z(c,e,function(a){b.s.kb(a,[d])})}}function Z(a,d,c){var e;for(d=b.e.nextSibling(d);a&&(e=a)!==d;)a=b.e.nextSibling(e),(1===e.nodeType||8===e.nodeType)&&c(e)}function $(a,d,c){a=b.g.ba(a);for(var e=b.g.R,f=0;f<a.length;f++){var g=a[f].key;if(e.hasOwnProperty(g)){var h=e[g];"function"===typeof h?(g=h(a[f].value))&&k(Error(g)):h||k(Error("This template engine does not support the '"+g+"' binding within its templates"))}}a="ko.__tr_ambtns(function($context,$element){return(function(){return{ "+
b.g.ca(a)+" } })()})";return c.createJavaScriptEvaluatorBlock(a)+d}function aa(a,d,c,e){function f(a){return function(){return l[a]}}function g(){return l}var h=0,l,m,A=b.a.f.get(a,ba);d||(A&&k(Error("You cannot apply bindings multiple times to the same element.")),b.a.f.set(a,ba,n));b.j(function(){var p=c&&c instanceof b.w?c:new b.w(b.a.d(c)),q=p.$data;!A&&e&&b.gb(a,p);if(l=("function"==typeof d?d(p,a):d)||b.K.instance.getBindings(a,p))0===h&&(h=1,b.a.C(l,function(d){var c=b.c[d];c&&8===a.nodeType&&
!b.e.J[d]&&k(Error("The binding '"+d+"' cannot be used with virtual elements"));if(c&&"function"==typeof c.init&&(c=(0,c.init)(a,f(d),g,q,p))&&c.controlsDescendantBindings)m!==j&&k(Error("Multiple bindings ("+m+" and "+d+") are trying to control descendant bindings of the same element. You cannot use these bindings together on the same element.")),m=d}),h=2),2===h&&b.a.C(l,function(d){var c=b.c[d];c&&"function"==typeof c.update&&(0,c.update)(a,f(d),g,q,p)})},r,{Y:a});return{Qb:m===j}}function ca(a,
d,c){var e=n,f=1===d.nodeType;f&&b.e.Va(d);if(f&&c||b.K.instance.nodeHasBindings(d))e=aa(d,r,a,c).Qb;e&&da(a,d,!f)}function da(a,d,c){for(var e=b.e.firstChild(d);d=e;)e=b.e.nextSibling(d),ca(a,d,c)}function ea(a,b){var c=fa(a,b);return c?0<c.length?c[c.length-1].nextSibling:a.nextSibling:r}function fa(a,b){for(var c=a,e=1,f=[];c=c.nextSibling;){if(K(c)&&(e--,0===e))return f;f.push(c);B(c)&&e++}b||k(Error("Cannot find closing comment tag to match: "+a.nodeValue));return r}function K(a){return 8==a.nodeType&&
(L?a.text:a.nodeValue).match(oa)}function B(a){return 8==a.nodeType&&(L?a.text:a.nodeValue).match(pa)}function Q(a,b){for(var c=r;a!=c;)c=a,a=a.replace(qa,function(a,c){return b[c]});return a}function ra(){var a=[],d=[];this.save=function(c,e){var f=b.a.i(a,c);0<=f?d[f]=e:(a.push(c),d.push(e))};this.get=function(c){c=b.a.i(a,c);return 0<=c?d[c]:j}}function ga(a,b,c){function e(e){var g=b(a[e]);switch(typeof g){case "boolean":case "number":case "string":case "function":f[e]=g;break;case "object":case "undefined":var h=
c.get(g);f[e]=h!==j?h:ga(g,b,c)}}c=c||new ra;a=b(a);if(!("object"==typeof a&&a!==r&&a!==j&&!(a instanceof Date)))return a;var f=a instanceof Array?[]:{};c.save(a,f);var g=a;if(g instanceof Array){for(var h=0;h<g.length;h++)e(h);"function"==typeof g.toJSON&&e("toJSON")}else for(h in g)e(h);return f}function ha(a,d){if(a)if(8==a.nodeType){var c=b.s.Wa(a.nodeValue);c!=r&&d.push({vb:a,Ib:c})}else if(1==a.nodeType)for(var c=0,e=a.childNodes,f=e.length;c<f;c++)ha(e[c],d)}function R(a,b){for(var c in a)a.hasOwnProperty(c)&&
b(c,a[c])}function S(a,d){if("input"!==b.a.u(a)||!a.type||"click"!=d.toLowerCase())return t;var c=a.type;return"checkbox"==c||"radio"==c}function T(a,d,c,e){b.c[a]={init:function(a){b.a.f.set(a,ia,{});return{controlsDescendantBindings:n}},update:function(a,g,h,l,m){h=b.a.f.get(a,ia);g=b.a.d(g());l=!c!==!g;var j=!h.ab;if(j||d||l!==h.tb)j&&(h.ab=b.a.Ka(b.e.childNodes(a),n)),l?(j||b.e.O(a,b.a.Ka(h.ab)),b.Fa(e?e(m,g):m,a)):b.e.$(a),h.tb=l}};b.g.R[a]=t;b.e.J[a]=n}function ja(a,d,c){c&&d!==b.k.q(a)&&b.k.V(a,
d);d!==b.k.q(a)&&b.r.L(b.a.Ca,r,[a,"change"])}var b="undefined"!==typeof v?v:{};b.b=function(a,d){for(var c=a.split("."),e=b,f=0;f<c.length-1;f++)e=e[c[f]];e[c[c.length-1]]=d};b.p=function(a,b,c){a[b]=c};b.version="2.2.1";b.b("version",b.version);v=b;var sa=/^(\s|\u00A0)+|(\s|\u00A0)+$/g,y={},ka={};y[V&&/Firefox\/2/i.test(V.userAgent)?"KeyboardEvent":"UIEvents"]=["keyup","keydown","keypress"];y.MouseEvents="click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave".split(" ");
R(y,function(a,b){if(b.length)for(var c=0,e=b.length;c<e;c++)ka[b[c]]=a});var ta={propertychange:n};if(y=u){for(var y=3,la=u.createElement("div"),ua=la.getElementsByTagName("i");la.innerHTML="\x3c!--[if gt IE "+ ++y+"]><i></i><![endif]--\x3e",ua[0];);y=4<y?y:j}var D=y;v.a={Pa:["authenticity_token",/^__RequestVerificationToken(_.*)?$/],o:function(a,b){for(var c=0,e=a.length;c<e;c++)b(a[c])},i:function(a,b){if("function"==typeof Array.prototype.indexOf)return Array.prototype.indexOf.call(a,b);for(var c=
0,e=a.length;c<e;c++)if(a[c]===b)return c;return-1},Ha:function(a,b,c){for(var e=0,f=a.length;e<f;e++)if(b.call(c,a[e]))return a[e];return r},ha:function(a,d){var c=b.a.i(a,d);0<=c&&a.splice(c,1)},Ia:function(a){a=a||[];for(var d=[],c=0,e=a.length;c<e;c++)0>b.a.i(d,a[c])&&d.push(a[c]);return d},X:function(a,b){a=a||[];for(var c=[],e=0,f=a.length;e<f;e++)c.push(b(a[e]));return c},ga:function(a,b){a=a||[];for(var c=[],e=0,f=a.length;e<f;e++)b(a[e])&&c.push(a[e]);return c},Q:function(a,b){if(b instanceof
Array)a.push.apply(a,b);else for(var c=0,e=b.length;c<e;c++)a.push(b[c]);return a},mb:function(a,b,c){var e=a.indexOf?a.indexOf(b):utils.i(a,b);0>e?c&&a.push(b):c||a.splice(e,1)},extend:function(a,b){if(b)for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return a},C:R,la:function(a){for(;a.firstChild;)b.removeNode(a.firstChild)},Kb:function(a){a=b.a.M(a);for(var d=u.createElement("div"),c=0,e=a.length;c<e;c++)d.appendChild(b.z(a[c]));return d},Ka:function(a,d){for(var c=0,e=a.length,f=[];c<e;c++){var g=
a[c].cloneNode(n);f.push(d?b.z(g):g)}return f},O:function(a,d){b.a.la(a);if(d)for(var c=0,e=d.length;c<e;c++)a.appendChild(d[c])},$a:function(a,d){var c=a.nodeType?[a]:a;if(0<c.length){for(var e=c[0],f=e.parentNode,g=0,h=d.length;g<h;g++)f.insertBefore(d[g],e);g=0;for(h=c.length;g<h;g++)b.removeNode(c[g])}},eb:function(a,b){7>D?a.setAttribute("selected",b):a.selected=b},D:function(a){return(a||"").replace(sa,"")},Ub:function(a,d){for(var c=[],e=(a||"").split(d),f=0,g=e.length;f<g;f++){var h=b.a.D(e[f]);
""!==h&&c.push(h)}return c},Rb:function(a,b){a=a||"";return b.length>a.length?t:a.substring(0,b.length)===b},wb:function(a,b){if(b.compareDocumentPosition)return 16==(b.compareDocumentPosition(a)&16);for(;a!=r;){if(a==b)return n;a=a.parentNode}return t},Z:function(a){return b.a.wb(a,a.ownerDocument)},nb:function(a){return!!b.a.Ha(a,b.a.Z)},u:function(a){return a&&a.tagName&&a.tagName.toLowerCase()},n:function(a,b,c){var e=D&&ta[b];if(!e&&"undefined"!=typeof q){if(S(a,b)){var f=c;c=function(a,b){var c=
this.checked;b&&(this.checked=b.qb!==n);f.call(this,a);this.checked=c}}q(a).bind(b,c)}else!e&&"function"==typeof a.addEventListener?a.addEventListener(b,c,t):"undefined"!=typeof a.attachEvent?a.attachEvent("on"+b,function(b){c.call(a,b)}):k(Error("Browser doesn't support addEventListener or attachEvent"))},Ca:function(a,b){(!a||!a.nodeType)&&k(Error("element must be a DOM node when calling triggerEvent"));if("undefined"!=typeof q){var c=[];S(a,b)&&c.push({qb:a.checked});q(a).trigger(b,c)}else"function"==
typeof u.createEvent?"function"==typeof a.dispatchEvent?(c=u.createEvent(ka[b]||"HTMLEvents"),c.initEvent(b,n,n,z,0,0,0,0,0,t,t,t,t,0,a),a.dispatchEvent(c)):k(Error("The supplied element doesn't support dispatchEvent")):"undefined"!=typeof a.fireEvent?(S(a,b)&&(a.checked=a.checked!==n),a.fireEvent("on"+b)):k(Error("Browser doesn't support triggering events"))},d:function(a){return b.S(a)?a():a},va:function(a){return b.S(a)?a.t():a},ea:function(a,d,c){if(d){var e=/\S+/g,f=a.className.match(e)||[];
b.a.o(d.match(e),function(a){b.a.mb(f,a,c)});a.className=f.join(" ")}},fb:function(a,d){var c=b.a.d(d);if(c===r||c===j)c="";if(3===a.nodeType)a.data=c;else{var e=b.e.firstChild(a);!e||3!=e.nodeType||b.e.nextSibling(e)?b.e.O(a,[u.createTextNode(c)]):e.data=c;b.a.zb(a)}},cb:function(a,b){a.name=b;if(7>=D)try{a.mergeAttributes(u.createElement("<input name='"+a.name+"'/>"),t)}catch(c){}},zb:function(a){9<=D&&(a=1==a.nodeType?a:a.parentNode,a.style&&(a.style.zoom=a.style.zoom))},xb:function(a){if(9<=D){var b=
a.style.width;a.style.width=0;a.style.width=b}},Ob:function(a,d){a=b.a.d(a);d=b.a.d(d);for(var c=[],e=a;e<=d;e++)c.push(e);return c},M:function(a){for(var b=[],c=0,e=a.length;c<e;c++)b.push(a[c]);return b},Sb:6===D,Tb:7===D,aa:D,Qa:function(a,d){for(var c=b.a.M(a.getElementsByTagName("input")).concat(b.a.M(a.getElementsByTagName("textarea"))),e="string"==typeof d?function(a){return a.name===d}:function(a){return d.test(a.name)},f=[],g=c.length-1;0<=g;g--)e(c[g])&&f.push(c[g]);return f},Lb:function(a){return"string"==
typeof a&&(a=b.a.D(a))?H&&H.parse?H.parse(a):(new Function("return "+a))():r},ya:function(a,d,c){(!H||!H.stringify)&&k(Error("Cannot find JSON.stringify(). Some browsers (e.g., IE < 8) don't support it natively, but you can overcome this by adding a script reference to json2.js, downloadable from http://www.json.org/json2.js"));return H.stringify(b.a.d(a),d,c)},Mb:function(a,d,c){c=c||{};var e=c.params||{},f=c.includeFields||this.Pa,g=a;if("object"==typeof a&&"form"===b.a.u(a))for(var g=a.action,
h=f.length-1;0<=h;h--)for(var l=b.a.Qa(a,f[h]),m=l.length-1;0<=m;m--)e[l[m].name]=l[m].value;d=b.a.d(d);var j=u.createElement("form");j.style.display="none";j.action=g;j.method="post";for(var p in d)a=u.createElement("input"),a.name=p,a.value=b.a.ya(b.a.d(d[p])),j.appendChild(a);R(e,function(a,b){var c=u.createElement("input");c.name=a;c.value=b;j.appendChild(c)});u.body.appendChild(j);c.submitter?c.submitter(j):j.submit();setTimeout(function(){j.parentNode.removeChild(j)},0)}};b.b("utils",b.a);b.b("utils.arrayForEach",
b.a.o);b.b("utils.arrayFirst",b.a.Ha);b.b("utils.arrayFilter",b.a.ga);b.b("utils.arrayGetDistinctValues",b.a.Ia);b.b("utils.arrayIndexOf",b.a.i);b.b("utils.arrayMap",b.a.X);b.b("utils.arrayPushAll",b.a.Q);b.b("utils.arrayRemoveItem",b.a.ha);b.b("utils.extend",b.a.extend);b.b("utils.fieldsIncludedWithJsonPost",b.a.Pa);b.b("utils.getFormFields",b.a.Qa);b.b("utils.peekObservable",b.a.va);b.b("utils.postJson",b.a.Mb);b.b("utils.parseJson",b.a.Lb);b.b("utils.registerEventHandler",b.a.n);b.b("utils.stringifyJson",
b.a.ya);b.b("utils.range",b.a.Ob);b.b("utils.toggleDomNodeCssClass",b.a.ea);b.b("utils.triggerEvent",b.a.Ca);b.b("utils.unwrapObservable",b.a.d);Function.prototype.bind||(Function.prototype.bind=function(a){var b=this,c=Array.prototype.slice.call(arguments);a=c.shift();return function(){return b.apply(a,c.concat(Array.prototype.slice.call(arguments)))}});b.a.f=new function(){var a=0,d="__ko__"+(new Date).getTime(),c={};return{get:function(a,c){var d=b.a.f.ma(a,t);return d===j?j:d[c]},set:function(a,
c,d){d===j&&b.a.f.ma(a,t)===j||(b.a.f.ma(a,n)[c]=d)},ma:function(b,f){var g=b[d];if(!g||!("null"!==g&&c[g])){if(!f)return j;g=b[d]="ko"+a++;c[g]={}}return c[g]},clear:function(a){var b=a[d];return b?(delete c[b],a[d]=r,n):t}}};b.b("utils.domData",b.a.f);b.b("utils.domData.clear",b.a.f.clear);b.a.G=new function(){function a(a,d){var e=b.a.f.get(a,c);e===j&&d&&(e=[],b.a.f.set(a,c,e));return e}function d(c){var e=a(c,t);if(e)for(var e=e.slice(0),l=0;l<e.length;l++)e[l](c);b.a.f.clear(c);"function"==
typeof q&&"function"==typeof q.cleanData&&q.cleanData([c]);if(f[c.nodeType])for(e=c.firstChild;c=e;)e=c.nextSibling,8===c.nodeType&&d(c)}var c="__ko_domNodeDisposal__"+(new Date).getTime(),e={1:n,8:n,9:n},f={1:n,9:n};return{Da:function(b,c){"function"!=typeof c&&k(Error("Callback must be a function"));a(b,n).push(c)},Za:function(d,e){var f=a(d,t);f&&(b.a.ha(f,e),0==f.length&&b.a.f.set(d,c,j))},z:function(a){if(e[a.nodeType]&&(d(a),f[a.nodeType])){var c=[];b.a.Q(c,a.getElementsByTagName("*"));for(var l=
0,m=c.length;l<m;l++)d(c[l])}return a},removeNode:function(a){b.z(a);a.parentNode&&a.parentNode.removeChild(a)}}};b.z=b.a.G.z;b.removeNode=b.a.G.removeNode;b.b("cleanNode",b.z);b.b("removeNode",b.removeNode);b.b("utils.domNodeDisposal",b.a.G);b.b("utils.domNodeDisposal.addDisposeCallback",b.a.G.Da);b.b("utils.domNodeDisposal.removeDisposeCallback",b.a.G.Za);b.a.ua=function(a){var d;if("undefined"!=typeof q)if(q.parseHTML)d=q.parseHTML(a)||[];else{if((d=q.clean([a]))&&d[0]){for(a=d[0];a.parentNode&&
11!==a.parentNode.nodeType;)a=a.parentNode;a.parentNode&&a.parentNode.removeChild(a)}}else{var c=b.a.D(a).toLowerCase();d=u.createElement("div");c=c.match(/^<(thead|tbody|tfoot)/)&&[1,"<table>","</table>"]||!c.indexOf("<tr")&&[2,"<table><tbody>","</tbody></table>"]||(!c.indexOf("<td")||!c.indexOf("<th"))&&[3,"<table><tbody><tr>","</tr></tbody></table>"]||[0,"",""];a="ignored<div>"+c[1]+a+c[2]+"</div>";for("function"==typeof z.innerShiv?d.appendChild(z.innerShiv(a)):d.innerHTML=a;c[0]--;)d=d.lastChild;
d=b.a.M(d.lastChild.childNodes)}return d};b.a.da=function(a,d){b.a.la(a);d=b.a.d(d);if(d!==r&&d!==j)if("string"!=typeof d&&(d=d.toString()),"undefined"!=typeof q)q(a).html(d);else for(var c=b.a.ua(d),e=0;e<c.length;e++)a.appendChild(c[e])};b.b("utils.parseHtmlFragment",b.a.ua);b.b("utils.setHtml",b.a.da);var U={};b.s={sa:function(a){"function"!=typeof a&&k(Error("You can only pass a function to ko.memoization.memoize()"));var b=(4294967296*(1+Math.random())|0).toString(16).substring(1)+(4294967296*
(1+Math.random())|0).toString(16).substring(1);U[b]=a;return"\x3c!--[ko_memo:"+b+"]--\x3e"},jb:function(a,b){var c=U[a];c===j&&k(Error("Couldn't find any memo with ID "+a+". Perhaps it's already been unmemoized."));try{return c.apply(r,b||[]),n}finally{delete U[a]}},kb:function(a,d){var c=[];ha(a,c);for(var e=0,f=c.length;e<f;e++){var g=c[e].vb,h=[g];d&&b.a.Q(h,d);b.s.jb(c[e].Ib,h);g.nodeValue="";g.parentNode&&g.parentNode.removeChild(g)}},Wa:function(a){return(a=a.match(/^\[ko_memo\:(.*?)\]$/))?
a[1]:r}};b.b("memoization",b.s);b.b("memoization.memoize",b.s.sa);b.b("memoization.unmemoize",b.s.jb);b.b("memoization.parseMemoText",b.s.Wa);b.b("memoization.unmemoizeDomNodeAndDescendants",b.s.kb);b.Oa={throttle:function(a,d){a.throttleEvaluation=d;var c=r;return b.j({read:a,write:function(b){clearTimeout(c);c=setTimeout(function(){a(b)},d)}})},notify:function(a,d){a.equalityComparer="always"==d?J(t):b.m.fn.equalityComparer;return a}};b.b("extenders",b.Oa);b.hb=function(a,d,c){this.target=a;this.ia=
d;this.ub=c;b.p(this,"dispose",this.A)};b.hb.prototype.A=function(){this.Fb=n;this.ub()};b.U=function(){this.F={};b.a.extend(this,b.U.fn);b.p(this,"subscribe",this.za);b.p(this,"extend",this.extend);b.p(this,"getSubscriptionsCount",this.Bb)};b.U.fn={za:function(a,d,c){c=c||"change";var e=new b.hb(this,d?a.bind(d):a,function(){b.a.ha(this.F[c],e)}.bind(this));this.F[c]||(this.F[c]=[]);this.F[c].push(e);return e},notifySubscribers:function(a,d){d=d||"change";this.F[d]&&b.r.L(function(){b.a.o(this.F[d].slice(0),
function(b){b&&b.Fb!==n&&b.ia(a)})},this)},Bb:function(){var a=0;b.a.C(this.F,function(b,c){a+=c.length});return a},extend:function(a){var d=this;a&&b.a.C(a,function(a,e){var f=b.Oa[a];"function"==typeof f&&(d=f(d,e))});return d}};b.Sa=function(a){return"function"==typeof a.za&&"function"==typeof a.notifySubscribers};b.b("subscribable",b.U);b.b("isSubscribable",b.Sa);var G=[];b.r={pb:function(a){G.push({ia:a,Na:[]})},end:function(){G.pop()},Ya:function(a){b.Sa(a)||k(Error("Only subscribable things can act as dependencies"));
if(0<G.length){var d=G[G.length-1];d&&!(0<=b.a.i(d.Na,a))&&(d.Na.push(a),d.ia(a))}},L:function(a,b,c){try{return G.push(r),a.apply(b,c||[])}finally{G.pop()}}};var va={undefined:n,"boolean":n,number:n,string:n};b.m=function(a){function d(){if(0<arguments.length){if(!d.equalityComparer||!d.equalityComparer(c,arguments[0]))d.I(),c=arguments[0],d.H();return this}b.r.Ya(d);return c}var c=a;b.U.call(d);d.t=function(){return c};d.H=function(){d.notifySubscribers(c)};d.I=function(){d.notifySubscribers(c,
"beforeChange")};b.a.extend(d,b.m.fn);b.p(d,"peek",d.t);b.p(d,"valueHasMutated",d.H);b.p(d,"valueWillMutate",d.I);return d};b.m.fn={equalityComparer:function(a,b){return a===r||typeof a in va?a===b:t}};var I=b.m.Nb="__ko_proto__";b.m.fn[I]=b.m;b.na=function(a,d){return a===r||a===j||a[I]===j?t:a[I]===d?n:b.na(a[I],d)};b.S=function(a){return b.na(a,b.m)};b.Ta=function(a){return"function"==typeof a&&a[I]===b.m||"function"==typeof a&&a[I]===b.j&&a.Cb?n:t};b.b("observable",b.m);b.b("isObservable",b.S);
b.b("isWriteableObservable",b.Ta);b.T=function(a){0==arguments.length&&(a=[]);a!==r&&(a!==j&&!("length"in a))&&k(Error("The argument passed when initializing an observable array must be an array, or null, or undefined."));var d=b.m(a);b.a.extend(d,b.T.fn);return d};b.T.fn={remove:function(a){for(var b=this.t(),c=[],e="function"==typeof a?a:function(b){return b===a},f=0;f<b.length;f++){var g=b[f];e(g)&&(0===c.length&&this.I(),c.push(g),b.splice(f,1),f--)}c.length&&this.H();return c},removeAll:function(a){if(a===
j){var d=this.t(),c=d.slice(0);this.I();d.splice(0,d.length);this.H();return c}return!a?[]:this.remove(function(c){return 0<=b.a.i(a,c)})},destroy:function(a){var b=this.t(),c="function"==typeof a?a:function(b){return b===a};this.I();for(var e=b.length-1;0<=e;e--)c(b[e])&&(b[e]._destroy=n);this.H()},destroyAll:function(a){return a===j?this.destroy(J(n)):!a?[]:this.destroy(function(d){return 0<=b.a.i(a,d)})},indexOf:function(a){var d=this();return b.a.i(d,a)},replace:function(a,b){var c=this.indexOf(a);
0<=c&&(this.I(),this.t()[c]=b,this.H())}};b.a.o("pop push reverse shift sort splice unshift".split(" "),function(a){b.T.fn[a]=function(){var b=this.t();this.I();b=b[a].apply(b,arguments);this.H();return b}});b.a.o(["slice"],function(a){b.T.fn[a]=function(){var b=this();return b[a].apply(b,arguments)}});b.b("observableArray",b.T);b.j=function(a,d,c){function e(){b.a.o(x,function(a){a.A()});x=[]}function f(){var a=h.throttleEvaluation;a&&0<=a?(clearTimeout(s),s=setTimeout(g,a)):g()}function g(){if(!p)if(A&&
N())C();else{p=n;try{var a=b.a.X(x,function(a){return a.target});b.r.pb(function(c){var d;0<=(d=b.a.i(a,c))?a[d]=j:x.push(c.za(f))});for(var c=q.call(d),e=a.length-1;0<=e;e--)a[e]&&x.splice(e,1)[0].A();A=n;h.notifySubscribers(m,"beforeChange");m=c}finally{b.r.end()}h.notifySubscribers(m);p=t;x.length||C()}}function h(){if(0<arguments.length)return"function"===typeof u?u.apply(d,arguments):k(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.")),
this;A||g();b.r.Ya(h);return m}function l(){return!A||0<x.length}var m,A=t,p=t,q=a;q&&"object"==typeof q?(c=q,q=c.read):(c=c||{},q||(q=c.read));"function"!=typeof q&&k(Error("Pass a function that returns the value of the ko.computed"));var u=c.write,F=c.disposeWhenNodeIsRemoved||c.Y||r,N=c.disposeWhen||c.Ma||J(t),C=e,x=[],s=r;d||(d=c.owner);h.t=function(){A||g();return m};h.Ab=function(){return x.length};h.Cb="function"===typeof c.write;h.A=function(){C()};h.qa=l;b.U.call(h);b.a.extend(h,b.j.fn);
b.p(h,"peek",h.t);b.p(h,"dispose",h.A);b.p(h,"isActive",h.qa);b.p(h,"getDependenciesCount",h.Ab);c.deferEvaluation!==n&&g();if(F&&l()){C=function(){b.a.G.Za(F,C);e()};b.a.G.Da(F,C);var E=N,N=function(){return!b.a.Z(F)||E()}}return h};b.Eb=function(a){return b.na(a,b.j)};v=b.m.Nb;b.j[v]=b.m;b.j.fn={};b.j.fn[v]=b.j;b.b("dependentObservable",b.j);b.b("computed",b.j);b.b("isComputed",b.Eb);b.ib=function(a){0==arguments.length&&k(Error("When calling ko.toJS, pass the object you want to convert."));return ga(a,
function(a){for(var c=0;b.S(a)&&10>c;c++)a=a();return a})};b.toJSON=function(a,d,c){a=b.ib(a);return b.a.ya(a,d,c)};b.b("toJS",b.ib);b.b("toJSON",b.toJSON);b.k={q:function(a){switch(b.a.u(a)){case "option":return a.__ko__hasDomDataOptionValue__===n?b.a.f.get(a,b.c.options.ta):7>=b.a.aa?a.getAttributeNode("value").specified?a.value:a.text:a.value;case "select":return 0<=a.selectedIndex?b.k.q(a.options[a.selectedIndex]):j;default:return a.value}},V:function(a,d){switch(b.a.u(a)){case "option":switch(typeof d){case "string":b.a.f.set(a,
b.c.options.ta,j);"__ko__hasDomDataOptionValue__"in a&&delete a.__ko__hasDomDataOptionValue__;a.value=d;break;default:b.a.f.set(a,b.c.options.ta,d),a.__ko__hasDomDataOptionValue__=n,a.value="number"===typeof d?d:""}break;case "select":for(var c=a.options.length-1;0<=c;c--)if(b.k.q(a.options[c])==d){a.selectedIndex=c;break}break;default:if(d===r||d===j)d="";a.value=d}}};b.b("selectExtensions",b.k);b.b("selectExtensions.readValue",b.k.q);b.b("selectExtensions.writeValue",b.k.V);var qa=/\@ko_token_(\d+)\@/g,
wa=["true","false"],xa=/^(?:[$_a-z][$\w]*|(.+)(\.\s*[$_a-z][$\w]*|\[.+\]))$/i;b.g={R:[],ba:function(a){var d=b.a.D(a);if(3>d.length)return[];"{"===d.charAt(0)&&(d=d.substring(1,d.length-1));a=[];for(var c=r,e,f=0;f<d.length;f++){var g=d.charAt(f);if(c===r)switch(g){case '"':case "'":case "/":c=f,e=g}else if(g==e&&"\\"!==d.charAt(f-1)){g=d.substring(c,f+1);a.push(g);var h="@ko_token_"+(a.length-1)+"@",d=d.substring(0,c)+h+d.substring(f+1),f=f-(g.length-h.length),c=r}}e=c=r;for(var l=0,m=r,f=0;f<d.length;f++){g=
d.charAt(f);if(c===r)switch(g){case "{":c=f;m=g;e="}";break;case "(":c=f;m=g;e=")";break;case "[":c=f,m=g,e="]"}g===m?l++:g===e&&(l--,0===l&&(g=d.substring(c,f+1),a.push(g),h="@ko_token_"+(a.length-1)+"@",d=d.substring(0,c)+h+d.substring(f+1),f-=g.length-h.length,c=r))}e=[];d=d.split(",");c=0;for(f=d.length;c<f;c++)l=d[c],m=l.indexOf(":"),0<m&&m<l.length-1?(g=l.substring(m+1),e.push({key:Q(l.substring(0,m),a),value:Q(g,a)})):e.push({unknown:Q(l,a)});return e},ca:function(a){var d="string"===typeof a?
b.g.ba(a):a,c=[];a=[];for(var e,f=0;e=d[f];f++)if(0<c.length&&c.push(","),e.key){var g;a:{g=e.key;var h=b.a.D(g);switch(h.length&&h.charAt(0)){case "'":case '"':break a;default:g="'"+h+"'"}}e=e.value;c.push(g);c.push(":");c.push(e);e=b.a.D(e);0<=b.a.i(wa,b.a.D(e).toLowerCase())?e=t:(h=e.match(xa),e=h===r?t:h[1]?"Object("+h[1]+")"+h[2]:e);e&&(0<a.length&&a.push(", "),a.push(g+" : function(__ko_value) { "+e+" = __ko_value; }"))}else e.unknown&&c.push(e.unknown);d=c.join("");0<a.length&&(d=d+", '_ko_property_writers' : { "+
a.join("")+" } ");return d},Hb:function(a,d){for(var c=0;c<a.length;c++)if(b.a.D(a[c].key)==d)return n;return t},fa:function(a,d,c,e,f){if(!a||!b.S(a)){if((a=d()._ko_property_writers)&&a[c])a[c](e)}else b.Ta(a)&&(!f||a.t()!==e)&&a(e)}};b.b("expressionRewriting",b.g);b.b("expressionRewriting.bindingRewriteValidators",b.g.R);b.b("expressionRewriting.parseObjectLiteral",b.g.ba);b.b("expressionRewriting.preProcessBindings",b.g.ca);b.b("jsonExpressionRewriting",b.g);b.b("jsonExpressionRewriting.insertPropertyAccessorsIntoJson",
b.g.ca);var L=u&&"\x3c!--test--\x3e"===u.createComment("test").text,pa=L?/^\x3c!--\s*ko(?:\s+(.+\s*\:[\s\S]*))?\s*--\x3e$/:/^\s*ko(?:\s+(.+\s*\:[\s\S]*))?\s*$/,oa=L?/^\x3c!--\s*\/ko\s*--\x3e$/:/^\s*\/ko\s*$/,ya={ul:n,ol:n};b.e={J:{},childNodes:function(a){return B(a)?fa(a):a.childNodes},$:function(a){if(B(a)){a=b.e.childNodes(a);for(var d=0,c=a.length;d<c;d++)b.removeNode(a[d])}else b.a.la(a)},O:function(a,d){if(B(a)){b.e.$(a);for(var c=a.nextSibling,e=0,f=d.length;e<f;e++)c.parentNode.insertBefore(d[e],
c)}else b.a.O(a,d)},Xa:function(a,b){B(a)?a.parentNode.insertBefore(b,a.nextSibling):a.firstChild?a.insertBefore(b,a.firstChild):a.appendChild(b)},Ra:function(a,d,c){c?B(a)?a.parentNode.insertBefore(d,c.nextSibling):c.nextSibling?a.insertBefore(d,c.nextSibling):a.appendChild(d):b.e.Xa(a,d)},firstChild:function(a){return!B(a)?a.firstChild:!a.nextSibling||K(a.nextSibling)?r:a.nextSibling},nextSibling:function(a){B(a)&&(a=ea(a));return a.nextSibling&&K(a.nextSibling)?r:a.nextSibling},lb:function(a){return(a=
B(a))?a[1]:r},Va:function(a){if(ya[b.a.u(a)]){var d=a.firstChild;if(d){do if(1===d.nodeType){var c;c=d.firstChild;var e=r;if(c){do if(e)e.push(c);else if(B(c)){var f=ea(c,n);f?c=f:e=[c]}else K(c)&&(e=[c]);while(c=c.nextSibling)}if(c=e){e=d.nextSibling;for(f=0;f<c.length;f++)e?a.insertBefore(c[f],e):a.appendChild(c[f])}}while(d=d.nextSibling)}}}};b.b("virtualElements",b.e);b.b("virtualElements.allowedBindings",b.e.J);b.b("virtualElements.emptyNode",b.e.$);b.b("virtualElements.insertAfter",b.e.Ra);
b.b("virtualElements.prepend",b.e.Xa);b.b("virtualElements.setDomNodeChildren",b.e.O);b.K=function(){this.Ja={}};b.a.extend(b.K.prototype,{nodeHasBindings:function(a){switch(a.nodeType){case 1:return a.getAttribute("data-bind")!=r;case 8:return b.e.lb(a)!=r;default:return t}},getBindings:function(a,b){var c=this.getBindingsString(a,b);return c?this.parseBindingsString(c,b,a):r},getBindingsString:function(a){switch(a.nodeType){case 1:return a.getAttribute("data-bind");case 8:return b.e.lb(a);default:return r}},
parseBindingsString:function(a,d,c){try{var e;if(!(e=this.Ja[a])){var f=this.Ja,g,h="with($context){with($data||{}){return{"+b.g.ca(a)+"}}}";g=new Function("$context","$element",h);e=f[a]=g}return e(d,c)}catch(l){l.message="Unable to parse bindings.\nBindings value: "+a+"\nMessage: "+l.message,k(l)}}});b.K.instance=new b.K;b.b("bindingProvider",b.K);b.c={};b.w=function(a,d,c){d?(b.a.extend(this,d),this.$parentContext=d,this.$parent=d.$data,this.$parents=(d.$parents||[]).slice(0),this.$parents.unshift(this.$parent)):
(this.$parents=[],this.$root=a,this.ko=b);this.$data=a;c&&(this[c]=a)};b.w.prototype.createChildContext=function(a,d){return new b.w(a,this,d)};b.w.prototype.extend=function(a){var d=b.a.extend(new b.w,this);return b.a.extend(d,a)};var ba="__ko_boundElement";b.gb=function(a,d){if(2==arguments.length)b.a.f.set(a,"__ko_bindingContext__",d);else return b.a.f.get(a,"__ko_bindingContext__")};b.Ga=function(a,d,c){1===a.nodeType&&b.e.Va(a);return aa(a,d,c,n)};b.Fa=function(a,b){(1===b.nodeType||8===b.nodeType)&&
da(a,b,n)};b.Ea=function(a,b){b&&(1!==b.nodeType&&8!==b.nodeType)&&k(Error("ko.applyBindings: first parameter should be your view model; second parameter should be a DOM node"));b=b||z.document.body;ca(a,b,n)};b.ka=function(a){switch(a.nodeType){case 1:case 8:var d=b.gb(a);if(d)return d;if(a.parentNode)return b.ka(a.parentNode)}return j};b.sb=function(a){return(a=b.ka(a))?a.$data:j};b.b("bindingHandlers",b.c);b.b("applyBindings",b.Ea);b.b("applyBindingsToDescendants",b.Fa);b.b("applyBindingsToNode",
b.Ga);b.b("contextFor",b.ka);b.b("dataFor",b.sb);var ma={"class":"className","for":"htmlFor"};b.c.attr={update:function(a,d){var c=b.a.d(d())||{};b.a.C(c,function(c,d){d=b.a.d(d);var g=d===t||d===r||d===j;g&&a.removeAttribute(c);8>=b.a.aa&&c in ma?(c=ma[c],g?a.removeAttribute(c):a[c]=d):g||a.setAttribute(c,d.toString());"name"===c&&b.a.cb(a,g?"":d.toString())})}};b.c.checked={init:function(a,d,c){b.a.n(a,"click",function(){var e;if("checkbox"==a.type)e=a.checked;else if("radio"==a.type&&a.checked)e=
a.value;else return;var f=d(),g=b.a.d(f);"checkbox"==a.type&&g instanceof Array?(e=b.a.i(g,a.value),a.checked&&0>e?f.push(a.value):!a.checked&&0<=e&&f.splice(e,1)):b.g.fa(f,c,"checked",e,n)});"radio"==a.type&&!a.name&&b.c.uniqueName.init(a,J(n))},update:function(a,d){var c=b.a.d(d());"checkbox"==a.type?a.checked=c instanceof Array?0<=b.a.i(c,a.value):c:"radio"==a.type&&(a.checked=a.value==c)}};b.c.css={update:function(a,d){var c=b.a.d(d());"object"==typeof c?b.a.C(c,function(c,d){d=b.a.d(d);b.a.ea(a,
c,d)}):(c=String(c||""),b.a.ea(a,a.__ko__cssValue,t),a.__ko__cssValue=c,b.a.ea(a,c,n))}};b.c.enable={update:function(a,d){var c=b.a.d(d());c&&a.disabled?a.removeAttribute("disabled"):!c&&!a.disabled&&(a.disabled=n)}};b.c.disable={update:function(a,d){b.c.enable.update(a,function(){return!b.a.d(d())})}};b.c.event={init:function(a,d,c,e){var f=d()||{};b.a.C(f,function(f){"string"==typeof f&&b.a.n(a,f,function(a){var l,m=d()[f];if(m){var j=c();try{var p=b.a.M(arguments);p.unshift(e);l=m.apply(e,p)}finally{l!==
n&&(a.preventDefault?a.preventDefault():a.returnValue=t)}j[f+"Bubble"]===t&&(a.cancelBubble=n,a.stopPropagation&&a.stopPropagation())}})})}};b.c.foreach={Ua:function(a){return function(){var d=a(),c=b.a.va(d);if(!c||"number"==typeof c.length)return{foreach:d,templateEngine:b.B.pa};b.a.d(d);return{foreach:c.data,as:c.as,includeDestroyed:c.includeDestroyed,afterAdd:c.afterAdd,beforeRemove:c.beforeRemove,afterRender:c.afterRender,beforeMove:c.beforeMove,afterMove:c.afterMove,templateEngine:b.B.pa}}},
init:function(a,d){return b.c.template.init(a,b.c.foreach.Ua(d))},update:function(a,d,c,e,f){return b.c.template.update(a,b.c.foreach.Ua(d),c,e,f)}};b.g.R.foreach=t;b.e.J.foreach=n;b.c.hasfocus={init:function(a,d,c){function e(e){a.__ko_hasfocusUpdating=n;var f=a.ownerDocument;"activeElement"in f&&(e=f.activeElement===a);f=d();b.g.fa(f,c,"hasfocus",e,n);a.__ko_hasfocusLastValue=e;a.__ko_hasfocusUpdating=t}var f=e.bind(r,n),g=e.bind(r,t);b.a.n(a,"focus",f);b.a.n(a,"focusin",f);b.a.n(a,"blur",g);b.a.n(a,
"focusout",g)},update:function(a,d){var c=!!b.a.d(d());!a.__ko_hasfocusUpdating&&a.__ko_hasfocusLastValue!==c&&(c?a.focus():a.blur(),b.r.L(b.a.Ca,r,[a,c?"focusin":"focusout"]))}};b.c.hasFocus=b.c.hasfocus;b.c.html={init:function(){return{controlsDescendantBindings:n}},update:function(a,d){b.a.da(a,d())}};var ia="__ko_withIfBindingData";T("if");T("ifnot",t,n);T("with",n,t,function(a,b){return a.createChildContext(b)});b.c.options={update:function(a,d,c){"select"!==b.a.u(a)&&k(Error("options binding applies only to SELECT elements"));
for(var e=0==a.length,f=b.a.X(b.a.ga(a.childNodes,function(a){return a.tagName&&"option"===b.a.u(a)&&a.selected}),function(a){return b.k.q(a)||a.innerText||a.textContent}),g=a.scrollTop,h=b.a.d(d());0<a.length;)b.z(a.options[0]),a.remove(0);if(h){c=c();var l=c.optionsIncludeDestroyed;"number"!=typeof h.length&&(h=[h]);if(c.optionsCaption){var m=u.createElement("option");b.a.da(m,c.optionsCaption);b.k.V(m,j);a.appendChild(m)}d=0;for(var q=h.length;d<q;d++){var p=h[d];if(!p||!p._destroy||l){var m=u.createElement("option"),
v=function(a,b,c){var d=typeof b;return"function"==d?b(a):"string"==d?a[b]:c},w=v(p,c.optionsValue,p);b.k.V(m,b.a.d(w));p=v(p,c.optionsText,w);b.a.fb(m,p);a.appendChild(m)}}h=a.getElementsByTagName("option");d=l=0;for(q=h.length;d<q;d++)0<=b.a.i(f,b.k.q(h[d]))&&(b.a.eb(h[d],n),l++);a.scrollTop=g;e&&"value"in c&&ja(a,b.a.va(c.value),n);b.a.xb(a)}}};b.c.options.ta="__ko.optionValueDomData__";b.c.selectedOptions={init:function(a,d,c){b.a.n(a,"change",function(){var e=d(),f=[];b.a.o(a.getElementsByTagName("option"),
function(a){a.selected&&f.push(b.k.q(a))});b.g.fa(e,c,"selectedOptions",f)})},update:function(a,d){"select"!=b.a.u(a)&&k(Error("values binding applies only to SELECT elements"));var c=b.a.d(d());c&&"number"==typeof c.length&&b.a.o(a.getElementsByTagName("option"),function(a){var d=0<=b.a.i(c,b.k.q(a));b.a.eb(a,d)})}};b.c.style={update:function(a,d){var c=b.a.d(d()||{});b.a.C(c,function(c,d){d=b.a.d(d);a.style[c]=d||""})}};b.c.submit={init:function(a,d,c,e){"function"!=typeof d()&&k(Error("The value for a submit binding must be a function"));
b.a.n(a,"submit",function(b){var c,h=d();try{c=h.call(e,a)}finally{c!==n&&(b.preventDefault?b.preventDefault():b.returnValue=t)}})}};b.c.text={update:function(a,d){b.a.fb(a,d())}};b.e.J.text=n;b.c.uniqueName={init:function(a,d){if(d()){var c="ko_unique_"+ ++b.c.uniqueName.rb;b.a.cb(a,c)}}};b.c.uniqueName.rb=0;b.c.value={init:function(a,d,c){function e(){h=t;var e=d(),f=b.k.q(a);b.g.fa(e,c,"value",f)}var f=["change"],g=c().valueUpdate,h=t;g&&("string"==typeof g&&(g=[g]),b.a.Q(f,g),f=b.a.Ia(f));if(b.a.aa&&
("input"==a.tagName.toLowerCase()&&"text"==a.type&&"off"!=a.autocomplete&&(!a.form||"off"!=a.form.autocomplete))&&-1==b.a.i(f,"propertychange"))b.a.n(a,"propertychange",function(){h=n}),b.a.n(a,"blur",function(){h&&e()});b.a.o(f,function(c){var d=e;b.a.Rb(c,"after")&&(d=function(){setTimeout(e,0)},c=c.substring(5));b.a.n(a,c,d)})},update:function(a,d){var c="select"===b.a.u(a),e=b.a.d(d()),f=b.k.q(a),g=e!=f;0===e&&(0!==f&&"0"!==f)&&(g=n);g&&(f=function(){b.k.V(a,e)},f(),c&&setTimeout(f,0));c&&0<a.length&&
ja(a,e,t)}};b.c.visible={update:function(a,d){var c=b.a.d(d()),e="none"!=a.style.display;c&&!e?a.style.display="":!c&&e&&(a.style.display="none")}};b.c.click={init:function(a,d,c,e){return b.c.event.init.call(this,a,function(){var a={};a.click=d();return a},c,e)}};b.v=function(){};b.v.prototype.renderTemplateSource=function(){k(Error("Override renderTemplateSource"))};b.v.prototype.createJavaScriptEvaluatorBlock=function(){k(Error("Override createJavaScriptEvaluatorBlock"))};b.v.prototype.makeTemplateSource=
function(a,d){if("string"==typeof a){d=d||u;var c=d.getElementById(a);c||k(Error("Cannot find template with ID "+a));return new b.l.h(c)}if(1==a.nodeType||8==a.nodeType)return new b.l.P(a);k(Error("Unknown template type: "+a))};b.v.prototype.renderTemplate=function(a,b,c,e){a=this.makeTemplateSource(a,e);return this.renderTemplateSource(a,b,c)};b.v.prototype.isTemplateRewritten=function(a,b){return this.allowTemplateRewriting===t?n:this.makeTemplateSource(a,b).data("isRewritten")};b.v.prototype.rewriteTemplate=
function(a,b,c){a=this.makeTemplateSource(a,c);b=b(a.text());a.text(b);a.data("isRewritten",n)};b.b("templateEngine",b.v);var za=/(<[a-z]+\d*(\s+(?!data-bind=)[a-z0-9\-]+(=(\"[^\"]*\"|\'[^\']*\'))?)*\s+)data-bind=(["'])([\s\S]*?)\5/gi,Aa=/\x3c!--\s*ko\b\s*([\s\S]*?)\s*--\x3e/g;b.Aa={yb:function(a,d,c){d.isTemplateRewritten(a,c)||d.rewriteTemplate(a,function(a){return b.Aa.Jb(a,d)},c)},Jb:function(a,b){return a.replace(za,function(a,e,f,g,h,j,m){return $(m,e,b)}).replace(Aa,function(a,e){return $(e,
"\x3c!-- ko --\x3e",b)})},ob:function(a){return b.s.sa(function(d,c){d.nextSibling&&b.Ga(d.nextSibling,a,c)})}};b.b("__tr_ambtns",b.Aa.ob);b.l={};b.l.h=function(a){this.h=a};b.l.h.prototype.text=function(){var a=b.a.u(this.h),a="script"===a?"text":"textarea"===a?"value":"innerHTML";if(0==arguments.length)return this.h[a];var d=arguments[0];"innerHTML"===a?b.a.da(this.h,d):this.h[a]=d};b.l.h.prototype.data=function(a){if(1===arguments.length)return b.a.f.get(this.h,"templateSourceData_"+a);b.a.f.set(this.h,
"templateSourceData_"+a,arguments[1])};b.l.P=function(a){this.h=a};b.l.P.prototype=new b.l.h;b.l.P.prototype.text=function(){if(0==arguments.length){var a=b.a.f.get(this.h,"__ko_anon_template__")||{};a.Ba===j&&a.ja&&(a.Ba=a.ja.innerHTML);return a.Ba}b.a.f.set(this.h,"__ko_anon_template__",{Ba:arguments[0]})};b.l.h.prototype.nodes=function(){if(0==arguments.length)return(b.a.f.get(this.h,"__ko_anon_template__")||{}).ja;b.a.f.set(this.h,"__ko_anon_template__",{ja:arguments[0]})};b.b("templateSources",
b.l);b.b("templateSources.domElement",b.l.h);b.b("templateSources.anonymousTemplate",b.l.P);var P;b.xa=function(a){a!=j&&!(a instanceof b.v)&&k(Error("templateEngine must inherit from ko.templateEngine"));P=a};b.wa=function(a,d,c,e,f){c=c||{};(c.templateEngine||P)==j&&k(Error("Set a template engine before calling renderTemplate"));f=f||"replaceChildren";if(e){var g=O(e);return b.j(function(){var h=d&&d instanceof b.w?d:new b.w(b.a.d(d)),j="function"==typeof a?a(h.$data,h):a,h=X(e,f,j,h,c);"replaceNode"==
f&&(e=h,g=O(e))},r,{Ma:function(){return!g||!b.a.Z(g)},Y:g&&"replaceNode"==f?g.parentNode:g})}return b.s.sa(function(e){b.wa(a,d,c,e,"replaceNode")})};b.Pb=function(a,d,c,e,f){function g(a,b){Y(b,l);c.afterRender&&c.afterRender(b,a)}function h(d,e){l=f.createChildContext(b.a.d(d),c.as);l.$index=e;var g="function"==typeof a?a(d,l):a;return X(r,"ignoreTargetNode",g,l,c)}var l;return b.j(function(){var a=b.a.d(d)||[];"undefined"==typeof a.length&&(a=[a]);a=b.a.ga(a,function(a){return c.includeDestroyed||
a===j||a===r||!b.a.d(a._destroy)});b.r.L(b.a.bb,r,[e,a,h,c,g])},r,{Y:e})};b.c.template={init:function(a,d){var c=b.a.d(d());if("string"!=typeof c&&!c.name&&(1==a.nodeType||8==a.nodeType))c=1==a.nodeType?a.childNodes:b.e.childNodes(a),c=b.a.Kb(c),(new b.l.P(a)).nodes(c);return{controlsDescendantBindings:n}},update:function(a,d,c,e,f){d=b.a.d(d());c={};e=n;var g,h=r;"string"!=typeof d&&(c=d,d=b.a.d(c.name),"if"in c&&(e=b.a.d(c["if"])),e&&"ifnot"in c&&(e=!b.a.d(c.ifnot)),g=b.a.d(c.data));"foreach"in
c?h=b.Pb(d||a,e&&c.foreach||[],c,a,f):e?(f="data"in c?f.createChildContext(g,c.as):f,h=b.wa(d||a,f,c,a)):b.e.$(a);f=h;(g=b.a.f.get(a,"__ko__templateComputedDomDataKey__"))&&"function"==typeof g.A&&g.A();b.a.f.set(a,"__ko__templateComputedDomDataKey__",f&&f.qa()?f:j)}};b.g.R.template=function(a){a=b.g.ba(a);return 1==a.length&&a[0].unknown||b.g.Hb(a,"name")?r:"This template engine does not support anonymous templates nested within its templates"};b.e.J.template=n;b.b("setTemplateEngine",b.xa);b.b("renderTemplate",
b.wa);b.a.La=function(a,b,c){a=a||[];b=b||[];return a.length<=b.length?W(a,b,"added","deleted",c):W(b,a,"deleted","added",c)};b.b("utils.compareArrays",b.a.La);b.a.bb=function(a,d,c,e,f){function g(a,b){s=m[b];v!==b&&(x[a]=s);s.oa(v++);M(s.N);u.push(s);C.push(s)}function h(a,c){if(a)for(var d=0,e=c.length;d<e;d++)c[d]&&b.a.o(c[d].N,function(b){a(b,d,c[d].W)})}d=d||[];e=e||{};var l=b.a.f.get(a,"setDomNodeChildrenFromArrayMapping_lastMappingResult")===j,m=b.a.f.get(a,"setDomNodeChildrenFromArrayMapping_lastMappingResult")||
[],q=b.a.X(m,function(a){return a.W}),p=b.a.La(q,d),u=[],w=0,v=0,B=[],C=[];d=[];for(var x=[],q=[],s,E=0,y,z;y=p[E];E++)switch(z=y.moved,y.status){case "deleted":z===j&&(s=m[w],s.j&&s.j.A(),B.push.apply(B,M(s.N)),e.beforeRemove&&(d[E]=s,C.push(s)));w++;break;case "retained":g(E,w++);break;case "added":z!==j?g(E,z):(s={W:y.value,oa:b.m(v++)},u.push(s),C.push(s),l||(q[E]=s))}h(e.beforeMove,x);b.a.o(B,e.beforeRemove?b.z:b.removeNode);for(var E=0,l=b.e.firstChild(a),D;s=C[E];E++){s.N||b.a.extend(s,na(a,
c,s.W,f,s.oa));for(w=0;p=s.N[w];l=p.nextSibling,D=p,w++)p!==l&&b.e.Ra(a,p,D);!s.Db&&f&&(f(s.W,s.N,s.oa),s.Db=n)}h(e.beforeRemove,d);h(e.afterMove,x);h(e.afterAdd,q);b.a.f.set(a,"setDomNodeChildrenFromArrayMapping_lastMappingResult",u)};b.b("utils.setDomNodeChildrenFromArrayMapping",b.a.bb);b.B=function(){this.allowTemplateRewriting=t};b.B.prototype=new b.v;b.B.prototype.renderTemplateSource=function(a){var d=!(9>b.a.aa)&&a.nodes?a.nodes():r;if(d)return b.a.M(d.cloneNode(n).childNodes);a=a.text();
return b.a.ua(a)};b.B.pa=new b.B;b.xa(b.B.pa);b.b("nativeTemplateEngine",b.B);b.ra=function(){var a=this.Gb=function(){if("undefined"==typeof q||!q.tmpl)return 0;try{if(0<=q.tmpl.tag.tmpl.open.toString().indexOf("__"))return 2}catch(a){}return 1}();this.renderTemplateSource=function(b,c,e){e=e||{};2>a&&k(Error("Your version of jQuery.tmpl is too old. Please upgrade to jQuery.tmpl 1.0.0pre or later."));var f=b.data("precompiled");f||(f=b.text()||"",f=q.template(r,"{{ko_with $item.koBindingContext}}"+
f+"{{/ko_with}}"),b.data("precompiled",f));b=[c.$data];c=q.extend({koBindingContext:c},e.templateOptions);c=q.tmpl(f,b,c);c.appendTo(u.createElement("div"));q.fragments={};return c};this.createJavaScriptEvaluatorBlock=function(a){return"{{ko_code ((function() { return "+a+" })()) }}"};this.addTemplate=function(a,b){u.write("<script type='text/html' id='"+a+"'>"+b+"\x3c/script>")};0<a&&(q.tmpl.tag.ko_code={open:"__.push($1 || '');"},q.tmpl.tag.ko_with={open:"with($1) {",close:"} "})};b.ra.prototype=
new b.v;v=new b.ra;0<v.Gb&&b.xa(v);b.b("jqueryTmplTemplateEngine",b.ra)})})();
})();
!function(){return function(factory){if(typeof define==="function"&&define.amd){return define("knockback",["underscore","backbone","knockout"],factory)}else{return factory.call(this)}}(function(){var COMPARE_ASCENDING,COMPARE_DESCENDING,COMPARE_EQUAL,KB_TYPE_ARRAY,KB_TYPE_COLLECTION,KB_TYPE_MODEL,KB_TYPE_SIMPLE,KB_TYPE_UNKNOWN,addStatisticsEvent,copyProps,e,kb,ko,onReady,_,_argumentsAddKey,_arraySplice,_collapseOptions,_ko_applyBindings,_legacyWarning,_publishMethods,_throwMissing,_throwUnexpected,_unwrapModels,_unwrapObservable,_wrappedKey,__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};kb=function(){function kb(){}kb.VERSION="0.17.3";kb.TYPE_UNKNOWN=0;kb.TYPE_SIMPLE=1;kb.TYPE_ARRAY=2;kb.TYPE_MODEL=3;kb.TYPE_COLLECTION=4;kb.wasReleased=function(obj){return!obj||obj.__kb_released};kb.isReleaseable=function(obj,depth){var key,value;if(depth==null){depth=0}if(!obj||obj!==Object(obj)||obj.__kb_released){return false}else if(ko.isObservable(obj)||obj instanceof kb.ViewModel){return true}else if(typeof obj==="function"||obj instanceof kb.Model||obj instanceof kb.Collection){return false}else if(typeof obj.dispose==="function"||typeof obj.destroy==="function"||typeof obj.release==="function"){return true}else if(depth<1){for(key in obj){value=obj[key];if(key!=="__kb"&&kb.isReleaseable(value,depth+1)){return true}}}return false};kb.release=function(obj){var array,index,value;if(!kb.isReleaseable(obj)){return}if(_.isArray(obj)){for(index in obj){value=obj[index];if(kb.isReleaseable(value)){obj[index]=null;kb.release(value)}}return}obj.__kb_released=true;if(ko.isObservable(obj)&&_.isArray(array=obj())){if(obj.__kb_is_co||obj.__kb_is_o&&obj.valueType()===KB_TYPE_COLLECTION){if(obj.destroy){obj.destroy()}else if(obj.dispose){obj.dispose()}}else if(array.length){for(index in array){value=array[index];if(kb.isReleaseable(value)){array[index]=null;kb.release(value)}}}}else if(typeof obj.release==="function"){obj.release()}else if(typeof obj.destroy==="function"){obj.destroy()}else if(typeof obj.dispose==="function"){obj.dispose()}else if(!ko.isObservable(obj)){this.releaseKeys(obj)}};kb.releaseKeys=function(obj){var key,value;for(key in obj){value=obj[key];if(key!=="__kb"&&kb.isReleaseable(value)){obj[key]=null;kb.release(value)}}};kb.releaseOnNodeRemove=function(view_model,node){view_model||_throwUnexpected(this,"missing view model");node||_throwUnexpected(this,"missing node");return ko.utils.domNodeDisposal.addDisposeCallback(node,function(){return kb.release(view_model)})};kb.renderTemplate=function(template,view_model,options){var el,observable;if(options==null){options={}}el=document.createElement("div");observable=ko.renderTemplate(template,view_model,options,el,"replaceChildren");if(el.children.length===1){el=el.children[0]}kb.releaseOnNodeRemove(view_model,el);observable.dispose();if(view_model.afterRender&&!options.afterRender){view_model.afterRender(el)}return el};kb.applyBindings=function(view_model,node){ko.applyBindings(view_model,node);return kb.releaseOnNodeRemove(view_model,node)};return kb}();this.Knockback=this.kb=kb;if(typeof exports!=="undefined"){module.exports=kb}if(this.Parse){kb._=_=this.Parse._;kb.Parse=this.Parse;kb.Collection=this.Parse.Collection;kb.Model=this.Parse.Object;kb.Events=this.Parse.Events}else{if(!this._&&typeof require!=="undefined"){try{_=require("lodash")}catch(_error){e=_error;_=require("underscore")}}else{_=this._}kb._=_=_.hasOwnProperty("_")?_._:_;if(_.where&&!_.findWhere){_.mixin({findWhere:function(obj,attrs){var result;result=_.where(obj,attrs);if(result.length){return result[0]}else{return null}}})}kb.Backbone=!this.Backbone&&typeof require!=="undefined"?require("backbone"):this.Backbone;kb.Collection=kb.Backbone.Collection;kb.Model=kb.Backbone.Model;kb.Events=kb.Backbone.Events}kb.ko=ko=!this.ko&&typeof require!=="undefined"?require("knockout"):this.ko;_throwMissing=function(instance,message){throw""+(_.isString(instance)?instance:instance.constructor.name)+": "+message+" is missing"};_throwUnexpected=function(instance,message){throw""+(_.isString(instance)?instance:instance.constructor.name)+": "+message+" is unexpected"};_legacyWarning=function(identifier,last_version,message){var _base;this._legacy_warnings||(this._legacy_warnings={});(_base=this._legacy_warnings)[identifier]||(_base[identifier]=0);this._legacy_warnings[identifier]++;return console.warn("warning: '"+identifier+"' has been deprecated (will be removed in Knockback after "+last_version+"). "+message+".")};_arraySplice=Array.prototype.splice;_unwrapObservable=ko.utils.unwrapObservable;_collapseOptions=function(options){var result;result=_.clone(options);while(options.options){_.defaults(result,options.options);options=options.options}delete result.options;return result};_publishMethods=kb._publishMethods=function(observable,instance,methods){var fn,_i,_len;for(_i=0,_len=methods.length;_i<_len;_i++){fn=methods[_i];observable[fn]=kb._.bind(instance[fn],instance)}};copyProps=function(dest,source){var key,value;for(key in source){value=source[key];dest[key]=value}return dest};var ctor=function(){};var inherits=function(parent,protoProps,staticProps){var child;if(protoProps&&protoProps.hasOwnProperty("constructor")){child=protoProps.constructor}else{child=function(){parent.apply(this,arguments)}}copyProps(child,parent);ctor.prototype=parent.prototype;child.prototype=new ctor;if(protoProps)copyProps(child.prototype,protoProps);if(staticProps)copyProps(child,staticProps);child.prototype.constructor=child;child.__super__=parent.prototype;return child};var extend=function(protoProps,classProps){var child=inherits(this,protoProps,classProps);child.extend=this.extend;return child};kb.extend=extend;KB_TYPE_UNKNOWN=kb.TYPE_UNKNOWN;KB_TYPE_SIMPLE=kb.TYPE_SIMPLE;KB_TYPE_ARRAY=kb.TYPE_ARRAY;KB_TYPE_MODEL=kb.TYPE_MODEL;KB_TYPE_COLLECTION=kb.TYPE_COLLECTION;_wrappedKey=function(obj,key,value){if(arguments.length===2){if(obj&&obj.__kb&&obj.__kb.hasOwnProperty(key)){return obj.__kb[key]}else{return void 0}}obj||_throwUnexpected(this,"no obj for wrapping "+key);obj.__kb||(obj.__kb={});obj.__kb[key]=value;return value};_argumentsAddKey=function(args,key){_arraySplice.call(args,1,0,key);return args};_unwrapModels=function(obj){var key,result,value;if(!obj){return obj}if(obj.__kb){if("object"in obj.__kb){return obj.__kb.object}else{return obj}}else if(_.isArray(obj)){return _.map(obj,function(test){return _unwrapModels(test)})}else if(_.isObject(obj)&&obj.constructor==={}.constructor){result={};for(key in obj){value=obj[key];result[key]=_unwrapModels(value)}return result}return obj};kb.utils=function(){function utils(){}utils.wrappedObservable=function(obj,value){return _wrappedKey.apply(this,_argumentsAddKey(arguments,"observable"))};utils.wrappedObject=function(obj,value){return _wrappedKey.apply(this,_argumentsAddKey(arguments,"object"))};utils.wrappedModel=function(obj,value){if(arguments.length===1){value=_wrappedKey(obj,"object");if(_.isUndefined(value)){return obj}else{return value}}else{return _wrappedKey(obj,"object",value)}};utils.wrappedStore=function(obj,value){return _wrappedKey.apply(this,_argumentsAddKey(arguments,"store"))};utils.wrappedStoreIsOwned=function(obj,value){return _wrappedKey.apply(this,_argumentsAddKey(arguments,"store_is_owned"))};utils.wrappedFactory=function(obj,value){return _wrappedKey.apply(this,_argumentsAddKey(arguments,"factory"))};utils.wrappedEventWatcher=function(obj,value){return _wrappedKey.apply(this,_argumentsAddKey(arguments,"event_watcher"))};utils.wrappedEventWatcherIsOwned=function(obj,value){return _wrappedKey.apply(this,_argumentsAddKey(arguments,"event_watcher_is_owned"))};utils.wrappedDestroy=function(obj){var __kb;if(!obj.__kb){return}if(obj.__kb.event_watcher){obj.__kb.event_watcher.releaseCallbacks(obj)}__kb=obj.__kb;obj.__kb=null;if(__kb.observable){__kb.observable.destroy=__kb.observable.release=null;this.wrappedDestroy(__kb.observable);__kb.observable=null}__kb.factory=null;if(__kb.event_watcher_is_owned){__kb.event_watcher.destroy()}__kb.event_watcher=null;if(__kb.store_is_owned){__kb.store.destroy()}return __kb.store=null};utils.valueType=function(observable){if(!observable){return KB_TYPE_UNKNOWN}if(observable.__kb_is_o){return observable.valueType()}if(observable.__kb_is_co||observable instanceof kb.Collection){return KB_TYPE_COLLECTION}if(observable instanceof kb.ViewModel||observable instanceof kb.Model){return KB_TYPE_MODEL}if(_.isArray(observable)){return KB_TYPE_ARRAY}return KB_TYPE_SIMPLE};utils.pathJoin=function(path1,path2){return(path1?path1[path1.length-1]!=="."?""+path1+".":path1:"")+path2};utils.optionsPathJoin=function(options,path){return _.defaults({path:this.pathJoin(options.path,path)},options)};utils.inferCreator=function(value,factory,path,owner,key){var creator,relation;if(factory){creator=factory.creatorForPath(value,path)}if(creator){return creator}if(owner&&kb.Backbone&&kb.Backbone.RelationalModel&&owner instanceof kb.Backbone.RelationalModel){key=_unwrapObservable(key);relation=_.find(owner.getRelations(),function(test){return test.key===key});if(relation){if(relation.collectionType||_.isArray(relation.keyContents)){return kb.CollectionObservable}else{return kb.ViewModel}}}if(!value){return null}if(value instanceof kb.Model){return kb.ViewModel}if(value instanceof kb.Collection){return kb.CollectionObservable}return null};utils.createFromDefaultCreator=function(obj,options){if(obj instanceof kb.Model){return kb.viewModel(obj,options)}if(obj instanceof kb.Collection){return kb.collectionObservable(obj,options)}if(_.isArray(obj)){return ko.observableArray(obj)}return ko.observable(obj)};utils.hasModelSignature=function(obj){return obj&&obj.attributes&&!obj.models&&typeof obj.get==="function"&&typeof obj.trigger==="function"};utils.hasCollectionSignature=function(obj){return obj&&obj.models&&typeof obj.get==="function"&&typeof obj.trigger==="function"};return utils}();kb.Factory=function(){Factory.useOptionsOrCreate=function(options,obj,owner_path){var factory;if(options.factory&&(!options.factories||options.factories&&options.factory.hasPathMappings(options.factories,owner_path))){return kb.utils.wrappedFactory(obj,options.factory)}factory=kb.utils.wrappedFactory(obj,new kb.Factory(options.factory));if(options.factories){factory.addPathMappings(options.factories,owner_path)}return factory};function Factory(parent_factory){this.parent_factory=parent_factory;this.paths={}}Factory.prototype.hasPath=function(path){return this.paths.hasOwnProperty(path)||this.parent_factory&&this.parent_factory.hasPath(path)};Factory.prototype.addPathMapping=function(path,create_info){return this.paths[path]=create_info};Factory.prototype.addPathMappings=function(factories,owner_path){var create_info,path;for(path in factories){create_info=factories[path];this.paths[kb.utils.pathJoin(owner_path,path)]=create_info}};Factory.prototype.hasPathMappings=function(factories,owner_path){var all_exist,creator,existing_creator,path;all_exist=true;for(path in factories){creator=factories[path];all_exist&=(existing_creator=this.creatorForPath(null,kb.utils.pathJoin(owner_path,path)))&&creator===existing_creator}return all_exist};Factory.prototype.creatorForPath=function(obj,path){var creator;if(creator=this.paths[path]){if(creator.view_model){return creator.view_model}else{return creator}}if(this.parent_factory){if(creator=this.parent_factory.creatorForPath(obj,path)){return creator}}return null};return Factory}();kb.Store=function(){Store.useOptionsOrCreate=function(options,obj,observable){if(options.store){options.store.register(obj,observable,options);return kb.utils.wrappedStore(observable,options.store)}else{kb.utils.wrappedStoreIsOwned(observable,true);return kb.utils.wrappedStore(observable,new kb.Store)}};function Store(){this.observable_records=[];this.replaced_observables=[]}Store.prototype.destroy=function(){return this.clear()};Store.prototype.clear=function(){var record,_i,_len,_ref;_ref=this.observable_records.splice(0,this.observable_records.length);for(_i=0,_len=_ref.length;_i<_len;_i++){record=_ref[_i];kb.release(record.observable)}kb.release(this.replaced_observables)};Store.prototype.register=function(obj,observable,options){var creator;if(!observable){return}if(ko.isObservable(observable)||observable.__kb_is_co){return}kb.utils.wrappedObject(observable,obj);obj||(observable.__kb_null=true);creator=options.creator?options.creator:options.path&&options.factory?options.factory.creatorForPath(obj,options.path):null;if(!creator){creator=observable.constructor}this.observable_records.push({obj:obj,observable:observable,creator:creator});return observable};Store.prototype.findIndex=function(obj,creator){var index,record,_ref;if(!obj||obj instanceof kb.Model){_ref=this.observable_records;for(index in _ref){record=_ref[index];if(!record.observable){continue}if(record.observable.__kb_released){record.obj=null;record.observable=null;continue}if(!obj&&!record.observable.__kb_null||obj&&(record.observable.__kb_null||record.obj!==obj)){continue}else if(record.creator===creator||record.creator.create&&record.creator.create===creator.create){return index}}}return-1};Store.prototype.find=function(obj,creator){var index;if((index=this.findIndex(obj,creator))<0){return null}else{return this.observable_records[index].observable}};Store.prototype.isRegistered=function(observable){var record,_i,_len,_ref;_ref=this.observable_records;for(_i=0,_len=_ref.length;_i<_len;_i++){record=_ref[_i];if(record.observable===observable){return true}}return false};Store.prototype.findOrCreate=function(obj,options){var creator,observable;options.store=this;options.creator||(options.creator=kb.utils.inferCreator(obj,options.factory,options.path));if(!options.creator&&obj instanceof kb.Model){options.creator=kb.ViewModel}creator=options.creator;if(!creator){return kb.utils.createFromDefaultCreator(obj,options)}else if(creator.models_only){return obj}if(creator){observable=this.find(obj,creator)}if(observable){return observable}if(creator.create){observable=creator.create(obj,options)}else{observable=new creator(obj,options)}observable||(observable=ko.observable(null));if(!ko.isObservable(observable)){this.isRegistered(observable)||this.register(obj,observable,options)}return observable};Store.prototype.findOrReplace=function(obj,creator,observable){var index,record;obj||_throwUnexpected(this,"obj missing");if((index=this.findIndex(obj,creator))<0){return this.register(obj,observable,{creator:creator})}else{record=this.observable_records[index];kb.utils.wrappedObject(record.observable)===obj||_throwUnexpected(this,"different object");if(record.observable!==observable){record.observable.constructor===observable.constructor||_throwUnexpected(this,"replacing different type");this.replaced_observables.push(record.observable);record.observable=observable}return observable}};return Store}();addStatisticsEvent=function(emitter,event_name,info){return!kb.statistics||kb.statistics.addModelEvent({name:event_name,emitter:emitter,key:info.key,path:info.path})};kb.EventWatcher=function(){EventWatcher.useOptionsOrCreate=function(options,emitter,obj,callback_options){if(options.event_watcher){if(!(options.event_watcher.emitter()===emitter||options.event_watcher.model_ref===emitter)){_throwUnexpected(this,"emitter not matching")}return kb.utils.wrappedEventWatcher(obj,options.event_watcher).registerCallbacks(obj,callback_options)}else{kb.utils.wrappedEventWatcherIsOwned(obj,true);return kb.utils.wrappedEventWatcher(obj,new kb.EventWatcher(emitter)).registerCallbacks(obj,callback_options)}};function EventWatcher(emitter,obj,callback_options){this._onModelUnloaded=__bind(this._onModelUnloaded,this);this._onModelLoaded=__bind(this._onModelLoaded,this);this.__kb||(this.__kb={});this.__kb.callbacks={};this.__kb._onModelLoaded=_.bind(this._onModelLoaded,this);this.__kb._onModelUnloaded=_.bind(this._onModelUnloaded,this);if(callback_options){this.registerCallbacks(obj,callback_options)}if(emitter){this.emitter(emitter)}else{this.ee=null}}EventWatcher.prototype.destroy=function(){this.emitter(null);this.__kb.callbacks=null;return kb.utils.wrappedDestroy(this)};EventWatcher.prototype.emitter=function(new_emitter){var callbacks,event_name,info,list,previous_emitter,_i,_len,_ref;if(arguments.length===0||this.ee===new_emitter){return this.ee}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}if(kb.Backbone&&kb.Backbone.ModelRef&&new_emitter instanceof kb.Backbone.ModelRef){this.model_ref=new_emitter;this.model_ref.retain();this.model_ref.bind("loaded",this.__kb._onModelLoaded);this.model_ref.bind("unloaded",this.__kb._onModelUnloaded);new_emitter=this.model_ref.model()}else{delete this.model_ref}previous_emitter=this.ee;this.ee=new_emitter;_ref=this.__kb.callbacks;for(event_name in _ref){callbacks=_ref[event_name];if(previous_emitter){previous_emitter.unbind(event_name,callbacks.fn)}if(new_emitter){this.ee.bind(event_name,callbacks.fn)}list=callbacks.list;for(_i=0,_len=list.length;_i<_len;_i++){info=list[_i];if(info.emitter){info.emitter(this.ee)}}}return new_emitter};EventWatcher.prototype.registerCallbacks=function(obj,callback_info){var callbacks,event_name,event_names,event_selector,info,list,_i,_len,_this=this;obj||_throwMissing(this,"obj");callback_info||_throwMissing(this,"info");event_selector=callback_info.event_selector?callback_info.event_selector:"change";event_names=event_selector.split(" ");for(_i=0,_len=event_names.length;_i<_len;_i++){event_name=event_names[_i];if(!event_name){continue}callbacks=this.__kb.callbacks[event_name];if(!callbacks){list=[];callbacks={list:list,fn:function(emitter){var info,_j,_len1;for(_j=0,_len1=list.length;_j<_len1;_j++){info=list[_j];if(info.update&&!info.rel_fn){if(emitter&&info.key&&emitter.hasChanged&&!emitter.hasChanged(_unwrapObservable(info.key))){continue}!kb.statistics||addStatisticsEvent(emitter,event_name,info);info.update()}}return null}};this.__kb.callbacks[event_name]=callbacks;if(this.ee){this.ee.bind(event_name,callbacks.fn)}}info=_.defaults({obj:obj},callback_info);callbacks.list.push(info)}if(this.ee){if(kb.Backbone&&kb.Backbone.RelationalModel&&this.ee instanceof kb.Backbone.RelationalModel&&_.contains(event_names,"change")){this._modelBindRelatationalInfo("change",info)}info.emitter(this.ee)&&info.emitter}};EventWatcher.prototype.releaseCallbacks=function(obj){var callbacks,event_name,index,info,_ref,_ref1;if(!this.__kb.callbacks||!this.ee){return}_ref=this.__kb.callbacks;for(event_name in _ref){callbacks=_ref[event_name];_ref1=callbacks.list;for(index in _ref1){info=_ref1[index];if(info.obj!==obj){continue}callbacks.list.splice(index,1);if(info.rel_fn){this._modelUnbindRelatationalInfo(event_name,info)}if(!kb.wasReleased(obj)&&info.emitter){info.emitter(null)}return}}};EventWatcher.prototype._onModelLoaded=function(model){var callbacks,event_name,info,is_relational,list,_i,_len,_ref;is_relational=kb.Backbone&&kb.Backbone.RelationalModel&&model instanceof kb.Backbone.RelationalModel;this.ee=model;_ref=this.__kb.callbacks;for(event_name in _ref){callbacks=_ref[event_name];this.ee.bind(event_name,callbacks.fn);list=callbacks.list;for(_i=0,_len=list.length;_i<_len;_i++){info=list[_i];if(is_relational){this._modelBindRelatationalInfo(event_name,info)}if(info.emitter){info.emitter(this.ee)}}}};EventWatcher.prototype._onModelUnloaded=function(model){var callbacks,event_name,info,list,_i,_len,_ref;this.ee=null;_ref=this.__kb.callbacks;for(event_name in _ref){callbacks=_ref[event_name];model.unbind(event_name,callbacks.fn);list=callbacks.list;for(_i=0,_len=list.length;_i<_len;_i++){info=list[_i];if(info.rel_fn){this._modelUnbindRelatationalInfo(event_name,info)}if(info.emitter){info.emitter(null)}}}};EventWatcher.prototype._modelBindRelatationalInfo=function(event_name,info){var event,events,key,relation,_i,_len;if(event_name==="change"&&info.key&&info.update){key=_unwrapObservable(info.key);relation=_.find(this.ee.getRelations(),function(test){return test.key===key});if(!relation){return}info.rel_fn=function(emitter){!kb.statistics||addStatisticsEvent(emitter,""+event_name+" (relational)",info);return info.update()};events=Backbone.Relation.prototype.sanitizeOptions?["update","add","remove"]:["change","add","remove"];if(relation.collectionType||_.isArray(relation.keyContents)){info.is_collection=true;for(_i=0,_len=events.length;_i<_len;_i++){event=events[_i];this.ee.bind(""+event+":"+info.key,info.rel_fn)}}else{this.ee.bind(""+events[0]+":"+info.key,info.rel_fn)}}};EventWatcher.prototype._modelUnbindRelatationalInfo=function(event_name,info){var event,events,_i,_len,_results;if(!info.rel_fn){events=Backbone.Relation.prototype.sanitizeOptions?["update","add","remove"]:["change","add","remove"];if(relation.collectionType||_.isArray(relation.keyContents)){info.is_collection=true;_results=[];for(_i=0,_len=events.length;_i<_len;_i++){event=events[_i];_results.push(this.ee.unbind(""+event+":"+info.key,info.rel_fn))}return _results}else{return this.ee.unbind(""+events[0]+":"+info.key,info.rel_fn)}}info.rel_fn=null};return EventWatcher}();kb.emitterObservable=function(emitter,observable){return new kb.EventWatcher(emitter,observable)};kb.Observable=function(){function Observable(model,options,vm){var create_options,event_watcher,observable,_this=this;this.vm=vm;options||_throwMissing(this,"options");this.vm||(this.vm={});if(_.isString(options)||ko.isObservable(options)){create_options=this.create_options={key:options}}else{create_options=this.create_options=_collapseOptions(options)}this.key=create_options.key;delete create_options.key;this.key||_throwMissing(this,"key");!create_options.args||(this.args=create_options.args,delete create_options.args);!create_options.read||(this.read=create_options.read,delete create_options.read);!create_options.write||(this.write=create_options.write,delete create_options.write);event_watcher=create_options.event_watcher;delete create_options.event_watcher;this.vo=ko.observable(null);this._model=ko.observable();observable=kb.utils.wrappedObservable(this,ko.dependentObservable({read:function(){var arg,args,new_value,_i,_len,_ref;args=[_unwrapObservable(_this.key)];if(_this.args){if(_.isArray(_this.args)){_ref=_this.args;for(_i=0,_len=_ref.length;_i<_len;_i++){arg=_ref[_i];args.push(_unwrapObservable(arg))}}else{args.push(_unwrapObservable(_this.args))}}if(_this._mdl===_this._model()&&_this._mdl){new_value=_this.read?_this.read.apply(_this.vm,args):_this._mdl.get.apply(_this._mdl,args);_this.update(new_value)}return _unwrapObservable(_this.vo())},write:function(new_value){var arg,args,set_info,unwrapped_new_value,_i,_len,_ref;unwrapped_new_value=_unwrapModels(new_value);set_info={};set_info[_unwrapObservable(_this.key)]=unwrapped_new_value;args=_this.write?[unwrapped_new_value]:[set_info];if(_this.args){if(_.isArray(_this.args)){_ref=_this.args;for(_i=0,_len=_ref.length;_i<_len;_i++){arg=_ref[_i];args.push(_unwrapObservable(arg))}}else{args.push(_unwrapObservable(_this.args))}}if(_this._mdl){if(_this.write){_this.write.apply(_this.vm,args)}else{_this._mdl.set.apply(_this._mdl,args)}}return _this.update(new_value)},owner:this.vm}));observable.__kb_is_o=true;create_options.store=kb.utils.wrappedStore(observable,create_options.store);create_options.path=kb.utils.pathJoin(create_options.path,this.key);if(create_options.factories&&(typeof create_options.factories==="function"||create_options.factories.create)){create_options.factory=kb.utils.wrappedFactory(observable,new kb.Factory(create_options.factory));create_options.factory.addPathMapping(create_options.path,create_options.factories)}else{create_options.factory=kb.Factory.useOptionsOrCreate(create_options,observable,create_options.path)}delete create_options.factories;_publishMethods(observable,this,["value","valueType","destroy"]);observable.model=this.model=ko.dependentObservable({read:function(){_this._model();return _this._mdl},write:function(new_model){if(_this.__kb_released||_this._mdl===new_model){return}_this._mdl=new_model;_this.update(null);return _this._model(new_model)}});kb.EventWatcher.useOptionsOrCreate({event_watcher:event_watcher},model,this,{emitter:this.model,update:_.bind(this.update,this),key:this.key,path:create_options.path});this.__kb_value||this.update();if(kb.LocalizedObservable&&create_options.localizer){observable=new create_options.localizer(observable);delete create_options.localizer}if(kb.DefaultObservable&&create_options.hasOwnProperty("default")){observable=kb.defaultObservable(observable,create_options["default"]);delete create_options["default"]}return observable}Observable.prototype.destroy=function(){var observable;observable=kb.utils.wrappedObservable(this);this.__kb_released=true;kb.release(this.__kb_value);this.__kb_value=null;this.model.dispose();this._mdl=this.model=observable.model=null;return kb.utils.wrappedDestroy(this)};Observable.prototype.value=function(){return this.__kb_value};Observable.prototype.valueType=function(){var new_value;new_value=this._mdl?this._mdl.get(this.key):null;this.value_type||this._updateValueObservable(new_value);return this.value_type};Observable.prototype.update=function(new_value){var new_type,value;if(this.__kb_released){return}if(this._mdl&&!arguments.length){new_value=this._mdl.get(_unwrapObservable(this.key))}new_value!==void 0||(new_value=null);new_type=kb.utils.valueType(new_value);if(!this.__kb_value||this.__kb_value.__kb_released||this.__kb_value.__kb_null&&new_value){this.__kb_value=void 0;this.value_type=void 0}value=this.__kb_value;if(_.isUndefined(this.value_type)||this.value_type!==new_type&&new_type!==KB_TYPE_UNKNOWN){if(this.value_type===KB_TYPE_COLLECTION&&new_type===KB_TYPE_ARRAY){return value(new_value)}else{return this._updateValueObservable(new_value)}}else if(this.value_type===KB_TYPE_MODEL){if(typeof value.model==="function"){if(value.model()!==new_value){return value.model(new_value)}}else if(kb.utils.wrappedObject(value)!==new_value){return this._updateValueObservable(new_value)}}else if(this.value_type===KB_TYPE_COLLECTION){if(value.collection()!==new_value){return value.collection(new_value)}}else{if(value()!==new_value){return value(new_value)}}};Observable.prototype._updateValueObservable=function(new_value){var create_options,creator,previous_value,value;create_options=this.create_options;create_options.creator=kb.utils.inferCreator(new_value,create_options.factory,create_options.path,this._mdl,this.key);this.value_type=KB_TYPE_UNKNOWN;creator=create_options.creator;previous_value=this.__kb_value;this.__kb_value=void 0;if(previous_value){kb.release(previous_value)}if(creator){if(create_options.store){value=create_options.store.findOrCreate(new_value,create_options)}else{if(creator.models_only){value=new_value;this.value_type=KB_TYPE_SIMPLE}else if(creator.create){value=creator.create(new_value,create_options)}else{value=new creator(new_value,create_options)}}}else{if(_.isArray(new_value)){this.value_type=KB_TYPE_ARRAY;value=ko.observableArray(new_value)}else{this.value_type=KB_TYPE_SIMPLE;value=ko.observable(new_value)}}if(this.value_type===KB_TYPE_UNKNOWN){if(!ko.isObservable(value)){this.value_type=KB_TYPE_MODEL;if(typeof value.model!=="function"){kb.utils.wrappedObject(value,new_value)}}else if(value.__kb_is_co){this.value_type=KB_TYPE_COLLECTION}else{this.value_type=KB_TYPE_SIMPLE}}this.__kb_value=value;return this.vo(value)};return Observable}();kb.observable=function(model,options,view_model){return new kb.Observable(model,options,view_model)};kb.ViewModel=function(){ViewModel.extend=kb.extend;function ViewModel(model,options,view_model){var attribute_keys,bb_model,event_watcher,keys,mapped_keys,mapping_info,vm_key,_mdl,_ref,_this=this;!model||model instanceof kb.Model||typeof model.get==="function"&&typeof model.bind==="function"||_throwUnexpected(this,"not a model");options||(options={});view_model||(view_model={});if(_.isArray(options)){options={keys:options}}else{options=_collapseOptions(options)}this.__kb||(this.__kb={});this.__kb.vm_keys={};this.__kb.model_keys={};this.__kb.view_model=_.isUndefined(view_model)?this:view_model;!options.internals||(this.__kb.internals=_.isArray(options.internals)?options.internals:[options.internals]);!options.excludes||(this.__kb.excludes=_.isArray(options.excludes)?options.excludes:[options.excludes]);kb.Store.useOptionsOrCreate(options,model,this);this.__kb.path=options.path;kb.Factory.useOptionsOrCreate(options,this,options.path);_mdl=_wrappedKey(this,"_mdl",ko.observable());this.model=ko.dependentObservable({read:function(){_mdl();return kb.utils.wrappedObject(_this)},write:function(new_model){var event_watcher,missing;if(kb.utils.wrappedObject(_this)===new_model){return}if(_this.__kb_null){!new_model||_throwUnexpected(_this,"model set on shared null");return}kb.utils.wrappedObject(_this,new_model);event_watcher=kb.utils.wrappedEventWatcher(_this);if(!event_watcher){_mdl(new_model);return}event_watcher.emitter(new_model);if(!(_this.__kb.keys||!new_model||!new_model.attributes)){missing=_.difference(_.keys(new_model.attributes),_.keys(_this.__kb.model_keys));if(missing){_this._createObservables(new_model,missing)}}_mdl(new_model)}});event_watcher=kb.utils.wrappedEventWatcher(this,new kb.EventWatcher(model,this,{emitter:this.model}));if(options.requires){keys=_.isArray(options.requires)?_.clone(options.requires):[options.requires]}if(this.__kb.internals){keys=keys?_.union(keys,this.__kb.internals):_.clone(this.__kb.internals)}if(options.keys){if(_.isObject(options.keys)&&!_.isArray(options.keys)){mapped_keys={};_ref=options.keys;for(vm_key in _ref){mapping_info=_ref[vm_key];mapped_keys[_.isString(mapping_info)?mapping_info:mapping_info.key?mapping_info.key:vm_key]=true}this.__kb.keys=_.keys(mapped_keys)}else{this.__kb.keys=_.isArray(options.keys)?options.keys:[options.keys];keys=keys?_.union(keys,this.__kb.keys):_.clone(this.__kb.keys)}}else{bb_model=event_watcher.emitter();if(bb_model&&bb_model.attributes){attribute_keys=_.keys(bb_model.attributes);keys=keys?_.union(keys,attribute_keys):attribute_keys}}if(keys&&this.__kb.excludes){keys=_.difference(keys,this.__kb.excludes)}if(_.isObject(options.keys)&&!_.isArray(options.keys)){this._mapObservables(model,options.keys)}if(_.isObject(options.requires)&&!_.isArray(options.requires)){this._mapObservables(model,options.requires)}!options.mappings||this._mapObservables(model,options.mappings);!keys||this._createObservables(model,keys);!kb.statistics||kb.statistics.register("ViewModel",this)}ViewModel.prototype.destroy=function(){var vm_key;if(this.__kb.view_model!==this){for(vm_key in this.__kb.vm_keys){this.__kb.view_model[vm_key]=null}}this.__kb.view_model=null;kb.releaseKeys(this);kb.utils.wrappedDestroy(this);return!kb.statistics||kb.statistics.unregister("ViewModel",this)};ViewModel.prototype.shareOptions=function(){return{store:kb.utils.wrappedStore(this),factory:kb.utils.wrappedFactory(this)}};ViewModel.prototype._createObservables=function(model,keys){var create_options,key,vm_key,_i,_len;create_options={store:kb.utils.wrappedStore(this),factory:kb.utils.wrappedFactory(this),path:this.__kb.path,event_watcher:kb.utils.wrappedEventWatcher(this)};for(_i=0,_len=keys.length;_i<_len;_i++){key=keys[_i];vm_key=this.__kb.internals&&_.contains(this.__kb.internals,key)?"_"+key:key;if(this[vm_key]){continue}this.__kb.vm_keys[vm_key]=true;this.__kb.model_keys[key]=true;create_options.key=key;this[vm_key]=this.__kb.view_model[vm_key]=kb.observable(model,create_options,this)}};ViewModel.prototype._mapObservables=function(model,mappings){var create_options,mapping_info,vm_key;create_options={store:kb.utils.wrappedStore(this),factory:kb.utils.wrappedFactory(this),path:this.__kb.path,event_watcher:kb.utils.wrappedEventWatcher(this)};for(vm_key in mappings){mapping_info=mappings[vm_key];if(this[vm_key]){continue}mapping_info=_.isString(mapping_info)?{key:mapping_info}:_.clone(mapping_info);
mapping_info.key||(mapping_info.key=vm_key);this.__kb.vm_keys[vm_key]=true;this.__kb.model_keys[mapping_info.key]=true;this[vm_key]=this.__kb.view_model[vm_key]=kb.observable(model,_.defaults(mapping_info,create_options),this)}};return ViewModel}();kb.viewModel=function(model,options,view_model){return new kb.ViewModel(model,options,view_model)};COMPARE_EQUAL=0;COMPARE_ASCENDING=-1;COMPARE_DESCENDING=1;kb.compare=function(value_a,value_b){if(_.isString(value_a)){return value_a.localeCompare(""+value_b)}if(_.isString(value_b)){return value_b.localeCompare(""+value_a)}if(value_a===value_b){return COMPARE_EQUAL}else{if(value_a<value_b){return COMPARE_ASCENDING}else{return COMPARE_DESCENDING}}};kb.CollectionObservable=function(){CollectionObservable.extend=kb.extend;function CollectionObservable(collection,options){var create_options,observable,_this=this;!collection||collection instanceof kb.Collection||_throwUnexpected(this,"not a collection");options||(options={});observable=kb.utils.wrappedObservable(this,ko.observableArray([]));observable.__kb_is_co=true;this.in_edit=0;this.__kb||(this.__kb={});this.__kb._onCollectionChange=_.bind(this._onCollectionChange,this);options=_collapseOptions(options);if(options.sort_attribute){this._comparator=ko.observable(this._attributeComparator(options.sort_attribute))}else{this._comparator=ko.observable(options.comparator)}if(options.filters){this._filters=ko.observableArray(_.isArray(options.filters)?options.filters:options.filters?[options.filters]:void 0)}else{this._filters=ko.observableArray([])}create_options=this.create_options={store:kb.Store.useOptionsOrCreate(options,collection,observable)};this.path=options.path;create_options.factory=kb.utils.wrappedFactory(observable,this._shareOrCreateFactory(options));create_options.path=kb.utils.pathJoin(options.path,"models");create_options.creator=create_options.factory.creatorForPath(null,create_options.path);if(create_options.creator){this.models_only=create_options.creator.models_only}_publishMethods(observable,this,["destroy","shareOptions","filters","comparator","sortAttribute","viewModelByModel","hasViewModels"]);this._collection=ko.observable(collection);observable.collection=this.collection=ko.dependentObservable({read:function(){return _this._collection()},write:function(new_collection){var previous_collection;if((previous_collection=_this._collection())===new_collection){return}if(previous_collection){previous_collection.unbind("all",_this.__kb._onCollectionChange)}if(new_collection){new_collection.bind("all",_this.__kb._onCollectionChange)}return _this._collection(new_collection)}});if(collection){collection.bind("all",this.__kb._onCollectionChange)}this._mapper=ko.dependentObservable(function(){var comparator,current_collection,filter,filters,models,view_models,_i,_len;comparator=_this._comparator();filters=_this._filters();if(filters){for(_i=0,_len=filters.length;_i<_len;_i++){filter=filters[_i];_unwrapObservable(filter)}}current_collection=_this._collection();if(_this.in_edit){return}observable=kb.utils.wrappedObservable(_this);if(current_collection){models=current_collection.models}if(!models||current_collection.models.length===0){view_models=[]}else{if(filters.length){models=_.filter(models,function(model){return!_this._modelIsFiltered(model)})}if(comparator){view_models=_.map(models,function(model){return _this._createViewModel(model)}).sort(comparator)}else{if(_this.models_only){view_models=filters.length?models:models.slice()}else{view_models=_.map(models,function(model){return _this._createViewModel(model)})}}}_this.in_edit++;observable(view_models);return _this.in_edit--});observable.subscribe(_.bind(this._onObservableArrayChange,this));!kb.statistics||kb.statistics.register("CollectionObservable",this);return observable}CollectionObservable.prototype.destroy=function(){var array,collection,observable;observable=kb.utils.wrappedObservable(this);collection=this._collection();if(collection){collection.unbind("all",this.__kb._onCollectionChange);array=observable();array.splice(0,array.length)}this.collection.dispose();this._collection=observable.collection=this.collection=null;this._mapper.dispose();this._mapper=null;kb.release(this._filters);this._filters=null;this._comparator(null);this._comparator=null;this.create_options=null;observable.collection=null;kb.utils.wrappedDestroy(this);return!kb.statistics||kb.statistics.unregister("CollectionObservable",this)};CollectionObservable.prototype.shareOptions=function(){var observable;observable=kb.utils.wrappedObservable(this);return{store:kb.utils.wrappedStore(observable),factory:kb.utils.wrappedFactory(observable)}};CollectionObservable.prototype.filters=function(filters){if(filters){return this._filters(_.isArray(filters)?filters:[filters])}else{return this._filters([])}};CollectionObservable.prototype.comparator=function(comparator){return this._comparator(comparator)};CollectionObservable.prototype.sortAttribute=function(sort_attribute){return this._comparator(sort_attribute?this._attributeComparator(sort_attribute):null)};CollectionObservable.prototype.viewModelByModel=function(model){var id_attribute;if(this.models_only){return null}id_attribute=model.hasOwnProperty(model.idAttribute)?model.idAttribute:"cid";return _.find(kb.utils.wrappedObservable(this)(),function(test){var _ref;if(test!=null?(_ref=test.__kb)!=null?_ref.object:void 0:void 0){return test.__kb.object[id_attribute]===model[id_attribute]}else{return false}})};CollectionObservable.prototype.hasViewModels=function(){return!this.models_only};CollectionObservable.prototype._shareOrCreateFactory=function(options){var absolute_models_path,existing_creator,factories,factory;absolute_models_path=kb.utils.pathJoin(options.path,"models");factories=options.factories;if(factory=options.factory){if((existing_creator=factory.creatorForPath(null,absolute_models_path))&&(!factories||factories["models"]===existing_creator)){if(!factories){return factory}if(factory.hasPathMappings(factories,options.path)){return factory}}}factory=new kb.Factory(options.factory);if(factories){factory.addPathMappings(factories,options.path)}if(!factory.creatorForPath(null,absolute_models_path)){if(options.hasOwnProperty("models_only")){if(options.models_only){factory.addPathMapping(absolute_models_path,{models_only:true})}else{factory.addPathMapping(absolute_models_path,kb.ViewModel)}}else if(options.view_model){factory.addPathMapping(absolute_models_path,options.view_model)}else if(options.create){factory.addPathMapping(absolute_models_path,{create:options.create})}else{factory.addPathMapping(absolute_models_path,kb.ViewModel)}}return factory};CollectionObservable.prototype._onCollectionChange=function(event,arg){var collection,comparator,observable,view_model;if(this.in_edit){return}switch(event){case"reset":case"resort":this._collection.notifySubscribers(this._collection());break;case"new":case"add":if(this._modelIsFiltered(arg)){return}observable=kb.utils.wrappedObservable(this);collection=this._collection();if(view_model=this.viewModelByModel(arg)){return}this.in_edit++;view_model=this._createViewModel(arg);if(comparator=this._comparator()){observable().push(view_model);observable.sort(comparator)}else{observable.splice(collection.indexOf(arg),0,view_model)}this.in_edit--;break;case"remove":case"destroy":this._onModelRemove(arg);break;case"change":if(this._modelIsFiltered(arg)){this._onModelRemove(arg)}else{view_model=this.models_only?arg:this.viewModelByModel(arg);if(view_model){if(comparator=this._comparator()){observable=kb.utils.wrappedObservable(this);this.in_edit++;observable.sort(comparator);this.in_edit--}}else{this._onCollectionChange("add",arg)}}}};CollectionObservable.prototype._onModelRemove=function(model){var observable,view_model;view_model=this.models_only?model:this.viewModelByModel(model);if(!view_model){return}observable=kb.utils.wrappedObservable(this);this.in_edit++;observable.remove(view_model);return this.in_edit--};CollectionObservable.prototype._onObservableArrayChange=function(models_or_view_models){var collection,has_filters,model,models,observable,view_model,view_models,_i,_len,_this=this;if(this.in_edit){return}this.models_only&&(!models_or_view_models.length||kb.utils.hasModelSignature(models_or_view_models[0]))||!this.models_only&&(!models_or_view_models.length||_.isObject(models_or_view_models[0])&&!kb.utils.hasModelSignature(models_or_view_models[0]))||_throwUnexpected(this,"incorrect type passed");observable=kb.utils.wrappedObservable(this);collection=this._collection();has_filters=this._filters().length;if(!collection){return}view_models=models_or_view_models;if(this.models_only){if(has_filters){models=_.filter(models_or_view_models,function(model){return!_this._modelIsFiltered(model)})}}else{!has_filters||(view_models=[]);models=[];for(_i=0,_len=models_or_view_models.length;_i<_len;_i++){view_model=models_or_view_models[_i];model=kb.utils.wrappedObject(view_model);if(has_filters){if(this._modelIsFiltered(model)){continue}view_models.push(view_model)}this.create_options.store.findOrReplace(model,this.create_options.creator,view_model);models.push(model)}}this.in_edit++;models_or_view_models.length===view_models.length||observable(view_models);_.isEqual(collection.models,models)||collection.reset(models);this.in_edit--};CollectionObservable.prototype._attributeComparator=function(sort_attribute){var modelAttributeCompare;modelAttributeCompare=function(model_a,model_b){var attribute_name;attribute_name=_unwrapObservable(sort_attribute);return kb.compare(model_a.get(attribute_name),model_b.get(attribute_name))};return this.models_only?modelAttributeCompare:function(model_a,model_b){return modelAttributeCompare(kb.utils.wrappedModel(model_a),kb.utils.wrappedModel(model_b))}};CollectionObservable.prototype._createViewModel=function(model){if(this.models_only){return model}return this.create_options.store.findOrCreate(model,this.create_options)};CollectionObservable.prototype._modelIsFiltered=function(model){var filter,filters,_i,_len;filters=this._filters();for(_i=0,_len=filters.length;_i<_len;_i++){filter=filters[_i];filter=_unwrapObservable(filter);if(typeof filter==="function"&&filter(model)||model&&model.id===filter){return true}}return false};return CollectionObservable}();kb.collectionObservable=function(collection,options){return new kb.CollectionObservable(collection,options)};kb.RECUSIVE_AUTO_INJECT=false;ko.bindingHandlers["inject"]={init:function(element,value_accessor,all_bindings_accessor,view_model){return kb.Inject.inject(_unwrapObservable(value_accessor()),view_model,element,value_accessor,all_bindings_accessor)}};kb.Inject=function(){function Inject(){}Inject.inject=function(data,view_model,element,value_accessor,all_bindings_accessor,nested){var inject,result,wrapper;inject=function(data){var key,target,value;if(_.isFunction(data)){view_model=new data(view_model,element,value_accessor,all_bindings_accessor);kb.releaseOnNodeRemove(view_model,element)}else{if(data.view_model){view_model=new data.view_model(view_model,element,value_accessor,all_bindings_accessor);kb.releaseOnNodeRemove(view_model,element)}for(key in data){value=data[key];if(key==="view_model"){continue}if(key==="create"){value(view_model,element,value_accessor,all_bindings_accessor)}else if(_.isObject(value)&&!_.isFunction(value)){target=nested||value&&value.create?{}:view_model;view_model[key]=kb.Inject.inject(value,target,element,value_accessor,all_bindings_accessor,true)}else{view_model[key]=value}}}return view_model};if(nested){return inject(data)}else{result=(wrapper=ko.dependentObservable(function(){return inject(data)}))();wrapper.dispose();return result}};Inject.injectViewModels=function(root){var afterBinding,app,beforeBinding,data,expression,findElements,options,results,_i,_len;results=[];findElements=function(el){var attr,child_el,_i,_len,_ref;if(!el.__kb_injected){if(el.attributes&&(attr=_.find(el.attributes,function(attr){return attr.name==="kb-inject"}))){el.__kb_injected=true;results.push({el:el,view_model:{},binding:attr.value})}}_ref=el.childNodes;for(_i=0,_len=_ref.length;_i<_len;_i++){child_el=_ref[_i];findElements(child_el)}};findElements(root||document);for(_i=0,_len=results.length;_i<_len;_i++){app=results[_i];if(expression=app.binding){expression.search(/[:]/)<0||(expression="{"+expression+"}");data=new Function("","return ( "+expression+" )")();data||(data={});!data.options||(options=data.options,delete data.options);options||(options={});app.view_model=kb.Inject.inject(data,app.view_model,app.el,null,null,true);afterBinding=app.view_model.afterBinding||options.afterBinding;beforeBinding=app.view_model.beforeBinding||options.beforeBinding}if(beforeBinding){beforeBinding(app.view_model,app.el,options)}kb.applyBindings(app.view_model,app.el,options);if(afterBinding){afterBinding(app.view_model,app.el,options)}}return results};return Inject}();_ko_applyBindings=ko.applyBindings;ko.applyBindings=function(context,element){var results;results=kb.RECUSIVE_AUTO_INJECT?kb.injectViewModels(element):[];if(!results.length){return _ko_applyBindings.apply(this,arguments)}};kb.injectViewModels=kb.Inject.injectViewModels;if(this.$){this.$(function(){return kb.injectViewModels()})}else{(onReady=function(){if(document.readyState!=="complete"){return setTimeout(onReady,0)}return kb.injectViewModels()})()}return kb})}.call(this);