(function(n){var t=typeof self=="object"&&self.self==self&&self||typeof global=="object"&&global.global==global&&global,i,r;if(typeof define=="function"&&define.amd)define(["underscore","jquery","exports"],function(i,r,u){t.Backbone=n(t,u,i,r)});else if(typeof exports!="undefined"){i=require("underscore");try{r=require("jquery")}catch(u){}n(t,exports,i,r)}else t.Backbone=n(t,{},t._,t.jQuery||t.Zepto||t.ender||t.$)})(function(n,t,i,r){var et=n.Backbone,y=[].slice,c,b,k,l,d,a,e,g,nt,tt,rt,ft,v,s;t.VERSION="1.2.1",t.$=r,t.noConflict=function(){return n.Backbone=et,this},t.emulateHTTP=!1,t.emulateJSON=!1;var ot=function(n,t,r){switch(n){case 1:return function(){return i[t](this[r])};case 2:return function(n){return i[t](this[r],n)};case 3:return function(n,u){return i[t](this[r],n,u)};case 4:return function(n,u,f){return i[t](this[r],n,u,f)};default:return function(){var n=y.call(arguments);return n.unshift(this[r]),i[t].apply(i,n)}}},p=function(n,t,r){i.each(t,function(t,u){i[u]&&(n.prototype[u]=ot(t,u,r))})},u=t.Events={},w=/\s+/,o=function(n,t,r,u,f){var e=0,o;if(r&&typeof r=="object")for(u!==void 0&&("context"in f)&&f.context===void 0&&(f.context=u),o=i.keys(r);e<o.length;e++)t=n(t,o[e],r[o[e]],f);else if(r&&w.test(r))for(o=r.split(w);e<o.length;e++)t=n(t,o[e],u,f);else t=n(t,r,u,f);return t};u.on=function(n,t,i){return c(this,n,t,i)},c=function(n,t,i,r,u){if(n._events=o(b,n._events||{},t,i,{context:r,ctx:n,listening:u}),u){var f=n._listeners||(n._listeners={});f[u.id]=u}return n},u.listenTo=function(n,t,r){var o;if(!n)return this;var u=n._listenId||(n._listenId=i.uniqueId("l")),f=this._listeningTo||(this._listeningTo={}),e=f[u];return e||(o=this._listenId||(this._listenId=i.uniqueId("l")),e=f[u]={obj:n,objId:u,id:o,listeningTo:f,count:0}),c(n,t,r,this,e),this},b=function(n,t,i,r){if(i){var e=n[t]||(n[t]=[]),f=r.context,o=r.ctx,u=r.listening;u&&u.count++,e.push({callback:i,context:f,ctx:f||o,listening:u})}return n},u.off=function(n,t,i){return this._events?(this._events=o(k,this._events,n,t,{context:i,listeners:this._listeners}),this):this},u.stopListening=function(n,t,r){var u=this._listeningTo,e,f,o;if(!u)return this;for(e=n?[n._listenId]:i.keys(u),f=0;f<e.length;f++){if(o=u[e[f]],!o)break;o.obj.off(t,r,this)}return i.isEmpty(u)&&(this._listeningTo=void 0),this},k=function(n,t,r,u){var v,y,h,c,l,o;if(n){var e=0,f,a=u.context,s=u.listeners;if(!t&&!r&&!a){for(v=i.keys(s);e<v.length;e++)f=s[v[e]],delete s[f.id],delete f.listeningTo[f.objId];return}for(y=t?[t]:i.keys(n);e<y.length;e++){if(t=y[e],h=n[t],!h)break;for(c=[],l=0;l<h.length;l++)o=h[l],r&&r!==o.callback&&r!==o.callback._callback||a&&a!==o.context?c.push(o):(f=o.listening,f&&--f.count==0&&(delete s[f.id],delete f.listeningTo[f.objId]));c.length?n[t]=c:delete n[t]}if(i.size(n))return n}},u.once=function(n,t,r){var u=o(l,{},n,t,i.bind(this.off,this));return this.on(u,void 0,r)},u.listenToOnce=function(n,t,r){var u=o(l,{},t,r,i.bind(this.stopListening,this,n));return this.listenTo(n,u)},l=function(n,t,r,u){if(r){var f=n[t]=i.once(function(){u(t,f),r.apply(this,arguments)});f._callback=r}return n},u.trigger=function(n){var i,r,t;if(!this._events)return this;for(i=Math.max(0,arguments.length-1),r=Array(i),t=0;t<i;t++)r[t]=arguments[t+1];return o(d,this._events,n,void 0,r),this},d=function(n,t,i,r){if(n){var f=n[t],u=n.all;f&&u&&(u=u.slice()),f&&a(f,r),u&&a(u,[t].concat(r))}return n},a=function(n,t){var i,r=-1,u=n.length,f=t[0],e=t[1],o=t[2];switch(t.length){case 0:while(++r<u)(i=n[r]).callback.call(i.ctx);return;case 1:while(++r<u)(i=n[r]).callback.call(i.ctx,f);return;case 2:while(++r<u)(i=n[r]).callback.call(i.ctx,f,e);return;case 3:while(++r<u)(i=n[r]).callback.call(i.ctx,f,e,o);return;default:while(++r<u)(i=n[r]).callback.apply(i.ctx,t);return}},u.bind=u.on,u.unbind=u.off,i.extend(t,u),e=t.Model=function(n,t){var r=n||{};t||(t={}),this.cid=i.uniqueId(this.cidPrefix),this.attributes={},t.collection&&(this.collection=t.collection),t.parse&&(r=this.parse(r,t)||{}),r=i.defaults({},r,i.result(this,"defaults")),this.set(r,t),this.changed={},this.initialize.apply(this,arguments)},i.extend(e.prototype,u,{changed:null,validationError:null,idAttribute:"id",cidPrefix:"c",initialize:function(){},toJSON:function(){return i.clone(this.attributes)},sync:function(){return t.sync.apply(this,arguments)},get:function(n){return this.attributes[n]},escape:function(n){return i.escape(this.get(n))},has:function(n){return this.get(n)!=null},matches:function(n){return!!i.iteratee(n,this)(this.attributes)},set:function(n,t,r){var f,u,o;if(n==null)return this;if(typeof n=="object"?(f=n,r=t):(f={})[n]=t,r||(r={}),!this._validate(f,r))return!1;var a=r.unset,h=r.silent,e=[],c=this._changing;this._changing=!0,c||(this._previousAttributes=i.clone(this.attributes),this.changed={});var s=this.attributes,l=this.changed,v=this._previousAttributes;this.idAttribute in f&&(this.id=f[this.idAttribute]);for(u in f)t=f[u],i.isEqual(s[u],t)||e.push(u),i.isEqual(v[u],t)?delete l[u]:l[u]=t,a?delete s[u]:s[u]=t;if(!h)for(e.length&&(this._pending=r),o=0;o<e.length;o++)this.trigger("change:"+e[o],this,s[e[o]],r);if(c)return this;if(!h)while(this._pending)r=this._pending,this._pending=!1,this.trigger("change",this,r);return this._pending=!1,this._changing=!1,this},unset:function(n,t){return this.set(n,void 0,i.extend({},t,{unset:!0}))},clear:function(n){var t={},r;for(r in this.attributes)t[r]=void 0;return this.set(t,i.extend({},n,{unset:!0}))},hasChanged:function(n){return n==null?!i.isEmpty(this.changed):i.has(this.changed,n)},changedAttributes:function(n){var f,t,r,u;if(!n)return this.hasChanged()?i.clone(this.changed):!1;f=this._changing?this._previousAttributes:this.attributes,t={};for(r in n)(u=n[r],i.isEqual(f[r],u))||(t[r]=u);return i.size(t)?t:!1},previous:function(n){return n==null||!this._previousAttributes?null:this._previousAttributes[n]},previousAttributes:function(){return i.clone(this._previousAttributes)},fetch:function(n){n=i.extend({parse:!0},n);var t=this,r=n.success;return n.success=function(i){var u=n.parse?t.parse(i,n):i;if(!t.set(u,n))return!1;r&&r.call(n.context,t,i,n),t.trigger("sync",t,i,n)},s(this,n),this.sync("read",this,n)},save:function(n,t,r){var u,e,h,l;if(n==null||typeof n=="object"?(u=n,r=t):(u={})[n]=t,r=i.extend({validate:!0,parse:!0},r),e=r.wait,u&&!e){if(!this.set(u,r))return!1}else if(!this._validate(u,r))return!1;var f=this,c=r.success,o=this.attributes;return r.success=function(n){f.attributes=o;var t=r.parse?f.parse(n,r):n;if(e&&(t=i.extend({},u,t)),t&&!f.set(t,r))return!1;c&&c.call(r.context,f,n,r),f.trigger("sync",f,n,r)},s(this,r),u&&e&&(this.attributes=i.extend({},o,u)),h=this.isNew()?"create":r.patch?"patch":"update",h!=="patch"||r.attrs||(r.attrs=u),l=this.sync(h,this,r),this.attributes=o,l},destroy:function(n){var r;n=n?i.clone(n):{};var t=this,u=n.success,f=n.wait,e=function(){t.stopListening(),t.trigger("destroy",t,t.collection,n)};return n.success=function(i){f&&e(),u&&u.call(n.context,t,i,n),t.isNew()||t.trigger("sync",t,i,n)},r=!1,this.isNew()?i.defer(n.success):(s(this,n),r=this.sync("delete",this,n)),f||e(),r},url:function(){var n=i.result(this,"urlRoot")||i.result(this.collection,"url")||v(),t;return this.isNew()?n:(t=this.get(this.idAttribute),n.replace(/[^\/]$/,"$&/")+encodeURIComponent(t))},parse:function(n){return n},clone:function(){return new this.constructor(this.attributes)},isNew:function(){return!this.has(this.idAttribute)},isValid:function(n){return this._validate({},i.defaults({validate:!0},n))},_validate:function(n,t){if(!t.validate||!this.validate)return!0;n=i.extend({},this.attributes,n);var r=this.validationError=this.validate(n,t)||null;return r?(this.trigger("invalid",this,r,i.extend(t,{validationError:r})),!1):!0}}),g={keys:1,values:1,pairs:1,invert:1,pick:0,omit:0,chain:1,isEmpty:1},p(e,g,"attributes");var h=t.Collection=function(n,t){t||(t={}),t.model&&(this.model=t.model),t.comparator!==void 0&&(this.comparator=t.comparator),this._reset(),this.initialize.apply(this,arguments),n&&this.reset(n,i.extend({silent:!0},t))},st={add:!0,remove:!0,merge:!0},ht={add:!0,remove:!1};i.extend(h.prototype,u,{model:e,initialize:function(){},toJSON:function(n){return this.map(function(t){return t.toJSON(n)})},sync:function(){return t.sync.apply(this,arguments)},add:function(n,t){return this.set(n,i.extend({merge:!1},t,ht))},remove:function(n,t){var u,r;return t=i.extend({},t),u=!i.isArray(n),n=u?[n]:i.clone(n),r=this._removeModels(n,t),!t.silent&&r&&this.trigger("update",this,t),u?r[0]:r},set:function(n,t){var y,p,u,e,s,h,f,k,d,r;t=i.defaults({},t,st),t.parse&&!this._isModel(n)&&(n=this.parse(n,t)),y=!i.isArray(n),n=y?n?[n]:[]:n.slice(),f=t.at,f!=null&&(f=+f),f<0&&(f+=this.length+1);var w=this.comparator&&f==null&&t.sort!==!1,nt=i.isString(this.comparator)?this.comparator:null,o=[],c=[],l={},g=t.add,tt=t.merge,b=t.remove,a=!w&&g&&b?[]:!1,v=!1;for(r=0;r<n.length;r++){if(e=n[r],s=this.get(e))b&&(l[s.cid]=!0),tt&&e!==s&&(e=this._isModel(e)?e.attributes:e,t.parse&&(e=s.parse(e,t)),s.set(e,t),w&&!h&&s.hasChanged(nt)&&(h=!0)),n[r]=s;else if(g){if(u=n[r]=this._prepareModel(e,t),!u)continue;o.push(u),this._addReference(u,t)}(u=s||u,u)&&(p=this.modelId(u.attributes),a&&(u.isNew()||!l[p])&&(a.push(u),v=v||!this.models[r]||u.cid!==this.models[r].cid),l[p]=!0)}if(b){for(r=0;r<this.length;r++)l[(u=this.models[r]).cid]||c.push(u);c.length&&this._removeModels(c,t)}if(o.length||v)if(w&&(h=!0),this.length+=o.length,f!=null)for(r=0;r<o.length;r++)this.models.splice(f+r,0,o[r]);else for(a&&(this.models.length=0),k=a||o,r=0;r<k.length;r++)this.models.push(k[r]);if(h&&this.sort({silent:!0}),!t.silent){for(d=f!=null?i.clone(t):t,r=0;r<o.length;r++)f!=null&&(d.index=f+r),(u=o[r]).trigger("add",u,this,d);(h||v)&&this.trigger("sort",this,t),(o.length||c.length)&&this.trigger("update",this,t)}return y?n[0]:n},reset:function(n,t){t=t?i.clone(t):{};for(var r=0;r<this.models.length;r++)this._removeReference(this.models[r],t);return t.previousModels=this.models,this._reset(),n=this.add(n,i.extend({silent:!0},t)),t.silent||this.trigger("reset",this,t),n},push:function(n,t){return this.add(n,i.extend({at:this.length},t))},pop:function(n){var t=this.at(this.length-1);return this.remove(t,n)},unshift:function(n,t){return this.add(n,i.extend({at:0},t))},shift:function(n){var t=this.at(0);return this.remove(t,n)},slice:function(){return y.apply(this.models,arguments)},get:function(n){if(n==null)return void 0;var t=this.modelId(this._isModel(n)?n.attributes:n);return this._byId[n]||this._byId[t]||this._byId[n.cid]},at:function(n){return n<0&&(n+=this.length),this.models[n]},where:function(n,t){var r=i.matches(n);return this[t?"find":"filter"](function(n){return r(n.attributes)})},findWhere:function(n){return this.where(n,!0)},sort:function(n){if(!this.comparator)throw new Error("Cannot sort a set without a comparator");return n||(n={}),i.isString(this.comparator)||this.comparator.length===1?this.models=this.sortBy(this.comparator,this):this.models.sort(i.bind(this.comparator,this)),n.silent||this.trigger("sort",this,n),this},pluck:function(n){return i.invoke(this.models,"get",n)},fetch:function(n){n=i.extend({parse:!0},n);var r=n.success,t=this;return n.success=function(i){var u=n.reset?"reset":"set";t[u](i,n),r&&r.call(n.context,t,i,n),t.trigger("sync",t,i,n)},s(this,n),this.sync("read",this,n)},create:function(n,t){var r,f,u;return(t=t?i.clone(t):{},r=t.wait,n=this._prepareModel(n,t),!n)?!1:(r||this.add(n,t),f=this,u=t.success,t.success=function(n,t,i){r&&f.add(n,i),u&&u.call(i.context,n,t,i)},n.save(null,t),n)},parse:function(n){return n},clone:function(){return new this.constructor(this.models,{model:this.model,comparator:this.comparator})},modelId:function(n){return n[this.model.prototype.idAttribute||"id"]},_reset:function(){this.length=0,this.models=[],this._byId={}},_prepareModel:function(n,t){if(this._isModel(n))return n.collection||(n.collection=this),n;t=t?i.clone(t):{},t.collection=this;var r=new this.model(n,t);return r.validationError?(this.trigger("invalid",this,r.validationError,t),!1):r},_removeModels:function(n,t){for(var u=[],i,f,r=0;r<n.length;r++)(i=this.get(n[r]),i)&&(f=this.indexOf(i),this.models.splice(f,1),this.length--,t.silent||(t.index=f,i.trigger("remove",i,this,t)),u.push(i),this._removeReference(i,t));return u.length?u:!1},_isModel:function(n){return n instanceof e},_addReference:function(n){this._byId[n.cid]=n;var i=this.modelId(n.attributes);i!=null&&(this._byId[i]=n);n.on("all",this._onModelEvent,this)},_removeReference:function(n){delete this._byId[n.cid];var i=this.modelId(n.attributes);i!=null&&delete this._byId[i],this===n.collection&&delete n.collection,n.off("all",this._onModelEvent,this)},_onModelEvent:function(n,t,i,r){if(n!=="add"&&n!=="remove"||i===this){if(n==="destroy"&&this.remove(t,r),n==="change"){var u=this.modelId(t.previousAttributes()),f=this.modelId(t.attributes);u!==f&&(u!=null&&delete this._byId[u],f!=null&&(this._byId[f]=t))}this.trigger.apply(this,arguments)}}}),nt={forEach:3,each:3,map:3,collect:3,reduce:4,foldl:4,inject:4,reduceRight:4,foldr:4,find:3,detect:3,filter:3,select:3,reject:3,every:3,all:3,some:3,any:3,include:2,contains:2,invoke:0,max:3,min:3,toArray:1,size:1,first:3,head:3,take:3,initial:3,rest:3,tail:3,drop:3,last:3,without:0,difference:0,indexOf:3,shuffle:1,lastIndexOf:3,isEmpty:1,chain:1,sample:3,partition:3},p(h,nt,"models"),tt=["groupBy","countBy","sortBy","indexBy"],i.each(tt,function(n){i[n]&&(h.prototype[n]=function(t,r){var u=i.isFunction(t)?t:function(n){return n.get(t)};return i[n](this.models,u,r)})});var it=t.View=function(n){this.cid=i.uniqueId("view"),i.extend(this,i.pick(n,lt)),this._ensureElement(),this.initialize.apply(this,arguments)},ct=/^(\S+)\s*(.*)$/,lt=["model","collection","el","id","attributes","className","tagName","events"];i.extend(it.prototype,u,{tagName:"div",$:function(n){return this.$el.find(n)},initialize:function(){},render:function(){return this},remove:function(){return this._removeElement(),this.stopListening(),this},_removeElement:function(){this.$el.remove()},setElement:function(n){return this.undelegateEvents(),this._setElement(n),this.delegateEvents(),this},_setElement:function(n){this.$el=n instanceof t.$?n:t.$(n),this.el=this.$el[0]},delegateEvents:function(n){var r,t,u;if(n||(n=i.result(this,"events")),!n)return this;this.undelegateEvents();for(r in n)(t=n[r],i.isFunction(t)||(t=this[t]),t)&&(u=r.match(ct),this.delegate(u[1],u[2],i.bind(t,this)));return this},delegate:function(n,t,i){this.$el.on(n+".delegateEvents"+this.cid,t,i);return this},undelegateEvents:function(){return this.$el&&this.$el.off(".delegateEvents"+this.cid),this},undelegate:function(n,t,i){return this.$el.off(n+".delegateEvents"+this.cid,t,i),this},_createElement:function(n){return document.createElement(n)},_ensureElement:function(){if(this.el)this.setElement(i.result(this,"el"));else{var n=i.extend({},i.result(this,"attributes"));this.id&&(n.id=i.result(this,"id")),this.className&&(n["class"]=i.result(this,"className")),this.setElement(this._createElement(i.result(this,"tagName"))),this._setAttributes(n)}},_setAttributes:function(n){this.$el.attr(n)}}),t.sync=function(n,r,u){var e=rt[n],f,o,s,h;return i.defaults(u||(u={}),{emulateHTTP:t.emulateHTTP,emulateJSON:t.emulateJSON}),f={type:e,dataType:"json"},u.url||(f.url=i.result(r,"url")||v()),u.data==null&&r&&(n==="create"||n==="update"||n==="patch")&&(f.contentType="application/json",f.data=JSON.stringify(u.attrs||r.toJSON(u))),u.emulateJSON&&(f.contentType="application/x-www-form-urlencoded",f.data=f.data?{model:f.data}:{}),u.emulateHTTP&&(e==="PUT"||e==="DELETE"||e==="PATCH")&&(f.type="POST",u.emulateJSON&&(f.data._method=e),o=u.beforeSend,u.beforeSend=function(n){return n.setRequestHeader("X-HTTP-Method-Override",e),o?o.apply(this,arguments):void 0}),f.type==="GET"||u.emulateJSON||(f.processData=!1),s=u.error,u.error=function(n,t,i){u.textStatus=t,u.errorThrown=i,s&&s.call(u.context,n,t,i)},h=u.xhr=t.ajax(i.extend(f,u)),r.trigger("request",r,h,u),h},rt={create:"POST",update:"PUT",patch:"PATCH","delete":"DELETE",read:"GET"},t.ajax=function(){return t.$.ajax.apply(t.$,arguments)};var ut=t.Router=function(n){n||(n={}),n.routes&&(this.routes=n.routes),this._bindRoutes(),this.initialize.apply(this,arguments)},at=/\((.*?)\)/g,vt=/(\(\?)?:\w+/g,yt=/\*\w+/g,pt=/[\-{}\[\]+?.,\\\^$|#\s]/g;i.extend(ut.prototype,u,{initialize:function(){},route:function(n,r,u){i.isRegExp(n)||(n=this._routeToRegExp(n)),i.isFunction(r)&&(u=r,r=""),u||(u=this[r]);var f=this;return t.history.route(n,function(i){var e=f._extractParameters(n,i);f.execute(u,e,r)!==!1&&(f.trigger.apply(f,["route:"+r].concat(e)),f.trigger("route",r,e),t.history.trigger("route",f,r,e))}),this},execute:function(n,t){n&&n.apply(this,t)},navigate:function(n,i){return t.history.navigate(n,i),this},_bindRoutes:function(){if(this.routes){this.routes=i.result(this,"routes");for(var n,t=i.keys(this.routes);(n=t.pop())!=null;)this.route(n,this.routes[n])}},_routeToRegExp:function(n){return n=n.replace(pt,"\\$&").replace(at,"(?:$1)?").replace(vt,function(n,t){return t?n:"([^/?]+)"}).replace(yt,"([^?]*?)"),new RegExp("^"+n+"(?:\\?([\\s\\S]*))?$")},_extractParameters:function(n,t){var r=n.exec(t).slice(1);return i.map(r,function(n,t){return t===r.length-1?n||null:n?decodeURIComponent(n):null})}});var f=t.History=function(){this.handlers=[],i.bindAll(this,"checkUrl"),typeof window!="undefined"&&(this.location=window.location,this.history=window.history)},wt=/^[#\/]|\s+$/g,bt=/^\/+|\/+$/g,kt=/#.*$/;return f.started=!1,i.extend(f.prototype,u,{interval:50,atRoot:function(){var n=this.location.pathname.replace(/[^\/]$/,"$&/");return n===this.root&&!this.getSearch()},matchRoot:function(){var n=this.decodeFragment(this.location.pathname),t=n.slice(0,this.root.length-1)+"/";return t===this.root},decodeFragment:function(n){return decodeURI(n.replace(/%25/g,"%2525"))},getSearch:function(){var n=this.location.href.replace(/#.*/,"").match(/\?.+/);return n?n[0]:""},getHash:function(n){var t=(n||this).location.href.match(/#(.*)$/);return t?t[1]:""},getPath:function(){var n=this.decodeFragment(this.location.pathname+this.getSearch()).slice(this.root.length-1);return n.charAt(0)==="/"?n.slice(1):n},getFragment:function(n){return n==null&&(n=this._usePushState||!this._wantsHashChange?this.getPath():this.getHash()),n.replace(wt,"")},start:function(n){var e,r,t,u;if(f.started)throw new Error("Backbone.history has already been started");if(f.started=!0,this.options=i.extend({root:"/"},this.options,n),this.root=this.options.root,this._wantsHashChange=this.options.hashChange!==!1,this._hasHashChange="onhashchange"in window,this._useHashChange=this._wantsHashChange&&this._hasHashChange,this._wantsPushState=!!this.options.pushState,this._hasPushState=!!(this.history&&this.history.pushState),this._usePushState=this._wantsPushState&&this._hasPushState,this.fragment=this.getFragment(),this.root=("/"+this.root+"/").replace(bt,"/"),this._wantsHashChange&&this._wantsPushState)if(this._hasPushState||this.atRoot())this._hasPushState&&this.atRoot()&&this.navigate(this.getHash(),{replace:!0});else return e=this.root.slice(0,-1)||"/",this.location.replace(e+"#"+this.getPath()),!0;return this._hasHashChange||!this._wantsHashChange||this._usePushState||(this.iframe=document.createElement("iframe"),this.iframe.src="javascript:0",this.iframe.style.display="none",this.iframe.tabIndex=-1,r=document.body,t=r.insertBefore(this.iframe,r.firstChild).contentWindow,t.document.open(),t.document.close(),t.location.hash="#"+this.fragment),u=window.addEventListener||function(n,t){return attachEvent("on"+n,t)},this._usePushState?u("popstate",this.checkUrl,!1):this._useHashChange&&!this.iframe?u("hashchange",this.checkUrl,!1):this._wantsHashChange&&(this._checkUrlInterval=setInterval(this.checkUrl,this.interval)),this.options.silent?void 0:this.loadUrl()},stop:function(){var n=window.removeEventListener||function(n,t){return detachEvent("on"+n,t)};this._usePushState?n("popstate",this.checkUrl,!1):this._useHashChange&&!this.iframe&&n("hashchange",this.checkUrl,!1),this.iframe&&(document.body.removeChild(this.iframe),this.iframe=null),this._checkUrlInterval&&clearInterval(this._checkUrlInterval),f.started=!1},route:function(n,t){this.handlers.unshift({route:n,callback:t})},checkUrl:function(){var t=this.getFragment();if(t===this.fragment&&this.iframe&&(t=this.getHash(this.iframe.contentWindow)),t===this.fragment)return!1;this.iframe&&this.navigate(t),this.loadUrl()},loadUrl:function(n){return this.matchRoot()?(n=this.fragment=this.getFragment(n),i.any(this.handlers,function(t){if(t.route.test(n))return t.callback(n),!0})):!1},navigate:function(n,t){var i,u,r;if(!f.started)return!1;if(t&&t!==!0||(t={trigger:!!t}),n=this.getFragment(n||""),i=this.root,(n===""||n.charAt(0)==="?")&&(i=i.slice(0,-1)||"/"),u=i+n,n=this.decodeFragment(n.replace(kt,"")),this.fragment!==n){if(this.fragment=n,this._usePushState)this.history[t.replace?"replaceState":"pushState"]({},document.title,u);else if(this._wantsHashChange)this._updateHash(this.location,n,t.replace),this.iframe&&n!==this.getHash(this.iframe.contentWindow)&&(r=this.iframe.contentWindow,t.replace||(r.document.open(),r.document.close()),this._updateHash(r.location,n,t.replace));else return this.location.assign(u);if(t.trigger)return this.loadUrl(n)}},_updateHash:function(n,t,i){if(i){var r=n.href.replace(/(javascript:|#).*$/,"");n.replace(r+"#"+t)}else n.hash="#"+t}}),t.history=new f,ft=function(n,t){var u=this,r,f;return r=n&&i.has(n,"constructor")?n.constructor:function(){return u.apply(this,arguments)},i.extend(r,u,t),f=function(){this.constructor=r},f.prototype=u.prototype,r.prototype=new f,n&&i.extend(r.prototype,n),r.__super__=u.prototype,r},e.extend=h.extend=ut.extend=it.extend=f.extend=ft,v=function(){throw new Error('A "url" property or function must be specified');},s=function(n,t){var i=t.error;t.error=function(r){i&&i.call(t.context,n,r,t),n.trigger("error",n,r,t)}},t}),function(n,t){if(typeof define=="function"&&define.amd)define(["backbone","underscore"],function(i,r){return n.Marionette=n.Mn=t(n,i,r)});else if(typeof exports!="undefined"){var i=require("backbone"),r=require("underscore");module.exports=t(n,i,r)}else n.Marionette=n.Mn=t(n,n.Backbone,n._)}(this,function(n,t,i){"use strict";var u,f;(function(n,t){var i=n.ChildViewContainer;return n.ChildViewContainer=function(n,t){var i=function(n){this._views={},this._indexByModel={},this._indexByCustom={},this._updateLength(),t.each(n,this.add,this)},r;return t.extend(i.prototype,{add:function(n,t){var i=n.cid;return this._views[i]=n,n.model&&(this._indexByModel[n.model.cid]=i),t&&(this._indexByCustom[t]=i),this._updateLength(),this},findByModel:function(n){return this.findByModelCid(n.cid)},findByModelCid:function(n){var t=this._indexByModel[n];return this.findByCid(t)},findByCustom:function(n){var t=this._indexByCustom[n];return this.findByCid(t)},findByIndex:function(n){return t.values(this._views)[n]},findByCid:function(n){return this._views[n]},remove:function(n){var i=n.cid;return n.model&&delete this._indexByModel[n.model.cid],t.any(this._indexByCustom,function(n,t){if(n===i)return delete this._indexByCustom[t],!0},this),delete this._views[i],this._updateLength(),this},call:function(n){this.apply(n,t.tail(arguments))},apply:function(n,i){t.each(this._views,function(r){t.isFunction(r[n])&&r[n].apply(r,i||[])})},_updateLength:function(){this.length=t.size(this._views)}}),r=["forEach","each","map","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","toArray","first","initial","rest","last","without","isEmpty","pluck","reduce"],t.each(r,function(n){i.prototype[n]=function(){var i=t.values(this._views),r=[i].concat(t.toArray(arguments));return t[n].apply(t,r)}}),i}(n,t),n.ChildViewContainer.VERSION="0.1.7",n.ChildViewContainer.noConflict=function(){return n.ChildViewContainer=i,this},n.ChildViewContainer})(t,i),function(n,t){var r=n.Wreqr,i=n.Wreqr={};return n.Wreqr.VERSION="1.3.3",n.Wreqr.noConflict=function(){return n.Wreqr=r,this},i.Handlers=function(n,t){var i=function(n){this.options=n,this._wreqrHandlers={},t.isFunction(this.initialize)&&this.initialize(n)};return i.extend=n.Model.extend,t.extend(i.prototype,n.Events,{setHandlers:function(n){t.each(n,function(n,i){var r=null;t.isObject(n)&&!t.isFunction(n)&&(r=n.context,n=n.callback),this.setHandler(i,n,r)},this)},setHandler:function(n,t,i){var r={callback:t,context:i};this._wreqrHandlers[n]=r,this.trigger("handler:add",n,t,i)},hasHandler:function(n){return!!this._wreqrHandlers[n]},getHandler:function(n){var t=this._wreqrHandlers[n];if(t)return function(){return t.callback.apply(t.context,arguments)}},removeHandler:function(n){delete this._wreqrHandlers[n]},removeAllHandlers:function(){this._wreqrHandlers={}}}),i}(n,t),i.CommandStorage=function(){var i=function(n){this.options=n,this._commands={},t.isFunction(this.initialize)&&this.initialize(n)};return t.extend(i.prototype,n.Events,{getCommands:function(n){var t=this._commands[n];return t||(t={command:n,instances:[]},this._commands[n]=t),t},addCommand:function(n,t){var i=this.getCommands(n);i.instances.push(t)},clearCommands:function(n){var t=this.getCommands(n);t.instances=[]}}),i}(),i.Commands=function(n,t){return n.Handlers.extend({storageType:n.CommandStorage,constructor:function(t){this.options=t||{},this._initializeStorage(this.options);this.on("handler:add",this._executeCommands,this);n.Handlers.prototype.constructor.apply(this,arguments)},execute:function(n){n=arguments[0];var i=t.rest(arguments);this.hasHandler(n)?this.getHandler(n).apply(this,i):this.storage.addCommand(n,i)},_executeCommands:function(n,i,r){var u=this.storage.getCommands(n);t.each(u.instances,function(n){i.apply(r,n)}),this.storage.clearCommands(n)},_initializeStorage:function(n){var i,r=n.storageType||this.storageType;i=t.isFunction(r)?new r:r,this.storage=i}})}(i,t),i.RequestResponse=function(n,t){return n.Handlers.extend({request:function(n){if(this.hasHandler(n))return this.getHandler(n).apply(this,t.rest(arguments))}})}(i,t),i.EventAggregator=function(n,t){var i=function(){};return i.extend=n.Model.extend,t.extend(i.prototype,n.Events),i}(n,t),i.Channel=function(){var r=function(t){this.vent=new n.Wreqr.EventAggregator,this.reqres=new n.Wreqr.RequestResponse,this.commands=new n.Wreqr.Commands,this.channelName=t};return t.extend(r.prototype,{reset:function(){return this.vent.off(),this.vent.stopListening(),this.reqres.removeAllHandlers(),this.commands.removeAllHandlers(),this},connectEvents:function(n,t){return this._connect("vent",n,t),this},connectCommands:function(n,t){return this._connect("commands",n,t),this},connectRequests:function(n,t){return this._connect("reqres",n,t),this},_connect:function(n,i,r){if(i){r=r||this;var u=n==="vent"?"on":"setHandler";t.each(i,function(i,f){this[n][u](f,t.bind(i,r))},this)}}}),r}(i),i.radio=function(n,t){var i=function(){this._channels={},this.vent={},this.commands={},this.reqres={},this._proxyMethods()},r,u;return t.extend(i.prototype,{channel:function(n){if(!n)throw new Error("Channel must receive a name");return this._getChannel(n)},_getChannel:function(t){var i=this._channels[t];return i||(i=new n.Channel(t),this._channels[t]=i),i},_proxyMethods:function(){t.each(["vent","commands","reqres"],function(n){t.each(r[n],function(t){this[n][t]=u(this,n,t)},this)},this)}}),r={vent:["on","off","trigger","once","stopListening","listenTo","listenToOnce"],commands:["execute","setHandler","setHandlers","removeHandler","removeAllHandlers"],reqres:["request","setHandler","setHandlers","removeHandler","removeAllHandlers"]},u=function(n,i,r){return function(u){var f=n._getChannel(u)[i];return f[r].apply(f,t.rest(arguments))}},new i}(i,t),n.Wreqr}(t,i);var e=n.Marionette,o=n.Mn,r=t.Marionette={};return r.VERSION="2.4.2",r.noConflict=function(){return n.Marionette=e,n.Mn=o,this},t.Marionette=r,r.Deferred=t.$.Deferred,r.extend=t.Model.extend,r.isNodeAttached=function(n){return t.$.contains(document.documentElement,n)},r.mergeOptions=function(n,t){n&&i.extend(this,i.pick(n,t))},r.getOption=function(n,t){if(n&&t)return n.options&&n.options[t]!==undefined?n.options[t]:n[t]},r.proxyGetOption=function(n){return r.getOption(this,n)},r._getValue=function(n,t,r){return i.isFunction(n)&&(n=r?n.apply(t,r):n.call(t)),n},r.normalizeMethods=function(n){return i.reduce(n,function(n,t,r){return i.isFunction(t)||(t=this[t]),t&&(n[r]=t),n},{},this)},r.normalizeUIString=function(n,t){return n.replace(/@ui\.[a-zA-Z_$0-9]*/g,function(n){return t[n.slice(4)]})},r.normalizeUIKeys=function(n,t){return i.reduce(n,function(n,i,u){var f=r.normalizeUIString(u,t);return n[f]=i,n},{})},r.normalizeUIValues=function(n,t,u){return i.each(n,function(f,e){i.isString(f)?n[e]=r.normalizeUIString(f,t):i.isObject(f)&&i.isArray(u)&&(i.extend(f,r.normalizeUIValues(i.pick(f,u),t)),i.each(u,function(n){var u=f[n];i.isString(u)&&(f[n]=r.normalizeUIString(u,t))}))}),n},r.actAsCollection=function(n,t){var r=["forEach","each","map","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","toArray","first","initial","rest","last","without","isEmpty","pluck"];i.each(r,function(r){n[r]=function(){var n=i.values(i.result(this,t)),u=[n].concat(i.toArray(arguments));return i[r].apply(i,u)}})},u=r.deprecate=function(n,t){i.isObject(n)&&(n=n.prev+" is going to be removed in the future. Please use "+n.next+" instead."+(n.url?" See: "+n.url:"")),t!==undefined&&t||u._cache[n]||(u._warn("Deprecation warning: "+n),u._cache[n]=!0)},u._warn=typeof console!="undefined"&&(console.warn||console.log)||function(){},u._cache={},r._triggerMethod=function(){function t(n,t,i){return i.toUpperCase()}var n=/(^|:)(\w)/gi;return function(r,u,f){var e=arguments.length<3,s,o,h;return e&&(f=u,u=f[0]),s="on"+u.replace(n,t),o=r[s],i.isFunction(o)&&(h=o.apply(r,e?i.rest(f):f)),i.isFunction(r.trigger)&&(e+f.length>1?r.trigger.apply(r,e?f:[u].concat(i.drop(f,0))):r.trigger(u)),h}}(),r.triggerMethod=function(){return r._triggerMethod(this,arguments)},r.triggerMethodOn=function(n){var t=i.isFunction(n.triggerMethod)?n.triggerMethod:r.triggerMethod;return t.apply(n,i.rest(arguments))},r.MonitorDOMRefresh=function(n){function u(){n._isShown=!0,t()}function f(){n._isRendered=!0,t()}function t(){n._isShown&&n._isRendered&&r.isNodeAttached(n.el)&&i.isFunction(n.triggerMethod)&&n.triggerMethod("dom:refresh")}n.on({show:u,render:f})},function(n){function r(t,r,u,f){var e=f.split(/\s+/);i.each(e,function(i){var f=t[i];if(!f)throw new n.Error('Method "'+i+'" was configured as an event handler, but does not exist.');t.listenTo(r,u,f)})}function u(n,t,i,r){n.listenTo(t,i,r)}function f(n,t,r,u){var f=u.split(/\s+/);i.each(f,function(i){var u=n[i];n.stopListening(t,r,u)})}function e(n,t,i,r){n.stopListening(t,i,r)}function t(t,r,u,f,e){if(r&&u){if(!i.isObject(u))throw new n.Error({message:"Bindings must be an object or function.",url:"marionette.functions.html#marionettebindentityevents"});u=n._getValue(u,t),i.each(u,function(n,u){i.isFunction(n)?f(t,r,u,n):e(t,r,u,n)})}}n.bindEntityEvents=function(n,i,f){t(n,i,f,u,r)},n.unbindEntityEvents=function(n,i,r){t(n,i,r,e,f)},n.proxyBindEntityEvents=function(t,i){return n.bindEntityEvents(this,t,i)},n.proxyUnbindEntityEvents=function(t,i){return n.unbindEntityEvents(this,t,i)}}(r),f=["description","fileName","lineNumber","name","message","number"],r.Error=r.extend.call(Error,{urlRoot:"http://marionettejs.com/docs/v"+r.VERSION+"/",constructor:function(n,t){i.isObject(n)?(t=n,n=t.message):t||(t={});var r=Error.call(this,n);i.extend(this,i.pick(r,f),i.pick(t,f)),this.captureStackTrace(),t.url&&(this.url=this.urlRoot+t.url)},captureStackTrace:function(){Error.captureStackTrace&&Error.captureStackTrace(this,r.Error)},toString:function(){return this.name+": "+this.message+(this.url?" See: "+this.url:"")}}),r.Error.extend=r.extend,r.Callbacks=function(){this._deferred=r.Deferred(),this._callbacks=[]},i.extend(r.Callbacks.prototype,{add:function(n,t){var r=i.result(this._deferred,"promise");this._callbacks.push({cb:n,ctx:t}),r.then(function(i){t&&(i.context=t),n.call(i.context,i.options)})},run:function(n,t){this._deferred.resolve({options:n,context:t})},reset:function(){var n=this._callbacks;this._deferred=r.Deferred(),this._callbacks=[],i.each(n,function(n){this.add(n.cb,n.ctx)},this)}}),r.Controller=function(n){this.options=n||{},i.isFunction(this.initialize)&&this.initialize(this.options)},r.Controller.extend=r.extend,i.extend(r.Controller.prototype,t.Events,{destroy:function(){return r._triggerMethod(this,"before:destroy",arguments),r._triggerMethod(this,"destroy",arguments),this.stopListening(),this.off(),this},triggerMethod:r.triggerMethod,mergeOptions:r.mergeOptions,getOption:r.proxyGetOption}),r.Object=function(n){this.options=i.extend({},i.result(this,"options"),n),this.initialize.apply(this,arguments)},r.Object.extend=r.extend,i.extend(r.Object.prototype,t.Events,{initialize:function(){},destroy:function(){return this.triggerMethod("before:destroy"),this.triggerMethod("destroy"),this.stopListening(),this},triggerMethod:r.triggerMethod,mergeOptions:r.mergeOptions,getOption:r.proxyGetOption,bindEntityEvents:r.proxyBindEntityEvents,unbindEntityEvents:r.proxyUnbindEntityEvents}),r.Region=r.Object.extend({constructor:function(n){if(this.options=n||{},this.el=this.getOption("el"),this.el=this.el instanceof t.$?this.el[0]:this.el,!this.el)throw new r.Error({name:"NoElError",message:'An "el" must be specified for a region.'});this.$el=this.getEl(this.el),r.Object.call(this,n)},show:function(n,t){if(this._ensureElement()){this._ensureViewIsIntact(n);var e=t||{},o=n!==this.currentView,l=!!e.preventDestroy,a=!!e.forceShow,u=!!this.currentView,v=o&&!l,s=o||a;if(u&&this.triggerMethod("before:swapOut",this.currentView,this,t),this.currentView&&delete this.currentView._parent,v?this.empty():u&&s&&this.currentView.off("destroy",this.empty,this),s){n.once("destroy",this.empty,this);n.render(),n._parent=this,u&&this.triggerMethod("before:swap",n,this,t),this.triggerMethod("before:show",n,this,t),r.triggerMethodOn(n,"before:show",n,this,t),u&&this.triggerMethod("swapOut",this.currentView,this,t);var h=r.isNodeAttached(this.el),f=[],c=i.extend({triggerBeforeAttach:this.triggerBeforeAttach,triggerAttach:this.triggerAttach},e);return h&&c.triggerBeforeAttach&&(f=this._displayedViews(n),this._triggerAttach(f,"before:")),this.attachHtml(n),this.currentView=n,h&&c.triggerAttach&&(f=this._displayedViews(n),this._triggerAttach(f)),u&&this.triggerMethod("swap",n,this,t),this.triggerMethod("show",n,this,t),r.triggerMethodOn(n,"show",n,this,t),this}return this}},triggerBeforeAttach:!0,triggerAttach:!0,_triggerAttach:function(n,t){var u=(t||"")+"attach";i.each(n,function(n){r.triggerMethodOn(n,u,n,this)},this)},_displayedViews:function(n){return i.union([n],i.result(n,"_getNestedViews")||[])},_ensureElement:function(){if(i.isObject(this.el)||(this.$el=this.getEl(this.el),this.el=this.$el[0]),!this.$el||this.$el.length===0){if(this.getOption("allowMissingEl"))return!1;throw new r.Error('An "el" '+this.$el.selector+" must exist in DOM");}return!0},_ensureViewIsIntact:function(n){if(!n)throw new r.Error({name:"ViewNotValid",message:"The view passed is undefined and therefore invalid. You must pass a view instance to show."});if(n.isDestroyed)throw new r.Error({name:"ViewDestroyedError",message:'View (cid: "'+n.cid+'") has already been destroyed and cannot be used.'});},getEl:function(n){return t.$(n,r._getValue(this.options.parentEl,this))},attachHtml:function(n){this.$el.contents().detach(),this.el.appendChild(n.el)},empty:function(n){var t=this.currentView,i=r._getValue(n,"preventDestroy",this);if(t)return t.off("destroy",this.empty,this),this.triggerMethod("before:empty",t),i||this._destroyView(),this.triggerMethod("empty",t),delete this.currentView,i&&this.$el.contents().detach(),this},_destroyView:function(){var n=this.currentView;n.destroy&&!n.isDestroyed?n.destroy():n.remove&&(n.remove(),n.isDestroyed=!0)},attachView:function(n){return this.currentView=n,this},hasView:function(){return!!this.currentView},reset:function(){return this.empty(),this.$el&&(this.el=this.$el.selector),delete this.$el,this}},{buildRegion:function(n,t){if(i.isString(n))return this._buildRegionFromSelector(n,t);if(n.selector||n.el||n.regionClass)return this._buildRegionFromObject(n,t);if(i.isFunction(n))return this._buildRegionFromRegionClass(n);throw new r.Error({message:"Improper region configuration type.",url:"marionette.region.html#region-configuration-types"});},_buildRegionFromSelector:function(n,t){return new t({el:n})},_buildRegionFromObject:function(n,t){var u=n.regionClass||t,r=i.omit(n,"selector","regionClass");return n.selector&&!r.el&&(r.el=n.selector),new u(r)},_buildRegionFromRegionClass:function(n){return new n}}),r.RegionManager=r.Controller.extend({constructor:function(n){this._regions={},this.length=0,r.Controller.call(this,n),this.addRegions(this.getOption("regions"))},addRegions:function(n,t){return n=r._getValue(n,this,arguments),i.reduce(n,function(n,r,u){return i.isString(r)&&(r={selector:r}),r.selector&&(r=i.defaults({},r,t)),n[u]=this.addRegion(u,r),n},{},this)},addRegion:function(n,t){var i;return i=t instanceof r.Region?t:r.Region.buildRegion(t,r.Region),this.triggerMethod("before:add:region",n,i),i._parent=this,this._store(n,i),this.triggerMethod("add:region",n,i),i},get:function(n){return this._regions[n]},getRegions:function(){return i.clone(this._regions)},removeRegion:function(n){var t=this._regions[n];return this._remove(n,t),t},removeRegions:function(){var n=this.getRegions();return i.each(this._regions,function(n,t){this._remove(t,n)},this),n},emptyRegions:function(){var n=this.getRegions();return i.invoke(n,"empty"),n},destroy:function(){return this.removeRegions(),r.Controller.prototype.destroy.apply(this,arguments)},_store:function(n,t){this._regions[n]||this.length++,this._regions[n]=t},_remove:function(n,t){this.triggerMethod("before:remove:region",n,t),t.empty(),t.stopListening(),delete t._parent,delete this._regions[n],this.length--,this.triggerMethod("remove:region",n,t)}}),r.actAsCollection(r.RegionManager.prototype,"_regions"),r.TemplateCache=function(n){this.templateId=n},i.extend(r.TemplateCache,{templateCaches:{},get:function(n,t){var i=this.templateCaches[n];return i||(i=new r.TemplateCache(n),this.templateCaches[n]=i),i.load(t)},clear:function(){var n,t=i.toArray(arguments),r=t.length;if(r>0)for(n=0;n<r;n++)delete this.templateCaches[t[n]];else this.templateCaches={}}}),i.extend(r.TemplateCache.prototype,{load:function(n){if(this.compiledTemplate)return this.compiledTemplate;var t=this.loadTemplate(this.templateId,n);return this.compiledTemplate=this.compileTemplate(t,n)},loadTemplate:function(n){var u=t.$(n).html();if(!u||u.length===0)throw new r.Error({name:"NoTemplateError",message:'Could not find template: "'+n+'"'});return u},compileTemplate:function(n,t){return i.template(n,t)}}),r.Renderer={render:function(n,t){if(!n)throw new r.Error({name:"TemplateNotFoundError",message:"Cannot render the template since its false, null or undefined."});var u=i.isFunction(n)?n:r.TemplateCache.get(n);return u(t)}},r.View=t.View.extend({isDestroyed:!1,constructor:function(n){i.bindAll(this,"render"),n=r._getValue(n,this),this.options=i.extend({},i.result(this,"options"),n),this._behaviors=r.Behaviors(this),t.View.call(this,this.options),r.MonitorDOMRefresh(this)},getTemplate:function(){return this.getOption("template")},serializeModel:function(n){return n.toJSON.apply(n,i.rest(arguments))},mixinTemplateHelpers:function(n){n=n||{};var t=this.getOption("templateHelpers");return t=r._getValue(t,this),i.extend(n,t)},normalizeUIKeys:function(n){var t=i.result(this,"_uiBindings");return r.normalizeUIKeys(n,t||i.result(this,"ui"))},normalizeUIValues:function(n,t){var u=i.result(this,"ui"),f=i.result(this,"_uiBindings");return r.normalizeUIValues(n,f||u,t)},configureTriggers:function(){if(this.triggers){var n=this.normalizeUIKeys(i.result(this,"triggers"));return i.reduce(n,function(n,t,i){return n[i]=this._buildViewTrigger(t),n},{},this)}},delegateEvents:function(n){return this._delegateDOMEvents(n),this.bindEntityEvents(this.model,this.getOption("modelEvents")),this.bindEntityEvents(this.collection,this.getOption("collectionEvents")),i.each(this._behaviors,function(n){n.bindEntityEvents(this.model,n.getOption("modelEvents")),n.bindEntityEvents(this.collection,n.getOption("collectionEvents"))},this),this},_delegateDOMEvents:function(n){var u=r._getValue(n||this.events,this);u=this.normalizeUIKeys(u),i.isUndefined(n)&&(this.events=u);var f={},e=i.result(this,"behaviorEvents")||{},o=this.configureTriggers(),s=i.result(this,"behaviorTriggers")||{};i.extend(f,e,u,o,s),t.View.prototype.delegateEvents.call(this,f)},undelegateEvents:function(){return t.View.prototype.undelegateEvents.apply(this,arguments),this.unbindEntityEvents(this.model,this.getOption("modelEvents")),this.unbindEntityEvents(this.collection,this.getOption("collectionEvents")),i.each(this._behaviors,function(n){n.unbindEntityEvents(this.model,n.getOption("modelEvents")),n.unbindEntityEvents(this.collection,n.getOption("collectionEvents"))},this),this},_ensureViewIsIntact:function(){if(this.isDestroyed)throw new r.Error({name:"ViewDestroyedError",message:'View (cid: "'+this.cid+'") has already been destroyed and cannot be used.'});},destroy:function(){if(this.isDestroyed)return this;var n=i.toArray(arguments);return this.triggerMethod.apply(this,["before:destroy"].concat(n)),this.isDestroyed=!0,this.triggerMethod.apply(this,["destroy"].concat(n)),this.unbindUIElements(),this.isRendered=!1,this.remove(),i.invoke(this._behaviors,"destroy",n),this},bindUIElements:function(){this._bindUIElements(),i.invoke(this._behaviors,this._bindUIElements)},_bindUIElements:function(){if(this.ui){this._uiBindings||(this._uiBindings=this.ui);var n=i.result(this,"_uiBindings");this.ui={},i.each(n,function(n,t){this.ui[t]=this.$(n)},this)}},unbindUIElements:function(){this._unbindUIElements(),i.invoke(this._behaviors,this._unbindUIElements)},_unbindUIElements:function(){this.ui&&this._uiBindings&&(i.each(this.ui,function(n,t){delete this.ui[t]},this),this.ui=this._uiBindings,delete this._uiBindings)},_buildViewTrigger:function(n){var r=i.isObject(n),t=i.defaults({},r?n:{},{preventDefault:!0,stopPropagation:!0}),u=r?t.event:n;return function(n){n&&(n.preventDefault&&t.preventDefault&&n.preventDefault(),n.stopPropagation&&t.stopPropagation&&n.stopPropagation());var i={view:this,model:this.model,collection:this.collection};this.triggerMethod(u,i)}},setElement:function(){var n=t.View.prototype.setElement.apply(this,arguments);return i.invoke(this._behaviors,"proxyViewProperties",this),n},triggerMethod:function(){var n=r._triggerMethod(this,arguments);return this._triggerEventOnBehaviors(arguments),this._triggerEventOnParentLayout(arguments[0],i.rest(arguments)),n},_triggerEventOnBehaviors:function(n){for(var f=r._triggerMethod,i=this._behaviors,t=0,u=i&&i.length;t<u;t++)f(i[t],n)},_triggerEventOnParentLayout:function(n,t){var u=this._parentLayoutView(),e,o,s,f;u&&(e=r.getOption(u,"childViewEventPrefix"),o=e+":"+n,r._triggerMethod(u,[o,this].concat(t)),s=r.getOption(u,"childEvents"),f=u.normalizeMethods(s),!!f&&i.isFunction(f[n])&&f[n].apply(u,[this].concat(t)))},_getImmediateChildren:function(){return[]},_getNestedViews:function(){var n=this._getImmediateChildren();return n.length?i.reduce(n,function(n,t){return t._getNestedViews?n.concat(t._getNestedViews()):n},n):n},_getAncestors:function(){for(var t=[],n=this._parent;n;)t.push(n),n=n._parent;return t},_parentLayoutView:function(){var n=this._getAncestors();return i.find(n,function(n){return n instanceof r.LayoutView})},normalizeMethods:r.normalizeMethods,mergeOptions:r.mergeOptions,getOption:r.proxyGetOption,bindEntityEvents:r.proxyBindEntityEvents,unbindEntityEvents:r.proxyUnbindEntityEvents}),r.ItemView=r.View.extend({constructor:function(){r.View.apply(this,arguments)},serializeData:function(){if(!this.model&&!this.collection)return{};var n=[this.model||this.collection];return arguments.length&&n.push.apply(n,arguments),this.model?this.serializeModel.apply(this,n):{items:this.serializeCollection.apply(this,n)}},serializeCollection:function(n){return n.toJSON.apply(n,i.rest(arguments))},render:function(){return this._ensureViewIsIntact(),this.triggerMethod("before:render",this),this._renderTemplate(),this.isRendered=!0,this.bindUIElements(),this.triggerMethod("render",this),this},_renderTemplate:function(){var n=this.getTemplate(),t,i;if(n!==!1){if(!n)throw new r.Error({name:"UndefinedTemplateError",message:"Cannot render the template since it is null or undefined."});return t=this.mixinTemplateHelpers(this.serializeData()),i=r.Renderer.render(n,t,this),this.attachElContent(i),this}},attachElContent:function(n){return this.$el.html(n),this}}),r.CollectionView=r.View.extend({childViewEventPrefix:"childview",sort:!0,constructor:function(){this.once("render",this._initialEvents);this._initChildViewStorage(),r.View.apply(this,arguments);this.on({"before:show":this._onBeforeShowCalled,show:this._onShowCalled,"before:attach":this._onBeforeAttachCalled,attach:this._onAttachCalled});this.initRenderBuffer()},initRenderBuffer:function(){this._bufferedChildren=[]},startBuffering:function(){this.initRenderBuffer(),this.isBuffering=!0},endBuffering:function(){var t=this._isShown&&r.isNodeAttached(this.el),n;this.isBuffering=!1,this._isShown&&this._triggerMethodMany(this._bufferedChildren,this,"before:show"),t&&this._triggerBeforeAttach&&(n=this._getNestedViews(),this._triggerMethodMany(n,this,"before:attach")),this.attachBuffer(this,this._createBuffer()),t&&this._triggerAttach&&(n=this._getNestedViews(),this._triggerMethodMany(n,this,"attach")),this._isShown&&this._triggerMethodMany(this._bufferedChildren,this,"show"),this.initRenderBuffer()},_triggerMethodMany:function(n,t,u){var f=i.drop(arguments,3);i.each(n,function(n){r.triggerMethodOn.apply(n,[n,u,n,t].concat(f))})},_initialEvents:function(){this.collection&&(this.listenTo(this.collection,"add",this._onCollectionAdd),this.listenTo(this.collection,"remove",this._onCollectionRemove),this.listenTo(this.collection,"reset",this.render),this.getOption("sort")&&this.listenTo(this.collection,"sort",this._sortViews))},_onCollectionAdd:function(n,t,r){var u,f;u=r.at!==undefined?r.at:i.indexOf(this._filteredSortedModels(),n),this._shouldAddChild(n,u)&&(this.destroyEmptyView(),f=this.getChildView(n),this.addChild(n,f,u))},_onCollectionRemove:function(n){var t=this.children.findByModel(n);this.removeChildView(t),this.checkEmpty()},_onBeforeShowCalled:function(){this._triggerBeforeAttach=this._triggerAttach=!1,this.children.each(function(n){r.triggerMethodOn(n,"before:show",n)})},_onShowCalled:function(){this.children.each(function(n){r.triggerMethodOn(n,"show",n)})},_onBeforeAttachCalled:function(){this._triggerBeforeAttach=!0},_onAttachCalled:function(){this._triggerAttach=!0},render:function(){return this._ensureViewIsIntact(),this.triggerMethod("before:render",this),this._renderChildren(),this.isRendered=!0,this.triggerMethod("render",this),this},reorder:function(){var n=this.children,t=this._filteredSortedModels(),u=i.find(t,function(t){return!n.findByModel(t)}),r;u?this.render():(r=i.map(t,function(t,i){var r=n.findByModel(t);return r._index=i,r.el}),this.triggerMethod("before:reorder"),this._appendReorderedChildren(r),this.triggerMethod("reorder"))},resortView:function(){r.getOption(this,"reorderOnSort")?this.reorder():this.render()},_sortViews:function(){var n=this._filteredSortedModels(),t=i.find(n,function(n,t){var i=this.children.findByModel(n);return!i||i._index!==t},this);t&&this.resortView()},_emptyViewIndex:-1,_appendReorderedChildren:function(n){this.$el.append(n)},_renderChildren:function(){this.destroyEmptyView(),this.destroyChildren({checkEmpty:!1}),this.isEmpty(this.collection)?this.showEmptyView():(this.triggerMethod("before:render:collection",this),this.startBuffering(),this.showCollection(),this.endBuffering(),this.triggerMethod("render:collection",this),this.children.isEmpty()&&this.showEmptyView())},showCollection:function(){var n,t=this._filteredSortedModels();i.each(t,function(t,i){n=this.getChildView(t),this.addChild(t,n,i)},this)},_filteredSortedModels:function(){var n,t=this.getViewComparator();return n=t?i.isString(t)||t.length===1?this.collection.sortBy(t,this):i.clone(this.collection.models).sort(i.bind(t,this)):this.collection.models,this.getOption("filter")&&(n=i.filter(n,function(n,t){return this._shouldAddChild(n,t)},this)),n},showEmptyView:function(){var n=this.getEmptyView(),i;n&&!this._showingEmptyView&&(this.triggerMethod("before:render:empty"),this._showingEmptyView=!0,i=new t.Model,this.addEmptyView(i,n),this.triggerMethod("render:empty"))},destroyEmptyView:function(){this._showingEmptyView&&(this.triggerMethod("before:remove:empty"),this.destroyChildren(),delete this._showingEmptyView,this.triggerMethod("remove:empty"))},getEmptyView:function(){return this.getOption("emptyView")},addEmptyView:function(n,t){var o=this._isShown&&!this.isBuffering&&r.isNodeAttached(this.el),f,e=this.getOption("emptyViewOptions")||this.getOption("childViewOptions"),u;if(i.isFunction(e)&&(e=e.call(this,n,this._emptyViewIndex)),u=this.buildChildView(n,t,e),u._parent=this,this.proxyChildEvents(u),this._isShown&&r.triggerMethodOn(u,"before:show",u),this.children.add(u),o&&this._triggerBeforeAttach){f=[u].concat(u._getNestedViews());u.once("render",function(){this._triggerMethodMany(f,this,"before:attach")},this)}this.renderChildView(u,this._emptyViewIndex),o&&this._triggerAttach&&(f=[u].concat(u._getNestedViews()),this._triggerMethodMany(f,this,"attach")),this._isShown&&r.triggerMethodOn(u,"show",u)},getChildView:function(){var t=this.getOption("childView");if(!t)throw new r.Error({name:"NoChildViewError",message:'A "childView" must be specified'});return t},addChild:function(n,t,i){var f=this.getOption("childViewOptions"),u;return f=r._getValue(f,this,[n,i]),u=this.buildChildView(n,t,f),this._updateIndices(u,!0,i),this.triggerMethod("before:add:child",u),this._addChildView(u,i),this.triggerMethod("add:child",u),u._parent=this,u},_updateIndices:function(n,t,i){this.getOption("sort")&&(t&&(n._index=i),this.children.each(function(i){i._index>=n._index&&(i._index+=t?1:-1)}))},_addChildView:function(n,t){var u=this._isShown&&!this.isBuffering&&r.isNodeAttached(this.el),i;if(this.proxyChildEvents(n),this._isShown&&!this.isBuffering&&r.triggerMethodOn(n,"before:show",n),this.children.add(n),u&&this._triggerBeforeAttach){i=[n].concat(n._getNestedViews());n.once("render",function(){this._triggerMethodMany(i,this,"before:attach")},this)}this.renderChildView(n,t),u&&this._triggerAttach&&(i=[n].concat(n._getNestedViews()),this._triggerMethodMany(i,this,"attach")),this._isShown&&!this.isBuffering&&r.triggerMethodOn(n,"show",n)},renderChildView:function(n,t){return n.render(),this.attachHtml(this,n,t),n},buildChildView:function(n,t,r){var u=i.extend({model:n},r);return new t(u)},removeChildView:function(n){return n&&(this.triggerMethod("before:remove:child",n),n.destroy?n.destroy():n.remove&&n.remove(),delete n._parent,this.stopListening(n),this.children.remove(n),this.triggerMethod("remove:child",n),this._updateIndices(n,!1)),n},isEmpty:function(){return!this.collection||this.collection.length===0},checkEmpty:function(){this.isEmpty(this.collection)&&this.showEmptyView()},attachBuffer:function(n,t){n.$el.append(t)},_createBuffer:function(){var n=document.createDocumentFragment();return i.each(this._bufferedChildren,function(t){n.appendChild(t.el)}),n},attachHtml:function(n,t,i){n.isBuffering?n._bufferedChildren.splice(i,0,t):n._insertBefore(t,i)||n._insertAfter(t)},_insertBefore:function(n,t){var i,r=this.getOption("sort")&&t<this.children.length-1;return(r&&(i=this.children.find(function(n){return n._index===t+1})),i)?(i.$el.before(n.el),!0):!1},_insertAfter:function(n){this.$el.append(n.el)},_initChildViewStorage:function(){this.children=new t.ChildViewContainer},destroy:function(){return this.isDestroyed?this:(this.triggerMethod("before:destroy:collection"),this.destroyChildren({checkEmpty:!1}),this.triggerMethod("destroy:collection"),r.View.prototype.destroy.apply(this,arguments))},destroyChildren:function(n){var t=n||{},r=!0,u=this.children.map(i.identity);return i.isUndefined(t.checkEmpty)||(r=t.checkEmpty),this.children.each(this.removeChildView,this),r&&this.checkEmpty(),u},_shouldAddChild:function(n,t){var r=this.getOption("filter");return!i.isFunction(r)||r.call(this,n,t,this.collection)},proxyChildEvents:function(n){var t=this.getOption("childViewEventPrefix");this.listenTo(n,"all",function(){var r=i.toArray(arguments),u=r[0],f=this.normalizeMethods(i.result(this,"childEvents"));r[0]=t+":"+u,r.splice(1,0,n),typeof f!="undefined"&&i.isFunction(f[u])&&f[u].apply(this,r.slice(1)),this.triggerMethod.apply(this,r)})},_getImmediateChildren:function(){return i.values(this.children._views)},getViewComparator:function(){return this.getOption("viewComparator")}}),r.CompositeView=r.CollectionView.extend({constructor:function(){r.CollectionView.apply(this,arguments)},_initialEvents:function(){this.collection&&(this.listenTo(this.collection,"add",this._onCollectionAdd),this.listenTo(this.collection,"remove",this._onCollectionRemove),this.listenTo(this.collection,"reset",this._renderChildren),this.getOption("sort")&&this.listenTo(this.collection,"sort",this._sortViews))},getChildView:function(){return this.getOption("childView")||this.constructor},serializeData:function(){var n={};return this.model&&(n=i.partial(this.serializeModel,this.model).apply(this,arguments)),n},render:function(){return this._ensureViewIsIntact(),this._isRendering=!0,this.resetChildViewContainer(),this.triggerMethod("before:render",this),this._renderTemplate(),this._renderChildren(),this._isRendering=!1,this.isRendered=!0,this.triggerMethod("render",this),this},_renderChildren:function(){(this.isRendered||this._isRendering)&&r.CollectionView.prototype._renderChildren.call(this)},_renderTemplate:function(){var n={},t,i;n=this.serializeData(),n=this.mixinTemplateHelpers(n),this.triggerMethod("before:render:template"),t=this.getTemplate(),i=r.Renderer.render(t,n,this),this.attachElContent(i),this.bindUIElements(),this.triggerMethod("render:template")},attachElContent:function(n){return this.$el.html(n),this},attachBuffer:function(n,t){var i=this.getChildViewContainer(n);i.append(t)},_insertAfter:function(n){var t=this.getChildViewContainer(this,n);t.append(n.el)},_appendReorderedChildren:function(n){var t=this.getChildViewContainer(this);t.append(n)},getChildViewContainer:function(n){var i,f,u;if(!!n.$childViewContainer)return n.$childViewContainer;if(f=r.getOption(n,"childViewContainer"),f){if(u=r._getValue(f,n),i=u.charAt(0)==="@"&&n.ui?n.ui[u.substr(4)]:n.$(u),i.length<=0)throw new r.Error({name:"ChildViewContainerMissingError",message:'The specified "childViewContainer" was not found: '+n.childViewContainer});}else i=n.$el;return n.$childViewContainer=i,i},resetChildViewContainer:function(){this.$childViewContainer&&(this.$childViewContainer=undefined)}}),r.LayoutView=r.ItemView.extend({regionClass:r.Region,options:{destroyImmediate:!1},childViewEventPrefix:"childview",constructor:function(n){n=n||{},this._firstRender=!0,this._initializeRegions(n),r.ItemView.call(this,n)},render:function(){return this._ensureViewIsIntact(),this._firstRender?this._firstRender=!1:this._reInitializeRegions(),r.ItemView.prototype.render.apply(this,arguments)},destroy:function(){return this.isDestroyed?this:(this.getOption("destroyImmediate")===!0&&this.$el.remove(),this.regionManager.destroy(),r.ItemView.prototype.destroy.apply(this,arguments))},showChildView:function(n,t){return this.getRegion(n).show(t)},getChildView:function(n){return this.getRegion(n).currentView},addRegion:function(n,t){var i={};return i[n]=t,this._buildRegions(i)[n]},addRegions:function(n){return this.regions=i.extend({},this.regions,n),this._buildRegions(n)},removeRegion:function(n){return delete this.regions[n],this.regionManager.removeRegion(n)},getRegion:function(n){return this.regionManager.get(n)},getRegions:function(){return this.regionManager.getRegions()},_buildRegions:function(n){var t={regionClass:this.getOption("regionClass"),parentEl:i.partial(i.result,this,"el")};return this.regionManager.addRegions(n,t)},_initializeRegions:function(n){var t,u;this._initRegionManager(),t=r._getValue(this.regions,this,[n])||{},u=this.getOption.call(n,"regions"),u=r._getValue(u,this,[n]),i.extend(t,u),t=this.normalizeUIValues(t,["selector","el"]),this.addRegions(t)},_reInitializeRegions:function(){this.regionManager.invoke("reset")},getRegionManager:function(){return new r.RegionManager},_initRegionManager:function(){this.regionManager=this.getRegionManager(),this.regionManager._parent=this,this.listenTo(this.regionManager,"before:add:region",function(n){this.triggerMethod("before:add:region",n)}),this.listenTo(this.regionManager,"add:region",function(n,t){this[n]=t,this.triggerMethod("add:region",n,t)}),this.listenTo(this.regionManager,"before:remove:region",function(n){this.triggerMethod("before:remove:region",n)}),this.listenTo(this.regionManager,"remove:region",function(n,t){delete this[n],this.triggerMethod("remove:region",n,t)})},_getImmediateChildren:function(){return i.chain(this.regionManager.getRegions()).pluck("currentView").compact().value()}}),r.Behavior=r.Object.extend({constructor:function(n,t){this.view=t,this.defaults=i.result(this,"defaults")||{},this.options=i.extend({},this.defaults,n),this.ui=i.extend({},i.result(t,"ui"),i.result(this,"ui")),r.Object.apply(this,arguments)},$:function(){return this.view.$.apply(this.view,arguments)},destroy:function(){return this.stopListening(),this},proxyViewProperties:function(n){this.$el=n.$el,this.el=n.el}}),r.Behaviors=function(n,t){function i(n,u){return t.isObject(n.behaviors)?(u=i.parseBehaviors(n,u||t.result(n,"behaviors")),i.wrap(n,u,t.keys(r)),u):{}}function u(n,t){this._view=n,this._behaviors=t,this._triggers={}}function f(n){return n._uiBindings||n.ui}var e=/^(\S+)\s*(.*)$/,r={behaviorTriggers:function(n,t){var i=new u(this,t);return i.buildBehaviorTriggers()},behaviorEvents:function(i,r){var u={};return t.each(r,function(i,r){var s={},o=t.clone(t.result(i,"events"))||{},h;o=n.normalizeUIKeys(o,f(i)),h=0,t.each(o,function(n,u){var f=u.match(e),o=f[1]+"."+[this.cid,r,h++," "].join(""),c=f[2],l=o+c,a=t.isFunction(n)?n:i[n];s[l]=t.bind(a,i)},this),u=t.extend(u,s)},this),u}};return t.extend(i,{behaviorsLookup:function(){throw new n.Error({message:"You must define where your behaviors are stored.",url:"marionette.behaviors.html#behaviorslookup"});},getBehaviorClass:function(t,r){return t.behaviorClass?t.behaviorClass:n._getValue(i.behaviorsLookup,this,[t,r])[r]},parseBehaviors:function(n,r){return t.chain(r).map(function(r,u){var e=i.getBehaviorClass(r,u),f=new e(r,n),o=i.parseBehaviors(n,t.result(f,"behaviors"));return[f].concat(o)}).flatten().value()},wrap:function(n,i,u){t.each(u,function(u){n[u]=t.partial(r[u],n[u],i)})}}),t.extend(u.prototype,{buildBehaviorTriggers:function(){return t.each(this._behaviors,this._buildTriggerHandlersForBehavior,this),this._triggers},_buildTriggerHandlersForBehavior:function(i,r){var u=t.clone(t.result(i,"triggers"))||{};u=n.normalizeUIKeys(u,f(i)),t.each(u,t.bind(this._setHandlerForBehavior,this,i,r))},_setHandlerForBehavior:function(n,t,i,r){var u=r.replace(/^\S+/,function(n){return n+".behaviortriggers"+t});this._triggers[u]=this._view._buildViewTrigger(i)}}),i}(r,i),r.AppRouter=t.Router.extend({constructor:function(n){this.options=n||{},t.Router.apply(this,arguments);var i=this.getOption("appRoutes"),r=this._getController();this.processAppRoutes(r,i);this.on("route",this._processOnRoute,this)},appRoute:function(n,t){var i=this._getController();this._addAppRoute(i,n,t)},_processOnRoute:function(n,t){if(i.isFunction(this.onRoute)){var r=i.invert(this.getOption("appRoutes"))[n];this.onRoute(n,r,t)}},processAppRoutes:function(n,t){if(t){var r=i.keys(t).reverse();i.each(r,function(i){this._addAppRoute(n,i,t[i])},this)}},_getController:function(){return this.getOption("controller")},_addAppRoute:function(n,t,u){var f=n[u];if(!f)throw new r.Error('Method "'+u+'" was not found on the controller');this.route(t,u,i.bind(f,n))},mergeOptions:r.mergeOptions,getOption:r.proxyGetOption,triggerMethod:r.triggerMethod,bindEntityEvents:r.proxyBindEntityEvents,unbindEntityEvents:r.proxyUnbindEntityEvents}),r.Application=r.Object.extend({constructor:function(n){this._initializeRegions(n),this._initCallbacks=new r.Callbacks,this.submodules={},i.extend(this,n),this._initChannel(),r.Object.call(this,n)},execute:function(){this.commands.execute.apply(this.commands,arguments)},request:function(){return this.reqres.request.apply(this.reqres,arguments)},addInitializer:function(n){this._initCallbacks.add(n)},start:function(n){this.triggerMethod("before:start",n),this._initCallbacks.run(n,this),this.triggerMethod("start",n)},addRegions:function(n){return this._regionManager.addRegions(n)},emptyRegions:function(){return this._regionManager.emptyRegions()},removeRegion:function(n){return this._regionManager.removeRegion(n)},getRegion:function(n){return this._regionManager.get(n)},getRegions:function(){return this._regionManager.getRegions()},module:function(n,t){var u=r.Module.getClass(t),f=i.toArray(arguments);return f.unshift(this),u.create.apply(u,f)},getRegionManager:function(){return new r.RegionManager},_initializeRegions:function(n){var u=i.isFunction(this.regions)?this.regions(n):this.regions||{},t;return this._initRegionManager(),t=r.getOption(n,"regions"),i.isFunction(t)&&(t=t.call(this,n)),i.extend(u,t),this.addRegions(u),this},_initRegionManager:function(){this._regionManager=this.getRegionManager(),this._regionManager._parent=this,this.listenTo(this._regionManager,"before:add:region",function(){r._triggerMethod(this,"before:add:region",arguments)}),this.listenTo(this._regionManager,"add:region",function(n,t){this[n]=t,r._triggerMethod(this,"add:region",arguments)}),this.listenTo(this._regionManager,"before:remove:region",function(){r._triggerMethod(this,"before:remove:region",arguments)}),this.listenTo(this._regionManager,"remove:region",function(n){delete this[n],r._triggerMethod(this,"remove:region",arguments)})},_initChannel:function(){this.channelName=i.result(this,"channelName")||"global",this.channel=i.result(this,"channel")||t.Wreqr.radio.channel(this.channelName),this.vent=i.result(this,"vent")||this.channel.vent,this.commands=i.result(this,"commands")||this.channel.commands,this.reqres=i.result(this,"reqres")||this.channel.reqres}}),r.Module=function(n,t,r){this.moduleName=n,this.options=i.extend({},this.options,r),this.initialize=r.initialize||this.initialize,this.submodules={},this._setupInitializersAndFinalizers(),this.app=t,i.isFunction(this.initialize)&&this.initialize(n,t,this.options)},r.Module.extend=r.extend,i.extend(r.Module.prototype,t.Events,{startWithParent:!0,initialize:function(){},addInitializer:function(n){this._initializerCallbacks.add(n)},addFinalizer:function(n){this._finalizerCallbacks.add(n)},start:function(n){this._isInitialized||(i.each(this.submodules,function(t){t.startWithParent&&t.start(n)}),this.triggerMethod("before:start",n),this._initializerCallbacks.run(n,this),this._isInitialized=!0,this.triggerMethod("start",n))},stop:function(){this._isInitialized&&(this._isInitialized=!1,this.triggerMethod("before:stop"),i.invoke(this.submodules,"stop"),this._finalizerCallbacks.run(undefined,this),this._initializerCallbacks.reset(),this._finalizerCallbacks.reset(),this.triggerMethod("stop"))},addDefinition:function(n,t){this._runModuleDefinition(n,t)},_runModuleDefinition:function(n,u){if(n){var f=i.flatten([this,this.app,t,r,t.$,i,u]);n.apply(this,f)}},_setupInitializersAndFinalizers:function(){this._initializerCallbacks=new r.Callbacks,this._finalizerCallbacks=new r.Callbacks},triggerMethod:r.triggerMethod}),i.extend(r.Module,{create:function(n,t,r){var u=n,o=i.drop(arguments,3),e,f;return t=t.split("."),e=t.length,f=[],f[e-1]=r,i.each(t,function(t,i){var e=u;u=this._getModule(e,t,n,r),this._addModuleDefinition(e,u,f[i],o)},this),u},_getModule:function(n,t,r,u){var o=i.extend({},u),s=this.getClass(u),e=n[t];return e||(e=new s(t,r,o),n[t]=e,n.submodules[t]=e),e},getClass:function(n){var t=r.Module;return n?n.prototype instanceof t?n:n.moduleClass||t:t},_addModuleDefinition:function(n,t,i,r){var u=this._getDefine(i),f=this._getStartWithParent(i,t);u&&t.addDefinition(u,r),this._addStartWithParent(n,t,f)},_getStartWithParent:function(n,t){var u;return i.isFunction(n)&&n.prototype instanceof r.Module?(u=t.constructor.prototype.startWithParent,i.isUndefined(u)?!0:u):i.isObject(n)?(u=n.startWithParent,i.isUndefined(u)?!0:u):!0},_getDefine:function(n){return i.isFunction(n)&&!(n.prototype instanceof r.Module)?n:i.isObject(n)?n.define:null},_addStartWithParent:function(n,t,i){(t.startWithParent=t.startWithParent&&i,t.startWithParent&&!t.startWithParentIsConfigured)&&(t.startWithParentIsConfigured=!0,n.addInitializer(function(n){t.startWithParent&&t.start(n)}))}}),r}),function(n,t){var r=20181008,i=t.Marionette;i.Handlebars={path:"/scripts",extension:".html"},i.TemplateCache.prototype.load=function(){if(this.compiledTemplate)return this.compiledTemplate;if(n.templates&&n.templates[this.templateId])this.compiledTemplate=n.templates[this.templateId];else{var t=this.loadTemplate(this.templateId);this.compiledTemplate=this.compileTemplate(t)}return this.compiledTemplate},i.TemplateCache.prototype.loadTemplate=function(n){var u,f,e,o;try{u=t.$(n).html()}catch(s){}if((!u||u.length===0)&&(o=i.Handlebars.extension,f=n.length&&n.indexOf(o)>-1?n:n+o,e=i.Handlebars.path+f,t.$.ajax({url:e+"?v="+r,success:function(n){u=n},async:!1}),!u||u.length===0))throw"NoTemplateError - Could not find template: '"+e+"'";return u},i.TemplateCache.prototype.compileTemplate=function(t){return n.compile(t)}}(Handlebars,Backbone)