var ENV={platform:"classic",mode:"production"},SC=SC||{BUNDLE_INFO:{},LAZY_INSTANTIATION:{}};SC.json=JSON;
SC.browser=function(){var a=navigator.userAgent.toLowerCase(),b=(a.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[])[1];a={version:b,safari:/webkit/.test(a)?b:0,opera:/opera/.test(a)?b:0,msie:/msie/.test(a)&&!/opera/.test(a)?b:0,mozilla:/mozilla/.test(a)&&!/(compatible|webkit)/.test(a)?b:0,mobileSafari:/apple.*mobile.*safari/.test(a)?b:0,windows:!!/(windows)/.test(a),mac:!!(/(macintosh)/.test(a)||/(mac os x)/.test(a)),language:(navigator.language||navigator.browserLanguage).split("-",1)[0]};a.current=
a.msie?"msie":a.mozilla?"mozilla":a.safari?"safari":a.opera?"opera":"unknown";return a}();SC.bundleDidLoad=function(a){var b=this.BUNDLE_INFO[a];b||(b=this.BUNDLE_INFO[a]={});b.loaded=true};SC.bundleIsLoaded=function(a){return(a=this.BUNDLE_INFO[a])?!!a.loaded:false};SC.loadBundle=function(){throw"SC.loadBundle(): SproutCore is not loaded.";};
SC.setupBodyClassNames=function(){var a=document.body;if(a){var b,c,d,e,f;b=SC.browser.current;c=SC.browser.windows?"windows":SC.browser.mac?"mac":"other-platform";e=document.documentElement.style;d=e.MozBoxShadow!==undefined||e.webkitBoxShadow!==undefined||e.oBoxShadow!==undefined||e.boxShadow!==undefined;e=e.MozBorderRadius!==undefined||e.webkitBorderRadius!==undefined||e.oBorderRadius!==undefined||e.borderRadius!==undefined;f=a.className?a.className.split(" "):[];d&&f.push("box-shadow");e&&f.push("border-rad");
f.push(b);f.push(c);SC.browser.mobileSafari&&f.push("mobile-safari");a.className=f.join(" ")}};
if("undefined"===typeof tiki)var tiki=function(){function a(f,g){b.push({m:f,a:g})}var b=[],c={},d={},e={_modules:d,_factories:c,isBootstrap:true,queue:b,register:function(f,g){if(f==="tiki"&&"undefined"!==typeof ENV)if(ENV.app==="tiki"&&ENV.mode==="test"){if(!g.depends)g.depends=[];g.depends.push("core_test")}a("register",arguments);return this},script:function(){a("script",arguments);return this},stylesheet:function(){a("stylesheet",arguments);return this},module:function(f,g){c[f]=g;a("module",
arguments);return this},require:function(f){var g,h,j;if(f.indexOf(":")<0)f="tiki:"+f;if(g=d[f])g=g.exports;else{g={};j=d[f]={id:f,exports:g,boot:this};h=c[f];if(typeof h!=="function")throw f+" is not function";f=c["tiki:index"]?e.require("tiki:index"):null;h.call(g,e.require,g,j,f);g=j.exports}return g},destroy:function(){if(this.isDestroyed)return this;this.isDestroyed=true;d=c=b=this.queue=null;return this}};e.require.loader=e;e.ENV=typeof ENV!=="undefined"?ENV:undefined;e.ARGV=typeof ARGV!=="undefined"?
ARGV:undefined;return e}();tiki.register("tiki",{scripts:[{url:"/static/tiki/en/f190e4e36f88857b033c419907d4b704109b7815/javascript.js",id:"tiki:en/f190e4e36f88857b033c419907d4b704109b7815/javascript.js"}]});
tiki.module("tiki:index",function(a,b){function c(y,D,K){var z=D.length;y=y||{};var p,t,A;for(K=K;K<z;K++)if(p=D[K])for(t in p)if(p.hasOwnProperty(t)){A=p[t];if(y!==A)if(A!==undefined)y[t]=A}return y}function d(){return function(){this.__init(arguments);return this}}function e(y,D,K,z,p,t){if(y[D])z&&z.isInvocation?z.invoke():w.invoke(z,p,t,2);else{D=z&&z.isInvocation?z.retain():w.create(z,p,t,2);y[K]||(y[K]=[]);y[K].push(D);y.schedule()}}function f(y,D){var K=y[D],z=K?K.length:0,p,t;for(p=0;p<z;p++){t=
K[p];t.invoke();t.release()}y[D]=null}b.T_ERROR="error";b.T_OBJECT="object";b.T_NULL="null";b.T_CLASS="class";b.T_HASH="hash";b.T_FUNCTION="function";b.T_UNDEFINED="undefined";b.T_NUMBER="number";b.T_BOOL="boolean";b.T_ARRAY="array";b.T_STRING="string";b.T_BOOLEAN="boolean";b.YES=true;b.NO=false;var g=[],h=function(y){if(y&&y.isArray)return true;if(!y)return false;if("undefined"!==typeof y.length)if(typeof y!=="function"&&typeof y!=="string"&&y.constructor!==String)return true;return false};b.isArray=
h;Array.prototype.isArray=true;b.$A=function(y){if(y===null||y===undefined)return[];if(y.slice instanceof Function)return typeof y==="string"?[y]:y.slice();if(y.toArray)return y.toArray();if(!h(y))return[y];for(var D=[],K=y.length;--K>=0;)D[K]=y[K];return D};b.typeOf=function(y){if(y===undefined)return"undefined";if(y===null)return"null";var D=typeof y;if(D=="object")D=h(y)?"array":y instanceof Function?y.isClass?"class":"function":y instanceof Error||y.isError?"error":y.isObject?"object":y.isClass?
"class":y.constructor===Object?"hash":y.constructor===Number?"number":y.constructor===String?"string":"object";else if(D==="function")D=y.isClass?"class":"function";return D};var j="_tk_guid_"+(new Date).getTime(),k=0,l=[],m=[],n=function(y){var D="tk"+k++;if(y)y[j]=D;return D};b.generateGuid=n;b.guidFor=function(y){if(y===undefined)return"(undefined)";if(y===null)return"(null)";if(y===Object)return"(Object)";if(y===Array)return"(Array)";if(y[j])return y[j];switch(typeof y){case "number":return l[y]=
l[y]||"nu"+y;case "string":return m[y]=m[y]||"st"+y;case "boolean":return y?"(true)":"(false)";default:return n(y)}};b.mixin=function(y){return c(y,arguments,1)};var o=function(){},r=o.prototype,u=function(y){var D;if("object"!==typeof y)return y;o.prototype=y;D=new o;o.prototype=r;return c(D,arguments,1)};b.beget=u;var q=function(y){var D;if(D=this.init)D.apply(this,y)};b.extend=function(y){var D=d(),K;if("function"===typeof y){K=D.prototype=u(y.prototype);if(!K.__init)K.__init=q;c(K,arguments,1)}else K=
D.prototype=c({__init:q},arguments,0);return K.constructor=D};var s=function(y,D){g[0]=D;var K;for(K in y)if(y.hasOwnProperty(K)){D=y[K];if("function"===typeof D){g[1]=K;D.displayName=g.join(".")}}g.length=0;return y};b.setupDisplayNames=s;s(b,"tiki");b.Retainable=a("retainable");b.Invocation=a("invocation");b.Promise=a("promise");var w=a("invocation"),v,x;v=function(y,D){e(v,"isReady","queue",y,D,arguments)};b.ready=v;v.main=function(y,D){e(v,"isReady","mqueue",y,D,arguments)};v.isReady=false;v.fire=
function(){if(!v.isReady){v.isReady=true;if(a.loader)a.loader.isReady=true;v.cleanup&&v.cleanup();v.cleanup=null;f(v,"queue");f(v,"mqueue");var y=a.loader?a.loader.nextReady:null;y&&y!==v&&y.fire()}};v.fire.displayName="ready.fire()";v.schedule=function(){};if("undefined"!==typeof document)if(document.addEventListener){v.cleanup=function(){document.removeEventListener("DOMContentLoaded",v.fire,false);document.removeEventListener("load",v.fire,false)};document.addEventListener("DOMContentLoaded",v.fire,
false);document.addEventListener("load",v.fire,false)}else if(document.attachEvent){v.cleanup=function(){document.detachEvent("onreadystatechange",v.fire);document.detachEvent("onload",v.fire);v.ieHandler=null};document.attachEvent("onreadystatechange",v.fire);document.attachEvent("onload",v.fire);if(document.documentElement.doScroll&&window==window.top){v.ieHandler=function(){if(v.ieHandler&&!v.isReady)try{document.documentElement.doScroll("left")}catch(y){setTimeout(v.ieHandler,0);return}v.fire()};
v.ieHandler()}}if(a.loader&&a.loader.previousLoader){if(a.loader.previousLoader.isReady)v.fire();else a.loader.previousLoader.nextReady=v;a.loader.previousLoder=null}x=function(y,D){e(x,"isUnloading","queue",y,D,arguments)};b.unload=x;x.isUnloading=false;x.fire=function(){if(!x.isUnloading){x.isUnloading=true;x.cleanup&&x.cleanup();x.cleanup=null;var y=x.queue,D=y?y.length:0,K,z;for(K=0;K<D;K++){z=y[K];z.invoke();z.release()}x.queue=null}};x.schedule=function(){if(!x.isScheduled){x.isScheduled=true;
if("undefined"!==typeof document)if(document.addEventListener){x.cleanup=function(){document.removeEventListener("unload",x.fire)};document.addEventListener("unload",x.fire,false)}else if(document.attachEvent){x.cleanup=function(){document.detachEvent("onunload",x.fire)};document.attachEvent("unload",x.fire)}}}});
tiki.module("tiki:invocation",function(a,b,c,d){a=a("retainable");var e,f=Array.prototype.slice,g=[];e=d.extend(a,{init:function(h,j,k,l){if(k&&l!==undefined)k=k.length>l?f.call(k,l):null;this.recycled++;this.inPool=this.isDestroyed=false;this.target=h;this.method=j;this.args=k;return this},destroy:function(){this.isDestroyed=true;this.retainCount=1;this.inPool=true;this.target=this.method=this.args=null;g.push(this);return this},invoke:function(){return e.invoke(this.target,this.method,this.args,
undefined,arguments)},isInvocation:true,recycled:0});e.create=function(h,j,k,l){return g.length>0?g.pop().init(h,j,k,l):new e(h,j,k,l)};e.invoke=function(h,j,k,l,m){if(!j&&d.typeOf(h)===d.T_FUNCTION)j=h;if(d.typeOf(j)===d.T_STRING)j=h[j];if(!j)throw"Invocation: method "+this.method+" not defined";if(l!==undefined&&k)k=k.length>l?f.call(k,l):null;if(m&&m.length>0)k=k?k.concat(m):m;return k?j.apply(h,k):j.call(h)};b=c.exports=e;b.Invocation=e});
tiki.module("tiki:loader",function(a,b,c,d){function e(q,s){n[0]=q;n[1]=s;return n.join("::")}function f(q){var s=r[q];if(s)return s;return r[q]="tiki/"+q}function g(q,s){var w=u[q],v;w||(w=u[q]={});(v=w[s])||(v=w[s]=q+":"+s);return v}var h=a("promise"),j=a("sandbox"),k,l=["(function(require, exports, module, tiki) {",null,"\n});\n//@ sourceURL=",null,"\n"],m={},n=[],o=Object.keys;o||(o=function(q){var s,w=[];for(s in q)q.hasOwnProperty(s)&&w.push(s);return w});var r={},u={};k=function(q,s,w){this.id=
q;this.scripts=[];this.packages=[];this.stylesheets=[];this.modules=[];this.ENV=w;this.sandbox=j.create(q,this);this.register("default",{});this.register("tiki",{});q=s?s.length:0;var v;for(w=0;w<q;w++){v=s[w];this[v.m].apply(this,v.a)}return this};k.prototype={scripts:null,stylesheets:null,packages:null,sandbox:null,modules:null,destroy:function(){},resolve:function(q,s,w){var v,x,y,D;if(q.match(/(^\.\.?\/)|(\/\.\.?\/)|(\/\.\.?\/?$)/)){if((x=q.indexOf(":"))>=0){w=q.slice(0,x);q=q.slice(x+1);s=[]}else if(q.match(/^\.\.?\//)){if(!s)throw"base required to resolve relative: "+
q;x=s.indexOf(":");w||(w=s.slice(0,x));if(x>=0)s=s.slice(x+1);s=s.split("/");s.pop()}else s=[];D=q.split("/");v=D.length;for(x=0;x<v;x++){y=D[x];if(y===".."){if(s.length<1)throw"invalid path: "+q;s.pop()}else y!=="."&&s.push(y)}q=s.join("/");if(w)q=g(w,q)}return q},canonical:function(q,s,w){var v=this.resolve(q,s,w),x=this._factories,y=this._catalog;if((q=v.indexOf(":"))<0){if(!w&&s&&(q=s.indexOf(":")))w=s.slice(0,q);if(w==="default")w="tiki";q=g(w,v);v=!y||x&&x[q]?q:y[v]?g(v,"index"):y[f(v)]?g(f(v),
"index"):q}else{w=v.slice(0,q);if(w==="default")v=g("tiki",v.slice(q+1));else if(y&&!y[w]&&y[f(w)])v=f(v)}return v},evaluate:function(q,s){l[1]=q;l[3]=s||"(unknown module)";q=l.join("");q=eval(q);l[1]=l[3]=null;return q},load:function(q,s){var w=this._factories;q=this.canonical(q,s);if(!this.ready(q))throw q+" is not ready";if((s=w[q])&&"string"===typeof s){s=this.evaluate(s,q);w[q]=s}if(!s.displayName)s.displayName=q;return s},global:function(q){var s,w,v,x,y,D;q=this.canonical(q);if((v=q.indexOf(":"))<
0)throw"package not found: "+q;y=q.slice(0,v);q.split(":");s=this._catalog[y];if(!s)throw y+" is not registered";w=(s=s.depends)?s.length:0;if(w<=0)return this;x=this._factories;if(!x)return this;for(v=0;v<w;v++){y=s[v];if(!m[y]){m[y]=true;if(!this.ready(y))throw"cannot make "+y+" global because it is not ready";q=this.canonical(y);if(x[q]){y=this.require(q);if(!y)throw"require "+q+" failed";if(q=y.__globals__){w=q.length;for(v=0;v<w;v++){D=q[v];window[D]=y[D]}}else for(D in y)if(y.hasOwnProperty(D))window[D]=
y[D]}}}},register:function(q,s){if(q.indexOf(":")>0)return this.module(q,s);var w=this._catalog,v;if(!w)w=this._catalog={};if(s=(w[q]=s)?s.packages:null)for(v in s)!s.hasOwnProperty(v)||w[v]||(w[v]=s[v]);this._resolved("catalog",q)||this.packages.push(q);this._promiseFor("catalog",q).resolve(q)},script:function(q){this._resolved("scripts",q)||this.scripts.push(q);this._promiseFor("scripts",q).resolve(q);return this},stylesheet:function(q){this._resolved("stylesheets",q)||this.stylesheets.push(q);
this._promiseFor("stylesheets",q).resolve(q);return this},module:function(q,s){var w=this._factories;if(!w)w=this._factories={};w[q]=s;this._resolved("modules",q)||this.modules.push(q);this._promiseFor("modules",q).resolve(q)},async:function(q){return this._async(q,null)},_async:function(q,s){var w=this._promiseFor("loads",q);if(w.isPending)if(this.ready(q))w.resolve();else{var v=this;w.action(function(x){v._promiseFor("catalog",q).then(x,function(){v._loadPackage(q,x,s||{});x.resolve()},function(y){x.cancel(y)});
v._loadPackage(q,x,s||{})}).run()}return w},require:function(q,s){return this.sandbox.require(q,s)},ready:function(q){return this._ready(q,null)},_ready:function(q,s){if(s)if(s[q])return true;else s[q]=true;var w,v,x,y,D;w=q.indexOf(":");w=w>=0?q.slice(0,w):q;if(!this._resolved("catalog",w))return false;v=this._catalog[w];for(y=(x=v.depends)?x.length:0;--y>=0;){s||(s={});D=x[y];if(!this._ready(D,s))return false}for(y=(x=v.stylesheets)?x.length:0;--y>=0;){s=x[y];if("string"!==typeof s)s=s.id;if(!this._resolved("stylesheets",
s))return false}for(y=(x=v.scripts)?x.length:0;--y>=0;){s=x[y];if("string"!==typeof s)s=s.id;if(!this._resolved("scripts",s))return false}if(q!==w)if(!this._resolved("modules",q))return false;return true},main:function(q,s){var w=this.require("index","tiki").ready;if(!w)throw"cannot register main because system.ready does not exist";w.main(this,function(){this.async(q).then(this,function(){this.require(q)[s]()})});return this},_loadScript:function(q){var s,w;if("string"!==typeof q){s=q.id;w=q.url}else s=
w=q;q=this._promiseFor("scripts",s);q.isPending&&q.action(function(){var v=document.body,x;v||promise.cancel("no document to append script");x=document.createElement("script");x.setAttribute("src",w);v.appendChild(x)});return q},_loadStylesheet:function(q){var s,w;if("string"!==typeof q){s=q.id;w=q.url}else s=w=q;q=this._promiseFor("stylesheets",s);if(q.isPending){var v=this;q.action(function(x){var y=document.body;y||x.cancel("no document to append stylesheet");x=document.createElement("link");x.setAttribute("rel",
"stylesheet");x.setAttribute("href",w);y.appendChild(x);v.stylesheet(s)})}return q},_loadPackage:function(q,s,w){if(w)if(w[q]){console&&console.warn&&console.warn("detected cyclical reference to "+q+" seen="+o(w).join(", "));return}else w[q]=true;var v=this._catalog?this._catalog[q]:null,x,y,D,K;if(!v)return this;y=(x=v.depends)?x.length:0;for(K=h.create(e("load-package",q));--y>=0;){q=x[y];q!=="tiki"&&K.depends(this._async(q,w))}s.depends(K);K.resolve();y=(x=v.scripts)?x.length:0;D=null;for(w=v.ordered!==
false;--y>=0;){q=this._loadScript(x[y]);s.depends(q);if(w)D&&q.then(D,D.run,D.cancel);else q.run();D=q}D&&w&&K.then(D,D.run,D.cancel);y=(x=v.stylesheets)?x.length:0;for(D=null;--y>=0;){q=this._loadStylesheet(x[y]);s.depends(q);D&&q.then(D,D.run,D.cancel);D=q}D&&K.then(D,D.run,D.cancel)},_promiseFor:function(q,s,w){var v=this._promises,x;if(!v)v=this._promises={};(x=v[q])||(x=v[q]={});if(w===undefined){v=x;w=s}else(v=x[s])||(v=x[s]={});(x=v[w])||(x=v[w]=h.create(e(q,s)));return x},_discoveredStylesheets:false,
discoverStylesheets:function(){this._discoveredStylesheets=true;if("undefined"===typeof document)return this;for(var q=document.getElementsByTagName("link"),s=q?q.length:0,w,v;--s>=0;){w=q[s];if(!(!w||w.rel!=="stylesheet")){(v=w.getAttribute("loadid")||w.getAttribute("LOADID"))&&this.stylesheet(v.toString());(v=w.href)&&this.stylesheet(v.toString())}}return this},_resolved:function(q,s,w){q==="stylesheets"&&!this._discoveredStylesheets&&this.discoverStylesheets();var v=this._promises;if(v)v=v[q];
if(v)v=v[s];if(v&&w)v=v[w];return v?v.isResolved:false},_inspectLoader:function(){var q=[],s,w;q.push("Loader<id="+this.id+">:");if(this.packages.length>0){q.push("  packages: "+this.packages.join(","));q.push("")}if(this.scripts.length>0){q.push("  scripts:");s=this.scripts.length;for(w=0;w<s;w++)q.push("    "+this.scripts[w]);q.push("")}if(this.stylesheets.length>0){q.push("  stylesheets:");s=this.scripts.length;for(w=0;w<s;w++)q.push("    "+this.scripts[w]);q.push("")}if(this.modules.length>0){q.push("  modules: ");
s=this.modules.length;for(w=0;w<s;w++)q.push("    "+this.modules[w]);q.push("")}return q.join("\n")},_inspectModule:function(q){var s=[],w=q.slice(0,q.indexOf(":")),v;if(this._catalog&&!this._catalog[w]){v="tiki/"+w;if(this._catalog[v]){w=v;q="tiki/"+q}}s.push(q+" ("+(this.ready(q)?"READY":"NOT READY")+"):");s.push(this._inspectPackage(w));return s.join("\n")},_inspectPackage:function(q){if(this._catalog&&!this._catalog[q]){var s="tiki/"+q;if(this._catalog[s])q=s}s=[];var w=this._catalog?this._catalog[q]:
null,v,x,y;s.push(q+" ("+(this.ready(q)?"READY":"NOT READY")+"): "+(w?"":"Not in Catalog!"));if(!w)return s.join("\n");v=w.depends?w.depends.length:0;if(v>0){y=[];for(q=0;q<v;q++){x=w.depends[q];y.push(x+" ("+(this.ready(x)?"READY":"NOT READY")+")")}s.push("  depends: "+y.join(", "))}v=w.scripts?w.scripts.length:0;if(v>0){s.push("\n  scripts:");for(q=0;q<v;q++){x=w.scripts[q];if("string"!==typeof x)x=x.id;s.push("    "+x+" ("+(this._resolved("scripts",x)?"READY":"NOT READY")+")")}}v=w.stylesheets?
w.stylesheets.length:0;if(v>0){s.push("\n  stylesheets:");for(q=0;q<v;q++){x=w.stylesheets[q];if("string"!==typeof x)x=x.id;s.push("    "+x+"("+(this._resolved("stylesheets",x)?"READY":"NOT READY")+")")}}return s.join("\n")},inspect:function(q){return arguments.length===0?this._inspectLoader():q.indexOf(":")<0?this._inspectPackage(q):this._inspectModule(q)},toString:function(){return"Loader<id="+this.id+">"}};d.setupDisplayNames(k.prototype,"Loader");k.setup=function(q,s){if(q&&!q.isBootstrap)return q;
s=new k(q?q.id:"default",q?q.queue:null,s);(s.previousLoader=q)&&q.destroy&&q.destroy();return s};b=c.exports=k;b.Loader=k;b.setup=k.setup});
tiki.module("tiki:promise",function(a,b,c,d){function e(j,k,l){j=d.guidFor(j)+":"+j.id+"."+k+"() dep="+j.holds+" status="+h[j._status]+" handlers="+(j._handlers?j._handlers.length:"null");if(l)j+=" pr="+l.toString();console&&console.log&&console.log(j)}b=a("retainable");a("invocation");var f,g=[],h={4097:"PENDING",12289:"BLOCKED_PENDING",12290:"BLOCKED_RESOLVED",16386:"RESOLVED",16388:"CANCELLED"};f=d.extend(b,{init:function(j){this.inPool=false;this.id=j;this._status=4097;this._actionStatus=257;
this.holds=0;this.retain();return this},destroy:function(){this.isDestroyed=false;this.retainCount=1;this.inPool=true;this.target=this.method=this._actions=null;g.push(this);return this},value:null,isPending:true,isResolved:false,isCancelled:false,hasAction:false,_status:4097,_actionStatus:257,resolve:function(j){f.LOG_PROMISES&&e(this,"resolve");switch(this._status){case 4097:this.value=j;this._makeResolved();break;case 12289:this.value=j;this._status=12290;break}return this},_makeResolved:function(){this.isPending=
false;this.isResolved=true;this._status=16386;this._didResolve();this._invoke("__resolved",this.value,true);this.release()},cancel:function(j){f.LOG_PROMISES&&e(this,"cancel");switch(this._status){case 4097:case 12289:this.value=j;this._makeCancelled()}return this},_makeCancelled:function(){this._status=16388;this.isPending=false;this.isCancelled=true;this._didCancel();this._invoke("__cancel",this.value,true);this.release()},update:function(j){f.LOG_PROMISES&&e(this,"update");switch(this._status){case 4097:case 12289:this._invoke("__progress",
j,false);break}return this},then:function(j,k,l,m){var n=typeof j,o=this.values;if(arguments.length<4&&("function"===n||"string"===n)){m=l;l=k;k=j;j=this}n=f.create();switch(this._status){case 16386:if(k)o=k.call(j,this.value,this);n.resolve(o);break;case 16388:if(l)o=l.call(j,this.value,this);n.cancel(o);break;default:n.__resolved=k;n.__cancel=l;n.__progress=m;n.__target=j;if(!this._handlers)this._handlers=[];this._handlers.push(n)}return n},_invoke:function(j,k,l){var m=this._handlers,n=m?m.length:
0,o,r,u;if(n<=0)return this;for(o=0;o<n;o++){r=m[o];u=(u=r[j])?u.call(r.__target,k,this):null;if(l){j==="__cancel"?r.cancel(u):r.resolve(u);r.__resolve=r.__cancel=r.__progress=r.__target=null}}if(l)this._handlers=null},depends:function(j){f.LOG_PROMISES&&e(this,"depends",j);switch(this._status){case 4097:this._status=12289;this.holds=1;if(!this._depends)this._depends={};this._depends[d.guidFor(j)]=j;j.then(this,this._resolveHold,this._cancelHold);break;case 12289:case 12290:this.holds++;this._depends[d.guidFor(j)]=
j;j.then(this,this._resolveHold,this._cancelHold);break}return this},_resolveHold:function(j,k){f.LOG_PROMISES&&e(this,"resolveHold",k);this._depends&&delete this._depends[d.guidFor(k)];switch(this._status){case 12289:if(this.holds<=1){this._status=4097;this.holds=null}else this.holds--;break;case 12290:if(this.holds<=1){this.holds=null;this._makeResolved()}else this.holds--;break}},_cancelHold:function(j,k){f.LOG_PROMISES&&e(this,"cancelHold",k);this._depends&&delete this._depends[d.guidFor(k)];
if(this._status&12288){this.holds=null;this.value=new Error("hold cancelled");this._makeCancelled()}},action:function(j,k){if(this._actionStatus===257){if(arguments.length===1){k=j;j=this}this.hasAction=true;this.actionTarget=j;this.actionMethod=k;this._actionStatus=258}return this},run:function(){if(this._actionStatus===258){this._actionStatus=512;this.actionMethod.call(this.actionTarget,this);this._actionStatus=768}return this},_didResolve:function(){this._actionStatus=768},_didCancel:function(){this._actionStatus=
768},toString:function(){return"Promise<guid="+d.guidFor(this)+" id="+this.id+" status="+h[this._status]+">"}});f.create=function(j){return g.length>0?g.pop().init(j):new f(j)};f.create.displayName="Promise.create";f.LOG_PROMISES=false;d.setupDisplayNames(f.prototype,"Promise");b=c.exports=f;b.Promise=f});
tiki.module("tiki:retainable",function(a,b,c){a={retainCount:1,isDestroyed:false,retain:function(){this.retainCount++;return this},release:function(){--this.retainCount<=0&&this.__destroy();return this},__destroy:function(){if(!this.isDestroyed){this.isDestroyed=true;this.destroy&&this.destroy()}}};b=c.exports=a;b.Retainable=a});
tiki.module("tiki:sandbox",function(a,b,c){var d;d=function(e,f){function g(){var m=arguments.length,n;if(m>0)for(;--m>=0;){if((n=arguments[m])&&j[n]){delete j[n];delete k[n];l.splice(l.indexOf(n),1)}}else{j={};k={};l.length=0}}function h(m,n,o){var r,u,q;if(n){r=m.indexOf(":");if(r>=0)m=m.slice(0,r);m=n+":"+m}m=f.canonical(m,o);if(o=j[m]){o=o.exports;k[m]||(k[m]=o);return o||{}}l.push(m);n={};j[m]=r={id:m,exports:n};o=function(s,w){return h(s,w,m)};o.displayName="Sandbox.require";o.loader=f;o.clear=
g;o.sandbox=this;u=f.load(m);q=h("tiki:index");if(!u)throw"could not load function for "+m;u.call(n,o,n,r,q);n=r.exports;if((o=k[m])&&o!==n)throw"circular require in "+m;return k[m]=n}var j={},k={},l=[];this.id=e;this.modules=l;this.loader=f;g.displayName="Sandbox.clear";this.clear=g;this.require=function(m,n){return h(m,n)};this.require.displayName="Sandbox.require"};d.create=function(e,f){return new d(e,f)};d.create.displayName="Sandbox.create";d.prototype={};b=c.exports=d;b.Sandbox=d});
tiki.module("tiki:system",function(a,b,c,d){if(a.loader){b.env=a.loader.ENV;b.args=a.loader.ARGV}a=function(e){d.console&&d.console.log&&d.console.log(e)};b.print=a;c=function(){return null};b.stdin={read:c,readLine:c};b.stdout=b.stderr={write:a,writeLine:a,print:a};b.platform="tiki";b.global=window;d.unload(function(){b.global={}})});
tiki.module("tiki:timer",function(a,b){function c(h){if(h){delete f[h.timerKey];delete h.timerKey;h.release()}}function d(h,j){return function(){h.invoke();j&&c(h)}}var e=a("invocation"),f={},g={};b.setTimeout=function(h,j,k){var l,m;if(arguments.length>2){m=e.create(k,h,arguments,3);h=d(m,true)}l=setTimeout(h,j);if(m){m.timerKey=l;f[l]=m}return l};b.clearTimeout=function(h){c(f[h]);clearTimeout(h)};b.setInterval=function(h,j,k){var l,m;if(arguments.length>2){m=e.create(k,h,arguments,3);h=d(m,false)}l=
setInterval(h,j);if(m)g[l]=m;return l};b.clearInterval=function(h){var j=g[h];if(j){j.release();delete g[h]}clearInterval(h)}});tiki=tiki.require("tiki:loader").setup(tiki,"undefined"===typeof ENV?null:ENV,"undefined"===typeof ARGV?null:ARGV);tiki.script("tiki:en/f190e4e36f88857b033c419907d4b704109b7815/javascript.js");tiki.stylesheet("sproutcore/desktop:en/ecf7ecda0e8421fbcfcc4ebb8aafd0ff1cc97343/stylesheet.css");tiki.stylesheet("sproutcore/foundation:en/a04970954a917ede9918ca06897bc0e1406986d5/stylesheet.css");
tiki.register("sproutcore/runtime",{packages:{tiki:{scripts:[{url:"/static/tiki/en/f190e4e36f88857b033c419907d4b704109b7815/javascript.js",id:"tiki:en/f190e4e36f88857b033c419907d4b704109b7815/javascript.js"}]}},depends:["tiki"],scripts:[{url:"/static/sproutcore/runtime/en/4e45a795ad83e4f4a267451bf706cc3fc2658096/javascript.js",id:"sproutcore/runtime:en/4e45a795ad83e4f4a267451bf706cc3fc2658096/javascript.js"}]});
tiki.module("sproutcore/runtime:core",function(a,b,c){var d=a("system","default"),e,f;if(d.platform==="tiki"){if("undefined"===typeof console)console=d.console;if("undefined"===typeof sc_require)sc_require=function(){};if("undefined"===typeof sc_resource)sc_resource=function(){}}e=window.SC==undefined?(f={}):window.SC;e.global=function(g,h){d.global[g]=h;return e};e.global.remove=function(g){delete d.global[g];return e};e.global("SC",e);e.mixin=function(){var g=arguments[0]||{},h=1,j=arguments.length,
k,l,m;if(j===1){g=this||{};h=0}for(;h<j;h++)if(k=arguments[h])for(m in k)if(k.hasOwnProperty(m)){l=k[m];if(g!==l)if(l!==undefined)g[m]=l}return g};e.supplement=function(){var g=arguments[0]||{},h=1,j=arguments.length,k;if(j===1){g=this||{};h=0}for(;h<j;h++)if(k=arguments[h])for(var l in k)if(k.hasOwnProperty(l)){var m=g[l],n=k[l];if(g!==n)if(n!==undefined&&m===undefined)g[l]=n}return g};e.extend=e.mixin;e.mixin({T_ERROR:"error",T_OBJECT:"object",T_NULL:"null",T_CLASS:"class",T_HASH:"hash",T_FUNCTION:"function",
T_UNDEFINED:"undefined",T_NUMBER:"number",T_BOOL:"boolean",T_ARRAY:"array",T_STRING:"string",typeOf:function(g){if(g===undefined)return e.T_UNDEFINED;if(g===null)return e.T_NULL;var h=typeof g;if(h=="object")h=g instanceof Array?e.T_ARRAY:g instanceof Function?g.isClass?e.T_CLASS:e.T_FUNCTION:e.Error&&g instanceof e.Error?e.T_ERROR:g.isObject===true?e.T_OBJECT:e.T_HASH;else if(h===e.T_FUNCTION)h=g.isClass?e.T_CLASS:e.T_FUNCTION;return h},none:function(g){return g===null||g===undefined},empty:function(g){return g===
null||g===undefined||g===""},isArray:function(g){if(g&&g.objectAt)return true;var h=g?g.length:null,j=e.typeOf(g);return!(e.none(h)||j===e.T_FUNCTION||j===e.T_STRING||g.setInterval)},makeArray:function(g){return e.isArray(g)?g:e.A(g)},A:function(g){if(e.none(g))return[];if(g.slice instanceof Function)return typeof g==="string"?[g]:g.slice();if(g.toArray)return g.toArray();if(!e.isArray(g))return[g];for(var h=[],j=g.length;--j>=0;)h[j]=g[j];return h},guidKey:"_sc_guid_"+(new Date).getTime(),_nextGUID:0,
_numberGuids:[],_stringGuids:{},_keyCache:{},guidFor:function(g){if(g===undefined)return"(undefined)";if(g===null)return"(null)";if(g===Object)return"(Object)";if(g===Array)return"(Array)";var h=this.guidKey;if(g[h])return g[h];switch(typeof g){case e.T_NUMBER:return this._numberGuids[g]=this._numberGuids[g]||"nu"+g;case e.T_STRING:return this._stringGuids[g]=this._stringGuids[g]||"st"+g;case e.T_BOOL:return g?"(true)":"(false)";default:return e.generateGuid(g)}},keyFor:function(g,h){var j,k=this._keyCache[g];
k||(k=this._keyCache[g]={});(j=k[h])||(j=k[h]=g+"_"+h);return j},generateGuid:function(g){var h="sc"+this._nextGUID++;if(g)g[this.guidKey]=h;return h},hashFor:function(g){return g&&g.hash&&typeof g.hash===e.T_FUNCTION?g.hash():this.guidFor(g)},isEqual:function(g,h){return g===null?h===null:g===undefined?h===undefined:this.hashFor(g)===this.hashFor(h)},compare:function(g,h){if(g===h)return 0;var j=e.typeOf(g),k=e.typeOf(h),l=e.ORDER_DEFINITION_MAPPING;if(!l){var m=e.ORDER_DEFINITION;l=e.ORDER_DEFINITION_MAPPING=
{};var n,o;n=0;for(o=m.length;n<o;++n)l[m[n]]=n;delete e.ORDER_DEFINITION}m=l[j];k=l[k];if(m<k)return-1;if(m>k)return 1;switch(j){case e.T_BOOL:case e.T_NUMBER:if(g<h)return-1;if(g>h)return 1;return 0;case e.T_STRING:j=g.localeCompare(h);if(j<0)return-1;if(j>0)return 1;return 0;case e.T_ARRAY:j=g.length;k=h.length;l=Math.min(j,k);n=m=0;for(o=arguments.callee;m===0&&n<l;){m=o(g[n],h[n]);n++}if(m!==0)return m;if(j<k)return-1;if(j>k)return 1;return 0;case e.T_OBJECT:if(g.constructor.isComparable===true)return g.constructor.compare(g,
h);return 0;default:return 0}},K:function(){return this},EMPTY_ARRAY:[],EMPTY_HASH:{},EMPTY_RANGE:{start:0,length:0},beget:function(g){if(e.none(g))return null;var h=e.K;h.prototype=g;var j=new h;h.prototype=null;if(e.typeOf(g.didBeget)===e.T_FUNCTION)j=g.didBeget(j);return j},copy:function(g){var h=g;if(g&&g.isCopyable)return g.copy();switch(e.typeOf(g)){case e.T_ARRAY:h=g.clone&&e.typeOf(g.clone)===e.T_FUNCTION?g.clone():g.slice();break;case e.T_HASH:case e.T_OBJECT:if(g.clone&&e.typeOf(g.clone)===
e.T_FUNCTION)h=g.clone();else{h={};for(var j in g)h[j]=g[j]}}return h},merge:function(){var g={},h=arguments.length,j;for(j=0;j<h;j++)e.mixin(g,arguments[j]);return g},keys:function(g){var h=[];for(var j in g)h.push(j);return h},inspect:function(g){var h,j=[];for(var k in g){h=g[k];if(h!=="toString"){if(e.typeOf(h)===e.T_FUNCTION)h="function() { ... }";j.push(k+": "+h)}}return"{"+j.join(" , ")+"}"},tupleForPropertyPath:function(g,h){if(e.typeOf(g)===e.T_ARRAY)return g;var j,k=g.indexOf("*");if(k<
0)k=g.lastIndexOf(".");j=k>=0?g.slice(k+1):g;return(g=this.objectForPropertyPath(g,h,k))&&j?[g,j]:null},objectForPropertyPath:function(g,h,j){var k,l,m;if(!h)h=d.global;if(e.typeOf(g)===e.T_STRING){if(j===undefined)j=g.length;for(k=0;h&&k<j;){l=g.indexOf(".",k);if(l<0||l>j)l=j;m=g.slice(k,l);h=h.get?h.get(m):h[m];k=l+1}if(k<j)h=undefined}else{k=0;for(j=g.length;k<j&&h;)if(m=g[k++])h=h.get?h.get(m):h[m];if(k<j)h=undefined}return h},STRINGS:{},stringsFor:function(g,h){e.mixin(e.STRINGS,h);return this}});
e.clone=e.copy;e.$A=e.A;e.didLoad=e.K;e.ORDER_DEFINITION=[e.T_ERROR,e.T_UNDEFINED,e.T_NULL,e.T_BOOL,e.T_NUMBER,e.T_STRING,e.T_ARRAY,e.T_HASH,e.T_OBJECT,e.T_FUNCTION,e.T_CLASS];e.mixin(Function.prototype,{property:function(){this.dependentKeys=e.$A(arguments);var g=e.guidFor(this);this.cacheKey="__cache__"+g;this.lastSetValueKey="__lastValue__"+g;this.isProperty=true;return this},cacheable:function(g){this.isProperty=true;if(!this.dependentKeys)this.dependentKeys=[];this.isCacheable=g===undefined?
true:g;return this},idempotent:function(g){this.isProperty=true;if(!this.dependentKeys)this.dependentKeys=[];this.isVolatile=g===undefined?true:g;return this},observes:function(){for(var g=arguments.length,h=null,j=null;--g>=0;){var k=arguments[g];if(k.indexOf(".")<0&&k.indexOf("*")<0){if(!h)h=this.localPropertyPaths=[];h.push(k)}else{if(!j)j=this.propertyPaths=[];j.push(k)}}return this}});String.prototype.fmt=function(){var g=arguments,h=0;return this.replace(/%@([0-9]+)?/g,function(j,k){k=k?parseInt(k,
0)-1:h++;j=g[k];return(j===null?"(null)":j===undefined?"":j).toString()})};String.prototype.loc=function(){var g=e.STRINGS[this]||this;return g.fmt.apply(g,arguments)};String.prototype.w=function(){var g=[],h=this.split(" "),j=h.length,k,l=0;for(l=0;l<j;++l){k=h[l];k.length!==0&&g.push(k)}return g};c.exports=e;e.SC=e;e.SproutCore=f;e.YES=true;e.NO=false});
tiki.module("sproutcore/runtime:index",function(a,b,c){b=c.exports=a("core");a("mixins/array");a("mixins/comparable");a("mixins/copyable");a("mixins/delegate_support");a("mixins/enumerable");a("mixins/freezable");a("mixins/observable");a("system/binding");a("system/cookie");a("system/enumerator");a("system/error");a("system/index_set");a("system/logger");a("system/object");a("system/range_observer");a("system/run_loop");a("system/selection_set");a("system/set");a("system/sparse_array");b.__globals__=
["SC","SproutCore","YES","NO"]});
tiki.module("sproutcore/runtime:mixins/array",function(a){var b=a("core");a("mixins/observable");a("mixins/enumerable");a("system/range_observer");b.OUT_OF_RANGE_EXCEPTION="Index out of range";b.Array={isSCArray:true,replace:function(){throw"replace() must be implemented to support SC.Array";},objectAt:function(c){if(!(c<0))if(!(c>=this.get("length")))return this.get(c)},"[]":function(c,d){d!==undefined&&this.replace(0,this.get("length"),d);return this}.property(),insertAt:function(c,d){if(c>this.get("length"))throw b.OUT_OF_RANGE_EXCEPTION;
this.replace(c,0,[d]);return this},removeAt:function(c,d){var e=0,f=[];if(typeof c===b.T_NUMBER){if(c<0||c>=this.get("length"))throw b.OUT_OF_RANGE_EXCEPTION;if(d===undefined){this.replace(c,1,f);return this}else c=b.IndexSet.create(c,d)}this.beginPropertyChanges();c.forEachRange(function(g,h){g-=e;e+=h;this.replace(g,h,f)},this);this.endPropertyChanges();return this},removeObject:function(c){for(var d=this.get("length")||0;--d>=0;)this.objectAt(d)==c&&this.removeAt(d);return this},removeObjects:function(c){this.beginPropertyChanges();
c.forEach(function(d){this.removeObject(d)},this);this.endPropertyChanges();return this},pushObject:function(c){this.insertAt(this.get("length"),c);return c},pushObjects:function(c){this.beginPropertyChanges();c.forEach(function(d){this.pushObject(d)},this);this.endPropertyChanges();return this},popObject:function(){var c=this.get("length");if(c!==0){var d=this.objectAt(c-1);this.removeAt(c-1);return d}},shiftObject:function(){if(this.get("length")!==0){var c=this.objectAt(0);this.removeAt(0);return c}},
unshiftObject:function(c){this.insertAt(0,c);return c},unshiftObjects:function(c){this.beginPropertyChanges();c.forEach(function(d){this.unshiftObject(d)},this);this.endPropertyChanges();return this},isEqual:function(c){if(!c)return false;if(c==this)return true;var d=c.get("length");if(d!=this.get("length"))return false;for(;--d>=0;)if(!b.isEqual(c.objectAt(d),this.objectAt(d)))return false;return true},compact:function(){return this.without(null)},without:function(c){if(this.indexOf(c)<0)return this;
var d=[];this.forEach(function(e){if(e!==c)d[d.length]=e});return d},uniq:function(){var c=[];this.forEach(function(d){if(c.indexOf(d)<0)c[c.length]=d});return c},rangeObserverClass:b.RangeObserver,addRangeObserver:function(c,d,e,f){var g=this._array_rangeObservers;if(!g)g=this._array_rangeObservers=b.CoreSet.create();if(this._array_oldLength===undefined)this._array_oldLength=this.get("length");c=this.rangeObserverClass.create(this,c,d,e,f,false);g.add(c);if(!this._array_isNotifyingRangeObservers){this._array_isNotifyingRangeObservers=
true;this.addObserver("[]",this,this._array_notifyRangeObservers)}return c},updateRangeObserver:function(c,d){return c.update(this,d)},removeRangeObserver:function(c){var d=c.destroy(this),e=this._array_rangeObservers;e&&e.remove(c);return d},enumerableContentDidChange:function(c,d,e){var f=this._array_rangeObservers,g=this._array_oldLength;this.beginPropertyChanges();this.notifyPropertyChange("length");if(f&&f.length>0){if(g===undefined)g=0;this._array_oldLength=f=this.get("length");if(c===undefined)c=
0;if(e===undefined)e=f-g;if(e!==0||d===undefined){d=f-c;if(e<0)d-=e}else d=d;e=this._array_rangeChanges;if(!e)e=this._array_rangeChanges=b.IndexSet.create();e.add(c,d)}this.notifyPropertyChange("[]");this.endPropertyChanges();return this},_array_notifyRangeObservers:function(){var c=this._array_rangeObservers,d=this._array_rangeChanges,e=c?c.length:0,f;if(e>0&&d&&d.length>0){for(f=0;f<e;f++)c[f].rangeDidChange(d);d.clear()}}};b.mixin(Array.prototype,b.Array);b.Array=b.mixin({},b.Enumerable,b.Array);
b.Array.slice=function(c,d){var e=[],f=this.get("length");if(b.none(c))c=0;if(b.none(d)||d>f)d=f;for(;c<d;)e[e.length]=this.objectAt(c++);return e};b.Array.indexOf=function(c,d){var e=this.get("length");d=d===undefined?0:d<0?Math.ceil(d):Math.floor(d);if(d<0)d+=e;for(d=d;d<e;d++)if(this.objectAt(d)===c)return d;return-1};if(!Array.prototype.indexOf)Array.prototype.indexOf=b.Array.indexOf;b.Array.lastIndexOf=function(c,d){var e=this.get("length");d=d===undefined?e-1:d<0?Math.ceil(d):Math.floor(d);
if(d<0)d+=e;for(d=d;d>=0;d--)if(this.objectAt(d)===c)return d;return-1};if(!Array.prototype.lastIndexOf)Array.prototype.lastIndexOf=b.Array.lastIndexOf;(function(){b.mixin(Array.prototype,{replace:function(d,e,f){if(this.isFrozen)throw b.FROZEN_ERROR;!f||f.length===0?this.splice(d,e):this.splice.apply(this,[d,e].concat(f));f=f?f.get?f.get("length"):f.length:0;this.enumerableContentDidChange(d,e,f-e);return this},unknownProperty:function(d,e){var f=this.reducedProperty(d,e);if(e!==undefined&&f===undefined)f=
this[d]=e;return f}});var c=Array.prototype.indexOf;if(!c||c===b.Array.indexOf)Array.prototype.indexOf=function(d,e){var f=this.length;e=e===undefined?0:e<0?Math.ceil(e):Math.floor(e);if(e<0)e+=f;for(e=e;e<f;e++)if(this[e]===d)return e;return-1};c=Array.prototype.lastIndexOf;if(!c||c===b.Array.lastIndexOf)Array.prototype.lastIndexOf=function(d,e){var f=this.length;e=e===undefined?f-1:e<0?Math.ceil(e):Math.floor(e);if(e<0)e+=f;for(e=e;e>=0;e--)if(this[e]===d)return e;return-1}})()});
tiki.module("sproutcore/runtime:mixins/comparable",function(a){a("core").Comparable={isComparable:true,compare:function(){throw"%@.compare() is not implemented".fmt(this.toString());}}});
tiki.module("sproutcore/runtime:mixins/copyable",function(a){a=a("core");a.Copyable={isCopyable:true,copy:function(){throw"%@.copy() is not implemented";},frozenCopy:function(){var b=this.get?this.get("isFrozen"):this.isFrozen;if(b===true)return this;else if(b===undefined)throw"%@ does not support freezing".fmt(this);else return this.copy().freeze()}};a.mixin(Array.prototype,a.Copyable);Array.prototype.copy=Array.prototype.slice});
tiki.module("sproutcore/runtime:mixins/delegate_support",function(a){var b=a("core");b.DelegateSupport={delegateFor:function(c){for(var d=1,e=arguments.length,f;d<e;){if((f=arguments[d])&&f[c]!==undefined)return f;d++}return this[c]!==undefined?this:null},invokeDelegateMethod:function(c,d,e){e=b.A(arguments);e=e.slice(2,e.length);if(!c||!c[d])c=this;var f=c[d];return f?f.apply(c,e):null},getDelegateProperty:function(c){for(var d=1,e=arguments.length,f;d<e;)if((f=arguments[d++])&&f[c]!==undefined)return f.get?
f.get(c):f[c];return this[c]!==undefined?this.get(c):undefined}}});
tiki.module("sproutcore/runtime:mixins/enumerable",function(a){var b=a("core");a("system/enumerator");b.Enumerable={isEnumerable:true,nextObject:function(c){return this.objectAt?this.objectAt(c):this[c]},firstObject:function(){if(this.get("length")!==0){if(this.objectAt)return this.objectAt(0);var c=b.Enumerator._popContext(),d;d=this.nextObject(0,null,c);b.Enumerator._pushContext(c);return d}}.property(),enumerator:function(){return b.Enumerator.create(this)},forEach:function(c,d){if(typeof c!==
"function")throw new TypeError;var e=this.get?this.get("length"):this.length;if(d===undefined)d=null;for(var f=null,g=b.Enumerator._popContext(),h=0;h<e;h++){f=this.nextObject(h,f,g);c.call(d,f,h,this);f=f}b.Enumerator._pushContext(g);return this},getEach:function(c){return this.map(function(d){return d?d.get?d.get(c):d[c]:null},this)},setEach:function(c,d){this.forEach(function(e){if(e)if(e.set)e.set(c,d);else e[c]=d},this);return this},map:function(c,d){if(typeof c!=="function")throw new TypeError;
var e=this.get?this.get("length"):this.length;if(d===undefined)d=null;for(var f=[],g=null,h=b.Enumerator._popContext(),j=0;j<e;j++){g=this.nextObject(j,g,h);f[j]=c.call(d,g,j,this);g=g}b.Enumerator._pushContext(h);return f},mapProperty:function(c){return this.map(function(d){return d?d.get?d.get(c):d[c]:null})},filter:function(c,d){if(typeof c!=="function")throw new TypeError;var e=this.get?this.get("length"):this.length;if(d===undefined)d=null;for(var f=[],g=null,h=b.Enumerator._popContext(),j=0;j<
e;j++){g=this.nextObject(j,g,h);c.call(d,g,j,this)&&f.push(g);g=g}b.Enumerator._pushContext(h);return f},sortProperty:function(c){var d=typeof c===b.T_STRING?arguments:c,e=d.length,f;if(this instanceof Array)f=this;else{f=[];this.forEach(function(g){f.push(g)})}if(!f)return[];return f.sort(function(g,h){var j,k,l;for(j=l=0;l===0&&j<e;j++){k=d[j];l=g?g.get?g.get(k):g[k]:null;k=h?h.get?h.get(k):h[k]:null;l=b.compare(l,k)}return l})},filterProperty:function(c,d){for(var e=this.get?this.get("length"):
this.length,f=[],g=null,h=b.Enumerator._popContext(),j=0;j<e;j++){var k=(g=this.nextObject(j,g,h))?g.get?g.get(c):g[c]:null;(d===undefined?!!k:b.isEqual(k,d))&&f.push(g);g=g}b.Enumerator._pushContext(h);return f},find:function(c,d){if(typeof c!=="function")throw new TypeError;var e=this.get?this.get("length"):this.length;if(d===undefined)d=null;for(var f=null,g=false,h=null,j=b.Enumerator._popContext(),k=0;k<e&&!g;k++){f=this.nextObject(k,f,j);if(g=c.call(d,f,k,this))h=f;f=f}b.Enumerator._pushContext(j);
return h},findProperty:function(c,d){for(var e=this.get?this.get("length"):this.length,f=false,g=null,h=null,j=b.Enumerator._popContext(),k=0;k<e&&!f;k++){f=(h=this.nextObject(k,h,j))?h.get?h.get(c):h[c]:null;if(f=d===undefined?!!f:b.isEqual(f,d))g=h;h=h}b.Enumerator._pushContext(j);return g},every:function(c,d){if(typeof c!=="function")throw new TypeError;var e=this.get?this.get("length"):this.length;if(d===undefined)d=null;for(var f=true,g=null,h=b.Enumerator._popContext(),j=0;f&&j<e;j++){g=this.nextObject(j,
g,h);c.call(d,g,j,this)||(f=false);g=g}b.Enumerator._pushContext(h);return f},everyProperty:function(c,d){for(var e=this.get?this.get("length"):this.length,f=true,g=null,h=b.Enumerator._popContext(),j=0;f&&j<e;j++){f=(g=this.nextObject(j,g,h))?g.get?g.get(c):g[c]:null;f=d===undefined?!!f:b.isEqual(f,d);g=g}b.Enumerator._pushContext(h);return f},some:function(c,d){if(typeof c!=="function")throw new TypeError;var e=this.get?this.get("length"):this.length;if(d===undefined)d=null;for(var f=false,g=null,
h=b.Enumerator._popContext(),j=0;!f&&j<e;j++){g=this.nextObject(j,g,h);if(c.call(d,g,j,this))f=true;g=g}b.Enumerator._pushContext(h);return f},someProperty:function(c,d){for(var e=this.get?this.get("length"):this.length,f=false,g=null,h=b.Enumerator._popContext(),j=0;!f&&j<e;j++){f=(g=this.nextObject(j,g,h))?g.get?g.get(c):g[c]:null;f=d===undefined?!!f:b.isEqual(f,d);g=g}b.Enumerator._pushContext(h);return f},reduce:function(c,d,e){if(typeof c!=="function")throw new TypeError;var f=this.get?this.get("length"):
this.length;if(f===0&&d===undefined)throw new TypeError;d=d;for(var g=null,h=b.Enumerator._popContext(),j=0;j<f;j++){g=this.nextObject(j,g,h);if(g!==null)d=d===undefined?g:c.call(null,d,g,j,this,e);g=g}b.Enumerator._pushContext(h);if(d===undefined)throw new TypeError;return d},invoke:function(c){var d=this.get?this.get("length"):this.length;if(d<=0)return[];var e,f=[],g=arguments.length;if(g>1)for(e=1;e<g;e++)f.push(arguments[e]);g=[];var h=null,j=b.Enumerator._popContext();for(e=0;e<d;e++){var k=
(h=this.nextObject(e,h,j))?h[c]:null;if(k)g[e]=k.apply(h,f);h=h}b.Enumerator._pushContext(j);return g},invokeWhile:function(c,d){var e=this.get?this.get("length"):this.length;if(e<=0)return null;var f,g=[],h=arguments.length;if(h>2)for(f=2;f<h;f++)g.push(arguments[f]);h=c;var j=null,k=b.Enumerator._popContext();for(f=0;h===c&&f<e;f++){var l=(j=this.nextObject(f,j,k))?j[d]:null;if(l)h=l.apply(j,g);j=j}b.Enumerator._pushContext(k);return h},toArray:function(){var c=[];this.forEach(function(d){c.push(d)},
this);return c},groupBy:function(c){for(var d=this.get?this.get("length"):this.length,e=[],f=null,g=b.Enumerator._popContext(),h=[],j=[],k=0;k<d;k++){var l=(f=this.nextObject(k,f,g))?f.get?f.get(c):f[c]:null;if(b.none(h[l])){h[l]=[];j.push(l)}h[l].push(f);f=f}b.Enumerator._pushContext(g);k=0;for(c=j.length;k<c;k++)e.push(h[j[k]]);return e}};b._buildReducerFor=function(c,d){return function(e,f){var g=this[c];return b.typeOf(g)!==b.T_FUNCTION?this.unknownProperty?this.unknownProperty(e,f):null:b.Enumerable.reduce.call(this,
g,null,d)}.property("[]")};b.Reducers={"[]":function(){return this}.property(),enumerableContentDidChange:function(){this.notifyPropertyChange("[]");return this},reducedProperty:function(c,d,e){if(!(!c||c.charAt(0)!=="@")){d=c.match(/^@([^(]*)(\(([^)]*)\))?$/);if(!(!d||d.length<2)){var f=d[1];d=d[3];f="reduce"+f.slice(0,1).toUpperCase()+f.slice(1);var g=this[f];if(b.typeOf(g)===b.T_FUNCTION){if(e===false)return b.Enumerable.reduce.call(this,g,null,d);f=b._buildReducerFor(f,d);if(e=this.constructor.prototype){e[c]=
f;f=e._properties||[];f.push(c);e._properties=f;this.registerDependentKey(c,"[]")}return b.Enumerable.reduce.call(this,g,null,d)}}}},reduceMax:function(c,d,e,f,g){if(g&&d)d=d.get?d.get(g):d[g];if(c===null)return d;return d>c?d:c},reduceMaxObject:function(c,d,e,f,g){e=c;f=d;if(g){if(d)f=d.get?d.get(g):d[g];if(c)e=c.get?c.get(g):c[g]}if(e===null)return d;return f>e?d:c},reduceMin:function(c,d,e,f,g){if(g&&d)d=d.get?d.get(g):d[g];if(c===null)return d;return d<c?d:c},reduceMinObject:function(c,d,e,f,
g){e=c;f=d;if(g){if(d)f=d.get?d.get(g):d[g];if(c)e=c.get?c.get(g):c[g]}if(e===null)return d;return f<e?d:c},reduceAverage:function(c,d,e,f,g){if(g&&d)d=d.get?d.get(g):d[g];c=(c||0)+d;f=f.get?f.get("length"):f.length;if(e>=f-1)c/=f;return c},reduceSum:function(c,d,e,f,g){if(g&&d)d=d.get?d.get(g):d[g];return c===null?d:c+d}};b.mixin(b.Enumerable,b.Reducers);b.mixin(Array.prototype,b.Reducers);Array.prototype.isEnumerable=true;(function(){var c={nextObject:b.Enumerable.nextObject,enumerator:b.Enumerable.enumerator,
firstObject:b.Enumerable.firstObject,sortProperty:b.Enumerable.sortProperty,mapProperty:function(f){for(var g=this.length,h=[],j=0;j<g;j++){var k=this[j];h[j]=k?k.get?k.get(f):k[f]:null}return h},filterProperty:function(f,g){for(var h=this.length,j=[],k=0;k<h;k++){var l=this[k],m=l?l.get?l.get(f):l[f]:null;(g===undefined?!!m:b.isEqual(m,g))&&j.push(l)}return j},groupBy:function(f){for(var g=this.length,h=[],j=[],k=[],l=0;l<g;l++){var m=this[l],n=m?m.get?m.get(f):m[f]:null;if(b.none(j[n])){j[n]=[];
k.push(n)}j[n].push(m)}l=0;for(f=k.length;l<f;l++)h.push(j[k[l]]);return h},find:function(f,g){if(typeof f!=="function")throw new TypeError;var h=this.length;if(g===undefined)g=null;for(var j,k=null,l=false,m=0;m<h&&!l;m++){j=this[m];if(l=f.call(g,j,m,this))k=j}return k},findProperty:function(f,g){var h=this.length,j,k;k=false;for(var l=null,m=0;m<h&&!k;m++){k=(j=this[m])?j.get?j.get(f):j[f]:null;if(k=g===undefined?!!k:b.isEqual(k,g))l=j}return l},everyProperty:function(f,g){for(var h=this.length,
j=true,k=0;j&&k<h;k++){j=(j=this[k])?j.get?j.get(f):j[f]:null;j=g===undefined?!!j:b.isEqual(j,g)}return j},someProperty:function(f,g){for(var h=this.length,j=false,k=0;!j&&k<h;k++){j=(j=this[k])?j.get?j.get(f):j[f]:null;j=g===undefined?!!j:b.isEqual(j,g)}return j},invoke:function(f){var g=this.length;if(g<=0)return[];var h,j=[],k=arguments.length;if(k>1)for(h=1;h<k;h++)j.push(arguments[h]);k=[];for(h=0;h<g;h++){var l=this[h],m=l?l[f]:null;if(m)k[h]=m.apply(l,j)}return k},invokeWhile:function(f,g){var h=
this.length;if(h<=0)return null;var j,k=[],l=arguments.length;if(l>2)for(j=2;j<l;j++)k.push(arguments[j]);l=f;for(j=0;l===f&&j<h;j++){var m=this[j],n=m?m[g]:null;if(n)l=n.apply(m,k)}return l},toArray:function(){var f=this.length;if(f<=0)return[];for(var g=[],h=0;h<f;h++)g.push(this[h]);return g},getEach:function(f){for(var g=[],h=this.length,j=0;j<h;j++){var k=this[j];g[j]=k?k.get?k.get(f):k[f]:null}return g},setEach:function(f,g){for(var h=this.length,j=0;j<h;j++){var k=this[j];if(k)if(k.set)k.set(f,
g);else k[f]=g}return this}},d={forEach:function(f,g){if(typeof f!=="function")throw new TypeError;var h=this.length;if(g===undefined)g=null;for(var j=0;j<h;j++)f.call(g,this[j],j,this);return this},map:function(f,g){if(typeof f!=="function")throw new TypeError;var h=this.length;if(g===undefined)g=null;for(var j=[],k=0;k<h;k++)j[k]=f.call(g,this[k],k,this);return j},filter:function(f,g){if(typeof f!=="function")throw new TypeError;var h=this.length;if(g===undefined)g=null;for(var j=[],k=0;k<h;k++){var l=
this[k];f.call(g,l,k,this)&&j.push(l)}return j},every:function(f,g){if(typeof f!=="function")throw new TypeError;var h=this.length;if(g===undefined)g=null;for(var j=true,k=0;j&&k<h;k++)f.call(g,this[k],k,this)||(j=false);return j},some:function(f,g){if(typeof f!=="function")throw new TypeError;var h=this.length;if(g===undefined)g=null;for(var j=false,k=0;!j&&k<h;k++)if(f.call(g,this[k],k,this))j=true;return j},reduce:function(f,g,h){if(typeof f!=="function")throw new TypeError;var j=this.length;if(j===
0&&g===undefined)throw new TypeError;g=g;for(var k=0;k<j;k++){var l=this[k];if(l!==null)g=g===undefined?l:f.call(null,g,l,k,this,h)}if(g===undefined)throw new TypeError;return g}};for(var e in d)if(d.hasOwnProperty(e))if(!Array.prototype[e]||typeof Prototype==="object"&&Prototype.Version.match(/^1\.6/))Array.prototype[e]=d[e];b.mixin(Array.prototype,c)})()});
tiki.module("sproutcore/runtime:mixins/freezable",function(a){a=a("core");a.FROZEN_ERROR=new Error("Cannot modify a frozen object");a.Freezable={isFreezable:true,isFrozen:false,freeze:function(){if(this.set)this.set("isFrozen",true);else this.isFrozen=true;return this}};a.mixin(Array.prototype,a.Freezable)});
tiki.module("sproutcore/runtime:mixins/observable",function(a){var b=a("core");a("private/observer_set");a("private/chain_observer");b.LOG_OBSERVERS=false;b.Observable={isObservable:true,automaticallyNotifiesObserversFor:function(){return true},get:function(c){var d=this[c],e;if(d===undefined)return this.unknownProperty(c);else if(d&&d.isProperty)if(d.isCacheable){e=this._kvo_cache;if(!e)e=this._kvo_cache={};return e[d.cacheKey]!==undefined?e[d.cacheKey]:(e[d.cacheKey]=d.call(this,c))}else return d.call(this,
c);else return d},set:function(c,d){var e=this[c],f=this.automaticallyNotifiesObserversFor(c),g=d,h,j,k,l;if(!f&&this._kvo_cacheable&&(j=this._kvo_cache)){h=this._kvo_cachedep;if(!h||(h=h[c])===undefined)h=this._kvo_computeCachedDependentsFor(c);if(h)for(k=h.length;--k>=0;){l=h[k];j[l.cacheKey]=j[l.lastSetValueKey]=undefined}}if(e&&e.isProperty){j=this._kvo_cache;if(e.isVolatile||!j||j[e.lastSetValueKey]!==d){if(!j)j=this._kvo_cache={};j[e.lastSetValueKey]=d;f&&this.propertyWillChange(c);g=e.call(this,
c,d);if(e.isCacheable)j[e.cacheKey]=g;f&&this.propertyDidChange(c,g,true)}}else if(e===undefined){f&&this.propertyWillChange(c);this.unknownProperty(c,d);f&&this.propertyDidChange(c,g)}else if(this[c]!==d){f&&this.propertyWillChange(c);g=this[c]=d;f&&this.propertyDidChange(c,g)}return this},unknownProperty:function(c,d){if(d!==undefined)this[c]=d;return d},beginPropertyChanges:function(){this._kvo_changeLevel=(this._kvo_changeLevel||0)+1;return this},endPropertyChanges:function(){this._kvo_changeLevel=
(this._kvo_changeLevel||1)-1;var c=this._kvo_changes;this._kvo_changeLevel<=0&&c&&c.length>0&&!b.Observers.isObservingSuspended&&this._notifyPropertyObservers();return this},propertyWillChange:function(){return this},propertyDidChange:function(c,d,e){this._kvo_revision=(this._kvo_revision||0)+1;var f=this._kvo_changeLevel||0,g,h,j;d=b.LOG_OBSERVERS&&this.LOG_OBSERVING!==false;if(j=this._kvo_cache){if(!e)if((e=this[c])&&e.isProperty)j[e.cacheKey]=j[e.lastSetValueKey]=undefined;if(this._kvo_cacheable){e=
this._kvo_cachedep;if(!e||(e=e[c])===undefined)e=this._kvo_computeCachedDependentsFor(c);if(e)for(g=e.length;--g>=0;){h=e[g];j[h.cacheKey]=j[h.lastSetValueKey]=undefined}}}j=b.Observers.isObservingSuspended;if(f>0||j){f=this._kvo_changes;if(!f)f=this._kvo_changes=b.CoreSet.create();f.add(c);if(j){d&&b.Logger.log("%@%@: will not notify observers because observing is suspended".fmt(b.KVO_SPACES,this));b.Observers.objectHasPendingChanges(this)}}else this._notifyPropertyObservers(c);return this},registerDependentKey:function(c,
d){var e=this._kvo_dependents,f,g,h,j,k;if(b.typeOf(d)===b.T_ARRAY){f=d;h=0}else{f=arguments;h=1}g=f.length;if(!e)this._kvo_dependents=e={};for(;--g>=h;){j=f[g];(k=e[j])||(k=e[j]=[]);k.push(c)}},_kvo_addCachedDependents:function(c,d,e,f){for(var g=d.length,h,j,k;--g>=0;){j=d[g];f.add(j);if((h=this[j])&&h instanceof Function&&h.isProperty){h.isCacheable&&c.push(h);if((k=e[j])&&k.length>0)this._kvo_addCachedDependents(c,k,e,f)}}},_kvo_computeCachedDependentsFor:function(c){var d=this._kvo_cachedep,
e=this._kvo_dependents,f=e?e[c]:null,g,h;if(!d)d=this._kvo_cachedep={};if(!f||f.length===0)return d[c]=null;g=d[c]=[];h=b._TMP_SEEN_SET=b._TMP_SEEN_SET||b.CoreSet.create();h.add(c);this._kvo_addCachedDependents(g,f,e,h);h.clear();if(g.length===0)g=d[c]=null;return g},_kvo_for:function(c,d){var e=this[c];if(!this._kvo_cloned)this._kvo_cloned={};if(e){if(!this._kvo_cloned[c]){e=this[c]=e.copy();this._kvo_cloned[c]=true}}else{e=this[c]=d===undefined?[]:d.create();this._kvo_cloned[c]=true}return e},addObserver:function(c,
d,e,f){var g;if(e===undefined){e=d;d=this}d||(d=this);if(b.typeOf(e)===b.T_STRING)e=d[e];if(!e)throw"You must pass a method to addObserver()";c=c.toString();if(c.indexOf(".")>=0){f=b._ChainObserver.createChain(this,c,d,e,f);f.masterTarget=d;f.masterMethod=e;this._kvo_for(b.keyFor("_kvo_chains",c)).push(f)}else{this[c]===undefined&&c.indexOf("@")===0&&this.get(c);if(d===this)d=null;g=b.keyFor("_kvo_observers",c);this._kvo_for(g,b.ObserverSet).add(d,e,f);this._kvo_for("_kvo_observed_keys",b.CoreSet).add(c)}this.didAddObserver&&
this.didAddObserver(c,d,e);return this},removeObserver:function(c,d,e){var f,g,h;if(e===undefined){e=d;d=this}d||(d=this);if(b.typeOf(e)===b.T_STRING)e=d[e];if(!e)throw"You must pass a method to removeObserver()";c=c.toString();if(c.indexOf(".")>=0){f=b.keyFor("_kvo_chains",c);if(this[f]){f=this._kvo_for(f);for(h=f.length;--h>=0;)if((g=f[h])&&g.masterTarget===d&&g.masterMethod===e)f[h]=g.destroyChain()}}else{if(d===this)d=null;f=b.keyFor("_kvo_observers",c);if(this[f]){f=this._kvo_for(f);f.remove(d,
e);f.targets<=0&&this._kvo_for("_kvo_observed_keys",b.CoreSet).remove(c)}}this.didRemoveObserver&&this.didRemoveObserver(c,d,e);return this},hasObserverFor:function(c){b.Observers.flush(this);var d=this[b.keyFor("_kvo_observers",c)];if((c=this[b.keyFor("_kvo_local",c)])&&c.length>0)return true;if(d&&d.getMembers().length>0)return true;return false},initObservable:function(){if(!this._observableInited){this._observableInited=true;var c,d,e,f,g,h,j,k,l,m;if(d=this._observers){f=d.length;for(c=0;c<f;c++){e=
d[c];e=this[e];h=(g=e.propertyPaths)?g.length:0;for(j=0;j<h;j++){k=g[j];l=k.indexOf(".");if(l<0)this.addObserver(k,this,e);else if(k.indexOf("*")===0)this.addObserver(k.slice(1),this,e);else{m=null;if(l===0){m=this;k=k.slice(1)}else if(l===4&&k.slice(0,5)==="this."){m=this;k=k.slice(5)}else if(l<0&&k.length===4&&k==="this"){m=this;k=""}b.Observers.addObserver(k,this,e,m)}}}}this.bindings=[];if(d=this._bindings){c=0;for(h=d.length;c<h;c++){e=d[c];f=this[e];g=e.slice(0,-7);this[e]=this.bind(g,f)}}if(d=
this._properties){c=0;for(h=d.length;c<h;c++){e=d[c];if(f=this[e]){if(f.isCacheable)this._kvo_cacheable=true;f.dependentKeys&&f.dependentKeys.length>0&&this.registerDependentKey(e,f.dependentKeys)}}}}},observersForKey:function(c){return this._kvo_for("_kvo_observers",c).getMembers()||[]},_notifyPropertyObservers:function(c){this._observableInited||this.initObservable();b.Observers.flush(this);var d=b.LOG_OBSERVERS&&this.LOG_OBSERVING!==false,e,f,g,h,j,k,l,m,n,o,r,u;if(d){u=b.KVO_SPACES=(b.KVO_SPACES||
"")+"  ";b.Logger.log('%@%@: notifying observers after change to key "%@"'.fmt(u,this,c))}g=this["_kvo_observers_*"];for(this._kvo_changeLevel=(this._kvo_changeLevel||0)+1;(f=this._kvo_changes)&&f.length>0||c;){k=++this.propertyRevision;f||(f=b.CoreSet.create());this._kvo_changes=null;if(c==="*"){f.add("*");f.addEach(this._kvo_for("_kvo_observed_keys",b.CoreSet))}else c&&f.add(c);if(e=this._kvo_dependents)for(h=0;h<f.length;h++){c=f[h];if((j=e[c])&&(o=j.length)){d&&b.Logger.log("%@...including dependent keys for %@: %@".fmt(u,
c,j));l=this._kvo_cache;if(!l)l=this._kvo_cache={};for(;--o>=0;){f.add(c=j[o]);if(c=this[c]){this[c.cacheKey]=undefined;l[c.cacheKey]=l[c.lastSetValueKey]=undefined}}}}for(;f.length>0;){c=f.pop();if(e=this[b.keyFor("_kvo_observers",c)]){e=e.getMembers();h=e.length;for(l=0;l<h;l++){j=e[l];if(j[3]!==k){m=j[0]||this;n=j[1];r=j[2];j[3]=k;d&&b.Logger.log('%@...firing observer on %@ for key "%@"'.fmt(u,m,c));r!==undefined?n.call(m,this,c,null,r,k):n.call(m,this,c,null,k)}}}if(e=this[b.keyFor("_kvo_local",
c)]){h=e.length;for(l=0;l<h;l++){j=e[l];if(n=this[j]){d&&b.Logger.log('%@...firing local observer %@.%@ for key "%@"'.fmt(u,this,j,c));n.call(this,this,c,null,k)}}}if(g&&c!=="*"){e=g.getMembers();h=e.length;for(l=0;l<h;l++){j=e[l];m=j[0]||this;n=j[1];r=j[2];d&&b.Logger.log('%@...firing * observer on %@ for key "%@"'.fmt(u,m,c));r!==undefined?n.call(m,this,c,null,r,k):n.call(m,this,c,null,k)}}if(this.propertyObserver){d&&b.Logger.log('%@...firing %@.propertyObserver for key "%@"'.fmt(u,this,c));this.propertyObserver(this,
c,null,k)}}f&&f.destroy();c=null}this._kvo_changeLevel=(this._kvo_changeLevel||1)-1;if(d)b.KVO_SPACES=u.slice(0,-2);return true},bind:function(c,d,e){if(e!==undefined)d=[d,e];e=b.typeOf(d);if(e===b.T_STRING||e===b.T_ARRAY){e=this[c+"BindingDefault"]||b.Binding;e=e.beget().from(d)}else e=d;e=e.to(c,this).connect();this.bindings.push(e);return e},didChangeFor:function(c){var d,e,f,g,h,j,k,l,m;c=b.hashFor(c);d=this._kvo_didChange_valueCache;if(!d)d=this._kvo_didChange_valueCache={};e=this._kvo_didChange_revisionCache;
if(!e)e=this._kvo_didChange_revisionCache={};f=d[c]||{};g=e[c]||{};h=false;j=this._kvo_revision||0;for(k=arguments.length;--k>=1;){l=arguments[k];if(g[l]!=j){m=this.get(l);if(f[l]!==m){h=true;f[l]=m}}g[l]=j}d[c]=f;e[c]=g;return h},setIfChanged:function(c,d){return this.get(c)!==d?this.set(c,d):this},getPath:function(c){c=b.tupleForPropertyPath(c,this);if(!(c===null||c[0]===null))return c[0].get(c[1])},setPath:function(c,d){if(c.indexOf(".")>=0){c=b.tupleForPropertyPath(c,this);if(!c||!c[0])return null;
c[0].set(c[1],d)}else this.set(c,d);return this},setPathIfChanged:function(c,d){if(c.indexOf(".")>=0){c=b.tupleForPropertyPath(c,this);if(!c||!c[0])return null;c[0].get(c[1])!==d&&c[0].set(c[1],d)}else this.setIfChanged(c,d);return this},getEach:function(){var c=b.A(arguments),d=[],e,f;e=0;for(f=c.length;e<f;e++)d[d.length]=this.getPath(c[e]);return d},incrementProperty:function(c,d){d||(d=1);this.set(c,(this.get(c)||0)+d);return this.get(c)},decrementProperty:function(c,d){d||(d=1);this.set(c,(this.get(c)||
0)-d);return this.get(c)},toggleProperty:function(c,d,e){if(d===undefined)d=true;if(e===undefined)e=false;d=this.get(c)==d?e:d;this.set(c,d);return this.get(c)},notifyPropertyChange:function(c,d){this.propertyWillChange(c);this.propertyDidChange(c,d);return this},allPropertiesDidChange:function(){this._kvo_cache=null;this._notifyPropertyObservers("*");return this},addProbe:function(c){this.addObserver(c,b.logChange)},removeProbe:function(c){this.removeObserver(c,b.logChange)},logProperty:function(){var c=
b.$A(arguments),d,e,f;f=0;for(e=c.length;f<e;f++){d=c[f];b.Logger.log("%@:%@: ".fmt(b.guidFor(this),d),this.get(d))}},propertyRevision:1};b.logChange=function(c,d){b.Logger.log("CHANGE: %@[%@] => %@".fmt(c,d,c.get(d)))};b.mixin(b,{get:function(c,d){if(c){if(d===undefined)return this[c];if(c.get)return c.get(d);return c[d]}}});b.mixin(Array.prototype,b.Observable);a("system/binding");a("private/observer_queue")});
tiki.module("sproutcore/runtime:private/chain_observer",function(a){var b=a("core");b._ChainObserver=function(c){this.property=c};b._ChainObserver.createChain=function(c,d,e,f,g){d=d.split(".");for(var h=new b._ChainObserver(d[0]),j=h,k=d.length,l=1;l<k;l++)j=j.next=new b._ChainObserver(d[l]);h.objectDidChange(c);j.target=e;j.method=f;j.context=g;return h};b._ChainObserver.prototype={isChainObserver:true,object:null,property:null,next:null,target:null,method:null,objectDidChange:function(c){if(c!==
this.object){this.object&&this.object.removeObserver&&this.object.removeObserver(this.property,this,this.propertyDidChange);(this.object=c)&&this.object.addObserver&&this.object.addObserver(this.property,this,this.propertyDidChange);this.propertyDidChange()}},propertyDidChange:function(){var c=this.object,d=this.property,e=c&&c.get?c.get(d):null;this.next&&this.next.objectDidChange(e);var f=this.target,g=this.method,h=this.context;if(f&&g){var j=c?c.propertyRevision:null;h?g.call(f,c,d,e,h,j):g.call(f,
c,d,e,j)}},destroyChain:function(){var c=this.object;c&&c.removeObserver&&c.removeObserver(this.property,this,this.propertyDidChange);this.next&&this.next.destroyChain();return this.next=this.target=this.method=this.object=this.context=null}}});
tiki.module("sproutcore/runtime:private/observer_queue",function(a){var b=a("core");a("system/set");b.Observers={queue:[],addObserver:function(c,d,e,f){var g;(g=b.typeOf(c)===b.T_STRING?b.tupleForPropertyPath(c,f):c)?g[0].addObserver(g[1],d,e):this.queue.push([c,d,e,f])},removeObserver:function(c,d,e,f){var g,h,j;(g=b.tupleForPropertyPath(c,f))&&g[0].removeObserver(g[1],d,e);g=this.queue.length;for(h=this.queue;--g>=0;){j=h[g];if(j[0]===c&&j[1]===d&&j[2]==e&&j[3]===f)h[g]=null}},addPendingRangeObserver:function(c){var d=
this.rangeObservers;if(!d)d=this.rangeObservers=b.CoreSet.create();d.add(c);return this},_TMP_OUT:[],flush:function(c){var d=this.queue;if(d&&d.length>0)for(var e=this.queue=[],f=d.length;--f>=0;){var g=d[f];if(g){var h=b.tupleForPropertyPath(g[0],g[3]);h?h[0].addObserver(h[1],g[1],g[2]):e.push(g)}}if(c._kvo_needsRangeObserver){e=(d=this.rangeObservers)?d.get("length"):0;g=this._TMP_OUT;for(f=0;f<e;f++){h=d[f];h.setupPending(c)&&g.push(h)}g.length>0&&d.removeEach(g);g.length=0;c._kvo_needsRangeObserver=
false}},isObservingSuspended:0,_pending:b.CoreSet.create(),objectHasPendingChanges:function(c){this._pending.add(c)},suspendPropertyObserving:function(){this.isObservingSuspended++},resumePropertyObserving:function(){var c;if(--this.isObservingSuspended<=0){c=this._pending;this._pending=b.CoreSet.create();var d,e=c.length;for(d=0;d<e;d++)c[d]._notifyPropertyObservers();c.clear()}}}});
tiki.module("sproutcore/runtime:private/observer_set",function(a){var b=a("core");b.ObserverSet={targets:0,_membersCacheIsValid:false,add:function(c,d,e){var f=c?b.guidFor(c):"__this__",g=this[f];if(!g){g=this[f]=b.CoreSet.create();g.target=c;g.isTargetSet=true;this.targets++}g.add(d);if(e!==undefined){c=g.contexts;if(!e)e=g.contexts={};c[b.guidFor(d)]=e}this._membersCacheIsValid=false},remove:function(c,d){c=c?b.guidFor(c):"__this__";var e=this[c];if(!e)return false;e.remove(d);if(e.length<=0){e.target=
null;e.isTargetSet=false;e.contexts=null;delete this[c];this.targets--}else e.contexts&&delete e.contexts[b.guidFor(d)];this._membersCacheIsValid=false;return true},invokeMethods:function(){var c,d,e,f,g;for(c in this)if(this.hasOwnProperty(c))if((d=this[c])&&d.isTargetSet){e=d.length;for(f=d.target;--e>=0;)(g=d[e])&&g.call(f)}},getMembers:function(){if(this._membersCacheIsValid)return this._members;if(this._members)this._members.length=0;else this._members=[];var c=this._members;for(var d in this)if(this.hasOwnProperty(d)){var e=
this[d];if(e&&e.isTargetSet){var f=e.length,g=e.target,h=e.contexts;if(h)for(;--f>=0;){var j=e[f];c.push([g,j,h[b.guidFor(j)]])}else for(;--f>=0;)c.push([g,e[f]])}}this._membersCacheIsValid=true;return c},clone:function(){var c,d,e,f=b.ObserverSet.create();for(e in this)if(this.hasOwnProperty(e))if((c=this[e])&&c.isTargetSet){d=c.clone();d.target=c.target;if(c.contexts)d.contexts=b.clone(c.contexts);f[e]=d}f.targets=this.targets;f._membersCacheIsValid=false;return f},create:function(){return b.beget(this)}};
b.ObserverSet.slice=b.ObserverSet.clone});
tiki.module("sproutcore/runtime:system/binding",function(a){var b=a("core");a("system/set");b.LOG_BINDINGS=false;b.BENCHMARK_BINDING_NOTIFICATIONS=false;b.BENCHMARK_BINDING_SETUP=false;b.MULTIPLE_PLACEHOLDER="@@MULT@@";b.NULL_PLACEHOLDER="@@NULL@@";b.EMPTY_PLACEHOLDER="@@EMPTY@@";b.Binding={beget:function(c){var d=b.beget(this);d.parentBinding=this;if(c!==undefined)d=d.from(c);return d},builder:function(){var c=this,d=function(e){return c.beget().from(e)};d.beget=function(){return c.beget()};return d},
from:function(c,d){if(!c)return this;var e=this===b.Binding?this.beget():this;e._fromPropertyPath=c;e._fromRoot=d;e._fromTuple=null;return e},to:function(c,d){var e=this===b.Binding?this.beget():this;e._toPropertyPath=c;e._toRoot=d;e._toTuple=null;return e},connect:function(){if(this.isConnected)return this;this._syncOnConnect=this._connectionPending=this.isConnected=true;b.Binding._connectQueue.add(this);return this},_connect:function(){if(this._connectionPending){this._connectionPending=false;var c,
d,e=b.BENCHMARK_BINDING_SETUP;e&&b.Benchmark.start("SC.Binding.connect()");c=this._fromPropertyPath;d=this._fromRoot;if(b.typeOf(c)===b.T_STRING)if(c.indexOf(".")===0){c=c.slice(1);if(!d)d=this._toRoot}else if(c.indexOf("*")===0){c=[this._fromRoot||this._toRoot,c.slice(1)];d=null}b.Observers.addObserver(c,this,this.fromPropertyDidChange,d);if(!this._oneWay){c=this._toPropertyPath;d=this._toRoot;b.Observers.addObserver(c,this,this.toPropertyDidChange,d)}e&&b.Benchmark.end("SC.Binding.connect()");if(this._syncOnConnect){this._syncOnConnect=
false;e&&b.Benchmark.start("SC.Binding.connect().sync");this.sync();e&&b.Benchmark.end("SC.Binding.connect().sync")}}},disconnect:function(){if(!this.isConnected)return this;if(this._connectionPending)this._connectionPending=false;else{b.Observers.removeObserver(this._fromPropertyPath,this,this.fromPropertyDidChange,this._fromRoot||this._toRoot);this._oneWay||b.Observers.removeObserver(this._toPropertyPath,this,this.toPropertyDidChange,this._toRoot)}this.isConnected=false;return this},fromPropertyDidChange:function(c,
d){if((c?c.get(d):null)!==this._bindingValue){this._setBindingValue(c,d);this._changePending=true;b.Binding._changeQueue.add(this)}},toPropertyDidChange:function(c,d){if(!this._oneWay)if(c.get(d)!==this._transformedBindingValue){this._setBindingValue(c,d);this._changePending=true;b.Binding._changeQueue.add(this)}},_setBindingValue:function(c,d){this._bindingSource=c;this._bindingKey=d},_computeBindingValue:function(){var c=this._bindingSource,d=this._bindingKey;this._bindingValue=c=c?c.getPath(d):
null;var e=this._transforms;if(e){var f=e.length,g;for(d=0;d<f;d++){g=e[d];c=g(c,this)}}if(this._noError&&b.typeOf(c)===b.T_ERROR)c=null;this._transformedBindingValue=c},_connectQueue:b.CoreSet.create(),_alternateConnectQueue:b.CoreSet.create(),_changeQueue:b.CoreSet.create(),_alternateChangeQueue:b.CoreSet.create(),_changePending:false,flushPendingChanges:function(){if(this._isFlushing)return false;this._isFlushing=true;b.Observers.suspendPropertyObserving();for(var c=false,d=b.LOG_BINDINGS,e,f;(e=
this._connectQueue).length>0;){this._connectQueue=this._alternateConnectQueue;for(this._alternateConnectQueue=e;f=e.pop();)f._connect()}for(;(e=this._changeQueue).length>0;){d&&b.Logger.log("Begin: Trigger changed bindings");c=true;this._changeQueue=this._alternateChangeQueue;for(this._alternateChangeQueue=e;f=e.pop();)f.applyBindingValue();d&&b.Logger.log("End: Trigger changed bindings")}this._isFlushing=false;b.Observers.resumePropertyObserving();return c},applyBindingValue:function(){this._changePending=
false;this._computeBindingTargets();this._computeBindingValue();var c=this._bindingValue,d=this._transformedBindingValue,e=b.BENCHMARK_BINDING_NOTIFICATIONS,f=b.LOG_BINDINGS;if(!this._oneWay&&this._fromTarget){f&&b.Logger.log("%@: %@ -> %@".fmt(this,c,d));e&&b.Benchmark.start(this.toString()+"->");this._fromTarget.setPathIfChanged(this._fromPropertyKey,c);e&&b.Benchmark.end(this.toString()+"->")}if(this._toTarget){f&&b.Logger.log("%@: %@ <- %@".fmt(this,c,d));e&&b.Benchmark.start(this.toString()+
"<-");this._toTarget.setPathIfChanged(this._toPropertyKey,d);e&&b.Benchmark.start(this.toString()+"<-")}},sync:function(){if(!this.isConnected)return this;if(this._connectionPending)this._syncOnConnect=true;else{this._computeBindingTargets();var c=this._fromTarget,d=this._fromPropertyKey;if(!c||!d)return this;if(c.getPath(d)!==this._bindingValue){this._setBindingValue(c,d);this._changePending=true;b.Binding._changeQueue.add(this)}}return this},_syncOnConnect:false,_computeBindingTargets:function(){if(!this._fromTarget){var c,
d;c=this._fromPropertyPath;d=this._fromRoot;if(b.typeOf(c)===b.T_STRING)if(c.indexOf(".")===0){c=c.slice(1);if(!d)d=this._toRoot}else if(c.indexOf("*")===0){c=[d||this._toRoot,c.slice(1)];d=null}if(c=b.tupleForPropertyPath(c,d)){this._fromTarget=c[0];this._fromPropertyKey=c[1]}}if(!this._toTarget){c=this._toPropertyPath;d=this._toRoot;if(c=b.tupleForPropertyPath(c,d)){this._toTarget=c[0];this._toPropertyKey=c[1]}}},oneWay:function(c,d){if(d===undefined&&b.typeOf(c)===b.T_BOOL){d=c;c=null}c=this.from(c);
if(c===b.Binding)c=c.beget();c._oneWay=d===undefined?true:d;return c},transform:function(c){var d=this===b.Binding?this.beget():this,e=d._transforms;if(e&&e===d.parentBinding._transform)e=d._transforms=e.slice();if(!e)e=d._transforms=[];e.push(c);return d},resetTransforms:function(){var c=this===b.Binding?this.beget():this;c._transforms=null;return c},noError:function(c,d){if(d===undefined&&b.typeOf(c)===b.T_BOOL){d=c;c=null}c=this.from(c);if(c===b.Binding)c=c.beget();c._noError=d===undefined?true:
d;return c},single:function(c,d){if(d===undefined)d=b.MULTIPLE_PLACEHOLDER;return this.from(c).transform(function(e){if(e&&e.isEnumerable){var f=e.get("length");e=f>1?d:f<=0?null:e.firstObject()}return e})},notEmpty:function(c,d){if(d===undefined)d=b.EMPTY_PLACEHOLDER;return this.from(c).transform(function(e){if(b.none(e)||e===""||b.isArray(e)&&e.length===0)e=d;return e})},notNull:function(c,d){if(d===undefined)d=b.EMPTY_PLACEHOLDER;return this.from(c).transform(function(e){if(b.none(e))e=d;return e})},
multiple:function(c){return this.from(c).transform(function(d){b.isArray(d)||(d=d==null?[]:[d]);return d})},bool:function(c){return this.from(c).transform(function(d){var e=b.typeOf(d);if(e===b.T_ERROR)return d;return e==b.T_ARRAY?d.length>0:d===""?false:!!d})},and:function(c,d){return this.from("and",b.Object.create({valueABinding:c,valueBBinding:d,and:function(){return this.get("valueA")&&this.get("valueB")}.property("valueA","valueB").cacheable()})).oneWay()},or:function(c,d){return this.from("or",
b.Object.create({valueABinding:c,valueBBinding:d,or:function(){return this.get("valueA")||this.get("valueB")}.property("valueA","valueB").cacheable()})).oneWay()},not:function(c){return this.from(c).transform(function(d){var e=b.typeOf(d);if(e===b.T_ERROR)return d;return!(e==b.T_ARRAY?d.length>0:d===""?false:!!d)})},isNull:function(c){return this.from(c).transform(function(d){return b.typeOf(d)===b.T_ERROR?d:b.none(d)})},toString:function(){var c=this._fromRoot?"<%@>:%@".fmt(this._fromRoot,this._fromPropertyPath):
this._fromPropertyPath,d=this._toRoot?"<%@>:%@".fmt(this._toRoot,this._toPropertyPath):this._toPropertyPath,e=this._oneWay?"[oneWay]":"";return"SC.Binding%@(%@ -> %@)%@".fmt(b.guidFor(this),c,d,e)}};b.binding=function(c,d){return b.Binding.from(c,d)}});
tiki.module("sproutcore/runtime:system/cookie",function(a){var b=a("core");a("system/object");b.Cookie=b.Object.extend({name:null,value:"",expires:null,path:null,domain:null,secure:false,isCookie:true,destroy:function(){this.set("expires",-1);this.write();arguments.callee.base.apply(this,arguments)},write:function(){var c=this.get("name"),d=this.get("value"),e=this.get("expires"),f=this.get("path"),g=this.get("domain"),h=this.get("secure"),j="";if(e&&(b.typeOf(e)===b.T_NUMBER||b.DateTime&&e.get&&
e.get("milliseconds")||b.typeOf(e.toUTCString)===b.T_FUNCTION)){var k;if(b.typeOf(e)===b.T_NUMBER){k=new Date;k.setTime(k.getTime()+e*24*60*60*1E3)}else if(b.DateTime&&e.get&&e.get("milliseconds"))k=new Date(e.get("milliseconds"));else if(b.typeOf(e.toUTCString)===b.T_FUNCTION)k=e;if(k)j="; expires="+k.toUTCString()}e=f?"; path="+f:"";g=g?"; domain="+g:"";h=h?"; secure":"";document.cookie=[c,"=",encodeURIComponent(d),j,e,g,h].join("");return this}});b.Cookie.mixin({find:function(c){if(document.cookie&&
document.cookie!=="")for(var d=document.cookie.split(";"),e=0;e<d.length;e++){var f=String(d[e]).trim();if(f.substring(0,c.length+1)===c+"=")return b.Cookie.create({name:c,value:decodeURIComponent(f.substring(c.length+1))})}return null}})});
tiki.module("sproutcore/runtime:system/enumerator",function(a){var b=a("core");b.Enumerator=function(c){this.enumerable=c;this.reset();return this};b.Enumerator.prototype={nextObject:function(){var c=this._index,d=this._length;if(!(c>=d)){var e=this.enumerable.nextObject(c,this._previousObject,this._context);this._previousObject=e;this._index=c+1;if(c>=d)this._context=b.Enumerator._pushContext(this._context);return e}},reset:function(){var c=this.enumerable;if(!c)throw b.$error("Enumerator has been destroyed");
c=this._length=c.get?c.get("length"):c.length;this._index=0;this._previousObject=null;this._context=c>0?b.Enumerator._popContext():null},destroy:function(){this.enumerable=this._length=this._index=this._previousObject=this._context=null}};b.Enumerator.create=function(c){return new b.Enumerator(c)};b.Enumerator._popContext=function(){return(this._contextCache?this._contextCache.pop():null)||{}};b.Enumerator._pushContext=function(c){this._contextCache=this._contextCache||[];this._contextCache.push(c);
return null}});
tiki.module("sproutcore/runtime:system/error",function(a){var b=a("core");b.Error=b.Object.extend({code:-1,message:"",errorValue:null,errorObject:function(){return this}.property().cacheable(),label:null,toString:function(){return"SC.Error:%@:%@ (%@)".fmt(b.guidFor(this),this.get("message"),this.get("code"))},isError:true});b.Error.desc=function(c,d,e,f){c={message:c};if(d!==undefined)c.label=d;if(f!==undefined)c.code=f;if(e!==undefined)c.errorValue=e;return this.create(c)};b.$error=function(c,d,
e,f){return b.Error.desc(c,d,e,f)};b.ok=function(c){return c!==false&&!(c&&c.isError)};b.$ok=b.ok;b.val=function(c){return c&&c.isError?c.get?c.get("errorValue"):null:c};b.$val=b.val;b.Error.HAS_MULTIPLE_VALUES=-100});
tiki.module("sproutcore/runtime:system/index_set",function(a){var b=a("core");a("mixins/enumerable");a("mixins/observable");a("mixins/freezable");a("mixins/copyable");b.IndexSet=b.mixin({},b.Enumerable,b.Observable,b.Freezable,b.Copyable,{_sc_sliceContent:function(c){if(c.length<1E3)return c.slice();for(var d=0,e=[],f=c[0];f!==0;){e[d]=f;d=f<0?0-f:f;f=c[d]}e[d]=0;this._hint(0,d,e);return e},create:function(c,d){var e=b.beget(this);e.initObservable();if(c&&c.isIndexSet){e._content=this._sc_sliceContent(c._content);
e.max=c.max;e.length=c.length;e.source=c.source}else{e._content=[0];c!==undefined&&e.add(c,d)}return e},isIndexSet:true,HINT_SIZE:256,length:0,max:0,min:function(){var c=this._content[0];return c===0?-1:c>0?0:Math.abs(c)}.property("[]").cacheable(),firstObject:function(){return this.get("length")>0?this.get("min"):undefined}.property(),rangeStartForIndex:function(c){var d=this._content,e=this.get("max"),f;if(c>=e)return e;if(Math.abs(d[c])>c)return c;f=c-c%b.IndexSet.HINT_SIZE;e=d[f];if(e<0||e>c)e=
f;for(f=Math.abs(d[e]);f<c;){e=f;f=Math.abs(d[e])}return e},isEqual:function(c){if(c===this)return true;if(!c||!c.isIndexSet||c.max!==this.max||c.length!==this.length)return false;var d=this._content;c=c._content;var e=0,f=d[e];do{if(c[e]!==f)return false;e=Math.abs(f);f=d[e]}while(e!==0);return true},indexBefore:function(c){if(c===0)return-1;c--;var d=this._content,e=this.get("max"),f=this.rangeStartForIndex(c);if(!d)return null;for(;f===e||d[f]<0;){if(f===0)return-1;c=f-1;f=this.rangeStartForIndex(c)}return c},
indexAfter:function(c){var d=this._content,e=this.get("max");if(!d||c>=e)return-1;c++;e=this.rangeStartForIndex(c);for(e=d[e];e<0;){if(e===0)return-1;c=e=Math.abs(e);e=d[e]}return c},contains:function(c,d){var e,f;if(d===undefined){if(c===null||c===undefined)return false;if(typeof c===b.T_NUMBER)d=1;else if(c&&c.isIndexSet){if(c===this)return true;c=c._content;d=0;for(e=c[d];e!==0;){if(e>0&&!this.contains(d,e-d))return false;d=Math.abs(e);e=c[d]}return true}else{d=c.length;c=c.start}}e=this.rangeStartForIndex(c);
f=this._content[e];return f>0&&e<=c&&f>=c+d},intersects:function(c,d){var e,f,g;if(d===undefined)if(typeof c===b.T_NUMBER)d=1;else if(c&&c.isIndexSet){if(c===this)return true;e=c._content;f=0;for(g=e[f];g!==0;){if(g>0&&this.intersects(f,g-f))return true;f=Math.abs(g);g=e[f]}return false}else{d=c.length;c=c.start}f=this.rangeStartForIndex(c);e=this._content;g=e[f];for(d=c+d;f<d;){if(g===0)return false;if(g>0&&g>c)return true;f=Math.abs(g);g=e[f]}return false},without:function(c,d){if(c===this)return b.IndexSet.create();
return this.clone().remove(c,d)},replace:function(c,d){if(d===undefined)if(typeof c===b.T_NUMBER)d=1;else if(c&&c.isIndexSet){this._content=this._sc_sliceContent(c._content);this.beginPropertyChanges().set("max",c.max).set("length",c.length).set("source",c.source).enumerableContentDidChange().endPropertyChanges();return this}else{d=c.length;c=c.start}this._content.length=1;this.length=this.max=this._content[0]=0;return this.add(c,d)},add:function(c,d){if(this.isFrozen)throw b.FROZEN_ERROR;var e,f,
g;if(c&&c.isIndexSet){e=c._content;if(!e)return this;f=0;for(g=e[0];g!==0;){g>0&&this.add(f,g-f);f=g<0?0-g:g;g=e[f]}return this}else if(d===undefined)if(c===null||c===undefined)return this;else if(typeof c===b.T_NUMBER)d=1;else{d=c.length;c=c.start}else if(d===null)d=1;if(d<=0)return this;var h=this.get("max"),j=h,k;e=this._content;if(c===h){if(c>0){f=this.rangeStartForIndex(c-1);g=e[f];if(g>0){delete e[h];e[f]=h=c+d;c=f}else e[h]=h=c+d}else e[c]=h=d;e[h]=0;this.set("max",h);this.set("length",this.length+
d);d=h-c}else if(c>h){e[h]=0-c;e[c]=c+d;e[c+d]=0;this.set("max",c+d);this.set("length",this.length+d);d=c+d-h;c=h}else{f=this.rangeStartForIndex(c);g=e[f];h=c+d;k=0;if(c>0&&f===c&&g<=0){f=this.rangeStartForIndex(c-1);g=e[f]}if(g<0){e[f]=0-c;if(Math.abs(g)>h){e[c]=0-h;e[h]=g}else e[c]=g}else{c=f;if(g>h)h=g}for(f=c;f<h;){d=e[f];if(d===0){e[h]=0;g=h;k+=h-f}else{g=Math.abs(d);if(g>h){e[h]=d;g=h}if(d<0)k+=g-f}delete e[f];f=g}if((f=e[h])>0){delete e[h];h=f}e[c]=h;h>j&&this.set("max",h);this.set("length",
this.get("length")+k);d=h-c}this._hint(c,d);k!==0&&this.enumerableContentDidChange();return this},remove:function(c,d){if(this.isFrozen)throw b.FROZEN_ERROR;if(d===undefined)if(c===null||c===undefined)return this;else if(typeof c===b.T_NUMBER)d=1;else if(c.isIndexSet){c.forEachRange(this.remove,this);return this}else{d=c.length;c=c.start}if(d<=0)return this;var e=this.get("max"),f=this._content,g,h,j;if(c>=e)return this;e=this.rangeStartForIndex(c);g=f[e];j=c+d;h=0;if(c>0&&e===c&&g>0){e=this.rangeStartForIndex(c-
1);g=f[e]}if(g>0){f[e]=c;if(g>j){f[c]=j;f[j]=g}else f[c]=g}else{c=e;g=Math.abs(g);if(g>j)j=g}for(e=c;e<j;){d=f[e];if(d===0){f[j]=0;g=j}else{g=Math.abs(d);if(g>j){f[j]=d;g=j}if(d>0)h+=g-e}delete f[e];e=g}if((e=f[j])<0){delete f[j];j=Math.abs(e)}if(f[j]===0){delete f[j];f[c]=0;this.set("max",c)}else f[c]=0-j;this.set("length",this.get("length")-h);d=j-c;this._hint(c,d);h!==0&&this.enumerableContentDidChange();return this},_hint:function(c,d,e){if(e===undefined)e=this._content;var f=b.IndexSet.HINT_SIZE,
g=Math.abs(e[c]),h=c-c%f+f;for(d=c+d;h<d;){for(;g!==0&&g<=h;){c=g;g=Math.abs(e[c])}if(g===0)delete e[h];else if(h!==c)e[h]=c;h+=f}},clear:function(){if(this.isFrozen)throw b.FROZEN_ERROR;var c=this.length;this._content.length=1;this._content[0]=0;this.set("length",0).set("max",0);c>0&&this.enumerableContentDidChange()},addEach:function(c){if(this.isFrozen)throw b.FROZEN_ERROR;this.beginPropertyChanges();var d=c.get("length");if(c.isSCArray)for(;--d>=0;)this.add(c.objectAt(d));else c.isEnumerable&&
c.forEach(function(e){this.add(e)},this);this.endPropertyChanges();return this},removeEach:function(c){if(this.isFrozen)throw b.FROZEN_ERROR;this.beginPropertyChanges();var d=c.get("length");if(c.isSCArray)for(;--d>=0;)this.remove(c.objectAt(d));else c.isEnumerable&&c.forEach(function(e){this.remove(e)},this);this.endPropertyChanges();return this},clone:function(){return b.IndexSet.create(this)},inspect:function(){var c=this._content,d=c.length,e=0,f=[],g;for(e=0;e<d;e++){g=c[e];g!==undefined&&f.push("%@:%@".fmt(e,
g))}return"SC.IndexSet<%@>".fmt(f.join(" , "))},forEachRange:function(c,d){var e=this._content,f=0,g=e[f],h=this.source;if(d===undefined)d=null;for(;g!==0;){g>0&&c.call(d,f,g-f,this,h);f=Math.abs(g);g=e[f]}return this},forEachIn:function(c,d,e,f){var g=this._content,h=0,j=0;d=c+d;var k=this.source,l=g[h];if(f===undefined)f=null;for(;l!==0;){if(h<c)h=c;for(;h<l&&h<d;)e.call(f,h++,j++,this,k);if(h>=d)h=l=0;else{h=Math.abs(l);l=g[h]}}return this},lengthIn:function(c,d){var e=0;if(d===undefined)if(c===
null||c===undefined)return 0;else if(typeof c===b.T_NUMBER)d=1;else if(c.isIndexSet){c.forEachRange(function(j,k){e+=this.lengthIn(j,k)},this);return e}else{d=c.length;c=c.start}if(this.get("length")===0)return 0;var f=this._content,g=0,h=f[g];for(c=c+d;g<c&&h!==0;){if(h>0)e+=h>c?c-g:h-g;g=Math.abs(h);h=f[g]}return e},source:null,indexOf:function(c){var d=this.source;if(!d)throw"%@.indexOf() requires source".fmt(this);var e=d.get("length"),f=this._content;for(f=f[0]<0?Math.abs(f[0]):0;f>=0&&f<e;){f=
d.indexOf(c,f);if(f<0)return-1;if(this.contains(f))return f;f=f+1}return-1},lastIndexOf:function(c){var d=this.source;if(!d)throw"%@.lastIndexOf() requires source".fmt(this);var e=d.get("length"),f=this.max-1;if(f>=e)f=e-1;for(;f>=0;){e=d.lastIndexOf(c,f);if(e<0)return-1;if(this.contains(e))return e;f=e+1}return-1},forEachObject:function(c,d){var e=this.source;if(!e)throw"%@.forEachObject() requires source".fmt(this);var f=this._content,g=0,h=f[g];if(d===undefined)d=null;for(;h!==0;){for(;g<h;){c.call(d,
e.objectAt(g),g,e,this);g++}g=Math.abs(h);h=f[g]}return this},addObject:function(c,d){var e=this.source;if(!e)throw"%@.addObject() requires source".fmt(this);for(var f=e.get("length"),g=0;g>=0&&g<f;){g=e.indexOf(c,g);if(g>=0){this.add(g);if(d)return this;g=g++}else return this}return this},addObjects:function(c,d){c.forEach(function(e){this.addObject(e,d)},this);return this},removeObject:function(c,d){var e=this.source;if(!e)throw"%@.removeObject() requires source".fmt(this);for(var f=e.get("length"),
g=0;g>=0&&g<f;){g=e.indexOf(c,g);if(g>=0){this.remove(g);if(d)return this;g=g+1}else return this}return this},removeObjects:function(c,d){c.forEach(function(e){this.removeObject(e,d)},this);return this},LOG_OBSERVING:false,forEach:function(c,d){var e=this._content,f=0,g=0,h=this.source,j=e[f];if(d===undefined)d=null;for(;j!==0;){for(;f<j;)c.call(d,f++,g++,this,h);f=Math.abs(j);j=e[f]}return this},nextObject:function(c,d,e){c=this._content;var f=e.next,g=this.get("max");if(d===null)d=f=0;else if(d>=
g){delete e.next;return null}else d++;if(d===f){do{d=Math.abs(f);f=c[d]}while(f<0);e.next=f}return d},toString:function(){var c=[];this.forEachRange(function(d,e){c.push(e===1?d:"%@..%@".fmt(d,d+e-1))},this);return"SC.IndexSet<%@>".fmt(c.join(","))},max:0});b.IndexSet.slice=b.IndexSet.copy=b.IndexSet.clone;b.IndexSet.EMPTY=b.IndexSet.create().freeze()});
tiki.module("sproutcore/runtime:system/logger",function(){SC.LOGGER_LOG_DELIMITER=", ";SC.LOGGER_LOG_ERROR="ERROR: ";SC.LOGGER_LOG_INFO="INFO: ";SC.LOGGER_LOG_WARN="WARNING: ";SC.LOGGER_LOG_DEBUG="DEBUG: ";SC.Logger=SC.Object.create({debugEnabled:false,exists:function(){return typeof this.get("reporter")!=="undefined"&&this.get("reporter")!=null}.property("reporter").cacheable(),fallBackOnAlert:false,fallBackOnLog:true,format:true,reporter:console,log:function(){var a=this.get("reporter");if(this.get("exists")&&
typeof a.log==="function"){this.get("format")?a.log(this._argumentsToString.apply(this,arguments)):a.log.apply(a,arguments);return true}else if(this.fallBackOnAlert){var b=this.get("format")?this._argumentsToString.apply(this,arguments):arguments;this.get("exists")&&typeof a.alert==="function"?a.alert(b):alert(b);return true}return false},debug:function(){var a=this.get("reporter");if(this.get("debugEnabled")!==true)return false;if(this.get("exists")&&typeof a.debug==="function"){a.debug.apply(a,
arguments);return true}else if(this.fallBackOnLog){a=this._argumentsToArray(arguments);typeof a.unshift==="function"&&a.unshift(SC.LOGGER_LOG_DEBUG);return this.log.apply(this,a)}return false},dir:function(){var a=this.get("reporter");if(this.get("exists")&&typeof a.dir==="function"){a.dir.apply(a,arguments);return true}return this.fallBackOnLog?this.log.apply(this,arguments):false},dirxml:function(){var a=this.get("reporter");if(this.get("exists")&&typeof a.dirxml==="function"){a.dirxml.apply(a,
arguments);return true}return this.fallBackOnLog?this.log.apply(this,arguments):false},error:function(){var a=this.get("reporter");if(this.get("exists")&&typeof a.error==="function"){a.error.apply(a,arguments);return true}else if(this.fallBackOnLog){a=this._argumentsToArray(arguments);typeof a.unshift==="function"&&a.unshift(SC.LOGGER_LOG_ERROR);return this.log.apply(this,a)}return false},group:function(a){var b=this.get("reporter");if(this.get("exists")&&typeof b.group==="function"){b.group(a);return true}return false},
groupEnd:function(){var a=this.get("reporter");if(this.get("exists")&&typeof a.groupEnd==="function"){a.groupEnd();return true}return false},info:function(){var a=this.get("reporter");if(this.get("exists")&&typeof a.info==="function"){a.info.apply(a,arguments);return true}else if(this.fallBackOnLog){a=this._argumentsToArray(arguments);typeof a.unshift==="function"&&a.unshift(SC.LOGGER_LOG_INFO);return this.log.apply(this,a)}return false},profile:function(){var a=this.get("reporter");if(this.get("exists")&&
typeof a.profile==="function"){a.profile();return true}return false},profileEnd:function(){var a=this.get("reporter");if(this.get("exists")&&typeof a.profileEnd==="function"){a.profileEnd();return true}return false},time:function(a){var b=this.get("reporter");if(this.get("exists")&&typeof b.time==="function"){b.time(a);return true}return false},timeEnd:function(a){var b=this.get("reporter");if(this.get("exists")&&typeof b.timeEnd==="function"){b.timeEnd(a);return true}return false},trace:function(){var a=
this.get("reporter");if(this.get("exists")&&typeof a.trace==="function"){a.trace();return true}return false},warn:function(){var a=this.get("reporter");if(this.get("exists")&&typeof a.warn==="function"){a.warn.apply(a,arguments);return true}else if(this.fallBackOnLog){a=this._argumentsToArray(arguments);typeof a.unshift==="function"&&a.unshift(SC.LOGGER_LOG_WARN);return this.log.apply(this,a)}return false},_argumentsToArray:function(a){if(!a)return[];for(var b=[],c=0;c<a.length;c++)b[c]=a[c];return b},
_argumentsToString:function(){for(var a="",b=0;b<arguments.length-1;b++)a+=arguments[b]+SC.LOGGER_LOG_DELIMITER;a+=arguments[arguments.length-1];return a}})});
tiki.module("sproutcore/runtime:system/object",function(a){function b(){if(!c._object_foundObjectClassNames){c._object_foundObjectClassNames=true;var d=[],e=function(f,g,h){h--;if(!(d.indexOf(g)>=0)){d.push(g);for(var j in g)if(j!="__scope__")if(j!="superclass")if(j.match(/^[A-Z0-9]/)){var k=f?[f,j].join("."):j,l=g[j];switch(c.typeOf(l)){case c.T_CLASS:if(!l._object_className)l._object_className=k;h>=0&&e(k,l,h);break;case c.T_OBJECT:h>=0&&e(k,l,h);break;case c.T_HASH:if((f||k==="SC")&&h>=0)e(k,l,
h);break;default:break}}}};e(null,a("system","default").global,2)}}var c=a("core");a("mixins/observable");a("system/set");c.BENCHMARK_OBJECTS=false;c._object_extend=function(d,e){if(!e)throw"SC.Object.extend expects a non-null value.  Did you forget to 'sc_require' something?  Or were you passing a Protocol to extend() as if it were a mixin?";d._kvo_cloned=null;var f,g,h,j=d.concatenatedProperties,k=c.K,l,m;g=j?j.length:0;for(var n=g>0?{}:null;--g>=0;){f=j[g];l=d[f];m=e[f];if(l){l instanceof Array||
(l=c.$A(l));n[f]=m?l.concat(m):m}else{m instanceof Array||(m=c.$A(m));n[f]=m}}g=d._bindings;j=false;l=d._observers;m=false;var o=d._properties,r=false,u,q,s,w=d.outlets,v=false;if(e.outlets){w=(w||c.EMPTY_ARRAY).concat(e.outlets);v=true}for(f in e)if(f!=="_kvo_cloned")if(e.hasOwnProperty(f)){var x=(n.hasOwnProperty(f)?n[f]:null)||e[f];if(f.slice(-7)==="Binding"){if(!j){g=(g||c.EMPTY_ARRAY).slice();j=true}if(g===null)g=(d._bindings||c.EMPTY_ARRAY).slice();g[g.length]=f}else if(x&&x instanceof Function){if(!x.superclass&&
x!==(h=d[f]))x.superclass=x.base=h||k;if(x.propertyPaths){if(!m){l=(l||c.EMPTY_ARRAY).slice();m=true}l[l.length]=f}else if(u=x.localPropertyPaths)for(q=u.length;--q>=0;){s=d._kvo_for(c.keyFor("_kvo_local",u[q]),c.Set);s.add(f);d._kvo_for("_kvo_observed_keys",c.CoreSet).add(u[q])}else if(x.dependentKeys){if(!r){o=(o||c.EMPTY_ARRAY).slice();r=true}o[o.length]=f}else if(x.autoconfiguredOutlet){if(!v){w=(w||c.EMPTY_ARRAY).slice();v=true}w[w.length]=f}}d[f]=x}if(e.hasOwnProperty("toString")){f="toString";
x=(n.hasOwnProperty(f)?n[f]:null)||e[f];if(!x.superclass&&x!==(h=d[f]))x.superclass=x.base=h||k;d[f]=x}d._bindings=g||[];d._observers=l||[];d._properties=o||[];d.outlets=w||[];return d};c.Object=function(d){return this._object_init(d)};c.mixin(c.Object,{mixin:function(){var d=arguments.length,e;for(e=0;e<d;e++)c.mixin(this,arguments[e]);return this},superclass:null,extend:function(){var d=c.BENCHMARK_OBJECTS;d&&c.Benchmark.start("SC.Object.extend");var e,f=function(j){return this._object_init(j)};
for(e in this)if(this.hasOwnProperty(e))f[e]=this[e];if(this.hasOwnProperty("toString"))f.toString=this.toString;f.superclass=this;c.generateGuid(f);f.subclasses=c.Set.create();this.subclasses.add(f);e=f.prototype=c.beget(this.prototype);var g,h=arguments.length;for(g=0;g<h;g++)c._object_extend(e,arguments[g]);e.constructor=f;d&&c.Benchmark.end("SC.Object.extend");return f},create:function(){return new this(arguments)},isClass:true,subclasses:c.Set.create(),toString:function(){return c._object_className(this)},
subclassOf:function(d){if(this===d)return false;for(var e=this;e=e.superclass;)if(e===d)return true;return false},hasSubclass:function(d){return d&&d.subclassOf?d.subclassOf(this):false},kindOf:function(d){return this===d||this.subclassOf(d)}});c.Object.prototype={_kvo_enabled:true,_object_init:function(d){var e,f=d?d.length:0;for(e=0;e<f;e++)c._object_extend(this,d[e]);c.generateGuid(this);this.init();f=(d=this.initMixin)?d.length:0;for(e=0;e<f;e++)d[e].call(this);return this},mixin:function(){var d,
e=arguments.length;for(d=0;d<e;d++)c.mixin(this,arguments[d]);for(d=0;d<e;d++){var f=arguments[d].initMixin;f&&f.call(this)}return this},init:function(){this.initObservable();return this},isDestroyed:false,destroy:function(){if(this.get("isDestroyed"))return this;this.set("isDestroyed",true);var d,e=this.destroyMixin,f=e?e.length:0;for(d=0;d<f;d++)e[d].call(this);return this},isObject:true,respondsTo:function(d){return c.typeOf(this[d])===c.T_FUNCTION},tryToPerform:function(d,e,f){return this.respondsTo(d)&&
this[d](e,f)!==false},superclass:function(){var d=arguments.callee.caller;if(!d)throw"superclass cannot determine the caller method";return d.superclass?d.superclass.apply(this,arguments):null},instanceOf:function(d){return this.constructor===d},kindOf:function(d){return this.constructor.kindOf(d)},toString:function(){if(!this._object_toString){var d=c._object_className(this.constructor),e="%@:%@".fmt(d,c.guidFor(this));if(d)this._object_toString=e;else return e}return this._object_toString},awake:function(){this.outlets.forEach(function(d){this.get(d)},
this);this.bindings.invoke("sync")},invokeOnce:function(d){c.RunLoop.currentRunLoop.invokeOnce(this,d);return this},invokeLast:function(d){c.RunLoop.currentRunLoop.invokeLast(this,d);return this},concatenatedProperties:["concatenatedProperties","initMixin","destroyMixin"]};c.Object.prototype.constructor=c.Object;c.mixin(c.Object.prototype,c.Observable);c.instanceOf=function(d,e){return!!(d&&d.constructor===e)};c.kindOf=function(d,e){if(d&&!d.isClass)d=d.constructor;return!!(d&&d.kindOf&&d.kindOf(e))};
c._object_className=function(d){if(!c.isReady)return"";d._object_className||b();if(d._object_className)return d._object_className;for(d=d;d&&!d._object_className;)d=d.superclass;return d&&d._object_className?d._object_className:"Anonymous"}});
tiki.module("sproutcore/runtime:system/range_observer",function(a){var b=a("core");a("private/observer_queue");a("system/index_set");b.RangeObserver={isRangeObserver:true,toString:function(){return(this.indexes?this.indexes.toString():"SC.IndexSet<..>").replace("IndexSet","RangeObserver(%@)".fmt(b.guidFor(this)))},create:function(c,d,e,f,g,h){var j=b.beget(this);j.source=c;j.indexes=d?d.frozenCopy():null;j.target=e;j.method=f;j.context=g;j.isDeep=h||false;j.beginObserving();return j},extend:function(){var c=
b.beget(this),d=arguments,e=d.length,f;for(f=0;f<e;f++)b.mixin(c,d[f]);return c},destroy:function(){this.endObserving();return this},update:function(c,d){if(this.indexes&&this.indexes.isEqual(d))return this;this.indexes=d?d.frozenCopy():null;this.endObserving().beginObserving();return this},beginObserving:function(){if(!this.isDeep)return this;var c=this.observing;if(!c)c=this.observing=b.CoreSet.create();var d=this._beginObservingForEach;if(!d)d=this._beginObservingForEach=function(e){if((e=this.source.objectAt(e))&&
e.addObserver){c.push(e);e._kvo_needsRangeObserver=true}};this.indexes.forEach(d,this);this.isObserving=false;b.Observers.addPendingRangeObserver(this);return this},setupPending:function(c){var d=this.observing;if(this.isObserving||!d||d.get("length")===0)return true;if(d.contains(c)){this.isObserving=true;c=this._setupPendingForEach;if(!c){var e=this.objectPropertyDidChange;c=this._setupPendingForEach=function(f){var g=this.source.objectAt(f),h=b.guidFor(g);if(g&&g.addObserver){d.push(g);g.addObserver("*",
this,e);g=this[h];if(g===undefined||g===null)this[h]=f;else if(g.isIndexSet)g.add(f);else this[h]=b.IndexSet.create(g).add(f)}}}this.indexes.forEach(c,this);return true}else return false},endObserving:function(){if(!this.isDeep)return this;var c=this.observing;if(this.isObserving){var d=this.objectPropertyDidChange,e,f,g;if(c){f=c.length;for(e=0;e<f;e++){g=c[e];g.removeObserver("*",this,d);this[b.guidFor(g)]=null}c.length=0}this.isObserving=false}c&&c.clear();return this},rangeDidChange:function(c){var d=
this.indexes;if(!c||!d||d.intersects(c)){this.endObserving();this.method.call(this.target,this.source,null,"[]",c,this.context);this.beginObserving()}return this},objectPropertyDidChange:function(c,d,e,f){e=this.context;var g=this.method,h=b.guidFor(c),j=this[h];if(j&&!j.isIndexSet)j=this[h]=b.IndexSet.create(j).freeze();e?g.call(this.target,this.source,c,d,j,e,f):g.call(this.target,this.source,c,d,j,f)}}});
tiki.module("sproutcore/runtime:system/run_loop",function(a){var b=a("core");a("private/observer_set");a("system/object");b.RunLoop=b.Object.extend({beginRunLoop:function(){this._start=(new Date).getTime();if(b.LOG_BINDINGS||b.LOG_OBSERVERS)b.Logger.log("-- SC.RunLoop.beginRunLoop at %@".fmt(this._start));return this},endRunLoop:function(){var c;if(b.LOG_BINDINGS||b.LOG_OBSERVERS)b.Logger.log("-- SC.RunLoop.endRunLoop ~ flushing application queues");do(c=this.flushApplicationQueues())||(c=this._flushinvokeLastQueue());
while(c);this._start=null;if(b.LOG_BINDINGS||b.LOG_OBSERVERS)b.Logger.log("-- SC.RunLoop.endRunLoop ~ End");return this},invokeOnce:function(c,d){if(d===undefined){d=c;c=this}if(b.typeOf(d)===b.T_STRING)d=c[d];if(!this._invokeQueue)this._invokeQueue=b.ObserverSet.create();this._invokeQueue.add(c,d);return this},invokeLast:function(c,d){if(d===undefined){d=c;c=this}if(b.typeOf(d)===b.T_STRING)d=c[d];if(!this._invokeLastQueue)this._invokeLastQueue=b.ObserverSet.create();this._invokeLastQueue.add(c,
d);return this},flushApplicationQueues:function(){var c=NO,d=this._invokeQueue;if(d&&d.targets>0){this._invokeQueue=null;c=true;d.invokeMethods()}return b.Binding.flushPendingChanges()||c},_flushinvokeLastQueue:function(){var c=this._invokeLastQueue,d=false;if(c&&c.targets>0){this._invokeLastQueue=null;(d=true)&&c.invokeMethods()}return d}});b.RunLoop.currentRunLoop=null;b.RunLoop.runLoopClass=b.RunLoop;b.RunLoop.begin=function(){var c=this.currentRunLoop;if(!c)c=this.currentRunLoop=this.runLoopClass.create();
c.beginRunLoop();return this};b.RunLoop.end=function(){var c=this.currentRunLoop;if(!c)throw"SC.RunLoop.end() called outside of a runloop!";c.endRunLoop();return this};b.run=function(c,d){b.RunLoop.begin();c.call(d);b.RunLoop.end()}});
tiki.module("sproutcore/runtime:system/selection_set",function(a){var b=a("core");a("system/object");a("mixins/enumerable");a("mixins/copyable");a("mixins/freezable");a("system/set");a("system/index_set");b.SelectionSet=b.Object.extend(b.Enumerable,b.Freezable,b.Copyable,{isSelectionSet:true,length:function(){var c=0,d=this._sets,e=this._objects;if(e)c+=e.get("length");d&&d.forEach(function(f){c+=f.get("length")});return c}.property().cacheable(),sources:function(){var c=[],d=this._sets,e=d?d.length:
0,f,g;for(f=0;f<e;f++)(g=d[f])&&g.get("length")>0&&g.source&&c.push(g.source);return c}.property().cacheable(),indexSetForSource:function(c){if(!c||!c.isSCArray)return null;var d=this._indexSetCache,e=this._objects,f,g;if(!d)d=this._indexSetCache={};if((f=d[b.guidFor(c)])&&f._sourceRevision&&f._sourceRevision!==c.propertyRevision)f=null;if(!f){if((f=this._indexSetForSource(c,false))&&f.get("length")===0)f=null;if(e){if(f)f=f.copy();e.forEach(function(h){if((g=c.indexOf(h))>=0){f||(f=b.IndexSet.create());
f.add(g)}},this)}if(f){f=d[b.guidFor(c)]=f.frozenCopy();f._sourceRevision=c.propertyRevision}}return f},_indexSetForSource:function(c,d){if(d===undefined)d=true;var e=b.guidFor(c),f=this[e],g=this._sets,h=g?g.length:0,j=null;if(f>=h)f=null;if(b.none(f)){if(d&&!this.isFrozen){this.propertyWillChange("sources");if(!g)g=this._sets=[];j=g[h]=b.IndexSet.create();j.source=c;this[e]=h;this.propertyDidChange("sources")}}else j=g?g[f]:null;return j},add:function(c,d,e){if(this.isFrozen)throw b.FROZEN_ERROR;
var f,g,h;if(d===undefined&&e===undefined){if(!c)throw"Must pass params to SC.SelectionSet.add()";if(c.isIndexSet)return this.add(c.source,c);if(c.isSelectionSet){d=c._sets;g=c._objects;e=d?d.length:0;this.beginPropertyChanges();for(f=0;f<e;f++)(c=d[f])&&c.get("length")>0&&this.add(c.source,c);g&&this.addObjects(g);this.endPropertyChanges();return this}}c=this._indexSetForSource(c,true);f=this.get("length");h=c.get("length");g=f-h;c.add(d,e);this._indexSetCache=null;g+=c.get("length");if(g!==f){this.propertyDidChange("length");
this.enumerableContentDidChange();h===0&&this.notifyPropertyChange("sources")}return this},remove:function(c,d,e){if(this.isFrozen)throw b.FROZEN_ERROR;var f,g,h,j,k;if(d===undefined&&e===undefined){if(!c)throw"Must pass params to SC.SelectionSet.remove()";if(c.isIndexSet)return this.remove(c.source,c);if(c.isSelectionSet){f=c._sets;k=c._objects;e=f?f.length:0;this.beginPropertyChanges();for(g=0;g<e;g++)(h=f[g])&&h.get("length")>0&&this.remove(h.source,h);k&&this.removeObjects(k);this.endPropertyChanges();
return this}}h=this._indexSetForSource(c,true);f=this.get("length");j=f-h.get("length");if(h&&(k=this._objects)){if(e!==undefined){d=b.IndexSet.create(d,e);e=undefined}k.forEach(function(l){g=c.indexOf(l);if(d.contains(g)){k.remove(l);j--}},this)}h.remove(d,e);h=h.get("length");j+=h;this._indexSetCache=null;if(j!==f){this.propertyDidChange("length");this.enumerableContentDidChange();h===0&&this.notifyPropertyChange("sources")}return this},contains:function(c,d,e){if(d===undefined&&e===undefined)return this.containsObject(c);
c=this.indexSetForSource(c);if(!c)return false;return c.contains(d,e)},intersects:function(c,d,e){c=this.indexSetForSource(c,false);if(!c)return false;return c.intersects(d,e)},_TMP_ARY:[],addObject:function(c){var d=this._TMP_ARY;d[0]=c;c=this.addObjects(d);d.length=0;return c},addObjects:function(c){var d=this._objects,e;if(!d)d=this._objects=b.CoreSet.create();e=d.get("length");d.addEach(c);c=d.get("length");this._indexSetCache=null;if(c!==e){this.propertyDidChange("length");this.enumerableContentDidChange()}return this},
removeObject:function(c){var d=this._TMP_ARY;d[0]=c;c=this.removeObjects(d);d.length=0;return c},removeObjects:function(c){var d=this._objects,e,f;if(!d)return this;e=d.get("length");d.removeEach(c);f=d.get("length");if(d=this._sets)d.forEach(function(g){e+=g.get("length");g.removeObjects(c);f+=g.get("length")},this);this._indexSetCache=null;if(f!==e){this.propertyDidChange("length");this.enumerableContentDidChange()}return this},containsObject:function(c){var d=this._objects;if(d&&d.contains(c))return true;
var e=(d=this._sets)?d.length:0,f,g;for(f=0;f<e;f++)if((g=d[f])&&g.indexOf(c)>=0)return true;return false},constrain:function(c){var d,e,f;this.beginPropertyChanges();this.get("sources").forEach(function(g){if(g!==c)(g=this._indexSetForSource(c,false))&&this.remove(c,g)},this);if((d=this._indexSetForSource(c,false))&&(f=d.get("max"))>(e=c.get("length")))this.remove(c,e,f-e);if(d=this._objects)d.forEach(function(g){c.indexOf(g)<0&&this.removeObject(g)},this);this.endPropertyChanges();return this},
isEqual:function(c){var d,e,f,g;if(!c||!c.isSelectionSet)return false;if(c===this)return true;if(this._sets===c._sets&&this._objects===c._objects)return true;if(this.get("length")!==c.get("length"))return false;d=this._objects;e=c._objects;if(d||e){if((d?d.get("length"):0)!==(e?e.get("length"):0))return false;if(d&&!d.isEqual(e))return false}g=this.get("sources");f=g.get("length");for(c=0;c<f;c++){e=g.objectAt(c);d=this._indexSetForSource(e,false);e=this._indexSetForSource(e,false);if(!!e!==!!d)return false;
if(d&&!d.isEqual(e))return false}return true},clear:function(){if(this.isFrozen)throw b.FROZEN_ERROR;if(this._sets)this._sets.length=0;if(this._objects)this._objects=null;this._indexSetCache=null;this.propertyDidChange("length");this.enumerableContentDidChange();this.notifyPropertyChange("sources");return this},copy:function(){var c=this.constructor.create(),d=this._sets,e=d?d.length:0,f,g;if(d&&e>0){d=c._sets=d.slice();for(f=0;f<e;f++)if(g=d[f]){g=d[f]=g.copy();c[b.guidFor(g.source)]=f}}if(this._objects)c._objects=
this._objects.copy();return c},freeze:function(){if(this.isFrozen)return this;for(var c=this._sets,d=c?c.length:0,e;--d>=0;)if(e=c[d])e.freeze();this._objects&&this._objects.freeze();return arguments.callee.base.apply(this,arguments)},toString:function(){var c=this._sets||[];c=c.map(function(d){return d.toString().replace("SC.IndexSet",b.guidFor(d.source))},this);this._objects&&c.push(this._objects.toString());return"SC.SelectionSet:%@<%@>".fmt(b.guidFor(this),c.join(","))},firstObject:function(){var c=
this._sets,d=this._objects;if(c&&c.get("length")>0){var e=c?c[0]:null;c=e?e.source:null;e=e?e.firstObject():-1;if(c&&e>=0)return c.objectAt(e)}return d?d.firstObject():undefined}.property(),nextObject:function(c,d,e){var f;if(c===0){f=e.objects=[];this.forEach(function(g){f.push(g)},this);e.max=f.length}f=e.objects;d=f[c];if(c+1>=e.max)e.objects=e.max=null;return d},forEach:function(c,d){var e=this._sets,f=this._objects,g=e?e.length:0,h,j;for(j=0;j<g;j++)(h=e[j])&&h.forEachObject(c,d);f&&f.forEach(c,
d);return this}});b.SelectionSet.prototype.clone=b.SelectionSet.prototype.copy;b.SelectionSet.EMPTY=b.SelectionSet.create().freeze()});
tiki.module("sproutcore/runtime:system/set",function(a){var b=a("core");a("mixins/enumerable");a("mixins/copyable");a("mixins/freezable");a("mixins/observable");b.Set=b.mixin({},b.Enumerable,b.Observable,b.Freezable,{create:function(c){var d,e;e=b.Set._pool;var f=this.isObservable;if(!f&&c===undefined&&e.length>0)d=e.pop();else{d=b.beget(this);f&&d.initObservable();if(c&&c.isEnumerable&&c.get("length")>0){d.isObservable=false;if(c.isSCArray)for(e=c.get?c.get("length"):c.length;--e>=0;)d.add(c.objectAt(e));
else if(c.isSet)for(e=c.length;--e>=0;)d.add(c[e]);else c.forEach(function(g){d.add(g)},this);d.isObservable=f}}return d},isSet:true,length:0,firstObject:function(){return this.length>0?this[0]:undefined}.property(),clear:function(){if(this.isFrozen)throw b.FROZEN_ERROR;this.length=0;return this},contains:function(c){if(c===null)return false;var d=this[b.hashFor(c)];return!b.none(d)&&d<this.length&&this[d]===c},isEqual:function(c){if(!c||!c.isSet||c.get("length")!==this.get("length"))return false;
for(var d=this.get("length");--d>=0;)if(!c.contains(this[d]))return false;return true},add:function(c){if(this.isFrozen)throw b.FROZEN_ERROR;if(c===null||c===undefined)return this;var d=b.hashFor(c),e=this[d],f=this.length;if(e===null||e===undefined||e>=f||this[e]!==c){this[f]=c;this[d]=f;this.length=f+1}this.isObservable&&this.enumerableContentDidChange();return this},addEach:function(c){if(this.isFrozen)throw b.FROZEN_ERROR;if(!c||!c.isEnumerable)throw"%@.addEach must pass enumerable".fmt(this);
var d,e=this.isObservable;e&&this.beginPropertyChanges();if(c.isSCArray)for(d=c.get("length");--d>=0;)this.add(c.objectAt(d));else if(c.isSet)for(d=c.length;--d>=0;)this.add(c[d]);else c.forEach(function(f){this.add(f)},this);e&&this.endPropertyChanges();return this},remove:function(c){if(this.isFrozen)throw b.FROZEN_ERROR;if(b.none(c))return this;var d=b.hashFor(c),e=this[d],f=this.length;if(b.none(e)||e>=f||this[e]!==c)return this;delete this[d];if(e<f-1){c=this[e]=this[f-1];this[b.hashFor(c)]=
e}this.length=f-1;this.isObservable&&this.enumerableContentDidChange();return this},pop:function(){if(this.isFrozen)throw b.FROZEN_ERROR;var c=this.length>0?this[this.length-1]:null;c&&this.remove(c);return c},removeEach:function(c){if(this.isFrozen)throw b.FROZEN_ERROR;if(!c||!c.isEnumerable)throw"%@.addEach must pass enumerable".fmt(this);var d,e=this.isObservable;e&&this.beginPropertyChanges();if(c.isSCArray)for(d=c.get("length");--d>=0;)this.remove(c.objectAt(d));else if(c.isSet)for(d=c.length;--d>=
0;)this.remove(c[d]);else c.forEach(function(f){this.remove(f)},this);e&&this.endPropertyChanges();return this},copy:function(){return this.constructor.create(this)},destroy:function(){this.isFrozen=false;this.isObservable||b.Set._pool.push(this.clear());return this},forEach:function(c,d){var e=this.length;d||(d=this);for(var f=0;f<e;f++)c.call(d,this[f],f,this);return this},toString:function(){var c=this.length,d,e=[];for(d=0;d<c;d++)e[d]=this[d];return"SC.Set<%@>".fmt(e.join(","))},_pool:[],isObservable:true});
b.Set.constructor=b.Set;b.Set.clone=b.Set.copy;b.Set.push=b.Set.unshift=b.Set.add;b.Set.shift=b.Set.pop;b.Set.addObject=b.Set.add;b.Set.removeObject=b.Set.remove;b.Set._pool=[];b.CoreSet=b.beget(b.Set);b.CoreSet.isObservable=false;b.CoreSet.constructor=b.CoreSet});
tiki.module("sproutcore/runtime:system/sparse_array",function(a){var b=a("core");a("system/index_set");a("system/object");a("mixins/enumerable");a("mixins/array");a("mixins/delegate_support");b.SparseArray=b.Object.extend(b.Enumerable,b.Array,b.DelegateSupport,{_requestingLength:0,_requestingIndex:0,length:function(){var c=this.delegate;if(c&&b.none(this._length)&&c.sparseArrayDidRequestLength){this._requestingLength++;c.sparseArrayDidRequestLength(this);this._requestingLength--}return this._length||
0}.property().cacheable(),provideLength:function(c){if(b.none(c))this._sa_content=null;if(c!==this._length){this._length=c;this._requestingLength<=0&&this.enumerableContentDidChange()}return this},rangeWindowSize:1,requestedRangeIndex:[],objectAt:function(c){var d=this._sa_content,e;if(!d)d=this._sa_content=[];if((e=d[c])===undefined){this.requestIndex(c);e=d[c]}return e},definedIndexes:function(c){var d=b.IndexSet.create(),e=this._sa_content,f;if(!e)return d.freeze();if(c)c.forEach(function(g){e[g]!==
undefined&&d.add(g)});else{f=e.length;for(c=0;c<f;c++)e[c]!==undefined&&d.add(c)}return d.freeze()},_TMP_RANGE:{},requestIndex:function(c){var d=this.delegate;if(!d)return this;var e=this.get("rangeWindowSize");c=c;if(e>1)c-=Math.floor(c%e);if(e<1)e=1;this._requestingIndex++;if(d.sparseArrayDidRequestRange){var f=this._TMP_RANGE;if(this.wasRangeRequested(c)===-1){f.start=c;f.length=e;d.sparseArrayDidRequestRange(this,f);this.requestedRangeIndex.push(c)}}else if(d.sparseArrayDidRequestIndex)for(;--e>=
0;)d.sparseArrayDidRequestIndex(this,c+e);this._requestingIndex--;return this},wasRangeRequested:function(c){var d,e;d=0;for(e=this.requestedRangeIndex.length;d<e;d++)if(this.requestedRangeIndex[d]===c)return d;return-1},rangeRequestCompleted:function(c){c=this.wasRangeRequested(c);if(c>=0){this.requestedRangeIndex.removeAt(c,1);return true}return false},provideObjectsInRange:function(c,d){var e=this._sa_content;if(!e)e=this._sa_content=[];var f=c.start;for(c=c.length;--c>=0;)e[f+c]=d[c];this._requestingIndex<=
0&&this.enumerableContentDidChange();return this},_TMP_PROVIDE_ARRAY:[],_TMP_PROVIDE_RANGE:{length:1},provideObjectAtIndex:function(c,d){var e=this._TMP_PROVIDE_ARRAY,f=this._TMP_PROVIDE_RANGE;e[0]=d;f.start=c;return this.provideObjectsInRange(f,e)},objectsDidChangeInRange:function(c){var d=this._sa_content;if(d)if(c.start===0&&b.maxRange(c)>=d.length)this._sa_content=null;else for(var e=c.start,f=Math.min(e+c.length,d.length);--f>=e;)d[f]=undefined;this.enumerableContentDidChange(c);return this},
indexOf:function(c){var d=this.delegate;if(d&&d.sparseArrayDidRequestIndexOf)return d.sparseArrayDidRequestIndexOf(this,c);else{d=this._sa_content;if(!d)d=this._sa_content=[];return d.indexOf(c)}},replace:function(c,d,e){e=e||[];var f=this.delegate;if(f)if(!f.sparseArrayShouldReplace||!f.sparseArrayShouldReplace(this,c,d,e))return this;f=this._sa_content;if(!f)f=this._sa_content=[];f.replace(c,d,e);e=(e?e.get?e.get("length"):e.length:0)-d;if(!b.none(this._length)){this.propertyWillChange("length");
this._length+=e;this.propertyDidChange("length")}this.enumerableContentDidChange(c,d,e);return this},reset:function(){this._length=this._sa_content=null;this.enumerableContentDidChange();this.invokeDelegateMethod(this.delegate,"sparseArrayDidReset",this);return this}});b.SparseArray.array=function(c){return this.create({_length:c||0})}});tiki.script("sproutcore/runtime:en/4e45a795ad83e4f4a267451bf706cc3fc2658096/javascript.js");
tiki.register("sproutcore/datastore",{packages:{"sproutcore/runtime":{scripts:[{url:"/static/sproutcore/runtime/en/4e45a795ad83e4f4a267451bf706cc3fc2658096/javascript.js",id:"sproutcore/runtime:en/4e45a795ad83e4f4a267451bf706cc3fc2658096/javascript.js"}]},tiki:{scripts:[{url:"/static/tiki/en/f190e4e36f88857b033c419907d4b704109b7815/javascript.js",id:"tiki:en/f190e4e36f88857b033c419907d4b704109b7815/javascript.js"}]}},depends:["tiki","sproutcore/runtime"],scripts:[{url:"/static/sproutcore/datastore/en/eb43c56c9a551db9bba1cd04f29ca1dfb2e47e4c/javascript.js",
id:"sproutcore/datastore:en/eb43c56c9a551db9bba1cd04f29ca1dfb2e47e4c/javascript.js"}]});tiki.module("sproutcore/datastore:index",function(){});tiki.script("sproutcore/datastore:en/eb43c56c9a551db9bba1cd04f29ca1dfb2e47e4c/javascript.js");
tiki.register("sproutcore/foundation",{packages:{"sproutcore/runtime":{scripts:[{url:"/static/sproutcore/runtime/en/4e45a795ad83e4f4a267451bf706cc3fc2658096/javascript.js",id:"sproutcore/runtime:en/4e45a795ad83e4f4a267451bf706cc3fc2658096/javascript.js"}]},tiki:{scripts:[{url:"/static/tiki/en/f190e4e36f88857b033c419907d4b704109b7815/javascript.js",id:"tiki:en/f190e4e36f88857b033c419907d4b704109b7815/javascript.js"}]}},stylesheets:[{url:"/static/sproutcore/foundation/en/a04970954a917ede9918ca06897bc0e1406986d5/stylesheet.css",
id:"sproutcore/foundation:en/a04970954a917ede9918ca06897bc0e1406986d5/stylesheet.css"}],depends:["tiki","sproutcore/runtime"],scripts:[{url:"/static/sproutcore/foundation/en/a04970954a917ede9918ca06897bc0e1406986d5/javascript.js",id:"sproutcore/foundation:en/a04970954a917ede9918ca06897bc0e1406986d5/javascript.js"}]});tiki.global("sproutcore/foundation");
SC.Locale=SC.Object.extend({init:function(){this.language||SC.Locale._assignLocales();if(!this.hasStrings){var a=this._deprecatedLanguageCodes||[];a.push(this.language);for(var b=a.length,c=null;!c&&--b>=0;)c=String[a[b]];if(c){this.hasStrings=YES;this.strings=c}}},hasStrings:NO,strings:{},toString:function(){this.language||SC.Locale._assignLocales();return"SC.Locale["+this.language+"]"+SC.guidFor(this)},locWithDefault:function(a,b){return this.strings[a]||b||a}});
SC.Locale.mixin({useAutodetectedLanguage:NO,preferredLanguage:null,createCurrentLocale:function(){var a=String.preferredLanguage!==undefined?String.preferredLanguage:this.preferredLanguage;a=((String.useAutodetectedLanguage!==undefined?String.useAutodetectedLanguage:this.useAutodetectedLanguage)?SC.browser.language:null)||a||SC.browser.language||"en";a=SC.Locale.normalizeLanguage(a);var b=this.localeClassFor(a);if(a!=this.currentLanguage){this.currentLanguage=a;this.currentLocale=b.create()}return this.currentLocale},
localeClassFor:function(a){a=SC.Locale.normalizeLanguage(a);var b,c=this.locales[a];if(!c&&(b=a.split("-")[0])!==a&&(c=this.locales[b]))c=this.locales[a]=c.extend();c||(c=this.locales[a]=this.locales.en.extend());return c},define:function(a,b){var c;if(b===undefined&&SC.typeOf(a)!==SC.T_STRING){c=this;b=a}else c=SC.Locale.localeClassFor(a);SC.mixin(c.prototype,b);return c},options:function(){return this.prototype},addStrings:function(a){var b=this.prototype.strings;if(b){if(!this.prototype.hasOwnProperty("strings"))this.prototype.strings=
SC.clone(b)}else b=this.prototype.strings={};if(a)this.prototype.strings=SC.mixin(b,a);this.prototype.hasStrings=YES;return this},_map:{english:"en",french:"fr",german:"de",japanese:"ja",jp:"ja",spanish:"es"},normalizeLanguage:function(a){if(!a)return"en";return SC.Locale._map[a.toLowerCase()]||a},_assignLocales:function(){for(var a in this.locales)this.locales[a].prototype.language=a},toString:function(){this.prototype.language||SC.Locale._assignLocales();return"SC.Locale["+this.prototype.language+
"]"},extend:function(){var a=SC.Object.extend.apply(this,arguments);a.addStrings=SC.Locale.addStrings;a.define=SC.Locale.define;a.options=SC.Locale.options;a.toString=SC.Locale.toString;return a}});SC.Locale.locales={en:SC.Locale.extend({_deprecatedLanguageCodes:["English"]}),fr:SC.Locale.extend({_deprecatedLanguageCodes:["French"]}),de:SC.Locale.extend({_deprecatedLanguageCodes:["German"]}),ja:SC.Locale.extend({_deprecatedLanguageCodes:["Japanese","jp"]}),es:SC.Locale.extend({_deprecatedLanguageCodes:["Spanish"]})};
SC.stringsFor=function(a,b){SC.Locale.localeClassFor(a).addStrings(b);return this};sc_require("system/locale");SC.stringsFor("English",{"_SC.DateTime.dayNames":"Sunday Monday Tuesday Wednesday Thursday Friday Saturday","_SC.DateTime.abbreviatedDayNames":"Sun Mon Tue Wed Thu Fri Sat","_SC.DateTime.monthNames":"January February March April May June July August September October November December","_SC.DateTime.abbreviatedMonthNames":"Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec"});SC.DROP_ON=1;
SC.DROP_BEFORE=2;SC.DROP_AFTER=4;SC.DROP_ANY=7;SC.SAFARI_FOCUS_BEHAVIOR=YES;SC.mixin({data:function(a,b,c){a=a===window?"@window":a;a=SC.hashFor(a);var d=SC._data_cache;if(!d)SC._data_cache=d={};var e=d[a];if(b&&!e)d[a]=e={};if(e&&c!==undefined)e[b]=c;return b?e[b]:e},removeData:function(a,b){a=a===window?"@window":a;a=SC.hashFor(a);var c=SC._data_cache;if(c){var d=c[a];if(d){var e=b?d[b]:d;if(b)delete d[b];else delete c[a];return e}}}});
SC.mixin(Function.prototype,{invokeLater:function(a,b){if(b===undefined)b=1;var c=this;if(arguments.length>2){var d=SC.$A(arguments).slice(2,arguments.length);d.unshift(a);var e=this,f=c;c=function(){return f.apply(e,d.slice(1))}}return SC.Timer.schedule({target:a,action:c,interval:b})}});SC.Controller=SC.Object.extend({isEditable:YES});
SC.SelectionSupport={hasSelectionSupport:YES,allowsSelection:YES,allowsMultipleSelection:YES,allowsEmptySelection:YES,firstSelectableObject:function(){return this.get("firstObject")}.property(),selection:function(a,b){var c=(a=this._scsel_selection)?a.get("length"):0,d;if(b===undefined||!this.get("allowsSelection"))b=a;d=b&&b.isEnumerable?b.get("length"):0;if(d>1&&!this.get("allowsMultipleSelection"))if(c>1){b=SC.SelectionSet.create().addObject(a.get("firstObject")).freeze();d=1}else{b=a;d=c}if(d===
0&&!this.get("allowsEmptySelection"))if(c===0){b=(b=this.get("firstSelectableObject"))?SC.SelectionSet.create().addObject(b).freeze():SC.SelectionSet.EMPTY;d=b.get("length")}else{b=a;d=c}if(d===0)b=SC.SelectionSet.EMPTY;return this._scsel_selection=b=b.frozenCopy()}.property("arrangedObjects","allowsEmptySelection","allowsMultipleSelection","allowsSelection").cacheable(),hasSelection:function(){var a=this.get("selection");return!!a&&a.get("length")>0}.property("selection").cacheable(),selectObjects:function(a,
b){if(!a||a.get("length")===0){b||this.set("selection",SC.SelectionSet.EMPTY);return this}var c=this.get("selection");c=b&&c?c.copy():SC.SelectionSet.create();c.addObjects(a).freeze();this.set("selection",c);return this},selectObject:function(a,b){if(a===null){b||this.set("selection",null);return this}else return this.selectObjects([a],b)},deselectObjects:function(a){if(!a||a.get("length")===0)return this;var b=this.get("selection");if(!b||b.get("length")===0)return this;b=b.copy().removeObjects(a).freeze();
this.set("selection",b.freeze());return this},deselectObject:function(a){return a?this.deselectObjects([a]):this},updateSelectionAfterContentChange:function(){var a=this.get("arrangedObjects"),b=this.get("selection"),c=b,d,e;if(c&&a&&c.get("sources").indexOf(a)>=0){d=c.indexSetForSource(a);e=a.get("length");d=d?d.get("max"):0;if(d>e){c=c.copy().remove(a,e,d-e).freeze();this.set("selection",c)}}if(c===b){e=b?b.get("length"):0;d=a?a.get("length"):0;e===0&&!this.get("allowsEmptySelection")&&d>0&&this.notifyPropertyChange("selection")}return this}};
sc_require("controllers/controller");sc_require("mixins/selection_support");
SC.ArrayController=SC.Controller.extend(SC.Array,SC.SelectionSupport,{content:null,isEditable:YES,orderBy:null,allowsSingleContent:YES,destroyOnRemoval:NO,arrangedObjects:function(){return this}.property().cacheable(),canRemoveContent:function(){var a=this.get("content");return a&&this.get("isEditable")&&this.get("hasContent")?!a.isEnumerable||SC.typeOf(a.removeObject)===SC.T_FUNCTION:NO}.property("content","isEditable","hasContent"),canReorderContent:function(){var a=this.get("content");return!!a&&
this.get("isEditable")&&!this.get("orderBy")&&!!a.isSCArray}.property("content","isEditable","orderBy"),canAddContent:function(){var a=this.get("content");return a&&this.get("isEditable")&&a.isEnumerable?SC.typeOf(a.addObject)===SC.T_FUNCTION||SC.typeOf(a.pushObject)===SC.T_FUNCTION:NO}.property("content","isEditable"),hasContent:function(){var a=this.get("content");return!!a&&(!!a.isEnumerable||!!this.get("allowsSingleContent"))}.property("content","allowSingleContent"),status:function(){var a=this.get("content");
return(a=a?a.get("status"):null)?a:SC.Record.READY}.property().cacheable(),addObject:function(a){if(!this.get("canAddContent"))throw"%@ cannot add content".fmt(this);var b=this.get("content");if(b.isSCArray)b.pushObject(a);else if(b.addObject)b.addObject(a);else throw"%@.content does not support addObject".fmt(this);return this},removeObject:function(a){if(!this.get("canRemoveContent"))throw"%@ cannot remove content".fmt(this);var b=this.get("content");b.isEnumerable?b.removeObject(a):this.set("content",
null);this.get("destroyOnRemoval")&&a.destroy&&a.destroy();return this},length:function(){var a=this._scac_observableContent();return a?a.get("length"):0}.property().cacheable(),objectAt:function(a){var b=this._scac_observableContent();return b?b.objectAt(a):undefined},replace:function(a,b,c){if(!c||c.get("length")===0){if(!this.get("canRemoveContent"))throw"%@ cannot remove objects from the current content".fmt(this);}else if(!this.get("canReorderContent"))throw"%@ cannot add or reorder the current content".fmt(this);
var d=this.get("content"),e=[],f;if(this.get("destroyOnRemoval"))for(f=0;f<b;f++)e.push(d.objectAt(f+a));d&&d.replace(a,b,c);f=0;for(a=e.length;f<a;f++)e[f].destroy();return this},indexOf:function(a,b){var c=this._scac_observableContent();return c?c.indexOf(a,b):-1},init:function(){arguments.callee.base.apply(this,arguments);this._scac_contentDidChange()},_scac_cached:NO,_scac_observableContent:function(){var a=this._scac_cached;if(a!==NO)return a;var b=this.get("content"),c,d,e;if(SC.none(b))return this._scac_cached=
[];if(!b.isEnumerable)return this._scac_cached=a=this.get("allowsSingleContent")?[b]:[];c=this.get("orderBy");if(!c)if(b.isSCArray)return this._scac_cached=b;else throw"%@.orderBy is required for unordered content".fmt(this);switch(SC.typeOf(c)){case SC.T_STRING:c=[c];break;case SC.T_FUNCTION:d=c;break;case SC.T_ARRAY:break;default:throw"%@.orderBy must be Array, String, or Function".fmt(this);}if(!d){e=c.get("length");d=function(f,g){var h=0,j=0,k,l;for(h=0;h<e&&j===0;h++){k=c.objectAt(h);l=NO;if(k.indexOf("ASC")>
-1)k=k.split("ASC ")[1];else if(k.indexOf("DESC")>-1){k=k.split("DESC ")[1];l=YES}j=f?f.isObservable?f.get(k):f[k]:f;k=g?g.isObservable?g.get(k):g[k]:g;j=SC.compare(j,k);if(l)j=-1*j}return j}}a=[];b.forEach(function(f){a.push(f)});a.sort(d);d=null;return this._scac_cached=a},_scac_contentDidChange:function(){this._scac_cached=NO;var a=this.get("content"),b=!!this.get("orderBy"),c=this._scac_content,d=this._scac_length||0,e=this._scac_rangeObserver,f=this._scac_rangeDidChange,g=this._scac_enumerableDidChange,
h=this._scac_contentStatusDidChange;if(c===a)return this;if(c){if(e&&c.isSCArray)c.removeRangeObserver(e);else c.isEnumerable&&c.removeObserver("[]",this,g);c.removeObserver("status",this,h)}e=null;this._scac_cached=NO;if(this._scac_content=a){if(!b&&a.isSCArray)e=a.addRangeObserver(null,this,f);else a.isEnumerable&&a.addObserver("[]",this,g);b=a.isEnumerable?a.get("length"):1;a.addObserver("status",this,h)}else b=SC.none(a)?0:1;this._scac_rangeObserver=e;this._scac_length=b;this._scac_contentStatusDidChange();
this.enumerableContentDidChange(0,b,b-d);this.updateSelectionAfterContentChange()}.observes("content"),_scac_enumerableDidChange:function(){var a=this.get("content");a=a?a.get("length"):0;var b=this._scac_length;this._scac_length=a;this.beginPropertyChanges();this._scac_cached=NO;this.enumerableContentDidChange(0,a,a-b);this.endPropertyChanges();this.updateSelectionAfterContentChange()}.observes("orderBy"),_scac_rangeDidChange:function(a,b,c,d){if(c==="[]"){this._scac_length=this.get("content").get("length");
this._scac_cached=NO;if(d){this.beginPropertyChanges();d.forEachRange(function(e,f){this.enumerableContentDidChange(e,f,0)},this);this.endPropertyChanges();this.updateSelectionAfterContentChange()}}},_scac_contentStatusDidChange:function(){this.notifyPropertyChange("status")}});sc_require("controllers/controller");
SC.ObjectController=SC.Controller.extend({content:null,allowsMultipleContent:NO,hasContent:function(){return!SC.none(this.get("observableContent"))}.property("observableContent"),isEditable:YES,observableContent:function(){var a=this.get("content"),b,c;if(a&&a.isEnumerable){b=a.get("length");c=this.get("allowsMultipleContent");if(b===1)a=a.firstObject();else if(b===0||!c)a=null;if(a&&!c&&a.isEnumerable)a=null}return a}.property("content","allowsMultipleContent").cacheable(),destroy:function(){var a=
this.get("observableContent");a&&SC.typeOf(a.destroy)===SC.T_FUNCTION&&a.destroy();this.set("content",null);return this},contentPropertyDidChange:function(a,b){b==="*"?this.allPropertiesDidChange():this.notifyPropertyChange(b)},unknownProperty:function(a,b){if(a==="content"){if(b!==undefined)this.content=b;return this.content}var c=this.get("observableContent"),d;if(!(c===null||c===undefined)){if(b===undefined)if(c.isEnumerable){b=c.getEach(a);a=b.get("length");if(a>0){d=YES;for(c=b.objectAt(0);--a>
0&&d;)if(c!==b.objectAt(a))d=NO;if(d)b=c}else b=undefined}else b=c.isObservable?c.get(a):c[a];else{if(!this.get("isEditable"))throw"%@.%@ is not editable".fmt(this,a);if(c.isEnumerable)c.setEach(a,b);else if(c.isObservable)c.set(a,b);else c[a]=b}return b}},init:function(){arguments.callee.base.apply(this,arguments);this.get("content")&&this._scoc_contentDidChange();this.get("observableContent")&&this._scoc_observableContentDidChange()},_scoc_contentDidChange:function(){var a=this._scoc_content,b=
this.get("content");if(a!==b){this._scoc_content=b;var c=this._scoc_enumerableContentDidChange;a&&a.isEnumerable&&a.removeObserver("[]",this,c);b&&b.isEnumerable&&b.addObserver("[]",this,c)}}.observes("content"),_scoc_observableContentDidChange:function(){var a=this._scoc_observableContent,b=this.get("observableContent"),c=this.contentPropertyDidChange,d=this._scoc_enumerableContentDidChange;if(a===b)return this;this._scoc_observableContent=b;if(a)if(a.isEnumerable)a.removeObserver("[]",this,d);else a.isObservable&&
a.removeObserver("*",this,c);if(b)if(b.isEnumerable)b.addObserver("[]",this,d);else b.isObservable&&b.addObserver("*",this,c);a&&a.isEnumerable||b&&b.isEnumerable?this._scoc_enumerableContentDidChange():this.contentPropertyDidChange(b,"*")}.observes("observableContent"),_scoc_enumerableContentDidChange:function(){var a=this.get("observableContent"),b=this._scoc_observableContentItems,c=this.contentPropertyDidChange;if(b){b.forEach(function(d){d.isObservable&&d.removeObserver("*",this,c)},this);b.clear()}if(a&&
a.isEnumerable){b||(b=SC.Set.create());a.forEach(function(d){if(!b.contains(d)){b.add(d);d.isObservable&&d.addObserver("*",this,c)}},this)}else b=null;this._scoc_observableContentItems=b;this.contentPropertyDidChange(a,"*");return this}});
SC.TreeItemContent={isTreeItemContent:YES,treeItemChildren:null,treeItemIsExpanded:YES,treeItemIsGrouped:NO,treeItemDisclosureState:function(){return this.get("treeItemIsExpanded")?SC.BRANCH_OPEN:SC.BRANCH_CLOSED},treeItemCollapse:function(){this.setIfChanged("treeItemIsExpanded",NO)},treeItemExpand:function(){this.setIfChanged("treeItemIsExpanded",YES)},treeItemBranchIndexes:function(){var a=this.get("treeItemChildren"),b,c,d,e;if(!a)return null;b=SC.IndexSet.create();c=a.get("length");for(d=0;d<
c;d++)if(e=a.objectAt(d))e.get("treeItemChildren")&&e.treeItemDisclosureState(this,d)!==SC.LEAF_NODE&&b.add(d);return b.get("length")>0?b:null}};SC.BRANCH_OPEN=17;SC.BRANCH_CLOSED=18;SC.LEAF_NODE=32;
SC.CollectionContent={isCollectionContent:YES,contentIndexIsSelected:function(a,b,c){return(a=a.get("selection"))?a.contains(b,c):NO},contentIndexIsEnabled:function(a){return a.get("isEnabled")},contentGroupIndexes:function(){return null},contentIndexIsGroup:function(){return NO},contentIndexOutlineLevel:function(){return-1},contentIndexDisclosureState:function(){return SC.LEAF_NODE},contentIndexExpand:function(a,b,c){SC.Logger.log("contentIndexExpand(%@, %@, %@)".fmt(a,b,c))},contentIndexCollapse:function(a,
b,c){SC.Logger.log("contentIndexCollapse(%@, %@, %@)".fmt(a,b,c))}};sc_require("mixins/tree_item_content");sc_require("mixins/collection_content");
SC.TreeItemObserver=SC.Object.extend(SC.Array,SC.CollectionContent,{item:null,delegate:null,parentObserver:null,parentItem:function(){var a=this.get("parentObserver");return a?a.get("item"):null}.property("parentObserver").cacheable(),index:null,outlineLevel:0,children:null,disclosureState:SC.BRANCH_OPEN,branchIndexes:function(){var a=this.get("item"),b,c,d,e,f;if(a)if(a.isTreeItemContent){c=this.get("parentItem");d=this.get("index");return a.treeItemBranchIndexes(c,d)}else{e=this.get("children");
if(!e)return null;f=SC.IndexSet.create();b=e.get("length");c=a;for(d=0;d<b;d++)if(a=e.objectAt(d))this._computeChildren(a,c,d)&&this._computeDisclosureState(a,c,d)!==SC.LEAF_NODE&&f.add(d);return f.get("length")>0?f:null}else return SC.IndexSet.EMPTY}.property("children").cacheable(),isHeaderVisible:function(){return!!this.get("parentObserver")}.property("parentObserver").cacheable(),length:0,objectAt:function(a){var b=this.get("length"),c=this.get("item"),d=this._objectAtCache,e=a,f;if(!(a>=b)){if(this.get("isHeaderVisible"))if(a===
0)return c;else e--;c=null;if(!d)d=this._objectAtCache=[];if((c=d[a])!==undefined)return c;if(f=this.get("children")){if(b=this.get("branchIndexes"))b.forEach(function(g){if(!(c||g>e)){var h=this.branchObserverAt(g),j;if(h){j=h.get("length");if(g+j>e){c=h.objectAt(e-g);e=-1}else e-=j-1}}},this);if(e>=0)c=f.objectAt(e);return d[a]=c}}},replace:function(a,b,c,d){var e=a,f=null,g,h;if(d===undefined)d=SC.DROP_BEFORE;this.get("isHeaderVisible")&&e--;if(e<0)throw"Tree Item cannot replace itself";if(a=this.get("branchIndexes"))a.forEach(function(j){if(!(f||
j>=e))if(f=this.branchObserverAt(j)){g=f.get("length");if(j+g===e&&d===SC.DROP_AFTER)e-=j;else if(j+g>e)e-=j;else{e-=g-1;f=null}}},this);if(f){f.replace(e,b,c,d);return this}h=e+b;b>1&&a&&a.forEachIn(e,a.get("max")-e,function(j){if(!(j>h))if(f=this.branchObserverAt(j)){g=f.get("length");h-=g-1}},this);b=h-e;a=this.get("children");if(!a)throw"cannot replace() tree item with no children";if(b<0||h>a.get("length"))throw"replace() range must lie within a single tree item";a.replace(e,b,c,d);return this},
observerContentDidChange:function(a,b,c){this.invalidateBranchObserversAt(a);this._disclosureStateCache=this._objectAtCache=this._outlineLevelCache=null;this._contentGroupIndexes=NO;this.notifyPropertyChange("branchIndexes");var d=this.get("length"),e=this._computeLength();c=this.get("parentObserver");d!==e&&this.set("length",e);if(!this._notifyParent)return this;if(c){a=SC.IndexSet.create(this.get("index"));c._childrenRangeDidChange(c.get("children"),null,"[]",a)}else{if(d===e){b=this.expandChildIndex(a+
b);a=this.expandChildIndex(a);b-=a;c=0}else{a=this.expandChildIndex(a);b=e-a;c=e-d}this.enumerableContentDidChange(a,b,c)}},expandChildIndex:function(a){var b=a;this.get("isHeaderVisible")&&a++;var c=this.get("branchIndexes");if(!c||c.get("length")===0)return b;c.forEachIn(0,a,function(d){b+=this.branchObserverAt(d).get("length")-1},this);return b},_contentGroupIndexes:NO,contentGroupIndexes:function(a,b){if(b!==this)return null;var c=this._contentGroupIndexes;if(c!==NO)return c;if(this.get("parentObserver"))return null;
a=this.get("item");var d,e;if(a&&a.isTreeItemContent?a.get("treeItemIsGrouped"):!!this.delegate.get("treeItemIsGrouped")){c=SC.IndexSet.create();a=this.get("branchIndexes");b=(b=this.get("children"))?b.get("length"):0;d=e=0;a&&a.forEach(function(f){c.add(d,f+1-e);d+=f+1-e;e=f+1;if(f=this.branchObserverAt(f))d+=f.get("length")-1},this);e<b&&c.add(d,b-e)}else c=null;return this._contentGroupIndexes=c},contentIndexIsGroup:function(a,b,c){return(a=this.contentGroupIndexes(a,b))?a.contains(c):NO},contentIndexOutlineLevel:function(a,
b,c){if(b!==this)return-1;if((b=this._outlineLevelCache)&&b[c]!==undefined)return b[c];if(!b)b=this._outlineLevelCache=[];var d=this.get("length"),e=c,f=null;if(c>=d)return-1;if(this.get("isHeaderVisible"))if(c===0)return b[0]=this.get("outlineLevel")-1;else e--;if(d=this.get("branchIndexes"))d.forEach(function(g){if(!(f!==null||g>e)){var h=this.branchObserverAt(g),j;if(h){j=h.get("length");if(g+j>e){f=h.contentIndexOutlineLevel(a,h,e-g);e=-1}else e-=j-1}}},this);if(e>=0)f=this.get("outlineLevel");
return b[c]=f},contentIndexDisclosureState:function(a,b,c){if(b!==this)return-1;if((b=this._disclosureStateCache)&&b[c]!==undefined)return b[c];if(!b)b=this._disclosureStateCache=[];var d=this.get("length"),e=c,f=null;if(c>=d)return SC.LEAF_NODE;if(this.get("isHeaderVisible"))if(c===0)return b[0]=this.get("disclosureState");else e--;if(d=this.get("branchIndexes"))d.forEach(function(g){if(!(f!==null||g>e)){var h=this.branchObserverAt(g),j;if(h){j=h.get("length");if(g+j>e){f=h.contentIndexDisclosureState(a,
h,e-g);e=-1}else e-=j-1}}},this);if(e>=0)f=SC.LEAF_NODE;return b[c]=f},contentIndexExpand:function(a,b,c){var d=c;if(b===this){if(this.get("isHeaderVisible"))if(c===0){this._expand(this.get("item"));return}else d--;if(b=this.get("branchIndexes"))b.forEach(function(e){if(!(e>=d)){var f=this.branchObserverAt(e),g;if(f){g=f.get("length");if(e+g>d){f.contentIndexExpand(a,f,d-e);d=-1}else d-=g-1}}},this);if(d>=0)(b=(b=this.get("children"))?b.objectAt(d):null)&&this._expand(b,this.get("item"),d)}},contentIndexCollapse:function(a,
b,c){var d=c;if(b===this){if(this.get("isHeaderVisible"))if(c===0){this._collapse(this.get("item"));return}else d--;if(b=this.get("branchIndexes"))b.forEach(function(e){if(!(e>=d)){var f=this.branchObserverAt(e),g;if(f){g=f.get("length");if(e+g>d){f.contentIndexCollapse(a,f,d-e);d=-1}else d-=g-1}}},this);if(d>=0)(b=(b=this.get("children"))?b.objectAt(d):null)&&this._collapse(b,this.get("item"),d)}},branchObserverAt:function(a){var b=this._branchObserversByIndex,c=this._branchObserverIndexes,d;if(!b)b=
this._branchObserversByIndex=[];if(!c)c=this._branchObserverIndexes=SC.IndexSet.create();if(d=b[a])return d;d=(d=this.get("children"))?d.objectAt(a):null;if(!d)return null;b[a]=d=SC.TreeItemObserver.create({item:d,delegate:this.get("delegate"),parentObserver:this,index:a,outlineLevel:this.get("outlineLevel")+1});c.add(a);return d},invalidateBranchObserversAt:function(a){var b=this._branchObserversByIndex,c=this._branchObserverIndexes;if(!b||b.length<=a)return this;if(a<0)a=0;c.forEachIn(a,c.get("max")-
a,function(d){(d=b[d])&&d.destroy()},this);b.length=a;return this},init:function(){arguments.callee.base.apply(this,arguments);var a=this.get("item");if(!a)throw"SC.TreeItemObserver.item cannot be null";a.addObserver("*",this,this._itemPropertyDidChange);this._itemPropertyDidChange(a,"*");this._notifyParent=YES},destroy:function(){this.invalidateBranchObserversAt(0);this._objectAtCache=null;var a=this.get("item");a&&a.removeObserver("*",this,this._itemPropertyDidChange);a=this._children;var b=this._childrenRangeObserver;
a&&b&&a.removeRangeObserver(b);arguments.callee.base.apply(this,arguments)},_itemPropertyDidChange:function(){var a=this.get("children"),b=this.get("disclosureState"),c=this.get("item"),d;this.beginPropertyChanges();d=this._computeDisclosureState(c);b!==d&&this.set("disclosureState",d);d=this._computeChildren(c);a!==d&&this.set("children",d);this.endPropertyChanges()},_childrenDidChange:function(){var a=this.get("disclosureState")===SC.BRANCH_OPEN?this.get("children"):null,b=this._children,c=this._childrenRangeObserver;
if(b===a)return this;c&&b.removeRangeObserver(c);this._childrenRangeObserver=a?a.addRangeObserver(null,this,this._childrenRangeDidChange):null;this._children=a;this._childrenRangeDidChange(a,null,"[]",null)}.observes("children","disclosureState"),_childrenRangeDidChange:function(a,b,c,d){a=(a=this.get("children"))?a.get("length"):0;b=d?d.get("min"):0;d=d?d.get("max"):a;c=this._childrenLen||0;this._childrenLen=a;this.observerContentDidChange(b,d-b,a-c)},_computeDisclosureState:function(a,b,c){if(!a||
!this._computeChildren(a))return SC.LEAF_NODE;else if(a.isTreeItemContent){if(b===undefined)b=this.get("parentItem");if(c===undefined)c=this.get("index");return a.treeItemDisclosureState(b,c)}else{b=this._treeItemIsExpandedKey;if(!b)this._treeItemIsExpandedKey=b=(b=this.get("delegate"))?b.get("treeItemIsExpandedKey"):"treeItemIsExpanded";return a.get(b)?SC.BRANCH_OPEN:SC.BRANCH_CLOSED}},_collapse:function(a,b,c){if(!a||!this._computeChildren(a))return this;else if(a.isTreeItemContent){if(b===undefined)b=
this.get("parentItem");if(c===undefined)c=this.get("index");a.treeItemCollapse(b,c)}else{b=this._treeItemIsExpandedKey;if(!b)this._treeItemIsExpandedKey=b=(b=this.get("delegate"))?b.get("treeItemIsExpandedKey"):"treeItemIsExpanded";a.setIfChanged(b,NO)}return this},_expand:function(a,b,c){if(!a||!this._computeChildren(a))return this;else if(a.isTreeItemContent){if(b===undefined)b=this.get("parentItem");if(c===undefined)c=this.get("index");a.treeItemExpand(b,c)}else{b=this._treeItemIsExpandedKey;if(!b)this._treeItemIsExpandedKey=
b=(b=this.get("delegate"))?b.get("treeItemIsExpandedKey"):"treeItemIsExpanded";a.setIfChanged(b,YES)}return this},_computeChildren:function(a){var b;if(a)if(a.isTreeItemContent)return a.get("treeItemChildren");else{b=this._treeItemChildrenKey;if(!b)this._treeItemChildrenKey=b=(b=this.get("delegate"))?b.get("treeItemChildrenKey"):"treeItemChildren";return a.get(b)}else return null},_computeLength:function(){var a=this.get("isHeaderVisible")?1:0,b=this.get("disclosureState"),c=this.get("children");
if(b===SC.BRANCH_OPEN&&c){a+=c.get("length");if(b=this.get("branchIndexes"))b.forEach(function(d){d=this.branchObserverAt(d);a+=d.get("length")-1},this)}return a}});sc_require("controllers/object");sc_require("mixins/selection_support");sc_require("private/tree_item_observer");
SC.TreeController=SC.ObjectController.extend(SC.SelectionSupport,{treeItemIsGrouped:NO,treeItemIsExpandedKey:"treeItemIsExpanded",treeItemChildrenKey:"treeItemChildren",arrangedObjects:function(){var a;return this._sctc_arrangedObjects=a=(a=this.get("content"))?SC.TreeItemObserver.create({item:a,delegate:this}):null}.property().cacheable(),_sctc_invalidateArrangedObjects:function(){this.propertyWillChange("arrangedObjects");var a=this._sctc_arrangedObjects;a&&a.destroy();this._sctc_arrangedObjects=
null;this.propertyDidChange("arrangedObjects")}.observes("content","treeItemIsExpandedKey","treeItemChildrenKey","treeItemIsGrouped"),_sctc_arrangedObjectsContentDidChange:function(){this.updateSelectionAfterContentChange()}.observes("*arrangedObjects.[]"),firstSelectableObject:function(){var a=this.get("arrangedObjects"),b,c,d=0;if(!a)return null;b=a.contentGroupIndexes(null,a);for(c=a.get("length");b.contains(d)&&d<c;)d++;return d>=c?null:a.objectAt(d)}.property()});
SC.mixin(SC.Object.prototype,{invokeLater:function(a,b){if(b===undefined)b=1;var c=a,d,e;if(arguments.length>2){d=SC.$A(arguments).slice(2);if(SC.typeOf(c)===SC.T_STRING)c=this[a];e=c;c=function(){return e.apply(this,d)}}return SC.Timer.schedule({target:this,action:c,interval:b})},invokeWith:function(a,b,c){if(c===undefined){c=b;b=this}b||(b=this);if(SC.typeOf(c)===SC.T_STRING)c=b[c];a=this.getPath(a);c.call(b,a,this);return this}});
SC.RunLoop=SC.RunLoop.extend({startTime:function(){if(!this._start)this._start=Date.now();return this._start}.property(),endRunLoop:function(){this.fireExpiredTimers();var a=arguments.callee.base.apply(this,arguments);this.scheduleNextTimeout();return a},scheduleTimer:function(a,b){this._timerQueue=a.removeFromTimerQueue(this._timerQueue);this._timerQueue=a.scheduleInTimerQueue(this._timerQueue,b);return this},cancelTimer:function(a){this._timerQueue=a.removeFromTimerQueue(this._timerQueue);return this},
TIMER_ARRAY:[],fireExpiredTimers:function(){if(!this._timerQueue||this._firing)return NO;var a=this.get("startTime"),b=this.TIMER_ARRAY,c;this._firing=YES;this._timerQueue=this._timerQueue.collectExpiredTimers(b,a);c=b.length;for(a=0;a<c;a++)b[a].fire();a=b.length>0;b.length=0;this._firing=NO;return a},scheduleNextTimeout:function(){var a=this._timerQueue,b=NO;if(a){a=a._timerQueueRunTime;if(this._timeoutAt!==a){this._timeout&&clearTimeout(this._timeout);b=Math.max(0,a-Date.now());this._timeout=setTimeout(this._timeoutDidFire,
b);this._timeoutAt=a}b=YES}else this._timeout&&clearTimeout(this._timeout);return b},_timeoutDidFire:function(){var a=SC.RunLoop.currentRunLoop;a._timeout=a._timeoutAt=null;SC.RunLoop.begin().end()}});SC.RunLoop.currentRunLoop=SC.RunLoop.create();
SC.Button={value:null,toggleOnValue:YES,toggleOffValue:NO,localize:NO,localizeBindingDefault:SC.Binding.bool(),title:"",contentTitleKey:null,icon:null,contentIconKey:null,needsEllipsis:YES,displayTitle:function(){var a=this.get("title");return a&&this.get("localize")?a.loc():a||""}.property("title","localize").cacheable(),keyEquivalent:null,renderTitle:function(a,b){var c=this.get("icon"),d="",e=this.get("displayTitle"),f=!SC.none(e)&&e.length>0;if(this.get("escapeHTML"))e=SC.RenderContext.escapeHTML(e);
if(c){f=SC.BLANK_IMAGE_URL;d=c.indexOf("/")>=0?'<img src="'+c+'" alt="" class="icon" />':'<img src="'+f+'" alt="" class="'+c+'" />';f=YES}c=d+e;if(b){this.get("needsEllipsis")?a.push('<label class="sc-button-label ellipsis">'+c+"</label>"):a.push('<label class="sc-button-label">'+c+"</label>");this._ImageTitleCached=c}else{b=this.$("label");if(e=b[0])if(f){this.get("needsEllipsis")?b.addClass("ellipsis"):b.removeClass("ellipsis");if(this._ImageTitleCached!==c){this._ImageTitleCached=c;e.innerHTML=
c}}else e.innerHTML=""}return a},contentPropertyDidChange:function(a,b){var c=this.get("displayDelegate");a=this.get("content");var d=this.getDelegateProperty("contentValueKey",c);if(d&&(b===d||b==="*"))this.set("value",a?a.get(d):null);if((d=this.getDelegateProperty("contentTitleKey",c))&&(b===d||b==="*"))this.set("title",a?a.get(d):null);if((c=this.getDelegateProperty("contentIconKey",c))&&(b===c||b==="*"))this.set("icon",a?a.get(c):null);return this},_button_displayObserver:function(){this.displayDidChange()}.observes("title",
"icon","value"),performKeyEquivalent:function(a,b){if(!this.get("isEnabled"))return NO;var c=this.get("keyEquivalent");if(c){if(c===a)return this.triggerAction(b)}else if(this.get("isDefault")&&a==="return"||this.get("isCancel")&&a==="escape")return this.triggerAction(b);return NO},triggerAction:function(){throw"SC.Button.triggerAction() is not defined in %@".fmt(this);},computeIsSelectedForValue:function(a){var b=this.get("toggleOnValue"),c,d;if(SC.typeOf(a)===SC.T_ARRAY)if(a.length===1)c=a[0]==
b;else{c=null;a.find(function(e){d=e==b;if(c===null)c=d;else if(d!==c)c=SC.MIXED_STATE;return c===SC.MIXED_STATE})}else c=a===SC.MIXED_STATE?SC.MIXED_STATE:a==b;return c},initMixin:function(){SC.none(this.get("value"))||this._button_valueDidChange()},_button_valueDidChange:function(){this.set("isSelected",this.computeIsSelectedForValue(this.get("value")))}.observes("value"),_button_isSelectedDidChange:function(){var a=this.get("isSelected"),b=this.computeIsSelectedForValue(this.get("value"));if(a!==
SC.MIXED_STATE&&b!==a)this.set("value",this.get(a?"toggleOnValue":"toggleOffValue"))}.observes("isSelected")};
SC.ContentDisplay={concatenatedProperties:"contentDisplayProperties",displayProperties:["content"],contentDisplayProperties:[],_display_contentDidChange:function(a,b,c){if((c=this.get("content"))!=this._display_content){a=this._display_contentPropertyDidChange;if(b=this._display_content)if(SC.isArray(b))b.invoke("removeObserver","*",this,a);else b.removeObserver&&b.removeObserver("*",this,a);if(b=this._display_content=c)if(SC.isArray(b))b.invoke("addObserver","*",this,a);else b.addObserver&&b.addObserver("*",
this,a);this.allPropertiesDidChange();this.endPropertyChanges()}}.observes("content","contentDisplayProperties"),_display_contentPropertyDidChange:function(a,b){if(b==="*")this.displayDidChange();else(a=this.get("contentDisplayProperties"))&&a.indexOf(b)>=0&&this.displayDidChange()}};sc_require("system/locale");SC.STRING_TITLEIZE_REGEXP=/([\s|\-|\_|\n])([^\s|\-|\_|\n]?)/g;SC.STRING_DECAMELIZE_REGEXP=/([a-z])([A-Z])/g;SC.STRING_DASHERIZE_REGEXP=/[ _]/g;SC.STRING_HUMANIZE_REGEXP=/[\-_]/g;
SC.STRING_TRIM_REGEXP=/^\s+|\s+$/g;SC.STRING_TRIM_LEFT_REGEXP=/^\s+/g;SC.STRING_TRIM_RIGHT_REGEXP=/\s+$/g;SC.STRING_REGEXP_ESCAPED_REGEXP=/([\\\.\+\*\?\[\^\]\$\(\)\{\}\=\!\<\>\|\:])/g;
SC.String={loc:function(){SC.Locale.currentLocale||SC.Locale.createCurrentLocale();var a=SC.Locale.currentLocale.locWithDefault(this)||this;return a.fmt.apply(a,arguments)},locWithDefault:function(a){SC.Locale.currentLocale||SC.Locale.createCurrentLocale();var b=SC.Locale.currentLocale.locWithDefault(a)||this,c=SC.$A(arguments);c.shift();return b.fmt.apply(b,c)},capitalize:function(){return this.charAt(0).toUpperCase()+this.slice(1)},capitalizeEach:function(){return this.replace(SC.STRING_TITLEIZE_REGEXP,
function(a,b,c){return c?b+c.toUpperCase():b}).capitalize()},titleize:function(){return this.replace(SC.STRING_DECAMELIZE_REGEXP,"$1_$2").replace(SC.STRING_TITLEIZE_REGEXP,function(a,b,c){return c?" "+c.toUpperCase():" "}).capitalize()},camelize:function(){var a=this.replace(SC.STRING_TITLEIZE_REGEXP,function(d,e,f){return f?f.toUpperCase():""}),b=a.charAt(0),c=b.toLowerCase();return b!==c?c+a.slice(1):a},classify:function(){var a=this.replace(SC.STRING_TITLEIZE_REGEXP,function(d,e,f){return f?f.toUpperCase():
""}),b=a.charAt(0),c=b.toUpperCase();return b!==c?c+a.slice(1):a},decamelize:function(){return this.replace(SC.STRING_DECAMELIZE_REGEXP,"$1_$2").toLowerCase()},dasherize:function(){return this.decamelize().replace(SC.STRING_DASHERIZE_REGEXP,"-")},humanize:function(){return this.decamelize().replace(SC.STRING_HUMANIZE_REGEXP," ")},escapeForRegExp:function(){return this.replace(SC.STRING_REGEXP_ESCAPED_REGEXP,"\\$1")},removeDiacritics:function(){var a=SC.diacriticMappingTable;if(!a){SC.diacriticMappingTable=
{"\u00c0":"A","\u00c1":"A","\u00c2":"A","\u00c3":"A","\u00c4":"A","\u00c5":"A","\u0100":"A","\u0102":"A","\u0104":"A","\u01cd":"A","\u01de":"A","\u01e0":"A","\u01fa":"A","\u0200":"A","\u0202":"A","\u0226":"A","\u1e00":"A","\u1ea0":"A","\u1ea2":"A","\u1ea4":"A","\u1ea6":"A","\u1ea8":"A","\u1eaa":"A","\u1eac":"A","\u1eae":"A","\u1eb0":"A","\u1eb2":"A","\u1eb4":"A","\u1eb6":"A","\u212b":"A","\u1e02":"B","\u1e04":"B","\u1e06":"B","\u00c7":"C","\u0106":"C","\u0108":"C","\u010a":"C","\u010c":"C","\u1e08":"C",
"\u010e":"D","\u1e0a":"D","\u1e0c":"D","\u1e0e":"D","\u1e10":"D","\u1e12":"D","\u00c8":"E","\u00c9":"E","\u00ca":"E","\u00cb":"E","\u0112":"E","\u0114":"E","\u0116":"E","\u0118":"E","\u011a":"E","\u0204":"E","\u0206":"E","\u0228":"E","\u1e14":"E","\u1e16":"E","\u1e18":"E","\u1e1a":"E","\u1e1c":"E","\u1eb8":"E","\u1eba":"E","\u1ebc":"E","\u1ebe":"E","\u1ec0":"E","\u1ec2":"E","\u1ec4":"E","\u1ec6":"E","\u1e1e":"F","\u011c":"G","\u011e":"G","\u0120":"G","\u0122":"G","\u01e6":"G","\u01f4":"G","\u1e20":"G",
"\u0124":"H","\u021e":"H","\u1e22":"H","\u1e24":"H","\u1e26":"H","\u1e28":"H","\u1e2a":"H","\u00cc":"I","\u00cd":"I","\u00ce":"I","\u00cf":"I","\u0128":"I","\u012a":"I","\u012c":"I","\u012e":"I","\u0130":"I","\u01cf":"I","\u0208":"I","\u020a":"I","\u1e2c":"I","\u1e2e":"I","\u1ec8":"I","\u1eca":"I","\u0134":"J","\u0136":"K","\u01e8":"K","\u1e30":"K","\u1e32":"K","\u1e34":"K","\u0139":"L","\u013b":"L","\u013d":"L","\u1e36":"L","\u1e38":"L","\u1e3a":"L","\u1e3c":"L","\u1e3e":"M","\u1e40":"M","\u1e42":"M",
"\u00d1":"N","\u0143":"N","\u0145":"N","\u0147":"N","\u01f8":"N","\u1e44":"N","\u1e46":"N","\u1e48":"N","\u1e4a":"N","\u00d2":"O","\u00d3":"O","\u00d4":"O","\u00d5":"O","\u00d6":"O","\u014c":"O","\u014e":"O","\u0150":"O","\u01a0":"O","\u01d1":"O","\u01ea":"O","\u01ec":"O","\u020c":"O","\u020e":"O","\u022a":"O","\u022c":"O","\u022e":"O","\u0230":"O","\u1e4c":"O","\u1e4e":"O","\u1e50":"O","\u1e52":"O","\u1ecc":"O","\u1ece":"O","\u1ed0":"O","\u1ed2":"O","\u1ed4":"O","\u1ed6":"O","\u1ed8":"O","\u1eda":"O",
"\u1edc":"O","\u1ede":"O","\u1ee0":"O","\u1ee2":"O","\u1e54":"P","\u1e56":"P","\u0154":"R","\u0156":"R","\u0158":"R","\u0210":"R","\u0212":"R","\u1e58":"R","\u1e5a":"R","\u1e5c":"R","\u1e5e":"R","\u015a":"S","\u015c":"S","\u015e":"S","\u0160":"S","\u0218":"S","\u1e60":"S","\u1e62":"S","\u1e64":"S","\u1e66":"S","\u1e68":"S","\u0162":"T","\u0164":"T","\u021a":"T","\u1e6a":"T","\u1e6c":"T","\u1e6e":"T","\u1e70":"T","\u00d9":"U","\u00da":"U","\u00db":"U","\u00dc":"U","\u0168":"U","\u016a":"U","\u016c":"U",
"\u016e":"U","\u0170":"U","\u0172":"U","\u01af":"U","\u01d3":"U","\u01d5":"U","\u01d7":"U","\u01d9":"U","\u01db":"U","\u0214":"U","\u0216":"U","\u1e72":"U","\u1e74":"U","\u1e76":"U","\u1e78":"U","\u1e7a":"U","\u1ee4":"U","\u1ee6":"U","\u1ee8":"U","\u1eea":"U","\u1eec":"U","\u1eee":"U","\u1ef0":"U","\u1e7c":"V","\u1e7e":"V","\u0174":"W","\u1e80":"W","\u1e82":"W","\u1e84":"W","\u1e86":"W","\u1e88":"W","\u1e8a":"X","\u1e8c":"X","\u00dd":"Y","\u0176":"Y","\u0178":"Y","\u0232":"Y","\u1e8e":"Y","\u1ef2":"Y",
"\u1ef4":"Y","\u1ef6":"Y","\u1ef8":"Y","\u0179":"Z","\u017b":"Z","\u017d":"Z","\u1e90":"Z","\u1e92":"Z","\u1e94":"Z","\u1fef":"`","\u00e0":"a","\u00e1":"a","\u00e2":"a","\u00e3":"a","\u00e4":"a","\u00e5":"a","\u0101":"a","\u0103":"a","\u0105":"a","\u01ce":"a","\u01df":"a","\u01e1":"a","\u01fb":"a","\u0201":"a","\u0203":"a","\u0227":"a","\u1e01":"a","\u1ea1":"a","\u1ea3":"a","\u1ea5":"a","\u1ea7":"a","\u1ea9":"a","\u1eab":"a","\u1ead":"a","\u1eaf":"a","\u1eb1":"a","\u1eb3":"a","\u1eb5":"a","\u1eb7":"a",
"\u1e03":"b","\u1e05":"b","\u1e07":"b","\u00e7":"c","\u0107":"c","\u0109":"c","\u010b":"c","\u010d":"c","\u1e09":"c","\u010f":"d","\u1e0b":"d","\u1e0d":"d","\u1e0f":"d","\u1e11":"d","\u1e13":"d","\u00e8":"e","\u00e9":"e","\u00ea":"e","\u00eb":"e","\u0113":"e","\u0115":"e","\u0117":"e","\u0119":"e","\u011b":"e","\u0205":"e","\u0207":"e","\u0229":"e","\u1e15":"e","\u1e17":"e","\u1e19":"e","\u1e1b":"e","\u1e1d":"e","\u1eb9":"e","\u1ebb":"e","\u1ebd":"e","\u1ebf":"e","\u1ec1":"e","\u1ec3":"e","\u1ec5":"e",
"\u1ec7":"e","\u1e1f":"f","\u011d":"g","\u011f":"g","\u0121":"g","\u0123":"g","\u01e7":"g","\u01f5":"g","\u1e21":"g","\u0125":"h","\u021f":"h","\u1e23":"h","\u1e25":"h","\u1e27":"h","\u1e29":"h","\u1e2b":"h","\u1e96":"h","\u00ec":"i","\u00ed":"i","\u00ee":"i","\u00ef":"i","\u0129":"i","\u012b":"i","\u012d":"i","\u012f":"i","\u01d0":"i","\u0209":"i","\u020b":"i","\u1e2d":"i","\u1e2f":"i","\u1ec9":"i","\u1ecb":"i","\u0135":"j","\u01f0":"j","\u0137":"k","\u01e9":"k","\u1e31":"k","\u1e33":"k","\u1e35":"k",
"\u013a":"l","\u013c":"l","\u013e":"l","\u1e37":"l","\u1e39":"l","\u1e3b":"l","\u1e3d":"l","\u1e3f":"m","\u1e41":"m","\u1e43":"m","\u00f1":"n","\u0144":"n","\u0146":"n","\u0148":"n","\u01f9":"n","\u1e45":"n","\u1e47":"n","\u1e49":"n","\u1e4b":"n","\u00f2":"o","\u00f3":"o","\u00f4":"o","\u00f5":"o","\u00f6":"o","\u014d":"o","\u014f":"o","\u0151":"o","\u01a1":"o","\u01d2":"o","\u01eb":"o","\u01ed":"o","\u020d":"o","\u020f":"o","\u022b":"o","\u022d":"o","\u022f":"o","\u0231":"o","\u1e4d":"o","\u1e4f":"o",
"\u1e51":"o","\u1e53":"o","\u1ecd":"o","\u1ecf":"o","\u1ed1":"o","\u1ed3":"o","\u1ed5":"o","\u1ed7":"o","\u1ed9":"o","\u1edb":"o","\u1edd":"o","\u1edf":"o","\u1ee1":"o","\u1ee3":"o","\u1e55":"p","\u1e57":"p","\u0155":"r","\u0157":"r","\u0159":"r","\u0211":"r","\u0213":"r","\u1e59":"r","\u1e5b":"r","\u1e5d":"r","\u1e5f":"r","\u015b":"s","\u015d":"s","\u015f":"s","\u0161":"s","\u0219":"s","\u1e61":"s","\u1e63":"s","\u1e65":"s","\u1e67":"s","\u1e69":"s","\u0163":"t","\u0165":"t","\u021b":"t","\u1e6b":"t",
"\u1e6d":"t","\u1e6f":"t","\u1e71":"t","\u1e97":"t","\u00f9":"u","\u00fa":"u","\u00fb":"u","\u00fc":"u","\u0169":"u","\u016b":"u","\u016d":"u","\u016f":"u","\u0171":"u","\u0173":"u","\u01b0":"u","\u01d4":"u","\u01d6":"u","\u01d8":"u","\u01da":"u","\u01dc":"u","\u0215":"u","\u0217":"u","\u1e73":"u","\u1e75":"u","\u1e77":"u","\u1e79":"u","\u1e7b":"u","\u1ee5":"u","\u1ee7":"u","\u1ee9":"u","\u1eeb":"u","\u1eed":"u","\u1eef":"u","\u1ef1":"u","\u1e7d":"v","\u1e7f":"v","\u0175":"w","\u1e81":"w","\u1e83":"w",
"\u1e85":"w","\u1e87":"w","\u1e89":"w","\u1e98":"w","\u1e8b":"x","\u1e8d":"x","\u00fd":"y","\u00ff":"y","\u0177":"y","\u0233":"y","\u1e8f":"y","\u1e99":"y","\u1ef3":"y","\u1ef5":"y","\u1ef7":"y","\u1ef9":"y","\u017a":"z","\u017c":"z","\u017e":"z","\u1e91":"z","\u1e93":"z","\u1e95":"z"};a=SC.diacriticMappingTable}for(var b,c,d="",e=this.length,f=0;f<=e;++f){b=this.charAt(f);c=a[b];d+=c?c:b}return d},trim:function(){return this.replace(SC.STRING_TRIM_REGEXP,"")},trimLeft:function(){return this.replace(SC.STRING_TRIM_LEFT_REGEXP,
"")},trimRight:function(){return this.replace(SC.STRING_TRIM_RIGHT_REGEXP,"")}};SC.String.strip=SC.String.trim;SC.supplement(String.prototype,SC.String);String.prototype.loc=SC.String.loc;SC.String.fmt=String.prototype.fmt;sc_require("mixins/string");SC.MIXED_STATE="__MIXED__";SC.HUGE_CONTROL_SIZE="sc-huge-size";SC.LARGE_CONTROL_SIZE="sc-large-size";SC.REGULAR_CONTROL_SIZE="sc-regular-size";SC.SMALL_CONTROL_SIZE="sc-small-size";SC.TINY_CONTROL_SIZE="sc-tiny-size";
SC.Control={initMixin:function(){this._control_contentDidChange()},isSelected:NO,isSelectedBindingDefault:SC.Binding.oneWay().bool(),isActive:NO,isActiveBindingDefault:SC.Binding.oneWay().bool(),value:null,content:null,contentValueKey:null,contentPropertyDidChange:function(a,b){return this.updatePropertyFromContent("value",b,"contentValueKey")},updatePropertyFromContent:function(a,b,c,d){var e=b==="*";if(c===undefined)c="content"+a.capitalize()+"Key";if(d===undefined)d=this.get("content");if((c=this[c]?
this.get(c):this.getDelegateProperty(c,this.displayDelegate))&&(e||b===c)){b=d?d.get?d.get(c):d[c]:null;this.set(a,b)}return this},updateContentWithValueObserver:function(){var a=this.contentValueKey?this.get("contentValueKey"):this.getDelegateProperty("contentValueKey",this.displayDelegate),b=this.get("content");if(a&&b){var c=this.get("value");if(typeof b.setIfChanged===SC.T_FUNCTION)b.setIfChanged(a,c);else if(b[a]!==c)b[a]=c}}.observes("value"),fieldKey:null,fieldLabel:null,errorLabel:function(){var a,
b;if(a=this.get("fieldLabel"))return a;a=this.get("fieldKey")||this.constructor.toString();b=(a||"").humanize().capitalize();return"ErrorLabel."+a.locWithDefault(("FieldKey."+a).locWithDefault(b))}.property("fieldLabel","fieldKey").cacheable(),controlSize:SC.REGULAR_CONTROL_SIZE,displayProperties:"isEnabled isSelected isActive controlSize".w(),_CONTROL_TMP_CLASSNAMES:{},renderMixin:function(a,b){var c=this.get("isSelected"),d=!this.get("isEnabled"),e=this._CONTROL_TMP_CLASSNAMES;e.mixed=c===SC.MIXED_STATE;
e.sel=c&&c!==SC.MIXED_STATE;e.active=this.get("isActive");a.setClass(e).addClass(this.get("controlSize"));!b&&this.$input&&this.$input().attr("type")!=="radio"&&this.$input().attr("disabled",d)},_control_content:null,_control_contentDidChange:function(){var a=this.get("content");if(this._control_content!==a){var b=this.contentPropertyDidChange,c=this._control_content;c&&c.removeObserver&&c.removeObserver("*",this,b);(this._control_content=a)&&a.addObserver&&a.addObserver("*",this,b);this.contentPropertyDidChange(a,
"*")}}.observes("content")};SC.Editable={isEditable:NO,isEditing:NO,beginEditing:function(){if(!this.get("isEditable"))return NO;if(this.get("isEditing"))return YES;this.set("isEditing",YES);this.becomeFirstResponder();return YES},discardEditing:function(){return!this.get("isEditing")},commitEditing:function(){if(!this.get("isEditing"))return YES;this.set("isEditing",NO);this.resignFirstResponder();return YES}};
SC.browser=function(){var a=navigator.userAgent.toLowerCase(),b=(a.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[])[1];a={version:b,safari:/webkit/.test(a)?b:0,opera:/opera/.test(a)?b:0,msie:/msie/.test(a)&&!/opera/.test(a)?b:0,mozilla:/mozilla/.test(a)&&!/(compatible|webkit)/.test(a)?b:0,mobileSafari:/apple.*mobile.*safari/.test(a)?b:0,windows:!!/(windows)/.test(a),mac:!!(/(macintosh)/.test(a)||/(mac os x)/.test(a)),language:(navigator.language||navigator.browserLanguage).split("-",1)[0],touch:"createTouch"in
document};SC.extend(a,{isOpera:!!a.opera,isIe:!!a.msie,isIE:!!a.msie,isSafari:!!a.safari,isMobileSafari:!!a.mobileSafari,isMozilla:!!a.mozilla,isWindows:!!a.windows,isMac:!!a.mac,current:a.msie?"msie":a.mozilla?"mozilla":a.safari?"safari":a.opera?"opera":"unknown",compareVersion:function(){if(this._versionSplit===undefined){function c(g){return Number(g.match(/^[0-9]+/))}this._versionSplit=SC.A(this.version.split(".")).map(c)}for(var d=SC.A(arguments).map(Number),e=0;e<d.length;e++){var f=this._versionSplit[e]-
d[e];if(isNaN(f))return 0;if(f!==0)return f}return 0}});return a}();SC.Builder=function(a){return SC.Builder.create(a)};SC.Builder.create=function(a){var b=SC.mixin(SC.beget(this.fn),a||{});if(a.hasOwnProperty("toString"))b.toString=a.toString;var c=function(){var d=SC.beget(b);d.defaultClass=this;d.constructor=c;return d.init.apply(d,arguments)};c.fn=c.prototype=b;c.extend=SC.Builder.create;c.mixin=SC.Builder.mixin;return c};
SC.Builder.mixin=function(){var a=arguments.length,b;for(b=0;b<a;b++)SC.mixin(this,arguments[b]);return this};
SC.Builder.fn={init:function(a){if(a!==undefined)if(SC.typeOf(a)===SC.T_ARRAY){for(var b=a.length;--b>=0;)this[b]=a.objectAt?a.objectAt(b):a[b];this.length=a.length}else{this[0]=a;this.length=1}return this},size:function(){return this.length},pushStack:function(){var a=this.constructor.apply(this,arguments);a.prevObject=this;return a},end:function(){return this.prevObject||this.constructor()},toString:function(){return"%@$(%@)".fmt(this.defaultClass.toString(),SC.A(this).invoke("toString").join(","))},
mixin:SC.Builder.mixin};(function(){var a=SC.Enumerable,b=SC.Builder.fn,c,d;for(c in a)if(a.hasOwnProperty(c)){d=Array.prototype[c]||a[c];b[c]=d}})();sc_require("system/builder");
SC.CoreQuery=function(){function a(p,t){return p[0]&&parseInt(z.curCSS(p[0],t,true),10)||0}var b=/^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/,c=/^.[^:#\[\.]*$/,d=/ CQ\d+="(?:\d+|null)"/g,e=/(<(\w+)[^>]*?)\/>/g,f=/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i,g=/\s+/,h=/^\s+/,j=/^body|html$/i,k=/href|src|style/,l=/(button|input|object|select|textarea)/i,m=/alpha\([^)]*\)/,n=/opacity=([^)]*)/,o=SC.browser.msie?"styleFloat":"cssFloat",r=SC.browser.safari&&parseInt(SC.browser.version,0)<417?"(?:[\\w*_-]|\\\\.)":
"(?:[\\w\u0128-\uffff*_-]|\\\\.)",u=new RegExp("^([#.]?)("+r+"*)"),q=new RegExp("([#.]?)("+r+"*)","g"),s=["Left","Right"],w=["Top","Bottom"],v={position:"absolute",visibility:"hidden",display:"block"},x=function(p,t,A){t=t==="width"?p.offsetWidth:p.offsetHeight;for(var C=0,B=0,G=A.length,J;--G>=0;){J=A[G];C+=parseFloat(z.curCSS(p,"padding"+J,true))||0;B+=parseFloat(z.curCSS(p,"border"+J+"Width",true))||0}t-=Math.round(C+B);return t},y=/z-?index|font-?weight|opacity|zoom|line-?height/i,D=document.defaultView||
{},K=function(p){if(!SC.browser.safari)return false;p=D.getComputedStyle(p,null);return!p||p.getPropertyValue("color")===""},z;z=r=SC.Builder.create({jquery:"SC.CoreQuery",init:function(p,t){p=p||document;if(p.nodeType){this[0]=p;this.length=1;return this}else if(typeof p==="string"){var A=b.exec(p);if(A&&(A[1]||!t))if(A[1])p=z.clean([A[1]],t);else{if(t=document.getElementById(A[3])){if(t.id!=A[3])return z().find(p);return z(t)}p=[]}else return z(t).find(p)}else if(SC.typeOf(p)===SC.T_FUNCTION)return SC.ready(p);
return this.setArray(z.makeArray(p))},size:function(){return this.length},get:function(p){return p===undefined?z.makeArray(this):this[p]},find:function(p){return this.pushStack(z.map(this,function(t){return z.find(p,t)}))},filter:function(p){return this.pushStack(SC.typeOf(p)===SC.T_FUNCTION&&z.grep(this,function(t,A){return p.call(t,A)})||z.multiFilter(p,this))},not:function(p){if(typeof p==="string")if(c.test(p))return this.pushStack(z.multiFilter(p,this,true));else p=z.multiFilter(p,this);var t=
p.length&&p[p.length-1]!==undefined&&!p.nodeType;return this.filter(function(){return t?z.inArray(this,p)<0:this!=p})},setArray:function(p){this.length=0;Array.prototype.push.apply(this,p);return this},map:function(p){return this.pushStack(z.map(this,function(t,A){return p.call(t,A,t)}))},each:function(p,t){return z.each(this,p,t)},index:function(p){if(p&&p.jquery)p=p[0];return Array.prototype.indexOf.call(this,p)},eq:function(p){return this.slice(p,+p+1)},slice:function(){return this.pushStack(Array.prototype.slice.apply(this,
arguments))},add:function(p){return this.pushStack(z.merge(this.get(),typeof p==="string"?z(p):z.makeArray(p)).uniq())},attr:function(p,t,A){var C=p;if(typeof p==="string")if(t===undefined)return this[0]&&z[A||"attr"](this[0],p);else{C={};C[p]=t}return this.each(function(B){for(p in C)z.attr(A?this.style:this,p,z.prop(this,C[p],A,B,p))})},html:function(p){return p===undefined?this[0]?this[0].innerHTML.replace(d,""):null:this.empty().append(p)},andSelf:function(){return this.add(this.prevObject)},
is:function(p){return!!p&&z.multiFilter(p,this).length>0},hasClass:function(p){return Array.prototype.every.call(this,function(t){return t.nodeType===1&&z.className.has(t,p)})},val:function(p){if(p===undefined){var t=this[0];if(t){if(z.nodeName(t,"option"))return(t.attributes.value||{}).specified?t.value:t.text;if(z.nodeName(t,"select")){var A=t.selectedIndex,C=[],B=t.options;t=t.type==="select-one";if(A<0)return null;var G,J=t?A+1:B.length;for(G=t?A:0;G<J;G++){A=B[G];if(A.selected){p=z(A).val();
if(t)return p;C.push(p)}}return C}return(t.value||"").replace(/\r/g,"")}}else{if(typeof p==="number")p+="";this.each(function(){if(this.nodeType===1)if(SC.typeOf(p)===SC.T_ARRAY&&/radio|checkbox/.test(this.type))this.checked=z.inArray(this.value,p)>=0||z.inArray(this.name,p)>=0;else if(z.nodeName(this,"select")){var F=z.makeArray(p);z("option",this).each(function(){this.selected=z.inArray(this.value,F)>=0||z.inArray(this.text,F)>=0});if(!F.length)this.selectedIndex=-1}else this.value=p});return this}},
clone:function(){var p=this.map(function(){if(SC.browser.msie&&!z.isXMLDoc(this)){var t=this.cloneNode(true),A=document.createElement("div");A.appendChild(t);return z.clean([A.innerHTML])[0]}else return this.cloneNode(true)});p.find("*").andSelf().each(function(){if(this[SC.guidKey]!==undefined)this[SC.guidKey]=null});return p},css:function(p,t){if((p==="width"||p==="height")&&parseFloat(t,0)<0)t=undefined;return this.attr(p,t,"curCSS")},text:function(p){if(p!==undefined&&typeof p!=="object"&&p!=
null)return this.empty().append((this[0]&&this[0].ownerDocument||document).createTextNode(p));var t="";z.each(p||this,function(){z.each(this.childNodes,function(){if(this.nodeType!==8)t+=this.nodeType!==1?this.nodeValue:z.fn.text([this])})});return t},show:function(){var p=SC.$.isVisible;this.each(function(){if(!p(this)){this.style.display=this.oldblock||"";if(z.css(this,"display")==="none"){var t=z("<"+this.tagName+"/>");z("body").append(t);this.style.display=t.css("display");if(this.style.display===
"none")this.style.display="block";t.remove()}}});return this},hide:function(){var p=SC.$.isVisible;this.each(function(){if(p(this)){this.oldblock=this.oldblock||z.css(this,"display");this.style.display="none"}});return this},domManip:function(p,t,A,C){var B=this.length>1,G;return this.each(function(){if(!G){G=z.clean(p,this.ownerDocument);A&&G.reverse()}var J=this;if(t&&z.nodeName(this,"table")&&z.nodeName(G[0],"tr"))J=this.getElementsByTagName("tbody")[0]||this.appendChild(this.ownerDocument.createElement("tbody"));
z.each(G,function(){var F=B?z(this).clone(true)[0]:this;C.call(J,F)})})},append:function(){return this.domManip(arguments,true,false,function(p){this.nodeType===1&&this.appendChild(p)})},prepend:function(){return this.domManip(arguments,true,true,function(p){this.nodeType===1&&this.insertBefore(p,this.firstChild)})},before:function(){return this.domManip(arguments,false,false,function(p){this.parentNode.insertBefore(p,this)})},after:function(){return this.domManip(arguments,false,true,function(p){this.parentNode.insertBefore(p,
this.nextSibling)})},replaceWith:function(p){return this.after(p).remove()},removeData:function(p){return this.each(function(){SC.removeData(this,p)})}});r.mixin({nodeName:function(p,t){return p.nodeName&&p.nodeName.toUpperCase()===t.toUpperCase()},map:function(p,t){var A=[],C,B,G;B=0;for(G=p.length;B<G;B++){C=t(p[B],B);if(C!=null)A[A.length]=C}return A.concat.apply([],A)},each:function(p,t,A){var C,B=0,G=p.length;if(A)if(G===undefined)for(C in p){if(t.apply(p[C],A)===false)break}else for(;B<G;){if(t.apply(p[B++],
A)===false)break}else if(G===undefined)for(C in p){if(t.call(p[C],C,p[C])===false)break}else for(A=p[0];B<G&&t.call(A,B,A)!==false;A=p[++B]);return p},isXMLDoc:function(p){return p.documentElement&&!p.body||p.tagName&&p.ownerDocument&&!p.ownerDocument.body},clean:function(p,t){var A=[];t=t||document;if(typeof t.createElement=="undefined")t=t.ownerDocument||t[0]&&t[0].ownerDocument||document;z.each(p,function(C,B){if(typeof B==="number")B+="";if(B){if(typeof B==="string"){B=B.replace(e,function(F,
E,H){return H.match(f)?F:E+"></"+H+">"});var G=B.replace(h,"").substring(0,10).toLowerCase();C=t.createElement("div");var J=!G.indexOf("<opt")&&[1,"<select multiple='multiple'>","</select>"]||!G.indexOf("<leg")&&[1,"<fieldset>","</fieldset>"]||G.match(/^<(thead|tbody|tfoot|colg|cap)/)&&[1,"<table>","</table>"]||!G.indexOf("<tr")&&[2,"<table><tbody>","</tbody></table>"]||(!G.indexOf("<td")||!G.indexOf("<th"))&&[3,"<table><tbody><tr>","</tr></tbody></table>"]||!G.indexOf("<col")&&[2,"<table><tbody></tbody><colgroup>",
"</colgroup></table>"]||SC.browser.msie&&[1,"div<div>","</div>"]||[0,"",""];for(C.innerHTML=J[1]+B+J[2];J[0]--;)C=C.lastChild;if(SC.browser.msie){G=!G.indexOf("<table")&&G.indexOf("<tbody")<0?C.firstChild&&C.firstChild.childNodes:J[1]==="<table>"&&G.indexOf("<tbody")<0?C.childNodes:[];for(J=G.length-1;J>=0;--J)z.nodeName(G[J],"tbody")&&!G[J].childNodes.length&&G[J].parentNode.removeChild(G[J]);/^\s/.test(B)&&C.insertBefore(t.createTextNode(B.match(/^\s*/)[0]),C.firstChild)}B=z.makeArray(C.childNodes)}if(!(B.length===
0&&!z.nodeName(B,"form")&&!z.nodeName(B,"select")))if(B[0]===undefined||z.nodeName(B,"form")||B.options)A.push(B);else A=z.merge(A,B)}});return A},find:function(p,t){var A;if(typeof p!=="string")return[p];if(p.indexOf(",")>=0){A=p.split(",").map(function(M){return z.find(M,t)});return A.concat.apply([],A).uniq()}if(t&&t.nodeType!==1&&t.nodeType!==9)return[];t=t||document;A=[t];for(var C=YES,B=p.match(q),G=B.length,J=0;J<G;J++){p=B[J];if(p===" "||p==="")C=YES;else if(C){p=u.exec(p);if(p[1]===""&&J<
G-1&&B[J+1].charAt(0)==="#"){p=B[J+1];B[J+1]=B[J];p=u.exec(p)}C=[];var F=A.length,E,H,I=p[2],L;for(E=0;E<F;E++){H=A[E];switch(p[1]){case "":I||(I="*");if(I==="*"&&H.nodeName.toLowerCase()==="object")I="param";C=z.merge(C,H.getElementsByTagName(I));break;case "#":if(H===document){L=document.getElementById(I);if(SC.browser.msie&&L&&L.getAttribute("id")!==I)L=NO;else{L&&C.push(L);L=YES}}else L=NO;if(!L){L=H.getElementsByTagName("*");(L=Array.prototype.find.call(L,function(M){return M.getAttribute&&M.getAttribute("id")===
I}))&&C.push(L)}break;case ".":C=H.getElementsByClassName?z.merge(C,H.getElementsByClassName(I)):z.merge(C,z.classFilter(H.getElementsByTagName("*"),I));break;default:}}delete A;A=C;C=NO}else A=z.filter(p,A)}A&&A[0]==t&&A.shift();return A.uniq()},classFilter:function(p,t,A){t=" "+t+" ";for(var C=[],B,G=0;p[G];G++){B=(" "+p[G].className+" ").indexOf(t)>=0;if(!A&&B||A&&!B)C.push(p[G])}return C},filter:function(p,t,A){p=u.exec(p);var C=p[2];p=p[1];if(p===".")return z.classFilter(z.makeArray(t),C,A);
else{p=p==="#"?function(B){B=B&&B.getAttribute&&B.getAttribute("id")===C;return A?!B:B}:function(B){B=z.nodeName(B,C);return A?!B:B};return Array.prototype.filter.call(z.makeArray(t),p)}},multiFilter:function(p,t,A){p=p.indexOf(",")?p.split(","):[p];for(var C=p.length,B,G=[];--C>=0;){B=z.filter(p[C].trim(),t,A);G=A?(t=B):z.merge(B,G)}return G},merge:function(p,t){var A=0,C,B=p.length;if(SC.browser.msie)for(;C=t[A++];){if(C.nodeType!==8)p[B++]=C}else for(;C=t[A++];)p[B++]=C;return p},makeArray:function(p){var t=
[];if(p!==undefined||p!=null){var A=p.length;if(A==null||typeof p==="string"||p.setInterval)t[0]=p;else for(;A;)t[--A]=p[A]}return t},inArray:function(p,t){return t.indexOf?t.indexOf(p):Array.prototype.indexOf.call(t,p)},boxModel:!SC.browser.msie||document.compatMode==="CSS1Compat",props:{"for":"htmlFor","class":"className","float":o,cssFloat:o,styleFloat:o,readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan"},prop:function(p,t,A,C,B){if(SC.typeOf(t)===SC.T_FUNCTION)t=
t.call(p,C);return t&&typeof t==="number"&&A==="curCSS"&&!y.test(B)?t+"px":t},grep:function(p,t,A){for(var C=[],B=0,G=p.length;B<G;B++)!A!=!t(p[B],B)&&C.push(p[B]);return C},className:{add:function(p,t){var A=z.className.has;z.each((t||"").split(g),function(C,B){if(p.nodeType===1&&!A(p.className,B))p.className+=(p.className?" ":"")+B})},remove:function(p,t){if(p.nodeType===1)p.className=t!==undefined?z.grep(p.className.split(g),function(A){return!z.className.has(t,A)}).join(" "):""},has:function(p,
t){return p&&z.inArray(t,(p.className||p).toString().split(g))>-1}},swap:function(p,t,A,C,B){var G={},J;for(J in t){G[J]=p.style[J];p.style[J]=t[J]}A=A(p,C,B);for(J in t)p.style[J]=G[J];return A},css:function(p,t,A){if(t==="width"||t==="height"){A=t==="width"?s:w;p=SC.$.isVisible(p)?x(p,t,A):z.swap(p,v,x,t,A);return Math.max(0,p)}return z.curCSS(p,t,A)},curCSS:function(p,t,A){var C,B=p.style;if(t==="opacity"&&SC.browser.msie){C=z.attr(B,"opacity");return C===""?"1":C}if(SC.browser.opera&&t==="display"){var G=
B.outline;B.outline="0 solid black";B.outline=G}if(G=t.match(/float/i))t=o;if(!A&&B&&B[t])C=B[t];else if(D.getComputedStyle){if(G)t="float";t=t.replace(/([A-Z])/g,"-$1").toLowerCase();if((C=D.getComputedStyle(p,null))&&!K(p,D))C=C.getPropertyValue(t);else{B=[];A=[];G=p;for(p=0;G&&K(G);G=G.parentNode)A.unshift(G);for(G=A.length;p<G;p++)if(K(A[p])){B[p]=A[p].style.display;A[p].style.display="block"}C=t==="display"&&B[A.length-1]!==null?"none":C&&C.getPropertyValue(t)||"";p=0;for(G=B.length;p<G;p++)if(B[p]!==
null)A[p].style.display=B[p]}if(t==="opacity"&&C==="")C="1"}else if(p.currentStyle){C=p.currentStyle[t]||p.currentStyle[t.camelize()];if(!/^\d+(px)?$/i.test(C)&&/^\d/.test(C)){t=B.left;A=p.runtimeStyle.left;p.runtimeStyle.left=p.currentStyle.left;B.left=C||0;C=B.pixelLeft+"px";B.left=t;p.runtimeStyle.left=A}}return C},dir:function(p,t){var A=[];for(p=p[t];p&&p!=document;){p.nodeType===1&&A.push(p);p=p[t]}return A},nth:function(p,t,A){t=t||1;for(var C=0;p;p=p[A])if(p.nodeType===1&&++C==t)break;return p},
sibling:function(p,t){for(var A=[];p;p=p.nextSibling)p.nodeType===1&&p!=t&&A.push(p);return A},attr:function(p,t,A){if(!(!p||p.nodeType===3||p.nodeType===8)){var C=!z.isXMLDoc(p),B=A!==undefined,G=SC.browser.msie;t=C&&z.props[t]||t;if(p.tagName){var J=k.test(t);if(t in p&&C&&!J){if(B){if(t==="type"&&z.nodeName(p,"input")&&p.parentNode)throw"type property can't be changed";p[t]=A}if(z.nodeName(p,"form")&&p.getAttributeNode(t))return p.getAttributeNode(t).nodeValue;if(t==="tabIndex")return(t=p.getAttributeNode("tabIndex"))&&
t.specified?t.value:p.nodeName.match(l)?0:p.nodeName.match(/^(a|area)$/i)&&p.href?0:undefined;return p[t]}if(G&&C&&t==="style")return z.attr(p.style,"cssText",A);B&&p.setAttribute(t,""+A);p=G&&C&&J?p.getAttribute(t,2):p.getAttribute(t);return p===null?undefined:p}if(G&&t==="opacity"){if(B){p.zoom=1;p.filter=(p.filter||"").replace(m,"")+(parseInt(A,0)+""=="NaN"?"":"alpha(opacity="+A*100+")")}return p.filter&&p.filter.indexOf("opacity=")>=0?parseFloat(p.filter.match(n)[1])/100+"":""}t=t.camelize();
if(B)p[t]=A;return p[t]}}});z.fn.init.prototype=z.fn;z.each({parent:function(p){return p.parentNode},parents:function(p){return z.dir(p,"parentNode")},next:function(p){return z.nth(p,2,"nextSibling")},prev:function(p){return z.nth(p,2,"previousSibling")},nextAll:function(p){return z.dir(p,"nextSibling")},prevAll:function(p){return z.dir(p,"previousSibling")},siblings:function(p){return z.sibling(p.parentNode.firstChild,p)},children:function(p){return z.sibling(p.firstChild)},contents:function(p){return z.nodeName(p,
"iframe")?p.contentDocument||p.contentWindow.document:z.makeArray(p.childNodes)}},function(p,t){z.fn[p]=function(A){var C=z.map(this,t);if(A&&typeof A==="string")C=z.multiFilter(A,C);return this.pushStack(C.uniq())}});z.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(p,t){z.fn[p]=function(){var A=arguments;return this.each(function(){for(var C=0,B=A.length;C<B;C++)z(A[C])[t](this)})}});z.each({removeAttr:function(p){z.attr(this,
p,"");this.nodeType===1&&this.removeAttribute(p)},addClass:function(p){z.className.add(this,p)},removeClass:function(p){z.className.remove(this,p)},toggleClass:function(p){z.className[z.className.has(this,p)?"remove":"add"](this,p)},remove:function(p){if(!p||z.filter(p,[this]).length)this.parentNode&&this.parentNode.removeChild(this)},empty:function(){for(;this.firstChild;)this.removeChild(this.firstChild)}},function(p,t){z.fn[p]=function(){return this.each(t,arguments)}});z.each(["Height","Width"],
function(p,t){var A=t.toLowerCase(),C;z.fn[A]=function(J){if(this[0]===window)C=SC.browser.opera?document.body["client"+t]:SC.browser.safari?window["inner"+t]:document.compatMode?documentElement["client"+t]:document.body["client"+t];else if(this[0]===document)C=Math.max(Math.max(document.body["scroll"+t],document.documentElement["scroll"+t]),Math.max(document.body["offset"+t],document.documentElement["offset"+t]));else return J===undefined?this.length?z.css(this[0],A):null:this.css(A,typeof J==="string"?
J:J+"px");return C};var B=p?"Left":"Top",G=p?"Right":"Bottom";z.fn["inner"+t]=function(){return this[t.toLowerCase()]()+a(this,"padding"+B)+a(this,"padding"+G)};z.fn["outer"+t]=function(J){return this["inner"+t]()+a(this,"border"+B+"Width")+a(this,"border"+G+"Width")+(J?a(this,"margin"+B)+a(this,"margin"+G):0)}});r.fn.offset=function(){function p(N){t(z.curCSS(N,"borderLeftWidth",true),z.curCSS(N,"borderTopWidth",true))}function t(N,O){A+=parseInt(N,10)||0;C+=parseInt(O,10)||0}var A=0,C=0,B=this[0],
G=SC.browser;if(B){var J=B.parentNode,F=B,E=B.offsetParent,H=B.ownerDocument,I=G.safari&&parseInt(G.version,0)<522&&!/adobeair/i.test(G.userAgent),L=z.curCSS,M=z.css(B,"position")==="fixed";if(!(G.mozilla&&B==document.body)&&B.getBoundingClientRect){B=B.getBoundingClientRect();t(B.left+Math.max(H.documentElement.scrollLeft,H.body.scrollLeft),B.top+Math.max(H.documentElement.scrollTop,H.body.scrollTop));t(-H.documentElement.clientLeft,-H.documentElement.clientTop)}else{for(t(B.offsetLeft,B.offsetTop);E;){t(E.offsetLeft,
E.offsetTop);if(G.mozilla&&!/^t(able|d|h)$/i.test(E.tagName)||G.safari&&!I)p(E);if(!M&&L(E,"position")==="fixed")M=true;F=/^body$/i.test(E.tagName)?F:E;E=E.offsetParent}for(;J&&J.tagName&&!j.test(J.tagName);){/^inline|table.*$/i.test(L(J,"display"))||t(-J.scrollLeft,-J.scrollTop);G.mozilla&&L(J,"overflow")!=="visible"&&p(J);J=J.parentNode}if(I&&(M||L(F,"position")==="absolute")||G.mozilla&&L(F,"position")!=="absolute")t(-H.body.offsetLeft,-H.body.offsetTop);M&&t(Math.max(H.documentElement.scrollLeft,
H.body.scrollLeft),Math.max(H.documentElement.scrollTop,H.body.scrollTop))}return{top:C,left:A}}};r.fn.mixin({position:function(){var p;if(this[0]){p=this.offsetParent();var t=this.offset(),A=j.test(p[0].tagName)?{top:0,left:0}:p.offset();t.top-=a(this,"marginTop");t.left-=a(this,"marginLeft");A.top+=a(p,"borderTopWidth");A.left+=a(p,"borderLeftWidth");p={top:t.top-A.top,left:t.left-A.left}}return p},offsetParent:function(){for(var p=this[0].offsetParent||document.body;p&&!j.test(p.tagName)&&z.css(p,
"position")==="static";)p=p.offsetParent;return z(p)}});z.each(["Left","Top"],function(p,t){var A="scroll"+t;z.fn[A]=function(C){if(this[0])return C!==undefined?this.each(function(){this==window||this==document?window.scrollTo(!p?C:z(window).scrollLeft(),p?C:z(window).scrollTop()):(this[A]=C)}):this[0]==window||this[0]==document?self[p?"pageYOffset":"pageXOffset"]||z.boxModel&&document.documentElement[A]||document.body[A]:this[0][A]}});return r}();SC.$=typeof jQuery=="undefined"?SC.CoreQuery:jQuery;
SC.mixin(SC.$.fn,{isCoreQuery:YES,toString:function(){var a=[],b=this.length,c=0;for(c=0;c<b;c++)a[c]="%@: %@".fmt(c,this[c]?this[c].toString():"(null)");return"<$:%@>(%@)".fmt(SC.guidFor(this),a.join(" , "))},isVisible:function(){return Array.prototype.every.call(this,function(a){return SC.$.isVisible(a)})},first:function(){return this.pushStack([this[0]])},last:function(){return this.pushStack([this[this.length-1]])},view:function(){return this.map(function(){for(var a=null,b=this,c;!a&&b&&b!==
document;){if(c=b.getAttribute("id"))a=SC.View.views[c];b=b.parentNode}return a})},setClass:function(a,b){if(SC.none(a))return this;var c=SC.typeOf(a)!==SC.T_STRING,d=this._fixupClass;this.each(function(){if(this.nodeType===1){var e=this.className.split(/\s+/),f=NO;if(c)for(var g in a){if(a.hasOwnProperty(g))f=d(e,g,a[g])||f}else f=d(e,a,b);if(f)this.className=e.join(" ")}});return this},_fixupClass:function(a,b,c){var d=a.indexOf(b);if(c){if(d<0){a.push(b);return YES}}else if(d>=0){a[d]=null;return YES}return NO},
within:function(a){a=SC.$(a);for(var b,c,d,e=a.length,f=this.length;!b&&--f>=0;){c=this[f];for(d=0;!b&&d<e;d++){for(b=a[d];b&&b!==c;)b=b.parentNode;b=b===c}}return b}});
(function(){var a={},b={find:function(g,h){return h!==undefined?SC.Enumerable.find.call(this,g,h):a.find.call(this,g)},filter:function(g,h){return h!==undefined?this.pushStack(SC.Enumerable.filter.call(this,g,h)):a.filter.call(this,g)},filterProperty:function(g,h){return this.pushStack(SC.Enumerable.filterProperty.call(this,g,h))},indexOf:SC.$.index,map:function(g,h){return h!==undefined?SC.Enumerable.map.call(this,g,h):a.map.call(this,g)}},c=SC.$.fn,d=SC.$.jquery==="SC.CoreQuery"?b:SC.Enumerable,
e;for(var f in d)if(d.hasOwnProperty(f)){e=d[f];if(f in b){a[f]=c[f];e=b[f]}c[f]=e}})();SC.mixin(SC.$,{isVisible:function(a){var b=SC.$;return"hidden"!=a.type&&b.css(a,"display")!="none"&&b.css(a,"visibility")!="hidden"}});sc_require("system/core_query");
SC.Event=function(a){if(a){this.originalEvent=a;for(var b=SC.Event._props,c=b.length,d;--c>=0;){d=b[c];this[d]=a[d]}}this.timeStamp=this.timeStamp||Date.now();if(!this.target)this.target=this.srcElement||document;if(this.target.nodeType===3)this.target=this.target.parentNode;if(!this.relatedTarget&&this.fromElement)this.relatedTarget=this.fromElement===this.target?this.toElement:this.fromElement;if(SC.none(this.pageX)&&!SC.none(this.clientX)){b=document.documentElement;c=document.body;this.pageX=
this.clientX+(b&&b.scrollLeft||c&&c.scrollLeft||0)-(b.clientLeft||0);this.pageY=this.clientY+(b&&b.scrollTop||c&&c.scrollTop||0)-(b.clientTop||0)}if(!this.which&&(this.charCode||a.charCode===0?this.charCode:this.keyCode))this.which=this.charCode||this.keyCode;if(!this.metaKey&&this.ctrlKey)this.metaKey=this.ctrlKey;if(!this.which&&this.button)this.which=this.button&1?1:this.button&2?3:this.button&4?2:0;if(SC.browser.safari&&a.wheelDelta!==undefined){this.wheelDelta=0-(a.wheelDeltaY||a.wheelDeltaX);
this.wheelDeltaY=0-(a.wheelDeltaY||0);this.wheelDeltaX=0-(a.wheelDeltaX||0)}else if(SC.none(a.detail)){this.wheelDelta=this.wheelDeltaY=SC.browser.msie?0-a.wheelDelta:a.wheelDelta;this.wheelDeltaX=0}else{b=Math.floor(a.detail*40);if(a.axis&&a.axis===a.HORIZONTAL_AXIS){this.wheelDeltaX=b;this.wheelDeltaY=this.wheelDelta=0}else{this.wheelDeltaY=this.wheelDelta=b;this.wheelDeltaX=0}}if(SC.browser.touch){if((a=this.changedTouches)&&a.length>0){a=a[0];this.pageX=a.pageX;this.pageY=a.pageY}a=b=this.target;
if(a===SC.RootResponder.responder._touchInterceptElement){b.style.display="none";this.target=a=document.elementFromPoint(this.pageX,this.pageY);b.style.display="block"}}return this};
SC.mixin(SC.Event,{create:function(a){return new SC.Event(a)},add:function(a,b,c,d,e){if(a&&a.isCoreQuery)if(a.length>0){a.forEach(function(h){this.add(h,b,c,d,e)},this);return this}else a=a[0];if(!a)return this;if(a.nodeType===3||a.nodeType===8)return SC.Event;if(SC.browser.msie&&a.setInterval)a=window;if(SC.typeOf(c)===SC.T_FUNCTION){e=d;d=c;c=null}else if(c&&SC.typeOf(d)===SC.T_STRING)d=c[d];var f=SC.data(a,"events")||SC.data(a,"events",{}),g=f[b];if(!g){g=f[b]={};this._addEventListener(a,b)}g[SC.guidFor(d)]=
[c,d,e];SC.Event._global[b]=YES;a=f=g=null;return this},remove:function(a,b,c,d){if(a&&a.isCoreQuery)if(a.length>0){a.forEach(function(j){this.remove(j,b,c,d)},this);return this}else a=a[0];if(!a)return this;if(a.nodeType===3||a.nodeType===8)return SC.Event;if(SC.browser.msie&&a.setInterval)a=window;var e,f,g=SC.data(a,"events");if(!g)return this;if(b===undefined)for(b in g)this.remove(a,b);else if(e=g[b]){var h=NO;if(c||d){if(SC.typeOf(c)===SC.T_FUNCTION){d=c;c=null}else if(SC.typeOf(d)===SC.T_STRING)d=
c[d];delete e[SC.guidFor(d)];f=null;for(f in e)break;if(f===null)h=YES}else h=YES;if(h){delete g[b];this._removeEventListener(a,b)}f=null;for(f in g)break;if(!f){SC.removeData(a,"events");delete this._elements[SC.guidFor(a)]}}a=g=e=null;return this},NO_BUBBLE:["blur","focus","change"],simulateEvent:function(a,b,c){a=SC.Event.create({type:b,target:a,preventDefault:function(){this.cancelled=YES},stopPropagation:function(){this.bubbles=NO},allowDefault:function(){this.hasCustomEventHandling=YES},timeStamp:Date.now(),
bubbles:this.NO_BUBBLE.indexOf(b)<0,cancelled:NO,normalized:YES});c&&SC.mixin(a,c);return a},trigger:function(a,b,c,d){if(a&&a.isCoreQuery)if(a.length>0){a.forEach(function(k){this.trigger(k,b,c,d)},this);return this}else a=a[0];if(!a)return this;if(!(a.nodeType===3||a.nodeType===8)){c=SC.A(c);var e,f=SC.typeOf(a[b]||null)===SC.T_FUNCTION,g,h;g=c[0];if(!g||!g.preventDefault){g=this.simulateEvent(a,b);c.unshift(g)}g.type=b;h=a;do{e=SC.Event.handle.apply(h,c);h=h===document?null:h.parentNode||document}while(!e&&
g.bubbles&&h);h=null;g=a["on"+b];h=SC.CoreQuery.nodeName(a,"a")&&b==="click";if((!f||h)&&g&&g.apply(a,c)===NO)e=NO;if(f&&d!==NO&&e!==NO&&!h){this.triggered=YES;try{a[b]()}catch(j){}}this.triggered=NO;return e}},handle:function(a){if(typeof SC==="undefined"||SC.Event.triggered)return YES;var b,c,d,e,f,g;e=SC.A(arguments);e[0]=a=SC.Event.normalizeEvent(a||window.event);d=(SC.data(this,"events")||{})[a.type];if(!d)return NO;for(f in d){g=d[f];c=g[1];a.handler=c;a.data=a.context=g[2];g=g[0]||this;c=c.apply(g,
e);if(b!==NO)b=c;if(c===NO){a.preventDefault();a.stopPropagation()}}return b},unload:function(){var a,b=this._elements;for(a in b)this.remove(b[a]);for(a in b)delete b[a];delete this._elements},special:{ready:{setup:function(){SC._bindReady()},teardown:function(){}},mouseenter:{setup:function(){if(SC.browser.msie)return NO;SC.Event.add(this,"mouseover",SC.Event.special.mouseover.handler);return YES},teardown:function(){if(SC.browser.msie)return NO;SC.Event.remove(this,"mouseover",SC.Event.special.mouseover.handler);
return YES},handler:function(a){if(SC.Event._withinElement(a,this))return YES;a.type="mouseenter";return SC.Event.handle.apply(this,arguments)}},mouseleave:{setup:function(){if(SC.browser.msie)return NO;SC.Event.add(this,"mouseout",SC.Event.special.mouseleave.handler);return YES},teardown:function(){if(SC.browser.msie)return NO;SC.Event.remove(this,"mouseout",SC.Event.special.mouseleave.handler);return YES},handler:function(a){if(SC.Event._withinElement(a,this))return YES;a.type="mouseleave";return SC.Event.handle.apply(this,
arguments)}}},KEY_BACKSPACE:8,KEY_TAB:9,KEY_RETURN:13,KEY_ESC:27,KEY_LEFT:37,KEY_UP:38,KEY_RIGHT:39,KEY_DOWN:40,KEY_DELETE:46,KEY_HOME:36,KEY_END:35,KEY_PAGEUP:33,KEY_PAGEDOWN:34,KEY_INSERT:45,_withinElement:function(a,b){for(a=a.relatedTarget;a&&a!=b;)try{a=a.parentNode}catch(c){a=b}return a===b},_addEventListener:function(a,b){var c;c=this.special[b];if(!c||c.setup.call(a)===NO){var d=SC.guidFor(a);this._elements[d]=a;c=SC.data(a,"listener")||SC.data(a,"listener",function(){return SC.Event.handle.apply(SC.Event._elements[d],
arguments)});if(a.addEventListener)a.addEventListener(b,c,NO);else a.attachEvent&&a.attachEvent("on"+b,c)}a=c=c=null},_removeEventListener:function(a,b){var c;c=SC.Event.special[b];if(!c||c.teardown.call(a)===NO)if(c=SC.data(a,"listener"))if(a.removeEventListener)a.removeEventListener(b,c,NO);else a.detachEvent&&a.detachEvent("on"+b,c)},_elements:{},normalizeEvent:function(a){return a===window.event?SC.Event.create(a):a.normalized?a:SC.Event.create(a)},_global:{},_props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler hasCustomEventHandling keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target timeStamp toElement type view which touches targetTouches changedTouches".split(" ")});
SC.Event.prototype={hasCustomEventHandling:NO,allowDefault:function(){this.hasCustomEventHandling=YES;return this},preventDefault:function(){var a=this.originalEvent;if(a){a.preventDefault&&a.preventDefault();a.returnValue=NO}this.hasCustomEventHandling=YES;return this},stopPropagation:function(){var a=this.originalEvent;if(a){a.stopPropagation&&a.stopPropagation();a.cancelBubble=YES}this.hasCustomEventHandling=YES;return this},stop:function(){return this.preventDefault().stopPropagation()},normalized:YES,
getCharString:function(){return SC.browser.msie?this.keyCode==8||this.keyCode==9||this.keyCode>=37&&this.keyCode<=40?String.fromCharCode(0):this.keyCode>0?String.fromCharCode(this.keyCode):null:this.charCode>0?String.fromCharCode(this.charCode):null},commandCodes:function(){var a=this.keyCode,b=null,c=null,d="";if(a){b=SC.FUNCTION_KEYS[a];if(!b&&(this.altKey||this.ctrlKey||this.metaKey))b=SC.PRINTABLE_KEYS[a];if(b){if(this.altKey)d+="alt_";if(this.ctrlKey||this.metaKey)d+="ctrl_"}}if(!b){a=this.which;
c=b=String.fromCharCode(a);a=b.toLowerCase();if(this.metaKey){d="meta_";b=a}else b=null}if(this.shiftKey&&b)d+="shift_";if(b)b=d+b;return[b,c]}};SC.Event.observe=SC.Event.add;SC.Event.stopObserving=SC.Event.remove;SC.Event.fire=SC.Event.trigger;SC.Event.add(window,"unload",SC.Event.prototype,SC.Event.unload);SC.MODIFIER_KEYS={16:"shift",17:"ctrl",18:"alt"};
SC.FUNCTION_KEYS={8:"backspace",9:"tab",13:"return",19:"pause",27:"escape",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",44:"printscreen",45:"insert",46:"delete",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"numlock",145:"scrolllock"};
SC.PRINTABLE_KEYS={32:" ",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",59:";",61:"=",65:"a",66:"b",67:"c",68:"d",69:"e",70:"f",71:"g",72:"h",73:"i",74:"j",75:"k",76:"l",77:"m",78:"n",79:"o",80:"p",81:"q",82:"r",83:"s",84:"t",85:"u",86:"v",87:"w",88:"x",89:"y",90:"z",107:"+",109:"-",110:".",188:",",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:'"'};SC.PRINTABLE_KEYS_CHARCODE={};
(function(){var a;for(i in SC.PRINTABLE_KEYS){a=SC.PRINTABLE_KEYS[i];SC.PRINTABLE_KEYS_CHARCODE[a.charCodeAt(0)]=i;if(a.toUpperCase()!=a)SC.PRINTABLE_KEYS_CHARCODE[a.toUpperCase().charCodeAt(0)]=i}})();SC.SYSTEM_CURSOR="default";SC.AUTO_CURSOR=SC.DEFAULT_CURSOR="auto";SC.CROSSHAIR_CURSOR="crosshair";SC.HAND_CURSOR=SC.POINTER_CURSOR="pointer";SC.MOVE_CURSOR="move";SC.E_RESIZE_CURSOR="e-resize";SC.NE_RESIZE_CURSOR="ne-resize";SC.NW_RESIZE_CURSOR="nw-resize";SC.N_RESIZE_CURSOR="n-resize";
SC.SE_RESIZE_CURSOR="se-resize";SC.SW_RESIZE_CURSOR="sw-resize";SC.S_RESIZE_CURSOR="s-resize";SC.W_RESIZE_CURSOR="w-resize";SC.IBEAM_CURSOR=SC.TEXT_CURSOR="text";SC.WAIT_CURSOR="wait";SC.HELP_CURSOR="help";
SC.Cursor=SC.Object.extend({init:function(){arguments.callee.base.apply(this,arguments);var a=this.get("cursorStyle")||SC.DEFAULT_CURSOR,b=this.constructor.sharedStyleSheet(),c=SC.guidFor(this);if(b.insertRule)b.insertRule("."+c+" {cursor: "+a+";}",b.cssRules?b.cssRules.length:0);else b.addRule&&b.addRule("."+c,"cursor: "+a);this.cursorStyle=a;this.className=c;return this},className:null,cursorStyle:SC.DEFAULT_CURSOR,cursorStyleDidChange:function(){var a,b,c,d,e,f;a=this.get("cursorStyle")||SC.DEFAULT_CURSOR;
if(b=this._rule)b.style.cursor=a;else{c="."+this.get("className");b=this.constructor.sharedStyleSheet();d=(b.cssRules?b.cssRules:b.rules)||[];e=0;for(f=d.length;e<f;++e){b=d[e];if(b.selectorText===c){this._rule=b;b.style.cursor=a;break}}}}.observes("cursorStyle")});
SC.Cursor.sharedStyleSheet=function(){var a,b=this._styleSheet;if(!b){b=document.createElement("style");b.type="text/css";a=document.getElementsByTagName("head")[0];if(!a)a=document.documentElement;a.appendChild(b);this._styleSheet=b=document.styleSheets[document.styleSheets.length-1]}return b};
SC.Responder=SC.Object.extend({isResponder:YES,pane:null,responderContext:null,nextResponder:null,isFirstResponder:NO,hasFirstResponder:NO,acceptsFirstResponder:YES,becomingFirstResponder:NO,becomeFirstResponder:function(){var a=this.get("pane")||this.get("responderContext")||this.pane();a&&this.get("acceptsFirstResponder")&&a.get("firstResponder")!==this&&a.makeFirstResponder(this);return this},resignFirstResponder:function(){var a=this.get("pane")||this.get("responderContext");a&&a.get("firstResponder")===
this&&a.makeFirstResponder(null);return YES},willLoseFirstResponder:function(){},didBecomeFirstResponder:function(){}});sc_require("system/browser");sc_require("system/event");sc_require("system/cursor");sc_require("system/responder");sc_require("mixins/string");SC.viewKey=SC.guidKey+"_view";SC.LAYOUT_HORIZONTAL="sc-layout-horizontal";SC.LAYOUT_VERTICAL="sc-layout-vertical";SC._VIEW_DEFAULT_DIMS="marginTop marginLeft".w();SC.ANCHOR_TOP={top:0};SC.ANCHOR_LEFT={left:0};SC.ANCHOR_TOP_LEFT={top:0,left:0};
SC.ANCHOR_BOTTOM={bottom:0};SC.ANCHOR_RIGHT={right:0};SC.ANCHOR_BOTTOM_RIGHT={bottom:0,right:0};SC.FULL_WIDTH={left:0,right:0};SC.FULL_HEIGHT={top:0,bottom:0};SC.ANCHOR_CENTER={centerX:0,centerY:0};SC.LAYOUT_AUTO="auto";SC.CONTEXT_MENU_ENABLED=YES;SC.TABBING_ONLY_INSIDE_DOCUMENT=YES;SC.ROUTE_TOUCH=YES;SC.EMPTY_CHILD_VIEWS_ARRAY=[];SC.EMPTY_CHILD_VIEWS_ARRAY.needsClone=YES;
SC.View=SC.Responder.extend(SC.DelegateSupport,{concatenatedProperties:"outlets displayProperties layoutProperties classNames renderMixin didCreateLayerMixin willDestroyLayerMixin".w(),pane:function(){for(var a=this;a&&!a.isPane;)a=a.get("parentView");return a}.property("parentView").cacheable(),page:null,splitView:function(){for(var a=this;a&&!a.isSplitView;)a=a.get("parentView");return a}.property("parentView").cacheable(),parentView:null,backgroundColor:null,routeTouch:YES,isEnabled:YES,isEnabledBindingDefault:SC.Binding.oneWay().bool(),
isEnabledInPane:function(){var a=this.get("isEnabled"),b;if(a&&(b=this.get("parentView")))a=b.get("isEnabledInPane");return a}.property("parentView","isEnabled"),isVisible:YES,isVisibleBindingDefault:SC.Binding.bool(),isVisibleInWindow:NO,isContextMenuEnabled:function(){return SC.CONTEXT_MENU_ENABLED}.property(),recomputeIsVisibleInWindow:function(a){this.get("isVisibleInWindow");var b=this.get("isVisible"),c;if(b)b=a===undefined?(c=this.get("parentView"))?c.get("isVisibleInWindow"):NO:a;this.set("isVisibleInWindow",
b);this._needsVisibiltyChange=YES;a=this.get("childViews");c=a.length;var d;for(d=0;d<c;d++)a[d].recomputeIsVisibleInWindow(b);if(b){this.parentViewDidResize&&this.parentViewDidResize();this.get("childViewsNeedLayout")&&this.invokeOnce(this.layoutChildViewsIfNeeded)}this.set("layerNeedsUpdate",YES);!b&&this.get("isFirstResponder")&&this.resignFirstResponder();return this}.observes("isVisible"),childViews:SC.EMPTY_CHILD_VIEWS_ARRAY,insertBefore:function(a,b){a.beginPropertyChanges();a.get("parentView")&&
a.removeFromParent();this.willAddChild&&this.willAddChild(a,b);a.willAddToParent&&a.willAddToParent(this,b);a.set("parentView",this);var c,d=this.get("childViews");if(d.needsClone)this.set(d=[]);c=b?d.indexOf(b):d.length;if(c<0)c=d.length;d.insertAt(c,a);a.parentViewDidChange();a.layoutDidChange();(c=a.get("pane"))&&c.get("isPaneAttached")&&a._notifyDidAppendToDocument();this.didAddChild&&this.didAddChild(a,b);a.didAddToParent&&a.didAddToParent(this,b);a.endPropertyChanges();return this},removeChild:function(a){if(!a)return this;
if(a.parentView!==this)throw"%@.removeChild(%@) must belong to parent".fmt(this,a);a.willRemoveFromParent&&a.willRemoveFromParent();this.willRemoveChild&&this.willRemoveChild(a);a.set("parentView",null);var b=this.get("childViews"),c=b.indexOf(a);c>=0&&b.removeAt(c);a.parentViewDidChange();this.didRemoveChild&&this.didRemoveChild(a);a.didRemoveFromParent&&a.didRemoveFromParent(this);return this},removeAllChildren:function(){for(var a=this.get("childViews"),b;b=a.objectAt(a.get("length")-1);)this.removeChild(b);
return this},removeFromParent:function(){var a=this.get("parentView");a&&a.removeChild(this);return this},replaceChild:function(a,b){a.beginPropertyChanges();b.beginPropertyChanges();this.beginPropertyChanges();this.insertBefore(a,b).removeChild(b);this.endPropertyChanges();b.endPropertyChanges();a.endPropertyChanges();return this},replaceAllChildren:function(a){var b=a.get("length"),c;this.beginPropertyChanges();this.destroyLayer().removeAllChildren();for(c=0;c<b;c++)this.appendChild(a.objectAt(c));
this.replaceLayer();this.endPropertyChanges();return this},appendChild:function(a){return this.insertBefore(a,null)},parentViewDidChange:function(){this.recomputeIsVisibleInWindow();this.set("layerLocationNeedsUpdate",YES);this.invokeOnce(this.updateLayerLocationIfNeeded);this._invalidatePaneCacheForSelfAndAllChildViews();return this}.observes("isVisible"),_invalidatePaneCacheForSelfAndAllChildViews:function(){var a,b=this.get("childViews"),c=b.length,d;this.notifyPropertyChange("pane");for(d=0;d<
c;++d){a=b[d];a._invalidatePaneCacheForSelfAndAllChildViews&&a._invalidatePaneCacheForSelfAndAllChildViews()}},layer:function(a,b){if(b!==undefined)this._view_layer=b;else{b=this._view_layer;if(!b){if(a=this.get("parentView"))a=a.get("layer");if(a)this._view_layer=b=this.findLayerInParentLayer(a)}}return b}.property("isVisibleInWindow").cacheable(),$:function(a){var b=this.get("layer");return!b?SC.$([]):a===undefined?SC.$(b):SC.$(a,b)},containerLayer:function(){return this.get("layer")}.property("layer").cacheable(),
layerId:function(){return SC.guidFor(this)}.property().cacheable(),findLayerInParentLayer:function(a){var b=this.get("layerId"),c,d,e,f;f=a.getElementById?a.getElementById(b):document.getElementById(b);if(SC.browser.msie&&f&&f.id!==b)f=null;if(!f&&a.querySelector)f=a.querySelector("#"+b);if(!f){f=a.firstChild;var g=[];for(g.push(a);g.length!==0;){a=g[0];g.shift();if(a.id===b){e=true;f=a;break}c=0;for(d=a.childNodes.length;c<d;c++)g.push(a.childNodes[c])}e||(f=null)}return f},displayDidChange:function(){this.set("layerNeedsUpdate",
YES);return this},layerNeedsUpdate:NO,_view_layerNeedsUpdateDidChange:function(){this.get("layerNeedsUpdate")&&this.invokeOnce(this.updateLayerIfNeeded)}.observes("layerNeedsUpdate"),updateLayerIfNeeded:function(){if((this.get("isVisibleInWindow")||this._needsVisibiltyChange)&&this.get("layerNeedsUpdate")){this._needsVisibiltyChange=NO;if(this.get("layer")){this.beginPropertyChanges();this.set("layerNeedsUpdate",NO);this.updateLayer();this.endPropertyChanges()}}else this.set("layerNeedsUpdate",NO);
return this},updateLayer:function(){var a=this.renderContext(this.get("layer"));this.prepareContext(a,NO);a.update();if(a._innerHTMLReplaced)(a=this.get("pane"))&&a.get("isPaneAttached")&&this._notifyDidAppendToDocument();this.didUpdateLayer&&this.didUpdateLayer();this.designer&&this.designer.viewDidUpdateLayer&&this.designer.viewDidUpdateLayer();return this},renderContext:function(a){return SC.RenderContext(a)},createLayer:function(){if(this.get("layer"))return this;var a=this.renderContext(this.get("tagName"));
this.prepareContext(a,YES);this.set("layer",a.element());this._notifyDidCreateLayer();return this},_notifyDidCreateLayer:function(){this.didCreateLayer&&this.didCreateLayer();var a=this.didCreateLayerMixin,b,c,d=this.get("childViews");if(a){b=a.length;for(c=0;c<b;++c)a[c].call(this)}b=d.length;for(c=0;c<b;++c)d[c]&&d[c]._notifyDidCreateLayer()},destroyLayer:function(){var a=this.get("layer");if(a){this._notifyWillDestroyLayer();a.parentNode&&a.parentNode.removeChild(a)}return this},replaceLayer:function(){this.destroyLayer();
this.set("layerLocationNeedsUpdate",YES);this.invokeOnce(this.updateLayerLocationIfNeeded)},_notifyWillDestroyLayer:function(){this.willDestroyLayer&&this.willDestroyLayer();var a=this.willDestroyLayerMixin,b,c,d=this.get("childViews");if(a){b=a.length;for(c=0;c<b;++c)a[c].call(this)}b=d.length;for(c=0;c<b;++c)d[c]._notifyWillDestroyLayer();this.set("layer",null)},prepareContext:function(a,b){var c,d,e;if(b){c=this.layerId?this.get("layerId"):SC.guidFor(this);a.id(c).classNames(this.get("classNames"),
YES);this.renderLayout(a,b)}else{a.resetClassNames();a.classNames(this.get("classNames"),YES)}this.get("isTextSelectable")&&a.addClass("allow-select");this.get("isEnabled")||a.addClass("disabled");this.get("isVisible")||a.addClass("hidden");this.get("isFirstResponder")&&a.addClass("focus");(c=this.get("backgroundColor"))&&a.addStyle("backgroundColor",c);(c=this.get("cursor"))&&a.addClass(c.get("className"));this.beginPropertyChanges();this.set("layerNeedsUpdate",NO);this.render(a,b);if(c=this.renderMixin){d=
c.length;for(e=0;e<d;++e)c[e].call(this,a,b)}this.endPropertyChanges()},renderChildViews:function(a,b){var c=this.get("childViews"),d=c.length,e,f;for(e=0;e<d;++e)if(f=c[e]){a=a.begin(f.get("tagName"));f.prepareContext(a,b);a=a.end()}return a},render:function(a,b){b&&this.renderChildViews(a,b)},_notifyDidAppendToDocument:function(){this.didAppendToDocument&&this.didAppendToDocument();var a=0,b,c,d=this.get("childViews");a=0;for(c=d.length;a<c;a++){b=d[a];b._notifyDidAppendToDocument&&b._notifyDidAppendToDocument()}},
tagName:"div",classNames:["sc-view"],toolTip:null,isTextSelectable:NO,displayProperties:["isFirstResponder","isVisible"],cursor:null,layerLocationNeedsUpdate:NO,updateLayerLocationIfNeeded:function(){if(this.get("layerLocationNeedsUpdate")){this.set("layerLocationNeedsUpdate",NO);this.updateLayerLocation()}return this},updateLayerLocation:function(){var a=this.get("layer"),b=this.get("parentView"),c=b?b.get("containerLayer"):null;a&&a.parentNode&&a.parentNode!==c&&a.parentNode.removeChild(a);if(b)if(c){if(!a){this.createLayer();
a=this.get("layer");if(!a)return}b=b.get("childViews");var d=(b=b.objectAt(b.indexOf(this)+1))?b.get("layer"):null;if(b&&(!d||d.parentNode!==c)){b.updateLayerLocationIfNeeded();d=b.get("layer")}if(a.parentNode!==c||a.nextSibling!==d){c.insertBefore(a,d);this.parentViewDidResize&&this.parentViewDidResize()}}else{if(a){a.parentNode&&a.parentNode.removeChild(a);this.destroyLayer()}}else a&&a.parentNode&&a.parentNode.removeChild(a);return this},nextResponder:function(){return this.get("parentView")}.property("parentView").cacheable(),
acceptsFirstResponder:NO,isKeyResponder:NO,willLoseKeyResponderTo:function(){},willBecomeKeyResponderFrom:function(){},didLoseKeyResponderTo:function(){},didBecomeKeyResponderFrom:function(){},interpretKeyEvents:function(a){var b=a.commandCodes(),c=b[0];b=b[1];if(!c&&!b)return null;if(c)if(c=SC.MODIFIED_KEY_BINDINGS[c]||SC.BASE_KEY_BINDINGS[c.match(/[^_]+$/)[0]]){b=this;for(var d=this.get("pane"),e=null;b&&!(e=b.tryToPerform(c,a));)b=b===d?null:b.get("nextResponder");return e}if(b&&this.respondsTo("insertText"))return(a=
this.insertText(b,a))?a===YES?this:a:null;return null},insertText:function(){return NO},performKeyEquivalent:function(a,b){for(var c=NO,d=this.get("childViews"),e=d.length,f=-1;!c&&++f<e;)c=d[f].performKeyEquivalent(a,b);return c},nextKeyView:null,nextValidKeyView:function(){var a=[],b=this.pane(),c;c=b._computeNextValidKeyView(this,a);if(SC.TABBING_ONLY_IN_DOCUMENT&&SC.ret===null)c=b._computeNextValidKeyView(b,a);return c}.property("nextKeyView"),_computeNextValidKeyView:function(a,b){var c=this.get("nextKeyView"),
d,e,f,g;if(this!==a&&b.indexOf(a)!=-1&&this.get("acceptsFirstResponder")&&this.get("isVisibleInWindow"))return this;b.push(this);if(!c){d=this.get("childViews");e=0;for(f=d.length;e<f;e++){g=d[e];if(g.get("isVisibleInWindow")&&g.get("isVisible"))c=g._computeNextValidKeyView(a,b);if(c)return c}c=null}return c},previousKeyView:null,previousValidKeyView:function(){return this.pane()._computePreviousValidKeyView(this,[])}.property("previousKeyView"),_computePreviousValidKeyView:function(a,b){var c=this.get("previousKeyView"),
d,e,f;if(this!==a&&b.indexOf(a)!=-1&&this.get("acceptsFirstResponder")&&this.get("isVisibleInWindow"))return this;b.push(this);if(!c){d=this.get("childViews");for(e=d.length-1;0<=e;e--){f=d[e];if(f.get("isVisibleInWindow")&&f.get("isVisible"))c=f._computePreviousValidKeyView(a,b);if(c)return c}c=null}return c},init:function(){var a,b;arguments.callee.base.apply(this,arguments);this.get("isMaterialized")||(SC.View.views[this.get("layerId")]=this);this.childViews=(a=this.get("childViews"))?a.slice():
[];this.createChildViews();b=this.get("displayProperties");for(a=b.length;--a>=0;)this.addObserver(b[a],this,this.displayDidChange);this.get("isDropTarget")&&SC.Drag.addDropTarget(this);this.get("isScrollable")&&SC.Drag.addScrollableView(this);SC.ROUTE_TOUCH&&this.get("routeTouch")&&this.routeTouchEvents()},routeTouchEvents:function(){if(!this.respondsTo("touchStart")&&this.respondsTo("mouseDown"))this.touchStart=this.mouseDown;if(!this.respondsTo("touchEnd")&&this.respondsTo("mouseUp"))this.touchEnd=
this.mouseUp;if(!this.respondsTo("touchMoved")&&this.respondsTo("mouseMove"))this.touchMoved=this.mouseMove;if(!this.respondsTo("touchEntered")&&this.respondsTo("mouseEntered"))this.touchEntered=this.mouseEntered;if(!this.respondsTo("touchExited")&&this.respondsTo("mouseExited"))this.touchExited=this.mouseExited},awake:function(){arguments.callee.base.apply(this,arguments);var a=this.get("childViews"),b=a.length,c;for(c=0;c<b;++c)a[c]&&a[c].awake()},destroy:function(){if(this.get("isDestroyed"))return this;
arguments.callee.base.apply(this,arguments);this.removeFromParent();this._destroy();this.get("isDropTarget")&&SC.Drag.removeDropTarget(this);this.get("isScrollable")&&SC.Drag.removeScrollableView(this);return this},_destroy:function(){if(this.get("isDestroyed"))return this;this.destroyLayer();var a=this.get("childViews"),b=a.length,c;if(b){a=a.slice();for(c=0;c<b;++c)a[c]._destroy()}delete SC.View.views[this.get("layerId")];delete this._CQ;delete this.page;this.set("isDestroyed",YES);return this},
createChildViews:function(){var a=this.get("childViews"),b=a.length,c,d,e;this.beginPropertyChanges();for(c=0;c<b;++c){if(d=e=a[c]){if(typeof d===SC.T_STRING)e=this[d];else d=null;if(!e){SC.Logger.error("No view with name "+d+" has been found in "+this.toString());continue}if(e.isClass){e=this.createChildView(e);if(d)this[d]=e}}a[c]=e}this.endPropertyChanges();return this},createChildView:function(a,b){b||(b={});b.owner=b.parentView=this;b.isVisibleInWindow=this.get("isVisibleInWindow");if(!b.page)b.page=
this.page;return a=a.create(b)},adjust:function(a,b){var c=SC.clone(this.get("layout")),d=NO,e;if(a===undefined)return this;if(SC.typeOf(a)===SC.T_STRING){e=c[a];if(SC.none(b)){if(e!==undefined)d=YES;delete c[a]}else{if(e!==b)d=YES;c[a]=b}}else{var f=a;for(a in f)if(f.hasOwnProperty(a)){b=f[a];e=c[a];if(b===null){if(e!==undefined)d=YES;delete c[a]}else if(b!==undefined){if(e!==b)d=YES;c[a]=b}}}d&&this.set("layout",c);return this},layout:{top:0,left:0,bottom:0,right:0},convertFrameToView:function(a,
b){var c=0,d=0,e=0,f=0,g=this,h;if(this.get("useStaticLayout"))throw"convertFrameToView is not available with static layout";for(;g;){h=g.get("frame");c+=h.x;d+=h.y;g=g.get("layoutView")}if(b)for(g=b;g;){h=g.get("frame");e+=h.x;f+=h.y;g=g.get("layoutView")}c=a.x+c-e;d=a.y+d-f;return{x:c,y:d,width:a.width,height:a.height}},convertFrameFromView:function(a,b){var c=0,d=0,e=0,f=0,g=this,h;if(this.get("useStaticLayout"))throw"convertFrameToView is not available with static layout";for(;g&&g.get("frame");){h=
g.get("frame");c+=h.x;d+=h.y;g=g.get("parentView")}if(b)for(g=b;g;){h=g.get("frame");e+=h.x;f+=h.y;g=g.get("parentView")}c=a.x-c+e;d=a.y-d+f;return{x:c,y:d,width:a.width,height:a.height}},scrollToVisible:function(){for(var a=this.get("parentView");a&&!a.get("isScrollable");)a=a.get("parentView");if(a){a.scrollToVisible();return a.scrollToVisible(this)}else return NO},frame:function(){return this.computeFrameWithParentFrame(null)}.property("layout","useStaticLayout").cacheable(),computeFrameWithParentFrame:function(a){var b=
this.get("layout"),c={},d,e=SC.LAYOUT_AUTO,f=this.get("useStaticLayout"),g=this.get("parentView");d=b.right;var h=b.left,j=b.top,k=b.bottom,l=b.width,m=b.height,n=b.centerX,o=b.centerY;if(l!==undefined&&l===SC.LAYOUT_AUTO&&f!==undefined&&!f){b=SC.Error.desc("%@.layout() you cannot use width:auto if ".fmt(this)+"staticLayout is disabled","%@".fmt(this),-1);SC.Logger.error(b.toString());throw b;}if(m!==undefined&&m===SC.LAYOUT_AUTO&&f!==undefined&&!f){b=SC.Error.desc("%@.layout() you cannot use height:auto if ".fmt(this)+
"staticLayout is disabled","%@".fmt(this),-1);SC.Logger.error(b.toString());throw b;}if(f){if(d=this.get("layer")){c=SC.viewportOffset(d);c.width=d.offsetWidth;c.height=d.offsetHeight;return c}return null}a||(a=this.computeParentDimensions(b));f=a.height;a=a.width;if(SC.none(h))if(SC.none(d))if(SC.none(n)){c.x=0;if(SC.none(l))c.width=a;else{if(l===e)c.width=e;c.width=SC.isPercentage(l)?l*a:l||0}}else{c.width=l===e?e:SC.isPercentage(l)?l*a:l||0;c.x=SC.isPercentage(n)?(a-c.width)/2+n*a:(a-c.width)/
2+n}else if(SC.none(l)){c.width=SC.isPercentage(h)?a-a*d:a-d;c.x=0}else{c.width=l===e?e:SC.isPercentage(l)?a*l:l||0;c.x=SC.isPercentage(l)?a-d*a-c.width:a-d-c.width}else{c.x=SC.isPercentage(h)?a*h:h;if(l!==undefined)c.width=l===e?e:SC.isPercentage(l)?a*l:l;else{c.width=a-c.x;c.width-=d&&SC.isPercentage(d)?d*a:d||0}}if(SC.none(j))if(SC.none(k))if(SC.none(o)){c.y=0;if(SC.none(m))c.height=f;else{if(m===e)c.height=e;c.height=SC.isPercentage(m)?m*f:m||0}}else{if(m===e)c.height=e;c.height=m&&SC.isPercentage(m)?
m*f:m||0;c.y=SC.isPercentage(o)?(f-c.height)/2+o*f:(f-c.height)/2+o}else if(SC.none(m)){c.height=SC.isPercentage(k)?f-k*f:f-k;c.y=0}else{if(m===e)c.height=e;c.height=m&&SC.isPercentage(m)?m*f:m||0;c.y=SC.isPercentage(k)?f-k*f-c.height:f-k-c.height}else{c.y=SC.isPercentage(j)?j*f:j;c.height=m!==undefined?m===e?e:SC.isPercentage(m)?m*f:m:k&&SC.isPercentage(k)?f-c.y-k*f:f-c.y-(k||0)}c.x=Math.floor(c.x);c.y=Math.floor(c.y);if(c.height!==e)c.height=Math.floor(c.height);if(c.width!==e)c.width=Math.floor(c.width);
if(c.height===e||c.width===e){d=this.get("layer");if(c.height===e)c.height=d?d.clientHeight:0;if(c.width===e)c.width=d?d.clientWidth:0}if(this.get("hasBorder")){e=this.get("borderTop");d=this.get("borderLeft");c.height-=e+this.get("borderBottom");c.y+=e;c.width-=d+this.get("borderRight");c.x+=d}if(g&&g.isScrollContainer){g=g.get("parentView");c.x-=g.get("horizontalScrollOffset");c.y-=g.get("verticalScrollOffset")}if(!SC.none(b.maxHeight)&&c.height>b.maxHeight)c.height=b.maxHeight;if(!SC.none(b.minHeight)&&
c.height<b.minHeight)c.height=b.minHeight;if(!SC.none(b.maxWidth)&&c.width>b.maxWidth)c.width=b.maxWidth;if(!SC.none(b.minWidth)&&c.width<b.minWidth)c.width=b.minWidth;if(c.height<0)c.height=0;if(c.width<0)c.width=0;return c},computeParentDimensions:function(a){var b=this.get("parentView");return(b=b?b.get("frame"):null)?{width:b.width,height:b.height}:{width:(a.left||0)+(a.width||0)+(a.right||0),height:(a.top||0)+(a.height||0)+(a.bottom||0)}},clippingFrame:function(){var a=this.get("parentView"),
b=this.get("frame"),c=b;if(a){a=a.get("clippingFrame");c=SC.intersectRects(a,b)}c.x-=b.x;c.y-=b.y;return c}.property("parentView","frame").cacheable(),_sc_view_clippingFrameDidChange:function(){var a=this.get("childViews"),b=a.length,c,d;for(c=0;c<b;++c){d=a[c];d.hasStaticLayout||d.notifyPropertyChange("clippingFrame")}}.observes("clippingFrame"),parentViewDidResize:function(){var a=this.get("layout"),b;b=a.left!==undefined&&a.top!==undefined&&a.width!==undefined&&a.height!==undefined;a=SC.isPercentage(a.left)||
SC.isPercentage(a.top)||SC.isPercentage(a.width)||SC.isPercentage(a.right)||SC.isPercentage(a.centerX)||SC.isPercentage(a.centerY);if(!b||a){this.notifyPropertyChange("frame");this.viewDidResize()}},viewDidResize:function(){var a=this.childViews,b=a.length,c,d;for(c=0;c<b;++c){d=a[c];d.parentViewDidResize&&d.parentViewDidResize()}}.observes("layout"),beginLiveResize:function(){this.willBeginLiveResize&&this.willBeginLiveResize();var a=this.get("childViews"),b=a.length,c,d;for(c=0;c<b;++c){d=a[c];
d.beginLiveResize&&d.beginLiveResize()}return this},endLiveResize:function(){var a=this.get("childViews"),b,c;for(b=a.length-1;b>=0;--b){c=a[b];c.endLiveResize&&c.endLiveResize()}this.didEndLiveResize&&this.didEndLiveResize();return this},layoutStyle:function(){var a=this.get("layout"),b={},c=SC._VIEW_DEFAULT_DIMS,d=c.length,e,f=this.get("useStaticLayout"),g=a.right,h=a.left,j=a.top,k=a.bottom,l=a.width,m=a.height,n=a.maxWidth,o=a.maxHeight,r=a.centerX,u=a.centerY;if(l!==undefined&&l===SC.LAYOUT_AUTO&&
!f){b=SC.Error.desc("%@.layout() you cannot use width:auto if ".fmt(this)+"staticLayout is disabled","%@".fmt(this),-1);SC.Logger.error(b.toString());throw b;}if(m!==undefined&&m===SC.LAYOUT_AUTO&&!f){b=SC.Error.desc("%@.layout() you cannot use height:auto if ".fmt(this)+"staticLayout is disabled","%@".fmt(this),-1);SC.Logger.error(b.toString());throw b;}if(SC.none(h))if(SC.none(g))if(SC.none(r)){if(SC.none(l)){b.left=0;b.right=0;b.width=null}else{b.left=0;b.right=null;b.width=l===SC.LAYOUT_AUTO?
SC.LAYOUT_AUTO:SC.isPercentage(l)?l*100+"%":Math.floor(l)}b.marginLeft=0}else{b.left="50%";b.width=l&&SC.isPercentage(l)?l*100+"%":Math.floor(l||0);b.marginLeft=l&&SC.isPercentage(l)&&r>=0&&r<1?Math.floor((r-l/2)*100)+"%":l&&l>1&&(r>=1||r<=0)?Math.floor(r-b.width/2):0;b.right=null}else{b.right=SC.isPercentage(g)?Math.floor(g*100)+"%":Math.floor(g);b.marginLeft=0;if(SC.none(l)){if(SC.none(n))b.left=0;b.width=null}else{b.left=null;b.width=l===SC.LAYOUT_AUTO?SC.LAYOUT_AUTO:l&&SC.isPercentage(l)?l*100+
"%":Math.floor(l||0)}}else{b.left=SC.isPercentage(h)?h*100+"%":Math.floor(h);b.marginLeft=0;if(l!==undefined){b.width=l===SC.LAYOUT_AUTO?SC.LAYOUT_AUTO:SC.isPercentage(l)?l*100+"%":Math.floor(l);b.right=null}else{b.width=null;b.right=g&&SC.isPercentage(g)?g*100+"%":Math.floor(g||0)}}b.minWidth=a.minWidth===undefined?null:a.minWidth;b.maxWidth=a.maxWidth===undefined?null:a.maxWidth;if(SC.none(j))if(SC.none(k))if(SC.none(u)){if(SC.none(m)){b.top=0;b.bottom=0;b.height=null}else{b.top=0;b.bottom=null;
b.height=m===SC.LAYOUT_AUTO?SC.LAYOUT_AUTO:m&&SC.isPercentage(m)?m*100+"%":Math.floor(m||0)}b.marginTop=0}else{b.top="50%";b.bottom=null;b.height=m&&SC.isPercentage(m)?m*100+"%":Math.floor(m||0);if(m&&SC.isPercentage(m)&&u>=0&&u<1)b.marginTop=Math.floor((u-m/2)*100)+"%";else if(m&&m>1&&(u>=1||u<=0))b.marginTop=Math.floor(u-b.height/2);else{SC.Logger.error("You have to set height and centerY to use both percentages or pixels");b.marginTop=0}}else{b.marginTop=0;b.bottom=SC.isPercentage(k)?k*100+"%":
Math.floor(k);if(SC.none(m)){if(SC.none(o))b.top=0;b.height=null}else{b.top=null;b.height=m===SC.LAYOUT_AUTO?SC.LAYOUT_AUTO:m&&SC.isPercentage(m)?m*100+"%":Math.floor(m||0)}}else{b.top=SC.isPercentage(j)?j*100+"%":Math.floor(j);if(m!==undefined){b.height=m===SC.LAYOUT_AUTO?SC.LAYOUT_AUTO:SC.isPercentage(m)?m*100+"%":Math.floor(m);b.bottom=null}else{b.height=null;b.bottom=k&&SC.isPercentage(k)?k*100+"%":Math.floor(k||0)}b.marginTop=0}b.minHeight=a.minHeight===undefined?null:a.minHeight;b.maxHeight=
a.maxHeight===undefined?null:a.maxHeight;b.zIndex=SC.none(a.zIndex)?null:a.zIndex.toString();for(b.backgroundPosition=SC.none(a.backgroundPosition)?null:a.backgroundPosition.toString();--d>=0;){a=c[d];if(b[a]===0)b[a]=null}for(e in b){c=b[e];if(typeof c===SC.T_NUMBER)b[e]=c+"px"}return b}.property().cacheable(),layoutView:function(){return this.get("parentView")}.property("parentView").cacheable(),layoutDidChange:function(){this.beginPropertyChanges();this.frame&&this.notifyPropertyChange("frame");
this.notifyPropertyChange("layoutStyle");this.endPropertyChanges();var a=this.get("layoutView");if(a){a.set("childViewsNeedLayout",YES);a.layoutDidChangeFor(this);a.get("childViewsNeedLayout")&&a.invokeOnce(a.layoutChildViewsIfNeeded)}return this}.observes("layout"),childViewsNeedLayout:NO,layoutDidChangeFor:function(a){var b=this._needLayoutViews;if(!b)b=this._needLayoutViews=SC.CoreSet.create();b.add(a)},layoutChildViewsIfNeeded:function(a){a||(a=this.get("isVisibleInWindow"));if(a&&this.get("childViewsNeedLayout")){this.set("childViewsNeedLayout",
NO);this.layoutChildViews()}return this},layoutChildViews:function(){var a=this._needLayoutViews,b=a?a.length:0,c;for(c=0;c<b;++c)a[c].updateLayout();a.clear()},updateLayout:function(){var a=this.get("layer");if(a){a=this.renderContext(a);this.renderLayout(a);a.update()}return this},renderLayout:function(a){a.addStyle(this.get("layoutStyle"))},isView:YES,selectStart:function(){return this.get("isTextSelectable")},contextMenu:function(a){this.get("isContextMenuEnabled")||a.stop();return true}});
SC.View.mixin({isViewClass:YES,design:function(){if(this.isDesign)return this;var a=this.extend.apply(this,arguments);a.isDesign=YES;SC.ViewDesigner&&SC.ViewDesigner.didLoadDesign(a,this,SC.A(arguments));return a},layout:function(a){this.prototype.layout=a;return this},convertLayoutToAnchoredLayout:function(a,b){var c={top:0,left:0,width:b.width,height:b.height},d=b.width;b=b.height;var e=a.right,f=a.left,g=a.top,h=a.bottom,j=a.width,k=a.height,l=a.centerX,m=a.centerY;if(SC.none(f))if(SC.none(e))if(SC.none(l))if(SC.none(j)){c.left=
0;c.width=0}else{c.left=0;c.width=j===SC.LAYOUT_AUTO?SC.LAYOUT_AUTO:SC.isPercentage(j)?j*d:j}else{c.width=j&&SC.isPercentage(j)?j*d:j||0;c.left=(d-c.width)/2;c.left+=SC.isPercentage(l)?l*d:l}else if(SC.none(j)){c.left=0;c.width=e&&SC.isPercentage(e)?d-e*d:d-(e||0)}else if(j===SC.LAYOUT_AUTO)c.width=SC.LAYOUT_AUTO;else{c.width=SC.isPercentage(j)?j*d:j;SC.isPercentage(e);c.left=d-(c.width+e)}else{c.left=SC.isPercentage(f)?f*d:f;c.width=j!==undefined?j===SC.LAYOUT_AUTO?SC.LAYOUT_AUTO:SC.isPercentage(j)?
j*d:j:e&&SC.isPercentage(e)?d-c.left-e*d:d-c.left-(e||0)}if(a.minWidth!==undefined)c.minWidth=a.minWidth;if(a.maxWidth!==undefined)c.maxWidth=a.maxWidth;if(SC.none(g))if(SC.none(h))if(SC.none(m))if(SC.none(k)){c.top=0;c.height=0}else{c.top=0;c.height=k===SC.LAYOUT_AUTO?SC.LAYOUT_AUTO:SC.isPercentage(k)?k*b:k}else{c.height=k&&SC.isPercentage(k)?k*b:k||0;c.top=(b-c.height)/2;c.top+=SC.isPercentage(m)?m*b:m}else if(SC.none(k)){c.top=0;c.height=h&&SC.isPercentage(h)?b-h*b:b-(h||0)}else if(k===SC.LAYOUT_AUTO)c.height=
SC.LAYOUT_AUTO;else{c.height=SC.isPercentage(k)?k*b:k;c.top=b-c.height;c.top-=SC.isPercentage(h)?h*b:h}else{c.top=SC.isPercentage(g)?g*b:g;if(k!==undefined)c.height=k===SC.LAYOUT_AUTO?SC.LAYOUT_AUTO:SC.isPercentage(k)?k*b:k;else{c.height=b-c.top;c.height-=h&&SC.isPercentage(h)?h*b:h||0}}if(c.top)c.top=Math.floor(c.top);if(c.bottom)c.bottom=Math.floor(c.bottom);if(c.left)c.left=Math.floor(c.left);if(c.right)c.right=Math.floor(c.right);if(c.width!==SC.LAYOUT_AUTO)c.width=Math.floor(c.width);if(c.height!==
SC.LAYOUT_AUTO)c.height=Math.floor(c.height);if(a.minHeight!==undefined)c.minHeight=a.minHeight;if(a.maxHeight!==undefined)c.maxHeight=a.maxHeight;return c},convertLayoutToCustomLayout:function(){},classNames:function(a){a=(this.prototype.classNames||[]).concat(a);this.prototype.classNames=a;return this},tagName:function(a){this.prototype.tagName=a;return this},childView:function(a){var b=this.prototype.childViews||[];if(b===this.superclass.prototype.childViews)b=b.slice();b.push(a);this.prototype.childViews=
b;return this},bind:function(a,b){var c=this.prototype,d=this.superclass.prototype,e=c._bindings;if(!e||e===d._bindings)e=c._bindings=(e||[]).slice();a+="Binding";c[a]=b;e.push(a);return this},prop:function(a,b){this.prototype[a]=b;return this},localization:function(a,b){if(b)a.rootElement=SC.$(b)[0];return a},viewFor:function(a){var b=SC.$A(arguments);if(SC.none(a))b.shift();else b[0]={rootElement:SC.$(a)[0]};var c=this.create.apply(this,arguments);b[0]=null;return c},create:function(){var a=new this(arguments);
SC.ViewDesigner&&SC.ViewDesigner.didCreateView(a,SC.$A(arguments));return a},loc:function(a){var b=a.childViews;delete a.childViews;this.applyLocalizedAttributes(a);SC.ViewDesigner&&SC.ViewDesigner.didLoadLocalization(this,SC.$A(arguments));for(var c=this.prototype.childViews,d=c.length,e;--d>=0;){e=c[d];(a=b[d])&&e&&e.loc&&e.loc(a)}return this},applyLocalizedAttributes:function(a){SC.mixin(this.prototype,a)},views:{}});
SC.outlet=function(a){return function(b){return this[b]=SC.objectForPropertyPath(a,this)}.property()};SC.View.unload=function(){var a=SC.View.views;if(a)for(var b in a)a.hasOwnProperty(b)&&delete a[b]};SC.Event.add(window,"unload",SC.View,SC.View.unload);
SC.Validatable={initMixin:function(){this._validatable_validatorDidChange()},validator:null,errorLabel:null,isValid:function(){return SC.typeOf(this.get("value"))!==SC.T_ERROR}.property("value"),ownerForm:null,performValidate:function(a){var b=SC.VALIDATE_OK;if(this._validator){var c=this.get("ownerForm");if(a){b=this._validator.validatePartial(c,this);if(b==SC.VALIDATE_NO_CHANGE&&this._validator.validateChange(c,this)==SC.VALIDATE_OK)b=SC.VALIDATE_OK}else b=this._validator.validateChange(c,this)}return b},
performValidateSubmit:function(){return this._validator?this._validator.validateSubmit(this.get("ownerForm"),this):SC.VALIDATE_OK},performValidateKeyDown:function(a){a=a.getCharString();if(!a)return YES;return this._validator?this._validator.validateKeyDown(this.get("ownerForm"),this,a):YES},validatorObject:function(){return this._validator}.property(),validateSubmit:function(){return this.performValidateSubmit()},objectForFieldValue:function(a){return this._validator?this._validator.objectForFieldValue(a,
this.get("ownerForm"),this):a},fieldValueForObject:function(a){return this._validator?this._validator.fieldValueForObject(a,this.get("ownerForm"),this):a},_validatable_displayObserver:function(){this.displayDidChange()}.observes("isValid"),renderMixin:function(a){a.setClass("invalid",!this.get("isValid"))},_validatable_validatorDidChange:function(){var a=this.get("ownerForm"),b=SC.Validator.findFor(a,this,this.get("validator"));if(b!=this._validator){this.propertyWillChange("validatorObject");this._validator&&
this._validator.detachFrom(a,this);(this._validator=b)&&this._validator.attachTo(a,this);this.propertyDidChange("validatorObject")}}.observes("validator","ownerForm")};sc_require("views/view");sc_require("mixins/control");sc_require("mixins/validatable");
SC.FieldView=SC.View.extend(SC.Control,SC.Validatable,{isTextArea:NO,_field_isMouseDown:NO,fieldValue:function(){var a=this.get("value");if(SC.typeOf(a)===SC.T_ERROR)a=a.get("errorValue");return this.fieldValueForObject(a)}.property("value","validator").cacheable(),$input:function(){return this.get("isTextArea")?this.$("textarea").andSelf().filter("textarea"):this.$("input").andSelf().filter("input")},setFieldValue:function(a){if(SC.none(a))a="";var b=this.$input();b.val()!==a&&b.val(a);return this},
getFieldValue:function(){return this.$input().val()},_field_fieldValueDidChange:function(){SC.RunLoop.begin();this.fieldValueDidChange(NO);SC.RunLoop.end()},fieldValueDidChange:function(a){this.setIfChanged("value",this.objectForFieldValue(this.getFieldValue(),a))},_field_valueDidChange:function(){this.setFieldValue(this.get("fieldValue"))}.observes("fieldValue"),didCreateLayer:function(){this.setFieldValue(this.get("fieldValue"));SC.Event.add(this.$input(),"change",this,this._field_fieldValueDidChange)},
didAppendToDocument:function(){if(this.get("isTextArea")){this.setFieldValue(this.get("fieldValue"));SC.Event.add(this.$input(),"change",this,this._field_fieldValueDidChange)}},willDestroyLayer:function(){SC.Event.remove(this.$input(),"change",this,this._field_fieldValueDidChange)},mouseDown:function(a){this._field_isMouseDown=YES;a.allowDefault();return YES},mouseOut:function(a){this._field_isMouseDown&&this.set("isActive",NO);a.allowDefault();return YES},mouseOver:function(a){this.set("isActive",
this._field_isMouseDown);a.allowDefault();return YES},mouseUp:function(a){this._field_isMouseDown&&this.set("isActive",NO);this._field_isMouseDown=NO;a.allowDefault();return YES},keyDown:function(a){if(a.which===9){var b=a.shiftKey?this.get("previousValidKeyView"):this.get("nextValidKeyView");b?b.becomeFirstResponder():a.allowDefault();return YES}if(this.performValidateKeyDown(a)){this._isKeyDown=YES;a.allowDefault()}else a.stop();return YES},acceptsFirstResponder:function(){return SC.SAFARI_FOCUS_BEHAVIOR?
NO:this.get("isEnabled")}.property("isEnabled"),willBecomeKeyResponderFrom:function(){if(!this._isFocused){this._isFocused=YES;this.becomeFirstResponder();this.get("isVisibleInWindow")&&this.$input()[0].focus()}},willLoseKeyResponderTo:function(){if(this._isFocused)this._isFocused=NO},_field_setFieldValue:function(a){this.propertyWillChange("fieldValue");if(this.fieldValueForObject)a=this.fieldValueForObject(a);a=this.setFieldValue(a);this.propertyDidChange("fieldValue");return a},_field_getFieldValue:function(){var a=
this.getFieldValue();if(this.objectForFieldValue)a=this.objectForFieldValue(a);return a}});
SC.TextSelection=SC.Object.extend(SC.Copyable,SC.Freezable,{start:-1,end:-1,length:function(){var a=this.get("start"),b=this.get("end");return a===-1||b===-1?-1:b-a}.property("start","end").cacheable(),init:function(){arguments.callee.base.apply(this,arguments);this.freeze()},copy:function(){return SC.TextSelection.create({start:this.get("start"),end:this.get("end")})},toString:function(){var a=this.get("length");return a&&a>0?a===1?"[%@ character selected: {%@, %@}]".fmt(a,this.get("start"),this.get("end")):
"[%@ characters selected: {%@, %@}]".fmt(a,this.get("start"),this.get("end")):"[no text selected; caret at %@]".fmt(this.get("start"))}});SC.StaticLayout={hasStaticLayout:YES,useStaticLayout:NO,renderMixin:function(a){a.setClass("sc-static-layout",this.get("useStaticLayout"))},parentViewDidResize:function(){return null},beginLiveResize:function(){return null},endLiveResize:function(){return null},viewDidResize:function(){return null}};sc_require("views/field");sc_require("system/text_selection");
sc_require("mixins/static_layout");
SC.TextFieldView=SC.FieldView.extend(SC.StaticLayout,SC.Editable,{tagName:"label",classNames:["sc-text-field-view"],applyImmediately:YES,isPassword:NO,isTextArea:NO,hint:null,isEditing:NO,leftAccessoryView:null,rightAccessoryView:null,_isFocused:NO,_ignoreBlur:null,routeTouch:NO,isEditable:function(){return this.get("isEnabled")}.property("isEnabled").cacheable(),selection:function(a,b){a=this.$input()[0];var c,d;if(b===undefined)if(a){c=d=null;if(a.value){if("selectionStart"in a)d=a.selectionStart;
if("selectionEnd"in a)c=a.selectionEnd;if(d===null||c===null)if(b=document.selection){var e=b.type;if(e&&(e==="None"||e==="Text")){c=b.createRange();if(this.get("isTextArea")){d=c.duplicate();d.moveToElementText(a);d.setEndPoint("EndToStart",c);d=d.text.length;c=d+c.text.length}else{b=c.text.length;d=Math.abs(c.moveStart("character",0-(a.value.length+1)));c=d+b}}}}else d=c=0;return SC.TextSelection.create({start:d,end:c})}else return null;else{if(!b||!b.kindOf||!b.kindOf(SC.TextSelection))throw"When setting the selection, you must specify an SC.TextSelection instance.";
if(a)if(a.setSelectionRange)a.setSelectionRange(b.get("start"),b.get("end"));else{c=a.createTextRange();d=b.get("start");c.move("character",d);c.moveEnd("character",b.get("end")-d);c.select()}return b}}.property("fieldValue").cacheable(),displayProperties:"hint fieldValue isEditing leftAccessoryView rightAccessoryView isTextArea".w(),createChildViews:function(){this.accessoryViewObserver()},acceptsFirstResponder:function(){return this.get("isEnabled")}.property("isEnabled"),accessoryViewObserver:function(){var a,
b=["leftAccessoryView","rightAccessoryView"],c=b.length,d,e,f,g;for(d=0;d<c;d++){e=b[d];f=this["_"+e];g=this.get(e);if(!(f&&g&&f===g)){if(f){a=f.get("classNames");a=a.without("sc-text-field-accessory-view");f.set("classNames",a);this.removeChild(f);this["_"+e]=null}if(g){if(g.isClass)g=g.create({layoutView:this});a=g.get("classNames");a.indexOf("sc-text-field-accessory-view")<0&&a.push("sc-text-field-accessory-view");this.appendChild(g);this["_"+e]=g}}}}.observes("leftAccessoryView","rightAccessoryView"),
layoutChildViewsIfNeeded:function(a){a||(a=this.get("isVisibleInWindow"));if(a&&this.get("childViewsNeedLayout")){var b=this.get("rightAccessoryView");if(b&&b.get){var c=b.get("layout");if(c){c.left=null;if(!c.right)c.right=0;b.adjust({layout:c})}}}arguments.callee.base.apply(this,arguments)},render:function(a,b){arguments.callee.base.apply(this,arguments);this.get("isEnabled");SC.guidFor(this);this.get("isPassword");var c,d,e;this.get("isTextArea")&&a.addClass("text-area");c=this.get("fieldValue");
if(SC.none(c))c="";c=String(c);a.setClass("not-empty",c.length>0);d=this._getAccessoryViewWidths();e=d.left;d=d.right;if(e)e+="px";if(d)d+="px";this._renderField(a,b,c,e,d);SC.browser.mozilla&&this.invokeLast(this._applyFirefoxCursorFix)},_forceRenderFirstTime:NO,_renderFieldLikeFirstTime:function(){this.set("_forceRenderFirstTime",YES)}.observes("isTextArea"),_renderField:function(a,b,c,d,e){var f=this.get("hint"),g,h;if(b||this._forceRenderFirstTime){this._forceRenderFirstTime=NO;b=this.get("isEnabled")?
"":'disabled="disabled"';g=this.get("layerId");a.push('<span class="border"></span>');h="";if(d||e){h='style="';if(d)h+="left: "+d+"; ";if(e)h+="right: "+e+";";h+='"'}a.push('<span class="padding" '+h+">",'<span class="sc-hint">',f,"</span>");c=this.get("escapeHTML")?SC.RenderContext.escapeHTML(c):c;if(this.get("isTextArea"))a.push('<textarea name="',g,'" ',b,">",c,"</textarea></span>");else{d=this.get("isPassword")?"password":"text";a.push('<input type="',d,'" name="',g,'" ',b,' value="',c,'"/></span>')}}else{a=
this.$(".sc-hint");if(f!==this._textField_currentHint){this._textField_currentHint=f;a.text(f)}if(a=this.$input()[0]){a.disabled=this.get("isEnabled")?null:"true";a=a.parentNode.style;if(d){if(a.left!==d)a.left=d}else a.left=null;if(e){if(a.right!==e)a.right=e}else a.right=null}}},_getAccessoryViewWidths:function(){var a={},b=["left","right"],c=b.length,d,e,f,g;for(d=0;d<c;d++){e=b[d];if((f=this.get(e+"AccessoryView"))&&f.get)if(g=f.get("frame"))if(g=g.width){if(f=f.get("layout")){f=f[e];g+=f}a[e]=
g}}return a},didCreateLayer:function(){arguments.callee.base.apply(this,arguments);this.get("isTextArea")?this.invokeLast(this._addTextAreaEvents):this._addTextAreaEvents()},_addTextAreaEvents:function(){var a=this.$input();SC.Event.add(a,"focus",this,this._textField_fieldDidFocus);SC.Event.add(a,"blur",this,this._textField_fieldDidBlur);SC.Event.add(a,"select",this,this._textField_selectionDidChange);if(SC.browser.mozilla){this._cacheInputElement=this.$input();this._cachePaddingElement=this.$(".padding")}},
willDestroyLayer:function(){arguments.callee.base.apply(this,arguments);var a=this.$input();SC.Event.remove(a,"focus",this,this._textField_fieldDidFocus);SC.Event.remove(a,"blur",this,this._textField_fieldDidBlur);SC.Event.remove(a,"select",this,this._textField_selectionDidChange)},_textField_fieldDidFocus:function(){SC.RunLoop.begin();this.fieldDidFocus();SC.RunLoop.end()},_textField_fieldDidBlur:function(){SC.RunLoop.begin();this._ignoreBlur=true;this.fieldDidBlur();this._ignoreBlur=false;SC.RunLoop.end()},
fieldDidFocus:function(){this.beginEditing()},fieldDidBlur:function(){this.commitEditing()},_topOffsetForFirefoxCursorFix:3,_applyFirefoxCursorFix:function(){if(parseFloat(SC.browser.mozilla)<1.9&&!this.get("useStaticLayout")){var a,b,c,d,e;e=this._cacheInputElement;if((a=this._cachePaddingElement)&&a[0]){d=a[0];b=SC.$(d).offset();a=SC.browser.compareVersion(1,9,2)<0&&e[0].tagName.toLowerCase()==="input"?b.top+this._topOffsetForFirefoxCursorFix:b.top;b=b.left;c=d.offsetWidth;d=d.offsetHeight;a="position: fixed; top: %@px; left: %@px; width: %@px; height: %@px;".fmt(a,
b,c,d);if(!this._prevStyle||this._prevStyle!=a)e.attr("style",a);this._prevStyle=a}}return this},_textField_selectionDidChange:function(){this.notifyPropertyChange("selection")},willBecomeKeyResponderFrom:function(){if(this.get("isVisibleInWindow")){var a=this.$input()[0];a&&a.focus();if(!this._txtFieldMouseDown)if(SC.browser.mozilla)this.invokeOnce(this._selectRootElement);else SC.browser.safari?this.invokeLater(this._selectRootElement,1):this._selectRootElement()}},willLoseKeyResponderTo:function(){},
_selectRootElement:function(){this.$input()[0].select()},didLoseKeyResponderTo:function(){SC.none(this._ignoreBlur)&&this.$input()[0].blur()},parentViewDidResize:function(){SC.browser.mozilla&&this.invokeLast(this._applyFirefoxCursorFix);arguments.callee.base.apply(this,arguments)},keyDown:function(a){if(a.which===13&&!a.isIMEInput&&!this.get("isTextArea"))return NO;if(a.which===27)return NO;if(a.which===9){var b=a.shiftKey?this.get("previousValidKeyView"):this.get("nextValidKeyView");b?b.becomeFirstResponder():
a.allowDefault();return YES}if(this.performValidateKeyDown(a)){this._isKeyDown=YES;a.allowDefault()}else a.stop();return YES},keyUp:function(a){this.notifyPropertyChange("selection");this._isKeyDown&&this.get("applyImmediately")&&this.invokeLater(this.fieldValueDidChange,1,YES);this._isKeyDown=NO;a.allowDefault();return YES},mouseDown:function(a){var b=this.get("fieldValue");this._txtFieldMouseDown=YES;if(this.get("isEnabled"))if(b&&b.length===0||!b){this.$input()[0].focus();return YES}else{SC.browser.safari||
this.$input()[0].focus();return arguments.callee.base.apply(this,arguments)}else{a.stop();return YES}},mouseUp:function(a){var b=this.get("fieldValue");this._txtFieldMouseDown=NO;this.notifyPropertyChange("selection");if(this.get("isEnabled"))if(b&&b.length===0||!b){SC.browser.msie<8?this.invokeLater(this.focusIE7,1):this.$input()[0].focus();return YES}else return arguments.callee.base.apply(this,arguments);else{a.stop();return YES}},focusIE7:function(){this.$input()[0].focus()},selectStart:function(){return YES}});
sc_require("views/text_field");
SC.InlineTextFieldView=SC.TextFieldView.extend(SC.DelegateSupport,{_topOffsetForFirefoxCursorFix:0,beginEditing:function(a){if(a){var b={},c,d,e=this._delegate=a.delegate;if(this.invokeDelegateMethod(e,"inlineEditorShouldBeginEditing",this)){this.beginPropertyChanges();if(this.get("isEditing")&&!this.blurEditor()){this.endPropertyChanges();return NO}this._optframe=a.frame;this._optIsCollection=a.isCollection;this._exampleElement=a.exampleElement;this._delegate=a.delegate;this.set("delegate",this._delegate);
if(!this._optframe||!this._delegate)throw"At least frame and delegate options are required for inline editor";this._originalValue=a.value||"";(this._multiline=a.multiline!==undefined?a.multiline:NO)?this.set("isTextArea",YES):this.set("isTextArea",NO);this._commitOnBlur=a.commitOnBlur!==undefined?a.commitOnBlur:YES;this.set("validator",a.validator);this.set("value",this._originalValue);this.set("isEditing",YES);a=this._delegate.pane();b.height=this._optframe.height;b.width=this._optframe.width;c=
this._delegate.get("layout");d=a.$()[0];b.left=this._optIsCollection&&c.left?this._optframe.x-c.left-d.offsetLeft-1:this._optframe.x-d.offsetLeft-1;SC.browser.msie==7&&b.left--;b.top=this._optIsCollection&&c.top?this._optframe.y-c.top-d.offsetTop:this._optframe.y-d.offsetTop;if(SC.browser.msie==7)b.top-=2;this.set("layout",b);this.set("parentNode",a);a.appendChild(this);SC.RunLoop.begin().end();(this._className=this.getDelegateProperty(e,"inlineEditorClassName"))&&!this.hasClassName(this._className)&&
this.setClassName(this._className,true);this.invokeDelegateMethod(e,"inlineEditorWillBeginEditing",this);this._previousFirstResponder=a?a.get("firstResponder"):null;this.endPropertyChanges();this.invokeLast(function(){this.becomeFirstResponder();this.invokeDelegateMethod(e,"inlineEditorDidBeginEditing",this)})}}},commitEditing:function(){if(!SC.$ok(this.validateSubmit()))return NO;return this._endEditing(this.get("value"))},discardEditing:function(){return this._endEditing(this._originalValue)},blurEditor:function(){if(!this.get("isEditing"))return YES;
return this._commitOnBlur?this.commitEditing():this.discardEditing()},_endEditing:function(a){if(!this.get("isEditing"))return YES;var b=this._delegate;if(!this.invokeDelegateMethod(b,"inlineEditorShouldEndEditing",this,a))return NO;this.invokeDelegateMethod(b,"inlineEditorDidEndEditing",this,a);this._className&&this.setClassName(this._className,false);this._originalValue=this._delegate=this._exampleElement=this._optframe=this._className=null;this.set("isEditing",NO);if(this.get("isFirstResponder"))(a=
this.get("pane"))&&this._previousFirstResponder?a.makeFirstResponder(this._previousFirstResponder):this.resignFirstResponder();this._previousFirstResponder=null;this.get("parentNode")&&this.removeFromParent();return YES},isEditing:NO,mouseDown:function(a){arguments.callee.base.call(this,a);return this.get("isEditing")},keyDown:function(a){a=this.interpretKeyEvents(a);this.fieldValueDidChange(true);return!a?NO:a},insertText:null,willRemoveFromParent:function(){this.$input()[0].blur()},willLoseFirstResponder:function(a){if(a===
this){this._previousFirstResponder=null;this.$input()[0].blur();return this.blurEditor()}},cancel:function(){this.discardEditing();return YES},fieldValueDidChange:function(a){arguments.callee.base.call(this,a)},insertNewline:function(a){if(this._multiline){a.allowDefault();return arguments.callee.base.call(this,a)}else{this.get("value")!=this.$input().val()&&this.set("value",this.$input().val());this.commitEditing();return YES}},insertTab:function(){this.resignFirstResponder();this.commitEditing();
if(this._delegate){var a=this._delegate.nextValidKeyView();a&&a.beginEditing&&a.beginEditing()}return YES},insertBacktab:function(){this.commitEditing();if(this._delegate){var a=this._delegate.previousValidKeyView();a&&a.beginEditing()}return YES},deleteForward:function(a){a.allowDefault();return YES},deleteBackward:function(a){a.allowDefault();return YES}});
SC.InlineTextFieldView.mixin({beginEditing:function(a){this._exampleElement=a.exampleElement;var b=a.exampleInlineTextFieldView?a.exampleInlineTextFieldView:this,c=a.delegate.get("layout"),d=this.updateViewStyle(),e=this.updateViewPaddingStyle(),f=".inline-editor input{"+d+"} ";f=f+".inline-editor textarea{"+d+"} .inline-editor .padding{"+e+"}";d=document.getElementsByTagName("head")[0];e=document.createElement("style");e.type="text/css";e.media="screen";if(e.styleSheet)e.styleSheet.cssText=f;else e.appendChild(document.createTextNode(f));
d.appendChild(e);this.editor=b.create({classNames:"inline-editor",layout:c});return this.editor.beginEditing(a)},commitEditing:function(){return this.editor?this.editor.commitEditing():YES},discardEditing:function(){return this.editor?this.editor.discardEditing():YES},updateViewStyle:function(){var a=this._exampleElement[0],b="",c=SC.getStyle(a,"font-size");if(c&&c.length>0)b=b+"font-size: "+c+" !important; ";if((c=SC.getStyle(a,"font-family"))&&c.length>0)b=b+"font-family: "+c+" !important; ";if((c=
SC.getStyle(a,"font-weight"))&&c.length>0)b=b+"font-weight: "+c+" !important; ";if((c=SC.getStyle(a,"z-index"))&&c.length>0)b=b+"z-index: "+c+" !important; ";if((c=SC.getStyle(a,"line-height"))&&c.length>0)b=b+"line-height: "+c+" !important; ";if((c=SC.getStyle(a,"text-align"))&&c.length>0)b=b+"text-align: "+c+" !important; ";if((c=SC.getStyle(a,"top-margin"))&&c.length>0)b=b+"top-margin: "+c+" !important; ";if((c=SC.getStyle(a,"bottom-margin"))&&c.length>0)b=b+"bottom-margin: "+c+" !important; ";
if((c=SC.getStyle(a,"left-margin"))&&c.length>0)b=b+"left-margin: "+c+" !important; ";if((c=SC.getStyle(a,"right-margin"))&&c.length>0)b=b+"right-margin: "+c+" !important; ";return b},updateViewPaddingStyle:function(){var a=this._exampleElement[0],b="",c=SC.getStyle(a,"padding-top");if(c&&c.length>0)b=b+"top: "+c+" !important; ";if((c=SC.getStyle(a,"padding-bottom"))&&c.length>0)b=b+"bottom: "+c+" !important; ";if((c=SC.getStyle(a,"padding-left"))&&c.length>0)b=b+"left: "+c+" !important; ";if((c=
SC.getStyle(a,"padding-right"))&&c.length>0)b=b+"right: "+c+" !important; ";return b},editor:null});sc_require("views/view");
SC.Pane=SC.View.extend({isPane:YES,page:null,rootResponder:null,currentWindowSize:null,computeParentDimensions:function(){var a=this.get("currentWindowSize"),b={x:0,y:0,width:1E3,height:1E3};if(a){b.width=a.width;b.height=a.height}else if(SC.RootResponder.responder){if(a=SC.RootResponder.responder.get("currentWindowSize")){b.width=a.width;b.height=a.height}}else{if(window.innerHeight){b.width=window.innerWidth;b.height=window.innerHeight}else if(document.documentElement&&document.documentElement.clientHeight){b.width=
document.documentElement.clientWidth;b.height=document.documentElement.clientHeight}else if(document.body){b.width=document.body.clientWidth;b.height=document.body.clientHeight}this.windowSizeDidChange(null,b)}return b},frame:function(){return this.computeFrameWithParentFrame(null)}.property(),windowSizeDidChange:function(a,b){this.set("currentWindowSize",b);this.parentViewDidResize();return this},paneLayoutDidChange:function(){this.invokeOnce(this.updateLayout)}.observes("layout"),sendEvent:function(a,
b,c){for(c||(c=this.get("firstResponder"));c&&!c.tryToPerform(a,b);)c=c===this?null:c.get("nextResponder");if(!c&&(c=this.get("defaultResponder"))){if(typeof c===SC.T_STRING)c=SC.objectForPropertyPath(c);c=c?c.isResponderContext?c.sendAction(a,this,b):c.tryToPerform(a,b)?c:null:null}return b.mouseHandler||c},sendTouchEvent:function(a,b,c){var d,e=NO,f=[];for(c||(c=this.get("firstResponder"));c;){if(c.respondsTo(a))switch(c[a](b)){case SC.MIXED_STATE:f.push(c);break;case YES:f=[c];c=null;e=YES;continue}c=
c===this?null:c.get("nextResponder")}if(!e&&(c=this.get("defaultResponder"))){if(typeof c===SC.T_STRING)c=SC.objectForPropertyPath(c);if(c)if(c.isResponderContext)f=f.concat(c.sendTouchAction(a,this,b));else{if(c.respondsTo(a))d=c[a](b);switch(d){case SC.MIXED_STATE:f.push(c);break;case YES:f=[c]}}}return f},performKeyEquivalent:function(a,b){var c=arguments.callee.base.apply(this,arguments);if(!c){var d=this.get("defaultResponder");if(d){if(d.performKeyEquivalent)c=d.performKeyEquivalent(a,b);if(!c&&
d.tryToPerform)c=d.tryToPerform(a,b)}}return c},defaultResponder:null,nextResponder:function(){return null}.property().cacheable(),firstResponder:null,acceptsKeyPane:YES,isKeyPane:NO,becomeKeyPane:function(){if(this.get("isKeyPane"))return this;this.rootResponder&&this.rootResponder.makeKeyPane(this);return this},resignKeyPane:function(){if(!this.get("isKeyPane"))return this;this.rootResponder&&this.rootResponder.makeKeyPane(null);return this},makeFirstResponder:function(a){var b=this.get("firstResponder"),
c=this.get("isKeyPane");if(b===a)return this;b&&b.willLoseFirstResponder(b);if(c){b&&b.willLoseKeyResponderTo(a);a&&a.willBecomeKeyResponderFrom(b)}b&&b.beginPropertyChanges().set("isFirstResponder",NO).set("isKeyResponder",NO).endPropertyChanges();this.set("firstResponder",a);a&&a.beginPropertyChanges().set("isFirstResponder",YES).set("isKeyResponder",c).endPropertyChanges();if(c){a&&a.didBecomeKeyResponderFrom(b);b&&b.didLoseKeyResponderTo(a)}a&&a.didBecomeFirstResponder(a);return this},_forwardKeyChange:function(a,
b,c,d){var e;if(a&&(e=this.get("firstResponder"))){c=c?c.get("firstResponder"):null;(a=this.get("firstResponder"))&&a[b](c);d!==undefined&&e&&e.set("isKeyResponder",d)}},willLoseKeyPaneTo:function(a){this._forwardKeyChange(this.get("isKeyPane"),"willLoseKeyResponderTo",a,NO);return this},willBecomeKeyPaneFrom:function(a){this._forwardKeyChange(!this.get("isKeyPane"),"willBecomeKeyResponderFrom",a,YES);return this},didLoseKeyPaneTo:function(a){var b=this.get("isKeyPane");this.set("isKeyPane",NO);this._forwardKeyChange(b,
"didLoseKeyResponderTo",a);return this},didBecomeKeyPaneFrom:function(a){var b=this.get("isKeyPane");this.set("isKeyPane",YES);this._forwardKeyChange(!b,"didBecomeKeyResponderFrom",a,YES);return this},isMainPane:NO,focusFrom:function(){},blurTo:function(){},blurMainTo:function(){this.set("isMainPane",NO)},focusMainFrom:function(){this.set("isMainPane",YES)},append:function(){return this.appendTo(document.body)},remove:function(){if(!this.get("isVisibleInWindow"))return this;if(!this.get("isPaneAttached"))return this;
this.set("isVisibleInWindow",NO);var a=this.get("layer");a.parentNode&&a.parentNode.removeChild(a);this.resignKeyPane();a=this.rootResponder;this.get("isMainPane")&&a.makeMainPane(null);a.panes.remove(this);this.rootResponder=null;this.set("isPaneAttached",NO);return this},appendTo:function(a){var b=this.get("layer");b||(b=this.createLayer().get("layer"));if(this.get("isPaneAttached")&&b.parentNode===a)return this;a.insertBefore(b,null);return this.paneDidAttach()},prependTo:function(a){if(this.get("isPaneAttached"))return this;
var b=this.get("layer");b||(b=this.createLayer().get("layer"));if(this.get("isPaneAttached")&&b.parentNode===a)return this;a.insertBefore(b,a.firstChild);return this.paneDidAttach()},before:function(a){if(this.get("isPaneAttached"))return this;var b=this.get("layer");b||(b=this.createLayer().get("layer"));var c=a.parentNode;if(this.get("isPaneAttached")&&b.parentNode===c)return this;c.insertBefore(b,a);return this.paneDidAttach()},after:function(a){var b=this.get("layer");b||(b=this.createLayer().get("layer"));
var c=a.parentNode;if(this.get("isPaneAttached")&&b.parentNode===c)return this;c.insertBefore(b,a.nextSibling);return this.paneDidAttach()},removeFromParent:function(){},paneDidAttach:function(){var a=this.rootResponder=SC.RootResponder.responder;a.panes.add(this);this.set("currentWindowSize",a.computeWindowSize());this.set("isPaneAttached",YES);this.parentViewDidChange();this._notifyDidAppendToDocument();return this},isPaneAttached:NO,recomputeIsVisibleInWindow:function(){this.get("isVisibleInWindow");
var a=this.get("isVisible");this.set("isVisibleInWindow",a);this._needsVisibiltyChange=YES;a&&this.get("layerNeedsUpdate")&&this.updateLayerIfNeeded();a&&this.get("childViewsNeedLayout")&&this.layoutChildViewsIfNeeded();var b=this.get("childViews"),c=b.length,d;for(d=0;d<c;d++)b[d].recomputeIsVisibleInWindow(a);!a&&this.get("isFirstResponder")&&this.resignFirstResponder();if(a){this.parentViewDidResize&&this.parentViewDidResize();this.get("childViewsNeedLayout")&&this.invokeOnce(this.layoutChildViewsIfNeeded)}return this},
updateLayerLocation:function(){return this},init:function(){var a=!!this.get("layer");arguments.callee.base.apply(this,arguments);var b=this.get("theme");if(!b&&"undefined"!==ENV)b=ENV.theme;if(b){var c=this.get("classNames").copy();c.push(b);this.set("classNames",c)}a&&this.paneDidAttach()},classNames:function(){var a=["sc-pane"],b,c,d,e;b=SC.browser.current;c=SC.browser.windows?"windows":SC.browser.mac?"mac":"other-platform";e=document.documentElement.style;d=e.MozBoxShadow!==undefined||e.webkitBoxShadow!==
undefined||e.oBoxShadow!==undefined||e.boxShadow!==undefined;e=e.MozBorderRadius!==undefined||e.webkitBorderRadius!==undefined||e.oBorderRadius!==undefined||e.borderRadius!==undefined;d&&a.push("box-shadow");e&&a.push("border-rad");a.push(b);a.push(c);SC.browser.msie==7&&a.push("ie7");SC.browser.mobileSafari&&a.push("mobile-safari");return a}()});sc_require("system/responder");
SC.ResponderContext=SC.Responder.extend({isResponderContext:YES,trace:NO,defaultResponder:null,nextResponder:function(){return this.get("defaultResponder")}.property("defaultResponder").cacheable(),firstResponder:null,nextResponderFor:function(a){var b=a.get("nextResponder");if(typeof b===SC.T_STRING)b=SC.objectForPropertyPath(b,this);else if(!b&&a!==this)b=this;return b},responderNameFor:function(a){if(a){if(a._scrc_name)return a._scrc_name}else return"(No Responder)";this._findResponderNamesFor(this,
3,this.NAMESPACE?[this.NAMESPACE]:[]);return a._scrc_name||a.toString()},_findResponderNamesFor:function(a,b,c){var d,e;for(d in a)if(d!=="nextResponder")if((e=a[d])&&e.isResponder)if(!e._scrc_name){c.push(d);e._scrc_name=c.join(".");b>0&&this._findResponderNamesFor(e,b-1,c);c.pop()}},makeFirstResponder:function(a){var b=this.get("firstResponder"),c=this.get("nextResponder"),d=this.get("trace");if(this._locked){d&&SC.Logger.log("%@: AFTER ACTION: makeFirstResponder => %@".fmt(this,this.responderNameFor(a)));
this._pendingResponder=a}else{d&&SC.Logger.log("%@: makeFirstResponder => %@".fmt(this,this.responderNameFor(a)));a.set("becomingFirstResponder",YES);this._locked=YES;this._pendingResponder=null;for(d=a?a:null;d;){if(d.get("hasFirstResponder"))break;d=d===c?null:this.nextResponderFor(d)}d||(d=c);this._notifyWillLoseFirstResponder(b,b,d);b&&b.set("isFirstResponder",NO);this.beginPropertyChanges();this.set("firstResponder",a);a&&a.set("isFirstResponder",YES);this._notifyDidBecomeFirstResponder(a,a,
d);this.endPropertyChanges();this._locked=NO;if(this._pendingResponder){this.makeFirstResponder(this._pendingResponder);this._pendingResponder=null}a.set("becomingFirstResponder",NO);return this}},_notifyWillLoseFirstResponder:function(a,b,c){if(b!==c){b.willLoseFirstResponder(a);b.set("hasFirstResponder",NO);(b=this.nextResponderFor(b))&&this._notifyWillLoseFirstResponder(a,b,c)}},_notifyDidBecomeFirstResponder:function(a,b,c){if(b!==c){var d=this.nextResponderFor(b);d&&this._notifyDidBecomeFirstResponder(a,
d,c);b.set("hasFirstResponder",YES);b.didBecomeFirstResponder(a)}},sendAction:function(a,b,c){var d=this.get("firstResponder"),e=this.get("nextResponder"),f=this.get("trace"),g=NO;this._locked=YES;for(f&&SC.Logger.log("%@: begin action '%@' (%@, %@)".fmt(this,a,b,c));!g&&d;){if(d.tryToPerform)g=d.tryToPerform(a,b,c);g||(d=d===e?null:this.nextResponderFor(d))}if(f)g?SC.Logger.log("%@: action '%@' handled by %@".fmt(this,a,this.responderNameFor(d))):SC.Logger.log("%@:  action '%@' NOT HANDLED".fmt(this,
a));this._locked=NO;if(a=this._pendingResponder){this._pendingResponder=null;this.makeFirstResponder(a)}return d}});sc_require("system/responder_context");SC.Application=SC.ResponderContext.extend({});sc_require("core");
SC.Benchmark={verbose:NO,enabled:YES,stats:{},globalStartTime:null,start:function(a,b,c,d){if(this.enabled){c=c||Date.now();b=b?this._subStatFor(a,b):this._statFor(a);d&&b._starts.length>0?b._starts.push("ignore"):b._starts.push(c);b._times.push({start:c,_subStats:{}});return a}},end:function(a,b,c){if(this.enabled){b=b?this._subStatFor(a,b):this._statFor(a);var d=b._starts.pop();if(d){if(d!="ignore"){c=c||Date.now();d=c-d;b._times[b._times.length-1].end=c;b._times[b._times.length-1].dur=d;b.amt+=
d;b.runs++;this.verbose&&this.log(a)}}else SC.Logger.log('SC.Benchmark "%@" ended without a matching start.  No information was saved.'.fmt(a))}},setGlobalStartTime:function(a){this.globalStartTime=a},bench:function(a,b,c){b||(b="bench%@".fmt(this._benchCount++));c||(c=1);for(var d;--c>=0;){var e=SC.Benchmark.start(b);d=a();SC.Benchmark.end(e)}return d},install:function(a,b,c){a["b__"+b]=a[b];var d=a["b__"+b];a[b]=function(){var e="%@(%@)".fmt(b,$A(arguments).join(", "));SC.Benchmark.start(e,c);var f=
d.apply(this,arguments);SC.Benchmark.end(e);return f}},restore:function(a,b){a[b]=a["b__"+b]},report:function(a){if(a)return this._genReport(a);a=[];for(var b in this.stats)this.stats.hasOwnProperty(b)&&a.push(this._genReport(b));return a.join("\n")},timelineReport:function(a){a=a?"SproutCore Application":a;a=[a,"User-Agent: %@".fmt(navigator.userAgent),"Report Generated: %@ (%@)".fmt((new Date).toString(),Date.now()),""];for(var b=this._compileChartData(true),c=0;c<b.length;c++)b[c][4]?a.push(this._timelineGenSubReport(b[c])):
a.push(this._timelineGenReport(b[c]));return a.join("\n")},timelineChart:function(a){var b=0;this.hideChart();var c=this._compileChartData(false),d=c.length;if(d!==0){var e=this.globalStartTime?this.globalStartTime:c[0][1];b=c[d-1][2]-e;var f=50+d*30,g=Math.ceil(b/200)+1,h=g*50,j=document.createElement("div");j.className="sc-benchmark-graph";document.body.appendChild(j);var k=document.createElement("div");k.innerHTML=(a?a:"SproutCore Application")+(" - Total Captured Time: "+b+" ms - Points Captured: "+
d)+' [<a href="javascript:SC.Benchmark.hideChart();">Hide Chart</a>]';k.className="sc-benchmark-title";j.appendChild(k);b=document.createElement("div");b.className="sc-benchmark-top";b.style.width=h+"px";j.appendChild(b);for(b=0;b<g;b++){a=document.createElement("div");a.className="sc-benchmark-tick";a.style.left=b*50+"px";a.style.height=f+"px";k=document.createElement("div");k.className="sc-benchmark-tick-label";k.style.left=b*50+"px";k.innerHTML=b*200+" ms";j.appendChild(a);j.appendChild(k)}for(b=
0;b<d;b++){f=document.createElement("div");f.style.top=75+b*30+"px";f.style.width=h+"px";f.className=b%2===0?"sc-benchmark-row even":"sc-benchmark-row";j.appendChild(f);f=document.createElement("div");g=c[b][1];a=c[b][2];k=c[b][3];f.innerHTML="&nbsp;"+(c[b][0]+" <span class='sc-benchmark-emphasis'>"+k+"ms</span>");f.className="sc-benchmark-bar";f.style.cssText="left:"+(g-e)/4+"px; width: "+k/4+"px; top: "+(53+b*30)+"px;";f.title="start: "+(g-e)+" ms, end: "+(a-e)+" ms, duration: "+k+" ms";j.appendChild(f)}this._graph=
j}},hideChart:function(){if(this._graph)try{document.body.removeChild(this._graph)}catch(a){}},log:function(a){SC.Logger.log(this.report(a))},startProfile:function(a){this.enabled&&console&&console.profile&&console.profile(a)},endProfile:function(a){this.enabled&&console&&console.profileEnd&&console.profileEnd(a)},_compileChartData:function(a){var b=[],c;for(var d in this.stats)for(var e=this.stats[d],f=0;f<e._times.length;f++){var g=e._times[f];c=e._times.length>1?f+1+" - "+d:d;b.push([c,g.start,
g.end,g.dur,false]);if(a){g=g._subStats;for(var h in g)for(var j=g[h],k=0;k<j._times.length;k++){var l=j._times[k];c=j._times.length>1?k+1+" - "+h:h;b.push([c,l.start,l.end,l.dur,true])}}}b.sort(function(m,n){if(m[1]<n[1])return-1;else if(m[1]==n[1]){if(m[3]&&!n[3])return-1;if(!m[3]&&n[3])return 1;return 0}return 1});return b},_genReport:function(a){var b=this._statFor(a);return"BENCH %@ msec: %@ (%@x)".fmt(b.runs>0?Math.floor(b.amt*1E3/b.runs)/1E3:0,b.name||a,b.runs)},_timelineGenReport:function(a){return this.globalStartTime?
"BENCH start: %@ msec, duration: %@ msec,  %@".fmt(a[1]-this.globalStartTime,a[3],a[0]):"BENCH duration: %@ msec, %@".fmt(a[3],a[0])},_timelineGenSubReport:function(a){return this.globalStartTime?"   CHECKPOINT BENCH start: %@ msec, duration: %@ msec,  %@".fmt(a[1]-this.globalStartTime,a[3],a[0]):"   CHECKPOINT BENCH duration: %@ msec, %@".fmt(a[3],a[0])},_subStatFor:function(a,b){if(this.stats[b]._times.length!==0){b=this.stats[b]._times[this.stats[b]._times.length-1]._subStats;var c=b[a];if(!c){b[a]=
{runs:0,amt:0,name:a,_starts:[],_times:[]};c=b[a]}return c}},_statFor:function(a){var b=this.stats[a];if(!b){this.stats[a]={runs:0,amt:0,name:a,_starts:[],_times:[]};b=this.stats[a]}return b},reset:function(){this.stats={}},_bench:function(a,b){SC.Benchmark.bench(a,b,1)},_benchCount:1};SC.Benchmark=SC.Benchmark;
SC.mixin({logBundleLoading:NO,bundleIsLoaded:function(a){return tiki.ready(a)},loadBundle:function(a,b,c){if(c===undefined&&SC.typeOf(b)===SC.T_FUNCTION){c=b;b=null}var d=SC.A(arguments).slice(3);if(b&&c===undefined){c=b;b=this}var e=function(){if(SC.T_STRING===typeof b)b=SC.objectForPropertyPath(b);if(SC.T_STRING===typeof c)c=SC.objectForPropertyPath(c,b);if(b){if(SC.T_STRING===typeof c)c=b[c];if(!c)throw"could not find callback for load";SC.RunLoop.begin();c.apply(b,d);SC.RunLoop.end()}e=b=c=null};
tiki.async(a).then(function(){tiki.require("tiki").ready(this,e)})}});sc_require("system/locale");SC.IMAGE_ABORTED_ERROR=SC.$error("SC.Image.AbortedError","Image",-100);SC.IMAGE_FAILED_ERROR=SC.$error("SC.Image.FailedError","Image",-101);
SC.imageCache=SC.Object.create({loadLimit:4,activeRequests:0,loadImage:function(a,b,c,d){SC.typeOf(b);if(SC.none(c)&&SC.typeOf(b)===SC.T_FUNCTION)c=b=null;if(SC.typeOf(c)===SC.T_STRING)c=b[c];if(SC.none(d))d=SC.none(b)&&SC.none(c);a=this._imageEntryFor(a);if(a.status===this.IMAGE_LOADED){if(c)c.call(b||a.image,a.url,a.image)}else{if(b||c)this._addCallback(a,b,c);a.retainCount++;this._scheduleImageEntry(a,d)}},releaseImage:function(a,b,c){a=this._imageEntryFor(a,NO);if(!a)return this;if(--a.retainCount<=
0)this._deleteEntry(a);else if(b||c){SC.typeOf(b);if(SC.none(c)&&SC.typeOf(b)===SC.T_FUNCTION)c=b=null;if(SC.typeOf(c)===SC.T_STRING)c=b[c];this._removeCallback(a,b,c)}},reloadImage:function(a){if((a=this._imageEntryFor(a,NO))&&a.status===this.IMAGE_LOADED)a.status=this.IMAGE_WAITING},loadNextImage:function(){var a=null,b;if(!(this.get("activeRequests")>=this.get("loadLimit"))){for(b=this._foregroundQueue;b.length>0&&!a;)a=b.shift();if(!a)for(b=this._backgroundQueue;b.length>0&&!a;)a=b.shift();this.set("isLoading",
!!a);if(a){b=a.image;b.onabort=this._imageDidAbort;b.onerror=this._imageDidError;b.onload=this._imageDidLoad;b.src=a.url;this._loading.push(a);this.incrementProperty("activeRequests");this.loadNextImage()}}},_imageEntryFor:function(a,b){if(b===undefined)b=YES;var c=this._images[a];if(!c&&b){b=new Image;c=this._images[a]={url:a,status:this.IMAGE_WAITING,callbacks:[],retainCount:0,image:b};b.entry=c}return c},_deleteEntry:function(a){this._unscheduleImageEntry(a);delete this._images[a.url]},_addCallback:function(a,
b,c){a=a.callbacks;a.find(function(d){return d[0]===b&&d[1]===c},this)||a.push([b,c]);a=null;return this},_removeCallback:function(a,b,c){var d=a.callbacks;d.forEach(function(e,f){if(e[0]===b&&e[1]===c)d[f]=null},this);d=null;return this},_scheduleImageEntry:function(a,b){var c=this._backgroundQueue,d=this._foregroundQueue;if(a.status===this.IMAGE_LOADED)return this;if(a.status===this.IMAGE_QUEUED&&!b&&a.isBackground){c[c.indexOf(a)]=null;a.status=this.IMAGE_WAITING}if(a.status!==this.IMAGE_QUEUED){(b?
c:d).push(a);a.status=this.IMAGE_QUEUED;a.isBackground=b}this.isLoading||this.invokeLater(this.loadNextImage,100);this.set("isLoading",YES);return this},_unscheduleImageEntry:function(a){if(a.status!==this.IMAGE_QUEUED)return this;var b=a.isBackground?this._backgroundQueue:this._foregroundQueue;b[b.indexOf(a)]=null;if(this._loading.indexOf(a)>=0){b.image.abort();this.imageStatusDidChange(a,this.ABORTED)}return this},_imageDidAbort:function(){SC.imageCache.imageStatusDidChange(this.entry,SC.imageCache.ABORTED)},
_imageDidError:function(){SC.imageCache.imageStatusDidChange(this.entry,SC.imageCache.ERROR)},_imageDidLoad:function(){SC.imageCache.imageStatusDidChange(this.entry,SC.imageCache.LOADED)},imageStatusDidChange:function(a,b){if(a){var c=a.url,d;switch(b){case this.LOADED:d=a.image;break;case this.ABORTED:d=SC.IMAGE_ABORTED_ERROR;break;case this.ERROR:d=SC.IMAGE_FAILED_ERROR;break;default:d=SC.IMAGE_FAILED_ERROR;break}a.callbacks.forEach(function(f){f[1].call(f[0],c,d)},this);a.callbacks=[];a.status=
b===this.LOADED?this.IMAGE_LOADED:this.IMAGE_WAITING;var e=a.image;if(e){e.onload=e.onerror=e.onabort=null;if(b!==this.LOADED)a.image=null}this._loading[this._loading.indexOf(a)]=null;if(this._loading.length>this.loadLimit*2)this._loading=this._loading.compact();this.decrementProperty("activeRequests");this.loadNextImage()}},init:function(){arguments.callee.base.apply(this,arguments);this._images={};this._loading=[];this._foregroundQueue=[];this._backgroundQueue=[]},IMAGE_LOADED:"loaded",IMAGE_QUEUED:"queued",
IMAGE_WAITING:"waiting",ABORTED:"aborted",ERROR:"error",LOADED:"loaded"});SC.Math=SC.Object.create({near:function(a,b,c){c||(c=1.0E-5);return Math.abs(a-b)<=c},round:function(a,b){b||(b=0);var c=Math.pow(10,b);if(b<0){b=c.toString();c=b.substring(0,b.indexOf("1")+1)}a=a.valueOf();return Math.round(a*c)/c}});
SC.Page=SC.Object.extend({owner:null,get:function(a){var b=this[a];if(b&&b.isClass){this[a]=b=b.create({page:this});this.get("inDesignMode")||b.awake();return b}else return arguments.callee.base.apply(this,arguments)},awake:function(){var a,b;for(b in this)if(this.hasOwnProperty(b))if((a=this[b])&&a.isViewClass)this[b]=a.create({page:this});return this},getIfConfigured:function(a){var b=this[a];return b&&b.isViewClass?null:this.get(a)},loc:function(a){var b,c;for(c in a)if(a.hasOwnProperty(c))(b=
this[c])&&b.isViewClass&&b.loc(a[c]);return this}});SC.Page.design=SC.Page.create;SC.Page.localization=function(a){return a};sc_require("system/event");
SC.mixin({_isReadyBound:NO,_bindReady:function(){if(!this._isReadyBound){this._isReadyBound=YES;tiki.require("tiki").ready.main(SC,SC._didBecomeReady)}},_readyQueue:[],_afterReadyQueue:[],isReady:NO,_didBecomeReady:function(){if(!SC.isReady){typeof SC.mapDisplayNames===SC.T_FUNCTION&&SC.mapDisplayNames();typeof SC.addInvokeOnceLastDebuggingInfo===SC.T_FUNCTION&&SC.addInvokeOnceLastDebuggingInfo();SC.Locale.createCurrentLocale();if(document&&document.getElementsByTagName){var a=document.getElementsByTagName("body")[0];
if(a){var b=a.className,c=SC.Locale.currentLanguage.toLowerCase();a.className=b&&b.length>0?[b,c].join(" "):c}}SC.Benchmark.start("ready");SC.RunLoop.begin();var d;do{a=SC._readyQueue;SC._readyQueue=[];b=0;for(c=a.length;b<c;b++){d=a[b];var e=d[0]||document;(d=d[1])&&d.call(e)}}while(SC._readyQueue.length>0);SC.isReady=YES;SC._readyQueue=null;SC.Event.trigger("ready",null,document,NO);SC.removeLoading&&SC.$("#loading").remove();if(SC.userDefaults.get("ready"))SC.mode===SC.APP_MODE&&typeof main!="undefined"&&
main instanceof Function&&!SC.suppressMain&&main();else SC.userDefaults.readyCallback(window,main);SC.routes&&SC.routes.ping&&SC.routes.ping();SC.RunLoop.end();SC.Benchmark.end("ready");SC.Benchmark.log()}},ready:function(a,b){var c=this._readyQueue;if(b===undefined){b=a;a=null}else if(SC.typeOf(b)===SC.T_STRING)b=a[b];if(!b)return this;if(this.isReady)return b.call(a||document);c.push([a,b]);return this}});SC._bindReady();SC.removeLoading=YES;SC.APP_MODE="APP_MODE";SC.TEST_MODE="TEST_MODE";
SC.mode=SC.APP_MODE;sc_require("system/builder");SC.MODE_REPLACE="replace";SC.MODE_APPEND="append";SC.MODE_PREPEND="prepend";
SC.RenderContext=SC.Builder.create({SELF_CLOSING:SC.CoreSet.create().addEach("area base basefront br hr input img link meta".w()),init:function(a,b){if(a===undefined)a="div";if(b){this.prevObject=b;this.strings=b.strings;this.offset=b.length+b.offset}if(!this.strings)this.strings=[];this.needsContent=YES;if(SC.typeOf(a)===SC.T_STRING){this._tagName=a.toLowerCase();this._needsTag=YES;for(a=this;a;){a.length++;a=a.prevObject}this.strings.push(null);this._selfClosing=this.SELF_CLOSING.contains(this._tagName)}else{this._elem=
a;this._needsTag=NO;this.length=0;this.needsContent=NO}return this},strings:null,offset:0,length:0,updateMode:SC.MODE_REPLACE,needsContent:NO,get:function(a){var b=this.strings||[];return a===undefined?b.slice(this.offset,this.length):b[a+this.offset]},push:function(a){var b=this.strings,c=arguments.length;if(!b)this.strings=b=[];c>1?b.push.apply(b,arguments):b.push(a);for(b=this;b;){b.length+=c;b=b.prevObject}this.needsContent=YES;return this},text:function(){var a=arguments.length,b=0;for(b=0;b<
a;b++)this.push(SC.RenderContext.escapeHTML(arguments[b]));return this},join:function(a){this._needsTag&&this.end();var b=this.strings;return b?b.join(a||""):""},begin:function(a){return SC.RenderContext(a,this)},element:function(){if(this._elem)return this._elem;var a;if(!SC.RenderContext.factory)SC.RenderContext.factory=document.createElement("div");SC.RenderContext.factory.innerHTML=this.join();if(SC.RenderContext.factory.innerHTML.length>0){a=SC.RenderContext.factory.firstChild.cloneNode(true);
SC.RenderContext.factory.innerHTML=""}else a=null;return a},remove:function(a){if(a){var b=this._elem;if(b&&b.removeChild)(a=document.getElementById(a))&&b.removeChild(a)}},update:function(){var a=this._elem,b=this.updateMode,c,d,e,f;this._innerHTMLReplaced=NO;if(a){if(this.length>0){this._innerHTMLReplaced=YES;if(b===SC.MODE_REPLACE)a.innerHTML=this.join();else{b=a.cloneNode(false);b.innerHTML=this.join();for(b=b.firstChild;b;){f=b.nextSibling;a.insertBefore(b,f);b=f}}}if(this._attrsDidChange&&(d=
this._attrs))for(c in d)if(d.hasOwnProperty(c))d[c]===null?a.removeAttribute(c):SC.$(a).attr(c,d[c]);if(this._classNamesDidChange&&(d=this._classNames))SC.$(a).attr("class",d.join(" "));if(this._idDidChange&&(d=this._id))SC.$(a).attr("id",d);if(this._stylesDidChange&&(e=this._styles)){b=this._STYLE_PAIR_ARRAY;f=this._JOIN_ARRAY;for(c in e)if(e.hasOwnProperty(c)){d=e[c];if(d!==null){if(typeof d===SC.T_NUMBER)d=d.toString()+"px";b[0]=c.dasherize();b[1]=d;f.push(b.join(": "))}}SC.$(a).attr("style",f.join("; "));
f.length=0}this._elem=null;return this.prevObject||this}},_DEFAULT_ATTRS:{},_TAG_ARRAY:[],_JOIN_ARRAY:[],_STYLE_PAIR_ARRAY:[],end:function(){var a=this._TAG_ARRAY,b,c,d,e=this._attrs;b=this._classNames;c=this._id;var f=this._styles;a[0]="<";a[1]=this._tagName;if(e||b||f||c){if(!e)e=this._DEFAULT_ATTRS;if(c)e.id=c;if(b)e["class"]=b.join(" ");if(f){c=this._JOIN_ARRAY;b=this._STYLE_PAIR_ARRAY;for(d in f)if(f.hasOwnProperty(d)){b[0]=d.dasherize();b[1]=f[d];if(b[1]!==null){if(typeof b[1]===SC.T_NUMBER)b[1]+=
"px";c.push(b.join(": "))}}e.style=c.join("; ");c.length=0}a.push(" ");for(d in e)e.hasOwnProperty(d)&&e[d]!==null&&a.push(d,'="',e[d],'" ');if(e===this._DEFAULT_ATTRS){delete e.style;delete e["class"];delete e.id}}d=this.strings;e=this._selfClosing===NO?NO:this.length===1;a.push(e?" />":">");d[this.offset]=a.join("");a.length=0;if(!e){a[0]="</";a[1]=this._tagName;a[2]=">";d.push(a.join(""));for(d=this;d;){d.length++;d=d.prevObject}a.length=0}this._elem=null;return this.prevObject||this},tag:function(a,
b){return this.begin(a,b).end()},tagName:function(a){if(a===undefined){if(!this._tagName&&this._elem)this._tagName=this._elem.tagName;return this._tagName}else{this._tagName=a;this._tagNameDidChange=YES;return this}},id:function(a){if(a===undefined){if(!this._id&&this._elem)this._id=this._elem.id;return this._id}else{this._id=a;this._idDidChange=YES;return this}},classNames:function(a,b){if(a===undefined){if(!this._classNames&&this._elem)this._classNames=(SC.$(this._elem).attr("class")||"").split(" ");
if(this._cloneClassNames){this._classNames=(this._classNames||[]).slice();this._cloneClassNames=NO}if(!this._classNames)this._classNames=[];return this._classNames}else{this._classNames=a;this._cloneClassNames=b||NO;this._classNamesDidChange=YES;return this}},hasClass:function(a){return this.classNames().indexOf(a)>=0},addClass:function(a){if(a===undefined||a===null){SC.Logger.warn("You are adding an undefined or empty class"+this.toString());return this}var b=this.classNames();if(SC.typeOf(a)===
SC.T_STRING){if(b.indexOf(a)<0){b.push(a);this._classNamesDidChange=YES}}else for(var c=0,d=a.length;c<d;c++){var e=a[c];if(b.indexOf(e)<0){b.push(e);this._classNamesDidChange=YES}}return this},removeClass:function(a){var b=this._classNames,c;if(!b&&this._elem)b=this._classNames=(SC.$(this._elem).attr("class")||"").split(" ");if(b&&(c=b.indexOf(a))>=0){if(this._cloneClassNames){b=this._classNames=b.slice();this._cloneClassNames=NO}b[c]=null;this._classNamesDidChange=YES}return this},resetClassNames:function(){this._classNames=
[];this._classNamesDidChange=YES;return this},setClass:function(a,b){var c,d,e;if(b!==undefined)return b?this.addClass(a):this.removeClass(a);else{b=this._classNames;if(!b&&this._elem)b=this._classNames=(SC.$(this._elem).attr("class")||"").split(" ");if(!b)b=this._classNames=[];if(this._cloneClassNames){b=this._classNames=b.slice();this._cloneClassNames=NO}e=NO;for(d in a)if(a.hasOwnProperty(d)){c=b.indexOf(d);if(a[d]){if(c<0){b.push(d);e=YES}}else if(c>=0){b[c]=null;e=YES}}if(e)this._classNamesDidChange=
YES}return this},_STYLE_REGEX:/\s*([^:\s]+)\s*:\s*([^;]+)\s*;?/g,styles:function(a,b){var c,d;if(a===undefined){if(!this._styles&&this._elem)if((b=SC.$(this._elem).attr("style"))&&(b=b.toString()).length>0){if(SC.browser.msie)b=b.toLowerCase();a={};c=this._STYLE_REGEX;for(c.lastIndex=0;d=c.exec(b);)a[d[1].camelize()]=d[2];this._styles=a;this._cloneStyles=NO}else this._styles={};else if(this._styles){if(this._cloneStyles){this._styles=SC.beget(this._styles);this._cloneStyles=NO}}else this._styles=
{};return this._styles}else{this._styles=a;this._cloneStyles=b||NO;this._stylesDidChange=YES;return this}},addStyle:function(a,b){var c,d=NO,e=this.styles();if(typeof a===SC.T_STRING)if(b===undefined)return e[a];else{if(e[a]!==b){e[a]=b;this._stylesDidChange=YES}}else{for(c in a)if(a.hasOwnProperty(c)){b=a[c];if(e[c]!==b){e[c]=b;d=YES}}if(d)this._stylesDidChange=YES}return this},removeStyle:function(a){if(!this._styles&&!this._elem)return this;var b=this.styles();if(b[a]){b[a]=null;this._stylesDidChange=
YES}},attr:function(a,b){var c,d=this._attrs,e=NO;if(!d)this._attrs=d={};if(typeof a===SC.T_STRING)if(b===undefined)return d[a];else{if(d[a]!==b){d[a]=b;this._attrsDidChange=YES}}else{for(c in a)if(a.hasOwnProperty(c)){b=a[c];if(d[c]!==b){d[c]=b;e=YES}}if(e)this._attrsDidChange=YES}return this}});SC.RenderContext.fn.html=SC.RenderContext.fn.push;SC.RenderContext.fn.css=SC.RenderContext.fn.addStyle;if(!SC.browser.isSafari||parseInt(SC.browser.version,10)<526)SC.RenderContext._safari3=YES;
SC.RenderContext.escapeHTML=function(a){var b,c;if(SC.none(a))return a;b=this.escapeHTMLElement;if(!b)b=this.escapeHTMLElement=document.createElement("div");c=this.escapeTextNode;if(!c){c=this.escapeTextNode=document.createTextNode("");b.appendChild(c)}c.data=a;a=b.innerHTML;if(SC.RenderContext._safari3)a=a.replace(/>/g,"&gt;");return a};
SC.Response=SC.Object.extend({isError:NO,errorValue:function(){return this}.property().cacheable(),errorObject:null,request:null,originalRequest:function(){for(var a=this.get("request");a.get("source");)a=a.get("source");return a}.property("request").cacheable(),type:function(){return this.getPath("request.type")}.property("request").cacheable(),address:function(){return this.getPath("request.address")}.property("request").cacheable(),isJSON:function(){return this.getPath("request.isJSON")||NO}.property("request").cacheable(),
isXML:function(){return this.getPath("request.isXML")||NO}.property("request").cacheable(),listeners:function(){return this.getPath("request.listeners")}.property("request").cacheable(),status:-100,headers:null,encodedBody:null,body:function(){var a=this.get("encodedBody");if(a&&this.get("isJSON"))try{a=SC.json.decode(a)}catch(b){return SC.Error.create({message:b.name+": "+b.message,label:"Response",errorValue:this})}return a}.property("encodedBody").cacheable(),response:function(){return this.get("body")}.property("body").cacheable(),
isCancelled:NO,timedOut:null,timeoutTimer:null,fire:function(){var a=this.get("request"),b=a?a.get("source"):null;b&&b.willSend&&b.willSend(a,this);a.freeze();this.get("isCancelled")||this.invokeTransport();var c=a.get("timeout");c&&this.set("timeoutTimer",SC.Timer.schedule({target:this,action:"timeoutReached",interval:c,repeats:NO}));!this.get("isCancelled")&&b&&b.didSend&&b.didSend(a,this)},invokeTransport:function(){this.receive(function(){this.set("status",200)},this)},receive:function(a,b){if(!this.get("timedOut")){var c=
this.get("timeoutTimer");c&&c.invalidate();this.set("timedOut",NO);var d=(c=this.get("request"))?c.get("source"):null;d&&d.willReceive&&d.willReceive(c,this);a.call(b,!this.get("isCancelled"));!this.get("isCancelled")&&d&&d.didReceive&&d.didReceive(c,this);this.get("isCancelled")||this.notify()}SC.Request.manager.transportDidClose(this);return this},cancel:function(){if(!this.get("isCancelled")){this.set("isCancelled",YES);this.cancelTransport();SC.Request.manager.transportDidClose(this)}},timeoutReached:function(){if(this.get("timedOut")===
null){this.set("timedOut",YES);this.cancelTransport();SC.Request.manager.transportDidClose(this);var a=SC.$error("HTTP Request timed out","Request",408);a.set("errorValue",this);this.set("isError",YES);this.set("errorObject",a);var b=(a=this.get("request"))?a.get("source"):null;!this.get("isCancelled")&&b&&b.didTimeout&&b.didTimeout(a,this)}},cancelTransport:function(){},_notifyListener:function(a,b){var c=a[b];if(!c)return NO;a=(c.params||[]).copy();a.unshift(this);b=c.target;c=c.action;if(SC.typeOf(c)===
SC.T_STRING)c=b[c];return c.apply(b,a)},notify:function(){var a=this.get("listeners"),b=this.get("status"),c=Math.floor(b/100)*100,d=NO;if(!a)return this;SC.RunLoop.begin();(d=this._notifyListener(a,b))||(d=this._notifyListener(a,c));d||this._notifyListener(a,0);SC.RunLoop.end();return this},toString:function(){return"%@<%@ %@, status=%@".fmt(arguments.callee.base.apply(this,arguments),this.get("type"),this.get("address"),this.get("status"))}});
SC.XHRResponse=SC.Response.extend({headers:function(){var a=this.get("rawRequest");a=a?a.getAllResponseHeaders():null;var b={};if(!a)return b;a.split("\n").forEach(function(c){var d=c.indexOf(":"),e;if(d>=0){e=c.slice(0,d);c=c.slice(d+1).trim();b[e]=c}},this);return b}.property("status").cacheable(),header:function(a){var b=this.get("rawRequest");return b?b.getResponseHeader(a):null},encodedBody:function(){var a=this.get("rawRequest");return a?this.get("isXML")?a.responseXML:a.responseText:null}.property("status").cacheable(),
cancelTransport:function(){var a=this.get("rawRequest");a&&a.abort();this.set("rawRequest",null)},invokeTransport:function(){function a(){for(var g=0;g<arguments.length;g++)try{return arguments[g]()}catch(h){}return NO}var b,c,d,e;b=a(function(){return new XMLHttpRequest},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")});this.set("rawRequest",b);if(e=!!this.getPath("request.isAsynchronous"))if(SC.browser.msie){c=this;d=function(){if(!c)return null;
var g=c.finishRequest();if(g)c=null;return g};b.onreadystatechange=d}else SC.Event.add(b,"readystatechange",this,this.finishRequest,b);b.open(this.get("type"),this.get("address"),e);d=this.getPath("request.headers");for(var f in d)b.setRequestHeader(f,d[f]);b.send(this.getPath("request.encodedBody"));e||this.finishRequest();return b},finishRequest:function(){var a=this.get("rawRequest"),b,c,d;if(a.readyState===4){this.receive(function(e){if(e){c=-1;try{c=a.status||0}catch(f){}if(c<200||c>=300){try{d=
a.statusText||""}catch(g){d=""}b=SC.$error(d||"HTTP Request failed","Request",c);b.set("errorValue",this);this.set("isError",YES);this.set("errorObject",b)}this.set("status",c)}},this);a.onreadystatechange=function(){};return YES}return NO}});sc_require("system/response");
SC.Request=SC.Object.extend(SC.Copyable,SC.Freezable,{isAsynchronous:YES,isJSON:NO,isXML:NO,headers:function(){var a=this._headers;if(!a)a=this._headers={};return a}.property().cacheable(),responseClass:SC.XHRResponse,source:null,address:null,type:"GET",timeout:null,body:null,encodedBody:function(){var a=this.get("body");if(a&&this.get("isJSON"))a=SC.json.encode(a);return a}.property("isJSON","isXML","body").cacheable(),willSend:function(){},didSend:function(){},willReceive:function(){},didReceive:function(){},
didTimeout:function(){},COPY_KEYS:"isAsynchronous isJSON isXML address type timeout body responseClass willSend didSend willReceive didReceive".w(),copy:function(){for(var a={},b=this.COPY_KEYS,c=b.length,d;--c>=0;){d=b[c];if(this.hasOwnProperty(d))a[d]=this.get(d)}if(this.hasOwnProperty("listeners"))a.listeners=SC.copy(this.get("listeners"));if(this.hasOwnProperty("_headers"))a._headers=SC.copy(this._headers);a.source=this.get("source")||this;return this.constructor.create(a)},header:function(a,
b){var c;if(SC.typeOf(a)===SC.T_STRING){c=this._headers;if(arguments.length===1)return c?c[a]:null;else{this.propertyWillChange("headers");if(!c)c=this._headers={};c[a]=b;this.propertyDidChange("headers");return this}}else if(b===undefined){c=a;this.beginPropertyChanges();for(a in c)c.hasOwnProperty(a)&&this.header(a,c[a]);this.endPropertyChanges();return this}return this},async:function(a){if(a===undefined)a=YES;return this.set("isAsynchronous",a)},json:function(a){if(a===undefined)a=YES;a&&this.set("isXML",
NO);return this.set("isJSON",a)},xml:function(a){if(a===undefined)a=YES;a&&this.set("isJSON",NO);return this.set("isXML",a)},_prep:function(){var a=!!this.header("Content-Type");if(this.get("isJSON")&&!a)this.header("Content-Type","application/json");else this.get("isXML")&&!a&&this.header("Content-Type","text/xml");return this},send:function(a){var b=this.get("timeout");if(b){if(!this.get("isAsynchronous"))throw"Timeout values cannot be used with synchronous requests";}else if(b===0)throw"The timeout value must either not be specified or must be greater than 0";
a&&this.set("body",a);return SC.Request.manager.sendRequest(this.copy()._prep())},resend:function(){var a=this.get("source")?this:this.copy()._prep();return SC.Request.manager.sendRequest(a)},notify:function(a,b,c,d){if(SC.typeOf(a)!==SC.T_NUMBER){d=SC.A(arguments).slice(2);c=b;b=a;a=0}else d=SC.A(arguments).slice(3);var e=this.get("listeners");e||this.set("listeners",e={});e[a]={target:b,action:c,params:d};return this}});
SC.Request.mixin({getUrl:function(a){return this.create().set("address",a).set("type","GET")},postUrl:function(a,b){a=this.create().set("address",a).set("type","POST");b&&a.set("body",b);return a},deleteUrl:function(a){return this.create().set("address",a).set("type","DELETE")},putUrl:function(a,b){a=this.create().set("address",a).set("type","PUT");b&&a.set("body",b);return a}});
SC.Request.manager=SC.Object.create(SC.DelegateSupport,{maxRequests:6,inflight:[],pending:[],sendRequest:function(a){if(!a)return null;a=a.get("responseClass").create({request:a});this.get("pending").pushObject(a);this.fireRequestIfNeeded();return a},cancel:function(a){var b=this.get("pending"),c=this.get("inflight");if(b.indexOf(a)>=0){this.propertyWillChange("pending");b.removeObject(a);this.propertyDidChange("pending");return YES}else if(c.indexOf(a)>=0){a.cancel();c.removeObject(a);this.fireRequestIfNeeded();
return YES}else return NO},cancelAll:function(){if(this.get("pending").length||this.get("inflight").length){this.set("pending",[]);this.get("inflight").forEach(function(a){a.cancel()});this.set("inflight",[]);return YES}else return NO},fireRequestIfNeeded:function(){var a=this.get("pending"),b=this.get("inflight"),c=this.get("maxRequests");if(a.length>0&&b.length<c){a=a.shiftObject();b.pushObject(a);a.fire()}},transportDidClose:function(a){this.get("inflight").removeObject(a);this.fireRequestIfNeeded()}});
sc_require("system/ready");
SC.RootResponder=SC.Object.extend({panes:null,init:function(){arguments.callee.base.apply(this,arguments);this.panes=SC.Set.create()},mainPane:null,makeMainPane:function(a){var b=this.get("mainPane");if(b===a)return this;this.beginPropertyChanges();this.get("keyPane")===b&&this.makeKeyPane(a);this.set("mainPane",a);b&&b.blurMainTo(a);a&&a.focusMainFrom(b);this.endPropertyChanges();return this},keyPane:null,previousKeyPanes:[],makeKeyPane:function(a){var b,c;if(a)if(a.get("acceptsKeyPane")){b=this.get("keyPane");
if(b===a)return this;else{if(b){c=this.get("previousKeyPanes");c.push(b)}a=a}}else return this;else{b=this.get("keyPane");c=this.get("previousKeyPanes");for(a=null;c.length>0;){var d=c.pop();if(d.get("isPaneAttached")&&d.get("acceptsKeyPane")){a=d;break}}}if(!a)if((c=this.get("mainPane"))&&c.get("acceptsKeyPane"))a=c;b&&b.willLoseKeyPaneTo(a);a&&a.willBecomeKeyPaneFrom(b);this.set("keyPane",a);a&&a.didBecomeKeyPaneFrom(b);b&&b.didLoseKeyPaneTo(a);return this},computeWindowSize:function(){return{width:640,
height:480}},defaultResponder:null,sendAction:function(a,b,c,d,e){return(b=this.targetForAction(a,b,c,d))&&b.isResponderContext?!!b.sendAction(a,c,e):b&&b.tryToPerform(a,c)},_responderFor:function(a,b){var c=a?a.get("defaultResponder"):null;if(a){a=a.get("firstResponder")||a;do if(a.respondsTo(b))return a;while(a=a.get("nextResponder"))}if(typeof c===SC.T_STRING)c=SC.objectForPropertyPath(c);return c?c.isResponderContext?c:c.respondsTo(b)?c:null:null},targetForAction:function(a,b,c,d){if(!a||SC.typeOf(a)!==
SC.T_STRING)return null;if(b){if(SC.typeOf(b)===SC.T_STRING)b=SC.objectForPropertyPath(b);if(b)if(b.respondsTo&&!b.respondsTo(a))b=null;else if(SC.typeOf(b[a])!==SC.T_FUNCTION)b=null;return b}if(d)return this._responderFor(d,a);c=this.get("keyPane");var e=this.get("mainPane");if(c&&c!==d)b=this._responderFor(c,a);if(!b&&e&&e!==c)b=this._responderFor(e,a);if(!b&&(b=this.get("defaultResponder"))){if(SC.typeOf(b)===SC.T_STRING)(b=SC.objectForPropertyPath(b))&&this.set("defaultResponder",b);if(b)if(b.respondsTo&&
!b.respondsTo(a))b=null;else if(SC.typeOf(b[a])!==SC.T_FUNCTION)b=null}return b},targetViewForEvent:function(a){return a.target?SC.$(a.target).view()[0]:null},sendEvent:function(a,b,c){var d;SC.RunLoop.begin();a=(d=c?c.get("pane"):this.get("keyPane")||this.get("mainPane"))?d.sendEvent(a,b,c):null;SC.RunLoop.end();return a},sendTouchEvent:function(a,b,c){var d;SC.RunLoop.begin();a=(d=c?c.get("pane"):this.get("keyPane")||this.get("mainPane"))?d.sendTouchEvent(a,b,c):null;SC.RunLoop.end();return a},
listenFor:function(a,b){a.forEach(function(c){var d=this[c];d&&SC.Event.add(b,c,this,d)},this);b=null;return this},setup:function(){this.listenFor("touchstart touchmove touchend touchcancel".w(),document);if(SC.browser.touch){var a=document.createElement("div");a.id="sc-touch-intercept";a.style.position="absolute";a.style.top="0px";a.style.left="0px";a.style.bottom="0px";a.style.right="0px";a.style.zIndex=999;document.body.appendChild(a);this._touchInterceptElement=a}},touchstart:function(a){try{var b=
this.targetViewForEvent(a);this._touchViews=this.sendTouchEvent("touchStart",a,b)}catch(c){SC.Logger.warn("Exception during touchStart: %@".fmt(c));this._touchViews=null;return NO}return b?a.hasCustomEventHandling:YES},touchmove:function(a){SC.RunLoop.begin();try{for(var b=this._lastHovered||[],c=[],d=this.targetViewForEvent(a),e,f,g,h;d&&d!==this;){b.indexOf(d)!==-1?d.tryToPerform("touchMoved",a):d.tryToPerform("touchEntered",a);c.push(d);d=d.get("nextResponder")}f=0;for(g=b.length;f<g;f++){d=b[f];
(e=d.respondsTo("touchExited"))&&c.indexOf(d)===-1&&d.tryToPerform("touchExited",a)}this._lastHovered=c;h=this._touchViews;g=h.length;for(f=0;f<g;f++){d=h[f];if(d.respondsTo("touchDragged"))switch(d.touchDragged(a)){case YES:this.cancelTouch(h,d);h=null;this._touchViews=[d];break;case NO:h.removeObject(d);break}}}catch(j){SC.Logger.warn("Exception during touchMove: %@".fmt(j))}SC.RunLoop.end();return NO},touchend:function(a){try{a.cancel=NO;var b=null,c=this._touchViews,d,e,f;if(c){e=c.get("length");
for(d=0;d<e;d++){f=c[d];f.respondsTo("touchEnd")&&f.touchEnd(a)}}this._touchViews=null}catch(g){SC.Logger.warn("Exception during touchEnd: %@".fmt(g));this._touchViews=null;return NO}return b?a.hasCustomEventHandling:YES},touchcancel:function(a){a.cancel=YES;return this.touchend(a)},cancelTouch:function(a,b,c){var d,e,f;f=a.get("length");for(e=0;e<f;e++){d=a.objectAt(e);d!==b&&d.tryToPerform("touchCancelled",c)}}});
SC.ready(SC.RootResponder,SC.RootResponder.ready=function(){(SC.RootResponder.responder=SC.RootResponder.create()).setup()});
SC.routes=SC.Object.create({location:function(a,b){if(b!==undefined){if(b===null)b="";if(typeof b=="object"){var c=b.route?b.route.split("&"):[""],d=c.shift(),e={};c.forEach(function(f){f=f.split("=");e[f[0]]=f[1]});for(a in b)if(b.hasOwnProperty(a))if(a!="route")e[a]=encodeURIComponent(""+b[a]);c=[d];for(a in e)e.hasOwnProperty(a)&&c.push([a,e[a]].join("="));b=c.join("&")}if(this._location!=b){this._location=b;this._setWindowLocation(b)}}return this._location}.property(),ping:function(){if(!this._didSetupHistory){this._didSetupHistory=
true;this._setupHistory()}this._checkWindowLocation()},add:function(a,b,c){if(c===undefined&&SC.typeOf(b)===SC.T_FUNCTION){c=b;b=null}else if(SC.typeOf(c)===SC.T_STRING)c=b[c];a=a.split("/");if(!this._routes)this._routes=SC.routes._Route.create();this._routes.addRoute(a,b,c);return this},gotoRoute:function(a){var b={},c;this._lastRoute=a;if((c=a.split("&"))&&c.length>0){a=c.shift();c.forEach(function(d){if((d=d.split("="))&&d.length>1)b[d[0]]=decodeURIComponent(d[1])})}else a="";c=a.split("/");if(!this._routes)this._routes=
SC.routes._Route.create();if(c=this._routes.functionForRoute(c,b)){a=c._target;(c=c._method)&&c.call(a,b)}},init:function(){arguments.callee.base.call(this);if(SC.browser.isSafari&&parseInt(SC.browser.version,0)<417)SC.mixin(this,this.browserFuncs.safari);else if(SC.browser.isIE)SC.mixin(this,this.browserFuncs.ie);else SC.browser.isMozilla&&SC.mixin(this,this.browserFuncs.firefox);this._didSetupHistory=false},invokeCheckWindowLocation:function(a){var b=this.__checkWindowLocation,c=this;if(!b)b=this.__checkWindowLocation=
function(){c._checkWindowLocation()};setTimeout(b,a)},browserFuncs:{safari:{_setupHistory:function(){var a=location.hash;this._cloc=a=a&&a.length>0?a.slice(1,a.length):"";this._backStack=[];this._backStack.length=history.length;this._backStack.push(a);this._forwardStack=[];this.invokeCheckWindowLocation(1E3)},_checkWindowLocation:function(){var a=history.length-this._lastLength!==0,b=a?history.length-this._backStack.length:0;this._lastLength=history.length;a&&SC.Logger.log("historyDidChange");if(b)if(b<
0){this._forwardStack.push(this._cloc);for(a=0;a<Math.abs(b+1);a++)this._forwardStack.push(this._backStack.pop());this._cloc=this._backStack.pop()}else{this._backStack.push(this._cloc);for(a=0;a<b-1;a++)this._backStack.push(this._forwardStack.pop());this._cloc=this._forwardStack.pop()}else if(a&&this._locationDidChange){this.gotoRoute(this._cloc);this._locationDidChange=false}b=this._cloc;a=this.get("location");if(b!=a){this.set("location",b?b:"");this.gotoRoute(b)}this.invokeCheckWindowLocation(50)},
_setWindowLocation:function(a){if(this._cloc!=a){this._backStack.push(this._cloc);this._forwardStack.length=0;this._cloc=a;location.hash=a&&a.length>0?a:"";this._locationDidChange=true}}},ie:{_setupHistory:function(){this.invokeCheckWindowLocation(1E3)},_checkWindowLocation:function(){var a=this.get("location"),b=location.hash;b=b&&b.length>0?b.slice(1,b.length):"";if(b!=a)this.set("location",b?b:"");this.invokeCheckWindowLocation(100)},_setWindowLocation:function(a){var b=location.hash;b=b&&b.length>
0?b.slice(1,b.length):"";if(b!=a)location.hash=a&&a.length>0?a:"#";this.gotoRoute(a)}},firefox:{_checkWindowLocation:function(){var a=this.get("location"),b=location.hash;b=b&&b.length>0?b.slice(1,b.length):"";if(b!=a){SC.RunLoop.begin();this.set("location",b?b:"");SC.RunLoop.end()}this.invokeCheckWindowLocation(150)},_setWindowLocation:function(a){var b=location.hash;b=b&&b.length>0?b.slice(1,b.length):"";if(b!=a)location.hash=a&&a.length>0?a:"#";this.gotoRoute(a)}}},_setupHistory:function(){this.invokeCheckWindowLocation(1E3)},
_checkWindowLocation:function(){var a=this.get("location"),b=decodeURI(location.hash);b=b&&b.length>0?b.slice(1,b.length):"";if(b!==a){SC.RunLoop.begin();this.set("location",b?b:"");SC.RunLoop.end()}this.invokeCheckWindowLocation(150)},_setWindowLocation:function(a){var b=location.hash;b=b&&b.length>0?b.slice(1,b.length):"";if(b!=a)location.hash=a&&a.length>0?encodeURI(a):"#";this.gotoRoute(a)},_routes:null,_Route:SC.Object.extend({_target:null,_method:null,_static:null,_dynamic:null,_wildcard:null,
addRoute:function(a,b,c){if(!a||a.length===0){this._target=b;this._method=c}else{var d=a.shift(),e=null;switch(d.slice(0,1)){case ":":d=d.slice(1,d.length);var f=this._dynamic[d]||[];e=SC.routes._Route.create();f.push(e);this._dynamic[d]=f;break;case "*":this._wildcard=d=d.slice(1,d.length);this._target=b;this._method=c;break;default:f=this._static[d]||[];e=SC.routes._Route.create();f.push(e);this._static[d]=f}e&&e.addRoute(a,b,c)}},functionForRoute:function(a,b){if(!a||a.length===0)return this;else{var c=
a.shift(),d=null,e,f,g;if(e=this._static[c]){f=0;for(g=e.length;f<g&&d===null;f++){d=a.slice();d=e[f].functionForRoute(d,b)}}if(d===null)for(var h in this._dynamic){if(e=this._dynamic[h]){f=0;for(g=e.length;f<g&&d===null;f++){d=a.slice();if((d=e[f].functionForRoute(d,b))&&b)b[h]=c}}if(d)break}if(d===null&&this._wildcard){a.unshift(c);if(b)b[this._wildcard]=a.join("/");d=this}return d}},init:function(){arguments.callee.base.call(this);this._static={};this._dynamic={}}})});
SC.time=function(){var a=SC.beget(fn);a.value=timeOffset;return a};(function(){var a=new Date;SC.mixin(SC.time,{month:function(b,c){a.setTime(b);if(c===undefined)return a.getMonth();a.setMonth(c);return a.getTime()},utc:function(b){a.setTime(b);return b+a.getTimezoneOffset()*60*1E3},local:function(b){a.setTime(b);return b-a.getTimezoneOffset()*60*1E3},parse:function(){},format:function(){}})})();SC.time.fmt=SC.time.format;SC.time.fn={done:function(){return this.value}};
"month day year".split(" ").forEach(function(a){SC.time.fn[a]=function(b){if(b===undefined)return SC.time[a](this.value);else{this.value=SC.time[a](this.value,b);return this}}});
var MONTH_NAMES=new Array("January","February","March","April","May","June","July","August","September","October","November","December","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"),DAY_NAMES=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sun","Mon","Tue","Wed","Thu","Fri","Sat");function LZ(a){return(a<0||a>9?"":"0")+a}
SC.Locale.define("en",{longMonthNames:"January February March April May".split(" "),shortMonthNames:[],shortDateFormat:"dd/mm/yy",longDateFormat:""});
SC.mixin(Date,{now:function(){return(new Date).getTime()},isDate:function(a,b){if(Date.getDateFromFormat(a,b)==0)return false;return true},compareDates:function(a,b,c,d){a=Date.getDateFromFormat(a,b);c=Date.getDateFromFormat(c,d);if(a==0||c==0)return-1;else if(a>c)return 1;return 0},getDateFromFormat:function(a,b){a+="";b+="";var c=0,d=0,e="",f="",g,h,j=new Date,k=j.getFullYear(),l=j.getMonth()+1,m=1,n=j.getHours(),o=j.getMinutes();j=j.getSeconds();for(var r="";d<b.length;){e=b.charAt(d);for(f="";b.charAt(d)==
e&&d<b.length;)f+=b.charAt(d++);if(f=="yyyy"||f=="yy"||f=="y"){if(f=="yyyy")h=g=4;if(f=="yy")h=g=2;if(f=="y"){g=2;h=4}k=Date._getInt(a,c,g,h);if(k==null)return 0;c+=k.length;if(k.length==2)k=k>70?1900+(k-0):2E3+(k-0)}else if(f=="MMM"||f=="NNN"){for(e=l=0;e<MONTH_NAMES.length;e++){var u=MONTH_NAMES[e];if(a.substring(c,c+u.length).toLowerCase()==u.toLowerCase())if(f=="MMM"||f=="NNN"&&e>11){l=e+1;if(l>12)l-=12;c+=u.length;break}}if(l<1||l>12)return 0}else if(f=="EE"||f=="E")for(e=0;e<DAY_NAMES.length;e++){f=
DAY_NAMES[e];if(a.substring(c,c+f.length).toLowerCase()==f.toLowerCase()){c+=f.length;break}}else if(f=="MM"||f=="M"){l=Date._getInt(a,c,f.length,2);if(l==null||l<1||l>12)return 0;c+=l.length}else if(f=="dd"||f=="d"){m=Date._getInt(a,c,f.length,2);if(m==null||m<1||m>31)return 0;c+=m.length}else if(f=="hh"||f=="h"){n=Date._getInt(a,c,f.length,2);if(n==null||n<1||n>12)return 0;c+=n.length}else if(f=="HH"||f=="H"){n=Date._getInt(a,c,f.length,2);if(n==null||n<0||n>23)return 0;c+=n.length}else if(f=="KK"||
f=="K"){n=Date._getInt(a,c,f.length,2);if(n==null||n<0||n>11)return 0;c+=n.length}else if(f=="kk"||f=="k"){n=Date._getInt(a,c,f.length,2);if(n==null||n<1||n>24)return 0;c+=n.length;n--}else if(f=="mm"||f=="m"){o=Date._getInt(a,c,f.length,2);if(o==null||o<0||o>59)return 0;c+=o.length}else if(f=="ss"||f=="s"){j=Date._getInt(a,c,f.length,2);if(j==null||j<0||j>59)return 0;c+=j.length}else if(f=="a"){if(a.substring(c,c+2).toLowerCase()=="am")r="AM";else if(a.substring(c,c+2).toLowerCase()=="pm")r="PM";
else return 0;c+=2}else if(a.substring(c,c+f.length)!=f)return 0;else c+=f.length}if(c!=a.length)return 0;if(l==2)if(k%4==0&&k%100!=0||k%400==0){if(m>29)return 0}else if(m>28)return 0;if(l==4||l==6||l==9||l==11)if(m>30)return 0;if(n<12&&r=="PM")n=n-0+12;else if(n>11&&r=="AM")n-=12;return(new Date(k,l-1,m,n,o,j)).getTime()},parseDate:function(a){var b=arguments.length==2?arguments[1]:false;generalFormats=new Array("E NNN dd HH:mm:ss UTC yyyy","y-M-d","y-M-d","MMM d, y","MMM d,y","y-MMM-d","d-MMM-y",
"MMM d","d MMM y","d.MMM.y","y MMM d","y.MMM.d");monthFirst=new Array("M/d/y","M-d-y","M.d.y","MMM-d","M/d","M-d");dateFirst=new Array("d/M/y","d-M-y","d.M.y","d-MMM","d/M","d-M");b=new Array("generalFormats",b?"dateFirst":"monthFirst",b?"monthFirst":"dateFirst");var c=null;c=0;var d=(new Date).getTime();switch(a.toLowerCase()){case "yesterday".loc():c=d-864E5;break;case "today".loc():case "now".loc():c=d;break;case "tomorrow".loc():c=d+864E5;break}if(c>0)return new Date(c);for(d=0;d<b.length;d++)for(var e=
window[b[d]],f=0;f<e.length;f++){c=Date.getDateFromFormat(a,e[f]);if(c==0)c=Date.getDateFromFormat(a,e[f]+" H:m:s");if(c==0)c=Date.getDateFromFormat(a,e[f]+" h:m:s a");if(c!=0)return new Date(c)}return null},_isInteger:function(a){for(var b=0;b<a.length;b++)if("1234567890".indexOf(a.charAt(b))==-1)return false;return true},_getInt:function(a,b,c,d){for(d=d;d>=c;d--){var e=a.substring(b,b+d);if(e.length<c)return null;if(Date._isInteger(e))return e}return null}});
SC.mixin(Date.prototype,{format:function(a){a+="";var b=this,c="",d=0,e="",f="";e=b.getFullYear()+"";f=b.getMonth()+1;var g=b.getDate(),h=b.getDay(),j=b.getHours(),k=b.getMinutes(),l=b.getSeconds();b={};if(e.length<4)e=""+(e-0+1900);b.y=""+e;b.yyyy=e;b.yy=e.substring(2,4);b.M=f;b.MM=LZ(f);b.MMM=MONTH_NAMES[f-1];b.NNN=MONTH_NAMES[f+11];b.d=g;b.dd=LZ(g);b.E=DAY_NAMES[h+7];b.EE=DAY_NAMES[h];b.H=j;b.HH=LZ(j);b.h=j==0?12:j>12?j-12:j;b.hh=LZ(b.h);b.K=j>11?j-12:j;b.k=j+1;b.KK=LZ(b.K);b.kk=LZ(b.k);b.a=j>
11?"PM":"AM";b.m=k;b.mm=LZ(k);b.s=l;for(b.ss=LZ(l);d<a.length;){e=a.charAt(d);for(f="";a.charAt(d)==e&&d<a.length;)f+=a.charAt(d++);c+=b[f]!=null?b[f]:f}return c},utcFormat:function(){return(new Date(this.getTime()+this.getTimezoneOffset()*60*1E3)).format("E NNN dd HH:mm:ss UTC yyyy")}});
SC.Timer=SC.Object.extend({target:null,action:null,isPooled:NO,interval:0,startTime:null,repeats:NO,until:null,isPaused:NO,isScheduled:NO,isValid:YES,lastFireTime:0,fireTime:function(){if(!this.get("isValid"))return-1;var a=this.get("startTime");if(!a||a===0)return-1;var b=this.get("interval"),c=this.get("lastFireTime");if(c<a)c=a;a=this.get("repeats")?b===0?c:a+(Math.floor((c-a)/b)+1)*b:a+b;if((b=this.get("until"))&&b>0&&a>b)a=b;return a}.property("interval","startTime","repeats","until","isValid",
"lastFireTime").cacheable(),schedule:function(){if(!this.get("isValid"))return this;this.beginPropertyChanges();this.startTime||this.set("startTime",SC.RunLoop.currentRunLoop.get("startTime"));var a=this.get("fireTime"),b=this.get("lastFireTime");if(a>=b){this.set("isScheduled",YES);SC.RunLoop.currentRunLoop.scheduleTimer(this,a)}this.endPropertyChanges();return this},invalidate:function(){this.beginPropertyChanges();this.set("isValid",NO);SC.RunLoop.currentRunLoop.cancelTimer(this);this.action=this.target=
null;this.endPropertyChanges();this.get("isPooled")&&SC.Timer.returnTimerToPool(this);return this},fire:function(){var a=Date.now();this.set("lastFireTime",a);var b=this.get("fireTime");this.get("isPaused")||this.performAction();b>a?this.schedule():this.invalidate()},performAction:function(){var a=SC.typeOf(this.action);if(a==SC.T_FUNCTION)this.action.call(this.target||this,this);else if(a===SC.T_STRING)if(this.action.indexOf(".")>=0){var b=this.action.split(".");a=b.pop();b=SC.objectForPropertyPath(b,
window);if((a=b.get?b.get(a):b[a])&&SC.typeOf(a)==SC.T_FUNCTION)a.call(b,this);else throw"%@: Timer could not find a function at %@".fmt(this,this.action);}else SC.RootResponder.responder.sendAction(this.action,this.target,this)},init:function(){arguments.callee.base.apply(this,arguments);if(this.startTime instanceof Date)this.startTime=this.startTime.getTime();if(this.until instanceof Date)this.until=this.until.getTime()},RESET_DEFAULTS:{target:null,action:null,isPooled:NO,isPaused:NO,isScheduled:NO,
isValid:YES,interval:0,repeats:NO,until:null,startTime:null,lastFireTime:0},reset:function(a){if(!a)a=SC.EMPTY_HASH;this.propertyWillChange("fireTime");var b=this.RESET_DEFAULTS;for(var c in b)if(b.hasOwnProperty(c))this[c]=SC.none(a[c])?b[c]:a[c];this.propertyDidChange("fireTime");return this},removeFromTimerQueue:function(a){var b=this._timerQueuePrevious,c=this._timerQueueNext;if(!b&&!c&&a!==this)return a;if(b)b._timerQueueNext=c;if(c)c._timerQueuePrevious=b;this._timerQueuePrevious=this._timerQueueNext=
null;return a===this?c:a},scheduleInTimerQueue:function(a,b){this._timerQueueRunTime=b;for(var c=a,d=null;c&&c._timerQueueRunTime<b;){d=c;c=c._timerQueueNext}if(d){d._timerQueueNext=this;this._timerQueuePrevious=d}if(c){c._timerQueuePrevious=this;this._timerQueueNext=c}return c===a?this:a},collectExpiredTimers:function(a,b){if(this._timerQueueRunTime>b)return this;a.push(this);var c=this._timerQueueNext;this._timerQueueNext=null;if(c)c._timerQueuePrevious=null;return c?c.collectExpiredTimers(a,b):
null}});SC.Timer.schedule=function(a){return(!a||SC.none(a.isPooled)||a.isPooled?this.timerFromPool(a):this.create(a)).schedule()};SC.Timer.timerFromPool=function(a){var b=this._timerPool;if(!b)b=this._timerPool=[];(b=b.pop())||(b=this.create());return b.reset(a)};SC.Timer.returnTimerToPool=function(a){if(!this._timerPool)this._timerPool=[];this._timerPool.push(a);return this};
SC.UserDefaults=SC.Object.extend({ready:NO,userDomain:null,appDomain:null,_defaults:null,_safari3DB:null,defaults:function(a){this._defaults=a;this.allPropertiesDidChange()},readDefault:function(a){var b=undefined,c,d,e;a=this._normalizeKeyName(a);c=this._userKeyName(a);if(this._written)b=this._written[c];if(SC.browser.msie=="7.0"){d=document.body;try{d.load("SC.UserDefaults")}catch(f){SC.Logger.err("Couldn't load userDefaults in IE7: "+f.description)}}else if(this.HTML5DB_noLocalStorage)e=this._safari3DB;
else{d=window.localStorage;if(!d&&window.globalStorage)d=window.globalStorage[window.location.hostname]}if(d||e){b=["SC.UserDefaults",c].join("-at-");b=SC.browser.msie=="7.0"?d.getAttribute(b.replace(/\W/gi,"")):e?this.dataHash[b]:d[b];if(SC.none(b))b=undefined;else try{b=SC.json.decode(b)}catch(g){b=undefined}}if((d=this.delegate)&&d.userDefaultsNeedsDefault)b=d.userDefaultsNeedsDefault(this,a,c);if(b===undefined&&this._defaults)b=this._defaults[c]||this._defaults[a];return b},writeDefault:function(a,
b){var c,d,e,f,g;a=this._normalizeKeyName(a);c=this._userKeyName(a);d=this._written;if(!d)d=this._written={};d[c]=b;if(SC.browser.msie=="7.0")e=document.body;else if(this.HTML5DB_noLocalStorage)g=this._safari3DB;else{e=window.localStorage;if(!e&&window.globalStorage)e=window.globalStorage[window.location.hostname]}f=["SC.UserDefaults",c].join("-at-");if(e||g){var h=SC.json.encode(b);if(SC.browser.msie=="7.0"){e.setAttribute(f.replace(/\W/gi,""),h);e.save("SC.UserDefaults")}else if(g){var j=this;g.transaction(function(l){l.executeSql("delete from SCLocalStorage where key = ?",
[f],function(){l.executeSql("insert into SCLocalStorage(key, value) VALUES ('"+f+"', '"+h+"');",[],j._nullDataHandler,j.killTransaction)})});this.dataHash[f]=h}else try{e[f]=h}catch(k){SC.Logger.error("Failed using localStorage. "+k)}}(d=this.delegate)&&d.userDefaultsDidChange&&d.userDefaultsDidChange(this,a,b,c);return this},resetDefault:function(a){var b,c,d,e,f,g;b=this._normalizeKeyName(a);c=this._userKeyName(b);this.propertyWillChange(a);this.propertyWillChange(b);(d=this._written)&&delete d[c];
if(SC.browser.msie=="7.0")e=document.body;else if(this.HTML5DB_noLocalStorage)g=this._safari3DB;else{e=window.localStorage;if(!e&&window.globalStorage)e=window.globalStorage[window.location.hostname]}f=["SC.UserDefaults",c].join("-at-");if(e)if(SC.browser.msie=="7.0"){e.setAttribute(f.replace(/\W/gi,""),null);e.save("SC.UserDefaults")}else if(g){g.transaction(function(h){h.executeSql("delete from SCLocalStorage where key = ?",[f],null)});delete this.dataHash[f]}else delete e[f];this.propertyDidChange(a);
this.propertyDidChange(b);return this},unknownProperty:function(a,b){if(b===undefined)return this.readDefault(a);else{this.writeDefault(a,b);return b}},_normalizeKeyName:function(a){if(a.indexOf(":")<0)a=[this.get("appDomain")||"app",a].join(":");return a},_userKeyName:function(a){return[this.get("userDomain")||"(anonymous)",a].join("-at-")},_domainDidChange:function(){var a=NO;if(this.get("userDomain")!==this._scud_userDomain){this._scud_userDomain=this.get("userDomain");a=YES}if(this.get("appDomain")!==
this._scud_appDomain){this._scud_appDomain=this.get("appDomain");a=YES}a&&this.allPropertiesDidChange()}.observes("userDomain","appDomain"),init:function(){arguments.callee.base.apply(this,arguments);if(SC.userDefaults&&SC.userDefaults.get("dataHash"))if(SC.userDefaults.get("dataHash"))this.dataHash=SC.userDefaults.get("dataHash");this._scud_userDomain=this.get("userDomain");this._scud_appDomain=this.get("appDomain");SC.browser.msie=="7.0"&&document.body.addBehavior("#default#userData");if(this.HTML5DB_noLocalStorage=
parseInt(SC.browser.safari,0)>523&&parseInt(SC.browser.safari,0)<528){var a;try{if(window.openDatabase)a=openDatabase("scdb","1.0","SproutCore database",65536);else{SC.Logger.error("Trying to load a database with safari version 3.1 to get SC.UserDefaults to work. You are either in a previous version or there is a problem with your browser.");return}}catch(b){SC.Logger.error("Trying to load a database with safari version 3.1 to get SC.UserDefaults to work. You are either in a previous version or there is a problem with your browser.");
return}if(a){var c=this;a.transaction(function(d){d.executeSql("CREATE TABLE IF NOT EXISTS SCLocalStorage(key TEXT NOT NULL PRIMARY KEY, value TEXT NOT NULL);",[],c._nullDataHandler,c.killTransaction)});a.transaction(function(d){d.parent=c;d.executeSql("SELECT * from SCLocalStorage;",[],function(e,f){for(var g={},h,j=0,k=f.rows.length;j<k;j++){h=f.rows.item(j);g[h.key]=h.value}e.parent.dataHash=g;SC.userDefaults.set("ready",YES)},c.killTransaction)});this._safari3DB=a}}else this.set("ready",YES)},
_killTransaction:function(){return true},_nullDataHandler:function(){},readyCallback:function(a,b){this.func=b;this.ob=a},readyChanged:function(){if(this.ready===YES){var a=this.func;a&&a.apply(this.ob)}}.observes("ready")});SC.userDefaults=SC.UserDefaults.create();sc_require("system/browser");
SC.mixin({_downloadFrames:0,_copy_computed_props:["maxWidth","maxHeight","paddingLeft","paddingRight","paddingTop","paddingBottom","fontFamily","fontSize","fontStyle","fontWeight","fontVariant","lineHeight","whiteSpace"],download:function(a){var b=document.createElement("iframe"),c="DownloadFrame_"+this._downloadFrames;SC.$(b).attr("id",c);b.style.border="10px";b.style.width="0px";b.style.height="0px";b.style.position="absolute";b.style.top="-10000px";b.style.left="-10000px";SC.browser.isSafari||
SC.$(b).attr("src",a);document.getElementsByTagName("body")[0].appendChild(b);SC.browser.isSafari&&SC.$(b).attr("src",a);this._downloadFrames+=1;SC.browser.isSafari||function(){document.body.removeChild(document.getElementById(c));c=null}.invokeLater(null,2E3);b=null},normalizeURL:function(a){if(a.slice(0,1)=="/")a=window.location.protocol+"//"+window.location.host+a;else a.slice(0,5)=="http:"||a.slice(0,6)=="https:"||(a=window.location.href+"/"+a);return a},isPercentage:function(a){return a<1&&a>
0},minX:function(a){return a.x||0},maxX:function(a){return(a.x||0)+(a.width||0)},midX:function(a){return(a.x||0)+(a.width||0)/2},minY:function(a){return a.y||0},maxY:function(a){return(a.y||0)+(a.height||0)},midY:function(a){return(a.y||0)+(a.height||0)/2},centerX:function(a,b){return(b.width-a.width)/2},centerY:function(a,b){return(b.height-a.height)/2},pointInRect:function(a,b){return a.x>=SC.minX(b)&&a.y>=SC.minY(b)&&a.x<=SC.maxX(b)&&a.y<=SC.maxY(b)},rectsEqual:function(a,b,c){if(!a||!b)return a==
b;if(!c&&c!==0)c=0.1;if(a.y!=b.y&&Math.abs(a.y-b.y)>c)return NO;if(a.x!=b.x&&Math.abs(a.x-b.x)>c)return NO;if(a.width!=b.width&&Math.abs(a.width-b.width)>c)return NO;if(a.height!=b.height&&Math.abs(a.height-b.height)>c)return NO;return YES},intersectRects:function(a,b){a={x:Math.max(SC.minX(a),SC.minX(b)),y:Math.max(SC.minY(a),SC.minY(b)),width:Math.min(SC.maxX(a),SC.maxX(b)),height:Math.min(SC.maxY(a),SC.maxY(b))};a.width=Math.max(0,a.width-a.x);a.height=Math.max(0,a.height-a.y);return a},unionRects:function(a,
b){a={x:Math.min(SC.minX(a),SC.minX(b)),y:Math.min(SC.minY(a),SC.minY(b)),width:Math.max(SC.maxX(a),SC.maxX(b)),height:Math.max(SC.maxY(a),SC.maxY(b))};a.width=Math.max(0,a.width-a.x);a.height=Math.max(0,a.height-a.y);return a},cloneRect:function(a){return{x:a.x,y:a.y,width:a.width,height:a.height}},stringFromRect:function(a){return"{x:"+a.x+", y:"+a.y+", width:"+a.width+", height:"+a.height+"}"},stringFromLayout:function(a){for(var b=["maxHeight","maxWidth","minHeight","minWidth","centerY","centerX",
"width","height","bottom","right","top","left"],c=[],d=b.length;--d>=0;){var e=b[d];a.hasOwnProperty(e)&&c.push(e+":"+a[e])}return"{"+c.join(", ")+"}"},heightForString:function(a,b,c,d){var e=this._heightCalcElement;d=d&&SC.typeOf(d)===SC.T_ARRAY?d.join(" "):"";b||(b=100);if(!e){e=this._heightCalcElement=document.createElement("div");document.body.insertBefore(e,null)}c=c+"; width: "+b+"px; left: "+-1*b+"px; position: absolute";SC.$(e).attr("style",c);d!==""&&SC.$(e).attr("class",d);e.innerHTML=a;
return e.clientHeight},prepareStringMeasurement:function(a,b){var c=this._metricsCalculationElement;b=SC.A(b).join(" ");if(!c){c=this._metricsCalculationElement=document.createElement("div");document.body.insertBefore(c,null)}if(SC.typeOf(a)!=SC.T_STRING){var d=null;d=document.defaultView&&document.defaultView.getComputedStyle?document.defaultView.getComputedStyle(a,null):a.currentStyle;a=d.cssText;if(!a||a.trim()===""){a=this._copy_computed_props;for(var e=0;e<a.length;e++){var f=a[e];c.style[f]=
d[f]}d=c.style;if(d.font===""){a="";if(d.fontStyle)a+=d.fontStyle+" ";if(d.fontVariant)a+=d.fontVariant+" ";if(d.fontWeight)a+=d.fontWeight+" ";a+=d.fontSize?d.fontSize:"10px";if(d.lineHeight)a+="/"+d.lineHeight;a+=" ";if(d.fontFamily)a+=d.fontFamily;c.style.font=a}SC.mixin(c.style,{left:"0px",top:"0px",position:"absolute",bottom:"auto",right:"auto",width:"auto",height:"auto"})}else c.setAttribute("style",a+"; position:absolute; left: 0px; top: 0px; bottom: auto; right: auto; width: auto; height: auto;")}else{a=
a;c.setAttribute("style",a+"; position:absolute; left: 0px; top: 0px; bottom: auto; right: auto; width: auto; height: auto;")}c.className=b},teardownStringMeasurement:function(){var a=this._metricsCalculationElement;a.innerHTML="";a.className="";a.setAttribute("style","")},measureString:function(a){var b=this._metricsCalculationElement;if(!b)throw"measureString requires a string measurement environment to be set up. Did you mean metricsForString?";if(typeof b.innerText!="undefined")b.innerText=a;
else b.textContent=a;return{width:b.clientWidth,height:b.clientHeight}},metricsForString:function(a,b,c){SC.prepareStringMeasurement(b,c);a=SC.measureString(a);SC.teardownStringMeasurement();return a},viewportOffset:function(a){if(a.getBoundingClientRect){a=a.getBoundingClientRect();return{x:a.left,y:a.top}}for(var b=0,c=0,d=a,e=SC.browser.mozilla>=3;d;){c+=d.offsetTop||0;if(!e||d!==a)c+=d.clientTop||0;b+=d.offsetLeft||0;if(!e||d!==a)b+=d.clientLeft||0;if(SC.browser.mozilla){if(SC.$(d).attr("overflow")!==
"visible"){var f=parseInt(SC.$(d).attr("borderLeftWidth"),0)||0,g=parseInt(SC.$(d).attr("borderTopWidth"),0)||0;if(a!==d){f*=2;g*=2}b+=f;c+=g}f=d.offsetParent;if(SC.browser.mozilla.match(/1[.]9/)&&f){c-=f.clientTop;b-=f.clientLeft}}if(d.offsetParent==document.body&&SC.$(d).attr("position")=="absolute")break;d=d.offsetParent}for(d=a;d;){if(!SC.browser.isOpera||d.tagName=="BODY"){c-=d.scrollTop||0;b-=d.scrollLeft||0}d=d.parentNode}return{x:b,y:c}},ZERO_POINT:{x:0,y:0},ZERO_RANGE:{start:0,length:0},
RANGE_NOT_FOUND:{start:0,length:-1},valueInRange:function(a,b){return a>=0&&a>=b.start&&a<b.start+b.length},minRange:function(a){return a.start},maxRange:function(a){return a.length<0?-1:a.start+a.length},unionRanges:function(a,b){if(a==null||a.length<0)return b;if(b==null||b.length<0)return a;var c=Math.min(a.start,b.start);a=Math.max(SC.maxRange(a),SC.maxRange(b));return{start:c,length:a-c}},intersectRanges:function(a,b){if(a==null||b==null)return SC.RANGE_NOT_FOUND;if(a.length<0||b.length<0)return SC.RANGE_NOT_FOUND;
var c=Math.max(SC.minRange(a),SC.minRange(b));a=Math.min(SC.maxRange(a),SC.maxRange(b));if(a<c)return SC.RANGE_NOT_FOUND;return{start:c,length:a-c}},subtractRanges:function(a,b){if(a==null||b==null)return SC.RANGE_NOT_FOUND;if(a.length<0||b.length<0)return SC.RANGE_NOT_FOUND;var c=Math.max(SC.minRange(a),SC.minRange(b));a=Math.min(SC.maxRange(a),SC.maxRange(b));if(c<a)return SC.RANGE_NOT_FOUND;return{start:a,length:c-a}},cloneRange:function(a){return{start:a.start,length:a.length}},rangesEqual:function(a,
b){if(a===b)return true;if(a==null)return b.length<0;if(b==null)return a.length<0;return a.start==b.start&&a.length==b.length},convertHsvToHex:function(a,b,c){var d=0,e=0,f=0;if(c>0){f=a==1?0:Math.floor(a*6);a=a==1?0:a*6-f;d=c*(1-b);e=c*(1-b*a);b=c*(1-b*(1-a));c=[[c,b,d],[e,c,d],[d,c,b],[d,e,c],[b,d,c],[c,d,e]];d=Math.round(255*c[f][0]);e=Math.round(255*c[f][1]);f=Math.round(255*c[f][2])}return this.parseColor("rgb("+d+","+e+","+f+")")},convertHexToHsv:function(a){var b=this.expandColor(a);a=Math.max(Math.max(b[0],
b[1]),b[2]);var c=Math.min(Math.min(b[0],b[1]),b[2]);b=a==c?0:a==b[0]?(b[1]-b[2])/(a-c)/6:a==b[1]?(b[2]-b[0])/(a-c)/6+1/3:(b[0]-b[1])/(a-c)/6+2/3;b=b<0?b+1:b>1?b-1:b;return[b,a==0?0:1-c/a,a/255]},PARSE_COLOR_RGBRE:/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i,PARSE_COLOR_HEXRE:/^\#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,expandColor:function(a){var b,c;if(b=this.parseColor(a)){a=parseInt(b.slice(1,3),16);c=parseInt(b.slice(3,5),16);b=parseInt(b.slice(5,7),16);return[a,c,b]}},parseColor:function(a){var b=
0,c="#",d;if(d=this.PARSE_COLOR_RGBRE.exec(a)){for(b=1;b<=3;b++){a=Math.max(0,Math.min(255,parseInt(d[b],0)));c+=this.toColorPart(a)}return c}if(d=this.PARSE_COLOR_HEXRE.exec(a)){if(d[1].length==3){for(b=0;b<3;b++)c+=d[1].charAt(b)+d[1].charAt(b);return c}return"#"+d[1]}return false},toColorPart:function(a){if(a>255)a=255;var b=a.toString(16);if(a<16)return"0"+b;return b},getStyle:function(a,b){var c="";if(document.defaultView&&document.defaultView.getComputedStyle)c=document.defaultView.getComputedStyle(a,
"").getPropertyValue(b);else if(a.currentStyle){b=b.replace(/\-(\w)/g,function(d,e){return e.toUpperCase()});c=a.currentStyle[b]}return c}});SC.VALIDATE_OK=YES;SC.VALIDATE_NO_CHANGE=NO;
SC.Validator=SC.Object.extend({fieldValueForObject:function(a){return a},objectForFieldValue:function(a){return a},validate:function(){return true},validateError:function(a,b){return SC.$error("Invalid.General(%@)".loc(b.get("fieldValue")),b.get("fieldKey"))},validateChange:function(a,b){return this.validate(a,b)?SC.VALIDATE_OK:this.validateError(a,b)},validateSubmit:function(a,b){return this.validate(a,b)?SC.VALIDATE_OK:this.validateError(a,b)},validatePartial:function(a,b){return b.get("isValid")?
SC.VALIDATE_NO_CHANGE:this.validate(a,b)?SC.VALIDATE_OK:this.validateError(a,b)},validateKeyDown:function(){return true},attachTo:function(){},detachFrom:function(){}});
SC.Validator.mixin({OK:true,NO_CHANGE:false,findFor:function(a,b,c){var d;if(c){if(c instanceof SC.Validator)d=c;else if(c.isClass)d=c.create();else if(SC.typeOf(c)===SC.T_STRING){var e=null;if(d=c.match(/^(.+)\[(.*)\]/)){c=d[1];e=d[2]}c=c.classify();var f=SC.Validator[c];if(SC.none(f))throw"validator %@ not found for %@".fmt(c,b);else if(e){if(!a)throw"named validator (%@) could not be found for field %@ because the field does not belong to a form".fmt(e,b);if(!a._validatorHash)a._validatorHash=
{};(d=e?a._validatorHash[e]:null)||(d=f.create());if(e)a._validatorHash[e]=d}else d=f.create()}return d}},fieldValueForObject:function(a,b,c){return this.prototype&&this.prototype.fieldValueForObject?this.prototype.fieldValueForObject(a,b,c):null},objectForFieldValue:function(a,b,c){return this.prototype&&this.prototype.objectForFieldValue?this.prototype.objectForFieldValue(a,b,c):null}});sc_require("validators/validator");
SC.Validator.CreditCard=SC.Validator.extend({fieldValueForObject:function(a){if(typeof a=="string"&&a.length==16)a=[a.slice(0,4),a.slice(4,8),a.slice(8,12),a.slice(12,16)].join(" ");return a},objectForFieldValue:function(a){return a.replace(/[\s-\.\:]/g,"")},validate:function(a,b){return this.checkNumber(b.get("fieldValue"))},validateError:function(a,b){a=b.get("errorLabel")||"Field";return SC.$error("Invalid.CreditCard(%@)".loc(a),a)},validateKeyDown:function(a,b,c){return!!c.match(/[0-9\- ]/)},
checkNumber:function(a){if(!a||a.length===0)return YES;a=a.replace(/[^0-9]/g,"");var b=a.length,c=parseInt(a,0),d=a.toString();d=d.replace(/^\s+|\s+$/g,"");a=0;for(var e=true,f=false,g,h=0;h<b;h++){g=""+d.substring(h,h+1);if("0123456789".indexOf(g)=="-1")e=false}e||(f=false);if(b===0&&f)f=false;else if(b>=15){for(d=b;d>0;d--){b=parseInt(c,0)%10;b=parseInt(b,0);a+=b;d--;c/=10;b=parseInt(c,0)%10;b*=2;switch(b){case 10:b=1;break;case 12:b=3;break;case 14:b=5;break;case 16:b=7;break;case 18:b=9;break;
default:b=b}c/=10;a+=b}f=a%10===0?true:false}return f}});sc_require("validators/validator");SC.Validator.Date=SC.Validator.extend({format:"NNN d, yyyy h:mm:ss a",fieldValueForObject:function(a){var b;if(typeof a==="number")b=new Date(a);else if(a instanceof Date)b=a;if(b)a=b.format(this.get("format"));return a},objectForFieldValue:function(a){if(a)a=(a=Date.parseDate(a))?a.getTime():null;return a}});sc_require("validators/validator");
SC.Validator.Email=SC.Validator.extend({validate:function(a,b){return(b.get("fieldValue")||"").match(/.+@.+\...+/)},validateError:function(a,b){a=b.get("errorLabel")||"Field";return SC.$error("Invalid.Email(%@)".loc(a),a)}});SC.Validator.EmailOrEmpty=SC.Validator.Email.extend({validate:function(a,b){return(a=b.get("fieldValue"))&&a.length>0?a.match(/.+@.+\...+/):true}});sc_require("validators/validator");
SC.Validator.NotEmpty=SC.Validator.extend({validate:function(a,b){a=b.get("fieldValue");if((b=!!a)&&a.length)b=a.length>0;return b},validateError:function(a,b){a=b.get("errorLabel")||"Field";return SC.$error("Invalid.NotEmpty(%@)".loc(a.capitalize()),b.get("errorLabel"))}});sc_require("validators/validator");
SC.Validator.Number=SC.Validator.extend({places:0,fieldValueForObject:function(a){switch(SC.typeOf(a)){case SC.T_NUMBER:a=a.toFixed(this.get("places"));break;case SC.T_NULL:case SC.T_UNDEFINED:a="";break}return a},objectForFieldValue:function(a){a=a.replace(/,/g,"");switch(SC.typeOf(a)){case SC.T_STRING:a=a.length===0?null:this.get("places")>0?parseFloat(a):a.length==1&&a.match(/-/)?null:parseInt(a,0);break;case SC.T_NULL:case SC.T_UNDEFINED:a=null;break}return a},validate:function(a,b){a=b.get("fieldValue");
return a===""||!(isNaN(a)||isNaN(parseFloat(a)))},validateError:function(a,b){a=b.get("errorLabel")||"Field";return SC.$error("Invalid.Number(%@)".loc(a),a)},validateKeyDown:function(a,b,c){(a=b.$input().val())||(a="");a+=c;return this.get("places")===0?c.length===0?true:a.match(/^[\-{0,1}]?[0-9,\0]*/)[0]===a:c.length===0?true:a.match(/^[\-{0,1}]?[0-9,\0]*\.?[0-9\0]+/)===a}});sc_require("validators/validator");
SC.Validator.Password=SC.Validator.extend({attachTo:function(a,b){arguments.callee.base.apply(this,arguments);if(!this.fields)this.fields=[];this.fields.push(b)},validate:function(a){if(!this.fields||this.fields.length===0)return true;var b=false,c=false,d=true,e=this.fields[0].get("fieldValue");this.fields.forEach(function(f){f=f.get("fieldValue");if(f!=e)d=false;if(!f||f.length===0)b=true;if(f&&f.length>0)c=true});return a?c===false?false:d:b===true?true:d},updateFields:function(a,b){if(!this.fields||
this.fields.length===0)return true;var c="Invalid.Password".loc(),d=this._field;this.fields.forEach(function(e){a.setErrorFor(e,b?null:e==d?c:"")});return b?SC.VALIDATE_OK:c},validateChange:function(a){return this.updateFields(a,this.validate(false))},validateSubmit:function(a){return this.updateFields(a,this.validate(true))},validatePartial:function(a){return!this._field.get("isValid")?this.updateFields(a,this.validate(false)):SC.VALIDATE_NO_CHANGE}});sc_require("validators/validator");
SC.Validator.PositiveInteger=SC.Validator.extend({defaultValue:null,fieldValueForObject:function(a){switch(SC.typeOf(a)){case SC.T_NUMBER:a=a.toFixed(0);break;case SC.T_NULL:case SC.T_UNDEFINED:a=this.get("defaultValue");break}return a},objectForFieldValue:function(a){a=a.replace(/,/g,"");switch(SC.typeOf(a)){case SC.T_STRING:a=a.length===0?this.get("defaultValue"):parseInt(a,0);break;case SC.T_NULL:case SC.T_UNDEFINED:a=this.get("defaultValue");break}return a},validate:function(a,b){a=b.get("fieldValue");
return a===""||!isNaN(a)},validateError:function(a,b){a=b.get("errorLabel")||"Field";return SC.$error("Invalid.Number(%@)".loc(a),a)},validateKeyDown:function(a,b,c){(a=b.$input().val())||(a="");a+=c;return c.length===0?true:a.match(/^[0-9\0]*/)[0]===a}});sc_require("views/view");
SC.ContainerView=SC.View.extend({classNames:["sc-container-view"],nowShowing:null,contentView:null,contentViewBindingDefault:SC.Binding.single(),replaceContent:function(a){this.removeAllChildren();a&&this.appendChild(a)},createChildViews:function(){var a=this.get("contentView");if(a){a=this.contentView=this.createChildView(a);this.childViews=[a]}},awake:function(){arguments.callee.base.apply(this,arguments);var a=this.get("nowShowing");a&&a.length>0&&this.nowShowingDidChange()},nowShowingDidChange:function(){var a=
this.get("nowShowing"),b=null;if(SC.typeOf(a)===SC.T_STRING){if(a===SC.CONTENT_SET_DIRECTLY)return;if(a&&a.length>0)b=a.indexOf(".")>0?SC.objectForPropertyPath(a,null):SC.objectForPropertyPath(a,this.get("page"))}else b=a;if(b&&!(b instanceof SC.View))b=null;this.set("contentView",b)}.observes("nowShowing"),contentViewDidChange:function(){this.replaceContent(this.get("contentView"))}.observes("contentView")});sc_require("views/view");sc_require("mixins/control");SC.IMAGE_STATE_NONE="none";
SC.IMAGE_STATE_LOADING="loading";SC.IMAGE_STATE_LOADED="loaded";SC.IMAGE_STATE_FAILED="failed";SC.IMAGE_STATE_SPRITE="sprite";SC.BLANK_IMAGE_DATAURL="data:image/gif;base64,R0lGODlhAQABAJAAAP///wAAACH5BAUQAAAALAAAAAABAAEAAAICBAEAOw==";SC.BLANK_IMAGE_URL=SC.browser.msie&&SC.browser.msie<8?"/static/sproutcore/foundation/en/a04970954a917ede9918ca06897bc0e1406986d5/blank.gif":SC.BLANK_IMAGE_DATAURL;
SC.ImageView=SC.View.extend(SC.Control,{classNames:"sc-image-view",tagName:"img",status:SC.IMAGE_STATE_NONE,value:null,useImageCache:YES,canLoadInBackground:NO,localize:YES,displayProperties:"status toolTip".w(),render:function(a){var b=this.get("status"),c=this.get("value");b===SC.IMAGE_STATE_NONE&&c&&this._image_valueDidChange();b=this.get("status");var d=b===SC.IMAGE_STATE_LOADED?c:SC.BLANK_IMAGE_URL;b===SC.IMAGE_STATE_SPRITE&&a.addClass(c);a.attr("src",d);b=this.get("toolTip");if(SC.typeOf(b)===
SC.T_STRING){if(this.get("localize"))b=b.loc();a.attr("title",b);a.attr("alt",b)}},_image_valueDidChange:function(){var a=this.get("value"),b;if(a&&a.isEnumerable)a=a.firstObject();if((b=SC.ImageView.valueIsUrl(a))&&this.get("useImageCache")){b=this.get("isVisibleInWindow")||this.get("canLoadInBackground");this._loadingUrl=a;SC.imageCache.loadImage(a,this,this.imageDidLoad,b);this._loadingUrl&&this.set("status",SC.IMAGE_STATE_LOADING)}else{this._loadingUrl=null;this.set("status",b?SC.IMAGE_STATE_LOADED:
SC.IMAGE_STATE_SPRITE);this.displayDidChange()}}.observes("value"),imageDidLoad:function(a,b){if(a===this._loadingUrl)this._loadingUrl=null;if(this.get("value")===a){this.set("status",SC.$ok(b)?SC.IMAGE_STATE_LOADED:SC.IMAGE_STATE_FAILED);this.displayDidChange()}}});SC.ImageView.valueIsUrl=function(a){return a?a.indexOf("/")>=0:NO};sc_require("views/view");sc_require("mixins/control");SC.ALIGN_LEFT="left";SC.ALIGN_RIGHT="right";SC.ALIGN_CENTER="center";SC.REGULAR_WEIGHT="normal";SC.BOLD_WEIGHT="bold";
SC.LabelView=SC.View.extend(SC.Control,{classNames:["sc-label-view"],fontWeight:SC.REGULAR_WEIGHT,escapeHTML:true,escapeHTMLBindingDefault:SC.Binding.oneWay().bool(),localize:false,localizeBindingDefault:SC.Binding.oneWay().bool(),formatter:null,value:"",hint:null,exampleInlineTextFieldView:SC.InlineTextFieldView,icon:null,textAlign:SC.ALIGN_LEFT,isInlineEditorMultiline:NO,displayValue:function(){var a,b;a=this.get("value");if(b=this.getDelegateProperty("formatter",this.displayDelegate)){b=SC.typeOf(b)===
SC.T_FUNCTION?b(a,this):b.fieldValueForObject(a,this);SC.none(b)||(a=b)}if(SC.typeOf(a)===SC.T_ARRAY){b=[];for(var c=0,d=a.get("length");c<d;c++){var e=a.objectAt(c);if(!SC.none(e)&&e.toString)e=e.toString();b.push(e)}a=b.join(",")}if(!SC.none(a)&&a.toString)a=a.toString();if(a&&this.getDelegateProperty("localize",this.displayDelegate))a=a.loc();if(this.get("escapeHTML"))a=SC.RenderContext.escapeHTML(a);return a}.property("value","localize","formatter","escapeHTML").cacheable(),hintValue:function(){var a=
this.get("hint");if(this.get("escapeHTML"))a=SC.RenderContext.escapeHTML(a);return a}.property("hint","escapeHTML").cacheable(),isEditable:NO,isEditableBindingDefault:SC.Binding.bool(),isEditing:NO,validator:null,doubleClick:function(){return this.beginEditing()},beginEditing:function(){if(this.get("isEditing"))return YES;if(!this.get("isEditable"))return NO;var a=this.$(),b=this.get("value")||"",c=SC.viewportOffset(a[0]),d=this.convertFrameFromView(this.get("frame"),null);c.width=d.width;c.height=
d.height;SC.InlineTextFieldView.beginEditing({frame:c,delegate:this,exampleElement:a,value:b,multiline:this.get("isInlineEditorMultiline"),isCollection:NO,validator:this.get("validator"),exampleInlineTextFieldView:this.get("exampleInlineTextFieldView")})},discardEditing:function(){if(!this.get("isEditing"))return YES;return SC.InlineTextFieldView.discardEditing()},commitEditing:function(){if(!this.get("isEditing"))return YES;return SC.InlineTextFieldView.commitEditing()},inlineEditorShouldBeginEditing:function(){return YES},
inlineEditorWillBeginEditing:function(){this.set("isEditing",YES)},inlineEditorDidBeginEditing:function(){var a=this.$();this._oldOpacity=a.css("opacity");a.css("opacity",0)},inlineEditorShouldEndEditing:function(){return YES},inlineEditorDidEndEditing:function(a,b){this.setIfChanged("value",b);this.$().css("opacity",this._oldOpacity);this._oldOpacity=null;this.set("isEditing",NO)},displayProperties:"displayValue textAlign fontWeight icon".w(),_TEMPORARY_CLASS_HASH:{},render:function(a,b){var c=this.get("displayValue"),
d=this.get("icon"),e=this.get("hintValue"),f=false,g=false;if(d){var h=d.indexOf("/")>=0?d:SC.BLANK_IMAGE_URL;d='<img src="'+h+'" alt="" class="icon '+(h===d?"":d)+'" />';if(d!==this._iconCache){this._iconCache=d;f=true}}c=e&&(!c||c==="")?'<span class="sc-hint">'+e+"</span>":c;if(c!==this._textCache){this._textCache=c;g=true}if(b||g||f)a.push(d,c);b={"text-align":this.get("textAlign"),"font-weight":this.get("fontWeight")};if(this.get("isEditing"))b.opacity=0;a.addStyle(b);b=this._TEMPORARY_CLASS_HASH;
b.icon=!!this.get("icon");a.setClass(b)}});sc_require("panes/pane");SC.MainPane=SC.Pane.extend({layout:{left:0,right:0,top:0,bottom:0},paneDidAttach:function(){var a=arguments.callee.base.apply(this,arguments),b=this.rootResponder;b.makeMainPane(this);b.get("keyRootView")||b.makeKeyPane(this);return a},acceptsKeyPane:YES,classNames:["sc-main"]});tiki.script("sproutcore/foundation:en/a04970954a917ede9918ca06897bc0e1406986d5/javascript.js");
tiki.register("sproutcore/desktop",{packages:{"sproutcore/runtime":{scripts:[{url:"/static/sproutcore/runtime/en/4e45a795ad83e4f4a267451bf706cc3fc2658096/javascript.js",id:"sproutcore/runtime:en/4e45a795ad83e4f4a267451bf706cc3fc2658096/javascript.js"}]},"sproutcore/datastore":{scripts:[{url:"/static/sproutcore/datastore/en/eb43c56c9a551db9bba1cd04f29ca1dfb2e47e4c/javascript.js",id:"sproutcore/datastore:en/eb43c56c9a551db9bba1cd04f29ca1dfb2e47e4c/javascript.js"}]},"sproutcore/foundation":{stylesheets:[{url:"/static/sproutcore/foundation/en/a04970954a917ede9918ca06897bc0e1406986d5/stylesheet.css",
id:"sproutcore/foundation:en/a04970954a917ede9918ca06897bc0e1406986d5/stylesheet.css"}],scripts:[{url:"/static/sproutcore/foundation/en/a04970954a917ede9918ca06897bc0e1406986d5/javascript.js",id:"sproutcore/foundation:en/a04970954a917ede9918ca06897bc0e1406986d5/javascript.js"}]}},stylesheets:[{url:"/static/sproutcore/desktop/en/ecf7ecda0e8421fbcfcc4ebb8aafd0ff1cc97343/stylesheet.css",id:"sproutcore/desktop:en/ecf7ecda0e8421fbcfcc4ebb8aafd0ff1cc97343/stylesheet.css"}],depends:["sproutcore/runtime",
"sproutcore/datastore","sproutcore/foundation"],scripts:[{url:"/static/sproutcore/desktop/en/ecf7ecda0e8421fbcfcc4ebb8aafd0ff1cc97343/javascript.js",id:"sproutcore/desktop:en/ecf7ecda0e8421fbcfcc4ebb8aafd0ff1cc97343/javascript.js"}]});tiki.global("sproutcore/desktop");
SC.stringsFor("English",{"Invalid.CreditCard(%@)":"%@ is not a valid credit card number","Invalid.Email(%@)":"%@ is not a valid email address","Invalid.NotEmpty(%@)":"%@ must not be empty","Invalid.Password":"Your passwords do not match.  Please try typing them again.","Invalid.General(%@)":"%@ is invalid.  Please try again.","Invalid.Number(%@)":"%@ is not a number."});SC.allowsBackspaceToPreviousPage=NO;SC.BORDER_BEZEL="sc-bezel-border";SC.BORDER_BLACK="sc-black-border";SC.BORDER_GRAY="sc-gray-border";
SC.BORDER_TOP="sc-top-border";SC.BORDER_BOTTOM="sc-bottom-border";SC.BORDER_NONE=null;
SC.Border={borderTop:0,borderRight:0,borderBottom:0,borderLeft:0,borderStyle:SC.BORDER_GRAY,hasBorder:YES,displayProperties:["borderStyle"],_BORDER_REGEXP:/-border$/,initMixin:function(){this._sc_border_borderStyleDidChange()},renderMixin:function(a){var b=this.get("borderStyle");if(b)this._BORDER_REGEXP.exec(b)?a.addClass(b):a.addStyle("border","1px "+b+" solid")},_sc_border_borderStyleDidChange:function(){var a=this.get("borderStyle");if(a=SC.Border.dimensions[a])this.borderLeft=this.borderBottom=
this.borderRight=this.borderTop=a}};SC.mixin(SC.Border,{dimensions:{"sc-bezel-border":1,"sc-black-border":1,"sc-gray-border":1,"sc-top-border":1,"sc-bottom-border":1}});SC.CollectionGroup={classNames:["sc-collection-group"]};SC.CollectionRowDelegate={isCollectionRowDelegate:YES,rowHeight:18,customRowHeightIndexes:null,contentIndexRowHeight:function(){return this.get("rowHeight")}};
SC.CollectionViewDelegate={isCollectionViewDelegate:YES,collectionViewSelectionForProposedSelection:function(a,b){return b},collectionViewShouldSelectIndexes:function(a,b){return b},collectionViewShouldDeselectIndexes:function(a,b){return b},collectionViewShouldDeleteIndexes:function(a,b){return b},collectionViewDeleteContent:function(a,b,c){if(!b)return NO;if(SC.typeOf(b.destroyAt)===SC.T_FUNCTION){b.destroyAt(c);a.selectPreviousItem(NO,1);return YES}else if(SC.typeOf(b.removeAt)===SC.T_FUNCTION){b.removeAt(c);
a.selectPreviousItem(NO,1);return YES}else return NO},collectionViewShouldBeginDrag:function(){return YES},collectionViewDragDataTypes:function(){return[]},collectionViewDragDataForType:function(){return null},collectionViewComputeDragOperations:function(a,b,c){return c},collectionViewValidateDragOperation:function(a,b,c,d,e){return e&SC.DROP_ON?SC.DRAG_NONE:c},collectionViewPerformDragOperation:function(){return SC.DRAG_NONE},collectionViewDragViewFor:function(){return null},ghostActsLikeCursor:NO};
SC.Scrollable={isScrollable:true,verticalLineScroll:20,horizontalLineScroll:20,verticalPageScroll:function(){return this.get("innerFrame").height}.property("innerFrame"),horizontalPageScroll:function(){return this.get("innerFrame").width}.property("innerFrame"),hasVerticalScroller:function(){return this.get("scrollFrame").height>this.get("innerFrame").height}.property("scrollFrame"),hasHorizontalScroller:function(){return this.get("scrollFrame").width>this.get("innerFrame").width}.property("scrollFrame"),
scrollBy:function(a){var b=this.get("scrollFrame"),c=this.get("innerFrame");if(!this.get("hasVerticalScroller"))a.y=0;if(b.height<=c.height)a.y=0;if(!this.get("hasHorizontalScroller"))a.x=0;if(b.width<=c.width)a.x=0;a={x:b.x-(a.x||0),y:b.y-(a.y||0)};this.set("scrollFrame",a);a=this.get("scrollFrame");return{x:a.x-b.x,y:a.y-b.y}},scrollTo:function(a,b){this.set("scrollFrame",{x:0-a,y:0-b})},scrollToVisible:function(a){var b=this.get("innerFrame"),c=this.get("scrollFrame");a=this.convertFrameFromView(a.get("frame"),
a);a.x-=b.x+c.x;a.y-=b.y+c.y;b={x:0-c.x,y:0-c.y,width:b.width,height:b.height};b.y-=Math.max(0,SC.minY(b)-SC.minY(a));b.x-=Math.max(0,SC.minX(b)-SC.minX(a));b.y+=Math.max(0,SC.maxY(a)-SC.maxY(b));b.x+=Math.max(0,SC.maxX(a)-SC.maxX(b));this.scrollTo(b.x,b.y)},scrollDownLine:function(a){if(a===undefined)a=1;return this.scrollBy({y:this.get("verticalLineScroll")*a}).y},scrollUpLine:function(a){if(a===undefined)a=1;return 0-this.scrollBy({y:0-this.get("verticalLineScroll")*a}).y},scrollRightLine:function(a){if(a===
undefined)a=1;return this.scrollTo({y:this.get("horizontalLineScroll")*a}).x},scrollLeftLine:function(a){if(a===undefined)a=1;return 0-this.scrollTo({y:0-this.get("horizontalLineScroll")*a}).x},scrollDownPage:function(a){if(a===undefined)a=1;return this.scrollBy({y:this.get("verticalPageScroll")*a}).y},scrollUpPage:function(a){if(a===undefined)a=1;return 0-this.scrollBy({y:0-this.get("verticalPageScroll")*a}).y},scrollRightPage:function(a){if(a===undefined)a=1;return this.scrollTo({y:this.get("horizontalPageScroll")*
a}).x},scrollLeftPage:function(a){if(a===undefined)a=1;return 0-this.scrollTo({y:0-this.get("horizontalPageScroll")*a}).x}};
SC.ModalPane=SC.Pane.extend({classNames:"sc-modal",layout:{top:0,left:0,bottom:0,right:0},_openPaneCount:0,paneWillAppend:function(){this._openPaneCount++;this.get("isVisibleInWindow")||this.append();return this},paneDidRemove:function(){this._openPaneCount--;if(this._openPaneCount<=0){this._openPaneCount=0;this.get("isVisibleInWindow")&&this.remove()}},mouseDown:function(a){var b=this.get("owner");b&&b.modalPaneDidClick&&b.modalPaneDidClick(a)},touchStart:function(a){this.mouseDown(a)}});sc_require("panes/modal");
SC.PanelPane=SC.Pane.extend({layout:{left:0,right:0,top:0,bottom:0},classNames:["sc-panel"],acceptsKeyPane:YES,isModal:YES,modalPane:SC.ModalPane.extend({classNames:"for-sc-panel"}),contentView:null,contentViewBindingDefault:SC.Binding.single(),render:function(a,b){if(a.needsContent){this.renderChildViews(a,b);a.push("<div class='top-left-edge'></div>","<div class='top-edge'></div>","<div class='top-right-edge'></div>","<div class='right-edge'></div>","<div class='bottom-right-edge'></div>","<div class='bottom-edge'></div>",
"<div class='bottom-left-edge'></div>","<div class='left-edge'></div>")}},replaceContent:function(a){this.removeAllChildren();a&&this.appendChild(a)},createChildViews:function(){var a=this.contentView;if(a){a=this.contentView=this.createChildView(a);this.childViews=[a]}},contentViewDidChange:function(){this.replaceContent(this.get("contentView"))}.observes("contentView"),_modalPane:function(){var a=this.get("modalPane");if(a&&a.isClass){a=a.create({owner:this});this.set("modalPane",a)}return a},appendTo:function(){var a;
if(!this.get("isVisibleInWindow")&&this.get("isModal")&&(a=this._modalPane())){this._isShowingModal=YES;a.paneWillAppend(this)}return arguments.callee.base.apply(this,arguments)},remove:function(){var a,b=arguments.callee.base.apply(this,arguments);if(this._isShowingModal){this._isShowingModal=NO;if(a=this._modalPane())a.paneDidRemove(this)}return b},_isModalDidChange:function(){var a;if(this.get("isModal")){if(!this._isShowingModal&&this.get("isVisibleInWindow")&&(a=this._modalPane())){this._isShowingModal=
YES;a.paneWillAppend(this)}}else if(this._isShowingModal&&(a=this._modalPane())){this._isShowingModal=NO;a.paneDidRemove(this)}}.observes("isModal"),paneDidAttach:function(){var a=arguments.callee.base.apply(this,arguments);this.becomeKeyPane();return a}});SC.TOGGLE_BEHAVIOR="toggle";SC.PUSH_BEHAVIOR="push";SC.TOGGLE_ON_BEHAVIOR="on";SC.TOGGLE_OFF_BEHAVIOR="off";SC.HOLD_BEHAVIOR="hold";SC.REGULAR_BUTTON_HEIGHT=24;
SC.ButtonView=SC.View.extend(SC.Control,SC.Button,SC.StaticLayout,{tagName:"div",classNames:["sc-button-view"],theme:"square",buttonBehavior:SC.PUSH_BEHAVIOR,holdInterval:100,isDefault:NO,isDefaultBindingDefault:SC.Binding.oneWay().bool(),isCancel:NO,isCancelBindingDefault:SC.Binding.oneWay().bool(),href:"",action:null,target:null,supportFocusRing:NO,triggerAction:function(a){if(!this.get("isEnabled"))return NO;this.set("isActive",YES);this._action(a,YES);this.didTriggerAction();this.invokeLater("set",
200,"isActive",NO);return true},didTriggerAction:function(){},titleMinWidth:80,init:function(){arguments.callee.base.apply(this,arguments);if(this.get("keyEquivalent"))this._defaultKeyEquivalent=this.get("keyEquivalent")},_TEMPORARY_CLASS_HASH:{},displayProperties:["href","icon","title","value","toolTip"],renderStyle:"renderDefault",render:function(a,b){var c;if(this.get("tagName")==="a"){c=this.get("href");if(!c||c.length===0)c="javascript:;";a.attr("href",c)}else a.attr("role","button");c=this.get("toolTip");
if(SC.typeOf(c)===SC.T_STRING){if(this.get("localize"))c=c.loc();a.attr("title",c);a.attr("alt",c)}c=this._TEMPORARY_CLASS_HASH;c.def=this.get("isDefault");c.cancel=this.get("isCancel");c.icon=!!this.get("icon");a.attr("role","button").setClass(c);(c=this.get("theme"))&&a.addClass(c);this[this.get("renderStyle")](a,b)},renderDefault:function(a,b){if(b){a=a.push("<span class='sc-button-inner' style = 'min-width:",this.get("titleMinWidth"),"px'>");this.renderTitle(a,b);a.push("</span>");this.get("supportFocusRing")&&
a.push('<div class="focus-ring">','<div class="focus-left"></div>','<div class="focus-middle"></div>','<div class="focus-right"></div></div>')}else this.renderTitle(a,b)},renderImage:function(a){var b=this.get("icon");b?a.push("<div class='img "+b+"'></div>"):a.push("<div class='img'></div>")},_defaultKeyEquivalent:null,_isDefaultOrCancelDidChange:function(){var a=!!this.get("isDefault"),b=!a&&this.get("isCancel");if(this.didChangeFor("defaultCancelChanged","isDefault","isCancel")){this.displayDidChange();
if(a)this.set("keyEquivalent","return");else b?this.setIfChanged("keyEquivalent","escape"):this.set("keyEquivalent",this._defaultKeyEquivalent)}}.observes("isDefault","isCancel"),isMouseDown:false,mouseDown:function(a){var b=this.get("buttonBehavior");if(!this.get("isEnabled"))return YES;this.set("isActive",YES);this._isMouseDown=YES;if(b===SC.HOLD_BEHAVIOR)this._action(a);else if(!this._isFocused&&b!==SC.PUSH_BEHAVIOR){this._isFocused=YES;this.becomeFirstResponder();this.get("isVisibleInWindow")&&
this.$()[0].focus()}return YES},mouseExited:function(){this._isMouseDown&&this.set("isActive",NO);return YES},mouseEntered:function(){this.set("isActive",this._isMouseDown);return YES},mouseUp:function(a){this._isMouseDown&&this.set("isActive",NO);this._isMouseDown=false;this.get("buttonBehavior")!==SC.HOLD_BEHAVIOR&&this.$().within(a.target)&&this.get("isEnabled")&&this._action(a);return YES},keyDown:function(a){if(a.which===9){var b=a.shiftKey?this.get("previousValidKeyView"):this.get("nextValidKeyView");
b?b.becomeFirstResponder():a.allowDefault();return YES}if(a.which===13){this.triggerAction(a);return YES}return YES},_action:function(a,b){switch(this.get("buttonBehavior")){case SC.TOGGLE_BEHAVIOR:this.get("isSelected")?this.set("value",this.get("toggleOffValue")):this.set("value",this.get("toggleOnValue"));break;case SC.TOGGLE_ON_BEHAVIOR:this.set("value",this.get("toggleOnValue"));break;case SC.TOGGLE_OFF_BEHAVIOR:this.set("value",this.get("toggleOffValue"));break;case SC.HOLD_BEHAVIOR:this._runHoldAction(a,
b);break;default:this._runAction(a)}},_runAction:function(a){var b=this.get("action"),c=this.get("target")||null;if(b)this._hasLegacyActionHandler()?this._triggerLegacyActionHandler(a):this.getPath("pane.rootResponder").sendAction(b,c,this,this.get("pane"))},_runHoldAction:function(a,b){if(this.get("isActive")){this._runAction();if(!b){SC.RunLoop.begin();this.invokeLater("_runHoldAction",this.get("holdInterval"),a);SC.RunLoop.end()}}},_hasLegacyActionHandler:function(){var a=this.get("action");if(a&&
SC.typeOf(a)===SC.T_FUNCTION)return true;if(a&&SC.typeOf(a)===SC.T_STRING&&a.indexOf(".")!=-1)return true;return false},_triggerLegacyActionHandler:function(a){if(!this._hasLegacyActionHandler())return false;var b=this.get("action");SC.typeOf(b)===SC.T_FUNCTION&&this.action(a);if(SC.typeOf(b)===SC.T_STRING){eval("this.action = function(e) { return "+b+"(this, e); };");this.action(a)}},acceptsFirstResponder:function(){return SC.SAFARI_FOCUS_BEHAVIOR?NO:this.get("isEnabled")}.property("isEnabled"),
willBecomeKeyResponderFrom:function(){if(!this._isFocused){this._isFocused=YES;this.becomeFirstResponder();if(this.get("isVisibleInWindow")){var a=this.$()[0];a&&a.focus()}}},willLoseKeyResponderTo:function(){if(this._isFocused)this._isFocused=NO},didAppendToDocument:function(){if(SC.browser.msie===7){var a=this.$();if(a&&a[0]){var b=a[0].clientWidth;a=parseInt(a.css("paddingRight"),0);this.$(".sc-button-label").css("minWidth",b-a*2+"px")}}}});sc_require("panes/panel");sc_require("views/button");
SC.BUTTON1_STATUS="button1";SC.BUTTON2_STATUS="button2";SC.BUTTON3_STATUS="button3";
SC.AlertPane=SC.PanelPane.extend({classNames:"sc-alert",delegate:null,icon:"sc-icon-alert-48",message:"",description:"",displayDescription:function(){var a=this.get("description");if(!a||a.length===0)return a;a=SC.RenderContext.escapeHTML(a);return'<p class="description">'+a.split("\n").join('</p><p class="description">')+"</p>"}.property("description").cacheable(),caption:"",displayCaption:function(){var a=this.get("caption");if(!a||a.length===0)return a;a=SC.RenderContext.escapeHTML(a);return'<p class="caption">'+
a.split("\n").join('</p><p class="caption">')+"</p>"}.property("caption").cacheable(),buttonOne:SC.outlet("contentView.childViews.1.childViews.1"),buttonTwo:SC.outlet("contentView.childViews.1.childViews.0"),buttonThree:SC.outlet("contentView.childViews.2.childViews.0"),buttonThreeWrapper:SC.outlet("contentView.childViews.2"),layout:{centerX:0,width:500,top:55},contentView:SC.View.extend({useStaticLayout:YES,layout:{left:0,right:0,top:0,height:"auto"},childViews:[SC.View.extend(SC.StaticLayout,{classNames:["info"],
render:function(a){var b=this.get("pane"),c=SC.BLANK_IMAGE_URL;b.get("icon")=="blank"&&a.addClass("plain");a.push('<img src="'+c+'" class="icon '+b.get("icon")+'" />');a.begin("h1").text(b.get("message")||"").end();a.push(b.get("displayDescription")||"");a.push(b.get("displayCaption")||"");a.push('<div class="separator"></div>')}}),SC.View.extend({layout:{bottom:13,height:24,right:18,width:466},childViews:["cancelButton","okButton"],classNames:["text-align-right"],cancelButton:SC.ButtonView.extend({useStaticLayout:YES,
actionKey:SC.BUTTON2_STATUS,localize:YES,titleMinWidth:64,layout:{right:5,height:"auto",width:"auto",bottom:0},theme:"capsule",title:"Cancel",action:"dismiss",isVisible:NO}),okButton:SC.ButtonView.extend({useStaticLayout:YES,actionKey:SC.BUTTON1_STATUS,localize:YES,titleMinWidth:64,layout:{left:0,height:"auto",width:"auto",bottom:0},theme:"capsule",title:"OK",isDefault:YES,action:"dismiss"})}),SC.View.extend({layout:{bottom:13,height:24,left:18,width:150},isVisible:NO,childViews:[SC.ButtonView.extend({useStaticLayout:YES,
actionKey:SC.BUTTON3_STATUS,localize:YES,titleMinWidth:64,layout:{left:0,height:"auto",width:"auto",bottom:0},theme:"capsule",title:"Extra",action:"dismiss",isVisible:NO})]})]}),dismiss:function(a){var b=this.delegate;b&&b.alertPaneDidDismiss&&b.alertPaneDidDismiss(this,a.get("actionKey"));this.remove()},alertInfoDidChange:function(){var a=this.getPath("contentView.childViews.0");a&&a.displayDidChange()}.observes("icon","message","displayDescription","displayCaption")});
SC.AlertPane._normalizeArguments=function(a){a=SC.A(a);var b=a.length,c=a[b-1];if(SC.typeOf(c)!==SC.T_STRING)a[b-1]=null;else c=null;a[7]=c;return a};
SC.AlertPane.show=function(){for(var a=this._normalizeArguments(arguments),b=this.create({message:a[0]||"",description:a[1]||null,caption:a[2]||null,icon:a[6]||"sc-icon-alert-48",delegate:a[7]}),c="buttonOne buttonTwo buttonThree".w(),d,e,f=0;f<3;f++){d=b.get(c[f]);if(e=a[f+3]){d.set("title",e).set("isVisible",YES);e=="?"&&d.set("titleMinWidth",0);f==2&&b.get("buttonThreeWrapper").set("isVisible",YES)}}a=b.append();b.adjust("height",b.childViews[0].$().height());b.updateLayout();return a};
SC.AlertPane.warn=function(){var a=this._normalizeArguments(arguments);a[6]="sc-icon-alert-48";return this.show.apply(this,a)};SC.AlertPane.info=function(){var a=this._normalizeArguments(arguments);a[6]="sc-icon-info-48";return this.show.apply(this,a)};SC.AlertPane.error=function(){var a=this._normalizeArguments(arguments);a[6]="sc-icon-error-48";return this.show.apply(this,a)};SC.AlertPane.plain=function(){var a=this._normalizeArguments(arguments);a[6]="blank";return this.show.apply(this,a)};sc_require("panes/panel");
SC.PalettePane=SC.PanelPane.extend({classNames:"sc-palette",isModal:NO,modalPane:SC.ModalPane,isAnchored:NO,_mouseOffsetX:null,_mouseOffsetY:null,mouseDown:function(a){var b=this.get("frame");this._mouseOffsetX=b?b.x-a.pageX:0;this._mouseOffsetY=b?b.y-a.pageY:0;return YES},mouseDragged:function(a){if(!this.isAnchored){this.set("layout",{width:this.layout.width,height:this.layout.height,left:this._mouseOffsetX+a.pageX,top:this._mouseOffsetY+a.pageY});this.updateLayout()}return YES}});sc_require("panes/palette");
SC.PICKER_MENU="menu";SC.PICKER_FIXED="fixed";SC.PICKER_POINTER="pointer";SC.POINTER_LAYOUT=["perfectRight","perfectLeft","perfectTop","perfectBottom"];
SC.PickerPane=SC.PalettePane.extend({classNames:"sc-picker",isAnchored:YES,isModal:YES,pointerPos:"perfectRight",pointerPosX:0,pointerPosY:0,anchorElement:null,preferType:null,preferMatrix:null,popup:function(a,b,c){a=a.isView?a.get("layer"):a;this.beginPropertyChanges();this.set("anchorElement",a);b&&this.set("preferType",b);c&&this.set("preferMatrix",c);this.endPropertyChanges();this.positionPane();this.append()},positionPane:function(){var a=this.get("anchorElement"),b=this.get("preferType"),c=
this.get("preferMatrix"),d=this.get("layout");if(a){a=this.computeAnchorRect(a);d=SC.cloneRect(a);if(b)switch(b){case SC.PICKER_MENU:case SC.PICKER_FIXED:if(!c||c.length!==3)this.set("preferMatrix",[1,4,3]);d.x+=(this.preferMatrix[2]===0?d.width:0)+this.preferMatrix[0];d.y+=(this.preferMatrix[2]===3?d.height:0)+this.preferMatrix[1];break;default:d.y+=d.height;break}else d.y+=d.height;d=this.fitPositionToScreen(d,this.get("frame"),a);d={width:d.width,height:d.height,left:d.x,top:d.y}}else d={width:d.width,
height:d.height,centerX:0,centerY:0};this.set("layout",d).updateLayout();return this},computeAnchorRect:function(a){var b=SC.viewportOffset(a);a=SC.$(a);var c=SC.RootResponder.responder.computeWindowSize();b.width=a.outerWidth();b.height=c.height-b.y<a.outerHeight()?c.height-b.y:a.outerHeight();return b},fitPositionToScreen:function(a,b,c){var d=SC.RootResponder.responder.computeWindowSize();d={x:0,y:0,width:d.width,height:d.height};b.x=a.x;b.y=a.y;if(this.preferType)switch(this.preferType){case SC.PICKER_MENU:b=
this.fitPositionToScreenMenu(d,b,this.get("isSubMenu"));break;case SC.PICKER_POINTER:b=this.fitPositionToScreenPointer(d,b,c);break;case SC.PICKER_FIXED:break;default:break}else b=this.fitPositionToScreenDefault(d,b,c);this.displayDidChange();return b},fitPositionToScreenDefault:function(a,b,c){if(SC.maxX(b)>a.width){var d=Math.max(SC.maxX(c),b.width);b.x=Math.min(d,a.width)-b.width}if(SC.minX(b)<0){b.x=SC.minX(Math.max(c,0));if(SC.maxX(b)>a.width)b.x=Math.max(0,a.width-b.width)}if(SC.maxY(b)>a.height){d=
Math.max(c.y-b.height,0);b.y=d>a.height?Math.max(0,a.height-b.height):d}if(SC.minY(b)<0){d=Math.min(SC.maxY(c),a.height-c.height);b.y=Math.max(d,0)}return b},fitPositionToScreenMenu:function(a,b,c){if(b.x+b.width>a.width-20)if(c)b.x-=b.width*2;else b.x=a.width-b.width-20;if(b.x<7)b.x=7;if(b.height+b.y+35>=a.height)if(b.height+50>=a.height){b.y=15;b.height=a.height-50}else b.y+=a.height-(b.height+b.y+35);return b},fitPositionToScreenPointer:function(a,b,c){var d=c.height>12?0:1,e=c.height>12?0:3,f=
[[c.x+c.width+(7+d),c.y+parseInt(c.height/2,0)-40],[c.x-b.width-(7+d),c.y+parseInt(c.height/2,0)-40],[c.x+parseInt(c.width/2-b.width/2,0),c.y-b.height-(17+e)],[c.x+parseInt(c.width/2-b.width/2,0),c.y+c.height+(17+e)]];d=[[c.x+c.width+b.width+(7+d),c.y+parseInt(c.height/2,0)+b.height-24],[c.x-(7+d),c.y+parseInt(c.height/2,0)+b.height-24],[c.x+parseInt(c.width/2-b.width/2,0)+b.width,c.y-(17+e)],[c.x+parseInt(c.width/2-b.width/2,0)+b.width,c.y+c.height+b.height+(17+e)]];a=[[f[0][1]>0?0:0-f[0][1],d[0][0]<
a.width?0:d[0][0]-a.width,d[0][1]<a.height?0:d[0][1]-a.height,f[0][0]>0?0:0-f[0][0]],[f[1][1]>0?0:0-f[1][1],d[1][0]<a.width?0:d[1][0]-a.width,d[1][1]<a.height?0:d[1][1]-a.height,f[1][0]>0?0:0-f[1][0]],[f[2][1]>0?0:0-f[2][1],d[2][0]<a.width?0:d[2][0]-a.width,d[2][1]<a.height?0:d[2][1]-a.height,f[2][0]>0?0:0-f[2][0]],[f[3][1]>0?0:0-f[3][1],d[3][0]<a.width?0:d[3][0]-a.width,d[3][1]<a.height?0:d[3][1]-a.height,f[3][0]>0?0:0-f[3][0]]];if(!this.preferMatrix||this.preferMatrix.length!==5)this.set("preferMatrix",
[0,1,2,3,2]);d=this.preferMatrix;if(d[4]===-1){b.x=c.x+parseInt(c.width/2,0);b.y=c.y+parseInt(c.height/2,0)-parseInt(b.height/2,0);this.set("pointerPos",SC.POINTER_LAYOUT[0]+" fallback");this.set("pointerPosY",parseInt(b.height/2,0)-40)}else{b.x=f[d[4]][0];b.y=f[d[4]][1];this.set("pointerPos",SC.POINTER_LAYOUT[d[4]]);this.set("pointerPosY",0)}this.set("pointerPosX",0);c=0;for(var g=SC.POINTER_LAYOUT.length;c<g;c++){e=d[c];if(a[e][0]===0&&a[e][1]===0&&a[e][2]===0&&a[e][3]===0){if(d[4]!==e){b.x=f[e][0];
b.y=f[e][1];this.set("pointerPosY",0);this.set("pointerPos",SC.POINTER_LAYOUT[e])}c=SC.POINTER_LAYOUT.length}else if((e===0||e===1)&&a[e][0]===0&&a[e][1]===0&&a[e][2]<b.height-91&&a[e][3]===0){if(d[4]!==e){b.x=f[e][0];this.set("pointerPos",SC.POINTER_LAYOUT[e])}b.y=f[e][1]-a[e][2];this.set("pointerPosY",a[e][2]);c=SC.POINTER_LAYOUT.length}else if((e===0||e===1)&&a[e][0]===0&&a[e][1]===0&&a[e][2]<=b.height-57&&a[e][3]===0){if(d[4]!==e)b.x=f[e][0];b.y=f[e][1]-(b.height-57);this.set("pointerPosY",b.height-
59);this.set("pointerPos",SC.POINTER_LAYOUT[e]+" extra-low");c=SC.POINTER_LAYOUT.length}}return b},displayProperties:["pointerPosY"],render:function(a){var b=arguments.callee.base.apply(this,arguments);if(a.needsContent)this.get("preferType")==SC.PICKER_POINTER&&a.push('<div class="sc-pointer '+this.get("pointerPos")+'" style="margin-top: '+this.get("pointerPosY")+'px"></div>');else{var c=this.$(".sc-pointer");c.attr("class","sc-pointer "+this.get("pointerPos"));c.attr("style","margin-top: "+this.get("pointerPosY")+
"px")}return b},modalPaneDidClick:function(a){this.clickInside(this.get("frame"),a)||this.remove();return YES},mouseDown:function(a){return this.modalPaneDidClick(a)},clickInside:function(a,b){return SC.pointInRect({x:b.pageX,y:b.pageY},a)},windowSizeDidChange:function(){this.positionPane()}});SC.SeparatorView=SC.View.extend({classNames:["sc-separator-view"],tagName:"span",layoutDirection:SC.LAYOUT_HORIZONTAL,render:function(a,b){b&&a.push("<span></span>");a.addClass(this.get("layoutDirection"))}});
sc_require("views/button");sc_require("views/separator");
SC.MenuItemView=SC.View.extend(SC.ContentDisplay,{classNames:["sc-menu-item"],acceptsFirstResponder:YES,content:null,isSubMenuViewVisible:null,hasMouseExited:NO,subMenu:function(){var a=this.get("content"),b;if(!a)return null;b=this.get("parentMenu");if(a=a.get(b.itemSubMenuKey))if(SC.kindOf(a,SC.MenuPane)){a.set("isModal",NO);a.set("isSubMenu",YES);a.set("parentMenu",b);return a}else return SC.MenuPane.create({layout:{width:200},items:a,isModal:NO,isSubMenu:YES,parentMenu:b});return null}.property("content").cacheable(),
hasSubMenu:function(){return!!this.get("subMenu")}.property("subMenu").cacheable(),render:function(a){var b=this.get("content"),c=this.get("parentMenu"),d=this.get("itemWidth")||c.layout.width,e=this.get("itemHeight")||SC.DEFAULT_MENU_ITEM_HEIGHT;this.set("itemWidth",d);this.set("itemHeight",e);a=a.begin("a");if(b.get(c.itemSeparatorKey)){a.push('<span class="separator"></span>');a.addClass("disabled")}else{if(b=b.get(c.itemIconKey)){this.renderImage(a,b);a.addClass("has-icon")}b=this.get("title");
if(SC.typeOf(b)!==SC.T_STRING)b=b.toString();this.renderLabel(a,b);this.getContentProperty("itemCheckboxKey")&&a.push('<div class="checkbox"></div>');this.get("hasSubMenu")&&this.renderBranch(a);(b=this.getContentProperty("itemShortCutKey"))&&this.renderShortcut(a,b)}a.end()},renderImage:function(a,b){var c;if(b&&SC.ImageView.valueIsUrl(b)){b=b;c=""}else{c=b;b=SC.BLANK_IMAGE_URL}a.begin("img").addClass("image").addClass(c).attr("src",b).end()},renderLabel:function(a,b){if(this.get("escapeHTML"))b=
SC.RenderContext.escapeHTML(b);a.push("<span class='value ellipsis'>"+b+"</span>")},renderBranch:function(a){a.push('<span class="has-branch"></span>')},renderShortcut:function(a,b){a.push('<span class = "shortcut">'+b+"</span>")},isSeparator:function(){return this.getContentProperty("itemSeparatorKey")===YES}.property("content").cacheable(),showSubMenu:function(){var a=this.get("subMenu");a&&a.popup(this,[0,0,0])},isEnabled:function(){return this.getContentProperty("itemIsEnabledKey")!==NO&&this.getContentProperty("itemSeparatorKey")!==
YES}.property("content.isEnabled").cacheable(),title:function(){var a=this.getContentProperty("itemTitleKey");if(this.getPath("parentMenu.localize")&&a)a=a.loc();return a||""}.property("content.title").cacheable(),getContentProperty:function(a){var b=this.get("content"),c=this.get("parentMenu");if(b)return b.get(c.get(a))},mouseUp:function(){var a;(a=this.getPath("parentMenu.rootMenu.targetMenuItem"))&&a.performAction();return YES},performAction:function(){if(!(!this.get("isEnabled")||this.get("hasSubMenu")))if(this.getContentProperty("itemDisableMenuFlashKey"))this.sendAction();
else{this._flashCounter=0;this.invokeLater(this.flashHighlight,25);this.invokeLater(this.sendAction,200)}},sendAction:function(){var a=this.getContentProperty("itemActionKey"),b=this.getContentProperty("itemTargetKey"),c=this.getPath("parentMenu.rootMenu");a=a===undefined?c.get("action"):a;b=b===undefined?c.get("target"):b;c.set("selectedItem",this.get("content"));if(SC.typeOf(a)===SC.T_FUNCTION){a.apply(b,[c]);SC.Logger.warn("Support for menu item action functions has been deprecated. Please use target and action.")}else(c=
this.getPath("pane.rootResponder")||SC.RootResponder.responder)&&c.sendAction(a,b,this,this.get("pane"));this.getPath("parentMenu.rootMenu").remove()},flashHighlight:function(){var a=this._flashCounter,b=this.$();a%2===0?b.addClass("focus"):b.removeClass("focus");if(a<=2){this.invokeLater(this.flashHighlight,50);this._flashCounter++}},mouseDown:function(){return YES},mouseEntered:function(){var a=this.get("parentMenu");a.set("mouseHasEntered",YES);a.set("currentMenuItem",this);this.get("hasSubMenu")&&
this.invokeLater(this.showSubMenu,100);return YES},mouseExited:function(){var a;if(this.get("hasSubMenu")){this.get("subMenu");this.invokeLater(this.checkMouseLocation,200)}else{a=this.get("parentMenu");a.get("currentMenuItem")===this&&a.set("currentMenuItem",null)}return YES},checkMouseLocation:function(){var a=this.get("subMenu"),b=this.get("parentMenu"),c;if(!a.get("mouseHasEntered")){c=b.get("currentMenuItem");if(c===this||c===null){(b=b.get("previousMenuItem"))&&b.resignFirstResponder();a.remove()}}},
moveUp:function(){var a=this.get("parentMenu");a&&a.moveUp(this);return YES},moveDown:function(){var a=this.get("parentMenu");a&&a.moveDown(this);return YES},moveRight:function(){this.showSubMenu();return YES},keyDown:function(a){return this.interpretKeyEvents(a)},keyUp:function(){return YES},cancel:function(){this.getPath("parentMenu.rootMenu").remove();return YES},didBecomeFirstResponder:function(a){if(a===this)(a=this.get("parentMenu"))&&a.set("currentSelectedMenuItem",this)},willLoseFirstResponder:function(a){if(a===
this)if(a=this.get("parentMenu")){a.set("currentSelectedMenuItem",null);a.set("previousSelectedMenuItem",this)}},insertNewline:function(a,b){this.mouseUp(b)},closeParent:function(){this.$().removeClass("focus");var a=this.get("parentMenu");a&&a.remove()},clickInside:function(a,b){return SC.pointInRect({x:b.pageX,y:b.pageY},a)}});sc_require("panes/picker");sc_require("views/menu_item");if(!SC.DEFAULT_MENU_ITEM_HEIGHT)SC.DEFAULT_MENU_ITEM_HEIGHT=20;
if(!SC.DEFAULT_MENU_ITEM_SEPARATOR_HEIGHT)SC.DEFAULT_MENU_ITEM_SEPARATOR_HEIGHT=9;if(!SC.DEFAULT_MENU_HEIGHT_PADDING)SC.DEFAULT_MENU_HEIGHT_PADDING=0;
SC.MenuPane=SC.PickerPane.extend({classNames:["sc-menu"],items:[],itemHeight:SC.DEFAULT_MENU_ITEM_HEIGHT,itemSeparatorHeight:SC.DEFAULT_MENU_ITEM_SEPARATOR_HEIGHT,menuHeight:0,menuHeightPadding:SC.DEFAULT_MENU_HEIGHT_PADDING,selectedItem:null,exampleView:SC.MenuItemView,anchor:null,isSubMenu:NO,localize:YES,popup:function(a,b){var c;if(a)c=a.isView?a.get("layer"):a;this.beginPropertyChanges();this.set("anchorElement",c);this.set("anchor",a);this.set("preferType",SC.PICKER_MENU);b&&this.set("preferMatrix",
b);this.endPropertyChanges();this.adjust("height",this.get("menuHeight"));this.positionPane();this.set("defaultResponder",this);this.append()},remove:function(){this.set("currentMenuItem",null);this.closeOpenMenus();this.resignKeyPane();return arguments.callee.base.apply(this,arguments)},itemTitleKey:"title",itemIsEnabledKey:"isEnabled",itemValueKey:"value",itemIconKey:"icon",itemHeightKey:"height",itemSubMenuKey:"subMenu",itemSeparatorKey:"separator",itemTargetKey:"target",itemActionKey:"action",
itemCheckboxKey:"checkbox",itemShortCutKey:"shortcut",itemKeyEquivalentKey:"keyEquivalent",itemDisableMenuFlashKey:"disableMenuFlash",menuItemKeys:"itemTitleKey itemValueKey itemIsEnabledKey itemIconKey itemSeparatorKey itemActionKey itemCheckboxKey itemShortCutKey itemBranchKey itemHeightKey subMenuKey itemKeyEquivalentKey itemTargetKey".w(),preferType:SC.PICKER_MENU,isModal:YES,_menuView:null,createChildViews:function(){var a,b,c;a=this.createChildView(SC.MenuScrollView,{borderStyle:SC.BORDER_NONE});
b=this._menuView=SC.View.create();c=this.get("menuItemViews");b.set("layout",{top:0,left:0,height:this.get("menuHeight")});b.replaceAllChildren(c);a.set("contentView",b);this.childViews=[a];return this},menuItemViews:function(){var a=[],b=this.get("displayItems"),c=this.get("exampleView"),d,e,f,g,h,j,k,l,m,n,o,r,u;if(!b)return a;g=this.get("itemHeightKey");h=this.get("itemSeparatorKey");j=this.get("itemHeight");n=this.get("itemKeyEquivalentKey");k=this.get("itemSeparatorHeight");l=m=Math.floor(this.get("menuHeightPadding")/
2);o=this.menuItemKeys.map(SC._menu_fetchKeys,this);u=b.get("length");for(r=0;r<u;r++){d=b[r];(f=d.get(g))||(f=d.get(h)?k:j);e=this._menuView.createChildView(c,{layout:{height:f,top:l},contentDisplayProperties:o,content:d,parentMenu:this});a[r]=e;l+=f;if(d=d.get(n))this._keyEquivalents[d]=e}this.set("menuHeight",l+m);return a}.property("displayItems").cacheable(),menuItemViewForContentIndex:function(a){var b=this.get("menuItemViews");if(b)return b.objectAt(a)},_keyEquivalents:{},rootMenu:function(){if(this.get("isSubMenu"))return this.getPath("parentMenu.rootMenu");
return this}.property("isSubMenu").cacheable(),windowSizeDidChange:function(){this.remove();return arguments.callee.base.apply(this,arguments)},displayItems:function(){var a=this.get("items");this.get("localize");this.get("itemHeight");var b,c=[],d,e,f;if(!a)return null;b=a.get("length");for(d=0;d<b;d++)if(e=a.objectAt(d)){f=SC.typeOf(e);if(f===SC.T_STRING)e=SC.Object.create({title:e,value:e,isEnabled:YES});else if(f===SC.T_HASH)e=SC.Object.create(e);else if(f===SC.T_ARRAY)e=this.convertArrayMenuItemToObject(e);
e.contentIndex=d;c.push(e)}return c}.property("items").cacheable(),_sc_menu_itemsDidChange:function(){this._menuView.replaceAllChildren(this.get("menuItemViews"));this._menuView.adjust("height",this.get("menuHeight"))}.observes("items"),convertArrayMenuItemToObject:function(a){SC.Logger.warn("Support for Array-based menu items has been deprecated.  Please update your menus to use a hash.");var b;b=SC._menu_fetchKeys;var c=SC.Object.create();b=this.menuItemKeys.map(b,this);c[b[0]]=a[0];c[b[1]]=a[1];
c[b[2]]=a[2];c[b[3]]=a[3];c[b[4]]=a[4];c[b[5]]=a[5];c[b[6]]=a[6];c[b[7]]=a[7];c[b[8]]=a[8];c[b[9]]=a[9];c[b[10]]=a[10];c[b[11]]=a[11];c[b[12]]=a[12];return c},currentMenuItem:function(a,b){if(b!==undefined){this._currentMenuItem!==null&&this.set("previousMenuItem",this._currentMenuItem);this._currentMenuItem=b;this.setPath("rootMenu.targetMenuItem",b);return b}return this._currentMenuItem}.property().cacheable(),_sc_menu_currentMenuItemDidChange:function(){var a=this.get("currentMenuItem"),b=this.get("previousMenuItem");
if(b)if(!(b.get("hasSubMenu")&&a===null)){b.resignFirstResponder();this.closeOpenMenusFor(b)}a&&a.get("isEnabled")&&!a.get("isSeparator")&&a.becomeFirstResponder()}.observes("currentMenuItem"),closeOpenMenusFor:function(a){if(a)for(var b=a.get("parentMenu");b&&a;)if(b=a.get("subMenu")){b.remove();a.resignFirstResponder();a=b.get("previousMenuItem")}},closeOpenMenus:function(){this.closeOpenMenusFor(this.get("previousMenuItem"))},mouseDown:function(){this.modalPaneDidClick();return YES},keyUp:function(a){a=
this.interpretKeyEvents(a);return!a?NO:a},moveUp:function(){var a=this.get("currentMenuItem"),b=this.get("menuItemViews");if(a){a=a.getPath("content.contentIndex");if(a===0)return YES;a=a-1}else a=b.get("length")-1;for(;a>=0;){if(b[a].get("isEnabled")){this.set("currentMenuItem",b[a]);break}a--}return YES},moveDown:function(){var a=this.get("currentMenuItem"),b=this.get("menuItemViews"),c=b.get("length");if(a){a=a.getPath("content.contentIndex");if(a===c)return YES;a=a+1}else a=0;for(;a<c;){if(b[a].get("isEnabled")){this.set("currentMenuItem",
b[a]);break}a++}return YES},insertText:function(a){var b=this._timer,c=this._keyBuffer;b&&b.invalidate();this._timer=SC.Timer.schedule({target:this,action:"clearKeyBuffer",interval:500,isPooled:NO});c=c||"";c+=a.toUpperCase();this.selectMenuItemForString(c);this._keyBuffer=c;return YES},performKeyEquivalent:function(a){if(a=this._keyEquivalents[a]){a.performAction(YES);return YES}return NO},selectMenuItemForString:function(a){var b=this.get("menuItemViews"),c,d,e,f,g;if(b){g=a.length;f=b.get("length");
for(e=0;e<f;e++){c=b.objectAt(e);if(d=c.get("title")){d=d.replace(/ /g,"").substr(0,g).toUpperCase();if(d===a){this.set("currentMenuItem",c);break}}}}},clearKeyBuffer:function(){this._keyBuffer=""},modalPaneDidClick:function(){this.closeOpenMenusFor(this.get("previousMenuItem"));this.remove();return YES}});SC._menu_fetchKeys=function(a){return this.get(a)};SC._menu_fetchItem=function(a){if(!a)return null;return this.get?this.get(a):this[a]};sc_require("views/button");
SC.SelectButtonView=SC.ButtonView.extend({objects:[],objectsBindingDefault:SC.Binding.multiple(),nameKey:null,sortKey:null,valueKey:null,iconKey:null,isEnabledKey:"isEnabled",localize:YES,disableSort:YES,classNames:["select-button"],itemList:[],itemIdx:null,value:null,checkboxEnabled:YES,separatorPostion:null,_defaultVal:null,_defaultTitle:null,_defaultIcon:null,theme:"popup",displayProperties:["icon","value","controlSize","objects"],preferMatrix:null,SELECT_BUTTON_SPRITE_WIDTH:28,CUSTOM_MENU_ITEM_HEIGHT:20,
isSelectedBinding:"*menu.isVisibleInWindow",isDefaultPosition:NO,lastMenuWidth:null,customView:null,customViewClassName:null,customViewMenuOffsetWidth:0,needsEllipsis:YES,menuPaneHeightPadding:0,supportFocusRing:YES,leftAlign:function(){var a=0,b=this.get("controlSize");if(b===SC.SMALL_CONTROL_SIZE)a=-12;if(b===SC.REGULAR_CONTROL_SIZE)a=-15;return a}.property("controlSize"),sortObjects:function(a){if(!this.get("disableSort")){var b=this.get("sortKey")||this.get("nameKey");a=a.sort(function(c,d){if(b){c=
c.get?c.get(b):c[b];d=d.get?d.get(b):d[b]}return c<d?-1:c>d?1:0})}return a},render:function(a,b){arguments.callee.base.apply(this,arguments);var c,d,e,f,g,h,j,k,l,m,n,o,r,u,q,s,w;c=this.layout.width;b&&c&&this.adjust({width:c-this.SELECT_BUTTON_SPRITE_WIDTH});c=this.get("objects");c=this.sortObjects(c);d=c.length;e=this.get("nameKey");f=this.get("iconKey");g=this.get("valueKey");w=this.get("isEnabledKey");h=this.get("checkboxEnabled");j=this.get("value");k=this.get("localize");l=this.get("separatorPostion");
m=[];n=YES;o=0;c.forEach(function(v){if(v){r=e?v.get?v.get(e):v[e]:v.toString();r=k?r.loc():r;u=f?v.get?v.get(f):v[f]:null;if(SC.none(v[f]))u=null;q=g?v.get?v.get(g):v[g]:v;if(!SC.none(j)&&!SC.none(q))if(j===q){this.set("title",r);this.set("icon",u)}if(q===this.get("value")){this.set("itemIdx",o);n=!h?NO:YES}else n=NO;s=v[w];if(NO!==s)s=YES;if(o===0){this._defaultVal=q;this._defaultTitle=r;this._defaultIcon=u}v=SC.Object.create({title:r,icon:u,value:q,isEnabled:s,checkbox:n,target:this,action:this.displaySelectedItem});
m.push(v)}o+=1;if(l&&o===d-l){v=SC.Object.create({separator:YES});m.push(v)}this.set("itemList",m)},this);b&&this.invokeLast(function(){var v=this.get("value");if(SC.none(v)){this.set("value",this._defaultVal);this.set("title",this._defaultTitle);this.set("icon",this._defaultIcon)}});this.set("CUSTOM_MENU_ITEM_HEIGHT",this.get("controlSize")===SC.SMALL_CONTROL_SIZE?18:20);this.changeSelectButtonPreferMatrix(this.itemIdx)},_action:function(){var a,b,c,d,e,f,g,h,j;a=this.$(".sc-button-label")[0];b=
this.get("layer").offsetWidth;c=a.scrollWidth;d=this.get("lastMenuWidth");if(c){a=a.offsetWidth;if(c&&a)b=b+c-a}if(!d||b>d)d=b;b=this.get("itemList");g=this.get("customViewClassName");c=this.get("customViewMenuOffsetWidth");a="sc-view sc-pane sc-panel sc-palette sc-picker sc-menu select-button sc-scroll-view sc-menu-scroll-view sc-container-view menuContainer sc-button-view sc-menu-item sc-regular-size";a=g?a+" "+g:a;h=0;for(j=b.length;h<j;++h){e=b.objectAt(h);g=document.createElement("div");g.style.cssText=
"top:-10000px; left: -10000px;  position: absolute;";g.className=a;g.innerHTML=e.title;document.body.appendChild(g);e=g.offsetWidth+c;if(!f||e>f)f=e;document.body.removeChild(g)}d=f>d?f:d;f=SC.RootResponder.responder.get("currentWindowSize").width;if(d>f)d=f-25;this.set("lastMenuWidth",d);this.get("value");f=this.get("itemList");b=this.get("controlSize");c=this.get("menuPaneHeightPadding");a=this.get("customView");d=SC.MenuPane.create({classNames:["select-button"],items:f,exampleView:a?a:SC.MenuItemView,
isEnabled:YES,menuHeightPadding:c,preferType:SC.PICKER_MENU,itemHeightKey:"height",layout:{width:d},controlSize:b,itemWidth:d,itemHeight:this.get("itemHeight")||20,contentView:SC.View.extend({})});if(!d)return NO;d.popup(this,this.preferMatrix);d.set("currentMenuItem",d.menuItemViewForContentIndex(this.get("itemIdx")));return YES},displaySelectedItem:function(a){a=a.get("selectedItem");this.set("value",a.get("value"));this.set("title",a.get("title"));this.set("itemIdx",a.get("contentIndex"))},changeSelectButtonPreferMatrix:function(){var a=
this.get("controlSize")===SC.SMALL_CONTROL_SIZE?0:-2,b=a,c=this.get("itemIdx"),d=this.get("leftAlign");if(this.get("isDefaultPosition")){a=[d,4,3];this.set("preferMatrix",a)}else{if(c)b=c*this.CUSTOM_MENU_ITEM_HEIGHT+a;a=[d,-b,2];this.set("preferMatrix",a)}},mouseDown:function(){if(!this.get("isEnabled"))return YES;this.set("isActive",YES);this._isMouseDown=YES;this.becomeFirstResponder();this._action();return YES},keyDown:function(a){if(this.interpretKeyEvents(a))return YES;else arguments.callee.base.apply(this,
arguments)},interpretKeyEvents:function(a){if(a)if(a.keyCode===38||a.keyCode===40)this._action();else a.keyCode===27&&this.resignFirstResponder();return arguments.callee.base.apply(this,arguments)},acceptsFirstResponder:function(){return this.get("isEnabled")}.property("isEnabled")});sc_require("panes/panel");
SC.SheetPane=SC.PanelPane.extend({classNames:"sc-sheet",transitionDuration:200,_state:"NO_VIEW",init:function(){arguments.callee.base.apply(this,arguments);if(SC.Animatable){SC.SheetPane.ANIMATABLE_AVAILABLE=YES;this.mixin(SC.Animatable);if(!this.transitions)this.transitions={};if(!this.transitions.top)this.transitions.top={duration:this.transitionDuration===200?0.3:this.transitionDuration/1E3,action:"_complete",target:this}}},append:function(){var a=this.get("layout");if(!a.height||!a.top)a=SC.View.convertLayoutToAnchoredLayout(a,
this.computeParentDimensions());a.top=-1*a.height;this.disableAnimation&&this.disableAnimation();this.adjust(a);this.updateLayout();this.enableAnimation&&this.enableAnimation();return arguments.callee.base.apply(this,arguments)},remove:function(){var a=this,b=arguments;this.invokeLater(function(){b.callee.base.apply(a,b)},this.transitionDuration);this.slideUp();return this},paneDidAttach:function(){var a=arguments.callee.base.apply(this,arguments);this.slideDown();return a},slideDown:function(){this._state=
SC.SheetPane.ANIMATING;this._direction=SC.SheetPane.SLIDE_DOWN;if(SC.SheetPane.ANIMATABLE_AVAILABLE){this.transitions.top.timing=SC.Animatable.TRANSITION_EASE_OUT;this.adjust("top",0)}else{this._start=Date.now();this._end=this._start+this.get("transitionDuration");this.tick()}},slideUp:function(){this._state=SC.SheetPane.ANIMATING;this._direction=SC.SheetPane.SLIDE_UP;if(SC.SheetPane.ANIMATABLE_AVAILABLE){var a=this.get("layout");this.transitions.top.timing=SC.Animatable.TRANSITION_EASE_IN;this.adjust("top",
-1*a.height)}else{this._start=Date.now();this._end=this._start+this.get("transitionDuration");this.tick()}},_complete:function(){if(this._direction===SC.SheetPane.SLIDE_DOWN){SC.SheetPane.ANIMATABLE_AVAILABLE||this.adjust("top",0);SC.browser.mozilla&&this.parentViewDidChange()}else{var a=this.get("layout");SC.SheetPane.ANIMATABLE_AVAILABLE||this.adjust("top",-1*a.height)}this._state=SC.SheetPane.READY;this.updateLayout()},blurTo:function(){this.setFirstResponder("")},tick:function(){this._timer=null;
var a=(Date.now()-this._start)/(this._end-this._start),b=this,c=this._direction,d=this.get("layout");if(a<0)a=0;if(a>=1){this._complete();return this}a=Math.floor(d.height*a);if(c==SC.SheetPane.SLIDE_DOWN)b.adjust("top",0-(d.height-a));else c==SC.SheetPane.SLIDE_UP&&b.adjust("top",0-a);this._timer=this.invokeLater(this.tick,20);b.updateLayout();return this}});SC.SheetPane.mixin({ANIMATABLE_AVAILABLE:NO,NO_VIEW:"NO_VIEW",ANIMATING:"ANIMATING",READY:"READY",SLIDE_DOWN:"SLIDEDOWN",SLIDE_UP:"SLIDEUP"});
SC.DRAG_LINK=4;SC.DRAG_COPY=1;SC.DRAG_MOVE=2;SC.DRAG_NONE=0;SC.DRAG_ANY=7;SC.DRAG_AUTOSCROLL_ZONE_THICKNESS=20;
SC.Drag=SC.Object.extend({source:null,ghostView:null,ghostActsLikeCursor:NO,dragView:null,ghost:YES,slideBack:YES,mouseDownEvent:null,ghostOffset:{x:0,y:0},location:{},dataTypes:function(){if(this.dataSource)return this.dataSource.get("dragDataTypes")||[];var a=this.data;if(a){var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(c);return b}if((a=this.get("source"))&&a.dragDataTypes)return a.get("dragDataTypes")||[];return[]}.property().cacheable(),hasDataType:function(a){return this.get("dataTypes").indexOf(a)>=
0},dataForType:function(a){if(this.dataSource)return this.dataSource.dragDataForType(this,a);else if(this.data)return this.data[a];else{var b=this.get("source");return b&&SC.typeOf(b.dragDataForType)==SC.T_FUNCTION?b.dragDataForType(this,a):null}},dataSource:null,data:null,allowedDragOperations:SC.DRAG_ANY,_dragInProgress:YES,_dragViewWasVisible:null,startDrag:function(){this._createGhostView();var a=this.event,b={x:a.pageX,y:a.pageY};this.set("location",b);var c=this._getDragView(),d=c.get("parentView");
d=d?d.convertFrameToView(c.get("frame"),null):c.get("frame");if(this.ghost){this._dragViewWasVisible=c.get("isVisible");c.set("isVisible",NO)}this.ghostOffset=this.ghostActsLikeCursor?{x:14,y:14}:{x:b.x-d.x,y:b.y-d.y};this._ghostViewHidden||this._positionGhostView(a);this.ghostView.rootResponder.dragDidStart(this);(c=this.source)&&c.dragDidBegin&&c.dragDidBegin(this,b);b=this._dropTargets();c=0;for(d=b.length;c<d;c++)b[c].tryToPerform("dragStarted",this,a)},mouseDragged:function(a){var b=this._autoscroll(a),
c=this.get("location");if(!(!b&&a.pageX===c.x&&a.pageY===c.y)){c={x:a.pageX,y:a.pageY};this.set("location",c);b=this.source;for(var d=this._lastTarget,e=this._findDropTarget(a),f=SC.DRAG_NONE;e&&e!==d&&f===SC.DRAG_NONE;){f=e&&b&&b.dragSourceOperationMaskFor?b.dragSourceOperationMaskFor(this,e):SC.DRAG_ANY;if(f!==SC.DRAG_NONE&&e&&e.computeDragOperations)f&=e.computeDragOperations(this,a,f);else f=SC.DRAG_NONE;this.allowedDragOperations=f;if(f===SC.DRAG_NONE)e=this._findNextDropTarget(e)}if(e!==d){d&&
d.dragExited&&d.dragExited(this,a);if(e){e.dragEntered&&e.dragEntered(this,a);e.dragUpdated&&e.dragUpdated(this,a)}this._lastTarget=e}else e&&e.dragUpdated&&e.dragUpdated(this,a);b&&b.dragDidMove&&b.dragDidMove(this,c);this._ghostViewHidden||this._positionGhostView(a)}},mouseUp:function(a){var b={x:a.pageX,y:a.pageY},c=this._lastTarget,d=this.allowedDragOperations;this.set("location",b);try{d=c&&c.acceptDragOperation&&c.acceptDragOperation(this,d)?c.performDragOperation?c.performDragOperation(this,
d):SC.DRAG_NONE:SC.DRAG_NONE}catch(e){SC.Logger.error("Exception in SC.Drag.mouseUp(acceptDragOperation|performDragOperation): %@".fmt(e))}try{c&&c.dragExited&&c.dragExited(this,a)}catch(f){SC.Logger.error("Exception in SC.Drag.mouseUp(target.dragExited): %@".fmt(f))}c=this._dropTargets();for(var g=0,h=c.length;g<h;g++)try{c[g].tryToPerform("dragEnded",this,a)}catch(j){SC.Logger.error("Exception in SC.Drag.mouseUp(dragEnded on %@): %@".fmt(c[g],j))}this._destroyGhostView();if(this.ghost){this._dragViewWasVisible&&
this._getDragView().set("isVisible",YES);this._dragViewWasVisible=null}(a=this.source)&&a.dragDidEnd&&a.dragDidEnd(this,b,d);this._lastTarget=null;this._dragInProgress=NO},_getDragView:function(){if(!this.dragView){if(!this.source||!this.source.isView)throw"Source can't be used as dragView, because it's not a view.";this.dragView=this.source}return this.dragView},_createGhostView:function(){var a=this._getDragView(),b=a.get("frame");(this.ghostView=SC.Pane.create({classNames:["sc-ghost-view"],layout:{top:b.y,
left:b.x,width:b.width,height:b.height},owner:this,didCreateLayer:function(){if(a){var c=a.get("layer");if(c){c=c.cloneNode(true);c.style.top="0px";c.style.left="0px";this.get("layer").appendChild(c)}}}})).append()},_positionGhostView:function(){var a=this.get("location");a.x-=this.ghostOffset.x;a.y-=this.ghostOffset.y;var b=this.ghostView;if(b){b.adjust({top:a.y,left:a.x});b.invokeOnce("updateLayout")}},_ghostViewHidden:NO,hideGhostView:function(){if(this.ghostView&&!this._ghostViewHidden){this.ghostView.remove();
this._ghostViewHidden=YES}},unhideGhostView:function(){if(this._ghostViewHidden){this._ghostViewHidden=NO;this._createGhostView()}},_destroyGhostView:function(){if(this.ghostView){this.ghostView.remove();this.ghostView=null;this._ghostViewHidden=NO}},_dropTargets:function(){if(this._cachedDropTargets)return this._cachedDropTargets;var a=[],b=SC.Drag._dropTargets;for(var c in b)b.hasOwnProperty(c)&&a.push(b[c]);var d={},e=SC.Drag._dropTargets,f=function(g){if(!g)return 0;var h=SC.guidFor(g),j=d[h];
if(!j){for(j=1;g=g.get("parentView");)e[SC.guidFor(g)]!==undefined&&j++;d[h]=j}return j};a.sort(function(g,h){if(g===h)return 0;g=f(g);h=f(h);return g>h?-1:1});return this._cachedDropTargets=a},_findDropTarget:function(a){a={x:a.pageX,y:a.pageY};for(var b,c,d=this._dropTargets(),e=0,f=d.length;e<f;e++){b=d[e];if(b.get("isVisibleInWindow")){c=b.convertFrameToView(b.get("clippingFrame"),null);if(SC.pointInRect(a,c))return b}}return null},_findNextDropTarget:function(a){for(var b=SC.Drag._dropTargets;a=
a.get("parentView");)if(b[SC.guidFor(a)])return a;return null},_autoscroll:function(a){if(!a)a=this._lastAutoscrollEvent;if(!this._dragInProgress)return NO;for(var b=a?{x:a.pageX,y:a.pageY}:this.get("location"),c=this._findScrollableView(b),d=null,e,f,g,h,j;c&&!d;){e=c.get("canScrollVertical")?1:0;f=c.get("canScrollHorizontal")?1:0;if(e||f)if(g=c.get("containerView"))j=c.convertFrameToView(g.get("frame"),null);else e=f=0;if(e){h=SC.maxY(j);g=h-SC.DRAG_AUTOSCROLL_ZONE_THICKNESS;if(b.y>=g&&b.y<=h)e=
1;else{g=SC.minY(j);h=g+SC.DRAG_AUTOSCROLL_ZONE_THICKNESS;e=b.y>=g&&b.y<=h?-1:0}}if(f){h=SC.maxX(j);g=h-SC.DRAG_AUTOSCROLL_ZONE_THICKNESS;if(b.x>=g&&b.x<=h)f=1;else{g=SC.minX(j);h=g+SC.DRAG_AUTOSCROLL_ZONE_THICKNESS;f=b.x>=g&&b.x<=h?-1:0}}if(e||f)d=c;else c=this._findNextScrollableView(c)}if(d&&this._lastScrollableView===d){if(Date.now()-this._hotzoneStartTime>100){this._horizontalScrollAmount*=1.05;this._verticalScrollAmount*=1.05}}else{this._lastScrollableView=d;this._verticalScrollAmount=this._horizontalScrollAmount=
15;this._hotzoneStartTime=d?Date.now():null;f=e=0}if(d&&(f||e))d.scrollBy({x:f*this._horizontalScrollAmount,y:e*this._verticalScrollAmount});if(d){if(a)this._lastAutoscrollEvent={pageX:a.pageX,pageY:a.pageY};this.invokeLater(this._autoscroll,100,null);return YES}else{this._lastAutoscrollEvent=null;return NO}},_scrollableViews:function(){if(this._cachedScrollableView)return this._cachedScrollableView;var a=[],b=SC.Drag._scrollableViews;for(var c in b)b.hasOwnProperty(c)&&a.push(b[c]);return this._cachedScrollableView=
a=a.sort(function(d,e){for(d=d;d=d.get("parentView");)if(e==d)return-1;return 1})},_findScrollableView:function(a){var b=this._scrollableViews(),c=b?b.length:0,d,e,f;for(f=0;f<c;f++){d=b[f];if(d.get("isVisibleInWindow")){e=d.convertFrameToView(d.get("clippingFrame"),null);if(SC.pointInRect(a,e))return d}}return null},_findNextScrollableView:function(a){for(var b=SC.Drag._scrollableViews;a=a.get("parentView");)if(b[SC.guidFor(a)])return a;return null}});
SC.Drag.mixin({start:function(a){a=this.create(a);a.startDrag();return a},_dropTargets:{},_scrollableViews:{},addDropTarget:function(a){this._dropTargets[SC.guidFor(a)]=a},removeDropTarget:function(a){delete this._dropTargets[SC.guidFor(a)]},addScrollableView:function(a){this._scrollableViews[SC.guidFor(a)]=a},removeScrollableView:function(a){delete this._scrollableViews[SC.guidFor(a)]}});
SC.MODIFIED_KEY_BINDINGS={"ctrl_.":"cancel",shift_tab:"insertBacktab",shift_left:"moveLeftAndModifySelection",shift_right:"moveRightAndModifySelection",shift_up:"moveUpAndModifySelection",shift_down:"moveDownAndModifySelection",alt_left:"moveLeftAndModifySelection",alt_right:"moveRightAndModifySelection",alt_up:"moveUpAndModifySelection",alt_down:"moveDownAndModifySelection",ctrl_a:"selectAll"};
SC.BASE_KEY_BINDINGS={escape:"cancel",backspace:"deleteBackward","delete":"deleteForward","return":"insertNewline",tab:"insertTab",left:"moveLeft",right:"moveRight",up:"moveUp",down:"moveDown",home:"moveToBeginningOfDocument",end:"moveToEndOfDocument",pagedown:"pageDown",pageup:"pageUp"};SC.CAPTURE_BACKSPACE_KEY=NO;SC.PANEL_ORDER_LAYER=4096;SC.PALETTE_ORDER_LAYER=8192;SC.POPUP_ORDER_LAYER=12288;
SC.RootResponder=SC.RootResponder.extend({platform:"desktop",focusedPane:function(){var a=this.get("orderedPanes");return a[a.length-1]}.property("orderedPanes"),orderedPanes:null,orderBefore:function(a,b){var c=this.get("focusedPane"),d=this.get("orderedPanes").without(a),e,f,g,h=a.get("orderLayer");if(b){e=d.length;f=d.indexOf(b);g=b.get("orderLayer");if(g<h){for(;b.get("orderLayer")<h&&++f<e;)b=d[f];if(f>=e)b=null}else if(g>h){for(;b.get("orderLayer")>h&&--f>=0;)b=d[f];b=f<0?d[0]:d[f+1]}}else{for(f=
d.length;--f>=0&&!b;){b=d[f];if(b.get("orderLayer")>h)b=null}b=f<0?d[0]:d[f+1]}if(b){f=d.indexOf(b);d.insertAt(f,a)}else d.push(a);this.set("orderedPanes",d);a=this.get("focusedPane");if(a!==c){c&&c.blurTo(a);a&&a.focusFrom(c)}return this},orderOut:function(a){var b=this.get("focusedPane"),c=this.get("keyPane");this.set("orderedPanes",this.get("orderedPanes").without(a));if(b===a){var d=this.get("focusedPane");b&&b.blurTo(d);d&&d.focusFrom(b);c===a&&this.makeKeyPane(d)}else c===a&&this.makeKeyPane(null);
return this},init:function(){arguments.callee.base.apply(this,arguments);this.orderedPanes=[]},setup:function(){this.listenFor("keydown keyup beforedeactivate mousedown mouseup click dblclick mouseout mouseover mousemove selectstart contextmenu".w(),document).listenFor("resize focus blur".w(),window);if(this.keypress)if(SC.CAPTURE_BACKSPACE_KEY&&SC.browser.mozilla){var a=this;document.onkeypress=function(b){b=SC.Event.normalizeEvent(b);return a.keypress.call(a,b)};SC.Event.add(window,"unload",this,
function(){document.onkeypress=null})}else SC.Event.add(document,"keypress",this,this.keypress);"drag selectstart".w().forEach(function(b){var c=this[b];if(c)if(SC.browser.msie){var d=this;document.body["on"+b]=function(){return c.call(d,SC.Event.normalizeEvent(event||window.event))};SC.Event.add(window,"unload",this,function(){document.body["on"+b]=null})}else SC.Event.add(document,b,this,c)},this);SC.Event.add(document,SC.browser.mozilla?"DOMMouseScroll":"mousewheel",this,this.mousewheel);this.set("currentWindowSize",
this.computeWindowSize());this.focus();arguments.callee.base.apply(this,arguments)},attemptKeyEquivalent:function(a){var b=null,c=a.commandCodes()[0];if(!c)return NO;var d=this.get("keyPane"),e=this.get("mainPane"),f=this.get("mainMenu");if(d)if((b=d.performKeyEquivalent(c,a))||d.get("isModal"))return b;if(!b&&e&&e!==d)if((b=e.performKeyEquivalent(c,a))||e.get("isModal"))return b;if(!b&&f)b=f.performKeyEquivalent(c,a);return b},currentWindowSize:null,computeWindowSize:function(){var a;if(window.innerHeight)a=
{width:window.innerWidth,height:window.innerHeight};else if(document.documentElement&&document.documentElement.clientHeight)a={width:document.documentElement.clientWidth,height:document.documentElement.clientHeight};else if(document.body)a={width:document.body.clientWidth,height:document.body.clientHeight};return a},resize:function(){this._resize();return YES},_resize:function(){var a=this.computeWindowSize(),b=this.get("currentWindowSize");this.set("currentWindowSize",a);if(!SC.rectsEqual(a,b))if(this.panes){SC.RunLoop.begin();
this.panes.invoke("windowSizeDidChange",b,a);SC.RunLoop.end()}},hasFocus:NO,focus:function(){if(!this.get("hasFocus")){SC.$("body").addClass("sc-focus").removeClass("sc-blur");SC.RunLoop.begin();this.set("hasFocus",YES);SC.RunLoop.end()}return YES},blur:function(){if(this.get("hasFocus")){SC.$("body").addClass("sc-blur").removeClass("sc-focus");SC.RunLoop.begin();this.set("hasFocus",NO);SC.RunLoop.end()}return YES},dragDidStart:function(a){this._drag=this._mouseDownView=a},_lastModifiers:null,_handleModifierChanges:function(a){var b;
b=this._lastModifiers=this._lastModifiers||{alt:false,ctrl:false,shift:false};var c=false;if(a.altKey!==b.alt){b.alt=a.altKey;c=true}if(a.ctrlKey!==b.ctrl){b.ctrl=a.ctrlKey;c=true}if(a.shiftKey!==b.shift){b.shift=a.shiftKey;c=true}a.modifiers=b;return c?this.sendEvent("flagsChanged",a)?!!a.hasCustomEventHandling:YES:YES},_isFunctionOrNonPrintableKey:function(a){return!!(a.altKey||a.ctrlKey||a.metaKey||a.charCode!==a.which&&SC.FUNCTION_KEYS[a.which])},_isModifierKey:function(a){return!!SC.MODIFIER_KEYS[a.charCode]},
keydown:function(a){if(SC.none(a))return YES;if(a.keyCode===229)return this._IMEInputON=YES;if(SC.browser.mozilla)if(SC.FUNCTION_KEYS[a.keyCode])return true;else if((a.ctrlKey||a.metaKey)&&SC.PRINTABLE_KEYS[a.keyCode])return true;var b=this._handleModifierChanges(a),c=a.target||a.srcElement;c=a.which===8&&!SC.allowsBackspaceToPreviousPage&&c===document.body;if(this._isModifierKey(a))return c?NO:b;b=YES;if(this._isFunctionOrNonPrintableKey(a)){b=this.sendEvent("keyDown",a);if(!b&&!a.hasCustomEventHandling)b=
!this.attemptKeyEquivalent(a);else if(b=!!a.hasCustomEventHandling)c=NO}return c?NO:b},keypress:function(a){var b;if(SC.browser.mozilla)if(SC.FUNCTION_KEYS[a.keyCode]){a.which=a.keyCode;b=this.sendEvent("keyDown",a);b=!b&&!a.hasCustomEventHandling?!this.attemptKeyEquivalent(a):!!a.hasCustomEventHandling;if(a.keyCode===8)if((a.target||a.srcElement)===document.body)b=b&&SC.allowsBackspaceToPreviousPage;return b}else if((a.ctrlKey||a.metaKey)&&SC.PRINTABLE_KEYS_CHARCODE[a.charCode]){a.keyCode=SC.PRINTABLE_KEYS_CHARCODE[a.charCode];
a.charCode=0;return this.sendEvent("keyDown",a)?!!a.hasCustomEventHandling:YES}if(a.charCode!==undefined&&a.charCode===0)return YES;return this.sendEvent("keyDown",a)?!!a.hasCustomEventHandling:YES},keyup:function(a){if(this._ffevt)this._ffevt=null;var b=this._handleModifierChanges(a);if(this._isModifierKey(a))return b;if(this._IMEInputON&&a.keyCode===13){a.isIMEInput=YES;this.sendEvent("keyDown",a);this._IMEInputON=NO}return this.sendEvent("keyUp",a)?!!a.hasCustomEventHandling:YES},beforedeactivate:function(a){if(a=
a.toElement)if((a=SC.$(a).view()[0])&&!a.get("acceptsKeyPane")&&!a.get("acceptsFirstResponder"))return NO;return YES},mousedown:function(a){try{if(SC.browser.mozilla){window.focus();this.focus()}this._clickCount+=1;if(!this._lastMouseUpAt||Date.now()-this._lastMouseUpAt>200)this._clickCount=1;else{var b=this._lastMouseDownX-a.clientX,c=this._lastMouseDownY-a.clientY;if(Math.sqrt(b*b+c*c)>8)this._clickCount=1}a.clickCount=this._clickCount;this._lastMouseDownX=a.clientX;this._lastMouseDownY=a.clientY;
var d,e=this.targetViewForEvent(a);if(e===undefined)return YES;if(e)d=e.getPath("pane.firstResponder");d&&d.kindOf(SC.InlineTextFieldView)&&d!==e&&d.resignFirstResponder();if((e=this._mouseDownView=this.sendEvent("mouseDown",a,e))&&e.respondsTo("mouseDragged"))this._mouseCanDrag=YES}catch(f){SC.Logger.warn("Exception during mousedown: %@".fmt(f));this._mouseDownView=null;this._mouseCanDrag=NO;throw f;}return e?!!a.hasCustomEventHandling:YES},mouseup:function(a){this.targetViewForEvent(a);try{if(this._drag){this._drag.tryToPerform("mouseUp",
a);this._drag=null}var b=null,c=this._mouseDownView,d=this.targetViewForEvent(a);this._lastMouseUpAt=Date.now();a.clickCount=this._clickCount;if(c){b=this.sendEvent("mouseUp",a,c);if(!b&&this._clickCount===2)b=this.sendEvent("doubleClick",a,c);b||(b=this.sendEvent("click",a,c))}if(!b){if(this._clickCount===2)b=this.sendEvent("doubleClick",a,d);b||(b=this.sendEvent("click",a,d))}this._mouseCanDrag=NO;this._mouseDownView=null}catch(e){this._drag=null;this._mouseCanDrag=NO;this._mouseDownView=null;throw e;
}return b?!!a.hasCustomEventHandling:YES},dblclick:function(a){if(SC.browser.isIE){this._clickCount=2;this.mouseup(a)}},mousewheel:function(a){try{var b=this.targetViewForEvent(a);if(b===undefined)return YES;var c=this.sendEvent("mouseWheel",a,b)}catch(d){throw d;}return c?!!a.hasCustomEventHandling:YES},_lastHovered:null,mousemove:function(a){if(SC.browser.msie)if(this._lastMoveX===a.clientX&&this._lastMoveY===a.clientY)return;this._lastMoveX=a.clientX;this._lastMoveY=a.clientY;SC.RunLoop.begin();
try{this.focus();if(this._drag)if(SC.browser.msie)this._lastMouseDownX!==a.clientX&&this._lastMouseDownY!==a.clientY&&this._drag.tryToPerform("mouseDragged",a);else this._drag.tryToPerform("mouseDragged",a);else{for(var b=this._lastHovered||[],c=[],d,e,f,g=this.targetViewForEvent(a);g&&g!==this;){b.indexOf(g)!==-1?g.tryToPerform("mouseMoved",a):g.tryToPerform("mouseEntered",a);c.push(g);g=g.get("nextResponder")}e=0;for(f=b.length;e<f;e++){g=b[e];(d=g.respondsTo("mouseExited"))&&c.indexOf(g)===-1&&
g.tryToPerform("mouseExited",a)}this._lastHovered=c;if(this._mouseDownView)if(SC.browser.msie)this._lastMouseDownX!==a.clientX&&this._lastMouseDownY!==a.clientY&&this._mouseDownView.tryToPerform("mouseDragged",a);else this._mouseDownView.tryToPerform("mouseDragged",a)}}catch(h){throw h;}SC.RunLoop.end()},_mouseCanDrag:YES,selectstart:function(a){var b=this.targetViewForEvent(a);a=this.sendEvent("selectStart",a,b);return b&&b.respondsTo("mouseDragged")?(a!==null?YES:NO)&&!this._mouseCanDrag:a!==null?
YES:NO},drag:function(){return false},contextmenu:function(a){var b=this.targetViewForEvent(a);return this.sendEvent("contextMenu",a,b)}});sc_require("core");
SC.UndoManager=SC.Object.extend({undoActionName:function(){return this.undoStack?this.undoStack.name:null}.property("undoStack"),redoActionName:function(){return this.redoStack?this.redoStack.name:null}.property("redoStack"),canUndo:function(){return this.undoStack!=null}.property("undoStack"),canRedo:function(){return this.redoStack!=null}.property("redoStack"),undo:function(){this._undoOrRedo("undoStack","isUndoing")},redo:function(){this._undoOrRedo("redoStack","isRedoing")},isUndoing:false,isRedoing:false,
groupingLevel:0,registerUndo:function(a,b){this.beginUndoGroup(b);this._activeGroup.actions.push(a);this.endUndoGroup(b)},beginUndoGroup:function(a){if(this._activeGroup)this.groupingLevel++;else{var b=this.isUndoing?"redoStack":"undoStack";this._activeGroup={name:a,actions:[],prev:this.get(b)};this.set(b,this._activeGroup);this.groupingLevel=1}},endUndoGroup:function(){this._activeGroup||raise("endUndoGroup() called outside group.");if(this.groupingLevel>1)this.groupingLevel--;else{this._activeGroup=
null;this.groupingLevel=0}this.propertyDidChange(this.isUndoing?"redoStack":"undoStack")},setActionName:function(a){this._activeGroup||raise("setActionName() called outside group.");this._activeGroup.name=a},_activeGroup:null,undoStack:null,redoStack:null,_undoOrRedo:function(a,b){if(this._activeGroup)return false;if(this.get(a)==null)return true;this.set(b,true);var c=this.get(a);this.set(a,c.prev);var d=c.actions.length>1;for(d&&this.beginUndoGroup(c.name);a=c.actions.pop();)a();d&&this.endUndoGroup(c.name);
this.set(b,false)}});
SC.CheckboxView=SC.ButtonView.extend(SC.StaticLayout,SC.Button,{classNames:["sc-checkbox-view"],tagName:"label",needsEllipsis:NO,routeTouch:NO,render:function(a,b){var c=this.get("value");c=c===SC.MIXED_MODE?"mixed":c===this.get("toggleOnValue")?"true":"false";if(b){this.get("isEnabled");var d=SC.guidFor(this);a.attr("role","checkbox");b=this._field_currentDisplayTitle=this.get("displayTitle");SC.browser.msie&&a.attr("for",d);a.push('<span class="button" ></span>');this.get("needsEllipsis")?a.push('<span class="label ellipsis">',
b,"</span>"):a.push('<span class="label">',b,"</span>");a.attr("name",d)}else{b=this.get("displayTitle");if(b!==this._field_currentDisplayTitle){this._field_currentDisplayTitle=b;this.$("span.label").text(b)}}a.attr("aria-checked",c)},acceptsFirstResponder:function(){return SC.SAFARI_FOCUS_BEHAVIOR?NO:this.get("isEnabled")}.property("isEnabled"),mouseDown:function(){if(!this.get("isEnabled"))return YES;this.set("isActive",YES);return this._field_isMouseDown=YES},mouseUp:function(){if(!this.get("isEnabled"))return YES;
if(this.get("value")===this.get("toggleOnValue")){this.$().attr("aria-checked","false");this.set("value",this.get("toggleOffValue"))}else{this.$().attr("aria-checked","true");this.set("value",this.get("toggleOnValue"))}this.set("isActive",NO);this._field_isMouseDown=NO;return YES}});SC.LIST_ITEM_ACTION_CANCEL="sc-list-item-cancel-action";SC.LIST_ITEM_ACTION_REFRESH="sc-list-item-cancel-refresh";SC.LIST_ITEM_ACTION_EJECT="sc-list-item-cancel-eject";
SC.ListItemView=SC.View.extend(SC.StaticLayout,SC.Control,{classNames:["sc-list-item-view"],content:null,hasContentIcon:NO,hasContentRightIcon:NO,hasContentBranch:NO,contentCheckboxKey:null,contentIconKey:null,contentRightIconKey:null,contentValueKey:null,escapeHTML:YES,contentUnreadCountKey:null,contentIsBranchKey:null,isEditing:NO,outlineIndent:16,outlineLevel:0,disclosureState:SC.LEAF_NODE,contentPropertyDidChange:function(){this.get("contentIsEditable")!==this.contentIsEditable()&&this.notifyPropertyChange("contentIsEditable");
this.displayDidChange()},contentIsEditable:function(){var a=this.get("content");return a&&(a.get?a.get("isEditable")!==NO:NO)}.property("content").cacheable(),render:function(a){var b=this.get("content"),c=this.displayDelegate,d=this.get("outlineLevel"),e=this.get("outlineIndent"),f,g=[];g.push(this.get("contentIndex")%2===0?"even":"odd");a.setClass("disabled",!this.get("isEnabled"));f=a.begin("div").addClass("sc-outline");d>=0&&e>0&&f.addStyle("left",e*(d+1));e=this.get("disclosureState");if(e!==
SC.LEAF_NODE){this.renderDisclosure(f,e);g.push("has-disclosure")}if(d=this.getDelegateProperty("contentCheckboxKey",c)){e=b?b.get?b.get(d):b[d]:NO;this.renderCheckbox(f,e);g.push("has-checkbox")}if(this.getDelegateProperty("hasContentIcon",c)){e=(d=this.getDelegateProperty("contentIconKey",c))&&b?b.get?b.get(d):b[d]:null;this.renderIcon(f,e);g.push("has-icon")}if((e=(d=this.getDelegateProperty("contentValueKey",c))&&b?b.get?b.get(d):b[d]:b)&&SC.typeOf(e)!==SC.T_STRING)e=e.toString();if(this.get("escapeHTML"))e=
SC.RenderContext.escapeHTML(e);this.renderLabel(f,e);if(this.getDelegateProperty("hasContentRightIcon",c)){e=(d=this.getDelegateProperty("contentRightIconKey",c))&&b?b.get?b.get(d):b[d]:null;this.renderRightIcon(f,e);g.push("has-right-icon")}e=(d=this.getDelegateProperty("contentUnreadCountKey",c))&&b?b.get?b.get(d):b[d]:null;if(!SC.none(e)&&e!==0){this.renderCount(f,e);d=["zero","one","two","three","four","five"];e=e.toString().length;var h=d.length;g.push("has-count "+(e<h?d[e]:d[h-1])+"-digit")}if(e=
(d=this.getDelegateProperty("listItemActionProperty",c))&&b?b.get?b.get(d):b[d]:null){this.renderAction(f,e);g.push("has-action")}if(this.getDelegateProperty("hasContentBranch",c)){e=(d=this.getDelegateProperty("contentIsBranchKey",c))&&b?b.get?b.get(d):b[d]:NO;this.renderBranch(f,e);g.push("has-branch")}a.addClass(g);f.end()},renderDisclosure:function(a,b){b=b===SC.BRANCH_OPEN?"open":"closed";var c=this._scli_disclosureHtml,d;if(!c)c=this.constructor.prototype._scli_disclosureHtml={};(d=c[b])||(d=
c[b]='<img src="'+SC.BLANK_IMAGE_URL+'" class="disclosure button '+b+'" />');a.push(d)},renderCheckbox:function(a,b){var c=b===SC.MIXED_STATE?"mixed":b?"sel":"nosel",d=this._scli_checkboxHtml,e=this.get("contentIsEditable")&&this.get("isEnabled"),f,g=[];e||(c=SC.keyFor("disabled",c));if(!d)d=this.constructor.prototype._scli_checkboxHtml={};f=d[c];if(!f){f=SC.RenderContext("div").attr("role","button").classNames(SC.clone(SC.CheckboxView.prototype.classNames));if(b===SC.MIXED_STATE)g.push("mixed");
else b&&g.push("sel");e||g.push("disabled");f.addClass(g);f.push('<span class="button"></span>');f=d[c]=f.join()}a.push(f)},renderIcon:function(a,b){var c=null,d=null,e=[];if(b&&SC.ImageView.valueIsUrl(b)){c=b;d=""}else{d=b;c=SC.BLANK_IMAGE_URL}e.push(d);e.push("icon");a.begin("img").addClass(e).attr("src",c).end()},renderLabel:function(a,b){a.push("<label>",b||"","</label>")},$label:function(){return this.$("label")},renderRightIcon:function(a,b){var c=null,d=null,e=[];if(b&&SC.ImageView.valueIsUrl(b)){c=
b;d=""}else{d=b;c=SC.BLANK_IMAGE_URL}e.push("right-icon");e.push(d);a.begin("img").addClass(e).attr("src",c).end()},renderCount:function(a,b){a.push('<span class="count"><span class="inner">',b.toString(),"</span></span>")},renderAction:function(a){a.push('<img src="',SC.BLANK_IMAGE_URL,'" class="action" />')},renderBranch:function(a,b){var c=[];c.push("branch");c.push(b?"branch-visible":"branch-hidden");a.begin("span").addClass(c).push("&nbsp;").end()},_isInsideElementWithClassName:function(a,b){var c=
this.get("layer");if(!c)return NO;b=SC.$(b.target);for(var d=NO;!d&&b.length>0&&b[0]!==c;){if(b.hasClass(a))d=YES;b=b.parent()}return d},_isInsideCheckbox:function(a){return this.getDelegateProperty("contentCheckboxKey",this.displayDelegate)&&this._isInsideElementWithClassName("sc-checkbox-view",a)},_isInsideDisclosure:function(a){if(this.get("disclosureState")===SC.LEAF_NODE)return NO;return this._isInsideElementWithClassName("disclosure",a)},_isInsideRightIcon:function(a){return this.getDelegateProperty("hasContentRightIcon",
this.displayDelegate)&&this._isInsideElementWithClassName("right-icon",a)},mouseDown:function(a){if(!this.get("contentIsEditable"))return NO;if(this._isInsideCheckbox(a)){this._addCheckboxActiveState();return this._isMouseInsideCheckbox=this._isMouseDownOnCheckbox=YES}else if(this._isInsideDisclosure(a)){this._addDisclosureActiveState();return this._isMouseInsideDisclosure=this._isMouseDownOnDisclosure=YES}else if(this._isInsideRightIcon(a)){this._addRightIconActiveState();return this._isMouseInsideRightIcon=
this._isMouseDownOnRightIcon=YES}return NO},mouseUp:function(a){var b=NO,c;if(this._isMouseDownOnCheckbox){if(this._isInsideCheckbox(a)){b=this.displayDelegate;a=this.getDelegateProperty("contentCheckboxKey",b);if((b=this.get("content"))&&b.get){c=b.get(a);c=c===SC.MIXED_STATE?YES:!c;b.set(a,c);this.displayDidChange()}}this._removeCheckboxActiveState();b=YES}else if(this._isMouseDownOnDisclosure){if(this._isInsideDisclosure(a)){a=this.get("disclosureState");b=this.get("contentIndex");c=!SC.none(b)?
SC.IndexSet.create(b):null;b=this.get("displayDelegate");if(a===SC.BRANCH_OPEN){c&&b&&b.collapse?b.collapse(c):this.set("disclosureState",SC.BRANCH_CLOSED);this.displayDidChange()}else if(a===SC.BRANCH_CLOSED){c&&b&&b.expand?b.expand(c):this.set("disclosureState",SC.BRANCH_OPEN);this.displayDidChange()}}this._removeDisclosureActiveState();b=YES}else if(this._isMouseDownOnRightIcon){this._removeRightIconActiveState();b=YES}this._isMouseInsideRightIcon=this._isMouseDownOnRightIcon=this._isMouseDownOnDisclosure=
this._isMouseInsideDisclosure=this._isMouseInsideCheckbox=this._isMouseDownOnCheckbox=NO;return b},mouseExited:function(){if(this._isMouseDownOnCheckbox){this._removeCheckboxActiveState();this._isMouseInsideCheckbox=NO}else if(this._isMouseDownOnDisclosure){this._removeDisclosureActiveState();this._isMouseInsideDisclosure=NO}else if(this._isMouseDownOnRightIcon){this._removeRightIconActiveState();this._isMouseInsideRightIcon=NO}return NO},mouseEntered:function(){if(this._isMouseDownOnCheckbox){this._addCheckboxActiveState();
this._isMouseInsideCheckbox=YES}else if(this._isMouseDownOnDisclosure){this._addDisclosureActiveState();this._isMouseInsideDisclosure=YES}else if(this._isMouseDownOnRightIcon){this._addRightIconActiveState();this._isMouseInsideRightIcon=YES}return NO},_addCheckboxActiveState:function(){var a=this.get("isEnabled");this.$(".sc-checkbox-view").setClass("active",a)},_removeCheckboxActiveState:function(){this.$(".sc-checkbox-view").removeClass("active")},_addDisclosureActiveState:function(){var a=this.get("isEnabled");
this.$("img.disclosure").setClass("active",a)},_removeDisclosureActiveState:function(){this.$("img.disclosure").removeClass("active")},_addRightIconActiveState:function(){this.$("img.right-icon").setClass("active",YES)},_removeRightIconActiveState:function(){this.$("img.right-icon").removeClass("active")},contentHitTest:function(a){if(!this.getDelegateProperty("contentValueKey",this.displayDelegate))return NO;var b=this.$label()[0];if(!b)return NO;a=a.target;for(var c=this.get("layer");a&&a!==c&&
a!==window;){if(a===b)return YES;a=a.parentNode}return NO},beginEditing:function(){if(this.get("isEditing"))return YES;return this._beginEditing(YES)},_beginEditing:function(a){var b=this.get("content"),c=this.getDelegateProperty("contentValueKey",this.get("displayDelegate")),d=this.get("parentView");d&&d.get("frame");var e=this.$label(),f,g,h,j;if(a&&this.scrollToVisible()){var k=this.get("owner"),l=this.get("contentIndex");this.invokeLast(function(){var m=k.itemViewForContentIndex(l);m&&m._beginEditing&&
m._beginEditing(NO)});return YES}if(!d||!e||e.get("length")===0)return NO;c=c&&b&&b.get?b.get(c):null;b=this.computeFrameWithParentFrame(null);d=SC.viewportOffset(e[0]);a=e.css("lineHeight");f=e.css("fontSize");g=(g=this.$().css("top"))?parseInt(g.substring(0,g.length-2),0):0;h=a;j=0;if(f&&h){f=f*1.5;if(f<h){e.css({lineHeight:"1.5"});j=(h-f)/2}else a=null}b.x=d.x;b.y=d.y+g+j;b.height=e[0].offsetHeight;b.width=e[0].offsetWidth;b=SC.InlineTextFieldView.beginEditing({frame:b,exampleElement:e,delegate:this,
value:c,multiline:NO,isCollection:YES});a&&e.css({lineHeight:a});return b},commitEditing:function(){if(!this.get("isEditing"))return YES;return SC.InlineTextFieldView.commitEditing()},discardEditing:function(){if(!this.get("isEditing"))return YES;return SC.InlineTextFieldView.discardEditing()},inlineEditorShouldBeginEditing:function(){return YES},inlineEditorWillBeginEditing:function(){this.set("isEditing",YES)},inlineEditorDidBeginEditing:function(){var a=this.$label();this._oldOpacity=a.css("opacity");
a.css("opacity",0)},inlineEditorShouldEndEditing:function(){return YES},inlineEditorDidEndEditing:function(a,b){this.set("isEditing",NO);a=this.get("content");var c=this.getDelegateProperty("contentValueKey",this.displayDelegate);c&&a&&a.set&&a.set(c,b);this.displayDidChange()}});sc_require("mixins/collection_view_delegate");sc_require("views/list_item");SC.DRAG_REORDER=16;SC.HORIZONTAL_ORIENTATION="horizontal";SC.VERTICAL_ORIENTATION="vertical";SC.BENCHMARK_RELOAD=NO;
SC.CollectionView=SC.View.extend(SC.CollectionViewDelegate,SC.CollectionContent,{classNames:["sc-collection-view"],ACTION_DELAY:200,content:null,contentBindingDefault:SC.Binding.multiple(),length:0,nowShowing:function(){return this.computeNowShowing()}.property("length","clippingFrame").cacheable(),selection:null,isSelectable:YES,isSelectableBindingDefault:SC.Binding.bool(),isEnabled:YES,isEnabledBindingDefault:SC.Binding.bool(),isEditable:YES,isEditableBindingDefault:SC.Binding.bool(),canReorderContent:NO,
canReorderContentBindingDefault:SC.Binding.bool(),canDeleteContent:NO,canDeleteContentBindingDefault:SC.Binding.bool(),canEditContent:NO,canEditContentBindingDefault:SC.Binding.bool(),isDropTarget:NO,useToggleSelection:NO,actOnSelect:NO,selectOnMouseDown:YES,exampleView:SC.ListItemView,contentExampleViewKey:null,groupExampleView:null,contentGroupExampleViewKey:null,action:null,target:null,contentValueKey:null,acceptsFirstResponder:NO,isActive:NO,calculatedHeight:0,calculatedWidth:0,computeLayout:function(){return null},
layoutForContentIndex:function(){return null},allContentIndexes:function(){return SC.IndexSet.create(0,this.get("length")).freeze()}.property("length").cacheable(),contentIndexesInRect:function(){return null},computeNowShowing:function(){var a=this.contentIndexesInRect(this.get("clippingFrame"));if(a){var b=this.get("length"),c=a.get("max");if(c>b)a=a.copy().remove(b,c-b).freeze()}else a=this.get("allContentIndexes");return a},showInsertionPoint:function(){},hideInsertionPoint:function(){},delegate:null,
selectionDelegate:function(){var a=this.get("delegate"),b=this.get("content");return this.delegateFor("isCollectionViewDelegate",a,b)}.property("delegate","content").cacheable(),contentDelegate:function(){var a=this.get("delegate"),b=this.get("content");return this.delegateFor("isCollectionContent",a,b)}.property("delegate","content").cacheable(),_contentGroupIndexes:function(){return this.get("contentDelegate").contentGroupIndexes(this,this.get("content"))}.property("contentDelegate","content").cacheable(),
contentRangeDidChange:function(a,b,c,d){!b&&c==="[]"?this.reload(d):this.contentPropertyDidChange(b,c,d)},contentPropertyDidChange:function(){},updateContentRangeObserver:function(){var a=this.get("nowShowing"),b=this._cv_contentRangeObserver,c=this.get("content");if(c)if(b)c.updateRangeObserver(b,a);else this._cv_contentRangeObserver=b=c.addRangeObserver(a,this,this.contentRangeDidChange,null)},removeContentRangeObserver:function(){var a=this.get("content"),b=this._cv_contentRangeObserver;if(b){a&&
a.removeRangeObserver(b);this._cv_contentRangeObserver=null}},contentLengthDidChange:function(){var a=this.get("content");this.set("length",a?a.get("length"):0)},_cv_contentDidChange:function(){var a=this.get("content"),b=this.contentLengthDidChange;if(a!==this._content){this.removeContentRangeObserver();this._content&&this._content.removeObserver("length",this,b);(this._content=a)&&a.addObserver("length",this,b);this.contentLengthDidChange();this.contentRangeDidChange(a,null,"[]",null)}}.observes("content"),
_invalidIndexes:NO,reload:function(a){var b=this._invalidIndexes;if(a&&b!==YES)if(b)b.add(a);else this._invalidIndexes=a.clone();else this._invalidIndexes=YES;this.get("isVisibleInWindow")&&this.invokeOnce(this.reloadIfNeeded);return this},reloadIfNeeded:function(){var a=this._invalidIndexes;if(!a||!this.get("isVisibleInWindow"))return this;this._invalidIndexes=NO;var b=this.get("content"),c,d,e,f=this.computeLayout(),g=SC.BENCHMARK_RELOAD,h=this.get("nowShowing"),j=this._sc_itemViews,k=this.get("containerView")||
this,l,m,n,o,r,u,q,s,w;if(a.isIndexSet&&a.contains(h))a=YES;if(this.willReload)this.willReload(a===YES?null:a);l=(l=this.get("exampleView"))?l.isReusableInCollections:NO;m=(c=this.get("exampleGroupView"))?c.isReusableInCollections:NO;if(a.isIndexSet){if(g)SC.Benchmark.start(g="%@#reloadIfNeeded (Partial)".fmt(this),YES);o=[];r=[];u=[];a.forEach(function(v){e=j?j[v]:null;if(h.contains(v))e&&e.parentView===k?r.push(v):u.push(v);else e&&e.parentView===k&&o.push(v)},this);c=0;for(d=o.length;c<d;++c){n=
o[c];e=j?j[n]:null;delete j[n];w=this.get("contentDelegate");if(s=(s=this.get("_contentGroupIndexes"))&&s.contains(n))s=w.contentIndexIsGroup(this,b,n);if(n=s?m:l){s=s?this._GROUP_VIEW_POOL:this._VIEW_POOL;s.push(e);e.destroyLayer()}k.removeChild(e)}c=0;for(d=r.length;c<d;++c){n=r[c];e=j?j[n]:null;b=this.itemViewForContentIndex(n,YES);e.destroyLayer();k.replaceChild(b,e)}c=0;for(d=u.length;c<d;++c){n=u[c];b=this.itemViewForContentIndex(n,YES);k.insertBefore(b,null)}}else{if(g)SC.Benchmark.start(g=
"%@#reloadIfNeeded (Full)".fmt(this),YES);if(j)j.length=0;if(q=k.get("childViews"))q=q.copy();k.beginPropertyChanges();k.destroyLayer().removeAllChildren();if(q){c=0;for(d=q.length;c<d;++c){b=q[c];if(n=(s=b.get("isGroupView"))?m:l){s=s?this._GROUP_VIEW_POOL:this._VIEW_POOL;s.push(b);b.destroyLayer()}}}q=[];h.forEach(function(v){q.push(this.itemViewForContentIndex(v,YES))},this);k.set("childViews",q);k.replaceLayer();k.endPropertyChanges()}g&&SC.Benchmark.end(g);f&&this.adjust(f);if(this.didReload)this.didReload(a===
YES?null:a);return this},displayProperties:"isFirstResponder isEnabled isActive".w(),render:function(a,b){b&&this._needsReload&&this.reloadIfNeeded();a.setClass("focus",this.get("isFirstResponder"));a.setClass("disabled",!this.get("isEnabled"));a.setClass("active",this.get("isActive"));return arguments.callee.base.apply(this,arguments)},_TMP_ATTRS:{},_COLLECTION_CLASS_NAMES:"sc-collection-item".w(),_GROUP_COLLECTION_CLASS_NAMES:"sc-collection-item sc-group-item".w(),_VIEW_POOL:null,_GROUP_VIEW_POOL:null,
itemViewForContentIndex:function(a,b){var c,d=this._sc_itemViews;if(d){if(!b&&(c=d[a]))return c}else d=this._sc_itemViews=[];var e=this.get("content");b=e.objectAt(a);var f=this.get("contentDelegate"),g=this.get("_contentGroupIndexes"),h=NO,j,k,l,m,n,o,r,u;if(h=g&&g.contains(a))h=f.contentIndexIsGroup(this,e,a);if(h){if((g=this.get("contentGroupExampleViewKey"))&&b)j=b.get(g);j||(j=this.get("groupExampleView")||this.get("exampleView"));k="_GROUP_VIEW_POOL"}else{if((g=this.get("contentExampleViewKey"))&&
b)j=b.get(g);j||(j=this.get("exampleView"));k="_VIEW_POOL"}m=this.get("containerView")||this;g=this.layerIdFor(a);n=f.contentIndexIsEnabled(this,e,a);o=f.contentIndexIsSelected(this,e,a);r=f.contentIndexOutlineLevel(this,e,a);f=f.contentIndexDisclosureState(this,e,a);u=this.isVisibleInWindow;e=this.layoutForContentIndex(a);if(j&&j.isReusableInCollections){(l=this[k])||(l=this[k]=[]);if(l.length>0){c=l.pop();(k=c.prepareForReuse)&&k.call(c);c.beginPropertyChanges();c.set("contentIndex",a);c.set("layerId",
g);c.set("isEnabled",n);c.set("isSelected",o);c.set("outlineLevel",r);c.set("disclosureState",f);c.set("isVisibleInWindow",u);c.set("parentView",m);SC.View.views[g]=c;e?c.set("layout",e):c.set("layout",j.prototype.layout);c.set("content",b);c.endPropertyChanges()}}if(!c){c=this._TMP_ATTRS;c.contentIndex=a;c.content=b;c.owner=c.displayDelegate=this;c.parentView=m;c.page=this.page;c.layerId=g;c.isEnabled=n;c.isSelected=o;c.outlineLevel=r;c.disclosureState=f;c.isGroupView=h;c.isVisibleInWindow=u;c.classNames=
h?this._GROUP_COLLECTION_CLASS_NAMES:this._COLLECTION_CLASS_NAMES;if(e)c.layout=e;else delete c.layout;c=this.createItemView(j,a,c)}return d[a]=c},itemViewForContentObject:function(a){return this.itemViewForContentIndex(this.get("content").indexOf(a))},_TMP_LAYERID:[],createItemView:function(a,b,c){return a.create(c)},layerIdFor:function(a){var b=this._TMP_LAYERID;b[0]=SC.guidFor(this);b[1]=a;return b.join("-")},contentIndexForLayerId:function(a){if(!a||!(a=a.toString()))return null;var b=this._baseLayerId;
if(!b)b=this._baseLayerId=SC.guidFor(this)+"-";if(a.length<=b.length||a.indexOf(b)!==0)return null;a=Number(a.slice(a.lastIndexOf("-")+1));return isNaN(a)?null:a},itemViewForEvent:function(a){if(!this.getPath("pane.rootResponder"))return null;SC.guidFor(this);a=a.target;for(var b=this.get("layer"),c=null,d;a&&a!==document&&a!==b;){if((d=a?SC.$(a).attr("id"):null)&&(c=this.contentIndexForLayerId(d))!==null)break;a=a.parentNode}if(c===null||a===b)return null;if(c>=this.get("length"))throw"layout for item view %@ was found when item view does not exist (%@)".fmt(d,
this);return this.itemViewForContentIndex(c)},expand:function(a){if(!a)return this;var b=this.get("contentDelegate"),c=this.get("content");a.forEach(function(d){b.contentIndexDisclosureState(this,c,d)===SC.BRANCH_CLOSED&&b.contentIndexExpand(this,c,d)},this);return this},collapse:function(a){if(!a)return this;var b=this.get("contentDelegate"),c=this.get("content");a.forEach(function(d){b.contentIndexDisclosureState(this,c,d)===SC.BRANCH_OPEN&&b.contentIndexCollapse(this,c,d)},this);return this},_cv_selectionDidChange:function(){var a=
this.get("selection"),b=this._cv_selection,c=this._cv_selectionContentDidChange;if(a!==b){b&&b.removeObserver("[]",this,c);a&&a.addObserver("[]",this,c);this._cv_selection=a;this._cv_selectionContentDidChange()}}.observes("selection"),_cv_selectionContentDidChange:function(){var a=this.get("selection"),b=this._cv_selindexes,c=this.get("content");this._cv_selindexes=a?a.frozenCopy():null;if(b)b=b.indexSetForSource(c);if(a)a=a.indexSetForSource(c);(a=a&&b?a.without(b).add(b.without(a)):a||b)&&a.get("length")>
0&&this.reloadSelectionIndexes(a)},_invalidSelection:NO,reloadSelectionIndexes:function(a){var b=this._invalidSelection;if(a&&b!==YES)if(b)b.add(a);else this._invalidSelection=a.copy();else this._invalidSelection=YES;this.get("isVisibleInWindow")&&this.invokeOnce(this.reloadSelectionIndexesIfNeeded);return this},reloadSelectionIndexesIfNeeded:function(){var a=this._invalidSelection;if(!a||!this.get("isVisibleInWindow"))return this;var b=this.get("nowShowing"),c=this._invalidIndexes,d=this.get("content"),
e=this.get("selection");this._invalidSelection=NO;if(c===YES||!b)return this;if(a===YES)a=b;if(c&&c.isIndexSet)a=a.without(c);a.forEach(function(f){if(b.contains(f)){var g=this.itemViewForContentIndex(f,NO);if(g)g.set("isSelected",e?e.contains(d,f):NO)}},this);return this},select:function(a,b){var c=this.get("content"),d=this.get("selectionDelegate"),e=this.get("_contentGroupIndexes"),f;if(!this.get("isSelectable"))return this;if(SC.typeOf(a)===SC.T_NUMBER)a=SC.IndexSet.create(a,1);if(a&&a.get("length")>
0){if(e&&e.get("length")>0)a=a.copy().remove(e);a=d.collectionViewShouldSelectIndexes(this,a,b);if(!a||a.get("length")===0)return this}else a=null;f=b&&(f=this.get("selection"))?f.copy():SC.SelectionSet.create();if(a&&a.get("length")>0)a.get("length")===1?f.addObject(c.objectAt(a.get("firstObject"))):f.add(c,a);(f=d.collectionViewSelectionForProposedSelection(this,f))||(f=SC.SelectionSet.create());this._selectionAnchor=null;this.set("selection",f.freeze());return this},deselect:function(a){var b=
this.get("selection"),c=this.get("content"),d=this.get("selectionDelegate");if(!this.get("isSelectable"))return this;if(!b||b.get("length")===0)return this;if(SC.typeOf(a)===SC.T_NUMBER)a=SC.IndexSet.create(a,1);a=d.collectionViewShouldDeselectIndexes(this,a);if(!a||a.get("length")===0)return this;b=b.copy().remove(c,a);(b=d.collectionViewSelectionForProposedSelection(this,b))||(b=SC.SelectionSet.create());this.set("selection",b.freeze());return this},_findNextSelectableItemFromIndex:function(a,b){var c=
this.get("length"),d=SC.IndexSet.create();this.get("content");var e=this.get("selectionDelegate"),f=this.get("_contentGroupIndexes"),g;if(!f&&e.collectionViewShouldSelectIndexes===this.collectionViewShouldSelectIndexes)return a;for(;a<c;){if(!f||!f.contains(a)){d.add(a);if((g=e.collectionViewShouldSelectIndexes(this,d))&&g.get("length")>=1)return a;d.remove(a)}a++}if(b===undefined)b=(a=this.get("selection"))?a.get("max"):-1;return b},_findPreviousSelectableItemFromIndex:function(a,b){var c=SC.IndexSet.create();
this.get("content");var d=this.get("selectionDelegate"),e=this.get("_contentGroupIndexes"),f;if(SC.none(a))a=-1;if(!e&&d.collectionViewShouldSelectIndexes===this.collectionViewShouldSelectIndexes)return a;for(;a>=0;){if(!e||!e.contains(a)){c.add(a);if((f=d.collectionViewShouldSelectIndexes(this,c))&&f.get("length")>=1)return a;c.remove(a)}a--}if(b===undefined)b=(a=this.get("selection"))?a.get("min"):-1;if(SC.none(b))b=-1;return b},selectPreviousItem:function(a,b){if(SC.none(b))b=1;if(SC.none(a))a=
false;var c=this.get("selection"),d=this.get("content");if(c)c=c.indexSetForSource(d);d=c?c.get("min"):-1;c=c?c.get("max")-1:-1;var e=this._selectionAnchor;if(SC.none(e))e=d;if(a){if(c>e)c-=b;else d=this._findPreviousSelectableItemFromIndex(d-b);if(SC.none(d)||d<0)d=0;if(c<d)c=d}else{d=this._findPreviousSelectableItemFromIndex(d-b);if(SC.none(d)||d<0)d=0;c=d;e=null}a=d;c=SC.IndexSet.create(d,c+1-d);this.scrollToContentIndex(a);this.select(c);this._selectionAnchor=e;return this},selectNextItem:function(a,
b){if(SC.none(b))b=1;if(SC.none(a))a=false;var c=this.get("selection"),d=this.get("content");if(c)c=c.indexSetForSource(d);d=c?c.get("min"):-1;c=c?c.get("max")-1:-1;var e=this._selectionAnchor,f=this.get("length");if(SC.none(e))e=d;if(a){if(d<e)d+=b;else c=this._findNextSelectableItemFromIndex(c+b,c);if(c>=f)c=f-1;if(d>c)d=c}else{c=this._findNextSelectableItemFromIndex(c+b,c);if(c>=f)c=f-1;d=c;e=null}a=c;c=SC.IndexSet.create(d,c-d+1);this.scrollToContentIndex(a);this.select(c);this._selectionAnchor=
e;return this},deleteSelection:function(){if(!this.get("canDeleteContent"))return NO;var a=this.get("selection"),b=this.get("content"),c=this.get("selectionDelegate");a=a&&b?a.indexSetForSource(b):null;if(!b||!a||a.get("length")===0)return NO;a=c.collectionViewShouldDeleteIndexes(this,a);if(!a||a.get("length")===0)return NO;c.collectionViewDeleteContent(this,this.get("content"),a);return YES},scrollToContentIndex:function(a){(a=this.itemViewForContentIndex(a))&&this.scrollToItemView(a);return this},
scrollToItemView:function(a){a&&a.scrollToVisible();return this},keyDown:function(a){a=this.interpretKeyEvents(a);return!a?NO:a},keyUp:function(){return true},insertText:function(a,b){if(a===" "){(a=this.get("selection"))&&a.get("length")>0&&this.invokeLater(this._cv_action,0,null,b);return YES}else return NO},selectAll:function(){var a=this.get("content");this.select(a?SC.IndexSet.create(0,a.get("length")):null,NO);return YES},deleteBackward:function(){return this.deleteSelection()},deleteForward:function(){return this.deleteSelection()},
moveDown:function(a,b){this.selectNextItem(false,this.get("itemsPerRow")||1);this._cv_performSelectAction(null,b,this.ACTION_DELAY);return true},moveUp:function(a,b){this.selectPreviousItem(false,this.get("itemsPerRow")||1);this._cv_performSelectAction(null,b,this.ACTION_DELAY);return true},moveLeft:function(a,b){if((this.get("itemsPerRow")||1)>1){this.selectPreviousItem(false,1);this._cv_performSelectAction(null,b,this.ACTION_DELAY)}else{b=this.get("selection");a=this.get("content");var c=b?b.indexSetForSource(a):
null;if(c){b=undefined;var d=false,e=undefined;if(c.get("length")===1){e=c.get("firstObject");b=this.get("contentDelegate");if(b.contentIndexDisclosureState(this,a,e)!==SC.BRANCH_OPEN)d=true}if(d){c=b.contentIndexOutlineLevel(this,a,e)-1;if(c>=0){for(d=-1;d<0;){var f=this._findPreviousSelectableItemFromIndex(e-1);if(f<0)return false;e=f;if(b.contentIndexOutlineLevel(this,a,e)===c)d=f}d!==-1&&this.select(e)}}else this.collapse(c)}}return true},moveRight:function(a,b){if((this.get("itemsPerRow")||1)>
1){this.selectNextItem(false,1);this._cv_performSelectAction(null,b,this.ACTION_DELAY)}else{a=this.get("selection");b=this.get("content");(a=a?a.indexSetForSource(b):null)&&this.expand(a)}return true},moveDownAndModifySelection:function(a,b){this.selectNextItem(true,this.get("itemsPerRow")||1);this._cv_performSelectAction(null,b,this.ACTION_DELAY);return true},moveUpAndModifySelection:function(a,b){this.selectPreviousItem(true,this.get("itemsPerRow")||1);this._cv_performSelectAction(null,b,this.ACTION_DELAY);
return true},moveLeftAndModifySelection:function(a,b){if((this.get("itemsPerRow")||1)>1){this.selectPreviousItem(true,1);this._cv_performSelectAction(null,b,this.ACTION_DELAY)}return true},moveRightAndModifySelection:function(a,b){if((this.get("itemsPerRow")||1)>1){this.selectNextItem(true,1);this._cv_performSelectAction(null,b,this.ACTION_DELAY)}return true},insertNewline:function(){var a=this.get("isEditable")&&this.get("canEditContent"),b,c,d,e;if(a){b=this.get("selection");c=this.get("content");
if(b&&b.get("length")===1){d=(a=b.indexSetForSource(c))?a.get("min"):-1;a=d>=0}}if(a)a=(e=this.itemViewForContentIndex(d))&&SC.typeOf(e.beginEditing)===SC.T_FUNCTION;if(a){this.scrollToContentIndex(d);e=this.itemViewForContentIndex(d);e.beginEditing()}else this.invokeLater(this._cv_action,0,e,null);return YES},mouseDown:function(a){if(this.get("useToggleSelection"))return true;var b=this.itemViewForEvent(a),c=this.get("content"),d=b?b.get("contentIndex"):-1,e;e=this.mouseDownInfo={event:a,itemView:b,
contentIndex:d,at:Date.now()};this.becomeFirstResponder();if(!b){this.get("allowDeselectAll")&&this.select(null,false);return YES}b=this.get("selection");var f;if(b)b=b.indexSetForSource(c);c=b?b.contains(d):NO;if((e.modifierKeyPressed=f=a.ctrlKey||a.metaKey)&&c)e.shouldDeselect=d>=0;else if(a.shiftKey&&b&&b.get("length")>0){b=this._findSelectionExtendedByShift(b,d);a=this._selectionAnchor;this.select(b);this._selectionAnchor=a}else if(!f&&c)e.shouldReselect=d>=0;else if(this.get("selectOnMouseDown"))this.select(d,
f);else e.shouldSelect=d>=0;e.previousContentIndex=d;return YES},mouseUp:function(a){var b=this.itemViewForEvent(a),c=this.mouseDownInfo,d,e;if(this.get("useToggleSelection")){if(!b)return;c=this.get("selection");d=b?b.get("contentIndex"):-1;(c=c&&c.include(d))?this.deselect(d):this.select(d,YES)}else if(c){d=c.contentIndex;b&&b.get("contentIndex");c.shouldSelect&&this.select(d,c.modifierKeyPressed);c.shouldDeselect&&this.deselect(d);if(c.shouldReselect){if(c=this.get("isEditable")&&this.get("canEditContent"))c=
(c=this.get("selection"))&&c.get("length")===1;if(c)c=(c=(e=this.itemViewForContentIndex(d))&&(!e.contentHitTest||e.contentHitTest(a)))&&e.beginEditing?e.beginEditing():NO;if(!c){this._cv_reselectTimer&&this._cv_reselectTimer.invalidate();this._cv_reselectTimer=this.invokeLater(this.select,300,d,false)}}this._cleanupMouseDown()}this._cv_performSelectAction(b,a,0,a.clickCount);return NO},_cleanupMouseDown:function(){var a=this.mouseDownInfo,b;if(a)for(b in a)a.hasOwnProperty(b)&&delete a[b];this.mouseDownInfo=
null},mouseMoved:function(a){var b=this.itemViewForEvent(a),c=this._lastHoveredItem;if(b!==c){c&&c.mouseOut&&c.mouseOut(a);b&&b.mouseOver&&b.mouseOver(a)}(this._lastHoveredItem=b)&&b.mouseMoved&&b.mouseMoved(a);return YES},mouseOut:function(a){var b=this._lastHoveredItem;this._lastHoveredItem=null;b&&b.mouseOut&&b.mouseOut(a);return YES},touchStart:function(a){if(this.get("useToggleSelection"))return true;a=this.itemViewForEvent(a);this.get("content");a=a?a.get("contentIndex"):-1;this.becomeFirstResponder();
this.select(a,NO);return SC.MIXED_STATE},touchDragged:function(){this.select(null,NO);return SC.MIXED_STATE},touchCancelled:function(){this.select(null,NO)},_findSelectionExtendedByShift:function(a,b){if(!a||a.get("length")===0)return SC.IndexSet.create(b);this.get("content").get("length");var c=a.get("min");a=a.get("max")-1;var d=this._selectionAnchor;if(SC.none(d))d=-1;if(b<c){c=b;if(d<0)this._selectionAnchor=a}else if(b>a){a=b;if(d<0)this._selectionAnchor=c}else if(b>=c&&b<=a){if(d<0)this._selectionAnchor=
d=c;if(b===d)c=a=b;else if(b>d){c=d;a=b}else if(b<d){c=b;a=d}}return SC.IndexSet.create(c,a-c+1)},reorderDataType:function(){return"SC.CollectionView.Reorder."+SC.guidFor(this)}.property().cacheable(),dragContent:null,proposedInsertionIndex:null,proposedDropOperation:null,mouseDragged:function(){var a=this.get("selectionDelegate"),b=this.get("content"),c=this.get("selection"),d=this.mouseDownInfo,e=this.get("_contentGroupIndexes");if(!d||d.contentIndex<0)return YES;if(Date.now()-d.at<123)return YES;
if(a.collectionViewShouldBeginDrag(this)){if((c=this.get("selectOnMouseDown")?c?c.indexSetForSource(b):null:SC.IndexSet.create(d.contentIndex))&&e&&e.get("length")>0){c=c.copy().remove(e);if(c.get("length")===0)c=null;else c.freeze()}if(c)c=c.frozenCopy();else return YES;c={content:b,indexes:c};this.set("dragContent",c);if((b=this.get("dragDataTypes"))&&b.get("length")>0){(b=a.collectionViewDragViewFor(this,c.indexes))||(b=this._cv_dragViewFor(c.indexes));b.createLayer();SC.Drag.start({event:d.event,
source:this,dragView:b,ghost:NO,ghostActsLikeCursor:a.ghostActsLikeCursor,slideBack:YES,dataSource:this});this._cleanupMouseDown();this._lastInsertionIndex=null}else this.set("dragContent",null);return YES}},_cv_dragViewFor:function(a){a=this.get("nowShowing").without(a);a=this.get("nowShowing").without(a);var b=this.get("layer").cloneNode(false),c=SC.View.create({layer:b,parentView:this});SC.$(b).css("backgroundColor","transparent").css("border","none").css("top",0).css("left",0);a.forEach(function(d){d=
this.itemViewForContentIndex(d);var e,f;if(d){e=d.get("isSelected");d.set("isSelected",NO);d.updateLayerIfNeeded();if(f=d.get("layer"))f=f.cloneNode(true);d.set("isSelected",e);d.updateLayerIfNeeded()}f&&b.appendChild(f)},this);b=null;return c},dragDataTypes:function(){var a=this.get("selectionDelegate").collectionViewDragDataTypes(this),b;if(this.get("canReorderContent")){a=a?a.copy():[];b=this.get("reorderDataType");a.indexOf(b)<0&&a.push(b)}return a?a:[]}.property(),dragDataForType:function(a,
b){if(this.get("canReorderContent"))if(b===this.get("reorderDataType"))return this.get("dragContent");return this.get("selectionDelegate").collectionViewDragDataForType(this,a,b)},computeDragOperations:function(a){var b=SC.DRAG_NONE,c=this.get("selectionDelegate");if(this.get("canReorderContent"))if(a.get("dataTypes").indexOf(this.get("reorderDataType"))>=0)b=SC.DRAG_REORDER;b=c.collectionViewComputeDragOperations(this,a,b);if(b&SC.DRAG_REORDER)b=SC.DRAG_MOVE;return b},_computeDropOperationState:function(a,
b,c){var d=this.convertFrameFromView(a.get("location"),null);b=SC.DROP_BEFORE;var e=this.get("selectionDelegate"),f=this.get("canReorderContent"),g,h,j=this.insertionIndexForLocation(d,SC.DROP_ON);if(SC.typeOf(j)===SC.T_ARRAY){b=j[1];j=j[0]}if(b===SC.DROP_ON){this.set("proposedInsertionIndex",j);this.set("proposedDropOperation",b);g=e.collectionViewValidateDragOperation(this,a,c,j,b);j=this.get("proposedInsertionIndex");b=this.get("proposedDropOperation");this._dropInsertionIndex=this._dropOperation=
null;if(g!==SC.DRAG_NONE)return[j,b,g];else{b=SC.DROP_BEFORE;j=this.insertionIndexForLocation(d,SC.DROP_BEFORE);if(SC.typeOf(j)===SC.T_ARRAY){b=j[1];j=j[0]}}}if(j>=0&&f&&b!==SC.DROP_ON)if(d=a.dataForType(this.get("reorderDataType"))){f=this.get("content");if(b===SC.DROP_BEFORE){g=d.indexes.contains(j-1);h=d.indexes.contains(j)}else{g=d.indexes.contains(j);h=d.indexes.contains(j-1)}if(g&&h)if(SC.none(this._lastInsertionIndex))if(b===SC.DROP_BEFORE)for(;j>=0&&d.indexes.contains(j);)j--;else for(f=f?
f.get("length"):0;j<f&&d.indexes.contains(j);)j++;else j=this._lastInsertionIndex;if(j>=0)c=SC.DRAG_REORDER}this.set("proposedInsertionIndex",j);this.set("proposedDropOperation",b);c=e.collectionViewValidateDragOperation(this,a,c,j,b);j=this.get("proposedInsertionIndex");b=this.get("proposedDropOperation");this._dropInsertionIndex=this._dropOperation=null;return[j,b,c]},dragUpdated:function(a,b){var c=a.get("allowedDragOperations");c=this._computeDropOperationState(a,b,c);a=c[0];b=c[1];c=c[2];if(c!==
SC.DRAG_NONE){if(this._lastInsertionIndex!==a||this._lastDropOperation!==b)this.showInsertionPoint(this.itemViewForContentIndex(a),b);this._lastInsertionIndex=a;this._lastDropOperation=b}else{this.hideInsertionPoint();this._lastInsertionIndex=this._lastDropOperation=null}return c&SC.DRAG_REORDER?SC.DRAG_MOVE:c},dragExited:function(){this.hideInsertionPoint();this._lastInsertionIndex=this._lastDropOperation=null},acceptDragOperation:function(){return YES},performDragOperation:function(a,b){var c=this._computeDropOperationState(a,
null,b),d=c[0],e=c[1];c=c[2];var f=this.get("selectionDelegate"),g,h,j;if(c&SC.DRAG_REORDER)b=b&SC.DRAG_MOVE?SC.DRAG_REORDER:SC.DRAG_NONE;else b&=c;if(b===SC.DRAG_NONE)return b;if(f.collectionViewPerformDragOperation(this,a,b,d,e)===SC.DRAG_NONE&&b&SC.DRAG_REORDER){a=a.dataForType(this.get("reorderDataType"));if(!a)return SC.DRAG_NONE;h=this.get("content");b=a.indexes;if(b.get("length")===1)if((e===SC.DROP_BEFORE||e===SC.DROP_AFTER)&&b.get("min")===d)return SC.DRAG_MOVE;h.beginPropertyChanges();g=
[];j=0;a.indexes.forEach(function(k){g.push(h.objectAt(k-j));h.removeAt(k-j);j++;k<d&&d--},this);e===SC.DROP_AFTER&&d++;h.replace(d,0,g,e);this.select(SC.IndexSet.create(d,g.length));h.endPropertyChanges();b=SC.DRAG_MOVE}return b},collectionViewShouldBeginDrag:function(){return this.get("canReorderContent")},insertionIndexForLocation:function(){return-1},_cv_isVisibleInWindowDidChange:function(){if(this.get("isVisibleInWindow")){this._invalidIndexes&&this.invokeOnce(this.reloadIfNeeded);this._invalidSelection&&
this.invokeOnce(this.reloadSelectionIndexesIfNeeded)}}.observes("isVisibleInWindow"),collectionViewShouldSelectItem:function(){return this.get("isSelectable")},_TMP_DIFF1:SC.IndexSet.create(),_TMP_DIFF2:SC.IndexSet.create(),_cv_nowShowingDidChange:function(){var a=this.get("nowShowing"),b=this._sccv_lastNowShowing,c,d,e;if(b!==a)if(b&&a){d=this._TMP_DIFF1.add(b).remove(a);e=this._TMP_DIFF2.add(a).remove(b);c=d.add(e)}else c=b||a;if(c&&c.get("length")>0){this._sccv_lastNowShowing=a?a.frozenCopy():
null;this.updateContentRangeObserver();this.reload(c)}d&&d.clear();e&&e.clear()}.observes("nowShowing"),init:function(){arguments.callee.base.apply(this,arguments);this.get("canReorderContent")&&this._cv_canReorderContentDidChange();this._sccv_lastNowShowing=this.get("nowShowing").clone();this.content&&this._cv_contentDidChange();this.selection&&this._cv_selectionDidChange()},_cv_canReorderContentDidChange:function(){if(this.get("canReorderContent")){this.get("isDropTarget")||this.set("isDropTarget",
YES);SC.Drag.addDropTarget(this)}}.observes("canReorderContent"),_cv_performSelectAction:function(a,b,c,d){if(c===undefined)c=0;if(d===undefined)d=1;if(d>1||this.get("actOnSelect")){this._cv_reselectTimer&&this._cv_reselectTimer.invalidate();d=(d=this.get("selection"))?d.toArray():[];this._cv_actionTimer&&this._cv_actionTimer.invalidate();this._cv_actionTimer=this.invokeLater(this._cv_action,c,a,b,d)}},_cv_action:function(a,b,c){var d=this.get("action"),e=this.get("target")||null;this._cv_actionTimer=
null;if(d){if(SC.typeOf(d)===SC.T_FUNCTION)return this.action(a,b);(a=this.get("pane"))&&a.rootResponder.sendAction(d,e,this,a,c)}else if(a)if(SC.typeOf(a._action)==SC.T_FUNCTION)return a._action(b);else if(SC.typeOf(a.action)==SC.T_FUNCTION)return a.action(b)}});
SC.DisclosureView=SC.ButtonView.extend({classNames:["sc-disclosure-view"],theme:"disclosure",buttonBehavior:SC.TOGGLE_BEHAVIOR,toggleOnValue:YES,toggleOffValue:NO,valueBindingDefault:SC.Binding.bool(),render:function(a,b){var c=this.get("displayTitle");if(b){a.push('<img src="',SC.BLANK_IMAGE_URL,'" class="button" alt="" />');this.get("needsEllipsis")?a.push('<span class="ellipsis sc-button-label">',c,"</span>"):a.push('<span class="sc-button-label">',c,"</span>")}else this.$("label").text(c)},keyDown:function(a){if(a.which===
37||a.which===38){this.set("value",this.get("toggleOffValue"));return YES}if(a.which===39||a.which===40){this.set("value",this.get("toggleOnValue"));return YES}arguments.callee.base.apply(this,arguments)}});sc_require("views/collection");sc_require("mixins/collection_row_delegate");
SC.ListView=SC.CollectionView.extend(SC.CollectionRowDelegate,{classNames:["sc-list-view"],acceptsFirstResponder:YES,showAlternatingRows:NO,render:function(a){a.setClass("alternating",this.get("showAlternatingRows"));return arguments.callee.base.apply(this,arguments)},rowDelegate:function(){var a=this.delegate,b=this.get("content");return this.delegateFor("isCollectionRowDelegate",a,b)}.property("delegate","content").cacheable(),_sclv_rowDelegateDidChange:function(){var a=this._sclv_rowDelegate,b=
this.get("rowDelegate"),c=this._sclv_rowHeightDidChange,d=this._sclv_customRowHeightIndexesDidChange;if(a===b)return this;this._sclv_rowDelegate=b;if(a){a.removeObserver("rowHeight",this,c);a.removeObserver("customRowHeightIndexes",this,d)}if(!b)throw"Internal Inconsistancy: ListView must always have CollectionRowDelegate";b.addObserver("rowHeight",this,c);b.addObserver("customRowHeightIndexes",this,d);this._sclv_rowHeightDidChange()._sclv_customRowHeightIndexesDidChange();return this}.observes("rowDelegate"),
_sclv_rowHeightDidChange:function(){var a=this.get("rowDelegate").get("rowHeight");if(a===this._sclv_rowHeight)return this;this._sclv_rowHeight=a;this.rowHeightDidChangeForIndexes(SC.IndexSet.create(0,this.get("length")));return this},_sclv_customRowHeightIndexesDidChange:function(){var a=this.get("rowDelegate").get("customRowHeightIndexes"),b=this._sclv_customRowHeightIndexes,c=this._sclv_customRowHeightIndexesContentDidChange;if(a===b||b&&b.isEqual(a))return this;b&&this._sclv_isObservingCustomRowHeightIndexes&&
b.removeObserver("[]",this,c);if(this._sclv_isObservingCustomRowHeightIndexes=a&&!a.get("isFrozen"))a.addObserver("[]",this,c);this._sclv_customRowHeightIndexesContentDidChange();return this},_sclv_customRowHeightIndexesContentDidChange:function(){var a=this.get("rowDelegate").get("customRowHeightIndexes"),b=this._sclv_customRowHeightIndexes;b=a&&b?a.copy().add(b):a||b;this._sclv_customRowHeightIndexes=a?a.frozenCopy():null;this.rowHeightDidChangeForIndexes(b);return this},rowOffsetForContentIndex:function(a){if(a===
0)return 0;var b=this.get("rowDelegate"),c=b.get("rowHeight"),d,e,f,g,h,j;e=a*c;if(d=this.get("rowSpacing"))e+=a*d;if(b.customRowHeightIndexes&&(f=b.get("customRowHeightIndexes"))){g=this._sclv_offsetCache;if(!g){g=this._sclv_offsetCache=[];h=j=0;f.forEach(function(k){h+=this.rowHeightForContentIndex(k)-c;g[k+1]=h;j=k},this);this._sclv_max=j+1}h=g[a];if(h===undefined){h=g[a]=g[a-1];if(h===undefined){j=this._sclv_max;if(a<j)j=f.indexBefore(a)+1;h=g[a]=g[j]||0}}e+=h}return e},rowHeightForContentIndex:function(a){var b=
this.get("rowDelegate"),c,d,e;if(b.customRowHeightIndexes&&(e=b.get("customRowHeightIndexes"))){c=this._sclv_heightCache;if(!c){c=this._sclv_heightCache=[];d=this.get("content");e.forEach(function(f){c[f]=b.contentIndexRowHeight(this,d,f)},this)}a=c[a];if(a===undefined)a=b.get("rowHeight")}else a=b.get("rowHeight");return a},rowHeightDidChangeForIndexes:function(a){var b=this.get("length");this._sclv_heightCache=this._sclv_offsetCache=null;if(a&&a.isIndexSet)a=a.get("min");this.reload(SC.IndexSet.create(a,
b-a));return this},computeLayout:function(){var a=this._sclv_layout;if(!a)a=this._sclv_layout={};a.minHeight=this.rowOffsetForContentIndex(this.get("length"))+4;this.set("calculatedHeight",a.minHeight);return a},layoutForContentIndex:function(a){return{top:this.rowOffsetForContentIndex(a),height:this.rowHeightForContentIndex(a),left:0,right:0}},contentIndexesInRect:function(a){var b=this.get("rowDelegate").get("rowHeight"),c=SC.minY(a),d=SC.maxY(a),e=a.height||0;a=this.get("length");var f,g;g=(c-
c%b)/b;for(f=this.rowOffsetForContentIndex(g);g>0&&f>=c;){g--;f-=this.rowHeightForContentIndex(g)}for(f+=this.rowHeightForContentIndex(g);g<a&&f<c;){f+=this.rowHeightForContentIndex(g);g++}if(g<0)g=0;if(g>=a)g=a;b=g+(e-e%b)/b;if(b>a)b=a;for(f=this.rowOffsetForContentIndex(b);b>=g&&f>=d;){b--;f-=this.rowHeightForContentIndex(b)}for(f+=this.rowHeightForContentIndex(b);b<a&&f<=d;){f+=this.rowHeightForContentIndex(b);b++}b++;if(b<g)b=g;if(b>a)b=a;return SC.IndexSet.create(g,b-g)},insertionPointView:SC.View.extend({classNames:"sc-list-insertion-point",
render:function(a,b){b&&a.push('<div class="anchor"></div>')}}),showInsertionPoint:function(a,b){var c=this._insertionPointView;if(!c)c=this._insertionPointView=this.get("insertionPointView").create();var d=a.get("contentIndex"),e=this.get("length"),f=SC.clone(a.get("layout")),g=a.get("outlineLevel"),h=a.get("outlineIndent")||0;if(d>=e&&d>0){d=this.itemViewForContentIndex(e-1);if(d.get("isGroupView")){g=1;h=d.get("outlineIndent")}}if(SC.none(g))g=-1;if(b&SC.DROP_ON){this.hideInsertionPoint();a.set("isSelected",
YES);this._lastDropOnView=a}else{if(this._lastDropOnView){this._lastDropOnView.set("isSelected",NO);this._lastDropOnView=null}if(b&SC.DROP_AFTER)f.top+=f.height;f.height=2;f.right=0;f.left=(g+1)*h+12;delete f.width;c.set("layout",f);this.appendChild(c)}},hideInsertionPoint:function(){if(this._lastDropOnView){this._lastDropOnView.set("isSelected",NO);this._lastDropOnView=null}var a=this._insertionPointView;a&&a.removeFromParent().destroy();this._insertionPointView=null},insertionIndexForLocation:function(a,
b){var c=this.contentIndexesInRect(a).get("min"),d=this.get("length"),e,f,g;if(SC.none(c)||c<0)if(d===0||a.y<=this.rowOffsetForContentIndex(0))c=0;else if(a.y>=this.rowOffsetForContentIndex(d))c=d;e=this.rowOffsetForContentIndex(c);f=e+this.rowHeightForContentIndex(c);if(b==SC.DROP_ON){g=this.get("isEditable")?Math.min(Math.floor((f-e)*0.2),5):0;if(a.y>=e+g||a.y<=f+g)return[c,SC.DROP_ON]}c<d&&a.y>=f-10&&c++;if(c>0){f=((g=this.itemViewForContentIndex(c-1))?g.get("outlineIndent"):0)||0;e=g?g.get("outlineLevel"):
0;if(c<d){a=(g=this.itemViewForContentIndex(c))?g.get("outlineLevel"):0;g=(g?g.get("outlineIndent"):0)||0;g*=a}else{a=g.get("isGroupView")?1:0;g=f*a}f*=e;if(a!==e&&g!==f)if(f>g){c--;b=SC.DROP_AFTER}}if(b===SC.DROP_BEFORE){g=c<d?this.itemViewForContentIndex(c):null;if(!g||g.get("isGroupView"))if(c>0){g=this.itemViewForContentIndex(c-1);if(!g.get("isGroupView")||g.get("disclosureState")===SC.BRANCH_OPEN){c-=1;b=SC.DROP_AFTER}else c=-1}else c=-1;if(c<0)b=SC.DRAG_NONE}return[c,b]},mouseWheel:function(){var a=
SC.InlineTextFieldView.editor;a&&a.get("isEditing")&&a.get("delegate").get("displayDelegate")===this&&SC.InlineTextFieldView.commitEditing();return NO},init:function(){arguments.callee.base.apply(this,arguments);this._sclv_rowDelegateDidChange()}});sc_require("views/list");
SC.GridView=SC.ListView.extend({classNames:["sc-grid-view"],layout:{left:0,right:0,top:0,bottom:0},rowHeight:48,columnWidth:64,exampleView:SC.LabelView,insertionOrientation:SC.HORIZONTAL_ORIENTATION,itemsPerRow:function(){var a=this.get("frame"),b=this.get("columnWidth")||0;return b<=0?1:Math.floor(a.width/b)}.property("clippingFrame","columnWidth").cacheable(),contentIndexesInRect:function(a){var b=this.get("rowHeight")||48,c=this.get("itemsPerRow"),d=Math.floor(SC.minY(a)/b)*c;a=Math.ceil(SC.maxY(a)/
b)*c;return SC.IndexSet.create(d,a-d)},layoutForContentIndex:function(a){var b=this.get("rowHeight")||48,c=this.get("clippingFrame").width,d=this.get("itemsPerRow");c=Math.floor(c/d);var e=Math.floor(a/d);return{left:(a-d*e)*c,top:e*b,height:b,width:c}},computeLayout:function(){var a=this.get("content"),b=a?a.get("length"):0;a=this.get("rowHeight")||48;var c=this.get("itemsPerRow");b=Math.ceil(b/c);c=this._cachedLayoutHash;if(!c)c=this._cachedLayoutHash={};c.minHeight=b*a;this.calculatedHeight=c.minHeight;
return c},insertionPointClass:SC.View.extend({classNames:["grid-insertion-point"],render:function(a,b){b&&a.push('<span class="anchor"></span>')}}),showInsertionPoint:function(a,b){if(a)if(b===SC.DROP_ON){if(a!==this._dropOnInsertionPoint){this.hideInsertionPoint();a.addClassName("drop-target");this._dropOnInsertionPoint=a}}else{if(this._dropOnInsertionPoint){this._dropOnInsertionPoint.removeClassName("drop-target");this._dropOnInsertionPoint=null}if(!this._insertionPointView)this._insertionPointView=
this.insertionPointClass.create();b=this._insertionPointView;var c=a.get("frame");c={height:c.height-6,x:c.x,y:c.y+6,width:0};SC.rectsEqual(b.get("frame"),c)||b.set("frame",c);b.parentNode!=a.parentNode&&a.parentNode.appendChild(b)}},hideInsertionPoint:function(){var a=this._insertionPointView;a&&a.removeFromParent();if(this._dropOnInsertionPoint){this._dropOnInsertionPoint.removeClassName("drop-target");this._dropOnInsertionPoint=null}},insertionIndexForLocation:function(a,b){var c=this.get("frame"),
d=this.get("scrollFrame"),e=this.get("itemsPerRow"),f=Math.floor(c.width/e),g=Math.floor((a.y-c.y-d.y)/this.get("rowHeight")),h=SC.DROP_BEFORE;c=a.x-c.x-d.x;a=Math.floor(c/f);f=c/f-a;if(b===SC.DROP_ON){f>0.8&&a++;if(f>=0.2&&f<=0.8)h=SC.DROP_ON}else f>0.45&&a++;return[g*e+a,h]},_gv_clippingFrameDidChange:function(){var a=this.get("nowShowing"),b,c;this.notifyPropertyChange("itemsPerRow");c=a.get("length");for(b=0;b<c;b++){a=this.itemViewForContentIndex(b);a.adjust(this.layoutForContentIndex(b))}}.observes("clippingFrame")});
SC.ScrollerView=SC.View.extend({classNames:["sc-scroller-view"],value:function(a,b){a=this.get("minimum");if(b!==undefined)this._scs_value=b;b=this._scs_value||a;return Math.max(Math.min(b,this.get("maximum")),a)}.property("maximum","minimum").cacheable(),proportion:0,maximum:100,minimum:0,isEnabled:YES,layoutDirection:SC.LAYOUT_VERTICAL,hasButtons:YES,scrollbarThickness:14,capLength:18,capOverlap:14,buttonLength:41,buttonOverlap:11,displayProperties:"thumbPosition thumbLength isEnabled controlsHidden".w(),
render:function(a,b){var c=[],d="";switch(this.get("layoutDirection")){case SC.LAYOUT_VERTICAL:c.push("sc-vertical");break;case SC.LAYOUT_HORIZONTAL:c.push("sc-horizontal");break}this.get("isEnabled")||c.push("disabled");this.get("controlsHidden")&&c.push("controls-hidden");a.addClass(c);c=this.get("thumbLength");d=this.get("thumbPosition");if(b){d=this.get("hasButtons")?'<div class="button-bottom"></div><div class="button-top"></div>':'<div class="endcap"></div>';switch(this.get("layoutDirection")){case SC.LAYOUT_VERTICAL:a.push('<div class="track"></div>',
'<div class="cap"></div>',d,'<div class="thumb" style="height: '+c+'px;">','<div class="thumb-center"></div>','<div class="thumb-top"></div>','<div class="thumb-bottom"></div></div>');break;case SC.LAYOUT_HORIZONTAL:a.push('<div class="track"></div>','<div class="cap"></div>',d,'<div class="thumb" style="width: '+c+'px;">','<div class="thumb-center"></div>','<div class="thumb-top"></div>','<div class="thumb-bottom"></div></div>')}}else if(!this.get("controlsHidden")){a=this.$(".thumb");this.adjustThumbSize(a,
c);this.adjustThumbPosition(a,d)}},adjustThumbPosition:function(a,b){if(this._thumbPosition!==b){switch(this.get("layoutDirection")){case SC.LAYOUT_VERTICAL:a.css("top",b);break;case SC.LAYOUT_HORIZONTAL:a.css("left",b);break}this._thumbPosition=b}},adjustThumbSize:function(a,b){if(this._thumbSize!==b){switch(this.get("layoutDirection")){case SC.LAYOUT_VERTICAL:a.css("height",Math.max(b,20));break;case SC.LAYOUT_HORIZONTAL:a.css("width",Math.max(b,20));break}this._thumbSize=b}},trackLength:function(){var a=
this.get("scrollerLength");a-=this.capLength-this.capOverlap;a-=this.buttonLength-this.buttonOverlap;return a}.property("scrollerLength").cacheable(),scrollerLength:function(){switch(this.get("layoutDirection")){case SC.LAYOUT_VERTICAL:return this.get("frame").height;case SC.LAYOUT_HORIZONTAL:return this.get("frame").width}return 0}.property("frame").cacheable(),thumbLength:function(){return Math.max(Math.floor(this.get("trackLength")*this.get("proportion")),20)}.property("trackLength","proportion").cacheable(),
thumbPosition:function(){var a=this.get("value"),b=this.get("maximum"),c=this.get("trackLength"),d=this.get("thumbLength"),e=this.get("capLength"),f=this.get("capOverlap");a=a/b*(c-d);a+=e-f;return Math.floor(a)}.property("value","maximum","trackLength","thumbLength").cacheable(),controlsHidden:function(){return this.get("proportion")>=1}.property("proportion").cacheable(),mouseDown:function(a){if(!this.get("isEnabled"))return NO;var b=a.target,c=this.get("thumbPosition"),d;if(b.className.indexOf("thumb")>=
0){d=this.convertFrameFromView({x:a.pageX,y:a.pageY});d.x-=c;d.y-=c;this._thumbDragging=YES;this._thumbOffset=d;this._mouseDownLocation={x:a.pageX,y:a.pageY};this._thumbPositionAtDragStart=this.get("thumbPosition")}else if(b.className.indexOf("button-top")>=0){this.decrementProperty("value",30);this.makeButtonActive(".button-top");this.startMouseDownTimer("scrollUp")}else if(b.className.indexOf("button-bottom")>=0){this.incrementProperty("value",30);this.makeButtonActive(".button-bottom");this.startMouseDownTimer("scrollDown")}else{b=
this.get("scrollerLength");a=this.convertFrameFromView({x:a.pageX,y:a.pageY});switch(this.get("layoutDirection")){case SC.LAYOUT_VERTICAL:this._mouseDownLocation=d=a.y;break;case SC.LAYOUT_HORIZONTAL:this._mouseDownLocation=d=a.x;break}if(d<c){this.decrementProperty("value",b);this.startMouseDownTimer("pageUp")}else{this.incrementProperty("value",b);this.startMouseDownTimer("pageDown")}}return YES},mouseUp:function(){var a=this._scs_buttonActive,b=NO;if(a){a.removeClass("active");b=YES}if(a=this._mouseDownTimer){a.invalidate();
this._mouseDownTimer=null}this._thumbDragging=NO;return b},mouseDragged:function(a){var b,c=this._thumbPositionAtDragStart;if(!this._thumbDragging)return NO;switch(this.get("layoutDirection")){case SC.LAYOUT_VERTICAL:b=a.pageY-this._mouseDownLocation.y;break;case SC.LAYOUT_HORIZONTAL:b=a.pageX-this._mouseDownLocation.x;break}b=c+b;a=this.get("trackLength")-this.get("thumbLength");this.set("value",Math.round(b/a*this.get("maximum")));return YES},startMouseDownTimer:function(a){this._mouseDownTimerAction=
a;this._mouseDownTimer=SC.Timer.schedule({target:this,action:this.mouseDownTimerDidFire,interval:300})},mouseDownTimerDidFire:function(){var a=this.get("scrollerLength"),b=this._mouseDownLocation,c;switch(this._mouseDownTimerAction){case "scrollDown":this.incrementProperty("value",30);break;case "scrollUp":this.decrementProperty("value",30);break;case "pageDown":c=this._scs_thumbPosition+this._scs_thumbSize;if(b<c)return;this.incrementProperty("value",a);break;case "pageUp":c=this._scs_thumbPosition;
if(b>c)return;this.decrementProperty("value",a);break}this._mouseDownTimer=SC.Timer.schedule({target:this,action:this.mouseDownTimerDidFire,interval:50})},makeButtonActive:function(a){this._scs_buttonActive=this.$(a).addClass("active")}});sc_require("views/scroller");sc_require("mixins/border");
SC.ScrollView=SC.View.extend(SC.Border,{classNames:["sc-scroll-view"],isScrollable:YES,contentView:null,horizontalScrollOffset:function(a,b){if(b!==undefined)this._scroll_horizontalScrollOffset=Math.max(0,Math.min(this.get("maximumHorizontalScrollOffset"),b));return this._scroll_horizontalScrollOffset||0}.property().cacheable(),verticalScrollOffset:function(a,b){if(b!==undefined)this._scroll_verticalScrollOffset=Math.max(0,Math.min(this.get("maximumVerticalScrollOffset"),b));return this._scroll_verticalScrollOffset||
0}.property().cacheable(),maximumHorizontalScrollOffset:function(){if(!this.get("canScrollHorizontal"))return 0;var a=this.get("contentView"),b=a?a.get("frame").width:0;if(a.calculatedWidth&&a.calculatedWidth!==0)b=a.calculatedWidth;a=this.get("containerView").get("frame").width;return Math.max(0,b-a)}.property(),maximumVerticalScrollOffset:function(){if(!this.get("canScrollVertical"))return 0;var a=this.get("contentView"),b=a&&a.get("frame")?a.get("frame").height:0;if(a.calculatedHeight&&a.calculatedHeight!==
0)b=a.calculatedHeight;a=this.get("containerView").get("frame").height;return Math.max(0,b-a)}.property(),verticalLineScroll:20,horizontalLineScroll:20,verticalPageScroll:function(){return this.get("frame").height}.property("frame"),horizontalPageScroll:function(){return this.get("frame").width}.property("frame"),hasHorizontalScroller:YES,horizontalScrollerView:SC.ScrollerView,isHorizontalScrollerVisible:YES,canScrollHorizontal:function(){return!!(this.get("hasHorizontalScroller")&&this.get("horizontalScrollerView")&&
this.get("isHorizontalScrollerVisible"))}.property("isHorizontalScrollerVisible").cacheable(),autohidesHorizontalScroller:YES,hasVerticalScroller:YES,verticalScrollerView:SC.ScrollerView,isVerticalScrollerVisible:YES,canScrollVertical:function(){return!!(this.get("hasVerticalScroller")&&this.get("verticalScrollerView")&&this.get("isVerticalScrollerVisible"))}.property("isVerticalScrollerVisible").cacheable(),autohidesVerticalScroller:YES,verticalScrollerBottom:0,verticalOverlay:NO,horizontalOverlay:NO,
verticalScrollerLayout:null,horizontalScrollerLayout:null,containerView:SC.ContainerView,scrollTo:function(a,b){if(b===undefined&&SC.typeOf(a)===SC.T_HASH){b=a.y;a=a.x}if(!SC.none(a)){a=Math.max(0,Math.min(this.get("maximumHorizontalScrollOffset"),a));this.set("horizontalScrollOffset",a)}if(!SC.none(b)){b=Math.max(0,Math.min(this.get("maximumVerticalScrollOffset"),b));this.set("verticalScrollOffset",b)}return this},scrollBy:function(a,b){if(b===undefined&&SC.typeOf(a)===SC.T_HASH){b=a.y;a=a.x}a=a?
this.get("horizontalScrollOffset")+a:null;b=b?this.get("verticalScrollOffset")+b:null;return this.scrollTo(a,b)},scrollToVisible:function(a){if(arguments.length===0)return arguments.callee.base.apply(this,arguments);var b=this.get("contentView");if(!b)return NO;var c=a.get("frame");if(!c)return NO;c=b.convertFrameFromView(c,a.get("parentView"));b=SC.cloneRect(this.get("containerView").get("frame"));b.x=this.get("horizontalScrollOffset");b.y=this.get("verticalScrollOffset");var d=b.x,e=b.y;b.y-=Math.max(0,
SC.minY(b)-SC.minY(c));b.x-=Math.max(0,SC.minX(b)-SC.minX(c));b.y+=Math.max(0,SC.maxY(c)-SC.maxY(b));b.x+=Math.max(0,SC.maxX(c)-SC.maxX(b));if(d!==b.x||e!==b.y){this.scrollTo(b.x,b.y);return YES}else return NO},scrollDownLine:function(a){if(a===undefined)a=1;return this.scrollBy(null,this.get("verticalLineScroll")*a)},scrollUpLine:function(a){if(a===undefined)a=1;return this.scrollBy(null,0-this.get("verticalLineScroll")*a)},scrollRightLine:function(a){if(a===undefined)a=1;return this.scrollTo(this.get("horizontalLineScroll")*
a,null)},scrollLeftLine:function(a){if(a===undefined)a=1;return this.scrollTo(0-this.get("horizontalLineScroll")*a,null)},scrollDownPage:function(a){if(a===undefined)a=1;return this.scrollBy(null,this.get("verticalPageScroll")*a)},scrollUpPage:function(a){if(a===undefined)a=1;return this.scrollBy(null,0-this.get("verticalPageScroll")*a)},scrollRightPage:function(a){if(a===undefined)a=1;return this.scrollBy(this.get("horizontalPageScroll")*a,null)},scrollLeftPage:function(a){if(a===undefined)a=1;return this.scrollBy(0-
this.get("horizontalPageScroll")*a,null)},tile:function(){var a=this.get("hasHorizontalScroller")?this.get("horizontalScrollerView"):null,b=a&&this.get("isHorizontalScrollerVisible"),c=this.get("hasVerticalScroller")?this.get("verticalScrollerView"):null,d=c&&this.get("isVerticalScrollerVisible"),e=this.get("containerView"),f={left:0,top:0},g,h,j;h=b?a.get("scrollbarThickness"):0;var k=d?c.get("scrollbarThickness"):0;if(b){g=this.get("horizontalScrollerLayout");g={left:g?g.left:0,bottom:g?g.bottom:
0,right:g?g.right+k-1:k-1,height:h};a.set("layout",g);j=this.get("horizontalOverlay");f.bottom=j?0:g.bottom+h}else f.bottom=0;a&&a.set("isVisible",b);if(d){h+=this.get("verticalScrollerBottom");a=this.get("verticalScrollerLayout");g={top:a?a.top:0,bottom:a?a.bottom+h:h,right:a?a.right:0,width:k};c.set("layout",g);h=this.get("verticalOverlay");f.right=h?0:g.right+k}else f.right=0;c&&c.set("isVisible",d);e.set("layout",f)},scrollerVisibilityDidChange:function(){this.tile()}.observes("isVerticalScrollerVisible",
"isHorizontalScrollerVisible"),_scroll_wheelDeltaX:0,_scroll_wheelDeltaY:0,mouseWheel:function(a){this._scroll_wheelDeltaX+=a.wheelDeltaX;this._scroll_wheelDeltaY+=a.wheelDeltaY;this.invokeLater(this._scroll_mouseWheel,10);return this.get("canScrollHorizontal")||this.get("canScrollVertical")},_scroll_mouseWheel:function(){this.scrollBy(this._scroll_wheelDeltaX,this._scroll_wheelDeltaY);if(SC.WHEEL_MOMENTUM&&this._scroll_wheelDeltaY>0){this._scroll_wheelDeltaY=Math.floor(this._scroll_wheelDeltaY*0.95);
this._scroll_wheelDeltaY=Math.max(this._scroll_wheelDeltaY,0);this.invokeLater(this._scroll_mouseWheel,10)}else if(SC.WHEEL_MOMENTUM&&this._scroll_wheelDeltaY<0){this._scroll_wheelDeltaY=Math.ceil(this._scroll_wheelDeltaY*0.95);this._scroll_wheelDeltaY=Math.min(this._scroll_wheelDeltaY,0);this.invokeLater(this._scroll_mouseWheel,10)}else this._scroll_wheelDeltaX=this._scroll_wheelDeltaY=0},touchStart:function(a){this.beginTouchTracking(a);this.invokeLater(this.beginTouchesInContent,150);return SC.MIXED_STATE},
beginTouchesInContent:function(){var a=this.touch;if(a.tracking&&!a.dragging){a=a.originalEvent;a.manufactured=YES;this.contentView.mouseDown(a)}},beginTouchTracking:function(a){var b=this.get("verticalScrollOffset");this.touch={startScrollOffset:{x:this.horizontalScrollOffset,y:b},startTime:a.timeStamp,startTimePosition:b,startTouchOffset:{x:a.pageX,y:a.pageY},decelerationVelocity:{y:0},originalTarget:SC.RootResponder.responder.targetViewForEvent(a),originalPane:this.get("pane"),originalEvent:SC.copy(a),
tracking:YES,dragging:NO,decelerating:NO};this.tracking=YES;this.dragging=NO},touchDragged:function(a){var b=this.touch,c=a.pageY,d=b.startScrollOffset.y,e=this.get("maximumVerticalScrollOffset");c=c-b.startTouchOffset.y;if(!b.dragging)if(Math.abs(c)>5){b.dragging=YES;b.firstDrag=YES}if(b.dragging){d-=c;if(b.firstDrag){b.firstDrag=NO;return}}this.set("verticalScrollOffset",Math.max(0,Math.min(d,e)));if(a.timeStamp-b.lastEventTime>50){b.startTime=a.timeStamp;b.startTimePosition=this.get("verticalScrollOffset")}b.lastEventTime=
a.timeStamp},touchEnd:function(a){var b=this.touch;this.tracking=NO;this.dragging=b.tracking=NO;if(b.dragging){b.dragging=NO;if(a.timeStamp-b.lastEventTime<=100){b.offsetBeforeDeceleration={y:this.get("verticalScrollOffset")};this.startDecelerationAnimation(a)}}},startDecelerationAnimation:function(a){var b=this.touch,c=this.get("verticalScrollOffset")-b.startTimePosition;b.decelerationVelocity={y:c/((a.timeStamp-b.startTime)/15)};this.decelerateAnimation()},decelerateAnimation:function(){var a=this.touch,
b=this.get("maximumVerticalScrollOffset"),c=this.get("verticalScrollOffset")+a.decelerationVelocity.y;this.set("verticalScrollOffset",Math.max(0,Math.min(Math.round(c),b)));a.decelerationVelocity.y*=0.95;if(Math.abs(a.decelerationVelocity.y)<1){a.decelerationVelocity.y=0;a.decelerating=NO}else this.invokeLater(this.decelerateAnimation,16)},createChildViews:function(){var a=[],b;if(SC.none(b=this.containerView))b=SC.ContainerView;a.push(this.containerView=this.createChildView(b,{contentView:this.contentView,
isScrollContainer:YES}));this.contentView=this.containerView.get("contentView");if(b=this.horizontalScrollerView)if(this.get("hasHorizontalScroller")){b=this.horizontalScrollerView=this.createChildView(b,{layoutDirection:SC.LAYOUT_HORIZONTAL,valueBinding:"*owner.horizontalScrollOffset"});a.push(b)}else this.horizontalScrollerView=null;if(b=this.verticalScrollerView)if(this.get("hasVerticalScroller")){b=this.verticalScrollerView=this.createChildView(b,{layoutDirection:SC.LAYOUT_VERTICAL,valueBinding:"*owner.verticalScrollOffset"});
a.push(b)}else this.verticalScrollerView=null;this.childViews=a;this.contentViewDidChange();this.tile()},init:function(){arguments.callee.base.apply(this,arguments);var a=this._scroll_contentView=this.get("contentView");a&&a.addObserver("frame",this,this.contentViewFrameDidChange);this.get("isVisibleInWindow")&&this._scsv_registerAutoscroll()},_scsv_registerAutoscroll:function(){this.get("isVisibleInWindow")?SC.Drag.addScrollableView(this):SC.Drag.removeScrollableView(this)}.observes("isVisibleInWindow"),
contentViewDidChange:function(){var a=this.get("contentView"),b=this._scroll_contentView,c=this.contentViewFrameDidChange;if(a!==b){b&&b.removeObserver("frame",this,c);(this._scroll_contentView=a)&&a.addObserver("frame",this,c);this.containerView.set("contentView",a);this.contentViewFrameDidChange()}}.observes("contentView"),render:function(a,b){this.invokeLast(this.adjustElementScroll);b&&a.push('<div class="corner"></div>');return arguments.callee.base.apply(this,arguments)},oldMaxHOffset:0,oldMaxVOffset:0,
contentViewFrameDidChange:function(){var a=this.get("contentView"),b=a?a.get("frame"):null,c=b?b.width:0;b=b?b.height:0;var d=this.get("frame");this._scroll_contentWidth=c;this._scroll_contentHeight=b;if(this.get("hasHorizontalScroller")&&(a=this.get("horizontalScrollerView"))){this.get("autohidesHorizontalScroller")&&this.set("isHorizontalScrollerVisible",c>d.width);a.setIfChanged("maximum",c-d.width);a.setIfChanged("proportion",d.width/c)}if(this.get("hasVerticalScroller")&&(a=this.get("verticalScrollerView"))){this.get("autohidesVerticalScroller")&&
this.set("isVerticalScrollerVisible",b>d.height);b-=this.get("verticalScrollerBottom");a.setIfChanged("maximum",b-d.height);a.setIfChanged("proportion",d.height/b)}!this.get("isVerticalScrollerVisible")&&this.get("verticalScrollOffset")!==0&&this.get("autohidesVerticalScroller")&&this.set("verticalScrollOffset",0);!this.get("isHorizontalScrollerVisible")&&this.get("horizontalScrollOffset")!==0&&this.get("autohidesHorizontalScroller")&&this.set("horizontalScrollOffset",0);d=this.get("maximumVerticalScrollOffset");
a=this.get("verticalScrollOffset");b=this.get("maximumHorizontalScrollOffset");c=this.get("horizontalScrollOffset");d=d<a;b=b<c;if(d||b)this.forceDimensionsRecalculation(b,d,a,c)},_scroll_horizontalScrollOffsetDidChange:function(){this.invokeLast(this.adjustElementScroll)}.observes("horizontalScrollOffset"),_scroll_verticalScrollOffsetDidChange:function(){this.invokeLast(this.adjustElementScroll)}.observes("verticalScrollOffset"),adjustElementScroll:function(){var a=this.get("containerView"),b=this.get("contentView"),
c=this.get("verticalScrollOffset"),d=this.get("horizontalScrollOffset");if(b){SC.RunLoop.begin();b.notifyPropertyChange("frame");SC.RunLoop.end();if(SC.browser.touch){var e="translate3d(-"+d+"px, -"+c+"px, 0)";b.get("layer").style.webkitTransform=e}}if(a&&!SC.browser.touch){b=a.get("hasCustomScrolling");e=a.get("layer");if(a){if(c!==this._verticalScrollOffset){if(!b)e.scrollTop=c;this._verticalScrollOffset=c}if(d!==this._horizontalScrollOffset){if(!b)e.scrollLeft=d;this._horizontalScrollOffset=d}}}},
forceDimensionsRecalculation:function(a,b,c,d){this.scrollTo(0,0);a&&b&&this.scrollTo(this.get("maximumHorizontalScrollOffset"),this.get("maximumVerticalScrollOffset"));a&&!b&&this.scrollTo(this.get("maximumHorizontalScrollOffset"),c);!a&&b&&this.scrollTo(d,this.get("maximumVerticalScrollOffset"))},_verticalScrollOffset:0,_horizontalScrollOffset:0});sc_require("views/scroll");
SC.MenuScrollerView=SC.ScrollerView.extend({classNames:["sc-menu-scroller-view"],scrollDown:NO,value:function(a,b){if(b!==undefined)this._value=b;else return Math.min(this._value||0,this.get("maximum"))}.property("maximum").cacheable(),maximum:0,isEnabled:YES,layoutDirection:SC.LAYOUT_VERTICAL,verticalLineScroll:20,ownerScrollValueKey:function(){return"verticalScrollOffset"}.property("layoutDirection").cacheable(),render:function(a,b){a.addClass("sc-vertical");if(b){b=this.get("scrollDown")?"arrowDown":
"arrowUp";a.push('<span class="'+b+'">&nbsp;</span>')}a.setClass("disabled",!this.get("isEnabled"))},didCreateLayer:function(){},willDestroyLayer:function(){var a=this._sc_scroller_scrollDidChange;SC.Event.remove(this.$(),"scroll",this,a)},mouseEntered:function(){this.set("isMouseOver",YES);this._invokeScrollOnMouseOver()},mouseExited:function(){this.set("isMouseOver",NO)},_sc_scroller_valueDidChange:function(){}.observes("value"),_sc_scroller_armScrollTimer:function(){if(!this._sc_scrollTimer){SC.RunLoop.begin();
this._sc_scrollTimer=this.invokeLater(this._sc_scroller_scrollDidChange,50);SC.RunLoop.end()}},_sc_scroller_scrollDidChange:function(){var a=Date.now(),b=this._sc_lastScroll,c=this.get("layer"),d=0;if(b&&a-b<50)return this._sc_scroller_armScrollTimer();this._sc_scrollTimer=null;this._sc_lastScroll=a;SC.RunLoop.begin();if(this.get("isEnabled")){this._sc_scrollValue=d=c.scrollTop;this.set("value",d);SC.RunLoop.end()}},_scrollMenu:function(){var a=this.get("value"),b;if(this.get("scrollDown")){b=a+this.verticalLineScroll;
b<=this.get("maximum")&&this.set("value",b)}else{b=a-this.verticalLineScroll;if(b>=0)this.set("value",b);else a<=this.verticalLineScroll&&a>0&&this.set("value",0)}return YES},_invokeScrollOnMouseOver:function(){this._scrollMenu();this.get("isMouseOver")&&this.invokeLater(this._invokeScrollOnMouseOver,100)}});
SC.MenuScrollView=SC.ScrollView.extend({classNames:["sc-menu-scroll-view"],maximumHorizontalScrollOffset:0,hasHorizontalScroller:NO,horizontalScrollerView:SC.MenuScrollerView,isHorizontalScrollerVisible:NO,canScrollHorizontal:NO,autohidesHorizontalScroller:NO,hasVerticalScroller:YES,verticalScrollerView:SC.MenuScrollerView,verticalScrollerView2:SC.MenuScrollerView,isVerticalScrollerVisible:YES,canScrollVertical:YES,autohidesVerticalScroller:YES,verticalScrollerBottom:0,controlSize:SC.REGULAR_CONTROL_SIZE,
containerView:SC.ContainerView,tile:function(){var a,b,c,d,e,f;b=(a=this.get("hasVerticalScroller"))?this.get("verticalScrollerView"):null;a=a?this.get("verticalScrollerView2"):null;c=b&&this.get("isVerticalScrollerVisible");d=this.get("containerView");e={left:0,top:0};if(c){f=0;var g=b.get("scrollerThickness")||a.get("scrollerThickness"),h=this.get("contentView");h=(h=h?h.get("frame"):null)?h.height:0;var j=this.containerView.$()[0],k=this.get("verticalScrollOffset"),l={height:0,top:0,right:0,left:0},
m={height:g,top:0,right:0,left:0},n={height:g,bottom:0,right:0,left:0},o={height:0,bottom:0,right:0,left:0};if(j)f=j.offsetHeight;if(k===0){e.top=0;e.bottom=g;b.set("layout",l);a.set("layout",n)}else if(k>=h-f-g){e.top=g;e.bottom=0;b.set("layout",m);a.set("layout",o)}else{e.top=g;e.bottom=g;b.set("layout",m);a.set("layout",n)}}if(b){b.set("isVisible",c);a.set("isVisible",c)}d.set("layout",e)},scrollerVisibilityDidChange:function(){this.tile()}.observes("isVerticalScrollerVisible","isHorizontalScrollerVisible",
"verticalScrollOffset"),createChildViews:function(){var a=[],b,c;if(SC.none(b=this.containerView))b=SC.ContainerView;a.push(this.containerView=this.createChildView(b,{contentView:this.contentView}));this.contentView=this.containerView.get("contentView");if((b=this.verticalScrollerView)&&(c=this.verticalScrollerView2))if(this.get("hasVerticalScroller")){var d=this.get("controlSize")===SC.SMALL_CONTROL_SIZE?14:16;b=this.verticalScrollerView=this.createChildView(b,{layout:{top:0,left:0,right:0,height:d},
scrollerThickness:d,valueBinding:"*owner.verticalScrollOffset"});a.push(b);c=this.verticalScrollerView2=this.createChildView(c,{scrollDown:YES,layout:{bottom:0,left:0,right:0,height:d},scrollerThickness:d,valueBinding:"*owner.verticalScrollOffset"});a.push(c)}else this.verticalScrollerView2=this.verticalScrollerView=null;this.childViews=a;this.contentViewFrameDidChange();this.tile()},init:function(){arguments.callee.base.apply(this,arguments);var a=this._scroll_contentView=this.get("contentView");
a&&a.addObserver("frame",this,this.contentViewFrameDidChange);this.get("isVisibleInWindow")&&this._scsv_registerAutoscroll()},_scsv_registerAutoscroll:function(){this.get("isVisibleInWindow")?SC.Drag.addScrollableView(this):SC.Drag.removeScrollableView(this)}.observes("isVisibleInWindow"),contentViewFrameDidChange:function(){var a=this.get("contentView"),b,c=a?a.get("frame"):null,d=c?c.width:0;c=c?c.height:0;var e=this.get("frame");this._scroll_contentWidth=d;this._scroll_contentHeight=c;if(this.get("hasVerticalScroller")&&
(a=this.get("verticalScrollerView"))&&(b=this.get("verticalScrollerView2"))){c-=1;this.get("autohidesVerticalScroller")&&this.set("isVerticalScrollerVisible",c>e.height);c-=this.get("verticalScrollerBottom");d=0;if(e=this.containerView.$()[0])d=e.offsetHeight;c-=d;a.setIfChanged("maximum",c);b.setIfChanged("maximum",c)}},_scroll_horizontalScrollOffsetDidChange:function(){},_scroll_verticalScrollOffsetDidChange:function(){var a=this.get("verticalScrollOffset"),b=this.get("contentView");b&&b.adjust("top",
0-a)}.observes("verticalScrollOffset")});sc_require("views/button");
SC.PopupButtonView=SC.ButtonView.extend({keyEquivalent:null,classNames:["sc-popup-button"],preferMatrix:null,acceptsFirstResponder:function(){return SC.SAFARI_FOCUS_BEHAVIOR?NO:this.get("isEnabled")}.property("isEnabled"),isSelected:NO,performKeyEquivalent:function(a,b){if(!this.get("isEnabled"))return NO;var c=this.get("menu");return!!c&&c.performKeyEquivalent(a,b)},menu:null,isSelectedBinding:"*menu.isVisibleInWindow",action:function(){var a=this.get("menu");if(!a)return NO;a.popup(this,this.preferMatrix);
return YES},mouseDown:function(){if(!this.get("isEnabled"))return YES;this.set("isActive",YES);this._isMouseDown=YES;this._action();return YES}});
SC.ProgressView=SC.View.extend(SC.Control,{value:0.5,valueBindingDefault:SC.Binding.single().notEmpty(),minimum:0,minimumBindingDefault:SC.Binding.single().notEmpty(),contentMinimumKey:null,maximum:1,maximumBindingDefault:SC.Binding.single().notEmpty(),offsetRange:24,contentMaximumKey:null,isIndeterminate:NO,isIndeterminateBindingDefault:SC.Binding.bool(),isRunning:NO,isRunningBindingDefault:SC.Binding.bool(),animatedBackgroundMatrix:[],contentIsIndeterminateKey:null,classNames:"sc-progress-view",
_backgroundOffset:0,_currentBackground:1,_nextBackground:1,init:function(){arguments.callee.base.apply(this,arguments);this.animateProgressBar()},animateProgressBar:function(){this.get("isRunning")&&this.get("isVisibleInWindow")&&this._animateProgressBar(500)}.observes("isRunning","isVisibleInWindow"),_animateProgressBar:function(a){if(a===0)a=1E3/30;if(this.get("isRunning")&&this.get("isVisibleInWindow")){this.displayDidChange();this.invokeLater(this._animateProgressBar,a,30)}},displayProperties:"value minimum maximum isIndeterminate".w(),
render:function(a,b){var c,d=this.get("isIndeterminate"),e=this.get("isRunning");c=this.get("isEnabled");var f=this.get("offsetRange");e=d&&e?Math.floor(Date.now()/75)%f-f:0;if(c)if(d)c="120%";else{f=this.get("minimum")||0;var g=this.get("maximum")||1;c=this.get("value")||0;c=(c-f)/(g-f);if(c>1)c=1;if(isNaN(c))c=0;if(c<f)c=0;if(c>g)c=1;c=c*100+"%"}else c="0%";d={"sc-indeterminate":d,"sc-empty":c<=0,"sc-complete":c>=100};if(b){b=this._createClassNameString(d);a.push('<div class="sc-inner ',b,'" style="width: ',
c,";left: ",e,'px;">','<div class="sc-inner-head">',"</div>",'<div class="sc-inner-tail"></div></div>','<div class="sc-outer-head"></div>','<div class="sc-outer-tail"></div>')}else{a.setClass(d);a=this.$(".sc-inner");b=this.get("animatedBackgroundMatrix");c="width: "+c+"; ";c=c+"left: "+e+"px; ";if(b.length===3){a.css("backgroundPosition","0px -"+(b[0]+b[1]*this._currentBackground)+"px");if(this._currentBackground===b[2]-1||this._currentBackground===0)this._nextBackground*=-1;this._currentBackground+=
this._nextBackground;c+="backgroundPosition: undefinedpx; "}a.attr("style",c)}},contentPropertyDidChange:function(a,b){a=this.get("content");this.beginPropertyChanges().updatePropertyFromContent("value",b,"contentValueKey",a).updatePropertyFromContent("minimum",b,"contentMinimumKey",a).updatePropertyFromContent("maximum",b,"contentMaximumKey",a).updatePropertyFromContent("isIndeterminate",b,"contentIsIndeterminateKey",a).endPropertyChanges()},_createClassNameString:function(a){var b=[],c;for(c in a)a.hasOwnProperty(c)&&
a[c]&&b.push(c);return b.join(" ")}});
SC.RadioView=SC.View.extend(SC.Control,{classNames:["sc-radio-view"],value:null,layoutDirection:SC.LAYOUT_VERTICAL,escapeHTML:YES,items:[],itemTitleKey:null,itemValueKey:null,itemIsEnabledKey:null,itemIconKey:null,routeTouch:YES,itemsDidChange:function(){this._items&&this._items.removeObserver("[]",this,this.itemContentDidChange);(this._items=this.get("items"))&&this._items.addObserver("[]",this,this.itemContentDidChange);this.itemContentDidChange()}.observes("items"),itemContentDidChange:function(){this.notifyPropertyChange("_displayItems")},
displayProperties:["value","_displayItems"],render:function(a,b){var c,d,e,f,g,h,j,k=this.get("_displayItems"),l=this.get("value"),m=SC.isArray(l);a.addClass(this.get("layoutDirection"));if(m&&l.length<=0){l=l[0];m=NO}if(b){a.attr("role","radiogroup");SC.guidFor(this);b=k.length;for(d=0;d<b;d++){c=k[d];if(e=c[3]){f=e.indexOf("/")>=0?e:SC.BLANK_IMAGE_URL;e=f===e?"":e;e='<img src="'+f+'" class="icon '+e+'" alt="" />'}else e="";g=c?m?l.indexOf(c[1])>=0:l===c[1]:NO;j=this._getSelectionStateClassNames(c,
g,l,m,false);f=this.escapeHTML?SC.RenderContext.escapeHTML(c[0]):c[0];a.push('<div class="sc-radio-button ',j,'" ','aria-checked="',g?"true":"false",'" ','role="radio"',' index="',d,'">','<span class="button"></span>','<span class="sc-button-label">',e,f,"</span></div>")}}else this.$(".sc-radio-button").forEach(function(n){n=this.$(n);d=parseInt(n.attr("index"),0);g=(c=d>=0?k[d]:null)?m?l.indexOf(c[1])>=0:l===c[1]:NO;h=this._getSelectionStateClassNames(c,g,l,m,true);n.attr("aria-checked",g?"true":
"false");n.setClass(h);d=h=null},this)},_displayItems:function(){var a=this.get("items"),b=this.get("localize"),c=this.get("itemTitleKey"),d=this.get("itemValueKey"),e=this.get("itemIsEnabledKey"),f=this.get("itemIconKey"),g=[],h=a?a.get("length"):0,j,k,l,m,n,o;for(m=0;m<h;m++){j=a.objectAt(m);if(SC.typeOf(j)===SC.T_ARRAY){k=j[0];l=j[1]}else if(j){k=c?j.get?j.get(c):j[c]:j.toString?j.toString():null;l=d?j.get?j.get(d):j[d]:j;n=e?j.get?j.get(e):j[e]:YES;o=f?j.get?j.get(f):j[f]:null}else{k=l=o=null;
n=NO}if(b)k=k.loc();g.push([k,l,n,o])}return g}.property("items","itemTitleKey","itemValueKey","itemIsEnabledKey","localize","itemIconKey").cacheable(),_getSelectionStateClassNames:function(a,b,c,d,e){var f;a={sel:b&&!d,mixed:b&&d,disabled:!a[2]};if(e)return a;else{e=[];for(f in a)a.hasOwnProperty(f)&&a[f]&&e.push(f);return e.join(" ")}},mouseDown:function(a){if(!this.get("isEnabled"))return YES;for(a=a.target;a;){if(a.className&&a.className.indexOf("sc-radio-button")>-1)break;a=a.parentNode}if(!a)return NO;
a=this.$(a);if(a.hasClass("disabled"))return YES;a.addClass("active");this._activeRadioButton=a;return YES},mouseUp:function(a){if(!this.get("isEnabled"))return YES;var b=this._activeRadioButton,c=a.target;a=this.get("_displayItems");if(b){b.removeClass("active");this._activeRadioButton=null}else return YES;for(;c;){if(c.className&&c.className.indexOf("sc-radio-button")>-1)break;c=c.parentNode}c=this.$(c);if(c[0]!==b[0]||c.hasClass("disabled"))return YES;b=parseInt(c.attr("index"),0);this.set("value",
a[b][1])}});
SC.SceneView=SC.ContainerView.extend({scenes:["master","detail"],nowShowing:null,transitionDuration:200,_state:"NO_VIEW",replaceContent:function(a){a&&this._state===this.READY?this.animateScene(a):this.replaceScene(a);return this},replaceScene:function(a){var b=this._targetView,c=this.STANDARD_LAYOUT,d=this.get("scenes");d=d?d.indexOf(this.get("nowShowing")):-1;this._targetView=a;this._targetIndex=d;this._timer&&this._timer.invalidate();this._timer=this._leftView=this._rightView=this._start=this._end=
null;this.removeAllChildren();b&&b.set("layout",c);a&&a.set("layout",c);a&&this.appendChild(a);this._state=a?this.READY:this.NO_VIEW},animateScene:function(a){var b=this._targetView,c=this._targetIndex,d=this.get("scenes");d=d?d.indexOf(this.get("nowShowing")):-1;if(c<0||d<0||c===d)return this.replaceScene(a);this._targetView=a;this._targetIndex=d;if(d>c){this._leftView=b;this._rightView=a;this._target=-1}else{this._leftView=a;this._rightView=b;this._target=1}this.removeAllChildren();b&&this.appendChild(b);
a&&this.appendChild(a);this._start=Date.now();this._end=this._start+this.get("transitionDuration");this._state=this.ANIMATING;this.tick()},tick:function(){this._timer=null;var a=(Date.now()-this._start)/(this._end-this._start),b=this._target,c=this._leftView,d=this._rightView,e;if(a<0)a=0;if(!this.get("isVisibleInWindow")||a>=1)return this.replaceScene(this._targetView);e=SC.clone(this.get("frame"));a=Math.floor(e.width*a);if(b>0){e.left=0-(e.width-a);c.set("layout",e);e=SC.clone(e);e.left=a}else{e.left=
0-a;c.set("layout",e);e=SC.clone(e);e.left=e.width-a}d.set("layout",e);this._timer=this.invokeLater(this.tick,20);return this},NO_VIEW:"NO_VIEW",ANIMATING:"ANIMATING",READY:"READY",STANDARD_LAYOUT:{top:0,left:0,bottom:0,right:0}});
SC.SegmentedView=SC.View.extend(SC.Control,{classNames:["sc-segmented-view"],theme:"square",value:null,isEnabled:YES,allowsEmptySelection:NO,allowsMultipleSelection:NO,localize:YES,align:SC.ALIGN_CENTER,layoutDirection:SC.LAYOUT_HORIZONTAL,items:[],itemTitleKey:null,itemValueKey:null,itemIsEnabledKey:null,itemIconKey:null,itemWidthKey:null,itemActionKey:null,itemTargetKey:null,itemKeyEquivalentKey:null,itemKeys:"itemTitleKey itemValueKey itemIsEnabledKey itemIconKey itemWidthKey itemToolTipKey".w(),
displayItems:function(){var a=this.get("items"),b=this.get("localize"),c=null,d,e,f=[],g=a.get("length"),h,j,k=SC._segmented_fetchKeys,l=SC._segmented_fetchItem;for(h=0;h<g;h++){j=a.objectAt(h);if(!SC.none(j)){d=SC.typeOf(j);if(d===SC.T_STRING)e=[j.humanize().titleize(),j,YES,null,null,null,h];else if(d!==SC.T_ARRAY){if(c===null)c=this.itemKeys.map(k,this);e=c.map(l,j);e[e.length]=h;if(!c[0]&&j.toString)e[0]=j.toString();c[1]||(e[1]=j);c[2]||(e[2]=YES)}if(b&&e[0])e[0]=e[0].loc();if(b&&e[5]&&SC.typeOf(e[5])===
SC.T_STRING)e[5]=e[5].loc();f[f.length]=e}}return f}.property("items","itemTitleKey","itemValueKey","itemIsEnabledKey","localize","itemIconKey","itemWidthKey","itemToolTipKey"),itemsDidChange:function(){this._items&&this._items.removeObserver("[]",this,this.itemContentDidChange);(this._items=this.get("items"))&&this._items.addObserver("[]",this,this.itemContentDidChange);this.itemContentDidChange()}.observes("items"),itemContentDidChange:function(){this.notifyPropertyChange("displayItems")},init:function(){arguments.callee.base.apply(this,
arguments);this.itemsDidChange()},displayProperties:["displayItems","value","activeIndex"],render:function(a,b){var c=this.get("displayItems"),d=this._seg_displayItems,e=this.get("theme");e&&a.addClass(e);if(b||c!==d){this._seg_displayItems=c;this.renderDisplayItems(a,c);a.addStyle("text-align",this.get("align"))}else{a=this.get("activeIndex");b=this.get("value");if((d=SC.isArray(b))&&b.get("length")===1){b=b.objectAt(0);d=NO}e={};for(var f=c.length,g=this.$(".sc-segment"),h;--f>=0;){h=c[f];e.sel=
d?b.indexOf(h[1])>=0:h[1]===b;e.active=a===f;e.disabled=!h[2];SC.$(g[f]).setClass(e)}}},renderDisplayItems:function(a,b){var c=this.get("value"),d=SC.isArray(c),e=this.get("activeIndex"),f=b.length,g,h,j,k,l,m,n,o;for(m=0;m<f;m++){k=a.begin("a").attr("role","button");l=b[m];g=l[0];h=l[3];j=l[5];n={};o=[];if(this.get("layoutDirection")==SC.LAYOUT_HORIZONTAL)n.display="inline-block";o.push("sc-segment");l[2]||o.push("disabled");m===0&&o.push("sc-first-segment");m===f-1&&o.push("sc-last-segment");m!==
0&&m!==f-1&&o.push("sc-middle-segment");if(d?c.indexOf(l[1])>=0:l[1]===c)o.push("sel");e===m&&o.push("active");if(l[4]){l=l[4];n.width=l+"px"}k.addClass(o);k.addStyle(n);j&&k.attr("title",j);if(h){j=h.indexOf("/")>=0?h:SC.BLANK_IMAGE_URL;h=j===h?"":h;h='<img src="'+j+'" alt="" class="icon '+h+'" />'}else h="";k.push('<span class="sc-button-inner"><label class="sc-button-label">',h+g,"</label></span>");k.end()}},displayItemIndexForEvent:function(a){a=SC.$(a.target);if(!a||a===document)return-1;for(var b=
this.$(),c=null;!c&&a.length>0&&a[0]!==b[0];)if(a.hasClass("sc-segment"))c=a;else a=a.parent();return c?this.$(".sc-segment").index(c):-1},keyDown:function(a){var b,c,d,e,f;if(a.which===9){(c=a.shiftKey?this.get("previousValidKeyView"):this.get("nextValidKeyView"))?c.becomeFirstResponder():a.allowDefault();return YES}if(!this.get("allowsMultipleSelection")&&!this.get("allowsEmptySelection")){c=this.get("displayItems");d=c.length;e=this.get("value");f=SC.isArray(e);if(a.which===39||a.which===40){for(a=
0;a<d-1;a++){b=c[a];if(f?e.indexOf(b[1])>=0:b[1]===e)this.triggerItemAtIndex(a+1)}return YES}else if(a.which===37||a.which===38){for(a=1;a<d;a++){b=c[a];if(f?e.indexOf(b[1])>=0:b[1]===e)this.triggerItemAtIndex(a-1)}return YES}}return YES},mouseDown:function(a){if(!this.get("isEnabled"))return YES;a=this.displayItemIndexForEvent(a);if(a>=0){this._isMouseDown=YES;this.set("activeIndex",a)}return YES},mouseUp:function(a){a=this.displayItemIndexForEvent(a);this._isMouseDown&&a>=0&&this.triggerItemAtIndex(a);
this._isMouseDown=NO;this.set("activeIndex",-1);return YES},mouseMoved:function(a){a=this.displayItemIndexForEvent(a);this._isMouseDown&&this.set("activeIndex",a);return YES},mouseOver:function(a){a=this.displayItemIndexForEvent(a);this._isMouseDown&&this.set("activeIndex",a);return YES},mouseOut:function(){this._isMouseDown&&this.set("activeIndex",-1);return YES},triggerItemAtIndex:function(a){a=this.get("displayItems").objectAt(a);var b,c,d,e,f;if(!a[2])return this;e=this.get("allowsEmptySelection");
f=this.get("allowsMultipleSelection");b=a[1];c=d=this.get("value");SC.isArray(c)||(c=[c]);if(f)if(c.indexOf(b)>=0){if(c.get("length")>1||c.objectAt(0)!==b||e)c=c.without(b)}else c=c.concat([b]);else c=e&&c.get("length")===1&&c.objectAt(0)===b?[]:[b];switch(c.get("length")){case 0:c=null;break;case 1:c=c.objectAt(0);break;default:break}b=this.get("itemActionKey");e=this.get("itemTargetKey");var g;f=null;var h=this.getPath("pane.rootResponder");if(b&&(a=this.get("items").objectAt(a[6]))){g=a.get?a.get(b):
a[b];if(e)f=a.get?a.get(e):a[e];h&&h.sendAction(g,f,this,this.get("pane"))}!g&&d!==undefined&&this.set("value",c);(g=this.get("action"))&&h&&h.sendAction(g,this.get("target"),this,this.get("pane"))},acceptsFirstResponder:function(){return SC.SAFARI_FOCUS_BEHAVIOR?NO:this.get("isEnabled")}.property("isEnabled"),willBecomeKeyResponderFrom:function(){if(!this._isFocused){this._isFocused=YES;this.becomeFirstResponder();this.get("isVisibleInWindow")&&this.$()[0].focus()}},willLoseKeyResponderTo:function(){if(this._isFocused)this._isFocused=
NO}});SC._segmented_fetchKeys=function(a){return this.get(a)};SC._segmented_fetchItem=function(a){if(!a)return null;return this.get?this.get(a):this[a]};sc_require("views/button");
SC.SelectView=SC.ButtonView.extend({items:[],itemsBindingDefault:SC.Binding.multiple(),itemTitleKey:null,itemSortKey:null,itemValueKey:null,itemIconKey:null,itemSeparatorKey:"separator",localize:YES,disableSort:YES,classNames:["sc-select-view"],_itemList:[],_currentSelItem:null,_itemIdx:null,value:null,showCheckbox:YES,_defaultVal:null,_defaultTitle:null,_defaultIcon:null,theme:"popup",displayProperties:["icon","value","controlSize","items"],preferMatrix:null,CUSTOM_MENU_ITEM_HEIGHT:20,isSelectedBinding:"*menu.isVisibleInWindow",
positionMenuBelow:NO,lastMenuWidth:null,exampleView:null,customViewMenuOffsetWidth:0,needsEllipsis:YES,menuPaneHeightPadding:0,menuItemPadding:35,leftAlign:function(){var a=0,b=this.get("controlSize");if(b===SC.SMALL_CONTROL_SIZE)a=-14;if(b===SC.REGULAR_CONTROL_SIZE)a=-16;return a}.property("controlSize"),sortObjects:function(a){if(!this.get("disableSort")){var b=this.get("itemSortKey")||this.get("itemTitleKey");a=a.sort(function(c,d){if(b){c=c.get?c.get(b):c[b];d=d.get?d.get(b):d[b]}return c<d?-1:
c>d?1:0})}return a},render:function(a,b){arguments.callee.base.apply(this,arguments);var c,d,e,f,g,h,j,k,l,m,n,o,r,u,q;c=this.get("items");c=this.sortObjects(c);d=this.get("itemTitleKey");e=this.get("itemIconKey");f=this.get("itemValueKey");g=this.get("itemSeparatorKey");h=this.get("showCheckbox");j=this.get("value");k=this.get("localize");m=[];n=YES;o=0;c.forEach(function(s){if(s){r=d?s.get?s.get(d):s[d]:s.toString();r=k?r.loc():r;u=e?s.get?s.get(e):s[e]:null;if(SC.none(s[e]))u=null;q=f?s.get?s.get(f):
s[f]:s;if(!SC.none(j)&&!SC.none(q))if(j===q){this.set("title",r);this.set("icon",u)}if(q===this.get("value")){this.set("_itemIdx",o);n=!h?NO:YES}else n=NO;l=g?s.get?s.get(g):s[g]:NO;if(o===0){this._defaultVal=q;this._defaultTitle=r;this._defaultIcon=u}s=SC.Object.create({separator:l,title:r,icon:u,value:q,isEnabled:YES,checkbox:n,action:this.displaySelectedItem});m.push(s)}o+=1;this.set("_itemList",m)},this);b&&this.invokeLast(function(){var s=this.get("value");if(SC.none(s)){this.set("value",this._defaultVal);
this.set("title",this._defaultTitle);this.set("icon",this._defaultIcon)}});this.changeSelectButtonPreferMatrix(this._itemIdx)},_action:function(){var a,b,c,d,e,f;a=this.$(".sc-button-label")[0];b=this.get("layer").offsetWidth;c=a.scrollWidth;d=this.get("lastMenuWidth");if(c){a=a.offsetWidth;if(c&&a)b=b+c-a}if(!d||b>d)d=b;b=this.get("_itemList");c=this.get("customViewClassName");this.get("customViewMenuOffsetWidth");a="sc-view sc-pane sc-panel sc-palette sc-picker sc-menu select-button sc-scroll-view sc-menu-scroll-view sc-container-view menuContainer sc-button-view sc-menu-item sc-regular-size";
a=c?a+" "+c:a;SC.prepareStringMeasurement("",a);c=0;for(a=b.length;c<a;++c){e=b.objectAt(c);e=SC.measureString(e.title).width;if(!f||e>f)f=e}SC.teardownStringMeasurement();d=f+this.menuItemPadding>d?f+this.menuItemPadding:d;f=SC.RootResponder.responder.get("currentWindowSize").width;if(d>f)d=f-25;this.set("lastMenuWidth",d);f=this.get("_currentSelItem");b=this.get("_itemList");c=this.get("controlSize");a=this.get("menuPaneHeightPadding");e=this.get("exampleView");d=SC.MenuPane.create({classNames:["select-button"],
items:b,exampleView:e?e:SC.MenuItemView,isEnabled:YES,menuHeightPadding:a,preferType:SC.PICKER_MENU,itemHeightKey:"height",layout:{width:d},controlSize:c,itemWidth:d,contentView:SC.View.extend({})});if(!d)return NO;d.popup(this,this.preferMatrix);d.set("currentSelectedMenuItem",f);return YES},displaySelectedItem:function(){var a,b,c,d,e=0,f,g,h=null;a=this.parentMenu();b=a.get("currentSelectedMenuItem");c=a.menuItemViews;if(b&&c)e=c.indexOf(b);c=a.get("anchor");f=a.get("items");for(g=f.length;!h&&
--g>=0;){d=f[g];a=!SC.none(d.title)?d.title:f.toString();d=!SC.none(d.value)?d.value:a;if(a===this.get("value")&&e===g){h=f;c.set("value",d);c.set("title",a)}}c.set("icon",this.get("icon")).set("_currentSelItem",b).set("_itemIdx",e)},changeSelectButtonPreferMatrix:function(){var a=0,b=this.get("_itemIdx"),c=this.get("leftAlign");if(this.get("positionMenuBelow")){a=[c,4,3];this.set("preferMatrix",a)}else{if(b)a=b*this.CUSTOM_MENU_ITEM_HEIGHT;a=[c,-a,2];this.set("preferMatrix",a)}},mouseDown:function(){if(!this.get("isEnabled"))return YES;
this.set("isActive",YES);this._isMouseDown=YES;this.becomeFirstResponder();this._action();return YES},keyDown:function(a){if(this.interpretKeyEvents(a))return YES;else arguments.callee.base.apply(this,arguments)},interpretKeyEvents:function(a){if(a)if(a.keyCode===38||a.keyCode===40)this._action();else a.keyCode===27&&this.resignFirstResponder();return arguments.callee.base.apply(this,arguments)}});
SC.SelectFieldView=SC.FieldView.extend({tagName:"select",classNames:["sc-select-field-view"],objects:[],objectsBindingDefault:SC.Binding.multiple(),nameKey:null,sortKey:null,valueKey:null,emptyName:null,localize:false,cpDidChange:YES,disableSort:NO,validateMenuItem:function(){return true},sortObjects:function(a){if(!this.get("disableSort")){var b=this.get("sortKey")||this.get("nameKey");a=a.sort(function(c,d){if(b){c=c.get?c.get(b):c[b];d=d.get?d.get(b):d[b]}return c<d?-1:c>d?1:0})}return a},render:function(a,
b){if(this.get("cpDidChange")){this.set("cpDidChange",NO);var c=this.get("nameKey"),d=this.get("valueKey"),e=this.get("objects"),f=this.get("value"),g,h,j=this.get("localize");if(!d&&f)f=SC.guidFor(f);if(f===null||f==="")f="***";if(e){e=this.sortObjects(e);if(!b){h=this.$input()[0];h.innerHTML=""}var k=this.get("emptyName");if(k){if(j)k=k.loc();if(b)a.push('<option value="***">'+k+"</option>",'<option disabled="disabled"></option>');else{g=document.createElement("option");g.value="***";g.innerHTML=
k;h.appendChild(g);g=document.createElement("option");g.disabled="disabled";h.appendChild(g)}}e.forEach(function(l){if(l){var m=c?l.get?l.get(c):l[c]:l.toString();if(j)m=m.loc();if(l=d?l.get?l.get(d):l[d]:l)l=SC.guidFor(l)?SC.guidFor(l):l.toString();var n=this.validateMenuItem&&this.validateMenuItem(l,m)?"":'disabled="disabled" ';if(b)a.push("<option "+n+'value="'+l+'">'+m+"</option>");else{g=document.createElement("option");g.value=l;g.innerHTML=m;if(n.length>0)g.disable="disabled";h.appendChild(g)}}else if(b)a.push('<option disabled="disabled"></option>');
else{g=document.createElement("option");g.disabled="disabled";h.appendChild(g)}},this);this.setFieldValue(f)}else this.set("value",null)}},displayProperties:["objects","nameKey","valueKey"],_objectsObserver:function(){this.set("cpDidChange",YES)}.observes("objects"),_nameKeyObserver:function(){this.set("cpDidChange",YES)}.observes("nameKey"),_valueKeyObserver:function(){this.set("cpDidChange",YES)}.observes("valueKey"),$input:function(){return this.$()},mouseDown:function(a){if(this.get("isEnabled"))return arguments.callee.base.apply(this,
arguments);else{a.stop();return YES}},getFieldValue:function(){var a=arguments.callee.base.apply(this,arguments),b=this.get("valueKey"),c=this.get("objects"),d,e;if(a=="***")a=null;else if(a&&c){var f=SC.typeOf(c.length)===SC.T_FUNCTION?c.length():c.length;for(d=null;!d&&--f>=0;){e=c.objectAt?c.objectAt(f):c[f];if(b)e=e.get?e.get(b):e[b];var g=e?SC.guidFor(e)?SC.guidFor(e):e.toString():null;if(a==g)d=e}}return b||d?d:a},setFieldValue:function(a){a=SC.none(a)?"":a?SC.guidFor(a)?SC.guidFor(a):a.toString():
null;this.$input().val(a);return this},fieldDidFocus:function(){this.get("isFocused")||this.set("isFocused",true)},fieldDidBlur:function(){this.get("isFocused")&&this.set("isFocused",false)},_isFocusedObserver:function(){this.$().setClass("focus",this.get("isFocused"))}.observes("isFocused"),didCreateLayer:function(){var a=this.$input();if(this.get("isEnabled")===false)this.$()[0].disabled=true;SC.Event.add(a,"blur",this,this.fieldDidBlur);SC.Event.add(a,"focus",this,this.fieldDidFocus);return arguments.callee.base.apply(this,
arguments)},willDestroyLayer:function(){var a=this.$input();SC.Event.remove(a,"focus",this,this.fieldDidFocus);SC.Event.remove(a,"blur",this,this.fieldDidBlur);return arguments.callee.base.apply(this,arguments)}});
SC.SliderView=SC.View.extend(SC.Control,{classNames:"sc-slider-view",handleSelector:"img.sc-handle",value:0.5,valueBindingDefault:SC.Binding.single().notEmpty(),minimum:0,minimumBindingDefault:SC.Binding.single().notEmpty(),contentMinimumKey:null,maximum:1,maximumBindingDefault:SC.Binding.single().notEmpty(),contentMaximumKey:null,step:0.1,displayProperties:"value minimum maximum".w(),render:function(a,b){arguments.callee.base.apply(this,arguments);var c=this.get("minimum"),d=this.get("maximum"),
e=this.get("value"),f=this.get("step");e=Math.min(Math.max(e,c),d);if(!SC.none(f)&&f!==0)e=Math.round(e/f)*f;if(e!==0)e=Math.floor((e-c)/(d-c)*100);b?a.push('<span class="sc-inner">','<span class="sc-leftcap"></span>','<span class="sc-rightcap"></span>','<img src="',SC.BLANK_IMAGE_URL,'" class="sc-handle" style="left: ',e,'%" />',"</span>"):this.$(this.get("handleSelector")).css("left",e+"%")},_isMouseDown:NO,mouseDown:function(a){if(!this.get("isEnabled"))return YES;this.set("isActive",YES);this._isMouseDown=
YES;return this._triggerHandle(a)},mouseDragged:function(a){return this._isMouseDown?this._triggerHandle(a):YES},mouseUp:function(a){this._isMouseDown&&this.set("isActive",NO);a=this._isMouseDown?this._triggerHandle(a):YES;this._isMouseDown=NO;return a},_triggerHandle:function(a){var b=this.get("frame").width,c=this.get("minimum"),d=this.get("maximum"),e=this.get("step"),f=this.get("value");a=this.convertFrameFromView({x:a.pageX}).x;a=Math.max(Math.min(a,b-8),8)-8;b-=16;a/=b;a=c+(d-c)*a;if(e!==0)a=
Math.round(a/e)*e;Math.abs(f-a)>=0.01&&this.set("value",a);return YES},acceptsFirstResponder:function(){return SC.SAFARI_FOCUS_BEHAVIOR?NO:this.get("isEnabled")}.property("isEnabled"),willBecomeKeyResponderFrom:function(){if(!this._isFocused){this._isFocused=YES;this.becomeFirstResponder();this.get("isVisibleInWindow")&&this.$()[0].focus()}},willLoseKeyResponderTo:function(){if(this._isFocused)this._isFocused=NO},keyDown:function(a){if(a.which===9){var b=a.shiftKey?this.get("previousValidKeyView"):
this.get("nextValidKeyView");b?b.becomeFirstResponder():a.allowDefault();return YES}if(a.which===37||a.which===38||a.which===39||a.which===40){b=this.get("minimum");var c=this.get("maximum"),d=this.get("step"),e=c-b,f=0;if(a.which===37||a.which===38)if(d===0)if(e<100)f=this.get("value")-1;else{Math.abs(e/100);f=this.get("value")-Math.abs(e/100)}else f=this.get("value")-d;if(a.which===39||a.which===40)if(d===0)if(e<100)f=this.get("value")+2;else{a=Math.abs(e/100);if(a<2)a=2;f=this.get("value")+a}else f=
this.get("value")+d;f>=b&&f<=c&&this.set("value",f)}SC.RunLoop.begin().end();return YES},contentPropertyDidChange:function(a,b){a=this.get("content");this.beginPropertyChanges().updatePropertyFromContent("value",b,"contentValueKey",a).updatePropertyFromContent("minimum",b,"contentMinimumKey",a).updatePropertyFromContent("maximum",b,"contentMaximumKey",a).updatePropertyFromContent("isIndeterminate",b,"contentIsIndeterminateKey",a).endPropertyChanges()}});sc_require("mixins/collection_group");sc_require("views/disclosure");
SC.SourceListGroupView=SC.View.extend(SC.Control,SC.CollectionGroup,{classNames:["sc-source-list-group"],content:null,isGroupVisible:YES,hasGroupTitle:YES,groupTitleKey:null,groupVisibleKey:null,render:function(a){a.push('<div role="button" class="sc-source-list-label sc-disclosure-view sc-button-view button disclosure no-disclosure">','<img src="'+SC.BLANK_IMAGE_URL+'" class="button" />','<span class="label"></span></div>')},createChildViews:function(){},contentPropertyDidChange:function(a,b){var c=
this.get("content");a=this.outlet("labelView");if(c===null){a.setIfChanged("isVisible",NO);this.setIfChanged("hasGroupTitle",NO)}else{a.setIfChanged("isVisible",YES);this.setIfChanged("hasGroupTitle",YES);var d=this.getDelegateProperty("groupTitleKey",this.displayDelegate);if(b=="*"||d&&b==d){d=c&&c.get&&d?c.get(d):c;if(d!=this._title){if(this._title=d)d=d.capitalize();a.set("title",d)}}d=this.getDelegateProperty("groupVisibleKey",this.displayDelegate);if(b=="*"||d&&b==d)if(d){a.removeClassName("no-disclosure");
b=c&&c.get?!!c.get(d):YES;if(b!=this.get("isGroupVisible")){this.set("isGroupVisible",b);a.set("value",b)}}else a.addClassName("no-disclosure")}},disclosureValueDidChange:function(a){if(a!=this.get("isGroupVisible")){var b=this.get("content"),c=this.getDelegateProperty("groupVisibleKey",this.displayDelegate);b&&b.set&&c&&b.set(c,a);this.set("isGroupVisible",a);this.owner&&this.owner.updateChildren&&this.owner.updateChildren(true)}},labelView:SC.DisclosureView.extend({value:YES,_valueObserver:function(){this.owner&&
this.owner.disclosureValueDidChange(this.get("value"))}.observes("value")})});sc_require("views/list");sc_require("views/source_list_group");SC.BENCHMARK_SOURCE_LIST_VIEW=YES;SC.SourceListView=SC.ListView.extend({classNames:["sc-source-list"],rowHeight:32,selectOnMouseDown:NO,actOnSelect:YES});sc_require("views/split");
SC.SplitDividerView=SC.View.extend({classNames:["sc-split-divider-view"],prepareContext:function(){var a=this.get("splitView");a&&this.set("cursor",a.get("thumbViewCursor"));return arguments.callee.base.apply(this,arguments)},mouseDown:function(a){var b=this.get("splitView");return b?b.mouseDownInThumbView(a,this):arguments.callee.base.apply(this,arguments)},doubleClick:function(a){var b=this.get("splitView");return b?b.doubleClickInThumbView(a,this):arguments.callee.base.apply(this,arguments)}});
sc_require("views/split_divider");SC.RESIZE_BOTH="resize-both";SC.RESIZE_TOP_LEFT="resize-top-left";SC.RESIZE_BOTTOM_RIGHT="resize-bottom-right";
SC.SplitView=SC.View.extend({classNames:["sc-split-view"],displayProperties:["layoutDirection"],delegate:null,layoutDirection:SC.LAYOUT_HORIZONTAL,canCollapseViews:YES,autoresizeBehavior:SC.RESIZE_BOTTOM_RIGHT,defaultThickness:0.5,isSplitView:YES,topLeftView:SC.View,dividerView:SC.SplitDividerView,bottomRightView:SC.View,topLeftThickness:function(){var a=this.get("topLeftView");return a?this.thicknessForView(a):0}.property("topLeftView").cacheable(),bottomRightThickness:function(){var a=this.get("bottomRightView");
return a?this.thicknessForView(a):0}.property("bottomRightView").cacheable(),thumbViewCursor:null,canCollapseView:function(a){return this.invokeDelegateMethod(this.delegate,"splitViewCanCollapse",this,a)},thicknessForView:function(a){var b=this.get("layoutDirection");a=a.get("frame");return b===SC.LAYOUT_HORIZONTAL?a.width:a.height},createChildViews:function(){var a=[],b=["topLeftView","dividerView","bottomRightView"],c,d,e;d=0;for(e=b.length;d<e;++d)if(c=this.get(b[d])){c=this[b[d]]=this.createChildView(c,
{layoutView:this,rootElementPath:[d]});a.push(c)}this.set("childViews",a);return this},updateChildLayout:function(){var a=this.get("topLeftView"),b=this.get("bottomRightView"),c=this.get("dividerView"),d=this.get("layoutDirection"),e=this._desiredTopLeftThickness,f=this.get("dividerThickness");f=!SC.none(f)?f:7;var g=(d===SC.LAYOUT_HORIZONTAL?this.get("frame").width:this.get("frame").height)-f-e,h=this.get("autoresizeBehavior"),j;j=a.get("isCollapsed")||NO;a.setIfChanged("isVisible",!j);j=SC.clone(a.get("layout"));
if(d===SC.LAYOUT_HORIZONTAL){j.top=0;j.left=0;j.bottom=0;switch(h){case SC.RESIZE_BOTH:throw"SC.RESIZE_BOTH is currently unsupported.";case SC.RESIZE_TOP_LEFT:j.right=g+f;delete j.width;break;case SC.RESIZE_BOTTOM_RIGHT:delete j.right;delete j.height;j.width=e;break}}else{j.top=0;j.left=0;j.right=0;switch(h){case SC.RESIZE_BOTH:throw"SC.RESIZE_BOTH is currently unsupported.";case SC.RESIZE_TOP_LEFT:j.bottom=g+f;delete j.height;break;case SC.RESIZE_BOTTOM_RIGHT:delete j.bottom;delete j.width;j.height=
e;break}}a.set("layout",j);if(c){j=SC.clone(c.get("layout"));if(d===SC.LAYOUT_HORIZONTAL){j.width=f;delete j.height;j.top=0;j.bottom=0;switch(h){case SC.RESIZE_BOTH:throw"SC.RESIZE_BOTH is currently unsupported.";case SC.RESIZE_TOP_LEFT:delete j.left;j.right=g;delete j.centerX;delete j.centerY;break;case SC.RESIZE_BOTTOM_RIGHT:j.left=e;delete j.right;delete j.centerX;delete j.centerY;break}}else{delete j.width;j.height=f;j.left=0;j.right=0;switch(h){case SC.RESIZE_BOTH:throw"SC.RESIZE_BOTH is currently unsupported.";
case SC.RESIZE_TOP_LEFT:delete j.top;j.bottom=g;delete j.centerX;delete j.centerY;break;case SC.RESIZE_BOTTOM_RIGHT:j.top=e;delete j.bottom;delete j.centerX;delete j.centerY;break}}c.set("layout",j)}j=b.get("isCollapsed")||NO;b.setIfChanged("isVisible",!j);j=SC.clone(b.get("layout"));if(d===SC.LAYOUT_HORIZONTAL){j.top=0;j.bottom=0;j.right=0;switch(h){case SC.RESIZE_BOTH:throw"SC.RESIZE_BOTH is currently unsupported.";case SC.RESIZE_BOTTOM_RIGHT:j.left=e+f;delete j.width;break;case SC.RESIZE_TOP_LEFT:delete j.left;
j.width=g;break}}else{j.left=0;j.right=0;j.bottom=0;switch(h){case SC.RESIZE_BOTH:throw"SC.RESIZE_BOTH is currently unsupported.";case SC.RESIZE_BOTTOM_RIGHT:j.top=e+f;delete j.height;break;case SC.RESIZE_TOP_LEFT:delete j.top;j.height=g;break}}b.set("layout",j);this.notifyPropertyChange("topLeftThickness").notifyPropertyChange("bottomRightThickness")},renderLayout:function(a,b){if(b||this._recalculateDivider){this.get("thumbViewCursor")||this.set("thumbViewCursor",SC.Cursor.create());var c=this.get("layoutDirection"),
d=this.get("frame"),e=this.$(),f=this.get("defaultThickness"),g=this.get("autoresizeBehavior"),h=this.get("dividerThickness");h=!SC.none(h)?h:7;if(this._recalculateDivider===undefined&&f<1)this._recalculateDivider=YES;else if(this._recalculateDivider)this._recalculateDivider=NO;c=e[0]?c===SC.LAYOUT_HORIZONTAL?e[0].offsetWidth:e[0].offsetHeight:c===SC.LAYOUT_HORIZONTAL?d.width:d.height;if(SC.none(f)||f>0&&f<1)f=Math.floor((c-h)*(f||0.5));this._desiredTopLeftThickness=g===SC.RESIZE_BOTTOM_RIGHT?f:c-
h-f;this._topLeftView=this.get("topLeftView");this._bottomRightView=this.get("bottomRightView");this._topLeftViewThickness=this.thicknessForView(this.get("topLeftView"));this._bottomRightThickness=this.thicknessForView(this.get("bottomRightView"));this._dividerThickness=this.get("dividerThickness");this._layoutDirection=this.get("layoutDirection");this._updateTopLeftThickness(0);this._setCursorStyle();this.updateChildLayout()}arguments.callee.base.apply(this,arguments)},render:function(a){arguments.callee.base.apply(this,
arguments);this._inLiveResize&&this._setCursorStyle();this.get("layoutDirection")===SC.LAYOUT_HORIZONTAL?a.addClass("sc-horizontal"):a.addClass("sc-vertical")},mouseDownInThumbView:function(a,b){var c=this.getPath("pane.rootResponder");if(!c)return NO;c.dragDidStart(this);this._mouseDownX=a.pageX;this._mouseDownY=a.pageY;this._thumbView=b;this._topLeftView=this.get("topLeftView");this._bottomRightView=this.get("bottomRightView");this._topLeftViewThickness=this.thicknessForView(this.get("topLeftView"));
this._bottomRightThickness=this.thicknessForView(this.get("bottomRightView"));this._dividerThickness=this.get("dividerThickness");this._layoutDirection=this.get("layoutDirection");this.beginLiveResize();return this._inLiveResize=YES},mouseDragged:function(a){this._updateTopLeftThickness(this._layoutDirection===SC.LAYOUT_HORIZONTAL?a.pageX-this._mouseDownX:a.pageY-this._mouseDownY);return YES},mouseUp:function(){if(this._inLiveResize===YES){this._thumbView=null;this._inLiveResize=NO;this.endLiveResize();
return YES}return NO},doubleClickInThumbView:function(){var a=this._topLeftView,b=a.get("isCollapsed")||NO;if(!b&&!this.canCollapseView(a)){a=this._bottomRightView;b=a.get("isCollapsed")||NO;if(!b&&!this.canCollapseView(a))return NO}if(b){a===this._topLeftView?this._updateTopLeftThickness(this._uncollapsedThickness):this._updateBottomRightThickness(this._uncollapsedThickness);a._uncollapsedThickness=null}else{this._uncollapsedThickness=this.thicknessForView(a);a===this._topLeftView?this._updateTopLeftThickness(this.topLeftThickness()*
-1):this._updateBottomRightThickness(this.bottomRightThickness()*-1);if(!a.get("isCollapsed"))this._uncollapsedThickness=null}this._setCursorStyle();return true},_updateTopLeftThickness:function(a){var b=this._topLeftView,c=this._bottomRightView,d=this.thicknessForView(b),e=this.thicknessForView(c),f=this._dividerThickness,g=0;a=this._topLeftViewThickness+a;this.canCollapseView(c);var h=a,j=this.get("topLeftMaxThickness"),k=this.get("topLeftMinThickness");b.get("isCollapsed")||(g+=d);c.get("isCollapsed")||
(g+=e);SC.none(j)||(h=Math.min(j,h));SC.none(k)||(h=Math.max(k,h));j=this.get("bottomRightMaxThickness");k=this.get("bottomRightMinThickness");h=g-h;SC.none(j)||(h=Math.min(j,h));SC.none(k)||(h=Math.max(k,h));h=g-h;h=this.invokeDelegateMethod(this.delegate,"splitViewConstrainThickness",this,b,h);h=Math.min(h,g);h=Math.max(0,h);(d=b.get("collapseAtThickness"))||(d=0);e=c.get("collapseAtThickness");e=SC.none(e)?g:g-e;if(a<=d&&this.canCollapseView(b)){j=c.get("maxThickness");if(!j||f+g<=j)h=0}else if(a>=
e&&this.canCollapseView(c)){j=b.get("maxThickness");if(!j||f+g<=j)h=g}if(h!=this.thicknessForView(b)){this._desiredTopLeftThickness=h;b.set("isCollapsed",h===0);c.set("isCollapsed",h>=g);this.updateChildLayout();this.displayDidChange()}},_updateBottomRightThickness:function(a){var b=this._topLeftView,c=this._bottomRightView,d=this.thicknessForView(b),e=this.thicknessForView(c),f=this._dividerThickness,g=0;a=this._topLeftViewThickness+a;this.canCollapseView(c);var h=a,j=this.get("topLeftMaxThickness"),
k=this.get("topLeftMinThickness");b.get("isCollapsed")||(g+=d);c.get("isCollapsed")||(g+=e);SC.none(j)||(h=Math.min(j,h));SC.none(k)||(h=Math.max(k,h));j=this.get("bottomRightMaxThickness");k=this.get("bottomRightMinThickness");h=g-h;SC.none(j)||(h=Math.min(j,h));SC.none(k)||(h=Math.max(k,h));h=g-h;h=this.invokeDelegateMethod(this.delegate,"splitViewConstrainThickness",this,b,h);h=Math.min(h,g);h=Math.max(0,h);(d=b.get("collapseAtThickness"))||(d=0);e=c.get("collapseAtThickness");e=SC.none(e)?g:g-
e;if(a<=d&&this.canCollapseView(b)){j=c.get("maxThickness");if(!j||f+g<=j)h=0}else if(a>=e&&this.canCollapseView(c)){j=b.get("maxThickness");if(!j||f+g<=j)h=g}if(h!=this.thicknessForView(b)){this._desiredTopLeftThickness=h;b.set("isCollapsed",h===0);c.set("isCollapsed",h>=g);this.updateChildLayout();this.displayDidChange()}},_setCursorStyle:function(){var a=this._topLeftView,b=this._bottomRightView,c=this.get("thumbViewCursor"),d=this.thicknessForView(a),e=this.thicknessForView(b);this._layoutDirection=
this.get("layoutDirection");if(a.get("isCollapsed")||d===this.get("topLeftMinThickness")||e==this.get("bottomRightMaxThickness"))c.set("cursorStyle",this._layoutDirection===SC.LAYOUT_HORIZONTAL?"e-resize":"s-resize");else if(b.get("isCollapsed")||d===this.get("topLeftMaxThickness")||e==this.get("bottomRightMinThickness"))c.set("cursorStyle",this._layoutDirection===SC.LAYOUT_HORIZONTAL?"w-resize":"n-resize");else SC.browser.msie?c.set("cursorStyle",this._layoutDirection===SC.LAYOUT_HORIZONTAL?"e-resize":
"n-resize"):c.set("cursorStyle",this._layoutDirection===SC.LAYOUT_HORIZONTAL?"ew-resize":"ns-resize")}.observes("layoutDirection"),splitViewCanCollapse:function(a,b){if(a.get("canCollapseViews")===NO)return NO;if(b.get("canCollapse")===NO)return NO;return YES},splitViewConstrainThickness:function(a,b,c){return c},_forceSplitCalculation:function(){this.updateLayout()}.observes("*pane.isPaneAttached"),viewDidResize:function(){arguments.callee.base.apply(this,arguments);this.notifyPropertyChange("topLeftThickness").notifyPropertyChange("bottomRightThickness")}.observes("layout")});
sc_require("views/collection");
SC.StackedView=SC.CollectionView.extend({classNames:["sc-stacked-view"],layout:{top:0,left:0,right:0,height:1},computeNowShowing:function(){return this.get("allContentIndexes")},updateHeight:function(a){a?this._updateHeight():this.invokeLast(this._updateHeight);return this},_updateHeight:function(){var a=this.get("childViews"),b=a.get("length");if(b===0)a=1;else a=(a=(a=a.objectAt(b-1))?a.get("layer"):null)?a.offsetTop+a.offsetHeight:1;this.adjust("height",a)},didReload:function(){return this.updateHeight()},didCreateLayer:function(){return this.updateHeight()}});
sc_require("views/segmented");SC.TOP_LOCATION="top";SC.TOP_TOOLBAR_LOCATION="top-toolbar";SC.BOTTOM_LOCATION="bottom";
SC.TabView=SC.View.extend({classNames:["sc-tab-view"],displayProperties:["nowShowing"],nowShowing:null,items:[],isEnabled:YES,itemTitleKey:null,itemValueKey:null,itemIsEnabledKey:null,itemIconKey:null,itemWidthKey:null,itemToolTipKey:null,tabHeight:SC.REGULAR_BUTTON_HEIGHT,tabLocation:SC.TOP_LOCATION,userDefaultKey:null,_tab_nowShowingDidChange:function(){var a=this.get("nowShowing");this.get("containerView").set("nowShowing",a);this.get("segmentedView").set("value",a);return this}.observes("nowShowing"),
_tab_saveUserDefault:function(){var a=this.get("nowShowing"),b=this.get("userDefaultKey");b&&SC.userDefaults.set([b,"nowShowing"].join(":"),a)}.observes("nowShowing"),_tab_itemsDidChange:function(){this.get("segmentedView").set("items",this.get("items"));return this}.observes("items"),init:function(){arguments.callee.base.apply(this,arguments);this._tab_nowShowingDidChange()._tab_itemsDidChange()},awake:function(){arguments.callee.base.apply(this,arguments);var a=this.get("userDefaultKey");if(a){a=
[a,"nowShowing"].join(":");a=SC.userDefaults.get(a);SC.none(a)||this.set("nowShowing",a)}},createChildViews:function(){var a=[],b,c=this.get("tabLocation"),d=this.get("tabHeight");b=c===SC.TOP_LOCATION?{top:d/2+1,left:0,right:0,bottom:0}:c===SC.TOP_TOOLBAR_LOCATION?{top:d+1,left:0,right:0,bottom:0}:{top:0,left:0,right:0,bottom:d-1};b=this.containerView=this.createChildView(this.containerView.extend(SC.Border,{layout:b,borderStyle:SC.BORDER_BLACK}));a.push(b);b=c===SC.TOP_LOCATION||c===SC.TOP_TOOLBAR_LOCATION?
{height:d,left:0,right:0,top:0}:{height:d,left:0,right:0,bottom:0};this.segmentedView=this.get("segmentedView").extend({layout:b,_sc_tab_segmented_valueDidChange:function(){var e=this.get("parentView");e&&e.set("nowShowing",this.get("value"));this.set("layerNeedsUpdate",YES);this.invokeOnce(this.updateLayerIfNeeded)}.observes("value"),init:function(){var e=this.get("parentView");e&&SC._TAB_ITEM_KEYS.forEach(function(f){this[f]=e.get(f)},this);return arguments.callee.base.apply(this,arguments)}});
b=this.segmentedView=this.createChildView(this.segmentedView);a.push(b);this.set("childViews",a);return this},containerView:SC.ContainerView,segmentedView:SC.SegmentedView});SC._TAB_ITEM_KEYS="itemTitleKey itemValueKey itemIsEnabledKey itemIconKey itemWidthKey itemToolTipKey".w();
SC.ThumbView=SC.View.extend({classNames:["sc-thumb-view"],isEnabled:YES,isEnabledBindingDefault:SC.Binding.bool(),prepareContext:function(){var a=this.get("splitView");a&&this.set("cursor",a.get("thumbViewCursor"));return arguments.callee.base.apply(this,arguments)},mouseDown:function(a){if(!this.get("isEnabled"))return NO;var b=this.get("splitView");return b?b.mouseDownInThumbView(a,this):arguments.callee.base.apply(this,arguments)}});
SC.ToolbarView=SC.View.extend({classNames:["sc-toolbar-view"],anchorLocation:null,layout:{left:0,height:32,right:0},init:function(){if(this.anchorLocation)this.layout=SC.merge(this.layout,this.anchorLocation);arguments.callee.base.apply(this,arguments)}});
SC.WebView=SC.View.extend(SC.Control,{classNames:"sc-web-view",displayProperties:["value","shouldAutoResize"],shouldAutoResize:NO,render:function(a,b){var c=this.get("value");if(b)a.push('<iframe src="'+c+'" style="position: absolute; width: 100%; height: 100%; border: 0px; margin: 0px; padding: 0p;"></iframe>');else{a=this.$("iframe");a.attr("src","javascript:;");a.attr("src",c)}},didCreateLayer:function(){var a=this.$("iframe");SC.Event.add(a,"load",this,this.iframeDidLoad)},iframeDidLoad:function(){if(this.get("shouldAutoResize")===
YES){var a;if((a=this.$("iframe")[0])&&a.contentWindow)if((a=a.contentWindow)&&a.document&&a.document.documentElement){a=a.document.documentElement;if(SC.browser.isIE){this.$().width(a.scrollWidth+12);this.$().height(a.scrollHeight+5)}else{this.$().width(a.scrollWidth);this.$().height(a.scrollHeight)}}}}});SC.WELL_CONTAINER_PADDING=15;
SC.WellView=SC.ContainerView.extend({classNames:"sc-well-view",contentLayout:{top:SC.WELL_CONTAINER_PADDING,bottom:SC.WELL_CONTAINER_PADDING,left:SC.WELL_CONTAINER_PADDING,right:SC.WELL_CONTAINER_PADDING},createChildViews:function(){var a=this.get("contentView");if(a){a=this.contentView=this.createChildView(a);a.set("layout",this.contentLayout);this.childViews=[a]}},render:function(a,b){b&&a.push("<div class='top-left-edge'></div>","<div class='top-edge'></div>","<div class='top-right-edge'></div>",
"<div class='right-edge'></div>","<div class='bottom-right-edge'></div>","<div class='bottom-edge'></div>","<div class='bottom-left-edge'></div>","<div class='left-edge'></div>","<div class='content-background'></div>");arguments.callee.base.apply(this,arguments)},contentViewDidChange:function(){var a=this.get("contentView");a.set("layout",this.contentLayout);this.replaceContent(a)}.observes("contentView")});tiki.script("sproutcore/desktop:en/ecf7ecda0e8421fbcfcc4ebb8aafd0ff1cc97343/javascript.js");
tiki.register("sproutcore/empty_theme",{scripts:[{url:"/static/sproutcore/empty_theme/en/21c3b7b16d7ef39d60d2651975590828812f3ad9/javascript.js",id:"sproutcore/empty_theme:en/21c3b7b16d7ef39d60d2651975590828812f3ad9/javascript.js"}]});tiki.module("sproutcore/empty_theme:index",function(){});tiki.script("sproutcore/empty_theme:en/21c3b7b16d7ef39d60d2651975590828812f3ad9/javascript.js");
tiki.register("sproutcore",{packages:{"sproutcore/runtime":{scripts:[{url:"/static/sproutcore/runtime/en/4e45a795ad83e4f4a267451bf706cc3fc2658096/javascript.js",id:"sproutcore/runtime:en/4e45a795ad83e4f4a267451bf706cc3fc2658096/javascript.js"}]},"sproutcore/datastore":{scripts:[{url:"/static/sproutcore/datastore/en/eb43c56c9a551db9bba1cd04f29ca1dfb2e47e4c/javascript.js",id:"sproutcore/datastore:en/eb43c56c9a551db9bba1cd04f29ca1dfb2e47e4c/javascript.js"}]},"sproutcore/foundation":{stylesheets:[{url:"/static/sproutcore/foundation/en/a04970954a917ede9918ca06897bc0e1406986d5/stylesheet.css",
id:"sproutcore/foundation:en/a04970954a917ede9918ca06897bc0e1406986d5/stylesheet.css"}],scripts:[{url:"/static/sproutcore/foundation/en/a04970954a917ede9918ca06897bc0e1406986d5/javascript.js",id:"sproutcore/foundation:en/a04970954a917ede9918ca06897bc0e1406986d5/javascript.js"}]},"sproutcore/desktop":{stylesheets:[{url:"/static/sproutcore/desktop/en/ecf7ecda0e8421fbcfcc4ebb8aafd0ff1cc97343/stylesheet.css",id:"sproutcore/desktop:en/ecf7ecda0e8421fbcfcc4ebb8aafd0ff1cc97343/stylesheet.css"}],scripts:[{url:"/static/sproutcore/desktop/en/ecf7ecda0e8421fbcfcc4ebb8aafd0ff1cc97343/javascript.js",
id:"sproutcore/desktop:en/ecf7ecda0e8421fbcfcc4ebb8aafd0ff1cc97343/javascript.js"}]},tiki:{scripts:[{url:"/static/tiki/en/f190e4e36f88857b033c419907d4b704109b7815/javascript.js",id:"tiki:en/f190e4e36f88857b033c419907d4b704109b7815/javascript.js"}]}},depends:["tiki","sproutcore/runtime","sproutcore/datastore","sproutcore/foundation","sproutcore/desktop"],scripts:[{url:"/static/sproutcore/en/b787d076ea5a03a72f4c0bdc1d1b432a40401c0b/javascript.js",id:"sproutcore:en/b787d076ea5a03a72f4c0bdc1d1b432a40401c0b/javascript.js"}]});
tiki.module("sproutcore:index",function(a,b,c){c.exports=a("sproutcore/runtime");a("sproutcore/datastore")});tiki.module("sproutcore:license",function(){});tiki.script("sproutcore:en/b787d076ea5a03a72f4c0bdc1d1b432a40401c0b/javascript.js");tiki.register("bespin",{});
tiki.module("bespin:builtins",function(a,b){b.metadata={bespin:{provides:[{ep:"extensionpoint",name:"extensionpoint",description:"Defines a new extension point",params:[{name:"name",type:"string",description:"the extension point's name",required:true},{name:"description",type:"string",description:"description of what the extension point is for"},{name:"params",type:"array of objects",description:"parameters that provide the metadata for a given extension. Each object should have name and description, minimally. It can also have a 'type' (eg string, pointer, or array) and required to denote whether or not this parameter must be present on the extension."},
{name:"indexOn",type:"string",description:"You can provide an 'indexOn' property                          to name a property of extensions through which you'd                          like to be able to easily look up the extension."},{name:"register",type:"pointer",description:"function that is called when a new extension is discovered. Note that this should be used sparingly, because it will cause your plugin to be loaded whenever a matching plugin appears."},{name:"unregister",type:"pointer",description:"function that is called when an extension is removed. Note that this should be used sparingly, because it will cause your plugin to be loaded whenever a matching plugin appears."}]},
{ep:"extensionpoint",name:"extensionhandler",description:"Used to attach listeners ",params:[{name:"name",type:"string",description:"name of the extension point to listen to",required:true},{name:"register",type:"pointer",description:"function that is called when a new extension is discovered. Note that this should be used sparingly, because it will cause your plugin to be loaded whenever a matching plugin appears."},{name:"unregister",type:"pointer",description:"function that is called when an extension is removed. Note that this should be used sparingly, because it will cause your plugin to be loaded whenever a matching plugin appears."}]},
{ep:"extensionpoint",name:"startup",description:"A function that should be called at startup. This should be used sparingly, as these plugins will be eagerly loaded at the beginning. All that's needed for this extension point is a pointer to a function that takes no arguments.",register:"plugins#startupHandler",params:[{name:"pointer",description:"Pointer to a function that takes no parameters",required:true}]},{ep:"extensionpoint",name:"factory",description:"Provides a factory for singleton components. Each extension needs to provide a name, a pointer and an action. The action can be 'call' (if the pointer refers to a function), 'create' (if the pointer refers to an SC.Object), 'new' (if the pointer refers to a traditional JS object) or 'value' (if the pointer refers to the object itself that is the component).",
indexOn:"name"},{ep:"factory",name:"hub",action:"create",pointer:"util/hub#Hub"},{ep:"extensionpoint",name:"command",description:"Editor commands/actions. TODO: list parameters here."}]}}});
tiki.module("bespin:console",function(a,b){function c(){this._error(arguments)}function d(g){return function(){window.console[g].apply(window.console,arguments)}}a=a("sproutcore/runtime").SC;var e=["log","debug","info","warn","error","assert","dir","dirxml","trace","group","groupCollapsed","groupEnd","time","timeEnd","profile","profileEnd","count"],f={_error:function(){}};window.console&&e.forEach(function(g){if(window.console[g])f[g]=d(g)});e.forEach(function(g){f[g]||(f[g]=c)});if(!window.console)window.console=
b.console;b.console=a.Object.create(f)});
tiki.module("bespin:globals",function(a){var b=a("sproutcore/runtime").SC;(function(){if(!Array.isArray)Array.isArray=function(c){return c&&Object.prototype.toString.call(c)=="[object Array]"};if(!Function.prototype.bind)Function.prototype.bind=function(){var c=Array.prototype.slice.call(arguments),d=this,e=function(){return d.call.apply(d,c.concat(Array.prototype.slice.call(arguments)))};e.name=this.name;e.displayName=this.displayName;e.length=this.length;e.unbound=d;return e};b.Object.prototype.sc_super=
function c(){c.caller.base.apply(this,c.caller.arguments)};b.objectForPropertyPathOriginal=b.objectForPropertyPath;b.objectForPropertyPath=function(c,d,e){e=e==undefined?c.length:e;var f=c.split("#");if(f.length==1)return b.objectForPropertyPathOriginal(c,d,e);c=a(f[0]);if(c!==undefined){e-=f[0].length;return b.objectForPropertyPathOriginal(f[1],c,e)}}})()});tiki.module("bespin:index",function(a,b){b.versionNumber="0.7.3";b.versionCodename="Bryce";b.apiVersion="4"});
tiki.module("bespin:plugins",function(a,b){var c=a("sproutcore/runtime").SC;a("globals");var d=a("promise").Promise,e=a("builtins"),f=a("console").console,g=a("util/util").objectKeys,h=a.loader,j=function(n,o){if(o){o=o.split("#");return{modName:o[0]?n+":"+o[0]:n,objName:o[1]}}},k=function(n){var o=a(n.modName);if(n.objName)return o[n.objName];return o};b.Extension=c.Object.extend({_getPointer:function(n){n=n||"pointer";return j(this._pluginName,this.get(n))},init:function(){this._observers=[]},load:function(n,
o){var r=this._getPointer(o);if(!r){f.error("Extension cannot be loaded because it has no 'pointer'");f.log(this);return null}var u=new d;h.async(this._pluginName).then(function(){c.run(function(){var q=a(r.modName);q=r.objName?q[r.objName]:q;n&&n(q);u.resolve(q)})});return u},observe:function(n,o,r){this._observers.push({plugin:n,callback:o,property:r});this.load(o,r)},getPluginName:function(){return this._pluginName},_getLoaded:function(n){n=this._getPointer(n);return k(n)}});b.ExtensionPoint=c.Object.extend({init:function(){this.extensions=
[];this.handlers=[]},getImplementingPlugins:function(){var n={};this.extensions.forEach(function(r){n[r._pluginName]=true});var o=g(n);o.sort();return o},getDefiningPluginName:function(){return this._pluginName},getByKey:function(n){var o=this.get("indexOn");if(o)for(var r=0;r<this.extensions.length;r++)if(this.extensions[r][o]==n)return this.extensions[r]},register:function(n){this.extensions.push(n);this.handlers.forEach(function(o){o.register&&o.load(function(r){r(n)},"register")})},unregister:function(n){this.extensions.removeObject(n);
this.handlers.forEach(function(o){o.unregister&&o.load(function(r){r(n)},"unregister")})},orderExtensions:function(n){for(var o=[],r,u=0;u<n.length;u++)for(r=0;r!=this.extensions.length;)if(this.extensions[r]._pluginName===n[u]){o.push(this.extensions[r]);this.extensions.splice(r,1)}else r++;this.extensions=o.concat(this.extensions)}});b.Plugin=c.Object.extend({register:function(){var n=this;this.provides.forEach(function(o){n.get("catalog").getExtensionPoint(o.ep,true).register(o)})},unregister:function(){var n=
this;this.provides.forEach(function(o){n.get("catalog").getExtensionPoint(o.ep,true).unregister(o)})},_getObservers:function(){var n={};this.provides.forEach(function(o){f.log("ep: ",o.ep);f.log(o._observers);n[o.ep]=o._observers});return n},_findDependents:function(n,o){var r=this.name,u=this;n.forEach(function(q){if(q!=r){var s=u.catalog.plugins[q];if(s&&s.dependencies)for(dependName in s.dependencies)if(dependName==r&&!o[q]){o[q]={keepModule:false};s._findDependents(n,o)}}})},_cleanup:function(){var n=
this.get("name");this.stylesheets.forEach(function(u){for(var q=document.getElementsByTagName("link"),s=0;s<q.length;s++)if(q[s].href.indexOf(u.url)!=-1){q[s].parentNode.removeChild(q[s]);break}});var o=new RegExp("^"+n+":");l(o,h.scripts);l(o,h.modules,function(u){delete h._factories[u]});l(o,h.stylesheets);l(new RegExp("^"+n+"$"),h.packages);var r=h._promises;delete r.catalog[n];delete r.loads[n];m(o,r.modules);m(o,r.scripts);m(o,r.stylesheets);delete h._catalog[n]},reload:function(n){var o,r;if(this.get("reloadURL")){var u=
this.name,q=this.get("reloadPointer");if(q){q=j(u,q);if(o=k(q))o();else{f.error("Reload function could not be loaded. Aborting reload.");return}}var s={},w=this;this._findDependents(g(this.catalog.plugins),s);var v={pluginName:u,dependents:s};for(r in s){q=this.catalog.plugins[r];if(q.preRefresh){q=j(r,q.preRefresh);if(o=k(q))s[r]=o(v)}}this.unregister();for(r in s)this.catalog.plugins[r].unregister();this._cleanup(u);q=[];var x=h.sandbox,y=x.modules.length,D=[];for(r in s)s[r].keepModule||D.push(new RegExp("^"+
r+":"));for(var K=new RegExp("^"+u+":");--y>=0;){var z=x.modules[y];if(K.exec(z))q.push(z);else for(var p=D.length;--p>=0;)if(D[p].exec(z)){q.push(z);break}}q.length>0&&x.clear.apply(x,q);this.catalog.loadMetadataFromURL(this.reloadURL).then(function(){h.async(u).then(function(){c.run(function(){for(r in s)w.catalog.plugins[r].register();for(r in s)if(s[r].callPointer){var t=j(r,s[r].callPointer);(o=k(t))&&o(v)}n&&n()})})},function(){f.error("Failed to load metadata from "+w.reloadURL)})}}});b.Catalog=
c.Object.extend({init:function(){this.points={};this.plugins={};this.deactivatedPlugins={};this._extensionsOrdering=[];this.getExtensionPoint("extensionpoint",true).set("indexOn","name");this.loadMetadata(e.metadata)},getObject:function(n){n=this.getExtensionByKey("factory",n);if(n!==undefined){var o=n.get("instance");if(o)return o;o=n._getLoaded();var r=n.action;if(r=="call")o=o();else if(r=="create")o=o.create();else if(r=="new")o=new o;else if(r=="value")o=o;else throw new Error("Create action must be call|create|new|value. Found"+
r);n.set("instance",o);return o}},getExtensionPoint:function(n,o){if(o&&this.points[n]===undefined)this.points[n]=b.ExtensionPoint.create({name:n,catalog:this});return this.points[n]},getExtensions:function(n){n=this.getExtensionPoint(n);if(n===undefined)return[];return n.extensions},orderExtensions:function(n){n=n||this._extensionsOrdering;for(name in this.points)this.points[name].orderExtensions(n);this._extensionsOrdering=n},getExtensionsOrdering:function(){return this._extensionsOrdering},getExtensionByKey:function(n,
o){n=this.getExtensionPoint(n);if(n!==undefined)return n.getByKey(o)},_registerExtensionPoint:function(n){var o=this.getExtensionPoint(n.name,true);o.description=n.description;o._pluginName=n._pluginName;o.params=n.params;o.handlers.push(n);n.indexOn&&o.set("indexOn",n.indexOn)},_registerExtensionHandler:function(n){var o=this.getExtensionPoint(n.name,true);o.handlers.push(n);n.register&&n.load(function(r){if(!r)throw n.name+" is not ready";o.extensions.forEach(function(u){r(u)})},"register")},_toposort:function(n){var o=
[],r={},u=function(s){if(!(s in r||!(s in n))){r[s]=true;var w=n[s].dependencies;if(!c.none(w))for(var v in w)u(v);o.push(s)}};for(var q in n)u(q);return o},loadMetadata:function(n){var o=this.plugins;for(pluginName in n)if(!this.deactivatedPlugins[pluginName]){var r=n[pluginName];if(r.errors){f.error("Plugin ",pluginName," has errors:");r.errors.forEach(function(u){f.error(u)});delete n[pluginName]}else{if(r.dependencies)r.depends=g(r.dependencies);h.register(pluginName,r)}}this._toposort(n).forEach(function(u){var q=
n[u],s=!this.deactivatedPlugins[u];q.catalog=this;if(q.provides&&s){s=q.provides;for(var w=0;w<s.length;w++){var v=b.Extension.create(s[w]);v._pluginName=u;s[w]=v;var x=v.ep;if(x=="extensionpoint")this._registerExtensionPoint(v);else x=="extensionhandler"&&this._registerExtensionHandler(v);this.getExtensionPoint(v.ep,true).register(v)}}else q.provides=[];q.name=u;q=b.Plugin.create(q);o[u]=q},this);for(pluginName in n)this._checkLoops(pluginName,o,[]);this.orderExtensions()},loadPlugin:function(n,
o){n=h.async(n);o&&n.then(o,function(r){f.error("Plugin loading canceled: ",r)})},loadMetadataFromURL:function(n,o){var r=new d;c.Request.create({address:n,type:o||"GET"}).notify(0,this,this._metadataFinishedLoading,r).send("");return r},deactivatePlugin:function(n){var o=this.get("plugins")[n];if(o!==undefined){o.unregister();o._cleanup()}this.deactivatedPlugins[n]=true},removePlugin:function(n){var o=this.get("plugins"),r=o[n];if(r==undefined)throw new Error("Attempted to remove plugin "+n+" which does not exist.");
r.unregister();r._cleanup();delete o[n]},getResourceURL:function(n){n=this.plugins[n];if(n!=undefined)return n.resourceURL},_metadataFinishedLoading:function(n,o){if(n.isError){n=n.errorObject.errorValue.rawRequest;var r=new Error(n.responseText+" (Status "+n.status+")");r.xhr=n;o.reject(r)}else{r=n.body();this.loadMetadata(JSON.parse(r));o.resolve({catalog:this,response:n})}},_checkLoops:function(n,o,r){var u=false;r.forEach(function(w){if(n===w){f.error("Circular dependency",n,r);u=true}});if(!u){r.push(n);
if(o[n]){if(o[n].dependencies)for(var q in o[n].dependencies){var s=r.slice();this._checkLoops(q,o,s)}}else f.error("Missing metadata for ",n)}},getPlugins:function(n){var o=[],r=n.onlyType,u=this.get("plugins");for(var q in u){var s=u[q];r&&s.type&&s.type!=r||s.name=="bespin"||o.push(s)}var w=n.sortBy;w||(w=["name"]);o.sort(function(v,x){for(var y=0;y<w.length;y++){var D=w[y];if(v[D]<x[D])return-1;else if(x[D]<v[D])return 1}return 0});return o},loadObjectForPropertyPath:function(n,o){var r=new d,
u=/^([^:]+):([^#]+)#(.*)$/.exec(n);if(u===null)throw new Error("loadObjectForPropertyPath: malformed path: '"+n+"'");u=u[1];if(u===""){if(c.none(o))throw new Error("loadObjectForPropertyPath: no plugin name supplied and no context is present");u=o}h.async(u).then(function(){r.resolve(c.objectForPropertyPath(n))});return r}});var l=function(n,o,r){for(var u=0;u<o.length;)if(n.exec(o[u])){var q=o.splice(u,1);r&&r(q)}else u++},m=function(n,o){for(var r=g(o),u=r.length;--u>0;)n.exec(r[u])&&delete o[r[u]]};
b.catalog=b.Catalog.create();b.startupHandler=function(n){n.load(function(o){o()})};b.getUserPlugins=function(){return b.catalog.getPlugins({onlyType:"user"})}});
tiki.module("bespin:promise",function(a,b){function c(f){delete b._outstanding[f._id];for(b._recent.push(f);b._recent.length>20;)b._recent.shift()}var d=a("bespin:console").console;a("bespin:util/stacktrace");var e=0;b._outstanding=[];b._recent=[];b.Promise=function(){this._status=0;this._value=undefined;this._onSuccessHandlers=[];this._onErrorHandlers=[];this._id=e++;b._outstanding[this._id]=this};b.Promise.prototype.isPromise=true;b.Promise.prototype.then=function(f,g){f!==null&&f!==undefined&&
this._onSuccessHandlers.push(f);g!==null&&g!==undefined&&this._onErrorHandlers.push(g);this._status!==0&&this._callHandlers();return this};b.Promise.prototype.chainPromise=function(f){var g=new b.Promise;g._chainedFrom=this;this.then(function(h){try{g.resolve(f(h))}catch(j){g.reject(j)}},function(h){g.reject(h)});return g};b.Promise.prototype.resolve=function(f){if(this._status!=0){d.groupCollapsed("Promise already closed");d.error("Attempted resolve() with ",f);d.error("Previous status = ",this._status,
", previous value = ",this._value);d.trace();d.groupEnd()}this._status=1;this._value=f;this._callHandlers();c(this);return this};b.Promise.prototype.reject=function(f){if(this._status!=0){d.group("Promise already closed");d.error("Attempted reject() with ",f);d.error("Previous status = ",this._status,", previous value = ",this._value);d.trace();d.groupEnd()}this._status=-1;this._value=f;this._callHandlers();c(this);return this};b.Promise.prototype._callHandlers=function(){if(this._status===0)throw new Error("call handlers in pending");
(this._status===1?this._onSuccessHandlers:this._onErrorHandlers).forEach(function(f){f.call(null,this._value)},this);this._onSuccessHandlers.length=0;this._onErrorHandlers.length=0};b.group=function(f){f instanceof Array||(f=Array.prototype.slice.call(arguments));if(f.length===0)return(new b.Promise).resolve([]);var g=new b.Promise,h=[],j=0,k=function(l){return function(m){h[l]=m;j++;j===f.length&&g.resolve(h)}};f.forEach(function(l,m){l.then(k(m),l.reject)});return g}});
tiki.module("bespin:theme",function(a,b){a=a("sproutcore/runtime").SC;b.coffee={backgroundStyle:"#2A211C",gutterStyle:"#4c4a41",lineNumberColor:"#e5c138",lineNumberFont:"10pt Monaco, Lucida Console, monospace",lineMarkerErrorColor:"#CC4444",lineMarkerWarningColor:"#B8860B",lineMarkerMessageColor:"green",zebraStripeColor:"#2A211C",highlightCurrentLineColor:"#3a312b",editorTextFont:"10pt Monaco, Lucida Console, monospace",editorTextColor:"rgb(230, 230, 230)",editorSelectedTextColor:"rgb(240, 240, 240)",
editorSelectedTextBackground:"#526DA5",cursorStyle:"#879aff",cursorType:"ibeam",unfocusedCursorStrokeStyle:"#FF0033",unfocusedCursorFillStyle:"#73171E",partialNibStyle:"rgba(100, 100, 100, 0.3)",partialNibArrowStyle:"rgba(255, 255, 255, 0.3)",partialNibStrokeStyle:"rgba(150, 150, 150, 0.3)",fullNibStyle:"rgb(100, 100, 100)",fullNibArrowStyle:"rgb(255, 255, 255)",fullNibStrokeStyle:"rgb(150, 150, 150)",scrollTrackFillStyle:"rgba(50, 50, 50, 0.8)",scrollTrackStrokeStyle:"rgb(150, 150, 150)",scrollBarFillStyle:"rgba(0, 0, 0, %a)",
scrollBarFillGradientTopStart:"rgba(90, 90, 90, %a)",scrollBarFillGradientTopStop:"rgba(40, 40, 40, %a)",scrollBarFillGradientBottomStart:"rgba(22, 22, 22, %a)",scrollBarFillGradientBottomStop:"rgba(44, 44, 44, %a)",tabSpace:"#392A25",searchHighlight:"#B55C00",searchHighlightSelected:"#FF9A00",plain:"#bdae9d",keyword:"#42a8ed",string:"#039a0a",comment:"#666666","c-comment":"#666666",punctuation:"#888888",attribute:"#BF9464",test:"rgb(255,0,0)",cdata:"#bdae9d","attribute-value":"#039a0a",tag:"#46a8ed",
color:"#c4646b","tag-name":"#46a8ed",value:"#039a0a",important:"#990000",sizes:"#990000",cssclass:"#BF9464",cssid:"#46a8ed",atom:"#aa4444",variable:"#00cccc",variabledef:"#4422cc",localvariable:"#cc2277",property:"#66bb33",operator:"#88bbff",error:"#FF0000",processing:"#999999",entity:"#AA2222",text:"#00BB00","compile-time-constant":"#776088","predefined-constant":"#33CC33","reserved-language-construct":"#00FF00","predefined-function":"#22FF22","predefined-class":"#22FF22",literal:"#DD4411",identifier:"#22FF22",
func:"#2200FF",type:"#8822FF",decorator:"#2222FF"};b.coffeezebra={};a.mixin(b.coffeezebra,b.coffee);b.coffeezebra.zebraStripeColor="#FFFFFF";b["default"]=b.coffee});
tiki.module("bespin:util/cookie",function(a,b){var c=function(d,e){return d.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,function(f){if(e&&e.indexOf(f)!=-1)return f;return"\\"+f})};b.get=function(d){d=new RegExp("(?:^|; )"+c(d)+"=([^;]*)");return(d=document.cookie.match(d))?decodeURIComponent(d[1]):undefined};b.set=function(d,e,f){f=f||{};if(typeof f.expires=="number"){var g=new Date;g.setTime(g.getTime()+f.expires*24*60*60*1E3);f.expires=g}if(f.expires&&f.expires.toUTCString)f.expires=f.expires.toUTCString();
e=encodeURIComponent(e);d=d+"="+e;var h;for(h in f){d+="; "+h;e=f[h];if(e!==true)d+="="+e}document.cookie=d};b.remove=function(d){b.set(d,"",{expires:-1})};b.isSupported=function(){if(!("cookieEnabled"in navigator)){b.set("__djCookieTest__","CookiesAllowed");navigator.cookieEnabled=b.get("__djCookieTest__")=="CookiesAllowed";navigator.cookieEnabled&&b.remove("__djCookieTest__")}return navigator.cookieEnabled}});
tiki.module("bespin:util/scratchcanvas",function(a,b){var c=a("sproutcore/runtime").SC,d=c.Object.extend({getContext:function(){return document.getElementById("bespin-scratch-canvas").getContext("2d")},init:function(){if(c.none(document.getElementById("bespin-scratch-canvas"))){var f=document.createElement("canvas");f.id="bespin-scratch-canvas";f.width=400;f.height=300;f.style.position="absolute";f.style.top="-10000px";f.style.left="-10000px";document.body.appendChild(f)}},measureStringWidth:function(f,
g){if(c.none(g))g="M";var h=this.getContext();h.save();h.font=f;f=h.measureText(g).width;h.restore();return f}}),e=null;b.get=function(){if(e===null)e=d.create();return e}});
tiki.module("bespin:util/stacktrace",function(a,b){function c(k){for(var l=0;l<k.length;++l){var m=k[l];if(typeof m=="object")k[l]="#object";else if(typeof m=="function")k[l]="#function";else if(typeof m=="string")k[l]='"'+m+'"'}return k.join(",")}function d(){}var e=a("bespin:util/util"),f=function(){if(e.isMozilla)return"firefox";else if(e.isOpera)return"opera";else if(e.isSafari)return"other";try{0()}catch(k){if(k.arguments)return"chrome";if(k.stack)return"firefox";if(window.opera&&!("stacktrace"in
k))return"opera"}return"other"}(),g={chrome:function(k){return k.stack.replace(/^.*?\n/,"").replace(/^.*?\n/,"").replace(/^.*?\n/,"").replace(/^[^\(]+?[\n$]/gm,"").replace(/^\s+at\s+/gm,"").replace(/^Object.<anonymous>\s*\(/gm,"{anonymous}()@").split("\n")},firefox:function(k){var l=k.stack;if(!l){console.log(k);return[]}l=l.replace(/(?:\n@:0)?\s+$/m,"");l=l.replace(/^\(/gm,"{anonymous}(");return l.split("\n")},opera:function(k){k=k.message.split("\n");var l=/Line\s+(\d+).*?script\s+(http\S+)(?:.*?in\s+function\s+(\S+))?/i,
m,n,o;m=4;n=0;for(o=k.length;m<o;m+=2)if(l.test(k[m]))k[n++]=(RegExp.$3?RegExp.$3+"()@"+RegExp.$2+RegExp.$1:"{anonymous}()@"+RegExp.$2+":"+RegExp.$1)+" -- "+k[m+1].replace(/^\s+/,"");k.splice(n,k.length-n);return k},other:function(k){for(var l=/function\s*([\w\-$]+)?\s*\(/i,m=[],n=0,o,r;k&&m.length<10;){o=l.test(k.toString())?RegExp.$1||"{anonymous}":"{anonymous}";r=Array.prototype.slice.call(k.arguments);m[n++]=o+"("+c(r)+")";if(k===k.caller&&window.opera)break;k=k.caller}return m}};d.prototype=
{sourceCache:{},ajax:function(k){var l=this.createXMLHTTPObject();if(l){l.open("GET",k,false);l.setRequestHeader("User-Agent","XMLHTTP/1.0");l.send("");return l.responseText}},createXMLHTTPObject:function(){for(var k,l=[function(){return new XMLHttpRequest},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")}],m=0;m<l.length;m++)try{k=l[m]();this.createXMLHTTPObject=l[m];return k}catch(n){}},
getSource:function(k){k in this.sourceCache||(this.sourceCache[k]=this.ajax(k).split("\n"));return this.sourceCache[k]},guessFunctions:function(k){for(var l=0;l<k.length;++l){var m=k[l],n=/{anonymous}\(.*\)@(\w+:\/\/([-\w\.]+)+(:\d+)?[^:]+):(\d+):?(\d+)?/.exec(m);if(n){var o=n[1];n=n[4];if(o&&n){o=this.guessFunctionName(o,n);k[l]=m.replace("{anonymous}",o)}}}return k},guessFunctionName:function(k,l){try{return this.guessFunctionNameFromLines(l,this.getSource(k))}catch(m){return"getSource failed with url: "+
k+", exception: "+m.toString()}},guessFunctionNameFromLines:function(k,l){for(var m=/function ([^(]*)\(([^)]*)\)/,n=/['"]?([0-9A-Za-z_]+)['"]?\s*[:=]\s*(function|eval|new Function)/,o="",r=0;r<10;++r){o=l[k-r]+o;if(o!==undefined){var u=n.exec(o);if(u)return u[1];else u=m.exec(o);if(u&&u[1])return u[1]}}return"(?)"}};var h=new d,j=[/http:\/\/localhost:4020\/sproutcore.js:/];b.ignoreFramesMatching=function(k){j.push(k)};b.Trace=function(k,l){this._ex=k;this._stack=g[f](k);if(l)this._stack=h.guessFunctions(this._stack)};
b.Trace.prototype.log=function(k){if(k<=0)k=999999999;for(var l=0,m=0;m<this._stack.length&&l<k;m++){var n=this._stack[m],o=true;j.forEach(function(r){if(r.test(n))o=false});if(o){console.debug(n);l++}}}});
tiki.module("bespin:util/util",function(a,b){b.queryToObject=function(g,h){var j={};g=g.split(h||"&");var k=decodeURIComponent;g.forEach(function(l){if(l.length){var m=l.split("=");l=k(m.shift());m=k(m.join("="));if(b.isString(j[l]))j[l]=[j[l]];if(Array.isArray(j[l]))j[l].push(m);else j[l]=m}});return j};b.objectToQuery=function(g){var h=encodeURIComponent,j=[],k={};for(var l in g){var m=g[l];if(m!=k[l]){var n=h(l)+"=";if(m.isArray)for(var o=0;o<m.length;o++)j.push(n+h(m[o]));else j.push(n+h(m))}}return j.join("&")};
var c=0,d={};b.rateLimit=function(g,h,j){if(g){var k=c++;return function(){d[k]&&clearTimeout(d[k]);d[k]=setTimeout(function(){j.apply(h,arguments);delete d[k]},g)}}};b.isString=function(g){return typeof g=="string"||g instanceof String};b.isObject=function(g){return g!==undefined&&(g===null||typeof g=="object"||Array.isArray(g)||b.isFunction(g))};b.isFunction=function(){var g=function(h){var j=typeof h;return h&&(j=="function"||h instanceof Function)&&!h.nodeType};return b.isSafari?function(h){if(typeof h==
"function"&&h=="[object NodeList]")return false;return g(h)}:g}();b.endsWith=function(g,h){if(!g)return false;return g.match(new RegExp(h+"$"))};b.include=function(g,h){return g.indexOf(h)>-1};b.indexOfProperty=function(g,h,j){for(var k=0;k<g.length;k++)if(g[k][h]==j)return k;return null};b.last=function(g){if(Array.isArray(g))return g[g.length-1]};b.shrinkArray=function(g){var h=[],j=true;g.reverse().forEach(function(k){if(!(j&&k===undefined)){j=false;h.push(k)}});return h.reverse()};b.makeArray=
function(g,h){if(g<1)return[];h||(h=" ");for(var j=[],k=0;k<g;k++)j.push(h);return j};b.repeatString=function(g,h){for(var j="",k=0;k<h;k++)j+=g;return j};b.leadingSpaces=function(g){for(var h=0,j=0;j<g.length;j++)if(g[j]==" "||g[j]==""||g[j]===undefined)h++;else return h;return h};b.leadingTabs=function(g){for(var h=0,j=0;j<g.length;j++)if(g[j]=="\t"||g[j]==""||g[j]===undefined)h++;else return h;return h};b.leadingWhitespace=function(g){for(var h=[],j=0;j<g.length;j++)if(g[j]==" "||g[j]=="\t"||g[j]==
""||g[j]===undefined)h.push(g[j]);else return h;return h};b.englishFromCamel=function(g){g.replace(/([A-Z])/g,function(h){return" "+h.toLowerCase()}).trim()};b.OS={LINUX:"LINUX",MAC:"MAC",WINDOWS:"WINDOWS"};a=navigator.userAgent;var e=navigator.appVersion;b.isLinux=e.indexOf("Linux")>=0;b.isWindows=e.indexOf("Win")>=0;b.isWebKit=parseFloat(a.split("WebKit/")[1])||undefined;b.isChrome=parseFloat(a.split("Chrome/")[1])||undefined;b.isMac=e.indexOf("Macintosh")>=0;if(a.indexOf("AdobeAIR")>=0)b.isAIR=
1;var f=Math.max(e.indexOf("WebKit"),e.indexOf("Safari"),0);if(f&&!b.isChrome){b.isSafari=parseFloat(e.split("Version/")[1]);if(!b.isSafari||parseFloat(e.substr(f+7))<=419.3)b.isSafari=2}if(a.indexOf("Gecko")>=0&&!b.isWebKit)b.isMozilla=parseFloat(e);b.getOS=function(){return b.isMac?b.OS.MAC:b.isLinux?b.OS.LINUX:b.OS.WINDOWS};b.contains=document.compareDocumentPosition?function(g,h){return g.compareDocumentPosition(h)&16}:function(g,h){return g!==h&&(g.contains?g.contains(h):true)};b.stopEvent=function(g){g.preventDefault();
g.stopPropagation()};b.randomPassword=function(g){g=g||16;for(var h="",j=0;j<g;j++){var k=Math.floor(Math.random()*62);h+="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890".charAt(k)}return h};b.isEmpty=function(g){for(var h in g)if(g.hasOwnProperty(h))return false;return true};b.isMyProject=function(g){return g.indexOf("+")==-1};b.formatDate=function(g){if(!g)return"Unknown";return g.getDate()+" "+b.formatDate.shortMonths[g.getMonth()]+" "+g.getFullYear()};b.formatDate.shortMonths=
["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];b.objectKeys=Object.keys;if(!b.objectKeys)b.objectKeys=function(g){var h,j=[];for(h in g)g.hasOwnProperty(h)&&j.push(h);return j}});tiki.register("delegate_support",{});
tiki.module("delegate_support:index",function(a,b){a("sproutcore/runtime");b.MultiDelegateSupport={delegates:[],addDelegate:function(c){this.set("delegates",this.get("delegates").concat(c))},notifyDelegates:function(c){for(var d=[this],e=1;e<arguments.length;e++)d.push(arguments[e]);this.get("delegates").forEach(function(f){f.respondsTo(c)&&f[c].apply(f,d)})},removeDelegate:function(c){this.set("delegates",this.get("delegates").filter(function(d){return d!==c}))}}});tiki.register("types",{});
tiki.module("types:basic",function(a,b){var c=a("bespin:plugins").catalog,d=a("bespin:console").console,e=a("bespin:promise").Promise;b.text={isValid:function(f){return typeof f=="string"},toString:function(f){return f},fromString:function(f){return f}};b.number={isValid:function(f){if(isNaN(f))return false;if(f===null)return false;if(f===undefined)return false;if(f===Infinity)return false;return typeof f=="number"},toString:function(f){if(!f)return null;return""+f},fromString:function(f){if(!f)return null;
var g=parseInt(f,10);if(isNaN(g))throw new Error("Can't convert \""+f+'" to a number.');return g}};b.bool={isValid:function(f){return typeof f=="boolean"},toString:function(f){return""+f},fromString:function(f){if(f===null)return null;if(!f.toLowerCase)return!!f;var g=f.toLowerCase();if(g=="true")return true;else if(g=="false")return false;return!!f}};b.object={isValid:function(f){return typeof f=="object"},toString:function(f){return JSON.stringify(f)},fromString:function(f){return JSON.parse(f)}};
b.selection={isValid:function(f,g){if(typeof f!="string")return false;if(!g.data){d.error("Missing data on selection type extension. Skipping");return true}var h=false;g.data.forEach(function(j){if(f==j)h=true});return h},toString:function(f){return f},fromString:function(f){return f},resolveTypeSpec:function(f,g){var h=new e;if(g.data){f.data=g.data;h.resolve()}else if(g.pointer)c.loadObjectForPropertyPath(g.pointer).then(function(j){j=j(g);if(typeof j.then==="function")j.then(function(k){f.data=
k;h.resolve()});else{f.data=j;h.resolve()}},function(j){h.reject(j)});else{d.warn("Missing data/pointer for selection",g);h.resolve()}return h}}});
tiki.module("types:types",function(a,b){function c(g){var h=new f,j=e.getExtensionByKey("type",g.name);j?h.resolve({ext:j,typeSpec:g}):h.reject(new Error("Unknown type: "+g.name));return h}function d(g){if(typeof g==="string")return c({name:g});if(typeof g==="object")if(g.name==="deferred"){var h=new f;b.undeferTypeSpec(g).then(function(j){d(j).then(function(k){h.resolve(k)},function(k){h.reject(k)})});return h}else return c(g);throw new Error("Unknown typeSpec type: "+typeof g);}var e=a("bespin:plugins").catalog;
a("bespin:console");var f=a("bespin:promise").Promise;b.getSimpleName=function(g){if(!g)throw new Error("null|undefined is not a valid typeSpec");if(typeof g=="string")return g;if(typeof g=="object"){if(!g.name)throw new Error("Missing name member to typeSpec");return g.name}throw new Error("Not a typeSpec: "+g);};b.equals=function(g,h){return b.getSimpleName(g)==b.getSimpleName(h)};b.undeferTypeSpec=function(g){var h=new f;if(!g.pointer){h.reject(new Error("Missing deferred pointer"));return h}e.loadObjectForPropertyPath(g.pointer).then(function(j){j=
j(g);typeof j.then==="function"?j.then(function(k){h.resolve(k)},function(k){h.reject(k)}):h.resolve(j)},function(j){h.reject(j)});return h};b.resolveType=function(g){var h=new f;d(g).then(function(j){j.ext.load(function(k){typeof k.resolveTypeSpec==="function"?k.resolveTypeSpec(j.ext,j.typeSpec).then(function(){h.resolve({type:k,ext:j.ext})},function(l){h.reject(l)}):h.resolve({type:k,ext:j.ext})})},function(j){h.reject(j)});return h};b.fromString=function(g,h){var j=new f;b.resolveType(h).then(function(k){j.resolve(k.type.fromString(g,
k.ext))});return j};b.toString=function(g,h){var j=new f;b.resolveType(h).then(function(k){j.resolve(k.type.toString(g,k.ext))});return j};b.isValid=function(g,h){var j=new f;b.resolveType(h).then(function(k){j.resolve(k.type.isValid(g,k.ext))});return j}});tiki.module("types:index",function(){});tiki.register("settings",{});
tiki.module("settings:commands",function(a,b){a("bespin:plugins");var c=a("settings").settings;b.setCommand=function(d,e,f){var g;if(e.setting)if(e.value===undefined)g="<strong>"+e.setting+"</strong> = "+c.get(e.setting);else{g="Setting: <strong>"+e.setting+"</strong> = "+e.value;c.set(e.setting,e.value)}else{d=c._list();g="";d.sort(function(h,j){return h.key<j.key?-1:h.key==j.key?0:1});d.forEach(function(h){g+='<a class="setting" href="https://wiki.mozilla.org/Labs/Bespin/Settings#'+h.key+'" title="View external documentation on setting: '+
h.key+'" target="_blank">'+h.key+"</a> = "+h.value+"<br/>"})}f.done(g)};b.unsetCommand=function(d,e,f){c.resetValue(e.setting);f.done("Reset "+e.setting+" to default: "+c.get(e.setting))}});
tiki.module("settings:cookie",function(a,b){var c=a("bespin:util/cookie");b.CookiePersister=SC.Object.create({loadInitialValues:function(d){d._loadDefaultValues().then(function(){var e=c.get("settings");d._loadFromObject(JSON.parse(e))}.bind(this))},persistValue:function(d){try{var e={};d._getSettingNames().forEach(function(h){e[h]=d.get(h)});var f=JSON.stringify(e);c.set("settings",f)}catch(g){console.error("Unable to JSONify the settings! "+g)}}})});
tiki.module("settings:index",function(a,b){a("bespin:plugins");a=a("memory").MemorySettings;b.settings=a.create()});
tiki.module("settings:memory",function(a,b){var c=a("bespin:plugins").catalog,d=a("bespin:console").console,e=a("bespin:promise").Promise,f=a("bespin:promise").group,g=a("sproutcore/runtime").SC,h=a("types:types");b.addSetting=function(j){a("settings").settings.addSetting(j)};b.getSettings=function(){return c.getExtensions("setting")};b.getTypeSpecFromAssignment=function(j){var k=j.assignments;j="text";if(k){var l=null;k.forEach(function(m){if(m.param.name==="setting")l=m});if(l)if((k=l.value)&&k!==
"")if(k=c.getExtensionByKey("setting",k))j=k.type}return j};b.MemorySettings=g.Object.extend({setPersister:function(j){(this._persister=j)&&j.loadInitialValues(this)},set:function(j,k){var l=c.getExtensionByKey("setting",j);if(!l){d.warn("Setting not defined: ",j,k);return this.superclass("__deactivated__"+j,k)}if(typeof k=="string"&&l.type=="string")return this.superclass(j,k);else{var m=arguments.callee.base,n=false;h.fromString(k,l.type).then(function(o){n=true;m.apply(this,[j,o])}.bind(this),
function(o){d.error("Error setting",j,": ",o)});if(!n){d.warn("About to set string version of ",j,"delaying typed set.");this.superclass(j,k)}}return this},addSetting:function(j){if(j.name){!j.defaultValue===undefined&&d.error("Setting.defaultValue == undefined",j);h.isValid(j.defaultValue,j.type).then(function(k){k||d.warn("!Setting.isValid(Setting.defaultValue)",j);k=this.get("__deactivated__"+j.name)||j.defaultValue;this.set(j.name,k);this.addObserver(j.name,this,function(){this._persistValue(j.name,
this.get(j.name))}.bind(this))}.bind(this),function(k){d.error("Type error ",k," ignoring setting ",j)})}else d.error("Setting.name == undefined. Ignoring.",j)},resetValue:function(j){var k=c.getExtensionByKey("setting",j);k?this.set(j,k.defaultValue):d.log("ignore resetValue on ",j)},resetAll:function(){this._getSettingNames().forEach(function(j){this.resetValue(j)}.bind(this))},_getSettingNames:function(){var j=[];c.getExtensions("setting").forEach(function(k){j.push(k.name)});return j},_list:function(){var j=
[];this._getSettingNames().forEach(function(k){j.push({key:k,value:this.get(k)})}.bind(this));return j},_persistValue:function(j,k){var l=this._persister;l&&l.persistValue(this,j,k)},_loadInitialValues:function(){var j=this._persister;j?j.loadInitialValues(this):this._loadDefaultValues()},_loadDefaultValues:function(){return this._loadFromObject(this._defaultValues())},_loadFromObject:function(j){var k=[],l=function(u){return function(q){this.set(u,q)}};for(var m in j)if(j.hasOwnProperty(m)){var n=
j[m],o=c.getExtensionByKey("setting",m);if(o){n=h.fromString(n,o.type);o=l(m);n.then(o);k.push(n)}}var r=new e;f(k).then(function(){r.resolve()});return r},_saveToObject:function(){var j=[],k={};this._getSettingNames().forEach(function(m){var n=this.get(m),o=c.getExtensionByKey("setting",m);if(o){n=h.toString(n,o.type);n.then(function(r){k[m]=r});j.push(n)}}.bind(this));var l=new e;f(j).then(function(){l.resolve(k)});return l},_defaultValues:function(){var j={};c.getExtensions("setting").forEach(function(k){j[k.name]=
k.defaultValue});return j}})});tiki.register("traits",{});
tiki.module("traits:index",function(a,b){b.Trait=function(){function c(F){var E=function(){throw new Error("Conflicting property: "+F);};p(E.prototype);return p(E)}function d(){return p({value:undefined,enumerable:false,required:true})}function e(F){F=c(F);return v?p({get:F,set:F,enumerable:false,conflict:true}):p({value:F,enumerable:false,conflict:true})}function f(F,E){return F===E?F!==0||1/F===1/E:F!==F&&E!==E}function g(F,E){return F.conflict&&E.conflict?true:F.get===E.get&&F.set===E.set&&f(F.value,
E.value)&&F.enumerable===E.enumerable&&F.required===E.required&&F.conflict===E.conflict}function h(F,E){return p(y(F,E))}function j(F){var E={};z(F,function(H){E[H]=true});return p(E)}function k(F){var E={};z(t(F),function(H){var I=A(F,H);if(I.value===J)I=d(H);else if(typeof I.value==="function"){I.method=true;"prototype"in I.value&&p(I.value.prototype)}else{I.get&&I.get.prototype&&p(I.get.prototype);I.set&&I.set.prototype&&p(I.set.prototype)}E[H]=I});return E}function l(){var F=K(arguments,0),E=
{};z(F,function(H){z(t(H),function(I){var L=H[I];if(D(E,I)&&!E[I].required)L.required||g(E[I],L)||(E[I]=e(I));else E[I]=L})});return p(E)}function m(F,E){var H=j(F),I={};z(t(E),function(L){I[L]=!D(H,L)||E[L].required?E[L]:d(L)});return p(I)}function n(){var F=K(arguments,0),E={};z(F,function(H){z(t(H),function(I){var L=H[I];if(!D(E,I)||E[I].required)E[I]=L})});return p(E)}function o(F,E){var H={};z(t(E),function(I){if(D(F,I)&&!E[I].required){var L=F[I];H[L]=D(H,L)&&!H[L].required?e(L):E[I];D(H,I)||
(H[I]=d(I))}else if(D(H,I))E[I].required||(H[I]=e(I));else H[I]=E[I]});return p(H)}function r(F,E){var H={},I=[];for(var L in F)if(D(F,L))if(F[L])H[L]=F[L];else I.push(L);return o(H,m(I,E))}function u(F,E){var H=G(F),I={};z(t(E),function(L){var M=E[L];if(M.required&&!(L in F))throw new Error("Missing required property: "+L);else if(M.conflict)throw new Error("Remaining conflicting property: "+L);else I[L]="value"in M?M.method?{value:h(M.value,H),enumerable:M.enumerable,configurable:M.configurable,
writable:M.writable}:M:{get:M.get?h(M.get,H):undefined,set:M.set?h(M.set,H):undefined,enumerable:M.enumerable,configurable:M.configurable,writable:M.writable}});B(H,I);return p(H)}function q(F,E){return u(Object.prototype,k(F),E)}function s(F,E){var H=t(F),I=t(E);if(H.length!==I.length)return false;for(var L=0;L<H.length;L++){I=H[L];if(!E[I]||!g(F[I],E[I]))return false}return true}function w(F){return k(F)}var v=!!Object.defineProperty,x=Function.prototype.call,y=Function.prototype.bind?function(F,
E){return Function.prototype.bind.call(F,E)}:function(F,E){function H(){return F.apply(E,arguments)}return H},D=y(x,Object.prototype.hasOwnProperty),K=y(x,Array.prototype.slice),z=Array.prototype.forEach?y(x,Array.prototype.forEach):function(F,E){for(var H=0,I=F.length;H<I;H++)E(F[H])},p=Object.freeze||function(F){return F},t=Object.getOwnPropertyNames||function(F){var E=[];for(var H in F)D(F,H)&&E.push(H);return E},A=Object.getOwnPropertyDescriptor||function(F,E){return{value:F[E],enumerable:true,
writable:true,configurable:true}},C=Object.defineProperty||function(F,E,H){F[E]=H.value},B=Object.defineProperties||function(F,E){for(var H in E)D(E,H)&&C(F,H,E[H])},G=Object.create||function(F,E){function H(){}H.prototype=F||Object.prototype;F=new H;E&&B(F,E);return F};x=Object.getOwnProperties||function(F){var E={};z(t(F),function(H){E[H]=A(F,H)});return E};var J=p({toString:function(){return"<Trait.required>"}});if(!Object.create)Object.create=G;if(!Object.getOwnProperties)Object.getOwnProperties=
x;w.required=p(J);w.compose=p(l);w.resolve=p(r);w.override=p(n);w.create=p(u);w.eqv=p(s);w.object=p(q);return p(w)}()});tiki.register("appsupport",{});
tiki.module("appsupport:controllers/bespin",function(a,b){var c=a("sproutcore/runtime").SC,d=a("traits").Trait,e=a("bespin:promise").Promise,f=d({attach:d.required,detach:function(){}}),g;g=Object.create(Object.prototype,d({_components:null,_componentOrder:null,_loadedComponents:null,_registeredComponents:null,_state:0,_dockView:null,_editorView:null,_environment:null,_themeManager:null,_username:null,_registrationHandlers:{environment:d.create(Object.prototype,d.override(d({attach:function(h){g._environment=
h;g._componentOrder=h.componentOrder;h.paneClass=g.paneClass;var j=new e;h.createPane().then(function(k){g.pane=k;j.resolve()});return j},detach:function(){g.pane=null;g._environment=null}}),f)),theme_manager:d.create(Object.prototype,d.override(d({attach:function(h){g._themeManager=h;h.addPane(g.pane);return h.loadTheme()},detach:function(){_themeManager.removePane(g.pane);g._themeManager=null}}),f)),login_controller:d.create(Object.prototype,d.override(d({_loginController:null,_loginPane:null,_promise:null,
attach:function(h){this._loginController=h;var j=h.get("accepted"),k=h.get("loggedOut");j.add(this.loginControllerAcceptedLogin);k.add(this.loginControllerLoggedOut);this._loginPane=j=a("userident").userIdentPage.get("mainPane");g._themeManager.addPane(j);this._promise=j=new e;c.run(h.showIfNotLoggedIn.bind(h));return j},detach:function(){g._themeManager.removePane(this._loginPane);var h=this._loginController,j=h.get("loggedOut");h=h.get("accepted");j.remove(this.loginControllerLoggedOut);h.remove(this.loginControllerAcceptedLogin);
this._loginController=this._loginPane=null},loginControllerAcceptedLogin:function(h){g._username=h;a("userident").registerUserPlugins();this._promise.resolve();this._promise=null},loginControllerLoggedOut:function(){g._rollback("login_controller");g._username=null;var h=this._loginController;c.run(h.show.bind(h))}}),f)),file_source:d.create(Object.prototype,d.override(d({attach:function(h){var j=a("filesystem").Filesystem;g.files=j.create({source:h.create()});return(new e).resolve()},detach:function(){g.files=
null}}),f)),settings:d.create(Object.prototype,d.override(d({attach:function(){return(new e).resolve()},detach:function(){}}),f)),key_listener:d.create(Object.prototype,d.override(d({_keyListener:null,attach:function(h){var j=g.pane;h=h.create();j.set("defaultResponder",h);this._keyListener=h;return(new e).resolve()},detach:function(){g.pane.set("defaultResponder",null);this._keyListener=null}}),f)),dock_view:d.create(Object.prototype,d.override(d({attach:function(h){h=h.create();g.pane.appendChild(h);
g._dockView=h;return(new e).resolve()},detach:function(){g._dockView.removeFromParent();g._dockView=null}}),f)),command_line:d.create(Object.prototype,d.override(d({_cliView:null,attach:function(h){var j=g._dockView;h=j.addDockedView(h,"bottom");j.appendChild(h);this._cliView=h;return(new e).resolve()},detach:function(){this._cliView.removeFromParent();this._cliView=null}}),f)),social_view:d.create(Object.prototype,d.override(d({_socialView:null,attach:function(h){var j=g._dockView;h=j.addDockedView(h,
"right");j.appendChild(h);this._socialView=h;return(new e).resolve()},detach:function(){this._socialView.removeFromParent();this._socialView=null}}),f)),editor_view:d.create(Object.prototype,d.override(d({attach:function(h){var j=g._dockView;h=j.createCenterView(h);j.set("centerView",h);j.appendChild(h);g._editorView=h;return(new e).resolve()},detach:function(){g._editorView.removeFromParent();g._editorView=null}}),f)),edit_session:d.create(Object.prototype,d.override(d({attach:function(h){var j=
g._editorView,k=j.get("textView"),l=j.get("layoutManager");j=l.get("textStorage");l=l.get("syntaxManager");j=h.Buffer.create({model:j,syntaxManager:l});h=h.EditSession.create();g.session=h;h.set("currentUser",g._username);h.set("currentView",k);h.set("currentBuffer",j);g.loadFile&&h.loadMostRecentOrNew();g._environment.sessionInitialized(h);return(new e).resolve()},detach:function(){g.session=null}}),f))},_attach:function(h){var j=this._registrationHandlers[h].attach;j(this._components[h]).then(this._attached.bind(this))},
_attached:function(){this._state++;var h=this._componentOrder[this._state];h in this._components&&this._attach(h)},_rollback:function(h){for(var j=this._componentOrder.indexOf(h);this._state>j;){this._state--;this._registrationHandlers[this._componentOrder[this._state]].detach()}this._attach(h)},files:null,loadFile:true,pane:null,session:null,paneClass:c.MainPane.extend({layout:{left:0,bottom:0,top:0,right:0}}),init:function(){this._componentOrder=["environment"];this._components={};this._loadedComponents=
{};this._registeredComponents={}},registerAppComponent:function(h){var j=this._registeredComponents,k=h.name;if(!(k in j)){j[k]=true;h.load(function(l){this._loadedComponents[k]=true;this._components[k]=l;this._componentOrder[this._state]===k&&this._attach(k)}.bind(this))}},unregisterAppComponent:function(h){var j=h.name;this._rollback(this._componentOrder[this._componentOrder.indexOf(h.name)-1]);delete this._registeredComponents[j];delete this._components[j]}}));g.init();b.bespinController=g;d=b.bespinController;
b.registerAppComponent=d.registerAppComponent.bind(d);b.unregisterAppComponent=d.unregisterAppComponent.bind(d)});
tiki.module("appsupport:controllers/undomanager",function(a,b){a=a("sproutcore/runtime").SC;b.undoManager=a.Object.create({_redoStack:null,_undoStack:null,_undoOrRedo:function(c,d,e){if(d.length===0)return false;d=d.pop();if(!d.target[c](d.context)){this._redoStack=[];this._undoStack=[];return false}e.push(d);return true},init:function(){this._redoStack=[];this._undoStack=[]},redo:function(){return this._undoOrRedo("redo",this._redoStack,this._undoStack)},registerUndo:function(c,d){this._redoStack=
[];this._undoStack.push({target:c,context:d})},undo:function(){return this._undoOrRedo("undo",this._undoStack,this._redoStack)}});b.undoManagerCommand=function(c,d,e){b.undoManager[e.commandExt.name]()}});tiki.module("appsupport:index",function(){});tiki.register("canon",{});
tiki.module("canon:environment",function(a,b){var c=a("sproutcore/runtime").SC,d=a("bespin:console").console,e=a("appsupport:controllers/bespin").bespinController;b.Environment=c.Object.extend({session:function(){return e.session}.property(),view:function(){var f=this.get("session");if(!f)return null;return f.get("currentView")}.property(),model:function(){var f=this.get("session");if(f)if(f=f.get("currentBuffer"))return f.get("model");else d.error("Session has no current buffer");else d.error("command attempted to get model but there's no session")}.property(),
contexts:function(){var f=this.get("view");if(!f)return[];var g=f.getPath("layoutManager.syntaxManager");f=f.getSelectedRange().start;return g.contextsAtPosition(f)}.property(),file:function(){var f=this.get("session");if(f)if(f=f.get("currentBuffer"))return f.get("file");else d.error("Session has no current buffer");else d.error("command attempted to get file but there's no session")}.property(),buffer:function(){var f=this.get("session");if(f)return f.get("currentBuffer");else d.error("command attempted to get buffer but there's no session")}.property(),
files:function(){return e.files}.property()});b.global=b.Environment.create()});
tiki.module("canon:keyboard",function(a,b){var c=a("sproutcore/runtime").SC,d=a("bespin:plugins").catalog,e=a("bespin:console").console,f=a("settings").settings,g=a("canon:request").Request,h=a("canon:environment"),j=a("bespin:util/stacktrace").Trace;b.buildFlags=function(k,l){l.context=k.get("contexts")[0];return l};a=c.Object.extend({_customKeymappingCache:{states:{}},_commandCodes:function(){var k=this.originalEvent,l=true,m=this.keyCode,n=null,o=null,r="";if(this.keyCode===0&&this.which===0)return false;
if(m){n=c.FUNCTION_KEYS[m];if(!n&&(k.altKey||k.ctrlKey||k.metaKey)){n=c.PRINTABLE_KEYS[m];if(m>47&&m<58)l=k.altKey}if(n){if(k.altKey)r+="alt_";if(k.ctrlKey)r+="ctrl_";if(k.metaKey)r+="meta_"}else if(k.ctrlKey||k.metaKey)return false}if(!n){m=this.which;o=n=String.fromCharCode(m);m=n.toLowerCase();if(k.metaKey){r="meta_";n=m}else n=null}if(this.shiftKey&&n&&l)r+="shift_";if(n)n=r+n;return[n,o]},processKeyEvent:function(k,l,m){k=this._commandCodes.call(k)[0];if(c.none(k))return false;b.buildFlags(h.global,
m);m.isCommandKey=true;return this._matchCommand(k,l,m)},processKeyInput:function(k,l,m){m.isCommandKey=false;return this._matchCommand(k,l,m)},_matchCommand:function(k,l,m){var n=this._findCommandExtension(k,l,m);if(n&&n.commandExt!=="no command"){m.isTextView&&l.resetKeyBuffers();var o=n.commandExt;o.load(function(r){var u=g.create({command:r,commandExt:o});try{r(h.global,n.args,u);return true}catch(q){r=new j(q,true);e.group("Error calling command");e.log("command=",o);e.log("args=",n.args);e.error(q);
r.log(3);e.groupEnd();return false}});return true}return n&&n.commandExt==="no command"?true:false},_buildBindingsRegex:function(k){k.forEach(function(l){if(c.none(l.key))if(c.isArray(l.regex)){l.key=new RegExp("^"+l.regex[1]+"$");l.regex=new RegExp(l.regex.join("")+"$")}else l.regex=new RegExp(l.regex+"$");else l.key=new RegExp("^"+l.key+"$")})},_buildKeymappingRegex:function(k){for(state in k.states)this._buildBindingsRegex(k.states[state]);k._convertedRegExp=true},_findCommandExtension:function(k,
l,m){if(m.isTextView){var n=l._keyState;if(!m.isCommandKey||k.indexOf("alt_")===-1){l._keyBuffer+=k.replace(/ctrl_meta|meta/,"ctrl");l._keyMetaBuffer+=k}var o=[this._customKeymappingCache];o=o.concat(d.getExtensions("keymapping"));for(var r=0;r<o.length;r++)if(!c.none(o[r].states[n])){c.none(o[r]._convertedRegExp)&&this._buildKeymappingRegex(o[r]);var u=this._bindingsMatch(k,m,l,o[r]);if(!c.none(u))return u}}l=d.getExtensions("command");var q=null;n={};k=k.replace(/ctrl_meta|meta/,"ctrl");l.some(function(s){if(this._commandMatches(s,
k,m)){q=s;return true}return false}.bind(this));return c.none(q)?null:{commandExt:q,args:n}},_bindingsMatch:function(k,l,m,n){var o,r=null,u={},q;q=c.none(n.hasMetaKey)?m._keyMetaBuffer:m._keyBuffer;if(k.indexOf("alt_")===0&&l.isCommandKey)q+=k;n.states[m._keyState].some(function(s){if(s.key&&!s.key.test(k))return false;if(s.regex&&!(o=s.regex.exec(q)))return false;if(s.disallowMatches)for(var w=0;w<s.disallowMatches.length;w++)if(o[s.disallowMatches[w]])return true;if(!b.flagsMatch(s.predicates,
l))return false;if(s.exec){r=d.getExtensionByKey("command",s.exec);if(c.none(r))throw new Error("Can't find command "+s.exec+" in state="+m._keyState+", symbolicName="+k);if(s.params){var v;s.params.forEach(function(x){v=!c.none(x.match)&&!c.none(o)?o[x.match]||x.defaultValue:x.defaultValue;if(x.type==="number")v=parseInt(v);u[x.name]=v})}m.resetKeyBuffers()}if(s.then){m._keyState=s.then;m.resetKeyBuffers()}if(c.none(r))r="no command";return true});if(c.none(r))return null;return{commandExt:r,args:u}},
_commandMatches:function(k,l,m){if(!b.flagsMatch(k.predicates,m))return false;var n=k.key;if(!n)return false;if(typeof n==="string"){if(n!=l)return false;return true}if(!n.isArray){n=[n];k.key=n}for(k=0;k<n.length;k++){var o=n[k];if(typeof o==="string"){if(o==l)return true}else if(o.key==l)return b.flagsMatch(o.predicates,m)}return false},_customKeymappingChanged:function(){var k=this._customKeymappingCache=JSON.parse(f.get("customKeymapping"));k.states=k.states||{};for(state in k.states)this._buildBindingsRegex(k.states[state])}.observes("settings:index#settings.customKeymapping")});
b.flagsMatch=function(k,l){if(c.none(k))return true;if(!l)return false;for(var m in k)if(l[m]!==k[m])return false;return true};b.keyboardManager=a.create()});
tiki.module("canon:request",function(a,b){var c=a("sproutcore/runtime").SC,d=a("settings").settings;b.history=c.Object.create({requests:[],trim:function(){for(var e=d.get("historyLength");this.requests.length>e;)this.requests.shiftObject()}.observes(".requests")});b.Request=c.Object.extend({command:undefined,commandExt:undefined,args:undefined,typed:undefined,outputs:undefined,start:undefined,end:undefined,duration:undefined,completed:undefined,error:undefined,_inited:undefined,_init:function(){this.set("_inited",
true);this.outputs=[];this.start=new Date;this.error=this.completed=false;b.history.requests.pushObject(this)},doneWithError:function(e){this.set("error",true).done(e)},async:function(){this.get("_inited")||this._init()},output:function(e){this.get("_inited")||this._init();if(typeof e!=="string")e=e.toString();c.run(function(){this.outputs.pushObject(e)}.bind(this));return this},done:function(e){e&&this.output(e);this.set("completed",true);this.set("end",new Date);this.set("duration",this.get("end").getTime()-
this.get("start").getTime())}})});tiki.module("canon:index",function(){});tiki.register("rangeutils",{});
tiki.module("rangeutils:utils/range",function(a,b){var c=a("sproutcore/runtime").SC;b.addPositions=function(d,e){return{row:d.row+e.row,col:d.col+e.col}};b.cloneRange=function(d){var e=d.start;d=d.end;return{start:{row:e.row,col:e.col},end:{row:d.row,col:d.col}}};b.comparePositions=function(d,e){var f=d.row-e.row;return f===0?d.col-e.col:f};b.equal=function(d,e){return b.comparePositions(d.start,e.start)===0&&b.comparePositions(d.end,e.end)===0};b.extendRange=function(d,e){var f=d.end;return{start:d.start,
end:{row:f.row+e.row,col:f.col+e.col}}};b.intersectRangeSets=function(d,e){d=c.clone(d);e=c.clone(e);for(var f=[];d.length>0&&e.length>0;){var g=d.shift(),h=e.shift(),j=b.comparePositions(g.start,h.start),k=b.comparePositions(g.end,h.end);if(b.comparePositions(g.end,h.start)<0){f.push(g);e.unshift(h)}else if(b.comparePositions(h.end,g.start)<0){f.push(h);d.unshift(g)}else if(j<0){f.push({start:g.start,end:h.start});d.unshift({start:h.start,end:g.end});e.unshift(h)}else if(j===0)if(k<0)e.unshift({start:g.end,
end:h.end});else k>0&&d.unshift({start:h.end,end:g.end});else if(j>0){f.push({start:h.start,end:g.start});d.unshift(g);e.unshift({start:g.start,end:h.end})}}return f.concat(d,e)};b.isZeroLength=function(d){return d.start.row===d.end.row&&d.start.col===d.end.col};b.maxPosition=function(d,e){return b.comparePositions(d,e)>0?d:e};b.normalizeRange=function(d){return this.comparePositions(d.start,d.end)<0?d:{start:d.end,end:d.start}};b.rangeSetBoundaries=function(d){return{start:d[0].start,end:d[d.length-
1].end}};b.toString=function(d){var e=d.start;d=d.end;return"[ %@,%@ %@,%@ ]".fmt(e.row,e.col,d.row,d.col)};b.unionRanges=function(d,e){return{start:d.start.row<e.start.row||d.start.row===e.start.row&&d.start.col<e.start.col?d.start:e.start,end:d.end.row>e.end.row||d.end.row===e.end.row&&d.end.col>e.end.col?d.end:e.end}};b.isPosition=function(d){return!c.none(d)&&!c.none(d.row)&&!c.none(d.col)};b.isRange=function(d){return!c.none(d)&&b.isPosition(d.start)&&b.isPosition(d.end)}});
tiki.module("rangeutils:index",function(){});tiki.register("syntax_manager",{});
tiki.module("syntax_manager:controllers/standardsyntax",function(a,b){var c=a("sproutcore/runtime").SC,d=a("bespin:promise").Promise;b.StandardSyntax=c.Object.extend({_stickySupported:null,_parseActions:function(e){if(c.none(e))return[];return e.split(" ").map(function(f){f=f.split(":");return f.length===1?["transition",f[0]]:f})},_transition:function(e,f){var g=f;e.actions.forEach(function(h){if(h[0]==="transition")g=h[1]});return g},states:null,init:function(){for(var e=null,f=this.get("states"),
g=f.length,h=0;h<g;h++)for(var j=f[h],k=j.length,l=0;l<k;l++){var m=j[l].regex;if(e===null)e=m.sticky!==undefined;if(e)m.sticky=true}this._stickySupported=e},syntaxInfoForLineFragment:function(e,f,g,h,j){var k=new d,l=[],m=this._stickySupported,n=this.get("states");if(j!==null&&j<g.length)g=g.substring(0,j);var o=g.length;for(h=h;h!==o;){var r=m?g:g.substring(h);if(n[f]===undefined)throw new Error('StandardSyntax: no such states "%@"'.fmt(f));for(var u={start:h,state:f},q,s=n[f],w=s.length,v=0;v<
w;v++){q=s[v];var x=q.regex;if(m)x.lastIndex=h;var y=x.exec(r);if(y!==null){r=y[0].length;u.end=h+r;u.tag=q.tag;u.actions=this._parseActions(q.then);q=this._transition(u,f);if(r===0&&q===f)throw new Error("Syntax regex matches the empty string and the state didn't change: "+x.toSource());f=q;break}}if(u.tag===undefined){u.end=h+1;u.tag="plain";u.actions=[]}h!==u.end&&l.push(u);h=u.end}j===null&&l.push({start:h,end:null,state:f,tag:"plain",actions:[]});k.resolve({attrs:l,next:{context:e,state:f}});
return k}})});
tiki.module("syntax_manager:controllers/syntaxdirectory",function(a,b){var c=a("sproutcore/runtime").SC,d=a("bespin:promise").Promise;b.discoveredNewSyntax=function(f){b.syntaxDirectory.registerExtension(f)};var e=c.Object.extend({extension:null,fileExts:null,name:null,init:function(){var f=this.get("extension");this.set("name",f.name);f=f.fileexts;this.set("fileExts",c.none(f)?[]:f)}});b.syntaxDirectory=c.Object.create({_fileExts:{},_syntaxInfo:{},loadSyntax:function(f){f=this._syntaxInfo[f];if(f===
undefined)return null;var g=new d;f.get("extension").load(function(h){g.resolve(h)});return g},registerExtension:function(f){f=e.create({extension:f});var g=f.get("name");this._syntaxInfo[g]=f;var h=this._fileExts;f.get("fileExts").forEach(function(j){h[j]=g})},syntaxForFileExt:function(f){f=this._fileExts[f.toLowerCase()];return c.none(f)?"plain":f}})});
tiki.module("syntax_manager:controllers/syntaxmanager",function(a,b){var c=a("sproutcore/runtime").SC,d=a("bespin:promise"),e=a("utils/array"),f=a("delegate_support").MultiDelegateSupport,g=d.Promise,h=a("rangeutils:utils/range");a("bespin:plugins");var j=a("bespin:console").console,k=a("controllers/syntaxdirectory").syntaxDirectory;b.SyntaxManager=c.Object.extend(f,{_invalidRows:[],_lineAttrInfo:null,_adjustInvalidRowsForDeletion:function(l,m){var n=[];this._invalidRows.forEach(function(o){if(o<=
l)n.push(o);else o>l||o<m||o>=m&&n.push(o-(m-l))});this._invalidRows=n},_adjustInvalidRowsForInsertion:function(l,m){this._invalidRows=this._invalidRows.map(function(n){return n<l?n:n+m-l})},_attrIndexForColumn:function(l,m){l=e.binarySearch(l,m,function(n,o){if(n<o.start)return-1;o=o.end;if(o!==null&&n>=o)return 1;return 0});l===null&&j.error("position not found",position);return l},_attrsToString:function(l){return l.map(function(m){return"%@.%@.%@@%@-%@".fmt(m.context,m.state,m.tag,m.start,m.end)}.bind(this)).join(", ")},
_clearAttrsAtRow:function(l){for(var m=[],n=0;n<2;n++)m.push(this._defaultAttrs());this._lineAttrInfo[l].attrs=m},_deepSyntaxInfoForLine:function(l,m){var n=new g,o=l[0],r=o.context;this._shallowSyntaxInfoForLineFragment(r,o.state,m,0,null).then(function(u){var q=u.attrs;q.forEach(function(v){v.context=r});var s=[{attrs:q,next:u.next}],w=this._innerRangesFromAttrs(q,l[1]);if(w.length===0){s.push({attrs:[{context:null,start:0,end:null}],next:{context:null}});n.resolve(s)}else{u=w.map(function(v){return this._shallowSyntaxInfoForLineFragment(v.context,
v.state,m,v.start,v.end)}.bind(this));d.group(u).then(function(v){var x=v.map(function(D){return D.attrs});for(v=0;v<x.length;v++){var y=w[v].context;x[v].forEach(function(D){D.context=y})}v=this._flattenAttrGroups(x);x=x[x.length-1];x=x[x.length-1];s.push({attrs:v,next:x.end===null?{context:x.context,state:x.state}:{context:null}});n.resolve(s)}.bind(this))}}.bind(this));return n},_defaultAttrs:function(){return[{start:0,end:null,tag:"plain",actions:[]}]},_deleteAttrsInRange:function(l){var m=l.start.row;
l=l.end.row;this._clearAttrsAtRow(m);this._lineAttrInfo.splice(m+1,l-m)},_deleteRange:function(l){if(!h.isZeroLength(l)){this._deleteAttrsInRange(l);var m=l.start.row;this._adjustInvalidRowsForDeletion(m,l.end.row);this._invalidateRow(m)}},_flattenAttrGroups:function(l){var m=[],n=0;l.forEach(function(o){var r=o[0].start;n!==r&&m.push({start:n,end:r,context:null});m.pushObjects(o);n=o[o.length-1].end});n!==null&&m.push({start:n,end:null,context:null});return m},_initialContextChanged:function(){this._reset();
this.notifyDelegates("syntaxManagerInvalidatedSyntax")}.observes("initialContext"),_innerRangesFromAttrs:function(l,m){var n=m.context,o=m.state,r=0,u=[];l.forEach(function(q){q.actions.forEach(function(s){switch(s[0]){case "start":if(n!==null)break;n=s[1];o="start";r=q.end;break;case "stop":if(n!==s[1])break;s=q.start;r!==s&&u.push({context:n,state:o,start:r,end:s});n=null;break}})});n!==null&&u.push({context:n,state:o,start:r,end:null});return u},_insertAttrsIntoRange:function(l){var m=l.start.row,
n=l.end.row;this._clearAttrsAtRow(m);l=this._lineAttrInfo;n=n-m;for(var o=0;o<n;o++){for(var r=[],u=[],q=0;q<2;q++){r.push({context:null});u.push(this._defaultAttrs())}l.splice(m+1,0,{snapshot:r,attrs:u})}},_insertRange:function(l){if(!h.isZeroLength(l)){this._insertAttrsIntoRange(l);var m=l.start.row;this._adjustInvalidRowsForInsertion(m,l.end.row);this._invalidateRow(m)}},_invalidateRow:function(l){var m=this._invalidRows;m.push(l);m.sort(function(n,o){return n-o});this._invalidRows=m.uniq()},_mergeAttrGroups:function(l){var m=
[],n=l[0];l=l[1];for(var o=0,r=0,u=0;u!==null;){var q=n[o],s=l[r];if(s.context!==null){m.push(s);u=s.end;r++;q.end===u&&o++}else{m.push(q);u=q.end;o++;s.end===u&&r++}}return m},_recomputeAttrInfoForRows:function(l,m,n){var o=new g,r=this._lineAttrInfo;if(l===m){o.resolve(l===r.length?l:false);return o}if(c.none(n))n=0;var u=r[l],q=this.getPath("layoutManager.textStorage.lines")[l];this._deepSyntaxInfoForLine(u.snapshot,q).then(function(s){u.attrs=s.map(function(x){return x.attrs});if(l!==r.length-
1){var w=r[l+1],v=w.snapshot;s=s.map(function(x){return x.next});if(this._snapshotsEqual(v,s)){o.resolve(l+1);return}w.snapshot=s}n===50?window.setTimeout(function(){c.run(function(){this._recomputeAttrInfoForRows(l+1,m,0).then(function(x){o.resolve(x)})}.bind(this))}.bind(this),0):this._recomputeAttrInfoForRows(l+1,m,n+1).then(function(x){o.resolve(x)})}.bind(this));return o},_reset:function(){for(var l=[],m=this.getPath("layoutManager.textStorage.lines").length,n=this.get("initialContext"),o=0;o<
m;o++)l.push({snapshot:[o===0?{context:n,state:"start"}:{context:null},{context:null}],attrs:[this._defaultAttrs(),[{context:null,start:0,end:null}]]});this._invalidRows=[0];this._lineAttrInfo=l},_shallowSyntaxInfoForLineFragment:function(l,m,n,o,r){var u=new g;if(l==="plain")u.resolve({attrs:this._defaultAttrs(),next:{context:"plain",state:"start"}});else if(l!==null)k.loadSyntax(l).then(function(q){try{q.syntaxInfoForLineFragment(l,m,n,o,r).then(function(w){u.resolve(w)})}catch(s){j.log("Syntax highlighter ",
l," caused an exception:",s);u.resolve({attrs:this._defaultAttrs(),next:{context:"plain",state:"start"}})}}.bind(this));else{j.log("No syntax context");u.resolve({attrs:this._defaultAttrs(),next:{context:"plain",state:"start"}})}return u},_snapshotsEqual:function(l,m){if(l.length!==m.length)return false;for(var n=0;n<l.length;n++){var o=l[n],r=m[n];if(o.context!==r.context||o.state!==r.state)return false}return true},initialContext:"plain",layoutManager:null,attrsForRows:function(l,m){return this._lineAttrInfo.slice(l,
m).map(function(n){return this._mergeAttrGroups(n.attrs)},this)},contextsAtPosition:function(l){var m=[];this._lineAttrInfo[l.row].attrs.forEach(function(n){var o=this._attrIndexForColumn(n,l.column);n=n[o].context;n!==null&&m.push(n)},this);return m},init:function(){this._reset()},layoutManagerReplacedText:function(l,m){this._deleteRange(l);this._insertRange(m)},setInitialContextFromExt:function(l){this.set("initialContext",k.syntaxForFileExt(l))},toString:function(){return"{ lineAttrInfo: [ %@ ], invalidRows: [ %@ ] }".fmt(this._lineAttrInfo.map(function(l){return"{ (%@) -> (%@) }".fmt(l.snapshot.map(function(m){return m.context+
": "+m.state}).join(", "),l.attrs.map(this._attrsToString.bind(this)).join(", "))}.bind(this)).join(", "),this._invalidRows.join(", "))},updateSyntaxForRows:function(l,m){var n=this._invalidRows,o=n.length,r;for(r=0;r<o;r++){var u=n[r];if(u<m)break}var q=new g;if(r===o)q.resolve({startRow:l,endRow:l});else{for(u=n[r];r<n.length&&n[r]<m;)n.splice(r,1);this._recomputeAttrInfoForRows(u,m).then(function(s){if(s===false){this._invalidateRow(m);s=m}q.resolve({startRow:u,endRow:s})}.bind(this))}return q}})});
tiki.module("syntax_manager:utils/array",function(a,b){a("sproutcore/runtime");b.binarySearch=function(c,d,e){for(var f=0,g=c.length;f<g;){var h=f+(g-f)/2>>0,j=e(d,c[h]);if(j<0)g=h;else if(j>0)f=h+1;else return h}return null}});tiki.module("syntax_manager:index",function(){});tiki.register("text_editor",{});
tiki.module("text_editor:commands/editing",function(a,b){var c=a("settings").settings;a("rangeutils:utils/range");b.backspace=function(e){e.get("view").performBackspaceOrDelete(true)};b.deleteCommand=function(e){e.get("view").performBackspaceOrDelete(false)};b.deleteLines=function(e){if(!e.getPath("model.readOnly")){var f=e.get("view"),g=f.getSelectedRange();f.groupChanges(function(){var h={col:0,row:g.start.row};f.replaceCharacters({start:h,end:{col:0,row:g.end.row+1}},"");f.moveCursorTo(h)})}};
var d=function(e,f){var g=f.getSelectedRange().start,h=g.row;g=g.col;e=/^\s*/.exec(e.get("lines")[h].substring(0,g));f.insertText("\n"+e)};b.insertText=function(e,f){e.get("view").insertText(f.text)};b.newline=function(e){var f=e.get("model");e=e.get("view");d(f,e)};b.joinLines=function(e){var f=e.get("model");if(!f.get("readOnly")){var g=e.get("view");e=g.getSelectedRange();var h=f.get("lines"),j=e.end.row;h.length!=j&&g.groupChanges(function(){g.replaceCharacters({start:{col:h[j].length,row:j},
end:{col:/^\s*/.exec(h[j+1])[0].length,row:j+1}},"")})}};b.openLine=function(e){if(!e.getPath("model.readOnly")){var f=e.get("model");e=e.get("view");var g=e.getSelectedRange().end.row,h=f.get("lines");e.moveCursorTo({row:g,col:h[g].length});d(f,e)}};b.tab=function(e){e=e.get("view");var f=c.get("tabstop"),g=e.getSelectedRange();f=f-g.start.col%f;g="";for(var h=0;h<f;h++)g+=" ";e.insertText(g)}});
tiki.module("text_editor:commands/editor",function(a,b){var c=a("bespin:plugins").catalog,d=a("settings").settings;b.findCommand=function(f,g,h){if("value"in g){f=f.get("view");var j=f.get("searchController"),k=f.getSelectedRange(),l="";j.setSearchText(g.value,false);if(j=j.findNext(k.end,true)){f.setSelection(j,true);f.focus()}else l+="<i>No matches found</i><br>";l+='Searching for "'+g.value+'"';h.done(l)}else{g=c.getObject("clicontroller");SC.none(g)||g.prompt("find ")}};b.findNextCommand=function(f){f=
f.get("view");var g=f.get("searchController"),h=f.getSelectedRange();if(g=g.findNext(h.end,true)){f.setSelection(g,true);f.focus()}};b.findPrevCommand=function(f){f=f.get("view");var g=f.get("searchController"),h=f.getSelectedRange();if(g=g.findPrevious(h.start,true)){f.setSelection(g,true);f.focus()}};b.gotoCommand=function(f,g){if("line"in g){f=f.get("view");f.moveCursorTo({row:g.line-1,col:0});f.focus()}else{g=c.getObject("clicontroller");SC.none(g)||g.prompt("goto ")}};var e=function(f,g){var h=
f.get("view"),j=h.getSelectedCharacters();g=g(j);h=h.getSelectedRange();f.get("model").replaceCharacters(h,g)};b.replaceCommand=function(f,g){e(f,function(h){return h.replace(g.search+"/g",g.replace)})};b.entabCommand=function(f){tabstop=d.get("tabstop");e(f,function(g){return g.replace(" {"+tabstop+"}","\t")})};b.detabCommand=function(f){tabstop=d.get("tabstop");e(f,function(g){return g.replace("\t",(new Array(tabstop+1)).join(" "))})};b.trimCommand=function(f,g){e(f,function(h){h=h.split("\n");
h=h.map(function(j){if(g.side==="left"||g.side==="both")j=j.replace(/^\s+/,"");if(g.side==="right"||g.side==="both")j=j.replace(/\s+$/,"");return j});return h.join("\n")})};b.ucCommand=function(f){e(f,function(g){return g.toUpperCase()})};b.lcCommand=function(f){e(f,function(g){return g.toLowerCase()})}});
tiki.module("text_editor:commands/movement",function(a,b){a("rangeutils:utils/range");b.moveDown=function(h){h.get("view").moveDown()};b.moveLeft=function(h){h.get("view").moveLeft()};b.moveRight=function(h){h.get("view").moveRight()};b.moveUp=function(h){h.get("view").moveUp()};b.selectDown=function(h){h.get("view").selectDown()};b.selectLeft=function(h){h.get("view").selectLeft()};b.selectRight=function(h){h.get("view").selectRight()};b.selectUp=function(h){h.get("view").selectUp()};var c=function(h,
j,k){var l=h.get("view");h=h.get("model").get("lines");var m=l.getSelectedRange();k=k?m.end.row:h.length-1;l.moveCursorTo({row:k,col:h[k].length},j)};b.moveLineEnd=function(h){c(h,false,true)};b.selectLineEnd=function(h){c(h,true,true)};b.moveDocEnd=function(h){c(h,false,false)};b.selectDocEnd=function(h){c(h,true,false)};var d=function(h,j,k){h=h.get("view");var l=h.getSelectedRange();h.moveCursorTo({row:k?l.end.row:0,col:0},j)};b.moveLineStart=function(h){d(h,false,true)};b.selectLineStart=function(h){d(h,
true,true)};b.moveDocStart=function(h){d(h,false,false)};b.selectDocStart=function(h){d(h,true,false)};var e=function(h,j,k,l,m){var n=0,o=false;if(l<0){k--;if(m)n=1}for(;k<j.length&&k>-1;){if(m=h.isDelimiter(j[k]))n++;else o=true;if((m||n>1)&&o)break;k+=l}l<0&&k++;return k},f=function(h,j){var k=h.get("view");h=h.get("model").get("lines");var l=k.getSelectedRange(true).end,m=l.row;l=l.col;var n=h[m],o=false;if(l>=n.length){m++;o=true;if(m<h.length){l=0;n=h[m]}else n=""}l=e(k,n,l,1,o);k.moveCursorTo({row:m,
col:l},j)},g=function(h,j){var k=h.get("view");h=h.get("model").get("lines");var l=k.getSelectedRange(true).end,m=l.row;l=l.col;var n=h[m],o=false;if(l>n.length)l=n.length;else if(l==0){m--;o=true;if(m>-1){n=h[m];l=n.length}else n=""}l=e(k,n,l,-1,o);k.moveCursorTo({row:m,col:l},j)};b.moveNextWord=function(h){f(h,false)};b.selectNextWord=function(h){f(h,true)};b.movePreviousWord=function(h){g(h,false)};b.selectPreviousWord=function(h){g(h,true)};b.selectAll=function(h){h.get("view").selectAll()}});
tiki.module("text_editor:commands/scrolling",function(a,b){b.scrollDocStart=function(c){c.get("view").scrollToPosition({col:0,row:0})};b.scrollDocEnd=function(c){c.get("view").scrollToPosition(c.get("model").range().end)};b.scrollPageDown=function(c){c.get("view").scrollPageDown()};b.scrollPageUp=function(c){c.get("view").scrollPageUp()}});
tiki.module("text_editor:controllers/layoutmanager",function(a,b){var c=a("sproutcore/runtime").SC,d=a("delegate_support").MultiDelegateSupport;a("rangeutils:utils/range");var e=a("syntax_manager:controllers/syntaxmanager").SyntaxManager,f=a("models/textstorage").TextStorage;a=a("bespin:plugins").catalog;b.LayoutManager=c.Object.extend(d,{_maximumWidth:0,_syntaxManagerInitialized:false,_textStorage:null,_textStorageChanged:function(){var g=this._textStorage;c.none(g)||g.removeDelegate(this);var h=
this.get("textStorage");this._textStorage=h;h.addDelegate(this);if(this._syntaxManagerInitialized){var j=g.range();h=h.range();c.none(g)||this.get("syntaxManager").layoutManagerReplacedText(j,h);this._recomputeLayoutForRanges(j,h)}}.observes("textStorage"),characterWidth:8,lineAscent:16,lineHeight:20,margin:{left:5,bottom:6,top:0,right:12},pluginCatalog:a,syntaxManager:e,textLines:null,textStorage:f,theme:{editorTextColor:"rgb(230, 230, 230)",editorTextColor_comment:"rgb(102, 102, 102)",editorTextColor_directive:"rgb(153, 153, 153)",
editorTextColor_error:"rgb(255, 0, 0)",editorTextColor_identifier:"rgb(230, 230, 230)",editorTextColor_keyword:"rgb(66, 168, 237)",editorTextColor_operator:"rgb(136, 187, 255)",editorTextColor_plain:"rgb(230, 230, 230)",editorTextColor_string:"rgb(3, 154, 10)"},_computeInvalidRects:function(g,h){var j=this.characterRectForPosition(g.start),k={x:j.x,y:j.y,width:Number.MAX_VALUE,height:j.height};return g.end.row===h.end.row?[k]:[k,{x:0,y:j.y+this.get("lineHeight"),width:Number.MAX_VALUE,height:Number.MAX_VALUE}]},
_lastCharacterPosition:function(){return{row:this.get("textLines").length-1,col:this._maximumWidth}},_recalculateMaximumWidth:function(){var g=0;this.get("textLines").forEach(function(h){h=h.characters.length;if(g<h)g=h});this._maximumWidth=g},_recomputeEntireLayout:function(){var g=this._textStorage.range();this._recomputeLayoutForRanges(g,g)},_recomputeLayoutForRanges:function(g,h){for(var j=g.start.row,k=g.end.row,l=h.end.row,m=l-j+1,n=this._textStorage.get("lines"),o=this.get("theme").editorTextColor_plain,
r=[],u=0;u<m;u++)r[u]={characters:n[j+u],colors:[{start:0,end:null,color:o}]};this.textLines.replace(j,k-j+1,r);this._recalculateMaximumWidth();this.updateTextRows(j,l+1);this.notifyDelegates("layoutManagerChangedTextAtRow",j);this.notifyDelegates("layoutManagerInvalidatedRects",this._computeInvalidRects(g,h))},boundingRect:function(){return this.rectsForRange({start:{row:0,col:0},end:{row:this.get("textLines").length-1,col:this._maximumWidth}})[0]},characterAtPoint:function(g){var h=this.get("margin"),
j=g.x-h.left,k=g.y-h.top;g=this.get("characterWidth");h=this._textStorage;k=h.clampPosition({row:Math.floor(k/this.get("lineHeight")),col:Math.floor(j/g)});h=h.get("lines")[k.row].length;return c.mixin(k,{partialFraction:j<0||k.col===h?0:j%g/g})},characterRangeForBoundingRect:function(g){var h=this.get("lineHeight"),j=this.get("characterWidth"),k=this.get("margin"),l=g.x-k.left;k=g.y-k.top;return{start:{row:Math.max(Math.floor(k/h),0),col:Math.max(Math.floor(l/j),0)},end:{row:Math.floor((k+g.height-
1)/h),col:Math.floor((l+g.width-1)/j)+1}}},characterRectForPosition:function(g){return this.rectsForRange({start:g,end:{row:g.row,col:g.col+1}})[0]},createSyntaxManager:function(){var g=this.get("syntaxManager").create({layoutManager:this});g.addDelegate(this);this.set("syntaxManager",g);this._syntaxManagerInitialized=true},createTextStorage:function(){this.set("textStorage",this.get("textStorage").create())},init:function(){this.set("textLines",[{characters:"",colors:[{start:0,end:0,color:this.get("theme").editorTextColor}]}]);
this.createTextStorage();this.createSyntaxManager();this._recomputeEntireLayout()},lineRectForRow:function(g){return this.rectsForRange({start:{row:g,col:0},end:{row:g,col:this._maximumWidth}})[0]},rectForPosition:function(g){var h=this.get("margin"),j=this.get("characterWidth"),k=this.get("lineHeight");return{x:h.left+j*g.col,y:h.top+k*g.row,width:j,height:k}},rectsForRange:function(g){var h=this.get("characterWidth"),j=this.get("lineHeight"),k=this._maximumWidth,l=this.get("margin"),m=g.start,n=
g.end;g=m.row;var o=m.col;m=n.row;n=n.col;if(g===m)return[{x:l.left+h*o,y:l.top+j*g,width:h*(n-o),height:j}];var r=[],u;if(o===0)u=g;else{u=g+1;r.push({x:l.left+h*o,y:l.top+j*g,width:h*(k-o),height:j})}if(n===0)g=m-1;else if(n===k)g=m;else{g=m-1;r.push({x:l.left,y:l.top+j*m,width:h*n,height:j})}r.push({x:l.left,y:l.top+j*u,width:h*k,height:j*(g-u+1)});return r},syntaxManagerInvalidatedSyntax:function(){this._recomputeEntireLayout()},textStorageEdited:function(g,h,j){this.get("syntaxManager").layoutManagerReplacedText(h,
j);this._recomputeLayoutForRanges(h,j)},updateTextRows:function(g,h){var j=this.get("textLines");h=this.get("syntaxManager").attrsForRows(g,h);for(var k=this.get("theme"),l=0;l<h.length;l++)j[g+l].colors=h[l].map(function(m){var n=k["editorTextColor_"+m.tag];if(c.none(n))n=k.editorTextColor_plain;return{start:m.start,end:m.end,color:n}})}})});
tiki.module("text_editor:controllers/search",function(a,b){var c=a("sproutcore/runtime").SC;a("rangeutils:utils/range");a("bespin:console");b.EditorSearchController=c.Object.extend({_escapeString:/(\/|\.|\*|\+|\?|\||\(|\)|\[|\]|\{|\}|\\)/g,_findMatchesInString:function(d){var e=[],f=this.get("searchRegExp"),g;for(f.lastIndex=0;;){g=f.exec(d);if(g===null)break;e.push(g);f.lastIndex=g.index+g[0].length}return e},_makeRange:function(d,e){return{start:{row:e,col:d.index},end:{row:e,col:d.index+d[0].length}}},
isRegExp:null,searchRegExp:null,searchText:null,textView:null,setSearchText:function(d,e){this.set("searchRegExp",e?new RegExp(d):new RegExp(d.replace(this._escapeString,"\\$1"),"gi"));this.set("isRegExp",e);this.set("searchText",d)},findNext:function(d,e){var f=this.get("searchRegExp");if(c.none(f))return null;var g=this.get("textView");d=d||g.getSelectedRange().end;g=g.getPath("layoutManager.textStorage.lines");var h;f.lastIndex=d.col;var j;for(j=d.row;j<g.length;j++){h=f.exec(g[j]);if(!c.none(h))return this._makeRange(h,
j)}if(!e)return null;for(j=0;j<=d.row;j++){h=f.exec(g[j]);if(!c.none(h))return this._makeRange(h,j)}return null},findPrevious:function(d,e){var f=this.get("searchRegExp");if(c.none(f))return null;f=this.get("textView");d=d||f.getSelectedRange().start;f=f.getPath("layoutManager.textStorage.lines");var g;g=this._findMatchesInString(f[d.row].substring(0,d.col));if(g.length!==0)return this._makeRange(g[g.length-1],d.row);var h;for(h=d.row-1;h!==-1;h--){g=this._findMatchesInString(f[h]);if(g.length!==
0)return this._makeRange(g[g.length-1],h)}if(!e)return null;for(h=f.length-1;h>=d.row;h--){g=this._findMatchesInString(f[h]);if(g.length!==0)return this._makeRange(g[g.length-1],h)}return null}})});
tiki.module("text_editor:controllers/undo",function(a,b){var c=a("sproutcore/runtime").SC,d=a("bespin:console").console,e=a("appsupport:controllers/undomanager").undoManager;b.EditorUndoController=c.Object.extend({_inTransaction:false,_record:null,textView:null,_beginTransaction:function(){if(this._inTransaction){d.trace();throw new Error("UndoController._beginTransaction() called with a transaction already in place");}this._inTransaction=true;this._record={patches:[]}},_endTransaction:function(){if(!this._inTransaction)throw new Error("UndoController._endTransaction() called without a transaction in place");
e.registerUndo(this,this._record);this._record=null;this._inTransaction=false},_tryApplyingPatches:function(f){var g=this.getPath("textView.layoutManager.textStorage");f.forEach(function(h){g.replaceCharacters(h.oldRange,h.newCharacters)});return true},_undoOrRedo:function(f,g){if(this._inTransaction)throw new Error("UndoController._undoOrRedo() called while in a transaction");if(!this._tryApplyingPatches(f))return false;this.get("textView").setSelection(g,true);return true},init:function(){this._redoStack=
[];this._undoStack=[];this.get("textView").addDelegate(this)},redo:function(f){var g=f.patches.concat();g.reverse();return this._undoOrRedo(g,f.selectionAfter)},textViewBeganChangeGroup:function(f,g){this._beginTransaction();this._record.selectionBefore=g},textViewEndedChangeGroup:function(f,g){this._record.selectionAfter=g;this._endTransaction()},textViewReplacedCharacters:function(f,g,h){if(!this._inTransaction)throw new Error("UndoController.textViewReplacedCharacters() called outside a transaction");
this._record.patches.push({oldCharacters:this._deletedCharacters,oldRange:g,newCharacters:h,newRange:this.getPath("textView.layoutManager.textStorage").resultingRangeForReplacement(g,h.split("\n"))});this._deletedCharacters=null},textViewWillReplaceRange:function(f,g){if(!this._inTransaction)throw new Error("UndoController.textViewWillReplaceRange() called outside a transaction");this._deletedCharacters=this.getPath("textView.layoutManager.textStorage").getCharacters(g)},undo:function(f){return this._undoOrRedo(f.patches.map(function(g){return{oldCharacters:g.newCharacters,
oldRange:g.newRange,newCharacters:g.oldCharacters,newRange:g.oldRange}}),f.selectionBefore)}})});tiki.module("text_editor:mixins/textbuffer",function(a,b){a("sproutcore/runtime");b.TextBuffer={deleteCharacters:function(c){this.replaceCharacters(c,"")},insertCharacters:function(c,d){this.replaceCharacters({start:c,end:c},d)},resultingRangeForReplacement:function(c,d){var e=d.length;c=c.start;return{start:c,end:{row:c.row+e-1,col:(e===1?c.col:0)+d[e-1].length}}}}});
tiki.module("text_editor:mixins/textinput",function(a,b){var c=a("sproutcore/runtime").SC;b.TextInput={_TextInput_composing:false,_TextInput_ignore:false,_TextInput_ignoreBlur:false,_TextInput_textFieldId:undefined,_TextInput_textFieldDom:undefined,_TextInput_wantsFocus:false,_isChrome:!!parseFloat(navigator.userAgent.split("Chrome/")[1]),_TextInput_textFieldChanged:function(){if(!(this._TextInput_composing||this._TextInput_ignore)){var d=this._TextInput_textFieldDom,e=d.value;if(e!=""){d.value="";
this._TextInput_textInserted(e)}}},_TextInput_copy:function(){var d=false;if(this.respondsTo("copy")){c.RunLoop.begin();d=this.copy();c.RunLoop.end()}return d},_TextInput_cut:function(){var d=false;if(this.respondsTo("cut")){c.RunLoop.begin();d=this.cut();c.RunLoop.end()}return d},_TextInput_textInserted:function(d){if(this.respondsTo("textInserted")){c.RunLoop.begin();this.textInserted(d);c.RunLoop.end()}},_TextInput_setValueAndSelect:function(d){var e=this._TextInput_textFieldDom;e.value=d;e.select()},
focusTextInput:function(){if(c.none(this._TextInput_textFieldDom))this._TextInput_wantsFocus=true;else this._TextInput_textFieldDom.focus()},unfocusTextInput:function(){this._TextInput_textFieldDom.blur()},render:function(d,e){arguments.callee.base.apply(this,arguments);if(e){this.get("frame");var f=d.begin("textarea");this._TextInput_textFieldId=c.guidFor(f);f.id(this._TextInput_textFieldId);f.attr("style","position: absolute; z-index: -99999; top: -999px; left: -999px; width: 0px; height: 0px");
f.end()}},didCreateLayer:function(){arguments.callee.base.apply(this,arguments);var d=this.$("#"+this._TextInput_textFieldId)[0];this._TextInput_textFieldDom=d;var e=this;this._TextInput_wantsFocus&&window.setTimeout(this.becomeFirstResponder.bind(this),0);if(c.browser.safari){this._isChrome||d.addEventListener("compositionend",function(k){e._TextInput_textInserted(k.data)},false);d.addEventListener("textInput",function(k){e._TextInput_textInserted(k.data)},false);d.addEventListener("paste",function(k){e._TextInput_textInserted(k.clipboardData.getData("text/plain"));
k.preventDefault()},false)}else{var f=function(){e._TextInput_textFieldChanged()};d.addEventListener("keydown",function(){window.setTimeout(function(){c.run(f)},0)},false);d.addEventListener("keypress",f,false);d.addEventListener("keyup",f,false);d.addEventListener("compositionstart",function(){e._TextInput_composing=true},false);d.addEventListener("compositionend",function(){e._TextInput_composing=false;e._TextInput_textFieldChanged()},false);d.addEventListener("paste",function(){e._TextInput_setValueAndSelect("");
window.setTimeout(function(){e._TextInput_textFieldChanged()},0)},false)}var g=function(k){k=k.type.indexOf("copy")!=-1?e._TextInput_copy():e._TextInput_cut();e._TextInput_setValueAndSelect(k)};if(c.browser.isSafari&&!this._isChrome&&c.browser.isMac){var h=(new Date).getTime(),j=function(k){var l=k.type.indexOf("cut")!=-1;if(!(l&&(new Date).getTime()-h<10)){g(k);if(l)h=(new Date).getTime()}};d.addEventListener("beforecopy",j,false);d.addEventListener("beforecut",j,false)}else{j=false;if(c.browser.isMozilla)j=
function(k){g(k);if(c.browser.isMozilla){e._TextInput_ignore=true;window.setTimeout(function(){e._TextInput_setValueAndSelect("");e._TextInput_ignore=false},0)}};d.addEventListener("copy",j||g,false);d.addEventListener("cut",j||g,false)}d.addEventListener("blur",function(){c.run(function(){e._TextInput_ignoreBlur=true;e.resignFirstResponder();e._TextInput_ignoreBlur=false})},false);d.addEventListener("focus",function(){c.run(function(){e.becomeFirstResponder()})},false)},mouseDown:function(){arguments.callee.base.apply(this,
arguments);window.setTimeout(this.becomeFirstResponder.bind(this),0);return true},willBecomeKeyResponderFrom:function(){arguments.callee.base.apply(this,arguments);this.focusTextInput()},willLoseKeyResponderTo:function(){arguments.callee.base.apply(this,arguments);this._TextInput_ignoreBlur||this.unfocusTextInput()}}});
tiki.module("text_editor:models/textstorage",function(a,b){var c=a("sproutcore/runtime").SC,d=a("delegate_support").MultiDelegateSupport;a=a("mixins/textbuffer").TextBuffer;b.TextStorage=c.Object.extend(d,a,{initialValue:"",lines:null,readOnly:false,clampPosition:function(e){var f=this.get("lines"),g=e.row;if(g<0)return{row:0,col:0};else if(g>=f.length)return this.range().end;return{row:g,col:Math.max(0,Math.min(e.col,f[g].length))}},clampRange:function(e){return{start:this.clampPosition(e.start),
end:this.clampPosition(e.end)}},displacePosition:function(e,f){var g=f>0,h=this.get("lines"),j=h.length;for(f=Math.abs(f);f!==0;f--)if(g){var k=h[e.row].length;if(e.row===j-1&&e.col===k)return e;e=e.col===k?{row:e.row+1,col:0}:{row:e.row,col:e.col+1}}else{if(e.row===0&&e.col==0)return e;if(e.col===0){h=this.get("lines");e={row:e.row-1,col:h[e.row-1].length}}else e={row:e.row,col:e.col-1}}return e},getCharacters:function(e){var f=this.get("lines"),g=e.start,h=e.end;e=g.row;var j=h.row;g=g.col;h=h.col;
if(e===j)return f[e].substring(g,h);return[f[e].substring(g)].concat(f.slice(e+1,j),f[j].substring(0,h)).join("\n")},getValue:function(){return this.get("lines").join("\n")},init:function(){arguments.callee.base.apply(this,arguments);this.set("lines",this.get("initialValue").split("\n"));delete this.initialValue},range:function(){var e=this.get("lines");return{start:{row:0,col:0},end:{row:e.length-1,col:e[e.length-1].length}}},replaceCharacters:function(e,f){if(this.get("readOnly"))throw new Error("Attempt to modify a read-only text storage object");
f=f.split("\n");var g=f.length,h=this.resultingRangeForReplacement(e,f),j=e.start,k=e.end,l=j.row,m=k.row;j=j.col;var n=this.get("lines");f[0]=n[l].substring(0,j)+f[0];f[g-1]+=n[m].substring(k.col);n.replace(l,m-l+1,f);this.notifyDelegates("textStorageEdited",e,h)},setValue:function(e){this.replaceCharacters(this.range(),e)}})});
tiki.module("text_editor:utils/rect",function(a,b){var c=a("sproutcore/runtime").SC;b._distanceFromBounds=function(d,e,f){if(d<e)return d-e;if(d>=f)return d-f;return 0};b.merge=function(d){var e;do{e=false;for(var f=[],g=0;g<d.length;g++){var h=d[g];f.push(h);for(var j=g+1;j<d.length;j++){var k=d[j];if(b.rectsSideBySide(h,k)||b.rectsIntersect(h,k)){d.removeAt(j,1);f[f.length-1]=c.unionRects(h,k);e=true;break}}}d=f}while(e);return d};b.offsetFromRect=function(d,e){return{x:b._distanceFromBounds(e.x,
d.x,c.maxX(d)),y:b._distanceFromBounds(e.y,d.y,c.maxY(d))}};b.rectsIntersect=function(d,e){d=c.intersectRects(d,e);return d.width!==0&&d.height!==0};b.rectsSideBySide=function(d,e){if(d.x==e.x&&d.width==e.width)return d.y<e.y?d.y+d.height==e.y:e.y+e.height==d.y;else if(d.y==e.y&&d.height==e.height)return d.x<e.x?d.x+d.width==e.x:e.x+e.width==d.x;return false}});
tiki.module("text_editor:views/canvas",function(a,b){var c=a("sproutcore/runtime").SC,d=a("utils/rect");b.CanvasView=c.View.extend({_cvCanvasContext:null,_cvCanvasDom:null,_cvCanvasId:null,_cvInvalidRects:null,_cvLastRedrawTime:null,_cvPreviousClippingFrame:null,_cvRedrawTimer:null,_cvClippingFrameChanged:function(){var e=this._cvPreviousClippingFrame,f=this.get("clippingFrame");if(e===null||!c.rectsEqual(f,e)){this._cvPreviousClippingFrame=f;this.clippingFrameChanged()}}.observes("clippingFrame"),
_cvGetContext:function(){if(this._cvCanvasContext===null)this._cvCanvasContext=this._cvCanvasDom.getContext("2d");return this._cvCanvasContext},_cvResizeCanvas:function(){var e=this.getPath("parentView.frame"),f=this._cvCanvasDom;if(!c.none(f)){var g=f.width<e.width,h=f.height<e.height;if(g)f.width=e.width;if(h)f.height=e.height;if(g||h)this.setNeedsDisplay()}},layoutStyle:{left:"0px",top:"0px"},minimumRedrawDelay:1E3/30,clippingFrameChanged:function(){this.setNeedsDisplay()},didCreateLayer:function(){arguments.callee.base.apply(this,
arguments);this._cvCanvasDom=this.$("#"+this._cvCanvasId)[0];this.redraw()},drawRect:function(){},init:function(){arguments.callee.base.apply(this,arguments);this._cvInvalidRects=[];this.get("parentView").addObserver("frame",this,this.parentViewFrameChanged)},parentViewFrameChanged:function(){this._cvResizeCanvas()},redraw:function(){var e=this.get("frame");e.x<0&&this.computeFrameWithParentFrame(null);var f=this._cvGetContext();f.save();f.translate(Math.round(e.x),Math.round(e.y));var g=this.get("clippingFrame");
g={x:Math.round(g.x),y:Math.round(g.y),width:g.width,height:g.height};e=this._cvInvalidRects;e==="all"?this.drawRect(g,f):d.merge(e).forEach(function(h){f.save();h=c.intersectRects(h,g);if(h.width!==0&&h.height!==0){var j=h.x,k=h.y,l=h.width,m=h.height;f.beginPath();f.moveTo(j,k);f.lineTo(j+l,k);f.lineTo(j+l,k+m);f.lineTo(j,k+m);f.closePath();f.clip();this.drawRect(h,f)}f.restore()},this);f.restore();this._cvInvalidRects=[];this._cvLastRedrawTime=(new Date).getTime();return true},render:function(e,
f){arguments.callee.base.apply(this,arguments);if(f){var g=this.getPath("parentView.frame"),h=e.begin("canvas");this._cvCanvasId=c.guidFor(h);h.id(this._cvCanvasId);h.attr("width",""+g.width);h.attr("height",""+g.height);h.push("canvas tag not supported by your browser");h.end()}else this.invokeLater(this.tryRedraw,0)},renderLayout:function(e,f){arguments.callee.base.apply(this,arguments);var g=this.getPath("parentView.frame");if(f){e.attr("width",g.width);e.attr("height",g.height)}},setNeedsDisplay:function(){this._cvInvalidRects=
"all";this.set("layerNeedsUpdate",true)},setNeedsDisplayInRect:function(e){var f=this._cvInvalidRects;f!=="all"&&f.push(e);this.set("layerNeedsUpdate",true)},tryRedraw:function(){var e=(new Date).getTime(),f=this._cvLastRedrawTime,g=this.get("minimumRedrawDelay");if(f===null||e-f>=g)this.redraw();else{e=this._cvRedrawTimer;if(!(e!==null&&e.get("isValid")))this._cvRedrawTimer=c.Timer.schedule({target:this,action:this.redraw,interval:g,repeats:false})}}})});
tiki.module("text_editor:views/editor",function(a,b){var c=a("sproutcore/runtime").SC,d=a("views/gutter").GutterView,e=a("controllers/layoutmanager").LayoutManager,f=a("views/scroll").ScrollView,g=a("views/text").TextView,h=a("controllers/undo").EditorUndoController,j=a("controllers/search").EditorSearchController,k=a("settings").settings,l=a("bespin:util/scratchcanvas");b.EditorView=c.View.extend(c.Border,{_fontChanged:function(){for(var m=k.get("fontsize"),n=l.get(),o=this.layoutManager,r="",u=
0;u<100;u++)r+="M";n=n.measureStringWidth(this.font,r)/100;o.set("characterWidth",n);o.set("lineHeight",Math.floor(m*1.6));o.set("lineAscent",Math.floor(m*1.3));this.layoutManager._recomputeEntireLayout();this.gutterView._recomputeLayout();this.textView.setNeedsDisplay()}.observes("font"),_fontSizeChanged:function(){var m=k.get("fontsize"),n=k.get("fontface");this.set("font",m+"px "+n)}.observes("settings:index#settings.fontsize","settings:index#settings.fontface"),borderStyle:c.BORDER_GRAY,font:"10pt Monaco, Lucida Console, monospace",
gutterView:d,layoutManager:e,scrollView:f,searchController:j,textView:g,undoController:h,_gutterViewFrameChanged:function(){this.get("scrollView").adjust({left:this.getPath("gutterView.frame").width})},_scrollViewVerticalScrollOffsetChanged:function(){this.setPath("gutterView.verticalScrollOffset",this.getPath("scrollView.verticalScrollOffset"))},createChildViews:function(){var m=this.get("layoutManager"),n=this.get("scrollView"),o=this.createChildView(this.get("gutterView"),{editor:this,layoutManager:m});
this.set("gutterView",o);o.addObserver("frame",this,this._gutterViewFrameChanged);var r=this.get("textView");m=this.createChildView(n,{containerView:c.ContainerView.extend({hasCustomScrolling:true}),contentView:r.extend({editor:this,layoutManager:m,searchController:this.get("searchController")}),layout:{left:o.get("frame").width,bottom:0,top:0,right:0}});this.set("scrollView",m);m.addObserver("verticalScrollOffset",this,this._scrollViewVerticalScrollOffsetChanged);n=m.get("contentView");this.set("textView",
n);this.set("undoController",this.get("undoController").create({textView:n}));this.get("searchController").set("textView",n);this.set("childViews",[o,m]);this._fontSizeChanged()},init:function(){this.set("layoutManager",this.get("layoutManager").create());this.set("searchController",this.get("searchController").create());return arguments.callee.base.apply(this,arguments)}})});
tiki.module("text_editor:views/gutter",function(a,b){var c=a("sproutcore/runtime").SC,d=a("views/canvas").CanvasView;a("bespin:util/scratchcanvas");var e=d.extend({theme:{gutterStyle:"#4c4a41",lineNumberColor:"#e5c138"},_frameChanged:function(){this.setNeedsDisplay()}.observes("frame"),drawRect:function(f,g){var h=this.get("theme");g.fillStyle=h.gutterStyle;g.fillRect(f.x,f.y,f.width,f.height);g.save();var j=this.get("parentView"),k=j.get("padding");g.translate(k.left,0);k=j.get("layoutManager");
var l=k.characterRangeForBoundingRect(f);f=Math.min(l.end.row,k.get("textLines").length-1);var m=k.get("lineAscent");g.fillStyle=h.lineNumberColor;g.font=j.get("editor").font;for(h=l.start.row;h<=f;h++)g.fillText(""+(h+1),-0.5,k.lineRectForRow(h).y+m-0.5);g.restore()}});b.GutterView=c.View.extend({_interiorView:null,_computeWidth:function(){var f=this.get("padding");f=f.left+f.right;this.get("theme");var g=this.get("layoutManager"),h=""+g.get("textLines").length;return g.get("characterWidth")*h.length+
f},_frameChanged:function(){this._recomputeLayout()}.observes("frame"),_recomputeLayout:function(){var f=this.get("layoutManager"),g=this.get("padding"),h=this._computeWidth(),j=c.clone(this.get("layout"));if(j.width!==h){j.width=h;this.set("layout",j)}else{j=this.get("frame");this._interiorView.set("layout",{left:0,top:-this.get("verticalScrollOffset"),width:h,height:Math.max(j.height,f.boundingRect().height+g.bottom)})}},_verticalScrollOffsetChanged:function(){this._recomputeLayout()}.observes("verticalScrollOffset"),
layout:{left:0,top:0,bottom:0,width:32},layoutManager:null,padding:{bottom:30,left:5,right:10},theme:{lineNumberFont:"10pt Monaco, Lucida Console, monospace"},verticalScrollOffset:0,createChildViews:function(){var f=this.createChildView(e);this._interiorView=f;this.get("frame");this._recomputeLayout();this.set("childViews",[f])},init:function(){arguments.callee.base.apply(this,arguments);this.get("layoutManager").addDelegate(this)},layoutManagerInvalidatedRects:function(){this._recomputeLayout()}})});
tiki.module("text_editor:views/scroll",function(a,b){a=a("sproutcore/runtime").SC;b.ScrollView=a.ScrollView.extend({_containerViewLaidOut:false,autohidesHorizontalScroller:false,autohidesVerticalScroller:false,borderStyle:a.BORDER_NONE,hasHorizontalScroller:true,hasVerticalScroller:true,horizontalScrollerThickness:17,horizontalScrollerView:a.ScrollerView,verticalScrollerThickness:17,verticalScrollerView:a.ScrollerView,tile:function(){if(!this._containerViewLaidOut){var c=this.get("containerView");
c.adjust({left:0,bottom:0,top:0,right:0});c.updateLayout();this._containerViewLaidOut=true}var d=this.get("horizontalScrollerView"),e=this.get("verticalScrollerView");d=this.get("isHorizontalScrollerVisible");e=this.get("isVerticalScrollerVisible");c=this.get("horizontalScrollerThickness");var f=this.get("verticalScrollerThickness");if(d){d=this.get("horizontalScrollerView");d.set("scrollbarThickness",c);d.set("layout",{left:0,bottom:6,right:6+f,height:c})}if(e){e=this.get("verticalScrollerView");
e.set("scrollbarThickness",f);e.set("layout",{top:0,right:6,bottom:6+c,width:f})}this.get("contentView").get("hasPadding")===true&&this.get("contentView").set("padding",{bottom:c+6,right:f+6})}})});
tiki.module("text_editor:views/text",function(a,b){var c=a("sproutcore/runtime").SC,d=a("views/canvas").CanvasView;a("controllers/layoutmanager");var e=a("delegate_support").MultiDelegateSupport,f=a("rangeutils:utils/range"),g=a("utils/rect"),h=a("mixins/textinput").TextInput,j=a("canon:keyboard").keyboardManager,k=a("settings").settings;b.TextView=d.extend(e,h,{_dragPoint:null,_dragTimer:null,_enclosingScrollView:null,_inChangeGroup:false,_insertionPointBlinkTimer:null,_insertionPointVisible:true,
_keyBuffer:"",_keyMetaBuffer:"",_keyState:"start",_lineAscent:16,_selectedRange:null,_selectedRangeEndVirtual:null,classNames:["text_editor"],_drag:function(){var l=this.convertFrameFromView(this._dragPoint),m=g.offsetFromRect(this.get("clippingFrame"),l);this.moveCursorTo(this._selectionPositionForPoint({x:l.x-m.x,y:l.y-m.y}),true);this.becomeFirstResponder()},_drawInsertionPoint:function(l,m){if(this._insertionPointVisible){l=this._selectedRange;var n=this.get("layoutManager").characterRectForPosition(l.start);
l=Math.floor(n.x);var o=n.y,r=Math.ceil(n.width);n=n.height;m.save();var u=this.get("theme");if(this.get("isFirstResponder")){m.strokeStyle=u.cursorStyle;m.beginPath();m.moveTo(l+0.5,o);m.lineTo(l+0.5,o+n);m.closePath();m.stroke()}else{m.fillStyle=u.unfocusedCursorFillStyle;m.fillRect(l+0.5,o,r,n);m.strokeStyle=u.unfocusedCursorStrokeStyle;m.strokeRect(l+0.5,o+0.5,r-1,n-1)}m.restore()}},_drawLines:function(l,m){var n=this.get("layoutManager"),o=n.get("textLines"),r=n.get("lineAscent");this.get("theme");
m.save();m.font=this.getPath("editor.font");var u=n.characterRangeForBoundingRect(l);l=u.start;u=u.end;for(var q=u.row,s=l.row;s<=q;s++){var w=o[s];if(!c.none(w)){var v=w.characters,x=v.length,y=Math.min(u.col,x),D=l.col;if(!(D>=x)){w=w.colors;for(x=0;D<w[x].start;)x++;for(var K=w[x].start;K!==null&&K<y;){var z=w[x];D=z.end;m.fillStyle=z.color;z=n.characterRectForPosition({row:s,col:K});K=D===null?v.substring(K):v.substring(K,D);m.fillText(K,z.x,z.y+r);K=D;x++}}}}m.restore()},_drawSelectionHighlight:function(l,
m){l=this.get("theme");l=this.get("isFirstResponder")?l.editorSelectedTextBackground:l.unfocusedCursorFillStyle;var n=this.get("layoutManager");m.save();var o=f.normalizeRange(this._selectedRange);m.fillStyle=l;n.rectsForRange(o).forEach(function(r){m.fillRect(r.x,r.y,r.width,r.height)});m.restore()},_drawSelection:function(l,m){this._rangeIsInsertionPoint(this._selectedRange)?this._drawInsertionPoint(l,m):this._drawSelectionHighlight(l,m)},_getVirtualSelection:function(l){return{start:l&&this._selectedRangeEndVirtual?
this._selectedRangeEndVirtual:this._selectedRange.start,end:this._selectedRangeEndVirtual||this._selectedRange.end}},_invalidateSelection:function(){var l=function(o){return{x:o.x-1,y:o.y,width:o.width+2,height:o.height}},m=this.get("layoutManager"),n=f.normalizeRange(this._selectedRange);if(this._rangeIsInsertionPoint(n)){m=m.characterRectForPosition(n.start);this.setNeedsDisplayInRect(l(m))}else m.rectsForRange(n).forEach(function(o){this.setNeedsDisplayInRect(l(o))},this)},_isReadOnly:function(){return this.getPath("layoutManager.textStorage.readOnly")},
_keymappingChanged:function(){this._keyBuffer="";this._keyState="start"},_parentViewChanged:function(){this._updateEnclosingScrollView()}.observes("parentView"),_performVerticalKeyboardSelection:function(l){this.getPath("layoutManager.textStorage");this.moveCursorTo(f.addPositions(this._selectedRangeEndVirtual!==null?this._selectedRangeEndVirtual:this._selectedRange.end,{row:l,col:0}),true,true)},_rangeIsInsertionPoint:function(l){return f.isZeroLength(l)},_rearmInsertionPointBlinkTimer:function(){this._insertionPointVisible||
this.blinkInsertionPoint();this._insertionPointBlinkTimer!==null&&this._insertionPointBlinkTimer.invalidate();this._insertionPointBlinkTimer=c.Timer.schedule({target:this,action:"blinkInsertionPoint",interval:750,repeats:true})},_repositionSelection:function(){var l=this.getPath("layoutManager.textLines"),m=l.length,n=this._selectedRange,o=Math.min(n.start.row,m-1);m=Math.min(n.end.row,m-1);var r=l[m];this.setSelection({start:{row:o,col:Math.min(n.start.col,l[o].characters.length)},end:{row:m,col:Math.min(n.end.col,
r.characters.length)}})},_resize:function(){var l=this.get("layoutManager").boundingRect(),m=this.get("padding"),n=this.getPath("parentView.frame");this.set("layout",c.mixin(c.clone(this.get("layout")),{width:Math.max(n.width,l.width+m.right),height:Math.max(n.height,l.height+m.bottom)}))},_scrollPage:function(l){var m=this._enclosingScrollView;if(!c.none(m)){var n=this.get("clippingFrame");m.scrollTo(n.x,n.y+(n.height+this._lineAscent)*(l?-1:1))}},_scrollWhileDragging:function(){var l=this._enclosingScrollView;
if(!c.none(l)){var m=g.offsetFromRect(this.get("clippingFrame"),this.convertFrameFromView(this._dragPoint));if(!(m.x===0&&m.y===0)){l.scrollBy(m.x,m.y);this._drag()}}},_scrolled:function(){var l=this._enclosingScrollView,m=l.get("horizontalScrollOffset");l=l.get("verticalScrollOffset");this.notifyDelegates("textViewWasScrolled",{x:m,y:l});this._updateSyntax(null)},_selectionPositionForPoint:function(l){l=this.get("layoutManager").characterAtPoint(l);return l.partialFraction<0.5?l:f.addPositions(l,
{row:0,col:1})},_syntaxManagerUpdatedSyntaxForRows:function(l,m){if(l!==m){var n=this.get("layoutManager");n.updateTextRows(l,m);n.rectsForRange({start:{row:l,col:0},end:{row:m,col:0}}).forEach(this.setNeedsDisplayInRect,this)}},_updateEnclosingScrollView:function(){if(!c.none(this._enclosingScrollView)){var l=this._enclosingScrollView;l.removeObserver("horizontalScrollOffset",this,this._scrolled);l.removeObserver("verticalScrollOffset",this,this._scrolled)}for(l=this.get("parentView");!c.none(l)&&
!l.get("isScrollable");)l=l.get("parentView");this._enclosingScrollView=l;if(!c.none(l)){l.addObserver("horizontalScrollOffset",this,this._scrolled);l.addObserver("verticalScrollOffset",this,this._scrolled)}},_updateSyntax:function(l){var m=this.get("layoutManager"),n=m.characterRangeForBoundingRect(this.get("clippingFrame")),o=n.start.row;n=n.end.row;if(l!==null){if(l<o||l>n)return;o=l}var r=this;l=m.getPath("textStorage.lines");m=m.get("syntaxManager");n=Math.min(l.length,n+1);m.updateSyntaxForRows(o,
n).then(function(u){r._syntaxManagerUpdatedSyntaxForRows(u.startRow,u.endRow)})},acceptsFirstResponder:true,hasPadding:true,layoutManager:null,padding:{bottom:0,right:0},theme:{backgroundStyle:"#2a211c",cursorStyle:"#879aff",editorSelectedTextColor:"rgb(240, 240, 240)",editorSelectedTextBackground:"#526da5",unfocusedCursorStrokeStyle:"#ff0033",unfocusedCursorFillStyle:"#73171e"},blinkInsertionPoint:function(){this._insertionPointVisible=!this._insertionPointVisible;this._invalidateSelection()},clippingFrameChanged:function(){arguments.callee.base.apply(this,
arguments);this._updateSyntax(null)},copy:function(){return this.getSelectedCharacters()},cut:function(){var l=this.getSelectedCharacters();l!=""&&this.performBackspaceOrDelete(false);return l},drawRect:function(l,m){m.fillStyle=this.get("theme").backgroundStyle;m.fillRect(l.x,l.y,l.width,l.height);this._drawSelection(l,m);this._drawLines(l,m)},focus:function(){this.focusTextInput()},getSelectedCharacters:function(){return this._rangeIsInsertionPoint(this._selectedRange)?"":this.getPath("layoutManager.textStorage").getCharacters(f.normalizeRange(this._selectedRange))},
getSelectedRange:function(l){return l?this._selectedRange:f.normalizeRange(this._selectedRange)},groupChanges:function(l){if(this._inChangeGroup)l();else{this._inChangeGroup=true;this.notifyDelegates("textViewBeganChangeGroup",this._selectedRange);try{l()}finally{this._inChangeGroup=false;this.notifyDelegates("textViewEndedChangeGroup",this._selectedRange)}}},init:function(){arguments.callee.base.apply(this,arguments);this._invalidRange=null;this._selectedRange={start:{row:0,col:0},end:{row:0,col:0}};
this.set("padding",c.clone(this.get("padding")));this.get("layoutManager").addDelegate(this);this._updateEnclosingScrollView();this._resize()},insertText:function(l){if(this._isReadOnly())return false;this.groupChanges(function(){this.getPath("layoutManager.textStorage");var m=f.normalizeRange(this._selectedRange);this.replaceCharacters(m,l);var n=l.split("\n");this.moveCursorTo(n.length>1?{row:m.start.row+n.length-1,col:n[n.length-1].length}:f.addPositions(m.start,{row:0,col:l.length}))}.bind(this));
return true},isDelimiter:function(l){return"\"',;.!~@#$%^&*?[]<>():/\\-+ \t".indexOf(l)!==-1},keyDown:function(l){if(l.charCode===0)return j.processKeyEvent(l,this,{isTextView:true});else if(l.keyCode===9)l.preventDefault();else return false},layoutManagerChangedTextAtRow:function(l,m){this._updateSyntax(m);this._repositionSelection()},layoutManagerInvalidatedRects:function(l,m){m.forEach(this.setNeedsDisplayInRect,this);this._resize()},mouseDown:function(l){arguments.callee.base.apply(this,arguments);
var m={x:l.pageX,y:l.pageY};switch(l.clickCount){case 1:var n=this._selectionPositionForPoint(this.convertFrameFromView(m));this.moveCursorTo(n,l.shiftKey);break;case 2:n=this._selectionPositionForPoint(this.convertFrameFromView(m));var o=this.getPath("layoutManager.textStorage").lines[n.row];if(o.length===0)return true;n.col-=n.col==o.length?1:0;var r=!this.isDelimiter(o[n.col]),u=this,q=function(w,v){for(;w>-1&&w<o.length;w+=v)if(u.isDelimiter(o[w])===r)break;return w+(v==1?0:1)},s=q(n.col,-1);
q=q(n.col,1);this.moveCursorTo({row:n.row,col:s});this.moveCursorTo({row:n.row,col:q},true);break;case 3:s=this.getPath("layoutManager.textStorage").lines;n=this._selectionPositionForPoint(this.convertFrameFromView(m));this.setSelection({start:{row:n.row,col:0},end:{row:n.row,col:s[n.row].length}});break}this._dragPoint=m;this._dragTimer=c.Timer.schedule({target:this,action:"_scrollWhileDragging",interval:100,repeats:true});return true},mouseDragged:function(l){this._dragPoint={x:l.pageX,y:l.pageY};
this._drag();return true},mouseUp:function(){this._dragTimer!==null&&this._dragTimer.invalidate()},moveCursorTo:function(l,m,n){var o=this.getPath("layoutManager.textStorage"),r=o.clampPosition(l);this.setSelection({start:m?this._selectedRange.start:r,end:r});if(n){m=o.get("lines").length;n=l.row;o=l.col;this._selectedRangeEndVirtual=n>0&&n<m?l:{row:n<1?0:m-1,col:o}}else this._selectedRangeEndVirtual=null;this.scrollToPosition(this._selectedRange.end)},moveDown:function(){var l=this._getVirtualSelection();
l=f.normalizeRange(l);l=this._rangeIsInsertionPoint(this._selectedRange)?l.end:{row:l.end.row,col:l.start.col};l=f.addPositions(l,{row:1,col:0});this.moveCursorTo(l,false,true)},moveLeft:function(){var l=f.normalizeRange(this._selectedRange);this._rangeIsInsertionPoint(l)?this.moveCursorTo(this.getPath("layoutManager.textStorage").displacePosition(l.start,-1)):this.moveCursorTo(l.start)},moveRight:function(){var l=f.normalizeRange(this._selectedRange);this._rangeIsInsertionPoint(l)?this.moveCursorTo(this.getPath("layoutManager.textStorage").displacePosition(l.end,
1)):this.moveCursorTo(l.end)},moveUp:function(){var l=f.normalizeRange(this._getVirtualSelection(true));position=f.addPositions({row:l.start.row,col:this._getVirtualSelection().end.col},{row:-1,col:0});this.moveCursorTo(position,false,true)},parentViewFrameChanged:function(){arguments.callee.base.apply(this,arguments);this._resize()},replaceCharacters:function(l,m){if(this._isReadOnly())return false;this.groupChanges(function(){l=f.normalizeRange(l);this.notifyDelegates("textViewWillReplaceRange",
l);this.getPath("layoutManager.textStorage").replaceCharacters(l,m);this.notifyDelegates("textViewReplacedCharacters",l,m)}.bind(this));return true},performBackspaceOrDelete:function(l){if(this._isReadOnly())return false;var m=this.getPath("layoutManager.textStorage"),n=m.get("lines"),o=this.getSelectedRange();if(f.isZeroLength(o))if(l){var r=o.start;l=k.get("tabstop");var u=r.row;r=r.col;n=n[u];o=r>0&&r%l===0&&(new RegExp("^\\s{"+r+"}")).test(n)?{start:{row:u,col:r-l},end:o.end}:{start:m.displacePosition(o.start,
-1),end:o.end}}else o={start:o.start,end:m.displacePosition(o.end,1)};this.groupChanges(function(){this.replaceCharacters(o,"");this.moveCursorTo(o.start)}.bind(this));return true},resetKeyBuffers:function(){this._keyMetaBuffer=this._keyBuffer=""},scrollPageDown:function(){this._scrollPage(false)},scrollPageUp:function(){this._scrollPage(true)},scrollTo:function(l){var m=this._enclosingScrollView;c.none(m)||m.scrollTo(l)},scrollToPosition:function(l){var m=this.get("layoutManager").characterRectForPosition(l);
l=m.x;var n=m.y,o=m.width;m=m.height;var r=this.get("clippingFrame"),u=r.x,q=r.y,s=this.get("padding"),w=r.width-s.right;r=r.height-s.bottom;this.scrollTo({x:l>=u&&l+o<u+w?u:l-w/2+o/2,y:n>=q&&n+m<q+r?q:n-r/2+m/2})},selectAll:function(){var l=this.getPath("layoutManager.textStorage.lines"),m=l.length-1;this.setSelection({start:{row:0,col:0},end:{row:m,col:l[m].length}})},selectDown:function(){this._performVerticalKeyboardSelection(1)},selectLeft:function(){this.moveCursorTo(this.getPath("layoutManager.textStorage").displacePosition(this._selectedRange.end,
-1),true)},selectRight:function(){this.moveCursorTo(this.getPath("layoutManager.textStorage").displacePosition(this._selectedRange.end,1),true)},selectUp:function(){this._performVerticalKeyboardSelection(-1)},setSelection:function(l,m){var n=this.getPath("layoutManager.textStorage");l=n.clampRange(l);if(!f.equal(l,this._selectedRange)){this._invalidateSelection();this._selectedRange=n.clampRange(l);this._invalidateSelection();this.notifyDelegates("textViewSelectionChanged",this._selectedRange);this.get("isFirstResponder")&&
this._rearmInsertionPointBlinkTimer();m&&this.scrollToPosition(this._selectedRange.end);this.notifyDelegates("textViewChangedSelection",this._selectedRange)}},textInserted:function(l){if(!j.processKeyInput(l,this,{isTextView:true,isCommandKey:false})){this.insertText(l);this.resetKeyBuffers()}},willBecomeKeyResponderFrom:function(){arguments.callee.base.apply(this,arguments);this._invalidateSelection();this._rearmInsertionPointBlinkTimer()},willLoseKeyResponderTo:function(){arguments.callee.base.apply(this,
arguments);this._invalidateSelection();this._insertionPointBlinkTimer.invalidate();this._insertionPointVisible=true}})});tiki.module("text_editor:index",function(){});tiki.register("theme_manager",{});
tiki.module("theme_manager:index",function(a,b){var c=a("sproutcore/runtime").SC,d=a("bespin:promise").Promise;a=a("bespin:plugins");b.ThemeManager=c.Object.extend({_theme:null,_applyTheme:function(){c.none(this._theme)||this.get("panes").forEach(this._applyThemeToPane,this)},_applyThemeToPane:function(e){var f=e.get("theme");if(c.none(f))f=window.ENV.theme;var g=e.get("classNames");c.none(f)||(g=g.filter(function(j){return j!==f}));var h=this._theme.get("cssClass");g.push(h);e.set("classNames",g);
e.set("theme",h);e.set("bespinThemeManager",this);e.updateLayer();this._applyThemeToView(e)},_applyThemeToView:function(e){var f=this._theme;e.respondsTo("bespinThemeChanged")&&e.bespinThemeChanged(this,f);e.get("childViews").forEach(this._applyThemeToView,this)},_panesChanged:function(){this._applyTheme()}.observes("panes"),catalog:a.catalog,panes:[],theme:null,themeRegistered:null,addPane:function(e){this.set("panes",this.get("panes").concat(e))},init:function(){this.set("themeRegistered",new d);
this.set("panes",this.get("panes").concat())},loadTheme:function(){var e=new d;this.get("themeRegistered").then(function(f){f.load().then(function(g){this._theme=g.create();this._applyTheme();e.resolve()}.bind(this))}.bind(this));return e},removePane:function(e){this.set("panes",this.get("panes").filter(function(f){return e!==f}))}});b.themeManager=b.ThemeManager.create({theme:"Screen"});b.registerTheme=function(e){var f=b.themeManager;e.name===f.get("theme")&&f.get("themeRegistered").resolve(e)}});
tiki.register("events",{});tiki.module("events:index",function(a,b){b.Event=function(){var c=[],d=function(){var e=arguments;c.forEach(function(f){f.apply(null,e)})};d.add=function(e){c.push(e)};d.remove=function(e){c=c.filter(function(f){return e!==f})};return d}});tiki.register("dock_view",{});
tiki.module("dock_view:index",function(a,b){var c=a("sproutcore/runtime").SC;b.DockView=c.View.extend({classNames:["bespin-dock-view"],centerView:null,dockedViews:[],_createCenterView:function(d){d=this.createChildView(d,{layoutView:this});this.set("centerView",d);return d},addDockedView:function(d,e){var f=this.get("dockedViews"),g=f.length;if(c.none(e))e="bottom";var h=this;d=this.createChildView(d,{dock:e,layoutView:this,rootElementPath:[g],_bespin_dockView_frameDidChange:function(){h._updateChildLayout()}.observes("frame")});
return f[g]=d},removeDockedView:function(d){this.get("dockedViews").removeObject(d);this.removeChild(d);this._updateChildLayout()},createChildViews:function(){var d=[],e=this.get("centerView");if(e!==null){e=this._createCenterView(e);d.push(e)}e=this.get("dockedViews");for(var f=0;f<e.length;f++)d.push(this.addDockedView(e[f],f));this.set("childViews",d);return this},createCenterView:function(d){var e=this.get("centerView");e!==null&&e.removeFromParent();d=this._createCenterView(d);this._updateChildLayout();
return d},init:function(){arguments.callee.base.apply(this,arguments);this.set("dockedViews",this.get("dockedViews").concat())},_updateChildLayout:function(){var d=0,e=0,f=0,g=0;this.get("dockedViews").forEach(function(j){var k=j.get("frame"),l=j.get("dock");switch(l){case "left":d+=k.width;j.adjust("top",f);j.adjust("bottom",e);break;case "bottom":e+=k.height;j.adjust("left",d);j.adjust("right",g);break;case "top":f+=k.height;j.adjust("left",d);j.adjust("right",g);break;case "right":g+=k.width;j.adjust("top",
f);j.adjust("bottom",e);break;default:throw new Error("invalid 'dock' property: "+l);}});var h=this.get("centerView");h!==null&&h.adjust({left:d,bottom:e,top:f,right:g})},renderLayout:function(){this._updateChildLayout();arguments.callee.base.apply(this,arguments)}})});tiki.register("screen_theme",{});
tiki.module("screen_theme:index",function(a,b){a=a("sproutcore/runtime").SC;b.ScreenTheme=a.Object.extend({cssClass:"bespin-screen"});a.mixin(a.ScrollerView.prototype,{scrollbarThickness:17,capLength:21,capOverlap:0,buttonLength:21,buttonOverlap:0})});tiki.register("filesystem",{});
tiki.module("filesystem:index",function(a,b){var c=a("sproutcore/runtime").SC;a("bespin:console");a("bespin:util/util");var d=a("bespin:promise"),e=a("filesystem:path"),f=d.Promise;b._prefixSearch=function(g,h){for(var j=0,k=g.length-1,l=h.length,m,n=null,o;j<=k;){m=parseInt((j+k)/2,10);o=g[m].substring(0,l);if(m==n)return m;if(o==h){n=m;k=m-1}else if(o<h)j=m+1;else k=m-1}return n};b._binarySearch=function(g,h){for(var j=0,k=g.length-1,l,m;j<=k;){l=parseInt((j+k)/2,10);m=g[l];if(m<h)j=l+1;else if(m>
h)k=l-1;else return l}return null};b.NEW={name:"NEW"};b.LOADING={name:"LOADING"};b.READY={name:"READY"};b.Filesystem=c.Object.extend({source:null,_files:null,status:b.NEW,_loadingPromises:null,init:function(){var g=this.get("source");typeof g=="string"&&this.set("source",c.objectForPropertyPath(g));if(!this.get("source"))throw new Error("Directory must have a source.");this._loadingPromises=[]},_load:function(){var g=new f;if(this.status===b.READY)g.resolve();else if(this.status===b.LOADING)this._loadingPromises.push(g);
else{this.set("status",b.LOADING);this._loadingPromises.push(g);this.get("source").loadAll().then(this._fileListReceived.bind(this))}return g},_fileListReceived:function(g){g.sort();this._files=g;this.set("status",b.READY);for(g=this._loadingPromises;g.length>0;)g.pop().resolve()},invalidate:function(){this._files=[];this.set("status",b.NEW)},listAll:function(){return this._load().chainPromise(function(){return this._files}.bind(this))},loadContents:function(g){g=e.trimLeadingSlash(g);return this.get("source").loadContents(g)},
saveContents:function(g,h){var j=new f;g=e.trimLeadingSlash(g);var k=this;this.get("source").saveContents(g,h).then(function(){k.exists(g).then(function(l){if(!l){k._files.push(g);k._files.sort()}j.resolve()})},function(l){j.reject(l)});return j},getFile:function(g){return new b.File(this,g)},exists:function(g){g=e.trimLeadingSlash(g);var h=new f;this._load().then(function(){var j=b._binarySearch(this._files,g);h.resolve(j!==null)}.bind(this));return h},remove:function(g){g=e.trimLeadingSlash(g);
var h=new f,j=this;this.get("source").remove(g).then(function(){j.status!==b.NEW?j._load().then(function(){var k=b._binarySearch(j._files,g);k!==null&&j._files.splice(k,1);h.resolve()},function(k){h.reject(k)}):h.resolve()},function(k){h.reject(k)});return h},listDirectory:function(g){g=e.trimLeadingSlash(g);var h=new f;this._load().then(function(){var j=this._files,k=b._prefixSearch(j,g);if(k===null)h.reject(new Error("Path "+g+" not found."));else{var l=[],m=j.length,n=g.length,o=null;for(k=k;k<
m;k++){var r=j[k];if(r.substring(0,n)!=g)break;var u=r.indexOf("/",n)+1;if(u==0)u=r.length;r=r.substring(n,u);if(r!="")if(r!=o){o=r;l.push(r)}}h.resolve(l)}}.bind(this));return h},makeDirectory:function(g){g=e.trimLeadingSlash(g);e.isDir(g)||(g+="/");var h=this,j=new f;this._load().then(function(){h.get("source").makeDirectory(g).then(function(){h._files.push(g);h._files.sort();j.resolve()})});return j}});b.File=function(g,h){this.fs=g;this.path=h};b.File.prototype={parentdir:function(){return e.parentdir(this.path)},
loadContents:function(){return this.fs.loadContents(this.path)},saveContents:function(g){return this.fs.saveContents(this.path,g)},exists:function(){return this.fs.exists(this.path)},remove:function(){return this.fs.remove(this.path)},extension:function(){return e.fileType(this.path)}}});
tiki.module("filesystem:path",function(a,b){var c=a("bespin:util/util");b.combine=function(){var d=Array.prototype.slice.call(arguments).join("/");d=d.replace(/\/\/+/g,"/");return d=d.replace(/^\s+|\s+$/g,"")};b.directory=function(d){d=/^(.*?\/)[^\/]*$/.exec(d);return d===null?"":d[1]};b.makeDirectory=function(d){/\/$/.test(d)||(d+="/");return d};b.combineAsDirectory=function(){return this.makeDirectory(this.combine.apply(this,arguments))};b.escape=function(){return escape(this.combine.apply(this,
arguments))};b.trimLeadingSlash=function(d){if(d.indexOf("/")==0)d=d.substring(1,d.length);return d};b.hasLeadingSlash=function(d){return d.indexOf("/")==0};b.fileType=function(d){if(d.indexOf(".")>=0){d=d.split(".");if(d.length>1)return d[d.length-1]}return null};b.isDir=function(d){return c.endsWith(d,"/")};b.basename=function(d){var e=d.lastIndexOf("/");if(e==-1)return d;return d.substring(e+1)};b.splitext=function(d){var e=d.lastIndexOf(".");if(e==-1)return[d,""];var f=d.substring(0,e);d=d.substring(e+
1);return[f,d]};b.parentdir=function(d){if(d==""||d=="/")return"";if(b.isDir(d))d=d.substring(0,d.length-1);slash=d.lastIndexOf("/");return d=d.substring(0,slash+1)}});tiki.module("filesystem:types",function(a,b){b.existingFile={isValid:function(){return true},toString:function(c){return c},fromString:function(c){return c}}});tiki.register("edit_session",{});
tiki.module("edit_session:history",function(a,b){var c=a("sproutcore/runtime").SC,d=a("canon:environment");b.History=c.Object.extend({_getStorageName:function(){return"bespin.history."+d.global.get("session").currentUser},_getHistory:function(){var e=this.get("storage")[this._getStorageName()];if(e)return JSON.parse(e);return[]},_setHistory:function(e){this.get("storage")[this._getStorageName()]=JSON.stringify(e)},storage:window.localStorage,addPath:function(e){for(var f=this._getHistory(),g=null,
h=f.length-1;h>=0;h--){var j=f[h];if(j.path===e){g=j;f.splice(h,1);break}}if(g===null)g={path:e};f.length>=30&&f.splice(0,f.length-30+1);f.push(g);this._setHistory(f)},getRecent:function(e){var f=this._getHistory();return f.slice(e<f.length?-e:0)},update:function(e,f,g){var h=this._getHistory(),j=h[h.length-1];if(j.path===e){j[f]=g;this._setHistory(h)}}})});
tiki.module("edit_session:index",function(a,b){var c=a("bespin:promise").Promise,d=a("bespin:plugins").catalog,e=a("sproutcore/runtime").SC;a("filesystem:index");var f=a("delegate_support").MultiDelegateSupport,g=a("text_editor:models/textstorage").TextStorage;a("filesystem:path");var h=a("appsupport:controllers/bespin").bespinController,j=a("edit_session:history").History;b.Buffer=e.Object.extend(f,{_file:null,_fileChanged:function(){this.notifyDelegates("bufferFileChanged",this._file)}.observes("file"),
_modelChanged:function(){this.notifyDelegates("bufferModelChanged",this.get("model"))}.observes("model"),model:null,syntaxManager:null,file:function(k,l){if(l!==undefined){this._file=l;e.none(l)?this.set("model",g.create()):l.loadContents().then(function(m){console.log("SET FILE CONTENTS: ",m);e.run(function(){this.set("model",g.create({initialValue:m}))}.bind(this))}.bind(this))}return this._file}.property(),init:function(){this.get("model")==null&&this.set("model",g.create())},changeFile:function(k){this.changeFileOnly(k);
if(e.none(k)){this.set("model",g.create());k=new c;k.resolve(this);return k}return k.loadContents().then(function(l){e.run(function(){this.set("model",g.create({initialValue:l}))}.bind(this));return this}.bind(this))},changeFileOnly:function(k){this._file=k;this.propertyDidChange("file")},reload:function(){return this.get("file").loadContents().then(function(k){this.set("model",g.create({initialValue:k}))}.bind(this))},save:function(){return this._file.saveContents(this.get("model").getValue())},
saveAs:function(k){var l=new c;k.saveContents(this.get("model").getValue()).then(function(){this.changeFileOnly(k);l.resolve()}.bind(this),function(m){l.reject(m)});return l},untitled:function(){return e.none(this._file)}});b.EditSession=e.Object.extend({_currentBuffer:null,_currentView:null,_currentBufferChanged:function(){var k=this._currentBuffer;e.none(k)||k.removeDelegate(this);this._currentBuffer=k=this.get("currentBuffer");k.addDelegate(this)}.observes("currentBuffer"),_currentViewChanged:function(){var k=
this._currentView;e.none(k)||k.removeDelegate(this);this._currentView=k=this.get("currentView");k.addDelegate(this)}.observes("currentView"),_updateHistoryProperty:function(k,l){var m=this._currentBuffer.get("file");e.none(m)||this.get("history").update(m.path,k,l)},currentBuffer:null,currentUser:null,currentView:null,history:null,bufferFileChanged:function(k,l){if(!e.none(l)){this.get("history").addPath(l.path);k=l.extension();this._currentView.getPath("layoutManager.syntaxManager").setInitialContextFromExt(k===
null?"":k)}d.getExtensions("bufferFileChanged").forEach(function(m){m.load(function(n){n(l)})})},bufferModelChanged:function(k,l){this._currentView.setPath("layoutManager.textStorage",l)},getCompletePath:function(k){if(k==null)k="";if(k==null||k.substring(0,1)!="/"){var l=this._currentBuffer,m;if(l)m=l.get("file");k=m?m.parentdir()+k:"/"+k}return k},loadMostRecentOrNew:function(){var k=this.get("history").getRecent(1);if(k.length!==0){k=k[0];var l=k.scroll,m=k.selection;this._currentBuffer.changeFile(h.files.getFile(k.path)).then(function(){var n=
this._currentView;e.none(l)||n.scrollTo(l);e.none(m)||n.setSelection(m)}.bind(this))}},textViewChangedSelection:function(k,l){this._updateHistoryProperty("selection",l)},textViewWasScrolled:function(k,l){this._updateHistoryProperty("scroll",l)},init:function(){this.set("history",j.create())}});b.editSessionClasses={Buffer:b.Buffer,EditSession:b.EditSession}});tiki.register("keylistener",{});
tiki.module("keylistener:index",function(a,b){var c=a("sproutcore/runtime").SC,d=a("canon:keyboard").keyboardManager;b.KeyListener=c.Responder.extend({performKeyEquivalent:function(e,f){d.processKeyEvent(f,this,{isApplication:true})}})});tiki.register("embedded",{});
tiki.module("embedded:index",function(a,b){var c=a("sproutcore/runtime").SC,d=a("events").Event,e=a("bespin:promise").Promise,f=a("traits").Trait,g=a("bespin:console").console,h=a("rangeutils:utils/range");f=f.object({_element:null,_elementChosen:new e,_events:null,_options:null,_session:null,_attachToElement:function(){var j=this._element;if(typeof j==="string")this._element=j=document.getElementById(j);if(typeof j!=="object")throw new Error("Expected a DOM element to attach Bespin to but found "+
j);var k=this._options;if(typeof j!=="string")k.initialContent=j.innerHTML;j.style.position="relative";j.innerHTML="";this.pane.appendTo(j)},_computeLayout:function(){for(var j=this._element,k={top:0,left:0,width:j.clientWidth,height:j.clientHeight};j!==null;){k.top+=j.offsetTop+j.clientTop;k.left+=j.offsetLeft+j.clientLeft;j=j.offsetParent}return k},_createValueProperty:function(){this.__defineGetter__("value",this.getValue);this.__defineSetter__("value",this.setValue)},_getTextStorage:function(){return this._session.currentView.getPath("layoutManager.textStorage")},
_hookWindowResizeEvent:function(){window.addEventListener("resize",this.dimensionsChanged,false)},_unhookWindowResizeEvent:function(){window.removeEventListener("resize",this.dimensionsChanged,false)},componentOrder:["environment","theme_manager","settings","key_listener","dock_view","editor_view","edit_session"],pane:null,paneClass:null,addEventListener:function(j,k){var l=this._events;j in l?l[j].add(k):g.warn('[Bespin] addEventListener(): unknown event: "'+j+'"')},createPane:function(){var j=new e;
this._elementChosen.then(function(){if(this.pane!==null)throw new Error("Attempt to instantiate multiple instances of Bespin");var k=this.paneClass.create({_layoutChanged:function(){this._recomputeLayoutStyle()}.observes("layout"),_recomputeLayoutStyle:function(){var l=this.get("layout");this.set("layoutStyle",{width:l.width+"px",height:l.height+"px"})},init:function(){arguments.callee.base.apply(this,arguments);this._recomputeLayoutStyle()},layout:this._computeLayout(),layoutStyle:{}});this.pane=
k;this._attachToElement();this._hookWindowResizeEvent();j.resolve(k)}.bind(this));return j},dimensionsChanged:function(){c.run(function(){var j=this.pane,k=j.get("layout"),l=this._computeLayout();if(!c.rectsEqual(k,l)){j.adjust(l);j.updateLayout()}}.bind(this))},getSelection:function(){var j=this._session.currentView.getSelectedRange(false);return h.cloneRange(j)},getSelectedText:function(){return this.getText(this.getSelection())},getText:function(j){if(!h.isRange(j))throw new Error('getText(): expected range but found "'+
j+'"');return this._getTextStorage().getCharacters(h.normalizeRange(j))},getValue:function(){return this._getTextStorage().getValue()},init:function(){this._createValueProperty();this._events={select:d(),textChange:d()}},removeEventListener:function(j,k){var l=this._events;j in l?l[j].remove(k):g.warn('[Bespin] removeEventListener(): unknown event: "'+j+'"')},replace:function(j,k,l){if(!h.isRange(j))throw new Error('replace(): expected range but found "'+j+"'");if(typeof text!=="string")throw new Error('replace(): expected text string but found "'+
text+'"');c.run(function(){var m=h.normalizeRange(j),n=this._session.currentView,o=n.getSelectedRange(false);n.groupChanges(function(){n.replaceCharacters(m,k);l&&n.setSelection(o)})}.bind(this))},replaceSelection:function(j){if(typeof j!=="string")throw new Error('replaceSelection(): expected string but found "'+j+'"');this.replace(this.getSelection(),text)},sessionInitialized:function(j){this._session=j;var k=this._options;for(var l in k)this.setOption(l,k[l]);var m=this;this._getTextStorage().addDelegate(c.Object.create({textStorageEdited:function(n,
o,r,u){m._events.textChange({oldRange:o,newRange:r,newValue:u})}}));j.currentView.addDelegate(c.Object.create({textViewSelectionChanged:function(n,o){m._events.select({selection:o})}}))},setCursor:function(j){if(!h.isPosition(j))throw new Error('setCursor(): expected position but found "'+j+'"');this._session.currentView.moveCursorTo(j)},setFocus:function(j){j=!!j;var k=this.pane,l=this._session.currentView;if(l.get("isFirstResponder")!==j)if(j){k.becomeKeyPane();l.focus()}else k.resignKeyPane()},
setLineNumber:function(j){this._session.currentView.moveCursorTo({row:j-1,col:0})},setOption:function(j,k){switch(j){case "initialContent":this.setValue(k);break;case "noAutoresize":k?this._unhookWindowResizeEvent():this._hookWindowResizeEvent();break;case "settings":for(var l in k)this.setSetting(l,k[l]);break;case "stealFocus":this.setFocus(k);break;case "syntax":this.setSyntax(k);break;default:g.warn('[Bespin] unknown setting: "'+j+'"');break}},setSelection:function(j){if(!h.isRange(j))throw new Error("setSelection(): selection must be supplied");
this._session.currentView.setSelection(j)},setSetting:function(j,k){if(j===null||j===undefined)throw new Error("setSetting(): key must be supplied");if(k===null||k===undefined)throw new Error("setSetting(): value must be supplied");c.run(function(){a("settings").settings.set(j,k)})},setSyntax:function(j){if(j===null||j===undefined)throw new Error("setSyntax(): syntax must be supplied");c.run(function(){this._session.currentView.getPath("layoutManager.syntaxManager").set("initialContext",j)}.bind(this))},
setValue:function(j){c.run(function(){var k=this._session.currentView;k.getPath("layoutManager.textStorage").setValue(j);k.moveCursorTo({row:0,col:0})}.bind(this))},useBespin:function(j,k){if(k===null||k===undefined)k={};this._element=j;this._options=k;this._elementChosen.resolve();return this}});b.embeddedEditor=f;f.init();b.useBespin=f.useBespin});tiki.register("html",{});
tiki.module("html:index",function(a,b){a("sproutcore/runtime");a=a("syntax_manager:controllers/standardsyntax").StandardSyntax;var c={},d=function(e,f){c[e+"_beforeAttrName"]=[{regex:/^\s+/,tag:"plain"},{regex:/^\//,tag:"operator",then:e+"_selfClosingStartTag"},{regex:/^>/,tag:"operator",then:f},{regex:/^./,tag:"keyword",then:e+"_attrName"}];c[e+"_attrName"]=[{regex:/^\s+/,tag:"plain",then:e+"_afterAttrName"},{regex:/^\//,tag:"operator",then:e+"_selfClosingStartTag"},{regex:/^=/,tag:"operator",then:e+
"_beforeAttrValue"},{regex:/^>/,tag:"operator",then:f},{regex:/^["'<]+/,tag:"error"},{regex:/^[^ \t\n\/=>"'<]+/,tag:"keyword"}];c[e+"_afterAttrName"]=[{regex:/^\s+/,tag:"plain"},{regex:/^\//,tag:"operator",then:e+"_selfClosingStartTag"},{regex:/^=/,tag:"operator",then:e+"_beforeAttrValue"},{regex:/^>/,tag:"operator",then:f},{regex:/^./,tag:"keyword",then:e+"_attrName"}];c[e+"_beforeAttrValue"]=[{regex:/^\s+/,tag:"plain"},{regex:/^"/,tag:"string",then:e+"_attrValueQQ"},{regex:/^(?=&)/,tag:"plain",
then:e+"_attrValueU"},{regex:/^'/,tag:"string",then:e+"_attrValueQ"},{regex:/^>/,tag:"error",then:f},{regex:/^./,tag:"string",then:e+"_attrValueU"}];c[e+"_attrValueQQ"]=[{regex:/^"/,tag:"string",then:e+"_afterAttrValueQ"},{regex:/^[^"]+/,tag:"string"}];c[e+"_attrValueQ"]=[{regex:/^'/,tag:"string",then:e+"_afterAttrValueQ"},{regex:/^[^']+/,tag:"string"}];c[e+"_attrValueU"]=[{regex:/^\s/,tag:"string",then:e+"_beforeAttrName"},{regex:/^>/,tag:"operator",then:f},{regex:/[^ \t\n>]+/,tag:"string"}];c[e+
"_afterAttrValueQ"]=[{regex:/^\s/,tag:"plain",then:e+"_beforeAttrName"},{regex:/^\//,tag:"operator",then:e+"_selfClosingStartTag"},{regex:/^>/,tag:"operator",then:f},{regex:/^(?=.)/,tag:"operator",then:e+"_beforeAttrName"}];c[e+"_selfClosingStartTag"]=[{regex:/^>/,tag:"operator",then:"start"},{regex:/^./,tag:"error",then:e+"_beforeAttrName"}]};c={start:[{regex:/^[^<]+/,tag:"plain"},{regex:/^<!--/,tag:"comment",then:"commentStart"},{regex:/^<!/,tag:"directive",then:"markupDeclarationOpen"},{regex:/^<\?/,
tag:"comment",then:"bogusComment"},{regex:/^</,tag:"operator",then:"tagOpen"}],tagOpen:[{regex:/^\//,tag:"operator",then:"endTagOpen"},{regex:/^script/i,tag:"keyword",then:"script_beforeAttrName"},{regex:/^[a-zA-Z]/,tag:"keyword",then:"tagName"},{regex:/^(?=.)/,tag:"plain",then:"start"}],scriptData:[{regex:/^<(?=\/script>)/i,tag:"operator",then:"tagOpen stop:js"},{regex:/^[^<]+/,tag:"plain"}],endTagOpen:[{regex:/^[a-zA-Z]/,tag:"keyword",then:"tagName"},{regex:/^>/,tag:"error",then:"start"},{regex:/^./,
tag:"error",then:"bogusComment"}],tagName:[{regex:/^\s+/,tag:"plain",then:"normal_beforeAttrName"},{regex:/^\//,tag:"operator",then:"normal_selfClosingStartTag"},{regex:/^>/,tag:"operator",then:"start"},{regex:/^[^ \t\n\/>]+/,tag:"keyword"}],bogusComment:[{regex:/^[^>]+/,tag:"comment"},{regex:/^>/,tag:"comment",then:"start"}],markupDeclarationOpen:[{regex:/^doctype/i,tag:"directive",then:"doctype"},{regex:/^(?=.)/,tag:"comment",then:"bogusComment"}],commentStart:[{regex:/^--\>/,tag:"comment",then:"start"},
{regex:/^[^-]+/,tag:"comment"}],doctype:[{regex:/^\s/,tag:"plain",then:"beforeDoctypeName"},{regex:/^./,tag:"error",then:"beforeDoctypeName"}],beforeDoctypeName:[{regex:/^\s+/,tag:"plain"},{regex:/^>/,tag:"error",then:"start"},{regex:/^./,tag:"directive",then:"doctypeName"}],doctypeName:[{regex:/^\s/,tag:"plain",then:"afterDoctypeName"},{regex:/^>/,tag:"directive",then:"start"},{regex:/^[^ \t\n>]+/,tag:"directive"}],afterDoctypeName:[{regex:/^\s+/,tag:"directive"},{regex:/^>/,tag:"directive",then:"start"},
{regex:/^public/i,tag:"directive",then:"afterDoctypePublicKeyword"},{regex:/^system/i,tag:"directive",then:"afterDoctypeSystemKeyword"},{regex:/^./,tag:"error",then:"bogusDoctype"}],afterDoctypePublicKeyword:[{regex:/^\s+/,tag:"plain",then:"beforeDoctypePublicId"},{regex:/^"/,tag:"error",then:"doctypePublicIdQQ"},{regex:/^'/,tag:"error",then:"doctypePublicIdQ"},{regex:/^>/,tag:"error",then:"start"},{regex:/^./,tag:"error",then:"bogusDoctype"}],beforeDoctypePublicId:[{regex:/^\s+/,tag:"plain"},{regex:/^"/,
tag:"string",then:"doctypePublicIdQQ"},{regex:/^'/,tag:"string",then:"doctypePublicIdQ"},{regex:/^>/,tag:"error",then:"start"},{regex:/^./,tag:"error",then:"bogusDoctype"}],doctypePublicIdQQ:[{regex:/^"/,tag:"string",then:"afterDoctypePublicId"},{regex:/^>/,tag:"error",then:"start"},{regex:/^[^>"]+/,tag:"string"}],doctypePublicIdQ:[{regex:/^'/,tag:"string",then:"afterDoctypePublicId"},{regex:/^>/,tag:"error",then:"start"},{regex:/^[^>']+/,tag:"string"}],afterDoctypePublicId:[{regex:/^\s/,tag:"plain",
then:"betweenDoctypePublicAndSystemIds"},{regex:/^>/,tag:"directive",then:"start"},{regex:/^"/,tag:"error",then:"doctypeSystemIdQQ"},{regex:/^'/,tag:"error",then:"doctypeSystemIdQ"},{regex:/^./,tag:"error",then:"bogusDoctype"}],betweenDoctypePublicAndSystemIds:[{regex:/^\s+/,tag:"plain",then:"betweenDoctypePublicAndSystemIds"},{regex:/^>/,tag:"directive",then:"start"},{regex:/^"/,tag:"string",then:"doctypeSystemIdQQ"},{regex:/^'/,tag:"string",then:"doctypeSystemIdQ"},{regex:/^./,tag:"error",then:"bogusDoctype"}],
afterDoctypeSystemKeyword:[{regex:/^\s/,tag:"plain",then:"beforeDoctypeSystemId"},{regex:/^"/,tag:"error",then:"doctypeSystemIdQQ"},{regex:/^'/,tag:"error",then:"doctypeSystemIdQ"},{regex:/^>/,tag:"error",then:"start"},{regex:/^./,tag:"error",then:"bogusDoctype"}],beforeDoctypeSystemId:[{regex:/^\s+/,tag:"plain",then:"beforeDoctypeSystemId"},{regex:/^"/,tag:"string",then:"doctypeSystemIdQQ"},{regex:/^'/,tag:"string",then:"doctypeSystemIdQ"},{regex:/^>/,tag:"error",then:"start"},{regex:/./,tag:"error",
then:"bogusDoctype"}],doctypeSystemIdQQ:[{regex:/^"/,tag:"string",then:"afterDoctypeSystemId"},{regex:/^>/,tag:"error",then:"start"},{regex:/^[^">]+/,tag:"string"}],doctypeSystemIdQ:[{regex:/^'/,tag:"string",then:"afterDoctypeSystemId"},{regex:/^>/,tag:"error",then:"start"},{regex:/^[^'>]+/,tag:"string"}],afterDoctypeSystemId:[{regex:/^\s+/,tag:"plain"},{regex:/^>/,tag:"directive",then:"start"},{regex:/^./,tag:"error",then:"bogusDoctype"}],bogusDoctype:[{regex:/^>/,tag:"directive",then:"start"},{regex:/^[^>]+/,
tag:"directive"}]};d("normal","start");d("script","scriptData start:js");b.HTMLSyntax=a.create({states:c})});tiki.register("javascript",{});
tiki.module("javascript:index",function(a,b){a("sproutcore/runtime");a("bespin:promise");a=a("syntax_manager:controllers/standardsyntax").StandardSyntax;b.JSSyntax=a.create({states:{start:[{regex:/^(?:break|case|catch|continue|default|delete|do|else|false|finally|for|function|if|in|instanceof|let|new|null|return|switch|this|throw|true|try|typeof|var|void|while|with)(?![a-zA-Z0-9_])/,tag:"keyword"},{regex:/^[A-Za-z_][A-Za-z0-9_]*/,tag:"identifier"},{regex:/^[^'"\/ \tA-Za-z0-9_]+/,tag:"plain"},{regex:/^[ \t]+/,
tag:"plain"},{regex:/^'/,tag:"string",then:"qstring"},{regex:/^"/,tag:"string",then:"qqstring"},{regex:/^\/\/.*/,tag:"comment"},{regex:/^\/\*/,tag:"comment",then:"comment"},{regex:/^./,tag:"plain"}],qstring:[{regex:/^'/,tag:"string",then:"start"},{regex:/^(?:\\.|[^'\\])+/,tag:"string"}],qqstring:[{regex:/^"/,tag:"string",then:"start"},{regex:/^(?:\\.|[^"\\])+/,tag:"string"}],comment:[{regex:/^[^*\/]+/,tag:"comment"},{regex:/^\*\//,tag:"comment",then:"start"},{regex:/^[*\/]/,tag:"comment"}]}})});
SC.ready(function(){tiki.require("bespin:plugins").catalog.loadMetadata({text_editor:{resourceURL:"resources/text_editor/",description:"Canvas-based text editor component and many common editing commands",dependencies:{delegate_support:"0.0",settings:"0.0",canon:"0.0",rangeutils:"0.0",appsupport:"0.0",syntax_manager:"0.0"},testmodules:[],provides:[{pointer:"views/editor#EditorView",ep:"appcomponent",name:"editor_view"},{predicates:{isTextView:true},pointer:"commands/editing#backspace",ep:"command",
key:"backspace",name:"backspace"},{predicates:{isTextView:true},pointer:"commands/editing#deleteCommand",ep:"command",key:"delete",name:"delete"},{description:"Delete all lines currently selected",key:"ctrl_d",predicates:{isTextView:true},pointer:"commands/editing#deleteLines",ep:"command",name:"deletelines"},{description:"Create a new, empty line below the current one",key:"ctrl_return",predicates:{isTextView:true},pointer:"commands/editing#openLine",ep:"command",name:"openline"},{description:"Join the current line with the following",
key:"ctrl_shift_j",predicates:{isTextView:true},pointer:"commands/editing#joinLines",ep:"command",name:"openline"},{params:[{defaultValue:"",type:"text",name:"text",description:"The text to insert"}],pointer:"commands/editing#insertText",ep:"command",name:"insertText"},{predicates:{isTextView:true},pointer:"commands/editing#newline",ep:"command",key:"return",name:"newline"},{predicates:{isTextView:true},pointer:"commands/editing#tab",ep:"command",key:"tab",name:"tab"},{predicates:{isTextView:true},
ep:"command",name:"move"},{description:"Search for text within this buffer",params:[{type:"text",name:"value",description:"string to search for"}],key:"ctrl_f",pointer:"commands/editor#findCommand",ep:"command",name:"find"},{description:"Repeat the last search (forward)",pointer:"commands/editor#findNextCommand",ep:"command",key:"ctrl_g",name:"findnext"},{description:"Repeat the last search (backward)",pointer:"commands/editor#findPrevCommand",ep:"command",key:"ctrl_shift_g",name:"findprev"},{predicates:{isTextView:true},
pointer:"commands/movement#moveDown",ep:"command",key:"down",name:"move down"},{predicates:{isTextView:true},pointer:"commands/movement#moveLeft",ep:"command",key:"left",name:"move left"},{predicates:{isTextView:true},pointer:"commands/movement#moveRight",ep:"command",key:"right",name:"move right"},{predicates:{isTextView:true},pointer:"commands/movement#moveUp",ep:"command",key:"up",name:"move up"},{predicates:{isTextView:true},ep:"command",name:"select"},{predicates:{isTextView:true},pointer:"commands/movement#selectDown",
ep:"command",key:"shift_down",name:"select down"},{predicates:{isTextView:true},pointer:"commands/movement#selectLeft",ep:"command",key:"shift_left",name:"select left"},{predicates:{isTextView:true},pointer:"commands/movement#selectRight",ep:"command",key:"shift_right",name:"select right"},{predicates:{isTextView:true},pointer:"commands/movement#selectUp",ep:"command",key:"shift_up",name:"select up"},{predicates:{isTextView:true},pointer:"commands/movement#moveLineEnd",ep:"command",key:["end","ctrl_right"],
name:"move lineend"},{predicates:{isTextView:true},pointer:"commands/movement#selectLineEnd",ep:"command",key:["shift_end","ctrl_shift_right"],name:"select lineend"},{predicates:{isTextView:true},pointer:"commands/movement#moveDocEnd",ep:"command",key:"ctrl_down",name:"move docend"},{predicates:{isTextView:true},pointer:"commands/movement#selectDocEnd",ep:"command",key:"ctrl_shift_down",name:"select docend"},{predicates:{isTextView:true},pointer:"commands/movement#moveLineStart",ep:"command",key:["home",
"ctrl_left"],name:"move linestart"},{predicates:{isTextView:true},pointer:"commands/movement#selectLineStart",ep:"command",key:["shift_home","ctrl_shift_left"],name:"select linestart"},{predicates:{isTextView:true},pointer:"commands/movement#moveDocStart",ep:"command",key:"ctrl_up",name:"move docstart"},{predicates:{isTextView:true},pointer:"commands/movement#selectDocStart",ep:"command",key:"ctrl_shift_up",name:"select docstart"},{predicates:{isTextView:true},pointer:"commands/movement#moveNextWord",
ep:"command",key:["alt_right"],name:"move nextword"},{predicates:{isTextView:true},pointer:"commands/movement#selectNextWord",ep:"command",key:["alt_shift_right"],name:"select nextword"},{predicates:{isTextView:true},pointer:"commands/movement#movePreviousWord",ep:"command",key:["alt_left"],name:"move prevword"},{predicates:{isTextView:true},pointer:"commands/movement#selectPreviousWord",ep:"command",key:["alt_shift_left"],name:"select prevword"},{predicates:{isTextView:true},pointer:"commands/movement#selectAll",
ep:"command",key:["ctrl_a","meta_a"],name:"select all"},{predicates:{isTextView:true},ep:"command",name:"scroll"},{predicates:{isTextView:true},pointer:"commands/scrolling#scrollDocStart",ep:"command",key:"ctrl_home",name:"scroll start"},{predicates:{isTextView:true},pointer:"commands/scrolling#scrollDocEnd",ep:"command",key:"ctrl_end",name:"scroll end"},{predicates:{isTextView:true},pointer:"commands/scrolling#scrollPageDown",ep:"command",key:"pagedown",name:"scroll down"},{predicates:{isTextView:true},
pointer:"commands/scrolling#scrollPageUp",ep:"command",key:"pageup",name:"scroll up"},{pointer:"commands/editor#lcCommand",description:"Change all selected text to lowercase",withKey:"CMD SHIFT L",ep:"command",name:"lc"},{pointer:"commands/editor#detabCommand",description:"Convert tabs to spaces.",params:[{defaultValue:null,type:"text",name:"tabsize",description:"Optionally, specify a tab size. (Defaults to setting.)"}],ep:"command",name:"detab"},{pointer:"commands/editor#entabCommand",description:"Convert spaces to tabs.",
params:[{defaultValue:null,type:"text",name:"tabsize",description:"Optionally, specify a tab size. (Defaults to setting.)"}],ep:"command",name:"entab"},{description:"move it! make the editor head to a line number.",params:[{type:"text",name:"line",description:"add the line number to move to in the file"}],key:"ctrl_l",pointer:"commands/editor#gotoCommand",ep:"command",name:"goto"},{pointer:"commands/editor#trimCommand",description:"trim trailing or leading whitespace from each line in selection",
params:[{defaultValue:"both",type:{data:[{name:"left"},{name:"right"},{name:"both"}],name:"selection"},name:"side",description:"Do we trim from the left, right or both"}],ep:"command",name:"trim"},{pointer:"commands/editor#ucCommand",description:"Change all selected text to uppercase",withKey:"CMD SHIFT U",ep:"command",name:"uc"},{description:"The distance in characters between each tab",defaultValue:8,type:"number",ep:"setting",name:"tabstop"},{description:"Customize the keymapping",defaultValue:"{}",
type:"text",ep:"setting",name:"customKeymapping"},{description:"The keymapping to use",defaultValue:"standard",type:"text",ep:"setting",name:"keymapping"},{description:"The editor font size in pixels",defaultValue:14,type:"number",ep:"setting",name:"fontsize"},{description:"The editor font face",defaultValue:"Monaco, Lucida Console, monospace",type:"text",ep:"setting",name:"fontface"}],type:"plugins/supported",name:"text_editor"},delegate_support:{testmodules:[],type:"plugins/supported",resourceURL:"resources/delegate_support/",
description:"Simple support for multiple delegates on an object",name:"delegate_support"},embedded:{resourceURL:"resources/embedded/",description:"The environment for an embedded Bespin instance",dependencies:{text_editor:"0.0",settings:"0.0",theme_manager:"0.0",events:"0.0",rangeutils:"0.0",traits:"0.0",dock_view:"0.0",screen_theme:"0.0",appsupport:"0.0",edit_session:"0.0",keylistener:"0.0"},testmodules:[],provides:[{pointer:"#embeddedEditor",ep:"appcomponent",name:"environment"}],type:"plugins/embedded",
name:"embedded"},settings:{resourceURL:"resources/settings/",description:"Infrastructure and commands for managing user preferences",dependencies:{types:"0.0"},testmodules:[],provides:[{pointer:"index#settings",ep:"appcomponent",name:"settings",description:"Storage for the customizable Bespin settings"},{indexOn:"name",register:"memory#addSetting",ep:"extensionpoint",name:"setting",description:"A Choice is something that the application offers as a way to customize how it works"},{pointer:"commands#setCommand",
description:"define and show settings",params:[{defaultValue:null,type:{pointer:"settings:memory#getSettings",name:"selection"},name:"setting",description:"The name of the setting to display or alter"},{defaultValue:null,type:{pointer:"settings:memory#getTypeSpecFromAssignment",name:"deferred"},name:"value",description:"The new value for the chosen setting"}],ep:"command",name:"set"},{pointer:"commands#unsetCommand",description:"unset a setting entirely",params:[{type:{pointer:"settings:memory#getSettings",
name:"selection"},name:"setting",description:"The name of the setting to return to defaults"}],ep:"command",name:"unset"}],type:"plugins/supported",name:"settings"},javascript:{resourceURL:"resources/javascript/",description:"JavaScript syntax highlighter",dependencies:{syntax_manager:"0.0"},testmodules:[],provides:[{pointer:"#JSSyntax",ep:"syntax",fileexts:["js"],name:"js"}],type:"plugins/supported",name:"javascript"},canon:{resourceURL:"resources/canon/",description:"Manages commands and their keyboard shortcuts",
dependencies:{appsupport:"0.0",types:"0.0",settings:"0.0"},testmodules:["tests/testKeyboard"],provides:[{indexOn:"name",description:"A command is a bit of functionality with optional typed arguments which can do something small like moving the cursor around the screen, or large like cloning a project from VCS.",ep:"extensionpoint",name:"command"},{description:"How many typed commands do we recall for reference?",defaultValue:50,type:"number",ep:"setting",name:"historyLength"}],type:"plugins/supported",
name:"canon"},dock_view:{resourceURL:"resources/dock_view/",description:"A view that supports docked panels on the sides",testmodules:[],provides:[{pointer:"#DockView",ep:"appcomponent",name:"dock_view"}],type:"plugins/supported",name:"dock_view"},edit_session:{resourceURL:"resources/edit_session/",description:"Ties together the files being edited with the views on screen",dependencies:{text_editor:"0.0",appsupport:"0.0",delegate_support:"0.0",filesystem:"0.0"},testmodules:["tests/testHistory","tests/testSession"],
provides:[{pointer:"index#editSessionClasses",ep:"appcomponent",name:"edit_session"},{ep:"extensionpoint",name:"bufferFileChanged",description:"Notifies that the current file is changed."}],type:"plugins/supported",name:"edit_session"},rangeutils:{testmodules:["tests/test"],type:"plugins/supported",resourceURL:"resources/rangeutils/",description:"Utility functions for dealing with ranges of text",name:"rangeutils"},traits:{resourceURL:"resources/traits/",description:"Traits library, traitsjs.org",
dependencies:{},testmodules:[],provides:[],type:"plugins/thirdparty",name:"traits"},theme_manager:{testmodules:[],resourceURL:"resources/theme_manager/",name:"theme_manager",provides:[{pointer:"#themeManager",ep:"appcomponent",name:"theme_manager",description:"Applies styles to the Bespin UI"},{register:"#registerTheme",ep:"extensionhandler",name:"theme"},{indexOn:"name",ep:"extensionpoint",name:"theme"}],type:"plugins/supported"},html:{resourceURL:"resources/html/",description:"HTML syntax highlighter",
dependencies:{syntax_manager:"0.0"},testmodules:[],provides:[{pointer:"#HTMLSyntax",ep:"syntax",fileexts:["htm","html"],name:"html"}],type:"plugins/supported",name:"html"},screen_theme:{resourceURL:"resources/screen_theme/",name:"screen_theme",dependencies:{theme_manager:"0.0"},testmodules:[],provides:[{pointer:"#ScreenTheme",ep:"theme",name:"Screen"}],type:"plugins/supported"},filesystem:{resourceURL:"resources/filesystem/",description:"Provides the file and directory model used within Bespin",dependencies:{types:"0.0"},
testmodules:["tests/testFileManagement","tests/testPathUtils"],provides:[{description:"A pointer to a file which we believe to already exist",pointer:"types#existingFile",ep:"type",name:"existingFile"}],type:"plugins/supported",name:"filesystem"},appsupport:{resourceURL:"resources/appsupport/",description:"Common services used in the editor application",dependencies:{traits:"0.0"},testmodules:[],provides:[{unregister:"controllers/bespin#unregisterAppComponent",register:"controllers/bespin#registerAppComponent",
ep:"extensionhandler",name:"appcomponent"},{pointer:"controllers/undomanager#undoManagerCommand",ep:"command",key:["ctrl_shift_z"],name:"redo"},{pointer:"controllers/undomanager#undoManagerCommand",ep:"command",key:["ctrl_z"],name:"undo"}],type:"plugins/supported",name:"appsupport"},keylistener:{resourceURL:"resources/keylistener/",description:"Routes keys to the appropriate destination",dependencies:{canon:"0.0"},testmodules:[],provides:[{pointer:"#KeyListener",ep:"appcomponent",name:"key_listener"}],
type:"plugins/supported",name:"keylistener"},events:{resourceURL:"resources/events/",description:"Dead simple event implementation",dependencies:{traits:"0.0"},testmodules:["tests/test"],provides:[],type:"plugins/supported",name:"events"},types:{resourceURL:"resources/types/",description:"Defines parameter types for commands",testmodules:["tests/testBasic","tests/testTypes"],provides:[{indexOn:"name",description:"Commands can accept various arguments that the user enters or that are automatically supplied by the environment. Those arguments have types that define how they are supplied or completed. The pointer points to an object with methods convert(str value) and getDefault(). Both functions have `this` set to the command's `takes` parameter. If getDefault is not defined, the default on the command's `takes` is used, if there is one. The object can have a noInput property that is set to true to reflect that this type is provided directly by the system. getDefault must be defined in that case.",
ep:"extensionpoint",name:"type"},{description:"Text that the user needs to enter.",pointer:"basic#text",ep:"type",name:"text"},{description:"A JavaScript number",pointer:"basic#number",ep:"type",name:"number"},{description:"A true/false value",pointer:"basic#bool",ep:"type",name:"boolean"},{description:"An object that converts via JavaScript",pointer:"basic#object",ep:"type",name:"object"},{description:"A string that is constrained to be one of a number of pre-defined values",pointer:"basic#selection",
ep:"type",name:"selection"},{description:"A type which we don't understand from the outset, but which we hope context can help us with",ep:"type",name:"deferred"}],type:"plugins/supported",name:"types"},syntax_manager:{resourceURL:"resources/syntax_manager/",description:"Provides syntax highlighting services for the editor",dependencies:{rangeutils:"0.0",delegate_support:"0.0"},testmodules:[],provides:[{register:"controllers/syntaxdirectory#discoveredNewSyntax",ep:"extensionhandler",name:"syntax"},
{indexOn:"name",ep:"extensionpoint",name:"fileextension"}],type:"plugins/supported",name:"syntax_manager"}})});SC.ready(function(){for(var a=tiki.require("embedded"),b=document.querySelectorAll(".bespin"),c=0;c<b.length;c++){var d=b[c],e=d.getAttribute("data-bespinoptions");d.bespin=a.useBespin(d,JSON.parse(e))}window.onBespinLoad&&window.onBespinLoad()});document.addEventListener("DOMContentLoaded",SC.didLoad,false);window.tiki=tiki;
