// Underscore.js 1.3.3 // (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc. // Underscore is freely distributable under the MIT license. // Portions of Underscore are inspired or borrowed from Prototype, // Oliver Steele's Functional, and John Resig's Micro-Templating. // For all details and documentation: // http://documentcloud.github.com/underscore function S4(){return((1+Math.random())*65536|0).toString(16).substring(1)}function guid(){return S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4()}function setupConfig(e){var t=gbst.namespace("gbst.loan.app.stampdutycalculator.translations");t.en=e}(function(){function C(e,t,n){if(e===t)return e!==0||1/e==1/t;if(e==null||t==null)return e===t;e._chain&&(e=e._wrapped),t._chain&&(t=t._wrapped);if(e.isEqual&&S.isFunction(e.isEqual))return e.isEqual(t);if(t.isEqual&&S.isFunction(t.isEqual))return t.isEqual(e);var r=a.call(e);if(r!=a.call(t))return!1;switch(r){case"[object String]":return e==String(t);case"[object Number]":return e!=+e?t!=+t:e==0?1/e==1/t:e==+t;case"[object Date]":case"[object Boolean]":return+e==+t;case"[object RegExp]":return e.source==t.source&&e.global==t.global&&e.multiline==t.multiline&&e.ignoreCase==t.ignoreCase}if(typeof e!="object"||typeof t!="object")return!1;var i=n.length;while(i--)if(n[i]==e)return!0;n.push(e);var s=0,o=!0;if(r=="[object Array]"){s=e.length,o=s==t.length;if(o)while(s--)if(!(o=s in e==s in t&&C(e[s],t[s],n)))break}else{if("constructor"in e!="constructor"in t||e.constructor!=t.constructor)return!1;for(var u in e)if(S.has(e,u)){s++;if(!(o=S.has(t,u)&&C(e[u],t[u],n)))break}if(o){for(u in t)if(S.has(t,u)&&!(s--))break;o=!s}}return n.pop(),o}var e=this,t=e._,n={},r=Array.prototype,i=Object.prototype,s=Function.prototype,o=r.slice,u=r.unshift,a=i.toString,f=i.hasOwnProperty,l=r.forEach,c=r.map,h=r.reduce,p=r.reduceRight,d=r.filter,v=r.every,m=r.some,g=r.indexOf,y=r.lastIndexOf,b=Array.isArray,w=Object.keys,E=s.bind,S=function(e){return new P(e)};typeof exports!="undefined"?(typeof module!="undefined"&&module.exports&&(exports=module.exports=S),exports._=S):e._=S,S.VERSION="1.3.3";var x=S.each=S.forEach=function(e,t,r){if(e==null)return;if(l&&e.forEach===l)e.forEach(t,r);else if(e.length===+e.length){for(var i=0,s=e.length;i2;e==null&&(e=[]);if(h&&e.reduce===h)return r&&(t=S.bind(t,r)),i?e.reduce(t,n):e.reduce(t);x(e,function(e,s,o){i?n=t.call(r,n,e,s,o):(n=e,i=!0)});if(!i)throw new TypeError("Reduce of empty array with no initial value");return n},S.reduceRight=S.foldr=function(e,t,n,r){var i=arguments.length>2;e==null&&(e=[]);if(p&&e.reduceRight===p)return r&&(t=S.bind(t,r)),i?e.reduceRight(t,n):e.reduceRight(t);var s=S.toArray(e).reverse();return r&&!i&&(t=S.bind(t,r)),i?S.reduce(s,t,n,r):S.reduce(s,t)},S.find=S.detect=function(e,t,n){var r;return T(e,function(e,i,s){if(t.call(n,e,i,s))return r=e,!0}),r},S.filter=S.select=function(e,t,n){var r=[];return e==null?r:d&&e.filter===d?e.filter(t,n):(x(e,function(e,i,s){t.call(n,e,i,s)&&(r[r.length]=e)}),r)},S.reject=function(e,t,n){var r=[];return e==null?r:(x(e,function(e,i,s){t.call(n,e,i,s)||(r[r.length]=e)}),r)},S.every=S.all=function(e,t,r){var i=!0;return e==null?i:v&&e.every===v?e.every(t,r):(x(e,function(e,s,o){if(!(i=i&&t.call(r,e,s,o)))return n}),!!i)};var T=S.some=S.any=function(e,t,r){t||(t=S.identity);var i=!1;return e==null?i:m&&e.some===m?e.some(t,r):(x(e,function(e,s,o){if(i||(i=t.call(r,e,s,o)))return n}),!!i)};S.include=S.contains=function(e,t){var n=!1;return e==null?n:g&&e.indexOf===g?e.indexOf(t)!=-1:(n=T(e,function(e){return e===t}),n)},S.invoke=function(e,t){var n=o.call(arguments,2);return S.map(e,function(e){return(S.isFunction(t)?t||e:e[t]).apply(e,n)})},S.pluck=function(e,t){return S.map(e,function(e){return e[t]})},S.max=function(e,t,n){if(!t&&S.isArray(e)&&e[0]===+e[0])return Math.max.apply(Math,e);if(!t&&S.isEmpty(e))return-Infinity;var r={computed:-Infinity};return x(e,function(e,i,s){var o=t?t.call(n,e,i,s):e;o>=r.computed&&(r={value:e,computed:o})}),r.value},S.min=function(e,t,n){if(!t&&S.isArray(e)&&e[0]===+e[0])return Math.min.apply(Math,e);if(!t&&S.isEmpty(e))return Infinity;var r={computed:Infinity};return x(e,function(e,i,s){var o=t?t.call(n,e,i,s):e;or?1:0}),"value")},S.groupBy=function(e,t){var n={},r=S.isFunction(t)?t:function(e){return e[t]};return x(e,function(e,t){var i=r(e,t);(n[i]||(n[i]=[])).push(e)}),n},S.sortedIndex=function(e,t,n){n||(n=S.identity);var r=0,i=e.length;while(r>1;n(e[s])=0})})},S.difference=function(e){var t=S.flatten(o.call(arguments,1),!0);return S.filter(e,function(e){return!S.include(t,e)})},S.zip=function(){var e=o.call(arguments),t=S.max(S.pluck(e,"length")),n=new Array(t);for(var r=0;r=0;n--)t=[e[n].apply(this,t)];return t[0]}},S.after=function(e,t){return e<=0?t():function(){if(--e<1)return t.apply(this,arguments)}},S.keys=w||function(e){if(e!==Object(e))throw new TypeError("Invalid object");var t=[];for(var n in e)S.has(e,n)&&(t[t.length]=n);return t},S.values=function(e){return S.map(e,S.identity)},S.functions=S.methods=function(e){var t=[];for(var n in e)S.isFunction(e[n])&&t.push(n);return t.sort()},S.extend=function(e){return x(o.call(arguments,1),function(t){for(var n in t)e[n]=t[n]}),e},S.pick=function(e){var t={};return x(S.flatten(o.call(arguments,1)),function(n){n in e&&(t[n]=e[n])}),t},S.defaults=function(e){return x(o.call(arguments,1),function(t){for(var n in t)e[n]==null&&(e[n]=t[n])}),e},S.clone=function(e){return S.isObject(e)?S.isArray(e)?e.slice():S.extend({},e):e},S.tap=function(e,t){return t(e),e},S.isEqual=function(e,t){return C(e,t,[])},S.isEmpty=function(e){if(e==null)return!0;if(S.isArray(e)||S.isString(e))return e.length===0;for(var t in e)if(S.has(e,t))return!1;return!0},S.isElement=function(e){return!!e&&e.nodeType==1},S.isArray=b||function(e){return a.call(e)=="[object Array]"},S.isObject=function(e){return e===Object(e)},S.isArguments=function(e){return a.call(e)=="[object Arguments]"},S.isArguments(arguments)||(S.isArguments=function(e){return!!e&&!!S.has(e,"callee")}),S.isFunction=function(e){return a.call(e)=="[object Function]"},S.isString=function(e){return a.call(e)=="[object String]"},S.isNumber=function(e){return a.call(e)=="[object Number]"},S.isFinite=function(e){return S.isNumber(e)&&isFinite(e)},S.isNaN=function(e){return e!==e},S.isBoolean=function(e){return e===!0||e===!1||a.call(e)=="[object Boolean]"},S.isDate=function(e){return a.call(e)=="[object Date]"},S.isRegExp=function(e){return a.call(e)=="[object RegExp]"},S.isNull=function(e){return e===null},S.isUndefined=function(e){return e===void 0},S.has=function(e,t){return f.call(e,t)},S.noConflict=function(){return e._=t,this},S.identity=function(e){return e},S.times=function(e,t,n){for(var r=0;r/g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")},S.result=function(e,t){if(e==null)return null;var n=e[t];return S.isFunction(n)?n.call(e):n},S.mixin=function(e){x(S.functions(e),function(t){B(t,S[t]=e[t])})};var k=0;S.uniqueId=function(e){var t=k++;return e?e+t:t},S.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var L=/.^/,A={"\\":"\\","'":"'",r:"\r",n:"\n",t:" ",u2028:"\u2028",u2029:"\u2029"};for(var O in A)A[A[O]]=O;var M=/\\|'|\r|\n|\t|\u2028|\u2029/g,_=/\\(\\|'|r|n|t|u2028|u2029)/g,D=function(e){return e.replace(_,function(e,t){return A[t]})};S.template=function(e,t,n){n=S.defaults(n||{},S.templateSettings);var r="__p+='"+e.replace(M,function(e){return"\\"+A[e]}).replace(n.escape||L,function(e,t){return"'+\n_.escape("+D(t)+")+\n'"}).replace(n.interpolate||L,function(e,t){return"'+\n("+D(t)+")+\n'"}).replace(n.evaluate||L,function(e,t){return"';\n"+D(t)+"\n;__p+='"})+"';\n";n.variable||(r="with(obj||{}){\n"+r+"}\n"),r="var __p='';var print=function(){__p+=Array.prototype.join.call(arguments, '')};\n"+r+"return __p;\n";var i=new Function(n.variable||"obj","_",r);if(t)return i(t,S);var s=function(e){return i.call(this,e,S)};return s.source="function("+(n.variable||"obj")+"){\n"+r+"}",s},S.chain=function(e){return S(e).chain()};var P=function(e){this._wrapped=e};S.prototype=P.prototype;var H=function(e,t){return t?S(e).chain():e},B=function(e,t){P.prototype[e]=function(){var e=o.call(arguments);return u.call(e,this._wrapped),H(t.apply(S,e),this._chain)}};S.mixin(S),x(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var t=r[e];P.prototype[e]=function(){var n=this._wrapped;t.apply(n,arguments);var r=n.length;return(e=="shift"||e=="splice")&&r===0&&delete n[0],H(n,this._chain)}}),x(["concat","join","slice"],function(e){var t=r[e];P.prototype[e]=function(){return H(t.apply(this._wrapped,arguments),this._chain)}}),P.prototype.chain=function(){return this._chain=!0,this},P.prototype.value=function(){return this._wrapped}}).call(this),function(){var e=this,t=e.Backbone,n=Array.prototype.slice,r=Array.prototype.splice,i;typeof exports!="undefined"?i=exports:i=e.Backbone={},i.VERSION="0.9.2";var s=e._;!s&&typeof require!="undefined"&&(s=require("underscore"));var o=e.jQuery||e.Zepto||e.ender;i.setDomLibrary=function(e){o=e},i.noConflict=function(){return e.Backbone=t,this},i.emulateHTTP=!1,i.emulateJSON=!1;var u=/\s+/,a=i.Events={on:function(e,t,n){var r,i,s,o,a;if(!t)return this;e=e.split(u),r=this._callbacks||(this._callbacks={});while(i=e.shift())a=r[i],s=a?a.tail:{},s.next=o={},s.context=n,s.callback=t,r[i]={tail:o,next:a?a.next:s};return this},off:function(e,t,n){var r,i,o,a,f,l;if(!(i=this._callbacks))return;if(!(e||t||n))return delete this._callbacks,this;e=e?e.split(u):s.keys(i);while(r=e.shift()){o=i[r],delete i[r];if(!o||!t&&!n)continue;a=o.tail;while((o=o.next)!==a)f=o.callback,l=o.context,(t&&f!==t||n&&l!==n)&&this.on(r,f,l)}return this},trigger:function(e){var t,r,i,s,o,a,f;if(!(i=this._callbacks))return this;a=i.all,e=e.split(u),f=n.call(arguments,1);while(t=e.shift()){if(r=i[t]){s=r.tail;while((r=r.next)!==s)r.callback.apply(r.context||this,f)}if(r=a){s=r.tail,o=[t].concat(f);while((r=r.next)!==s)r.callback.apply(r.context||this,o)}}return this}};a.bind=a.on,a.unbind=a.off;var f=i.Model=function(e,t){var n;e||(e={}),t&&t.parse&&(e=this.parse(e));if(n=C(this,"defaults"))e=s.extend({},n,e);t&&t.collection&&(this.collection=t.collection),this.attributes={},this._escapedAttributes={},this.cid=s.uniqueId("c"),this.changed={},this._silent={},this._pending={},this.set(e,{silent:!0}),this.changed={},this._silent={},this._pending={},this._previousAttributes=s.clone(this.attributes),this.initialize.apply(this,arguments)};s.extend(f.prototype,a,{changed:null,_silent:null,_pending:null,idAttribute:"id",initialize:function(){},toJSON:function(e){return s.clone(this.attributes)},get:function(e){return this.attributes[e]},escape:function(e){var t;if(t=this._escapedAttributes[e])return t;var n=this.get(e);return this._escapedAttributes[e]=s.escape(n==null?"":""+n)},has:function(e){return this.get(e)!=null},set:function(e,t,n){var r,i,o;s.isObject(e)||e==null?(r=e,n=t):(r={},r[e]=t),n||(n={});if(!r)return this;r instanceof f&&(r=r.attributes);if(n.unset)for(i in r)r[i]=void 0;if(!this._validate(r,n))return!1;this.idAttribute in r&&(this.id=r[this.idAttribute]);var u=n.changes={},a=this.attributes,l=this._escapedAttributes,c=this._previousAttributes||{};for(i in r){o=r[i];if(!s.isEqual(a[i],o)||n.unset&&s.has(a,i))delete l[i],(n.silent?this._silent:u)[i]=!0;n.unset?delete a[i]:a[i]=o,!s.isEqual(c[i],o)||s.has(a,i)!=s.has(c,i)?(this.changed[i]=o,n.silent||(this._pending[i]=!0)):(delete this.changed[i],delete this._pending[i])}return n.silent||this.change(n),this},unset:function(e,t){return(t||(t={})).unset=!0,this.set(e,null,t)},clear:function(e){return(e||(e={})).unset=!0,this.set(s.clone(this.attributes),e)},fetch:function(e){e=e?s.clone(e):{};var t=this,n=e.success;return e.success=function(r,i,s){if(!t.set(t.parse(r,s),e))return!1;n&&n(t,r)},e.error=i.wrapError(e.error,t,e),(this.sync||i.sync).call(this,"read",this,e)},save:function(e,t,n){var r,o;s.isObject(e)||e==null?(r=e,n=t):(r={},r[e]=t),n=n?s.clone(n):{};if(n.wait){if(!this._validate(r,n))return!1;o=s.clone(this.attributes)}var u=s.extend({},n,{silent:!0});if(r&&!this.set(r,n.wait?u:n))return!1;var a=this,f=n.success;n.success=function(e,t,i){var o=a.parse(e,i);n.wait&&(delete n.wait,o=s.extend(r||{},o));if(!a.set(o,n))return!1;f?f(a,e):a.trigger("sync",a,e,n)},n.error=i.wrapError(n.error,a,n);var l=this.isNew()?"create":"update",c=(this.sync||i.sync).call(this,l,this,n);return n.wait&&this.set(o,u),c},destroy:function(e){e=e?s.clone(e):{};var t=this,n=e.success,r=function(){t.trigger("destroy",t,t.collection,e)};if(this.isNew())return r(),!1;e.success=function(i){e.wait&&r(),n?n(t,i):t.trigger("sync",t,i,e)},e.error=i.wrapError(e.error,t,e);var o=(this.sync||i.sync).call(this,"delete",this,e);return e.wait||r(),o},url:function(){var e=C(this,"urlRoot")||C(this.collection,"url")||k();return this.isNew()?e:e+(e.charAt(e.length-1)=="/"?"":"/")+encodeURIComponent(this.id)},parse:function(e,t){return e},clone:function(){return new this.constructor(this.attributes)},isNew:function(){return this.id==null},change:function(e){e||(e={});var t=this._changing;this._changing=!0;for(var n in this._silent)this._pending[n]=!0;var r=s.extend({},e.changes,this._silent);this._silent={};for(var n in r)this.trigger("change:"+n,this,this.get(n),e);if(t)return this;while(!s.isEmpty(this._pending)){this._pending={},this.trigger("change",this,e);for(var n in this.changed){if(this._pending[n]||this._silent[n])continue;delete this.changed[n]}this._previousAttributes=s.clone(this.attributes)}return this._changing=!1,this},hasChanged:function(e){return arguments.length?s.has(this.changed,e):!s.isEmpty(this.changed)},changedAttributes:function(e){if(!e)return this.hasChanged()?s.clone(this.changed):!1;var t,n=!1,r=this._previousAttributes;for(var i in e){if(s.isEqual(r[i],t=e[i]))continue;(n||(n={}))[i]=t}return n},previous:function(e){return!arguments.length||!this._previousAttributes?null:this._previousAttributes[e]},previousAttributes:function(){return s.clone(this._previousAttributes)},isValid:function(){return!this.validate(this.attributes)},_validate:function(e,t){if(t.silent||!this.validate)return!0;e=s.extend({},this.attributes,e);var n=this.validate(e,t);return n?(t&&t.error?t.error(this,n,t):this.trigger("error",this,n,t),!1):!0}});var l=i.Collection=function(e,t){t||(t={}),t.model&&(this.model=t.model),t.comparator&&(this.comparator=t.comparator),this._reset(),this.initialize.apply(this,arguments),e&&this.reset(e,{silent:!0,parse:t.parse})};s.extend(l.prototype,a,{model:f,initialize:function(){},toJSON:function(e){return this.map(function(t){return t.toJSON(e)})},add:function(e,t){var n,i,o,u,a,f,l={},c={},h=[];t||(t={}),e=s.isArray(e)?e.slice():[e];for(n=0,o=e.length;n').hide().appendTo("body")[0].contentWindow,this.navigate(t)),this._hasPushState?o(window).bind("popstate",this.checkUrl):this._wantsHashChange&&"onhashchange"in window&&!r?o(window).bind("hashchange",this.checkUrl):this._wantsHashChange&&(this._checkUrlInterval=setInterval(this.checkUrl,this.interval)),this.fragment=t;var i=window.location,u=i.pathname==this.options.root;if(this._wantsHashChange&&this._wantsPushState&&!this._hasPushState&&!u)return this.fragment=this.getFragment(null,!0),window.location.replace(this.options.root+"#"+this.fragment),!0;this._wantsPushState&&this._hasPushState&&u&&i.hash&&(this.fragment=this.getHash().replace(g,""),window.history.replaceState({},document.title,i.protocol+"//"+i.host+this.options.root+this.fragment));if(!this.options.silent)return this.loadUrl()},stop:function(){o(window).unbind("popstate",this.checkUrl).unbind("hashchange",this.checkUrl),clearInterval(this._checkUrlInterval),m.started=!1},route:function(e,t){this.handlers.unshift({route:e,callback:t})},checkUrl:function(e){var t=this.getFragment();t==this.fragment&&this.iframe&&(t=this.getFragment(this.getHash(this.iframe)));if(t==this.fragment)return!1;this.iframe&&this.navigate(t),this.loadUrl()||this.loadUrl(this.getHash())},loadUrl:function(e){var t=this.fragment=this.getFragment(e),n=s.any(this.handlers,function(e){if(e.route.test(t))return e.callback(t),!0});return n},navigate:function(e,t){if(!m.started)return!1;if(!t||t===!0)t={trigger:t};var n=(e||"").replace(g,"");if(this.fragment==n)return;this._hasPushState?(n.indexOf(this.options.root)!=0&&(n=this.options.root+n),this.fragment=n,window.history[t.replace?"replaceState":"pushState"]({},document.title,n)):this._wantsHashChange?(this.fragment=n,this._updateHash(window.location,n,t.replace),this.iframe&&n!=this.getFragment(this.getHash(this.iframe))&&(t.replace||this.iframe.document.open().close(),this._updateHash(this.iframe.location,n,t.replace))):window.location.assign(this.options.root+e),t.trigger&&this.loadUrl(e)},_updateHash:function(e,t,n){n?e.replace(e.toString().replace(/(javascript:|#).*$/,"")+"#"+t):e.hash=t}});var b=i.View=function(e){this.cid=s.uniqueId("view"),this._configure(e||{}),this._ensureElement(),this.initialize.apply(this,arguments),this.delegateEvents()},w=/^(\S+)\s*(.*)$/,E=["model","collection","el","id","attributes","className","tagName"];s.extend(b.prototype,a,{tagName:"div",$:function(e){return this.$el.find(e)},initialize:function(){},render:function(){return this},remove:function(){return this.$el.remove(),this},make:function(e,t,n){var r=document.createElement(e);return t&&o(r).attr(t),n&&o(r).html(n),r},setElement:function(e,t){return this.$el&&this.undelegateEvents(),this.$el=e instanceof o?e:o(e),this.el=this.$el[0],t!==!1&&this.delegateEvents(),this},delegateEvents:function(e){if(!e&&!(e=C(this,"events")))return;this.undelegateEvents();for(var t in e){var n=e[t];s.isFunction(n)||(n=this[e[t]]);if(!n)throw new Error('Method "'+e[t]+'" does not exist');var r=t.match(w),i=r[1],o=r[2];n=s.bind(n,this),i+=".delegateEvents"+this.cid,o===""?this.$el.bind(i,n):this.$el.delegate(o,i,n)}},undelegateEvents:function(){this.$el.unbind(".delegateEvents"+this.cid)},_configure:function(e){this.options&&(e=s.extend({},this.options,e));for(var t=0,n=E.length;tthis.maxSize)throw"Max collection size exceeded";return e.id||(e.id=e.attributes.id=t()),this.data[e.id]=_.extend({},e),e},find:function(e){return this.data[e.id]},findAll:function(){return _.values(this.data)},update:function(e){return this.data[e.id]=_.extend({},e),e},destroy:function(e){return delete this.data[e.id],e}}),Backbone.sync=function(e,t,n,r){typeof n=="function"&&(n={success:n,error:r});var i,s=t.collection||t,o=s.noPersistence;_.isUndefined(o)&&(s.noPersistence=new bnp.NoPersistence,o=s.noPersistence);switch(e){case"read":i=t.id?o.find(t):o.findAll();break;case"create":i=o.create(t);break;case"update":i=o.update(t);break;case"delete":i=o.destroy(t)}i?n.success(i):n.error("Record not found")}}(),function(e){"use strict";var t,n,r;typeof window=="undefined"?(t=require("underscore"),n=require("backbone"),r=module.exports=n):(t=window._,n=window.Backbone,r=window),n.Relational={showWarnings:!0},n.Semaphore={_permitsAvailable:null,_permitsUsed:0,acquire:function(){if(this._permitsAvailable&&this._permitsUsed>=this._permitsAvailable)throw new Error("Max permits acquired");this._permitsUsed++},release:function(){if(this._permitsUsed===0)throw new Error("All permits released");this._permitsUsed--},isLocked:function(){return this._permitsUsed>0},setAvailablePermits:function(e){if(this._permitsUsed>e)throw new Error("Available permits cannot be less than used permits");this._permitsAvailable=e}},n.BlockingQueue=function(){this._queue=[]},t.extend(n.BlockingQueue.prototype,n.Semaphore,{_queue:null,add:function(e){this.isBlocked()?this._queue.push(e):e()},process:function(){while(this._queue&&this._queue.length)this._queue.shift()()},block:function(){this.acquire()},unblock:function(){this.release(),this.isBlocked()||this.process()},isBlocked:function(){return this.isLocked()}}),n.Relational.eventQueue=new n.BlockingQueue,n.Store=function(){this._collections=[],this._reverseRelations=[],this._subModels=[],this._modelScopes=[r]},t.extend(n.Store.prototype,n.Events,{addModelScope:function(e){this._modelScopes.push(e)},addSubModels:function(e,t){this._subModels.push({superModelType:t,subModels:e})},setupSuperModel:function(e){t.find(this._subModels,function(n){return t.find(n.subModels,function(t,r){var i=this.getObjectByName(t);if(e===i)return n.superModelType._subModels[r]=e,e._superModel=n.superModelType,e._subModelTypeValue=r,e._subModelTypeAttribute=n.superModelType.prototype.subModelTypeAttribute,!0},this)},this)},addReverseRelation:function(e){var n=t.any(this._reverseRelations,function(n){return t.all(e,function(e,t){return e===n[t]})});if(!n&&e.model&&e.type){this._reverseRelations.push(e);var r=function(e,n){e.prototype.relations||(e.prototype.relations=[]),e.prototype.relations.push(n),t.each(e._subModels,function(e){r(e,n)},this)};r(e.model,e),this.retroFitRelation(e)}},retroFitRelation:function(e){var t=this.getCollection(e.model);t.each(function( t){if(!(t instanceof e.model))return;new e.type(t,e)},this)},getCollection:function(e){e instanceof n.RelationalModel&&(e=e.constructor);var r=e;while(r._superModel)r=r._superModel;var i=t.detect(this._collections,function(e){return e.model===r});return i||(i=this._createCollection(r)),i},getObjectByName:function(e){var n=e.split("."),r=null;return t.find(this._modelScopes,function(e){r=t.reduce(n,function(e,t){return e[t]},e);if(r&&r!==e)return!0},this),r},_createCollection:function(e){var t;return e instanceof n.RelationalModel&&(e=e.constructor),e.prototype instanceof n.RelationalModel&&(t=new n.Collection,t.model=e,this._collections.push(t)),t},resolveIdForItem:function(e,r){var i=t.isString(r)||t.isNumber(r)?r:null;return i===null&&(r instanceof n.RelationalModel?i=r.id:t.isObject(r)&&(i=r[e.prototype.idAttribute])),!i&&i!==0&&(i=null),i},find:function(e,t){var n=this.resolveIdForItem(e,t),r=this.getCollection(e);if(r){var i=r.get(n);if(i instanceof e)return i}return null},register:function(e){var t=this.getCollection(e);if(t){if(t.get(e))throw new Error("Cannot instantiate more than one Backbone.RelationalModel with the same id per type!");var n=e.collection;t.add(e),e.bind("destroy",this.unregister,this),e.collection=n}},update:function(e){var t=this.getCollection(e);t._onModelEvent("change:"+e.idAttribute,e,t)},unregister:function(e){e.unbind("destroy",this.unregister);var t=this.getCollection(e);t&&t.remove(e)}}),n.Relational.store=new n.Store,n.Relation=function(e,r){this.instance=e,r=t.isObject(r)?r:{},this.reverseRelation=t.defaults(r.reverseRelation||{},this.options.reverseRelation),this.reverseRelation.type=t.isString(this.reverseRelation.type)?n[this.reverseRelation.type]||n.Relational.store.getObjectByName(this.reverseRelation.type):this.reverseRelation.type,this.model=r.model||this.instance.constructor,this.options=t.defaults(r,this.options,n.Relation.prototype.options),this.key=this.options.key,this.keySource=this.options.keySource||this.key,this.keyDestination=this.options.keyDestination||this.keySource||this.key,this.relatedModel=this.options.relatedModel,t.isString(this.relatedModel)&&(this.relatedModel=n.Relational.store.getObjectByName(this.relatedModel));if(!this.checkPreconditions())return!1;e&&(this.keyContents=this.instance.get(this.keySource),this.key!==this.keySource&&this.instance.unset(this.keySource,{silent:!0}),this.instance._relations.push(this)),!this.options.isAutoRelation&&this.reverseRelation.type&&this.reverseRelation.key&&n.Relational.store.addReverseRelation(t.defaults({isAutoRelation:!0,model:this.relatedModel,relatedModel:this.model,reverseRelation:this.options},this.reverseRelation)),t.bindAll(this,"_modelRemovedFromCollection","_relatedModelAdded","_relatedModelRemoved"),e&&(this.initialize(),n.Relational.store.getCollection(this.instance).bind("relational:remove",this._modelRemovedFromCollection),n.Relational.store.getCollection(this.relatedModel).bind("relational:add",this._relatedModelAdded).bind("relational:remove",this._relatedModelRemoved))},n.Relation.extend=n.Model.extend,t.extend(n.Relation.prototype,n.Events,n.Semaphore,{options:{createModels:!0,includeInJSON:!0,isAutoRelation:!1},instance:null,key:null,keyContents:null,relatedModel:null,reverseRelation:null,related:null,_relatedModelAdded:function(e,t,n){var r=this;e.queue(function(){r.tryAddRelated(e,n)})},_relatedModelRemoved:function(e,t,n){this.removeRelated(e,n)},_modelRemovedFromCollection:function(e){e===this.instance&&this.destroy()},checkPreconditions:function(){var e=this.instance,r=this.key,i=this.model,s=this.relatedModel,o=n.Relational.showWarnings&&typeof console!="undefined";if(!i||!r||!s)return o&&console.warn("Relation=%o; no model, key or relatedModel (%o, %o, %o)",this,i,r,s),!1;if(i.prototype instanceof n.RelationalModel){if(s.prototype instanceof n.RelationalModel){if(this instanceof n.HasMany&&this.reverseRelation.type===n.HasMany)return o&&console.warn("Relation=%o; relation is a HasMany, and the reverseRelation is HasMany as well.",this),!1;if(e&&e._relations.length){var u=t.any(e._relations,function(e){var t=this.reverseRelation.key&&e.reverseRelation.key;return e.relatedModel===s&&e.key===r&&(!t||this.reverseRelation.key===e.reverseRelation.key)},this);if(u)return o&&console.warn("Relation=%o between instance=%o.%s and relatedModel=%o.%s already exists",this,e,r,s,this.reverseRelation.key),!1}return!0}return o&&console.warn("Relation=%o; relatedModel does not inherit from Backbone.RelationalModel (%o)",this,s),!1}return o&&console.warn("Relation=%o; model does not inherit from Backbone.RelationalModel (%o)",this,e),!1},setRelated:function(e,n){this.related=e,this.instance.acquire(),this.instance.set(this.key,e,t.defaults(n||{},{silent:!0})),this.instance.release()},_isReverseRelation:function(e){return e.instance instanceof this.relatedModel&&this.reverseRelation.key===e.key&&this.key===e.reverseRelation.key?!0:!1},getReverseRelations:function(e){var n=[],r=t.isUndefined(e)?this.related&&(this.related.models||[this.related]):[e];return t.each(r,function(e){t.each(e.getRelations(),function(e){this._isReverseRelation(e)&&n.push(e)},this)},this),n},sanitizeOptions:function(e){return e=e?t.clone(e):{},e.silent&&(e.silentChange=!0,delete e.silent),e},unsanitizeOptions:function(e){return e=e?t.clone(e):{},e.silentChange&&(e.silent=!0,delete e.silentChange),e},destroy:function(){n.Relational.store.getCollection(this.instance).unbind("relational:remove",this._modelRemovedFromCollection),n.Relational.store.getCollection(this.relatedModel).unbind("relational:add",this._relatedModelAdded).unbind("relational:remove",this._relatedModelRemoved),t.each(this.getReverseRelations(),function(e){e.removeRelated(this.instance)},this)}}),n.HasOne=n.Relation.extend({options:{reverseRelation:{type:"HasMany"}},initialize:function(){t.bindAll(this,"onChange"),this.instance.bind("relational:change:"+this.key,this.onChange);var e=this.findRelated({silent:!0});this.setRelated(e),t.each(this.getReverseRelations(),function(e){e.addRelated(this.instance)},this)},findRelated:function(e){var t=this.keyContents,n=null;if(t instanceof this.relatedModel)n=t;else if(t||t===0)n=this.relatedModel.findOrCreate(t,{create:this.options.createModels});return n},onChange:function(e,r,i){if(this.isLocked())return;this.acquire(),i=this.sanitizeOptions(i);var s=t.isUndefined(i._related),o=s?this.related:i._related;if(s){this.keyContents=r;if(r instanceof this.relatedModel)this.related=r;else if(r){var u=this.findRelated(i);this.setRelated(u)}else this.setRelated(null)}o&&this.related!==o&&t.each(this.getReverseRelations(o),function(e){e.removeRelated(this.instance,i)},this),t.each(this.getReverseRelations(),function(e){e.addRelated(this.instance,i)},this);if(!i.silentChange&&this.related!==o){var a=this;n.Relational.eventQueue.add(function(){a.instance.trigger("update:"+a.key,a.instance,a.related,i)})}this.release()},tryAddRelated:function(e,r){if(this.related)return;r=this.sanitizeOptions(r);var i=this.keyContents;if(i||i===0){var s=n.Relational.store.resolveIdForItem(this.relatedModel,i);!t.isNull(s)&&e.id===s&&this.addRelated(e,r)}},addRelated:function(e,t){if(e!==this.related){var n=this.related||null;this.setRelated(e),this.onChange(this.instance,e,{_related:n})}},removeRelated:function(e,t){if(!this.related)return;if(e===this.related){var n=this.related||null;this.setRelated(null),this.onChange(this.instance,e,{_related:n})}}}),n.HasMany=n.Relation.extend({collectionType:null,options:{reverseRelation:{type:"HasOne"},collectionType:n.Collection,collectionKey:!0,collectionOptions:{}},initialize:function(){t.bindAll(this,"onChange","handleAddition","handleRemoval","handleReset"),this.instance.bind("relational:change:"+this.key,this.onChange),this.collectionType=this.options.collectionType,t.isString(this.collectionType)&&(this.collectionType=n.Relational.store.getObjectByName(this.collectionType));if(!this.collectionType.prototype instanceof n.Collection)throw new Error("collectionType must inherit from Backbone.Collection");this.keyContents instanceof n.Collection?this.setRelated(this._prepareCollection(this.keyContents)):this.setRelated(this._prepareCollection()),this.findRelated({silent:!0})},_getCollectionOptions:function(){return t.isFunction(this.options.collectionOptions)?this.options.collectionOptions(this.instance):this.options.collectionOptions},_prepareCollection:function(e){this.related&&this.related.unbind("relational:add",this.handleAddition).unbind("relational:remove",this.handleRemoval).unbind("relational:reset",this.handleReset);if(!e||!(e instanceof n.Collection))e=new this.collectionType([],this._getCollectionOptions());e.model=this.relatedModel;if(this.options.collectionKey){var t=this.options.collectionKey===!0?this.options.reverseRelation.key:this.options.collectionKey;e[t]&&e[t]!==this.instance?n.Relational.showWarnings&&typeof console!="undefined"&&console.warn("Relation=%o; collectionKey=%s already exists on collection=%o",this,t,this.options.collectionKey):t&&(e[t]=this.instance)}return e.bind("relational:add",this.handleAddition).bind("relational:remove",this.handleRemoval).bind("relational:reset",this.handleReset),e},findRelated:function(e){if(this.keyContents){var r=[];this.keyContents instanceof n.Collection?r=this.keyContents.models:(this.keyContents=t.isArray(this.keyContents)?this.keyContents:[this.keyContents],t.each(this.keyContents,function(e){var t=null;if(e instanceof this.relatedModel)t=e;else if(e||e===0)t=this.relatedModel.findOrCreate(e,{create:this.options.createModels});t&&!this.related.getByCid(t)&&!this.related.get(t)&&r.push(t)},this)),r.length&&(e=this.unsanitizeOptions(e),this.related.add(r,e))}},onChange:function(e,r,i){i=this.sanitizeOptions(i),this.keyContents=r,t.each(this.getReverseRelations(),function(e){e.removeRelated(this.instance,i)},this);if(r instanceof n.Collection)this._prepareCollection(r),this.related=r;else{var s;this.related instanceof n.Collection?(s=this.related,s.remove(s.models)):s=this._prepareCollection(),this.setRelated(s),this.findRelated(i)}t.each(this.getReverseRelations(),function(e){e.addRelated(this.instance,i)},this);var o=this;n.Relational.eventQueue.add(function(){!i.silentChange&&o.instance.trigger("update:"+o.key,o.instance,o.related,i)})},tryAddRelated:function(e,r){r=this.sanitizeOptions(r);if(!this.related.getByCid(e)&&!this.related.get(e)){var i=t.any(this.keyContents,function(r){var i=n.Relational.store.resolveIdForItem(this.relatedModel,r);return!t.isNull(i)&&i===e.id},this);i&&this.related.add(e,r)}},handleAddition:function(e,r,i){if(!(e instanceof n.Model))return;i=this.sanitizeOptions(i),t.each(this.getReverseRelations(e),function(e){e.addRelated(this.instance,i)},this);var s=this;n.Relational.eventQueue.add(function(){!i.silentChange&&s.instance.trigger("add:"+s.key,e,s.related,i)})},handleRemoval:function(e,r,i){if(!(e instanceof n.Model))return;i=this.sanitizeOptions(i),t.each(this.getReverseRelations(e),function(e){e.removeRelated(this.instance,i)},this);var s=this;n.Relational.eventQueue.add(function(){!i.silentChange&&s.instance.trigger("remove:"+s.key,e,s.related,i)})},handleReset:function(e,t){t=this.sanitizeOptions(t);var r=this;n.Relational.eventQueue.add(function(){!t.silentChange&&r.instance.trigger("reset:"+r.key,r.related,t)})},addRelated:function(e,t){var n=this;t=this.unsanitizeOptions(t),e.queue(function(){n.related&&!n.related.getByCid(e)&&!n.related.get(e)&&n.related.add(e,t)})},removeRelated:function(e,t){t=this.unsanitizeOptions(t),(this.related.getByCid(e)||this.related.get(e))&&this.related.remove(e,t)}}),n.RelationalModel=n.Model.extend({relations:null,_relations:null,_isInitialized:!1,_deferProcessing:!1,_queue:null,subModelTypeAttribute:"type",subModelTypes:null,constructor:function(e,r){var i=this;if(r&&r.collection){this._deferProcessing=!0;var s=function(e){e===i&&(i._deferProcessing=!1,i.processQueue(),r.collection.unbind("relational:add",s))};r.collection.bind("relational:add",s),t.defer(function(){s(i)})}this._queue=new n.BlockingQueue,this._queue.block(),n.Relational.eventQueue.block(),n.Model.apply(this,arguments),n.Relational.eventQueue.unblock()},trigger:function(e){if(e.length>5&&"change"===e.substr(0,6)){var t=this,r=arguments;n.Relational.eventQueue.add(function(){n.Model.prototype.trigger.apply(t,r)})}else n.Model.prototype.trigger.apply(this,arguments);return this},initializeRelations:function(){this.acquire(),this._relations=[],t.each(this.relations,function(e){var r=t.isString(e.type)?n[e.type]||n.Relational.store.getObjectByName(e.type):e.type;r&&r.prototype instanceof n.Relation?new r(this,e):n.Relational.showWarnings&&typeof console!="undefined"&&console.warn("Relation=%o; missing or invalid type!",e)},this),this._isInitialized=!0,this.release(),this.processQueue()},updateRelations:function(e){this._isInitialized&&!this.isLocked()&&t.each(this._relations,function(t){var n=this.attributes[t.keySource]||this.attributes[t.key];t.related!==n&&this.trigger("relational:change:"+t.key,this,n,e||{})},this)},queue:function(e){this._queue.add(e)},processQueue:function(){this._isInitialized&&!this._deferProcessing&&this._queue.isBlocked()&&this._queue.unblock()},getRelation:function(e){return t.detect(this._relations,function(t){if(t.key===e)return!0},this)},getRelations:function(){return this._relations},fetchRelated:function(e,r,i){r||(r={});var s,o=[],u=this.getRelation(e),a=u&&u.keyContents,f=a&&t.select(t.isArray(a)?a:[a],function(e){var r=n.Relational.store.resolveIdForItem(u.relatedModel,e);return!t.isNull(r)&&(i||!n.Relational.store.find(u.relatedModel,r))},this);if(f&&f.length){var l=t.map(f,function(e){var n;if(t.isObject(e))n=u.relatedModel.build(e);else{var r={};r[u.relatedModel.prototype.idAttribute]=e,n=u.relatedModel.build(r)}return n},this);u.related instanceof n.Collection&&t.isFunction(u.related.url)&&(s=u.related.url(l));if(s&&s!==u.related.url()){var c=t.defaults({error:function(){var e=arguments;t.each(l,function(t){t.trigger("destroy",t,t.collection,r),r.error&&r.error.apply(t,e)})},url:s},r,{add:!0});o=[u.related.fetch(c)]}else o=t.map(l,function(e){var n=t.defaults({error:function(){e.trigger("destroy",e,e.collection,r),r.error&&r.error.apply(e,arguments)}},r);return e.fetch(n)},this)}return o},set:function(e,r,i){n.Relational.eventQueue.block();var s;t.isObject(e)||e==null?(s=e,i=r):(s={},s[e]=r);var o=n.Model.prototype.set.apply(this,arguments);return!this._isInitialized&&!this.isLocked()?(this.constructor.initializeModelHierarchy(),n.Relational.store.register(this),this.initializeRelations()):s&&this.idAttribute in s&&n.Relational.store.update(this),s&&this.updateRelations(i),n.Relational.eventQueue.unblock(),o},unset:function(e,t){n.Relational.eventQueue.block();var r=n.Model.prototype.unset.apply(this,arguments);return this.updateRelations(t),n.Relational.eventQueue.unblock(),r},clear:function(e){n.Relational.eventQueue.block();var t=n.Model.prototype.clear.apply(this,arguments);return this.updateRelations(e),n.Relational.eventQueue.unblock(),t},change:function(e){var t=this,r=arguments;n.Relational.eventQueue.add(function(){n.Model.prototype.change.apply(t,r)})},clone:function(){var e=t.clone(this.attributes);return t.isUndefined(e[this.idAttribute])||(e[this.idAttribute]=null),t.each(this.getRelations(),function(t){delete e[t.key]}),new this.constructor(e)},toJSON:function(){if(this.isLocked())return this.id;this.acquire();var e=n.Model.prototype.toJSON.call(this);return this.constructor._superModel&&!(this.constructor._subModelTypeAttribute in e)&&(e[this.constructor._subModelTypeAttribute]=this.constructor._subModelTypeValue),t.each(this._relations,function(r){var i=e[r.key];if(r.options.includeInJSON===!0)i&&t.isFunction(i.toJSON)?e[r.keyDestination]=i.toJSON():e[r.keyDestination]=null;else if(t.isString(r.options.includeInJSON))i instanceof n.Collection?e[r.keyDestination]=i.pluck(r.options.includeInJSON):i instanceof n.Model?e[r.keyDestination]=i.get(r.options.includeInJSON):e[r.keyDestination]=null;else if(t.isArray(r.options.includeInJSON))if(i instanceof n.Collection){var s=[];i.each(function(e){var n={};t.each(r.options.includeInJSON,function(t){n[t]=e.get(t)}),s.push(n)}),e[r.keyDestination]=s}else if(i instanceof n.Model){var s={};t.each(r.options.includeInJSON,function(e){s[e]=i.get(e)}),e[r.keyDestination]=s}else e[r.keyDestination]=null;else delete e[r.key];r.keyDestination!==r.key&&delete e[r.key]}),this.release(),e}},{setup:function(e){return this.prototype.relations=(this.prototype.relations||[]).slice(0),this._subModels={},this._superModel=null,this.prototype.hasOwnProperty("subModelTypes")?n.Relational.store.addSubModels(this.prototype.subModelTypes,this):this.prototype.subModelTypes=null,t.each(this.prototype.relations,function(e){e.model||(e.model=this);if(e.reverseRelation&&e.model===this){var r=!0;if(t.isString(e.relatedModel)){var i=n.Relational.store.getObjectByName(e.relatedModel);r=i&&i.prototype instanceof n.RelationalModel}var s=t.isString(e.type)?n[e.type]||n.Relational.store.getObjectByName(e.type):e.type;r&&s&&s.prototype instanceof n.Relation&&new s(null,e)}},this),this},build:function(e,t){var n=this;this.initializeModelHierarchy();if(this._subModels&&this.prototype.subModelTypeAttribute in e){var r=e[this.prototype.subModelTypeAttribute],i=this._subModels[r];i&&(n=i)}return new n(e,t)},initializeModelHierarchy:function(){if(t.isUndefined(this._superModel)||t.isNull(this._superModel)){n.Relational.store.setupSuperModel(this);if(this._superModel){if(this._superModel.prototype.relations){var e=t.any(this.prototype.relations,function(e){return e.model&&e.model!==this},this);e||(this.prototype.relations=this._superModel.prototype.relations.concat(this.prototype.relations))}}else this._superModel=!1}this.prototype.subModelTypes&&t.keys(this.prototype.subModelTypes).length!==t.keys(this._subModels).length&&t.each(this.prototype.subModelTypes,function(e){var t=n.Relational.store.getObjectByName(e);t&&t.initializeModelHierarchy()})},findOrCreate:function(e,r){var i=n.Relational.store.find(this,e);if(t.isObject(e))if(i)i.set(i.parse?i.parse(e):e,r);else if(!r||r&&r.create!==!1)i=this.build(e,r);return i}}),t.extend(n.RelationalModel.prototype,n.Semaphore),n.Collection.prototype.__prepareModel=n.Collection.prototype._prepareModel,n.Collection.prototype._prepareModel=function(e,t){t||(t={});if(e instanceof n.Model)e.collection||(e.collection=this);else{var r=e;t.collection=this,typeof this.model.findOrCreate!="undefined"?e=this.model.findOrCreate(r,t):e=new this.model(r,t),e._validate(e.attributes,t)||(e=!1)}return e};var i=n.Collection.prototype.__add=n.Collection.prototype.add;n.Collection.prototype.add=function(e,r){r||(r={}),t.isArray(e)||(e=[e]);var s=[];return t.each(e,function(e){e instanceof n.Model||(e=n.Collection.prototype._prepareModel.call(this,e,r)),e instanceof n.Model&&!this.get(e)&&!this.getByCid(e)&&s.push(e)},this),s.length&&(i.call(this,s,r),t.each(s,function(e){this.trigger("relational:add",e,this,r)},this)),this};var s=n.Collection.prototype.__remove=n.Collection.prototype.remove;n.Collection.prototype.remove=function(e,r){return r||(r={}),t.isArray(e)?e=e.slice(0):e=[e],t.each(e,function(e){e=this.getByCid(e)||this.get(e),e instanceof n.Model&&(s.call(this,e,r),this.trigger("relational:remove",e,this,r))},this),this};var o=n.Collection.prototype.__reset=n.Collection.prototype.reset;n.Collection.prototype.reset=function(e,t){return o.call(this,e,t),this.trigger("relational:reset",this,t),this};var u=n.Collection.prototype.__sort=n.Collection.prototype.sort;n.Collection.prototype.sort=function(e){return u.call(this,e),this.trigger("relational:reset",this,e),this};var a=n.Collection.prototype.__trigger=n.Collection.prototype.trigger;n.Collection.prototype.trigger=function(e){if(e==="add"||e==="remove"||e==="reset"){var r=this,i=arguments;e==="add"&&(i=t.toArray(i),t.isObject(i[3])&&(i[3]=t.clone(i[3]))),n.Relational.eventQueue.add(function(){a.apply(r,i)})}else a.apply(this,arguments);return this},n.RelationalModel.extend=function(e,t){var r=n.Model.extend.apply(this,arguments);return r.setup(this),r}}(),window.Store=function(e){this.name=e;var t=localStorage.getItem(this.name);this.records=t&&t.split(",")||[]},_.extend(Store.prototype,{save:function(){localStorage.setItem(this.name,this.records.join(","))},create:function(e){return e.id||(e.id=e.attributes.id=guid()),localStorage.setItem(this.name+"-"+e.id,JSON.stringify(e)),this.records.push(e.id.toString()),this.save(),e},update:function(e){return localStorage.setItem(this.name+"-"+e.id,JSON.stringify(e)),_.include(this.records,e.id.toString())||this.records.push(e.id.toString()),this.save(),e},find:function(e){return JSON.parse(localStorage.getItem(this.name+"-"+e.id))},findAll:function(){return _.map(this.records,function(e){return JSON.parse(localStorage.getItem(this.name+"-"+e))},this)},destroy:function(e){return localStorage.removeItem(this.name+"-"+e.id),this.records=_.reject(this.records,function(t){return t==e.id.toString()}),this.save(),e}}),Backbone.localSync=function(e,t,n,r){typeof n=="function"&&(n={success:n,error:r});var i,s=t.localStorage||t.collection.localStorage;switch(e){case"read":i=t.id!=undefined?s.find(t):s.findAll();break;case"create":i=s.create(t);break;case"update":i=s.update(t);break;case"delete":i=s.destroy(t)}i?n.success(i):n.error("Record not found")},Backbone.ajaxSync=Backbone.sync,Backbone.sync=Backbone.localSync;var I18n=I18n||{};I18n.defaultLocale="en",I18n.fallbacks=!1,I18n.defaultSeparator=".",I18n.locale=null,I18n.PLACEHOLDER=/(?:\{\{|%\{)(.*?)(?:\}\}?)/gm,I18n.fallbackRules={},I18n.pluralizationRules={en:function(e){return e==0?["zero","none","other"]:e==1?"one":"other"}},I18n.getFallbacks=function(e){if(e===I18n.defaultLocale)return[];if(!I18n.fallbackRules[e]){var t=[],n=e.split("-");for(var r=1;r0)o=e.shift(),s=s[o];if(!s){if(I18n.fallbacks){var u=this.getFallbacks(i);for(var a=0;a11?1:0,l=e.getSeconds(),c=e.getMinutes(),h=e.getTimezoneOffset(),p=Math.floor(Math.abs(h/60)),d=Math.abs(h)-p*60,v=(h>0?"-":"+")+(p.toString().length<2?"0"+p:p)+(d.toString().length<2?"0"+d:d);a>12?a-=12:a===0&&(a=12);var m=function(e){var t="0"+e.toString();return t.substr(t.length-2)},g=t;return g=g.replace("%a",n.abbr_day_names[r]),g=g.replace("%A",n.day_names[r]),g=g.replace("%b",n.abbr_month_names[o]),g=g.replace("%B",n.month_names[o]),g=g.replace("%d",m(i)),g=g.replace("%e",i),g=g.replace("%-d",i),g=g.replace("%H",m(u)),g=g.replace("%-H",u),g=g.replace("%I",m(a)),g=g.replace("%-I",a),g=g.replace("%m",m(o)),g=g.replace("%-m",o),g=g.replace("%M",m(c)),g=g.replace("%-M",c),g=g.replace("%p",n.meridian[f]),g=g.replace("%S",m(l)),g=g.replace("%-S",l),g=g.replace("%w",r),g=g.replace("%y",m(s)),g=g.replace("%-y",m(s).replace(/^0+/,"")),g=g.replace("%Y",s),g=g.replace("%z",v),g},I18n.toNumber=function(e,t){t=this.prepareOptions(t,this.lookup("number.format"),{precision:3,separator:".",delimiter:",",strip_insignificant_zeros:!1});var n=e<0,r=Math.abs(e).toFixed(t.precision).toString(),i=r.split("."),s,o=[],u;e=i[0],s=i[1];while(e.length>0)o.unshift(e.substr(Math.max(0,e.length-3),3)),e=e.substr(0,e.length-3);u=o.join(t.delimiter),t.precision>0&&(u+=t.separator+i[1]),n&&(u="-"+u);if(t.strip_insignificant_zeros){var a={separator:new RegExp(t.separator.replace(/\./,"\\.")+"$"),zeros:/0+$/};u=u.replace(a.zeros,"").replace(a.separator,"")}return u},I18n.toCurrency=function(e,t){return t=this.prepareOptions(t,this.lookup("number.currency.format"),this.lookup("number.format"),{unit:"$",precision:2,format:"%u%n",delimiter:",",separator:"."}),e=this.toNumber(e,t),e=t.format.replace("%u",t.unit).replace("%n",e),e},I18n.toHumanSize=function(e,t){var n=1024,r=e,i=0,s,o;while(r>=n&&i<4)r/=n,i+=1;return i===0?(s=this.t("number.human.storage_units.units.byte",{count:r}),o=0):(s=this.t("number.human.storage_units.units."+[null,"kb","mb","gb","tb"][i]),o=r-Math.floor(r)===0?0:1),t=this.prepareOptions(t,{precision:o,format:"%n%u",delimiter:""}),e=this.toNumber(r,t),e=t.format.replace("%u",s).replace("%n",e),e},I18n.toPercentage=function(e,t){return t=this.prepareOptions(t,this.lookup("number.percentage.format"),this.lookup("number.format"),{precision:3,separator:".",delimiter:""}),e=this.toNumber(e,t),e+"%"},I18n.pluralizer=function(e){return pluralizer=this.pluralizationRules[e],pluralizer!==undefined?pluralizer:this.pluralizationRules.en},I18n.findAndTranslateValidNode=function(e,t){for(i=0;i= 1.0.0"},e.helpers={},e.partials={};var n=Object.prototype.toString,r="[object Function]",i="[object Object]";e.registerHelper=function(t,r,s){if(n.call(t)===i){if(s||r)throw new e.Exception("Arg not supported with multiple helpers");e.Utils.extend(this.helpers,t)}else s&&(r.not=s),this.helpers[t]=r},e.registerPartial=function(t,r){n.call(t)===i?e.Utils.extend(this.partials,t):this.partials[t]=r},e.registerHelper("helperMissing",function(e){if(arguments.length===2)return t;throw new Error("Missing helper: '"+e+"'")}),e.registerHelper("blockHelperMissing",function(t,i){var s=i.inverse||function(){},o=i.fn,u=n.call(t);return u===r&&(t=t.call(this)),t===!0?o(this):t===!1||t==null?s(this):u==="[object Array]"?t.length>0?e.helpers.each(t,i):s(this):o(t)}),e.K=function(){},e.createFrame=Object.create||function(t){e.K.prototype=t;var n=new e.K;return e.K.prototype=null,n},e.logger={DEBUG:0,INFO:1,WARN:2,ERROR:3,level:3,methodMap:{0:"debug",1:"info",2:"warn",3:"error"},log:function(t,n){if(e.logger.level<=t){var r=e.logger.methodMap[t];typeof console!="undefined"&&console[r]&&console[r].call(console,n)}}},e.log=function(t,n){e.logger.log(t,n)},e.registerHelper("each",function(t,i){var s=i.fn,o=i.inverse,u=0,a="",f,l=n.call(t);l===r&&(t=t.call(this)),i.data&&(f=e.createFrame(i.data));if(t&&typeof t=="object")if(t instanceof Array)for(var c=t.length;u2&&k.push("'"+this.terminals_[T]+"'");this.lexer.showPosition?L="Parse error on line "+(a+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+k.join(", ")+", got '"+(this.terminals_[g]||g)+"'":L="Parse error on line "+(a+1)+": Unexpected "+(g==1?"end of input":"'"+(this.terminals_[g]||g)+"'"),this.parseError(L,{text:this.lexer.match,token:this.terminals_[g]||g,line:this.lexer.yylineno,loc:p,expected:k})}}if(w[0]instanceof Array&&w.length>1)throw new Error("Parse Error: multiple actions possible at state: "+b+", token: "+g);switch(w[0]){case 1:r.push(g),i.push(this.lexer.yytext),s.push(this.lexer.yylloc),r.push(w[1]),g=null,y?(g=y,y=null):(f=this.lexer.yyleng,u=this.lexer.yytext,a=this.lexer.yylineno,p=this.lexer.yylloc,l>0&&l--);break;case 2:N=this.productions_[w[1]][1],x.$=i[i.length-N],x._$={first_line:s[s.length-(N||1)].first_line,last_line:s[s.length-1].last_line,first_column:s[s.length-(N||1)].first_column,last_column:s[s.length-1].last_column},d&&(x._$.range=[s[s.length-(N||1)].range[0],s[s.length-1].range[1]]),S=this.performAction.call(x,u,f,a,this.yy,w[1],i,s);if(typeof S!="undefined")return S;N&&(r=r.slice(0,-1*N*2),i=i.slice(0,-1*N),s=s.slice(0,-1*N)),r.push(this.productions_[w[1]][0]),i.push(x.$),s.push(x._$),C=o[r[r.length-2]][r[r.length-1]],r.push(C);break;case 3:return!0}}return!0}},t=function(){var e={EOF:1,parseError:function(t,n){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,n)},setInput:function(e){return this._input=e,this._more=this._less=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var e=this._input[0];this.yytext+=e,this.yyleng++,this.offset++,this.match+=e,this.matched+=e;var t=e.match(/(?:\r\n?|\n).*/g);return t?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),e},unput:function(e){var t=e.length,n=e.split(/(?:\r\n?|\n)/g);this._input=e+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-t-1),this.offset-=t;var r=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),n.length-1&&(this.yylineno-=n.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:n?(n.length===r.length?this.yylloc.first_column:0)+r[r.length-n.length].length-n[0].length:this.yylloc.first_column-t},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-t]),this},more:function(){return this._more=!0,this},less:function(e){this.unput(this.match.slice(e))},pastInput:function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?"...":"")+e.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var e=this.pastInput(),t=(new Array(e.length+1)).join("-");return e+this.upcomingInput()+"\n"+t+"^"},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var e,t,n,r,i,s;this._more||(this.yytext="",this.match="");var o=this._currentRules();for(var u=0;ut[0].length)){t=n,r=u;if(!this.options.flex)break}}if(t){s=t[0].match(/(?:\r\n?|\n).*/g),s&&(this.yylineno+=s.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:s?s[s.length-1].length-s[s.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],e=this.performAction.call(this,this.yy,this,o[r],this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1);if(e)return e;return}return this._input===""?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var t=this.next();return typeof t!="undefined"?t:this.lex()},begin:function(t){this.conditionStack.push(t)},popState:function(){return this.conditionStack.pop()},_currentRules:function(){return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules},topState:function(){return this.conditionStack[this.conditionStack.length-2]},pushState:function(t){this.begin(t)}};return e.options={},e.performAction=function(t,n,r,i){var s=i;switch(r){case 0:return n.yytext="\\",14;case 1:n.yytext.slice(-1)!=="\\"&&this.begin("mu"),n.yytext.slice(-1)==="\\"&&(n.yytext=n.yytext.substr(0,n.yyleng-1),this.begin("emu"));if(n.yytext)return 14;break;case 2:return 14;case 3:return n.yytext.slice(-1)!=="\\"&&this.popState(),n.yytext.slice(-1)==="\\"&&(n.yytext=n.yytext.substr(0,n.yyleng-1)),14;case 4:return n.yytext=n.yytext.substr(0,n.yyleng-4),this.popState(),15;case 5:return 25;case 6:return 16;case 7:return 20;case 8:return 19;case 9:return 19;case 10:return 23;case 11:return 22;case 12:this.popState(),this.begin("com");break;case 13:return n.yytext=n.yytext.substr(3,n.yyleng-5),this.popState(),15;case 14:return 22;case 15:return 37;case 16:return 36;case 17:return 36;case 18:return 40;case 19:break;case 20:return this.popState(),24;case 21:return this.popState(),18;case 22:return n.yytext=n.yytext.substr(1,n.yyleng-2).replace(/\\"/g,'"'),31;case 23:return n.yytext=n.yytext.substr(1,n.yyleng-2).replace(/\\'/g,"'"),31;case 24:return 38;case 25:return 33;case 26:return 33;case 27:return 32;case 28:return 36;case 29:return n.yytext=n.yytext.substr(1,n.yyleng-2),36;case 30:return"INVALID";case 31:return 5}},e.rules=[/^(?:\\\\(?=(\{\{)))/,/^(?:[^\x00]*?(?=(\{\{)))/,/^(?:[^\x00]+)/,/^(?:[^\x00]{2,}?(?=(\{\{|$)))/,/^(?:[\s\S]*?--\}\})/,/^(?:\{\{>)/,/^(?:\{\{#)/,/^(?:\{\{\/)/,/^(?:\{\{\^)/,/^(?:\{\{\s*else\b)/,/^(?:\{\{\{)/,/^(?:\{\{&)/,/^(?:\{\{!--)/,/^(?:\{\{![\s\S]*?\}\})/,/^(?:\{\{)/,/^(?:=)/,/^(?:\.(?=[}\/ ]))/,/^(?:\.\.)/,/^(?:[\/.])/,/^(?:\s+)/,/^(?:\}\}\})/,/^(?:\}\})/,/^(?:"(\\["]|[^"])*")/,/^(?:'(\\[']|[^'])*')/,/^(?:@)/,/^(?:true(?=[}\s]))/,/^(?:false(?=[}\s]))/,/^(?:-?[0-9]+(?=[}\s]))/,/^(?:[^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=[=}\s\/.]))/,/^(?:\[[^\]]*\])/,/^(?:.)/,/^(?:$)/],e.conditions={mu:{rules:[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],inclusive:!1},emu:{rules:[3],inclusive:!1},com:{rules:[4],inclusive:!1},INITIAL:{rules:[0,1,2,31],inclusive:!0}},e}();return e.lexer=t,n.prototype=e,e.Parser=n,new n}();e.Parser=s,e.parse=function(t){return t.constructor===e.AST.ProgramNode?t:(e.Parser.yy=e.AST,e.Parser.parse(t))},e.AST={},e.AST.ProgramNode=function(t,n){this.type="program",this.statements=t,n&&(this.inverse=new e.AST.ProgramNode(n))},e.AST.MustacheNode=function(e,t,n){this.type="mustache",this.escaped=!n,this.hash=t;var r=this.id=e[0],i=this.params=e.slice(1),s=this.eligibleHelper=r.isSimple;this.isHelper=s&&(i.length||t)},e.AST.PartialNode=function(e,t){this.type="partial",this.partialName=e,this.context=t},e.AST.BlockNode=function(t,n,r,i){var s=function(t,n){if(t.original!==n.original)throw new e.Exception(t.original+" doesn't match "+n.original)};s(t.id,i),this.type="block",this.mustache=t,this.program=n,this.inverse=r,this.inverse&&!this.program&&(this.isInverse=!0)},e.AST.ContentNode=function(e){this.type="content",this.string=e},e.AST.HashNode=function(e){this.type="hash",this.pairs=e},e.AST.IdNode=function(t){this.type="ID";var n="",r=[],i=0;for(var s=0,o=t.length;s0)throw new e.Exception("Invalid path: "+n);u===".."?i++:this.isScoped=!0}else r.push(u)}this.original=n,this.parts=r,this.string=r.join("."),this.depth=i,this.isSimple=t.length===1&&!this.isScoped&&i===0,this.stringModeValue=this.string},e.AST.PartialNameNode=function(e){this.type="PARTIAL_NAME",this.name=e.original},e.AST.DataNode=function(e){this.type="DATA",this.id=e},e.AST.StringNode=function(e){this.type="STRING",this.original=this.string=this.stringModeValue=e},e.AST.IntegerNode=function(e){this.type="INTEGER",this.original=this.integer=e,this.stringModeValue=Number(e)},e.AST.BooleanNode=function(e){this.type="BOOLEAN",this.bool=e,this.stringModeValue=e==="true"},e.AST.CommentNode=function(e){this.type="comment",this.comment=e};var o=["description","fileName","lineNumber","message","name","number","stack"];e.Exception=function(e){var t=Error.prototype.constructor.apply(this,arguments);for(var n=0;n":">",'"':""","'":"'","`":"`"},a=/[&<>"'`]/g,f=/[&<>"'`]/,l=function(e){return u[e]||"&"};e.Utils={extend:function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},escapeExpression:function(t){return t instanceof e.SafeString?t.toString():t==null||t===!1?"":(t=t.toString(),f.test(t)?t.replace(a,l):t)},isEmpty:function(e){return!e&&e!==0?!0:n.call(e)==="[object Array]"&&e.length===0?!0:!1}};var c=e.Compiler=function(){},h=e.JavaScriptCompiler=function(){};c.prototype={compiler:c,disassemble:function(){var e=this.opcodes,t,n=[],r,i;for(var s=0,o=e.length;sthis.stackVars.length&&this.stackVars.push("stack"+this.stackSlot),this.topStackName()},topStackName:function(){return"stack"+this.stackSlot},flushInline:function(){var e=this.inlineStack;if(e.length){this.inlineStack=[];for(var t=0,n=e.length;ts(a,"width"),f?(v=s(a,"height")-s(g,"height"),d=a.offset().top+v):(v=s(a,"width")-s(g,"width"),d=a.offset().left)}function O(){A(),r.setValue(n.value!==undefined?n.value:n.min)}var r=this,u=n.css,a=e("
").data("rangeinput",r),f,l,c=!1,h=!1,p,d,v,m;t.before(a);var g=a.addClass(u.slider).find("a").addClass(u.handle),y=a.find("div").addClass(u.progress);e.each("min,max,step,value".split(","),function(e,r){var i=t.attr(r);parseFloat(i)&&(n[r]=parseFloat(i,10))});var b=n.max-n.min,w=n.step=="any"?0:n.step,E=n.precision;if(E===undefined)try{E=w.toString().split(".")[1].length}catch(S){E=0}if(t.attr("type")=="range"){var x=t.clone().wrap("
").parent().html(),T=e(x.replace(/type/i,"type=text data-orig-type"));T.val(n.value),t.replaceWith(T),t=T}t.addClass(u.input);var N=e(r).add(t),C=!0;e.extend(r,{getValue:function(){return l},getDisplayValue:function(){return p},setValue:function(t,n){return A(),k(n||e.Event("api"),undefined,t,!0)},getConf:function(){return n},updateFromInput:function(e){return L(e),this},suppressChangeValue:function(e){return typeof e=="boolean"&&(h=e),this},getProgress:function(){return y},getHandle:function(){return g},getInput:function(){return t},step:function(t,i){i=i||e.Event();var s=n.step=="any"?1:n.step;r.setValue(l+s*(t||1),i)},stepUp:function(e){return r.step(e||1)},stepDown:function(e){return r.step(-e||-1)}}),e.each("onSlide,change".split(","),function(t,i){e.isFunction(n[i])&&e(r).bind(i,n[i]),r[i]=function(t){return t&&e(r).bind(i,t),r}}),g.drag({drag:!1}).bind("dragStart",function(){A(),C=o(e(r))||o(t)}).bind("drag",function(e,n,r){if(t.is(":disabled"))return!1;k(e,f?n:r)}).bind("dragEnd",function(e){e.isDefaultPrevented()||(e.type="change",N.trigger(e,[l]),N.trigger("changeValue",[l]))}).click(function(e){return e.preventDefault()}),a.click(function(e){if(t.is(":disabled")||e.target==g[0])return e.preventDefault();A();var n=f?g.height()/2:g.width()/2;k(e,f?v-d-n+e.pageY:e.pageX-d-n)}),n.keyboard&&t.keydown(function(n){if(t.attr("readonly"))return;var i=n.keyCode,s=e([75,76,38,33,39]).index(i)!=-1,o=e([74,72,40,34,37]).index(i)!=-1;if((s||o)&&!(n.shiftKey||n.altKey||n.ctrlKey))return s?r.step(i==33?10:1,n):o&&r.step(i==34?-10:-1,n),n.preventDefault()}),t.blur(function(t){var i=e(this).val();i=n.parseValue?n.parseValue(i):i,i!==l&&r.setValue(i,t)}),e.extend(t[0],{stepUp:r.stepUp,stepDown:r.stepDown}),O(),v||e(window).load(O)}e.tools=e.tools||{version:"1.2.6.R8"};var t;t=e.tools.rangeinput={conf:{min:0,max:100,step:"any",steps:0,value:0,precision:undefined,vertical:0,keyboard:!0,progress:!1,speed:100,formatValue:null,parseValue:null,css:{input:"range",slider:"slider",progress:"progress",handle:"handle"}}};var n,r;e.fn.drag=function(t){return t=e.extend({x:!0,y:!0,drag:!0,_ie_disableDragStart:!0},t),e.browser.msie&&this.bind("dragstart",function(){return!1}),n=n||e(document).bind("mousedown mouseup touchstart touchend",function(i){var s=e(i.target);if(i.type!="mousedown"&&i.type!="touchstart"||!s.data("drag"))try{r&&r.trigger("dragEnd")}finally{n.unbind("mousemove.drag touchmove.drag"),r=null}else{var o,u;i.type=="touchstart"?(o=i.originalEvent.targetTouches[0].pageX,u=i.originalEvent.targetTouches[0].pageY):(o=i.pageX,u=i.pageY);var a=s.position(),f=o-a.left,l=u-a.top,c=!0;n.bind("mousemove.drag touchmove.drag",function(e){var n,i;e.type=="touchmove"?(n=e.originalEvent.targetTouches[0].pageX,i=e.originalEvent.targetTouches[0].pageY):(n=e.pageX,i=e.pageY);var o=n-f,u=i-l,a={};t.x&&(a.left=o),t.y&&(a.top=u),c&&(s.trigger("dragStart"),c=!1),t.drag&&s.css(a),s.trigger("drag",[u,o]),r=s}),i.preventDefault()}}),this.data("drag",!0)},e.expr[":"].range=function(t){var n=t.getAttribute("type");return n&&n=="range"||!!e(t).filter("input").data("rangeinput")},e.fn.rangeinput=function(n){if(this.data("rangeinput"))return this;n=e.extend(!0,{},t.conf,n);var r;return this.each(function(){var t=new u(e(this),e.extend(!0,{},n)),i=t.getInput().data("rangeinput",t);r=r?r.add(i):i}),r?r:this}}(jQuery),function(e,t){function n(t,n){var i=t.nodeName.toLowerCase();if("area"===i){var s=t.parentNode,o=s.name,u;return!t.href||!o||s.nodeName.toLowerCase()!=="map"?!1:(u=e("img[usemap=#"+o+"]")[0],!!u&&r(u))}return(/input|select|textarea|button|object/.test(i)?!t.disabled:"a"==i?t.href||n:n)&&r(t)}function r(t){return!e(t).parents().andSelf().filter(function(){return e.curCSS(this,"visibility")==="hidden"||e.expr.filters.hidden(this)}).length}e.ui=e.ui||{};if(e.ui.version)return;e.extend(e.ui,{version:"1.8.21",keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}}),e.fn.extend({propAttr:e.fn.prop||e.fn.attr,_focus:e.fn.focus,focus:function(t,n){return typeof t=="number"?this.each(function(){var r=this;setTimeout(function(){e(r).focus(),n&&n.call(r)},t)}):this._focus.apply(this,arguments)},scrollParent:function(){var t;return e.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?t=this.parents().filter(function(){return/(relative|absolute|fixed)/.test(e.curCSS(this,"position",1))&&/(auto|scroll)/.test(e.curCSS(this,"overflow",1)+e.curCSS(this,"overflow-y",1)+e.curCSS(this,"overflow-x",1))}).eq(0):t=this.parents().filter(function(){return/(auto|scroll)/.test(e.curCSS(this,"overflow",1)+e.curCSS(this,"overflow-y",1)+e.curCSS(this,"overflow-x",1))}).eq(0),/fixed/.test(this.css("position"))||!t.length?e(document):t},zIndex:function(n){if(n!==t)return this.css("zIndex",n);if(this.length){var r=e(this[0]),i,s;while(r.length&&r[0]!==document){i=r.css("position");if(i==="absolute"||i==="relative"||i==="fixed"){s=parseInt(r.css("zIndex"),10);if(!isNaN(s)&&s!==0)return s}r=r.parent()}}return 0},disableSelection:function(){return this.bind((e.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(e){e.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}}),e.each(["Width","Height"],function(n,r){function u(t,n,r,s){return e.each(i,function(){n-=parseFloat(e.curCSS(t,"padding"+this,!0))||0,r&&(n-=parseFloat(e.curCSS(t,"border"+this+"Width",!0))||0),s&&(n-=parseFloat(e.curCSS(t,"margin"+this,!0))||0)}),n}var i=r==="Width"?["Left","Right"]:["Top","Bottom"],s=r.toLowerCase(),o={innerWidth:e.fn.innerWidth,innerHeight:e.fn.innerHeight,outerWidth:e.fn.outerWidth,outerHeight:e.fn.outerHeight};e.fn["inner"+r]=function(n){return n===t?o["inner"+r].call(this):this.each(function(){e(this).css(s,u(this,n)+"px")})},e.fn["outer"+r]=function(t,n){return typeof t!="number"?o["outer"+r].call(this,t):this.each(function(){e(this).css(s,u(this,t,!0,n)+"px")})}}),e.extend(e.expr[":"],{data:function(t,n,r){return!!e.data(t,r[3])},focusable:function(t){return n(t,!isNaN(e.attr(t,"tabindex")))},tabbable:function(t){var r=e.attr(t,"tabindex"),i=isNaN(r);return(i||r>=0)&&n(t,!i)}}),e(function(){var t=document.body,n=t.appendChild(n=document.createElement("div"));n.offsetHeight,e.extend(n.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0}),e.support.minHeight=n.offsetHeight===100,e.support.selectstart="onselectstart"in n,t.removeChild(n).style.display="none"}),e.extend(e.ui,{plugin:{add:function(t,n,r){var i=e.ui[t].prototype;for(var s in r)i.plugins[s]=i.plugins[s]||[],i.plugins[s].push([n,r[s]])},call:function(e,t,n){var r=e.plugins[t];if(!r||!e.element[0].parentNode)return;for(var i=0;i0?!0:(t[r]=1,i=t[r]>0,t[r]=0,i)},isOverAxis:function(e,t,n){return e>t&&e",this.element[0].ownerDocument).addClass("ui-button-text").html(this.options.label).appendTo(t.empty()).text(),r=this.options.icons,i=r.primary&&r.secondary,s=[];r.primary||r.secondary?(this.options.text&&s.push("ui-button-text-icon"+(i?"s":r.primary?"-primary":"-secondary")),r.primary&&t.prepend(""),r.secondary&&t.append(""),this.options.text||(s.push(i?"ui-button-icons-only":"ui-button-icon-only"),this.hasTitle||t.attr("title",n))):s.push("ui-button-text-only"),t.addClass(s.join(" "))}}),e.widget("ui.buttonset",{options:{items:":button, :submit, :reset, :checkbox, :radio, a, :data(button)"},_create:function(){this.element.addClass("ui-buttonset")},_init:function(){this.refresh()},_setOption:function(t,n){t==="disabled"&&this.buttons.button("option",t,n),e.Widget.prototype._setOption.apply(this,arguments)},refresh:function(){var t=this.element.css("direction")==="rtl";this.buttons=this.element.find(this.options.items).filter(":ui-button").button("refresh").end().not(":ui-button").button().end().map(function(){return e(this).button("widget")[0]}).removeClass("ui-corner-all ui-corner-left ui-corner-right").filter(":first").addClass(t?"ui-corner-right":"ui-corner-left").end().filter(":last").addClass(t?"ui-corner-left":"ui-corner-right").end().end()},destroy:function(){this.element.removeClass("ui-buttonset"),this.buttons.map(function(){return e(this).button("widget")[0]}).removeClass("ui-corner-left ui-corner-right").end().button("destroy"),e.Widget.prototype.destroy.call(this)}})}(jQuery),function(e,t){e.ui=e.ui||{};var n=/left|center|right/,r=/top|center|bottom/,i="center",s={},o=e.fn.position,u=e.fn.offset;e.fn.position=function(t){if(!t||!t.of)return o.apply(this,arguments);t=e.extend({},t);var u=e(t.of),a=u[0],f=(t.collision||"flip").split(" "),l=t.offset?t.offset.split(" "):[0,0],c,h,p;return a.nodeType===9?(c=u.width(),h=u.height(),p={top:0,left:0}):a.setTimeout?(c=u.width(),h=u.height(),p={top:u.scrollTop(),left:u.scrollLeft()}):a.preventDefault?(t.at="left top",c=h=0,p={top:t.of.pageY,left:t.of.pageX}):(c=u.outerWidth(),h=u.outerHeight(),p=u.offset()),e.each(["my","at"],function(){var e=(t[this]||"").split(" ");e.length===1&&(e=n.test(e[0])?e.concat([i]):r.test(e[0])?[i].concat(e):[i,i]),e[0]=n.test(e[0])?e[0]:i,e[1]=r.test(e[1])?e[1]:i,t[this]=e}),f.length===1&&(f[1]=f[0]),l[0]=parseInt(l[0],10)||0,l.length===1&&(l[1]=l[0]),l[1]=parseInt(l[1],10)||0,t.at[0]==="right"?p.left+=c:t.at[0]===i&&(p.left+=c/2),t.at[1]==="bottom"?p.top+=h:t.at[1]===i&&(p.top+=h/2),p.left+=l[0],p.top+=l[1],this.each(function(){var n=e(this),r=n.outerWidth(),o=n.outerHeight(),u=parseInt(e.curCSS(this,"marginLeft",!0))||0,a=parseInt(e.curCSS(this,"marginTop",!0))||0,d=r+u+(parseInt(e.curCSS(this,"marginRight",!0))||0),v=o+a+(parseInt(e.curCSS(this,"marginBottom",!0))||0),m=e.extend({},p),g;t.my[0]==="right"?m.left-=r:t.my[0]===i&&(m.left-=r/2),t.my[1]==="bottom"?m.top-=o:t.my[1]===i&&(m.top-=o/2),s.fractions||(m.left=Math.round(m.left),m.top=Math.round(m.top)),g={left:m.left-u,top:m.top-a},e.each(["left","top"],function(n,i){e.ui.position[f[n]]&&e.ui.position[f[n]][i](m,{targetWidth:c,targetHeight:h,elemWidth:r,elemHeight:o,collisionPosition:g,collisionWidth:d,collisionHeight:v,offset:l,my:t.my,at:t.at})}),e.fn.bgiframe&&n.bgiframe(),n.offset(e.extend(m,{using:t.using}))})},e.ui.position={fit:{left:function(t,n){var r=e(window),i=n.collisionPosition.left+n.collisionWidth-r.width()-r.scrollLeft();t.left=i>0?t.left-i:Math.max(t.left-n.collisionPosition.left,t.left)},top:function(t,n){var r=e(window),i=n.collisionPosition.top+n.collisionHeight-r.height()-r.scrollTop();t.top=i>0?t.top-i:Math.max(t.top-n.collisionPosition.top,t.top)}},flip:{left:function(t,n){if(n.at[0]===i)return;var r=e(window),s=n.collisionPosition.left+n.collisionWidth-r.width()-r.scrollLeft(),o=n.my[0]==="left"?-n.elemWidth:n.my[0]==="right"?n.elemWidth:0,u=n.at[0]==="left"?n.targetWidth:-n.targetWidth,a=-2*n.offset[0];t.left+=n.collisionPosition.left<0?o+u+a:s>0?o+u+a:0},top:function(t,n){if(n.at[1]===i)return;var r=e(window),s=n.collisionPosition.top+n.collisionHeight-r.height()-r.scrollTop(),o=n.my[1]==="top"?-n.elemHeight:n.my[1]==="bottom"?n.elemHeight:0,u=n.at[1]==="top"?n.targetHeight:-n.targetHeight,a=-2*n.offset[1];t.top+=n.collisionPosition.top<0?o+u+a:s>0?o+u+a:0}}},e.offset.setOffset||(e.offset.setOffset=function(t,n){/static/.test(e.curCSS(t,"position"))&&(t.style.position="relative");var r=e(t),i=r.offset(),s=parseInt(e.curCSS(t,"top",!0),10)||0,o=parseInt(e.curCSS(t,"left",!0),10)||0,u={top:n.top-i.top+s,left:n.left-i.left+o};"using"in n?n.using.call(t,u):r.css(u)},e.fn.offset=function(t){var n=this[0];return!n||!n.ownerDocument?null:t?e.isFunction(t)?this.each(function(n){e(this).offset(t.call(this,n,e(this).offset()))}):this.each(function(){e.offset.setOffset(this,t)}):u.call(this)}),function(){var t=document.getElementsByTagName("body")[0],n=document.createElement("div"),r,i,o,u,a;r=document.createElement(t?"div":"body"),o={visibility:"hidden",width:0,height:0,border:0,margin:0,background:"none"},t&&e.extend(o,{position:"absolute",left:"-1000px",top:"-1000px"});for(var f in o)r.style[f]=o[f];r.appendChild(n),i=t||document.documentElement,i.insertBefore(r,i.firstChild),n.style.cssText="position: absolute; left: 10.7432222px; top: 10.432325px; height: 30px; width: 201px;",u=e(n).offset(function(e,t){return t}).offset(),r.innerHTML="",i.removeChild(r),a=u.top+u.left+(t?2e3:0),s.fractions=a>21&&a<22}()}(jQuery),function(e){e.widget("ui.selectmenu",{getter:"value",version:"1.9",eventPrefix:"selectmenu",options:{transferClasses:!0,typeAhead:1e3,style:"dropdown",positionOptions:{my:"left top",at:"left bottom",offset:null},width:null,menuWidth:null,handleWidth:26,maxHeight:null,icons:null,format:null,bgImage:function(){},wrapperElement:"
"},_create:function(){var t=this,n=this.options,r=(this.element.attr("id")||"ui-selectmenu-"+Math.random().toString(16).slice(2,10)).replace(":","\\:");this.ids=[r,r+"-button",r+"-menu"],this._safemouseup=!0,this.isOpen=!1,this.newelement=e("",{"class":this.widgetBaseClass+" ui-widget ui-state-default ui-corner-all",id:this.ids[1],role:"combobox","aria-labelledby":n.label,href:"#",tabindex:this.element.attr("disabled")?1:0,"aria-haspopup":!1,"aria-owns":this.ids[2]}),this.newelementWrap=e(n.wrapperElement).append(this.newelement).insertAfter(this.element);var i=this.element.attr("tabindex");i&&this.newelement.attr("tabindex",i),this.newelement.data("selectelement",this.element),this.selectmenuIcon=e('').prependTo(this.newelement),this.newelement.prepend(''),this.element.bind({"click.selectmenu":function(e){t.newelement.focus(),e.preventDefault()}}),this.newelement.bind("mousedown.selectmenu",function(e){return t._toggle(e,!0),n.style=="popup"&&(t._safemouseup=!1,setTimeout(function(){t._safemouseup=!0},300)),!1}).bind("click.selectmenu",function(){return!1}).bind("keydown.selectmenu",function(n){var r=!1;switch(n.keyCode){case e.ui.keyCode.ENTER:r=!0;break;case e.ui.keyCode.SPACE:t._toggle(n);break;case e.ui.keyCode.UP:n.altKey?t.open(n):t._moveSelection(-1);break;case e.ui.keyCode.DOWN:n.altKey?t.open(n):t._moveSelection(1);break;case e.ui.keyCode.LEFT:t._moveSelection(-1);break;case e.ui.keyCode.RIGHT:t._moveSelection(1);break;case e.ui.keyCode.TAB:r=!0;break;case e.ui.keyCode.HOME:t.index(0);break;default:r=!0}return r}).bind("keypress.selectmenu",function(e){return e.which>0&&t._typeAhead(e.which,"mouseup"),!0}).bind("mouseover.selectmenu focus.selectmenu",function(){n.disabled||e(this).addClass(t.widgetBaseClass+"-focus ui-state-hover")}).bind("mouseout.selectmenu blur.selectmenu",function(){n.disabled||e(this).removeClass(t.widgetBaseClass+"-focus ui-state-hover")}),e(document).bind("mousedown.selectmenu-"+this.ids[0],function(e){t.isOpen&&t.close(e)}),this.element.bind("click.selectmenu",function(){t._refreshValue()}).bind("focus.selectmenu",function(){t.newelement&&t.newelement[0].focus()}),n.width||(n.width=this.element.outerWidth()),this.newelement.width(n.width),this.element.hide(),this.list=e("
'),this},prepareContext:function(e){var t=_.extend({},e);return t.templateData=_.extend({},e.templateData),t.templateData.titleString=I18n.t(e.templateData.title),t.templateData.isSingleOption=this.determineIfSingleOption(e.controlData.listData.length),t},determineIfSingleOption:function(e){return e<2},rebuild:function(t){var n=this.input.selectmenu("index");if(n==-1||n>=t.length)n=t.length-1;this.controlConfig.controlData.listData=t,this.input.empty();for(var r=0,i=t.length;r").attr("value",t[r].value).text(t[r].label));var s=this.input.data("selectmenu");s&&(s.list.height("auto"),this.input.selectmenu(),this.input.selectmenu("index",n))},setControlValue:function(e){var t=this.input.val(),n=t!=e;return this.input.val([e]),n},inputChange_handler:function(){var e=this.input.val(),n={};n[this.controlConfig.name]=e,this.model.set(n),this.dispatcher.trigger(t.Events.CONTROL_CHANGE,{name:this.controlConfig.name,value:e,control:this})}})}(jQuery),function(e){var t=gbst.module("gbst.loan.shared.view");t.Events={CONTROL_CHANGE:"view.controlchange"},t.CheckBoxInputView=Backbone.View.extend({templateId:null,model:null,dispatcher:null,controlConfig:null,controlsInitialised:!1,input:null,events:{"change input":"checkboxChange_handler","dblclick .checkbox-label":"dblclick_handler"},initialize:function(e){this.model=e.model,this.dispatcher=e.dispatcher;var t=this.controlConfig=e.controlConfig;this.templateId=t.templateId},render:function(){var e=this.controlConfig,t=null,n=this.input,r=null;if(!this.controlsInitialised){var i=this.prepareContext(e);r=HandlebarsTemplates[this.templateId](i),this.$el.append(r),n=this.input=this.$el.find("input"),this.controlsInitialised=!0}t=this.model.get(e.name);var s=null;t==1&&(s=e.name),this.setControlValue(s),n.button()},prepareContext:function(e){var t={};return t.name=e.name,t.templateData=_.extend({},e.templateData),t.templateData.titleString=I18n.t(e.templateData.title),t},setControlValue:function(e){this.input.val([e])},checkboxChange_handler:function(e){var n=this.input[0].checked,r={};r[this.controlConfig.name]=n,this.model.set(r),this.dispatcher.trigger(t.Events.CONTROL_CHANGE,{name:this.controlConfig.name,value:n,control:this})},dblclick_handler:function(){this.input.button("refresh")}})}(jQuery);