/*!
 * jQuery JavaScript Library v1.11.1
 * http://jquery.com/
 *
 * Includes Sizzle.js
 * http://sizzlejs.com/
 *
 * Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors
 * Released under the MIT license
 * http://jquery.org/license
 *
 * Date: 2014-05-01T17:42Z
 */
(function(b,a){if(typeof module==="object"&&typeof module.exports==="object"){module.exports=b.document?a(b,true):function(c){if(!c.document){throw new Error("jQuery requires a window with a document")}return a(c)}}else{a(b)}}(typeof window!=="undefined"?window:this,function(a5,av){var aP=[];var P=aP.slice;var az=aP.concat;var w=aP.push;var bU=aP.indexOf;var ac={};var x=ac.toString;var J=ac.hasOwnProperty;var C={};var ai="1.11.1",bI=function(e,i){return new bI.fn.init(e,i)},D=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,bS=/^-ms-/,aW=/-([\da-z])/gi,O=function(e,i){return i.toUpperCase()};bI.fn=bI.prototype={jquery:ai,constructor:bI,selector:"",length:0,toArray:function(){return P.call(this)},get:function(e){return e!=null?(e<0?this[e+this.length]:this[e]):P.call(this)},pushStack:function(e){var i=bI.merge(this.constructor(),e);i.prevObject=this;i.context=this.context;return i},each:function(i,e){return bI.each(this,i,e)},map:function(e){return this.pushStack(bI.map(this,function(b7,b6){return e.call(b7,b6,b7)}))},slice:function(){return this.pushStack(P.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(b7){var e=this.length,b6=+b7+(b7<0?e:0);return this.pushStack(b6>=0&&b6<e?[this[b6]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:w,sort:aP.sort,splice:aP.splice};bI.extend=bI.fn.extend=function(){var e,cb,b6,b7,ce,cc,ca=arguments[0]||{},b9=1,b8=arguments.length,cd=false;if(typeof ca==="boolean"){cd=ca;ca=arguments[b9]||{};b9++}if(typeof ca!=="object"&&!bI.isFunction(ca)){ca={}}if(b9===b8){ca=this;b9--}for(;b9<b8;b9++){if((ce=arguments[b9])!=null){for(b7 in ce){e=ca[b7];b6=ce[b7];if(ca===b6){continue}if(cd&&b6&&(bI.isPlainObject(b6)||(cb=bI.isArray(b6)))){if(cb){cb=false;cc=e&&bI.isArray(e)?e:[]}else{cc=e&&bI.isPlainObject(e)?e:{}}ca[b7]=bI.extend(cd,cc,b6)}else{if(b6!==undefined){ca[b7]=b6}}}}}return ca};bI.extend({expando:"jQuery"+(ai+Math.random()).replace(/\D/g,""),isReady:true,error:function(e){throw new Error(e)},noop:function(){},isFunction:function(e){return bI.type(e)==="function"},isArray:Array.isArray||function(e){return bI.type(e)==="array"},isWindow:function(e){return e!=null&&e==e.window},isNumeric:function(e){return !bI.isArray(e)&&e-parseFloat(e)>=0},isEmptyObject:function(i){var e;for(e in i){return false}return true},isPlainObject:function(b7){var i;if(!b7||bI.type(b7)!=="object"||b7.nodeType||bI.isWindow(b7)){return false}try{if(b7.constructor&&!J.call(b7,"constructor")&&!J.call(b7.constructor.prototype,"isPrototypeOf")){return false}}catch(b6){return false}if(C.ownLast){for(i in b7){return J.call(b7,i)}}for(i in b7){}return i===undefined||J.call(b7,i)},type:function(e){if(e==null){return e+""}return typeof e==="object"||typeof e==="function"?ac[x.call(e)]||"object":typeof e},globalEval:function(e){if(e&&bI.trim(e)){(a5.execScript||function(i){a5["eval"].call(a5,i)})(e)}},camelCase:function(e){return e.replace(bS,"ms-").replace(aW,O)},nodeName:function(i,e){return i.nodeName&&i.nodeName.toLowerCase()===e.toLowerCase()},each:function(ca,cb,b6){var b9,b7=0,b8=ca.length,e=ad(ca);if(b6){if(e){for(;b7<b8;b7++){b9=cb.apply(ca[b7],b6);if(b9===false){break}}}else{for(b7 in ca){b9=cb.apply(ca[b7],b6);if(b9===false){break}}}}else{if(e){for(;b7<b8;b7++){b9=cb.call(ca[b7],b7,ca[b7]);if(b9===false){break}}}else{for(b7 in ca){b9=cb.call(ca[b7],b7,ca[b7]);if(b9===false){break}}}}return ca},trim:function(e){return e==null?"":(e+"").replace(D,"")},makeArray:function(e,b6){var i=b6||[];if(e!=null){if(ad(Object(e))){bI.merge(i,typeof e==="string"?[e]:e)}else{w.call(i,e)}}return i},inArray:function(b8,b6,b7){var e;if(b6){if(bU){return bU.call(b6,b8,b7)}e=b6.length;b7=b7?b7<0?Math.max(0,e+b7):b7:0;for(;b7<e;b7++){if(b7 in b6&&b6[b7]===b8){return b7}}}return -1},merge:function(b9,b7){var e=+b7.length,b6=0,b8=b9.length;while(b6<e){b9[b8++]=b7[b6++]}if(e!==e){while(b7[b6]!==undefined){b9[b8++]=b7[b6++]}}b9.length=b8;return b9},grep:function(e,cc,b9){var cb,b8=[],b6=0,b7=e.length,ca=!b9;for(;b6<b7;b6++){cb=!cc(e[b6],b6);if(cb!==ca){b8.push(e[b6])}}return b8},map:function(b7,cc,e){var cb,b9=0,ca=b7.length,b6=ad(b7),b8=[];if(b6){for(;b9<ca;b9++){cb=cc(b7[b9],b9,e);if(cb!=null){b8.push(cb)}}}else{for(b9 in b7){cb=cc(b7[b9],b9,e);if(cb!=null){b8.push(cb)}}}return az.apply([],b8)},guid:1,proxy:function(b8,b7){var e,b6,i;if(typeof b7==="string"){i=b8[b7];b7=b8;b8=i}if(!bI.isFunction(b8)){return undefined}e=P.call(arguments,2);b6=function(){return b8.apply(b7||this,e.concat(P.call(arguments)))};b6.guid=b8.guid=b8.guid||bI.guid++;return b6},now:function(){return +(new Date())},support:C});bI.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(b6,e){ac["[object "+e+"]"]=e.toLowerCase()});function ad(b6){var i=b6.length,e=bI.type(b6);if(e==="function"||bI.isWindow(b6)){return false}if(b6.nodeType===1&&i){return true}return e==="array"||i===0||typeof i==="number"&&i>0&&(i-1) in b6}var m=
/*!
 * Sizzle CSS Selector Engine v1.10.19
 * http://sizzlejs.com/
 *
 * Copyright 2013 jQuery Foundation, Inc. and other contributors
 * Released under the MIT license
 * http://jquery.org/license
 *
 * Date: 2014-04-18
 */
(function(de){var cx,dh,cn,cG,cJ,ch,cV,dg,dl,cH,cW,cY,cB,co,c7,c2,df,ce,cE,c9="sizzle"+-(new Date()),cI=de.document,di=0,c3=0,b9=cz(),c8=cz(),cF=cz(),cD=function(i,e){if(i===e){cW=true}return 0},dd=typeof undefined,cP=1<<31,cN=({}).hasOwnProperty,db=[],dc=db.pop,cL=db.push,b7=db.push,cm=db.slice,cd=db.indexOf||function(dn){var dm=0,e=this.length;for(;dm<e;dm++){if(this[dm]===dn){return dm}}return -1},b8="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",cp="[\\x20\\t\\r\\n\\f]",b6="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",cK=b6.replace("w","w#"),c5="\\["+cp+"*("+b6+")(?:"+cp+"*([*^$|!~]?=)"+cp+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+cK+"))|)"+cp+"*\\]",ck=":("+b6+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+c5+")*)|.*)\\)|)",cr=new RegExp("^"+cp+"+|((?:^|[^\\\\])(?:\\\\.)*)"+cp+"+$","g"),cu=new RegExp("^"+cp+"*,"+cp+"*"),cA=new RegExp("^"+cp+"*([>+~]|"+cp+")"+cp+"*"),ct=new RegExp("="+cp+"*([^\\]'\"]*?)"+cp+"*\\]","g"),cR=new RegExp(ck),cT=new RegExp("^"+cK+"$"),c1={ID:new RegExp("^#("+b6+")"),CLASS:new RegExp("^\\.("+b6+")"),TAG:new RegExp("^("+b6.replace("w","w*")+")"),ATTR:new RegExp("^"+c5),PSEUDO:new RegExp("^"+ck),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+cp+"*(even|odd|(([+-]|)(\\d*)n|)"+cp+"*(?:([+-]|)"+cp+"*(\\d+)|))"+cp+"*\\)|)","i"),bool:new RegExp("^(?:"+b8+")$","i"),needsContext:new RegExp("^"+cp+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+cp+"*((?:-\\d)?\\d*)"+cp+"*\\)|)(?=[^-]|$)","i")},cc=/^(?:input|select|textarea|button)$/i,cl=/^h\d$/i,cO=/^[^{]+\{\s*\[native \w/,cQ=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,c0=/[+~]/,cM=/'|\\/g,cs=new RegExp("\\\\([\\da-f]{1,6}"+cp+"?|("+cp+")|.)","ig"),c4=function(e,dn,i){var dm="0x"+dn-65536;return dm!==dm||i?dn:dm<0?String.fromCharCode(dm+65536):String.fromCharCode(dm>>10|55296,dm&1023|56320)};try{b7.apply((db=cm.call(cI.childNodes)),cI.childNodes);db[cI.childNodes.length].nodeType}catch(cC){b7={apply:db.length?function(i,e){cL.apply(i,cm.call(e))}:function(dp,dn){var e=dp.length,dm=0;while((dp[e++]=dn[dm++])){}dp.length=e-1}}}function cv(du,dm,dy,dA){var dz,dr,ds,dw,dx,dq,dp,e,dn,dv;if((dm?dm.ownerDocument||dm:cI)!==cB){cY(dm)}dm=dm||cB;dy=dy||[];if(!du||typeof du!=="string"){return dy}if((dw=dm.nodeType)!==1&&dw!==9){return[]}if(c7&&!dA){if((dz=cQ.exec(du))){if((ds=dz[1])){if(dw===9){dr=dm.getElementById(ds);if(dr&&dr.parentNode){if(dr.id===ds){dy.push(dr);return dy}}else{return dy}}else{if(dm.ownerDocument&&(dr=dm.ownerDocument.getElementById(ds))&&cE(dm,dr)&&dr.id===ds){dy.push(dr);return dy}}}else{if(dz[2]){b7.apply(dy,dm.getElementsByTagName(du));return dy}else{if((ds=dz[3])&&dh.getElementsByClassName&&dm.getElementsByClassName){b7.apply(dy,dm.getElementsByClassName(ds));return dy}}}}if(dh.qsa&&(!c2||!c2.test(du))){e=dp=c9;dn=dm;dv=dw===9&&du;if(dw===1&&dm.nodeName.toLowerCase()!=="object"){dq=ch(du);if((dp=dm.getAttribute("id"))){e=dp.replace(cM,"\\$&")}else{dm.setAttribute("id",e)}e="[id='"+e+"'] ";dx=dq.length;while(dx--){dq[dx]=e+ci(dq[dx])}dn=c0.test(du)&&cS(dm.parentNode)||dm;dv=dq.join(",")}if(dv){try{b7.apply(dy,dn.querySelectorAll(dv));return dy}catch(dt){}finally{if(!dp){dm.removeAttribute("id")}}}}}return dg(du.replace(cr,"$1"),dm,dy,dA)}function cz(){var i=[];function e(dm,dn){if(i.push(dm+" ")>cn.cacheLength){delete e[i.shift()]}return(e[dm+" "]=dn)}return e}function cj(e){e[c9]=true;return e}function cf(i){var dn=cB.createElement("div");try{return !!i(dn)}catch(dm){return false}finally{if(dn.parentNode){dn.parentNode.removeChild(dn)}dn=null}}function dj(dm,dp){var e=dm.split("|"),dn=dm.length;while(dn--){cn.attrHandle[e[dn]]=dp}}function ca(i,e){var dn=e&&i,dm=dn&&i.nodeType===1&&e.nodeType===1&&(~e.sourceIndex||cP)-(~i.sourceIndex||cP);if(dm){return dm}if(dn){while((dn=dn.nextSibling)){if(dn===e){return -1}}}return i?1:-1}function cw(e){return function(dm){var i=dm.nodeName.toLowerCase();return i==="input"&&dm.type===e}}function cb(e){return function(dm){var i=dm.nodeName.toLowerCase();return(i==="input"||i==="button")&&dm.type===e}}function c6(e){return cj(function(i){i=+i;return cj(function(dm,dr){var dp,dn=e([],dm.length,i),dq=dn.length;while(dq--){if(dm[(dp=dn[dq])]){dm[dp]=!(dr[dp]=dm[dp])}}})})}function cS(e){return e&&typeof e.getElementsByTagName!==dd&&e}dh=cv.support={};cJ=cv.isXML=function(e){var i=e&&(e.ownerDocument||e).documentElement;return i?i.nodeName!=="HTML":false};cY=cv.setDocument=function(dm){var e,dn=dm?dm.ownerDocument||dm:cI,i=dn.defaultView;if(dn===cB||dn.nodeType!==9||!dn.documentElement){return cB}cB=dn;co=dn.documentElement;c7=!cJ(dn);if(i&&i!==i.top){if(i.addEventListener){i.addEventListener("unload",function(){cY()},false)}else{if(i.attachEvent){i.attachEvent("onunload",function(){cY()})}}}dh.attributes=cf(function(dp){dp.className="i";return !dp.getAttribute("className")});dh.getElementsByTagName=cf(function(dp){dp.appendChild(dn.createComment(""));return !dp.getElementsByTagName("*").length});dh.getElementsByClassName=cO.test(dn.getElementsByClassName)&&cf(function(dp){dp.innerHTML="<div class='a'></div><div class='a i'></div>";dp.firstChild.className="i";return dp.getElementsByClassName("i").length===2});dh.getById=cf(function(dp){co.appendChild(dp).id=c9;return !dn.getElementsByName||!dn.getElementsByName(c9).length});if(dh.getById){cn.find.ID=function(dr,dq){if(typeof dq.getElementById!==dd&&c7){var dp=dq.getElementById(dr);return dp&&dp.parentNode?[dp]:[]}};cn.filter.ID=function(dq){var dp=dq.replace(cs,c4);return function(dr){return dr.getAttribute("id")===dp}}}else{delete cn.find.ID;cn.filter.ID=function(dq){var dp=dq.replace(cs,c4);return function(ds){var dr=typeof ds.getAttributeNode!==dd&&ds.getAttributeNode("id");return dr&&dr.value===dp}}}cn.find.TAG=dh.getElementsByTagName?function(dp,dq){if(typeof dq.getElementsByTagName!==dd){return dq.getElementsByTagName(dp)}}:function(dp,dt){var du,ds=[],dr=0,dq=dt.getElementsByTagName(dp);if(dp==="*"){while((du=dq[dr++])){if(du.nodeType===1){ds.push(du)}}return ds}return dq};cn.find.CLASS=dh.getElementsByClassName&&function(dq,dp){if(typeof dp.getElementsByClassName!==dd&&c7){return dp.getElementsByClassName(dq)}};df=[];c2=[];if((dh.qsa=cO.test(dn.querySelectorAll))){cf(function(dp){dp.innerHTML="<select msallowclip=''><option selected=''></option></select>";if(dp.querySelectorAll("[msallowclip^='']").length){c2.push("[*^$]="+cp+"*(?:''|\"\")")}if(!dp.querySelectorAll("[selected]").length){c2.push("\\["+cp+"*(?:value|"+b8+")")}if(!dp.querySelectorAll(":checked").length){c2.push(":checked")}});cf(function(dq){var dp=dn.createElement("input");dp.setAttribute("type","hidden");dq.appendChild(dp).setAttribute("name","D");if(dq.querySelectorAll("[name=d]").length){c2.push("name"+cp+"*[*^$|!~]?=")}if(!dq.querySelectorAll(":enabled").length){c2.push(":enabled",":disabled")}dq.querySelectorAll("*,:x");c2.push(",.*:")})}if((dh.matchesSelector=cO.test((ce=co.matches||co.webkitMatchesSelector||co.mozMatchesSelector||co.oMatchesSelector||co.msMatchesSelector)))){cf(function(dp){dh.disconnectedMatch=ce.call(dp,"div");ce.call(dp,"[s!='']:x");df.push("!=",ck)})}c2=c2.length&&new RegExp(c2.join("|"));df=df.length&&new RegExp(df.join("|"));e=cO.test(co.compareDocumentPosition);cE=e||cO.test(co.contains)?function(dq,dp){var ds=dq.nodeType===9?dq.documentElement:dq,dr=dp&&dp.parentNode;return dq===dr||!!(dr&&dr.nodeType===1&&(ds.contains?ds.contains(dr):dq.compareDocumentPosition&&dq.compareDocumentPosition(dr)&16))}:function(dq,dp){if(dp){while((dp=dp.parentNode)){if(dp===dq){return true}}}return false};cD=e?function(dq,dp){if(dq===dp){cW=true;return 0}var dr=!dq.compareDocumentPosition-!dp.compareDocumentPosition;if(dr){return dr}dr=(dq.ownerDocument||dq)===(dp.ownerDocument||dp)?dq.compareDocumentPosition(dp):1;if(dr&1||(!dh.sortDetached&&dp.compareDocumentPosition(dq)===dr)){if(dq===dn||dq.ownerDocument===cI&&cE(cI,dq)){return -1}if(dp===dn||dp.ownerDocument===cI&&cE(cI,dp)){return 1}return cH?(cd.call(cH,dq)-cd.call(cH,dp)):0}return dr&4?-1:1}:function(dq,dp){if(dq===dp){cW=true;return 0}var dw,dt=0,dv=dq.parentNode,ds=dp.parentNode,dr=[dq],du=[dp];if(!dv||!ds){return dq===dn?-1:dp===dn?1:dv?-1:ds?1:cH?(cd.call(cH,dq)-cd.call(cH,dp)):0}else{if(dv===ds){return ca(dq,dp)}}dw=dq;while((dw=dw.parentNode)){dr.unshift(dw)}dw=dp;while((dw=dw.parentNode)){du.unshift(dw)}while(dr[dt]===du[dt]){dt++}return dt?ca(dr[dt],du[dt]):dr[dt]===cI?-1:du[dt]===cI?1:0};return dn};cv.matches=function(i,e){return cv(i,null,null,e)};cv.matchesSelector=function(dm,dp){if((dm.ownerDocument||dm)!==cB){cY(dm)}dp=dp.replace(ct,"='$1']");if(dh.matchesSelector&&c7&&(!df||!df.test(dp))&&(!c2||!c2.test(dp))){try{var i=ce.call(dm,dp);if(i||dh.disconnectedMatch||dm.document&&dm.document.nodeType!==11){return i}}catch(dn){}}return cv(dp,cB,null,[dm]).length>0};cv.contains=function(e,i){if((e.ownerDocument||e)!==cB){cY(e)}return cE(e,i)};cv.attr=function(dm,e){if((dm.ownerDocument||dm)!==cB){cY(dm)}var i=cn.attrHandle[e.toLowerCase()],dn=i&&cN.call(cn.attrHandle,e.toLowerCase())?i(dm,e,!c7):undefined;return dn!==undefined?dn:dh.attributes||!c7?dm.getAttribute(e):(dn=dm.getAttributeNode(e))&&dn.specified?dn.value:null};cv.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)};cv.uniqueSort=function(dn){var dp,dq=[],e=0,dm=0;cW=!dh.detectDuplicates;cH=!dh.sortStable&&dn.slice(0);dn.sort(cD);if(cW){while((dp=dn[dm++])){if(dp===dn[dm]){e=dq.push(dm)}}while(e--){dn.splice(dq[e],1)}}cH=null;return dn};cG=cv.getText=function(dq){var dp,dm="",dn=0,e=dq.nodeType;if(!e){while((dp=dq[dn++])){dm+=cG(dp)}}else{if(e===1||e===9||e===11){if(typeof dq.textContent==="string"){return dq.textContent}else{for(dq=dq.firstChild;dq;dq=dq.nextSibling){dm+=cG(dq)}}}else{if(e===3||e===4){return dq.nodeValue}}}return dm};cn=cv.selectors={cacheLength:50,createPseudo:cj,match:c1,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:true}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:true},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){e[1]=e[1].replace(cs,c4);e[3]=(e[3]||e[4]||e[5]||"").replace(cs,c4);if(e[2]==="~="){e[3]=" "+e[3]+" "}return e.slice(0,4)},CHILD:function(e){e[1]=e[1].toLowerCase();if(e[1].slice(0,3)==="nth"){if(!e[3]){cv.error(e[0])}e[4]=+(e[4]?e[5]+(e[6]||1):2*(e[3]==="even"||e[3]==="odd"));e[5]=+((e[7]+e[8])||e[3]==="odd")}else{if(e[3]){cv.error(e[0])}}return e},PSEUDO:function(i){var e,dm=!i[6]&&i[2];if(c1.CHILD.test(i[0])){return null}if(i[3]){i[2]=i[4]||i[5]||""}else{if(dm&&cR.test(dm)&&(e=ch(dm,true))&&(e=dm.indexOf(")",dm.length-e)-dm.length)){i[0]=i[0].slice(0,e);i[2]=dm.slice(0,e)}}return i.slice(0,3)}},filter:{TAG:function(i){var e=i.replace(cs,c4).toLowerCase();return i==="*"?function(){return true}:function(dm){return dm.nodeName&&dm.nodeName.toLowerCase()===e}},CLASS:function(e){var i=b9[e+" "];return i||(i=new RegExp("(^|"+cp+")"+e+"("+cp+"|$)"))&&b9(e,function(dm){return i.test(typeof dm.className==="string"&&dm.className||typeof dm.getAttribute!==dd&&dm.getAttribute("class")||"")})},ATTR:function(dm,i,e){return function(dp){var dn=cv.attr(dp,dm);if(dn==null){return i==="!="}if(!i){return true}dn+="";return i==="="?dn===e:i==="!="?dn!==e:i==="^="?e&&dn.indexOf(e)===0:i==="*="?e&&dn.indexOf(e)>-1:i==="$="?e&&dn.slice(-e.length)===e:i==="~="?(" "+dn+" ").indexOf(e)>-1:i==="|="?dn===e||dn.slice(0,e.length+1)===e+"-":false}},CHILD:function(i,dp,dn,dq,dm){var ds=i.slice(0,3)!=="nth",e=i.slice(-4)!=="last",dr=dp==="of-type";return dq===1&&dm===0?function(dt){return !!dt.parentNode}:function(dz,dx,dC){var dt,dF,dA,dE,dB,dw,dy=ds!==e?"nextSibling":"previousSibling",dD=dz.parentNode,dv=dr&&dz.nodeName.toLowerCase(),du=!dC&&!dr;if(dD){if(ds){while(dy){dA=dz;while((dA=dA[dy])){if(dr?dA.nodeName.toLowerCase()===dv:dA.nodeType===1){return false}}dw=dy=i==="only"&&!dw&&"nextSibling"}return true}dw=[e?dD.firstChild:dD.lastChild];if(e&&du){dF=dD[c9]||(dD[c9]={});dt=dF[i]||[];dB=dt[0]===di&&dt[1];dE=dt[0]===di&&dt[2];dA=dB&&dD.childNodes[dB];while((dA=++dB&&dA&&dA[dy]||(dE=dB=0)||dw.pop())){if(dA.nodeType===1&&++dE&&dA===dz){dF[i]=[di,dB,dE];break}}}else{if(du&&(dt=(dz[c9]||(dz[c9]={}))[i])&&dt[0]===di){dE=dt[1]}else{while((dA=++dB&&dA&&dA[dy]||(dE=dB=0)||dw.pop())){if((dr?dA.nodeName.toLowerCase()===dv:dA.nodeType===1)&&++dE){if(du){(dA[c9]||(dA[c9]={}))[i]=[di,dE]}if(dA===dz){break}}}}}dE-=dm;return dE===dq||(dE%dq===0&&dE/dq>=0)}}},PSEUDO:function(dn,dm){var e,i=cn.pseudos[dn]||cn.setFilters[dn.toLowerCase()]||cv.error("unsupported pseudo: "+dn);if(i[c9]){return i(dm)}if(i.length>1){e=[dn,dn,"",dm];return cn.setFilters.hasOwnProperty(dn.toLowerCase())?cj(function(dr,dt){var dq,dp=i(dr,dm),ds=dp.length;while(ds--){dq=cd.call(dr,dp[ds]);dr[dq]=!(dt[dq]=dp[ds])}}):function(dp){return i(dp,0,e)}}return i}},pseudos:{not:cj(function(e){var i=[],dm=[],dn=cV(e.replace(cr,"$1"));return dn[c9]?cj(function(dq,dv,dt,dr){var du,dp=dn(dq,null,dr,[]),ds=dq.length;while(ds--){if((du=dp[ds])){dq[ds]=!(dv[ds]=du)}}}):function(dr,dq,dp){i[0]=dr;dn(i,null,dp,dm);return !dm.pop()}}),has:cj(function(e){return function(i){return cv(e,i).length>0}}),contains:cj(function(e){return function(i){return(i.textContent||i.innerText||cG(i)).indexOf(e)>-1}}),lang:cj(function(e){if(!cT.test(e||"")){cv.error("unsupported lang: "+e)}e=e.replace(cs,c4).toLowerCase();return function(dm){var i;do{if((i=c7?dm.lang:dm.getAttribute("xml:lang")||dm.getAttribute("lang"))){i=i.toLowerCase();return i===e||i.indexOf(e+"-")===0}}while((dm=dm.parentNode)&&dm.nodeType===1);return false}}),target:function(e){var i=de.location&&de.location.hash;return i&&i.slice(1)===e.id},root:function(e){return e===co},focus:function(e){return e===cB.activeElement&&(!cB.hasFocus||cB.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:function(e){return e.disabled===false},disabled:function(e){return e.disabled===true},checked:function(e){var i=e.nodeName.toLowerCase();return(i==="input"&&!!e.checked)||(i==="option"&&!!e.selected)},selected:function(e){if(e.parentNode){e.parentNode.selectedIndex}return e.selected===true},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling){if(e.nodeType<6){return false}}return true},parent:function(e){return !cn.pseudos.empty(e)},header:function(e){return cl.test(e.nodeName)},input:function(e){return cc.test(e.nodeName)},button:function(i){var e=i.nodeName.toLowerCase();return e==="input"&&i.type==="button"||e==="button"},text:function(i){var e;return i.nodeName.toLowerCase()==="input"&&i.type==="text"&&((e=i.getAttribute("type"))==null||e.toLowerCase()==="text")},first:c6(function(){return[0]}),last:c6(function(e,i){return[i-1]}),eq:c6(function(e,dm,i){return[i<0?i+dm:i]}),even:c6(function(e,dn){var dm=0;for(;dm<dn;dm+=2){e.push(dm)}return e}),odd:c6(function(e,dn){var dm=1;for(;dm<dn;dm+=2){e.push(dm)}return e}),lt:c6(function(e,dp,dn){var dm=dn<0?dn+dp:dn;for(;--dm>=0;){e.push(dm)}return e}),gt:c6(function(e,dp,dn){var dm=dn<0?dn+dp:dn;for(;++dm<dp;){e.push(dm)}return e})}};cn.pseudos.nth=cn.pseudos.eq;for(cx in {radio:true,checkbox:true,file:true,password:true,image:true}){cn.pseudos[cx]=cw(cx)}for(cx in {submit:true,reset:true}){cn.pseudos[cx]=cb(cx)}function cU(){}cU.prototype=cn.filters=cn.pseudos;cn.setFilters=new cU();ch=cv.tokenize=function(dp,du){var i,dq,ds,dt,dr,dm,e,dn=c8[dp+" "];if(dn){return du?0:dn.slice(0)}dr=dp;dm=[];e=cn.preFilter;while(dr){if(!i||(dq=cu.exec(dr))){if(dq){dr=dr.slice(dq[0].length)||dr}dm.push((ds=[]))}i=false;if((dq=cA.exec(dr))){i=dq.shift();ds.push({value:i,type:dq[0].replace(cr," ")});dr=dr.slice(i.length)}for(dt in cn.filter){if((dq=c1[dt].exec(dr))&&(!e[dt]||(dq=e[dt](dq)))){i=dq.shift();ds.push({value:i,type:dt,matches:dq});dr=dr.slice(i.length)}}if(!i){break}}return du?dr.length:dr?cv.error(dp):c8(dp,dm).slice(0)};function ci(dp){var dn=0,dm=dp.length,e="";for(;dn<dm;dn++){e+=dp[dn].value}return e}function cq(dp,dm,dn){var e=dm.dir,dq=dn&&e==="parentNode",i=c3++;return dm.first?function(dt,ds,dr){while((dt=dt[e])){if(dt.nodeType===1||dq){return dp(dt,ds,dr)}}}:function(dv,dt,ds){var dw,du,dr=[di,i];if(ds){while((dv=dv[e])){if(dv.nodeType===1||dq){if(dp(dv,dt,ds)){return true}}}}else{while((dv=dv[e])){if(dv.nodeType===1||dq){du=dv[c9]||(dv[c9]={});if((dw=du[e])&&dw[0]===di&&dw[1]===i){return(dr[2]=dw[2])}else{du[e]=dr;if((dr[2]=dp(dv,dt,ds))){return true}}}}}}}function dk(e){return e.length>1?function(dq,dp,dm){var dn=e.length;while(dn--){if(!e[dn](dq,dp,dm)){return false}}return true}:e[0]}function cy(dm,dq,dp){var dn=0,e=dq.length;for(;dn<e;dn++){cv(dm,dq[dn],dp)}return dp}function cZ(e,dm,dn,dp,ds){var dq,dv=[],dr=0,dt=e.length,du=dm!=null;for(;dr<dt;dr++){if((dq=e[dr])){if(!dn||dn(dq,dp,ds)){dv.push(dq);if(du){dm.push(dr)}}}}return dv}function cg(dm,i,dp,dn,dq,e){if(dn&&!dn[c9]){dn=cg(dn)}if(dq&&!dq[c9]){dq=cg(dq,e)}return cj(function(dB,dy,dt,dA){var dD,dz,dv,du=[],dC=[],ds=dy.length,dr=dB||cy(i||"*",dt.nodeType?[dt]:dt,[]),dw=dm&&(dB||!i)?cZ(dr,du,dm,dt,dA):dr,dx=dp?dq||(dB?dm:ds||dn)?[]:dy:dw;if(dp){dp(dw,dx,dt,dA)}if(dn){dD=cZ(dx,dC);dn(dD,[],dt,dA);dz=dD.length;while(dz--){if((dv=dD[dz])){dx[dC[dz]]=!(dw[dC[dz]]=dv)}}}if(dB){if(dq||dm){if(dq){dD=[];dz=dx.length;while(dz--){if((dv=dx[dz])){dD.push((dw[dz]=dv))}}dq(null,(dx=[]),dD,dA)}dz=dx.length;while(dz--){if((dv=dx[dz])&&(dD=dq?cd.call(dB,dv):du[dz])>-1){dB[dD]=!(dy[dD]=dv)}}}}else{dx=cZ(dx===dy?dx.splice(ds,dx.length):dx);if(dq){dq(null,dy,dx,dA)}else{b7.apply(dy,dx)}}})}function da(ds){var dm,dq,dn,dr=ds.length,dv=cn.relative[ds[0].type],dw=dv||cn.relative[" "],dp=dv?1:0,dt=cq(function(i){return i===dm},dw,true),du=cq(function(i){return cd.call(dm,i)>-1},dw,true),e=[function(dy,dx,i){return(!dv&&(i||dx!==dl))||((dm=dx).nodeType?dt(dy,dx,i):du(dy,dx,i))}];for(;dp<dr;dp++){if((dq=cn.relative[ds[dp].type])){e=[cq(dk(e),dq)]}else{dq=cn.filter[ds[dp].type].apply(null,ds[dp].matches);if(dq[c9]){dn=++dp;for(;dn<dr;dn++){if(cn.relative[ds[dn].type]){break}}return cg(dp>1&&dk(e),dp>1&&ci(ds.slice(0,dp-1).concat({value:ds[dp-2].type===" "?"*":""})).replace(cr,"$1"),dq,dp<dn&&da(ds.slice(dp,dn)),dn<dr&&da((ds=ds.slice(dn))),dn<dr&&ci(ds))}e.push(dq)}}return dk(e)}function cX(dn,dm){var e=dm.length>0,dp=dn.length>0,i=function(dz,dt,dy,dx,dC){var du,dv,dA,dE=0,dw="0",dq=dz&&[],dF=[],dD=dl,ds=dz||dp&&cn.find.TAG("*",dC),dr=(di+=dD==null?1:Math.random()||0.1),dB=ds.length;if(dC){dl=dt!==cB&&dt}for(;dw!==dB&&(du=ds[dw])!=null;dw++){if(dp&&du){dv=0;while((dA=dn[dv++])){if(dA(du,dt,dy)){dx.push(du);break}}if(dC){di=dr}}if(e){if((du=!dA&&du)){dE--}if(dz){dq.push(du)}}}dE+=dw;if(e&&dw!==dE){dv=0;while((dA=dm[dv++])){dA(dq,dF,dt,dy)}if(dz){if(dE>0){while(dw--){if(!(dq[dw]||dF[dw])){dF[dw]=dc.call(dx)}}}dF=cZ(dF)}b7.apply(dx,dF);if(dC&&!dz&&dF.length>0&&(dE+dm.length)>1){cv.uniqueSort(dx)}}if(dC){di=dr;dl=dD}return dq};return e?cj(i):i}cV=cv.compile=function(e,dn){var dp,dm=[],dr=[],dq=cF[e+" "];if(!dq){if(!dn){dn=ch(e)}dp=dn.length;while(dp--){dq=da(dn[dp]);if(dq[c9]){dm.push(dq)}else{dr.push(dq)}}dq=cF(e,cX(dr,dm));dq.selector=e}return dq};dg=cv.select=function(dn,e,dp,ds){var dq,dv,dm,dw,dt,du=typeof dn==="function"&&dn,dr=!ds&&ch((dn=du.selector||dn));dp=dp||[];if(dr.length===1){dv=dr[0]=dr[0].slice(0);if(dv.length>2&&(dm=dv[0]).type==="ID"&&dh.getById&&e.nodeType===9&&c7&&cn.relative[dv[1].type]){e=(cn.find.ID(dm.matches[0].replace(cs,c4),e)||[])[0];if(!e){return dp}else{if(du){e=e.parentNode}}dn=dn.slice(dv.shift().value.length)}dq=c1.needsContext.test(dn)?0:dv.length;while(dq--){dm=dv[dq];if(cn.relative[(dw=dm.type)]){break}if((dt=cn.find[dw])){if((ds=dt(dm.matches[0].replace(cs,c4),c0.test(dv[0].type)&&cS(e.parentNode)||e))){dv.splice(dq,1);dn=ds.length&&ci(dv);if(!dn){b7.apply(dp,ds);return dp}break}}}}(du||cV(dn,dr))(ds,e,!c7,dp,c0.test(dn)&&cS(e.parentNode)||e);return dp};dh.sortStable=c9.split("").sort(cD).join("")===c9;dh.detectDuplicates=!!cW;cY();dh.sortDetached=cf(function(e){return e.compareDocumentPosition(cB.createElement("div"))&1});if(!cf(function(e){e.innerHTML="<a href='#'></a>";return e.firstChild.getAttribute("href")==="#"})){dj("type|href|height|width",function(i,e,dm){if(!dm){return i.getAttribute(e,e.toLowerCase()==="type"?1:2)}})}if(!dh.attributes||!cf(function(e){e.innerHTML="<input/>";e.firstChild.setAttribute("value","");return e.firstChild.getAttribute("value")===""})){dj("value",function(i,e,dm){if(!dm&&i.nodeName.toLowerCase()==="input"){return i.defaultValue}})}if(!cf(function(e){return e.getAttribute("disabled")==null})){dj(b8,function(i,e,dn){var dm;if(!dn){return i[e]===true?e.toLowerCase():(dm=i.getAttributeNode(e))&&dm.specified?dm.value:null}})}return cv})(a5);bI.find=m;bI.expr=m.selectors;bI.expr[":"]=bI.expr.pseudos;bI.unique=m.uniqueSort;bI.text=m.getText;bI.isXMLDoc=m.isXML;bI.contains=m.contains;var z=bI.expr.match.needsContext;var a=(/^<(\w+)\s*\/?>(?:<\/\1>|)$/);var aL=/^.[^:#\[\.,]*$/;function aR(b6,e,i){if(bI.isFunction(e)){return bI.grep(b6,function(b8,b7){return !!e.call(b8,b7,b8)!==i})}if(e.nodeType){return bI.grep(b6,function(b7){return(b7===e)!==i})}if(typeof e==="string"){if(aL.test(e)){return bI.filter(e,b6,i)}e=bI.filter(e,b6)}return bI.grep(b6,function(b7){return(bI.inArray(b7,e)>=0)!==i})}bI.filter=function(b7,e,b6){var i=e[0];if(b6){b7=":not("+b7+")"}return e.length===1&&i.nodeType===1?bI.find.matchesSelector(i,b7)?[i]:[]:bI.find.matches(b7,bI.grep(e,function(b8){return b8.nodeType===1}))};bI.fn.extend({find:function(b6){var b9,b8=[],b7=this,e=b7.length;if(typeof b6!=="string"){return this.pushStack(bI(b6).filter(function(){for(b9=0;b9<e;b9++){if(bI.contains(b7[b9],this)){return true}}}))}for(b9=0;b9<e;b9++){bI.find(b6,b7[b9],b8)}b8=this.pushStack(e>1?bI.unique(b8):b8);b8.selector=this.selector?this.selector+" "+b6:b6;return b8},filter:function(e){return this.pushStack(aR(this,e||[],false))},not:function(e){return this.pushStack(aR(this,e||[],true))},is:function(e){return !!aR(this,typeof e==="string"&&z.test(e)?bI(e):e||[],false).length}});var y,n=a5.document,bt=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,bV=bI.fn.init=function(e,b6){var i,b7;if(!e){return this}if(typeof e==="string"){if(e.charAt(0)==="<"&&e.charAt(e.length-1)===">"&&e.length>=3){i=[null,e,null]}else{i=bt.exec(e)}if(i&&(i[1]||!b6)){if(i[1]){b6=b6 instanceof bI?b6[0]:b6;bI.merge(this,bI.parseHTML(i[1],b6&&b6.nodeType?b6.ownerDocument||b6:n,true));if(a.test(i[1])&&bI.isPlainObject(b6)){for(i in b6){if(bI.isFunction(this[i])){this[i](b6[i])}else{this.attr(i,b6[i])}}}return this}else{b7=n.getElementById(i[2]);if(b7&&b7.parentNode){if(b7.id!==i[2]){return y.find(e)}this.length=1;this[0]=b7}this.context=n;this.selector=e;return this}}else{if(!b6||b6.jquery){return(b6||y).find(e)}else{return this.constructor(b6).find(e)}}}else{if(e.nodeType){this.context=this[0]=e;this.length=1;return this}else{if(bI.isFunction(e)){return typeof y.ready!=="undefined"?y.ready(e):e(bI)}}}if(e.selector!==undefined){this.selector=e.selector;this.context=e.context}return bI.makeArray(e,this)};bV.prototype=bI.fn;y=bI(n);var bv=/^(?:parents|prev(?:Until|All))/,bz={children:true,contents:true,next:true,prev:true};bI.extend({dir:function(b6,i,b8){var e=[],b7=b6[i];while(b7&&b7.nodeType!==9&&(b8===undefined||b7.nodeType!==1||!bI(b7).is(b8))){if(b7.nodeType===1){e.push(b7)}b7=b7[i]}return e},sibling:function(b6,i){var e=[];for(;b6;b6=b6.nextSibling){if(b6.nodeType===1&&b6!==i){e.push(b6)}}return e}});bI.fn.extend({has:function(b8){var b7,b6=bI(b8,this),e=b6.length;return this.filter(function(){for(b7=0;b7<e;b7++){if(bI.contains(this,b6[b7])){return true}}})},closest:function(b9,b8){var ca,b7=0,b6=this.length,e=[],cb=z.test(b9)||typeof b9!=="string"?bI(b9,b8||this.context):0;for(;b7<b6;b7++){for(ca=this[b7];ca&&ca!==b8;ca=ca.parentNode){if(ca.nodeType<11&&(cb?cb.index(ca)>-1:ca.nodeType===1&&bI.find.matchesSelector(ca,b9))){e.push(ca);break}}}return this.pushStack(e.length>1?bI.unique(e):e)},index:function(e){if(!e){return(this[0]&&this[0].parentNode)?this.first().prevAll().length:-1}if(typeof e==="string"){return bI.inArray(this[0],bI(e))}return bI.inArray(e.jquery?e[0]:e,this)},add:function(e,i){return this.pushStack(bI.unique(bI.merge(this.get(),bI(e,i))))},addBack:function(e){return this.add(e==null?this.prevObject:this.prevObject.filter(e))}});function aY(i,e){do{i=i[e]}while(i&&i.nodeType!==1);return i}bI.each({parent:function(i){var e=i.parentNode;return e&&e.nodeType!==11?e:null},parents:function(e){return bI.dir(e,"parentNode")},parentsUntil:function(b6,e,b7){return bI.dir(b6,"parentNode",b7)},next:function(e){return aY(e,"nextSibling")},prev:function(e){return aY(e,"previousSibling")},nextAll:function(e){return bI.dir(e,"nextSibling")},prevAll:function(e){return bI.dir(e,"previousSibling")},nextUntil:function(b6,e,b7){return bI.dir(b6,"nextSibling",b7)},prevUntil:function(b6,e,b7){return bI.dir(b6,"previousSibling",b7)},siblings:function(e){return bI.sibling((e.parentNode||{}).firstChild,e)},children:function(e){return bI.sibling(e.firstChild)},contents:function(e){return bI.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:bI.merge([],e.childNodes)}},function(e,i){bI.fn[e]=function(b8,b6){var b7=bI.map(this,i,b8);if(e.slice(-5)!=="Until"){b6=b8}if(b6&&typeof b6==="string"){b7=bI.filter(b6,b7)}if(this.length>1){if(!bz[e]){b7=bI.unique(b7)}if(bv.test(e)){b7=b7.reverse()}}return this.pushStack(b7)}});var aF=(/\S+/g);var b2={};function af(i){var e=b2[i]={};bI.each(i.match(aF)||[],function(b7,b6){e[b6]=true});return e}bI.Callbacks=function(ce){ce=typeof ce==="string"?(b2[ce]||af(ce)):bI.extend({},ce);var b8,b7,e,b9,ca,b6,cb=[],cc=!ce.once&&[],i=function(cf){b7=ce.memory&&cf;e=true;ca=b6||0;b6=0;b9=cb.length;b8=true;for(;cb&&ca<b9;ca++){if(cb[ca].apply(cf[0],cf[1])===false&&ce.stopOnFalse){b7=false;break}}b8=false;if(cb){if(cc){if(cc.length){i(cc.shift())}}else{if(b7){cb=[]}else{cd.disable()}}}},cd={add:function(){if(cb){var cg=cb.length;(function cf(ch){bI.each(ch,function(cj,ci){var ck=bI.type(ci);if(ck==="function"){if(!ce.unique||!cd.has(ci)){cb.push(ci)}}else{if(ci&&ci.length&&ck!=="string"){cf(ci)}}})})(arguments);if(b8){b9=cb.length}else{if(b7){b6=cg;i(b7)}}}return this},remove:function(){if(cb){bI.each(arguments,function(ch,cf){var cg;while((cg=bI.inArray(cf,cb,cg))>-1){cb.splice(cg,1);if(b8){if(cg<=b9){b9--}if(cg<=ca){ca--}}}})}return this},has:function(cf){return cf?bI.inArray(cf,cb)>-1:!!(cb&&cb.length)},empty:function(){cb=[];b9=0;return this},disable:function(){cb=cc=b7=undefined;return this},disabled:function(){return !cb},lock:function(){cc=undefined;if(!b7){cd.disable()}return this},locked:function(){return !cc},fireWith:function(cg,cf){if(cb&&(!e||cc)){cf=cf||[];cf=[cg,cf.slice?cf.slice():cf];if(b8){cc.push(cf)}else{i(cf)}}return this},fire:function(){cd.fireWith(this,arguments);return this},fired:function(){return !!e}};return cd};bI.extend({Deferred:function(b6){var i=[["resolve","done",bI.Callbacks("once memory"),"resolved"],["reject","fail",bI.Callbacks("once memory"),"rejected"],["notify","progress",bI.Callbacks("memory")]],b7="pending",b8={state:function(){return b7},always:function(){e.done(arguments).fail(arguments);return this},then:function(){var b9=arguments;return bI.Deferred(function(ca){bI.each(i,function(cc,cb){var cd=bI.isFunction(b9[cc])&&b9[cc];e[cb[1]](function(){var ce=cd&&cd.apply(this,arguments);if(ce&&bI.isFunction(ce.promise)){ce.promise().done(ca.resolve).fail(ca.reject).progress(ca.notify)}else{ca[cb[0]+"With"](this===b8?ca.promise():this,cd?[ce]:arguments)}})});b9=null}).promise()},promise:function(b9){return b9!=null?bI.extend(b9,b8):b8}},e={};b8.pipe=b8.then;bI.each(i,function(ca,b9){var cc=b9[2],cb=b9[3];b8[b9[1]]=cc.add;if(cb){cc.add(function(){b7=cb},i[ca^1][2].disable,i[2][2].lock)}e[b9[0]]=function(){e[b9[0]+"With"](this===e?b8:this,arguments);return this};e[b9[0]+"With"]=cc.fireWith});b8.promise(e);if(b6){b6.call(e,e)}return e},when:function(b9){var b7=0,cb=P.call(arguments),e=cb.length,b6=e!==1||(b9&&bI.isFunction(b9.promise))?e:0,ce=b6===1?b9:bI.Deferred(),b8=function(cg,ch,cf){return function(i){ch[cg]=this;cf[cg]=arguments.length>1?P.call(arguments):i;if(cf===cd){ce.notifyWith(ch,cf)}else{if(!(--b6)){ce.resolveWith(ch,cf)}}}},cd,ca,cc;if(e>1){cd=new Array(e);ca=new Array(e);cc=new Array(e);for(;b7<e;b7++){if(cb[b7]&&bI.isFunction(cb[b7].promise)){cb[b7].promise().done(b8(b7,cc,cb)).fail(ce.reject).progress(b8(b7,ca,cd))}else{--b6}}}if(!b6){ce.resolveWith(cc,cb)}return ce.promise()}});var ak;bI.fn.ready=function(e){bI.ready.promise().done(e);return this};bI.extend({isReady:false,readyWait:1,holdReady:function(e){if(e){bI.readyWait++}else{bI.ready(true)}},ready:function(e){if(e===true?--bI.readyWait:bI.isReady){return}if(!n.body){return setTimeout(bI.ready)}bI.isReady=true;if(e!==true&&--bI.readyWait>0){return}ak.resolveWith(n,[bI]);if(bI.fn.triggerHandler){bI(n).triggerHandler("ready");bI(n).off("ready")}}});function bm(){if(n.addEventListener){n.removeEventListener("DOMContentLoaded",bZ,false);a5.removeEventListener("load",bZ,false)}else{n.detachEvent("onreadystatechange",bZ);a5.detachEvent("onload",bZ)}}function bZ(){if(n.addEventListener||event.type==="load"||n.readyState==="complete"){bm();bI.ready()}}bI.ready.promise=function(b8){if(!ak){ak=bI.Deferred();if(n.readyState==="complete"){setTimeout(bI.ready)}else{if(n.addEventListener){n.addEventListener("DOMContentLoaded",bZ,false);a5.addEventListener("load",bZ,false)}else{n.attachEvent("onreadystatechange",bZ);a5.attachEvent("onload",bZ);var b7=false;try{b7=a5.frameElement==null&&n.documentElement}catch(b6){}if(b7&&b7.doScroll){(function i(){if(!bI.isReady){try{b7.doScroll("left")}catch(b9){return setTimeout(i,50)}bm();bI.ready()}})()}}}}return ak.promise(b8)};var aC=typeof undefined;var bh;for(bh in bI(C)){break}C.ownLast=bh!=="0";C.inlineBlockNeedsLayout=false;bI(function(){var b6,b7,e,i;e=n.getElementsByTagName("body")[0];if(!e||!e.style){return}b7=n.createElement("div");i=n.createElement("div");i.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px";e.appendChild(i).appendChild(b7);if(typeof b7.style.zoom!==aC){b7.style.cssText="display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1";C.inlineBlockNeedsLayout=b6=b7.offsetWidth===3;if(b6){e.style.zoom=1}}e.removeChild(i)});(function(){var b6=n.createElement("div");if(C.deleteExpando==null){C.deleteExpando=true;try{delete b6.test}catch(i){C.deleteExpando=false}}b6=null})();bI.acceptData=function(b6){var i=bI.noData[(b6.nodeName+" ").toLowerCase()],e=+b6.nodeType||1;return e!==1&&e!==9?false:!i||i!==true&&b6.getAttribute("classid")===i};var by=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,aQ=/([A-Z])/g;function bA(b7,b6,b8){if(b8===undefined&&b7.nodeType===1){var i="data-"+b6.replace(aQ,"-$1").toLowerCase();b8=b7.getAttribute(i);if(typeof b8==="string"){try{b8=b8==="true"?true:b8==="false"?false:b8==="null"?null:+b8+""===b8?+b8:by.test(b8)?bI.parseJSON(b8):b8}catch(b9){}bI.data(b7,b6,b8)}else{b8=undefined}}return b8}function Q(i){var e;for(e in i){if(e==="data"&&bI.isEmptyObject(i[e])){continue}if(e!=="toJSON"){return false}}return true}function bc(b7,i,b9,b8){if(!bI.acceptData(b7)){return}var cb,ca,cc=bI.expando,cd=b7.nodeType,e=cd?bI.cache:b7,b6=cd?b7[cc]:b7[cc]&&cc;if((!b6||!e[b6]||(!b8&&!e[b6].data))&&b9===undefined&&typeof i==="string"){return}if(!b6){if(cd){b6=b7[cc]=aP.pop()||bI.guid++}else{b6=cc}}if(!e[b6]){e[b6]=cd?{}:{toJSON:bI.noop}}if(typeof i==="object"||typeof i==="function"){if(b8){e[b6]=bI.extend(e[b6],i)}else{e[b6].data=bI.extend(e[b6].data,i)}}ca=e[b6];if(!b8){if(!ca.data){ca.data={}}ca=ca.data}if(b9!==undefined){ca[bI.camelCase(i)]=b9}if(typeof i==="string"){cb=ca[i];if(cb==null){cb=ca[bI.camelCase(i)]}}else{cb=ca}return cb}function ab(b9,b7,e){if(!bI.acceptData(b9)){return}var cb,b8,ca=b9.nodeType,b6=ca?bI.cache:b9,cc=ca?b9[bI.expando]:bI.expando;if(!b6[cc]){return}if(b7){cb=e?b6[cc]:b6[cc].data;if(cb){if(!bI.isArray(b7)){if(b7 in cb){b7=[b7]}else{b7=bI.camelCase(b7);if(b7 in cb){b7=[b7]}else{b7=b7.split(" ")}}}else{b7=b7.concat(bI.map(b7,bI.camelCase))}b8=b7.length;while(b8--){delete cb[b7[b8]]}if(e?!Q(cb):!bI.isEmptyObject(cb)){return}}}if(!e){delete b6[cc].data;if(!Q(b6[cc])){return}}if(ca){bI.cleanData([b9],true)}else{if(C.deleteExpando||b6!=b6.window){delete b6[cc]}else{b6[cc]=null}}}bI.extend({cache:{},noData:{"applet ":true,"embed ":true,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(e){e=e.nodeType?bI.cache[e[bI.expando]]:e[bI.expando];return !!e&&!Q(e)},data:function(i,e,b6){return bc(i,e,b6)},removeData:function(i,e){return ab(i,e)},_data:function(i,e,b6){return bc(i,e,b6,true)},_removeData:function(i,e){return ab(i,e,true)}});bI.fn.extend({data:function(b8,cb){var b7,b6,ca,b9=this[0],e=b9&&b9.attributes;if(b8===undefined){if(this.length){ca=bI.data(b9);if(b9.nodeType===1&&!bI._data(b9,"parsedAttrs")){b7=e.length;while(b7--){if(e[b7]){b6=e[b7].name;if(b6.indexOf("data-")===0){b6=bI.camelCase(b6.slice(5));bA(b9,b6,ca[b6])}}}bI._data(b9,"parsedAttrs",true)}}return ca}if(typeof b8==="object"){return this.each(function(){bI.data(this,b8)})}return arguments.length>1?this.each(function(){bI.data(this,b8,cb)}):b9?bA(b9,b8,bI.data(b9,b8)):undefined},removeData:function(e){return this.each(function(){bI.removeData(this,e)})}});bI.extend({queue:function(b6,i,b7){var e;if(b6){i=(i||"fx")+"queue";e=bI._data(b6,i);if(b7){if(!e||bI.isArray(b7)){e=bI._data(b6,i,bI.makeArray(b7))}else{e.push(b7)}}return e||[]}},dequeue:function(b9,b8){b8=b8||"fx";var i=bI.queue(b9,b8),ca=i.length,b7=i.shift(),e=bI._queueHooks(b9,b8),b6=function(){bI.dequeue(b9,b8)};if(b7==="inprogress"){b7=i.shift();ca--}if(b7){if(b8==="fx"){i.unshift("inprogress")}delete e.stop;b7.call(b9,b6,e)}if(!ca&&e){e.empty.fire()}},_queueHooks:function(b6,i){var e=i+"queueHooks";return bI._data(b6,e)||bI._data(b6,e,{empty:bI.Callbacks("once memory").add(function(){bI._removeData(b6,i+"queue");bI._removeData(b6,e)})})}});bI.fn.extend({queue:function(e,i){var b6=2;if(typeof e!=="string"){i=e;e="fx";b6--}if(arguments.length<b6){return bI.queue(this[0],e)}return i===undefined?this:this.each(function(){var b7=bI.queue(this,e,i);bI._queueHooks(this,e);if(e==="fx"&&b7[0]!=="inprogress"){bI.dequeue(this,e)}})},dequeue:function(e){return this.each(function(){bI.dequeue(this,e)})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(b7,cb){var b6,b8=1,cc=bI.Deferred(),ca=this,e=this.length,b9=function(){if(!(--b8)){cc.resolveWith(ca,[ca])}};if(typeof b7!=="string"){cb=b7;b7=undefined}b7=b7||"fx";while(e--){b6=bI._data(ca[e],b7+"queueHooks");if(b6&&b6.empty){b8++;b6.empty.add(b9)}}b9();return cc.promise(cb)}});var aE=(/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source;var bT=["Top","Right","Bottom","Left"];var S=function(i,e){i=e||i;return bI.css(i,"display")==="none"||!bI.contains(i.ownerDocument,i)};var aB=bI.access=function(e,ca,cc,cb,b8,ce,cd){var b7=0,b6=e.length,b9=cc==null;if(bI.type(cc)==="object"){b8=true;for(b7 in cc){bI.access(e,ca,b7,cc[b7],true,ce,cd)}}else{if(cb!==undefined){b8=true;if(!bI.isFunction(cb)){cd=true}if(b9){if(cd){ca.call(e,cb);ca=null}else{b9=ca;ca=function(cf,i,cg){return b9.call(bI(cf),cg)}}}if(ca){for(;b7<b6;b7++){ca(e[b7],cc,cd?cb:cb.call(e[b7],b7,ca(e[b7],cc)))}}}}return b8?e:b9?ca.call(e):b6?ca(e[0],cc):ce};var aM=(/^(?:checkbox|radio)$/i);(function(){var i=n.createElement("input"),b8=n.createElement("div"),b6=n.createDocumentFragment();b8.innerHTML="  <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";C.leadingWhitespace=b8.firstChild.nodeType===3;C.tbody=!b8.getElementsByTagName("tbody").length;C.htmlSerialize=!!b8.getElementsByTagName("link").length;C.html5Clone=n.createElement("nav").cloneNode(true).outerHTML!=="<:nav></:nav>";i.type="checkbox";i.checked=true;b6.appendChild(i);C.appendChecked=i.checked;b8.innerHTML="<textarea>x</textarea>";C.noCloneChecked=!!b8.cloneNode(true).lastChild.defaultValue;b6.appendChild(b8);b8.innerHTML="<input type='radio' checked='checked' name='t'/>";C.checkClone=b8.cloneNode(true).cloneNode(true).lastChild.checked;C.noCloneEvent=true;if(b8.attachEvent){b8.attachEvent("onclick",function(){C.noCloneEvent=false});b8.cloneNode(true).click()}if(C.deleteExpando==null){C.deleteExpando=true;try{delete b8.test}catch(b7){C.deleteExpando=false}}})();(function(){var b6,e,b7=n.createElement("div");for(b6 in {submit:true,change:true,focusin:true}){e="on"+b6;if(!(C[b6+"Bubbles"]=e in a5)){b7.setAttribute(e,"t");C[b6+"Bubbles"]=b7.attributes[e].expando===false}}b7=null})();var bG=/^(?:input|select|textarea)$/i,a6=/^key/,bM=/^(?:mouse|pointer|contextmenu)|click/,bC=/^(?:focusinfocus|focusoutblur)$/,bx=/^([^.]*)(?:\.(.+)|)$/;function U(){return true}function Z(){return false}function am(){try{return n.activeElement}catch(e){}}bI.event={global:{},add:function(b8,cd,ci,ca,b9){var cb,cj,ck,b6,cf,cc,ch,b7,cg,e,i,ce=bI._data(b8);if(!ce){return}if(ci.handler){b6=ci;ci=b6.handler;b9=b6.selector}if(!ci.guid){ci.guid=bI.guid++}if(!(cj=ce.events)){cj=ce.events={}}if(!(cc=ce.handle)){cc=ce.handle=function(cl){return typeof bI!==aC&&(!cl||bI.event.triggered!==cl.type)?bI.event.dispatch.apply(cc.elem,arguments):undefined};cc.elem=b8}cd=(cd||"").match(aF)||[""];ck=cd.length;while(ck--){cb=bx.exec(cd[ck])||[];cg=i=cb[1];e=(cb[2]||"").split(".").sort();if(!cg){continue}cf=bI.event.special[cg]||{};cg=(b9?cf.delegateType:cf.bindType)||cg;cf=bI.event.special[cg]||{};ch=bI.extend({type:cg,origType:i,data:ca,handler:ci,guid:ci.guid,selector:b9,needsContext:b9&&bI.expr.match.needsContext.test(b9),namespace:e.join(".")},b6);if(!(b7=cj[cg])){b7=cj[cg]=[];b7.delegateCount=0;if(!cf.setup||cf.setup.call(b8,ca,e,cc)===false){if(b8.addEventListener){b8.addEventListener(cg,cc,false)}else{if(b8.attachEvent){b8.attachEvent("on"+cg,cc)}}}}if(cf.add){cf.add.call(b8,ch);if(!ch.handler.guid){ch.handler.guid=ci.guid}}if(b9){b7.splice(b7.delegateCount++,0,ch)}else{b7.push(ch)}bI.event.global[cg]=true}b8=null},remove:function(b7,cd,ck,b8,cc){var ca,ch,cb,b9,cj,ci,cf,b6,cg,e,i,ce=bI.hasData(b7)&&bI._data(b7);if(!ce||!(ci=ce.events)){return}cd=(cd||"").match(aF)||[""];cj=cd.length;while(cj--){cb=bx.exec(cd[cj])||[];cg=i=cb[1];e=(cb[2]||"").split(".").sort();if(!cg){for(cg in ci){bI.event.remove(b7,cg+cd[cj],ck,b8,true)}continue}cf=bI.event.special[cg]||{};cg=(b8?cf.delegateType:cf.bindType)||cg;b6=ci[cg]||[];cb=cb[2]&&new RegExp("(^|\\.)"+e.join("\\.(?:.*\\.|)")+"(\\.|$)");b9=ca=b6.length;while(ca--){ch=b6[ca];if((cc||i===ch.origType)&&(!ck||ck.guid===ch.guid)&&(!cb||cb.test(ch.namespace))&&(!b8||b8===ch.selector||b8==="**"&&ch.selector)){b6.splice(ca,1);if(ch.selector){b6.delegateCount--}if(cf.remove){cf.remove.call(b7,ch)}}}if(b9&&!b6.length){if(!cf.teardown||cf.teardown.call(b7,e,ce.handle)===false){bI.removeEvent(b7,cg,ce.handle)}delete ci[cg]}}if(bI.isEmptyObject(ci)){delete ce.handle;bI._removeData(b7,"events")}},trigger:function(b6,cd,b9,ck){var ce,b8,ci,cj,cg,cc,cb,ca=[b9||n],ch=J.call(b6,"type")?b6.type:b6,b7=J.call(b6,"namespace")?b6.namespace.split("."):[];ci=cc=b9=b9||n;if(b9.nodeType===3||b9.nodeType===8){return}if(bC.test(ch+bI.event.triggered)){return}if(ch.indexOf(".")>=0){b7=ch.split(".");ch=b7.shift();b7.sort()}b8=ch.indexOf(":")<0&&"on"+ch;b6=b6[bI.expando]?b6:new bI.Event(ch,typeof b6==="object"&&b6);b6.isTrigger=ck?2:3;b6.namespace=b7.join(".");b6.namespace_re=b6.namespace?new RegExp("(^|\\.)"+b7.join("\\.(?:.*\\.|)")+"(\\.|$)"):null;b6.result=undefined;if(!b6.target){b6.target=b9}cd=cd==null?[b6]:bI.makeArray(cd,[b6]);cg=bI.event.special[ch]||{};if(!ck&&cg.trigger&&cg.trigger.apply(b9,cd)===false){return}if(!ck&&!cg.noBubble&&!bI.isWindow(b9)){cj=cg.delegateType||ch;if(!bC.test(cj+ch)){ci=ci.parentNode}for(;ci;ci=ci.parentNode){ca.push(ci);cc=ci}if(cc===(b9.ownerDocument||n)){ca.push(cc.defaultView||cc.parentWindow||a5)}}cb=0;while((ci=ca[cb++])&&!b6.isPropagationStopped()){b6.type=cb>1?cj:cg.bindType||ch;ce=(bI._data(ci,"events")||{})[b6.type]&&bI._data(ci,"handle");if(ce){ce.apply(ci,cd)}ce=b8&&ci[b8];if(ce&&ce.apply&&bI.acceptData(ci)){b6.result=ce.apply(ci,cd);if(b6.result===false){b6.preventDefault()}}}b6.type=ch;if(!ck&&!b6.isDefaultPrevented()){if((!cg._default||cg._default.apply(ca.pop(),cd)===false)&&bI.acceptData(b9)){if(b8&&b9[ch]&&!bI.isWindow(b9)){cc=b9[b8];if(cc){b9[b8]=null}bI.event.triggered=ch;try{b9[ch]()}catch(cf){}bI.event.triggered=undefined;if(cc){b9[b8]=cc}}}}return b6.result},dispatch:function(e){e=bI.event.fix(e);var b9,ca,ce,b6,b8,cd=[],cc=P.call(arguments),b7=(bI._data(this,"events")||{})[e.type]||[],cb=bI.event.special[e.type]||{};cc[0]=e;e.delegateTarget=this;if(cb.preDispatch&&cb.preDispatch.call(this,e)===false){return}cd=bI.event.handlers.call(this,e,b7);b9=0;while((b6=cd[b9++])&&!e.isPropagationStopped()){e.currentTarget=b6.elem;b8=0;while((ce=b6.handlers[b8++])&&!e.isImmediatePropagationStopped()){if(!e.namespace_re||e.namespace_re.test(ce.namespace)){e.handleObj=ce;e.data=ce.data;ca=((bI.event.special[ce.origType]||{}).handle||ce.handler).apply(b6.elem,cc);if(ca!==undefined){if((e.result=ca)===false){e.preventDefault();e.stopPropagation()}}}}}if(cb.postDispatch){cb.postDispatch.call(this,e)}return e.result},handlers:function(e,b7){var b6,cc,ca,b9,cb=[],b8=b7.delegateCount,cd=e.target;if(b8&&cd.nodeType&&(!e.button||e.type!=="click")){for(;cd!=this;cd=cd.parentNode||this){if(cd.nodeType===1&&(cd.disabled!==true||e.type!=="click")){ca=[];for(b9=0;b9<b8;b9++){cc=b7[b9];b6=cc.selector+" ";if(ca[b6]===undefined){ca[b6]=cc.needsContext?bI(b6,this).index(cd)>=0:bI.find(b6,this,null,[cd]).length}if(ca[b6]){ca.push(cc)}}if(ca.length){cb.push({elem:cd,handlers:ca})}}}}if(b8<b7.length){cb.push({elem:this,handlers:b7.slice(b8)})}return cb},fix:function(b8){if(b8[bI.expando]){return b8}var b6,cb,ca,b7=b8.type,e=b8,b9=this.fixHooks[b7];if(!b9){this.fixHooks[b7]=b9=bM.test(b7)?this.mouseHooks:a6.test(b7)?this.keyHooks:{}}ca=b9.props?this.props.concat(b9.props):this.props;b8=new bI.Event(e);b6=ca.length;while(b6--){cb=ca[b6];b8[cb]=e[cb]}if(!b8.target){b8.target=e.srcElement||n}if(b8.target.nodeType===3){b8.target=b8.target.parentNode}b8.metaKey=!!b8.metaKey;return b9.filter?b9.filter(b8,e):b8},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(i,e){if(i.which==null){i.which=e.charCode!=null?e.charCode:e.keyCode}return i}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(b7,b6){var e,b8,b9,i=b6.button,ca=b6.fromElement;if(b7.pageX==null&&b6.clientX!=null){b8=b7.target.ownerDocument||n;b9=b8.documentElement;e=b8.body;b7.pageX=b6.clientX+(b9&&b9.scrollLeft||e&&e.scrollLeft||0)-(b9&&b9.clientLeft||e&&e.clientLeft||0);b7.pageY=b6.clientY+(b9&&b9.scrollTop||e&&e.scrollTop||0)-(b9&&b9.clientTop||e&&e.clientTop||0)}if(!b7.relatedTarget&&ca){b7.relatedTarget=ca===b7.target?b6.toElement:ca}if(!b7.which&&i!==undefined){b7.which=(i&1?1:(i&2?3:(i&4?2:0)))}return b7}},special:{load:{noBubble:true},focus:{trigger:function(){if(this!==am()&&this.focus){try{this.focus();return false}catch(i){}}},delegateType:"focusin"},blur:{trigger:function(){if(this===am()&&this.blur){this.blur();return false}},delegateType:"focusout"},click:{trigger:function(){if(bI.nodeName(this,"input")&&this.type==="checkbox"&&this.click){this.click();return false}},_default:function(e){return bI.nodeName(e.target,"a")}},beforeunload:{postDispatch:function(e){if(e.result!==undefined&&e.originalEvent){e.originalEvent.returnValue=e.result}}}},simulate:function(b6,b8,b7,i){var b9=bI.extend(new bI.Event(),b7,{type:b6,isSimulated:true,originalEvent:{}});if(i){bI.event.trigger(b9,null,b8)}else{bI.event.dispatch.call(b8,b9)}if(b9.isDefaultPrevented()){b7.preventDefault()}}};bI.removeEvent=n.removeEventListener?function(i,e,b6){if(i.removeEventListener){i.removeEventListener(e,b6,false)}}:function(b6,i,b7){var e="on"+i;if(b6.detachEvent){if(typeof b6[e]===aC){b6[e]=null}b6.detachEvent(e,b7)}};bI.Event=function(i,e){if(!(this instanceof bI.Event)){return new bI.Event(i,e)}if(i&&i.type){this.originalEvent=i;this.type=i.type;this.isDefaultPrevented=i.defaultPrevented||i.defaultPrevented===undefined&&i.returnValue===false?U:Z}else{this.type=i}if(e){bI.extend(this,e)}this.timeStamp=i&&i.timeStamp||bI.now();this[bI.expando]=true};bI.Event.prototype={isDefaultPrevented:Z,isPropagationStopped:Z,isImmediatePropagationStopped:Z,preventDefault:function(){var i=this.originalEvent;this.isDefaultPrevented=U;if(!i){return}if(i.preventDefault){i.preventDefault()}else{i.returnValue=false}},stopPropagation:function(){var i=this.originalEvent;this.isPropagationStopped=U;if(!i){return}if(i.stopPropagation){i.stopPropagation()}i.cancelBubble=true},stopImmediatePropagation:function(){var i=this.originalEvent;this.isImmediatePropagationStopped=U;if(i&&i.stopImmediatePropagation){i.stopImmediatePropagation()}this.stopPropagation()}};bI.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(i,e){bI.event.special[i]={delegateType:e,bindType:e,handle:function(b8){var b6,ca=this,b9=b8.relatedTarget,b7=b8.handleObj;if(!b9||(b9!==ca&&!bI.contains(ca,b9))){b8.type=b7.origType;b6=b7.handler.apply(this,arguments);b8.type=e}return b6}}});if(!C.submitBubbles){bI.event.special.submit={setup:function(){if(bI.nodeName(this,"form")){return false}bI.event.add(this,"click._submit keypress._submit",function(b7){var b6=b7.target,i=bI.nodeName(b6,"input")||bI.nodeName(b6,"button")?b6.form:undefined;if(i&&!bI._data(i,"submitBubbles")){bI.event.add(i,"submit._submit",function(e){e._submit_bubble=true});bI._data(i,"submitBubbles",true)}})},postDispatch:function(e){if(e._submit_bubble){delete e._submit_bubble;if(this.parentNode&&!e.isTrigger){bI.event.simulate("submit",this.parentNode,e,true)}}},teardown:function(){if(bI.nodeName(this,"form")){return false}bI.event.remove(this,"._submit")}}}if(!C.changeBubbles){bI.event.special.change={setup:function(){if(bG.test(this.nodeName)){if(this.type==="checkbox"||this.type==="radio"){bI.event.add(this,"propertychange._change",function(e){if(e.originalEvent.propertyName==="checked"){this._just_changed=true}});bI.event.add(this,"click._change",function(e){if(this._just_changed&&!e.isTrigger){this._just_changed=false}bI.event.simulate("change",this,e,true)})}return false}bI.event.add(this,"beforeactivate._change",function(b6){var i=b6.target;if(bG.test(i.nodeName)&&!bI._data(i,"changeBubbles")){bI.event.add(i,"change._change",function(e){if(this.parentNode&&!e.isSimulated&&!e.isTrigger){bI.event.simulate("change",this.parentNode,e,true)}});bI._data(i,"changeBubbles",true)}})},handle:function(i){var e=i.target;if(this!==e||i.isSimulated||i.isTrigger||(e.type!=="radio"&&e.type!=="checkbox")){return i.handleObj.handler.apply(this,arguments)}},teardown:function(){bI.event.remove(this,"._change");return !bG.test(this.nodeName)}}}if(!C.focusinBubbles){bI.each({focus:"focusin",blur:"focusout"},function(b6,e){var i=function(b7){bI.event.simulate(e,b7.target,bI.event.fix(b7),true)};bI.event.special[e]={setup:function(){var b8=this.ownerDocument||this,b7=bI._data(b8,e);if(!b7){b8.addEventListener(b6,i,true)}bI._data(b8,e,(b7||0)+1)},teardown:function(){var b8=this.ownerDocument||this,b7=bI._data(b8,e)-1;if(!b7){b8.removeEventListener(b6,i,true);bI._removeData(b8,e)}else{bI._data(b8,e,b7)}}}})}bI.fn.extend({on:function(b6,e,b9,b8,i){var b7,ca;if(typeof b6==="object"){if(typeof e!=="string"){b9=b9||e;e=undefined}for(b7 in b6){this.on(b7,e,b9,b6[b7],i)}return this}if(b9==null&&b8==null){b8=e;b9=e=undefined}else{if(b8==null){if(typeof e==="string"){b8=b9;b9=undefined}else{b8=b9;b9=e;e=undefined}}}if(b8===false){b8=Z}else{if(!b8){return this}}if(i===1){ca=b8;b8=function(cb){bI().off(cb);return ca.apply(this,arguments)};b8.guid=ca.guid||(ca.guid=bI.guid++)}return this.each(function(){bI.event.add(this,b6,b8,b9,e)})},one:function(i,e,b7,b6){return this.on(i,e,b7,b6,1)},off:function(b6,e,b8){var i,b7;if(b6&&b6.preventDefault&&b6.handleObj){i=b6.handleObj;bI(b6.delegateTarget).off(i.namespace?i.origType+"."+i.namespace:i.origType,i.selector,i.handler);return this}if(typeof b6==="object"){for(b7 in b6){this.off(b7,e,b6[b7])}return this}if(e===false||typeof e==="function"){b8=e;e=undefined}if(b8===false){b8=Z}return this.each(function(){bI.event.remove(this,b6,b8,e)})},trigger:function(e,i){return this.each(function(){bI.event.trigger(e,i,this)})},triggerHandler:function(e,b6){var i=this[0];if(i){return bI.event.trigger(e,b6,i,true)}}});function A(e){var b6=d.split("|"),i=e.createDocumentFragment();if(i.createElement){while(b6.length){i.createElement(b6.pop())}}return i}var d="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",aD=/ jQuery\d+="(?:null|\d+)"/g,M=new RegExp("<(?:"+d+")[\\s/>]","i"),b5=/^\s+/,aH=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,o=/<([\w:]+)/,b0=/<tbody/i,K=/<|&#?\w+;/,an=/<(?:script|style|link)/i,bW=/checked\s*(?:[^=]|=\s*.checked.)/i,bB=/^$|\/(?:java|ecma)script/i,ar=/^true\/(.*)/,aO=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,W={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],area:[1,"<map>","</map>"],param:[1,"<object>","</object>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:C.htmlSerialize?[0,"",""]:[1,"X<div>","</div>"]},aT=A(n),k=aT.appendChild(n.createElement("div"));W.optgroup=W.option;W.tbody=W.tfoot=W.colgroup=W.caption=W.thead;W.th=W.td;function l(b8,e){var b6,b9,b7=0,ca=typeof b8.getElementsByTagName!==aC?b8.getElementsByTagName(e||"*"):typeof b8.querySelectorAll!==aC?b8.querySelectorAll(e||"*"):undefined;if(!ca){for(ca=[],b6=b8.childNodes||b8;(b9=b6[b7])!=null;b7++){if(!e||bI.nodeName(b9,e)){ca.push(b9)}else{bI.merge(ca,l(b9,e))}}}return e===undefined||e&&bI.nodeName(b8,e)?bI.merge([b8],ca):ca}function bY(e){if(aM.test(e.type)){e.defaultChecked=e.checked}}function a3(i,e){return bI.nodeName(i,"table")&&bI.nodeName(e.nodeType!==11?e:e.firstChild,"tr")?i.getElementsByTagName("tbody")[0]||i.appendChild(i.ownerDocument.createElement("tbody")):i}function t(e){e.type=(bI.find.attr(e,"type")!==null)+"/"+e.type;return e}function bf(i){var e=ar.exec(i.type);if(e){i.type=e[1]}else{i.removeAttribute("type")}return i}function bu(e,b7){var b8,b6=0;for(;(b8=e[b6])!=null;b6++){bI._data(b8,"globalEval",!b7||bI._data(b7[b6],"globalEval"))}}function at(cc,b6){if(b6.nodeType!==1||!bI.hasData(cc)){return}var b9,b8,e,cb=bI._data(cc),ca=bI._data(b6,cb),b7=cb.events;if(b7){delete ca.handle;ca.events={};for(b9 in b7){for(b8=0,e=b7[b9].length;b8<e;b8++){bI.event.add(b6,b9,b7[b9][b8])}}}if(ca.data){ca.data=bI.extend({},ca.data)}}function T(b8,i){var b9,b7,b6;if(i.nodeType!==1){return}b9=i.nodeName.toLowerCase();if(!C.noCloneEvent&&i[bI.expando]){b6=bI._data(i);for(b7 in b6.events){bI.removeEvent(i,b7,b6.handle)}i.removeAttribute(bI.expando)}if(b9==="script"&&i.text!==b8.text){t(i).text=b8.text;bf(i)}else{if(b9==="object"){if(i.parentNode){i.outerHTML=b8.outerHTML}if(C.html5Clone&&(b8.innerHTML&&!bI.trim(i.innerHTML))){i.innerHTML=b8.innerHTML}}else{if(b9==="input"&&aM.test(b8.type)){i.defaultChecked=i.checked=b8.checked;if(i.value!==b8.value){i.value=b8.value}}else{if(b9==="option"){i.defaultSelected=i.selected=b8.defaultSelected}else{if(b9==="input"||b9==="textarea"){i.defaultValue=b8.defaultValue}}}}}}bI.extend({clone:function(b6,b8,e){var ca,b7,cd,b9,cb,cc=bI.contains(b6.ownerDocument,b6);if(C.html5Clone||bI.isXMLDoc(b6)||!M.test("<"+b6.nodeName+">")){cd=b6.cloneNode(true)}else{k.innerHTML=b6.outerHTML;k.removeChild(cd=k.firstChild)}if((!C.noCloneEvent||!C.noCloneChecked)&&(b6.nodeType===1||b6.nodeType===11)&&!bI.isXMLDoc(b6)){ca=l(cd);cb=l(b6);for(b9=0;(b7=cb[b9])!=null;++b9){if(ca[b9]){T(b7,ca[b9])}}}if(b8){if(e){cb=cb||l(b6);ca=ca||l(cd);for(b9=0;(b7=cb[b9])!=null;b9++){at(b7,ca[b9])}}else{at(b6,cd)}}ca=l(cd,"script");if(ca.length>0){bu(ca,!cc&&l(b6,"script"))}ca=cb=b7=null;return cd},buildFragment:function(b6,b8,cd,ci){var ce,ca,cc,ch,cj,cg,b7,cb=b6.length,b9=A(b8),e=[],cf=0;for(;cf<cb;cf++){ca=b6[cf];if(ca||ca===0){if(bI.type(ca)==="object"){bI.merge(e,ca.nodeType?[ca]:ca)}else{if(!K.test(ca)){e.push(b8.createTextNode(ca))}else{ch=ch||b9.appendChild(b8.createElement("div"));cj=(o.exec(ca)||["",""])[1].toLowerCase();b7=W[cj]||W._default;ch.innerHTML=b7[1]+ca.replace(aH,"<$1></$2>")+b7[2];ce=b7[0];while(ce--){ch=ch.lastChild}if(!C.leadingWhitespace&&b5.test(ca)){e.push(b8.createTextNode(b5.exec(ca)[0]))}if(!C.tbody){ca=cj==="table"&&!b0.test(ca)?ch.firstChild:b7[1]==="<table>"&&!b0.test(ca)?ch:0;ce=ca&&ca.childNodes.length;while(ce--){if(bI.nodeName((cg=ca.childNodes[ce]),"tbody")&&!cg.childNodes.length){ca.removeChild(cg)}}}bI.merge(e,ch.childNodes);ch.textContent="";while(ch.firstChild){ch.removeChild(ch.firstChild)}ch=b9.lastChild}}}}if(ch){b9.removeChild(ch)}if(!C.appendChecked){bI.grep(l(e,"input"),bY)}cf=0;while((ca=e[cf++])){if(ci&&bI.inArray(ca,ci)!==-1){continue}cc=bI.contains(ca.ownerDocument,ca);ch=l(b9.appendChild(ca),"script");if(cc){bu(ch)}if(cd){ce=0;while((ca=ch[ce++])){if(bB.test(ca.type||"")){cd.push(ca)}}}}ch=null;return b9},cleanData:function(b6,ce){var b8,cd,b7,b9,ca=0,cf=bI.expando,e=bI.cache,cb=C.deleteExpando,cc=bI.event.special;for(;(b8=b6[ca])!=null;ca++){if(ce||bI.acceptData(b8)){b7=b8[cf];b9=b7&&e[b7];if(b9){if(b9.events){for(cd in b9.events){if(cc[cd]){bI.event.remove(b8,cd)}else{bI.removeEvent(b8,cd,b9.handle)}}}if(e[b7]){delete e[b7];if(cb){delete b8[cf]}else{if(typeof b8.removeAttribute!==aC){b8.removeAttribute(cf)}else{b8[cf]=null}}aP.push(b7)}}}}}});bI.fn.extend({text:function(e){return aB(this,function(i){return i===undefined?bI.text(this):this.empty().append((this[0]&&this[0].ownerDocument||n).createTextNode(i))},null,e,arguments.length)},append:function(){return this.domManip(arguments,function(e){if(this.nodeType===1||this.nodeType===11||this.nodeType===9){var i=a3(this,e);i.appendChild(e)}})},prepend:function(){return this.domManip(arguments,function(e){if(this.nodeType===1||this.nodeType===11||this.nodeType===9){var i=a3(this,e);i.insertBefore(e,i.firstChild)}})},before:function(){return this.domManip(arguments,function(e){if(this.parentNode){this.parentNode.insertBefore(e,this)}})},after:function(){return this.domManip(arguments,function(e){if(this.parentNode){this.parentNode.insertBefore(e,this.nextSibling)}})},remove:function(e,b9){var b8,b6=e?bI.filter(e,this):this,b7=0;for(;(b8=b6[b7])!=null;b7++){if(!b9&&b8.nodeType===1){bI.cleanData(l(b8))}if(b8.parentNode){if(b9&&bI.contains(b8.ownerDocument,b8)){bu(l(b8,"script"))}b8.parentNode.removeChild(b8)}}return this},empty:function(){var b6,e=0;for(;(b6=this[e])!=null;e++){if(b6.nodeType===1){bI.cleanData(l(b6,false))}while(b6.firstChild){b6.removeChild(b6.firstChild)}if(b6.options&&bI.nodeName(b6,"select")){b6.options.length=0}}return this},clone:function(i,e){i=i==null?false:i;e=e==null?i:e;return this.map(function(){return bI.clone(this,i,e)})},html:function(e){return aB(this,function(b9){var b8=this[0]||{},b7=0,b6=this.length;if(b9===undefined){return b8.nodeType===1?b8.innerHTML.replace(aD,""):undefined}if(typeof b9==="string"&&!an.test(b9)&&(C.htmlSerialize||!M.test(b9))&&(C.leadingWhitespace||!b5.test(b9))&&!W[(o.exec(b9)||["",""])[1].toLowerCase()]){b9=b9.replace(aH,"<$1></$2>");try{for(;b7<b6;b7++){b8=this[b7]||{};if(b8.nodeType===1){bI.cleanData(l(b8,false));b8.innerHTML=b9}}b8=0}catch(ca){}}if(b8){this.empty().append(b9)}},null,e,arguments.length)},replaceWith:function(){var e=arguments[0];this.domManip(arguments,function(i){e=this.parentNode;bI.cleanData(l(this));if(e){e.replaceChild(i,this)}});return e&&(e.length||e.nodeType)?this:this.remove()},detach:function(e){return this.remove(e,true)},domManip:function(cd,ci){cd=az.apply([],cd);var cb,b7,e,b9,cg,cc,ca=0,b8=this.length,cf=this,ch=b8-1,ce=cd[0],b6=bI.isFunction(ce);if(b6||(b8>1&&typeof ce==="string"&&!C.checkClone&&bW.test(ce))){return this.each(function(cj){var i=cf.eq(cj);if(b6){cd[0]=ce.call(this,cj,i.html())}i.domManip(cd,ci)})}if(b8){cc=bI.buildFragment(cd,this[0].ownerDocument,false,this);cb=cc.firstChild;if(cc.childNodes.length===1){cc=cb}if(cb){b9=bI.map(l(cc,"script"),t);e=b9.length;for(;ca<b8;ca++){b7=cc;if(ca!==ch){b7=bI.clone(b7,true,true);if(e){bI.merge(b9,l(b7,"script"))}}ci.call(this[ca],b7,ca)}if(e){cg=b9[b9.length-1].ownerDocument;bI.map(b9,bf);for(ca=0;ca<e;ca++){b7=b9[ca];if(bB.test(b7.type||"")&&!bI._data(b7,"globalEval")&&bI.contains(cg,b7)){if(b7.src){if(bI._evalUrl){bI._evalUrl(b7.src)}}else{bI.globalEval((b7.text||b7.textContent||b7.innerHTML||"").replace(aO,""))}}}}cc=cb=null}}return this}});bI.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,i){bI.fn[e]=function(b6){var b7,b9=0,b8=[],cb=bI(b6),ca=cb.length-1;for(;b9<=ca;b9++){b7=b9===ca?this:this.clone(true);bI(cb[b9])[i](b7);w.apply(b8,b7.get())}return this.pushStack(b8)}});var aI,bl={};function a4(e,b8){var i,b6=bI(b8.createElement(e)).appendTo(b8.body),b7=a5.getDefaultComputedStyle&&(i=a5.getDefaultComputedStyle(b6[0]))?i.display:bI.css(b6[0],"display");b6.detach();return b7}function a0(b6){var i=n,e=bl[b6];if(!e){e=a4(b6,i);if(e==="none"||!e){aI=(aI||bI("<iframe frameborder='0' width='0' height='0'/>")).appendTo(i.documentElement);i=(aI[0].contentWindow||aI[0].contentDocument).document;i.write();i.close();e=a4(b6,i);aI.detach()}bl[b6]=e}return e}(function(){var e;C.shrinkWrapBlocks=function(){if(e!=null){return e}e=false;var b7,i,b6;i=n.getElementsByTagName("body")[0];if(!i||!i.style){return}b7=n.createElement("div");b6=n.createElement("div");b6.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px";i.appendChild(b6).appendChild(b7);if(typeof b7.style.zoom!==aC){b7.style.cssText="-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;display:block;margin:0;border:0;padding:1px;width:1px;zoom:1";b7.appendChild(n.createElement("div")).style.width="5px";e=b7.offsetWidth!==3}i.removeChild(b6);return e}})();var aZ=(/^margin/);var Y=new RegExp("^("+aE+")(?!px)[a-z%]+$","i");var bq,F,bo=/^(top|right|bottom|left)$/;if(a5.getComputedStyle){bq=function(e){return e.ownerDocument.defaultView.getComputedStyle(e,null)};F=function(cb,i,ca){var b8,b7,b9,e,b6=cb.style;ca=ca||bq(cb);e=ca?ca.getPropertyValue(i)||ca[i]:undefined;if(ca){if(e===""&&!bI.contains(cb.ownerDocument,cb)){e=bI.style(cb,i)}if(Y.test(e)&&aZ.test(i)){b8=b6.width;b7=b6.minWidth;b9=b6.maxWidth;b6.minWidth=b6.maxWidth=b6.width=e;e=ca.width;b6.width=b8;b6.minWidth=b7;b6.maxWidth=b9}}return e===undefined?e:e+""}}else{if(n.documentElement.currentStyle){bq=function(e){return e.currentStyle};F=function(ca,b7,b9){var cb,i,e,b6,b8=ca.style;b9=b9||bq(ca);b6=b9?b9[b7]:undefined;if(b6==null&&b8&&b8[b7]){b6=b8[b7]}if(Y.test(b6)&&!bo.test(b7)){cb=b8.left;i=ca.runtimeStyle;e=i&&i.left;if(e){i.left=ca.currentStyle.left}b8.left=b7==="fontSize"?"1em":b6;b6=b8.pixelLeft+"px";b8.left=cb;if(e){i.left=e}}return b6===undefined?b6:b6+""||"auto"}}}function a7(e,i){return{get:function(){var b6=e();if(b6==null){return}if(b6){delete this.get;return}return(this.get=i).apply(this,arguments)}}}(function(){var cb,b9,b7,ca,b6,b8,i;cb=n.createElement("div");cb.innerHTML="  <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";b7=cb.getElementsByTagName("a")[0];b9=b7&&b7.style;if(!b9){return}b9.cssText="float:left;opacity:.5";C.opacity=b9.opacity==="0.5";C.cssFloat=!!b9.cssFloat;cb.style.backgroundClip="content-box";cb.cloneNode(true).style.backgroundClip="";C.clearCloneStyle=cb.style.backgroundClip==="content-box";C.boxSizing=b9.boxSizing===""||b9.MozBoxSizing===""||b9.WebkitBoxSizing==="";bI.extend(C,{reliableHiddenOffsets:function(){if(b8==null){e()}return b8},boxSizingReliable:function(){if(b6==null){e()}return b6},pixelPosition:function(){if(ca==null){e()}return ca},reliableMarginRight:function(){if(i==null){e()}return i}});function e(){var cf,cc,cd,ce;cc=n.getElementsByTagName("body")[0];if(!cc||!cc.style){return}cf=n.createElement("div");cd=n.createElement("div");cd.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px";cc.appendChild(cd).appendChild(cf);cf.style.cssText="-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;display:block;margin-top:1%;top:1%;border:1px;padding:1px;width:4px;position:absolute";ca=b6=false;i=true;if(a5.getComputedStyle){ca=(a5.getComputedStyle(cf,null)||{}).top!=="1%";b6=(a5.getComputedStyle(cf,null)||{width:"4px"}).width==="4px";ce=cf.appendChild(n.createElement("div"));ce.style.cssText=cf.style.cssText="-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;display:block;margin:0;border:0;padding:0";ce.style.marginRight=ce.style.width="0";cf.style.width="1px";i=!parseFloat((a5.getComputedStyle(ce,null)||{}).marginRight)}cf.innerHTML="<table><tr><td></td><td>t</td></tr></table>";ce=cf.getElementsByTagName("td");ce[0].style.cssText="margin:0;border:0;padding:0;display:none";b8=ce[0].offsetHeight===0;if(b8){ce[0].style.display="";ce[1].style.display="none";b8=ce[0].offsetHeight===0}cc.removeChild(cd)}})();bI.swap=function(b9,b8,ca,b7){var b6,i,e={};for(i in b8){e[i]=b9.style[i];b9.style[i]=b8[i]}b6=ca.apply(b9,b7||[]);for(i in b8){b9.style[i]=e[i]}return b6};var bj=/alpha\([^)]*\)/i,aU=/opacity\s*=\s*([^)]*)/,G=/^(none|table(?!-c[ea]).+)/,bb=new RegExp("^("+aE+")(.*)$","i"),V=new RegExp("^([+-])=("+aE+")","i"),be={position:"absolute",visibility:"hidden",display:"block"},bD={letterSpacing:"0",fontWeight:"400"},aw=["Webkit","O","Moz","ms"];function c(b8,b6){if(b6 in b8){return b6}var b9=b6.charAt(0).toUpperCase()+b6.slice(1),e=b6,b7=aw.length;while(b7--){b6=aw[b7]+b9;if(b6 in b8){return b6}}return e}function r(ca,e){var cb,b8,b9,i=[],b6=0,b7=ca.length;for(;b6<b7;b6++){b8=ca[b6];if(!b8.style){continue}i[b6]=bI._data(b8,"olddisplay");cb=b8.style.display;if(e){if(!i[b6]&&cb==="none"){b8.style.display=""}if(b8.style.display===""&&S(b8)){i[b6]=bI._data(b8,"olddisplay",a0(b8.nodeName))}}else{b9=S(b8);if(cb&&cb!=="none"||!b9){bI._data(b8,"olddisplay",b9?cb:bI.css(b8,"display"))}}}for(b6=0;b6<b7;b6++){b8=ca[b6];if(!b8.style){continue}if(!e||b8.style.display==="none"||b8.style.display===""){b8.style.display=e?i[b6]||"":"none"}}return ca}function aN(e,b6,b7){var i=bb.exec(b6);return i?Math.max(0,i[1]-(b7||0))+(i[2]||"px"):b6}function ax(b9,b6,e,cb,b8){var b7=e===(cb?"border":"content")?4:b6==="width"?1:0,ca=0;for(;b7<4;b7+=2){if(e==="margin"){ca+=bI.css(b9,e+bT[b7],true,b8)}if(cb){if(e==="content"){ca-=bI.css(b9,"padding"+bT[b7],true,b8)}if(e!=="margin"){ca-=bI.css(b9,"border"+bT[b7]+"Width",true,b8)}}else{ca+=bI.css(b9,"padding"+bT[b7],true,b8);if(e!=="padding"){ca+=bI.css(b9,"border"+bT[b7]+"Width",true,b8)}}}return ca}function u(b8,i,e){var b7=true,b9=i==="width"?b8.offsetWidth:b8.offsetHeight,b6=bq(b8),ca=C.boxSizing&&bI.css(b8,"boxSizing",false,b6)==="border-box";if(b9<=0||b9==null){b9=F(b8,i,b6);if(b9<0||b9==null){b9=b8.style[i]}if(Y.test(b9)){return b9}b7=ca&&(C.boxSizingReliable()||b9===b8.style[i]);b9=parseFloat(b9)||0}return(b9+ax(b8,i,e||(ca?"border":"content"),b7,b6))+"px"}bI.extend({cssHooks:{opacity:{get:function(b6,i){if(i){var e=F(b6,"opacity");return e===""?"1":e}}}},cssNumber:{columnCount:true,fillOpacity:true,flexGrow:true,flexShrink:true,fontWeight:true,lineHeight:true,opacity:true,order:true,orphans:true,widows:true,zIndex:true,zoom:true},cssProps:{"float":C.cssFloat?"cssFloat":"styleFloat"},style:function(b7,b6,cd,b8){if(!b7||b7.nodeType===3||b7.nodeType===8||!b7.style){return}var cb,cc,ce,b9=bI.camelCase(b6),i=b7.style;b6=bI.cssProps[b9]||(bI.cssProps[b9]=c(i,b9));ce=bI.cssHooks[b6]||bI.cssHooks[b9];if(cd!==undefined){cc=typeof cd;if(cc==="string"&&(cb=V.exec(cd))){cd=(cb[1]+1)*cb[2]+parseFloat(bI.css(b7,b6));cc="number"}if(cd==null||cd!==cd){return}if(cc==="number"&&!bI.cssNumber[b9]){cd+="px"}if(!C.clearCloneStyle&&cd===""&&b6.indexOf("background")===0){i[b6]="inherit"}if(!ce||!("set" in ce)||(cd=ce.set(b7,cd,b8))!==undefined){try{i[b6]=cd}catch(ca){}}}else{if(ce&&"get" in ce&&(cb=ce.get(b7,false,b8))!==undefined){return cb}return i[b6]}},css:function(ca,b8,i,b9){var b7,cb,e,b6=bI.camelCase(b8);b8=bI.cssProps[b6]||(bI.cssProps[b6]=c(ca.style,b6));e=bI.cssHooks[b8]||bI.cssHooks[b6];if(e&&"get" in e){cb=e.get(ca,true,i)}if(cb===undefined){cb=F(ca,b8,b9)}if(cb==="normal"&&b8 in bD){cb=bD[b8]}if(i===""||i){b7=parseFloat(cb);return i===true||bI.isNumeric(b7)?b7||0:cb}return cb}});bI.each(["height","width"],function(b6,e){bI.cssHooks[e]={get:function(b8,b7,i){if(b7){return G.test(bI.css(b8,"display"))&&b8.offsetWidth===0?bI.swap(b8,be,function(){return u(b8,e,i)}):u(b8,e,i)}},set:function(b8,b9,i){var b7=i&&bq(b8);return aN(b8,b9,i?ax(b8,e,i,C.boxSizing&&bI.css(b8,"boxSizing",false,b7)==="border-box",b7):0)}}});if(!C.opacity){bI.cssHooks.opacity={get:function(i,e){return aU.test((e&&i.currentStyle?i.currentStyle.filter:i.style.filter)||"")?(0.01*parseFloat(RegExp.$1))+"":e?"1":""},set:function(b8,b9){var b7=b8.style,i=b8.currentStyle,e=bI.isNumeric(b9)?"alpha(opacity="+b9*100+")":"",b6=i&&i.filter||b7.filter||"";b7.zoom=1;if((b9>=1||b9==="")&&bI.trim(b6.replace(bj,""))===""&&b7.removeAttribute){b7.removeAttribute("filter");if(b9===""||i&&!i.filter){return}}b7.filter=bj.test(b6)?b6.replace(bj,e):b6+" "+e}}}bI.cssHooks.marginRight=a7(C.reliableMarginRight,function(i,e){if(e){return bI.swap(i,{display:"inline-block"},F,[i,"marginRight"])}});bI.each({margin:"",padding:"",border:"Width"},function(e,i){bI.cssHooks[e+i]={expand:function(b8){var b7=0,b6={},b9=typeof b8==="string"?b8.split(" "):[b8];for(;b7<4;b7++){b6[e+bT[b7]+i]=b9[b7]||b9[b7-2]||b9[0]}return b6}};if(!aZ.test(e)){bI.cssHooks[e+i].set=aN}});bI.fn.extend({css:function(e,i){return aB(this,function(ca,b7,cb){var b9,b6,cc={},b8=0;if(bI.isArray(b7)){b9=bq(ca);b6=b7.length;for(;b8<b6;b8++){cc[b7[b8]]=bI.css(ca,b7[b8],false,b9)}return cc}return cb!==undefined?bI.style(ca,b7,cb):bI.css(ca,b7)},e,i,arguments.length>1)},show:function(){return r(this,true)},hide:function(){return r(this)},toggle:function(e){if(typeof e==="boolean"){return e?this.show():this.hide()}return this.each(function(){if(S(this)){bI(this).show()}else{bI(this).hide()}})}});function I(b6,i,b8,e,b7){return new I.prototype.init(b6,i,b8,e,b7)}bI.Tween=I;I.prototype={constructor:I,init:function(b7,i,b9,e,b8,b6){this.elem=b7;this.prop=b9;this.easing=b8||"swing";this.options=i;this.start=this.now=this.cur();this.end=e;this.unit=b6||(bI.cssNumber[b9]?"":"px")},cur:function(){var e=I.propHooks[this.prop];return e&&e.get?e.get(this):I.propHooks._default.get(this)},run:function(b6){var i,e=I.propHooks[this.prop];if(this.options.duration){this.pos=i=bI.easing[this.easing](b6,this.options.duration*b6,0,1,this.options.duration)}else{this.pos=i=b6}this.now=(this.end-this.start)*i+this.start;if(this.options.step){this.options.step.call(this.elem,this.now,this)}if(e&&e.set){e.set(this)}else{I.propHooks._default.set(this)}return this}};I.prototype.init.prototype=I.prototype;I.propHooks={_default:{get:function(i){var e;if(i.elem[i.prop]!=null&&(!i.elem.style||i.elem.style[i.prop]==null)){return i.elem[i.prop]}e=bI.css(i.elem,i.prop,"");return !e||e==="auto"?0:e},set:function(e){if(bI.fx.step[e.prop]){bI.fx.step[e.prop](e)}else{if(e.elem.style&&(e.elem.style[bI.cssProps[e.prop]]!=null||bI.cssHooks[e.prop])){bI.style(e.elem,e.prop,e.now+e.unit)}else{e.elem[e.prop]=e.now}}}}};I.propHooks.scrollTop=I.propHooks.scrollLeft={set:function(e){if(e.elem.nodeType&&e.elem.parentNode){e.elem[e.prop]=e.now}}};bI.easing={linear:function(e){return e},swing:function(e){return 0.5-Math.cos(e*Math.PI)/2}};bI.fx=I.prototype.init;bI.fx.step={};var N,ae,bR=/^(?:toggle|show|hide)$/,bJ=new RegExp("^(?:([+-])=|)("+aE+")([a-z%]*)$","i"),bP=/queueHooks$/,aG=[h],a2={"*":[function(e,ca){var cc=this.createTween(e,ca),b8=cc.cur(),b7=bJ.exec(ca),cb=b7&&b7[3]||(bI.cssNumber[e]?"":"px"),i=(bI.cssNumber[e]||cb!=="px"&&+b8)&&bJ.exec(bI.css(cc.elem,e)),b6=1,b9=20;if(i&&i[3]!==cb){cb=cb||i[3];b7=b7||[];i=+b8||1;do{b6=b6||".5";i=i/b6;bI.style(cc.elem,e,i+cb)}while(b6!==(b6=cc.cur()/b8)&&b6!==1&&--b9)}if(b7){i=cc.start=+i||+b8||0;cc.unit=cb;cc.end=b7[1]?i+(b7[1]+1)*b7[2]:+b7[2]}return cc}]};function bn(){setTimeout(function(){N=undefined});return(N=bI.now())}function bH(b7,b9){var b8,e={height:b7},b6=0;b9=b9?1:0;for(;b6<4;b6+=2-b9){b8=bT[b6];e["margin"+b8]=e["padding"+b8]=b7}if(b9){e.opacity=e.width=b7}return e}function bd(b8,ca,b7){var i,b9=(a2[ca]||[]).concat(a2["*"]),e=0,b6=b9.length;for(;e<b6;e++){if((i=b9[e].call(b7,ca,b8))){return i}}}function h(b7,cc,e){var b6,cf,b9,ci,cj,cg,cb,ce,b8=this,cd={},i=b7.style,ca=b7.nodeType&&S(b7),ch=bI._data(b7,"fxshow");if(!e.queue){cj=bI._queueHooks(b7,"fx");if(cj.unqueued==null){cj.unqueued=0;cg=cj.empty.fire;cj.empty.fire=function(){if(!cj.unqueued){cg()}}}cj.unqueued++;b8.always(function(){b8.always(function(){cj.unqueued--;if(!bI.queue(b7,"fx").length){cj.empty.fire()}})})}if(b7.nodeType===1&&("height" in cc||"width" in cc)){e.overflow=[i.overflow,i.overflowX,i.overflowY];cb=bI.css(b7,"display");ce=cb==="none"?bI._data(b7,"olddisplay")||a0(b7.nodeName):cb;if(ce==="inline"&&bI.css(b7,"float")==="none"){if(!C.inlineBlockNeedsLayout||a0(b7.nodeName)==="inline"){i.display="inline-block"}else{i.zoom=1}}}if(e.overflow){i.overflow="hidden";if(!C.shrinkWrapBlocks()){b8.always(function(){i.overflow=e.overflow[0];i.overflowX=e.overflow[1];i.overflowY=e.overflow[2]})}}for(b6 in cc){cf=cc[b6];if(bR.exec(cf)){delete cc[b6];b9=b9||cf==="toggle";if(cf===(ca?"hide":"show")){if(cf==="show"&&ch&&ch[b6]!==undefined){ca=true}else{continue}}cd[b6]=ch&&ch[b6]||bI.style(b7,b6)}else{cb=undefined}}if(!bI.isEmptyObject(cd)){if(ch){if("hidden" in ch){ca=ch.hidden}}else{ch=bI._data(b7,"fxshow",{})}if(b9){ch.hidden=!ca}if(ca){bI(b7).show()}else{b8.done(function(){bI(b7).hide()})}b8.done(function(){var ck;bI._removeData(b7,"fxshow");for(ck in cd){bI.style(b7,ck,cd[ck])}});for(b6 in cd){ci=bd(ca?ch[b6]:0,b6,b8);if(!(b6 in ch)){ch[b6]=ci.start;if(ca){ci.end=ci.start;ci.start=b6==="width"||b6==="height"?1:0}}}}else{if((cb==="none"?a0(b7.nodeName):cb)==="inline"){i.display=cb}}}function ao(b7,b9){var b6,i,ca,b8,e;for(b6 in b7){i=bI.camelCase(b6);ca=b9[i];b8=b7[b6];if(bI.isArray(b8)){ca=b8[1];b8=b7[b6]=b8[0]}if(b6!==i){b7[i]=b8;delete b7[b6]}e=bI.cssHooks[i];if(e&&"expand" in e){b8=e.expand(b8);delete b7[i];for(b6 in b8){if(!(b6 in b7)){b7[b6]=b8[b6];b9[b6]=ca}}}else{b9[i]=ca}}}function f(b6,ca,cd){var ce,e,b9=0,i=aG.length,cc=bI.Deferred().always(function(){delete b8.elem}),b8=function(){if(e){return false}var ck=N||bn(),ch=Math.max(0,b7.startTime+b7.duration-ck),cf=ch/b7.duration||0,cj=1-cf,cg=0,ci=b7.tweens.length;for(;cg<ci;cg++){b7.tweens[cg].run(cj)}cc.notifyWith(b6,[b7,cj,ch]);if(cj<1&&ci){return ch}else{cc.resolveWith(b6,[b7]);return false}},b7=cc.promise({elem:b6,props:bI.extend({},ca),opts:bI.extend(true,{specialEasing:{}},cd),originalProperties:ca,originalOptions:cd,startTime:N||bn(),duration:cd.duration,tweens:[],createTween:function(ch,cf){var cg=bI.Tween(b6,b7.opts,ch,cf,b7.opts.specialEasing[ch]||b7.opts.easing);b7.tweens.push(cg);return cg},stop:function(cg){var cf=0,ch=cg?b7.tweens.length:0;if(e){return this}e=true;for(;cf<ch;cf++){b7.tweens[cf].run(1)}if(cg){cc.resolveWith(b6,[b7,cg])}else{cc.rejectWith(b6,[b7,cg])}return this}}),cb=b7.props;ao(cb,b7.opts.specialEasing);for(;b9<i;b9++){ce=aG[b9].call(b7,b6,cb,b7.opts);if(ce){return ce}}bI.map(cb,bd,b7);if(bI.isFunction(b7.opts.start)){b7.opts.start.call(b6,b7)}bI.fx.timer(bI.extend(b8,{elem:b6,anim:b7,queue:b7.opts.queue}));return b7.progress(b7.opts.progress).done(b7.opts.done,b7.opts.complete).fail(b7.opts.fail).always(b7.opts.always)}bI.Animation=bI.extend(f,{tweener:function(i,b8){if(bI.isFunction(i)){b8=i;i=["*"]}else{i=i.split(" ")}var b7,e=0,b6=i.length;for(;e<b6;e++){b7=i[e];a2[b7]=a2[b7]||[];a2[b7].unshift(b8)}},prefilter:function(i,e){if(e){aG.unshift(i)}else{aG.push(i)}}});bI.speed=function(b6,b7,i){var e=b6&&typeof b6==="object"?bI.extend({},b6):{complete:i||!i&&b7||bI.isFunction(b6)&&b6,duration:b6,easing:i&&b7||b7&&!bI.isFunction(b7)&&b7};e.duration=bI.fx.off?0:typeof e.duration==="number"?e.duration:e.duration in bI.fx.speeds?bI.fx.speeds[e.duration]:bI.fx.speeds._default;if(e.queue==null||e.queue===true){e.queue="fx"}e.old=e.complete;e.complete=function(){if(bI.isFunction(e.old)){e.old.call(this)}if(e.queue){bI.dequeue(this,e.queue)}};return e};bI.fn.extend({fadeTo:function(e,b7,b6,i){return this.filter(S).css("opacity",0).show().end().animate({opacity:b7},e,b6,i)},animate:function(ca,b7,b9,b8){var b6=bI.isEmptyObject(ca),e=bI.speed(b7,b9,b8),i=function(){var cb=f(this,bI.extend({},ca),e);if(b6||bI._data(this,"finish")){cb.stop(true)}};i.finish=i;return b6||e.queue===false?this.each(i):this.queue(e.queue,i)},stop:function(b6,i,e){var b7=function(b8){var b9=b8.stop;delete b8.stop;b9(e)};if(typeof b6!=="string"){e=i;i=b6;b6=undefined}if(i&&b6!==false){this.queue(b6||"fx",[])}return this.each(function(){var cb=true,b8=b6!=null&&b6+"queueHooks",ca=bI.timers,b9=bI._data(this);if(b8){if(b9[b8]&&b9[b8].stop){b7(b9[b8])}}else{for(b8 in b9){if(b9[b8]&&b9[b8].stop&&bP.test(b8)){b7(b9[b8])}}}for(b8=ca.length;b8--;){if(ca[b8].elem===this&&(b6==null||ca[b8].queue===b6)){ca[b8].anim.stop(e);cb=false;ca.splice(b8,1)}}if(cb||!e){bI.dequeue(this,b6)}})},finish:function(e){if(e!==false){e=e||"fx"}return this.each(function(){var b7,ca=bI._data(this),b6=ca[e+"queue"],i=ca[e+"queueHooks"],b9=bI.timers,b8=b6?b6.length:0;ca.finish=true;bI.queue(this,e,[]);if(i&&i.stop){i.stop.call(this,true)}for(b7=b9.length;b7--;){if(b9[b7].elem===this&&b9[b7].queue===e){b9[b7].anim.stop(true);b9.splice(b7,1)}}for(b7=0;b7<b8;b7++){if(b6[b7]&&b6[b7].finish){b6[b7].finish.call(this)}}delete ca.finish})}});bI.each(["toggle","show","hide"],function(b6,e){var b7=bI.fn[e];bI.fn[e]=function(i,b9,b8){return i==null||typeof i==="boolean"?b7.apply(this,arguments):this.animate(bH(e,true),i,b9,b8)}});bI.each({slideDown:bH("show"),slideUp:bH("hide"),slideToggle:bH("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,i){bI.fn[e]=function(b6,b8,b7){return this.animate(i,b6,b8,b7)}});bI.timers=[];bI.fx.tick=function(){var b7,b6=bI.timers,e=0;N=bI.now();for(;e<b6.length;e++){b7=b6[e];if(!b7()&&b6[e]===b7){b6.splice(e--,1)}}if(!b6.length){bI.fx.stop()}N=undefined};bI.fx.timer=function(e){bI.timers.push(e);if(e()){bI.fx.start()}else{bI.timers.pop()}};bI.fx.interval=13;bI.fx.start=function(){if(!ae){ae=setInterval(bI.fx.tick,bI.fx.interval)}};bI.fx.stop=function(){clearInterval(ae);ae=null};bI.fx.speeds={slow:600,fast:200,_default:400};bI.fn.delay=function(i,e){i=bI.fx?bI.fx.speeds[i]||i:i;e=e||"fx";return this.queue(e,function(b7,b6){var b8=setTimeout(b7,i);b6.stop=function(){clearTimeout(b8)}})};(function(){var b6,b8,e,i,b7;b8=n.createElement("div");b8.setAttribute("className","t");b8.innerHTML="  <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";i=b8.getElementsByTagName("a")[0];e=n.createElement("select");b7=e.appendChild(n.createElement("option"));b6=b8.getElementsByTagName("input")[0];i.style.cssText="top:1px";C.getSetAttribute=b8.className!=="t";C.style=/top/.test(i.getAttribute("style"));C.hrefNormalized=i.getAttribute("href")==="/a";C.checkOn=!!b6.value;C.optSelected=b7.selected;C.enctype=!!n.createElement("form").enctype;e.disabled=true;C.optDisabled=!b7.disabled;b6=n.createElement("input");b6.setAttribute("value","");C.input=b6.getAttribute("value")==="";b6.value="t";b6.setAttribute("type","radio");C.radioValue=b6.value==="t"})();var al=/\r/g;bI.fn.extend({val:function(b7){var e,i,b8,b6=this[0];if(!arguments.length){if(b6){e=bI.valHooks[b6.type]||bI.valHooks[b6.nodeName.toLowerCase()];if(e&&"get" in e&&(i=e.get(b6,"value"))!==undefined){return i}i=b6.value;return typeof i==="string"?i.replace(al,""):i==null?"":i}return}b8=bI.isFunction(b7);return this.each(function(b9){var ca;if(this.nodeType!==1){return}if(b8){ca=b7.call(this,b9,bI(this).val())}else{ca=b7}if(ca==null){ca=""}else{if(typeof ca==="number"){ca+=""}else{if(bI.isArray(ca)){ca=bI.map(ca,function(cb){return cb==null?"":cb+""})}}}e=bI.valHooks[this.type]||bI.valHooks[this.nodeName.toLowerCase()];if(!e||!("set" in e)||e.set(this,ca,"value")===undefined){this.value=ca}})}});bI.extend({valHooks:{option:{get:function(e){var i=bI.find.attr(e,"value");return i!=null?i:bI.trim(bI.text(e))}},select:{get:function(e){var cb,b7,cd=e.options,b9=e.selectedIndex,b8=e.type==="select-one"||b9<0,cc=b8?null:[],ca=b8?b9+1:cd.length,b6=b9<0?ca:b8?b9:0;for(;b6<ca;b6++){b7=cd[b6];if((b7.selected||b6===b9)&&(C.optDisabled?!b7.disabled:b7.getAttribute("disabled")===null)&&(!b7.parentNode.disabled||!bI.nodeName(b7.parentNode,"optgroup"))){cb=bI(b7).val();if(b8){return cb}cc.push(cb)}}return cc},set:function(ca,cb){var cc,b9,b7=ca.options,e=bI.makeArray(cb),b8=b7.length;while(b8--){b9=b7[b8];if(bI.inArray(bI.valHooks.option.get(b9),e)>=0){try{b9.selected=cc=true}catch(b6){b9.scrollHeight}}else{b9.selected=false}}if(!cc){ca.selectedIndex=-1}return b7}}}});bI.each(["radio","checkbox"],function(){bI.valHooks[this]={set:function(e,i){if(bI.isArray(i)){return(e.checked=bI.inArray(bI(e).val(),i)>=0)}}};if(!C.checkOn){bI.valHooks[this].get=function(e){return e.getAttribute("value")===null?"on":e.value}}});var ba,b3,bO=bI.expr.attrHandle,aq=/^(?:checked|selected)$/i,bN=C.getSetAttribute,bF=C.input;bI.fn.extend({attr:function(e,i){return aB(this,bI.attr,e,i,arguments.length>1)},removeAttr:function(e){return this.each(function(){bI.removeAttr(this,e)})}});bI.extend({attr:function(b8,b7,b9){var e,b6,i=b8.nodeType;if(!b8||i===3||i===8||i===2){return}if(typeof b8.getAttribute===aC){return bI.prop(b8,b7,b9)}if(i!==1||!bI.isXMLDoc(b8)){b7=b7.toLowerCase();e=bI.attrHooks[b7]||(bI.expr.match.bool.test(b7)?b3:ba)}if(b9!==undefined){if(b9===null){bI.removeAttr(b8,b7)}else{if(e&&"set" in e&&(b6=e.set(b8,b9,b7))!==undefined){return b6}else{b8.setAttribute(b7,b9+"");return b9}}}else{if(e&&"get" in e&&(b6=e.get(b8,b7))!==null){return b6}else{b6=bI.find.attr(b8,b7);return b6==null?undefined:b6}}},removeAttr:function(b7,b9){var e,b8,b6=0,ca=b9&&b9.match(aF);if(ca&&b7.nodeType===1){while((e=ca[b6++])){b8=bI.propFix[e]||e;if(bI.expr.match.bool.test(e)){if(bF&&bN||!aq.test(e)){b7[b8]=false}else{b7[bI.camelCase("default-"+e)]=b7[b8]=false}}else{bI.attr(b7,e,"")}b7.removeAttribute(bN?e:b8)}}},attrHooks:{type:{set:function(e,i){if(!C.radioValue&&i==="radio"&&bI.nodeName(e,"input")){var b6=e.value;e.setAttribute("type",i);if(b6){e.value=b6}return i}}}}});b3={set:function(i,b6,e){if(b6===false){bI.removeAttr(i,e)}else{if(bF&&bN||!aq.test(e)){i.setAttribute(!bN&&bI.propFix[e]||e,e)}else{i[bI.camelCase("default-"+e)]=i[e]=true}}return e}};bI.each(bI.expr.match.bool.source.match(/\w+/g),function(b7,b6){var e=bO[b6]||bI.find.attr;bO[b6]=bF&&bN||!aq.test(b6)?function(b9,b8,cb){var i,ca;if(!cb){ca=bO[b8];bO[b8]=i;i=e(b9,b8,cb)!=null?b8.toLowerCase():null;bO[b8]=ca}return i}:function(b8,i,b9){if(!b9){return b8[bI.camelCase("default-"+i)]?i.toLowerCase():null}}});if(!bF||!bN){bI.attrHooks.value={set:function(i,b6,e){if(bI.nodeName(i,"input")){i.defaultValue=b6}else{return ba&&ba.set(i,b6,e)}}}}if(!bN){ba={set:function(b6,b7,i){var e=b6.getAttributeNode(i);if(!e){b6.setAttributeNode((e=b6.ownerDocument.createAttribute(i)))}e.value=b7+="";if(i==="value"||b7===b6.getAttribute(i)){return b7}}};bO.id=bO.name=bO.coords=function(b6,i,b7){var e;if(!b7){return(e=b6.getAttributeNode(i))&&e.value!==""?e.value:null}};bI.valHooks.button={get:function(b6,i){var e=b6.getAttributeNode(i);if(e&&e.specified){return e.value}},set:ba.set};bI.attrHooks.contenteditable={set:function(i,b6,e){ba.set(i,b6===""?false:b6,e)}};bI.each(["width","height"],function(b6,e){bI.attrHooks[e]={set:function(i,b7){if(b7===""){i.setAttribute(e,"auto");return b7}}}})}if(!C.style){bI.attrHooks.style={get:function(e){return e.style.cssText||undefined},set:function(e,i){return(e.style.cssText=i+"")}}}var aJ=/^(?:input|select|textarea|button|object)$/i,E=/^(?:a|area)$/i;bI.fn.extend({prop:function(e,i){return aB(this,bI.prop,e,i,arguments.length>1)},removeProp:function(e){e=bI.propFix[e]||e;return this.each(function(){try{this[e]=undefined;delete this[e]}catch(i){}})}});bI.extend({propFix:{"for":"htmlFor","class":"className"},prop:function(b9,b7,ca){var b6,e,b8,i=b9.nodeType;if(!b9||i===3||i===8||i===2){return}b8=i!==1||!bI.isXMLDoc(b9);if(b8){b7=bI.propFix[b7]||b7;e=bI.propHooks[b7]}if(ca!==undefined){return e&&"set" in e&&(b6=e.set(b9,ca,b7))!==undefined?b6:(b9[b7]=ca)}else{return e&&"get" in e&&(b6=e.get(b9,b7))!==null?b6:b9[b7]}},propHooks:{tabIndex:{get:function(i){var e=bI.find.attr(i,"tabindex");return e?parseInt(e,10):aJ.test(i.nodeName)||E.test(i.nodeName)&&i.href?0:-1}}}});if(!C.hrefNormalized){bI.each(["href","src"],function(b6,e){bI.propHooks[e]={get:function(i){return i.getAttribute(e,4)}}})}if(!C.optSelected){bI.propHooks.selected={get:function(i){var e=i.parentNode;if(e){e.selectedIndex;if(e.parentNode){e.parentNode.selectedIndex}}return null}}}bI.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){bI.propFix[this.toLowerCase()]=this});if(!C.enctype){bI.propFix.enctype="encoding"}var bL=/[\t\r\n\f]/g;bI.fn.extend({addClass:function(cd){var b7,b6,ce,cb,b8,e,b9=0,ca=this.length,cc=typeof cd==="string"&&cd;if(bI.isFunction(cd)){return this.each(function(i){bI(this).addClass(cd.call(this,i,this.className))})}if(cc){b7=(cd||"").match(aF)||[];for(;b9<ca;b9++){b6=this[b9];ce=b6.nodeType===1&&(b6.className?(" "+b6.className+" ").replace(bL," "):" ");if(ce){b8=0;while((cb=b7[b8++])){if(ce.indexOf(" "+cb+" ")<0){ce+=cb+" "}}e=bI.trim(ce);if(b6.className!==e){b6.className=e}}}}return this},removeClass:function(cd){var b7,b6,ce,cb,b8,e,b9=0,ca=this.length,cc=arguments.length===0||typeof cd==="string"&&cd;if(bI.isFunction(cd)){return this.each(function(i){bI(this).removeClass(cd.call(this,i,this.className))})}if(cc){b7=(cd||"").match(aF)||[];for(;b9<ca;b9++){b6=this[b9];ce=b6.nodeType===1&&(b6.className?(" "+b6.className+" ").replace(bL," "):"");if(ce){b8=0;while((cb=b7[b8++])){while(ce.indexOf(" "+cb+" ")>=0){ce=ce.replace(" "+cb+" "," ")}}e=cd?bI.trim(ce):"";if(b6.className!==e){b6.className=e}}}}return this},toggleClass:function(b6,e){var i=typeof b6;if(typeof e==="boolean"&&i==="string"){return e?this.addClass(b6):this.removeClass(b6)}if(bI.isFunction(b6)){return this.each(function(b7){bI(this).toggleClass(b6.call(this,b7,this.className,e),e)})}return this.each(function(){if(i==="string"){var b9,b8=0,b7=bI(this),ca=b6.match(aF)||[];while((b9=ca[b8++])){if(b7.hasClass(b9)){b7.removeClass(b9)}else{b7.addClass(b9)}}}else{if(i===aC||i==="boolean"){if(this.className){bI._data(this,"__className__",this.className)}this.className=this.className||b6===false?"":bI._data(this,"__className__")||""}}})},hasClass:function(e){var b8=" "+e+" ",b7=0,b6=this.length;for(;b7<b6;b7++){if(this[b7].nodeType===1&&(" "+this[b7].className+" ").replace(bL," ").indexOf(b8)>=0){return true}}return false}});bI.each(("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu").split(" "),function(b6,e){bI.fn[e]=function(b7,i){return arguments.length>0?this.on(e,null,b7,i):this.trigger(e)}});bI.fn.extend({hover:function(e,i){return this.mouseenter(e).mouseleave(i||e)},bind:function(e,b6,i){return this.on(e,null,b6,i)},unbind:function(e,i){return this.off(e,null,i)},delegate:function(e,i,b7,b6){return this.on(i,e,b7,b6)},undelegate:function(e,i,b6){return arguments.length===1?this.off(e,"**"):this.off(i,e||"**",b6)}});var bp=bI.now();var bQ=(/\?/);var a1=/(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g;bI.parseJSON=function(e){if(a5.JSON&&a5.JSON.parse){return a5.JSON.parse(e+"")}var b7,b6=null,i=bI.trim(e+"");return i&&!bI.trim(i.replace(a1,function(ca,b8,b9,cb){if(b7&&b8){b6=0}if(b6===0){return ca}b7=b9||b8;b6+=!cb-!b9;return""}))?(Function("return "+i))():bI.error("Invalid JSON: "+e)};bI.parseXML=function(b7){var i,b6;if(!b7||typeof b7!=="string"){return null}try{if(a5.DOMParser){b6=new DOMParser();i=b6.parseFromString(b7,"text/xml")}else{i=new ActiveXObject("Microsoft.XMLDOM");i.async="false";i.loadXML(b7)}}catch(b8){i=undefined}if(!i||!i.documentElement||i.getElementsByTagName("parsererror").length){bI.error("Invalid XML: "+b7)}return i};var b4,aa,ap=/#.*$/,R=/([?&])_=[^&]*/,ah=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,B=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,q=/^(?:GET|HEAD)$/,aK=/^\/\//,aV=/^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,v={},a9={},aX="*/".concat("*");try{aa=location.href}catch(bi){aa=n.createElement("a");aa.href="";aa=aa.href}b4=aV.exec(aa.toLowerCase())||[];function bK(e){return function(b9,ca){if(typeof b9!=="string"){ca=b9;b9="*"}var b6,b7=0,b8=b9.toLowerCase().match(aF)||[];if(bI.isFunction(ca)){while((b6=b8[b7++])){if(b6.charAt(0)==="+"){b6=b6.slice(1)||"*";(e[b6]=e[b6]||[]).unshift(ca)}else{(e[b6]=e[b6]||[]).push(ca)}}}}}function p(e,b6,ca,b7){var i={},b8=(e===a9);function b9(cb){var cc;i[cb]=true;bI.each(e[cb]||[],function(ce,cd){var cf=cd(b6,ca,b7);if(typeof cf==="string"&&!b8&&!i[cf]){b6.dataTypes.unshift(cf);b9(cf);return false}else{if(b8){return !(cc=cf)}}});return cc}return b9(b6.dataTypes[0])||!i["*"]&&b9("*")}function s(b6,b7){var e,i,b8=bI.ajaxSettings.flatOptions||{};for(i in b7){if(b7[i]!==undefined){(b8[i]?b6:(e||(e={})))[i]=b7[i]}}if(e){bI.extend(true,b6,e)}return b6}function g(cc,cb,b8){var e,b7,b6,b9,i=cc.contents,ca=cc.dataTypes;while(ca[0]==="*"){ca.shift();if(b7===undefined){b7=cc.mimeType||cb.getResponseHeader("Content-Type")}}if(b7){for(b9 in i){if(i[b9]&&i[b9].test(b7)){ca.unshift(b9);break}}}if(ca[0] in b8){b6=ca[0]}else{for(b9 in b8){if(!ca[0]||cc.converters[b9+" "+ca[0]]){b6=b9;break}if(!e){e=b9}}b6=b6||e}if(b6){if(b6!==ca[0]){ca.unshift(b6)}return b8[b6]}}function ag(cg,b8,cd,b6){var i,cb,ce,b9,b7,cf={},cc=cg.dataTypes.slice();if(cc[1]){for(ce in cg.converters){cf[ce.toLowerCase()]=cg.converters[ce]}}cb=cc.shift();while(cb){if(cg.responseFields[cb]){cd[cg.responseFields[cb]]=b8}if(!b7&&b6&&cg.dataFilter){b8=cg.dataFilter(b8,cg.dataType)}b7=cb;cb=cc.shift();if(cb){if(cb==="*"){cb=b7}else{if(b7!=="*"&&b7!==cb){ce=cf[b7+" "+cb]||cf["* "+cb];if(!ce){for(i in cf){b9=i.split(" ");if(b9[1]===cb){ce=cf[b7+" "+b9[0]]||cf["* "+b9[0]];if(ce){if(ce===true){ce=cf[i]}else{if(cf[i]!==true){cb=b9[0];cc.unshift(b9[1])}}break}}}}if(ce!==true){if(ce&&cg["throws"]){b8=ce(b8)}else{try{b8=ce(b8)}catch(ca){return{state:"parsererror",error:ce?ca:"No conversion from "+b7+" to "+cb}}}}}}}}return{state:"success",data:b8}}bI.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:aa,type:"GET",isLocal:B.test(b4[1]),global:true,processData:true,async:true,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":aX,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":true,"text json":bI.parseJSON,"text xml":bI.parseXML},flatOptions:{url:true,context:true}},ajaxSetup:function(i,e){return e?s(s(i,bI.ajaxSettings),e):s(bI.ajaxSettings,i)},ajaxPrefilter:bK(v),ajaxTransport:bK(a9),ajax:function(ca,b7){if(typeof ca==="object"){b7=ca;ca=undefined}b7=b7||{};var cj,cl,cb,cq,cf,b6,cm,b8,ce=bI.ajaxSetup({},b7),cs=ce.context||ce,ch=ce.context&&(cs.nodeType||cs.jquery)?bI(cs):bI.event,cr=bI.Deferred(),co=bI.Callbacks("once memory"),cc=ce.statusCode||{},ci={},cp={},b9=0,cd="canceled",ck={readyState:0,getResponseHeader:function(i){var e;if(b9===2){if(!b8){b8={};while((e=ah.exec(cq))){b8[e[1].toLowerCase()]=e[2]}}e=b8[i.toLowerCase()]}return e==null?null:e},getAllResponseHeaders:function(){return b9===2?cq:null},setRequestHeader:function(i,ct){var e=i.toLowerCase();if(!b9){i=cp[e]=cp[e]||i;ci[i]=ct}return this},overrideMimeType:function(e){if(!b9){ce.mimeType=e}return this},statusCode:function(i){var e;if(i){if(b9<2){for(e in i){cc[e]=[cc[e],i[e]]}}else{ck.always(i[ck.status])}}return this},abort:function(i){var e=i||cd;if(cm){cm.abort(e)}cg(0,e);return this}};cr.promise(ck).complete=co.add;ck.success=ck.done;ck.error=ck.fail;ce.url=((ca||ce.url||aa)+"").replace(ap,"").replace(aK,b4[1]+"//");ce.type=b7.method||b7.type||ce.method||ce.type;ce.dataTypes=bI.trim(ce.dataType||"*").toLowerCase().match(aF)||[""];if(ce.crossDomain==null){cj=aV.exec(ce.url.toLowerCase());ce.crossDomain=!!(cj&&(cj[1]!==b4[1]||cj[2]!==b4[2]||(cj[3]||(cj[1]==="http:"?"80":"443"))!==(b4[3]||(b4[1]==="http:"?"80":"443"))))}if(ce.data&&ce.processData&&typeof ce.data!=="string"){ce.data=bI.param(ce.data,ce.traditional)}p(v,ce,b7,ck);if(b9===2){return ck}b6=ce.global;if(b6&&bI.active++===0){bI.event.trigger("ajaxStart")}ce.type=ce.type.toUpperCase();ce.hasContent=!q.test(ce.type);cb=ce.url;if(!ce.hasContent){if(ce.data){cb=(ce.url+=(bQ.test(cb)?"&":"?")+ce.data);delete ce.data}if(ce.cache===false){ce.url=R.test(cb)?cb.replace(R,"$1_="+bp++):cb+(bQ.test(cb)?"&":"?")+"_="+bp++}}if(ce.ifModified){if(bI.lastModified[cb]){ck.setRequestHeader("If-Modified-Since",bI.lastModified[cb])}if(bI.etag[cb]){ck.setRequestHeader("If-None-Match",bI.etag[cb])}}if(ce.data&&ce.hasContent&&ce.contentType!==false||b7.contentType){ck.setRequestHeader("Content-Type",ce.contentType)}ck.setRequestHeader("Accept",ce.dataTypes[0]&&ce.accepts[ce.dataTypes[0]]?ce.accepts[ce.dataTypes[0]]+(ce.dataTypes[0]!=="*"?", "+aX+"; q=0.01":""):ce.accepts["*"]);for(cl in ce.headers){ck.setRequestHeader(cl,ce.headers[cl])}if(ce.beforeSend&&(ce.beforeSend.call(cs,ck,ce)===false||b9===2)){return ck.abort()}cd="abort";for(cl in {success:1,error:1,complete:1}){ck[cl](ce[cl])}cm=p(a9,ce,b7,ck);if(!cm){cg(-1,"No Transport")}else{ck.readyState=1;if(b6){ch.trigger("ajaxSend",[ck,ce])}if(ce.async&&ce.timeout>0){cf=setTimeout(function(){ck.abort("timeout")},ce.timeout)}try{b9=1;cm.send(ci,cg)}catch(cn){if(b9<2){cg(-1,cn)}else{throw cn}}}function cg(cw,i,cx,cu){var e,cA,cy,cv,cz,ct=i;if(b9===2){return}b9=2;if(cf){clearTimeout(cf)}cm=undefined;cq=cu||"";ck.readyState=cw>0?4:0;e=cw>=200&&cw<300||cw===304;if(cx){cv=g(ce,ck,cx)}cv=ag(ce,cv,ck,e);if(e){if(ce.ifModified){cz=ck.getResponseHeader("Last-Modified");if(cz){bI.lastModified[cb]=cz}cz=ck.getResponseHeader("etag");if(cz){bI.etag[cb]=cz}}if(cw===204||ce.type==="HEAD"){ct="nocontent"}else{if(cw===304){ct="notmodified"}else{ct=cv.state;cA=cv.data;cy=cv.error;e=!cy}}}else{cy=ct;if(cw||!ct){ct="error";if(cw<0){cw=0}}}ck.status=cw;ck.statusText=(i||ct)+"";if(e){cr.resolveWith(cs,[cA,ct,ck])}else{cr.rejectWith(cs,[ck,ct,cy])}ck.statusCode(cc);cc=undefined;if(b6){ch.trigger(e?"ajaxSuccess":"ajaxError",[ck,ce,e?cA:cy])}co.fireWith(cs,[ck,ct]);if(b6){ch.trigger("ajaxComplete",[ck,ce]);if(!(--bI.active)){bI.event.trigger("ajaxStop")}}}return ck},getJSON:function(e,i,b6){return bI.get(e,i,b6,"json")},getScript:function(e,i){return bI.get(e,undefined,i,"script")}});bI.each(["get","post"],function(e,b6){bI[b6]=function(i,b8,b9,b7){if(bI.isFunction(b8)){b7=b7||b9;b9=b8;b8=undefined}return bI.ajax({url:i,type:b6,dataType:b7,data:b8,success:b9})}});bI.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,b6){bI.fn[b6]=function(i){return this.on(b6,i)}});bI._evalUrl=function(e){return bI.ajax({url:e,type:"GET",dataType:"script",async:false,global:false,"throws":true})};bI.fn.extend({wrapAll:function(e){if(bI.isFunction(e)){return this.each(function(b6){bI(this).wrapAll(e.call(this,b6))})}if(this[0]){var i=bI(e,this[0].ownerDocument).eq(0).clone(true);if(this[0].parentNode){i.insertBefore(this[0])}i.map(function(){var b6=this;while(b6.firstChild&&b6.firstChild.nodeType===1){b6=b6.firstChild}return b6}).append(this)}return this},wrapInner:function(e){if(bI.isFunction(e)){return this.each(function(b6){bI(this).wrapInner(e.call(this,b6))})}return this.each(function(){var i=bI(this),b6=i.contents();if(b6.length){b6.wrapAll(e)}else{i.append(e)}})},wrap:function(e){var i=bI.isFunction(e);return this.each(function(b6){bI(this).wrapAll(i?e.call(this,b6):e)})},unwrap:function(){return this.parent().each(function(){if(!bI.nodeName(this,"body")){bI(this).replaceWith(this.childNodes)}}).end()}});bI.expr.filters.hidden=function(e){return e.offsetWidth<=0&&e.offsetHeight<=0||(!C.reliableHiddenOffsets()&&((e.style&&e.style.display)||bI.css(e,"display"))==="none")};bI.expr.filters.visible=function(e){return !bI.expr.filters.hidden(e)};var bw=/%20/g,aS=/\[\]$/,X=/\r?\n/g,b=/^(?:submit|button|image|reset|file)$/i,au=/^(?:input|select|textarea|keygen)/i;function j(b6,b8,i,b7){var e;if(bI.isArray(b8)){bI.each(b8,function(ca,b9){if(i||aS.test(b6)){b7(b6,b9)}else{j(b6+"["+(typeof b9==="object"?ca:"")+"]",b9,i,b7)}})}else{if(!i&&bI.type(b8)==="object"){for(e in b8){j(b6+"["+e+"]",b8[e],i,b7)}}else{b7(b6,b8)}}}bI.param=function(e,b6){var b7,i=[],b8=function(b9,ca){ca=bI.isFunction(ca)?ca():(ca==null?"":ca);i[i.length]=encodeURIComponent(b9)+"="+encodeURIComponent(ca)};if(b6===undefined){b6=bI.ajaxSettings&&bI.ajaxSettings.traditional}if(bI.isArray(e)||(e.jquery&&!bI.isPlainObject(e))){bI.each(e,function(){b8(this.name,this.value)})}else{for(b7 in e){j(b7,e[b7],b6,b8)}}return i.join("&").replace(bw,"+")};bI.fn.extend({serialize:function(){return bI.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=bI.prop(this,"elements");return e?bI.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!bI(this).is(":disabled")&&au.test(this.nodeName)&&!b.test(e)&&(this.checked||!aM.test(e))}).map(function(e,b6){var b7=bI(this).val();return b7==null?null:bI.isArray(b7)?bI.map(b7,function(i){return{name:b6.name,value:i.replace(X,"\r\n")}}):{name:b6.name,value:b7.replace(X,"\r\n")}}).get()}});bI.ajaxSettings.xhr=a5.ActiveXObject!==undefined?function(){return !this.isLocal&&/^(get|post|head|put|delete|options)$/i.test(this.type)&&bE()||bg()}:bE;var aA=0,aj={},ay=bI.ajaxSettings.xhr();if(a5.ActiveXObject){bI(a5).on("unload",function(){for(var e in aj){aj[e](undefined,true)}})}C.cors=!!ay&&("withCredentials" in ay);ay=C.ajax=!!ay;if(ay){bI.ajaxTransport(function(e){if(!e.crossDomain||C.cors){var i;return{send:function(b9,b6){var b7,b8=e.xhr(),ca=++aA;b8.open(e.type,e.url,e.async,e.username,e.password);if(e.xhrFields){for(b7 in e.xhrFields){b8[b7]=e.xhrFields[b7]}}if(e.mimeType&&b8.overrideMimeType){b8.overrideMimeType(e.mimeType)}if(!e.crossDomain&&!b9["X-Requested-With"]){b9["X-Requested-With"]="XMLHttpRequest"}for(b7 in b9){if(b9[b7]!==undefined){b8.setRequestHeader(b7,b9[b7]+"")}}b8.send((e.hasContent&&e.data)||null);i=function(cd,cc){var cb,cg,ce;if(i&&(cc||b8.readyState===4)){delete aj[ca];i=undefined;b8.onreadystatechange=bI.noop;if(cc){if(b8.readyState!==4){b8.abort()}}else{ce={};cb=b8.status;if(typeof b8.responseText==="string"){ce.text=b8.responseText}try{cg=b8.statusText}catch(cf){cg=""}if(!cb&&e.isLocal&&!e.crossDomain){cb=ce.text?200:404}else{if(cb===1223){cb=204}}}}if(ce){b6(cb,cg,ce,b8.getAllResponseHeaders())}};if(!e.async){i()}else{if(b8.readyState===4){setTimeout(i)}else{b8.onreadystatechange=aj[ca]=i}}},abort:function(){if(i){i(undefined,true)}}}}})}function bE(){try{return new a5.XMLHttpRequest()}catch(i){}}function bg(){try{return new a5.ActiveXObject("Microsoft.XMLHTTP")}catch(i){}}bI.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(e){bI.globalEval(e);return e}}});bI.ajaxPrefilter("script",function(e){if(e.cache===undefined){e.cache=false}if(e.crossDomain){e.type="GET";e.global=false}});bI.ajaxTransport("script",function(b6){if(b6.crossDomain){var e,i=n.head||bI("head")[0]||n.documentElement;return{send:function(b7,b8){e=n.createElement("script");e.async=true;if(b6.scriptCharset){e.charset=b6.scriptCharset}e.src=b6.url;e.onload=e.onreadystatechange=function(ca,b9){if(b9||!e.readyState||/loaded|complete/.test(e.readyState)){e.onload=e.onreadystatechange=null;if(e.parentNode){e.parentNode.removeChild(e)}e=null;if(!b9){b8(200,"success")}}};i.insertBefore(e,i.firstChild)},abort:function(){if(e){e.onload(undefined,true)}}}}});var bs=[],a8=/(=)\?(?=&|$)|\?\?/;bI.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=bs.pop()||(bI.expando+"_"+(bp++));this[e]=true;return e}});bI.ajaxPrefilter("json jsonp",function(b7,e,b8){var ca,i,b6,b9=b7.jsonp!==false&&(a8.test(b7.url)?"url":typeof b7.data==="string"&&!(b7.contentType||"").indexOf("application/x-www-form-urlencoded")&&a8.test(b7.data)&&"data");if(b9||b7.dataTypes[0]==="jsonp"){ca=b7.jsonpCallback=bI.isFunction(b7.jsonpCallback)?b7.jsonpCallback():b7.jsonpCallback;if(b9){b7[b9]=b7[b9].replace(a8,"$1"+ca)}else{if(b7.jsonp!==false){b7.url+=(bQ.test(b7.url)?"&":"?")+b7.jsonp+"="+ca}}b7.converters["script json"]=function(){if(!b6){bI.error(ca+" was not called")}return b6[0]};b7.dataTypes[0]="json";i=a5[ca];a5[ca]=function(){b6=arguments};b8.always(function(){a5[ca]=i;if(b7[ca]){b7.jsonpCallback=e.jsonpCallback;bs.push(ca)}if(b6&&bI.isFunction(i)){i(b6[0])}b6=i=undefined});return"script"}});bI.parseHTML=function(b8,b6,b7){if(!b8||typeof b8!=="string"){return null}if(typeof b6==="boolean"){b7=b6;b6=false}b6=b6||n;var i=a.exec(b8),e=!b7&&[];if(i){return[b6.createElement(i[1])]}i=bI.buildFragment([b8],b6,e);if(e&&e.length){bI(e).remove()}return bI.merge([],i.childNodes)};var b1=bI.fn.load;bI.fn.load=function(b7,ca,cb){if(typeof b7!=="string"&&b1){return b1.apply(this,arguments)}var e,b6,b8,i=this,b9=b7.indexOf(" ");if(b9>=0){e=bI.trim(b7.slice(b9,b7.length));b7=b7.slice(0,b9)}if(bI.isFunction(ca)){cb=ca;ca=undefined}else{if(ca&&typeof ca==="object"){b8="POST"}}if(i.length>0){bI.ajax({url:b7,type:b8,dataType:"html",data:ca}).done(function(cc){b6=arguments;i.html(e?bI("<div>").append(bI.parseHTML(cc)).find(e):cc)}).complete(cb&&function(cd,cc){i.each(cb,b6||[cd.responseText,cc,cd])})}return this};bI.expr.filters.animated=function(e){return bI.grep(bI.timers,function(i){return e===i.elem}).length};var bX=a5.document.documentElement;function br(e){return bI.isWindow(e)?e:e.nodeType===9?e.defaultView||e.parentWindow:false}bI.offset={setOffset:function(b7,ch,cb){var cd,ca,e,b8,b6,cf,cg,cc=bI.css(b7,"position"),b9=bI(b7),ce={};if(cc==="static"){b7.style.position="relative"}b6=b9.offset();e=bI.css(b7,"top");cf=bI.css(b7,"left");cg=(cc==="absolute"||cc==="fixed")&&bI.inArray("auto",[e,cf])>-1;if(cg){cd=b9.position();b8=cd.top;ca=cd.left}else{b8=parseFloat(e)||0;ca=parseFloat(cf)||0}if(bI.isFunction(ch)){ch=ch.call(b7,cb,b6)}if(ch.top!=null){ce.top=(ch.top-b6.top)+b8}if(ch.left!=null){ce.left=(ch.left-b6.left)+ca}if("using" in ch){ch.using.call(b7,ce)}else{b9.css(ce)}}};bI.fn.extend({offset:function(i){if(arguments.length){return i===undefined?this:this.each(function(ca){bI.offset.setOffset(this,i,ca)})}var e,b9,b7={top:0,left:0},b6=this[0],b8=b6&&b6.ownerDocument;if(!b8){return}e=b8.documentElement;if(!bI.contains(e,b6)){return b7}if(typeof b6.getBoundingClientRect!==aC){b7=b6.getBoundingClientRect()}b9=br(b8);return{top:b7.top+(b9.pageYOffset||e.scrollTop)-(e.clientTop||0),left:b7.left+(b9.pageXOffset||e.scrollLeft)-(e.clientLeft||0)}},position:function(){if(!this[0]){return}var b6,b7,e={top:0,left:0},i=this[0];if(bI.css(i,"position")==="fixed"){b7=i.getBoundingClientRect()}else{b6=this.offsetParent();b7=this.offset();if(!bI.nodeName(b6[0],"html")){e=b6.offset()}e.top+=bI.css(b6[0],"borderTopWidth",true);e.left+=bI.css(b6[0],"borderLeftWidth",true)}return{top:b7.top-e.top-bI.css(i,"marginTop",true),left:b7.left-e.left-bI.css(i,"marginLeft",true)}},offsetParent:function(){return this.map(function(){var e=this.offsetParent||bX;while(e&&(!bI.nodeName(e,"html")&&bI.css(e,"position")==="static")){e=e.offsetParent}return e||bX})}});bI.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(b6,i){var e=/Y/.test(i);bI.fn[b6]=function(b7){return aB(this,function(b8,cb,ca){var b9=br(b8);if(ca===undefined){return b9?(i in b9)?b9[i]:b9.document.documentElement[cb]:b8[cb]}if(b9){b9.scrollTo(!e?ca:bI(b9).scrollLeft(),e?ca:bI(b9).scrollTop())}else{b8[cb]=ca}},b6,b7,arguments.length,null)}});bI.each(["top","left"],function(e,b6){bI.cssHooks[b6]=a7(C.pixelPosition,function(b7,i){if(i){i=F(b7,b6);return Y.test(i)?bI(b7).position()[b6]+"px":i}})});bI.each({Height:"height",Width:"width"},function(e,i){bI.each({padding:"inner"+e,content:i,"":"outer"+e},function(b6,b7){bI.fn[b7]=function(cb,ca){var b9=arguments.length&&(b6||typeof cb!=="boolean"),b8=b6||(cb===true||ca===true?"margin":"border");return aB(this,function(cd,cc,ce){var cf;if(bI.isWindow(cd)){return cd.document.documentElement["client"+e]}if(cd.nodeType===9){cf=cd.documentElement;return Math.max(cd.body["scroll"+e],cf["scroll"+e],cd.body["offset"+e],cf["offset"+e],cf["client"+e])}return ce===undefined?bI.css(cd,cc,b8):bI.style(cd,cc,ce,b8)},i,b9?cb:undefined,b9,null)}})});bI.fn.size=function(){return this.length};bI.fn.andSelf=bI.fn.addBack;if(typeof define==="function"&&define.amd){define("jquery",[],function(){return bI})}var bk=a5.jQuery,H=a5.$;bI.noConflict=function(e){if(a5.$===bI){a5.$=H}if(e&&a5.jQuery===bI){a5.jQuery=bk}return bI};if(typeof av===aC){a5.jQuery=a5.$=bI}return bI}));if(!window.require){window.require=function require(){}}if(!window.sc_require){window.sc_require=require}if(!window.sc_resource){window.sc_resource=function sc_resource(){}}sc_require("license");window.YES=true;window.NO=false;if(typeof console==="undefined"){window.console={};console.log=console.info=console.warn=console.error=function(){}}window.SC=window.SC||{};window.SproutCore=window.SproutCore||SC;SC=window.SC;SC.VERSION="1.11.0";SC._baseMixin=function(e,c){var g=c[0]||{},a=1,f=c.length,b,h,d;if(f===1){g=this||{};a=0}for(;a<f;a++){if(!(b=c[a])){continue}for(d in b){if(!b.hasOwnProperty(d)){continue}h=b[d];if(g===h){continue}if(h!==undefined&&(e||(g[d]===undefined))){g[d]=h}}if(b.hasOwnProperty("toString")){g.toString=b.toString}}return g};SC.mixin=function(){var b=new Array(arguments.length);for(var c=0,a=b.length;c<a;c++){b[c]=arguments[c]}return SC._baseMixin(true,b)};SC.supplement=function(){var b=new Array(arguments.length);for(var c=0,a=b.length;c<a;c++){b[c]=arguments[c]}return SC._baseMixin(false,b)};SC.extend=SC.mixin;SC.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",T_DATE:"date",T_REGEXP:"regexp",typeOf:function(a){var b=SC._nativeTypeOf(a);if(b==="function"){return a.isClass?SC.T_CLASS:SC.T_FUNCTION}else{if(b==="object"){if(SC.Error&&(a instanceof SC.Error)){return SC.T_ERROR}else{if(a instanceof SC.Object){return SC.T_OBJECT}else{return SC.T_HASH}}}}return b},_nativeTypeOf:function(a){if(a===undefined){return SC.T_UNDEFINED}if(a===null){return SC.T_NULL}var c=typeof a,b;if(c==="object"||c==="function"){b=SC._nativeToString.call(a);return SC._nativeTypeHash[b]||"object"}else{return c}},_nativeTypeHash:{"[object Boolean]":"boolean","[object Number]":"number","[object String]":"string","[object Function]":"function","[object Array]":"array","[object Date]":"date","[object RegExp]":"regexp","[object Object]":"object"},_nativeToString:Object.prototype.toString,none:function(a){return a==null},empty:function(a){return a===null||a===undefined||a===""},isArray:function(a){if(!a||a.setInterval){return false}if(Array.isArray&&Array.isArray(a)){return true}if(a.objectAt){return true}if(a.length!==undefined&&SC._nativeTypeOf(a)==="object"){return true}return false},makeArray:function(a){return SC.isArray(a)?a:SC.A(a)},A:function(c){if(c===null||c===undefined){return[]}if(c.slice instanceof Function){if(typeof(c)==="string"){return[c]}else{return c.slice()}}if(c.toArray){return c.toArray()}if(!SC.isArray(c)){return[c]}var b=[],a=c.length;while(--a>=0){b[a]=c[a]}return b},guidKey:"SproutCore"+(SC.VERSION+Math.random()).replace(/\D/g,""),_guidPrefixes:{number:"nu",string:"st"},_guidCaches:{number:{},string:{}},_numberGuids:[],_stringGuids:{},_keyCache:{},_uuid:0,guidFor:function(e){var b,c,d=typeof e;if(e===undefined){return"(undefined)"}if(e===null){return"(null)"}if(d===SC.T_NUMBER||d===SC.T_STRING){b=this._guidCaches[d];c=b[e];if(!c){c="st"+(SC._uuid++);b[e]=c}return c}else{if(d===SC.T_BOOL){return(e)?"(true)":"(false)"}}var a=this.guidKey;if(e[a]){return e[a]}if(e===Object){return"(Object)"}if(e===Array){return"(Array)"}return SC.generateGuid(e,"sc")},keyFor:function(d,c){var b,a=this._keyCache[d];if(!a){a=this._keyCache[d]={}}b=a[c];if(!b){b=a[c]=d+"_"+c}return b},generateGuid:function(c,b){var a=(b+(SC._uuid++));if(c){c[this.guidKey]=a}return a},hashFor:function(){var a=arguments.length,c="",e,d,b;for(b=0;b<a;++b){e=arguments[b];c+=(e&&(d=e.hash)&&(typeof d===SC.T_FUNCTION))?d.call(e):this.guidFor(e)}return c===""?null:c},isEqual:function(d,c){return this.hashFor(d)===this.hashFor(c)},compare:function(s,p){if(s===p){return 0}var j=SC.typeOf(s);var g=SC.typeOf(p);var b=SC.ORDER_DEFINITION_MAPPING;if(!b){var d=SC.ORDER_DEFINITION;b=SC.ORDER_DEFINITION_MAPPING={};var q,n;for(q=0,n=d.length;q<n;++q){b[d[q]]=q}delete SC.ORDER_DEFINITION}var t=b[j];var c=b[g];if(t<c){return -1}if(t>c){return 1}switch(j){case SC.T_BOOL:case SC.T_NUMBER:if(s<p){return -1}if(s>p){return 1}return 0;case SC.T_STRING:var k=s.localeCompare(p);if(k<0){return -1}if(k>0){return 1}return 0;case SC.T_ARRAY:var o=s.length;var m=p.length;var e=Math.min(o,m);var a=0;var h=0;var f=arguments.callee;while(a===0&&h<e){a=f(s[h],p[h]);h++}if(a!==0){return a}if(o<m){return -1}if(o>m){return 1}return 0;case SC.T_OBJECT:if(s.constructor.isComparable===YES){return s.constructor.compare(s,p)}return 0;default:return 0}},K:function(){return this},EMPTY_ARRAY:[],EMPTY_HASH:{},EMPTY_RANGE:{start:0,length:0},beget:function(c){if(c===null||c===undefined){return null}var a=SC.K;a.prototype=c;var b=new a();a.prototype=null;if(typeof c.didBeget==="function"){b=c.didBeget(b)}return b},copy:function(d,b){var c=d,a;if(d){if(d.isCopyable){return d.copy(b)}if(d.clone){return d.clone()}}switch(SC._nativeTypeOf(d)){case"array":c=d.slice();if(b){a=c.length;while(a--){c[a]=SC.copy(c[a],true)}}break;case"object":c={};for(var e in d){c[e]=b?SC.copy(d[e],true):d[e]}}return c},merge:function(){var c={},b=arguments.length,a;for(a=0;a<b;a++){SC.mixin(c,arguments[a])}return c},keys:function(c){var a=[];for(var b in c){a.push(b)}return a},inspect:function(d){var a,b=[];for(var c in d){a=d[c];if(a==="toString"){continue}if(SC.typeOf(a)===SC.T_FUNCTION){a="function () { ... }"}b.push(c+": "+a)}return"{ "+b.join(", ")+" }"},tupleForPropertyPath:function(e,a){if(e==null){return null}if(typeof e==="object"&&(e instanceof Array)){return e}var c;var b=e.indexOf("*");if(b<0){b=e.lastIndexOf(".")}c=(b>=0)?e.slice(b+1):e;var d=this.objectForPropertyPath(e,a,b);return(d&&c)?[d,c]:null},objectForPropertyPath:function(f,c,d){var g,b,e,a;if(!c){c=window}if(typeof f==="string"){if(d===undefined){d=f.length}g=0;while((c)&&(g<d)){b=f.indexOf(".",g);if((b<0)||(b>d)){b=d}e=f.slice(g,b);c=c.get?c.get(e):c[e];g=b+1}if(g<d){c=undefined}}else{g=0;a=f.length;e=null;while((g<a)&&c){e=f[g++];if(e){c=(c.get)?c.get(e):c[e]}}if(g<a){c=undefined}}return c},requiredObjectForPropertyPath:function(c,a,b){var d=SC.objectForPropertyPath(c,a,b);if(!d){throw c+" could not be found"}return d}});SC.clone=SC.copy;SC.$A=SC.A;SC.didLoad=SC.K;SC.ORDER_DEFINITION=[SC.T_ERROR,SC.T_UNDEFINED,SC.T_NULL,SC.T_BOOL,SC.T_NUMBER,SC.T_STRING,SC.T_ARRAY,SC.T_HASH,SC.T_OBJECT,SC.T_FUNCTION,SC.T_CLASS];SC.Function={property:function(b,c){b.dependentKeys=SC.$A(c);var a=SC.guidFor(b);b.cacheKey="__cache__"+a;b.lastSetValueKey="__lastValue__"+a;b.isProperty=true;return b},cacheable:function(a,b){a.isProperty=true;if(!a.dependentKeys){a.dependentKeys=[]}a.isCacheable=(b===undefined)?true:b;return a},idempotent:function(a,b){a.isProperty=true;if(!a.dependentKeys){this.dependentKeys=[]}a.isVolatile=(b===undefined)?true:b;return a},enhance:function(a){a.isEnhancement=true;return a},observes:function(c,a){var f=a.length,b=null,e=null;while(--f>=0){var d=a[f];if((d.indexOf(".")<0)&&(d.indexOf("*")<0)){if(!b){b=c.localPropertyPaths=[]}b.push(d)}else{if(!e){e=c.propertyPaths=[]}e.push(d)}}return c}};sc_require("system/function");SC.mixin(Function.prototype,{property:function(){return SC.Function.property(this,arguments)},cacheable:function(a){return SC.Function.cacheable(this,a)},idempotent:function(a){return SC.Function.idempotent(this,a)},enhance:function(){return SC.Function.enhance(this)},observes:function(a){return SC.Function.observes(this,arguments)}});SC.ObserverSet={add:function(j,a,c){var b=SC.guidFor(j),f=SC.guidFor(a),i=this._members,d=this.members,g=i[b],h,e;if(!g){g=i[b]={_size:0}}h=g[f];if(h===undefined){g[f]=d.length;g._size++;e=[j,a,c];d.push(e)}else{}},remove:function(g,h){var e=SC.guidFor(g),b=SC.guidFor(h);var d=this._members[e],a=this.members;if(!d){return false}var c=d[b];if(c===undefined){return false}if(c!==a.length-1){var f=(a[c]=a[a.length-1]);this._members[SC.guidFor(f[0])][SC.guidFor(f[1])]=c}a.pop();delete this._members[e][b];if(--this._members[e]._size===0){delete this._members[e]}return true},invokeMethods:function(){var b=this.members,d;for(var c=0,a=b.length;c<a;c++){d=b[c];d[1].call(d[0],d[2])}},clone:function(){var c=SC.ObserverSet.create(),d=this.members;c._members=SC.clone(this._members);var e=c.members;for(var b=0,a=d.length;b<a;b++){e[b]=SC.clone(d[b]);e[b].length=3}return c},create:function(){return new SC.ObserverSet.constructor()},getMembers:function(){return this.members.slice(0)},constructor:function(){this._members={};this.members=[]}};SC.ObserverSet.constructor.prototype=SC.ObserverSet;SC.ObserverSet.slice=SC.ObserverSet.clone;SC.ObserverSet.copy=SC.ObserverSet.clone;SC._ChainObserver=function(b,a){this.property=b;this.root=a||this};SC._ChainObserver.createChain=function(e,l,g,a,b){var c=l.split("."),j=new SC._ChainObserver(c[0]),h=j;for(var d=1,f=c.length;d<f;d++){h=h.next=new SC._ChainObserver(c[d],j)}var k=j.tails=[h];j.objectDidChange(e);k.forEach(function(i){i.target=g;i.method=a;i.context=b});j.tails=null;return j};SC._ChainObserver.prototype={isChainObserver:true,object:null,property:null,next:null,root:null,target:null,method:null,tail:function(){if(this._tail){return this._tail}var a=this;while(a.next){a=a.next}this._tail=a;return a},objectDidChange:function(a){if(a===this.object){return}if(this.object){if(this.property==="@each"&&this.object._removeContentObserver){this.object._removeContentObserver(this)}else{if(this.object.removeObserver){this.object.removeObserver(this.property,this,this.propertyDidChange)}}}this.object=a;if(this.property==="@each"&&this.next){if(this.object&&this.object._addContentObserver){this.object._addContentObserver(this)}}else{if(this.object&&this.object.addObserver){this.object.addObserver(this.property,this,this.propertyDidChange)}this.propertyDidChange()}},propertyDidChange:function(){var b=this.object;var e=this.property;var d=(b&&b.get)?b.get(e):null;if(this.next){this.next.objectDidChange(d)}var f=this.target,g=this.method,c=this.context;if(f&&g){var a=b?b.propertyRevision:null;if(c){g.call(f,b,e,d,c,a)}else{g.call(f,b,e,d,a)}}},destroyChain:function(){var a=this.object;if(a){if(this.property==="@each"&&this.next&&a._removeContentObserver){a._removeContentObserver(this)}if(a.removeObserver){a.removeObserver(this.property,this,this.propertyDidChange)}}if(this.next){this.next.destroyChain()}this.next=this.target=this.method=this.object=this.context=null;return null}};sc_require("ext/function");sc_require("private/observer_set");sc_require("private/chain_observer");SC.OBSERVES_HANDLER_ADD=0;SC.OBSERVES_HANDLER_REMOVE=1;SC.Observable={_kvo_cache:null,_kvo_cacheable:false,_kvo_cachedep:null,_kvo_changeLevel:0,_kvo_changes:null,_kvo_cloned:null,_kvo_revision:0,_observableInited:false,isObservable:YES,automaticallyNotifiesObserversFor:function(a){return YES},get:function(c){var b=this[c],a;if(b===undefined){return this.unknownProperty(c)}else{if(b&&b.isProperty){if(b.isCacheable){a=this._kvo_cache;if(!a){a=this._kvo_cache={}}return(a[b.cacheKey]!==undefined)?a[b.cacheKey]:(a[b.cacheKey]=b.call(this,c))}else{return b.call(this,c)}}else{return b}}},set:function(i,g){var b=this[i],j=this.automaticallyNotifiesObserversFor(i),f=g,d,a,h,e;if(g===undefined&&SC.typeOf(i)===SC.T_HASH){var c=i;for(var k in c){if(!c.hasOwnProperty(k)){continue}this.set(k,c[k])}return this}if(!j&&this._kvo_cacheable&&(a=this._kvo_cache)){d=this._kvo_cachedep;if(!d||(d=d[i])===undefined){d=this._kvo_computeCachedDependentsFor(i)}if(d){h=d.length;while(--h>=0){e=d[h];a[e.cacheKey]=a[e.lastSetValueKey]=undefined}}}if(b&&b.isProperty){a=this._kvo_cache;if(b.isVolatile||!a||(a[b.lastSetValueKey]!==g)){if(!a){a=this._kvo_cache={}}a[b.lastSetValueKey]=g;if(j){this.propertyWillChange(i)}f=b.call(this,i,g);if(b.isCacheable){a[b.cacheKey]=f}if(j){this.propertyDidChange(i,f,YES)}}}else{if(b===undefined){if(j){this.propertyWillChange(i)}this.unknownProperty(i,g);if(j){this.propertyDidChange(i,f)}}else{if(this[i]!==g){if(j){this.propertyWillChange(i)}f=this[i]=g;if(j){this.propertyDidChange(i,f)}}}}return this},unknownProperty:function(a,b){if(b!==undefined){this[a]=b}return b},beginPropertyChanges:function(){this._kvo_changeLevel=this._kvo_changeLevel+1;return this},endPropertyChanges:function(){this._kvo_changeLevel=(this._kvo_changeLevel||1)-1;var b=this._kvo_changeLevel,a=this._kvo_changes;if((b<=0)&&a&&(a.length>0)&&!SC.Observers.isObservingSuspended){this._notifyPropertyObservers()}return this},propertyWillChange:function(a){return this},propertyDidChange:function(m,k,c){this._kvo_revision=this._kvo_revision+1;var b=this._kvo_changeLevel,g,l,h,d;var i=this._kvo_property_chains;if(i){var f=i[m];if(f){this.beginPropertyChanges();f=SC.clone(f);f.forEach(function(n){n.notifyPropertyDidChange()});this.endPropertyChanges()}}var a=this._kvo_cache;if(a){if(!c){d=this[m];if(d&&d.isProperty){a[d.cacheKey]=a[d.lastSetValueKey]=undefined}}if(this._kvo_cacheable){g=this._kvo_cachedep;if(!g||(g=g[m])===undefined){g=this._kvo_computeCachedDependentsFor(m)}if(g){l=g.length;while(--l>=0){h=g[l];a[h.cacheKey]=a[h.lastSetValueKey]=undefined}}}}var e=SC.Observers.isObservingSuspended;if((b>0)||e){var j=this._kvo_changes;if(!j){j=this._kvo_changes=SC.CoreSet.create()}j.add(m);if(e){SC.Observers.objectHasPendingChanges(this)}}else{this._notifyPropertyObservers(m)}return this},registerDependentKey:function(c,g){var h=this._kvo_dependents,d,b,f,e,a;if(typeof g==="object"&&(g instanceof Array)){d=g;f=0}else{d=arguments;f=1}b=d.length;if(!h){this._kvo_dependents=h={}}while(--b>=f){e=d[b];if(e.indexOf(".")>=0){SC._PropertyChain.createChain(e,this,c).activate()}else{a=h[e];if(!a){a=h[e]=[]}a.push(c)}}},registerDependentKeyWithChain:function(b,a){var c=this._chainsFor(b);c.add(a)},removeDependentKeyWithChain:function(b,a){var c=this._chainsFor(b);c.remove(a);if(c.get("length")===0){delete this._kvo_property_chains[b]}},_chainsFor:function(a){this._kvo_property_chains=this._kvo_property_chains||{};var b=this._kvo_property_chains[a]||SC.CoreSet.create();this._kvo_property_chains[a]=b;return b},_kvo_addCachedDependents:function(b,f,h,c){var a=f.length,e,d,g;while(--a>=0){d=f[a];c.add(d);e=this[d];if(e&&(e instanceof Function)&&e.isProperty){if(e.isCacheable){b.push(e)}if((g=h[d])&&g.length>0){this._kvo_addCachedDependents(b,g,h,c)}}}},_kvo_computeCachedDependentsFor:function(c){var d=this._kvo_cachedep,f=this._kvo_dependents,e=f?f[c]:null,a,b;if(!d){d=this._kvo_cachedep={}}if(!e||e.length===0){return d[c]=null}a=d[c]=[];b=SC._TMP_SEEN_SET=(SC._TMP_SEEN_SET||SC.CoreSet.create());b.add(c);this._kvo_addCachedDependents(a,e,f,b);b.clear();if(a.length===0){a=d[c]=null}return a},_kvo_for:function(c,b){var a=this[c];if(!this._kvo_cloned){this._kvo_cloned={}}if(!a){a=this[c]=(b===undefined)?[]:b.create();this._kvo_cloned[c]=YES}else{if(!this._kvo_cloned[c]){a=this[c]=a.copy();this._kvo_cloned[c]=YES}}return a},addObserver:function(c,e,f,b){var d,a;if(f===undefined){f=e;e=this}if(!e){e=this}if(typeof f==="string"){f=e[f]}if(!f){throw new Error("You must pass a method to addObserver()")}c=c.toString();if(c.indexOf(".")>=0){a=SC._ChainObserver.createChain(this,c,e,f,b);a.masterTarget=e;a.masterMethod=f;this._kvo_for(SC.keyFor("_kvo_chains",c)).push(a)}else{if((this[c]===undefined)&&(c.indexOf("@")===0)){this.get(c)}if(e===this){e=null}d=SC.keyFor("_kvo_observers",c);this._kvo_for(d,SC.ObserverSet).add(e,f,b);this._kvo_for("_kvo_observed_keys",SC.CoreSet).add(c)}if(this.didAddObserver){this.didAddObserver(c,e,f)}return this},removeObserver:function(c,f,h){var d,e,b,g,a;if(h===undefined){h=f;f=this}if(!f){f=this}if(typeof h==="string"){h=f[h]}if(!h){throw new Error("You must pass a method to removeObserver()")}c=c.toString();if(c.indexOf(".")>=0){d=SC.keyFor("_kvo_chains",c);if(e=this[d]){e=this._kvo_for(d);a=e.length;while(--a>=0){b=e[a];if(b&&(b.masterTarget===f)&&(b.masterMethod===h)){e[a]=b.destroyChain()}}}}else{if(f===this){f=null}d=SC.keyFor("_kvo_observers",c);if(g=this[d]){g=this._kvo_for(d);g.remove(f,h);if(g.getMembers().length===0){this._kvo_for("_kvo_observed_keys",SC.CoreSet).remove(c)}}}if(this.didRemoveObserver){this.didRemoveObserver(c,f,h)}return this},hasObserverFor:function(j,g,a){SC.Observers.flush(this);var e=this[SC.keyFor("_kvo_observers",j)],h=this._kvo_for(SC.keyFor("_kvo_chains",j)),b=this[SC.keyFor("_kvo_local",j)],k=j.indexOf(".")>=0;if(g===undefined){if(k){if(h&&h.length>0){return YES}}else{if(b&&b.length>0){return YES}if(e&&e.getMembers().length>0){return YES}}return NO}else{if(a===undefined){a=g;g=this}if(typeof a==="string"){a=g[a]}if(!a){throw new Error("Developer Error: If present, the `method` argument of hasObserverFor must be (or refer to) a function.")}var d,f;if(k){if(!h||!h.length){return NO}f=h.length;for(d=0;d<f;d++){if(h[d].masterTarget===g&&h[d].masterMethod===a){return YES}}return NO}else{if(g===this){if(!b){return NO}f=b.length;for(d=0;d<f;d++){if(this[b[d]]===a){return YES}}return NO}else{if(!e||!e.members){return NO}f=e.members.length;var c;for(d=0;d<f;d++){c=e.members[d];if(c[0]===g&&c[1]===a){return YES}}return NO}}}},initObservable:function(){if(this._observableInited){return}this._observableInited=YES;var e,k,i,h,g,d,j,f,b,l,c,a;if(k=this._observers){f=k.length;for(e=0;e<f;e++){i=k[e];g=this[i];d=g.propertyPaths;j=(d)?d.length:0;for(b=0;b<j;b++){l=d[b];this.addObservesHandler(g,l)}}}this.bindings=[];if(k=this._bindings){for(e=0,a=k.length;e<a;e++){i=k[e];h=this[i];c=i.slice(0,-7);this[i]=this.bind(c,h)}}if(k=this._properties){for(e=0,a=k.length;e<a;e++){i=k[e];if(h=this[i]){if(h.isCacheable){this._kvo_cacheable=YES}if(h.dependentKeys&&(h.dependentKeys.length>0)){this.registerDependentKey(i,h.dependentKeys)}}}}delete this._bindings;delete this._properties;return this},destroyObservable:function(){var f,h,d,e,i,b,g;this.bindings.invoke("destroy");delete this.bindings;if(h=this._observers){d=h.length;for(var c=0;c<d;c++){f=h[c];e=this[f];b=e.propertyPaths;g=(b)?b.length:0;for(var a=0;a<g;a++){i=b[a];this.removeObservesHandler(e,i)}}}delete this._observers;return this},addObservesHandler:function(a,b){this._configureObservesHandler(SC.OBSERVES_HANDLER_ADD,a,b);return this},removeObservesHandler:function(a,b){this._configureObservesHandler(SC.OBSERVES_HANDLER_REMOVE,a,b);return this},_configureObservesHandler:function(d,b,e){var c,a;switch(d){case SC.OBSERVES_HANDLER_ADD:d="addObserver";break;case SC.OBSERVES_HANDLER_REMOVE:d="removeObserver";break;default:throw new Error("invalid action provided: "+d)}c=e.indexOf(".");if(c<0){this[d](e,this,b)}else{if(e.indexOf("*")===0){this[d](e.slice(1),this,b)}else{a=null;if(c===0){a=this;e=e.slice(1)}else{if(c===4&&e.slice(0,5)==="this."){a=this;e=e.slice(5)}else{if(c<0&&e.length===4&&e==="this"){a=this;e=""}else{if(c>0&&e[0]===e.charAt(0).toLowerCase()){a=this}}}}SC.Observers[d](e,this,b,a)}}},observersForKey:function(a){SC.Observers.flush(this);var b=this[SC.keyFor("_kvo_observers",a)];return b?b.getMembers():[]},_notifyPropertyObservers:function(s){if(!this._observableInited){this.initObservable()}SC.Observers.flush(this);var n,q,l,d,m,k,p,o,i,a,f,r,c,h,e,b,g,j;d=this["_kvo_observers_*"];this._kvo_changeLevel=this._kvo_changeLevel+1;while(((q=this._kvo_changes)&&(q.length>0))||s){p=++this.propertyRevision;if(!q){q=SC.CoreSet.create()}this._kvo_changes=null;if(s==="*"){q.add("*");q.addEach(this._kvo_for("_kvo_observed_keys",SC.CoreSet))}else{if(s){q.add(s)}}l=this._kvo_dependents;if(l){for(m=0;m<q.length;m++){s=q[m];k=l[s];if(k&&(h=k.length)){j=this._kvo_cache;if(!j){j=this._kvo_cache={}}while(--h>=0){q.add(s=k[h]);if(e=this[s]){this[e.cacheKey]=undefined;j[e.cacheKey]=j[e.lastSetValueKey]=undefined}}}}}while(q.length>0){s=q.pop();n=this[SC.keyFor("_kvo_observers",s)];if(n){o=n.getMembers();i=o.length;for(f=0;f<i;f++){a=o[f];if(a[3]===p){continue}if(!a[1]){console.log(a)}r=a[0]||this;c=a[1];b=a[2];a[3]=p;if(b!==undefined){c.call(r,this,s,null,b,p)}else{c.call(r,this,s,null,p)}}}o=this[SC.keyFor("_kvo_local",s)];if(o){i=o.length;for(f=0;f<i;f++){a=o[f];c=this[a];if(c){c.call(this,this,s,null,p)}}}if(d&&s!=="*"){o=d.getMembers();i=o.length;for(f=0;f<i;f++){a=o[f];r=a[0]||this;c=a[1];b=a[2];if(b!==undefined){c.call(r,this,s,null,b,p)}else{c.call(r,this,s,null,p)}}}if(this.propertyObserver){this.propertyObserver(this,s,null,p)}}if(q){q.destroy()}s=null}this._kvo_changeLevel=(this._kvo_changeLevel||1)-1;return YES},bind:function(a,c,e){var d,b;if(e!==undefined){c=[c,e]}b=typeof c;if(b==="string"||(b==="object"&&(c instanceof Array))){d=this[a+"BindingDefault"]||SC.Binding;d=d.beget().from(c)}else{d=c.beget()}d=d.to(a,this).connect();this.bindings.push(d);return d},didChangeFor:function(a){var b,f,e,j,d,c,h,i,g;a=SC.hashFor(a);b=this._kvo_didChange_valueCache;if(!b){b=this._kvo_didChange_valueCache={}}f=this._kvo_didChange_revisionCache;if(!f){f=this._kvo_didChange_revisionCache={}}e=b[a]||{};j=f[a]||{};d=false;c=this._kvo_revision;h=arguments.length;while(--h>=1){i=arguments[h];if(j[i]!=c){g=this.get(i);if(e[i]!==g){d=true;e[i]=g}}j[i]=c}b[a]=e;f[a]=j;return d},setIfChanged:function(a,b){if(b===undefined&&SC.typeOf(a)===SC.T_HASH){var c=a;for(a in c){if(!c.hasOwnProperty(a)){continue}this.setIfChanged(a,c[a])}return this}return(this.get(a)!==b)?this.set(a,b):this},getPath:function(b){var a=SC.tupleForPropertyPath(b,this);if(a===null||a[0]===null){return undefined}return SC.get(a[0],a[1])},setPath:function(c,b){if(c.indexOf(".")>=0){var a=SC.tupleForPropertyPath(c,this);if(!a||!a[0]){return null}a[0].set(a[1],b)}else{this.set(c,b)}return this},setPathIfChanged:function(c,b){if(c.indexOf(".")>=0){var a=SC.tupleForPropertyPath(c,this);if(!a||!a[0]){return null}if(a[0].get(a[1])!==b){a[0].set(a[1],b)}}else{this.setIfChanged(c,b)}return this},getEach:function(){var c=[],a,b;for(a=0,b=arguments.length;a<b;a++){c[c.length]=this.getPath(arguments[a])}return c},incrementProperty:function(b,a){if(!a){a=1}this.set(b,(this.get(b)||0)+a);return this.get(b)},decrementProperty:function(b,a){if(!a){a=1}this.set(b,(this.get(b)||0)-a);return this.get(b)},toggleProperty:function(a,b,c){if(b===undefined){b=true}if(c===undefined){c=false}b=(this.get(a)==b)?c:b;this.set(a,b);return this.get(a)},notifyPropertyChange:function(a,b){this.propertyWillChange(a);this.propertyDidChange(a,b);return this},allPropertiesDidChange:function(){this._kvo_cache=null;this._notifyPropertyObservers("*");return this},propertyRevision:1};SC.mixin(SC,{get:function(a,b){if(!a){return undefined}if(b===undefined){return this[a]}if(a.get){return a.get(b)}return a[b]},getPath:function(a,b){if(b===undefined){b=a;a=window}return SC.objectForPropertyPath(b,a)}});SC.mixin(Array.prototype,SC.Observable);SC.Enumerator=function(a){this.enumerable=a;this.reset();return this};SC.Enumerator.prototype={nextObject:function(){var c=this._index;var a=this._length;if(c>=a){return undefined}var b=this.enumerable.nextObject(c,this._previousObject,this._context);this._previousObject=b;this._index=c+1;if(c>=a){this._context=SC.Enumerator._pushContext(this._context)}return b},reset:function(){var b=this.enumerable;if(!b){SC.throw("Enumerator has been destroyed")}this._length=b.get?b.get("length"):b.length;var a=this._length;this._index=0;this._previousObject=null;this._context=(a>0)?SC.Enumerator._popContext():null},destroy:function(){this.enumerable=this._length=this._index=this._previousObject=this._context=null}};SC.Enumerator.create=function(a){return new SC.Enumerator(a)};SC.Enumerator._popContext=function(){var a=this._contextCache?this._contextCache.pop():null;return a||{}};SC.Enumerator._pushContext=function(b){this._contextCache=this._contextCache||[];var a=this._contextCache;a.push(b);return null};sc_require("core");sc_require("ext/function");sc_require("system/enumerator");SC.Enumerable={isEnumerable:YES,nextObject:function(a,c,b){return this.objectAt?this.objectAt(a):this[a]},firstObject:function(){if(this.get("length")===0){return undefined}if(this.objectAt){return this.objectAt(0)}var b=SC.Enumerator._popContext(),a;a=this.nextObject(0,null,b);b=SC.Enumerator._pushContext(b);return a}.property().cacheable(),lastObject:function(){var a=this.get("length");if(a===0){return undefined}if(this.objectAt){return this.objectAt(a-1)}}.property().cacheable(),enumerator:function(){return SC.Enumerator.create(this)},forEach:function(g,f){if(typeof g!=="function"){throw new TypeError()}var b=this.get?this.get("length"):this.length;if(f===undefined){f=null}var e=null;var c=SC.Enumerator._popContext();for(var a=0;a<b;a++){var d=this.nextObject(a,e,c);g.call(f,d,a,this);e=d}e=null;c=SC.Enumerator._pushContext(c);return this},getEach:function(a){return this.map(function(b){return b?(b.get?b.get(a):b[a]):null},this)},setEach:function(a,b){this.forEach(function(c){if(c){if(c.set){c.set(a,b)}else{c[a]=b}}},this);return this},map:function(h,g){if(typeof h!=="function"){throw new TypeError()}var b=this.get?this.get("length"):this.length;if(g===undefined){g=null}var c=[];var f=null;var d=SC.Enumerator._popContext();for(var a=0;a<b;a++){var e=this.nextObject(a,f,d);c[a]=h.call(g,e,a,this);f=e}f=null;d=SC.Enumerator._pushContext(d);return c},mapProperty:function(a){return this.map(function(b){return b?(b.get?b.get(a):b[a]):null})},filter:function(h,g){if(typeof h!=="function"){throw new TypeError()}var b=this.get?this.get("length"):this.length;if(g===undefined){g=null}var c=[];var f=null;var d=SC.Enumerator._popContext();for(var a=0;a<b;a++){var e=this.nextObject(a,f,d);if(h.call(g,e,a,this)){c.push(e)}f=e}f=null;d=SC.Enumerator._pushContext(d);return c},sortProperty:function(b){var c=(typeof b===SC.T_STRING)?arguments:b,a=c.length,d;if(this instanceof Array){d=this}else{d=[];this.forEach(function(e){d.push(e)})}if(!d){return[]}return d.sort(function(g,f){var e,i,k,j,h=0;for(e=0;h===0&&e<a;e++){i=c[e];k=g?(g.get?g.get(i):g[i]):null;j=f?(f.get?f.get(i):f[i]):null;h=SC.compare(k,j)}return h})},filterProperty:function(h,d){var b=this.get?this.get("length"):this.length,c=[],g=null,a=SC.Enumerator._popContext(),e,i,f;if(d===undefined){for(e=0;e<b;e++){i=this.nextObject(e,g,a);f=i?(i.get?i.get(h):i[h]):null;if(!!f){c.push(i)}g=i}}else{for(e=0;e<b;e++){i=this.nextObject(e,g,a);f=i?(i.get?i.get(h):i[h]):null;if(SC.isEqual(f,d)){c.push(i)}g=i}}g=null;a=SC.Enumerator._pushContext(a);return c},find:function(h,d){var c=this.get?this.get("length"):this.length;if(d===undefined){d=null}var g=null,b,i=NO,e=null;var a=SC.Enumerator._popContext();for(var f=0;f<c&&!i;f++){b=this.nextObject(f,g,a);if(i=h.call(d,b,f,this)){e=b}g=b}b=g=null;a=SC.Enumerator._pushContext(a);return e},findProperty:function(i,f){var c=this.get?this.get("length"):this.length;var j=NO,d=null,h=null,b,g;var a=SC.Enumerator._popContext();for(var e=0;e<c&&!j;e++){b=this.nextObject(e,h,a);g=b?(b.get?b.get(i):b[i]):null;j=(f===undefined)?!!g:SC.isEqual(g,f);if(j){d=b}h=b}h=b=null;a=SC.Enumerator._pushContext(a);return d},every:function(h,g){if(typeof h!=="function"){throw new TypeError()}var b=this.get?this.get("length"):this.length;if(g===undefined){g=null}var c=YES;var f=null;var d=SC.Enumerator._popContext();for(var a=0;c&&(a<b);a++){var e=this.nextObject(a,f,d);if(!h.call(g,e,a,this)){c=NO}f=e}f=null;d=SC.Enumerator._pushContext(d);return c},everyProperty:function(i,e){var c=this.get?this.get("length"):this.length;var d=YES;var h=null;var a=SC.Enumerator._popContext();for(var f=0;d&&(f<c);f++){var b=this.nextObject(f,h,a);var g=b?(b.get?b.get(i):b[i]):null;d=(e===undefined)?!!g:SC.isEqual(g,e);h=b}h=null;a=SC.Enumerator._pushContext(a);return d},some:function(h,g){if(typeof h!=="function"){throw new TypeError()}var b=this.get?this.get("length"):this.length;if(g===undefined){g=null}var c=NO;var f=null;var d=SC.Enumerator._popContext();for(var a=0;(!c)&&(a<b);a++){var e=this.nextObject(a,f,d);if(h.call(g,e,a,this)){c=YES}f=e}f=null;d=SC.Enumerator._pushContext(d);return c},someProperty:function(i,e){var c=this.get?this.get("length"):this.length;var d=NO;var h=null;var a=SC.Enumerator._popContext();for(var f=0;!d&&(f<c);f++){var b=this.nextObject(f,h,a);var g=b?(b.get?b.get(i):b[i]):null;d=(e===undefined)?!!g:SC.isEqual(g,e);h=b}h=null;a=SC.Enumerator._pushContext(a);return d},reduce:function(g,h,i){if(typeof g!=="function"){throw new TypeError()}var c=this.get?this.get("length"):this.length;if(c===0&&h===undefined){throw new TypeError()}var d=h;var f=null;var a=SC.Enumerator._popContext();for(var e=0;e<c;e++){var b=this.nextObject(e,f,a);if(b!==null){if(d===undefined){d=b}else{d=g.call(null,d,b,e,this,i)}}f=b}f=null;a=SC.Enumerator._pushContext(a);if(d===undefined){throw new TypeError()}return d},invoke:function(h){var e=this.get?this.get("length"):this.length;if(e<=0){return[]}var i;var g=[];var c=arguments.length;if(c>1){for(i=1;i<c;i++){g.push(arguments[i])}}var f=[];var j=null;var b=SC.Enumerator._popContext();for(i=0;i<e;i++){var d=this.nextObject(i,j,b);var a=d?d[h]:null;if(a){f[i]=a.apply(d,g)}j=d}j=null;b=SC.Enumerator._pushContext(b);return f},invokeWhile:function(d,i){var f=this.get?this.get("length"):this.length;if(f<=0){return null}var j;var h=[];var c=arguments.length;if(c>2){for(j=2;j<c;j++){h.push(arguments[j])}}var g=d;var k=null;var b=SC.Enumerator._popContext();for(j=0;(g===d)&&(j<f);j++){var e=this.nextObject(j,k,b);var a=e?e[i]:null;if(a){g=a.apply(e,h)}k=e}k=null;b=SC.Enumerator._pushContext(b);return g},toArray:function(){var a=[];this.forEach(function(b){a.push(b)},this);return a},groupBy:function(i){var c=this.get?this.get("length"):this.length,d=[],h=null,a=SC.Enumerator._popContext(),e=[],j=[],f,b,g;for(f=0;f<c;f++){b=this.nextObject(f,h,a);g=b?(b.get?b.get(i):b[i]):null;if(SC.none(e[g])){e[g]=[];j.push(g)}e[g].push(b);h=b}h=null;a=SC.Enumerator._pushContext(a);for(f=0,c=j.length;f<c;f++){d.push(e[j[f]])}return d}};SC._buildReducerFor=function(a,b){return function(d,e){var f=this[a];if(SC.typeOf(f)!==SC.T_FUNCTION){return this.unknownProperty?this.unknownProperty(d,e):null}else{var c=SC.Enumerable.reduce.call(this,f,null,b);return c}}.property("[]")};SC.Reducers={"[]":function(a,b){return this}.property(),enumerableContentDidChange:function(c,a,b){if(!SC.none(c)){if(c===0){this.notifyPropertyChange("firstObject")}if(!SC.none(a)&&c+a>=this.get("length")-1){this.notifyPropertyChange("lastObject")}}this.notifyPropertyChange("[]")},reducedProperty:function(i,g,f){if(!i||typeof i!==SC.T_STRING||i.charAt(0)!=="@"){return undefined}var d=i.match(/^@([^(]*)(\(([^)]*)\))?$/);if(!d||d.length<2){return undefined}var h=d[1];var j=d[3];h="reduce"+h.slice(0,1).toUpperCase()+h.slice(1);var a=this[h];if(SC.typeOf(a)!==SC.T_FUNCTION){return undefined}if(f===NO){return SC.Enumerable.reduce.call(this,a,null,j)}var c=SC._buildReducerFor(h,j);var b=this.constructor.prototype;if(b){b[i]=c;var e=b._properties||[];e.push(i);b._properties=e;this.registerDependentKey(i,"[]")}return SC.Enumerable.reduce.call(this,a,null,j)},reduceMax:function(a,d,b,f,c){if(c&&d){d=d.get?d.get(c):d[c]}if(a===null){return d}return(d>a)?d:a},reduceMaxObject:function(b,f,c,g,d){var a=b,h=f;if(d){if(f){h=f.get?f.get(d):f[d]}if(b){a=b.get?b.get(d):b[d]}}if(a===null){return f}return(h>a)?f:b},reduceMin:function(a,d,b,f,c){if(c&&d){d=d.get?d.get(c):d[c]}if(a===null){return d}return(d<a)?d:a},reduceMinObject:function(b,f,c,g,d){var a=b,h=f;if(d){if(f){h=f.get?f.get(d):f[d]}if(b){a=b.get?b.get(d):b[d]}}if(a===null){return f}return(h<a)?f:b},reduceAverage:function(b,g,d,h,f){if(f&&g){g=g.get?g.get(f):g[f]}var c=(b||0)+g;var a=h.get?h.get("length"):h.length;if(d>=a-1){c=c/a}return c},reduceSum:function(a,d,b,f,c){if(c&&d){d=d.get?d.get(c):d[c]}return(a===null)?d:a+d}};SC.mixin(SC.Enumerable,SC.Reducers);SC.mixin(Array.prototype,SC.Reducers);Array.prototype.isEnumerable=YES;(function(){var a={nextObject:SC.Enumerable.nextObject,enumerator:SC.Enumerable.enumerator,firstObject:SC.Enumerable.firstObject,lastObject:SC.Enumerable.lastObject,sortProperty:SC.Enumerable.sortProperty,mapProperty:function(g){var e=this.length;var f=[];for(var d=0;d<e;d++){var h=this[d];f[d]=h?(h.get?h.get(g):h[g]):null}return f},filterProperty:function(g,i){var e=this.length,f=[],d,h,j;if(i===undefined){for(d=0;d<e;d++){h=this[d];j=h?(h.get?h.get(g):h[g]):null;if(!!j){f.push(h)}}}else{for(d=0;d<e;d++){h=this[d];j=h?(h.get?h.get(g):h[g]):null;if(SC.isEqual(j,i)){f.push(h)}}}return f},groupBy:function(h){var e=this.length,g=[],j=[],f=[],d,i,k;for(d=0;d<e;d++){i=this[d];k=i?(i.get?i.get(h):i[h]):null;if(SC.none(j[k])){j[k]=[];f.push(k)}j[k].push(i)}for(d=0,e=f.length;d<e;d++){g.push(j[f[d]])}return g},find:function(j,i){if(typeof j!=="function"){throw new TypeError()}var e=this.length;if(i===undefined){i=null}var g,f=null,h=NO;for(var d=0;d<e&&!h;d++){g=this[d];if(h=j.call(i,g,d,this)){f=g}}g=null;return f},findProperty:function(g,j){var e=this.length;var h,k,i=NO,f=null;for(var d=0;d<e&&!i;d++){k=(h=this[d])?(h.get?h.get(g):h[g]):null;i=(j===undefined)?!!k:SC.isEqual(k,j);if(i){f=h}}h=null;return f},everyProperty:function(g,i){var e=this.length;var f=YES;for(var d=0;f&&(d<e);d++){var h=this[d];var j=h?(h.get?h.get(g):h[g]):null;f=(i===undefined)?!!j:SC.isEqual(j,i)}return f},someProperty:function(g,i){var e=this.length;var f=NO;for(var d=0;!f&&(d<e);d++){var h=this[d];var j=h?(h.get?h.get(g):h[g]):null;f=(i===undefined)?!!j:SC.isEqual(j,i)}return f},invoke:function(f){var e=this.length;if(e<=0){return[]}var d;var h=[];var j=arguments.length;if(j>1){for(d=1;d<j;d++){h.push(arguments[d])}}var g=[];for(d=0;d<e;d++){var i=this[d];var k=i?i[f]:null;if(k){g[d]=k.apply(i,h)}}return g},invokeWhile:function(f,k){var h=this.length;if(h<=0){return null}var l;var j=[];var e=arguments.length;if(e>2){for(l=2;l<e;l++){j.push(arguments[l])}}var i=f;for(l=0;(i===f)&&(l<h);l++){var g=this[l];var d=g?g[k]:null;if(d){i=d.apply(g,j)}}return i},toArray:function(){var e=this.length;if(e<=0){return[]}var f=[];for(var d=0;d<e;d++){var g=this[d];f.push(g)}return f},getEach:function(g){var f=[];var e=this.length;for(var d=0;d<e;d++){var h=this[d];f[d]=h?(h.get?h.get(g):h[g]):null}return f},setEach:function(f,g){var e=this.length;for(var d=0;d<e;d++){var h=this[d];if(h){if(h.set){h.set(f,g)}else{h[f]=g}}}return this}};var c={forEach:function(h,g){if(typeof h!=="function"){throw new TypeError()}if(g===undefined){g=null}for(var e=0,d=this.length;e<d;e++){var f=this[e];h.call(g,f,e,this)}return this},map:function(j,h){if(typeof j!=="function"){throw new TypeError()}if(h===undefined){h=null}var e=[];for(var f=0,d=this.length;f<d;f++){var g=this[f];e[f]=j.call(h,g,f,this)}return e},filter:function(j,h){if(typeof j!=="function"){throw new TypeError()}if(h===undefined){h=null}var e=[];for(var f=0,d=this.length;f<d;f++){var g=this[f];if(j.call(h,g,f,this)){e.push(g)}}return e},every:function(i,h){if(typeof i!=="function"){throw new TypeError()}var e=this.length;if(h===undefined){h=null}var f=YES;for(var d=0;f&&(d<e);d++){var g=this[d];if(!i.call(h,g,d,this)){f=NO}}return f},some:function(i,h){if(typeof i!=="function"){throw new TypeError()}var e=this.length;if(h===undefined){h=null}var f=NO;for(var d=0;(!f)&&(d<e);d++){var g=this[d];if(i.call(h,g,d,this)){f=YES}}return f},reduce:function(j,f,i){if(typeof j!=="function"){throw new TypeError()}var e=this.length;if(e===0&&f===undefined){throw new TypeError()}var g=f;for(var d=0;d<e;d++){var h=this[d];if(h!==null){if(g===undefined){g=h}else{g=j.call(null,g,h,d,this,i)}}}if(g===undefined){throw new TypeError()}return g}};for(var b in c){if(!c.hasOwnProperty(b)){continue}if(!Array.prototype[b]||((typeof Prototype==="object")&&Prototype.Version.match(/^1\.6/))){Array.prototype[b]=c[b]}}SC.mixin(Array.prototype,a)})();SC.RangeObserver={isRangeObserver:YES,toString:function(){var a=this.indexes?this.indexes.toString():"SC.IndexSet<..>";return a.replace("IndexSet","RangeObserver(%@)".fmt(SC.guidFor(this)))},create:function(d,f,e,g,c,a){var b=SC.beget(this);b.source=d;b.indexes=f?f.frozenCopy():null;b.target=e;b.method=(typeof g==="string")?e[g]:g;b.context=c;b.isDeep=a||false;b.beginObserving();return b},extend:function(d){var c=SC.beget(this),b=arguments;for(var e=0,a=b.length;e<a;e++){SC.mixin(c,b[e])}return c},destroy:function(a){this.endObserving();return this},update:function(a,b){if(this.indexes&&this.indexes.isEqual(b)){return this}this.indexes=b?b.frozenCopy():null;this.endObserving().beginObserving();return this},beginObserving:function(){if(!this.isDeep){return this}var c=this.observing=this.observing||SC.CoreSet.create();var a=this._beginObservingForEach,b=this.source;if(!a){a=this._beginObservingForEach=function(d){var e=b.objectAt(d);if(e&&e.addObserver){c.push(e);e._kvo_needsRangeObserver=true}}}this.indexes.forEach(a);this.isObserving=false;SC.Observers.addPendingRangeObserver(this);return this},setupPending:function(b){var e=this.observing;if(this.isObserving||!e||(e.get("length")===0)){return true}if(e.contains(b)){this.isObserving=true;var c=this._setupPendingForEach;if(!c){var d=this.source,f=this.objectPropertyDidChange,a=this;c=this._setupPendingForEach=function(g){var j=d.objectAt(g),h=SC.guidFor(j),i;if(j&&j.addObserver){e.push(j);j.addObserver("*",a,f);i=a[h];if(i==null){a[h]=g}else{if(i.isIndexSet){i.add(g)}else{a[h]=SC.IndexSet.create(i).add(g)}}}}}this.indexes.forEach(c);return true}else{return false}},endObserving:function(){if(!this.isDeep){return this}var e=this.observing;if(this.isObserving){var b=this.objectPropertyDidChange,c=this.source,a,f,d;if(e){f=e.length;for(a=0;a<f;a++){d=e[a];d.removeObserver("*",this,b);this[SC.guidFor(d)]=null}e.length=0}this.isObserving=false}if(e){e.clear()}return this},rangeDidChange:function(b){var a=this.indexes;if(!b||!a||a.intersects(b)){this.endObserving();this.method.call(this.target,this.source,null,"[]",b,this.context);this.beginObserving()}return this},objectPropertyDidChange:function(d,f,g,a){var e=this.context,h=this.method,c=SC.guidFor(d),b=this[c];if(b&&!b.isIndexSet){b=this[c]=SC.IndexSet.create(b).freeze()}h.call(this.target,this.source,d,f,b,e||a,a)}};sc_require("ext/function");sc_require("mixins/observable");sc_require("mixins/enumerable");sc_require("system/range_observer");SC.OUT_OF_RANGE_EXCEPTION="Index out of range";SC.CoreArray={isSCArray:YES,replace:function(a,c,b){throw new Error("replace() must be implemented to support SC.Array")},indexOf:function(d,c){var b,a=this.get("length");if(c===undefined){c=0}else{c=(c<0)?Math.ceil(c):Math.floor(c)}if(c<0){c+=a}for(b=c;b<a;b++){if(this.objectAt(b,YES)===d){return b}}return -1},lastIndexOf:function(d,c){var b,a=this.get("length");if(c===undefined){c=a-1}else{c=(c<0)?Math.ceil(c):Math.floor(c)}if(c<0){c+=a}for(b=c;b>=0;b--){if(this.objectAt(b)===d){return b}}return -1},objectAt:function(a){if(a<0){return undefined}if(a>=this.get("length")){return undefined}return this.get(a)},"[]":function(a,b){if(b!==undefined){this.replace(0,this.get("length"),b)}return this}.property(),insertAt:function(a,b){if(a>this.get("length")){throw new Error(SC.OUT_OF_RANGE_EXCEPTION)}this.replace(a,0,[b]);return this},removeAt:function(d,a){var c=0,b=[];if(typeof d===SC.T_NUMBER){if((d<0)||(d>=this.get("length"))){throw new Error(SC.OUT_OF_RANGE_EXCEPTION)}if(a===undefined){this.replace(d,1,b);return this}else{d=SC.IndexSet.create(d,a)}}this.beginPropertyChanges();d.forEachRange(function(f,e){f-=c;c+=e;this.replace(f,e,b)},this);this.endPropertyChanges();return this},removeObject:function(b){var c=this.get("length")||0;while(--c>=0){var a=this.objectAt(c);if(a===b){this.removeAt(c)}}return this},removeObjects:function(a){this.beginPropertyChanges();a.forEach(function(b){this.removeObject(b)},this);this.endPropertyChanges();return this},slice:function(b,d){var a=[];var c=this.get("length");if(SC.none(b)){b=0}if(SC.none(d)||(d>c)){d=c}while(b<d){a[a.length]=this.objectAt(b++)}return a},pushObject:function(a){this.insertAt(this.get("length"),a);return a},pushObjects:function(a){this.beginPropertyChanges();a.forEach(function(b){this.pushObject(b)},this);this.endPropertyChanges();return this},popObject:function(){var a=this.get("length");if(a===0){return null}var b=this.objectAt(a-1);this.removeAt(a-1);return b},shiftObject:function(){if(this.get("length")===0){return null}var a=this.objectAt(0);this.removeAt(0);return a},unshiftObject:function(a){this.insertAt(0,a);return a},unshiftObjects:function(a){this.beginPropertyChanges();a.forEach(function(b){this.unshiftObject(b)},this);this.endPropertyChanges();return this},isEqual:function(a){if(!a){return false}if(a==this){return true}var b=a.get("length");if(b!=this.get("length")){return false}while(--b>=0){if(!SC.isEqual(a.objectAt(b),this.objectAt(b))){return false}}return true},compact:function(){return this.without(null)},without:function(b){if(this.indexOf(b)<0){return this}var a=[];this.forEach(function(c){if(c!==b){a[a.length]=c}});return a},uniq:function(){var a=[];this.forEach(function(b){if(a.indexOf(b)<0){a[a.length]=b}});return a},flatten:function(){var a=[];this.forEach(function(b){if(b&&b.isEnumerable){a=a.pushObjects(b.flatten())}else{a.pushObject(b)}});return a},max:function(){return Math.max.apply(Math,this)},min:function(){return Math.min.apply(Math,this)},rangeObserverClass:SC.RangeObserver,contains:function(a){return this.indexOf(a)>=0},addRangeObserver:function(d,f,h,e){var a=this._array_rangeObservers;if(!a){a=this._array_rangeObservers=SC.CoreSet.create()}if(this._array_oldLength===undefined){this._array_oldLength=this.get("length")}var g=this.rangeObserverClass;var b=NO;var c=g.create(this,d,f,h,e,b);a.add(c);if(!this._array_isNotifyingRangeObservers){this._array_isNotifyingRangeObservers=YES;this.addObserver("[]",this,this._array_notifyRangeObservers)}return c},updateRangeObserver:function(b,a){return b.update(this,a)},removeRangeObserver:function(c){var b=c.destroy(this);var a=this._array_rangeObservers;if(a){a.remove(c)}return b},addArrayObservers:function(a){this._modifyObserverSet("add",a)},removeArrayObservers:function(a){this._modifyObserverSet("remove",a)},_modifyObserverSet:function(h,c){var e,b;var g=c.target||this;var a=c.willChange||"arrayWillChange";var f=c.didChange||"arrayDidChange";var d=c.context;if(typeof a==="string"){a=g[a]}if(typeof f==="string"){f=g[f]}e=this._kvo_for("_kvo_array_will_change",SC.ObserverSet);b=this._kvo_for("_kvo_array_did_change",SC.ObserverSet);e[h](g,a,d);b[h](g,f,d)},arrayContentWillChange:function(b,i,a){this._teardownContentObservers(b,i);var f,d,h,j;var g,c;var e=this._kvo_array_will_change;if(e){d=e.members;h=d.length;for(j=0;j<h;j++){f=d[j];g=f[0];c=f[1];c.call(g,b,i,a,this)}}},arrayContentDidChange:function(b,m,a){var d=this._array_rangeObservers,c,k;this.beginPropertyChanges();this.notifyPropertyChange("length");if(d&&d.length>0){k=this._array_rangeChanges;if(!k){k=this._array_rangeChanges=SC.IndexSet.create()}if(m===a){c=m}else{c=this.get("length")-b;if(m>a){c+=(m-a)}}k.add(b,c)}this._setupContentObservers(b,a);var g,f,j,l;var h,e;var i=this._kvo_array_did_change;if(i){if(b===undefined){b=0;m=this.get("length");a=0}f=i.members;j=f.length;for(l=0;l<j;l++){g=f[l];h=g[0];e=g[1];e.call(h,b,m,a,this)}}this.enumerableContentDidChange(b,a,a-m);this.endPropertyChanges();return this},_setupContentObservers:function(f,e){var c=this._kvo_for("_kvo_content_observed_keys",SC.CoreSet);var d;var b;if(c.get("length")>0){d=this.slice(f,f+e);var a=this;c.forEach(function(g){b=SC.keyFor("_kvo_content_observers",g);a._kvo_for(b).forEach(function(h){d.forEach(function(i){a._resumeChainObservingForItemWithChainObserver(i,h)})})})}},_teardownContentObservers:function(e,a){var c=this._kvo_for("_kvo_content_observed_keys",SC.CoreSet);var d;var b;if(c.get("length")>0){d=this.slice(e,e+a);c.forEach(function(f){b=SC.keyFor("_kvo_content_observers",f);d.forEach(function(g){g._kvo_for(b).forEach(function(h){h.destroyChain()})})})}},teardownEnumerablePropertyChains:function(b){var a=this._kvo_enumerable_property_chains;if(a){a.forEach(function(g){var d,c=b.get("length"),i=SC.guidFor(g),f,h,e="_kvo_enumerable_property_clones";g.notifyPropertyDidChange();for(d=0;d<c;d++){h=b.objectAt(d);f=h[e][i];f.deactivate();delete h[e][i]}},this)}return this},setupEnumerablePropertyChains:function(b){var a=this._kvo_enumerable_property_chains;if(a){a.forEach(function(e){var d,c=b.get("length");e.notifyPropertyDidChange();c=b.get("length");for(d=0;d<c;d++){this._clonePropertyChainToItem(e,b.objectAt(d))}},this)}return this},registerDependentKeyWithChain:function(c,b){var a="_kvo_enumerable_property_chains",d;d=this._kvo_for(a,SC.CoreSet);d.add(b);this.forEach(function(e){this._clonePropertyChainToItem(b,e)},this)},_clonePropertyChainToItem:function(c,d){var e=SC.clone(c),b="_kvo_enumerable_property_clones",a;e.object=d;a=d[b]=d[b]||{};a[SC.guidFor(c)]=e;e.activate(d)},removeDependentKeyWithChain:function(d,c){var b="_kvo_enumerable_property_clones",e,a;this.forEach(function(f){f.removeDependentKeyWithChain(d,c);a=f[b];e=a[SC.guidFor(c)];e.deactivate(f)},this)},_resumeChainObservingForItemWithChainObserver:function(d,a){var b=SC.clone(a.next);var c=b.property;b.object=d;d.addObserver(c,b,b.propertyDidChange);if(a.root.tails){a.root.tails.pushObject(b.tail())}d._kvo_for(SC.keyFor("_kvo_content_observers",c)).push(b)},_addContentObserver:function(a){var c=a.next.property;this._kvo_for("_kvo_content_observed_keys",SC.CoreSet).push(c);var d=SC.keyFor("_kvo_content_observers",c);this._kvo_for(d).push(a);var b=a.tail();this.addObserver("[]",b,b.propertyDidChange);this._setupContentObservers(0,a.object.get("length"))},_removeContentObserver:function(a){var f,d;var e=this._kvo_content_observed_keys;var c=a.next.property;var b=a.tail();this.removeObserver("[]",b,b.propertyDidChange);if(e.contains(c)){d=SC.keyFor("_kvo_content_observers",c);f=this._kvo_for(d);f.removeObject(a);this._teardownContentObservers(0,a.object.get("length"));if(f.length===0){this._kvo_for("_kvo_content_observed_keys").remove(c)}}},_array_notifyRangeObservers:function(){var c=this._array_rangeObservers,d=this._array_rangeChanges,b=c?c.length:0,a;if(b>0&&d&&d.length>0){for(a=0;a<b;a++){c[a].rangeDidChange(d)}d.clear()}}};SC.Array=SC.mixin({},SC.Enumerable,SC.CoreArray);sc_require("mixins/array");SC.supplement(Array.prototype,SC.CoreArray);SC.mixin(Array.prototype,{replace:function(b,e,d){if(this.isFrozen){throw new Error(SC.FROZEN_ERROR)}var c;var a=d?(d.get?d.get("length"):d.length):0;this.arrayContentWillChange(b,e,a);if(a===0){this.splice(b,e)}else{c=[b,e].concat(d);this.splice.apply(this,c)}this.arrayContentDidChange(b,e,a);return this},unknownProperty:function(b,c){var a=this.reducedProperty(b,c);if((c!==undefined)&&a===undefined){a=this[b]=c}return a}});if(Array.prototype.indexOf===SC.CoreArray.indexOf){Array.prototype.indexOf=function(d,c){var b,a=this.length;if(c===undefined){c=0}else{c=(c<0)?Math.ceil(c):Math.floor(c)}if(c<0){c+=a}for(b=c;b<a;b++){if(this[b]===d){return b}}return -1}}if(Array.prototype.lastIndexOf===SC.CoreArray.lastIndexOf){Array.prototype.lastIndexOf=function(d,c){var b,a=this.length;if(c===undefined){c=a-1}else{c=(c<0)?Math.ceil(c):Math.floor(c)}if(c<0){c+=a}for(b=c;b>=0;b--){if(this[b]===d){return b}}return -1}}if(!Date.now){Date.now=function(){return new Date().getTime()}}SC.supplement(Number.prototype,{ordinal:function(){if(SC.Locale){return SC.Locale.currentLocale.ordinalForNumber(this)}var a=this%10;return(~~(this%100/10)===1)?"th":(a===1)?"st":(a===2)?"nd":(a===3)?"rd":"th"}});SC.String={_scs_valueForKey:function(e,g,c){var a,f,d,b=e.indexOf(":");if(b>-1){a=e.substr(b+1);e=e.substr(0,b)}f=g.get?g.get(e):g[e];d=g[e+"Formatter"];if(d){f=d(f,a)}else{if(a){throw new Error("String.fmt was given a formatting string, but key `"+e+"` has no formatter! String: "+c)}}return f},fmt:function(b,a){var c=0,d,e;if(a){d=a[0]}return b.replace(/%\{(.*?)\}/g,function(g,h){e=YES;if(!d){throw new Error("Cannot use named parameters with `fmt` without a data hash. String: '"+b+"'")}var f=SC.String._scs_valueForKey(h,d,b);if(!SC.none(f)){return f}else{return g}}).replace(/%@([0-9]+)?/g,function(g,f){if(e){throw new Error("Invalid attempt to use both named parameters and indexed parameters. String: '"+b+"'")}f=f?parseInt(f,10)-1:c++;if(a[f]!==undefined){return a[f]}else{return""}})},w:function(f){var d=[],e=f.split(" "),b=e.length,c,a=0;for(a=0;a<b;++a){c=e[a];if(c.length!==0){d.push(c)}}return d}};sc_require("system/string");SC.mixin(String.prototype,{fmt:function(){return SC.String.fmt(this,arguments)},w:function(){return SC.String.w(this)}});(function(){if(window&&typeof window.performance==="undefined"){window.performance={}}if(window&&!window.performance.now){var a;if(window.performance.timing&&window.performance.timing.navigationStart){a=window.performance.timing.navigationStart}else{window.performance.timing={};a=window.performance.timing.navigationStart=Date.now?Date.now():(new Date()).getTime()}window.performance.now=function(){var b=Date.now?Date.now():(new Date()).getTime();return b-a}}})();SC.Comparable={isComparable:YES,compare:function(d,c){throw new Error("%@.compare() is not implemented".fmt(this.toString()))}};SC.Copyable={isCopyable:YES,copy:function(a){var b=SC._object_className(this.constructor);throw new Error("%@.copy() is not implemented".fmt(b))},frozenCopy:function(){var a=this.get?this.get("isFrozen"):this.isFrozen;if(a===YES){return this}else{if(a===undefined){throw new Error("%@ does not support freezing".fmt(this))}else{return this.copy().freeze()}}}};SC.mixin(Array.prototype,SC.Copyable);Array.prototype.copy=function(b){var c=this.slice(),a;if(b){a=c.length;while(a--){c[a]=SC.copy(c[a],true)}}return c};SC.FROZEN_ERROR="Cannot modify a frozen object";SC.Freezable={isFreezable:YES,isFrozen:NO,freeze:function(){if(this.set){this.set("isFrozen",YES)}else{this.isFrozen=YES}return this}};SC.mixin(Array.prototype,SC.Freezable);SC.Tree={invoke:function(b,a,d){var h,f=this.get("childViews"),g,e;for(var c=f.length-1;c>=0;c--){h=f[c];if(!h){continue}g=h[b];if(a===undefined||a){e=g.call(h,d)}if(e===undefined||e){h._callOnChildViews(b,a,d)}if(a===false){g.call(h,d)}}}};sc_require("mixins/enumerable");sc_require("mixins/observable");sc_require("mixins/freezable");sc_require("mixins/copyable");SC.Set=SC.mixin({},SC.Observable,SC.Enumerable,SC.Freezable,{create:function(c){var d,b,e=SC.Set._pool,f=this.isObservable,a;if(!f&&c===undefined&&e.length>0){return e.pop()}else{d=SC.beget(this);if(f){d.initObservable()}if(c&&c.isEnumerable&&c.get("length")>0){d.isObservable=NO;if(c.isSCArray){a=c.get("length");for(b=0;b<a;b++){d.add(c.objectAt(b))}}else{if(c.isSet){a=c.length;for(b=0;b<a;b++){d.add(c[b])}}else{c.forEach(function(g){d.add(g)},this)}}d.isObservable=f}}return d},isSet:YES,length:0,firstObject:function(){return(this.length>0)?this[0]:undefined}.property(),clear:function(){if(this.isFrozen){throw new Error(SC.FROZEN_ERROR)}this.length=0;return this},contains:function(b){if(b===null){return NO}var a=this[SC.hashFor(b)];return(!SC.none(a)&&(a<this.length)&&(this[a]===b))},isEqual:function(a){if(!a||!a.isSet||(a.get("length")!==this.get("length"))){return NO}var b=this.get("length");while(--b>=0){if(!a.contains(this[b])){return NO}}return YES},addSetObserver:function(a){if(!this.setObservers){this.setObservers=SC.CoreSet.create()}this.setObservers.add(a)},removeSetObserver:function(a){if(!this.setObservers){return}this.setObservers.remove(a)},add:function(e){if(this.isFrozen){throw new Error(SC.FROZEN_ERROR)}if(e===null||e===undefined){return this}var c,d=((c=e.hash)&&(typeof c==="function"))?c.call(e):SC.guidFor(e),b=this[d],a=this.length;if((b>=a)||(this[b]!==e)){this[a]=e;this[d]=a;this.length=a+1;if(this.setObservers){this.didAddItem(e)}}if(this.isObservable){this.enumerableContentDidChange()}return this},addEach:function(c){if(this.isFrozen){throw new Error(SC.FROZEN_ERROR)}if(!c||!c.isEnumerable){throw new Error("%@.addEach must pass enumerable".fmt(this))}var a,b=this.isObservable;if(b){this.beginPropertyChanges()}if(c.isSCArray){a=c.get("length");while(--a>=0){this.add(c.objectAt(a))}}else{if(c.isSet){a=c.length;while(--a>=0){this.add(c[a])}}else{c.forEach(function(d){this.add(d)},this)}}if(b){this.endPropertyChanges()}return this},remove:function(f){if(this.isFrozen){throw new Error(SC.FROZEN_ERROR)}if(f===null||f===undefined){return this}var c,d=(f&&(c=f.hash)&&(typeof c===SC.T_FUNCTION))?c.call(f):SC.guidFor(f),b=this[d],a=this.length,e;if((b===null||b===undefined)||(b>=a)||(this[b]!==f)){return this}delete this[d];if(b<(a-1)){e=this[b]=this[a-1];d=(e&&(c=e.hash)&&(typeof c===SC.T_FUNCTION))?c.call(e):SC.guidFor(e);this[d]=b}delete this[a-1];this.length=a-1;if(this.isObservable){this.enumerableContentDidChange()}if(this.setObservers){this.didRemoveItem(f)}return this},pop:function(){if(this.isFrozen){throw new Error(SC.FROZEN_ERROR)}var a=(this.length>0)?this[this.length-1]:null;this.remove(a);return a},removeEach:function(c){if(this.isFrozen){throw new Error(SC.FROZEN_ERROR)}if(!c||!c.isEnumerable){throw new Error("%@.addEach must pass enumerable".fmt(this))}var a,b=this.isObservable;if(b){this.beginPropertyChanges()}if(c.isSCArray){a=c.get("length");while(--a>=0){this.remove(c.objectAt(a))}}else{if(c.isSet){a=c.length;while(--a>=0){this.remove(c[a])}}else{c.forEach(function(d){this.remove(d)},this)}}if(b){this.endPropertyChanges()}return this},copy:function(){return this.constructor.create(this)},destroy:function(){this.isFrozen=NO;if(!this.isObservable){SC.Set._pool.push(this.clear())}return this},forEach:function(c,d){var b=this.length;if(!d){d=this}for(var a=0;a<b;a++){c.call(d,this[a],a,this)}return this},toString:function(){var b=this.length,a,c=[];for(a=0;a<b;a++){c[a]=this[a]}return"SC.Set<%@>".fmt(c.join(","))},didAddItem:function(c){var d=this.setObservers;if(!d){return}var b=d.length,a;for(a=0;a<b;a++){d[a].didAddItem(this,c)}},didRemoveItem:function(c){var d=this.setObservers;if(!d){return}var b=d.length,a;for(a=0;a<b;a++){d[a].didRemoveItem(this,c)}},isObservable:YES});SC.Set.constructor=SC.Set;SC.Set.clone=SC.Set.copy;SC.Set.push=SC.Set.unshift=SC.Set.add;SC.Set.shift=SC.Set.pop;SC.Set.addObject=SC.Set.add;SC.Set.removeObject=SC.Set.remove;SC.Set._pool=[];SC.CoreSet=SC.beget(SC.Set);SC.CoreSet.isObservable=NO;SC.CoreSet.constructor=SC.CoreSet;sc_require("mixins/observable");sc_require("system/set");SC.Observers={queue:[],addObserver:function(c,d,e,b){var a;if(typeof c==="string"){a=SC.tupleForPropertyPath(c,b)}else{a=c}if(a&&a[0].addObserver){a[0].addObserver(a[1],d,e)}else{this.queue.push([c,d,e,b])}},removeObserver:function(c,e,a,b){var h,d,f,i;f=SC.tupleForPropertyPath(c,b);if(f){f[0].removeObserver(f[1],e,a)}h=this.queue.length;d=this.queue;var g;while(--h>=0){i=d[h];if(i[0]!==c||i[1]!==e||i[2]!==a||i[3]!==b){if(!g){g=[]}g.push(i)}}this.queue=g||this.queue},addPendingRangeObserver:function(a){var b=this.rangeObservers;if(!b){b=this.rangeObservers=SC.CoreSet.create()}b.add(a);return this},_TMP_OUT:[],flush:function(b){var g=this.queue,d,a=g.length;if(g&&a>0){var k=(this.queue=[]);for(d=0;d<a;d++){var l=g[d];if(!l){continue}var h=SC.tupleForPropertyPath(l[0],l[3]);if(h&&h[0].addObserver){h[0].addObserver(h[1],l[1],l[2])}else{k.push(l)}}}if(b._kvo_needsRangeObserver){var j=this.rangeObservers,f=j?j.get("length"):0,c=this._TMP_OUT,e;for(d=0;d<f;d++){e=j[d];if(e.setupPending(b)){c.push(e)}}if(c.length>0){j.removeEach(c)}c.length=0;b._kvo_needsRangeObserver=false}},isObservingSuspended:0,_pending:SC.CoreSet.create(),objectHasPendingChanges:function(a){this._pending.add(a)},suspendPropertyObserving:function(){this.isObservingSuspended++},resumePropertyObserving:function(){var c;if(--this.isObservingSuspended<=0){c=this._pending;this._pending=SC.CoreSet.create();var b,a=c.length;for(b=0;b<a;b++){c[b]._notifyPropertyObservers()}c.clear();c=null}}};sc_require("core");sc_require("mixins/observable");sc_require("private/observer_queue");sc_require("mixins/array");sc_require("system/set");SC.BENCHMARK_OBJECTS=NO;SC._detect_base=function _detect_base(c,b,a){return function d(){var h=b[a],f,g,e;if(c.isEnhancement){f=new Array(arguments.length-1);for(g=0,e=f.length;g<e;g++){f[g]=arguments[g+1]}}else{f=new Array(arguments.length);for(g=0,e=f.length;g<e;g++){f[g]=arguments[g]}}return h.apply(this,f)}};SC._object_extend=function _object_extend(g,f,n){g._kvo_cloned=null;var w,m,e,h=g.concatenatedProperties,k=SC.K,c,b;m=(h)?h.length:0;var a=(m>0)?{}:null;while(--m>=0){w=h[m];c=g[w];b=f[w];if(c){if(!(c instanceof Array)){c=SC.$A(c)}a[w]=(b)?c.concat(b):b}else{if(!(b instanceof Array)){b=SC.$A(b)}a[w]=b}}var v=g._bindings,l=NO,t=g._observers,u=NO,i=g._properties,d=NO,q,j,o,p;var s=g.outlets,r=NO;if(f.outlets){s=(s||SC.EMPTY_ARRAY).concat(f.outlets);r=YES}for(w in f){if(w==="_kvo_cloned"){continue}if(!f.hasOwnProperty(w)){continue}p=(a.hasOwnProperty(w)?a[w]:null)||f[w];if(w.length>7&&w.slice(-7)==="Binding"){if(!l){v=(v||SC.EMPTY_ARRAY).slice();l=YES}if(g[w]==null){v[v.length]=w}}else{if(p&&(p instanceof Function)){if(!p.superclass&&(p!==(e=g[w]))){p.superclass=e||k;p.base=n?SC._detect_base(p,n,w):e||k}if(p.propertyPaths){if(!u){t=(t||SC.EMPTY_ARRAY).slice();u=YES}t[t.length]=w}q=p.localPropertyPaths;if(q){j=q.length;while(--j>=0){o=g._kvo_for(SC.keyFor("_kvo_local",q[j]),SC.CoreSet);o.add(w);g._kvo_for("_kvo_observed_keys",SC.CoreSet).add(q[j])}}if(p.dependentKeys){if(!d){i=(i||SC.EMPTY_ARRAY).slice();d=YES}i[i.length]=w}if(p.autoconfiguredOutlet){if(!r){s=(s||SC.EMPTY_ARRAY).slice();r=YES}s[s.length]=w}if(p.isEnhancement){p=SC._enhance(g[w]||k,p)}}}g[w]=p}if(f.hasOwnProperty("toString")){w="toString";p=(a.hasOwnProperty(w)?a[w]:null)||f[w];if(!p.superclass&&(p!==(e=g[w]))){p.superclass=p.base=e||k}g[w]=p}g._bindings=v||[];g._observers=t||[];g._properties=i||[];g.outlets=s||[];return g};SC._enhance=function(b,a){return function(){var d=new Array(arguments.length+1);for(var f=1,c=d.length;f<c;f++){d[f]=arguments[f-1]}var e=this;d[0]=function(){var h=new Array(arguments.length);for(var j=0,g=h.length;j<g;j++){h[j]=arguments[j]}return b.apply(e,h)};return a.apply(this,d)}};SC.Object=function(a){this.__sc_super__=SC.Object.prototype;return this._object_init(a)};SC.mixin(SC.Object,{mixin:function(){var a=arguments.length,b;for(b=0;b<a;b++){SC.mixin(this,arguments[b])}return this},superclass:null,extend:function(){var e,c=function(f){this.__sc_super__=c.prototype;return this._object_init(f)};for(e in this){if(!this.hasOwnProperty(e)){continue}c[e]=this[e]}if(this.hasOwnProperty("toString")){c.toString=this.toString}c.superclass=this;c.__sc_super__=this.prototype;SC.generateGuid(c,"sc");c.subclasses=SC.Set.create();this.subclasses.add(c);var d=(c.prototype=SC.beget(this.prototype)),b,a=arguments.length;for(b=0;b<a;b++){SC._object_extend(d,arguments[b],c.__sc_super__)}d.constructor=c;return c},reopen:function(f){if(this.subclasses){var b,e,g,c,a=this.subclasses.length,d;for(d=0;d<a;d++){c=null;b=this.subclasses[d];for(e in f){if(!f.hasOwnProperty(e)){continue}if(b.prototype.hasOwnProperty(e)){if(!c){c=SC.clone(f)}delete c[e];continue}g=f[e];if(g&&(g instanceof Function)&&(g.isEnhancement)){if(!c){c=SC.clone(f)}delete c[e];continue}}b.reopen(c||f)}}return SC._object_extend(this.prototype,f,this.__sc_super__)},create:function(){var b=this,a=new b(arguments);if(SC.ObjectDesigner){SC.ObjectDesigner.didCreateObject(a,SC.$A(arguments))}return a},isClass:YES,subclasses:SC.Set.create(),toString:function(){return SC._object_className(this)},subclassOf:function(b){if(this===b){return NO}var a=this;while((a=a.superclass)){if(a===b){return YES}}return NO},hasSubclass:function(a){return(a&&a.subclassOf)?a.subclassOf(this):NO},kindOf:function(a){return(this===a)||this.subclassOf(a)},design:function(){if(this.isDesign){return this}var a=this.extend.apply(this,arguments);a.isDesign=YES;if(SC.ObjectDesigner){SC.ObjectDesigner.didLoadDesign(a,this,SC.A(arguments))}return a}});SC.Object.prototype={_kvo_enabled:YES,_object_init:function(c){var b,a=(c)?c.length:0;for(b=0;b<a;b++){SC._object_extend(this,c[b],this.__sc_super__)}SC.generateGuid(this,"sc");this.init();var d=this.initMixin;a=(d)?d.length:0;for(b=0;b<a;b++){d[b].call(this)}return this},mixin:function(){var b,a=arguments.length,c;for(b=0;b<a;b++){SC._object_extend(this,arguments[b])}this._observableInited=NO;this.initObservable();for(b=0;b<a;b++){c=arguments[b].initMixin;if(c){c.call(this)}}return this},init:function(){this.initObservable();return this},isDestroyed:NO,destroy:function(){if(this.get("isDestroyed")){return this}this.set("isDestroyed",YES);var b,c=this.destroyMixin,a=(c)?c.length:0;for(b=0;b<a;b++){c[b].call(this)}this.destroyObservable();return this},isObject:true,respondsTo:function(a){return !!(this[a] instanceof Function)},tryToPerform:function(b,c,a){return this.respondsTo(b)&&(this[b](c,a)!==NO)},superclass:function(){var a=arguments.callee.caller;return a.superclass?a.superclass.apply(this,arguments):null},instanceOf:function(a){return this.constructor===a},kindOf:function(a){return this.constructor.kindOf(a)},toString:function(){if(!this._object_toString){var a=SC._object_className(this.constructor),b=a+":"+SC.guidFor(this);if(a){this._object_toString=b}else{return b}}return this._object_toString},invokeOnce:function(a){SC.RunLoop.currentRunLoop.invokeOnce(this,a);return this},invokeLast:function(a){SC.RunLoop.currentRunLoop.invokeLast(this,a);return this},invokeNext:function(a){SC.RunLoop.currentRunLoop.invokeNext(this,a);return this},concatenatedProperties:["concatenatedProperties","initMixin","destroyMixin"]};SC.Object.prototype.constructor=SC.Object;SC.mixin(SC.Object.prototype,SC.Observable);SC.findClassNames=function(){if(SC._object_foundObjectClassNames){return}SC._object_foundObjectClassNames=true;var b=[],c=false;var a=function(d,f,j){var l,i,h;j--;if(b.indexOf(f)>=0){return}b.push(f);for(var g in f){if(g==="__scope__"){continue}if(g==="superclass"){continue}if(g==="__SC__"){g="SC"}if(!g.match(/^[A-Z0-9]/)){continue}if(g==="SC"){if(c){continue}c=true}l=(d)?[d,g].join("."):g;i=f[g];try{h=SC.typeOf(i)}catch(k){break}switch(h){case SC.T_CLASS:if(!i._object_className){i._object_className=l}if(j>=0){a(l,i,j)}break;case SC.T_OBJECT:if(j>=0){a(l,i,j)}break;case SC.T_HASH:if(((d)||(l==="SC"))&&(j>=0)){a(l,i,j)}break;default:break}}};window.__SC__=SC;a(null,window,2)};SC.instanceOf=function(a,b){return !!(a&&a.constructor===b)};SC.kindOf=function(a,b){if(a&&!a.isClass){a=a.constructor}return !!(a&&a.kindOf&&a.kindOf(b))};SC._object_className=function(b){if(SC.isReady===NO){return""}if(!b._object_className){SC.findClassNames()}if(b._object_className){return b._object_className}var a=b;while(a&&!a._object_className){a=a.superclass}return(a&&a._object_className)?a._object_className:"Anonymous"};sc_require("system/object");SC._PropertyChain=SC.Object.extend({object:null,property:null,target:null,toInvalidate:null,nextProperty:null,activate:function(b){var a=this.get("object"),c=this.get("property"),d;if(!b){b=this.get("target")}if(a&&a!==b){this.deactivate()}this.set("object",b);if(b&&c!=="@each"){b.registerDependentKeyWithChain(c,this)}if(this.next){d=b?b.get(c):undefined;this.next.activate(d)}return this},deactivate:function(){var a=this.get("object"),b=this.get("property");if(a){a.removeDependentKeyWithChain(b,this)}if(this.next){this.next.deactivate()}return this},notifyPropertyDidChange:function(){var d=this.get("target"),c=this.get("toInvalidate"),b,a;d.propertyDidChange(c);if(this.next){b=this.get("object");a=b.get(this.get("property"));this.next.activate(a)}}});SC._PropertyChain.createChain=function(h,g,e){var f=h.split(".");var a=f.length,d=1;var b=SC._PropertyChain.create({property:f[0],target:g,toInvalidate:e,nextProperty:f[1]});b.set("length",a);var c=b;while(--a>=1){c=c.next=SC._PropertyChain.create({property:f[d],target:g,toInvalidate:e,nextProperty:f[++d]});c.set("length",a)}return b};sc_require("ext/function");sc_require("system/object");SC.MULTIPLE_PLACEHOLDER="@@MULT@@";SC.NULL_PLACEHOLDER="@@NULL@@";SC.EMPTY_PLACEHOLDER="@@EMPTY@@";SC.Binding={isBinding:YES,beget:function(b){var a=SC.beget(this);a.parentBinding=this;if(a._MixAdapter){a._mixAdapter=a._MixAdapter.create(a._mixAdapterHash);a=a.from("aggregateProperty",a._mixAdapter).oneWay()}if(b!==undefined){a=a.from(b)}return a},builder:function(){var b=this,a=function(c){return b.beget().from(c)};a.beget=function(){return b.beget()};return a},from:function(b,a){if(!b){return this}var c=(this===SC.Binding)?this.beget():this;c._fromPropertyPath=b;c._fromRoot=a;c._fromTuple=null;return c},to:function(b,a){var c=(this===SC.Binding)?this.beget():this;c._toPropertyPath=b;c._toRoot=a;c._toTuple=null;return c},connect:function(){if(this.isConnected){return this}this.isConnected=YES;this._connectionPending=YES;this._syncOnConnect=YES;SC.Binding._connectQueue.add(this);if(!SC.RunLoop.isRunLoopInProgress()){this._scheduleSync()}return this},_connect:function(){if(!this._connectionPending){return}this._connectionPending=NO;var b,a;b=this._fromPropertyPath;a=this._fromRoot;if(typeof b==="string"){if(b.indexOf(".")===0){b=b.slice(1);if(!a){a=this._toRoot}}else{if(b.indexOf("*")===0){b=[this._fromRoot||this._toRoot,b.slice(1)];a=null}}}this._fromObserverData=[b,this,this.fromPropertyDidChange,a];SC.Observers.addObserver.apply(SC.Observers,this._fromObserverData);if(!this._oneWay){b=this._toPropertyPath;a=this._toRoot;this._toObserverData=[b,this,this.toPropertyDidChange,a];SC.Observers.addObserver.apply(SC.Observers,this._toObserverData)}if(this._syncOnConnect){this._syncOnConnect=NO;this.sync()}},disconnect:function(){if(!this.isConnected){return this}if(this._connectionPending){this._connectionPending=NO;SC.Binding._connectQueue.remove(this)}else{SC.Observers.removeObserver.apply(SC.Observers,this._fromObserverData);if(!this._oneWay){SC.Observers.removeObserver.apply(SC.Observers,this._toObserverData)}SC.Binding._changeQueue.remove(this)}this.isConnected=NO;return this},isDestroyed:NO,destroy:function(){if(this.isDestroyed){return}this.isDestroyed=YES;if(this._mixAdapter){this._mixAdapter.destroy();this._mixAdapter=null;this._MixAdapter=null;this._mixAdapterHash=null}this.disconnect();this._bindingSource=null;this._toRoot=this._toTarget=null;this._fromRoot=this._fromTarget=null;this._toObserverData=this._fromObserverData=null},fromPropertyDidChange:function(c,b){var a=c?c.get(b):null;if(!this.isConnected){return}if(a!==this._bindingValue||b==="[]"){this._setBindingValue(c,b);SC.Binding._changeQueue.add(this);this._scheduleSync()}},toPropertyDidChange:function(c,b){if(this._oneWay){return}var a=c.get(b);if(!this.isConnected){return}if(a!==this._transformedBindingValue){this._setBindingValue(c,b);SC.Binding._changeQueue.add(this);this._scheduleSync()}},_scheduleSync:function(){if(SC.RunLoop.isRunLoopInProgress()||SC.Binding._syncScheduled){return}SC.Binding._syncScheduled=YES;setTimeout(function(){SC.run();SC.Binding._syncScheduled=NO},1)},_setBindingValue:function(b,a){this._bindingSource=b;this._bindingKey=a},_computeBindingValue:function(){var c=this._bindingSource,b=this._bindingKey,a;this._bindingValue=a=(c?c.getPath(b):null);this._transformedBindingValue=this._computeTransformedValue(a)},_computeTransformedValue:function(e){var d=this._transforms,b,a,c;if(d){a=d.length;for(b=0;b<a;b++){c=d[b];e=c(e,this)}}if(this._noError&&SC.typeOf(e)===SC.T_ERROR){e=null}return e},_connectQueue:SC.CoreSet.create(),_alternateConnectQueue:SC.CoreSet.create(),_changeQueue:SC.CoreSet.create(),_alternateChangeQueue:SC.CoreSet.create(),flushPendingChanges:function(){if(this._isFlushing){return NO}this._isFlushing=YES;SC.Observers.suspendPropertyObserving();var b=NO,a,c;while((a=this._connectQueue).length>0){this._connectQueue=this._alternateConnectQueue;this._alternateConnectQueue=a;while((c=a.pop())){c._connect()}}while((a=this._changeQueue).length>0){b=YES;this._changeQueue=this._alternateChangeQueue;this._alternateChangeQueue=a;while((c=a.pop())){c.applyBindingValue()}}this._isFlushing=NO;SC.Observers.resumePropertyObserving();return b},applyBindingValue:function(){this._computeBindingTargets();this._computeBindingValue();var a=this._bindingValue,b=this._transformedBindingValue;if(!this._oneWay&&this._fromTarget){this._fromTarget.setPathIfChanged(this._fromPropertyKey,a)}if(this._toTarget){this._toTarget.setPathIfChanged(this._toPropertyKey,b)}},sync:function(){var d,c,a,b;if(!this.isConnected){return this}if(this._connectionPending){this._syncOnConnect=YES}else{this._computeBindingTargets();d=this._fromTarget;c=this._fromPropertyKey;if(!d||!c){return this}if(!d.isObservable){return this}a=d.getPath(c);b=this._computeTransformedValue(a);if(a!==this._bindingValue||b!==this._transformedBindingValue||c==="[]"){this._setBindingValue(d,c);SC.Binding._changeQueue.add(this)}}return this},_syncOnConnect:NO,_computeBindingTargets:function(){var c,b,a;if(!this._fromTarget){c=this._fromPropertyPath;b=this._fromRoot;if(typeof c==="string"){if(c.indexOf(".")===0){c=c.slice(1);if(!b){b=this._toRoot}}else{if(c.indexOf("*")===0){c=[b||this._toRoot,c.slice(1)];b=null}}}a=SC.tupleForPropertyPath(c,b);if(a){this._fromTarget=a[0];this._fromPropertyKey=a[1]}}if(!this._toTarget){c=this._toPropertyPath;b=this._toRoot;a=SC.tupleForPropertyPath(c,b);if(a){this._toTarget=a[0];this._toPropertyKey=a[1];if(this._mixAdapter){this._mixAdapter.set("localObject",this._toTarget)}}}},oneWay:function(c,a){if((a===undefined)&&(SC.typeOf(c)===SC.T_BOOL)){a=c;c=null}var b=this.from(c);if(b===SC.Binding){b=b.beget()}b._oneWay=(a===undefined)?YES:a;return b},transform:function(b){var c=(this===SC.Binding)?this.beget():this;var a=c._transforms;if(a&&(a===c.parentBinding._transforms)){a=c._transforms=a.slice()}if(!a){a=c._transforms=[]}a.push(b);return c},resetTransforms:function(){var a=(this===SC.Binding)?this.beget():this;a._transforms=null;return a},bool:function(a){return this.from(a).transform(function(b){var c=SC.typeOf(b);if(c===SC.T_ERROR){return b}return(c==SC.T_ARRAY)?(b.length>0):(b==="")?NO:!!b})},integer:function(a,b){if(b===undefined){b=a;a=null}if(b===undefined){b=10}return this.from(a).transform(function(c){if(SC.none(c)){c=0}else{if(typeof c===SC.T_STRING){c=window.parseInt(c,b)}else{if(typeof c===SC.T_BOOL){c=c?1:0}}}if(typeof c!==SC.T_NUMBER||isNaN(c)){c=0}return c})},isNull:function(a){return this.from(a).transform(function(b){var c=SC.typeOf(b);return(c===SC.T_ERROR)?b:SC.none(b)})},noError:function(c,a){if((a===undefined)&&(SC.typeOf(c)===SC.T_BOOL)){a=c;c=null}var b=this.from(c);if(b===SC.Binding){b=b.beget()}b._noError=(a===undefined)?YES:a;return b},not:function(a){return this.from(a).transform(function(b){var c=SC.typeOf(b);if(c===SC.T_ERROR){return b}return !((c==SC.T_ARRAY)?(b.length>0):(b==="")?NO:!!b)})},multiple:function(a){return this.from(a).transform(function(b){if(!SC.isArray(b)){b=(b==null)?[]:[b]}return b})},notEmpty:function(b,a){if(a===undefined){a=SC.EMPTY_PLACEHOLDER}return this.from(b).transform(function(d,c){if(SC.none(d)||(d==="")||(SC.isArray(d)&&(d.get?d.get("length"):d.length)===0)){d=a}return d})},notNull:function(b,a){if(a===undefined){a=SC.EMPTY_PLACEHOLDER}return this.from(b).transform(function(d,c){if(SC.none(d)){d=a}return d})},single:function(b,a){if(a===undefined){a=SC.MULTIPLE_PLACEHOLDER}return this.from(b).transform(function(e,d){if(e&&e.isEnumerable){var c=e.get("length");e=(c>1)?a:(c<=0)?null:e.firstObject()}return e})},string:function(a){return this.from(a).transform(function(b){if(SC.none(b)){b=""}else{if(typeof b!==SC.T_STRING&&b.toString){b=b.toString()}}return b})},_sc_mixAdapterBinding:function(h){var g=[];for(var e=1;e<arguments.length;e++){var f=arguments[e];if(f.indexOf("*")===0||f.indexOf(".")===0){f=f.slice(1).replace(/\*/g,".");f="*localObject."+f}g.push(f)}var d={localObject:null};for(e=0;e<g.length;++e){var c="value"+e;d[c+"Binding"]=SC.Binding.oneWay(g[e])}var a=h.create(d);var b=this.from("aggregateProperty",a).oneWay();b._MixAdapter=h;b._mixAdapterHash=d;b._mixAdapter=a;return b},_sc_mixImpl:function(f,e){var a=f.length,d=[];for(var c=0;c<a;++c){d.push("value"+c)}var b=SC.Object.extend({aggregateProperty:SC.Function.property(function(){var g=d.map(function(h){return this.get(h)},this);return e.apply(null,g)},d).cacheable()});return this._sc_mixAdapterBinding.apply(this,[b].concat(f))},and:function(){var a=arguments.length,c=new Array(a);for(var b=0;b<a;b++){c[b]=arguments[b]}return this._sc_mixImpl(c,function(){var d=true;for(b=0;d&&(b<arguments.length);b++){d=d&&arguments[b]}return d})},or:function(){var a=arguments.length,c=new Array(a);for(var b=0;b<a;b++){c[b]=arguments[b]}return this._sc_mixImpl(c,function(){var d=false;for(b=0;!d&&(b<arguments.length);b++){d=d||arguments[b]}return d})},mix:function(){var a=arguments.length-1,c=new Array(a);for(var b=0;b<a;b++){c[b]=arguments[b]}return this._sc_mixImpl(c,arguments[a])},equalTo:function(b,a){if(a===undefined){a=b;b=null}return this.from(b).transform(function(c,d){return c===a})},toString:function(){var c=this._fromRoot?"<%@>:%@".fmt(this._fromRoot,this._fromPropertyPath):this._fromPropertyPath;var b=this._toRoot?"<%@>:%@".fmt(this._toRoot,this._toPropertyPath):this._toPropertyPath;var a=this._oneWay?"[oneWay]":"";return"SC.Binding%@(%@ -> %@)%@".fmt(SC.guidFor(this),c,b,a)}};SC.binding=function(b,a){return SC.Binding.from(b,a)};sc_require("ext/function");SC.Error=SC.Object.extend({code:-1,message:"",errorValue:null,errorObject:function(){return this}.property().cacheable(),"throw":function(){var a=this.toString();SC.Logger.error(a);throw new Error(a)},trace:function(){return(new Error()).trace}.property().cacheable(),label:null,toString:function(){return"SC.Error:%@:%@ (%@)".fmt(SC.guidFor(this),this.get("message"),this.get("code"))},isError:YES});SC.Error.mixin({desc:function(d,a,e,c){var b={message:d};if(a!==undefined){b.label=a}if(c!==undefined){b.code=c}if(e!==undefined){b.errorValue=e}return this.create(b)},"throw":function(c,a,d,b){this.desc.apply(this,arguments).throw()}});SC.$error=function(b,a,d,e){return SC.Error.desc(b,a,d,e)};SC.throw=function(b,a,d,e){SC.Error.throw(b,a,d,e)};SC.$throw=SC.throw;SC.ok=function(a){return(a!==false)&&!(a&&a.isError)};SC.$ok=SC.ok;SC.val=function(a){if(a&&a.isError){return a.get?a.get("errorValue"):null}else{return a}};SC.$val=SC.val;SC.Error.HAS_MULTIPLE_VALUES=-100;sc_require("mixins/enumerable");sc_require("mixins/observable");sc_require("mixins/freezable");sc_require("mixins/copyable");SC.IndexSet=SC.mixin({},SC.Observable,SC.Enumerable,SC.Freezable,SC.Copyable,{_sc_sliceContent:function(e){if(e.length<1000){return e.slice()}var d=0,a=[],b=e[0];while(b!==0){a[d]=b;d=(b<0)?(0-b):b;b=e[d]}a[d]=0;this._hint(0,d,a);return a},create:function(c,b){var a=SC.beget(this);a.initObservable();a.registerDependentKey("min","[]");if(c&&c.isIndexSet){a._content=this._sc_sliceContent(c._content);a.max=c.max;a.length=c.length;a.source=c.source}else{a._content=[0];if(c!==undefined){a.add(c,b)}}return a},isIndexSet:YES,HINT_SIZE:256,length:0,max:0,min:function(){var a=this._content,b=a[0];return(b===0)?-1:(b>0)?0:Math.abs(b)}.property("[]").cacheable(),firstObject:function(){return(this.get("length")>0)?this.get("min"):undefined}.property(),rangeStartForIndex:function(c){var f=this._content,a=this.get("max"),b,e,d;if(c>=a){return a}if(Math.abs(f[c])>c){return c}d=c-(c%SC.IndexSet.HINT_SIZE);b=f[d];if(SC.none(b)){b=this._infRange}if(b<0||b>c){b=d}e=f[b];if(e===undefined){e=this.rangeStartForIndex(b)}else{e=Math.abs(e)}while(e<c){b=e;e=Math.abs(f[b])}return b},isEqual:function(c){if(c===this){return YES}if(!c||!c.isIndexSet||(c.max!==this.max)||(c.length!==this.length)){return NO}var e=this._content,b=c._content,d=0,a=e[d];do{if(b[d]!==a){return NO}d=Math.abs(a);a=e[d]}while(d!==0);return YES},indexBefore:function(b){if(b===0){return -1}b--;var c=this._content,a=this.get("max"),d=this.rangeStartForIndex(b);if(!c){return null}if(!isFinite(d)){return b}while((d===a)||(c[d]<0)){if(d===0){return -1}b=d-1;d=this.rangeStartForIndex(b)}return b},indexAfter:function(b){var d=this._content,a=this.get("max"),e,c;if(!d||(b>=a)){return -1}b++;e=this.rangeStartForIndex(b);c=d[e];while(c<0){if(c===0){return -1}b=e=Math.abs(c);c=d[e]}return b},contains:function(g,c){var b,f,a,e,d;if(c===undefined){if(g===null||g===undefined){return NO}if(typeof g===SC.T_NUMBER){c=1}else{if(g&&g.isIndexSet){if(g===this){return YES}b=g._content;f=0;a=b[f];while(a!==0){if((a>0)&&!this.contains(f,a-f)){return NO}f=Math.abs(a);a=b[f]}return YES}else{c=g.length;g=g.start}}}e=this.rangeStartForIndex(g);if(isFinite(e)){d=this._content[e];return(d>0)&&(e<=g)&&(d>=(g+c))}else{return true}},intersects:function(f,c){var b,e,a,d;if(c===undefined){if(typeof f===SC.T_NUMBER){c=1}else{if(f&&f.isIndexSet){if(f===this){return YES}b=f._content;e=0;a=b[e];while(a!==0){if((a>0)&&this.intersects(e,a-e)){return YES}e=Math.abs(a);a=b[e]}return NO}else{c=f.length;f=f.start}}}e=this.rangeStartForIndex(f);b=this._content;a=b[e];d=f+c;while(e<d){if(a===0){return NO}if((a>0)&&(a>f)){return YES}e=Math.abs(a);a=b[e]}return NO},without:function(b,a){if(b===this){return SC.IndexSet.create()}return this.clone().remove(b,a)},replace:function(b,a){if(a===undefined){if(typeof b===SC.T_NUMBER){a=1}else{if(b&&b.isIndexSet){this._content=this._sc_sliceContent(b._content);this.beginPropertyChanges().set("max",b.max).set("length",b.length).set("source",b.source).enumerableContentDidChange();this.endPropertyChanges();return this}else{a=b.length;b=b.start}}}this._content.length=1;this._content[0]=0;this.length=this.max=0;return this.add(b,a)},add:function(a,b){if(this.isFrozen){throw new Error(SC.FROZEN_ERROR)}var e,i,d;if(a&&a.isIndexSet){e=a._content;if(!e){return this}i=0;d=e[0];while(d!==0){if(d>0){this.add(i,d-i)}i=d<0?0-d:d;d=e[i]}return this}else{if(b===undefined){if(a===null||a===undefined){return this}else{if(typeof a===SC.T_NUMBER){b=1}else{b=a.length;a=a.start}}}else{if(b===null){b=1}}}if(b<=0){return this}var f=this.get("max"),c=f,h,g;e=this._content;if(a===f){if(a>0){i=this.rangeStartForIndex(a-1);d=e[i];if(d>0){delete e[f];e[i]=f=a+b;a=i}else{e[f]=f=a+b}}else{e[a]=f=b}e[f]=0;this.set("max",f);this.set("length",this.length+b);b=f-a}else{if(a>f){e[f]=0-a;e[a]=a+b;e[a+b]=0;this.set("max",a+b);this.set("length",this.length+b);b=a+b-f;a=f}else{i=this.rangeStartForIndex(a);d=e[i];f=a+b;h=0;if((a>0)&&(i===a)&&(d<=0)){i=this.rangeStartForIndex(a-1);d=e[i]}if(d<0){e[i]=0-a;if(Math.abs(d)>f){e[a]=0-f;e[f]=d}else{e[a]=d}}else{a=i;if(d>f){f=d}}i=a;while(i<f){g=e[i];if(g===0){e[f]=0;d=f;h+=f-i}else{d=Math.abs(g);if(d>f){e[f]=g;d=f}if(g<0){h+=d-i}}delete e[i];i=d}if((i=e[f])>0){delete e[f];f=i}e[a]=f;if(f>c){this.set("max",f)}this.set("length",this.get("length")+h);b=f-a}}this._hint(a,b);if(h!==0){this.enumerableContentDidChange()}return this},remove:function(a,b){if(this.isFrozen){throw new Error(SC.FROZEN_ERROR)}if(b===undefined){if(a===null||a===undefined){return this}else{if(typeof a===SC.T_NUMBER){b=1}else{if(a.isIndexSet){a.forEachRange(this.remove,this);return this}else{b=a.length;a=a.start}}}}if(b<=0){return this}var e=this.get("max"),d=this._content,i,c,h,f,g;if(a>=e){return this}i=this.rangeStartForIndex(a);c=d[i];g=a+b;h=0;if((a>0)&&(i===a)&&(c>0)){i=this.rangeStartForIndex(a-1);c=d[i]}if(c>0){d[i]=a;if(c>g){d[a]=g;d[g]=c}else{d[a]=c}}else{a=i;c=Math.abs(c);if(c>g){g=c}}if(!isFinite(c)){this._hint(i,a-i);this._infRange=g}i=a;while(i<g){f=d[i];if(f===0){d[g]=0;c=g}else{c=Math.abs(f);if(c>g){d[g]=f;c=g}if(f>0){h+=c-i}}delete d[i];i=c}if((i=d[g])<0){delete d[g];g=Math.abs(i)}if(d[g]===0){delete d[g];d[a]=0;this.set("max",a)}else{d[a]=0-g}if(isFinite(h)){this.set("length",this.get("length")-h)}else{this.set("length",0)}b=Math.min(d.length,g-a);this._hint(a,b);if(h!==0){this.enumerableContentDidChange()}return this},_hint:function(g,d,c){if(c===undefined){c=this._content}var b=SC.IndexSet.HINT_SIZE,a=Math.abs(c[g]),f=g-(g%b)+b,e=g+d;while(f<e){while((a!==0)&&(a<=f)){g=a;a=Math.abs(c[g])}if(a===0){delete c[f]}else{if(!isFinite(a)){this._infRange=g;f=Infinity}else{if(f!==g){c[f]=g}}}f+=b}},clear:function(){if(this.isFrozen){throw new Error(SC.FROZEN_ERROR)}var a=this.length;this._content.length=1;this._content[0]=0;this._infRange=null;this.set("length",0).set("max",0);if(a>0){this.enumerableContentDidChange()}},addEach:function(b){if(this.isFrozen){throw new Error(SC.FROZEN_ERROR)}this.beginPropertyChanges();var a=b.get("length");if(b.isSCArray){while(--a>=0){this.add(b.objectAt(a))}}else{if(b.isEnumerable){b.forEach(function(c){this.add(c)},this)}}this.endPropertyChanges();return this},removeEach:function(b){if(this.isFrozen){throw new Error(SC.FROZEN_ERROR)}this.beginPropertyChanges();var a=b.get("length");if(b.isSCArray){while(--a>=0){this.remove(b.objectAt(a))}}else{if(b.isEnumerable){b.forEach(function(c){this.remove(c)},this)}}this.endPropertyChanges();return this},clone:function(){return SC.IndexSet.create(this)},inspect:function(){var e=this._content,b=e.length,a=0,c=[],d;for(a=0;a<b;a++){d=e[a];if(d!==undefined){c.push("%@:%@".fmt(a,d))}}return"SC.IndexSet<%@>".fmt(c.join(" , "))},forEachRange:function(f,d){var b=this._content,e=0,a=b[e],c=this.source;if(d===undefined){d=null}while(a!==0){if(a>0){f.call(d,e,a-e,this,c)}e=Math.abs(a);a=b[e]}return this},forEachIn:function(b,c,j,f){var g=this._content,i=0,h=0,d=b+c,a=this.source,e=g[i];if(f===undefined){f=null}while(e!==0){if(i<b){i=b}while((i<e)&&(i<d)){j.call(f,i++,h++,this,a)}if(i>=d){i=e=0}else{i=Math.abs(e);e=g[i]}}return this},lengthIn:function(g,d){var a=0;if(d===undefined){if(g===null||g===undefined){return 0}else{if(typeof g===SC.T_NUMBER){d=1}else{if(g.isIndexSet){g.forEachRange(function(i,h){a+=this.lengthIn(i,h)},this);return a}else{d=g.length;g=g.start}}}}if(this.get("length")===0){return 0}var c=this._content,f=0,b=c[f],e=g+d;while(f<e&&b!==0){if(b>0){a+=(b>e)?e-f:b-f}f=Math.abs(b);b=c[f]}return a},source:null,indexOf:function(d,c){var f=this.source;if(!f){throw new Error("%@.indexOf() requires source".fmt(this))}var b=f.get("length"),e=this._content,g=e[0]<0?Math.abs(e[0]):0,a;while(g>=0&&g<b){a=f.indexOf(d,g);if(a<0){return -1}if(this.contains(a)){return a}g=a+1}return -1},lastIndexOf:function(d,c){var e=this.source;if(!e){throw new Error("%@.lastIndexOf() requires source".fmt(this))}var b=e.get("length"),f=this.max-1,a;if(f>=b){f=b-1}while(f>=0){a=e.lastIndexOf(d,f);if(a<0){return -1}if(this.contains(a)){return a}f=a+1}return -1},forEachObject:function(f,d){var c=this.source;if(!c){throw new Error("%@.forEachObject() requires source".fmt(this))}var b=this._content,e=0,a=b[e];if(d===undefined){d=null}while(a!==0){while(e<a){f.call(d,c.objectAt(e),e,c,this);e++}e=Math.abs(a);a=b[e]}return this},addObject:function(c,d){var e=this.source;if(!e){throw new Error("%@.addObject() requires source".fmt(this))}var b=e.get("length"),f=0,a;while(f>=0&&f<b){a=e.indexOf(c,f);if(a>=0){this.add(a);if(d){return this}f=a++}else{return this}}return this},addObjects:function(b,a){b.forEach(function(c){this.addObject(c,a)},this);return this},removeObject:function(c,d){var e=this.source;if(!e){throw new Error("%@.removeObject() requires source".fmt(this))}var b=e.get("length"),f=0,a;while(f>=0&&f<b){a=e.indexOf(c,f);if(a>=0){this.remove(a);if(d){return this}f=a+1}else{return this}}return this},removeObjects:function(b,a){b.forEach(function(c){this.removeObject(c,a)},this);return this},LOG_OBSERVING:NO,forEach:function(g,e){var c=this._content,f=0,a=0,d=this.source,b=c[f];if(e===undefined){e=null}while(b!==0){if(isFinite(b)){while(f<b){g.call(e,f++,a++,this,d)}f=Math.abs(b);b=c[f]}else{throw new Error("Developer Error: You may not iterate an infinite range in SC.IndexSet.")}}return this},nextObject:function(f,b,c){var e=this._content,d=c.next,a=this.get("max");if(b===null){b=d=0}else{if(b>=a){delete c.next;return null}else{b++}}if(b===d){do{b=Math.abs(d);d=e[b]}while(d<0);c.next=d}return b},toString:function(){var a=[];this.forEachRange(function(c,b){a.push(b===1?c:"%@..%@".fmt(c,c+b-1))},this);return"SC.IndexSet<%@>".fmt(a.join(","))}});SC.IndexSet.slice=SC.IndexSet.copy=SC.IndexSet.clone;SC.IndexSet.EMPTY=SC.IndexSet.create().freeze();SC.json={encode:function(a){return JSON.stringify(a)},decode:function(a){return JSON.parse(a)}};if(!this.JSON){this.JSON={}}(function(){function f(n){return n<10?"0"+n:n}if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf()}}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==="string"?c:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+string+'"'}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==="object"&&typeof value.toJSON==="function"){value=value.toJSON(key)}if(typeof rep==="function"){value=rep.call(holder,key,value)}switch(typeof value){case"string":return quote(value);case"number":return isFinite(value)?String(value):"null";case"boolean":case"null":return String(value);case"object":if(!value){return"null"}gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==="[object Array]"){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||"null"}v=partial.length===0?"[]":gap?"[\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"]":"["+partial.join(",")+"]";gap=mind;return v}if(rep&&typeof rep==="object"){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==="string"){v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v)}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v)}}}}v=partial.length===0?"{}":gap?"{\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"}":"{"+partial.join(",")+"}";gap=mind;return v}}if(typeof JSON.stringify!=="function"){JSON.stringify=function(value,replacer,space){var i;gap="";indent="";if(typeof space==="number"){for(i=0;i<space;i+=1){indent+=" "}}else{if(typeof space==="string"){indent=space}}rep=replacer;if(replacer&&typeof replacer!=="function"&&(typeof replacer!=="object"||typeof replacer.length!=="number")){throw new Error("JSON.stringify")}return str("",{"":value})}}if(typeof JSON.parse!=="function"){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==="object"){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v}else{delete value[k]}}}}return reviver.call(holder,key,value)}text=String(text);cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})}if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){j=eval("("+text+")");return typeof reviver==="function"?walk({"":j},""):j}throw new SyntaxError("JSON.parse")}}}());sc_require("ext/function");SC.LOGGER_LOG_DELIMITER=", ";SC.LOGGER_LOG_ERROR="ERROR: ";SC.LOGGER_LOG_INFO="INFO:  ";SC.LOGGER_LOG_WARN="WARN:  ";SC.LOGGER_LOG_DEBUG="DEBUG: ";SC.LOGGER_LOG_GROUP_HEADER="** %@";SC.LOGGER_LOG_GROUP_INDENTATION="    ";SC.LOGGER_RECORDED_LOG_TIMESTAMP_PREFIX="%@:  ";SC.LOGGER_LEVEL_DEBUG="debug";SC.LOGGER_LEVEL_INFO="info";SC.LOGGER_LEVEL_WARN="warn";SC.LOGGER_LEVEL_ERROR="error";SC.LOGGER_LEVEL_NONE="none";SC.Logger=SC.Object.create({messagePrefix:null,outputMessagePrefix:null,recordedMessagePrefix:null,logOutputLevel:null,logRecordingLevel:SC.LOGGER_LEVEL_NONE,recordedLogMessages:null,recordedLogMessagesMaximumLength:500,recordedLogMessagesPruningMinimumLength:100,debugEnabled:NO,exists:function(){return !SC.none(this.get("reporter"))}.property("reporter").cacheable(),fallBackOnAlert:NO,reporter:console,debug:function(a,b){SC.Logger._handleMessage(SC.LOGGER_LEVEL_DEBUG,YES,a,arguments)},debugWithoutFmt:function(){this._handleMessage(SC.LOGGER_LEVEL_DEBUG,NO,null,arguments)},debugGroup:function(a,b){SC.Logger._handleGroup(SC.LOGGER_LEVEL_DEBUG,a,arguments)},debugGroupEnd:function(){SC.Logger._handleGroupEnd(SC.LOGGER_LEVEL_DEBUG)},info:function(a,b){SC.Logger._handleMessage(SC.LOGGER_LEVEL_INFO,YES,a,arguments)},infoWithoutFmt:function(){this._handleMessage(SC.LOGGER_LEVEL_INFO,NO,null,arguments)},infoGroup:function(a,b){SC.Logger._handleGroup(SC.LOGGER_LEVEL_INFO,a,arguments)},infoGroupEnd:function(){SC.Logger._handleGroupEnd(SC.LOGGER_LEVEL_INFO)},warn:function(a,b){SC.Logger._handleMessage(SC.LOGGER_LEVEL_WARN,YES,a,arguments)},warnWithoutFmt:function(){this._handleMessage(SC.LOGGER_LEVEL_WARN,NO,null,arguments)},warnGroup:function(a,b){SC.Logger._handleGroup(SC.LOGGER_LEVEL_WARN,a,arguments)},warnGroupEnd:function(){SC.Logger._handleGroupEnd(SC.LOGGER_LEVEL_WARN)},error:function(a,b){SC.Logger._handleMessage(SC.LOGGER_LEVEL_ERROR,YES,a,arguments)},errorWithoutFmt:function(){this._handleMessage(SC.LOGGER_LEVEL_ERROR,NO,null,arguments)},errorGroup:function(a,b){SC.Logger._handleGroup(SC.LOGGER_LEVEL_ERROR,a,arguments)},errorGroupEnd:function(){SC.Logger._handleGroupEnd(SC.LOGGER_LEVEL_ERROR)},outputRecordedLogMessages:function(n){if(!this.get("exists")){return}var r=this.get("reporter"),k=this.get("recordedLogMessages"),a=0,d=SC.LOGGER_RECORDED_LOG_TIMESTAMP_PREFIX,q,o,b,c,g,h,e,f,t,m,l,p,s;if(k){for(q=0,o=k.length;q<o;++q){b=k[q];c=b.type;if(n){g=d.fmt(b.timestamp.toUTCString())}h=b.message;if(h){e=b.originalArguments;this._outputMessage(c,g,a,h,e)}else{m=b.indentation;t=b.title;l=m-a;if(r.group){if(Math.abs(l)>1){for(p=0,s=(l-1);p<s;++p){if(l>0){r.group()}else{r.groupEnd()}}}if(l>0){f=g?g:"";f+=t;r.group(f)}else{r.groupEnd()}}else{if(l>0){this._outputGroup(c,g,m-1,t)}}a=m}}}},stringifyRecordedLogMessages:function(){var j="",f=this.get("recordedLogMessages"),m=0,h=SC.LOGGER_RECORDED_LOG_TIMESTAMP_PREFIX,d=this._LOG_FALLBACK_PREFIX_MAPPING,c=SC.LOGGER_LOG_GROUP_HEADER,e,a,o,l,r,q,g,p,n,k,b;if(f){for(e=0,a=f.length;e<a;++e){o=f[e];l=o.type;g=h.fmt(o.timestamp.toUTCString());g+=d[l]||"";r=o.message;if(r){q=o.originalArguments;p=g+this._indentation(m);p+=q?this._argumentsToString(q):r}else{k=o.indentation;n=o.title;b=k-m;if(b>0){p=g+this._indentation(m)+c.fmt(n)}m=k}j+=p+"\n"}}return j},log:function(){var a=this.get("reporter"),c=arguments[0],d=this.get("messagePrefix"),e=this.get("outputMessagePrefix"),b=NO;if(c&&SC.typeOf(c)===SC.T_STRING){if(d||e){if(d){c=d+c}if(e){c=e+c}arguments[0]=c}}if(this.get("exists")){if(typeof a.log==="function"){a.log.apply(a,arguments);b=YES}else{if(a.log){a.log(this._argumentsToArray(arguments));b=YES}}}if(!b&&this.get("fallBackOnAlert")){if(this.get("exists")&&(typeof a.alert==="function")){a.alert(arguments);b=YES}else{alert(arguments);b=YES}}return b},group:function(b){var a=this.get("reporter");if(this.get("exists")&&(typeof a.group==="function")){a.group(b)}},groupEnd:function(){var a=this.get("reporter");if(this.get("exists")&&(typeof a.groupEnd==="function")){a.groupEnd()}},dir:function(){var a=this.get("reporter");if(this.get("exists")&&(typeof a.dir==="function")){a.dir.apply(a,arguments)}else{this.log.apply(this,arguments)}},dirxml:function(){var a=this.get("reporter");if(this.get("exists")&&(typeof a.dirxml==="function")){a.dirxml.apply(a,arguments)}else{this.log.apply(this,arguments)}},profile:function(b){var a=this.get("reporter");if(this.get("exists")&&(typeof a.profile==="function")){a.profile(b);return YES}return NO},profileEnd:function(b){var a=this.get("reporter");if(this.get("exists")&&(typeof a.profileEnd==="function")){a.profileEnd(b);return YES}return NO},time:function(b){var a=this.get("reporter");if(this.get("exists")&&(typeof a.time==="function")){a.time(b);return YES}return NO},timeEnd:function(b){var a=this.get("reporter");if(this.get("exists")&&(typeof a.timeEnd==="function")){a.timeEnd(b);return YES}return NO},trace:function(){var a=this.get("reporter");if(this.get("exists")&&(typeof a.trace==="function")){a.trace();return YES}return NO},init:function(){arguments.callee.base.apply(this,arguments);if(!this.get("logOutputLevel")){if(SC.buildMode==="debug"){this.set("logOutputLevel",SC.LOGGER_LEVEL_DEBUG)}else{this.set("logOutputLevel",SC.LOGGER_LEVEL_INFO)}}this.debugEnabledDidChange()},debugEnabledDidChange:function(){if(this.get("debugEnabled")){this.set("logOutputLevel",SC.LOGGER_LEVEL_DEBUG)}}.observes("debugEnabled"),_handleMessage:function(l,n,p,o){var a=this._shouldOutputType(l),d=this._shouldRecordType(l),e,f,j,k,b,m,h,c,g;if(!(a||d)){return}e=(o&&o.length>1);if(n&&(SC.none(p)||(typeof p!=="string"))){n=NO}if(n){if(e){k=[];for(f=1,j=o.length;f<j;++f){k.push(o[f])}p=p.fmt.apply(p,k)}}h=this.get("messagePrefix");if(h){p=h+p}if(a){c=this.get("outputMessagePrefix");k=n?null:o;this._outputMessage(l,null,this._outputIndentationLevel,(c?c+p:p),k)}if(d){g=this.get("recordedMessagePrefix");m={type:l,message:p?(g?g+p:p):YES,timestamp:new Date()};if(!n&&e){m.originalArguments=o}this._addRecordedMessageEntry(m)}},_handleGroup:function(l,n,q){var a=this._shouldOutputType(l),e=this._shouldRecordType(l),f,g,j,k,p,d,c,h,b,m,o;if(!(a||e)){return}f=(q&&q.length>1);if(n&&f){k=[];for(g=1,j=q.length;g<j;++g){k.push(q[g])}n=n.fmt.apply(n,k)}if(a){this._outputGroup(l,null,this._outputIndentationLevel,n);this._outputIndentationLevel++}if(e){m=++this._recordingIndentationLevel;o={type:l,indentation:m,beginGroup:YES,title:n,timestamp:new Date()};this._addRecordedMessageEntry(o)}},_handleGroupEnd:function(d){var g=this._shouldOutputType(d),c=this._shouldRecordType(d),a,f,b,e;if(!(g||c)){return}if(g){this._outputIndentationLevel--;if(this.get("exists")){a=this.get("reporter");f=a.groupEnd;if(f){f.call(a)}}}if(c){b=--this._recordingIndentationLevel;e={type:d,indentation:b,timestamp:new Date()};this._addRecordedMessageEntry(e)}},_shouldOutputType:function(a){var c=this._LOG_LEVEL_MAPPING,d=c[a]||0,b=c[this.get("logOutputLevel")]||0;return(d<=b)},_shouldRecordType:function(a){var c=this._LOG_LEVEL_MAPPING,d=c[a]||0,b=c[this.get("logRecordingLevel")]||0;return(d<=b)},_outputMessage:function(h,g,i,l,k){if(!this.get("exists")){return}var d=this.get("reporter"),b,a,c,e,f,j;a=!d.group;c=d[h];if(c){if(!k){b=g?g:"";if(a){b+=this._indentation(i)}b+=l;d[h](b)}else{f=this._argumentsToArray(k);e="";if(g){e=g}if(a){e+=this._indentation(i)}if(e){f.splice(0,0,e)}if(c.apply){c.apply(d,f)}else{d[h](f)}}}else{if(d.log){e="";if(g){e=g}e+=this._LOG_FALLBACK_PREFIX_MAPPING[h]||"";if(a){e+=this._indentation(i)}if(!k){d.log(e+l)}else{f=this._argumentsToArray(k);if(e){f.splice(0,0,e)}d.log(f)}}}},_outputGroup:function(d,f,c,g){if(!this.get("exists")){return}var b=this.get("reporter"),e=b.group,a;if(e){a=f?f:"";a+=g;e.call(b,a)}else{if(b.log){a="";if(f){a=f}a+=this._LOG_FALLBACK_PREFIX_MAPPING[d]||"";a+=this._indentation(c);a+=SC.LOGGER_LOG_GROUP_HEADER.fmt(g);b.log(a)}}},_addRecordedMessageEntry:function(c){var b=this.get("recordedLogMessages"),a;if(!b){b=[];this.set("recordedLogMessages",b)}b.push(c);a=b.length;if(a>this.get("recordedLogMessagesMaximumLength")){b.splice(0,(a-this.get("recordedLogMessagesPruningMinimumLength")))}b.enumerableContentDidChange()},_argumentsToArray:function(c){var b=[],d,a;if(c){for(d=0,a=c.length;d<a;++d){b[d]=c[d]}}return b},_argumentsToString:function(){var c="",b=SC.LOGGER_LOG_DELIMITER,d,a;for(d=0,a=(arguments.length-1);d<a;++d){c+=arguments[d]+b}c+=arguments[a];return c},_indentation:function(d){if(!d||d<0){d=0}var b="",a=SC.LOGGER_LOG_GROUP_INDENTATION,c;for(c=0;c<d;++c){b+=a}return b},_outputIndentationLevel:0,_recordingIndentationLevel:0,_LOG_LEVEL_MAPPING:{debug:4,info:3,warn:2,error:1,none:0},_LOG_FALLBACK_PREFIX_MAPPING:{debug:SC.LOGGER_LOG_DEBUG,info:SC.LOGGER_LOG_INFO,warn:SC.LOGGER_LOG_WARN,error:SC.LOGGER_LOG_ERROR}});SC.debug=SC.Logger.debug;SC.info=SC.Logger.info;SC.warn=SC.Logger.warn;SC.error=SC.Logger.error;sc_require("ext/function");sc_require("private/observer_set");SC.RunLoop=SC.Object.extend({beginRunLoop:function(){this._start=new Date().getTime();this._runLoopInProgress=YES;this._flushinvokeNextQueue();return this},isRunLoopInProgress:function(){return this._runLoopInProgress}.property(),endRunLoop:function(){this.flushAllPending();this._start=null;SC.RunLoop.lastRunLoopEnd=Date.now();this._runLoopInProgress=NO;var a=this._invokeNextQueue;if(a&&a.getMembers().length){this._invokeNextTimeout=this.scheduleRunLoop(SC.RunLoop.lastRunLoopEnd)}return this},flushAllPending:function(){var a;do{a=this.flushApplicationQueues();if(!a){a=this._flushinvokeLastQueue()}}while(a)},invokeOnce:function(b,c){if(c===undefined){c=b;b=this}var a;if(typeof c==="string"){c=b[c]}if(!this._invokeQueue){this._invokeQueue=SC.ObserverSet.create()}if(c){this._invokeQueue.add(b,c,undefined,a)}return this},invokeLast:function(b,c){if(c===undefined){c=b;b=this}var a;if(typeof c==="string"){c=b[c]}if(!this._invokeLastQueue){this._invokeLastQueue=SC.ObserverSet.create()}this._invokeLastQueue.add(b,c,undefined,a);return this},invokeNext:function(a,b){if(b===undefined){b=a;a=this}if(typeof b==="string"){b=a[b]}if(!this._invokeNextQueue){this._invokeNextQueue=SC.ObserverSet.create()}this._invokeNextQueue.add(a,b);return this},flushApplicationQueues:function(){var b=NO,a=this._invokeQueue;if(a&&a.getMembers().length){this._invokeQueue=null;b=YES;a.invokeMethods()}return SC.Binding.flushPendingChanges()||b},_flushinvokeLastQueue:function(){var a=this._invokeLastQueue,b=NO;if(a&&a.getMembers().length){this._invokeLastQueue=null;b=YES;if(b){a.invokeMethods()}}return b},_flushinvokeNextQueue:function(){var a=this._invokeNextQueue,b=NO;if(a&&a.getMembers().length){this._invokeNextQueue=null;b=YES;if(b){a.invokeMethods()}}return b},scheduleRunLoop:function(b){if(this._timeoutAt==null||this._timeoutAt>b){if(this._timeout){clearTimeout(this._timeout)}var a=Math.max(0,b-Date.now());this._timeout=setTimeout(this._timeoutDidFire,a);this._timeoutAt=b}return this._timeout},_timeoutDidFire:function(){var a=SC.RunLoop.currentRunLoop;a._timeout=a._timeoutAt=a._invokeNextTimeout=null;SC.run()},unscheduleRunLoop:function(){if(!this._invokeNextTimeout){clearTimeout(this._timeout);this._timeout=this._timeoutAt=null}}});SC.RunLoop.currentRunLoop=null;SC.RunLoop.runLoopClass=SC.RunLoop;SC.RunLoop.begin=function(){var a=this.currentRunLoop;if(!a){a=this.currentRunLoop=this.runLoopClass.create()}a.beginRunLoop();return this};SC.RunLoop.end=function(){var a=this.currentRunLoop;if(!a){throw new Error("SC.RunLoop.end() called outside of a runloop!")}a.endRunLoop();return this};SC.RunLoop.kill=function(){this.currentRunLoop=this.runLoopClass.create();return this};SC.RunLoop.isRunLoopInProgress=function(){if(this.currentRunLoop){return this.currentRunLoop.get("isRunLoopInProgress")}return NO};SC.run=function(g,f,b){var a=SC.RunLoop.isRunLoopInProgress();try{try{if(b||!a){SC.RunLoop.begin()}if(g){g.call(f)}}finally{if(b||!a){SC.RunLoop.end()}}}catch(d){var c=false;if(SC.ExceptionHandler&&SC.ExceptionHandler.enabled){c=SC.ExceptionHandler.handleException(d)}if(SC.RunLoop.isRunLoopInProgress()){SC.RunLoop.kill()}if(!c&&!SC.browser.isIE){throw d}}};SC.RunLoop.wrapFunction=function(b){var a=function(){var c=SC.RunLoop.isRunLoopInProgress();if(!c){SC.RunLoop.begin()}var d=arguments.callee.wrapped.apply(this,arguments);if(!c){SC.RunLoop.end()}return d};a.wrapped=b;return a};SC.DROP_ON=1;SC.DROP_BEFORE=2;SC.DROP_AFTER=4;SC.DROP_ANY=7;SC.ALIGN_LEFT="left";SC.ALIGN_RIGHT="right";SC.ALIGN_CENTER="center";SC.ALIGN_TOP="top";SC.ALIGN_MIDDLE="middle";SC.ALIGN_BOTTOM="bottom";SC.ALIGN_TOP_LEFT="top-left";SC.ALIGN_TOP_RIGHT="top-right";SC.ALIGN_BOTTOM_LEFT="bottom-left";SC.ALIGN_BOTTOM_RIGHT="bottom-right";SC.ALIGN_DEFAULT="default";SC.POSITION_RIGHT=0;SC.POSITION_LEFT=1;SC.POSITION_TOP=2;SC.POSITION_BOTTOM=3;SC.mixin({data:$.data,removeData:$.removeData,STRINGS:{},stringsFor:function(b,a){SC.mixin(SC.STRINGS,a);return this},viewFor:function(d){if(!(d instanceof Element)){SC.error("Developer Error: Attempt to retrieve the SC.View instance for a non-element in SC.viewFor(): %@".fmt(d));return null}var c=SC.View.views,b=c[d.getAttribute("id")];if(!b){var a;while(!b&&(a=d.parentNode)&&(a!==document)){var e;if((e=a.getAttribute("id"))){b=c[e]}d=a}d=a=null}return b||null}});SC.mixin(SC.browser,{_cachedNames:null,_testEl:null,_testSupportFor:function(e,b,d){var c=e[b]!=null,a;if(d!=null){a=e[b];e[b]=d;c=e[b]===d;e[b]=a}return c},compare:function(c,a){var f,g,e;if(typeof c==="number"||typeof a==="number"){c=String(c);a=String(a)}f=function(h){return Number(h.match(/^[0-9]+/))};g=SC.A(c.split(".")).map(f);e=SC.A(a.split(".")).map(f);for(var d=0;d<e.length;d++){var b=g[d]-e[d];if(isNaN(b)){return 0}if(b!==0){return b}}return 0},experimentalNameFor:function(d,b,c){var a=b;if(!this._testSupportFor(d,a,c)){a=SC.browser.classPrefix+b.capitalize();if(!this._testSupportFor(d,a,c)){if(SC.browser.domPrefix===SC.browser.classPrefix){SC.warn("SC.browser.experimentalNameFor(): target, %@, does not have property `%@` or `%@`.".fmt(d,b,a));a=SC.UNSUPPORTED}else{a=SC.browser.domPrefix+b.capitalize();if(!this._testSupportFor(d,a,c)){SC.warn("SC.browser.experimentalNameFor(): target, %@, does not have property `%@`, '%@' or `%@`.".fmt(d,b,SC.browser.classPrefix+b.capitalize(),a));a=SC.UNSUPPORTED}}}}return a},experimentalStyleNameFor:function(c,e){var d=this._sc_experimentalStyleNames,a;if(!d){d=this._sc_experimentalStyleNames={}}if(d[c]){a=d[c]}else{var b=this._testEl;if(!b){b=this._testEl=document.createElement("div")}a=d[c]=this.experimentalNameFor(b.style,c,e)}return a},experimentalCSSNameFor:function(a,e){var b=a,d=a.camelize(),c=this.experimentalStyleNameFor(d,e);if(c===SC.UNSUPPORTED){b=SC.UNSUPPORTED}else{if(c!==d){b=SC.browser.cssPrefix+a}}return b}});SC.Builder=function(a){return SC.Builder.create(a)};SC.Builder.create=function create(c){var b=SC.mixin(SC.beget(this.fn),c||{});if(c.hasOwnProperty("toString")){b.toString=c.toString}var a=function(){var d=SC.beget(b);d.defaultClass=this;d.constructor=a;return d.init.apply(d,arguments)};a.fn=a.prototype=b;a.extend=SC.Builder.create;a.mixin=SC.Builder.mixin;return a};SC.Builder.mixin=function(){var b=arguments.length,a;for(a=0;a<b;a++){SC.mixin(this,arguments[a])}return this};SC.Builder.fn={init:function(a){if(a!==undefined){if(SC.typeOf(a)===SC.T_ARRAY){var b=a.length;while(--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,c=SC.Builder.fn,b,d;for(b in a){if(!a.hasOwnProperty(b)){continue}d=Array.prototype[b]||a[b];c[b]=d}})();sc_require("system/builder");SC.$=SC.CoreQuery=jQuery;SC.mixin(SC.$.fn,{isCoreQuery:YES,toString:function(){var c=[],b=this.length,a=0;for(a=0;a<b;a++){c[a]="%@: %@".fmt(a,this[a]?this[a].toString():"(null)")}return"<$:%@>(%@)".fmt(SC.guidFor(this),c.join(" , "))},isVisible:function(){return Array.prototype.every.call(this,function(a){return SC.$.isVisible(a)})},view:function(){return SC.viewFor(this[0])},within:function(a){if(this.filter(a).length){return true}return !!this.has(a).length}});(function(){var c={},f={find:function(h,g){return(g!==undefined)?SC.Enumerable.find.call(this,h,g):c.find.call(this,h)},filter:function(h,g){return(g!==undefined)?this.pushStack(SC.Enumerable.filter.call(this,h,g)):c.filter.call(this,h)},filterProperty:function(g,h){return this.pushStack(SC.Enumerable.filterProperty.call(this,g,h))},indexOf:SC.$.index,map:function(h,g){return(g!==undefined)?SC.Enumerable.map.call(this,h,g):c.map.call(this,h)}};var d=SC.$.fn,a=SC.Enumerable,e;for(var b in a){if(a.hasOwnProperty(b)){e=a[b];if(b in f){c[b]=d[b];e=f[b]}d[b]=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){this._sc_updateNormalizedEvent(a);return this};SC.mixin(SC.Event,{MOUSE_WHEEL_MULTIPLIER:function(){var b=1,a=SC.browser.engineVersion;if(SC.browser.name===SC.BROWSER.safari){b=0.4;if(SC.browser.compare(a,"533.17")>0&&SC.browser.compare(a,"534")<0){b=0.004}else{if(SC.browser.compare(a,"533")<0){b=40}}}else{if(SC.browser.name===SC.BROWSER.ie){b=0.3}else{if(SC.browser.name===SC.BROWSER.chrome){b=0.4}}}return b}(),MOUSE_WHEEL_DELTA_LIMIT:1000,_MOUSE_WHEEL_LIMIT_INVALIDATED:NO,create:function(a){return new SC.Event(a)},add:function(f,e,g,h,d,a){if(f&&f.isCoreQuery){if(f.length>0){f.forEach(function(i){this.add(i,e,g,h,d)},this);return this}else{f=f[0]}}if(!f){return this}if(!a){a=NO}if(f.nodeType===3||f.nodeType===8){return SC.Event}if(SC.browser.name===SC.BROWSER.ie&&f.setInterval){f=window}if(SC.typeOf(g)===SC.T_FUNCTION){d=h;h=g;g=null}else{if(g&&SC.typeOf(h)===SC.T_STRING){h=g[h]}}var c=SC.data(f,"sc_events")||SC.data(f,"sc_events",{}),b=c[e];if(!b){b=c[e]={};this._addEventListener(f,e,a)}b[SC.hashFor(g,h)]=[g,h,d];SC.Event._global[e]=YES;f=c=b=null;return this},remove:function(c,b,f,a){if(c&&c.isCoreQuery){if(c.length>0){c.forEach(function(j){this.remove(j,b,f,a)},this);return this}else{c=c[0]}}if(!c){return this}if(c.nodeType===3||c.nodeType===8){return SC.Event}var d,g,i=SC.data(c,"sc_events");if(!i){return this}if(b===undefined){for(var h in i){this.remove(c,h)}}else{if((d=i[b])){var e=NO;if(f||a){if(SC.typeOf(f)===SC.T_FUNCTION){a=f;f=null}else{if(SC.typeOf(a)===SC.T_STRING){a=f[a]}}delete d[SC.hashFor(f,a)];g=null;for(g in d){break}if(g===null){e=YES}}else{e=YES}if(e){delete i[b];this._removeEventListener(c,b)}g=null;for(g in i){break}if(!g){SC.removeData(c,"sc_events");delete this._elements[SC.guidFor(c)];SC.removeData(c,"listener")}}}c=i=d=null;return this},NO_BUBBLE:["blur","focus","change"],simulateEvent:function(d,c,b){var a=SC.Event.create({type:c,target:d,preventDefault:function(){this.cancelled=YES},stopPropagation:function(){this.bubbles=NO},allowDefault:function(){this.hasCustomEventHandling=YES},timeStamp:Date.now(),bubbles:(this.NO_BUBBLE.indexOf(c)<0),cancelled:NO,normalized:YES,simulated:true});if(b){SC.mixin(a,b)}return a},trigger:function(c,b,a,i){if(c&&c.isCoreQuery){if(c.length>0){c.forEach(function(l){this.trigger(l,b,a,i)},this);return this}else{c=c[0]}}if(!c){return this}if(c.nodeType===3||c.nodeType===8){return undefined}if(SC.typeOf(a)===SC.T_ARRAY){a=a[0]}var h,j=SC.typeOf(c[b]||null)===SC.T_FUNCTION,g,d,k;if(!a||!a.preventDefault){a=this.simulateEvent(c,b)}a.type=b;g=c;do{h=SC.Event.handle.call(g,a);g=(g===document)?null:(g.parentNode||document)}while(!h&&a.bubbles&&g);g=null;d=c["on"+b];k=SC.$.nodeName(c,"a")&&b==="click";if((!j||k)&&d&&d.call(c,a)===NO){h=NO}if(j&&i!==NO&&h!==NO&&!k){this.triggered=YES;try{c[b]()}catch(f){}}this.triggered=NO;return h},handle:function(e){if((typeof SC==="undefined")||SC.Event.triggered){return true}var g,b,a,h,f;a=(SC.data(this,"sc_events")||{})[e.type];if(!a){g=false}else{e=SC.Event.normalizeEvent(e||window.event);for(var c in a){var d=a[c];h=d[1];e.handler=h;e.data=e.context=d[2];f=d[0]||this;b=h.call(f,e);if(g!==false){g=b}if(b===false){e.preventDefault();e.stopPropagation()}}if(e.originalEvent&&!e.originalEvent.simulated){e._sc_clearNormalizedEvent()}}return g},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();return},teardown:function(){return}},mouseenter:{setup:function(){if(SC.browser.name===SC.BROWSER.ie){return NO}SC.Event.add(this,"mouseover",SC.Event.special.mouseenter.handler);return YES},teardown:function(){if(SC.browser.name===SC.BROWSER.ie){return NO}SC.Event.remove(this,"mouseover",SC.Event.special.mouseenter.handler);return YES},handler:function(a){if(SC.Event._withinElement(a,this)){return YES}a.type="mouseenter";return SC.Event.handle.call(this,a)}},mouseleave:{setup:function(){if(SC.browser.name===SC.BROWSER.ie){return NO}SC.Event.add(this,"mouseout",SC.Event.special.mouseleave.handler);return YES},teardown:function(){if(SC.browser.name===SC.BROWSER.ie){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.call(this,a)}}},KEY_BACKSPACE:8,KEY_TAB:9,KEY_RETURN:13,KEY_ESC:27,KEY_SPACE:32,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(d,c){var b=d.relatedTarget;while(b&&b!==c){try{b=b.parentNode}catch(a){b=c}}return b===c},_addEventListener:function(f,d,a){var g,c=this.special[d];if(!a){a=false}if(!c||c.setup.call(f)===false){var b=SC.guidFor(f);this._elements[b]=f;g=SC.data(f,"listener")||SC.data(f,"listener",function e(h){return SC.Event.handle.call(SC.Event._elements[b],h)});if(f.addEventListener){f.addEventListener(d,g,a)}else{if(f.attachEvent){f.attachEvent("on"+d,g)}}}f=c=g=null},_removeEventListener:function(c,b){var d,a=SC.Event.special[b];if(!a||(a.teardown.call(c)===NO)){d=SC.data(c,"listener");if(d){if(c.removeEventListener){c.removeEventListener(b,d,NO)}else{if(c.detachEvent){c.detachEvent("on"+b,d)}}}}c=a=d=null},_elements:{},_sc_normalizedEvents:null,normalizeEvent:function(b){var a;if(!this._sc_normalizedEvents){this._sc_normalizedEvents={}}a=this._sc_normalizedEvents[b.type];if(!a){if(b===window.event){a=SC.Event.create(b)}else{a=b.normalized?b:SC.Event.create(b)}}else{if(b.normalized){a=b}else{a._sc_updateNormalizedEvent(b)}}this._sc_normalizedEvents[b.type]=a;return a},_global:{},_props:["altKey","attrChange","attrName","bubbles","button","cancelable","charCode","clientX","clientY","ctrlKey","currentTarget","data","detail","fromElement","handler","keyCode","metaKey","newValue","originalTarget","pageX","pageY","prevValue","relatedNode","relatedTarget","screenX","screenY","shiftKey","srcElement","target","timeStamp","toElement","type","view","which","touches","targetTouches","changedTouches","animationName","elapsedTime","dataTransfer"]});SC.Event.prototype={hasCustomEventHandling:false,_sc_clearNormalizedEvent:function(){this.originalEvent=null;this.hasCustomEventHandling=false;this.normalized=false;var c=SC.Event._props,a;a=c.length;while(--a>=0){var b=c[a];this[b]=null}this.timeStamp=null;this.target=null;this.relatedTarget=null;this.pageX=null;this.pageY=null;this.which=null;this.metaKey=null;this.wheelDelta=null;this.wheelDeltaY=null;this.wheelDeltaX=null},_sc_updateNormalizedEvent:function(d){var c,b;this.normalized=true;if(d){this.originalEvent=d;var g=SC.Event._props,f;b=g.length;c=b;while(--c>=0){f=g[c];this[f]=d[f]}}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)){var h=document.documentElement,a=document.body;this.pageX=this.clientX+(h&&h.scrollLeft||a&&a.scrollLeft||0)-(h.clientLeft||0);this.pageY=this.clientY+(h&&h.scrollTop||a&&a.scrollTop||0)-(h.clientTop||0)}if(!this.which&&((this.charCode||d.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(this.type==="mousewheel"||this.type==="DOMMouseScroll"||this.type==="MozMousePixelScroll"){var e=SC.Event.MOUSE_WHEEL_MULTIPLIER;if(SC.browser.isWebkit&&d.wheelDelta!==undefined){this.wheelDelta=0-(d.wheelDeltaY||d.wheelDeltaX);this.wheelDeltaY=0-(d.wheelDeltaY||0);this.wheelDeltaX=0-(d.wheelDeltaX||0)}else{if(!SC.none(d.detail)&&SC.browser.isMozilla){if(d.axis&&(d.axis===d.HORIZONTAL_AXIS)){this.wheelDeltaX=d.detail;this.wheelDelta=this.wheelDeltaY=0}else{this.wheelDelta=this.wheelDeltaY=d.detail;this.wheelDeltaX=0}}else{this.wheelDelta=this.wheelDeltaY=SC.browser.isIE||SC.browser.isOpera?0-d.wheelDelta:d.wheelDelta;this.wheelDeltaX=0}}this.wheelDelta*=e;this.wheelDeltaX*=e;this.wheelDeltaY*=e}},touchesForView:function(a){if(this.touchContext){return this.touchContext.touchesForView(a)}},touchesForResponder:function(a){if(this.touchContext){return this.touchContext.touchesForView(a)}},averagedTouchesForView:function(a){if(this.touchContext){return this.touchContext.averagedTouchesForView(a)}return null},allowDefault:function(){this.hasCustomEventHandling=YES;return this},preventDefault:function(){var a=this.originalEvent;if(a&&a.type!=="mousewheel"){if(a.preventDefault){a.preventDefault()}else{a.returnValue=NO}}this.hasCustomEventHandling=YES;return this},stopPropagation:function(){var a=this.originalEvent;if(a){if(a.stopPropagation){a.stopPropagation()}a.cancelBubble=YES}this.hasCustomEventHandling=YES;return this},stop:function(){return this.preventDefault().stopPropagation()},normalized:YES,getCharString:function(){if(SC.browser.name===SC.BROWSER.ie&&SC.browser.compare(SC.browser.version,"9.0")<0){if(this.keyCode===8||this.keyCode===9||(this.keyCode>=37&&this.keyCode<=40)){return String.fromCharCode(0)}else{return(this.keyCode>0)?String.fromCharCode(this.keyCode):null}}else{return(this.charCode>0)?String.fromCharCode(this.charCode):null}},commandCodes:function(){var b=this.charCode,f=this.keyCode,a=null,e=null,d;if(f&&f!==b){e=SC.FUNCTION_KEYS[f]}if(e){d=e}else{d=SC.PRINTABLE_KEYS[f]}if(d){var c="";if(this.ctrlKey||this.metaKey){c+="ctrl_"}if(this.altKey){c+="alt_"}if(this.shiftKey){c+="shift_"}e=c+d}a=this.getCharString();return[e,a]}};SC.Event.observe=SC.Event.add;SC.Event.stopObserving=SC.Event.remove;SC.Event.fire=SC.Event.trigger;if(SC.browser.name===SC.BROWSER.ie){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.SYSTEM_CURSOR=SC.DEFAULT_CURSOR="default";SC.AUTO_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,c=this.constructor.sharedStyleSheet(),b=SC.guidFor(this);if(c.insertRule){c.insertRule("."+b+" {cursor: "+a+";}",c.cssRules?c.cssRules.length:0)}else{if(c.addRule){c.addRule("."+b,"cursor: "+a)}}this.cursorStyle=a;this.className=b;return this},className:null,cursorStyle:SC.DEFAULT_CURSOR,cursorStyleDidChange:function(){var d,f,c,e,g,b,a;d=this.get("cursorStyle")||SC.DEFAULT_CURSOR;f=this._rule;if(f){f.style.cursor=d;return}c="."+this.get("className");e=this.constructor.sharedStyleSheet();g=(e.cssRules?e.cssRules:e.rules)||[];for(b=0,a=g.length;b<a;++b){f=g[b];if(f.selectorText===c){this._rule=f;f.style.cursor=d;break}}}.observes("cursorStyle")});SC.Cursor.sharedStyleSheet=function(){var d,c,b=this._styleSheet;if(!b){d=document.createElement("style");c=document.getElementsByTagName("head")[0];if(!c){c=document.documentElement}c.appendChild(d);for(var a=document.styleSheets.length-1;a>=0;a--){b=document.styleSheets[a];if(b.ownerNode===d){this._styleSheet=b;break}}}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();if(a&&this.get("acceptsFirstResponder")){if(a.get("firstResponder")!==this){a.makeFirstResponder(this)}}return this},resignFirstResponder:function(a){var b=this.get("pane")||this.get("responderContext");if(b&&(b.get("firstResponder")===this)){b.makeFirstResponder(null,a)}return YES},willLoseFirstResponder:function(a){},didBecomeFirstResponder:function(a){},destroy:function(){this.resignFirstResponder();arguments.callee.base.apply(this,arguments)}});SC.Theme={isTheme:YES,classNames:[],_extend_class_names:function(c){if(c){if(SC.typeOf(c)===SC.T_HASH&&!c.isSet){for(var b in c){var a=this.classNames.indexOf(b);if(c[b]&&a<0){this.classNames.push(b)}else{if(a>=0){this.classNames.removeAt(a)}}}}else{if(typeof c==="string"){c=c.split(" ")}c.forEach(function(d){if(!this.classNames.contains(d)){this.classNames.push(d)}},this)}}},_extend_self:function(b){if(b.classNames){this._extend_class_names(b.classNames)}var a,c,d;for(a in b){if(a==="classNames"){continue}if(!b.hasOwnProperty(a)){continue}c=b[a];if(c instanceof Function&&!c.base&&(c!==(d=this[a]))){c.base=d}this[a]=c}},create:function(){var c=SC.beget(this);c.baseTheme=this;if(this.themes===SC.Theme.themes){c.themes={}}else{c.themes=SC.beget(this.themes)}c._privateThemes={};c._specializedThemes={};c.classNames=SC.clone(this.classNames);var e=arguments,b=e.length,a,d;for(a=0;a<b;a++){c._extend_self(e[a])}if(c.name&&!c.classNames.contains(c.name)){c.classNames.push(c.name)}return c},subtheme:function(a){var b=this.create({name:a});this.addTheme(b);return b},invisibleSubtheme:function(a){var b=this.create({name:a});this._privateThemes[a]=b;return b},themes:{},find:function(a){if(this===SC.Theme){return this.themes[a]}var b;b=this._privateThemes[a];if(b){return b}b=this._specializedThemes[a];if(b){return b}b=this.themes[a];if(b&&!this._specializedThemes[a]){return(this._specializedThemes[a]=b.create({classNames:this.classNames}))}b=SC.Theme.themes[a];if(b){return b}return null},addTheme:function(a){this.themes[a.name]=a}};SC.BaseTheme=SC.Theme.create({name:""});SC.Theme.themes["sc-base"]=SC.BaseTheme;SC.defaultTheme="sc-base";SC.Locale=SC.Object.extend({init:function(){if(!this.language){SC.Locale._assignLocales()}if(!this.hasStrings){var c=this._deprecatedLanguageCodes||[];c.push(this.language);var b=c.length;var a=null;while(!a&&--b>=0){a=String[c[b]]}if(a){this.hasStrings=YES;this.strings=a}}},hasStrings:NO,strings:{},metrics:{},inflectionConstants:null,ordinalForNumber:function(a){return""},toString:function(){if(!this.language){SC.Locale._assignLocales()}return"SC.Locale["+this.language+"]"+SC.guidFor(this)},locWithDefault:function(b,c){var a=this.strings[b];if(SC.typeOf(a)===SC.T_STRING){return a}else{if(SC.typeOf(c)===SC.T_STRING){return c}}return b},locMetric:function(b){var a=this.metrics[b];if(SC.typeOf(a)===SC.T_NUMBER){return a}else{if(a===undefined){SC.warn('No localized metric found for key "'+b+'"');return undefined}else{SC.warn('Unexpected metric type for key "'+b+'"');return undefined}}},locLayout:function(c,b){var e,g,f,m,l,a=SC.Locale.layoutKeys,k=this.metrics,j=SC.typeOf,d=SC.T_NUMBER,h={};if(b){SC.mixin(h,b)}for(e=0,g=a.length;e<g;++e){f=a[e];m=c+"."+f;l=k[m];if(j(l)===d){if(b&&b[f]){throw new Error("locLayout():  There is a localized value for the key '"+m+"' but a value for '"+f+"' was also specified in the non-localized hash")}h[f]=l}}return h}});SC.Locale.mixin({useAutodetectedLanguage:NO,preferredLanguage:null,layoutKeys:["left","top","right","bottom","width","height","minWidth","minHeight","centerX","centerY"],createCurrentLocale:function(){var c=(String.useAutodetectedLanguage!==undefined)?String.useAutodetectedLanguage:this.useAutodetectedLanguage;var b=(String.preferredLanguage!==undefined)?String.preferredLanguage:this.preferredLanguage;var d=((c)?SC.browser.language:null)||b||SC.browser.language||"en";d=SC.Locale.normalizeLanguage(d);var a=this.localeClassFor(d);if(d!=this.currentLanguage){this.currentLanguage=d;this.currentLocale=a.create()}return this.currentLocale},localeClassFor:function(c){c=SC.Locale.normalizeLanguage(c);var b,a=this.locales[c];if(!a&&((b=c.split("-")[0])!==c)&&(a=this.locales[b])){a=this.locales[c]=a.extend()}if(!a){a=this.locales[c]=this.locales.en.extend()}return a},define:function(b,c){var a;if(c===undefined&&(SC.typeOf(b)!==SC.T_STRING)){a=this;c=b}else{a=SC.Locale.localeClassFor(b)}SC.mixin(a.prototype,c);return a},options:function(){return this.prototype},addHashes:function(a,c){var b=this.prototype[a];if(b){if(!this.prototype.hasOwnProperty(b)){b=this.prototype[a]=SC.clone(b)}}else{b=this.prototype[a]={}}if(c){this.prototype[a]=SC.mixin(b,c)}return this},addMethod:function(a,b){this.prototype[a]=b;return this},addStrings:function(a){var b=this.addHashes("strings",a);this.prototype.hasStrings=YES;return b},addMetrics:function(a){return this.addHashes("metrics",a)},_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(){if(!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.hashesForLocale=function(d,b,c){var a=SC.Locale.localeClassFor(d);a.addHashes(b,c)};SC.methodForLocale=function(c,b,d){var a=SC.Locale.localeClassFor(c);a.addMethod(b,d)};SC.stringsFor=function(c,b){var a=SC.Locale.localeClassFor(c);a.addStrings(b);return this};SC.metricsFor=function(c,b){var a=SC.Locale.localeClassFor(c);a.addMetrics(b);return this};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_DASHERIZE_CACHE={};SC.STRING_TRIM_LEFT_REGEXP=(/^\s+/g);SC.STRING_TRIM_RIGHT_REGEXP=(/\s+$/g);SC.STRING_CSS_ESCAPED_REGEXP=(/(:|\.|\[|\])/g);SC.mixin(SC.String,{capitalize:function(a){return a.charAt(0).toUpperCase()+a.slice(1)},camelize:function(d){var b=d.replace(SC.STRING_TITLEIZE_REGEXP,function(f,g,e){return e?e.toUpperCase():""});var c=b.charAt(0),a=c.toLowerCase();return c!==a?a+b.slice(1):b},decamelize:function(a){return a.replace(SC.STRING_DECAMELIZE_REGEXP,"$1_$2").toLowerCase()},dasherize:function(c){var a=SC.STRING_DASHERIZE_CACHE,b=a[c];if(b){return b}else{b=SC.String.decamelize(c).replace(SC.STRING_DASHERIZE_REGEXP,"-");a[c]=b}return b},escapeCssIdForSelector:function(a){return a.replace(SC.STRING_CSS_ESCAPED_REGEXP,"\\$1")},loc:function(d){if(!SC.Locale.currentLocale){SC.Locale.createCurrentLocale()}var b=SC.Locale.currentLocale.locWithDefault(d);if(SC.typeOf(b)!==SC.T_STRING){b=d}var a=SC.$A(arguments);a.shift();if(a.length>0&&a[0]&&a[0].isSCArray){a=a[0]}try{return SC.String.fmt(b,a)}catch(c){SC.error("Error processing string with key: "+d);SC.error("Localized String: "+b);SC.error("Error: "+c)}},locMetric:function(b){var a=SC.Locale,c=a.currentLocale;if(!c){a.createCurrentLocale();c=a.currentLocale}return c.locMetric(b)},locLayout:function(b,c){var a=SC.Locale,d=a.currentLocale;if(!d){a.createCurrentLocale();d=a.currentLocale}return d.locLayout(b,c)},locWithDefault:function(d,c){if(!SC.Locale.currentLocale){SC.Locale.createCurrentLocale()}var b=SC.Locale.currentLocale.locWithDefault(d,c);if(SC.typeOf(b)!==SC.T_STRING){b=d}var a=SC.$A(arguments);a.shift();a.shift();return SC.String.fmt(b,a)},trim:jQuery.trim,trimLeft:function(a){return a.replace(SC.STRING_TRIM_LEFT_REGEXP,"")},trimRight:function(a){return a.replace(SC.STRING_TRIM_RIGHT_REGEXP,"")},mult:function(d,c){if(SC.typeOf(c)!==SC.T_NUMBER||c<1){return null}var a="";for(var b=0;b<c;b+=1){a+=d}return a}});if(String.prototype.trim){SC.supplement(String.prototype,{trim:function(){return SC.String.trim(this,arguments)},trimLeft:function(){return SC.String.trimLeft(this,arguments)},trimRight:function(){return SC.String.trimRight(this,arguments)}})}SC.mixin(String.prototype,{loc:function(){return SC.String.loc(this.toString(),SC.$A(arguments))},locMetric:function(){return SC.String.locMetric(this.toString())},locLayout:function(a){return SC.String.locLayout(this.toString(),a)}});SC.DelegateSupport={delegateFor:function(c){var b=1,a=arguments.length,d;while(b<a){d=arguments[b];if(d&&d[c]!==undefined){return d}b++}return(this[c]!==undefined)?this:null},invokeDelegateMethod:function(e,b){var c=new Array(arguments.length-2);for(var d=0,a=c.length;d<a;d++){c[d]=arguments[d+2]}if(!e||!e[b]){e=this}var f=e[b];return f?f.apply(e,c):null},getDelegateProperty:function(d,e){var b=1,a=arguments.length,c;while(b<a){c=arguments[b++];if(c&&c[d]!=undefined){return c.get?c.get(d):c[d]}}return(this[d]!=undefined)?this.get(d):undefined}};sc_require("mixins/delegate_support");SC.CoreView=SC.Responder.extend(SC.DelegateSupport);sc_require("views/view/base");SC.CoreView.mixin({IS_RENDERED:256,IS_ATTACHED:128,IS_SHOWN:64,IS_HIDDEN:32,UNRENDERED:512,UNATTACHED:768,ATTACHED_PARTIAL:896,ATTACHED_HIDDEN:928,ATTACHED_SHOWN:960,ATTACHED_HIDDEN_BY_PARENT:929,ATTACHED_BUILDING_IN:961,ATTACHED_BUILDING_OUT:964,ATTACHED_BUILDING_OUT_BY_PARENT:965,ATTACHED_SHOWING:962,ATTACHED_HIDING:963,ATTACHED_SHOWN_ANIMATING:966});SC.CoreView.reopen({_sc_buildOutCount:null,_owningView:null,_preTransitionLayout:null,_preTransitionFrame:null,_transitionLayoutCache:null,viewState:SC.CoreView.UNRENDERED,isAttached:function(){return(this.get("viewState")&SC.CoreView.IS_ATTACHED)>0}.property("viewState").cacheable(),_isRendered:function(){return(this.get("viewState")&SC.CoreView.IS_RENDERED)>0}.property("viewState").cacheable(),isVisibleInWindow:function(){return(this.get("viewState")&SC.CoreView.IS_SHOWN)>0}.property("viewState").cacheable(),_doAdopt:function(k,c){var e=this.get("parentView"),g=true,a=this.get("viewState");if(e&&e!==k){this._doOrphan();e=false}var h=k.get("childViews");if(!e||h.indexOf(this)<0){var j,b=k.get("viewState"),f,d,i;if(k.willAddChild){k.willAddChild(this,c)}if(this.willAddToParent){this.willAddToParent(k,c)}this.set("parentView",k);if(h.needsClone){k.set("childViews",[])}j=(c)?h.indexOf(c):h.length;if(j<0){j=h.length}h.insertAt(j,this);this.updateDesignMode(this.get("designMode"),k.get("designMode"));this._adopted(c);switch(a){case SC.CoreView.UNRENDERED:switch(b){case SC.CoreView.UNRENDERED:break;default:this._doRender()}break;case SC.CoreView.UNATTACHED:switch(b){case SC.CoreView.UNRENDERED:this._doDestroyLayer();break;default:f=k.get("containerLayer");i=h.objectAt(h.indexOf(this)+1);d=(i)?i.get("layer"):null;this._doAttach(f,d)}break;default:switch(b){case SC.CoreView.UNRENDERED:this._doDestroyLayer();break;default:f=k.get("containerLayer");i=h.objectAt(h.indexOf(this)+1);d=(i)?i.get("layer"):null;this._doAttach(f,d)}}}else{if(a===SC.CoreView.ATTACHED_BUILDING_OUT){this._doAttach()}else{g=false}}return g},_doAttach:function(b,a){var g=this.get("viewState"),d=this.get("transitionIn"),f,c=false;switch(g){case SC.CoreView.UNATTACHED:var e=this.get("layer");this._executeQueuedUpdates();b.insertBefore(e,a||null);f=this.get("parentView");if(!f||(f&&f.get("isAttached"))){this._executeDoAttach();if(d){this._transitionIn(false)}}else{this._gotoAttachedPartialState()}c=true;break;case SC.CoreView.ATTACHED_BUILDING_OUT:this._callOnChildViews("_parentDidCancelBuildOut");this._sc_buildOutCount=null;if(this.get("transitionOut")){this.cancelAnimation();this._gotoAttachedShownState();if(d){this._transitionIn(true)}}else{this._gotoAttachedShownState()}c=true;break;case SC.CoreView.ATTACHED_HIDING:case SC.CoreView.ATTACHED_HIDDEN:case SC.CoreView.ATTACHED_HIDDEN_BY_PARENT:case SC.CoreView.ATTACHED_BUILDING_IN:case SC.CoreView.ATTACHED_BUILDING_OUT_BY_PARENT:case SC.CoreView.ATTACHED_SHOWING:case SC.CoreView.UNRENDERED:break;case SC.CoreView.ATTACHED_SHOWN:case SC.CoreView.ATTACHED_SHOWN_ANIMATING:break;case SC.CoreView.ATTACHED_PARTIAL:break}return c},_doDestroyLayer:function(){var b=this.get("viewState"),a=false;switch(b){case SC.CoreView.UNRENDERED:case SC.CoreView.ATTACHED_HIDING:case SC.CoreView.ATTACHED_HIDDEN:case SC.CoreView.ATTACHED_HIDDEN_BY_PARENT:case SC.CoreView.ATTACHED_BUILDING_IN:case SC.CoreView.ATTACHED_BUILDING_OUT_BY_PARENT:case SC.CoreView.ATTACHED_SHOWING:case SC.CoreView.ATTACHED_SHOWN:case SC.CoreView.ATTACHED_SHOWN_ANIMATING:case SC.CoreView.ATTACHED_BUILDING_OUT:case SC.CoreView.ATTACHED_PARTIAL:break;default:this._callOnChildViews("_teardownLayer",false);this._teardownLayer();a=true}return a},_doDetach:function(b){var d=this.get("viewState"),c=this.get("transitionOut"),a=true;switch(d){case SC.CoreView.ATTACHED_SHOWN:this._executeDoBuildOut(b);break;case SC.CoreView.ATTACHED_PARTIAL:case SC.CoreView.ATTACHED_HIDDEN:case SC.CoreView.ATTACHED_HIDDEN_BY_PARENT:this._executeDoDetach();break;case SC.CoreView.ATTACHED_HIDING:this.cancelAnimation();this._gotoAttachedHiddenState();this._executeDoDetach();break;case SC.CoreView.ATTACHED_SHOWING:case SC.CoreView.ATTACHED_SHOWN_ANIMATING:this.cancelAnimation();this._gotoAttachedShownState();this._executeDoBuildOut(b);break;case SC.CoreView.ATTACHED_BUILDING_IN:this.cancelAnimation();this._gotoAttachedShownState();this._executeDoBuildOut(b,true);break;case SC.CoreView.ATTACHED_BUILDING_OUT_BY_PARENT:this.cancelAnimation(SC.LayoutState.CURRENT);this._gotoAttachedShownState();this._executeDoBuildOut(b,true);break;case SC.CoreView.ATTACHED_BUILDING_OUT:if(b){this.cancelAnimation();this._executeDoDetach()}break;default:a=false}return a},_doHide:function(){var c=this.get("viewState"),b=this.get("transitionHide"),a=true;switch(c){case SC.CoreView.ATTACHED_SHOWN:case SC.CoreView.ATTACHED_BUILDING_IN:case SC.CoreView.ATTACHED_BUILDING_OUT:case SC.CoreView.ATTACHED_BUILDING_OUT_BY_PARENT:case SC.CoreView.ATTACHED_SHOWN_ANIMATING:if(b){this._transitionHide()}else{this._executeDoHide()}break;case SC.CoreView.ATTACHED_SHOWING:if(b){this.cancelAnimation(SC.LayoutState.CURRENT)}else{this.cancelAnimation()}this._gotoAttachedShownState();if(b){this._transitionHide(true)}else{this._executeDoHide()}break;case SC.CoreView.UNATTACHED:case SC.CoreView.ATTACHED_PARTIAL:this._visibleStyleNeedsUpdate=true;break;case SC.CoreView.UNRENDERED:a=false;break;case SC.CoreView.ATTACHED_HIDDEN:case SC.CoreView.ATTACHED_HIDING:return false;case SC.CoreView.ATTACHED_HIDDEN_BY_PARENT:this._doUpdateVisibleStyle();this._gotoAttachedHiddenState();return true;default:a=false}return a},_doOrphan:function(){var b=this.get("parentView"),d=true;if(b){var c=b.get("childViews"),a=c.indexOf(this);this.set("parentView",null);if(a>=0){c.removeAt(a)}this._orphaned(b)}else{d=false}return d},_doRender:function(){var f=this.get("viewState"),c=true;switch(f){case SC.CoreView.UNRENDERED:this._executeDoRender();var e=this.get("parentView");if(e&&e.get("_isRendered")){var b=e.get("containerLayer"),g=e.get("childViews"),d=g.objectAt(g.indexOf(this)+1),a=(d)?d.get("layer"):null;this._doAttach(b,a)}break;default:c=false}return c},_doShow:function(){var f=this.get("viewState"),d=this.get("transitionShow"),a=true;switch(f){case SC.CoreView.ATTACHED_HIDDEN:var e=this.get("parentView"),b=e?e.get("viewState")&SC.CoreView.IS_SHOWN:true;if(b){var g=[];this._executeQueuedUpdates();this._callOnChildViews("_parentWillShowInDocument",true,g);for(var c=g.length-1;c>=0;c--){var h=g[c];h._notifyWillShowInDocument()}this._notifyWillShowInDocument();this._executeDoShow();if(d){this._transitionShow(false)}}else{this._visibleStyleNeedsUpdate=true;this._gotoAttachedHiddenByParentState()}break;case SC.CoreView.ATTACHED_HIDING:this.cancelAnimation(d?SC.LayoutState.CURRENT:SC.LayoutState.START);this._gotoAttachedShownState();if(d){this._transitionShow(true)}break;case SC.CoreView.UNATTACHED:case SC.CoreView.ATTACHED_PARTIAL:this._visibleStyleNeedsUpdate=true;break;case SC.CoreView.UNRENDERED:a=false;break;default:a=false}return a},_doUpdateContent:function(b){var a=this.get("isVisibleInWindow"),c=true;if(this.get("_isRendered")){if(a||b){this._executeDoUpdateContent()}else{this._contentNeedsUpdate=true}}else{c=false}return c},didTransitionIn:function(){var a=this.get("viewState");if(a===SC.CoreView.ATTACHED_SHOWING||a===SC.CoreView.ATTACHED_BUILDING_IN){this._teardownTransition();this._gotoAttachedShownState()}},didTransitionOut:function(){var b=this.get("viewState");if(b===SC.CoreView.ATTACHED_BUILDING_OUT){this._teardownTransition();this._executeDoDetach()}else{if(b===SC.CoreView.ATTACHED_BUILDING_OUT_BY_PARENT){var a=this._owningView;a._sc_buildOutCount--;if(a._sc_buildOutCount===0){a._executeDoDetach();this._owningView=null}}else{if(b===SC.CoreView.ATTACHED_HIDING){this._teardownTransition();this._executeDoHide()}}}},_adopted:function(b){this._callOnChildViews("_ancestorDidChangeParent",false);var a=this.get("parentView");if(this.didAddToParent){this.didAddToParent(a,b)}if(a.didAddChild){a.didAddChild(this,b)}},_orphaned:function(a){if(!this.isDestroyed){this._callOnChildViews("_ancestorDidChangeParent",false);if(a.didRemoveChild){a.didRemoveChild(this)}if(this.didRemoveFromParent){this.didRemoveFromParent(a)}}},_gotoAttachedBuildingInState:function(){this.set("viewState",SC.CoreView.ATTACHED_BUILDING_IN)},_gotoAttachedBuildingOutState:function(){this.set("viewState",SC.CoreView.ATTACHED_BUILDING_OUT)},_gotoAttachedBuildingOutByParentState:function(){this.set("viewState",SC.CoreView.ATTACHED_BUILDING_OUT_BY_PARENT)},_gotoAttachedHiddenState:function(){this.set("viewState",SC.CoreView.ATTACHED_HIDDEN)},_gotoAttachedHiddenByParentState:function(){this.set("viewState",SC.CoreView.ATTACHED_HIDDEN_BY_PARENT)},_gotoAttachedHidingState:function(){this.set("viewState",SC.CoreView.ATTACHED_HIDING)},_gotoAttachedShowingState:function(){this.set("viewState",SC.CoreView.ATTACHED_SHOWING)},_gotoAttachedShownState:function(){this.set("viewState",SC.CoreView.ATTACHED_SHOWN)},_gotoUnattachedState:function(){this.set("viewState",SC.CoreView.UNATTACHED)},_gotoAttachedPartialState:function(){this.set("viewState",SC.CoreView.ATTACHED_PARTIAL)},_gotoUnrenderedState:function(){this.set("viewState",SC.CoreView.UNRENDERED)},_sc_addRenderedStateObservers:function(){var c,b,a;c=this.get("displayProperties");for(a=0,b=c.length;a<b;a++){this.addObserver(c[a],this,this.displayDidChange)}this.addObserver("isVisible",this,this._isVisibleDidChange);this.addObserver("isFirstResponder",this,this._isFirstResponderDidChange)},_ancestorDidChangeParent:function(){this.notifyPropertyChange("pane")},_cancelTransition:function(){this.cancelAnimation()},_doUpdateVisibleStyle:function(){var a=this.get("isVisible");this.$().toggleClass("sc-hidden",!a);this.$().attr("aria-hidden",a?null:true);this._visibleStyleNeedsUpdate=false},_teardownLayer:function(){this._notifyWillDestroyLayer();var c,b,a;c=this.get("displayProperties");for(b=0,a=c.length;b<a;b++){this.removeObserver(c[b],this,this.displayDidChange)}this.removeObserver("isVisible",this,this._isVisibleDidChange);this.removeObserver("isFirstResponder",this,this._isFirstResponderDidChange);this.set("layer",null);this._gotoUnrenderedState()},_executeDoAttach:function(){var b=[];this._executeQueuedUpdates();this._gotoSomeAttachedState();this._callOnChildViews("_parentDidAttach",true,b);for(var a=b.length-1;a>=0;a--){var c=b[a];c._notifyDidAttach()}this._notifyDidAttach()},_executeDoBuildOut:function(a,c){if(a){this._executeDoDetach()}else{this._sc_buildOutCount=0;this._callOnChildViews("_parentWillBuildOutFromDocument",true,this);var b=this.get("transitionOut");if(b){c=c||false;this._transitionOut(c,this)}else{if(this._sc_buildOutCount>0){this._gotoAttachedBuildingOutState()}else{this._sc_buildOutCount=null;this._executeDoDetach()}}}},_executeDoDetach:function(){var d=[];this._callOnChildViews("_parentWillDetach",true,d);for(var a=d.length-1;a>=0;a--){var e=d[a];e._notifyWillDetach()}this._notifyWillDetach();var c=this.get("viewState");switch(c){case SC.CoreView.ATTACHED_HIDING:case SC.CoreView.ATTACHED_SHOWN_ANIMATING:this.cancelAnimation();break}var b=this.get("layer");b.parentNode.removeChild(b);this._gotoUnattachedState();this._callOnChildViews("_parentDidDetach",true)},_executeDoHide:function(){var c=[];this._callOnChildViews("_parentWillHideInDocument",true,c);for(var a=c.length-1;a>=0;a--){var d=c[a];d._notifyWillHideInDocument()}this._notifyWillHideInDocument();var b=this.get("viewState");switch(b){case SC.CoreView.ATTACHED_BUILDING_IN:case SC.CoreView.ATTACHED_BUILDING_OUT:case SC.CoreView.ATTACHED_BUILDING_OUT_BY_PARENT:case SC.CoreView.ATTACHED_SHOWN_ANIMATING:this.cancelAnimation();break}this._doUpdateVisibleStyle();this._gotoAttachedHiddenState();this._callOnChildViews("_parentDidHideInDocument",true);this._notifyDidHideInDocument()},_executeDoRender:function(){var c=[];var b=this.renderContext(this.get("tagName"));this.renderToContext(b);this.set("layer",b.element());this._gotoUnattachedState();this._callOnChildViews("_parentDidRender",true,c);this._sc_addRenderedStateObservers();for(var a=c.length-1;a>=0;a--){var d=c[a];d._notifyDidRender()}this._notifyDidRender()},_executeDoShow:function(){this._doUpdateVisibleStyle();this._gotoAttachedShownState();this._callOnChildViews("_parentDidShowInDocument",true);this._notifyDidShowInDocument()},_executeDoUpdateContent:function(){var c=this.renderMixin,d=this.renderContext(this.get("layer"));if(!this.update){this.render(d,false)}else{this.update(d.$())}if(c){var b=c.length;for(var a=0;a<b;++a){c[a].call(this,d,false)}}this.applyAttributesToContext(d);d.update();this.set("layerNeedsUpdate",false);this._contentNeedsUpdate=false;this.notifyPropertyChange("layer");if(this.didUpdateLayer){this.didUpdateLayer()}if(this.designer&&this.designer.viewDidUpdateLayer){this.designer.viewDidUpdateLayer()}},_executeQueuedUpdates:function(){if(this._visibleStyleNeedsUpdate){this._doUpdateVisibleStyle()}if(this._contentNeedsUpdate){this._executeDoUpdateContent()}},_isVisibleDidChange:function(){if(this.get("isVisible")){this._doShow()}else{this._doHide()}},_isFirstResponderDidChange:function(){var a=this.get("isFirstResponder");this.$().toggleClass("focus",a)},_notifyDidAttach:function(){this.notifyPropertyChange("frame");if(this.didAppendToDocument){this.didAppendToDocument()}},_notifyDidHideInDocument:function(){if(this.didHideInDocument){this.didHideInDocument()}},_notifyDidRender:function(){var c=this.didCreateLayerMixin,b,a;if(this.didCreateLayer){this.didCreateLayer()}if(c){a=c.length;for(b=0;b<a;++b){c[b].call(this)}}},_notifyDidShowInDocument:function(){if(this.didShowInDocument){this.didShowInDocument()}},_notifyWillDestroyLayer:function(){var b,a,c;c=this.willDestroyLayerMixin;if(c){a=c.length;for(b=0;b<a;++b){c[b].call(this)}}if(this.willDestroyLayer){this.willDestroyLayer()}},_notifyWillDetach:function(){if(this.willRemoveFromDocument){this.willRemoveFromDocument()}},_notifyWillHideInDocument:function(){if(this.willHideInDocument){this.willHideInDocument()}},_notifyWillShowInDocument:function(){if(this.willShowInDocument){this.willShowInDocument()}},_parentDidAttach:function(d){var c=this.get("viewState"),b=true;switch(c){case SC.CoreView.ATTACHED_PARTIAL:this._executeQueuedUpdates();this._gotoSomeAttachedState();var a=this.get("transitionIn");if(a){this._transitionIn(false)}break;case SC.CoreView.UNRENDERED:case SC.CoreView.UNATTACHED:b=false;break;default:b=false}if(b){d.push(this)}return b},_parentDidCancelBuildOut:function(){var b=this.get("viewState");if(b===SC.CoreView.ATTACHED_BUILDING_OUT_BY_PARENT){var a=this.get("transitionIn");this.cancelAnimation(a?SC.LayoutState.CURRENT:undefined);this._gotoAttachedShownState();if(a){this._transitionIn(true)}}else{if(b===SC.CoreView.ATTACHED_BUILDING_OUT||b&SC.CoreView.IS_HIDDEN){return false}}},_parentDidHideInDocument:function(){var b=this.get("viewState"),a=false;switch(b){case SC.CoreView.ATTACHED_SHOWN:this._gotoAttachedHiddenByParentState();a=true;break;case SC.CoreView.UNRENDERED:case SC.CoreView.UNATTACHED:case SC.CoreView.ATTACHED_HIDDEN:break;default:}return a},_parentDidDetach:function(){var a=this.get("viewState");if(a&SC.CoreView.IS_ATTACHED){this._gotoAttachedPartialState()}else{return false}},_parentDidRender:function(c){var b=this.get("viewState"),a=true;switch(b){case SC.CoreView.UNRENDERED:this._sc_addRenderedStateObservers();this._gotoAttachedPartialState();break;default:a=false}if(a){c.push(this)}return a},_parentDidShowInDocument:function(){var b=this.get("viewState"),a=true;switch(b){case SC.CoreView.ATTACHED_HIDDEN_BY_PARENT:this._gotoAttachedShownState();break;case SC.CoreView.UNRENDERED:case SC.CoreView.UNATTACHED:case SC.CoreView.ATTACHED_HIDDEN:a=false;break;default:a=false}return a},_parentWillBuildOutFromDocument:function(a){var d=this.get("viewState"),b=this.get("transitionOut"),c=true;switch(d){case SC.CoreView.UNRENDERED:case SC.CoreView.UNATTACHED:case SC.CoreView.ATTACHED_BUILDING_OUT:case SC.CoreView.ATTACHED_HIDDEN:c=false;break;case SC.CoreView.ATTACHED_BUILDING_IN:if(b){this.cancelAnimation(SC.LayoutState.CURRENT)}else{this.cancelAnimation()}this._gotoAttachedShownState();if(b){this._transitionOut(true,a)}break;case SC.CoreView.ATTACHED_HIDING:case SC.CoreView.ATTACHED_SHOWN_ANIMATING:case SC.CoreView.ATTACHED_SHOWING:case SC.CoreView.ATTACHED_SHOWN:if(b){this._transitionOut(false,a)}break;default:c=false}return c},_parentWillHideInDocument:function(){var b=this.get("viewState"),a=true;switch(b){case SC.CoreView.ATTACHED_SHOWN:break;case SC.CoreView.ATTACHED_SHOWN_ANIMATING:case SC.CoreView.ATTACHED_SHOWING:case SC.CoreView.ATTACHED_BUILDING_IN:case SC.CoreView.ATTACHED_BUILDING_OUT:case SC.CoreView.ATTACHED_BUILDING_OUT_BY_PARENT:case SC.CoreView.ATTACHED_HIDING:this.cancelAnimation();break;case SC.CoreView.UNRENDERED:case SC.CoreView.UNATTACHED:case SC.CoreView.ATTACHED_HIDDEN:break;default:a=false}return a},_parentWillDetach:function(c){var b=this.get("viewState"),a=true;switch(b){case SC.CoreView.ATTACHED_SHOWN:break;case SC.CoreView.ATTACHED_SHOWN_ANIMATING:case SC.CoreView.ATTACHED_SHOWING:case SC.CoreView.ATTACHED_BUILDING_IN:case SC.CoreView.ATTACHED_BUILDING_OUT:case SC.CoreView.ATTACHED_HIDING:this.cancelAnimation();break;case SC.CoreView.UNRENDERED:case SC.CoreView.UNATTACHED:case SC.CoreView.ATTACHED_HIDDEN:case SC.CoreView.ATTACHED_HIDDEN_BY_PARENT:a=false;break;default:a=false}if(a){c.push(this)}return a},_parentWillShowInDocument:function(c){var b=this.get("viewState"),a=true;switch(b){case SC.CoreView.ATTACHED_HIDDEN_BY_PARENT:this._executeQueuedUpdates();break;case SC.CoreView.UNRENDERED:case SC.CoreView.UNATTACHED:case SC.CoreView.ATTACHED_HIDDEN:a=false;break;default:a=false}if(a){c.push(this)}return a},_setupTransition:function(e){var d=SC.clone(this.get("layout"));this._preTransitionLayout=d;this._preTransitionFrame=this.get("borderFrame");var c=SC.get(e,"layoutProperties");if(c&&c.length){this._transitionLayoutCache={};var b,f,a=c.length;for(b=0;b<a;b++){f=c[b];this._transitionLayoutCache[f]=d[f]===undefined?null:d[f]}}},_teardownTransition:function(){if(this._transitionLayoutCache){this.adjust(this._transitionLayoutCache)}else{if(this._preTransitionLayout){this.set("layout",this._preTransitionLayout)}}this._preTransitionLayout=null;this._preTransitionFrame=null;this._transitionLayoutCache=null},_transitionHide:function(c){var b=this.get("transitionHide"),a=this.get("transitionHideOptions")||{};if(!c){this._setupTransition(b)}if(b.setup){b.setup(this,a,c)}b.run(this,a,this._preTransitionLayout,this._preTransitionFrame);this._gotoAttachedHidingState()},_transitionIn:function(c){var a=this.get("transitionIn"),b=this.get("transitionInOptions")||{};if(!c){this._setupTransition(a)}if(a.setup){a.setup(this,b,c)}if(a.run){a.run(this,b,this._preTransitionLayout,this._preTransitionFrame)}this._gotoAttachedBuildingInState()},_transitionOut:function(d,a){var c=this.get("transitionOut"),b=this.get("transitionOutOptions")||{};if(!d){this._setupTransition(c)}a._sc_buildOutCount++;if(c.setup){c.setup(this,b,d)}c.run(this,b,this._preTransitionLayout,this._preTransitionFrame);if(a===this){this._gotoAttachedBuildingOutState()}else{this._gotoAttachedBuildingOutByParentState()}},_transitionShow:function(c){var b=this.get("transitionShow"),a=this.get("transitionShowOptions")||{};if(!c){this._setupTransition(b)}if(b.setup){b.setup(this,a,c)}b.run(this,a,this._preTransitionLayout,this._preTransitionFrame);this._gotoAttachedShowingState()},_gotoSomeAttachedState:function(){var b=this.get("parentView"),c=b?b.get("viewState")&SC.CoreView.IS_HIDDEN:false,a=b?b.get("viewState")&SC.CoreView.IS_SHOWN:true;if(a){if(this.get("isVisible")){this._gotoAttachedShownState()}else{this._gotoAttachedHiddenState()}}else{if(c){this._gotoAttachedHiddenByParentState()}else{this._gotoAttachedPartialState()}}}});sc_require("system/browser");sc_require("system/event");sc_require("system/cursor");sc_require("system/responder");sc_require("system/theme");sc_require("system/string");sc_require("views/view/statechart");SC.CONTEXT_MENU_ENABLED=YES;SC.TABBING_ONLY_INSIDE_DOCUMENT=NO;SC.FROM_THEME="__FROM_THEME__";SC.EMPTY_CHILD_VIEWS_ARRAY=[];SC.EMPTY_CHILD_VIEWS_ARRAY.needsClone=YES;SC.CoreView.reopen({concatenatedProperties:["outlets","displayProperties","classNames","renderMixin","didCreateLayerMixin","willDestroyLayerMixin","classNameBindings","attributeBindings"],ariaRole:null,ariaHidden:null,createdByParent:false,owner:function(){return this.get("parentView")}.property("parentView").cacheable(),pane:function(){var a=this;while(a&&!a.isPane){a=a.get("parentView")}return a}.property("parentView").cacheable(),page:null,parentView:null,isVisible:true,isVisibleBindingDefault:SC.Binding.bool(),childViews:SC.EMPTY_CHILD_VIEWS_ARRAY,autoMixins:null,layer:function(a,c){if(c!==undefined){this._view_layer=c}else{c=this._view_layer;if(!c){var b=this.get("parentView");if(b){b=b.get("layer")}this._view_layer=c=this.findLayerInParentLayer(b)}}return c}.property("isVisibleInWindow").cacheable(),$:function(b){var a=this.get("layer");if(!a){return SC.$()}else{if(b===undefined){return SC.$(a)}else{return SC.$(b,a)}}},containerLayer:function(){return this.get("layer")}.property("layer").cacheable(),layerId:function(a,b){if(b){this._layerId=b}if(this._layerId){return this._layerId}return SC.guidFor(this)}.property().cacheable(),findLayerInParentLayer:function(a){var b="#"+this.get("layerId").escapeCssIdForSelector();return jQuery(b,a)[0]||jQuery(b)[0]},isDescendantOf:function(a){var b=this.get("parentView");if(this===a){return YES}else{if(b){return b.isDescendantOf(a)}else{return NO}}},displayDidChange:function(){if(this.get("_isRendered")){this.set("layerNeedsUpdate",true);this.invokeOnce(this._doUpdateContent)}return this},layerNeedsUpdate:NO,updateLayerIfNeeded:function(a){this._doUpdateContent(false);return this},updateLayer:function(){this._doUpdateContent(true);return this},parentViewDidResize:function(){if(!this.get("hasLayout")){this.notifyPropertyChange("frame")}this.viewDidResize()},viewDidResize:function(){},renderContext:function(a){return SC.RenderContext(a)},createLayer:function(){if(!this.get("_isRendered")){this._doRender()}return this},destroyLayer:function(){if(this.get("isAttached")){this._doDetach()}if(this.get("_isRendered")){this._doDestroyLayer()}return this},replaceLayer:function(){var b,a;if(this.get("isAttached")){b=this.get("layer");a=b.parentNode;this._doDetach()}this.destroyLayer().createLayer();if(a&&!this.get("isAttached")){this._doAttach(a)}return this},parentViewDidChange:function(){},layerLocationNeedsUpdate:NO,updateLayerLocationIfNeeded:function(){return this},updateLayerLocation:function(){return this},renderToContext:function(d){var c,b,a;this.beginPropertyChanges();d.id(this.get("layerId"));d.setAttr("role",this.get("ariaRole"));this._applyClassNameBindings();this._applyAttributeBindings(d);d.addClass(this.get("classNames"));if(this.get("isTextSelectable")){d.addClass("allow-select")}if(!this.get("isVisible")){d.addClass("sc-hidden");d.setAttr("aria-hidden","true")}this.applyAttributesToContext(d);this.render(d,true);if(!this._didRenderChildViews){this.renderChildViews(d)}this._didRenderChildViews=false;if(c=this.renderMixin){a=c.length;for(b=0;b<a;++b){c[b].call(this,d,true)}}this.endPropertyChanges()},applyAttributesToContext:function(a){},_applyClassNameBindings:function(){var a=this.get("classNameBindings"),b=this.get("classNames"),c;if(!a){return}a.forEach(function(f){var e;var d=function(){var h=this._classStringForProperty(f);var g=this.$();if(e){g.removeClass(e);b.removeObject(e)}if(h){g.addClass(h);b.push(h);e=h}else{e=null}};this.addObserver(f.split(":")[0],this,d);c=this._classStringForProperty(f);if(c){b.push(c);e=c}},this)},_applyAttributeBindings:function(a){var e=this.get("attributeBindings"),c,d,b;if(!e){return}e.forEach(function(g){var f=function(){d=this.$();var h=d.attr(g);c=this.get(g);b=typeof c;if((b==="string"||b==="number")&&c!==h){d.attr(g,c)}else{if(c&&b==="boolean"){d.attr(g,g)}else{if(c===NO){d.removeAttr(g)}}}};this.addObserver(g,this,f);c=this.get(g);b=typeof c;if(b==="string"||b==="number"){a.setAttr(g,c)}else{if(c&&b==="boolean"){a.setAttr(g,g)}}},this)},_classStringForProperty:function(c){var a=c.split(":"),b=a[1];c=a[0];var d=SC.getPath(this,c);if(d===YES){if(b){return b}return SC.String.dasherize(c.split(".").get("lastObject"))}else{if(d!==NO&&d!==undefined&&d!==null){return d}else{return null}}},renderChildViews:function(e){var d=this.get("childViews"),b=d.length,a,c;for(a=0;a<b;++a){c=d[a];if(!c){continue}e=e.begin(c.get("tagName"));c.renderToContext(e);e=e.end()}this._didRenderChildViews=true;return e},render:function(){},attributeBindings:null,tagName:"div",classNames:[],classNameBindings:null,toolTip:null,displayToolTip:function(){var a=this.get("toolTip");return(a&&this.get("localize"))?SC.String.loc(a):(a||"")}.property("toolTip","localize").cacheable(),isTextSelectable:NO,displayProperties:[],nextResponder:function(){return this.get("parentView")}.property("parentView").cacheable(),acceptsFirstResponder:NO,_lastLayerId:null,init:function(){var b,a;arguments.callee.base.apply(this,arguments);a=this._lastLayerId=this.get("layerId");SC.View.views[a]=this;this.classNames=this.get("classNames").slice();b=this.childViews=this.get("childViews").slice();this.createChildViews()},frame:function(){return this.computeFrameWithParentFrame(null)}.property("useStaticLayout").cacheable(),computeFrameWithParentFrame:function(){var a,b=this.get("parentView"),c;if(a=this.get("layer")){c=SC.offset(a);if(b){c=b.convertFrameFromView(c,null)}c.width=a.offsetWidth;c.height=a.offsetHeight;return c}if(this.get("hasLayout")){return null}else{return{x:0,y:0,width:0,height:0}}},_callOnChildViews:function(b,a,d){var h,f=this.get("childViews"),g,e;for(var c=f.length-1;c>=0;c--){h=f[c];if(!h){continue}g=h[b];if(a===undefined||a){e=g.call(h,d)}if(e===undefined||e){h._callOnChildViews(b,a,d)}if(a===false){g.call(h,d)}}},clippingFrame:function(){var e=this.get("frame");if(!e){return null}var g=(e.scale==null)?1:e.scale,d=this.get("parentView"),h=d?d.get("clippingFrame"):null,c;if(!h){return{x:0,y:0,width:e.width/g,height:e.height/g}}c=SC.intersectRects(h,e);c.x-=e.x;c.y-=e.y;if(g!==1){var b,a;if(SC.typeOf(g)===SC.T_ARRAY){b=1/g[0];a=1/g[1]}else{b=a=1/g}c.x*=b;c.width*=b;c.y*=a;c.height*=a}return c}.property("parentView","frame").cacheable(),_sc_clippingFrameDidChange:function(){this.notifyPropertyChange("clippingFrame")},removeChild:function(b,a){if(b.get("isAttached")){b._doDetach(a)}if(!a&&b.get("viewState")===SC.CoreView.ATTACHED_BUILDING_OUT){b.addObserver("isAttached",this,this._orphanChildView)}else{b._doOrphan()}return this},removeChildAndDestroy:function(b,a){if(b.get("isAttached")){b._doDetach(a)}if(b.get("isAttached")&&b.get("transitionOut")&&!a){b.addObserver("isAttached",this,this._destroyChildView)}else{b.destroy()}return this},removeAllChildren:function(b){var d=this.get("childViews"),a=d.get("length"),c;for(c=a-1;c>=0;c--){this.removeChildAndDestroy(d.objectAt(c),b)}return this},removeFromParent:function(){var a=this.get("parentView");if(a){a.removeChild(this)}return this},_destroyChildView:function(a){if(!a.get("isAttached")){a.removeObserver("isAttached",this,this._destroyChildView);a.destroy()}},_orphanChildView:function(a){if(!a.get("isAttached")){a.removeObserver("isAttached",this,this._orphanChildView);a._doOrphan()}},destroy:function(){if(this.get("isDestroyed")){return this}var a=arguments.callee.base.apply(this,arguments);if(this.getPath("parentView.isDestroyed")){this.invokeNext(this._destroy)}else{if(this.get("isAttached")){this._doDetach(true)}if(this.get("_isRendered")){this._doDestroyLayer()}this._destroy()}delete SC.View.views[this.get("layerId")];var c=this.get("childViews");for(var b=c.length-1;b>=0;b--){c[b].destroy()}return a},_destroy:function(){this._doOrphan();delete this.page},createChildViews:function(){var e=this.get("childViews"),b=e.length,f=false,a,d,c;this.beginPropertyChanges();for(a=0;a<b;++a){d=c=e[a];if(typeof d===SC.T_STRING){c=this[d]}else{d=null}if(!c){f=true;e[a]=null;continue}c=this.createChildView(c);if(d){this[d]=c}e[a]=c}if(f){this.set("childViews",e.compact())}this.endPropertyChanges();return this},createChildView:function(b,c){if(b.isClass){if(!c){c={}}else{c=SC.clone(c)}c.parentView=this;if(!c.page){c.page=this.page}c.createdByParent=true;var a=this.autoMixins;if(!!a){a=SC.clone(a);a.push(c);b=b.create.apply(b,a)}else{b=b.create(c)}}else{b.set("parentView",this);b._adopted();if(!b.get("page")){b.set("page",this.page)}}return b},isView:YES,selectStart:function(a){return this.get("isTextSelectable")},contextMenu:function(a){if(this.get("isContextMenuEnabled")){a.allowDefault();return YES}},transitionIn:null,transitionInOptions:null,transitionOut:null,transitionOutOptions:null,transitionShow:null,transitionShowOptions:null,transitionHide:null,transitionHideOptions:null,updateDesignMode:function(a,b){}});SC.CoreView.mixin({isViewClass:YES,design:function(){if(this.isDesign){return this}var a=this.extend.apply(this,arguments);a.isDesign=YES;if(SC.ViewDesigner){SC.ViewDesigner.didLoadDesign(a,this,SC.A(arguments))}return a},extend:function(){var a=arguments[arguments.length-1];if(a&&!SC.none(a.theme)){a.themeName=a.theme;delete a.theme}return SC.Object.extend.apply(this,arguments)},layout:function(a){this.prototype.layout=a;return this},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(b,d){var c=this.prototype,a=this.superclass.prototype;var e=c._bindings;if(!e||e===a._bindings){e=c._bindings=(e||[]).slice()}b=b+"Binding";c[b]=d;e.push(b);return this},prop:function(a,b){this.prototype[a]=b;return this},localization:function(b,a){if(a){b.rootElement=SC.$(a)[0]}return b},viewFor:function(d,c){var b=SC.$A(arguments);if(SC.none(d)){b.shift()}else{b[0]={rootElement:SC.$(d)[0]}}var a=this.create.apply(this,arguments);b=b[0]=null;return a},create:function(){var b=arguments[arguments.length-1];if(b&&b.theme){b.themeName=b.theme;delete b.theme}var c=this,a=new c(arguments);if(SC.ViewDesigner){SC.ViewDesigner.didCreateView(a,SC.$A(arguments))}return a},loc:function(e){var b=e.childViews;delete e.childViews;this.applyLocalizedAttributes(e);if(SC.ViewDesigner){SC.ViewDesigner.didLoadLocalization(this,SC.$A(arguments))}var d=this.prototype.childViews,a=d.length,c;while(--a>=0){c=d[a];e=b[a];if(e&&c&&typeof c===SC.T_STRING){SC.String.loc(c,e)}}return this},applyLocalizedAttributes:function(a){SC.mixin(this.prototype,a)},views:{}});SC.outlet=function(b,a){return function(c){return(this[c]=SC.objectForPropertyPath(b,(a!==undefined)?a:this))}.property()};SC.CoreView.unload=function(){var a=SC.View.views;if(a){for(var b in a){if(!a.hasOwnProperty(b)){continue}delete a[b]}}};SC.View=SC.CoreView.extend({classNames:["sc-view"],displayProperties:[],_executeQueuedUpdates:function(){arguments.callee.base.apply(this,arguments);if(this._enabledStyleNeedsUpdate){this._doUpdateEnabledStyle()}if(this._layoutStyleNeedsUpdate){this._doUpdateLayoutStyle()}},applyAttributesToContext:function(f){var h=this.get("cursor");if(h){f.addClass(h.get("className"))}if(!this.get("isEnabled")){f.addClass("disabled");f.setAttr("aria-disabled","true")}this.renderLayout(f,true);if(this.get("useStaticLayout")){f.addClass("sc-static-layout")}var d=this.get("backgroundColor");if(!SC.none(d)||this._scv_hasBackgroundColor){this._scv_hasBackgroundColor=YES;if(d){f.setStyle("backgroundColor",d)}else{f.removeStyle("backgroundColor")}}var g=this.get("theme");var c=g.classNames,b,a=c.length;for(b=0;b<a;b++){f.addClass(c[b])}arguments.callee.base.apply(this,arguments);var e=this.get("renderDelegate");if(e&&e.className){f.addClass(e.className)}},computeFrameWithParentFrame:function(e){var i=this.get("layout"),l;if(this.get("useStaticLayout")){l=arguments.callee.base.apply(this,arguments);l=l?this._sc_adjustForBorder(l,i):null;l=l?this._sc_adjustForScale(l,i):null;return l}l={};var n,j,q=SC.LAYOUT_AUTO,a,h,p=i.right,b=i.left,o=i.top,k=i.bottom,m=i.width,g=i.height,d=i.centerX,c=i.centerY;if(m===q){SC.throw(("%@.layout() cannot use width:auto if staticLayout is disabled").fmt(this),"%@".fmt(this),-1)}if(g===q){SC.throw(("%@.layout() cannot use height:auto if staticLayout is disabled").fmt(this),"%@".fmt(this),-1)}if(!e){e=this.computeParentDimensions(i)}a=e.height;h=e.width;if(!SC.none(b)){if(SC.isPercentage(b)){l.x=h*b}else{l.x=b}if(m!==undefined){if(m===q){l.width=q}else{if(SC.isPercentage(m)){l.width=h*m}else{l.width=m}}}else{l.width=h-l.x;if(p&&SC.isPercentage(p)){l.width=l.width-(p*h)}else{l.width=l.width-(p||0)}}}else{if(!SC.none(p)){if(SC.none(m)){if(SC.isPercentage(p)){l.width=h-(h*p)}else{l.width=h-p}l.x=0}else{if(m===q){l.width=q}else{if(SC.isPercentage(m)){l.width=h*m}else{l.width=(m||0)}}if(SC.isPercentage(m)){l.x=h-(p*h)-l.width}else{l.x=h-p-l.width}}}else{if(!SC.none(d)){if(m===q){l.width=q}else{if(SC.isPercentage(m)){l.width=m*h}else{l.width=(m||0)}}if(SC.isPercentage(d)){l.x=(h-l.width)/2+(d*h)}else{l.x=(h-l.width)/2+d}}else{l.x=0;if(SC.none(m)){l.width=h}else{if(m===q){l.width=q}if(SC.isPercentage(m)){l.width=m*h}else{l.width=(m||0)}}}}}if(!SC.none(o)){if(SC.isPercentage(o)){l.y=o*a}else{l.y=o}if(g!==undefined){if(g===q){l.height=q}else{if(SC.isPercentage(g)){l.height=g*a}else{l.height=g}}}else{if(k&&SC.isPercentage(k)){l.height=a-l.y-(k*a)}else{l.height=a-l.y-(k||0)}}}else{if(!SC.none(k)){if(SC.none(g)){if(SC.isPercentage(k)){l.height=a-(k*a)}else{l.height=a-k}l.y=0}else{if(g===q){l.height=q}if(g&&SC.isPercentage(g)){l.height=g*a}else{l.height=(g||0)}if(SC.isPercentage(k)){l.y=a-(k*a)-l.height}else{l.y=a-k-l.height}}}else{if(!SC.none(c)){if(g===q){l.height=q}if(g&&SC.isPercentage(g)){l.height=g*a}else{l.height=(g||0)}if(SC.isPercentage(c)){l.y=(a-l.height)/2+(c*a)}else{l.y=(a-l.height)/2+c}}else{l.y=0;if(SC.none(g)){l.height=a}else{if(g===q){l.height=q}if(SC.isPercentage(g)){l.height=g*a}else{l.height=g||0}}}}}l.x=Math.floor(l.x);l.y=Math.floor(l.y);if(l.height!==q){l.height=Math.floor(l.height)}if(l.width!==q){l.width=Math.floor(l.width)}if(l.height===q||l.width===q){j=this.get("layer");if(l.height===q){l.height=j?j.clientHeight:0}if(l.width===q){l.width=j?j.clientWidth:0}}l=this._sc_adjustForBorder(l,i);if((i.maxHeight!=null)&&(l.height>i.maxHeight)){l.height=i.maxHeight}if((i.minHeight!=null)&&(l.height<i.minHeight)){l.height=i.minHeight}if((i.maxWidth!=null)&&(l.width>i.maxWidth)){l.width=i.maxWidth}if((i.minWidth!=null)&&(l.width<i.minWidth)){l.width=i.minWidth}l=this._sc_adjustForScale(l,i);return l},init:function(){arguments.callee.base.apply(this,arguments);if(!this.get("isEnabled")){this._doDisable()}this._previousLayout=this.get("layout");var a=this.childViewLayout;if(a){this.set("childViewsNeedLayout",true);this.layoutChildViewsIfNeeded();if(this.get("isChildViewLayoutLive")){this.addObserver("childViews.[]",this,this._cvl_childViewsDidChange);this.addObserver("childViewLayoutOptions",this,this._cvl_childViewLayoutDidChange);this._cvl_setupChildViewsLiveLayout();if(!this.get("isFixedSize")&&a.layoutDependsOnSize&&a.layoutDependsOnSize(this)){this.addObserver("frame",this,this._cvl_childViewLayoutDidChange)}}}this._lastTheme=this.get("theme")},destroy:function(){this._previousLayout=null;return arguments.callee.base.apply(this,arguments)},removeChild:function(a){if(!a){return this}if(a.parentView!==this){throw new Error("%@.removeChild(%@) must belong to parent".fmt(this,a))}if(a.willRemoveFromParent){a.willRemoveFromParent()}if(this.willRemoveChild){this.willRemoveChild(a)}arguments.callee.base.apply(this,arguments);return this}});if(SC.browser.isIE){SC.Event.add(window,"unload",SC.View,SC.View.unload)}sc_require("views/view");function _SC_VIEW_STACK_PLUGIN(a){this.direction=a}_SC_VIEW_STACK_PLUGIN.prototype.childLayoutProperties=["marginBefore","marginAfter","isVisible"];_SC_VIEW_STACK_PLUGIN.prototype.layoutDependsOnSize=function(a){var b=a.get("childViewLayoutOptions");if(b){return SC.none(b.resizeToFit)?false:!b.resizeToFit}else{return false}};_SC_VIEW_STACK_PLUGIN.prototype.layoutChildViews=function(m){var y=m.get("childViews"),c=m.get("childViewLayoutOptions")||{},s=SC.none(c.resizeToFit)?true:c.resizeToFit,w=0,l=c.paddingBefore||0,h=c.paddingAfter||0,v=0,e=0,r=0,n=0,f=0,d=c.spacing||0,a=this.direction==="vertical"?"height":"width",b=this.direction==="vertical"?"minHeight":"minWidth",g=this.direction==="vertical"?"top":"left",C,x,B,k,t,u;if(!s){n=m.get("frame")[a];if(!n){return}for(t=0,u=y.get("length");t<u;t++){C=y.objectAt(t);if(!C.get("isVisible")||C.get("useAbsoluteLayout")||C.get("useStaticLayout")){continue}B=C.get("layout");k=C.get("marginBefore")||0;e+=Math.max(l,k);if(SC.none(B[a])){x=C.get("fillRatio");if(!SC.none(x)){f+=x}else{if(t===u-1&&f===0){f=1}}}else{e+=C.get("borderFrame")[a]}w=C.get("marginAfter")||0;l=w||d}if(e!==0||f!==0){e+=Math.max(w,h)}r=Math.max(0,n-e)}w=0;l=c.paddingBefore||0;h=c.paddingAfter||0;for(t=0,u=y.get("length");t<u;t++){var p,A,z;C=y.objectAt(t);if(!C.get("isVisible")||C.get("useAbsoluteLayout")||C.get("useStaticLayout")){continue}B=C.get("layout");k=C.get("marginBefore")||0;v+=Math.max(l,k);A=B[g]!==v;C.beginPropertyChanges();if(!s&&!B[a]){var j=this.direction==="vertical"?"bottom":"right",o;x=C.get("fillRatio");if(t===u-1&&SC.none(x)){x=1}if(!SC.none(x)){var q=(x/f);p=Math.ceil(r*q);o=Math.max(0,n-v-p);z=B[j]!==o;if(z){C.adjust(j,o)}}}if(A){C.adjust(g,v)}C.endPropertyChanges();v+=C.get("borderFrame")[a];w=C.get("marginAfter")||0;l=w||d}if(v!==0){v+=Math.max(w,h)}if(s&&m.get("layout")[a]!==v){m.adjust(a,v)}};SC.mixin(SC.View,{HORIZONTAL_STACK:new _SC_VIEW_STACK_PLUGIN("horizontal"),VERTICAL_STACK:new _SC_VIEW_STACK_PLUGIN("vertical")});SC.Controller=SC.Object.extend({isEditable:YES,destroyContentOnReplace:NO,contentObjectDidChanged:function(){var b,a;if(!this.get("destroyContentOnReplace")){return}b=this._oldContent;a=this.get("content");if(b&&a!==b&&b.destroy){b.destroy()}this._oldContent=a}.observes("content")});SC.SelectionSupport={hasSelectionSupport:YES,allowsSelection:YES,allowsMultipleSelection:YES,allowsEmptySelection:YES,firstSelectableObject:function(){return this.get("firstObject")}.property(),selection:function(d,f){var c=this._scsel_selection,g=c?c.get("length"):0,e,b=this.get("arrangedObjects"),a;if((f===undefined)||!this.get("allowsSelection")){f=c}a=(f&&f.isEnumerable)?f.get("length"):0;if((a>1)&&!this.get("allowsMultipleSelection")){if(g>1){f=SC.SelectionSet.create().addObject(c.get("firstObject")).freeze();a=1}else{f=c;a=g}}if((a===0)&&!this.get("allowsEmptySelection")&&b&&b.get("length")!==0){if(g===0){f=this.get("firstSelectableObject");if(f){f=SC.SelectionSet.create().addObject(f).freeze()}else{f=SC.SelectionSet.EMPTY}a=f.get("length")}else{f=c;a=g}}if(a===0){f=SC.SelectionSet.EMPTY}if(f!==c){f=f.frozenCopy()}this._scsel_selection=f;return f}.property("arrangedObjects","allowsEmptySelection","allowsMultipleSelection","allowsSelection").cacheable(),hasSelection:function(){var a=this.get("selection");return !!a&&(a.get("length")>0)}.property("selection").cacheable(),selectObjects:function(b,c){if(!b||b.get("length")===0){if(!c){this.set("selection",SC.SelectionSet.EMPTY)}return this}var a=this.get("selection");if(c&&a){a=a.copy()}else{a=SC.SelectionSet.create()}a.addObjects(b).freeze();this.set("selection",a);return this},selectObject:function(a,b){if(a===null){if(!b){this.set("selection",null)}return this}else{return this.selectObjects([a],b)}},deselectObjects:function(b){if(!b||b.get("length")===0){return this}var a=this.get("selection");if(!a||a.get("length")===0){return this}a=a.copy().removeObjects(b).freeze();this.set("selection",a.freeze());return this},deselectObject:function(a){if(!a){return this}else{return this.deselectObjects([a])}},updateSelectionAfterContentChange:function(){var a=this.get("arrangedObjects");var b=this.get("selection");var d=this.get("allowsEmptySelection");var c;if(!b){return this}c=b.indexSetForSource(a);if((c&&(c.get("length")!==b.get("length")))||(!c&&(b.get("length")>0))){if(a){b=b.copy().constrain(a).freeze()}else{b=SC.SelectionSet.EMPTY}this.set("selection",b)}if((b.get("length")===0)&&a&&(a.get("length")>0)&&!d){this.selectObject(this.get("firstSelectableObject"),NO)}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 b=this.get("content"),a;a=!!b&&this.get("isEditable")&&this.get("hasContent");if(a){return !b.isEnumerable||(SC.typeOf(b.removeObject)===SC.T_FUNCTION)}else{return NO}}.property("content","isEditable","hasContent"),canReorderContent:function(){var b=this.get("content"),a;a=!!b&&this.get("isEditable")&&!this.get("orderBy");return a&&!!b.isSCArray}.property("content","isEditable","orderBy"),canAddContent:function(){var b=this.get("content"),a;a=b&&this.get("isEditable")&&b.isEnumerable;if(a){return(SC.typeOf(b.addObject)===SC.T_FUNCTION)||(SC.typeOf(b.pushObject)===SC.T_FUNCTION)}else{return NO}}.property("content","isEditable"),hasContent:function(){var a=this.get("content");return !!a&&(!!a.isEnumerable||!!this.get("allowsSingleContent"))}.property("content","allowSingleContent"),status:function(){var b=this.get("content"),a=b?b.get("status"):null;return a?a:SC.Record.READY}.property().cacheable(),addObject:function(a){if(!this.get("canAddContent")){throw new Error("%@ 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 new Error("%@.content does not support addObject".fmt(this))}}return this},removeObject:function(a){if(!this.get("canRemoveContent")){throw new Error("%@ cannot remove content".fmt(this))}var b=this.get("content");if(b.isEnumerable){b.removeObject(a)}else{this.set("content",null)}if(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(g,f,d){if(!d||d.get("length")===0){if(!this.get("canRemoveContent")){throw new Error("%@ cannot remove objects from the current content".fmt(this))}}else{if(!this.get("canReorderContent")){throw new Error("%@ cannot add or reorder the current content".fmt(this))}}var c=this.get("content");var b=[],a,e;if(this.get("destroyOnRemoval")){for(a=0;a<f;a++){b.push(c.objectAt(a+g))}}if(c){c.replace(g,f,d)}for(a=0,e=b.length;a<e;a++){b[a].destroy()}b=null;return this},indexOf:function(b,a){var c=this._scac_observableContent();return c?c.indexOf(b,a):-1},init:function(){arguments.callee.base.apply(this,arguments);this._scac_contentDidChange()},_scac_cached:NO,_scac_observableContent:function(){var b=this._scac_cached;if(b){return b}var e=this.get("content"),d,a;if(SC.none(e)){return(this._scac_cached=[])}if(!e.isEnumerable){b=this.get("allowsSingleContent")?[e]:[];return(this._scac_cached=b)}var f=this.get("orderBy");if(!f){if(e.isSCArray){return(this._scac_cached=e)}else{throw new Error("%@.orderBy is required for unordered content".fmt(this))}}var c=SC.typeOf(f);if(c===SC.T_STRING){f=[f]}else{if(c===SC.T_FUNCTION){d=f}else{if(c!==SC.T_ARRAY){throw new Error("%@.orderBy must be Array, String, or Function".fmt(this))}}}d=d||function(o,n){var j,p,m,g,q;for(var k=0,h=f.get("length");k<h&&!j;k++){p=f.objectAt(k);if(p.search(/(ASC|DESC)/)===0){m=p.match(/^(ASC )?(DESC )?(.*)$/);p=m[3]}else{m=p.match(/^(\S*)\s*(DESC)?(?:ASC)?$/);p=m[1]}a=m[2]?-1:1;if(o){g=o.isObservable?o.get(p):o[p]}if(n){q=n.isObservable?n.get(p):n[p]}j=SC.compare(g,q)*a}return j};return(this._scac_cached=e.toArray().sort(d))},propertyWillChange:function(a){if(a==="content"){this.arrayContentWillChange(0,this.get("length"),0)}else{return arguments.callee.base.apply(this,arguments)}},_scac_arrayContentWillChange:function(e,d,b){if(this.get("orderBy")){var a=this.get("length");e=0;b=a+b-d;d=a}this.arrayContentWillChange(e,d,b);if(this._kvo_enumerable_property_chains){var c=this.slice(e,e+d);this.teardownEnumerablePropertyChains(c)}},_scac_arrayContentDidChange:function(e,d,b){this._scac_cached=NO;if(this.get("orderBy")){var a=this.get("length");e=0;b=a+b-d;d=a}this.arrayContentDidChange(e,d,b);if(this._kvo_enumerable_property_chains){var c=this.slice(e,e+b);this.setupEnumerablePropertyChains(c)}this.updateSelectionAfterContentChange()},_scac_contentDidChange:function(){this._scac_cached=NO;var d=this.get("content"),b=this._scac_content,f=this._scac_arrayContentDidChange,a=this._scac_arrayContentWillChange,c=this._scac_contentStatusDidChange,e=this._scac_enumerableDidChange,g;if(d===b){return this}if(b){if(b.isSCArray){b.removeArrayObservers({target:this,didChange:f,willChange:a})}else{if(b.isEnumerable){b.removeObserver("[]",this,e)}}b.removeObserver("status",this,c);this.teardownEnumerablePropertyChains(b)}this._scac_cached=NO;this._scac_content=d;if(d){if(d.isSCArray){d.addArrayObservers({target:this,didChange:f,willChange:a});g=d.get("length")}else{if(d.isEnumerable){d.addObserver("[]",this,e);g=d.get("length")}else{g=1}}d.addObserver("status",this,c);this.setupEnumerablePropertyChains(d)}else{g=SC.none(d)?0:1}this._scac_length=g;this._scac_contentStatusDidChange();this.arrayContentDidChange(0,0,g);this.updateSelectionAfterContentChange()}.observes("content"),_scac_enumerableDidChange:function(){var a=this.get("content"),c=a?a.get("length"):0,b=this._scac_length;this._scac_length=c;this._scac_cached=NO;this.arrayContentWillChange(0,b,c);this.arrayContentDidChange(0,b,c);this.updateSelectionAfterContentChange()}.observes("orderBy"),_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 b=this.get("content"),a,c;if(b&&b.isEnumerable){a=b.get("length");c=this.get("allowsMultipleContent");if(a===1){b=b.firstObject()}else{if(a===0||!c){b=null}}if(b&&!c&&b.isEnumerable){b=null}}return b}.property("content","allowsMultipleContent").cacheable(),destroy:function(){var a=this.get("observableContent");if(a&&SC.typeOf(a.destroy)===SC.T_FUNCTION){a.destroy()}this.set("content",null);return this},contentPropertyDidChange:function(b,a){if(a==="*"){this.allPropertiesDidChange()}else{this.notifyPropertyChange(a)}},unknownProperty:function(b,d){if(b==="content"){if(d!==undefined){this.content=d}return this.content}var c=this.get("observableContent"),f,e,a;if(c===null||c===undefined){return undefined}if(d===undefined){if(c.isEnumerable){d=c.getEach(b);f=d.get("length");if(f>0){a=YES;e=d.objectAt(0);while((--f>0)&&a){if(e!==d.objectAt(f)){a=NO}}if(a){d=e}}else{d=undefined}}else{d=(c.isObservable)?c.get(b):c[b]}}else{if(!this.get("isEditable")){throw new Error("%@.%@ is not editable".fmt(this,b))}if(c.isEnumerable){c.setEach(b,d)}else{if(c.isObservable){c.set(b,d)}else{c[b]=d}}}return d},init:function(){arguments.callee.base.apply(this,arguments);if(this.get("content")){this._scoc_contentDidChange()}if(this.get("observableContent")){this._scoc_observableContentDidChange()}},_scoc_contentDidChange:function(){var b=this._scoc_content,c=this.get("content");if(b!==c){this._scoc_content=c;var a=this._scoc_enumerableContentDidChange;if(b&&b.isEnumerable){b.removeObserver("[]",this,a)}if(c&&c.isEnumerable){c.addObserver("[]",this,a)}}}.observes("content"),_scoc_observableContentDidChange:function(){var b=this._scoc_observableContent,d=this.get("observableContent"),a=this.contentPropertyDidChange,c=this._scoc_enumerableContentDidChange;if(b===d){return this}this._scoc_observableContent=d;if(b){if(b.isEnumerable){b.removeObserver("[]",this,c)}else{if(b.isObservable){b.removeObserver("*",this,a)}}}if(d){if(d.isEnumerable){d.addObserver("[]",this,c)}else{if(d.isObservable){d.addObserver("*",this,a)}}}if((b&&b.isEnumerable)||(d&&d.isEnumerable)){this._scoc_enumerableContentDidChange()}else{this.contentPropertyDidChange(d,"*")}}.observes("observableContent"),_scoc_enumerableContentDidChange:function(){var b=this.get("observableContent"),c=this._scoc_observableContentItems,a=this.contentPropertyDidChange;if(c){c.forEach(function(d){if(d.isObservable){d.removeObserver("*",this,a)}},this);c.clear()}if(b&&b.isEnumerable){if(!c){c=SC.Set.create()}b.forEach(function(d){if(c.contains(d)){return}c.add(d);if(d.isObservable){d.addObserver("*",this,a)}},this)}else{c=null}this._scoc_observableContentItems=c;this.contentPropertyDidChange(b,"*");return this}});SC.mixin(Function.prototype,{invokeLater:function(e,a){if(a===undefined){a=1}var d=this;if(arguments.length>2){var b=SC.$A(arguments).slice(2,arguments.length);b.unshift(e);var c=d;d=function(){return c.apply(this,b.slice(1))}}return SC.Timer.schedule({target:e,action:d,interval:a})}});SC.mixin(SC.Object.prototype,{invokeLater:function(d,a){var c,b;if(SC.typeOf(d)===SC.T_STRING){d=this[d]}if(a===undefined){a=1}if(arguments.length>2){b=SC.$A(arguments).slice(2);c=function(){return d.apply(this,b)}}else{c=d}return SC.Timer.schedule({target:this,action:c,interval:a})},invokeOnceLater:function(i,c){var d,g,b,e=this._sc_invokeOnceLaterTimers,h,a;if(SC.typeOf(i)===SC.T_STRING){i=this[i]}if(c===undefined){c=1}if(!e){e=this._sc_invokeOnceLaterTimers={}}b=SC.guidFor(i);h=e[b];if(h){h.invalidate()}if(arguments.length>2){d=SC.$A(arguments).slice(2)}else{d=arguments}g=function(){delete e[b];return i.apply(this,d)};a=SC.Timer.schedule({target:this,action:g,interval:c});e[b]=a;return a},invokeWith:function(b,c,d){if(d===undefined){d=c;c=this}if(!c){c=this}if(SC.typeOf(d)===SC.T_STRING){d=c[d]}var a=this.getPath(b);d.call(c,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(b,a){this._timerQueue=b.removeFromTimerQueue(this._timerQueue);this._timerQueue=b.scheduleInTimerQueue(this._timerQueue,a);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 d=this.get("startTime"),e=this.TIMER_ARRAY,c,b,a;this._firing=YES;this._timerQueue=this._timerQueue.collectExpiredTimers(e,d);b=e.length;for(c=0;c<b;c++){e[c].fire()}a=e.length>0;e.length=0;this._firing=NO;return a},scheduleNextTimeout:function(){var a=NO,c=this._timerQueue;if(!c){if(this._timerTimeout){this.unscheduleRunLoop()}this._timerTimeout=null}else{var b=c._timerQueueRunTime;this._timerTimeout=this.scheduleRunLoop(b);a=YES}return a}});SC.RunLoop.currentRunLoop=SC.RunLoop.create();SC.RunLoop.runLoopClass=SC.RunLoop;sc_require("system/string");SC.supplement(String.prototype,{capitalize:function(){return SC.String.capitalize(this,arguments)},camelize:function(){return SC.String.camelize(this,arguments)},decamelize:function(){return SC.String.decamelize(this,arguments)},dasherize:function(){return SC.String.dasherize(this,arguments)},escapeCssIdForSelector:function(){return SC.String.escapeCssIdForSelector(this)},loc:function(){var a=SC.$A(arguments);a.unshift(this);return SC.String.loc.apply(SC.String,a)},locWithDefault:function(b){var a=SC.$A(arguments);a.unshift(this);return SC.String.locWithDefault.apply(SC.String,a)},mult:function(a){return SC.String.mult(this,a)}});SC.methodForLocale("fr","ordinalForNumber",function(a){return a==1?"er":"e"});SC.ActionSupport={action:null,actionContext:null,target:null,fireAction:function(b){var e=this.get("pane"),c=e.get("rootResponder"),d=this.get("action"),a;if(b===undefined){a=this.get("actionContext")}else{if(typeof b===SC.T_STRING&&d==null){d=b;a=this.get("actionContext")}else{a=b}}if(d&&c){return c.sendAction(d,this.get("target"),this,e,a,this)}return false}};sc_require("system/responder");SC.ResponderContext={isResponderContext:YES,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){return"(No Responder)"}else{if(a._scrc_name){return a._scrc_name}}var b=this.NAMESPACE;this._findResponderNamesFor(this,3,b?[this.NAMESPACE]:[]);return a._scrc_name||a.toString()},_findResponderNamesFor:function(a,e,d){var b,c;for(b in a){if(b==="nextResponder"){continue}c=a[b];if(c&&c.isResponder){if(c._scrc_name){continue}d.push(b);c._scrc_name=d.join(".");if(e>0){this._findResponderNamesFor(c,e-1,d)}d.pop()}}},makeFirstResponder:function(b,a){var e=this.get("firstResponder"),d=this.get("nextResponder"),c;if(this._locked){this._pendingResponder=b;return}if(b){b.set("becomingFirstResponder",YES)}this._locked=YES;this._pendingResponder=null;c=b?b:null;while(c){if(c.get("hasFirstResponder")){break}c=(c===d)?null:this.nextResponderFor(c)}if(!c){c=d}this._notifyWillLoseFirstResponder(e,e,c,a);if(e){e.set("isFirstResponder",NO)}this.beginPropertyChanges();this.set("firstResponder",b);if(b){b.set("isFirstResponder",YES)}this._notifyDidBecomeFirstResponder(b,b,c);this.endPropertyChanges();this._locked=NO;if(this._pendingResponder){this.makeFirstResponder(this._pendingResponder);this._pendingResponder=null}if(b){b.set("becomingFirstResponder",NO)}return this},_notifyWillLoseFirstResponder:function(c,e,b,a){if(!e||e===b){return}e.willLoseFirstResponder(c,a);e.set("hasFirstResponder",NO);var d=this.nextResponderFor(e);if(d){this._notifyWillLoseFirstResponder(c,d,b)}},_notifyDidBecomeFirstResponder:function(b,d,a){if(!d||d===a){return}var c=this.nextResponderFor(d);if(c){this._notifyDidBecomeFirstResponder(b,c,a)}d.set("hasFirstResponder",YES);d.didBecomeFirstResponder(b)},resetFirstResponder:function(){var a=this.get("firstResponder");if(!a){return}a.willLoseFirstResponder();a.didBecomeFirstResponder()},sendAction:function(f,d,c){var a=this.get("firstResponder"),e=this.get("nextResponder"),g=NO,b;this._locked=YES;if(!g&&!a&&this.tryToPerform){g=this.tryToPerform(f,d,c)}while(!g&&a){if(a.tryToPerform){g=a.tryToPerform(f,d,c)}if(!g){a=(a===e)?null:this.nextResponderFor(a)}}this._locked=NO;if(b=this._pendingResponder){this._pendingResponder=null;this.makeFirstResponder(b)}return a}};SC.bodyOverflowArbitrator=SC.Object.create({requestHidden:function(b,a){this._makeRequest(b,-1-9*!!a)},requestVisible:function(b,a){this._makeRequest(b,1+9*!!a)},withdrawRequest:function(c){if(!c){return}var a=SC.guidFor(c),b=this._requests[a];if(b){delete this._requests[a];this.setOverflow()}},setOverflow:function(){var a=this._decideOverflow();if(a!==undefined){document.body.style.overflow=a?"auto":"hidden"}},_makeRequest:function(d,c){if(!d){return}var a=SC.guidFor(d),b=this._requests[a];if(b!=c){this._requests[a]=c;this.setOverflow()}},_requests:{},_decideOverflow:function(){var a,e,c,f,b=this._requests,g;for(var d in b){if((g=b[d])<0){a=YES}if(g<-1){c=YES}if(g>0){e=YES}if(g>1){f=YES}}if(f){return YES}if(e&&c){return NO}if(e){return YES}if(a){return NO}return undefined}});sc_require("views/view");SC.ANIMATABLE_PROPERTIES={top:YES,left:YES,bottom:YES,right:YES,width:YES,height:YES,centerX:YES,centerY:YES,opacity:YES,scale:YES,rotate:YES,rotateX:YES,rotateY:YES,rotateZ:YES};SC.LayoutState={START:1,CURRENT:2,END:3};SC.View.reopen({_SC_DECOMPOSED_TRANSFORM_MAP:null,_activeAnimations:null,_activeAnimationsLength:null,_animateLayout:null,_pendingAnimations:null,_prevLayout:null,animate:function(m,j,o,i,a){var l,e,c=NO,n=NO,f,h,d,g=this._pendingAnimations,b;if(typeof m===SC.T_STRING){f={};f[m]=j}else{a=i;i=o;o=j;f=m}d=SC.typeOf(o);if(d===SC.T_NUMBER){o={duration:o}}else{if(d!==SC.T_HASH){throw new Error("Must provide options hash!")}}if(o.callback){a=o.callback;delete o.callback}if(a===undefined){a=i;i=this}if(!i){i=this}if(a){if(typeof a==="string"){a=i[a]}o.target=i;o.method=a}if(o.duration===0){this.invokeNext(function(){this.adjust(f);this.runAnimationCallback(o,null,false)});return this}if(!this.get("isVisibleInWindow")){this.invokeNext(function(){this.adjust(f);this.runAnimationCallback(o,null)});return this}b=o.timing;if(b){if(typeof b!==SC.T_STRING){o.timing="cubic-bezier("+b[0]+", "+b[1]+", "+b[2]+", "+b[3]+")"}}else{o.timing="ease"}if(SC.none(o.delay)){o.delay=0}if(!this._prevLayout){this._prevLayout=SC.clone(this.get("explicitLayout"))}if(!g){g=this._pendingAnimations={}}h=this._animateLayout||SC.clone(this.get("explicitLayout"));if(!SC.none(f.rotate)){if(SC.none(f.rotateZ)){f.rotateZ=f.rotate}delete f.rotate}for(var k in f){if(!f.hasOwnProperty(k)||!SC.ANIMATABLE_PROPERTIES[k]){continue}j=f[k];l=h[k];e=g[k];if(SC.none(j)){throw new Error("Can only animate to an actual value!")}if(e&&(e.duration!==o.duration||e.timing!==o.timing||e.delay!==o.delay)){n=YES;this.runAnimationCallback(e,null,YES)}if(l!==j||n){c=YES;h[k]=j;g[k]=o}}if(c){if(!SC.none(g.height)&&!SC.none(h.centerY)&&SC.none(g.centerY)){if(Math.abs(f.height-this.get("layout").height)>=2){g.centerY=o}}if(!SC.none(g.width)&&!SC.none(h.centerX)&&SC.none(g.centerX)){if(Math.abs(f.width-this.get("layout").width)>=2){g.centerX=o}}this._animateLayout=h;this.invokeNext("_animate")}else{if(!n){this.invokeNext(function(){this.runAnimationCallback(o,null,false)})}}return this},_animate:function(){var a=this._animateLayout;if(a){this.willRenderAnimations();this._animateLayout=null;this.set("layout",a);if(this.get("viewState")===SC.CoreView.ATTACHED_SHOWN){this.set("viewState",SC.CoreView.ATTACHED_SHOWN_ANIMATING)}}},_animateFrames:function(d,e,b,a){if(SC.none(a)){a=0}var c=d[a];this.animate(c.value,{delay:b,duration:c.duration,timing:c.timing},function(f){a+=1;if(!f.isCancelled&&a<d.length){this._animateFrames(d,e,0,a)}else{if(e){e(f)}}});return this},cancelAnimation:function(d){var a=this._activeAnimations,f=this._pendingAnimations,g,c,e,b=NO;switch(d){case SC.LayoutState.START:e=this._prevLayout;break;case SC.LayoutState.CURRENT:e=this.get("liveAdjustments");break;default:e=this._animateLayout}if(this.get("viewState")===SC.CoreView.ATTACHED_SHOWN_ANIMATING){this.set("viewState",SC.CoreView.ATTACHED_SHOWN)}for(c in f){g=f[c];b=YES;delete f[c];this.runAnimationCallback(g,null,YES)}for(c in a){g=a[c];b=YES;delete a[c];this.removeAnimationFromLayout(c,YES);this.runAnimationCallback(g,null,YES)}if(b&&!!e){this.set("layout",e)}this._prevLayout=this._activeAnimations=this._pendingAnimations=this._animateLayout=null;return this},didRenderAnimations:function(){if(!SC.platform.supportsCSSTransitions||document.hidden){var b=this._pendingAnimations;for(var a in b){this.removeAnimationFromLayout(a,NO);this.runAnimationCallback(b[a],null,NO)}if(this.get("viewState")===SC.CoreView.ATTACHED_SHOWN_ANIMATING){this.set("viewState",SC.CoreView.ATTACHED_SHOWN)}this._activeAnimations=this._pendingAnimations=null}},_sc_decompose3DTransformMatrix:function(a,d){var b=SC.View._SC_DECOMPOSED_TRANSFORM_MAP,c=180/Math.PI;if(!b){b=SC.View._SC_DECOMPOSED_TRANSFORM_MAP={}}if(d){b.scaleX=Math.sqrt((a.m11*a.m11)+(a.m12*a.m12)+(a.m13*a.m13));b.scaleY=Math.sqrt((a.m21*a.m21)+(a.m22*a.m22)+(a.m23*a.m23));b.scaleZ=Math.sqrt((a.m31*a.m31)+(a.m32*a.m32)+(a.m33*a.m33));a=a.scale(1/b.scaleX,1/b.scaleY,1/b.scaleZ)}else{b.scaleX=1;b.scaleY=1;b.scaleZ=1}b.rotateZ=-Math.atan2(a.m21,a.m11)*c;if(b.rotateZ<0){b.rotateZ=360+b.rotateZ}b.translateX=a.m41;b.translateY=a.m42;b.translateZ=a.m43;return b},_sc_removeENotationFromMatrixString:function(b){var g,c,d;g=b.split(/\(|\)/);c=g[1].split(",");for(var e=0,a=c.length;e<a;e++){var f=c[e];if(f.indexOf("e")>0){c[e]=window.parseFloat(f).toFixed(20)}}d=g[0]+"("+c.join(", ")+")";return d},liveAdjustments:function(){var l=this._activeAnimations,b=this.get("layer"),f={},g=SC.browser.experimentalCSSNameFor("transform");if(l){for(var k in l){var j=document.defaultView.getComputedStyle(b)[k];if(k===g){var i=SC.browser.experimentalNameFor(window,"CSSMatrix"),h;if(i!==SC.UNSUPPORTED){j=this._sc_removeENotationFromMatrixString(j);h=new window[i](j);var d=this.get("layout"),e=d.scale,c=e!=null,a=this._sc_decompose3DTransformMatrix(h,c);if(d.rotateZ!=null){f.rotateZ=a.rotateZ}if(c){if(SC.typeOf(e)===SC.T_ARRAY){f.scale=[a.scaleX,a.scaleY]}else{if(SC.typeOf(e)===SC.T_HASH){f.scale={x:a.scaleX,y:a.scaleY}}else{f.scale=a.scaleX}}}if(this.get("hasAcceleratedLayer")){f.left=a.translateX;f.top=a.translateY}}else{h=j.match(/^matrix\((.*)\)$/)[1].split(/,\s*/);if(h&&this.get("hasAcceleratedLayer")){f.left=parseInt(h[4],10);f.top=parseInt(h[5],10)}}}else{j=window.parseFloat(j,10);if(k==="centerX"){j=j+parseInt(document.defaultView.getComputedStyle(b).width,10)/2}else{if(k==="centerY"){j=j+parseInt(document.defaultView.getComputedStyle(b).height,10)/2}}f[k]=j}}}return f}.property(),removeAnimationFromLayout:function(b,c){var a=this._activeAnimations,e=this.get("layer");if(!!e&&c){var f=[];for(var d in a){if(d!==b){f.push(a[d].css)}}e.style[SC.browser.experimentalStyleNameFor("transition")]=f.join(", ")}},resetAnimation:function(){return this.cancelAnimation()},runAnimationCallback:function(c,a,b){var e=c.method,d=c.target;if(e){e.call(d,{event:a,view:this,isCancelled:b});delete c.method;delete c.target}},transitionDidEnd:function(b){var c=b.originalEvent.propertyName,a=this._activeAnimations,d;if(c==="margin-left"){c="centerX"}if(c==="margin-top"){c="centerY"}d=a?a[c]:null;if(d){delete a[c];this.removeAnimationFromLayout(c,YES);this._activeAnimationsLength-=1;if(this._activeAnimationsLength===0){if(this.get("viewState")===SC.CoreView.ATTACHED_SHOWN_ANIMATING){this.set("viewState",SC.CoreView.ATTACHED_SHOWN)}this._activeAnimations=this._prevLayout=null}this.runAnimationCallback(d,b,NO)}},willRenderAnimations:function(){if(SC.platform.supportsCSSTransitions&&!document.hidden){var e=this._pendingAnimations;if(e){var b=this._activeAnimations;if(!b){this._activeAnimationsLength=0;b={}}for(var d in e){if(!e.hasOwnProperty(d)){continue}var a=b[d],c=e[d];if(a){this.runAnimationCallback(a,null,YES)}b[d]=c;this._activeAnimationsLength+=1}this._activeAnimations=b;this._pendingAnimations=null}}}});sc_require("ext/string");sc_require("views/view");sc_require("views/view/animation");SC.CSS_TRANSFORM_NAMES=["rotateX","rotateY","rotateZ","scale"];SC.CSS_TRANSFORM_MAP={rotate:function(a){if(SC.typeOf(a)===SC.T_NUMBER){a+="deg"}return"rotate("+a+")"},rotateX:function(a){if(SC.typeOf(a)===SC.T_NUMBER){a+="deg"}return"rotateX("+a+")"},rotateY:function(a){if(SC.typeOf(a)===SC.T_NUMBER){a+="deg"}return"rotateY("+a+")"},rotateZ:function(a){if(SC.typeOf(a)===SC.T_NUMBER){a+="deg"}return"rotateZ("+a+")"},scale:function(a){if(SC.typeOf(a)===SC.T_ARRAY){a=a.join(", ")}return"scale("+a+")"}};SC.View.LayoutStyleCalculator={_SC_STATE_MAP:null,_SC_TRANSFORMS_ARRAY:null,_SC_TRANSITIONS_ARRAY:null,_valueOrNull:function(a){return a===undefined?null:a},_prepareStyle:function(b,d){var f=this._valueOrNull(d.border);b.marginLeft=null;b.marginTop=null;b.bottom=d.bottom;b.right=d.right;b.left=d.left;b.top=d.top;b.centerX=d.centerX;b.centerY=d.centerY;b.height=d.height;b.width=d.width;b.borderTopWidth=d.borderTop!==undefined?d.borderTop:f;b.borderRightWidth=d.borderRight!==undefined?d.borderRight:f;b.borderBottomWidth=d.borderBottom!==undefined?d.borderBottom:f;b.borderLeftWidth=d.borderLeft!==undefined?d.borderLeft:f;b.maxHeight=this._valueOrNull(d.maxHeight);b.maxWidth=this._valueOrNull(d.maxWidth);b.minWidth=this._valueOrNull(d.minWidth);b.minHeight=this._valueOrNull(d.minHeight);b.zIndex=(d.zIndex!=null)?d.zIndex.toString():null;b.opacity=(d.opacity!=null)?d.opacity.toString():null;b.backgroundPosition=this._valueOrNull(d.backgroundPosition);if(SC.platform.supportsCSSTransforms){var a=SC.browser.experimentalStyleNameFor("transform"),g=this._SC_TRANSFORMS_ARRAY,l=SC.CSS_TRANSFORM_MAP;if(!g){g=this._SC_TRANSFORMS_ARRAY=[]}for(var c=0,e=SC.CSS_TRANSFORM_NAMES.length;c<e;c++){var h=SC.CSS_TRANSFORM_NAMES[c],j=d[h];if(j!=null){g.push(l[h](j))}}b[a]=g.length>0?g.join(" "):null;var n=SC.browser.experimentalStyleNameFor("transformOrigin"),m=d.transformOriginX,k=d.transformOriginY;if(m==null&&k==null){b[n]=null}else{if(m==null){m=0.5}if(k==null){k=0.5}b[n]=(m*100)+"% "+(k*100)+"%"}}if(SC.platform.supportsCSSTransitions){b[SC.browser.experimentalStyleNameFor("transition")]=null}this._SC_TRANSFORMS_ARRAY.length=0},_prepareState:function(b,a){b.hasBottom=(a.bottom!=null);b.hasRight=(a.right!=null);b.hasLeft=(a.left!=null);b.hasTop=(a.top!=null);b.hasCenterX=(a.centerX!=null);b.hasCenterY=(a.centerY!=null);b.hasHeight=(a.height!=null);b.hasWidth=(a.width!=null);b.hasMaxWidth=(a.maxWidth!=null);b.hasMaxHeight=(a.maxHeight!=null)},_invalidAutoValue:function(a,b){SC.throw("%@.layout() you cannot use %@:auto if staticLayout is disabled".fmt(a,b),"%@".fmt(a),-1)},_calculatePosition:function(c,b,l){var d,m,o,e,n,i,h,g,k;if(l==="X"){d="left";m="right";o="width";g="borderLeftWidth";k="borderRightWidth";e=b.hasLeft;n=b.hasRight;i=b.hasWidth;h=b.hasMaxWidth}else{d="top";m="bottom";o="height";g="borderTopWidth";k="borderBottomWidth";e=b.hasTop;n=b.hasBottom;i=b.hasHeight;h=b.hasMaxHeight}c[d]=this._cssNumber(c[d]);c[m]=this._cssNumber(c[m]);var j=this._cssNumber(c[g]),f=this._cssNumber(c[k]),a=c[o];c[g]=j;c[k]=f;if(a>=1){a-=(j+f)}c[o]=this._cssNumber(a);if(e){if(n&&i){c[m]=null}}else{if(!n||(n&&!i&&!h)){c[d]=0}}if(!i&&!n){c[m]=0}},_calculateCenter:function(b,l){var o,a,c,m,e,f,k;if(l==="X"){o="width";a="centerX";c="left";m="right";e="marginLeft";f="borderLeftWidth";k="borderRightWidth"}else{o="height";a="centerY";c="top";m="bottom";e="marginTop";f="borderTopWidth";k="borderBottomWidth"}b[c]="50%";var j=this._cssNumber(b[f]),d=this._cssNumber(b[k]),i=b[o],h=b[a],g=SC.isPercentage(i),n;b[f]=j;b[k]=d;if(SC.none(i)){b[e]="50%"}else{n=h-i/2;b[e]=(g)?Math.floor(n*100)+"%":Math.floor(n)}if(i>1){i-=(j+d)}b[o]=this._cssNumber(i)||0;b[m]=b[a]=null},_cssNumber:function(a){if(a==null){return null}else{if(a===SC.LAYOUT_AUTO){return SC.LAYOUT_AUTO}else{if(SC.isPercentage(a)){return(a*100)+"%"}else{return Math.floor(a)}}}},calculate:function(a,c){var d=a.get("layout"),h=a._activeAnimations,f=this._SC_STATE_MAP,g=a.get("useStaticLayout");if(g&&d===SC.View.prototype.layout){return{}}this._prepareStyle(c,d);if(!f){f=this._SC_STATE_MAP={}}this._prepareState(f,c);if(!g){if(c.width===SC.LAYOUT_AUTO){this._invalidAutoValue(a,"width")}if(c.height===SC.LAYOUT_AUTO){this._invalidAutoValue(a,"height")}}if(f.hasLeft||f.hasRight||!f.hasCenterX){this._calculatePosition(c,f,"X")}else{this._calculateCenter(c,"X")}if(f.hasTop||f.hasBottom||!f.hasCenterY){this._calculatePosition(c,f,"Y")}else{this._calculateCenter(c,"Y")}this._calculateAnimations(c,h,a.get("hasAcceleratedLayer"));for(var b in c){var e=c[b];if(typeof e===SC.T_NUMBER){c[b]=(e+"px")}}return c},_calculateAnimations:function(b,l,f){var k,e;if(f){e=YES;if(l&&(l.top||l.left)){for(k in l){if(SC.CSS_TRANSFORM_MAP[k]&&((l.top&&l.top.duration!==l[k].duration)||(l.left&&l.left.duration!==l[k].duration))){e=NO}}}if(e){var a=SC.browser.experimentalStyleNameFor("transform"),h=b[a],d;d="translateX("+b.left+"px) translateY("+b.top+"px)";if(SC.platform.supportsCSS3DTransforms){d+=" translateZ(0px)"}if(h){d+=" "+h}b[a]=d;b.left=0;b.top=0}}if(l){if(SC.platform.supportsCSSTransitions){var i=this._SC_TRANSITIONS_ARRAY;if(!i){i=this._SC_TRANSITIONS_ARRAY=[]}for(k in l){var g=l[k],m=!!SC.CSS_TRANSFORM_MAP[k],c=e&&(k==="top"||k==="left");if(SC.platform.supportsCSSTransforms&&(c||m)){delete l[k];k=SC.browser.experimentalCSSNameFor("transform");var j=l[k];if(j){g=j}else{l[k]=g}}if(k==="centerX"){k="margin-left"}if(k==="centerY"){k="margin-top"}g.css=k+" "+g.duration+"s "+g.timing+" "+g.delay+"s";if(i.indexOf(g.css)<0){i.push(g.css)}}b[SC.browser.experimentalStyleNameFor("transition")]=i.join(", ");this._SC_TRANSITIONS_ARRAY.length=0}else{}}}};SC.View.reopen({_SC_STYLE_MAP:null,layoutStyle:function(){var a=this._SC_STYLE_MAP;if(!a){a=this._SC_STYLE_MAP={}}return SC.View.LayoutStyleCalculator.calculate(this,a)}.property("layout","hasAcceleratedLayer","useStaticLayout").cacheable()});sc_require("views/view");sc_require("views/view/layout_style");SC.LAYOUT_HORIZONTAL="sc-layout-horizontal";SC.LAYOUT_VERTICAL="sc-layout-vertical";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._ROTATION_VALUE_REGEX=/^\-?\d+(\.\d*)?(rad|deg)$/;SC._SCALE_VALUE_REGEX=/^\d+(,\d+){0,2}$/;SC._PERCENT_VALUE_REGEX=/^\-?\d+(\.\d*)?%$/;SC.View.reopen({_sc_previousLayout:null,backgroundColor:null,borderFrame:function(){var b=this.get("frame"),h=null;if(b){var f=this.get("layout"),k=f.border==null?0:f.border,d=this._sc_explicitValueFor(f.borderTop,k),m=this._sc_explicitValueFor(f.borderRight,k),j=this._sc_explicitValueFor(f.borderBottom,k),i=this._sc_explicitValueFor(f.borderLeft,k);h={x:b.x,y:b.y,width:b.width,height:b.height};var c=b.scale;if(c!=null){var a=d*c,e=m*c,g=j*c,l=i*c;h.scale=c;h.x-=l;h.y-=a;h.width+=l+e;h.height+=a+g}else{h.x-=i;h.y-=d;h.width+=i+m;h.height+=d+j}if(b.transformOriginX!=null){h.transformOriginX=b.transformOriginX}if(b.transformOriginY!=null){h.transformOriginY=b.transformOriginY}}return h}.property("frame").cacheable(),childViewsNeedLayout:NO,childViewLayout:null,childViewLayoutOptions:null,explicitLayout:function(){var b=this.get("layout"),a=null;if(b){a=this._sc_computeExplicitLayout(b)}return a}.property("layout").cacheable(),hasLayout:true,isChildViewLayoutLive:true,isFixedHeight:function(){var a=this.get("layout");return(a.height!==undefined)&&!SC.isPercentage(a.height)&&(a.height!==SC.LAYOUT_AUTO)}.property("layout").cacheable(),isFixedLayout:function(){return this.get("isFixedPosition")&&this.get("isFixedSize")}.property("isFixedPosition","isFixedSize").cacheable(),isFixedPosition:function(){var e=this.get("explicitLayout"),d=e.left,c=e.top,b,a;b=d!==undefined&&!SC.isPercentage(d)&&d!==SC.LAYOUT_AUTO;a=c!==undefined&&!SC.isPercentage(c)&&c!==SC.LAYOUT_AUTO;return b&&a}.property("explicitLayout").cacheable(),isFixedSize:function(){return this.get("isFixedHeight")&&this.get("isFixedWidth")}.property("isFixedWidth","isFixedHeight").cacheable(),isFixedWidth:function(){var a=this.get("layout");return(a.width!==undefined)&&!SC.isPercentage(a.width)&&(a.width!==SC.LAYOUT_AUTO)}.property("layout").cacheable(),layout:{top:0,left:0,bottom:0,right:0},layoutView:function(){return this.get("parentView")}.property("parentView").cacheable(),transitionAdjust:null,transitionAdjustOptions:null,useStaticLayout:NO,_sc_adjustForBorder:function(f,d){var b=d.border==null?0:d.border,g=this._sc_explicitValueFor(d.borderTop,b),e=this._sc_explicitValueFor(d.borderLeft,b),c=this._sc_explicitValueFor(d.borderBottom,b),a=this._sc_explicitValueFor(d.borderRight,b);f.x+=e;f.y+=g;f.width-=(e+a);f.height-=(g+c);return f},_sc_adjustForScale:function(e,c){if(!SC.platform.supportsCSSTransforms){e.scale=1;e.transformOriginX=e.transformOriginY=0.5}else{var d=c.scale,b=c.transformOriginX,a=c.transformOriginY;if(d!=null&&d!==1){e=SC.scaleRect(e,d,b,a);e.scale=d}if(b!=null&&b!==0.5){e.transformOriginX=b}if(a!=null&&a!==0.5){e.transformOriginY=a}}if(e.height<0){e.height=0}if(e.width<0){e.width=0}return e},_sc_applyAdjustment:function(a,e,b,d){var c=this._animateLayout;if(c){if(e===null){delete c[a]}else{c[a]=e}if(this._pendingAnimations&&this._pendingAnimations[a]){delete this._pendingAnimations[a]}}if(e!==undefined&&b[a]!=e){if(!d){d=SC.clone(this.get("layout"))}if(e===null){delete d[a]}else{d[a]=e}}return d},_sc_checkForResize:function(b,d){var e=true,c=true,a=true;if(b!=null&&((b.width!=null&&b.width===d.width)||(b.width==null&&d.width==null&&b.left===d.left&&b.right===d.right))){c=false}if(!c&&((b.height!=null&&b.height===d.height)||(b.height==null&&d.height==null&&b.top===d.top&&b.bottom===d.bottom))){e=false}if(!e&&!c){a=!(b.border===d.border&&b.borderTop===d.borderTop&&b.borderLeft===d.borderLeft&&b.borderBottom===d.borderBottom&&b.borderRight===d.borderRight)}return a},_cvl_childViewLayoutDidChange:function(){this.set("childViewsNeedLayout",true);this.invokeOnce(this.layoutChildViewsIfNeeded)},_cvl_childViewsDidChange:function(){this._cvl_teardownChildViewsLiveLayout();this._cvl_setupChildViewsLiveLayout();this.set("childViewsNeedLayout",true);this.invokeOnce(this.layoutChildViewsIfNeeded)},_cvl_setupChildViewsLiveLayout:function(){var a=this.childViewLayout,h,b=a.childLayoutProperties||[];h=this._cvl_childViews=this.get("childViews");for(var d=0,g=b.length;d<g;d++){var f=b[d];for(var c=0,k=h.get("length");c<k;c++){var e=h.objectAt(c);if(!e.get("useAbsoluteLayout")&&!e.get("useStaticLayout")){e.addObserver(f,this,this._cvl_childViewLayoutDidChange)}}}},_cvl_teardownChildViewsLiveLayout:function(){var a=this.childViewLayout,h=this._cvl_childViews||[],b=a.childLayoutProperties||[];for(var d=0,g=b.length;d<g;d++){var f=b[d];for(var c=0,k=h.get("length");c<k;c++){var e=h.objectAt(c);if(!e.get("useAbsoluteLayout")&&!e.get("useStaticLayout")){e.removeObserver(f,this,this._cvl_childViewLayoutDidChange)}}}},_sc_computeExplicitLayout:function(g){var h=SC.copy(g);var b=(g.bottom!=null);var k=(g.right!=null);var i=(g.left!=null);var e=(g.top!=null);var c=(g.centerX!=null);var a=(g.centerY!=null);var j=(g.height!=null);var d=(g.width!=null);delete h.right;delete h.bottom;if(i){h.left=g.left}else{if(!c&&!(d&&k)){h.left=0}}if(k&&!(i&&d)){h.right=g.right}else{if(!c&&!d){h.right=0}}if(e){h.top=g.top}else{if(!a&&!(j&&b)){h.top=0}}if(b&&!(e&&j)){h.bottom=g.bottom}else{if(!a&&!j){h.bottom=0}}if(c){h.centerX=g.centerX}if(a){h.centerY=g.centerY}var f=g.border;if(f!=null){h.borderTop=f;h.borderRight=f;h.borderBottom=f;h.borderLeft=f;delete h.border}if(g.borderTop!=null){h.borderTop=g.borderTop}if(g.borderRight!=null){h.borderRight=g.borderRight}if(g.borderBottom!=null){h.borderBottom=g.borderBottom}if(g.borderLeft!=null){h.borderLeft=g.borderLeft}return h},_sc_convertFrameFromViewHelper:function(d,e,a){var l=d.x,j=d.y,b=d.width,c=d.height,k,h;if(e){k=e;while(k&&(h=k.get("frame"))){if(h.scale&&h.scale!==1){l*=h.scale;j*=h.scale;b*=h.scale;c*=h.scale}l+=h.x;j+=h.y;k=k.get("layoutView")}}if(a){var m=[];k=a;while(k&&k.get("frame")){m.unshift(k);k=k.get("layoutView")}for(var g=0;g<m.length;g++){k=m[g];h=k.get("frame");l-=h.x;j-=h.y;if(h.scale&&h.scale!==1){l/=h.scale;j/=h.scale;b/=h.scale;c/=h.scale}}}return{x:l,y:j,width:b,height:c}},_sc_explicitValueFor:function(a,b){return a===undefined?b:a},_sc_transitionAdjust:function(c){var b=this.get("transitionAdjust"),a=this.get("transitionAdjustOptions")||{};b.run(this,a,c)},_sc_viewFrameDidChange:function(){this.notifyPropertyChange("frame");this._callOnChildViews("_sc_clippingFrameDidChange")},adjust:function(b,f){if(b===undefined){return this}var d=this.get("layout"),e;if(SC.typeOf(b)===SC.T_STRING){e=this._sc_applyAdjustment(b,f,d)}else{for(var c in b){if(!b.hasOwnProperty(c)){continue}e=this._sc_applyAdjustment(c,b[c],d,e)}}if(e){var a=this.get("transitionAdjust");if(this.get("viewState")&SC.CoreView.IS_SHOWN&&a){this._sc_transitionAdjust(e)}else{this.set("layout",e)}}return this},computeParentDimensions:function(d){var b=this.get("parentView"),c=(b)?b.get("frame"):null,a;if(c){a={width:c.width,height:c.height}}else{if(d){a={width:(d.left||0)+(d.width||0)+(d.right||0),height:(d.top||0)+(d.height||0)+(d.bottom||0)}}else{a={width:0,height:0}}}return a},convertFrameToView:function(b,a){return this._sc_convertFrameFromViewHelper(b,this,a)},convertFrameFromView:function(b,a){return this._sc_convertFrameFromViewHelper(b,a,this)},didTransitionAdjust:function(){},layoutDidChange:function(){var c=this.get("layout");if(!SC.none(c.rotate)){if(SC.none(c.rotateZ)&&SC.platform.get("supportsCSS3DTransforms")){c.rotateZ=c.rotate;delete c.rotate}}var a=this._sc_checkForResize(this._sc_previousLayout,c);this._sc_previousLayout=c;if(a){this.viewDidResize()}else{this._sc_viewFrameDidChange()}var b=this.get("layoutView");if(b){b.set("childViewsNeedLayout",YES);b.layoutDidChangeFor(this);if(b.get("childViewsNeedLayout")){b.invokeOnce(b.layoutChildViewsIfNeeded)}}else{this.invokeOnce(this.updateLayout)}return this},layoutDidChangeFor:function(b){var a=this._needLayoutViews;if(!a){a=this._needLayoutViews=SC.CoreSet.create()}a.add(b)},layoutChildViewsIfNeeded:function(a){if(this.get("childViewsNeedLayout")){this.layoutChildViews(a);this.set("childViewsNeedLayout",NO)}return this},layoutChildViews:function(d){var c=this.childViewLayout,e,a,b;if(c){c.layoutChildViews(this)}e=this._needLayoutViews;if(e){for(b=0,a=e.length;b<a;++b){e[b].updateLayout(d)}e.clear()}},parentViewDidResize:function(k){var c=!this.get("isFixedPosition");var i=this.get("useStaticLayout"),f=k?k.height:0,a=f!==this._scv_parentHeight,b=this.get("isFixedHeight"),h=i||(a&&!b),j=k?k.width:0,e=j!==this._scv_parentWidth,g=this.get("isFixedWidth"),d=i||(e&&!g);this._scv_parentHeight=f;this._scv_parentWidth=j;if(h||d){this.viewDidResize()}else{if(c){this._sc_viewFrameDidChange()}}},propertyDidChange:function(b,d,c){var a=false;if(typeof this.layout==="function"&&this._kvo_dependents){var e=this._kvo_dependents[b];if(e&&e.indexOf("layout")!==-1){a=true}}if(b==="layout"||a){this.layoutDidChange()}return arguments.callee.base.apply(this,arguments)},scrollToVisible:function(){var a=this.get("parentView");while(a&&!a.get("isScrollable")){a=a.get("parentView")}if(a){a.scrollToVisible();return a.scrollToVisible(this)}else{return NO}},viewDidResize:function(){this._sc_viewFrameDidChange();var d=this.childViews,e=this.get("frame"),b,a,c;for(a=0;a<(b=d.length);++a){c=d[a];c.tryToPerform("parentViewDidResize",e)}},beginLiveResize:function(){if(this.willBeginLiveResize){this.willBeginLiveResize()}var d=this.get("childViews"),b=d.length,a,c;for(a=0;a<b;++a){c=d[a];if(c.beginLiveResize){c.beginLiveResize()}}return this},endLiveResize:function(){var d=this.get("childViews"),b=d.length,a,c;for(a=b-1;a>=0;--a){c=d[a];if(c.endLiveResize){c.endLiveResize()}}if(this.didEndLiveResize){this.didEndLiveResize()}return this},updateLayout:function(a){this._doUpdateLayout(a);return this},renderLayout:function(a){a.setStyle(this.get("layoutStyle"))},_doUpdateLayout:function(b){var d=this.get("_isRendered"),a=this.get("isVisibleInWindow"),c=true;if(d){if(a||b){this._doUpdateLayoutStyle()}else{this._layoutStyleNeedsUpdate=true}}else{c=false}return c},_doUpdateLayoutStyle:function(){var c=this.get("layer"),a=this.get("layoutStyle");for(var b in a){c.style[b]=a[b]}this._layoutStyleNeedsUpdate=false;this._updatedLayout()},_notifyDidAttach:function(){if(this.get("useStaticLayout")){this.viewDidResize()}if(this.didAppendToDocument){this.didAppendToDocument()}},_adopted:function(b){var a=this.get("isFixedSize");if(a){this._sc_viewFrameDidChange()}else{this.viewDidResize()}arguments.callee.base.apply(this,arguments)},_orphaned:function(){arguments.callee.base.apply(this,arguments);if(!this.isDestroyed){var a=this.get("isFixedSize");if(a){this._sc_viewFrameDidChange()}else{this.viewDidResize()}}},_updatedContent:function(){arguments.callee.base.apply(this,arguments);if(this.get("useStaticLayout")){this.viewDidResize()}},_updatedLayout:function(){this.didRenderAnimations()}});SC.View.mixin({convertLayoutToAnchoredLayout:function(f,m){var h={top:0,left:0,width:m.width,height:m.height},d=m.width,k=m.height,l=f.right,a=f.left,j=f.top,g=f.bottom,i=f.width,e=f.height,c=f.centerX,b=f.centerY;if(!SC.none(a)){if(SC.isPercentage(a)){h.left=a*d}else{h.left=a}if(i!==undefined){if(i===SC.LAYOUT_AUTO){h.width=SC.LAYOUT_AUTO}else{if(SC.isPercentage(i)){h.width=i*d}else{h.width=i}}}else{if(l&&SC.isPercentage(l)){h.width=d-h.left-(l*d)}else{h.width=d-h.left-(l||0)}}}else{if(!SC.none(l)){if(SC.none(i)){h.left=0;if(l&&SC.isPercentage(l)){h.width=d-(l*d)}else{h.width=d-(l||0)}}else{if(i===SC.LAYOUT_AUTO){h.width=SC.LAYOUT_AUTO}else{if(SC.isPercentage(i)){h.width=i*d}else{h.width=i}if(SC.isPercentage(l)){h.left=d-(h.width+l)}else{h.left=d-(h.width+l)}}}}else{if(!SC.none(c)){if(i&&SC.isPercentage(i)){h.width=(i*d)}else{h.width=(i||0)}h.left=((d-h.width)/2);if(SC.isPercentage(c)){h.left=h.left+c*d}else{h.left=h.left+c}}else{if(!SC.none(i)){h.left=0;if(i===SC.LAYOUT_AUTO){h.width=SC.LAYOUT_AUTO}else{if(SC.isPercentage(i)){h.width=i*d}else{h.width=i}}}else{h.left=0;h.width=0}}}}if(f.minWidth!==undefined){h.minWidth=f.minWidth}if(f.maxWidth!==undefined){h.maxWidth=f.maxWidth}if(!SC.none(j)){if(SC.isPercentage(j)){h.top=j*k}else{h.top=j}if(e!==undefined){if(e===SC.LAYOUT_AUTO){h.height=SC.LAYOUT_AUTO}else{if(SC.isPercentage(e)){h.height=e*k}else{h.height=e}}}else{h.height=k-h.top;if(g&&SC.isPercentage(g)){h.height=h.height-(g*k)}else{h.height=h.height-(g||0)}}}else{if(!SC.none(g)){if(SC.none(e)){h.top=0;if(g&&SC.isPercentage(g)){h.height=k-(g*k)}else{h.height=k-(g||0)}}else{if(e===SC.LAYOUT_AUTO){h.height=SC.LAYOUT_AUTO}else{if(SC.isPercentage(e)){h.height=e*k}else{h.height=e}h.top=k-h.height;if(SC.isPercentage(g)){h.top=h.top-(g*k)}else{h.top=h.top-g}}}}else{if(!SC.none(b)){if(e&&SC.isPercentage(e)){h.height=(e*k)}else{h.height=(e||0)}h.top=((k-h.height)/2);if(SC.isPercentage(b)){h.top=h.top+b*k}else{h.top=h.top+b}}else{if(!SC.none(e)){h.top=0;if(e===SC.LAYOUT_AUTO){h.height=SC.LAYOUT_AUTO}else{if(SC.isPercentage(e)){h.height=e*k}else{h.height=e}}}else{h.top=0;h.height=0}}}}if(h.top){h.top=Math.floor(h.top)}if(h.bottom){h.bottom=Math.floor(h.bottom)}if(h.left){h.left=Math.floor(h.left)}if(h.right){h.right=Math.floor(h.right)}if(h.width!==SC.LAYOUT_AUTO){h.width=Math.floor(h.width)}if(h.height!==SC.LAYOUT_AUTO){h.height=Math.floor(h.height)}if(f.minHeight!==undefined){h.minHeight=f.minHeight}if(f.maxHeight!==undefined){h.maxHeight=f.maxHeight}return h},convertLayoutToCustomLayout:function(b,a,c){}});sc_require("views/view");sc_require("views/view/layout");sc_require("views/view/layout_style");SC.View.reopen({wantsAcceleratedLayer:NO,hasAcceleratedLayer:function(){return(SC.platform.supportsCSSTransforms&&this.get("wantsAcceleratedLayer")&&this.get("isFixedLayout"))}.property("wantsAcceleratedLayer","isFixedLayout").cacheable()});sc_require("views/view");SC.View.reopen({cursor:function(a,c){var b;if(c){this._setCursor=c}if(this._setCursor!==undefined){return this._setCursor}b=this.get("parentView");if(this.get("shouldInheritCursor")&&b){return b.get("cursor")}return null}.property("parentView","shouldInheritCursor").cacheable(),shouldInheritCursor:YES});sc_require("views/view");SC.CoreView.mixin({ENABLED:8,IS_DISABLED:16,DISABLED:17,DISABLED_BY_PARENT:18,DISABLED_AND_BY_PARENT:19});SC.View.reopen({enabledState:SC.CoreView.ENABLED,isEnabled:YES,isEnabledBindingDefault:SC.Binding.oneWay().bool(),isEnabledInPane:function(){return this.get("enabledState")===SC.CoreView.ENABLED}.property("enabledState").cacheable(),shouldInheritEnabled:true,_doEnable:function(){var b=true,a=this.get("enabledState");if(a===SC.CoreView.DISABLED){this._callOnChildViews("_parentDidEnableInPane");this._gotoEnabledState()}else{if(a===SC.CoreView.DISABLED_AND_BY_PARENT){this._gotoDisabledByParentState()}else{b=false}}return b},_doDisable:function(){var b=true,a=this.get("enabledState");if(a===SC.CoreView.ENABLED){this._callOnChildViews("_parentDidDisableInPane");this._gotoDisabledState();if(this.get("isFirstResponder")){this.resignFirstResponder()}}else{if(a===SC.CoreView.DISABLED_BY_PARENT){this._gotoDisabledAndByParentState()}else{b=false}}return b},_sc_view_isEnabledDidChange:function(){this.invokeOnce(this._doUpdateEnabled)}.observes("isEnabled"),_doUpdateEnabled:function(){var a=this.get("viewState");if(this.get("isEnabled")){this._doEnable()}else{this._doDisable()}switch(a){case SC.CoreView.ATTACHED_SHOWN:case SC.CoreView.ATTACHED_SHOWING:case SC.CoreView.ATTACHED_BUILDING_IN:this._doUpdateEnabledStyle();break;default:this._enabledStyleNeedsUpdate=true}},_doUpdateEnabledStyle:function(){var a=this.get("isEnabled");this.$().toggleClass("disabled",!a);this.$().attr("aria-disabled",!a?true:null);this._enabledStyleNeedsUpdate=false},_parentDidEnableInPane:function(){var a=this.get("enabledState");if(this.get("shouldInheritEnabled")){if(a===SC.CoreView.DISABLED_BY_PARENT){this._gotoEnabledState()}else{if(a===SC.CoreView.DISABLED_AND_BY_PARENT){this._gotoDisabledState();return false}}}else{return false}},_parentDidDisableInPane:function(){var a=this.get("enabledState");if(this.get("shouldInheritEnabled")){if(a===SC.CoreView.ENABLED){this._gotoDisabledByParentState()}else{if(a===SC.CoreView.DISABLED){this._gotoDisabledAndByParentState()}else{return false}}}else{return false}},_gotoEnabledState:function(){this.set("enabledState",SC.CoreView.ENABLED)},_gotoDisabledState:function(){this.set("enabledState",SC.CoreView.DISABLED)},_gotoDisabledAndByParentState:function(){this.set("enabledState",SC.CoreView.DISABLED_AND_BY_PARENT)},_gotoDisabledByParentState:function(){this.set("enabledState",SC.CoreView.DISABLED_BY_PARENT)}});sc_require("views/view");SC.View.reopen({isKeyResponder:NO,willLoseKeyResponderTo:function(a){},willBecomeKeyResponderFrom:function(a){},didLoseKeyResponderTo:function(a){},didBecomeKeyResponderFrom:function(a){},interpretKeyEvents:function(b){var a=b.commandCodes(),d=a[0],e=a[1],h,f,i,g,c,j;if(!d&&!e){return null}if(d){f=d.match(/[^_]+$/);i=SC.MODIFIED_KEY_BINDINGS[d];if(!i&&f&&f.length>0){i=SC.BASE_KEY_BINDINGS[f[0]]}if(i){g=this;c=this.get("pane");j=null;while(g&&!(j=g.tryToPerform(i,b))){g=(g===c)?null:g.get("nextResponder")}return j}}if(e&&this.respondsTo("insertText")){h=this.insertText(e,b);return h?(h===YES?this:h):null}return null},insertText:function(a){return NO},performKeyEquivalent:function(f,d){var e=NO,g=this.get("childViews"),b=g.length,a=-1,c;while(!e&&(++a<b)){c=g[a];e=c.tryToPerform("performKeyEquivalent",f,d)}return e},firstKeyView:null,_getFirstKeyView:function(){var a=this.get("firstKeyView");if(a){return a}var b=this.get("childViews");if(b){return b[0]}},lastKeyView:null,_getLastKeyView:function(){var d=this.get("lastKeyView");if(d){return d}var a,b=this.get("firstKeyView");if(b){while(a=b._getNextKeyView()){b=a}return b}else{var c=this.get("childViews");if(c){return c[c.length-1]}}},nextKeyView:undefined,_getNextKeyView:function(){var b=this.get("parentView"),a=this.get("nextKeyView");if(b&&b.get("lastKeyView")===this){return null}if(a!==undefined){return a}if(b){var c=b.get("childViews");return c[c.indexOf(this)+1]}},nextValidKeyView:function(){var b=this,a;while(a!==this){a=null;if(b.get("isVisibleInWindow")){a=b._getFirstKeyView()}if(!a){a=b._getNextKeyView()}if(!a){while(b=b.get("parentView")){if(a=b._getNextKeyView()){break}}}if(!a){if(!SC.TABBING_ONLY_INSIDE_DOCUMENT){break}else{a=this.get("pane")}}if(a.get("isVisibleInWindow")&&a.get("acceptsFirstResponder")){return a}b=a}return null}.property("nextKeyView"),previousKeyView:undefined,_getPreviousKeyView:function(){var b=this.get("parentView"),a=this.get("previousKeyView");if(b&&b.get("firstKeyView")===this){return null}if(a!==undefined){return a}if(b){var c=b.get("childViews");return c[c.indexOf(this)-1]}},previousValidKeyView:function(){var b=this,a;while(a!==this){if(b.get("parentView")){a=b._getPreviousKeyView()}else{if(!SC.TABBING_ONLY_INSIDE_DOCUMENT){break}else{a=b}}if(a){do{b=a;a=a._getLastKeyView()}while(a&&a.get("isVisibleInWindow"));if(!a){a=b}}else{a=b.get("parentView")}if(a.get("isVisibleInWindow")&&a.get("acceptsFirstResponder")){return a}b=a}return null}.property("previousKeyView")});sc_require("views/view");SC.View.reopen({layerIdDidChange:function(){var a=this.get("layer"),b=this.get("layerId"),c=this._lastLayerId;if(b!==c){if(c&&SC.View.views[c]===this){delete SC.View.views[c]}this._lastLayerId=b;SC.View.views[b]=this;if(a){a.id=b}}}.observes("layerId"),insertBefore:function(a,b){a.beginPropertyChanges();if(a.resetBuildState){a.resetBuildState()}a._doAdopt(this,b);a.endPropertyChanges();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(c){this.beginPropertyChanges();this.removeAllChildren(true);for(var b=0,a=c.get("length");b<a;b++){this.appendChild(c.objectAt(b))}this.endPropertyChanges();return this},appendChild:function(a){return this.insertBefore(a,null)},buildInChild:function(a){a.willBuildInToView(this);this.appendChild(a);a.buildInToView(this)},buildOutChild:function(a){a.buildOutFromView(this)},buildInDidFinishFor:function(a){},buildOutDidFinishFor:function(a){this.removeChild(a)},isBuildingIn:NO,isBuildingOut:NO,buildIn:function(){this.buildInDidFinish()},buildOut:function(){this.buildOutDidFinish()},resetBuild:function(){},buildOutDidCancel:function(){},buildInDidCancel:function(){},buildInDidFinish:function(){this.isBuildingIn=NO;this._buildingInTo.buildInDidFinishFor(this);this._buildingInTo=null},buildOutDidFinish:function(){this.isBuildingOut=NO;this._buildingOutFrom.buildOutDidFinishFor(this);this._buildingOutFrom=null},resetBuildState:function(){if(this.isBuildingIn){this.buildInDidCancel();this.isBuildingIn=NO}if(this.isBuildingOut){this.buildOutDidCancel();this.isBuildingOut=NO}this.buildingInTo=null;this.buildingOutFrom=null;this.resetBuild()},willBuildInToView:function(a){if(this.isBuildingOut){this.buildOutDidCancel()}},buildInToView:function(a){if(this.isBuildingIn){return}this._buildingInTo=a;this.isBuildingOut=NO;this.isBuildingIn=YES;this.buildIn()},buildOutFromView:function(a){if(this.isBuildingOut){return}if(this.isBuildingIn){this.buildInDidCancel()}this.isBuildingOut=YES;this.isBuildingIn=NO;this._buildingOutFrom=a;this.buildOut()}});sc_require("views/view");SC.View.reopen({themeName:null,baseThemeName:null,theme:function(){var b=this.get("baseTheme"),a=this.get("themeName");if(a){var c;if(b){c=b.find(a);if(c){return c}}c=SC.Theme.find(a);if(c){return c}return b.invisibleSubtheme(a)}return b}.property("baseTheme","themeName").cacheable(),_sc_view_themeDidChange:function(){var d=this.get("theme");if(this._lastTheme===d){return}this._lastTheme=d;var c=this.childViews,b=c.length,a;for(a=0;a<b;a++){c[a].notifyPropertyChange("baseTheme")}if(this.get("layer")){this.replaceLayer()}}.observes("theme"),baseTheme:function(){var b;var a=this.get("baseThemeName");if(a){return SC.Theme.find(a)}else{b=this.get("parentView");var c=b&&b.get("theme");return c||SC.Theme.find(SC.defaultTheme)}}.property("baseThemeName","parentView").cacheable(),renderDelegate:function(c,d){if(d){this._setRenderDelegate=d}if(this._setRenderDelegate){return this._setRenderDelegate}var a=this.get("renderDelegateName"),b;if(a){b=this.get("theme")[a];if(!b){throw new Error('%@: Unable to locate render delegate "%@" in theme.'.fmt(this,a))}return b}return null}.property("renderDelegateName","theme"),renderDelegateName:null,renderDelegateProxy:function(){return SC.View._RenderDelegateProxy.createForView(this)}.property("renderDelegate").cacheable(),render:function(b,c){var a=this.get("renderDelegate");if(a){if(c){a.render(this.get("renderDelegateProxy"),b)}else{a.update(this.get("renderDelegateProxy"),b.$())}}},invokeRenderDelegateMethod:function(c,b){var a=this.get("renderDelegate");if(!a){return undefined}if(SC.typeOf(a[c])!==SC.T_FUNCTION){return undefined}b=SC.$A(arguments);b.shift();b.unshift(this.get("renderDelegateProxy"));return a[c].apply(a,b)}});SC.View._RenderDelegateProxy={createForView:function(c){var d=SC.beget(this);var f=c.get("displayProperties"),e={};for(var b=0,a=f.length;b<a;b++){e[f[b]]=YES}e.theme=YES;d._displayPropertiesLookup=e;d.renderState={};d._view=c;return d},get:function(b){if(this[b]!==undefined){return this[b]}var a="display"+b.capitalize();if(this._displayPropertiesLookup[a]){return this._view.get(a)}else{return this._view.get(b)}},didChangeFor:function(d){var b=arguments.length,a;for(a=1;a<b;a++){var e=arguments[a],c="display"+e.capitalize();if(this._displayPropertiesLookup[c]){if(this._view.didChangeFor(d,c)){return YES}}else{if(this._view.didChangeFor(d,e)){return YES}}}return NO}};SC.propertyFromRenderDelegate=function(a,b){return function(f,g){if(g!==undefined){this["_set_rd_"+f]=g}var d=this["_set_rd_"+f];if(d!==undefined){return d}var c=this.get("renderDelegate");if(c&&c.get){var e=this.get("renderDelegateProxy");d=c.getPropertyFor(e,a)}if(d!==undefined){return d}return b}.property("renderDelegate").cacheable()};sc_require("views/view");SC.View.reopen({acceptsMultitouch:NO,hasTouch:NO,touchBoundary:{left:25,right:25,top:25,bottom:25},_touchBoundaryFrame:function(){var b=this.get("touchBoundary"),a;a=this.get("parentView").convertFrameToView(this.get("frame"),null);a.x-=b.left;a.y-=b.top;a.width+=b.left+b.right;a.height+=b.top+b.bottom;return a}.property("touchBoundary","clippingFrame").cacheable(),touchIsInBoundary:function(a){return SC.pointInRect({x:a.pageX,y:a.pageY},this.get("_touchBoundaryFrame"))}});sc_require("views/view");SC.View.reopen({hasVisibility:YES,isContextMenuEnabled:function(){return SC.CONTEXT_MENU_ENABLED}.property(),recomputeIsVisibleInWindow:function(){return this}});sc_require("views/view");sc_require("views/view/acceleration");sc_require("views/view/cursor");sc_require("views/view/enabled");sc_require("views/view/keyboard");sc_require("views/view/layout");sc_require("views/view/manipulation");sc_require("views/view/theming");sc_require("views/view/touch");sc_require("views/view/visibility");sc_require("mixins/responder_context");SC.MIXED_STATE="__MIXED__";SC.Pane=SC.View.extend(SC.ResponderContext,{isPane:YES,page:null,rootResponder:null,sendEvent:function(c,a,d,b){if(!d){d=this.get("firstResponder")}while(d){if(c==="touchStart"){if(a.touchResponder===d){d=null;break}if(!d.get("hasTouch")||d.get("acceptsMultitouch")){if(d.tryToPerform("touchStart",a)){break}}}else{if(c==="touchEnd"&&!d.get("acceptsMultitouch")){if(!d.get("hasTouch")){if(d.tryToPerform("touchEnd",a)){break}}}else{if(d.tryToPerform(c,a)){break}}}d=(d===this)?null:d.get("nextResponder");if(d===b){return(a&&a.mouseHandler)||null}}if(!d&&(d=this.get("defaultResponder"))){if(typeof d===SC.T_STRING){d=SC.objectForPropertyPath(d)}if(!d){d=null}else{d=d.tryToPerform(c,a)?d:null}}else{if(!d&&!(d=this.get("defaultResponder"))){d=this.tryToPerform(c,a)?this:null}}return(a&&a.mouseHandler)||d},nextResponder:function(){return null}.property().cacheable(),firstResponder:null,acceptsKeyPane:YES,isKeyPane:NO,becomeKeyPane:function(){if(this.get("isKeyPane")){return this}if(this.rootResponder){this.rootResponder.makeKeyPane(this)}return this},resignKeyPane:function(){if(!this.get("isKeyPane")){return this}if(this.rootResponder){this.rootResponder.makeKeyPane(null)}return this},makeFirstResponder:function(c,b,a){if(!b){b=this}var e=this.get("firstResponder"),d=this.get("isKeyPane");if(e===b){return this}if(d){if(e){e.tryToPerform("willLoseKeyResponderTo",b)}if(b){b.tryToPerform("willBecomeKeyResponderFrom",e)}}if(e){e.beginPropertyChanges();e.set("isKeyResponder",NO)}if(b){b.beginPropertyChanges();b.set("isKeyResponder",d)}c(b,a);if(e){e.endPropertyChanges()}if(b){b.endPropertyChanges()}if(d){if(b){b.tryToPerform("didBecomeKeyResponderFrom",e)}if(e){e.tryToPerform("didLoseKeyResponderTo",b)}}return this}.enhance(),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},didBecomeKeyResponderFrom:function(a){},didLoseKeyPaneTo:function(b){var a=this.get("isKeyPane");this.set("isKeyPane",NO);this._forwardKeyChange(a,"didLoseKeyResponderTo",b);return this},didBecomeKeyPaneFrom:function(b){var a=this.get("isKeyPane");this.set("isKeyPane",YES);this._forwardKeyChange(!a,"didBecomeKeyResponderFrom",b,YES);return this},isMainPane:NO,focusFrom:function(a){},blurTo:function(a){},blurMainTo:function(a){this.set("isMainPane",NO)},focusMainFrom:function(a){this.set("isMainPane",YES)},append:function(){return this.appendTo(document.body)},remove:function(){if(this.get("isAttached")){this._doDetach()}return this},insert:function(b){this.createLayer();var a=this.get("layer");b(a);return this},appendTo:function(b){var a=this;return this.insert(function(){a._doAttach(jQuery(b)[0])})},paneDidAttach:function(){},recomputeDependentProperties:function(){},isPaneAttached:function(){return this.get("isAttached")}.property("isAttached").cacheable(),wantsTouchIntercept:NO,hasTouchIntercept:function(){return this.get("wantsTouchIntercept")&&SC.platform.touch}.property("wantsTouchIntercept").cacheable(),zIndex:0,touchZ:99,_addIntercept:function(){if(this.get("hasTouchIntercept")){var b=document.createElement("div");var a=b.style;a.position="absolute";a.left="0px";a.top="0px";a.right="0px";a.bottom="0px";a[SC.browser.experimentalStyleNameFor("transform")]="translateZ(0px)";a.zIndex=this.get("zIndex")+this.get("touchZ");b.className="touch-intercept";b.id="touch-intercept-"+SC.guidFor(this);this._touchIntercept=b;document.body.appendChild(b)}},_removeIntercept:function(){if(this._touchIntercept){document.body.removeChild(this._touchIntercept);this._touchIntercept=null}},hideTouchIntercept:function(){if(this._touchIntercept){this._touchIntercept.style.display="none"}},showTouchIntercept:function(){if(this._touchIntercept){this._touchIntercept.style.display="block"}},init:function(){var a=!!this.get("layer");arguments.callee.base.apply(this,arguments);if(a){this._attached()}},classNames:["sc-pane"]});sc_require("panes/pane");SC.Pane.reopen({performKeyEquivalent:function(c,a){var b=arguments.callee.base.apply(this,arguments);if(!b){var d=this.get("defaultResponder");if(d){if(d.performKeyEquivalent){b=d.performKeyEquivalent(c,a)}if(!b&&d.tryToPerform){b=d.tryToPerform(c,a)}}}return b},keyDown:function(a){var b;if(a.keyCode===9&&!this.get("firstResponder")){if(a.shiftKey){b=this.get("previousValidKeyView")}else{b=this.get("nextValidKeyView")}if(b){this.makeFirstResponder(b);return YES}else{if(!SC.TABBING_ONLY_INSIDE_DOCUMENT){a.allowDefault()}}}return NO},_forwardKeyChange:function(d,b,g,f){var c,a,e;if(d&&(a=this.get("firstResponder"))){e=(g)?g.get("firstResponder"):null;c=this.get("firstResponder");if(c&&c[b]){c[b](e)}if((f!==undefined)&&a){a.set("isKeyResponder",f)}}}});sc_require("panes/pane");SC.Pane.reopen({currentWindowSize:null,computeParentDimensions:function(c){if(this.get("designer")&&SC.suppressMain){return arguments.callee.base.apply(this,arguments)}var d={x:0,y:0,width:1000,height:1000},b=this.get("layout");if(document&&document.body){d.width=document.body.clientWidth;d.height=document.body.clientHeight;if(SC.browser.name===SC.BROWSER.ie&&SC.browser.compare(SC.browser.version,"7")===0){var a=SC.platform.get("scrollbarSize");if(document.body.scrollWidth>d.width){d.width-=a}if(document.body.scrollHeight>d.height){d.height-=a}}}if(b.minHeight||b.minWidth){if(b.minHeight){d.height=Math.max(d.height,b.minHeight)}if(b.minWidth){d.width=Math.max(d.width,b.minWidth)}}return d},windowSizeDidChange:function(b,a){this.set("currentWindowSize",a);this.setBodyOverflowIfNeeded();this.parentViewDidResize(a);return this},setBodyOverflowIfNeeded:function(e){var d=this.get("layout"),b=this.get("currentWindowSize");if(!d||!b||!b.width||!b.height){return}var a=d.minWidth,c=d.minHeight;if(e===true||a||c){if((c&&b.height<c)||(a&&b.width<a)){SC.bodyOverflowArbitrator.requestVisible(this)}else{SC.bodyOverflowArbitrator.requestHidden(this)}}},unsetBodyOverflowIfNeeded:function(){SC.bodyOverflowArbitrator.withdrawRequest(this)}});sc_require("panes/pane");SC.Pane.reopen({prependTo:function(b){var a=this;return this.insert(function(){var c=jQuery(b)[0];a._doAttach(c,c.firstChild)})},removeFromParent:function(){SC.throw("SC.Pane cannot be removed from its parent, since it's the root. Did you mean remove()?")}});sc_require("panes/pane");SC.Pane.reopen({_executeDoAttach:function(){var a=(this.rootResponder=SC.RootResponder.responder);a.panes.add(this);this.set("currentWindowSize",a.currentWindowSize);this.updateDesignMode(this.get("designMode"),a.get("currentDesignMode"));arguments.callee.base.apply(this,arguments);this.paneDidAttach();this.recomputeDependentProperties();this._addIntercept();if(!this.get("isFixedSize")){this.viewDidResize()}},_executeDoDetach:function(){arguments.callee.base.apply(this,arguments);this._removeIntercept();var a=this.rootResponder;a.panes.remove(this);this.rootResponder=null}});SC.BENCHMARK_LOG_READY=YES;sc_require("system/event");SC.mixin({isReady:NO,suppressOnReady:SC.suppressOnReady?YES:NO,suppressMain:SC.suppressMain?YES:NO,ready:function(b,c){var a=SC._readyQueue;if(c===undefined){c=b;b=null}else{if(SC.typeOf(c)===SC.T_STRING){c=b[c]}}if(SC.isReady){jQuery(document).ready(function(){c.call(b)})}else{if(!a){SC._readyQueue=[]}SC._readyQueue.push(function(){c.call(b)})}return this},onReady:{done:function(){if(SC.isReady){return}SC.isReady=true;SC.RunLoop.begin();SC.Locale.createCurrentLocale();var d=SC.Locale.currentLanguage.toLowerCase();jQuery("body").addClass(d);jQuery("html").attr("lang",d);jQuery("#loading").remove();var c=SC._readyQueue,b,a;if(c){for(b=0,a=c.length;b<a;b++){c[b].call()}SC._readyQueue=null}if(window.main&&!SC.suppressMain&&(SC.mode===SC.APP_MODE)){window.main()}SC.RunLoop.end()}}});if(!SC.suppressOnReady){$(document).ready(SC.onReady.done)}SC.APP_MODE="APP_MODE";SC.TEST_MODE="TEST_MODE";SC.mode=SC.APP_MODE;SC.UNSUPPORTED="_sc_unsupported";SC.platform=SC.Object.create({scrollbarSize:function(){var a=document.createElement("DIV"),d;a.innerHTML="<div style='height:1px;'></div>";a.style.cssText="position:absolute;width:100px;height:100px;overflow-y:visible;";d=a.childNodes[0];document.body.appendChild(a);var b=d.innerWidth||d.clientWidth;a.style.overflowY="scroll";var c=d.innerWidth||d.clientWidth;document.body.removeChild(a);return b-c}.property().cacheable(),touch:(!SC.none(window.ontouchstart)||SC.browser.name===SC.BROWSER.android||"ontouchstart" in document.documentElement)&&SC.none(window._phantom),bounceOnScroll:SC.browser.os===SC.OS.ios,pinchToZoom:SC.browser.os===SC.OS.ios,a:function(){var a=document.createElement("a");return{download:!!("download" in a),media:!!("media" in a),ping:!!("ping" in a)}}(),input:function(d){var e={},c=d.length,f=document.createElement("input"),b,a;for(a=0;a<c;a++){b=d[a];e[b]=!!(b in f)}return e}(["autocomplete","readonly","list","size","required","multiple","maxlength","pattern","min","max","step","placeholder","selectionStart","selectionEnd","selectionDirection"]),standalone:!!navigator.standalone,cssPrefix:SC.browser.cssPrefix,domCSSPrefix:SC.browser.domPrefix,simulateTouchEvents:function(){if(this.touch){return}SC.Logger.log("Simulating touch events");SC.platform.touch=YES;SC.platform.bounceOnScroll=YES;document.body.className=document.body.className+" touch";this._simtouch_counter=1;this.removeEvents(["click","dblclick","mouseout","mouseover","mousewheel"]);this.replaceEvent("mousemove",this._simtouch_mousemove);this.replaceEvent("mousedown",this._simtouch_mousedown);this.replaceEvent("mouseup",this._simtouch_mouseup);SC.platform.windowSizeDeterminesOrientation=YES;SC.device.orientationHandlingShouldChange()},removeEvents:function(d){var b,a=d.length,c;for(b=0;b<a;b++){c=d[b];SC.Event.remove(document,c,SC.RootResponder.responder,SC.RootResponder.responder[c])}},replaceEvent:function(a,b){SC.Event.remove(document,a,SC.RootResponder.responder,SC.RootResponder.responder[a]);SC.Event.add(document,a,this,b)},_simtouch_mousemove:function(a){if(!this._mousedown){if(a.altKey&&this._pinchCenter===null){this._pinchCenter={pageX:a.pageX,pageY:a.pageY,screenX:a.screenX,screenY:a.screenY,clientX:a.clientX,clientY:a.clientY}}else{if(!a.altKey&&this._pinchCenter!==null){this._pinchCenter=null}}return NO}var b=this.manufactureTouchEvent(a,"touchmove");return SC.RootResponder.responder.touchmove(b)},_simtouch_mousedown:function(a){this._mousedown=YES;var b=this.manufactureTouchEvent(a,"touchstart");return SC.RootResponder.responder.touchstart(b)},_simtouch_mouseup:function(a){var c=this.manufactureTouchEvent(a,"touchend"),b=SC.RootResponder.responder.touchend(c);this._mousedown=NO;this._simtouch_counter++;return b},manufactureTouchEvent:function(k,j){var c,l,f=this._simtouch_counter;c={type:j,target:k.target,identifier:f,pageX:k.pageX,pageY:k.pageY,screenX:k.screenX,screenY:k.screenY,clientX:k.clientX,clientY:k.clientY};k.touches=[c];if(k.altKey&&this._pinchCenter!==null){var h=this._pinchCenter.pageX+this._pinchCenter.pageX-k.pageX,g=this._pinchCenter.pageY+this._pinchCenter.pageY-k.pageY,e=this._pinchCenter.screenX+this._pinchCenter.screenX-k.screenX,d=this._pinchCenter.screenY+this._pinchCenter.screenY-k.screenY,b=this._pinchCenter.clientX+this._pinchCenter.clientX-k.clientX,a=this._pinchCenter.clientY+this._pinchCenter.clientY-k.clientY,i=this._simtouch_counter+1;l={type:j,target:k.target,identifier:i,pageX:h,pageY:g,screenX:e,screenY:d,clientX:b,clientY:a};k.touches=[c,l]}k.changedTouches=k.touches;return k},supportsCSSAnimations:SC.browser.experimentalStyleNameFor("animation")!==SC.UNSUPPORTED,supportsCSSTransitions:SC.browser.experimentalStyleNameFor("transition")!==SC.UNSUPPORTED,supportsCSSTransforms:SC.browser.experimentalStyleNameFor("transform")!==SC.UNSUPPORTED,supportsCSS3DTransforms:SC.browser.experimentalStyleNameFor("perspective")!==SC.UNSUPPORTED,supportsApplicationCache:("applicationCache" in window),supportsHashChange:function(){return("onhashchange" in window)&&(document.documentMode===undefined||document.documentMode>7)}(),supportsHistory:function(){return !!(window.history&&window.history.pushState)}(),supportsIndexedDB:function(){return !!(window.indexedDB||window[SC.browser.domPrefix+"IndexedDB"])}(),supportsCanvas:function(){return !!document.createElement("canvas").getContext}(),supportsXHR2ProgressEvent:("ProgressEvent" in window),supportsXHR2FormData:("FormData" in window),supportsXHR2LoadEndEvent:function(){return(new XMLHttpRequest).onloadend===null}(),supportsOrientationChange:("onorientationchange" in window),supportsWebSQL:("openDatabase" in window),windowSizeDeterminesOrientation:SC.browser.os===SC.OS.ios||!("onorientationchange" in window),cordova:(typeof window.cordova!=="undefined")});SC.ready(function(){var a=function(j,h,m,i){var l=SC.browser.domPrefix,g=l.toLowerCase(),k=h+"EventName",n=function(o){var r=SC.browser.domPrefix,p=r.toLowerCase(),q=h+"EventName";j.removeEventListener(h,n,NO);j.removeEventListener(p+h,n,NO);j.removeEventListener(p+m,n,NO);j.removeEventListener(r+m,n,NO);if(o){SC.platform[q]=o.type;o.stopPropagation()}if(i){i(!!o)}};SC.platform[k]=SC.UNSUPPORTED;j.addEventListener(h,n,NO);j.addEventListener(g+h,n,NO);j.addEventListener(g+m,n,NO);j.addEventListener(l+m,n,NO)};if(SC.platform.supportsCSSTransitions){var e=document.createElement("div"),d=SC.browser.experimentalStyleNameFor("transition","all 1ms linear");e.style[d]="all 1ms linear";a(e,"transitionend","TransitionEnd",function(g){if(g){SC.RootResponder.responder.cleanUpTransitionListeners()}else{SC.platform.supportsCSSTransitions=NO}e.parentNode.removeChild(e);e=null});document.documentElement.appendChild(e);setTimeout(function(){e.style.opacity="0"});if(SC.platform.supportsCSSAnimations){var c=document.createElement("div"),f,b;f="@keyframes _sc_animation_test { from { opacity: 1; } to { opacity: 0; } }";b="@"+SC.browser.cssPrefix+"keyframes _sc_prefixed_animation_test { from { opacity: 1; } to { opacity: 0; } }";c.innerHTML="<style>"+f+"\n"+b+"</style>";c.style.animation="_sc_animation_test 1ms linear";c.style[SC.browser.domPrefix+"Animation"]="_sc_prefixed_animation_test 5ms linear";a(c,"animationend","AnimationEnd",function(j){if(j){var i=SC.browser.domPrefix,g=i.toLowerCase(),h=SC.platform.animationendEventName;switch(h){case g+"animationend":SC.platform.animationstartEventName=g+"animationstart";SC.platform.animationiterationEventName=g+"animationiteration";break;case g+"AnimationEnd":SC.platform.animationstartEventName=g+"AnimationStart";SC.platform.animationiterationEventName=g+"AnimationIteration";break;case i+"AnimationEnd":SC.platform.animationstartEventName=i+"AnimationStart";SC.platform.animationiterationEventName=i+"AnimationIteration";break;default:SC.platform.animationstartEventName="animationstart";SC.platform.animationiterationEventName="animationiteration"}SC.RootResponder.responder.cleanUpAnimationListeners()}else{SC.platform.supportsCSSAnimations=NO}c.parentNode.removeChild(c);c=null});document.documentElement.appendChild(c)}}});SC.Touch=function(d,a){this.touchContext=a;this.identifier=d.identifier;var c=d.target,b;if(c&&SC.$(c).hasClass("touch-intercept")){d.target.style[SC.browser.experimentalStyleNameFor("transform")]="translate3d(0px,-5000px,0px)";c=document.elementFromPoint(d.pageX,d.pageY);if(c){b=SC.viewFor(c)}this.hidesTouchIntercept=NO;if(c.tagName==="INPUT"){this.hidesTouchIntercept=d.target}else{d.target.style[SC.browser.experimentalStyleNameFor("transform")]="translate3d(0px,0px,0px)"}}else{b=d.target?SC.viewFor(d.target):null}this.targetView=b;this.target=c;this.type=d.type;this.touchResponders=[];this.startX=this.pageX=d.pageX;this.startY=this.pageY=d.pageY;this.clientX=d.clientX;this.clientY=d.clientY;this.screenX=d.screenX;this.screenY=d.screenY};SC.Touch.prototype={touchContext:null,identifier:null,target:null,targetView:null,view:null,touchResponder:null,hasEnded:NO,type:null,clickCount:1,timeStamp:null,clientX:null,clientY:null,screenX:null,screenY:null,pageX:null,pageY:null,startX:null,startY:null,velocityX:0,velocityY:0,unhideTouchIntercept:function(){var a=this.hidesTouchIntercept;if(a){setTimeout(function(){a.style[SC.browser.experimentalStyleNameFor("transform")]="translate3d(0px,0px,0px)"},500)}},allowDefault:function(){if(this.event){this.event.hasCustomEventHandling=YES}},preventDefault:function(){if(this.event){this.event.preventDefault()}},stopPropagation:function(){if(this.event){this.event.stopPropagation()}},stop:function(){if(this.event){this.event.stop()}},end:function(){this.touchContext.endTouch(this)},nextTouchResponder:null,touchResponders:null,candidateTouchResponders:null,stackNextTouchResponder:function(a,b){this.makeTouchResponder(a,YES,b)},restoreLastTouchResponder:function(){if(this.nextTouchResponder){this.makeTouchResponder(this.nextTouchResponder)}else{var b=this.candidateTouchResponders,a=b?b.pop():null;if(a){this.makeTouchResponder(a)}}},makeTouchResponder:function(b,c,a){return this.touchContext.makeTouchResponder(this,b,c,a)},stackCandidateTouchResponder:function(a){if(!this.candidateTouchResponders){this.candidateTouchResponders=[a]}else{if(a!==this.candidateTouchResponders[this.candidateTouchResponders.length-1]){this.candidateTouchResponders.push(a)}}},captureTouch:function(a,b){return this.touchContext.captureTouch(this,a,b)},touchesForView:function(a){return this.touchContext.touchesForView(a)},touchesForResponder:function(a){return this.touchContext.touchesForView(a)},averagedTouchesForView:function(a,b){return this.touchContext.averagedTouchesForView(a,(b?this:null))}};SC.mixin(SC.Touch,{create:function(b,a){return new SC.Touch(b,a)},averagedTouch:function(d,b){var e=d.length,a=0,l=0,g=0,f=0,h,c;if(b===undefined){b={}}for(h=0;h<e;h++){c=d[h];a+=c.pageX;l+=c.pageY;g+=c.velocityX;f+=c.velocityY}a/=e;l/=e;g/=e;f/=e;var i=0;for(h=0;h<e;h++){c=d[h];var k=Math.abs(c.pageX-a);var j=Math.abs(c.pageY-l);i+=Math.pow(k*k+j*j,0.5)}i/=e;b.x=a;b.y=l;b.velocityX=g;b.velocityY=f;b.d=i;return b}});sc_require("system/ready");sc_require("system/platform");sc_require("system/touch");SC.CAPTURE_BACKSPACE_KEY=NO;SC.RootResponder=SC.Object.extend({panes:null,init:function(){arguments.callee.base.apply(this,arguments);this.panes=SC.Set.create()},mainPane:null,makeMainPane:function(b){var a=this.get("mainPane");if(a===b){return this}this.beginPropertyChanges();if(this.get("keyPane")===a){this.makeKeyPane(b)}this.set("mainPane",b);if(a){a.blurMainTo(b)}if(b){b.focusMainFrom(a)}this.endPropertyChanges();return this},menuPane:null,makeMenuPane:function(b){if(b&&!b.get("acceptsMenuPane")){return this}else{var a=this.get("menuPane");if(a===b){return this}this.set("menuPane",b)}return this},keyPane:null,previousKeyPanes:[],makeKeyPane:function(f){var e,a,d;if(f){if(!f.get("acceptsKeyPane")){return this}else{a=this.get("keyPane");if(a===f){return this}else{if(a){d=this.get("previousKeyPanes");d.push(a)}e=f}}}else{a=this.get("keyPane");d=this.get("previousKeyPanes");e=null;var c;while(d.length>0){c=d.pop();if(c.get("isVisibleInWindow")&&c.get("acceptsKeyPane")){e=c;break}}}if(!e){var b=this.get("mainPane");if(b&&b.get("acceptsKeyPane")){e=b}}if(a){a.willLoseKeyPaneTo(e)}if(e){e.willBecomeKeyPaneFrom(a)}this.set("keyPane",e);if(e){e.didBecomeKeyPaneFrom(a)}if(a){a.didLoseKeyPaneTo(e)}return this},currentWindowSize:null,computeWindowSize:function(){var c,b,a;if(!this._bod||!this._docElement){b=document.body;a=document.documentElement;this._bod=b;this._docElement=a}else{b=this._bod;a=this._docElement}if(window.innerHeight){c={width:window.innerWidth,height:window.innerHeight}}else{if(a&&a.clientHeight){c={width:a.clientWidth,height:a.clientHeight}}else{if(b){c={width:b.clientWidth,height:b.clientHeight}}}}return c},resize:function(){this._resize();this._assignDesignMode();return YES},_resize:function(){var a=this.computeWindowSize(),b=this.get("currentWindowSize");this.set("currentWindowSize",a);if(!SC.rectsEqual(a,b)){SC.run(function(){SC.device.windowSizeDidChange(a);if(this.panes){if(b!==a){this.panes.invoke("windowSizeDidChange",b,a)}}},this)}},_assignDesignMode:function(){var a=this.computeDesignMode(),b=this.get("currentDesignMode");if(b!==a){this.set("currentDesignMode",a);if(this.panes){SC.run(function(){this.panes.invoke("updateDesignMode",b,a)},this)}}},hasFocus:NO,focus:function(a){if(!this.get("hasFocus")){SC.$("body").addClass("sc-focus").removeClass("sc-blur");SC.run(function(){if(!SC.TABBING_ONLY_INSIDE_DOCUMENT&&!SC.browser.isIE8OrLower){var b=SC.RootResponder.responder.get("keyPane");if(b){var c=b.get("nextValidKeyView");if(c){b.makeFirstResponder(c)}}}this.set("hasFocus",YES)},this)}return YES},focusin:function(a){if(this._focusTimeout){clearTimeout(this._focusTimeout)}this.focus(a)},focusout:function(a){var b=this;this._focusTimeout=setTimeout(function(){b.blur(a)},300)},blur:function(a){if(this.get("hasFocus")){SC.$("body").addClass("sc-blur").removeClass("sc-focus");SC.run(function(){this.set("hasFocus",NO)},this)}return YES},dragDidStart:function(a){this._mouseDownView=a;this._drag=a},currentDesignMode:null,designModes:function(a,b){if(SC.none(b)){if(this._designModeNames){delete this._designModeNames;delete this._designModeThresholds}b=null}else{this._prepOrderedArrays(b)}this._assignDesignMode();return b}.property().cacheable(),computeDesignMode:function(){var e=null,c=this._designModeNames,h=this._designModeThresholds,g,f;if(!c){return null}g=this.get("currentWindowSize");f=(g.width*g.height);var d,a;for(d=0,a=h.get("length");d<a;d++){var b=h.objectAt(d);if(f<b){e=c.objectAt(d);break}}if(SC.none(e)&&c&&c.get("length")>0){e=c.objectAt(d)}return SC.device.orientation===SC.PORTRAIT_ORIENTATION?e+"_p":e+"_l"},fallbackDesignMode:function(d){var c=this._designModeNames,b,a=null;b=c.indexOf(d);if(b>=0){a=c[b-1]}return a},_prepOrderedArrays:function(e){var a,f;if(e){a=this._designModeNames=[];f=this._designModeThresholds=[];var c;outer:for(c in e){var b,d;d=e[c];inner:for(b=f.length-1;b>=0;b--){if(f[b]<d){break inner}}b+=1;a.splice(b,0,c);f.splice(b,0,d)}}},defaultResponder:null,sendAction:function(d,e,c,f,b,a){e=this.targetForAction(d,e,c,f,a);if(e){if(e.isResponderContext){return !!e.sendAction(d,c,b,a)}else{return e.tryToPerform(d,c,b)}}},_responderFor:function(d,b,a){var c=d?d.get("defaultResponder"):null;if(d){d=a||d.get("firstResponder")||d;do{if(d.respondsTo(b)){return d}}while((d=d.get("nextResponder")))}if(typeof c===SC.T_STRING){c=SC.objectForPropertyPath(c)}if(!c){return null}else{if(c.isResponderContext){return c}else{if(c.respondsTo(b)){return c}else{return null}}}},targetForAction:function(c,f,e,g,a){if(!c||(SC.typeOf(c)!==SC.T_STRING)){return null}if(f){if(SC.typeOf(f)===SC.T_STRING){f=SC.objectForPropertyPath(f)||SC.objectForPropertyPath(f,e)}if(f&&!f.isResponderContext){if(f.respondsTo&&!f.respondsTo(c)){f=null}else{if(SC.typeOf(f[c])!==SC.T_FUNCTION){f=null}}}return f}if(g){f=this._responderFor(g,c,a);if(f){return f}}var b=this.get("keyPane"),d=this.get("mainPane");if(b&&(b!==g)){f=this._responderFor(b,c)}if(!f&&d&&(d!==b)){f=this._responderFor(d,c)}if(!f&&(f=this.get("defaultResponder"))){if(SC.typeOf(f)===SC.T_STRING){f=SC.objectForPropertyPath(f);if(f){this.set("defaultResponder",f)}}if(f&&!f.isResponderContext){if(f.respondsTo&&!f.respondsTo(c)){f=null}else{if(SC.typeOf(f[c])!==SC.T_FUNCTION){f=null}}}}return f},targetViewForEvent:function(a){var b=null;if(a.target){b=SC.viewFor(a.target)}return b},sendEvent:function(d,a,e){var f,c;SC.run(function b(){if(e){f=e.get("pane")}else{f=this.get("menuPane")||this.get("keyPane")||this.get("mainPane")}c=(f)?f.sendEvent(d,a,e):null},this);return c},listenFor:function(d,c,b,a){b=b?b:this;d.forEach(function(e){var f=b[e];if(f){SC.Event.add(c,e,b,f,null,a)}},this);c=null;return b},setup:function(){this.listenFor(["touchstart","touchmove","touchend","touchcancel","keydown","keyup","beforedeactivate","mousedown","mouseup","dragenter","dragover","dragleave","drop","click","dblclick","mousemove","contextmenu"],document).listenFor(["resize"],window);if(SC.browser.isIE8OrLower){this.listenFor(["focusin","focusout"],document)}else{this.listenFor(["focus","blur"],window)}if(this.keypress){if(SC.CAPTURE_BACKSPACE_KEY&&SC.browser.isMozilla){var d=this;document.onkeypress=function(f){f=SC.Event.normalizeEvent(f);return d.keypress.call(d,f)}}else{SC.Event.add(document,"keypress",this,this.keypress)}}if(SC.platform.supportsCSSTransitions){var c=SC.browser.domPrefix,a=c.toLowerCase(),j=a+"transitionend",h=a+"TransitionEnd",g=c+"TransitionEnd";this[j]=this[h]=this[g]=this.transitionend;this.listenFor(["transitionend",j,h,g],document);if(SC.platform.supportsCSSAnimations){j=a+"animationstart";h=a+"AnimationStart";g=c+"AnimationStart";this[j]=this[h]=this[g]=this.animationstart;this.listenFor(["animationstart",j,h,g],document);j=a+"animationiteration";h=a+"AnimationIteration";g=c+"AnimationIteration";this[j]=this[h]=this[g]=this.animationiteration;this.listenFor(["animationiteration",j,h,g],document);j=a+"animationend";h=a+"AnimationEnd";g=c+"AnimationEnd";this[j]=this[h]=this[g]=this.animationend;this.listenFor(["animationend",j,h,g],document)}}["drag","selectstart"].forEach(function(k){var l=this[k];if(l){if(SC.browser.isIE){var f=this;document.body["on"+k]=function(m){return l.call(f,SC.Event.normalizeEvent(event||window.event))};SC.Event.add(window,"unload",this,function(){document.body["on"+k]=null})}else{SC.Event.add(document,k,this,l)}}},this);var i="mousewheel";if(SC.browser.isMozilla){if(SC.browser.compare(SC.browser.engineVersion,"1.9.1")<0){i="DOMMouseScroll"}else{i="MozMousePixelScroll"}}SC.Event.add(document,i,this,this.mousewheel);this.set("currentWindowSize",this.computeWindowSize());if(SC.browser.os===SC.OS.ios&&SC.browser.name===SC.BROWSER.safari){if(SC.platform&&!SC.platform.touch){SC.platform.simulateTouchEvents()}var e=SC.RunLoop.prototype.endRunLoop,b;b=function(){if(e){e.apply(this,arguments)}var n=SC.RootResponder.responder._touches,p,k,m,l=NO;if(n){for(p in n){if(n[p]._rescuedElement){continue}m=k=n[p].target;while(k&&(k=k.parentNode)&&!l){l=(k===document.body)}if(!l&&m){if(m.parentNode&&m.cloneNode){var o=m.cloneNode(true);m.parentNode.replaceChild(o,m);m.swapNode=o}var f=SC.touchHoldingPen;if(!f){f=SC.touchHoldingPen=document.createElement("div");f.style.display="none";document.body.appendChild(f)}f.appendChild(m);n[p]._rescuedElement=m}}}};SC.RunLoop.prototype.endRunLoop=b}},cleanUpTransitionListeners:function(){var a=SC.platform.transitionendEventName,c=SC.browser.domPrefix,b=c.toLowerCase(),f=b+"transitionend",e=b+"TransitionEnd",d=c+"TransitionEnd";["transitionend",f,e,d].forEach(function(g){if(g!==a){SC.Event.remove(document,g,this,this[g]);this[g]=null}})},cleanUpAnimationListeners:function(){var c=SC.browser.domPrefix,b=c.toLowerCase(),a=SC.platform.animationendEventName,f=b+"animationend",e=b+"AnimationEnd",d=c+"AnimationEnd";["animationend",f,e,d].forEach(function(g){if(g!==a){SC.Event.remove(document,g,this,this[g]);this[g]=null}});a=SC.platform.animationiterationEventName;f=b+"animationiteration";e=b+"AnimationIteration";d=c+"AnimationIteration";["animationiteration",f,e,d].forEach(function(g){if(g!==a){SC.Event.remove(document,g,this,this[g]);this[g]=null}});a=SC.platform.animationstartEventName;f=b+"animationstart";e=b+"AnimationStart";d=c+"AnimationStart";["animationstart",f,e,d].forEach(function(g){if(g!==a){SC.Event.remove(document,g,this,this[g]);this[g]=null}})},_touchedViews:{},_touches:{},touchesForView:function(a){if(this._touchedViews[SC.guidFor(a)]){return this._touchedViews[SC.guidFor(a)].touches}},averagedTouchesForView:function(b,f){var e=this.touchesForView(b),a,d,h;d=b._scrr_averagedTouches||(b._scrr_averagedTouches={});if((!e||e.length===0)&&!f){d.x=0;d.y=0;d.d=0;d.velocityX=0;d.velocityY=0}else{var g=this._averagedTouches_touches||(this._averagedTouches_touches=[]);if(e){var c;a=e.length;for(c=0;c<a;c++){g.push(e[c]);if(f&&e[c]===f){h=YES}}}if(f&&!h){g.push(f)}SC.Touch.averagedTouch(g,d);g.length=0}return d},assignTouch:function(b,a){if(b.hasEnded){throw new Error("Attempt to assign a touch that is already finished.")}if(b.view===a){return}if(b.view){this.unassignTouch(b)}if(!this._touchedViews[SC.guidFor(a)]){this._touchedViews[SC.guidFor(a)]={view:a,touches:SC.CoreSet.create([]),touchCount:0};a.set("hasTouch",YES)}b.view=a;this._touchedViews[SC.guidFor(a)].touches.add(b);this._touchedViews[SC.guidFor(a)].touchCount++},unassignTouch:function(c){var a,b;if(!c.view){return}a=c.view;b=this._touchedViews[SC.guidFor(a)];b.touches.remove(c);b.touchCount--;if(b.touchCount<1){a.set("hasTouch",NO);b.view=null;delete this._touchedViews[SC.guidFor(a)]}c.view=undefined},_flushQueuedTouchResponder:function(){if(this._queuedTouchResponder){var a=this._queuedTouchResponder;this._queuedTouchResponder=null;this.makeTouchResponder.apply(this,a)}},makeTouchResponder:function(f,d,c,k){if(this._isMakingTouchResponder){this._queuedTouchResponder=[f,d,c,k];return YES}this._isMakingTouchResponder=YES;var h=f.touchResponders||[],b;if(f.touchResponder===d){this._isMakingTouchResponder=NO;this._flushQueuedTouchResponder();return YES}var a;if(d){a=d.get("pane")}else{a=this.get("keyPane")||this.get("mainPane")}if(h.indexOf(d)<0){if(k){try{d=a?a.sendEvent("touchStart",f,d,k):null}catch(g){SC.Logger.error("Error in touchStart: "+g);d=null}}else{if(d&&((d.get?d.get("acceptsMultitouch"):d.acceptsMultitouch)||!d.hasTouch)){if(!d.respondsTo("touchStart")){d=null}else{if(d.touchStart(f)===NO){d=null}}}}}if(!c||(h.indexOf(d)>-1&&h[h.length-1]!==d)){this.unassignTouch(f);var i=h.length-1,j=h[i];while(j&&j!==d){b=this.touchesForView(j);if((j.get?j.get("acceptsMultitouch"):j.acceptsMultitouch)||!b){if(j.touchCancelled){j.touchCancelled(f)}}i--;j=h[i];h.pop();f.touchResponder=h[i];f.nextTouchResponder=h[i-1]}}if(d){this.assignTouch(f,d);if(d!==f.touchResponder){h.push(d);f.touchResponder=d;f.nextTouchResponder=h[h.length-2]}}this._isMakingTouchResponder=NO;this._flushQueuedTouchResponder();return !!d},captureTouch:function(h,e,g){if(!e){e=this}var f=h.targetView,c=f,d=[],b,a;while(c&&(c!==e)){d.unshift(c);c=c.get("nextResponder")}for(a=d.length,b=0;b<a;b++){c=d[b];if(c.tryToPerform("captureTouch",h)){this.makeTouchResponder(h,c,g,e);return YES}}return NO},_touchCount:0,endTouch:function(b,g,c){if(!g){g="touchEnd"}var a,f,d,e;this.unassignTouch(b);if(b.touchResponder){e=b.touchResponder;f=b.touchResponders;a=f.length-1;d=f[a];while(d){if(d[g]){d[g](b,c)}if(b.touchResponder!==e){break}a--;d=f[a];g="touchCancelled"}}},finishTouch:function(b){this.unassignTouch(b);var a=b._rescuedElement;if(a){if(a.swapNode&&a.swapNode.parentNode){a.swapNode.parentNode.replaceChild(a,a.swapNode)}else{if(a.parentNode===SC.touchHoldingPen){SC.touchHoldingPen.removeChild(a)}}delete b._rescuedElement;a.swapNode=null;a=null}b.touchResponders=null;b.touchResponder=null;b.nextTouchResponder=null;b.hasEnded=YES;if(this._touches[b.identifier]){delete this._touches[b.identifier]}},touchstart:function(a){if(this.ignoreTouchHandle(a)){return YES}var b=NO;SC.run(function(){var f=a.changedTouches,e=f.length,d,h,c;a.touchContext=this;for(d=0;d<e;d++){h=f[d];c=SC.Touch.create(h,this);if(!c.targetView){continue}if(c.hidesTouchIntercept){b=YES}c.timeStamp=a.timeStamp;this._touches[h.identifier]=c;c.event=a;var g=this.captureTouch(c,this);if(!g){this.makeTouchResponder(c,c.targetView,NO,YES)}c.event=null}a.touchContext=null},this);if(b){return YES}return a.hasCustomEventHandling},touchmove:function(a){if(this.ignoreTouchHandle(a)){return YES}SC.run(function(){var e=a.changedTouches,d,q,n,h=e.length,m,l,k,p,i={},j,f=NO;if(this._drag){d=SC.Touch.create(a.changedTouches[0],this);this._drag.tryToPerform("mouseDragged",d)}for(n=0;n<h;n++){d=e[n];q=this._touches[d.identifier];if(!q){continue}if(q.hidesTouchIntercept){f=YES}var c=a.timeStamp-q.timeStamp,o,b,g;if(c!==0){o=Math.min(1,c/80);b=(d.pageX-q.pageX)/c;q.velocityX=(1-o)*q.velocityX+o*(b);g=(d.pageY-q.pageY)/c;q.velocityY=(1-o)*q.velocityY+o*(g)}q.pageX=d.pageX;q.pageY=d.pageY;q.clientX=d.clientX;q.clientY=d.clientY;q.screenX=d.screenX;q.screenY=d.screenY;q.timeStamp=a.timeStamp;q.type=a.type;q.event=a;if(q.touchResponder){m=q.touchResponder;j=SC.guidFor(m);if(!i[j]){i[j]={view:m,touches:[]}}i[j].touches.push(q)}}if(f){a.allowDefault();return YES}for(n in i){m=i[n].view;l=i[n].touches;a.viewChangedTouches=l;k=this.touchesForView(m);p=k.firstObject();a.pageX=p.pageX;a.pageY=p.pageY;a.clientX=p.clientX;a.clientY=p.clientY;a.screenX=p.screenX;a.screenY=p.screenY;a.startX=p.startX;a.startY=p.startY;a.velocityX=p.velocityX;a.velocityY=p.velocityY;a.touchContext=this;m.tryToPerform("touchesDragged",a,k)}e=a.changedTouches;h=e.length;for(n=0;n<h;n++){d=e[n];q=this._touches[d.identifier];if(q){q.event=null}}a.touchContext=null;a.viewChangedTouches=null},this);return a.hasCustomEventHandling},touchend:function(a){var b=NO;if(this.ignoreTouchHandle(a)){return YES}SC.run(function(){var g=a.changedTouches,f,l,j,i=g.length,e=a.isCancel?"touchCancelled":"touchEnd";for(j=0;j<i;j++){f=g[j];f.type="touchend";l=this._touches[f.identifier];if(!l){continue}var d=a.timeStamp-l.timeStamp,k,c,h;if(d!==0){k=Math.min(1,d/80);c=(f.pageX-l.pageX)/d;l.velocityX=(1-k)*l.velocityX+k*(c);h=(f.pageY-l.pageY)/d;l.velocityY=(1-k)*l.velocityY+k*(h)}l.timeStamp=a.timeStamp;l.pageX=f.pageX;l.pageY=f.pageY;l.clientX=f.clientX;l.clientY=f.clientY;l.screenX=f.screenX;l.screenY=f.screenY;l.type="touchend";l.event=a;if(l.hidesTouchIntercept){l.unhideTouchIntercept();b=YES}if(this._drag){this._drag.tryToPerform("mouseUp",f);this._drag=null;this._mouseDownView=null}this.endTouch(l,e,a);this.finishTouch(l)}},this);if(b){return YES}return a.hasCustomEventHandling},touchcancel:function(a){a.isCancel=YES;this.touchend(a)},ignoreTouchHandle:function(b){if(SC.browser.isMobileSafari){var a=b.target.tagName;if(a==="INPUT"||a==="TEXTAREA"||a==="A"||a==="SELECT"){b.allowDefault();return YES}}return NO},ignoreKeyHandle:function(a){return NO},attemptKeyEquivalent:function(b){var d=null;var c=b.commandCodes()[0];if(!c){return NO}var f=this.get("menuPane"),a=this.get("keyPane"),e=this.get("mainPane");if(f){d=f.performKeyEquivalent(c,b);if(d){return d}}if(a){d=a.performKeyEquivalent(c,b);if(d||a.get("isModal")){return d}}if(!d&&e&&(e!==a)){d=e.performKeyEquivalent(c,b);if(d||e.get("isModal")){return d}}return d},_lastModifiers:null,_handleModifierChanges:function(b){var a;a=this._lastModifiers=(this._lastModifiers||{alt:false,ctrl:false,shift:false});var c=false;if(b.altKey!==a.alt){a.alt=b.altKey;c=true}if(b.ctrlKey!==a.ctrl){a.ctrl=b.ctrlKey;c=true}if(b.shiftKey!==a.shift){a.shift=b.shiftKey;c=true}b.modifiers=a;return(c)?(this.sendEvent("flagsChanged",b)?b.hasCustomEventHandling:YES):YES},_isFunctionOrNonPrintableKey:function(a){return !!(a.altKey||a.ctrlKey||a.metaKey||SC.FUNCTION_KEYS[a.which])},_isModifierKey:function(a){return !!SC.MODIFIER_KEYS[a.charCode]},_isPrintableKey:function(a){return((a.originalEvent.which===undefined||a.originalEvent.which>0)&&!(a.which===8||a.which===9||a.which===13||a.which===27))},keydown:function(a){if(SC.none(a)){return YES}if(this.ignoreKeyHandle(a)){return YES}var e=a.keyCode;if(SC.browser.isMozilla&&a.keyCode===9){this.keydownCounter=1}if(e===229){this._IMEInputON=YES;return this.sendEvent("keyDown",a)}if(e===27&&this._drag){this._drag.cancelDrag(a);this._drag=null;this._mouseDownView=null;return YES}if(SC.browser.isMozilla&&(a.which===8)){return true}var b=this._handleModifierChanges(a),d=a.target||a.srcElement,c=(a.which===8)&&!SC.allowsBackspaceToPreviousPage&&(d===document.body);if(this._isModifierKey(a)){return(c?NO:b)}b=YES;if(this._isFunctionOrNonPrintableKey(a)){if(e>=37&&e<=40&&SC.browser.isMozilla){return YES}b=this.sendEvent("keyDown",a);if(!b){SC.run(function(){b=!this.attemptKeyEquivalent(a)},this)}else{b=a.hasCustomEventHandling;if(b){c=NO}}}return c?NO:b},keypress:function(b){if(this.ignoreKeyHandle(b)){return YES}var c,e=b.keyCode,f=SC.browser.isMozilla;if(f&&b.keyCode===9){this.keydownCounter++;if(this.keydownCounter===2){return YES}}if(f&&(b.which===8)){b.which=e;c=this.sendEvent("keyDown",b);return c?(SC.allowsBackspaceToPreviousPage||b.hasCustomEventHandling):YES}else{var d=(e>=37&&e<=40&&f),a=b.charCode;if((a!==undefined&&a===0&&b.keyCode!==9)&&!d){return YES}if(d){b.which=e}if(d||this._isPrintableKey(b)){return this.sendEvent("keyDown",b)?b.hasCustomEventHandling:YES}}},keyup:function(a){if(this.ignoreKeyHandle(a)){return YES}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(c){var b=c.toElement;if(b&&b.tagName&&b.tagName!=="IFRAME"){var a=SC.viewFor(b);if(a&&a.get("blocksIEDeactivate")){return NO}}return YES},mousedown:function(d){if(this.ignoreMouseHandle(d)){return YES}this._clickCount+=1;var c=this.targetViewForEvent(d);c=this._mouseDownView=this.sendEvent("mouseDown",d,c);if(c&&c.respondsTo("mouseDragged")){this._mouseCanDrag=YES}var e=c?d.hasCustomEventHandling:YES;this._lastMouseDownCustomHandling=e;if(!this._lastMouseUpAt||this._lastMouseDownView!==this._mouseDownView||((Date.now()-this._lastMouseUpAt)>250)){this._clickCount=1}else{var b=this._lastMouseDownX-d.clientX,a=this._lastMouseDownY-d.clientY,f=Math.sqrt(b*b+a*a);if(f>8){this._clickCount=1}}d.clickCount=this._clickCount;this._lastMouseDownView=this._mouseDownView;this._lastMouseDownX=d.clientX;this._lastMouseDownY=d.clientY;return e},mouseup:function(b){if(this.ignoreMouseHandle(b)){return YES}var g=NO,c=this._drag,f=null;if(c){SC.run(function(){c.tryToPerform("mouseUp",b)})}else{var a=this._mouseDownView,e=this.targetViewForEvent(b);b.clickCount=this._clickCount;if(a){f=this.sendEvent("mouseUp",b,a);if(!f&&this._clickCount===2){f=this.sendEvent("doubleClick",b,a);g=YES}if(!f){f=this.sendEvent("click",b,a);g=YES}}if(!f&&!g){if(this._clickCount===2){f=this.sendEvent("doubleClick",b,e)}if(!f){f=this.sendEvent("click",b,e)}}}this._mouseCanDrag=NO;this._mouseDownView=this._drag=null;this._lastMouseUpAt=Date.now();var d=f?b.hasCustomEventHandling:YES;this._lastMouseUpCustomHandling=d;return d},click:function(a){if(this.ignoreMouseHandle(a)){return YES}if(!this._lastMouseUpCustomHandling||!this._lastMouseDownCustomHandling){a.preventDefault();a.stopPropagation();return NO}return YES},dblclick:function(a){if(this.ignoreMouseHandle(a)){return YES}if(SC.browser.isIE8OrLower){this._clickCount=2;this.mouseup(a)}},mousewheel:function(b){if(this.ignoreMouseHandle(b)){return YES}var a=this.targetViewForEvent(b),c=this.sendEvent("mouseWheel",b,a);return(c)?b.hasCustomEventHandling:YES},_lastHovered:null,mousemove:function(a){if(this.ignoreMouseHandle(a)){return YES}if(SC.browser.isIE){if(this._lastMoveX===a.clientX&&this._lastMoveY===a.clientY){return}}if(!(a.target instanceof Element)){SC.warn("mousemove target not element: "+(a&&a.target&&a.target.constructor.name));return}this._lastMoveX=a.clientX;this._lastMoveY=a.clientY;SC.run(function(){var e=this._drag;if(e){if(SC.browser.isIE){if(this._lastMouseDownX!==a.clientX||this._lastMouseDownY!==a.clientY){e.tryToPerform("mouseDragged",a)}}else{e.tryToPerform("mouseDragged",a)}}else{var d=this._lastHovered||[],f=[],g,b,c=this.targetViewForEvent(a);while(c&&(c!==this)){f.push(c);c=c.get("nextResponder")}for(g=0,b=d.length;g<b;g++){c=d[g];if(f.indexOf(c)===-1&&!c.isDestroyed){c.tryToPerform("mouseExited",a)}}for(g=0,b=f.length;g<b;g++){c=f[g];if(d.indexOf(c)!==-1){c.tryToPerform("mouseMoved",a)}else{c.tryToPerform("mouseEntered",a)}}this._lastHovered=f;if(this._mouseDownView){if(SC.browser.isIE){if(this._lastMouseDownX!==a.clientX&&this._lastMouseDownY!==a.clientY){this._mouseDownView.tryToPerform("mouseDragged",a)}}else{this._mouseDownView.tryToPerform("mouseDragged",a)}}}},this)},ignoreMouseHandle:function(a){return NO},dragenter:function(a){SC.run(function(){this._dragenter(a)},this)},_dragenter:function(a){if(!this._dragCounter){this._dragCounter=1}else{this._dragCounter++}return this._dragover(a)},dragleave:function(a){SC.run(function(){this._dragleave(a)},this)},_dragleave:function(a){this._dragCounter--;var b=this._dragover(a);return b},_forceDragLeave:function(){this.invokeLast(function(){if(this._dragCounter===0){return}this._dragCounter=0;var a=this._lastDraggedEvt;this._dragover(a)})},dragover:function(a){SC.run(function(){this._dragover(a)},this)},_dragover:function(c){if(c.dataTransfer&&c.dataTransfer.types&&(c.dataTransfer.types.includes("Files")||c.dataTransfer.types.includes("text/uri-list"))){c.preventDefault();c.stopPropagation();c.dataTransfer.dropEffect="none"}var d=this._lastDraggedOver||[],f=[],e,a,b=this.targetViewForEvent(c);while(b&&(b!==this)){f.push(b);b=b.get("nextResponder")}if(this._dragLeaveTimer){this._dragLeaveTimer.invalidate()}if(this._dragCounter===0){for(e=0,a=f.length;e<a;e++){b=f[e];b.tryToPerform("dataDragExited",c)}this._lastDraggedOver=this._lastDraggedEvt=this._dragLeaveTimer=null}else{if(c.type!=="dragleave"){for(e=0,a=d.length;e<a;e++){b=d[e];if(f.indexOf(b)===-1){b.tryToPerform("dataDragExited",c)}}for(e=f.length-1;e>=0;e--){b=f[e];if(d.indexOf(b)===-1){b.tryToPerform("dataDragEntered",c)}}for(e=0,a=f.length;e<a;e++){b=f[e];b.tryToPerform("dataDragHovered",c)}this._lastDraggedOver=f;this._lastDraggedEvt=new SC.Event(c.originalEvent||c);this._dragLeaveTimer=SC.Timer.schedule({target:this,action:"_forceDragLeave",interval:5000})}}},drop:function(a){SC.run(function(){this._drop(a)},this)},_drop:function(c){if(c.dataTransfer&&c.dataTransfer.types&&(c.dataTransfer.types.includes("Files")||c.dataTransfer.types.includes("text/uri-list"))){c.preventDefault();c.stopPropagation();c.dataTransfer.dropEffect="none"}var d=this._lastDraggedOver||[],f=[],e,a,b=this.targetViewForEvent(c);while(b&&(b!==this)){f.push(b);b=b.get("nextResponder")}for(e=0,a=d.length;e<a;e++){b=d[e];if(f.indexOf(b)===-1){b.tryToPerform("dataDragExited",c)}}for(e=0,a=f.length;e<a;e++){b=f[e];if(b.tryToPerform("dataDragDropped",c)){break}}for(e=0,a=f.length;e<a;e++){b=f[e];b.tryToPerform("dataDragExited",c)}this._lastDraggedOver=null;this._lastDraggedAt=null;this._dragCounter=0;if(this._dragLeaveTimer){this._dragLeaveTimer.invalidate()}this._dragLeaveTimer=null},_mouseCanDrag:YES,ignoreSelectHandle:function(a){return NO},selectstart:function(b){if(this.ignoreSelectHandle(b)){return YES}var c=this.targetViewForEvent(b),a=this.sendEvent("selectStart",b,c);if(c&&c.respondsTo("mouseDragged")){return(a!==null?YES:NO)&&!this._mouseCanDrag}else{return(a!==null?YES:NO)}},drag:function(){return false},contextmenu:function(b){var a=this.targetViewForEvent(b),c;a=this.sendEvent("contextMenu",b,a);c=a?b.hasCustomEventHandling:YES;return c},animationstart:function(b){var a=this.targetViewForEvent(b);this.sendEvent("animationDidStart",b,a);return a?b.hasCustomEventHandling:YES},animationiteration:function(b){var a=this.targetViewForEvent(b);this.sendEvent("animationDidIterate",b,a);return a?b.hasCustomEventHandling:YES},animationend:function(b){var a=this.targetViewForEvent(b);this.sendEvent("animationDidEnd",b,a);return a?b.hasCustomEventHandling:YES},transitionend:function(b){var a=this.targetViewForEvent(b);this.sendEvent("transitionDidEnd",b,a);return a?b.hasCustomEventHandling:YES}});SC.ready(SC.RootResponder,SC.RootResponder.ready=function(){var a;a=SC.RootResponder.responder=SC.RootResponder.create();a.setup()});sc_require("system/root_responder");SC.Application=SC.Responder.extend(SC.ResponderContext,{designModes:{s:500000,m:2000000,l:Infinity},init:function(){arguments.callee.base.apply(this,arguments);SC.ready(this,"_setDesignModes")},_setDesignModes:function(){var b=this.get("designModes"),a=SC.RootResponder.responder;if(b){a.set("designModes",b)}}});SC.CubicBezierEquation=function(h,g,f,d){var e=function(i){return(1-i)*(1-i)*(1-i)};var c=function(i){return 3*i*(1-i)*(1-i)};var b=function(i){return 3*i*i*(1-i)};var a=function(i){return i*i*i};this.position=function(i){var j={};j.x=h.x*e(i)+g.x*c(i)+f.x*b(i)+d.x*a(i);j.y=h.y*e(i)+g.y*c(i)+f.y*b(i)+d.y*a(i);return j}};SC.easingCurve=function(i,h,f,d){var e={x:0,y:0},c={x:i,y:h},b={x:f,y:d},a={x:1,y:1};var g=new SC.CubicBezierEquation(e,c,b,a);g.value=function(j){j=Math.max(0,Math.min(j,1));return this.position(j).y};g.toString=function(){return"cubic-bezier(%@, %@, %@, %@)".fmt(i,h,f,d)};return g};SC.Color=SC.Object.extend(SC.Copyable,{original:null,isError:NO,errorValue:null,a:function(a,b){if(b===undefined){return this._a}else{if(this.get("isError")){b=this._a}this._a=b;return b}}.property().cacheable(),_a:1,r:function(a,b){if(b===undefined){return this._r}else{if(this.get("isError")){b=this._r}this._r=b;return b}}.property().cacheable(),_r:0,g:function(a,b){if(b===undefined){return this._g}else{if(this.get("isError")){b=this._g}this._g=b;return b}}.property().cacheable(),_g:0,b:function(a,b){if(b===undefined){return this._b}else{if(this.get("isError")){b=this._b}this._b=b;return b}}.property().cacheable(),_b:0,hue:function(c,d){var e=SC.Color.clampToDeviceGamut,a=SC.Color.rgbToHsl(e(this.get("r")),e(this.get("g")),e(this.get("b"))),b;if(d!==undefined){a[0]=(d%360+360)%360;b=SC.Color.hslToRgb(a[0],a[1],a[2]);this.beginPropertyChanges();this.set("r",b[0]);this.set("g",b[1]);this.set("b",b[2]);this.endPropertyChanges()}return a[0]}.property("r","g","b").cacheable(),saturation:function(c,d){var e=SC.Color.clampToDeviceGamut,a=SC.Color.rgbToHsl(e(this.get("r")),e(this.get("g")),e(this.get("b"))),b;if(d!==undefined){a[1]=SC.Color.clamp(d,0,1);b=SC.Color.hslToRgb(a[0],a[1],a[2]);this.beginPropertyChanges();this.set("r",b[0]);this.set("g",b[1]);this.set("b",b[2]);this.endPropertyChanges()}return a[1]}.property("r","g","b").cacheable(),luminosity:function(c,d){var e=SC.Color.clampToDeviceGamut,a=SC.Color.rgbToHsl(e(this.get("r")),e(this.get("g")),e(this.get("b"))),b;if(d!==undefined){a[2]=SC.Color.clamp(d,0,1);b=SC.Color.hslToRgb(a[0],a[1],a[2]);this.beginPropertyChanges();this.set("r",b[0]);this.set("g",b[1]);this.set("b",b[2]);this.endPropertyChanges()}return a[2]}.property("r","g","b").cacheable(),isEqualTo:function(a){return this.get("r")===a.get("r")&&this.get("g")===a.get("g")&&this.get("b")===a.get("b")&&this.get("a")===a.get("a")},toArgb:function(){var a=SC.Color.clampToDeviceGamut;return"#"+[a(255*this.get("a")),a(this.get("r")),a(this.get("g")),a(this.get("b"))].map(function(b){b=b.toString(16);return b.length===1?"0"+b:b}).join("")},toHex:function(){var a=SC.Color.clampToDeviceGamut;return"#"+[a(this.get("r")),a(this.get("g")),a(this.get("b"))].map(function(b){b=b.toString(16);return b.length===1?"0"+b:b}).join("")},toRgb:function(){var a=SC.Color.clampToDeviceGamut;return"rgb("+a(this.get("r"))+","+a(this.get("g"))+","+a(this.get("b"))+")"},toRgba:function(){var a=SC.Color.clampToDeviceGamut;return"rgba("+a(this.get("r"))+","+a(this.get("g"))+","+a(this.get("b"))+","+this.get("a")+")"},toHsl:function(){var a=Math.round;return"hsl("+a(this.get("hue"))+","+a(this.get("saturation")*100)+"%,"+a(this.get("luminosity")*100)+"%)"},toHsla:function(){var a=Math.round;return"hsla("+a(this.get("hue"))+","+a(this.get("saturation")*100)+"%,"+a(this.get("luminosity")*100)+"%,"+this.get("a")+")"},cssText:function(a,c){if(c===undefined){if(this.get("isError")){return this.get("errorValue")}if(this.get("a")===0){return"transparent"}var b=SC.Color.supportsRgba||SC.Color.supportsArgb;return(this.get("a")===1||!b)?this.toHex():SC.Color.supportsRgba?this.toRgba():this.toArgb()}else{var d=SC.Color._parse(c);this.beginPropertyChanges();if(!d){this._lastValidHash={r:this._r,g:this._g,b:this._b,a:this._a};this.set("r",0);this.set("g",0);this.set("b",0);this.set("a",0);this.set("errorValue",c);this.set("isError",YES)}else{this.setIfChanged("isError",NO);this.setIfChanged("errorValue",null);this.set("r",d.r);this.set("g",d.g);this.set("b",d.b);this.set("a",d.a)}this.endPropertyChanges();return c}}.property("r","g","b","a").cacheable(),validCssText:function(){if(this.get("isError")){return"transparent"}else{return this.get("cssText")}}.property("cssText","isError").cacheable(),reset:function(){if(!this.get("isError")){return this}var a=this._lastValidHash||{r:0,g:0,b:0,a:1};this.beginPropertyChanges();this.set("isError",NO);this.set("errorValue",null);this.set("r",a.r);this.set("g",a.g);this.set("b",a.b);this.set("a",a.a);this.endPropertyChanges();return this},copy:function(){return SC.Color.create({original:this.get("original"),r:this.get("r"),g:this.get("g"),b:this.get("b"),a:this.get("a"),isError:this.get("isError"),errorValue:this.get("errorValue")})},sub:function(a){return SC.Color.create({r:this.get("r")-a.get("r"),g:this.get("g")-a.get("g"),b:this.get("b")-a.get("b"),a:this.get("a")-a.get("a"),isError:this.get("isError")||a.get("isError")})},add:function(a){return SC.Color.create({r:this.get("r")+a.get("r"),g:this.get("g")+a.get("g"),b:this.get("b")+a.get("b"),a:this.get("a")+a.get("a"),isError:this.get("isError")})},mult:function(b){var a=Math.round;return SC.Color.create({r:a(this.get("r")*b),g:a(this.get("g")*b),b:a(this.get("b")*b),a:this.get("a")*b,isError:this.get("isError")})}});SC.Color.mixin({create:function(){var g={},a=NO,j=["a","r","g","b"],f,e,c,d,b,h;f=new Array(arguments.length);e=f.length;for(d=0;d<e;d++){c=arguments[d];if(SC.typeOf(c.a)===SC.T_NUMBER||SC.typeOf(c.r)===SC.T_NUMBER||SC.typeOf(c.g)===SC.T_NUMBER||SC.typeOf(c.b)===SC.T_NUMBER){a=YES;c=f[d]=SC.clone(c);for(b=0;b<4;b++){h=j[b];if(SC.typeOf(c[h])===SC.T_NUMBER){g["_"+h]=c[h];delete c[h]}}}else{f[d]=c}}if(a){f.push(g)}return SC.Object.create.apply(this,f)},supportsRgba:(function(){var c=document.getElementsByTagName("script")[0].style,b=c.cssText,a;c.cssText="background-color:rgba(5,2,1,.5)";a=c.backgroundColor.indexOf("rgba")!==-1;c.cssText=b;return a}()),supportsArgb:(function(){var c=document.getElementsByTagName("script")[0].style,b=c.cssText,a;c.cssText='filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#55000000", endColorstr="#55000000");';a=c.backgroundColor.indexOf("#55000000")!==-1;c.cssText=b;return a}()),clamp:function(c,b,a){return Math.max(Math.min(c,a),b)},clampInt:function(c,b,a){return Math.round(SC.Color.clamp(c,b,a))},clampToDeviceGamut:function(a){return SC.Color.clampInt(a,0,255)},hsvToRgb:function(j,x,u){j/=360;var a,l,o,e=Math.floor(j*6),m=j*6-e,d=u*(1-x),c=u*(1-(x*m)),w=u*(1-(x*(1-m))),n=[[u,w,d],[c,u,d],[d,u,w],[d,c,u],[w,d,u],[u,d,c]],k=SC.Color.clampToDeviceGamut;e=e%6;a=k(n[e][0]*255);l=k(n[e][1]*255);o=k(n[e][2]*255);return[a,l,o]},rgbToHsv:function(a,f,j){a/=255;f/=255;j/=255;var k=Math.max(a,f,j),c=Math.min(a,f,j),i=k-c,e,m=k===0?0:i/k,l=k;if(k===c){e=0}else{switch(k){case a:e=(f-j)/i+(f<j?6:0);break;case f:e=(j-a)/i+2;break;case j:e=(a-f)/i+4;break}e/=6}e*=360;return[e,m,l]},hslToRgb:function(f,e,b){f/=360;var d,c,a=SC.Color.hueToRgb,g=SC.Color.clampToDeviceGamut;c=b<=0.5?b*(e+1):b+e-b*e;d=b*2-c;return[g(a(d,c,f+1/3)*255),g(a(d,c,f)*255),g(a(d,c,f-1/3)*255)]},hueToRgb:function(b,a,c){if(c<0){c++}if(c>1){c--}if(c<1/6){return b+(a-b)*c*6}if(c<1/2){return a}if(c<2/3){return b+(a-b)*(2/3-c)*6}return b},rgbToHsl:function(a,i,k){a/=255;i/=255;k/=255;var m=Math.max(a,i,k),e=Math.min(a,i,k),f,n,c=(m+e)/2,j=m-e;if(m===e){f=n=0}else{n=c>0.5?j/(2-m-e):j/(m+e);switch(m){case a:f=(i-k)/j+(i<k?6:0);break;case i:f=(k-a)/j+2;break;case k:f=(a-i)/j+4;break}f/=6}f*=360;return[f,n,c]},PARSE_RGBA:/^rgba\(\s*([\d]+%?)\s*,\s*([\d]+%?)\s*,\s*([\d]+%?)\s*,\s*([.\d]+)\s*\)$/,PARSE_RGB:/^rgb\(\s*([\d]+%?)\s*,\s*([\d]+%?)\s*,\s*([\d]+%?)\s*\)$/,PARSE_HSLA:/^hsla\(\s*(-?[\d]+)\s*\s*,\s*([\d]+)%\s*,\s*([\d]+)%\s*,\s*([.\d]+)\s*\)$/,PARSE_HSL:/^hsl\(\s*(-?[\d]+)\s*,\s*([\d]+)%\s*,\s*([\d]+)%\s*\)$/,PARSE_HEX:/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,PARSE_ARGB:/^#[0-9a-fA-F]{8}$/,KEYWORDS:{aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aqua:"#00FFFF",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000000",blanchedalmond:"#FFEBCD",blue:"#0000FF",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",cyan:"#00FFFF",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgray:"#A9A9A9",darkgreen:"#006400",darkgrey:"#A9A9A9",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkorange:"#FF8C00",darkorchid:"#9932CC",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deepskyblue:"#00BFFF",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",firebrick:"#B22222",floralwhite:"#FFFAF0",forestgreen:"#228B22",fuchsia:"#FF00FF",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",gold:"#FFD700",goldenrod:"#DAA520",gray:"#808080",green:"#008000",greenyellow:"#ADFF2F",grey:"#808080",honeydew:"#F0FFF0",hotpink:"#FF69B4",indianred:"#CD5C5C",indigo:"#4B0082",ivory:"#FFFFF0",khaki:"#F0E68C",lavender:"#E6E6FA",lavenderblush:"#FFF0F5",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lightblue:"#ADD8E6",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightgoldenrodyellow:"#FAFAD2",lightgray:"#D3D3D3",lightgreen:"#90EE90",lightgrey:"#D3D3D3",lightpink:"#FFB6C1",lightsalmon:"#FFA07A",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",lime:"#00FF00",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#FF00FF",maroon:"#800000",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumpurple:"#9370DB",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",mistyrose:"#FFE4E1",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",navy:"#000080",oldlace:"#FDF5E6",olive:"#808000",olivedrab:"#6B8E23",orange:"#FFA500",orangered:"#FF4500",orchid:"#DA70D6",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",paleturquoise:"#AFEEEE",palevioletred:"#DB7093",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peru:"#CD853F",pink:"#FFC0CB",plum:"#DDA0DD",powderblue:"#B0E0E6",purple:"#800080",red:"#FF0000",rosybrown:"#BC8F8F",royalblue:"#4169E1",saddlebrown:"#8B4513",salmon:"#FA8072",sandybrown:"#F4A460",seagreen:"#2E8B57",seashell:"#FFF5EE",sienna:"#A0522D",silver:"#C0C0C0",skyblue:"#87CEEB",slateblue:"#6A5ACD",slategray:"#708090",slategrey:"#708090",snow:"#FFFAFA",springgreen:"#00FF7F",steelblue:"#4682B4",tan:"#D2B48C",teal:"#008080",thistle:"#D8BFD8",tomato:"#FF6347",turquoise:"#40E0D0",violet:"#EE82EE",wheat:"#F5DEB3",white:"#FFFFFF",whitesmoke:"#F5F5F5",yellow:"#FFFF00",yellowgreen:"#9ACD32"},from:function(a){if(SC.kindOf(a,SC.Color)){return a.copy()}var b=SC.Color._parse(a),c=SC.Color;if(!b){return SC.Color.create({original:a,isError:YES})}return c.create({original:a,r:c.clampInt(b.r,0,255),g:c.clampInt(b.g,0,255),b:c.clampInt(b.b,0,255),a:c.clamp(b.a,0,1)})},_parse:function(f){var k=SC.Color,j=f,i,h,c,d=1,e=function(b){var a=parseInt(b,10);return b.slice(-1)==="%"?k.clampInt(a*2.55,0,255):k.clampInt(a,0,255)};if(k.KEYWORDS.hasOwnProperty(f)){f=k.KEYWORDS[f]}else{if(SC.none(f)||f===""){f="transparent"}}if(k.PARSE_RGB.test(f)){f=f.match(k.PARSE_RGB);i=e(f[1]);h=e(f[2]);c=e(f[3])}else{if(k.PARSE_RGBA.test(f)){f=f.match(k.PARSE_RGBA);i=e(f[1]);h=e(f[2]);c=e(f[3]);d=parseFloat(f[4],10)}else{if(k.PARSE_HEX.test(f)){if(f.length===4){f="#"+f.charAt(1)+f.charAt(1)+f.charAt(2)+f.charAt(2)+f.charAt(3)+f.charAt(3)}i=parseInt(f.slice(1,3),16);h=parseInt(f.slice(3,5),16);c=parseInt(f.slice(5,7),16)}else{if(k.PARSE_ARGB.test(f)){i=parseInt(f.slice(3,5),16);h=parseInt(f.slice(5,7),16);c=parseInt(f.slice(7,9),16);d=parseInt(f.slice(1,3),16)/255}else{if(k.PARSE_HSL.test(f)){f=f.match(k.PARSE_HSL);f=k.hslToRgb(((parseInt(f[1],10)%360+360)%360),k.clamp(parseInt(f[2],10)/100,0,1),k.clamp(parseInt(f[3],10)/100,0,1));i=f[0];h=f[1];c=f[2]}else{if(k.PARSE_HSLA.test(f)){f=f.match(k.PARSE_HSLA);d=parseFloat(f[4],10);f=k.hslToRgb(((parseInt(f[1],10)%360+360)%360),k.clamp(parseInt(f[2],10)/100,0,1),k.clamp(parseInt(f[3],10)/100,0,1));i=f[0];h=f[1];c=f[2]}else{if(f==="transparent"){i=h=c=0;d=0}else{return null}}}}}}}return{r:i,g:h,b:c,a:d}}});sc_require("system/core_query");sc_require("system/ready");sc_require("system/root_responder");sc_require("system/platform");SC.PORTRAIT_ORIENTATION="portrait";SC.LANDSCAPE_ORIENTATION="landscape";SC.NO_ORIENTATION="desktop";SC.device=SC.Object.create({orientation:SC.PORTRAIT_ORIENTATION,isOffline:NO,mouseLocation:function(){var a=SC.RootResponder.responder,c=a._lastMoveX,b=a._lastMoveY;if(SC.empty(c)||SC.empty(b)){return null}return{x:c,y:b}}.property(),init:function(){arguments.callee.base.apply(this,arguments);if(navigator&&navigator.onLine===false){this.set("isOffline",YES)}},setup:function(){var a=SC.RootResponder.responder;a.listenFor(["online","offline"],window,this);this.orientationHandlingShouldChange()},orientationHandlingShouldChange:function(){if(SC.platform.windowSizeDeterminesOrientation){SC.Event.remove(window,"orientationchange",this,this.orientationchange);this.windowSizeDidChange(SC.RootResponder.responder.get("currentWindowSize"))}else{if(SC.platform.supportsOrientationChange){SC.Event.add(window,"orientationchange",this,this.orientationchange);this.orientationchange()}}},windowSizeDidChange:function(a){if(SC.platform.windowSizeDeterminesOrientation){if(a.height>=a.width){SC.device.set("orientation",SC.PORTRAIT_ORIENTATION)}else{SC.device.set("orientation",SC.LANDSCAPE_ORIENTATION)}return YES}return NO},orientationchange:function(a){SC.run(function(){if(window.orientation===0||window.orientation===180){SC.device.set("orientation",SC.PORTRAIT_ORIENTATION)}else{SC.device.set("orientation",SC.LANDSCAPE_ORIENTATION)}})},orientationObserver:function(){var a=SC.$(document.body),b=this.get("orientation");if(b===SC.PORTRAIT_ORIENTATION){a.addClass("sc-portrait")}else{a.removeClass("sc-portrait")}if(b===SC.LANDSCAPE_ORIENTATION){a.addClass("sc-landscape")}else{a.removeClass("sc-landscape")}}.observes("orientation"),online:function(a){SC.run(function(){this.set("isOffline",NO)},this)},offline:function(a){SC.run(function(){this.set("isOffline",YES)},this)}});SC.ready(function(){SC.device.setup()});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.Page=SC.Object.extend({owner:null,get:function(a){var b=this[a];if(b&&b.isClass){this[a]=b=b.create({page:this});return b}else{return arguments.callee.base.apply(this,arguments)}},getIfConfigured:function(b){var a=this[b];return(a&&a.isViewClass)?null:this.get(b)},loc:function(c){var a,b;for(b in c){if(!c.hasOwnProperty(b)){continue}a=this[b];if(!a||!a.isViewClass){continue}a.loc(c[b])}return this}});SC.Page.design=SC.Page.create;SC.Page.localization=function(a){return a};sc_require("system/builder");SC.MODE_REPLACE="replace";SC.MODE_APPEND="append";SC.MODE_PREPEND="prepend";SC.NON_PIXEL_PROPERTIES=["zIndex","opacity"];SC.COMBO_STYLES={WebkitTransition:["WebkitTransitionProperty","WebkitTransitionDuration","WebkitTransitionDelay","WebkitTransitionTimingFunction"]};SC.RenderContext=SC.Builder.create({SELF_CLOSING:SC.CoreSet.create().addEach(["area","base","basefront","br","hr","input","img","link","meta"]),init:function(d,b){var a;if(b){this.prevObject=b;this.strings=b.strings;this.offset=b.length+b.offset}if(!this.strings){this.strings=[]}if(d===undefined){d="div";a=YES}else{if(d==="div"||d==="label"||d==="a"){a=YES}else{if(SC.typeOf(d)===SC.T_STRING){d=d.toLowerCase();a=YES}}}if(a){this._tagName=d;this._needsTag=YES;this.needsContent=YES;var e=this;while(e){e.length++;e=e.prevObject}this.strings.push(null);this._selfClosing=this.SELF_CLOSING.contains(d)}else{this._elem=d;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(b){var a=this.strings||[];return(b===undefined)?a.slice(this.offset,this.length):a[b+this.offset]},html:function(a){return this.push(a)},push:function(d){var b=this.strings,a=arguments.length;if(!b){this.strings=b=[]}if(a>1){b.push.apply(b,arguments)}else{b.push(d)}var e=this;while(e){e.length+=a;e=e.prevObject}this.needsContent=YES;return this},text:function(){var b=arguments.length,a=0;for(a=0;a<b;a++){this.push(SC.RenderContext.escapeHTML(arguments[a]))}return this},join:function(b){if(this._needsTag){this.end()}var a=this.strings;return a?a.join(b||""):""},begin:function(a){return SC.RenderContext(a,this)},element:function(){return this._elem?this._elem:SC.$(this.join())[0]},remove:function(a){if(!a){return}var b,c=this._elem;if(!c||!c.removeChild){return}b=document.getElementById(a);if(b){b=c.removeChild(b);b=null}},update:function(){var c=this._elem,g=this.updateMode,e,d,a,f,b;if(!c){return}e=this.$();if(this.length>0){if(g===SC.MODE_REPLACE){e.html(this.join())}else{a=c.cloneNode(false);a.innerHTML=this.join();f=a.firstChild;while(f){b=f.nextSibling;c.insertBefore(f,b);f=b}f=b=a=null}}if(this._idDidChange&&(d=this._id)){e.attr("id",d)}c=this._elem=null;return this.prevObject||this},_DEFAULT_ATTRS:{},end:function(){var l="",b="",i,g,j=this._attrs,d=this._classes,a=this._id,k=this._styles,h,f;l="<"+this._tagName;if(j||d||k||a){if(!j){j=this._DEFAULT_ATTRS}if(a){j.id=a}if(d){j["class"]=d.join(" ")}if(k){for(i in k){if(!k.hasOwnProperty(i)){continue}g=k[i];if(g===null){continue}if(typeof g===SC.T_NUMBER&&!SC.NON_PIXEL_PROPERTIES.contains(i)){g+="px"}b=b+this._dasherizeStyleName(i)+": "+g+"; "}j.style=b}l=l+" ";for(i in j){if(!j.hasOwnProperty(i)){continue}g=j[i];if(g===null){continue}l=l+i+'="'+g+'" '}if(j===this._DEFAULT_ATTRS){delete j.style;delete j["class"];delete j.id}}h=this.strings;f=(this._selfClosing===NO)?NO:(this.length===1);l=l+(f?" />":">");h[this.offset]=l;if(!f){h.push("</"+this._tagName+">");var e=this;while(e){e.length++;e=e.prevObject}}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){if(a){return this.setClass(a)}else{return this.classes()}},classes:function(){if(!this._classes){if(this._elem){var a=this.$().attr("class");if(a&&(a=a.toString()).length>0){this._classes=a.split(/\s/)}else{this._classes=[]}}else{this._classes=[]}}return this._classes},addClass:function(b){if(SC.typeOf(b)===SC.T_ARRAY){for(var a=0,c=b.length,d={};a<c;a++){d[b[a]]=YES}b=d}return this.setClass(b,YES)},removeClass:function(a){return this.setClass(a,NO)},setClass:function(d,e){var g=NO,c=this.classes();if(SC.typeOf(d)===SC.T_ARRAY){this.resetClasses();c=this.classes();for(var b=0,f=d.length;b<f;b++){g=this._setClass(c,d[b],YES)||g}}else{if(SC.typeOf(d)===SC.T_HASH){for(var a in d){if(!d.hasOwnProperty(a)){continue}e=d[a];g=this._setClass(c,a,e)||g}}else{g=this._setClass(c,d,e)}}if(g){this._classesDidChange=YES;if(this._elem){this.$().attr("class",c.join(" "))}}return this},_setClass:function(c,b,d){var e=NO,a;a=c.indexOf(b);if(a>=0&&!d){c.splice(a,1);e=YES}else{if(a<0&&d){c.push(b);e=YES}}return e},hasClass:function(a){if(this._elem){return this.$().hasClass(a)}return this.classes().indexOf(a)>=0},resetClassNames:function(){return this.resetClasses()},resetClasses:function(){var b=NO,a=this.classes();b=a.length;this._classes=[];if(b){this._classesDidChange=YES;if(this._elem){this.$().attr("class","")}}return this},_STYLE_REGEX:/-?\s*([^:\s]+)\s*:\s*([^;]+)\s*;?/g,styles:function(e){if(e){return this.setStyle(e)}if(!this._styles){if(this._elem){var a=this.$().attr("style");if(a&&(a=a.toString()).length>0){if(SC.browser.name===SC.BROWSER.ie){a=a.toLowerCase()}var d={},b,c=this._STYLE_REGEX;c.lastIndex=0;while(b=c.exec(a)){d[this._camelizeStyleName(b[1])]=b[2]}this._styles=d}else{this._styles={}}}else{this._styles={}}}return this._styles},addStyle:function(a,b){return this.setStyle(a,b)},removeStyle:function(a){return this.setStyle(a)},css:function(a,b){return this.setStyle(a,b)},setStyle:function(a,e){var d=NO,c=this.styles();if(SC.typeOf(a)===SC.T_HASH){for(var b in a){d=this._sc_setStyleFromObject(d,b,a,c)}}else{d=this._deleteComboStyles(c,a);d=this._setOnHash(c,a,e)||d}if(d&&this._elem){this.$().css(c)}return this},_sc_setStyleFromObject:function(e,a,d,b){if(!d.hasOwnProperty(a)){return false}var c=d[a];e=this._deleteComboStyles(b,a)||e;e=this._setOnHash(b,a,c)||e;return e},_deleteComboStyles:function(e,d){var g=SC.COMBO_STYLES[d],f=NO,c;if(g){for(var a=0,b=g.length;a<b;a++){c=g[a];if(e[c]){delete e[c];f=YES}}}return f},_setOnHash:function(d,a,c){var e=d[a],b=true;if(e==null&&c!=null){d[a]=c}else{if(e!=null&&c==null){d[a]=""}else{if(e!=c){d[a]=c}else{b=false}}}return b},resetStyles:function(){var c=NO,b=this.styles();for(var a in b){if(!b.hasOwnProperty(a)){continue}c=YES}this._styles={};if(c){if(this._elem){this.$().attr("style","")}}return this},attrs:function(){if(!this._attrs){if(this._elem){var d={},b=this._elem.attributes,f=b.length;for(var e=0,a,c;e<f;e++){a=b.item(e);c=a.nodeName;if(c.match(/^(?!class|style).*$/i)){d[c]=a.value}}this._attrs=d}else{this._attrs={}}}return this._attrs},attr:function(a,b){if(a){if(SC.typeOf(a)===SC.T_HASH||b!==undefined){return this.setAttr(a,b)}else{return this.attrs()[a]}}return this.attrs()},addAttr:function(a,b){return this.setAttr(a,b)},removeAttr:function(a){return this.setAttr(a)},setAttr:function(a,e){var d=NO,b=this.attrs(),c;if(SC.typeOf(a)===SC.T_HASH){for(c in a){if(!a.hasOwnProperty(c)){continue}e=a[c];d=this._setOnHash(b,c,e)||d}}else{d=this._setOnHash(b,a,e)}if(d){this._attrsDidChange=YES;if(this._elem){this.$().attr(a,e)}}return this},$:function(c){var a,b=this._elem;a=!b?SC.$([]):(c===undefined)?SC.$(b):SC.$(c,b);b=null;return a},_camelizeStyleName:function(a){var b=a.match(/^-(webkit|moz|o)-/),c=SC.String.camelize(a);if(b){return c.substr(0,1).toUpperCase()+c.substr(1)}else{return c}},_dasherizeStyleName:function(a){var b=SC.String.dasherize(a);if(b.match(/^(webkit|moz|ms|o)-/)){b="-"+b}return b}});(function(){var b=/[<>]|&(?![\d\w#]{1,7};)/g,a=function(c){switch(c){case"&":return"&amp;";case"<":return"&lt;";case">":return"&gt;"}};SC.RenderContext.escapeHTML=function(c){if(!c){return""}if(SC.typeOf(c)===SC.T_NUMBER){c=c.toString()}return c.replace(b,a)}})();SC.SelectionSet=SC.Object.extend(SC.Enumerable,SC.Freezable,SC.Copyable,{isSelectionSet:YES,length:function(){var a=0,b=this._sets,c=this._objects;if(c){a+=c.get("length")}if(b){b.forEach(function(d){a+=d.get("length")})}return a}.property().cacheable(),sources:function(){var c=[],d=this._sets,b=d?d.length:0,a,f,e;for(a=0;a<b;a++){f=d[a];if(f&&f.get("length")>0&&f.source){c.push(f.source)}}return c}.property().cacheable(),indexSetForSource:function(e){if(!e||!e.isSCArray){return null}var b=this._indexSetCache,d=this._objects,c,a;if(!b){b=this._indexSetCache={}}c=b[SC.guidFor(e)];if(c&&c._sourceRevision&&(c._sourceRevision!==e.propertyRevision)){c=null}if(!c){c=this._indexSetForSource(e,NO);if(c&&c.get("length")===0){c=null}if(d){if(c){c=c.copy()}d.forEach(function(f){if((a=e.indexOf(f))>=0){if(!c){c=SC.IndexSet.create()}c.add(a)}},this)}if(c){c=b[SC.guidFor(e)]=c.frozenCopy();c._sourceRevision=e.propertyRevision}}return c},_indexSetForSource:function(f,g){if(g===undefined){g=YES}var d=SC.guidFor(f),c=this[d],e=this._sets,a=e?e.length:0,b=null;if(c>=a){c=null}if(SC.none(c)){if(g&&!this.isFrozen){this.propertyWillChange("sources");if(!e){e=this._sets=[]}b=e[a]=SC.IndexSet.create();b.source=f;this[d]=a;this.propertyDidChange("sources")}}else{b=e?e[c]:null}return b},add:function(a,b,d){if(this.isFrozen){throw new Error(SC.FROZEN_ERROR)}var g,f,j,i,c,e,h,k;if(b===undefined&&d===undefined){if(!a){throw new Error("Must pass params to SC.SelectionSet.add()")}if(a.isIndexSet){return this.add(a.source,a)}if(a.isSelectionSet){g=a._sets;k=a._objects;f=g?g.length:0;this.beginPropertyChanges();for(j=0;j<f;j++){i=g[j];if(i&&i.get("length")>0){this.add(i.source,i)}}if(k){this.addObjects(k)}this.endPropertyChanges();return this}}i=this._indexSetForSource(a,YES);c=this.get("length");h=i.get("length");e=c-h;i.add(b,d);this._indexSetCache=null;e+=i.get("length");if(e!==c){this.propertyDidChange("length");this.enumerableContentDidChange();if(h===0){this.notifyPropertyChange("sources")}}return this},remove:function(a,c,d){if(this.isFrozen){throw new Error(SC.FROZEN_ERROR)}var j,h,m,f,l,b,g,k,n,e;if(c===undefined&&d===undefined){if(!a){throw new Error("Must pass params to SC.SelectionSet.remove()")}if(a.isIndexSet){return this.remove(a.source,a)}if(a.isSelectionSet){j=a._sets;n=a._objects;h=j?j.length:0;this.beginPropertyChanges();for(m=0;m<h;m++){l=j[m];if(l&&l.get("length")>0){this.remove(l.source,l)}}if(n){this.removeObjects(n)}this.endPropertyChanges();return this}}l=this._indexSetForSource(a,YES);b=this.get("length");g=b-l.get("length");if(l&&(n=this._objects)){if(d!==undefined){c=SC.IndexSet.create(c,d);d=undefined}for(f=n.get("length")-1;f>=0;--f){e=n[f];m=a.indexOf(e);if(c.contains(m)){n.remove(e);g--}}}l.remove(c,d);k=l.get("length");g+=k;this._indexSetCache=null;if(g!==b){this.propertyDidChange("length");this.enumerableContentDidChange();if(k===0){this.notifyPropertyChange("sources")}}return this},contains:function(b,d,a){if(d===undefined&&a===undefined){return this.containsObject(b)}var c=this.indexSetForSource(b);if(!c){return NO}return c.contains(d,a)},intersects:function(b,d,a){var c=this.indexSetForSource(b,NO);if(!c){return NO}return c.intersects(d,a)},_TMP_ARY:[],addObject:function(b){var c=this._TMP_ARY,a;c[0]=b;a=this.addObjects(c);c.length=0;return a},addObjects:function(a){var d=this._objects,b,c;if(!d){d=this._objects=SC.CoreSet.create()}b=d.get("length");d.addEach(a);c=d.get("length");this._indexSetCache=null;if(c!==b){this.propertyDidChange("length");this.enumerableContentDidChange()}return this},removeObject:function(b){var c=this._TMP_ARY,a;c[0]=b;a=this.removeObjects(c);c.length=0;return a},removeObjects:function(b){var e=this._objects,c,d,a;if(!e){return this}c=e.get("length");e.removeEach(b);d=e.get("length");if(a=this._sets){a.forEach(function(f){c+=f.get("length");f.removeObjects(b);d+=f.get("length")},this)}this._indexSetCache=null;if(d!==c){this.propertyDidChange("length");this.enumerableContentDidChange()}return this},containsObject:function(c){var e=this._objects;if(e&&e.contains(c)){return YES}var d=this._sets,b=d?d.length:0,a,f;for(a=0;a<b;a++){f=d[a];if(f&&f.indexOf(c)>=0){return YES}}return NO},constrain:function(e){var g,b,a,d;this.beginPropertyChanges();this.get("sources").forEach(function(h){if(h===e){return}var i=this._indexSetForSource(e,NO);if(i){this.remove(e,i)}},this);g=this._indexSetForSource(e,NO);if(g&&((a=g.get("max"))>(b=e.get("length")))){this.remove(e,b,a-b)}if(d=this._objects){var c,f;for(c=d.length-1;c>=0;c--){f=d[c];if(e.indexOf(f)<0){this.removeObject(f)}}}this.endPropertyChanges();return this},isEqual:function(g){var f,d,b,a,c,e;if(!g||!g.isSelectionSet){return NO}if(g===this){return YES}if((this._sets===g._sets)&&(this._objects===g._objects)){return YES}if(this.get("length")!==g.get("length")){return NO}f=this._objects;d=g._objects;if(f||d){if((f?f.get("length"):0)!==(d?d.get("length"):0)){return NO}if(f&&!f.isEqual(d)){return NO}}c=this.get("sources");a=c.get("length");for(b=0;b<a;b++){e=c.objectAt(b);f=this._indexSetForSource(e,NO);d=this._indexSetForSource(e,NO);if(!!d!==!!f){return NO}if(f&&!f.isEqual(d)){return NO}}return YES},clear:function(){if(this.isFrozen){throw new Error(SC.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,b=d?d.length:0,a,e;if(d&&b>0){d=c._sets=d.slice();for(a=0;a<b;a++){if(!(e=d[a])){continue}e=d[a]=e.copy();c[SC.guidFor(e.source)]=a}}if(this._objects){c._objects=this._objects.copy()}return c},freeze:function(){if(this.get("isFrozen")){return this}var a=this._sets,b=a?a.length:0,c;while(--b>=0){c=a[b];if(c){c.freeze()}}if(this._objects){this._objects.freeze()}this.set("isFrozen",YES);return this},toString:function(){var a=this._sets||[];a=a.map(function(b){return b.toString().replace("SC.IndexSet",SC.guidFor(b.source))},this);if(this._objects){a.push(this._objects.toString())}return"SC.SelectionSet:%@<%@>".fmt(SC.guidFor(this),a.join(","))},firstObject:function(){var b=this._sets,c=this._objects;if(b&&b.get("length")>0){var e=b?b[0]:null,d=e?e.source:null,a=e?e.firstObject():-1;if(d&&a>=0){return d.objectAt(a)}}return c?c.firstObject():undefined}.property(),nextObject:function(c,e,b){var d,a;if(c===0){d=b.objects=[];this.forEach(function(f){d.push(f)},this);b.max=d.length}d=b.objects;a=d[c];if(c+1>=b.max){b.objects=b.max=null}return a},forEach:function(g,e){var c=this._sets,d=this._objects,b=c?c.length:0,f,a;for(a=0;a<b;a++){f=c[a];if(f){f.forEachObject(g,e)}}if(d){d.forEach(g,e)}return this}});SC.SelectionSet.prototype.clone=SC.SelectionSet.prototype.copy;SC.SelectionSet.EMPTY=SC.SelectionSet.create().freeze();sc_require("mixins/delegate_support");SC.SparseArray=SC.Object.extend(SC.Observable,SC.Enumerable,SC.Array,SC.DelegateSupport,{_requestingLength:0,_requestingIndex:0,length:function(){var a=this.delegate;if(a&&SC.none(this._length)&&a.sparseArrayDidRequestLength){this._requestingLength++;a.sparseArrayDidRequestLength(this);this._requestingLength--}return this._length||0}.property().cacheable(),provideLength:function(b){var a;if(SC.none(b)){this._sa_content=null}if(b!==this._length){a=this._length;this._length=b;if(this._requestingLength<=0){this.arrayContentDidChange(0,a||0,b||0)}}return this},rangeWindowSize:1,requestedRangeIndex:null,init:function(){arguments.callee.base.apply(this,arguments);this.requestedRangeIndex=[];this._TMP_PROVIDE_ARRAY=[];this._TMP_PROVIDE_RANGE={length:1};this._TMP_RANGE={}},objectAt:function(a,d){var c=this._sa_content,b;if(a>=this.get("length")){return undefined}if(!c){c=this._sa_content=[]}if((b=c[a])===undefined){if(!d){this.requestIndex(a)}b=c[a]}return b},definedIndexes:function(d){var c=SC.IndexSet.create(),e=this._sa_content,b,a;if(!e){return c.freeze()}if(d){d.forEach(function(f){if(e[f]!==undefined){c.add(f)}})}else{a=e.length;for(b=0;b<a;b++){if(e[b]!==undefined){c.add(b)}}}return c.freeze()},_TMP_RANGE:{},requestIndex:function(b){var c=this.delegate;if(!c){return this}var a=this.get("rangeWindowSize"),e=b;if(a>1){e=e-Math.floor(e%a)}if(a<1){a=1}this._requestingIndex++;if(c.sparseArrayDidRequestRange){var d=this._TMP_RANGE;if(this.wasRangeRequested(e)===-1){d.start=e;d.length=a;this.requestedRangeIndex.push(e);c.sparseArrayDidRequestRange(this,d)}}else{if(c.sparseArrayDidRequestIndex){while(--a>=0){c.sparseArrayDidRequestIndex(this,e+a)}}}this._requestingIndex--;return this},wasRangeRequested:function(c){var b,a;for(b=0,a=this.requestedRangeIndex.length;b<a;b++){if(this.requestedRangeIndex[b]===c){return b}}return -1},rangeRequestCompleted:function(b){var a=this.wasRangeRequested(b);if(a>=0){this.requestedRangeIndex.removeAt(a,1);return YES}return NO},provideObjectsInRange:function(b,e){var c=this._sa_content;if(!c){c=this._sa_content=[]}var d=b.start,a=b.length;while(--a>=0){c[d+a]=e.objectAt(a)}if(this._requestingIndex<=0){this.arrayContentDidChange(b.start,b.length,b.length)}return this},provideObjectAtIndex:function(c,b){var d=this._TMP_PROVIDE_ARRAY,a=this._TMP_PROVIDE_RANGE;d[0]=b;a.start=c;return this.provideObjectsInRange(a,d)},objectsDidChangeInRange:function(a){var b=this._sa_content;if(b){if(a.start===0&&SC.maxRange(a)>=b.length){this._sa_content=null}else{var d=a.start,c=Math.min(d+a.length,b.length);while(--c>=d){b[c]=undefined}}}this.arrayContentDidChange(a.start,a.length,a.length);return this},indexOf:function(d){var e,b,a=this.delegate;if(a&&a.sparseArrayDidRequestIndexOf){b=a.sparseArrayDidRequestIndexOf(this,d)}if(SC.none(b)){e=this._sa_content;if(!e){e=this._sa_content=[]}b=e.indexOf(d)}return b},replace:function(b,g,e){e=e||[];var c=this.delegate;if(c){if(!c.sparseArrayShouldReplace||!c.sparseArrayShouldReplace(this,b,g,e)){return this}}var d=this._sa_content;if(!d){d=this._sa_content=[]}d.replace(b,g,e);var a=e?(e.get?e.get("length"):e.length):0;var f=a-g;this.arrayContentWillChange(b,g,a);if(!SC.none(this._length)){this.propertyWillChange("length");this._length+=f;this.propertyDidChange("length")}this.arrayContentDidChange(b,g,a);return this},reset:function(){var a;this._sa_content=null;a=this._length;this._length=null;this.arrayContentDidChange(0,a,0);this.invokeDelegateMethod(this.delegate,"sparseArrayDidReset",this);return this}});SC.SparseArray.array=function(a){return this.create({_length:a||0})};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 e=this.get("startTime");if(!e||e===0){return -1}var a=this.get("interval"),c=this.get("lastFireTime");if(c<e){c=e}var b;if(this.get("repeats")){if(a===0){b=c}else{b=e+(Math.floor((c-e)/a)+1)*a}}else{b=e+a}var d=this.get("until");if(d&&d>0&&b>d){b=d}return b}.property("interval","startTime","repeats","until","isValid","lastFireTime").cacheable(),schedule:function(){if(!this.get("isValid")){return this}this.beginPropertyChanges();if(!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);var a=SC.RunLoop.currentRunLoop;if(a){a.cancelTimer(this)}this.action=this.target=null;this.endPropertyChanges();if(this.get("isPooled")){SC.Timer.returnTimerToPool(this)}return this},fire:function(){var b=Date.now();this.set("lastFireTime",b);var a=this.get("fireTime");if(!this.get("isPaused")){this.performAction()}if(a>b){this.schedule()}else{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 e=this.action.split(".");var c=e.pop();var d=SC.objectForPropertyPath(e,window);var b=d.get?d.get(c):d[c];if(b&&SC.typeOf(b)==SC.T_FUNCTION){b.call(d,this)}else{throw new Error("%@: 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(b){if(!b){b=SC.EMPTY_HASH}this.propertyWillChange("fireTime");var c=this.RESET_DEFAULTS;for(var a in c){if(!c.hasOwnProperty(a)){continue}this[a]=SC.none(b[a])?c[a]:b[a]}this.propertyDidChange("fireTime");return this},removeFromTimerQueue:function(c){var b=this._timerQueuePrevious,a=this._timerQueueNext;if(!b&&!a&&c!==this){return c}if(b){b._timerQueueNext=a}if(a){a._timerQueuePrevious=b}this._timerQueuePrevious=this._timerQueueNext=null;return(c===this)?a:c},scheduleInTimerQueue:function(c,b){this._timerQueueRunTime=b;var a=c;var d=null;while(a&&a._timerQueueRunTime<b){d=a;a=a._timerQueueNext}if(d){d._timerQueueNext=this;this._timerQueuePrevious=d}if(a){a._timerQueuePrevious=this;this._timerQueueNext=a}return(a===c)?this:c},collectExpiredTimers:function(c,a){if(this._timerQueueRunTime>a){return this}c.push(this);var b=this._timerQueueNext;this._timerQueueNext=null;if(b){b._timerQueuePrevious=null}return b?b.collectExpiredTimers(c,a):null}});SC.Timer.schedule=function(a){var b;if(!a||SC.none(a.isPooled)||a.isPooled){b=this.timerFromPool(a)}else{b=this.create(a)}return b.schedule()};SC.Timer.timerFromPool=function(a){var b=this._timerPool;if(!b){b=this._timerPool=[]}var c=b.pop();if(!c){c=this.create()}return c.reset(a)};SC.Timer.returnTimerToPool=function(a){if(!this._timerPool){this._timerPool=[]}this._timerPool.push(a);return this};sc_require("system/browser");SC.mixin({normalizeURL:function(a){if(a.slice(0,1)=="/"){a=window.location.protocol+"//"+window.location.host+a}else{if((a.slice(0,5)=="http:")||(a.slice(0,6)=="https:")){}else{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(b,a){return(a.width-b.width)/2},centerY:function(b,a){return(a.height-b.height)/2},offset:function(d,c){var f,b,h,a;c=c||"document";if(c==="parent"){a=jQuery(d).position()}else{a=jQuery(d).offset();if(SC.browser.isMobileSafari){f=navigator.userAgent;b=f.indexOf("Mobile/");h=f.substring(b+7,b+9);if(parseInt(SC.browser.mobileSafari,0)<=532||(h<="8A")){a.left-=window.pageXOffset;a.top-=window.pageYOffset}}if(c==="viewport"){if(SC.browser.isIE8OrLower){a.left-=$(window).scrollLeft();a.top-=$(window).scrollTop()}else{a.left-=window.pageXOffset;a.top-=window.pageYOffset}}}try{a.x=a.left;a.y=a.top}catch(g){a={x:a.left,y:a.top}}delete a.left;delete a.top;return a},viewportOffset:function(b){var a=SC.offset(b,"viewport");return{x:a.left,y:a.top}}});SC.mixin({ZERO_POINT:{x:0,y:0},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(b,a,c){if(!b||!a){return(b==a)}if(!c&&c!==0){c=0.1}if((b.y!=a.y)&&(Math.abs(b.y-a.y)>c)){return NO}if((b.x!=a.x)&&(Math.abs(b.x-a.x)>c)){return NO}if((b.width!=a.width)&&(Math.abs(b.width-a.width)>c)){return NO}if((b.height!=a.height)&&(Math.abs(b.height-a.height)>c)){return NO}return YES},intersectRects:function(b,a){var c={x:Math.max(SC.minX(b),SC.minX(a)),y:Math.max(SC.minY(b),SC.minY(a)),width:Math.min(SC.maxX(b),SC.maxX(a)),height:Math.min(SC.maxY(b),SC.maxY(a))};c.width=Math.max(0,c.width-c.x);c.height=Math.max(0,c.height-c.y);return c},unionRects:function(b,a){var c={x:Math.min(SC.minX(b),SC.minX(a)),y:Math.min(SC.minY(b),SC.minY(a)),width:Math.max(SC.maxX(b),SC.maxX(a)),height:Math.max(SC.maxY(b),SC.maxY(a))};c.width=Math.max(0,c.width-c.x);c.height=Math.max(0,c.height-c.y);return c},scaleRect:function(h,a,l,k){if(a==null){a=1}if(l==null){l=0.5}if(k==null){k=0.5}if(a===1){return SC.cloneRect(h)}var j,i;switch(SC.typeOf(a)){case SC.T_ARRAY:j=a[0];i=a[1];break;case SC.T_HASH:j=a.x;i=a.y;break;default:j=a;i=a;break}var g=h.height*i,e=h.width*j,c=g-h.height,f=e-h.width;var d=h.x-(f*l),b=h.y-(c*k);return{height:g,width:e,x:d,y:b}},cloneRect:function(a){return{x:a.x,y:a.y,width:a.width,height:a.height}},stringFromRect:function(a){if(!a){return"(null)"}else{return"{ x:"+a.x+", y:"+a.y+", width:"+a.width+", height:"+a.height+" }"}}});sc_require("views/view");SC.DESIGN_MODE_CLASS_NAMES={s:"sc-small",m:"sc-medium",l:"sc-large",xl:"sc-xlarge"};SC.View.reopen({designMode:null,modeAdjust:null,adjustChildDesignModes:function(b,d){var e=this.get("childViews");var c,a=e.get("length");for(c=0;c<a;c++){var f=e.objectAt(c);f.updateDesignMode(b,d)}},_sc_assignProperty:function(c,e){if(c==="layout"){var b=this._sc_computeExplicitLayout(e),f={},g=this.get("explicitLayout");for(var a in b){var d=g[a];f[a]=d===undefined?null:d;if(a==="centerX"){f.left=g.left;f.right=g.right}if(a==="centerY"){f.top=g.top;f.bottom=g.bottom}}this._originalProperties.layout=f}else{this._originalProperties[c]=this.get(c)}if(c==="layout"){this.adjust(e)}else{this.set(c,e)}},_sc_revertProperty:function(b,a){if(b==="layout"){this.adjust(a)}else{this.set(b,a)}},updateDesignMode:function(c,h){if(c===h){return}var a=this.get("classNames"),g,d,i,f,e,b,k;this.set("designMode",h);if(h){k=h.split("_")[0]}g=this.get("modeAdjust");if(g){this.beginPropertyChanges();b=this._originalProperties;if(b){for(i in b){this._sc_revertProperty(i,b[i])}this._originalProperties=null}if(h){if(g[k]||g[h]){e=SC.merge(g[k],g[h]);this._originalProperties={};for(i in e){this._sc_assignProperty(i,e[i])}}}this.endPropertyChanges()}var j;f=this.get("layer");if(f){d=this.$();if(c){j=SC.DESIGN_MODE_CLASS_NAMES[c.split("_")[0]];d.removeClass(j);a.removeObject(j)}if(h){j=SC.DESIGN_MODE_CLASS_NAMES[k];d.addClass(j);a.push(j)}}else{if(h){j=SC.DESIGN_MODE_CLASS_NAMES[k];a.push(j)}}this.adjustChildDesignModes(c,h)}});sc_require("panes/pane");sc_require("panes/keyboard");sc_require("panes/layout");sc_require("panes/manipulation");sc_require("panes/pane_statechart");SC.MainPane=SC.Pane.extend({layout:{minHeight:200,minWidth:200},didAppendToDocument:function(){var a=this.rootResponder;a.makeMainPane(this);this.becomeKeyPane();this.setBodyOverflowIfNeeded()},willRemoveFromDocument:function(){var a=this.rootResponder;this.unsetBodyOverflowIfNeeded();a.makeMainPane(null);this.resignKeyPane()},_updatedLayout:function(){arguments.callee.base.apply(this,arguments);this.setBodyOverflowIfNeeded()},acceptsKeyPane:YES,classNames:["sc-main"]});SC.routes=SC.Object.create({wantsHistory:NO,usesHistory:null,baseURI:document.baseURI,_didSetup:NO,_location:null,_firstRoute:null,_extractParametersAndRoute:function(d,b){var a={},j=d.route||"",f,c,e,h,g,k;f=(j.indexOf("?")<0&&j.indexOf("&")>=0)?"&":"?";c=j.split(f);j=c.shift();a=this.deparam(c.join("&"),b||false);for(k in d){if(d.hasOwnProperty(k)&&k!=="route"){a[k]=""+d[k]}}a.params=f+$.param(a);a.route=j;return a},location:function(a,b){var c;this._skipRoute=NO;if(b!==undefined){c=this.informLocation.lastSetValueKey;if(c&&this._kvo_cache){this._kvo_cache[c]=b}}return this._extractLocation(a,b)}.property(),informLocation:function(a,b){var c;this._skipRoute=YES;if(b!==undefined){c=this.location.lastSetValueKey;if(c&&this._kvo_cache){this._kvo_cache[c]=b}}return this._extractLocation(a,b)}.property(),_extractLocation:function(c,d){var a,b;if(d!==undefined){if(d===null){d=""}if(typeof(d)==="object"){a=this._extractParametersAndRoute(d);d=a.route+a.params}if(!this._exogenous){if(!SC.empty(d)||(this._location&&this._location!==d)){b=encodeURI(d);if(this.usesHistory){if(b.length>0){b="/"+b}window.history.pushState(null,null,this.get("baseURI")+b)}else{window.location.hash=b}}}this._location=d}return this._location},ping:function(){var a;if(!this._didSetup){this._didSetup=YES;if(this.get("wantsHistory")&&SC.platform.supportsHistory){this.usesHistory=YES;this.popState();SC.Event.add(window,"popstate",this,this.popState)}else{this.usesHistory=NO;if(SC.platform.supportsHashChange){this.hashChange();SC.Event.add(window,"hashchange",this,this.hashChange)}else{a=this;this._invokeHashChange=function(){a.hashChange();setTimeout(a._invokeHashChange,100)};this._invokeHashChange()}}}},hashChange:function(a){this._exogenous=YES;var b=window.location.hash;b=(b&&b.length>0)?b.slice(1,b.length):"";if(!SC.browser.isMozilla){b=decodeURI(b)}if(this.get("location")!==b&&!this._skipRoute){SC.run(function(){this.set("location",b)},this)}this._skipRoute=NO;this._exogenous=NO},popState:function(a){this._exogenous=YES;var b=this.get("baseURI"),c=document.location.href;if(c.slice(0,b.length)===b){c=c.slice(b.length+1,c.length);if(this.get("location")!==c&&!this._skipRoute){SC.run(function(){this.set("location",c)},this)}}this._skipRoute=NO;this._exogenous=NO},add:function(a,b,c){if(!this._didSetup){this.invokeNext(this.ping)}if(c===undefined&&SC.typeOf(b)===SC.T_FUNCTION){c=b;b=null}else{if(SC.typeOf(c)===SC.T_STRING){c=b[c]}}if(!this._firstRoute){this._firstRoute=this._Route.create()}this._firstRoute.add(a.split("/"),b,c);return this},locationDidChange:function(){this.trigger()}.observes("location"),trigger:function(){var a=this._firstRoute,b=this.get("location"),d,c;if(a){d=this._extractParametersAndRoute({route:b});b=d.route;delete d.route;delete d.params;c=a.routeForParts(b.split("/"),d);if(c&&c.method){c.method.call(c.target||this,d)}}},deparam:function(k,g){var j={},b={"true":!0,"false":!1,"null":null},f,l,n,d,p,c,o,h,q,m,e=decodeURIComponent,a=Object.prototype.toString;if(k.indexOf("?")>=0){k=k.split("?")[1];if(k.indexOf("#")>=0){k=k.split("#")[0]}}else{if(k.indexOf("#")>=0){k=k.split("#")[1]}}f=k.replace(/\+/g," ").split("&");l=f.length;for(n=0;n<l;++n){d=f[n].split("="),p=e(d[0]),o=j,q=p.split("]["),m=p.length-1;if(/\[/.test(q[0])&&/\]$/.test(q[m])){q[m]=q[m].replace(/\]$/,"");q=q.shift().split("[").concat(q);m=q.length-1}else{m=0}if(d.length===2){c=e(d[1]);if(g){c=c&&!isNaN(c)?+c:c==="undefined"?undefined:b[c]!==undefined?b[c]:c}if(m){for(h=0;h<m;++h){p=q[h]===""?o.length:q[h];o=o[p]=h<m?o[p]||(q[h+1]&&isNaN(q[h+1])?{}:[]):c}}else{if(a.apply(j[p])==="[object Array]"){j[p].push(c)}else{if(j[p]!==undefined){j[p]=[j[p],c]}else{j[p]=c}}}}else{if(p){j[p]=g?undefined:""}}}return j},_Route:SC.Object.extend({target:null,method:null,staticRoutes:null,dynamicRoutes:null,wildcardRoutes:null,add:function(c,b,e){var a,d;c=SC.clone(c);if(!c||c.length===0){this.target=b;this.method=e}else{a=c.shift();switch(a.slice(0,1)){case":":a=a.slice(1,a.length);if(!this.dynamicRoutes){this.dynamicRoutes={}}if(!this.dynamicRoutes[a]){this.dynamicRoutes[a]=this.constructor.create()}d=this.dynamicRoutes[a];break;case"*":a=a.slice(1,a.length);if(!this.wildcardRoutes){this.wildcardRoutes={}}d=this.wildcardRoutes[a]=this.constructor.create();break;default:if(!this.staticRoutes){this.staticRoutes={}}if(!this.staticRoutes[a]){this.staticRoutes[a]=this.constructor.create()}d=this.staticRoutes[a]}if(d){d.add(c,b,e)}}},routeForParts:function(d,e){var b,c,a;d=SC.clone(d);if(!d||d.length===0){return this.method?this:null}else{b=d.shift();if(this.staticRoutes&&this.staticRoutes[b]){return this.staticRoutes[b].routeForParts(d,e)}else{for(c in this.dynamicRoutes){a=this.dynamicRoutes[c].routeForParts(d,e);if(a){e[c]=b;return a}}for(c in this.wildcardRoutes){d.unshift(b);e[c]=d.join("/");return this.wildcardRoutes[c].routeForParts(null,e)}return null}}}})});SC.SCANNER_OUT_OF_BOUNDS_ERROR=SC.$error("Out of bounds.");SC.SCANNER_INT_ERROR=SC.$error("Not an int.");SC.SCANNER_SKIP_ERROR=SC.$error("Did not find the string to skip.");SC.SCANNER_SCAN_ARRAY_ERROR=SC.$error("Did not find any string of the given array to scan.");SC.DATETIME_COMPAREDATE_TIMEZONE_ERROR=SC.$error("Can't compare the dates of two DateTimes that don't have the same timezone.");SC.DATETIME_ISO8601="%Y-%m-%dT%H:%M:%S%Z";SC.Scanner=SC.Object.extend({string:null,scanLocation:0,scan:function(a){if(this.scanLocation+a>this.length){SC.SCANNER_OUT_OF_BOUNDS_ERROR.throw()}var b=this.string.substr(this.scanLocation,a);this.scanLocation+=a;return b},scanInt:function(c,e){if(e===undefined){e=c}var d=this.scan(e);var b=new RegExp("^\\d{"+c+","+e+"}");var a=d.match(b);if(!a){SC.SCANNER_INT_ERROR.throw()}if(a[0].length<e){this.scanLocation+=a[0].length-e}return parseInt(a[0],10)},skipString:function(a){if(this.scan(a.length)!==a){SC.SCANNER_SKIP_ERROR.throw()}return YES},scanArray:function(c){for(var b=0,a=c.length;b<a;b++){if(this.scan(c[b].length)===c[b]){return b}this.scanLocation-=c[b].length}SC.SCANNER_SCAN_ARRAY_ERROR.throw()}});SC.DateTime=SC.Object.extend(SC.Freezable,SC.Copyable,{_ms:0,timezone:0,isFrozen:YES,adjust:function(b,a){var c;b=b?SC.clone(b):{};c=(b.timezone!==undefined)?b.timezone:(this.timezone!==undefined)?this.timezone:0;return this.constructor._adjust(b,this._ms,c,a)._createFromCurrentState()},advance:function(a){return this.constructor._advance(a,this._ms,this.timezone)._createFromCurrentState()},unknownProperty:function(a){return this.constructor._get(a,this._ms,this.timezone)},toFormattedString:function(a){return this.constructor._toFormattedString(a,this._ms,this.timezone)},toISO8601:function(){return this.constructor._toFormattedString(SC.DATETIME_ISO8601,this._ms,this.timezone)},dayOrdinal:function(){return this.get("day").ordinal()}.property(),toString:function(){return"UTC: "+new Date(this._ms).toUTCString()+", timezone: "+this.timezone},isEqual:function(a){return this.constructor.compare(this,a)===0},copy:function(){return this},toTimezone:function(a){if(a===undefined){a=0}return this.advance({timezone:a-this.timezone})}});SC.DateTime.mixin(SC.Comparable,{recordFormat:SC.DATETIME_ISO8601,dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],_englishDayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],abbreviatedDayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],abbreviatedMonthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],AMPMNames:["AM","PM"],_date:new Date(),_tz:0,timezone:new Date().getTimezoneOffset(),_dt_cache:{},_dt_cache_index:-1,_DT_CACHE_MAX_LENGTH:1000,_setCalcState:function(a,c){var b={milliseconds:this._date.getTime(),timezone:this._tz};if(a!==undefined){this._date.setTime(a)}if(c!==undefined){this._tz=c}return b},_setCalcStateFromHash:function(c,b){var d=(b!==undefined)?b:this._tz;var a=this._toMilliseconds(c,this._ms,d);return this._setCalcState(a,d)},_get:function(t,b,n){var l,h,o,e,j,k,f,p,a;var c,i;var r=this._date;var q,g=null;q=this._setCalcState(b,n);if(t==="milliseconds"){g=r.getTime()}else{if(t==="timezone"){g=this._tz}}if(g===null){p=t.slice(0,4);a=t.slice(4);if(p==="last"||p==="next"){c=this._get("dayOfWeek",b,n);i=this._englishDayNames.indexOf(a);if(i>=0){var s=i-c;if(p==="last"&&s>=0){s-=7}if(p==="next"&&s<0){s+=7}this._advance({day:s},b,n);g=this._createFromCurrentState()}}}if(g===null){if(n!==undefined){this._setCalcState(r.getTime()-(n*60000),0)}switch(t){case"year":g=r.getUTCFullYear();break;case"month":g=r.getUTCMonth()+1;break;case"day":g=r.getUTCDate();break;case"dayOfWeek":g=r.getUTCDay();break;case"hour":g=r.getUTCHours();break;case"minute":g=r.getUTCMinutes();break;case"second":g=r.getUTCSeconds();break;case"millisecond":g=r.getUTCMilliseconds();break;case"elapsed":g=+new Date()-r.getTime()-(n*60000);break}if((g===null)&&(t==="isLeapYear")){e=this._get("year");g=(e%4===0&&e%100!==0)||e%400===0}if((g===null)&&(t==="daysInMonth")){switch(this._get("month")){case 4:case 6:case 9:case 11:g=30;break;case 2:g=this._get("isLeapYear")?29:28;break;default:g=31;break}}if((g===null)&&(t==="dayOfYear")){l=r.getTime();h=this._get("day");this._setCalcStateFromHash({day:1});for(o=this._get("month")-1;o>0;o--){this._setCalcStateFromHash({month:o});h+=this._get("daysInMonth")}r.setTime(l);g=h}if((g===null)&&(t.slice(0,4)==="week")){j=t.length===4?1:parseInt(t.slice("4"),10);k=this._get("dayOfWeek");f=this._get("dayOfYear")-1;if(j===0){g=parseInt((f-k+7)/7,10)}else{g=parseInt((f-(k-1+7)%7+7)/7,10)}}}this._setCalcState(q.milliseconds,q.timezone);return g},_adjust:function(c,e,d,a){var b=this._toMilliseconds(c,e,d,a);this._setCalcState(b,d);return this},_advance:function(a,f,d){var c=a?SC.clone(a):{};var e;for(var b in c){c[b]+=this._get(b,f,d)}e=(c.timezone!==undefined)?c.timezone:d;return this._adjust(c,f,e,NO)},_toMilliseconds:function(j,c,h,f){var a=j?SC.clone(j):{};var i=this._date;var g=i.getTime();var b,e;if(!SC.none(c)){i.setTime(c)}e=(h!==undefined)?h:(this.timezone!==undefined)?this.timezone:0;i.setTime(i.getTime()-(e*60000));if(f===undefined||f===YES){if(!SC.none(a.hour)&&SC.none(a.minute)){a.minute=0}if(!(SC.none(a.hour)&&SC.none(a.minute))&&SC.none(a.second)){a.second=0}if(!(SC.none(a.hour)&&SC.none(a.minute)&&SC.none(a.second))&&SC.none(a.millisecond)){a.millisecond=0}}if(SC.none(a.year)){a.year=i.getUTCFullYear()}if(SC.none(a.month)){a.month=i.getUTCMonth()+1}if(SC.none(a.day)){a.day=i.getUTCDate()}if(SC.none(a.hour)){a.hour=i.getUTCHours()}if(SC.none(a.minute)){a.minute=i.getUTCMinutes()}if(SC.none(a.second)){a.second=i.getUTCSeconds()}if(SC.none(a.millisecond)){a.millisecond=i.getUTCMilliseconds()}b=Date.UTC(a.year,a.month-1,a.day,a.hour,a.minute,a.second,a.millisecond);i.setTime(b+(e*60000));b=i.getTime();i.setTime(g);return b},create:function(){var i=arguments.length===0?{}:arguments[0];var d;if(SC.typeOf(i)===SC.T_NUMBER){i={milliseconds:i}}d=(i.timezone!==undefined)?i.timezone:this.timezone;if(d===undefined){d=0}if(!SC.none(i.milliseconds)){var h="nu"+i.milliseconds+d,a=this._dt_cache;var e=a[h];if(!e){var f,g=this._dt_cache_index,b=this;e=a[h]=new b([{_ms:i.milliseconds,timezone:d}]);g=this._dt_cache_index=(g+1)%this._DT_CACHE_MAX_LENGTH;f=a[g];if(f!==undefined&&a[f]){delete a[f]}a[g]=h}return e}else{var c=new Date();return this.create({milliseconds:this._toMilliseconds(i,c.getTime(),d,i.resetCascadingly),timezone:d})}},_createFromCurrentState:function(){return this.create({milliseconds:this._date.getTime(),timezone:this._tz})},parse:function(o,c){var p=new RegExp("(?:%([aAbBcdDhHiIjmMpsSUWwxXyYZ%])|(.))","g");var n,j,a={},b={},i=SC.Scanner.create({string:o});if(SC.none(c)){c=SC.DATETIME_ISO8601}try{while((j=p.exec(c))!==null){switch(j[1]){case"a":b.dayOfWeek=i.scanArray(this.abbreviatedDayNames);break;case"A":b.dayOfWeek=i.scanArray(this.dayNames);break;case"b":a.month=i.scanArray(this.abbreviatedMonthNames)+1;break;case"B":a.month=i.scanArray(this.monthNames)+1;break;case"c":throw new Error("%c is not implemented");case"d":case"D":a.day=i.scanInt(1,2);break;case"e":throw new Error("%e is not implemented");case"E":throw new Error("%E is not implemented");case"h":case"H":a.hour=i.scanInt(1,2);break;case"i":case"I":a.hour=i.scanInt(1,2);break;case"j":throw new Error("%j is not implemented");case"m":a.month=i.scanInt(1,2);break;case"M":a.minute=i.scanInt(1,2);break;case"p":a.meridian=i.scanArray(this.AMPMNames);break;case"S":a.second=i.scanInt(1,2);break;case"s":a.millisecond=i.scanInt(1,3);break;case"U":throw new Error("%U is not implemented");case"W":throw new Error("%W is not implemented");case"w":throw new Error("%w is not implemented");case"x":throw new Error("%x is not implemented");case"X":throw new Error("%X is not implemented");case"y":a.year=i.scanInt(2);a.year+=(a.year>70?1900:2000);break;case"Y":a.year=i.scanInt(4);break;case"Z":var g=i.scan(1);if(g==="Z"){a.timezone=0}else{if(g==="+"||g==="-"){var k=i.scanInt(2);if(i.scan(1)!==":"){i.scan(-1)}var f=i.scanInt(2);a.timezone=(g==="+"?-1:1)*(k*60+f)}}break;case"%":i.skipString("%");break;default:i.skipString(j[0]);break}}}catch(l){SC.Logger.log("SC.DateTime.createFromString "+l.toString());return null}if(!SC.none(a.meridian)&&!SC.none(a.hour)){if((a.meridian===1&&a.hour!==12)||(a.meridian===0&&a.hour===12)){a.hour=(a.hour+12)%24}delete a.meridian}n=this.create(a);if(!SC.none(b.dayOfWeek)&&n.get("dayOfWeek")!==b.dayOfWeek){return null}return n},_pad:function(b,a){var c=""+b;if(a===undefined){a=2}while(c.length<a){c="0"+c}return c},__toFormattedString:function(b,e,c){var a,d;switch(b[1]){case"a":return this.abbreviatedDayNames[this._get("dayOfWeek")];case"A":return this.dayNames[this._get("dayOfWeek")];case"b":return this.abbreviatedMonthNames[this._get("month")-1];case"B":return this.monthNames[this._get("month")-1];case"c":return this._date.toString();case"d":return this._pad(this._get("day"));case"D":return this._get("day");case"E":return this._toFormattedString(this.__getElapsedStringFormat(e,c),e,c);case"h":return this._get("hour");case"H":return this._pad(this._get("hour"));case"i":a=this._get("hour");return(a===12||a===0)?12:(a+12)%12;case"I":a=this._get("hour");return this._pad((a===12||a===0)?12:(a+12)%12);case"j":return this._pad(this._get("dayOfYear"),3);case"m":return this._pad(this._get("month"));case"M":return this._pad(this._get("minute"));case"o":return this._get("day").ordinal();case"p":return this._get("hour")>11?this.AMPMNames[1]:this.AMPMNames[0];case"S":return this._pad(this._get("second"));case"s":return this._pad(this._get("millisecond"),3);case"u":return this._pad(this._get("utc"));case"U":return this._pad(this._get("week0"));case"W":return this._pad(this._get("week1"));case"w":return this._get("dayOfWeek");case"x":return this._date.toDateString();case"X":return this._date.toTimeString();case"y":return this._pad(this._get("year")%100);case"Y":return this._get("year");case"Z":d=-1*c;return(d>=0?"+":"-")+this._pad(parseInt(Math.abs(d)/60,10))+":"+this._pad(Math.abs(d)%60);case"%":return"%"}},_toFormattedString:function(c,d,b){var a=this;this._setCalcState(d-(b*60000),0);return c.replace(/\%([aAbBcdeEDhHiIjmMopsSUWwxXyYZ\%])/g,function(){var e=a.__toFormattedString.call(a,arguments,d,b);return e})},__getElapsedStringFormat:function(b,a){return""},compare:function(d,c){if(SC.none(d)||SC.none(c)){throw new Error("You must pass two valid dates to compare()")}var f=d.get("milliseconds");var e=c.get("milliseconds");return f<e?-1:f===e?0:1},compareDate:function(d,c){if(SC.none(d)||SC.none(c)){throw new Error("You must pass two valid dates to compareDate()")}if(d.get("timezone")!==c.get("timezone")){SC.DATETIME_COMPAREDATE_TIMEZONE_ERROR.throw()}var f=d.adjust({hour:0}).get("milliseconds");var e=c.adjust({hour:0}).get("milliseconds");return f<e?-1:f===e?0:1},difference:function(d,c,h){if(SC.none(d)||SC.none(c)){throw new Error("You must pass two valid dates to difference()")}var j=d.get("milliseconds"),i=c.get("milliseconds"),g=i-j,f;switch(h){case"d":case"D":f=86400000;break;case"h":case"H":f=3600000;break;case"M":f=60000;break;case"S":f=1000;break;case"s":f=1;break;case"W":f=604800000;break;default:throw new Error(h+" is not supported")}var e=g/f;return Math.round(e)}});SC.Binding.dateTime=function(a){return this.transform(function(b){return b?b.toFormattedString(a):null})};SC.stringsFor("fr",{"_SC.DateTime.dayNames":"Dimanche Lundi Mardi Mercredi Jeudi Vendredi Samedi","_SC.DateTime.abbreviatedDayNames":"Dim Lun Mar Mer Jeu Ven Sam","_SC.DateTime.monthNames":"Janvier Février Mars Avril Mai Juin Juillet Août Septembre Octobre Novembre Decembre","_SC.DateTime.abbreviatedMonthNames":"Janv Févr Mars Avr Mai Juin Juil Août Sept Oct Nov Déc","_SC.DateTime.AMPMNames":"AM PM","_SC.DateTime.now":"Maintenant","_SC.DateTime.secondIn":"Dans un instant","_SC.DateTime.secondsIn":"Dans %e secondes","_SC.DateTime.minuteIn":"Dans une minute","_SC.DateTime.minutesIn":"Dans %e minutes","_SC.DateTime.hourIn":"Dans une heure","_SC.DateTime.hoursIn":"Dans environ %e heures","_SC.DateTime.dayIn":"Demain à %H:%M","_SC.DateTime.daysIn":"%A à %H:%M","_SC.DateTime.weekIn":"La semaine prochaine","_SC.DateTime.weeksIn":"Dans %e semaines","_SC.DateTime.monthIn":"Le mois prochain","_SC.DateTime.monthsIn":"Dans %e mois","_SC.DateTime.yearIn":"L'an prochain","_SC.DateTime.yearsIn":"Dans %e ans","_SC.DateTime.secondAgo":"Il y a un instant","_SC.DateTime.secondsAgo":"Il y a %e secondes","_SC.DateTime.minuteAgo":"Il y a une minute","_SC.DateTime.minutesAgo":"Il y a %e minutes","_SC.DateTime.hourAgo":"Il y a une heure","_SC.DateTime.hoursAgo":"Il y a %e heures","_SC.DateTime.dayAgo":"Hier à %H:%M","_SC.DateTime.daysAgo":"%A à %H:%M","_SC.DateTime.weekAgo":"Il y a une semaine","_SC.DateTime.weeksAgo":"Il y a %e semaines","_SC.DateTime.monthAgo":"Il y a un mois","_SC.DateTime.monthsAgo":"Il y a %e mois","_SC.DateTime.yearAgo":"L'an dernier","_SC.DateTime.yearsAgo":"Il y a %e ans"});SC.DateTime.mixin({_setup:function(){SC.DateTime.dayNames=SC.String.w(SC.String.loc("_SC.DateTime.dayNames"));SC.DateTime.abbreviatedDayNames=SC.String.w(SC.String.loc("_SC.DateTime.abbreviatedDayNames"));SC.DateTime.monthNames=SC.String.w(SC.String.loc("_SC.DateTime.monthNames"));SC.DateTime.abbreviatedMonthNames=SC.String.w(SC.String.loc("_SC.DateTime.abbreviatedMonthNames"));SC.DateTime.AMPMNames=SC.String.w(SC.String.loc("_SC.DateTime.AMPMNames"))},__getElapsedStringFormat:function(g,e){var c=Math.floor((+new Date()-this._date.getTime()-(e*60000))/1000);var b=!!(c<0)?"In":"Ago";var d=0;var f="now";if(Math.abs(c)>31536000){d=Math.floor(Math.abs(c/31536000));f="year"}else{if(Math.abs(c)>2678400){d=Math.floor(Math.abs(c/2678400));f="month"}else{if(Math.abs(c)>604800){d=Math.floor(Math.abs(c/604800));f="week"}else{if(Math.abs(c)>86400){d=Math.floor(Math.abs(c/86400));f="day"}else{if(Math.abs(c)>3600){d=Math.floor(Math.abs(c/3600));f="hour"}else{if(Math.abs(c)>60){d=Math.floor(Math.abs(c/60));f="minute"}else{if(Math.abs(c)>0){d=Math.abs(c);f="second"}}}}}}}var a="_SC.DateTime.now";if(f!=="now"){a="_SC.DateTime.%@%@%@".fmt(f,d>1?"s":"",b)}return a.loc().replace("%e",d)}});jQuery(document).ready(function(){SC.DateTime._setup()});SC.WebSocketDelegate={isWebSocketDelegate:true,webSocketDidOpen:function(a,b){},webSocketDidReceiveMessage:function(a,b){switch(b){case"ping":return true;break}if(this.get("isJSON")){try{JSON.parse(b)}catch(c){return true}}},webSocketDidClose:function(a,b){},webSocketDidError:function(a,b){}};SC.Response=SC.Object.extend({isResponse:YES,isError:NO,errorValue:function(){return this}.property().cacheable(),errorObject:null,request:null,originalRequest:function(){var a=this.get("request");while(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,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"),c=a?a.get("source"):null;if(c&&c.willSend){c.willSend(a,this)}a.freeze();if(!this.get("isCancelled")){this.invokeTransport()}var b=a.get("timeout");if(b){var d=SC.Timer.schedule({target:this,action:"timeoutReached",interval:b,repeats:NO});this.set("timeoutTimer",d)}if(!this.get("isCancelled")&&c&&c.didSend){c.didSend(a,this)}},invokeTransport:function(){this.receive(function(a){this.set("status",200)},this)},receive:function(e,a){if(!this.get("timedOut")){var d=this.get("timeoutTimer");if(d){d.invalidate()}this.set("timedOut",NO)}var b=this.get("request");var c=b?b.get("source"):null;SC.run(function(){if(c&&c.willReceive){c.willReceive(b,this)}e.call(a,!this.get("isCancelled"));if(!this.get("isCancelled")&&c&&c.didReceive){c.didReceive(b,this)}if(!this.get("isCancelled")){this.notify()}},this);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();this.receive(function(b){if(!b){return}var a=SC.$error("HTTP Request timed out","Request",0);a.set("errorValue",this);this.set("isError",YES);this.set("errorObject",a);this.set("status",0)},this);return YES}return NO},cancelTransport:function(){},_notifyListeners:function(h,b){var j=h[b],g,f,a;if(!j){return NO}var d=NO;var e=j.length;for(var c=0;c<e;c++){var k=j[c];g=(k.args||[]).copy();g.unshift(this);f=k.target;a=k.action;if(SC.typeOf(a)===SC.T_STRING){a=f[a]}d=a.apply(f,g)}return d},notify:function(){var b=this.get("listeners"),a=this.get("status"),c=Math.floor(a/100)*100,d=NO;if(!b){return this}d=this._notifyListeners(b,a);if(!d&&c!==a){d=this._notifyListeners(b,c)}if(!d&&a!==0){d=this._notifyListeners(b,0)}return this},toString:function(){var a=arguments.callee.base.apply(this,arguments);return"%@<%@ %@, status=%@".fmt(a,this.get("type"),this.get("address"),this.get("status"))}});SC.XHRResponse=SC.Response.extend({headers:function(){var c=this.get("rawRequest"),b=c?c.getAllResponseHeaders():null,a={};if(!b){return a}b.split("\n").forEach(function(g){var d=g.indexOf(":"),e,f;if(d>=0){e=g.slice(0,d);f=g.slice(d+1).trim();a[e]=f}},this);return a}.property("status").cacheable(),header:function(a){var b=this.get("rawRequest");return b?b.getResponseHeader(a):null},encodedBody:function(){var a=this.get("rawRequest");if(!a){return null}if(this.get("isXML")){return a.responseXML}return a.responseText}.property("status").cacheable(),cancelTransport:function(){var a=this.get("rawRequest");if(a){a.abort()}this.set("rawRequest",null)},invokeTransport:function(){var d,n,b,g,h=this.get("request"),e,a,f,c;g=this.createRequest();this.set("rawRequest",g);f=!!h.get("isAsynchronous");if(f){if(SC.platform.get("supportsXHR2ProgressEvent")){n=h.get("listeners");if(n){for(var o in n){if(isNaN(parseInt(o,10))){b=n[o];for(var k=0,l=b.length;k<l;k++){d=b[k];var m=o.split(".");if(SC.none(m[1])){SC.Event.add(g,m[0],d.target,d.action,d.args)}else{SC.Event.add(g[m[0]],m[1],d.target,d.action,d.args)}}}}}if(SC.platform.get("supportsXHR2LoadEndEvent")){SC.Event.add(g,"loadend",this,this.finishRequest)}else{SC.Event.add(g,"load",this,this.finishRequest);SC.Event.add(g,"error",this,this.finishRequest);SC.Event.add(g,"abort",this,this.finishRequest)}}else{if(window.XMLHttpRequest&&g.addEventListener){SC.Event.add(g,"readystatechange",this,this.finishRequest)}else{e=this;a=function(){if(!e){return null}var i=e.finishRequest();if(i){e=null}return i};g.onreadystatechange=a}}}g.open(this.get("type"),this.get("address"),f);c=this.getPath("request.headers");for(var j in c){g.setRequestHeader(j,c[j])}if(!this.getPath("request.isSameDomain")&&this.getPath("request.allowCredentials")){g.withCredentials=true}g.send(this.getPath("request.encodedBody"));if(!f){this.finishRequest()}return g},createRequest:function(){var a;if(window.XMLHttpRequest){a=new XMLHttpRequest()}else{try{a=new ActiveXObject("MSXML2.XMLHTTP.6.0")}catch(b){}try{if(!a){a=new ActiveXObject("MSXML2.XMLHTTP")}}catch(b){}}return a},finishRequest:function(o){var c,l,a,e=this.get("rawRequest"),h=e.readyState,f,m,d,b;if(h===4&&!this.get("timedOut")){this.receive(function(i){if(!i){return}d=-1;try{d=e.status||0;d=d===1223?204:d}catch(q){}if((d<200)||(d>=300)){try{b=e.statusText||""}catch(p){b=""}m=SC.$error(b||"HTTP Request failed","Request",d);m.set("errorValue",this);this.set("isError",YES);this.set("errorObject",m)}this.set("status",d)},this);if(SC.platform.get("supportsXHR2ProgressEvent")){if(SC.platform.get("supportsXHR2LoadEndEvent")){SC.Event.remove(e,"loadend",this,this.finishRequest)}else{SC.Event.remove(e,"load",this,this.finishRequest);SC.Event.remove(e,"error",this,this.finishRequest);SC.Event.remove(e,"abort",this,this.finishRequest)}f=this.get("request");l=f.get("listeners");if(l){for(var n in l){if(isNaN(parseInt(n,10))){a=l[n];for(var g=0,j=a.length;g<j;g++){c=a[g];var k=n.split(".");if(SC.none(k[1])){SC.Event.remove(e,k[0],c.target,c.action,c.args)}else{SC.Event.remove(e[k[0]],k[1],c.target,c.action,c.args)}}}}}}else{if(window.XMLHttpRequest&&e.addEventListener){SC.Event.remove(e,"readystatechange",this,this.finishRequest)}else{e.onreadystatechange=null}}return YES}return NO}});sc_require("system/response");SC.Request=SC.Object.extend(SC.Copyable,SC.Freezable,{allowCredentials:YES,isAsynchronous:YES,isJSON:NO,isXML:NO,attachIdentifyingHeaders:YES,headers:function(){var a=this._headers;if(!a){a=this._headers={}}return a}.property().cacheable(),isSameDomain:function(){var b=this.get("address"),e=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,a=window.location,d,c;d=e.exec(b.toLowerCase());c=e.exec(a.href.toLowerCase());return SC.none(d)||(d[1]===c[1]&&d[2]===c[2]&&(d[3]||(d[1]==="http:"?80:443))===(c[3]||(c[1]==="http:"?80:443)))}.property("address").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(b,a){},didSend:function(b,a){},willReceive:function(b,a){},didReceive:function(b,a){},concatenatedProperties:"COPY_KEYS",COPY_KEYS:["attachIdentifyingHeaders","allowCredentials","isAsynchronous","isJSON","isXML","address","type","timeout","body","responseClass","willSend","didSend","willReceive","didReceive"],copy:function(){var a={},c=this.COPY_KEYS,d=c.length,b;while(--d>=0){b=c[d];if(this.hasOwnProperty(b)){a[b]=this.get(b)}}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 d,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(d in c){if(!c.hasOwnProperty(d)){continue}this.header(d,c[d])}this.endPropertyChanges();return this}}return this},clearHeaders:function(){this.propertyWillChange("headers");this._headers={};this.propertyDidChange("headers")},async:function(a){if(a===undefined){a=YES}return this.set("isAsynchronous",a)},credentials:function(a){if(a===undefined){a=YES}return this.set("allowCredentials",a)},timeoutAfter:function(a){return this.set("timeout",a)},json:function(a){if(a===undefined){a=YES}if(a){this.set("isXML",NO)}return this.set("isJSON",a)},xml:function(a){if(a===undefined){a=YES}if(a){this.set("isJSON",NO)}return this.set("isXML",a)},_prep:function(){var a=!!this.header("Content-Type");if(this.get("attachIdentifyingHeaders")){this.header("X-Requested-With","XMLHttpRequest");this.header("X-SproutCore-Version",SC.VERSION)}if(!a&&!!this.get("body")){if(this.get("isJSON")){this.header("Content-Type","application/json")}else{if(this.get("isXML")){this.header("Content-Type","text/xml")}}}return this},send:function(a){var b=this.get("timeout");if(b&&!this.get("isAsynchronous")){throw new Error("Timeout values cannot be used with synchronous requests")}else{if(b===0){throw new Error("The timeout value must either not be specified or must be greater than 0")}}if(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(g,f,e){var b,c,a;if(SC.typeOf(g)!==SC.T_NUMBER&&SC.typeOf(g)!==SC.T_STRING){b=new Array(arguments.length-2);for(c=0,a=b.length;c<a;c++){b[c]=arguments[c+2]}e=f;f=g;g=0}else{if(arguments.length>3){b=new Array(arguments.length-3);for(c=0,a=b.length;c<a;c++){b[c]=arguments[c+3]}}else{b=[]}}var d=this.get("listeners");if(!d){this.set("listeners",d={})}if(!d[g]){d[g]=[]}d[g].push({target:f,action:e,args:b});return this}});SC.Request.mixin({getUrl:function(a){return this.create().set("address",a).set("type","GET")},postUrl:function(b,a){var c=this.create().set("address",b).set("type","POST");if(a){c.set("body",a)}return c},deleteUrl:function(a){return this.create().set("address",a).set("type","DELETE")},putUrl:function(b,a){var c=this.create().set("address",b).set("type","PUT");if(a){c.set("body",a)}return c},patchUrl:function(b,a){var c=this.create().set("address",b).set("type","PATCH");if(a){c.set("body",a)}return c}});SC.Request.WARN_ON_LOADEND=YES;SC.Request.manager=SC.Object.create({maxRequests:6,inflight:[],pending:[],sendRequest:function(b){if(!b){return null}var a=b.get("responseClass").create({request:b});this.get("pending").pushObject(a);this.fireRequestIfNeeded();return a},cancel:function(a){var c=this.get("pending"),b=this.get("inflight");if(c.indexOf(a)>=0){this.propertyWillChange("pending");c.removeObject(a);this.propertyDidChange("pending");return YES}else{if(b.indexOf(a)>=0){a.cancel();b.removeObject(a);this.fireRequestIfNeeded();return YES}}return NO},cancelAll:function(){var a=this.getPath("pending.length"),c=this.getPath("inflight.length"),e=this.get("inflight"),f=this.get("pending");if(a||c){for(var b=c-1;b>=0;b--){var d=e.objectAt(b);d.cancel()}f.replace(0,a);e.replace(0,c);return YES}return NO},fireRequestIfNeeded:function(){var d=this.get("pending"),c=this.get("inflight"),a=this.get("maxRequests"),b;if((d.length>0)&&(c.length<a)){b=d.shiftObject();c.pushObject(b);b.fire()}},transportDidClose:function(a){this.get("pending").removeObject(a);this.get("inflight").removeObject(a);this.fireRequestIfNeeded()},isPending:function(a){return this.get("pending").contains(a)},isInFlight:function(a){return this.get("inflight").contains(a)}});sc_require("mixins/websocket_delegate");SC.WebSocket=SC.Object.extend(SC.DelegateSupport,SC.WebSocketDelegate,{server:null,isSupported:null,isConnected:false,isAuth:null,isJSON:true,delegate:null,autoReconnect:true,reconnectInterval:10000,connect:function(){var b=this;if(this.isSupported===null){this.set("isSupported",!!window.WebSocket)}if(!this.isSupported||this.socket){return this}try{var a=this.socket=new WebSocket(this.get("server"));a.onopen=function(){SC.RunLoop.begin();b.onOpen.apply(b,arguments);SC.RunLoop.end()};a.onmessage=function(){SC.RunLoop.begin();b.onMessage.apply(b,arguments);SC.RunLoop.end()};a.onclose=function(){SC.RunLoop.begin();b.onClose.apply(b,arguments);SC.RunLoop.end()};a.onerror=function(){SC.RunLoop.begin();b.onError.apply(b,arguments);SC.RunLoop.end()}}catch(c){SC.error("An error has occurred while connnecting to the websocket server: "+c)}return this},close:function(b,c){var a=this.socket;if(a&&a.readyState===SC.WebSocket.OPEN){this.socket.close(b,c)}return this},notify:function(e,g,f){var b,c,a;if(SC.typeOf(e)!==SC.T_STRING){b=new Array(arguments.length-2);for(c=0,a=b.length;c<a;c++){b[c]=arguments[c+2]}f=g;g=e;e="onmessage"}else{if(arguments.length>3){b=new Array(arguments.length-3);for(c=0,a=b.length;c<a;c++){b[c]=arguments[c+3]}}else{b=[]}}var d=this.get("listeners");if(!d){this.set("listeners",d={})}if(!d[e]){d[e]=[]}d[e].push({target:g,action:f,args:b});return this},send:function(a){if(this.isConnected===true&&this.isAuth!==false){if(this.isJSON){a=JSON.stringify(a)}this.socket.send(a)}else{this.addToQueue(a)}return this},onOpen:function(c){var a=this.get("objectDelegate");this.set("isConnected",true);var b=a.webSocketDidOpen(this,c);if(b!==true){this._notifyListeners("onopen",c)}this.fireQueue()},onMessage:function(a){if(a){var b=this.get("objectDelegate"),d,e,c;d=e=a.data;c=b.webSocketDidReceiveMessage(this,e);if(c!==true){if(this.isJSON){d=JSON.parse(e)}this._notifyListeners("onmessage",d)}}this.fireQueue()},onClose:function(c){var a=this.get("objectDelegate");this.set("isConnected",false);this.set("isAuth",null);this.socket=null;var b=a.webSocketDidClose(this,c);if(b!==true){this._notifyListeners("onclose",c);this.tryReconnect()}},onError:function(c){var a=this.get("objectDelegate"),b=a.webSocketDidError(this,c);if(b!==true){this._notifyListeners("onerror",c)}},addToQueue:function(b){var a=this.queue;if(!a){this.queue=a=[]}a.push(b)},fireQueue:function(){var b=this.queue;if(!b||b.length===0){return}b=SC.A(b);this.queue=null;for(var c=0,a=b.length;c<a;c++){var d=b[c];this.send(d)}},tryReconnect:function(){if(!this.get("autoReconnect")){return}var a=this;setTimeout(function(){a.connect()},this.get("reconnectInterval"))},_notifyListeners:function(a,j){var h=(this.listeners||{})[a],k,f,b,g;if(!h){return NO}var e=NO,d=h.length;for(var c=0;c<d;c++){k=h[c];g=(k.args||[]).copy();g.unshift(j);g.unshift(this);f=k.target;b=k.action;if(SC.typeOf(b)===SC.T_STRING){b=f[b]}e=b.apply(f,g);if(e===true){return e}}return e},objectDelegate:function(){var a=this.get("delegate");return this.delegateFor("isWebSocketDelegate",a,this)}.property("delegate").cacheable(),socket:null,listeners:null,queue:null});SC.WebSocket.mixin({CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3});SC.FOCUS_ALL_CONTROLS=false;SC.TreeItemContent={isTreeItemContent:YES,treeItemChildren:null,treeItemIsExpanded:YES,treeItemIsGrouped:NO,treeItemDisclosureState:function(b,a){return this.get("treeItemIsExpanded")?SC.BRANCH_OPEN:SC.BRANCH_CLOSED},treeItemCollapse:function(b,a){this.setIfChanged("treeItemIsExpanded",NO)},treeItemExpand:function(b,a){this.setIfChanged("treeItemIsExpanded",YES)},treeItemBranchIndexes:function(e,c){var d=this.get("treeItemChildren"),b,g,a,f;if(!d){return null}b=SC.IndexSet.create();g=d.get("length");for(a=0;a<g;a++){if(!(f=d.objectAt(a))){continue}if(!f.get("treeItemChildren")){continue}if(f.treeItemDisclosureState(this,a)!==SC.LEAF_NODE){b.add(a)}}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(d,b,a){var c=d.get("selection");return c?c.contains(b,a):NO},contentIndexIsEnabled:function(c,b,a){return c.get("isEnabled")},contentGroupIndexes:function(b,a){return null},contentIndexIsGroup:function(c,b,a){return NO},contentIndexOutlineLevel:function(c,b,a){return -1},contentIndexDisclosureState:function(c,b,a){return SC.LEAF_NODE},contentIndexExpand:function(c,b,a){SC.Logger.log("contentIndexExpand(%@, %@, %@)".fmt(c,b,a))},contentIndexCollapse:function(c,b,a){SC.Logger.log("contentIndexCollapse(%@, %@, %@)".fmt(c,b,a))}};sc_require("mixins/tree_item_content");sc_require("mixins/collection_content");SC.TreeItemObserver=SC.Object.extend(SC.Array,SC.CollectionContent,{_cachedItem:null,_cachedDelegate:null,item:null,delegate:null,treeItemChildrenKey:"treeItemChildren",treeItemIsExpandedKey:"treeItemIsExpanded",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 e=this.get("item"),b,f,a,d,c;if(!e){return SC.IndexSet.EMPTY}else{if(e.isTreeItemContent){f=this.get("parentItem");a=this.get("index");return e.treeItemBranchIndexes(f,a)}else{d=this.get("children");if(!d){return null}c=SC.IndexSet.create();b=d.get("length");f=e;for(a=0;a<b;a++){e=d.objectAt(a);if(!e){continue}if(!this._computeChildren(e,f,a)){continue}if(this._computeDisclosureState(e,f,a)!==SC.LEAF_NODE){c.add(a)}}return c.get("length")>0?c:null}}}.property("children").cacheable(),isHeaderVisible:function(){return !!this.get("parentObserver")}.property("parentObserver").cacheable(),length:0,objectAt:function(d,g){var a=this.get("length"),f=this.get("item"),b=this._objectAtCache,h=d,c,e;if(d>=a){return undefined}if(this.get("isHeaderVisible")){if(d===0){return f}else{h--}}f=null;if(!b){b=this._objectAtCache=[]}if((f=b[d])!==undefined){return f}e=this.get("children");if(!e){return undefined}c=this.get("branchIndexes");if(c){c.forEach(function(l){if(f||(l>h)){return}var k=this.branchObserverAt(l),j;if(!k){return}j=k.get("length");if(l+j>h){f=k.objectAt(h-l,g);h=-1}else{h=h-(j-1)}},this)}if(h>=0){f=e.objectAt(h,g)}b[d]=f;return f},replace:function(a,b,j,d){var i=a,g=null,e,f,h;if(d===undefined){d=SC.DROP_BEFORE}if(this.get("isHeaderVisible")){i--}if(i<0){throw new Error("Tree Item cannot replace itself")}e=this.get("branchIndexes");if(e){e.forEach(function(k){if(g||(k>=i)){return}g=this.branchObserverAt(k);if(!g){return}f=g.get("length");if((k+f===i)&&d===SC.DROP_AFTER){i=i-k}else{if(k+f>i){i=i-k}else{i=i-(f-1);g=null}}},this)}if(g){g.replace(i,b,j,d);return this}h=i+b;if(b>1&&e){e.forEachIn(i,e.get("max")-i,function(k){if(k>h){return}if(!(g=this.branchObserverAt(k))){return}f=g.get("length");h=h-(f-1)},this)}b=h-i;var c=this.get("children");if(!c){throw new Error("cannot replace() tree item with no children")}if((b<0)||(h>c.get("length"))){throw new Error("replace() range must lie within a single tree item")}c.replace(i,b,j,d);return this},observerContentDidChange:function(b,c,i){this.invalidateBranchObserversAt(b);this._objectAtCache=this._outlineLevelCache=null;this._disclosureStateCache=null;this.notifyPropertyChange("branchIndexes");var d=this.get("length"),e=this._computeLength(),g=this.get("parentObserver"),f;if(d!==e){this.set("length",e)}if(!this._notifyParent){return this}if(g){f=SC.IndexSet.create(this.get("index"));g._childrenRangeDidChange(g.get("children"),null,"[]",f)}else{if(d===e){c=this.expandChildIndex(b+c);b=this.expandChildIndex(b);c=c-b;i=0}else{b=this.expandChildIndex(b);c=e-b;i=e-d}var h=c;var a=i+h;this.arrayContentDidChange(b,h,a)}},expandChildIndex:function(c){var b=c;if(this.get("isHeaderVisible")){c++}var a=this.get("branchIndexes");if(!a||a.get("length")===0){return b}a.forEachIn(0,c,function(d){b+=this.branchObserverAt(d).get("length")-1},this);return b},contentGroupIndexes:function(a,e){var c;if(e!==this){return null}if(this.get("parentObserver")){return null}var d=this.get("item"),g,b,h,f;if(d&&d.isTreeItemContent){g=d.get("treeItemIsGrouped")}else{g=!!this.delegate.get("treeItemIsGrouped")}if(g){c=SC.IndexSet.create();b=this.get("branchIndexes");if(b){h=b.min();f=0;b.forEach(function(k){c.add(k+f,1);var j=this.branchObserverAt(k);if(j){f+=j.get("length")-1;h+=f}},this)}}else{c=null}return c},contentIndexIsGroup:function(b,d,a){var c=this.contentGroupIndexes(b,d);return c?c.contains(a):NO},contentIndexOutlineLevel:function(b,g,f){if(g!==this){return -1}var c=this._outlineLevelCache;if(c&&(c[f]!==undefined)){return c[f]}if(!c){c=this._outlineLevelCache=[]}var a=this.get("length"),h=f,e=null,d;if(f>=a){return -1}if(this.get("isHeaderVisible")){if(f===0){c[0]=this.get("outlineLevel")-1;return c[0]}else{h--}}d=this.get("branchIndexes");if(d){d.forEach(function(l){if((e!==null)||(l>h)){return}var k=this.branchObserverAt(l),j;if(!k){return}j=k.get("length");if(l+j>h){e=k.contentIndexOutlineLevel(b,k,h-l);h=-1}else{h=h-(j-1)}},this)}if(h>=0){e=this.get("outlineLevel")}c[f]=e;return e},contentIndexDisclosureState:function(b,g,f){if(g!==this){return -1}var c=this._disclosureStateCache;if(c&&(c[f]!==undefined)){return c[f]}if(!c){c=this._disclosureStateCache=[]}var a=this.get("length"),h=f,e=null,d;if(f>=a){return SC.LEAF_NODE}if(this.get("isHeaderVisible")){if(f===0){c[0]=this.get("disclosureState");return c[0]}else{h--}}d=this.get("branchIndexes");if(d){d.forEach(function(l){if((e!==null)||(l>h)){return}var k=this.branchObserverAt(l),j;if(!k){return}j=k.get("length");if(l+j>h){e=k.contentIndexDisclosureState(b,k,h-l);h=-1}else{h=h-(j-1)}},this)}if(h>=0){e=SC.LEAF_NODE}c[f]=e;return e},contentIndexExpand:function(b,f,a){var c,g=a,d,e;if(f!==this){return}if(this.get("isHeaderVisible")){if(a===0){this._expand(this.get("item"));return}else{g--}}c=this.get("branchIndexes");if(c){c.forEach(function(k){if(k>=g){return}var j=this.branchObserverAt(k),h;if(!j){return}h=j.get("length");if(k+h>g){j.contentIndexExpand(b,j,g-k);g=-1}else{g=g-(h-1)}},this)}if(g>=0){d=this.get("children");e=d?d.objectAt(g):null;if(e){this._expand(e,this.get("item"),g)}}},contentIndexCollapse:function(b,f,a){var c,d,e,g=a;if(f!==this){return}if(this.get("isHeaderVisible")){if(a===0){this._collapse(this.get("item"));return}else{g--}}c=this.get("branchIndexes");if(c){c.forEach(function(k){if(k>=g){return}var j=this.branchObserverAt(k),h;if(!j){return}h=j.get("length");if(k+h>g){j.contentIndexCollapse(b,j,g-k);g=-1}else{g=g-(h-1)}},this)}if(g>=0){d=this.get("children");e=d?d.objectAt(g):null;if(e){this._collapse(e,this.get("item"),g)}}},branchObserverAt:function(d){var c=this._branchObserversByIndex,b=this._branchObserverIndexes,a,f,e;if(!c){c=this._branchObserversByIndex=[]}if(!b){b=this._branchObserverIndexes=SC.IndexSet.create()}a=c[d];if(a){return a}e=this.get("children");f=e?e.objectAt(d):null;if(!f){return null}c[d]=a=SC.TreeItemObserver.create({item:f,delegate:this.get("delegate"),parentObserver:this,index:d,outlineLevel:this.get("outlineLevel")+1});b.add(d);return a},invalidateBranchObserversAt:function(c){var b=this._branchObserversByIndex,a=this._branchObserverIndexes;if(!b||b.length<=c){return this}if(c<0){c=0}a.forEachIn(c,a.get("max")-c,function(e){var d=b[e];if(d){d.destroy()}},this);b.length=c;return this},_cleanUpCachedDelegate:function(){var a=this._cachedDelegate;if(a){a.removeObserver("treeItemIsExpandedKey",this,this.treeItemIsExpandedKeyDidChange);a.removeObserver("treeItemChildrenKey",this,this.treeItemChildrenKeyDidChange);a.removeObserver("treeItemIsGrouped",this,this.treeItemIsGroupedDidChange);this._cleanUpCachedItem();this.set("treeItemChildrenKey","treeItemChildren");this.set("treeItemIsExpandedKey","treeItemIsExpanded");this._cachedDelegate=null}},_cleanUpCachedItem:function(){var b=this._cachedItem,c=this.get("treeItemIsExpandedKey"),a=this.get("treeItemChildrenKey");if(b){b.removeObserver(c,this,this._itemIsExpandedDidChange);b.removeObserver(a,this,this._itemChildrenDidChange);this._cachedItem=null}},init:function(){arguments.callee.base.apply(this,arguments);this._delegateDidChange();this._itemDidChange();this._notifyParent=YES},destroy:function(){this.invalidateBranchObserversAt(0);this._objectAtCache=null;this._notifyParent=NO;this._cleanUpCachedItem();this._cleanUpCachedDelegate();var a=this._children,b=this._childrenRangeObserver;if(a&&b){a.removeRangeObserver(b)}this.set("length",0);arguments.callee.base.apply(this,arguments)},_itemDidChange:function(){var b=this.get("item"),a,c;c=this.get("treeItemIsExpandedKey");a=this.get("treeItemChildrenKey");this._cleanUpCachedItem();b.addObserver(c,this,this._itemIsExpandedDidChange);b.addObserver(a,this,this._itemChildrenDidChange);this.beginPropertyChanges();this._itemIsExpandedDidChange();this._itemChildrenDidChange();this.endPropertyChanges();this._cachedItem=b}.observes("item"),_itemIsExpandedDidChange:function(){var c=this.get("disclosureState"),b=this.get("item"),a;a=this._computeDisclosureState(b);if(c!==a){this.set("disclosureState",a)}},_itemChildrenDidChange:function(){var a=this.get("children"),c=this.get("item"),b;b=this._computeChildren(c);if(a!==b){this.set("children",b)}},_childrenDidChange:function(){var c=this.get("disclosureState"),d=c===SC.BRANCH_OPEN?this.get("children"):null,b=this._children,a=this._childrenRangeObserver;if(b===d){return this}if(a){b.removeRangeObserver(a)}if(d){this._childrenRangeObserver=d.addRangeObserver(null,this,this._childrenRangeDidChange)}else{this._childrenRangeObserver=null}this._children=d;this._childrenRangeDidChange(d,null,"[]",null)}.observes("children","disclosureState"),_childrenRangeDidChange:function(f,i,h,d){var a=this.get("children"),e=a?a.get("length"):0,c=d?d.get("min"):0,g=d?d.get("max"):e,b=this._childrenLen||0;this._childrenLen=e;this.observerContentDidChange(c,g-c,e-b)},_computeDisclosureState:function(c,d,a){var b;if(!c||!this._computeChildren(c)){return SC.LEAF_NODE}else{if(c.isTreeItemContent){if(d===undefined){d=this.get("parentItem")}if(a===undefined){a=this.get("index")}return c.treeItemDisclosureState(d,a)}else{b=this.get("treeItemIsExpandedKey");return c.get(b)?SC.BRANCH_OPEN:SC.BRANCH_CLOSED}}},_collapse:function(c,d,a){var b;if(!c||!this._computeChildren(c)){return this}else{if(c.isTreeItemContent){if(d===undefined){d=this.get("parentItem")}if(a===undefined){a=this.get("index")}c.treeItemCollapse(d,a)}else{b=this.get("treeItemIsExpandedKey");c.setIfChanged(b,NO)}}return this},_delegateDidChange:function(){var a=this.get("delegate");this._cleanUpCachedDelegate();if(a){a.addObserver("treeItemChildrenKey",this,this.treeItemChildrenKeyDidChange);a.addObserver("treeItemIsExpandedKey",this,this.treeItemIsExpandedKeyDidChange);a.addObserver("treeItemIsGrouped",this,this.treeItemIsGroupedDidChange);this.treeItemChildrenKeyDidChange();this.treeItemIsExpandedKeyDidChange();this.treeItemIsGroupedDidChange()}this._itemDidChange();this._cachedDelegate=a}.observes("delegate"),_expand:function(c,d,a){var b;if(!c||!this._computeChildren(c)){return this}else{if(c.isTreeItemContent){if(d===undefined){d=this.get("parentItem")}if(a===undefined){a=this.get("index")}c.treeItemExpand(d,a)}else{b=this.get("treeItemIsExpandedKey");c.setIfChanged(b,YES)}}return this},_computeChildren:function(b){var a;if(!b){return null}else{if(b.isTreeItemContent){return b.get("treeItemChildren")}else{a=this.get("treeItemChildrenKey");return b.get(a)}}},_computeLength:function(){var b=this.get("isHeaderVisible")?1:0,d=this.get("disclosureState"),c=this.get("children"),a;if((d===SC.BRANCH_OPEN)&&c){b+=c.get("length");a=this.get("branchIndexes");if(a){a.forEach(function(e){var f=this.branchObserverAt(e);b+=f.get("length")-1},this)}}return b},treeItemChildrenKeyDidChange:function(){var a=this.get("delegate"),b;b=a?a.get("treeItemChildrenKey"):"treeItemChildren";this.set("treeItemChildrenKey",b?b:"treeItemChildren")},treeItemIsExpandedKeyDidChange:function(){var a=this.get("delegate"),b;b=a?a.get("treeItemIsExpandedKey"):"treeItemIsExpanded";this.set("treeItemIsExpandedKey",b?b:"treeItemIsExpanded")},treeItemIsGroupedDidChange:function(){this.notifyPropertyChange("branchIndexes")}});sc_require("private/tree_item_observer");SC.TreeController=SC.ObjectController.extend(SC.SelectionSupport,{treeItemIsGrouped:NO,treeItemIsExpandedKey:"treeItemIsExpanded",treeItemChildrenKey:"treeItemChildren",arrangedObjects:null,init:function(){arguments.callee.base.apply(this,arguments);this._contentDidChange()},_contentDidChange:function(){var a=this.get("arrangedObjects"),b=this.get("content");if(b){if(a){a.set("item",b)}else{a=SC.TreeItemObserver.create({item:b,delegate:this});a.bind("allowsSelection",this,"allowsSelection");a.bind("allowsMultipleSelection",this,"allowsMultipleSelection");a.bind("allowsEmptySelection",this,"allowsEmptySelection");a.addObserver("[]",this,this._sctc_arrangedObjectsContentDidChange);this.set("arrangedObjects",a)}}else{if(a){a.destroy();this.set("arrangedObjects",null);this._sctc_arrangedObjectsContentDidChange()}}}.observes("content"),_sctc_arrangedObjectsContentDidChange:function(){this.updateSelectionAfterContentChange()}.observes(),canSelectGroups:NO,firstSelectableObject:function(){var d=this.get("arrangedObjects"),c,b,a=0;if(!d){return null}if(this.get("canSelectGroups")){return d.get("firstObject")}c=d.contentGroupIndexes(null,d);b=d.get("length");while(c.contains(a)&&(a<b)){a++}return a>=b?null:d.objectAt(a)}.property()});SC.InlineTextFieldDelegate={editor:null,acquireEditor:function(a){var b=this.editor;if(b){if(b.get("isEditing")&&!b.commitEditing()&&!b.discardEditing()){return null}this.releaseEditor(b)}var d=a.exampleEditor?a.exampleEditor:SC.InlineTextFieldView,c=a.get("parentView");b=this.editor=c.createChildView(d,{inlineEditorDelegate:this});c.appendChild(b);return b},releaseEditor:function(a){a.destroy();this.editor=null;return YES}};SC.STRING_TITLEIZE_REGEXP=(/([\s|\-|\_|\n])([^\s|\-|\_|\n]?)/g);SC.STRING_HUMANIZE_REGEXP=(/[\-_]/g);SC.STRING_REGEXP_ESCAPED_REGEXP=(/([\\\.\+\*\?\[\^\]\$\(\)\{\}\=\!\<\>\|\:])/g);SC.STRING_DASHERIZE_CACHE={top:"top",left:"left",right:"right",bottom:"bottom",width:"width",height:"height",minWidth:"min-width",maxWidth:"max-width"};SC.mixin(SC.String,{capitalizeEach:function(a){return a.replace(SC.STRING_TITLEIZE_REGEXP,function(c,b,d){return(d)?(b+d.toUpperCase()):b}).capitalize()},titleize:function(b){var a=b.replace(SC.STRING_DECAMELIZE_REGEXP,"$1_$2");return a.replace(SC.STRING_TITLEIZE_REGEXP,function(c,e,d){return d?" "+d.toUpperCase():" "}).capitalize()},classify:function(d){var a=d.replace(SC.STRING_TITLEIZE_REGEXP,function(e,g,f){return f?f.toUpperCase():""});var c=a.charAt(0),b=c.toUpperCase();return c!==b?b+a.slice(1):a},humanize:function(a){return SC.String.decamelize(a).replace(SC.STRING_HUMANIZE_REGEXP," ")},escapeForRegExp:function(a){return a.replace(SC.STRING_REGEXP_ESCAPED_REGEXP,"\\$1")},removeDiacritics:function(g){var a=SC.diacriticMappingTable;if(!a){SC.diacriticMappingTable={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","Ā":"A","Ă":"A","Ą":"A","Ǎ":"A","Ǟ":"A","Ǡ":"A","Ǻ":"A","Ȁ":"A","Ȃ":"A","Ȧ":"A","Ḁ":"A","Ạ":"A","Ả":"A","Ấ":"A","Ầ":"A","Ẩ":"A","Ẫ":"A","Ậ":"A","Ắ":"A","Ằ":"A","Ẳ":"A","Ẵ":"A","Ặ":"A","Å":"A","Ḃ":"B","Ḅ":"B","Ḇ":"B","Ç":"C","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","Ḉ":"C","Ď":"D","Ḋ":"D","Ḍ":"D","Ḏ":"D","Ḑ":"D","Ḓ":"D","È":"E","É":"E","Ê":"E","Ë":"E","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","Ȅ":"E","Ȇ":"E","Ȩ":"E","Ḕ":"E","Ḗ":"E","Ḙ":"E","Ḛ":"E","Ḝ":"E","Ẹ":"E","Ẻ":"E","Ẽ":"E","Ế":"E","Ề":"E","Ể":"E","Ễ":"E","Ệ":"E","Ḟ":"F","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","Ǧ":"G","Ǵ":"G","Ḡ":"G","Ĥ":"H","Ȟ":"H","Ḣ":"H","Ḥ":"H","Ḧ":"H","Ḩ":"H","Ḫ":"H","Ì":"I","Í":"I","Î":"I","Ï":"I","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","Ǐ":"I","Ȉ":"I","Ȋ":"I","Ḭ":"I","Ḯ":"I","Ỉ":"I","Ị":"I","Ĵ":"J","Ķ":"K","Ǩ":"K","Ḱ":"K","Ḳ":"K","Ḵ":"K","Ĺ":"L","Ļ":"L","Ľ":"L","Ḷ":"L","Ḹ":"L","Ḻ":"L","Ḽ":"L","Ḿ":"M","Ṁ":"M","Ṃ":"M","Ñ":"N","Ń":"N","Ņ":"N","Ň":"N","Ǹ":"N","Ṅ":"N","Ṇ":"N","Ṉ":"N","Ṋ":"N","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ō":"O","Ŏ":"O","Ő":"O","Ơ":"O","Ǒ":"O","Ǫ":"O","Ǭ":"O","Ȍ":"O","Ȏ":"O","Ȫ":"O","Ȭ":"O","Ȯ":"O","Ȱ":"O","Ṍ":"O","Ṏ":"O","Ṑ":"O","Ṓ":"O","Ọ":"O","Ỏ":"O","Ố":"O","Ồ":"O","Ổ":"O","Ỗ":"O","Ộ":"O","Ớ":"O","Ờ":"O","Ở":"O","Ỡ":"O","Ợ":"O","Ṕ":"P","Ṗ":"P","Ŕ":"R","Ŗ":"R","Ř":"R","Ȑ":"R","Ȓ":"R","Ṙ":"R","Ṛ":"R","Ṝ":"R","Ṟ":"R","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","Ș":"S","Ṡ":"S","Ṣ":"S","Ṥ":"S","Ṧ":"S","Ṩ":"S","Ţ":"T","Ť":"T","Ț":"T","Ṫ":"T","Ṭ":"T","Ṯ":"T","Ṱ":"T","Ù":"U","Ú":"U","Û":"U","Ü":"U","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","Ư":"U","Ǔ":"U","Ǖ":"U","Ǘ":"U","Ǚ":"U","Ǜ":"U","Ȕ":"U","Ȗ":"U","Ṳ":"U","Ṵ":"U","Ṷ":"U","Ṹ":"U","Ṻ":"U","Ụ":"U","Ủ":"U","Ứ":"U","Ừ":"U","Ử":"U","Ữ":"U","Ự":"U","Ṽ":"V","Ṿ":"V","Ŵ":"W","Ẁ":"W","Ẃ":"W","Ẅ":"W","Ẇ":"W","Ẉ":"W","Ẋ":"X","Ẍ":"X","Ý":"Y","Ŷ":"Y","Ÿ":"Y","Ȳ":"Y","Ẏ":"Y","Ỳ":"Y","Ỵ":"Y","Ỷ":"Y","Ỹ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","Ẑ":"Z","Ẓ":"Z","Ẕ":"Z","`":"`","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","ā":"a","ă":"a","ą":"a","ǎ":"a","ǟ":"a","ǡ":"a","ǻ":"a","ȁ":"a","ȃ":"a","ȧ":"a","ḁ":"a","ạ":"a","ả":"a","ấ":"a","ầ":"a","ẩ":"a","ẫ":"a","ậ":"a","ắ":"a","ằ":"a","ẳ":"a","ẵ":"a","ặ":"a","ḃ":"b","ḅ":"b","ḇ":"b","ç":"c","ć":"c","ĉ":"c","ċ":"c","č":"c","ḉ":"c","ď":"d","ḋ":"d","ḍ":"d","ḏ":"d","ḑ":"d","ḓ":"d","è":"e","é":"e","ê":"e","ë":"e","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","ȅ":"e","ȇ":"e","ȩ":"e","ḕ":"e","ḗ":"e","ḙ":"e","ḛ":"e","ḝ":"e","ẹ":"e","ẻ":"e","ẽ":"e","ế":"e","ề":"e","ể":"e","ễ":"e","ệ":"e","ḟ":"f","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","ǧ":"g","ǵ":"g","ḡ":"g","ĥ":"h","ȟ":"h","ḣ":"h","ḥ":"h","ḧ":"h","ḩ":"h","ḫ":"h","ẖ":"h","ì":"i","í":"i","î":"i","ï":"i","ĩ":"i","ī":"i","ĭ":"i","į":"i","ǐ":"i","ȉ":"i","ȋ":"i","ḭ":"i","ḯ":"i","ỉ":"i","ị":"i","ĵ":"j","ǰ":"j","ķ":"k","ǩ":"k","ḱ":"k","ḳ":"k","ḵ":"k","ĺ":"l","ļ":"l","ľ":"l","ḷ":"l","ḹ":"l","ḻ":"l","ḽ":"l","ḿ":"m","ṁ":"m","ṃ":"m","ñ":"n","ń":"n","ņ":"n","ň":"n","ǹ":"n","ṅ":"n","ṇ":"n","ṉ":"n","ṋ":"n","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ō":"o","ŏ":"o","ő":"o","ơ":"o","ǒ":"o","ǫ":"o","ǭ":"o","ȍ":"o","ȏ":"o","ȫ":"o","ȭ":"o","ȯ":"o","ȱ":"o","ṍ":"o","ṏ":"o","ṑ":"o","ṓ":"o","ọ":"o","ỏ":"o","ố":"o","ồ":"o","ổ":"o","ỗ":"o","ộ":"o","ớ":"o","ờ":"o","ở":"o","ỡ":"o","ợ":"o","ṕ":"p","ṗ":"p","ŕ":"r","ŗ":"r","ř":"r","ȑ":"r","ȓ":"r","ṙ":"r","ṛ":"r","ṝ":"r","ṟ":"r","ś":"s","ŝ":"s","ş":"s","š":"s","ș":"s","ṡ":"s","ṣ":"s","ṥ":"s","ṧ":"s","ṩ":"s","ţ":"t","ť":"t","ț":"t","ṫ":"t","ṭ":"t","ṯ":"t","ṱ":"t","ẗ":"t","ù":"u","ú":"u","û":"u","ü":"u","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","ư":"u","ǔ":"u","ǖ":"u","ǘ":"u","ǚ":"u","ǜ":"u","ȕ":"u","ȗ":"u","ṳ":"u","ṵ":"u","ṷ":"u","ṹ":"u","ṻ":"u","ụ":"u","ủ":"u","ứ":"u","ừ":"u","ử":"u","ữ":"u","ự":"u","ṽ":"v","ṿ":"v","ŵ":"w","ẁ":"w","ẃ":"w","ẅ":"w","ẇ":"w","ẉ":"w","ẘ":"w","ẋ":"x","ẍ":"x","ý":"y","ÿ":"y","ŷ":"y","ȳ":"y","ẏ":"y","ẙ":"y","ỳ":"y","ỵ":"y","ỷ":"y","ỹ":"y","ź":"z","ż":"z","ž":"z","ẑ":"z","ẓ":"z","ẕ":"z"};a=SC.diacriticMappingTable}var d,e,b="",f=g.length;for(var c=0;c<=f;++c){d=g.charAt(c);e=a[d];b+=e||d}return b},pluralize:function(h){var d=SC.Locale.currentLocale.inflectionConstants;if(!d){return h.toString()}var l,f,b=h.split(/\s/).pop(),i=h.replace(b,""),a=b.charAt(0).match(/[A-Z]/)?true:false;b=b.toLowerCase();for(l=0,f=d.UNCOUNTABLE.length;l<f;l++){var g=d.UNCOUNTABLE[l];if(b==g){return h.toString()}}for(l=0,f=d.IRREGULAR.length;l<f;l++){var c=d.IRREGULAR[l][0],k=d.IRREGULAR[l][1];if((b==c)||(b==k)){if(a){k=k.capitalize()}return i+k}}for(l=0,f=d.PLURAL.length;l<f;l++){var j=d.PLURAL[l][0],e=d.PLURAL[l][1];if(j.test(b)){return h.replace(j,e)}}},singularize:function(h){var d=SC.Locale.currentLocale.inflectionConstants;if(!d){return h.toString()}var l,f,b=h.split(/\s/).pop(),i=h.replace(b,""),a=b.charAt(0).match(/[A-Z]/)?true:false;b=b.toLowerCase();for(l=0,f=d.UNCOUNTABLE.length;l<f;l++){var g=d.UNCOUNTABLE[l];if(b==g){return h.toString()}}for(l=0,f=d.IRREGULAR.length;l<f;l++){var c=d.IRREGULAR[l][0],k=d.IRREGULAR[l][1];if((b==c)||(b==k)){if(a){c=c.capitalize()}return i+c}}for(l=0,f=d.SINGULAR.length;l<f;l++){var j=d.SINGULAR[l][0],e=d.SINGULAR[l][1];if(j.test(b)){return h.replace(j,e)}}}});SC.String.strip=SC.String.trim;sc_require("system/string");SC.supplement(String.prototype,{capitalizeEach:function(){return SC.String.capitalizeEach(this,arguments)},titleize:function(a){return SC.String.titleize(this,arguments)},classify:function(a){return SC.String.classify(this,arguments)},humanize:function(a){return SC.String.humanize(this,arguments)},escapeForRegExp:function(a){return SC.String.escapeForRegExp(this,arguments)},removeDiacritics:function(a){return SC.String.removeDiacritics(this,arguments)},trim:function(a){return SC.String.trim(this,arguments)},trimLeft:function(a){return SC.String.trimLeft(this,arguments)},trimRight:function(a){return SC.String.trimRight(this,arguments)},pluralize:function(a){return SC.String.pluralize(this,arguments)},singularize:function(a){return SC.String.singularize(this,arguments)}});SC.Gesture=SC.Object.extend({_sc_isActive:false,acceptsMultitouch:false,name:"gesture",touchIsInGesture:function(b,a){return NO},touchStart:function(a){return true},start:function(){if(!this._sc_isActive){this._sc_isActive=true;var e=arguments.length,c=new Array(e);for(var d=0,a=e;d<a;d++){c[d]=arguments[d]}var b=this.name+"Start";if(this.view[b]){this.view[b].apply(this.view,c)}}},end:function(){if(this._sc_isActive){this._sc_isActive=false;var e=arguments.length,c=new Array(e);for(var d=0,a=e;d<a;d++){c[d]=arguments[d]}var b=this.name+"End";if(this.view[b]){this.view[b].apply(this.view,c)}}},change:function(){if(this._sc_isActive){var e=arguments.length,c=new Array(e);for(var d=0,a=e;d<a;d++){c[d]=arguments[d]}var b=this.name+"Changed";if(this.view[b]){this.view[b].apply(this.view,c)}}},cancel:function(){if(this._sc_isActive){this._sc_isActive=false;var e=arguments.length,c=new Array(e);for(var d=0,a=e;d<a;d++){c[d]=arguments[d]}var b=this.name+"Cancelled";if(this.view[b]){this.view[b].apply(this.view,c)}}},trigger:function(){var e=arguments.length,c=new Array(e);for(var d=0,a=e;d<a;d++){c[d]=arguments[d]}var b=this.name;if(this.view[b]){this.view[b].apply(this.view,c)}},touchSessionStarted:function(a){},touchSessionEnded:function(){},touchSessionCancelled:function(){},touchAddedToSession:function(b,a){return true},touchCancelledInSession:function(b,a){return true},touchEndedInSession:function(b,a){return true},touchesMovedInSession:function(a){return true}});sc_require("system/gesture");SC.PinchGesture=SC.Gesture.extend({_sc_isPinching:false,_sc_pinchAnchorD:null,_sc_pinchAnchorScale:null,name:"pinch",pinchDelay:500,_sc_cleanUpTouchSession:function(){if(this._sc_isPinching){this._sc_pinchingTimer.invalidate();this._sc_pinchingTimer=null;this._sc_lastPinchTime=null;this._sc_isPinching=false;this.end()}this._sc_pinchAnchorD=null},_sc_touchFinishedInSession:function(c,a){if(a.length>1){var b=c.averagedTouchesForView(this.view);this._sc_pinchAnchorD=b.d}else{this._sc_cleanUpTouchSession()}},_sc_triggerPinchEnd:function(){if(this._sc_lastPinchTime){var a=Date.now()-this._sc_lastPinchTime,b=this.get("pinchDelay");this._sc_pinchingTimer=SC.Timer.schedule({target:this,action:this._sc_triggerPinchEnd,interval:b-a});this._sc_lastPinchTime=null}else{this.end();this._sc_isPinching=false;this._sc_pinchingTimer=null}},touchAddedToSession:function(c,a){var b=c.averagedTouchesForView(this.view,true);this._sc_pinchAnchorD=b.d;return true},touchCancelledInSession:function(b,a){this._sc_touchFinishedInSession(b,a);return true},touchEndedInSession:function(b,a){this._sc_touchFinishedInSession(b,a);return true},touchesMovedInSession:function(b){if(b.length>1){var c=SC.Touch.averagedTouch(b);var a=this._sc_pinchAnchorD-c.d,f=Math.abs(a);if(f>0){if(!this._sc_isPinching){this.start();this._sc_pinchingTimer=SC.Timer.schedule({target:this,action:this._sc_triggerPinchEnd,interval:this.get("pinchDelay")});this._sc_isPinching=true}else{this._sc_lastPinchTime=Date.now()}var e=c.d/this._sc_pinchAnchorD,d=this._sc_pinchAnchorScale*e;this.trigger(d,b.length);this._sc_pinchAnchorD=c.d;this._sc_pinchAnchorScale=d}}return true},touchSessionCancelled:function(){this._sc_cleanUpTouchSession()},touchSessionEnded:function(){this._sc_cleanUpTouchSession()},touchSessionStarted:function(b){var a=this.view.get("layout");this._sc_pinchAnchorScale=a.scale==null?1:a.scale}});sc_require("system/gesture");SC.SWIPE_HORIZONTAL=[0,180];SC.SWIPE_VERTICAL=[90,-90];SC.SWIPE_ANY=null;SC.SWIPE_LEFT=[180];SC.SWIPE_RIGHT=[0];SC.SWIPE_UP=[-90];SC.SWIPE_DOWN=[90];SC.SwipeGesture=SC.Gesture.extend({_sc_lastAngle:null,_sc_lastDistance:null,_sc_numberOfTouches:0,_sc_swipeAnchorX:null,_sc_swipeAnchorY:null,_sc_swipeLastMovedAt:null,angles:function(b,c){var d=this.get("direction"),a=SC.SWIPE_HORIZONTAL;if(!SC.none(d)){return d}if(!SC.none(c)){a=c}return a}.property("direction").cacheable(),direction:SC.SWIPE_HORIZONTAL,name:"swipe",swipeDistance:40,swipeVelocity:0.5,tolerance:15,_sc_cleanUpTouchSession:function(a){this._sc_numberOfTouches=0;this._sc_lastDistance=null;this._sc_swipeStartedAt=null;this._sc_lastAngle=null;this._sc_swipeAnchorX=null;this._sc_swipeAnchorY=null},_sc_swipeTooSlow:function(){this._sc_cleanUpTouchSession()},touchAddedToSession:function(c,a){var b=c.averagedTouchesForView(this.view,true);this._sc_swipeAnchorX=b.x;this._sc_swipeAnchorY=b.y;return true},touchCancelledInSession:function(b,a){return true},touchEndedInSession:function(b,a){return true},_sc_testAngle:function(b,c,k,f){var g=k>=0,i=!g?Math.abs(k):k,a=i+f,j=i-f,e=false;if(j<=b&&b<=a){var h=a>=0&&a<=180,d=j>=0;e=h===d?c===g:true}return e},touchesMovedInSession:function(g){var n=this.get("direction"),a=g[0].averagedTouchesForView(this.view),r=a.x-this._sc_swipeAnchorX,j=a.y-this._sc_swipeAnchorY,m=Math.atan2(j,r)*(180/Math.PI),t=Math.abs(m),u=m>=0,p=this.get("tolerance"),c=null,s;if(n===null){s=this._sc_lastAngle;if(s!==null){var e=this._sc_testAngle(t,u,s,p);if(e){c=s}else{c=m}}else{c=m}}else{for(var o=0,q=n.length;o<q;o++){s=n[o];if(this._sc_testAngle(t,u,s,p)){c=s;break}}}if(c!==null){if(this._sc_lastAngle===c){var l=Math.abs(r),k=Math.abs(j),b=Date.now(),d,h;d=Math.pow(l*l+k*k,0.5);h=d/(b-this._sc_swipeStartedAt);var f=this.get("swipeVelocity");if(h<f){this._sc_lastAngle=null;this._sc_swipeAnchorX=a.x;this._sc_swipeAnchorY=a.y;this._sc_lastDistance=0;this._sc_swipeStartedAt=null}else{this._sc_lastDistance=d;this._sc_swipeLastMovedAt=Date.now()}}else{this._sc_lastAngle=c;this._sc_swipeStartedAt=Date.now();this._sc_numberOfTouches=g.length}}else{this._sc_lastAngle=null;this._sc_swipeAnchorX=a.x;this._sc_swipeAnchorY=a.y;this._sc_lastDistance=0;this._sc_swipeStartedAt=null}return true},touchSessionCancelled:function(){this._sc_cleanUpTouchSession(true)},touchSessionEnded:function(){var a=(Date.now()-this._sc_swipeLastMovedAt)<200;if(this._sc_lastAngle!==null&&this._sc_lastDistance>this.get("swipeDistance")&&a){this.trigger(this._sc_lastAngle,this._sc_numberOfTouches)}this._sc_cleanUpTouchSession(false)},touchSessionStarted:function(a){this._sc_swipeAnchorX=a.pageX;this._sc_swipeAnchorY=a.pageY}});sc_require("system/gesture");SC.TapGesture=SC.Gesture.extend({_sc_firstTouchAddedAt:null,_sc_firstTouchEndedAt:null,_sc_isTapping:false,_sc_numberOfTouches:0,_sc_tapStartTimer:null,name:"tap",tapLengthDelay:250,tapStartDelay:150,tapWiggle:10,touchUnityDelay:75,_sc_calculateDragDistance:function(a){return Math.sqrt(Math.pow(a.pageX-a.startX,2)+Math.pow(a.pageY-a.startY,2))},_sc_cleanUpTouchSession:function(a){if(this._sc_isTapping){if(a){this.cancel()}else{this.end()}this._sc_isTapping=false}this._sc_tapStartTimer.invalidate();this._sc_numberOfTouches=0;this._sc_tapStartTimer=this._sc_firstTouchAddedAt=this._sc_firstTouchEndedAt=null},_sc_triggerTapStart:function(){this.start();this._sc_isTapping=true},touchAddedToSession:function(d,a){var c,b;b=Date.now()-this._sc_firstTouchAddedAt;c=b<this.get("touchUnityDelay");return c},touchCancelledInSession:function(b,a){return true},touchEndedInSession:function(c,a){var b;this._sc_numberOfTouches+=1;if(this._sc_firstTouchEndedAt===null){this._sc_firstTouchEndedAt=Date.now();b=this._sc_firstTouchEndedAt-this._sc_firstTouchAddedAt<this.get("tapLengthDelay")}else{b=Date.now()-this._sc_firstTouchEndedAt<this.get("touchUnityDelay")}return b},touchesMovedInSession:function(b){var c=true;for(var d=0,a=b.length;d<a;d++){var f=b[d],e=this._sc_calculateDragDistance(f)>this.get("tapWiggle");if(e){c=false;break}}return c},touchSessionCancelled:function(){this._sc_cleanUpTouchSession(true)},touchSessionEnded:function(){this.trigger(this._sc_numberOfTouches);this._sc_cleanUpTouchSession(false)},touchSessionStarted:function(a){this._sc_firstTouchAddedAt=Date.now();this._sc_tapStartTimer=SC.Timer.schedule({target:this,action:this._sc_triggerTapStart,interval:this.get("tapStartDelay")})}});SC.hashesForLocale("fr","inflectionConstants",{PLURAL:[[/(bijou|caillou|chou|genou|hibou|joujou|pou|au|eu|eau)$/i,"$1x"],[/(bleu|émeu|landau|lieu|pneu|sarrau)$/i,"$1s"],[/al$/i,"aux"],[/ail$/i,"ails"],[/(b|cor|ém|gemm|soupir|trav|vant|vitr)ail$/i,"$1aux"],[/(s|x|z)$/i,"$1"],[/$/,"s"]],SINGULAR:[[/(bijou|caillou|chou|genou|hibou|joujou|pou|au|eu|eau)x$/i,"$1"],[/(journ|chev)aux$/i,"$1al"],[/ails$/i,"ail"],[/(b|cor|ém|gemm|soupir|trav|vant|vitr)aux$/i,"$1ail"],[/s$/i,""]],IRREGULAR:[["monsieur","messieurs"],["madame","mesdames"],["mademoiselle","mesdemoiselles"]],UNCOUNTABLE:[]});SC.AutoMixin={autoMixins:[],createChildView:function(b,c){if(!b.isClass){c=b}else{if(!c){c={}}else{c=SC.clone(c)}}c.owner=c.parentView=this;if(!c.page){c.page=this.page}if(b.isClass){c.createdByParent=true;var a=SC.clone(this.get("autoMixins"));a.push(c);b=b.create.apply(b,a)}return b}};SC.mixin({_copy_computed_props:["maxWidth","maxHeight","paddingLeft","paddingRight","paddingTop","paddingBottom","fontFamily","fontSize","fontStyle","fontWeight","fontVariant","lineHeight","whiteSpace","letterSpacing","wordWrap"],stringFromLayout:function(e){var d=["maxHeight","maxWidth","minHeight","minWidth","centerY","centerX","width","height","bottom","right","top","left","zIndex","opacity","border","borderLeft","borderRight","borderTop","borderBottom","rotateX","rotateY","rotateZ","scale"],a=[],c,b=d.length;while(--b>=0){c=d[b];if(e.hasOwnProperty(c)){a.push(c+":"+e[c])}}return"{ "+a.join(", ")+" }"},heightForString:function(h,c,b,a,g){var e=this._heightCalcElement,f,i;if(!g){h=SC.RenderContext.escapeHTML(h)}f=(a&&SC.typeOf(a)===SC.T_ARRAY)?a.join(" "):"";if(!c){c=100}if(!e){e=this._heightCalcElement=document.createElement("div");document.body.insertBefore(e,null)}b=b+"; width: "+c+"px; left: "+(-1*c)+"px; position: absolute";var d=SC.$(e);d.attr("style",b);if(f!==""){d.attr("class",f)}e.innerHTML=h;i=e.clientHeight;e=null;return i},prepareStringMeasurement:function(o,a){var k=this._metricsCalculationElement,h,c,d;h=SC.A(a).join(" ");if(!k){var n=document.createElement("div");n.style.cssText="position:absolute; left:-10010px; top:-10px;width:10000px; height:0px; overflow:hidden;visibility:hidden;";k=this._metricsCalculationElement=document.createElement("div");n.appendChild(k);document.body.insertBefore(n,null)}d=SC.$(k);if(SC.typeOf(o)!=SC.T_STRING){var g=null;if(document.defaultView&&document.defaultView.getComputedStyle){g=document.defaultView.getComputedStyle(o,null)}else{g=o.currentStyle}var m=this._copy_computed_props;for(var j=0;j<m.length;j++){var b=m[j],f=g[b];k.style[b]=f}var l=k.style;if(l.font===""){var e="";if(l.fontStyle){e+=l.fontStyle+" "}if(l.fontVariant){e+=l.fontVariant+" "}if(l.fontWeight){e+=l.fontWeight+" "}if(l.fontSize){e+=l.fontSize}else{e+="10px"}if(l.lineHeight){e+="/"+l.lineHeight}e+=" ";if(l.fontFamily){e+=l.fontFamily}else{l+="sans-serif"}k.style.font=e}SC.mixin(k.style,{left:"0px",top:"0px",position:"absolute",bottom:"auto",right:"auto",width:"auto",height:"auto"});g=null}else{c=o;d.attr("style",c+"; position:absolute; left: 0px; top: 0px; bottom: auto; right: auto; width: auto; height: auto;")}k.className=h;k=null},teardownStringMeasurement:function(){var a=this._metricsCalculationElement;a.innerHTML="";a.className="";a.setAttribute("style","");a=null},measureString:function(c,b){var d=this._metricsCalculationElement,e=0;if(!d){throw new Error("measureString requires a string measurement environment to be set up. Did you mean metricsForString?")}if(b){d.innerHTML=c}else{if(typeof d.innerText!="undefined"){d.innerText=c}else{d.textContent=c}}if(SC.browser.isIE){e=1}var a={width:d.clientWidth+e,height:d.clientHeight};if(SC.browser.isMozilla){a.width+=1}d=null;return a},metricsForString:function(c,d,e,b){SC.prepareStringMeasurement(d,e);var a=SC.measureString(c,b);SC.teardownStringMeasurement();return a}});sc_require("system/utils/string_measurement");SC.AutoResize={shouldAutoResize:YES,shouldMeasureSize:YES,shouldCacheSizes:NO,shouldResizeWidth:YES,shouldResizeHeight:NO,measuredSize:{width:0,height:0},maxWidth:null,maxHeight:null,shouldAutoFitText:NO,autoFitDiscreteFontSizes:NO,minFontSize:12,maxFontSize:20,calculatedFontSize:20,fontPropertyDidChange:function(){if(this.get("shouldAutoFitText")){this.invokeLast(this.fitTextToFrame)}}.observes("shouldAutoFitText","minFontSize","maxFontSize","measuredSize"),measuredSizeDidChange:function(){var c=this.get("measuredSize"),b=c.width,h=c.height,g,a,d=this.get("autoResizePadding")||0,f=this.get("maxWidth"),e=this.get("maxHeight");if(SC.typeOf(d)===SC.T_NUMBER){g=a=d}else{g=d.height;a=d.width}h+=g;b+=a;if(this.get("shouldAutoResize")){if(this.get("shouldResizeWidth")){if(f&&b>f){b=f}this.set("calculatedWidth",b);this.adjust("width",b)}if(this.get("shouldResizeHeight")){if(e&&h>e){h=e}this.set("calculatedHeight",h);this.adjust("height",h)}}}.observes("shouldAutoResize","measuredSize","autoResizePadding","maxWidth","maxHeight","shouldResizeWidth","shouldResizeHeight"),batchResizeId:null,scheduleMeasurement:function(){var a=this.get("batchResizeId");if(!this.get("shouldMeasureSize")||!this.get("isVisibleInWindow")||(this.get("autoResizeText")===this._lastMeasuredText&&a===this._lastMeasuredId)){return}SC.AutoResizeManager.scheduleMeasurementForView(this,a)}.observes("isVisibleInWindow","shouldMeasureSize","autoResizeText","batchResizeId"),_lastMeasuredText:null,_cachedMetrics:function(c,d){if(!this.get("shouldCacheSizes")){return}var b=SC.cacheSlotFor(this.get("batchResizeId")||this),a=this.get("autoResizeText");if(d){b[a]=d}else{d=b[a]}return d}.property("shouldCacheSizes","autoResizeText","batchResizeId").cacheable(),measureSize:function(d){var g,e=this.get("autoResizeLayer"),c=this.get("autoResizeText"),b=!this.get("escapeHTML"),f=this.get("batchResizeId"),a=this.get("_cachedMetrics");if(!e){return}if(a){g=a}else{if(SC.none(c)||c===""){g={width:0,height:0}}else{if(d){g=SC.measureString(c,b)}else{this.prepareLayerForStringMeasurement(e);g=SC.metricsForString(c,e,this.get("classNames"),b)}}}this.set("measuredSize",g);if(this.get("shouldCacheSizes")){this.setIfChanged("_cachedMetrics",g)}this._lastMeasuredText=c;this._lastMeasuredId=f;return g},prepareLayerForStringMeasurement:function(a){var b=this.get("maxFontSize");if(this.get("shouldAutoFitText")&&this.get("calculatedFontSize")!==b){a.style.fontSize=b+"px"}if(!this.get("shouldResizeWidth")){a.style.maxWidth=$(a).outerWidth()+"px"}},viewDidResize:function(a){a();this.fontPropertyDidChange()}.enhance(),fitTextToFrame:function(){var q=this.get("autoResizeLayer");if(!q){return}var c=this.get("maxFontSize"),d=this.get("minFontSize");this.prepareLayerForStringMeasurement(q);var e=this.get("frame"),f=this.get("autoResizePadding")||0,j=e.width-1,g=e.height-1,p=this.get("measuredSize"),a=p.width,r=p.height,h;if(SC.typeOf(f)===SC.T_NUMBER){j-=f;g-=f}else{j-=f.width;g-=f.height}if(a<=j&&r<=g){return}if(this.get("autoFitDiscreteFontSizes")){h=d}else{var b=j/a,i=g/r,l=Math.floor(c*Math.min(b,i)),o=this.get("classNames"),n=!this.get("escapeHTML"),k=this.get("autoResizeText"),m;l=h=Math.min(c,Math.max(d,l));q.style.fontSize=l+"px";m=SC.metricsForString(k,q,o,n);if(m.width>j||m.height>g){for(l=l-1;l>=d;l--){q.style.fontSize=l+"px";m=SC.metricsForString(k,q,o,n);h=l;if(m.width<=j&&m.height<=g){break}}}else{if(m.width<j||m.height<g){for(l=l+1;l<=c;l++){q.style.fontSize=l+"px";m=SC.metricsForString(k,q,o,n);if(m.width<=j&&m.height<=g){h=l}if(m.width>=j||m.height>=g){break}}}}}q.style.fontSize=h+"px";this.set("calculatedFontSize",h)},applyAttributesToContext:function(b,a){b(a);if(this.get("shouldAutoFitText")){a.setStyle("font-size",this.get("calculatedFontSize")+"px")}}.enhance(),didCreateLayer:function(a){a();this.scheduleMeasurement()}.enhance(),_transitionIn:function(b,c){var a=this.get("layout").opacity||1;this.adjust("opacity",0);this.invokeNext(function(){this.adjust("opacity",a);b(c)})}.enhance()};SC.AutoResizeManager={measurementQueue:SC.CoreSet.create(),scheduleMeasurementForView:function(a){this.measurementQueue.add(a);SC.RunLoop.currentRunLoop.invokeOnce(this.doBatchResize)},cancelMeasurementForView:function(a,b){this.measurementQueue.remove(a)},doBatchResize:function(){if(this!==SC.AutoResizeManager){return SC.AutoResizeManager.doBatchResize()}var b,d,f,g=this.measurementQueue,h,c,e,a;while((a=g.get("length"))>0){h=NO;b=g[a-1].get("batchResizeId");for(e=a-1;e>=0;--e){d=g[e];if(d.get("batchResizeId")!==b){continue}if(d.get("isVisibleInWindow")&&d.get("shouldMeasureSize")&&(f=d.get("autoResizeLayer"))){c=d.get("autoResizeText");if(!SC.none(c)&&c!==""&&!d.get("_cachedMetrics")&&!h){d.prepareLayerForStringMeasurement(f);SC.prepareStringMeasurement(f,d.get("classNames"));h=YES}d.measureSize(YES)}g.remove(d);if(!b){break}}if(h){SC.teardownStringMeasurement()}}}};if(SC.Button){SC.Button.initMixin=function(){throw new Error("SC.Button is deprecated as a mixin and is now a subclass of SC.TemplateView. Subclass SC.ButtonView instead.")}}SC.ContentDisplay={concatenatedProperties:"contentDisplayProperties",contentDisplayProperties:[],initMixin:function(){this._display_contentDidChange()},destroyMixin:function(){if(!this._display_content){return}this._display_stopObservingContent(this._display_content);this._display_content=null},_display_beginObservingContent:function(a){var b=this._display_contentPropertyDidChange;if(SC.isArray(a)){a.invoke("addObserver","*",this,b)}else{if(a.addObserver){a.addObserver("*",this,b)}}},_display_stopObservingContent:function(a){var b=this._display_contentPropertyDidChange;if(SC.isArray(a)){a.invoke("removeObserver","*",this,b)}else{if(a.removeObserver){a.removeObserver("*",this,b)}}},_display_contentDidChange:function(d,a,c){if((c=this.get("content"))===this._display_content){return}var b=this._display_content;if(b){this._display_stopObservingContent(b)}b=this._display_content=c;if(b){this._display_beginObservingContent(b)}this.displayDidChange()}.observes("content"),_display_contentPropertyDidChange:function(e,c,d,b){if(c==="*"){this.displayDidChange()}else{var a=this.get("contentDisplayProperties");if(a&&a.indexOf(c)>=0){this.displayDidChange()}}}};SC.ContentValueSupport={hasContentValueSupport:YES,initMixin:function(){this._control_contentKeysDidChange()},destroyMixin:function(){this._cleanup_old_observers();this._cleanup_old_content_observers()},value:null,content:null,contentKeys:null,_default_contentKeys:{contentValueKey:"value"},contentValueKey:null,contentPropertyDidChange:function(c,b){var a=this.get("contentKeys");if(a){var d;for(d in a){if(b===this.getDelegateProperty(d,this,this.get("displayDelegate"),a)){return this.updatePropertyFromContent(a[d],b,d,c)}else{if(b==="*"){this.updatePropertyFromContent(a[d],b,d,c)}}}}else{return this.updatePropertyFromContent("value",b,"contentValueKey",c)}},updatePropertyFromContent:function(f,c,e,d){var a,b;if(e===undefined){e="content"+f.capitalize()+"Key"}if(this[e]){e=this.get(e)}else{if((a=this.get("displayDelegate"))&&(b=a[e])){e=a.get?a.get(e):b}else{return this}}if(c==="*"||c===e){if(d===undefined){d=this.get("content")}if(d){b=d.get?d.get(e):d[e]}else{b=null}this.setIfChanged(f,b)}return this},updateContentWithValueObserver:function(d,a){var f=this._reverseContentKeys;if(!a||a==="*"){for(a in f){this.updateContentWithValueObserver(this,a)}}var c=this.get(a);var b=this.get("content"),e=this.getDelegateProperty(f[a],this,this.displayDelegate);if(!e||!b){return this}if(typeof b.setIfChanged===SC.T_FUNCTION){b.setIfChanged(e,c)}else{if(b[e]!==c){b[e]=c}}},_control_content:null,_old_contentValueKeys:null,_old_contentKeys:null,_control_contentDidChange:function(g,b){this._cleanup_old_content_observers();var c=this.get("content"),a=this.get("contentKeys"),h,e=this._old_contentValueKeys,d=this.contentPropertyDidChange;if(c&&c.addObserver){if(a){if(!e){e=SC.CoreSet.create()}for(h in a){h=this.getDelegateProperty(h,this,this.get("displayDelegate"));if(h){c.addObserver(h,this,d);e.add(h)}}}else{h=this.getDelegateProperty("contentValueKey",this,this.get("displayDelegate"));if(h){c.addObserver(h,this,d);if(e){e.add(h)}else{e=h}}}}b=(!b||b==="content")?"*":this.get(b);if(b){this.contentPropertyDidChange(c,b)}this._control_content=c;this._old_contentValueKeys=e}.observes("content"),_control_contentKeysDidChange:function(){var c,b={},a=this.get("contentKeys")||this._default_contentKeys,g,e=this._control_contentDidChange,d=this.updateContentWithValueObserver;this._cleanup_old_observers();for(c in a){g=a[c];b[g]=c;this.addObserver(g,this,d);this.addObserver(c,this,e)}this._reverseContentKeys=b;this._old_contentKeys=a;this._control_contentDidChange()}.observes("contentKeys"),_cleanup_old_content_observers:function(){var b=this._control_content,g=this._old_contentValueKeys,e=SC.typeOf(g),d=this.contentPropertyDidChange,h;if(b&&b.removeObserver&&g){if(e===SC.T_STRING){b.removeObserver(g,this,d);this._old_contentValueKeys=g=null}else{var c,a=g.get("length");for(c=0;c<a;c++){h=g[c];b.removeObserver(h,this,d)}g.clear()}}},_cleanup_old_observers:function(){var a=this._old_contentKeys,d=this._control_contentDidChange,c=this.updateContentWithValueObserver,e,b;for(b in a){e=a[b];this.removeObserver(e,this,c);this.removeObserver(b,this,d)}}};sc_require("mixins/content_value_support");sc_require("system/string");SC.AUTO_CONTROL_SIZE="__AUTO__";SC.JUMBO_CONTROL_SIZE="sc-jumbo-size";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=SC.mixin(SC.clone(SC.ContentValueSupport),{isControl:YES,isSelected:NO,isSelectedBindingDefault:SC.Binding.oneWay().bool(),isActive:NO,isActiveBindingDefault:SC.Binding.oneWay().bool(),fieldKey:null,fieldLabel:null,errorLabel:function(){var a=this.get("fieldLabel"),d,c,b;if(a){return a}d=this.get("fieldKey")||this.constructor.toString();c=d?SC.String.capitalize(SC.String.humanize(d)):"";b=SC.String.locWithDefault("FieldKey."+d,c);return SC.String.locWithDefault("ErrorLabel."+d,b)}.property("fieldLabel","fieldKey").cacheable(),controlSize:SC.REGULAR_CONTROL_SIZE,displayProperties:["isSelected","isActive","controlSize"],_CONTROL_TMP_CLASSNAMES:{},renderMixin:function(b,g){var d=this.get("isSelected"),c=!this.get("isEnabledInPane"),e=this._CONTROL_TMP_CLASSNAMES;e.mixed=d===SC.MIXED_STATE;e.sel=d&&(d!==SC.MIXED_STATE);e.active=this.get("isActive");var f=this.get("controlSize");if(!f){f=SC.REGULAR_CONTROL_SIZE}if(g){b.setClass(e);if(!this.get("renderDelegate")){b.addClass(f)}}else{b.$().setClass(e);if(!this.get("renderDelegate")){b.$().addClass(f)}}if(!g&&this.$input){var a=this.$input();if(a.attr("type")!=="radio"){this.$input().attr("disabled",c)}}}});SC.Editable={isEditable:NO,isEditing:NO,beginEditing:function(){if(!this.get("isEditable")){return NO}if(this.get("isEditing")){return YES}this.beginPropertyChanges();this.set("isEditing",YES);this.becomeFirstResponder();this.endPropertyChanges();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.ALIGN_JUSTIFY="justify";SC.FlowedLayout={isFlowedLayout:YES,layoutDirection:SC.LAYOUT_HORIZONTAL,autoResize:YES,shouldResizeWidth:YES,shouldResizeHeight:YES,align:SC.ALIGN_LEFT,canWrap:YES,defaultFlowSpacing:{left:0,bottom:0,top:0,right:0},flowPadding:{left:0,bottom:0,right:0,top:0},_scfl_validFlowPadding:function(){var b=this.get("flowPadding")||{},a={};a.left=b.left||0;a.top=b.top||0;a.bottom=b.bottom||0;a.right=b.right||0;return a}.property("flowPadding").cacheable(),concatenatedProperties:["childMixins"],initMixin:function(){this._scfl_tileOnce();this.addObserver("childViews.[]",this,this._scfl_childViewsDidChange)},_scfl_childViewsDidChange:function(a){this._scfl_tileOnce()},_scfl_layoutPropertyDidChange:function(a){this._scfl_tileOnce()}.observes("layoutDirection","align","flowPadding","canWrap","defaultFlowSpacing","isVisibleInWindow"),layoutDidChangeFor:function(g){var b=g._scfl_lastLayout,a=g.get("layout"),d=g.get("frame");if(!b){return arguments.callee.base.apply(this,arguments)}var e=YES;if(b.left&&b.left!==a.left){e=NO}else{if(b.top&&b.top!==a.top){e=NO}else{if(!g.get("fillWidth")&&b.width&&b.width!==a.width){e=NO}else{if(!b.width&&!g.get("fillWidth")&&d.width!==g._scfl_lastFrame.width){e=NO}else{if(!g.get("fillHeight")&&b.height&&b.height!==a.height){e=NO}else{if(!b.height&&!g.get("fillHeight")&&d.height!==g._scfl_lastFrame.height){e=NO}}}}}}if(e){return arguments.callee.base.apply(this,arguments)}this._scfl_tileOnce();arguments.callee.base.apply(this,arguments)},observeChildLayout:function(a){if(a._scfl_isBeingObserved){return}a._scfl_isBeingObserved=YES;a.addObserver("flowSpacing",this,"_scfl_tileOnce");a.addObserver("isVisible",this,"_scfl_tileOnce");a.addObserver("useAbsoluteLayout",this,"_scfl_tileOnce");a.addObserver("calculatedWidth",this,"_scfl_tileOnce");a.addObserver("calculatedHeight",this,"_scfl_tileOnce");a.addObserver("startsNewRow",this,"_scfl_tileOnce");a.addObserver("isSpacer",this,"_scfl_tileOnce");a.addObserver("maxSpacerLength",this,"_scfl_tileOnce");a.addObserver("fillWidth",this,"_scfl_tileOnce");a.addObserver("fillHeight",this,"_scfl_tileOnce")},unobserveChildLayout:function(a){a._scfl_isBeingObserved=NO;a.removeObserver("flowSpacing",this,"_scfl_tileOnce");a.removeObserver("isVisible",this,"_scfl_tileOnce");a.removeObserver("useAbsoluteLayout",this,"_scfl_tileOnce");a.removeObserver("calculatedWidth",this,"_scfl_tileOnce");a.removeObserver("calculatedHeight",this,"_scfl_tileOnce");a.removeObserver("startsNewRow",this,"_scfl_tileOnce");a.removeObserver("isSpacer",this,"_scfl_tileOnce");a.removeObserver("maxSpacerLength",this,"_scfl_tileOnce");a.removeObserver("fillWidth",this,"_scfl_tileOnce");a.removeObserver("fillHeight",this,"_scfl_tileOnce")},shouldIncludeChildInFlow:function(a,b){return b.get("isVisible")&&!b.get("useAbsoluteLayout")},flowSpacingForChild:function(a,b){var c=b.get("flowSpacing");if(SC.none(c)){c=this.get("defaultFlowSpacing")}if(SC.none(c)){c=0}if(SC.typeOf(c)===SC.T_NUMBER){c={left:c,right:c,bottom:c,top:c}}else{c.left=c.left||0;c.right=c.right||0;c.top=c.top||0;c.bottom=c.bottom||0}return c},flowSizeForChild:function(a,d){var c=d.get("calculatedWidth"),g=d.get("calculatedHeight"),i=this.get("layoutDirection"),e={},h=d.get("frame"),b=d.get("layout");d._scfl_lastFrame=h;if(c){e.width=c}else{e.width=b.width||h.width}if(g){e.height=g}else{e.height=b.height||h.height}if(d.get("isSpacer")){e.maxSpacerLength=d.get("maxSpacerLength");if(i===SC.LAYOUT_HORIZONTAL){e.width=b.minWidth||0}else{e.height=b.minHeight||0}}if(i===SC.LAYOUT_HORIZONTAL&&d.get("fillHeight")){e.height=b.minHeight||0}else{if(i===SC.LAYOUT_VERTICAL&&d.get("fillWidth")){e.width=b.minWidth||0}}return e},clippingFrame:function(){return{left:0,top:0,width:this.get("calculatedWidth"),height:this.get("calculatedHeight")}}.property("calculatedWidth","calculatedHeight"),_scfl_maxCollapsedRowLength:0,_scfl_totalCollapsedRowSize:0,_scfl_calculatedSizeDidChange:function(){if(this.get("autoResize")){if(this.get("layoutDirection")==SC.LAYOUT_VERTICAL){if(this.get("shouldResizeHeight")){this.adjust("minHeight",this.get("_scfl_maximumCollapsedRowLength"))}if(this.get("shouldResizeWidth")){this.adjust("minWidth",this.get("_scfl_totalCollapsedRowSize"))}}else{if(this.get("shouldResizeWidth")){this.adjust("minWidth",this.get("_scfl_maximumCollapsedRowLength"))}if(this.get("shouldResizeHeight")){this.adjust("minHeight",this.get("_scfl_totalCollapsedRowSize"))}}}}.observes("autoResize","shouldResizeWidth","_scfl_maximumCollapsedRowLength","_scfl_totalCollapsedRowSize","shouldResizeHeight"),_scfl_createPlan:function(){var e=this.get("layoutDirection"),a=this.get("_scfl_validFlowPadding"),d=this.get("frame");var c=(e===SC.LAYOUT_VERTICAL);var b={rows:undefined,maximumCollapsedRowLength:0,totalCollapsedRowSize:0,isVertical:e===SC.LAYOUT_VERTICAL,isHorizontal:e===SC.LAYOUT_HORIZONTAL,flowPadding:a,planStartPadding:a[c?"left":"top"],planEndPadding:a[c?"right":"bottom"],rowStartPadding:a[c?"top":"left"],rowEndPadding:a[c?"bottom":"right"],maximumRowLength:undefined,fitToPlanSize:undefined,align:this.get("align")};if(c){b.maximumRowLength=d.height-b.rowStartPadding-b.rowEndPadding;b.fitToPlanSize=d.width-b.planStartPadding-b.planEndPadding}else{b.maximumRowLength=d.width-b.rowStartPadding-b.rowEndPadding;b.fitToPlanSize=d.height-b.planStartPadding-b.planEndPadding}return b},_scfl_distributeChildrenIntoRows:function(d){var b=this.get("childViews"),a,g,c=b.length,e=d.isVertical,i=[],f;f=-1;g=0;while(g<c&&g!==f){f=g;var h={plan:d,rowLength:undefined,rowSize:undefined,shouldExpand:undefined,items:undefined,position:undefined};g=this._scfl_distributeChildrenIntoRow(b,g,h);i.push(h)}d.rows=i},_scfl_distributeChildrenIntoRow:function(e,m,i){var o,t=e.length,b=i.plan,g,a,d,p=[],k=0,l=b.isVertical,j,f,c,n=this.get("canWrap"),h=NO,q=0,s=i.plan.maximumRowLength;for(o=m;o<t;o++){g=e[o];h=h||(p.length>0&&g.get("startsNewRow"));if(!this.shouldIncludeChildInFlow(o,g)){continue}a=this.flowSizeForChild(o,g);d=this.flowSpacingForChild(o,g);a.width+=d.left+d.right;a.height+=d.top+d.bottom;f=a[l?"height":"width"];if(!SC.none(a.maxSpacerLength)){c=a.maxSpacerLength+(l?d.top+d.bottom:d.left+d.right)}j=a[l?"width":"height"];if((h||(n&&k+f>s))&&p.length>0){break}var u={child:g,itemLength:f,maxSpacerLength:c,itemSize:j,spacing:d,position:undefined,fillRow:l?g.get("fillWidth"):g.get("fillHeight"),isSpacer:g.get("isSpacer"),left:undefined,top:undefined,width:undefined,height:undefined};p.push(u);k+=f;q=Math.max(f,q)}i.rowLength=k;var r=n?q:i.rowLength;i.plan.maximumCollapsedRowLength=Math.max(r,i.plan.maximumCollapsedRowLength);i.items=p;return o},_scfl_positionChildrenInRows:function(d){var c=d.rows,b=c.length,a;for(a=0;a<b;a++){this._scfl_positionChildrenInRow(c[a])}},_scfl_positionChildrenInRow:function(m){var g=m.items,e=g.length,j,l,d,k=0,a=0,c,f=m.plan.align,i=YES,b=0,h=NO;for(j=0;j<e;j++){l=g[j];if(l.isSpacer){a+=l.child.get("spaceUnits")||1}}if(f===SC.ALIGN_JUSTIFY){a+=e-1}c=Math.max(0,m.plan.maximumRowLength-m.rowLength)/a;while(c>0){for(j=0;j<e;j++){l=g[j];if(l.isSpacer){l.itemLength+=c*(l.child.get("spaceUnits")||1);if(l.itemLength>l.maxSpacerLength){b+=l.itemLength-l.maxSpacerLength;l.itemLength=l.maxSpacerLength}else{h=YES}}}if(!h){break}c=Math.round(b/a);b=0}d=0;if(a===0&&(f===SC.ALIGN_RIGHT||f===SC.ALIGN_BOTTOM)){d=m.plan.maximumRowLength-m.rowLength}else{if(a===0&&(f===SC.ALIGN_CENTER||f===SC.ALIGN_MIDDLE)){d=(m.plan.maximumRowLength/2)-(m.rowLength/2)}}d+=m.plan.rowStartPadding;for(j=0;j<e;j++){l=g[j];if(!l.fillRow){i=NO}k=Math.max(l.itemSize,k);l.position=d;d+=l.itemLength;if(f===SC.ALIGN_JUSTIFY&&j<e-1){d+=c}}m.shouldExpand=e>0?i:NO;m.rowLength=d-m.plan.rowStartPadding;m.rowSize=k;m.plan.totalCollapsedRowSize+=m.rowSize},_scfl_positionRows:function(d){var i=d.rows,c=i.length,f,h,b,a=0,g=0,e;for(f=0;f<c;f++){if(i[f].shouldExpand){a++}g+=i[f].rowSize}e=d.fitToPlanSize-g;b=d.planStartPadding;for(f=0;f<c;f++){h=i[f];if(h.shouldExpand&&e>0){h.rowSize+=e/a;a--}h.position=b;b+=h.rowSize}},_scfl_applyPlan:function(h){var n=h.rows,b,c,m,e=0,j=0,g,a,d,l,f,k,i=h.isVertical;c=n.length;for(b=0;b<c;b++){m=n[b];e=Math.max(e,m.rowLength);j+=m.rowSize;g=m.items;d=g.length;for(a=0;a<d;a++){l=g[a];l.child.beginPropertyChanges();k=l.fillRow?m.rowSize:l.itemSize;f={left:l.spacing.left+(i?m.position:l.position),top:l.spacing.top+(i?l.position:m.position),width:i?k:l.itemLength,height:i?l.itemLength:k};f.width-=l.spacing.left+l.spacing.right;f.height-=l.spacing.top+l.spacing.bottom;this.applyPlanToView(l.child,f);l.child._scfl_lastLayout=f;l.child.endPropertyChanges()}}j+=h.planStartPadding+h.planEndPadding;e+=h.rowStartPadding+h.rowEndPadding;this.beginPropertyChanges();this.set("calculatedHeight",i?e:j);this.set("calculatedWidth",i?j:e);this.set("_scfl_maximumCollapsedRowLength",h.maximumCollapsedRowLength);this.set("_scfl_totalCollapsedRowSize",h.totalCollapsedRowSize);this.endPropertyChanges()},applyPlanToView:function(a,b){a.adjust(b)},_scfl_tileOnce:function(){this.invokeLast(this._scfl_tile)},_scfl_tile:function(){if(!this.get("isVisibleInWindow")){return}var f=this._scfl_createPlan();this._scfl_distributeChildrenIntoRows(f);this._scfl_positionChildrenInRows(f);this._scfl_positionRows(f);this._scfl_applyPlan(f);this.setIfChanged("numberOfRows",f.rows.length);var d=this._scfl_isObserving||SC.CoreSet.create(),c=this._scfl_isObserving=SC.CoreSet.create();var e=this.get("childViews"),b=e.length,a,g;for(a=0;a<b;a++){g=e[a];if(!d.contains(g)){this.observeChildLayout(g)}else{d.remove(g)}c.add(g)}b=d.length;for(a=0;a<b;a++){this.unobserveChildLayout(d[a])}},_scfl_frameDidChange:function(){var b=this.get("frame"),a=this._scfl_lastFrameSize||{};this._scfl_lastFrameSize=SC.clone(b);if(a.width==b.width&&a.height==b.height){return}this._scfl_tileOnce()}.observes("frame"),destroyMixin:function(){this.removeObserver("childViews.[]",this,this._scfl_childViewsDidChange);var c=this._scfl_isObserving;if(!c){return}var b=c.length,a;for(a=0;a<b;a++){this.unobserveChildLayout(c[a])}},reorder:function(b){if(!SC.typeOf(b)===SC.T_ARRAY){b=arguments}var c=b.length,d=this.childViews,a;this.beginPropertyChanges();while(c-->0){a=b[c];if(SC.typeOf(a)===SC.T_STRING){a=this.get(a)}d.removeObject(a);d.unshiftObject(a)}this.endPropertyChanges();this._scfl_childViewsDidChange();return this}};SC.Gesturable={_sc_interestedGestures:null,_sc_touchesInSession:null,acceptsMultitouch:true,concatenatedProperties:["gestures"],gestures:null,_sc_gestureTouchFinish:function(c,g){var a=this._sc_touchesInSession,d=a.indexOf(c);a.replace(d,1);var e=this._sc_interestedGestures,h,i;for(h=e.length-1;h>=0;h--){var b;i=e[h];if(g){b=i.touchCancelledInSession(c,a)}else{b=i.touchEndedInSession(c,a)}if(!b){i.touchSessionCancelled();e.replace(h,1)}}if(a.length===0){var f;for(h=0,f=e.length;h<f;h++){i=e[h];i.touchSessionEnded()}this._sc_interestedGestures.length=0}},initMixin:function(){this.createGestures()},createGestures:function(){var e=this.get("gestures"),b=e.length,c=[],a;for(a=0;a<b;a++){var d;if(SC.typeOf(e[a])===SC.T_STRING){d=this.get(e[a])}else{d=e[a]}if(!d){throw new Error("Developer Error: Could not find gesture named '"+e[a]+"' on view.")}if(d.isClass){d=d.create({view:this})}if(SC.typeOf(e[a])===SC.T_STRING){this[e[a]]=d}c.push(d)}this.set("gestures",c)},touchStart:function(a){return this.gestureTouchStart(a)},touchesDragged:function(a,b){this.gestureTouchesDragged(a,b)},touchEnd:function(a){this.gestureTouchEnd(a)},touchCancelled:function(a){this.gestureTouchCancelled(a)},gestureLostInterest:function(a){var c=this._sc_interestedGestures,b=c.indexOf(a);if(b>=0){a.touchSessionCancelled();c.replace(b,1)}},gestureTouchStart:function(e){var c=this._sc_interestedGestures,a=this._sc_touchesInSession,h=false,i;if(a===null){a=this._sc_touchesInSession=[];c=this._sc_interestedGestures=[]}if(a.length===0){var f=this.get("gestures"),g;for(i=0,g=f.length;i<g;i++){var j=f[i];j.touchSessionStarted(e);c.push(j)}h=true}else{for(i=c.length-1;i>=0;i--){var b=c[i],d;d=b.touchAddedToSession(e,a);if(d){h=true}else{b.touchSessionCancelled();c.replace(i,1)}}}if(h){a.push(e)}return h},gestureTouchesDragged:function(b,f){var g=this._sc_interestedGestures,a=this._sc_touchesInSession;for(var e=g.length-1;e>=0;e--){var d=g[e],c=d.touchesMovedInSession(a);if(!c){d.touchSessionCancelled();g.replace(e,1)}}},gestureTouchEnd:function(a){this._sc_gestureTouchFinish(a,false)},gestureTouchCancelled:function(a){this._sc_gestureTouchFinish(a,true)}};SC.InlineEditable={isInlineEditable:YES,isEditable:YES,exampleEditor:SC.InlineTextFieldView,isEditing:NO,inlineEditorDelegate:SC.InlineTextFieldDelegate,_editor:null,beginEditing:function(){var a;a=this.delegateFor("inlineEditorShouldBeginEditing",this.inlineEditorDelegate);if(a&&!a.inlineEditorShouldBeginEditing(this,this.get("value"))){return NO}this._editor=this.invokeDelegateMethod(this.inlineEditorDelegate,"acquireEditor",this);if(this._editor){return this._editor.beginEditing(this)}else{return NO}},commitEditing:function(){return this._editor?this._editor.commitEditing():NO},discardEditing:function(){return this._editor?this._editor.discardEditing():NO},inlineEditorShouldBeginEditing:function(){return !this.get("isEditing")&&this.get("isEditable")},inlineEditorWillBeginEditing:function(b,c,a){b.set("value",this.get("value"))},inlineEditorDidBeginEditing:function(b,c,a){this.set("isEditing",YES)},inlineEditorWillCommitEditing:function(b,c,a){if(this.inlineEditorWillEndEditing){this.inlineEditorWillEndEditing(b,c)}},inlineEditorDidCommitEditing:function(b,c,a){a.setIfChanged("value",c);if(this.inlineEditorDidEndEditing){this.inlineEditorDidEndEditing(b,c)}this._endEditing()},inlineEditorWillDiscardEditing:function(b,a){if(this.inlineEditorWillEndEditing){this.inlineEditorWillEndEditing(b,this.get("value"))}},inlineEditorDidDiscardEditing:function(b,a){if(this.inlineEditorDidEndEditing){this.inlineEditorDidEndEditing(b,this.get("value"))}this._endEditing()},_endEditing:function(){if(this._editor){this.invokeDelegateMethod(this.inlineEditorDelegate,"releaseEditor",this._editor);this._editor=null}this.set("isEditing",NO)}};SC.InlineEditor={isInlineEditor:YES,isEditing:NO,inlineEditorDelegate:null,_target:null,beginEditing:function(b){if(this.get("isEditing")||!b||!b.isInlineEditable){return NO}var a,c;c=this._target=b;a=this.delegateFor("inlineEditorWillBeginEditing",this.inlineEditorDelegate,c);if(a){a.inlineEditorWillBeginEditing(this,this.get("value"),c)}this.set("isEditing",YES);this.invokeLast(this._callDidBegin);this._didBeginInvoked=YES;return YES},_callDidBegin:function(){if(!this.get("isEditing")){return NO}this._didBeginInvoked=NO;var b=this._target,a;a=this.delegateFor("inlineEditorDidBeginEditing",this.inlineEditorDelegate,b);if(a){a.inlineEditorDidBeginEditing(this,this.get("value"),b)}},commitEditing:function(){if(!this.get("isEditing")){return NO}if(this._didBeginInvoked){this._callDidBegin()}var a,b=this._target;a=this.delegateFor("inlineEditorShouldCommitEditing",this.inlineEditorDelegate,b);if(a&&!a.inlineEditorShouldCommitEditing(this,this.get("value"),b)){return NO}a=this.delegateFor("inlineEditorWillCommitEditing",this.inlineEditorDelegate,b);if(a){a.inlineEditorWillCommitEditing(this,this.get("value"),b)}this._endEditing();a=this.delegateFor("inlineEditorDidCommitEditing",this.inlineEditorDelegate,b);if(a){a.inlineEditorDidCommitEditing(this,this.get("value"),b)}return YES},discardEditing:function(){if(!this.get("isEditing")){return NO}if(this._didBeginInvoked){this._callDidBegin()}var a,b=this._target;a=this.delegateFor("inlineEditorShouldDiscardEditing",this.inlineEditorDelegate,b);if(a&&!a.inlineEditorShouldDiscardEditing(this,b)){return NO}a=this.delegateFor("inlineEditorWillDiscardEditing",this.inlineEditorDelegate,b);if(a){a.inlineEditorWillDiscardEditing(this,b)}this._endEditing();a=this.delegateFor("inlineEditorDidDiscardEditing",this.inlineEditorDelegate,b);if(a){a.inlineEditorDidDiscardEditing(this,b)}return YES},_endEditing:function(){this.set("isEditing",NO);this._target=null}};SC.InlineEditorDelegate={acquireEditor:function(a){},releaseEditor:function(a){},inlineEditorShouldBeginEditing:function(a,b){},inlineEditorWillBeginEditing:function(b,c,a){},inlineEditorDidBeginEditing:function(b,c,a){},inlineEditorShouldCommitEditing:function(b,c,a){},inlineEditorWillCommitEditing:function(b,c,a){},inlineEditorDidCommitEditing:function(b,c,a){},inlineEditorShouldDiscardEditing:function(b,a){},inlineEditorWillDiscardEditing:function(b,a){},inlineEditorDidDiscardEditing:function(b,a){},inlineEditorWillEndEditing:function(b,c,a){},inlineEditorDidEndEditing:function(b,c,a){}};SC.SCALE_NONE="none";SC.FILL="fill";SC.FILL_PROPORTIONALLY=SC.BEST_FILL="best-fill";SC.BEST_FIT="best-fit";SC.BEST_FIT_DOWN_ONLY="best-fit-down";SC.InnerFrame={align:SC.ALIGN_CENTER,innerFrameForSize:function(a,c,h,b){var e=this.get("align"),d=this.get("scale"),g,f,i;i={x:0,y:0,width:h,height:b};if(d===SC.FILL){return i}g=h/a;f=b/c;switch(d){case SC.BEST_FILL:d=g>f?g:f;break;case SC.BEST_FIT:d=g<f?g:f;break;case SC.BEST_FIT_DOWN_ONLY:if((a>h)||(c>b)){d=g<f?g:f}else{d=1}break;case SC.SCALE_NONE:d=1;break;default:if(isNaN(window.parseFloat(d))||(window.parseFloat(d)<=0)){SC.Logger.warn("SC.InnerFrame: The scale '%@' was not understood.  Scale must be one of SC.FILL, SC.BEST_FILL, SC.BEST_FIT, SC.BEST_FIT_DOWN_ONLY or a positive number greater than 0.00.".fmt(d));return i}}a*=d;c*=d;i.width=Math.round(a);i.height=Math.round(c);switch(e){case SC.ALIGN_LEFT:i.x=0;i.y=(b/2)-(c/2);break;case SC.ALIGN_RIGHT:i.x=h-a;i.y=(b/2)-(c/2);break;case SC.ALIGN_TOP:i.x=(h/2)-(a/2);i.y=0;break;case SC.ALIGN_BOTTOM:i.x=(h/2)-(a/2);i.y=b-c;break;case SC.ALIGN_TOP_LEFT:i.x=0;i.y=0;break;case SC.ALIGN_TOP_RIGHT:i.x=h-a;i.y=0;break;case SC.ALIGN_BOTTOM_LEFT:i.x=0;i.y=b-c;break;case SC.ALIGN_BOTTOM_RIGHT:i.x=h-a;i.y=b-c;break;default:i.x=(h/2)-(a/2);i.y=(b/2)-(c/2)}return i},scale:SC.FILL};SC.StaticLayout={hasStaticLayout:YES,initMixin:function(){}};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(c){var a=SC.VALIDATE_OK;if(this._validator){var b=this.get("ownerForm");if(c){a=this._validator.validatePartial(b,this);if((a==SC.VALIDATE_NO_CHANGE)&&(this._validator.validateChange(b,this)==SC.VALIDATE_OK)){a=SC.VALIDATE_OK}}else{a=this._validator.validateChange(b,this)}}return a},performValidateSubmit:function(){return this._validator?this._validator.validateSubmit(this.get("ownerForm"),this):SC.VALIDATE_OK},performValidateKeyDown:function(a){var b=a.getCharString();if(!b){return YES}return this._validator?this._validator.validateKeyDown(this.get("ownerForm"),this,b):YES},validatorObject:function(){return this._validator}.property(),validateSubmit:function(){return this.performValidateSubmit()},objectForFieldValue:function(b,a){return this._validator?this._validator.objectForFieldValue(b,this.get("ownerForm"),this):b},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");var b=SC.Validator.findFor(a,this,this.get("validator"));if(b!=this._validator){this.propertyWillChange("validatorObject");if(this._validator){this._validator.detachFrom(a,this)}this._validator=b;if(this._validator){this._validator.attachTo(a,this)}this.propertyDidChange("validatorObject")}}.observes("validator","ownerForm")};SC.RenderDelegate={create:function(){var c=SC.beget(this);var b,a=arguments.length;for(b=0;b<a;b++){c.mixin(arguments[b])}return c},reopen:function(b){var c,a;for(c in b){a=b[c];if(!b.hasOwnProperty(c)){continue}if(typeof a==="function"&&a!==this[c]){a.base=this[c]||SC.K}if(a&&a.isEnhancement&&a!==this[c]){a=SC._enhance(this[c]||SC.K,a)}this[c]=a}},get:function(a){return this[a]},getPropertyFor:function(b,a){if(this[a+"For"]){return this[a+"For"](b,a)}return this[a]},className:undefined,render:function(b,a){},update:function(b,a){}};SC.RenderDelegate.extend=SC.RenderDelegate.create;SC.RenderDelegate.mixin=SC.RenderDelegate.reopen;sc_require("render_delegates/render_delegate");SC.BaseTheme.canvasImageRenderDelegate=SC.RenderDelegate.create({className:"canvasImage",render:function(f,b){var d=f.get("width")||0,a=f.get("height")||0,c=f.get("type")||SC.IMAGE_TYPE_URL,e=f.get("value");if(e&&c===SC.IMAGE_TYPE_CSS_CLASS){b.addClass(e);f.renderState._last_class=e}b.setAttr("width",d);b.setAttr("height",a)},update:function(o,f){var p=f[0],l=o.get("image"),j=o.get("frame"),n=j.width,h=j.height,k=o.get("innerFrame"),e=o.get("backgroundColor"),r=o.get("renderState"),c,a=o.renderState._last_class,d=o.get("type")||SC.IMAGE_TYPE_URL,m=o.get("value");if(a){f.removeClass(a)}if(m&&d===SC.IMAGE_TYPE_CSS_CLASS){f.addClass(m);o.renderState._last_class=m;if(p&&p.getContext){c=p.getContext("2d");c.clearRect(0,0,n,h)}}else{var b=![k.x,k.y,k.width,k.height].isEqual(r._lastInnerFrameValues),g=![p.width,p.height].isEqual(r._lastElemSizeValues),q=o.didChangeFor("canvasImageRenderDelegate","backgroundColor"),i=o.didChangeFor("canvasImageRenderDelegate","image")||(l&&l.complete)!==r._lastImageComplete;if(g||b||q||i){if(p&&p.getContext){p.height=h;p.width=n;c=p.getContext("2d");c.clearRect(0,0,n,h);if(e){c.fillStyle=e;c.fillRect(0,0,n,h)}if(l&&l.complete){c.drawImage(l,Math.floor(k.x),Math.floor(k.y),Math.floor(k.width),Math.floor(k.height))}}r._lastInnerFrameValues=[k.x,k.y,k.width,k.height];r._lastElemSizeValues=[p.width,p.height];r._lastImageComplete=l&&l.complete}}}});sc_require("render_delegates/render_delegate");SC.BaseTheme.containerRenderDelegate=SC.RenderDelegate.create({render:function(b,a){},update:function(){}});sc_require("render_delegates/render_delegate");SC.RenderDelegate.reopen({sizes:[SC.TINY_CONTROL_SIZE,SC.SMALL_CONTROL_SIZE,SC.REGULAR_CONTROL_SIZE,SC.LARGE_CONTROL_SIZE,SC.HUGE_CONTROL_SIZE,SC.JUMBO_CONTROL_SIZE],sizeFor:function(f){var e=f.get("controlSize"),c,b,a;if(e){if(!this[e]){this[e]={}}c=this[e];if(!c.name){c.name=e}return c}var d=f.get("frame");if(!d){c=this["sc-regular-size"];if(!c){c=this["sc-regular-size"]={}}if(!c.name){c.name="sc-regular-size"}return c}for(b=0;b<a;b++){key=sizes[b];c=this[key];if(!c){continue}if((c.width===undefined&&c.height===undefined&&c.minHeight===undefined&&c.minWidth===undefined&&c.maxHeight===undefined&&c.maxWidth===undefined)||(c.width!==undefined&&d.width!==c.width)||(c.minWidth!==undefined&&d.width<c.minWidth)||(c.maxWidth!==undefined&&d.width>c.maxWidth)||(c.height!==undefined&&d.height!==c.height)||(c.minHeight!==undefined&&d.height<c.minHeight)||(c.maxHeight!==undefined&&d.height<c.maxHeight)){continue}if(!c.name){c.name=key}return c}c=this["sc-regular-size"];if(!c){c=this["sc-regular-size"]={}}if(!c.name){c.name="sc-regular-size"}return c},addSizeClassName:function(c,b){var a=this.sizeFor(c);if(a){b.addClass(a.name)}},updateSizeClassName:function(c,a){var b=this.sizeFor(c);if(b){a.addClass(b.name)}},getPropertyFor:function(c,a){var b=this.sizeFor(c);if(b){if(b[a+"For"]){return b[a+"For"](c,a)}else{if(b[a]!==undefined){return b[a]}}}if(this[a+"For"]){return this[a+"For"]}return this[a]}});sc_require("render_delegates/render_delegate");SC.BaseTheme.imageRenderDelegate=SC.RenderDelegate.create({className:"image",render:function(f,b){var e=f.get("image"),d=f.get("value"),c=f.get("type")||SC.IMAGE_TYPE_URL,a=f.get("toolTip");b=b.begin("img");b.setAttr("src",e.src);if(d&&c===SC.IMAGE_TYPE_CSS_CLASS){b.addClass(d);f.renderState._last_class=d}if(a){b.setAttr("title",a);b.setAttr("alt",a)}b.addStyle(this.imageStyles(f));b=b.end()},update:function(g,a){var f=g.get("image"),c=g.renderState._last_class,e=g.get("value"),d=g.get("type")||SC.IMAGE_TYPE_URL,b=g.get("toolTip");a=a.find("img");a.attr("src",f.src);if(c){a.removeClass(c)}if(e&&d===SC.IMAGE_TYPE_CSS_CLASS){a.addClass(e);g.renderState._last_class=e}if(b){a.attr("title",b);a.attr("alt",b)}a.css(this.imageStyles(g))},imageStyles:function(b){var a=b.get("innerFrame");return{position:"absolute",left:Math.round(a.x),top:Math.round(a.y),width:Math.round(a.width),height:Math.round(a.height)}}});sc_require("render_delegates/render_delegate");SC.BaseTheme.labelRenderDelegate=SC.RenderDelegate.create({className:"label",render:function(d,c){var a=d.get("toolTip");this.addSizeClassName(d,c);if(a){c.setAttr("title",a)}c.addStyle({textAlign:d.get("textAlign")||null});c.setClass("ellipsis",d.get("needsEllipsis")||NO);c.setClass("icon",d.get("icon")||NO);var b=this.htmlForTitleAndIcon(d);c.push(b);d.get("renderState")._lastHTMLForTitleAndIcon=b},update:function(d,a){var b=d.get("toolTip");this.updateSizeClassName(d,a);a.css({textAlign:d.get("textAlign")||null});if(b){a.attr("title",b)}else{a.removeAttr("title")}a.setClass("ellipsis",d.get("needsEllipsis")||NO);var c=this.htmlForTitleAndIcon(d);if(d.get("renderState")._lastHTMLForTitleAndIcon!==c){a.html(c);d.get("renderState")._lastHTMLForTitleAndIcon=c}},htmlForTitleAndIcon:function(e){var d=e.get("title"),c=e.get("hint"),b=e.get("escapeHTML"),a=e.get("icon")||"";if(d&&b){d=SC.RenderContext.escapeHTML(d)}if(c&&b){c=SC.RenderContext.escapeHTML(c)}if(c&&!d){d="<span class='sc-hint'>"+c+"</span>"}if(a){if(a.indexOf("/")>=0){a='<img src="'+a+'" alt="" class="icon" />'}else{a='<img src="'+SC.BLANK_IMAGE_URL+'" alt="" class="icon '+a+'" />'}}return a+(SC.none(d)?"":d)}});SC.Task=SC.Object.extend({run:function(a){}});sc_require("tasks/task");SC.AppCacheTask=SC.Task.extend({run:function(){window.applicationCache.update();SC.appCache._appCacheStatusDidChange()}});SC.appCache=SC.Object.create({isNewVersionValid:function(){var c=this.get("hasNewVersion"),b,a=this.get("status");if(SC.platform.supportsApplicationCache){if(c){if(a===window.applicationCache.UPDATEREADY){b=true}else{b=false}}}else{b=false}return b}.property("hasNewVersion").cacheable(),isReadyForOffline:function(){var b,a=this.get("status");if(SC.platform.supportsApplicationCache){if(a===window.applicationCache.IDLE||a===window.applicationCache.UPDATEREADY){b=true}else{if(a===window.applicationCache.UNCACHED||a===window.applicationCache.OBSOLETE){b=false}}}else{b=false}return b}.property("status").cacheable(),hasNewVersion:function(){var b,a=this.get("status");if(SC.platform.supportsApplicationCache){if(a===window.applicationCache.UPDATEREADY||a===window.applicationCache.OBSOLETE){b=true}else{if(a===window.applicationCache.IDLE){b=false}}}else{b=false}return b}.property("status").cacheable(),interval:1800000,progress:0,shouldPoll:function(b,c){if(SC.none(c)){c=false}else{if(c){var a=this.get("status");if(a===window.applicationCache.IDLE){this._timer=SC.Timer.schedule({target:this,action:"_checkForUpdates",interval:this.get("interval"),repeats:YES})}else{}}else{if(this._timer){this._timer.invalidate();this._timer=null;this._task=null}}}return c}.property().cacheable(),status:0,_appCacheDidProgress:function(a){a=a.originalEvent;if(a.lengthComputable){this.set("progress",a.loaded/a.total)}else{this.set("progress",null)}},_appCacheStatusDidChange:function(){var b=window.applicationCache,a;a=b.status;SC.Event.remove(b);switch(a){case b.UNCACHED:break;case b.IDLE:this.set("progress",1);break;case b.CHECKING:SC.Event.add(b,"downloading",this,"_appCacheStatusDidChange");SC.Event.add(b,"noupdate",this,"_appCacheStatusDidChange");SC.Event.add(b,"error",this,"_appCacheStatusDidChange");break;case b.DOWNLOADING:SC.Event.add(b,"progress",this,"_appCacheDidProgress");SC.Event.add(b,"cached",this,"_appCacheStatusDidChange");SC.Event.add(b,"updateready",this,"_appCacheStatusDidChange");SC.Event.add(b,"error",this,"_appCacheStatusDidChange");break;case b.UPDATEREADY:break;case b.OBSOLETE:break;default:SC.error("Unknown application cache status: %@".fmt(b.status));break}this.set("status",a)},_checkForUpdates:function(){var a=this._task;if(this.get("status")===window.applicationCache.IDLE){if(!a){a=this._task=SC.AppCacheTask.create()}SC.backgroundTaskQueue.push(a)}else{this.set("shouldPoll",false)}},init:function(){arguments.callee.base.apply(this,arguments);if(SC.platform.supportsApplicationCache){this._appCacheStatusDidChange()}else{SC.warn("Unable to use SC.appCache, the browser does not support the application cache.")}}});SC.Benchmark={verbose:NO,enabled:YES,events:{},stats:{},globalStartTime:null,addEvent:function(a,b){if(!b){b=new Date().getTime()}this.events[a]=b},start:function(b,a,e,d){var f,c;if(this.enabled){f=e||Date.now();if(a){c=this._subStatFor(b,a)}else{c=this._statFor(b)}if(c){if(d&&c._starts.length>0){c._starts.push("ignore")}else{c._starts.push(f)}c._times.push({start:f,_subStats:{}})}}return b},end:function(c,b,f){var e,g,a,d;if(!this.enabled){return}if(b){e=this._subStatFor(c,b)}else{e=this._statFor(c)}if(e&&e._starts.length){g=e._starts.pop();if(g!=="ignore"){a=(f||Date.now());d=a-g;e._times[e._times.length-1].end=a;e._times[e._times.length-1].dur=d;e.amt+=d;e.runs++;if(this.verbose){this.log(c)}}}else{SC.Logger.log('SC.Benchmark "%@" ended without a matching start.  No information was saved.'.fmt(c))}},setGlobalStartTime:function(a){this.globalStartTime=a},bench:function(d,c,a){var b;if(!c){c="bench%@".fmt(this._benchCount++)}if(!a){a=1}while(--a>=0){SC.Benchmark.start(c);b=d();SC.Benchmark.end(c)}return b},install:function(a,e,c){var b=a["b__"+e]=a[e],d=Array.prototype.join;a[e]=function(){var g="%@(%@)".fmt(e,d.call(arguments,", ")),f;SC.Benchmark.start(g,null,null,c);f=b.apply(this,arguments);SC.Benchmark.end(g);return f}},restore:function(a,b){a[b]=a["b__"+b]},report:function(c){if(c){return this._genReport(c)}var b=[];for(var a in this.stats){if(!this.stats.hasOwnProperty(a)){continue}b.push(this._genReport(a))}return b.join("\n")},timelineReport:function(a){a=(a)?"SproutCore Application":a;var b=[a,"User-Agent: %@".fmt(navigator.userAgent),"Report Generated: %@ (%@)".fmt(new Date().toString(),Date.now()),""];var d=this._compileChartData(true);for(var c=0;c<d.length;c++){if(d[c][4]){b.push(this._timelineGenSubReport(d[c]))}else{b.push(this._timelineGenReport(d[c]))}}return b.join("\n")},getTimelineChartContent:function(){var l=this._compileChartData(false);var g=l.length;if(g===0){return}var c=this.globalStartTime?this.globalStartTime:l[0][1];var d=l[g-1][2]-c;var n=25+g*30;var q=Math.ceil(d/200)+1;var r=q*50;var m=10,s=300;var o="<div class = 'sc-benchmark-timeline-chart' style = 'position:relative;'>";o+="<div class = 'sc-benchmark-top'></div>";for(var p=0;p<q;p++){o+="<div class = 'sc-benchmark-tick' style = '";o+="left: "+(m+p*50)+"px; ";o+="height: "+n+"px;";o+="'></div>";o+="<div class = 'sc-benchmark-tick-label' style = '";o+="left: "+(m+p*50)+"px; ";o+="'>"+(p*200)+"ms</div>"}for(p=0;p<g;p++){o+="<div class = 'sc-benchmark-row ";o+=(p%2===0)?"even":"odd";o+="' style = '";o+="top: "+(50+(p*30))+"px; ";o+="'></div>";var j=document.createElement("div");var f=l[p][1];var e=l[p][2];var a=l[p][3];o+="<div class = 'sc-benchmark-bar' style = '";o+="left:"+(m+((f-c)/4))+"px; width: "+((a/4))+"px;";o+="top: "+(28+(p*30))+"px;";o+="' title = 'start: "+(f-c)+" ms, end: "+(e-c)+" ms, duration: "+a+" ms'";o+=">";o+="&nbsp;"+l[p][0]+" <span class='sc-benchmark-emphasis'>";o+=a+"ms (start: "+(f-c)+"ms)";o+="</span>";o+="</div>"}var b=this.events,k=0;for(p in b){var h=b[p]-c;o+="<div class = 'sc-benchmark-event idx"+(k%10)+"' style = '";o+="left: "+(m+h/4)+"px; height: "+n+"px; top: 20px;";o+="' title = '"+p+": "+h+"'></div>";k++}o+="</div>";return{html:o,totalCapturedTime:d,pointsCaptured:g,width:r+m+s,height:n}},getTimelineChartView:function(){var a=SC.ScrollView.create({contentView:SC.StaticContentView.extend({}),reload:function(){var b=SC.Benchmark.getTimelineChartContent();this.contentView.set("content",b.html);this.contentView.adjust({width:b.width,height:b.height});this.chartContent=b;SC.RunLoop.invokeLater(SC.Benchmark,function(){this.contentView.notifyPropertyChange("frame")})}});a.reload();return a},timelineChart:function(a){SC.RunLoop.begin();var c=0;this.hideChart();var b=this.getTimelineChartView();var e=b.chartContent.pointsCaptured,d=b.chartContent.totalCapturedTime;this._benchmarkChart=SC.Pane.create({classNames:["sc-benchmark-pane"],layout:{left:20,right:20,bottom:20,top:20},childViews:["title","exit"],exit:SC.ButtonView.extend({layout:{right:20,top:20,width:100,height:30},title:"Hide Chart",target:this,action:"hideChart"}),title:SC.LabelView.extend({classNames:["sc-benchmark-title"],layout:{left:20,top:23,right:200,height:30},value:((a)?a:"SproutCore Application")+(" - Total Captured Time: "+d+" ms - Points Captured: "+e)})}).append();b.set("layout",{left:20,top:60,bottom:20,right:20});this._benchmarkChart.appendChild(b);SC.RunLoop.end()},hideChart:function(){if(this._benchmarkChart){this._benchmarkChart.remove();this._benchmarkChart=null}return YES},tryToPerform:function(b,a){if(this[b]){return this[b](a)}return NO},log:function(d){var c=this.report(d).split("\n"),b=c.length,a;for(a=0;a<b;a++){SC.Logger.log(c[a])}},startProfile:function(a){if(!this.enabled){return}SC.Logger.profile(a)},endProfile:function(a){if(!this.enabled){return}SC.Logger.profileEnd(a)},loadPreloadEvents:function(){var f=SC.benchmarkPreloadEvents,e=[],b,a,c;if(typeof webkitPerformance!=="undefined"){SC.mixin(f,webkitPerformance.timing)}if(!this.globalStartTime){var d=["navigation","navigationStart","headStart"];a=d.length;for(b=0;b<a;b++){if(f[d[b]]){this.globalStartTime=f[d[b]];break}}}this.javascriptStartTime=f.headStart;SC.mixin(this.events,f);this._hasLoadedPreloadEvents=true},_loadBenchmarksFromEvents:function(){if(!this._hasLoadedPreloadEvents){this.loadPreloadEvents()}var b=this.events;for(var a in b){if(a.substr(-3)!=="End"){continue}var c=a.substr(0,a.length-3);if(!b[c+"Start"]){continue}SC.Benchmark.start(c,undefined,b[c+"Start"]);SC.Benchmark.end(c,undefined,b[c+"End"]);delete b[c+"Start"];delete b[c+"End"]}},_compileChartData:function(g){this._loadBenchmarksFromEvents();var l=[],a;for(var m in this.stats){var e=this.stats[m];for(var f=0;f<e._times.length;f++){var n=e._times[f];a=(e._times.length>1)?(f+1)+" - "+m:m;l.push([a,n.start,n.end,n.dur,false]);if(g){var b=n._subStats;for(var c in b){var h=b[c];for(var d=0;d<h._times.length;d++){var o=h._times[d];a=(h._times.length>1)?(d+1)+" - "+c:c;l.push([a,o.start,o.end,o.dur,true])}}}}}l.sort(function(j,i){if(j[1]<i[1]){return -1}else{if(j[1]==i[1]){if(j[3]&&!i[3]){return -1}if(!j[3]&&i[3]){return 1}return 0}}return 1});return l},_genReport:function(b){var c=this._statFor(b),e=(c.runs>0)?(Math.floor(c.amt*1000/c.runs)/1000):0,d,a;if(c._times.length){d=c._times[c._times.length-1];a="BENCH %@ msec: %@ (%@x); latest: %@".fmt(e,(c.name||b),c.runs,d.end-d.start)}else{a='No information for SC.Benchmark "%@".'.fmt(b)}return a},_timelineGenReport:function(a){if(this.globalStartTime){return"BENCH start: %@ msec, duration: %@ msec,  %@".fmt((a[1]-this.globalStartTime),a[3],a[0])}else{return"BENCH duration: %@ msec, %@".fmt(a[3],a[0])}},_timelineGenSubReport:function(a){if(this.globalStartTime){return"   CHECKPOINT BENCH start: %@ msec, duration: %@ msec,  %@".fmt((a[1]-this.globalStartTime),a[3],a[0])}else{return"   CHECKPOINT BENCH duration: %@ msec, %@".fmt(a[3],a[0])}},_subStatFor:function(d,c){var f=this.stats[c],e=f?f._times.length:0,a,b;if(!e){return}a=f._times[e-1]._subStats;b=a[d];if(!b){b=a[d]={runs:0,amt:0,name:d,_starts:[],_times:[]}}return b},_statFor:function(b){var a=this.stats[b];if(!a){a=this.stats[b]={runs:0,amt:0,name:b,_starts:[],_times:[]}}return a},reset:function(){this.stats={}},_bench:function(b,a){SC.Benchmark.bench(b,a,1)},_benchCount:1};SC.Benchmark=SC.Benchmark;SC.Cookie=SC.Object.extend({name:null,value:"",expires:null,path:null,domain:null,secure:NO,isCookie:YES,destroy:function(){this.set("expires",-1);this.write();arguments.callee.base.apply(this,arguments)},write:function(){var d=this.get("name"),f=this.get("value"),a=this.get("expires"),h=this.get("path"),e=this.get("domain"),g=this.get("secure"),b="",c;if(a){if(typeof a===SC.T_NUMBER){c=new Date();c.setTime(c.getTime()+(a*24*60*60*1000))}else{if(SC.DateTime&&a.get&&a.get("milliseconds")){c=new Date(a.get("milliseconds"))}else{if(a.toUTCString&&a.toUTCString.apply){c=a}}}if(c){b="; expires="+c.toUTCString()}}if(!SC.none(h)){b+="; path="+h}if(!SC.none(e)){b+="; domain="+e}if(g===YES){b+="; secure"}document.cookie=d+"="+encodeURIComponent(f)+b;return this}});SC.Cookie.mixin({find:function(a){if(document.cookie&&document.cookie!==""){var d=document.cookie.split(";");for(var c=0;c<d.length;c++){var b=SC.String.trim(String(d[c]));if(b.substring(0,a.length+1)===(a+"=")){return SC.Cookie.create({name:a,value:decodeURIComponent(b.substring(a.length+1))})}}}return null}});SC.CookieMonster={nomNomNom:function(b){var a=SC.kindOf(b,SC.Cookie);if(a){SC.Logger.log("YUM!");return b.destroy()}SC.Logger.error("Y U PASS ME NO COOKIE? %@",b);return NO}};SC.mixin(SC.$.fn,{setClass:function(d,c){if(SC.none(d)){return this}var e=SC.typeOf(d)!==SC.T_STRING,a=this._fixupClass,b;this.each(function(){if(this.nodeType!==1){return}var h=this.className.split(/\s+/),g=NO;if(e){for(var f in d){if(d.hasOwnProperty(f)){g=a(h,f,d[f])||g}}}else{g=a(h,d,c)}if(g){this.className=h.join(" ")}});return this},_fixupClass:function(d,a,c){var b=d.indexOf(a);if(c){if(b<0){d.push(a);return YES}}else{if(b>=0){d[b]=null;return YES}}return NO}});SC.ExceptionHandler={enabled:(SC.buildMode!=="debug"),handleException:function(a){if(this.isShowingErrorDialog){return NO}this._displayErrorDialog(a);return NO},_displayErrorDialog:function(b){var a=this._errorDialogHTMLForException(b),c=document.createElement("div");c.style.cssText="left: 0px; right: 0px; top: 0px; bottom: 0px; position: absolute; background-color: white; background-color: rgba(255,255,255,0.6); z-index:100;";c.innerHTML=a;document.body.appendChild(c);this.isShowingErrorDialog=YES},_errorDialogHTMLForException:function(b){var a;a=['<div id="sc-error-dialog" style="position: absolute; width: 500px; left: 50%; top: 50%; margin-left: -250px; background-color: white; border: 1px solid black; font-family: Monaco, monospace; font-size: 9px; letter-spacing: 1px; padding: 10px">',"An error has occurred which prevents the application from running:","<br><br>",b.message,'<div id="sc-error-dialog-reload-button" onclick="window.location.reload();" style="float: right; font-family: Monaco, monospace; font-size: 9px; letter-spacing: 1px; border: 1px solid black; padding: 3px; clear: both; margin-top: 20px; cursor: pointer;">',"Reload","</div>","</div>"];return a.join("")},isShowingErrorDialog:NO};SC.IMAGE_ABORTED_ERROR=SC.$error("SC.Image.AbortedError","Image",-100);SC.IMAGE_FAILED_ERROR=SC.$error("SC.Image.FailedError","Image",-101);SC.imageQueue=SC.Object.create({loadLimit:4,activeRequests:0,loadImage:function(a,e,f,d){var b=SC.typeOf(e);if(SC.none(f)&&SC.typeOf(e)===SC.T_FUNCTION){e=null;f=e}if(SC.typeOf(f)===SC.T_STRING){f=e[f]}if(SC.none(d)){d=SC.none(e)&&SC.none(f)}var c=this._imageEntryFor(a);if(c.status===this.IMAGE_LOADED){if(f){f.call(e||c.image,c.url,c.image)}}else{if(e||f){this._addCallback(c,e,f)}c.retainCount++;this._scheduleImageEntry(c,d)}},releaseImage:function(a,d,e){var c=this._imageEntryFor(a,NO);if(!c){return this}if(--c.retainCount<=0){this._deleteEntry(c)}else{if(d||e){var b=SC.typeOf(d);if(SC.none(e)&&SC.typeOf(d)===SC.T_FUNCTION){d=null;e=d}if(SC.typeOf(e)===SC.T_STRING){e=d[e]}this._removeCallback(c,d,e)}}},reloadImage:function(a){var b=this._imageEntryFor(a,NO);if(b&&b.status===this.IMAGE_LOADED){b.status=this.IMAGE_WAITING}},loadNextImage:function(){var c=null,a;if(this.get("activeRequests")>=this.get("loadLimit")){return}a=this._foregroundQueue;while(a.length>0&&!c){c=a.shift()}if(!c){a=this._backgroundQueue;while(a.length>0&&!c){c=a.shift()}}this.set("isLoading",!!c);if(c){var b=c.image;if(!b){return}$(b).bind("abort",this._imageDidAbort);$(b).bind("error",this._imageDidError);$(b).bind("load",this._imageDidLoad);b.src=c.url;this._loading.push(c);this.incrementProperty("activeRequests");this.loadNextImage()}},_imageEntryFor:function(c,a){if(a===undefined){a=YES}var d=this._images[c];if(!d&&a){var b=new Image();d=this._images[c]={url:c,status:this.IMAGE_WAITING,callbacks:[],retainCount:0,image:b};b.entry=d}else{if(d&&d.image===null){d.image=new Image();d.image.entry=d}}return d},_deleteEntry:function(a){this._unscheduleImageEntry(a);delete this._images[a.url]},_addCallback:function(c,d,e){var b=c.callbacks;var a=b.find(function(f){return f[0]===d&&f[1]===e},this);if(!a){b.push([d,e])}b=null;return this},_removeCallback:function(b,c,d){var a=b.callbacks;a.forEach(function(f,e){if(f[0]===c&&f[1]===d){a[e]=null}},this);a=null;return this},_scheduleImageEntry:function(d,c){var b=this._backgroundQueue;var e=this._foregroundQueue;if(d.status===this.IMAGE_LOADED){return this}if((d.status===this.IMAGE_QUEUED)&&!c&&d.isBackground){b[b.indexOf(d)]=null;d.status=this.IMAGE_WAITING}if(d.status!==this.IMAGE_QUEUED){var a=(c)?b:e;a.push(d);d.status=this.IMAGE_QUEUED;d.isBackground=c}if(!this.isLoading){this.invokeLater(this.loadNextImage,100)}this.set("isLoading",YES);return this},_unscheduleImageEntry:function(b){if(b.status!==this.IMAGE_QUEUED){return this}var a=b.isBackground?this._backgroundQueue:this._foregroundQueue;a[a.indexOf(b)]=null;if(this._loading.indexOf(b)>=0){if(a.image){a.image.abort()}this.imageStatusDidChange(b,this.ABORTED)}return this},_imageDidAbort:function(){SC.run(function(){SC.imageQueue.imageStatusDidChange(this.entry,SC.imageQueue.ABORTED)},this)},_imageDidError:function(){SC.run(function(){SC.imageQueue.imageStatusDidChange(this.entry,SC.imageQueue.ERROR)},this)},_imageDidLoad:function(){SC.run(function(){SC.imageQueue.imageStatusDidChange(this.entry,SC.imageQueue.LOADED)},this)},imageStatusDidChange:function(c,a){if(!c){return}var b=c.url;var d;switch(a){case this.LOADED:d=c.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}c.callbacks.forEach(function(f){var g=f[0],h=f[1];h.call(g,b,d)},this);c.callbacks=[];c.status=(a===this.LOADED)?this.IMAGE_LOADED:this.IMAGE_WAITING;var e=c.image;if(e){e.onload=e.onerror=e.onabort=null;if(a!==this.LOADED){c.image=null}}this._loading[this._loading.indexOf(c)]=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(c,b,a){if(!a){a=0.00001}return Math.abs(c-b)<=a},round:function(d,a){if(!a){a=0}var b=Math.pow(10,a);if(a<0){var c=b.toString();b=c.substring(0,c.indexOf("1")+1)}d=d.valueOf();return Math.round(d*b)/b}});sc_require("tasks/task");SC.Module=SC.Object.create({isModuleReady:function(a){var b=SC.MODULE_INFO[a];return b?!!b.isReady:NO},loadModule:function(c,f,g){var e=SC.MODULE_INFO[c],b;if(arguments.length>3){b=new Array(arguments.length-3);for(var d=0,a=b.length;d<a;d++){b[d]=arguments[d+3]}}else{b=[]}if(g===undefined&&SC.typeOf(f)===SC.T_FUNCTION){g=f;f=null}if(!e){throw new Error("SC.Module: could not find module '%@'".fmt(c))}e.isPrefetching=NO;if(e.isLoaded&&!e.isWaitingForRunLoop){if(!this._dependenciesMetForModule(c)){this._addCallbackForModule(c,f,g,b);this._loadDependenciesForModule(c);return NO}if(e.source){this._evaluateStringLoadedModule(e);this._addCallbackForModule(c,f,g,b);this.invokeLast(function(){e.isReady=YES;this._moduleDidBecomeReady(c)});return NO}if(g){if(SC.isReady){SC.Module._invokeCallback(c,f,g,b)}else{SC.ready(SC.Module,function(){SC.Module._invokeCallback(c,f,g,b)})}}return YES}else{if(e.isWaitingForRunLoop){this._addCallbackForModule(c,f,g,b)}else{this._addCallbackForModule(c,f,g,b);if(!e.isLoading){this._loadDependenciesForModule(c);this._loadCSSForModule(c);this._loadJavaScriptForModule(c);e.isLoading=YES}return NO}}},_addCallbackForModule:function(b,e,f,a){var c=SC.MODULE_INFO[b];var d=c.callbacks||[];if(f){d.push(function(){SC.Module._invokeCallback(b,e,f,a)})}c.callbacks=d},prefetchModule:function(a){var b=SC.MODULE_INFO[a];if(b.isLoading||b.isLoaded){return}if(SC.LOG_MODULE_LOADING){SC.debug("SC.Module: Prefetching module '%@'.",a)}this._loadDependenciesForModule(a);this._loadCSSForModule(a);this._loadJavaScriptForModule(a);b.isLoading=YES;b.isPrefetching=YES},_executeLazilyInstantiatedModule:function(b,c,i){var h=SC.LAZY_INSTANTIATION[b];var g;var a;var j,d;if(SC.LOG_MODULE_LOADING){SC.debug("SC.Module: Module '%@' is marked for lazy instantiation, instantiating it now…",b)}d=h.length;for(j=0;j<d;j++){try{h[j]()}catch(f){SC.Logger.error("SC.Module: Failed to lazily instatiate entry for  '%@'".fmt(b))}}delete SC.LAZY_INSTANTIATION[b];g=this._targetForTargetName(c);a=this._methodForMethodNameInTarget(i,g);if(!a){throw new Error("SC.Module: could not find callback for lazily instantiated module '%@'".fmt(b))}},_evaluateStringLoadedModule:function(b){var a=b.source;jQuery.globalEval(a);delete b.source;if(b.cssSource){var c=document.createElement("style");c.setAttribute("type","text/css");if(c.styleSheet){c.styleSheet.cssText=b.cssSource}else{var d=document.createTextNode(b.cssSource);c.appendChild(d)}document.getElementsByTagName("head")[0].appendChild(c)}b.isReady=YES},_loadCSSForModule:function(d){var f=document.getElementsByTagName("head")[0];var e=SC.MODULE_INFO[d];var h=e.styles||[];var b=h.length;var c;var g;var a;if(!f){f=document.documentElement}b=h.length;for(a=0;a<b;a++){c=h[a];if(c.length>0){if(SC.LOG_MODULE_LOADING){SC.debug("SC.Module: Loading CSS file in '%@' -> '%@'",d,c)}if(window.devicePixelRatio>1||window.location.search.indexOf("2x")>-1){c=c.replace(".css","@2x.css")}g=document.createElement("link");g.setAttribute("href",c);g.setAttribute("rel","stylesheet");g.setAttribute("type","text/css");f.appendChild(g)}}g=null},_loadJavaScriptForModule:function(b){var c=SC.MODULE_INFO[b];var d;var a;var e=c.dependencies;var f=YES;if(e&&e.length>0){f=this._dependenciesMetForModule(b)}if(c.isPrefetched){a=c.stringURL}else{if(f){a=c.scriptURL}else{a=c.stringURL}}if(a.length>0){if(SC.LOG_MODULE_LOADING){SC.debug("SC.Module: Loading JavaScript file in '%@' -> '%@'",b,a)}d=document.createElement("script");d.setAttribute("type","text/javascript");d.setAttribute("src",a);if(d.addEventListener){d.addEventListener("load",function(){SC.run(function(){SC.Module._moduleDidLoad(b)})},false)}else{if(d.readyState){d.onreadystatechange=function(){if(this.readyState==="complete"||this.readyState==="loaded"){SC.run(function(){SC.Module._moduleDidLoad(b)})}}}}document.body.appendChild(d)}},_dependenciesMetForModule:function(c){var e=SC.MODULE_INFO[c].dependencies||[];var b,a=e.length;var f;var d;for(b=0;b<a;b++){f=e[b];d=SC.MODULE_INFO[f];if(!d){throw new Error("SC.loadModule: Unable to find dependency %@ for module %@.".fmt(f,c))}if(!d.isReady){return NO}}return YES},_loadDependenciesForModule:function(a){var b=SC.MODULE_INFO[a];var h=b.dependencies||[];var e=YES;var f=h.length;var i;var d;var c;var g;for(i=0;i<f;i++){d=h[i];c=SC.MODULE_INFO[d];if(!c){throw new Error("SC.Module: could not find required module '%@' for module '%@'".fmt(d,a))}else{if(c.isLoading){e=NO;g=c.dependents;if(!g){c.dependents=g=[]}g.push(a)}else{if(c.isReady){continue}else{e=NO;g=c.dependents;if(!g){c.dependents=g=[]}g.push(a);SC.Module.loadModule(d)}}}}},_invokeCallback:function(c,d,a,b){var g;var f;f=this._targetForTargetName(d);g=this._methodForMethodNameInTarget(a,f);if(!g){if(SC.LAZY_INSTANTIATION[c]){this._executeLazilyInstantiatedModule(c,d,a);f=this._targetForTargetName(d);g=this._methodForMethodNameInTarget(a,f)}else{throw new Error("SC.Module: could not find callback for '%@'".fmt(c))}}if(!b){b=[]}b.unshift(c);var e=!!SC.RunLoop.currentRunLoop;if(e){SC.run(function(){g.apply(f,b)})}else{g.apply(f,b)}},_invokeCallbacksForModule:function(c){var e=SC.MODULE_INFO[c],d;if(!e){return}d=e.callbacks||[];for(var b=0,a=d.length;b<a;++b){d[b]()}},_evaluateAndInvokeCallbacks:function(a){var c=SC.MODULE_INFO;var b=c[a];if(b.source){this._evaluateStringLoadedModule(b)}b.isWaitingForRunLoop=YES;this.invokeLast(function(){b.isReady=YES;this._moduleDidBecomeReady(a)})},_moduleDidBecomeReady:function(c){var g=SC.MODULE_INFO;var d=g[c];d.isWaitingForRunLoop=NO;if(SC.isReady){SC.Module._invokeCallbacksForModule(c);delete d.callbacks}else{SC.ready(SC,function(){SC.Module._invokeCallbacksForModule(c);delete d.callbacks})}var h=d.dependents||[];var f,e;for(var b=0,a=h.length;b<a;b++){f=h[b];e=g[f];if(e.isLoaded&&this._dependenciesMetForModule(f)){this._evaluateAndInvokeCallbacks(f)}}},_moduleDidLoad:function(a){var b=SC.MODULE_INFO[a];var c;if(!b){b=SC.MODULE_INFO[a]={isLoaded:YES,isReady:YES};return}if(b.isLoaded){return}delete b.isLoading;b.isLoaded=YES;if(!b.isPrefetching){c=this._dependenciesMetForModule(a);if(c){this._evaluateAndInvokeCallbacks(a)}else{}}else{delete b.isPrefetching}},_targetForTargetName:function(a){if(SC.typeOf(a)===SC.T_STRING){return SC.objectForPropertyPath(a)}return a},_methodForMethodNameInTarget:function(a,b){if(SC.typeOf(a)===SC.T_STRING){return SC.objectForPropertyPath(a,b)}return a},methodsForSuspend:"loadModule _moduleDidLoad prefetchModule _moduleDidBecomeReady".w(),suspend:function(){this._suspendCount=(this._suspendCount||0)+1;if(this._suspendCount!==1){return}var a=this.get("methodsForSuspend"),e,d,c,b;for(b=0;(c=a[b]);b++){if(!this[e="__replacement_"+c+"__"]){(this[e]=function(){(this._bufferedCalls||(this._bufferedCalls=[])).push({method:arguments.callee.methodName,arguments:arguments})}).methodName=c}if(!this[d="__saved_"+c+"__"]){this[d]=this[c]}this[c]=this[e]}},resume:function(){this._suspendCount=(this._suspendCount||0)-1;if(this._suspendCount<0){SC.warn("SC.Module.resume() was called without SC.Module having been in a suspended state. Call aborted.");this._suspendCount=0;return}if(this._suspendCount>0){return}var a=this.get("methodsForSuspend"),d=this._bufferedCalls,c,b,e;for(b=0;(c=a[b]);b++){this[c]=this["__saved_"+c+"__"]}for(b=0;(e=d)&&d[b];b++){this[e.method].apply(this,e.arguments)}if(d){d.length=0}}});SC.ready(function(){var d=SC.MODULE_INFO;var b;var c;var a;for(b in d){c=d[b];if(c.isPrefetched){a=SC.Module.PrefetchModuleTask.create({prefetchedModuleName:b});SC.backgroundTaskQueue.push(a)}}});SC.Module.PrefetchModuleTask=SC.Task.extend({prefetchedModuleName:null,run:function(){SC.Module.prefetchModule(this.prefetchedModuleName)}});sc_require("tasks/task");SC.TaskQueue=SC.Task.extend({init:function(){var a=this;this._doIdleEntry=function(){a._idleEntry()};this._suspendCount=0;this._tasks=[]},runWhenIdle:NO,runLimit:50,interval:50,isRunning:NO,minimumIdleDuration:500,_tasks:null,hasTasks:function(){return this._tasks.length>0}.property("taskCount").cacheable(),taskCount:function(){return this._tasks.length}.property().cacheable(),push:function(a){this._tasks.push(a);this.notifyPropertyChange("taskCount")},next:function(){if(this._tasks.length<1){return null}var a=this._tasks.shift();this.notifyPropertyChange("taskCount");return a},suspend:function(){this._suspendCount++},resume:function(){this._suspendCount--;if(this._suspendCount<=0){this._setupIdle()}},_taskCountDidChange:function(){this._setupIdle()}.observes("taskCount"),_runWhenIdleDidChange:function(){this._setupIdle()}.observes("runWhenIdle"),_setupIdle:function(){if(!this._suspendCount&&this.get("runWhenIdle")&&!this._idleIsScheduled&&this.get("taskCount")>0){setTimeout(this._doIdleEntry,this.get("interval"));this._idleIsScheduled=YES}},_idleEntry:function(){this._idleIsScheduled=NO;var a=SC.RunLoop.lastRunLoopEnd;if(!this.get("runWhenIdle")&&!this._suspendCount){return}if(Date.now()-a>this.get("minimumIdleDuration")){SC.run(this.run,this);SC.RunLoop.lastRunLoopEnd=a}this._setupIdle()},run:function(a){this.set("isRunning",YES);if(!a){a=this.get("runLimit")}var b,c=Date.now();while(b=this.next()){b.run(this);if(Date.now()-c>a){break}}this.set("isRunning",NO)}});SC.backgroundTaskQueue=SC.TaskQueue.create({runWhenIdle:YES});SC.TextSelection=SC.Object.extend(SC.Copyable,SC.Freezable,{start:-1,end:-1,direction:"none",length:function(){var b=this.get("start");var a=this.get("end");if(b===-1||a===-1){return -1}else{return a-b}}.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"),direction:this.get("direction")})},toString:function(){var b=this.get("length"),d=this.get("start"),a=this.get("end"),c=this.get("direction");if(b&&b>0){if(b===1){return"[%@ character selected: {%@, %@}; direction: %@]".fmt(b,d,a,c)}else{return"[%@ characters selected: {%@, %@}; direction: %@]".fmt(b,d,a,c)}}else{return"[no text selected; caret at %@]".fmt(d)}}});SC.UndoManager=SC.Object.extend({undoActionName:function(){return this.undoStack?this.undoStack.name:null}.property("undoStack").cacheable(),undoActionTimestamp:function(){return this.undoStack?this.undoStack.timeStamp:null}.property("undoStack").cacheable(),redoActionName:function(){return this.redoStack?this.redoStack.name:null}.property("redoStack").cacheable(),redoActionTimestamp:function(){return this.redoStack?this.redoStack.timeStamp:null}.property("redoStack").cacheable(),canUndo:function(){return !SC.none(this.undoStack)}.property("undoStack").cacheable(),canRedo:function(){return !SC.none(this.redoStack)}.property("redoStack").cacheable(),undo:function(){this._undoOrRedo("undoStack","isUndoing")},redo:function(){this._undoOrRedo("redoStack","isRedoing")},reset:function(){this._activeGroup=null;this.set("undoStack",null);this.set("redoStack",null)},maxStackLength:0,isUndoing:NO,isRedoing:NO,registerUndoAction:function(d,c,b,a){if(!this.isUndoing&&!this.isRedoing){if(this._activeGroup){this.endUndoGroup()}this.beginUndoGroup(a)}this.registerGroupedUndoAction(d,c,b)},registerGroupedUndoAction:function(d,c,b,a){if(!this._activeGroup){this.registerUndoAction(d,c,b,a)}else{if(a){this._activeGroup.name=a}this._activeGroup.targets.push(d);this._activeGroup.actions.push(c);this._activeGroup.contexts.push(b);this._activeGroup.timeStamp=SC.DateTime.create();if(!this.isUndoing&&!this.isRedoing){this.set("redoStack",null)}}},beginUndoGroup:function(b){if(this._activeGroup){return}var a=this.isUndoing?"redoStack":"undoStack";this._activeGroup={name:b,targets:[],actions:[],contexts:[],prev:this.get(a),timeStamp:SC.DateTime.create()};this.set(a,this._activeGroup)},endUndoGroup:function(){var d=this.get("maxStackLength"),b=this.isUndoing?"redoStack":"undoStack";if(!this._activeGroup){return}this._activeGroup=null;this.notifyPropertyChange(b);if(d>0){var a=this[b],c=1;while(a=a.prev){c++;if(c>=d){a.prev=null}}}},setActionName:function(a){if(!this._activeGroup){return}this._activeGroup.name=a},_activeGroup:null,undoStack:null,redoStack:null,_undoOrRedo:function(b,f){if(this._activeGroup){this.endUndoGroup()}this.set(f,true);var h=this.get(b);if(h){this.set(b,h.prev);this.beginUndoGroup(h.name);var a=h.actions.length,g,e,d,c;for(c=a-1;c>=0;c--){g=h.targets[c];e=h.actions[c];d=h.contexts[c];if(SC.typeOf(g)===SC.T_FUNCTION){e=g;g=null}if(SC.typeOf(g)===SC.T_STRING){g=SC.objectForPropertyPath(g)}if(g&&SC.typeOf(e)===SC.T_STRING&&SC.typeOf(g[e])===SC.T_FUNCTION){e=g[e]}if(SC.typeOf(e)===SC.T_FUNCTION){e.call(g,d)}}this.endUndoGroup()}this.set(f,false)},destroy:function(){this._activeGroup=null;this.set("undoStack",null);this.set("redoStack",null);return arguments.callee.base.apply(this,arguments)},registerUndo:function(b,a){this.registerUndoAction(null,b,null,a)}});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(i){var a,d,b,j,h,k,g;i=this._normalizeKeyName(i);b=this._userKeyName(i);if(this._written){d=this._written[b]}a=SC.browser.isIE&&SC.browser.compare(SC.browser.version,"7")===0;if(a){j=document.body;try{j.load("SC.UserDefaults")}catch(c){SC.Logger.error("Couldn't load userDefaults in IE7: "+c.description)}}else{if(this.HTML5DB_noLocalStorage){g=this._safari3DB}else{j=window.localStorage;if(!j&&window.globalStorage){j=window.globalStorage[window.location.hostname]}}}if(j||g){h=["SC.UserDefaults",b].join("-at-");if(a){d=j.getAttribute(h.replace(/\W/gi,""))}else{if(g){d=this.dataHash[h]}else{d=j[h]}}if(!SC.none(d)){try{d=SC.json.decode(d)}catch(f){}}}k=this.delegate;if(k&&k.userDefaultsNeedsDefault){d=k.userDefaultsNeedsDefault(this,i,b)}if(SC.none(d)&&this._defaults){d=this._defaults[b]||this._defaults[i]}return d},writeDefault:function(k,i){var b,f,c,l,j,m,h;k=this._normalizeKeyName(k);f=this._userKeyName(k);c=this._written;if(!c){c=this._written={}}c[f]=i;b=SC.browser.isIE&&SC.browser.compare(SC.browser.version,"7")===0;if(b){l=document.body}else{if(this.HTML5DB_noLocalStorage){h=this._safari3DB}else{l=window.localStorage;if(!l&&window.globalStorage){l=window.globalStorage[window.location.hostname]}}}j=["SC.UserDefaults",f].join("-at-");if(l||h){var a=SC.json.encode(i);if(b){l.setAttribute(j.replace(/\W/gi,""),a);l.save("SC.UserDefaults")}else{if(h){var d=this;h.transaction(function(e){e.executeSql("delete from SCLocalStorage where key = ?",[j],function(){e.executeSql("insert into SCLocalStorage(key, value) VALUES ('"+j+"', '"+a+"');",[],d._nullDataHandler,d.killTransaction)})});this.dataHash[j]=a}else{try{l[j]=a}catch(g){SC.Logger.error("Failed using localStorage. "+g)}}}}m=this.delegate;if(m&&m.userDefaultsDidChange){m.userDefaultsDidChange(this,k,i,f)}return this},resetDefault:function(j){var b,a,f,c,k,i,h;b=this._normalizeKeyName(j);f=this._userKeyName(b);this.propertyWillChange(j);this.propertyWillChange(b);c=this._written;if(c){delete c[f]}a=SC.browser.isIE&&SC.browser.compare(SC.browser.version,"7")===0;if(a){k=document.body}else{if(this.HTML5DB_noLocalStorage){h=this._safari3DB}else{k=window.localStorage;if(!k&&window.globalStorage){k=window.globalStorage[window.location.hostname]}}}i=["SC.UserDefaults",f].join("-at-");if(k){if(a){k.setAttribute(i.replace(/\W/gi,""),null);k.save("SC.UserDefaults")}else{if(h){var d=this;h.transaction(function(e){e.executeSql("delete from SCLocalStorage where key = ?",[i],null)});delete this.dataHash[i]}else{try{delete k[i]}catch(g){SC.Logger.warn("Deleting local storage encountered a problem. "+g)}}}}this.propertyDidChange(j);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){var b=this.get("appDomain")||"app";a=[b,a].join(":")}return a},_userKeyName:function(b){var a=this.get("userDomain")||"(anonymous)";return[a,b].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}if(a){this.allPropertiesDidChange()}}.observes("userDomain","appDomain"),init:function(){arguments.callee.base.apply(this,arguments);var a;jQuery.readyWait++;if(SC.userDefaults&&SC.userDefaults.get("dataHash")){var g=SC.userDefaults.get("dataHash");if(g){this.dataHash=SC.userDefaults.get("dataHash")}}this._scud_userDomain=this.get("userDomain");this._scud_appDomain=this.get("appDomain");a=SC.browser.isIE&&SC.browser.compare(SC.browser.version,"7")===0;if(a){document.body.addBehavior("#default#userData")}this.HTML5DB_noLocalStorage=SC.browser.isWebkit&&SC.browser.compare(SC.browser.engineVersion,"523")>0&&SC.browser.compare(SC.browser.engineVersion,"528")<0;if(this.HTML5DB_noLocalStorage){var b;try{if(!window.openDatabase){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}else{var h="scdb",f="1.0",i="SproutCore database",j=65536;b=openDatabase(h,f,i,j)}}catch(d){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(b){var c=this;b.transaction(function(e){e.executeSql("CREATE TABLE IF NOT EXISTS SCLocalStorage(key TEXT NOT NULL PRIMARY KEY, value TEXT NOT NULL);",[],c._nullDataHandler,c.killTransaction)});b.transaction(function(e){e.parent=c;e.executeSql("SELECT * from SCLocalStorage;",[],function(p,m){var n={},o;for(var l=0,k=m.rows.length;l<k;l++){o=m.rows.item(l);n[o.key]=o.value}p.parent.dataHash=n;SC.run(function(){jQuery.ready(true)})},c.killTransaction)});this._safari3DB=b}}else{jQuery.ready(true)}},_killTransaction:function(b,a){return true},_nullDataHandler:function(b,a){}});SC.userDefaults=SC.UserDefaults.create();SC.mixin({convertHsvToHex:function(d,c,a){var b=SC.Color.hsvToRgb(d,c,a);return SC.Color.create({r:b[0],g:b[1],b:b[2]}).toHex()},convertHexToHsv:function(b){var a=SC.Color.from(b);return a&&SC.Color.rgbToHsv(a.r,a.g,a.b)},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(b){var c,e,d,a;c=this.parseColor(b);if(c){e=parseInt(c.slice(1,3),16);d=parseInt(c.slice(3,5),16);a=parseInt(c.slice(5,7),16);return[e,d,a]}},parseColor:function(d){var e=0,a="#",c,b;if(c=this.PARSE_COLOR_RGBRE.exec(d)){for(e=1;e<=3;e++){b=Math.max(0,Math.min(255,parseInt(c[e],0)));a+=this.toColorPart(b)}return a}if(c=this.PARSE_COLOR_HEXRE.exec(d)){if(c[1].length==3){for(e=0;e<3;e++){a+=c[1].charAt(e)+c[1].charAt(e)}return a}return"#"+c[1]}return false},toColorPart:function(a){if(a>255){a=255}var b=a.toString(16);if(a<16){return"0"+b}return b}});SC.mixin({_downloadFrames:0,download:function(d){var a=document.createElement("iframe"),c="DownloadFrame_"+this._downloadFrames;SC.$(a).attr("id",c);a.style.border="10px";a.style.width="0px";a.style.height="0px";a.style.position="absolute";a.style.top="-10000px";a.style.left="-10000px";if(!SC.browser.isSafari){SC.$(a).attr("src",d)}document.getElementsByTagName("body")[0].appendChild(a);if(SC.browser.isSafari){SC.$(a).attr("src",d)}this._downloadFrames=this._downloadFrames+1;if(!SC.browser.isSafari){var b=function(){document.body.removeChild(document.getElementById(c));c=null};b.invokeLater(null,2000)}a=null},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},uniJapaneseConvert:function(e){var a,c="",b,d;for(b=0,d=e.length;b<d;b++){a=e.charCodeAt(b);a=((a>=65281&&a<=65392)?a-65248:a);a=(a===12540?45:a);c=c+String.fromCharCode(a)}return c},pointInElement:function(b,g,c,f){var h,d,a,e;g=jQuery(g);c=c||"border";h=SC.offset(g,f);if(c==="padding"){d=g.innerWidth();a=g.innerHeight();h.x+=window.parseInt(g.css("border-left-width").replace("px",""));h.y+=window.parseInt(g.css("border-top-width").replace("px",""))}else{d=g.outerWidth(c==="margin");a=g.outerHeight(c==="margin");if(c==="margin"){h.x-=window.parseInt(g.css("margin-left").replace("px",""));h.y-=window.parseInt(g.css("margin-top").replace("px",""))}}e={x:h.x,y:h.y,width:d,height:a};return SC.pointInRect(b,e)},switchScale:function(){$("head meta[name=viewport]").remove();if(window.innerWidth===window.screen.width){$("head").prepend('<meta name="viewport" content="width=device-width, initial-scale=0.5, maximum-scale=0.5, minimum-scale=0.5, user-scalable=0" />')}else{$("head").prepend('<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=0" />')}}});SC.mixin({ZERO_RANGE:{start:0,length:0},RANGE_NOT_FOUND:{start:0,length:-1},valueInRange:function(b,a){return(b>=0)&&(b>=a.start)&&(b<(a.start+a.length))},minRange:function(a){return a.start},maxRange:function(a){return(a.length<0)?-1:(a.start+a.length)},unionRanges:function(c,b){if((c==null)||(c.length<0)){return b}if((b==null)||(b.length<0)){return c}var d=Math.min(c.start,b.start),a=Math.max(SC.maxRange(c),SC.maxRange(b));return{start:d,length:a-d}},intersectRanges:function(c,b){if((c==null)||(b==null)){return SC.RANGE_NOT_FOUND}if((c.length<0)||(b.length<0)){return SC.RANGE_NOT_FOUND}var d=Math.max(SC.minRange(c),SC.minRange(b)),a=Math.min(SC.maxRange(c),SC.maxRange(b));if(a<d){return SC.RANGE_NOT_FOUND}return{start:d,length:a-d}},subtractRanges:function(c,b){if((c==null)||(b==null)){return SC.RANGE_NOT_FOUND}if((c.length<0)||(b.length<0)){return SC.RANGE_NOT_FOUND}var a=Math.max(SC.minRange(c),SC.minRange(b)),d=Math.min(SC.maxRange(c),SC.maxRange(b));if(a<d){return SC.RANGE_NOT_FOUND}return{start:d,length:a-d}},cloneRange:function(a){return{start:a.start,length:a.length}},rangesEqual:function(b,a){if(b===a){return true}if(b==null){return a.length<0}if(a==null){return b.length<0}return(b.start==a.start)&&(b.length==a.length)}});SC.mixin({bestStringMetricsForMaxWidth:function(a,x,n,z,w){if(!x){SC.warn("When calling bestMetricsForWidth, the second argument, maxWidth, is required. There's no reason to call this without a maxWidth.");return undefined}x=Math.ceil(parseFloat(x));var A=arguments.callee,h=SC.typeOf(n||(n=""))!==SC.T_STRING,m=h?n.style.maxWidth:undefined,o=(!h||n.cacheableForMetrics)?SC.cacheSlotFor(n,z,w,a):undefined,r=h?(A._applyMaxToEl||(A._applyMaxToEl=function(l,i){l.style.maxWidth=i+"px";return l})):(A._applyMaxToStr||(A._applyMaxToStr=function(l,i){return l.replace(/max-width:[^;]*;/g,"")+" max-width:"+i+"px"})),u=h?(A._removeMaxFromEl||(A._removeMaxFromEl=function(i){i.style.maxWidth="none";return i})):(A._removeMaxFromStr||(A._removeMaxFromStr=function(i){return i.replace(/max-width:[^;]*;/g,"")+" max-width:none"})),p=false;if(o){o.list||(o.list=[{width:Infinity,height:0}]);for(var v=1,t=o.list.length,C,b,D;v<t&&!D;v++){C=o.list[v];b=o.list[v-1];if(!C||!C.width){continue}if(x>=C.width){if((b&&b.width)||(x<=C.maxWidth)){return C}D=C}}}var q=r(n,x),s=SC.metricsForString(a,q,z,w),y=s.height,d=o?o.parent.height||(o.parent.height=SC.metricsForString("W",q,z).height):SC.metricsForString("W",q,z).height,c=Math.round(y/d);if(p){c--;y=c*d}if(y>d){var g=p?Math.ceil(s.width*2.5):s.width,k=p?s.width:Math.floor(s.width/2.5),B,f=new Date()*1,j=0;while(g-k>1||(s.height>y&&!p)||(s.height<y&&p)){j++;B=(g+k)/2;q=r(q,B);s=SC.metricsForString(a,q,z,w);if(s.height>y){k=B}else{g=B}}s.width=Math.ceil(B);s.height=y;s.maxWidth=x;s.lineHeight=d;s.lines=c;s.searchPerformed=true;s.searchTime=new Date()*1-f;s.searchCount=j}else{if(p){s=SC.metricsForString(a,q=u(q),z,w)}s.maxWidth=x;s.lineHeight=d;s.lines=c;s.searchPerformed=false}s.browserCorrection=0;if(SC.browser.isIE){s.browserCorrection=1}if(SC.browser.isMozilla){s.browserCorrection=1}s.width=Math.min(x,s.width+s.browserCorrection);if(o){var e=o.list[c];if(e&&e.maxWidth<x){e.maxWidth=x}if(!e){e=o.list[c]=s}}if(h){q.style.maxWidth=m}D=p?D:s;return D},cacheSlotFor:function(){var e=arguments.callee.caller,f=e.cache||(e.cache={});if(!arguments[0]){return f}var b=(arguments[0] instanceof Array||arguments[0].callee)?arguments[0]:arguments,d=b.length,a,c;for(c=0;c<d;c++){if(typeof(a=b[c])==="object"){a=SC.guidFor(a)}f=f[a]||(f[a]={parent:f})}return f},cachedVersionOf:function(){var a=function(c){var b=function(){var d=SC.cacheSlotFor(arguments);return d.result||(d.result=arguments.callee.func.apply(this,arguments))};b.func=c;return b};return a(a)}()});SC.mixin(SC.View,{BOUNCE_ADJUST:{run:function(h,o,j){var l=o.bounces||2,e=o.bounciness||0.25,f=h.get("layout"),g=[],b=(l*2)+1,c,d;c=o.duration||0.4;c=c/b;for(d=0;d<b;d++){if(d%2){g[d]={value:SC.clone(j),duration:c,timing:"ease-out"}}else{if(d===b-1){g[d]={value:SC.clone(j),duration:c,timing:"ease-in-out"}}else{g[d]={value:SC.clone(j),duration:c,timing:"ease-in"}}}}for(var k in j){var a=j[k],n=Math.round((a-f[k])*e);for(d=0;d<l;d++){g[(d*2)+1].value[k]=a-n;n=Math.round(n*0.5)}}var m=function(){h.didTransitionAdjust()};h._animateFrames(g,m,o.delay||0)}}});SC.mixin(SC.View,{SMOOTH_ADJUST:{run:function(a,b,d){var c,e;a.animate(d,{delay:b.delay||0,duration:b.duration||0.4,timing:b.timing||"ease"},function(f){this.didTransitionAdjust()})}}});SC.mixin(SC.View,{SPRING_ADJUST:{run:function(j,o,k){var g=o.springs||4,h=o.springiness||0.25,e=j.get("layout"),f=[],b=g+1,c,d;c=o.duration||0.4;c=c/b;for(d=0;d<b;d++){if(d!==0){f[d]={value:SC.clone(k),duration:c,timing:"ease-in-out"}}else{f[d]={value:SC.clone(k),duration:c,timing:"ease-out"}}}for(var m in k){var a=k[m],l=Math.round((a-e[m])*h);for(d=0;d<g;d++){if(d%2){f[d].value[m]=a-l}else{f[d].value[m]=a+l}l=Math.round(l*0.5)}}var n=function(){j.didTransitionAdjust()};j._animateFrames(f,n,o.delay||0)}}});SC.mixin(SC.View,{BOUNCE_IN:{setup:function(a,b,f){var c=a.get("parentView"),h,g=a.get("borderFrame"),e,d;if(f){}else{if(c){h=c.get("borderFrame")}else{h=SC.RootResponder.responder.currentWindowSize}switch(b.direction){case"left":e=h.width;break;case"up":d=h.height;break;case"down":d=-g.height;break;default:e=-g.width}}a.adjust({centerX:null,centerY:null,bottom:null,left:e||g.x,right:null,top:d||g.y,height:g.height,width:g.width})},run:function(i,n,j,c){var e=i.get("layout"),d=n.bounciness||0.25,m,b,f,a,k,h,g;switch(n.direction){case"left":a=c.x;k={left:a};m=-(a-e.left)*d;h={left:a+m};g={left:a+(m*0.5)};break;case"up":a=c.y;k={top:a};m=-(a-e.top)*d;h={top:a+m};g={top:a+(m*0.5)};break;case"down":a=c.y;k={top:a};m=(e.top-a)*d;h={top:a+m};g={top:a+(m*0.5)};break;default:a=c.x;k={left:a};m=(e.left-a)*d;h={left:a+m};g={left:a+(m*0.5)}}b=n.duration||0.4;b=b*0.2;f=[{value:k,duration:b,timing:"ease-in"},{value:h,duration:b,timing:"ease-out"},{value:k,duration:b,timing:"ease-in"},{value:g,duration:b,timing:"ease-out"},{value:k,duration:b,timing:"ease-in-out"}];var l=function(o){if(!o.isCancelled){i.didTransitionIn()}};i._animateFrames(f,l,n.delay||0)}},BOUNCE_OUT:{setup:function(b,c){var g=b.get("borderFrame"),f=g.x,e=g.y,a=g.height,d=g.width;b.adjust({centerX:null,centerY:null,bottom:null,left:f,right:null,top:e,height:a,width:d})},run:function(j,q,k,e){var f=q.bounciness||0.25,o,p,c,d,a,i,h=j.get("layout"),g=j.get("borderFrame"),n=j.get("parentView"),m,b;if(n){m=n.get("borderFrame")}else{m=SC.RootResponder.responder.currentWindowSize}switch(q.direction){case"left":b={left:h.left};a={left:-g.width};o=(h.left+g.width)*f;p={left:h.left-(o*0.5)};c={left:h.left-o};break;case"up":b={top:h.top};a={top:-g.height};o=(h.top+g.height)*f;p={top:h.top-(o*0.5)};c={top:h.top-o};break;case"down":b={top:h.top};a={top:m.height};o=(m.height-h.top)*f;p={top:h.top+(o*0.5)};c={top:h.top+o};break;default:b={left:h.left};a={left:m.width};o=(m.width-h.left)*f;p={left:h.left+(o*0.5)};c={left:h.left+o}}d=q.duration||0.6;d=d*0.2;i=[{value:p,duration:d,timing:"ease-out"},{value:b,duration:d,timing:"ease-in"},{value:c,duration:d,timing:"ease-out"},{value:b,duration:d,timing:"ease-in-out"},{value:a,duration:d,timing:"ease-in"}];var l=function(r){if(!r.isCancelled){j.didTransitionOut()}};j._animateFrames(i,l,q.delay||0)}}});SC.mixin(SC.View,{FADE_IN:{layoutProperties:["opacity"],setup:function(a,b,c){a.adjust({opacity:c?a.get("layout").opacity||0:0})},run:function(b,c,d,a){b.animate("opacity",d.opacity||1,{delay:c.delay||0,duration:c.duration||0.4,timing:c.timing||"ease"},function(e){if(!e.isCancelled){this.didTransitionIn()}})}},FADE_OUT:{layoutProperties:["opacity"],run:function(a,b){a.animate("opacity",0,{delay:b.delay||0,duration:b.duration||0.4,timing:b.timing||"ease"},function(c){if(!c.isCancelled){this.didTransitionOut()}})}}});SC.mixin(SC.View,{POP_IN:{layoutProperties:["scale"],setup:function(a,b,c){a.adjust({scale:c?a.get("layout").scale||0:0})},run:function(g,j,h,d){var a,c,e,f=j.poppiness||0.2,b;b=h.scale||1;a=b*(f+1);c=j.duration||0.25;e=[{value:{scale:a},duration:c*0.6,timing:"ease-out"},{value:{scale:b},duration:c*0.4,timing:"ease-in-out"}];var i=function(k){if(!k.isCancelled){g.didTransitionIn()}};g._animateFrames(e,i,j.delay||0)}},POP_OUT:{layoutProperties:["scale"],run:function(a,b){var f,c,e,h=b.poppiness||0.15,d;d=a.get("layout").scale||1;f=d*(h+1);c=b.duration||0.2;e=[{value:{scale:f},duration:c*0.4,timing:"ease-out"},{value:{scale:0},duration:c*0.6,timing:"ease-in-out"}];var g=function(i){if(!i.isCancelled){a.didTransitionOut()}};a._animateFrames(e,g,b.delay||0)}}});SC.mixin(SC.View,{SCALE_IN:{layoutProperties:["scale"],setup:function(a,b,c){a.adjust({scale:c?a.get("layout").scale||0:0})},run:function(b,c,d,a){b.animate("scale",d.scale||1,{delay:c.delay||0,duration:c.duration||0.4,timing:c.timing||"ease"},function(e){if(!e.isCancelled){this.didTransitionIn()}})}},SCALE_OUT:{layoutProperties:["scale"],run:function(a,b){a.animate("scale",0,{delay:b.delay||0,duration:b.duration||0.4,timing:b.timing||"ease"},function(c){if(!c.isCancelled){this.didTransitionOut()}})}}});SC.mixin(SC.View,{SLIDE_IN:{layoutProperties:["top","bottom","left","right","height","width","centerX","centerY"],setup:function(a,b,f){var c=a.get("parentView"),h,g=a.get("borderFrame"),e,d;if(f){}else{if(c){h=c.get("borderFrame")}else{h=SC.RootResponder.responder.currentWindowSize}switch(b.direction){case"left":e=h.width;break;case"up":d=h.height;break;case"down":d=-g.height;break;default:e=-g.width}}a.adjust({centerX:null,centerY:null,bottom:null,left:e||g.x,right:null,top:d||g.y,height:g.height,width:g.width})},run:function(b,c,e,a){var d,f;if(c.direction==="up"||c.direction==="down"){d="top";f=a.y}else{d="left";f=a.x}b.animate(d,f,{delay:c.delay||0,duration:c.duration||0.4,timing:c.timing||"ease"},function(g){if(!g.isCancelled){this.didTransitionIn()}})}},SLIDE_OUT:{layoutProperties:["top","bottom","left","right","height","width","centerX","centerY"],setup:function(b,c){var g=b.get("borderFrame"),f=g.x,e=g.y,a=g.height,d=g.width;b.adjust({centerX:null,centerY:null,bottom:null,left:f,right:null,top:e,height:a,width:d})},run:function(c,i,d,a){var b=c.get("borderFrame"),h=c.get("parentView"),g,f,e;if(h){g=h.get("borderFrame")}else{g=SC.RootResponder.responder.currentWindowSize}switch(i.direction){case"left":f="left";e=-b.width;break;case"up":f="top";e=-b.height;break;case"down":f="top";e=g.height;break;default:f="left";e=g.width}c.animate(f,e,{delay:i.delay||0,duration:i.duration||0.4,timing:i.timing||"ease"},function(j){if(!j.isCancelled){this.didTransitionOut()}})}}});SC.mixin(SC.View,{SPRING_IN:{setup:function(a,b,f){var c=a.get("parentView"),h,g=a.get("borderFrame"),e,d;if(f){}else{if(c){h=c.get("borderFrame")}else{h=SC.RootResponder.responder.currentWindowSize}switch(b.direction){case"left":e=h.width;break;case"up":d=h.height;break;case"down":d=-g.height;break;default:e=-g.width}}a.adjust({centerX:null,centerY:null,bottom:null,left:e||g.x,right:null,top:d||g.y,height:g.height,width:g.width})},run:function(j,o,k,c){var g=j.get("layout"),i=o.springiness||0.25,m,b,h,a,f,e,d,l;switch(o.direction){case"left":a=c.x;l={left:a};m=(g.left-a)*i;f={left:a-m};e={left:a+(m*0.5)};d={left:a-(m*0.25)};break;case"up":a=c.y;l={top:a};m=(g.top-a)*i;f={top:a-m};e={top:a+(m*0.5)};d={top:a-(m*0.25)};break;case"down":a=c.y;l={top:a};m=(a-g.top)*i;f={top:a+m};e={top:a-(m*0.5)};d={top:a+(m*0.25)};break;default:a=c.x;l={left:a};m=(a-g.left)*i;f={left:a+m};e={left:a-(m*0.5)};d={left:a+(m*0.25)}}b=o.duration||0.4;b=b*0.25;h=[{value:f,duration:b,timing:"ease-out"},{value:e,duration:b,timing:"ease-in-out"},{value:d,duration:b,timing:"ease-in-out"},{value:l,duration:b,timing:"ease-in-out"}];var n=function(p){if(!p.isCancelled){j.didTransitionIn()}};j._animateFrames(h,n,o.delay||0)}},SPRING_OUT:{setup:function(b,c){var g=b.get("borderFrame"),f=g.x,e=g.y,a=g.height,d=g.width;b.adjust({centerX:null,centerY:null,bottom:null,left:f,right:null,top:e,height:a,width:d})},run:function(j,p,k,c){var i=p.springiness||0.25,b,a,h,g=j.get("layout"),f=j.get("borderFrame"),o=j.get("parentView"),n,l,e,d;if(o){n=o.get("borderFrame")}else{n=SC.RootResponder.responder.currentWindowSize}switch(p.direction){case"left":a={left:-f.width};l=(g.left+f.width)*i;e={left:g.left-(l*0.5)};d={left:g.left+l};break;case"up":a={top:-f.height};l=(g.top+f.height)*i;e={top:g.top-(l*0.5)};d={top:g.top+l};break;case"down":a={top:n.height};l=(n.height-g.top)*i;e={top:g.top+(l*0.5)};d={top:g.top-l};break;default:a={left:n.width};l=(n.width-g.left)*i;e={left:g.left+(l*0.5)};d={left:g.left-l}}b=p.duration||0.3;b=b*0.33;h=[{value:e,duration:b,timing:"ease-in-out"},{value:d,duration:b,timing:"ease-in-out"},{value:a,duration:b,timing:"ease-in"}];var m=function(q){if(!q.isCancelled){j.didTransitionOut()}};j._animateFrames(h,m,p.delay||0)}}});SC.ContainerView=SC.View.extend({classNames:["sc-container-view"],contentView:null,contentViewBindingDefault:SC.Binding.single(),isTransitioning:NO,nowShowing:null,renderDelegateName:"containerRenderDelegate",transitionSwap:null,transitionSwapOptions:null,init:function(){var a;arguments.callee.base.apply(this,arguments);if(this.get("nowShowing")){this.nowShowingDidChange()}else{a=this.get("contentView");if(a){this.set("nowShowing",a)}}this.addObserver("contentView",this,this._sc_contentViewDidChange);this._sc_contentViewDidChange()},_sc_cancelTransitions:function(){var b=this._contentStatecharts;if(b){for(var a=b.length-1;a>=0;a--){b[a].doExit(true)}}},clippingFrame:function(){var d=this._contentStatecharts,c=this.get("frame"),a=arguments.callee.base.apply(this,arguments);if(this.get("isTransitioning")){for(var b=d.length-1;b>=0;b--){a=d[b].transitionClippingFrame(a)}}else{a.width=c.width}return a}.property("parentView","frame").cacheable(),_sc_contentViewDidChange:function(){var a=this.get("contentView");if(a&&a.kindOf(SC.CoreView)){a=this.createChildView(a)}this.replaceContent(a)},destroy:function(){this.removeObserver("contentView",this,this._sc_contentViewDidChange);this._sc_cancelTransitions();this._contentStatecharts=this._currentStatechart=null;return arguments.callee.base.apply(this,arguments)},nowShowingDidChange:function(){var c=this.get("nowShowing");if(SC.typeOf(c)===SC.T_STRING&&c.length>0){var b=c.indexOf(".");if(b===-1){var a=this.get(c);c=SC.kindOf(a,SC.CoreView)?a:SC.objectForPropertyPath(c,this.get("page"))}else{if(b===0){c=this.getPath(c.slice(1))}else{c=SC.objectForPropertyPath(c)}}}if(c&&c.kindOf(SC.CoreView)){c=this.createChildView(c)}this.set("contentView",c)}.observes("nowShowing"),statechartReady:function(){var b=this._contentStatecharts;for(var a=b.length-2;a>=0;a--){b[a].doExit(true)}this.set("isTransitioning",NO)},statechartEnded:function(a){var b=this._contentStatecharts;b.removeObject(a);if(b.length===1){b[0].entered()}},replaceContent:function(b){var f,d=this._currentStatechart,a;this.set("isTransitioning",YES);f=this._contentStatecharts;if(!f){f=this._contentStatecharts=[]}for(var c=f.length-1;c>=0;c--){var e=f[c].doExit(false,b);if(e){a=f[c];if(a){a.set("previousStatechart",d);a.gotoEnteringState()}}}if(!a){a=SC.ContainerContentStatechart.create({container:this,content:b,previousStatechart:d});f.pushObject(a)}this._currentStatechart=a},set:function(a,b){if(a==="transitionSwap"&&this.get("isTransitioning")){this._sc_cancelTransitions()}return arguments.callee.base.apply(this,arguments)}});SC.ContainerContentStatechart=SC.Object.extend({container:null,content:null,previousStatechart:null,state:"none",init:function(){arguments.callee.base.apply(this,arguments);this.gotoEnteringState()},transitionClippingFrame:function(d){var b=this.get("container"),c=b.get("transitionSwapOptions")||{},a=b.get("transitionSwap");if(a&&a.transitionClippingFrame){return a.transitionClippingFrame(b,d,c)}else{return d}},entered:function(){if(this.state==="entering"){this.gotoReadyState()}},doExit:function(b,a){if(this.state!=="exited"){this.gotoExitingState(b,a)}if(this.get("content")===a){return true}else{return false}},exited:function(){if(this.state==="exiting"){this.gotoExitedState()}},gotoEnteringState:function(){var b=this.get("container"),d=this.get("content"),e=this.get("previousStatechart"),c=b.get("transitionSwapOptions")||{},a=b.get("transitionSwap");if(this.state==="exiting"&&a.reverseBuildOut){a.reverseBuildOut(this,b,d,c);this.set("state","entering");return}else{if(d){b.appendChild(d)}}this.set("state","entering");if(e&&d&&a){if(a.willBuildInToView){a.willBuildInToView(b,d,e,c)}if(a.buildInToView){a.buildInToView(this,b,d,e,c)}else{this.entered()}}else{this.entered()}},gotoExitingState:function(c){var b=this.get("container"),f=this.get("content"),e=this._exitCount,d=b.get("transitionSwapOptions")||{},a=b.get("transitionSwap");if(this.state==="entering"&&a.reverseBuildIn){a.reverseBuildIn(this,b,f,d);this.set("state","exiting");return}this.set("state","exiting");if(!c&&f&&a){if(!e){e=this._exitCount=1}if(a.willBuildOutFromView){a.willBuildOutFromView(b,f,d,e)}if(a.buildOutFromView){a.buildOutFromView(this,b,f,d,e)}else{}this._exitCount+=1}else{this.exited()}},gotoExitedState:function(){var b=this.get("container"),d=this.get("content"),c=b.get("transitionSwapOptions")||{},a=b.get("transitionSwap");if(d){if(a&&a.didBuildOutFromView){a.didBuildOutFromView(b,d,c)}if(d.createdByParent){b.removeChildAndDestroy(d)}else{b.removeChild(d)}}b.statechartEnded(this);this._exitCount=0;this.set("state","exited")},gotoReadyState:function(){var b=this.get("container"),d=this.get("content"),c=b.get("transitionSwapOptions")||{},a=b.get("transitionSwap");if(d&&a&&a.didBuildInToView){a.didBuildInToView(b,d,c)}b.statechartReady();this.set("state","ready")}});sc_require("views/container");SC.mixin(SC.ContainerView,{DISSOLVE:{willBuildInToView:function(a,c,d,b){c.adjust({opacity:0})},buildInToView:function(b,a,d,e,c){d.animate("opacity",1,{duration:c.duration||0.4,timing:c.timing||"ease"},function(f){if(b.get("state")==="entering"){b.entered()}})},buildOutFromView:function(b,a,e,c,d){if(d==1){e.animate("opacity",0,{duration:c.duration||0.4,timing:c.timing||"ease"},function(f){if(!f.isCancelled){b.exited()}})}},didBuildOutFromView:function(a,c,b){c.adjust({opacity:1})}}});sc_require("views/container");SC.mixin(SC.ContainerView,{FADE_COLOR:{willBuildInToView:function(a,d,e,c){var b,f;d.adjust({opacity:0});b=SC.Color.from(c.color||"black");f=SC.View.create({layout:{opacity:0,zIndex:1},render:function(g){g.addStyle("background-color",b.get("cssText"))}});a.appendChild(f)},buildInToView:function(b,a,d,e,c){var f=a.get("childViews"),g;g=f.objectAt(f.get("length")-1);g.animate("opacity",1,{duration:c.duration*0.5||0.4,timing:c.timing||"ease-in"},function(){d.adjust("opacity",1);g.animate("opacity",0,{duration:c.duration*0.5||0.4,timing:c.timing||"ease-in"},function(h){a.removeChild(this);this.destroy();if(b.get("state")==="entering"){b.entered()}})})},buildOutFromView:function(b,a,e,c,d){}}});sc_require("views/container");SC.mixin(SC.ContainerView,{MOVE_IN:{willBuildInToView:function(a,f,e,i){var c=a.get("frame"),d,g,h,b;h=c.height;b=c.width;switch(i.direction){case"right":d=-b;break;case"up":g=h;break;case"down":g=-h;break;default:d=b}f.adjust({bottom:null,left:d||0,right:null,top:g||0,height:h,width:b})},buildInToView:function(b,a,e,g,c){var d,f;switch(c.direction){case"right":d="left";break;case"up":d="top";break;case"down":d="top";break;default:d="left"}e.animate(d,0,{duration:c.duration||0.4,timing:c.timing||"ease"},function(h){if(b.get("state")==="entering"){b.entered()}})},didBuildInToView:function(a,c,b){c.adjust({bottom:0,right:0,height:null,width:null})},didBuildOutFromView:function(a,c,b){c.adjust({bottom:0,right:0,height:null,width:null})},buildOutFromView:function(b,a,d,c){}}});sc_require("views/container");SC.mixin(SC.ContainerView,{PUSH:{willBuildInToView:function(a,h,g,l){var e=0,j=0,c=a.get("frame"),f=0,i=0,k,b;k=c.height;b=c.width;if(g&&g.get("content")){var d=g.getPath("content.liveAdjustments");e=d.left||0;j=d.top||0}switch(l.direction){case"right":f=-b+e;break;case"up":i=k+j;break;case"down":i=-k+j;break;default:f=b+e}h.adjust({bottom:null,right:null,left:f,top:i,height:k,width:b})},buildInToView:function(b,a,e,f,c){var d;switch(c.direction){case"up":d="top";break;case"down":d="top";break;default:d="left"}e.animate(d,0,{duration:c.duration||0.4,timing:c.timing||"ease"},function(g){if(b.get("state")==="entering"){b.entered()}})},didBuildInToView:function(a,c,b){c.adjust({bottom:0,right:0,height:null,width:null})},willBuildOutFromView:function(b,e,c){var f=b.get("frame"),a,d;a=f.height;d=f.width;e.adjust({bottom:null,right:null,height:a,width:d})},buildOutFromView:function(b,a,f,c,e){var h=a.get("frame"),d,g;switch(c.direction){case"right":d="left";g=h.width;break;case"up":d="top";g=-h.height;break;case"down":d="top";g=h.height;break;default:d="left";g=-h.width}f.animate(d,g*e,{duration:c.duration||0.4,timing:c.timing||"ease"},function(i){if(!i.isCancelled){b.exited()}})},didBuildOutFromView:function(a,c,b){c.adjust({bottom:0,right:0,height:null,width:null})},transitionClippingFrame:function(a,d,b){var c=a.get("frame");switch(b.direction){case"right":d.width=c.width*2;d.x=-c.width;break;case"up":d.height=c.height*2;d.y=-c.height;break;case"down":d.height=c.height*2;d.y=0;break;default:d.width=c.width*2;d.x=0}return d}}});sc_require("views/container");SC.mixin(SC.ContainerView,{REVEAL:{buildInToView:function(b,a,d,e,c){},didBuildInToView:function(a,c,b){c.adjust({bottom:0,right:0,height:null,width:null,zIndex:null})},willBuildOutFromView:function(b,f,c,d){var g=b.get("frame"),a,e;a=g.height;e=g.width;f.adjust({bottom:null,right:null,height:a,width:e,zIndex:d})},buildOutFromView:function(b,a,f,c,e){if(e===1){var h=a.get("frame"),d,g;switch(c.direction){case"right":d="left";g=-h.width;break;case"up":d="top";g=-h.height;break;case"down":d="top";g=h.height;break;default:d="left";g=h.width}f.animate(d,g,{duration:c.duration||0.4,timing:c.timing||"ease"},function(i){if(!i.isCancelled){b.exited()}})}},didBuildOutFromView:function(a,c,b){c.adjust({top:0,left:0,bottom:0,right:0,height:null,width:null,zIndex:null})}}});sc_require("system/string");SC.VALIDATE_OK=YES;SC.VALIDATE_NO_CHANGE=NO;SC.Validator=SC.Object.extend({fieldValueForObject:function(b,c,a){return b},objectForFieldValue:function(c,b,a){return c},validate:function(a,b){return true},validateError:function(a,b){return SC.$error(SC.String.loc("Invalid.General(%@)",b.get("fieldValue")),b.get("fieldKey"))},validateChange:function(b,c,a){return this.validate(b,c)?SC.VALIDATE_OK:this.validateError(b,c)},validateSubmit:function(a,b){return this.validate(a,b)?SC.VALIDATE_OK:this.validateError(a,b)},validatePartial:function(a,b){if(!b.get("isValid")){return this.validate(a,b)?SC.VALIDATE_OK:this.validateError(a,b)}else{return SC.VALIDATE_NO_CHANGE}},validateKeyDown:function(b,c,a){return true},attachTo:function(a,b){},detachFrom:function(a,b){}});SC.Validator.mixin({OK:true,NO_CHANGE:false,findFor:function(e,g,f){var c;if(!f){return}if(f instanceof SC.Validator){c=f}else{if(f.isClass){c=f.create()}else{if(SC.typeOf(f)===SC.T_STRING){var b=null;var a=f.match(/^(.+)\[(.*)\]/);if(a){f=a[1];b=a[2]}f=SC.String.classify(f);var d=SC.Validator[f];if(SC.none(d)){throw new Error("validator %@ not found for %@".fmt(f,g))}else{if(b){if(!e){throw new Error("named validator (%@) could not be found for field %@ because the field does not belong to a form".fmt(b,g))}if(!e._validatorHash){e._validatorHash={}}c=(b)?e._validatorHash[b]:null;if(!c){c=d.create()}if(b){e._validatorHash[b]=c}}else{c=d.create()}}}}}return c},fieldValueForObject:function(a,b,c){if(this.prototype&&this.prototype.fieldValueForObject){return this.prototype.fieldValueForObject(a,b,c)}else{return null}},objectForFieldValue:function(b,a,c){if(this.prototype&&this.prototype.objectForFieldValue){return this.prototype.objectForFieldValue(b,a,c)}else{return null}}});sc_require("validators/validator");SC.Validator.CreditCard=SC.Validator.extend({fieldValueForObject:function(a,b,c){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(b,a,c){return b.replace(/[\s-\.\:]/g,"")},validate:function(a,b){return this.checkNumber(b.get("fieldValue"))},validateError:function(b,c){var a=c.get("errorLabel")||"Field";return SC.$error(SC.String.loc("Invalid.CreditCard(%@)",a),a)},validateKeyDown:function(b,c,a){return !!a.match(/[0-9\- ]/)},checkNumber:function(h){if(!h||h.length===0){return YES}h=h.replace(/[^0-9]/g,"");var a="0123456789";var g=h.length;var f=parseInt(h,0);var l=h.toString();l=l.replace(/^\s+|\s+$/g,"");var k=0;var n=true;var b=false;var m;var d;for(var c=0;c<g;c++){m=""+l.substring(c,c+1);if(a.indexOf(m)=="-1"){n=false}}if(!n){b=false}if((g===0)&&(b)){b=false}else{if(g>=15){for(var e=g;e>0;e--){d=parseInt(f,0)%10;d=parseInt(d,0);k+=d;e--;f=f/10;d=parseInt(f,0)%10;d=d*2;switch(d){case 10:d=1;break;case 12:d=3;break;case 14:d=5;break;case 16:d=7;break;case 18:d=9;break;default:d=d}f=f/10;k+=d}if((k%10)===0){b=true}else{b=false}}}return b}});sc_require("validators/validator");SC.Validator.Date=SC.Validator.extend({format:"%b %d, %Y %i:%M:%S %p",fieldValueForObject:function(a,b,e){var d=this.get("format"),c;if(SC.typeOf(a)===SC.T_NUMBER){c=SC.DateTime.create(a)}else{if(a instanceof Date){c=a.getTime()}}if(c){a=c.toFormattedString(d)}return a},objectForFieldValue:function(c,a,e){var d=this.get("format"),b;if(c){b=SC.DateTime.parse(c,d);c=b?b._ms:null}return c}});sc_require("validators/validator");SC.Validator.DateTime=SC.Validator.extend({format:"%d/%m/%Y",fieldValueForObject:function(a,b,c){if(SC.kindOf(a,SC.DateTime)){a=a.toFormattedString(this.get("format"))}else{a=null}return a},objectForFieldValue:function(b,a,c){if(b){b=SC.DateTime.parse(b,this.get("format"))}return b}});sc_require("validators/validator");SC.Validator.Email=SC.Validator.extend({validate:function(a,b){return(b.get("fieldValue")||"").match(/.+@.+\...+/)},validateError:function(b,c){var a=c.get("errorLabel")||"Field";return SC.$error(SC.String.loc("Invalid.Email(%@)",a),a)}});SC.Validator.EmailOrEmpty=SC.Validator.Email.extend({validate:function(a,c){var b=c.get("fieldValue");return(b&&b.length>0)?b.match(/.+@.+\...+/):true}});sc_require("validators/validator");SC.Validator.NotEmpty=SC.Validator.extend({validate:function(a,c){var b=c.get("fieldValue");if(SC.none(b)){return NO}if(!SC.none(b.length)){return b.length>0}return YES},validateError:function(b,c){var a=c.get("errorLabel")||"Field";return SC.$error(SC.String.loc("Invalid.NotEmpty(%@)",SC.String.capitalize(a)),c.get("errorLabel"))}});sc_require("validators/validator");sc_require("system/utils/misc");SC.Validator.Number=SC.Validator.extend({places:0,fieldValueForObject:function(a,b,c){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(c,b,d){var a;c=c.replace(/,/g,"");switch(SC.typeOf(c)){case SC.T_STRING:if(c.length===0){c=null}else{if(this.get("places")>0){c=parseFloat(c)}else{if(c.length===1&&c.match(/-/)){c=null}else{a=parseInt(c,0);if(isNaN(a)){c=SC.uniJapaneseConvert(c);c=parseInt(c,0);if(isNaN(c)){c=""}}else{c=a}}}}break;case SC.T_NULL:case SC.T_UNDEFINED:c=null;break}return c},validate:function(a,c){var b=c.get("fieldValue");return(b==="")||!(isNaN(b)||isNaN(parseFloat(b)))},validateError:function(b,c){var a=c.get("errorLabel")||"Field";return SC.$error(SC.String.loc("Invalid.Number(%@)",a),a)},validateKeyDown:function(b,c,a){if(!a){a=""}var d=c.$input().val();if(!d){d=""}d+=a;if(this.get("places")===0){if(a.length===0){return true}else{return d.match(/^[\-{0,1}]?[0-9,\0]*/)[0]===d}}else{if(a.length===0){return true}else{return d.match(/^[\-{0,1}]?[0-9,\0]*\.?[0-9\0]+/)===d}}}});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(e){if(!this.fields||this.fields.length===0){return true}var d=false;var b=false;var a=true;var c=this.fields[0].get("fieldValue");this.fields.forEach(function(g){var f=g.get("fieldValue");if(f!=c){a=false}if(!f||f.length===0){d=true}if(f&&f.length>0){b=true}});if(e){return(b===false)?false:a}else{return(d===true)?true:a}},updateFields:function(c,b){if(!this.fields||this.fields.length===0){return true}var a=SC.String.loc("Invalid.Password");var d=this._field;this.fields.forEach(function(e){var g=(b)?null:((e==d)?a:"");c.setErrorFor(e,g)});return(b)?SC.VALIDATE_OK:a},validateChange:function(b,c,a){return this.updateFields(b,this.validate(false))},validateSubmit:function(a,b){return this.updateFields(a,this.validate(true))},validatePartial:function(b,c){var a=!this._field.get("isValid");if(a){return this.updateFields(b,this.validate(false))}else{return SC.VALIDATE_NO_CHANGE}}});sc_require("validators/validator");SC.Validator.PositiveInteger=SC.Validator.extend({defaultValue:null,fieldValueForObject:function(a,b,c){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(b,a,c){b=b.replace(/,/g,"");switch(SC.typeOf(b)){case SC.T_STRING:if(b.length===0){b=this.get("defaultValue")}else{b=parseInt(b,0)}break;case SC.T_NULL:case SC.T_UNDEFINED:b=this.get("defaultValue");break}if(isNaN(b)){return this.get("defaultValue")}return b},validate:function(a,c){var b=c.get("fieldValue");return(b==="")||!isNaN(b)},validateError:function(b,c){var a=c.get("errorLabel")||"Field";return SC.$error(SC.String.loc("Invalid.Number(%@)",a),a)},validateKeyDown:function(b,c,a){var d=c.$input().val();if(!d){d=""}d+=a;if(a.length===0){return true}else{return d.match(/^[0-9\0]*/)[0]===d}}});sc_require("mixins/validatable");SC.FieldView=SC.View.extend(SC.Control,SC.Validatable,{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(){var a=this._inputElementTagName();return this.$(a).andSelf().filter(a)},_inputElementTagName:function(){return"input"},setFieldValue:function(b){if(SC.none(b)){b=""}var a=this.$input();if(a.val()!==b){a.val(b)}return this},getFieldValue:function(){return this.$input().val()},_field_fieldValueDidChange:function(a){SC.run(function(){this.fieldValueDidChange(NO)},this)},fieldValueDidChange:function(a){var c=this.getFieldValue();var b=this.objectForFieldValue(c,a);this.setIfChanged("value",b)},_field_valueDidChange:function(){this.setFieldValue(this.get("fieldValue"))}.observes("fieldValue"),didCreateLayer:function(){this.setFieldValue(this.get("fieldValue"));this._addChangeEvent()},willDestroyLayer:function(){SC.Event.remove(this.$input(),"change",this,this._field_fieldValueDidChange)},mouseDown:function(a){this._field_isMouseDown=YES;a.allowDefault();return YES},mouseExited:function(a){if(this._field_isMouseDown){this.set("isActive",NO)}a.allowDefault();return YES},mouseEntered:function(a){this.set("isActive",this._field_isMouseDown);a.allowDefault();return YES},mouseUp:function(a){if(this._field_isMouseDown){this.set("isActive",NO)}this._field_isMouseDown=NO;a.allowDefault();return YES},keyDown:function(b){if(b.which===9||b.keyCode===9){var a=b.shiftKey?this.get("previousValidKeyView"):this.get("nextValidKeyView");if(a){a.becomeFirstResponder()}else{b.allowDefault()}return YES}if(this.performValidateKeyDown(b)){this._isKeyDown=YES;b.allowDefault()}else{b.stop()}return YES},acceptsFirstResponder:function(){if(SC.FOCUS_ALL_CONTROLS){return this.get("isEnabledInPane")}return NO}.property("isEnabledInPane"),_addChangeEvent:function(){SC.Event.add(this.$input(),"change",this,this._field_fieldValueDidChange)},_field_setFieldValue:function(b){this.propertyWillChange("fieldValue");if(this.fieldValueForObject){b=this.fieldValueForObject(b)}var a=this.setFieldValue(b);this.propertyDidChange("fieldValue");return a},_field_getFieldValue:function(){var a=this.getFieldValue();if(this.objectForFieldValue){a=this.objectForFieldValue(a)}return a}});SC.IMAGE_STATE_NONE="none";SC.IMAGE_STATE_LOADING="loading";SC.IMAGE_STATE_LOADED="loaded";SC.IMAGE_STATE_FAILED="failed";SC.IMAGE_TYPE_NONE="NONE";SC.IMAGE_TYPE_URL="URL";SC.IMAGE_TYPE_CSS_CLASS="CSS_CLASS";SC.BLANK_IMAGE_DATAURL="data:image/gif;base64,R0lGODlhAQABAJAAAP///wAAACH5BAUQAAAALAAAAAABAAEAAAICBAEAOw==";SC.BLANK_IMAGE_URL=SC.browser.isIE&&SC.browser.compare(SC.browser.version,"8")<=0?"../../../../static/sproutcore/foundation/fr/cert/source/resources/blank.gif":SC.BLANK_IMAGE_DATAURL;SC.BLANK_IMAGE=new Image();SC.BLANK_IMAGE.src=SC.BLANK_IMAGE_URL;SC.BLANK_IMAGE.width=SC.BLANK_IMAGE.height=1;SC.ImageView=SC.View.extend(SC.Control,SC.InnerFrame,{classNames:"sc-image-view",displayProperties:["align","scale","value","displayToolTip"],renderDelegateName:function(){return(this.get("useCanvas")?"canvasImage":"image")+"RenderDelegate"}.property("useCanvas").cacheable(),tagName:function(){return this.get("useCanvas")?"canvas":"div"}.property("useCanvas").cacheable(),canLoadInBackground:NO,image:SC.BLANK_IMAGE,innerFrame:function(){var c=this.get("image"),b=c.width,a=c.height,d=this.get("frame");if(SC.none(d)){return{x:0,y:0,width:0,height:0}}return this.innerFrameForSize(b,a,d.width,d.height)}.property("align","image","scale","frame").cacheable(),localize:YES,status:SC.IMAGE_STATE_NONE,type:function(){var a=this.get("value");if(SC.ImageView.valueIsUrl(a)){return SC.IMAGE_TYPE_URL}else{if(!SC.none(a)){return SC.IMAGE_TYPE_CSS_CLASS}}return SC.IMAGE_TYPE_NONE}.property("value").cacheable(),useCanvas:function(){return SC.platform.supportsCanvas&&!this.get("useStaticLayout")}.property("useStaticLayout").cacheable(),useImageQueue:YES,value:null,valueBindingDefault:SC.Binding.oneWay(),viewDidResize:function(){arguments.callee.base.apply(this,arguments);if(this.get("useStaticLayout")){if(this._updatingOnce){this._updatingOnce=false}else{this._updatingOnce=true;this.updateLayerIfNeeded()}}else{this.updateLayerIfNeeded()}},init:function(){arguments.callee.base.apply(this,arguments);this._valueDidChange();if(this.get("useImageCache")!==undefined){this.set("useImageQueue",this.get("useImageCache"))}},didAppendToDocument:function(){if(this.get("useStaticLayout")){this.updateLayerIfNeeded()}},didCreateLayer:function(){if(this.get("useCanvas")){this.updateLayerIfNeeded()}},_valueDidChange:function(){var b=this.get("value"),a=this.get("type");this.set("image",SC.BLANK_IMAGE);if(a==SC.IMAGE_TYPE_URL){this.set("status",SC.IMAGE_STATE_LOADING);if(!this._loadImageUsingCache()){this._loadImage()}}}.observes("value"),_loadImageUsingCache:function(){var c=this.get("value"),b=this.get("type");if(b===SC.IMAGE_TYPE_URL&&this.get("useImageQueue")){var a=this.get("isVisibleInWindow")||this.get("canLoadInBackground");SC.imageQueue.loadImage(c,this,this._loadImageUsingCacheDidComplete,a);return YES}return NO},_loadImageUsingCacheDidComplete:function(a,c){var b=this.get("value");if(b===a){if(SC.ok(c)){this.didLoad(c)}else{this.didError(c)}}},_loadImage:function(){var d=this.get("value"),b=this.get("type"),c=this,f,a;if(b===SC.IMAGE_TYPE_URL){f=new Image();var e=function(){SC.run(function(){c._loadImageDidComplete(d,SC.$error("SC.Image.FailedError","Image",-101))})};var g=function(){SC.run(function(){c._loadImageDidComplete(d,f)})};a=$(f);a.bind("error",e);a.bind("abort",e);a.bind("load",g);f.src=d;return YES}return NO},_loadImageDidComplete:function(a,c){var b=this.get("value");if(b===a){if(SC.ok(c)){this.didLoad(c)}else{this.didError(c)}}},didLoad:function(a){this.set("status",SC.IMAGE_STATE_LOADED);if(!a){a=SC.BLANK_IMAGE}this.set("image",a);this.displayDidChange()},didError:function(a){this.set("status",SC.IMAGE_STATE_FAILED);this.set("image",SC.BLANK_IMAGE)}});SC.ImageView.valueIsUrl=function(a){return a&&SC.typeOf(a)===SC.T_STRING?a.indexOf("/")>=0:NO};sc_require("views/field");sc_require("system/text_selection");sc_require("mixins/editable");SC.AUTOCAPITALIZE_NONE="none";SC.AUTOCAPITALIZE_SENTENCES="sentences";SC.AUTOCAPITALIZE_WORDS="words";SC.AUTOCAPITALIZE_CHARACTERS="characters";SC.TextFieldView=SC.FieldView.extend(SC.Editable,{classNames:["sc-text-field-view"],isTextField:true,applyImmediately:true,commitOnBlur:true,isTextArea:false,focused:false,hint:"",type:"text",isBrowserFocusable:true,autoCorrect:true,autoCapitalize:SC.CAPITALIZE_SENTENCES,autoComplete:null,formattedHint:function(){var a=this.get("hint");a=typeof(a)==="string"&&this.get("localize")?SC.String.loc(a):a;if(this.get("useHintOverlay")){a=this.get("escapeHTML")?SC.RenderContext.escapeHTML(a):a}return a}.property("hint","localize").cacheable(),hintOnFocus:true,localize:true,isEditing:false,defaultTabbingEnabled:true,isContextMenuEnabled:true,allowsErrorAsValue:true,leftAccessoryView:null,rightAccessoryView:null,spellCheckEnabled:true,maxLength:5096,shouldRenderBorder:true,supportsAutoResize:true,autoResizeLayer:function(){return this.$input()[0]}.property("layer").cacheable(),autoResizeText:function(){return this.get("value")}.property("value").cacheable(),autoResizePadding:SC.propertyFromRenderDelegate("autoResizePadding",20),isEditable:true,selection:function(m,l){var d=this.$input()[0],j="none",f,a,c;if(l===undefined){if(d){a=null;c=null;if(!d.value){a=c=0}else{try{if(SC.platform.input.selectionStart){a=d.selectionStart}if(SC.platform.input.selectionEnd){c=d.selectionEnd}if(SC.platform.input.selectionDirection){j=d.selectionDirection}}catch(g){return null}if(a===null||c===null){var k=document.selection;if(k){var i=k.type;if(i&&(i==="None"||i==="Text")){f=k.createRange();if(!this.get("isTextArea")){var b=f.text.length;a=Math.abs(f.moveStart("character",0-(d.value.length+1)));c=a+b}else{var h=f.duplicate();h.moveToElementText(d);h.setEndPoint("EndToStart",f);a=h.text.length;c=a+f.text.length}}}}}return SC.TextSelection.create({start:a,end:c,direction:j})}else{return null}}else{if(!l||!l.kindOf||!l.kindOf(SC.TextSelection)){throw new Error("When setting the selection, you must specify an SC.TextSelection instance.")}if(d){if(d.setSelectionRange){try{d.setSelectionRange(l.get("start"),l.get("end"),l.get("direction"))}catch(g){return null}if(!SC.platform.input.selectionDirection){l.set("direction","none")}}else{f=d.createTextRange();a=l.get("start");f.move("character",a);f.moveEnd("character",l.get("end")-a);f.select()}}return l}}.property("fieldValue").cacheable(),useHintOverlay:function(){return this.get("hintOnFocus")||!SC.platform.input.placeholder}.property().cacheable(),displayProperties:["isBrowserFocusable","formattedHint","fieldValue","isEditing","isEditable","isEnabledInPane","leftAccessoryView","rightAccessoryView","isTextArea","maxLength"],createChildViews:function(){arguments.callee.base.apply(this,arguments);this.accessoryViewObserver()},acceptsFirstResponder:function(){return this.get("isEnabledInPane")}.property("isEnabledInPane"),accessoryViewObserver:function(){var a,c=["leftAccessoryView","rightAccessoryView"],f=c.length,d,g,b,j;for(d=0;d<f;d++){g=c[d];b=this["_"+g];j=this.get(g);if(!(b&&j&&(b===j))){if(b){a=b.get("classNames");a=a.without("sc-text-field-accessory-view");b.set("classNames",a);if(b.createdByParent){this.removeChildAndDestroy(b)}else{this.removeChild(b)}b=this["_"+g]=this["_created"+g]=null}if(j){j=this.createChildView(j);if(g==="rightAccessoryView"){var e=j.get("layout");j.adjust({left:null,right:e.right||0})}a=j.get("classNames");var h="sc-text-field-accessory-view";if(a.indexOf(h)<0){a=SC.clone(a);a.push(h);j.set("classNames",a)}this.appendChild(j);this["_"+g]=j}}}}.observes("leftAccessoryView","rightAccessoryView"),render:function(e,f){var a,d,c,b;a=this.get("fieldValue");if(SC.none(a)){a=""}a=String(a);e.setClass("not-empty",a.length>0);d=this._getAccessoryViewWidths();c=d.left;b=d.right;if(c){c+="px"}if(b){b+="px"}this._renderField(e,f,a,c,b)},_forceRenderFirstTime:false,_renderFieldLikeFirstTime:function(){this.set("_forceRenderFirstTime",true)}.observes("isTextArea"),_renderField:function(f,l,y,j,t){var u=this.get("formattedHint"),d="",k=this.get("maxLength"),w=this.get("isTextArea"),i=this.get("isEnabledInPane"),q=this.get("isEditable"),v=this.get("autoCorrect"),A=this.get("autoCapitalize"),D=this.get("autoComplete"),o=this.get("isBrowserFocusable"),C="",e="",c="",s="",n="",m="",B,z,g,p,h,a;f.setClass("text-area",w);a=SC.browser.isWebkit&&SC.browser.compare(SC.browser.engineVersion,"532")<0;f.setClass("oldWebKitFieldPadding",a);if(l||this._forceRenderFirstTime){this._forceRenderFirstTime=false;n=i?(q?"":' readonly="readonly"'):' disabled="disabled"';B=this.get("layerId");C=this.get("spellCheckEnabled")?' spellcheck="true"':' spellcheck="false"';if(!SC.none(v)){c=" autocorrect="+(!v?'"off"':'"on"')}if(!SC.none(A)){if(SC.typeOf(A)==="boolean"){e=" autocapitalize="+(!A?'"none"':'"sentences"')}else{e=" autocapitalize="+A}}if(!SC.none(D)){s=" autocomplete="+(!D?'"off"':'"on"')}if(!o){m=' tabindex="-1"'}if(this.get("shouldRenderBorder")){f.push('<div class="border"></div>')}z="";if(j||t){z='style="';if(j){z+="left:"+j+";"}if(t){z+="right:"+t+";"}z+='"'}f.push('<div class="padding" '+z+">");y=this.get("escapeHTML")?SC.RenderContext.escapeHTML(y):y;if(this.get("useHintOverlay")){var x='<div aria-hidden="true" class="hint '+(w?"":"ellipsis")+'%@">'+u+"</div>";f.push(x.fmt(y?" sc-hidden":""))}else{d=' placeholder="'+u+'"'}h="field";if(w){f.push('<textarea aria-label="'+u+'" class="'+h+'" aria-multiline="true"" name="'+B+'"'+n+d+C+c+e+m+' maxlength="'+k+'">'+y+"</textarea></div>")}else{g=this.get("type");f.push('<input aria-label="'+u+'" class="'+h+'" type="'+g+'" name="'+B+'"'+n+d+C+c+e+s+m+' maxlength="'+k+'" value="'+y+'"/></div>')}}else{var r=this.$input(),b=r[0];if(this.get("useHintOverlay")){f.$(".hint")[0].innerHTML=u}else{r.attr("placeholder",u)}r.attr("maxLength",k);if(SC.browser.name===SC.BROWSER.ie&&SC.browser.version<=8&&!w){r.css("line-height",this.get("frame").height+"px")}if(!SC.none(v)){r.attr("autocorrect",!v?"off":"on")}else{r.attr("autocorrect",null)}if(!SC.none(A)){if(SC.typeOf(A)==="boolean"){r.attr("autocapitalize",!A?"none":"sentences")}else{r.attr("autocapitalize",A)}}else{r.attr("autocapitalize",null)}if(!SC.none(D)){r.attr("autoComplete",!D?"off":"on")}else{r.attr("autoComplete",null)}if(o){r.removeAttr("tabindex")}else{r.attr("tabindex","-1")}if(!q){r.attr("readOnly",true)}else{r.attr("readOnly",null)}if(b){p=b.parentNode.style;if(j){if(p.left!==j){p.left=j}}else{p.left=null}if(t){if(p.right!==t){p.right=t}}else{p.right=null}}}},_getAccessoryViewWidths:function(){var c={},j=["left","right"],d=j.length,f,g,k,a,h,e,b;for(f=0;f<d;f++){g=j[f];k=this["_"+g+"AccessoryView"];if(k&&k.isObservable){b=k.get("frame");if(b){a=b.width;if(a){h=k.get("layout");if(h){e=h[g];a+=e}c[g]=a}}}}return c},didCreateLayer:function(){arguments.callee.base.apply(this,arguments);if(this.get("isTextArea")){this.invokeLast(this._addTextAreaEvents)}else{this._addTextAreaEvents();if(SC.browser.isMozilla){var a=this.$input();SC.Event.add(a,"keypress",this,this._firefox_dispatch_keypress)}}},didAppendToDocument:function(){this._fixupTextLayout()},_fixupTextLayout:function(){var a=this.get("frame").height;if(SC.browser.name===SC.BROWSER.ie&&SC.browser.version<=8&&!this.get("isTextArea")){this.$input().css("line-height",a+"px")}if(this.get("useHintOverlay")&&!this.get("isTextArea")){var b=this.$(".hint");b.css("line-height",b.outerHeight()+"px")}},_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);SC.Event.add(a,"input",this,this._textField_inputDidChange)},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);SC.Event.remove(a,"keypress",this,this._firefox_dispatch_keypress);SC.Event.remove(a,"input",this,this._textField_inputDidChange)},_textField_fieldDidFocus:function(a){SC.run(function(){this.set("focused",true);this.fieldDidFocus(a)},this)},_textField_fieldDidBlur:function(a){SC.run(function(){this.set("focused",false);this.fieldDidBlur(this._origEvent||a)},this)},fieldDidFocus:function(a){this.becomeFirstResponder();this.beginEditing(a);if(this._didHideInterceptForPane){this._didHideInterceptForPane.showTouchIntercept();this._didHideInterceptForPane=null}var b=this.get("pane");if(b&&b.get("hasTouchIntercept")){b.hideTouchIntercept();this._didHideInterceptForPane=this.get("pane")}},fieldDidBlur:function(a){this.resignFirstResponder(a);if(this.get("commitOnBlur")){this.commitEditing(a)}var b=this._didHideInterceptForPane;if(b){b.showTouchIntercept();b=null}},_field_fieldValueDidChange:function(a){if(this.get("focused")){SC.run(function(){this.fieldValueDidChange(false)},this)}this.updateHintOnFocus()},_textField_inputDidChange:function(){var a=SC.empty(this._fieldValueDidChangeTimer)||!this._fieldValueDidChangeTimer.get("isValid");if(this.get("applyImmediately")&&a){this.invokeLater(this.fieldValueDidChange,10)}},updateHintOnFocus:function(){if(!this.get("useHintOverlay")){return}if(this.getFieldValue()){this.$(".hint").addClass("sc-hidden")}else{this.$(".hint").removeClass("sc-hidden");this._fixupTextLayout()}}.observes("value"),_topOffsetForFirefoxCursorFix:3,_firefox_dispatch_keypress:function(a){var d=this.get("selection"),e=this.get("value"),c=e?e.length:0,b;if(!d||((d.get("length")===0&&(d.get("start")===0)||d.get("end")===c))){b=SC.RootResponder.responder;if(a.keyCode===9){return}b.keypress.call(b,a);a.stopPropagation()}},_textField_selectionDidChange:function(){this.notifyPropertyChange("selection")},didBecomeKeyResponderFrom:function(a){if(this.get("isVisibleInWindow")){var b=this.$input()[0];try{if(b){b.focus()}}catch(c){}if(!this._txtFieldMouseDown){this.invokeLast(this._selectRootElement)}}},_selectRootElement:function(){var b=this.$input()[0],a;if(b){a=SC.browser.os===SC.OS.mac&&SC.browser.compare(SC.browser.osVersion,"10.7")===0;if(!(SC.browser.name===SC.BROWSER.safari&&a&&SC.buildLocale==="ko-kr")){b.select()}}else{this._textField_selectionDidChange()}},didLoseKeyResponderTo:function(a){var b=this.$input()[0];if(b){b.blur()}this.invokeLater("scrollToOriginIfNeeded",100)},scrollToOriginIfNeeded:function(){var b=this.get("pane");if(!b){return}var a=b.get("firstResponder");if(!a||!a.get("isTextField")){document.body.scrollTop=document.body.scrollLeft=0}},keyDown:function(a){return this.interpretKeyEvents(a)||false},insertText:function(c,a){var f=a.which,d=a.keyCode,b=false;if(!SC.platform.input.maxlength&&this.get("isTextArea")){var e=this.get("value");if(e&&((!SC.browser.isMozilla&&f>47)||(SC.browser.isMozilla&&((f>32&&f<43)||f>47)&&!(d>36&&d<41)))&&(e.length>=this.get("maxLength"))){b=true}}if(this.performValidateKeyDown(a)&&!b){a.allowDefault()}else{a.stop()}if(this.get("applyImmediately")){this._fieldValueDidChangeTimer=this.invokeLater(this.fieldValueDidChange,10)}return true},insertTab:function(b){if(!this.get("defaultTabbingEnabled")){b.preventDefault();return false}var a=this.get("nextValidKeyView");if(a){a.becomeFirstResponder()}else{b.allowDefault()}return true},insertBacktab:function(b){if(!this.get("defaultTabbingEnabled")){b.preventDefault();return false}var a=this.get("previousValidKeyView");if(a){a.becomeFirstResponder()}else{b.allowDefault()}return true},insertNewline:function(a){if(this.get("isTextArea")||a.isIMEInput){a.allowDefault();return true}return false},deleteForward:function(a){a.allowDefault();return true},deleteBackward:function(a){a.allowDefault();return true},moveLeft:function(a){a.allowDefault();return true},moveRight:function(a){a.allowDefault();return true},selectAll:function(a){a.allowDefault();return true},moveUp:function(a){if(this.get("isTextArea")){a.allowDefault();return true}return false},moveDown:function(a){if(this.get("isTextArea")){a.allowDefault();return true}return false},keyUp:function(a){if(SC.browser.isMozilla&&a.keyCode===SC.Event.KEY_RETURN){this.fieldValueDidChange()}this.invokeNext(this._textField_selectionDidChange);a.allowDefault();return true},mouseDown:function(a){if(!this.get("isEnabledInPane")){a.stop();return true}else{this._txtFieldMouseDown=true;this.becomeFirstResponder();return arguments.callee.base.apply(this,arguments)}},mouseUp:function(a){this._txtFieldMouseDown=false;if(!this.get("isEnabledInPane")){a.stop();return true}this.invokeNext(this._textField_selectionDidChange);return arguments.callee.base.apply(this,arguments)},touchStart:function(a){return this.mouseDown(a)},touchEnd:function(a){return this.mouseUp(a)},mouseWheel:function(a){if(this.get("isTextArea")){a.allowDefault();return true}else{return false}},selectStart:function(a){return true},_inputElementTagName:function(){if(this.get("isTextArea")){return"textarea"}else{return"input"}},_valueObserver:function(){var b=this.get("value"),a;if(b&&b.length>0){a=this.get("maxLength");if(!SC.platform.input.maxlength&&b.length>a){this.set("value",b.substr(0,a))}}}.observes("value")});sc_require("views/text_field");sc_require("system/utils/misc");sc_require("delegates/inline_text_field");sc_require("mixins/inline_editor");SC.InlineTextFieldView=SC.TextFieldView.extend(SC.InlineEditor,{classNames:["inline-editor"],_topOffsetForFirefoxCursorFix:0,layout:{height:0,width:0},useAbsoluteLayout:YES,_updateViewStyle:function(b){var c="",a=SC.getStyle(b,"font-size");if(a&&a.length>0){c=c+"font-size: "+a+" !important; "}a=SC.getStyle(b,"font-family");if(a&&a.length>0){c=c+"font-family: "+a+" !important; "}a=SC.getStyle(b,"font-weight");if(a&&a.length>0){c=c+"font-weight: "+a+" !important; "}a=SC.getStyle(b,"z-index");if(a&&a.length>0){c=c+"z-index: "+a+" !important; "}a=SC.getStyle(b,"line-height");if(a&&a.length>0){c=c+"line-height: "+a+" !important; "}a=SC.getStyle(b,"text-align");if(a&&a.length>0){c=c+"text-align: "+a+" !important; "}a=SC.getStyle(b,"top-margin");if(a&&a.length>0){c=c+"top-margin: "+a+" !important; "}a=SC.getStyle(b,"bottom-margin");if(a&&a.length>0){c=c+"bottom-margin: "+a+" !important; "}a=SC.getStyle(b,"left-margin");if(a&&a.length>0){c=c+"left-margin: "+a+" !important; "}a=SC.getStyle(b,"right-margin");if(a&&a.length>0){c=c+"right-margin: "+a+" !important; "}return c},_updateViewPaddingStyle:function(b){var c="",a=SC.getStyle(b,"padding-top");if(a&&a.length>0){c=c+"top: "+a+" !important; "}a=SC.getStyle(b,"padding-bottom");if(a&&a.length>0){c=c+"bottom: "+a+" !important; "}a=SC.getStyle(b,"padding-left");if(a&&a.length>0){c=c+"left: "+a+" !important; "}a=SC.getStyle(b,"padding-right");if(a&&a.length>0){c=c+"right: "+a+" !important; "}return c},updateStyle:function(d){if(d.length){d=d[0]}var a=document.getElementById("sc-inline-text-field-style"),c=this._updateViewStyle(d),e=this._updateViewPaddingStyle(d),f=".inline-editor input{"+c+"}.inline-editor textarea{"+c+"}.inline-editor .padding{"+e+"}";if(!a){var b=document.getElementsByTagName("head")[0];a=document.createElement("style");a.type="text/css";a.media="screen";a.id="sc-inline-text-field-style";b.appendChild(a)}if(a.styleSheet){a.styleSheet.cssText=f}else{a.innerHTML=f}},positionOverTargetView:function(g,f,e,a,b){var d=g.get("layout"),c={};if(!SC.none(a)){f=a;e=b}if(f&&e){var h=SC.offset(e,"parent");c.top=d.top+h.y-f.height/2;c.left=d.left+h.x;c.height=f.height;c.width=f.width}else{c=SC.copy(d)}this.set("layout",c)},multiline:NO,isTextArea:function(){return this.get("multiline")}.property("multiline").cacheable(),beginEditing:function(b,a){if(!b(a)){return NO}var d=a.get("pane"),c=this.get("exampleElement");this.beginPropertyChanges();if(a.multiline){this.set("multiline",a.multiline)}if(c){if(c.length){c=c[0]}}else{c=a.$()[0]}this.updateStyle(c);this.positionOverTargetView(a,this.get("exampleFrame"),c);this._previousFirstResponder=d?d.get("firstResponder"):null;this.becomeFirstResponder();this.endPropertyChanges();return YES}.enhance(),blurEditor:function(a){if(this.get("isEditing")){return this.commitOnBlur?this.commitEditing():this.discardEditing()}else{return true}},_endEditing:function(b){var a=b();if(this.get("isFirstResponder")){var c=this.get("pane");if(c&&this._previousFirstResponder){c.makeFirstResponder(this._previousFirstResponder)}else{this.resignFirstResponder()}}this._previousFirstResponder=null;return a}.enhance(),mouseDown:function(a){arguments.callee.base.call(this,a);return this.get("isEditing")},touchStart:function(a){this.mouseDown(a)},_scitf_blurInput:function(){var a=this.$input()[0];if(a){a.blur()}a=null},willRemoveFromParent:function(){return this._scitf_blurInput()},willLoseFirstResponder:function(b,a){if(b!==this){return}this._previousFirstResponder=null;this._origEvent=a;this._scitf_blurInput();return this.blurEditor(a)},cancel:function(){this.discardEditing();return YES},insertNewline:function(a){if(this.get("isTextArea")){return arguments.callee.base.apply(this,arguments)}else{this.commitEditing();return YES}},insertTab:function(a){var c=this.target;this.resignFirstResponder();if(c){var b=c.get("nextValidKeyView");if(b&&b.beginEditing){b.beginEditing()}}return YES},insertBacktab:function(a){var c=this.target;this.resignFirstResponder();if(c){var b=c.get("previousValidKeyView");if(b&&b.beginEditing){b.beginEditing()}}return YES}});sc_require("mixins/inline_editable");sc_require("mixins/inline_editor_delegate");sc_require("delegates/inline_text_field");SC.LabelView=SC.View.extend(SC.Control,SC.InlineEditable,{classNames:["sc-label-view"],displayProperties:["displayTitle","displayHint","displayToolTip","icon"],inlineEditorDelegate:SC.InlineTextFieldDelegate,isEditable:NO,exampleEditor:SC.InlineTextFieldView,escapeHTML:true,localize:NO,localizeBindingDefault:SC.Binding.oneWay().bool(),needsEllipsis:false,formatter:null,value:"",hint:null,hintEnabled:function(){return this.get("isEditable")}.property("isEditable").cacheable(),icon:null,textAlign:null,supportsAutoResize:YES,autoResizeLayer:function(){return this.get("layer")}.property("layer").cacheable(),autoResizeText:function(){return this.get("displayTitle")}.property("displayTitle").cacheable(),autoResizePadding:SC.propertyFromRenderDelegate("autoResizePadding",{height:0,width:10}),renderDelegateName:"labelRenderDelegate",displayTitle:function(){var g,e;g=this.get("value");e=this.getDelegateProperty("formatter",this.displayDelegate);if(e){var f=(SC.typeOf(e)===SC.T_FUNCTION)?e(g,this):e.fieldValueForObject(g,this);if(!SC.none(f)){g=f}}if(SC.typeOf(g)===SC.T_ARRAY){var d=[];for(var b=0,c=g.get("length");b<c;b++){var a=g.objectAt(b);if(!SC.none(a)&&a.toString){a=a.toString()}d.push(a)}g=d.join(",")}if(!SC.none(g)&&g.toString){g=g.toString()}if(g&&this.getDelegateProperty("localize",this.displayDelegate)){g=SC.String.loc(g)}return g}.property("value","localize","formatter").cacheable(),displayHint:function(){var b=this.get("hint"),a=this.get("isEditable");if(a){if(b&&this.getDelegateProperty("localize",this.displayDelegate)){b=SC.String.loc(b)}}else{b=null}return b}.property("hint","localize","isEditable").cacheable(),hintValue:function(){var a=this.get("hint");return a}.property("hint").cacheable(),mouseDown:function(a){return this.get("isEditable")&&a.clickCount===2},doubleClick:function(a){return this.beginEditing()},inlineEditorDidBeginEditing:function(b,c,d,a){this._oldOpacity=this.get("layout").opacity||1;this.adjust("opacity",0);b(c,d,a)}.enhance(),inlineEditorDidEndEditing:function(){this.adjust("opacity",this._oldOpacity);this._oldOpacity=null}});SC.allowsBackspaceToPreviousPage=NO;SC.HORIZONTAL_ORIENTATION="horizontal";SC.VERTICAL_ORIENTATION="vertical";SC.CollectionGroup={classNames:["sc-collection-group"]};SC.CollectionRowDelegate={isCollectionRowDelegate:true,itemHeight:null,rowSize:function(b,c){var d=this.get("itemHeight"),a=24;if(!SC.none(d)){return d}if(!SC.none(c)){a=c}return a}.property("itemHeight").cacheable(),rowSpacing:0,rowPadding:0,rowHeight:function(c,d){var a=this.get("rowPadding"),b=this.get("rowSize");if(d!==undefined){this.set("rowSize",d-a*2);return d}return b+a*2}.property("rowSize","rowPadding"),_sc_totalRowSize:function(){return this.get("rowHeight")}.property("rowHeight"),customRowHeightIndexes:null,customRowSizeIndexes:function(c,d){var a=this.get("customRowHeightIndexes"),b=null;if(!SC.none(a)){return a}if(!SC.none(d)){b=d}return b}.property("customRowHeightIndexes").cacheable(),contentIndexRowHeight:function(a,b,c){return this.get("_sc_totalRowSize")},contentIndexRowSize:function(a,b,c){return this.contentIndexRowHeight(a,b,c)}};SC.CollectionViewDelegate={isCollectionViewDelegate:YES,collectionViewSelectionForProposedSelection:function(a,b){return b},collectionViewShouldSelectIndexes:function(a,b,c){return b},collectionViewShouldDeselectIndexes:function(a,b){return b},collectionViewShouldDeleteIndexes:function(a,b){return b},collectionViewDeleteContent:function(a,c,b){if(!c){return NO}if(SC.typeOf(c.destroyAt)===SC.T_FUNCTION){c.destroyAt(b);a.selectPreviousItem(NO,1);return YES}else{if(SC.typeOf(c.removeAt)===SC.T_FUNCTION){c.removeAt(b);a.selectPreviousItem(NO,1);return YES}else{return NO}}},collectionViewShouldBeginDrag:function(a){return YES},collectionViewDragDataTypes:function(a){return[]},collectionViewDragDataForType:function(a,c,b){return null},collectionViewComputeDragOperations:function(a,b,c){return c},collectionViewValidateDragOperation:function(b,d,e,c,a){return(a&SC.DROP_ON)?SC.DRAG_NONE:e},collectionViewPerformDragOperation:function(b,d,e,c,a){return SC.DRAG_NONE},collectionViewDragViewFor:function(a,b){return null},ghostActsLikeCursor:NO};SC.NavigationBuilder={isNavigationBuilder:YES,navigationTransitions:NO,initMixin:function(){var b=SC.Animatable;if(b&&!this.isAnimatable){this.mixin(b)}else{if(!b){SC.Logger.error("SC.NavigationView and SC.NavigationBuilder require SC.Animatable to perform animations, but it is not present. Please ensure your app or framework references it.")}}var a=this.get("navigationTransitions");if(!a&&SC.Animatable){a={left:{duration:0.25,timing:SC.Animatable.TRANSITION_EASE_IN_OUT,action:"navigationBuildDidFinish"},transform:{duration:0.25,timing:SC.Animatable.TRANSITION_EASE_IN_OUT,action:"navigationBuildDidFinish"}}}if(SC.Animatable){SC.mixin(this.transitions,a)}},metrics:function(){var a=this.computeFrameWithParentFrame();return a},transform:function(a){if(SC.platform.supportsCSS3DTransforms){this.adjust("transform","translate3d("+a+"px,0px,0px)")}else{this.adjust("transform","translate("+a+"px,0px)")}},buildInNavigation:function(){var a=this.metrics();this.disableAnimation();this.transform(this.get("buildDirection")===SC.TO_LEFT?a.width:-a.width);this.enableAnimation();this.invokeLater("transform",10,0)},buildOutNavigation:function(){var a=this.metrics();this.transform(this.get("buildDirection")===SC.TO_LEFT?-a.width:a.width)},buildIn:function(){this.buildInNavigation()},buildOut:function(){this.buildOutNavigation()},resetBuild:function(){this.transform(0)},navigationBuildDidFinish:function(){if(this.isBuildingIn){this.buildInDidFinish()}else{if(this.isBuildingOut){this.buildOutDidFinish()}}}};SC.NeedsSplitParent={splitView:function(){var a=this.get("parentView");while(a&&!a.isSplitView){a=a.get("parentView")}return a}.property("parentView").cacheable(),splitViewLayoutDirection:null,splitViewLayoutDirectionBinding:SC.Binding.oneWay("*splitView.layoutDirection")};SC.SplitChild={isSplitDivider:NO,minimumSize:100,maximumSize:undefined,size:undefined,position:0,positionOffset:SC.propertyFromRenderDelegate("splitPositionOffset",0),sizeOffset:SC.propertyFromRenderDelegate("splitSizeOffset",0),canCollapse:NO,collapseAtSize:undefined,autoResizeStyle:undefined,compensatesForMovement:YES,allowsIndirectAdjustments:YES,initMixin:function(){if(!this.splitView){this.mixin(SC.NeedsSplitParent)}},_scsvc_positionOrSizeDidChange:function(){this.invokeOnce("splitChildLayoutDidChange")}.observes("position","size"),splitChildLayoutDidChange:function(){var c=this.get("splitView");if(!c){return}var a=this.get("position")+this.get("positionOffset"),b=this.get("size")+this.get("sizeOffset");if(c.get("layoutDirection")===SC.LAYOUT_HORIZONTAL){this.set("layout",{left:a,width:b,top:0,bottom:0})}else{this.set("layout",{top:a,height:b,right:0,left:0})}},splitViewLayoutDirectionDidChange:function(){this.invokeOnce("splitChildLayoutDidChange")}.observes("splitViewLayoutDirection")};SC.MOVES_AUTOMATIC_CHILD="moves-automatic-child";SC.MOVES_CHILD="moves-child";SC.MOVES_PREVIOUS_CHILD="moves-previous-child";SC.MOVES_NEXT_CHILD="moves-next-child";SC.SplitThumb={movesChild:function(){var a=this,d,c=this.get("splitView"),b=this.get("movesSibling");while(a&&a!==c){d=a;a=a.get("parentView")}if(b===SC.MOVES_NEXT_CHILD){return d.nextView}if(b===SC.MOVES_PREVIOUS_CHILD){return d.previousView}if(b===SC.MOVES_AUTOMATIC_CHILD){if(!d.nextView){return d.previousView}if(!d.previousView){return d.nextView}}return d}.property("splitView","movesSibling").cacheable(),movesSibling:SC.MOVES_AUTOMATIC_CHILD,splitCursorStyle:function(){if(this.get("splitViewLayoutDirection")===SC.LAYOUT_HORIZONTAL){return"ew-resize"}else{return"ns-resize"}}.property("splitViewLayoutDirection").cacheable(),splitCursorStyleDidChange:function(){if(this._isDragging){this.get("splitView").set("splitChildCursorStyle",this.get("splitCursorStyle"))}this.$().css("cursor",this.get("splitCursorStyle"))}.observes("splitCursorStyle"),initMixin:function(){if(!this.splitView){this.mixin(SC.NeedsSplitParent)}},renderMixin:function(a){a.setStyle("cursor",this.get("splitCursorStyle"))},touchStart:function(b){this._isDragging=YES;var a=this.get("splitView");a.beginLiveResize();this._scst_mouseStartPosition=a.get("layoutDirection")===SC.LAYOUT_HORIZONTAL?b.pageX:b.pageY;this._scst_childStartPosition=a.getPositionForChild(this.get("movesChild"));return YES},touchesDragged:function(a){var b=this.get("splitView");var e=b.get("layoutDirection")===SC.LAYOUT_HORIZONTAL?a.pageX:a.pageY;var c=e-this._scst_mouseStartPosition,d=this._scst_childStartPosition;b.adjustPositionForChild(this.get("movesChild"),d+c);return YES},touchEnd:function(e){this._isDragging=NO;var a=this.get("splitView");var d=a.get("layoutDirection")===SC.LAYOUT_HORIZONTAL?e.pageX:e.pageY;var b=d-this._scst_mouseStartPosition,c=this._scst_childStartPosition;a.adjustPositionForChild(this.get("movesChild"),c+b);a.set("splitChildCursorStyle",null);a.endLiveResize();return YES},mouseDown:function(a){var b=this.get("splitView");b.set("splitChildCursorStyle",this.get("splitCursorStyle"));return this.touchStart(a)},mouseDragged:function(a){return this.touchesDragged(a)},mouseUp:function(a){this.get("splitView").set("splitChildCursorStyle",null);return this.touchEnd(a)}};SC.ModalPane=SC.Pane.extend({classNames:"sc-modal",_openPaneCount:0,paneWillAppend:function(e){var d;this._openPaneCount++;if(!this.get("isVisibleInWindow")){this.append()}var c=SC.RootResponder.responder.panes;for(var b=0,a=c.length;b<a;b++){d=c[b];if(d!==e){this._hideShowTextfields(d,NO)}}return this},paneDidRemove:function(e){var d;this._openPaneCount--;var c=SC.RootResponder.responder.panes;for(var b=0,a=c.length;b<a;b++){d=c[b];if(d!==e){this._hideShowTextfields(d,YES)}}if(this._openPaneCount<=0){this._openPaneCount=0;if(this.get("isVisibleInWindow")){this.remove()}}},_hideShowTextfields:function(c,b){var a;for(a in SC.View.views){a=SC.View.views[a];if(a.get("isTextField")&&a!==c&&a.get("pane")===c){if(b){if(a._scmp_isBrowserFocusable!==undefined){b=a._scmp_isBrowserFocusable;delete a._scmp_isBrowserFocusable}}else{a._scmp_isBrowserFocusable=a.get("isBrowserFocusable")}a.set("isBrowserFocusable",b)}}},mouseDown:function(b){var a=this.get("owner");if(a&&a.modalPaneDidClick){a.modalPaneDidClick(b)}},touchStart:function(a){this.mouseDown(a)}});sc_require("panes/modal");SC.PanelPane=SC.Pane.extend({isPanelPane:YES,classNames:["sc-panel"],acceptsKeyPane:YES,ariaRole:"dialog",ariaLabel:null,ariaLabelledBy:null,ariaDescribedBy:null,isModal:YES,modalPane:SC.ModalPane.extend({classNames:"for-sc-panel"}),contentView:null,contentViewBindingDefault:SC.Binding.single(),replaceContent:function(a){this.removeAllChildren();if(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"),renderDelegateName:"panelRenderDelegate",_modalPane:function(){var a=this.get("modalPane");if(a&&a.isClass){a=a.create({owner:this});this.set("modalPane",a)}return a},appendTo:function(a){var b;if(!this.get("isVisibleInWindow")&&this.get("isModal")&&(b=this._modalPane())){this._isShowingModal=YES;b.paneWillAppend(this)}return arguments.callee.base.apply(this,arguments)},remove:function(){var b,a=arguments.callee.base.apply(this,arguments);if(this._isShowingModal){this._isShowingModal=NO;if(b=this._modalPane()){b.paneDidRemove(this)}}return a},destroy:function(){var a=this.get("modalPane");if(a&&!a.isClass){a.destroy()}arguments.callee.base.apply(this,arguments)},_isModalDidChange:function(){var a,b=this.get("isModal");if(b){if(!this._isShowingModal&&(a=this._modalPane())){this._isShowingModal=YES;a.paneWillAppend(this)}}else{if(this._isShowingModal&&(a=this._modalPane())){this._isShowingModal=NO;a.paneDidRemove(this)}}}.observes("isModal"),didShowInDocument:function(){this.becomeKeyPane()},didAppendToDocument:function(){this.becomeKeyPane()},willRemoveFromDocument:function(){this.resignKeyPane()},willHideInDocument:function(){this.resignKeyPane()},displayProperties:["ariaLabel","ariaLabelledBy","ariaDescribedBy"]});SC.TOGGLE_BEHAVIOR="toggle";SC.PUSH_BEHAVIOR="push";SC.TOGGLE_ON_BEHAVIOR="on";SC.TOGGLE_OFF_BEHAVIOR="off";SC.HOLD_BEHAVIOR="hold";SC.ButtonView=SC.View.extend(SC.ActionSupport,SC.Control,{acceptsFirstResponder:function(){if(SC.FOCUS_ALL_CONTROLS){return this.get("isEnabledInPane")}return NO}.property("isEnabledInPane"),action:null,classNames:["sc-button-view"],escapeHTML:true,target:null,themeName:"square",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"))?SC.String.loc(a):(a||"")}.property("title","localize").cacheable(),keyEquivalent:null,buttonBehavior:SC.PUSH_BEHAVIOR,holdInterval:100,isDefault:NO,isDefaultBindingDefault:SC.Binding.oneWay().bool(),isCancel:NO,isCancelBindingDefault:SC.Binding.oneWay().bool(),supportFocusRing:NO,supportsAutoResize:YES,autoResizeLayer:function(){var a=this.invokeRenderDelegateMethod("getRenderedAutoResizeLayer",this.$());return a||this.get("layer")}.property("layer").cacheable(),autoResizeText:function(){return this.get("displayTitle")}.property("displayTitle").cacheable(),autoResizePadding:SC.propertyFromRenderDelegate("autoResizePadding",10),_labelMinWidthIE7:0,triggerActionAfterDelay:function(a){if(!this.get("isEnabledInPane")){return NO}this.set("isActive",YES);this.invokeLater("triggerAction",SC.ButtonView.TRIGGER_DELAY,a);return YES},triggerAction:function(a){this._action(a,YES);this.didTriggerAction();this.set("isActive",NO)},didTriggerAction:function(){},init:function(){arguments.callee.base.apply(this,arguments);var a=this.get("keyEquivalent");if(a){this._defaultKeyEquivalent=a}if(!SC.none(this.get("value"))){this._button_valueDidChange()}},ariaRole:"button",displayProperties:["icon","displayTitle","displayToolTip","supportFocusRing","buttonBehavior"],renderDelegateName:"buttonRenderDelegate",contentKeys:{contentValueKey:"value",contentTitleKey:"title",contentIconKey:"icon"},performKeyEquivalent:function(c,b){if(!this.get("isVisibleInWindow")){return NO}if(!this.get("isEnabledInPane")){return NO}var a=this.get("keyEquivalent");if(a){if(a===c){return this.triggerAction(b)}}else{if((this.get("isDefault")&&(c==="return"))||(this.get("isCancel")&&(c==="escape"))){return this.triggerAction(b)}}return NO},computeIsSelectedForValue:function(d){var b=this.get("toggleOnValue"),c,a;if(SC.typeOf(d)===SC.T_ARRAY){if(d.length===1){c=(d[0]==b)}else{c=null;d.find(function(e){a=(e==b);if(c===null){c=a}else{if(a!==c){c=SC.MIXED_STATE}}return c===SC.MIXED_STATE})}}else{if(d===SC.MIXED_STATE){c=SC.MIXED_STATE}else{c=(d===b)}}return c},_button_valueDidChange:function(){var b=this.get("value"),a=this.computeIsSelectedForValue(b);this.set("isSelected",a);this.displayDidChange()}.observes("value"),_button_isSelectedDidChange:function(){var c=this.get("isSelected"),b=this.computeIsSelectedForValue(this.get("value"));if((c!==SC.MIXED_STATE)&&(b!==c)){var a=(c)?"toggleOnValue":"toggleOffValue";this.set("value",this.get(a))}}.observes("isSelected"),_defaultKeyEquivalent:null,_isDefaultOrCancelDidChange:function(){var b=!!this.get("isDefault"),a=!b&&this.get("isCancel");if(b){this.set("keyEquivalent","return")}else{if(a){this.set("keyEquivalent","escape")}else{this.set("keyEquivalent",this._defaultKeyEquivalent)}}this.displayDidChange()}.observes("isDefault","isCancel"),mouseDown:function(a){if(a.which!==1){return false}var b=this.get("buttonBehavior");if(!this.get("isEnabledInPane")){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()}}return YES},mouseExited:function(a){if(this._isMouseDown){this.set("isActive",NO)}return YES},mouseEntered:function(a){if(this._isMouseDown){this.set("isActive",YES)}return YES},mouseUp:function(b){if(this._isMouseDown){this.set("isActive",NO)}this._isMouseDown=false;if(this.get("buttonBehavior")!==SC.HOLD_BEHAVIOR){var a=this.$().within(b.target);if(a&&this.get("isEnabledInPane")){this._action(b)}}return YES},touchStart:function(b){var a=this.get("buttonBehavior");if(!this.get("isEnabledInPane")){return YES}this.set("isActive",YES);if(a===SC.HOLD_BEHAVIOR){this._action(b)}else{if(!this._isFocused&&(a!==SC.PUSH_BEHAVIOR)){this._isFocused=YES;this.becomeFirstResponder()}}b.preventDefault();return YES},touchesDragged:function(a,b){if(!this.touchIsInBoundary(a)){if(!this._touch_exited){this.set("isActive",NO)}this._touch_exited=YES}else{if(this._touch_exited){this.set("isActive",YES)}this._touch_exited=NO}a.preventDefault();return YES},touchEnd:function(a){this._touch_exited=NO;this.set("isActive",NO);if(this.get("buttonBehavior")!==SC.HOLD_BEHAVIOR){if(this.touchIsInBoundary(a)&&this.get("isEnabledInPane")){this._action()}}a.preventDefault();return YES},keyDown:function(b){if(!this.get("isEnabledInPane")){return YES}if(b.which===9||b.keyCode===9){var a=b.shiftKey?this.get("previousValidKeyView"):this.get("nextValidKeyView");if(a){a.becomeFirstResponder()}else{b.allowDefault()}return YES}if(b.which===13||b.which===32){this.triggerActionAfterDelay(b);return YES}b.allowDefault();return NO},_action:function(a,c){switch(this.get("buttonBehavior")){case SC.TOGGLE_BEHAVIOR:var b=this.get("isSelected");if(b){this.set("value",this.get("toggleOffValue"))}else{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,c);break;default:this._runAction(a)}},_runAction:function(a){var b=this.get("action");if(b){if(b&&(SC.typeOf(b)===SC.T_FUNCTION)){this.action(a)}else{this.fireAction()}}},_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()}}},didBecomeKeyResponderFrom:function(a){if(!this._isFocused){this._isFocused=YES;this.becomeFirstResponder();if(this.get("isVisibleInWindow")){this.$().focus()}}},willLoseKeyResponderTo:function(a){if(this._isFocused){this._isFocused=NO}},didAppendToDocument:function(){if(SC.browser.isIE&&SC.browser.compare(SC.browser.version,"7")===0&&this.get("useStaticLayout")){var e=this.get("layout"),d=this.$(),a=0;if(d&&d[0]&&(a=d[0].clientWidth)&&a!==0&&this._labelMinWidthIE7===0){var c=this.$(".sc-button-label"),h=parseInt(c.css("paddingRight"),0),b=parseInt(c.css("paddingLeft"),0),g=parseInt(c.css("marginRight"),0),f=parseInt(c.css("marginLeft"),0);if(g=="auto"){SC.Logger.log(g+","+f+","+h+","+b)}if(!h&&isNaN(h)){h=0}if(!b&&isNaN(b)){b=0}if(!g&&isNaN(g)){g=0}if(!f&&isNaN(f)){f=0}this._labelMinWidthIE7=a-(h+b)-(g+f);c.css("minWidth",this._labelMinWidthIE7+"px")}else{this.invokeLater(this.didAppendToDocument,1)}}}});SC.ButtonView.TRIGGER_DELAY=200;SC.ButtonView.CLICK_AND_HOLD_DELAY=SC.browser.isIE?600:300;SC.REGULAR_BUTTON_HEIGHT=24;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"],ariaRole:"alertdialog",delegate:null,icon:"sc-icon-alert-48",message:"",ariaLabel:function(){return this.get("message")}.property("message").cacheable(),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(),button1:SC.outlet("contentView.childViews.1.childViews.1"),button2:SC.outlet("contentView.childViews.1.childViews.0"),button3:SC.outlet("contentView.childViews.2.childViews.0"),buttonThreeWrapper:SC.outlet("contentView.childViews.2"),layout:{top:0.3,centerX:0,width:500},contentView:SC.View.extend({useStaticLayout:YES,layout:{left:0,right:0,top:0,height:"auto"},childViews:[SC.View.extend({classNames:["info"],useStaticLayout:YES,render:function(a,c){var b=this.get("pane");if(b.get("icon")=="blank"){a.addClass("plain")}a.push('<img src="'+SC.BLANK_IMAGE_URL+'" class="icon '+b.get("icon")+'" />');a.begin("h1").addClass("header").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,layout:{right:5,height:"auto",width:"auto",bottom:0},isCancel:YES,action:"dismiss",isVisible:NO}),okButton:SC.ButtonView.extend({useStaticLayout:YES,actionKey:SC.BUTTON1_STATUS,localize:YES,layout:{left:0,height:"auto",width:"auto",bottom:0},isDefault:YES,action:"dismiss",isVisible:NO})}),SC.View.extend({layout:{bottom:13,height:24,left:18,width:150},childViews:[SC.ButtonView.extend({useStaticLayout:YES,actionKey:SC.BUTTON3_STATUS,localize:YES,layout:{left:0,height:"auto",width:"auto",bottom:0},action:"dismiss",isVisible:NO})]})]}),dismiss:function(b){var a=this.delegate,c,d,e;if(a&&a.alertPaneDidDismiss){a.alertPaneDidDismiss(this,b.get("actionKey"))}if(d=(b&&b.get("customAction"))){if(SC.typeOf(d)===SC.T_FUNCTION){d.call(d)}else{c=this.getPath("pane.rootResponder");if(c){e=b.get("customTarget");c.sendAction(d,e||a,this,this,null,this)}}}this.remove()},alertInfoDidChange:function(){var a=this.getPath("contentView.childViews.0");if(a){a.displayDidChange()}}.observes("icon","message","displayDescription","displayCaption")});SC.AlertPane.mixin({show:function(l){l=SC.AlertPane._argumentsCall.apply(this,arguments);var b=this.create(l),p,m=l.buttons,f,k,e,n,a,d,j,h,c,i,g,q;if(m){g=!!m.findProperty("isDefault");q=!!m.findProperty("isCancel");for(p=0;p<3;p++){f=m[p];if(!f){continue}k=b.get("button%@".fmt(p+1));e=f.layerId;n=f.title;localize=f.localize;a=f.toolTip;d=f.action;j=f.target;h=l.themeName||"capsule";c=g?!!f.isDefault:undefined;i=q?!!f.isCancel:undefined;k.set("title",n);if(localize===YES){k.set("localize",YES)}if(a){k.set("toolTip",a)}if(d){k.set("customAction",d)}if(j){k.set("customTarget",j)}if(e!==undefined){k.set("layerId",e)}if(c!==undefined){k.set("isDefault",c)}if(i!==undefined){k.set("isCancel",i)}k.set("isVisible",!!n);k.set("themeName",h)}}else{k=b.get("button1");k.set("title","OK");k.set("isVisible",YES)}var o=b.append();b.adjust("height",b.childViews[0].$().height());b.updateLayout();return o},warn:function(a){a=SC.AlertPane._argumentsCall.apply(this,arguments);a.icon="sc-icon-alert-48";return this.show(a)},info:function(a){a=SC.AlertPane._argumentsCall.apply(this,arguments);a.icon="sc-icon-info-48";return this.show(a)},error:function(a){a=SC.AlertPane._argumentsCall.apply(this,arguments);a.icon="sc-icon-error-48";return this.show(a)},plain:function(a){a=SC.AlertPane._argumentsCall.apply(this,arguments);a.icon="blank";return this.show(a)},_argumentsCall:function(b){var a=b;if(SC.typeOf(b)!==SC.T_HASH){var c=this._normalizeArguments(arguments);a={message:c[0],description:c[1],caption:c[2],delegate:c[7],icon:(c[6]||"sc-icon-alert-48"),themeName:"capsule"};if(SC.typeOf(c[3])===SC.T_STRING||SC.typeOf(c[4])===SC.T_STRING||SC.typeOf(c[5])===SC.T_STRING){a.buttons=[{title:c[3]},{title:c[4]},{title:c[5]}]}}return a},_normalizeArguments:function(b){b=SC.A(b);var a=b.length,c=b[a-1];if(SC.typeOf(c)!==SC.T_STRING){b[a-1]=null}else{c=null}b[7]=c;return b}});SC.DraggablePaneSupport={isDraggablePane:YES,isAnchored:NO,_drag_cachedMouseX:null,_drag_cachedMouseY:null,initMixin:function(){if(this.mouseDown){this.mouseDown=SC._enhance(this.mouseDown,function(c,a){var b=this._drag_mouseDown(a);return c(a)||b})}else{this.mouseDown=this._drag_mouseDown}if(this.mouseDragged){this.mouseDragged=SC._enhance(this.mouseDragged,function(c,a){var b=this._drag_mouseDragged(a);return c(a)||b})}else{this.mouseDragged=this._drag_mouseDragged}if(this.touchStart){this.touchStart=SC._enhance(this.touchStart,function(c,a){var b=this._drag_touchStart(a);return c(a)||b})}else{this.touchStart=this._drag_touchStart}if(this.touchesDragged){this.touchesDragged=SC._enhance(this.touchesDragged,function(c,a){var b=this._drag_touchesDragged(a);return c(a)||b})}else{this.touchesDragged=this._drag_touchesDragged}},_drag_targetHasSelectableText:function(a){var b=SC.RootResponder.responder.targetViewForEvent(a);return !!(b&&b.isTextSelectable)},_drag_shouldHandleDrag:function(a){return !this.get("isAnchored")&&!this._drag_targetHasSelectableText(a)},_drag_mouseDown:function(a){this._drag_cachedMouseX=a.pageX;this._drag_cachedMouseY=a.pageY;return this._drag_shouldHandleDrag(a)},_drag_mouseDragged:function(a){var c=this._drag_cachedMouseX-a.pageX,g=this._drag_cachedMouseY-a.pageY,f=this.get("frame"),e=SC.RootResponder.responder.computeWindowSize(),b=SC.clone(this.get("layout")),d={},h=function(i){return(i<1&&i>0)};this._drag_cachedMouseX=a.pageX;this._drag_cachedMouseY=a.pageY;if(!this._drag_shouldHandleDrag(a)){return NO}if(b.hasOwnProperty("left")){if(h(b.left)){b.left=f.x}d.left=b.left-c}if(b.hasOwnProperty("right")){if(h(b.right)){b.right=e.width-(f.x+f.width)}d.right=b.right+c}if(b.hasOwnProperty("centerX")){d.centerX=b.centerX-c}if(b.hasOwnProperty("top")){if(h(b.top)){b.top=f.y}d.top=b.top-g}if(b.hasOwnProperty("bottom")){if(h(b.bottom)){b.bottom=e.height-(f.y+f.height)}d.bottom=b.bottom+g}if(b.hasOwnProperty("centerY")){d.centerY=b.centerY-g}this.adjust(d);return YES},_drag_touchStart:function(a){return this._drag_mouseDown(a)},_drag_touchesDragged:function(a){return this._drag_mouseDragged(a)}};sc_require("panes/panel");SC.PalettePane=SC.PanelPane.extend(SC.DraggablePaneSupport,{classNames:["sc-palette"],isModal:NO,modalPane:SC.ModalPane});sc_require("panes/palette");SC.PICKER_MENU="menu";SC.PICKER_FIXED="fixed";SC.PICKER_POINTER="pointer";SC.PICKER_MENU_POINTER="menu-pointer";SC.PickerPane=SC.PalettePane.extend({classNames:["sc-picker"],isAnchored:YES,isModal:YES,_sc_pointerLayout:SC.POINTER_LAYOUT||["perfectRight","perfectLeft","perfectTop","perfectBottom"],pointerPos:"perfectRight",pointerPosX:0,pointerPosY:0,anchorElement:function(a,b){if(b===undefined){if(this._anchorView){return this._anchorView.get("layer")}else{return this._anchorHTMLElement}}else{if(b&&b.isCoreQuery){b=b[0]}if(!b){SC.throw("You must set 'anchorElement' to either a view or a DOM element")}this._removeScrollObservers();if(b.isView){this._setupScrollObservers(b);this._anchorView=b;this._anchorHTMLElement=null;return b.get("layer")}else{this._anchorView=null;this._anchorHTMLElement=b;return b}}}.property().cacheable(),anchorCached:null,preferType:null,preferMatrix:null,pointerOffset:null,extraRightOffset:function(){return this.get("windowPadding")}.property("windowPadding").cacheable(),removeTarget:null,removeAction:null,repositionOnWindowResize:YES,windowPadding:null,viewDidResize:function(){arguments.callee.base.apply(this,arguments);this.positionPane(true)},popup:function(c,b,d,a){this.beginPropertyChanges();this.setIfChanged("anchorElement",c);if(b){this.set("preferType",b)}if(d){this.set("preferMatrix",d)}if(a){this.set("pointerOffset",a)}this.endPropertyChanges();this.positionPane();this._hideOverflow();return this.append()},positionPane:function(a){var c=this.get("borderFrame"),i=this.get("preferType"),h=this.get("preferMatrix"),k,f,g,b,j;b=this.get("anchorCached");j=this.get("anchorElement");if(a&&b){g=b}else{if(j){g=this.computeAnchorRect(j);this.set("anchorCached",g)}}if(g){k=SC.cloneRect(g);switch(i){case SC.PICKER_MENU:case SC.PICKER_FIXED:if(!h||h.length!==3){this.set("preferMatrix",[1,4,3]);h=this.get("preferMatrix")}k.x+=((h[2]===0)?k.width:0)+h[0];k.y+=((h[2]===3)?k.height:0)+h[1];break;default:k.y+=k.height;break}g.halfWidth=parseInt(g.width*0.5,0);g.halfHeight=parseInt(g.height*0.5,0);c=SC.cloneRect(c);c.halfWidth=parseInt(c.width*0.5,0);c.halfHeight=parseInt(c.height*0.5,0);c=this.fitPositionToScreen(k,c,g);f={left:c.x,top:c.y};if(c.width!=null){f.width=c.width}if(c.height!=null){f.height=c.height}var l=this.get("transitionIn");if(l&&(l.layoutProperties.indexOf("scale")>=0||l.layoutProperties.indexOf("rotate")>=0)){var e,d;switch(i){case SC.PICKER_POINTER:case SC.PICKER_MENU_POINTER:switch(this.get("pointerPos")){case"perfectTop":e=(c.halfWidth+this.get("pointerPosX"))/c.width;d=1;break;case"perfectRight":e=0;d=(c.halfHeight+this.get("pointerPosY"))/c.height;break;case"perfectBottom":e=(c.halfWidth+this.get("pointerPosX"))/c.width;d=0;break;case"perfectLeft":e=1;d=(c.halfHeight+this.get("pointerPosY"))/c.height;break}break;case SC.PICKER_MENU:case SC.PICKER_FIXED:if(c.x>=g.x){e=0}else{e=1}if(c.y>=g.y){d=0}else{d=1}break}f.transformOriginX=e;f.transformOriginY=d}this.adjust(f)}else{this.adjust({centerX:0,centerY:0})}return this},computeAnchorRect:function(c){var e,b,d,a=SC.RootResponder.responder.computeWindowSize();if(c.getBoundingClientRect){e=c.getBoundingClientRect();b={x:e.left,y:e.top,width:e.width,height:e.height};if(b.width===undefined||b.height===undefined){d=SC.$(c);b.width=d.outerWidth();b.height=d.outerHeight()}}else{b=SC.offset(c);d=SC.$(c);b.width=d.outerWidth();b.height=d.outerHeight()}b.height=(a.height-b.y)<b.height?(a.height-b.y):b.height;if(!SC.browser.isIE&&window.scrollX>0||window.scrollY>0){b.x+=window.scrollX;b.y+=window.scrollY}else{if(SC.browser.isIE&&(document.documentElement.scrollTop>0||document.documentElement.scrollLeft>0)){b.x+=document.documentElement.scrollLeft;b.y+=document.documentElement.scrollTop}}return b},fitPositionToScreen:function(f,c,d){var h=SC.RootResponder.responder.computeWindowSize(),e={x:0,y:0,width:h.width,height:h.height};var b=SC.RootResponder.responder.mainPane;if(b){var a=b.layout.minWidth,i=b.layout.minHeight;if(a&&e.width<a){e.width=b.layout.minWidth}if(i&&e.height<i){e.height=b.layout.minHeight}}c.x=f.x;c.y=f.y;var g=this.get("preferType");if(g){switch(g){case SC.PICKER_MENU:c=this.fitPositionToScreenMenu(e,c,this.get("isSubMenu"));break;case SC.PICKER_MENU_POINTER:this.setupPointer(d);c=this.fitPositionToScreenMenuPointer(e,c,d);break;case SC.PICKER_POINTER:this.setupPointer(d);c=this.fitPositionToScreenPointer(e,c,d);break;case SC.PICKER_FIXED:break;default:break}}else{c=this.fitPositionToScreenDefault(e,c,d)}return c},fitPositionToScreenDefault:function(b,d,a){var c;if(SC.maxX(d)>b.width){c=Math.max(SC.maxX(a),d.width);d.x=Math.min(c,b.width)-d.width}if(SC.minX(d)<0){d.x=SC.minX(Math.max(a,0));if(SC.maxX(d)>b.width){d.x=Math.max(0,b.width-d.width)}}if(SC.maxY(d)>b.height){c=Math.max((a.y-d.height),0);if(c>b.height){d.y=Math.max(0,b.height-d.height)}else{d.y=c}}if(SC.minY(d)<0){c=Math.min(SC.maxY(a),(b.height-a.height));d.y=Math.max(c,0)}return d},fitPositionToScreenMenu:function(c,d,a){var b=this.get("windowPadding");if(a){d.x-=this.get("submenuOffsetX");d.y-=Math.floor(this.get("menuHeightPadding")/2)}if(d.x<b){d.x=b}if((d.x+d.width+b)>c.width){if(a){d.x=d.x-(d.width*2)}else{d.x=c.width-d.width-b}}if(d.y<b){d.y=b}if(d.y+d.height+b>c.height){d.y=Math.max(b,c.height-d.height-b)}if(d.y+d.height+b>c.height){d.height=c.height-(2*b)}return d},fitPositionToScreenMenuPointer:function(b,c,a){c=this.fitPositionToScreenPointer(b,c,a);if(c.height+c.y+35>=b.height){c.height=b.height-c.y-(SC.MenuPane.VERTICAL_OFFSET*2)}return c},fitPositionToScreenPointer:function(d,b,c){var l,e,m=this.get("preferMatrix"),f=this.get("pointerOffset"),j,k,a=this.get("windowPadding");j=[[c.x+c.width+f[0],c.y+c.halfHeight-b.halfHeight],[c.x-b.width+f[1],c.y+c.halfHeight-b.halfHeight],[c.x+c.halfWidth-b.halfWidth,c.y-b.height+f[2]],[c.x+c.halfWidth-b.halfWidth,c.y+c.height+f[3]]];k=[[c.x+c.width+b.width+f[0],c.y+c.halfHeight+b.halfHeight],[c.x+f[1],c.y+c.halfHeight+b.halfHeight],[c.x+c.halfWidth+b.halfWidth,c.y+f[2]],[c.x+c.halfWidth+b.halfWidth,c.y+c.height+b.height+f[3]]];for(var g=0,h=this._sc_pointerLayout.length;g<h;g++){l=m[g];e={top:j[l][1]-a,right:d.width-a-k[l][0],bottom:d.height-a-k[l][1],left:j[l][0]-a};if(e.top>=0&&e.right>=0&&e.bottom>=0&&e.left>=0){b.x=j[l][0];b.y=j[l][1];this.set("pointerPosX",0);this.set("pointerPosY",0);this.set("pointerPos",this._sc_pointerLayout[l]);break}else{if(((l===0&&e.right>=0)||(l===1&&e.left>=0))&&e.top<0&&e.top+b.halfHeight>=0){b.x=j[l][0];b.y=j[l][1]-e.top;this.set("pointerPosX",0);this.set("pointerPosY",e.top);this.set("pointerPos",this._sc_pointerLayout[l]);break}else{if(((l===0&&e.right>=0)||(l===1&&e.left>=0))&&e.bottom<0&&e.bottom+b.halfHeight>=0){b.x=j[l][0];b.y=j[l][1]+e.bottom;this.set("pointerPosX",0);this.set("pointerPosY",Math.abs(e.bottom));this.set("pointerPos",this._sc_pointerLayout[l]);break}else{if(((l===2&&e.top>=0)||(l===3&&e.bottom>=0))&&e.right<0&&e.right+b.halfWidth>=0){b.x=j[l][0]+e.right;b.y=j[l][1];this.set("pointerPosX",Math.abs(e.right));this.set("pointerPosY",0);this.set("pointerPos",this._sc_pointerLayout[l]);break}else{if(((l===2&&e.top>=0)||(l===3&&e.bottom>=0))&&e.left<0&&e.left+b.halfWidth>=0){b.x=j[l][0]-e.left;b.y=j[l][1];this.set("pointerPosX",e.left);this.set("pointerPosY",0);this.set("pointerPos",this._sc_pointerLayout[l]);break}}}}}}if(g===h){if(m[4]===-1){b.x=c.x+c.halfWidth;b.y=c.y+c.halfHeight-b.halfHeight;this.set("pointerPos",this._sc_pointerLayout[0]+" fallback");this.set("pointerPosY",b.halfHeight-40)}else{b.x=j[m[4]][0];b.y=j[m[4]][1];this.set("pointerPos",this._sc_pointerLayout[m[4]]);this.set("pointerPosY",0)}this.set("pointerPosX",0)}this.invokeLast(this._adjustPointerPosition);return b},_adjustPointerPosition:function(){var d=this.$(".sc-pointer"),a=this.get("pointerPos"),c,b;switch(a){case"perfectRight":case"perfectLeft":b=-Math.round(d.outerHeight()/2);b+=this.get("pointerPosY");d.attr("style","margin-top: "+b+"px");break;case"perfectTop":case"perfectBottom":c=-Math.round(d.outerWidth()/2);c+=this.get("pointerPosX");d.attr("style","margin-left: "+c+"px;");break}},setupPointer:function(f){var g=this.get("pointerOffset"),e=SC.PickerPane;if(!g||g.length!==4){if(this.get("preferType")===SC.PICKER_MENU||this.get("preferType")===SC.PICKER_MENU_POINTER){switch(this.get("controlSize")){case SC.TINY_CONTROL_SIZE:this.set("pointerOffset",e.TINY_PICKER_MENU_POINTER_OFFSET);this.set("windowPadding",e.TINY_MENU_WINDOW_PADDING);break;case SC.SMALL_CONTROL_SIZE:this.set("pointerOffset",e.SMALL_PICKER_MENU_POINTER_OFFSET);this.set("windowPadding",e.SMALL_MENU_WINDOW_PADDING);break;case SC.REGULAR_CONTROL_SIZE:this.set("pointerOffset",e.REGULAR_PICKER_MENU_POINTER_OFFSET);this.set("windowPadding",e.REGULAR_MENU_WINDOW_PADDING);break;case SC.LARGE_CONTROL_SIZE:this.set("pointerOffset",e.LARGE_PICKER_MENU_POINTER_OFFSET);this.set("windowPadding",e.LARGE_MENU_WINDOW_PADDING);break;case SC.HUGE_CONTROL_SIZE:this.set("pointerOffset",e.HUGE_PICKER_MENU_POINTER_OFFSET);this.set("windowPadding",e.HUGE_MENU_WINDOW_PADDING);break;default:this.set("pointerOffset",e.REGULAR_PICKER_MENU_POINTER_OFFSET);this.set("windowPadding",e.REGULAR_MENU_WINDOW_PADDING)}}else{var d=(f.width<16)?((f.width<4)?9:6):0,b=(f.height<16)?((f.height<4)?9:6):0,c=e.PICKER_POINTER_OFFSET;var i=[c[0]+d,c[1]-d,c[2]-b,c[3]+b];this.set("pointerOffset",i)}}var h=this.get("preferMatrix");if(!h||h.length!==5){this.set("preferMatrix",this.get("preferType")===SC.PICKER_MENU_POINTER?[3,2,1,0,3]:[0,1,2,3,2])}},displayProperties:["pointerPos"],renderDelegateName:"pickerRenderDelegate",modalPaneDidClick:function(a){var d=this.get("frame"),e=this.get("removeTarget")||null,c=this.get("removeAction"),b=this.get("rootResponder");if(!this.clickInside(d,a)){if(c){b.sendAction(c,e,this,this,null,this)}else{this.remove()}return YES}return NO},mouseDown:function(a){return this.modalPaneDidClick(a)},clickInside:function(b,a){return SC.pointInRect({x:a.pageX,y:a.pageY},b)},windowSizeDidChange:function(b,a){arguments.callee.base.apply(this,arguments);if(this.repositionOnWindowResize){this.invokeNext(this.positionPane)}},remove:function(){if(this.get("isVisibleInWindow")){this._withdrawOverflowRequest()}this._removeScrollObservers();return arguments.callee.base.apply(this,arguments)},_hideOverflow:function(){var a=SC.$(".sc-main"),c=parseInt(a.css("minWidth"),0),d=parseInt(a.css("minHeight"),0),b=SC.RootResponder.responder.get("currentWindowSize");if(b.width>=c&&b.height>=d){SC.bodyOverflowArbitrator.requestHidden(this)}},_withdrawOverflowRequest:function(){SC.bodyOverflowArbitrator.withdrawRequest(this)},_getScrollViewOfView:function(b){var a=b;while(a){if(a.isScrollable){break}a=a.get("parentView")}return a},_setupScrollObservers:function(b){var a=this._getScrollViewOfView(b);if(a){a.addObserver("canScrollHorizontal",this,this._scrollCanScrollHorizontalDidChange);a.addObserver("canScrollVertical",this,this._scrollCanScrollVerticalDidChange);this._scrollCanScrollHorizontalDidChange(a);this._scrollCanScrollVerticalDidChange(a);this._scrollView=a}},_scrollCanScrollHorizontalDidChange:function(a){if(a.get("canScrollHorizontal")){a.addObserver("horizontalScrollOffset",this,this._scrollOffsetDidChange)}else{a.removeObserver("horizontalScrollOffset",this,this._scrollOffsetDidChange)}},_scrollCanScrollVerticalDidChange:function(a){if(a.get("canScrollVertical")){a.addObserver("verticalScrollOffset",this,this._scrollOffsetDidChange)}else{a.removeObserver("verticalScrollOffset",this,this._scrollOffsetDidChange)}},_removeScrollObservers:function(){var a=this._scrollView;if(a){a.removeObserver("canScrollHorizontal",this,this._scrollCanScrollHorizontalDidChange);a.removeObserver("canScrollVertical",this,this._scrollCanScrollVerticalDidChange);a.removeObserver("horizontalScrollOffset",this,this._scrollOffsetDidChange);a.removeObserver("verticalScrollOffset",this,this._scrollOffsetDidChange)}},_scrollOffsetDidChange:function(){this.invokeNext(this.positionPane)},init:function(){arguments.callee.base.apply(this,arguments);if(!this.windowPadding){this.windowPadding=SC.PickerPane.WINDOW_PADDING}},destroy:function(){this._scrollView=null;this._anchorView=null;this._anchorHTMLElement=null;return arguments.callee.base.apply(this,arguments)}});SC.PickerPane.mixin({WINDOW_PADDING:20,TINY_MENU_WINDOW_PADDING:12,SMALL_MENU_WINDOW_PADDING:11,REGULAR_MENU_WINDOW_PADDING:12,LARGE_MENU_WINDOW_PADDING:17,HUGE_MENU_WINDOW_PADDING:12,PICKER_POINTER_OFFSET:[9,-9,-18,18],TINY_PICKER_MENU_POINTER_OFFSET:[9,-9,-18,18],SMALL_PICKER_MENU_POINTER_OFFSET:[9,-9,-8,8],REGULAR_PICKER_MENU_POINTER_OFFSET:[9,-9,-12,12],LARGE_PICKER_MENU_POINTER_OFFSET:[9,-9,-16,16],HUGE_PICKER_MENU_POINTER_OFFSET:[9,-9,-18,18],PICKER_EXTRA_RIGHT_OFFSET:20,TINY_PICKER_MENU_EXTRA_RIGHT_OFFSET:12,SMALL_PICKER_MENU_EXTRA_RIGHT_OFFSET:11,REGULAR_PICKER_MENU_EXTRA_RIGHT_OFFSET:12,LARGE_PICKER_MENU_EXTRA_RIGHT_OFFSET:17,HUGE_PICKER_MENU_EXTRA_RIGHT_OFFSET:12});SC.SeparatorView=SC.View.extend({classNames:["sc-separator-view"],tagName:"span",layoutDirection:SC.LAYOUT_HORIZONTAL,render:function(a,b){if(b){a.push("<span></span>")}a.addClass(this.get("layoutDirection"))}});sc_require("views/separator");SC.MenuItemView=SC.View.extend(SC.ContentDisplay,{classNames:["sc-menu-item"],displayProperties:["title","toolTip","isEnabled","icon","isSeparator","shortcut","isChecked"],ariaRole:"menuitem",escapeHTML:YES,acceptsFirstResponder:YES,blocksIEDeactivate:YES,isContextMenuEnabled:NO,content:null,title:function(){var b=this.getContentProperty("itemTitleKey"),a=this.getPath("parentMenu.localize");if(a&&b){b=SC.String.loc(b)}return b||""}.property().cacheable(),value:function(){return this.getContentProperty("itemValueKey")}.property().cacheable(),toolTip:function(){var b=this.getContentProperty("itemToolTipKey"),a=this.getPath("parentMenu.localize");if(a&&b){b=SC.String.loc(b)}return b||""}.property().cacheable(),isEnabled:function(){return this.getContentProperty("itemIsEnabledKey")!==NO&&this.getContentProperty("itemSeparatorKey")!==YES}.property().cacheable(),icon:function(){return this.getContentProperty("itemIconKey")}.property().cacheable(),isSeparator:function(){return this.getContentProperty("itemSeparatorKey")===YES}.property().cacheable(),shortcut:function(){return this.getContentProperty("itemShortCutKey")}.property().cacheable(),isChecked:function(){return this.getContentProperty("itemCheckboxKey")}.property().cacheable(),subMenu:function(){var b=this.get("parentMenu"),c=this.getContentProperty("itemSubMenuKey");if(c){if(SC.kindOf(c,SC.MenuPane)){c.set("isModal",NO);c.set("isSubMenu",YES);c.set("parentMenu",b);return c}else{var a=this._subMenu;if(a){if(a.get("isAttached")){this.invokeLast("showSubMenu")}a.remove();a.destroy()}a=this._subMenu=SC.MenuPane.create({layout:{width:200},items:c,isModal:NO,isSubMenu:YES,parentMenu:b,controlSize:b.get("controlSize"),exampleView:b.get("exampleView")});return a}}return null}.property().cacheable(),hasSubMenu:function(){return !!this.get("subMenu")}.property("subMenu").cacheable(),getContentProperty:function(b){var a=this.get("content"),c=this.get("parentMenu");if(a&&c){return a.get(c.get(b))}},init:function(){arguments.callee.base.apply(this,arguments);this.contentDidChange()},destroy:function(){arguments.callee.base.apply(this,arguments);var a=this._subMenu;if(a){a.destroy();this._subMenu=null}},isReusable:false,render:function(a){var b=this.get("content"),f,e=this.get("parentMenu"),c=this.get("itemWidth")||e.layout.width,g=this.get("itemHeight")||SC.DEFAULT_MENU_ITEM_HEIGHT,d=this.get("escapeHTML");this.set("itemWidth",c);this.set("itemHeight",g);if(this.get("isSeparator")){a.setAttr("role","separator")}else{if(this.get("isChecked")){a.setAttr("role","menuitemcheckbox");a.setAttr("aria-checked",true)}}a=a.begin("a").addClass("menu-item");if(this.get("isSeparator")){a.push('<span class="separator"></span>');a.addClass("disabled")}else{f=this.get("icon");if(f){this.renderImage(a,f);a.addClass("has-icon")}f=this.get("title");if(SC.typeOf(f)!==SC.T_STRING){f=f.toString()}this.renderLabel(a,f);f=this.get("toolTip");if(SC.typeOf(f)!==SC.T_STRING){f=f.toString()}if(d){f=SC.RenderContext.escapeHTML(f)}a.setAttr("title",f);if(this.get("isChecked")){a.push('<div class="checkbox"></div>')}if(this.get("hasSubMenu")){this.renderBranch(a)}f=this.get("shortcut");if(f){this.renderShortcut(a,f)}}a=a.end()},renderImage:function(b,d){var a,c;if(d&&SC.ImageView.valueIsUrl(d)){a=d;c=""}else{c=d;a=SC.BLANK_IMAGE_URL}b.begin("img").addClass("image").addClass(c).setAttr("src",a).end()},renderLabel:function(b,a){if(this.get("escapeHTML")){a=SC.RenderContext.escapeHTML(a)}b.push("<span class='value ellipsis'>"+a+"</span>")},renderBranch:function(a){a.push('<span class="has-branch"></span>')},renderShortcut:function(b,a){b.push('<span class = "shortcut">'+a+"</span>")},showSubMenu:function(){var a=this.get("subMenu");if(a&&!a.get("isAttached")){a.set("mouseHasEntered",NO);a.popup(this,[0,0,0])}this._subMenuTimer=null},mouseUp:function(b){var a;a=this.getPath("parentMenu.rootMenu.targetMenuItem");if(a){a.performAction()}return YES},performAction:function(){if(!this.get("isEnabled")){this.getPath("parentMenu.rootMenu").remove();return YES}if(this.get("hasSubMenu")){return NO}var b=this.getContentProperty("itemDisableMenuFlashKey"),a;if(b){this.sendAction()}else{this._flashCounter=0;a=this.getPath("parentMenu.rootMenu");a._isFlashing=YES;this.invokeLater(this.flashHighlight,25);this.invokeLater(this.sendAction,150)}return YES},sendAction:function(){var c=this.getContentProperty("itemActionKey"),d=this.getContentProperty("itemTargetKey"),b=this.getPath("parentMenu.rootMenu"),a;this.getPath("parentMenu.rootMenu").remove();b._isFlashing=NO;c=(c===undefined)?b.get("action"):c;d=(d===undefined)?b.get("target"):d;b.set("selectedItem",this.get("content"));if(SC.typeOf(c)===SC.T_FUNCTION){c.apply(d,[b])}else{a=this.getPath("pane.rootResponder")||SC.RootResponder.responder;if(a){a.sendAction(c,d,b)}}},flashHighlight:function(){var a=this._flashCounter,b=this.$();if(a%2===0){b.addClass("focus")}else{b.removeClass("focus")}if(a<=2){this.invokeLater(this.flashHighlight,50);this._flashCounter++}},mouseDown:function(a){return a.which===1},mouseEntered:function(a){var c=this.get("parentMenu"),b=c.get("rootMenu");if(b._isFlashing){return}c.set("mouseHasEntered",YES);this.set("mouseHasEntered",YES);c.set("currentMenuItem",this);if(this.get("isEnabled")){this.becomeFirstResponder()}if(this.get("hasSubMenu")){this._subMenuTimer=this.invokeLater(this.showSubMenu,100)}return YES},mouseExited:function(a){var b,c;if(this.get("hasSubMenu")){c=this._subMenuTimer;if(c){c.invalidate()}else{this.invokeLater(this.checkMouseLocation,100)}}else{b=this.get("parentMenu");if(b.get("currentMenuItem")===this){b.set("currentMenuItem",null)}}return YES},touchStart:function(a){this.mouseEntered(a);return YES},touchEnd:function(a){return this.mouseUp(a)},touchEntered:function(a){return this.mouseEntered(a)},touchExited:function(a){return this.mouseExited(a)},checkMouseLocation:function(){var b=this.get("subMenu"),c=this.get("parentMenu"),a,d;if(!b.get("mouseHasEntered")){a=c.get("currentMenuItem");if(a===this||a===null){d=c.get("previousMenuItem");if(d){d.resignFirstResponder()}this.resignFirstResponder();b.remove()}}},moveUp:function(b,a){var c=this.get("parentMenu");if(c){c.moveUp(this)}return YES},moveDown:function(b,a){var c=this.get("parentMenu");if(c){c.moveDown(this)}return YES},moveRight:function(b,a){this.showSubMenu();return YES},insertText:function(b,a){var c=this.get("parentMenu");if(c){c.insertText(b,a)}},keyDown:function(a){return this.interpretKeyEvents(a)},keyUp:function(a){return YES},cancel:function(a){this.getPath("parentMenu.rootMenu").remove();return YES},didBecomeFirstResponder:function(a){if(a!==this){return}var b=this.get("parentMenu");if(b){b.set("currentSelectedMenuItem",this)}},willLoseFirstResponder:function(a){if(a!==this){return}var b=this.get("parentMenu");if(b){b.set("currentSelectedMenuItem",null);b.set("previousSelectedMenuItem",this)}},insertNewline:function(b,a){this.mouseUp(a)},closeParent:function(){this.$().removeClass("focus");var a=this.get("parentMenu");if(a){a.remove()}},clickInside:function(b,a){return SC.pointInRect({x:a.pageX,y:a.pageY},b)},contentDidChange:function(){var b=this.get("content"),a=this._content;if(b===a){return}var c=this.contentPropertyDidChange;if(a&&a.removeObserver){a.removeObserver("*",this,c)}this._content=b;if(b&&b.addObserver){b.addObserver("*",this,c)}this.contentPropertyDidChange(b,"*")}.observes("content"),contentPropertyDidChange:function(g,j){var b=this.get("parentMenu");if(!b){return}var a=SC.MenuItemView._contentPropertyToMenuItemPropertyMapping,h=SC.keys(a),e,f,d,c;if(j==="*"){for(e=0,f=h.length;e<f;++e){d=h[e];c=a[d];this.notifyPropertyChange(c)}}else{for(e=0,f=h.length;e<f;++e){d=h[e];if(b.get(d)===j){c=a[d];this.notifyPropertyChange(c)}}}}});SC.MenuItemView._contentPropertyToMenuItemPropertyMapping={itemTitleKey:"title",itemValueKey:"value",itemToolTipKey:"toolTip",itemIsEnabledKey:"isEnabled",itemIconKey:"icon",itemSeparatorKey:"isSeparator",itemShortCutKey:"shortcut",itemCheckboxKey:"isChecked",itemSubMenuKey:"subMenu"};sc_require("panes/picker");sc_require("views/menu_item");SC.MenuPane=SC.PickerPane.extend({_sc_menu_items:null,classNames:["sc-menu"],ariaRole:"menu",items:null,controlSize:SC.REGULAR_CONTROL_SIZE,itemHeight:SC.propertyFromRenderDelegate("itemHeight",20),itemSeparatorHeight:SC.propertyFromRenderDelegate("itemSeparatorHeight",9),menuHeight:0,menuHeightPadding:SC.propertyFromRenderDelegate("menuHeightPadding",6),submenuOffsetX:SC.propertyFromRenderDelegate("submenuOffsetX",2),selectedItem:null,exampleView:SC.MenuItemView,anchor:null,isSubMenu:NO,escapeHTML:YES,localize:YES,acceptsMenuPane:YES,isContextMenuEnabled:NO,popup:function(a,b){this.beginPropertyChanges();if(a){if(a.isView){this._anchorView=a;this._setupScrollObservers(a)}else{this._anchorHTMLElement=a}}if(b){this.set("preferMatrix",b)}this.adjust("height",this.get("menuHeight"));this.positionPane();this.set("defaultResponder",this);this.endPropertyChanges();SC.bodyOverflowArbitrator.requestHidden(this,true);this.append()},itemTitleKey:"title",itemValueKey:"value",itemToolTipKey:"toolTip",itemIsEnabledKey:"isEnabled",itemIconKey:"icon",itemHeightKey:"height",itemSubMenuKey:"subMenu",itemSeparatorKey:"isSeparator",itemTargetKey:"target",itemActionKey:"action",itemCheckboxKey:"checkbox",itemShortCutKey:"shortcut",itemKeyEquivalentKey:"keyEquivalent",itemDisableMenuFlashKey:"disableMenuFlash",itemLayerIdKey:"layerId",itemExampleViewKey:"exampleView",menuItemKeys:["itemTitleKey","itemValueKey","itemToolTipKey","itemIsEnabledKey","itemIconKey","itemSeparatorKey","itemActionKey","itemCheckboxKey","itemShortCutKey","itemHeightKey","itemSubMenuKey","itemKeyEquivalentKey","itemTargetKey","itemLayerIdKey"],target:null,action:null,preferType:SC.PICKER_MENU,init:function(){if(!this.items){this.items=[]}this._keyEquivalents={};arguments.callee.base.apply(this,arguments);this._sc_menu_itemsDidChange()},displayProperties:["controlSize"],renderDelegateName:"menuRenderDelegate",createChildViews:function(){var b,a;a=this._menuView=SC.View.create({layout:{height:0}});b=this._menuScrollView=this.createChildView(SC.MenuScrollView,{controlSize:this.get("controlSize"),contentView:a});this.childViews=[b];return this},didAppendToDocument:function(){this.becomeMenuPane()},willRemoveFromDocument:function(){var a=this.get("parentMenu");this.set("currentMenuItem",null);this.closeOpenMenus();this.resignMenuPane();if(a){a.becomeMenuPane()}},becomeMenuPane:function(){if(this.rootResponder){this.rootResponder.makeMenuPane(this)}return this},resignMenuPane:function(){if(this.rootResponder){this.rootResponder.makeMenuPane(null)}return this},menuItemViews:function(){return this.createMenuItemViews()}.property("displayItems").cacheable(),createMenuItemViews:function(){var i=[],q=this.get("displayItems"),a=this.get("exampleView"),u,d,l,k,e,p,n,g,b,j,r,c,f,m,h,o,w,v,s,t;if(!q){return i}n=this.get("itemHeightKey");g=this.get("itemSeparatorKey");k=this.get("itemExampleViewKey");b=this.get("itemHeight");f=this.get("itemKeyEquivalentKey");j=this.get("itemSeparatorHeight");w=this.get("itemLayerIdKey");s=this.get("escapeHTML");c=Math.floor(this.get("menuHeightPadding")/2);r=c;h=this.menuItemKeys.map(SC._menu_fetchKeys,this);t=q.get("length");for(o=0;o<t;o++){u=q[o];p=u.get(n);if(!p){p=u.get(g)?j:b}v={layout:{height:p,top:r},contentDisplayProperties:h,content:u,parentMenu:this,escapeHTML:s};if(u.get(w)){v.layerId=u.get(w)}e=u.get(k);if(e){d=e}else{d=a}l=this._menuView.createChildView(d,v);i[o]=l;r+=p;m=u.get(f);if(m){if(SC.typeOf(m)===SC.T_ARRAY){m.forEach(function(x){this._keyEquivalents[x]=l},this)}else{this._keyEquivalents[m]=l}}}this.set("menuHeight",r+c);return i},menuItemViewForContentIndex:function(a){var b=this.get("menuItemViews");if(!b){return undefined}return b.objectAt(a)},rootMenu:function(){if(this.get("isSubMenu")){return this.getPath("parentMenu.rootMenu")}return this}.property("isSubMenu").cacheable(),destroy:function(){var a=arguments.callee.base.apply(this,arguments);if(this._sc_menu_items){this._sc_menu_items.removeObserver("[]",this,"_sc_menu_itemPropertiesDidChange")}this._menuView.destroy();this._sc_menu_items=null;this._menuView=null;return a},windowSizeDidChange:function(){this.remove();return arguments.callee.base.apply(this,arguments)},displayItems:function(){var c=this.get("items"),b,d=[],a,e,f;if(!c){return null}b=c.get("length");for(a=0;a<b;a++){e=c.objectAt(a);if(!e||(!d.length&&e[this.get("itemSeparatorKey")])){continue}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)}}e.contentIndex=a;d.push(e)}return d}.property("items").cacheable(),_sc_menu_itemsDidChange:function(){var a=this.get("items");if(this._sc_menu_items){this._sc_menu_items.removeObserver("[]",this,"_sc_menu_itemPropertiesDidChange")}if(a){a.addObserver("[]",this,"_sc_menu_itemPropertiesDidChange")}this._sc_menu_items=a;var b;b=this.get("menuItemViews");this._menuView.replaceAllChildren(b);this._menuView.adjust("height",this.get("menuHeight"))}.observes("items"),_sc_menu_itemPropertiesDidChange:function(){this.notifyPropertyChange("displayItems");var a;a=this.get("menuItemViews");this._menuView.replaceAllChildren(a);this._menuView.adjust("height",this.get("menuHeight"))},currentMenuItem:function(a,b){if(b!==undefined){if(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){}else{b.resignFirstResponder();this.closeOpenMenusFor(b)}}if(a&&a.get("isEnabled")){a.scrollToVisible()}}.observes("currentMenuItem"),closeOpenMenusFor:function(a){if(!a){return}var b=a.get("parentMenu");while(b&&a){b=a.get("subMenu");if(b){b.remove();a.resignFirstResponder();a=b.get("previousMenuItem")}}},closeOpenMenus:function(){this.closeOpenMenusFor(this.get("previousMenuItem"))},mouseDown:function(a){this.modalPaneDidClick(a);return YES},mouseEntered:function(){this.set("mouseHasEntered",YES)},keyUp:function(a){var b=this.interpretKeyEvents(a);return !b?NO:b},moveUp:function(){var c=this.get("currentMenuItem"),d=this.get("menuItemViews"),b,a;if(!c){a=d.get("length")-1}else{b=c.getPath("content.contentIndex");if(b===0){return YES}a=b-1}while(a>=0){if(d[a].get("isEnabled")){this.set("currentMenuItem",d[a]);d[a].becomeFirstResponder();break}a--}return YES},moveDown:function(){var d=this.get("currentMenuItem"),e=this.get("menuItemViews"),b=e.get("length"),c,a;if(!d){a=0}else{c=d.getPath("content.contentIndex");if(c===b){return YES}a=c+1}while(a<b){if(e[a].get("isEnabled")){this.set("currentMenuItem",e[a]);e[a].becomeFirstResponder();break}a++}return YES},moveToBeginningOfDocument:function(){var c=this.get("menuItemViews"),b=c.get("length"),a=0;while(a<b){if(c[a].get("isEnabled")){this.set("currentMenuItem",c[a]);c[a].becomeFirstResponder();break}++a}return YES},moveToEndOfDocument:function(){var c=this.get("menuItemViews"),b=c.get("length"),a=b-1;while(a>=0){if(c[a].get("isEnabled")){this.set("currentMenuItem",c[a]);c[a].becomeFirstResponder();break}--a}return YES},pageDown:function(){var c=this.get("currentMenuItem"),h,e=this.get("menuItemViews"),b=e.get("length"),a=0,g,d=0,f;if(this._menuScrollView&&this._menuScrollView.bottomScrollerView){if(c){a=c.getPath("content.contentIndex")}g=a;f=this._menuScrollView.get("verticalPageScroll");for(a;a<b;a++){h=e[a];d+=h.get("layout").height;if(d>f){break}else{if(h.get("isEnabled")){g=a}}}h=e[g];this.set("currentMenuItem",h);h.becomeFirstResponder()}else{this.moveToEndOfDocument()}return YES},pageUp:function(){var c=this.get("currentMenuItem"),h,e=this.get("menuItemViews"),b=e.get("length"),a=b-1,g,d=0,f;if(this._menuScrollView&&this._menuScrollView.topScrollerView){if(c){a=c.getPath("content.contentIndex")}g=a;f=this._menuScrollView.get("verticalPageScroll");for(a;a>=0;a--){h=e[a];d+=h.get("layout").height;if(d>f){break}else{if(h.get("isEnabled")){g=a}}}h=e[g];this.set("currentMenuItem",h);h.becomeFirstResponder()}else{this.moveToBeginningOfDocument()}return YES},insertText:function(a){var c=this._timer,b=this._keyBuffer;if(c){c.invalidate()}c=this._timer=SC.Timer.schedule({target:this,action:"clearKeyBuffer",interval:500,isPooled:NO});b=b||"";b+=a.toUpperCase();this.selectMenuItemForString(b);this._keyBuffer=b;return YES},performKeyEquivalent:function(d,a,b){if(!b&&!this.get("isVisibleInWindow")){return NO}var c=this._keyEquivalents[d];if(c){c.performAction(YES);return YES}if(d==="escape"||d==="return"){this.remove();return YES}return NO},selectMenuItemForString:function(c){var d=this.get("menuItemViews"),f,g,b,a,e;if(!d){return}e=c.length;a=d.get("length");for(b=0;b<a;b++){f=d.objectAt(b);g=f.get("title");if(!g){continue}g=g.replace(/ /g,"").substr(0,e).toUpperCase();if(g===c){this.set("currentMenuItem",f);f.becomeFirstResponder();break}}},clearKeyBuffer:function(){this._keyBuffer=""},modalPaneDidClick:function(){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.MenuPane.TINY_MENU_ITEM_HEIGHT=10;SC.MenuPane.SMALL_MENU_ITEM_HEIGHT=16;SC.MenuPane.REGULAR_MENU_ITEM_HEIGHT=22;SC.MenuPane.LARGE_MENU_ITEM_HEIGHT=31;SC.MenuPane.HUGE_MENU_ITEM_HEIGHT=20;sc_require("panes/panel");SC.SheetPane=SC.PanelPane.extend({classNames:["sc-sheet"],modalPane:SC.ModalPane,duration:0.3,timing:"ease-in-out",transitionIn:SC.View.SLIDE_IN,transitionInOptions:function(){return{direction:"down",duration:this.get("duration"),timing:this.get("timing")}}.property("timing","duration").cacheable(),transitionOut:SC.View.SLIDE_OUT,transitionOutOptions:function(){return{direction:"up",duration:this.get("duration"),timing:this.get("timing")}}.property("timing","duration").cacheable()});SC.BaseTheme.buttonRenderDelegate=SC.RenderDelegate.create({className:"button","sc-small-size":{height:18,autoResizePadding:{width:15,height:0}},"sc-regular-size":{height:24,autoResizePadding:{width:20,height:0}},"sc-huge-size":{height:30,autoResizePadding:{width:30,height:0}},"sc-jumbo-size":{height:44,autoResizePadding:{width:50,height:0}},render:function(a,e){this.addSizeClassName(a,e);var b=a.get("toolTip"),f=a.get("isSelected")||NO,i=a.get("isActive")||NO,g=a.get("isDefault")||NO,h=a.get("isCancel")||NO,d=(a.get("buttonBehavior")===SC.TOGGLE_BEHAVIOR),c=SC.guidFor(a)+"-label";e.setClass({icon:!!a.get("icon"),def:g,cancel:h&&!g,active:i,sel:f});if(b){e.setAttr("title",b)}this.includeSlices(a,e,SC.THREE_SLICE);if(a.get("isSegment")){e.setAttr("aria-selected",f.toString())}else{if(d){e.setAttr("aria-pressed",i.toString())}}e.setAttr("aria-labelledby",c);e=e.begin("label").addClass("sc-button-label").id(c);a.get("theme").labelRenderDelegate.render(a,e);e=e.end();if(a.get("supportFocusRing")){e=e.begin("div").addClass("focus-ring");this.includeSlices(a,e,SC.THREE_SLICE);e=e.end()}},update:function(f,a){var e=(f.get("buttonBehavior")===SC.TOGGLE_BEHAVIOR),d=f.get("isDefault"),c=f.get("isCancel"),b=f.get("toolTip");this.updateSizeClassName(f,a);if(f.get("isActive")){a.addClass("active")}if(f.get("isSegment")){a.attr("aria-selected",f.get("isSelected").toString())}else{if(e){a.attr("aria-pressed",f.get("isActive").toString())}}if(b){a.attr("title",b)}else{a.removeAttr("title")}a.setClass("icon",!!f.get("icon"));a.setClass("def",!!d);a.setClass("cancel",!!c&&!d);f.get("theme").labelRenderDelegate.update(f,a.find("label"))},getRenderedAutoResizeLayer:function(a,b){return b.find(".sc-button-label")[0]}});SC.BaseTheme.checkboxRenderDelegate=SC.RenderDelegate.create({className:"checkbox",render:function(g,c){this.addSizeClassName(g,c);var f=g.get("theme"),e;e=SC.guidFor(g)+"-label";var b=g.get("isSelected")||NO;var d=g.get("isActive");var a;if(b===SC.MIXED_STATE){a="mixed"}else{if(b){a="true"}else{a="false"}}c.setAttr("role","checkbox");c.setAttr("aria-checked",a);c.setAttr("aria-labelledby",e);c.setClass({sel:b,active:d});c.push('<span class = "button"></span>');c=c.begin("span").addClass("label").id(e);f.labelRenderDelegate.render(g,c);c=c.end()},update:function(f,b){this.updateSizeClassName(f,b);var e=f.get("theme");var c=f.get("isSelected");var d=f.get("isActive");var a;if(c===SC.MIXED_STATE){a="mixed"}else{if(c){a="true"}else{a="false"}}b.attr("aria-checked",a);e.labelRenderDelegate.update(f,b.find("span.label"));b.setClass({sel:c,active:d})}});SC.BaseTheme.collectionRenderDelegate=SC.RenderDelegate.create({className:"collection",render:function(b,a){a.setClass("active",b.get("isActive"))},update:function(b,a){a.setClass("active",b.get("isActive"))}});SC.BaseTheme.disclosureRenderDelegate=SC.RenderDelegate.create({className:"disclosure",render:function(g,a){this.addSizeClassName(g,a);var f=g.get("theme"),d=g.get("value"),b=["sc-button-label","sc-disclosure-label"];var e=SC.guidFor(g)+"-label";a.setAttr("aria-expanded",d);a.setAttr("aria-labelledby",e);if(g.get("isSelected")){a.addClass("sel")}var c="";c+=g.get("isSelected")?"open":"closed";if(g.get("isActive")){c+=" active"}a.push('<img src = "'+SC.BLANK_IMAGE_URL+'" class = "disclosure button '+c+'" />');a=a.begin("span").addClass(b).id(e);f.labelRenderDelegate.render(g,a);a=a.end()},update:function(d,a){this.updateSizeClassName(d,a);var c=d.get("theme"),b=d.get("value");a.attr("aria-expanded",b);if(d.get("isSelected")){a.addClass("sel")}a.find("img").setClass({open:d.get("isSelected"),closed:!d.get("isSelected"),active:d.get("isActive")});c.labelRenderDelegate.update(d,a.find("span.sc-disclosure-label"))}});SC.THREE_SLICE=["left","middle","right"];SC.NINE_SLICE=["top-left","top","top-right","left","middle","right","bottom-left","bottom","bottom-right"];SC.RenderDelegate.reopen({includeSlices:function(e,c,d){for(var b=0,a=d.length;b<a;b++){c.push('<div class="'+d[b]+'"></div>')}}});SC.BaseTheme.imageButtonRenderDelegate=SC.RenderDelegate.create({className:"image-button",render:function(d,b){var c=d.get("image"),a=d.get("toolTip");this.addSizeClassName(d,b);if(a){b.setAttr("title",a);b.setAttr("alt",a)}if(c){b.addClass(c);d.renderState._cachedImage=c}},update:function(d,b){var c,a;this.updateSizeClassName(d,b);if(d.didChangeFor("imageButtonRenderDelegate","toolTip")){a=d.get("toolTip");b.attr("title",a);b.attr("alt",a)}if(d.didChangeFor("imageButtonRenderDelegate","image")){c=d.get("image");if(d.renderState._cachedImage){b.removeClass(d.renderState._cachedImage)}if(c){b.addClass(c);d.renderState._cachedImage=c}}}});SC.BaseTheme.MASTER_DETAIL_DIVIDER_WIDTH=1;SC.BaseTheme.masterDetailRenderDelegate=SC.RenderDelegate.create({className:"master-detail",dividerWidth:1,render:function(b,a){a.setClass("round-toolbars",SC.platform.touch)},update:function(b,a){a.setClass("round-toolbars",SC.platform.touch)}});SC.BaseTheme.panelRenderDelegate=SC.RenderDelegate.create({className:"panel",render:function(e,b){b=b.begin("div").addClass("panel-background");this.includeSlices(e,b,SC.NINE_SLICE);b=b.end();var a=e.get("ariaLabel"),c=e.get("ariaLabelledBy"),d=e.get("ariaDescribedBy");if(a){b.setAttr("aria-label",a)}if(c){b.setAttr("aria-labelledby",c)}if(d){b.setAttr("aria-describedby",d)}},update:function(e,c){var a=e.get("ariaLabel"),b=e.get("ariaLabelledBy"),d=e.get("ariaDescribedBy");if(a){c.attr("aria-label",a)}if(b){c.attr("aria-labelledby",b)}if(d){c.attr("aria-describedby",d)}}});sc_require("render_delegates/panel");SC.BaseTheme.pickerRenderDelegate=SC.RenderDelegate.create({className:"picker",render:function(e,c){var a=e.get("theme").panelRenderDelegate;a.render(e,c);var b=e.get("preferType"),d=e.get("pointerPos");if(b==SC.PICKER_POINTER||b==SC.PICKER_MENU_POINTER){c.push('<div class="sc-pointer '+d+'"></div>');c.addClass(d);e.renderState._lastPointerPosition=d}},update:function(g,e){var a=g.get("theme").panelRenderDelegate;a.update(g,e);var b=g.get("preferType"),d=g.get("pointerPos");if(b==SC.PICKER_POINTER||b==SC.PICKER_MENU_POINTER){var f=g.renderState._lastPointerPosition;if(f!==d){var c=e.find(".sc-pointer");c.attr("class","sc-pointer "+d);e.removeClass(f);e.addClass(d);g.renderState._lastPointerPosition=d}}}});sc_require("render_delegates/picker");SC.BaseTheme.menuRenderDelegate=SC.BaseTheme.pickerRenderDelegate.create({className:"menu",render:function(c,b,a){this.addSizeClassName(b,a);c(b,a)}.enhance(),update:function(c,b,a){this.updateSizeClassName(b,a);c(b,a)}.enhance(),itemHeight:20,itemSeparatorHeight:9,menuHeightPadding:6,menuWidthPadding:50,minimumMenuWidth:50,submenuOffsetX:2,verticalOffset:23,"sc-tiny-size":{itemHeight:10,itemSeparatorHeight:2,menuHeightPadding:2,submenuOffsetX:0},"sc-small-size":{itemHeight:16,itemSeparatorHeight:7,menuHeightPadding:4,submenuOffsetX:2},"sc-large-size":{itemHeight:60,itemSeparatorHeight:20,menuHeightPadding:0,submenuOffsetX:4},"sc-huge-size":{itemHeight:20,itemSeparatorHeight:9,menuHeightPadding:0,submenuOffsetX:0}});SC.BaseTheme.popupButtonRenderDelegate=SC.BaseTheme.buttonRenderDelegate.create({render:function(b,a){a.setAttr("aria-haspopup","true");arguments.callee.base.apply(this,arguments)},update:function(b,a){arguments.callee.base.apply(this,arguments)}});SC.BaseTheme.PROGRESS_OFFSET=0.5;SC.BaseTheme.PROGRESS_OFFSET_RANGE=42;SC.BaseTheme.progressRenderDelegate=SC.RenderDelegate.create({className:"progress",render:function(h,c){this.addSizeClassName(h,c);var a=h.get("isIndeterminate"),g=h.get("theme"),b=h.get("maximum"),e=h.get("minimum"),d=h.get("ariaValue");var f;if(a){f=1}else{f=h.get("value")}c.setAttr("aria-valuemax",b);c.setAttr("aria-valuemin",e);c.setAttr("aria-valuenow",d);c.setAttr("aria-valuetext",d);c.setClass({indeterminate:a,running:h.get("isRunning")&&a,"sc-empty":(f<=0),"sc-complete":(f>=1&&!a)});c=c.begin("div").addClass("track");this.includeSlices(h,c,SC.THREE_SLICE);c=c.end();c=c.begin("div").addClass("content");c.setStyle("width",(f*100)+"%");this.includeSlices(h,c,SC.THREE_SLICE);c=c.end()},update:function(a,j){this.updateSizeClassName(a,j);var d=a.get("theme"),g,h=a.get("maximum"),e=a.get("minimum"),b=a.get("ariaValue"),c=a.get("isIndeterminate"),i=a.get("isRunning"),f=a.get("isVisibleInWindow");j.attr("aria-valuemax",h);j.attr("aria-valuemin",e);j.attr("aria-valuenow",b);j.attr("aria-valuetext",b);if(c){g=1}else{g=a.get("value")}j.setClass({indeterminate:c,running:i&&c,"sc-empty":(g<=0),"sc-complete":(g>=1&&!c)});j.find(".content").css("width",(g*100)+"%");if(!SC.platform.supportsCSSTransitions){if(!this._queue[j[0].id]){this._queue[j[0].id]={offset:0,element:SC.$(j).find(".content .middle"),shouldAnimate:false}}if(c&&i&&f){this._queue[j[0].id].shouldAnimate=true;this.animate(a)}else{if(!c){this._queue[j[0].id].element.css("background-position","")}else{this._queue[j[0].id].shouldAnimate=false}}}},_queue:{},_animating:false,animate:function(b){var a=this;if(this._animating){return}function c(){var h,e,f,d=a._queue,j=0,g;var i;for(i in d){if(d.hasOwnProperty(i)){g=d[i];if(g.shouldAnimate){a._animating=true;j++;e=g.offset||0;h=(e+SC.BaseTheme.PROGRESS_OFFSET)%SC.BaseTheme.PROGRESS_OFFSET_RANGE;f=Math.round(h);if(f>Math.round(e)){g.element.css("background-position",f+"px 0px")}g.offset=h}}}if(j===0){a._animating=false}else{window.requestAnimationFrame(c)}}c()}});SC.BaseTheme.radioRenderDelegate=SC.RenderDelegate.create({className:"radio",render:function(f,b){this.addSizeClassName(f,b);var e=f.get("theme");var a=f.get("isSelected"),c=f.get("width"),d=SC.guidFor(f)+"-label";b.setClass({active:f.get("isActive"),mixed:f.get("isMixed"),sel:f.get("isSelected"),disabled:!f.get("isEnabled")});b.setAttr("role","radio");b.setAttr("aria-checked",a);b.setAttr("aria-labelledby",d);b.setAttr("aria-disabled",f.get("isEnabled")?"false":"true");if(c){b.setStyle("width",c)}b.push('<span class = "button"></span>');b=b.begin("span").addClass("sc-button-label").id(d);e.labelRenderDelegate.render(f,b);b=b.end()},update:function(f,a){this.updateSizeClassName(f,a);var e=f.get("theme");var b=f.get("isSelected"),c=f.get("width"),d=f.get("value");a.setClass({active:f.get("isActive"),mixed:f.get("isMixed"),sel:f.get("isSelected"),disabled:!f.get("isEnabled")});a.attr("aria-disabled",f.get("isEnabled")?"false":"true");a.attr("aria-checked",b);a.css("width",c?c:null);e.labelRenderDelegate.update(f,a.find(".sc-button-label"))}});SC.BaseTheme.radioGroupRenderDelegate=SC.RenderDelegate.create({className:"radio-group",render:function(h,e){this.addSizeClassName(h,e);var g=h.get("theme"),d=SC.guidFor(this),c=h.get("items"),b,a=c.length,f;e.addClass(h.get("layoutDirection"));e.setAttr("role","radiogroup");e.setAttr("aria-disabled",h.get("isEnabled")?"false":"true");for(b=0;b<a;b++){f=c[b];e=e.begin("div").addClass("radio-"+b).setAttr("index",b).addClass(g.classNames).addClass(g.radioRenderDelegate.className).addClass("sc-radio-button");g.radioRenderDelegate.render(f,e);e=e.end()}h.get("renderState").radioCount=b},update:function(a,d){this.updateSizeClassName(a,d);var e=a.get("theme"),b=SC.guidFor(this),g=a.get("items"),h,f=g.length,i;d.addClass(a.get("layoutDirection"));d.attr("aria-disabled",a.get("isEnabled")?"false":"true");if(a.get("renderState").radioCount!==f){var c=SC.RenderContext(d[0]);this.render(a,c);c.update();return}for(h=0;h<f;h++){i=g[h];e.radioRenderDelegate.update(i,d.find(".radio-"+h))}},updateRadioAtIndex:function(d,a,b){var c=d.get("items")[b];d.get("theme").radioRenderDelegate.update(c,a.find(".radio-"+b))},indexForEvent:function(d,b,a){var c=$(a.target).closest(".sc-radio-button").attr("index");if(isNaN(c)){return undefined}return parseInt(c,0)}});SC.BaseTheme.segmentRenderDelegate=SC.RenderDelegate.create({className:"segment",render:function(e,b){var c=e.get("theme"),d,a;a={"sc-first-segment":e.get("isFirstSegment"),"sc-middle-segment":e.get("isMiddleSegment"),"sc-last-segment":e.get("isLastSegment"),"sc-overflow-segment":e.get("isOverflowSegment"),vertical:e.get("layoutDirection")!==SC.LAYOUT_HORIZONTAL};if(!SC.none(e.get("index"))){a["sc-segment-"+e.get("index")]=YES}b.setClass(a);d=c.buttonRenderDelegate;d.render(e,b)},update:function(e,a){var c=e.get("theme"),d,b={};b={"sc-first-segment":e.get("isFirstSegment"),"sc-middle-segment":e.get("isMiddleSegment"),"sc-last-segment":e.get("isLastSegment"),"sc-overflow-segment":e.get("isOverflowSegment")||NO,vertical:e.get("layoutDirection")!==SC.LAYOUT_HORIZONTAL};if(!SC.none(e.get("index"))){b["sc-segment-"+e.get("index")]=YES}a.setClass(b);d=c.buttonRenderDelegate;d.update(e,a)}});SC.BaseTheme.segmentedRenderDelegate=SC.RenderDelegate.create({className:"segmented",render:function(b,a){this.addSizeClassName(b,a);a.addStyle("text-align",b.get("align"))},update:function(b,a){this.updateSizeClassName(b,a);a.css("text-align",b.get("align"))}});SC.BaseTheme.sliderRenderDelegate=SC.RenderDelegate.create({className:"slider",render:function(h,d){this.addSizeClassName(h,d);var b=h.get("maximum"),f=h.get("minimum"),e=h.get("ariaValue");d.setAttr("aria-valuemax",b);d.setAttr("aria-valuemin",f);d.setAttr("aria-valuenow",e);if(f!==0||b!==100){d.setAttr("aria-valuetext",e)}d.setAttr("aria-orientation","horizontal");d=d.begin("span").addClass("track");this.includeSlices(h,d,SC.THREE_SLICE);if(h.get("markSteps")){var g=h.get("stepPositions");if(g){var c,a=g.length;for(c=0;c<a;c++){d.begin().setStyle("left","%@%".fmt(g[c]*100)).addClass(["sc-slider-step-mark","sc-slider-step-mark-%@".fmt(c)]).setClass({"sc-slider-step-mark-first":c===0,"sc-slider-step-mark-last":c===a-1}).end()}}}d.begin("img").setAttr("src",SC.BLANK_IMAGE_URL).addClass("sc-handle").setStyle("left","%@%".fmt(h.get("value"))).end();d=d.end();h.get("renderState")._cachedHandle=null},update:function(b,c){this.updateSizeClassName(b,c);var o=b.get("maximum"),h=b.get("minimum"),e=b.get("ariaValue"),k=b.get("renderState")._cachedHandle;if(!k){k=b.get("renderState")._cachedHandle=c.find(".sc-handle")}c.attr("aria-valuemax",o);c.attr("aria-valuemin",h);c.attr("aria-valuenow",e);if(h!==0||o!==100){c.attr("aria-valuetext",e)}c.attr("aria-orientation","horizontal");if(b.didChangeFor("sliderRenderDelegateMinimumMaximumStepMarkSteps","minimum","maximum","step","markSteps")){var m=c.find(".sc-slider-step-mark"),q=b.get("markSteps"),p;if(!q||!(p=b.get("stepPositions"))){m.remove()}else{var f,g,j=p.length,a,d='<div style="left:%@%" class="sc-slider-step-mark sc-slider-step-mark-%@ %@"></div>',l;for(g=0;g<j;g++){if(m[g]){m.eq(g).css("left","%@%".fmt(p[g]*100)).setClass({"sc-slider-step-mark-first":g===0,"sc-slider-step-mark-last":g===j-1})}else{if(g===0){a="sc-slider-step-mark-first"}else{if(g===j-1){a="sc-slider-step-mark-last"}else{a=""}}l=d.fmt(p[g]*100,g,a);k.before(l)}}m.slice(g).remove()}}if(b.didChangeFor("sliderRenderDelegateValue","value")){var n=b.get("value");k.css("left",n+"%")}}});SC.BaseTheme.SourceList=SC.BaseTheme.subtheme("source-list");SC.BaseTheme.splitRenderDelegate=SC.RenderDelegate.create({className:"split",_classesForDataSource:function(b){var a={},c=b.get("layoutDirection");a[SC.LAYOUT_VERTICAL]=c===SC.LAYOUT_VERTICAL;a[SC.LAYOUT_HORIZONTAL]=c===SC.LAYOUT_HORIZONTAL;return a},render:function(b,a){a.setClass(this._classesForDataSource(b))},update:function(b,a){a.setClass(this._classesForDataSource(b))}});SC.BaseTheme.splitDividerRenderDelegate=SC.RenderDelegate.create({className:"split-divider",dividerSize:1,splitPositionOffset:-5,splitSizeOffset:10,render:function(b,a){this.addSizeClassName(b,a);a.push("<div class='line'></div>")},update:function(b,a){this.updateSizeClassName(b,a)}});SC.BaseTheme.toolbarRenderDelegate=SC.RenderDelegate.create({className:"toolbar",render:function(b,a){},update:function(){}});SC.BaseTheme.wellRenderDelegate=SC.RenderDelegate.create({className:"well",render:function(b,a){this.includeSlices(b,a,SC.NINE_SLICE)},update:function(){}});SC.BaseTheme.workspaceRenderDelegate=SC.RenderDelegate.create({className:"workspace",render:function(){},update:function(){}});SC.DRAG_LINK=4;SC.DRAG_COPY=1;SC.DRAG_MOVE=2;SC.DRAG_NONE=0;SC.DRAG_ANY=15;SC.DRAG_DATA=8;SC.DRAG_AUTOSCROLL_ZONE_THICKNESS=20;SC.View.reopen({init:function(a){a();if(this.get("isDropTarget")){SC.Drag.addDropTarget(this)}if(this.get("isScrollable")){SC.Drag.addScrollableView(this)}}.enhance(),destroy:function(a){if(this.get("isDropTarget")){SC.Drag.removeDropTarget(this)}if(this.get("isScrollable")){SC.Drag.removeScrollableView(this)}return a()}.enhance()});SC.Drag=SC.Object.extend({source:null,ghostView:null,ghostActsLikeCursor:NO,dragView:null,ghost:YES,sourceIsDraggable:YES,slideBack:YES,ghostOffset:{x:0,y:0},location:{},dataTypes:function(){if(this.dataSource){return this.dataSource.get("dragDataTypes")||[]}var d=this.data;if(d){var a=[];for(var b in d){if(d.hasOwnProperty(b)){a.push(b)}}return a}var c=this.get("source");if(c&&c.dragDataTypes){return c.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");if(b&&SC.typeOf(b.dragDataForType)===SC.T_FUNCTION){return b.dragDataForType(this,a)}else{return null}}}},dataSource:null,data:null,allowedDragOperations:SC.DRAG_ANY,_dragInProgress:YES,_dragViewWasVisible:null,startDrag:function(){if(this.get("sourceIsDraggable")){this._createGhostView()}var i=this.event;var e={x:i.clientX,y:i.clientY};this.set("location",e);if(this.get("sourceIsDraggable")){var b=this._getDragView();var j=b.get("parentView");var h=j?j.convertFrameToView(b.get("frame"),null):b.get("frame");if(this.get("ghost")){this._dragViewWasVisible=b.get("isVisible");b.set("isVisible",NO)}if(this.ghostActsLikeCursor){this.ghostOffset={x:14,y:14}}else{this.ghostOffset={x:(e.x-h.x),y:(e.y-h.y)}}if(!this._ghostViewHidden){this._positionGhostView(i)}if(i.makeTouchResponder){var k=this;SC.Timer.schedule({target:i,action:function(){if(!i.hasEnded){i.makeTouchResponder(k,YES)}},interval:1})}else{this.ghostView.rootResponder.dragDidStart(this,i)}}var a=this.source;if(a&&a.dragDidBegin){a.dragDidBegin(this,e)}var c=this._dropTargets();for(var g=0,d=c.length;g<d;g++){var f=c[g];if(!f.get("isVisibleInWindow")){continue}f.tryToPerform("dragStarted",this,i)}},cancelDrag:function(a){var b=this._lastTarget;if(b&&b.dragExited){b.dragExited(this,this._lastMouseDraggedEvent)}this.endDrag(a,SC.DRAG_NONE)},endDrag:function(c,h){var g=this.get("location");var d=this._dropTargets();for(var b=0,a=d.length;b<a;b++){try{d[b].tryToPerform("dragEnded",this,c)}catch(e){SC.Logger.error("Exception in SC.Drag.mouseUp(dragEnded on %@): %@".fmt(d[b],e))}}if(this.get("sourceIsDraggable")&&this.get("slideBack")&&h===SC.DRAG_NONE){this._slideGhostViewBack()}else{this._endDrag()}var f=this.get("source");if(f){if(f.dragDidSucceed&&h!==SC.DRAG_NONE){f.dragDidSucceed(this,g,h)}else{if(f.dragDidCancel&&h===SC.DRAG_NONE){f.dragDidCancel(this,g,h)}}if(f.dragDidEnd){f.dragDidEnd(this,g,h)}}},touchStart:function(a){return YES},mouseDragged:function(a){var b=this._autoscroll(a);var f=this.get("location");if(!b&&(a.clientX===f.x)&&(a.clientY===f.y)){return}f={x:a.clientX,y:a.clientY};this.set("location",f);this._lastMouseDraggedEvent=a;var d=this.source;var c=this._lastTarget;var e=this._findDropTarget(a);var g=SC.DRAG_NONE;while(e&&(e!==c)&&(g===SC.DRAG_NONE)){if(e&&d&&d.dragSourceOperationMaskFor){g=d.dragSourceOperationMaskFor(this,e)}else{g=SC.DRAG_ANY}if((g!==SC.DRAG_NONE)&&e&&e.computeDragOperations){g=g&e.computeDragOperations(this,a,g)}else{g=SC.DRAG_NONE}this.allowedDragOperations=g;if(g===SC.DRAG_NONE){e=this._findNextDropTarget(e)}}if(e!==c){if(c&&c.dragExited){c.dragExited(this,a)}if(e){if(e.dragEntered){e.dragEntered(this,a)}if(e.dragUpdated){e.dragUpdated(this,a)}}this._lastTarget=e}else{if(e&&e.dragUpdated){e.dragUpdated(this,a)}}if(d&&d.dragDidMove){d.dragDidMove(this,f)}if(this.get("sourceIsDraggable")&&!this._ghostViewHidden){this._positionGhostView(a)}},touchesDragged:function(a){this.mouseDragged(a)},mouseUp:function(a){var d={x:a.clientX,y:a.clientY},c=this._lastTarget,f=this.allowedDragOperations;this.set("location",d);try{if(c&&c.acceptDragOperation&&c.acceptDragOperation(this,f)){f=c.performDragOperation?c.performDragOperation(this,f):SC.DRAG_NONE}else{f=SC.DRAG_NONE}}catch(b){SC.Logger.error("Exception in SC.Drag.mouseUp(acceptDragOperation|performDragOperation): %@".fmt(b))}this.endDrag(a,f)},touchEnd:function(a){this.mouseUp(a)},_getDragView:function(){if(!this.dragView){if(!this.source||!this.source.isView){throw new Error("Source can't be used as dragView, because it's not a view.")}this.dragView=this.source}return this.dragView},_createGhostView:function(){var b=this._getDragView(),d=b.get("borderFrame"),c,a;c={top:d.y,left:d.x,width:d.width,height:d.height};a=this.ghostView=SC.Pane.create({classNames:["sc-ghost-view"],layout:c,owner:this,wantsAcceleratedLayer:b.get("wantsAcceleratedLayer"),didCreateLayer:function(){if(b){var j=b.get("layer");if(j){var h=j.cloneNode(true);var l=b.$().find("canvas");if(l.length){var m=$(h).find("canvas"),f=l.length,g,k,e;for(g=0;g<f;g++){k=l[g];e=m[g];e.width=k.width;e.height=k.height;e.getContext("2d").drawImage(k,0,0)}}h.style.top="0px";h.style.left="0px";h.style.bottom="0px";h.style.right="0px";this.get("layer").appendChild(h)}}}});a.append()},_positionGhostView:function(a){var b=this.ghostView,c;if(b){c=this.get("location");c.x-=this.ghostOffset.x;c.y-=this.ghostOffset.y;b.adjust({top:c.y,left:c.x})}},_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()}},_slideGhostViewBack:function(){if(this.ghostView){var b=this._getDragView(),e=b.get("borderFrame"),a=b.get("parentView"),d=a?a.convertFrameToView(e,null):b.get("frame"),c;c={top:d.y,left:d.x};this.ghostView.animate(c,0.5,this,function(){this.invokeNext(function(){var f=this.get("source");if(this.get("slideBack")&&f&&f.dragSlideBackDidEnd){f.dragSlideBackDidEnd(this)}this._endDrag()})})}else{this._endDrag()}},_destroyGhostView:function(){if(this.ghostView){this.ghostView.remove();this.ghostView=null;this._ghostViewHidden=NO}},_endDrag:function(){if(this.get("sourceIsDraggable")){this._destroyGhostView();if(this.get("ghost")){if(this._dragViewWasVisible){this._getDragView().set("isVisible",YES)}this._dragViewWasVisible=null}}this._cleanUpDrag()},_cleanUpDrag:function(){this._lastTarget=null;this._dragInProgress=NO;this._cachedDropTargets=null},_dropTargets:function(){if(this._cachedDropTargets){return this._cachedDropTargets}var b=[];var d=SC.Drag._dropTargets;for(var c in d){if(d.hasOwnProperty(c)){b.push(d[c])}}var f={};var e=SC.Drag._dropTargets;var a=function(g){if(!g){return 0}var i=SC.guidFor(g);var h=f[i];if(!h){h=1;while((g=g.get("parentView"))){if(e[SC.guidFor(g)]!==undefined){h=h+1}if(g.isPane&&g.isMainPane){h=h+10000}}f[i]=h}return h};b.sort(function(h,g){if(h===g){return 0}h=a(h);g=a(g);return(h>g)?-1:1});this._cachedDropTargets=b;return b},_findDropTarget:function(c){var g={x:c.clientX,y:c.clientY};var e,f;var d=this._dropTargets();for(var b=0,a=d.length;b<a;b++){e=d[b];if(!e.get("isVisibleInWindow")){continue}f=e.convertFrameToView(e.get("clippingFrame"),null);if(SC.pointInRect(g,f)){return e}}return null},_findNextDropTarget:function(a){var b=SC.Drag._dropTargets;while((a=a.get("parentView"))){if(b[SC.guidFor(a)]){return a}}return null},_autoscroll:function(k){if(!k){k=this._lastAutoscrollEvent}if(!this._dragInProgress){return NO}var e=k?{x:k.clientX,y:k.clientY}:this.get("location"),g=this._findScrollableView(e),l=null,j,b,c,h,a,d;while(g&&!l){j=g.get("canScrollVertical")?1:0;b=g.get("canScrollHorizontal")?1:0;if(j||b){a=g.get("containerView");if(a){d=g.convertFrameToView(a.get("frame"),null)}else{j=b=0}}if(j){h=SC.maxY(d);c=h-SC.DRAG_AUTOSCROLL_ZONE_THICKNESS;if(e.y>=c&&e.y<=h){j=1}else{c=SC.minY(d);h=c+SC.DRAG_AUTOSCROLL_ZONE_THICKNESS;if(e.y>=c&&e.y<=h){j=-1}else{j=0}}}if(b){h=SC.maxX(d);c=h-SC.DRAG_AUTOSCROLL_ZONE_THICKNESS;if(e.x>=c&&e.x<=h){b=1}else{c=SC.minX(d);h=c+SC.DRAG_AUTOSCROLL_ZONE_THICKNESS;if(e.x>=c&&e.x<=h){b=-1}else{b=0}}}if(j||b){l=g}else{g=this._findNextScrollableView(g)}}if(l&&(this._lastScrollableView===l)){if((Date.now()-this._hotzoneStartTime)>100){this._horizontalScrollAmount*=1.05;this._verticalScrollAmount*=1.05}}else{this._lastScrollableView=l;this._horizontalScrollAmount=15;this._verticalScrollAmount=15;this._hotzoneStartTime=(l)?Date.now():null;b=j=0}if(l&&(b||j)){var i={x:b*this._horizontalScrollAmount,y:j*this._verticalScrollAmount};l.scrollBy(i)}if(l){if(k){this._lastAutoscrollEvent={clientX:k.clientX,clientY:k.clientY}}this.invokeLater(this._autoscroll,100,null);return YES}else{this._lastAutoscrollEvent=null;return NO}},_scrollableViews:function(){if(this._cachedScrollableView){return this._cachedScrollableView}var a=[];var c=SC.Drag._scrollableViews;for(var b in c){if(c.hasOwnProperty(b)){a.push(c[b])}}a=a.sort(function(f,d){var e=f;while((e=e.get("parentView"))){if(d===e){return -1}}return 1});this._cachedScrollableView=a;return a},_findScrollableView:function(f){var c=this._scrollableViews(),b=c?c.length:0,d,e,a;for(a=0;a<b;a++){d=c[a];if(!d.get("isVisibleInWindow")){continue}e=d.convertFrameToView(d.get("clippingFrame"),null);if(SC.pointInRect(f,e)){return d}}return null},_findNextScrollableView:function(a){var b=SC.Drag._scrollableViews;while((a=a.get("parentView"))){if(b[SC.guidFor(a)]){return a}}return null}});SC.Drag.mixin({start:function(b){var a=this.create(b);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.CheckboxView=SC.ButtonView.extend({classNames:["sc-checkbox-view","sc-checkbox-control"],ariaRole:"checkbox",themeName:null,renderDelegateName:"checkboxRenderDelegate",needsEllipsis:NO,acceptsFirstResponder:function(){if(SC.FOCUS_ALL_CONTROLS){return this.get("isEnabledInPane")}return NO}.property("isEnabledInPane"),_toggleValue:function(){var a=this.get("value")===this.get("toggleOnValue");this.set("value",a?this.get("toggleOffValue"):this.get("toggleOnValue"))},mouseDown:function(a){if(a.which&&a.which!==1){return false}if(!this.get("isEnabledInPane")){return YES}this.set("isActive",YES);this._isMouseDown=YES;if(a&&this.get("acceptsFirstResponder")){a.allowDefault()}return YES},mouseUp:function(a){if(!this.get("isEnabledInPane")){return YES}this.set("isActive",NO);this._isMouseDown=NO;if(this.get("buttonBehavior")!==SC.HOLD_BEHAVIOR){if(this.$().within(a.target)){this._toggleValue();this._action(a)}}return YES},keyDown:function(b){if(!this.get("isEnabledInPane")){return YES}if(b.which===9||b.keyCode===9){var a=b.shiftKey?this.get("previousValidKeyView"):this.get("nextValidKeyView");if(a){a.becomeFirstResponder()}else{b.allowDefault()}return YES}if(b.which===13||b.which===32){this._toggleValue();if(this.get("buttonBehavior")!==SC.HOLD_BEHAVIOR){if(this.$().within(b.target)){this._action(b)}}return YES}b.allowDefault();return NO},touchStart:function(a){return this.mouseDown(a)},touchEnd:function(a){return this.mouseUp(a)}});sc_require("mixins/collection_view_delegate");SC.DRAG_REORDER=16;SC.CollectionView=SC.View.extend(SC.ActionSupport,SC.CollectionViewDelegate,SC.CollectionContent,{_content:null,_cv_actionTimer:null,_cv_contentRangeObserver:null,_cv_selection:null,_pools:null,_sc_clearMouseJustDownTimer:null,_sc_isMouseDown:false,_sc_isMouseJustDown:false,_sc_itemViews:null,_TMP_DIFF1:SC.IndexSet.create(),_TMP_DIFF2:SC.IndexSet.create(),classNames:["sc-collection-view"],displayProperties:["isActive"],renderDelegateName:"collectionRenderDelegate",ACTION_DELAY:200,useFastPath:NO,content:null,contentBindingDefault:SC.Binding.multiple(),length:0,nowShowing:function(){var a=this.get("clippingFrame");return this.computeNowShowing(a)}.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.View,contentExampleViewKey:null,groupExampleView:null,contentGroupExampleViewKey:null,action:null,target:null,rightIconAction:null,rightIconTarget:null,contentValueKey:null,acceptsFirstResponder:NO,isActive:NO,calculatedHeight:0,calculatedWidth:0,adjustLayout:function(){var a=this.computeLayout();if(a){this.adjust(a)}},computeLayout:function(){return null},layoutForContentIndex:function(a){return null},allContentIndexes:function(){return SC.IndexSet.create(0,this.get("length")).freeze()}.property("length").cacheable(),contentIndexesInRect:function(a){return null},computeNowShowing:function(d){var c=this.contentIndexesInRect(d);if(!c){c=this.get("allContentIndexes")}else{var b=this.get("length"),a=c.get("max");if(a>b){c=c.copy().remove(b,a-b).freeze()}}return c},showInsertionPoint:function(a,b){},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(),contentRangeDidChange:function(d,b,c,a){if(!b&&(c==="[]")){this.notifyPropertyChange("_contentGroupIndexes");this.reload(a)}else{this.contentPropertyDidChange(b,c,a)}},contentPropertyDidChange:function(c,b,a){},updateContentRangeObserver:function(){var d=this.get("nowShowing"),a=this._cv_contentRangeObserver,c=this.get("content");if(!c){return}if(a){c.updateRangeObserver(a,d)}else{var b=this.contentRangeDidChange;a=c.addRangeObserver(d,this,b,null);this._cv_contentRangeObserver=a}},removeContentRangeObserver:function(){var b=this.get("content"),a=this._cv_contentRangeObserver;if(a){if(b){b.removeRangeObserver(a)}this._cv_contentRangeObserver=null}},contentLengthDidChange:function(){var a=this.get("content");this.set("length",a?a.get("length"):0);this.invokeOnce(this.adjustLayout)},_cv_contentDidChange:function(){var c=this.get("content"),b=this.contentLengthDidChange;if(c===this._content){return}this.removeContentRangeObserver();if(this._content){this._content.removeObserver("length",this,b)}if(this._pools){for(var a in this._pools){this._pools[a].invoke("destroy")}this._pools=null}this._content=c;if(c){c.addObserver("length",this,b)}this.contentLengthDidChange();this.contentRangeDidChange(c,null,"[]",null)}.observes("content"),_invalidIndexes:NO,_isEnabledDidChange:function(){this.reload()}.observes("isEnabled","isEditable","canEditContent","canReorderContent","canDeleteContent"),reload:function(a){var c=this._invalidIndexes,b;if(a&&c!==YES){if(c){c.add(a)}else{c=this._invalidIndexes=a.clone()}b=this.get("length");if(b>1&&c.max===b){c.add(b-2)}}else{this._invalidIndexes=YES}if(this.get("isVisibleInWindow")){this.invokeOnce(this.reloadIfNeeded)}return this},reloadIfNeeded:function(){var f=this._invalidIndexes;if(!f||!this.get("isVisibleInWindow")){return this}this._invalidIndexes=NO;var b,d,e=this.get("nowShowing"),c=this._sc_itemViews||[],a;if(f.isIndexSet&&f.contains(e)){f=YES}if(f.isIndexSet){f.forEach(function(g){d=c[g];if(d){this._removeItemView(d,g)}if(e.contains(g)){this.itemViewForContentIndex(g,YES)}},this)}else{for(a=0,b=c.length;a<b;a++){d=c?c[a]:null;if(d){this._removeItemView(d,a)}}e.forEach(function(g){this.itemViewForContentIndex(g,YES)},this)}return this},_TMP_ATTRS:{},_COLLECTION_CLASS_NAMES:["sc-collection-item","sc-item"],_GROUP_COLLECTION_CLASS_NAMES:["sc-collection-item","sc-group-item"],itemViewForContentIndex:function(g,d){var c,i;if(SC.none(g)||g<0||g>=this.get("length")){return null}i=this._sc_itemViews;if(!i){i=this._sc_itemViews=[]}c=i[g];if(c){if(d){c.destroy();c=null}else{return c}}var h,f=this.get("containerView")||this,a,b,e;h=this._attrsForContentIndex(g);a=this._exampleViewForContentIndex(g);e=a.prototype;if(SC.none(e.isReusable)||e.isReusable){b=this._poolForExampleView(a);if(b.length>0){c=b.shift();this._reconfigureItemView(c,h);if(c.awakeFromPool){c.awakeFromPool(this)}if(!c.get("_isRendered")){c.invokeOnce(c._doRender)}}}if(!c){c=this.createItemView(a,g,h);f.insertBefore(c,null)}i[g]=c;return c},itemViewForContentObject:function(a){var b=this.get("content");if(!b){return null}var c=b.indexOf(a);if(c===-1){return null}return this.itemViewForContentIndex(c)},_TMP_LAYERID:[],createItemView:function(c,a,b){return c.create(b)},layerIdFor:function(a){var b=this._TMP_LAYERID;b[0]=this.get("layerId");b[1]=a;return b.join("-")},contentIndexForLayerId:function(c){if(!c||!(c=c.toString())){return null}var b=this.get("layerId")+"-";if((c.length<=b.length)||(c.indexOf(b)!==0)){return null}var a=Number(c.slice(c.lastIndexOf("-")+1));return isNaN(a)?null:a},itemViewForEvent:function(a){var b=this.getPath("pane.rootResponder");if(!b){return null}var d=a.target,c=this.get("layer"),f=null,e;while(d&&d!==document&&d!==c){e=d?SC.$(d).attr("id"):null;if(e&&(f=this.contentIndexForLayerId(e))!==null){break}d=d.parentNode}if(f===null||(d===c)){d=c=null;return null}if(f>=this.get("length")){throw new Error("layout for item view %@ was found when item view does not exist (%@)".fmt(e,this))}return this.itemViewForContentIndex(f)},expand:function(b){if(!b){return this}var a=this.get("contentDelegate"),c=this.get("content");b.forEach(function(d){var e=a.contentIndexDisclosureState(this,c,d);if(e===SC.BRANCH_CLOSED){a.contentIndexExpand(this,c,d)}},this);return this},collapse:function(b){if(!b){return this}var a=this.get("contentDelegate"),c=this.get("content");b.forEach(function(d){var e=a.contentIndexDisclosureState(this,c,d);if(e===SC.BRANCH_OPEN){a.contentIndexCollapse(this,c,d)}},this);return this},_cv_selectionDidChange:function(){var c=this.get("selection"),b=this._cv_selection,a=this._cv_selectionContentDidChange;if(c===b){return}if(b){b.removeObserver("[]",this,a)}if(c){c.addObserver("[]",this,a)}this._cv_selection=c;this._cv_selectionContentDidChange()}.observes("selection"),_cv_selectionContentDidChange:function(){var c=this.get("selection"),b=this._cv_selindexes,a=this.get("content"),d;this._cv_selindexes=c?c.frozenCopy():null;if(b){b=b.indexSetForSource(a)}if(c){c=c.indexSetForSource(a)}if(c&&b){d=c.without(b).add(b.without(c))}else{d=c||b}if(d&&d.get("length")>0){this.reloadSelectionIndexes(d)}},_invalidSelection:NO,reloadSelectionIndexes:function(a){var b=this._invalidSelection;if(a&&(b!==YES)){if(b){b.add(a)}else{b=this._invalidSelection=a.copy()}}else{this._invalidSelection=YES}if(this.get("isVisibleInWindow")){this.invokeOnce(this.reloadSelectionIndexesIfNeeded)}return this},reloadSelectionIndexesIfNeeded:function(){var e=this._invalidSelection;if(!e||!this.get("isVisibleInWindow")){return this}var d=this.get("nowShowing"),b=this._invalidIndexes,a=this.get("content"),c=this.get("selection");this._invalidSelection=NO;if(b===YES||!d){return this}if(e===YES){e=d}if(b&&b.isIndexSet){e=e.without(b)}e.forEach(function(f){if(!d.contains(f)){return}var g=this.itemViewForContentIndex(f,NO);if(g){g.set("isSelected",c?c.contains(a,f):NO)}},this);return this},select:function(c,f){var d=this.get("content"),a=this.get("selectionDelegate"),b=this.get("_contentGroupIndexes"),e;if(!this.get("isSelectable")||!this.get("isEnabledInPane")){return this}if(SC.typeOf(c)===SC.T_NUMBER){c=SC.IndexSet.create(c,1)}if(c&&c.get("length")>0){if(b&&b.get("length")>0){c=c.copy().remove(b)}c=a.collectionViewShouldSelectIndexes(this,c,f);if(!c||c.get("length")===0){return this}}else{c=null}if(f&&(e=this.get("selection"))){e=e.copy()}else{e=SC.SelectionSet.create()}if(c&&c.get("length")>0){if(c.get("length")===1&&!this.get("allowDuplicateItems")){e.addObject(d.objectAt(c.get("firstObject")))}else{e.add(d,c)}}e=a.collectionViewSelectionForProposedSelection(this,e);if(!e){e=SC.SelectionSet.create()}this._selectionAnchor=null;this.set("selection",e.freeze());return this},deselect:function(b){var d=this.get("selection"),c=this.get("content"),a=this.get("selectionDelegate");if(!this.get("isSelectable")||!this.get("isEnabledInPane")){return this}if(!d||d.get("length")===0){return this}if(SC.typeOf(b)===SC.T_NUMBER){b=SC.IndexSet.create(b,1)}b=a.collectionViewShouldDeselectIndexes(this,b);if(!b||b.get("length")===0){return this}d=d.copy().remove(c,b);d=a.collectionViewSelectionForProposedSelection(this,d);if(!d){d=SC.SelectionSet.create()}this.set("selection",d.freeze());return this},_findNextSelectableItemFromIndex:function(b,d){var h=this.get("length"),c=SC.IndexSet.create(),a=this.get("selectionDelegate"),f=this.get("_contentGroupIndexes"),e,g;if(!f&&(a.collectionViewShouldSelectIndexes===this.collectionViewShouldSelectIndexes)){return b}while(b<h){if(!f||!f.contains(b)){c.add(b);e=a.collectionViewShouldSelectIndexes(this,c);if(e&&e.get("length")>=1){return b}c.remove(b)}b++}if(d===undefined){g=this.get("selection");d=g?g.get("max"):-1}return d},_findPreviousSelectableItemFromIndex:function(b,g){var c=SC.IndexSet.create(),a=this.get("selectionDelegate"),e=this.get("_contentGroupIndexes"),d;if(SC.none(b)){b=-1}if(!e&&(a.collectionViewShouldSelectIndexes===this.collectionViewShouldSelectIndexes)){return b}while(b>=0){if(!e||!e.contains(b)){c.add(b);d=a.collectionViewShouldSelectIndexes(this,c);if(d&&d.get("length")>=1){return b}c.remove(b)}b--}if(g===undefined){var f=this.get("selection");g=f?f.get("min"):-1}if(SC.none(g)){g=-1}return g},selectPreviousItem:function(h,b){if(SC.none(b)){b=1}if(SC.none(h)){h=false}var f=this.get("selection"),e=this.get("content");if(f){f=f.indexSetForSource(e)}var g=f?f.get("min"):-1,a=f?f.get("max")-1:-1,d=this._selectionAnchor;if(SC.none(d)){d=g}if(h){if(a>d){a=a-b}else{g=this._findPreviousSelectableItemFromIndex(g-b)}if(SC.none(g)||(g<0)){g=0}if(!e.objectAt(g)){g=f?f.get("min"):-1}if(a<g){a=g}}else{g=this._findPreviousSelectableItemFromIndex(g-b);if(SC.none(g)||(g<0)){g=0}if(!e.objectAt(g)){g=f?f.get("min"):-1}a=g;d=null}var c=g;f=SC.IndexSet.create(g,a+1-g);this.scrollToContentIndex(c);this.select(f);this._selectionAnchor=d;return this},selectNextItem:function(h,i){if(SC.none(i)){i=1}if(SC.none(h)){h=false}var b=this.get("selection"),g=this.get("content");if(b){b=b.indexSetForSource(g)}var a=b?b.get("min"):-1,d=b?b.get("max")-1:-1,e=this._selectionAnchor,c=this.get("length");if(SC.none(e)){e=a}if(h){if(a<e){a=a+i}else{d=this._findNextSelectableItemFromIndex(d+i,d)}if(d>=c){d=c-1}if(!g.objectAt(d)){d=b?b.get("max")-1:-1}if(a>d){a=d}}else{d=this._findNextSelectableItemFromIndex(d+i,d);if(d>=c){d=c-1}if(!g.objectAt(d)){d=b?b.get("max")-1:-1}a=d;e=null}var f=d;b=SC.IndexSet.create(a,d-a+1);this.scrollToContentIndex(f);this.select(b);this._selectionAnchor=e;return this},deleteSelection:function(){if(!this.get("isEditable")||!this.get("canDeleteContent")){return NO}var d=this.get("selection"),c=this.get("content"),a=this.get("selectionDelegate"),b=d&&c?d.indexSetForSource(c):null;if(!c||!b||b.get("length")===0){return NO}b=a.collectionViewShouldDeleteIndexes(this,b);if(!b||b.get("length")===0){return NO}a.collectionViewDeleteContent(this,this.get("content"),b);return YES},scrollToContentIndex:function(b){var a=this.itemViewForContentIndex(b);if(a){this.scrollToItemView(a)}return this},scrollToItemView:function(a){if(a){a.scrollToVisible()}return this},keyDown:function(a){var b=this.interpretKeyEvents(a);return !b?NO:b},keyUp:function(){return true},insertText:function(b,a){if(b===" "){var c=this.get("selection");if(c&&c.get("length")>0){this.invokeLater(this._cv_action,0,null,a)}return YES}else{return NO}},selectAll:function(b){var c=this.get("content"),a=this.delegateFor("allowsMultipleSelection",this.get("delegate"),c);if(a&&a.get("allowsMultipleSelection")){var d=c?SC.IndexSet.create(0,c.get("length")):null;this.select(d,NO)}return YES},deselectAll:function(){var b=this.get("content"),a=this.delegateFor("allowsEmptySelection",this.get("delegate"),b);if(a&&a.get("allowsEmptySelection")){var c=b?SC.IndexSet.create(0,b.get("length")):null;this.deselect(c,NO)}return YES},deleteBackward:function(a){return this.deleteSelection()},deleteForward:function(a){return this.deleteSelection()},moveDown:function(b,a){this.selectNextItem(false,this.get("itemsPerRow")||1);this._cv_performSelectAction(null,a,this.ACTION_DELAY);return true},moveUp:function(b,a){this.selectPreviousItem(false,this.get("itemsPerRow")||1);this._cv_performSelectAction(null,a,this.ACTION_DELAY);return true},moveLeft:function(k){if(k.ctrlKey||k.metaKey){return NO}if((this.get("itemsPerRow")||1)>1){this.selectPreviousItem(false,1);this._cv_performSelectAction(null,k,this.ACTION_DELAY)}else{var c=this.get("selection"),i=this.get("content"),g=c?c.indexSetForSource(i):null;if(g){var l,f=false,h;if(g.get("length")===1){h=g.get("firstObject");l=this.get("contentDelegate");var b=l.contentIndexDisclosureState(this,i,h);if(b!==SC.BRANCH_OPEN){f=true}}if(f){var a=l.contentIndexOutlineLevel(this,i,h)-1;if(a>=0){var e=-1;while(e<0){var d=this._findPreviousSelectableItemFromIndex(h-1);if(d<0){return false}h=d;var j=l.contentIndexOutlineLevel(this,i,h);if(j===a){e=d}}if(e!==-1){this.select(h)}}}else{this.collapse(g)}}}return true},moveRight:function(a){if(a.ctrlKey||a.metaKey){return NO}if((this.get("itemsPerRow")||1)>1){this.selectNextItem(false,1);this._cv_performSelectAction(null,a,this.ACTION_DELAY)}else{var d=this.get("selection"),c=this.get("content"),b=d?d.indexSetForSource(c):null;if(b){this.expand(b)}}return true},moveDownAndModifySelection:function(c,b){var d=this.get("content"),a=this.delegateFor("allowsMultipleSelection",this.get("delegate"),d);if(a&&a.get("allowsMultipleSelection")){this.selectNextItem(true,this.get("itemsPerRow")||1);this._cv_performSelectAction(null,b,this.ACTION_DELAY)}return true},moveUpAndModifySelection:function(c,b){var d=this.get("content"),a=this.delegateFor("allowsMultipleSelection",this.get("delegate"),d);if(a&&a.get("allowsMultipleSelection")){this.selectPreviousItem(true,this.get("itemsPerRow")||1);this._cv_performSelectAction(null,b,this.ACTION_DELAY)}return true},moveLeftAndModifySelection:function(b,a){if((this.get("itemsPerRow")||1)>1){this.selectPreviousItem(true,1);this._cv_performSelectAction(null,a,this.ACTION_DELAY)}return true},moveRightAndModifySelection:function(b,a){if((this.get("itemsPerRow")||1)>1){this.selectNextItem(true,1);this._cv_performSelectAction(null,a,this.ACTION_DELAY)}return true},insertNewline:function(c,i){var d=this.get("isEditable")&&this.get("canEditContent"),a=false,b,e,g,h,f;if(d){b=this.get("selection");e=this.get("content");if(b&&b.get("length")===1){g=b.indexSetForSource(e);h=g?g.get("min"):-1;f=this.itemViewForContentIndex(h);a=f&&SC.typeOf(f.beginEditing)===SC.T_FUNCTION}}if(a){this.scrollToContentIndex(h);f.beginEditing()}else{this.invokeLater(this._cv_action,0,f,null)}return YES},insertTab:function(b){var a=this.get("nextValidKeyView");if(a){a.becomeFirstResponder()}else{b.allowDefault()}return YES},insertBacktab:function(b){var a=this.get("previousValidKeyView");if(a){a.becomeFirstResponder()}else{b.allowDefault()}return YES},doubleClick:function(c){var b=this.get("isEnabledInPane"),e=false;if(b){var d=this.get("action");if(d){var a=this.itemViewForEvent(c);this._cv_performSelectAction(a,c,0,c.clickCount);e=true}}return e},mouseDown:function(m){var g=this.get("isEnabledInPane"),e=this.get("isSelectable"),h=false;if(g&&e){var j=this.get("content");h=true;if(j){var k=this.itemViewForEvent(m),l=j.get("allowsMultipleSelection"),i=false,b,a,f;this.becomeFirstResponder();f=k?k.get("contentIndex"):-1;if(this.get("useToggleSelection")){if(this.get("selectOnMouseDown")&&k){b=this.get("selection");a=b&&b.contains(j,f,1);if(a){this.deselect(f)}else{if(!l){this.select(f,false);i=true}else{this.select(f,true);i=true}}}}else{var c,d,n;if(!k){if(this.get("allowDeselectAll")){this.select(null,false)}}else{b=this.get("selection");if(b){b=b.indexSetForSource(j)}c=this.mouseDownInfo={event:m,itemView:k,contentIndex:f,at:Date.now()};a=b?b.contains(f):NO;c.modifierKeyPressed=n=m.ctrlKey||m.metaKey;if(n&&a){c.shouldDeselect=f>=0}else{if(m.shiftKey&&b&&b.get("length")>0&&l){b=this._findSelectionExtendedByShift(b,f);d=this._selectionAnchor;this.select(b);i=true;this._selectionAnchor=d}else{if(!n&&a){c.shouldReselect=f>=0}else{if((m.shiftKey||n)&&!l){this.select(null,false);i=true}if(this.get("selectOnMouseDown")){this.select(f,n);i=true}else{c.shouldSelect=f>=0}}}}c.previousContentIndex=f}}if(i&&this.get("actOnSelect")){this._cv_performSelectAction(k,m)}}}if(h){this._sc_isMouseDown=true}return h},mouseUp:function(l){var g=this.get("isEnabledInPane"),e=this.get("isSelectable");if(g&&e){var i=this.get("content");if(i){var j=this.itemViewForEvent(l),d=this.mouseDownInfo,h=false,c,b,f;f=j?j.get("contentIndex"):-1;if(this.get("useToggleSelection")){if(!this.get("selectOnMouseDown")&&j){var k=i.get("allowsMultipleSelection");c=this.get("selection");b=c&&c.contains(i,f,1);if(b){this.deselect(f)}else{if(!k){this.select(f,false);h=true}else{this.select(f,true);h=true}}}}else{if(d){var m=d.contentIndex;if(d.shouldSelect){this.select(m,d.modifierKeyPressed);h=true}if(d.shouldDeselect){this.deselect(m)}if(d.shouldReselect){var a=this.get("isEditable")&&this.get("canEditContent");if(a){c=this.get("selection");a=c&&(c.get("length")===1)}if(a){j=this.itemViewForContentIndex(m);a=j&&(!j.contentHitTest||j.contentHitTest(l));a=(a&&j.beginEditing)?j.beginEditing():NO}if(!a){if(this._cv_reselectTimer){this._cv_reselectTimer.invalidate()}this._cv_reselectTimer=this.invokeLater(this.select,300,m,false)}}this._cleanupMouseDown()}}if(h&&this.get("actOnSelect")){this._cv_performSelectAction(j,l)}}this._sc_isMouseJustDown=true;this._sc_clearMouseJustDownTimer=this.invokeLater(this._sc_clearMouseJustDown,250)}this._sc_isMouseDown=false;return false},_cleanupMouseDown:function(){var b=this.mouseDownInfo,a;if(b){for(a in b){if(!b.hasOwnProperty(a)){continue}delete b[a]}}this.mouseDownInfo=null},mouseMoved:function(c){var a=this.itemViewForEvent(c),b=this._lastHoveredItem;if(a!==b){if(b&&b.mouseExited){b.mouseExited(c)}if(a&&a.mouseEntered){a.mouseEntered(c)}}this._lastHoveredItem=a;if(a&&a.mouseMoved){a.mouseMoved(c)}return YES},mouseExited:function(b){var a=this._lastHoveredItem;this._lastHoveredItem=null;if(a&&a.mouseExited){a.mouseExited(b)}return YES},mouseWheel:function(a){return this._sc_isMouseDown||this._sc_isMouseJustDown},touchStart:function(d,a){var b=this.itemViewForEvent(d),c=b?b.get("contentIndex"):-1;if(!this.get("isEnabledInPane")){return c>-1}this.becomeFirstResponder();this._touchSelectedView=b;if(!this.get("useToggleSelection")){if(b&&!b.get("isSelected")){b.set("isSelected",YES)}}return YES},touchesDragged:function(a,b){b.forEach(function(c){if(Math.abs(c.pageX-c.startX)>5||Math.abs(c.pageY-c.startY)>5){c.makeTouchResponder(c.nextTouchResponder)}},this)},touchEnd:function(g){var d=this.get("content"),c=this._touchSelectedView,f=c?c.get("contentIndex"):-1,a=NO,e,b;if(!this.get("isEnabledInPane")){return f>-1}if(f>-1){if(this.get("useToggleSelection")){e=this.get("selection");a=e&&e.contains(d,f,1);b=!a}else{b=true}if(b){this.select(f,NO);this._cv_performSelectAction(c,g,0)}else{this.deselect(f)}}this._touchSelectedView=null},touchCancelled:function(a){if(this._touchSelectedView){this._touchSelectedView.set("isSelected",NO);this._touchSelectedView=null}},_findSelectionExtendedByShift:function(d,e){if(!d||d.get("length")===0){return SC.IndexSet.create(e)}var c=d.get("min"),a=d.get("max")-1,b=this._selectionAnchor;if(SC.none(b)){b=-1}if(e<c){c=e;if(b<0){this._selectionAnchor=b=a}}else{if(e>a){a=e;if(b<0){this._selectionAnchor=b=c}}else{if(e>=c&&e<=a){if(b<0){this._selectionAnchor=b=c}if(e===b){c=a=e}else{if(e>b){c=b;a=e}else{if(e<b){c=e;a=b}}}}}}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(h){var i=this.get("selectionDelegate"),e=this.get("content"),a=this.get("selection"),c=this.mouseDownInfo,f=this.get("_contentGroupIndexes"),d,b,g;if(!c||c.contentIndex<0){return YES}if((Date.now()-c.at)<123){return YES}if(this.get("isEditable")&&i.collectionViewShouldBeginDrag(this)){if(!this.get("selectOnMouseDown")){d=SC.IndexSet.create(c.contentIndex)}else{d=a?a.indexSetForSource(e):null}if(d&&f&&f.get("length")>0){d=d.copy().remove(f);if(d.get("length")===0){d=null}else{d.freeze()}}if(!d){return YES}else{d=d.frozenCopy()}d={content:e,indexes:d};this.set("dragContent",d);b=this.get("dragDataTypes");if(b&&b.get("length")>0){g=i.collectionViewDragViewFor(this,d.indexes);if(!g){g=this._cv_dragViewFor(d.indexes)}SC.Drag.start({event:c.event,source:this,dragView:g,ghost:NO,ghostActsLikeCursor:i.ghostActsLikeCursor,slideBack:YES,dataSource:this});this._cleanupMouseDown();this._lastInsertionIndex=null}else{this.set("dragContent",null)}return YES}},_cv_dragViewFor:function(f){var c=this.get("nowShowing").without(f),d=this.get("layer").cloneNode(false),b=SC.View.create({layer:d,parentView:this}),a=0,e;c=this.get("nowShowing").without(c);SC.$(d).css("backgroundColor","transparent").css("border","none").css("top",0).css("left",0);c.forEach(function(j){var o=this.itemViewForContentIndex(j),g,l,m;if(o){g=o.get("isSelected");o.set("isSelected",NO);o.updateLayerIfNeeded();l=o.get("layer");if(l){m=l.cloneNode(true);var p=o.$().find("canvas");if(p){var h=$(m).find("canvas"),n=p.length,k,q;for(j=0;j<n;j++){k=p[j];q=h[j];q.height=k.height;q.width=k.width;q.getContext("2d").drawImage(k,0,0)}}}o.set("isSelected",g);o.updateLayerIfNeeded()}if(m){d.appendChild(m);e=o.get("layout");if(e.height+e.top>a){a=e.height+e.top}}m=null},this);b.set("layout",{height:a});d=null;return b},dragDataTypes:function(){var a=this.get("selectionDelegate"),b=a.collectionViewDragDataTypes(this),c;if(this.get("canReorderContent")){b=b?b.copy():[];c=this.get("reorderDataType");if(b.indexOf(c)<0){b.push(c)}}return b?b:[]}.property(),dragDataForType:function(c,b){if(this.get("canReorderContent")){if(b===this.get("reorderDataType")){return this.get("dragContent")}}var a=this.get("selectionDelegate");return a.collectionViewDragDataForType(this,c,b)},computeDragOperations:function(c,b){var d=SC.DRAG_NONE,a=this.get("selectionDelegate");if(this.get("canReorderContent")){if(c.get("dataTypes").indexOf(this.get("reorderDataType"))>=0){d=SC.DRAG_REORDER}}d=a.collectionViewComputeDragOperations(this,c,d);if(d&SC.DRAG_REORDER){d=SC.DRAG_MOVE}return d},_computeDropOperationState:function(c,l,e){var g=this.convertFrameFromView(c.get("location"),null),k=SC.DROP_BEFORE,m=this.get("selectionDelegate"),d=this.get("canReorderContent"),n,h,a,i,f,b;var j=this.insertionIndexForLocation(g,SC.DROP_ON);if(SC.typeOf(j)===SC.T_ARRAY){k=j[1];j=j[0]}if(k===SC.DROP_ON){this.set("proposedInsertionIndex",j);this.set("proposedDropOperation",k);b=m.collectionViewValidateDragOperation(this,c,e,j,k);j=this.get("proposedInsertionIndex");k=this.get("proposedDropOperation");this._dropInsertionIndex=this._dropOperation=null;if(b!==SC.DRAG_NONE){return[j,k,b]}else{k=SC.DROP_BEFORE;j=this.insertionIndexForLocation(g,SC.DROP_BEFORE);if(SC.typeOf(j)===SC.T_ARRAY){k=j[1];j=j[0]}}}if((j>=0)&&d&&(k!==SC.DROP_ON)){n=c.dataForType(this.get("reorderDataType"));if(n){h=this.get("content");if(k===SC.DROP_BEFORE){a=n.indexes.contains(j-1);i=n.indexes.contains(j)}else{a=n.indexes.contains(j);i=n.indexes.contains(j-1)}if(a&&i){if(SC.none(this._lastInsertionIndex)){if(k===SC.DROP_BEFORE){while((j>=0)&&n.indexes.contains(j)){j--}}else{f=h?h.get("length"):0;while((j<f)&&n.indexes.contains(j)){j++}}}else{j=this._lastInsertionIndex}}if(j>=0){e=SC.DRAG_REORDER}}}this.set("proposedInsertionIndex",j);this.set("proposedDropOperation",k);e=m.collectionViewValidateDragOperation(this,c,e,j,k);j=this.get("proposedInsertionIndex");k=this.get("proposedDropOperation");this._dropInsertionIndex=this._dropOperation=null;return[j,k,e]},dragUpdated:function(f,b){var h=f.get("allowedDragOperations"),g=this._computeDropOperationState(f,b,h),a=g[0],c=g[1],e=g[2];if(e!==SC.DRAG_NONE){if((this._lastInsertionIndex!==a)||(this._lastDropOperation!==c)){var d=this.itemViewForContentIndex(a);this.showInsertionPoint(d,c)}this._lastInsertionIndex=a;this._lastDropOperation=c}else{this.hideInsertionPoint();this._lastInsertionIndex=this._lastDropOperation=null}return(e&SC.DRAG_REORDER)?SC.DRAG_MOVE:e},dragEnded:function(){this.hideInsertionPoint();this._lastInsertionIndex=this._lastDropOperation=null},acceptDragOperation:function(a,b){return YES},performDragOperation:function(e,g){var a=this._computeDropOperationState(e,null,g),k=a[0],j=a[1],h=a[2],l=this.get("selectionDelegate"),c,m,d,i,b,f;if(h&SC.DRAG_REORDER){g=(g&SC.DRAG_MOVE)?SC.DRAG_REORDER:SC.DRAG_NONE}else{g=g&h}if(g===SC.DRAG_NONE){return g}c=l.collectionViewPerformDragOperation(this,e,g,k,j);if((c===SC.DRAG_NONE)&&(g&SC.DRAG_REORDER)){d=e.dataForType(this.get("reorderDataType"));if(!d){return SC.DRAG_NONE}i=this.get("content");f=d.indexes;if(f.get("length")===1){if(((j===SC.DROP_BEFORE)||(j===SC.DROP_AFTER))&&(f.get("min")===k)){return SC.DRAG_MOVE}}i.beginPropertyChanges();m=[];b=0;d.indexes.forEach(function(n){m.push(i.objectAt(n-b));i.removeAt(n-b);b++;if(n<k){k--}},this);if(j===SC.DROP_AFTER){k++}i.replace(k,0,m,j);this.select(SC.IndexSet.create(k,m.length));i.endPropertyChanges();g=SC.DRAG_MOVE}return g},collectionViewShouldBeginDrag:function(a){return this.get("canReorderContent")},insertionIndexForLocation:function(a,b){return -1},_sc_clearMouseJustDown:function(){this._sc_isMouseJustDown=false},willShowInDocument:function(){if(this._invalidIndexes){this.invokeOnce(this.reloadIfNeeded)}if(this._invalidSelection){this.invokeOnce(this.reloadSelectionIndexesIfNeeded)}},didAppendToDocument:function(){if(this._invalidIndexes){this.invokeOnce(this.reloadIfNeeded)}if(this._invalidSelection){this.invokeOnce(this.reloadSelectionIndexesIfNeeded)}},collectionViewShouldSelectItem:function(a,b){return this.get("isSelectable")},_cv_nowShowingDidChange:function(){var b=this.get("nowShowing"),a=this._sccv_lastNowShowing,d,e,c;if(a!==b){if(a&&b){e=this._TMP_DIFF1.add(a).remove(b);c=this._TMP_DIFF2.add(b).remove(a);d=e.add(c)}else{d=a||b}}if(d&&d.get("length")>0){this._sccv_lastNowShowing=b?b.frozenCopy():null;this.updateContentRangeObserver();this.reload(d)}if(e){e.clear()}if(c){c.clear()}}.observes("nowShowing"),init:function(){arguments.callee.base.apply(this,arguments);if(this.get("canReorderContent")){this._cv_canReorderContentDidChange()}this._sccv_lastNowShowing=this.get("nowShowing").clone();if(this.content){this._cv_contentDidChange()}if(this.selection){this._cv_selectionDidChange()}this.adjustLayout()},destroy:function(){arguments.callee.base.apply(this,arguments);var a=this._content;if(a){a.removeObserver("length",this,this.contentLengthDidChange);this._content=null}var b=this._cv_selection;if(b){b.removeObserver("[]",this,this._cv_selectionContentDidChange);this._cv_selection=null}var c=this._cv_contentRangeObserver;if(c){if(a){a.removeRangeObserver(c)}this._cv_contentRangeObserver=null}},_cv_canReorderContentDidChange:function(){if(this.get("canReorderContent")){if(!this.get("isDropTarget")){this.set("isDropTarget",YES)}SC.Drag.addDropTarget(this)}}.observes("canReorderContent"),_cv_performSelectAction:function(b,d,c,a){var e;if(c===undefined){c=0}if(a===undefined){a=1}if((a>1)||this.get("actOnSelect")){if(this._cv_reselectTimer){this._cv_reselectTimer.invalidate()}e=this.get("selection");e=e?e.toArray():[];if(this._cv_actionTimer){this._cv_actionTimer.invalidate()}this._cv_actionTimer=this.invokeLater(this._cv_action,c,b,d,e)}},_cv_action:function(b,a,c){var d=this.get("action");this._cv_actionTimer=null;if(d){if(d&&(SC.typeOf(d)===SC.T_FUNCTION)){return this.action(b,a)}else{return this.fireAction(c)}}else{if(!b){return}else{if(SC.typeOf(b._action)===SC.T_FUNCTION){return b._action(a)}else{if(SC.typeOf(b.action)===SC.T_FUNCTION){return b.action(a)}}}}},_attrsForContentIndex:function(j){var k=this._TMP_ATTRS,l=this.get("contentDelegate"),g=this.get("content"),c=this._contentIndexIsGroup(j),m=this.get("isEditable")&&this.get("canEditContent"),b=this.get("isEditable")&&this.get("canReorderContent"),e=this.get("isEditable")&&this.get("canDeleteContent"),i=l.contentIndexIsEnabled(this,g,j),a=l.contentIndexIsSelected(this,g,j),h=l.contentIndexOutlineLevel(this,g,j),f=l.contentIndexDisclosureState(this,g,j);k.contentIndex=j;k.content=g.objectAt(j);k.disclosureState=f;k.isEnabled=i;k.isEditable=m;k.isReorderable=b;k.isDeletable=e;k.isSelected=a;k.isGroupView=c;k.layerId=this.layerIdFor(j);k.owner=k.displayDelegate=this;k.page=this.page;k.outlineLevel=h;k.isLast=j===g.get("length")-1;if(c){k.classNames=this._GROUP_COLLECTION_CLASS_NAMES}else{k.classNames=this._COLLECTION_CLASS_NAMES}var d=this.layoutForContentIndex(j);if(d){k.layout=d}else{delete k.layout}return k},_contentGroupIndexes:function(){return this.get("contentDelegate").contentGroupIndexes(this,this.get("content"))}.property("contentDelegate").cacheable(),_contentIndexIsGroup:function(a){var d=this.get("_contentGroupIndexes");if(d&&d.contains(a)){var b=this.get("contentDelegate"),c=this.get("content");return b.contentIndexIsGroup(this,c,a)}else{return false}},_exampleViewForContentIndex:function(b){var d,a,c=this.get("content"),e=c.objectAt(b);if(this._contentIndexIsGroup(b)){d=this.get("contentGroupExampleViewKey");if(d&&e){a=e.get(d)}if(!a){a=this.get("groupExampleView")||this.get("exampleView")}}else{d=this.get("contentExampleViewKey");if(d&&e){a=e.get(d)}if(!a){a=this.get("exampleView")}}return a},_poolForExampleView:function(a){var b=SC.guidFor(a);if(!this._pools){this._pools={}}if(!this._pools[b]){this._pools[b]=[]}return this._pools[b]},_poolLayoutForContentIndex:function(b){var a=this.layoutForContentIndex(b);if(a&&a.height){if(a.top){a.top=-a.height}else{a.bottom=-a.height}}else{if(a&&a.width){if(a.left){a.left=-a.width}else{a.right=-a.width}}}return a},_reconfigureItemView:function(c,b){c.beginPropertyChanges();c.set("content",b.content);c.set("contentIndex",b.contentIndex);c.set("isEnabled",b.isEnabled);c.set("isEditable",b.isEditable);c.set("isReorderable",b.isReorderable);c.set("isDeletable",b.isDeletable);c.set("isSelected",b.isSelected);c.set("layerId",b.layerId);c.set("outlineLevel",b.outlineLevel);c.set("disclosureState",b.disclosureState);c.set("isLast",b.isLast);if(b.layout){c.set("layout",b.layout)}var e=c.get("isGroupView"),a=b.isGroupView;if(e!==a){c.set("isGroupView",a);var f=c.get("classNames"),d=c.$();if(e&&!a){f.pushObject("sc-item");f.removeObject("sc-group-item");d.setClass({"sc-item":YES,"sc-group-item":NO})}else{f.removeObject("sc-item");f.pushObject("sc-group-item");d.setClass({"sc-item":NO,"sc-group-item":YES})}}c.endPropertyChanges()},_removeItemView:function(f,j){var d,g=this.get("content"),a,h,c,e,i,b=false;if(g&&f.get("content")===g.objectAt(j)){d=this._exampleViewForContentIndex(j);i=d.prototype;a=SC.none(i.isReusable)||i.isReusable;if(a){e=this._poolForExampleView(d);if(f.sleepInPool){f.sleepInPool(this)}e.push(f);c=this._poolLayoutForContentIndex(j);h=c&&(SC.none(i.isLayerReusable)||i.isLayerReusable);if(h){f.set("layout",c)}else{f.destroyLayer()}f.set("layerId",SC.generateGuid(null,"pool-"));b=true}}if(!b){f.destroy()}delete this._sc_itemViews[j]}});SC.DateFieldView=SC.TextFieldView.extend({value:null,showDate:YES,showTime:NO,allowNumericInput:YES,formatTime:"%I:%M %p",formatDate:"%d/%m/%Y",formatDateTime:"%d/%m/%Y %I:%M %p",_dtConstants:["%a","%b","%d","%H","%I","%j","%m","%M","%p","%S","%U","%W","%y","%Y"],_wtConstants:[3,3,2,2,2,3,2,2,2,2,2,2,2,4],activeSelection:0,format:function(){var a=this.get("showTime");var b=this.get("showDate");if(a===YES&&b===YES){return this.get("formatDateTime")}if(a===YES){return this.get("formatTime")}return this.get("formatDate")}.property("showTime","showDate","formatDateTime","formatDate","formatTime").cacheable(),validator:function(){return SC.Validator.DateTime.extend({format:this.get("format")})}.property("format").cacheable(),tabsSelections:function(){var f=[];var d=this.get("format");var i=this.get("_dtConstants");var b=this.get("_wtConstants");if(SC.empty(d)){throw new Error("The format string is empty, and must be a valid string.")}var g,j,c,e=0,a=0,h=0;while(e<d.length&&d.indexOf("%",e)!==-1){g=d.indexOf("%",e);j=d.substring(g,g+2);e=g+2;c=i.indexOf(j);if(c===-1){throw new Error("SC.DateFieldView: The format's key '%@' is not supported.".fmt(j))}a=a+g-h;f.push(SC.Object.create({key:j,textSelection:SC.TextSelection.create({start:a,end:a+b[c]})}));a=a+b[c];h=e}g=j=c=null;return f}.property("format").cacheable(),updateTextSelectionObserver:function(){var a=this.get("activeSelection");var b=this.get("tabsSelections");if(this.get("isEditing")){this.selection(null,b[a].get("textSelection"))}}.observes("activeSelection","value"),updateValue:function(b,c){var e=(c===0)?-1:1;var d=this.get("value"),a;switch(b){case"%a":case"%d":case"%j":this.set("value",d.advance({day:e}));break;case"%b":case"%m":this.set("value",d.advance({month:e}));break;case"%H":case"%I":this.set("value",d.advance({hour:e}));break;case"%M":this.set("value",d.advance({minute:e}));break;case"%p":a=d.get("hour")>=12?-12:12;this.set("value",d.advance({hour:a}));break;case"%S":this.set("value",d.advance({second:e}));break;case"%U":this.set("value",d.advance({week1:e}));break;case"%W":this.set("value",d.advance({week0:e}));break;case"%y":case"%Y":this.set("value",d.advance({year:e}));break}},_lastValue:null,_lastKey:null,_selectRootElement:function(){},keyDown:function(a){if(this.interpretKeyEvents(a)){a.stop();return YES}return arguments.callee.base.apply(this,arguments)},ctrl_a:function(){return YES},moveUp:function(b){var a=this.get("activeSelection");var c=this.get("tabsSelections");this.updateValue(c[a].get("key"),1);return YES},moveDown:function(b){var a=this.get("activeSelection");var c=this.get("tabsSelections");this.updateValue(c[a].get("key"),0);return YES},moveRight:function(a){var c=this.get("tabsSelections");var b=this.get("activeSelection")+1;if(b===c.length){b=0}this.set("activeSelection",b);return YES},moveLeft:function(a){var c=this.get("tabsSelections");var b=this.get("activeSelection")-1;if(b===-1){b=c.length-1}this.set("activeSelection",b);return YES},insertTab:function(a){var c=this.get("tabsSelections");var b=this.get("activeSelection")+1;if(b<c.length){this.set("activeSelection",b);return YES}return NO},insertBacktab:function(a){var b=this.get("activeSelection")-1;if(b!==-1){this.set("activeSelection",b);return YES}return NO},mouseUp:function(b){var c=arguments.callee.base.apply(this,arguments);var e=this.get("selection");if(SC.none(e)){this.set("activeSelection",0)}else{var h=e.get("start");var g=this.get("tabsSelections");var a=g.length,f;for(var d=0;d<a;d++){f=g[d].get("textSelection");if(h>=f.get("start")&&h<=f.get("end")){this.set("activeSelection",d)}}}return c},deleteBackward:function(a){return YES},deleteForward:function(a){return YES},_numericCharacters:["0","1","2","3","4","5","6","7","8","9"],_nonnumericCharacters:[" ","-","/",":"],insertText:function(e,l){if(this._nonnumericCharacters.contains(e)){this.moveRight()}if(this.get("allowNumericInput")&&this._numericCharacters.contains(e)){var c=this.get("activeSelection"),g=this.get("tabsSelections"),k=g[c].get("key");var j=this.get("value"),i=this._lastValue,b=2,d=0,h,k,a;switch(k){case"%Y":k="year";d=1000;h=9999;b=4;break;case"%y":k="year";h=99;break;case"%m":k="month";d=1;h=12;break;case"%d":k="day";d=1;h=j.advance({month:1}).adjust({day:0}).get("day");break;case"%H":k="hour";h=23;break;case"%I":k="hour";h=11;break;case"%M":k="minute";h=59;break;case"%S":k="second";h=59;break}if(SC.none(i)||this._lastKey!==k){i=j.get(k);i=(i<10?"0":"")+i}if(i.length>b){i=i.substr(-b)}i=i.slice(1)+e;a=parseInt(i,10);if(a<=h&&a>=d){var f={};f[k]=a;this.set("value",j.adjust(f,NO))}this._lastValue=i;this._lastKey=k}return YES}});SC.DisclosureView=SC.ButtonView.extend({classNames:["sc-disclosure-view"],renderDelegateName:"disclosureRenderDelegate",buttonBehavior:SC.TOGGLE_BEHAVIOR,toggleOnValue:YES,toggleOffValue:NO,valueBindingDefault:SC.Binding.bool(),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.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.InlineEditable,SC.Control,{classNames:["sc-list-item-view"],displayProperties:["disclosureState","escapeHTML","isDropTarget"],contentIndex:null,hasContentIcon:NO,hasContentRightIcon:NO,hasContentBranch:NO,contentCheckboxKey:null,icon:null,isDropTarget:NO,contentIconKey:null,rightIcon:null,contentRightIconKey:null,contentValueKey:null,escapeHTML:YES,contentUnreadCountKey:null,contentIsBranchKey:null,outlineIndent:16,outlineLevel:0,disclosureState:SC.LEAF_NODE,validator:null,contentKeys:{contentValueKey:"title",contentCheckboxKey:"checkbox",contentIconKey:"icon",contentRightIconKey:"rightIcon",contentUnreadCountKey:"count",contentIsBranchKey:"branch"},contentPropertyDidChange:function(){if(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(),inlineEditorDelegate:SC.InlineTextFieldDelegate,$label:function(){return this.$("label")},_isInsideElementWithClassName:function(e,a){var c=this.get("layer");if(!c){return NO}var d=SC.$(a.target);var b=NO;while(!b&&d.length>0&&(d[0]!==c)){if(d.hasClass(e)){b=YES}d=d.parent()}d=c=null;return b},_isInsideCheckbox:function(b){var a=this.displayDelegate;var c=this.getDelegateProperty("contentCheckboxKey",a);return c&&this._isInsideElementWithClassName("sc-checkbox-view",b)},_isInsideDisclosure:function(a){if(this.get("disclosureState")===SC.LEAF_NODE){return NO}return this._isInsideElementWithClassName("sc-disclosure-view",a)},_isInsideRightIcon:function(c){var b=this.displayDelegate;var a=this.getDelegateProperty("hasContentRightIcon",b)||!SC.none(this.rightIcon);return a&&this._isInsideElementWithClassName("right-icon",c)},mouseDown:function(a){if(a.which&&a.which!==1){return false}if(!this.get("contentIsEditable")){return NO}if(this._isInsideCheckbox(a)){this._addCheckboxActiveState();this._isMouseDownOnCheckbox=YES;this._isMouseInsideCheckbox=YES;return YES}else{if(this._isInsideDisclosure(a)){this._addDisclosureActiveState();this._isMouseDownOnDisclosure=YES;this._isMouseInsideDisclosure=YES;return YES}else{if(this._isInsideRightIcon(a)){this._addRightIconActiveState();this._isMouseDownOnRightIcon=YES;this._isMouseInsideRightIcon=YES;return YES}}}return NO},mouseUp:function(h){var c=NO,i,d,b,a,g,f;if(this._isMouseDownOnCheckbox){if(this._isInsideCheckbox(h)){i=this.displayDelegate;d=this.getDelegateProperty("contentCheckboxKey",i);b=this.get("content");if(b&&b.get){var e=b.get(d);e=(e===SC.MIXED_STATE)?YES:!e;b.set(d,e);this.displayDidChange()}}this._removeCheckboxActiveState();c=YES}else{if(this._isMouseDownOnDisclosure){if(this._isInsideDisclosure(h)){a=this.get("disclosureState");g=this.get("contentIndex");f=(!SC.none(g))?SC.IndexSet.create(g):null;i=this.get("displayDelegate");if(a===SC.BRANCH_OPEN){if(f&&i&&i.collapse){i.collapse(f)}else{this.set("disclosureState",SC.BRANCH_CLOSED)}this.displayDidChange()}else{if(a===SC.BRANCH_CLOSED){if(f&&i&&i.expand){i.expand(f)}else{this.set("disclosureState",SC.BRANCH_OPEN)}this.displayDidChange()}}}this._removeDisclosureActiveState();c=YES}else{if(this._isMouseDownOnRightIcon){this._removeRightIconActiveState();c=YES}}}this._isMouseInsideCheckbox=this._isMouseDownOnCheckbox=NO;this._isMouseDownOnDisclosure=this._isMouseInsideDisclosure=NO;this._isMouseInsideRightIcon=this._isMouseDownOnRightIcon=NO;return c},mouseMoved:function(a){if(this._isMouseDownOnCheckbox&&this._isInsideCheckbox(a)){this._addCheckboxActiveState();this._isMouseInsideCheckbox=YES}else{if(this._isMouseDownOnCheckbox){this._removeCheckboxActiveState();this._isMouseInsideCheckbox=NO}else{if(this._isMouseDownOnDisclosure&&this._isInsideDisclosure(a)){this._addDisclosureActiveState();this._isMouseInsideDisclosure=YES}else{if(this._isMouseDownOnDisclosure){this._removeDisclosureActiveState();this._isMouseInsideDisclosure=NO}else{if(this._isMouseDownOnRightIcon&&this._isInsideRightIcon(a)){this._addRightIconActiveState();this._isMouseInsideRightIcon=YES}else{if(this._isMouseDownOnRightIcon){this._removeRightIconActiveState();this._isMouseInsideRightIcon=NO}}}}}}return NO},touchStart:function(a){return this.mouseDown(a)},touchEnd:function(a){return this.mouseUp(a)},touchEntered:function(a){return this.mouseEntered(a)},touchExited:function(a){return this.mouseExited(a)},_addCheckboxActiveState:function(){if(this.get("isEnabled")){if(this._checkboxRenderDelegate){var a=this._checkboxRenderSource;a.set("isActive",YES);this._checkboxRenderDelegate.update(a,this.$(".sc-checkbox-view"))}else{this.$(".sc-checkbox-view").addClass("active")}}},_removeCheckboxActiveState:function(){if(this._checkboxRenderer){var a=this._checkboxRenderSource;a.set("isActive",NO);this._checkboxRenderDelegate.update(a,this.$(".sc-checkbox-view"))}else{this.$(".sc-checkbox-view").removeClass("active")}},_addDisclosureActiveState:function(){if(this.get("isEnabled")){if(this._disclosureRenderDelegate){var a=this._disclosureRenderSource;a.set("isActive",YES);this._disclosureRenderDelegate.update(a,this.$(".sc-disclosure-view"))}else{this.$(".sc-disclosure-view").addClass("active")}}},_removeDisclosureActiveState:function(){if(this._disclosureRenderer){var a=this._disclosureRenderSource;a.set("isActive",NO);this._disclosureRenderDelegate.update(a,this.$(".sc-disclosure-view"))}else{this.$(".sc-disclosure-view").addClass("active")}},_addRightIconActiveState:function(){this.$("img.right-icon").setClass("active",YES)},_removeRightIconActiveState:function(){this.$("img.right-icon").removeClass("active");var d=this.get("pane"),a=this.displayDelegate,c=this.getDelegateProperty("rightIconTarget",a),b=this.getDelegateProperty("rightIconAction",a);if(b&&d){d.rootResponder.sendAction(b,c,this,d)}},contentHitTest:function(b){var a=this.displayDelegate;var c=this.getDelegateProperty("contentValueKey",a);if(!c){return NO}var e=this.$label()[0];if(!e){return NO}var f=b.target,d=this.get("layer");while(f&&(f!==d)&&(f!==window)){if(f===e){return YES}f=f.parentNode}return NO},beginEditing:function(d,c){var f=this.$label(),e=this.get("parentView");if(c&&this.scrollToVisible()){var b=this.get("owner"),a=this.get("contentIndex");this.invokeLast(function(){var g=b.itemViewForContentIndex(a);if(g&&g.beginEditing){g.beginEditing(NO)}});return YES}else{if(!e||!f||f.get("length")===0){return NO}else{return d()}}}.enhance(),inlineEditorWillBeginEditing:function(i,d,m){var j=this.get("content"),o=this.get("displayDelegate"),e=this.getDelegateProperty("contentValueKey",o),b=this.$label(),a=this.get("validator"),h,n,g,r,k,l,q,p,c;n=(e&&j)?(j.get?j.get(e):j[e]):j;h=this.computeFrameWithParentFrame(null);l=this._oldLineHeight=b.css("lineHeight");r=b.css("fontSize");k=this.$().css("top");if(k){k=parseInt(k.substring(0,k.length-2),0)}else{k=0}p=0;if(r&&l){c=r*1.5;if(c<l){b.css({lineHeight:"1.5"});p=(l-c)/2}else{this._oldLineHeight=null}}b=b[0];g=SC.offset(b);h.x=g.x;h.y=g.y+k+p;h.height=b.offsetHeight;h.width=b.offsetWidth;q=this.get("escapeHTML");i.set({value:n,exampleFrame:h,exampleElement:b,multiline:NO,validator:a,escapeHTML:q})},inlineEditorShouldBeginEditing:function(a){return YES},inlineEditorDidBeginEditing:function(b,d,e,a){b(d,e,a);var c=this.$label();this._oldOpacity=c.css("opacity");c.css("opacity",0);if(this._oldLineHeight){c.css({lineHeight:this._oldLineHeight})}}.enhance(),inlineEditorDidCommitEditing:function(d,f,c){var e=this.get("content");var a=this.displayDelegate;var b=this.getDelegateProperty("contentValueKey",a);if(b&&e){if(e.set){e.set(b,f)}else{e[b]=f}}else{this.set("content",f)}this.displayDidChange();this._endEditing()},_endEditing:function(a){this.$label().css("opacity",this._oldOpacity);a()}.enhance(),isReusable:false,render:function(c,a){var f=this.get("content"),m=this.displayDelegate,b=this.get("outlineLevel"),e=this.get("outlineIndent"),l,j,i,n=[];n.push((this.get("contentIndex")%2===0)?"even":"odd");c.setClass("disabled",!this.get("isEnabled"));c.setClass("drop-target",this.get("isDropTarget"));i=c.begin("div").addClass("sc-outline");if(b>=0&&e>0){i.addStyle("left",e*(b+1))}j=this.get("disclosureState");if(j!==SC.LEAF_NODE){this.renderDisclosure(i,j);n.push("has-disclosure")}else{if(this._disclosureRenderSource){c.removeClass("has-disclosure");this._disclosureRenderSource.destroy();this._disclosureRenderSource=this._disclosureRenderDelegate=null}}l=this.getDelegateProperty("contentCheckboxKey",m);if(l){j=f?(f.get?f.get(l):f[l]):NO;if(j!==null){this.renderCheckbox(i,j);n.push("has-checkbox")}else{if(this._checkboxRenderSource){c.removeClass("has-checkbox");this._checkboxRenderSource.destroy();this._checkboxRenderSource=this._checkboxRenderDelegate=null}}}if(this.getDelegateProperty("hasContentIcon",m)){l=this.getDelegateProperty("contentIconKey",m);j=(l&&f)?(f.get?f.get(l):f[l]):null;if(j){this.renderIcon(i,j);n.push("has-icon")}}else{if(this.get("icon")){j=this.get("icon");this.renderIcon(i,j);n.push("has-icon")}}l=this.getDelegateProperty("contentValueKey",m);j=(l&&f)?(f.get?f.get(l):f[l]):f;if(j&&SC.typeOf(j)!==SC.T_STRING){j=j.toString()}if(this.get("escapeHTML")){j=SC.RenderContext.escapeHTML(j)}this.renderLabel(i,j);if(this.getDelegateProperty("hasContentRightIcon",m)){l=this.getDelegateProperty("contentRightIconKey",m);j=(l&&f)?(f.get?f.get(l):f[l]):null;if(j){this.renderRightIcon(i,j);n.push("has-right-icon")}}else{if(this.get("rightIcon")){j=this.get("rightIcon");this.renderRightIcon(i,j);n.push("has-right-icon")}}l=this.getDelegateProperty("contentUnreadCountKey",m);j=(l&&f)?(f.get?f.get(l):f[l]):null;if(!SC.none(j)&&(j!==0)){this.renderCount(i,j);var d=["zero","one","two","three","four","five"];var k=j.toString().length;var h=d.length;var g=(k<h)?d[k]:d[h-1];n.push("has-count",g+"-digit")}else{c.removeClass("has-count")}l=this.getDelegateProperty("listItemActionProperty",m);j=(l&&f)?(f.get?f.get(l):f[l]):null;if(j){this.renderAction(i,j);n.push("has-action")}if(this.getDelegateProperty("hasContentBranch",m)){l=this.getDelegateProperty("contentIsBranchKey",m);j=(l&&f)?(f.get?f.get(l):f[l]):NO;this.renderBranch(i,j);n.push("has-branch")}c.addClass(n);c=i.end()},renderDisclosure:function(a,d){var c=this.get("theme").disclosureRenderDelegate;a=a.begin("div").addClass("sc-disclosure-view").addClass("sc-regular-size").addClass(this.get("theme").classNames).addClass(c.get("className"));var b=this._disclosureRenderSource;if(!b){this._disclosureRenderSource=b=SC.Object.create({renderState:{},theme:this.get("theme")})}b.set("isSelected",d===SC.BRANCH_OPEN).set("isEnabled",this.get("isEnabled")).set("title","");c.render(b,a);a=a.end();this._disclosureRenderDelegate=c},renderCheckbox:function(a,d){var c=this.get("theme").checkboxRenderDelegate;a=a.begin("div").addClass("sc-checkbox-view").addClass("sc-regular-size").addClass(this.get("theme").classNames).addClass(c.get("className"));var b=this._checkboxRenderSource;if(!b){b=this._checkboxRenderSource=SC.Object.create({renderState:{},theme:this.get("theme")})}b.set("isSelected",d&&(d!==SC.MIXED_STATE)).set("isEnabled",this.get("isEnabled")&&this.get("contentIsEditable")).set("isActive",this._checkboxIsActive).set("title","");c.render(b,a);a=a.end();this._checkboxRenderDelegate=c},renderIcon:function(c,e){var b=null,d=null,a=[];if(e&&SC.ImageView.valueIsUrl(e)){b=e;d=""}else{d=e;b=SC.BLANK_IMAGE_URL}a.push(d,"icon");c.begin("img").addClass(a).setAttr("src",b).end()},renderLabel:function(b,a){b.push("<label>",a||"","</label>")},renderRightIcon:function(c,e){var b=null,d=null,a=[];if(e&&SC.ImageView.valueIsUrl(e)){b=e;d=""}else{d=e;b=SC.BLANK_IMAGE_URL}a.push("right-icon",d);c.begin("img").addClass(a).setAttr("src",b).end()},renderCount:function(a,b){a.push('<span class="count"><span class="inner">',b.toString(),"</span></span>")},renderAction:function(a,b){a.push('<img src="',SC.BLANK_IMAGE_URL,'" class="action" />')},renderBranch:function(c,b){var a=[];a.push("branch",b?"branch-visible":"branch-hidden");c.begin("span").addClass(a).push("&nbsp;").end()}});SC.ListItemView._deprecatedRenderWarningHasBeenIssued=false;sc_require("views/collection");sc_require("views/list_item");sc_require("mixins/collection_row_delegate");SC.ListView=SC.CollectionView.extend(SC.CollectionRowDelegate,{_sc_customRowSizeIndexes:null,_sc_insertionPointView:null,_sc_lastDropOnView:null,_sc_layout:null,_sc_sizeCache:null,_sc_offsetCache:null,_sc_rowDelegate:null,_sc_rowSize:null,classNames:["sc-list-view"],acceptsFirstResponder:true,exampleView:SC.ListItemView,layoutDirection:SC.LAYOUT_VERTICAL,showAlternatingRows:false,init:function(){arguments.callee.base.apply(this,arguments);this._sc_rowDelegateDidChange()},destroy:function(){arguments.callee.base.apply(this,arguments);var b=this._sc_rowDelegate;if(b){b.removeObserver("_sc_totalRowSize",this,this._sc_rowSizeDidChange);b.removeObserver("customRowSizeIndexes",this,this._sc_customRowSizeIndexesDidChange);this._sc_rowDelegate=null}var a=this._sc_customRowSizeIndexes;if(a){a.removeObserver("[]",this,this._sc_customRowSizeIndexesContentDidChange);this._sc_customRowSizeIndexes=null}},render:function(a,b){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(),_sc_rowDelegateDidChange:function(){var d=this._sc_rowDelegate,b=this.get("rowDelegate"),c=this._sc_rowSizeDidChange,a=this._sc_customRowSizeIndexesDidChange;if(d===b){return this}this._sc_rowDelegate=b;if(d){d.removeObserver("_sc_totalRowSize",this,c);d.removeObserver("customRowSizeIndexes",this,a)}b.addObserver("_sc_totalRowSize",this,c);b.addObserver("customRowSizeIndexes",this,a);this._sc_rowSizeDidChange()._sc_customRowSizeIndexesDidChange();return this}.observes("rowDelegate"),_sc_rowSizeDidChange:function(){var b=this.get("rowDelegate"),a=b.get("_sc_totalRowSize"),c;if(a===this._sc_rowSize){return this}this._sc_rowSize=a;c=SC.IndexSet.create(0,this.get("length"));this.rowSizeDidChangeForIndexes(c);return this},_sc_customRowSizeIndexesDidChange:function(){var a=this.get("rowDelegate"),b=a.get("customRowSizeIndexes"),d=this._sc_customRowSizeIndexes,c=this._sc_customRowSizeIndexesContentDidChange;if((b===d)||(d&&d.isEqual(b))){return this}if(d&&this._sc_isObservingCustomRowSizeIndexes){d.removeObserver("[]",this,c)}this._sc_isObservingCustomRowSizeIndexes=b;if(b&&!b.get("isFrozen")){b.addObserver("[]",this,c)}this._sc_customRowSizeIndexesContentDidChange();return this},_sc_customRowSizeIndexesContentDidChange:function(){var a=this.get("rowDelegate"),b=a.get("customRowSizeIndexes"),c=this._sc_customRowSizeIndexes,d;if(b&&c){d=b.copy().add(c)}else{d=b||c}this._sc_customRowSizeIndexes=b?b.frozenCopy():null;this.rowSizeDidChangeForIndexes(d);return this},rowOffsetForContentIndex:function(g){if(g===0){return 0}var i=this.get("rowDelegate"),c=i.get("_sc_totalRowSize"),e=i.get("rowSpacing"),d,b,a,h,f;d=g*c;if(e){d+=g*e}if(i.customRowSizeIndexes&&(b=i.get("customRowSizeIndexes"))){a=this._sc_offsetCache;if(!a){a=[];h=f=0;b.forEach(function(j){h+=this.rowSizeForContentIndex(j)-c;a[j+1]=h;f=j},this);this._sc_max=f+1;this._sc_offsetCache=a}h=a[g];if(h===undefined){h=a[g]=a[g-1];if(h===undefined){f=this._sc_max;if(g<f){f=b.indexBefore(g)+1}h=a[g]=a[f]||0}}d+=h}return d},rowHeightForContentIndex:null,rowSizeForContentIndex:function(a){var b=this.get("rowDelegate"),e,c,f,d;if(this.rowHeightForContentIndex){return this.rowHeightForContentIndex(a)}if(b.customRowSizeIndexes&&(d=b.get("customRowSizeIndexes"))){c=this._sc_sizeCache;if(!c){c=[];f=this.get("content");d.forEach(function(g){c[g]=b.contentIndexRowSize(this,f,g)},this);this._sc_sizeCache=c}e=c[a];if(e===undefined){e=b.get("_sc_totalRowSize")}}else{e=b.get("_sc_totalRowSize")}return e},rowHeightDidChangeForIndexes:function(a){return this.rowSizeDidChangeForIndexes(a)},rowSizeDidChangeForIndexes:function(b){var a=this.get("length");this._sc_sizeCache=this._sc_offsetCache=null;if(b&&b.isIndexSet){b=b.get("min")}this.reload(SC.IndexSet.create(b,a-b));this.invokeOnce("adjustLayout");return this},computeLayout:function(){var c=this._sc_layout,d=this.get("layoutDirection"),b=this.get("rowDelegate"),a=b.get("rowSpacing");if(!c){c=this._sc_layout={}}if(d===SC.LAYOUT_HORIZONTAL){c.width=Math.max(this.rowOffsetForContentIndex(this.get("length"))-a,0)}else{c.height=Math.max(this.rowOffsetForContentIndex(this.get("length"))-a,0)}return c},layoutForContentIndex:function(e){var a=this.get("rowDelegate"),d=this.get("layoutDirection"),c,b;c=this.rowOffsetForContentIndex(e);b=this.rowSizeForContentIndex(e)-a.get("rowPadding")*2;if(d===SC.LAYOUT_HORIZONTAL){return{left:c,width:b,top:0,bottom:0}}else{return{top:c,height:b,left:0,right:0}}},contentIndexesInRect:function(i){var j=this.get("rowDelegate"),b=j.get("_sc_totalRowSize"),h=j.get("rowSpacing"),f=b+h,e=this.get("layoutDirection"),g=this.get("length"),d,a,c,k,m,l;if(e===SC.LAYOUT_HORIZONTAL){k=SC.minX(i);m=SC.maxX(i);l=i.width||0}else{k=SC.minY(i);m=SC.maxY(i);l=i.height||0}a=(k-(k%f))/f;d=this.rowOffsetForContentIndex(a);while(a>0&&d>k){a--;d-=(this.rowSizeForContentIndex(a)+h)}d+=this.rowSizeForContentIndex(a);while(a<g&&d<=k){a++;d+=this.rowSizeForContentIndex(a)+h}if(a<0){a=0}if(a>=g){a=g}c=a+((l-(l%f))/f);if(c>g){c=g}d=this.rowOffsetForContentIndex(c);while(c>=a&&d>=m){c--;d-=(this.rowSizeForContentIndex(c)+h)}d+=this.rowSizeForContentIndex(c)+h;while(c<g&&d<m){c++;d+=this.rowSizeForContentIndex(c)+h}c++;if(c<a){c=a}if(c>g){c=g}return SC.IndexSet.create(a,c-a)},insertionPointView:SC.View.extend({classNames:"sc-list-insertion-point",layout:function(a,b){var c=this.get("layoutDirection");a=c===SC.LAYOUT_HORIZONTAL?"width":"height";if(b===undefined){b={}}if(SC.none(b[a])){b[a]=2}return b}.property("layoutDirection").cacheable(),layoutDirection:SC.LAYOUT_VERTICAL,render:function(a,b){if(b){a.push('<div class="anchor"></div>')}}}),showInsertionPoint:function(j,i){if(i&SC.DROP_ON){if(j&&j!==this._sc_lastDropOnView){this.hideInsertionPoint();j.set("isDropTarget",YES);this._sc_lastDropOnView=j}return}if(this._sc_lastDropOnView){this._sc_lastDropOnView.set("isDropTarget",NO);this._sc_lastDropOnView=null}var g=this.get("length"),f,a,b;if(j){f=j.get("contentIndex");a=j.get("outlineLevel");b=j.get("outlineIndent")}f=f||0;if(SC.none(a)){a=-1}b=b||0;if((f>=g)&&f>0){var e=this.itemViewForContentIndex(g-1);if(e.get("isGroupView")){a=1;b=e.get("outlineIndent")}}var h=this._sc_insertionPointView,d=this.get("layoutDirection");if(!h){h=this._sc_insertionPointView=this.get("insertionPointView").create({layoutDirection:d})}var l=j?j.get("layout"):{top:0,left:0},k,c;if(d===SC.LAYOUT_HORIZONTAL){c=l.left;if(i&SC.DROP_AFTER){c+=l.width}k=((a+1)*b)+12}else{k=l.top;if(i&SC.DROP_AFTER){k+=l.height}c=((a+1)*b)+12}h.adjust({top:k,left:c});this.appendChild(h)},hideInsertionPoint:function(){if(this._sc_lastDropOnView){this._sc_lastDropOnView.set("isDropTarget",NO);this._sc_lastDropOnView=null}var a=this._sc_insertionPointView;if(a){a.removeFromParent().destroy()}this._sc_insertionPointView=null},insertionIndexForLocation:function(f,j){var a={x:f.x,y:f.y,width:1,height:1},e=this.contentIndexesInRect(a),g=e.get("min"),h=this.get("length"),b,k,l,d,n,c,m,i;if(SC.none(g)||g<0){if((h===0)||(f.y<=this.rowOffsetForContentIndex(0))){g=0}else{if(f.y>=this.rowOffsetForContentIndex(h)){g=h}}}b=this.rowOffsetForContentIndex(g);k=b+this.rowSizeForContentIndex(g);if(j===SC.DROP_ON){if(this.get("isEditable")){l=Math.min(Math.floor((k-b)*0.2),5)}else{l=0}if(f.y>=(b+l)||f.y<=(k+l)){return[g,SC.DROP_ON]}}if(g>0){i=this.itemViewForContentIndex(g-1);m=(i?i.get("outlineIndent"):0)||0;c=i?i.get("outlineLevel"):0;if(g<h){i=this.itemViewForContentIndex(g);d=i?i.get("outlineLevel"):0;n=(i?i.get("outlineIndent"):0)||0;n*=d}else{d=i.get("isGroupView")?1:0;n=m*d}m*=c;if((d!==c)&&(n!==m)){if(m>n){g--;j=SC.DROP_AFTER}}}if(j===SC.DROP_BEFORE){i=(g<h)?this.itemViewForContentIndex(g):null;if(!i||i.get("isGroupView")){if(g>0){i=this.itemViewForContentIndex(g-1);if(!i.get("isGroupView")||(i.get("disclosureState")===SC.BRANCH_OPEN)){g=g-1;j=SC.DROP_AFTER}else{g=-1}}else{g=-1}}if(g<0){j=SC.DRAG_NONE}}return[g,j]}});sc_require("views/list");SC.GridView=SC.ListView.extend({_lastFrameWidth:null,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").width,b=this.get("columnWidth")||0;return(b<1)?1:Math.floor(a/b)}.property("columnWidth","_frameWidth").cacheable(),contentIndexesInRect:function(e){var d=this.get("rowHeight")||48,b=this.get("itemsPerRow"),c=Math.floor(SC.minY(e)/d)*b,a=Math.ceil(SC.maxY(e)/d)*b;return SC.IndexSet.create(c,a-c)},layoutForContentIndex:function(g){var d=this.get("rowHeight")||48,a=this.get("frame").width,b=this.get("itemsPerRow"),e=Math.floor(a/b),f=Math.floor(g/b),c=g-(b*f);if(a===0||b===0){return{}}return{left:c*e,top:f*d,height:d,width:e}},computeLayout:function(){var e=this.get("content"),d=(e)?e.get("length"):0,c=this.get("rowHeight")||48,a=this.get("itemsPerRow"),f=a?Math.ceil(d/a):0;var b=this._cachedLayoutHash;if(!b){b=this._cachedLayoutHash={}}b.height=f*c;return b},insertionPointClass:SC.View.extend({classNames:["sc-grid-insertion-point"],layout:{width:2},render:function(a,b){if(b){a.push('<div class="anchor"></div>')}}}),showInsertionPoint:function(c,g){if(!c){return}if(g&SC.DROP_ON){if(c!==this._lastDropOnView){this.hideInsertionPoint();c.set("isDropTarget",YES);this._lastDropOnView=c}}else{if(this._lastDropOnView){this._lastDropOnView.set("isDropTarget",NO);this._lastDropOnView=null}var b=this._insertionPointView,d=c.get("layout"),f,e;if(!b){b=this._insertionPointView=this.insertionPointClass.create()}f=d.top;e=d.left;if(g&SC.DROP_AFTER){e+=d.width}var a=d.height;b.adjust({top:f,left:e,height:a});this.appendChild(b)}},hideInsertionPoint:function(){if(this._lastDropOnView){this._lastDropOnView.set("isDropTarget",NO);this._lastDropOnView=null}var a=this._insertionPointView;if(a){a.removeFromParent().destroy()}this._insertionPointView=null},insertionIndexForLocation:function(d,j){var e=this.get("frame"),g=this.get("clippingFrame"),k=this.get("itemsPerRow"),a=Math.floor(e.width/k),m=Math.floor((d.y-e.y-g.y)/this.get("rowHeight"));var i=SC.DROP_BEFORE,c=(d.x-e.x-g.x),b=Math.floor(c/a),l=(c/a)-b;if(j===SC.DROP_ON){if(l>0.8){b++}if((l>=0.2)&&(l<=0.8)){i=SC.DROP_ON}}else{if(l>0.45){b++}}var h=(m*k)+b;return[h,i]},_gv_frameDidChange:function(){var e=this.get("frame"),c=this._lastFrameWidth,b=e.width;if(!SC.none(c)&&b!==c){var a,d=this.get("nowShowing");this.set("_frameWidth",b);d.forEach(function(f){a=this.itemViewForContentIndex(f);a.adjust(this.layoutForContentIndex(f))},this)}this._lastFrameWidth=b}.observes("frame"),_gv_itemsPerRowDidChange:function(){var a=this.get("itemsPerRow"),b=this._lastItemsPerRow||0;if(a!==b){this.invokeOnce("adjustLayout")}this._lastItemsPerRow=a}.observes("itemsPerRow")});SC.ImageButtonView=SC.ButtonView.extend({classNames:["sc-image-button-view"],themeName:null,renderDelegateName:"imageButtonRenderDelegate",displayProperties:["image"],image:null});SC.LinkView=SC.View.extend({ariaRole:"link",body:"",classNames:["sc-link-view"],displayBody:function(){var a=this.get("body");return(a&&this.get("localize"))?SC.String.loc(a):(a||"")}.property("body","localize").cacheable(),displayProperties:["displayBody","displayToolTip","fileName","href","hreflang"],fileName:null,escapeHTML:true,href:"#",language:null,hreflang:function(){var b=this.get("language"),a;a=b||SC.Locale.currentLocale.language;return a}.property("language","localize").cacheable(),ping:null,rel:null,tagName:"a",target:"_blank",type:null,render:function(b){var c=this.get("displayBody"),f=this.get("displayToolTip"),e=this.get("fileName"),k=this.get("escapeHTML"),a=this.get("href"),d=this.get("hreflang"),i=this.get("ping"),j=this.get("rel"),g=this.get("target"),h=this.get("type");if(f&&k){f=SC.RenderContext.escapeHTML(f)}b.setAttr({download:e,href:a,hreflang:d,ping:i?i.join(" "):null,rel:j?j.join(" "):null,target:g,title:f,type:h});if(c&&k){c=SC.RenderContext.escapeHTML(c)}b.push(c)},mouseDown:function(a){a.allowDefault();return true},mouseUp:function(a){a.allowDefault();return true},touchStart:function(a){a.allowDefault();return true},touchEnd:function(a){a.allowDefault();return true},update:function(c){var f=this.get("displayBody"),e=this.get("displayToolTip"),g=this.get("fileName"),d=this.get("escapeHTML"),b=this.get("href"),a=this.get("hreflang");c.attr("download",g);c.attr("href",b);c.attr("hreflang",a);if(e&&d){e=SC.RenderContext.escapeHTML(e)}c.attr("title",e);if(f&&d){f=SC.RenderContext.escapeHTML(f)}c.html(f)}});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.ToolbarView=SC.View.extend({classNames:["sc-toolbar-view"],ariaRole:"toolbar",renderDelegateName:"toolbarRenderDelegate",anchorLocation:null,layout:{left:0,right:0,height:32,zIndex:10},init:function(){if(this.anchorLocation){this.layout=SC.merge(this.layout,this.anchorLocation);switch(this.anchorLocation){case SC.ANCHOR_TOP:case SC.ANCHOR_TOP_LEFT:this.layout.borderBottom=1;break;case SC.ANCHOR_BOTTOM:case SC.ANCHOR_BOTTOM_RIGHT:this.layout.borderTop=1;break;default:}}arguments.callee.base.apply(this,arguments)}});sc_require("views/toolbar");SC.WorkspaceView=SC.View.extend({classNames:["sc-workspace-view"],displayProperties:["hasTopToolbar","hasBottomToolbar"],renderDelegateName:"workspaceRenderDelegate",topToolbar:SC.ToolbarView.extend(),bottomToolbar:null,contentView:SC.View.extend(),autoResizeToolbars:NO,defaultToolbarSize:44,largeToolbarSize:44,smallToolbarSize:30,toolbarSize:function(){if(!this.get("autoResizeToolbars")){return this.get("defaultToolbarSize")}if(this.get("orientation")===SC.HORIZONTAL_ORIENTATION){return this.get("smallToolbarSize")}return this.get("largeToolbarSize")}.property("autoHideMaster","orientation"),orientation:function(){var a=this.get("frame");if(a.width>a.height){return SC.HORIZONTAL_ORIENTATION}else{return SC.VERTICAL_ORIENTATION}}.property("frame").cacheable(),masterIsHidden:NO,masterIsHiddenDidChange:function(){var a,b=this.get("masterIsHidden");if(a=this.get("topToolbar")){a.set("masterIsHidden",b)}if(a=this.get("bottomToolbar")){a.set("masterIsHidden",b)}}.observes("masterIsHidden"),_scmd_tilePropertyDidChange:function(){this.invokeOnce("_scws_tile")}.observes("toolbarSize"),createChildViews:function(){arguments.callee.base.apply(this,arguments);var a=this.get("topToolbar");if(a){a=this.topToolbar=this.activeTopToolbar=this.createChildView(a);this.appendChild(a)}var c=this.get("bottomToolbar");if(c){c=this.bottomToolbar=this.activeBottomToolbar=this.createChildView(c);this.appendChild(c)}var b=this.get("contentView");b=this.contentView=this.activeContentView=this.createChildView(b);this.appendChild(b);this.invokeOnce("_scws_tile")},_scws_tile:function(){var b=0,e=0,a=this.get("topToolbar"),f=this.get("bottomToolbar"),d=this.get("contentView"),c=this.get("toolbarSize");if(a){a.set("layout",{left:0,right:0,top:0,height:c});b+=c}if(f){f.set("layout",{left:0,right:0,bottom:0,height:c});e+=c}this.contentView.set("layout",{left:0,right:0,top:b,bottom:e})},hasTopToolbar:function(){if(this.get("topToolbar")){return YES}return NO}.property("topToolbar").cacheable(),hasBottomToolbar:function(){if(this.get("bottomToolbar")){return YES}return NO}.property("bottomToolbar").cacheable(),childDidChange:function(){this._scws_tile()},activeTopToolbar:null,activeBottomToolbar:null,activeContentView:null,topToolbarDidChange:function(){var b=this.activeTopToolbar,a=this.get("topToolbar");if(b){if(b.createdByParent){container.removeChildAndDestroy(b)}else{container.removeChild(b)}}if(a){this.appendChild(a)}this.activeTopToolbar=a;this.invokeLast("childDidChange")}.observes("topToolbar"),bottomToolbarDidChange:function(){var b=this.activeBottomToolbar,a=this.get("bottomToolbar");if(b){if(b.createdByParent){container.removeChildAndDestroy(b)}else{container.removeChild(b)}}if(a){this.appendChild(a)}this.activeBottomToolbar=a;this.invokeLast("childDidChange")}.observes("bottomToolbar"),contentViewDidChange:function(){var b=this.activeContentView,a=this.get("contentView");if(b){if(b.createdByParent){container.removeChildAndDestroy(b)}else{container.removeChild(b)}}if(a){this.appendChild(a)}this.activeContentView=a;this.invokeLast("childDidChange")}.observes("contentView")});sc_require("views/workspace");sc_require("views/toolbar");SC.MasterDetailView=SC.View.extend({classNames:["sc-master-detail-view"],renderDelegateName:"masterDetailRenderDelegate",masterView:SC.WorkspaceView.extend({topToolbar:SC.ToolbarView.extend({}),contentView:SC.View.extend({backgroundColor:"white"})}),detailView:SC.WorkspaceView.extend({topToolbar:SC.ToolbarView.extend({childViews:["showHidePicker"],showHidePicker:SC.ButtonView.extend({layout:{left:7,centerY:0,height:30,width:100},controlSize:SC.AUTO_CONTROL_SIZE,title:"Picker",action:"toggleMasterPicker",isVisible:NO,isVisibleBinding:".parentView.masterIsHidden"})})}),autoHideMaster:function(){if(SC.platform.touch){return YES}return NO}.property().cacheable(),masterWidth:250,dividerWidth:SC.propertyFromRenderDelegate("dividerWidth",1),masterIsHidden:function(){if(!this.get("autoHideMaster")){return NO}if(this.get("orientation")===SC.HORIZONTAL_ORIENTATION){return NO}return YES}.property("autoHideMaster","orientation"),orientation:SC.VERTICAL_ORIENTATION,_scmd_frameDidChange:function(){var b=this.get("frame"),a;if(b.width>b.height){a=SC.HORIZONTAL_ORIENTATION}else{a=SC.VERTICAL_ORIENTATION}this.setIfChanged("orientation",a)}.observes("frame"),init:function(){arguments.callee.base.apply(this,arguments);this._scmd_frameDidChange();this._scmd_masterIsHiddenDidChange()},toggleMasterPicker:function(a){if(!this.get("masterIsHidden")){return}if(this._picker&&this._picker.get("isVisibleInWindow")){this.hideMasterPicker()}else{this.showMasterPicker(a)}},showMasterPicker:function(b){if(this._picker&&this._picker.get("isVisibleInWindow")){return}if(!this._picker){var a=this.get("pickerPane");this._picker=a.create({})}this._picker.set("contentView",this.get("masterView"));this._picker.set("extraRightOffset",this.get("pointerDistanceFromEdge"));this.showPicker(this._picker,b)},hideMasterPicker:function(){if(this._picker&&this._picker.get("isVisibleInWindow")){this.hidePicker(this._picker)}},showPicker:function(b,a){b.popup(a,SC.PICKER_POINTER,[3,0,1,2,3],[9,-9,-18,18])},hidePicker:function(a){a.remove()},pickerPane:SC.PickerPane.extend({layout:{width:250,height:480},themeName:"popover"}),_picker:null,pointerDistanceFromEdge:46,_scmd_masterIsHiddenDidChange:function(){var a=this.get("masterIsHidden");this.get("masterView").set("masterIsHidden",a);this.get("detailView").set("masterIsHidden",a)}.observes("masterIsHidden"),_scmd_orientationDidChange:function(){this.invokeOnce("_scmd_tile")}.observes("orientation"),_scmd_retileProperties:function(){this.invokeOnce("_scmd_tile")}.observes("masterIsHidden","masterWidth"),createChildViews:function(){var b=this.get("masterView");b=this.masterView=this.createChildView(b);var a=this.get("detailView");a=this.detailView=this.createChildView(a);this.appendChild(a);this.invokeOnce("_scmd_tile")},_masterIsDrawn:NO,_scmd_tile:function(){var b=!this.get("masterIsHidden");var e=this.get("masterWidth"),d=this.get("masterView"),c=this.get("detailView");if(b){this.hideMasterPicker();if(!this._masterIsDrawn){if(this._picker){this._picker.set("contentView",null)}this.appendChild(d);this._masterIsDrawn=YES}d.set("layout",{left:0,top:0,bottom:0,width:e});var a=this.get("dividerWidth");c.set("layout",{left:e+a,right:0,top:0,bottom:0})}else{if(this._masterIsDrawn){this.removeChild(d);this._masterIsDrawn=NO}c.set("layout",{left:0,right:0,top:0,bottom:0})}}});SC.ScrollerView=SC.View.extend({classNames:["sc-scroller-view"],displayProperties:["thumbPosition","thumbLength","controlsHidden"],ariaRole:"scrollbar",shouldScrollToClick:NO,value:null,displayValue:function(){return Math.max(Math.min(this.get("value"),this.get("maximum")),this.get("minimum"))}.property("value","minimum","maximum").cacheable(),proportion:0,maximum:0,minimum:0,isEnabled:function(a,b){if(b!==undefined){this._scsv_isEnabled=b}if(this._scsv_isEnabled!==undefined){return this._scsv_isEnabled}return this.get("proportion")<1}.property("proportion").cacheable(),_scsv_isEnabled:undefined,layoutDirection:SC.LAYOUT_VERTICAL,hasButtons:YES,scrollbarThickness:14,capLength:18,capOverlap:14,buttonLength:41,buttonOverlap:9,minimumThumbLength:20,render:function(c,a){var g="vertical",b={},i=this.get("parentView"),f=this.get("layoutDirection"),d,h,e;switch(f){case SC.LAYOUT_VERTICAL:b["sc-vertical"]=YES;break;case SC.LAYOUT_HORIZONTAL:b["sc-horizontal"]=YES;g="horizontal";break}b["controls-hidden"]=this.get("controlsHidden");c.setClass(b);h=this.get("thumbLength");d=this.get("thumbPosition");if(a){c.push('<div class="track"></div>','<div class="cap"></div>');this.renderButtons(c,this.get("hasButtons"));this.renderThumb(c,f,h,d);c.setAttr("aria-orientation",g);c.setAttr("aria-valuemax",this.get("maximum"));c.setAttr("aria-valuemin",this.get("minimum"));c.setAttr("aria-valuenow",this.get("value"));c.setAttr("aria-controls",i.getPath("contentView.layerId"))}else{if(this.get("controlsHidden")){return}e=this.$(".thumb");this.adjustThumb(e,d,h);c.setAttr("aria-valuenow",this.get("value"));if(this.didChangeFor("render-min","minimum")){c.setAttr("aria-valuemin",this.get("minimum"))}if(this.didChangeFor("render-max","maximum")){c.setAttr("aria-valuemax",this.get("maximum"))}}},renderThumb:function(d,e,b,c){var a;if(e===SC.LAYOUT_HORIZONTAL){a="width: "+b+"px; left: "+c+"px;"}else{a="height: "+b+"px; top: "+c+"px;"}d.push('<div class="thumb" style="%@">'.fmt(a),'<div class="thumb-center"></div>','<div class="thumb-top"></div>','<div class="thumb-bottom"></div></div>')},renderButtons:function(b,a){if(a){b.push('<div class="button-bottom"></div><div class="button-top"></div>')}else{b.push('<div class="endcap"></div>')}},adjustThumb:function(b,a,c){this.adjustThumbPosition(b,a);this.adjustThumbSize(b,c)},adjustThumbPosition:function(b,d){var a=SC.browser.experimentalCSSNameFor("transform"),i=b[0];if(this._thumbPosition!==d){var j=this.get("parentView"),g=j._sc_isAnimating;if(SC.platform.supportsCSSTransitions){var e=SC.browser.experimentalStyleNameFor("transition");if(g){var f=j._sc_animationDuration,c=j._sc_animationTiming.toString();if(SC.platform.supportsCSSTransforms){i.style[e]=a+" "+f+"s "+c}else{switch(this.get("layoutDirection")){case SC.LAYOUT_VERTICAL:i.style[e]="top "+f+"s "+c;break;case SC.LAYOUT_HORIZONTAL:i.style[e]="left "+f+"s "+c;break}}}else{i.style[e]=""}}var h;switch(this.get("layoutDirection")){case SC.LAYOUT_VERTICAL:if(SC.platform.supportsCSSTransforms){h="translateX(0px) translateY("+d+"px)";if(SC.platform.supportsCSS3DTransforms){h+=" translateZ(0px)"}i.style[a]=h}else{i.style.top=d}break;case SC.LAYOUT_HORIZONTAL:if(SC.platform.supportsCSSTransforms){h="translateX("+d+"px) translateY(0px)";if(SC.platform.supportsCSS3DTransforms){h+=" translateZ(0px)"}i.style[a]=h}else{i.style.left=d}break}}this._thumbPosition=d},adjustThumbSize:function(a,b){if(this._thumbSize===b){return}switch(this.get("layoutDirection")){case SC.LAYOUT_VERTICAL:a.css("height",Math.max(b,this.get("minimumThumbLength")));break;case SC.LAYOUT_HORIZONTAL:a.css("width",Math.max(b,this.get("minimumThumbLength")));break}this._thumbSize=b},trackLength:function(){var a=this.get("scrollerLength");a-=this.get("capLength")-this.get("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(){var c=this.get("value"),e=this.get("maximum"),b=this.get("minimum"),d=this.get("proportion"),a;if(c<b){d-=(b-c)/e}else{if(c>e){d-=(c-e)/e}}a=Math.floor(this.get("trackLength")*d);a=isNaN(a)?0:a;return Math.max(a,this.get("minimumThumbLength"))}.property("value","minimum","maximum","trackLength","proportion").cacheable(),thumbPosition:function(){var e=this.get("displayValue"),g=this.get("maximum"),b=this.get("trackLength"),c=this.get("thumbLength"),f=this.get("capLength"),d=this.get("capOverlap"),a;a=(e/g)*(b-c);a+=f-d;return Math.floor(isNaN(a)?0:a)}.property("displayValue","maximum","trackLength","thumbLength").cacheable(),controlsHidden:function(){return this.get("proportion")>=1}.property("proportion").cacheable(),fadeIn:null,fadeOut:null,valueForPosition:function(g){var b=this.get("maximum"),a=this.get("trackLength"),c=this.get("thumbLength"),f=this.get("capLength"),d=this.get("capOverlap"),e;e=g-(f-d);e=e/(a-c);e=e*b;return e},touchStart:function(a){a.which=1;return this.mouseDown(a)},touchesDragged:function(a){return this.mouseDragged(a)},touchEnd:function(a){return this.mouseUp(a)},mouseDown:function(g){if(g.which!==1){return false}if(!this.get("isEnabledInPane")){return NO}this._altIsDown=g.altKey;this._shiftIsDown=g.shiftKey;var d=g.target,b=this.get("thumbPosition"),c,e=this.get("scrollerLength");if(d.className.indexOf("thumb")>=0){c=this.convertFrameFromView({x:g.pageX,y:g.pageY});c.x-=b;c.y-=b;this._thumbDragging=YES;this._thumbOffset=c;this._mouseDownLocation={x:g.pageX,y:g.pageY};this._thumbPositionAtDragStart=this.get("thumbPosition");this._valueAtDragStart=this.get("value")}else{if(d.className.indexOf("button-top")>=0){this.decrementProperty("value",(this._altIsDown?e:30));this.makeButtonActive(".button-top");this.startMouseDownTimer("scrollUp");this._isScrollingUp=YES}else{if(d.className.indexOf("button-bottom")>=0){this.incrementProperty("value",(this._altIsDown?e:30));this.makeButtonActive(".button-bottom");this.startMouseDownTimer("scrollDown");this._isScrollingDown=YES}else{var i=this.get("shouldScrollToClick");if(g.altKey){i=!i}var f=this.get("thumbLength"),a=this.convertFrameFromView({x:g.pageX,y:g.pageY}),h;switch(this.get("layoutDirection")){case SC.LAYOUT_VERTICAL:this._mouseDownLocation=h=a.y;break;case SC.LAYOUT_HORIZONTAL:this._mouseDownLocation=h=a.x;break}if(i){this.set("value",Math.min(this.get("maximum"),Math.max(this.get("minimum"),this.valueForPosition(h-(f/2)))));b=this.get("thumbPosition");this._thumbDragging=YES;this._thumbOffset={x:a.x-b,y:a.y-b};this._mouseDownLocation={x:g.pageX,y:g.pageY};this._thumbPositionAtDragStart=b;this._valueAtDragStart=this.get("value")}else{if(h<b){this.decrementProperty("value",e);this.startMouseDownTimer("page")}else{this.incrementProperty("value",e);this.startMouseDownTimer("page")}}}}}return YES},mouseUp:function(a){var c=this._scs_buttonActive,b=NO,d;if(c){c.removeClass("active");b=YES}d=this._mouseDownTimer;if(d){d.invalidate();this._mouseDownTimer=null}this._thumbDragging=NO;this._isScrollingDown=NO;this._isScrollingUp=NO;return b},mouseDragged:function(i){if(!this.get("isEnabledInPane")){return NO}var a,h,b,c=this._thumbPositionAtDragStart,f=this._isScrollingUp,k=this._isScrollingDown,d=this._scs_buttonActive;if(this._thumbDragging){switch(this.get("layoutDirection")){case SC.LAYOUT_VERTICAL:h=(i.pageY-this._mouseDownLocation.y);break;case SC.LAYOUT_HORIZONTAL:h=(i.pageX-this._mouseDownLocation.x);break}if(i.altKey){if(!this._altIsDown||(this._shiftIsDown!==i.shiftKey)){c=this._thumbPositionAtDragStart=c+h;h=0;this._mouseDownLocation={x:i.pageX,y:i.pageY};this._valueAtDragStart=this.get("value")}if(i.shiftKey){h=-h}this.set("value",Math.min(this.get("maximum"),Math.max(this.get("minimum"),Math.round(this._valueAtDragStart+h*2))))}else{b=c+h;a=this.get("trackLength")-this.get("thumbLength");this.set("value",Math.min(this.get("maximum"),Math.max(this.get("minimum"),Math.round((b/a)*this.get("maximum")))))}}else{if(f||k){var j=NO,e=NO;var g=this.$(".button-top")[0].getBoundingClientRect();switch(this.get("layoutDirection")){case SC.LAYOUT_VERTICAL:if(i.clientY<g.bottom){j=YES}else{e=YES}break;case SC.LAYOUT_HORIZONTAL:if(i.clientX<g.right){j=YES}else{e=YES}break}if((j||e)&&j!==f){if(d){d.removeClass("active")}this._mouseDownTimerAction=j?"scrollUp":"scrollDown";if(j){this.makeButtonActive(".button-top")}else{if(e){this.makeButtonActive(".button-bottom")}}this._isScrollingUp=j;this._isScrollingDown=e}}}this._altIsDown=i.altKey;this._shiftIsDown=i.shiftKey;return YES},startMouseDownTimer:function(b,a){this._mouseDownTimerAction=b;this._mouseDownTimer=SC.Timer.schedule({target:this,action:this.mouseDownTimerDidFire,interval:a?0:300})},mouseDownTimerDidFire:function(){var d=this.get("scrollerLength"),a=SC.device.get("mouseLocation"),c=this.get("thumbPosition"),b=this.get("thumbLength"),e=50;switch(this.get("layoutDirection")){case SC.LAYOUT_VERTICAL:a=this.convertFrameFromView(a).y;break;case SC.LAYOUT_HORIZONTAL:a=this.convertFrameFromView(a).x;break}switch(this._mouseDownTimerAction){case"scrollDown":this.incrementProperty("value",this._altIsDown?d:30);break;case"scrollUp":this.decrementProperty("value",this._altIsDown?d:30);break;case"page":e=150;if(a<c){this.decrementProperty("value",d)}else{if(a>c+b){this.incrementProperty("value",d)}}}this._mouseDownTimer=SC.Timer.schedule({target:this,action:this.mouseDownTimerDidFire,interval:e})},makeButtonActive:function(a){this._scs_buttonActive=this.$(a).addClass("active")}});SC.OverlayScrollerView=SC.ScrollerView.extend({fadeIn:function(){this.$().toggleClass("fade-in",true);this.$().toggleClass("fade-out",false)},fadeOut:function(){this.$().toggleClass("fade-in",false);this.$().toggleClass("fade-out",true)},classNames:["sc-touch-scroller-view","sc-overlay-scroller-view"],scrollbarThickness:12,capLength:3,capOverlap:0,buttonLength:3,buttonOverlap:0,hasButtons:NO,adjustThumb:function(b,d,j){var a=SC.browser.experimentalCSSNameFor("transform"),l=b[0],i=this.$(".thumb-inner"),h=i[0];if(this._thumbPosition!==d){var m=this.get("parentView"),g=m._sc_isAnimating;if(SC.platform.supportsCSSTransitions){var e=SC.browser.experimentalStyleNameFor("transition");if(g){var f=m._sc_animationDuration,c=m._sc_animationTiming.toString();if(SC.platform.supportsCSSTransforms){l.style[e]=a+" "+f+"s "+c;if(this._thumbSize!==j){h.style[e]=a+" "+f+"s "+c}}else{switch(this.get("layoutDirection")){case SC.LAYOUT_VERTICAL:l.style[e]="top "+f+"s "+c;if(this._thumbSize!==j){h.style[e]="top "+f+"s "+c}break;case SC.LAYOUT_HORIZONTAL:l.style[e]="left "+f+"s "+c;if(this._thumbSize!==j){h.style[e]="left "+f+"s "+c}break}}}else{l.style[e]="";h.style[e]=""}}var k;switch(this.get("layoutDirection")){case SC.LAYOUT_VERTICAL:if(SC.platform.supportsCSSTransforms){k="translateX(0px) translateY("+d+"px)";if(SC.platform.supportsCSS3DTransforms){k+=" translateZ(0px)"}l.style[a]=k;if(this._thumbSize!==j){k="translateX(0px) translateY("+Math.round(j-1044)+"px)";if(SC.platform.supportsCSS3DTransforms){k+=" translateZ(0px)"}h.style[a]=k}}else{l.style.top=d;if(this._thumbSize!==j){h.style.top=Math.round(j-1044)}}break;case SC.LAYOUT_HORIZONTAL:if(SC.platform.supportsCSSTransforms){k="translateX("+d+"px) translateY(0px)";if(SC.platform.supportsCSS3DTransforms){k+=" translateZ(0px)"}l.style[a]=k;if(this._thumbSize!==j){k="translateX("+Math.round(j-1044)+"px) translateY(0px)";if(SC.platform.supportsCSS3DTransforms){k+=" translateZ(0px)"}h.style[a]=k}}else{l.style.left=d;if(this._thumbSize!==j){h.style.left=Math.round(j-1044)}}break}}this._thumbPosition=d;this._thumbSize=j},render:function(c,f){var e=[],b,a,d;switch(this.get("layoutDirection")){case SC.LAYOUT_VERTICAL:e.push("sc-vertical");break;case SC.LAYOUT_HORIZONTAL:e.push("sc-horizontal");break}if(this.get("controlsHidden")){e.push("controls-hidden")}c.addClass(e);a=this.get("thumbLength");b=this.get("thumbPosition");if(f){c.push('<div class="track"></div><div class="cap"></div>');this.renderButtons(c,this.get("hasButtons"));this.renderThumb(c,b,a)}else{if(this.get("controlsHidden")){return}d=this.$(".thumb");this.adjustThumb(d,b,a)}},renderThumb:function(f,e,c){var b=SC.browser.experimentalCSSNameFor("transform"),d,a;switch(this.get("layoutDirection")){case SC.LAYOUT_VERTICAL:d=b+": translate3d(0px,"+e+"px,0px)";a=b+": translateY("+(c-1044)+"px)".fmt();break;case SC.LAYOUT_HORIZONTAL:d=b+": translate3d("+e+"px,0px,0px)";a=b+": translateX("+(c-1044)+"px)".fmt();break}f.push('<div class="thumb" style="%@;">'.fmt(d)+'<div class="thumb-top"></div><div class="thumb-clip">'+'<div class="thumb-inner" style="%@;">'.fmt(a)+'<div class="thumb-center"></div><div class="thumb-bottom"></div></div></div></div>');this._thumbPosition=e;this._thumbSize=c}});SC.TouchScrollerView=SC.OverlayScrollerView.extend({});sc_require("views/scroller");SC.SCROLL={DRAG_SCROLL_DECELERATION:3,SCROLL_GESTURE_THRESHOLD:5,SCROLL_LOCK_GESTURE_THRESHOLD:50,SCALE_GESTURE_THRESHOLD:3};SC.ScrollView=SC.View.extend({_sc_animationDuration:null,_sc_animationTiming:null,_sc_containerHeight:0,_sc_containerOffset:null,_sc_containerWidth:0,_sc_contentHeight:0,_sc_contentHeightDidChange:false,_sc_contentScale:undefined,_sc_contentScaleDidChange:false,_sc_contentWidth:0,_sc_contentWidthDidChange:false,_sc_gestureAnchorHOffset:null,_sc_gestureAnchorTotalD:null,_sc_gestureAnchorTotalX:null,_sc_gestureAnchorTotalY:null,_sc_gestureAnchorVOffset:null,_sc_gestureAnchorX:null,_sc_gestureAnchorY:null,_sc_gestureAnchorD:null,_sc_gestureAnchorScale:null,_sc_horizontalFadeOutTimer:null,_sc_horizontalScrollOffset:null,_sc_horizontalPct:null,_sc_isTouchScaling:false,_sc_isTouchScrollingH:false,_sc_isTouchScrollingHOnly:false,_sc_isTouchScrollingV:false,_sc_isTouchScrollingVOnly:false,_sc_minimumFadeOutDelay:function(){return Math.max(Math.max(this.get("fadeOutDelay")||0,0.1),this.get("fadeInDuration")||0)*1000}.property("fadeOutDelay").cacheable(),_sc_overDragSlip:0.5,_sc_passTouchToContentTimer:null,_sc_scale:1,_sc_touchCenterX:null,_sc_touchCenterY:null,_sc_verticalFadeOutTimer:null,_sc_verticalScrollOffset:null,_sc_verticalPct:null,acceptsMultitouch:true,animationCurveDecelerate:SC.easingCurve(0.35,0.34,0.84,1),animationCurveReverse:SC.easingCurve(0.45,-0.47,0.73,1.3),animationCurveSnap:SC.easingCurve(0.28,0.36,0.52,1),autohidesHorizontalScroller:true,autohidesVerticalScroller:true,canScale:false,canScrollHorizontal:function(){return !!(this.get("hasHorizontalScroller")&&this.get("horizontalScrollerView")&&this.get("isHorizontalScrollerVisible"))}.property("isHorizontalScrollerVisible").cacheable(),canScrollVertical:function(){return !!(this.get("hasVerticalScroller")&&this.get("verticalScrollerView")&&this.get("isVerticalScrollerVisible"))}.property("isVerticalScrollerVisible").cacheable(),classNames:["sc-scroll-view"],containerView:SC.ContainerView,contentView:null,decelerationRate:SC.SCROLL.DRAG_SCROLL_DECELERATION,delaysContentTouches:true,fadeOutDelay:0.4,hasHorizontalScroller:true,hasVerticalScroller:true,horizontalAlign:SC.ALIGN_CENTER,horizontalFade:true,horizontalLineScroll:20,horizontalOverlay:false,horizontalPageScroll:function(){return this.get("frame").width}.property("frame"),horizontalScrollOffset:function(e,g){var f=this._sc_containerWidth,b=this._sc_contentWidth,d=this.get("minimumHorizontalScrollOffset"),a=this.get("maximumHorizontalScrollOffset");if(g!=null){if(!this._sc_isTouchScrollingH){g=Math.max(d,Math.min(a,g))}if(b>0){this._sc_horizontalPct=(g+(f/2))/b}}else{g=this._sc_horizontalScrollOffset;if(g==null){var c=this.get("initialHorizontalAlign");g=this._sc_alignedHorizontalOffset(c,f,b)}}this._sc_horizontalScrollOffset=g;return g}.property().cacheable(),horizontalScrollerLayout:null,horizontalScrollerView:null,initialHorizontalAlign:SC.outlet("horizontalAlign"),initialVerticalAlign:SC.outlet("verticalAlign"),isHorizontalScrollerVisible:true,isScrollable:true,isVerticalScrollerVisible:true,maximumHorizontalScrollOffset:function(){return Math.max(this._sc_contentWidth-this._sc_containerWidth,0)}.property("_sc_containerWidth","_sc_contentWidth").cacheable(),maximumScale:2,maximumVerticalScrollOffset:function(){return Math.max(this._sc_contentHeight-this._sc_containerHeight,0)}.property("_sc_containerHeight","_sc_contentHeight").cacheable(),minimumHorizontalScrollOffset:function(){return Math.min(this._sc_contentWidth-this._sc_containerWidth,0)}.property("_sc_containerWidth","_sc_contentWidth").cacheable(),minimumScale:0.25,minimumVerticalScrollOffset:function(){return Math.min(this._sc_contentHeight-this._sc_containerHeight,0)}.property("_sc_containerHeight","_sc_contentHeight").cacheable(),scale:function(c,d){if(d!=null){if(!this.get("canScale")){d=1}else{var b=this.get("minimumScale"),a=this.get("maximumScale");if(this._sc_isTouchScaling){b=b-(b*0.1);a=a+(a*0.1);if((d<b||d>a)){d=Math.min(Math.max(b,d),a)}}else{if((d<b||d>a)){d=Math.min(Math.max(b,d),a)}}}}else{d=this._sc_scale}this._sc_scale=d;return d}.property("canScale","minimumScale","maximumScale").cacheable(),scaleGestureThreshold:SC.SCROLL.SCALE_GESTURE_THRESHOLD,scrollGestureThreshold:SC.SCROLL.SCROLL_GESTURE_THRESHOLD,scrollLockGestureThreshold:SC.SCROLL.SCROLL_LOCK_GESTURE_THRESHOLD,verticalAlign:SC.ALIGN_TOP,verticalFade:true,verticalLineScroll:20,verticalOverlay:false,verticalPageScroll:function(){return this.get("frame").height}.property("frame"),verticalScrollOffset:function(c,f){var e=this._sc_containerHeight,d=this._sc_contentHeight,b=this.get("minimumVerticalScrollOffset"),a=this.get("maximumVerticalScrollOffset");if(f!=null){if(!this._sc_isTouchScrollingV){f=Math.max(b,Math.min(a,f))}if(d>0){this._sc_verticalPct=(f+(e/2))/d}}else{f=this._sc_verticalScrollOffset;if(f==null){var g=this.get("initialVerticalAlign");f=this._sc_alignedVerticalOffset(g,e,d)}}this._sc_verticalScrollOffset=f;return f}.property().cacheable(),verticalScrollerLayout:null,verticalScrollerView:null,_sc_alignedHorizontalOffset:function(b,c,a){switch(b){case SC.ALIGN_RIGHT:return 0-(c-a);case SC.ALIGN_CENTER:return 0-((c-a)/2);default:return 0}},_sc_alignedVerticalOffset:function(c,b,a){switch(c){case SC.ALIGN_BOTTOM:return 0-(b-a);case SC.ALIGN_MIDDLE:return 0-((b-a)/2);default:return 0}},_sc_animateContentView:function(j){var h=this._sc_animationTiming,l=this._sc_animationDuration*1000,d=new Date(),m=this.get("contentView"),b=m.get("layout"),f=b.left,c=j.left-f,a=b.scale==null?1:b.scale,k=j.scale-a,i=b.top,g=j.top-i,n=this;function e(){if(n._sc_isAnimating){var p=new Date()-d,o=Math.min(p/l,1);SC.run(function(){var r=f+c*h.value(o),s=a+k*h.value(o),q=i+g*h.value(o);j.left=r;j.top=q;j.scale=s;m.adjust(j)});if(o<1){window.requestAnimationFrame(e)}else{n._sc_isAnimating=false;n._sc_animationDuration=null;n._sc_animationTiming=null}}}n._sc_isAnimating=true;e()},_sc_cancelAnimation:function(){if(this._sc_isAnimating){var b=this.get("contentView");var a=b.get("layout");this.set("horizontalScrollOffset",-a.left);this.set("verticalScrollOffset",-a.top);this.set("scale",a.scale);this._sc_isAnimating=false;this._sc_animationDuration=null;this._sc_animationTiming=null}},_sc_containerViewFrameDidChange:function(){var a=this.getPath("containerView.frame"),c=this.get("contentView"),f=this.get("maximumHorizontalScrollOffset"),b=this.get("maximumVerticalScrollOffset"),e=this.get("minimumHorizontalScrollOffset"),d=this.get("minimumVerticalScrollOffset");this.set("_sc_containerHeight",a.height);this.set("_sc_containerWidth",a.width);if(c){this._sc_contentViewSizeDidChange(e,f,d,b)}},_sc_contentViewDidChange:function(){var c=this.get("contentView"),b=this.get("containerView"),a=this._sc_contentViewFrameDidChange;this._sc_removeContentViewObservers();this._sc_contentHeight=0;this._sc_contentWidth=0;this._sc_contentScale=undefined;b.set("contentView",c);c=this.contentView=b.get("contentView");if(c){if(!c.useStaticLayout){}c.addObserver("frame",this,a);this._sc_contentViewFrameDidChange()}this._sc_contentView=c},_sc_contentViewFrameDidChange:function(){var e=this._sc_contentHeight,c=this._sc_contentScale,a=this._sc_contentWidth,h=this.getPath("contentView.borderFrame"),g=this.get("maximumHorizontalScrollOffset"),b=this.get("maximumVerticalScrollOffset"),f=this.get("minimumHorizontalScrollOffset"),d=this.get("minimumVerticalScrollOffset");if(h){if(c!==h.scale){this._sc_contentScaleDidChange=true;this.set("_sc_contentScale",h.scale)}if(a!==h.width){this._sc_contentWidthDidChange=true;this.set("_sc_contentWidth",h.width)}if(e!==h.height){this._sc_contentHeightDidChange=true;this.set("_sc_contentHeight",h.height)}if(this._sc_contentScaleDidChange||this._sc_contentWidthDidChange||this._sc_contentHeightDidChange){this._sc_contentViewSizeDidChange(f,g,d,b)}}},_sc_contentViewSizeDidChange:function(k,i,o,h){var f=this.get("maximumHorizontalScrollOffset"),p=this.get("maximumVerticalScrollOffset"),q,l,n,a;q=this._sc_containerHeight;l=this._sc_containerWidth;n=this._sc_contentHeight;a=this._sc_contentWidth;var m;if(a){if(f===0){m=this._sc_alignedHorizontalOffset(this.get("horizontalAlign"),l,a);this.set("horizontalScrollOffset",m)}else{if(this._sc_horizontalPct==null){this._sc_horizontalScrollOffset=null;this.notifyPropertyChange("horizontalScrollOffset")}else{if(this._sc_contentScaleDidChange){if(this._sc_touchCenterX!=null){m=(this._sc_horizontalPct*a)-this._sc_touchCenterX}else{m=(this._sc_horizontalPct*a)-(l/2)}this.set("horizontalScrollOffset",m);if(this._sc_gestureAnchorHOffset!=null){this._sc_gestureAnchorHOffset=m}}else{if(this.get("canScrollHorizontal")){var b=this.get("horizontalAlign"),g=this._sc_horizontalScrollOffset,e=this.get("minimumHorizontalScrollOffset");switch(b){case SC.ALIGN_CENTER:if((k<0&&e===0)||(g===i/2)){this.set("horizontalScrollOffset",f/2)}break;case SC.ALIGN_RIGHT:if((k<0&&e===0)||(g===i)){this.set("horizontalScrollOffset",f)}break}if(g>f){this.set("horizontalScrollOffset",f)}}}}}}if(n){if(p===0){m=this._sc_alignedVerticalOffset(this.get("verticalAlign"),q,n);this.set("verticalScrollOffset",m)}else{if(this._sc_verticalPct==null){this._sc_verticalScrollOffset=null;this.notifyPropertyChange("verticalScrollOffset")}else{if(this._sc_contentScaleDidChange){if(this._sc_touchCenterY!=null){m=(this._sc_verticalPct*n)-this._sc_touchCenterY}else{m=(this._sc_verticalPct*n)-(q/2)}this.set("verticalScrollOffset",m);if(this._sc_gestureAnchorVOffset!=null){this._sc_gestureAnchorVOffset=m}}else{if(this.get("canScrollVertical")){var d=this.get("verticalAlign"),c=this._sc_verticalScrollOffset,j=this.get("minimumVerticalScrollOffset");switch(d){case SC.ALIGN_MIDDLE:if((o<0&&j===0)||(c===h/2)){this.set("verticalScrollOffset",p/2)}break;case SC.ALIGN_BOTTOM:if((o<0&&j===0)||(c===h)){this.set("verticalScrollOffset",p)}break}if(c>p){this.set("verticalScrollOffset",p)}}}}}}this._sc_contentScaleDidChange=false;this._sc_contentHeightDidChange=false;this._sc_contentWidthDidChange=false;this._sc_updateScrollers()},_sc_fadeInHorizontalScroller:function(){var b=this.get("canScrollHorizontal"),c=this.get("horizontalScrollerView"),a;if(b&&c&&c.get("fadeIn")){if(this._sc_horizontalFadeOutTimer){this._sc_horizontalFadeOutTimer.startTime=null;this._sc_horizontalFadeOutTimer.schedule()}else{c.fadeIn();a=this.get("_sc_minimumFadeOutDelay");this._sc_horizontalFadeOutTimer=this.invokeLater(this._sc_fadeOutHorizontalScroller,a)}}},_sc_fadeInVerticalScroller:function(){var b=this.get("canScrollVertical"),a=this.get("verticalScrollerView"),c;if(b&&a&&a.get("fadeIn")){if(this._sc_verticalFadeOutTimer){this._sc_verticalFadeOutTimer.startTime=null;this._sc_verticalFadeOutTimer.schedule()}else{a.fadeIn();c=this.get("_sc_minimumFadeOutDelay");this._sc_verticalFadeOutTimer=this.invokeLater(this._sc_fadeOutVerticalScroller,c)}}},_sc_fadeOutHorizontalScroller:function(){var a=this.get("horizontalScrollerView");if(a&&a.get("fadeOut")){a.fadeOut()}this._sc_horizontalFadeOutTimer=null},_sc_fadeOutVerticalScroller:function(){var a=this.get("verticalScrollerView");if(a&&a.get("fadeOut")){a.fadeOut()}this._sc_verticalFadeOutTimer=null},_sc_horizontalAlignDidChange:function(){var c=this.get("maximumHorizontalScrollOffset");if(c===0&&this._sc_contentWidth){var a=this.get("horizontalAlign"),b;b=this._sc_alignedHorizontalOffset(a,this._sc_containerWidth,this._sc_contentWidth);this.set("horizontalScrollOffset",b)}},_sc_maximumScrollOffset:function(c,b,d,a){if(a===NO){c=Math.min(c,b)}if(c>=b){return c-b}if(d===SC.ALIGN_LEFT||d===SC.ALIGN_TOP){return 0}else{if(d===SC.ALIGN_MIDDLE||d===SC.ALIGN_CENTER){return 0-Math.round((b-c)/2)}else{return 0-(b-c)}}},_sc_minimumScrollOffset:function(c,b,d,a){if(a===NO){c=Math.min(c,b)}if(c>b){return 0}if(d===SC.ALIGN_LEFT||d===SC.ALIGN_TOP){return 0}else{if(d===SC.ALIGN_MIDDLE||d===SC.ALIGN_CENTER){return 0-Math.round((b-c)/2)}else{return 0-(b-c)}}},_sc_registerAutoscroll:function(){if(this.get("isVisibleInWindow")&&this.get("isEnabledInPane")){SC.Drag.addScrollableView(this)}else{SC.Drag.removeScrollableView(this)}},_sc_repositionContentView:function(){var a=this.get("contentView");if(a){this.invokeOnce(this._sc_repositionContentViewUnfiltered)}},_sc_repositionContentViewUnfiltered:function(){var j=this.get("containerView"),k=this.get("contentView"),f=this.get("horizontalScrollOffset"),b=this.get("verticalScrollOffset"),e=this.get("scale");if(k.useStaticLayout){var g=j.get("layer");g.style.marginLeft=-f+"px";g.style.marginTop=-b+"px"}else{var a=this.get("horizontalAlign"),d=this.get("verticalAlign"),c,i;c=-f;switch(a){case SC.ALIGN_CENTER:c=Math.round(c);break;case SC.ALIGN_RIGHT:c=Math.ceil(c);break;default:c=Math.floor(c)}i=-b;switch(d){case SC.ALIGN_MIDDLE:i=Math.round(i);break;case SC.ALIGN_BOTTOM:i=Math.ceil(i);break;default:i=Math.floor(i)}var h=SC.ScrollView._SC_CONTENT_ADJUST_MAP;if(!h){h=SC.ScrollView._SC_CONTENT_ADJUST_MAP={transformOriginX:0,transformOriginY:0}}h.left=c;h.top=i;h.scale=e;if(this._sc_animationDuration){this._sc_animateContentView(h)}else{k.adjust(h)}}},_sc_repositionScrollers:function(){this.invokeOnce(this._sc_repositionScrollersUnfiltered)},_sc_repositionScrollersUnfiltered:function(){var k=this.get("hasHorizontalScroller"),o=this.get("hasVerticalScroller"),g=this.get("canScrollHorizontal"),c=this.get("canScrollVertical"),j=SC.ScrollView._SC_CONTAINER_LAYOUT_MAP,b=this.get("horizontalScrollerView"),i=b&&g?b.get("scrollbarThickness"):0,l=this.get("verticalScrollerView"),e=l&&c?l.get("scrollbarThickness"):0,h;if(!j){j=SC.ScrollView._SC_CONTAINER_LAYOUT_MAP={}}j.bottom=0;j.right=0;if(k){var d=this.get("horizontalOverlay"),a=this.get("horizontalScrollerLayout");if(a){h={left:a.left,bottom:a.bottom,right:a.right+e,height:i}}else{h={left:0,bottom:0,right:e,height:i}}b.set("layout",h);if(g&&!d){j.bottom=i}b.set("isVisible",g);this._sc_fadeInHorizontalScroller()}if(o){var n=this.get("verticalOverlay"),f=this.get("verticalScrollerLayout");if(f){h={top:f.top,right:f.right,bottom:f.bottom+i,width:e}}else{h={top:0,right:0,bottom:i,width:e}}l.set("layout",h);if(c&&!n){j.right=e}l.set("isVisible",c);this._sc_fadeInVerticalScroller()}var m=this.get("containerView");m.adjust(j)},_sc_removeContentViewObservers:function(){var b=this._sc_contentView,a=this._sc_contentViewFrameDidChange;if(b){b.removeObserver("frame",this,a)}},_sc_scaleDidChange:function(){var a=this.get("contentView"),b=this.get("scale");if(a){if(a.useStaticLayout){}else{this._sc_repositionContentView()}}},_sc_scrollOffsetHorizontalDidChange:function(){this._sc_repositionContentView();this.invokeLast(this._sc_fadeInHorizontalScroller)},_sc_scrollOffsetVerticalDidChange:function(){this._sc_repositionContentView();this.invokeLast(this._sc_fadeInVerticalScroller)},_sc_updateScrollers:function(){var b=this.get("horizontalScrollerView"),g=this.get("verticalScrollerView"),c=this.get("minimumHorizontalScrollOffset"),f=this.get("minimumVerticalScrollOffset"),d=this.get("maximumHorizontalScrollOffset"),j=this.get("maximumVerticalScrollOffset"),k,h,i,a;k=this._sc_containerHeight;h=this._sc_containerWidth;i=this._sc_contentHeight;a=this._sc_contentWidth;var e;if(b){b.set("minimum",c);b.set("maximum",d);if(this.get("autohidesHorizontalScroller")){this.setIfChanged("isHorizontalScrollerVisible",a>h)}e=Math.min(h/a,1);b.setIfChanged("proportion",e)}if(g){g.set("minimum",f);g.set("maximum",j);if(this.get("autohidesVerticalScroller")){this.setIfChanged("isVerticalScrollerVisible",i>k)}e=Math.min(k/i,1);g.setIfChanged("proportion",e)}},_sc_verticalAlignDidChange:function(){var b=this.get("maximumVerticalScrollOffset");if(b===0&&this._sc_contentHeight){var c=this.get("verticalAlign"),a;a=this._sc_alignedVerticalOffset(c,this._sc_containerHeight,this._sc_contentHeight);this.set("verticalScrollOffset",a)}},createChildViews:function(){var c=[];var b=this.get("containerView");b=this.containerView=this.createChildView(b,{contentView:this.contentView});this.contentView=b.get("contentView");c.push(b);var a;if(!this.get("hasHorizontalScroller")){this.horizontalScrollerView=null}else{a=this.get("horizontalScrollerView");if(a==null){a=this.get("horizontalOverlay")?SC.OverlayScrollerView:SC.ScrollerView}a=this.horizontalScrollerView=this.createChildView(a,{isVisible:!this.get("autohidesHorizontalScroller"),layoutDirection:SC.LAYOUT_HORIZONTAL,value:this.get("horizontalScrollOffset"),valueBinding:".parentView.horizontalScrollOffset",minimum:this.get("minimumHorizontalScrollOffset"),maximum:this.get("maximumHorizontalScrollOffset")});c.push(a)}if(!this.get("hasVerticalScroller")){this.verticalScrollerView=null}else{a=this.get("verticalScrollerView");if(a==null){a=this.get("verticalOverlay")?SC.OverlayScrollerView:SC.ScrollerView}a=this.verticalScrollerView=this.createChildView(a,{isVisible:!this.get("autohidesVerticalScroller"),layoutDirection:SC.LAYOUT_VERTICAL,value:this.get("verticalScrollOffset"),valueBinding:".parentView.verticalScrollOffset",minimum:this.get("minimumVerticalScrollOffset"),maximum:this.get("maximumVerticalScrollOffset")});c.push(a)}this.childViews=c},destroy:function(){this._sc_removeContentViewObservers();this.removeObserver("contentView",this,this._sc_contentViewDidChange);this.removeObserver("horizontalAlign",this,this._sc_horizontalAlignDidChange);this.removeObserver("verticalAlign",this,this._sc_verticalAlignDidChange);arguments.callee.base.apply(this,arguments)},didCreateLayer:function(){this.addObserver("horizontalScrollOffset",this,this._sc_scrollOffsetHorizontalDidChange);this.addObserver("verticalScrollOffset",this,this._sc_scrollOffsetVerticalDidChange);this._sc_scrollOffsetHorizontalDidChange();this._sc_scrollOffsetVerticalDidChange();this.addObserver("isHorizontalScrollerVisible",this,this._sc_repositionScrollers);this.addObserver("isVerticalScrollerVisible",this,this._sc_repositionScrollers);this._sc_repositionScrollers();this.addObserver("scale",this,this._sc_scaleDidChange);this._sc_scaleDidChange();var a=this.get("containerView");a.addObserver("frame",this,this._sc_containerViewFrameDidChange);this._sc_containerViewFrameDidChange();this.addObserver("isVisibleInWindow",this,this._sc_registerAutoscroll);this.addObserver("isEnabledInPane",this,this._sc_registerAutoscroll);this._sc_registerAutoscroll()},init:function(){arguments.callee.base.apply(this,arguments);this.addObserver("contentView",this,this._sc_contentViewDidChange);this._sc_contentViewDidChange();this.addObserver("horizontalAlign",this,this._sc_horizontalAlignDidChange);this.addObserver("verticalAlign",this,this._sc_verticalAlignDidChange)},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;if(a!==null){a=Math.min(Math.max(this.get("minimumHorizontalScrollOffset"),a),this.get("maximumHorizontalScrollOffset"))}if(b!==null){b=Math.min(Math.max(this.get("minimumVerticalScrollOffset"),b),this.get("maximumVerticalScrollOffset"))}return this.scrollTo(a,b)},scrollDownLine:function(a){if(a===undefined){a=1}return this.scrollBy(null,this.get("verticalLineScroll")*a)},scrollDownPage:function(a){if(a===undefined){a=1}return this.scrollBy(null,this.get("verticalPageScroll")*a)},scrollLeftLine:function(a){if(a===undefined){a=1}return this.scrollTo(0-this.get("horizontalLineScroll")*a,null)},scrollLeftPage:function(a){if(a===undefined){a=1}return this.scrollBy(0-(this.get("horizontalPageScroll")*a),null)},scrollRightLine:function(a){if(a===undefined){a=1}return this.scrollTo(this.get("horizontalLineScroll")*a,null)},scrollRightPage:function(a){if(a===undefined){a=1}return this.scrollBy(this.get("horizontalPageScroll")*a,null)},scrollTo:function(a,b){if(b===undefined&&SC.typeOf(a)===SC.T_HASH){b=a.y;a=a.x}if(!SC.none(a)){this.set("horizontalScrollOffset",a)}if(!SC.none(b)){this.set("verticalScrollOffset",b)}return this},scrollToRect:function(b){var a=SC.cloneRect(this.get("containerView").get("frame")),e=this.get("horizontalScrollOffset"),d=this.get("verticalScrollOffset"),c=this.get("scale");a.x=e;a.y=d;if(c!==1){b=SC.cloneRect(b);b.x*=c;b.y*=c;b.height*=c;b.width*=c}a.y+=Math.max(0,SC.maxY(b)-SC.maxY(a));a.x+=Math.max(0,SC.maxX(b)-SC.maxX(a));a.y-=Math.max(0,SC.minY(a)-SC.minY(b));a.x-=Math.max(0,SC.minX(a)-SC.minX(b));if((e!==a.x)||(d!==a.y)){this.scrollTo(a.x,a.y);return YES}else{return NO}},scrollUpLine:function(a){if(a===undefined){a=1}return this.scrollBy(null,0-this.get("verticalLineScroll")*a)},scrollUpPage:function(a){if(a===undefined){a=1}return this.scrollBy(null,0-(this.get("verticalPageScroll")*a))},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("borderFrame");if(!c){return NO}c=b.convertFrameFromView(c,a.get("parentView"));return this.scrollToRect(c)},willDestroyLayer:function(){this.removeObserver("horizontalScrollOffset",this,this._sc_scrollOffsetHorizontalDidChange);this.removeObserver("verticalScrollOffset",this,this._sc_scrollOffsetVerticalDidChange);this.removeObserver("isHorizontalScrollerVisible",this,this._sc_repositionScrollers);this.removeObserver("isVerticalScrollerVisible",this,this._sc_repositionScrollers);this.removeObserver("scale",this,this._sc_scaleDidChange);var a=this.get("containerView");a.removeObserver("frame",this,this._sc_containerViewFrameDidChange);this.removeObserver("isVisibleInWindow",this,this._sc_registerAutoscroll);this.removeObserver("isEnabledInPane",this,this._sc_registerAutoscroll);SC.Drag.removeScrollableView(this)},_sc_beginTouchesInContent:function(a){this._sc_passTouchToContentTimer=null;if(!a.captureTouch(this,true)){a.makeTouchResponder(a.targetView,true,this)}},_sc_touchEnded:function(j,q){var t=this.get("hasTouch");if(t){var b=j.averagedTouchesForView(this);this._sc_gestureAnchorD=this._sc_gestureAnchorTotalD=b.d;this._sc_gestureAnchorX=this._sc_gestureAnchorTotalX=b.x;this._sc_gestureAnchorY=this._sc_gestureAnchorTotalY=b.y;if(this._sc_containerOffset){this._sc_touchCenterX=b.x-this._sc_containerOffset.x;this._sc_touchCenterY=b.y-this._sc_containerOffset.y}}else{if(this._sc_isTouchScrollingV||this._sc_isTouchScrollingH||this._sc_isTouchScaling){var i=this.get("decelerationRate"),p=this._sc_containerHeight,m=this._sc_containerWidth,c=0,r=0,h,g;if(this._sc_isTouchScrollingH){var d=this.get("horizontalScrollOffset"),e=this.get("maximumHorizontalScrollOffset"),k=this.get("minimumHorizontalScrollOffset"),u=this._sc_touchVelocityH;if(d>e){this.set("horizontalScrollOffset",e);if(u<0.2){this._sc_animationTiming=this.get("animationCurveReverse")}else{this._sc_animationTiming=this.get("animationCurveSnap")}c=0.8*(d-e)/m}else{if(d<k){this.set("horizontalScrollOffset",k);if(u>0.2){this._sc_animationTiming=this.get("animationCurveReverse")}else{this._sc_animationTiming=this.get("animationCurveSnap")}c=0.8*(k-d)/m}else{d-=(Math.abs(u)*u*1000)/(2*i);if(d>e){h=(d-e)/m;g=2*h;this._sc_animationTiming=SC.easingCurve(0,0.5,h.toFixed(1),g.toFixed(1));d=e}else{if(d<k){h=(k-d)/m;g=2*h;this._sc_animationTiming=SC.easingCurve(0,0.5,h.toFixed(1),g.toFixed(1));d=k}else{this._sc_animationTiming=this.get("animationCurveDecelerate")}}this.set("horizontalScrollOffset",d);c=Math.abs(u/i)}}}if(this._sc_isTouchScrollingV){var o=this.get("verticalScrollOffset"),n=this.get("maximumVerticalScrollOffset"),f=this.get("minimumVerticalScrollOffset"),a=this._sc_touchVelocityV;if(o>n){this.set("verticalScrollOffset",n);if(a<0.2){this._sc_animationTiming=this.get("animationCurveReverse")}else{this._sc_animationTiming=this.get("animationCurveSnap")}r=0.8*(o-n)/p}else{if(o<f){this.set("verticalScrollOffset",f);if(a>0.2){this._sc_animationTiming=this.get("animationCurveReverse")}else{this._sc_animationTiming=this.get("animationCurveSnap")}r=0.8*(f-o)/p}else{o-=(Math.abs(a)*a*1000)/(2*i);if(o>n){h=(o-n)/p;g=2*h;this._sc_animationTiming=SC.easingCurve(0,0.5,h.toFixed(1),g.toFixed(1));"cubic-bezier(0.0,0.5,%@,%@)".fmt(h.toFixed(1),g.toFixed(1));o=n}else{if(o<f){h=(f-o)/p;g=2*h;this._sc_animationTiming=SC.easingCurve(0,0.5,h.toFixed(1),g.toFixed(1));"cubic-bezier(0.0,0.5,%@,%@)".fmt(h.toFixed(1),g.toFixed(1));o=f}else{this._sc_animationTiming=this.get("animationCurveDecelerate")}}this.set("verticalScrollOffset",o);r=Math.abs(a/i)}}}var v=this.get("scale"),w=this.get("maximumScale"),l=this.get("minimumScale"),s=0;if(v>w){this.set("scale",w);s=0.25}else{if(v<l){this.set("scale",l);s=0.25}else{}}this._sc_animationDuration=Math.max(Math.max(c,r),s);this._sc_touchVelocityH=null;this._sc_touchVelocityV=null}else{if(this._sc_passTouchToContentTimer){this._sc_passTouchToContentTimer.invalidate();this._sc_passTouchToContentTimer=null;if(!q){if(j.makeTouchResponder(j.targetView,true,this)){j.end()}}}}this._sc_gestureAnchorX=this._sc_gestureAnchorY=this._sc_gestureAnchorD=null;this._sc_gestureAnchorTotalX=this._sc_gestureAnchorTotalY=this._sc_gestureAnchorTotalD=null;this._sc_gestureAnchorScale=null;this._sc_gestureAnchorHOffset=null;this._sc_gestureAnchorVOffset=null;this._sc_containerOffset=null;this._sc_touchCenterX=null;this._sc_touchCenterY=null}this._sc_isTouchScrollingH=false;this._sc_isTouchScrollingHOnly=false;this._sc_isTouchScrollingV=false;this._sc_isTouchScrollingVOnly=false;this._sc_isTouchScaling=false;return true},captureTouch:function(a){if(this.get("delaysContentTouches")){return true}else{a.stackCandidateTouchResponder(this);return false}},mouseWheel:function(i){var h=false,j=this.get("contentView");if(j&&this.get("isEnabledInPane")){var f=this.get("horizontalScrollOffset"),d=this.get("minimumHorizontalScrollOffset"),g=this.get("minimumVerticalScrollOffset"),e=this.get("maximumHorizontalScrollOffset"),k=this.get("maximumVerticalScrollOffset"),b=this.get("verticalScrollOffset"),c=i.wheelDeltaX,a=i.wheelDeltaY;if(!this.get("canScrollHorizontal")){c=0}if(!this.get("canScrollVertical")){a=0}h=((c<0&&f>d)||(c>0&&f<e))||((a<0&&b>g)||(a>0&&b<k));if(h){this.scrollBy(c,a)}}return h},touchesDragged:function(t,i){var b=t.averagedTouchesForView(this),p=this.get("canScale"),f=this.get("canScrollHorizontal"),w=this.get("canScrollVertical"),x=this.get("scrollGestureThreshold"),n=this.get("scaleGestureThreshold"),u=this.get("scrollLockGestureThreshold"),d,s;if(!(this._sc_isTouchScrollingH&&this._sc_isTouchScrollingV)&&!this._sc_isTouchScrollingHOnly&&!this._sc_isTouchScrollingVOnly){if(f){var m=Math.abs(this._sc_gestureAnchorTotalX-b.x);if(!this._sc_isTouchScrollingH){this._sc_isTouchScrollingH=m>=x}else{this._sc_isTouchScrollingHOnly=m>=u}}if(w){var k=Math.abs(this._sc_gestureAnchorTotalY-b.y);if(!this._sc_isTouchScrollingV){this._sc_isTouchScrollingV=k>=x}else{this._sc_isTouchScrollingVOnly=k>=u}}}var A=this._sc_gestureAnchorX-b.x,c=Math.abs(A);if(f&&c>=1&&!this._sc_isTouchScrollingVOnly){this._sc_touchVelocityH=b.velocityX;var l=this.get("minimumHorizontalScrollOffset"),g=this.get("maximumHorizontalScrollOffset");d=this._sc_gestureAnchorHOffset+A;this._sc_gestureAnchorX=b.x;this._sc_gestureAnchorHOffset=d;if(d>g){d=d-this._sc_overDragSlip*(d-g)}else{if(d<l){d=d+this._sc_overDragSlip*(l-d)}}this.set("horizontalScrollOffset",d)}var z=this._sc_gestureAnchorY-b.y,a=Math.abs(z);if(w&&a>0&&!this._sc_isTouchScrollingHOnly){this._sc_touchVelocityV=b.velocityY;var h=this.get("minimumVerticalScrollOffset"),r=this.get("maximumVerticalScrollOffset");s=this._sc_gestureAnchorVOffset+z;this._sc_gestureAnchorY=b.y;this._sc_gestureAnchorVOffset=s;if(s>r){s=s-this._sc_overDragSlip*(s-r)}else{if(s<h){s=s+this._sc_overDragSlip*(h-s)}}this.set("verticalScrollOffset",s)}if(p){if(!this._sc_isTouchScaling){var v=Math.abs(this._sc_gestureAnchorTotalD-b.d);this._sc_isTouchScaling=!!b.d&&v>n}var o=this._sc_gestureAnchorD-b.d,q=Math.abs(o);if(q>0){var j=b.d/this._sc_gestureAnchorD,y=this._sc_gestureAnchorScale*j;d=this._sc_horizontalScrollOffset;s=this._sc_verticalScrollOffset;if(!this._sc_containerOffset){var e=this.getPath("containerView.layer");this._sc_containerOffset=SC.offset(e);this._sc_touchCenterX=b.x-this._sc_containerOffset.x;this._sc_touchCenterY=b.y-this._sc_containerOffset.y}this._sc_horizontalPct=(d+this._sc_touchCenterX)/this._sc_contentWidth;this._sc_verticalPct=(s+this._sc_touchCenterY)/this._sc_contentHeight;this.set("scale",y);this._sc_gestureAnchorD=b.d;this._sc_gestureAnchorScale=y}}if(this._sc_passTouchToContentTimer&&(this._sc_isTouchScrollingV||this._sc_isTouchScrollingH||this._sc_isTouchScaling)){this._sc_passTouchToContentTimer.invalidate();this._sc_passTouchToContentTimer=null}},touchCancelled:function(a){return this._sc_touchEnded(a,true)},touchEnd:function(a){return this._sc_touchEnded(a,false)},touchStart:function(e){var d=false,b=this.get("contentView");if(b&&this.get("isEnabledInPane")){var c=this.get("hasTouch");if(c){this._sc_isTouchScrollingV=this._sc_isTouchScrollingH=false;this._sc_isTouchScrollingHOnly=this._sc_isTouchScrollingHOnly=false;if(this._sc_passTouchToContentTimer){this._sc_passTouchToContentTimer.invalidate();this._sc_passTouchToContentTimer=null}}else{this._sc_cancelAnimation();if(this.get("delaysContentTouches")){this._sc_passTouchToContentTimer=this.invokeLater(this._sc_beginTouchesInContent,150,e)}}var a=e.averagedTouchesForView(this,true);this._sc_gestureAnchorX=this._sc_gestureAnchorTotalX=a.x;this._sc_gestureAnchorY=this._sc_gestureAnchorTotalY=a.y;this._sc_gestureAnchorD=this._sc_gestureAnchorTotalD=a.d;this._sc_gestureAnchorScale=this.get("scale");this._sc_gestureAnchorHOffset=this.get("horizontalScrollOffset");this._sc_gestureAnchorVOffset=this.get("verticalScrollOffset");d=true}return d}});SC.ScrollView.mixin({_SC_CONTAINER_LAYOUT_MAP:null,_SC_CONTENT_ADJUST_MAP:null});sc_require("views/scroll_view");SC.MenuScrollView=SC.ScrollView.extend({bottomScrollerView:SC.MenuScrollerView,canScrollVertical:function(){return !!(this.get("hasVerticalScroller")&&this.get("bottomScrollerView")&&this.get("topScrollerView")&&this.get("isVerticalScrollerVisible"))}.property("isVerticalScrollerVisible").cacheable(),classNames:["sc-menu-scroll-view"],controlSize:SC.REGULAR_CONTROL_SIZE,hasHorizontalScroller:false,topScrollerView:SC.MenuScrollerView,_sc_contentViewFrameDidChange:function(){arguments.callee.base.apply(this,arguments);this._sc_repositionScrollers()},_sc_repositionContentViewUnfiltered:function(){var e=this.get("hasVerticalScroller"),f=this.get("maximumVerticalScrollOffset");if(e){var a=this.get("bottomScrollerView"),b=this.get("topScrollerView");b.set("maximum",f);a.set("maximum",f);var d=this._sc_containerHeight,c=this._sc_contentHeight;if(this.get("autohidesVerticalScroller")){this.setIfChanged("isVerticalScrollerVisible",c>d)}}arguments.callee.base.apply(this,arguments)},_sc_repositionScrollersUnfiltered:function(){var g=this.get("hasVerticalScroller"),e=this.get("containerView");if(g&&this.get("autohidesVerticalScroller")){var c=this.get("bottomScrollerView"),a=c.get("scrollerThickness"),i=this.get("maximumVerticalScrollOffset"),d=this.get("topScrollerView"),b=d.get("scrollerThickness"),j=this.get("verticalScrollOffset"),h=c.get("isVisible"),f=d.get("isVisible");if(f){if(j<=b){d.set("isVisible",false);e.adjust("top",0);this.decrementProperty("verticalScrollOffset",b)}}else{if(j>0){d.set("isVisible",true);e.adjust("top",b);this.incrementProperty("verticalScrollOffset",b)}}if(h){if(j>=i-a){c.set("isVisible",false);e.adjust("bottom",0);this.incrementProperty("verticalScrollOffset",a)}}else{if(j<i){c.set("isVisible",true);e.adjust("bottom",a);this.decrementProperty("verticalScrollOffset",a)}}}},createChildViews:function(){var e=[],h=this.get("autohidesVerticalScroller");var d=this.get("containerView");d=this.containerView=this.createChildView(d,{contentView:this.contentView});this.contentView=d.get("contentView");e.push(d);if(!this.get("hasVerticalScroller")){this.topScrollerView=null;this.bottomScrollerView=null}else{var f=this.get("controlSize"),c=this.get("topScrollerView");if(c==null){c=SC.MenuScrollerView}c=this.topScrollerView=this.createChildView(c,{controlSize:f,scrollDown:false,isVisible:!h,layout:{height:0},value:this.get("verticalScrollOffset"),valueBinding:".parentView.verticalScrollOffset",minimum:this.get("minimumVerticalScrollOffset"),maximum:this.get("maximumVerticalScrollOffset")});var b=c.get("scrollerThickness");c.adjust("height",b);e.push(c);var a=this.get("bottomScrollerView");if(a==null){a=SC.MenuScrollerView}a=this.bottomScrollerView=this.createChildView(a,{controlSize:f,scrollDown:true,isVisible:!h,layout:{bottom:0,height:0},value:this.get("verticalScrollOffset"),valueBinding:".parentView.verticalScrollOffset",minimum:this.get("minimumVerticalScrollOffset"),maximum:this.get("maximumVerticalScrollOffset")});var g=a.get("scrollerThickness");a.adjust("height",g);e.push(a);if(!h){d.adjust("top",b);d.adjust("bottom",g)}}this.childViews=e}});sc_require("views/scroller");SC.MenuScrollerView=SC.ScrollerView.extend({classNames:["sc-menu-scroller-view"],scrollDown:false,verticalLineScroll:20,init:function(){switch(this.get("controlSize")){case SC.TINY_CONTROL_SIZE:this.set("scrollerThickness",SC.MenuScrollerView.TINY_SCROLLER_THICKNESS);break;case SC.SMALL_CONTROL_SIZE:this.set("scrollerThickness",SC.MenuScrollerView.SMALL_SCROLLER_THICKNESS);break;case SC.REGULAR_CONTROL_SIZE:this.set("scrollerThickness",SC.MenuScrollerView.REGULAR_SCROLLER_THICKNESS);break;case SC.LARGE_CONTROL_SIZE:this.set("scrollerThickness",SC.MenuScrollerView.LARGE_SCROLLER_THICKNESS);break;case SC.HUGE_CONTROL_SIZE:this.set("scrollerThickness",SC.MenuScrollerView.HUGE_SCROLLER_THICKNESS);break}return arguments.callee.base.apply(this,arguments)},render:function(a,c){a.addClass("sc-vertical");a.addClass(this.get("controlSize"));if(c){var b=this.get("scrollDown")?"arrowDown":"arrowUp";a.push('<span class="scrollArrow '+b+'">&nbsp;</span>')}},mouseEntered:function(a){this.set("isMouseOver",YES);this._invokeScrollOnMouseOver()},mouseExited:function(a){this.set("isMouseOver",NO)},_scrollMenu:function(){var a=this.get("value");if(this.get("scrollDown")){a=a+this.verticalLineScroll;a=Math.min(a,this.get("maximum"))}else{a=a-this.verticalLineScroll;a=Math.max(a,this.get("minimum"))}this.set("value",a);return YES},_invokeScrollOnMouseOver:function(){this._scrollMenu();if(this.get("isMouseOver")){this.invokeLater(this._invokeScrollOnMouseOver,50)}}});SC.MenuScrollerView.REGULAR_SCROLLER_THICKNESS=18;SC.MenuScrollerView.TINY_SCROLLER_THICKNESS=10;SC.MenuScrollerView.SMALL_SCROLLER_THICKNESS=14;SC.MenuScrollerView.LARGE_SCROLLER_THICKNESS=23;SC.MenuScrollerView.HUGE_SCROLLER_THICKNESS=26;sc_require("views/workspace");SC.TO_LEFT="TOLEFT";SC.TO_RIGHT="TORIGHT";SC.NavigationView=SC.WorkspaceView.extend({_views:null,_current:null,navigationContentView:SC.View,init:function(){arguments.callee.base.apply(this,arguments);this._views=[]},createChildViews:function(){arguments.callee.base.apply(this,arguments);var a=this.get("navigationContentView");if(a.isClass){a=this.createChildView(a)}this._defaultContent=this.navigationContentView=a;this.contentView.appendChild(a)},changeNavigationContent:function(a){var c=null,b=null;if(a){c=a.get("topToolbar");b=a.get("bottomToolbar")}if(c&&c.isClass){a.set("topToolbar",c=c.create())}if(b&&b.isClass){a.set("bottomToolbar",b=b.create())}this.beginPropertyChanges();this._current=a;this.set("navigationContentView",a?a:this._defaultContent);this.set("topToolbar",c);this.set("bottomToolbar",b);this.endPropertyChanges()},push:function(a){this._currentDirection=this._current?SC.TO_LEFT:null;if(this._current){this._views.push(this._current)}this.changeNavigationContent(a)},pop:function(){this._currentDirection=SC.TO_RIGHT;var a=this._views.pop();this.changeNavigationContent(a)},popToView:function(b){this._currentDirection=SC.TO_RIGHT;var d=this._views,a=d.length-1,c=d[a];while(c&&c!==b){this._views.pop();a--;c=d[a]}this.changeNavigationContent(c)},topToolbarDidChange:function(){var b=this.activeTopToolbar,a=this.get("topToolbar");if(b){if(this._currentDirection!==null){b.set("buildDirection",this._currentDirection);this.buildOutChild(b)}else{this.removeChild(b)}}if(a){if(this._currentDirection!==null){a.set("buildDirection",this._currentDirection);this.buildInChild(a)}else{this.appendChild(a)}}this.activeTopToolbar=a;this.invokeOnce("childDidChange")}.observes("topToolbar"),bottomToolbarDidChange:function(){var b=this.activeBottomToolbar,a=this.get("bottomToolbar");if(b){if(this._currentDirection!==null){b.set("buildDirection",this._currentDirection);this.buildOutChild(b)}else{this.removeChild(b)}}if(a){if(this._currentDirection!==null){a.set("buildDirection",this._currentDirection);this.buildInChild(a)}else{this.appendChild(a)}}this.activeBottomToolbar=a;this.invokeOnce("childDidChange")}.observes("topToolbar"),contentViewDidChange:function(){var b=this.activeNavigationContentView,a=this.get("navigationContentView");if(!a.isNavigationBuilder){a.mixin(SC.NavigationBuilder)}this._pendingBuildOut=b;this._pendingBuildIn=a;this.activeNavigationContentView=a;this.invokeOnce("childDidChange")}.observes("navigationContentView"),childDidChange:function(){var a=this._pendingBuildIn,b=this._pendingBuildOut;if(b){if(this._currentDirection!==null){b.set("buildDirection",this._currentDirection);this.contentView.buildOutChild(b)}else{this.contentView.removeChild(b)}}this._scws_tile();if(a){if(this._currentDirection!==null){a.set("buildDirection",this._currentDirection);this.contentView.buildInChild(a)}else{this.contentView.appendChild(a)}}}});sc_require("views/toolbar");SC.NavigationBarView=SC.ToolbarView.extend(SC.Gesturable,{init:function(){arguments.callee.base.apply(this,arguments);if(!SC.Animatable){SC.Logger.error("NavigationBarView requires SC.Animatable. Please make your app or framework require the animation framework. CRASH.")}},mixinAnimatable:function(){this.mixin(SC.Animatable);this.transitions=this.navigationTransitions},navigationTransitions:{opacity:{duration:0.25,action:"didFinishTransition"}},style:{opacity:1},gestures:["swipeGesture"],swipeGesture:SC.SwipeGesture,swipe:function(d,h,f){var e=(f===SC.SWIPE_LEFT)?"isSwipeLeft":"isSwipeRight",c=this.get("childViews"),g,b,a=c.get("length");for(b=0;b<a;b++){g=c[b];if(g.get(e)){h.makeTouchResponder(g);h.end();return}}},resetBuild:function(){if(!this.isAnimatable){this.mixinAnimatable()}},didFinishTransition:function(){if(this.isBuildingIn){this.buildInDidFinish()}else{if(this.isBuildingOut){this.buildOutDidFinish()}}},preBuildIn:function(){this.disableAnimation();this.adjust("opacity",0).updateLayout();this.enableAnimation();var c=this.get("childViews"),d,b,a=c.get("length");for(b=0;b<a;b++){d=c[b];if(d.disableNavigationTransition){continue}if(!d._nv_mixedIn){this.mixinNavigationChild(d)}d.disableAnimation();d.transform(this.buildDirection===SC.TO_LEFT?100:-100);d.enableAnimation()}},buildIn:function(){this.preBuildIn();this.invokeLater("startBuildIn",10)},startBuildIn:function(){this.adjust("opacity",1);var c=this.get("childViews"),d,b,a=c.get("length");for(b=0;b<a;b++){d=c[b];if(d.disableNavigationTransition){continue}d.transform(0)}},buildOut:function(){this.adjust("opacity",0);var c=this.get("childViews"),d,b,a=c.get("length");for(b=0;b<a;b++){d=c[b];if(d.disableNavigationTransition){continue}if(!d._nv_mixedIn){this.mixinNavigationChild(d)}d.transform(this.buildDirection===SC.TO_LEFT?-100:100)}},mixinNavigationChild:function(a){if(a.isAnimatable){return}a.mixin(SC.Animatable);a.mixin({transitions:{transform:{timing:SC.Animatable.TRANSITION_EASE_IN_OUT,duration:0.25}},naturalLayout:a.get("layout"),transform:function(b){if(SC.platform.supportsCSS3DTransforms){this.adjust("transform","translate3d("+b+"px,0px,0px)")}else{this.adjust("transform","translate("+b+"px,0px)")}}});a._nv_mixedIn=YES}});sc_require("views/button");SC.PopupButtonView=SC.ButtonView.extend({classNames:["sc-popup-button"],renderDelegateName:"popupButtonRenderDelegate",preferMatrix:null,menu:null,shouldLoadInBackground:NO,init:function(){arguments.callee.base.apply(this,arguments);this._setupMenu();if(this.get("shouldLoadInBackground")){SC.backgroundTaskQueue.push(SC.PopupButtonMenuLoader.create({popupButton:this}))}},_setupMenu:function(){var a=this.get("instantiatedMenu");if(this.isActiveBinding){this.isActiveBinding.disconnect()}this.isActiveBinding=null;if(a&&!a.isClass){this.isActiveBinding=this.bind("isActive",a,"isVisibleInWindow")}},_popup_menuDidChange:function(){this._setupMenu()}.observes("menu"),isActive:NO,_instantiateMenu:function(){var a=this.get("menu");if(!a||!a.isClass){return}this.menu=a.create();this._setupMenu()},instantiatedMenu:function(){var a=this.get("menu");if(a&&a.isClass){this._instantiateMenu();a=this.get("menu")}return a}.property("menu").cacheable(),action:function(a){var b=this.get("instantiatedMenu");if(!b){return NO}b.popup(this,this.get("preferMatrix"));return YES},mouseDown:function(a){if(a.which&&a.which!==1){return false}if(!this.get("isEnabledInPane")){return YES}this._isMouseDown=YES;this._action();this._menuRenderedTimestamp=0;var b=this;setTimeout(function(){SC.run(function(){b._menuRenderedTimestamp=Date.now()})},1);this.becomeFirstResponder();return YES},mouseUp:function(b){var d=new Date().getTime(),c=this._menuRenderedTimestamp,e=this.get("instantiatedMenu"),f=SC.platform.touch,a;if(c===0){c=Date.now()}if(e){a=e.getPath("rootMenu.targetMenuItem");if(a){if(!a.performAction()){e.remove()}}else{if(!f&&(d-c>SC.ButtonView.CLICK_AND_HOLD_DELAY)){e.remove()}}}this._isMouseDown=NO;arguments.callee.base.apply(this,arguments);return YES},mouseExited:function(a){return YES},performKeyEquivalent:function(b,a){if(!this.get("isEnabledInPane")){return NO}var c=this.get("instantiatedMenu");return(!!c&&c.performKeyEquivalent(b,a,YES))},touchStart:function(a){return this.mouseDown(a)},touchEnd:function(a){return this.mouseUp(a)}});SC.PopupButtonMenuLoader=SC.Task.extend({popupButton:null,run:function(){if(this.popupButton){this.popupButton._instantiateMenu()}}});SC.ProgressView=SC.View.extend(SC.Control,{classNames:["sc-progress-view"],displayProperties:["displayValue","ariaValue","minimum","maximum","isIndeterminate","isRunning","isVisibleInWindow"],renderDelegateName:"progressRenderDelegate",value:0.5,valueBindingDefault:SC.Binding.single().notEmpty(),displayValue:function(){var b=this.get("minimum")||0,c=this.get("maximum")||1,a=this.get("value")||0;a=(a-b)/(c-b);if(isNaN(a)){a=0}if(a<0){a=0}if(a>1){a=1}return a}.property("value","maximum","minimum").cacheable(),ariaRole:"progressbar",ariaValue:function(){return this.get("value")}.property("value").cacheable(),minimum:0,minimumBindingDefault:SC.Binding.single().notEmpty(),contentMinimumKey:null,maximum:1,maximumBindingDefault:SC.Binding.single().notEmpty(),contentMaximumKey:null,isIndeterminate:NO,isIndeterminateBindingDefault:SC.Binding.bool(),isRunning:NO,isRunningBindingDefault:SC.Binding.bool(),contentIsIndeterminateKey:null,contentPropertyDidChange:function(c,a){var b=this.get("content");this.beginPropertyChanges().updatePropertyFromContent("value",a,"contentValueKey",b).updatePropertyFromContent("minimum",a,"contentMinimumKey",b).updatePropertyFromContent("maximum",a,"contentMaximumKey",b).updatePropertyFromContent("isIndeterminate",a,"contentIsIndeterminateKey",b).endPropertyChanges()},didCreateLayer:function(){if(this.get("isIndeterminate")&&this.get("isRunning")&&this.get("isVisibleInWindow")){this.displayDidChange()}}});SC.RadioView=SC.View.extend(SC.Control,{acceptsFirstResponder:function(){if(SC.FOCUS_ALL_CONTROLS){return this.get("isEnabledInPane")}return NO}.property("isEnabledInPane"),classNames:["sc-radio-view"],ariaRole:"radiogroup",displayProperties:["displayItems","layoutDirection"],renderDelegateName:"radioGroupRenderDelegate",itemAriaLabeledByKey:null,itemAriaLabelKey:null,value:null,layoutDirection:SC.LAYOUT_VERTICAL,escapeHTML:YES,items:[],itemTitleKey:null,itemWidthKey:null,itemValueKey:null,itemIsEnabledKey:null,itemIconKey:null,itemsDidChange:function(){if(this._items){this._items.removeObserver("[]",this,this.itemContentDidChange)}this._items=this.get("items");if(this._items){this._items.addObserver("[]",this,this.itemContentDidChange)}this.itemContentDidChange()}.observes("items"),itemContentDidChange:function(){this._renderAsFirstTime=YES;this.notifyPropertyChange("displayItems")},displayItems:function(){var k=this.get("items"),p=this.get("value"),h=SC.isArray(p),f=this.get("localize"),d=this.get("itemTitleKey"),e=this.get("itemValueKey"),o=this.get("itemWidthKey"),c=this.get("layoutDirection")===SC.LAYOUT_HORIZONTAL,j=this.get("itemIsEnabledKey"),w=this.get("itemIconKey"),g=this.get("itemAriaLabeledByKey"),y=this.get("itemAriaLabelKey"),v=this._displayItems||[],q=(k)?k.get("length"):0,t,x,l,m,i,u,s,n,b,a,r;for(i=0;i<q;i++){t=k.objectAt(i);if(SC.typeOf(t)===SC.T_ARRAY){x=t[0];m=t[1]}else{if(t){if(d){x=t.get?t.get(d):t[d]}else{x=(t.toString)?t.toString():null}if(o&&c){l=t.get?t.get(o):t[o]}if(e){m=t.get?t.get(e):t[e]}else{m=t}if(j){u=t.get?t.get(j):t[j]}else{u=YES}if(w){s=t.get?t.get(w):t[w]}else{s=null}if(g){a=t.get?t.get(g):t[g]}else{a=null}if(y){r=t.get?t.get(y):t[y]}else{r=null}}else{x=m=s=null;u=NO}}u=u&&this.get("isEnabled");if(t){n=(h)?(p.indexOf(m)>=0):(p===m)}else{n=NO}if(f){x=SC.String.loc(x)}v.push(SC.Object.create({title:x,icon:s,width:l,value:m,isEnabled:u,isSelected:(h&&p.indexOf(m)>=0&&p.length===1)||(p===m),isMixed:(h&&p.indexOf(m)>=0),isActive:this._activeRadioButton===i,theme:this.get("theme"),renderState:{}}))}return v}.property("isEnabled","value","items","itemTitleKey","itemWidthKey","itemValueKey","itemIsEnabledKey","localize","itemIconKey","itemAriaLabeledByKey","itemAriaLabelKey").cacheable(),mouseDown:function(a){if(a.which&&a.which!==1){return false}if(!this.get("isEnabledInPane")){return YES}var d=this.get("renderDelegate"),c=this.get("renderDelegateProxy"),f=this.$(),b=d.indexForEvent(c,f,a);this._activeRadioButton=b;if(b!==undefined){var e=this.get("displayItems")[b];if(e.get("isEnabled")){e.set("isActive",YES);d.updateRadioAtIndex(c,f,b)}}a.allowDefault();return YES},mouseUp:function(a){if(!this.get("isEnabledInPane")){return YES}var d=this.get("renderDelegate"),c=this.get("renderDelegateProxy"),f=this.$(),g=this.get("displayItems"),b=d.indexForEvent(c,f,a);if(this._activeRadioButton!==undefined&&b!==this._activeRadioButton){g[this._activeRadioButton].set("isActive",NO);d.updateRadioAtIndex(c,f,this._activeRadioButton)}this._activeRadioButton=undefined;if(b!==undefined){var e=this.get("displayItems")[b];if(e.get("isEnabled")){e.set("isActive",NO);d.updateRadioAtIndex(c,f,b);this.set("value",e.value)}}a.allowDefault();return YES},keyDown:function(j){if(!this.get("isEnabledInPane")){return YES}if(j.which===9||j.keyCode===9){var h=j.shiftKey?this.get("previousValidKeyView"):this.get("nextValidKeyView");if(h){h.becomeFirstResponder()}else{j.allowDefault()}return YES}if(j.which>=37&&j.which<=40){var g=this.get("renderDelegate"),f=this.get("renderDelegateProxy"),c=this.$(),e=this.get("displayItems"),b=this.get("value");for(var d=0,a=e.length;d<a;d++){if(b===e[d].value){break}}if(j.which===37||j.which===38){if(d<=0){d=e.length-1}else{d--}}if(j.which===39||j.which===40){if(d>=e.length-1){d=0}else{d++}}g.updateRadioAtIndex(f,c,d);this.set("value",e[d].value)}j.allowDefault();return NO},touchStart:function(a){return this.mouseDown(a)},touchEnd:function(a){return this.mouseUp(a)}});SC.SceneView=SC.ContainerView.extend({scenes:null,transitionBackward:SC.ContainerView.PUSH,transitionBackwardOptions:{duration:0.25,direction:"right"},transitionForward:SC.ContainerView.PUSH,transitionForwardOptions:{duration:0.25,direction:"left"},replaceContent:function(b){var a=this.get("scenes"),c=this.get("nowShowing"),e=a?a.indexOf(this._lastNowShowingView):-1,d=a?a.indexOf(c):-1;this._lastNowShowingView=c;if(e<d){this.transitionSwap=this.transitionForward;this.transitionSwapOptions=this.transitionForwardOptions}else{this.transitionSwap=this.transitionBackward;this.transitionSwapOptions=this.transitionBackwardOptions}arguments.callee.base.apply(this,arguments)}});SC.SegmentView=SC.View.extend(SC.Control,{ariaRole:"button",isSegment:YES,classNames:["sc-segment-view"],toolTip:null,isActive:NO,isSelected:NO,layoutDirection:SC.LAYOUT_HORIZONTAL,controlSize:null,supportFocusRing:NO,displayProperties:["icon","displayTitle","value","displayToolTip","isDefault","isCancel","width","isSegment","isFirstSegment","isMiddleSegment","isLastSegment","isOverflowSegment","index","layoutDirection"],renderDelegateName:"segmentRenderDelegate",useStaticLayout:YES,title:"",value:null,icon:null,localize:NO,keyEquivalent:null,escapeHTML:YES,needsEllipsis:YES,displayTitle:function(){var a=this.get("title");if(this.get("localize")){a=SC.String.loc(a)}return a}.property("title","localize").cacheable(),width:null,localItem:null,widthDidChange:function(){this.adjust("width",this.get("width"))}.observes("width"),updateItem:function(d,c){var g=d.get("itemKeys"),f,a=d.get("viewKeys"),e,b;for(b=g.get("length")-1;b>=0;b--){f=d.get(g.objectAt(b));e=a.objectAt(b);if(!SC.none(c.get(f))){this.set(e,c.get(f))}}this.set("localItem",c)}});sc_require("views/segment");SC.SegmentedView=SC.View.extend(SC.Control,{acceptsFirstResponder:function(){if(SC.FOCUS_ALL_CONTROLS){return this.get("isEnabledInPane")}return NO}.property("isEnabledInPane").cacheable(),ariaRole:"group",classNames:["sc-segmented-view"],theme:"square",value:null,allowsEmptySelection:NO,allowsMultipleSelection:NO,selectSegmentWhenTriggeringAction:NO,localize:YES,align:SC.ALIGN_CENTER,layoutDirection:SC.LAYOUT_HORIZONTAL,items:null,itemTitleKey:null,itemValueKey:null,itemIsEnabledKey:null,itemIconKey:null,itemWidthKey:null,itemActionKey:null,itemTargetKey:null,itemLayerIdKey:null,itemKeyEquivalentKey:null,shouldHandleOverflow:YES,overflowTitle:"&raquo;",overflowToolTip:"More…",overflowIcon:null,segmentViewClass:SC.SegmentView,shouldAutoResize:NO,itemKeys:["itemTitleKey","itemValueKey","itemIsEnabledKey","itemIconKey","itemWidthKey","itemToolTipKey","itemKeyEquivalentKey","itemLayerIdKey"],viewKeys:["title","value","isEnabled","icon","width","toolTip","keyEquivalent","layerId"],init:function(){arguments.callee.base.apply(this,arguments);this.shouldHandleOverflowDidChange();this.itemsDidChange()},shouldHandleOverflowDidChange:function(){var c=this.get("overflowView");if(this.get("shouldHandleOverflow")){var d=this.get("overflowTitle"),a=this.get("overflowToolTip"),b=this.get("overflowIcon");c=this.get("segmentViewClass").create({controlSize:this.get("controlSize"),escapeHTML:false,localize:this.get("localize"),title:d,toolTip:a,icon:b,isLastSegment:YES,isOverflowSegment:YES,layoutDirection:this.get("layoutDirection")});this.appendChild(c);this.set("overflowView",c);this.invokeLast(this.remeasure)}else{if(c){this.removeChildAndDestroy(c);this.set("overflowView",null)}}}.observes("shouldHandleOverflow"),itemsDidChange:function(){var m=this.get("items")||[],c,g,n=this.get("childViews"),h,d=this.get("overflowView"),o=this.get("value"),b,p=this.get("itemKeys"),a,l=this.get("segmentViewClass"),f,e;var k=this.get("shouldHandleOverflow")?n.get("length")-1:n.get("length");if(k>m.get("length")){for(f=k-1;f>=m.get("length");f--){h=n.objectAt(f);c=h.get("localItem");if(c instanceof SC.Object){for(e=p.get("length")-1;e>=0;e--){a=this.get(p.objectAt(e));if(a){c.removeObserver(a,this,this.itemContentDidChange)}}}if(SC.isArray(o)){o.removeObject(c)}else{if(o===c){o=null}}this.removeChildAndDestroy(h)}this.set("value",o)}else{if(k<m.get("length")){for(f=k;f<m.get("length");f++){h=l.create({controlSize:this.get("controlSize"),localize:this.get("localize"),layoutDirection:this.get("layoutDirection")});this.insertBefore(h,d)}}}n=this.get("childViews");for(f=0;f<m.get("length");f++){c=m.objectAt(f);h=n.objectAt(f);g=h.get("localItem");if(g instanceof SC.Object&&!m.contains(g)){for(e=p.get("length")-1;e>=0;e--){a=this.get(p.objectAt(e));if(a){g.removeObserver(a,this,this.itemContentDidChange)}}}if(SC.none(c)){continue}if(SC.typeOf(c)===SC.T_STRING){c=SC.Object.create({title:c.humanize().titleize(),value:c});this.set("itemTitleKey","title");this.set("itemValueKey","value")}else{if(SC.typeOf(c)===SC.T_HASH){c=SC.Object.create(c)}else{if(c instanceof SC.Object){for(e=p.get("length")-1;e>=0;e--){a=this.get(p.objectAt(e));if(a){c.removeObserver(a,this,this.itemContentDidChange);c.addObserver(a,this,this.itemContentDidChange,f)}}}else{SC.Logger.error("SC.SegmentedView items may be Strings, Objects (ie. Hashes) or SC.Objects only")}}}b=NO;if(SC.isArray(o)?o.indexOf(c.get(this.get("itemValueKey")))>=0:o===c.get(this.get("itemValueKey"))){b=YES}h.set("isSelected",b);h.set("index",f);h.set("isFirstSegment",f===0);h.set("isMiddleSegment",f<m.get("length")-1&&f>0);h.set("isLastSegment",f===m.get("length")-1);h.updateItem(this,c)}if(this.get("shouldHandleOverflow")){this.invokeLast(this.remeasure)}}.observes("*items.[]"),itemContentDidChange:function(d,c,a,b){var e=this.get("childViews"),f;f=e.objectAt(b);if(f){f.updateItem(this,d);if(this.get("shouldHandleOverflow")){this.invokeLast(this.remeasure)}}},viewDidResize:function(){this._sc_viewFrameDidChange();var b=this.get("layoutDirection")===SC.LAYOUT_HORIZONTAL,a=b?this.$().width():this.$().height();if(this.get("shouldHandleOverflow")&&(this.get("isOverflowing")||a<=this.cachedMinimumDim)){this.invokeLast(this.remeasure)}},isVisibleInWindowDidChange:function(){if(this.get("shouldHandleOverflow")){this.invokeLast(this.remeasure)}}.observes("isVisibleInWindow"),remeasure:function(){if(!this.get("shouldHandleOverflow")){return}var c=this.get("childViews"),b;if(this.get("isVisibleInWindow")){b=this.get("overflowView");b.set("isVisible",YES);for(var a=c.get("length")-1;a>=0;a--){c.objectAt(a).set("isVisible",YES)}this.cachedDims=this.segmentDimensions();this.cachedOverflowDim=this.overflowSegmentDim();this.adjustOverflow()}},adjustOverflow:function(){if(!this.get("shouldHandleOverflow")){return}var j=this.get("childViews"),f,m=this.get("value"),c=this.get("overflowView"),k=this.get("layoutDirection")===SC.LAYOUT_HORIZONTAL,p=k?this.$().width():this.$().height(),e=0,o,b,d,a=NO,n=this.get("shouldAutoResize"),g=k?"width":"height",l=!SC.none(this.getPath("layout.%@".fmt(g))),h=n&&l;if(j.get("length")!==this.cachedDims.length+1){return}a=NO;c.set("isSelected",NO);this.overflowItems=[];b=this.cachedDims.length;for(d=0;d<b;d++){f=j.objectAt(d);e+=this.cachedDims[d];if(!a&&!h){o=(d===b-1)?e:e+this.cachedOverflowDim;if(o>p){a=YES}}if(a){this.overflowItems.pushObject(f.get("localItem"));f.set("isVisible",NO);if(d===0){c.set("isFirstSegment",YES)}if(SC.isArray(m)?m.indexOf(f.get("value"))>=0:m===f.get("value")){c.set("isSelected",YES)}}else{f.set("isVisible",YES);if(d===0){c.set("isFirstSegment",NO)}}}c.set("isVisible",a);this.setIfChanged("isOverflowing",a);if(h){this.adjust(g,this.isOverflowing?this.cachedMinimumDim:e)}this.cachedMinimumDim=e+this.cachedOverflowDim},segmentDimensions:function(){var b=this.get("childViews"),a,e,h=[],g=this.get("layoutDirection")===SC.LAYOUT_HORIZONTAL;for(var c=0,d=b.length;c<d-1;c++){a=b[c];e=a.get("frame");h[c]=g?e.width:e.height}return h},overflowSegmentDim:function(){var b=this.get("childViews"),a,c,d=this.get("layoutDirection")===SC.LAYOUT_HORIZONTAL;a=b.length&&b[b.length-1];if(a){c=a.get("frame");return d?c.width:c.height}return 0},indexForClientPosition:function(b,h){var d=this.get("childViews"),g,e,c,f,a;a={x:b,y:h};for(e=0,g=d.length;e<g;e++){c=d[e];f=c.get("layer").getBoundingClientRect();f={x:f.left,y:f.top,width:(f.right-f.left),height:(f.bottom-f.top)};if(SC.pointInRect(a,f)){return e}}return -1},displayProperties:["align"],renderDelegateName:"segmentedRenderDelegate",displayItemIndexForEvent:function(b){var e=b.target,a=b.clientX,g=b.clientY,d=-1;if(e&&e!==this.get("layer")){if(a===0&&g===0){var f=SC.offset(e);a=f.x+Math.round(e.offsetWidth/2);g=f.y+Math.round(e.offsetHeight/2)}var c=this.get("renderDelegate");if(c&&c.indexForClientPosition){d=c.indexForClientPosition(this,a,g)}else{d=this.indexForClientPosition(a,g)}}return d},keyDown:function(c){var g,h,d,e,f,b;if(c.which===9||c.keyCode===9){var a=c.shiftKey?this.get("previousValidKeyView"):this.get("nextValidKeyView");if(a){a.becomeFirstResponder()}else{c.allowDefault()}return YES}if(!this.get("allowsMultipleSelection")){g=this.get("childViews");e=g.get("length");f=this.get("value");b=SC.isArray(f);if(c.which===39||c.which===40){if(f){for(d=0;d<e-2;d++){h=g.objectAt(d);if(b?(f.indexOf(h.get("value"))>=0):(h.get("value")===f)){this.triggerItemAtIndex(d+1)}}}else{this.triggerItemAtIndex(0)}return YES}else{if(c.which===37||c.which===38){if(f){for(d=1;d<e-1;d++){h=g.objectAt(d);if(b?(f.indexOf(h.get("value"))>=0):(h.get("value")===f)){this.triggerItemAtIndex(d-1)}}}else{this.triggerItemAtIndex(e-2)}return YES}}}return NO},mouseDown:function(a){if(a.which!==1){return false}var c=this.get("childViews"),e,b;if(!this.get("isEnabledInPane")){return YES}b=this.displayItemIndexForEvent(a);if(b>=0){e=c.objectAt(b);if(e.get("isEnabled")){e.set("isActive",YES)}this.activeChildView=e;var d=this.get("shouldHandleOverflow")?c.get("length")-1:null;if(b===d){this.showOverflowMenu()}else{this._isMouseDown=YES}return YES}else{return NO}},mouseUp:function(a){var c,b;b=this.displayItemIndexForEvent(a);if(this._isMouseDown&&(b>=0)){this.triggerItemAtIndex(b);c=this.activeChildView;if(c){c.set("isActive",NO);this.activeChildView=null}}this._isMouseDown=NO;return YES},mouseMoved:function(a){var d=this.get("childViews"),c,f,b;if(this._isMouseDown){b=this.displayItemIndexForEvent(a);c=this.activeChildView;f=d.objectAt(b);if(f&&f!==c){if(c){c.set("isActive",NO)}if(f.get("isEnabled")){f.set("isActive",YES)}this.activeChildView=f;var e=this.get("shouldHandleOverflow")?d.get("length")-1:null;if(b===e){this.showOverflowMenu();this._isMouseDown=NO}}}return YES},mouseEntered:function(a){var c=this.get("childViews"),e,b;if(this._isMouseDown){b=this.displayItemIndexForEvent(a);var d=this.get("shouldHandleOverflow")?c.get("length")-1:null;if(b===d){this.showOverflowMenu();this._isMouseDown=NO}else{if(b>=0){e=c.objectAt(b);if(e.get("isEnabled")){e.set("isActive",YES)}this.activeChildView=e}}}return YES},mouseExited:function(a){var b;if(this._isMouseDown){b=this.activeChildView;if(b){b.set("isActive",NO)}this.activeChildView=null}return YES},touchStart:function(e){var b=this.get("childViews"),d,a;if(!this.get("isEnabledInPane")){return YES}a=this.displayItemIndexForEvent(e);if(a>=0){d=b.objectAt(a);d.set("isActive",YES);this.activeChildView=d;var c=this.get("shouldHandleOverflow")?b.get("length")-1:null;if(a===c){this.showOverflowMenu()}else{this._isTouching=YES}}return YES},touchEnd:function(c){var b,a;a=this.displayItemIndexForEvent(c);if(this._isTouching&&(a>=0)){this.triggerItemAtIndex(a);b=this.activeChildView;b.set("isActive",NO);this.activeChildView=null;this._isTouching=NO}return YES},touchesDragged:function(a,e){var h=this.touchIsInBoundary(a),d=this.get("childViews"),c,g,b;if(h){if(!this._isTouching){this._touchDidEnter(a)}b=this.displayItemIndexForEvent(a);c=this.activeChildView;g=d[b];if(g&&g!==c){if(c){c.set("isActive",NO)}g.set("isActive",YES);this.activeChildView=g;var f=this.get("shouldHandleOverflow")?d.get("length")-1:null;if(b===f){this.showOverflowMenu();this._isMouseDown=NO}}}else{if(this._isTouching){this._touchDidExit(a)}}this._isTouching=h;return YES},_touchDidExit:function(a){var b;if(this.isTouching){b=this.activeChildView;b.set("isActive",NO);this.activeChildView=null}return YES},_touchDidEnter:function(a){var c=this.get("childViews"),e,b;b=this.displayItemIndexForEvent(a);var d=this.get("shouldHandleOverflow")?c.get("length")-1:null;if(b===d){this.showOverflowMenu();this._isTouching=NO}else{if(b>=0){e=c.objectAt(b);e.set("isActive",YES);this.activeChildView=e}}return YES},triggerItemAtIndex:function(f){var j=this.get("childViews"),e,h,k,b,i;e=j.objectAt(f);if(!e.get("isEnabled")){return this}b=this.get("allowsEmptySelection");i=this.get("allowsMultipleSelection");h=e.get("value");k=this.get("value");if(!i){if(b&&k===h){k=null}else{k=h}}else{if(!k){k=[]}else{if(!SC.isArray(k)){k=[k]}}if(k.indexOf(h)>=0){if(k.get("length")>1||(k.objectAt(0)!==h)||b){k=k.without(h)}}else{k=k.concat(h)}}var m=this.get("itemActionKey"),a=this.get("itemTargetKey"),d,g=null,c=this.getPath("pane.rootResponder"),l;if(m&&(l=this.get("items").objectAt(f))){d=l.get?l.get(m):l[m];if(a){g=l.get?l.get(a):l[a]}if(c){c.sendAction(d,g,this,this.get("pane"),k)}}if(k!==undefined&&(!d||this.get("selectSegmentWhenTriggeringAction"))){this.set("value",k)}d=this.get("action");if(d&&c){c.sendAction(d,this.get("target"),this,this.get("pane"),k)}},selectOverflowItem:function(b){var a=b.get("selectedItem");this.triggerItemAtIndex(a.get("index"));b.removeObserver("selectedItem",this,"selectOverflowItem");this.activeChildView.set("isActive",NO);this.activeChildView=null},showOverflowMenu:function(){var p=this,f=this.get("childViews"),m=this.get("itemValueKey"),g=this.get("itemLayerIdKey"),o=this.overflowItems,l,k,e,j,n,b,d,h;l=o.get("length");k=f.get("length")-1-l;j=this.get("value");e=SC.isArray(j);for(var c=0;c<l;c++){n=o.objectAt(c);if(e?j.indexOf(n.get(m))>=0:j===n.get(m)){n.set("isChecked",YES)}else{n.set("isChecked",NO)}n.set("index",k+c);b=n.get(g);if(b){n.set("overflowLayerId",b+"-overflow-menu-item")}}var a=SC.MenuPane.create({layout:{width:200},items:o,itemTitleKey:this.get("itemTitleKey"),itemIconKey:this.get("itemIconKey"),itemIsEnabledKey:this.get("itemIsEnabledKey"),itemKeyEquivalentKey:this.get("itemKeyEquivalentKey"),itemCheckboxKey:"isChecked",itemLayerIdKey:"overflowLayerId",modalPaneDidClick:function(){arguments.callee.base.apply(this,arguments);this.removeObserver("selectedItem",p,"selectOverflowItem");p.activeChildView.set("isActive",NO);p.activeChildView=null}});d=this.get("layer");h=d.childNodes[d.childNodes.length-1];a.popup(h);a.addObserver("selectedItem",this,"selectOverflowItem")},valueDidChange:function(){var d=this.get("value"),c,f=this.get("childViews"),a=this.get("shouldHandleOverflow")?f.get("length")-1:f.get("length"),g=Infinity,e=this.get("overflowView"),h;if(this.overflowItems){c=this.overflowItems.get("length");g=a-c;e.set("isSelected",NO)}for(var b=a-1;b>=0;b--){h=f.objectAt(b);if(SC.isArray(d)?d.indexOf(h.get("value"))>=0:d===h.get("value")){h.set("isSelected",YES);if(b>=g){e.set("isSelected",YES)}}else{h.set("isSelected",NO)}}}.observes("value")});sc_require("views/button");SC.SelectView=SC.ButtonView.extend({acceptsFirstResponder:function(){return this.get("isEnabledInPane")}.property("isEnabledInPane"),escapeHTML:YES,escapeHTMLBindingDefault:SC.Binding.oneWay().bool(),items:[],itemsBindingDefault:SC.Binding.multiple(),itemTitleKey:null,itemSortKey:null,itemValueKey:null,itemIconKey:null,itemSeparatorKey:"isSeparator",itemIsEnabledKey:"isEnabled",localize:YES,disableSort:YES,classNames:["sc-select-view"],menu:null,_itemList:[],_itemIdx:null,value:null,checkboxEnabled:YES,showCheckbox:YES,emptyName:null,_defaultVal:null,_defaultTitle:null,_defaultIcon:null,theme:"popup",displayProperties:["icon","value","controlSize","escapeHTML","emptyName"],preferMatrix:null,CUSTOM_MENU_ITEM_HEIGHT:20,isActiveBinding:"*menu.isVisibleInWindow",isDefaultPosition:NO,lastMenuWidth:null,exampleView:null,customViewMenuOffsetWidth:0,needsEllipsis:YES,menuPaneHeightPadding:0,menuItemPadding:35,isContextMenuEnabled:NO,supportFocusRing:YES,init:function(){arguments.callee.base.apply(this,arguments);this.itemsDidChange()},leftAlign:function(){switch(this.get("controlSize")){case SC.TINY_CONTROL_SIZE:return SC.SelectView.TINY_OFFSET_X;case SC.SMALL_CONTROL_SIZE:return SC.SelectView.SMALL_OFFSET_X;case SC.REGULAR_CONTROL_SIZE:return SC.SelectView.REGULAR_OFFSET_X;case SC.LARGE_CONTROL_SIZE:return SC.SelectView.LARGE_OFFSET_X;case SC.HUGE_CONTROL_SIZE:return SC.SelectView.HUGE_OFFSET_X}return 0}.property("controlSize"),sortObjects:function(b){if(!this.get("disableSort")){var a=this.get("itemSortKey")||this.get("itemTitleKey");b=b.sort(function(d,c){if(a){d=d.get?d.get(a):d[a];c=c.get?c.get(a):c[a]}return(d<c)?-1:((d>c)?1:0)})}return b},itemsDidChange:function(){var m,i,o,q,u,e,d,t,f,l,a,k,c,h,v,p,n,r,j,g,s,b;i=this.get("items")||[];i=this.sortObjects(i);o=i.length;q=this.get("itemTitleKey");u=this.get("itemIconKey");e=this.get("itemValueKey");d=this.get("itemSeparatorKey");t=this.get("showCheckbox");g=this.get("itemIsEnabledKey");m=this.get("escapeHTML");f=this.get("value");l=this.get("localize");k=[];c=YES;h=0;s=this.get("emptyName");if(!SC.none(s)){s=l?SC.String.loc(s):s;s=m?SC.RenderContext.escapeHTML(s):s;r=SC.Object.create({isSeparator:NO,title:s,icon:null,value:null,isEnabled:YES,checkbox:NO,target:this,action:"displaySelectedItem"});if(SC.none(f)){this.set("title",s)}k.push(r)}i.forEach(function(w){if(w||w===0){a=d?(w.get?w.get(d):w[d]):NO;if(a){r=SC.Object.create({isSeparator:true,value:"_sc_separator_item"})}else{v=q?(w.get?w.get(q):w[q]):w.toString();v=l?SC.String.loc(v):v;v=m?SC.RenderContext.escapeHTML(v):v;p=u?(w.get?w.get(u):w[u]):null;if(SC.none(w[u])){p=null}n=e?(w.get?w.get(e):w[e]):w;if(!SC.none(f)&&!SC.none(n)){b=false;if(SC.kindOf(f,SC.Record)&&SC.kindOf(n,SC.Record)){b=f.get("storeKey")===n.get("storeKey")}if(f===n||b){this.set("title",v);this.set("icon",p)}}if(n===this.get("value")){this.set("_itemIdx",h);c=!t?NO:YES}else{c=NO}j=(w.get?w.get(g):w[g]);if(NO!==j){j=YES}if(SC.none(this._defaultVal)&&j){this._defaultVal=n;this._defaultTitle=v;this._defaultIcon=p}r=SC.Object.create({action:"displaySelectedItem",title:v,icon:p,value:n,isEnabled:j,checkbox:c,target:this})}k.push(r)}h+=1},this);this.set("_itemList",k);var n=this.get("value");if(SC.none(n)){if(SC.none(s)){this.set("value",this._defaultVal);this.set("title",this._defaultTitle);this.set("icon",this._defaultIcon)}else{this.set("title",s)}}this.changeSelectPreferMatrix()}.observes("*items.[]"),_action:function(k){var h,a,i,j,o,m,w,d,v,l,q,n,t,e,f,b,u,g,p;h=this.$(".sc-button-label")[0];var x=SC.SelectView.MENU_WIDTH_OFFSET;if(!this.get("isDefaultPosition")){switch(this.get("controlSize")){case SC.TINY_CONTROL_SIZE:x+=SC.SelectView.TINY_POPUP_MENU_WIDTH_OFFSET;break;case SC.SMALL_CONTROL_SIZE:x+=SC.SelectView.SMALL_POPUP_MENU_WIDTH_OFFSET;break;case SC.REGULAR_CONTROL_SIZE:x+=SC.SelectView.REGULAR_POPUP_MENU_WIDTH_OFFSET;break;case SC.LARGE_CONTROL_SIZE:x+=SC.SelectView.LARGE_POPUP_MENU_WIDTH_OFFSET;break;case SC.HUGE_CONTROL_SIZE:x+=SC.SelectView.HUGE_POPUP_MENU_WIDTH_OFFSET;break}}a=this.get("layer").offsetWidth+x;a=this.get("layer").offsetWidth;i=h.scrollWidth;j=this.get("lastMenuWidth");if(i){o=h.offsetWidth;if(i&&o){a=a+i-o}}if(!j||(a>j)){j=a}m=this.get("_itemList");var r=this.get("customViewClassName");var c="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";c=r?(c+" "+r):c;SC.prepareStringMeasurement("",c);for(l=0,u=m.length;l<u;++l){v=m.objectAt(l);w=SC.measureString(v.title).width;if(!d||(w>d)){d=w}}SC.teardownStringMeasurement();j=(d+this.menuItemPadding>j)?d+this.menuItemPadding:j;var s=SC.RootResponder.responder.get("currentWindowSize").width;if(j>s){j=(s-25)}this.set("lastMenuWidth",j);q=this.get("value");n=this.get("_itemList");t=this.get("controlSize");e=this.get("menuPaneHeightPadding");p=this.get("escapeHTML");f=this.get("exampleView")||SC.MenuItemView.extend({escapeHTML:p});b=SC.MenuPane.create({classNames:["select-button"],items:n,exampleView:f,isEnabled:YES,menuHeightPadding:e,preferType:SC.PICKER_MENU,itemHeightKey:"height",layout:{width:j},controlSize:t,itemWidth:j});if(!b){return NO}b.popup(this,this.preferMatrix);this.set("menu",b);g=this._itemIdx;if(!SC.empty(g)&&g>-1){f=b.menuItemViewForContentIndex(g);if(f){f.becomeFirstResponder()}}this.set("isActive",YES);return YES},displaySelectedItem:function(a){var b=a.get("selectedItem");this.set("value",b.get("value"))},valueDidChange:function(){var b=this._itemList,c=this.get("showCheckbox"),f=this.get("value");for(var d=0,a=b.length;d<a;d++){var e=b[d],g=false;if(f===e.get("value")){g=c;this.set("title",e.get("title"));this.set("icon",e.get("icon"));this.set("_itemIdx",e.get("contentIndex"))}e.set("checkbox",g)}}.observes("value"),changeSelectPreferMatrix:function(){var c=0,g=0;switch(this.get("controlSize")){case SC.TINY_CONTROL_SIZE:c=SC.SelectView.TINY_OFFSET_Y;g=SC.MenuPane.TINY_MENU_ITEM_HEIGHT;break;case SC.SMALL_CONTROL_SIZE:c=SC.SelectView.SMALL_OFFSET_Y;g=SC.MenuPane.SMALL_MENU_ITEM_HEIGHT;break;case SC.REGULAR_CONTROL_SIZE:c=SC.SelectView.REGULAR_OFFSET_Y;g=SC.MenuPane.REGULAR_MENU_ITEM_HEIGHT;break;case SC.LARGE_CONTROL_SIZE:c=SC.SelectView.LARGE_OFFSET_Y;g=SC.MenuPane.LARGE_MENU_ITEM_HEIGHT;break;case SC.HUGE_CONTROL_SIZE:c=SC.SelectView.HUGE_OFFSET_Y;g=SC.MenuPane.HUGE_MENU_ITEM_HEIGHT;break}var e=c,b=this.get("_itemIdx"),a=this.get("leftAlign"),f,d;if(this.get("isDefaultPosition")){f=[1,0,3];this.set("preferMatrix",f)}else{if(b){e=b*g+c}d=[a,-e,2];this.set("preferMatrix",d)}},mouseDown:function(a){if(a.which!==1){return false}if(!this.get("isEnabledInPane")){return YES}this.set("isActive",YES);this._isMouseDown=YES;this.becomeFirstResponder();this._action();return YES},mouseUp:function(b){var c=this.get("menu"),a;if(c){a=c.getPath("rootMenu.targetMenuItem");if(a&&c.get("mouseHasEntered")){if(!a.performAction()){c.remove()}}else{if(b.timeStamp-this._mouseDownTimestamp>400){c.remove()}}}this._isMouseDown=NO;this.set("isActive",NO);return YES},mouseExited:function(){return YES},keyDown:function(a){if(this.interpretKeyEvents(a)){return YES}else{return arguments.callee.base.apply(this,arguments)}},moveUp:function(a){this._action();return YES},moveDown:function(a){this._action();return YES},cancel:function(a){this.resignFirstResponder()},_button_isSelectedDidChange:function(){}.observes("isSelected")});SC.SelectView.TINY_OFFSET_X=0;SC.SelectView.TINY_OFFSET_Y=0;SC.SelectView.TINY_POPUP_MENU_WIDTH_OFFSET=0;SC.SelectView.SMALL_OFFSET_X=-18;SC.SelectView.SMALL_OFFSET_Y=3;SC.SelectView.SMALL_POPUP_MENU_WIDTH_OFFSET=7;SC.SelectView.REGULAR_OFFSET_X=-17;SC.SelectView.REGULAR_OFFSET_Y=0;SC.SelectView.REGULAR_POPUP_MENU_WIDTH_OFFSET=4;SC.SelectView.LARGE_OFFSET_X=-17;SC.SelectView.LARGE_OFFSET_Y=6;SC.SelectView.LARGE_POPUP_MENU_WIDTH_OFFSET=3;SC.SelectView.HUGE_OFFSET_X=0;SC.SelectView.HUGE_OFFSET_Y=0;SC.SelectView.HUGE_POPUP_MENU_WIDTH_OFFSET=0;SC.SelectView.MENU_WIDTH_OFFSET=-2;SC.SliderView=SC.View.extend(SC.Control,{classNames:"sc-slider-view",ariaRole:"slider",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,markSteps:false,updateOnScroll:true,displayProperties:["displayValue","markSteps"],ariaValue:function(){return this.get("value")}.property("value").cacheable(),renderDelegateName:"sliderRenderDelegate",displayValue:function(){return this._displayValueForValue(this.get("value"))}.property("value","minimum","maximum","step").cacheable(),steps:function(){var d=this.get("step");if(!d){return null}var c=this.get("minimum"),a=this.get("maximum"),e=c,b=[];while(e<a){b.push(e);e+=d;e=Math.round(e/d)*d}b.push(a);return b}.property("minimum","maximum","step").cacheable(),stepPositions:function(){var c=this.get("steps");if(!c){return null}var f=c[0],b=c[c.length-1],d=[],a=c.length,e;for(e=0;e<a;e++){d[e]=Math.round((c[e]-f)/(b-f)*1000)/1000}return d}.property("steps").cacheable(),_displayValueForValue:function(d){var b=this.get("minimum"),a=this.get("maximum"),c=this.get("step");d=Math.min(Math.max(d,b),a);if(!SC.none(c)&&c!==0){d=Math.round(d/c)*c}d=Math.round((d-b)/(a-b)*100);return d},_sc_clearMouseJustDown:function(){this._sc_isMouseJustDown=NO},_isMouseDown:NO,_sc_isMouseJustDown:NO,_sc_clearMouseJustDownTimer:null,mouseDown:function(a){if(a.which&&a.which!==1){return false}if(!this.get("isEnabledInPane")){return YES}this.set("isActive",YES);this._isMouseDown=YES;if(this._sc_clearMouseJustDownTimer){this._sc_clearMouseJustDownTimer.invalidate();this._sc_clearMouseJustDownTimer=null}this._sc_isMouseJustDown=NO;return this._triggerHandle(a,YES)},mouseDragged:function(a){return this._isMouseDown?this._triggerHandle(a):YES},mouseUp:function(a){if(this._isMouseDown){this.set("isActive",NO)}var b=this._isMouseDown?this._triggerHandle(a):YES;this._isMouseDown=NO;this._sc_isMouseJustDown=YES;this._sc_clearMouseJustDownTimer=this.invokeLater(this._sc_clearMouseJustDown,250);return b},mouseWheel:function(b){if(!this.get("isEnabledInPane")){return NO}if(!this.get("updateOnScroll")){return NO}if(this._isMouseDown||this._sc_isMouseJustDown){return NO}var d=this.get("minimum"),a=this.get("maximum"),e=this.get("step")||((a-d)/20),c=this.get("value")+((b.wheelDeltaX+b.wheelDeltaY)*e),f=Math.round(c/e)*e;if(c<d){this.setIfChanged("value",d)}else{if(c>a){this.setIfChanged("value",a)}else{this.setIfChanged("value",c)}}return YES},touchStart:function(a){return this.mouseDown(a)},touchEnd:function(a){return this.mouseUp(a)},touchesDragged:function(a){return this.mouseDragged(a)},_triggerHandle:function(i,e){var a=this.get("frame").width,c=this.get("minimum"),f=this.get("maximum"),b=this.get("step"),h=this.get("value"),d;if(e){d=this.convertFrameFromView({x:i.pageX}).x;this._evtDiff=i.pageX-d}else{d=i.pageX-this._evtDiff}d=Math.max(0,Math.min(d/a,1));if(e){var g=this.get("value");g=(g-c)/(f-c);if(Math.abs(g*a-d*a)<16){this._offset=g-d}else{this._offset=0}}d=Math.max(0,Math.min(d+this._offset,1));d=c+((f-c)*d);if(!SC.none(b)&&b!==0){d=Math.round(d/b)*b}if(Math.abs(h-d)>=0.01){this.set("value",d)}return YES},acceptsFirstResponder:function(){if(SC.FOCUS_ALL_CONTROLS){return this.get("isEnabledInPane")}return NO}.property("isEnabledInPane"),keyDown:function(h){if(h.which===9||h.keyCode===9){var f=h.shiftKey?this.get("previousValidKeyView"):this.get("nextValidKeyView");if(f){f.becomeFirstResponder()}else{h.allowDefault()}return YES}if(h.which>=33&&h.which<=40){var d=this.get("minimum"),g=this.get("maximum"),b=this.get("step"),i=g-d,a=0,c,e=this.get("value");if(h.which===37||h.which===38||h.which===34){if(SC.none(b)||b===0){if(i<100){a=e-1}else{c=Math.abs(i/100);if(c<2){c=2}a=e-c}}else{a=e-b}}if(h.which===39||h.which===40||h.which===33){if(SC.none(b)||b===0){if(i<100){a=e+2}else{c=Math.abs(i/100);if(c<2){c=2}a=e+c}}else{a=e+b}}if(h.which===36){a=g}if(h.which===35){a=d}if(a>=d&&a<=g){this.set("value",a)}}else{h.allowDefault();return NO}return YES},contentKeys:{contentValueKey:"value",contentMinimumKey:"minimum",contentMaximumKey:"maximum",contentIsIndeterminateKey:"isIndeterminate"}});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,b){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(f,c){var e=this.get("content");var h=this.outlet("labelView");if(e===null){h.setIfChanged("isVisible",NO);this.setIfChanged("hasGroupTitle",NO);return}else{h.setIfChanged("isVisible",YES);this.setIfChanged("hasGroupTitle",YES)}var b=this.getDelegateProperty("groupTitleKey",this.displayDelegate);if((c=="*")||(b&&(c==b))){var g=(e&&e.get&&b)?e.get(b):e;if(g!=this._title){this._title=g;if(g){g=g.capitalize()}h.set("title",g)}}var d=this.getDelegateProperty("groupVisibleKey",this.displayDelegate);if((c=="*")||(d&&(c==d))){if(d){h.removeClassName("no-disclosure");var a=(e&&e.get)?!!e.get(d):YES;if(a!=this.get("isGroupVisible")){this.set("isGroupVisible",a);h.set("value",a)}}else{h.addClassName("no-disclosure")}}},disclosureValueDidChange:function(c){if(c==this.get("isGroupVisible")){return}var b=this.get("content");var a=this.getDelegateProperty("groupVisibleKey",this.displayDelegate);if(b&&b.set&&a){b.set(a,c)}this.set("isGroupVisible",c);if(this.owner&&this.owner.updateChildren){this.owner.updateChildren(true)}},labelView:SC.DisclosureView.extend({value:YES,_valueObserver:function(){if(this.owner){this.owner.disclosureValueDidChange(this.get("value"))}}.observes("value")})});sc_require("views/list");sc_require("views/source_list_group");SC.SourceListView=SC.ListView.extend({theme:"source-list",classNames:["sc-source-list"],rowHeight:32,selectOnMouseDown:NO,actOnSelect:YES});sc_require("mixins/split_child");sc_require("mixins/split_thumb");SC.SplitDividerView=SC.View.extend(SC.SplitChild,SC.SplitThumb,{classNames:["sc-split-divider-view"],classNameBindings:["layoutDirection"],isSplitDivider:YES,layoutDirection:SC.LAYOUT_HORIZONTAL,autoResizeStyle:"sc-fixed-size",movesSibling:SC.MOVES_CHILD,size:SC.propertyFromRenderDelegate("dividerSize",10),renderDelegateName:"splitDividerRenderDelegate"});sc_require("views/split_divider");SC.FIXED_SIZE="sc-fixed-size";SC.RESIZE_MANUAL="sc-manual-size";SC.RESIZE_AUTOMATIC="sc-automatic-resize";SC.SplitView=SC.View.extend({childViews:["topLeftView","bottomRightView"],classNames:["sc-split-view"],isSplitView:YES,splitDividerView:SC.SplitDividerView,layoutDirection:SC.LAYOUT_HORIZONTAL,shouldResizeChildrenToFit:YES,splitChildCursorStyle:null,_scsv_splitChildCursorDidChange:function(){this.get("cursor").set("cursorStyle",this.get("splitChildCursorStyle"))}.observes("splitChildCursorStyle"),init:function(){this.cursor=SC.Cursor.create();arguments.callee.base.apply(this,arguments)},displayProperties:["layoutDirection"],renderDelegateName:"splitRenderDelegate",_frameSize:function(){if(this.get("layoutDirection")===SC.LAYOUT_HORIZONTAL){return this.get("frame").width}else{return this.get("frame").height}}.property("frame","layoutDirection").cacheable(),viewDidResize:function(){this.scheduleTiling();arguments.callee.base.apply(this,arguments)},layoutDirectionDidChange:function(){this.scheduleTiling();var e=this.get("layoutDirection"),d=this.get("childViews"),a=d?d.get("length"):0,c,b;for(c=0;c<a;c++){b=d[c];if(b.get("isSplitDivider")){b.setIfChanged("layoutDirection",e)}}}.observes("layoutDirection"),adjustPositionForChild:function(b,a){return this.invokeDelegateMethod(this.get("delegate"),"splitViewAdjustPositionForChild",this,b,a)},getPositionForChild:function(a){return this.invokeDelegateMethod(this.get("delegate"),"splitViewGetPositionForChild",this,a)},didAddChild:function(){if(this._scsv_settingUpChildViews){return}this._scsv_settingUpChildViews=YES;this.invokeOnce("_scsv_setupChildViews");this._scsv_settingUpChildViews=NO},didRemoveChild:function(){if(this._scsv_settingUpChildViews){return}this._scsv_settingUpChildViews=YES;this.invokeOnce("_scsv_setupChildViews");this._scsv_settingUpChildViews=NO},createChildViews:function(){arguments.callee.base.apply(this,arguments);if(this._scsv_settingUpChildViews){return}this._scsv_settingUpChildViews=YES;this.invokeOnce("_scsv_setupChildViews");this._scsv_settingUpChildViews=NO},_scsv_setupChildViews:function(){var l=this.get("delegate"),g=this.get("layoutDirection"),d=this.get("childViews").copy(),h=d.length,k,c,a,e,j=this._scsv_dividers||{},b={},f,i;for(k=0;k<h;k++){c=d[k];if(!c.get("autoResizeStyle")){if(c.get("size")!==undefined){c.set("autoResizeStyle",SC.RESIZE_MANUAL)}else{c.set("autoResizeStyle",SC.RESIZE_AUTOMATIC)}}var m=this.invokeDelegateMethod(l,"splitViewGetSizeForChild",this,c);m=this.invokeDelegateMethod(l,"splitViewConstrainSizeForChild",this,c,m);this.invokeDelegateMethod(l,"splitViewSetSizeForChild",this,c,m);c.previousView=a;c.nextView=undefined;c.viewIndex=k;if(a){a.nextView=c}if(e&&!c.isSplitDivider){i=SC.guidFor(e)+"-"+SC.guidFor(c);f=j[i];if(!f){f=this.invokeDelegateMethod(l,"splitViewDividerBetween",this,e,c)}if(f){f.setIfChanged("isSplitDivider",YES);f.setIfChanged("layoutDirection",g);b[i]=f;if(j[i]){delete j[i]}else{this.insertBefore(f,c)}}}a=c;if(!c.isSplitDivider){e=c}}for(i in j){j[i].destroy()}this._scsv_dividers=b;this._scsv_tile()},needsTiling:YES,scheduleTiling:function(){this.set("needsTiling",YES);this.invokeOnce("_scsv_tile")},tileIfNeeded:function(){if(!this.get("needsTiling")){return}this._scsv_tile()},_scsv_tile:function(){var a=this.get("delegate");var c,b=this.get("_frameSize");c=this.invokeDelegateMethod(a,"splitViewLayoutChildren",this);if(this.get("shouldResizeChildrenToFit")&&c!==b){this.invokeDelegateMethod(a,"splitViewResizeChildrenToFit",this,c);c=this.invokeDelegateMethod(a,"splitViewLayoutChildren",this)}if(!this.get("shouldResizeChildrenToFit")){if(this.get("layoutDirection")===SC.LAYOUT_HORIZONTAL){this.adjust("width",c)}else{this.adjust("height",c)}}this.set("needsTiling",NO)},splitViewLayoutChildren:function(e){var c=this.get("delegate");var d=this.get("childViews"),b=d.length,a,g,f=0;for(a=0;a<b;a++){g=d[a];this.invokeDelegateMethod(c,"splitViewSetPositionForChild",this,d[a],f);f+=this.invokeDelegateMethod(c,"splitViewGetSizeForChild",this,d[a])}return f},splitViewResizeChildrenToFit:function(h,d){var l=this.get("delegate");var g=this.get("_frameSize");var e=this.get("childViews"),i=e.length,k,c,a=0,f=0,j;for(k=0;k<i;k++){c=e[k];j=this.invokeDelegateMethod(l,"splitViewGetSizeForChild",this,c);if(this.invokeDelegateMethod(l,"splitViewShouldResizeChildToFit",this,c)){a+=j}else{f+=j}}var b=d;b=this._resizeChildrenForSize(b,g,YES,a);b=this._resizeChildrenForSize(b,g,YES,-1);b=this._resizeChildrenForSize(b,g,NO,f);b=this._resizeChildrenForSize(b,g,NO,-1)},_resizeChildrenForSize:function(d,e,f,h){var l=this.get("delegate");var c=this.get("childViews"),j,g=c.length,b;var i=e-d;for(j=0;j<g;j++){b=c[j];var k=this.invokeDelegateMethod(l,"splitViewGetSizeForChild",this,b),m=k;var a=this.invokeDelegateMethod(l,"splitViewShouldResizeChildToFit",this,b);if(a===f){if(h===-1){m+=i}else{m+=(m/h)*i}m=Math.round(m);m=this.invokeDelegateMethod(l,"splitViewConstrainSizeForChild",this,b,m);this.invokeDelegateMethod(l,"splitViewSetSizeForChild",this,b,m);if(h!==-1){h-=k}}d-=k;d+=m;i=e-d}return d},splitViewShouldResizeChildToFit:function(a,b){return(this.get("shouldResizeChildrenToFit")&&b.get("autoResizeStyle")===SC.RESIZE_AUTOMATIC)},splitViewAdjustPositionForChild:function(c,e,a){var d=this._scsv_createPlan();var b=this._scsv_adjustPositionForChildInPlan(d,e,a,e);this._scsv_commitPlan(d);return b},_scsv_createPlan:function(){var c=this.get("delegate"),g=[],f=this.get("childViews"),b,a=f.length,h,e,d;for(b=0;b<a;b++){h=f[b];e=this.invokeDelegateMethod(c,"splitViewGetPositionForChild",this,h);d=this.invokeDelegateMethod(c,"splitViewGetSizeForChild",this,h);g[b]={child:h,originalPosition:e,position:e,originalSize:d,size:d}}return g},_scsv_resetPlanRange:function(c,d,b){for(var a=d;a<=b;a++){c[a].position=c[a].originalPosition;c[a].size=c[a].originalSize}},_scsv_commitPlan:function(f){var d=this.get("delegate"),b=f.length,a,e,c=0;for(a=0;a<b;a++){e=f[a];if(e.size!==e.originalSize){this.invokeDelegateMethod(d,"splitViewSetSizeForChild",this,e.child,e.size)}if(e.position!==e.originalPosition){this.invokeDelegateMethod(d,"splitViewSetPositionForChild",this,e.child,e.position)}c=e.position+e.size}if(!this.get("shouldResizeChildrenToFit")){if(this.get("layoutDirection")===SC.LAYOUT_HORIZONTAL){this.adjust("width",c)}else{this.adjust("height",c)}}},_scsv_adjustPositionForChildInPlan:function(i,d,f,a){var j=this.get("delegate");if(!d.get("allowsIndirectAdjustments")&&a!==d&&a!==d.previousView){return i[d.viewIndex].position}if(d._splitViewIsAdjusting){return i[d.viewIndex].position}d._splitViewIsAdjusting=YES;var g=d.previousView,b=d.nextView,c,k,h,e,l=i[d.viewIndex].size;if(g&&!g._splitViewIsAdjusting){c=i[g.viewIndex].position;k=f-c;k=this._scsv_adjustSizeForChildInPlan(i,g,k,a);f=c+k}else{if(!g){f=0}}if(b&&b._splitViewIsAdjusting){d._splitViewIsAdjusting=NO;i[d.viewIndex].position=f;return f}if(d.get("compensatesForMovement")&&b){h=i[b.viewIndex].position;l=this._scsv_adjustSizeForChildInPlan(i,d,h-f)}else{if(!b&&this.get("shouldResizeChildrenToFit")){h=this.get("_frameSize");l=this._scsv_adjustSizeForChildInPlan(i,d,h-f);f=h-l}}if(b){h=f+l;h=this._scsv_adjustPositionForChildInPlan(i,b,h,a)}if(h&&f!==h-l){f=h-l;if(g&&!g._splitViewIsAdjusting){this._scsv_resetPlanRange(i,0,g.viewIndex);k=f-i[g.viewIndex].position;this._scsv_adjustSizeForChildInPlan(i,g,k,d)}}i[d.viewIndex].position=f;d._splitViewIsAdjusting=NO;return f},_scsv_adjustSizeForChildInPlan:function(f,b,i,a){var g=this.get("delegate");if(a&&!b.get("allowsIndirectAdjustments")&&a!==b&&a!==b.nextView&&a!==b.previousView){return f[b.viewIndex].size}var h=this.invokeDelegateMethod(g,"splitViewConstrainSizeForChild",this,b,i);f[b.viewIndex].size=h;if(i===h){return i}var c=f[b.viewIndex].position,d=c+i-h;var e=this._scsv_adjustPositionForChildInPlan(f,b,d,a);return e+h-c},splitViewDividerBetween:function(c,b,a){if(!this.get("splitDividerView")){return null}return this.get("splitDividerView").create()},splitViewGetPositionForChild:function(a,b){return b.get("position")},splitViewSetPositionForChild:function(b,c,a){c.set("position",a)},splitViewGetSizeForChild:function(b,c){var a=c.get("size");if(SC.none(a)){return 100}return a},splitViewSetSizeForChild:function(b,c,a){c.set("size",a)},splitViewConstrainSizeForChild:function(c,f,a){if(f.get("autoResizeStyle")===SC.FIXED_SIZE){return this.invokeDelegateMethod(this.get("delegate"),"splitViewGetSizeForChild",this,f)}if(f.get("canCollapse")){var b=f.get("collapseAtSize");if(b&&a<b){return 0}}var d=f.get("minimumSize")||0;if(d!==undefined&&d!==null){a=Math.max(d,a)}var e=f.get("maximumSize");if(e!==undefined&&e!==null){a=Math.min(e,a)}return a}});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){if(a){this._updateHeight()}else{this.invokeLast(this._updateHeight)}return this},_updateHeight:function(){var e=this.get("childViews"),b=e.get("length"),c,d,a;if(b===0){a=1}else{c=e.objectAt(b-1);d=c?c.get("layer"):null;a=d?(d.offsetTop+d.offsetHeight):1;d=null}this.adjust("minHeight",a);this.set("calculatedHeight",a)},reloadIfNeeded:function(){arguments.callee.base.apply(this,arguments);return this.updateHeight()},didCreateLayer:function(){return this.updateHeight()}});SC.StaticContentView=SC.View.extend({classNames:["sc-static-content-view"],displayProperties:["content"],content:null,contentLayoutDidChange:function(){this._sc_viewFrameDidChange()},useStaticLayout:YES,frame:function(){var a=this.get("layer"),b;if(!a){return{x:0,y:0,width:0,height:0}}if(a.getBoundingClientRect&&!SC.browser.isIE8OrLower){b=a.getBoundingClientRect();return{x:0,y:0,width:b.width,height:b.height}}else{return{x:0,y:0,width:a.clientWidth,height:a.clientHeight}}}.property("content").cacheable(),parentViewDidResize:function(){this.contentLayoutDidChange()},didUpdateLayer:function(){this.contentLayoutDidChange()},render:function(a,c){var b=this.get("content");a.push(b||"")},touchStart:function(a){a.allowDefault();return YES},touchEnd:function(a){a.allowDefault();return YES}});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:[],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 d=this.get("nowShowing");this.get("segmentedView").set("value",d);var c=this.get("userDefaultKey");if(c){SC.userDefaults.set([c,"nowShowing"].join(":"),d)}if(SC.typeOf(d)===SC.T_STRING&&d.length>0){var b=d.indexOf(".");if(b===-1){var a=this.get(d);d=SC.kindOf(a,SC.CoreView)?a:SC.objectForPropertyPath(d,this.get("page"))}else{if(b===0){d=this.getPath(d.slice(1))}else{d=SC.objectForPropertyPath(d)}}}this.get("containerView").set("nowShowing",d);return this}.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();var a=this.get("userDefaultKey");if(a){a=[a,"nowShowing"].join(":");var b=SC.userDefaults.get(a);if(!SC.none(b)){this.set("nowShowing",b)}}},createChildViews:function(){var e=[],d,c,b=this.get("tabLocation"),a=this.get("tabHeight"),f=this.get("controlSize");if(b===SC.TOP_LOCATION){c={top:a/2+1,left:0,right:0,bottom:0,border:1}}else{if(b===SC.TOP_TOOLBAR_LOCATION){c={top:a+1,left:0,right:0,bottom:0,border:1}}else{c={top:0,left:0,right:0,bottom:(a/2)-1,border:1}}}d=this.containerView.extend({layout:c,ariaRole:"tabpanel"});this.containerView=this.createChildView(d);c=(b===SC.TOP_LOCATION||b===SC.TOP_TOOLBAR_LOCATION)?{height:a,left:0,right:0,top:0}:{height:a,left:0,right:0,bottom:0};this.segmentedView=this.get("segmentedView").extend({layout:c,controlSize:f,_sc_tab_segmented_valueDidChange:function(){var g=this.get("parentView");if(g){g.set("nowShowing",this.get("value"))}}.observes("value"),init:function(){var g=this.get("parentView");if(g){SC._TAB_ITEM_KEYS.forEach(function(h){this[h]=g.get(h)},this)}return arguments.callee.base.apply(this,arguments)}});this.segmentedView=this.createChildView(this.segmentedView);e.push(this.containerView);e.push(this.segmentedView);this.set("childViews",e);return this},containerView:SC.ContainerView.extend({renderDelegateName:"wellRenderDelegate"}),segmentedView:SC.SegmentedView});SC._TAB_ITEM_KEYS=["itemTitleKey","itemValueKey","itemIsEnabledKey","itemIconKey","itemWidthKey","itemToolTipKey","itemActionKey","itemTargetKey"];SC.ThumbView=SC.View.extend(SC.SplitThumb,{classNames:["sc-thumb-view"],init:function(){arguments.callee.base.apply(this,arguments);console.warn("SC.ThumbView is deprecated. Please use a normal view and mix in SC.SplitThumb instead.")}});SC.WebView=SC.View.extend(SC.Control,{classNames:"sc-web-view",displayProperties:["value","shouldAutoResize"],shouldAutoResize:NO,render:function(a,d){var c=this.get("value")||"",b;if(d){a.push('<iframe src="'+c+'" style="position: absolute; width: 100%; height: 100%; border: 0px; margin: 0px; padding: 0px;"></iframe>')}else{if(c!==this._lastSrc){b=this.$("iframe");b.attr("src","javascript:;");b.attr("src",c)}}this._lastSrc=c},didCreateLayer:function(){var a=this.$("iframe");SC.Event.add(a,"load",this,this.iframeDidLoad)},willDestroyLayer:function(){var a=this.$("iframe");SC.Event.remove(a,"load",this,this.iframeDidLoad)},iframeDidLoad:function(){if(this.get("shouldAutoResize")===YES){var a;var c=this.$("iframe")[0];if(c&&c.contentWindow){a=c.contentWindow;if(a&&a.document&&a.document.documentElement){var b=a.document.documentElement;if(!SC.browser.isIE){this.$().width(b.scrollWidth);this.$().height(b.scrollHeight)}else{this.$().width(b.scrollWidth+12);this.$().height(b.scrollHeight+5)}}}}}});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},renderDelegateName:"wellRenderDelegate",createChildView:function(a,b){a=arguments.callee.base.apply(this,arguments);a.set("layout",this.contentLayout);return a},_sc_contentViewDidChange:function(){var a=this.get("contentView");if(a){a.set("layout",this.contentLayout)}arguments.callee.base.apply(this,arguments)}});if(!Object.keys){Object.keys=(function(){var c=Object.prototype.hasOwnProperty,d=!({toString:null}).propertyIsEnumerable("toString"),b=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],a=b.length;return function(g){if(typeof g!=="object"&&(typeof g!=="function"||g===null)){throw new TypeError("Object.keys called on non-object")}var e=[],h,f;for(h in g){if(c.call(g,h)){e.push(h)}}if(d){for(f=0;f<a;f++){if(c.call(g,b[f])){e.push(b[f])}}}return e}}())}(function(){var b=0;var c=["ms","moz","webkit","o"];for(var a=0;a<c.length&&!window.requestAnimationFrame;++a){window.requestAnimationFrame=window[c[a]+"RequestAnimationFrame"];window.cancelRequestAnimationFrame=window[c[a]+"CancelRequestAnimationFrame"]}if(!window.requestAnimationFrame){window.requestAnimationFrame=function(g){var d=new Date().getTime();var e=Math.max(0,16-(d-b));var f=window.setTimeout(function(){g(window.performance.now())},e);b=d+e;return f}}if(!window.cancelAnimationFrame){window.cancelAnimationFrame=function(d){clearTimeout(d)}}}());SC.MIXED_STATE="__MIXED__";SC.DataSource=SC.Object.extend({fetch:function(a,b){return NO},retrieveRecords:function(a,c,b){return this._handleEach(a,c,this.retrieveRecord,b)},commitRecords:function(c,b,g,f,h){var e,a,d;if(b.length>0){d=this.createRecords.call(this,c,b,h)}if(g.length>0){e=this.updateRecords.call(this,c,g,h);d=SC.none(d)?e:(d===e)?d:SC.MIXED_STATE}if(f.length>0){a=this.destroyRecords.call(this,c,f,h);d=SC.none(d)?a:(d===a)?d:SC.MIXED_STATE}return d||NO},cancel:function(a,b){return NO},updateRecords:function(a,b,c){return this._handleEach(a,b,this.updateRecord,null,c)},createRecords:function(a,b,c){return this._handleEach(a,b,this.createRecord,null,c)},destroyRecords:function(a,b,c){return this._handleEach(a,b,this.destroyRecord,null,c)},_handleEach:function(h,e,c,a,b){var f=e.length,i,g,j,d;for(i=0;i<f;i++){d=a?a[i]:b;j=c.call(this,h,e[i],d);if(g===undefined){g=j}else{if(g===YES){g=(j===YES)?YES:SC.MIXED_STATE}else{if(g===NO){g=(j===NO)?NO:SC.MIXED_STATE}}}}return !SC.none(g)?g:null},updateRecord:function(a,b,c){return NO},retrieveRecord:function(a,b,c){return NO},createRecord:function(a,b,c){return NO},destroyRecord:function(a,b,c){return NO}});sc_require("data_sources/data_source");SC.CascadeDataSource=SC.DataSource.extend({dataSources:null,from:function(a){var b=this.get("dataSources");if(!b){this.set("dataSources",b=[])}b.push(a);return this},fetch:function(c,g){var e=this.get("dataSources"),b=e?e.length:0,d=NO,h,f,a;for(a=0;(d!==YES)&&a<b;a++){f=e.objectAt(a);h=f.fetch?f.fetch.apply(f,arguments):NO;d=this._handleResponse(d,h)}return d},retrieveRecords:function(h,d,b){var c=this.get("dataSources"),e=c?c.length:0,f=NO,i,a,g;for(g=0;(f!==YES)&&g<e;g++){a=c.objectAt(g);i=a.retrieveRecords.apply(a,arguments);f=this._handleResponse(f,i)}return f},commitRecords:function(j,c,h,e,d){var b=this.get("dataSources"),f=b?b.length:0,g=NO,k,a,i;for(i=0;(g!==YES)&&i<f;i++){a=b.objectAt(i);k=a.commitRecords.apply(a,arguments);g=this._handleResponse(g,k)}return g},cancel:function(c,f){var e=this.get("dataSources"),b=e?e.length:0,d=NO,h,g,a;for(a=0;(d!==YES)&&a<b;a++){g=e.objectAt(a);h=g.cancel.apply(g,arguments);d=this._handleResponse(d,h)}return d},init:function(){arguments.callee.base.apply(this,arguments);var b=this.get("dataSources"),a=b?b.get("length"):0,c;while(--a>=0){c=b[a];if(SC.typeOf(c)===SC.T_STRING){b[a]=this.get(c)}}},_handleResponse:function(b,a){if(a===YES){return YES}else{if(b===NO){return(a===NO)?NO:SC.MIXED_STATE}else{return SC.MIXED_STATE}}}});sc_require("core");sc_require("models/record");SC.Query=SC.Object.extend(SC.Copyable,SC.Freezable,{isQuery:YES,conditions:null,orderBy:null,recordType:null,recordTypes:null,expandedRecordTypes:function(){var b=SC.CoreSet.create(),a,c;if(a=this.get("recordType")){this._scq_expandRecordType(a,b)}else{if(a=this.get("recordTypes")){a.forEach(function(d){this._scq_expandRecordType(d,b)},this)}else{this._scq_expandRecordType(SC.Record,b)}}c=SC.Query._scq_queriesWithExpandedRecordTypes;if(!c){c=SC.Query._scq_queriesWithExpandedRecordTypes=SC.CoreSet.create()}c.add(this);return b.freeze()}.property("recordType","recordTypes").cacheable(),_scq_expandRecordType:function(b,a){if(a.contains(b)){return}a.add(b);if(SC.typeOf(b)===SC.T_STRING){b=SC.objectForPropertyPath(b)}b.subclasses.forEach(function(c){this._scq_expandRecordType(c,a)},this)},parameters:null,location:"local",scope:null,isRemote:function(){return this.get("location")===SC.Query.REMOTE}.property("location").cacheable(),isLocal:function(){return this.get("location")===SC.Query.LOCAL}.property("location").cacheable(),isEditable:NO,contains:function(a,d){var e,b=YES;if(e=this.get("recordTypes")){b=e.find(function(f){return SC.kindOf(a,f)})}else{if(e=this.get("recordType")){b=SC.kindOf(a,e)}}if(!b){return NO}var c=this.get("scope");if(c&&!c.contains(a)){return NO}if(!this._isReady){this.parse()}if(!this._isReady){return NO}if(d===undefined){d=this.parameters||this}return this._tokenTree.evaluate(a,d)},containsRecordTypes:function(a){var b=this.get("recordType");if(b){return !!a.find(function(c){return SC.kindOf(c,b)})}else{if(b=this.get("recordTypes")){return !!b.find(function(c){return !!a.find(function(d){return SC.kindOf(d,c)})})}else{return YES}}},compare:function(g,d){var c=0,f,b,a,h,e;if(g===d){return 0}if(!this._isReady){this.parse()}if(!this._isReady){return SC.compare(g.get("storeKey"),d.get("storeKey"))}b=this._order;if(SC.typeOf(b)===SC.T_FUNCTION){c=b.call(null,g,d)}else{a=b?b.length:0;for(h=0;c===0&&(h<a);h++){f=b[h].propertyName;e=/\./.test(f)?"getPath":"get";if(SC.Query.comparisons[f]){c=SC.Query.comparisons[f](g[e](f),d[e](f))}else{c=SC.compare(g[e](f),d[e](f))}if((c!==0)&&b[h].descending){c=(-1)*c}}}if(c!==0){return c}else{return SC.compare(g.get("storeKey"),d.get("storeKey"))}},_isReady:NO,parse:function(){var c=this.get("conditions"),d=this.get("queryLanguage"),b,a;b=this._tokenList=this.tokenizeString(c,d);a=this._tokenTree=this.buildTokenTree(b,d);this._order=this.buildOrder(this.get("orderBy"));this._isReady=!!a&&!a.error;if(a&&a.error){SC.throw(a.error)}return this._isReady},queryWithScope:function(c){var b=SC.keyFor("__query__",SC.guidFor(this)),a=c[b];if(!a){c[b]=a=this.copy();a.set("scope",c);a.freeze()}return a},copyKeys:["conditions","orderBy","recordType","recordTypes","parameters","location","scope"],concatenatedProperties:["copyKeys"],copy:function(){var d={},c=this.get("copyKeys"),f=c?c.length:0,b,e,a;while(--f>=0){b=c[f];e=this.get(b);if(e!==undefined){d[b]=e}}a=this.constructor.create(d);d=null;return a},queryLanguage:{UNKNOWN:{firstCharacter:/[^\s'"\w\d\(\)\{\}]/,notAllowed:/[\-\s'"\w\d\(\)\{\}]/},PROPERTY:{firstCharacter:/[a-zA-Z_]/,notAllowed:/[^a-zA-Z_0-9\.]/,evalType:"PRIMITIVE",evaluate:function(e,b){var f=this.tokenValue.split(".");var a=f.length;if(a<2){return e.get(this.tokenValue)}var c=e;for(var d=0;d<a;d++){if(!c){return}if(c.get){c=c.get(f[d])}else{c=c[f[d]]}}return c}},NUMBER:{firstCharacter:/[\d\-]/,notAllowed:/[^\d\-\.]/,format:/^-?\d+$|^-?\d+\.\d+$/,evalType:"PRIMITIVE",evaluate:function(b,a){return parseFloat(this.tokenValue)}},STRING:{firstCharacter:/['"]/,delimited:true,evalType:"PRIMITIVE",evaluate:function(b,a){return this.tokenValue}},PARAMETER:{firstCharacter:/\{/,lastCharacter:"}",delimited:true,evalType:"PRIMITIVE",evaluate:function(b,a){return a[this.tokenValue]}},"%@":{rememberCount:true,reservedWord:true,evalType:"PRIMITIVE",evaluate:function(b,a){return a[this.tokenValue]}},OPEN_PAREN:{firstCharacter:/\(/,singleCharacter:true},CLOSE_PAREN:{firstCharacter:/\)/,singleCharacter:true},AND:{reservedWord:true,leftType:"BOOLEAN",rightType:"BOOLEAN",evalType:"BOOLEAN",evaluate:function(c,a){var d=this.leftSide.evaluate(c,a);var b=this.rightSide.evaluate(c,a);return d&&b}},OR:{reservedWord:true,leftType:"BOOLEAN",rightType:"BOOLEAN",evalType:"BOOLEAN",evaluate:function(c,a){var d=this.leftSide.evaluate(c,a);var b=this.rightSide.evaluate(c,a);return d||b}},NOT:{reservedWord:true,rightType:"BOOLEAN",evalType:"BOOLEAN",evaluate:function(c,a){var b=this.rightSide.evaluate(c,a);return !b}},"=":{reservedWord:true,leftType:"PRIMITIVE",rightType:"PRIMITIVE",evalType:"BOOLEAN",evaluate:function(c,a){var d=this.leftSide.evaluate(c,a);var b=this.rightSide.evaluate(c,a);return SC.isEqual(d,b)}},"!=":{reservedWord:true,leftType:"PRIMITIVE",rightType:"PRIMITIVE",evalType:"BOOLEAN",evaluate:function(c,a){var d=this.leftSide.evaluate(c,a);var b=this.rightSide.evaluate(c,a);return !SC.isEqual(d,b)}},"<":{reservedWord:true,leftType:"PRIMITIVE",rightType:"PRIMITIVE",evalType:"BOOLEAN",evaluate:function(c,a){var d=this.leftSide.evaluate(c,a);var b=this.rightSide.evaluate(c,a);return SC.compare(d,b)===-1}},"<=":{reservedWord:true,leftType:"PRIMITIVE",rightType:"PRIMITIVE",evalType:"BOOLEAN",evaluate:function(c,a){var d=this.leftSide.evaluate(c,a);var b=this.rightSide.evaluate(c,a);return SC.compare(d,b)!==1}},">":{reservedWord:true,leftType:"PRIMITIVE",rightType:"PRIMITIVE",evalType:"BOOLEAN",evaluate:function(c,a){var d=this.leftSide.evaluate(c,a);var b=this.rightSide.evaluate(c,a);return SC.compare(d,b)===1}},">=":{reservedWord:true,leftType:"PRIMITIVE",rightType:"PRIMITIVE",evalType:"BOOLEAN",evaluate:function(c,a){var d=this.leftSide.evaluate(c,a);var b=this.rightSide.evaluate(c,a);return SC.compare(d,b)!==-1}},BEGINS_WITH:{reservedWord:true,leftType:"PRIMITIVE",rightType:"PRIMITIVE",evalType:"BOOLEAN",evaluate:function(c,a){var b=this.leftSide.evaluate(c,a);var d=this.rightSide.evaluate(c,a);return(b&&b.indexOf(d)===0)}},ENDS_WITH:{reservedWord:true,leftType:"PRIMITIVE",rightType:"PRIMITIVE",evalType:"BOOLEAN",evaluate:function(d,b){var c=this.leftSide.evaluate(d,b);var a=this.rightSide.evaluate(d,b);return(c&&c.length>=a.length&&c.lastIndexOf(a)===(c.length-a.length))}},CONTAINS:{reservedWord:true,leftType:"PRIMITIVE",rightType:"PRIMITIVE",evalType:"BOOLEAN",evaluate:function(e,a){var d=this.leftSide.evaluate(e,a)||[];var g=this.rightSide.evaluate(e,a);var c=SC.typeOf(d);if(c===SC.T_STRING){return(d.indexOf(g)!==-1)}else{if(c===SC.T_ARRAY||d.toArray){if(c!==SC.T_ARRAY){d=d.toArray()}var f=false;var b=0;while(f===false&&b<d.length){if(g==d[b]){f=true}b++}return f}}}},ANY:{reservedWord:true,leftType:"PRIMITIVE",rightType:"PRIMITIVE",evalType:"BOOLEAN",evaluate:function(d,a){var f=this.leftSide.evaluate(d,a);var b=this.rightSide.evaluate(d,a);var e=false;var c=0;while(e===false&&c<b.length){if(f==b[c]){e=true}c++}return e}},MATCHES:{reservedWord:true,leftType:"PRIMITIVE",rightType:"PRIMITIVE",evalType:"BOOLEAN",evaluate:function(c,a){var d=this.leftSide.evaluate(c,a);var b=this.rightSide.evaluate(c,a);return b.test(d)}},TYPE_IS:{reservedWord:true,rightType:"PRIMITIVE",evalType:"BOOLEAN",evaluate:function(d,a){var c=SC.Store.recordTypeFor(d.storeKey);var b=this.rightSide.evaluate(d,a);var e=SC.objectForPropertyPath(b);return c==e}},"null":{reservedWord:true,evalType:"PRIMITIVE",evaluate:function(b,a){return null}},"undefined":{reservedWord:true,evalType:"PRIMITIVE",evaluate:function(b,a){return undefined}},"false":{reservedWord:true,evalType:"PRIMITIVE",evaluate:function(b,a){return false}},"true":{reservedWord:true,evalType:"PRIMITIVE",evaluate:function(b,a){return true}},YES:{reservedWord:true,evalType:"PRIMITIVE",evaluate:function(b,a){return true}},NO:{reservedWord:true,evalType:"PRIMITIVE",evaluate:function(b,a){return false}}},tokenizeString:function(o,b){var p=[],n=null,s=null,e=null,f=null,h=null,a=null,r=null,q=false,g=false,d=false,l={};function k(t,c){s=b[t];if(s.format&&!s.format.test(c)){t="UNKNOWN"}if(s.delimited){d=true}if(!s.delimited){for(var i in b){if(b[i].reservedWord&&i==c){t=i}}}s=b[t];if(s&&s.rememberCount){if(!l[t]){l[t]=0}c=l[t];l[t]+=1}p.push({tokenType:t,tokenValue:c});f=null;h=null;a=null}if(!o){return[]}var m=o.length;for(var j=0;j<m;j++){q=(j===m-1);n=o.charAt(j);d=false;if(f){s=b[f];g=s.delimited?n===r:s.notAllowed.test(n);if(!g){a+=n}if(g||q){k(f,a)}if(q&&!g){d=true}}if(!f&&!d){for(e in b){s=b[e];if(s.firstCharacter&&s.firstCharacter.test(n)){f=e}}if(f){s=b[f];a=n;if(s.delimited){a="";if(s.lastCharacter){r=s.lastCharacter}else{r=n}}if(s.singleCharacter||q){k(f,a)}}}}return p},buildTokenTree:function(k,a){var o=k.slice();var q=0;var s=[];var c=false;var p=[];if(!k||k.length===0){return{evaluate:function(){return true}}}function r(i){var v=i;if(v<0){return false}var l=a[o[v].tokenType];if(!l){p.push("logic for token '"+o[v].tokenType+"' is not defined");return false}o[v].evaluate=l.evaluate;return l}function b(v,i){var w=i;var l=r(w);if(!l){return false}if(v==="left"){return l.leftType}if(v==="right"){return l.rightType}}function n(i){var v=i;var l=r(v);if(!l){return false}else{return l.evalType}}function f(i){o.splice(i,1);if(i<=q){q--}}function t(i){var l=i||q;if(l>0){return true}else{return false}}function j(i){var l=i;if(l<0){return true}return(b("left",l)&&!o[l].leftSide)||(b("right",l)&&!o[l].rightSide)}function h(l,v){var i=(v<l)?"left":"right";if(l<0||v<0){return false}if(!b(i,l)){return false}if(!n(v)){return false}if(b(i,l)==n(v)){return true}else{return false}}function m(i){var l=i;if(!j(l)){return false}if(!t(l)){return false}if(h(l,l-1)){return true}else{return false}}function d(i){var l=i;if(j(l)){return false}if(!t(l)){return false}if(!j(l-1)){return false}if(h(l-1,l)){return true}else{return false}}function g(i){var l=i;if(l<1){return false}o[l].leftSide=o[l-1];f(l-1)}function u(i){var l=i;if(l<1){return false}o[l-1].rightSide=o[l];f(l)}function e(i){f(i);f(s.pop())}for(q=0;q<o.length;q++){c=false;if(o[q].tokenType==="UNKNOWN"){p.push("found unknown token: "+o[q].tokenValue)}if(o[q].tokenType==="OPEN_PAREN"){s.push(q)}if(o[q].tokenType==="CLOSE_PAREN"){e(q)}if(m(q)){g(q)}if(d(q)){u(q);c=true}if(c){q--}}if(o.length===1){o=o[0]}else{p.push("string did not resolve to a single tree")}if(p.length>0){return{error:p.join(",\n"),tree:o,isError:YES,errorVal:function(){return this.error}}}else{return o}},buildOrder:function(a){if(!a){return[]}else{if(SC.typeOf(a)===SC.T_FUNCTION){return a}else{var d=a.split(",");for(var b=0;b<d.length;b++){var c=d[b];c=c.replace(/^\s+|\s+$/,"");c=c.replace(/\s+/,",");c=c.split(",");d[b]={propertyName:c[0]};if(c[1]&&c[1]==="DESC"){d[b].descending=true}}return d}}}});SC.Query.mixin({LOCAL:"local",REMOTE:"remote",storeKeyFor:function(a){return a?a.get("storeKey"):null},containsRecords:function(g,e,d){var f=[];for(var b=0,a=e.get("length");b<a;b++){var c=e.objectAt(b);if(c&&g.contains(c)){f.push(c.get("storeKey"))}}f=SC.Query.orderStoreKeys(f,g,d);return f},orderStoreKeys:function(b,c,a){if(b){b.sort(function(e,d){return SC.Query.compareStoreKeys(c,a,e,d)})}return b},compareStoreKeys:function(f,c,e,d){var b=c.materializeRecord(e),a=c.materializeRecord(d);return f.compare(b,a)},build:function(g,c,f,i){var a=null,e,b,h,d;if(c&&c.isQuery){if(c.get("location")===g){return c}else{return c.copy().set("location",g).freeze()}}if(typeof c===SC.T_STRING){e=SC.objectForPropertyPath(c);if(!e){throw new Error("%@ did not resolve to a class".fmt(c))}c=e}else{if(c&&c.isEnumerable){e=[];c.forEach(function(j){if(typeof j===SC.T_STRING){j=SC.objectForPropertyPath(j)}if(!j){throw new Error("cannot resolve record types: %@".fmt(c))}e.push(j)},this);c=e}else{if(!c){c=SC.Record}}}if(i===undefined){i=null}if(f===undefined){f=null}if(!i&&(typeof f!==SC.T_STRING)){a=f;f=null}if(!i&&!a){d=SC.Query._scq_recordTypeCache;if(!d){d=SC.Query._scq_recordTypeCache={}}b=d[g];if(!b){b=d[g]={}}if(c.isEnumerable){h=c.map(function(j){return SC.guidFor(j)});h=h.sort().join(":")}else{h=SC.guidFor(c)}if(f){h=[h,f].join("::")}e=b[h];if(!e){if(c.isEnumerable){a={recordTypes:c.copy()}}else{a={recordType:c}}a.location=g;a.conditions=f;e=b[h]=SC.Query.create(a).freeze()}}else{if(!a){a={}}if(!a.location){a.location=g}if(c&&c.isEnumerable){a.recordTypes=c}else{a.recordType=c}if(f){a.conditions=f}if(i){a.parameters=i}e=SC.Query.create(a).freeze()}return e},local:function(c,a,b){return this.build(SC.Query.LOCAL,c,a,b)},remote:function(c,a,b){return this.build(SC.Query.REMOTE,c,a,b)},_scq_didDefineRecordType:function(){var a=SC.Query._scq_queriesWithExpandedRecordTypes;if(a){a.forEach(function(b){b.notifyPropertyChange("expandedRecordTypes")},this);a.clear()}}});SC.Query.comparisons={};SC.Query.registerComparison=function(a,b){SC.Query.comparisons[a]=b};SC.Query.registerQueryExtension=function(b,a){SC.Query.prototype.queryLanguage[b]=a};SC.Q=SC.Query.from;sc_require("system/query");SC.Record=SC.Object.extend({isRecord:YES,id:function(a,b){if(b!==undefined){this.writeAttribute(this.get("primaryKey"),b);return b}else{return SC.Store.idFor(this.storeKey)}}.property("storeKey").cacheable(),isParentRecord:NO,primaryKey:"guid",status:function(){return this.store.readStatus(this.storeKey)}.property("storeKey").cacheable(),store:null,storeKey:null,isDestroyed:function(){return !!(this.get("status")&SC.Record.DESTROYED)}.property("status").cacheable(),isEditable:function(a,b){if(b!==undefined){this._screc_isEditable=b}if(this.get("status")&SC.Record.READY){return this._screc_isEditable}else{return NO}}.property("status").cacheable(),_screc_isEditable:YES,isLoaded:function(){var b=SC.Record,a=this.get("status");return !((a===b.EMPTY)||(a===b.BUSY_LOADING)||(a===b.ERROR))}.property("status").cacheable(),relationships:null,attributes:function(){var a=this.get("store"),b=this.storeKey;return a.readEditableDataHash(b)}.property(),readOnlyAttributes:function(){var a=this.get("store"),c=this.storeKey,b=a.readDataHash(c);if(b){b=SC.clone(b,YES)}return b}.property(),nestedRecordNamespace:null,isNestedRecord:function(){var c=this.get("store"),d,b=this.get("storeKey"),a=c.parentStoreKeyExists(b);d=a?YES:NO;return d}.property().cacheable(),parentRecord:function(){var a=this.storeKey,b=this.get("store");return b.materializeParentRecord(a)}.property(),refresh:function(e,g){var c=this.get("store"),f,d,b=this.get("storeKey"),a=c.parentStoreKeyExists();d=e||(SC.none(e)&&SC.none(a));if(d){c.refreshRecord(null,null,b,g)}else{if(a){f=c.materializeRecord(a);f.refresh(e,g)}}return this},destroy:function(e){var c=this.get("store"),f,d,b=this.get("storeKey"),a=c.parentStoreKeyExists();d=e||(SC.none(e)&&SC.none(a));if(d){c.destroyRecord(null,null,b);this.notifyPropertyChange("status");this.propagateToAggregates()}else{if(a){f=c.materializeRecord(a);f.destroy(e)}}return this},recordDidChange:function(a){var b=this.get("parentRecord");if(b){b.recordDidChange()}this.get("store").recordDidChange(null,null,this.get("storeKey"),a);this.notifyPropertyChange("status");this.propagateToAggregates();return this},toJSON:function(){return this.get("attributes")},_editLevel:0,beginEditing:function(){this._editLevel++;return this},endEditing:function(a){if(--this._editLevel<=0){this._editLevel=0;this.recordDidChange(a)}return this},readAttribute:function(c){var a=this.get("store"),d=this.storeKey;var b=a.readDataHash(d);return b?b[c]:undefined},writeAttribute:function(c,f,e){var a=this.get("store"),d=this.storeKey,b;b=a.readEditableDataHash(d);if(!b){SC.Record.BAD_STATE_ERROR.throw()}if(f!==b[c]){if(!e){this.beginEditing()}b[c]=f;if(c===this.get("primaryKey")){SC.Store.replaceIdFor(d,f);this.propertyDidChange("id")}if(!e){this.endEditing(c)}else{a.dataHashDidChange(d,null,undefined,c)}}return this},propagateToAggregates:function(){var m=this.get("storeKey"),d=SC.Store.recordTypeFor(m),f=d.__sc_aggregate_keys,k,g,l,b,c,j;if(!f){f=[];for(l in this){b=this[l];if(b&&b.isRecordAttribute&&b.aggregate===YES){f.push(l)}}d.__sc_aggregate_keys=f}var i=SC.Record,a=i.DIRTY,e=i.READY_NEW,n=i.DESTROYED,o=i.READY_CLEAN,h;h=function(t){var p,q,r,s;if(t){p=this.get("status");if((p&a)||(p&e)||(p&n)){q=t.get("store");r=t.get("storeKey");s=q.peekStatus(r);if(s===o){t.get("store").recordDidChange(t.constructor,null,t.get("storeKey"),null,YES)}}}};for(k=0,g=f.length;k<g;++k){l=f[k];c=this.get(l);j=SC.kindOf(c,SC.ManyArray)?c:[c];j.forEach(h,this)}},storeDidChangeProperties:function(a,b){if(a){this.notifyPropertyChange("status")}else{if(b){this.beginPropertyChanges();b.forEach(function(e){this.notifyPropertyChange(e)},this);this.notifyPropertyChange("status");this.endPropertyChanges()}else{this.allPropertiesDidChange()}var d=this.relationships,c=d?d.length:0;while(--c>=0){d[c].recordPropertyDidChange(b)}}},normalize:function(d){var j=this.primaryKey,k=this.get("store"),m=this.get("storeKey"),n={},l,g,c,p,f,b,a,i,o,h;var e=k.readEditableDataHash(m)||{};p=k.readDataHash(m);n[j]=YES;for(l in this){g=this[l];if(g){c=g.typeClass;if(c){o=g.get("key")||l;n[o]=YES;b=SC.typeOf(c.call(g))===SC.T_CLASS;a=g.isNestedRecordTransform;if(!b&&!a){f=this.get(l);if(f!==undefined&&(f!==null||d)){h=this[l];if(SC.kindOf(h,SC.RecordAttribute)){f=h.fromType(this,l,f)}e[o]=f}else{if(!d){n[o]=NO}}}else{if(a){f=this.get(l);if(f&&f.normalize){f.normalize()}}else{if(b){f=p[o];if(f!==undefined){e[o]=f}else{i=g.get("defaultValue");if(SC.typeOf(i)===SC.T_FUNCTION){e[o]=i(this,l,i)}else{e[o]=i}}}}}}}}for(l in e){if(!n[l]){SC.debug("%@:  Deleting key from underlying data hash due to normalization:  %@",this,l);delete e[l]}}return this},unknownProperty:function(b,d){if(d!==undefined){var c=this.get("storeKey"),e=SC.Store.recordTypeFor(c);if(e.ignoreUnknownProperties===YES){this[b]=d;return d}var a=this.get("primaryKey");this.writeAttribute(b,d);if(b===a){SC.Store.replaceIdFor(c,d)}}return this.readAttribute(b)},commitRecord:function(f,d,g){var b=this.get("store"),e,c,a=b.parentStoreKeyExists();c=d||(SC.none(d)&&SC.none(a));if(c){b.commitRecord(undefined,undefined,this.get("storeKey"),f,g)}else{if(a){e=b.materializeRecord(a);e.commitRecord(f,d,g)}}return this},isError:function(){return !!(this.get("status")&SC.Record.ERROR)}.property("status").cacheable(),errorValue:function(){return this.get("isError")?SC.val(this.get("errorObject")):null}.property("isError").cacheable(),errorObject:function(){if(this.get("isError")){var a=this.get("store");return a.readError(this.get("storeKey"))||SC.Record.GENERIC_ERROR}else{return null}}.property("isError").cacheable(),set:function(a,c){var b=this[a];if(b&&b.isProperty&&b.get&&!b.get("isEditable")){return this}return arguments.callee.base.apply(this,arguments)},registerNestedRecord:function(f,e,g){var c,d=this.get("storeKey"),b,a,h;if(SC.none(g)){g=e}if(f&&f.get&&f.get("isRecord")){a=f}else{h=this._materializeNestedRecordType(f,e);a=this.createNestedRecord(h,f,d,g)}if(a){this.isParentRecord=YES;c=this.get("store");b=a.get("storeKey");c.registerChildToParent(d,b,g)}return a},unregisterNestedRecord:function(d){var b,a,c;c=this.get("store");b=this.getPath(d);a=b.get("storeKey");c.unregisterChildFromParent(a)},_materializeNestedRecordType:function(c,b){var a,d;if(SC.typeOf(c)===SC.T_HASH){a=this.get("nestedRecordNamespace");if(c.type&&!SC.none(a)){d=a[c.type]}}if(!d&&b&&this[b]){d=this[b].get("typeClass")}if(!d||!SC.kindOf(d,SC.Record)){throw new Error("SC.Child: Error during transform: Invalid record type.")}return d},createNestedRecord:function(h,f,c,e){var b=this.get("store"),g,a,d=null;f=f||{};if(SC.none(b)){throw new Error("Error: during the creation of a child record: NO STORE ON PARENT!")}g=f[h.prototype.primaryKey];if(!g){g=this.generateIdForChild(d)}if(!g){g=c+"."+e}a=b.storeKeyExists(h,g);if(a){b.writeDataHash(a,f);d=b.materializeRecord(a)}else{d=b.createRecord(h,f,g)}return d},_nestedRecordKey:0,generateIdForChild:function(a){}});SC.Record.mixin({ignoreUnknownProperties:NO,CLEAN:1,DIRTY:2,EMPTY:256,ERROR:4096,READY:512,READY_CLEAN:513,READY_DIRTY:514,READY_NEW:515,DESTROYED:1024,DESTROYED_CLEAN:1025,DESTROYED_DIRTY:1026,BUSY:2048,BUSY_LOADING:2052,BUSY_CREATING:2056,BUSY_COMMITTING:2064,BUSY_REFRESH:2080,BUSY_REFRESH_CLEAN:2081,BUSY_REFRESH_DIRTY:2082,BUSY_DESTROYING:2112,BAD_STATE_ERROR:SC.$error("Internal Inconsistency"),RECORD_EXISTS_ERROR:SC.$error("Record Exists"),NOT_FOUND_ERROR:SC.$error("Not found "),BUSY_ERROR:SC.$error("Busy"),GENERIC_ERROR:SC.$error("Generic Error"),isPolymorphic:NO,_nextChildKey:0,attr:function(a,b){return SC.RecordAttribute.attr(a,b)},fetch:function(b,a){return SC.FetchedAttribute.attr(b,a)},toMany:function(d,b){b=b||{};var c=b.nested||b.isNested;var a;this._throwUnlessRecordTypeDefined(d,"toMany");if(c){a=SC.ChildrenAttribute.attr(d,b)}else{a=SC.ManyAttribute.attr(d,b)}return a},toOne:function(d,b){b=b||{};var c=b.nested||b.isNested;var a;this._throwUnlessRecordTypeDefined(d,"toOne");if(c){a=SC.ChildAttribute.attr(d,b)}else{a=SC.SingleAttribute.attr(d,b)}return a},_throwUnlessRecordTypeDefined:function(b,a){if(!b){throw new Error("Attempted to create "+a+" attribute with undefined recordType. Did you forget to sc_require a dependency?")}},storeKeysById:function(){var c=this.superclass,b=SC.keyFor("storeKey",SC.guidFor(this)),a=this[b];if(!a){if(this.isPolymorphic&&c.isPolymorphic&&c!==SC.Record){a=this[b]=c.storeKeysById()}else{a=this[b]={}}}return a},storeKeyFor:function(c){var b=this.storeKeysById(),a=b[c];if(!a){a=SC.Store.generateStoreKey();SC.Store.idsByStoreKey[a]=c;SC.Store.recordTypesByStoreKey[a]=this;b[c]=a}return a},storeKeyExists:function(c){var b=this.storeKeysById(),a=b[c];return a},find:function(a,b){return a.find(this,b)},extend:function(){var a=SC.Object.extend.apply(this,arguments);if(SC.Query){SC.Query._scq_didDefineRecordType(a)}if(a.prototype.hasOwnProperty("isPolymorphic")){a.isPolymorphic=a.prototype.isPolymorphic;delete a.prototype.isPolymorphic}return a}});sc_require("data_sources/data_source");sc_require("models/record");SC.FixturesDataSource=SC.DataSource.extend({simulateRemoteResponse:NO,latency:50,cancel:function(a,b){return NO},fetch:function(a,b){if(b.get("location")!==SC.Query.LOCAL){SC.throw("SC.Fixture data source can only fetch local queries")}if(!b.get("recordType")&&!b.get("recordTypes")){SC.throw("SC.Fixture data source can only fetch queries with one or more record types")}if(this.get("simulateRemoteResponse")){this.invokeLater(this._fetch,this.get("latency"),a,b)}else{this._fetch(a,b)}},_fetch:function(a,c){var d=c.get("recordType"),b=c.get("recordTypes")||[d];b.forEach(function(e){if(SC.typeOf(e)===SC.T_STRING){e=SC.objectForPropertyPath(e)}if(e){this.loadFixturesFor(a,e)}},this);a.dataSourceDidFetchQuery(c)},retrieveRecords:function(a,c){var d=this.get("latency"),b=this.hasFixturesFor(c);if(!b){return b}if(this.get("simulateRemoteResponse")){this.invokeLater(this._retrieveRecords,d,a,c)}else{this._retrieveRecords(a,c)}return b},_retrieveRecords:function(a,b){b.forEach(function(d){var c=[],g=SC.Store.recordTypeFor(d),f=a.idFor(d),e=this.fixtureForStoreKey(a,d);c.push(d);a.dataSourceDidComplete(d,e,f)},this)},updateRecords:function(a,c,e){var d=this.get("latency"),b=this.hasFixturesFor(c);if(!b){return b}if(this.get("simulateRemoteResponse")){this.invokeLater(this._updateRecords,d,a,c)}else{this._updateRecords(a,c)}return b},_updateRecords:function(a,b){b.forEach(function(c){var d=a.readDataHash(c);this.setFixtureForStoreKey(a,c,d);a.dataSourceDidComplete(c)},this)},createRecords:function(a,b,d){var c=this.get("latency");if(this.get("simulateRemoteResponse")){this.invokeLater(this._createRecords,c,a,b)}else{this._createRecords(a,b)}return YES},_createRecords:function(a,b){b.forEach(function(e){var g=a.idFor(e),f=a.recordTypeFor(e),d=a.readDataHash(e),c=this.fixturesFor(f);if(!g){g=this.generateIdFor(f,d,a,e)}this._invalidateCachesFor(f,e,g);c[g]=d;a.dataSourceDidComplete(e,null,g)},this)},destroyRecords:function(a,c,e){var d=this.get("latency"),b=this.hasFixturesFor(c);if(!b){return b}if(this.get("simulateRemoteResponse")){this.invokeLater(this._destroyRecords,d,a,c)}else{this._destroyRecords(a,c)}return b},_destroyRecords:function(a,b){b.forEach(function(d){var f=a.idFor(d),e=a.recordTypeFor(d),c=this.fixturesFor(e);this._invalidateCachesFor(e,d,f);if(f){delete c[f]}a.dataSourceDidDestroy(d)},this)},loadFixturesFor:function(a,g,c){var b=[],e,d,f;e=this.fixturesFor(g);for(d in e){f=g.storeKeyFor(d);if(a.peekStatus(f)===SC.Record.EMPTY){b.push(e[d])}if(c){c.push(f)}}if(b&&b.length>0){a.loadRecords(g,b)}return this},generateIdFor:function(d,b,a,c){return"@id%@".fmt(SC.Store.generateStoreKey())},fixtureForStoreKey:function(a,c){var e=a.idFor(c),d=a.recordTypeFor(c),b=this.fixturesFor(d);return b?b[e]:null},setFixtureForStoreKey:function(a,d,c){var f=a.idFor(d),e=a.recordTypeFor(d),b=this.fixturesFor(e);this._invalidateCachesFor(e,d,f);b[f]=c;return this},fixturesFor:function(h){if(!this._fixtures){this._fixtures={}}var f=this._fixtures[SC.guidFor(h)];if(f){return f}var e=h?h.FIXTURES:null,b=e?e.length:0,c=h?h.prototype.primaryKey:"guid",a,d,g;this._fixtures[SC.guidFor(h)]=f={};for(a=0;a<b;a++){d=e[a];g=d[c];if(!g){g=this.generateIdFor(h,d)}f[g]=d}return f},fixturesLoadedFor:function(c){if(!this._fixtures){return NO}var a=[],b=this._fixtures[SC.guidFor(c)];return b?YES:NO},reset:function(){this._fixtures=null;return this},hasFixturesFor:function(b){var a=NO;b.forEach(function(d){if(a!==SC.MIXED_STATE){var e=SC.Store.recordTypeFor(d),c=e?e.FIXTURES:null;if(c&&c.length&&c.length>0){if(a===NO){a=YES}}else{if(a===YES){a=SC.MIXED_STATE}}}},this);return a},_invalidateCachesFor:function(d,b,c){var a=this._storeKeyCache;if(a){delete a[SC.guidFor(d)]}return this}});SC.Record.fixtures=SC.FixturesDataSource.create();SC.RelationshipSupport={_srs_inverseDidRelinquishRelationships:function(d,c,a,b){c.forEach(function(e){this._srs_inverseDidRelinquishRelationship(d,e,a,b)},this)},_srs_inverseDidRelinquishRelationship:function(b,a,f,i){var h=b.storeKeyFor(a),e=this.readDataHash(h),g=f.inverse,d=b.prototype;if(!e||!g){return}if(SC.instanceOf(d[g],SC.SingleAttribute)){delete e[g]}else{if(SC.instanceOf(d[g],SC.ManyAttribute)&&SC.typeOf(e[g])===SC.T_ARRAY){e[g].removeObject(i);var c=this.records[h];if(c){c.get(g)._records=null}}}this.pushRetrieve(b,a,e,undefined,true)},_srs_inverseDidAddRelationships:function(d,c,a,b){c.forEach(function(e){this._srs_inverseDidAddRelationship(d,e,a,b)},this)},_srs_inverseDidAddRelationship:function(b,a,i,k){var j=b.storeKeyFor(a),g=this.readDataHash(j),d=this.peekStatus(j),f=b.prototype,h=i.inverse,l=f[h],c=f[f.primaryKey],e=false;l=(l&&l.get&&l.get("key")||l.key)||h;if((d===SC.Record.EMPTY)&&(SC.typeOf(i.lazilyInstantiate)===SC.T_FUNCTION&&i.lazilyInstantiate()||SC.typeOf(i.lazilyInstantiate)!==SC.T_FUNCTION&&i.lazilyInstantiate)){if(!SC.none(c)&&c.typeClass&&SC.typeOf(c.typeClass())===SC.T_CLASS){e=true}g={};g[f.primaryKey]=a}if(!g||!h){return}if(SC.instanceOf(f[h],SC.SingleAttribute)){g[l]=k}else{if(SC.instanceOf(f[h],SC.ManyAttribute)){g[l]=g[l]||[];if(g[l].indexOf(k)<0){g[l].push(k)}}}this.pushRetrieve(b,a,g,undefined,!e)},_srs_pushIterator:function(d,b,i,f){var e=d.prototype,g,c,h,a;if(typeof i==="undefined"){i=d.storeKeyFor(b)}c=this.readDataHash(i)||{};for(h in e){g=e[h];if(g&&g.typeClass&&g.inverse&&g.isMaster){a=g.typeClass();if(SC.typeOf(a)!==SC.T_CLASS){continue}f.apply(this,[a,c,g,g.get&&g.get("key")||h])}}},pushDestroy:function(a,e,d,c){var b;this._srs_pushIterator(e,d,c,function(f,g,i,h){b=[g[h]||null].flatten().compact().uniq();this._srs_inverseDidRelinquishRelationships(f,b,i,d)});return a(e,d,c)}.enhance(),pushRetrieve:function(b,h,g,c,e,f){if(!f){var d,a;this._srs_pushIterator(h,g,e,function(i,j,l,k){a=[c[k]||null].flatten().compact().uniq();d=[j[k]||null].flatten().compact().uniq();d=d.filter(function(m){return a.indexOf(m)===-1});this._srs_inverseDidRelinquishRelationships(i,d,l,g);this._srs_inverseDidAddRelationships(i,a,l,g)})}e=e||h.storeKeyFor(g);return b(h,g,c,e)}.enhance()};sc_require("models/record");SC.RecordAttribute=SC.Object.extend({isRecordAttribute:YES,defaultValue:null,type:String,key:null,isRequired:NO,isEditable:YES,useIsoDate:YES,aggregate:NO,lazilyInstantiate:NO,typeClass:function(){var a=this.get("type");if(SC.typeOf(a)===SC.T_STRING){a=SC.requiredObjectForPropertyPath(a)}return a}.property("type").cacheable(),transform:function(){var a=this.get("typeClass")||String,c=SC.RecordAttribute.transforms,b;while(a&&!(b=c[SC.guidFor(a)])){if(a.superclass.hasOwnProperty("create")){a=a.superclass}else{a=SC.T_FUNCTION}}return b}.property("typeClass").cacheable(),toType:function(e,j,h){var c=this.get("transform"),g=this.get("typeClass"),b;if(c&&c.to){h=c.to(h,this,g,e,j);if(!SC.none(h)&&(b=c.observesChildren)){var d,f=b.length,a={record:e,key:j};for(d=0;d<f;d++){h.addObserver(b[d],this,this._SCRA_childObserver,a)}}}return h},_SCRA_childObserver:function(d,b,c,a){this.call(a.record,a.key,d);a.record.notifyPropertyChange(a.key)},fromType:function(a,c,e){var b=this.get("transform"),d=this.get("typeClass");if(b&&b.from){e=b.from(e,this,d,a,c)}return e},call:function(a,b,c){var d=this.get("key")||b,e;if((c!==undefined)&&this.get("isEditable")){e=this.fromType(a,b,c);a.writeAttribute(d,e)}c=a.readAttribute(d);if(SC.none(c)&&(c=this.get("defaultValue"))){if(typeof c===SC.T_FUNCTION){c=c(a,b,this)}}c=this.toType(a,b,c);return c},apply:function(b,a){return this.call.apply(b,a)},isProperty:YES,isCacheable:YES,dependentKeys:[],init:function(){arguments.callee.base.apply(this,arguments);this.cacheKey="__cache__recattr__"+SC.guidFor(this);this.lastSetValueKey="__lastValue__recattr__"+SC.guidFor(this)}});SC.RecordAttribute.mixin({attr:function(a,b){if(!b){b={}}if(!b.type){b.type=a||String}return this.create(b)},transforms:{},registerTransform:function(a,b){SC.RecordAttribute.transforms[SC.guidFor(a)]=b}});SC.RecordAttribute.registerTransform(Boolean,{to:function(a){return SC.none(a)?null:!!a}});SC.RecordAttribute.registerTransform(Number,{to:function(a){return SC.none(a)?null:Number(a)}});SC.RecordAttribute.registerTransform(String,{to:function(a){if(!(typeof a===SC.T_STRING)&&!SC.none(a)&&a.toString){a=a.toString()}return a}});SC.RecordAttribute.registerTransform(Array,{to:function(a){if(!SC.isArray(a)&&!SC.none(a)){a=[]}return a},observesChildren:["[]"]});SC.RecordAttribute.registerTransform(Object,{to:function(a){if(!(typeof a==="object")&&!SC.none(a)){a={}}return a}});SC.RecordAttribute.registerTransform(SC.Record,{to:function(e,a,d,c){var b=c.get("store");if(SC.none(e)||(e==="")){return null}else{return b.find(d,e)}},from:function(a){return a?a.get("id"):null}});SC.RecordAttribute.registerTransform(SC.T_FUNCTION,{to:function(e,a,d,c){d=d.apply(c);var b=c.get("store");return b.find(d,e)},from:function(a){return a.get("id")}});SC.RecordAttribute.registerTransform(Date,{to:function(i,a){if(SC.none(i)){return i}var c;i=i.toString()||"";if(a.get("useIsoDate")){var e="([0-9]{4})(-([0-9]{2})(-([0-9]{2})(T([0-9]{2}):([0-9]{2})(:([0-9]{2})(\\.([0-9]+))?)?(Z|(([-+])([0-9]{2}):([0-9]{2})))?)?)?)?",h=i.match(new RegExp(e)),g=0,b=new Date(h[1],0,1),f;if(h[3]){b.setMonth(h[3]-1)}if(h[5]){b.setDate(h[5])}if(h[7]){b.setHours(h[7])}if(h[8]){b.setMinutes(h[8])}if(h[10]){b.setSeconds(h[10])}if(h[12]){b.setMilliseconds(Number("0."+h[12])*1000)}if(h[14]){g=(Number(h[16])*60)+Number(h[17]);g*=((h[15]==="-")?1:-1)}g-=b.getTimezoneOffset();f=(Number(b)+(g*60*1000));c=new Date();c.setTime(Number(f))}else{c=new Date(Date.parse(i))}return c},_dates:{},_zeropad:function(a){return((a<0)?"-":"")+((a<10)?"0":"")+Math.abs(a)},from:function(b){if(SC.none(b)){return null}var a=this._dates[b.getTime()];if(a){return a}var d=this._zeropad,c=0-b.getTimezoneOffset()/60;c=(c===0)?"Z":"%@:00".fmt(d(c));this._dates[b.getTime()]=a="%@-%@-%@T%@:%@:%@%@".fmt(d(b.getFullYear()),d(b.getMonth()+1),d(b.getDate()),d(b.getHours()),d(b.getMinutes()),d(b.getSeconds()),c);return a}});if(SC.DateTime&&!SC.RecordAttribute.transforms[SC.guidFor(SC.DateTime)]){SC.RecordAttribute.registerTransform(SC.DateTime,{to:function(c,a){if(SC.none(c)||SC.instanceOf(c,SC.DateTime)){return c}if(a.get("useUnixTime")){if(SC.typeOf(c)===SC.T_STRING){c=parseInt(c)}if(isNaN(c)||SC.typeOf(c)!==SC.T_NUMBER){c=0}return SC.DateTime.create({milliseconds:c*1000,timezone:0})}if(SC.instanceOf(c,Date)){return SC.DateTime.create(c.getTime())}var b=a.get("format");return SC.DateTime.parse(c,b?b:SC.DateTime.recordFormat)},from:function(b,a){if(SC.none(b)){return b}if(a.get("useUnixTime")){return b.get("milliseconds")/1000}var c=a.get("format");return b.toFormattedString(c?c:SC.DateTime.recordFormat)}})}SC.RecordAttribute.registerTransform(SC.Set,{to:function(e,a,d,b,c){return SC.Set.create(e)},from:function(e,a,d,b,c){return e.toArray()},observesChildren:["[]"]});sc_require("models/record");sc_require("models/record_attribute");SC.ChildAttribute=SC.RecordAttribute.extend({isNestedRecordTransform:YES,toType:function(b,d,e){var c=null,a,f=this.get("typeClass");if(!b){throw new Error("SC.Child: Error during transform: Unable to retrieve parent record.")}if(!SC.none(e)){c=b.registerNestedRecord(e,d)}return c},fromType:function(b,e,f){var a,c,d;if(b){if(b.readAttribute(e)){b.unregisterNestedRecord(e)}if(SC.none(f)){b.writeAttribute(e,f);d=f}else{d=b.registerNestedRecord(f,e);if(d){a=d.get("storeKey");c=d.get("store");b.writeAttribute(e,c.readDataHash(a))}else{if(f){b.writeAttribute(e,f)}}}}return d},call:function(a,b,c){var d=this.get("key")||b;if(c!==undefined){c=this.fromType(a,b,c)}else{c=a.readAttribute(d);if(SC.none(c)&&(c=this.get("defaultValue"))){if(typeof c===SC.T_FUNCTION){c=this.defaultValue(a,b,this);if(a.attributes()){a.writeAttribute(d,c,true)}}}else{c=this.toType(a,b,c)}}return c}});sc_require("models/record");SC.ChildRecord=SC.Record.extend({});SC.ChildRecord.extend=function(){return SC.Record.extend.apply(this,arguments)};SC.ChildArray=SC.Object.extend(SC.Enumerable,SC.Array,{defaultRecordType:null,record:null,propertyName:null,store:function(){return this.getPath("record.store")}.property("record").cacheable(),storeKey:function(){return this.getPath("record.storeKey")}.property("record").cacheable(),readOnlyChildren:function(){return this.get("record").readAttribute(this.get("propertyName"))}.property(),editableChildren:function(){var a=this.get("store"),d=this.get("storeKey"),c=this.get("propertyName"),b,e;b=a.readEditableProperty(d,c);if(!b){e=a.readEditableDataHash(d);b=e[c]=[]}return b}.property(),length:function(){var a=this.get("readOnlyChildren");return a?a.length:0}.property("readOnlyChildren"),objectAt:function(b){var g=this._records,e=this.get("readOnlyChildren"),h,c,d=this.get("propertyName"),f=this.get("record"),a=e?e.length:0;if(!e){return undefined}if(g&&(c=g[b])){return c}if(b>=a){return undefined}h=e.objectAt(b);if(!h){return undefined}if(!g){this._records=g=[]}g[b]=c=f.registerNestedRecord(h,d,d+"."+b);return c},replace:function(p,c,l){var d=this.get("editableChildren"),m=l?(l.get?l.get("length"):l.length):0,n=this.get("record"),f=this.get("propertyName"),o=this.get("store"),b,q,j,r,a,e,g,h;if(!this._records){this._records=[]}a=this._processRecordsToHashes(l);j=this.get("defaultRecordType");r=j.storeKeysById();for(g=p,h=p+c;g<h;g++){e=this._records[g];if(!e){e=n.registerNestedRecord(d[g],f,f+"."+g)}else{this._records[g]=null}r[e.get("id")]=null}for(g=p+c,h=this._records.length;g<h;g++){e=this._records[g];if(e){o.unregisterChildFromParent(e.get("storeKey"));this._records[g]=null}}b=d.length-p;q=d.length-p-c+m;this.arrayContentWillChange(p,b,q);if(a.length===0){d.splice(p,c)}else{var k=[p,c].concat(a);d.splice.apply(d,k)}for(g=p,h=d.length;g<h;g++){this._records[g]=n.registerNestedRecord(d[g],f,f+"."+g)}this.arrayContentDidChange(p,b,q);this._sc_prevChildren=d;n.recordDidChange(f);return this},normalize:function(){this.forEach(function(a){if(a.normalize){a.normalize()}})},_processRecordsToHashes:function(d){var b,a,c=[];d.forEach(function(f,e){if(f.isNestedRecord){b=f.get("store");a=f.storeKey;c[e]=b.readDataHash(a)}else{c[e]=f}});return c},recordPropertyDidChange:function(d){var c=this.get("length"),b=this.get("readOnlyChildren"),e=b?b.length:0,a=this._sc_prevChildren;if(a===b){return}this._records=null;this.arrayContentDidChange(0,c,e);this._sc_prevChildren=b}});sc_require("models/record");sc_require("models/record_attribute");sc_require("models/child_attribute");sc_require("system/child_array");SC.ChildrenAttribute=SC.ChildAttribute.extend({toType:function(b,d,e){var g=this.get("key")||d,f=SC.keyFor("__kidsArray__",SC.guidFor(this)),c=b[f],h=this.get("typeClass"),a;if(!c){c=SC.ChildArray.create({record:b,propertyName:g,defaultRecordType:h});b[f]=c;a=b.get("relationships");if(!a){b.set("relationships",a=[])}a.push(c)}return c},fromType:function(b,e,f){var a,c,g=SC.keyFor("__kidsArray__",SC.guidFor(this)),d=b[g];if(b){b.writeAttribute(e,f);if(d){d=d.recordPropertyDidChange()}}return d}});sc_require("models/record");sc_require("models/record_attribute");SC.FetchedAttribute=SC.RecordAttribute.extend({paramValueKey:"link",paramOwnerKey:"owner",paramRelKey:"rel",queryKey:null,isEditable:NO,toType:function(d,i,g){var h=d.get("store");if(!h){return null}var b=this.get("paramValueKey"),a=this.get("paramOwnerKey"),f=this.get("paramRelKey"),e=this.get("queryKey")||this.get("typeClass"),c={};if(b){c[b]=g}if(a){c[a]=d}if(f){c[f]=this.get("key")||i}return h.find(e,c)},fromType:function(a,b,c){return c}});SC.ManyArray=SC.Object.extend(SC.Enumerable,SC.Array,{recordType:null,record:null,propertyName:null,manyAttribute:null,store:function(){return this.get("record").get("store")}.property("record").cacheable(),storeKey:function(){return this.get("record").get("storeKey")}.property("record").cacheable(),supportNewRecords:NO,readOnlyStoreIds:function(){return this.get("record").readAttribute(this.get("propertyName"))}.property(),editableStoreIds:function(){var a=this.get("store"),d=this.get("storeKey"),c=this.get("propertyName"),b,e;b=a.readEditableProperty(d,c);if(!b){e=a.readEditableDataHash(d);b=e[c]=[]}return b}.property(),isEditable:function(){var a=this.manyAttribute;return a?a.get("isEditable"):NO}.property("manyAttribute").cacheable(),inverse:function(){var a=this.manyAttribute;return a?a.get("inverse"):null}.property("manyAttribute").cacheable(),isMaster:function(){var a=this.manyAttribute;return a?a.get("isMaster"):null}.property("manyAttribute").cacheable(),orderBy:function(){var a=this.manyAttribute;return a?a.get("orderBy"):null}.property("manyAttribute").cacheable(),length:function(){var a=this.get("readOnlyStoreIds");return a?a.get("length"):0}.property("readOnlyStoreIds"),objectAt:function(g){var e=this._records,a=this.get("readOnlyStoreIds"),f=this.get("store"),b=this.get("recordType"),c=a?a.length:0,i,d,h;if(!a||!f){return undefined}if(e&&(d=e[g])){return d}if(g>=c){return undefined}h=a.objectAt(g);if(!h){return undefined}if(!e){this._records=e=[]}if(typeof h===SC.T_STRING&&h.indexOf("_sc_id_placeholder_")===0){i=h.replace("_sc_id_placeholder_","")}else{i=f.storeKeyFor(b,h)}if(f.readStatus(i)===SC.Record.EMPTY){f.retrieveRecord(b,null,i)}e[g]=d=f.materializeRecord(i);return d},replace:function(r,e,o){var c=this.get("editableStoreIds"),p=o?(o.get?o.get("length"):o.length):0,q=this.get("record"),g=this.get("propertyName"),n=this.get("supportNewRecords"),a,b,h,l,k,j;if(!this._records){this._records=[]}a=[];for(j=0;j<p;j++){var f=o.objectAt(j),d=f.get("id");if(SC.none(d)){if(n){a[j]="_sc_id_placeholder_"+f.get("storeKey")}else{throw new Error("Developer Error: Attempted to add a record without a primary key to a to-many relationship (%@). The record must have a real id or be given a temporary id before it can be used. ".fmt(g))}}else{a[j]=d}}h=this.get("inverse");if(h&&e>0){b=SC.ManyArray._toRemove;if(b){SC.ManyArray._toRemove=null}else{b=[]}for(j=0;j<e;j++){b[j]=this.objectAt(r+j)}}this.arrayContentWillChange(r,e,p);if(a.length===0){c.splice(r,e);this._records.splice(r,e)}else{var m=[r,e].concat(a);c.splice.apply(c,m);m=[r,e].concat(new Array(a.length));this._records.splice.apply(this._records,m)}if(h){for(j=0;j<e;j++){k=b[j];l=k?k[h]:null;if(l&&l.inverseDidRemoveRecord){l.inverseDidRemoveRecord(k,h,q,g)}}if(b){b.length=0;if(!SC.ManyArray._toRemove){SC.ManyArray._toRemove=b}}for(j=0;j<p;j++){k=o.objectAt(j);l=k?k[h]:null;if(l&&l.inverseDidAddRecord){l.inverseDidAddRecord(k,h,q,g)}}}this.arrayContentDidChange(r,e,p);this._sc_prevStoreIds=c;if(q&&(!h||this.get("isMaster"))){q.recordDidChange(g)}return this},removeInverseRecord:function(c){if(!c){return this}var e=c.get("id"),d=this.get("editableStoreIds"),a=(d&&e)?d.indexOf(e):-1,b;if(a>=0){this.arrayContentWillChange(a,1,0);d.splice(a,1);if(this._records){this._records.splice(a,1)}this.arrayContentDidChange(a,1,0);this._sc_prevStoreIds=d;if(this.get("isMaster")&&(b=this.get("record"))){b.recordDidChange(this.get("propertyName"))}}return this},addInverseRecord:function(d){if(!d){return this}var f=this.get("editableStoreIds"),h=this.get("orderBy"),b=f.get("length"),a,c,g,e;if(h){a=this._findInsertionLocation(d,0,b,h);g=f.length-a;e=f.length-a+1}else{a=b;g=0;e=1}this.arrayContentWillChange(a,g,e);f.splice(a,0,d.get("id"));if(this._records){this._records.splice(a,0,null)}this.arrayContentDidChange(a,g,e);this._sc_prevStoreIds=f;if(this.get("isMaster")&&(c=this.get("record"))){c.recordDidChange(this.get("propertyName"))}return this},_findInsertionLocation:function(g,d,c,f){var b=d+Math.floor((c-d)/2),e=this.objectAt(b),a=this._compare(g,e,f);if(a<0){if(b===0){return b}else{return this._findInsertionLocation(g,0,b-1,f)}}else{if(a>0){if(b>=c){return b+1}else{return this._findInsertionLocation(g,b+1,c,f)}}else{return b}}},_compare:function(f,e,i){var h=SC.typeOf(i),g,d,c;if(h===SC.T_FUNCTION){g=i(f,e)}else{if(h===SC.T_STRING){g=SC.compare(f,e)}else{c=i.get("length");g=0;for(d=0;g===0&&d<c;d++){g=SC.compare(f,e)}}}return g},updateNewRecordId:function(c){var b=this.get("editableStoreIds"),a;a=b.indexOf("_sc_id_placeholder_"+c.get("storeKey"));if(a>=0){b.replace(a,1,[c.get("id")])}},unknownProperty:function(b,c){var a;if(SC.typeOf(b)===SC.T_STRING){a=this.reducedProperty(b,c)}return a===undefined?arguments.callee.base.apply(this,arguments):a},init:function(){arguments.callee.base.apply(this,arguments);this.recordPropertyDidChange()},recordPropertyDidChange:function(c){if(c&&!c.contains(this.get("propertyName"))){return this}var a=this.get("length"),e=this.get("readOnlyStoreIds"),d=e?e.length:0,b=this._sc_prevStoreIds;if(e===b){return}this._records=null;this.arrayContentDidChange(0,a,d);this._sc_prevStoreIds=e}});sc_require("models/record");sc_require("models/record_attribute");sc_require("system/many_array");SC.ManyAttribute=SC.RecordAttribute.extend({inverse:null,isMaster:YES,orderBy:null,supportNewRecords:true,toType:function(c,h,g){var f=this.get("typeClass"),e=this.get("supportNewRecords"),a=this.get("key")||h,b=SC.keyFor("__manyArray__",SC.guidFor(this)),d=c[b],i;if(!d){d=SC.ManyArray.create({recordType:f,record:c,propertyName:a,manyAttribute:this,supportNewRecords:e});c[b]=d;i=c.get("relationships");if(!i){c.set("relationships",i=[])}i.push(d)}return d},fromType:function(b,e,f){var c=[];if(!SC.isArray(f)){throw new Error("Expects toMany attribute to be an array")}var a=f.get("length");for(var d=0;d<a;d++){c[d]=f.objectAt(d).get("id")}return c},inverseDidRemoveRecord:function(a,b,c,d){var e=a.get(b);if(e){e.removeInverseRecord(c)}},inverseDidAddRecord:function(a,b,c,d){var e=a.get(b);if(e){e.addInverseRecord(c)}}});sc_require("models/record");sc_require("models/record_attribute");SC.SingleAttribute=SC.RecordAttribute.extend({inverse:null,isMaster:YES,call:function(c,i,b){var a=this.get("key")||i,h,g,j,f,e,d;if(b!==undefined&&this.get("isEditable")){h=this.get("inverse");if(h){j=this._scsa_call(c,i)}d=this.fromType(c,i,b);c.writeAttribute(a,d,!this.get("isMaster"));e=b;if(h&&(j!==b)){if(j&&(f=j[h])){f.inverseDidRemoveRecord(j,h,c,i)}if(b&&(f=b[h])){f.inverseDidAddRecord(b,h,c,i)}}}else{e=this._scsa_call(c,i,b)}return e},_scsa_call:SC.RecordAttribute.prototype.call,inverseDidRemoveRecord:function(c,f,g,h){var b=this.get("inverse"),e=this._scsa_call(c,f),d=this.get("isMaster"),a;c.writeAttribute(this.get("key")||f,null,!d);c.notifyPropertyChange(f);if((e!==g)||(h!==b)){if(e&&(a=e[b])){a.inverseDidRemoveRecord(e,b,c,f)}}},inverseDidAddRecord:function(a,h,c,g){var e=this.get("inverse"),i=this._scsa_call(a,h),f=this.get("isMaster"),d,b;b=this.fromType(a,h,c);a.writeAttribute(this.get("key")||h,b,!f);a.notifyPropertyChange(h);if((i!==c)||(g!==e)){if(i&&(d=i[e])){d.inverseDidRemoveRecord(i,e,a,h)}}}});sc_require("models/record");SC.Store=SC.Object.extend({name:null,nestedStores:null,dataSource:null,isNested:NO,commitRecordsAutomatically:NO,from:function(a){this.set("dataSource",a);return this},_getDataSource:function(){var a=this.get("dataSource");if(typeof a===SC.T_STRING){a=SC.requiredObjectForPropertyPath(a);if(a.isClass){a=a.create()}this.set("dataSource",a)}return a},cascade:function(c){var d;d=new Array(arguments.length);for(var b=0,a=d.length;b<a;b++){d[b]=arguments[b]}c=SC.CascadeDataSource.create({dataSources:d});return this.from(c)},chain:function(b,c){if(!b){b={}}b.parentStore=this;if(c){if(SC.typeOf(c)!=="class"){throw new Error("%@ is not a valid class".fmt(c))}if(!SC.kindOf(c,SC.NestedStore)){throw new Error("%@ is not a type of SC.NestedStore".fmt(c))}}else{c=SC.NestedStore}b.childRecords=this.childRecords?SC.clone(this.childRecords):{};b.parentRecords=this.parentRecords?SC.clone(this.parentRecords):{};var a=c.create(b),d=this.nestedStores;if(!d){d=this.nestedStores=[]}d.push(a);return a},chainAutonomousStore:function(a,d){var b=a?SC.clone(a):{};var c=this._getDataSource();b.dataSource=c;return this.chain(b,d)},willDestroyNestedStore:function(a){if(this.nestedStores){this.nestedStores.removeObject(a)}return this},hasNestedStore:function(a){while(a&&(a!==this)){a=a.get("parentStore")}return a===this},dataHashes:null,statuses:null,revisions:null,editables:null,changelog:null,recordErrors:null,queryErrors:null,childRecords:null,parentRecords:null,storeKeyEditState:function(a){var b=this.editables;return(b&&b[a])?SC.Store.EDITABLE:SC.Store.LOCKED},readDataHash:function(a){return this.dataHashes[a]},readEditableDataHash:function(b){var a=this.dataHashes[b];if(!a){return a}var c=this.editables;if(!c){c=this.editables=[]}if(!c[b]){c[b]=1;a=this.dataHashes[b]=SC.clone(a,YES)}return a},readEditableProperty:function(c,a){var e=this.readEditableDataHash(c),d=this.editables[c],b=e[a];if(d===1){d=this.editables[c]={}}if(!d[a]){b=e[a];if(b&&b.isCopyable){b=e[a]=b.copy(YES)}d[a]=YES}return b},writeDataHash:function(b,d,a){if(d){this.dataHashes[b]=d}if(a){this.statuses[b]=a}var c=this.editables;if(!c){c=this.editables=[]}c[b]=1;this._updateChildRecordHashes(b,d,a);return this},_updateChildRecordHashes:function(i,d,c){var e={};if(!SC.none(this.parentRecords)){var a=this.parentRecords[i]||{},b;for(var h in a){if(a.hasOwnProperty(h)){if(d){var g=a[h];g=g.split(".");if(g.length>1){b=d[g[0]][g[1]]}else{b=d[g[0]]}if(!e[d[g[0]]]){this.writeDataHash(h,b,c)}if(g.length>1&&!e[d[g[0]]]){e[d[g[0]]]=true;var f=this;this.invokeLast(function(){f.records[i].get(g[0]).forEach(function(j){})})}}else{this.writeDataHash(h,null,c)}}}}},removeDataHash:function(b,a){this.dataHashes[b]=null;this.statuses[b]=a||SC.Record.EMPTY;var c=this.editables;if(c){c[b]=0}return this},readStatus:function(a){this.readDataHash(a);return this.statuses[a]||SC.Record.EMPTY},peekStatus:function(a){return this.statuses[a]||SC.Record.EMPTY},writeStatus:function(d,a){var c=this,b;b=this.writeDataHash(d,null,a);this._propagateToChildren(d,function(e){c.writeStatus(e,a)});return b},dataHashDidChange:function(e,b,a,h){if(!b){b=SC.Store.generateStoreKey()}var c,f,g,i;c=SC.typeOf(e)===SC.T_ARRAY;if(c){f=e.length}else{f=1;i=e}var d=this;for(g=0;g<f;g++){if(c){i=e[g]}this.revisions[i]=b;this._notifyRecordPropertyChange(i,a,h);this._propagateToChildren(i,function(j){d.dataHashDidChange(j,null,a,h)})}return this},_notifyRecordPropertyChange:function(m,e,l){var a=this.records,g=this.get("nestedStores"),h=SC.Store,c,b,f,k,j,d,n;f=g?g.length:0;for(k=0;k<f;k++){j=g[k];d=j.peekStatus(m);b=j.storeKeyEditState(m);if(b===h.INHERITED){j._notifyRecordPropertyChange(m,e,l)}else{if(d&SC.Record.BUSY){if(j.get("hasChanges")){h.CHAIN_CONFLICT_ERROR.throw()}j.reset()}}}var i=this.recordPropertyChanges;if(!i){i=this.recordPropertyChanges={storeKeys:SC.CoreSet.create(),records:SC.CoreSet.create(),hasDataChanges:SC.CoreSet.create(),propertyForStoreKeys:{}}}i.storeKeys.add(m);if(a&&(c=a[m])){i.records.push(m);if(!e){i.hasDataChanges.push(m)}if(l){if(!(n=i.propertyForStoreKeys[m])){n=i.propertyForStoreKeys[m]=SC.CoreSet.create()}if(n!=="*"){n.add(l)}}else{i.propertyForStoreKeys[m]="*"}}this.invokeOnce(this.flush);return this},flush:function(){if(!this.recordPropertyChanges){return this}var h=this.recordPropertyChanges,g=h.storeKeys,i=h.hasDataChanges,a=h.records,f=h.propertyForStoreKeys,d=SC.CoreSet.create(),c,b,e,j;g.forEach(function(k){if(a.contains(k)){e=i.contains(k)?NO:YES;c=this.records[k];j=f?f[k]:null;if(j==="*"){j=null}a.remove(k);if(c){c.storeDidChangeProperties(e,j)}}b=SC.Store.recordTypeFor(k);d.add(b)},this);if(g.get("length")>0){this._notifyRecordArrays(g,d)}g.clear();i.clear();a.clear();this.recordPropertyChanges.propertyForStoreKeys={};return this},reset:function(){this.dataHashes={};this.revisions={};this.statuses={};this.records={};this.childRecords={};this.parentRecords={};this.chainedChanges=this.locks=this.editables=null;this.changelog=null;this.recordErrors=null;this.queryErrors=null;var e=this.get("dataSource");if(e&&e.reset){e.reset()}var b=this.records,c;if(b){for(c in b){if(!b.hasOwnProperty(c)){continue}this._notifyRecordPropertyChange(parseInt(c,10),NO)}}var d,a=this.get("recordArrays");if(a){while((d=a.pop())){d.destroy()}a.clear();this.set("recordArrays",null)}this.set("hasChanges",NO)},commitChangesFromNestedStore:function(j,t,d){if(!d&&j.get("conflictedStoreKeys")){SC.Store.CHAIN_CONFLICT_ERROR.throw()}var p=t.length,o,f,c,l,e,b,h,a,q,r,g,m,k;b=this.revisions;c=this.dataHashes;l=this.statuses;e=this.editables;h=this.parentRecords?this.parentRecords:this.parentRecords={};a=this.childRecords?this.childRecords:this.childRecords={};if(!e){e=this.editables=[]}q=j.dataHashes;g=j.revisions;r=j.statuses;m=j.parentRecords||{};k=j.childRecords||{};for(o=0;o<p;o++){f=t[o];c[f]=q[f];l[f]=r[f];b[f]=g[f];h[f]=m[f];a[f]=k[f];e[f]=0;this._notifyRecordPropertyChange(f,NO)}var n=this.changelog,s=j.changelog;if(s){if(!n){n=this.changelog=SC.CoreSet.create()}n.addEach(s)}this.changelog=n;if(!this.get("parentStore")){this.flush()}return this},find:function(b,a){if(SC.typeOf(b)===SC.T_STRING){b=SC.objectForPropertyPath(b)}if((arguments.length===1)&&!(b&&b.get&&b.get("isRecord"))){if(!b){throw new Error("SC.Store#find() must pass recordType or query")}if(!b.isQuery){b=SC.Query.local(b)}return this._findQuery(b,YES,YES)}else{return this._findRecord(b,a)}},_findQuery:function(f,a,e){var b=this._scst_recordArraysByQuery,d=SC.guidFor(f),c,g;if(!b){b=this._scst_recordArraysByQuery={}}c=b[d];if(!c&&a){b[d]=c=SC.RecordArray.create({store:this,query:f});g=this.get("recordArrays");if(!g){this.set("recordArrays",g=SC.Set.create())}g.add(c);if(e){this.refreshQuery(f)}}this.flush();return c},_findRecord:function(c,b){var a;if(c&&c.get&&c.get("isRecord")){a=c.get("storeKey")}else{a=b?c.storeKeyFor(b):null}if(a&&(this.peekStatus(a)===SC.Record.EMPTY)){a=this.retrieveRecord(c,b)}return a?this.materializeRecord(a):null},recordArrayWillDestroy:function(b){var a=this._scst_recordArraysByQuery,c=this.get("recordArrays");if(a){delete a[SC.guidFor(b.get("query"))]}if(c){c.remove(b)}return this},refreshQuery:function(d){if(!d){throw new Error("refreshQuery() requires a query")}var a=this._scst_recordArraysByQuery,c=a?a[SC.guidFor(d)]:null,b=this._getDataSource();if(b&&b.fetch){if(c){c.storeWillFetchQuery(d)}b.fetch.call(b,this,d)}return this},_notifyRecordArrays:function(b,a){var c=this.get("recordArrays");if(!c){return this}c.forEach(function(d){if(d){d.storeDidChangeStoreKeys(b,a)}},this);return this},recordsFor:function(f){var d=[],a=f.storeKeysById(),e,c,b;for(e in a){c=a[e];if(this.readStatus(c)!==SC.RECORD_EMPTY){d.push(c)}}if(d.length>0){b=SC.RecordArray.create({store:this,storeKeys:d})}else{b=d}return b},_CACHED_REC_ATTRS:{},_CACHED_REC_INIT:function(){},materializeRecord:function(e){var b=this.records,d,f,c;if(!b){b=this.records={}}d=b[e];if(d){return d}f=SC.Store.recordTypeFor(e);if(!f){return null}c=this._CACHED_REC_ATTRS;c.storeKey=e;c.store=this;var a=f.prototype._object_init;f.prototype._object_init=this._CACHED_REC_INIT;d=b[e]=f.create();f.prototype._object_init=d._object_init=a;d._object_init([c]);return d},createRecord:function(d,f,b){var m,l,n,e,k=SC.Record,h,j,i;f=(f?f:{});if(!b&&(m=d.prototype.primaryKey)){b=f[m];j=d.prototype[m]?d.prototype[m].defaultValue:null;if(!b&&SC.typeOf(j)===SC.T_FUNCTION){b=f[m]=j()}}n=b?d.storeKeyFor(b):SC.Store.generateStoreKey();e=this.readStatus(n);if((e&k.BUSY)||(e&k.READY)||(e===k.DESTROYED_DIRTY)){(b?k.RECORD_EXISTS_ERROR:k.BAD_STATE_ERROR).throw()}else{if(!b&&(e===SC.DESTROYED_CLEAN||e===SC.ERROR)){k.BAD_STATE_ERROR.throw()}}this.writeDataHash(n,f,k.READY_NEW);SC.Store.replaceRecordTypeFor(n,d);this.dataHashDidChange(n);i=this.materializeRecord(n);l=d.prototype;for(var a in l){var g=l[a];if(g&&g.isRecordAttribute){var c=g.key||a;if(!f.hasOwnProperty(c)){if(f.hasOwnProperty(a)){f[c]=f[a];delete f[a]}else{j=g.defaultValue;if(j){if(SC.typeOf(j)===SC.T_FUNCTION){f[c]=SC.copy(j(i,c),YES)}else{f[c]=SC.copy(j,YES)}}}}else{if(c!==a&&f.hasOwnProperty(a)){delete f[a]}}}}h=this.changelog;if(!h){h=SC.Set.create()}h.add(n);this.changelog=h;if(this.get("commitRecordsAutomatically")){this.invokeLast(this.commitRecords)}if(i){i.propagateToAggregates()}return i},createRecords:function(d,i,a){var g=[],c,b,e,f=i.length,h;e=SC.typeOf(d)===SC.T_ARRAY;if(!e){c=d}for(h=0;h<f;h++){if(e){c=d[h]||SC.Record}b=a?a[h]:undefined;g.push(this.createRecord(c,i[h],b))}return g},unloadRecord:function(g,f,e,c){if(e===undefined){e=g.storeKeyFor(f)}var b=this.readStatus(e),a=SC.Record;c=c||a.EMPTY;if((b===a.BUSY_DESTROYING)||(b&a.DESTROYED)){return this}else{if(b&a.BUSY){a.BUSY_ERROR.throw()}else{b=c}}this.removeDataHash(e,b);this.dataHashDidChange(e);delete this.records[e];var d=this;this._propagateToChildren(e,function(h){d.unregisterChildFromParent(h)});if(this.parentRecords){delete this.parentRecords[e]}return this},unloadRecords:function(d,a,g,e){var h,f,i,b,c,j;if(g===undefined){f=SC.typeOf(d)===SC.T_ARRAY;if(!f){c=d}if(a===undefined){h=f?d.length:1;for(i=0;i<h;i++){if(f){c=d[i]}g=this.storeKeysFor(c);this.unloadRecords(undefined,undefined,g,e)}}else{h=a.length;for(i=0;i<h;i++){if(f){c=d[i]||SC.Record}b=a?a[i]:undefined;this.unloadRecord(c,b,undefined,e)}}}else{h=g.length;for(i=0;i<h;i++){j=g?g[i]:undefined;this.unloadRecord(undefined,undefined,j,e)}}return this},destroyRecord:function(g,f,e){if(e===undefined){e=g.storeKeyFor(f)}var b=this.readStatus(e),c,a=SC.Record;if((b===a.BUSY_DESTROYING)||(b&a.DESTROYED)){return this}else{if(b===a.EMPTY){a.NOT_FOUND_ERROR.throw()}else{if(b&a.BUSY){a.BUSY_ERROR.throw()}else{if(b===a.READY_NEW){b=a.DESTROYED_CLEAN;this.removeDataHash(e,b)}else{b=a.DESTROYED_DIRTY}}}}this.writeStatus(e,b);this.dataHashDidChange(e);c=this.changelog;if(!c){c=this.changelog=SC.Set.create()}if(b&a.DIRTY){c.add(e)}else{c.remove(e)}this.changelog=c;if(this.get("commitRecordsAutomatically")){this.invokeLast(this.commitRecords)}var d=this;this._propagateToChildren(e,function(h){d.destroyRecord(null,null,h)});return this},destroyRecords:function(d,a,f){var g,e,h,b,c,i;if(f===undefined){g=a.length;e=SC.typeOf(d)===SC.T_ARRAY;if(!e){c=d}for(h=0;h<g;h++){if(e){c=d[h]||SC.Record}b=a?a[h]:undefined;this.destroyRecord(c,b,undefined)}}else{g=f.length;for(h=0;h<g;h++){i=f?f[h]:undefined;this.destroyRecord(undefined,undefined,i)}}return this},registerChildToParent:function(c,f,e){var h,b,d,g,a;b=this.childRecords||{};h=this.parentRecords||{};d=b[f];if(d){g=h[d];delete g[f]}a=h[c]||{};a[f]=e||YES;h[c]=a;b[f]=c;this.writeStatus(f,this.statuses[c]);this.childRecords=b;this.parentRecords=h},unregisterChildFromParent:function(e){var a,b,d,g=this.recordTypeFor(e),f=this.idFor(e),c=this;a=this.childRecords;this.removeDataHash(e);if(this.records){delete this.records[e]}if(a){b=a[e];if(b){delete this.parentRecords[b][e]}delete a[e]}delete SC.Store.idsByStoreKey[e];d=g.storeKeysById();delete d[f];this._propagateToChildren(e,function(h){c.unregisterChildFromParent(h)})},materializeParentRecord:function(c){var b,a;if(SC.none(c)){return null}a=this.childRecords;b=a?this.childRecords[c]:null;if(SC.none(b)){return null}return this.materializeRecord(b)},parentStoreKeyExists:function(b){if(SC.none(b)){return}var a=this.childRecords||{};return a[b]},_propagateToChildren:function(d,c){if(SC.none(this.parentRecords)){return}var b=this.parentRecords[d]||{};if(SC.none(c)){return}for(var a in b){if(b.hasOwnProperty(a)){c(parseInt(a,10))}}},recordDidChange:function(h,g,f,d,c){if(f===undefined){f=h.storeKeyFor(g)}var b=this.readStatus(f),e,a=SC.Record;if(b&a.BUSY){a.BUSY_ERROR.throw()}else{if(!(b&a.READY)){a.NOT_FOUND_ERROR.throw()}else{if(b!==a.READY_NEW){this.writeStatus(f,a.READY_DIRTY)}}}this.dataHashDidChange(f,null,c,d);e=this.changelog;if(!e){e=this.changelog=SC.Set.create()}e.add(f);this.changelog=e;if(this.get("commitRecordsAutomatically")){this.invokeLast(this.commitRecords)}return this},recordsDidChange:function(d,a,f){var g,e,h,b,c,i;if(f===undefined){g=a.length;e=SC.typeOf(d)===SC.T_ARRAY;if(!e){c=d}for(h=0;h<g;h++){if(e){c=d[h]||SC.Record}b=a?a[h]:undefined;i=f?f[h]:undefined;this.recordDidChange(c,b,i)}}else{g=f.length;for(h=0;h<g;h++){i=f?f[h]:undefined;this.recordDidChange(undefined,undefined,i)}}return this},retrieveRecords:function(f,m,b,c,q){var l=this._getDataSource(),h=SC.typeOf(f)===SC.T_ARRAY,k=SC.typeOf(q)===SC.T_ARRAY,o=(!b)?m.length:b.length,r=[],p=SC.Store.generateStoreKey(),g=SC.Record,a,j,e,n,i,d;if(!h){a=f}for(j=0;j<o;j++){if(b){e=b[j]}else{if(h){a=f[j]}e=a.storeKeyFor(m[j])}d=k?q[j]:q;n=this.readStatus(e);if((n===g.EMPTY)||(n===g.ERROR)||(n===g.DESTROYED_CLEAN)){this.writeStatus(e,g.BUSY_LOADING);this.dataHashDidChange(e,p,YES);r.push(e);this._setCallbackForStoreKey(e,d,k,b)}else{if(c){if(n&g.READY){this.writeStatus(e,g.BUSY_REFRESH|(n&3));this.dataHashDidChange(e,p,YES);r.push(e);this._setCallbackForStoreKey(e,d,k,b)}else{if((n===g.BUSY_DESTROYING)||(n===g.BUSY_CREATING)||(n===g.BUSY_COMMITTING)){g.BUSY_ERROR.throw()}else{if(n===g.DESTROYED_DIRTY){g.BAD_STATE_ERROR.throw()}}}}}}i=NO;if(l){i=l.retrieveRecords.call(l,this,r,m)}if(!i){o=r.length;p=SC.Store.generateStoreKey();for(j=0;j<o;j++){e=r[j];n=this.readStatus(e);if(n===g.BUSY_LOADING){this.writeStatus(e,g.ERROR);this.dataHashDidChange(e,p,YES)}else{if(n&g.BUSY_REFRESH){this.writeStatus(e,g.READY|(n&3));this.dataHashDidChange(e,p,YES)}}}r.length=0}return r},_TMP_RETRIEVE_ARRAY:[],_callback_queue:{},_setCallbackForStoreKey:function(d,e,b,c){var a=this._callback_queue;if(b){a[d]={callback:e,otherKeys:c}}else{a[d]=e}},_retrieveCallbackForStoreKey:function(c){var a=this._callback_queue,e=a[c],d,b;if(e){if(SC.typeOf(e)===SC.T_FUNCTION){e.call();delete a[c]}else{if(SC.typeOf(e)===SC.T_HASH){e.completed=YES;b=e.storeKeys;b.forEach(function(f){if(!a[f].completed){d=YES}});if(d){e.callback.call();b.forEach(function(f){delete a[f]})}}}}},_cancelCallback:function(b){var a=this._callback_queue;if(a[b]){delete a[b]}},retrieveRecord:function(g,f,b,c,e){var d=this._TMP_RETRIEVE_ARRAY,a;if(b){d[0]=b;b=d;f=null}else{d[0]=f;f=d}a=this.retrieveRecords(g,f,b,c,e);d.length=0;return a[0]},refreshRecord:function(d,c,a,b){return !!this.retrieveRecord(d,c,a,YES,b)},refreshRecords:function(b,c,d,e){var a=this.retrieveRecords(b,c,d,YES,e);return a&&a.length>0},commitRecords:function(f,n,b,q,t){var m=this._getDataSource(),h=SC.typeOf(f)===SC.T_ARRAY,k=SC.typeOf(t)===SC.T_ARRAY,c=[],j=[],l=[],r=SC.Store.generateStoreKey(),g=SC.Record,a,i,e,o,s,p,d;if(!f&&!n&&!b){b=this.changelog}p=b?b.get("length"):(n?n.get("length"):0);for(i=0;i<p;i++){if(b){e=b[i]}else{if(h){a=f[i]||SC.Record}else{a=f}e=a.storeKeyFor(n[i])}d=k?t[i]:t;o=this.readStatus(e);if(o===g.ERROR){g.NOT_FOUND_ERROR.throw()}else{if(o===g.READY_NEW){this.writeStatus(e,g.BUSY_CREATING);this.dataHashDidChange(e,r,YES);c.push(e);this._setCallbackForStoreKey(e,d,k,b)}else{if(o===g.READY_DIRTY){this.writeStatus(e,g.BUSY_COMMITTING);this.dataHashDidChange(e,r,YES);j.push(e);this._setCallbackForStoreKey(e,d,k,b)}else{if(o===g.DESTROYED_DIRTY){this.writeStatus(e,g.BUSY_DESTROYING);this.dataHashDidChange(e,r,YES);l.push(e);this._setCallbackForStoreKey(e,d,k,b)}else{if(o===g.DESTROYED_CLEAN){this.dataHashDidChange(e,r,YES)}}}}}}if(m&&(p>0||q)){s=m.commitRecords.call(m,this,c,j,l,q)}if(s&&!f&&!n){if(b===this.changelog){this.changelog=null}else{this.changelog.removeEach(b)}}return s},commitRecord:function(g,f,b,c,e){var d=this._TMP_RETRIEVE_ARRAY,a;if(f===undefined&&b===undefined){return NO}if(b!==undefined){d[0]=b;b=d;f=null}else{d[0]=f;f=d}a=this.commitRecords(g,f,b,c,e);d.length=0;return a},cancelRecords:function(e,b,i){var a=this._getDataSource(),g=SC.typeOf(e)===SC.T_ARRAY,k=SC.Record,j=[],f,h,l,c,d,m;h=(i===undefined)?b.length:i.length;for(l=0;l<h;l++){if(g){d=e[l]||SC.Record}else{d=e||SC.Record}c=b?b[l]:undefined;if(i===undefined){m=d.storeKeyFor(c)}else{m=i?i[l]:undefined}if(m){f=this.readStatus(m);if((f===k.EMPTY)||(f===k.ERROR)){k.NOT_FOUND_ERROR.throw()}j.push(m);this._cancelCallback(m)}}if(a){a.cancel.call(a,this,j)}return this},cancelRecord:function(e,d,b){var c=this._TMP_RETRIEVE_ARRAY,a;if(b!==undefined){c[0]=b;b=c;d=null}else{c[0]=d;d=c}a=this.cancelRecords(e,d,b);c.length=0;return this},loadRecord:function(g,d,f){var a=SC.Record,c,b,e;g=g||SC.Record;b=g.prototype.primaryKey;f=f||d[b];c=e=g.storeKeyFor(f);if(this.readStatus(e)&a.BUSY){this.dataSourceDidComplete(e,d,f)}else{this.pushRetrieve(g,f,d,e)}return c},loadRecords:function(d,k,a){var f=SC.typeOf(d)===SC.T_ARRAY,g=k.get("length"),h=[],c,b,j,i,e;if(!f){c=d||SC.Record;j=c.prototype.primaryKey}for(i=0;i<g;i++){e=k.objectAt(i);if(f){c=d.objectAt(i)||SC.Record;j=c.prototype.primaryKey}b=(a)?a.objectAt(i):e[j];h[i]=this.loadRecord(c,e,b)}return h},readError:function(a){var b=this.recordErrors;return b?b[a]:undefined},readQueryError:function(a){var b=this.queryErrors;return b?b[SC.guidFor(a)]:undefined},dataSourceDidCancel:function(c){var b=this.readStatus(c),a=SC.Record;if(!(b&a.BUSY)){a.BAD_STATE_ERROR.throw()}switch(b){case a.BUSY_LOADING:b=a.EMPTY;break;case a.BUSY_CREATING:b=a.READY_NEW;break;case a.BUSY_COMMITTING:b=a.READY_DIRTY;break;case a.BUSY_REFRESH_CLEAN:b=a.READY_CLEAN;break;case a.BUSY_REFRESH_DIRTY:b=a.READY_DIRTY;break;case a.BUSY_DESTROYING:b=a.DESTROYED_DIRTY;break;default:a.BAD_STATE_ERROR.throw()}this.writeStatus(c,b);this.dataHashDidChange(c,null,YES);this._cancelCallback(c);return this},dataSourceDidComplete:function(g,f,e){var c=this.readStatus(g),b=SC.Record,d;if(!(c&b.BUSY)){b.BAD_STATE_ERROR.throw()}if(c===b.BUSY_DESTROYING){b.BAD_STATE_ERROR.throw()}else{c=b.READY_CLEAN}this.writeStatus(g,c);if(f){this.writeDataHash(g,f,c)}if(e){SC.Store.replaceIdFor(g,e)}d=f||e?NO:YES;this.dataHashDidChange(g,null,d);var a=this.materializeRecord(g);if(a!==null){if(e){a.propertyDidChange("id")}a.notifyPropertyChange("status")}this._retrieveCallbackForStoreKey(g);return this},dataSourceDidDestroy:function(d){var c=this.readStatus(d),b=SC.Record;if(!(c&b.BUSY)){b.BAD_STATE_ERROR.throw()}else{c=b.DESTROYED_CLEAN}this.removeDataHash(d,c);this.dataHashDidChange(d);var a=this.materializeRecord(d);if(a!==null){a.notifyPropertyChange("status")}this._retrieveCallbackForStoreKey(d);return this},dataSourceDidError:function(e,d){var c=this.readStatus(e),f=this.recordErrors,b=SC.Record;if(!(c&b.BUSY)){b.BAD_STATE_ERROR.throw()}else{c=b.ERROR}if(d&&d.isError){if(!f){f=this.recordErrors=[]}f[e]=d}this.writeStatus(e,c);this.dataHashDidChange(e,null,YES);var a=this.materializeRecord(e);if(a){a.notifyPropertyChange("status")}this._retrieveCallbackForStoreKey(e);return this},pushRetrieve:function(g,f,d,e){var c=SC.Record,b;if(e===undefined){e=g.storeKeyFor(f)}b=this.readStatus(e);if(b===c.EMPTY||b===c.ERROR||b===c.READY_CLEAN||b===c.DESTROYED_CLEAN){b=c.READY_CLEAN;if(d===undefined){this.writeStatus(e,b)}else{this.writeDataHash(e,d,b)}if(f&&this.idFor(e)!==f){SC.Store.replaceIdFor(e,f);var a=this.materializeRecord(e);a.propertyDidChange("id")}this.dataHashDidChange(e);return e}return NO},pushDestroy:function(e,d,c){var b=SC.Record,a;if(c===undefined){c=e.storeKeyFor(d)}a=this.readStatus(c);if(a===b.EMPTY||a===b.ERROR||a===b.READY_CLEAN||a===b.DESTROYED_CLEAN){a=b.DESTROYED_CLEAN;this.removeDataHash(c,a);this.dataHashDidChange(c);return c}return NO},pushError:function(g,f,c,d){var b=SC.Record,a,e=this.recordErrors;if(d===undefined){d=g.storeKeyFor(f)}a=this.readStatus(d);if(a===b.EMPTY||a===b.ERROR||a===b.READY_CLEAN||a===b.DESTROYED_CLEAN){a=b.ERROR;if(c&&c.isError){if(!e){e=this.recordErrors=[]}e[d]=c}this.writeStatus(d,a);this.dataHashDidChange(d,null,YES);return d}return NO},loadQueryResults:function(b,a){return this.dataSourceDidFetchQuery(b,a)},dataSourceDidFetchQuery:function(c,a){var b=this._findQuery(c,YES,NO);if(b&&c.get("isRemote")){b.set("storeKeys",a)}return this._scstore_dataSourceDidFetchQuery(c)},_scstore_dataSourceDidFetchQuery:function(c){var b=this._findQuery(c,NO,NO),a=this.get("nestedStores"),d=a?a.get("length"):0;if(b){b.storeDidFetchQuery(c)}while(--d>=0){a[d]._scstore_dataSourceDidFetchQuery(c)}return this},dataSourceDidCancelQuery:function(a){return this._scstore_dataSourceDidCancelQuery(a,YES)},_scstore_dataSourceDidCancelQuery:function(d,a){var c=this._findQuery(d,a,NO),b=this.get("nestedStores"),e=b?b.get("length"):0;if(c){c.storeDidCancelQuery(d)}while(--e>=0){b[e]._scstore_dataSourceDidCancelQuery(d,NO)}return this},dataSourceDidErrorQuery:function(b,a){var c=this.queryErrors;if(a&&a.isError){if(!c){c=this.queryErrors={}}c[SC.guidFor(b)]=a}return this._scstore_dataSourceDidErrorQuery(b,YES)},_scstore_dataSourceDidErrorQuery:function(d,a){var c=this._findQuery(d,a,NO),b=this.get("nestedStores"),e=b?b.get("length"):0;if(c){c.storeDidErrorQuery(d)}while(--e>=0){b[e]._scstore_dataSourceDidErrorQuery(d,NO)}return this},init:function(){arguments.callee.base.apply(this,arguments);this.reset()},toString:function(){var b=this.get("name");if(!b){return arguments.callee.base.apply(this,arguments)}else{var a=arguments.callee.base.apply(this,arguments);return"%@ (%@)".fmt(b,a)}},idFor:function(a){return SC.Store.idFor(a)},recordTypeFor:function(a){return SC.Store.recordTypeFor(a)},storeKeyFor:function(b,a){return b.storeKeyFor(a)},storeKeyExists:function(b,a){return b.storeKeyExists(a)},storeKeysFor:function(f){var a=[],e=f&&f.isEnumerable,c,d,b;if(!this.statuses){return a}for(d in SC.Store.recordTypesByStoreKey){c=SC.Store.recordTypesByStoreKey[d];if(e){b=f.contains(c)}else{b=c===f}if(b&&this.statuses[d]){a.push(parseInt(d,10))}}return a},storeKeys:function(){var a=[],b;if(!this.statuses){return a}for(b in this.statuses){if(this.statuses[b]!==SC.Record.EMPTY){a.push(parseInt(b,10))}}return a},statusString:function(a){var b=this.materializeRecord(a);return b.statusString()}});SC.Store.mixin({CHAIN_CONFLICT_ERROR:SC.$error("Nested Store Conflict"),NO_PARENT_STORE_ERROR:SC.$error("Parent Store Required"),NESTED_STORE_UNSUPPORTED_ERROR:SC.$error("Unsupported In Nested Store"),NESTED_STORE_RETRIEVE_DIRTY_ERROR:SC.$error("Cannot Retrieve Dirty Record in Nested Store"),EDITABLE:"editable",LOCKED:"locked",INHERITED:"inherited",idsByStoreKey:[],recordTypesByStoreKey:{},queriesByStoreKey:[],nextStoreKey:1,generateStoreKey:function(){return this.nextStoreKey++},idFor:function(a){return this.idsByStoreKey[a]},queryFor:function(a){return this.queriesByStoreKey[a]},recordTypeFor:function(a){return this.recordTypesByStoreKey[a]},replaceIdFor:function(c,a){var d=this.idsByStoreKey[c],e,b;if(d!==a){e=this.recordTypeFor(c);if(!e){throw new Error("replaceIdFor: storeKey %@ does not exist".fmt(c))}this.idsByStoreKey[c]=a;b=e.storeKeysById();delete b[d];b[a]=c}return this},replaceRecordTypeFor:function(a,b){this.recordTypesByStoreKey[a]=b;return this}});sc_require("system/store");SC.NestedStore=SC.Store.extend({hasChanges:NO,parentStore:null,isNested:YES,lockOnRead:YES,locks:null,chainedChanges:null,find:function(a){if(a&&a.isQuery&&a.get("location")!==SC.Query.LOCAL){throw new Error("SC.Store#find() can only accept LOCAL queries in nested stores")}return arguments.callee.base.apply(this,arguments)},commitChanges:function(b){if(this.get("hasChanges")){var a=this.get("parentStore");a.commitChangesFromNestedStore(this,this.get("chainedChanges"),b)}this.reset();return this},conflictedStoreKeys:function(){var d=null;if(this.get("hasChanges")){var a=this.get("parentStore"),k=this.locks,j=a.revisions;if(k&&j){var f=this.get("chainedChanges");for(var b=0,c=f.length;b<c;b++){var h=f[b],g=k[h]||1,e=j[h]||1;if(g<e){if(!d){d=[]}d.push(h)}}}}return d}.property("chainedChanges").cacheable(),commitSuccessfulChanges:function(b){var a=this.get("chainedChanges");if(this.get("hasChanges")&&a){var m=this.dataHashes,k=this.revisions,d=this.statuses,h=this.editables,l=this.locks;var f=a.filter(function(i){var n=this.readStatus(i);return n===SC.Record.READY_CLEAN||n===SC.Record.DESTROYED_CLEAN},this);var c=this.get("parentStore");c.commitChangesFromNestedStore(this,f,b);for(var e=0,g=f.get("length");e<g;e++){var j=f.objectAt(e);if(m&&m.hasOwnProperty(j)){delete m[j]}if(k&&k.hasOwnProperty(j)){delete k[j]}if(h){delete h[j]}if(l){delete l[j]}if(d&&d.hasOwnProperty(j)){delete d[j]}a.remove(j)}if(f.length>0){this.notifyPropertyChange("chainedChanges")}}return this},discardChanges:function(){var c,f;if((c=this.records)&&(f=this.locks)){var b=this.get("parentStore"),h=b.revisions;var g=this.revisions,e,d,a;for(e in c){if(!c.hasOwnProperty(e)){continue}if(!(d=f[e])){continue}a=h[e];if((a!==d)||(g[e]>a)){this._notifyRecordPropertyChange(parseInt(e,10))}}}this.reset();this.flush();return this},destroy:function(){this.discardChanges();var a=this.get("parentStore");if(a){a.willDestroyNestedStore(this)}arguments.callee.base.apply(this,arguments);return this},reset:function(){var a=this.get("parentStore");if(!a){SC.Store.NO_PARENT_STORE_ERROR.throw()}this.dataHashes=SC.beget(a.dataHashes);this.revisions=SC.beget(a.revisions);this.statuses=SC.beget(a.statuses);this.childRecords=a.childRecords?SC.beget(a.childRecords):{};this.parentRecords=a.parentRecords?SC.beget(a.parentRecords):{};this.set("hasChanges",false);this.chainedChanges=this.locks=this.editables=null;this.changelog=null},refreshQuery:function(b){var a=this.get("parentStore");if(a){a.refreshQuery(b)}return this},readError:function(b){var a=this.get("parentStore");return a?a.readError(b):null},readQueryError:function(b){var a=this.get("parentStore");return a?a.readQueryError(b):null},chainAutonomousStore:function(a,b){SC.Store.NESTED_STORE_UNSUPPORTED_ERROR.throw()},storeKeyEditState:function(b){var c=this.editables,a=this.locks;return(c&&c[b])?SC.Store.EDITABLE:(a&&a[b])?SC.Store.LOCKED:SC.Store.INHERITED},_lock:function(j){var k=this.locks,f,h,d,a,l,g,e,i;if(k&&k[j]){return this}if(!k){k=this.locks=[]}h=this.editables;if(h){h[j]=0}var b=this.get("parentStore"),c;while(b&&(c=b.storeKeyEditState(j))===SC.Store.INHERITED){b=b.get("parentStore")}if(b&&c===SC.Store.EDITABLE){d=this.childRecords[j];if(d){this._lock(d);a=this.parentRecords[d];if(a){l=a[j];g=l?SC.tupleForPropertyPath(l,this.dataHashes[d]):null;if(g){e=g[0];i=g[1]}this.dataHashes[j]=e&&i?e[i]:null}}else{this.dataHashes[j]=SC.clone(b.dataHashes[j],YES)}if(!h){h=this.editables=[]}h[j]=1}else{this.dataHashes[j]=b.dataHashes[j]}this.statuses[j]=this.statuses[j];f=this.revisions[j]=this.revisions[j];k[j]=f||1;return this},readDataHash:function(a){if(this.get("lockOnRead")){this._lock(a)}return this.dataHashes[a]},readEditableDataHash:function(a){this._lock(a);return arguments.callee.base.apply(this,arguments)},writeDataHash:function(d,f,b){var c=this.locks,g=NO,a;if(f){this.dataHashes[d]=f}else{this._lock(d);g=YES}if(b){this.statuses[d]=b}else{if(!g){this.statuses[d]=(this.statuses[d]||SC.Record.READY_NEW)}}if(!g){a=this.revisions[d]=this.revisions[d];if(!c){c=this.locks=[]}if(!c[d]){c[d]=a||1}}var e=this.editables;if(!e){e=this.editables=[]}e[d]=1;this._updateChildRecordHashes(d,f,b);return this},removeDataHash:function(c,a){var b=this.locks;if(!b){b=this.locks=[]}if(!b[c]){b[c]=this.revisions[c]||1}return arguments.callee.base.apply(this,arguments)},dataHashDidChange:function(e,b,a,j){if(!b){b=SC.Store.generateStoreKey()}var c,f,h,k;c=SC.typeOf(e)===SC.T_ARRAY;if(c){f=e.length}else{f=1;k=e}var g=this.get("chainedChanges");if(!g){g=this.chainedChanges=SC.Set.create()}var d=this,i=false;for(h=0;h<f;h++){if(c){k=e[h]}this._lock(k);this.revisions[k]=b;if(!g.contains(k)){g.add(k);i=true}this._notifyRecordPropertyChange(k,a,j);this._propagateToChildren(k,function(l){d.dataHashDidChange(l,null,a,j)})}this.setIfChanged("hasChanges",YES);if(i){this.notifyPropertyChange("chainedChanges")}return this},commitChangesFromNestedStore:function(e,f,a){arguments.callee.base.apply(this,arguments);var b=this.get("parentStore"),h=b.revisions,c;var k=this.locks,g=this.get("chainedChanges"),d,j;if(!k){k=this.locks=[]}if(!g){g=this.chainedChanges=SC.Set.create()}d=f.length;for(c=0;c<d;c++){j=f[c];if(!k[j]){k[j]=h[j]||1}g.add(j)}this.setIfChanged("hasChanges",g.get("length")>0);this.notifyPropertyChange("chainedChanges");this.flush();return this},queryFor:function(c,a,b){return this.get("parentStore").queryFor(c,a,b)},retrieveRecords:function(f,m,b,c,r){var a=this.get("parentStore"),k,d,o=(!b)?m.length:b.length,i=SC.Record,n;if(c){for(k=0;k<o;k++){d=!b?a.storeKeyFor(f,m[k]):b[k];n=this.peekStatus(d);if(n&i.DIRTY){SC.Store.NESTED_STORE_RETRIEVE_DIRTY_ERROR.throw()}else{var g=this.dataHashes,j=this.revisions,h=this.statuses,l=this.editables,q=this.locks;var e=NO;var p=NO;if(g&&g.hasOwnProperty(d)){delete g[d];e=YES}if(j&&j.hasOwnProperty(d)){delete j[d];e=YES}if(l){delete l[d]}if(q){delete q[d]}if(h&&h.hasOwnProperty(d)){delete h[d];if(!e){p=YES}e=YES}if(e){this._notifyRecordPropertyChange(d,p)}}}}return a.retrieveRecords(f,m,b,c,r)},commitRecords:function(a,b,c){if(this.get("dataSource")){return arguments.callee.base.apply(this,arguments)}else{SC.Store.NESTED_STORE_UNSUPPORTED_ERROR.throw()}},commitRecord:function(c,b,a){if(this.get("dataSource")){return arguments.callee.base.apply(this,arguments)}else{SC.Store.NESTED_STORE_UNSUPPORTED_ERROR.throw()}},cancelRecords:function(a,b,c){if(this.get("dataSource")){return arguments.callee.base.apply(this,arguments)}else{SC.Store.NESTED_STORE_UNSUPPORTED_ERROR.throw()}},cancelRecord:function(c,b,a){if(this.get("dataSource")){return arguments.callee.base.apply(this,arguments)}else{SC.Store.NESTED_STORE_UNSUPPORTED_ERROR.throw()}},dataSourceDidCancel:function(a){if(this.get("dataSource")){return arguments.callee.base.apply(this,arguments)}else{SC.Store.NESTED_STORE_UNSUPPORTED_ERROR.throw()}},dataSourceDidComplete:function(c,b,a){if(this.get("dataSource")){return arguments.callee.base.apply(this,arguments)}else{SC.Store.NESTED_STORE_UNSUPPORTED_ERROR.throw()}},dataSourceDidDestroy:function(a){if(this.get("dataSource")){return arguments.callee.base.apply(this,arguments)}else{SC.Store.NESTED_STORE_UNSUPPORTED_ERROR.throw()}},dataSourceDidError:function(b,a){if(this.get("dataSource")){return arguments.callee.base.apply(this,arguments)}else{SC.Store.NESTED_STORE_UNSUPPORTED_ERROR.throw()}},pushRetrieve:function(d,c,a,b){if(this.get("dataSource")){return arguments.callee.base.apply(this,arguments)}else{SC.Store.NESTED_STORE_UNSUPPORTED_ERROR.throw()}},pushDestroy:function(c,b,a){if(this.get("dataSource")){return arguments.callee.base.apply(this,arguments)}else{SC.Store.NESTED_STORE_UNSUPPORTED_ERROR.throw()}},pushError:function(d,c,a,b){if(this.get("dataSource")){return arguments.callee.base.apply(this,arguments)}else{SC.Store.NESTED_STORE_UNSUPPORTED_ERROR.throw()}}});sc_require("models/record");SC.RecordArray=SC.Object.extend(SC.Enumerable,SC.Array,{store:null,query:null,storeKeys:null,_prevStoreKeys:null,status:SC.Record.EMPTY,isEditable:function(){var a=this.get("query");return a?a.get("isEditable"):YES}.property("query").cacheable(),length:function(){this.flush();var a=this.get("storeKeys");return a?a.get("length"):0}.property("storeKeys").cacheable(),_scra_records:null,objectAt:function(a){this.flush();var f=this._scra_records,e=this.get("storeKeys"),b=this.get("store"),d,c;if(!e||!b){return undefined}if(f&&(c=f[a])){return c}if(!f){this._scra_records=f=[]}d=e.objectAt(a);if(d){if(b.peekStatus(d)===SC.Record.EMPTY){b.retrieveRecord(null,null,d)}f[a]=c=b.materializeRecord(d)}return c},forEach:function(h,d){this.flush();var e=this._scra_records,b=this.get("storeKeys"),f=this.get("store"),c=b?b.get("length"):0,g,i,a;if(!b||!f){return this}if(!e){e=this._scra_records=[]}if(!d){d=this}for(g=0;g<c;g++){a=e[g];if(!a){a=e[g]=f.materializeRecord(b.objectAt(g))}h.call(d,a,g,this)}return this},replace:function(b,g,f){this.flush();var e=this.get("storeKeys"),a=f?(f.get?f.get("length"):f.length):0,c,d;if(!e){throw new Error("Unable to edit an SC.RecordArray that does not have its storeKeys property set.")}if(!this.get("isEditable")){SC.RecordArray.NOT_EDITABLE.throw()}d=[];for(c=0;c<a;c++){d[c]=f.objectAt(c).get("storeKey")}e.replace(b,g,d);return this},contains:function(a){return this.indexOf(a)>=0},indexOf:function(b,a){if(!SC.kindOf(b,SC.Record)){return -1}this.flush();var d=b.get("storeKey"),c=this.get("storeKeys");return c?c.indexOf(d,a):-1},lastIndexOf:function(b,a){if(!SC.kindOf(b,SC.Record)){return -1}this.flush();var d=b.get("storeKey"),c=this.get("storeKeys");return c?c.lastIndexOf(d,a):-1},add:function(a){if(!SC.kindOf(a,SC.Record)){return this}if(this.indexOf(a)<0){this.pushObject(a)}return this},remove:function(a){if(!SC.kindOf(a,SC.Record)){return this}this.removeObject(a);return this},find:function(a,b,c){if(b&&b.isQuery){return this.get("store").find(b.queryWithScope(this))}else{return a.apply(this,SC.$A(arguments).slice(1))}}.enhance(),refresh:function(){this.get("store").refreshQuery(this.get("query"));return this},reload:function(){this.flush(YES);return this},destroy:function(){if(!this.get("isDestroyed")){this.get("store").recordArrayWillDestroy(this)}arguments.callee.base.apply(this,arguments)},storeWillFetchQuery:function(c){var b=this.get("status"),a=SC.Record;if((b===a.EMPTY)||(b===a.ERROR)){b=a.BUSY_LOADING}if(b&a.READY){b=a.BUSY_REFRESH}this.setIfChanged("status",b);return this},storeDidFetchQuery:function(a){this.setIfChanged("status",SC.Record.READY_CLEAN);return this},storeDidCancelQuery:function(c){var b=this.get("status"),a=SC.Record;if(b===a.BUSY_LOADING){b=a.EMPTY}else{if(b===a.BUSY_REFRESH){b=a.READY_CLEAN}}this.setIfChanged("status",b);return this},storeDidErrorQuery:function(a){this.setIfChanged("status",SC.Record.ERROR);return this},storeDidChangeStoreKeys:function(b,a){var c=this.get("query");if(c.get("location")!==SC.Query.LOCAL){return this}if(!c.containsRecordTypes(a)){return this}var d=this._scq_changedStoreKeys;if(!d){d=this._scq_changedStoreKeys=SC.IndexSet.create()}d.addEach(b);this.set("needsFlush",YES);if(this.get("storeKeys")){this.flush()}return this},flush:function(a){if(this._insideFlush){this.set("needsFlush",YES);return this}if(!this.get("needsFlush")&&!a){return this}this.set("needsFlush",NO);var j=this.get("query"),m=this.get("store");if(!m||!j||j.get("location")!==SC.Query.LOCAL){return this}this._insideFlush=YES;var h=this.get("storeKeys"),f=this._scq_changedStoreKeys,g=NO,k=SC.Record,o=[],b=new Date(),d,e,c,p,n,i;var l=h;if(h&&!a){if(f){f.forEach(function(q){if(o.length>0||new Date()-b>SC.RecordArray.QUERY_MATCHING_THRESHOLD){o.push(q);return}e=m.peekStatus(q);if(!(e&k.EMPTY)&&!((e&k.DESTROYED)||(e===k.BUSY_DESTROYING))){d=m.materializeRecord(q);i=!!(d&&j.contains(d))}else{i=NO}if(i){if(h.indexOf(q)<0){if(!g){h=h.copy()}h.pushObject(q)}}else{if(h.indexOf(q)>=0){if(!g){h=h.copy()}h.removeObject(q)}}},this);g=YES}}else{if(n=j.get("scope")){p=n.flush().get("storeKeys")}else{if(c=j.get("expandedRecordTypes")){p=SC.IndexSet.create();c.forEach(function(q){p.addEach(m.storeKeysFor(q))})}}h=[];p.forEach(function(q){if(o.length>0||new Date()-b>SC.RecordArray.QUERY_MATCHING_THRESHOLD){o.push(q);return}e=m.peekStatus(q);if(!(e&k.EMPTY)&&!((e&k.DESTROYED)||(e===k.BUSY_DESTROYING))){d=m.materializeRecord(q);if(d&&j.contains(d)){h.push(q)}}});g=YES}if(o.length>0){this.invokeNext(function(){if(!this||this.get("isDestroyed")){return}this.set("needsFlush",YES);this._scq_changedStoreKeys=SC.IndexSet.create().addEach(o);this.flush()})}if(f){f.clear()}this._insideFlush=NO;if(g){if(h&&(h===l)){h=h.copy()}h=SC.Query.orderStoreKeys(h,j,m);if(SC.compare(l,h)!==0){this.set("storeKeys",SC.clone(h))}}return this},needsFlush:YES,isError:function(){return !!(this.get("status")&SC.Record.ERROR)}.property("status").cacheable(),errorValue:function(){return this.get("isError")?SC.val(this.get("errorObject")):null}.property("isError").cacheable(),errorObject:function(){if(this.get("isError")){var a=this.get("store");return a.readQueryError(this.get("query"))||SC.Record.GENERIC_ERROR}else{return null}}.property("isError").cacheable(),propertyWillChange:function(b){if(b==="storeKeys"){var c=this.get("storeKeys");var a=c?c.get("length"):0;this.arrayContentWillChange(0,a,0)}return arguments.callee.base.apply(this,arguments)},_storeKeysDidChange:function(){var d=this.get("storeKeys");var c=this._prevStoreKeys,a,b;if(d===c){return}if(c){c.removeArrayObservers({target:this,willChange:this.arrayContentWillChange,didChange:this._storeKeysContentDidChange});a=c.get("length")}else{a=0}this._prevStoreKeys=d;if(d){d.addArrayObservers({target:this,willChange:this.arrayContentWillChange,didChange:this._storeKeysContentDidChange});b=d.get("length")}else{b=0}this._storeKeysContentDidChange(0,a,b)}.observes("storeKeys"),addArrayObservers:function(){this.flush();return SC.Array.addArrayObservers.apply(this,arguments)},_storeKeysContentDidChange:function(c,a,b){if(this._scra_records){this._scra_records.length=0}this.arrayContentDidChange(c,a,b)},init:function(){arguments.callee.base.apply(this,arguments);this._storeKeysDidChange()}});SC.RecordArray.mixin({NOT_EDITABLE:SC.$error("SC.RecordArray is not editable"),QUERY_MATCHING_THRESHOLD:100});Function.prototype.handleEvents=function(){this.isEventHandler=YES;this.events=arguments;return this};Function.prototype.stateObserves=function(){this.isStateObserveHandler=YES;this.args=new Array(arguments.length);for(var b=0,a=this.args.length;b<a;b++){this.args[b]=arguments[b]}return this};SC.StatechartDelegate={isStatechartDelegate:YES,statechartUpdateLocationForState:function(b,a,c){SC.routes.set("location",a)},statechartAcquireLocationForState:function(a,b){return SC.routes.get("location")},statechartBindStateToRoute:function(b,d,a,c){SC.routes.add(a,d,c)},statechartShouldStateHandleTriggeredRoute:function(a,c,b){return YES},statechartStateCancelledHandlingTriggeredRoute:function(a,c,b){}};SC.StatePathMatcher=SC.Object.extend({state:null,expression:null,tokens:null,init:function(){arguments.callee.base.apply(this,arguments);this._parseExpression()},_parseExpression:function(){var h=this.expression?this.expression.split("."):[],b=h.length,f=0,c,e=null,d,g=[];for(;f<b;f+=1){c=h[f];if(c.indexOf("~")>=0){c=c.split("~");if(c.length>2){throw new Error("Invalid use of '~' at part %@".fmt(f))}d=SC.StatePathMatcher._ExpandToken.create({start:c[0],end:c[1]})}else{if(c==="this"){if(g.length>0){throw new Error("Invalid use of 'this' at part %@".fmt(f))}d=SC.StatePathMatcher._ThisToken.create()}else{d=SC.StatePathMatcher._BasicToken.create({value:c})}}d.owner=this;g.push(d)}this.set("tokens",g);var a=SC.clone(g);this._chain=e=a.pop();while(d=a.pop()){e.nextToken=d;e=d}},lastPart:function(){var c=this.get("tokens"),a=c?c.length:0,b=a>0?c[a-1]:null;return b.get("lastPart")}.property("tokens").cacheable(),match:function(a){this._stack=a.split(".");if(SC.empty(a)||SC.typeOf(a)!==SC.T_STRING){return NO}return this._chain.match()},_pop:function(){this._lastPopped=this._stack.pop();return this._lastPopped}});SC.StatePathMatcher._Token=SC.Object.extend({type:null,owner:null,nextToken:null,lastPart:null,match:function(){return NO}});SC.StatePathMatcher._BasicToken=SC.StatePathMatcher._Token.extend({type:"basic",value:null,lastPart:function(){return this.value}.property("value").cacheable(),match:function(){var a=this.owner._pop(),b=this.nextToken;if(this.value!==a){return NO}return b?b.match():YES}});SC.StatePathMatcher._ExpandToken=SC.StatePathMatcher._Token.extend({type:"expand",start:null,end:null,lastPart:function(){return this.end}.property("end").cacheable(),match:function(){var d=this.start,a=this.end,b,c=this.nextToken;b=this.owner._pop();if(b!==a){return NO}while(b=this.owner._pop()){if(b===d){return c?c.match():YES}}return NO}});SC.StatePathMatcher._ThisToken=SC.StatePathMatcher._Token.extend({type:"this",lastPart:"this",match:function(){var e=this.owner.state,c=e.get("substates"),a=c.length,d=0,b;b=this.owner._lastPopped;if(!b||this.owner._stack.length!==0){return NO}for(;d<a;d+=1){if(c[d].get("name")===b){return YES}}return NO}});SC.Async=SC.Object.extend({func:null,arg1:null,arg2:null,tryToPerform:function(d){var c=this.get("func"),b=this.get("arg1"),a=this.get("arg2"),e=SC.typeOf(c);if(e===SC.T_STRING){d.tryToPerform(c,b,a)}else{if(e===SC.T_FUNCTION){c.apply(d,[b,a])}}}});SC.Async.mixin({perform:function(c,b,a){return SC.Async.create({func:c,arg1:b,arg2:a})}});SC.State=SC.Object.extend({name:null,parentState:null,historyState:null,initialSubstate:null,substatesAreConcurrent:NO,substates:null,statechart:null,stateIsInitialized:NO,currentSubstates:null,enteredSubstates:null,representRoute:null,owner:function(){var c=this.get("statechart"),b=c?c.get("statechartOwnerKey"):null,a=c?c.get(b):null;return a?a:c}.property().cacheable(),statechartDelegate:function(){return this.getPath("statechart.statechartDelegate")}.property().cacheable(),location:function(b,c){var d=this.get("statechart"),a=this.get("statechartDelegate");if(c!==undefined){a.statechartUpdateLocationForState(d,c,this)}return a.statechartAcquireLocationForState(d,this)}.property().idempotent(),init:function(){arguments.callee.base.apply(this,arguments);this._registeredEventHandlers={};this._registeredStringEventHandlers={};this._registeredRegExpEventHandlers=[];this._registeredStateObserveHandlers={};this._registeredSubstatePaths={};this._registeredSubstates=[];this._isEnteringState=NO;this._isExitingState=NO;var a=this.get("statechart"),b=a?a.get("statechartOwnerKey"):null;if(a){a.addObserver(b,this,"_statechartOwnerDidChange")}},destroy:function(){var b=this.get("statechart"),c=b?b.get("statechartOwnerKey"):null;if(b){b.removeObserver(c,this,"_statechartOwnerDidChange")}var a=this.get("substates");if(a){a.forEach(function(d){d.destroy()})}this._teardownAllStateObserveHandlers();this.set("substates",null);this.set("currentSubstates",null);this.set("enteredSubstates",null);this.set("parentState",null);this.set("historyState",null);this.set("initialSubstate",null);this.set("statechart",null);this.notifyPropertyChange("owner");this._registeredEventHandlers=null;this._registeredStringEventHandlers=null;this._registeredRegExpEventHandlers=null;this._registeredStateObserveHandlers=null;this._registeredSubstatePaths=null;this._registeredSubstates=null;arguments.callee.base.apply(this,arguments)},initState:function(){if(this.get("stateIsInitialized")){return}this._registerWithParentStates();this._setupRouteHandling();var h=null,g=null,b=null,i=[],f=NO,e=this.get("initialSubstate"),c=this.get("substatesAreConcurrent"),d=NO,a=null;this.set("substates",i);if(SC.kindOf(e,SC.HistoryState)&&e.isClass){a=this.createSubstate(e);this.set("initialSubstate",a);if(SC.none(a.get("defaultState"))){this.stateLogError("Initial substate is invalid. History state requires the name of a default state to be set");this.set("initialSubstate",null);a=null}}for(h in this){g=this[h];d=SC.typeOf(g)===SC.T_FUNCTION;if(d&&g.isEventHandler){this._registerEventHandler(h,g);continue}if(d&&g.isStateObserveHandler){this._registerStateObserveHandler(h,g);continue}if(d&&g.statePlugin){g=g.apply(this)}if(SC.kindOf(g,SC.State)&&g.isClass&&this[h]!==this.constructor){b=this._addSubstate(h,g);if(h===e){this.set("initialSubstate",b);f=YES}else{if(a&&a.get("defaultState")===h){a.set("defaultState",b);f=YES}}}}if(!SC.none(e)&&!f){this.stateLogError("Unable to set initial substate %@ since it did not match any of state's %@ substates".fmt(e,this))}if(i.length===0){if(!SC.none(e)){this.stateLogWarning("Unable to make %@ an initial substate since state %@ has no substates".fmt(e,this))}}else{if(i.length>0){b=this._addEmptyInitialSubstateIfNeeded();if(!b&&e&&c){this.set("initialSubstate",null);this.stateLogWarning("Can not use %@ as initial substate since substates are all concurrent for state %@".fmt(e,this))}}}this.notifyPropertyChange("substates");this.set("currentSubstates",[]);this.set("enteredSubstates",[]);this.set("stateIsInitialized",YES)},_setupRouteHandling:function(){var b=this.get("representRoute"),c=this.get("statechart"),a=this.get("statechartDelegate");if(SC.none(b)){return}if(this.get("isConcurrentState")){this.stateLogError("State %@ cannot handle route '%@' since state is concurrent".fmt(this,b));return}a.statechartBindStateToRoute(c,this,b,this.routeTriggered)},routeTriggered:function(f){if(this._isEnteringState){return}var e=this.get("statechart"),b=this.get("statechartDelegate"),d=this.get("location");var a={state:this,location:d,params:f,handler:this.routeTriggered};var c=this.createStateRouteHandlerContext(a);if(b.statechartShouldStateHandleTriggeredRoute(e,this,c)){this.handleTriggeredRoute(c)}else{b.statechartStateCancelledHandlingTriggeredRoute(e,this,c)}},createStateRouteHandlerContext:function(a){return SC.StateRouteHandlerContext.create(a)},handleTriggeredRoute:function(a){this.gotoState(this,a)},_addEmptyInitialSubstateIfNeeded:function(){var c=this.get("initialSubstate"),b=this.get("substatesAreConcurrent");if(c||b){return null}var a=this.createSubstate(SC.EmptyState);this.set("initialSubstate",a);this.get("substates").push(a);this[a.get("name")]=a;a.initState();this.stateLogWarning("state %@ has no initial substate defined. Will default to using an empty state as initial substate".fmt(this));return a},_addSubstate:function(c,d,a){var b=this.get("substates");a=SC.clone(a)||{};a.name=c;d=this.createSubstate(d,a);b.push(d);this[c]=d;d.initState();return d},addSubstate:function(c,e,b){if(SC.empty(c)){this.stateLogError("Can not add substate. name required");return null}if(this[c]!==undefined){this.stateLogError("Can not add substate '%@'. Already a defined property".fmt(c));return null}if(!this.get("stateIsInitialized")){this.stateLogError("Can not add substate '%@'. this state is not yet initialized".fmt(c));return null}var a=arguments.length;if(a===1){e=SC.State}else{if(a===2&&SC.typeOf(e)===SC.T_HASH){b=e;e=SC.State}}var d=SC.kindOf(e,SC.State)&&e.isClass;if(!d){this.stateLogError("Can not add substate '%@'. must provide a state class".fmt(c));return null}e=this._addSubstate(c,e,b);this._addEmptyInitialSubstateIfNeeded();this.notifyPropertyChange("substates");return e},createSubstate:function(b,a){a=a||{};return b.create({parentState:this,statechart:this.get("statechart")},a)},_registerEventHandler:function(b,e){var d=e.events,f=null,a=d.length,c=0;this._registeredEventHandlers[b]=e;for(;c<a;c+=1){f=d[c];if(SC.typeOf(f)===SC.T_STRING){this._registeredStringEventHandlers[f]={name:b,handler:e};continue}if(f instanceof RegExp){this._registeredRegExpEventHandlers.push({name:b,handler:e,regexp:f});continue}this.stateLogError("Invalid event %@ for event handler %@ in state %@".fmt(f,b,this))}},_registerStateObserveHandler:function(d,f){var e=0,c=f.args,b=c.length,a,g=YES;for(;e<b;e+=1){a=c[e];if(SC.typeOf(a)!==SC.T_STRING||SC.empty(a)){this.stateLogError("Invalid argument %@ for state observe handler %@ in state %@".fmt(a,d,this));g=NO}}if(!g){return}this._registeredStateObserveHandlers[d]=f.args},_registerWithParentStates:function(){var a=this.get("parentState");while(!SC.none(a)){a._registerSubstate(this);a=a.get("parentState")}},_registerSubstate:function(b){var c=b.pathRelativeTo(this);if(SC.none(c)){return}this._registeredSubstates.push(b);var a=this._registeredSubstatePaths;if(a[b.get("name")]===undefined){a[b.get("name")]={}}var d=a[b.get("name")];d[c]=b},pathRelativeTo:function(b){var c=this.get("name"),a=this.get("parentState");while(!SC.none(a)&&a!==b){c="%@.%@".fmt(a.get("name"),c);a=a.get("parentState")}if(a!==b&&b!==this){this.stateLogError("Can not generate relative path from %@ since it not a parent state of %@".fmt(b,this));return null}return c},getSubstate:function(f,h,e){if(!f){return null}var b=SC.typeOf(f);if(b===SC.T_OBJECT){return this._registeredSubstates.indexOf(f)>-1?f:null}if(b!==SC.T_STRING){this.stateLogError("Can not find matching subtype. value must be an object or string: %@".fmt(f));return null}var d=SC.StatePathMatcher.create({state:this,expression:f}),c=[],g;if(d.get("tokens").length===0){return null}var j=this._registeredSubstatePaths[d.get("lastPart")];if(!j){return this._notifySubstateNotFound(h,e,f)}for(g in j){if(d.match(g)){c.push(j[g])}}if(c.length===1){return c[0]}if(c.length>1){var i=[];for(g in j){i.push(g)}if(h){return this._notifySubstateNotFound(h,e,f,i)}var a="Can not find substate matching '%@' in state %@. Ambiguous with the following: %@";this.stateLogError(a.fmt(f,this.get("fullPath"),i.join(", ")))}return this._notifySubstateNotFound(h,e,f)},_notifySubstateNotFound:function(d,c,b,a){return d?d.call(c||this,this,b,a):null},getState:function(a){if(a===this.get("name")){return this}if(SC.kindOf(a,SC.State)){return a}return this.getSubstate(a,this._handleSubstateNotFound)},_handleSubstateNotFound:function(d,c,a){var b=this.get("parentState");if(b){return b.getState(c)}if(a){var e="Can not find state matching '%@'. Ambiguous with the following: %@";this.stateLogError(e.fmt(c,a.join(", ")))}return null},gotoState:function(c,a){var b=this.getState(c);if(!b){var d="can not go to state %@ from state %@. Invalid value.";this.stateLogError(d.fmt(c,this));return}var e=this.findFirstRelativeCurrentState(b);this.get("statechart").gotoState(b,e,false,a)},gotoHistoryState:function(d,a,b){var c=this.getState(d);if(!c){var e="can not go to history state %@ from state %@. Invalid value.";this.stateLogError(e.fmt(d,this));return}var f=this.findFirstRelativeCurrentState(c);this.get("statechart").gotoHistoryState(c,f,a,b)},resumeGotoState:function(){this.get("statechart").resumeGotoState()},stateIsCurrentSubstate:function(a){if(SC.typeOf(a)===SC.T_STRING){a=this.get("statechart").getState(a)}var b=this.get("currentSubstates");return !!b&&b.indexOf(a)>=0},stateIsEnteredSubstate:function(b){if(SC.typeOf(b)===SC.T_STRING){b=this.get("statechart").getState(b)}var a=this.get("enteredSubstates");return !!a&&a.indexOf(b)>=0},isRootState:function(){return this.getPath("statechart.rootState")===this}.property(),isCurrentState:function(){return this.stateIsCurrentSubstate(this)}.property("currentSubstates").cacheable(),isConcurrentState:function(){return this.getPath("parentState.substatesAreConcurrent")}.property(),isEnteredState:function(){return this.stateIsEnteredSubstate(this)}.property("enteredSubstates").cacheable(),hasSubstates:function(){return this.getPath("substates.length")>0}.property("substates"),hasCurrentSubstates:function(){var a=this.get("currentSubstates");return !!a&&a.get("length")>0}.property("currentSubstates").cacheable(),hasEnteredSubstates:function(){var a=this.get("enteredSubstates");return !!a&&a.get("length")>0}.property("enteredSubstates").cacheable(),findFirstRelativeCurrentState:function(b){if(this.get("isCurrentState")){return this}var a=this.get("currentSubstates")||[],d=a.get("length"),c=this.get("parentState");if(d===0){return c?c.findFirstRelativeCurrentState():null}if(d>1){b=this.getSubstate(b);if(b){return b.findFirstRelativeCurrentState()}}return a[0]},reenter:function(){if(this.get("isEnteredState")){this.gotoState(this)}else{SC.Logger.error("Can not re-enter state %@ since it is not an entered state in the statechart".fmt(this))}},tryToHandleEvent:function(g,d,b){var h=this.get("statechart"),c;if(this._registeredEventHandlers[g]){this.stateLogWarning("state %@ can not handle event '%@' since it is a registered event handler".fmt(this,g));return NO}if(this._registeredStateObserveHandlers[g]){this.stateLogWarning("state %@ can not handle event '%@' since it is a registered state observe handler".fmt(this,g));return NO}if(SC.typeOf(this[g])===SC.T_FUNCTION){h.stateWillTryToHandleEvent(this,g,g);c=(this[g](d,b)!==NO);h.stateDidTryToHandleEvent(this,g,g,c);return c}var f=this._registeredStringEventHandlers[g];if(f){h.stateWillTryToHandleEvent(this,g,f.name);c=(f.handler.call(this,g,d,b)!==NO);h.stateDidTryToHandleEvent(this,g,f.name,c);return c}var a=this._registeredRegExpEventHandlers.length,e=0;for(;e<a;e+=1){f=this._registeredRegExpEventHandlers[e];if(g.match(f.regexp)){h.stateWillTryToHandleEvent(this,g,f.name);c=(f.handler.call(this,g,d,b)!==NO);h.stateDidTryToHandleEvent(this,g,f.name,c);return c}}if(SC.typeOf(this["unknownEvent"])===SC.T_FUNCTION){h.stateWillTryToHandleEvent(this,g,"unknownEvent");c=(this.unknownEvent(g,d,b)!==NO);h.stateDidTryToHandleEvent(this,g,"unknownEvent",c);return c}return NO},enterState:function(a){},stateWillBecomeEntered:function(a){this._isEnteringState=YES},stateDidBecomeEntered:function(a){this._setupAllStateObserveHandlers();this._isEnteringState=NO},exitState:function(a){},stateWillBecomeExited:function(a){this._isExitingState=YES;this._teardownAllStateObserveHandlers()},stateDidBecomeExited:function(a){this._isExitingState=NO},_setupAllStateObserveHandlers:function(){this._configureAllStateObserveHandlers("addObserver")},_teardownAllStateObserveHandlers:function(){this._configureAllStateObserveHandlers("removeObserver")},_configureAllStateObserveHandlers:function(g){var e,c,f,h,b,d,a;for(e in this._registeredStateObserveHandlers){c=this._registeredStateObserveHandlers[e];for(d=0;d<c.length;d+=1){h=c[d];b=e;f=h.indexOf(".");if(f<0){this[g](h,this,b)}else{if(h.indexOf("*")===0){this[g](h.slice(1),this,b)}else{a=null;if(f===0){a=this;h=h.slice(1)}else{if(f===4&&h.slice(0,5)==="this."){a=this;h=h.slice(5)}else{if(f<0&&h.length===4&&h==="this"){a=this;h=""}}}SC.Observers[g](h,this,b,a)}}}}},performAsync:function(c,b,a){return SC.Async.perform(c,b,a)},respondsToEvent:function(d){if(this._registeredEventHandlers[d]){return false}if(SC.typeOf(this[d])===SC.T_FUNCTION){return true}if(this._registeredStringEventHandlers[d]){return true}if(this._registeredStateObserveHandlers[d]){return false}var a=this._registeredRegExpEventHandlers.length,b=0,c;for(;b<a;b+=1){c=this._registeredRegExpEventHandlers[b];if(d.match(c.regexp)){return true}}return SC.typeOf(this["unknownEvent"])===SC.T_FUNCTION},fullPath:function(){var a=this.getPath("statechart.rootState");if(!a){return this.get("name")}return this.pathRelativeTo(a)}.property("name","parentState").cacheable(),toString:function(){return this.get("fullPath")},_statechartOwnerDidChange:function(){this.notifyPropertyChange("owner")},stateLogWarning:function(b){var a=this.get("statechart");a.statechartLogWarning(b)},stateLogError:function(b){var a=this.get("statechart");a.statechartLogError(b)}});SC.State.plugin=function(e){var b;b=new Array(arguments.length-1);for(var c=0,a=b.length;c<a;c++){b[c]=arguments[c+1]}var d=function(){var f=SC.objectForPropertyPath(e);if(!f){console.error("SC.State.plugin: Unable to determine path %@".fmt(e));return undefined}if(!f.isClass||!f.kindOf(SC.State)){console.error("SC.State.plugin: Unable to extend. %@ must be a class extending from SC.State".fmt(e));return undefined}return f.extend.apply(f,b)};d.statePlugin=YES;return d};SC.State.design=SC.State.extend;sc_require("system/state");SC.EMPTY_STATE_NAME="__EMPTY_STATE__";SC.EmptyState=SC.State.extend({name:SC.EMPTY_STATE_NAME,enterState:function(){var a="No initial substate was defined for state %@. Entering default empty state";this.stateLogWarning(a.fmt(this.get("parentState")))}});sc_require("system/state");SC.HistoryState=SC.Object.extend({isRecursive:NO,defaultState:null,statechart:null,parentState:null,state:function(){var b=this.get("defaultState"),a=this.getPath("parentState.historyState");return !!a?a:b}.property().cacheable(),parentHistoryStateDidChange:function(){this.notifyPropertyChange("state")}.observes("*parentState.historyState")});SC.StateRouteHandlerContext=SC.Object.extend({state:null,location:null,params:null,handler:null,retry:function(){var b=this.get("state"),c=this.get("params"),a=this.get("handler");if(SC.typeOf(a)===SC.T_STRING){a=b[a]}if(SC.typeOf(a)===SC.T_FUNCTION){a.apply(b,[c])}}});sc_require("system/state");sc_require("mixins/statechart_delegate");SC.StatechartManager={isResponderContext:YES,isStatechart:YES,statechartIsInitialized:NO,name:null,rootState:null,rootStateExample:SC.State,initialState:null,statesAreConcurrent:NO,statechartOwnerKey:"owner",owner:null,autoInitStatechart:YES,suppressStatechartWarnings:NO,delegate:null,statechartDelegate:function(){var a=this.get("delegate");return this.delegateFor("isStatechartDelegate",a)}.property("delegate"),initMixin:function(){if(this.get("autoInitStatechart")){this.initStatechart()}},destroyMixin:function(){var a=this.get("rootState");a.destroy();this.set("rootState",null);this.notifyPropertyChange("currentStates")},initStatechart:function(){if(this.get("statechartIsInitialized")){return}this._gotoStateLocked=NO;this._sendEventLocked=NO;this._pendingStateTransitions=[];this._pendingSentEvents=[];this.sendAction=this.sendEvent;var b=this.get("rootState"),c;if(!b){b=this._constructRootStateClass()}else{if(SC.typeOf(b)===SC.T_FUNCTION&&b.statePlugin){b=b.apply(this)}}if(!(SC.kindOf(b,SC.State)&&b.isClass)){c="Unable to initialize statechart. Root state must be a state class";this.statechartLogError(c);SC.throw(c)}b=this.createRootState(b,{statechart:this,name:SC.ROOT_STATE_NAME});this.set("rootState",b);b.initState();if(SC.kindOf(b.get("initialSubstate"),SC.EmptyState)){c="Unable to initialize statechart. Root state must have an initial substate explicitly defined";this.statechartLogError(c);SC.throw(c)}if(!SC.empty(this.get("initialState"))){var a="initialState";this.set(a,b.get(this.get(a)))}this.set("statechartIsInitialized",YES);this.gotoState(b)},createRootState:function(b,a){if(!a){a={}}b=b.create(a);return b},currentStates:function(){return this.getPath("rootState.currentSubstates")}.property().cacheable(),firstCurrentState:function(){var a=this.get("currentStates");return a?a.objectAt(0):null}.property("currentStates").cacheable(),currentStateCount:function(){return this.getPath("currentStates.length")}.property("currentStates").cacheable(),stateIsCurrentState:function(a){return this.get("rootState").stateIsCurrentSubstate(a)},enteredStates:function(){return this.getPath("rootState.enteredSubstates")}.property().cacheable(),stateIsEntered:function(a){return this.get("rootState").stateIsEnteredSubstate(a)},doesContainState:function(a){return !SC.none(this.getState(a))},getState:function(b){var a=this.get("rootState");return a===b?a:a.getSubstate(b)},gotoState:function(a,l,m,b){if(!this.get("statechartIsInitialized")){this.statechartLogError("can not go to state %@. statechart has not yet been initialized".fmt(a));return}if(this.get("isDestroyed")){this.statechartLogError("can not go to state %@. statechart is destroyed".fmt(this));return}var j=new Array(arguments.length);for(var e=0,h=j.length;e<h;e++){j[e]=arguments[e]}j=this._processGotoStateArgs(j);a=j.state;l=j.fromCurrentState;m=j.useHistory;b=j.context;var o=null,k=[],n=[],g=a,d=l,c;a=this.getState(a);if(SC.none(a)){this.statechartLogError("Can not to goto state %@. Not a recognized state in statechart".fmt(g));return}if(this._gotoStateLocked){this._pendingStateTransitions.push({state:a,fromCurrentState:l,useHistory:m,context:b});return}this._gotoStateLocked=YES;if(l){l=this.getState(l);if(SC.none(l)||!l.get("isCurrentState")){c="Can not to goto state %@. %@ is not a recognized current state in statechart";this.statechartLogError(c.fmt(g,d));this._gotoStateLocked=NO;return}}else{l=a.findFirstRelativeCurrentState();if(!l){l=this.get("firstCurrentState")}}if(!SC.none(l)){k=this._createStateChain(l)}n=this._createStateChain(a);o=this._findPivotState(k,n);if(o){if(o.get("substatesAreConcurrent")&&o!==a){this.statechartLogError("Can not go to state %@ from %@. Pivot state %@ has concurrent substates.".fmt(a,l,o));this._gotoStateLocked=NO;return}}var f=[];this._traverseStatesToExit(k.shift(),k,o,f);if(o!==a){this._traverseStatesToEnter(n.pop(),n,o,m,f)}else{this._traverseStatesToExit(o,[],null,f);this._traverseStatesToEnter(o,null,null,m,f)}this._gotoStateActions=f;this._executeGotoStateActions(a,f,null,b)},gotoStateActive:function(){return this._gotoStateLocked}.property(),gotoStateSuspended:function(){return this._gotoStateLocked&&!!this._gotoStateSuspendedPoint}.property(),resumeGotoState:function(){if(!this.get("gotoStateSuspended")){this.statechartLogError("Can not resume goto state since it has not been suspended");return}var a=this._gotoStateSuspendedPoint;this._executeGotoStateActions(a.gotoState,a.actions,a.marker,a.context)},_executeGotoStateActions:function(g,f,b,c){var e=null,a=f.length,d=null;b=SC.none(b)?0:b;for(;b<a;b+=1){this._currentGotoStateAction=e=f[b];switch(e.action){case SC.EXIT_STATE:d=this._exitState(e.state,c);break;case SC.ENTER_STATE:d=this._enterState(e.state,e.currentState,c);break}if(SC.kindOf(d,SC.Async)){this._gotoStateSuspendedPoint={gotoState:g,actions:f,marker:b+1,context:c};d.tryToPerform(e.state);return}}this.beginPropertyChanges();this.notifyPropertyChange("currentStates");this.notifyPropertyChange("enteredStates");this.endPropertyChanges();this._cleanupStateTransition()},_cleanupStateTransition:function(){this._currentGotoStateAction=null;this._gotoStateSuspendedPoint=null;this._gotoStateActions=null;this._gotoStateLocked=NO;this._flushPendingStateTransition();if(!this._sendEventLocked&&!this._gotoStateLocked){this._flushPendingSentEvents()}},_exitState:function(d,b){var c;if(d.get("currentSubstates").indexOf(d)>=0){c=d.get("parentState");while(c){c.get("currentSubstates").removeObject(d);c.notifyPropertyChange("currentSubstates");c=c.get("parentState")}}c=d;while(c){c.get("enteredSubstates").removeObject(d);c.notifyPropertyChange("enteredSubstates");c=c.get("parentState")}d.set("currentSubstates",[]);d.notifyPropertyChange("currentSubstates");d.stateWillBecomeExited(b);var a=this.exitState(d,b);d.stateDidBecomeExited(b);d._traverseStatesToExit_skipState=NO;return a},exitState:function(b,a){return b.exitState(a)},_enterState:function(d,e,b){var c=d.get("parentState");if(c&&!d.get("isConcurrentState")){c.set("historyState",d)}if(e){c=d;while(c){c.get("currentSubstates").pushObject(d);c.notifyPropertyChange("currentSubstates");c=c.get("parentState")}}c=d;while(c){c.get("enteredSubstates").pushObject(d);c.notifyPropertyChange("enteredSubstates");c=c.get("parentState")}d.stateWillBecomeEntered(b);var a=this.enterState(d,b);d.stateDidBecomeEntered(b);return a},enterState:function(b,a){if(b.enterStateByRoute&&SC.kindOf(a,SC.StateRouteHandlerContext)){return b.enterStateByRoute(a)}else{return b.enterState(a)}},gotoHistoryState:function(h,g,d,f){if(!this.get("statechartIsInitialized")){this.statechartLogError("can not go to state %@'s history state. Statechart has not yet been initialized".fmt(h));return}var c=new Array(arguments.length);for(var e=0,b=c.length;e<b;e++){c[e]=arguments[e]}c=this._processGotoStateArgs(c);h=c.state;g=c.fromCurrentState;d=c.useHistory;f=c.context;h=this.getState(h);if(!h){this.statechartLogError("Can not to goto state %@'s history state. Not a recognized state in statechart".fmt(h));return}var a=h.get("historyState");if(!d){if(a){this.gotoState(a,g,f)}else{this.gotoState(h,g,f)}}else{this.gotoState(h,g,YES,f)}},sendEvent:function(b,f,e){if(this.get("isDestroyed")){this.statechartLogError("can not send event %@. statechart is destroyed".fmt(b));return}var c=NO,l=this,k=NO,g=this.get("currentStates").slice(),j={},h=0,d=0,a=null;if(this._sendEventLocked||this._gotoStateLocked){this._pendingSentEvents.push({event:b,arg1:f,arg2:e});return}this._sendEventLocked=YES;h=g.get("length");for(;d<h;d+=1){k=NO;a=g[d];if(!a.get("isCurrentState")){continue}while(!k&&a){if(!j[a.get("fullPath")]){k=a.tryToHandleEvent(b,f,e);j[a.get("fullPath")]=YES}if(!k){a=a.get("parentState")}else{c=YES}}}this._sendEventLocked=NO;if(!this._sendEventLocked&&!this._gotoStateLocked){l=this._flushPendingSentEvents()}return c?this:(l?this:null)},stateWillTryToHandleEvent:function(c,b,a){this._stateHandleEventInfo={state:c,event:b,handler:a}},stateDidTryToHandleEvent:function(c,b,a,d){this._stateHandleEventInfo=null},_createStateChain:function(b){var a=[];while(b){a.push(b);b=b.get("parentState")}return a},_findPivotState:function(c,b){if(c.length===0||b.length===0){return null}var a=c.find(function(e,d){if(b.indexOf(e)>=0){return YES}});return a},_traverseStatesToExit:function(b,j,d,g){if(!b||b===d){return}if(b.get("substatesAreConcurrent")){var e=0,f=b.get("currentSubstates"),h=f.length,c=null;for(;e<h;e+=1){c=f[e];if(c._traverseStatesToExit_skipState===YES){continue}var a=this._createStateChain(c);this._traverseStatesToExit(a.shift(),a,b,g)}}g.push({action:SC.EXIT_STATE,state:b});if(b.get("isCurrentState")){b._traverseStatesToExit_skipState=YES}this._traverseStatesToExit(j.shift(),j,d,g)},_traverseStatesToEnter:function(b,d,h,f,c){if(!b){return}if(h){if(b!==h){this._traverseStatesToEnter(d.pop(),d,h,f,c)}else{this._traverseStatesToEnter(d.pop(),d,null,f,c)}}else{if(!d||d.length===0){var g={action:SC.ENTER_STATE,state:b,currentState:NO};c.push(g);var e=b.get("initialSubstate"),a=b.get("historyState");if(b.get("substatesAreConcurrent")){this._traverseConcurrentStatesToEnter(b.get("substates"),null,f,c)}else{if(b.get("hasSubstates")&&a&&f){this._traverseStatesToEnter(a,null,null,f,c)}else{if(e){if(SC.kindOf(e,SC.HistoryState)){if(!f){f=e.get("isRecursive")}e=e.get("state")}this._traverseStatesToEnter(e,null,null,f,c)}else{g.currentState=YES}}}}else{if(d.length>0){c.push({action:SC.ENTER_STATE,state:b});var i=d.pop();this._traverseStatesToEnter(i,d,null,f,c);if(b.get("substatesAreConcurrent")){this._traverseConcurrentStatesToEnter(b.get("substates"),i,f,c)}}}}},respondsTo:function(d){if(this.get("isDestroyed")){this.statechartLogError("can not respond to event %@. statechart is destroyed".fmt(d));return false}var b=this.get("currentStates"),a=b.get("length"),c=0,e=null;for(;c<a;c+=1){e=b.objectAt(c);while(e){if(e.respondsToEvent(d)){return true}e=e.get("parentState")}}return SC.typeOf(this[d])===SC.T_FUNCTION},tryToPerform:function(d,c,b){if(!this.respondsTo(d)){return NO}if(SC.typeOf(this[d])===SC.T_FUNCTION){var a=this[d](c,b);if(a!==NO){return YES}}return !!this.sendEvent(d,c,b)},invokeStateMethod:function(k,j,c){if(k==="unknownEvent"){this.statechartLogError("can not invoke method unkownEvent");return}j=SC.A(arguments);j.shift();var f=j.length,m=f>0?j[f-1]:null,l=SC.typeOf(m)===SC.T_FUNCTION?j.pop():null,e=this.get("currentStates"),d=0,b=null,h={},a,n,g=0;f=e.get("length");for(;d<f;d+=1){b=e.objectAt(d);while(b){if(h[b.get("fullPath")]){break}h[b.get("fullPath")]=YES;a=b[k];if(SC.typeOf(a)===SC.T_FUNCTION&&!a.isEventHandler){n=a.apply(b,j);if(l){l.call(this,b,n)}g+=1;break}b=b.get("parentState")}}return g===1?n:undefined},_traverseConcurrentStatesToEnter:function(d,c,f,b){var e=0,a=d.length,g=null;for(;e<a;e+=1){g=d[e];if(g!==c){this._traverseStatesToEnter(g,null,null,f,b)}}},_flushPendingStateTransition:function(){if(!this._pendingStateTransitions){this.statechartLogError("Unable to flush pending state transition. _pendingStateTransitions is invalid");return}var a=this._pendingStateTransitions.shift();if(!a){return}this.gotoState(a.state,a.fromCurrentState,a.useHistory,a.context)},_flushPendingSentEvents:function(){var a=this._pendingSentEvents.shift();if(!a){return null}return this.sendEvent(a.event,a.arg1,a.arg2)},_processGotoStateArgs:function(b){var d={state:null,fromCurrentState:null,useHistory:false,context:null},a=null,c=null;b=b.filter(function(e){return e!==undefined});a=b.length;if(a<1){return d}d.state=b[0];if(a===2){c=b[1];switch(SC.typeOf(c)){case SC.T_BOOL:d.useHistory=c;break;case SC.T_HASH:case SC.T_OBJECT:if(!SC.kindOf(c,SC.State)){d.context=c}break;default:d.fromCurrentState=c}}else{if(a===3){c=b[1];if(SC.typeOf(c)===SC.T_BOOL){d.useHistory=c;d.context=b[2]}else{d.fromCurrentState=c;c=b[2];if(SC.typeOf(c)===SC.T_BOOL){d.useHistory=c}else{d.context=c}}}else{d.fromCurrentState=b[1];d.useHistory=b[2];d.context=b[3]}}return d},_constructRootStateClass:function(){var d="rootStateExample",e=this.get(d),b=this.get("initialState"),c=this.get("statesAreConcurrent"),a=0,i,g,f,h={};if(SC.typeOf(e)===SC.T_FUNCTION&&e.statePlugin){e=e.apply(this)}if(!(SC.kindOf(e,SC.State)&&e.isClass)){this._logStatechartCreationError("Invalid root state example");return null}if(c&&!SC.empty(b)){this._logStatechartCreationError("Can not assign an initial state when states are concurrent")}else{if(c){h.substatesAreConcurrent=YES}else{if(SC.typeOf(b)===SC.T_STRING){h.initialSubstate=b}else{this._logStatechartCreationError("Must either define initial state or assign states as concurrent");return null}}}for(i in this){if(i===d){continue}g=this[i];f=SC.typeOf(g)===SC.T_FUNCTION;if(f&&g.statePlugin){g=g.apply(this)}if(SC.kindOf(g,SC.State)&&g.isClass&&this[i]!==this.constructor){h[i]=g;a+=1}}if(a===0){this._logStatechartCreationError("Must define one or more states");return null}return e.extend(h)},_logStatechartCreationError:function(a){SC.Logger.error("Unable to create statechart for %@: %@.".fmt(this,a))},statechartLogError:function(a){SC.Logger.error("ERROR %@: %@".fmt(this.get("statechartLogPrefix"),a))},statechartLogWarning:function(a){if(this.get("suppressStatechartWarnings")){return}SC.Logger.warn("WARN %@: %@".fmt(this.get("statechartLogPrefix"),a))},statechartLogPrefix:function(){var b=SC._object_className(this.constructor),a=this.get("name"),c;if(SC.empty(a)){c="%@<%@>".fmt(b,SC.guidFor(this))}else{c="%@<%@, %@>".fmt(b,a,SC.guidFor(this))}return c}.property().cacheable()};SC.mixin(SC.StatechartManager,SC.StatechartDelegate,SC.DelegateSupport);SC.ROOT_STATE_NAME="__ROOT_STATE__";SC.EXIT_STATE=0;SC.ENTER_STATE=1;SC.Statechart=SC.Object.extend(SC.StatechartManager,{autoInitStatechart:NO});SC.Statechart.design=SC.Statechart.extend;
/*!
 * ==========================================================================
 * SproutCore -- JavaScript Application Framework
 * Copyright ©2008-2011 Apple Inc. All rights reserved.
 * Copyright 2006-2011, Strobe Inc. and contributors.
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a 
 * copy of this software and associated documentation files (the "Software"), 
 * to deal in the Software without restriction, including without limitation 
 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 
 * and/or sell copies of the Software, and to permit persons to whom the 
 * Software is furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in 
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
 * DEALINGS IN THE SOFTWARE.
 * 
 * SproutCore and the SproutCore logo are trademarks of Strobe Inc.
 * 
 * For more information about SproutCore, visit http://www.sproutcore.com
 * 
 * ==========================================================================
 */
;SC.EmptyTheme=SC.BaseTheme.create({name:"sc-empty-theme"});SC.Theme.addTheme(SC.EmptyTheme);SC.AceTheme=SC.BaseTheme.create({name:"ace",description:"A SproutCore built-in theme by Alex Iskander and contributors. Only supports browsers that implement CSS3."});SC.Theme.addTheme(SC.AceTheme);SC.AceTheme.PointLeft=SC.AceTheme.subtheme("point-left","point-left");SC.AceTheme.PointRight=SC.AceTheme.subtheme("point-right","point-right");SC.AceTheme.Capsule=SC.AceTheme.subtheme("capsule","capsule");SC.AceTheme.Dark=SC.AceTheme.subtheme("dark");SC.defaultTheme="ace";sc_require("theme");SC.AceTheme.Dark.PointLeft=SC.AceTheme.Dark.subtheme("point-left","point-left");SC.AceTheme.Dark.PointRight=SC.AceTheme.Dark.subtheme("point-right","point-right");SC.AceTheme.Dark.PointRight=SC.AceTheme.Dark.subtheme("capsule","capsule");SC.AceTheme.SourceList=SC.AceTheme.subtheme("source-list");sc_require("theme");SC.AceTheme.Popover=SC.AceTheme.Dark.subtheme("popover");SC.AceTheme.addTheme(SC.AceTheme.Popover);SC.AceTheme.SolidPopover=SC.AceTheme.Popover.subtheme("solid");SC.AceTheme.addTheme(SC.AceTheme.SolidPopover.create({name:"solid-popover"}));sc_require("resources/picker/popover/popover");SC.AceTheme.Popover.pickerRenderDelegate=SC.RenderDelegate.create({className:"picker",render:function(e,b){var a=e.get("preferType");var d=e.get("pointerPos");var c=e.get("pointerPosY");if(a==SC.PICKER_POINTER||a==SC.PICKER_MENU_POINTER){b.addClass(d)}},update:function(e,d){var a=e.get("preferType");var c=e.get("pointerPos");var b=e.get("pointerPosY");if(a==SC.PICKER_POINTER||a==SC.PICKER_MENU_POINTER){d.addClass(c)}}});SC.AceTheme.Popover.workspaceRenderDelegate=SC.RenderDelegate.create({className:"workspace",render:function(b,a){a.setClass({"top-toolbar":b.get("hasTopToolbar"),"bottom-toolbar":b.get("hasBottomToolbar")});a=a.begin("div").addClass("popover-background");this.includeSlices(b,a,SC.NINE_SLICE);a.push("<div class = 'sc-pointer'></div>");a=a.end()},update:function(b,a){a.setClass({"top-toolbar":b.get("hasTopToolbar"),"bottom-toolbar":b.get("hasBottomToolbar")})}});SC.stringsFor("fr",{"DG.fileMenu.menuItem.newDocument":"Nouveau","DG.fileMenu.menuItem.openDocument":"Ouvrir...","DG.fileMenu.menuItem.closeDocument":"Fermer","DG.fileMenu.menuItem.importFile":"Importer...","DG.fileMenu.menuItem.revertTo":"Rétablir...","DG.fileMenu.menuItem.revertToOpened":"État récemment ouvert","DG.fileMenu.menuItem.revertToShared":"Vue partagée","DG.fileMenu.menuItem.saveDocument":"Enregistrer...","DG.fileMenu.menuItem.copyDocument":"Créer une copie","DG.fileMenu.menuItem.share":"Partager...","DG.fileMenu.menuItem.shareGetLink":"Obtenir le lien vers la vue partagée","DG.fileMenu.menuItem.shareUpdate":"Actualiser la vue partagée","DG.fileMenu.menuItem.renameDocument":"Renommer","DG.main.userEntryView.title":"Que souhaitez-vous faire ?","DG.main.userEntryView.openDocument":"Ouvrir un document ou parcourir des exemples","DG.main.userEntryView.newDocument":"Nouveau document","DG.mainPage.mainPane.undoButton.title":"Annuler","DG.mainPage.mainPane.undoButton.toolTip":"Annuler la dernière action","DG.mainPage.mainPane.redoButton.title":"Rétablir","DG.mainPage.mainPane.redoButton.toolTip":"Rétablir la dernière action annulée","DG.mainPage.mainPane.versionString":"Version %@ (%@)","DG.mainPage.mainPane.messageView.value":"Malheureusement, CODAP n'est pas compatible avec votre navigateur. CODAP est compatible avec Firefox 46+, Chrome 50+, Windows Edge 14+ et Safari 10+. CODAP n'est pas compatible avec d'autres navigateurs à l'heure actuelle.","DG.mainPage.titleBar.saved":"Document enregistré!","DG.mainPage.mainPane.versionString.IS_BUILD":"Version %@ (%@ IS)","DG.mainPage.mainPane.versionString.SRRI_BUILD":"Version %@ (%@.srri10)","DG.AppController.resetData.title":"Effacer les données...","DG.AppController.resetData.toolTip":"Supprimer toutes les données de ce document","DG.AppController.resetData.warnMessage":"Voulez-vous vraiment supprimer toutes les données de ce document ?","DG.AppController.resetData.warnDescription":"Cette action ne peut pas être annulée.","DG.AppController.resetData.okButtonTitle":"Oui, supprimer les données","DG.AppController.resetData.cancelButtonTitle":"Non, conserver les données","DG.AppController.closeDocument.warnMessage":"Fermer le document actuel sans l'enregistrer ?","DG.AppController.closeDocument.warnDescription":"Cette action ne peut pas être annulée.","DG.AppController.closeDocument.okButtonTitle":"Fermer","DG.AppController.closeDocument.cancelButtonTitle":"Annuler","DG.AppController.beforeUnload.confirmationMessage":"Le document contient des modifications non enregistrées.","DG.AppController.optionMenuItems.reportProblem":"Envoyez un commentaire...","DG.AppController.optionMenuItems.viewWebPage":"Afficher la page Web ...","DG.AppController.optionMenuItems.configureGuide":"Configurer le guide...","DG.AppController.optionMenuItems.about":"À propos de CODAP...","DG.AppController.optionMenuItems.releaseNotes":"Quoi de neuf ?","DG.AppController.optionMenuItems.help":"Pages d'aide et vidéos...","DG.AppController.optionMenuItems.toWebSite":"Le projet CODAP ...","DG.AppController.exportDocument.prompt":"Nom du fichier:","DG.AppController.exportCaseData.prompt":"Exporter les données de cas depuis:","DG.AppController.exportDocument.exportTitle":"Exporter","DG.AppController.exportDocument.exportTooltip":"Exporter les données vers un fichier","DG.AppController.exportDocument.cancelTitle":"Annuler","DG.AppController.exportDocument.cancelTooltip":"Annuler l'export","DG.AppController.feedbackDialog.dialogTitle":"Laisser un commentaire","DG.AppController.feedbackDialog.subHeaderText":"Votre avis nous est précieux !","DG.AppController.feedbackDialog.messageText":"Aidez-nous à améliorer notre produit. Les questions, les signalements de bogues et les suggestions de fonctionnalités sont les bienvenus. Nous vous remercions de votre aide.","DG.AppController.feedbackDialog.subjectHint":"Quel est l’objet de votre retour?","DG.AppController.feedbackDialog.feedbackHint":"Détails","DG.AppController.feedbackDialog.submitFeedbackButton":"Enregistrer","DG.AppController.feedbackDialog.cancelFeedbackButton":"Annuler","DG.AppController.showWebSiteTitle":"À propos de CODAP","DG.AppController.showHelpTitle":"Aide pour CODAP","DG.AppController.showAboutTitle":"À propos de CODAP","DG.AppController.showReleaseNotesTitle":"Notes de mise à jour de CODAP","DG.AppController.dropFile.error":"Erreur: %@1","DG.AppController.dropFile.unknownFileType":"Vous ne pouvez pas importer le type de fichier déposé","DG.AppController.validateDocument.missingRequiredProperty":"Propriété requise introuvable: %@1","DG.AppController.validateDocument.unexpectedProperty":"Propriété de premier niveau inattendue : %@1","DG.AppController.validateDocument.unresolvedID":"Identifiant introuvable: %@1","DG.AppController.validateDocument.parseError":"Erreur d'analyse dans le document: %@1","DG.AppController.validateDocument.invalidDocument":"Document JSON invalide: %@1","DG.AppController.openDocument.error.general":"Impossible d'ouvrir le fichier","DG.AppController.openDocument.error.invalid_format":"CODAP ne parvient pas à lire ce type de fichier","DG.AppController.createDataSet.initialAttribute":"Nom de l'attribut","DG.AppController.createDataSet.name":"Nouvelle base de données","DG.AppController.createDataSet.collectionName":"Cas","DG.AppController.caseTableMenu.newDataSet":"--nouveau--","DG.SingleTextDialog.okButton.title":"OK","DG.SingleTextDialog.cancelButton.title":"Annuler","DG.SingleTextDialog.cancelButton.toolTip":"Fermer la boîte de dialogue sans apporter de modifications","DG.DocumentController.calculatorTitle":"Calculatrice","DG.DocumentController.caseTableTitle":"Table des cas","DG.DocumentController.graphTitle":"Graphique","DG.DocumentController.sliderTitle":"Curseur","DG.DocumentController.textTitle":"Texte","DG.DocumentController.mapTitle":"Carte","DG.DocumentController.enterURLPrompt":"Saisir l'URL d'une page web à afficher","DG.DocumentController.enterViewWebPageOKTip":"Afficher la page web indiquée par l'URL","DG.Document.defaultDocumentName":"Document sans titre","DG.Document.documentName.toolTip":"Cliquez pour modifier le nom du fichier","DG.SliderView.thumbView.toolTip":"Faites glisser le curseur pour modifier la valeur","DG.SliderView.startButton.toolTip":"Démarrer/arrêter l’animation","DG.ToolButtonData.tableButton.title":"Tableaux","DG.ToolButtonData.tableButton.toolTip":"Ouvrir une table de cas pour chaque ensemble de données (ctrl-alt-t)","DG.ToolButtonData.graphButton.title":"Graphique","DG.ToolButtonData.graphButton.toolTip":"Créer un graphique","DG.ToolButtonData.sliderButton.title":"Curseur","DG.ToolButtonData.sliderButton.toolTip":"Faire un curseur (ctrl-alt-s)","DG.ToolButtonData.calcButton.title":"Calc","DG.ToolButtonData.calcButton.toolTip":"Ouvrir/Fremer la calculatrice (ctrl-alt-c)","DG.ToolButtonData.textButton.title":"Texte","DG.ToolButtonData.textButton.toolTip":"Créez un objet texte (ctrl-alt-shift-t)","DG.ToolButtonData.mapButton.title":"Carte","DG.ToolButtonData.mapButton.toolTip":"Faire une carte","DG.ToolButtonData.optionMenu.title":"Options","DG.ToolButtonData.optionMenu.toolTip":"Afficher un site web, configurer un guide...","DG.ToolButtonData.tileListMenu.title":"Pavages","DG.ToolButtonData.tileListMenu.toolTip":"Afficher la liste des vignettes dans le document","DG.ToolButtonData.guideMenu.title":"Guide","DG.ToolButtonData.guideMenu.toolTip":"Afficher et naviguer dans le guide pour cette activité","DG.ToolButtonData.guideMenu.showGuide":"Afficher le guide","DG.ToolButtonData.help.title":"Aide","DG.ToolButtonData.help.toolTip":"Aide pour CODAP, s'informer sur le projet CODAP","DG.Slider.multiples":"Limiter aux multiples de :","DG.Slider.maxPerSecond":"Nombre maximal d’images/seconde pour l’animation:","DG.Slider.direction":"Sens de l’animation:","DG.Slider.backAndForth":"Aller-retour","DG.Slider.lowToHigh":"Croissant","DG.Slider.highToLow":"Décroissant","DG.Slider.mode":"Répétition de l'animation :","DG.Slider.nonStop":"Non-stop","DG.Slider.onceOnly":"Une seule fois","DG.Undo.exceptionOccurred":"Une erreur s'est produite lors de la tentative d'annulation.","DG.Redo.exceptionOccurred":"Une erreur s'est produite lors de la tentative de rétablissement.","DG.Undo.componentMove":"Annuler le déplacement du composant","DG.Redo.componentMove":"Refaire le déplacement du composant","DG.Undo.componentResize":"Annuler le redimensionnement du composant","DG.Redo.componentResize":"Refaire le redimensionnement du composant","DG.Undo.axisDilate":"Annuler le réajustement de l’axe à l’échelle des données","DG.Redo.axisDilate":"Refaire le redimensionnement de l'axe","DG.Undo.axisRescaleFromData":"Annuler le redimensionnement de l'axe","DG.Redo.axisRescaleFromData":"Refaire le redimensionnement de l'axe","DG.Undo.axisDrag":"Annuler le déplacement de l'axe","DG.Redo.axisDrag":"Refaire le déplacement de l'axe","DG.Undo.axisAttributeChange":"Annuler la modification de l’attribut d’axe","DG.Redo.axisAttributeChange":"Refaire la modification de l'attribut d'axe","DG.Undo.axisAttributeAdded":"Annuler l'ajout d'un attribut d'axe","DG.Redo.axisAttributeAdded":"Refaire l'ajout d'un attribut d'axe","DG.Undo.toggleComponent.add.calcView":"Annuler l'affichage de la calculatrice","DG.Redo.toggleComponent.add.calcView":"Refaire l'affichage de la calculatrice","DG.Undo.toggleComponent.delete.calcView":"Annuler le masquage de la calculatrice","DG.Redo.toggleComponent.delete.calcView":"Refaire le masquage de la calculatrice","DG.Undo.caseTable.open":"Annuler l'affichage des tables de cas","DG.Redo.caseTable.open":"Refaire les tableaux des cas","DG.Undo.caseTable.editAttribute":"Annuler la modification d’un attribut du tableau de cas","DG.Redo.caseTable.editAttribute":"Refaire l'édition d'un attribut de table des cas","DG.Undo.caseTable.createAttribute":"Annuler la création d’un attribut dans le tableau de cas","DG.Redo.caseTable.createAttribute":"Refaire la création d'un attribut de table des cas","DG.Undo.caseTable.editAttributeFormula":"Annuler la modification de la formule d’un attribut du tableau de cas","DG.Redo.caseTable.editAttributeFormula":"Refaire la modification de la formule de l’attribut dans la table des cas","DG.Undo.caseTable.editCellValue":"Annuler la modification d’une valeur dans le tableau de cas","DG.Redo.caseTable.editCellValue":"Refaire la modification de la valeur d’une cellule dans la table des cas","DG.Undo.caseTable.sortCases":"Annuler le tri des cas","DG.Redo.caseTable.sortCases":"Refaire le tri des cas","DG.Undo.caseTable.deleteAttribute":"Annuler la suppression d’un attribut du tableau de cas","DG.Redo.caseTable.deleteAttribute":"Refaire la suppression d'un attribut de table des cas","DG.Undo.caseTable.createCollection":"Annuler la création d'une nouvelle collection","DG.Redo.caseTable.createCollection":"Refaire créer une nouvelle collection","DG.Undo.caseTable.collectionNameChange":"Annuler le renommage de la collection","DG.Redo.caseTable.collectionNameChange":"Refaire renommer la collection","DG.Undo.caseTable.createNewCase":"Annuler la création d'un nouveau cas","DG.Redo.caseTable.createNewCase":"Refaire créer un nouveau cas","DG.Undo.caseTable.insertCases":"Annuler l'insertion de cas","DG.Redo.caseTable.insertCases":"Refaire l’insertion de cas","DG.Undo.caseTable.groupToggleExpandCollapseAll":"Annuler l’expansion/repli de tous les groupes","DG.Redo.caseTable.groupToggleExpandCollapseAll":"Refaire l’ouverture ou la fermeture de tous les éléments","DG.Undo.caseTable.expandCollapseOneCase":"Annuler l'expansion ou le repli d'un groupe","DG.Redo.caseTable.expandCollapseOneCase":"Refaire l'expansion ou la réduction d'un groupe","DG.Undo.caseTable.resizeColumns":"Annuler le redimensionnement automatique de toutes les colonnes","DG.Redo.caseTable.resizeColumns":"Refaire le redimensionnement automatique de toutes les colonnes","DG.Undo.document.share":"Annuler le partage du document","DG.Redo.document.share":"Refaire le partage du document","DG.Undo.document.unshare":"Annuler le zoom sur la carte","DG.Redo.document.unshare":"Refaire l’arrêt du partage du document","DG.Undo.game.add":"Annuler l'ajout d'un jeu au document","DG.Redo.game.add":"Refaire l'ajout d'un jeu au document","DG.Undo.graph.showCount":"Annuler l’affichage du dénombrement","DG.Redo.graph.showCount":"Refaire l’affichage de l’effectif","DG.Undo.graph.hideCount":"Annuler le masquage du nombre (de cas)","DG.Redo.graph.hideCount":"Refaire le masquage de l’effectif","DG.Undo.graph.showPercent":"Annuler l'affichage du pourcentage","DG.Redo.graph.showPercent":"Refaire l'affichage du pourcentage","DG.Undo.graph.hidePercent":"Annuler le masquage des pourcentages","DG.Redo.graph.hidePercent":"Refaire le masquage du pourcentage","DG.Undo.graph.showMovableLine":"Annuler l'affichage de la ligne mobile","DG.Redo.graph.showMovableLine":"Refaire l'affichage de la ligne mobile","DG.Undo.graph.hideMovableLine":"Annuler le masquage de la droite mobile","DG.Redo.graph.hideMovableLine":"Refaire le masquage de la ligne mobile","DG.Undo.graph.lockIntercept":"Annuler le verrouillage de l’ordonnée à l’origine","DG.Redo.graph.lockIntercept":"Refaire le verrouillage de l’ordonnée à l’origine","DG.Undo.graph.unlockIntercept":"Annuler le déverrouillage de l'ordonnée à l'origine","DG.Redo.graph.unlockIntercept":"Refaire le déverrouillage de l’ordonnée à l’origine","DG.Undo.graph.showPlotFunction":"Annuler l'affichage de la fonction tracée","DG.Redo.graph.showPlotFunction":"Refaire l'affichage de la fonction tracée","DG.Undo.graph.hidePlotFunction":"Annuler le masquage de la fonction tracée","DG.Redo.graph.hidePlotFunction":"Refaire le masquage de la fonction tracée","DG.Undo.graph.changePlotFunction":"Annuler le changement de fonction tracée","DG.Redo.graph.changePlotFunction":"Refaire le changement de la fonction tracée","DG.Undo.graph.showPlotValue":"Annuler l'affichage de la valeur tracée","DG.Redo.graph.showPlotValue":"Refaire l'affichage de la valeur tracée","DG.Undo.graph.hidePlotValue":"Annuler le masquage de la valeur tracée","DG.Redo.graph.hidePlotValue":"Refaire le masquage de la valeur tracée","DG.Undo.graph.changePlotValue":"Annuler le changement de valeur tracée","DG.Redo.graph.changePlotValue":"Refaire le changement de la valeur tracée","DG.Undo.graph.showConnectingLine":"Annuler l'affichage de la ligne de connexion","DG.Redo.graph.showConnectingLine":"Refaire l'affichage de la ligne de connexion","DG.Undo.graph.hideConnectingLine":"Annuler le masquage de la ligne de connexion","DG.Redo.graph.hideConnectingLine":"Refaire le masquage de la ligne de connexion","DG.Undo.graph.showLSRL":"Annuler l’affichage de la droite des moindres carrés","DG.Redo.graph.showLSRL":"Refaire l'affichage de la ligne des moindres carrés","DG.Undo.graph.hideLSRL":"Annuler le masquage de la droite des moindres carrés","DG.Redo.graph.hideLSRL":"Refaire le masquage de la droite des moindres carrés","DG.Undo.graph.showSquares":"Annuler l’affichage des carrés des résidus","DG.Redo.graph.showSquares":"Refaire l'affichage des carrés des résidus","DG.Undo.graph.hideSquares":"Annuler le masquage des carrés des résidus","DG.Redo.graph.hideSquares":"Refaire le masquage des carrés des résidus","DG.Undo.graph.showPlottedMean":"Annuler l'affichage de la moyenne","DG.Redo.graph.showPlottedMean":"Refaire l'affichage de la moyenne","DG.Undo.graph.hidePlottedMean":"Annuler le masquage de la moyenne","DG.Redo.graph.hidePlottedMean":"Refaire le masquage de la moyenne","DG.Undo.graph.showPlottedMedian":"Annuler l'affichage de la médiane","DG.Redo.graph.showPlottedMedian":"Refaire l'affichage de la médiane","DG.Undo.graph.hidePlottedMedian":"Annuler le masquage de la médiane","DG.Redo.graph.hidePlottedMedian":"Refaire le masquage de la médiane","DG.Undo.graph.showPlottedStDev":"Annuler l'affichage de l'écart-type","DG.Redo.graph.showPlottedStDev":"Refaire l'affichage de l'écart type","DG.Undo.graph.hidePlottedStDev":"Annuler le masquage de l’écart type","DG.Redo.graph.hidePlottedStDev":"Refaire le masquage de l’écart type","DG.Undo.graph.showPlottedIQR":"Annuler l'affichage de l'intervalle interquartile","DG.Redo.graph.hidePlottedIQR":"Refaire le masquage de l’intervalle interquartile","DG.Undo.graph.hidePlottedIQR":"Annuler le masquage de l’écart interquartile","DG.Redo.graph.showPlottedIQR":"Refaire l'affichage de l'intervalle interquartile","DG.Undo.graph.addMovableValue":"Annuler l’ajout de la valeur mobile","DG.Redo.graph.addMovableValue":"Refaire l’ajout d’une valeur mobile","DG.Undo.graph.removeMovableValue":"Annuler la suppression de la valeur mobile","DG.Redo.graph.removeMovableValue":"Refaire la suppression de la valeur mobile","DG.Undo.graph.moveMovableValue":"Annuler le déplacement de la valeur mobile","DG.Redo.graph.moveMovableValue":"Refaire le déplacement de la valeur mobile","DG.Undo.graph.changePointColor":"Annuler le changement de la couleur des données","DG.Redo.graph.changePointColor":"Refaire le changement de couleur des données","DG.Undo.graph.changeStrokeColor":"Annuler le changement de la couleur des traits","DG.Redo.graph.changeStrokeColor":"Refaire le changement de la couleur du trait","DG.Undo.graph.changePointSize":"Annuler le changement de la taille des points","DG.Redo.graph.changePointSize":"Refaire le changement de la taille des points","DG.Undo.graph.changeAttributeColor":"Annuler la modification de la couleur d'un attribut","DG.Redo.graph.changeAttributeColor":"Refaire la modification de la couleur de l’attribut","DG.Undo.graph.changeBackgroundColor":"Annuler le changement de couleur d’arrière-plan du graphique","DG.Redo.graph.changeBackgroundColor":"Refaire le changement de la couleur de fond du graphique","DG.Undo.graph.toggleTransparent":"Annuler l’activation de la transparence du graphique","DG.Redo.graph.toggleTransparent":"Refaire le changement de transparence du graphique","DG.Undo.guide.show":"Annuler l'affichage du guide","DG.Redo.guide.show":"Refaire l'affichage du guide","DG.Undo.guide.navigate":"Annuler le changement de page du guide","DG.Redo.guide.navigate":"Refaire le changement de page du guide","DG.Undo.hideSelectedCases":"Annuler le masquage des cas sélectionnés","DG.Redo.hideSelectedCases":"Refaire le masquage des cas sélectionnés","DG.Undo.hideUnselectedCases":"Annuler le masquage des cas non sélectionnés","DG.Redo.hideUnselectedCases":"Refaire le masquage des cas non sélectionnés","DG.Undo.enableNumberToggle":"Annuler l'affichage des bascules de visibilité parent","DG.Redo.enableNumberToggle":"Refaire l’affichage des commutateurs de visibilité des éléments parents","DG.Undo.disableNumberToggle":"Annuler la masque des bascules de visibilité parent","DG.Redo.disableNumberToggle":"Refaire le masquage des commutateurs de visibilité des éléments parents","DG.Undo.interactiveUndoableAction":"Annuler une action dans l’interface interactive","DG.Redo.interactiveUndoableAction":"Refaire une action dans l'interface interactive","DG.Undo.showAllCases":"Annuler l'affichage de tous les cas","DG.Redo.showAllCases":"Refaire l'affichage de tous les cas","DG.Undo.map.create":"Annuler l’ajout d’une carte","DG.Redo.map.create":"Refaire l’ajout d’une carte","DG.Undo.map.fitBounds":"Annuler le redimensionnement de la carte","DG.Redo.map.fitBounds":"Refaire le redimensionnement de la carte","DG.Undo.map.pan":"Annuler le déplacement de la carte","DG.Redo.map.pan":"Refaire le déplacement de la carte","DG.Undo.map.zoom":"Annuler le zoom sur la carte","DG.Redo.map.zoom":"Refaire le zoom sur la carte","DG.Undo.map.showGrid":"Annuler l'affichage de la grille sur la carte","DG.Redo.map.showGrid":"Refaire l'affichage de la grille sur la carte","DG.Undo.map.hideGrid":"Annuler le masquage de la grille sur la carte","DG.Redo.map.hideGrid":"Refaire le masquage de la grille sur la carte","DG.Undo.map.changeGridSize":"Annuler la modification de la taille de la grille de la carte","DG.Redo.map.changeGridSize":"Refaire le réglage de la taille de la grille sur la carte","DG.Undo.map.showPoints":"Annuler l'affichage des points sur la carte","DG.Redo.map.showPoints":"Refaire l'affichage des points sur la carte","DG.Undo.map.hidePoints":"Annuler le masquage de points sur la carte","DG.Redo.map.hidePoints":"Refaire le masquage des points sur la carte","DG.Undo.map.showLines":"Annuler l'affichage des lignes sur la carte","DG.Redo.map.showLines":"Refaire l'affichage des lignes sur la carte","DG.Undo.map.hideLines":"Annuler le masquage des lignes sur la carte","DG.Redo.map.hideLines":"Refaire le masquage des lignes sur la carte","DG.Undo.map.changeBaseMap":"Annuler le changement de fond de carte","DG.Redo.map.changeBaseMap":"Refaire la modification de l’arrière-plan de la carte","DG.Undo.textComponent.create":"Annuler l’ajout de l’objet texte","DG.Redo.textComponent.create":"Refaire l'ajout d'un objet texte","DG.Undo.textComponent.edit":"Annuler l'édition du texte","DG.Redo.textComponent.edit":"Refaire la modification du texte","DG.Undo.sliderComponent.create":"Annuler l'ajout d'un curseur","DG.Redo.sliderComponent.create":"Refaire l'ajout d'un curseur","DG.Undo.slider.change":"Annuler la modification de la valeur du curseur","DG.Redo.slider.change":"Refaire la modification de la valeur du curseur","DG.Undo.slider.changeMultiples":"Annuler la modification de la restriction des multiples du curseur","DG.Redo.slider.changeMultiples":"Refaire la modification de la restriction des multiples du curseur","DG.Undo.slider.changeSpeed":"Annuler la modification du nombre maximal d’images/seconde du curseur","DG.Redo.slider.changeSpeed":"Refaire la modification du nombre maximal d’images par seconde du curseur","DG.Undo.slider.changeDirection":"Annuler la modification de la direction de l’animation du curseur","DG.Redo.slider.changeDirection":"Refaire la modififcation de la direction de l'animation du curseur","DG.Undo.slider.changeRepetition":"Annuler la modification de la répétition de l’animation du curseur","DG.Redo.slider.changeRepetition":"Refaire la modification de la répétition de l'animation du curseur","DG.Undo.graphComponent.create":"Annuler l'ajout d'un graphique","DG.Redo.graphComponent.create":"Refaire l'ajout d'un graphique","DG.Undo.dataContext.create":"Annuler la création d’un jeu de données","DG.Redo.dataContext.create":"Refaire la création d’un jeu de données","DG.Undo.data.deleteCases":"Annuler la suppression des cas","DG.Redo.data.deleteCases":"Refaire la suppression des cas","DG.Undo.component.close":"Annuler la fermeture du composant","DG.Redo.component.close":"Refaire la fermeture du composant","DG.Undo.component.minimize":"Annuler la réduction du composant","DG.Redo.component.minimize":"Refaire la réduction du composant","DG.Undo.dataContext.moveAttribute":"Annuler le déplacement de l'attribut de la table de cas","DG.Redo.dataContext.moveAttribute":"Refaire le déplacement d’un attribut dans la table des cas","DG.DataContext.singleCaseName":"cas","DG.DataContext.pluralCaseName":"cas","DG.DataContext.caseCountString":"%@1 %@2","DG.DataContext.setOfCasesLabel":"un ensemble de cas","DG.DataContext.collapsedRowString":"%@1 de %@2","DG.DataContext.noData":"Pas de données","DG.DataContext.baseName":"Base de données %@1","DG.CollectionClient.cantEditFormulaErrorMsg":"La formule de l'attribut « %@ » n'est pas modifiable.","DG.CollectionClient.cantEditFormulaErrorDesc":"Créer un nouvel attribut pour pouvoir spécifier une formule.","DG.Formula.FuncCategoryArithmetic":"Fonction arithmétique","DG.Formula.FuncCategoryConversion":"Autres fonctions","DG.Formula.FuncCategoryDateTime":"Fonctions date/heure","DG.Formula.FuncCategoryLookup":"Fonctions de recherche","DG.Formula.FuncCategoryOther":"Autres fonctions","DG.Formula.FuncCategoryRandom":"Autres fonctions","DG.Formula.FuncCategoryStatistical":"Fonctions statistiques","DG.Formula.FuncCategoryString":"Fonctions de texte","DG.Formula.FuncCategoryTrigonometric":"Fonctions trigonométriques","DG.Formula.DateLongMonthJanuary":"Janvier","DG.Formula.DateLongMonthFebruary":"Février","DG.Formula.DateLongMonthMarch":"Mars","DG.Formula.DateLongMonthApril":"Avril","DG.Formula.DateLongMonthMay":"Mai","DG.Formula.DateLongMonthJune":"Juin","DG.Formula.DateLongMonthJuly":"Juillet","DG.Formula.DateLongMonthAugust":"Août","DG.Formula.DateLongMonthSeptember":"Septembre","DG.Formula.DateLongMonthOctober":"Octobre","DG.Formula.DateLongMonthNovember":"Novembre","DG.Formula.DateLongMonthDecember":"Décembre","DG.Formula.DateShortMonthJanuary":"jan","DG.Formula.DateShortMonthFebruary":"fev","DG.Formula.DateShortMonthMarch":"mar","DG.Formula.DateShortMonthApril":"avr","DG.Formula.DateShortMonthMay":"mai","DG.Formula.DateShortMonthJune":"juin","DG.Formula.DateShortMonthJuly":"jul","DG.Formula.DateShortMonthAugust":"aou","DG.Formula.DateShortMonthSeptember":"sep","DG.Formula.DateShortMonthOctober":"oct","DG.Formula.DateShortMonthNovember":"nov","DG.Formula.DateShortMonthDecember":"dec","DG.Formula.DateLongDaySunday":"Dimanche","DG.Formula.DateLongDayMonday":"Lundi","DG.Formula.DateLongDayTuesday":"Mardi","DG.Formula.DateLongDayWednesday":"Mercredi","DG.Formula.DateLongDayThursday":"Jeudi","DG.Formula.DateLongDayFriday":"Vendredi","DG.Formula.DateLongDaySaturday":"Samedi","DG.Utilities.date.localDatePattern":"(?:(?:[0-3]?\\d-(?:jan|fev|mar|avr|mai|jun|jul|au|sep|oct|nov|dec)-\\d{2}(?:\\d{2})?)|(?:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec) \\d{1,2}( |,) *\\d{4}|(?:[01]?\\d/[0-3]?\\d/\\d{2}(?:\\d{2})?))","DG.Utilities.date.timePattern":"(?:[0-2]?\\d:[0-5]?\\d(?::[0-5]\\d(?:\\.\\d{3})?)? ?(?:[ap]m)?)","DG.Utilities.date.iso8601Pattern":"^\\d{4}-[01]\\d-[0-3]\\d(?:[T ][0-2]\\d:[0-5]\\d(?::[0-5]\\d(?:\\.\\d{3,6})?)?(?:Z|(?:[-+]?[01]\\d:[0-5]\\d)|(?: ?[-+][0-2]\\d{3}))?)?$","DG.Utilities.colorPattern":"(?:rgb\\((?:\\d{1,3},){2}\\d{1,3}\\))|(?:rgba\\((?:\\d{1,3},){3}[\\d\\.]*\\))|(?:#[\\da-f]{6})","DG.Formula.SyntaxErrorMiddle":"Erreur de syntaxe : '%@'","DG.Formula.SyntaxErrorEnd":"Expression incomplète","DG.Formula.SyntaxErrorInvalidOperator":"Opérateur non valide '%@'","DG.Formula.TypeError.name":"❌","DG.Formula.TypeError.message":"Type(s) non valide(s) pour '%@'","DG.Formula.TypeError.description":"Type(s) non valide(s) pour '%@'","DG.Formula.VarReferenceError.name":"❌","DG.Formula.VarReferenceError.message":"'%@' n'est pas reconnu","DG.Formula.VarReferenceError.description":"La variable '%@' n'est pas reconnue","DG.Formula.HierReferenceError.name":"❌","DG.Formula.HierReferenceError.message":"Référence non valide à l'attribut enfant '%@'","DG.Formula.HierReferenceError.description":"'%@' est un attribut enfant qui ne peut être référencé que dans une fonction d'agrégation","DG.Formula.FuncReferenceError.name":"❌","DG.Formula.FuncReferenceError.message":"'%@()' n'est pas reconnu","DG.Formula.FuncReferenceError.description":"La fonction '%@()' n'est pas reconnue","DG.Formula.FuncArgsError.name":"❌","DG.Formula.FuncArgsErrorSingle.message":"'%@()' requiert 1 argument","DG.Formula.FuncArgsErrorSingle.description":"La fonction '%@()' requiert 1 argument","DG.Formula.FuncArgsErrorPlural.message":"%@() requiert%@ arguments","DG.Formula.FuncArgsErrorPlural.description":"La fonction %@() requiert%@ arguments","DG.Formula.FuncArgsErrorRange.message":"'%@()' requiert %@-%@ arguments","DG.Formula.FuncArgsErrorRange.description":"La fonction '%@()' requiert des arguments %@-%@","DG.Formula.PendingRequest.name":"⌛","DG.Formula.PendingRequest.message":"Demande en cours ...","DG.Formula.PendingRequest.description":"Demande en cours ...","DG.Formula.FailedRequest.name":"❌","DG.Formula.FailedRequest.message":"Échec de la demande (%@)","DG.Formula.FailedRequest.description":"Échec de la demande (%@)","DG.Formula.PendingBoundaries.name":"⌛","DG.Formula.PendingBoundaries.message":"Limites en attente...","DG.Formula.PendingBoundaries.description":"Limites en attente...","DG.Formula.FailedBoundaries.name":"❌","DG.Formula.FailedBoundaries.message":"Échec lors du traitement des limites (%@)","DG.Formula.FailedBoundaries.description":"Échec lors du traitement des limites (%@)","DG.Formula.LookupDataSetError.message":"%@' : base de données non reconnue","DG.Formula.LookupDataSetError.description":"La base de données '%@' n'est pas reconnaissable","DG.Formula.LookupAttrError.message":"%@' non trouvé dans la base de données '%@'","DG.Formula.LookupAttrError.description":"Attribut '%@' non présent dans la base de données '%@'","DG.TableController.headerMenuItems.editAttribute":"Modifier les propriétés de l'attribut...","DG.TableController.headerMenuItems.editFormula":"Modifier la formule...","DG.TableController.headerMenuItems.randomizeAttribute":"Réinitialiser aléatoirement","DG.TableController.headerMenuItems.sortAscending":"Trier par ordre croissant (A→Z, 0→9)","DG.TableController.headerMenuItems.sortDescending":"Trier par ordre décroissant (9→0, Z→A)","DG.TableController.headerMenuItems.deleteAttribute":"Supprimer l'attribut","DG.TableController.newAttrDlg.defaultAttrName":"Nouvel_attribut","DG.TableController.newAttrDlg.attrNameHint":"Saisir un nom pour le nouvel attribut","DG.TableController.newAttrDlg.formulaHint":"Vous pouvez, si vous le souhaitez, saisir une formule pour calculer les valeurs de cet attribut","DG.TableController.newAttrDlg.applyTooltip":"Définir le nouvel attribut à l’aide d’un nom et, si souhaité, d’une formule","DG.TableController.newAttrDlg.mustEnterAttrNameMsg":"Veuillez saisir un nom pour le nouvel attribut","DG.TableController.newAttrDialog.AttributesCategory":"Attributs","DG.TableController.newAttrDialog.SpecialCategory":"Spécial","DG.TableController.newAttrDialog.GlobalsCategory":"Globaux","DG.TableController.newAttrDialog.ConstantsCategory":"Constantes","DG.TableController.newAttrDialog.FunctionsCategory":"Fonctions","DG.TableController.renameAttributeInvalidMsg":"Le nom de l’attribut ne peut pas être vide","DG.TableController.renameAttributeInvalidDesc":"Veuillez entrer un nom d'attribut valide","DG.TableController.renameAttributeDuplicateMsg":"Un attribut avec ce nom existe déjà","DG.TableController.renameAttributeDuplicateDesc":"Veuillez entrer un nom d'attribut unique","DG.TableController.deleteAttribute.confirmMessage":"Supprimer l'attribut '%@'?","DG.TableController.deleteAttribute.confirmDescription":"Cette action ne peut pas être annulée.","DG.TableController.deleteAttribute.okButtonTitle":"Supprimer l'attribut","DG.TableController.deleteAttribute.cancelButtonTitle":"Annuler","DG.TableController.deleteDataSet.confirmMessage":"Supprimer et détruire ce jeu de données: '%@'?","DG.TableController.deleteDataSet.confirmDescription":"Cette action ne peut pas être annulée.","DG.TableController.deleteDataSet.okButtonTitle":"Supprimer le jeu de données","DG.TableController.deleteDataSet.cancelButtonTitle":"Annuler","DG.TableController.attrEditor.unitHint":"Définir la quantité d’informations affichées pour la date","DG.TableController.attrEditor.descriptionHint":"Décrire l'attribut","DG.TableController.setScoreDlg.applyTooltip":"Définir la formule pour l'attribut '%@'","DG.TableController.setScoreDlg.formulaHint":"Saisir une formule pour calculer les valeurs de cet attribut","DG.TableController.newAttributeTooltip":"Ajouter un nouvel attribut à cette table","DG.TableController.attributeEditor.title":"Propriétés de l’attribut","DG.CaseTableDropTarget.dropMessage":"Déposer un attribut pour créer une nouvelle collection","DG.CaseTable.defaultAttrName":"nouvAttr","DG.CaseTable.indexColumnName":"index","DG.CaseTable.indexColumnTooltip":"Le numéro de ligne (caseIndex) dans la collection","DG.CaseTable.indexMenu.insertCase":"Insérer un cas","DG.CaseTable.indexMenu.insertCases":"Insérer les cas...","DG.CaseTable.indexMenu.deleteCase":"Supprimer le cas","DG.CaseTable.indexMenu.deleteCases":"Supprimer les cas","DG.CaseTable.attribute.type.none":"\u200b","DG.CaseTable.attribute.type.nominal":"catégorielle","DG.CaseTable.attribute.type.categorical":"catégorielle","DG.CaseTable.attribute.type.numeric":"numérique","DG.CaseTable.attribute.type.date":"date","DG.CaseTable.attribute.type.qualitative":"qualitative","DG.CaseTable.attribute.type.boundary":"limite","DG.CaseTable.attributeEditor.name":"Nom","DG.CaseTable.attributeEditor.description":"Description","DG.CaseTable.attributeEditor.type":"Type","DG.CaseTable.attributeEditor.unit":"Unité","DG.CaseTable.attributeEditor.precision":"Précision","DG.CaseTable.attributeEditor.editable":"Modifiable","DG.CaseTable.insertCasesDialog.title":"Insérer les cas","DG.CaseTable.insertCasesDialog.numCasesPrompt":"# cas à insérer :","DG.CaseTable.insertCasesDialog.beforeAfter.prompt":"Lieu :","DG.CaseTable.insertCasesDialog.beforeAfter.before":"Avant","DG.CaseTable.insertCasesDialog.beforeAfter.after":"Après","DG.CaseTable.insertCasesDialog.applyBtnTitle":"Insérer des cas","DG.CaseTable.insertCasesDialog.applyBtnTooltip":"Insérer le nombre de cas spécifié","DG.CaseTableController.allTables":"Tous les tableaux","DG.AttrFormView.attrNamePrompt":"Nom de l'attribut :","DG.AttrFormView.formulaPrompt":"Formule :","DG.AttrFormView.operandMenuTitle":"--- Insérer valeur ---","DG.AttrFormView.functionMenuTitle":"--- Insérer fonction ---","DG.AttrFormView.applyBtnTitle":"Appliquer","DG.AttrFormView.cancelBtnTitle":"Annuler","DG.AttrFormView.cancelBtnTooltip":"Fermer la boîte de dialogue sans apporter de modifications","DG.GuideConfigView.titlePrompt":"Titre du guide","DG.GuideConfigView.titleHint":"Nom de l'activité","DG.GuideConfigView.itemTitleHint":"Nom de la section","DG.GuideConfigView.itemURLHint":"URL de la section","DG.GuideConfigView.okBtnTitle":"Ok","DG.GuideConfigView.okBtnToolTip":"Accepter les éléments du menu Guide","DG.GuideConfigView.cancelBtnTitle":"Annuler","DG.GuideConfigView.cancelBtnTooltip":"Fermer la boîte de dialogue sans apporter de modifications","DG.GuideConfigView.httpWarning":"L'URL doit commencer par http:// ou https://","DG.DataDisplayModel.rescaleToData":"Ajuster à l’étendue des données","DG.DataDisplayModel.ShowConnectingLine":"Afficher lignes de connexion","DG.DataDisplayModel.HideConnectingLine":"Masquer les lignes de connexion","DG.AxisView.emptyGraphCue":"Cliquer ici, ou faire glisser un attribut ici.","DG.CellLinearAxisView.midPanelTooltip":"Glisser pour modifier l'échelle de l'axe","DG.CellLinearAxisView.lowerPanelTooltip":"Glisser pour modifier la limite inférieure de l'axe","DG.CellLinearAxisView.upperPanelTooltip":"Glisser pour modifier la limite supérieure de l'axe","DG.PlotModel.mixup":"Mélanger le graphique","DG.PlotModel.showCount":"Afficher le nombre","DG.PlotModel.hideCount":"Cacher le nombre","DG.ScatterPlotModel.sumSquares":"Somme des carrés","DG.ScatterPlotModel.slopeOnly":"Pente","DG.ScatterPlotModel.yearsLabel":"par année","DG.ScatterPlotModel.daysLabel":"par jour","DG.ScatterPlotModel.hoursLabel":"par heure","DG.ScatterPlotModel.minutesLabel":"par minute","DG.ScatterPlotModel.secondsLabel":"par seconde","DG.LegendView.attributeTooltip":"Cliquer pour modifier l'attribut de la légende","DG.NumberToggleView.showAll":"Tout afficher -","DG.NumberToggleView.hideAll":"Cacher tout -","DG.NumberToggleView.lastDash":"–","DG.NumberToggleView.lastUnchecked":"☐","DG.NumberToggleView.lastChecked":"☒","DG.NumberToggleView.lastLabel":"Dernier","DG.NumberToggleView.showAllTooltip":"Cliquer sur les étiquettes des cas\nparents pour afficher ou masquer leur contenu","DG.NumberToggleView.hideAllTooltip":"Cliquer pour cacher tous les cas\nCliquer sur les étiquettes des cas parents pour afficher ou masquer leur contenu","DG.NumberToggleView.enableLastModeTooltip":"Cliquer pour afficher uniquement le dernier cas parent","DG.NumberToggleView.disableLastModeTooltip":"Cliquer pour quitter le mode du dernier cas parent","DG.NumberToggleView.indexTooltip":"Cliquer pour afficher ou masquer","DG.PlottedAverageAdornment.meanValueTitle":"moyenne=%@","DG.PlottedAverageAdornment.medianValueTitle":"médiane=%@","DG.PlottedAverageAdornment.stDevValueTitle":"SD =%@","DG.PlottedAverageAdornment.iqrValueTitle":"IQR =%@","DG.PlottedAverageAdornment.boxPlotTitle":"Inférieur=%@\nQ1=%@\nmédiane=%@\nQ3=%@\nsupérieur=%@\nIQR=%@","DG.PlottedCountAdornment.title":"%@ %@, %@%","DG.DataDisplayMenu.attribute_x":"X: %@","DG.DataDisplayMenu.attribute_y":"a: %@","DG.DataDisplayMenu.attribute_y2":"a: %@","DG.DataDisplayMenu.attribute_legend":"Légende: %@","DG.DataDisplayMenu.remove":"Supprimer un attribut","DG.DataDisplayMenu.removeAttribute_x":"Supprimer X: %@","DG.DataDisplayMenu.removeAttribute_y":"Supprimer Y: %@","DG.DataDisplayMenu.removeAttribute_y2":"Supprimer Y: %@","DG.DataDisplayMenu.removeAttribute_legend":"Supprimer Légende: %@","DG.DataDisplayMenu.treatAsCategorical":"Traiter comme une variable catégorielle","DG.DataDisplayMenu.treatAsNumeric":"Traiter comme une variable numérique","DG.DataDisplayMenu.hide":"Cacher et afficher","DG.DataDisplayMenu.hideSelectedPlural":"Cacher les cas sélectionnés","DG.DataDisplayMenu.hideUnselectedPlural":"Cacher les cas non sélectionnés","DG.DataDisplayMenu.hideSelectedSing":"Cacher le cas sélectionné","DG.DataDisplayMenu.hideUnselectedSing":"Cacher le cas non sélectionné","DG.DataDisplayMenu.enableNumberToggle":"Afficher les options de visibilité des parents","DG.DataDisplayMenu.disableNumberToggle":"Masquer les options de visibilité des parents","DG.DataDisplayMenu.showAll":"Afficher tous les cas","DG.DataDisplayMenu.snapshot":"Prendre un instantanné","DG.GraphView.replaceAttribute":"Remplacer %@ par %@","DG.GraphView.addAttribute":"Ajouter un attribut %@","DG.GraphView.addToEmptyPlace":"Créer une axe avec %@","DG.GraphView.addToEmptyX":"Créer l'axe des X avec %@","DG.GraphView.dropInPlot":"Colorier les points en fonction des valeurs de %@","DG.GraphView.zoomTip":"Double-clic pour effectuer un zoom avant.\nShift-double-clic pour effectuer un zoom arrière.","DG.GraphView.rescale":"Ajuster à l’étendue des données","DG.AxisView.labelTooltip":"—Cliquer pour modifier l'attribut %@ de l'axe","DG.AxisView.vertical":"vertical","DG.AxisView.horizontal":"horizontal","DG.DataTip.connectingLine":"%@: %@\navec %@ points (%@) sur cette ligne","DG.MovableMonthYear":"%@, %@","DG.MovableMonthDayHour":"%@ %@ %@:00","DG.PlottedFormula.defaultNamePrompt":"Formule","DG.PlottedValue.namePrompt":"Valeur tracée","DG.PlottedValue.formulaPrompt":"Valeur =","DG.PlottedValue.formulaHint":"\u200b","DG.PlottedFunction.namePrompt":"Fonction tracée","DG.PlottedFunction.formulaPrompt":"f() =","DG.PlottedFunction.formulaHint":"Tapez une expression, par exemple x*x/30 - 50","DG.MapView.showGrid":"Afficher la grille","DG.MapView.hideGrid":"Masquer la grille","DG.MapView.showPoints":"Afficher les points","DG.MapView.hidePoints":"Masquer les points","DG.MapView.marqueeHint":"Outil Marquee - faire glisser les points sélectionnés dans la carte","DG.MapView.gridControlHint":"Changer la taille des rectangles de la grille","DG.Inspector.values":"Mesure","DG.Inspector.styles":"Format","DG.Inspector.pointSize":"Taille des points :","DG.Inspector.transparency":"Transparence :","DG.Inspector.color":"Couleur:","DG.Inspector.legendColor":"Légende couleur:","DG.Inspector.backgroundColor":"Couleur \nd’arrière-plan:","DG.Inspector.stroke":"Trait:","DG.Inspector.rescale.toolTip":"Adapter l’affichage à l’ensemble des données","DG.Inspector.mixUp.toolTip":"Mélanger tous les points","DG.Inspector.hideShow.toolTip":"Afficher toutes les cases ou masquer les cases sélectionnées/non sélectionnées","DG.Inspector.delete.toolTip":"Supprimer les cas sélectionnés ou non sélectionnés","DG.Inspector.sliderValues.toolTip":"Définir la direction de l'animation du curseur, la vitesse, …","DG.Inspector.webViewEditURL.toolTip":"Editer l'URL de la page web affichée","DG.Inspector.selection.selectAll":"Sélectionner tous les cas","DG.Inspector.selection.deleteSelectedCases":"Supprimer les cas sélectionnés","DG.Inspector.selection.deleteUnselectedCases":"Supprimer les cas non sélectionnés","DG.Inspector.deleteAll":"Supprimer tous les cas","DG.Inspector.deleteDataSet":"Supprimer et détruire la base de données","DG.Inspector.displayValues.toolTip":"Modifier ce qui est affiché avec les points","DG.Inspector.displayStyles.toolTip":"Modifier l’apparence de l’affichage","DG.Inspector.makeImage.toolTip":"Sauvegarder l'image en tant que PNG","DG.Inspector.displayShow":"Afficher …","DG.Inspector.colorPicker.more":"Plus","DG.Inspector.colorPicker.less":"Moins","DG.Inspector.graphTransparency":"Transparent","DG.Inspector.graphCount":"Nombre","DG.Inspector.graphPercent":"Pourcentage","DG.Inspector.graphRow":"Ligne","DG.Inspector.graphColumn":"Colonne","DG.Inspector.graphCell":"Cellule","DG.Inspector.graphConnectingLine":"Lignes de connexion","DG.Inspector.graphMovableLine":"Ligne mobile","DG.Inspector.graphInterceptLocked":"Ordonnée à l’origine verrouillée","DG.Inspector.graphPlottedFunction":"Fonction tracée","DG.Inspector.graphSquares":"Carrés des résidus","DG.Inspector.graphLSRL":"Droite de régression linéaire","DG.Inspector.graphMovableValue":"Valeur mobile","DG.Inspector.graphAdd":"Ajouter une valeur mobile","DG.Inspector.graphRemove":"Supprimer la valeur mobile","DG.Inspector.graphPlottedMean":"Moyenne","DG.Inspector.graphPlottedMedian":"Médiane","DG.Inspector.graphPlottedStDev":"Écart-type","DG.Inspector.graphPlottedIQR":"Étendue interquartile","DG.Inspector.graphPlottedBoxPlot":"Boîte à moustaches","DG.Inspector.graphPlottedValue":"Valeur tracée","DG.Inspector.attributes.toolTip":"Créer de nouveaux attributs. Exporter des données de cas.","DG.Inspector.resize.toolTip":"Ajuster la largeur des colonnes au contenu","DG.Inspector.newAttribute":"Nouvel attribut dans %@ ...","DG.Inspector.randomizeAllAttributes":"Relancer une nouvelle distribution aléatoire","DG.Inspector.exportCaseData":"Exporter des données de cas...","DG.Inspector.mapGrid":"Grille","DG.Inspector.mapPoints":"Points","DG.Inspector.mapLines":"Lignes de connexion","DG.GameController.continuityError":"Une fois que les colonnes du tableau ont été réorganisées, les nouvelles données ne peuvent plus être acceptées.","DG.GameView.loading":"Chargement","DG.GameView.loadError":"Si vous voyez ce texte, il se peut que le chargement de l'URL ci-dessus ait échoué. Vous pouvez vérifier le lien dans un autre onglet du navigateur ou signaler l'erreur à http://codap.concord.org/help.","DG.Component.closeComponent.confirmCloseMessage":"Êtes-vous sûr?","DG.Component.closeComponent.confirmCloseDescription":"\u200b","DG.Component.closeComponent.okButtonTitle":"Oui, fermer","DG.Component.closeComponent.cancelButtonTitle":"Annuler","DG.GameController.confirmCloseDescription":"Si vous fermer ceci, il se peut que vous ne puissiez plus ajouter de données.","DG.WebView.defaultTitle":"Page Web","DG.mainPage.exceptionMessage":"Une erreur susceptible d'affecter le comportement de ce programme s'est produite. Vous souhaiterez peut-être recharger cette page après avoir sauvegardé votre travail. (Erreur : %@)","DG.fileMenu.provider.examples.displayName":"Documents d’exemples","DG.ToolButtonData.pluginMenu.title":"Plugins","DG.ToolButtonData.pluginMenu.toolTip":"Ouvrir un composant de plugin","DG.Undo.graph.showMovablePoint":"Annuler l'affichage d'un point mobile","DG.Redo.graph.showMovablePoint":"Refaire l’affichage du point mobile","DG.Undo.graph.hideMovablePoint":"Annuler le masquage d'un point mobile","DG.Redo.graph.hideMovablePoint":"Refaire le masquage du point mobile","DG.Undo.graph.moveMovablePoint":"Annuler le déplacement d'un point mobile","DG.Redo.graph.moveMovablePoint":"Refaire le déplacement du point mobile","DG.DataDisplayMenu.copyAsImage":"Ouvrir dans l'outil de dessin","DG.DataDisplayMenu.exportImage":"Exporter image...","DG.DataDisplayMenu.imageOfTitle":"Image de %@","DG.Inspector.graphMovablePoint":"Point mobile","DG.AppController.caseTableMenu.openCaseTableToolTip":"Ouvrir la table des cas pour cette base de données","DG.AppController.caseTableMenu.newDataSetToolTip":"Créer une nouvelle base de données","DG.AppController.caseTableMenu.deleteDataSetToolTip":"Supprimer et détruire cette base de donnée","DG.Undo.graph.showAsBarChart":"Annuler la fusion des points en barres","DG.Redo.graph.showAsBarChart":"Refaire la conversion des points en barres","DG.Undo.graph.showAsDotChart":"Annuler la dispersion des barres en points","DG.Redo.graph.showAsDotChart":"Refaire la dispersion des barres en points","DG.CountAxisView.countLabel":"Nombre","DG.CountAxisView.countLabelDescription":"Nombre de cas représentés par cette barre","DG.CountAxisView.percentLabel":"Pourcentage","DG.CountAxisView.percentLabelDescription":"Pourcentage de cas représentés par cette barre","DG.BarChartModel.cellTipPlural":"%@ de %@ %@ (%@%) sont %@","DG.BarChartModel.cellTipSingular":"%@ de %@ %@ (%@%) est %@","DG.Inspector.configuration":"Configuration","DG.Inspector.displayConfiguration.toolTip":"Configurer l'affichage différemment","DG.Inspector.displayScale":"Redimensionner …","DG.Inspector.graphBarChart":"Fusionner les points en barres","DG.Locale.name.de":"Allemand","DG.Locale.name.en":"Anglais","DG.Locale.name.es":"Espagnol","DG.Locale.name.he":"Hébreu","DG.Locale.name.tr":"Turc","DG.Locale.name.zh":"Chinois traditionnel","DG.Undo.graph.swapCategories":"Annuler la réorganisation des catégories","DG.Redo.graph.swapCategories":"Rétablir la réorganisation des catégories","DG.TableController.collectionTitleText":"%@1 (%@2 cas)","DG.TableController.collectionTitleTextWithSetAside":"%@1 (%@2 cas, %@3 mis de côté)","DG.Inspector.setaside.setAsideSelectedCases":"Mettre de côté les cas sélectionnés","DG.Inspector.setaside.setAsideUnselectedCases":"Mettre de côté les cas non sélectionnés","DG.Inspector.setaside.restoreSetAsideCases":"Restaurer les %@ cas mis de côté","DG.DocumentController.caseCardTitle":"Fiche de cas","DG.DocumentController.toggleToCaseCard":"Basculer vers l’affichage en fiche de cas","DG.DocumentController.toggleToCaseTable":"Basculer vers l’affichage en tableau des cas","DG.CaseCard.indexString":"1 de %@ %@","DG.CaseCard.namePlusCaseCount":"%@ %@","DG.CaseCard.namePlusSelectionCount":"%@ sélectionné de %@ %@","DG.CaseCard.summaryValues":"%@ valeurs","DG.CaseCard.summaryRange":"%@–%@ %@","DG.CaseCard.navNextCase":"Sélectionner et montrer le cas suivant","DG.CaseCard.navPrevCase":"Sélectionner et montrer le cas précédent","DG.CaseCard.navFirstCase":"Sélectionner et montrer le premier cas","DG.CaseCard.navLastCase":"Sélectionner et montrer le dernier cas","DG.Undo.component.toggleTableToCard":"Annuler le passage du tableau de cas à la carte de cas","DG.Redo.component.toggleTableToCard":"Refaire le changement de vue : de la table des cas à la fiche de cas","DG.Undo.component.toggleCardToTable":"Annuler le passage de la carte de cas au tableau de cas","DG.Redo.component.toggleCardToTable":"Refaire le changement de vue : de la fiche de cas à la table des cas","DG.Undo.graph.addBackgroundImage":"Annuler l’ajout de l’image d’arrière-plan du graphique","DG.Redo.graph.addBackgroundImage":"Refaire l’ajout d’une image d’arrière-plan au graphique","DG.Undo.graph.removeBackgroundImage":"Annuler la suppression de l’image d’arrière-plan du graphique","DG.Redo.graph.removeBackgroundImage":"Refaire la suppression de l’image d’arrière-plan du graphique","DG.Undo.graph.lockBackgroundImage":"Annuler le verrouillage de l’image d’arrière-plan sur les axes","DG.Redo.graph.lockBackgroundImage":"Refaire le verrouillage de l’image d’arrière-plan sur les axes","DG.Undo.graph.unlockBackgroundImage":"Annuler le déverrouillage de l’image d’arrière-plan par rapport aux axes","DG.Redo.graph.unlockBackgroundImage":"Refaire le déverrouillage de l’image d’arrière-plan des axes","DG.Undo.enableMeasuresForSelection":"Annuler l'affichage des mesures pour la sélection","DG.Redo.enableMeasuresForSelection":"Refaire l’affichage des mesures pour la sélection","DG.Undo.disableMeasuresForSelection":"Annuler le déplacement sur la carte","DG.Redo.disableMeasuresForSelection":"Refaire le masquage des mesures pour la sélection","DG.DataDisplayMenu.enableMeasuresForSelection":"Afficher les mesures à sélectionner","DG.DataDisplayMenu.disableMeasuresForSelection":"Masquer les mesures pour la sélection","DG.DataDisplayMenu.addBackgroundImage":"Ajouter une image d’arrière-plan","DG.DataDisplayMenu.lockImageToAxes":"Verrouiller l’image d’arrière-plan sur les axes","DG.DataDisplayMenu.unlockImageFromAxes":"Déverrouiller l’image d’arrière-plan des axes","DG.DataDisplayMenu.removeBackgroundImage":"Supprimer l’arrière-plan","DG.main.page.title":"%@1 - %@2","DG.TableController.headerMenuItems.deleteFormula":"Supprimer la formule (en conservant les valeurs)","DG.TableController.headerMenuItems.recoverFormula":"Récupérer la Formule Supprimée","DG.Inspector.displayLayers.toolTip":"Modifier l'apparence des couches de la carte","DG.Inspector.layers":"Couches","DG.Undo.graph.repositionEquation":"Annuler le repositionnement de l'équation","DG.Redo.graph.repositionEquation":"Refaire le repositionnement de l'équation","DG.TableController.attrEditor.precisionNumericHint":"Nombres de décimales","DG.TableController.attrEditor.precisionDateHint":"Définir la quantité d’informations affichées pour la date","DG.TableController.attrEditor.typeHint":"Le nom de l’attribut apparaît dans la table des cas, la fiche de cas et sur les axes des graphiques","DG.TableController.attrEditor.nameHint":"Le nom de l’attribut apparaît dans la table des cas, la fiche de cas et sur les axes des graphiques","DG.TableController.attrEditor.editableHint":"Si l'attribut n'est pas modifiable, ses valeurs et/ou sa formule ne peuvent pas être changées","DG.CaseTable.attributeEditor.datePrecisionOptions":"année mois jour heure minute seconde milliseconde","DG.AttributeFormat.DatePrecision.year":"YYYY","DG.AttributeFormat.DatePrecision.month":"MMM YYYY","DG.AttributeFormat.DatePrecision.day":"MMM D, YYYY","DG.AttributeFormat.DatePrecision.hour":"MMM D, YYYY HH:00","DG.AttributeFormat.DatePrecision.minute":"MMM D, YYYY HH:mm","DG.AttributeFormat.DatePrecision.second":"MMM D, YYYY HH:mm:ss","DG.CaseCard.attrHintPlain":"%@","DG.CaseCard.attrHintUnitsOnly":"%@1 in %@2","DG.CaseCard.attrHintDescription":"%@1: %@2","DG.CaseCard.attrHintFormula":"%@1 = %@2","DG.AppController.optionMenuItems.help-forum":"Forum d'aide...","DG.AppController.showHelpForumTitle":"Forum d'aide","DG.Locale.name.el":"Grec","DG.BarChartModel.cellTipNoLegendSingular":"%@ de %@ (%@%) est %@","DG.BarChartModel.cellTipNoLegendPlural":"%@ de %@ (%@%) sont %@","DG.DataDisplayMenu.removeAttribute_top":"Supprimer la disposition côte à côte en %@","DG.DataDisplayMenu.removeAttribute_right":"Supprimer la disposition verticale en %@","DG.GraphView.layoutPlotsSideBySide":"Disposition côte à côte par%@","DG.GraphView.layoutPlotsVertically":"Disposition verticale par%@","DG.Undo.graph.makeStrokeSameAsFill":"Annuler l’association du contour avec le remplissage","DG.Redo.graph.makeStrokeSameAsFill":"Refaire l’association du contour et du remplissage","DG.Undo.graph.makeStrokeIndependent":"Annuler l’indépendance du contour par rapport au remplissage","DG.Redo.graph.makeStrokeIndependent":"Refaire la dissociation du contour et du remplissage","DG.Inspector.strokeSameAsFill":"Trait de la même couleur que le remplissage","DG.Formula.DateShortDaySunday":"dim","DG.Formula.DateShortDayMonday":"lun","DG.Formula.DateShortDayTuesday":"ma","DG.Formula.DateShortDayWednesday":"me","DG.Formula.DateShortDayThursday":"jeu","DG.Formula.DateShortDayFriday":"ven","DG.Formula.DateShortDaySaturday":"sam","DG.AttributeFormat.DatePrecision.millisecond":"MMM D, YYYY HH:mm:ss.SSS","DG.CellAxis.other":"Autre","DG.PlottedAverageAdornment.madValueTitle":"MAD =%@","DG.Inspector.graphPlottedMeanAbsDev":"Écart absolu moyen","DG.Undo.graph.showPlottedBoxPlot":"Annuler l’affichage de la boîte à moustaches","DG.Redo.graph.hidePlottedBoxPlot":"Refaire le masquage de la boîte à moustaches","DG.Undo.graph.hidePlottedBoxPlot":"Annuler le masquage de la boîte à moustaches","DG.Redo.graph.showPlottedBoxPlot":"Refaire l'affichage du diagramme en barres","DG.Undo.graph.showOutliers":"Annuler l'affichage des valeurs aberrantes","DG.Redo.graph.hideOutliers":"Refaire le masquage des valeurs aberrantes","DG.Undo.graph.hideOutliers":"Annuler le masquage des valeurs aberrantes","DG.Redo.graph.showOutliers":"Refaire l'affichage des valeurs aberrantes","DG.Inspector.graphBoxPlotShowOutliers":"Afficher les valeurs aberrantes","DG.Locale.name.nb":"Bokmål","DG.Locale.name.nn":"Nynorsk","DG.CaseCard.newCaseToolTip":"Ajouter un cas vide à cette collection","DG.TableController.headerMenuItems.renameAttribute":"Renommer","DG.Undo.graph.fuseDotsToRectangles":"Annuler la fusion des points en rectangles","DG.Redo.graph.fuseDotsToRectangles":"Refaire la fusion des points en rectangles","DG.Undo.graph.dissolveRectanglesToDots":"Annuler la conversion des rectangles en points","DG.Redo.graph.dissolveRectanglesToDots":"Refaire la dissolution des rectangles en points","DG.Undo.graph.changeBreakdownType":"Annuler le changement du type d'échelle","DG.Redo.graph.changeBreakdownType":"Refaire le changement du type d'échelle","DG.Undo.graph.showAsBinnedPlot":"Annuler le réglage du nombre d’erreurs standard","DG.Redo.graph.showAsBinnedPlot":"Refaire le regroupement des points en classes","DG.Undo.graph.showAsDotPlot":"Annuler la dissociation des points de leurs intervalles","DG.Redo.graph.showAsDotPlot":"Refaire le regroupement des points des intervalles","DG.Undo.graph.dragBinBoundary":"Annuler le déplacement de la frontière d’un intervalle","DG.Redo.graph.dragBinBoundary":"Refaire le déplacement de la limite d’intervalle","DG.Undo.graph.changeBinWidth":"Annuler le changement de largeur des intervalles","DG.Redo.graph.changeBinWidth":"Refaire le réglage de la largeur des intervalles","DG.Undo.graph.changeBinAlignment":"Annuler le changement d’alignement des intervalles","DG.Redo.graph.changeBinAlignment":"Refaire le réglage de l’alignement des intervalles","DG.BinnedPlotModel.dragBinTip":"Faire glisser pour modifier la largeur des classes","DG.HistogramView.barTipPlural":"%@ de %@ %@ (%@%) sont ≥ %@ et < %@","DG.HistogramView.barTipSingular":"%@ de %@ %@ (%@%) est ≥ %@ et < %@","DG.HistogramView.barTipNoLegendSingular":"%@ de %@ (%@%) est ≥ %@ et < %@","DG.HistogramView.barTipNoLegendPlural":"%@ de %@ (%@%) sont ≥ %@ et < %@","DG.Inspector.graphGroupIntoBins":"Regroupement en classes","DG.Inspector.graphBinWidth":"Largeur de l’intervalle","DG.Inspector.graphAlignment":"Alignement","DG.CaseTable.dividerView.expandAllTooltip":"Élargir tous les groupes","DG.CaseTable.dividerView.expandGroupTooltip":"Élargir le groupe","DG.CaseTable.dividerView.collapseAllTooltip":"Réduire tous les groupes","DG.CaseTable.dividerView.collapseGroupTooltip":"Réduire le groupe","DG.BinnedPlotModel.binLabelTip":"Les valeurs dans cette classe sont ≥ %@ et < %@","DG.Component.closeComponent.toolTip":"Fermer ce composant","DG.Component.minimizeComponent.toolTip":"Réduire ou développer ce composant","DG.Locale.name.ja":"Japonais","DG.CaseCard.attrHintDescriptionAndFormula":"%@1: %@2\n%@1 = %@3","DG.Locale.name.zh-Hans":"Chinois simplifié","DG.PlottedCount.withoutSelection":"%@","DG.PlottedCount.withSelection":"%@ sélectionné","DG.PlottedPercent.withoutSelection":"%@%","DG.PlottedPercent.withSelection":"%@% sélectionné","DG.PlottedCountPercent.withoutSelection":"%@ (%@%)","DG.PlottedCountPercent.withSelection":"%@ de %@ (%@%) sélectionné","DG.Undo.caseTable.resizeColumn":"Annuler l'adaptation de la largeur au contenu","DG.Redo.caseTable.resizeColumn":"Refaire l'adaptation de la largeur au contenu","DG.TableController.headerMenuItems.resizeColumn":"Adapter la largeur au contenu","DG.SelectedInfoView.infoPlural":"Afficher les mesures pour %@ cas sélectionnés","DG.SelectedInfoView.infoSing":"Affichage des mesures pour %@ cas sélectionné","DG.Inspector.copyCaseDataToClipboard":"Copier dans le presse-papiers...","DG.Inspector.caseTable.exportCaseDialog.copyFrom":"Copier les données du cas depuis:","DG.Inspector.caseTable.exportCaseDialog.copy":"Copier","DG.Inspector.caseTable.exportCaseDialog.copyTooltip":"Copier les données dans le presse-papiers","DG.Inspector.caseTable.exportCaseDialog.copiedData":"Copie de %@ dans le presse-papiers","DG.Undo.caseTable.hideAttribute":"Annuler le masquage d’un attribut","DG.Redo.caseTable.hideAttribute":"Refaire le masquage de l’attribut","DG.Undo.caseTable.showAllHiddenAttributes":"Annuler l'affichage de tous les attributs cachés","DG.Redo.caseTable.showAllHiddenAttributes":"Refaire l'affichage de tous les attributs cachés","DG.TableController.headerMenuItems.hideAttribute":"Cacher l'attribut","DG.Inspector.attributes.showAllHiddenAttributesSing":"Afficher%@ l’attribut masqué","DG.Inspector.attributes.showAllHiddenAttributesPlural":"Afficher %@ les attributs cachés","DG.Inspector.attributes.showAllHiddenAttributesDisabled":"Afficher les attributs cachés","DG.Inspector.getCaseDataFromClipboard":"Importer des données de cas à partir du presse-papiers...","DG.CaseCard.addCaseButton":"Ajouter un cas","DG.Undo.DataContext.join":"Annuler la jonction de %@ avec %@","DG.Redo.DataContext.join":"Refaire la fusion de %@ à %@","DG.Collection.joinTip":"Joindre %@ dans %@ à %@ dans %@ en faisant correspondre %@ avec %@","DG.Inspector.graphPlotPoints":"Points","DG.Inspector.graphBarForEachPoint":"Barre pour chaque point","DG.Undo.graph.changeBarChartFunction":"Annuler la modification de la formule de l’histogramme","DG.Redo.graph.changeBarChartFunction":"Refaire la modification de la formule de l’histogramme","DG.Undo.graph.showAsLinePlot":"Annuler la création d’une barre pour chaque point","DG.Redo.graph.showAsLinePlot":"Refaire l’affichage d’une barre pour chaque point","DG.Undo.graph.showAsStandardBarChart":"Annuler l’utilisation du nombre ou du pourcentage comme échelle de l’histogramme","DG.Redo.graph.showAsStandardBarChart":"Refaire le réglage de l’échelle en effectifs ou en pourcentages","DG.Undo.graph.showAsComputedBarChart":"Annuler le calcul de la longueur des barres avec une formule","DG.Redo.graph.showAsComputedBarChart":"Refaire le calcul de la longueur des barres avec une formule","DG.FormulaAxisView.labelDescription":"Formule définissant la longueur des barres. Cliquez pour modifier.","DG.ComputedBarChartModel.cellTip":"Pour le groupe %@, la valeur est %@","DG.BarChartFunction.namePrompt":"Diagramme en barres","DG.BarChartFunction.formulaPrompt":"Longueur de la barre =","DG.BarChartFunction.formulaHint":"Entrer une formule pour calculer la longueur de la barre","DG.BarChartFunction.emptyExpressionAxisPrompt":"Cliquer ici pour ajouter une formule","DG.Inspector.graphFormula":"Formule","DG.Undo.displayOnlySelected":"Annuler l'affichage des seuls cas sélectionnés","DG.Redo.displayOnlySelected":"Refaire l’affichage des seuls cas sélectionnés","DG.Undo.webView.show":"Annuler l’ajout du composant WebView","DG.Redo.webView.show":"Refaire l'ajout du composant webView","DG.Undo.imageComponent.show":"Annuler l’ajout d’un composant image","DG.Redo.imageComponent.show":"Refaire l'ajout du composant image","DG.DataDisplayMenu.displayOnlySelected":"Afficher uniquement les cas sélectionnés","DG.DataDisplayMenu.displayingOnlySelected":"Affichage des cas sélectionnés uniquement","DG.PlotBackgroundView.msg0":"Ce graphique est configuré pour afficher","DG.PlotBackgroundView.msg1":"Seulement les cas sélectionnés.","DG.PlotBackgroundView.msg2":"Aucun cas n’est sélectionné","DG.PlotBackgroundView.msg3":"donc rien n'est affiché.","DG.PlotBackgroundView.msg4":"Vous pouvez sélectionner des cas dans","DG.PlotBackgroundView.msg5":"Tableau de cas ou un autre graphique.","DG.ImageComponent.defaultTitle":"Image","DG.TableController.datasetMetadata.title":"Informations sur le jeu de données","DG.CaseTable.datasetMetadata.url":"Source","DG.CaseTable.datasetMetadata.creationDate":"Importer date","DG.TableController.datasetMetadata.descriptionHint":"Décrire le jeu de données","DG.Inspector.datasetInfo.toolTip":"Afficher les informations de la base de données","DG.CaseTable.indexMenu.moveEntryRow":"Déplacer la ligne de saisie des données ici","DG.CaseCard.deselect":"Désélectionner tous les cas","DG.CaseCard.noDeselect":"Aucun cas n'est sélectionné","DG.CaseTable.indexProto.tooltip":"Faire glisser pour placer la ligne de saisie de données dans ce tableau","DG.AttributeFormat.DatePrecisionShort.year":"YYYY","DG.AttributeFormat.DatePrecisionShort.month":"M/YY","DG.AttributeFormat.DatePrecisionShort.day":"M/D/YY","DG.AttributeFormat.DatePrecisionShort.hour":"M/D/YY HH:00","DG.AttributeFormat.DatePrecisionShort.minute":"M/D/YY HH:mm","DG.AttributeFormat.DatePrecisionShort.second":"M/D/YY HH:mm:ss","DG.AttributeFormat.DatePrecisionShort.millisecond":"M/D/YY HH:mm:ss.SSS","DG.Formula.FuncCategoryLogic":"Fonctions logiques","DG.Undo.graph.showMeasureLabels":"Annuler l'affichage des étiquettes de mesure","DG.Redo.graph.showMeasureLabels":"Refaire l'affichage des étiquettes de mesure","DG.Undo.graph.hideMeasureLabels":"Annuler le masquage des étiquettes de mesure","DG.Redo.graph.hideMeasureLabels":"Refaire le masquage des étiquettes de mesure","DG.Inspector.showLabels":"Afficher les libellés des mesures","DG.Undo.caseTable.resizeOneColumn":"Annuler le redimensionnement d’une colonne","DG.Redo.caseTable.resizeOneColumn":"Refaire le redimensionnement de la colonne","DG.CaseTable.attribute.type.checkbox":"Case à cocher","DG.AppController.caseTableMenu.clipboardDataset":"-- Nouveau depuis le presse-papiers --","DG.AppController.caseTableMenu.clipboardDatasetToolTip":"Coller la base de données du presse-papiers","DG.AppController.optionMenuItems.toPrivacyPage":"Page de confidentialité...","DG.plugin.Importer.title":"Importer CSV vers CODAP","DG.plugin.Importer.enter-url":"Entrer l'url: ","DG.plugin.Importer.or":"ou","DG.plugin.Importer.downsample-section":"Options de sous-échantillonnage...","DG.plugin.Importer.downsample-random-p1":"Sélectionner aléatoirement","DG.plugin.Importer.downsample-random-p2":"lignes","DG.plugin.Importer.downsample-every-nth-p1":"Tout sélectionner","DG.plugin.Importer.downsample-every-nth-p2":"Xième ligne","DG.plugin.Importer.downsample-import-all":"Importer toutes les rangées","DG.plugin.Importer.target-options-title":"Options cibles...","DG.plugin.Importer.target-options-replace":"Remplacer le jeu de données existant par celui-ci","DG.plugin.Importer.target-options-append":"Fusionner ce jeu de données avec celui existant","DG.plugin.Importer.target-options-create-new":"Créer un nouveau jeu de données","DG.plugin.Importer.button-cancel":"Annuler","DG.plugin.Importer.button-submit":"OK","DG.plugin.Importer.button-dismiss":"Rejeter","DG.plugin.Importer.load-error":"Une erreur s'est produite lors du chargement de cette ressource : « %@ » raison : »%@ »","DG.plugin.Importer.no-table-error":"Il n'a pas été possible de trouver des données tabulaires dans un format pouvant être importé dans CODAP","DG.plugin.Importer.duplicate-dataset-msg":'Un jeu de données similaire existe déjà, il se nomme "%@".',"DG.plugin.Importer.upload-time-msg":"Importé%@","DG.plugin.Importer.large-file-msg":"Le fichier importé « %@ » contient %@ lignes. Avec plus de %@ lignes, les performances de CODAP peuvent être lentes. Vous pouvez travailler avec un échantillon des données, au moins dans un premier temps, et le remplacer par l'ensemble des données plus tard.","DG.plugin.Importer.error-codap-connection":"Erreur lors de l’envoi de données à CODAP","DG.plugin.Importer.error-upload":"Impossible d’importer ce fichier  -- %@","DG.plugin.Importer.import-message":"Préparation de l'importation de %@ lignes dans « %@ » à partir d'un tableau avec %@ attributs : %@%@","DG.Undo.component.componentTitleChange":"Annuler la modification du titre du composant","DG.Redo.component.componentTitleChange":"Refaire la modification du titre du composant","DG.TableController.collectionTitleText-nonempty":"%@1 (%@2 cas non vides)","DG.TableController.collectionTitleTextWithSetAside-nonempty":"%@1 (%@2 cas non vides, %@3 mis de côté)","DG.CaseTable.closedGroup.summary":"%@1 %@2","DG.CaseTable.closedGroup.summary-nonempty":"%@1 non vide %@2","DG.DataDisplayMenu.exportPngImage":"Exporter une image au format PNG...","DG.DataDisplayMenu.exportSvgImage":"Exporter une image au format SVG...","DG.plugin.StoryBuilder.pluginName":"Story builder","DG.plugin.StoryBuilder.description":"Créer un récit de votre exploration.","DG.plugin.StoryBuilder.controlArea.discardAlt":"Annuler les changements","DG.plugin.StoryBuilder.controlArea.discardTooltip":"Annuler les modifications jusqu’à ce moment","DG.plugin.StoryBuilder.controlArea.saveAlt":"Enregistrer","DG.plugin.StoryBuilder.controlArea.saveTooltip":"Sauvegarder ce moment","DG.plugin.StoryBuilder.controlArea.newAlt":"Créer un nouveau moment","DG.plugin.StoryBuilder.controlArea.newTooltip":"Ajouter un nouveau moment à droite","DG.plugin.StoryBuilder.dialog.optOutCheckbox":"Ne plus demander (toujours sauvegarder)","DG.plugin.StoryBuilder.emptyMoment.createAlt":"Créer un nouveau moment","DG.plugin.StoryBuilder.emptyMoment.createTitle":"Cliquer pour créer un nouveau moment","DG.plugin.StoryBuilder.buttons.helpAlt":"Obtenir de l'aide","DG.plugin.StoryBuilder.buttons.helpTitle":"Obtenir de l'aide sur l'utilisation de Story Builder","DG.plugin.StoryBuilder.buttons.autoSaveTitleAuto":"Les modifications apportées aux moments sont actuellement enregistrées automatiquement. Cliquez ici pour être invité à enregistrer ou ignorer les changements.","DG.plugin.StoryBuilder.buttons.autoSaveTitleManual":"Actuellement, une confirmation est demandée pour enregistrer ou ignorer les modifications des moments. Cliquez ici pour enregistrer automatiquement les changements sans confirmation.","DG.plugin.StoryBuilder.momentComponent.deleteAlt":"Supprimer ce moment","DG.plugin.StoryBuilder.momentComponent.deleteTitle":"Supprimer ce moment","DG.plugin.StoryBuilder.momentTextboxContent":"Qu’avez-vous fait ? Pourquoi l’avez-vous fait ?","DG.plugin.StoryBuilder.momentTextboxFirstContent":"Ceci est le début de ton histoire de données.","DG.plugin.StoryBuilder.momentManager.firstTitle":"Début ...","DG.plugin.StoryBuilder.momentManager.nextTitle":"Titre du moment","DG.plugin.StoryBuilder.storyArea.dialog.cancel":"Annuler","DG.plugin.StoryBuilder.storyArea.dialog.discard":"Annuler","DG.plugin.StoryBuilder.storyArea.dialog.save":"Sauvegarder","DG.plugin.StoryBuilder.storyArea.qClickAnotherMomentPrompt":"Sauvegarder ou annuler les changements?","DG.plugin.StoryBuilder.storyArea.qClickAnotherMomentExplanation":"Vous avez apporté des changements à Moment %@. Voulez-vous sauvegarder ou annuler ces modifications?","DG.plugin.StoryBuilder.storyArea.qDupNotLastMomentPrompt":"Save changes before creating Moment %@?","DG.plugin.StoryBuilder.storyArea.qDupNotLastMomentExplanation":"Vous avez apporté des changements à Moment %@. Voulez-vous sauvegarder ces modifications pour la paire Moments %@ et %@ ou uniquement pour le nouveau Moment %@?","DG.plugin.StoryBuilder.storyArea.qDupNotLastMomentTwoMoments":"Moments %@ et %@","DG.plugin.StoryBuilder.storyArea.qDupNotLastMomentOneMoment":"Uniquement moment %@","DG.plugin.StoryBuilder.storyArea.qRevertPrompt":"Annuler les changements?","DG.plugin.StoryBuilder.storyArea.qRevertExplanation":"Souhaitez-vous ignorer les modifications apportées au moment %@ (et revenir à son état initial) ?","DG.plugin.StoryBuilder.storyArea.qClickLockPrompt":"Sauvegarder ou annuler les changements?","DG.plugin.StoryBuilder.storyArea.qClickLockExplanation":"Vous avez apporté des changements à Moment %@. Voulez-vous sauvegarder ou annuler ces modifications?","DG.plugin.Scrambler.name":"Mélangeur","DG.plugin.Scrambler.description":"Tester des hypothèses en faisant varier un attribut de manière aléatoire.","DG.plugin.Scrambler.language":"Anglais","DG.plugin.Scrambler.static.scramblerTitle":"Mélangeur","DG.plugin.Scrambler.static.cantScrambleStripe":"Réparer pour continuer.","DG.plugin.Scrambler.static.howManyLabel":"combien?","DG.plugin.Scrambler.static.scrambledDataButtonName":"Afficher les données mélangées","DG.plugin.Scrambler.sScramble":"Mélanger","DG.plugin.Scrambler.sNoAttribute":"Aucun attribut 😕","DG.plugin.Scrambler.sIterationAttName":"Lot","DG.plugin.Scrambler.sIterationAttDescription":'Quel "lot" de données. Ce nombre augmente à chaque mélange.',"DG.plugin.Scrambler.sScrambledAttName":"Attribut mélangé","DG.plugin.Scrambler.sScrambledAttDescription":"Quel attribut a été mélangé.","DG.plugin.Scrambler.sNoDataset":"Trouvez un jeu de données et faites glisser ici l’attribut que vous souhaitez mélanger !","DG.plugin.Scrambler.sNoScrambleAttribute":"Quel attribut souhaitez-vous mélanger ? Faites-le glisser ici.","DG.plugin.Scrambler.shShowScrambledButtonHelpText":"Afficher un jeu de données mélangé","DG.plugin.Scrambler.sfScrambledAttribute":"<span>Mélanger <code>%@1</code></span>","DG.plugin.Scrambler.sfOKtoScramble":"<span>OK pour mélanger <code>%@1</code> dans l'ensemble de données <code>%@2</code></span>","DG.plugin.Scrambler.sfNoMeasure":"<span>Votre jeu de données, <code>%@1</code>, a besoin d’une mesure, probablement un attribut contenant une formule. Faites glisser cet attribut vers la gauche afin d’avoir quelque chose à collecter!</span>","DG.plugin.Scrambler.sfFormulaProblem":"<span>Impossible de mélanger <code>%@1</code> car il contient une formule. Faites glisser un autre attribut de la dernière collection (%@2), comme <code>%@3</code>.</span>","DG.plugin.Scrambler.sfNotALeafProblem":"<span>Impossible de mélanger <code>%@1</code> car il ne fait pas partie de la dernière collection (<code>%@2</code>). Déposez ici un attribut provenant de <code>%@2</code>, comme <code>%@3</code>.</span>","DG.plugin.Scrambler.sOr":"ou","DG.plugin.Scrambler.sScrambledDatasetPrefix":"mélangé_","DG.plugin.Scrambler.sMeasureDatasetPrefix":"mesures_de_","DG.plugin.Sampler.title":"Sampler","DG.plugin.Sampler.description":"Créer un jeu de données aléatoire à partir de zéro ou à partir d’un jeu de données existant.","DG.plugin.Sampler.tab.sampler":"Sampler","DG.plugin.Sampler.tab.options":"Options","DG.plugin.Sampler.tab.about":"À propos de","DG.plugin.Sampler.top-bar.run":"DÉPART","DG.plugin.Sampler.top-bar.stop":"Stop","DG.plugin.Sampler.top-bar.pause":"Pause","DG.plugin.Sampler.top-bar.medium-speed":"À propos de","DG.plugin.Sampler.draw-settings.select-items-p1":"Sélectionner","DG.plugin.Sampler.draw-settings.select-items-p2":"éléments","DG.plugin.Sampler.draw-settings.collect-samples-p1":"Collecter","DG.plugin.Sampler.draw-settings.collect-samples-p2":"échantillons","DG.plugin.Sampler.model-controls.add-variable-title":"Ajouter l'élément suivant au mélangeur","DG.plugin.Sampler.model-controls.remove-variable-title":"Retirer le dernier élément du mélangeur","DG.plugin.Sampler.model-controls.add-series-title":"Spécifier une série d'étiquettes pour les éléments","DG.plugin.Sampler.model-controls.select-collection-loading":"Chargement des collections...","DG.plugin.Sampler.reset-title":"Supprimer toutes les données et les attributs supplémentaires au niveau de l'élément","DG.plugin.Sampler.reset-text":"SUPPRIMER LES DONNEES","DG.plugin.Sampler.device-selection.mixer":"Mélangeur","DG.plugin.Sampler.device-selection.spinner":"Roue","DG.plugin.Sampler.device-selection.collector":"Collecteur","DG.plugin.Sampler.spinner-cover-alt":"Couche transparente","DG.plugin.sampler.speed.slow":"Lent","DG.plugin.sampler.speed.medium":"Moyen","DG.plugin.sampler.speed.fast":"Rapide","DG.plugin.sampler.speed.Fastest":"Le plus rapide","DG.plugin.sampler.collector.noDatasets":"Aucun jeu de données","DG.plugin.Sampler.selection-options.select-cases":"Sélectionner les cas","DG.plugin.Sampler.selection-options.with-replacement":"Avec remise","DG.plugin.Sampler.selection-options.without-replacement":"Sans remise","DG.plugin.Sampler.hide-options.hide":"Cacher le modèle","DG.plugin.Sampler.password-options.lock-title":"Verrouiller les paramètres avec un mot de passe:","DG.plugin.Sampler.password-options.lock":"Verrouiller","DG.plugin.Sampler.password-options.unlock-title":"Déverrouiller les paramètres à l'aide d'un mot de passe :","DG.plugin.Sampler.password-options.unlock":"Déverrouiller","DG.plugin.Sampler.password-options.password-failed":"Le mot de passe est incorrect.","DG.plugin.Sampler.options.reload":"Recharger les paramètres par défaut","DG.plugin.Sampler.about.paragraph1":"Le module Sampler (échantillonneur) de CODAP permet de sélectionner aléatoirement des éléments placés dans un mélangeur, de choisir en fonction des secteurs d’une roue tournante ou de prélever des cas dans un ensemble de données.","DG.plugin.Sampler.about.item1":"<b>Sélectionner &lt;n&gt ; éléments</b> détermine la taille de l'échantillon,","DG.plugin.Sampler.about.item2":"<b>Collectionner &lt;n&gt ; éléments</b> contrôle le nombre d'échantillons à répéter dans une expérience donnée.","DG.plugin.Sampler.about.paragraph2.1":"La vitesse d’échantillonnage peut être ajustée, tout comme le choix d’échantillonner avec ou sans remise (dans l’onglet Options). Les données générées par le module Sampler apparaissent dans un tableau hiérarchique. Le niveau supérieur représente l’expérience (c’est-à-dire une exécution complète de la simulation) et permet de calculer des statistiques sur l’ensemble de l’expérience. Le niveau intermédiaire contient les informations relatives à chaque échantillon et permet de calculer des statistiques pour chaque échantillon. Enfin, le niveau des éléments affiche chaque valeur individuelle tirée par le module Sampler. ","DG.plugin.Sampler.about.paragraph2.2":" explique les bases de l'échantillonneur.","DG.plugin.Sampler.about.tutorial-link-text":"Tutoriel vidéo","DG.plugin.Sampler.about.paragraph3.1":"Le Sampler dans CODAP a été inspiré par le Sampler dans","DG.plugin.Sampler.about.paragraph3.2":". A été développé par ","DG.plugin.Sampler.about.paragraph3.3":" une partie de ","DG.plugin.Sampler.about.paragraph3.4":'avec le soutien de la  National Science Foundation sous Grant No. DUE <span style="color:red;">1625713</span> décerné à North Carolina State University.',"DG.plugin.Sampler.about.paragraph3.6":" Les opinions, résultats et conclusions ou recommandations contenus dans ce document sont ceux des chercheurs principaux et ne reflètent pas nécessairement les opinions de la National Science Foundation.","DG.plugin.Sampler.about.tinkerPlots-link-text":"TinkerPlots","DG.plugin.Sampler.about.concord-link-text":"Concord Consortium","DG.plugin.Sampler.about.esteem-link-text":"Projet ESTEEM","DG.plugin.Sampler.about.esteem-logo-text":"Logo Esteem","DG.plugin.Sampler.sample-list.parse-error":"Désolé, cette saisie n’a pas pu être interprétée. Voici quelques expressions de liste ou d’intervalle valides :  'a,b,b,b', 'chat,chat,chien', '1-50', '-5 à 5', '1.0 à 5.0', ou 'A-Z'","DG.plugin.Sampler.sample-list.prompt":"Entrez une liste (p. ex. 'chat, chat, chien') ou un intervalle (p. ex. '1-50', '-5 %@1 5', '1.0 %@1 5.0', 'A-Z').","DG.plugin.Sampler.sample-list.initial-value":"a %@1 c","DG.plugin.Sampler.range-word":"à","DG.plugin.Sampler.dataset.name":"Échantillonneur","DG.plugin.Sampler.dataset.experiment-collection-name":"expériences","DG.plugin.Sampler.dataset.sample-collection-name":"échantillons","DG.plugin.Sampler.dataset.item-collection-name":"éléments","DG.plugin.Sampler.dataset.attr-experiment":"expérience","DG.plugin.Sampler.dataset.attr-description":"description","DG.plugin.Sampler.dataset.attr-sample_size":"taille de l’échantillon","DG.plugin.Sampler.dataset.attr-sample":"échantillon","DG.plugin.Sampler.dataset.attr-value":"sortie","DG.plugin.Sampler.dataset.col-experiments":"expériences","DG.plugin.Sampler.dataset.col-samples":"échantillons","DG.plugin.Sampler.dataset.col-items":"éléments","DG.plugin.sampler.experiment.description":"%@1 contenant %@2 %@3%@4(%@5)","DG.plugin.sampler.experiment.no-description":"caché!","DG.plugin.sampler.experiment.description-mixer-item-kind":"éléments","DG.plugin.sampler.experiment.description-spinner-item-kind":"sections","DG.plugin.sampler.experiment.description-collector-item-kind":"cas","DG.plugin.sampler.experiment.description-collector-phrase":" de %@1 ","DG.plugin.sampler.experiment.description-replacement-phrase":"avec remise","DG.plugin.sampler.experiment.description-no-replacement-phrase":"sans remise","DG.plugin.DrawTool.title":"Outil de dessin","DG.plugin.DrawTool.description":"Annoter une image.","DG.plugin.MicrodataPortal.title":"Portail des microdonnées","DG.plugin.MicrodataPortal.description":"Étudier les populations issues du recensement américain au niveau individuel.","DG.plugin.NOAA-weather.title":"NOAA Weather","DG.plugin.NOAA-weather.description":"Météo de l’Administration nationale océanique et atmosphérique des États-Unis.","DG.plugin.Choosy.title":"Exigeant","DG.plugin.Choosy.description":"Organiser et simplifier les bases de données comportant de nombreux attributs.","DG.plugin.Transformers.title":"Transformateurs","DG.plugin.Transformers.description":"Transformer des jeux de données à l’aide d’un ensemble d’outils puissants.","DG.Locale.name.ko":"Coréen","DG.Locale.name.pl":"Polonais","DG.Undo.graph.showICI":"Annuler l'affichage de l'intervalle de confiance informel","DG.Redo.graph.hideICI":"Refaire le masquage de l’intervalle de confiance informel","DG.Undo.graph.hideICI":"Annuler le masquage de l’intervalle de confiance informel","DG.Redo.graph.showICI":"Refaire l'affichage de l'intervalle de confiance informel","DG.Undo.graph.showPlottedStErr":"Annuler l'affichage de l'erreur standard","DG.Redo.graph.showPlottedStErr":"Refaire l'affichage de l'erreur standard","DG.Undo.graph.hidePlottedStErr":"Annuler le masquage de l’erreur standard","DG.Redo.graph.hidePlottedStErr":"Refaire le masquage de l’erreur standard","DG.Undo.graph.setNumStErrs":"Annuler le réglage du nombre d’erreurs standard","DG.Redo.graph.setNumStErrs":"Refaire le réglage du nombre d'erreurs standards","DG.Undo.graph.showPlottedNormal":"Annuler l'affichage de la courbe normale","DG.Redo.graph.hidePlottedNormal":"Refaire le masquage de la courbe normale","DG.Undo.graph.hidePlottedNormal":"Annuler le masquage de la courbe normale","DG.Redo.graph.showPlottedNormal":"Refaire l'affichage de la courbe normale","DG.ScatterPlotModel.LSRLCIBandInfo":"Les zones ombrées indiquent l’intervalle\n dans lequel se situe la droite de\n régression théorique avec un niveau de confiance de 95 %.","DG.PlottedAverageAdornment.stErrValueTitle":"%@ SE%@moyenne%@ =%@","DG.Inspector.graphLSRLSlopeCI":"Afficher la marge d’erreur de l’ajustement","DG.Inspector.graphSpreadOptions":"Mesures de dispersion","DG.Inspector.graphPlottedStErr":"Erreur standard","DG.Inspector.graphPlottedNormal":"Courbe normale","DG.Inspector.graphPlottedGaussianFit":"Ajustement gaussien","DG.Undo.legend.lockQuantiles":"Annuler le verrouillage des plages de couleurs de la légende","DG.Redo.legend.lockQuantiles":"Refaire le verrouillage des plages de couleur de la légende","DG.Undo.legend.unlockQuantiles":"Annuler le déverrouillage des plages de couleurs de la légende","DG.Redo.legend.unlockQuantiles":"Refaire le déverrouillage des plages de couleur de la légende","DG.Inspector.lockLegendQuantiles":"Verrouiller les plages de couleur de la légende","DG.Inspector.lockLegendQuantilesTooltip":"Lorsque cette option est cochée, les plages de couleur restent fixent, même si les valeurs changent.","DG.Inspector.graphBoxPlotShowICI":"Afficher l'IC informel","DG.plugin.Sampler.tab.devices":"Modèle","DG.plugin.Sampler.tab.measures":"Mesures","DG.Inspector.graphCenterOptions":"Mesures centrales","DG.Inspector.graphBoxPlotNormalCurveOptions":"Boîte à moustaches et courbe normale","DG.Inspector.graphBoxPlotGaussianFitOptions":"Boîte à moustache et ajustement gaussien","DG.Inspector.graphOtherValuesOptions":"Valeurs tracées et mobiles","DG.plugin.Sampler.measures.instructions":"Calculer les mesures courantes pour chaque échantillon en utilisant le modèle ci-dessous.","DG.plugin.Sampler.measures.select-measure":"Sélectionner une mesure: ","DG.plugin.Sampler.measures.add-measure":"Ajouter une mesure","DG.plugin.Sampler.measures.mean":"Moyenne","DG.plugin.Sampler.measures.mean-formula":"moyenne","DG.plugin.Sampler.measures.conditional_mean":"moyenne conditionnelle","DG.plugin.Sampler.measures.conditional_mean-formula":"moyenne","DG.plugin.Sampler.measures.difference_of_means":"Différence de moyennes","DG.plugin.Sampler.measures.difference_of_means-formula-pt-1":"moyenne","DG.plugin.Sampler.measures.difference_of_means-formula-pt-2":"- moyenne","DG.plugin.Sampler.measures.sum":"Somme","DG.plugin.Sampler.measures.sum-formula":"somme","DG.plugin.Sampler.measures.median":"Médiane","DG.plugin.Sampler.measures.median-formula":"médiane","DG.plugin.Sampler.measures.conditional_median":"médiane conditionnelle","DG.plugin.Sampler.measures.conditional_median-formula":"médiane","DG.plugin.Sampler.measures.difference_of_medians":"Différence de médianes","DG.plugin.Sampler.measures.difference_of_medians-formula-pt-1":"médiane","DG.plugin.Sampler.measures.difference_of_medians-formula-pt-2":" - médiane","DG.plugin.Sampler.measures.conditional_sum":"Somme conditionnelle","DG.plugin.Sampler.measures.conditional_sum-formula":"somme","DG.plugin.Sampler.measures.select-formula":"Sélectionner une formule: ","DG.plugin.Sampler.measures.count":"Nombre","DG.plugin.Sampler.measures.count-formula":"compter","DG.plugin.Sampler.measures.percent":"Pourcentage","DG.plugin.Sampler.measures.percent-formula-pt-1":"100 * nb","DG.plugin.Sampler.measures.percent-formula-pt-2":" / nb()","DG.plugin.Sampler.measures.name-label":"Nommer la mesure: ","DG.plugin.Testimate.name":"Testimate","DG.plugin.Testimate.description":"Tester les hypothèses à l'aide de méthodes inférentielles classiques.","DG.plugin.PurpleAir.title":"Purple Air","DG.plugin.Sonify.title":"Sonify","DG.plugin.Sonify.description":"Écouter les données","DG.plugin.NHANES.title":"Portail NHANES","DG.plugin.NHANES.description":"Obtenir des données de NHANES (National Health and Nutrition Examination Survey).","DG.plugin.NASA-data.title":"NASA: Terre, air et eau","DG.plugin.NASA-data.description":"Obtenir des données de la NASA","DG.plugin.DayLength.title":"Durée du jour","DG.plugin.DayLength.description":"Obtenir la durée du jour pour tout endroit sur Terre ainsi qu'une simulation astronomique","DG.plugin.Simmer.name":"Simmer","DG.plugin.Simmer.description":"Crée des simulations générant des données avec des langages de programmation par blocs."});SC.Record.ignoreUnknownProperties=true;SC.RecordArray.QUERY_MATCHING_THRESHOLD=10000;DG=SC.Application.create((function(){var a=null;var h=function(j,m){j=j.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");m=m||"";var k="[\\?&]"+j+"(&|$|=([^&]*))";var n=new RegExp(k);var l=n.exec(window.location.search);var o;if(SC.none(l)){return m}else{if(!l[2]){return null}else{o=l[2].replace(/[+]/g,"%20");return decodeURIComponent(o)}}};var b=function(){var j=h("app");return !SC.empty(j)?j==="dg":window.location.href.indexOf("/dg")>=0};var f=function(){var j=h("app");return !SC.empty(j)?j==="is":window.location.href.indexOf("/is")>=0};var g=function(){var j=h("app");return !SC.empty(j)?j==="srri":window.location.href.indexOf("srri")>=0};var d=function(){return(window.location.href.indexOf("-dev.codap.concord.org")>=0)||(window.location.href.indexOf("localhost:4020")>=0)};var c=function(){var j=h("no_dt");return !SC.empty(j)&&j==="true"};var i=function(){var j=h("standalone");return !SC.empty(j)&&j!=="false"};var e=function(){var j=h("inbounds");return !SC.empty(j)&&j==="true"};return Object.assign({NAMESPACE:"DG",APPNAME:"DG",USER_APPNAME:"CODAP",VERSION:"2.0",CODAP_SERVER:SC.buildMode==="debug"?"/extn":"../../../../extn",BUILD_NUM:"0742",IS_DG_BUILD:b.property(),IS_INQUIRY_SPACE_BUILD:f.property(),IS_SRRI_BUILD:g.property(),exampleListBaseURL:function(){return h("exampleURL")||this.get("CODAP_SERVER")+"/example-documents"}.property(),exampleListURL:function(){return"%@1/index.json.%@2".loc(this.get("exampleListBaseURL"),SC.Locale.currentLanguage)}.property(),showHelpURL:"https://codap.concord.org/help",showHelpURL_ja:"https://codap.concord.org/resources/latest/help-documents/CODAP解説書.pdf",showHelpForumURL:"https://codap.concord.org/forums/forum/test/",showWebSiteURL:"https://codap.concord.org",showPrivacyURL:"https://codap.concord.org/privacy",splashURL:"../../../../static/dg/fr/cert/source/resources/images/codap-splash-screen.png",googleDriveClientID:"891260722961-81f8ic8tddobbh66p1j7nenr42hb93u1.apps.googleusercontent.com",googleDriveAPIKey:"AIzaSyDici8Bs9pd6-dSxheNPTpnJlcR4YuGGQQ",googleDriveAppId:"891260722961",pluginURL:function(){return h("pluginURL")||this.get("CODAP_SERVER")+"/plugins"}.property(),pluginMetadataURL:function(){return this.get("pluginURL")+"/published-plugins.json"}.property(),pluginMetadata:null,drawToolPluginURL:function(){return this.get("pluginURL")+"/DrawTool/index.html"}.property(),logFromServer:"concord.org",defaultLogServerLoginURLSecure:"https://logger.concord.org/logs",getQueryParam:function(j,k){return h(j,k)},removeQueryParams:function(l){var k=window.location.search,j=Array.isArray(l)?l:[l];j.forEach(function(o){o=o.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var u="[\\?&]"+o+"=([^&]*)",s=new RegExp(u),v=s.exec(k),r=v&&v[0],t=v&&v.index,p=r&&r.length,q=t===0,n=t+p>=k.length;if(q&&!n){r=r.substr(1)+"&"}if(r){k=k.replace(r,"")}});if((k!==window.location.search)&&window.history.replaceState){var m=window.location.protocol+"//"+window.location.host+window.location.pathname+k+window.location.hash;window.history.replaceState(null,null,m)}},getVariantString:function(k){var j=k;if(DG.get("IS_INQUIRY_SPACE_BUILD")){j+=".IS_BUILD"}else{if(DG.get("IS_SRRI_BUILD")){j+=".SRRI_BUILD"}}return j},IS_DEV_BUILD:d(),NO_DATA_TIP_PREF:c(),KEEP_IN_BOUNDS_PREF:e(),STANDALONE_MODE:i(),STANDALONE_PLUGIN:h("standalone"),isStandaloneComponent:function(k,m){var l=(DG.STANDALONE_PLUGIN||"").toLowerCase();var j=(k||"").toLowerCase();return(DG.STANDALONE_MODE&&(m==="DG.GameView")&&(DG.STANDALONE_PLUGIN==="true"||(j===l)))},appStore:a,store:null,urlParamGames:h("moreGames"),startingDocUrl:h("url"),_startingDataInteractive:h("di"),startingDataInteractive:function(){var k,l;if(this._startingDataInteractive){l=window.location.hash;return this._startingDataInteractive+(l.length>1?l:"")}else{if(this.urlParamGames){try{k=JSON.parse(this.urlParamGames);if(k&&k[0]){return k[0].url}}catch(j){DG.logWarn(j)}}}}.property("urlParamGames, _startingDataInteractive"),_dataInteractiveOverride:h("di-override"),_diOverrideURL:h("di-override-url")||h("di"),finalGameUrl:function(p){var o=p;var n=[{from:"../../../../extn/plugins/NOAA-weather/index.html",to:"../../../../extn/plugins/noaa-codap-plugin/index.html"}];n.forEach(function(q){if(o===q.from){o=q.to}});if(!o||!DG._diOverrideURL||!DG._dataInteractiveOverride){return o}var l=p.indexOf("#"),m=l>=0?p.substring(0,l):p,k=l>=0?p.substring(l):"",j=m.indexOf(DG._dataInteractiveOverride);return j>=0?DG._diOverrideURL+k:o},runKey:h("runKey")||"",componentMode:function(){return h("componentMode","no")}.property(),hideCFMMenu:function(){var j=h("interactiveApi"),k=!!j||(j===null);return k||!!h("launchFromLara")||!!h("lara")}.property(),cfmBaseUrl:h("cfmBaseUrl"),boundarySpecsUrl:function(){return h("boundarySpec")||this.get("CODAP_SERVER")+"/boundaries/default_boundary_specs.json"}.property(),embeddedMode:function(){return h("embeddedMode","no")}.property(),hideSplashScreen:function(){return h("hideSplashScreen","no")}.property(),hideWebViewLoading:function(){return h("hideWebViewLoading","no")}.property(),hideUndoRedoInComponent:function(){return h("hideUndoRedoInComponent","no")}.property(),cfmConfigurationOverride:null,embeddedServer:function(){return h("embeddedServer","no")}.property(),informalConfidenceIntervalEnabled:function(){return h("ICI",undefined)}.property(),publicConfigurationProperties:["gaussianFitEnabled"],_gaussianFitEnabled:undefined,gaussianFitEnabled:function(j,k){if(k!==undefined){this._gaussianFitEnabled=k}return this._gaussianFitEnabled||h("gaussianFit",undefined)}.property(),_guideIndex:h("guideIndex",undefined),initialGuideIndex:function(j,k){if(k!==undefined){this._guideIndex=k}return this._guideIndex}.property(),toolButtons:["tableButton","graphButton","mapButton","sliderButton","calcButton","textButton","pluginButton"],rightButtons:["undoButton","redoButton","tileListButton","optionButton","helpButton","guideButton"],logServerUrl:function(){return DG.defaultLogServerLoginURLSecure}.property(),toType:function(j){return({}).toString.call(j).match(/\s([a-zA-Z]+)/)[1].toLowerCase()},copy:function(j){return SC.copy(j,NO)},clone:function(j){return SC.clone(j,YES)},canonicalizeNames:false,exportFile:null,enableUndoHistory:true,langOverride:function(){return DG.getQueryParam("lang-override")}.property(),currentLanguage:function(){return this.get("langOverride")||SC.Locale.currentLanguage}.property(),locales:[{langName:"Deutsch",langDigraph:"de",countryDigraph:"DE",icon:"flag flag-de"},{langName:"English",langDigraph:"en",countryDigraph:"US",icon:"flag flag-us"},{langName:"Español",langDigraph:"es",countryDigraph:"ES",icon:"flag flag-es"},{langName:"فارسی",langDigraph:"fa",countryDigraph:"IR",icon:"flag flag-ir"},{langName:"Français",langDigraph:"fr",countryDigraph:"FR",icon:"flag flag-fr"},{langName:"Ελληνικά",langDigraph:"el",countryDigraph:"GR",icon:"flag flag-gr"},{langName:"עברית",langDigraph:"he",countryDigraph:"IL",icon:"flag flag-il"},{langName:"日本語",langDigraph:"ja",countryDigraph:"JP",icon:"flag flag-jp"},{langName:"한국어",langDigraph:"ko",countryDigraph:"KO",icon:"flag flag-kr"},{langName:"Nederlands",langDigraph:"nl",countryDigraph:"NL",icon:"flag flag-nl"},{langName:"Bokmål",langDigraph:"nb",countryDigraph:"NO",icon:"flag flag-no"},{langName:"Nynorsk",langDigraph:"nn",countryDigraph:"NO",icon:"flag flag-no"},{langName:"Polski",langDigraph:"pl",countryDigraph:"PL",icon:"flag flag-pl"},{langName:"Português do Brasil",langDigraph:"pt-BR",countryDigraph:"BR",icon:"flag flag-br"},{langName:"ไทย",langDigraph:"th",countryDigraph:"TH",icon:"flag flag-th"},{langName:"Türkçe",langDigraph:"tr",countryDigraph:"TR",icon:"flag flag-tr"},{langName:"繁体中文",langDigraph:"zh-TW",countryDigraph:"TW",icon:"flag flag-tw"},{langName:"简体中文",langDigraph:"zh-Hans",countryDigraph:"Hans",icon:"flag flag-cn"}]},window.DG)}()));DG.ArchiveUtils={_addLinkSpec:function(a,d,c){if(a&&!SC.empty(d)&&c){if(!a._links_){a._links_={}}var b=a._links_;if(b[d]){if(!SC.isArray(b[d])){b[d]=[b[d]]}b[d].push(c)}else{b[d]=c}}},addLinkID:function(a,c,b,d){var e={type:b,id:d};DG.ArchiveUtils._addLinkSpec(a,c,e)},addLink:function(b,c,a){var d=a&&a.toLink&&a.toLink();DG.ArchiveUtils._addLinkSpec(b,c,d)},getLinkCount:function(a,c){var b=a&&a._links_;if(!b){return 0}if(SC.empty(c)){return DG.ObjectMap.length(b)}var d=b[c];return SC.isArray(d)?d.length:(SC.empty(d)?0:1)},getLinkID:function(a,d,c){var b=a&&a._links_,f=b&&b[d],e=SC.isArray(f)?f[c||0]:f;return e&&e.id}};DG.Browser={init:function(){if((SC.browser.name===SC.BROWSER.firefox)&&(SC.browser.compare(SC.browser.version,"46")<0)){var b;b=function(c){var d=false;try{if((SC.$("embed",c).length>0)||(SC.$("object",c).length>0)){d=true}if(SC.$("iframe",c)>0){d=true}}catch(f){d=true}return d};var a=SC.PickerPane.prototype._hideOverflow;SC.PickerPane.prototype._hideOverflow=function(){if(!b(SC.$(document))){a.call(this,arguments)}}}},isCompatibleBrowser:function(){function a(e,c){var f=e.split("."),d=f.length,h=c.split(".");for(var g=0;g<d;++g){var b=Number(h[g])||0,j=Number(f[g]);if(b>j){return true}if(b<j){return false}}return true}if(DG.IS_DEV_BUILD){return true}switch(SC.browser.name){case SC.BROWSER.ie:return false;case SC.BROWSER.firefox:return a("46",SC.browser.version)||a("46",SC.browser.engineVersion);case SC.BROWSER.chrome:return a("50",SC.browser.version);case SC.BROWSER.safari:return a("10",SC.browser.version)||a("603.1.30",SC.browser.engineVersion)}return true},customCursorStr:function(a,d,c,b){b=b||"auto";return(SC.browser.engine===SC.ENGINE.trident?"url("+a+"), "+b:"url("+a+") "+d+" "+c+", "+b)}};DG.Core={gClickWillBeHandledInReactComponent:false,setClickHandlingForReact:function(){DG.Core.gClickWillBeHandledInReactComponent=true;setTimeout(function(){DG.Core.gClickWillBeHandledInReactComponent=false},200)},classFromClassName:function(b){var d=b?b.split("."):[],a,e=d.length,c=window;for(a=0;a<e;++a){c=c&&c[d[a]]}return c||null},isExtendingFromEvent:function(c){var a=(SC.browser.os===SC.OS.mac)||(SC.browser.os===SC.OS.ios),b=a&&c.metaKey&&!c.ctrlKey,d=!a&&c.ctrlKey;return c.shiftKey||b||d}};(function(){DG.Analytics={};DG.Analytics.Category={GENERAL:"General",DATA:"Data",DOCUMENT:"Document",GAME:"Game",MODEL:"Model",PLOT:"Plot",SESSION:"Session"};var a={};DG.Analytics.categoryForEvent=function(b){switch(b){case"Show all cases":case"Show all":case"openCase":case"Hide all":case"deselectAll":case"createCases":case"createCase":case"closeCase":case"attributeRemoved":case"attributeCreate":return DG.Analytics.Category.DATA;case"openDocument":case"closeDocument":case"componentCreated":case"closeComponent":case"autoSaveDocument":case"saveDocument":return DG.Analytics.Category.DOCUMENT;case"initGame":case"backToGame":return DG.Analytics.Category.GAME;case"LoadedModel":case"StartedModel":return DG.Analytics.Category.MODEL;case"togglePlottedMean":case"togglePlotFunction":case"rescaleScatterplot":case"rescaleDotPlot":case"plotFunction":case"plotAxisAttributeChangeType":case"plotAxisAttributeChange":case"legendAttributeChange":case"hoverOverGraphLine":case"ExportedModel":case"addAxisAttribute":return DG.Analytics.Category.PLOT;case"Logout":case"Login":return DG.Analytics.Category.SESSION;default:if(b&&b.search(/Hide .* selected cases/)!==-1){return DG.Analytics.Category.DATA}return DG.Analytics.Category.GENERAL}};DG.Analytics._analyticsEnabled=function(){return typeof(ga)!=="undefined"&&ga!==null};DG.Analytics.trackEvent=function(d,f,c,e){if(!this._analyticsEnabled()){return}var b=["send","event",d,f];if(c){b.push(c);if(e){b.push(e)}}ga.apply(window,b)};DG.Analytics.trackTimingStart=function(b){if(!this._analyticsEnabled()){return}a[b]=new Date().getTime()};DG.Analytics.trackTimingEnd=function(c){if(!this._analyticsEnabled()||!a[c]){return}var d=new Date().getTime()-a[c];a[c]=null;if(d>0&&d<(1000*60*120)){var b=["send","timing",c,"Time spent",d];ga.apply(window,b)}}}());sc_require("utilities/analytics");DG.LOGGER_LEVEL_USER="user";DG.debugForceReload=function(){window.location.reload()};DG.debugLaunchDebugger=function(){eval("debugger")};SC.Logger.logOutputLevel=SC.LOGGER_LEVEL_WARN;DG.Debug=SC.Object.create((function(){var b=1000;var c=null;var a=0;return{logServerLevel:SC.LOGGER_LEVEL_INFO,googleAnalyticsLevel:SC.LOGGER_LEVEL_INFO,_prevHandleLogMessage:null,_prevExceptionHandler:null,_debugStartTime:0,init:function(){this._debugStartTime=Date.now();this._prevHandleLogMessage=SC.Logger._handleMessage;SC.Logger._handleMessage=this._prevHandleLogMessage;SC.ExceptionHandler.handleException=this._handleException;SC.ExceptionHandler.enabled=YES},logIfNotFinite:function(d,e){if(!isFinite(d)){this.logWarn("DG.Debug.logIfNotFinite: String: %@, Value: %@",e,d)}},logDebug:function(d,e){DG.Debug._handleLogMessage(SC.LOGGER_LEVEL_DEBUG,YES,d,arguments)},logDebugRaw:function(d){DG.Debug._handleLogMessage(SC.LOGGER_LEVEL_DEBUG,NO,null,arguments)},logDebugTimer:function(f,e,g){var d=Date.now();if(f){DG.Debug._debugStartTime=d;d=0}else{d-=DG.Debug._debugStartTime}DG.Debug._handleLogMessage(SC.LOGGER_LEVEL_DEBUG,YES,"[TIME="+(d/1000)+"] "+e,arguments)},logDebugGroupBegin:function(d,e){SC.Logger._handleGroup(SC.LOGGER_LEVEL_DEBUG,d,arguments)},logDebugGroupEnd:function(){SC.Logger._handleGroupEnd(SC.LOGGER_LEVEL_DEBUG)},logInfo:function(d,e){DG.Debug._handleLogMessage(SC.LOGGER_LEVEL_INFO,YES,d,arguments)},logInfoRaw:function(d){DG.Debug._handleLogMessage(SC.LOGGER_LEVEL_INFO,NO,null,arguments)},logUser:function(e,g){var d={formatStr:e,replaceArgs:[].slice.call(arguments,1)};var f=DG.currDocumentController().notificationManager;if(f){f.notifyLogMessageSubscribers(d)}DG.Debug._handleLogMessage(DG.LOGGER_LEVEL_USER,YES,e,arguments)},logUserWithTopic:function(f,g,i){var d={topic:f,formatStr:g,replaceArgs:[].slice.call(arguments,2)};var h=DG.currDocumentController().notificationManager;if(h){h.notifyLogMessageSubscribers(d)}var e=[].slice.call(arguments,1);DG.Debug._handleLogMessage(DG.LOGGER_LEVEL_USER,YES,g,e)},logUserRaw:function(d){DG.Debug._handleLogMessage(DG.LOGGER_LEVEL_USER,NO,null,arguments)},logWarn:function(d,e){DG.Debug._handleLogMessage(SC.LOGGER_LEVEL_WARN,YES,d,arguments)},logWarnRaw:function(d){DG.Debug._handleLogMessage(SC.LOGGER_LEVEL_WARN,NO,null,arguments)},logError:function(d,e){DG.Debug._handleLogMessage(SC.LOGGER_LEVEL_ERROR,YES,d,arguments)},logErrorRaw:function(d){DG.Debug._handleLogMessage(SC.LOGGER_LEVEL_ERROR,NO,null,arguments)},assert:function(g,h,e){if(!g){var f=((c!==h)&&((Date.now()-a)>b)),d=true;DG.Debug.logErrorRaw("Assertion Failed: "+h+": "+e);if(d){}if(f){SC.AlertPane.error({message:h||"",description:e||"",buttons:[{title:"Reload",action:DG.debugForceReload},{title:"Ignore"}]});c=h;a=Date.now()}}return g},check:function(d,f,e){return this.assert(!SC.none(d),f,e)},_shouldLogTypeToServer:function(d){var f=SC.Logger._LOG_LEVEL_MAPPING,g=f[d]||0,e=f[this.get("logServerLevel")]||0;return(g<=e)},_handleLogMessage:function(p,d,n,h){var m=p;if(p===DG.LOGGER_LEVEL_USER){m=SC.LOGGER_LEVEL_INFO}else{if(p===DG.LOGGER_LEVEL_INFO){m=SC.LOGGER_LEVEL_DEBUG}}this._prevHandleLogMessage.call(SC.Logger,m,d,n,h);var g=DG.Debug._shouldLogTypeToServer(m),o=DG.Debug._shouldLogTypeToGoogleAnalytics(m);if(g||o){var q=(h&&(h.length>0))?h[h.length-1]:undefined,f=typeof q==="object"?q:{},l=DG.Debug._currentMessage?DG.Debug._currentMessage.split(":"):[],e=DG.getPath("currDocumentController.documentName"),j=l.shift(),i=l.join(":").trim();if(m===SC.LOGGER_LEVEL_ERROR||m===SC.LOGGER_LEVEL_WARN){j=m;i='{"message": "'+DG.Debug._currentMessage+'"}'}if(g){try{DG.logToServer(j,{type:p,args:i,activity:e,application:"CODAP"},f)}catch(k){if(console&&console.log){console.log("Log to server failed: "+k)}}}if(o){DG.Analytics.trackEvent(DG.Analytics.categoryForEvent(j),j,i)}}},_shouldLogTypeToGoogleAnalytics:function(d){var f=SC.Logger._LOG_LEVEL_MAPPING,g=f[d]||0,e=f[this.get("googleAnalyticsLevel")]||0;return DG.GOOGLE_ANALYTICS_ID&&(g<=e)},_handleException:function(d){var e=!SC.none(DG.Debug._prevExceptionHandler);DG.Debug.logError("Exception: "+d);if(console&&console.log){DG.log(d.stack)}window.alert("DG.mainPage.exceptionMessage".loc(d.message));if(e){DG.Debug._prevExceptionHandler.call(this,d)}return true}}}()));DG.Debug._prevShouldOutputType=SC.Logger._shouldOutputType;SC.Logger._shouldOutputType=function(a){return true};DG.Debug._prevOutputMessage=SC.Logger._outputMessage;SC.Logger._outputMessage=function(b,d,a,c,e){if(typeof c==="string"){DG.Debug._currentMessage=c}else{if(c&&c.toString){DG.Debug._currentMessage=c.toString()}else{DG.Debug._currentMessage=""}}if(DG.Debug._prevShouldOutputType.call(SC.Logger,b)){DG.Debug._prevOutputMessage.call(SC.Logger,b,d,a,c,e)}};DG.Debug.scObjectID=function(a){var b="";DG.ObjectMap.findKey(a,function(c,d){if(c.substr(0,10)==="SproutCore"){b=d;return true}return false});return !SC.empty(b)?b:"{none}"};DG.log=DG.Debug.logDebug;DG.logRaw=DG.Debug.logDebugRaw;DG.logTimer=DG.Debug.logDebugTimer;DG.logGroupBegin=DG.Debug.logDebugGroupBegin;DG.logGroupEnd=DG.Debug.logDebugGroupEnd;DG.logInfo=DG.Debug.logInfo;DG.logInfoRaw=DG.Debug.logInfoRaw;DG.logUser=DG.Debug.logUser;DG.logUserRaw=DG.Debug.logUserRaw;DG.logWarn=DG.Debug.logWarn;DG.logWarnRaw=DG.Debug.logWarnRaw;DG.logError=DG.Debug.logError;DG.logErrorRaw=DG.Debug.logErrorRaw;DG.assert=DG.Debug.assert;DG.check=DG.Debug.check;DG.Destroyable={concatenatedProperties:["autoDestroyProperties"],destroyMixin:function(){var a=this.get("autoDestroyProperties");if(a){a.forEach(function(b){this.destroyProperty(b)}.bind(this))}},destroyProperty:function destroyProperty(b){var a=this.get(b);if(DG.Destroyable.destroyObject(a)){if(b.charAt(0)==="_"){this[b]=null}else{this.set(b,null)}}}};DG.Destroyable.destroyObject=function(a){if(a&&(a instanceof SC.Object)){if(a.willDestroy){a.willDestroy()}a.destroy();return true}return false};DG.Format={};DG.Format.re=function(a){return a.replace(/[\\\^\$\*\+\?\[\]\(\)\.\{\}]/g,"\\$&")};DG.Format.pad=function(e,d,b){var a=d-String(b).length;return(a<1)?b:new Array(a+1).join(e)+b};DG.Format.date=function(a){var c=DG.Format.pad;function b(e){return a.replace(/%[a-zA-Z0-9]/g,function(g){var f,d;switch(g){case"%a":return["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][e.getDay()];case"%A":return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][e.getDay()];case"%h":case"%b":return["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][e.getMonth()];case"%B":return["January","February","March","April","May","June","July","August","September","October","November","December"][e.getMonth()];case"%c":return e.toLocaleString();case"%C":return c("0",2,Math.floor(e.getFullYear()/100)%100);case"%d":return c("0",2,e.getDate());case"%x":case"%D":return c("0",2,e.getMonth()+1)+"/"+c("0",2,e.getDate())+"/"+c("0",2,e.getFullYear()%100);case"%e":return c(" ",2,e.getDate());case"%H":return c("0",2,e.getHours());case"%I":f=e.getHours()%12;return f?c("0",2,f):12;case"%m":return c("0",2,e.getMonth()+1);case"%M":return c("0",2,e.getMinutes());case"%n":return"\n";case"%p":return e.getHours()<12?"AM":"PM";case"%T":case"%X":case"%r":f=e.getHours()%12;return(f?c("0",2,f):12)+":"+c("0",2,e.getMinutes())+":"+c("0",2,e.getSeconds())+" "+(e.getHours()<12?"AM":"PM");case"%R":return c("0",2,e.getHours())+":"+c("0",2,e.getMinutes());case"%S":return c("0",2,e.getSeconds());case"%Q":return c("0",3,e.getMilliseconds());case"%t":return"\t";case"%u":d=e.getDay();return d?d:1;case"%w":return e.getDay();case"%y":return c("0",2,e.getFullYear()%100);case"%Y":return e.getFullYear();case"%%":return"%"}return g})}b.format=b;b.parse=function(m){var k=1970,j=0,e=1,g=0,f=0,d=0;var i=[function(){}];var l=DG.Format.re(a).replace(/%[a-zA-Z0-9]/g,function(n){switch(n){case"%b":i.push(function(o){j={Jan:0,Feb:1,Mar:2,Apr:3,May:4,Jun:5,Jul:6,Aug:7,Sep:8,Oct:9,Nov:10,Dec:11}[o]});return"([A-Za-z]+)";case"%h":case"%B":i.push(function(o){j={January:0,February:1,March:2,April:3,May:4,June:5,July:6,August:7,September:8,October:9,November:10,December:11}[o]});return"([A-Za-z]+)";case"%e":case"%d":i.push(function(o){e=o});return"([0-9]+)";case"%I":case"%H":i.push(function(o){g=o});return"([0-9]+)";case"%m":i.push(function(o){j=o-1});return"([0-9]+)";case"%M":i.push(function(o){f=o});return"([0-9]+)";case"%p":i.push(function(o){if(g===12){if(o==="am"){g=0}}else{if(o==="pm"){g=Number(g)+12}}});return"(am|pm)";case"%S":i.push(function(o){d=o});return"([0-9]+)";case"%y":i.push(function(o){o=Number(o);k=o+(((0<=o)&&(o<69))?2000:(((o>=69)&&(o<100)?1900:0)))});return"([0-9]+)";case"%Y":i.push(function(o){k=o});return"([0-9]+)";case"%%":i.push(function(){});return"%"}return n});var h=m.match(l);if(h){h.forEach(function(n,o){i[o](n)})}return new Date(k,j,e,g,f,d)};return b};DG.Format.time=function(a){var c=DG.Format.pad;function b(f){function j(h){return h>>0}f=Number(f);switch(a){case"short":if(f>=31536000000){return(f/31536000000).toFixed(1)+" years"}else{if(f>=604800000){return(f/604800000).toFixed(1)+" weeks"}else{if(f>=86400000){return(f/86400000).toFixed(1)+" days"}else{if(f>=3600000){return(f/3600000).toFixed(1)+" hours"}else{if(f>=60000){return(f/60000).toFixed(1)+" minutes"}}}}}return(f/1000).toFixed(1)+" seconds";case"long":var e=[],i=j((f%60000)/1000),d=j((f%3600000)/60000);e.push(c("0",2,i));if(f>=3600000){var g=j((f%86400000)/3600000);e.push(c("0",2,d));if(f>=86400000){e.push(c("0",2,g));e.push(Math.floor(f/86400000).toFixed())}else{e.push(g.toFixed())}}else{e.push(d.toFixed())}return e.reverse().join(":")}}b.format=b;b.parse=function(i){var h,d,g,j,e;switch(a){case"short":h=/([0-9,.]+)\s*([a-z]+)/g;g=0;d=h.exec(i);while(d){j=parseFloat(d[0].replace(",",""));e=0;switch(d[2].toLowerCase()){case"year":case"years":e=31536000000;break;case"week":case"weeks":e=604800000;break;case"day":case"days":e=86400000;break;case"hour":case"hours":e=3600000;break;case"minute":case"minutes":e=60000;break;case"second":case"seconds":e=1000;break}g+=j*e;d=h.exec(i)}return g;case"long":d=i.replace(",","").split(":").reverse();g=0;if(d.length){g+=parseFloat(d[0])*1000}if(d.length>1){g+=parseFloat(d[1])*60000}if(d.length>2){g+=parseFloat(d[2])*3600000}if(d.length>3){g+=parseFloat(d[3])*86400000}return g}};return b};DG.Format.number=function(){var g=0,c=Infinity,a=0,j=0,e=0,b=1,f="0",i="0",h=true,d=".",n=",",m="\u2212",k="";function l(o){if(Infinity>e){o=Math.round(o*b)/b}var q=String(Math.abs(o)).split(".");var p=q[0];if(p.length>c){p=p.substring(p.length-c)}if(h&&(p.length<g)){p=new Array(g-p.length+1).join(f)+p}if(p.length>3){p=p.replace(/\B(?=(?:\d{3})+(?!\d))/g,n)}if(!h&&(p.length<a)){p=new Array(a-p.length+1).join(f)+p}q[0]=o<0?m+p+k:p;var r=q[1]||"";if(r.length<j){q[1]=r+new Array(j-r.length+1).join(i)}return q.join(d)}l.format=l;l.parse=function(o){var r=DG.Format.re;var q=String(o).replace(new RegExp("^("+r(f)+")*"),"").replace(new RegExp("("+r(i)+")*$"),"").split(d);var p=q[0].replace(new RegExp(r(n),"g"),"");if(p.length>c){p=p.substring(p.length-c)}var t=q[1]?Number("0."+q[1]):0;if(Infinity>e){t=Math.round(t*b)/b}return Math.round(p)+t};l.integerDigits=function(p,o){if(arguments.length){g=Number(p);c=(arguments.length>1)?Number(o):g;a=g+Math.floor(g/3)*n.length;return this}return[g,c]};l.fractionDigits=function(p,o){if(arguments.length){j=Number(p);e=(arguments.length>1)?Number(o):j;b=Math.pow(10,e);return this}return[j,e]};l.integerPad=function(o){if(arguments.length){f=String(o);h=/\d/.test(f);return this}return f};l.fractionPad=function(o){if(arguments.length){i=String(o);return this}return i};l.decimal=function(o){if(arguments.length){d=String(o);return this}return d};l.group=function(o){if(arguments.length){n=o?String(o):"";a=g+Math.floor(g/3)*n.length;return this}return n};l.negativeAffix=function(o,p){if(arguments.length){m=String(o||"");k=String(p||"");return this}return[m,k]};return l};sc_require("utilities/formatter");DG.Calculator=SC.View.extend((function(){var i=30,h=24,e=5,d=5,j=2,g=2*i+j,b=i+j,a=h+j,f=4,c=5;return{classNames:["dg-calculator"],backgroundColor:"#333333",_justEvaled:NO,viewFormat:DG.Format.number().fractionDigits(0,9).group(""),exportFormat:DG.Format.number().fractionDigits(0,9).group("").negativeAffix("-",""),formatForView:function(k){if(typeof k!=="number"){return String(k)}return this.viewFormat(k)},formatForExport:function(k){if(typeof k!=="number"){return k}return this.exportFormat(k)},clearValue:function(){var l=this,k=this.editView.get("value");DG.UndoHistory.execute(DG.Command.create({name:"calculator.calculate",undoString:"DG.Undo.calculator.calculate",redoString:"DG.Redo.calculator.calculate",log:"Calculator value cleared",_redoValue:null,executeNotification:{action:"notify",resource:"component",values:{operation:"calculate",type:"DG.Calculator"}},execute:function(){l.editView.set("value",this._redoValue||"");l._justEvaled=NO},undo:function(){this._redoValue=l.editView.get("value");l.editView.set("value",k);l._justEvaled=NO}}))},insert:function(k){if(this._justEvaled&&!isNaN(parseInt(k,10))){this.clearValue()}this.editView.replaceSelectionWithString(k);if(!this.editView.get("isFirstResponder")){this.editView.becomeFirstResponder()}this._justEvaled=NO},insertSymbol:function(k){if(this._justEvaled){this.clearValue()}this.insert(k)},calculate:function(){var m=this.editView.get("formulaExpression"),p=DG.Formula.create({source:m}),q="";if(!SC.empty(m)&&(m.charAt(0)==="#")){return}try{q=p.evaluateDirect()}catch(l){q=!SC.empty(l.message)?l.message:String(l);q="#"+q}var o=this.formatForView(q),k=this.editView.get("value"),n=this;DG.UndoHistory.execute(DG.Command.create({name:"calculator.calculate",undoString:"DG.Undo.calculator.calculate",redoString:"DG.Redo.calculator.calculate",log:"Calculation done: %@ = %@".fmt(m,this.formatForExport(q)),executeNotification:{action:"notify",resource:"component",values:{operation:"calculate",type:"DG.Calculator"}},execute:function(){n.editView.set("value",o);n._justEvaled=YES},undo:function(){n.editView.set("value",k);n._justEvaled=NO}}))},init:function(){arguments.callee.base.apply(this,arguments);this.setupSubViews()},setupSubViews:function(){var o=this;this.editView=DG.FormulaTextEditView.create({layout:{top:5,left:5,right:5,height:20},value:"",continuouslyUpdatesValue:false,borderStyle:SC.BORDER_BEZEL,keyDown:function(p){if(o.handleKeyDown(p)){return arguments.callee.base.apply(this,arguments)}else{return true}}});this.appendChild(this.editView);this.set("defaultFirstResponder",this.editView);this.equals=SC.ButtonView.create({layout:{bottom:e,left:e+2*b,width:g,height:h},title:"=",titleMinWidth:0});this.appendChild(this.equals);this.equals.action=function(){o.calculate()};var k=d+e+this.editView.layout.height;this.set("layout",{top:3,left:5,width:1.5*j+f*b,height:k+c*a+e*3});var l=[["C",function(){o.clearValue()}],["(",function(){o.insertSymbol("(")}],[")",function(){o.insertSymbol(")")}],["/",function(){o.insert(" / ")}],["7",function(){o.insert("7")}],["8",function(){o.insert("8")}],["9",function(){o.insert("9")}],["X",function(){o.insert(" * ")}],["4",function(){o.insert("4")}],["5",function(){o.insert("5")}],["6",function(){o.insert("6")}],[DG.UNICODE.MINUS_SIGN,function(){o.insert(" "+DG.UNICODE.MINUS_SIGN+" ")}],["1",function(){o.insert("1")}],["2",function(){o.insert("2")}],["3",function(){o.insert("3")}],["+",function(){o.insert(" + ")}],["0",function(){o.insert("0")}],[".",function(){o.insertSymbol(".")}]];var n=0,m=5;l.forEach(function(q){var r=Math.floor(n/f);var p=n%f;var s=SC.ButtonView.create({layout:{bottom:e+(m-r-1)*a,left:e+p*b,width:i,height:h},title:q[0],action:q[1],titleMinWidth:0});o.appendChild(s);n++})},handleKeyDown:function(k){if(!this){return NO}if((k.which===SC.Event.KEY_RETURN)&&!k.isIMEInput){if(k.type==="keydown"){this.calculate()}}else{if(k.which===SC.Event.KEY_ESC){this.clearValue()}else{var l=String.fromCharCode(k.which);if(this._justEvaled&&("/*-+\t".indexOf(l)===-1)){this.clearValue()}else{if(l==="="){this.calculate();return false}else{this._justEvaled=NO}}}}return true},didReachInitialPosition:function(){this.editView.beginEditing()}}}()));DG.React={createClass:function(b,a){var c=createReactClass(b);if(a){a.forEach(function(d){c=d(c)})}return c},createComponent:function(b,a){return createReactFactory(DG.React.createClass(b,a))},toggleRender:function(a,b){if(a.children.length>0){ReactDOM.unmountComponentAtNode(a)}else{if(b){ReactDOM.render(b,a)}}},ready:function(a){if(window.React&&window.ReactDOM){a()}else{setTimeout(function(){DG.React.ready(a)},250)}}};DG.React.SlateContainer=createReactFactory(SlateEditor.SlateContainer);DG.React.SlateEditor=createReactFactory(SlateEditor.SlateEditor);DG.React.SlateToolbar=createReactFactory(SlateEditor.SlateToolbar);DG.React.HighOrderComponents={_render:function(c,a,d){var b=Object.assign({},c.props,c.state,(d||{}));return createReactFactory(a)(b)},UnmountOnOutsideClick:function(a){return createReactClass({componentDidMount:function(){window.addEventListener("mousedown",this.checkForToggle,true);window.addEventListener("touchstart",this.checkForToggle,true)},componentWillUnmount:function(){window.removeEventListener("mousedown",this.checkForToggle,true);window.removeEventListener("touchstart",this.checkForToggle,true)},checkForToggle:function(d){var b=ReactDOM.findDOMNode(this).parentNode,c=d.target;while(c&&(c!==b)){c=c.parentNode}if(!c){this.unmount();d.preventDefault();d.stopPropagation()}},unmount:function(){DG.React.toggleRender(ReactDOM.findDOMNode(this).parentNode)},render:function(){return DG.React.HighOrderComponents._render(this,a,{unmount:this.unmount})}})},UnmountOnEscapeKey:function(a){return createReactClass({componentDidMount:function(){window.addEventListener("keydown",this.checkForEscape,true)},componentWillUnmount:function(){window.removeEventListener("keydown",this.checkForEscape,true)},checkForEscape:function(b){if(b.keyCode===27){this.unmount();b.preventDefault();b.stopPropagation()}},unmount:function(){DG.React.toggleRender(ReactDOM.findDOMNode(this).parentNode)},render:function(){return DG.React.HighOrderComponents._render(this,a,{unmount:this.unmount})}})}};DG.React.Components={};DG.React.ready(function(){var a=ReactDOMFactories.img,c=ReactDOMFactories.div,b=ReactDOMFactories.td;DG.React.AttributeNameCell=DG.React.createComponent((function(){return{cellRef:null,cellWidth:null,moveDirection:"",componentDidMount:function(){this.componentDidRender()},componentDidUpdate:function(){this.componentDidRender()},componentDidRender:function(){if(this.cellRef&&this.props.onColumnWidthChanged){var d=this.cellRef.getBoundingClientRect();if(d.width!==this.cellWidth){this.cellWidth=d.width;this.props.onColumnWidthChanged(this.cellWidth)}}},showDragTip:function(e){if(e&&!this.tipIsShowing){var o=this.cellRef.getBoundingClientRect(),l=this.props.dragStatus.dragObject.data,k=l.attribute.get("name"),m=l.collection.get("name"),g=l.context.get("name"),n=this.props.attribute,d=n.getPath("collection.name"),h=n.getPath("collection.dataSet.dataContextRecord.name"),i=n.get("name"),j="DG.Collection.joinTip".loc(m,g,d,h,k,i);var f=DG.mainPage.getPath("mainPane.tipView");f.invokeLater(function(){f.show({x:o.left,y:o.top+o.height},j)},10);this.tipIsShowing=true}else{if(!e&&this.tipIsShowing){DG.mainPage.getPath("mainPane.tipView").hide();this.tipIsShowing=false}}},render:function(){var k=this;function g(x){k.cellRef=x}function u(){var B="";k.moveDirection="";if(k.props.dragStatus&&k.props.dragStatus.event&&k.cellRef){var A=k.props.dragStatus.event,x=A.clientX,C=A.clientY,z=k.cellRef.getBoundingClientRect(),y=k.props.dragStatus.dragType;if(x>z.x&&x<z.x+z.width&&C>z.y&&C<z.y+z.height){switch(y){case"ownContext":if(C<z.y+z.height/2){k.moveDirection="up";B="attr-cell-upper"}else{if(C<z.y+z.height){k.moveDirection="down";B="attr-cell-lower"}}break;case"foreignContext":k.moveDirection="join";B="attr-cell-all"}}}return B}function t(){if(k.props.dragStatus&&k.props.dragStatus.op===SC.DRAG_LINK&&k.props.dropCallback&&k.moveDirection!==""){k.props.dropCallback(k.moveDirection)}}function o(x){SC.run(function(){k.dropdown.hide();x()})}function j(){o(k.props.onBeginRenameAttribute)}function p(){o(k.props.editAttributeCallback)}function e(){o(k.props.editFormulaCallback)}function i(){o(k.props.hideAttributeCallback)}function v(){o(k.props.deleteAttributeFormulaCallback)}function q(){o(k.props.recoverAttributeFormulaCallback)}function w(){o(k.props.deleteAttributeCallback)}function m(){o(k.props.rerandomizeCallback)}function h(){if(k.props.newAttributeCallback){k.props.newAttributeCallback()}}var n=function(){var y=this.props.attribute.get("formula")!=="",x=this.props.attribute.hasDeletedFormula(),z=x?"DG.TableController.headerMenuItems.recoverFormula".loc():"DG.TableController.headerMenuItems.deleteFormula".loc(),B=[{label:"DG.TableController.headerMenuItems.renameAttribute".loc(),clickHandler:j},{label:"DG.TableController.headerMenuItems.editAttribute".loc(),clickHandler:p},{label:"DG.TableController.headerMenuItems.editFormula".loc(),disabled:!this.props.attributeIsEditableCallback(),clickHandler:e},{label:z,disabled:!this.props.attributeIsEditableCallback()||(!y&&!x),clickHandler:x?q:v},{label:"DG.TableController.headerMenuItems.randomizeAttribute".loc(),disabled:!this.props.attributeCanBeRandomizedCallback(),clickHandler:m},{label:"DG.TableController.headerMenuItems.hideAttribute".loc(),disabled:!this.props.attributeCanBeHiddenCallback(),clickHandler:i},{label:"DG.TableController.headerMenuItems.deleteAttribute".loc(),disabled:false,clickHandler:w}].map(function(D,C){return DG.React.Components.DropdownItem({disabled:D.disabled,key:"item-"+C,clickHandler:D.clickHandler},D.label)}),A=c({className:"react-name-cell"},this.props.content);return DG.React.Components.Dropdown({trigger:A,menuItems:B,ref:function(C){this.dropdown=C}.bind(this),onRefCallback:g})}.bind(this);t();var r="attr-cell "+u(),l=this.props.newAttributeCallback?"":" disabled",f=this.props.showNewAttrButton&&a({src:"../../../../static/dg/fr/cert/source/resources/images/add_circle_grey_72x72.png",className:"dg-floating-plus dg-wants-touch"+l,title:"DG.TableController.newAttributeTooltip".loc(),onClick:h}),s=this.props.columnWidthPct!=null?(Math.round(this.props.columnWidthPct*1000)/10)+"%":undefined,d=this.props.isEditing?DG.React.SimpleEdit({className:"react-data-card-attr-name-input",value:this.props.attribute.get("name"),onCompleteEdit:this.props.onEndRenameAttribute}):n();this.showDragTip(this.moveDirection==="join");return b({className:r,ref:g,style:{width:s}},f,d)}}}()),[])});DG.React.ready(function(){var a=ReactDOMFactories.span;DG.React.Components.AttributeSummary=DG.React.createComponent((function(){return{render:function(){var i=this.props.attr,h=i.get("id"),k=i.get("type"),j=k==="numeric",l=true,b=Number.MAX_VALUE,d=-Number.MAX_VALUE,f={},e,c;this.props.cases.forEach(function(m){var n=j?m.getForcedNumericValue(h):m.getValue(h);if(!SC.empty(n)){if(!f[n]){f[n]=0}f[n]++;if(n!==""&&isFinite(n)){b=Math.min(b,n);d=Math.max(d,n)}else{if(n!==""){l=false}}}});if(l){b=DG.MathUtilities.formatNumber(b,2);d=DG.MathUtilities.formatNumber(d,2)}e=Object.keys(f).length;if(e>2||l){c=(b==="Infinity")?"":l?(b===d?(b+this.props.unit):"DG.CaseCard.summaryRange".loc(b,d,this.props.unit)):"DG.CaseCard.summaryValues".loc(e);return a({className:"react-data-card-attribute-summary"},c)}else{var g=Object.keys(f).filter(function(m){return m!=="undefined"}).join(", ");if(g==="undefined"){g=""}return a({className:"react-data-card-attribute-summary"},g)}}}}()),[])});DG.ModelStore=SC.Object.extend({_idCount:0,_store:null,init:function(){arguments.callee.base.apply(this,arguments);this._store=[]},register:function(a,c){var b=this.getIDForNewRecord(c);c.id=b;DG.assert(!SC.none(b),"Check if found or created valid new ID for record of type %@".fmt(a));DG.assert(SC.none(this._store[b]),"Check if store contains new object ID of type %@".fmt(a));this._store[b]=c;return b},deregister:function(a){delete this._store[a]},find:function(a,b){if(typeof a==="number"&&typeof b==="undefined"){b=a}return this._store[b]},getIDForNewRecord:function(b){var a;if(!SC.empty(b.guid)){a=b.guid}else{if(!SC.empty(b.id)){a=b.id}}if(!SC.empty(a)&&!SC.empty(this._store[a])){DG.logWarn("Store may be corrupt: found id, "+a+", in new object and store.");DG.logWarn("Creating new object, but bad references may be present.")}if(SC.empty(a)){while(SC.empty(a)||this._store[a]){a=++this._idCount}}return a},_getDataSource:function(){return this},recordTypeFromString:function(d){var c=d.indexOf("."),a=c>=0?c+1:0,b=d.substr(a);return DG[b]},destroyAllRecordsOfType:function(b,c){var a=[];if(SC.empty(c)){c=[]}this._store.forEach(function(d){var e=d.id;if(d.get("recordType")===b&&!c.contains(e)){a.push(e);d.destroy();if(this._store[e]){this.deregister(e)}}}.bind(this));return a},resolve:function(a){var b;if(typeof a==="object"){return a}if(typeof a==="number"){b=this.find(null,a);if(SC.empty(b)){DG.logError("Could not resolve reference: "+a);return a}return b}},commitRecords:function(){},flush:function(){}});DG.BaseModel=SC.Object.extend({recordType:function(){return this.constructor}.property().cacheable(),recordTypeString:function(){return this.toString().replace(/:.*/,"")}.property().cacheable(),init:function(){arguments.callee.base.apply(this,arguments);if(!SC.empty(DG.store)){DG.store.register(this.recordType(),this)}this.verify()},destroy:function(){DG.store.deregister(this.id);arguments.callee.base.apply(this,arguments)},toLink:function(){var a=this.get("recordTypeString");return{type:a,id:this.get("id")}},willSaveRecord:function(){},didLoadRecord:function(){},verify:function(){}});sc_require("models/model_store");sc_require("models/base_model");DG.Attribute=DG.BaseModel.extend({name:"",_title:null,title:function(b,a){if(!SC.none(a)){this._title=a}return this._title||this.get("name")}.property(),formula:"",deletedFormula:"",_categoryMap:null,categoryMap:function(a,b){if(!SC.none(b)){this._categoryMap=b}if(SC.none(this._categoryMap)||!SC.isArray(this._categoryMap.__order)||this._categoryMap.__order.length===0){this.updateCategoryMap();this._categoryMap.__order.sort(function(d,c){if(DG.isNumeric(d)&&DG.isNumeric(c)){return d-c}else{return d>c}})}return this._categoryMap}.property(),blockDisplayOfEmptyCategories:true,description:"",type:null,cid:null,collection:null,precision:2,unit:null,editable:true,hidden:false,renameable:true,deleteable:true,_dgFormula:null,_cachedValues:null,init:function(){arguments.callee.base.apply(this,arguments);var a=this.get("formula");if(!SC.empty(a)&&!this._dgFormula){this.createDGFormula();this._dgFormula.set("source",a)}if(typeof this.collection==="number"){this.collection=DG.store.find(DG.Attribute,this.collection)}this._cachedValues={}},verify:function(){if(SC.empty(this.collection)){DG.logWarn("Unattached attribute: "+this.id)}if(typeof this.collection==="number"){DG.logWarn("Unresolved reference to collection id, "+this.collection+", in attribute: "+this.id)}if(!(this.collection.recordType&&this.collection.recordType()===DG.Collection)){DG.logWarn("Unexpected collection RecordType: "+this.collection.recordTypeString())}},destroy:function(){var a=this.get("id");if(!SC.none(a)){delete DG.Attribute.idMap[a]}if(this.collection){this.collection.attrs.removeObject(this);this.collection.dataSet.deleteAttribute(this)}if(this._dgFormula){this.destroyDGFormula()}arguments.callee.base.apply(this,arguments)},getTransferableProperties:function(){return{name:this.get("name"),title:this.get("title"),formula:this.get("formula"),deletedFormula:this.get("deletedFormula"),categoryMap:JSON.parse(JSON.stringify(this.get("categoryMap"))),blockDisplayOfEmptyCategories:this.get("blockDisplayOfEmptyCategories"),description:this.get("description"),type:this.get("type"),precision:this.get("precision"),unit:this.get("unit")}},forEachCategory:function(a){var b=this.get("categoryMap");DG.assert(!SC.none(b)&&SC.isArray(b.__order));b.__order.forEach(function(c,e){var d=b[c];d=d&&d.colorString?d.colorString:d;a(c,d,e)})},createDGFormula:function(){var a=DG.CollectionFormulaContext.create({ownerSpec:{type:DG.DEP_TYPE_ATTRIBUTE,id:this.get("id"),name:this.get("name")},collection:this.get("collection")});this._dgFormula=DG.Formula.create({context:a});this._dgFormula.addObserver("namespaceChange",this,"namespaceDidChange");this._dgFormula.addObserver("dependentChange",this,"dependentDidChange")},collectionDidChange:function(){if(this.hasFormula()){this._cachedValues={};this.setPath("_dgFormula.context.collection",this.get("collection"));this._dgFormula.invalidate()}}.observes("collection"),destroyDGFormula:function(){this._dgFormula.removeObserver("dependentChange",this,"dependentDidChange");this._dgFormula.removeObserver("namespaceChange",this,"namespaceDidChange");this._dgFormula.destroy();this._dgFormula=null},hasFormula:function(){return !SC.empty(this.get("formula"))}.property("formula").cacheable(),hasDeletedFormula:function(){return !SC.empty(this.get("deletedFormula"))}.property("deletedFormula").cacheable(),evalFormula:function(b){var f=this._dgFormula,a=NaN,c=b&&b.get("id"),g=this._cachedValues[c];if(g&&g.isValid){return g.value}try{a=f.evaluate({_case_:b,_id_:b&&b.get("id"),_collectionID_:this.getPath("collection.id")});if(g){g.isValid=true;g.value=a}else{this._cachedValues[c]={isValid:true,value:a}}}catch(d){a=d}return a},invalidateCases:function(b,c){var a=b&&b.length;if(a>0){b.forEach(function(f){var e=f&&f.get("id"),g=this._cachedValues[e];if(g){g.isValid=false}}.bind(this))}else{DG.ObjectMap.forEach(this._cachedValues,function(f,e){e.isValid=false})}if(c&&c.length){var d=this.getPath("_dgFormula.context");if(d){d.invalidateFunctions(c)}}},formulaDidChange:function(){var a=this.get("formula");if(!SC.empty(a)){if(!this._dgFormula){this.createDGFormula()}this._dgFormula.set("source",a);DG.ObjectMap.forEach(this._cachedValues,function(c,b){b.isValid=false})}else{if(this._dgFormula){this.destroyDGFormula()}this._cachedValues={}}this.set("deletedFormula","")}.observes("formula"),namespaceDidChange:function(){DG.ObjectMap.forEach(this._cachedValues,function(b,a){a.isValid=false})},dependentDidChange:function(a,b){this.notifyPropertyChange(b)},hasValues:function(){var d=false;var b=this.get("collection");if(b){var a=this.get("id"),c=b.get("cases");c&&c.forEach(function(e){var f=e.getValue(a);if((f==null)||(f==="")){return}if((typeof f==="number")&&!isFinite(f)){return}d=true}.bind(this))}return d}.property(),updateCategoryMap:function(){var h=["__order","stroke-color","stroke-transparency"];function f(i,j){var k=i.__order.slice();DG.ObjectMap.forEach(i,function(l,m){if(!h.includes(l)){if(SC.none(m)){i[l]=DG.ColorUtilities.kKellyColors[j];j=(j+1)%DG.ColorUtilities.kKellyColors.length}if(k.includes(l)){k.splice(k.indexOf(l),1)}else{i.__order.push(l)}}});k.forEach(function(l){i.__order.splice(i.__order.indexOf(l),1)})}var d=this.get("collection");if(d){var a=this.get("id"),g=d.get("cases"),b=this._categoryMap||{__order:[]},e=b.__order.length%DG.ColorUtilities.kKellyColors.length,c=new Set();f(b,e);g&&g.forEach(function(i){var j=i.getStrValue(a);if(SC.none(b[String(j)])){if(!SC.empty(j)){b[j]=DG.ColorUtilities.kKellyColors[e];e=(e+1)%DG.ColorUtilities.kKellyColors.length;b.__order.push(j)}}c.add(j)}.bind(this));if(!this._categoryMap){b.__order.sort(function(j,i){if(typeof j==="number"&&typeof i==="number"){return j-i}else{if(j<i){return -1}else{if(j>i){return 1}else{return 0}}}})}DG.ObjectMap.forEach(b,function(i){if(!h.includes(i)&&!c.has(i)){var j=b.__order.indexOf(i);b.__order.splice(j,1);b.__order.push(i)}});this.set("categoryMap",b)}},didLoadRecord:function(){var a=this.get("id");DG.Attribute.idMap[a]=this},toArchive:function(){return{name:this.get("name"),type:this.type,title:this.get("title"),cid:this.get("cid"),defaultMin:this.defaultMin,defaultMax:this.defaultMax,description:this.get("description"),_categoryMap:this._categoryMap?this.get("categoryMap"):undefined,blockDisplayOfEmptyCategories:this.blockDisplayOfEmptyCategories||undefined,editable:this.editable,hidden:this.hidden,renameable:this.renameable,deleteable:this.deleteable,formula:this.hasFormula()?this.formula:undefined,deletedFormula:this.hasDeletedFormula()?this.deletedFormula:undefined,guid:this.id,id:this.id,precision:this.precision,unit:this.unit}}});DG.Attribute.idMap={};DG.Attribute.getAttributeByID=function(a){return DG.Attribute.idMap[a]};DG.Attribute.createAttribute=function(c){var d=DG.store.resolve(c.collection),b,a;if(c.colormap){c.categoryMap=c.colormap;delete c.colormap}if(c._colormap){c._categoryMap=c._colormap;delete c._colormap}if(c.categoryMap){if(DG.ObjectMap.length(c.categoryMap)>0){c._categoryMap=c.categoryMap}delete c.categoryMap}if(!c.cid){c.cid=DG.DataUtilities.createUniqueID()}c.collection=d;b=DG.Attribute.create(c||{});if(c._categoryMap){a=SC.clone(c._categoryMap);if(c._categoryMap.__order){a.__order=SC.clone(c._categoryMap.__order)}else{a.__order=[];DG.ObjectMap.forEach(a,function(e){if(e!=="__order"&&!SC.empty(e)){a.__order.push(String(e))}})}b.set("categoryMap",a)}if(c.type&&c.type===DG.Attribute.TYPE_NOMINAL){c.type=DG.Attribute.TYPE_CATEGORICAL}DG.store.commitRecords();DG.Attribute.idMap[b.get("id")]=b;return b};DG.Attribute.extractUnitFromNameString=function(b){if(!b){return null}var a=/\(([^)]*)\)$/.exec(b.trim());if(a){return a[1]}else{return null}};DG.Attribute.canonicalizeName=function(b,d){var a=String(SC.none(b)?"":b),c=/\([^)]*\)$/;a=a.trim();if(d||((d==null)&&DG.canonicalizeNames)){a=a.replace(c,"");a=a.replace(/\W/g,"_")}if(a.length===0){a="attr"}return a};DG.Attribute.destroyAttribute=function(a){a.destroy()};DG.Attribute.TYPE_UNSPECIFIED="none";DG.Attribute.TYPE_NOMINAL="nominal";DG.Attribute.TYPE_CATEGORICAL="categorical";DG.Attribute.TYPE_NUMERIC="numeric";DG.Attribute.TYPE_DATE="date";DG.Attribute.TYPE_QUALITATIVE="qualitative";DG.Attribute.TYPE_BOUNDARY="boundary";DG.Attribute.TYPE_CHECKBOX="checkbox";DG.Attribute.attributeTypes=[DG.Attribute.TYPE_UNSPECIFIED,DG.Attribute.TYPE_CATEGORICAL,DG.Attribute.TYPE_NUMERIC,DG.Attribute.TYPE_DATE,DG.Attribute.TYPE_QUALITATIVE,DG.Attribute.TYPE_BOUNDARY,DG.Attribute.TYPE_CHECKBOX];DG.Attribute.DATE_PRECISION_NONE="";DG.Attribute.DATE_PRECISION_YEAR="year";DG.Attribute.DATE_PRECISION_MONTH="month";DG.Attribute.DATE_PRECISION_DAY="day";DG.Attribute.DATE_PRECISION_HOUR="hour";DG.Attribute.DATE_PRECISION_MINUTE="minute";DG.Attribute.DATE_PRECISION_SECOND="second";DG.Attribute.DATE_PRECISION_MILLISECOND="millisecond";DG.Attribute.datePrecisionOptions=[DG.Attribute.DATE_PRECISION_NONE,DG.Attribute.DATE_PRECISION_YEAR,DG.Attribute.DATE_PRECISION_MONTH,DG.Attribute.DATE_PRECISION_DAY,DG.Attribute.DATE_PRECISION_HOUR,DG.Attribute.DATE_PRECISION_MINUTE,DG.Attribute.DATE_PRECISION_SECOND,DG.Attribute.DATE_PRECISION_MILLISECOND];sc_require("models/model_store");sc_require("models/base_model");DG.Case=DG.BaseModel.extend((function(){function a(c,b){if(b&&(b.type==="date"&&(DG.isDate(c)))){return DG.formatDate(c,b.precision)}else{return(DG.isDate(c))?DG.formatDate(c):c}}return{revision:0,collection:null,parent:null,children:null,item:null,_cachedDate:null,_valuesMap:function(){return this.get("item").values}.property(),init:function(){arguments.callee.base.apply(this,arguments);this._cachedDate={};DG.Case._addCaseToItemMap(this);this.children=[];if(this.parent){this.parent.children.pushObject(this)}},verify:function(){if(SC.empty(this.collection)){DG.logWarn("Unattached case: "+this.id)}if(typeof this.collection==="number"){DG.logWarn("Unresolved reference to collection id, "+this.collection+", in case: "+this.id)}if(typeof this.get("parent")==="number"){DG.logWarn("Unresolved reference to parent, "+this.get("parent")+", in case: "+this.id)}},destroy:function(){DG.Case._removeCaseFromItemMap(this);arguments.callee.base.apply(this,arguments)},beginCaseValueChanges:function(){this.beginPropertyChanges()},endCaseValueChanges:function(){this.incrementProperty("revision");this.endPropertyChanges()},getRawValue:function(d){if(!SC.none(d)){var b=DG.Attribute.getAttributeByID(d);var e=this.get("_valuesMap");if(b&&b.get("hasFormula")&&(this.getPath("collection.id")===b.getPath("collection.id"))){return b.evalFormula(this)}if(b&&e&&(!SC.none(e[d]))&&(this.getPath("collection.id")===b.getPath("collection.id"))){return e[d]}var c=this.get("parent");if(c){return c.getRawValue(d)}}},getValue:function(c){var d=this.getRawValue(c);var b=DG.Attribute.getAttributeByID(c);return d!=null?a(d,b):d},getNumValue:function(d,c){var f=this.getRawValue(d),g=typeof f,b=DG.Attribute.getAttributeByID(d),e=b&&b.type;if(DG.isDate(f)){f=Number(f);g="number"}else{if(e==="date"){if(!this._cachedDate[d]){this._cachedDate[d]=DG.parseDate(f,true)}f=Number(this._cachedDate[d]);g="number"}else{if(DG.isDateString(f)){this._cachedDate[d]=DG.parseDate(f);f=Number(this._cachedDate[d]);g="number"}else{if(e==="numeric"){f=DG.MathUtilities.extractNumeric(f);g="number"}}}}if(c){c.type=g;c.isNominal=(g==="boolean")||((g==="string")&&!SC.empty(String(f)))}switch(g){case"number":return f;case"string":return(f!==""?Number(f):NaN)}return NaN},getForcedNumericValue:function(b){var c={},d=this.getNumValue(b,c);if(c.type==="number"){return d}else{return DG.MathUtilities.extractNumeric(this.getRawValue(b))}},getStrValue:function(c,b){var d=this.getValue(c),e=typeof d;if(b){b.type=e}return DG.DataUtilities.toString(d)},getTypedValue:function(c){var b=DG.Attribute.getAttributeByID(c);if(b){switch(DG.Attribute.getAttributeByID(c).get("type")){case"numeric":return this.getForcedNumericValue(c);case"date":return this.getValue(c);case"nominal":return this.getStrValue(c);default:return this.getRawValue(c)}}else{return this.getRawValue(c)}},hasValue:function(d){if(!SC.none(d)){var b=this.get("collection").getAttributeByID(d);if(b&&b.get("hasFormula")){return !SC.empty(this.getValue(d))}if(b){return this.get("_valuesMap")&&!SC.empty(this.get("_valuesMap")[d])}var c=this.get("parent");return c&&c.hasValue(d)}},setValue:function(c,d){var b=this.get("children");if(!this.get("_valuesMap")){return}this._cachedDate[c]=null;if(b.length===0){this.item.setValue(c,d)}else{b.forEach(function(e){e.setValue(c,d)})}},copyValues:function(){var d=this.get("_valuesMap"),c=this.collection.attrs,b={};c.forEach(function(e){b[e.name]=d[e.id]});return b},archivableValues:function(){var b={};var d=this.get("_valuesMap");var c=this.collection.attrs;c.forEach(function(e,f){b[e.name]=a(d[e.id])});return b}.property(),debugLog:function(b){DG.log("Case "+this.get("id"))},toArchive:function(){var b;b={parent:(this.get("parent")&&this.get("parent").id)||undefined,guid:this.id,id:this.id,itemID:this.item.id,values:this.get("archivableValues")};return b},isEmpty:function(){var d=this.get("collection");var b=d.get("attrs");var c=d.get("children")==null||d.get("children").length===0;c=c&&b&&!b.find(function(e){return this.hasValue(e.id)}.bind(this));return c}.property()}})());DG.Case._itemCaseMaps={};DG.Case._addCaseToItemMap=function(a){var c=a.getPath("collection.id"),d=a.getPath("item.id"),b=c&&DG.Case._itemCaseMaps[c];if(!SC.none(d)&&c){if(!b){DG.Case._itemCaseMaps[c]=b={}}b[d]=a}};DG.Case._removeCaseFromItemMap=function(a){var c=a.getPath("collection.id"),d=a.getPath("item.id"),b=c&&DG.Case._itemCaseMaps[c];if(!SC.none(d)&&b){delete b[d]}};DG.Case.findCase=function(c,b){var a=c&&DG.Case._itemCaseMaps[c];return a&&!SC.none(b)&&a[String(b)]};DG.Case.createCase=function(c){var d=c.collection,b=c.parent,a;c.collection=DG.store.resolve(d);if(!SC.empty(b)){c.parent=DG.store.resolve(b)}a=DG.Case.create(c||{});return a};DG.Case.destroyCase=function(a){a.destroy()};sc_require("models/attribute_model");sc_require("models/case_model");sc_require("react/dg-react");DG.React.ready(function(){var b=ReactDOMFactories.img,e=ReactDOMFactories.span,a=ReactDOMFactories.input,f=ReactDOMFactories.td;var c={displayName:"AttributeValueCell",propTypes:{attribute:PropTypes.instanceOf(DG.Attribute).isRequired,dataContext:PropTypes.instanceOf(DG.DataContext).isRequired,displayCase:PropTypes.instanceOf(DG.Case),editableCase:PropTypes.instanceOf(DG.Case),summaryCases:PropTypes.arrayOf(PropTypes.instanceOf(DG.Case)),deselectCallback:PropTypes.func.isRequired,forceUpdateCallback:PropTypes.func.isRequired,editProps:PropTypes.exact({isEditing:PropTypes.bool.isRequired,onToggleEditing:PropTypes.func.isRequired,onEscapeEditing:PropTypes.func.isRequired,onEditModeCallback:PropTypes.func.isRequired}).isRequired}};function d(k){function s(D){if(typeof D==="string"){D=D.toLowerCase()}return["","false","true",false,true,null].includes(D)||D===undefined}var B=function(G){function F(N){var M=N.target.checked,K=M?"checked":"unchecked";var J={operation:"updateCases",cases:[k.displayCase],caseIDs:[k.displayCase.get("id")],attributeIDs:[t.get("id")],values:[[M]]};k.dataContext.applyChange(J);D(K)}React.useEffect(function(){var K,J=(typeof G==="string")?G.toLowerCase():G;if(J&&J!=="false"){K="checked";E.current.checked=true;E.current.indeterminate=false}else{if(J===false){K="unchecked";E.current.checked=false;E.current.indeterminate=false}else{K="indeterminate";E.current.checked=false;E.current.indeterminate=true}}D(K)},[G,D]);var I=(t&&(t.formula||!t.editable)),E=React.useRef();var H=React.useState("indeterminate"),D=H[1];return e({className:"dg-checkbox-cell dg-wants-mouse dg-wants-touch"},a({type:"checkbox",disabled:I,onChange:F,ref:E}))};var t=k.attribute,j=t.get("id"),r=t.get("unit")||"",p=t.get("hasFormula"),l=k.displayCase&&k.displayCase.getValue(j),C=l&&l.jsonBoundaryObject?"boundary":t.get("type"),h,u,w,x,m,g,n,q,v="";if(C==="numeric"&&!DG.isNumeric(l)){l=k.displayCase&&k.displayCase.getForcedNumericValue(j)}if(l instanceof Error){l=l.name+l.message}else{if(DG.isColorSpecString(l)){m=tinycolor(l.toLowerCase().replace(/\s/gi,""));g={backgroundColor:m.toString("rgb")};h=e({className:"react-data-card-color-table-cell",style:g})}else{if(C==="qualitative"){if(SC.empty(l)){l=""}else{m=DG.PlotUtilities.kDefaultPointColor;g={backgroundColor:m,width:l+"%"};q=e({className:"react-data-card-qualitative-bar",style:g});u=e({className:"react-data-card-qualitative-backing"},q)}}else{if(C===DG.Attribute.TYPE_CHECKBOX&&s(l)&&!k.summaryCases){x=B(l,this)}else{if(C==="boundary"){var A="a boundary",y=DG.GeojsonUtils.boundaryObjectFromBoundaryValue(l),o=y&&y.jsonBoundaryObject&&y.jsonBoundaryObject.properties&&y.jsonBoundaryObject.properties.THUMB;if(o!==null&&o!==undefined){n=b({className:"react-data-card-thumbnail",src:o});w=e({},n)}else{if(y&&(y.jsonBoundaryObject instanceof Error)){l=y.jsonBoundaryObject.name+y.jsonBoundaryObject.message}}l=A}else{if(DG.isNumeric(l)&&typeof l!=="boolean"){var z=t.get("precision");z=SC.none(z)?2:z;l=DG.MathUtilities.formatNumber(l,z);v+=" react-data-card-numeric "}else{if(C==="date"&&!k.summaryCases){v+=" react-data-card-date "}else{if(SC.none(l)||(typeof l==="object")){l=""}}}}}}}}var i=k.summaryCases?DG.React.Components.AttributeSummary({cases:k.summaryCases,attr:t,unit:r}):DG.React.Components.TextInput({attr:t,"case":k.editableCase,value:l,unit:r,isEditable:t.get("editable")&&!t.get("hasFormula"),createInEditMode:k.editProps.isEditing,onToggleEditing:k.editProps.onToggleEditing,onEscapeEditing:k.editProps.onEscapeEditing,onEditModeCallback:k.editProps.onEditModeCallback});v+=p?"react-data-card-formula":"";if(h){i=h}else{if(x){i=x}else{if(w){i=w}else{if(u){i=u}}}}return(f({className:"dg-wants-touch "+v},i))}DG.React.AttributeValueCell=createReactFC(c,d)});DG.React.ready(function(){var f=ReactDOMFactories.div;function c(g){g.preventDefault();g.stopPropagation()}var d={displayName:"DragHandle",propTypes:{className:PropTypes.string,touchId:PropTypes.string,onUpdateDrag:PropTypes.func.isRequired,onEndDrag:PropTypes.func.isRequired}};function e(g){var h=DG.React.useDragOnDemand;h(g.touchId,g.onUpdateDrag,g.onEndDrag);return f({className:g.className})}DG.React.DragHandle=createReactFC(d,e);var a={displayName:"ColumnResizeHandle",propTypes:{containerWidth:PropTypes.number,columnWidth:PropTypes.number,minWidth:PropTypes.number.isRequired,onResize:PropTypes.func}};function b(s){var l=React.useState(false),n=l[0],j=l[1],t=DG.React.useRefState(null),q=t[0],i=t[1],m=t[2],u=React.useRef(),v=React.useRef();React.useLayoutEffect(function(){m(s.columnWidth)},[s.columnWidth,m]);function p(w){v.current=w.pageX-i.current;j(true)}function k(z){var y=z.pageX-v.current,w=s.minWidth||20,x=s.containerWidth-w;y=Math.max(y,w);y=Math.min(y,x);v.current=z.pageX-y;if(y!==i.current){s.onResize&&s.onResize(y);m(y)}}function o(){if(s.onResize){s.onResize(i.current,true)}j(false)}function g(w){if(!s.enabled||n||(w.button!==0)){return}p(w);c(w)}function r(w){if(!s.enabled||n){return}var x=w.changedTouches[0];u.current=x.identifier;p(x);c(w)}var h=q!=null?{left:q}:null;return((s.enabled||n)&&f({className:s.className+" column-resize-handle dg-wants-mouse dg-wants-touch",onMouseDown:g,onTouchStart:r,style:h},n&&DG.React.DragHandle({className:"column-resize-handle-render is-resizing",touchId:u.current,onUpdateDrag:k,onEndDrag:o})))}DG.React.ColumnResizeHandle=createReactFC(a,b)});DG.React.ready(function(){var b=ReactDOMFactories.span,a=ReactDOMFactories.input;DG.React.Components.TextInput=DG.React.createComponent((function(){return{inputElement:null,getInitialState:function(){return{editing:false,value:this.props.value,unit:this.props.unit}},componentDidMount:function(){window.addEventListener("touchstart",this._onWindowClick,true);window.addEventListener("mousedown",this._onWindowClick,true)},componentWillUnmount:function(){window.removeEventListener("touchstart",this._onWindowClick,true);window.removeEventListener("mousedown",this._onWindowClick,true)},UNSAFE_componentWillReceiveProps:function(c){if(c.value!==this.state.value){this.setState({value:c.value})}if(c.unit!==this.state.unit){this.setState({unit:c.unit})}if(c.createInEditMode&&c.onEditModeCallback){c.onEditModeCallback(this)}},componentDidUpdate:function(c){if(this.props.createInEditMode!==c.createInEditMode){this.setState({editing:this.props.createInEditMode})}},_onWindowClick:function(c){if(this.inputElement&&this.state.editing&&(c.target!==this.inputElement)&&!this.inputElement.contains(c.target)){this.props.onToggleEditing(this)}},handleChange:function(c){this.setState({value:c.target.value})},render:function(){var h=this,d=SC.empty(this.state.value)?"":" "+(this.state.unit||""),e=this.props.isEditable?"react-data-card-value ":"",g=SC.empty(this.state.value)?"____":this.state.value,c=[13,9],f=this.state.editing?a({className:"react-data-card-value-input dg-wants-mouse dg-wants-touch",type:"text",ref:function(i){h.inputElement=i;i&&i.focus()},value:this.state.value,onChange:this.handleChange,onKeyDown:function(i){if(c.indexOf(i.keyCode)>=0){this.props.onToggleEditing(this,i.shiftKey?"up":"down");i.preventDefault()}else{if(i.keyCode===27){this.props.onEscapeEditing(this)}}}.bind(this),onFocus:function(i){i.target.select()}}):b({className:e+(this.props.className||""),title:g,onClick:function(i){if(!this.state.editing&&this.props.onToggleEditing&&this.props.isEditable){this.props.onToggleEditing(this)}}.bind(this)},g+d);return f}}}()),[])});DG.DataContext=SC.Object.extend((function(){function a(c,d,b){var e=isNaN(c)?Number.MAX_SAFE_INTEGER:Math.round(c);return DG.MathUtilities.clipToIntegerRange(e,d,b+1)}return{type:"DG.DataContext",_managingControllerID:null,model:null,name:function(c,b){if(!SC.none(b)){this.setPath("model.name",b)}return this.getPath("model.name")}.property(),title:function(c,b){if(!SC.none(b)){this.setPath("model.title",b)}return this.getPath("model.title")}.property(),description:function(c,b){if(!SC.none(b)){this.setPath("model.description",b)}return this.getPath("model.description")}.property(),preventReorg:function(c,b){if(!SC.none(b)){this.setPath("model.preventReorg",b)}return this.getPath("model.preventReorg")}.property(),dependencyMgr:function(){return this.getPath("model.dependencyMgr")}.property(),changeCount:0,selectionChangeCount:0,metadataChangeCount:0,changes:null,flexibleGroupingChangeFlag:function(b,c){if(!SC.none(c)){this.setPath("model.flexibleGroupingChangeFlag",c)}return this.getPath("model.flexibleGroupingChangeFlag")}.property(),canonicalizeName:function(b){return DG.Attribute.canonicalizeName(b)},id:function(){return this.getPath("model.id")}.property("model"),collections:null,totalCaseCount:function(){var b=0;this.forEachCollection(function(c){b+=c.getPath("collection.cases").length});return b}.property("collectionCount"),allCases:function(){var b=[];this.forEachCollection(function(c){b=b.concat(c.getPath("collection.cases"))});return b}.property("collectionCount"),itemCount:function(){var b=this.get("dataSet");return b&&b.getDataItemCount()}.property(),dataSet:function(){return this.getPath("model.dataSet")}.property(),setAsideCount:function(){return this.get("dataSet").getSetAsideCount()}.property(),collectionsDidChange:function(){var e=this.getPath("model.collections"),g=DG.ObjectMap.values(e),d,f,b=g.length;this.collections=[];f=g[0];d=0;if(f){while(!SC.none(f.get("parent"))&&d<=b){f=f.get("parent");d++}if(d>b){DG.logError("Circular parental links among collections in context: "+this.name)}d=0;while(!SC.none(f)&&d<=b){this.collections.pushObject(f);f=f.get("children")[0];d++}if(d>b){DG.logError("Circular child links among collections in context: "+this.name)}}return this.collections}.observes("model.collectionsChangeCount"),_collectionClients:null,hasDataInteractive:function(){return !SC.none(this.get("owningDataInteractive"))}.property(),owningDataInteractive:function(){var d=DG.currDocumentController().get("dataInteractives");var b=this.get("id");var c=d&&DG.ObjectMap.values(d).find(function(f){var e=(f.getPath("context.id"));return(!SC.none(e)&&(e===b))}.bind(this));DG.assert(SC.none(c)||c.constructor===DG.GameController,"Found Game Controller");return c}.property(),managingController:function(b,c){if(c!=null){this._managingControllerID=c;this.incrementProperty("metadataChangeCount")}if(this._managingControllerID==null){return this.get("owningDataInteractive")}var d=DG.currDocumentController().get("dataInteractives");return d&&DG.ObjectMap.values(d).find(function(f){var e=(f.getPath("model.id"));return((e!=null)&&(e===this._managingControllerID))}.bind(this))}.property(),hasGameInteractive:function(){var c=this.get("owningDataInteractive");var b=c&&c.activeChannel();if(c){return SC.none(b)||(b.constructor===DG.GamePhoneHandler)}else{return false}}.property(),init:function(){arguments.callee.base.apply(this,arguments);this._collectionClients={};this.changes=[];this.collectionsDidChange();DG.globalsController.addObserver("globalNameChanges",this,"globalNamesDidChange");DG.globalsController.addObserver("globalValueChanges",this,"globalValuesDidChange")},destroy:function(){DG.globalsController.removeObserver("globalNameChanges",this,"globalNamesDidChange");DG.globalsController.removeObserver("globalValueChanges",this,"globalValuesDidChange");var c,b=this.get("collectionCount");for(c=0;c<b;++c){var d=this.getCollectionAtIndex(c);if(d){this.willRemoveCollection(d)}}this.model.destroy();arguments.callee.base.apply(this,arguments)},getSelectedCases:function(m){var e,h=this.get("collectionCount"),g={},j=[],k=[];function l(i){j.push(i);for(;i;i=i.get("parent")){g[i.get("id")]=true}}function b(n,i){if(!n.contains(i)&&!g[i.get("id")]){k.push(i)}}for(e=h-1;e>=0;--e){var f=this.getCollectionAtIndex(e),d=m&&f&&f.get("casesController"),c=f&&f.getPath("casesController.selection");if(c){c.forEach(l)}if(d){d.forEach(b.bind(null,c))}}return m?{selected:j,unselected:k}:j},getCaseByID:function(c){var b=DG.store.find(DG.Case,c);if(b&&b instanceof DG.Case){return b}},_changeCount:0,_prevChangeCount:0,lastChange:function(){var b=this.changes.length;return b>0?this.changes[b-1]:null}.property(),newChanges:function(){var b=this.changes&&this.changes.length,c=this._changeCount-this._prevChangeCount;DG.assert(this._changeCount<=b);DG.assert(this._prevChangeCount<=this._changeCount);return this.changes.slice(b-c)}.property(),applyChange:function(c){var d=this,b=this.performChange(c);c.result=DG.ObjectMap.join((c.result||{}),b);this.changes.push(c);++this._changeCount;SC.run(function(){d.invokeLast(function(){d.set("changeCount",d._changeCount);d._prevChangeCount=d._changeCount})});return c.result},performChange:function(e){if(e.isComplete){return{success:true}}var b={success:false},d=true,c=false;switch(e.operation){case"createCollection":b=this.doCreateCollection(e);break;case"updateCollection":b=this.doUpdateCollection(e);break;case"deleteCollection":b=this.doDeleteCollection(e);break;case"createCase":e.values=[e.values||[]];b=this.doCreateCases(e);if(b.caseIDs&&b.caseIDs.length){b.caseID=b.caseIDs[0]}c=true;break;case"createCases":b=this.doCreateCases(e);c=true;break;case"updateCases":b=this.doUpdateCases(e);break;case"moveCases":b=this.doMoveCases(e);break;case"deleteCases":b=this.doDeleteCases(e);d=false;break;case"selectCases":b=this.doSelectCases(e);d=false;break;case"createItems":b=this.doCreateItems(e);d=false;break;case"updateItems":b=this.doUpdateItem(e);d=false;break;case"moveItems":b=this.doMoveItems(e);d=false;break;case"deleteItems":b=this.doDeleteItems(e);d=false;break;case"createAttributes":b=this.doCreateAttributes(e);break;case"updateAttributes":b=this.doUpdateAttributes(e);break;case"unhideAttributes":case"hideAttributes":b=this.doChangeAttributesVisibility(e);break;case"deleteAttributes":b=this.doDeleteAttributes(e);break;case"moveAttribute":b=this.doMoveAttribute(e);d=false;break;case"resetCollections":b=this.doResetCollections(e);break;case"deleteDataContext":b=this.destroy();break;case"updateDataContext":b=this.doUpdateDataContext(e);break;default:DG.logWarn("DataContext.performChange: unknown operation: "+e.operation)}if(d&&(e.dirtyDocument!==false)){DG.dirtyCurrentDocument(this.get("model"),c)}return b},doCreateCollection:function(d){var c=this.guaranteeCollection(d.properties);var b;if(c){d.attributes&&d.attributes.forEach(function(e){if(!SC.none(e.id)&&!SC.none(e.collection)){this.moveAttribute(e,c)}else{c.guaranteeAttribute(e)}}.bind(this));d.attributes&&c.reorderAttributes(d.attributes.getEach("name"));b=this.regenerateCollectionCases();if(b){return{success:true,collection:c}}}return{success:false}},doUpdateCollection:function(d){var f=true;var c={};var b=["name","title"];var e=(SC.typeOf(d.collection)===SC.T_STRING)?this.getCollectionByName(d.collection):d.collection;DG.ObjectMap.forEach(d.properties,function(g,h){if(b.contains(g)){c[g]=h;e.set(g,h)}else{DG.logWarn('Attempt to update "%@" of collection %@[%@] not permitted.',g,e.get("name"),e.get("id"));delete d.properties.key}}.bind(this));return{success:f,properties:c}},doUpdateDataContext:function(d){var e=true;var c={};var b=["name","title","preventReorg"];DG.ObjectMap.forEach(d.properties,function(f,g){if(b.contains(f)){this.set(f,g);c[f]=g}else{DG.logWarn('Attempt to update "%@" of data context %@[%@] not permitted.',f,this.get("name"),this.get("id"));delete d.properties.key}}.bind(this));return{success:e,properties:c}},doCreateCases:function(g){function c(i){var k={};var j;if(g.properties){DG.ObjectMap.copy(k,g.properties)}if(Array.isArray(i)){j=h.createCase(k);if(j){h.setCaseValuesFromArray(j,i)}}else{k.values=i;j=h.createCase(k)}if(j){b.success=true;b.caseIDs.push(j.get("id"));b.itemIDs.push(j.item.id)}}var d=function(l,k){var i=true;var j=l.getParentCollectionID();if(j){i=!SC.none(this.getCaseByID(k));if(!i){DG.logWarn("Cannot create case with invalid or deleted parent: "+k)}}return i}.bind(this);var h,f,e=true,b={success:false,caseIDs:[],itemIDs:[]};if(!g.collection){g.collection=this.get("childCollection")}if(!g.collection.casesController){g.collection=g.collection.get("name")}if(typeof g.collection==="string"){h=this.getCollectionByName(g.collection);g.collection=h}else{h=g.collection}h.casesController.beginPropertyChanges();try{if(!g.properties){g.properties={}}if(typeof g.properties.parent!=="object"){e=d(h,g.properties.parent)}if(h&&e){f=g.values||[[]];f.forEach(c);if(b.caseIDs&&(b.caseIDs.length>0)){b.caseID=b.caseIDs[0]}if(b.itemIDs&&(b.itemIDs.length>0)){b.itemID=b.itemIDs[0]}}}finally{h.casesController.endPropertyChanges()}this.invalidateAttrsOfCollections([h],g);return b},doCreateItems:function(e){var d=this.addItems(e.items);if(!d){return{success:false}}var c=d.caseIDs;var b=d.itemIDs;return{success:true,caseIDs:c,itemIDs:b}},doUpdateItem:function(k){function i(n,o){return o.get("casesController").find(function(p){return p.item.id===n.id})}var b=k.items;if(b&&!Array.isArray(b)){b=[b]}var h=b.map(function(n){return this.updateItem(n.id,n.values)}.bind(this));var j=this.regenerateCollectionCases();var c=j&&j.deletedCases;var f=j&&j.createdCases;var d;var g;var e=[];var l=h.map(function(o){var n=i(o,this.getLastCollection());return n&&n.id}.bind(this));var m={success:true,changedCases:l,deletedCases:c,createCases:f};if(l&&l.length){this.applyChange({operation:"updateCases",collection:j.collection,isComplete:true,requester:k.requester,result:m});return m}if(c&&c.length){d=j.deletedCases.map(function(n){return n.id});this.applyChange({operation:"deleteCases",isComplete:true,requester:k.requester,result:{caseIDs:d}})}if(f&&f.length){f.forEach(function(o){var p=o.collection.get("id");var n=g[p];if(!n){e.push(o.collection);n=g[p]=[]}n.push(o.get("id"))});DG.dirtyCurrentDocument(this.get("model"),false);e.forEach(function(o){var n=g[o.get("id")];var p={operation:"createCases",collection:this.getCollectionByID(o.get("id")),isComplete:true,properties:{index:true},result:{caseIDs:n,caseID:n[0]}};this.applyChange(p)}.bind(this))}},doMoveItems:function(e){var d=this.get("dataSet");if(d&&e.items&&(e.itemOrder!=null)){var b=d.getClientIndexMapCopy();e.items.forEach(function(i,h){var g=Array.isArray(e.itemOrder)?e.itemOrder[h]:e.itemOrder;if(i.id){d.moveDataItemByID(i.id,g)}});var f=d.getClientIndexMapCopy();var c=!f.every(function(h,g){return b[g]===h});if(c){this.regenerateCollectionCases(null,"moveCases")}}},doDeleteItems:function(e){var d;var c=this.deleteItems(e.items);var b=this.regenerateCollectionCases();if(b){d=b.deletedCases.map(function(f){return f.id});this.applyChange({operation:"deleteCases",isComplete:true,requester:e.requester,result:{caseIDs:d}});return{deletedCaseIDs:d,deletedItemIDs:c&&c.map(function(f){return f.id})}}else{return{success:false}}},doSelectCases:function(p){var b=p.collection||this.get("childCollection"),q=b&&b.get("casesController"),l=p.extend||false,d={},o={},g=false,i=this;function f(r){var s=r.get("id").toString();if(d[s]===undefined){d[s]=true;return l}return true}function k(r,s){var t=r.get("id").toString();if(o[t]===undefined){o[t]={collection:r,cases:[]}}o[t].cases.push(s)}function h(){DG.ObjectMap.forEach(o,function(v,s){var r=s.collection,t=s.cases,u=r.get("casesController");u.selectObjects(t,f(r))})}function n(){DG.ObjectMap.forEach(o,function(v,s){var r=s.collection,t=s.cases,u=r.get("casesController");u.deselectObjects(t)})}function m(t){var s=t.get("children"),u=i.getCollectionForCase(t),v=u&&u.get("casesController");if(v){var r=v.get("selection");if(r&&(!r.contains(t)||(r.length()>1))){g=true}k(u,t);s.forEach(m)}}function c(t){var s=t.get("children"),u=i.getCollectionForCase(t),v=u&&u.get("casesController");if(v){var r=v.get("selection");if(r&&r.contains(t)){g=true}k(u,t);s.forEach(c)}}var e=p.cases||q,j=p.select?m:c;if(p.select&&!p.extend&&e.length===0){this.forEachCollection(function(r){var s=r.get("casesController");s.selectObject()});this.incrementProperty("selectionChangeCount");return{success:true}}else{if(e&&j){e.forEach(j);if(p.select){h()}else{n()}}}if(g){this.forEachCollection(function(s){var r=s.get("id"),t=s.get("casesController");if(r&&t&&!f(s)){t.selectObject()}});this.incrementProperty("selectionChangeCount")}return{success:true}},doUpdateCasesFromArrayOfValues:function(n){var d=n.cases.get("length"),e=n.attributeIDs?n.attributeIDs.get("length"):0,j=n.values.get("length"),o=[],f,k,h;if((d>0)&&(e===0)&&(j>0)){n.cases.forEach(function(c,p){if(c&&!c.get("isDestroyed")){this.setCaseValuesFromArray(c,n.values[p],n.collection)}}.bind(this));f=n.cases.map(function(c){return c.id});return{success:true,caseIDs:f}}n.caseIDs=[];for(k=0;k<e;++k){var m=n.attributeIDs.objectAt(k),g=this.getAttrRefByID(m);g.attributeID=m;o.push(g)}for(h=0;h<d;++h){var b=n.cases.objectAt(h);n.caseIDs.push(b.get("id"));b.beginCaseValueChanges();for(k=0;k<e;++k){b.setValue(o[k].attributeID,n.values[k][h])}b.endCaseValueChanges()}var l=false,i=o.map(function(p){var c=DG.Attribute.getAttributeByID(p.attributeID);if(!l&&c.getPath("collection.children")){l=true}return{type:DG.DEP_TYPE_ATTRIBUTE,id:p.attributeID,name:c.get("name")}});if(l){this.regenerateCollectionCases(null,"updateCases")}this.invalidateDependentsAndNotify(i,n);return{success:true,caseIDs:n.caseIDs}},doUpdateCasesFromHashOfNameValues:function(g){var f=g.cases;var h=true;var d={};var c=[];f.forEach(function(k,i){var j=g.values[i];c.push(k.id);if(j){k.beginCaseValueChanges();DG.ObjectMap.forEach(j,function(m,n){var l=this.getAttributeByName(m)||this.getAttributeByName(this.canonicalizeName(m));if(l){d[l.id]=l;k.setValue(l.id,n)}else{DG.logWarn("DataContext.doUpdateCasesFromHashOfNameValues: Cannot resolve attribute: "+m);h=false}}.bind(this));k.endCaseValueChanges()}}.bind(this));var b=[],e=false;DG.ObjectMap.forEach(d,function(j,i){if(!e&&i.getPath("collection.children")){e=true}b.push({type:DG.DEP_TYPE_ATTRIBUTE,id:i.id,name:i.get("name")})});if(e){this.regenerateCollectionCases(null,"updateCases")}this.invalidateDependentsAndNotify(b,g);return{success:h,caseIDs:c}},doUpdateCases:function(b){if(b.values&&b.values[0]&&Array.isArray(b.values[0])){return this.doUpdateCasesFromArrayOfValues(b)}else{return this.doUpdateCasesFromHashOfNameValues(b)}},doMoveCases:function(e){var d=e.cases;var c=d.length;var f=true;var b=[];d.forEach(function(h,i){var l=h.get("collection");var k=Array.isArray(e.caseOrder)?e.caseOrder[i]:e.caseOrder;var j=i<c-1;if(k==="first"){l.moveCase(h,0,j)}else{if(k==="last"){var g=l.getPath("cases.length");l.moveCase(h,g-1,j)}else{l.moveCase(h,k,j)}}b.push(h.id)});return{success:f,caseIDs:b}},deleteCasesAndChildren:function(e){var c=e.setAside;var d;var b={};function f(h){var g=h.get("children");var i=h.get("item");b[i.id]=i;if(g){g.forEach(f)}}if(e.cases){e.cases.forEach(f);this.deleteItems(Object.values(b),c);d=this.regenerateCollectionCases(null,"deleteCases")}return d.deletedCases},doDeleteCases:function(c){var d=[],e=this,b=this.collections;DG.UndoHistory.execute(DG.Command.create({name:"data.deleteCases",undoString:"DG.Undo.data.deleteCases",redoString:"DG.Redo.data.deleteCases",_beforeStorage:{context:this},execute:function(){d=e.deleteCasesAndChildren(c);e.invalidateAttrsOfCollections(e.collections,c);this._beforeStorage.deletedCases=d;this.log="Deleted %@ case%@".fmt(d.length,d.length===1?"":"s")},undo:function(){var f;b.forEach(function(h){this._beforeStorage.deletedCases.forEach(function(j,i){var k=j.item;var l=j.collection;if(l&&l===h){k.set("deleted",false);k.set("setAside",false)}})}.bind(this));f=this._beforeStorage.context.regenerateCollectionCases().createdCases;var g={};f.forEach(function(h){var i=h.getPath("collection.id");if(!g[i]){g[i]=[]}g[i].push(h.get("id"))});DG.ObjectMap.forEach(g,function(i,h){var j={operation:"createCases",isComplete:true,properties:{index:true},collections:[e.getCollectionByID(i)],result:{caseIDs:h,caseID:h[0]}};e.applyChange(j)});this._afterStorage={cases:f};e.invalidateAttrsOfCollections(e.collections,c)},redo:function(){this.execute()}}));return{success:true}},doCreateAttributes:function(e){var d=typeof e.collection==="string"?this.getCollectionByName(e.collection):e.collection,f=[],c=false,b={success:false,attrs:[],attrIDs:[]},h=this;function g(j){if(!j){return}var i=d.hasAttribute(j.name),l=DG.copy(j),k;if(!i){l.editable=true}k=d.guaranteeAttribute(l,e.isUndo);if(!SC.none(e.position)){h.moveAttribute(k,d,e.position)}if(k){if(!i){c=true}f.push(k.get("name"));b.success=true;b.attrs.push(k);b.attrIDs.push(k.get("id"))}}if(d&&e.attrPropsArray){e.attrPropsArray.forEach(g)}this.invalidateNamesAndNotify(f);if(!c){e.operation="updateAttributes"}return b},_handleAttrNameChange:function(b,d,f){var c=[];if(d==null||b.name===d){return}var e=this.get("dependencyMgr").findNode({type:DG.DEP_TYPE_ATTRIBUTE,id:b.id});if(e){var g=e.dependents;g.forEach(function(l){if(l.type==="attribute"){var i=this.getAttrRefByID(l.id);var h=i&&i.attribute;var m=h&&h._dgFormula;var k=m&&m.get("parsed");var j=k&&DG.Formula.toString(DG.Formula.renameVariable(k,b.name,d));if(j){c.push({operation:"updateAttributes",collection:h.collection,attrPropsArray:[{id:h.id,formula:j}]})}}}.bind(this))}return c},doUpdateAttributes:function(e){var f=typeof e.collection==="string"?this.getCollectionByName(e.collection):e.collection,d=[],b={success:false,attrs:[],attrIDs:[]};function c(h){var i=f&&!SC.none(h.id)?f.getAttributeByID(h.id):null;if(!i&&f&&h.name){i=f.getAttributeByName(h.name)}if(i){i.beginPropertyChanges();DG.ObjectMap.forEach(h,function(j,m){var l;var k;if(j==="name"){l=g._handleAttrNameChange(i,h.name,e);k=i.get("name");if(d.indexOf(k)<0){d.push(k)}m=DG.Attribute.canonicalizeName(m);if(d.indexOf(m)<0){d.push(m)}}if(j!=="id"){i.set(j,m)}if(l){l.forEach(function(n){g.applyChange(n)})}});i.endPropertyChanges();b.success=true;b.attrs.push(i);b.attrIDs.push(i.get("id"))}}var g=this;if(f&&e.attrPropsArray){e.attrPropsArray.forEach(c)}this.invalidateNamesAndNotify(d);return b},doRerandomizeAll:function(){var c=this.get("dependencyMgr"),b=c&&c.findNode({type:DG.DEP_TYPE_SPECIAL,id:"random"});this.invalidateDependentsAndNotify([b])},regenerateCollectionCases:function(i,e){var g=this.getCollectionAtIndex(0),d={},b,f=[];function c(l){var k=l&&l.get("id");if(k&&!d[k]){d[k]=l}var j=l&&l.get("children");if(j){j.forEach(function(m){c(m)})}}if(i&&i.length){i.forEach(function(j){c(j)})}this.forEachCollection(function(j){j.markCasesForDeletion()});this.forEachCollection(function(j){j.casesController.beginPropertyChanges()});try{b=g.get("collection").recreateCases()}finally{this.forEachCollection(function(j){j.casesController.endPropertyChanges()})}if(b){b.forEach(function(j){c(j.get("collection"))})}this.beginPropertyChanges();try{this.forEachCollection(function(k){var j=k.deleteMarkedCases();f=f.concat(j);if(f&&f.length){c(k)}}.bind(this))}finally{this.endPropertyChanges()}g.get("collection").reorderCases(0,[]);this.forEachCollection(function(j){j.didDeleteCases()});var h={collections:DG.ObjectMap.values(d),createdCases:b,deletedCases:f};if(e){h.operation=e;h.isComplete=true;h.result={caseIDs:b.map(function(j){return j.id})};this.applyChange(h)}return h},addItems:function(f,j){var b=this.getPath("model.dataSet");var g=Array.isArray(f)?f:(f?[f]:[]);var i=this.getAttributes();var c;var d=[];var e={};var h;g.forEach(function(m,l){var n=m instanceof DG.DataItem?m:DG.DataUtilities.canonicalizeAttributeValues(i,m);b.addDataItem(n,j)});c=this.regenerateCollectionCases();DG.assert(c&&(!c.deletedCases||c.deletedCases.length===0),"Unexpected deleted cases");c.createdCases.forEach(function(m){var n=m.collection.get("id");var l=e[n];if(!l){d.push(m.collection);l=e[n]=[]}l.push(m.get("id"))});DG.dirtyCurrentDocument(this.get("model"),false);if(c&&c.createdCases.length>0){d.forEach(function(m){var l=e[m.get("id")];h={operation:"createCases",collection:this.getCollectionByID(m.get("id")),isComplete:true,properties:{index:true},result:{caseIDs:l,caseID:l[0]}};this.applyChange(h)}.bind(this))}this.invalidateAttrsOfCollections(d,h);function k(){var m=[];var l=[];c.createdCases.forEach(function(n){m.push(n.id);l.push(n.item.id)});return{caseIDs:m,itemIDs:l}}return c&&k()},updateItem:function(d,b){var c=this.getPath("model.dataSet");return c.updateItem(d,b)},deleteItems:function(d,b){var c=this.getPath("model.dataSet");if(!Array.isArray(d)){d=[d]}d.forEach(function(e){if(!SC.none(e)){c.deleteDataItem(e,b)}else{DG.logWarn("Attempt to delete non-Item.")}});return d},_moveAttributeWithinCollection:function(j,k,h){var c=this;var b=j.name;var d=k.getAttributeNames();var f=d.indexOf(b);var e=a(h,0,d.get("length"));var l=this.get("flexibleGroupingChangeFlag");var m=d.slice();var g=(f>=e)?e:e-1;d.removeAt(f);d.insertAt(g,b);var i=d.slice();if(f!==-1){DG.UndoHistory.execute(DG.Command.create({name:"dataContext.moveAttribute",undoString:"DG.Undo.dataContext.moveAttribute",redoString:"DG.Redo.dataContext.moveAttribute",log:'move attribute {attribute: "%@", position: %@}'.loc(j.name,h),execute:function(){DG.log("Moving Attribute from: "+f+" to: "+g+" ("+e+")");k.reorderAttributes(i);c.set("flexibleGroupingChangeFlag",true)},undo:function(){DG.log("Undo move of Attribute from: "+f+" to: "+g+" ("+e+")");k.reorderAttributes(m);c.set("flexibleGroupingChangeFlag",l);var n={isComplete:true,operation:"moveAttribute",attr:j,toCollection:k,position:f};c.applyChange(n)},redo:function(){DG.log("Redo move of Attribute from: "+f+" to: "+g+" ("+e+")");k.reorderAttributes(i);c.set("flexibleGroupingChangeFlag",true);var n={isComplete:true,operation:"moveAttribute",attr:j,toCollection:k,position:h};c.applyChange(n)}}))}else{DG.logWarn('Reordering attribute, "'+b+'", not in collection, "'+k.get("name")+'"')}},_moveAttributeBetweenCollections:function(i,l,h,g){var b=this;var e=this.collections;var j={parent:l.parent,id:l.get("id"),name:l.get("name"),title:l.get("title"),context:l.get("context"),children:[l.children&&l.children[0]]};var k=i.get("id");var n=h.get("collection");DG.log("Moving attribute, "+i.get("name")+', from "'+l.get("name")+'" to "'+h.get("name")+'"');var f=l.get("attrs").findIndex(function(o){return o===i});var d=h.getAttributeCount();var c=a(g,0,d);DG.assert(f!==-1,"Moving attribute is found in original collection");var m;DG.UndoHistory.execute(DG.Command.create({name:"dataContext.moveAttribute",undoString:"DG.Undo.dataContext.moveAttribute",redoString:"DG.Redo.dataContext.moveAttribute",log:'move attribute {attribute: "%@", position: %@}'.loc(i.name,g),execute:function(){i.beginPropertyChanges();var o=i.collection;i=o.removeAttribute(i);if(o.get("attrs").length===0){b.destroyCollection(o);b.applyChange({operation:"deleteCollection",collection:l,isComplete:true})}n.addAttribute(i,c);m=b.regenerateCollectionCases([o,n]);b.invalidateAttrsOfCollections(m.collections);b.invalidateNamesAndNotify([i.name]);i.endPropertyChanges()},undo:function(){var o=DG.Attribute.getAttributeByID(k);var q=o.collection;var p;q.removeAttribute(o);if(q.get("attrs").length===0){b.destroyCollection(q);b.applyChange({operation:"deleteCollection",collection:q,isComplete:true})}e.forEach(function(s){m.deletedCases.forEach(function(u,t){var v=u.item;var w=u.collection;if(w&&w===s){v.set("deleted",false);w.addCase(u);DG.log("Adding case: "+u.id)}})});p=b.guaranteeCollection(j);b.applyChange({operation:"createCollection",collection:l,isComplete:true});p.get("collection").addAttribute(o,f);var r=b.regenerateCollectionCases([l,q]);b.invalidateAttrsOfCollections(r.collections);b.applyChange({operation:"resetCollections",isComplete:true})}.bind(this),redo:function(){this.execute();var o={isComplete:true,operation:"moveAttribute",attr:i,toCollection:h,position:g};b.applyChange(o);b.invalidateAttrsOfCollections(m.collections)}}))},moveAttribute:function(c,d,b){var e=c.get("collection");if(e===d.get("collection")){this._moveAttributeWithinCollection(c,d,b)}else{this._moveAttributeBetweenCollections(c,e,d,b)}},doMoveAttribute:function(h){try{var c=h.attr;var e=c.get("collection");var g=h.toCollection||e;var b=h.position;var d=(g.instanceOf(DG.CollectionClient))?g:this.getCollectionByID(g.id);this.moveAttribute(c,d,b);return{success:true}}catch(f){DG.logWarn(f);return{success:false}}},doChangeAttributesVisibility:function(d){var b={success:true,attrIDs:[]};function c(e,f){var g=e.attribute;if(g){g.set("hidden",f);b.attrIDs.push(e.id)}}d.attrs.forEach(function(e){c(e,d.operation==="hideAttributes")});return b},doDeleteAttributes:function(d){var f=typeof d.collection==="string"?this.getCollectionByName(d.collection):d.collection,c=[],b={success:true,attrIDs:[]};function g(h){var i=f&&!SC.none(h.id)?f.getAttributeByID(h.id):null;if(i){c.push({type:DG.DEP_TYPE_ATTRIBUTE,id:h.id});DG.Attribute.destroyAttribute(i);b.attrIDs.push(h.id)}}function e(){var h=c.length;var i=f&&f.getPath("collection.children");var k=!i||!i.get("length");var j=f.getAttributeCount();return f&&h&&(!k||!j)}if(f&&d.attrs){d.attrs.forEach(g);if(e()){this.regenerateCollectionCases()}this.invalidateDependentsAndNotify(c);DG.store.commitRecords()}return b},expungeCasesForChildCollection:function(){var f=this.childCollection();var e=f&&f.getParentCollectionID();var h=e&&this.getCollectionByID(e);var g=h.get("casesController");var b=g.map(function(i){return i.item.id});var d=this.get("dataSet").getDataItems();var c=d.filter(function(i){return !b.contains(i.id)});return this.deleteItems(c)},doDeleteCollection:function(e){var f=e.collection;var b;var c=this.get("collections").length;var d;if(c===1){return({success:false,values:{error:"cannot delete last collection"}})}if(!f.getPath("collection.children").length){d=this.expungeCasesForChildCollection()}this.destroyCollection(f);b=this.regenerateCollectionCases([f])||{};b.deletedItems=d;b.success=true;return b},doResetCollections:function(b){DG.store.destroyAllRecordsOfType(DG.Case);DG.store.destroyAllRecordsOfType(DG.Attribute);DG.store.destroyAllRecordsOfType(DG.CollectionRecord)},globalNamesDidChange:function(b,c){var d=b&&b.get(c),e=[];d.forEach(function(f){if(f.oldName&&(e.indexOf(f.oldName)<0)){e.push(f.oldName)}if(f.newName&&(e.indexOf(f.newName)<0)){e.push(f.newName)}});this.invalidateNamesAndNotify(e)},globalValuesDidChange:function(c,d){var e=c.get(d);if(e&&e.length){var b=[];e.forEach(function(g){var h=DG.globalsController.getGlobalValueByName(g),f=h&&h.get("id");if(h){b.push({type:DG.DEP_TYPE_GLOBAL,id:f,name:g})}});this.invalidateDependentsAndNotify(b)}},invalidateAttrsOfCollections:function(c,d){var b=[];if(!c||!c.length){return}c.forEach(function(g){var f=g instanceof DG.Collection?g:g.get("collection"),e=f&&f.get("attrs");if(e){e.forEach(function(h){b.push({type:DG.DEP_TYPE_ATTRIBUTE,id:h.get("id"),name:h.get("name")})})}});this.invalidateDependentsAndNotify(b,d)},invalidateNamesAndNotify:function(e){var d=this.get("dependencyMgr"),c=d.findNodesWithNames(e),b=d.findDependentsOfNodes(c);b.forEach(function(g){var f=g.dependencies&&g.dependencies[0],h=f&&f.dependentContext;if(h){h.invalidateNamespace()}});this.invalidateDependentsAndNotify(c)},invalidateDependentsAndNotify:function(c,d){var b=this.get("dependencyMgr").invalidateDependentsOf(c);this.notifyInvalidationResult(b,d)},invalidateDependencyAndNotify:function(c,d,e){var b=this.get("dependencyMgr").invalidateDependency(c,d,e);this.notifyInvalidationResult(b)},notifyInvalidationResult:function(c,k){var g=k&&k.collection,f=g&&g.get("id"),j=(k&&k.cases)||[],h,d,e=[];var b=function(q,p){var o={operation:"dependentCases",changes:[],isComplete:true},m=(p&&p.cases)||[],n={};q.forEach(function(v){var A=v.type,y=A===DG.DEP_TYPE_ATTRIBUTE?DG.Attribute.getAttributeByID(v.id):null,w,x,r,s=y&&y.get("collection"),t=s&&s.get("id"),z=t&&this.getCollectionByID(t),u,B=n[t];if(!z){w=s&&s.get("context");x=w&&w.get("id");r=DG.currDocumentController().getContextByID(x);z=r&&t&&r.getCollectionByID(t);if(e.indexOf(r)<0){e.push(r)}}if(!B){u=t===f?m:[];B=n[t]={dataContext:r||this,collection:z,attributeIDs:[v.id],cases:u}}else{B.attributeIDs.push(v.id)}}.bind(this));DG.ObjectMap.forEach(n,function(s,r){o.changes.push(r)});return o}.bind(this);if(!c.simpleDependencies.length&&!c.aggregateDependencies.length){}else{if(!k&&c.simpleDependencies.length){c.aggregateDependencies=c.aggregateDependencies.concat(c.simpleDependencies);c.simpleDependencies=[]}if(!g){var l,i;j.forEach(function(n){var m=n.get("collection"),o=m&&m.get("id");if(!i){l=m;i=o}else{if(o!==i){i=-1}}});if(i&&(i!==-1)){g=l;f=i}}if(c.simpleDependencies.length&&k&&(k.operation==="updateCases")){h=b(c.simpleDependencies,k)}if(c.aggregateDependencies.length){d=b(c.aggregateDependencies)}if(h){this.applyChange(h)}if(d){this.applyChange(d);e.forEach(function(m){m.applyChange(d)})}}},getLastCollection:function(){var c=this.get("collections");var b=c&&c[c.length-1];return b&&this.getCollectionByID(b.get("id"))},exportCaseData:function(c){function g(l){return(typeof l==="string")?l.replace(/\n/g,"&NewLine;").replace(/,/g,"&comma;"):l}function i(m){var l=""+(SC.none(m)?"":m);if(/.*[",].*/.test(m)){l='"'+l.replace(/"/g,'""')+'"'}return l}var h=",",k="\r\n",d,b,e,j=[],f=this.getPath("model.metadata");if(SC.empty(c)){return""}if(c==="DG.CaseTableController.allTables".loc()){d=this.getLastCollection();b=this.getAttributes()}else{d=this.getCollectionByName(c);b=d.attrsController}b=b.filter(function(l){return !l.hidden});e=b.map(function(l){return l.id});j.push("# name: "+g(this.get("name")));if(f){Object.entries(f).forEach(function(m){var l=m[0];var n=m[1];j.push("# "+l+": "+g(n))})}b.forEach(function(l){var n={type:"none",precision:2};var m=["name","description","type","unit","precision","editable","formula"].map(function(p){var o=l.get(p);if(o!=null&&o!==""&&(n[p]!==o)){return p+": "+g(o)}else{return""}}).filter(function(o){return(o!=="")});j.push("# attribute -- "+m.join(", "))});j.push(b.map(function(l){return i(l.name)}).join(h));d.forEachCase(function(l,m){var n=[];e.forEach(function(p){var o=l.getValue(p);if(o&&typeof o==="object"){if(typeof o.jsonBoundaryObject==="object"){o=o.jsonBoundaryObject}o=JSON.stringify(o)}n.push(i(o))});j.push(n.join(h))});return j.join(k)},collectionCount:function(){return this.getPath("collections.length")||0}.property(),childCollection:function(){var b=this.get("collectionCount");return(b?this.getCollectionAtIndex(b-1):null)}.property("_collectionClients"),parentCollection:function(){var b=this.get("collectionCount");return(b?this.getCollectionAtIndex(b-2):null)}.property("_collectionClients"),getCollectionAtIndex:function(c){var d=this.get("collections"),b=this.get("collectionCount"),e=(d&&(b>c)&&d.objectAt(c))||null;return e&&this._collectionClients[e.get("id")]},getCollectionByName:function(c){var b=this.get("collectionCount"),e=this.get("collections"),f;for(var d=0;d<b;++d){f=e.objectAt(d);if(f&&(f.get("name")===c)){return this._collectionClients[f.get("id")]}}return null},getCollectionByID:function(b){return this._collectionClients[b]||null},getCollectionForCase:function(b){return this.getCollectionByID(b.getPath("collection.id"))},getCollectionForAttribute:function(b){return this.getCollectionByID(b.getPath("collection.id"))},getParentCollection:function(c){var e=c&&c.get("id"),d=this.get("collectionCount"),h=this.get("collections"),j,g,b=null;for(var f=0;f<d;++f){j=h.objectAt(f);g=j.get("id");if(j&&(g===e)){return this.getCollectionByID(b)}b=g}return null},getChildCollection:function(c){var e=c&&c.get("id"),d=this.get("collectionCount"),h=this.get("collections"),j,g,b=null;for(var f=d-1;f>=0;--f){j=h.objectAt(f);g=j.get("id");if(j&&(g===e)){return this.getCollectionByID(b)}b=g}return null},createCollection:function(d){var b=d||{},c;b.context=this.get("model");c=this.addCollection(DG.Collection.createCollection(b));this.didCreateCollection(c);return c},destroyCollection:function(b){var c=b.get("id");this.willRemoveCollection(b);this._collectionClients[c].destroy();delete this._collectionClients[c]},didCreateCollection:function(b){},guaranteeCollection:function(c){var b=this.getCollectionByName(c.name);if(!b){b=this.createCollection(c)}return b},addCollection:function(c){function d(g){DG.logWarn("Instantiating collection from collectionRecord");return DG.Collection.create({collectionRecord:g})}var b=c&&c.get("id"),f=(b&&(c.type==="DG.CollectionRecord"))?d(c):c,e=f&&DG.CollectionClient.create({});if(e&&f&&b){e.setTargetCollection(f);this._collectionClients[b]=e;this.didAddCollection(e)}return e},didAddCollection:function(b){b.addObserver("caseIndices",this,"caseIndicesDidChange");b.addObserver("attrFormulaChanges",this,"attrFormulaDidChange")},willRemoveCollection:function(b){b.removeObserver("caseIndices",this,"caseIndicesDidChange");b.removeObserver("attrFormulaChanges",this,"attrFormulaDidChange")},caseIndicesDidChange:function(){var b=this.get("dependencyMgr").findNodesWithNames(["caseIndex"]);this.invalidateDependentsAndNotify(b)},attrFormulaDidChange:function(c,e){var f=c.get(e),g={operation:"updateCases",collection:c,attributeID:f,isComplete:true};this.applyChange(g);var b=DG.Attribute.getAttributeByID(f),d=[{type:DG.DEP_TYPE_ATTRIBUTE,id:f,name:b.get("name")}];this.invalidateDependentsAndNotify(d)},forEachCollection:function(c){var d=this,b=this.get("collections");b.forEach(function(f){var g=f.get("id"),e=d.getCollectionByID(g);if(e){c(e)}});return this},getCaseNameForCount:function(f,e){var d=f.get("collection"),c=d&&d.get("labels"),b=c?c.singleCase:d.get("caseName"),g=c?c.pluralCase:d.get("title");b=b||(g&&pluralize.singular(g));b=b||"DG.DataContext.singleCaseName".loc();g=g||"DG.DataContext.pluralCaseName".loc();return(e===1)?b:g},getCaseCountString:function(b,d){var c=this.getCaseNameForCount(b,d);return"DG.DataContext.caseCountString".loc(d,c)},getLabelForSetOfCases:function(b){return b.getPath("collection.collection.parent.caseName")||"DG.DataContext.setOfCasesLabel".loc()},getAttrRefByID:function(d){var e=this.get("collectionCount"),h=this.get("collections");for(var f=e-1;f>=0;--f){var j=h.objectAt(f),c=j&&this._collectionClients[j.get("id")],g=c&&c.getAttributeByID(d),b=g&&c.getAttributeIndexByName(g.get("name"));if(g){return{collection:c,attribute:g,position:b}}}return null},getAttrRefByName:function(e){var d=this.get("collectionCount"),h=this.get("collections");for(var f=d-1;f>=0;--f){var j=h.objectAt(f),c=j&&this._collectionClients[j.get("id")],g=c&&c.getAttributeByName(e),b=c&&c.getAttributeIndexByName(e);if(g){return{collection:c,attribute:g,position:b}}}return null},getAttributes:function(){var d=[];var c;var e;var b;for(c=0;c<this.get("collectionCount");c+=1){e=this.getCollectionAtIndex(c);b=e.get("attrsController");b&&b.forEach(function(f){d.push(f)})}return d},getNewAttributeName:function(){var b="DG.CaseTable.defaultAttrName".loc();return this.getUniqueAttributeName(b)},getUniqueAttributeName:function(d,b){var f=this.getAttributes().map(function(g){return g.get("name")}),c=this.canonicalizeName(d),e=1;while((f.indexOf(c)>=0)&&(!b||(b.indexOf(c)<0))){c=d+(++e)}return c},getAttributeByName:function(b){var c=this.getAttrRefByName(b);return c?c.attribute:null},getHiddenAttributes:function(){var b=[];this.getAttributes().forEach(function(c){if(c.get("hidden")){b.push(c)}});return b},setCaseValuesFromArray:function(d,b,c){var e=c||this.getCollectionForCase(d);if(e){e.setCaseValuesFromArray(d,b)}},collectionDefaults:function(){return{collectionClient:this.get("childCollection"),parentCollectionClient:this.get("parentCollection"),plotXAttr:null,plotXAttrIsNumeric:true,plotYAttr:null,plotYAttrIsNumeric:true}},willSaveContext:function(){var b=this.get("model");if(b){var c=this.createStorage()||{};b.set("contextStorage",c)}},toLink:function(){var b=this.get("model");return b&&b.toLink()},createStorage:function(){var b=this.getSelectedCases(false);var c={_links_:{}};c._links_.selectedCases=b.map(function(d){return d.toLink()});return c},restoreFromStorage:function(f){var e=this.get("collections");var b=f._links_;var d=b&&b.selectedCases;var c=[];if(!SC.none(e)){e.forEach(function(g){this.addCollection(g)}.bind(this))}if(d){c=d.map(function(g){return this.getCaseByID(g.id)}.bind(this))}this.invokeOnceLater(function(){this.applyChange({operation:"selectCases",select:true,cases:c})},200)},restoreSetAsideCases:function(){var b=this.get("dataSet").restoreSetAsideItems();var e=b.length;var c=this.regenerateCollectionCases(null,"createCases");this.invalidateAttrsOfCollections(this.collections,{operation:"createCases",cases:c.createdCases});DG.log("Restored "+e+' items in context "'+this.get("name")+'"');DG.log("Restored %@ cases".loc(c.createdCases&&c.createdCases.length));var d={operation:"selectCases",cases:c.createdCases,select:true,extend:false};this.applyChange(d)}}}()));DG.DataContext.registry={};DG.DataContext.registry["DG.DataContext"]=function(a){return DG.DataContext.create(a)};DG.DataContext.contextIDs=function(a){var b=DG.currDocumentController().contexts;return b&&b.map(function(c){return c.get("id")})};DG.DataContext.getContextFromCollection=function(b){var c=b&&b.get("collection"),a=c&&c.getPath("context.id");return a&&DG.currDocumentController().getContextByID(a)};DG.DataContext.collectionDefaults=function(){return{collectionClient:null,parentCollectionClient:null,plotXAttr:null,plotXAttrIsNumeric:true,plotYAttr:null,plotYAttrIsNumeric:true}};DG.DataContext.factory=function(c){var a=c&&c.type,b=a&&DG.DataContext.registry[a];return b?b(c):DG.DataContext.create(c)};sc_require("components/case_card/column_resize_handle");sc_require("components/case_card/text_input");sc_require("controllers/data_context");sc_require("react/dg-react");DG.React.ready(function(){var e=ReactDOMFactories.div,c=ReactDOMFactories.table,a=ReactDOMFactories.tbody,d=ReactDOMFactories.tr;var b=createReactClass((function(){var n=200,p=100,t=false,j,s,q=false,h=82;var m=0,f,r,i=false,l,g=false,o;var k=SC.Object.extend({dependent:null,_context:null,context:function(u,v){if(v&&v!==this._context){if(this._context){this._context.removeObserver("changeCount",this,this.contextDataDidChange)}this.guaranteeDataContextObserver(v);this._context=v}return this._context}.property(),init:function(){arguments.callee.base.apply(this,arguments)},destroy:function(){this.removeDataContextObserver(this.get("context"));this.dependent=null;arguments.callee.base.apply(this,arguments)},guaranteeDataContextObserver:function(u){if(!u.hasObserverFor("changeCount",this,this.contextDataDidChange)){u.addObserver("changeCount",this,this.contextDataDidChange)}},removeDataContextObserver:function(u){if(u){u.removeObserver("changeCount",this,this.contextDataDidChange)}},contextDataDidChange:function(x){var z=this;function v(){if(z.dependent){z.dependent.incrementStateCount()}}function u(){var A=Date.now();if(A-j>n){v();t=false;s.invalidate();s=null}else{s=SC.Timer.schedule({target:this,action:u,interval:p})}}function w(){if(q){q=false;v()}else{j=Date.now();if(!t){t=true;s=SC.Timer.schedule({target:this,action:u,interval:p})}}}function y(A){var B=A.map(function(C){return x.getCaseByID(C)}).filter(function(C){return !SC.none(C)});x.doSelectCases({operation:"selectCases",cases:B,select:true})}x.get("newChanges").forEach(function(A){switch(A.operation){case"selectCases":w();break;case"createCases":y(A.result.caseIDs);v();break;default:v()}}.bind(this))}});return{changeListener:null,currEditField:null,getInitialState:function(){return{count:0,attrIdOfNameToEdit:null,attrIdOfValueToEdit:null,columnWidths:{},resizeWidths:{}}},componentDidMount:function(){this.changeListener=k.create({dependent:this});this.changeListener.set("context",this.props.context)},componentDidUpdate:function(){this.changeListener.set("context",this.props.context)},componentWillUnmount:function(){this.changeListener.destroy();this.changeListener=null},handleColumnWidthChange:function(v,u){this.setState(function(w){if(u){w.columnWidths[v]=u}else{delete w.columnWidths[v]}return w})},handleUserResizeColumn:function(u,x,y){var v=x,w=this.props.size&&this.props.size.width;if(w){if((v<h)&&(w>=2*h)){v=h}if((w-v<h)&&(w>h+20)){v=w-h}}this.setState(function(A){var B;if(!y){if(v!==A.resizeWidths[u]){A.resizeWidths[u]=v;B=A}}else{if(A.resizeWidths[u]!==undefined){delete A.resizeWidths[u];B=A}var z=v/w;this.props.onResizeColumn&&this.props.onResizeColumn(u,z)}return B})},incrementStateCount:function(){this.setState({count:this.state.count+1})},stashEditValueInCaseAttributeValue:function(){if(this.currEditField){DG.DataContextUtilities.stashAttributeValue(this.props.context,this.currEditField.props["case"],this.currEditField.props.attr,this.currEditField.state.value);this.currEditField=null;this.setState({attrIdOfValueToEdit:null})}},renderCollectionHeader:function(v,w,x){var u=function(y){var z=w.get("collection"),B=z.get("parent"),A=DG.DataContextUtilities.createCollectionCommand(y,z,this.props.context,B);DG.UndoHistory.execute(A)}.bind(this);return DG.React.Components.CollectionHeader({index:v,collClient:w,caseID:x,onCollectionNameChange:function(z,y){SC.run(function(){DG.CaseDisplayUtils.setCollectionNameWithCommand(this.props.context,z,y)}.bind(this))}.bind(this),onNext:this.moveToNextCase,onPrevious:this.moveToPreviousCase,onDeselect:this.deselect,onNewCase:this.newCase,dragStatus:this.props.dragStatus,dropCallback:u})},renderAttribute:function(A,ak,G,T,y,X,R){function Q(ar){ar.preventDefault();ar.stopPropagation()}function P(ar){if(r){clearTimeout(r);r=null}ar&&DG.TouchTooltips.hideAllTouchTooltips()}function B(ar){i=true;l={x:ar.clientX,y:ar.clientY};g=false}function N(ar){if(!l){return}if(!g){u(ar)}else{o.handleDoDrag(ar.clientX-l.x,ar.clientY-l.y,ar.clientX,ar.clientY,ar)}}function ai(){f=null;r=null;i=false;l=null;g=false;o=null}function v(ar){P(true);if(ar.button!==0){return}B(ar)}function an(at){P(true);var ar=at.target,au=at.changedTouches[0];f=au.identifier;if(ar){r=setTimeout(function(){DG.TouchTooltips.showTouchTooltip(au,ar,ar.title);ai()},500)}B(at.changedTouches[0])}function C(ar){N(ar);g&&Q(ar)}function S(at){P();for(var ar=0;ar<at.touches.length;++ar){if(at.touches[ar].identifier===f){N(at.touches[ar]);g&&Q(at);return}}ai()}function al(){ai()}function Y(ar){if(i){if(!g){I(ar)}if(o){o.handleDoDrag(ar.clientX-l.x,ar.clientY-l.y,ar.clientX,ar.clientY,ar)}}}function I(ar){if(!g){o=DG.DragCaseCardItemHandler.create({viewToAddTo:DG.mainPage.docView,dataContext:A,attribute:T});o.handleStartDrag(ar);g=true}}function ad(ar){if(g){C(ar)}}function u(au){if(!l){return}var ar={x:au.clientX,y:au.clientY},at=(ar.x-l.x)*(ar.x-l.x)+(ar.y-l.y)*(ar.y-l.y);if(i&&at>m){I()}}var ac=function(ar){var av=this.props.dragStatus.dragObject.data.attribute,aw=y+(ar==="up"?0:1),au=av.get("collection");if(ak===au&&aw===au.get("attrs").indexOf(av)){return}var at={operation:"moveAttribute",attr:av,toCollection:ak,fromCollection:au,position:aw};A.invokeLater(function(){A.applyChange(at)})}.bind(this);var Z=function(){var at=this.props.dragStatus.dragObject.data.attribute,ar=A.getCollectionByID(ak.get("id"));if(at&&A&&ar&&T){A.invokeLater(function(){DG.DataContextUtilities.joinSourceToDestCollection(at,A,ar,T)})}}.bind(this);var E=function(ar){if(this.props.dragStatus.dragType==="ownContext"){ac(ar)}else{if(this.props.dragStatus.dragType==="foreignContext"){Z()}}}.bind(this);var ao=function(ax,at){var au=ak.get("attrs"),ar=this.currEditField;function ay(aA){var az;return(aA>=0)&&(aA<au.length)&&(az=au[aA])&&az.get("editable")&&!az.hasFormula()}this.stashEditValueInCaseAttributeValue();if(ar!==ax){this.currEditField=ax;this.setState({attrIdOfValueToEdit:T.get("id")})}else{if(at){var av,aw=y;switch(at){case"up":av=-1;break;case"down":av=1;break}aw+=av;while((aw>=0)&&(aw<au.length)&&!ay(aw)){aw+=av}if(ay(aw)){this.setState({attrIdOfValueToEdit:au[aw].get("id")})}}}}.bind(this);var K=function(ar){this.currEditField=null;this.setState({attrIdOfValueToEdit:null})}.bind(this);var z=function(ar){this.currEditField=ar}.bind(this);var D=function(ar){DG.DataContextUtilities.updateAttribute(A,ak,T,ar)},M=function(at){var au=T.get("name"),ar=A.getUniqueAttributeName(at,[au]);if(ar!==au){D({name:ar})}}.bind(this),W=function(){this.updateAttribute=function(at,au){D(au)};var ar=DG.AttributeEditorView.create({attrRef:{attribute:T},attrUpdater:this});ar.append()}.bind(this),ah=function(){A.invokeLater(function(){DG.DataContextUtilities.editAttributeFormula(A,ak,T.get("name"),T.get("formula"))},30)}.bind(this),w=function(){DG.DataContextUtilities.hideAttribute(A,T.get("id"))}.bind(this),F=function(){return T.get("collection").numberOfVisibleAttributes()>1}.bind(this),V=function(){DG.DataContextUtilities.deleteAttribute(A,T.get("id"))}.bind(this),aj=function(){DG.DataContextUtilities.deleteAttributeFormula(A,T.get("id"))}.bind(this),ag=function(){DG.DataContextUtilities.recoverAttributeFormula(A,T.get("id"))}.bind(this),J=function(){return T.get("editable")},O=function(){return DG.DataContextUtilities.attributeCanBeRandomized(A,T.get("id"))},aq=function(){DG.DataContextUtilities.randomizeAttribute(A,T.get("id"))},x=function(){var ar=!ak.get("parent");return !(ar&&DG.DataContextUtilities.isTopLevelReorgPrevented(A))},aa=function(){var au=A.getCollectionByID(ak.get("id")),ar=1,at=function(av){var ax=A.getAttrRefByName(av),aw=ax&&ax.attribute.get("id");aw&&this.setState({attrIdOfNameToEdit:aw})}.bind(this);DG.DataContextUtilities.newAttribute(A,au,ar,at)}.bind(this);var U=function(ar,at){if(at!==0){return}var au=this.state.resizeWidths[ar],av=this.props.size&&this.props.size.width;if(au&&av){return au/av}return this.props.columnWidthMap&&this.props.columnWidthMap[ar]}.bind(this);var af=ak.get("name"),ap=T.get("id"),am=X?null:(R&&R[0])||G[0],H=e({className:"react-data-card-attribute",title:DG.CaseDisplayUtils.getTooltipForAttribute(T),onMouseDown:v,onMouseUp:al,onMouseLeave:Y,onMouseMove:C,onTouchStart:an,onTouchMove:S,onTouchEnd:S,onTouchCancel:S},T.get("name")),ae=DG.React.AttributeNameCell({content:H,attribute:T,showNewAttrButton:(y===0)&&(ap!==this.state.attrIdOfNameToEdit),isEditing:ap===this.state.attrIdOfNameToEdit,dragStatus:this.props.dragStatus,dropCallback:E,onBeginRenameAttribute:function(){this.setState({attrIdOfNameToEdit:ap})}.bind(this),onEndRenameAttribute:function(ar){ar&&M(ar);this.setState({attrIdOfNameToEdit:null})}.bind(this),columnWidthPct:U(af,y),onColumnWidthChanged:(y===0)&&function(ar){this.handleColumnWidthChange(af,ar)}.bind(this),editAttributeCallback:W,editFormulaCallback:ah,attributeCanBeHiddenCallback:F,hideAttributeCallback:w,deleteAttributeCallback:V,deleteAttributeFormulaCallback:aj,recoverAttributeFormulaCallback:ag,attributeIsEditableCallback:J,attributeCanBeRandomizedCallback:O,rerandomizeCallback:aq,newAttributeCallback:x()?aa:null,cellLeaveCallback:ad}),ab=DG.React.AttributeValueCell({attribute:T,dataContext:this.props.context,displayCase:am,editableCase:X?null:G[0],summaryCases:X?G:null,deselectCallback:function(){SC.run(function(){if(this.props.isSelectedCallback()){this.props.context.applyChange({operation:"selectCases",select:false})}}.bind(this))}.bind(this),forceUpdateCallback:this.incrementStateCount,editProps:{isEditing:ap===this.state.attrIdOfValueToEdit,onToggleEditing:ao,onEscapeEditing:K,onEditModeCallback:z}});return(d({key:"attr-"+y,className:"react-data-card-row"},ae,ab))},moveToCase:function(x,w){q=true;var u=x.getCaseAt(w),v={operation:"selectCases",collection:x,cases:[u],select:true,extend:false};SC.run(function(){this.props.context.applyChange(v)}.bind(this))},getSelectedCaseFirstChildCaseID:function(w){var u,v=this.props.context;var x=v.getCollectionByID(w.get("id")).getPath("casesController.selection").toArray();if(x.length){u=x[0].get("children")[0].id}return u},getSelectedCaseIndices:function(w){var v=w.getPath("casesController.selection").toArray(),u=v.map(function(x){return{id:x.id,index:w.getCaseIndexByID(x.id)}});u.sort(function(y,x){return y.index-x.index});return u.map(function(x){return x.index})},moveToPreviousCase:function(y,x){this.stashEditValueInCaseAttributeValue();var A=null;var z=y.getPath("collection.parent");var w=y.getPath("collection.cases").length;if(SC.none(x)){if(z){var v=this.getSelectedCaseFirstChildCaseID(z);if(v){A=y.getCaseIndexByID(v)-1;if(A<0){A=w-1}}}else{var u=this.getSelectedCaseIndices(y);if(u.length){A=u[u.length-1]}}}if(SC.none(x)||x>1){if(SC.none(A)){A=SC.none(x)?w-1:x-2}this.moveToCase(y,A)}},moveToNextCase:function(z,y){this.stashEditValueInCaseAttributeValue();var A=z.getPath("collection.parent");if(SC.none(y)){if(A){var v=this.getSelectedCaseFirstChildCaseID(A);if(v){y=z.getCaseIndexByID(v)}}else{var u=this.getSelectedCaseIndices(z);if(u.length){y=u[0]}}}var x=z.getPath("collection.cases").length;if(SC.none(y)||y<x){var w=SC.none(y)?0:y;this.moveToCase(z,w)}},deselect:function(){SC.run(function(){this.props.context.applyChange({operation:"selectCases",select:false})}.bind(this))},newCase:function(A){var z=A.get("collection"),u=this.props.context,B=z&&z.getAttributeIDs(),x=this.props.context.getCollectionByID(z.getPath("parent.id")),w=x?x.getPath("casesController.selection").toArray():null,v=w?w.length:null,y=v===1?w[0]:null;SC.run(function(){DG.DataContextUtilities.createCaseUndoable(u,{collection:A,parent:y,attrIDs:B,values:[]})})},render:function(){function x(B){var D,z=B.get("collections"),C=z[0],y=0;while(C){var E=B.getCollectionByID(C.get("id")).getPath("casesController.selection").toArray(),A=E.length;if(A>0){D=E;C=z[++y]}else{if(A===0){C=z[++y]}}}return D}var v=[],u=this.props.context,w=x(u);u.get("collections").forEach(function(J,O){function H(S,U){var R=S.get("children");if(R&&R.length>0){if(R[0].get("collection")===U){return R}else{var T=[];R.forEach(function(V){T=T.concat(H(V,U))});return T}}return[]}function A(){var S=[],R=w&&w[0].get("collection");if(w&&w[0].get("collection").isDescendantOf(J)){J.get("cases").forEach(function(U){var T=H(U,R);if(T.some(function(V){return w.indexOf(V)>=0})){S.push(U)}})}return S}var B=u.getCollectionByID(J.get("id")),C=B.get("name"),Q=B?B.getPath("casesController.selection").toArray():null,P=Q?Q.length:0,I=P>0?Q:(w?A():J.get("cases")),F=I?I.length:0,D=P===1?Q[0]:(F===1?I[0]:null),N=SC.none(D),E=this.renderCollectionHeader(O,B,D&&D.get("id")),M=this.state.resizeWidths[C]||this.state.columnWidths[C],K=this.props.size&&this.props.size.width,y=[],G;J.get("attrs").forEach(function(R,S){if(!R.get("hidden")){y.push(this.renderAttribute(u,J,I,R,S,N,w))}}.bind(this));if(K&&M){var z="case-card-column-resize-handle";G=DG.React.ColumnResizeHandle({className:z,key:z+O+"-"+C,enabled:true,containerWidth:K,columnWidth:M,minWidth:h,onResize:function(R,S){this.handleUserResizeColumn(C,R,S)}.bind(this)})}v.push(e({className:"case-card-collection",key:"collection-"+O+"-"+C},c({},a({},E,y)),G))}.bind(this));return e({className:"react-data-card dg-wants-wheel",onMouseDownCapture:DG.Core.setClickHandlingForReact},v)}}}()),[]);b.displayName="CaseCard";b.propTypes={size:PropTypes.shape({width:PropTypes.number}),context:PropTypes.instanceOf(DG.DataContext).isRequired,dragStatus:PropTypes.object,columnWidthMap:PropTypes.objectOf(PropTypes.number).isRequired,isSelectedCallback:PropTypes.func.isRequired,onResizeColumn:PropTypes.func.isRequired};DG.React.CaseCard=createReactFactory(ReactSizeMe.withSize()(b))});DG.ComponentController=SC.Object.extend((function(){return{model:null,view:null,_oldLayout:null,_inspectorButtons:null,inspectorButtons:function(){if(!this._inspectorButtons){this._inspectorButtons=this.createInspectorButtons()}return this._inspectorButtons}.property("_inspectorButtons"),createInspectorButtons:function(){return[]},destroyInspectorButtons:function(){this._inspectorButtons.forEach(function(a){a.destroy()});this.set("_inspectorButtons",null)},specialTitleBarButtons:null,shouldConfirmClose:NO,shouldDestroyOnComponentDestroy:true,init:function(){arguments.callee.base.apply(this,arguments);this.set("specialTitleBarButtons",[])},willDestroy:function(){},destroy:function(){this.view=null;arguments.callee.base.apply(this,arguments)},addLink:function(b,c,a){DG.ArchiveUtils.addLink(b,c,a)},getLinkID:function(a,b){return DG.ArchiveUtils.getLinkID(a,b)},createComponentStorage:function(){return{title:this.getPath("model.title")}},restoreComponentStorage:function(a,d){var c=this.get("model"),e=a.title,b=a.name;c.set("title",e||b);if(b){c.set("name",b)}},willSaveComponent:function(){if(this.model){var a=this.createComponentStorage();if(a){this.model.set("componentStorage",a)}this.updateModelLayout()}},didRestoreComponent:function(b){var a=this.getPath("model.componentStorage");if(a){this.restoreComponentStorage(a,b)}},updateModelLayout:function(){var a=this.getPath("view.layout"),b=this.model.get("layout");if(a){a.isVisible=this.getPath("view.isVisible")}if(a&&(b&&JSON.stringify(a)!==JSON.stringify(b))){this.model.set("layout",a);return b}else{if(a&&!b){this.setPath("model.layout",a)}}return null},revertModelLayout:function(b){var a=this.model.get("layout");this.model.set("layout",b);this.model.set("oldLayout",a);this.setPath("view.layout",b);return a},willCloseComponent:function(){}}}()));sc_require("core");DG.ClipboardUtilities={foo:"bar"};DG.ClipboardUtilities.canCopy=function(){return !!(window.navigator.clipboard)};DG.ClipboardUtilities.canPaste=function(){return !!(window.navigator.clipboard&&window.navigator.clipboard.readText)};sc_require("controllers/component_controller");sc_require("utilities/clipboard_utilities");DG.CaseDisplayController=DG.ComponentController.extend((function(){return{dataContext:null,init:function(){arguments.callee.base.apply(this,arguments)},destroy:function(){arguments.callee.base.apply(this,arguments)},willDestroy:function(){arguments.callee.base.apply(this,arguments)},dataContextWasDeleted:function(){var b=this.get("view"),a=b.get("parentView");this.willCloseComponent();this.willSaveComponent();a.removeComponentView(b)},toggleViewVisibility:function(){},createComponentStorage:function(){},restoreComponentStorage:function(a,b){},createInspectorButtons:function(){var a=arguments.callee.base.apply(this,arguments);return a},createTrashButton:function(){return DG.IconButton.create({layout:{width:32},classNames:"dg-table-trash".w(),iconClass:"moonicon-icon-trash",showBlip:true,target:this,action:"showDeletePopup",toolTip:"DG.Inspector.delete.toolTip",localize:true})},createInfoButton:function(){return DG.IconButton.create({layout:{width:32},classNames:"dg-display-dataset-info".w(),iconClass:"moonicon-icon-info",showBlip:true,target:this,action:"showInfoPopup",toolTip:"DG.Inspector.datasetInfo.toolTip",localize:true})},createHideShowButton:function(){return DG.IconButton.create({layout:{width:32},classNames:"dg-display-hideshow".w(),iconClass:"moonicon-icon-hideShow",showBlip:true,target:this,action:"showHideShowPopup",toolTip:"DG.Inspector.hideShow.toolTip",localize:true})},createRulerButton:function(){return DG.IconButton.create({layout:{width:32},classNames:"dg-table-attributes".w(),iconClass:"moonicon-icon-values",showBlip:true,target:this,action:"showAttributesPopup",toolTip:"DG.Inspector.attributes.toolTip",localize:true})},createExportCaseButton:function(){return{title:"DG.Inspector.exportCaseData",localize:true,target:this,dgAction:"exportCaseData"}},createCopyToClipboardButton:function(){return{title:"DG.Inspector.copyCaseDataToClipboard",localize:true,isEnabled:DG.ClipboardUtilities.canCopy(),target:this,dgAction:"exportCaseDataToClipboard"}},createGetFromClipboardButton:function(){return{title:"DG.Inspector.getCaseDataFromClipboard",localize:true,isEnabled:DG.ClipboardUtilities.canPaste(),target:this,dgAction:"importCaseDataFromClipboard"}},createRandomizeButton:function(){var a=this.get("dataContext");return{title:"DG.Inspector.randomizeAllAttributes",localize:true,target:this,dgAction:"randomizeAllAttributes",isEnabled:!!(function(){var d=a&&a.get("dependencyMgr"),b=d&&d.findNode({type:DG.DEP_TYPE_SPECIAL,id:"random"}),c=b&&d.findDependentsOfNodes([b]);return c&&c.some(function(e){return e.type===DG.DEP_TYPE_ATTRIBUTE})}.bind(this))()}},showAttributesPopup:function(){},showDeletePopup:function(){function b(h,l){var k=l?l.length:0,j=l&&l.map(function(m){return DG.DataContextUtilities.isCaseEditable(h,m)}),i=j?j.reduce(function(m,n){return n?++m:m},0):0;return{count:k,deletable:i}}var g=this.get("dataContext"),d=g&&g.getSelectedCases(true),f=b(g,d.selected),c=b(g,d.unselected),a=[{title:"DG.Inspector.selection.selectAll",localize:true,target:this,action:"selectAll"},{title:"DG.Inspector.selection.deleteSelectedCases",localize:true,target:this,action:"deleteSelectedCases",isEnabled:f.deletable>0},{title:"DG.Inspector.selection.deleteUnselectedCases",localize:true,target:this,action:"deleteUnselectedCases",isEnabled:c.deletable>0},{title:"DG.Inspector.deleteAll",localize:true,target:this,action:"deleteAllCases",isEnabled:f.deletable+c.deletable>0}],e=DG.MenuPane.create({classNames:"dg-delete-popup".w(),layout:{width:200,height:150},items:a});e.popup(this.get("inspectorButtons")[0])},showInfoPopup:function(){var a=DG.DatasetMetadataView.create({dataContext:this.dataContext});a.append()},showHideShowPopup:function(){var a=this.get("dataContext"),f=a&&a.getSelectedCases(),e=f&&f.get("length")>0,h=a.get("totalCaseCount"),g=a.get("setAsideCount"),d=(h>0)&&(!f||f.get("length")<h),b=a.getHiddenAttributes().length,j=b===0?"DG.Inspector.attributes.showAllHiddenAttributesDisabled":(b===1?"DG.Inspector.attributes.showAllHiddenAttributesSing":"DG.Inspector.attributes.showAllHiddenAttributesPlural"),i=[{title:"DG.Inspector.setaside.setAsideSelectedCases",localize:true,target:this,action:"setAsideSelectedCases",isEnabled:e},{title:"DG.Inspector.setaside.setAsideUnselectedCases",localize:true,target:this,action:"setAsideUnselectedCases",isEnabled:d},{title:"DG.Inspector.setaside.restoreSetAsideCases".loc(g),localize:false,target:this,action:"restoreSetAsideCases",isEnabled:(g>0)},{title:j.loc(b),localize:false,target:this,action:"showAllHiddenAttributes",isEnabled:(b>0)}],c=DG.MenuPane.create({classNames:"dg-hideshow-popup".w(),layout:{width:200,height:150},items:i});c.popup(this.get("inspectorButtons")[0])},selectAll:function(){var a=this.get("dataContext"),c=a&&a.getCollectionAtIndex(0),b;if(c){b={operation:"selectCases",collection:c,cases:null,select:true}}a.applyChange(b)},deleteSelectedCases:function(){this._deleteOrSetAsideSelectedCases(false)},setAsideSelectedCases:function(){this._deleteOrSetAsideSelectedCases(true)},_deleteOrSetAsideSelectedCases:function(a){var b=this.get("dataContext"),e=b.getSelectedCases(),c=e.filter(function(f){return DG.DataContextUtilities.isCaseEditable(b,f)}),d;if(b&&c.length){d={operation:"selectCases",select:false,cases:c};b.applyChange(d);d={operation:"deleteCases",setAside:a,cases:c};b.applyChange(d)}},deleteUnselectedCases:function(){this._deleteOrSetAsideUnselectedCases(false)},setAsideUnselectedCases:function(){this._deleteOrSetAsideUnselectedCases(true)},_deleteOrSetAsideUnselectedCases:function(a){var b=this.get("dataContext"),d=b.getSelectedCases(true),c=d.unselected.filter(function(e){return DG.DataContextUtilities.isCaseEditable(b,e)});if(d.unselected.length){b.applyChange({operation:"deleteCases",setAside:a,cases:c})}},deleteAllCases:function(){var a=this.get("dataContext"),d=a.get("allCases"),b=d.filter(function(e){return DG.DataContextUtilities.isCaseEditable(a,e)});if(b.length){var c={operation:"deleteCases",cases:b};a.applyChange(c)}},restoreSetAsideCases:function(){var a=this.get("dataContext");a.restoreSetAsideCases()},showAllHiddenAttributes:function(){DG.DataContextUtilities.showAllHiddenAttributes(this.get("dataContext"))},randomizeAllAttributes:function(){var a=this.get("dataContext");if(a){a.doRerandomizeAll()}},_exportCaseData:function(c,b,a,e,h){function d(i){var j=[];i.forEachCollection(function(l){var k=l.get("name");j.push(k)});j.push("DG.CaseTableController.allTables".loc());return j}var g=d(c),f=g[0];if(g.length>2){DG.CreateExportCaseDataDialog({prompt:b,collectionMenuTitle:f,collectionMenuItems:g,collectionMenuItemAction:h,exportTitle:a,exportTooltip:e,cancelTitle:"DG.AppController.exportDocument.cancelTitle",cancelTooltip:"DG.AppController.exportDocument.cancelTooltip"})}else{h(g[1])}},exportCaseData:function(){var b=this.get("dataContext");var a=function(c){var d=b.exportCaseData(c);DG.exportFile(d,"csv","text/plain")};this._exportCaseData(b,"DG.AppController.exportCaseData.prompt","DG.AppController.exportDocument.exportTitle","DG.AppController.exportDocument.exportTooltip",a)},exportCaseDataToClipboard:function(){var b=this.get("dataContext");var a=function(g){function c(i){document.oncopy=function(k){k.preventDefault();var j=k.clipboardData;j.setData("text/plain",i);j.setData("text/csv",i)};document.execCommand("copy");SC.run(function(){DG.AlertPane.info({localization:true,message:f})});document.oncopy=null}function e(j,l){var m=(l==="DG.CaseTableController.allTables".loc());var n=m?j.get("childCollection"):j.getCollectionByName(l);var k=n.getCaseCount();var i=j.getCaseCountString(n,k);return"DG.Inspector.caseTable.exportCaseDialog.copiedData".loc(i)}var h=b.exportCaseData(g);var f=e(b,g);if(window.ClipboardItem){var d=new Blob([h],{type:"text/plain"});window.navigator.clipboard.write([new window.ClipboardItem({"text/csv":d,"text/plain":d})]).then(function(i){SC.run(function(){DG.AlertPane.info({localization:true,message:f})})},function(i){c(h)})}else{c(h)}};this._exportCaseData(b,"DG.Inspector.caseTable.exportCaseDialog.copyFrom","DG.Inspector.caseTable.exportCaseDialog.copy","DG.Inspector.caseTable.exportCaseDialog.copyTooltip",a)},importCaseDataFromClipboard:function(){var a=this.get("dataContext");var b=a&&a.get("name");window.focus();if(document.activeElement){document.activeElement.blur()}window.navigator.clipboard.readText().then(function(c){SC.run(function(){DG.appController.openCSVImporter({contentType:"text/csv",text:c,targetDatasetName:b,name:"clipboard",showCaseTable:false})})},function(c){console.log("Error importing from clipboard: ",c)})}}}()));sc_require("components/case_display_common/case_display_controller");DG.CaseCardController=DG.CaseDisplayController.extend({reactDiv:null,init:function(){arguments.callee.base.apply(this,arguments);this.get("specialTitleBarButtons").push(DG.CaseTableToggleButton.create())},destroy:function(){var a=this.get("dataContext");if(a&&a.removeObserver){a.removeObserver("changeCount",this,"handleDataContextChanges")}arguments.callee.base.apply(this,arguments)},dataContextDidChange:function(){var a=this.get("dataContext");if(a!==this._prevDataContext){if(this._prevDataContext){this._prevDataContext.removeObserver("changeCount",this,"handleDataContextChanges")}if(a){a.addObserver("changeCount",this,"handleDataContextChanges")}this._prevDataContext=a;DG.currDocumentController().tableCardRegistry.registerView(a,this.get("view"))}}.observes("dataContext","view"),handleDataContextChanges:function(){var a=this.getPath("dataContext.newChanges");var b=function(d){var c=d&&d.operation;switch(c){case"deleteDataContext":this.dataContextWasDeleted();break;default:}}.bind(this);if(a){a.forEach(function(c){b(c)})}},toggleViewVisibility:function(){var a=this.get("view"),c=a.get("isVisible")?"delete":"add",b="caseCardView";DG.UndoHistory.execute(DG.Command.create({name:"component.toggle.delete",undoString:"DG.Undo.toggleComponent."+c+"."+b,redoString:"DG.Redo.toggleComponent."+c+"."+b,log:"Toggle component: %@".fmt("caseCard"),execute:function(){var e=a.get("layout");a.set("savedLayout",e);var d=a.toggleProperty("isVisible");if(!d&&a.parentView&&a.parentView.select){a.parentView.select(null)}},undo:function(){this.execute()},redo:function(){this.execute()}}))},createInspectorButtons:function(){var a=arguments.callee.base.apply(this,arguments);a.push(this.createInfoButton());a.push(this.createTrashButton());a.push(this.createHideShowButton());a.push(this.createRulerButton());return a},showAttributesPopup:function(){var a=[];a.push(this.createRandomizeButton());a.push(this.createExportCaseButton());a.push(this.createCopyToClipboardButton());a.push(this.createGetFromClipboardButton());DG.MenuPane.create({classNames:"dg-attributes-popup".w(),layout:{width:200,height:150},items:a}).popup(this.get("inspectorButtons")[1])},createComponentStorage:function(){var e=this.getPath("model.content"),b=e.get("context"),d=e.get("isActive"),a=e.get("columnWidthMap"),f={isActive:d};if(b){this.addLink(f,"context",b)}if(a){var c={};DG.ObjectMap.forEach(a,function(g,h){c[g]=DG.MathUtilities.roundToDecimalPlaces(h,4)});f.columnWidthMap=c}return f},restoreComponentStorage:function(c,d){arguments.callee.base.apply(this,arguments);var e=this.getPath("model.content");if(e){var b=this.getLinkID(c,"context"),a=b&&DG.currDocumentController().getContextByID(b);if(a){e.set("context",a);this.set("dataContext",a)}e.set("isActive",c.isActive);if(c.columnWidthMap){e.set("columnWidthMap",SC.clone(c.columnWidthMap))}}}});DG.DataContextBaseModel=SC.Object.extend({context:null,id:null,idBinding:"*context.id",name:function(b,a){if(!SC.none(a)){this.context.applyChange({operation:"updateDataContext",properties:{name:a}})}return this.getPath("context.name")}.property(),title:function(b,a){if(!SC.none(a)){this.context.applyChange({operation:"updateDataContext",properties:{title:a}})}return this.getPath("context.title")}.property(),titleDidChange:function(){return this.notifyPropertyChange("title")}.observes("*context.title"),defaultTitle:function(){return this.getPath("context.defaultTitle")}.property(),defaultTitleDidChange:function(){return this.notifyPropertyChange("defaultTitle")}.observes("*context.defaultTitle")});sc_require("components/case_table/data_context_base_model");DG.CaseCardModel=DG.DataContextBaseModel.extend({columnWidthPct:null});DG.CaseCardView=SC.View.extend((function(){return{isDropTarget:true,model:null,context:function(){return this.getPath("model.context")}.property("model"),contextDidChange:function(){this.renderCard()}.observes("model.context"),isSelectedCallback:null,reactDiv:null,dragInProgress:false,classNames:"react-data-card-view".w(),classNameBindings:["dragInProgress"],_mouseYInDrag:0,_mouseHandlersInstalled:false,_scrollTimer:null,didAppendToDocument:function(){this.reactDiv=document.createElement("div");this.get("layer").appendChild(this.reactDiv);this.renderCard()},destroy:function(){DG.React.toggleRender(this.reactDiv);arguments.callee.base.apply(this,arguments)},viewDidResize:function(){arguments.callee.base.apply(this,arguments);this.reactDiv&&this.renderCard()},columnWidthDidChange:function(){this.renderCard()}.observes("*model.columnWidthMap"),resizeColumn:function(d,b){var a=this.getPath("model.columnWidthMap")||{},e=a[d];if(b===a[d]){return}var c=function(g,h){var f=SC.clone(this.getPath("model.columnWidthMap")||{});if(h){f[g]=h}else{delete f[g]}this.setPath("model.columnWidthMap",f)}.bind(this);DG.UndoHistory.execute(DG.Command.create({name:"caseCard.columnWidthChange",undoString:"DG.Undo.caseCard.columnWidthChange",redoString:"DG.Redo.caseCard.columnWidthChange",executeNotification:{action:"notify",resource:"component",values:{operation:"change column width",type:"DG.CaseCard"}},execute:function(){c(d,b);this.log="Change case card column width for collection '%@' to '%@'%".fmt(d,DG.MathUtilities.roundToDecimalPlaces(100*b,2))},undo:function(){c(d,e)},redo:function(){c(d,b)}}))},renderCard:function(a){var e=this;function d(){if(e._mouseHandlersInstalled){return}var f=e.get("layer"),g=false;f.addEventListener("mousedown",function(h){g=e.isSelectedCallback()});f.addEventListener("click",function(h){if(g&&!DG.Core.gClickWillBeHandledInReactComponent){SC.run(function(){e.get("context").applyChange({operation:"selectCases",select:false})})}g=false});e._mouseHandlersInstalled=true}function b(g,i){var f=g&&DG.MathUtilities.roundToDecimalPlaces(g,4),h=i&&DG.MathUtilities.roundToDecimalPlaces(i,4);return f!==h}var c=Object.assign({context:this.get("context"),columnWidthMap:this.getPath("model.columnWidthMap")||{},isSelectedCallback:this.isSelectedCallback,onResizeColumn:function(g,f,h){SC.run(function(){var i=this.getPath("model.columnWidthMap")||{},j=i[g];if(this.get("isVisible")&&!this.get("isAnimating")&&(f>0)&&(h||b(j,f))){this.resizeColumn(g,f,h)}}.bind(this))}.bind(this)},a||{});ReactDOM.render(DG.React.CaseCard(c),this.reactDiv);d()},touchStart:function(a){a.allowDefault();return YES},touchEnd:function(a){a.allowDefault();return YES},mouseDown:function(a){DG.globalEditorLock.commitCurrentEdit()},mouseWheel:function(a){return YES},isValidAttribute:function(c){var d=false,b=c.data.attribute,a=c.data.context;if(b&&a&&a===this.get("context")){d="ownContext"}else{if(a&&b){d="foreignContext"}}return d},canAcceptDrop:function(c){var d=false,b=this.get("context"),e=b.get("hasGameInteractive"),a=b.get("preventReorg");if(!a&&!e){d=true}return d},computeDragOperations:function(a){var b;if(this.isValidAttribute(a)&&this.canAcceptDrop(a)){b=SC.DRAG_LINK}else{b=SC.DRAG_NONE}return b},dragEntered:function(a,b){this.renderCard({dragStatus:{dragObject:a,event:b,dragType:this.get("dragType")}})},dragUpdated:function(f,a){function b(){if(e._mouseYInDrag<5&&g.scrollTop>0){g.scrollTop-=10}else{if(e._scrollTimer&&e._scrollTimer.isValid){e._scrollTimer.invalidate()}}}function j(){if(e._mouseYInDrag>c-10){g.scrollTop+=10}else{if(e._scrollTimer&&e._scrollTimer.isValid){e._scrollTimer.invalidate()}}}function d(k){if(!e._scrollTimer||!e._scrollTimer.isValid){e._scrollTimer=SC.Timer.schedule({target:e,action:k,interval:100,repeats:YES})}}var e=this,i=DG.ViewUtilities.windowToViewCoordinates({x:a.clientX,y:a.clientY},this),g=this.get("layer"),h=g.scrollTop,c=this.get("frame").height;this._mouseYInDrag=i.y;if(i.y<5&&h>0){d(b)}else{if(i.y>c-10){d(j)}}this.renderCard({dragStatus:{dragObject:f,event:a,dragType:this.get("dragType")}})},dragExited:function(a,b){this.renderCard({dragStatus:null})},acceptDragOperation:function(){return YES},dragStarted:function(b){var a=this.isValidAttribute(b);if(a&&this.canAcceptDrop(b)){this.set("dragInProgress",true);this.set("dragType",a)}},dragEnded:function(){if(this._scrollTimer&&this._scrollTimer.isValid){this._scrollTimer.invalidate()}this.set("dragInProgress",false);this.dragExited()},performDragOperation:function(a,b){this.renderCard({dragStatus:{dragObject:a,op:b,dragType:this.get("dragType")}})}}}()));DG.React.ready(function(){var b=ReactDOMFactories.tr,a=ReactDOMFactories.th,c=ReactDOMFactories.div;DG.React.Components.CollectionHeader=DG.React.createComponent((function(){return{domRow:null,getInitialState:function(){return{isEditingLabel:false}},render:function(){var g=this;function q(){var u;if(g.props.dragStatus&&g.props.dragStatus.dragType==="ownContext"&&g.props.dragStatus.event&&g.domRow){var t=g.props.dragStatus.event,r=t.clientX,v=t.clientY,s=g.domRow.getBoundingClientRect();u=r>=s.left&&r<s.right&&v>=s.top&&v<s.bottom}g.dragIsInMe=u;return u}function m(){if(g.dragIsInMe&&g.props.dragStatus&&g.props.dragStatus.op===SC.DRAG_LINK&&g.props.dropCallback){var r=g.props.dragStatus.dragObject.data.attribute,s=g.props.dropCallback;setTimeout(function(){SC.run(function(){s(r)})},0)}}var j=function(u,t,s){var v=u?u.getPath("casesController.selection").toArray().length:0,r=v>0?"DG.CaseCard.namePlusSelectionCount".loc(v,s,t):"DG.CaseCard.namePlusCaseCount".loc(s,t);return(c({className:"collection-label",onClick:function(){this.setState({isEditingLabel:true})}.bind(this)},r))}.bind(this);var k=function(r){return(DG.React.SimpleEdit({className:"collection-label",value:r,onCompleteEdit:function(s){if(s&&(s!==r)&&this.props.onCollectionNameChange){this.props.onCollectionNameChange(r,s)}this.setState({isEditingLabel:false})}.bind(this)}))}.bind(this);m();var l=this.props.collClient,h=this.props.caseID,p=this.props.index,e="collection-header-row"+(q()?" drop":""),d=l.get("collection"),f=d.get("name"),n=d.get("cases").length,o=SC.none(h)?null:d.getCaseIndexByID(h)+1,i=DG.React.Components.NavButtons({collectionClient:l,caseIndex:o,numCases:n,onPrevious:this.props.onPrevious,onNext:this.props.onNext,onNewCase:this.props.onNewCase,onDeselect:this.props.onDeselect});return(b({key:"coll-"+p,className:e,ref:function(r){this.domRow=r}.bind(this)},a({colSpan:2,style:{paddingLeft:(p*10+5)+"px"},className:"collection-header-cell"},c({className:"collection-header-contents"},this.state.isEditingLabel?k(f):j(l,f,n),c({className:"nav-header"},i)))))}}}()),[])});DG.DragCaseCardItemHandler=SC.Object.extend((function(){return{viewToAddTo:null,dragView:null,attribute:null,attributeName:function(){return this.getPath("attribute.name")}.property(),dataContext:null,receivedStartDrag:false,receivedDoDrag:false,handleStartDrag:function(b){var a=SC.LabelView.create({classNames:"dg-drag-label".w(),layout:{width:100,height:20,top:-100,left:0},value:this.get("attributeName")});this.set("dragView",a);SC.run(function(){if(a.isDescendantOf(this.viewToAddTo)){this.viewToAddTo.removeChild(a)}this.viewToAddTo.appendChild(a)}.bind(this));this.receivedStartDrag=true;this.receivedDoDrag=false},handleDoDrag:function(e,c,g,f,b){if(this.receivedStartDrag&&!this.receivedDoDrag){this.receivedDoDrag=true;var h=this.get("dragView"),d=this.get("attributeName"),i=this.get("attribute"),a=this.getPath("attribute.collection"),j=this.get("dataContext");if(!i){return}SC.run(function(){DG.Drag.start({event:b,source:this.viewToAddTo,dragView:h,ghost:YES,ghostActsLikeCursor:YES,slideBack:YES,origin:{x:b.clientX,y:b.clientY},data:{context:j,collection:a,attribute:i,text:d}})}.bind(this))}}}}()));DG.React.ready(function(){var a=ReactDOMFactories.div;DG.React.Components.DropdownContent=DG.React.createComponent((function(){return{getInitialState:function(){return{location:{left:-1000,top:-1000}}},render:function(){var c=this.props.children,b=this.props.location||this.state.location;return DG.React.Components.RenderInBody({},a({className:"dropdown__content dg-wants-touch",style:{left:b.left,top:b.top}},c))}}}()),[])});DG.React.ready(function(){var a=ReactDOMFactories.div;DG.React.Components.DropdownItem=DG.React.createComponent((function(){return{classNameDefault:"react-data-card-attribute-menu-item",render:function(){var b=this.classNameDefault+(this.props.disabled?" disabled":""),c=this.props.disabled?null:this.props.clickHandler;return a({className:b,onMouseDown:c,onTouchStart:c},this.props.children)}}}()),[])});DG.React.ready(function(){var b=ReactDOMFactories.a;DG.React.Components.DropdownTrigger=DG.React.createComponent((function(){return{render:function(){var d=this.props.children,a=this.props.className||"",c=Object.assign({},this.props);delete c.children;c.className="dropdown__trigger "+a;return b(c,d)}}}()),[])});DG.React.ready(function(){var a=ReactDOMFactories.div;DG.React.Components.Dropdown=DG.React.createComponent((function(){return{getInitialState:function(){return{active:false}},componentDidMount:function(){window.addEventListener("touchstart",this._onWindowClick,true);window.addEventListener("mousedown",this._onWindowClick,true)},componentWillUnmount:function(){window.removeEventListener("touchstart",this._onWindowClick,true);window.removeEventListener("mousedown",this._onWindowClick,true)},hide:function(){this.setState({active:false,location:null})},show:function(b){this.setState({active:true,location:b})},_onWindowClick:function(b){if(this.state.active&&!b.target.classList.contains("react-data-card-attribute-menu-item")&&!b.target.classList.contains("dropdown__content")){this.hide()}},_onToggleClick:function(b){b.preventDefault();if(this.state.active){this.hide()}else{this.show({left:b.clientX,top:b.clientY+12})}},render:function(){var e=this.props.className||"",g=this.props.disabled,f=this.state.active,d="dropdown"+(f?" dropdown--active":"")+(g?" dropdown--disabled":""),c=DG.React.Components.DropdownTrigger({},a({onClick:function(i){if(!g){this._onToggleClick(i)}}.bind(this)},this.props.trigger)),h=f?DG.React.Components.DropdownContent({location:this.state.location},this.props.menuItems):null,b=Object.assign({ref:function(i){this.props.onRefCallback(i)}.bind(this)},this.props);delete b.onRefCallback;delete b.trigger;delete b.menuItems;b.className=d+" "+e;return a(b,c,h)}}}()),[])});DG.React.ready(function(){var a=ReactDOMFactories.div;DG.React.Components.RenderInBody=DG.React.createComponent((function(){return{componentDidMount:function(){this.popup=document.createElement("div");document.body.appendChild(this.popup);this._renderLayer()},componentDidUpdate:function(){this._renderLayer()},componentWillUnmount:function(){ReactDOM.unmountComponentAtNode(this.popup);document.body.removeChild(this.popup)},_renderLayer:function(){ReactDOM.render(this.props.children,this.popup)},render:function(){return a({})}}}()),[])});DG.React.ready(function(){var b=ReactDOMFactories.br,a=ReactDOMFactories.button,c=ReactDOMFactories.span;DG.React.Components.NavButtons=DG.React.createComponent((function(){return{getPrevious:function(){this.props.onPrevious(this.props.collectionClient,this.props.caseIndex)},deselect:function(){this.props.onDeselect()},getNext:function(){this.props.onNext(this.props.collectionClient,this.props.caseIndex)},getNewCase:function(){this.props.onNewCase(this.props.collectionClient)},render:function(){var p=this.props.caseIndex,l=this.props.numCases,i=this.props.collectionClient?this.props.collectionClient.getPath("casesController.selection").toArray().length:0,n,m,r,h,g,f,d;if(!(l===0||(!SC.none(p)&&p<=1))){n=!SC.none(p)?"DG.CaseCard.navPrevCase":"DG.CaseCard.navLastCase";m=c({className:"moonicon-icon-reverse-play",style:{paddingRight:"4px"},onClick:this.getPrevious,title:n.loc()})}r=i===0?"DG.CaseCard.noDeselect":"DG.CaseCard.deselect";h=a({className:"dg-card-deselect",disabled:i===0,onClick:this.deselect,title:r.loc()});if(!(this.props.numCases===0||(!SC.none(p)&&p>=this.props.numCases))){g=!SC.none(p)?"DG.CaseCard.navNextCase":"DG.CaseCard.navFirstCase";f=c({className:"moonicon-icon-play",onClick:this.getNext,title:g.loc()})}else{f=c({className:"moonicon-icon-play",style:{color:"transparent",cursor:"default"}})}var q="DG.CaseCard.addCaseButton".loc(),o=q.indexOf(" "),j=o>=0?q.substring(0,o):q,k=o>=0?q.substring(o):"",e=c({},j,b(),k);d=a({className:"dg-floating-button-right",title:"DG.CaseCard.newCaseToolTip".loc(),onClick:this.getNewCase},e);return c({className:"nav-buttons dg-wants-touch"},m,h,f,d)}}}()),[])});sc_require("react/dg-react");(function(){var b=function(g){var f=React.useRef();React.useEffect(function(){f.current=g},[g]);return f.current};DG.React.usePrevious=b;var e=function(f){var h=React.useState(f),i=h[0],j=h[1],g=React.useRef(i);React.useEffect(function(){g.current=i},[i]);return[i,g,j]};DG.React.useRefState=e;var c=function(g,f){React.useEffect(function(){function h(i){var j=g.current;if(j&&(i.target!==j)&&!j.contains(i.target)){f(j)}}window.addEventListener("touchstart",h,true);window.addEventListener("mousedown",h,true);return function(){window.removeEventListener("touchstart",h,true);window.removeEventListener("mousedown",h,true)}},[])};DG.React.useCallbackOnOutsideEvent=c;var a=function(f){React.useEffect(function(){setTimeout(function(){var g=f.current;g&&g.focus();g&&g.select()})},[])};DG.React.useFocusSelectOnMount=a;var d=function(f,g,h){React.useEffect(function(){function k(l){g(l);stop(l)}function i(l){h();stop(l)}function j(m){for(var l=0;l<m.touches.length;++l){if(m.touches[l].identifier===f){g(m.touches[l]);return}}h()}if(f){document.addEventListener("touchstart",j,true);document.addEventListener("touchmove",j,true);document.addEventListener("touchcancel",j,true);document.addEventListener("touchend",j,true)}else{document.addEventListener("mousemove",k,true);document.addEventListener("mouseup",i,true)}return function(){if(f){document.removeEventListener("touchstart",j,true);document.removeEventListener("touchmove",j,true);document.removeEventListener("touchcancel",j,true);document.removeEventListener("touchend",j,true)}else{document.removeEventListener("mousemove",k,true);document.removeEventListener("mouseup",i,true)}}},[f])};DG.React.useDragOnDemand=d})();sc_require("react/dg-react");sc_require("react/custom_hooks");DG.React.ready(function(){var e=DG.React.useCallbackOnOutsideEvent,a=DG.React.useFocusSelectOnMount,b=ReactDOMFactories.input;var c={displayName:"SimpleEdit",propTypes:{className:PropTypes.string,value:PropTypes.string,onCompleteEdit:PropTypes.func.isRequired}};function d(i){var h=React.useRef();e(h,function(j){j.blur()});a(h);function g(){i.onCompleteEdit()}function f(j){i.onCompleteEdit(j!==i.value?j:undefined)}return b({className:i.className+" dg-wants-mouse dg-wants-touch",type:"text",ref:h,defaultValue:i.value||"",onKeyDown:function(j){var k=true;switch(j.keyCode){case 27:g();break;case 13:f(j.target.value);break;default:k=false;break}if(k){j.preventDefault();j.stopPropagation()}},onBlur:function(j){f(j.target.value)}})}DG.React.SimpleEdit=createReactFC(c,d)});DG.CaseDisplayUtils={getTooltipForAttribute:function(b){var a=b.get("name"),d=b.get("unit"),c=b.get("description"),e=b.get("formula");if(!c&&!e){return d?"DG.CaseCard.attrHintUnitsOnly".loc(a,d):"DG.CaseCard.attrHintPlain".loc(a)}if(!e){return"DG.CaseCard.attrHintDescription".loc(a,c)}if(!c){return"DG.CaseCard.attrHintFormula".loc(a,e)}return"DG.CaseCard.attrHintDescriptionAndFormula".loc(a,c,e)},setCollectionNameWithCommand:function(c,b,a){function d(g,f){var e=c.getCollectionByName(g);if(e){c.applyChange({operation:"updateCollection",collection:e,properties:{name:f}})}}DG.UndoHistory.execute(DG.Command.create({name:"caseTable.collectionNameChange",undoString:"DG.Undo.caseTable.collectionNameChange",redoString:"DG.Redo.caseTable.collectionNameChange",execute:function(){d(b,a);this.log="Change collection name from '%@' to '%@'".fmt(b,a)},undo:function(){d(a,b)},redo:function(){d(b,a)}}))}};DG.PickerTitleView=SC.View.extend({iconURL:null,title:null,layout:{height:26,right:0},childViews:"iconView titleView".w(),iconView:SC.ImageView.extend({classNames:"dg-inspector-picker-icon".w(),layout:{width:18,height:18}}),titleView:SC.LabelView.extend({classNames:"dg-inspector-picker-title".w(),layout:{left:27},localize:true}),init:function(){arguments.callee.base.apply(this,arguments);this.setPath("iconView.value",this.get("iconURL"));this.setPath("titleView.value",this.get("title"))}});DG.PickerControlView=SC.View.extend({label:null,toolTip:null,toolTipDidChange:function(){this.setPath("labelView.toolTip",this.get("toolTip"))}.observes("toolTip"),childViews:"labelView controlView".w(),labelView:SC.LabelView.extend({classNames:"dg-inspector-picker-tag".w(),localize:true}),controlView:null,init:function(){arguments.callee.base.apply(this,arguments);var a=this.get("controlView");if(a){a.adjust("right",10)}this.setPath("labelView.value",this.get("label"));this.setPath("labelView.toolTip",this.get("toolTip"))}});sc_require("views/inspector/picker_title_view");sc_require("views/inspector/picker_control_view");DG.DatasetMetadataView=SC.PalettePane.extend((function(){var c=5;var f=290;var g=200;var h=90;var i=f;var j=310;var d=26;var a=20;var l=a-2;var e=l+6;var b=l+10;var k=8;return{dataContext:null,buttonIconClass:"moonicon-icon-styles",classNames:"dg-inspector-picker".w(),layout:{width:f,height:j,centerX:0,centerY:0},isModal:true,contentView:SC.View.extend(SC.FlowedLayout,{layoutDirection:SC.LAYOUT_VERTICAL,isResizable:false,isClosable:false,defaultFlowSpacing:{left:0,right:0,bottom:c},canWrap:false,align:SC.ALIGN_TOP,childViews:["title","nameCtl","urlCtl","creationDateCtl","descriptionCtl","applyOrCancelCtl"],title:DG.PickerTitleView.extend({layout:{height:d,width:f},flowSpacing:{left:0,right:0,bottom:c},title:"DG.TableController.datasetMetadata.title",localize:true}),nameCtl:DG.PickerControlView.design({layout:{height:a},label:"DG.CaseTable.attributeEditor.name",localize:true,toolTip:"DG.TableController.attrEditor.nameHint",controlView:SC.TextFieldView.extend({layout:{centerY:0,width:g,height:l},backgroundColor:"white"})}),urlCtl:DG.PickerControlView.design({layout:{height:a},label:"DG.CaseTable.datasetMetadata.url",localize:true,toolTip:"DG.TableController.datasetMetadata.urlHint",controlView:SC.TextFieldView.extend({layout:{centerY:0,width:g,height:l},backgroundColor:"white"})}),creationDateCtl:DG.PickerControlView.design({layout:{height:a},label:"DG.CaseTable.datasetMetadata.creationDate",localize:true,toolTip:"DG.TableController.datasetMetadata.creationDateHint",controlView:SC.TextFieldView.extend({layout:{centerY:0,width:g,height:l},backgroundColor:"white"})}),descriptionCtl:DG.PickerControlView.design({layout:{height:a*k},label:"DG.CaseTable.attributeEditor.description",localize:true,controlView:SC.TextFieldView.extend({layout:{centerY:0,width:g,height:l*k},isTextArea:true,backgroundColor:"white",hint:"DG.TableController.datasetMetadata.descriptionHint",localize:true})}),applyOrCancelCtl:SC.View.design(SC.FlowedLayout,{layoutDirection:SC.LAYOUT_VERTICAL,defaultFlowSpacing:5,align:SC.ALIGN_CENTER,layout:{width:i,height:b},childViews:"cancel apply".w(),cancel:SC.ButtonView.design({layout:{width:h,height:e},titleMinWidth:0,title:"DG.AttrFormView.cancelBtnTitle",target:null,action:"close",toolTip:"DG.AttrFormView.cancelBtnTooltip",localize:true,isCancel:true}),apply:SC.ButtonView.design({layout:{width:h,height:e},titleMinWidth:0,title:"DG.AttrFormView.applyBtnTitle",target:null,action:"update",toolTip:"",localize:true,isDefault:true})})}),dataContextDidChange:function(){var m=this.get("dataContext");var n=m.getPath("model.metadata")||{};var p=n.importDate;if(DG.DateUtilities.isDate(p)||DG.DateUtilities.isDateString(p)){p=DG.DateUtilities.formatDate(p,DG.Attribute.DATE_PRECISION_MINUTE)}var o=this.get("contentView");if(m){o.setPath("nameCtl.controlView.value",m.get("title"));o.setPath("urlCtl.controlView.value",n.source);o.setPath("creationDateCtl.controlView.value",p);o.setPath("descriptionCtl.controlView.value",n.description)}}.observes("dataContext"),update:function(){var m=this.get("dataContext");var n=m.getPath("model.metadata")||{};var o=this.get("contentView");m.set("title",o.getPath("nameCtl.controlView.value"));n.source=o.getPath("urlCtl.controlView.value");n.importDate=o.getPath("creationDateCtl.controlView.value");n.description=o.getPath("descriptionCtl.controlView.value");m.setPath("model.metadata",n);DG.log("setting metadata: "+JSON.stringify(n));this.close()},close:function(){DG.log("Closing Attribute Editor");this.remove();this.destroy()},init:function(){arguments.callee.base.apply(this,arguments);if(this.get("dataContext")){this.dataContextDidChange()}}}}()));DG.TableCardRegistry=SC.Object.extend({contextCardMap:null,contextTableMap:null,init:function(){this.contextCardMap={};this.contextTableMap={}},reset:function(){this.contextCardMap={};this.contextTableMap={}},registerView:function(a,c){var b=(typeof a==="object")?a.get("id"):a;if(b!=null&&c){var d=c.get("contentView");if(c&&d instanceof DG.HierTableView){this.contextTableMap[b]=c}else{if(c&&d instanceof DG.CaseCardView){this.contextCardMap[b]=c}else{DG.log("TableCardRegistry: unrecognized view")}}}else{DG.log("TableCardRegistry: Context: no id")}},deregisterViews:function(a){var b=(typeof a==="object")?a.get("id"):a;delete this.contextCardMap[b];delete this.contextTableMap[b]},getViewForContext:function(b){var d=(typeof b==="object")?b.get("id"):b;var e=this.contextCardMap[d];var a=this.contextTableMap[d];var c=(e&&e.getPath("model.content.isActive"))?e:(a&&a.getPath("model.content.isActive"))?a:null;return c},getTableView:function(a){var b=(typeof a==="object")?a.get("id"):a;return this.contextTableMap[b]},getCardView:function(a){var b=(typeof a==="object")?a.get("id"):a;return this.contextCardMap[b]},getActiveViewTypeForContext:function(a){var b=this.getViewForContext(a);if(b){return b.getPath("model.type")}}});sc_require("models/attribute_model");sc_require("views/inspector/picker_title_view");sc_require("views/inspector/picker_control_view");DG.AttributeEditorView=SC.PalettePane.extend((function(){var d=20;var e=d-2;var c=26;var b=140;var a=10;var f=5;return{attrRef:null,attrUpdater:null,buttonIconClass:"moonicon-icon-styles",classNames:"dg-inspector-picker".w(),layout:{width:250,height:280,centerX:0,centerY:0},isModal:true,contentView:SC.View.extend(SC.FlowedLayout,{layoutDirection:SC.LAYOUT_VERTICAL,isResizable:false,isClosable:false,defaultFlowSpacing:{left:a,right:a,bottom:f},canWrap:false,align:SC.ALIGN_TOP,layout:{right:5},childViews:["title","nameCtl","descriptionCtl","typeCtl","unitCtl","precisionCtl","editableCtl","applyOrCancelCtl"],title:DG.PickerTitleView.extend({layout:{height:c},flowSpacing:{left:0,right:0,bottom:f},title:"DG.TableController.attributeEditor.title",localize:true}),nameCtl:DG.PickerControlView.design({layout:{height:d},label:"DG.CaseTable.attributeEditor.name",localize:true,toolTip:"DG.TableController.attrEditor.nameHint",controlView:SC.TextFieldView.extend({layout:{centerY:0,width:b,height:e},backgroundColor:"white"})}),descriptionCtl:DG.PickerControlView.design({layout:{height:d*4},label:"DG.CaseTable.attributeEditor.description",localize:true,controlView:SC.TextFieldView.extend({layout:{centerY:0,width:b,height:e*4},isTextArea:true,backgroundColor:"white",hint:"DG.TableController.attrEditor.descriptionHint",localize:true})}),typeCtl:DG.PickerControlView.design({layout:{height:d*1.5},label:"DG.CaseTable.attributeEditor.type",localize:true,toolTip:"DG.TableController.attrEditor.typeHint",controlView:SC.SelectView.extend({layout:{width:b,height:24},itemTitleKey:"title",itemValueKey:"value",items:DG.Attribute.attributeTypes.map(function(g){return{value:g,title:"DG.CaseTable.attribute.type."+g}}),value:null})}),unitCtl:DG.PickerControlView.design({layout:{height:d},label:"DG.CaseTable.attributeEditor.unit",localize:true,toolTip:"DG.TableController.attrEditor.unitHint",controlView:SC.TextFieldView.extend({layout:{width:b,height:e},backgroundColor:"white",localize:true})}),precisionCtl:DG.PickerControlView.design({layout:{height:d*1.5},label:"DG.CaseTable.attributeEditor.precision",localize:true,controlView:SC.SelectView.extend({layout:{width:b,height:24},itemTitleKey:"title",itemValueKey:"value"})}),editableCtl:DG.PickerControlView.design({layout:{height:d},label:"DG.CaseTable.attributeEditor.editable",localize:true,toolTip:"DG.TableController.attrEditor.editableHint",controlView:SC.RadioView.extend({layout:{width:b},items:[{title:"True",value:true,enabled:true},{title:"False",value:false,enabled:true}],value:[true],itemTitleKey:"title",itemValueKey:"value",itemIsEnabledKey:"enabled",layoutDirection:SC.LAYOUT_HORIZONTAL,localize:true})}),applyOrCancelCtl:SC.View.design(SC.FlowedLayout,{layoutDirection:SC.LAYOUT_VERTICAL,defaultFlowSpacing:5,align:SC.ALIGN_CENTER,layout:{width:b,height:24},childViews:"cancel apply".w(),cancel:SC.ButtonView.design({layout:{width:90},titleMinWidth:0,title:"DG.AttrFormView.cancelBtnTitle",target:null,action:"close",toolTip:"DG.AttrFormView.cancelBtnTooltip",localize:true,isCancel:true}),apply:SC.ButtonView.design({layout:{width:90},titleMinWidth:0,title:"DG.AttrFormView.applyBtnTitle",target:null,action:"update",toolTip:"",localize:true,isDefault:true})})}),typeDidChange:function(){this.updatePrecisionMenu(this.getPath("contentView.typeCtl.controlView.value"),this.getPath("attrRef.attribute.precision"))}.observes("contentView.typeCtl.controlView.value"),updatePrecisionMenu:function(j,l){var h=[" ","0","1","2","3","4","5","6","7","8"],i=DG.Attribute.datePrecisionOptions;function k(){var n=false;if(j==="date"){n=i.indexOf(l)>=0}else{n=h.indexOf(String(l))>=0}return n}var m=this.getPath("contentView.precisionCtl.controlView"),g;m.set("isEnabled",true);if(k()){m.set("value",String(l))}else{m.set("value","")}this.setPath("contentView.precisionCtl.toolTip","DG.TableController.attrEditor.precisionNumericHint".loc());switch(j){case"numeric":case"none":g=h.map(function(n){return{value:n.trim(),title:n}});break;case"date":g="DG.CaseTable.attributeEditor.datePrecisionOptions".loc().w();g.unshift(" ");g=g.map(function(n,o){var p=DG.Attribute.datePrecisionOptions[o];return{value:p,title:n}});this.setPath("contentView.precisionCtl.toolTip","DG.TableController.attrEditor.precisionDateHint".loc());break;default:m.set("isEnabled",false)}m.set("items",g)},attrRefDidChange:function(){var i=this.get("attrRef");var g=i.attribute;var h=this.get("contentView");if(i){DG.ObjectMap.forEach(g.toArchive(),function(l,m){var j=l+"Ctl";if(l==="name"){var k=g.get("renameable");h.setPath("nameCtl.controlView.enabledState",k?SC.CoreView.ENABLED:SC.CoreView.DISABLED)}if(l==="type"&&m===DG.Attribute.TYPE_NOMINAL){m=DG.Attribute.TYPE_CATEGORICAL}if(!SC.none(h.get(j))&&!SC.none(m)){h.setPath(j+".controlView.value",m)}}.bind(this));this.updatePrecisionMenu(this.getPath("contentView.typeCtl.controlView.value"),this.getPath("attrRef.attribute.precision"))}}.observes("attrRef"),update:function(){var g={name:this.getPath("contentView.nameCtl.controlView.value"),description:this.getPath("contentView.descriptionCtl.controlView.value"),type:this.getPath("contentView.typeCtl.controlView.value"),unit:this.getPath("contentView.unitCtl.controlView.value"),precision:this.getPath("contentView.precisionCtl.controlView.value"),editable:this.getPath("contentView.editableCtl.controlView.value")};DG.log("setting attribute: "+JSON.stringify(g));this.attrUpdater.updateAttribute(this.get("attrRef"),g);this.close()},close:function(){DG.log("Closing Attribute Editor");this.remove();this.destroy()},init:function(){arguments.callee.base.apply(this,arguments);this.setPath("contentView.applyOrCancelCtl.cancel.target",this);this.setPath("contentView.applyOrCancelCtl.cancel.action","close");this.setPath("contentView.applyOrCancelCtl.apply.target",this);this.setPath("contentView.applyOrCancelCtl.apply.action","update");if(this.get("attrRef")){this.attrRefDidChange()}}}}()));var kMultilineRowHeightThreshold=24;DG.CaseTableAdapter=SC.Object.extend((function(){var b="__INDEX__",f=60,u=60,p=35,w=35,m=45,l=18,q=20,h=256,d=function(y){var x=y.get("name"),z=y.get("unit");return x+(!SC.empty(z)?" ("+z+")":"")},j=function(B,x,z,A,y){return y&&y._isProtoCase?'<img src="../../../../static/dg/fr/cert/resources/images/drag-indicator.svg" title="'+"DG.CaseTable.indexProto.tooltip".loc()+'"/>':'<span class="dg-index">'+z+"</span>"},r=function(C,E,G,F,D){function x(I){if(typeof I==="string"){I=I.toLowerCase()}return["","false","true",false,true,null].includes(I)||I===undefined}var H;try{var z=F.attribute;var B=z&&z.get("type");var y=z&&z.get("precision");if(G&&G.jsonBoundaryObject){B=DG.Attribute.TYPE_BOUNDARY}if(G instanceof Error){H=g(G)}else{if(B===DG.Attribute.TYPE_QUALITATIVE){H=a(G)}else{if(G instanceof DG.SimpleMap){H=t(G.toString(),this,F)}else{if(B===DG.Attribute.TYPE_BOUNDARY){H=n(G)}else{if(B===DG.Attribute.TYPE_CHECKBOX&&x(G)&&(D instanceof DG.Case)){H=v(G,this,F)}else{if(SC.none(G)){H=""}else{if(typeof G==="boolean"){H=String(G)}else{if(DG.isDate(G)||B===DG.Attribute.TYPE_DATE){H=k(G,y,B)}else{if(DG.isNumeric(G)||B===DG.Attribute.TYPE_NUMERIC){H=i(G,B,y)}else{if(DG.isColorSpecString(G)){H=e(C,E,G,F,D)}else{if(typeof G==="string"){H=t(G,this,F)}else{DG.log("caseTableAdapter.cellFormatter: unhandled value type "+"for %@: %@".loc(F.name,G.toString()));H=""}}}}}}}}}}}}catch(A){DG.logWarn("Error in cell formatter: "+A+"/row,col,value/"+[C,E,G].join()+"/");H="error"}return H},k=function(A,x,z){var y=DG.isDate(A)?A:DG.parseDate(A,z===DG.Attribute.TYPE_DATE);return y?('<span class="dg-date">'+DG.formatDate(y,x)+"</span>"):'"'+A+'"'},i=function(B,z,x){var A=DG.isNumeric(B)?DG.getNumeric(B):DG.MathUtilities.extractNumeric(B),C=!SC.empty(x)?x:2,y;if(A!=null&&A!==""){if(z===DG.Attribute.TYPE_NUMERIC&&DG.MathUtilities.notAYear(A)){y=Intl.NumberFormat(DG.get("currentLanguage"),{maximumFractionDigits:C}).format(A)}else{var D=!SC.empty(C)?Math.pow(10,C):1;y=Math.round(D*A)/D}return'<span class="dg-numeric">'+y+"</span>"}else{return t(B)}},g=function(x){return t(x.toString())},o=function(x,A){var y=Math.floor((x-4)/(l-4));var z=Math.floor((A?A.width:f)/5);return Math.max(y*z,h)},t=function(y,x,z){if(!(y.length&&y.length<h)&&x){y=y.substring(0,o(x.get("rowHeight"),z))}return y.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")},a=function(y){if(y===null||y===undefined||y===""){return""}var x=DG.PlotUtilities.kDefaultPointColor;return"<span class='dg-qualitative-backing'><span class='dg-qualitative-bar' style='background:"+x+";width:"+y+"%'></span></span>"},n=function(y){var z="",A=DG.GeojsonUtils.boundaryObjectFromBoundaryValue(y),x=A&&A.jsonBoundaryObject&&A.jsonBoundaryObject.properties&&A.jsonBoundaryObject.properties.THUMB;if(x!==null&&x!==undefined){z="<span class='dg-boundary-thumb'><img src='"+x+"' alt='thumb' height='14'></span>"}else{if(A&&(A.jsonBoundaryObject instanceof Error)){z=g(A.jsonBoundaryObject)}else{if(A){z="A Boundary"}else{if(!SC.empty(y)){z=y}}}}return z},e=function(C,y,B,z,x){var A=tinycolor(B.toLowerCase().replace(/\s/gi,""));return"<span class='dg-color-table-cell' style= 'background:"+A.toString("rgb")+"'></span>"},v=function(B,A,D){B=(typeof B==="string")?B.toLowerCase():B;var x=D.attribute;var C=(x&&(x.formula||!x.editable));var z=(B&&B!=="false")?" checked":"";var y=C?" disabled":"";return'<span class="dg-checkbox-cell dg-wants-mouse dg-wants-touch"><input type="checkbox" title="'+B+'"'+z+y+"/></span>"},s=function(y,D,A,B){var z=y&&y.querySelector("input");var C=A.getValue(B.attribute.get("id")),x=![true,"true",false,"false"].includes(C);if(x&&z){z.indeterminate=true}},c=function(D,y,B,A,z,x){var C=/<span.*class=["']dg-.*["'].*<\/span>/.test(A)?"":A;return C&&A.replace?A.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"):""};return{minRowHeight:l,dataContext:null,collection:null,collectionName:function(x,y){if(y!==undefined){this.dataContext.applyChange({operation:"updateCollection",collection:this.collection,properties:{name:y}})}return this.getPath("collection.name")}.property().cacheable(),collectionNameDidChange:function(){this.notifyPropertyChange("collectionName")}.observes("*collection.name"),model:null,rowHeight:function(y,A){var x=this.get("model"),z=this.getPath("collection.id");if(x&&z){if(A!=null){x.setTableRowHeight(z,A)}return x.getTableRowHeight(z)||l}}.property(),isMultilineRowHeight:function(){return this.get("rowHeight")>=kMultilineRowHeightThreshold}.property(),hasAggregates:function(){return this.getPath("collection.hasAggregates")}.property(),showExpandedGroupRows:false,gridDataView:null,gridData:null,gridColumns:null,gridOptions:null,init:function(){arguments.callee.base.apply(this,arguments);this.gridDataView=DG.CaseTableDataManager.create({context:this.dataContext,collection:this.collection,adapter:this,model:this.model});if(this.get("dataContext")){this.dataContextDidChange()}},destroy:function(){if(this.gridDataView){this.gridDataView.destroy();this.gridDataView=null}arguments.callee.base.apply(this,arguments)},hasParentCollection:function(){var y=this.get("dataContext"),A=this.getPath("collection.id"),z=y&&y.getCollectionAtIndex(0),x=z&&z.get("id");return A!==x}.property(),isCollectionReorgAllowed:function(){var x=this.get("dataContext"),y=!this.get("hasParentCollection");return !y||!DG.DataContextUtilities.isTopLevelReorgPrevented(x)}.property(),dataContextMetadataDidChange:function(){this.refresh()}.observes("*dataContext.metadataChangeCount"),visibleRowCount:function(){return this.gridDataView.getLength()}.property(),getIndexForID:function(y){var x=this.get("gridDataView");return x&&x.getRowById(y)},getPreferredColumnWidth:function(z){var C=this;function B(){return C.getPath("collection.collection.attrs").length===1&&C.getPath("collection.collection.cases").length===0}var y=this.model;var x=y&&y.getPreferredAttributeWidth(z);var A=x||f;if(!x&&B()){A*=2;y.setPreferredAttributeWidth(z,A)}return A},getAttributeFromColumnIndex:function(x){return this.gridColumns[x].attribute},getColumnIndexFromAttribute:function(x){return this.gridColumns.findIndex(function(y){return y.attribute&&(x.id===y.attribute.id)})},getColumnFromAttribute:function(x){return this.gridColumns.find(function(y){return y.attribute&&(x.id===y.attribute.id)})},getColumnWidthStats:function(D){var A=this.getColumnFromAttribute(D);var z={display:"block","font-family":"Montserrat-Regular, sans-serif","font-size":"10.6667px","font-style":"normal","font-weight":"normal","text-align":"left",padding:"1px 4px 2px"};var F={display:"block","font-family":"Montserrat-Regular, sans-serif","font-size":"10.6667px","font-style":"normal","font-weight":"normal","text-align":"left"};var y=Number.MAX_VALUE;var E=0;var C=0;var B=0;var x=DG.measureText(d(D),F);var G=x&&x.width;this.collection.casesController.slice(0,500).forEach(function(I){var M=I.getValue(D.id);var H;var K;var J;if(DG.isColorSpecString(M)){J=q}else{if(D.type===DG.Attribute.TYPE_QUALITATIVE){J=u}else{H=r(0,0,M,A,I);K=DG.measureText(H,z);J=K&&K.width+1}}E=Math.max(E,J);y=Math.min(y,J);B++;C+=J});return{headerWidth:G,minWidth:y,maxWidth:E,meanWidth:C/B,count:B}},autoResizeColumn:function(x){var y=this.getColumnWidthStats(x);var z=Math.max(Math.ceil(3+y.headerWidth/2),Math.min(y.maxWidth,200))+11;this.model.setPreferredAttributeWidth(x.id,z)},autoResizeAllColumns:function(){this.collection.forEachAttribute(function(x){if(!x.get("hidden")){this.autoResizeColumn(x)}}.bind(this))},getProtoCase:function(){var y=this.get("gridDataView");var x=this.get("collection");return y&&x?y.getProtoCase(x):undefined},isCellEditable:function(E,y){var C=this.get("gridDataView"),x=this.get("dataContext"),B=C.getItem(E),D=this.gridColumns[y],A=D&&D.attribute,F=A&&A.get("editable")&&!A.get("hasFormula"),z=DG.DataContextUtilities.isCaseEditable(x,B);return F&&z},isCellRowSelectable:function(A,y){var z=this.get("gridDataView"),x=z.getItem(A);return x&&!x._isProtoCase},updateColumnInfo:function(){var A=this.get("dataContext"),C=this.get("collection"),B={},D=[];if(!C){return D}if(this.gridColumns){this.gridColumns.forEach(function(E){B[E.id]=E})}function z(F,E){E.editor=DG.CaseTableCellEditor}function x(){var F="DG.CaseTable.indexColumnName".loc(),E={context:A,id:b,name:F,field:F,toolTip:"DG.CaseTable.indexColumnTooltip".loc(),focusable:false,cssClass:"dg-index-column",formatter:j,width:p,minWidth:w};D.push(E)}function y(E){var J=E.get("id").toString(),M=E.get("collection"),F=E.get("name"),I=E.hasFormula(),H=E.hasDeletedFormula(),G=E.get("type")==="checkbox",K={context:A,collection:M,collectionID:M.get("id").toString(),attribute:E,id:J,name:d(E),field:F,focusable:!I,cssClass:I?"dg-formula-column":undefined,toolTip:DG.CaseDisplayUtils.getTooltipForAttribute(E),formatter:r.bind(this),asyncPostRender:G?s:null,tooltipFormatter:c,width:this.getPreferredColumnWidth(E.get("id")),minWidth:m,hasDependentInteractive:function(){return this.context.get("hasGameInteractive")},header:{menu:{items:[{title:"DG.TableController.headerMenuItems.renameAttribute".loc(),command:"cmdEditName",updater:function(N,P,O){O.disabled=false}},{title:"DG.TableController.headerMenuItems.resizeColumn".loc(),command:"cmdResizeAttribute",updater:function(N,P,O){O.disabled=false}},{title:"DG.TableController.headerMenuItems.editAttribute".loc(),command:"cmdEditAttribute",updater:function(N,P,O){O.disabled=false}},{title:"DG.TableController.headerMenuItems.editFormula".loc(),command:"cmdEditFormula",updater:function(N,P,O){O.disabled=!N.attribute.get("editable")}},{title:H?"DG.TableController.headerMenuItems.recoverFormula".loc():"DG.TableController.headerMenuItems.deleteFormula".loc(),command:H?"cmdRecoverDeletedFormula":"cmdDeleteFormulaKeepValues",updater:function(N,P,O){O.disabled=!N.attribute.get("editable")||(!I&&!H)}},{title:"DG.TableController.headerMenuItems.randomizeAttribute".loc(),command:"cmdRandomizeAttribute",updater:function(N,P,O){O.disabled=!DG.DataContextUtilities.attributeCanBeRandomized(A,J)}},{title:"DG.TableController.headerMenuItems.sortAscending".loc(),command:"cmdSortAscending",updater:function(N,P,O){O.disabled=false}},{title:"DG.TableController.headerMenuItems.sortDescending".loc(),command:"cmdSortDescending",updater:function(N,P,O){O.disabled=false}},{title:"DG.TableController.headerMenuItems.hideAttribute".loc(),command:"cmdHideAttribute",updater:function(N,P,O){O.disabled=N.collection.numberOfVisibleAttributes()===1}},{title:"DG.TableController.headerMenuItems.deleteAttribute".loc(),command:"cmdDeleteAttribute",updater:function(N,P,O){O.disabled=!N.attribute.get("deleteable")||N.hasDependentInteractive()||!DG.DataContextUtilities.isAttributeDeletable(A,E)}}]}}};z(E,K);if(!E.get("hidden")){D.push(K)}}if(this.model&&!this.model.get("isIndexHidden")){x()}C.forEachAttribute(y.bind(this));this.gridColumns=D;return D},getAttributeColumn:function(B){var y=this.get("dataContext"),x=y&&y.getAttributeByName(B),z=this.gridColumns.findIndex(function(C){return x&&(x.get("id").toString()===C.id)}),A=z>=0?this.gridColumns[z]:null;return A?{columnIndex:z,columnInfo:A}:null},updateColumnForAttribute:function(x){var y=DG.ArrayUtils.firstMatch(this.gridColumns,function(z){return x.get("id").toString()===z.id});if(y){y.name=d(x);y.field=x.get("name");y.toolTip=DG.CaseDisplayUtils.getTooltipForAttribute(x);y.formatter=r;y.cssClass=x.get("hasFormula")?"dg-formula-column":undefined;if(x.get("editable")&&!x.get("hasFormula")){y.editor=DG.CaseTableCellEditor}else{delete y.editor}this.gridDataView.refresh();return true}return false},buildGridOptions:function(){var x=function(A){var B=A&&A.get("id"),z=this.getPath("collection.collection.caseIDToGroupedIndexMap"),y=z&&B&&z[B];return(y!==null&&y!==undefined)?(y+1).toString():""}.bind(this);this.gridOptions={rowHeight:this.get("rowHeight"),headerRowHeight:l*2,enableColumnReorder:false,syncColumnCellResize:true,leaveSpaceForNewRows:false,editable:true,enableAddRow:false,asyncEditorLoading:false,enableAsyncPostRender:true,autoEdit:false,editCommandHandler:function(z,y,A){SC.run(function(){A.execute()})},dataItemColumnValueExtractor:function(z,y){return y.id===b?x(z):z.getValue(y.id)}};return this.gridOptions},rebuild:function(){this.updateColumnInfo();this.buildGridOptions()},dataContextDidChange:function(){this.beginPropertyChanges();this.setPath("gridDataView.context",this.get("dataContext"));this.setPath("gridDataView.collection",this.get("collection"));this.endPropertyChanges();this.rebuild()}.observes("dataContext"),attributeFormulaDidChange:function(x,y){if(y==="attrFormulaChanges"){this.updateColumnInfo()}this.markCasesChanged();this.gridDataView.refresh()}.observes(".collection.attrFormulaChanges"),refresh:function(){this.set("lastRefresh",null);this.invokeOnce(function(){this.set("lastRefresh",null);var x=this.get("gridDataView");if(x){x.refresh();this.notifyPropertyChange("tableDidRefresh")}this.set("lastRefresh",new Date())}.bind(this));this.set("lastRefresh",new Date())},getSelectedRows:function(){var y=this.get("dataContext"),C=this.get("collection"),F=this.get("gridDataView"),G=this.getPath("collection.casesController.selection"),z=[],D;if(G){G.forEach(function(I){var H=F.getRowById(I.get("id").toString());if(H>=0){z.push(H)}})}var A,E=this.get("visibleRowCount"),B=y&&y.getParentCollection(C);if(B&&F&&(E>0)){for(A=0;A<E;++A){var x=F.getItem(A);if(x.collection.get("id")!==C.get("id")){D=y.getCollectionByID(x.collection.get("id"));if(D){if(D.isCaseSelected(x)){z.push(A)}}else{DG.log("CaseTableAdapter.getSelectedRows: collectionClient for case "+x.id+" not found: "+x.collection.get("id"))}}}}return z},selectRowsInRange:function(D,E){var F=this.get("gridDataView"),G=this.get("dataContext"),x=this.get("collection"),A=[];for(var B=D;B<=E;++B){var y=F.getItem(B),z=y&&y.__group&&y.id;if(!SC.empty(z)){y=G.getCaseByID(z)}if(y){A.push(y)}}if(A.length){var C={operation:"selectCases",collection:x,cases:A,select:true,extend:false};G.applyChange(C)}},selectRowsInList:function(A){var B=this.get("gridDataView"),x=this.get("dataContext"),z=this.get("collection"),y={operation:"selectCases",collection:z,cases:A.map(function(C){return B.getItem(C)}).filter(function(C){return C&&!C._isProtoCase}),select:true,extend:false};if(y.cases.length){x.applyChange(y)}},deselectAllCases:function(){var x=this.getSelectedRows();if(x&&x.length){this.get("dataContext").applyChange({operation:"selectCases",select:false})}},markCasesChanged:function(y){var z=this.get("gridDataView"),x=y||this.getPath("collection.casesController");z.beginUpdate();x.forEach(function(B){var A=B.get("id").toString(),C=z.getItemById(A);if(C){z.updateItem(A,C)}});z.endUpdate();this.refresh()},requestMoveAttribute:function(y,x){var A=this.get("dataContext"),D=A&&this.get("collection"),C=D&&D.getPath("collection.attrs"),z=0,B={operation:"moveAttribute",attr:y,toCollection:D,fromCollection:y.get("collection"),position:null};if(!C){return}x-=1;while(x>0&&C[z]){if(!C[z].hidden){x--}z++}B.position=z;A.applyChange(B)},canAcceptDrop:function(y){var x=this.get("dataContext");var z=!this.get("hasParentCollection");return DG.DataContextUtilities.canAcceptAttributeDrop(x,y,z,true)}}}()));DG.CaseTableCellEditor=function CaseTableCellEditor(b){var c;var a;this.init=function(){var g=37,e=39,f=b.grid,h=f.getOptions(),d=h.rowHeight>=kMultilineRowHeightThreshold?"textarea":"input";c=SC.$("<"+d+" type=text class='dg-editor-text' />").appendTo(b.container).bind("keydown.nav",function(i){if(i.keyCode===g||i.keyCode===e){i.stopImmediatePropagation()}}).bind("blur",function(i){DG.globalEditorLock.commitCurrentEdit()}).bind("mousedown",function(i){i.stopImmediatePropagation()}).bind("mouseup",function(i){i.stopImmediatePropagation()}).bind("click",function(i){i.preventDefault();i.stopImmediatePropagation()}).focus().select()};this.destroy=function(){c.remove()};this.focus=function(){c.focus()};this.getValue=function(){return c.val()};this.setValue=function(d){c.val(d)};this.loadValue=function(e){var d=Number(b.column.id),f=e&&e.getValue(d);a=SC.none(f)?"":f.toString();c.val(a);c[0].defaultValue=a;c.select()};this.serializeValue=function(){return c.val()};this.saveEditState=function(){return{item:b.item,column:b.column,value:c.val(),selectionStart:c[0].selectionStart,selectionEnd:c[0].selectionEnd,selectionDirection:c[0].selectionDirection}};this.restoreEditState=function(d){c.val(d.value);c[0].setSelectionRange(d.selectionStart,d.selectionEnd,d.selectionDirection)};this.applyValue=function(s,d){var r=Number(b.column.id),f=s,p=f instanceof DG.Case,q=p?f.getStrValue(r):f.getValue(b.column.id),e=DG.DataUtilities.canonicalizeInputValue(d),g=b.column.context,j=g.get("name"),m=f.get("collection"),k=m&&m.get("name")||"",n=m&&m.getAttributeByID(r),o=n&&n.get("name"),h=b.grid.getData().getIdxById(f.id);function l(u,v,t){if(p){g.applyChange({operation:"updateCases",cases:[f],attributeIDs:[u],values:[[v]]})}else{if(!t){f.setValue(b.column.id,e)}}}var i=DG.Command.create({name:"caseTable.editCellValue",undoString:"DG.Undo.caseTable.editCellValue",redoString:"DG.Redo.caseTable.editCellValue",log:"editValue: { collection: %@, case: %@, attribute: '%@', old: '%@', new: '%@' }".fmt(k,h+1,r,q,e),causedChange:p,execute:function(){l(r,e)},undo:function(){l(r,q,true)},redo:function(){g=DG.currDocumentController().getContextByName(j);m=g&&g.getCollectionByName(k);n=m&&m.getAttributeByName(o);r=n.get("id");var t=m&&m.get("casesController");f=t&&t.objectAt(h);if(f){l(r,e,true)}}});DG.UndoHistory.execute(i)};this.isValueChanged=function(){return(!(c.val()===""&&SC.none(a)))&&(c.val()!==a)};this.validate=function(){if(b.column.validator){var d=b.column.validator(c.val());if(!d.valid){return d}}return{valid:true,msg:null}};this.init()};sc_require("components/case_display_common/case_display_controller");sc_require("components/case_table/attribute_editor_view");DG.CaseTableController=DG.CaseDisplayController.extend((function(){return{_prevDataContext:null,caseTableAdapters:null,contentView:null,newAttributeDialog:null,init:function(){arguments.callee.base.apply(this,arguments);this.get("specialTitleBarButtons").push(DG.CaseCardToggleButton.create());this.caseTableAdapters=[];this.invokeLater(function(){if(this.get("dataContext")&&this.get("model")){this.dataContextDidChange()}else{DG.logWarn("Case table controller unable to complete initialization: missing dataContext or model")}})},destroy:function(){var a=this.get("dataContext");if(a){a.removeObserver("changeCount",this,"contextDataDidChange")}this.caseTableAdapters=null;arguments.callee.base.apply(this,arguments)},findAdapterForCollection:function(d){var a,b,c=this.caseTableAdapters;if(c){b=c.length;for(a=0;a<b;++a){if(c[a]&&(c[a].getPath("collection.id")===d)){return c[a]}}}return null},updateTableAdapters:function(){var b=this.get("dataContext"),e=b&&b.get("collections")||[],c=this.model&&this.model.get("content"),a=[];function f(h){var g=h.get("attrs");return !!g.find(function(i){return !i.get("hidden")})}var d=function(i){var h=i.get("id"),j=b.getCollectionByID(h),g=this.findAdapterForCollection(h);if(g){g.beginPropertyChanges();g.set("dataContext",b);g.set("collection",j);g.endPropertyChanges()}else{g=DG.CaseTableAdapter.create({dataContext:b,collection:j,model:c})}a.push(g)}.bind(this);e.filter(function(g){return f(g)}).forEach(d);this.set("caseTableAdapters",a)},resetProtoCaseRows:function(){this.get("caseTableAdapters").forEach(function(a){var b=a.get("gridDataView");if(b){b.resetProtoCases()}})},dataContextDidChange:function(){var a=this.get("dataContext");this.updateTableAdapters();var d=this.getPath("view.contentView");if(d){var f=function(k){var i=k.getPath("dropData");if(SC.none(i)){return}var h=k.getPath("dataContext");var j=k.getPath("leftTable");this.resetProtoCaseRows();DG.UndoHistory.execute(DG.DataContextUtilities.createCollectionCommand(i.attribute,i.collection,h,j.getPath("gridAdapter.collection.id")));k.setPath("dropData",null)}.bind(this);d.set("dataContext",a);var e=d.getPath("dividerViews");e.forEach(function(h){h.removeObserver("dropData",f);h.destroy()});d.setCaseTableAdapters(this.get("caseTableAdapters"));var c=d.getPath("dividerViews");c.forEach(function(h){h.addObserver("dropData",f)})}if(a!==this._prevDataContext){if(this._prevDataContext){this._prevDataContext.removeObserver("changeCount",this,"contextDataDidChange")}if(a){a.addObserver("changeCount",this,"contextDataDidChange")}this._prevDataContext=a;DG.currDocumentController().tableCardRegistry.registerView(a,this.get("view"))}var b=this.getPath("dataContext.childCollection");if(b){var g=this;a.forEachCollection(function(h){h.attrsController.addObserver("[]",g,"attributesDidChange")})}this.doResetCollections()}.observes("dataContext"),getCaseCountMessage:function(){var a=this.get("dataContext");var c=a.get("collections");var d=[];var b="";c.forEach(function(f){var e=a.getCollectionByName(f.get("name"));var g=a.getCaseCountString(e,e.getCaseCount()||0);d.push(g)});b=d.join("/");if(SC.empty(b)){DG.logWarn("No status message for case table: no collections")}return b},createComponentStorage:function(){var e=this.getPath("model.content"),a=e.get("context"),i=e.get("isActive"),c=e.get("horizontalScrollOffset"),h=e.get("collapsedNodes"),b=e.get("isIndexHidden"),d=[],g=[],f={isActive:i,horizontalScrollOffset:c,isIndexHidden:b};if(a){this.addLink(f,"context",a)}DG.ObjectMap.forEach(e.get("preferredAttributeWidths"),function(j,k){var l={};var m=a.getAttrRefByID(j);if(m){this.addLink(l,"attr",m.attribute);l.width=k;d.push(l)}}.bind(this));f.attributeWidths=d;DG.ObjectMap.forEach(e.get("tableRowHeights"),function(k,j){var l={};var m=a.getCollectionByID(k);if(m){this.addLink(l,"collection",m);l.rowHeight=j;g.push(l)}}.bind(this));f.rowHeights=g;h.forEach(function(j,l){var k=a.getCaseByID(j);if(k){this.addLink(f,"collapsedNodes",k)}}.bind(this));return f},restoreComponentStorage:function(c,j){arguments.callee.base.apply(this,arguments);var e=this.getPath("model.content");if(e){var h=this.getLinkID(c,"context"),f=DG.ArchiveUtils.getLinkCount(c,"collapsedNodes"),a=h&&DG.currDocumentController().getContextByID(h),d={},g={},i=c.isActive,b=0;if(c.attributeWidths){c.attributeWidths.forEach(function(k){var l=this.getLinkID(k,"attr");d[l]=k.width}.bind(this));e.set("preferredAttributeWidths",d)}if(c.rowHeights){c.rowHeights.forEach(function(l){var k=this.getLinkID(l,"collection");g[k]=l.rowHeight}.bind(this));e.set("tableRowHeights",g)}if(a){e.set("context",a);this.set("dataContext",a)}e.set("isActive",i);e.set("isIndexHidden",c.isIndexHidden);e.set("horizontalScrollOffset",c.horizontalScrollOffset);if(f>0){while(b<f){e.collapseNode(DG.store.find("DG.Case",DG.ArchiveUtils.getLinkID(c,"collapsedNodes",b)));b+=1}}}if(this.get("contentView")){this.get("contentView").frameDidChange()}},doCommand:function(a){var b=Number(a.column.id);switch(a.command){case"cmdEditFormula":this.editAttributeFormula(b);break;case"cmdDeleteFormulaKeepValues":this.deleteFormulaKeepValues(b);break;case"cmdRecoverDeletedFormula":this.recoverDeletedFormula(b);break;case"cmdEditName":this.editName(b,a.grid.getHeaderRowColumn(b));break;case"cmdResizeAttribute":this.resizeColumn(b,a.grid.getHeaderRowColumn(b));break;case"cmdEditAttribute":this.editAttribute(b,a.grid.getHeaderRowColumn(b));break;case"cmdRandomizeAttribute":DG.DataContextUtilities.randomizeAttribute(this.get("dataContext"),b);break;case"cmdSortAscending":this.sortAttribute(b);break;case"cmdSortDescending":this.sortAttribute(b,true);break;case"cmdHideAttribute":DG.DataContextUtilities.hideAttribute(this.get("dataContext"),b);break;case"cmdDeleteAttribute":DG.DataContextUtilities.deleteAttribute(this.get("dataContext"),b);break}},contextDataDidChange:function(){var b=this.getPath("dataContext.newChanges"),a=true;var d=function(f){var e=f&&f.operation;switch(e){case"createCollection":this.dataContextDidChange();break;case"deleteCollection":this.dataContextDidChange();break;case"createCase":case"createCases":case"moveCases":this.doCreateCases(f);a=false;break;case"updateCases":this.doUpdateCases(f);a=false;break;case"deleteCases":this.doDeleteCases(f);a=false;break;case"selectCases":this.doSelectCases(f);a=false;break;case"dependentCases":this.doDependentCases(f);a=false;break;case"createAttributes":this.doCreateAttributes(f);break;case"hideAttributes":case"unhideAttributes":this.dataContextDidChange(f);this.attributesDidChange(f);break;case"updateAttributes":this.dataContextDidChange(f);this.attributesDidChange(f);break;case"deleteAttributes":this.doDeleteAttributes(f);break;case"moveAttribute":this.dataContextDidChange(f);this.doMoveAttributes(f);break;case"sortAttribute":this.dataContextDidChange(f);break;case"resetCollections":this.caseCountDidChange(f);this.dataContextDidChange();break;case"deleteDataContext":this.dataContextWasDeleted();break;case"updateDataContext":case"updateCollection":case"createItems":case"updateItems":case"deleteItems":case"moveItems":break;default:DG.logWarn("DG.CaseTableController -- Unhandled operation: "+f.operation)}}.bind(this);if(b){b.forEach(function(e){d(e)})}if(a){var c=this.get("caseTableAdapters");if(c){c.forEach(function(e){if(e.get("hasAggregates")){e.markCasesChanged()}})}}},doCreateCases:function(a){this.caseCountDidChange(a);if(a.result&&a.result.caseIDs){this.invokeNext(function(){this.get("contentView").scrollToCaseByID(a.collection,a.result.caseIDs[a.result.caseIDs.length-1])})}},doUpdateCases:function(a){this.doChangeCaseValues(a)},doDeleteCases:function(b){var a=this.getPath("model.content");this.caseCountDidChange(b);this.doSelectCases(b);a.didDeleteCases(b.cases);this.resetProtoCaseRows()},doDependentCases:function(a){if(a.changes){a.changes.forEach(function(d){var f=d.collection,c=f&&f.get("id"),e=d.cases&&d.cases.length?d.cases:undefined,b=this.findAdapterForCollection(c);if(b){b.markCasesChanged(e)}}.bind(this))}},doCreateAttributes:function(a){this.attributesDidChange(a)},doDeleteAttributes:function(a){this.attributesDidChange(a)},doMoveAttributes:function(a){this.attributesDidChange(a)},doResetCollections:function(c){function b(d){d.rebuild();d.refresh()}var a=this.get("caseTableAdapters");a.forEach(b)},doSelectCases:function(b){var c=this.getPath("view.contentView");var a=(b.operation==="selectCases")&&b.cases&&b.cases[0];this.invokeOnceLater(function(){if(c){c.updateSelectedRows();c.scrollSelectionToView(a)}})},doChangeCaseValues:function(c){var b={};this.get("caseTableAdapters").forEach(function(d){var e=d.getPath("collection.id");b[e]={adapter:d,cases:[]}});function a(d){if(d){d.forEach(function(f){var g=f.getPath("collection.id"),e=b[g];if(e){e.cases.push(f);a(f.get("children"))}})}}a(c.cases);DG.ObjectMap.forEach(b,function(e,d){if(d.cases.length>0){d.adapter.markCasesChanged(d.cases)}});this.getPath("view.contentView").refresh()},doUpdateAttributes:function(e){var f=this.getPath("view.contentView"),c=this.get("caseTableAdapters"),b=[],a=(e&&e.result&&e.result.attrs)||this.dataContext.getAttributes();function d(g){if(a){a.forEach(function(h){if(g.updateColumnForAttribute(h)){b.push(g)}})}}if(c){c.forEach(d);if(f){f.get("childTableViews").forEach(function(g){var i=g.get("gridAdapter");var h;if(b.indexOf(i)>=0){h=i.get("gridColumns").filter(function(j){return !j.attribute||!j.attribute.hidden});g.setColumns(h)}})}}},caseCountDidChange:function(b){var c=this.getPath("view.contentView"),a=b.properties&&!SC.none(b.properties.index);if(c){c.updateRowCount(a)}},attributesDidChange:function(){var a=this.getPath("view.contentView");if(a){a.updateColumnInfo();a.updateRowCount();a.updateSelectedRows()}},modelDidChange:function(){}.observes("model"),toggleViewVisibility:function(){var a=this.get("view"),c=a.get("isVisible")?"delete":"add",b="caseTableView";DG.UndoHistory.execute(DG.Command.create({name:"component.toggle.delete",undoString:"DG.Undo.toggleComponent."+c+"."+b,redoString:"DG.Redo.toggleComponent."+c+"."+b,log:"Toggle component: %@".fmt("caseTable"),execute:function(){var d=a.toggleProperty("isVisible"),f=a.get("layout"),e=d?"create":"delete";a.set("savedLayout",f);if(!d&&a.parentView&&a.parentView.select){a.parentView.select(null)}DG.currDocumentController().notificationManager.sendNotification({action:"notify",resource:"component",values:{operation:e,type:a.getPath("model.type"),id:a.getPath("model.id"),title:a.getPath("model.title")}})},undo:function(){this.execute()},redo:function(){this.execute()}}))},viewDidChange:function(){var b=this.get("view"),a=b.get("contentView");this.set("contentView",a);if(!this.getPath("caseTableAdapters.length")){this.updateTableAdapters()}if(a){a.bind("dataContext",this,"dataContext");a.setCaseTableAdapters(this.get("caseTableAdapters")||[])}var c=this.getPath("view.containerView.titlebar.gearView");if(c){c.set("contentView",b)}}.observes("view"),newAttributeAction:function(a,b){this.newAttribute(b);return YES},newAttribute:function(c){var b=this.get("dataContext"),e=c.collection,d=e&&e.get("id"),f=this.getPath("view.contentView"),a=f&&f.getChildTableViewForCollection(d);DG.DataContextUtilities.newAttribute(b,e,null,a,c.autoEditName)},editAttributeProperties:function(e,d,c){var g=this.get("dataContext"),b=d||"",f=c||"",a=DG.AttributeFormulaView.buildOperandsMenuAndCompletionData(g);this.newAttributeDialog=DG.CreateAttributeFormulaView(SC.mixin({applyTarget:this,applyAction:"applyNewAttribute",applyTooltip:"DG.TableController.newAttrDlg.applyTooltip",attrNameHint:"DG.TableController.newAttrDlg.attrNameHint",attrNameValue:b,attrNameIsEnabled:SC.empty(d),formulaValue:f,formulaCompletions:a.completionData,formulaOperands:a.operandsMenu,formulaHint:"DG.TableController.newAttrDlg.formulaHint"},e))},applyNewAttribute:function(){var b=this.get("dataContext"),g=this.newAttributeDialog.get("attributeName"),e=b.getAttrRefByName(g),c=e&&e.attribute.get("formula"),a=this.newAttributeDialog.get("attrNameIsEnabled");if(!SC.empty(g)){var d=this.newAttributeDialog.get("collection"),f=this.newAttributeDialog.get("formula");DG.UndoHistory.execute(DG.Command.create({name:a?"caseTable.createAttribute":"caseTable.editAttributeFormula",undoString:a?"DG.Undo.caseTable.createAttribute":"DG.Undo.caseTable.editAttributeFormula",redoString:a?"DG.Redo.caseTable.createAttribute":"DG.Redo.caseTable.editAttributeFormula",_componentId:this.getPath("model.id"),_controller:function(){return DG.currDocumentController().componentControllersMap[this._componentId]},executeNotification:{action:"notify",resource:"component",values:{operation:"edit formula",type:"DG.CaseTable"}},execute:function(){e=b.getAttrRefByName(g);var h={operation:"createAttributes",collection:d,attrPropsArray:[{name:g,formula:f}]},j=b&&b.applyChange(h);if(j.success){var i=a?"attributeCreate":"attributeEditFormula";this.log="%@: { name: '%@', collection: '%@', formula: '%@' }".fmt(i,g,d.get("name"),f)}else{this.set("causedChange",false)}},undo:function(){var h,j,i;b=this._controller().get("dataContext");if(a){e=b.getAttrRefByName(g);h={operation:"deleteAttributes",collection:d,attrs:[{id:e.attribute.get("id"),attribute:e.attribute}]}}else{h={operation:"createAttributes",collection:d,attrPropsArray:[{name:g,formula:c}],isUndo:true}}j=b&&b.applyChange(h);if(j.success){i=a?"attributeCreate":"attributeEditFormula"}else{this.set("causedChange",false)}},redo:function(){b=this._controller().get("dataContext");this.execute()}}))}else{DG.AlertPane.show({localize:true,message:"DG.TableController.newAttrDlg.mustEnterAttrNameMsg"});return}this.newAttributeDialog.close();this.newAttributeDialog=null},willDestroy:function(){if(this.newAttributeDialog){this.newAttributeDialog.close();this.newAttributeDialog=null}arguments.callee.base.apply(this,arguments)},editName:function(i,c){var a=this.get("dataContext"),d=a&&a.getAttrRefByID(i),g=d&&d.attribute,f=d&&d.collection,b=f&&f.get("id"),h=this.getPath("view.contentView"),e=h&&h.getChildTableViewForCollection(b);if(!DG.assert(g,"editName() is missing the attribute reference")){return}e.beginEditAttributeName(g.get("name"))},resizeColumn:function(j,d){var g=this,b=this.get("dataContext"),e=b&&b.getAttrRefByID(j),i=e&&e.attribute,f=e&&e.collection,c=f&&f.get("id"),h=c&&this.findAdapterForCollection(c),a;if(h){a=h.getPreferredColumnWidth(j);DG.UndoHistory.execute(DG.Command.create({name:"caseTable.resizeColumn",undoString:"DG.Undo.caseTable.resizeColumn",redoString:"DG.Undo.caseTable.resizeColumn",log:"Fit Column Width: {collection: %@, attribute: %@}".fmt(f.get("name"),i.get("name")),executeNotification:{action:"notify",resource:"component",values:{operation:"resize column",type:"DG.CaseTable"}},execute:function(){h.autoResizeColumn(i);g.attributesDidChange()},undo:function(){h.model.setPreferredAttributeWidth(j,a);g.attributesDidChange()}}))}else{DG.logWarn("Could not find adapter for attr: "+j)}},editAttribute:function(b,a){var d=this.get("dataContext"),c=d&&d.getAttrRefByID(b);if(!DG.assert(c,"editAttribute() is missing the attribute reference")){return}this.showEditAttributePane(c,a)},updateAttribute:function(a,b){DG.DataContextUtilities.updateAttribute(this.get("dataContext"),a&&a.collection,a.attribute,b)},showEditAttributePane:function(a,b){var c=DG.AttributeEditorView.create({attrRef:a,attrUpdater:this});c.append()},sortAttribute:function(b,g){var e=this.get("dataContext"),m=e&&e.getPath("model.dataSet"),s=e&&e.get("childCollection"),c=s&&s.get("id"),f=g?DG.DataUtilities.compareDescending:DG.DataUtilities.compareAscending,h=DG.Attribute.getAttributeByID(b),p=h.get("type")==="numeric",j=h&&h.get("collection"),d=j&&j.get("id"),l=j.get("parent"),q=this.getPath("view.contentView"),n,k;function o(v,u){var t=DG.Case.findCase(c,v);while(t&&(t.getPath("collection.id")!==d)){t=t.get("parent")}return t}function a(t,u){var v=t&&t.getRawValue(u);var w=t&&(p?t.getForcedNumericValue(u):null);return t&&(SC.empty(w)?v:w)}function i(u,t,w){var v=function(y,x){return y-x};if(w){return function(z,x){var A=z&&w.caseIDToIndexMap[z.getPath("parent.id")];var y=x&&w.caseIDToIndexMap[x.getPath("parent.id")];if(A!==y){return v(A,y)}else{return f(a(z,u),a(x,u))}}}else{return function(y,x){return f(a(y,u),a(x,u))}}}function r(){e.regenerateCollectionCases(null,"moveCases");if(q){q.updateRowData()}}if(m){DG.UndoHistory.execute(DG.Command.create({name:"caseTable.sortCases",undoString:"DG.Undo.caseTable.sortCases",redoString:"DG.Redo.caseTable.sortCases",log:'sort cases by attribute: %@ ("%@")'.fmt(b,h&&h.get("name")),execute:function(){n=m.sortItems(b,o,i(b,g,l));k=m.getClientIndexMapCopy();r()},undo:function(){m.setClientIndexMap(n);r()},redo:function(){m.setClientIndexMap(k);r()}}))}},editAttributeFormula:function(c){var e=this.get("dataContext"),d=e&&e.getAttrRefByID(c),a=d&&d.attribute.get("name"),b=d.attribute.get("formula");DG.assert(d&&a,"editAttributeFormula() is missing the attribute reference or attribute name");this.editAttributeProperties({collection:d.collection},a,b||"")},deleteFormulaKeepValues:function(a){var b=this.getPath("view.contentView").updateColumnInfo.bind(this);DG.DataContextUtilities.deleteAttributeFormula(this.get("dataContext"),a,b)},recoverDeletedFormula:function(a){var b=this.getPath("view.contentView").updateColumnInfo.bind(this);DG.DataContextUtilities.recoverAttributeFormula(this.get("dataContext"),a,b)},createNewAttributesButtons:function(){var d=this.get("dataContext"),c=d.get("collections")||[],a="DG.Inspector.newAttribute",b=[];c.forEach(function(g){var e=this.findAdapterForCollection(g.id),f=e&&e.get("isCollectionReorgAllowed");b.push({title:a.loc(g.name),target:this,args:[{collection:d.getCollectionByName(g.name),autoEditName:true}],dgAction:"newAttribute",isEnabled:f})}.bind(this));return b},showAttributesPopup:function(){var a=this.createNewAttributesButtons();a.push(this.createRandomizeButton());a.push(this.createExportCaseButton());a.push(this.createCopyToClipboardButton());a.push(this.createGetFromClipboardButton());DG.MenuPane.create({classNames:"dg-attributes-popup".w(),layout:{width:200,height:150},items:a}).popup(this.get("inspectorButtons")[1])},resizeColumns:function(){var a=this.dataContext;var b=this.getPath("model.content");var d=this.get("caseTableAdapters");var c=a.getAttributes().map(function(e){var f=e&&e.id;return{id:f,width:b.getPreferredAttributeWidth(f)}}.bind(this));DG.UndoHistory.execute(DG.Command.create({name:"caseTable.resizeColumns",undoString:"DG.Undo.caseTable.resizeColumns",redoString:"DG.Redo.caseTable.resizeColumns",log:"resizeColumns: { dataContext: % }".fmt(a),executeNotification:{action:"notify",resource:"component",values:{operation:"resize columns",type:"DG.CaseTable"}},execute:function(){d.forEach(function(e){e.autoResizeAllColumns()});this.attributesDidChange()}.bind(this),undo:function(){c.forEach(function(e){if(e){b.setPreferredAttributeWidth(e.id,e.width)}}.bind(this));this.attributesDidChange()}.bind(this)}))},createInspectorButtons:function(){var a=arguments.callee.base.apply(this,arguments);a.push(this.createInfoButton());a.push(DG.IconButton.create({layout:{width:32,left:0,height:25},classNames:"display-rescale".w(),iconClass:"moonicon-icon-scaleData",iconExtent:{width:30,height:25},target:this,action:"resizeColumns",toolTip:"DG.Inspector.resize.toolTip",localize:true}));a.push(this.createTrashButton());a.push(this.createHideShowButton());a.push(this.createRulerButton());return a},leftDropZoneDidAcceptDrop:function(){var b=this.getPath("contentView.leftDropTarget.dropData");if(SC.none(b)){return}var a=this.dataContext;this.resetProtoCaseRows();DG.UndoHistory.execute(DG.DataContextUtilities.createCollectionCommand(b.attribute,b.collection,a));this.setPath("contentView.leftDropTarget.dropData",null)}.observes("contentView.leftDropTarget.dropData")}}()));DG.CaseTableDataManager=SC.Object.extend({context:null,collection:null,model:null,adapter:null,suspended:false,_rowCaseMap:null,_protoCases:null,_collapsedNodeInfoCache:null,caseTableLength:function(){return this._rowCaseMap.length}.property(),init:function(){this._rowCaseMap=[];this._protoCases={};this.onRowCountChanged=new Slick.Event();this.onRowsChanged=new Slick.Event()},getLength:function(){return this.get("caseTableLength")},getItem:function(a){return this._rowCaseMap[a]},getItemMetadata:function(b){function c(e){var d={};e.forEach(function(g){var f=g.attribute;var h=f?!f.hasFormula():g.focusable;d[g.id]={id:g.id,focusable:h}});return{cssClasses:"dg-proto-row",columns:d}}var a=this.getItem(b);if(a&&(a instanceof DG.Case)){if(a.collection.get("id")!==this.collection.get("id")){return{cssClasses:"dg-collapsed-row",columns:{0:{colspan:"*"}},formatter:function(l,h,k,j,g){var e=this.subcaseCount(this._rowCaseMap[l]);var d=this.subcaseCount(this._rowCaseMap[l],true);var i=!!(e-d);var f=i?this.context.getCaseNameForCount(this.collection,d):this.context.getCaseNameForCount(this.collection,e);return i?"DG.CaseTable.closedGroup.summary-nonempty".loc(d,f):"DG.CaseTable.closedGroup.summary".loc(e,f)}.bind(this)}}else{if(a.get("isEmpty")){return{cssClasses:"dg-empty-case-row"}}}}else{return c(this.adapter.gridColumns)}},getProtoCase:function(b){if(!b){b=this.get("collection")}var a=b&&b.get("id"),c=a&&this._protoCases[a];if(!a){return null}if(!c){c=this._protoCases[a]=SC.Object.create({id:Math.pow(2,32)-a,collection:b,_isProtoCase:true,beforeCaseID:null,parentCaseID:null,children:[],_values:null,init:function(){arguments.callee.base.apply(this,arguments);this._values={}},getStrValue:function(d){var e=this._values[d];return DG.isDate(e)?DG.formatDate(e):e},getValue:function(d){return this._values[d]},setValue:function(d,e){this._values[d]=e}})}return c},resetProtoCases:function(a){DG.ObjectMap.forEach(this._protoCases,function(b,c){if(!a||(c.get("parentCaseID")===a)){c.set("beforeCaseID",null);c.set("parentCaseID",null)}})},refresh:function(){function i(n){var m=[];var o=n;var p;while(o){m.push(o);p=o.getParentCollectionID();if(!SC.none(p)){o=c.getCollectionByID(p)}else{o=null}}return m.reverse()}function j(m,n){m.forEach(function(o){if(n===g.length-1){a.push(o)}else{if(h.isCollapsedNode(o)){a.push(o)}else{j(o.get("children"),n+1)}}})}if(this.get("suspended")){this.set("refreshNeeded",true);return}var e=this._rowCaseMap.length;var a=[];var b=this.collection;var c=this.context;var h=this.model;var g=i(b);j(g[0].casesController,0);this._rowCaseMap=a;if(this.getPath("adapter.isCollectionReorgAllowed")){var f=this.getProtoCase(b);var l=f.get("beforeCaseID");var d=f.get("parentCaseID");var k=-1;if(l){this._rowCaseMap.forEach(function(m,n){if(m.getPath("id")===l){k=n}})}if((k<0)&&d){this._rowCaseMap.forEach(function(m,n){if(m.getPath("parent.id")===d){k=n+1}})}if(k>=0){this._rowCaseMap.splice(k,0,f)}else{this._rowCaseMap.push(f)}}if(this._rowCaseMap.length!==e){this.onRowCountChanged.notify({previous:e,current:this._rowCaseMap.length},null,this)}else{this.onRowsChanged.notify({rows:null},null,this)}this.set("refreshNeeded",false)},onRowsChanged:null,onRowCountChanged:null,beginUpdate:function(){this.set("suspended",true)},endUpdate:function(){this.set("suspended",false);if(this.get("refreshNeeded")){this.refresh()}},setItems:function(a){},getItemById:function(a){return this.collection.getCaseByID(a)},getIdxById:function(a){return this.collection.getCaseIndexByID(a)},getRowById:function(a){return this._rowCaseMap.findIndex(function(b){return b&&(b.get("id")==a)})},insertItem:function(a){},addItem:function(a){},updateItem:function(b,a){this.refresh()},setGrouping:function(a){},collapseGroup:function(b){var a=DG.store.find("DG.Case",b);if(a){this.model.collapseNode(a)}},expandGroup:function(b){var a=DG.store.find("DG.Case",b);if(a){this.model.expandNode(a)}},isGroupCollapsed:function(b){var a=this.collection.getCaseByID(b);if(a){return this.model.isCollapsedNode(a)}},setRefreshHints:function(a){},expandCollapseCounts:function(){var a=this.model;var b={expanded:0,collapsed:0};this.collection.casesController.forEach(function(c){if(a.isCollapsedNode(c)){b.collapsed+=1}else{b.expanded+=1}});return b}.property(),subcaseCount:function(a,c){var b=0;if(a.collection.id===this.collection.get("id")){b=1}else{a.children.forEach(function(d){if(!c||!d.get("isEmpty")){b+=this.subcaseCount(d)}}.bind(this))}return b}});DG.CaseTableDragHelper=SC.Object.extend((function(){return{caseTableView:null,dragInfo:null,dataObject:null,tipView:null,tipString:null,init:function(){arguments.callee.base.apply(this,arguments);this.tipView=DG.mainPage.getPath("mainPane.tipView")},destroy:function(){this.caseTableView=null;this.tipView=null;arguments.callee.base.apply(this,arguments)},computeDragOperations:function(a){if(this.isValidAttribute(a)){return SC.DRAG_LINK}else{return SC.DRAG_NONE}},dragStarted:function(a){this.set("dataObject",a.data)},dragEnded:function(){this.set("dataObject",null)},dragEntered:function(a,b){},removeHighliting:function(){if(this.dragInfo){this.caseTableView.$(this.dragInfo.headerNode).removeClass(this.dragInfo.highliteClass)}this.get("tipView").hide()},acceptDragOperation:function(c,d){$(".sc-ghost-view").hide();var a=$(document.elementFromPoint(c.location.x,c.location.y));var b=a.parents(".slick-header").length>0;$(".sc-ghost-view").show();if(!b){this.removeHighliting()}return b},updateHighliting:function(a){var c=this.caseTableView.parentView,g=c._slickGrid,e=this._computeDragInfo(g,a);if(e){e.headerNode=(e.columnIndex>=0)&&this.caseTableView.$(".slick-header-column",g.getHeaderRow())[e.columnIndex];if(this.dragInfo&&(this.dragInfo.columnIndex===e.columnIndex)&&(this.dragInfo.nearerBound===e.nearerBound)){return}}this.removeHighliting();this.dragInfo=e;if(this.dragInfo){this.dragInfo.highliteClass=this.highliteClassFor(this.dragInfo);this.caseTableView.$(this.dragInfo.headerNode).addClass(this.dragInfo.highliteClass);var f=this.get("tipString");if(f){var h=g.getCellNodeBox(0,this.dragInfo.columnIndex),d=h.bottom-h.top,b=DG.ViewUtilities.viewToWindowCoordinates({x:h.left,y:h.bottom+d},this.caseTableView);this.get("tipView").show(b,f)}}},dragUpdated:function(a,b){this.updateHighliting(a.location)},dragExited:function(a,b){this.removeHighliting();this.dragInfo=null},performDragOperation:function(a,b){this.removeHighliting();var c=a.data;this._performDragOperation(c)}}})());DG.CaseTableOwnAttributeDragHelper=DG.CaseTableDragHelper.extend((function(){return{highliteClassFor:function(a){return"drag-insert-"+a.nearerBound},_performDragOperation:function(c){var b=c.attribute;var a;if(this.dragInfo){a=(this.dragInfo.nearerBound==="right")?this.dragInfo.columnIndex+1:this.dragInfo.columnIndex;this.caseTableView.parentView.gridAdapter.requestMoveAttribute(b,a)}},isValidAttribute:function(b){var a=b.data.attribute;return !SC.none(a)&&this.caseTableView.parentView.gridAdapter.canAcceptDrop(b.data.attribute)},_computeDragInfo:function(j,l){var m=j.getGridPosition(),a=j.getOptions().headerRowHeight,f={x:l.x-m.left,y:l.y-m.top},i=f.x,c=f.y<a,b=null;if(c){var e=j.getColumns(),k=0,h,d,g=e.findIndex(function(q,p,o){var n=false;d=q.width||0;h=k+(d/2);if(p>0&&i<h){n=true}k+=d;return n});if(g>=0){b={columnIndex:g,nearerBound:"left"}}else{b={columnIndex:e.length-1,nearerBound:"right"}}}return b}}})());DG.CaseTableForeignAttributeDragHelper=DG.CaseTableDragHelper.extend((function(){return{highliteClassFor:function(a){return"drag-hover"},tipString:function(){var b=null,h=this.get("dataObject");if(h){var f=h.attribute.get("name"),g=h.collection.get("name"),c=h.context.get("name"),i=this.caseTableView.parentView.gridAdapter,a=i&&i.getPath("collection.name"),d=i&&i.getPath("dataContext.name"),e=i&&i.getAttributeFromColumnIndex(this.dragInfo.columnIndex).get("name");b="DG.Collection.joinTip".loc(g,c,a,d,f,e)}return b}.property(),_performDragOperation:function(e){var a=e.attribute,c=this.caseTableView.parentView.gridAdapter,b=c&&c.get("dataContext"),d=c&&c.get("collection"),f=c&&c.getAttributeFromColumnIndex(this.dragInfo.columnIndex);if(a&&f&&b){DG.DataContextUtilities.joinSourceToDestCollection(a,b,d,f)}},isValidAttribute:function(b){var a=b.data.attribute;return !SC.none(a)&&a&&a.collection},_computeDragInfo:function(i,k){var l=i.getGridPosition(),a=i.getOptions().headerRowHeight,f={x:k.x-l.left,y:k.y-l.top},h=f.x,c=f.y<a,b=null;if(c){var e=i.getColumns(),j=0,d,g=e.findIndex(function(p,o,n){var m=false;d=p.width||0;if(o>0&&h<j+d){m=true}j+=d;return m});if(g>=0){b={columnIndex:g}}else{b={columnIndex:e.length-1}}}return b}}})());DG.CaseTableDragHelper.createHelper=function(f,e){var c=e.data.attribute,d=f.parentView.gridAdapter&&f.parentView.gridAdapter.get("dataContext"),b=c&&c.collection,a=!!(c&&d&&!SC.none(d.getCollectionByID(b.id)));return a?DG.CaseTableOwnAttributeDragHelper.create({caseTableView:f}):(b?DG.CaseTableForeignAttributeDragHelper.create({caseTableView:f}):null)};DG.CaseTableDropTarget=SC.View.extend(SC.SplitChild,(function(){return{name:null,dataContext:null,classNames:"dg-table-drop-target".w(),layout:{width:50},isTopLevel:false,isDropTarget:function(){return YES}.property(),isDropEnabled:function(){var b=this.get("dragAttribute");var a=this.get("isTopLevel");return DG.DataContextUtilities.canAcceptAttributeDrop(this.dataContext,b,a)}.property("dragAttribute"),isDropEnabledDidChange:function(){this.notifyPropertyChange("isDropEnabled")}.observes("*dataContext.hasDataInteractive"),dragAttribute:null,isDragInProgress:false,isDragEntered:false,minimumSize:10,size:30,dropData:null,childViews:"labelView".w(),classNameBindings:["isDragInProgress:dg-table-drop-target-show","isDragEntered:dg-table-drop-target-highlight"],labelView:SC.LabelView.extend({value:"",layout:{left:2,right:2,top:2,bottom:2}}),showDropHint:function(){this.set("isDragEntered",true);this.labelView.set("value","DG.CaseTableDropTarget.dropMessage".loc())},hideDropHint:function(){this.labelView.set("value","");this.set("isDragEntered",false)},extractDragInfo:function(a){if(a&&a.data){this.set("dragAttribute",a.data.attribute)}},convertFrameToView:function(c,a){var b=$(this.containerLayer()).offset();return{x:b.left-window.pageXOffset,y:b.top-window.pageYOffset,width:c.width,height:c.height}},computeDragOperations:function(a){this.extractDragInfo(a);if(this.get("isDropEnabled")){return SC.DRAG_LINK}else{return SC.DRAG_NONE}},dragStarted:function(a){this.extractDragInfo(a);if(this.get("isDropEnabled")){this.set("isDragInProgress",true)}},dragEnded:function(){this.set("dragAttribute",null);this.set("isDragInProgress",false)},dragEntered:function(a,b){if(this.get("isDropEnabled")){this.showDropHint()}},dragExited:function(a,b){this.hideDropHint()},acceptDragOperation:function(){return this.get("isDropEnabled")},performDragOperation:function(a,b){this.hideDropHint();this.set("dropData",a.data)},_externalDragObject:function(){var a=DG.mainPage.getPath("mainPane.dragAttributeData");if(a&&a.context===this.get("dataContext")){return{data:a}}}.property(),externalDragDidChange:function(){var a=this.get("_externalDragObject");if(!a){return}if(DG.mainPage.getPath("mainPane._isDraggingAttr")){this.dragStarted(a)}else{this.dragEnded()}}.observes("DG.mainPage.mainPane._isDraggingAttr"),dataDragEntered:function(a){var b=this.get("_externalDragObject");if(b){this.dragEntered(null,b);a.preventDefault()}},dataDragHovered:function(a){var b=this.get("_externalDragObject");if(b){a.dataTransfer.dropEffect="copy";a.preventDefault();a.stopPropagation()}else{return false}},dataDragDropped:function(b){var c=this.get("_externalDragObject");if(c){var a=DG.mainPage.getPath("mainPane.dragAttributeData");this.set("dropData",a);b.preventDefault()}else{return false}},dataDragExited:function(a){var b=this.get("_externalDragObject");if(b){this.dragExited(null,b);a.preventDefault()}},click:function(){DG.globalEditorLock.commitCurrentEdit();var b=DG.ComponentView.findComponentViewParent(this);var a=this.get("dataContext");var c={operation:"selectCases",cases:[],select:true,extend:false};if(b&&!b.get("isSelected")){b.select();return NO}a.applyChange(c)},touchStart:function(){return YES},touchEnd:function(a){a.allowDefault();return YES},mouseDown:function(){return YES}}}()));sc_require("components/case_table/data_context_base_model");DG.CaseTableModel=DG.DataContextBaseModel.extend({preferredAttributeWidths:null,tableRowHeights:null,_collapsedNodes:null,horizontalScrollOffset:0,isIndexHidden:false,init:function(){arguments.callee.base.apply(this,arguments);this.preferredAttributeWidths=this.preferredAttributeWidths||{};this.tableRowHeights=this.tableRowHeights||{};this._collapsedNodes=this._collapsedNodes||{}},getPreferredAttributeWidth:function(a){return this.preferredAttributeWidths[a]},setPreferredAttributeWidth:function(b,a){this.preferredAttributeWidths[b]=a},getTableRowHeight:function(a){return this.tableRowHeights[a]},setTableRowHeight:function(b,a){this.tableRowHeights[b]=a},didDeleteCases:function(a){if(a){a.forEach(function(b){var c=b.get("id");delete this._collapsedNodes[c]}.bind(this))}},isCollapsedNode:function(a){return(this._collapsedNodes[a.id]&&!this.isHiddenNode(a))},isHiddenNode:function(a){var b=a.get("parent");if(b){if(this._collapsedNodes[b.id]){return true}else{return this.isHiddenNode(b)}}else{return false}},collapseNode:function(a){if(a){this._collapsedNodes[a.id]=true}},expandNode:function(a){delete this._collapsedNodes[a.id]},collapsedNodes:function(){var a;var b=[];for(a in this._collapsedNodes){if(this._collapsedNodes.hasOwnProperty(a)){b.push(a)}}return b}.property()});DG.CaseTableRowSelectionModel=function(y){var K;var z;var g;var D=[];var m=this;var c=new Slick.EventHandler();var E;var V;var B;var C=null;var X=null;var W=null;var a=null;var J=null;var h=null;var A=null;var x=null;var N=null;var Q=null;var s=null;var r=null;var e=20;var F=100;var i={selectActiveRow:true};function T(Y){V=$.extend(true,{},i,y);z=V.caseTableAdapter;g=z.gridDataView;K=Y;c.subscribe(K.onKeyDown,o(j));c.subscribe(K.onClick,o(d));c.subscribe(K.onDragInit,o(w));c.subscribe(K.onDragStart,o(b));c.subscribe(K.onDrag,o(R));c.subscribe(K.onDragEnd,o(I))}function P(){c.unsubscribeAll()}function k(Y){SC.run(function(){z.selectRowsInList(Y)})}function o(Y){return function(){var Z;if(!E){E=true;Z=Y.apply(this,arguments);E=false;return Z}}}function v(Y){var ab=[];for(var aa=0;aa<Y.length;aa++){for(var Z=Y[aa].fromRow;Z<=Y[aa].toRow;Z++){ab.push(Z)}}return ab}function q(ab){var Z=[];var Y=K.getColumns().length-1;for(var aa=0;aa<ab.length;aa++){Z.push(new Slick.Range(ab[aa],0,ab[aa],Y))}return Z}function U(ab,aa){var Y,Z=[];for(Y=ab;Y<=aa;Y++){Z.push(Y)}for(Y=aa;Y<ab;Y++){Z.push(Y)}return Z}function O(){return v(D)}function l(Y){p(q(Y))}function p(Y){D=Y;m.onSelectedRangesChanged.notify(D)}function M(){return D}function j(ah){var ad=K.getEditorLock();var Z=(ad&&ad.isActive());var ac=K.getActiveCell();var ak=38;var ae=40;var aj,am,ag,al,af,ab,ai,Y,aa;if(!Z&&ac&&!ah.ctrlKey&&!ah.altKey&&!ah.metaKey&&(ah.which===ak||ah.which===ae)){aj=(ah.which===ak)?-1:1;am=ac.row;if(ah.shiftKey){ab=O();ab.sort(function(an,ao){return an-ao});if(!ab.length){ab=[ac.row]}ai=ab[0];Y=ab[ab.length-1];if(ah.which===ae){aa=am<Y||ai===Y?++Y:++ai}else{aa=am<Y?--Y:--ai}if(aa>=0&&aa<K.getDataLength()){K.scrollRowIntoView(aa);k(U(ai,Y))}}else{ag=K.getDataLength();al=Math.min(Math.max(0,am+aj),ag);af=g.getItem(al);if(af._isProtoCase){al=am}k([al]);K.setActiveCell(al,ac.cell)}ah.stopImmediatePropagation()}}function w(Y){if(K.getActiveCell()){K.getEditorLock().commitCurrentEdit();K.focus()}Y.stopImmediatePropagation()}function b(ac){z.set("isModelDragging",true);var aa=K.getCellFromEvent(ac);var Z=K.getCellNodeBox(aa.row,aa.cell);B=aa&&aa.row;C=(Z.top+Z.bottom)/2;X=ac.clientX;W=a=ac.clientY;for(var Y=ac.target;Y;Y=Y.parentElement){if(Y&&$(Y).hasClass("dg-proto-row")){J=Y;h=J.getBoundingClientRect()}if(Y&&$(Y).hasClass("slick-viewport")){A=Y;x=A.getBoundingClientRect();break}}if(J){$(J).addClass("drag-source");N=J.cloneNode(true);$(N).addClass("drag-preview");$(N).find(".slick-row-resizer").remove();$(A).append(N)}var ab=!J&&aa&&[aa.row];if(ab){k(ab)}ac.stopImmediatePropagation()}function H(ad){if(!ad){return ad}var aa=$(ad);var ac=aa.data("row-id");var ae=g.getRowById(ac);var ab=g.getItem(ae+1);var Z=ab&&ab.get("id");var Y=Z&&$(A).find('[data-row-id="'+Z+'"]');if(Y&&Y.hasClass("dg-collapsed-row")){return null}return Y&&Y[0]||null}function S(ad){if(!ad){return ad}var aa=$(ad);var ab=aa.data("row-id");var ae=g.getRowById(ab);var Z=g.getItem(ae-1);var ac=Z&&Z.get("id");var Y=ac&&$(A).find('[data-row-id="'+ac+'"]');if(Y&&Y.hasClass("dg-collapsed-row")){return null}return Y&&Y[0]||null}function n(){var ac=[],ae,ab;var ad=A.getBoundingClientRect();var ah=X,af=a;af=Math.max(af,ad.top+1);af=Math.min(af,ad.bottom-1);var ag=isFinite(af)?document.elementsFromPoint(ah,af):[];for(var Z=0;Z<ag.length;++Z){var aa=ag[Z];if($(aa).hasClass("slick-row")&&!$(aa).hasClass("drag-preview")){var Y=aa.getBoundingClientRect();if(!$(aa).hasClass("dg-collapsed-row")){if(af>(Y.top+Y.bottom)/2){ab=H(aa)}else{ae=S(aa)}}if(ae!==undefined){ac.push(ae)}ac.push(aa);if(ab!==undefined){ac.push(ab)}if((ae===undefined)&&(ab===undefined)){ac.push(aa)}break}}return ac}function t(){var Z;var Y=n();if(Q){for(Z=0;Z<Q.length;++Z){$(Q[Z]).removeClass("drag-hilite")}}for(Z=0;Z<Y.length;++Z){$(Y[Z]).addClass("drag-hilite")}Q=Y}function u(){var ac=W-h.top;var Y=A.scrollTop+a-x.top-ac;var aa=K.getViewport();var Z=Math.min(aa.bottom,g.get("caseTableLength"));var ab=z.get("rowHeight");Y=Math.max(A.scrollTop,Y);Y=Math.min(Math.max(Z-1,0)*ab,Y);$(N).css("top",Y+"px")}function G(){var Z=K.getViewport();if(Z.top>0){var Y=Z.top-1;K.scrollRowIntoView(Y);u();t();s=Y>0?setTimeout(G,F):null}}function f(){var Z=K.getViewport();var Y=g.get("caseTableLength");if(Z.bottom<Y){var aa=Z.bottom+1;K.scrollRowIntoView(aa);u();t();r=aa<Y?setTimeout(f,F):null}}function R(af){var ab=C+(af.clientY-W);var ac=K.getCellFromPoint(0,ab);var aj;var aa,Y,ad;a=af.clientY;if(ac&&(B!=null)&&!J){aj=[];Y=Math.min(B,ac.row);ad=Math.max(B,ac.row);for(aa=Y;aa<=ad;aa+=1){aj.push(aa)}k(aj)}else{if(J){u();t();var ag=A.getBoundingClientRect();var ae=K.getViewport();var ah=g.get("caseTableLength");var ai=af.clientY-ag.top<e;if(ai){if(!s&&(A.scrollTop>0)){s=setTimeout(G,F)}}else{if(s){clearInterval(s);s=null}var Z=ag.bottom-af.clientY<e;if(Z){if(!r&&(ae.bottom<ah)){r=setTimeout(f,F)}}else{if(r){clearInterval(r);r=null}}}}}af.stopImmediatePropagation()}function I(aq){aq.stopImmediatePropagation();var ag=z.get("dataContext");var at=J&&n();var aa=at&&(at.length>=1)&&at[0];var aj=aa&&$(aa).hasClass("dg-collapsed-row");var al=aa&&$(aa).data("row-id");var ah=ag&&al&&ag.getCaseByID(al);var ad=aa&&$(aa).hasClass("dg-proto-row");var an=aj?ah:ah&&ah.get("parent");var ac=an&&an.get("id")||null;var ab=at&&(at.length>=2)&&at[1];var ap=ab&&$(ab).hasClass("dg-collapsed-row");var am=ab&&$(ab).data("row-id");var af=ag&&am&&ag.getCaseByID(am);var ak=ab&&$(ab).hasClass("dg-proto-row");var ao=ap?af:af&&af.get("parent");var Z=ao&&ao.get("id")||null;var ar=ac||Z;var ai=ah&&af&&(ac===Z);var au=(ah==null)&&(af==null);var Y=g.getProtoCase();if(Y&&!(ad&&ai)&&!(ak&&ai)){Y.set("beforeCaseID",!aa||au||ai||ad?am||null:null);Y.set("parentCaseID",ar||null);SC.run(function(){if(aj){g.expandGroup(al)}z.refresh();setTimeout(function(){var av=g.getRowById(Y.get("id"));if(av){K.scrollRowIntoView(av)}},50)})}B=undefined;C=null;X=null;W=null;a=null;if(J){$(J).removeClass("drag-source");J=null}h=null;if(N){$(N).remove();N=null}if(Q){for(var ae=0;ae<Q.length;++ae){$(Q[ae]).removeClass("drag-hilite")}Q=null}if(s){clearTimeout(s);s=null}if(r){clearTimeout(r);r=null}A=null;x=null;z.set("isModelDragging",false)}function d(aa){var ag=K.getCellFromEvent(aa);if(!ag){return false}if(!K.canCellBeActive(ag.row,ag.cell)&&!z.isCellRowSelectable(ag.row,ag.cell)){return false}var ad=v(D);var ae=$.inArray(ag.row,ad);if(!aa.ctrlKey&&!aa.shiftKey&&!aa.metaKey){return false}else{if(K.getOptions().multiSelect){if(ae===-1&&(aa.ctrlKey||aa.metaKey)){ad.push(ag.row);K.setActiveCell(ag.row,ag.cell)}else{if(ae!==-1&&(aa.ctrlKey||aa.metaKey)){ad=$.grep(ad,function(ai,ah){return(ai!==ag.row)});K.setActiveCell(ag.row,ag.cell)}else{if(ad.length&&aa.shiftKey){ad.sort(function(ai,ah){return ai-ah});var Z=ad[0];var af=ad[ad.length-1];var ab=Math.min(ag.row,Z);var ac=Math.max(ag.row,af);ad=[];for(var Y=ab;Y<=ac;Y++){ad.push(Y)}K.setActiveCell(ag.row,ag.cell)}}}}}k(ad);aa.stopImmediatePropagation();return true}$.extend(this,{getSelectedRows:O,setSelectedRows:l,getSelectedRanges:M,setSelectedRanges:p,init:T,destroy:P,onSelectedRangesChanged:new Slick.Event()})};DG.ScrollAnimationUtility=SC.Object.extend({kAnimationTime:1000,isAnimating:false,startTime:null,targetView:null,destroy:function(){this.endAnimation();arguments.callee.base.apply(this,arguments)},animate:function(d,b,a){var g=this,f=50,e=this.kAnimationTime;this.targetView=d;this.startValue=b;this.endValue=a;var c=function(){var h=(new Date()).valueOf(),i=(h-g.startTime)/e,k;function l(m){if(m>=1){return 1}else{return DG.AnimationMath.DefaultAnimationTween(m)}}function j(n,m,o){return n+o*(m-n)}k=l(i);g.get("targetView").scrollToRow(j(g.startValue,this.endValue,k));if(i<1){DG.assert(!g.animationTimer.get("isPaused"))}else{g.endAnimation()}}.bind(this);if(this.isAnimating){this.endAnimation()}this.isAnimating=true;this.startTime=(new Date()).valueOf();if(SC.none(this.animationTimer)){this.animationTimer=SC.Timer.schedule({action:c,interval:f,repeats:YES,until:false})}this.animationTimer.set("isPaused",NO);c()},endAnimation:function(b,a){if(this.animationTimer){this.animationTimer.set("isPaused",YES);this.endTime=(new Date()).valueOf()}this.isAnimating=false}});DG.ImageView=SC.ImageView.extend({altText:null,localize:false,displayAltText:function(){var a=this.get("altText")||this.get("toolTip")||"";return !SC.empty(a)&&this.get("localize")?a.loc():a}.property("altText","toolTip","localize"),render:function(c){arguments.callee.base.apply(this,arguments);var a=this.get("displayAltText");if(!SC.empty(a)){c.setAttr("alt",a)}var b=this.get("displayToolTip");if(!SC.empty(b)){c.setAttr("title",b)}}});DG.MouseAndTouchView={allowParent:YES,isMouseDown:NO,isMouseOver:NO,isActive:NO,mouseMoved:function(a){this.mouseOver(a);return YES},mouseOver:function(a){if(this.get("isMouseDown")){this.set("isActive",YES)}this.set("isMouseOver",YES);return YES},mouseExited:function(a){this.set("isActive",NO);this.set("isMouseOver",NO);return YES},mouseDown:function(a){if(!this.get("isMouseDown")){this.set("isMouseDown",YES);this.set("isActive",YES)}if(this.allowParent&&this.parentView.mouseDown){return this.parentView.mouseDown(a)}else{return YES}},mouseDragged:function(a){if(this.allowParent&&this.parentView.mouseDragged){this.set("isActive",NO);return this.parentView.mouseDragged(a)}else{return NO}},mouseUp:function(a){if(this.get("isActive")){this.set("isActive",NO);this.set("isMouseOver",NO);this.set("isMouseDown",NO);this.doIt();DG.mainPage.docView.coverUpComponentViews("uncover")}else{this.set("isMouseDown",NO);this.mouseExited(a);if(this.allowParent&&this.parentView.mouseUp){return this.parentView.mouseUp(a)}}return YES},touchStart:function(a){return YES},touchEnd:function(a){this.doIt()},doIt:null};sc_require("components/case_table/scroll_animation_utility");sc_require("components/case_table/case_table_row_selection_model");sc_require("views/image_view");sc_require("views/mouse_and_touch_view");DG.CaseTableView=SC.View.extend((function(){var b=59,c=200;function a(e){var d;for(;e&&!d;e=e.get("parentView")){d=e.get("controller")}return d}return{classNames:"dg-case-table-view",childViews:"titleBarContainer tableView _hiddenDragView".w(),dataContext:function(){return this.getPath("gridAdapter.dataContext")}.property(),dataContextDidChange:function(){this.respondToDataContextAndGridAdapterChanges()}.observes("gridAdapter.dataContext"),titleBarContainer:SC.View.extend({childViews:"titleBar".w(),classNames:["dg-case-table-title-bar-container"],layout:{left:0,right:0,top:0,height:22},mouseDown:function(d){if(d.target.tagName!=="INPUT"){DG.globalEditorLock.commitCurrentEdit()}return NO},titleBar:SC.View.extend({childViews:"titleView newAttrButtonView".w(),classNames:"dg-case-table-title-bar newAttrButtonView".w(),refView:function(){var d=this.parentView;return d&&d.parentView}.property(),titleView:SC.LabelView.extend(DG.MouseAndTouchView,SC.AutoResize,{refView:function(){var d=this.parentView;return d&&d.get("refView")}.property(),layout:{left:0,top:3,right:22,height:22},exampleNode:null,classNames:"dg-case-table-title".w(),isEditable:function(){var e=this.getPath("refView.dataContext.owningDataInteractive");var d=e&&e.get("preventDataContextReorg");return !e||!d}.property(),value:function(){var g=this.getPath("refView.collectionName");var e=this.getPath("refView.caseCount");var f=this.getPath("refView.nonemptyCaseCount");var i=(e===f);var h=!!this.getPath("refView.childTable");var d=h?0:this.getPath("refView.dataContext.setAsideCount");if(h||(i&&!d)){return"DG.TableController.collectionTitleText".loc(g,e)}else{if(i&&d){return"DG.TableController.collectionTitleTextWithSetAside".loc(g,e,d)}else{if(!i&&!d){return"DG.TableController.collectionTitleText-nonempty".loc(g,f,d)}else{return"DG.TableController.collectionTitleTextWithSetAside-nonempty".loc(g,f,d)}}}}.property(),valueDidChange:function(d){this.notifyPropertyChange("value");this.set("toolTip",this.get("value"))}.observes("*refView.collectionName","*refView.caseCount","*refView.nonemptyCaseCount","*refView.dataContext.setAsideCount"),toolTip:"",inlineEditorWillBeginEditing:function(k,l,g){arguments.callee.base.apply(this,arguments);k.set("value",this.getPath("refView.collectionName"));var f=this.get("exampleNode");var e=this.get("parentView");var i=e.get("frame");var j=4,h=2;var d=DG.ViewUtilities.viewToWindowCoordinates({x:j,y:h},e);if(!f){f=this.get("layer").cloneNode(false);f.id=f.id+"-clone";f.style.visibility="hidden";f.style.textAlign="center";f.className=f.className.replace("dg-case-table-title","");e.get("layer").appendChild(f);this.set("exampleNode",f)}f.style.left=3+"px";f.style.top=9+"px";k.set({exampleElement:f,exampleFrame:{x:d.x,y:d.y,width:i.width-2*j,height:i.height-2*h}})},inlineEditorDidCommitEditing:function(e,f,d){var i=a(this),h=i&&i.get("dataContext"),g=this.getPath("refView.collectionName");if(h){DG.CaseDisplayUtils.setCollectionNameWithCommand(h,g,f)}return arguments.callee.base.apply(this,arguments)},localize:true,doIt:function(){this.beginEditing()}}),newAttrButtonView:DG.ImageView.extend({refView:function(){return this.parentView&&this.parentView.get("refView")}.property(),classNames:["dg-floating-plus"],classNameBindings:["disabled"],layout:{top:0,right:0,width:22,height:22},value:"../../../../static/dg/fr/cert/source/resources/images/add_circle_grey_72x72.png",tooltip:"DG.TableController.newAttributeTooltip".loc(),disabled:function(){var d=this.getPath("refView.gridAdapter.dataContext");var e=!this.getPath("refView.gridAdapter.hasParentCollection");return d&&e&&DG.DataContextUtilities.isTopLevelReorgPrevented(d)}.property("_dataContextDidChange"),dataContextDidChange:function(){this.notifyPropertyChange("_dataContextDidChange")}.observes("refView.gridAdapter.dataContext.metadataChangeCount"),didAppendToDocument:function(){arguments.callee.base.apply(this,arguments);var d=this.get("tooltip");if(d){this.$().attr("title",d)}},mouseDown:function(d){var e=a(this),f=this.getPath("refView.gridAdapter.collection");if(e&&f&&(d.which===1)){SC.RootResponder.responder.sendAction("newAttributeAction",e,this,this.get("pane"),{collection:f,autoEditName:true})}return YES},touchStart:function(d){return YES},touchEnd:function(d){d.allowDefault();return YES}})})}),tableView:SC.View.extend({classNames:["dg-case-table"],layout:{left:0,right:0,top:22,bottom:0},backgroundColor:"white",isDropTarget:true,classNameBindings:["isDragInProgress:dg-table-drop-target-show"],dragHelper:null,computeDragOperations:function(d){if(this.isValidAttribute(d)){return SC.DRAG_LINK}else{return SC.DRAG_NONE}},dragStarted:function(e){var d=DG.CaseTableDragHelper.createHelper(this,e);if(d){this.set("dragHelper",d);this.get("dragHelper").dragStarted(e)}},dragEnded:function(){var d=this.get("dragHelper");d.dragEnded();d.destroy();this.set("dragHelper",null)},dragEntered:function(d,e){this.get("dragHelper").dragEntered(d,e)},dragUpdated:function(d,e){this.get("dragHelper").dragUpdated(d,e)},dragExited:function(d,e){this.get("dragHelper").dragExited(d,e)},acceptDragOperation:function(d,e){return this.get("dragHelper").acceptDragOperation(d,e)},performDragOperation:function(d,e){this.get("dragHelper").performDragOperation(d,e)},isValidAttribute:function(d){return this.get("dragHelper").isValidAttribute(d)},_externalDragObject:function(){var d=DG.mainPage.getPath("mainPane.dragAttributeData");if(d&&d.context===this.parentView.get("dataContext")){return{data:d}}}.property(),externalDragDidChange:function(){var d=this.get("_externalDragObject");if(!d){return}if(DG.mainPage.getPath("mainPane._isDraggingAttr")){this.dragStarted(d)}else{this.dragEnded()}}.observes("DG.mainPage.mainPane._isDraggingAttr"),dataDragEntered:function(d){var e=this.get("_externalDragObject");if(e&&this.isValidAttribute(e)){this.dragEntered(null,e);d.preventDefault()}},dataDragHovered:function(d){var e=this.get("_externalDragObject");if(e&&this.isValidAttribute(e)){d.dataTransfer.dropEffect="copy";d.preventDefault();d.stopPropagation();this._computeInsertionPoint({x:d.clientX,y:d.clientY})}else{return false}},dataDragDropped:function(e){var f=this.get("_externalDragObject");if(f&&this.isValidAttribute(f)){e.preventDefault();var d=DG.mainPage.getPath("mainPane.dragAttributeData");this._performDragOperation(d)}else{return false}},dataDragExited:function(d){var e=this.get("_externalDragObject");if(e&&this.isValidAttribute(e)){this.dragExited(null,e);d.preventDefault()}}}),parentTable:null,childTable:null,_hiddenDragView:SC.LabelView.design({classNames:"dg-drag-label".w(),layout:{width:100,height:20,top:-50,left:0},value:""}),ancestorViewDidResizeOrScroll:function(){this.invokeLater(function(){var d=this.get("visibleFrameBounds");var e=this.getPath("titleBarContainer.titleBar");if(d){e.adjust({left:d.x,width:d.width,right:null})}}.bind(this))},frameBounds:function(){var d=this.get("parentView"),e=this.get("frame");return d?d.convertFrameToView(e,null):e}.property(),visibleFrameBounds:function(){var d=this,h=this.get("parentView"),k=this.get("frame"),g=h?h.convertFrameToView(k,null):k,i={},f,e;while(h&&!(d instanceof DG.HierTableView)){d=h;h=d.get("parentView")}if(!h){return}var j=h.convertFrameToView(d.get("frame"),null);i.x=Math.max(j.x,g.x);i.y=Math.max(j.y,g.y);f=Math.min(j.x+j.width,g.x+g.width);e=Math.min(j.y+j.height,g.y+g.height);i.width=Math.max(f-i.x,0);i.height=Math.max(e-i.y,0);return this.convertFrameFromView(i,null)}.property(),layout:{left:0,right:0,top:0,bottom:0},backgroundColor:"white",collectionName:function(d,e){if(e!==undefined){this.setPath("gridAdapter.collectionName",e)}return this.getPath("gridAdapter.collectionName")}.property(),collectionNameDidChange:function(){this.notifyPropertyChange("collectionName")}.observes("*gridAdapter.collectionName"),caseCount:function(){return this.getPath("gridAdapter.collection.caseCount")}.property(),nonemptyCaseCount:function(){return this.getPath("gridAdapter.collection.nonemptyCaseCount")}.property(),caseCountDidChange:function(){this.notifyPropertyChange("caseCount")}.observes("*gridAdapter.collection.caseCount"),nonemptyCaseCountDidChange:function(){this.notifyPropertyChange("nonemptyCaseCount")}.observes("*gridAdapter.collection.nonemptyCaseCount"),gridAdapter:null,gridDataView:null,gridView:undefined,_slickGrid:null,_gridEventHandler:null,_gridWidth:0,_prevGridWidth:0,_protoCaseTimer:null,_canvasResizeCounter:0,clearProtoCaseTimer:function(){if(this._protoCaseTimer){clearTimeout(this._protoCaseTimer);this._protoCaseTimer=null}},resetProtoCaseTimer:function(){this.clearProtoCaseTimer();this._protoCaseTimer=setTimeout(function(){if(!this._slickGrid){return}var e=this._slickGrid.getDataLength(),d=this._slickGrid.getDataItem(e-1),f=d&&d._isProtoCase&&DG.ObjectMap.length(d._values);if(f){SC.run(function(){this.commitProtoCase(d)}.bind(this))}}.bind(this),300)},commitProtoCase:function(g){function k(o,s){var n=s.getParentCollectionID(),r=n&&o.getCollectionByID(n),q=g&&g.parentCaseID&&r&&r.getCaseByID(g.parentCaseID);if(q){return q}var p=r&&r.getCaseCount();if(!SC.none(p)){return r.getCaseAt(p-1)}}var l=this.get("gridAdapter"),h=l.get("gridDataView"),i=g&&g.collection,j=i&&i.getAttributeIDs(),e=g&&g.get("beforeCaseID"),d=k(this.get("dataContext"),i),f=d&&d.get("id"),m;if(!i||!j){return}m=j.map(function(n){var o=g._values[n];return o!=null?o:""});g._values={};if(h&&f){this.invokeNext(function(){this.invokeNext(function(){h.expandGroup(f);l.refresh()}.bind(this))}.bind(this))}DG.DataContextUtilities.createCaseUndoable(this.get("dataContext"),{collection:i,attrIDs:j,values:m,beforeCaseID:e,parent:d})},gridViewport:function(){return this.get("_slickGrid").getViewport()}.property("_slickGrid"),gridWidth:function(d,e){if(!SC.none(e)){this._prevGridWidth=this._gridWidth;this._gridWidth=e;return this}return this._gridWidth}.property(),gridWidthChange:function(){return this._gridWidth-this._prevGridWidth}.property(),gridWidthDidChange:function(){var d=this.get("parentView");if(d){d.gridWidthDidChange(this)}}.observes("gridWidth"),columnWidths:function(){var d=this._slickGrid.getColumns();var e={};if(!SC.none(d)){d.forEach(function(f){e[f.id]=f.width})}return e}.property(),sizeDidChange:function(){var d=this.get("parentView");if(d){d.childTableLayoutDidChange(this)}}.observes("size"),rowCountDidChange:function(){if(!SC.none(this.get("parentView"))){this.get("parentView").rowCountDidChange(this)}}.observes("rowCount"),tableDidScroll:function(){if(!SC.none(this.get("parentView"))){this.get("parentView").tableDidScroll(this)}}.observes("scrollPos"),tableDidExpandCollapse:function(){var d=this.get("parentView");if(d){d.tableDidExpandCollapse(this)}}.observes("expandCollapseCount"),rowCount:0,scrollPos:null,expandCollapseCount:0,scrollAnimator:null,displayProperties:["gridAdapter","gridDataView","_slickGrid"],init:function(){this.beginPropertyChanges();arguments.callee.base.apply(this,arguments);this.scrollAnimator=DG.ScrollAnimationUtility.create();this.endPropertyChanges();this.invokeLater(function(){this.ancestorViewDidResizeOrScroll()})},viewDidResize:function(){arguments.callee.base.apply(this,arguments);this._canvasResizeCounter++;this.invokeLast(function(){this._canvasResizeCounter--;if(this._slickGrid){this._slickGrid.resizeCanvas();this.setIfChanged("gridWidth",this._slickGrid.getContentSize().width);if(this._canvasResizeCounter===0){this.invokeLater(function(){if(this._slickGrid){this._slickGrid.resizeCanvas()}}.bind(this),400)}}}.bind(this))},headerMenu:null,hideHeaderMenu:function(){if(this.headerMenu){this.headerMenu.hideMenu()}},initGridView:function(){var h=this.tableView.get("layer"),g=this.get("gridAdapter"),i=g&&g.gridDataView,j=this.get("parentView");this._slickGrid=new Slick.Grid(h,g.gridDataView,g.gridColumns,g.gridOptions);this._slickGrid.setSelectionModel(new DG.CaseTableRowSelectionModel({selectActiveRow:true,caseTableAdapter:this.gridAdapter,caseTableView:this}));if(this.getPath("gridAdapter.isMultilineRowHeight")){this.$(".slick-viewport").addClass("slick-multiline-cells")}if(DG.supports("caseTableHeaderMenus")){this.headerMenu=new Slick.Plugins.HeaderMenu({buttonIsCell:true,buttonImage:"../../../../static/dg/fr/cert/source/resources/slickgrid/images/down.gif"});this._slickGrid.registerPlugin(this.headerMenu);this.$(".slick-viewport").addClass("dg-wants-touch").addClass("dg-wants-wheel");this.headerMenu.onBeforeMenuShow.subscribe(function(m,l){j.hideHeaderMenus();var k=0;if(l.menu&&l.menu.items&&l.menu.items.length){l.menu.items.forEach(function(n){if(n.updater){n.updater(l.column,l.menu,n)}if(!n.disabled){++k}});setTimeout(function(){$(".slick-header-menu").addClass(function(n,o){return(!o||(o.indexOf("dg-wants-touch")<0))?"dg-wants-touch":""})},10)}return(k>0)});this.headerMenu.onCommand.subscribe(function(l,k){SC.run(function(){var m=a(this);if(m){m.doCommand(k)}}.bind(this))}.bind(this))}this._gridEventHandler=new Slick.EventHandler();this.subscribe("onClick",this.handleClick);this.subscribe("onKeyDown",this.handleKeyDown);this.subscribe("onScroll",this.handleScroll);this.subscribe("onHeaderClick",this.handleHeaderClick);this.subscribe("onHeaderDragInit",function(l,k){DG.globalEditorLock.commitCurrentEdit();l.stopImmediatePropagation()});this.subscribe("onHeaderDragStart",this.handleHeaderDragStart);this.subscribe("onRowResizeDragInit",this.handleRowResizeDragInit);this.subscribe("onRowResizeDragStart",this.handleRowResizeDragStart);this.subscribe("onRowResizeDrag",this.handleRowResizeDrag);this.subscribe("onRowResizeDragEnd",this.handleRowResizeDragEnd);this.subscribe("onBeforeAutoEditCell",this.handleBeforeAutoEditCell);this.subscribe("onBeforeEditCell",this.handleBeforeEditCell);this.subscribe("onCanvasWidthChanged",function(l,k){SC.run(function(){this.setIfChanged("gridWidth",this._slickGrid.getContentSize().width)}.bind(this))}.bind(this));this.subscribe("onColumnsResized",this.handleColumnsResized);this.subscribe("onColumnResizing",this.handleColumnResizing);this.subscribe("onSelectedRowsChanged",this.handleSelectedRowsChanged);var f=this._slickGrid.getEditController(),e=f.commitCurrentEdit,d=f.cancelCurrentEdit;f.commitCurrentEdit=function(){var l=this._slickGrid.getActiveCell(),k=l&&this._slickGrid.getDataItem(l.row);if(k&&k._isProtoCase){this.resetProtoCaseTimer()}return e()}.bind(this);f.cancelCurrentEdit=function(){var l=this._slickGrid.getActiveCell(),k=l&&this._slickGrid.getDataItem(l.row);if(k&&k._isProtoCase){this.resetProtoCaseTimer()}return d()}.bind(this);i.onRowCountChanged.subscribe(function(l,k){SC.run(function(){if(this._slickGrid){var m=this.saveEditState();this._slickGrid.invalidate();this.set("rowCount",k.current);if(m){this.restoreEditStateWhenReady(m)}}}.bind(this))}.bind(this));i.onRowsChanged.subscribe(function(l,k){SC.run(function(){if(this._slickGrid){var m=this.saveEditState();this._slickGrid.invalidate();if(m){this.restoreEditStateWhenReady(m)}}}.bind(this))}.bind(this));$(h).on("change",".dg-checkbox-cell input:checkbox",{slickGrid:this._slickGrid},this.handleCheckboxChange);$(h).show();this.adjustHeaderForOverflow();this.notifyPropertyChange("gridView")},handleCheckboxChange:function(i){function k(m,C,B,t){var A=C,p=m,z=p.getValue(C),o=t,n=B,r=n.get("name"),v=p.get("collection"),s=v&&v.get("name")||"",x=v&&v.getAttributeByID(Number(A)),y=x&&x.get("name"),w=p.id;function u(E,F,D){n.applyChange({operation:"updateCases",cases:[p],attributeIDs:[E],values:[[F]]})}var q=DG.Command.create({name:"caseTable.editCellValue",undoString:"DG.Undo.caseTable.editCellValue",redoString:"DG.Redo.caseTable.editCellValue",log:"editValue: { collection: %@, case: %@, attribute: '%@', old: '%@', new: '%@' }".fmt(s,w,A,z,o),execute:function(){u(A,o)},undo:function(){u(A,z,true)},redo:function(){n=DG.currDocumentController().getContextByName(r);v=n&&n.getCollectionByName(s);x=v&&v.getAttributeByName(y);A=x.get("id");if(p){u(A,o,true)}}});DG.UndoHistory.execute(q)}var h=i.data.slickGrid;var d=h.getCellFromEvent(i);var e=h.getDataItem(d.row);var g=h.getColumns()[d.cell];var j=g.id;var l=g.context;var f=this.checked?"true":"false";k(e,j,l,f);i.preventDefault();i.stopPropagation()},_refreshDataView:function(f){var d=this.get("childTable");var e=this.get("gridAdapter");if(e){e.gridDataView.refresh()}else{DG.logWarn("CaseTableView._resetDataView: no data view")}if(d&&f){d._refreshDataView(f)}},getViewportPosition:function(i){var f=this.getPath("gridAdapter.gridDataView");var h=f.getRowById(i);var d=this.get("gridViewport");var e=d.bottom-d.top;var g=h-d.top;if(g>=0&&g<=e){return h-d.top}else{return undefined}},alignChildTables:function(f,e){var g=this.get("childTable");if(!g){return}var d=g.getPath("gridAdapter.gridDataView").getRowById(e);g.animateScrollToTop(d-f);g.alignChildTables(f,e)},showCaseIndexPopup:function(d,f){var h=this.get("dataContext"),n=this.getPath("gridAdapter.isCollectionReorgAllowed"),m=h&&h.getSelectedCases(),j=m&&m.get("length"),l=j>0,e=j===1,g=this._slickGrid.getDataItem(f.row),i=g&&g._isProtoCase,p=g&&g.get("isEmpty"),o=[{title:"DG.CaseTable.indexMenu.moveEntryRow",localize:true,target:this,action:"moveDataEntryRow",isEnabled:!i},{title:"DG.CaseTable.indexMenu.insertCase",localize:true,target:this,action:"insertCase"},{title:"DG.CaseTable.indexMenu.insertCases",localize:true,target:this,action:"insertCases"},{title:e?"DG.CaseTable.indexMenu.deleteCase":"DG.CaseTable.indexMenu.deleteCases",localize:true,target:a(this),action:"deleteSelectedCases",isEnabled:l}],k=DG.MenuPane.create({classNames:"dg-case-index-popup",layout:{width:200,height:150},items:o});if(n&&!p){this._caseIndexMenuCell=SC.copy(f);k.popup(d.target)}},collapseGroup:function(e){this.getPath("gridAdapter.gridDataView").collapseGroup(e);var d=this.getPath("childTable.gridAdapter.gridDataView");if(d){d.resetProtoCases(e)}},collapseCase:function(f){var e=this.get("childTable");var d;this.collapseGroup(f);if(e){e._refreshDataView(true);d=this.getViewportPosition(f);this.alignChildTables(d,f)}},expandCase:function(e){var d=this.get("childTable");this.getPath("gridAdapter.gridDataView").expandGroup(e);if(d){d._refreshDataView(true)}},moveDataEntryRow:function(){var d=this.get("gridAdapter"),i=d.get("gridDataView"),h=this._caseIndexMenuCell.row,g=i&&i.getItem(h),f=g&&g.get("parent"),e=g&&g.get("collection"),j=i&&i.getProtoCase(e);if(j&&g&&!g._isProtoCase){j.set("beforeCaseID",g.get("id"));j.set("parentCaseID",f&&f.get("id"));d.deselectAllCases();d.refresh()}},insertCase:function(){this.doInsertCases(1)},doInsertCases:function(f,p){var e=this.get("dataContext"),s=this.getPath("gridAdapter.gridDataView"),k=this._caseIndexMenuCell.row,r=s&&s.getItem(k),g=p?k+1:k,o=s&&s.getItem(g),j=o&&o._isProtoCase?s.getItem(g+1):o,h=r.getPath("collection.id"),q=j&&j.getPath("item.id"),n={},u=[n],d,m;while((d=r.get("parent"))){$.extend(n,d.copyValues());r=d}for(var l=1;l<f;++l){u.push(DG.clone(n))}DG.UndoHistory.execute(DG.Command.create({name:"caseTable.insertCases",undoString:"DG.Undo.caseTable.insertCases",redoString:"DG.Redo.caseTable.insertCases",log:"insert %@ cases in table".fmt(f),execute:function(){m=e.addItems(u,q).caseIDs},undo:function(){var i=m.map(function(v){return DG.store.find("DG.Case",v)});e.deleteCasesAndChildren({operation:"deleteCases",cases:i})},redo:function(){this.execute()}}));if(m){var t=[];m.forEach(function(i){var v=e.getCaseByID(i),w=v&&v.getPath("collection.id");if(w===h){t.push(v)}});if(t.length){this.invokeLater(function(){e.applyChange({operation:"selectCases",cases:t,select:true})})}}},insertCases:function(){var d=this.get("dataContext"),f=d&&d.getSelectedCases(),e=f&&f.get("length"),g=DG.InsertCasesDialog.create({caseTableView:this,initialCaseCount:e});g.append()},destroySlickGrid:function(){if(this._slickGrid){this._slickGrid.destroy()}this._slickGrid=null;this.gridDataView=null},_destroy:function(){if(this.scrollAnimator){if(this.scrollAnimator.destroy){this.scrollAnimator.destroy()}this.scrollAnimator=null}this.destroySlickGrid();if(this.gridAdapter){this.gridAdapter.destroy()}this.gridAdapter=null},willDestroy:function(){this._destroy()},destroy:function(){this._destroy();arguments.callee.base.apply(this,arguments)},subscribe:function(g,e){var d,f=function(h){return function(){var i;if(!d){d=true;i=h.apply(this,arguments);d=false;return i}}.bind(this)}.bind(this);this._gridEventHandler.subscribe(this._slickGrid[g],f(e))},getRowBounds:function(g){var e=this._slickGrid&&this._slickGrid.getCellNodeBox(g,0),f=this._slickGrid&&this._slickGrid.getColumns(),h=f&&f.length;if(e&&h){var d=this._slickGrid.getCellNodeBox(g,h-1);e.right=d.right}return e},gridAdapterDidChange:function(){this.respondToDataContextAndGridAdapterChanges()}.observes("gridAdapter"),respondToDataContextAndGridAdapterChanges:function(){if(this._slickGrid){this.destroySlickGrid();this.displayDidChange();this.notifyPropertyChange("gridView")}},refresh:function(){this.setPath("gridAdapter.lastRefresh",null);var d=this.saveEditState();var e=this.get("gridAdapter");if(e){e.refresh()}if(this._slickGrid){this._slickGrid.invalidate();if(d){this.restoreEditStateWhenReady(d)}}this.caseCountDidChange();this.setPath("gridAdapter.lastRefresh",new Date())},render:function(e,f){arguments.callee.base.apply(this,arguments);if(this._slickGrid){var d=this.get("gridAdapter");if(this._rowDataDidChange){d.refresh()}this._slickGrid.render();this._rowDataDidChange=false;this._renderRequired=false}},didAppendToDocument:function(){var d=this.get("gridAdapter");if(!this._slickGrid&&SC.none(d)){console.log("DG.CaseTableView.didAppendToDocument: Can't initialize _slickGrid!");return}if(!this._slickGrid){this.initGridView();this.set("gridWidth",this._slickGrid.getContentSize().width)}this.invokeLater(function(){this.ancestorViewDidResizeOrScroll()}.bind(this))},touchPosInView:function(d){return this.convertFrameFromView({x:d.pageX,y:d.pageY},null,true)},touchPosInBodyContent:function(d){var e=this.touchPosInView(d),f=this.get("scrollPos");e.y-=b;if(f){e.x+=f.scrollLeft;e.y+=f.scrollTop}return e},cellFromTouch:function(e){var d={},f=this.touchPosInView(e);if(f.y<b){d=this._slickGrid.getCellFromPoint(f.x,0);d.row=-1}else{d=this.bodyCellFromTouch(e)}return d},bodyCellFromTouch:function(d){var e=this.touchPosInBodyContent(d);return this._slickGrid.getCellFromPoint(e.x,e.y)},_touchStartTouch:null,_touchStartCell:null,_touchDragCell:null,captureTouch:function(d){return YES},handleScroll:function(e,d){this.set("scrollPos",d)},handleBeforeAutoEditCell:function(e,d){var f=this._slickGrid.getDataItem(d.row);return(d.source==="navigate")||(f&&f._isProtoCase)},handleBeforeEditCell:function(h,g){var j=this._slickGrid.getDataItem(g.row),f=this._slickGrid.getDataLength(),e=this._slickGrid.getDataItem(f-1),i=e&&e._isProtoCase&&DG.ObjectMap.length(e._values),d=true;this.clearProtoCaseTimer();SC.run(function(){if(!j._isProtoCase&&i){this.commitProtoCase(e)}if(j._isProtoCase){this.get("gridAdapter").deselectAllCases()}else{if(!this.get("gridAdapter").isCellEditable(g.row,g.cell)){d=false}else{this.get("gridAdapter").deselectAllCases()}}}.bind(this));return d},handleHeaderDragStart:function(h,e){DG.TouchTooltips.hideAllTouchTooltips();this.cancelAttrTapHold();var f=e.column;var i=this.get("parentView");if(!f.attribute){return}if(h.stopImmediatePropagation){h.stopImmediatePropagation()}i.hideHeaderMenus();DG.mainPage.mainPane.hideInspectorPicker();var d=this._hiddenDragView,g=f.attribute.get("name");SC.run(function(){d.set("value",g);this.removeChild(d);this.appendChild(d)}.bind(this));SC.run(function(){DG.Drag.start({event:h,source:this,dragView:d,ghost:YES,ghostActsLikeCursor:YES,slideBack:YES,origin:{x:h.clientX,y:h.clientY},data:{context:f.context,collection:f.collection,attribute:f.attribute,text:g}})})},handleRowResizeDragInit:function(e,d){DG.TouchTooltips.hideAllTouchTooltips();e.stopImmediatePropagation()},handleRowResizeDragStart:function(e,d){this.$(".slick-viewport").addClass("slick-resizing-row");e.stopImmediatePropagation()},setRowHeight:function(d){SC.run(function(){this.setPath("gridAdapter.rowHeight",d);if(this.getPath("gridAdapter.isMultilineRowHeight")){this.$(".slick-viewport").addClass("slick-multiline-cells")}else{this.$(".slick-viewport").removeClass("slick-multiline-cells")}this._slickGrid.setOptions({rowHeight:d});this.setColumns(this._slickGrid.getColumns())}.bind(this))},handleRowResizeDrag:function(e,d){this.setRowHeight(d.rowHeight)},handleRowResizeDragEnd:function(e,d){this.$(".slick-viewport").removeClass("slick-resizing-row")},inProgressAttributeEditElementName:null,completeEditAttributeName:function(){var e=this.inProgressAttributeEditElementName;var d=this.$("#attribute-name-editor");if(e){SC.run(function(){var k=d,f=this.get("dataContext"),h=f.getUniqueAttributeName(k.val(),[e]);if(h!==e){var g=a(this),j=f&&f.getAttrRefByName(e);var i={};if(h){i.name=h}g.updateAttribute(j,i)}else{this.updateColumnInfo()}this.inProgressAttributeEditElementName=null}.bind(this))}},cancelEditAttributeElement:function(){SC.run(function(){this.updateColumnInfo();this.inProgressAttributeEditElementName=null}.bind(this))},commitCurrentEdit:function(){this.completeEditAttributeName();DG.globalEditorLock.deactivate(this)},resetActiveCell:function(){this._slickGrid.resetActiveCell()},cancelCurrentEdit:function(){this.cancelEditAttributeElement();DG.globalEditorLock.deactivate(this)},beginEditAttributeName:function(i){var f=this,k=this.get("gridAdapter"),d=k&&k.getAttributeColumn(i),g=d&&d.columnIndex,e=this.$(".slick-header-column"),l=d&&$(e[g]),h=l&&l.find(".slick-column-name");DG.globalEditorLock.commitCurrentEdit();DG.globalEditorLock.activate(this);this.inProgressAttributeEditElementName=i;if(h){h.empty().append($("<input>").addClass("dg-attr-name-edit-input").val(i));this.getPath("parentView.parentView.parentView").scrollDOMElementHorizontallyToView(h[0]);var j=h.find("input");j.attr({type:"text",autocapitalize:"none",autocomplete:"off",autocorrect:"off",inputmode:"latin-name",spellcheck:false,id:"attribute-name-editor"}).on("mousedown",function(m){m.stopImmediatePropagation()}).on("mouseup",function(m){m.stopImmediatePropagation()}).on("touchstart",function(m){m.stopImmediatePropagation()}).on("touchend",function(m){m.stopImmediatePropagation()}).on("dragstart",function(){return false}).on("click",function(m){m.preventDefault();m.stopImmediatePropagation()}).on("change",function(){f.completeEditAttributeName(this)}).on("blur",function(){f.completeEditAttributeName(this)}).on("keydown",function(m){switch(m.keyCode){case 13:f.completeEditAttributeName(this);break;case 27:f.cancelEditAttributeName(this);break}}).focus().select()}},handleHeaderClick:function(e,d){DG.globalEditorLock.commitCurrentEdit()},handleClick:function(e,d){SC.run(function(){function i(l){while(l&&!(l instanceof DG.HierTableView)){l=l.get("parentView")}return l}var k=i(this);k.selectComponent();k.contentView.hideHeaderMenus();var g=this.get("dataContext"),h=this._slickGrid.getDataItem(d.row),j=this.getPath("gridAdapter.collection"),f=h&&j&&(h.get("collection").get("id")!==j.get("id"));if(d.cell===0&&!k.getPath("model.isIndexHidden")){if(DG.DataContextUtilities.isCaseEditable(g,h)&&!f){this.showCaseIndexPopup(e,d)}}}.bind(this))},handleKeyDown:function(f){function i(q){var r=0;var p=null;while(r<q.length){if(q[r]&&q[r].focusable){p=r}r+=1}return p}function o(p){var q=0;while(q<p.length){if(p[q]&&p[q].focusable){return q}q+=1}return null}var h=this._slickGrid.getEditorLock(),l=h&&h.isActive(),j=this._slickGrid.getColumns(),k=this._slickGrid.getActiveCell(),d=k&&this._slickGrid.getDataItem(k.row),e=function(){this.clearProtoCaseTimer();if(!d._isProtoCase||(k.cell>o(j))){this._slickGrid.navigatePrev()}else{if(h.commitCurrentEdit()&&d._isProtoCase&&DG.ObjectMap.length(d._values)){SC.run(function(){this.commitProtoCase(d);this.invokeNext(function(){this._slickGrid.navigatePrev()}.bind(this))}.bind(this))}else{this._slickGrid.navigatePrev()}}f.stopImmediatePropagation()}.bind(this),g=function(){this.clearProtoCaseTimer();if(!d._isProtoCase||(k.cell<i(j))){this._slickGrid.navigateNext()}else{if(h.commitCurrentEdit()&&d._isProtoCase&&DG.ObjectMap.length(d._values)){SC.run(function(){this.commitProtoCase(d);this.invokeNext(function(){this._slickGrid.navigateNext()}.bind(this))}.bind(this))}else{this._slickGrid.editActiveCell()}}f.stopImmediatePropagation()}.bind(this),m=function(){if(!d._isProtoCase){this._slickGrid.navigateUp()}else{if(d._isProtoCase&&h.commitCurrentEdit()&&DG.ObjectMap.length(d._values)){SC.run(function(){this.clearProtoCaseTimer();this.commitProtoCase(d);this.invokeNext(function(){this._slickGrid.navigateUp()}.bind(this))}.bind(this))}else{this.clearProtoCaseTimer();this._slickGrid.navigateUp()}}f.stopImmediatePropagation()}.bind(this),n=function(){if(!d._isProtoCase){this._slickGrid.navigateDown()}else{if(h.commitCurrentEdit()&&d._isProtoCase&&DG.ObjectMap.length(d._values)){SC.run(function(){this.clearProtoCaseTimer();this.commitProtoCase(d);this.invokeNext(function(){this._slickGrid.navigateDown()}.bind(this))}.bind(this))}else{this._slickGrid.editActiveCell()}}f.stopImmediatePropagation()}.bind(this);if(l&&d){switch(f.keyCode){case 9:if(f.shiftKey){e()}else{g()}break;case 13:if(f.shiftKey){m()}else{n()}break;case 38:m();break;case 40:n();break}}},handleColumnsResized:function(i,f){var h=this.get("parentView");var e=h&&h.get("model");var d=this.get("columnWidths");var g={};if(e){Object.keys(d).forEach(function(j){g[j]=e.getPreferredAttributeWidth(j)});DG.UndoHistory.execute(DG.Command.create({name:"caseTable.columnResize",undoString:"DG.Undo.caseTable.resizeOneColumn",redoString:"DG.Redo.caseTable.resizeOneColumn",log:"Resize one case table column",executeNotification:{action:"notify",resource:"component",values:{operation:"resize column",type:"DG.CaseTable"}},execute:function(){DG.ObjectMap.forEach(d,function(j,k){e.setPreferredAttributeWidth(j,k)});this.updateColumnInfo()}.bind(this),undo:function(){DG.ObjectMap.forEach(g,function(j,k){e.setPreferredAttributeWidth(j,k)});this.updateColumnInfo()}.bind(this)}))}},handleColumnResizing:function(e,d){this.adjustHeaderForOverflow()},adjustHeaderForOverflow:function(){if(this.isComponentDetached()){return}function f(j){var h={"[":"]","]":"[","{":"}","}":"{","(":")",")":"("};if(!j){return j}var i=j.split("");var l;var g;var k=[];for(g=i.length-1;g>=0;g-=1){l=i[g];if(h[l]){l=h[l]}k.push(l)}return k.join("")}function e(g){var j=g.text().replace(/_/g," ");var i=$("<span>").addClass("two-line-header-line-1").text(j);var h=$("<span>").addClass("two-line-header-line-2").text(f(j));g.empty().append(i).append(h)}function d(h){var k=h.width();var g=h.height();var m=$(".two-line-header-line-1",h);var j=["font-style:"+m.css("font-style"),"font-variant:"+m.css("font-variant"),"font-weight:"+m.css("font-weight"),"font-stretch:"+m.css("font-stretch"),"line-height:"+m.css("line-height"),"font-size:"+m.css("font-size"),"font-family:"+m.css("font-family"),"width:"+k+"px","height:"+g+"px","overflow: auto","white-space: normal","-webkit-hyphens: auto","-ms-hyphens: auto","hyphens: auto","overflow-wrap: break-word"].join(";");var l=m.text();var i=DG.measureText(l,j);if(i.hasOverflowed){h.addClass("two-line-header-truncating")}else{h.removeClass("two-line-header-truncating")}}$(this.get("layer")).find(".slick-header-column").each(function(h,g){if($(g).find("input").length){return}var j=$(g).find(".slick-column-name");var i=j.find(".two-line-header-line-1");if(!i.length){e(j)}d(j)})},handleSelectedRowsChanged:function(d,l){var f=l.rows,k=f&&f.length,e=this._slickGrid.getEditorLock(),j=this._slickGrid.getDataLength(),m=this._slickGrid.getDataItem(j-1),h=m&&m._isProtoCase,g=this._slickGrid.getActiveCell(),i=h&&g&&(g.row===j-1);if(k){e.commitCurrentEdit();if(i&&DG.ObjectMap.length(m._values)){this.invokeLater(function(){SC.run(function(){this.commitProtoCase(m)}.bind(this))})}}},updateColumnInfo:function(){if(this._slickGrid){this.setColumns(this.get("gridAdapter").updateColumnInfo());this._slickGrid.invalidate()}},setColumns:function(d){if(this._slickGrid){this._slickGrid.setColumns(d);this._slickGrid.render();this.invokeNext(function(){this.adjustHeaderForOverflow()})}},saveEditState:function(){var f=this._slickGrid&&this._slickGrid.getCellEditor(),e=f&&f.saveEditState(),d=e&&this._slickGrid.getEditController();if(d){d.cancelCurrentEdit()}return e},restoreEditState:function(d){var l=d&&d.item,f=l&&l.id,g=d&&d.column,e=g&&g.attribute,m=this.get("gridAdapter"),i=m&&m.get("gridDataView"),h=i.getRowById(f),k=e&&m.getColumnIndexFromAttribute(e);if((h!=null)&&(h>=0)&&(k!=null)&&(k>=0)){this._slickGrid.setActiveCell(h,k);this._slickGrid.editActiveCell();var j=this._slickGrid.getCellEditor();j&&j.restoreEditState(d)}},restoreEditStateWhenReady:function(e){var d=function(){if(e){var f=this.getPath("gridAdapter.lastRefresh"),g=f?new Date()-f:0,h=50;if(g>=h){this.restoreEditState(e)}else{setTimeout(d,h-g)}}}.bind(this);if(e){d()}},expandCollapseAll:function(f){var i=this.getPath("gridAdapter.collection");var g=i.get("casesController");var h=this.getPath("gridAdapter.gridDataView");var e=this.parentView.get("model");DG.assert(i);DG.assert(g);var d=e.get("collapsedNodes");DG.UndoHistory.execute(DG.Command.create({name:"caseTable.groupToggleExpandCollapseAll",undoString:"DG.Undo.caseTable.groupToggleExpandCollapseAll",redoString:"DG.Redo.caseTable.groupToggleExpandCollapseAll",log:"Expand/Collapse all",executeNotification:{action:"notify",resource:"component",values:{operation:"expand/collapse all",type:"DG.CaseTable"}},execute:function(){this.beginDataViewUpdate(true);g.forEach(function(j){try{if(f){h.expandGroup(j.id)}else{this.collapseGroup(j.id)}}catch(k){DG.logError("expandCollapseAll: "+k)}}.bind(this));this.endDataViewUpdate(true);this.childTable._refreshDataView(true)}.bind(this),undo:function(){this.beginDataViewUpdate(true);g.forEach(function(j){h.expandGroup(j.id)});d.forEach(function(j){this.collapseGroup(j)}.bind(this));this.updateSelectedRows(true);this.incrementProperty("expandCollapseCount");this.endDataViewUpdate(true);this.childTable._refreshDataView(true)}.bind(this),redo:function(){this.execute()}}))},beginDataViewUpdate:function(e){var f=this.getPath("gridAdapter.gridDataView");var d=this.get("childTable");DG.assert(f);f.beginUpdate();if(e&&d){d.beginDataViewUpdate(e)}},endDataViewUpdate:function(e){var f=this.getPath("gridAdapter.gridDataView");var d=this.get("childTable");DG.assert(f);f.endUpdate();if(e&&d){d.endDataViewUpdate(e)}},updateRowData:function(){this._rowDataDidChange=true;this._renderRequired=true;this.displayDidChange()},updateRowCount:function(d){if(!this._slickGrid){return}this.updateRowData();this.updateSelectedRows(true)},scrollToView:function(e){var j=this.get("gridViewport");for(var g=0;g<e.length;++g){if((e[g]>=j.top)&&(e[g]<=j.bottom)){return}}var l=this.getMinScrollDelta(e);var h=j.bottom-j.top;var m=Math.max(h-4,0);var d=(h-m-1)/2;var f=(Math.abs(l)<=(m/2));var k=Math.max(j.top+d-l,0);if(!f&&j.top!==k){this.scrollAnimator.animate(this,j.top,k)}},animateScrollToTop:function(e){var d=this._slickGrid.getViewport();this.scrollAnimator.animate(this,d.top,e)},refreshScroll:function(){var d=this._slickGrid.getViewport().top;this.scrollToRow(0);this.scrollToRow(d)},scrollToRow:function(d){this._slickGrid.scrollRowToTop(d)},getMinScrollDelta:function(g){var d=this._slickGrid.getViewport();var f=(d.top+d.bottom)/2;var e=g.map(function(h){return f-h});return e.reduce(function(i,h){return(Math.abs(i)>Math.abs(h))?h:i},Number.MAX_VALUE)},setSelectedRows:function(d){if(this._slickGrid){this._slickGrid.setSelectedRows(d)}},isComponentDetached:function(){var d=a(this);return d&&!d.getPath("view.isVisible")},scrollSelectionToView:function(f){if(this.isComponentDetached()){return}var d=this._slickGrid.getSelectedRows();var e=this.getPath("gridAdapter.collection");if(f&&(f.getPath("collection.id")===e.get("id"))){this.scrollToCase(f.get("id"))}else{if(d.length>0){this.scrollToView(d)}else{this._slickGrid.render()}}},scrollToCase:function(f){if(SC.none(f)){return}var e=this.getPath("gridAdapter.gridDataView");var d=e.getRowById(f);if(d<0){return}this.scrollToView([d])},updateSelectedRows:function(f){var d=this.get("gridAdapter"),e=d&&d.getSelectedRows(),g=this.get("childTable");if(e){this.setSelectedRows(e)}if(f&&g){g.updateSelectedRows(f)}},_scrollEventCount:0,scrollToAlignWithLeft:function(){function d(s){if(!s){DG.log("No case: scrollToAlignWithLeft: %@",e.get("collectionName"));return}if(s._isProtoCase){return n.getLength()-1}var r=s.get("children");var u=r&&r[0];var v=r&&r[r.length-1];var t;if(g.isCollapsedNode(s)){t={first:n.getRowById(s)};t.last=t.first}else{if(u&&v){t={first:n.getRowById(u.id),last:n.getRowById(v.id)}}}return t}var g=this.getPath("parentView.model");var l=this.get("gridViewport");var h=l.bottom-l.top-1;var n=this.getPath("gridAdapter.gridDataView");var e=this.get("parentTable");var k=e.get("gridViewport");var o=e.getPath("gridAdapter.gridDataView");var j=false;if(n.getLength()===0||o.getLength()===0){return false}function m(s,r){return Math.max(0,Math.min(s.getLength()-1,r.bottom))}var i=o.getItem(k.top);var q=d(i);var f=o.getItem(m(o,k));var p=d(f);if(q&&(q.first>l.top)){this._slickGrid.scrollRowToTop(q.first);j=true}else{if(p&&(p.last<m(n,l))){this._slickGrid.scrollRowToTop(p.last-h);j=true}}return j},scrollToAlignWithRight:function(){function i(q){if(!q){DG.log("No case: scrollToAlignWithRight: %@",j.get("collectionName"));return}if(q._isProtoCase){return p.getLength()-1}var r=q;if(!g.isCollapsedNode(q)){r=q.get("parent")}return p.getRowById(r.id)}var g=this.getPath("parentView.model");var n=this.get("gridViewport");var h=n.bottom-n.top-1;var p=this.getPath("gridAdapter.gridDataView");var j=this.get("childTable");var m=j&&j.get("gridViewport");var d=j&&j.getPath("gridAdapter.gridDataView");var l=false;if(!p||(p.getLength()===0)||!d||(d.getLength()===0)){return false}var e=d.getItem(m.top);var o=i(e);var f=d.getItem(Math.min(d.getLength()-1,m.bottom));var k=i(f);if(o<n.top){this._slickGrid.scrollRowToTop(o);l=true}else{if(k>=Math.min(p.getLength()-1,n.bottom)){this._slickGrid.scrollRowToTop(k-h);l=true}}return l},click:function(d){function e(m){return !!($(m.target).closest(".slick-header-column",".slick-header-columns").length)}if(this.getPath("gridAdapter.isModelDragging")){return NO}var i=this._slickGrid.getCellFromEvent(d);if(e(d)){return NO}var l=DG.ComponentView.findComponentViewParent(this);var g=l&&l.get("isSelected");var f=this.get("dataContext");var k=f.getSelectedCases();var j={operation:"selectCases",cases:[],select:true,extend:false};if(i){var h=this._slickGrid.getDataItem(i.row);if(h&&h._isProtoCase){f.applyChange({operation:"selectCases",select:false});return YES}if(k&&h&&(g||!(k.indexOf(h)>=0))){j.cases=[h];f.applyChange(j);return YES}}else{if(g){f.applyChange(j)}}return NO},mouseDown:function(){DG.TouchTooltips.hideAllTouchTooltips();return YES},cancelAttrTapHold:function(d){if(this._attrTapHoldTimer){clearTimeout(this._attrTapHoldTimer);this._attrTapHoldTimer=null}},touchStart:function(d){DG.TouchTooltips.hideAllTouchTooltips();var e=document.elementFromPoint(d.clientX,d.clientY);while(e&&!e.classList.contains("slick-header-column")){e=e.parentElement}if(e){this._attrTapHoldTimer=setTimeout(function(){DG.TouchTooltips.showTouchTooltip(d,e,e.title);this._attrTapHold=null}.bind(this),500)}return YES},touchEnd:function(d){this.cancelAttrTapHold();d.allowDefault();return YES},widenColumnsProportionally:function(f){var d=this.getPath("parentView.model");var e=this._slickGrid.getColumns();e.forEach(function(g){if(g.attribute){g.width=g.width*f;if(d){d.setPreferredAttributeWidth(g.id,g.width)}}});this.setColumns(e)},resizeLastColumn:function(h){var e=this.getPath("parentView.model");var f=this._slickGrid.getColumns();var d=f[f.length-1];var g=d.id;d.width=Math.max(d.width+h,d.minWidth);if(e){e.setPreferredAttributeWidth(g,d.width)}this.setColumns(f)}}}()));(function(i){var e="0.4.2",j="hasOwnProperty",b=/[\.\/]/,a="*",g=function(){},f=function(m,l){return m-l},d,h,k={n:{}},c=function(m,C){m=String(m);var v=k,s=h,w=Array.prototype.slice.call(arguments,2),y=c.listeners(m),x=0,u=false,p,o=[],t={},q=[],n=d,A=[];d=m;h=0;for(var r=0,B=y.length;r<B;r++){if("zIndex" in y[r]){o.push(y[r].zIndex);if(y[r].zIndex<0){t[y[r].zIndex]=y[r]}}}o.sort(f);while(o[x]<0){p=t[o[x++]];q.push(p.apply(C,w));if(h){h=s;return q}}for(r=0;r<B;r++){p=y[r];if("zIndex" in p){if(p.zIndex==o[x]){q.push(p.apply(C,w));if(h){break}do{x++;p=t[o[x]];p&&q.push(p.apply(C,w));if(h){break}}while(p)}else{t[p.zIndex]=p}}else{q.push(p.apply(C,w));if(h){break}}}h=s;d=n;return q.length?q:null};c._events=k;c.listeners=function(l){var t=l.split(b),r=k,x,s,m,p,w,o,q,u,v=[r],n=[];for(p=0,w=t.length;p<w;p++){u=[];for(o=0,q=v.length;o<q;o++){r=v[o].n;s=[r[t[p]],r[a]];m=2;while(m--){x=s[m];if(x){u.push(x);n=n.concat(x.f||[])}}}v=u}return n};c.on=function(l,o){l=String(l);if(typeof o!="function"){return function(){}}var q=l.split(b),p=k;for(var m=0,n=q.length;m<n;m++){p=p.n;p=p.hasOwnProperty(q[m])&&p[q[m]]||(p[q[m]]={n:{}})}p.f=p.f||[];for(m=0,n=p.f.length;m<n;m++){if(p.f[m]==o){return g}}p.f.push(o);return function(r){if(+r==+r){o.zIndex=+r}}};c.f=function(m){var l=[].slice.call(arguments,1);return function(){c.apply(null,[m,null].concat(l).concat([].slice.call(arguments,0)))}};c.stop=function(){h=1};c.nt=function(l){if(l){return new RegExp("(?:\\.|\\/|^)"+l+"(?:\\.|\\/|$)").test(d)}return d};c.nts=function(){return d.split(b)};c.off=c.unbind=function(m,r){if(!m){c._events=k={n:{}};return}var t=m.split(b),s,v,n,p,w,o,q,u=[k];for(p=0,w=t.length;p<w;p++){for(o=0;o<u.length;o+=n.length-2){n=[o,1];s=u[o].n;if(t[p]!=a){if(s[t[p]]){n.push(s[t[p]])}}else{for(v in s){if(s[j](v)){n.push(s[v])}}}u.splice.apply(u,n)}}for(p=0,w=u.length;p<w;p++){s=u[p];while(s.n){if(r){if(s.f){for(o=0,q=s.f.length;o<q;o++){if(s.f[o]==r){s.f.splice(o,1);break}}!s.f.length&&delete s.f}for(v in s.n){if(s.n[j](v)&&s.n[v].f){var l=s.n[v].f;for(o=0,q=l.length;o<q;o++){if(l[o]==r){l.splice(o,1);break}}!l.length&&delete s.n[v].f}}}else{delete s.f;for(v in s.n){if(s.n[j](v)&&s.n[v].f){delete s.n[v].f}}}s=s.n}}};c.once=function(l,m){var n=function(){c.unbind(l,n);return m.apply(this,arguments)};return c.on(l,n)};c.version=e;c.toString=function(){return"You are running Eve "+e};(typeof module!="undefined"&&module.exports)?(module.exports=c):(typeof define!="undefined"?(define("eve",[],function(){return c})):(i.eve=c))})(this);(function(b,a){if(typeof define==="function"&&define.amd){define(["eve"],function(c){return a(b,c)})}else{a(b,b.eve||(typeof require=="function"&&require("eve")))}}(this,function(aT,bc){function bi(g){if(bi.is(g,"function")){return K?g():bc.on("raphael.DOMload",g)}else{if(bi.is(g,u)){return bi._engine.create[bs](bi,g.splice(0,3+bi.is(g[0],bj))).add(g)}else{var b=Array.prototype.slice.call(arguments,0);if(bi.is(b[b.length-1],"function")){var d=b.pop();return K?d.call(bi._engine.create[bs](bi,b)):bc.on("raphael.DOMload",function(){d.call(bi._engine.create[bs](bi,b))})}else{return bi._engine.create[bs](bi,arguments)}}}}bi.version="2.1.2";bi.eve=bc;var K,bv=/[, ]+/,au={circle:1,rect:1,path:1,ellipse:1,text:1,image:1},X=/\{(\d+)\}/g,bz="prototype",bw="hasOwnProperty",a5={doc:document,win:aT},aE={was:Object.prototype[bw].call(a5.win,"Raphael"),is:a5.win.Raphael},bJ=function(){this.ca=this.customAttributes={}},ao,bA="appendChild",bs="apply",av="concat",P=("ontouchstart" in a5.win)||a5.win.DocumentTouch&&a5.doc instanceof DocumentTouch,bn="",bh=" ",k=String,l="split",bB="click dblclick mousedown mousemove mouseout mouseover mouseup touchstart touchmove touchend touchcancel"[l](bh),bp={mousedown:"touchstart",mousemove:"touchmove",mouseup:"touchend"},ak=k.prototype.toLowerCase,aI=Math,bI=aI.max,aj=aI.min,al=aI.abs,aS=aI.pow,ah=aI.PI,bj="number",a="string",u="array",s="toString",A="fill",aM=Object.prototype.toString,bC={},r="push",ab=bi._ISURL=/^url\(['"]?(.+?)['"]?\)$/i,aa=/^\s*((#[a-f\d]{6})|(#[a-f\d]{3})|rgba?\(\s*([\d\.]+%?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+%?(?:\s*,\s*[\d\.]+%?)?)\s*\)|hsba?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\)|hsla?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\))\s*$/i,B={"NaN":1,"Infinity":1,"-Infinity":1},an=/^(?:cubic-)?bezier\(([^,]+),([^,]+),([^,]+),([^\)]+)\)/,C=aI.round,Q="setAttribute",bM=parseFloat,bK=parseInt,aU=k.prototype.toUpperCase,bq=bi._availableAttrs={"arrow-end":"none","arrow-start":"none",blur:0,"clip-rect":"0 0 1e9 1e9",cursor:"default",cx:0,cy:0,fill:"#fff","fill-opacity":1,font:'10px "Arial"',"font-family":'"Arial"',"font-size":"10","font-style":"normal","font-weight":400,gradient:0,height:0,href:"http://raphaeljs.com/","letter-spacing":0,opacity:1,path:"M0,0",r:0,rx:0,ry:0,src:"",stroke:"#000","stroke-dasharray":"","stroke-linecap":"butt","stroke-linejoin":"butt","stroke-miterlimit":0,"stroke-opacity":1,"stroke-width":1,target:"_blank","text-anchor":"middle",title:"Raphael",transform:"",width:0,x:0,y:0},bo=bi._availableAnimAttrs={blur:bj,"clip-rect":"csv",cx:bj,cy:bj,fill:"colour","fill-opacity":bj,"font-size":bj,height:bj,opacity:bj,path:"path",r:bj,rx:bj,ry:bj,stroke:"colour","stroke-opacity":bj,"stroke-width":bj,transform:"transform",width:bj,x:bj,y:bj},bt=/[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]/g,bf=/[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*,[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*/,ax={hs:1,rg:1},aN=/,?([achlmqrstvxz]),?/gi,bg=/([achlmrqstvz])[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029,]*((-?\d*\.?\d*(?:e[\-+]?\d+)?[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*,?[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*)+)/ig,ad=/([rstm])[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029,]*((-?\d*\.?\d*(?:e[\-+]?\d+)?[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*,?[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*)+)/ig,ap=/(-?\d*\.?\d*(?:e[\-+]?\d+)?)[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*,?[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*/ig,a2=bi._radial_gradient=/^r(?:\(([^,]+?)[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*,[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*([^\)]+?)\))?/,N={},x=function(g,d){return g.key-d.key},bu=function(g,d){return bM(g)-bM(d)},ae=function(){},aw=function(b){return b},q=bi._rectPath=function(b,E,d,g,i){if(i){return[["M",b+i,E],["l",d-i*2,0],["a",i,i,0,0,1,i,i],["l",0,g-i*2],["a",i,i,0,0,1,-i,i],["l",i*2-d,0],["a",i,i,0,0,1,-i,-i],["l",0,i*2-g],["a",i,i,0,0,1,i,-i],["z"]]}return[["M",b,E],["l",d,0],["l",0,g],["l",-d,0],["z"]]},V=function(b,i,g,d){if(d==null){d=g}return[["M",b,i],["m",0,-d],["a",g,d,0,1,1,0,2*d],["a",g,d,0,1,1,0,-2*d],["z"]]},ag=bi._getPath={path:function(b){return b.attr("path")},circle:function(d){var b=d.attrs;return V(b.cx,b.cy,b.r)},ellipse:function(d){var b=d.attrs;return V(b.cx,b.cy,b.rx,b.ry)},rect:function(d){var b=d.attrs;return q(b.x,b.y,b.width,b.height,b.r)},image:function(d){var b=d.attrs;return q(b.x,b.y,b.width,b.height)},text:function(b){var d=b._getBBox();return q(d.x,d.y,d.width,d.height)},set:function(b){var d=b._getBBox();return q(d.x,d.y,d.width,d.height)}},T=bi.mapPath=function(bQ,S){if(!S){return bQ}var bO,R,g,b,bP,E,d;bQ=bk(bQ);for(g=0,bP=bQ.length;g<bP;g++){d=bQ[g];for(b=1,E=d.length;b<E;b+=2){bO=S.x(d[b],d[b+1]);R=S.y(d[b],d[b+1]);d[b]=bO;d[b+1]=R}}return bQ};bi._g=a5;bi.type=(a5.win.SVGAngle||a5.doc.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure","1.1")?"SVG":"VML");if(bi.type=="VML"){var a7=a5.doc.createElement("div"),a8;a7.innerHTML='<v:shape adj="1"/>';a8=a7.firstChild;a8.style.behavior="url(#default#VML)";if(!(a8&&typeof a8.adj=="object")){return(bi.type=bn)}a7=null}bi.svg=!(bi.vml=bi.type=="VML");bi._Paper=bJ;bi.fn=ao=bJ.prototype=bi.prototype;bi._id=0;bi._oid=0;bi.is=function(d,b){b=ak.call(b);if(b=="finite"){return !B[bw](+d)}if(b=="array"){return d instanceof Array}return(b=="null"&&d===null)||(b==typeof d&&d!==null)||(b=="object"&&d===Object(d))||(b=="array"&&Array.isArray&&Array.isArray(d))||aM.call(d).slice(8,-1).toLowerCase()==b};function bl(g){if(typeof g=="function"||Object(g)!==g){return g}var d=new g.constructor;for(var b in g){if(g[bw](b)){d[b]=bl(g[b])}}return d}bi.angle=function(E,S,g,R,d,i){if(d==null){var b=E-g,bO=S-R;if(!b&&!bO){return 0}return(180+aI.atan2(-bO,-b)*180/ah+360)%360}else{return bi.angle(E,S,d,i)-bi.angle(g,R,d,i)}};bi.rad=function(b){return b%360*ah/180};bi.deg=function(b){return Math.round((b*180/ah%360)*1000)/1000};bi.snapTo=function(d,E,b){b=bi.is(b,"finite")?b:10;if(bi.is(d,u)){var g=d.length;while(g--){if(al(d[g]-E)<=b){return d[g]}}}else{d=+d;var R=E%d;if(R<b){return E-R}if(R>d-b){return E-R+d}}return E};var aQ=bi.createUUID=(function(b,d){return function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(b,d).toUpperCase()}})(/[xy]/g,function(g){var d=aI.random()*16|0,b=g=="x"?d:(d&3|8);return b.toString(16)});bi.setWindow=function(b){bc("raphael.setWindow",bi,a5.win,b);a5.win=b;a5.doc=a5.win.document;if(bi._engine.initWin){bi._engine.initWin(a5.win)}};var J=function(g){if(bi.vml){var b=/^\s+|\s+$/g;var R;try{var S=new ActiveXObject("htmlfile");S.write("<body>");S.close();R=S.body}catch(bO){R=createPopup().document.body}var d=R.createTextRange();J=H(function(i){try{R.style.color=k(i).replace(b,bn);var bP=d.queryCommandValue("ForeColor");bP=((bP&255)<<16)|(bP&65280)|((bP&16711680)>>>16);return"#"+("000000"+bP.toString(16)).slice(-6)}catch(bQ){return"none"}})}else{var E=a5.doc.createElement("i");E.title="Rapha\xebl Colour Picker";E.style.display="none";a5.doc.body.appendChild(E);J=H(function(i){E.style.color=i;return a5.doc.defaultView.getComputedStyle(E,bn).getPropertyValue("color")})}return J(g)},az=function(){return"hsb("+[this.h,this.s,this.b]+")"},bm=function(){return"hsl("+[this.h,this.s,this.l]+")"},w=function(){return this.hex},G=function(R,E,d){if(E==null&&bi.is(R,"object")&&"r" in R&&"g" in R&&"b" in R){d=R.b;E=R.g;R=R.r}if(E==null&&bi.is(R,a)){var i=bi.getRGB(R);R=i.r;E=i.g;d=i.b}if(R>1||E>1||d>1){R/=255;E/=255;d/=255}return[R,E,d]},O=function(R,E,d,S){R*=255;E*=255;d*=255;var i={r:R,g:E,b:d,hex:bi.rgb(R,E,d),toString:w};bi.is(S,"finite")&&(i.opacity=S);return i};bi.color=function(b){var d;if(bi.is(b,"object")&&"h" in b&&"s" in b&&"b" in b){d=bi.hsb2rgb(b);b.r=d.r;b.g=d.g;b.b=d.b;b.hex=d.hex}else{if(bi.is(b,"object")&&"h" in b&&"s" in b&&"l" in b){d=bi.hsl2rgb(b);b.r=d.r;b.g=d.g;b.b=d.b;b.hex=d.hex}else{if(bi.is(b,"string")){b=bi.getRGB(b)}if(bi.is(b,"object")&&"r" in b&&"g" in b&&"b" in b){d=bi.rgb2hsl(b);b.h=d.h;b.s=d.s;b.l=d.l;d=bi.rgb2hsb(b);b.v=d.b}else{b={hex:"none"};b.r=b.g=b.b=b.h=b.s=b.v=b.l=-1}}}b.toString=w;return b};bi.hsb2rgb=function(S,bQ,bO,i){if(this.is(S,"object")&&"h" in S&&"s" in S&&"b" in S){bO=S.b;bQ=S.s;i=S.o;S=S.h}S*=360;var E,bP,d,g,b;S=(S%360)/60;b=bO*bQ;g=b*(1-al(S%2-1));E=bP=d=bO-b;S=~~S;E+=[b,g,0,0,g,b][S];bP+=[g,b,b,g,0,0][S];d+=[0,0,g,b,b,g][S];return O(E,bP,d,i)};bi.hsl2rgb=function(bO,bQ,E,i){if(this.is(bO,"object")&&"h" in bO&&"s" in bO&&"l" in bO){E=bO.l;bQ=bO.s;bO=bO.h}if(bO>1||bQ>1||E>1){bO/=360;bQ/=100;E/=100}bO*=360;var S,bP,d,g,b;bO=(bO%360)/60;b=2*bQ*(E<0.5?E:1-E);g=b*(1-al(bO%2-1));S=bP=d=E-b/2;bO=~~bO;S+=[b,g,0,0,g,b][bO];bP+=[g,b,b,g,0,0][bO];d+=[0,0,g,b,b,g][bO];return O(S,bP,d,i)};bi.rgb2hsb=function(bP,bO,d){d=G(bP,bO,d);bP=d[0];bO=d[1];d=d[2];var R,E,i,bQ;i=bI(bP,bO,d);bQ=i-aj(bP,bO,d);R=(bQ==0?null:i==bP?(bO-d)/bQ:i==bO?(d-bP)/bQ+2:(bP-bO)/bQ+4);R=((R+360)%6)*60/360;E=bQ==0?0:bQ/i;return{h:R,s:E,b:i,toString:az}};bi.rgb2hsl=function(d,bO,bR){bR=G(d,bO,bR);d=bR[0];bO=bR[1];bR=bR[2];var bS,R,bQ,bP,E,i;bP=bI(d,bO,bR);E=aj(d,bO,bR);i=bP-E;bS=(i==0?null:bP==d?(bO-bR)/i:bP==bO?(bR-d)/i+2:(d-bO)/i+4);bS=((bS+360)%6)*60/360;bQ=(bP+E)/2;R=(i==0?0:bQ<0.5?i/(2*bQ):i/(2-2*bQ));return{h:bS,s:R,l:bQ,toString:bm}};bi._path2string=function(){return this.join(",").replace(aN,"$1")};function c(E,g){for(var b=0,d=E.length;b<d;b++){if(E[b]===g){return E.push(E.splice(b,1)[0])}}}function H(i,d,b){function g(){var E=Array.prototype.slice.call(arguments,0),S=E.join("\u2400"),R=g.cache=g.cache||{},bO=g.count=g.count||[];if(R[bw](S)){c(bO,S);return b?b(R[S]):R[S]}bO.length>=1000&&delete R[bO.shift()];bO.push(S);R[S]=i[bs](d,E);return b?b(R[S]):R[S]}return g}var D=bi._preload=function(g,d){var b=a5.doc.createElement("img");b.style.cssText="position:absolute;left:-9999em;top:-9999em";b.onload=function(){d.call(this);this.onload=null;a5.doc.body.removeChild(this)};b.onerror=function(){a5.doc.body.removeChild(this)};a5.doc.body.appendChild(b);b.src=g};function h(){return this.hex}bi.getRGB=H(function(b){if(!b||!!((b=k(b)).indexOf("-")+1)){return{r:-1,g:-1,b:-1,hex:"none",error:1,toString:h}}if(b=="none"){return{r:-1,g:-1,b:-1,hex:"none",toString:h}}!(ax[bw](b.toLowerCase().substring(0,2))||b.charAt()=="#")&&(b=J(b));var E,d,g,S,i,bP,bO,R=b.match(aa);if(R){if(R[2]){S=bK(R[2].substring(5),16);g=bK(R[2].substring(3,5),16);d=bK(R[2].substring(1,3),16)}if(R[3]){S=bK((bP=R[3].charAt(3))+bP,16);g=bK((bP=R[3].charAt(2))+bP,16);d=bK((bP=R[3].charAt(1))+bP,16)}if(R[4]){bO=R[4][l](bf);d=bM(bO[0]);bO[0].slice(-1)=="%"&&(d*=2.55);g=bM(bO[1]);bO[1].slice(-1)=="%"&&(g*=2.55);S=bM(bO[2]);bO[2].slice(-1)=="%"&&(S*=2.55);R[1].toLowerCase().slice(0,4)=="rgba"&&(i=bM(bO[3]));bO[3]&&bO[3].slice(-1)=="%"&&(i/=100)}if(R[5]){bO=R[5][l](bf);d=bM(bO[0]);bO[0].slice(-1)=="%"&&(d*=2.55);g=bM(bO[1]);bO[1].slice(-1)=="%"&&(g*=2.55);S=bM(bO[2]);bO[2].slice(-1)=="%"&&(S*=2.55);(bO[0].slice(-3)=="deg"||bO[0].slice(-1)=="\xb0")&&(d/=360);R[1].toLowerCase().slice(0,4)=="hsba"&&(i=bM(bO[3]));bO[3]&&bO[3].slice(-1)=="%"&&(i/=100);return bi.hsb2rgb(d,g,S,i)}if(R[6]){bO=R[6][l](bf);d=bM(bO[0]);bO[0].slice(-1)=="%"&&(d*=2.55);g=bM(bO[1]);bO[1].slice(-1)=="%"&&(g*=2.55);S=bM(bO[2]);bO[2].slice(-1)=="%"&&(S*=2.55);(bO[0].slice(-3)=="deg"||bO[0].slice(-1)=="\xb0")&&(d/=360);R[1].toLowerCase().slice(0,4)=="hsla"&&(i=bM(bO[3]));bO[3]&&bO[3].slice(-1)=="%"&&(i/=100);return bi.hsl2rgb(d,g,S,i)}R={r:d,g:g,b:S,toString:h};R.hex="#"+(16777216|S|(g<<8)|(d<<16)).toString(16).slice(1);bi.is(i,"finite")&&(R.opacity=i);return R}return{r:-1,g:-1,b:-1,hex:"none",error:1,toString:h}},bi);bi.hsb=H(function(i,g,d){return bi.hsb2rgb(i,g,d).hex});bi.hsl=H(function(g,d,b){return bi.hsl2rgb(g,d,b).hex});bi.rgb=H(function(E,i,d){return"#"+(16777216|d|(i<<8)|(E<<16)).toString(16).slice(1)});bi.getColor=function(d){var g=this.getColor.start=this.getColor.start||{h:0,s:1,b:d||0.75},b=this.hsb2rgb(g.h,g.s,g.b);g.h+=0.075;if(g.h>1){g.h=0;g.s-=0.2;g.s<=0&&(this.getColor.start={h:0,s:1,b:g.b})}return b.hex};bi.getColor.reset=function(){delete this.start};function am(E,bO){var S=[];for(var g=0,b=E.length;b-2*!bO>g;g+=2){var R=[{x:+E[g-2],y:+E[g-1]},{x:+E[g],y:+E[g+1]},{x:+E[g+2],y:+E[g+3]},{x:+E[g+4],y:+E[g+5]}];if(bO){if(!g){R[0]={x:+E[b-2],y:+E[b-1]}}else{if(b-4==g){R[3]={x:+E[0],y:+E[1]}}else{if(b-2==g){R[2]={x:+E[0],y:+E[1]};R[3]={x:+E[2],y:+E[3]}}}}}else{if(b-4==g){R[3]=R[2]}else{if(!g){R[0]={x:+E[g],y:+E[g+1]}}}}S.push(["C",(-R[0].x+6*R[1].x+R[2].x)/6,(-R[0].y+6*R[1].y+R[2].y)/6,(R[1].x+6*R[2].x-R[3].x)/6,(R[1].y+6*R[2].y-R[3].y)/6,R[2].x,R[2].y])}return S}bi.parsePathString=function(b){if(!b){return null}var g=aR(b);if(g.arr){return aY(g.arr)}var i={a:7,c:6,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,z:0},d=[];if(bi.is(b,u)&&bi.is(b[0],u)){d=aY(b)}if(!d.length){k(b).replace(bg,function(R,E,bP){var bO=[],S=E.toLowerCase();bP.replace(ap,function(bR,bQ){bQ&&bO.push(+bQ)});if(S=="m"&&bO.length>2){d.push([E][av](bO.splice(0,2)));S="l";E=E=="m"?"l":"L"}if(S=="r"){d.push([E][av](bO))}else{while(bO.length>=i[S]){d.push([E][av](bO.splice(0,i[S])));if(!i[S]){break}}}})}d.toString=bi._path2string;g.arr=aY(d);return d};bi.parseTransformString=H(function(d){if(!d){return null}var g={r:3,s:4,t:2,m:6},b=[];if(bi.is(d,u)&&bi.is(d[0],u)){b=aY(d)}if(!b.length){k(d).replace(ad,function(E,i,bO){var S=[],R=ak.call(i);bO.replace(ap,function(bQ,bP){bP&&S.push(+bP)});b.push([i][av](S))})}b.toString=bi._path2string;return b});var aR=function(d){var b=aR.ps=aR.ps||{};if(b[d]){b[d].sleep=100}else{b[d]={sleep:100}}setTimeout(function(){for(var g in b){if(b[bw](g)&&g!=d){b[g].sleep--;!b[g].sleep&&delete b[g]}}});return b[d]};bi.findDotsAtSegment=function(d,b,b5,b3,S,E,bQ,bO,bY){var bV=1-bY,b0=aS(bV,3),b1=aS(bV,2),bS=bY*bY,bP=bS*bY,bU=b0*d+b1*3*bY*b5+bV*3*bY*bY*S+bP*bQ,bR=b0*b+b1*3*bY*b3+bV*3*bY*bY*E+bP*bO,bZ=d+2*bY*(b5-d)+bS*(S-2*b5+d),bX=b+2*bY*(b3-b)+bS*(E-2*b3+b),b4=b5+2*bY*(S-b5)+bS*(bQ-2*S+b5),b2=b3+2*bY*(E-b3)+bS*(bO-2*E+b3),bW=bV*d+bY*b5,bT=bV*b+bY*b3,i=bV*S+bY*bQ,g=bV*E+bY*bO,R=(90-aI.atan2(bZ-b4,bX-b2)*180/ah);(bZ>b4||bX<b2)&&(R+=180);return{x:bU,y:bR,m:{x:bZ,y:bX},n:{x:b4,y:b2},start:{x:bW,y:bT},end:{x:i,y:g},alpha:R}};bi.bezierBBox=function(d,b,i,g,bP,S,R,E){if(!bi.is(d,"array")){d=[d,b,i,g,bP,S,R,E]}var bO=aX.apply(null,d);return{x:bO.min.x,y:bO.min.y,x2:bO.max.x,y2:bO.max.y,width:bO.max.x-bO.min.x,height:bO.max.y-bO.min.y}};bi.isPointInsideBBox=function(d,b,g){return b>=d.x&&b<=d.x2&&g>=d.y&&g<=d.y2};bi.isBBoxIntersect=function(g,d){var b=bi.isPointInsideBBox;return b(d,g.x,g.y)||b(d,g.x2,g.y)||b(d,g.x,g.y2)||b(d,g.x2,g.y2)||b(g,d.x,d.y)||b(g,d.x2,d.y)||b(g,d.x,d.y2)||b(g,d.x2,d.y2)||(g.x<d.x2&&g.x>d.x||d.x<g.x2&&d.x>g.x)&&(g.y<d.y2&&g.y>d.y||d.y<g.y2&&d.y>g.y)};function aC(b,S,R,E,i){var g=-3*S+9*R-9*E+3*i,d=b*g+6*S-12*R+6*E;return b*d-3*S+3*R}function bb(bZ,R,bY,g,bX,d,bU,b,bR){if(bR==null){bR=1}bR=bR>1?1:bR<0?0:bR;var bS=bR/2,bT=12,bO=[-0.1252,0.1252,-0.3678,0.3678,-0.5873,0.5873,-0.7699,0.7699,-0.9041,0.9041,-0.9816,0.9816],bW=[0.2491,0.2491,0.2335,0.2335,0.2032,0.2032,0.1601,0.1601,0.1069,0.1069,0.0472,0.0472],E=0;for(var bV=0;bV<bT;bV++){var bP=bS*bO[bV]+bS,bQ=aC(bP,bZ,bY,bX,bU),b0=aC(bP,R,g,d,b),S=bQ*bQ+b0*b0;E+=bW[bV]*aI.sqrt(S)}return bS*E}function aK(g,bS,d,bR,b,bP,bU,bO,bQ){if(bQ<0||bb(g,bS,d,bR,b,bP,bU,bO)<bQ){return}var bT=1,i=bT/2,R=bT-i,E,S=0.01;E=bb(g,bS,d,bR,b,bP,bU,bO,R);while(al(E-bQ)>S){i/=2;R+=(E<bQ?1:-1)*i;E=bb(g,bS,d,bR,b,bP,bU,bO,R)}return R}function a4(i,bT,g,bR,b,bQ,bV,bP){if(bI(i,g)<aj(b,bV)||aj(i,g)>bI(b,bV)||bI(bT,bR)<aj(bQ,bP)||aj(bT,bR)>bI(bQ,bP)){return}var bO=(i*bR-bT*g)*(b-bV)-(i-g)*(b*bP-bQ*bV),S=(i*bR-bT*g)*(bQ-bP)-(bT-bR)*(b*bP-bQ*bV),E=(i-g)*(bQ-bP)-(bT-bR)*(b-bV);if(!E){return}var bU=bO/E,bS=S/E,R=+bU.toFixed(2),d=+bS.toFixed(2);if(R<+aj(i,g).toFixed(2)||R>+bI(i,g).toFixed(2)||R<+aj(b,bV).toFixed(2)||R>+bI(b,bV).toFixed(2)||d<+aj(bT,bR).toFixed(2)||d>+bI(bT,bR).toFixed(2)||d<+aj(bQ,bP).toFixed(2)||d>+bI(bQ,bP).toFixed(2)){return}return{x:bU,y:bS}}function aV(d,b){return aP(d,b)}function aL(d,b){return aP(d,b,1)}function aP(b5,b4,b3){var E=bi.bezierBBox(b5),d=bi.bezierBBox(b4);if(!bi.isBBoxIntersect(E,d)){return b3?0:[]}var bY=bb.apply(0,b5),bX=bb.apply(0,b4),bP=bI(~~(bY/5),1),bO=bI(~~(bX/5),1),bV=[],bU=[],g={},b6=b3?0:[];for(var b0=0;b0<bP+1;b0++){var bW=bi.findDotsAtSegment.apply(bi,b5.concat(b0/bP));bV.push({x:bW.x,y:bW.y,t:b0/bP})}for(b0=0;b0<bO+1;b0++){bW=bi.findDotsAtSegment.apply(bi,b4.concat(b0/bO));bU.push({x:bW.x,y:bW.y,t:b0/bO})}for(b0=0;b0<bP;b0++){for(var bZ=0;bZ<bO;bZ++){var b2=bV[b0],b=bV[b0+1],b1=bU[bZ],S=bU[bZ+1],bT=al(b.x-b2.x)<0.001?"y":"x",bS=al(S.x-b1.x)<0.001?"y":"x",R=a4(b2.x,b2.y,b.x,b.y,b1.x,b1.y,S.x,S.y);if(R){if(g[R.x.toFixed(4)]==R.y.toFixed(4)){continue}g[R.x.toFixed(4)]=R.y.toFixed(4);var bR=b2.t+al((R[bT]-b2[bT])/(b[bT]-b2[bT]))*(b.t-b2.t),bQ=b1.t+al((R[bS]-b1[bS])/(S[bS]-b1[bS]))*(S.t-b1.t);if(bR>=0&&bR<=1.001&&bQ>=0&&bQ<=1.001){if(b3){b6++}else{b6.push({x:R.x,y:R.y,t1:aj(bR,1),t2:aj(bQ,1)})}}}}}return b6}bi.pathIntersection=function(d,b){return bE(d,b)};bi.pathIntersectionNumber=function(d,b){return bE(d,b,1)};function bE(g,b,bZ){g=bi._path2curve(g);b=bi._path2curve(b);var bX,S,bW,E,bU,bO,d,bR,b3,b2,b4=bZ?0:[];for(var bV=0,bP=g.length;bV<bP;bV++){var b1=g[bV];if(b1[0]=="M"){bX=bU=b1[1];S=bO=b1[2]}else{if(b1[0]=="C"){b3=[bX,S].concat(b1.slice(1));bX=b3[6];S=b3[7]}else{b3=[bX,S,bX,S,bU,bO,bU,bO];bX=bU;S=bO}for(var bT=0,bY=b.length;bT<bY;bT++){var b0=b[bT];if(b0[0]=="M"){bW=d=b0[1];E=bR=b0[2]}else{if(b0[0]=="C"){b2=[bW,E].concat(b0.slice(1));bW=b2[6];E=b2[7]}else{b2=[bW,E,bW,E,d,bR,d,bR];bW=d;E=bR}var bQ=aP(b3,b2,bZ);if(bZ){b4+=bQ}else{for(var bS=0,R=bQ.length;bS<R;bS++){bQ[bS].segment1=bV;bQ[bS].segment2=bT;bQ[bS].bez1=b3;bQ[bS].bez2=b2}b4=b4.concat(bQ)}}}}}return b4}bi.isPointInsidePath=function(d,b,i){var g=bi.pathBBox(d);return bi.isPointInsideBBox(g,b,i)&&bE(d,[["M",b,i],["H",g.x2+10]],1)%2==1};bi._removedFactory=function(b){return function(){bc("raphael.log",null,"Rapha\xebl: you are calling to method \u201c"+b+"\u201d of removed object",b)}};var I=bi.pathBBox=function(bY){var bR=aR(bY);if(bR.bbox){return bl(bR.bbox)}if(!bY){return{x:0,y:0,width:0,height:0,x2:0,y2:0}}bY=bk(bY);var bU=0,bT=0,S=[],g=[],E;for(var bP=0,bX=bY.length;bP<bX;bP++){E=bY[bP];if(E[0]=="M"){bU=E[1];bT=E[2];S.push(bU);g.push(bT)}else{var bQ=aX(bU,bT,E[1],E[2],E[3],E[4],E[5],E[6]);S=S[av](bQ.min.x,bQ.max.x);g=g[av](bQ.min.y,bQ.max.y);bU=E[5];bT=E[6]}}var b=aj[bs](0,S),bV=aj[bs](0,g),bO=bI[bs](0,S),R=bI[bs](0,g),d=bO-b,bW=R-bV,bS={x:b,y:bV,x2:bO,y2:R,width:d,height:bW,cx:b+d/2,cy:bV+bW/2};bR.bbox=bl(bS);return bS},aY=function(d){var b=bl(d);b.toString=bi._path2string;return b},j=bi._pathToRelative=function(E){var bP=aR(E);if(bP.rel){return aY(bP.rel)}if(!bi.is(E,u)||!bi.is(E&&E[0],u)){E=bi.parsePathString(E)}var bS=[],bU=0,bT=0,bX=0,bW=0,g=0;if(E[0][0]=="M"){bU=E[0][1];bT=E[0][2];bX=bU;bW=bT;g++;bS.push(["M",bU,bT])}for(var bO=g,bY=E.length;bO<bY;bO++){var b=bS[bO]=[],bV=E[bO];if(bV[0]!=ak.call(bV[0])){b[0]=ak.call(bV[0]);switch(b[0]){case"a":b[1]=bV[1];b[2]=bV[2];b[3]=bV[3];b[4]=bV[4];b[5]=bV[5];b[6]=+(bV[6]-bU).toFixed(3);b[7]=+(bV[7]-bT).toFixed(3);break;case"v":b[1]=+(bV[1]-bT).toFixed(3);break;case"m":bX=bV[1];bW=bV[2];default:for(var S=1,bQ=bV.length;S<bQ;S++){b[S]=+(bV[S]-((S%2)?bU:bT)).toFixed(3)}}}else{b=bS[bO]=[];if(bV[0]=="m"){bX=bV[1]+bU;bW=bV[2]+bT}for(var R=0,d=bV.length;R<d;R++){bS[bO][R]=bV[R]}}var bR=bS[bO].length;switch(bS[bO][0]){case"z":bU=bX;bT=bW;break;case"h":bU+=+bS[bO][bR-1];break;case"v":bT+=+bS[bO][bR-1];break;default:bU+=+bS[bO][bR-2];bT+=+bS[bO][bR-1]}}bS.toString=bi._path2string;bP.rel=aY(bS);return bS},p=bi._pathToAbsolute=function(bT){var g=aR(bT);if(g.abs){return aY(g.abs)}if(!bi.is(bT,u)||!bi.is(bT&&bT[0],u)){bT=bi.parsePathString(bT)}if(!bT||!bT.length){return[["M",0,0]]}var bZ=[],bO=0,S=0,bR=0,bQ=0,E=0;if(bT[0][0]=="M"){bO=+bT[0][1];S=+bT[0][2];bR=bO;bQ=S;E++;bZ[0]=["M",bO,S]}var bY=bT.length==3&&bT[0][0]=="M"&&bT[1][0].toUpperCase()=="R"&&bT[2][0].toUpperCase()=="Z";for(var bS,b,bW=E,bP=bT.length;bW<bP;bW++){bZ.push(bS=[]);b=bT[bW];if(b[0]!=aU.call(b[0])){bS[0]=aU.call(b[0]);switch(bS[0]){case"A":bS[1]=b[1];bS[2]=b[2];bS[3]=b[3];bS[4]=b[4];bS[5]=b[5];bS[6]=+(b[6]+bO);bS[7]=+(b[7]+S);break;case"V":bS[1]=+b[1]+S;break;case"H":bS[1]=+b[1]+bO;break;case"R":var R=[bO,S][av](b.slice(1));for(var bV=2,bX=R.length;bV<bX;bV++){R[bV]=+R[bV]+bO;R[++bV]=+R[bV]+S}bZ.pop();bZ=bZ[av](am(R,bY));break;case"M":bR=+b[1]+bO;bQ=+b[2]+S;default:for(bV=1,bX=b.length;bV<bX;bV++){bS[bV]=+b[bV]+((bV%2)?bO:S)}}}else{if(b[0]=="R"){R=[bO,S][av](b.slice(1));bZ.pop();bZ=bZ[av](am(R,bY));bS=["R"][av](b.slice(-2))}else{for(var bU=0,d=b.length;bU<d;bU++){bS[bU]=b[bU]}}}switch(bS[0]){case"Z":bO=bR;S=bQ;break;case"H":bO=bS[1];break;case"V":S=bS[1];break;case"M":bR=bS[bS.length-2];bQ=bS[bS.length-1];default:bO=bS[bS.length-2];S=bS[bS.length-1]}}bZ.toString=bi._path2string;g.abs=aY(bZ);return bZ},aW=function(d,i,b,g){return[d,i,b,g,b,g]},z=function(d,i,S,E,b,g){var R=1/3,bO=2/3;return[R*d+bO*S,R*i+bO*E,R*b+bO*S,R*g+bO*E,b,g]},ac=function(bV,cq,b4,b2,bW,bQ,E,bU,cp,bX){var b1=ah*120/180,b=ah/180*(+bW||0),b8=[],b5,cm=H(function(cr,cu,i){var ct=cr*aI.cos(i)-cu*aI.sin(i),cs=cr*aI.sin(i)+cu*aI.cos(i);return{x:ct,y:cs}});if(!bX){b5=cm(bV,cq,-b);bV=b5.x;cq=b5.y;b5=cm(bU,cp,-b);bU=b5.x;cp=b5.y;var d=aI.cos(ah/180*bW),bS=aI.sin(ah/180*bW),ca=(bV-bU)/2,b9=(cq-cp)/2;var ck=(ca*ca)/(b4*b4)+(b9*b9)/(b2*b2);if(ck>1){ck=aI.sqrt(ck);b4=ck*b4;b2=ck*b2}var g=b4*b4,cd=b2*b2,cf=(bQ==E?-1:1)*aI.sqrt(al((g*cd-g*b9*b9-cd*ca*ca)/(g*b9*b9+cd*ca*ca))),bZ=cf*b4*b9/b2+(bV+bU)/2,bY=cf*-b2*ca/b4+(cq+cp)/2,bP=aI.asin(((cq-bY)/b2).toFixed(9)),bO=aI.asin(((cp-bY)/b2).toFixed(9));bP=bV<bZ?ah-bP:bP;bO=bU<bZ?ah-bO:bO;bP<0&&(bP=ah*2+bP);bO<0&&(bO=ah*2+bO);if(E&&bP>bO){bP=bP-ah*2}if(!E&&bO>bP){bO=bO-ah*2}}else{bP=bX[0];bO=bX[1];bZ=bX[2];bY=bX[3]}var bT=bO-bP;if(al(bT)>b1){var b0=bO,b3=bU,bR=cp;bO=bP+b1*(E&&bO>bP?1:-1);bU=bZ+b4*aI.cos(bO);cp=bY+b2*aI.sin(bO);b8=ac(bU,cp,b4,b2,bW,0,E,b3,bR,[bO,b0,bZ,bY])}bT=bO-bP;var S=aI.cos(bP),co=aI.sin(bP),R=aI.cos(bO),cn=aI.sin(bO),cb=aI.tan(bT/4),ce=4/3*b4*cb,cc=4/3*b2*cb,cl=[bV,cq],cj=[bV+ce*co,cq-cc*S],ci=[bU+ce*cn,cp-cc*R],cg=[bU,cp];cj[0]=2*cl[0]-cj[0];cj[1]=2*cl[1]-cj[1];if(bX){return[cj,ci,cg][av](b8)}else{b8=[cj,ci,cg][av](b8).join()[l](",");var b6=[];for(var ch=0,b7=b8.length;ch<b7;ch++){b6[ch]=ch%2?cm(b8[ch-1],b8[ch],b).y:cm(b8[ch],b8[ch+1],b).x}return b6}},bL=function(d,b,i,g,bP,bO,S,R,bQ){var E=1-bQ;return{x:aS(E,3)*d+aS(E,2)*3*bQ*i+E*3*bQ*bQ*bP+aS(bQ,3)*S,y:aS(E,3)*b+aS(E,2)*3*bQ*g+E*3*bQ*bQ*bO+aS(bQ,3)*R}},aX=H(function(i,d,R,E,bX,bW,bT,bQ){var bV=(bX-2*R+i)-(bT-2*bX+R),bS=2*(R-i)-2*(bX-R),bP=i-R,bO=(-bS+aI.sqrt(bS*bS-4*bV*bP))/2/bV,S=(-bS-aI.sqrt(bS*bS-4*bV*bP))/2/bV,bR=[d,bQ],bU=[i,bT],g;al(bO)>"1e12"&&(bO=0.5);al(S)>"1e12"&&(S=0.5);if(bO>0&&bO<1){g=bL(i,d,R,E,bX,bW,bT,bQ,bO);bU.push(g.x);bR.push(g.y)}if(S>0&&S<1){g=bL(i,d,R,E,bX,bW,bT,bQ,S);bU.push(g.x);bR.push(g.y)}bV=(bW-2*E+d)-(bQ-2*bW+E);bS=2*(E-d)-2*(bW-E);bP=d-E;bO=(-bS+aI.sqrt(bS*bS-4*bV*bP))/2/bV;S=(-bS-aI.sqrt(bS*bS-4*bV*bP))/2/bV;al(bO)>"1e12"&&(bO=0.5);al(S)>"1e12"&&(S=0.5);if(bO>0&&bO<1){g=bL(i,d,R,E,bX,bW,bT,bQ,bO);bU.push(g.x);bR.push(g.y)}if(S>0&&S<1){g=bL(i,d,R,E,bX,bW,bT,bQ,S);bU.push(g.x);bR.push(g.y)}return{min:{x:aj[bs](0,bU),y:aj[bs](0,bR)},max:{x:bI[bs](0,bU),y:bI[bs](0,bR)}}}),bk=bi._path2curve=H(function(bQ,d){var R=!d&&aR(bQ);if(!d&&R.curve){return aY(R.curve)}var bR=p(bQ),b=d&&p(d),bS={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},bZ={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},bY=function(b4,b5,b2){var i,b6,b3={T:1,Q:1};if(!b4){return["C",b5.x,b5.y,b5.x,b5.y,b5.x,b5.y]}!(b4[0] in b3)&&(b5.qx=b5.qy=null);switch(b4[0]){case"M":b5.X=b4[1];b5.Y=b4[2];break;case"A":b4=["C"][av](ac[bs](0,[b5.x,b5.y][av](b4.slice(1))));break;case"S":if(b2=="C"||b2=="S"){i=b5.x*2-b5.bx;b6=b5.y*2-b5.by}else{i=b5.x;b6=b5.y}b4=["C",i,b6][av](b4.slice(1));break;case"T":if(b2=="Q"||b2=="T"){b5.qx=b5.x*2-b5.qx;b5.qy=b5.y*2-b5.qy}else{b5.qx=b5.x;b5.qy=b5.y}b4=["C"][av](z(b5.x,b5.y,b5.qx,b5.qy,b4[1],b4[2]));break;case"Q":b5.qx=b4[1];b5.qy=b4[2];b4=["C"][av](z(b5.x,b5.y,b4[1],b4[2],b4[3],b4[4]));break;case"L":b4=["C"][av](aW(b5.x,b5.y,b4[1],b4[2]));break;case"H":b4=["C"][av](aW(b5.x,b5.y,b4[1],b5.y));break;case"V":b4=["C"][av](aW(b5.x,b5.y,b5.x,b4[1]));break;case"Z":b4=["C"][av](aW(b5.x,b5.y,b5.X,b5.Y));break}return b4},bW=function(b2,b3){if(b2[b3].length>7){b2[b3].shift();var b4=b2[b3];while(b4.length){bV[b3]="A";b&&(bT[b3]="A");b2.splice(b3++,0,["C"][av](b4.splice(0,6)))}b2.splice(b3,1);bO=bI(bR.length,b&&b.length||0)}},S=function(b6,b5,b3,b2,b4){if(b6&&b5&&b6[b4][0]=="M"&&b5[b4][0]!="M"){b5.splice(b4,0,["M",b2.x,b2.y]);b3.bx=0;b3.by=0;b3.x=b6[b4][1];b3.y=b6[b4][2];bO=bI(bR.length,b&&b.length||0)}},bV=[],bT=[],g="",b0="";for(var bU=0,bO=bI(bR.length,b&&b.length||0);bU<bO;bU++){bR[bU]&&(g=bR[bU][0]);if(g!="C"){bV[bU]=g;bU&&(b0=bV[bU-1])}bR[bU]=bY(bR[bU],bS,b0);if(bV[bU]!="A"&&g=="C"){bV[bU]="C"}bW(bR,bU);if(b){b[bU]&&(g=b[bU][0]);if(g!="C"){bT[bU]=g;bU&&(b0=bT[bU-1])}b[bU]=bY(b[bU],bZ,b0);if(bT[bU]!="A"&&g=="C"){bT[bU]="C"}bW(b,bU)}S(bR,b,bS,bZ,bU);S(b,bR,bZ,bS,bU);var bX=bR[bU],b1=b&&b[bU],bP=bX.length,E=b&&b1.length;bS.x=bX[bP-2];bS.y=bX[bP-1];bS.bx=bM(bX[bP-4])||bS.x;bS.by=bM(bX[bP-3])||bS.y;bZ.bx=b&&(bM(b1[E-4])||bZ.x);bZ.by=b&&(bM(b1[E-3])||bZ.y);bZ.x=b&&b1[E-2];bZ.y=b&&b1[E-1]}if(!b){R.curve=aY(bR)}return b?[bR,b]:bR},null,aY),ba=bi._parseDots=H(function(bR){var bQ=[];for(var S=0,bS=bR.length;S<bS;S++){var b={},bP=bR[S].match(/^([^:]*):?([\d\.]*)/);b.color=bi.getRGB(bP[1]);if(b.color.error){return null}b.color=b.color.hex;bP[2]&&(b.offset=bP[2]+"%");bQ.push(b)}for(S=1,bS=bQ.length-1;S<bS;S++){if(!bQ[S].offset){var g=bM(bQ[S-1].offset||0),E=0;for(var R=S+1;R<bS;R++){if(bQ[R].offset){E=bQ[R].offset;break}}if(!E){E=100;R=bS}E=bM(E);var bO=(E-g)/(R-S+1);for(;S<R;S++){g+=bO;bQ[S].offset=g+"%"}}}return bQ}),aH=bi._tear=function(b,d){b==d.top&&(d.top=b.prev);b==d.bottom&&(d.bottom=b.next);b.next&&(b.next.prev=b.prev);b.prev&&(b.prev.next=b.next)},M=bi._tofront=function(b,d){if(d.top===b){return}aH(b,d);b.next=null;b.prev=d.top;d.top.next=b;d.top=b},y=bi._toback=function(b,d){if(d.bottom===b){return}aH(b,d);b.next=d.bottom;b.prev=null;d.bottom.prev=b;d.bottom=b},ar=bi._insertafter=function(d,b,g){aH(d,g);b==g.top&&(g.top=d);b.next&&(b.next.prev=d);d.next=b.next;d.prev=b;b.next=d},m=bi._insertbefore=function(d,b,g){aH(d,g);b==g.bottom&&(g.bottom=d);b.prev&&(b.prev.next=d);d.prev=b.prev;b.prev=d;d.next=b},t=bi.toMatrix=function(g,b){var i=I(g),d={_:{transform:bn},getBBox:function(){return i}};Y(d,b);return d.matrix},ay=bi.transformPath=function(d,b){return T(d,t(d,b))},Y=bi._extractTransform=function(d,b2){if(b2==null){return d._.transform}b2=k(b2).replace(/\.{3}|\u2026/g,d._.transform||bn);var bU=bi.parseTransformString(b2),bS=0,bQ=0,bP=0,bW=1,bV=1,b3=d._,bX=new a9;b3.transform=bU||[];if(bU){for(var bY=0,bR=bU.length;bY<bR;bY++){var bT=bU[bY],b=bT.length,R=k(bT[0]).toLowerCase(),b1=bT[0]!=R,bO=b1?bX.invert():0,b0,E,bZ,g,S;if(R=="t"&&b==3){if(b1){b0=bO.x(0,0);E=bO.y(0,0);bZ=bO.x(bT[1],bT[2]);g=bO.y(bT[1],bT[2]);bX.translate(bZ-b0,g-E)}else{bX.translate(bT[1],bT[2])}}else{if(R=="r"){if(b==2){S=S||d.getBBox(1);bX.rotate(bT[1],S.x+S.width/2,S.y+S.height/2);bS+=bT[1]}else{if(b==4){if(b1){bZ=bO.x(bT[2],bT[3]);g=bO.y(bT[2],bT[3]);bX.rotate(bT[1],bZ,g)}else{bX.rotate(bT[1],bT[2],bT[3])}bS+=bT[1]}}}else{if(R=="s"){if(b==2||b==3){S=S||d.getBBox(1);bX.scale(bT[1],bT[b-1],S.x+S.width/2,S.y+S.height/2);bW*=bT[1];bV*=bT[b-1]}else{if(b==5){if(b1){bZ=bO.x(bT[3],bT[4]);g=bO.y(bT[3],bT[4]);bX.scale(bT[1],bT[2],bZ,g)}else{bX.scale(bT[1],bT[2],bT[3],bT[4])}bW*=bT[1];bV*=bT[2]}}}else{if(R=="m"&&b==7){bX.add(bT[1],bT[2],bT[3],bT[4],bT[5],bT[6])}}}}b3.dirtyT=1;d.matrix=bX}}d.matrix=bX;b3.sx=bW;b3.sy=bV;b3.deg=bS;b3.dx=bQ=bX.e;b3.dy=bP=bX.f;if(bW==1&&bV==1&&!bS&&b3.bbox){b3.bbox.x+=+bQ;b3.bbox.y+=+bP}else{b3.dirtyT=1}},o=function(d){var b=d[0];switch(b.toLowerCase()){case"t":return[b,0,0];case"m":return[b,1,0,0,1,0,0];case"r":if(d.length==4){return[b,0,d[2],d[3]]}else{return[b,0]}case"s":if(d.length==5){return[b,1,1,d[3],d[4]]}else{if(d.length==3){return[b,1,1]}else{return[b,1]}}}},bd=bi._equaliseTransform=function(R,E){E=k(E).replace(/\.{3}|\u2026/g,R);R=bi.parseTransformString(R)||[];E=bi.parseTransformString(E)||[];var b=bI(R.length,E.length),bQ=[],bR=[],g=0,d,S,bP,bO;for(;g<b;g++){bP=R[g]||o(E[g]);bO=E[g]||o(bP);if((bP[0]!=bO[0])||(bP[0].toLowerCase()=="r"&&(bP[2]!=bO[2]||bP[3]!=bO[3]))||(bP[0].toLowerCase()=="s"&&(bP[3]!=bO[3]||bP[4]!=bO[4]))){return}bQ[g]=[];bR[g]=[];for(d=0,S=bI(bP.length,bO.length);d<S;d++){d in bP&&(bQ[g][d]=bP[d]);d in bO&&(bR[g][d]=bO[d])}}return{from:bQ,to:bR}};bi._getContainer=function(b,E,g,i){var d;d=i==null&&!bi.is(b,"object")?a5.doc.getElementById(b):b;if(d==null){return}if(d.tagName){if(E==null){return{container:d,width:d.style.pixelWidth||d.offsetWidth,height:d.style.pixelHeight||d.offsetHeight}}else{return{container:d,width:E,height:g}}}return{container:1,x:b,y:E,width:g,height:i}};bi.pathToRelative=j;bi._engine={};bi.path2curve=bk;bi.matrix=function(i,g,bO,S,R,E){return new a9(i,g,bO,S,R,E)};function a9(i,g,bO,S,R,E){if(i!=null){this.a=+i;this.b=+g;this.c=+bO;this.d=+S;this.e=+R;this.f=+E}else{this.a=1;this.b=0;this.c=0;this.d=1;this.e=0;this.f=0}}(function(g){g.add=function(bW,bT,bR,bP,S,R){var E=[[],[],[]],i=[[this.a,this.c,this.e],[this.b,this.d,this.f],[0,0,1]],bV=[[bW,bR,S],[bT,bP,R],[0,0,1]],bU,bS,bQ,bO;if(bW&&bW instanceof a9){bV=[[bW.a,bW.c,bW.e],[bW.b,bW.d,bW.f],[0,0,1]]}for(bU=0;bU<3;bU++){for(bS=0;bS<3;bS++){bO=0;for(bQ=0;bQ<3;bQ++){bO+=i[bU][bQ]*bV[bQ][bS]}E[bU][bS]=bO}}this.a=E[0][0];this.b=E[1][0];this.c=E[0][1];this.d=E[1][1];this.e=E[0][2];this.f=E[1][2]};g.invert=function(){var E=this,i=E.a*E.d-E.b*E.c;return new a9(E.d/i,-E.b/i,-E.c/i,E.a/i,(E.c*E.f-E.d*E.e)/i,(E.b*E.e-E.a*E.f)/i)};g.clone=function(){return new a9(this.a,this.b,this.c,this.d,this.e,this.f)};g.translate=function(i,E){this.add(1,0,0,1,i,E)};g.scale=function(E,S,i,R){S==null&&(S=E);(i||R)&&this.add(1,0,0,1,i,R);this.add(E,0,0,S,0,0);(i||R)&&this.add(1,0,0,1,-i,-R)};g.rotate=function(E,i,bO){E=bi.rad(E);i=i||0;bO=bO||0;var S=+aI.cos(E).toFixed(9),R=+aI.sin(E).toFixed(9);this.add(S,R,-R,S,i,bO);this.add(1,0,0,1,-i,-bO)};g.x=function(i,E){return i*this.a+E*this.c+this.e};g.y=function(i,E){return i*this.b+E*this.d+this.f};g.get=function(E){return +this[k.fromCharCode(97+E)].toFixed(4)};g.toString=function(){return bi.svg?"matrix("+[this.get(0),this.get(1),this.get(2),this.get(3),this.get(4),this.get(5)].join()+")":[this.get(0),this.get(2),this.get(1),this.get(3),0,0].join()};g.toFilter=function(){return"progid:DXImageTransform.Microsoft.Matrix(M11="+this.get(0)+", M12="+this.get(2)+", M21="+this.get(1)+", M22="+this.get(3)+", Dx="+this.get(4)+", Dy="+this.get(5)+", sizingmethod='auto expand')"};g.offset=function(){return[this.e.toFixed(4),this.f.toFixed(4)]};function d(i){return i[0]*i[0]+i[1]*i[1]}function b(i){var E=aI.sqrt(d(i));i[0]&&(i[0]/=E);i[1]&&(i[1]/=E)}g.split=function(){var E={};E.dx=this.e;E.dy=this.f;var S=[[this.a,this.c],[this.b,this.d]];E.scalex=aI.sqrt(d(S[0]));b(S[0]);E.shear=S[0][0]*S[1][0]+S[0][1]*S[1][1];S[1]=[S[1][0]-S[0][0]*E.shear,S[1][1]-S[0][1]*E.shear];E.scaley=aI.sqrt(d(S[1]));b(S[1]);E.shear/=E.scaley;var i=-S[0][1],R=S[1][1];if(R<0){E.rotate=bi.deg(aI.acos(R));if(i<0){E.rotate=360-E.rotate}}else{E.rotate=bi.deg(aI.asin(i))}E.isSimple=!+E.shear.toFixed(9)&&(E.scalex.toFixed(9)==E.scaley.toFixed(9)||!E.rotate);E.isSuperSimple=!+E.shear.toFixed(9)&&E.scalex.toFixed(9)==E.scaley.toFixed(9)&&!E.rotate;E.noRotation=!+E.shear.toFixed(9)&&!E.rotate;return E};g.toTransformString=function(i){var E=i||this[l]();if(E.isSimple){E.scalex=+E.scalex.toFixed(4);E.scaley=+E.scaley.toFixed(4);E.rotate=+E.rotate.toFixed(4);return(E.dx||E.dy?"t"+[E.dx,E.dy]:bn)+(E.scalex!=1||E.scaley!=1?"s"+[E.scalex,E.scaley,0,0]:bn)+(E.rotate?"r"+[E.rotate,0,0]:bn)}else{return"m"+[this.get(0),this.get(1),this.get(2),this.get(3),this.get(4),this.get(5)]}}})(a9.prototype);var bD=function(){this.returnValue=false},n=function(){return this.originalEvent.preventDefault()},aJ=function(){this.cancelBubble=true},W=function(){return this.originalEvent.stopPropagation()},af=function(d){var b=a5.doc.documentElement.scrollTop||a5.doc.body.scrollTop,g=a5.doc.documentElement.scrollLeft||a5.doc.body.scrollLeft;return{x:d.clientX+g,y:d.clientY+b}},F=(function(){if(a5.doc.addEventListener){return function(E,g,d,b){var i=function(S){var bO=af(S);return d.call(b,S,bO.x,bO.y)};E.addEventListener(g,i,false);if(P&&bp[g]){var R=function(bQ){var bR=af(bQ),bO=bQ;for(var S=0,bP=bQ.targetTouches&&bQ.targetTouches.length;S<bP;S++){if(bQ.targetTouches[S].target==E){bQ=bQ.targetTouches[S];bQ.originalEvent=bO;bQ.preventDefault=n;bQ.stopPropagation=W;break}}return d.call(b,bQ,bR.x,bR.y)};E.addEventListener(bp[g],R,false)}return function(){E.removeEventListener(g,i,false);if(P&&bp[g]){E.removeEventListener(bp[g],R,false)}return true}}}else{if(a5.doc.attachEvent){return function(R,i,g,d){var E=function(bP){bP=bP||a5.win.event;var bO=a5.doc.documentElement.scrollTop||a5.doc.body.scrollTop,bQ=a5.doc.documentElement.scrollLeft||a5.doc.body.scrollLeft,S=bP.clientX+bQ,bR=bP.clientY+bO;bP.preventDefault=bP.preventDefault||bD;bP.stopPropagation=bP.stopPropagation||aJ;return g.call(d,bP,S,bR)};R.attachEvent("on"+i,E);var b=function(){R.detachEvent("on"+i,E);return true};return b}}}})(),aA=[],br=function(bP){var bS=bP.clientX,bR=bP.clientY,bU=a5.doc.documentElement.scrollTop||a5.doc.body.scrollTop,bV=a5.doc.documentElement.scrollLeft||a5.doc.body.scrollLeft,g,E=aA.length;while(E--){g=aA[E];if(P&&bP.touches){var S=bP.touches.length,R;while(S--){R=bP.touches[S];if(R.identifier==g.el._drag.id){bS=R.clientX;bR=R.clientY;(bP.originalEvent?bP.originalEvent:bP).preventDefault();break}}}else{bP.preventDefault()}var d=g.el.node,b,bO=d.nextSibling,bT=d.parentNode,bQ=d.style.display;a5.win.opera&&bT.removeChild(d);d.style.display="none";b=g.el.paper.getElementByPoint(bS,bR);d.style.display=bQ;a5.win.opera&&(bO?bT.insertBefore(d,bO):bT.appendChild(d));b&&bc("raphael.drag.over."+g.el.id,g.el,b);bS+=bV;bR+=bU;bc("raphael.drag.move."+g.el.id,g.move_scope||g.el,bS-g.el._drag.x,bR-g.el._drag.y,bS,bR,bP)}},e=function(g){bi.unmousemove(br).unmouseup(e);var d=aA.length,b;while(d--){b=aA[d];b.el._drag={};bc("raphael.drag.end."+b.el.id,b.end_scope||b.start_scope||b.move_scope||b.el,g)}aA=[]},aq=bi.el={};for(var a3=bB.length;a3--;){(function(b){bi[b]=aq[b]=function(g,d){if(bi.is(g,"function")){this.events=this.events||[];this.events.push({name:b,f:g,unbind:F(this.shape||this.node||a5.doc,b,g,d||this)})}return this};bi["un"+b]=aq["un"+b]=function(i){var g=this.events||[],d=g.length;while(d--){if(g[d].name==b&&(bi.is(i,"undefined")||g[d].f==i)){g[d].unbind();g.splice(d,1);!g.length&&delete this.events}}return this}})(bB[a3])}aq.data=function(d,E){var g=N[this.id]=N[this.id]||{};if(arguments.length==0){return g}if(arguments.length==1){if(bi.is(d,"object")){for(var b in d){if(d[bw](b)){this.data(b,d[b])}}return this}bc("raphael.data.get."+this.id,this,g[d],d);return g[d]}g[d]=E;bc("raphael.data.set."+this.id,this,E,d);return this};aq.removeData=function(b){if(b==null){N[this.id]={}}else{N[this.id]&&delete N[this.id][b]}return this};aq.getData=function(){return bl(N[this.id]||{})};aq.hover=function(i,b,g,d){return this.mouseover(i,g).mouseout(b,d||g)};aq.unhover=function(d,b){return this.unmouseover(d).unmouseout(b)};var ai=[];aq.drag=function(d,R,E,b,g,i){function S(bR){(bR.originalEvent||bR).preventDefault();var bO=bR.clientX,bU=bR.clientY,bQ=a5.doc.documentElement.scrollTop||a5.doc.body.scrollTop,bS=a5.doc.documentElement.scrollLeft||a5.doc.body.scrollLeft;this._drag.id=bR.identifier;if(P&&bR.touches){var bP=bR.touches.length,bT;while(bP--){bT=bR.touches[bP];this._drag.id=bT.identifier;if(bT.identifier==this._drag.id){bO=bT.clientX;bU=bT.clientY;break}}}this._drag.x=bO+bS;this._drag.y=bU+bQ;!aA.length&&bi.mousemove(br).mouseup(e);aA.push({el:this,move_scope:b,start_scope:g,end_scope:i});R&&bc.on("raphael.drag.start."+this.id,R);d&&bc.on("raphael.drag.move."+this.id,d);E&&bc.on("raphael.drag.end."+this.id,E);bc("raphael.drag.start."+this.id,g||b||this,this._drag.x,this._drag.y,bR)}this._drag={};ai.push({el:this,start:S});this.mousedown(S);return this};aq.onDragOver=function(b){b?bc.on("raphael.drag.over."+this.id,b):bc.unbind("raphael.drag.over."+this.id)};aq.undrag=function(){var b=ai.length;while(b--){if(ai[b].el==this){this.unmousedown(ai[b].start);ai.splice(b,1);bc.unbind("raphael.drag.*."+this.id)}}!ai.length&&bi.unmousemove(br).unmouseup(e);aA=[]};ao.circle=function(b,i,g){var d=bi._engine.circle(this,b||0,i||0,g||0);this.__set__&&this.__set__.push(d);return d};ao.rect=function(b,R,d,i,E){var g=bi._engine.rect(this,b||0,R||0,d||0,i||0,E||0);this.__set__&&this.__set__.push(g);return g};ao.ellipse=function(b,E,i,g){var d=bi._engine.ellipse(this,b||0,E||0,i||0,g||0);this.__set__&&this.__set__.push(d);return d};ao.path=function(b){b&&!bi.is(b,a)&&!bi.is(b[0],u)&&(b+=bn);var d=bi._engine.path(bi.format[bs](bi,arguments),this);this.__set__&&this.__set__.push(d);return d};ao.image=function(E,b,R,d,i){var g=bi._engine.image(this,E||"about:blank",b||0,R||0,d||0,i||0);this.__set__&&this.__set__.push(g);return g};ao.text=function(b,i,g){var d=bi._engine.text(this,b||0,i||0,k(g));this.__set__&&this.__set__.push(d);return d};ao.set=function(d){!bi.is(d,"array")&&(d=Array.prototype.splice.call(arguments,0,arguments.length));var b=new Z(d);this.__set__&&this.__set__.push(b);b.paper=this;b.type="set";return b};ao.setStart=function(b){this.__set__=b||this.set()};ao.setFinish=function(d){var b=this.__set__;delete this.__set__;return b};ao.getSize=function(){var b=this.canvas.parentNode;return{width:b.offsetWidth,height:b.offsetHeight}};ao.setSize=function(d,b){return bi._engine.setSize.call(this,d,b)};ao.setViewBox=function(b,E,d,i,g){return bi._engine.setViewBox.call(this,b,E,d,i,g)};ao.top=ao.bottom=null;ao.raphael=bi;var bN=function(g){var E=g.getBoundingClientRect(),bP=g.ownerDocument,R=bP.body,b=bP.documentElement,i=b.clientTop||R.clientTop||0,S=b.clientLeft||R.clientLeft||0,bO=E.top+(a5.win.pageYOffset||b.scrollTop||R.scrollTop)-i,d=E.left+(a5.win.pageXOffset||b.scrollLeft||R.scrollLeft)-S;return{y:bO,x:d}};ao.getElementByPoint=function(d,bO){var S=this,g=S.canvas,R=a5.doc.elementFromPoint(d,bO);if(a5.win.opera&&R.tagName=="svg"){var E=bN(g),i=g.createSVGRect();i.x=d-E.x;i.y=bO-E.y;i.width=i.height=1;var b=g.getIntersectionList(i,null);if(b.length){R=b[b.length-1]}}if(!R){return null}while(R.parentNode&&R!=g.parentNode&&!R.raphael){R=R.parentNode}R==S.canvas.parentNode&&(R=g);R=R&&R.raphael?S.getById(R.raphaelid):null;return R};ao.getElementsByBBox=function(b){var d=this.set();this.forEach(function(g){if(bi.isBBoxIntersect(g.getBBox(),b)){d.push(g)}});return d};ao.getById=function(d){var b=this.bottom;while(b){if(b.id==d){return b}b=b.next}return null};ao.forEach=function(g,b){var d=this.bottom;while(d){if(g.call(b,d)===false){return this}d=d.next}return this};ao.getElementsByPoint=function(b,g){var d=this.set();this.forEach(function(i){if(i.isPointInside(b,g)){d.push(i)}});return d};function bx(){return this.x+bh+this.y}function a6(){return this.x+bh+this.y+bh+this.width+" \xd7 "+this.height}aq.isPointInside=function(b,g){var d=this.realPath=ag[this.type](this);if(this.attr("transform")&&this.attr("transform").length){d=bi.transformPath(d,this.attr("transform"))}return bi.isPointInsidePath(d,b,g)};aq.getBBox=function(d){if(this.removed){return{}}var b=this._;if(d){if(b.dirty||!b.bboxwt){this.realPath=ag[this.type](this);b.bboxwt=I(this.realPath);b.bboxwt.toString=a6;b.dirty=0}return b.bboxwt}if(b.dirty||b.dirtyT||!b.bbox){if(b.dirty||!this.realPath){b.bboxwt=0;this.realPath=ag[this.type](this)}b.bbox=I(T(this.realPath,this.matrix));b.bbox.toString=a6;b.dirty=b.dirtyT=0}return b.bbox};aq.clone=function(){if(this.removed){return null}var b=this.paper[this.type]().attr(this.attr());this.__set__&&this.__set__.push(b);return b};aq.glow=function(bO){if(this.type=="text"){return null}bO=bO||{};var g={width:(bO.width||10)+(+this.attr("stroke-width")||1),fill:bO.fill||false,opacity:bO.opacity||0.5,offsetx:bO.offsetx||0,offsety:bO.offsety||0,color:bO.color||"#000"},S=g.width/2,E=this.paper,b=E.set(),R=this.realPath||ag[this.type](this);R=this.matrix?T(R,this.matrix):R;for(var d=1;d<S+1;d++){b.push(E.path(R).attr({stroke:g.color,fill:g.fill?g.color:"none","stroke-linejoin":"round","stroke-linecap":"round","stroke-width":+(g.width/S*d).toFixed(3),opacity:+(g.opacity/S).toFixed(3)}))}return b.insertBefore(this).translate(g.offsetx,g.offsety)};var aZ={},aO=function(d,b,E,i,bP,bO,S,R,g){if(g==null){return bb(d,b,E,i,bP,bO,S,R)}else{return bi.findDotsAtSegment(d,b,E,i,bP,bO,S,R,aK(d,b,E,i,bP,bO,S,R,g))}},aD=function(b,d){return function(bW,R,S){bW=bk(bW);var bS,bR,g,bO,E="",bV={},bT,bQ=0;for(var bP=0,bU=bW.length;bP<bU;bP++){g=bW[bP];if(g[0]=="M"){bS=+g[1];bR=+g[2]}else{bO=aO(bS,bR,g[1],g[2],g[3],g[4],g[5],g[6]);if(bQ+bO>R){if(d&&!bV.start){bT=aO(bS,bR,g[1],g[2],g[3],g[4],g[5],g[6],R-bQ);E+=["C"+bT.start.x,bT.start.y,bT.m.x,bT.m.y,bT.x,bT.y];if(S){return E}bV.start=E;E=["M"+bT.x,bT.y+"C"+bT.n.x,bT.n.y,bT.end.x,bT.end.y,g[5],g[6]].join();bQ+=bO;bS=+g[5];bR=+g[6];continue}if(!b&&!d){bT=aO(bS,bR,g[1],g[2],g[3],g[4],g[5],g[6],R-bQ);return{x:bT.x,y:bT.y,alpha:bT.alpha}}}bQ+=bO;bS=+g[5];bR=+g[6]}E+=g.shift()+g}bV.end=E;bT=b?bQ:d?bV:bi.findDotsAtSegment(bS,bR,g[0],g[1],g[2],g[3],g[4],g[5],1);bT.alpha&&(bT={x:bT.x,y:bT.y,alpha:bT.alpha});return bT}};var bG=aD(1),by=aD(),aB=aD(0,1);bi.getTotalLength=bG;bi.getPointAtLength=by;bi.getSubpath=function(d,i,g){if(this.getTotalLength(d)-g<0.000001){return aB(d,i).end}var b=aB(d,g,1);return i?aB(b,i).end:b};aq.getTotalLength=function(){var b=this.getPath();if(!b){return}if(this.node.getTotalLength){return this.node.getTotalLength()}return bG(b)};aq.getPointAtLength=function(b){var d=this.getPath();if(!d){return}return by(d,b)};aq.getPath=function(){var d,b=bi._getPath[this.type];if(this.type=="text"||this.type=="set"){return}if(b){d=b(this)}return d};aq.getSubpath=function(g,d){var b=this.getPath();if(!b){return}return bi.getSubpath(b,g,d)};var aG=bi.easing_formulas={linear:function(b){return b},"<":function(b){return aS(b,1.7)},">":function(b){return aS(b,0.48)},"<>":function(bO){var i=0.48-bO/1.04,g=aI.sqrt(0.1734+i*i),b=g-i,S=aS(al(b),1/3)*(b<0?-1:1),R=-g-i,E=aS(al(R),1/3)*(R<0?-1:1),d=S+E+0.5;return(1-d)*3*d*d+d*d*d},backIn:function(d){var b=1.70158;return d*d*((b+1)*d-b)},backOut:function(d){d=d-1;var b=1.70158;return d*d*((b+1)*d+b)+1},elastic:function(b){if(b==!!b){return b}return aS(2,-10*b)*aI.sin((b-0.075)*(2*ah)/0.3)+1},bounce:function(i){var d=7.5625,g=2.75,b;if(i<(1/g)){b=d*i*i}else{if(i<(2/g)){i-=(1.5/g);b=d*i*i+0.75}else{if(i<(2.5/g)){i-=(2.25/g);b=d*i*i+0.9375}else{i-=(2.625/g);b=d*i*i+0.984375}}}return b}};aG.easeIn=aG["ease-in"]=aG["<"];aG.easeOut=aG["ease-out"]=aG[">"];aG.easeInOut=aG["ease-in-out"]=aG["<>"];aG["back-in"]=aG.backIn;aG["back-out"]=aG.backOut;var bF=[],bH=aT.requestAnimationFrame||aT.webkitRequestAnimationFrame||aT.mozRequestAnimationFrame||aT.oRequestAnimationFrame||aT.msRequestAnimationFrame||function(b){setTimeout(b,16)},at=function(){var bO=+new Date,bW=0;for(;bW<bF.length;bW++){var b2=bF[bW];if(b2.el.removed||b2.paused){continue}var E=bO-b2.start,bU=b2.ms,bT=b2.easing,bX=b2.from,bR=b2.diff,d=b2.to,bQ=b2.t,S=b2.el,bS={},b,b0={},b4;if(b2.initstatus){E=(b2.initstatus*b2.anim.top-b2.prev)/(b2.percent-b2.prev)*bU;b2.status=b2.initstatus;delete b2.initstatus;b2.stop&&bF.splice(bW--,1)}else{b2.status=(b2.prev+(b2.percent-b2.prev)*(E/bU))/b2.anim.top}if(E<0){continue}if(E<bU){var g=bT(E/bU);for(var bV in bX){if(bX[bw](bV)){switch(bo[bV]){case bj:b=+bX[bV]+g*bU*bR[bV];break;case"colour":b="rgb("+[a1(C(bX[bV].r+g*bU*bR[bV].r)),a1(C(bX[bV].g+g*bU*bR[bV].g)),a1(C(bX[bV].b+g*bU*bR[bV].b))].join(",")+")";break;case"path":b=[];for(var bZ=0,bP=bX[bV].length;bZ<bP;bZ++){b[bZ]=[bX[bV][bZ][0]];for(var bY=1,b1=bX[bV][bZ].length;bY<b1;bY++){b[bZ][bY]=+bX[bV][bZ][bY]+g*bU*bR[bV][bZ][bY]}b[bZ]=b[bZ].join(bh)}b=b.join(bh);break;case"transform":if(bR[bV].real){b=[];for(bZ=0,bP=bX[bV].length;bZ<bP;bZ++){b[bZ]=[bX[bV][bZ][0]];for(bY=1,b1=bX[bV][bZ].length;bY<b1;bY++){b[bZ][bY]=bX[bV][bZ][bY]+g*bU*bR[bV][bZ][bY]}}}else{var b3=function(b5){return +bX[bV][b5]+g*bU*bR[bV][b5]};b=[["m",b3(0),b3(1),b3(2),b3(3),b3(4),b3(5)]]}break;case"csv":if(bV=="clip-rect"){b=[];bZ=4;while(bZ--){b[bZ]=+bX[bV][bZ]+g*bU*bR[bV][bZ]}}break;default:var R=[][av](bX[bV]);b=[];bZ=S.paper.customAttributes[bV].length;while(bZ--){b[bZ]=+R[bZ]+g*bU*bR[bV][bZ]}break}bS[bV]=b}}S.attr(bS);(function(b6,i,b5){setTimeout(function(){bc("raphael.anim.frame."+b6,i,b5)})})(S.id,S,b2.anim)}else{(function(b6,b5,i){setTimeout(function(){bc("raphael.anim.frame."+b5.id,b5,i);bc("raphael.anim.finish."+b5.id,b5,i);bi.is(b6,"function")&&b6.call(b5)})})(b2.callback,S,b2.anim);S.attr(d);bF.splice(bW--,1);if(b2.repeat>1&&!b2.next){for(b4 in d){if(d[bw](b4)){b0[b4]=b2.totalOrigin[b4]}}b2.el.attr(b0);U(b2.anim,b2.el,b2.anim.percents[0],null,b2.totalOrigin,b2.repeat-1)}if(b2.next&&!b2.stop){U(b2.anim,b2.el,b2.next,null,b2.totalOrigin,b2.repeat)}}}bF.length&&bH(at)},a1=function(b){return b>255?255:b<0?0:b};aq.animateWith=function(d,E,g,b,bO,bT){var S=this;if(S.removed){bT&&bT.call(S);return S}var bR=g instanceof f?g:bi.animation(g,b,bO,bT),bQ,bP;U(bR,S,bR.percents[0],null,S.attr());for(var R=0,bS=bF.length;R<bS;R++){if(bF[R].anim==E&&bF[R].el==d){bF[bS-1].start=bF[R].start;break}}return S};function a0(bU,i,d,bT,bS,bO){var bP=3*i,bR=3*(bT-i)-bP,b=1-bP-bR,S=3*d,bQ=3*(bS-d)-S,bV=1-S-bQ;function R(bW){return((b*bW+bR)*bW+bP)*bW}function g(bW,bY){var bX=E(bW,bY);return((bV*bX+bQ)*bX+S)*bX}function E(bW,b3){var b2,b1,bZ,bX,b0,bY;for(bZ=bW,bY=0;bY<8;bY++){bX=R(bZ)-bW;if(al(bX)<b3){return bZ}b0=(3*b*bZ+2*bR)*bZ+bP;if(al(b0)<0.000001){break}bZ=bZ-bX/b0}b2=0;b1=1;bZ=bW;if(bZ<b2){return b2}if(bZ>b1){return b1}while(b2<b1){bX=R(bZ);if(al(bX-bW)<b3){return bZ}if(bW>bX){b2=bZ}else{b1=bZ}bZ=(b1-b2)/2+b2}return bZ}return g(bU,1/(200*bO))}aq.onAnimation=function(b){b?bc.on("raphael.anim.frame."+this.id,b):bc.unbind("raphael.anim.frame."+this.id);return this};function f(E,g){var d=[],i={};this.ms=g;this.times=1;if(E){for(var b in E){if(E[bw](b)){i[bM(b)]=E[b];d.push(bM(b))}}d.sort(bu)}this.anim=i;this.top=d[d.length-1];this.percents=d}f.prototype.delay=function(d){var b=new f(this.anim,this.ms);b.times=this.times;b.del=+d||0;return b};f.prototype.repeat=function(d){var b=new f(this.anim,this.ms);b.del=this.del;b.times=aI.floor(bI(d,0))||1;return b};function U(b6,g,b,b4,bO,bS){b=bM(b);var cd,S,bR,ce=[],bY,bX,R,b0=b6.ms,b5={},E={},bU={};if(b4){for(b9=0,bT=bF.length;b9<bT;b9++){var cb=bF[b9];if(cb.el.id==g.id&&cb.anim==b6){if(cb.percent!=b){bF.splice(b9,1);bR=1}else{S=cb}g.attr(cb.totalOrigin);break}}}else{b4=+E}for(var b9=0,bT=b6.percents.length;b9<bT;b9++){if(b6.percents[b9]==b||b6.percents[b9]>b4*b6.top){b=b6.percents[b9];bX=b6.percents[b9-1]||0;b0=b0/b6.top*(b-bX);bY=b6.percents[b9+1];cd=b6.anim[b];break}else{if(b4){g.attr(b6.anim[b6.percents[b9]])}}}if(!cd){return}if(!S){for(var b2 in cd){if(cd[bw](b2)){if(bo[bw](b2)||g.paper.customAttributes[bw](b2)){b5[b2]=g.attr(b2);(b5[b2]==null)&&(b5[b2]=bq[b2]);E[b2]=cd[b2];switch(bo[b2]){case bj:bU[b2]=(E[b2]-b5[b2])/b0;break;case"colour":b5[b2]=bi.getRGB(b5[b2]);var b3=bi.getRGB(E[b2]);bU[b2]={r:(b3.r-b5[b2].r)/b0,g:(b3.g-b5[b2].g)/b0,b:(b3.b-b5[b2].b)/b0};break;case"path":var bP=bk(b5[b2],E[b2]),bW=bP[1];b5[b2]=bP[0];bU[b2]=[];for(b9=0,bT=b5[b2].length;b9<bT;b9++){bU[b2][b9]=[0];for(var b8=1,ca=b5[b2][b9].length;b8<ca;b8++){bU[b2][b9][b8]=(bW[b9][b8]-b5[b2][b9][b8])/b0}}break;case"transform":var cg=g._,cf=bd(cg[b2],E[b2]);if(cf){b5[b2]=cf.from;E[b2]=cf.to;bU[b2]=[];bU[b2].real=true;for(b9=0,bT=b5[b2].length;b9<bT;b9++){bU[b2][b9]=[b5[b2][b9][0]];for(b8=1,ca=b5[b2][b9].length;b8<ca;b8++){bU[b2][b9][b8]=(E[b2][b9][b8]-b5[b2][b9][b8])/b0}}}else{var b1=(g.matrix||new a9),cc={_:{transform:cg.transform},getBBox:function(){return g.getBBox(1)}};b5[b2]=[b1.a,b1.b,b1.c,b1.d,b1.e,b1.f];Y(cc,E[b2]);E[b2]=cc._.transform;bU[b2]=[(cc.matrix.a-b1.a)/b0,(cc.matrix.b-b1.b)/b0,(cc.matrix.c-b1.c)/b0,(cc.matrix.d-b1.d)/b0,(cc.matrix.e-b1.e)/b0,(cc.matrix.f-b1.f)/b0]}break;case"csv":var d=k(cd[b2])[l](bv),bQ=k(b5[b2])[l](bv);if(b2=="clip-rect"){b5[b2]=bQ;bU[b2]=[];b9=bQ.length;while(b9--){bU[b2][b9]=(d[b9]-b5[b2][b9])/b0}}E[b2]=d;break;default:d=[][av](cd[b2]);bQ=[][av](b5[b2]);bU[b2]=[];b9=g.paper.customAttributes[b2].length;while(b9--){bU[b2][b9]=((d[b9]||0)-(bQ[b9]||0))/b0}break}}}}var bZ=cd.easing,b7=bi.easing_formulas[bZ];if(!b7){b7=k(bZ).match(an);if(b7&&b7.length==5){var bV=b7;b7=function(i){return a0(i,+bV[1],+bV[2],+bV[3],+bV[4],b0)}}else{b7=aw}}R=cd.start||b6.start||+new Date;cb={anim:b6,percent:b,timestamp:R,start:R+(b6.del||0),status:0,initstatus:b4||0,stop:false,ms:b0,easing:b7,from:b5,diff:bU,to:E,el:g,callback:cd.callback,prev:bX,next:bY,repeat:bS||b6.times,origin:g.attr(),totalOrigin:bO};bF.push(cb);if(b4&&!S&&!bR){cb.stop=true;cb.start=new Date-b0*b4;if(bF.length==1){return at()}}if(bR){cb.start=new Date-cb.ms*b4}bF.length==1&&bH(at)}else{S.initstatus=b4;S.start=new Date-S.ms*b4}bc("raphael.anim.start."+g.id,g,b6)}bi.animation=function(g,b,bO,bQ){if(g instanceof f){return g}if(bi.is(bO,"function")||!bO){bQ=bQ||bO||null;bO=null}g=Object(g);b=+b||0;var d={},bR,S;for(S in g){if(g[bw](S)&&bM(S)!=S&&bM(S)+"%"!=S){bR=true;d[S]=g[S]}}if(!bR){if(bQ){var bP=0;for(var E in g){var R=bK(E);if(g[bw](E)&&R>bP){bP=R}}bP+="%";!g[bP].callback&&(g[bP].callback=bQ)}return new f(g,b)}else{bO&&(d.easing=bO);bQ&&(d.callback=bQ);return new f({100:d},b)}};aq.animate=function(i,b,R,E){var d=this;if(d.removed){E&&E.call(d);return d}var g=i instanceof f?i:bi.animation(i,b,R,E);U(g,d,g.percents[0],null,d.attr());return d};aq.setTime=function(d,b){if(d&&b!=null){this.status(d,aj(b,d.ms)/d.ms)}return this};aq.status=function(R,E){var d=[],g=0,b,S;if(E!=null){U(R,this,-1,aj(E,1));return this}else{b=bF.length;for(;g<b;g++){S=bF[g];if(S.el.id==this.id&&(!R||S.anim==R)){if(R){return S.status}d.push({anim:S.anim,status:S.status})}}if(R){return 0}return d}};aq.pause=function(d){for(var b=0;b<bF.length;b++){if(bF[b].el.id==this.id&&(!d||bF[b].anim==d)){if(bc("raphael.anim.pause."+this.id,this,bF[b].anim)!==false){bF[b].paused=true}}}return this};aq.resume=function(d){for(var b=0;b<bF.length;b++){if(bF[b].el.id==this.id&&(!d||bF[b].anim==d)){var g=bF[b];if(bc("raphael.anim.resume."+this.id,this,g.anim)!==false){delete g.paused;this.status(g.anim,g.status)}}}return this};aq.stop=function(d){for(var b=0;b<bF.length;b++){if(bF[b].el.id==this.id&&(!d||bF[b].anim==d)){if(bc("raphael.anim.stop."+this.id,this,bF[b].anim)!==false){bF.splice(b--,1)}}}return this};function be(d){for(var b=0;b<bF.length;b++){if(bF[b].el.paper==d){bF.splice(b--,1)}}}bc.on("raphael.remove",be);bc.on("raphael.clear",be);aq.toString=function(){return"Rapha\xebl\u2019s object"};var Z=function(b){this.items=[];this.length=0;this.type="set";if(b){for(var d=0,g=b.length;d<g;d++){if(b[d]&&(b[d].constructor==aq.constructor||b[d].constructor==Z)){this[this.items.length]=this.items[this.items.length]=b[d];this.length++}}}},v=Z.prototype;v.push=function(){var E,b;for(var d=0,g=arguments.length;d<g;d++){E=arguments[d];if(E&&(E.constructor==aq.constructor||E.constructor==Z)){b=this.items.length;this[b]=this.items[b]=E;this.length++}}return this};v.pop=function(){this.length&&delete this[this.length--];return this.items.pop()};v.forEach=function(E,b){for(var d=0,g=this.items.length;d<g;d++){if(E.call(b,this.items[d],d)===false){return this}}return this};for(var aF in aq){if(aq[bw](aF)){v[aF]=(function(b){return function(){var d=arguments;return this.forEach(function(g){g[b][bs](g,d)})}})(aF)}}v.attr=function(d,S){if(d&&bi.is(d,u)&&bi.is(d[0],"object")){for(var b=0,R=d.length;b<R;b++){this.items[b].attr(d[b])}}else{for(var g=0,E=this.items.length;g<E;g++){this.items[g].attr(d,S)}}return this};v.clear=function(){while(this.length){this.pop()}};v.splice=function(E,bO,bP){E=E<0?bI(this.length+E,0):E;bO=bI(0,aj(this.length-E,bO));var g=[],b=[],d=[],R;for(R=2;R<arguments.length;R++){d.push(arguments[R])}for(R=0;R<bO;R++){b.push(this[E+R])}for(;R<this.length-E;R++){g.push(this[E+R])}var S=d.length;for(R=0;R<S+g.length;R++){this.items[E+R]=this[E+R]=R<S?d[R]:g[R-S]}R=this.items.length=this.length-=bO-S;while(this[R]){delete this[R++]}return new Z(b)};v.exclude=function(g){for(var b=0,d=this.length;b<d;b++){if(this[b]==g){this.splice(b,1);return true}}};v.animate=function(g,b,bO,bQ){(bi.is(bO,"function")||!bO)&&(bQ=bO||null);var S=this.items.length,E=S,bR,bP=this,R;if(!S){return this}bQ&&(R=function(){!--S&&bQ.call(bP)});bO=bi.is(bO,a)?bO:R;var d=bi.animation(g,b,bO,R);bR=this.items[--E].animate(d);while(E--){this.items[E]&&!this.items[E].removed&&this.items[E].animateWith(bR,d,d);(this.items[E]&&!this.items[E].removed)||S--}return this};v.insertAfter=function(d){var b=this.items.length;while(b--){this.items[b].insertAfter(d)}return this};v.getBBox=function(){var b=[],S=[],d=[],E=[];for(var g=this.items.length;g--;){if(!this.items[g].removed){var R=this.items[g].getBBox();b.push(R.x);S.push(R.y);d.push(R.x+R.width);E.push(R.y+R.height)}}b=aj[bs](0,b);S=aj[bs](0,S);d=bI[bs](0,d);E=bI[bs](0,E);return{x:b,y:S,x2:d,y2:E,width:d-b,height:E-S}};v.clone=function(g){g=this.paper.set();for(var b=0,d=this.items.length;b<d;b++){g.push(this.items[b].clone())}return g};v.toString=function(){return"Rapha\xebl\u2018s set"};v.glow=function(d){var b=this.paper.set();this.forEach(function(i,E){var R=i.glow(d);if(R!=null){R.forEach(function(g,S){b.push(g)})}});return b};v.isPointInside=function(b,g){var d=false;this.forEach(function(i){if(i.isPointInside(b,g)){d=true;return false}});return d};bi.registerFont=function(d){if(!d.face){return d}this.fonts=this.fonts||{};var i={w:d.w,face:{},glyphs:{}},g=d.face["font-family"];for(var S in d.face){if(d.face[bw](S)){i.face[S]=d.face[S]}}if(this.fonts[g]){this.fonts[g].push(i)}else{this.fonts[g]=[i]}if(!d.svg){i.face["units-per-em"]=bK(d.face["units-per-em"],10);for(var E in d.glyphs){if(d.glyphs[bw](E)){var R=d.glyphs[E];i.glyphs[E]={w:R.w,k:{},d:R.d&&"M"+R.d.replace(/[mlcxtrv]/g,function(bO){return{l:"L",c:"C",x:"z",t:"m",r:"l",v:"c"}[bO]||"M"})+"z"};if(R.k){for(var b in R.k){if(R[bw](b)){i.glyphs[E].k[b]=R.k[b]}}}}}}return d};ao.getFont=function(bP,bQ,d,E){E=E||"normal";d=d||"normal";bQ=+bQ||{normal:400,bold:700,lighter:300,bolder:800}[bQ]||400;if(!bi.fonts){return}var R=bi.fonts[bP];if(!R){var g=new RegExp("(^|\\s)"+bP.replace(/[^\w\d\s+!~.:_-]/g,bn)+"(\\s|$)","i");for(var b in bi.fonts){if(bi.fonts[bw](b)){if(g.test(b)){R=bi.fonts[b];break}}}}var S;if(R){for(var bO=0,bR=R.length;bO<bR;bO++){S=R[bO];if(S.face["font-weight"]==bQ&&(S.face["font-style"]==d||!S.face["font-style"])&&S.face["font-stretch"]==E){break}}}return S};ao.print=function(bP,bO,b,bS,bU,b2,g,d){b2=b2||"middle";g=bI(aj(g||0,1),-1);d=bI(aj(d||1,3),1);var b1=k(b)[l](bn),bY=0,b0=0,bW=bn,b3;bi.is(bS,"string")&&(bS=this.getFont(bS));if(bS){b3=(bU||16)/bS.face["units-per-em"];var R=bS.face.bbox[l](bv),bR=+R[0],E=R[3]-R[1],S=0,bT=+R[1]+(b2=="baseline"?E+(+bS.face.descent):E/2);for(var bX=0,bQ=b1.length;bX<bQ;bX++){if(b1[bX]=="\n"){bY=0;bZ=0;b0=0;S+=E*d}else{var bV=b0&&bS.glyphs[b1[bX-1]]||{},bZ=bS.glyphs[b1[bX]];bY+=b0?(bV.w||bS.w)+(bV.k&&bV.k[b1[bX]]||0)+(bS.w*g):0;b0=1}if(bZ&&bZ.d){bW+=bi.transformPath(bZ.d,["t",bY*b3,S*b3,"s",b3,b3,bR,bT,"t",(bP-bR)/b3,(bO-bT)/b3])}}}return this.path(bW).attr({fill:"#000",stroke:"none"})};ao.add=function(E){if(bi.is(E,"array")){var g=this.set(),d=0,R=E.length,b;for(;d<R;d++){b=E[d]||{};au[bw](b.type)&&g.push(this[b.type]().attr(b))}}return g};bi.format=function(d,g){var b=bi.is(g,u)?[0][av](g):arguments;d&&bi.is(d,a)&&b.length-1&&(d=d.replace(X,function(R,E){return b[++E]==null?bn:b[E]}));return d||bn};bi.fullfill=(function(){var g=/\{([^\}]+)\}/g,b=/(?:(?:^|\.)(.+?)(?=\[|\.|$|\()|\[('|")(.+?)\2\])(\(\))?/g,d=function(R,E,S){var i=S;E.replace(b,function(bQ,bP,bO,bS,bR){bP=bP||bS;if(i){if(bP in i){i=i[bP]}typeof i=="function"&&bR&&(i=i())}});i=(i==null||i==S?R:i)+"";return i};return function(E,i){return String(E).replace(g,function(S,R){return d(S,R,i)})}})();bi.ninja=function(){aE.was?(a5.win.Raphael=aE.is):delete Raphael;return bi};bi.st=v;bc.on("raphael.DOMload",function(){K=true});(function(i,d,g){if(i.readyState==null&&i.addEventListener){i.addEventListener(d,g=function(){i.removeEventListener(d,g,false);i.readyState="complete"},false);i.readyState="loading"}function b(){(/in/).test(i.readyState)?setTimeout(b,9):bi.eve("raphael.DOMload")}b()})(document,"DOMContentLoaded");(function(){if(!bi.svg){return}var i="hasOwnProperty",ca=String,bV=parseFloat,bY=parseInt,bO=Math,cb=bO.max,b0=bO.abs,bQ=bO.pow,bP=/[, ]+/,b8=bi.eve,bZ="",bS=" ";var bW="http://www.w3.org/1999/xlink",b7={block:"M5,0 0,2.5 5,5z",classic:"M5,0 0,2.5 5,5 3.5,3 3.5,2z",diamond:"M2.5,0 5,2.5 2.5,5 0,2.5z",open:"M6,1 1,3.5 6,6",oval:"M2.5,0A2.5,2.5,0,0,1,2.5,5 2.5,2.5,0,0,1,2.5,0z"},b2={};bi.toString=function(){return"Your browser supports SVG.\nYou are running Rapha\xebl "+this.version};var bR=function(cc,E){if(E){if(typeof cc=="string"){cc=bR(cc)}for(var S in E){if(E[i](S)){if(S.substring(0,6)=="xlink:"){cc.setAttributeNS(bW,S.substring(6),ca(E[S]))}else{cc.setAttribute(S,ca(E[S]))}}}}else{cc=bi._g.doc.createElementNS("http://www.w3.org/2000/svg",cc);cc.style&&(cc.style.webkitTapHighlightColor="rgba(0,0,0,0)")}return cc},b=function(cj,cn){var cl="linear",S=cj.id+cn,ch=0.5,cf=0.5,cd=cj.node,E=cj.paper,cp=cd.style,cc=bi._g.doc.getElementById(S);if(!cc){cn=ca(cn).replace(bi._radial_gradient,function(cs,cq,ct){cl="radial";if(cq&&ct){ch=bV(cq);cf=bV(ct);var cr=((cf>0.5)*2-1);bQ(ch-0.5,2)+bQ(cf-0.5,2)>0.25&&(cf=bO.sqrt(0.25-bQ(ch-0.5,2))*cr+0.5)&&cf!=0.5&&(cf=cf.toFixed(5)-0.00001*cr)}return bZ});cn=cn.split(/\s*\-\s*/);if(cl=="linear"){var cg=cn.shift();cg=-bV(cg);if(isNaN(cg)){return null}var ce=[0,0,bO.cos(bi.rad(cg)),bO.sin(bi.rad(cg))],cm=1/(cb(b0(ce[2]),b0(ce[3]))||1);ce[2]*=cm;ce[3]*=cm;if(ce[2]<0){ce[0]=-ce[2];ce[2]=0}if(ce[3]<0){ce[1]=-ce[3];ce[3]=0}}var ck=bi._parseDots(cn);if(!ck){return null}S=S.replace(/[\(\)\s,\xb0#]/g,"_");if(cj.gradient&&S!=cj.gradient.id){E.defs.removeChild(cj.gradient);delete cj.gradient}if(!cj.gradient){cc=bR(cl+"Gradient",{id:S});cj.gradient=cc;bR(cc,cl=="radial"?{fx:ch,fy:cf}:{x1:ce[0],y1:ce[1],x2:ce[2],y2:ce[3],gradientTransform:cj.matrix.invert()});E.defs.appendChild(cc);for(var ci=0,co=ck.length;ci<co;ci++){cc.appendChild(bR("stop",{offset:ck[ci].offset?ck[ci].offset:ci?"100%":"0%","stop-color":ck[ci].color||"#fff"}))}}}bR(cd,{fill:"url('#"+S+"')",opacity:1,"fill-opacity":1});cp.fill=bZ;cp.opacity=1;cp.fillOpacity=1;return 1},d=function(S){var E=S.getBBox(1);bR(S.pattern,{patternTransform:S.matrix.invert()+" translate("+E.x+","+E.y+")"})},g=function(cl,cn,cg){if(cl.type=="path"){var E=ca(cn).toLowerCase().split("-"),ck=cl.paper,cy=cg?"end":"start",cp=cl.node,cm=cl.attrs,cf=cm["stroke-width"],ct=E.length,cd="classic",cs,cc,ci,cq,co,ch=3,cu=3,cj=5;while(ct--){switch(E[ct]){case"block":case"classic":case"oval":case"diamond":case"open":case"none":cd=E[ct];break;case"wide":cu=5;break;case"narrow":cu=2;break;case"long":ch=5;break;case"short":ch=2;break}}if(cd=="open"){ch+=2;cu+=2;cj+=2;ci=1;cq=cg?4:1;co={fill:"none",stroke:cm.stroke}}else{cq=ci=ch/2;co={fill:cm.stroke,stroke:"none"}}if(cl._.arrows){if(cg){cl._.arrows.endPath&&b2[cl._.arrows.endPath]--;cl._.arrows.endMarker&&b2[cl._.arrows.endMarker]--}else{cl._.arrows.startPath&&b2[cl._.arrows.startPath]--;cl._.arrows.startMarker&&b2[cl._.arrows.startMarker]--}}else{cl._.arrows={}}if(cd!="none"){var S="raphael-marker-"+cd,cx="raphael-marker-"+cy+cd+ch+cu+"-obj"+cl.id;if(!bi._g.doc.getElementById(S)){ck.defs.appendChild(bR(bR("path"),{"stroke-linecap":"round",d:b7[cd],id:S}));b2[S]=1}else{b2[S]++}var ce=bi._g.doc.getElementById(cx),cr;if(!ce){ce=bR(bR("marker"),{id:cx,markerHeight:cu,markerWidth:ch,orient:"auto",refX:cq,refY:cu/2});cr=bR(bR("use"),{"xlink:href":"#"+S,transform:(cg?"rotate(180 "+ch/2+" "+cu/2+") ":bZ)+"scale("+ch/cj+","+cu/cj+")","stroke-width":(1/((ch/cj+cu/cj)/2)).toFixed(4)});ce.appendChild(cr);ck.defs.appendChild(ce);b2[cx]=1}else{b2[cx]++;cr=ce.getElementsByTagName("use")[0]}bR(cr,co);var cw=ci*(cd!="diamond"&&cd!="oval");if(cg){cs=cl._.arrows.startdx*cf||0;cc=bi.getTotalLength(cm.path)-cw*cf}else{cs=cw*cf;cc=bi.getTotalLength(cm.path)-(cl._.arrows.enddx*cf||0)}co={};co["marker-"+cy]="url(#"+cx+")";if(cc||cs){co.d=bi.getSubpath(cm.path,cs,cc)}bR(cp,co);cl._.arrows[cy+"Path"]=S;cl._.arrows[cy+"Marker"]=cx;cl._.arrows[cy+"dx"]=cw;cl._.arrows[cy+"Type"]=cd;cl._.arrows[cy+"String"]=cn}else{if(cg){cs=cl._.arrows.startdx*cf||0;cc=bi.getTotalLength(cm.path)-cs}else{cs=0;cc=bi.getTotalLength(cm.path)-(cl._.arrows.enddx*cf||0)}cl._.arrows[cy+"Path"]&&bR(cp,{d:bi.getSubpath(cm.path,cs,cc)});delete cl._.arrows[cy+"Path"];delete cl._.arrows[cy+"Marker"];delete cl._.arrows[cy+"dx"];delete cl._.arrows[cy+"Type"];delete cl._.arrows[cy+"String"]}for(co in b2){if(b2[i](co)&&!b2[co]){var cv=bi._g.doc.getElementById(co);cv&&cv.parentNode.removeChild(cv)}}}},b3={"-":[3,1],".":[1,1],"-.":[3,1,1,1],"-..":[3,1,1,1,1,1],". ":[1,3],"- ":[4,3],"--":[8,3],"- .":[4,3,1,3],"--.":[8,3,1,3],"--..":[8,3,1,3,1,3]},bT=function(cg,ce,cf){ce=b3[ca(ce).toLowerCase()];if(ce){var cc=cg.attrs["stroke-width"]||"1",E={round:cc,square:cc,butt:0}[cg.attrs["stroke-linecap"]||cf["stroke-linecap"]]||0,cd=[],S=ce.length;while(S--){cd[S]=ce[S]*cc+((S%2)?1:-1)*E}bR(cg.node,{"stroke-dasharray":cd.join(",")})}else{bR(cg.node,{"stroke-dasharray":"none"})}},b5=function(cp,cy){var cu=cp.node,cq=cp.attrs,cm=cu.style.visibility;cu.style.visibility="hidden";for(var cs in cy){if(cy[i](cs)){if(!bi._availableAttrs[i](cs)){continue}var cr=cy[cs];cq[cs]=cr;switch(cs){case"blur":cp.blur(cr);break;case"title":var cz=cu.getElementsByTagName("title");if(cz.length&&(cz=cz[0])){cz.firstChild.nodeValue=cr}else{cz=bR("title");var cA=bi._g.doc.createTextNode(cr);cz.appendChild(cA);cu.appendChild(cz)}break;case"href":case"target":var cw=cu.parentNode;if(cw.tagName.toLowerCase()!="a"){var ce=bR("a");cw.insertBefore(ce,cu);ce.appendChild(cu);cw=ce;if(cs==="title"){var ck=document.createTextNode(cr),ct=bR("title");ct.appendChild(ck);cw.appendChild(ct);didCreateTitleElt=true}}if(cs=="target"){cw.setAttributeNS(bW,"show",cr=="blank"?"new":cr)}else{cw.setAttributeNS(bW,cs,cr)}if(!didCreateTitleElt&&(cs==="title")){for(var cg=cw.firstChild;cg;cg=cg.nextSibling){if(cg.tagName==="title"){var cn=cg.firstChild,ci=document.createTextNode(cr);if(cn){cg.replaceChild(ci,cn)}else{cg.appendChild(ci)}}}}break;case"cursor":cu.style.cursor=cr;break;case"transform":cp.transform(cr);break;case"arrow-start":g(cp,cr);break;case"arrow-end":g(cp,cr,1);break;case"clip-rect":var cc=ca(cr).split(bP);if(cc.length==4){cp.clip&&cp.clip.parentNode.parentNode.removeChild(cp.clip.parentNode);var S=bR("clipPath"),cv=bR("rect");S.id=bi.createUUID();bR(cv,{x:cc[0],y:cc[1],width:cc[2],height:cc[3]});S.appendChild(cv);cp.paper.defs.appendChild(S);bR(cu,{"clip-path":"url(#"+S.id+")"});cp.clip=cv}if(!cr){var co=cu.getAttribute("clip-path");if(co){var cx=bi._g.doc.getElementById(co.replace(/(^url\(#|\)$)/g,bZ));cx&&cx.parentNode.removeChild(cx);bR(cu,{"clip-path":bZ});delete cp.clip}}break;case"path":if(cp.type=="path"){bR(cu,{d:cr?cq.path=bi._pathToAbsolute(cr):"M0,0"});cp._.dirty=1;if(cp._.arrows){"startString" in cp._.arrows&&g(cp,cp._.arrows.startString);"endString" in cp._.arrows&&g(cp,cp._.arrows.endString,1)}}break;case"width":cu.setAttribute(cs,cr);cp._.dirty=1;if(cq.fx){cs="x";cr=cq.x}else{break}case"x":if(cq.fx){cr=-cq.x-(cq.width||0)}case"rx":if(cs=="rx"&&cp.type=="rect"){break}case"cx":cu.setAttribute(cs,cr);cp.pattern&&d(cp);cp._.dirty=1;break;case"height":cu.setAttribute(cs,cr);cp._.dirty=1;if(cq.fy){cs="y";cr=cq.y}else{break}case"y":if(cq.fy){cr=-cq.y-(cq.height||0)}case"ry":if(cs=="ry"&&cp.type=="rect"){break}case"cy":cu.setAttribute(cs,cr);cp.pattern&&d(cp);cp._.dirty=1;break;case"r":if(cp.type=="rect"){bR(cu,{rx:cr,ry:cr})}else{cu.setAttribute(cs,cr)}cp._.dirty=1;break;case"src":if(cp.type=="image"){cu.setAttributeNS(bW,"href",cr)}break;case"stroke-width":if(cp._.sx!=1||cp._.sy!=1){cr/=cb(b0(cp._.sx),b0(cp._.sy))||1}cu.setAttribute(cs,cr);if(cq["stroke-dasharray"]){bT(cp,cq["stroke-dasharray"],cy)}if(cp._.arrows){"startString" in cp._.arrows&&g(cp,cp._.arrows.startString);"endString" in cp._.arrows&&g(cp,cp._.arrows.endString,1)}break;case"stroke-dasharray":bT(cp,cr,cy);break;case"fill":var cf=ca(cr).match(bi._ISURL);if(cf){S=bR("pattern");var cl=bR("image");S.id=bi.createUUID();bR(S,{x:0,y:0,patternUnits:"userSpaceOnUse",height:1,width:1});bR(cl,{x:0,y:0,"xlink:href":cf[1]});S.appendChild(cl);(function(cB){bi._preload(cf[1],function(){var cC=this.offsetWidth,cD=this.offsetHeight;bR(cB,{width:cC,height:cD});bR(cl,{width:cC,height:cD})})})(S);cp.paper.defs.appendChild(S);bR(cu,{fill:"url(#"+S.id+")"});cp.pattern=S;cp.pattern&&d(cp);break}var cd=bi.getRGB(cr);if(!cd.error){delete cy.gradient;delete cq.gradient;!bi.is(cq.opacity,"undefined")&&bi.is(cy.opacity,"undefined")&&bR(cu,{opacity:cq.opacity});!bi.is(cq["fill-opacity"],"undefined")&&bi.is(cy["fill-opacity"],"undefined")&&bR(cu,{"fill-opacity":cq["fill-opacity"]})}else{if((cp.type=="circle"||cp.type=="ellipse"||ca(cr).charAt()!="r")&&b(cp,cr)){if("opacity" in cq||"fill-opacity" in cq){var E=bi._g.doc.getElementById(cu.getAttribute("fill").replace(/^url\(#|\)$/g,bZ));if(E){var ch=E.getElementsByTagName("stop");bR(ch[ch.length-1],{"stop-opacity":("opacity" in cq?cq.opacity:1)*("fill-opacity" in cq?cq["fill-opacity"]:1)})}}cq.gradient=cr;cq.fill="none";break}}cd[i]("opacity")&&bR(cu,{"fill-opacity":cd.opacity>1?cd.opacity/100:cd.opacity});case"stroke":cd=bi.getRGB(cr);cu.setAttribute(cs,cd.hex);cs=="stroke"&&cd[i]("opacity")&&bR(cu,{"stroke-opacity":cd.opacity>1?cd.opacity/100:cd.opacity});if(cs=="stroke"&&cp._.arrows){"startString" in cp._.arrows&&g(cp,cp._.arrows.startString);"endString" in cp._.arrows&&g(cp,cp._.arrows.endString,1)}break;case"gradient":(cp.type=="circle"||cp.type=="ellipse"||ca(cr).charAt()!="r")&&b(cp,cr);break;case"opacity":if(cq.gradient&&!cq[i]("stroke-opacity")){bR(cu,{"stroke-opacity":cr>1?cr/100:cr})}case"fill-opacity":if(cq.gradient){E=bi._g.doc.getElementById(cu.getAttribute("fill").replace(/^url\(#|\)$/g,bZ));if(E){ch=E.getElementsByTagName("stop");bR(ch[ch.length-1],{"stop-opacity":cr})}break}default:cs=="font-size"&&(cr=bY(cr,10)+"px");var cj=cs.replace(/(\-.)/g,function(cB){return cB.substring(1).toUpperCase()});cu.style[cj]=cr;cp._.dirty=1;cu.setAttribute(cs,cr);break}}}bX(cp,cy);cu.style.visibility=cm},b9=1.2,bX=function(E,ce){if(E.type!="text"||!(ce[i]("text")||ce[i]("font")||ce[i]("font-size")||ce[i]("x")||ce[i]("y"))){return}var cj=E.attrs,cc=E.node,cl=cc.firstChild?bY(bi._g.doc.defaultView.getComputedStyle(cc.firstChild,bZ).getPropertyValue("font-size"),10):10;cl=isFinite(cl)?cl:10;if(ce[i]("text")){cj.text=ce.text;while(cc.firstChild){cc.removeChild(cc.firstChild)}var cd=ca(ce.text).split("\n"),S=[],ch;for(var cf=0,ck=cd.length;cf<ck;cf++){ch=bR("tspan");cf&&bR(ch,{dy:cl*b9,x:cj.x});ch.appendChild(bi._g.doc.createTextNode(cd[cf]));cc.appendChild(ch);S[cf]=ch}}else{S=cc.getElementsByTagName("tspan");for(cf=0,ck=S.length;cf<ck;cf++){if(cf){bR(S[cf],{dy:cl*b9,x:cj.x})}else{bR(S[0],{dy:0})}}}bR(cc,{x:cj.x,y:cj.y});E._.dirty=1;var cg=E._getBBox(),ci=cj.y-(cg.y+cg.height/2);ci&&bi.is(ci,"finite")&&bR(S[0],{dy:ci})},b4=function(E){if(E.parentNode&&E.parentNode.tagName.toLowerCase()==="a"){return E.parentNode}else{return E}},b1=function(S,E){var cd=0,cc=0;this[0]=this.node=S;S.raphael=true;this.id=bi._oid++;S.raphaelid=this.id;this.matrix=bi.matrix();this.realPath=null;this.paper=E;this.attrs=this.attrs||{};this._={transform:[],sx:1,sy:1,deg:0,dx:0,dy:0,dirty:1};!E.bottom&&(E.bottom=this);this.prev=E.top;E.top&&(E.top.next=this);E.top=this;this.next=null},bU=bi.el;b1.prototype=bU;bU.constructor=b1;bi._engine.path=function(E,cd){var S=bR("path");cd.canvas&&cd.canvas.appendChild(S);var cc=new b1(S,cd);cc.type="path";b5(cc,{fill:"none",stroke:"#000",path:E});return cc};bU.rotate=function(S,E,cd){if(this.removed){return this}S=ca(S).split(bP);if(S.length-1){E=bV(S[1]);cd=bV(S[2])}S=bV(S[0]);(cd==null)&&(E=cd);if(E==null||cd==null){var cc=this.getBBox(1);E=cc.x+cc.width/2;cd=cc.y+cc.height/2}this.transform(this._.transform.concat([["r",S,E,cd]]));return this};bU.scale=function(ce,cc,E,cd){if(this.removed){return this}ce=ca(ce).split(bP);if(ce.length-1){cc=bV(ce[1]);E=bV(ce[2]);cd=bV(ce[3])}ce=bV(ce[0]);(cc==null)&&(cc=ce);(cd==null)&&(E=cd);if(E==null||cd==null){var S=this.getBBox(1)}E=E==null?S.x+S.width/2:E;cd=cd==null?S.y+S.height/2:cd;this.transform(this._.transform.concat([["s",ce,cc,E,cd]]));return this};bU.translate=function(S,E){if(this.removed){return this}S=ca(S).split(bP);if(S.length-1){E=bV(S[1])}S=bV(S[0])||0;E=+E||0;this.transform(this._.transform.concat([["t",S,E]]));return this};bU.transform=function(S){var cc=this._;if(S==null){return cc.transform}bi._extractTransform(this,S);this.clip&&bR(this.clip,{transform:this.matrix.invert()});this.pattern&&d(this);this.node&&bR(this.node,{transform:this.matrix});if(cc.sx!=1||cc.sy!=1){var E=this.attrs[i]("stroke-width")?this.attrs["stroke-width"]:1;this.attr({"stroke-width":E})}return this};bU.hide=function(){if(!this.removed){this.node.style.display="none"}return this};bU.show=function(){if(!this.removed){this.node.style.display=""}return this};bU.remove=function(){var S=b4(this.node);if(this.removed||!S.parentNode){return}var cc=this.paper;cc.__set__&&cc.__set__.exclude(this);b8.unbind("raphael.*.*."+this.id);if(this.gradient){cc.defs.removeChild(this.gradient)}bi._tear(this,cc);S.parentNode.removeChild(S);this.removeData();for(var E in this){this[E]=typeof this[E]=="function"?bi._removedFactory(E):null}this.removed=true};bU._getBBox=function(){if(this.node.style.display=="none"){this.show();var E=true}var ce=false,S;if(this.paper.canvas.parentElement){S=this.paper.canvas.parentElement.style}else{if(this.paper.canvas.parentNode){S=this.paper.canvas.parentNode.style}}if(S&&S.display=="none"){ce=true;S.display=""}var cd={};try{cd=this.node.getBBox()}catch(cc){cd={x:this.node.clientLeft,y:this.node.clientTop,width:this.node.clientWidth,height:this.node.clientHeight}}finally{cd=cd||{};if(ce){S.display="none"}}E&&this.hide();return cd};bU.attr=function(E,cj){if(this.removed){return this}if(E==null){var cg={};for(var ci in this.attrs){if(this.attrs[i](ci)){cg[ci]=this.attrs[ci]}}cg.gradient&&cg.fill=="none"&&(cg.fill=cg.gradient)&&delete cg.gradient;cg.transform=this._.transform;return cg}if(cj==null&&bi.is(E,"string")){if(E=="fill"&&this.attrs.fill=="none"&&this.attrs.gradient){return this.attrs.gradient}if(E=="transform"){return this._.transform}var ch=E.split(bP),cd={};for(var ce=0,cl=ch.length;ce<cl;ce++){E=ch[ce];if(E in this.attrs){cd[E]=this.attrs[E]}else{if(bi.is(this.paper.customAttributes[E],"function")){cd[E]=this.paper.customAttributes[E].def}else{cd[E]=bi._availableAttrs[E]}}}return cl-1?cd:cd[ch[0]]}if(cj==null&&bi.is(E,"array")){cd={};for(ce=0,cl=E.length;ce<cl;ce++){cd[E[ce]]=this.attr(E[ce])}return cd}if(cj!=null){var S={};S[E]=cj}else{if(E!=null&&bi.is(E,"object")){S=E}}for(var ck in S){b8("raphael.attr."+ck+"."+this.id,this,S[ck])}for(ck in this.paper.customAttributes){if(this.paper.customAttributes[i](ck)&&S[i](ck)&&bi.is(this.paper.customAttributes[ck],"function")){var cf=this.paper.customAttributes[ck].apply(this,[].concat(S[ck]));this.attrs[ck]=S[ck];for(var cc in cf){if(cf[i](cc)){S[cc]=cf[cc]}}}}b5(this,S);return this};bU.toFront=function(){if(this.removed){return this}var S=b4(this.node);S.parentNode.appendChild(S);var E=this.paper;E.top!=this&&bi._tofront(this,E);return this};bU.toBack=function(){if(this.removed){return this}var cc=b4(this.node);var E=cc.parentNode;E.insertBefore(cc,E.firstChild);bi._toback(this,this.paper);var S=this.paper;return this};bU.insertAfter=function(E){if(this.removed||!E){return this}var S=b4(this.node);var cc=b4(E.node||E[E.length-1].node);if(cc.nextSibling){cc.parentNode.insertBefore(S,cc.nextSibling)}else{cc.parentNode.appendChild(S)}bi._insertafter(this,E,this.paper);return this};bU.insertBefore=function(S){if(this.removed||!S){return this}var cc=b4(this.node);var E=b4(S.node||S[0].node);E.parentNode.insertBefore(cc,E);bi._insertbefore(this,S,this.paper);return this};bU.blur=function(S){var E=this;if(+S!==0){var cc=bR("filter"),cd=bR("feGaussianBlur");E.attrs.blur=S;cc.id=bi.createUUID();bR(cd,{stdDeviation:+S||1.5});cc.appendChild(cd);E.paper.defs.appendChild(cc);E._blur=cc;bR(E.node,{filter:"url(#"+cc.id+")"})}else{if(E._blur){E._blur.parentNode.removeChild(E._blur);delete E._blur;delete E.attrs.blur}E.node.removeAttribute("filter")}return E};bi._engine.circle=function(S,E,cf,ce){var cd=bR("circle");S.canvas&&S.canvas.appendChild(cd);var cc=new b1(cd,S);cc.attrs={cx:E,cy:cf,r:ce,fill:"none",stroke:"#000"};cc.type="circle";bR(cd,cc.attrs);return cc};bi._engine.rect=function(cc,E,ch,S,cf,cg){var ce=bR("rect");cc.canvas&&cc.canvas.appendChild(ce);var cd=new b1(ce,cc);cd.attrs={x:E,y:ch,width:S,height:cf,rx:cg||0,ry:cg||0,fill:"none",stroke:"#000"};cd.type="rect";bR(ce,cd.attrs);return cd};bi._engine.ellipse=function(S,E,cg,cf,ce){var cd=bR("ellipse");S.canvas&&S.canvas.appendChild(cd);var cc=new b1(cd,S);cc.attrs={cx:E,cy:cg,rx:cf,ry:ce,fill:"none",stroke:"#000"};cc.type="ellipse";bR(cd,cc.attrs);return cc};bi._engine.image=function(cc,cg,E,ch,S,cf){var ce=bR("image");bR(ce,{x:E,y:ch,width:S,height:cf,preserveAspectRatio:"none"});ce.setAttributeNS(bW,"href",cg);cc.canvas&&cc.canvas.appendChild(ce);var cd=new b1(ce,cc);cd.attrs={x:E,y:ch,width:S,height:cf,src:cg};cd.type="image";return cd};bi._engine.text=function(S,E,cf,ce){var cd=bR("text");S.canvas&&S.canvas.appendChild(cd);var cc=new b1(cd,S);cc.attrs={x:E,y:cf,"text-anchor":"middle",text:ce,"font-family":bi._availableAttrs["font-family"],"font-size":bi._availableAttrs["font-size"],stroke:"none",fill:"#000"};cc.type="text";b5(cc,cc.attrs);return cc};bi._engine.setSize=function(S,E){this.width=S||this.width;this.height=E||this.height;this.canvas.setAttribute("width",this.width);this.canvas.setAttribute("height",this.height);if(this._viewBox){this.setViewBox.apply(this,this._viewBox)}return this};bi._engine.create=function(){var cd=bi._getContainer.apply(0,arguments),S=cd&&cd.container,ch=cd.x,cg=cd.y,cc=cd.width,ci=cd.height;if(!S){throw new Error("SVG container not found.")}var E=bR("svg"),cf="overflow:hidden;",ce;ch=ch||0;cg=cg||0;cc=cc||512;ci=ci||342;bR(E,{height:ci,version:1.1,width:cc,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink"});if(S==1){E.style.cssText=cf+"position:absolute;left:"+ch+"px;top:"+cg+"px";bi._g.doc.body.appendChild(E);ce=1}else{E.style.cssText=cf+"position:relative";if(S.firstChild){S.insertBefore(E,S.firstChild)}else{S.appendChild(E)}}S=new bi._Paper;S.width=cc;S.height=ci;S.canvas=E;S.clear();S._left=S._top=0;ce&&(S.renderfix=function(){});S.renderfix();return S};bi._engine.setViewBox=function(cg,ce,ci,S,cc){b8("raphael.setViewBox",this,this._viewBox,[cg,ce,ci,S,cc]);var E=this.getSize(),ck=cb(ci/E.width,S/E.height),cf=this.top,cj=cc?"xMidYMid meet":"xMinYMin",cd,ch;if(cg==null){if(this._vbSize){ck=1}delete this._vbSize;cd="0 0 "+this.width+bS+this.height}else{this._vbSize=ck;cd=cg+bS+ce+bS+ci+bS+S}bR(this.canvas,{viewBox:cd,preserveAspectRatio:cj});while(ck&&cf){ch="stroke-width" in cf.attrs?cf.attrs["stroke-width"]:1;cf.attr({"stroke-width":ch});cf._.dirty=1;cf._.dirtyT=1;cf=cf.prev}this._viewBox=[cg,ce,ci,S,!!cc];return this};bi.prototype.renderfix=function(){var cf=this.canvas,E=cf.style,ce;try{ce=cf.getScreenCTM()||cf.createSVGMatrix()}catch(cd){ce=cf.createSVGMatrix()}var cc=-ce.e%1,S=-ce.f%1;if(cc||S){if(cc){this._left=(this._left+cc)%1;E.left=this._left+"px"}if(S){this._top=(this._top+S)%1;E.top=this._top+"px"}}};bi.prototype.clear=function(){bi.eve("raphael.clear",this);var E=this.canvas;while(E.firstChild){E.removeChild(E.firstChild)}this.bottom=this.top=null;(this.desc=bR("desc")).appendChild(bi._g.doc.createTextNode("Created with Rapha\xebl "+bi.version));E.appendChild(this.desc);E.appendChild(this.defs=bR("defs"))};bi.prototype.remove=function(){b8("raphael.remove",this);this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas);for(var E in this){this[E]=typeof this[E]=="function"?bi._removedFactory(E):null}};var b6=bi.st;for(var R in bU){if(bU[i](R)&&!b6[i](R)){b6[R]=(function(E){return function(){var S=arguments;return this.forEach(function(cc){cc[E].apply(cc,S)})}})(R)}}})();(function(){if(!bi.vml){return}var R="hasOwnProperty",cc=String,bV=parseFloat,bQ=Math,b9=bQ.round,cf=bQ.max,ca=bQ.min,b0=bQ.abs,b3="fill",bR=/[, ]+/,b8=bi.eve,b4=" progid:DXImageTransform.Microsoft",bT=" ",bY="",cb={M:"m",L:"l",C:"c",Z:"x",m:"t",l:"r",c:"v",z:"x"},bS=/([clmz]),?([^clmz]*)/gi,b1=/ progid:\S+Blur\([^\)]+\)/g,ce=/-?[^,\s-]+/g,i="position:absolute;left:0;top:0;width:1px;height:1px;behavior:url(#default#VML)",d=21600,b7={path:1,rect:1,image:1},bZ={circle:1,ellipse:1},bO=function(co){var cl=/[ahqstv]/ig,cg=bi._pathToAbsolute;cc(co).match(cl)&&(cg=bi._path2curve);cl=/[clmz]/g;if(cg==bi._pathToAbsolute&&!cc(co).match(cl)){var ck=cc(co).replace(bS,function(cs,cu,cq){var ct=[],cp=cu.toLowerCase()=="m",cr=cb[cu];cq.replace(ce,function(cv){if(cp&&ct.length==2){cr+=ct+cb[cu=="m"?"l":"L"];ct=[]}ct.push(b9(cv*d))});return cr+ct});return ck}var cm=cg(co),S,E;ck=[];for(var ci=0,cn=cm.length;ci<cn;ci++){S=cm[ci];E=cm[ci][0].toLowerCase();E=="z"&&(E="x");for(var ch=1,cj=S.length;ch<cj;ch++){E+=b9(S[ch]*d)+(ch!=cj-1?",":bY)}ck.push(E)}return ck.join(bT)},bW=function(ch,cg,S){var E=bi.matrix();E.rotate(-ch,0.5,0.5);return{dx:E.x(cg,S),dy:E.y(cg,S)}},bX=function(cn,cm,cl,ci,ch,cj){var cv=cn._,cp=cn.matrix,E=cv.fillpos,co=cn.node,ck=co.style,cg=1,S="",cr,ct=d/cm,cs=d/cl;ck.visibility="hidden";if(!cm||!cl){return}co.coordsize=b0(ct)+bT+b0(cs);ck.rotation=cj*(cm*cl<0?-1:1);if(cj){var cu=bW(cj,ci,ch);ci=cu.dx;ch=cu.dy}cm<0&&(S+="x");cl<0&&(S+=" y")&&(cg=-1);ck.flip=S;co.coordorigin=(ci*-ct)+bT+(ch*-cs);if(E||cv.fillsize){var cq=co.getElementsByTagName(b3);cq=cq&&cq[0];co.removeChild(cq);if(E){cu=bW(cj,cp.x(E[0],E[1]),cp.y(E[0],E[1]));cq.position=cu.dx*cg+bT+cu.dy*cg}if(cv.fillsize){cq.size=cv.fillsize[0]*b0(cm)+bT+cv.fillsize[1]*b0(cl)}co.appendChild(cq)}ck.visibility="visible"};bi.toString=function(){return"Your browser doesn\u2019t support SVG. Falling down to VML.\nYou are running Rapha\xebl "+this.version};var g=function(E,ck,S){var cm=cc(ck).toLowerCase().split("-"),ci=S?"end":"start",cg=cm.length,cj="classic",cl="medium",ch="medium";while(cg--){switch(cm[cg]){case"block":case"classic":case"oval":case"diamond":case"open":case"none":cj=cm[cg];break;case"wide":case"narrow":ch=cm[cg];break;case"long":case"short":cl=cm[cg];break}}var cn=E.node.getElementsByTagName("stroke")[0];cn[ci+"arrow"]=cj;cn[ci+"arrowlength"]=cl;cn[ci+"arrowwidth"]=ch},b5=function(cv,cH){cv.attrs=cv.attrs||{};var cC=cv.node,cL=cv.attrs,cr=cC.style,cn,cF=b7[cv.type]&&(cH.x!=cL.x||cH.y!=cL.y||cH.width!=cL.width||cH.height!=cL.height||cH.cx!=cL.cx||cH.cy!=cL.cy||cH.rx!=cL.rx||cH.ry!=cL.ry||cH.r!=cL.r),cu=bZ[cv.type]&&(cL.cx!=cH.cx||cL.cy!=cH.cy||cL.r!=cH.r||cL.rx!=cH.rx||cL.ry!=cH.ry),cO=cv;for(var cs in cH){if(cH[R](cs)){cL[cs]=cH[cs]}}if(cF){cL.path=bi._getPath[cv.type](cv);cv._.dirty=1}cH.href&&(cC.href=cH.href);cH.title&&(cC.title=cH.title);cH.target&&(cC.target=cH.target);cH.cursor&&(cr.cursor=cH.cursor);"blur" in cH&&cv.blur(cH.blur);if(cH.path&&cv.type=="path"||cF){cC.path=bO(~cc(cL.path).toLowerCase().indexOf("r")?bi._pathToAbsolute(cL.path):cL.path);cv._.dirty=1;if(cv.type=="image"){cv._.fillpos=[cL.x,cL.y];cv._.fillsize=[cL.width,cL.height];bX(cv,1,1,0,0,0)}}"transform" in cH&&cv.transform(cH.transform);if(cu){var ci=+cL.cx,cg=+cL.cy,cm=+cL.rx||+cL.r||0,cl=+cL.ry||+cL.r||0;cC.path=bi.format("ar{0},{1},{2},{3},{4},{1},{4},{1}x",b9((ci-cm)*d),b9((cg-cl)*d),b9((ci+cm)*d),b9((cg+cl)*d),b9(ci*d));cv._.dirty=1}if("clip-rect" in cH){var S=cc(cH["clip-rect"]).split(bR);if(S.length==4){S[2]=+S[2]+(+S[0]);S[3]=+S[3]+(+S[1]);var ct=cC.clipRect||bi._g.doc.createElement("div"),cN=ct.style;cN.clip=bi.format("rect({1}px {2}px {3}px {0}px)",S);if(!cC.clipRect){cN.position="absolute";cN.top=0;cN.left=0;cN.width=cv.paper.width+"px";cN.height=cv.paper.height+"px";cC.parentNode.insertBefore(ct,cC);ct.appendChild(cC);cC.clipRect=ct}}if(!cH["clip-rect"]){cC.clipRect&&(cC.clipRect.style.clip="auto")}}if(cv.textpath){var cJ=cv.textpath.style;cH.font&&(cJ.font=cH.font);cH["font-family"]&&(cJ.fontFamily='"'+cH["font-family"].split(",")[0].replace(/^['"]+|['"]+$/g,bY)+'"');cH["font-size"]&&(cJ.fontSize=cH["font-size"]);cH["font-weight"]&&(cJ.fontWeight=cH["font-weight"]);cH["font-style"]&&(cJ.fontStyle=cH["font-style"])}if("arrow-start" in cH){g(cO,cH["arrow-start"])}if("arrow-end" in cH){g(cO,cH["arrow-end"],1)}if(cH.opacity!=null||cH["stroke-width"]!=null||cH.fill!=null||cH.src!=null||cH.stroke!=null||cH["stroke-width"]!=null||cH["stroke-opacity"]!=null||cH["fill-opacity"]!=null||cH["stroke-dasharray"]!=null||cH["stroke-miterlimit"]!=null||cH["stroke-linejoin"]!=null||cH["stroke-linecap"]!=null){var cD=cC.getElementsByTagName(b3),cK=false;cD=cD&&cD[0];!cD&&(cK=cD=cd(b3));if(cv.type=="image"&&cH.src){cD.src=cH.src}cH.fill&&(cD.on=true);if(cD.on==null||cH.fill=="none"||cH.fill===null){cD.on=false}if(cD.on&&cH.fill){var ck=cc(cH.fill).match(bi._ISURL);if(ck){cD.parentNode==cC&&cC.removeChild(cD);cD.rotate=true;cD.src=ck[1];cD.type="tile";var E=cv.getBBox(1);cD.position=E.x+bT+E.y;cv._.fillpos=[E.x,E.y];bi._preload(ck[1],function(){cv._.fillsize=[this.offsetWidth,this.offsetHeight]})}else{cD.color=bi.getRGB(cH.fill).hex;cD.src=bY;cD.type="solid";if(bi.getRGB(cH.fill).error&&(cO.type in {circle:1,ellipse:1}||cc(cH.fill).charAt()!="r")&&b(cO,cH.fill,cD)){cL.fill="none";cL.gradient=cH.fill;cD.rotate=false}}}if("fill-opacity" in cH||"opacity" in cH){var cj=((+cL["fill-opacity"]+1||2)-1)*((+cL.opacity+1||2)-1)*((+bi.getRGB(cH.fill).o+1||2)-1);cj=ca(cf(cj,0),1);cD.opacity=cj;if(cD.src){cD.color="none"}}cC.appendChild(cD);var co=(cC.getElementsByTagName("stroke")&&cC.getElementsByTagName("stroke")[0]),cM=false;!co&&(cM=co=cd("stroke"));if((cH.stroke&&cH.stroke!="none")||cH["stroke-width"]||cH["stroke-opacity"]!=null||cH["stroke-dasharray"]||cH["stroke-miterlimit"]||cH["stroke-linejoin"]||cH["stroke-linecap"]){co.on=true}(cH.stroke=="none"||cH.stroke===null||co.on==null||cH.stroke==0||cH["stroke-width"]==0)&&(co.on=false);var cB=bi.getRGB(cH.stroke);co.on&&cH.stroke&&(co.color=cB.hex);cj=((+cL["stroke-opacity"]+1||2)-1)*((+cL.opacity+1||2)-1)*((+cB.o+1||2)-1);var cw=(bV(cH["stroke-width"])||1)*0.75;cj=ca(cf(cj,0),1);cH["stroke-width"]==null&&(cw=cL["stroke-width"]);cH["stroke-width"]&&(co.weight=cw);cw&&cw<1&&(cj*=cw)&&(co.weight=1);co.opacity=cj;cH["stroke-linejoin"]&&(co.joinstyle=cH["stroke-linejoin"]||"miter");co.miterlimit=cH["stroke-miterlimit"]||8;cH["stroke-linecap"]&&(co.endcap=cH["stroke-linecap"]=="butt"?"flat":cH["stroke-linecap"]=="square"?"square":"round");if("stroke-dasharray" in cH){var cA={"-":"shortdash",".":"shortdot","-.":"shortdashdot","-..":"shortdashdotdot",". ":"dot","- ":"dash","--":"longdash","- .":"dashdot","--.":"longdashdot","--..":"longdashdotdot"};co.dashstyle=cA[R](cH["stroke-dasharray"])?cA[cH["stroke-dasharray"]]:bY}cM&&cC.appendChild(co)}if(cO.type=="text"){cO.paper.canvas.style.display=bY;var cE=cO.paper.span,cz=100,ch=cL.font&&cL.font.match(/\d+(?:\.\d*)?(?=px)/);cr=cE.style;cL.font&&(cr.font=cL.font);cL["font-family"]&&(cr.fontFamily=cL["font-family"]);cL["font-weight"]&&(cr.fontWeight=cL["font-weight"]);cL["font-style"]&&(cr.fontStyle=cL["font-style"]);ch=bV(cL["font-size"]||ch&&ch[0])||10;cr.fontSize=ch*cz+"px";cO.textpath.string&&(cE.innerHTML=cc(cO.textpath.string).replace(/</g,"&#60;").replace(/&/g,"&#38;").replace(/\n/g,"<br>"));var cq=cE.getBoundingClientRect();cO.W=cL.w=(cq.right-cq.left)/cz;cO.H=cL.h=(cq.bottom-cq.top)/cz;cO.X=cL.x;cO.Y=cL.y+cO.H/2;("x" in cH||"y" in cH)&&(cO.path.v=bi.format("m{0},{1}l{2},{1}",b9(cL.x*d),b9(cL.y*d),b9(cL.x*d)+1));var cp=["x","y","text","font","font-family","font-weight","font-style","font-size"];for(var cG=0,cI=cp.length;cG<cI;cG++){if(cp[cG] in cH){cO._.dirty=1;break}}switch(cL["text-anchor"]){case"start":cO.textpath.style["v-text-align"]="left";cO.bbx=cO.W/2;break;case"end":cO.textpath.style["v-text-align"]="right";cO.bbx=-cO.W/2;break;default:cO.textpath.style["v-text-align"]="center";cO.bbx=0;break}cO.textpath.style["v-text-kern"]=true}},b=function(E,cn,cq){E.attrs=E.attrs||{};var co=E.attrs,ch=Math.pow,ci,cj,cl="linear",cm=".5 .5";E.attrs.gradient=cn;cn=cc(cn).replace(bi._radial_gradient,function(ct,cu,cs){cl="radial";if(cu&&cs){cu=bV(cu);cs=bV(cs);ch(cu-0.5,2)+ch(cs-0.5,2)>0.25&&(cs=bQ.sqrt(0.25-ch(cu-0.5,2))*((cs>0.5)*2-1)+0.5);cm=cu+bT+cs}return bY});cn=cn.split(/\s*\-\s*/);if(cl=="linear"){var S=cn.shift();S=-bV(S);if(isNaN(S)){return null}}var ck=bi._parseDots(cn);if(!ck){return null}E=E.shape||E.node;if(ck.length){E.removeChild(cq);cq.on=true;cq.method="none";cq.color=ck[0].color;cq.color2=ck[ck.length-1].color;var cr=[];for(var cg=0,cp=ck.length;cg<cp;cg++){ck[cg].offset&&cr.push(ck[cg].offset+bT+ck[cg].color)}cq.colors=cr.length?cr.join():"0% "+cq.color;if(cl=="radial"){cq.type="gradientTitle";cq.focus="100%";cq.focussize="0 0";cq.focusposition=cm;cq.angle=0}else{cq.type="gradient";cq.angle=(270-S)%360}E.appendChild(cq)}return 1},b2=function(S,E){this[0]=this.node=S;S.raphael=true;this.id=bi._oid++;S.raphaelid=this.id;this.X=0;this.Y=0;this.attrs={};this.paper=E;this.matrix=bi.matrix();this._={transform:[],sx:1,sy:1,dx:0,dy:0,deg:0,dirty:1,dirtyT:1};!E.bottom&&(E.bottom=this);this.prev=E.top;E.top&&(E.top.next=this);E.top=this;this.next=null};var bU=bi.el;b2.prototype=bU;bU.constructor=b2;bU.transform=function(ci){if(ci==null){return this._.transform}var ck=this.paper._viewBoxShift,cj=ck?"s"+[ck.scale,ck.scale]+"-1-1t"+[ck.dx,ck.dy]:bY,cn;if(ck){cn=ci=cc(ci).replace(/\.{3}|\u2026/g,this._.transform||bY)}bi._extractTransform(this,cj+ci);var co=this.matrix.clone(),cq=this.skew,cg=this.node,cm,ch=~cc(this.attrs.fill).indexOf("-"),E=!cc(this.attrs.fill).indexOf("url(");co.translate(1,1);if(E||ch||this.type=="image"){cq.matrix="1 0 0 1";cq.offset="0 0";cm=co.split();if((ch&&cm.noRotation)||!cm.isSimple){cg.style.filter=co.toFilter();var cl=this.getBBox(),S=this.getBBox(1),cr=cl.x-S.x,cp=cl.y-S.y;cg.coordorigin=(cr*-d)+bT+(cp*-d);bX(this,1,1,cr,cp,0)}else{cg.style.filter=bY;bX(this,cm.scalex,cm.scaley,cm.dx,cm.dy,cm.rotate)}}else{cg.style.filter=bY;cq.matrix=cc(co);cq.offset=co.offset()}if(cn!==null){this._.transform=cn;bi._extractTransform(this,cn)}return this};bU.rotate=function(S,E,ch){if(this.removed){return this}if(S==null){return}S=cc(S).split(bR);if(S.length-1){E=bV(S[1]);ch=bV(S[2])}S=bV(S[0]);(ch==null)&&(E=ch);if(E==null||ch==null){var cg=this.getBBox(1);E=cg.x+cg.width/2;ch=cg.y+cg.height/2}this._.dirtyT=1;this.transform(this._.transform.concat([["r",S,E,ch]]));return this};bU.translate=function(S,E){if(this.removed){return this}S=cc(S).split(bR);if(S.length-1){E=bV(S[1])}S=bV(S[0])||0;E=+E||0;if(this._.bbox){this._.bbox.x+=S;this._.bbox.y+=E}this.transform(this._.transform.concat([["t",S,E]]));return this};bU.scale=function(ci,cg,E,ch){if(this.removed){return this}ci=cc(ci).split(bR);if(ci.length-1){cg=bV(ci[1]);E=bV(ci[2]);ch=bV(ci[3]);isNaN(E)&&(E=null);isNaN(ch)&&(ch=null)}ci=bV(ci[0]);(cg==null)&&(cg=ci);(ch==null)&&(E=ch);if(E==null||ch==null){var S=this.getBBox(1)}E=E==null?S.x+S.width/2:E;ch=ch==null?S.y+S.height/2:ch;this.transform(this._.transform.concat([["s",ci,cg,E,ch]]));this._.dirtyT=1;return this};bU.hide=function(){!this.removed&&(this.node.style.display="none");return this};bU.show=function(){!this.removed&&(this.node.style.display=bY);return this};bU.auxGetBBox=bi.el.getBBox;bU.getBBox=function(){var E=this.auxGetBBox();if(this.paper&&this.paper._viewBoxShift){var cg={};var S=1/this.paper._viewBoxShift.scale;cg.x=E.x-this.paper._viewBoxShift.dx;cg.x*=S;cg.y=E.y-this.paper._viewBoxShift.dy;cg.y*=S;cg.width=E.width*S;cg.height=E.height*S;cg.x2=cg.x+cg.width;cg.y2=cg.y+cg.height;return cg}return E};bU._getBBox=function(){if(this.removed){return{}}return{x:this.X+(this.bbx||0)-this.W/2,y:this.Y-this.H,width:this.W,height:this.H}};bU.remove=function(){if(this.removed||!this.node.parentNode){return}this.paper.__set__&&this.paper.__set__.exclude(this);bi.eve.unbind("raphael.*.*."+this.id);bi._tear(this,this.paper);this.node.parentNode.removeChild(this.node);this.shape&&this.shape.parentNode.removeChild(this.shape);for(var E in this){this[E]=typeof this[E]=="function"?bi._removedFactory(E):null}this.removed=true};bU.attr=function(E,cn){if(this.removed){return this}if(E==null){var ck={};for(var cm in this.attrs){if(this.attrs[R](cm)){ck[cm]=this.attrs[cm]}}ck.gradient&&ck.fill=="none"&&(ck.fill=ck.gradient)&&delete ck.gradient;ck.transform=this._.transform;return ck}if(cn==null&&bi.is(E,"string")){if(E==b3&&this.attrs.fill=="none"&&this.attrs.gradient){return this.attrs.gradient}var cl=E.split(bR),ch={};for(var ci=0,cp=cl.length;ci<cp;ci++){E=cl[ci];if(E in this.attrs){ch[E]=this.attrs[E]}else{if(bi.is(this.paper.customAttributes[E],"function")){ch[E]=this.paper.customAttributes[E].def}else{ch[E]=bi._availableAttrs[E]}}}return cp-1?ch:ch[cl[0]]}if(this.attrs&&cn==null&&bi.is(E,"array")){ch={};for(ci=0,cp=E.length;ci<cp;ci++){ch[E[ci]]=this.attr(E[ci])}return ch}var S;if(cn!=null){S={};S[E]=cn}cn==null&&bi.is(E,"object")&&(S=E);for(var co in S){b8("raphael.attr."+co+"."+this.id,this,S[co])}if(S){for(co in this.paper.customAttributes){if(this.paper.customAttributes[R](co)&&S[R](co)&&bi.is(this.paper.customAttributes[co],"function")){var cj=this.paper.customAttributes[co].apply(this,[].concat(S[co]));this.attrs[co]=S[co];for(var cg in cj){if(cj[R](cg)){S[cg]=cj[cg]}}}}if(S.text&&this.type=="text"){this.textpath.string=S.text}b5(this,S)}return this};bU.toFront=function(){!this.removed&&this.node.parentNode.appendChild(this.node);this.paper&&this.paper.top!=this&&bi._tofront(this,this.paper);return this};bU.toBack=function(){if(this.removed){return this}if(this.node.parentNode.firstChild!=this.node){this.node.parentNode.insertBefore(this.node,this.node.parentNode.firstChild);bi._toback(this,this.paper)}return this};bU.insertAfter=function(E){if(this.removed){return this}if(E.constructor==bi.st.constructor){E=E[E.length-1]}if(E.node.nextSibling){E.node.parentNode.insertBefore(this.node,E.node.nextSibling)}else{E.node.parentNode.appendChild(this.node)}bi._insertafter(this,E,this.paper);return this};bU.insertBefore=function(E){if(this.removed){return this}if(E.constructor==bi.st.constructor){E=E[0]}E.node.parentNode.insertBefore(this.node,E.node);bi._insertbefore(this,E,this.paper);return this};bU.blur=function(E){var S=this.node.runtimeStyle,cg=S.filter;cg=cg.replace(b1,bY);if(+E!==0){this.attrs.blur=E;S.filter=cg+bT+b4+".Blur(pixelradius="+(+E||1.5)+")";S.margin=bi.format("-{0}px 0 0 -{0}px",b9(+E||1.5))}else{S.filter=cg;S.margin=0;delete this.attrs.blur}return this};bi._engine.path=function(ch,S){var ci=cd("shape");ci.style.cssText=i;ci.coordsize=d+bT+d;ci.coordorigin=S.coordorigin;var cj=new b2(ci,S),E={fill:"none",stroke:"#000"};ch&&(E.path=ch);cj.type="path";cj.path=[];cj.Path=bY;b5(cj,E);S.canvas.appendChild(ci);var cg=cd("skew");cg.on=true;ci.appendChild(cg);cj.skew=cg;cj.transform(bY);return cj};bi._engine.rect=function(S,ck,ci,cl,cg,E){var cm=bi._rectPath(ck,ci,cl,cg,E),ch=S.path(cm),cj=ch.attrs;ch.X=cj.x=ck;ch.Y=cj.y=ci;ch.W=cj.width=cl;ch.H=cj.height=cg;cj.r=E;cj.path=cm;ch.type="rect";return ch};bi._engine.ellipse=function(S,E,ck,cj,ci){var ch=S.path(),cg=ch.attrs;ch.X=E-cj;ch.Y=ck-ci;ch.W=cj*2;ch.H=ci*2;ch.type="ellipse";b5(ch,{cx:E,cy:ck,rx:cj,ry:ci});return ch};bi._engine.circle=function(S,E,cj,ci){var ch=S.path(),cg=ch.attrs;ch.X=E-ci;ch.Y=cj-ci;ch.W=ch.H=ci*2;ch.type="circle";b5(ch,{cx:E,cy:cj,r:ci});return ch};bi._engine.image=function(S,E,cl,cj,cm,ch){var co=bi._rectPath(cl,cj,cm,ch),ci=S.path(co).attr({stroke:"none"}),ck=ci.attrs,cg=ci.node,cn=cg.getElementsByTagName(b3)[0];ck.src=E;ci.X=ck.x=cl;ci.Y=ck.y=cj;ci.W=ck.width=cm;ci.H=ck.height=ch;ck.path=co;ci.type="image";cn.parentNode==cg&&cg.removeChild(cn);cn.rotate=true;cn.src=E;cn.type="tile";ci._.fillpos=[cl,cj];ci._.fillsize=[cm,ch];cg.appendChild(cn);bX(ci,1,1,0,0,0);return ci};bi._engine.text=function(E,ck,cj,cl){var ch=cd("shape"),cn=cd("path"),cg=cd("textpath");ck=ck||0;cj=cj||0;cl=cl||"";cn.v=bi.format("m{0},{1}l{2},{1}",b9(ck*d),b9(cj*d),b9(ck*d)+1);cn.textpathok=true;cg.string=cc(cl);cg.on=true;ch.style.cssText=i;ch.coordsize=d+bT+d;ch.coordorigin="0 0";var S=new b2(ch,E),ci={fill:"#000",stroke:"none",font:bi._availableAttrs.font,text:cl};S.shape=ch;S.path=cn;S.textpath=cg;S.type="text";S.attrs.text=cc(cl);S.attrs.x=ck;S.attrs.y=cj;S.attrs.w=1;S.attrs.h=1;b5(S,ci);ch.appendChild(cg);ch.appendChild(cn);E.canvas.appendChild(ch);var cm=cd("skew");cm.on=true;ch.appendChild(cm);S.skew=cm;S.transform(bY);return S};bi._engine.setSize=function(cg,E){var S=this.canvas.style;this.width=cg;this.height=E;cg==+cg&&(cg+="px");E==+E&&(E+="px");S.width=cg;S.height=E;S.clip="rect(0 "+cg+" "+E+" 0)";if(this._viewBox){bi._engine.setViewBox.apply(this,this._viewBox)}return this};bi._engine.setViewBox=function(ck,cj,cl,ch,ci){bi.eve("raphael.setViewBox",this,this._viewBox,[ck,cj,cl,ch,ci]);var cg=this.getSize(),E=cg.width,cn=cg.height,cm,S;if(ci){cm=cn/ch;S=E/cl;if(cl*cm<E){ck-=(E-cl*cm)/2/cm}if(ch*S<cn){cj-=(cn-ch*S)/2/S}}this._viewBox=[ck,cj,cl,ch,!!ci];this._viewBoxShift={dx:-ck,dy:-cj,scale:cg};this.forEach(function(co){co.transform("...")});return this};var cd;bi._engine.initWin=function(cg){var S=cg.document;if(S.styleSheets.length<31){S.createStyleSheet().addRule(".rvml","behavior:url(#default#VML)")}else{S.styleSheets[0].addRule(".rvml","behavior:url(#default#VML)")}try{!S.namespaces.rvml&&S.namespaces.add("rvml","urn:schemas-microsoft-com:vml");cd=function(ch){return S.createElement("<rvml:"+ch+' class="rvml">')}}catch(E){cd=function(ch){return S.createElement("<"+ch+' xmlns="urn:schemas-microsoft.com:vml" class="rvml">')}}};bi._engine.initWin(bi._g.win);bi._engine.create=function(){var cg=bi._getContainer.apply(0,arguments),E=cg.container,cm=cg.height,cn,S=cg.width,cl=cg.x,ck=cg.y;if(!E){throw new Error("VML container not found.")}var ci=new bi._Paper,cj=ci.canvas=bi._g.doc.createElement("div"),ch=cj.style;cl=cl||0;ck=ck||0;S=S||512;cm=cm||342;ci.width=S;ci.height=cm;S==+S&&(S+="px");cm==+cm&&(cm+="px");ci.coordsize=d*1000+bT+d*1000;ci.coordorigin="0 0";ci.span=bi._g.doc.createElement("span");ci.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;";cj.appendChild(ci.span);ch.cssText=bi.format("top:0;left:0;width:{0};height:{1};display:inline-block;position:relative;clip:rect(0 {0} {1} 0);overflow:hidden",S,cm);if(E==1){bi._g.doc.body.appendChild(cj);ch.left=cl+"px";ch.top=ck+"px";ch.position="absolute"}else{if(E.firstChild){E.insertBefore(cj,E.firstChild)}else{E.appendChild(cj)}}ci.renderfix=function(){};return ci};bi.prototype.clear=function(){bi.eve("raphael.clear",this);this.canvas.innerHTML=bY;this.span=bi._g.doc.createElement("span");this.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;";this.canvas.appendChild(this.span);this.bottom=this.top=null};bi.prototype.remove=function(){bi.eve("raphael.remove",this);this.canvas.parentNode.removeChild(this.canvas);for(var E in this){this[E]=typeof this[E]=="function"?bi._removedFactory(E):null}return true};var b6=bi.st;for(var bP in bU){if(bU[R](bP)&&!b6[R](bP)){b6[bP]=(function(E){return function(){var S=arguments;return this.forEach(function(cg){cg[E].apply(cg,S)})}})(bP)}}})();aE.was?(a5.win.Raphael=bi):(Raphael=bi);if(typeof exports=="object"){module.exports=bi}return bi}));DG.LayerManager=function(a){return{_firstLayer:null,_lastLayer:null,_paper:a,addNamedLayer:function(b,d){DG.assert(!SC.empty(b));if(this[b]){return this[b]}var c=DG.RaphaelLayer.create({_paper:this._paper,name:b});this[b]=c;if(d){c._prevLayer=d}else{if(this._lastLayer){c._prevLayer=this._lastLayer;this._lastLayer=c}else{this._firstLayer=this._lastLayer=c}}return this},getLayer:function(b){var c;this.forEach(function(d){if(d.get("name")===b){c=d}});return c},layerForElement:function(c){var b;this.forEach(function(d){if(!b&&d.contains(c)){b=d}});return b},forEach:function(d){var c,b;for(c=this._lastLayer;c;c=b){b=c._prevLayer;d(c)}},moveElementFromTo:function(d,c,b){if(c===b){return}if(typeof c==="string"){c=this[c]}if(typeof b==="string"){b=this[b]}if(c.contains(d)){c.prepareToMoveOrRemove(d);b.push(d)}},removeElement:function(c,b){b=b&&c[0].constructor!==SVGCircleElement;this.forEach(function(d){d.prepareToMoveOrRemove(c)});if(b){c.remove()}else{c.next=null;c.prev=null}},setVisibility:function(b,d,c){if(this[b]){if(d){this[b].show(c)}else{this[b].hide()}}},testValidity:function(){}}};sc_require("libraries/raphael");sc_require("utilities/layer_manager");DG.RaphaelBaseView=SC.View.extend(DG.Destroyable,{drawWidth:function(){return this.get("frame").width}.property("frame"),drawHeight:function(){return this.get("frame").height}.property("frame"),_paper:null,paper:function(){return this._paper}.property("_paper"),_layerManager:null,layerManager:function(){if(!this._layerManager){this.initLayerManager()}return this._layerManager}.property(),_plottedElementsMap:null,getPlottedElements:function(a){var b=this._plottedElementsMap&&this._plottedElementsMap[a];if(!b){b=[];if(this._plottedElementsMap){this._plottedElementsMap[a]=b}}return b},shiftPlottedElementsToEndOfMap:function(a){DG.assert(this._plottedElementsMap&&this._plottedElementsMap[a]);var c=this._plottedElementsMap.length,b=this._plottedElementsMap[a];if(a<c-1){this._plottedElementsMap.splice(a,1);this._plottedElementsMap.push(b)}},_elementsToClear:null,_firstTimeToDraw:true,init:function(){arguments.callee.base.apply(this,arguments);this._elementsToClear=[];this._plottedElementsMap=[]},destroy:function(){this._elementsToClear=null;this._paper=null;this._plottedElementsMap.length=0;this._plottedElementsMap=null;arguments.callee.base.apply(this,arguments)},createVisualization:function(){if(this.shouldDraw()){this.willDraw();this.doDraw();this.didDraw()}if(this._firstTimeToDraw){this._firstTimeToDraw=false;this.invokeLater("displayDidChange",1)}},shouldDraw:function shouldDraw(){return !SC.none(this._elementsToClear)},willDraw:function willDraw(){if(!this._elementsToClear){return}this._elementsToClear.forEach(function(a){a.remove()});this._elementsToClear=[]},doDraw:function doDraw(){},didDraw:function didDraw(){if(!this._elementsToClear){return}var b,a=this._elementsToClear.length;for(b=a-1;b>=0;b--){this._elementsToClear[b].toBack()}},updatePaper:function updatePaper(){if(this._paper){var b=this.get("drawWidth"),a=this.get("drawHeight");if((b<=0)||(a<=0)){return}if((this._paper.width!==b)||(this._paper.height!==a)){this._paper.setSize(b,a);this.notifyPropertyChange("paperSize");this.invokeLast(this.createVisualization)}}}.observes("frame"),render:function render(a,b){arguments.callee.base.apply(this,arguments);if(this._paper){this.createVisualization()}},initLayerManager:function(){if(!this._layerManager&&this._paper){this._layerManager=new DG.LayerManager(this._paper)}},didCreateLayer:function didCreateLayer(){this._paper=Raphael(this.get("layer"),this.get("drawWidth"),this.get("drawHeight"));this.createVisualization()},touchStart:function(a){return NO},touchEnd:function(a){return YES},touchesDragged:function(a,b){return YES},touchPriority:YES});sc_require("components/case_table/case_table_drop_target");sc_require("views/raphael_base");DG.RDV_DIVIDER_WIDTH=48;DG.RelationDividerView=DG.CaseTableDropTarget.extend((function(){var g=12,c=4,d="#808080",i="#EEEEEE",e="../../../../static/dg/fr/cert/source/resources/slickgrid/images/no-action.png",h="../../../../static/dg/fr/cert/source/resources/slickgrid/images/expand.gif",f="../../../../static/dg/fr/cert/source/resources/slickgrid/images/collapse.gif",b={width:9,height:9},j=5;function a(n,m){var o=m.width+2*j,l=m.height+2*j,k="M%@,%@ h%@ v%@ h%@ z".fmt(n.x-j,n.y-j,o,l,-o);return k}return{layout:{width:DG.RDV_DIVIDER_WIDTH},leftTable:function(k,l){if(l!==undefined){this.setPath("headerView.leftTable",l);this.setPath("dividerView.leftTable",l);return this}return this.getPath("dividerView.leftTable")}.property(),rightTable:function(k,l){if(l!==undefined){this.setPath("headerView.rightTable",l);this.setPath("dividerView.rightTable",l);return this}return this.getPath("dividerView.rightTable")}.property(),displayDidChange:function(){arguments.callee.base.apply(this,arguments);var k=this.get("headerView"),l=this.get("dividerView");if(k){k.displayDidChange()}if(l){l.displayDidChange()}}.observes("leftTable","rightTable"),childViews:["headerView","dividerView","labelView"],labelView:SC.LabelView.extend({value:"",layout:{left:2,right:2,top:2,bottom:2}}),headerView:DG.RaphaelBaseView.extend({layout:{left:0,top:0,right:0,height:54},render:function(k,l){arguments.callee.base.apply(this,arguments);k.resetClasses();k.addClass(["slick-header","ui-state-default"],YES)},classNames:[],backgroundColor:"#E6E6E6",expandCollapseIcon:null,expandCollapseMap:{collapse:f,expand:h,noAction:e},doDraw:function(){function q(){var z=r.get("model");var x=r.get("collection");var w=k.getLength();var u;var y;var v;var B=false;var A="noAction";DG.assert(z,"No data model");DG.assert(x,"No associated collection");for(u=0;u<w;u+=1){y=k.getItem(u);v=z.isCollapsedNode(y);if((y.get("collection").get("id")===x.get("id"))&&(y.children.length>0)){if(!v){A="collapse";return A}else{B=true}}}if(B){A="expand"}return A}function p(u){SC.run(function(){var v=q();switch(v){case"collapse":t.expandCollapseAll(false);break;case"expand":t.expandCollapseAll(true);break}})}var t=this.get("leftTable"),r=this.getPath("leftTable.gridAdapter"),k=r&&r.get("gridDataView"),l=q(),s=this.expandCollapseMap[l],m=(l==="collapse")?"DG.CaseTable.dividerView.collapseAllTooltip".loc():(l==="expand")?"DG.CaseTable.dividerView.expandAllTooltip".loc():"",n={x:3,y:38},o=b;this.action=l;if(SC.none(this.expandCollapseIcon)){this._paper.path(a(n,o)).attr({fill:"transparent",stroke:"transparent"}).touchstart(function(u){SC.run(p(u))});this.expandCollapseIcon=this._paper.image(s,n.x,n.y,o.width,o.height).click(function(u){SC.run(p(u))}).attr("title",m).setClass(l)}else{this.expandCollapseIcon.attr({src:s,title:m,x:n.x,y:n.y}).setClass(l)}}}),dividerView:DG.RaphaelBaseView.extend({layout:{left:0,top:54,right:0,bottom:0},backgroundColor:"white",leftTable:null,rightTable:null,tableRefreshObserver:function(){this.notifyPropertyChange("tableDidRefresh")}.observes("*leftTable.gridAdapter.tableDidRefresh","*rightTable.gridAdapter.tableDidRefresh"),_parentChildRelationsMap:null,displayProperties:["tableDidRefresh"],doDraw:function(){var m=this.get("leftTable"),x=m&&m.get("gridAdapter"),q=(m&&m.getPath("scrollPos.scrollTop"))||0,s=this.get("rightTable"),o=s&&s.get("gridAdapter"),t=(s&&s.getPath("scrollPos.scrollTop"))||0,r=this;if(!x||!o||SC.none(m._slickGrid)){return}if(!this._parentChildRelationsMap){this._parentChildRelationsMap=[]}function y(E,C){if(E===C){return"M0,%@ h%@".fmt(E,DG.RDV_DIVIDER_WIDTH)}var D={x:g,y:E},B={x:DG.RDV_DIVIDER_WIDTH-c,y:C},F={x:(D.x+B.x)/2,y:(D.y+B.y)/2},A={x:F.x,y:D.y};return"M0,%@ h%@ Q%@,%@ %@,%@ T%@,%@ h%@".fmt(D.y,g,A.x,A.y,F.x,F.y,B.x,B.y,c)}function p(G,E,F,C){var D={x:g,y:F},H={x:DG.RDV_DIVIDER_WIDTH-c,y:C},B={x:(D.x+H.x)/2,y:(D.y+H.y)/2},A={x:B.x,y:H.y};return"%@ V%@ h%@ Q%@,%@ %@,%@ T%@,%@ h%@ Z".fmt(y(G,E),H.y,-c,A.x,A.y,B.x,B.y,D.x,D.y,-g)}function z(D){var B=this.dgChildIDRange,C=(B&&B.isContained),A=(B&&B.isCollapsed),E=this.dgParentID;B.isCollapsed=!A;if(m&&!C){DG.UndoHistory.execute(DG.Command.create({name:"caseTable.expandCollapseOneCase",undoString:"DG.Undo.caseTable.expandCollapseOneCase",redoString:"DG.Redo.caseTable.expandCollapseOneCase",log:"%@ case %@".loc(A?"Expand":"Collapse",this.dgParentID),execute:function(){if(A){m.expandCase(E)}else{m.collapseCase(E)}s.updateSelectedRows(true);s.incrementProperty("expandCollapseCount")},undo:function(){if(A){m.collapseCase(E)}else{m.expandCase(E)}s.updateSelectedRows(true);s.incrementProperty("expandCollapseCount")},redo:function(){this.execute()}}))}}function v(A){return A.isContained?e:(A.isCollapsed?h:f)}function u(H,I,E,C,G){var F=H.getRowBounds(E);var B=I.getRowBounds(C);var D=I.getRowBounds(G);var A=(E===0)||(C===0);if(F&&B&&D){return{leftTop:F.top+(!A?1:0),leftBottom:F.bottom+1,rightTop:B.top+(!A?1:0),rightBottom:D.bottom+1}}}function w(B,A,C){if(B){if(A){B.attr({path:C});B.show()}else{B.hide()}}}function n(C,N,I,H){var B=H.isCollapsed||H.isContained;var F=o.get("gridDataView").getRowById(B?I:H.firstChildID);var M=o.get("gridDataView").getRowById(B?I:H.lastChildID);var R=u(m,s,N,F,M);if(SC.none(R)){return}var K=N%2;var J=H.renderBottom;var S=v(H);var T={x:3,y:R.leftTop-q+5};var G=b;var P=H.isContained?"none":H.isCollapsed?"expand":"collapse";var Q=(P==="collapse")?"DG.CaseTable.dividerView.collapseGroupTooltip".loc():(P==="expand")?"DG.CaseTable.dividerView.expandGroupTooltip".loc():"";var E=a(T,G);var U=y(R.leftTop-q,R.rightTop-t);var A=J?y(R.leftBottom-q+1,R.rightBottom-t+1):"";var O=K?p(R.leftTop-q,R.rightTop-t,R.leftBottom-q+1,R.rightBottom-t+1):"";var D=r._parentChildRelationsMap[C];if(!D){D=r._parentChildRelationsMap[C]={};D.top=r._paper.path(U).attr({stroke:d});D.bottom=r._paper.path(A).attr({stroke:d});if(!J){D.bottom.hide()}D.area=r._paper.path(O).attr({fill:i,stroke:"transparent"});if(!K){D.area.hide()}if((SC.browser.os===SC.OS.ios)||(SC.browser.os===SC.OS.android)){D.touch=r._paper.path(E).attr({fill:"transparent",stroke:"transparent"}).touchstart(function(V){SC.run(z.call(D.icon,V))})}D.icon=r._paper.image(S,T.x,T.y,G.width,G.height).setClass(P).click(function(V){SC.run(z.call(this,V))}).attr("title",Q)}else{w(D.top,true,U);w(D.bottom,J,A);w(D.area,K,O);w(D.touch,true,E);D.icon.attr({src:S,x:T.x,y:T.y,title:Q}).setClass(P).show()}D.icon.dgParentID=I;D.icon.dgChildIDRange=H;return D}function l(A){var B=r._parentChildRelationsMap[A];if(B){w(B.icon,false,"");w(B.top,false,"");w(B.bottom,false,"");w(B.area,false,"");w(B.touch,false,"")}}function k(){if(!m||!s||m.get("gridWidth")===0||s.get("gridWidth")===0){return}var T=m.get("gridViewport");var I=T.bottom-T.top;var A=x.get("gridDataView");var M=o.get("gridDataView");var Q=o.getProtoCase();var R=Q&&Q.get("id");var G=M&&M.getRowById(R);var K=Q&&Q.get("parentCaseID");var F;var V;var J;var B;var H;var S;var E;var C;var P;var U;var D;var N;DG.assert(T,"leftViewport missing");DG.assert(A,"leftDataView missing");for(F=0;F<I;++F){var O=A.getItem(T.top+F);if(O&&!O._isProtoCase){S=O}}for(F=0;F<I;F+=1){V=F+T.top;B=A.getItem(V);H=A.getItem(V+1);if(B&&B.children[0]){J=B.get("id");C=(K===J)||(!K&&(B===S));P=B.children[0].get("id");U=M&&M.getRowById(P);if(C&&(G<U)){P=R}D=B.children[B.children.length-1].get("id");N=M&&M.getRowById(D);if(C&&(G>N)){D=R}E={firstChildID:P,lastChildID:D,isCollapsed:x.model.isCollapsedNode(B),isContained:(B.get("collection").get("id")!==x.get("collection").get("id")),renderBottom:!H||H._isProtoCase};n(F,V,J,E)}else{l(F)}}for(F=I;F<r._parentChildRelationsMap.length;F+=1){l(F)}}k()}})}}()));sc_require("components/case_table/case_table_drop_target");sc_require("components/case_table/case_table_view");sc_require("components/case_table/relation_divider_view");DG.HierTableView=SC.ScrollView.extend((function(){var a=60;return{isVisibleChanged:function(){console.log("isVisibleChanged");if(this.get("isVisible")){this.updateColumnInfo()}}.observes("isVisible"),hasHorizontalScroller:YES,hasVerticalScroller:NO,horizontalOverlay:NO,autohidesHorizontalScroller:YES,horizontalAlign:SC.ALIGN_LEFT,classNames:"dg-hier-table-view",dataContext:null,layout:{left:0,top:0,right:0,bottom:8},isReady:false,isSelectedDidChange:function(){if(!this.getPath("parentView.parentView.isSelected")){this.contentView.hideHeaderMenus();this.resetActiveCell()}this.setPath("horizontalScrollerView.isVisible",false);this.invokeLater(function(){this.setPath("horizontalScrollerView.isVisible",true)},10)}.observes("parentView.parentView.isSelected"),resetActiveCell:function(){var b=this.get("childTableViews");b.forEach(function(c){c.resetActiveCell()})},selectComponent:function(){var b=DG.ComponentView.findComponentViewParent(this);b.select()},init:function(){arguments.callee.base.apply(this,arguments);this.set("horizontalScrollerLayout",{left:0,right:18,top:0,bottom:0})},convertFrameToView:function(c){var b=$(this.containerLayer()).offset();return{x:b.left-window.pageXOffset,y:b.top-window.pageYOffset,width:c.width,height:c.height}},adjustComponentViewClasses:function(b){b.get("classNames").push("dg-case-table-component-view")},didAppendToDocument:function(){var b=this.get("childTableViews");b.forEach(function(c){c.refreshScroll()})},viewDidScrollHorizontally:function(){this.get("contentView").parentViewDidResizeOrScroll();if(document.getElementById(this.get("layerId"))){this.setPath("model.horizontalScrollOffset",this.get("horizontalScrollOffset"))}}.observes("horizontalScrollOffset"),modelDidScrollHorizontally:function(){var b=this.getPath("model.horizontalScrollOffset");if(b!=null){this.setIfChanged("horizontalScrollOffset",b)}}.observes("model.horizontalScrollOffset"),isIndexHiddenDidChange:function(){this.updateColumnInfo()}.observes(".model.isIndexHidden"),contentView:SC.SplitView.extend({layout:{left:0,top:0,right:0,bottom:0},layoutDirection:SC.LAYOUT_HORIZONTAL,childViews:[],shouldResizeChildrenToFit:NO,parentViewDidResize:function(b){this.parentViewDidResizeOrScroll();return arguments.callee.base.apply(this,arguments)},parentViewDidResizeOrScroll:function(){var b=this.get("childTableViews");b.forEach(function(c){c.ancestorViewDidResizeOrScroll()})},frameSize:function(){return this.get("frame").width}.property(),frameSizeDidChange:function(){this.notifyPropertyChange("frameSize")}.observes("frame"),splitViewDividerBetween:function(d,c,b){return DG.InertSplitDividerView.create()},childTableViews:function(){var c=this.get("childViews")||[],b=[];c.forEach(function(d){if(d.kindOf(DG.CaseTableView)){b.push(d)}});return b}.property(),dividerViews:function(){var c=this.get("childViews")||[],b=[];c.forEach(function(d){if(d.kindOf(DG.RelationDividerView)){b.pushObject(d)}});return b}.property(),childTableLayoutDidChange:function(b){this.hideHeaderMenus();this.displayDidChange()},refreshTables:function(){var b=this.get("childTableViews");b.forEach(function(c){c.refresh()})},refreshDividers:function(){var b=this.get("dividerViews");b.forEach(function(c){c.displayDidChange()})},gridWidthDidChange:function(b){var c=b.get("gridWidth");b.set("size",c);this.scheduleTiling()},propagationCount:0,tableDidScroll:function(b){if(SC.none(b)){return}SC.run(function(){try{if(b._scrollEventCount<this.propagationCount){b._scrollEventCount=this.propagationCount}else{this.propagationCount++;b._scrollEventCount=this.propagationCount;var e=b.get("parentTable");var f=b.get("childTable");var d=true;while(e){if(d){d=e.scrollToAlignWithRight()}if(!d){e._scrollEventCount=this.propagationCount}e=e.get("parentTable")}d=true;while(f){if(d){d=f.scrollToAlignWithLeft()}if(!d){f._scrollEventCount=this.propagationCount}f=f.get("childTable")}}this.get("dividerViews").forEach(function(g){if(g.get("leftTable")===b||g.get("rightTable")===b){g.displayDidChange()}})}catch(c){DG.logWarn(c)}}.bind(this))},rowCountDidChange:function(b){if(!b){return}this.get("dividerViews").forEach(function(c){if((c.get("leftTable")===b)||(c.get("rightTable")===b)){c.displayDidChange()}})},tableDidExpandCollapse:function(){SC.run(function(){this.refreshDividers()}.bind(this))},hideHeaderMenus:function(){this.get("childTableViews").forEach(function(b){b.hideHeaderMenu()})},model:SC.outlet("parentView.parentView.model")}),relationDividerView:DG.RelationDividerView.extend(SC.SplitChild,{name:"relationDividerView",minimumSize:DG.RDV_DIVIDER_WIDTH,maximumSize:DG.RDV_DIVIDER_WIDTH,size:DG.RDV_DIVIDER_WIDTH,autoResizeStyle:SC.FIXED_SIZE,compensatesForMovement:YES,allowsIndirectAdjustments:NO}),childTableView:DG.CaseTableView.extend(SC.SplitChild,{name:"childTableView",minimumSize:a,autoResizeStyle:SC.RESIZE_AUTOMATIC,compensatesForMovement:YES}),leftDropTarget:null,makeRelationDividerView:function(){return this.relationDividerView.create({name:"dividerTarget",dataContext:this.model.get("context")})},makeChildTableView:function(){return this.childTableView.create({})},removeChildTableView:function(b){var e=this.get("contentView");var d=e.childViews.indexOf(b);var c=e.childViews.length;var f;if(d>0){f=e.childViews[d-1]}else{if(d===0&&c>2){f=e.childViews[d+1]}}if(f){e.removeChild(f)}e.removeChild(b)},getChildTableViewForCollection:function(c){var b=this.get("childTableViews");return DG.ArrayUtils.firstMatch(b,function(d){return d.getPath("gridAdapter.collection.id")===c})},childTableViews:function(){var b=this.get("contentView");return b.childTableViews()}.property(),dividerViews:function(){var b=this.get("contentView");return b.dividerViews()}.property(),willDestroy:function(){var b=this.get("childTableViews");b.forEach(function(c){if(c&&c.willDestroy){c.willDestroy()}c.removeObserver("frameSize",this,"contentWidthDidChange")})},refresh:function(){this.get("contentView").refreshTables()},refreshDividers:function(){this.get("contentView").refreshDividers()},mouseDown:function(b){if(b.target.tagName!=="INPUT"){DG.globalEditorLock.commitCurrentEdit()}return NO},touchStart:function(b){this.mouseDown(b);arguments.callee.base.apply(this,arguments);return NO},isHorizontalScrollActive:function(){if(SC.none(this._lastContentWidth)){this._lastContentWidth=this.getPath("contentView.frame.width")}return this.get("frame").width<this.get("_lastContentWidth")}.property(),_lastContentWidth:null,widenColumnsProportionally:function(f,d){var b=this.get("childTableViews")||[];var e=b.reduce(function(h,g){var i=g.get("columnWidths")||{};return h+Object.keys(i).reduce(function(l,j){var k=isNaN(Number(j))?0:i[j];return l+k},0)},0);var c=(e+f-d)/e;b.forEach(function(g){g.widenColumnsProportionally(c)})},expandRightmostColumn:function(c,b){var d=this.get("childTableViews");var e=d&&d[d.length-1];if(e){e.resizeLastColumn(c-b)}},adjustContentWidth:function(b){var k=this.getPath("contentView.frame.width");var c=this.get("frame").width;var f=window.innerWidth;var i=Math.max(f,c);var h=DG.ComponentView.findComponentViewParent(this);var g=this._lastContentWidth!=null;var j=this.get("isComponentLayoutAnimating");var e=h&&h.get("layout");if(SC.none(h)||!k||!c||k===c){return}if((k>0)&&(c>0)&&Number(c)!==Number(k)&&b==="frame"&&g&&!j){this.expandRightmostColumn(c,k);k=this.getPath("contentView.frame.width")}if(c===this._lastContentWidth&&b==="content"){var d=Math.min(k,i);if(DG.KEEP_IN_BOUNDS_PREF){h.configureViewBoundsLayout({height:e.height,width:d,x:e.left,y:e.top})}else{h.adjust("width",d)}}else{if(k<c){h.adjust("width",k)}}if(b==="content"){this._lastContentWidth=k}},frameDidChange:function(){this.adjustContentWidth("frame")}.observes("frame"),contentWidthDidChange:function(){this.adjustContentWidth("content")},isComponentLayoutAnimating:function(){var b=DG.ComponentView.findComponentViewParent(this);return b&&!!b._activeAnimations}.property(),_wasAnimating:false,componentIsAnimatingDidChange:function(){var b=DG.ComponentView.findComponentViewParent(this);var d=b&&b.get("viewState");var c=(d&&d===SC.CoreView.ATTACHED_SHOWN_ANIMATING);if(this._wasAnimating!==c){this.notifyPropertyChange("isComponentLayoutAnimating")}if(this._wasAnimating&&!c){this.adjustContentWidth("content");this.refresh()}this._wasAnimating=c}.observes("parentView.parentView.viewState"),_klugeAdjust:false,gridViewDidChange:function(c){this.refreshDividers();if(!this._klugeAdjust){this._klugeAdjust=true;var d=DG.ComponentView.findComponentViewParent(this),b=d&&d.get("frame"),e=b&&b.width;if(e){d.adjust("width",e+1)}}},setCaseTableAdapters:function(b){function c(m,l,k){if(k&&m&&l){k.beginPropertyChanges();k.set("leftTable",m);k.set("rightTable",l);k.endPropertyChanges()}}var j=this.get("contentView");var e=this.get("childTableViews");var g=[];var i;var f=null;var d=this.getPath("model.horizontalScrollOffset");var h;while(!SC.none(h=j.get("childViews")[0])){j.removeChild(h)}b.forEach(function(l,k){g[k]=e.findProperty("gridAdapter",l)});if(SC.none(this.leftDropTarget)){this.leftDropTarget=DG.CaseTableDropTarget.create({name:"leftTarget",isTopLevel:true,dataContext:this.model.get("context")})}j.appendChild(this.leftDropTarget);b.forEach(function(l,k){var m;if(!g[k]){i=this.makeChildTableView();i.set("gridAdapter",l);g[k]=i}if(k>0){m=this.makeRelationDividerView();c(g[k-1],g[k],m);j.appendChild(m)}if(k+1===b.length){g[k].set("isRightmost",true)}j.appendChild(g[k]);if(f){f.set("childTable",g[k]);g[k].set("parentTable",f)}else{g[k].set("parentTable",null)}f=g[k];f.set("childTable",null)}.bind(this));this.updateSelectedRows();j.scheduleTiling();if(!j.hasObserverFor("frameSize",this,"contentWidthDidChange")){j.addObserver("frameSize",this,"contentWidthDidChange")}this.invokeLater(function(){if(!SC.none(d)){this.set("horizontalScrollOffset",d)}})},updateColumnInfo:function(){var b=this.get("childTableViews")||[];b.forEach(function(c){c.updateColumnInfo()})},updateRowData:function(){this.refresh();this.refreshDividers()},updateRowCount:function(c){var b=this.get("childTableViews")||[];b.forEach(function(d){d.updateRowCount(c)})},updateSelectedRows:function(){var b=this.get("childTableViews")||[];b.forEach(function(c){c.updateSelectedRows()})},scrollSelectionToView:function(c){var b=this.get("childTableViews")||[];b.forEach(function(d){d.scrollSelectionToView(c)})},scrollToCaseByID:function(c,b){if(SC.none(c)){return}DG.assert(c.constructor===DG.CollectionClient,"Correct type");var d=this.findViewForCollection(c);if(d){d.scrollToCase(b)}},findViewForCollection:function(b){var d=b.get("id");var c=this.get("childTableViews")||[];return c.find(function(f){var e=f.getPath("gridAdapter.collection");return e.get("id")===d})},isFrameVisible:function(b){var c=this.get("frame");return((c.x<=b.x)&&(c.y<=b.y)&&(c.x+c.width>=b.x+b.width)&&(c.y+c.height>=b.y+b.height))},scrollHorizontallyToMakeVisible:function(d){var e=this.get("frame");var c=e.x-d.x;var b=d.x+d.width-(e.x+e.width);if(c>=b){this.scrollBy(c+2,0)}else{this.scrollBy(b+2,0)}},scrollDOMElementHorizontallyToView:function(f){var e=this.layer();var h=0,g=0,d=f.offsetWidth,b=f.offsetHeight,i;var c=f;while(c!==e){h+=c.offsetLeft;g+=c.offsetTop;c=c.parentElement}i={x:h,y:g,width:d,height:b};if(!this.isFrameVisible(i)){this.scrollHorizontallyToMakeVisible(i)}else{this.scrollBy(1,0)}}}}()));DG.InertSplitDividerView=SC.View.extend(SC.SplitChild,{classNames:["sc-split-divider-view"],isSplitDivider:YES,autoResizeStyle:"sc-fixed-size",movesSibling:SC.MOVES_CHILD,size:SC.propertyFromRenderDelegate("dividerSize",1),renderDelegateName:"inertSplitDividerRenderDelegate"});SC.BaseTheme.inertSplitDividerRenderDelegate=SC.RenderDelegate.create({className:"dg-split-divider",dividerSize:1,splitPositionOffset:-5,splitSizeOffset:5,render:function(b,a){this.addSizeClassName(b,a);a.push("<div class='line'></div>")},update:function(b,a){this.updateSizeClassName(b,a)}});DG.TableView=DG.HierTableView;sc_require("views/inspector/picker_title_view");sc_require("views/inspector/picker_control_view");DG.InsertCasesDialog=SC.PalettePane.extend((function(){var d=20;var e=d-2;var c=26;var b=80;var a=10;var f=5;return{buttonIconClass:"moonicon-icon-styles",classNames:"dg-insert-cases-dialog".w(),layout:{width:250,height:100,centerX:0,centerY:0},isModal:true,caseTableView:null,contentView:SC.View.extend(SC.FlowedLayout,{layoutDirection:SC.LAYOUT_VERTICAL,isResizable:false,isClosable:false,defaultFlowSpacing:{left:a,right:a,bottom:f},canWrap:false,align:SC.ALIGN_TOP,layout:{right:5},childViews:["title","countCtl","beforeAfterCtl","applyOrCancelCtl"],title:DG.PickerTitleView.extend({layout:{height:c},flowSpacing:{left:0,right:0,bottom:f},title:"DG.CaseTable.insertCasesDialog.title",localize:true}),countCtl:DG.PickerControlView.design({layout:{height:d},label:"DG.CaseTable.insertCasesDialog.numCasesPrompt",localize:true,controlView:SC.TextFieldView.extend({layout:{centerY:0,width:b,height:e},backgroundColor:"white",didAppendToDocument:function(){this.becomeFirstResponder()}})}),beforeAfterCtl:DG.PickerControlView.design({layout:{height:d},label:"DG.CaseTable.insertCasesDialog.beforeAfter.prompt",localize:true,controlView:SC.RadioView.design({layout:{centerY:0,width:140,height:e},items:[{title:"DG.CaseTable.insertCasesDialog.beforeAfter.before".loc(),value:"before",enabled:YES},{title:"DG.CaseTable.insertCasesDialog.beforeAfter.after".loc(),value:"after",enabled:YES}],value:"after",itemTitleKey:"title",itemValueKey:"value",itemIsEnabledKey:"enabled",isEnabled:YES,layoutDirection:SC.LAYOUT_HORIZONTAL})}),applyOrCancelCtl:SC.View.design(SC.FlowedLayout,{layoutDirection:SC.LAYOUT_VERTICAL,defaultFlowSpacing:5,align:SC.ALIGN_CENTER,layout:{width:b,height:24},childViews:"cancel apply".w(),cancel:SC.ButtonView.design({layout:{width:90},titleMinWidth:0,title:"DG.AttrFormView.cancelBtnTitle",target:null,action:"close",toolTip:"DG.AttrFormView.cancelBtnTooltip",localize:true,isCancel:true}),apply:SC.ButtonView.design({layout:{width:90},titleMinWidth:0,title:"DG.CaseTable.insertCasesDialog.applyBtnTitle",target:null,action:"insertCases",toolTip:"DG.CaseTable.insertCasesDialog.applyBtnTooltip",localize:true,isDefault:true})})}),insertCases:function(){var g=this.get("caseTableView"),h=Number(this.getPath("contentView.countCtl.controlView.value")),i=this.getPath("contentView.beforeAfterCtl.controlView.value");if(!g||!h||!(h>0)){return}g.doInsertCases(h,i==="after");this.close()},close:function(){DG.log("Closing Insert Cases Dialog");this.remove();this.destroy()},init:function(){arguments.callee.base.apply(this,arguments);var g=this.get("initialCaseCount")||1;this.setPath("contentView.countCtl.controlView.value",g);this.setPath("contentView.applyOrCancelCtl.cancel.target",this);this.setPath("contentView.applyOrCancelCtl.apply.target",this)}}}()));DG.DataInteractiveModel=SC.Object.extend({name:null,title:null,version:null,dimensions:null,preventBringToFront:false,preventDataContextReorg:false,preventTopLevelReorg:false,preventAttributeDeletion:false,allowEmptyAttributeDeletion:false,externalUndoAvailable:false,standaloneUndoModeAvalable:false,subscribeToDocuments:false,savedState:null,init:function(){arguments.callee.base.apply(this,arguments)}});function serializeItem(d,f){if(!f){return}var c={};var a={};var e=d.getPath("baseCollection.id");var b=d.get("attrs");b.forEach(function(g){var h=f.getValue(g.id,e);a[g.name]=h!=null?h:""});c.values=a;c.id=f.id;return c}DG.DataInteractivePhoneHandler=SC.Object.extend({controller:null,modelProps:["version","dimensions","preventBringToFront","preventDataContextReorg","preventTopLevelReorg","preventAttributeDeletion","allowEmptyAttributeDeletion","respectEditableItemAttribute","subscribeToDocuments"],view:function(){return this.getPath("controller.view")}.property(),id:function(){return this.getPath("controller.model.id")}.property(),rpcEndpoint:null,connected:false,sendMessage:function(a,b){this.rpcEndpoint.call(a,b)},handlerMap:null,init:function(){arguments.callee.base.apply(this,arguments);this.handlerMap={attribute:this.handleAttribute,attributeLocation:this.handleAttributeLocation,attributeList:this.handleAttributeList,"case":this.handleCase,allCases:this.handleAllCases,caseByIndex:this.handleCaseByIndexOrID,caseByID:this.handleCaseByIndexOrID,caseCount:this.handleCaseCount,caseSearch:this.handleCaseSearch,caseFormulaSearch:this.handleCaseFormulaSearch,collection:this.handleCollection,collectionList:this.handleCollectionList,component:this.handleComponent,componentList:this.handleComponentList,dataContext:this.handleDataContext,dataContextFromURL:this.handleDataContextFromURL,dataContextList:this.handleDataContextList,document:this.handleDocument,global:this.handleGlobal,globalList:this.handleGlobalList,configuration:this.handleConfiguration,configurationList:this.handleConfigurationList,item:this.handleItems,itemByID:this.handleItemByID,itemByCaseID:this.handleItemByCaseID,itemCount:this.handleItemCount,itemSearch:this.handleItemSearch,interactiveFrame:this.handleInteractiveFrame,logMessage:this.handleLogMessage,logMessageMonitor:this.handleLogMessageMonitor,selectionList:this.handleSelectionList,undoChangeNotice:this.handleUndoChangeNotice,formulaEngine:this.handleFormulaEngine}},destroy:function(){if(this.rpcEndpoint){this.rpcEndpoint.disconnect()}var a=this;var b=DG.currDocumentController().dataInteractiveLogMonitor;b.set("logMonitors",b.get("logMonitors").filter(function(c){return c.iPhoneHandler!==a}));return arguments.callee.base.apply(this,arguments)},requestDataInteractiveState:function(a){this.sendMessage({action:"get",resource:"interactiveState"},a)},parseResourceSelector:function(c){var e=/(([\w]+)(?:\[\s*([^\]]+)\s*])?)/g;var b=/^([\w]+)(?:\[\s*([^\]]+)\s*])?$/;var a={};var d=c.match(e);a.type="";d.forEach(function(f){var i,h;var g=b.exec(f);i=g[1];h=g[2];a[i]=h||"";a.type=i});return a},resolveResources:function(a,e){function i(l,m){var k=DG.currDocumentController();var n;if(SC.empty(l)){return}if(l==="#default"){n=m}else{n=k.getContextByName(a.dataContext)||(!isNaN(a.dataContext)&&k.getContextByID(a.dataContext))||null}return n}var j={interactiveFrame:this.get("controller")};var c;var g;var h,d;var f;if(["interactiveFrame","logMessage","logMessageMonitor","dataContextList","undoChangeNotice","undoableActionPerformed","component","componentList","document","global","globalList","configuration","configurationList","formulaEngine"].indexOf(a.type)<0){if(!(a.dataContext)){if(e!=="create"||(a.type!=="dataContext"&&a.type!=="dataContextFromURL")){a.dataContext="#default"}j.isDefaultDataContext=true}j.dataContext=i(a.dataContext,this.getPath("controller.context"))}c=j.dataContext;if(a.component){j.component=DG.currDocumentController().getComponentByName(a.component)||(!isNaN(a.component)&&DG.currDocumentController().getComponentByID(a.component))}if(a.configuration){j.configuration={name:a.configuration}}if(a.global){j.global=DG.globalsController.getGlobalValueByName(a.global)||DG.globalsController.getGlobalValueByID(a.global)}if(a.dataContextList!=null){j.dataContextList=DG.currDocumentController().get("contexts").map(function(k){return{name:k.get("name"),guid:k.get("id"),title:k.get("title")}})}if(a.collection){j.collection=c&&(c.getCollectionByName(a.collection)||(!isNaN(a.collection)&&c.getCollectionByID(a.collection)))}g=j.collection;if(a.attribute||a.attributeLocation){d=a.attribute?"attribute":"attributeLocation";h=a[d];j[d]=((c&&(c.getAttributeByName(h)||c.getAttributeByName(c.canonicalizeName(h))))||(!isNaN(h)&&g&&g.getAttributeByID(h)))}if(a.caseByID){j.caseByID=c.getCaseByID(a.caseByID)}if(a.caseByIndex){j.caseByIndex=g&&g.getCaseAt(Number(a.caseByIndex))}if(a.caseSearch){j.caseSearch=g&&g.searchCases(a.caseSearch)}if(a.caseFormulaSearch){j.caseFormulaSearch=g&&g.searchCasesByFormula(a.caseFormulaSearch)}if(a.item){f=j.dataContext&&j.dataContext.get("dataSet");j.item=f&&serializeItem(f,f.getDataItem(Number(a.item)))}if(a.itemByID){f=j.dataContext&&j.dataContext.get("dataSet");j.itemByID=f&&serializeItem(f,f.getDataItemByID(a.itemByID))}if(a.itemCount!=null){j.itemCount=j.dataContext&&j.dataContext.get("itemCount")}if(a.itemSearch){f=j.dataContext&&j.dataContext.get("dataSet");j.itemSearch=f&&f.getItemsBySearch(a.itemSearch)}if(a.itemByCaseID){var b=j.dataContext&&j.dataContext.getCaseByID(a.itemByCaseID);f=j.dataContext&&j.dataContext.get("dataSet");j.itemByCaseID=f&&b&&serializeItem(f,b.get("item"))}DG.ObjectMap.forEach(a,function(k,l){if(SC.none(j[k])&&(k!=="type")&&(k!==a.type)){throw (new Error("Unable to resolve %@: %@".loc(k,l)))}});return j},validateValues:function(b,a){if(SC.none(a)){return}if(a.type==="graph"){["xAttributeName","yAttributeName","y2AttributeName","legendAttributeName"].forEach(function(c){if(!SC.none(b)&&!SC.none(a[c])){a[c]=b.canonicalizeName(a[c]+" ")}})}return a},filterResultValues:function(d){var b=10;function a(e){if(e.guid!=null){e.id=e.guid}return e}function c(g,h){var f,e;if((h<0)||(!g)||(typeof g==="string")||(typeof g==="number")||(typeof g==="boolean")){return}if(Array.isArray(g)){g.forEach(function(i){c(i,h-1)})}else{if(typeof g==="object"){for(f in g){if(g.hasOwnProperty(f)){e=g[f];c(e,h-1)}}a(g)}}}c(d,b)},handleOneCommand:function(h){var j={success:false};try{var b=h.resource&&this.parseResourceSelector(h.resource);var a=this.resolveResources(b,h.action);var c=h.action;var e=b&&b.type;var g=this.validateValues(a.dataContext,h.values);var f=h.meta;var i=e&&this.handlerMap[e];if(i){if(i[c]){try{j=i[c].call(this,a,g,f)||{success:false};if(j.values){this.filterResultValues(j.values)}}catch(d){DG.logWarn(d);j.values={error:d.toString()}}}else{j.values={error:"Unsupported action: %@/%@".loc(c,e)}}}else{DG.logWarn("Unknown message type: "+e);j.values={error:"Unknown message type: "+e}}}catch(d){DG.logWarn(d);j.values={error:d.toString()}}return j},doCommand:function(d,c){this.setIfChanged("connected",true);DG.log("Handle Request: "+JSON.stringify(d));var a={success:false};SC.run(function(){if(!SC.none(d)){if(Array.isArray(d)){a=d.map(function(e){return this.handleOneCommand(e)}.bind(this))}else{a=this.handleOneCommand(d)}}}.bind(this));try{DG.log("Returning response: "+JSON.stringify(a));c(a)}catch(b){DG.logWarn(b);c({success:false,values:{error:"bad reply: "+b.toString()}})}},handleInteractiveFrame:{update:function(g,a){var b=g.interactiveFrame.getPath("model.content");var e=DG.currDocumentController().getComponentByID(this.get("id"));var d=this.get("view");var h=a.title||a.name;var c=g.interactiveFrame.getPath("model.userSetTitle");DG.assert(b,"DataInteractiveModel  exists");DG.assert(b.constructor===DG.DataInteractiveModel,"model content is DataInteractiveModel");if(a){if(!SC.none(h)&&!c){b.set("title",h)}if(a.cannotClose!=null){e.set("cannotClose",a.cannotClose)}if(a.isResizable!=null){e.set("isResizable",a.isResizable)}var f=this.get("modelProps");f.forEach(function(i){if(a[i]!=null){b.set(i,a[i])}})}if(DG.STANDALONE_MODE&&h&&DG.isStandaloneComponent(h,e.get("type"))){DG.log("isStandalone component: "+h);d.makeStandalone()}return{success:true}},get:function(d){var a=d.interactiveFrame.getPath("model.content");var c=d.interactiveFrame.getPath("model.componentStorage");DG.assert(a,"DataInteractiveModel  exists");DG.assert(a.constructor===DG.DataInteractiveModel,"model content is DataInteractiveModel");var e={};e.id=this.get("id");e.title=a.get("title");var b=this.get("modelProps");b.forEach(function(f){e[f]=a.get(f)});e.externalUndoAvailable=!DG.STANDALONE_MODE;e.standaloneUndoModeAvailable=!!DG.STANDALONE_MODE;e.run_remote_endpoint=DG.run_remote_endpoint||"unknown";if(c){DG.log("Sending data interactive, %@, state: %@".loc(e.title,JSON.stringify(c.savedGameState)));e.savedState=c.savedGameState}return{success:true,values:e}},notify:function(c,b){function e(g){var j={"image/png":"png","image/gif":"gif"};var i=/^data:([^,]*),(.*$)/;var l=i.exec(g);var h,k,m,n;if(l){h=l[1];k=l[2];m=Object.keys(j).find(function(o){return h.startsWith(o)});if(m){n=j[m]}}return{mediaType:h,content:k,mimeType:m,extension:n}}function d(h,g){var j=60000;var i=false;if(h==="openGuideConfiguration"){DG.currDocumentController().configureGuide()}else{if(h==="indicateBusy"){i=(g.cursorMode&&g.cursorMode!=="false");DG.splash.showSplash(i,i?j:undefined)}else{if(h==="indicateIdle"){DG.splash.hideSplash()}}}return{success:true}}var a={success:true};var f;if(b.dirty){DG.dirtyCurrentDocument(this.controller,true)}if(b.image){f=e(b.image);if(f){DG.exportFile(f.content,f.extension,f.mimeType)}else{a={success:false,values:{error:"Failed to parse image data uri: "+b.image.slice(0,20)}}}}if(b.request){a=d(b.request,b)}return a},"delete":function(){DG.closeComponent(this.get("id"));return{success:true}}},handleDataContext:{create:function(f,a){var c=DG.currDocumentController().getContextByName(a.name),b=true,e;if(c){e=c}else{var d=DG.copy(a),g=DG.clone(a);delete d.collections;e=DG.currDocumentController().createNewDataContext(d);if(f.isDefaultDataContext){this.setPath("controller.context",e)}if(g.collections){g.collections.forEach(function(i){var h,k,j=false;if(i.attrs){i.attrs.forEach(function(l){l.clientName=l.name;l.name=e.canonicalizeName(l.name+" ")})}d=DG.clone(i);if(d.parent){k=e.getCollectionByName(d.parent);if(k){d.parent=k.collection}else{DG.log('Attempt to create collection "%@": Unknown parent: "%@"'.loc(d.name,d.parent));j=true}}if(!j){h=e.createCollection(d);i.id=h&&h.get("id");if(h&&i.attrs){i.attrs.forEach(function(m){var l=h.getAttributeByName(m.name);m.id=l&&l.get("id")})}}b=b&&!SC.none(h)})}}return{success:b,values:{name:e.get("name"),id:e.get("id"),title:e.get("title")}}},update:function(b,a){return DG.appController.documentArchiver.updateDataContext(b,a)},get:function(d,a){var c=d.dataContext;var b;if(c){b=c.get("model").toArchive(true,true)}return{success:!SC.none(b),values:b}},"delete":function(c,a){var b=c.dataContext;var d=DG.currDocumentController();if(b){d.destroyDataContext(b.get("id"));return{success:true}}else{return{success:false,values:{error:"Could not find dataContext"}}}},notify:function(e,i){var a=e.dataContext;var c=i&&i.request;var d=i&&i.caseIDs;var g=true;var f;var b;var h;if(c==="setAside"){if(!d){g=false;f="Bad request"}else{h=d.map(function(j){var k=a.getCaseByID(j);if(!k){DG.log("Attempt to set aside missing case: "+j)}return k}).filter(function(j){return !!j});b=a.applyChange({operation:"deleteCases",setAside:true,cases:h,requester:this.get("id")});g=b.success;if(!b.success){f="Request failed"}}}else{if(c==="restoreSetasides"){a.restoreSetAsideCases()}else{g=false;f="unknown request: "+c}}return{success:g,values:{error:f}}}},handleDataContextFromURL:{create:function(d,a){var c;var b=true;if(a.URL){c=a.URL;delete a.URL;DG.appController.importTextFromUrl(c,false)}return{success:b}}},handleDataContextList:{get:function(a){var b=(a.dataContextList!=null);return b?{success:true,values:a.dataContextList}:{success:false}}},handleCollection:{get:function(c){if(!c.collection){return{success:false,values:{error:"Collection not found"}}}var b=c.collection.get("collection");var a=b.toArchive(true);return{success:true,values:a}},create:function(b,a){return DG.appController.documentArchiver.createCollection(b,a,this.get("id"))},update:function(d,a){if(!d.collection){return{success:false,values:{error:"Collection not found"}}}var c=d.dataContext;var f={operation:"updateCollection",collection:d.collection,properties:a,requester:this.get("id")};var b=c.applyChange(f);var e=(b&&b.success);return{success:e}},"delete":function(a){var b=DG.appController.documentArchiver.deleteCollection(a,this.get("id"));if(b&&b.collections&&b.collections.length){return{success:true,values:{collections:[b.collections[0].get("id")]}}}else{return{success:false,values:{error:"Delete failed"}}}}},handleCollectionList:{get:function(c){var b=c.dataContext;var a=b.get("collections").map(function(d){return{name:d.get("name"),guid:d.get("id"),title:d.get("title")}});return{success:true,values:a}}},handleAttribute:(function(){return{get:function(b){var c=b.attribute;var a;if(!c){return{success:false,values:{error:"Attribute not found"}}}a=c.toArchive();return{success:true,values:a}},create:function(c,b,a){if(SC.isArray(b)&&b.length===0){return{success:true}}return DG.appController.documentArchiver.createAttribute(c,b,a,this.get("id"))},update:function(c,b,a){return DG.appController.documentArchiver.updateAttribute(c,b,a)},"delete":function(c,i,j){var b=c.dataContext;var d=c.attribute;var h=d&&d.get("id");var e=c.collection;var a,f;if((e.get("attrsController").get("length")===1)&&(b.get("collections").length!==1)&&(e.getAttributeByID(h))){a=b.applyChange({operation:"deleteCollection",collection:e})}else{f={operation:"deleteAttributes",collection:e,attrs:[{id:h,attribute:d}],requester:this.get("id")};if(j&&j.dirtyDocument===false){f.dirtyDocument=false}a=b.applyChange(f)}b.set("flexibleGroupingChangeFlag",true);var g=!!(a&&a.success);return{success:g}}}}()),handleAttributeLocation:{update:function(c,b,a){return DG.appController.documentArchiver.updateAttributeLocation(c,b,a)}},handleAttributeList:{get:function(b){var c=b.collection;var a=[];if(!c){return{success:false,values:{error:"Collection not found"}}}c.forEachAttribute(function(d){var e={id:d.get("id"),name:d.get("name"),title:d.get("title")};a.push(e)});return{success:true,values:a}}},handleAttributeSort:{update:function(b,a){return DG.appController.documentArchiver.updateDataContext(b,a)}},handleCase:{create:function(b,a){return DG.appController.documentArchiver.createCases(b,a,this.get("id"))},update:function(f,b){var e=f.dataContext;var h=f.collection;var a={success:false};var g=[];var d=[];b.forEach(function(k){var i=k.id;var j=e.getCaseByID(i);if(j){g.push(j);d.push(k.values)}});var c;if(h&&g.length){c=e.applyChange({operation:"updateCases",collection:h,cases:g,values:d,requester:this.get("id")});a=c}return a}},handleAllCases:{get:function(c){var b=c.dataContext;var d=c.collection;if(!b||!d){return{success:false}}var a=function(f){var e={};d.forEachAttribute(function(g){e[g.name]=f.getValue(g.id)});return{"case":{id:f.id,parent:(f.parent&&f.parent.id),children:f.children.map(function(g){return g.id}),values:e},caseIndex:d.getCaseIndexByID(f.get("id"))}}.bind(this);return{success:true,values:{collection:{name:d.get("name"),id:d.get("id")},cases:d.get("casesController").map(a)}}},"delete":function(c){var b=c.dataContext;var e=false;var a,d;if(b){d=b.get("allCases");a=b.applyChange({operation:"deleteCases",cases:d,values:[],requester:this.get("id")});e=(a&&a.success)}return{success:e}}},makeSerializableCase:function(b,c){var a={};b.forEachAttribute(function(d){a[d.name]=c.getValue(d.id)});return{id:c.id,parent:(c.parent&&c.parent.id),collection:{name:b.get("name"),id:b.get("id")},values:a}},handleCaseByIndexOrID:{get:function(e){function b(h,g){var i=h.get("collection");var j=i.get("id");return g.getCollectionByID(j)}var a=e.dataContext;var d=e.caseByIndex||e.caseByID;var f,c;if(d){f=e.collection||b(d,a);c={"case":this.makeSerializableCase(f,d),caseIndex:f.getCaseIndexByID(d.get("id"))};c["case"].children=d.children.map(function(g){return g.id})}return{success:!SC.none(c),values:c}},notify:function(d,a){if(!d.collection){return{success:false,values:{error:"Collection not found"}}}if(!(d.caseByID||d.caseByIndex)){return{success:false,values:{error:"Case not found"}}}var c=d.dataContext;var g=d.collection;var e=d.caseByIndex||d.caseByID;var f=false;var b;if(g&&e&&a&&a.caseOrder){b=c.applyChange({operation:"moveCases",collection:g,cases:[e],caseOrder:a.caseOrder,requester:this.get("id")});f=(b&&b.success)}return{success:f}},update:function(d,a){if(!d.collection){return{success:false,values:{error:"Collection not found"}}}if(!(d.caseByID||d.caseByIndex)){return{success:false,values:{error:"Case not found"}}}var c=d.dataContext;var g=d.collection;var e=d.caseByIndex||d.caseByID;var f=false;var b;if(g&&e&&a&&a.values){b=c.applyChange({operation:"updateCases",collection:g,cases:[e],values:[a.values],requester:this.get("id")});f=(b&&b.success)}return{success:f}},"delete":function(c){var b=c.dataContext;var f=c.collection;var d=c.caseByIndex||c.caseByID;var e=false;var a;if(f&&d){a=b.applyChange({operation:"deleteCases",collection:f,cases:[d],values:[],requester:this.get("id")});e=(a&&a.success)}return{success:e}}},handleCaseCount:{get:function(a){if(!a.collection){return{success:false,values:{error:"Collection not found"}}}var b=a.collection.casesController.length();return{success:true,values:b}}},handleCaseSearch:{get:function(a){if(!a.collection){return{success:false,values:{error:"Collection not found"}}}var c=(a.caseSearch!=null),b=[];if(c){b=a.caseSearch.map(function(d){return this.makeSerializableCase(a.collection,d)}.bind(this))}return{success:c,values:b}}},handleCaseFormulaSearch:{get:function(a){if(!a.collection){return{success:false,values:{error:"Collection not found"}}}var c=(a.caseFormulaSearch!=null),b=[];if(c){b=a.caseFormulaSearch.map(function(d){return this.makeSerializableCase(a.collection,d)}.bind(this))}return{success:c,values:b}}},handleItems:{get:function(a){var c=(a.item!=null),b;if(c){b=a.item}return{success:c,values:b}},create:function(d,b){var c=d.dataContext;var a;if(c){a=c.applyChange({operation:"createItems",items:b,requester:this.get("id")});return a}return{success:false}},update:function(d,a){var f=d.item;var b=d.dataContext;var e,c,g;if(f!=null){g=b.applyChange({operation:"updateItems",items:{id:f.id,values:a},requester:this.get("id")});if(g){e=g.createdCases?g.createdCases.map(function(h){return h.id}):[];c=g.deletedCases?g.deletedCases.map(function(h){return h.id}):[];return{success:true,values:{createdCases:e,deletedCases:c}}}}else{return b.applyChange({operation:"updateItems",items:a,requester:this.get("id")})}}},handleItemSearch:{get:function(d){var a=d.dataContext;var c=a&&a.get("dataSet");var e=(d.itemSearch!=null),b=[];if(e){b=d.itemSearch&&d.itemSearch.map(function(f){return serializeItem(c,f)})}return{success:e,values:b}},"delete":function(d){var a=d.itemSearch;var b=d.dataContext;var c;if(b&&(a!=null)){b.applyChange({operation:"deleteItems",items:a,requester:this.get("id")});c=b.deleteItems(a);if(c){return{success:true,values:c&&c.map(function(e){return e.id})}}}return{success:false}},notify:function(d,a){var b=d.itemSearch;var c=d.dataContext;if(c&&(b!=null)&&a.itemOrder){c.applyChange({operation:"moveItems",items:b,itemOrder:a.itemOrder,requester:this.get("id")});return{success:true}}return{success:false}}},handleItemByID:{get:function(a){var c=(a.itemByID!=null),b;if(c){b=a.itemByID}return{success:c,values:b}},update:function(d,a){var f=d.itemByID;var b=d.dataContext;var e,c,g;if(f!=null){g=b.applyChange({operation:"updateItems",items:{id:f.id,values:a},requester:this.get("id")});if(g){e=g.createdCases?g.createdCases.map(function(h){return h.id}):[];c=g.deletedCases?g.deletedCases.map(function(h){return h.id}):[];return{success:true,values:{createdCases:e,deletedCases:c}}}}else{return{success:false,values:{error:"item not found"}}}},"delete":function(f){var d=f.dataContext;var g=f.itemByID;var c=d&&d.get("dataSet");var a=c&&c.getDataItemByID(g.id);var b=[a];var h=(a!=null);var e;if(h){d.applyChange({operation:"deleteItems",items:b,requester:this.get("id")});e=d.deleteItems(b);if(e){return{success:true,values:e&&e.map(function(i){return i.id})}}}else{return{success:h}}}},handleItemByCaseID:{get:function(b){var c=(b.itemByCaseID!=null),a=[];if(c){a=b.itemByCaseID}return{success:c,values:a}},update:function(d,a){var f=d.itemByCaseID;var b=d.dataContext;var e,c,g;if(f!=null){g=b.applyChange({operation:"updateItems",items:{id:f.id,values:a},requester:this.get("id")});if(g){e=g.createdCases?g.createdCases.map(function(h){return h.id}):[];c=g.deletedCases?g.deletedCases.map(function(h){return h.id}):[];return{success:true,values:{createdCases:e,deletedCases:c}}}}else{return{success:false,values:{error:"item not found"}}}},"delete":function(d){var e=d.itemByCaseID;var a=[e];var b=d.dataContext;var f=(e!=null);var c;if(f){b.applyChange({operation:"deleteItems",items:a,requester:this.get("id")});c=b.deleteItems(a);if(c){return{success:true,values:c&&c.map(function(g){return g.id})}}}else{return{success:f}}}},handleItemCount:{get:function(a){var b=(a.itemCount!=null);return b?{success:true,values:a.itemCount}:{success:false}}},handleSelectionList:{get:function(c){var b=c.dataContext;var d=c.collection;var a=b&&b.getSelectedCases().filter(function(e){return(!d||d===e.collection)}).map(function(f){var g=f.getPath("collection.id");var e=b.getCollectionByID(g).get("name");return{collectionID:g,collectionName:e,caseID:f.get("id")}});if(!a){return{success:false,values:{error:"Unknown context."}}}return{success:true,values:a}},create:function(b,a){if(!b.dataContext){return{success:false,values:{error:"Unknown context."}}}return this.doSelect(b,a,false)},update:function(b,a){if(!b.dataContext){return{success:false,values:{error:"Unknown context."}}}return this.doSelect(b,a,true)}},doSelect:function(c,a,f){var b=c.dataContext;var e=c.collection;var d;f=f&&a.length!==0;if(e){d=a.map(function(g){return e.getCaseByID(g)}).filter(function(g){return !!g})}else{d=a.map(function(g){return b.getCaseByID(g)}).filter(function(g){return !!g})}return b.applyChange({operation:"selectCases",collection:e,cases:d,select:true,extend:f,requester:this.get("id")})},handleComponent:(function(){var b={"DG.Calculator":"calculator","DG.TableView":"caseTable","DG.CaseCard":"caseCard","DG.GameView":"game","DG.GraphView":"graph","DG.GuideView":"guideView","DG.ImageComponentView":"image","DG.MapView":"map","DG.SliderView":"slider","DG.TextView":"text","DG.WebView":"webView"};var a={calculator:"DG.Calculator",caseTable:"DG.TableView",caseCard:"DG.CaseCard",game:"DG.GameView",graph:"DG.GraphView",guideView:"DG.GuideView",image:"DG.ImageComponentView",map:"DG.MapView",slider:"DG.SliderView",text:"DG.TextView",webView:"DG.WebView"};var d=function(h,i){return{key:h,value:i}};var e={slider:{dimensions:{width:300,height:98}},caseTable:{dimensions:{width:500,height:200}},caseCard:{dimensions:{width:200,height:400}}};var f={calculator:{name:d,title:d,cannotClose:d},caseTable:{name:d,title:d,cannotClose:d,horizontalScrollOffset:d,isIndexHidden:d},caseCard:{name:d,title:d,cannotClose:d},game:{currentGameName:function(h,i){return{key:"name",value:i}},currentGameUrl:function(h,i){return{key:"URL",value:i}},name:function(h,i){return{key:"currentGameName",value:i}},title:d,URL:function(h,i){return{key:"currentGameUrl",value:i}},cannotClose:d,isVisible:d},graph:{name:d,title:d,dataContext:function(i,j){var h;if(j){h=(typeof j==="string")?DG.currDocumentController().getContextByName(j):j.get("name")}return{key:i,value:h}},xAttributeName:d,yAttributeName:d,y2AttributeName:d,legendAttributeName:d,enableNumberToggle:d,numberToggleLastMode:d,cannotClose:d},guideView:{name:d,title:d,cannotClose:d,items:d,currentItemIndex:d,isVisible:d},image:{name:d,title:d,URL:d,cannotClose:d},map:{name:d,title:d,legendAttributeName:d,dataContextName:function(h,i){return{key:"context",value:DG.currDocumentController().getContextByName(i)}},context:function(h,i){return{key:"dataContextName",value:i.get("name")}},cannotClose:d,center:function(h,i){return{key:"newCenter",value:i}},zoom:function(h,i){return{key:"newZoom",value:i}}},slider:{animationDirection:d,animationMode:d,globalValueName:d,lowerBound:d,name:d,title:d,upperBound:d,value:d,cannotClose:d},text:{name:d,text:function(h,i){return{key:"apiText",value:i}},title:d,cannotClose:d},webView:{name:d,title:d,URL:d,cannotClose:d}};function c(k,j,i){var h=f[i];if(!h){return}Object.keys(k).forEach(function(n){var o=h[n];var l;if(typeof o==="function"){l=o(n,k[n]);if(j.set){j.set(l.key,l.value)}else{j[l.key]=l.value}}})}function g(i,j){var h=DG.currDocumentController();var k=i.dataContext&&h.getContextByName(i.dataContext);if(k){DG.ArchiveUtils.addLink(j,"context",k)}}return{create:function(m,s){var q=DG.currDocumentController();var n=s.type;var k=n&&a[n];var i=Object.assign({},e[n]||{},s);var o={componentStorage:{}};var r=true;var p,l,j;if(SC.none(k)){r=false;l="Unknown component type: "+n}if(r){o.document=q;o.type=k;o.allowMoreThanOne=true;o.layout={};if(i.dimensions){o.layout=Object.assign(o.layout,i.dimensions)}if(i.position){if(typeof i.position==="string"){o.position=i.position}else{if(typeof i.position==="object"){o.layout=Object.assign(o.layout,i.position)}}}c(i,o.componentStorage,n);var h;if(i.type==="caseTable"||i.type==="caseCard"){g(i,o.componentStorage);if(i.dataContext){h=DG.currDocumentController().getContextByName(i.dataContext)}}if((i.type==="caseTable")&&h){p=q.addCaseTable(DG.mainPage.get("docView"),null,Object.assign({position:"top",dataContext:h},o));p.invokeLater(function(){p.showAndSelect()})}if((i.type==="caseCard")&&h){p=q.addCaseCard(DG.mainPage.get("docView"),o.layout,h);p.invokeLater(function(){p.showAndSelect()})}else{if((i.type==="slider")&&i.globalValueName){j=DG.globalsController.getGlobalValueByName(i.globalValueName);if(j){DG.ArchiveUtils.addLink(o.componentStorage,"model",j);p=DG.currDocumentController().createComponentAndView(DG.Component.createComponent(o),null,{initiatedViaCommand:true});l=!p&&"Component creation failed"}else{l="Global not found: '%@'".loc(i.globalValueName)}}else{p=DG.currDocumentController().createComponentAndView(DG.Component.createComponent(o),null,{initiatedViaCommand:true});l=!p&&"Component creation failed"}}}if(r&&p){return{success:true,values:{id:p.getPath("model.id"),name:p.getPath("model.name"),title:p.getPath("model.title"),type:n}}}else{return{success:false,values:{error:l||"Unknown error"}}}},notify:function(l,h){if(!l.component||l.component.get("isDestroyed")){return{success:false,values:{error:"Component not found"}}}var k=l.component;var j=DG.currDocumentController().componentControllersMap[k.get("id")];var i=j&&j.get("view");if(!i){return{success:false,values:{error:"Cannot find component view"}}}if(h.request){if(h.request==="select"){DG.InspectorPickerPane.close();i.select()}else{if(h.request==="autoScale"){if(j&&j.rescaleFunction){j.rescaleFunction()}else{if(j&&j.resizeColumns){j.resizeColumns()}else{return{success:false,values:{error:"Component does not support rescale"}}}}}}}return{success:true}},update:function(k,q){if(!k.component||k.component.get("isDestroyed")){return{success:false,values:{error:"Component not found"}}}var o=k.component,j=o&&o.get("type"),i=j&&b[j],m=DG.Component.getContent(o),l,h,p={};if(!o){return{success:false,values:{error:"Cannot find component"}}}if(q.position){l=q.position;o.set("position",l);delete q.position}if(!SC.none(q.cannotClose)){o.set("cannotClose",q.cannotClose);delete q.cannotClose}if(!SC.none(q.isResizable)){o.set("isResizable",q.isResizable);delete q.isResizable}if(q.dimensions){h=q.dimensions;o.setPath("content.dimensions",h);delete q.dimensions}if(q.isVisible!=null){var n=DG.currDocumentController().componentControllersMap[o.get("id")].get("view");n.set("isVisible",q.isVisible);delete q.isVisible}c(q,p,i);m.beginPropertyChanges();Object.keys(p).forEach(function(r){m.set(r,p[r])});m.endPropertyChanges();return{success:true}},get:function(l){function k(o){function n(u,t){var v=DG.ArchiveUtils.getLinkID(u,t);var s=DG.store.find(v);return s&&s.get("name")}var r={};var p=o.componentStorage;var q=o.layout;r.type=b[o.type];if(q){if(q.height||q.width){r.dimensions={height:q.height||0,width:q.width||0}}if((q.left!=null)||(q.x!=null)){r.position={left:q.left||q.x||0,top:q.top||q.y||0}}}if(p){c(p,r,r.type)}switch(r.type){case"caseTable":r.dataContext=n(p,"context");break;case"graph":r.xAttributeName=n(p,"xAttr");r.yAttributeName=n(p,"yAttr");r.y2AttributeName=n(p,"y2Attr");r.xLowerBound=p.xLowerBound;r.xUpperBound=p.xUpperBound;r.yLowerBound=p.yLowerBound;r.yUpperBound=p.yUpperBound;r.y2LowerBound=p.y2LowerBound;r.y2UpperBound=p.y2UpperBound;case"map":r.dataContext=n(p,"context");r.legendAttributeName=n(p,"legendAttr");r.center=n("center");r.zoom=n("zoom");break;default:}return r}var i=l.component;var h=DG.currDocumentController().getComponentControllerForModel(i);h&&h.willSaveComponent();var j=i&&i.toArchive();var m=j&&k(j);if(m){return{success:true,values:m}}else{return{success:false,values:{error:"Could not serialize component."}}}},"delete":function(j){var i=j.component,h=i&&i.get("id");if(h){DG.closeComponent(h)}return{success:true}},toDIType:function(h){return b[h]}}}()),handleComponentList:{get:function(c){var b=DG.currDocumentController();var a=[];DG.ObjectMap.forEach(b.get("componentControllersMap"),function(f,d){var e=d.get("model");a.push({id:e.get("id"),name:e.get("name"),title:e.get("title"),type:this.handleComponent.toDIType(e.get("type"))})}.bind(this));return{success:true,values:a}}},handleDocument:{update:function(b,a){return{success:DG.appController.documentArchiver.updateDocument(a)}},get:function(){if(DG.currDocumentController().notificationManager){DG.currDocumentController().notificationManager.sendDocumentToSubscribers()}}},handleLogMessage:{notify:function(b,a){DG.Debug.logUserWithTopic.apply(DG.Debug,[a.topic,a.formatStr].concat(a.replaceArgs));DG.dirtyCurrentDocument(this.controller,true);return{success:true}}},handleLogMessageMonitor:{register:function(b,a){if(!a.topic&&!a.topicPrefix&&!a.formatStr&&!a.formatPrefix&&!a.message){return{success:false,values:{error:"At least one of the following values must be passed: topic, topicPrefix, formatStr, formatPrefix or message."}}}var d=DG.currDocumentController().dataInteractiveLogMonitor;var c=SC.Object.create({iPhoneHandler:this,values:{id:d.get("nextLogMonitorId"),clientId:a.clientId,topic:a.topic,topicPrefix:a.topicPrefix,formatStr:a.formatStr,formatPrefix:a.formatPrefix,message:a.message}});d.get("logMonitors").pushObject(c);d.set("nextLogMonitorId",d.get("nextLogMonitorId")+1);return{success:true,logMonitor:c.values}},unregister:function(b,a){if(!a.id&&!a.clientId){return{success:false,values:{error:"Missing monitor id or clientId in values"}}}var c=DG.currDocumentController().dataInteractiveLogMonitor;c.set("logMonitors",c.get("logMonitors").filter(function(d){var e=d.values;if(a.id&&(a.id!==e.id)){return true}return !!(a.clientId&&(a.clientId!==e.clientId))}));return{success:true}}},handleUndoChangeNotice:{notify:function(d,a){var b=this;function f(h){if(h&&h.success===false){DG.UndoHistory.showErrorAlert(true,{message:"Data Interactive error"})}}function c(i,h){DG.UndoHistory.execute(DG.Command.create({name:"interactive.undoableAction",undoString:"DG.Undo.interactiveUndoableAction",redoString:"DG.Redo.interactiveUndoableAction",log:"Interactive action occurred: "+i,execute:function(){},undo:function(){var j={action:"notify",resource:"undoChangeNotice",values:{operation:"undoAction"}};b.sendMessage(j,f)},redo:function(){var j={action:"notify",resource:"undoChangeNotice",values:{operation:"redoAction"}};b.sendMessage(j,f)}}));return true}var g=a&&a.logMessage?a.logMessage:"Unknown action";var e=true;switch(a.operation){case"undoableActionPerformed":e=c(g,this.get("rpcEndpoint"));break;case"undoButtonPress":DG.UndoHistory.undo();break;case"redoButtonPress":DG.UndoHistory.redo();break}return{success:e,values:{canUndo:DG.UndoHistory.get("canUndo"),canRedo:DG.UndoHistory.get("canRedo")}}}},handleGlobal:{get:function(a){var b=a.global;if(b){return{success:true,values:{name:b.name,value:b.value,id:b.id}}}else{return{success:false,values:{error:"Not found"}}}},update:function(b,a){var c=b.global;var d=a.value;if(c&&!SC.none(d)){c.set("value",d);return{success:true}}else{return{success:false,values:{error:"missing global or value"}}}},create:function(c,b){var d=DG.globalsController.createGlobalValue(b);var a=SC.none(d)?{error:"error creating global value"}:{name:d.name,value:d.value,id:d.id};return{success:!SC.none(d),values:a}}},handleGlobalList:{get:function(b){var c=DG.globalsController.getGlobalValueNames();var a=c.map(function(d){var e=DG.globalsController.getGlobalValueByName(d);if(e){return{name:e.name,value:e.value,id:e.id}}return null}).filter(function(d){return d});return{success:true,values:a}}},handleConfiguration:{get:function(a){var b=a.configuration;if(DG.get("publicConfigurationProperties").includes(b.name)){return{success:true,values:{name:b.name,value:DG.get(b.name)}}}else{return{success:false,values:{error:"Not found"}}}},update:function(b,a){var d=b.configuration;var c=a.value;if(DG.get("publicConfigurationProperties").includes(d.name)&&!SC.none(c)){DG.set(d.name,c);return{success:true}}else{return{success:false,values:{error:"not found or missing value"}}}}},handleConfigurationList:{get:function(c){var b=DG.get("publicConfigurationProperties");var a=b.map(function(d){var e=DG[d]();return{name:d,value:e}});return{success:true,values:a}}},handleFormulaEngine:{get:function(){return{success:true,values:DG.functionRegistry.get("categorizedFunctionInfo")}},notify:function(b,a){var d=a.request;switch(d){case"evalExpression":var e=a.source;try{return{success:true,values:a.records.map(function(f){var g=DG.FormulaContext.create({vars:f});var h=DG.Formula.create({source:e,context:g});return h.evaluate()})}}catch(c){return{success:false,values:{error:c.toString()}}}break;default:return{success:false,values:{error:"Unsupported request type: "+d}}}}}});DG.DataInteractiveUtils={getAttributeProperties:function(a,c){var b=Object.assign({},a&&a.toArchive(),c);if(a&&a.get("id")){b.id=a.get("id")}return b},mapAttributeProperties:function(a,b){return a&&a.map(function(c,e){var d=b&&b[e],g=d&&d.clientName,f=g?{clientName:g}:null;return DG.DataInteractiveUtils.getAttributeProperties(c,f)})}};DG.NotificationManager=SC.Object.extend((function(){function a(c){var d=c.get("dataInteractives");var b=d.filter(function(e){return e.get("isUsingDataInteractiveChannel")}).map(function(e){return e.get("activeChannel")});if(DG.embeddedModePhoneHandlers){DG.embeddedModePhoneHandlers.forEach(function(e){if(e.get("isPhoneInUse")){b.push(e)}})}return b}return{mostRecentDataContextChanges:null,init:function(){arguments.callee.base.apply(this,arguments);this.invokeLater(function(){if(!this.isDestroyed){var b=DG.currDocumentController().get("contexts");b.forEach(function(c){this.guaranteeDataContextObserver(c)}.bind(this));DG.currDocumentController().addObserver("contextsLength",this,this.contextCountDidChange)}},200)},destroy:function(){var b=DG.currDocumentController().get("contexts");b.forEach(function(c){this.removeDataContextObserver(c)}.bind(this));DG.currDocumentController().removeObserver("contextsLength",this,this.contextCountDidChange);arguments.callee.base.apply(this,arguments)},sendNotification:function(c,d){var b=a(DG.currDocumentController());b.forEach(function(e){if(e.sendMessage){e.sendMessage(c,d)}})},sendChannelNotification:function(e,c,d){var b=e.get("activeChannel");if(b){if(b.sendMessage){b.sendMessage(c,d)}}else{DG.logWarn("NotificationManager.sendChannelNotification to unknown plugin")}},contextCountDidChange:function(){DG.log("contextCountDidChange");DG.currDocumentController().contexts.forEach(function(b){this.guaranteeDataContextObserver(b)}.bind(this));this.sendNotification({action:"notify",resource:"documentChangeNotice",values:{operation:"dataContextCountChanged"}},function(b){DG.log("Sent documentChangeNotice to Data Interactive");DG.log("Response: "+JSON.stringify(b))})},guaranteeDataContextObserver:function(b){if(!b.hasObserverFor("changeCount",this,this.contextDataDidChange)){b.addObserver("changeCount",this,this.contextDataDidChange)}},removeDataContextObserver:function(b){b.removeObserver("changeCount",this,this.contextDataDidChange)},contextDataDidChange:function(b){var e=b.get("name");var c=b.get("newChanges");var d=a(DG.currDocumentController());d.forEach(function(g){var f=c.filter(function(h){return((h.result&&h.result.success)&&(!h.requester||(h.requester!==g.get("id"))))}.bind(g)).map(function(i){var h={};DG.ObjectMap.forEach(i.result,function(l,j){switch(l){case"success":case"properties":case"attrIDs":case"caseID":case"caseIDs":case"itemID":case"itemIDs":h[l]=j;break;case"collection":h[l]=j.get("id");h.name=i.properties.name;h.attribute=(i.attributes&&i.attributes.length>0)?i.attributes[0].get("name"):null;break;case"attrs":h[l]=j&&j.map(function(k){return DG.DataInteractiveUtils.getAttributeProperties(k)});break;default:DG.log("unhandled result property: "+l)}});if(i.cases){h.cases=[];h.extend=i.extend;(i.cases).forEach(function(k){if(k._isProtoCase){return}var j={};k.collection.attrs.forEach(function(l){j[l.name]=k.getValue(l.id)});h.cases.push({id:k.id,parent:k.parent&&k.parent.id,context:{id:k.collection.context.id,name:k.collection.context.name},collection:{id:k.collection.id,name:k.collection.name,parent:k.collection.parent?{id:k.collection.parent.id,name:k.collection.parent.name}:null},values:j})})}return{operation:i.operation,result:h}});if(!f||f.length===0){return}g.sendMessage({action:"notify",resource:"dataContextChangeNotice["+e+"]",values:f},function(h){DG.log("Sent dataContextChangeNotice to Data Interactive for dataContext: "+e+": "+JSON.stringify(f));DG.log("Response: "+JSON.stringify(h))})});this.set("mostRecentDataContextChanges",c)},notifyLogMessageSubscribers:function(c){var b=DG.currDocumentController().dataInteractiveLogMonitor.get("logMonitors");if(b.length===0){return}var d={};Object.keys(c).forEach(function(e){d[e]=c[e]});d.message=SC.String.fmt(c.formatStr,c.replaceArgs);b.forEach(function(e){var f=e.values;f=SC.merge({topicMatches:f.topic&&(f.topic===c.topic),topicPrefixMatches:f.topicPrefix&&c.topic&&(f.topicPrefix===c.topic.substr(0,f.topicPrefix.length)),formatStrMatches:f.formatStr&&(f.formatStr===c.formatStr),formatPrefixMatches:f.formatPrefix&&c.formatStr&&(f.formatPrefix===c.formatStr.substr(0,f.formatPrefix.length)),messageMatches:f.message&&((f.message===d.message)||(f.message==="*"))},f);if(f.topicMatches||f.topicPrefixMatches||f.formatStrMatches||f.formatPrefixMatches||f.messageMatches){d.logMonitor=f;e.iPhoneHandler.sendMessage({action:"notify",resource:"logMessageNotice",values:d})}}.bind(this))},sendDocumentToSubscribers:function(){var c=a(DG.currDocumentController()),b;b=c.filter(function(d){return d.getPath("controller.contentView.model.subscribeToDocuments")});if(b.length>0){DG.currDocumentController().captureCurrentDocumentState(true).then(function(d){b.forEach(function(e){e.sendMessage({action:"notify",resource:"document",values:{operation:"newDocumentState",state:d}})})})}}}})());sc_require("controllers/component_controller");DG.GameController=DG.ComponentController.extend({confirmCloseDescription:"DG.GameController.confirmCloseDescription",shouldDestroyOnComponentDestroy:true,gameIsReady:true,contextBinding:".model.context",changeCount:0,savedChangeCount:0,hasUnsavedChanges:function(){return this.get("changeCount")>this.get("savedChangeCount")}.property(),updateSavedChangeCount:function(){this.set("savedChangeCount",this.get("changeCount"))},storedProperties:["preventBringToFront","preventDataContextReorg","preventTopLevelReorg","preventAttributeDeletion","allowEmptyAttributeDeletion","respectEditableItemAttribute"],preventBringToFront:function(a,b){var c="model.content.preventBringToFront";if(b!=null){this.setPath(c,b)}return this.getPath(c)}.property(),preventDataContextReorg:function(a,b){var c="model.content.preventDataContextReorg";if(b!=null){this.setPath(c,b)}return this.getPath(c)}.property(),preventTopLevelReorg:function(a,b){var c="model.content.preventTopLevelReorg";if(b!=null){this.setPath(c,b)}return this.getPath(c)}.property(),preventAttributeDeletion:function(a,b){var c="model.content.preventAttributeDeletion";if(b!=null){this.setPath(c,b)}return this.getPath(c)}.property(),allowEmptyAttributeDeletion:function(a,b){var c="model.content.allowEmptyAttributeDeletion";if(b!=null){this.setPath(c,b)}return this.getPath(c)}.property(),respectEditableItemAttribute:function(a,b){var c="model.content.respectEditableItemAttribute";if(b!=null){this.setPath(c,b)}return this.getPath(c)}.property(),init:function(){arguments.callee.base.apply(this,arguments);this._cmdQueue=[];this.gamePhoneHandler=DG.GamePhoneHandler.create({controller:this});this.dataInteractivePhoneHandler=DG.DataInteractivePhoneHandler.create({controller:this});this.gamePhoneHandler.addObserver("connected",this,"connectionDidChange");this.dataInteractivePhoneHandler.addObserver("connected",this,"connectionDidChange")},destroy:function(){this.setPath("model.content",null);this.removeObserver("gamePhoneHandler.connected",this,"connectionDidChange");this.removeObserver("dataInteractivePhoneHandler.connected",this,"connectionDidChange");if(this.gamePhoneHandler){this.gamePhoneHandler.destroy();this.gamePhoneHandler=null}if(this.dataInteractivePhoneHandler){this.dataInteractivePhoneHandler.destroy();this.dataInteractivePhoneHandler=null}if(this.iframePhoneEndpoint){this.iframePhoneEndpoint.disconnect()}arguments.callee.base.apply(this,arguments)},iframePhoneEndpoint:null,gamePhoneHandler:null,dataInteractivePhoneHandler:null,activeChannel:function(){if(this.dataInteractivePhoneHandler.get("connected")){return this.dataInteractivePhoneHandler}else{if(this.gamePhoneHandler.get("connected")){return this.gamePhoneHandler}}}.property(),isUsingDataInteractiveChannel:function(){return this.get("activeChannel")===this.dataInteractivePhoneHandler}.property("activeChannel"),connectionDidChange:function(){this.sendQueuedCommands();this.notifyPropertyChange("activeChannel")},setUpChannels:function(a,b){var c=function(e,d){var f=function(g,h){e.set("isPhoneInUse",true);e.doCommand(g,function(i){DG.doCommandResponseHandler(i,h)})};if(e.rpcEndpoint){e.rpcEndpoint.disconnect()}e.set("isPhoneInUse",false);e.rpcEndpoint=new iframePhone.IframePhoneRpcEndpoint(f.bind(this),d,a,this.extractOrigin(b),this.iframePhoneEndpoint);e.rpcEndpoint.call({message:"codap-present"},function(g){DG.log('Got codap-present reply on channel: "'+d+'": '+JSON.stringify(g))})}.bind(this);this.iframePhoneEndpoint=new iframePhone.ParentEndpoint(a,this.extractOrigin(b),function(){DG.log("connected")});c(this.get("gamePhoneHandler"),"codap-game");c(this.get("dataInteractivePhoneHandler"),"data-interactive")},queueCommand:function(b,a){this._cmdQueue.push({cmd:b,responseHandler:a})},sendQueuedCommands:function(){var b=this.get("activeChannel");if(b){while(this._cmdQueue.length){var a=this._cmdQueue.shift();b.rpcEndpoint.call(a.cmd,a.responseHandler)}}},sendCommand:function(b,a){this.queueCommand(b,a);this.sendQueuedCommands()},extractOrigin:function(a){var b=/([^:]*:\/\/[^\/]*)/;if(/^http.*/i.test(a)){return b.exec(a)[1]}},gameViewWillClose:function(){},saveGameState:function(d){var a,c,b;if(this.get("isUsingDataInteractiveChannel")){a=this.get("model");c=a&&a.get("componentStorage");if(!c&&a){a.set("componentStorage",{})}b=this.get("dataInteractivePhoneHandler");b.requestDataInteractiveState(function(e){c.savedGameState=e&&(e.values||e.state);d(e)})}else{c=this.get("context");b=this.get("gamePhoneHandler");b.saveGameState(function(e){if(c){c.savedGameState=e&&e.state}d(e)})}},createComponentStorage:function(){var c=this.getPath("model.componentStorage");if(!SC.none(this.get("context"))){c.currentGameName=c.currentGameName||this.getPath("context.gameName")||this.getPath("context.name");c.title=this.getPath("model.title");c.currentGameUrl=c.currentGameUrl||this.getPath("context.gameUrl");var b=this.get("storedProperties");b.forEach(function(d){c[d]=this.get(d)}.bind(this))}var a=this.get("context");if(a&&!this.getLinkID(c,"context")){this.addLink(c,"context",a)}c.currentGameFormulas=SC.clone(this.getPath("context.formulas"));return c},restoreComponentStorage:function(c,g){arguments.callee.base.apply(this,arguments);var h=c.currentGameName||c.name,d=c&&c.currentGameUrl,e=DG.finalGameUrl(d),b,a;b=this.getLinkID(c,"context");a=b&&DG.currDocumentController().getContextByID(b);if(!a){DG.currDocumentController().contexts.forEach(function(i){if(!a&&i){var j=i.get("gameName")||i.get("name");if(j===h){a=i}}})}if(a){this.set("context",a);this.setPath("context.gameName",h);this.setPath("context.gameUrl",e);var f=this.get("storedProperties");f.forEach(function(i){this.set(i,c[i])}.bind(this))}if(a&&c.currentGameFormulas){a.set("formulas",c.currentGameFormulas)}this.set("gameIsReady",true)},restoreGameState:function(a){this.gamePhoneHandler.restoreGameState(a)}});DG.sendCommandToDI=function(c){function a(e){if(e&&e.resource==="undoChangeNotice"){return{operation:e.values.operation}}}var d=DG.currDocumentController().get("dataInteractives");var b=null;d.forEach(function(e){var g=e.getPath("view.title");var i=e.get("activeChannel");var f=e.get("gamePhoneHandler");function h(j){}if(i===f){if(!b){b=a(c)}i.rpcEndpoint.call(b,h);DG.log("sendCommandToDI: sent game notification to %@: %@".loc(g,JSON.stringify(b)))}else{if(i){i.rpcEndpoint.call(c,h);DG.log("sendCommandToDI: sent notification to %@: %@".loc(g,JSON.stringify(c)))}}})};DG.GamePhoneHandler=SC.Object.extend({openCaseIDs:null,rpcEndpoint:null,controller:null,view:function(){return this.getPath("controller.view")}.property(),connected:false,contextBinding:".controller.context",doCommandFunc:null,gameEmbedID:null,init:function(){arguments.callee.base.apply(this,arguments);this.openCaseIDs=[]},destroy:function(){if(this.rpcEndpoint){this.rpcEndpoint.disconnect()}arguments.callee.base.apply(this,arguments)},getOpenCaseIDs:function(b){var a=this.get("context"),d=[],c=!b;function e(g){d.push(g.get("id"));if(c){var f=g.get("children");f.forEach(function(h){e(h)})}}this.openCaseIDs.forEach(function(g){var f=a.getCaseByID(g);if(f){e(f)}});DG.ObjectMap.forEach(this._openParentCases,function(f,g){e(g)});return d},doCommand:function(c,b){var a;SC.run(function(){a=this.dispatchCommand(c,b)}.bind(this));return a},dispatchCommand:function(h,g){var b=null,a={success:false},d=true;this.setIfChanged("connected",true);if(SC.typeOf(h)===SC.T_STRING){try{b=SC.json.decode(h)}catch(i){DG.logWarn("Invalid JSON in doCommand(), reported from DG.GamePhoneHandler.dispatchCommand()");DG.log("JSON: "+h)}}else{b=h}try{if(!b){return a}if(this.context&&this.context.get("flexibleGroupingChangeFlag")&&(["initGame","createCollection","openCase","createCase","createCases","updateCases","deleteCases"].indexOf(b.action)>=0)){DG.log('User has reordered Data Context, "%@", further updates from data interactives prohibited.',this.context.get("name"));this.invokeLater(function(){this.showErrorAlert("DG.GamePhoneHandler.continuityError")}.bind(this));return a}switch(b.action){case"initGame":this.handleInitGame(b.args,function(){var e={success:true};this.set("changeCount",0);this.controller.updateSavedChangeCount();d=false;f.call(this);if(g){g(e)}else{return e}}.bind(this));return;case"createComponent":b.args.initiatedViaCommand=true;a=this.handleCreateComponent(b.args,DG.STANDALONE_MODE);break;case"createCollection":a=this.handleCreateCollection(b.args);break;case"openCase":a=this.handleOpenCase(b.args);break;case"updateCase":a=this.handleUpdateCase(b.args);break;case"closeCase":a=this.handleCloseCase(b.args);break;case"createCase":a=this.handleCreateCase(b.args);break;case"createCases":a=this.handleCreateCases(b.args);break;case"deleteCases":a=this.handleDeleteCases(b.args);break;case"deleteAllCaseData":a=this.handleDeleteAllCaseData(b.args);break;case"logAction":a=this.handleLogAction(b.args);d=false;break;case"reset":a=this.handleReset(b.args);break;case"undoableActionPerformed":a=this.handleUndoableAction(b.args);break;case"undo":a=DG.UndoHistory.undo();break;case"redo":a=DG.UndoHistory.redo();break;case"requestAttributeValues":a=this.handleRequestAttributeValues(b.args);d=false;SC.warn("Deprecated API Call: "+b.action);break;default:d=false;SC.warn("Dispatch of unknown Data Interactive action("+b.action+"): ignoring");break}}catch(c){DG.logWarn("DG.GameController.doCommand: Caught exception: "+c);a=a||{};a.success=false}function f(){if(d){this.incrementProperty("changeCount")}}f.call(this);if(g){g(a);return a}return a},handleInitGame:function(k,d){var c=function(){SC.run(function(){this.set("defaultTitle",k.name);this.setPath("model.content",this);this.set("gameIsReady",true);this.notifyPropertyChange("gameIsReady");if((k.log===undefined)||k.log){DG.logUser("initGame: '%@', Collections: [%@]",h,l.getEach("name").join(", "))}this.updateLayout();if(d){d()}}.bind(this))}.bind(this);var h=this.getPath("context.gameName"),n=this.getPath("context.gameUrl"),a=this.getPath("model.componentStorage.currentGameUrl"),g=n||DG.finalGameUrl(a),i=this.get("context"),l=[],e,f,m,j,b={success:true};if(SC.none(i)){i=DG.currDocumentController().createNewDataContext({type:"DG.GameContext"});this.set("context",i)}if(k.name){this.setPath("context.gameName",k.name)}if(k.version){this.setPath("context.gameVersion",k.version)}if(SC.empty(this.getPath("context.gameUrl"))){this.setPath("context.gameUrl",g)}if(k.dimensions){this.setPath("context.gameDimensions",{width:k.dimensions.width,height:k.dimensions.height})}if(!SC.none(k.preventBringToFront)){this.set("preventBringToFront",k.preventBringToFront)}this.set("doCommandFunc",k.doCommandFunc);this.set("gameEmbedID",k.gameEmbedID);this.setPath("view.version",SC.none(this.context.gameVersion)?"":this.context.gameVersion);this.setPath("view.title",SC.none(this.context.gameName)?"":this.context.gameName);if(k.collections){k.collections.forEach(function(p){var o=this.handleCreateCollection(p);b.success=b.success&&o.success}.bind(this))}this.notifyPropertyChange("collections");e=i&&i.get("restoredGameState");f={operation:"restoreState",args:{state:e}};m=this.get("doCommandFunc");j=this.findCurrentGameElement(this.get("gameEmbedID"));if(e){if(m){m(f)}else{if(j&&j.doCommandFunc){j.doCommandFunc(SC.json.encode(f))}else{if(this.get("isPhoneInUse")){this.rpcEndpoint.call(f,c.bind(this));return b}}}}c.call(this);return b},handleCreateComponent:function(a,b){if(b){a.allowMoreThanOne=true}return SC.RootResponder.responder.sendAction("createComponentAndView",null,this,null,a)},findCurrentGameElement:function(a){var f=document.getElementsByTagName("iframe"),c=null;if(a){var e,b;for(e=0,b=f.length;e<b&&!c;++e){try{c=f[e].contentWindow.document.getElementById(a)}catch(d){}}}return c},notifyGameAboutExternalUndo:function(){if(this.get("gameIsReady")&&DG.UndoHistory.get("enabled")){if(DG.STANDALONE_MODE){this.rpcEndpoint.call({operation:"standaloneUndoModeAvailable"})}else{this.rpcEndpoint.call({operation:"externalUndoAvailable"})}}}.observes("gameIsReady"),doCreateCase:function(d,c){var a=this.get("context"),f=a.getCollectionByName(c.collection),e={},b={success:false};if(!SC.none(c.parent)){e.parent=c.parent}if(!DG.assert(a,"Missing game Context")){return b}var g={operation:"createCase",properties:e,values:c.values};if(f){g.collection=f}else{DG.logWarn("DG.GamePhoneHandler.doCreateCase: Can't find collection '%@'",c.collection)}b=a.applyChange(g);return b},doCreateCases:function(d,c){var a=this.get("context"),f=a.getCollectionByName(c.collection),e={},b={success:false};if(!SC.none(c.parent)){e.parent=c.parent}if(!DG.assert(a,"Missing game context")){return b}var g={operation:"createCases",properties:e,values:c.values};if(f){g.collection=f}else{DG.logWarn("DG.GamePhoneHandler.doCreateCase: Can't find collection '%@'",c.collection)}b=a.applyChange(g);if(b.success&&((c.log===undefined)||c.log)){DG.logUser("%@: %@ %@ cases created",d,c.collection,c.values.length)}return b},doDeleteCases:function(c){var a=this.get("context"),d=[],e={operation:"deleteCases",cases:d},b;c.forEach(function(g){var f=a.getCaseByID(g);if(f){d.push(f)}});b=a.applyChange(e);if(SC.none(b)){DG.logWarn("UpdateCase failed to return a value");b={success:true}}return b},doUpdateCase:function(d,c){var a=this.get("context"),f=a.getCollectionByName(c.collection),e=a.getCaseByID(c.caseID),b={success:false};if(f&&e&&c.values){var g={operation:"updateCases",collection:f,cases:[e],values:[c.values]};b=a.applyChange(g);if(SC.none(b)){DG.logWarn("UpdateCase failed to return a value");b={success:true}}}if(c.values&&((c.log===undefined)||c.log)){DG.logUser("%@: %@ [%@]",d,f.get("name"),c.values?c.values.join(", "):"")}return b},handleOpenCase:function(a){var b=this.doCreateCase("openCase",a);if(b.success&&!SC.none(b.caseID)){this.openCaseIDs.pushObject(b.caseID)}return b},handleUpdateCase:function(a){return this.doUpdateCase("updateCase",a)},handleCloseCase:function(a){var b=this.doUpdateCase("closeCase",a);if(!SC.none(a.caseID)){this.openCaseIDs.removeObject(a.caseID)}return b},handleCreateCase:function(a){return this.doCreateCase("createCase",a)},handleCreateCases:function(a){return this.doCreateCases("createCases",a)},handleDeleteCases:function(a){return this.doDeleteCases(a.caseIDs)},handleDeleteAllCaseData:function(a){DG.logUser("deleteAllCaseData by Game");var b=a&&a.preserveAllGames,c=a&&a.preserveOpenEvents;return this.doDeleteAllCaseData(b,!c)},handleReset:function(a){this.doResetCollections()},handleUndoableAction:function(a){var d=a&&a.logMessage?a.logMessage:"Unknown action";var b=this.get("rpcEndpoint");var c=this.handleUndoRedoCompleted;DG.UndoHistory.execute(DG.Command.create({name:"interactive.undoableAction",undoString:"DG.Undo.interactiveUndoableAction",redoString:"DG.Redo.interactiveUndoableAction",log:"Interactive action occurred: "+d,execute:function(){},undo:function(){b.call({operation:"undoAction"},c)},redo:function(){b.call({operation:"redoAction"},c)}}))},handleUndoRedoCompleted:function(a){if(a&&a.success===false){DG.UndoHistory.showErrorAlert(true,{message:"Data Interactive error"})}},doResetCollections:function(){var b,a=this.get("context"),c={operation:"resetCollections"};if(a){b=a.applyChange(c)}return b},doDeleteAllCaseData:function(c,g){c=c||false;g=g||false;var b=this.get("context"),f=this.getOpenCaseIDs(g),d=null,h=null;if(c){d=b&&b.getCollectionAtIndex(0);if(d){d.getCaseIDs().forEach(function(i){if(f.indexOf(i)===-1){f.push(i)}})}}h=DG.store.destroyAllRecordsOfType(DG.Case,f);var e={operation:"deleteCases",isComplete:true,ids:h},a={success:false};if(b){a=b.applyChange(e)}return a},handleCreateCollection:function(b){var a=this.get("context"),f={name:b.name,caseName:b.caseName,labels:b.labels,defaults:b.defaults,collapseChildren:b.collapseChildren,areParentChildLinksConfigured:true},d=a.get("collections"),e,c;if(d&&d.length>0){f.parent=d[d.length-1].get("id")}b.attrs&&b.attrs.forEach(function(g){if(SC.none(g.editable)){g.editable=false}});e=a&&a.applyChange({operation:"createCollection",properties:f,attributes:b.attrs});c=e&&e.success&&e.collection;if(c){if((b.log===undefined)||b.log){DG.logUser("newCollectionCreated: %@ with %@ attributes",b.name,b.attrs.length)}return{success:true,collectionID:c.get("id")}}else{return{success:false}}},handleLogAction:function(a){if(a.formatStr){var b=[a.formatStr];if(a.replaceArgs){b=b.concat(a.replaceArgs)}DG.logUser.apply(this,b);return{success:true}}return{success:false}},handleRequestAttributeValues:function(l){var k=this.get("context"),e=k.getCollectionByName(l.collection),b=k.getCaseByID(l.caseID),h={success:false,values:[]};if(e&&b&&l.attributeNames){var g=e.getAttributeIDs(),a,f,d,c=l.attributeNames.length;for(d=0;d<c;++d){a=e.getAttributeIndexByName(l.attributeNames[d]);f=null;if(a>0&&a<g.length){f=b.getValue(g[a])}h.values.push(f)}h.success=true}return h},newCollectionWithAttributes:function(b,c){DG.logUser("newCollectionCreated: %@ [%@]",b,c.join(", "));var a=this.get("context"),d=a&&a.guaranteeCollection({name:b});if(d){c.forEach(function(e){d.guaranteeAttribute({name:e})})}if(b==="Weasels"){this.newCollectionWithAttributes("Games",["game"])}this.notifyPropertyChange("collections");this.set("gameIsReady",true)},_openGameName:"",_openParentCollectionName:"",_openParentCases:{},openParentCase:function(c,b,d,a){this._openGameName=c;this._openParentCollectionName=d;this._openParentCases[b]=a},closeParentCases:function(){this._openGameName="";this._openParentCollectionName="";this._openParentCases={}},closeParentCase:function(a){this.closeParentCases()},getParentCaseFor:function(a){return this._openParentCases[Object.keys(this._openParentCases).pop()]},saveGameState:function(e){var d=this.get("doCommandFunc"),b={operation:"saveState"},c=this.findCurrentGameElement(this.get("gameEmbedID")),a;if(d){a=d(b);e(a)}else{if(c&&c.doCommandFunc){a=c.doCommandFunc(SC.json.encode(b));if(typeof a==="string"){a=JSON.parse(a)}e(a)}else{if(this.get("isPhoneInUse")){this.rpcEndpoint.call(b,e)}else{e({success:false})}}}},restoreGameState:function(b){var a=this.getPath("controller.context");if(a){a.restoreFromStorage(b)}},gameViewWillClose:function(){},updateLayout:function(){if(DG.STANDALONE_MODE){return}var c=this.get("view"),d=this.getPath("context.gameDimensions"),b,a;if(c&&d){b=d.width+DG.ViewUtilities.horizontalPadding();a=d.height+DG.ViewUtilities.verticalPadding();c.adjust("width",b);c.adjust("height",a)}},logUserAction:function(b,a){DG.logUser(b+(a&&a.length?": ["+a.join(", ")+"]":""))},showErrorAlert:function(a){DG.AlertPane.warn({localize:true,message:a})}});DG.WebView=SC.View.extend({classNames:["dg-web-view"],childViews:DG.get("hideWebViewLoading")!=="yes"?["loadingView","webView"]:["webView"],isTextSelectable:YES,value:"",_url:function(){return this.get("value").replace(/^https?:/,"")}.property("value"),isLoading:true,loadingMessage:function(){return this.isLoading?"DG.GameView.loading".loc():"DG.GameView.loadError".loc()}.property("isLoading"),loadingView:SC.View.extend({childViews:["urlLabel","messageLabel"],isLoadingBinding:"*parentView.isLoading",classNames:["dg-web-view-backdrop"],classNameBindings:["isLoading:dg-interactive-loading"],urlLabel:SC.LabelView.extend({layout:{left:10,right:0,top:0,height:36},valueBinding:"*parentView.parentView.value",classNames:["dg-web-view-url"]}),messageLabel:SC.LabelView.extend({layout:{left:20,right:20,top:40,height:40},valueBinding:"*parentView.parentView.loadingMessage",classNames:["dg-web-view-message"]})}),webView:SC.WebView.extend({classNames:["dg-web-view-frame"],value:function(){return this.getPath("parentView._url")}.property(),urlDidChange:function(){this.notifyPropertyChange("value")}.observes("*parentView.value"),iframeDidLoad:function(){if(!SC.none(this.get("value"))){this.setPath("parentView.isLoading",false)}arguments.callee.base.apply(this,arguments)}})});sc_require("components/game/game_controller");sc_require("views/web_view");DG.GameView=DG.WebView.extend({classNames:["dg-game-view"],classNameBindings:["connected:dg-interactive-connected"],controller:null,connected:null,didConnect:function(){this.set("connected",!SC.none(this.getPath("controller.activeChannel")))}.observes(".controller.activeChannel"),backgroundColor:"white",destroy:function(){this.controller.gameViewWillClose();arguments.callee.base.apply(this,arguments)},webView:SC.WebView.extend({classNames:["dg-web-view-frame"],render:function(a,d){var c=this.get("value")||"",b;if(d){a.push('<iframe allow="geolocation; microphone; camera; bluetooth; clipboard-read; clipboard-write" src="'+c+'" style="position: absolute; width: 100%; height: 100%; border: 0; margin: 0; padding: 0;"></iframe>')}else{if(c!==this._lastSrc){b=this.$("iframe");b.attr("src","javascript:;");b.attr("src",c)}}this._lastSrc=c},value:function(){function a(h){var g=document.createElement("a");g.href=h;return g}var d=this.getPath("parentView._url");var e=a(d);var c=a(d).search;var f=DG.get("currentLanguage");var b=e.protocol==="data:";if(!b){if(!c||c.length===0){c="?lang="+f}else{c+="&lang="+f}}e.search=c;return e.href}.property(),controllerBinding:"*parentView.controller",_previousValue:null,valueDidChange:function(){var b=this.get("value");var a=this.parentView.get("controller");if(b!==this._previousValue){a.setUpChannels(this.$("iframe")[0],b)}this._previousValue=b}.observes("value"),iframeDidLoad:function(){if(!SC.none(this.value)){this.setPath("parentView.isLoading",false)}var a=this.$("iframe")[0];if(this.value){this.valueDidChange()}if(a&&a.contentWindow){$(a).attr("allowfullscreen",true).attr("webkitallowfullscreen",true).attr("mozallowfullscreen",true)}else{DG.logWarn("DG.GameView:iframeDidLoad no contentWindow\n")}var b=this.getPath("parentView.loadingView");if(b){b.destroy()}arguments.callee.base.apply(this,arguments)}})});DG.PlotAdornment=SC.Object.extend({model:null,paperSource:null,paper:function(){return this.getPath("paperSource.paper")}.property(),paperDidChange:function(){this.notifyPropertyChange("paper")}.observes("*paperSource.paper"),xAxisView:function(){return this.getPath("paperSource.xAxisView")}.property("paperSource").cacheable(),xAxisViewDidChange:function(){this.notifyPropertyChange("xAxisView")}.observes("*paperSource.xAxisView"),yAxisView:function(){return this.getPath("paperSource.yAxisView")}.property("paperSource").cacheable(),yAxisViewDidChange:function(){this.notifyPropertyChange("yAxisView")}.observes("*paperSource.yAxisView"),parentView:null,myElements:null,layerName:null,layer:function(){var a=this.getPath("paperSource.layerManager");return(a&&this.layerName)?a[this.layerName]:null}.property("paperSource","layerName"),modelPropertiesToObserve:[["willDestroy","detachModel"],["computingNeeded","updateToModel"],["isVisible","updateVisibility"]],concatenatedProperties:["modelPropertiesToObserve"],init:function(){arguments.callee.base.apply(this,arguments);this.myElements=[];this.modelDidChange()},detachModel:function(){this.set("model",null)},destroy:function(){this.detachModel();this.removeElements();arguments.callee.base.apply(this,arguments)},removeElements:function(){if(this.myElements){var a=this.getPath("paperSource.layerManager");this.myElements.forEach(function(b){a.removeElement(b);b.remove()});this.myElements=null}},_observedModel:null,modelDidChange:function(){var a=this.get("modelPropertiesToObserve");if(this._observedModel){if(a){a.forEach(function(c){this._observedModel.removeObserver(c[0],this,c[1])}.bind(this))}this._observedModel=null}var b=this.get("model");if(b){if(a){a.forEach(function(c){b.addObserver(c[0],this,c[1])}.bind(this))}this._observedModel=b}}.observes("model"),showElements:function(){var a=this.get("opacity")||1,b=this.get("strokeOpacity")||1;this.myElements.forEach(function(c){c.show();if(c.animatable){c.stop();c.animate({"stroke-opacity":b,opacity:a},DG.PlotUtilities.kDefaultAnimationTime,"<>")}})},hideElements:function(){this.myElements.forEach(function(a){if(a.animatable){a.stop();a.animate({"stroke-opacity":0,opacity:0},DG.PlotUtilities.kDefaultAnimationTime,"<>",function(){a.hide()})}else{a.hide()}})},updateVisibility:function(){if(this.getPath("model.isVisible")){this.updateToModel();this.showElements()}else{if(!SC.none(this.myElements)){this.hideElements()}}},updateToModel:function(){}});sc_require("components/graph/adornments/plot_adornment");DG.ConnectingLineAdornment=DG.PlotAdornment.extend({unselectedLineWidth:2,selectedLineWidth:4,_dataTip:null,dataTip:function(){if(!this._dataTip){var a=this.get("parentView");DG.assert(a);this._dataTip=DG.LineDataTip.create({paperSource:this.get("paperSource"),plotView:a,layerName:DG.LayerNames.kDataTip})}return this._dataTip}.property(),init:function(){arguments.callee.base.apply(this,arguments);this.myElements=[]},wantVisible:function(){return this.getPath("model.isVisible")},invalidateModel:function(){var a=this.get("model");if(a){a.setComputingNeeded()}},updateToModel:function(a){var b=this.get("model");if(SC.none(b)){return}if(b.get("isVisible")){b.recomputeValueIfNeeded();this.updateLine(a)}else{this.hideLines()}},updateVisibility:function(){this.updateToModel(true)},hideLines:function(){var c=this.myElements.length,b=this.get("layer");for(var a=0;a<c;a++){this.myElements[a].animate({"stroke-opacity":0},DG.PlotUtilities.kDefaultAnimationTime,"<>",function(){b.prepareToMoveOrRemove(this);this.remove()})}this.myElements.length=0},hide:function(){this.get("myElements").forEach(function(a){a.animate({"stroke-opacity":0},DG.PlotUtilities.kDefaultAnimationTime,"<>",function(){this.hide()})})},show:function(){if(this.getPath("model.isVisible")){this.get("myElements").forEach(function(a){a.animate({"stroke-opacity":1},DG.PlotUtilities.kDefaultAnimationTime,"<>",function(){this.show()})})}},updateLine:function(b){var a=this.getPath("parentView.xAxisView"),d=this.getPath("parentView.yAxisView");function c(e,f){return{x:a.dataToCoordinate(e),y:d.dataToCoordinate(f)}}if(a&&d){this.doUpdateLine(b,c)}},doUpdateLine:function(k,d){var e="M0,0",f=this,g=this.getPath("model.values"),c=10,h=this.get("paper"),j=this.get("layer"),i=DG.ObjectMap.length(g),a=0;if(!h){return}if(!g){return}DG.ObjectMap.forEach(g,function(l,n){var t=n.coordinates,q=t?t.length:0,m=e,r=n.color?(typeof n.color==="string"?n.color:n.color.colorString):DG.ColorUtilities.calcAttributeColorFromIndex(a%c,c),p,o;r=r.colorString||r;for(p=0;p<q;++p){var s=d(t[p].x,t[p].y);if(s.x&&s.y){if(m===e){m="M%@,%@".fmt(s.x,s.y)}else{m+=" L%@,%@".fmt(s.x,s.y)}}}DG.assert(m);o=f.myElements[a];if(!o){o=h.path("").attr({"stroke-opacity":0,cursor:"pointer"}).mousedown(function(u){f.get("model").selectParent(this.parentCaseID,u.shiftKey)}).hover(function(u){f.showDataTip(u,l)},function(){f.hideDataTip()});f.myElements.push(o);j.push(o)}o.parentCaseID=l;o.attr({path:m,stroke:r});if(k){o.animate({"stroke-opacity":1},DG.PlotUtilities.kDefaultAnimationTime,"<>")}else{o.attr({"stroke-opacity":1})}a++});while(this.myElements.length>i){var b=this.myElements.pop();j.prepareToMoveOrRemove(b);b.remove()}this.updateSelection()},updateSelection:function(){if(!this.get("paper")){return}var b=DG.ObjectMap.values(this.getPath("model.values"))||[],a=this.getPath("model.plotModel.selection");b.forEach(function(f,d){var h=f.coordinates,j=h?h.length:0,c=true,e=this.myElements[d],g;if(e){for(g=0;g<j;++g){c=c&&a.indexOf(h[g].theCase)>=0;if(!c){break}}e.attr({"stroke-width":(c?this.selectedLineWidth:this.unselectedLineWidth)})}}.bind(this))},showDataTip:function(c,d){var f=this.get("dataTip");var k=this.getPath("model.plotModel.dataContext"),a=k&&k.getCaseByID(d),g=this.getPath("model.parentCollectionFirstAttribute");if(SC.none(a)){return}var i=g.get("name"),j=a.getValue(g.get("id")),e=a.get("children").flatten(),h=SC.isArray(e)?e.get("length"):0,b=(h>0)?e[0].getPath("collection.name"):"";f.show({groupingAttributeValue:j,groupingAttributeName:i,numChildren:h,childrenName:b},{x:c.offsetX-5,y:c.offsetY-5})},hideDataTip:function(){this.get("dataTip").hide()}});DG.PlotAdornmentModelNextID=0;DG.PlotAdornmentModel=SC.Object.extend({plotModel:null,adornmentKey:null,isVisible:true,cases:function(){return this.get("enableMeasuresForSelection")?this.getPath("plotModel.selection"):this.getPath("plotModel.cases")}.property(),init:function(){this.set("id",++DG.PlotAdornmentModelNextID)},destroy:function(){this.plotModel=null;this.notifyPropertyChange("willDestroy");arguments.callee.base.apply(this,arguments)},_needsComputing:true,isComputingNeeded:function(){return this._needsComputing&&this.isVisible},setComputingNeeded:function(){this._needsComputing=true;if(this.isComputingNeeded()){this.notifyPropertyChange("computingNeeded")}},recomputeValueIfNeeded:function(){if(this.isComputingNeeded()){this.recomputeValue()}},recomputeValue:function(){},enableMeasuresForSelection:false,enableMeasuresForSelectionDidChange:function(){this.setComputingNeeded()}.observes("enableMeasuresForSelection"),createStorage:function(){var a={};a.isVisible=this.get("isVisible")||false;a.enableMeasuresForSelection=this.get("enableMeasuresForSelection")||false;return a},restoreStorage:function(a){if(a){this.set("isVisible",a.isVisible||false)}this.set("enableMeasuresForSelection",a.enableMeasuresForSelection||false)}});DG.PlotAdornmentModel.registry={};sc_require("components/graph/adornments/plot_adornment_model");DG.ConnectingLineModel=DG.PlotAdornmentModel.extend({_values:null,values:function(b,a){if(a){this._values=a}else{this.recomputeValueIfNeeded()}return this._values}.property(),parentCollectionFirstAttribute:null,isComputingNeeded:function(){return this._needsComputing&&this.isVisible},setComputingNeeded:function(){this._needsComputing=true},recomputeValueIfNeeded:function(){if(this.isComputingNeeded()){this.recomputeValue()}},getLineColorFunc:null,recomputeValue:function(){var d=this.getPath("plotModel.cases"),g=d.at(0),k=this.getPath("plotModel.xVarID"),h="plotModel."+(this.getPath("plotModel.verticalAxisIsY2")?"y2VarID":"yVarID"),m=this.getPath(h),l=this.getPath("plotModel.dataConfiguration.legendAttributeDescription")||this.getPath("plotModel.legendAttributeDescription");if(!(k&&m)){return}var j=function(){var q=null,o=l&&l.get("isCategorical");if(o&&g){var p=g.getPath("parent.collection.id"),n=l.getPath("collectionClient.id");if(p===n){q=l.getPath("attribute.categoryMap")}}return q}.bind(this);var a=g?g.getPath("parent.collection"):null,c=a?a.get("attrs"):null,f=c?c[0]:null;this.set("parentCollectionFirstAttribute",f);var b={},i=j(),e=this.get("getLineColorFunc");d.forEach(function(o,q){var s=o.getForcedNumericValue(k),p=o.getForcedNumericValue(m),n=o.get("parent"),r=n?n.get("id"):"top";if(isFinite(s)&&isFinite(p)){if(!b[r]){b[r]={color:(i?(i[o.getValue(l.getPath("attribute.id"))]):(e?e():null)),coordinates:[]}}b[r].coordinates.push({x:s,y:p,theCase:o})}});this._needsComputing=false;this.set("values",b)},_needsComputing:true,selectParent:function(d,e){if(!DG.isFinite(d)){return}var f=this.getPath("plotModel.dataContext"),a=f.getCaseByID(d),b=a.get("collection").getCaseIndexByID(d)+1,c={operation:"selectCases",collection:a.get("collection"),cases:[a],select:true,extend:e};SC.run(function(){f.applyChange(c);if(c.select){DG.logUser("lineSelected: %@",b)}else{DG.logUser("lineDeselected: %@",b)}}.bind(this))}});DG.PlotAdornmentModel.registry.connectingLine=DG.ConnectingLineModel;DG.ToolTip=SC.Object.extend({paperSource:null,destroy:function(){this.paperSource=null;arguments.callee.base.apply(this,arguments)},paper:function(){return this.getPath("paperSource.paper")}.property("paperSource").cacheable(),layerName:null,layer:function(){var a=this.getPath("paperSource.layerManager");return(a&&this.layerName)?a[this.layerName]:null}.property("paperSource","layerName"),text:null,tipOrigin:null,tipSourceRadius:null,tipIsEmpty:function(){return SC.empty(this.get("text"))}.property("text"),_tipTextElement:null,_tipRectElement:null,_tipShadowElement:null,updateTip:function(){if(this.get("tipIsEmpty")){return}var e=this.get("paper"),m=10,g=5,d=2,n,h,f=15,b,k,j,i,l,a,c;i=this.tipSourceRadius?this.tipSourceRadius:0;k=this.tipOrigin.x+i;j=this.tipOrigin.y+i;this._tipTextElement.attr({text:this.get("text")});l=DG.RenderingUtilities.getExtentForTextElement(this._tipTextElement,12);a=l.width+10;c=l.height+10;b=c/2+5;n=m+a+d;h=g+d;if(k+n>e.width){k=Math.max(-m,k-(k+n-e.width))}if(j+h+c>e.height){j=Math.max(-g,j-(j+h+c-e.height))}if(DG.ViewUtilities.ptInRect(this.tipOrigin,{x:k,y:j,width:a+d+5,height:c+d+5})){k=Math.max(0,this.tipOrigin.x-i-a-d-m);j=Math.max(0,this.tipOrigin.y-i-c-d-g)}this._tipTextElement.attr({x:k+f,y:j+b});this._tipShadowElement.attr({path:"M"+(k+n)+" "+(j+h)+" v"+c+" h-"+a});this._tipRectElement.attr({x:k+m,y:j+g,width:a,height:c})},show:function(){if(this.get("tipIsEmpty")){return}var a=this.get("paper"),b=this.get("layer");this.hide();this._tipTextElement=a.text(0,0,"").attr({"text-anchor":"start",opacity:0}).addClass(DG.PlotUtilities.kToolTipTextClassName);this._tipShadowElement=a.path("").attr("stroke-opacity",0).addClass(DG.PlotUtilities.kToolTipShadowClassName);this._tipRectElement=a.rect(0,0,0,0).attr("opacity",0).addClass(DG.PlotUtilities.kToolTipClassName);this.updateTip();b.push(this._tipShadowElement);b.push(this._tipRectElement);b.push(this._tipTextElement);this._tipRectElement.animate({opacity:0.7},DG.PlotUtilities.kToolTipShowTime,"<>");this._tipTextElement.animate({opacity:1},DG.PlotUtilities.kToolTipShowTime,"<>");this._tipShadowElement.animate({"stroke-opacity":0.7},DG.PlotUtilities.kToolTipShowTime,"<>")},hide:function(){var a=this.get("layer");[this._tipShadowElement,this._tipRectElement,this._tipTextElement].forEach(function(b){if(b){a.prepareToMoveOrRemove(b);b.remove()}})}});sc_require("utilities/tool_tip");DG.DataTip=DG.ToolTip.extend({plotLayer:null,plotBinding:".plotLayer.model",caseIndex:null,text:function(){return this.getDataTipText()}.property(),init:function(){arguments.callee.base.apply(this,arguments);if(!this.get("paperSource")){this.set("paperSource",this.get("plotLayer"))}},show:function(a,d,c,b){this.set("caseIndex",b);arguments.callee.base.apply(this,arguments)},getDataTipText:function(){return""},handleChanges:function(b){var a=(SC.typeOf(b)===SC.T_NUMBER?SC.IndexSet.create(b):b);a=a||[];if(SC.none(this._myElements)||(this._myElements.length===0)||!(a.contains(this.get("caseIndex")))){return}this.updateTip()}});DG.EquationView=SC.LabelView.extend({classNames:"dg-equationview".w(),transitionShow:SC.View.FADE_IN,transitionShowOptions:{duration:1,timing:"ease-in-out"},transitionHide:SC.View.FADE_OUT,transitionHideOptions:{duration:1,timing:"ease-in-out"},isEditable:false,localize:true,classNameBindings:["highlighted:dg-equationview-opaque"],highlight:null,unhighlight:null,show:function(a,b){if(!isFinite(a.x)||!isFinite(a.y)){return}this.get("layer").innerHTML=b;SC.run(function(){this.adjust({left:a.x,top:a.y})}.bind(this))},didCreateLayer:function(){var b=this,a=this.get("layer");a.addEventListener("mouseover",b.callHighlight.bind(b));a.addEventListener("mouseout",b.callUnHighlight.bind(b))},willDestroyLayer:function(){var b=this,a=this.get("layer");a.removeEventListener("mouseover",b.callHighlight.bind(b));a.removeEventListener("mouseout",b.callUnHighlight.bind(b))},callHighlight:function(){this.highlight(this.get("index"))},callUnHighlight:function(){this.unhighlight(this.get("index"))},hide:function(){this.set("isVisible",false)}});DG.EquationView.defaultHeight=16;sc_require("components/graph/adornments/data_tip");DG.LineDataTip=DG.DataTip.extend({info:null,getDataTipText:function(){var a="";if(this.info){a="DG.DataTip.connectingLine".loc(this.info.groupingAttributeName,this.info.groupingAttributeValue,this.info.numChildren,this.info.childrenName)}return a},show:function(b,a){this.info={};this.tipOrigin={};DG.ObjectMap.copy(this.info,b);DG.ObjectMap.copy(this.tipOrigin,a);arguments.callee.base.apply(this,arguments)}});DG.LineLabelMixin={backgrndRect:null,textElement:null,createBackgroundRect:function(){this.backgrndRect=this.get("paper").rect(0,0,0,0).attr({fill:"white","stroke-width":0,"fill-opacity":0.6});return this.backgrndRect},createTextElement:function(){this.textElement=this.get("paper").text(0,0,"").attr({"text-anchor":"start",opacity:1});this.textElement.addClass("dg-graph-adornment");return this.textElement},updateTextToModel:function(j){if(this.myElements===null){this.createElements()}var d=5,m=this.get("valueAxisView"),a=this.get("value"),b=(!SC.none(a)&&isFinite(a))?m.dataToCoordinate(a):-1000,h=this.get("paper"),g=this.get("valueString"),c=this.get("textElement"),f=this.get("backgrndRect"),i,l,k={},e={};c.attr({text:g});i=c.getBBox();if(m.get("orientation")===DG.GraphTypes.EOrientation.kHorizontal){l=c.attr("text-anchor");k.y=j*h.height;e.y=k.y-i.height/2;switch(l){case"start":case"middle":e.x=b+2;if(i.width+d<h.width-b){k.x=b+d}else{if(i.width+d<b){k.x=b-d;l="end"}else{k.x=d}}break;case"end":e.x=b-i.width-2;if(i.width+d<b){k.x=b-d}else{if(i.width+d<h.width-b){k.x=b+d;l="start"}else{k.x=h.width-d}}break}}else{k.y=b;k.x=h.width/2;e.x=k.x-i.width/2;l="middle";if(i.height>b){k.y+=i.height/2+2;e.y=b+2}else{k.y-=i.height/2+2;e.y=b-i.height-2}}c.attr({x:k.x,y:k.y,"text-anchor":l});f.attr({x:e.x,y:e.y,width:i.width,height:i.height})}};sc_require("components/graph/adornments/plot_adornment");DG.TwoDLineAdornment=DG.PlotAdornment.extend((function(){var d='<p style = "color:%@;">%@ = %@</p>',c='<p style="color:%@;"><i>%@</i> = %@ <i>%@</i> %@ %@</p>',b='<p style="color:%@;"><i>%@</i> = %@ (<i>%@</i>) %@ %@</p>',f='<p style = "color:%@;"><i>%@</i> = %@ %@</p>',e='<p style = "color:%@;">%@ = %@ %@</p>',a='<span style = "color:gray;">%@</span>';return{lineSeg:null,coverSeg:null,equation:null,defaultColor:"black",lineColor:function(){return this.get("defaultColor")}.property().cacheable(),equationColor:function(){return DG.color(DG.ColorUtilities.colorNameToHexColor(this.get("lineColor"))).darker(1).color}.property().cacheable(),destroy:function(){if(this.equation){this.get("paperSource").removeChildAndDestroy(this.equation);this.equation=null}arguments.callee.base.apply(this,arguments)},modelPropertiesToObserve:[["slope","updateToModel"],["intercept","updateToModel"],["isInterceptLocked","updateToModel"],["isVertical","updateToModel"],["xIntercept","updateToModel"],["sumSquaresResiduals","updateToModel"],["equationCoords","updateToModel"],["showConfidenceBands","updateToModel"]],equationString:function(){var i=this;function g(){var j=function(){var E=i.getPath("xAxisView.model.lowerBound"),G=i.getPath("xAxisView.model.upperBound"),D=G-E,F=1;if(D<120){w="DG.ScatterPlotModel.secondsLabel".loc()}else{if(D<60*60*2){F=60;w="DG.ScatterPlotModel.minutesLabel".loc()}else{if(D<3600*24*2){F=3600;w="DG.ScatterPlotModel.hoursLabel".loc()}else{if(D<3600*24*365){F=3600*24;w="DG.ScatterPlotModel.daysLabel".loc()}else{F=3600*24*365.25;w="DG.ScatterPlotModel.yearsLabel".loc()}}}}w=a.loc(w);y*=F;z=y.toPrecision(3)+" ";if(z!=="0 "){u=t="";z+=a.loc(i.getPath("yAxisView.model.firstAttributeUnit"))+" "}},k=function(){var D=i.getPath("yAxisView.model.firstAttributeUnit"),G=i.getPath("xAxisView.model.firstAttributeUnit"),E=(G==="")?"":"/",F;if(G.match(/((^[sS])|(\W[sS]))$/)){F=G}else{F=pluralize.singular(G)}G=SC.empty(F)?G:F;return(G===""&&D==="")?"":" "+D+E+G+")"},s=function(){var D=i.getPath("yAxisView.model.firstAttributeUnit");return(D==="")?"":" "+a.loc(D)};var m=c,A=i.getPath("model.intercept"),y=i.getPath("model.slope"),o=DG.PlotUtilities.findNeededFractionDigits(y,A,i.get("xAxisView"),i.get("yAxisView")),p=DG.Format.number().group("").fractionDigits(0,o.interceptDigits),u=p(A)+s(),r=DG.Format.number().group("").fractionDigits(0,o.slopeDigits),C=k(),l=r(y),v=a.loc(C),z=(SC.empty(C)?"":"(")+l+v+" ",t=(A<0)?" ":" + ",q=i.getPath("xAxisView.isDateTime"),B=i.getPath("yAxisView.model.firstAttributeName"),w=i.getPath("xAxisView.model.firstAttributeName"),n=i.get("equationColor");if(q){j();var x="DG.ScatterPlotModel.slopeOnly".loc();return e.loc(n,x,z,w)}if(p(A)==="0"){u=t=""}if(l==="1"&&SC.empty(C)){z=""}if(l==="0"){z="";w="";t=""}if(w.length>1){m=b}return m.loc(n,B,z,w,t,u)}function h(){var k=DG.PlotUtilities.findFractionDigitsForAxis(i.get("xAxisView")),m=i.getPath("model.xIntercept"),j=i.getPath("xAxisView.model.firstAttributeName"),n=i.getPath("xAxisView.model.firstAttributeUnit"),l=i.get("equationColor");return f.loc(l,j,DG.Format.number().group("").fractionDigits(0,k)(m),a.loc(n))}if(this.getPath("model.isVertical")){return h()}else{return g()}}.property("model.intercept","model.slope","model.isVertical","model.xIntercept","xAxisView.model.firstAttributeName","yAxisView.model.firstAttributeName").cacheable(),sumResidSquaredString:function(){var k="";if(this.getPath("model.showSumSquares")){var i=this.getPath("model.sumSquaresResiduals"),j=i>100?0:3,h=DG.Format.number().fractionDigits(0,j),l=SC.none(i)?"":h(i),g="DG.ScatterPlotModel.sumSquares".loc();k=d.loc(this.get("equationColor"),g,l)}return k}.property(),createElements:function(){var l=this;if(this.myElements&&(this.myElements.length>0)){return}var n=this.get("paper"),i=this.getPath("paperSource.layerManager")[DG.LayerNames.kDataTip],q=this.getPath("paperSource.layerManager")[DG.LayerNames.kAdornments],m=this.get("lineColor"),p,k,h;this.lineSeg=n.line(0,0,0,0).attr({stroke:m,"stroke-opacity":0});this.lineSeg.animatable=true;this.coverSeg=n.line(0,0,0,0).attr({stroke:m,"stroke-opacity":0.001,"stroke-width":6}).hover(g,j);this.coverSeg.animatable=false;function g(){l.lineSeg.attr("stroke-width",2);l.equation.set("highlighted",true)}function j(){l.lineSeg.attr("stroke-width",1);l.equation.set("highlighted",false)}function o(v){var t=this;function u(){var w=t.get("frame"),x=w.x+w.width/2,y=w.y+w.height/2;return{proportionCenterX:x/l.get("paper").width,proportionCenterY:y/l.get("paper").height}}p={x:v.clientX,y:v.clientY};k=l.getPath("model.equationCoords");h=SC.none(k)?u():k;return YES}function r(w){var v=(w.clientX-p.x)/2,u=(w.clientY-p.y)/2,t=l.get("paper");l.setPath("model.equationCoords",{proportionCenterX:h.proportionCenterX+v/t.width,proportionCenterY:h.proportionCenterY+u/t.height})}function s(v){var t=k,u;DG.UndoHistory.execute(DG.Command.create({name:"graph.repositionEquation",undoString:"DG.Undo.graph.repositionEquation",redoString:"DG.Redo.graph.repositionEquation",log:"Moved equation from %@ to %@".fmt(t,this.getPath("model.coordinates")),executeNotification:{action:"notify",resource:"component",values:{operation:"reposition equation",type:"DG.GraphView"}},execute:function(){u=l.getPath("model.equationCoords")}.bind(this),undo:function(){l.setPath("model.equationCoords",t)}.bind(this),redo:function(){l.setPath("model.equationCoords",u)}.bind(this)}))}this.equation=DG.EquationView.create({highlight:g,unhighlight:j,mouseDown:o,mouseDragged:r,mouseUp:s});this.get("paperSource").appendChild(this.equation);this.lineSeg.node.setAttribute("shape-rendering","geometricPrecision");this.myElements=[this.lineSeg,this.coverSeg];i.push(this.coverSeg);q.push(this.lineSeg)},positionEquationAndBackground:function(){var s=this.get("model");if(!s.get("isVisible")){return}s.recomputeSlopeAndInterceptIfNeeded();var w=s.get("slope"),x=s.get("intercept");this.showElements();if(this.myElements===null){this.createElements()}var q=this.get("xAxisView"),g=this.get("yAxisView"),t=g.getPath("model.lowerBound"),z=g.getPath("model.upperBound"),p=(s.get("isVertical"))?{pt1:{x:s.get("xIntercept"),y:t},pt2:{x:s.get("xIntercept"),y:z}}:DG.PlotUtilities.lineToAxisIntercepts(w,x,q.get("model"),g.get("model"));function i(A){return{x:q.dataToCoordinate(A.x),y:g.dataToCoordinate(A.y)}}function o(){var A=p.pt1;p.pt1=p.pt2;p.pt2=A}function u(){var A=i({x:(p.pt1.x+p.pt2.x)/2,y:(p.pt1.y+p.pt2.y)/2});return A}function y(){var B=k.proportionCenterX*v,A=k.proportionCenterY*j;return{x:B-l/2,y:A-h.height/2}}if(p.pt2.x<p.pt1.x){o()}var r=3,v=this.get("paper").width,j=this.get("paper").height,k=this.getPath("model.equationCoords"),n=i(p.pt1),m=i(p.pt2),h,l;DG.RenderingUtilities.updateLine(this.lineSeg,n,m);DG.RenderingUtilities.updateLine(this.coverSeg,n,m);h=this.getPath("equation.frame");l=h.width;l+=r;if(SC.none(k)){k=u()}else{k=y()}this.equation.show(k,this.get("equationString"))},updateVisibility:function(){arguments.callee.base.apply(this,arguments);if(this.equation){if(this.getPath("model.isVisible")){this.equation.set("isVisible",true)}else{this.equation.hide()}}},enableMeasuresForSelectionDidChange:function(){}}}()));DG.PlotUtilities={kAxisColor:"#ccc",kEmptyPromptColor:"#999999",kRuleColor:"#ddd",kRuleWidth:1,kZeroLineColor:"#555",kZeroLineWidth:1,kBinBorderLineColor:"rgba(115, 191, 202)",kBinBorderWidth:1,kDefaultMovablePointColor:"yellow",kDefaultMovablePointRadius:8,kDefaultMovableLineColor:"steelblue",kMovableLineHighlightColor:"rgba(70, 30, 180, 0.2)",kMovableValueCapSize:6,kDefaultLSRLColor:"green",kLineHighlightColor:"rgba(255, 0, 0, 0.3)",kPlotCellFill:"rgba(128, 128, 128, 0)",kPlotCellStroke:"#eee",kStrokeDarkerFactor:3,kPointRadiusLogBase:2,kPointRadiusMax:10,kPointRadiusMin:3,kPointRadiusSelectionAddend:1,kDefaultPointColor:"#e6805b",kDefaultStrokeColor:"white",kDefaultStrokeColorWithLegend:"lightgrey",kDefaultPointOpacity:0.85,kDefaultStrokeOpacity:0.4,kDefaultStrokeOpacityWithLegend:0.4,kDefaultStripWidth:4,kMarqueeColor:"rgba(128, 128, 128, 0.3)",kDotClassName:"dg-data-dot",kSelectedDotClassName:"dg-data-dot-selected",kColoredDotClassName:"dg-data-dot-colored",kSelectedColoredDotClassName:"dg-data-dot-colored-selected",kDotClasses:["dg-data-dot","dg-data-dot-selected","dg-data-dot-colored","dg-data-dot-colored-selected"],kToolTipClassName:"dg-data-tip",kToolTipShadowClassName:"dg-data-tip-shadow",kToolTipTextClassName:"dg-data-tip-text",kStripClassName:"dg-data-strip",kSelectedStripClassName:"dg-data-strip-selected",kColoredStripClassName:"dg-data-strip-colored",kSelectedColoredStripClassName:"dg-data-strip-colored-selected",kLegendKey:"legend-key",kLegendKeySelected:"legend-key-selected",kLegendKeyName:"legend-key-name",kMapColorRangeOffset:0,kDefaultAnimationTime:1000,kDataTipShowTime:500,kHighlightShowTime:100,kHighlightHideTime:250,kDataHoverTransform:"s1.5",kDataCreateTransform:"s2",kBoxplotMaxWidth:20,kMovableRegionOpacity:0.3,kOther:"_other_",kDefaultMapFillOpacity:"0.5",kDefaultMapStrokeColor:"white",kDefaultMapStrokeOpacity:"0.6",kMapAreaNoLegendColor:"#FF3E00",kMapAreaNoLegendSelectedColor:"#1a7a93",kMapAreaNoLegendUnselectedOpacity:0.5,kMapAreaNoLegendSelectedOpacity:0.7,kMapAreaWithLegendSelectedOpacity:0.9,kMapAreaWithLegendUnselectedOpacity:0.9,kMapAreaNoLegendSelectedBorderColor:"black",kMapAreaWithLegendUnselectedBorderColor:"white",kMapAreaWithLegendSelectedBorderColor:"red",kMapAreaSelectedBorderWeight:3,kMapAreaUnselectedBorderWeight:2,lineToAxisIntercepts:function(i,b,e,c){function j(){return{left:e.get("lowerBound"),top:c.get("upperBound"),right:e.get("upperBound"),bottom:c.get("lowerBound")}}var h,d,g,a,k=j();if(Math.abs(i)>1){d=k.bottom;h=(d-b)/i;if(h<k.left){h=k.left;d=i*h+b}else{if(h>k.right){h=k.right;d=i*h+b}}a=k.top;g=(a-b)/i;if(g>k.right){g=k.right;a=i*g+b}else{if(g<k.left){g=k.left;a=i*g+b}}}else{h=k.left;d=i*h+b;if(d<k.bottom){d=k.bottom;h=(d-b)/i}else{if(d>k.top){d=k.top;h=(d-b)/i}}g=k.right;a=i*g+b;if(a>k.top){a=k.top;g=(a-b)/i}else{if(a<k.bottom){a=k.bottom;g=(a-b)/i}}}if(h>g){var f=h;h=g;g=f;f=d;d=a;a=f}return{pt1:{x:h,y:d},pt2:{x:g,y:a}}},closestScreenPtGivenScreenPtAndWorldLine:function(g,a,h,f){var e=h.coordinateToData(g.x),d=f.coordinateToData(g.y),c=(a.slope===0)?e:(d-a.intercept+(e/a.slope))/(a.slope+(1/a.slope)),b=a.slope*c+a.intercept;return{x:h.dataToCoordinate(c),y:f.dataToCoordinate(b)}},lineIntersectsPlotArea:function(b,f,g,d){DG.assert(isFinite(b));var h=g.get("lowerBound"),a=g.get("upperBound"),c=d.get("lowerBound"),e=d.get("upperBound");return DG.MathUtilities.isInRange(b*h+f,c,e)||DG.MathUtilities.isInRange(b*a+f,c,e)||DG.MathUtilities.isInRange((c-f)/b,h,a)||DG.MathUtilities.isInRange((e-f)/b,h,a)},isPointInPlotArea:function(b,c,a){return DG.MathUtilities.isInRange(b.x,c.get("lowerBound"),c.get("upperBound"))&&DG.MathUtilities.isInRange(b.y,a.get("lowerBound"),a.get("upperBound"))},findFractionDigitsForAxis:function(d){if(!d){return null}var b=(d.get("pixelMin")+d.get("pixelMax"))/2,c=d.coordinateToData(b)-d.coordinateToData(b+1),a=Math.floor(Math.log(Math.abs(c))/Math.LN10);return Math.max(-a,0)},findFractionDigitsForRange:function(a){return(a.max-a.min===0)?2:Math.max(-Math.floor(Math.log((a.max-a.min)/1000)/Math.LN10),0)},findNeededFractionDigits:function(m,b,a,j){var g=12,n=a.get("model"),h=j.get("model"),p,d,c,l,f,i=2,o=(m<0.001&&m!==0)?Math.abs(Math.floor(Math.log10(Math.abs(m))))+1:3;function k(q){q.pt1.x=a.dataToCoordinate(q.pt1.x);q.pt1.y=j.dataToCoordinate(q.pt1.y);q.pt2.x=a.dataToCoordinate(q.pt2.x);q.pt2.y=j.dataToCoordinate(q.pt2.y);return q}function e(){var q;q=Math.max(Math.abs(d.pt1.x-p.pt1.x),Math.abs(d.pt1.y-p.pt1.y));q=Math.max(q,Math.abs(d.pt2.x-p.pt2.x));q=Math.max(q,Math.abs(d.pt2.y-p.pt2.y));return q}if(isNaN(m)||isNaN(b)||SC.none(m)||SC.none(b)){return{slopeDigits:0,interceptDigits:0}}p=k(DG.PlotUtilities.lineToAxisIntercepts(m,b,n,h));do{l=DG.MathUtilities.roundToSignificantDigits(b,i);d=k(DG.PlotUtilities.lineToAxisIntercepts(m,l.roundedValue,n,h));c=e();if(c>1){i+=1}}while((c>1)&&(i<g));do{f=DG.MathUtilities.roundToSignificantDigits(m,o);d=k(DG.PlotUtilities.lineToAxisIntercepts(f.roundedValue,b,n,h));c=e();if(c>1){o+=1}}while((c>1)&&(o<g));if(Math.abs(m)>1){o=Math.max(0,o-Math.floor(Math.log(Math.abs(m))/Math.LN10)-1)}if(Math.abs(b)>1){i=Math.max(0,i-Math.floor(Math.log(Math.abs(b))/Math.LN10)-1)}return{slopeDigits:o,interceptDigits:i}},getFormattedNumericValue:function(e,c){var a,b,d="";if(!SC.empty(e)){a=c();if(SC.none(a)){a=2}b=DG.Format.number().fractionDigits(0,a);b.group("");d=b(e)}return d},getFormattedCaseValue:function(a,d,e,i){i=!SC.none(i)?i:0;var f=d.get("attributes"),k=SC.isArray(f)?f[i]:null,j=k?f[i].get("id"):null,l=d.get("attributeType"),c=a&&!SC.none(j)&&a.getValue(j),h=k.get("type"),b,g;if(SC.empty(c)){return""}switch(l){case DG.Analysis.EAttributeType.eNumeric:c=a.getForcedNumericValue(j);b=e();if(SC.none(b)){b=2}if((h===DG.Attribute.TYPE_NUMERIC)&&DG.MathUtilities.notAYear(c)){c=Intl.NumberFormat(DG.get("currentLanguage"),{maximumFractionDigits:b}).format(c)}else{g=DG.Format.number().fractionDigits(0,b);g.group("");c=g(c)}break;case DG.Analysis.EAttributeType.eDateTime:c=DG.DateUtilities.formatDate(c);break;default:c=a.getStrValue(j)}return c},doCreateCircleAnimation:function(a){},doHideRemoveAnimation:function(a,b){if(a){a.attr({"fill-opacity":0,opacity:0});a.hide();if(a.events){a.events.forEach(function(c){c.unbind()});a.events.length=0}if(b){b.removeElement(this)}}},setPlottedPointAttributes:function(a,c){var b=a.node,h=a.attrs,d=Raphael,i="hasOwnProperty";for(var e in c){if(c[i](e)){if(!d._availableAttrs[i](e)){continue}if(a.attr(e)===c[e]){continue}var g=c[e];h[e]=g;switch(e){case"cursor":b.style.cursor=g;break;case"transform":a.transform(g);break;case"cx":case"cy":case"x":case"y":case"width":case"height":if(isFinite(g)){b.setAttribute(e,g);a._.dirty=1}break;case"r":if(a.type=="rect"){$(b,{rx:g,ry:g})}else{b.setAttribute(e,g)}a._.dirty=1;break;case"stroke-width":b.setAttribute(e,g);break;case"fill":var j=d.getRGB(g);if(!j.error){delete c.gradient;delete h.gradient;!d.is(h.opacity,"undefined")&&d.is(c.opacity,"undefined")&&$(b,{opacity:h.opacity});!d.is(h["fill-opacity"],"undefined")&&d.is(c["fill-opacity"],"undefined")&&$(b,{"fill-opacity":h["fill-opacity"]})}j[i]("opacity")&&$(b,{"fill-opacity":j.opacity>1?j.opacity/100:j.opacity});case"stroke":j=d.getRGB(g);b.setAttribute(e,j.hex);e=="stroke"&&j[i]("opacity")&&$(b,{"stroke-opacity":j.opacity>1?j.opacity/100:j.opacity});break;case"opacity":if(h.gradient&&!h[i]("stroke-opacity")){$(b,{"stroke-opacity":g>1?g/100:g})}default:e=="font-size"&&(g=parseInt(g,10)+"px");var f=e.replace(/(\-.)/g,function(k){return k.substring(1).toUpperCase()});b.style[f]=g;a._.dirty=1;b.setAttribute(e,g);break}}}},mapAxisViewClassToAxisModelClass:function(a){var b=DG.AxisModel;switch(a){case DG.CellAxisView:b=DG.CellAxisModel;break;case DG.CellLinearAxisView:case DG.QualCellLinearAxisView:b=DG.CellLinearAxisModel;break;case DG.CountAxisView:b=DG.CountAxisModel;break;case DG.BinnedAxisView:b=DG.BinnedAxisModel;break;case DG.FormulaAxisView:b=DG.FormulaAxisModel;break}return b},swapCategoriesByIndex:function(g,f,d){var c=g.getPath("attribute.categoryMap"),b=c.__order||[],a=g.get("attribute");DG.assert(DG.ObjectMap.length(c)!==0);var e=b[f];b[f]=b[d];b[d]=e;g.setPath("attribute.categoryMap",c);a.notifyPropertyChange("categoryMap");g.invalidateCaches()}};sc_require("components/graph/adornments/twoD_line_adornment");sc_require("components/graph/utilities/plot_utilities");DG.LSRLAdornment=DG.TwoDLineAdornment.extend({defaultColor:DG.PlotUtilities.kDefaultLSRLColor,confidenceBandCurve:null,confidenceBandCurveCover:null,confidenceBandShading:null,lineColor:function(){var b=this.getPath("model.plotModel.dataConfiguration.legendAttributeDescription");if(!b||b.isNull()||b.get("isNumeric")||b.get("isColor")){return arguments.callee.base.apply(this,arguments)}var a=DG.ColorUtilities.calcCaseColor(this.getPath("model.categoryName"),b);a=a.colorString||a;return a}.property(),_infoTip:null,infoTip:function(){if(!this._infoTip){var a=this;this._infoTip=DG.InfoTip.create({paperSource:function(){return a.get("paperSource")}.property()})}return this._infoTip}.property(),equationString:function(){var c=arguments.callee.base.apply(this,arguments),a='<p style = "color:%@;">r<sup>2</sup> = %@</p>',b='<p style = "color:%@;">&sigma;<sub style="vertical-align: sub">slope</sub> = %@</p>',d='<p style = "color:%@;">&sigma;<sub style="vertical-align: sub">intercept</sub> = %@</p>';if(!this.getPath("model.isInterceptLocked")){var g=this.get("equationColor"),i=DG.Format.number().fractionDigits(0,3),k=this.getPath("model.rSquared"),h=SC.none(k)?"":i(k),f=this.getPath("model.seSlope"),j=SC.none(f)?"":b.loc(g,i(f)),e=this.getPath("model.seIntercept"),l=SC.none(e)?"":d.loc(g,i(e));c=c+a.loc(g,h)+j+l+this.get("sumResidSquaredString")}return c}.property(),updateToModel:function(){this.positionEquationAndBackground()},createElements:function(){arguments.callee.base.apply(this,arguments);var d=this;function c(j){if(d.getPath("model.showConfidenceBands")){d.get("infoTip").show({x:j.offsetX-5,y:j.offsetY-5,tipString:"DG.ScatterPlotModel.LSRLCIBandInfo".loc()})}}function i(){d.get("infoTip").hide()}var f=this.get("paper"),a=this.getPath("paperSource.layerManager")[DG.LayerNames.kDataTip],g=this.getPath("paperSource.layerManager")[DG.LayerNames.kAdornments],h=this.getPath("paperSource.layerManager")[DG.LayerNames.kConnectingLines],e=this.get("lineColor"),b=tinycolor(e).lighten(10).toHexString();this.confidenceBandCurve=f.path("M,0,0").attr({stroke:b,"stroke-opacity":0,"stroke-dasharray":"- "});this.confidenceBandCurve.animatable=true;this.confidenceBandCurveCover=f.path("M,0,0").attr({stroke:e,"stroke-opacity":0.001,"stroke-width":6});this.confidenceBandCurveCover.animatable=false;this.confidenceBandShading=f.path("M,0,0").attr({fill:e,"stroke-width":0,"fill-opacity":0}).hover(c,i);this.confidenceBandShading.animatable=true;this.myElements=this.myElements.concat([this.confidenceBandCurve,this.confidenceBandCurveCover,this.confidenceBandShading]);a.push(this.confidenceBandCurveCover);g.push(this.confidenceBandCurve);h.push(this.confidenceBandShading)},positionEquationAndBackground:function(){arguments.callee.base.apply(this,arguments);var m=DG.PlotUtilities.kDefaultAnimationTime;if(!this.getPath("model.showConfidenceBands")){this.confidenceBandCurve.animate({"stroke-opacity":0},m,"<>");this.confidenceBandCurveCover.attr({path:"M,0,0"});this.confidenceBandShading.animate({"fill-opacity":0},m,"<>");return}var n=this.getPath("model.count"),p={count:n,sumSquaresX:this.getPath("model.xSumSquaredDeviations"),xMean:this.getPath("model.xMean"),slope:this.getPath("model.slope"),intercept:this.getPath("model.intercept"),mse:this.getPath("model.mse"),t:DG.MathUtilities.tAt0975ForDf(n-2)};function k(q){var t=p.intercept+p.slope*q,s=1/p.count+Math.pow(q-p.xMean,2)/p.sumSquaresX,r=p.t*Math.sqrt(p.mse*s);return{lower:t-r,upper:t+r}}var e=this.getPath("paperSource.xAxisView"),o=this.getPath("paperSource.yAxisView"),b=e.get("pixelMin"),c=e.get("pixelMax"),g=[],j=[],d="",i="",l,f,h;for(h=b;h<=c;h+=10){l=e.coordinateToData(h);f=k(l);g.push({left:h,top:o.dataToCoordinate(f.upper)});j.unshift({left:h,top:o.dataToCoordinate(f.lower)})}if(g.length>0){d="M"+g[0].left+","+g[0].top+DG.SvgScene.curveBasis(g);i="M"+j[0].left+","+j[0].top+DG.SvgScene.curveBasis(j)}var a=d+i.replace("M","L")+" Z";this.confidenceBandCurve.attr({path:d+i});this.confidenceBandCurveCover.attr({path:d+i});this.confidenceBandShading.attr({path:a});this.confidenceBandShading.animate({"fill-opacity":0.05},m,"<>")}});sc_require("components/graph/adornments/plot_adornment_model");DG.TwoDLineModel=DG.PlotAdornmentModel.extend({slope:null,intercept:null,isVertical:false,xIntercept:null,showSumSquares:false,sumSquaresResiduals:null,equationCoords:null,isInterceptLocked:function(b,a){if(a!==undefined){this._interceptLocked=a;this.setComputingNeeded();if(a){this.set("intercept",0)}}return this._interceptLocked}.property(),toggleInterceptLocked:function(){this.set("isInterceptLocked",!this._interceptLocked)},_interceptLocked:null,init:function(){arguments.callee.base.apply(this,arguments);this.slope=1;this.isVertical=false;this.xIntercept=null;this._interceptLocked=false;this._needsComputing=true},recomputeSlopeAndInterceptIfNeeded:function(c,a,b){if(this.isComputingNeeded(c,a)){this.recomputeSlopeAndIntercept(c,a,b);this._needsComputing=false}},getCoordinates:function(){var f=[],d=this.get("cases"),a=this.getPath("plotModel.xVarID"),e=this.getPath("plotModel.yVarID"),b=this.getPath("plotModel.legendVarID"),c=this.getPath("plotModel.dataConfiguration.legendAttributeDescription.isNumeric");if(!SC.none(d)){d.forEach(function(i){var h=i.getForcedNumericValue(a),g=i.getForcedNumericValue(e),j=c?null:i.getValue(b);if(isFinite(h)&&isFinite(g)){f.push({x:h,y:g,legend:j})}})}return f},createStorage:function(){var a=arguments.callee.base.apply(this,arguments);DG.ObjectMap.copy(a,{isInterceptLocked:this.get("isInterceptLocked"),equationCoords:this.get("equationCoords")});return a},restoreStorage:function(a){arguments.callee.base.apply(this,arguments);if(a){this.set("isInterceptLocked",a.isInterceptLocked);if(a.equationCoords){this.set("equationCoords",a.equationCoords)}}}});sc_require("components/graph/adornments/twoD_line_model");DG.LSRLModel=DG.TwoDLineModel.extend({showConfidenceBands:false,categoryName:null,rSquared:null,sdResiduals:null,seSlope:null,seIntercept:null,getCoordinates:function(){var b=arguments.callee.base.apply(this,arguments),a=this.get("categoryName");return b.filter(function(c){return SC.none(c.legend)||a==c.legend||a==="_main_"})},computeSumSquaresResiduals:function(){var c=0,a=this.get("slope"),b=this.get("intercept");this.getCoordinates().forEach(function(d){var e=b+a*d.x,f=d.y-e;c+=f*f});this.setIfChanged("sumSquaresResiduals",c)},recomputeSlopeAndIntercept:function(){var b=this.get("isInterceptLocked"),c=this.getCoordinates(),a,e,d;a=DG.MathUtilities.leastSquaresLinearRegression(c,b);e=this.get("showConfidenceBands")?DG.MathUtilities.linRegrSESlopeAndIntercept(c).seSlope:null;d=this.get("showConfidenceBands")?DG.MathUtilities.linRegrSESlopeAndIntercept(c).seIntercept:null;if(isNaN(a.slope)&&isNaN(this.get("slope"))||isNaN(a.intercept)&&isNaN(this.get("intercept"))){return}this.beginPropertyChanges();this.setIfChanged("count",a.count);this.setIfChanged("slope",a.slope);this.setIfChanged("intercept",a.intercept);this.setIfChanged("mse",a.mse);this.setIfChanged("xMean",a.xMean);this.setIfChanged("yMean",a.yMean);this.setIfChanged("xSumSquaredDeviations",a.xSumSquaredDeviations);this.setIfChanged("rSquared",a.rSquared);this.setIfChanged("seSlope",e);this.setIfChanged("seIntercept",d);this.setIfChanged("isVertical",!isFinite(a.slope));this.setIfChanged("xIntercept",null);this.computeSumSquaresResiduals();this.endPropertyChanges()},createStorage:function(){var a=arguments.callee.base.apply(this,arguments);a.showConfidenceBands=this.showConfidenceBands;return a},restoreStorage:function(a){arguments.callee.base.apply(this,arguments);this.showConfidenceBands=a.showConfidenceBands}});sc_require("components/graph/adornments/twoD_line_adornment");sc_require("components/graph/utilities/plot_utilities");DG.MovableLineAdornment=DG.TwoDLineAdornment.extend({defaultColor:DG.PlotUtilities.kDefaultMovableLineColor,kLineSlideCur:DG.Browser.customCursorStr("../../../../static/dg/fr/cert/resources/cursors/LineSlide.cur",8,8),kLineBotLeft:DG.Browser.customCursorStr("../../../../static/dg/fr/cert/resources/cursors/LinePivotBotLeft.cur",5,12),kLineBotRight:DG.Browser.customCursorStr("../../../../static/dg/fr/cert/resources/cursors/LinePivotBotRight.cur",12,12),kLineTopLeft:DG.Browser.customCursorStr("../../../../static/dg/fr/cert/resources/cursors/LinePivotTopLeft.cur",5,5),kLineTopRight:DG.Browser.customCursorStr("../../../../static/dg/fr/cert/resources/cursors/LinePivotTopRight.cur",12,5),kHandleSize:12,hitHandles:null,hitSegments:null,equationString:function(){var a=arguments.callee.base.apply(this,arguments);return a+this.get("sumResidSquaredString")}.property(),pivot1:null,pivot2:null,createElements:function(){var e=this,k=this.get("xAxisView"),a=this.get("yAxisView"),q,f,s=false;function g(){var w=e.get("equationString");w=w.replace(/\u2212/g,"-");DG.logUser("dragMovableLine: '%@'",w)}function m(){var w={stroke:DG.PlotUtilities.kLineHighlightColor};e.hitSegments.forEach(function(x){x.stop();x.animate(w,DG.PlotUtilities.kHighlightShowTime)})}function i(){var w={stroke:DG.RenderingUtilities.kSeeThrough};if(!s){e.hitSegments.forEach(function(x){x.stop();x.animate(w,DG.PlotUtilities.kHighlightHideTime)})}}function d(y,x){var w={slope:e.getPath("model.slope"),intercept:e.getPath("model.intercept")};q=DG.ViewUtilities.windowToViewCoordinates({x:y,y:x},e.parentView);if(e.getPath("model.isVertical")){q.x=k.dataToCoordinate(e.getPath("model.xIntercept"))}else{q=DG.PlotUtilities.closestScreenPtGivenScreenPtAndWorldLine(q,w,k,a)}f=e.getPath("model.isInterceptLocked");m();s=true}function h(x,w){e.get("model").forceThroughPoint({x:k.coordinateToData(q.x+x),y:a.coordinateToData(q.y+w)})}function v(x,w){e.pivot1=e.pivot2=null;e.updateToModel();g();s=false;i()}function l(x,w){d(x,w)}function r(A,y,w,z){var x=2;if(Math.abs(w.x-z.x)<x){A.x=y.x}else{if(Math.abs(w.y-z.y)<x){A.y=y.y}}e.get("model").forceThroughPoints(e.pivot1,e.pivot2)}function c(z,x){var y={x:q.x+z,y:q.y+x},w={x:k.dataToCoordinate(e.pivot2.x),y:a.dataToCoordinate(e.pivot2.y)};e.pivot1.x=k.coordinateToData(y.x);e.pivot1.y=a.coordinateToData(y.y);if(f){e.get("model").forceThroughOriginAndPoint(e.pivot1)}else{r(e.pivot1,e.pivot2,y,w)}}function b(z,x){var y={x:q.x+z,y:q.y+x},w={x:k.dataToCoordinate(e.pivot1.x),y:a.dataToCoordinate(e.pivot1.y)};e.pivot2.x=k.coordinateToData(y.x);e.pivot2.y=a.coordinateToData(y.y);if(f){e.get("model").forceThroughOriginAndPoint(e.pivot2)}else{r(e.pivot2,e.pivot1,y,w)}}function o(y,x){if(e.pivot1.x>e.pivot2.x){var w=e.pivot1;e.pivot1=e.pivot2;e.pivot2=w}g();s=false;i()}if(this.myElements&&(this.myElements.length>0)){return}arguments.callee.base.apply(this,arguments);var u=this.get("paper"),t=this.getPath("paperSource.layerManager")[DG.LayerNames.kDataTip];this.hitHandles=[0,1,2].map(function(w){return u.rect(0,0,this.kHandleSize,this.kHandleSize).addClass("dg-movable-line-handle").attr({fill:"#FFF","fill-opacity":1})}.bind(this));var p=[c,h,b],j=[l,d,l],n=[o,v,o];this.hitSegments=[0,1,2].map(function(w){return this.lineSeg.clone().attr({"stroke-width":12,stroke:DG.RenderingUtilities.kSeeThrough}).hover(m,i).drag(p[w],j[w],n[w])}.bind(this));this.hitHandles.concat(this.hitSegments).forEach(function(w){this.myElements.push(w);t.push(w)}.bind(this));return this.myElements},updateToModel:function(){if(!this.getPath("model.isVisible")){return}if(this.myElements===null){this.createElements()}var g=this.get("xAxisView"),a=this.get("yAxisView"),e=this.get("layer"),i=this.get("model"),o=i.get("slope"),c=i.get("isInterceptLocked"),p=i.get("intercept"),h=g.getPath("model.lowerBound"),m=g.getPath("model.upperBound"),n=a.getPath("model.lowerBound"),r=a.getPath("model.upperBound"),f=(i.get("isVertical"))?{pt1:{x:i.get("xIntercept"),y:n},pt2:{x:i.get("xIntercept"),y:r}}:DG.PlotUtilities.lineToAxisIntercepts(o,p,g.get("model"),a.get("model"));function b(s){return{x:g.dataToCoordinate(s.x),y:a.dataToCoordinate(s.y)}}function d(){var s=f.pt1;f.pt1=f.pt2;f.pt2=s}if(f.pt2.x<f.pt1.x){d()}var l,j;if(c){if((h<=0)&&(m>=0)&&(n<=0)&&(r>=0)){l={x:0,y:0};j=l}else{if(o>=0){if((r<0)||(m<0)){l=j=f.pt2}else{l=j=f.pt1}}else{if((n>0)||(m<0)){l=j=f.pt2}else{l=j=f.pt1}}}}else{l={x:f.pt1.x+(3/8)*(f.pt2.x-f.pt1.x),y:f.pt1.y+(3/8)*(f.pt2.y-f.pt1.y)};j={x:f.pt1.x+(5/8)*(f.pt2.x-f.pt1.x),y:f.pt1.y+(5/8)*(f.pt2.y-f.pt1.y)}}if(SC.none(this.pivot1)||!DG.MathUtilities.isInRange(this.pivot1.x,h,m)||!DG.MathUtilities.isInRange(this.pivot1.y,n,r)){this.pivot1=f.pt1}if(SC.none(this.pivot2)||!DG.MathUtilities.isInRange(this.pivot2.x,h,m)||!DG.MathUtilities.isInRange(this.pivot2.y,n,r)){this.pivot2=f.pt2}var q=[f.pt1,l,j,f.pt2].map(function(s){return b(s)});DG.RenderingUtilities.updateLine(this.lineSeg,q[0],q[3]);this.hitHandles.forEach(function(u,s){var t=(q[s].x+q[s+1].x)/2,v=(q[s].y+q[s+1].y)/2;e.bringToFront(u);u.attr({x:t-this.kHandleSize/2,y:v-this.kHandleSize/2})}.bind(this));this.hitSegments.forEach(function(t,s){DG.RenderingUtilities.updateLine(t,q[s],q[s+1])});var k=o>0?[this.kLineBotLeft,this.kLineSlideCur,this.kLineTopRight]:[this.kLineTopLeft,this.kLineSlideCur,this.kLineBotRight];this.hitSegments.forEach(function(t,s){e.bringToFront(t);t.attr({cursor:k[s]})});this.positionEquationAndBackground()},updateVisibility:function(){if(this.getPath("model.isVisible")){this.pivot1=this.pivot2=null}arguments.callee.base.apply(this,arguments)}});sc_require("components/graph/adornments/twoD_line_model");DG.MovableLineModel=DG.TwoDLineModel.extend({isComputingNeeded:function(b,a){b=b||this.getPath("plotModel.xAxis");a=a||this.getPath("plotModel.yAxis");if(this._needsComputing){return true}if(this.isVertical){this._needsComputing=(this.xIntercept<b.get("lowerBound"))||(this.xIntercept>b.get("upperBound"))}else{this._needsComputing=!DG.PlotUtilities.lineIntersectsPlotArea(this.slope,this.intercept,b,a)}return this._needsComputing},slopeOrInterceptChanged:function(){var b=this.get("slope"),a=this.get("intercept"),c=0;if(this.get("showSumSquares")){if(this.get("isVertical")){c=Infinity}else{this.getCoordinates().forEach(function(d){var e=a+b*d.x,f=d.y-e;c+=f*f})}this.set("sumSquaresResiduals",c)}}.observes("slope","intercept","showSumSquares"),recomputeSlopeAndIntercept:function(f,c){f=f||this.getPath("plotModel.xAxis");c=c||this.getPath("plotModel.yAxis");var b=f.get("lowerBound"),e=f.get("upperBound"),a=c.get("lowerBound"),d=c.get("upperBound");e=b+(e-b)/2;if(!this.get("isInterceptLocked")){this.beginPropertyChanges();this.set("slope",(d-a)/(e-b));this.set("intercept",a-this.slope*b);this.set("isVertical",false);this.set("xIntercept",null);this.endPropertyChanges()}else{this.forceThroughOriginAndPoint({x:e,y:(d+a)/2})}this._needsComputing=false},forceThroughPoint:function(b){if(this.isVertical){this.set("xIntercept",b.x)}else{var a=this.get("slope"),c=b.y-a*b.x;this.set("intercept",c)}},forceThroughPoints:function(c,b){if(c.x===b.x){this.beginPropertyChanges();this.set("isVertical",true);this.set("xIntercept",c.x);this.set("slope",null);this.set("intercept",null);this.endPropertyChanges()}else{var a=(b.y-c.y)/(b.x-c.x);this.beginPropertyChanges();this.set("slope",a);this.set("intercept",c.y-a*c.x);this.set("isVertical",false);this.set("xIntercept",null);this.endPropertyChanges()}},forceThroughOriginAndPoint:function(a){this.forceThroughPoints(a,{x:0,y:0})},createStorage:function(){var a=arguments.callee.base.apply(this,arguments);DG.ObjectMap.copy(a,{intercept:this.get("intercept"),slope:this.get("slope"),isVertical:this.get("isVertical"),xIntercept:this.get("xIntercept")});return a},restoreStorage:function(a){arguments.callee.base.apply(this,arguments);this.set("intercept",a.intercept);this.set("slope",a.slope);this.set("isVertical",a.isVertical);this.set("xIntercept",a.xIntercept);this._needsComputing=false}});DG.LayerNames={kBackgroundImage:"backgroundImage",kBackground:"background",kGrid:"grid",kIntervalShading:"intervalShading",kClick:"click",kGhost:"ghost",kConnectingLines:"connectingLines",kPoints:"points",kSelectedPoints:"selectedPoints",kAdornments:"adornments",kDataTip:"dataTip",kCoverRects:"coverRects"};sc_require("components/graph/utilities/plot_utilities");sc_require("components/graph_map_common/layer_names");DG.MovablePointAdornment=DG.PlotAdornment.extend({defaultColor:DG.PlotUtilities.kDefaultMovablePointColor,defaultRadius:DG.PlotUtilities.kDefaultMovablePointRadius,modelPropertiesToObserve:[["coordinates","updateToModel"]],layerName:DG.LayerNames.kDataTip,opacity:0.6,strokeOpacity:0.8,point:null,shadow:null,dataTip:function(){if(!this._dataTip){this._dataTip=DG.MovablePointDataTip.create({plotLayer:this.get("paperSource"),layerName:DG.LayerNames.kDataTip,movablePoint:this.get("model")})}return this._dataTip}.property(),dragging:false,createElements:function(){var e=this.get("xAxisView"),j=this.get("yAxisView"),a,c;var b=function(){this.get("dataTip").show(this.point.attr("cx"),this.point.attr("cy"),this.point.attr("r"))}.bind(this),k=function(){this.get("dataTip").hide()}.bind(this),f=function(m,l){a=this.getPath("model.coordinates");c=DG.ViewUtilities.windowToViewCoordinates({x:m,y:l},this.parentView);b();this.set("dragging",true)}.bind(this),g=function(m,l){this.setPath("model.coordinates",{x:e.coordinateToData(c.x+m),y:j.coordinateToData(c.y+l)})}.bind(this),h=function(o,n){var l=a,m;DG.UndoHistory.execute(DG.Command.create({name:"graph.moveMovablePoint",undoString:"DG.Undo.graph.moveMovablePoint",redoString:"DG.Redo.graph.moveMovablePoint",log:"Moved movable point from %@ to %@".fmt(l,this.getPath("model.coordinates")),executeNotification:{action:"notify",resource:"component",values:{operation:"drag movable point",type:"DG.GraphView"}},execute:function(){m=this.getPath("model.coordinates")}.bind(this),undo:function(){this.setPath("model.coordinates",l)}.bind(this),redo:function(){this.setPath("model.coordinates",m)}.bind(this)}));this.set("dragging",false)}.bind(this);if(this.myElements&&(this.myElements.length>0)){return}var i=this.get("layer"),d=this.get("paper");this.point=d.circle(0,0,this.defaultRadius).attr({fill:this.defaultColor,opacity:0,stroke:"black","stroke-opacity":0,cursor:"move"}).drag(g,f,h).hover(b,k);this.point.animatable=true;this.point.node.setAttribute("shape-rendering","geometricPrecision");this.shadow=d.circle(0,0,this.defaultRadius).attr({"stroke-width":2,stroke:"darkgray","stroke-opacity":0});this.shadow.animatable=true;this.shadow.node.setAttribute("shape-rendering","geometricPrecision");this.myElements=[this.shadow,this.point];this.myElements.forEach(function(l){i.push(l)});return this.myElements},updateToModel:function(){if(!this.getPath("model.isVisible")){return}if(this.myElements===null){this.createElements()}var d=this.get("xAxisView"),h=this.get("yAxisView"),f=this.get("model"),e=f.get("coordinates"),i=a(e),c=this.get("point"),b=this.get("shadow"),g=this.get("layer");function a(j){return{cx:d.dataToCoordinate(j.x),cy:h.dataToCoordinate(j.y)}}if(this.get("dragging")||c.attr("opacity")===0){c.attr(i);b.attr({cx:i.cx+1,cy:i.cy+1})}else{c.animate(i,DG.PlotUtilities.kDefaultAnimationTime,"<>");b.animate({cx:i.cx+1,cy:i.cy+1},DG.PlotUtilities.kDefaultAnimationTime,"<>")}if(c.attr("opacity")===0){c.animate({opacity:this.opacity,"stroke-opacity":this.strokeOpacity},DG.PlotUtilities.kDefaultAnimationTime,"<>");b.animate({"stroke-opacity":0.8},DG.PlotUtilities.kDefaultAnimationTime,"<>")}g.bringToFront(b);g.bringToFront(c)}});sc_require("components/graph/adornments/data_tip");DG.MovablePointDataTip=DG.DataTip.extend({movablePoint:null,coordinatesDidChange:function(){this.updateTip()}.observes("movablePoint.coordinates"),getDataTipText:function(){var c=this.getPath("plotLayer.graphModel"),d=this.getPath("movablePoint.coordinates"),a=function(j){var m=function(){return DG.PlotUtilities.findFractionDigitsForAxis(this.getPath("plotLayer."+j+"AxisView"))}.bind(this),k=c.getPath("dataConfiguration."+j+"AttributeDescription"),g=k.get("attribute"),h=g?g.get("id"):null,n=k.get("attributeType")===DG.Analysis.EAttributeType.eDateTime,i,l;if(!SC.none(h)){i=g.get("name");l=n?DG.DateUtilities.formatDate(d[j]):DG.PlotUtilities.getFormattedNumericValue(d[j],m);return i+": "+l}return null}.bind(this),f="";if(!this.get("showOnlyLegendData")){var b=a("x"),e=a("y");f=SC.none(b)?"":b;if(!SC.none(e)){if(f.length>0){f+="\n"}f+=e}}return f},show:function(a,d,c,b){this.set("tipOrigin",{x:a,y:d});this.set("tipSourceRadius",c);arguments.callee.base.apply(this,arguments)}});DG.MovablePointModel=DG.PlotAdornmentModel.extend({coordinates:null,isComputingNeeded:function(b,a){if(this._needsComputing){return true}this._needsComputing=!this.coordinates||(this.coordinates.x<b.get("lowerBound"))||(this.coordinates.x>b.get("upperBound"))||(this.coordinates.y<a.get("lowerBound"))||(this.coordinates.y>a.get("upperBound"));return this._needsComputing},recomputeCoordinates:function(f,c){var b=f.get("lowerBound"),e=f.get("upperBound"),a=c.get("lowerBound"),d=c.get("upperBound");this.set("coordinates",{x:e-(e-b)/3,y:d-(d-a)/3});this._needsComputing=false},recomputePositionIfNeeded:function(b,a){if(this.isComputingNeeded(b,a)){this.recomputeCoordinates(b,a)}},createStorage:function(){var a=arguments.callee.base.apply(this,arguments);DG.ObjectMap.copy(a,{coordinates:this.get("coordinates")});return a},restoreStorage:function(a){arguments.callee.base.apply(this,arguments);this.set("coordinates",a.coordinates)}});DG.ValueAxisViewMixin={valueAxisView:null,_observedAxisModel:null,_observedAxisView:null,initMixin:function(){this.axisViewDidChange();this.addObserver("valueAxisView",this,"axisViewDidChange")},destroyMixin:function(){this.set("valueAxisView",null);this.removeObserver("valueAxisView",this,"axisViewDidChange")},axisModelDidChange:function(){if(this._observedAxisModel){this._observedAxisModel.removeObserver("lowerBound",this,"updateToModel");this._observedAxisModel.removeObserver("upperBound",this,"updateToModel");this._observedAxisModel=null}var a=this.getPath("valueAxisView.model");if(a){a.addObserver("lowerBound",this,"updateToModel");a.addObserver("upperBound",this,"updateToModel");this._observedAxisModel=a}},axisViewDidChange:function(){if(this._observedAxisView){this._observedAxisView.removeObserver("model",this,"axisModelDidChange");this._observedAxisView.removeObserver("pixelMin",this,"updateToModel");this._observedAxisView.removeObserver("pixelMax",this,"updateToModel");this._observedAxisView=null}this.axisModelDidChange();var a=this.get("valueAxisView");if(a){a.addObserver("model",this,"axisModelDidChange");a.addObserver("pixelMin",this,"updateToModel");a.addObserver("pixelMax",this,"updateToModel");this._observedAxisView=a}},updateToModel:function(){}};sc_require("components/graph/adornments/plot_adornment");sc_require("components/graph/adornments/line_label_mixin");sc_require("components/graph/adornments/value_axis_view_mixin");DG.MovableValueAdornment=DG.PlotAdornment.extend(DG.LineLabelMixin,DG.ValueAxisViewMixin,{kLineSlideHCur:DG.Browser.customCursorStr("../../../../static/dg/fr/cert/resources/cursors/LineSlideH.cur",8,8),kLineSlideVCur:DG.Browser.customCursorStr("../../../../static/dg/fr/cert/resources/cursors/LineSlide.cur",8,8),valueElements:null,splitAxisView:function(){return this.getPath("parentView.secondaryAxisView")}.property(),orientation:function(){return this.getPath("valueAxisView.orientation")}.property(),orientationDidChange:function(){this.removeElements();this.updateToModel()}.observes("*valueAxisView.orientation"),screenCoord:function(a){return this.get("valueAxisView").dataToCoordinate(this.get("model").getValueForCategory(a))},valueStringForCategory:function(b){var a=function(){var h=this.getPath("valueAxisView.axisViewHelper"),e=h.getValueDisplayResolution(),g=new Date(d*1000),j=g.getFullYear(),k=DG.monthName(d),i=g.getDate(),f=g.getHours();switch(e){case"year":return String(j);case"month":return"DG.MovableMonthYear".loc(k,j);case"day":return g.toLocaleDateString();case"hour":return"DG.MovableMonthDayHour".loc(k,i,f);case"second":case"minute":return g.toLocaleTimeString()}return DG.DataUtilities.formatDate(d)}.bind(this),c=function(){var e=DG.PlotUtilities.findFractionDigitsForAxis(this.get("valueAxisView")),f=DG.Format.number().fractionDigits(0,e);if(d<2500){f.group("")}return f(d)}.bind(this);var d=this.get("model").getValueForCategory(b);if(this.getPath("valueAxisView.isDateTime")){return a()}else{return c()}},valueStringDidChange:function(){this.notifyPropertyChange("valueString")}.observes("*model.valueChange","*valueAxisView.model.firstAttributeName"),modelPropertiesToObserve:[["valueChange","updateToModel"],["removed","modelWasRemoved"]],modelWasRemoved:function(){this.detachModel()},createElements:function(){var f=this,g=this.get("paper"),k=this.get("layer"),c,e;function h(p,o){e=f.get("model").getValueForCategory(this._key);var q=DG.ViewUtilities.windowToViewCoordinates({x:p,y:o},f.parentView);c=(f.get("orientation")===DG.GraphTypes.EOrientation.kHorizontal)?q.x:q.y}function j(s,r){var p=f.get("valueAxisView"),o=(p.get("orientation")===DG.GraphTypes.EOrientation.kHorizontal)?s:r,q=p.coordinateToData(c+o,true);f.get("model").setValueForCategory(this._key,q)}function b(t,s){var p=e,o=this._key,r=f.get("model"),q;DG.logUser("dragMovableValue: '%@'",f.valueStringForCategory(o));DG.UndoHistory.execute(DG.Command.create({name:"graph.moveMovableValue",undoString:"DG.Undo.graph.moveMovableValue",redoString:"DG.Redo.graph.removeMovableValue",log:"Moved movable value from %@ to %@".fmt(p,r.getValueForCategory(o)),executeNotification:{action:"notify",resource:"component",values:{operation:"drag movable line",type:"DG.GraphView"}},execute:function(){q=r.getValueForCategory(o)},undo:function(){r.setValueForCategory(o,p)},redo:function(){r.setValueForCategory(o,q)}}))}function d(){var o=f.get("valueElements")[this._key].coverSeg,p={stroke:DG.PlotUtilities.kMovableLineHighlightColor};o.stop();o.animate(p,DG.PlotUtilities.kHighlightShowTime)}function n(){var o=f.get("valueElements")[this._key].coverSeg,p={stroke:DG.RenderingUtilities.kSeeThrough};o.stop();o.animate(p,DG.PlotUtilities.kHighlightHideTime)}if(this.myElements&&(this.myElements.length>0)){return}if(!g){return}var m=DG.PlotUtilities.kMovableValueCapSize,i=(this.get("orientation")===DG.GraphTypes.EOrientation.kHorizontal)?this.kLineSlideHCur:this.kLineSlideVCur,a=this.getPath("model.values"),l={};this.myElements=[];DG.ObjectMap.forEach(a,function(s,u){var q=g.line(0,0,0,0).attr({"stroke-opacity":0}).addClass("dg-graph-adornment-movable"),p=g.line(0,0,0,0).attr({"stroke-width":6,stroke:DG.RenderingUtilities.kSeeThrough,cursor:i,title:"Drag the value"}).hover(d,n).drag(j,h,b),r=g.rect(-20,0,m,m).attr({cursor:i,opacity:0}).drag(j,h,b).addClass("dg-graph-adornment-movable"),o=f.createBackgroundRect(),t=f.createTextElement();p._key=r._key=t._key=s;q.animatable=true;q.animate({"stroke-opacity":1},DG.PlotUtilities.kDefaultAnimationTime,"<>");t.animatable=true;t.attr({fill:DG.PlotUtilities.kDefaultMovableLineColor}).hover(d,n).drag(j,h,b);t.animate({opacity:1},DG.PlotUtilities.kDefaultAnimationTime,"<>");r.animatable=true;r.animate({opacity:1},DG.PlotUtilities.kDefaultAnimationTime,"<>");l[s]={lineSeg:q,coverSeg:p,cap:r,background:o,text:t};DG.ObjectMap.values(l[s]).forEach(function(v){f.myElements.push(v)})});this.myElements.forEach(function(o){k.push(o)});this.set("valueElements",l)},updateToModel:function(){var d=function(){var k=this.getPath("model.plotModel.secondaryAxisModel.attributeDescription.cellNames");if(!k||k.length===0){k=[DG.MovableValueModel.kSingleCellName]}return k}.bind(this),i=d(),j=this.get("valueElements");if(!this.myElements||i.some(function(k){return !j[k]})||Object.keys(j).some(function(k){return i.indexOf(k)<0})){this.removeElements();this.createElements()}var e=this,h=this.get("valueAxisView"),c=this.get("splitAxisView"),b=c&&c.get("fullCellWidth"),f=this.get("paper"),a=this.getPath("model.isVisible");if(!h||!f||!a||!c){return}var g=DG.PlotUtilities.kMovableValueCapSize/2;DG.ObjectMap.forEach(this.get("valueElements"),function(n,l){var s=e.get("model").getValueForCategory(n),q=h&&h.dataToCoordinate(s),u=c.cellNameToCoordinate(n),r,p,v,o,t=0,k=0,m;if(!DG.isFinite(u)||!DG.isFinite(q)){return}l.text.attr({text:e.valueStringForCategory(n)});o=l.text.getBBox();if(h.get("orientation")===DG.GraphTypes.EOrientation.kHorizontal){r={x:q,y:u+b/2};p={x:q,y:u-b/2+DG.MovableValueAdornment.kLabelSpace/2};v="middle";k=-4*g;m={x:q-o.width/2,y:p.y+k-o.height/2}}else{r={x:u-b/2,y:q};p={x:u+b/2-DG.MovableValueAdornment.kLabelSpace,y:q};v="start";t=2*g;m={x:p.x+t,y:p.y-o.height/2}}l.text.attr({x:p.x+t,y:p.y+k,"text-anchor":v});l.background.attr({x:m.x,y:m.y,width:o.width,height:o.height});DG.RenderingUtilities.updateLine(l.lineSeg,r,p);DG.RenderingUtilities.updateLine(l.coverSeg,r,p);l.cap.attr({x:p.x-g,y:p.y-g})})}});DG.MovableValueAdornment.kLabelSpace=50;sc_require("components/graph/adornments/plot_adornment_model");DG.MovableValueModel=DG.PlotAdornmentModel.extend({values:null,secondaryAxisAttributeDescription:function(){return this.getPath("plotModel.secondaryAxisModel.attributeDescription")}.property(),init:function(){arguments.callee.base.apply(this,arguments);this.createValuesObject()},createValuesObject:function(){var f=this.get("values"),c={},d=this.get("secondaryAxisAttributeDescription"),b=d&&d.get("cellNames");function a(){var g=(!b||b.length===0)?[DG.MovableValueModel.kSingleCellName]:b;var h=f&&Object.keys(f).every(function(i){return g.indexOf(i)>=0});h=h&&g.every(function(i){return f.hasOwnProperty(i)});return h}if(a()){return}if(b.length===0){c[DG.MovableValueModel.kSingleCellName]=null}else{var e=f&&f[DG.MovableValueModel.kSingleCellName];b.forEach(function(g){c[g]=e})}this.set("values",c)},getValueForCategory:function(a){var b=this.get("values");return b[a]},setValueForCategory:function(a,b){this.get("values")[a]=b;this.notifyPropertyChange("valueChange")},handleChangedAxisAttribute:function(a){this.createValuesObject();this.recomputeValue(a)},getAllValues:function(){return DG.ObjectMap.values(this.values)},setAllValues:function(a){DG.ObjectMap.forEach(this.values,function(b){this.values[b]=a}.bind(this));this.notifyPropertyChange("valueChange");this._needsComputing=false},recomputeValue:function(d,b){function a(h){return !SC.none(h)&&h>=c&&h<=g}var c=d.get("lowerBound"),g=d.get("upperBound"),f=false,e=Object.assign({},this.values);this.createValuesObject();DG.ObjectMap.forEach(this.values,function(i,l){if(i===DG.MovableValueModel.kSingleCellName&&!e.hasOwnProperty(i)){l=e[Object.keys(e)[0]];this.values[i]=l}var h=e[i];if(SC.none(l)&&a(h)){this.values[i]=h}else{if(!a(l)){var j=b&&b[i],k=SC.none(j)?c:j;this.values[i]=k+(g-k)/3;f=true}}}.bind(this));if(f){this.notifyPropertyChange("valueChange")}this._needsComputing=false},createStorage:function(){var a=arguments.callee.base.apply(this,arguments);if(this.get("isVisible")){a.values=this.get("values")}return a},restoreStorage:function(a){arguments.callee.base.apply(this,arguments);if(a){if(a.values){this.set("values",a.values)}else{if(a.value){var b={};b[DG.MovableValueModel.kSingleCellName]=a.value;this.set("values",b)}}this._needsComputing=false}return this}});DG.MovableValueModel.kSingleCellName="_main";DG.PlotAdornmentModel.registry.movableValue=DG.MovableValueModel;sc_require("components/graph/adornments/plot_adornment");DG.MultipleLSRLsAdornment=DG.PlotAdornment.extend({lsrlAdornments:null,init:function(){arguments.callee.base.apply(this,arguments);this.set("lsrlAdornments",[]);this.updateToModel()},destroy:function(){this.lsrlAdornments.forEach(function(a){a.destroy()});arguments.callee.base.apply(this,arguments)},modelPropertiesToObserve:[["lsrls","updateToModel"],["isInterceptLocked","updateToModel"],["showSumSquares","updateToModel"],["showConfidenceBands","updateToModel"]],updateToModel:function(){this.get("model").recomputeSlopeAndInterceptIfNeeded();var b=this.get("lsrlAdornments");var a=function(){var f=this.getPath("model.lsrls");b.forEach(function(h,g){if(g<f.length){h.set("model",f[g])}else{h.set("model",null)}});while(f.length>b.length){var c=DG.LSRLAdornment.create({parentView:this.get("parentView"),model:f[b.length],paperSource:this.get("paperSource"),layerName:DG.LayerNames.kAdornments});c.createElements();b.push(c)}while(f.length<b.length){var e=b.findIndex(function(g){return SC.none(g.get("model"))});if(e>=0){var d=b[e];b.splice(e,1);d.destroy()}}}.bind(this);a();b.forEach(function(c){c.updateToModel()})}});sc_require("components/graph/adornments/plot_adornment_model");DG.MultipleLSRLsModel=DG.PlotAdornmentModel.extend({lsrls:null,showSumSquares:false,isInterceptLocked:false,showConfidenceBands:false,numLegendCells:function(){var a=this.getPath("plotModel.dataConfiguration.legendAttributeDescription"),b=(SC.none(a)||a.get("isNumeric"))?1:a.getPath("attributeStats.numberOfCells");return SC.none(b)?1:Math.max(1,b)}.property(),_needsComputing:true,init:function(){arguments.callee.base.apply(this,arguments);this.lsrls=[];this.synchLSRLs()},destroy:function(){this.get("lsrls").forEach(function(a){a.destroy()});this.lsrls=[];arguments.callee.base.apply(this,arguments)},isVisibleChanged:function(){var a=this.get("isVisible");this.synchLSRLs();this.get("lsrls").forEach(function(b){b.set("isVisible",a)})}.observes("isVisible"),toggleInterceptLocked:function(){this.toggleProperty("isInterceptLocked")},isInterceptLockedChanged:function(){var a=this.get("isInterceptLocked");this.get("lsrls").forEach(function(b){b.set("isInterceptLocked",a);b.setComputingNeeded()})}.observes("isInterceptLocked"),showSumSquaresChanged:function(){var a=this.get("showSumSquares");this.get("lsrls").forEach(function(b){b.set("showSumSquares",a)})}.observes("showSumSquares"),showConfidenceBandsChanged:function(){var a=this.get("showConfidenceBands");this.get("lsrls").forEach(function(b){b.set("showConfidenceBands",a)})}.observes("showConfidenceBands"),setComputingNeeded:function(){this._needsComputing=true;this.get("lsrls").forEach(function(a){a.setComputingNeeded()})}.observes("plotModel"),enableMeasuresForSelectionDidChange:function(){var a=this.get("enableMeasuresForSelection");this.get("lsrls").forEach(function(b){b.set("enableMeasuresForSelection",a)})}.observes("enableMeasuresForSelection"),isComputingNeeded:function(a){if(this._needsComputing){return true}},recomputeSlopeAndInterceptIfNeeded:function(b,a){if(this.isComputingNeeded()){this._needsComputing=false;this.synchLSRLs();this.get("lsrls").forEach(function(c){c.recomputeSlopeAndInterceptIfNeeded(b,a)})}},synchLSRLs:function(){var e=this,c=this.getPath("plotModel.dataConfiguration.legendAttributeDescription"),b=c.get("isCategorical"),a=b?c.getPath("attributeStats.categoricalStats.cellNames")||[]:[],d=this.get("lsrls");if(a.length>0){d.filter(function(f){return a.indexOf(f.get("categoryName"))<0}).forEach(function(f){e.removeLSRL(f)});a.filter(function(f){return d.findIndex(function(g){return g.get("categoryName")===f})<0}).forEach(function(f){e.addLSRLModel(f)})}else{while(d.length>1){d.pop().destroy()}if(d.length===0){this.addLSRLModel("_main_")}}},addLSRLModel:function(b){var a=DG.LSRLModel.create({plotModel:this.get("plotModel"),categoryName:b,showSumSquares:this.get("showSumSquares"),showConfidenceBands:this.get("showConfidenceBands"),enableMeasuresForSelection:this.get("enableMeasuresForSelection"),isInterceptLocked:this.get("isInterceptLocked"),isVisible:this.get("isVisible")});a.set("isInterceptLocked",this.get("isInterceptLocked"));this.get("lsrls").push(a);this.setComputingNeeded();return a},removeLSRL:function(a){var b=this.get("lsrls"),c=b.indexOf(a);b.splice(c,1);a.destroy()},createStorage:function(){var a=arguments.callee.base.apply(this,arguments);a.showSumSquares=this.showSumSquares;a.isInterceptLocked=this.isInterceptLocked;a.showConfidenceBands=this.showConfidenceBands;a.lsrls=[];this.get("lsrls").forEach(function(b){a.lsrls.push(b.createStorage())});return a},restoreStorage:function(a){arguments.callee.base.apply(this,arguments);this.showSumSquares=a.showSumSquares;this.isInterceptLocked=a.isInterceptLocked;this.showConfidenceBands=a.showConfidenceBands;this.get("lsrls").forEach(function(b){b.set("showSumSquares",this.showSumSquares);b.set("isInterceptLocked",this.isInterceptLocked)}.bind(this));if(SC.isArray(a.lsrls)){this.get("lsrls").forEach(function(b,c){b.restoreStorage(a.lsrls[c])})}}});DG.PlotAdornmentModel.registry.multipleLSRLModels=DG.MultipleLSRLsModel;sc_require("components/graph/adornments/plot_adornment");DG.MultipleMovableValuesAdornment=DG.PlotAdornment.extend({valueAdornments:null,_shadingLayer:null,shadingLayer:function(){if(!this._shadingLayer&&this.getPath("paperSource.layerManager")){this._shadingLayer=this.getPath("paperSource.layerManager."+DG.LayerNames.kIntervalShading)}return this._shadingLayer}.property(),shadingElementsObject:null,valueAxisView:null,splitAxisView:function(){return this.getPath("parentView.secondaryAxisView")}.property(),isShowingCountsOrPercents:function(){return this.getPath("model.isShowingCount")||this.getPath("model.isShowingPercent")}.property(),init:function(){arguments.callee.base.apply(this,arguments);this.set("valueAdornments",[]);this.set("shadingElements",{})},destroy:function(){this.valueAdornments.forEach(function(a){a.destroy()});arguments.callee.base.apply(this,arguments)},modelPropertiesToObserve:[["valueChange","updateToModel"],["isShowingCount","updateToModel"],["isShowingPercent","updateToModel"],["valueModels","numberOfValuesChanged"],["countPercentsObject","numberOfValuesChanged"]],valueAxisViewDidChange:function(){var a=this.get("valueAxisView");if(a&&this.valueAdornments){this.valueAdornments.forEach(function(b){b.set("valueAxisView",a)})}}.observes("valueAxisView"),createElements:function(){var b=this.get("myElements"),c={},h=this.get("shadingLayer"),a=this.get("layer"),e=this.getPath("model.valueModels").length,d=(e===1)?0:Math.ceil(e/2),g=e===0?0:e+1,f=this.getPath("valueAxisView.orientation")===DG.GraphTypes.EOrientation.kHorizontal?"middle":"end";DG.ObjectMap.forEach(this.getPath("model.countPercentsObject"),function(i,m){c[i]={shadingRegions:[],shadingCounts:[]};var n=c[i].shadingRegions;while(n.length<d){var k=this.get("paper").rect(0,0,0,0).attr({opacity:0}).addClass("dg-movable-shaded");h.push(k);b.push(k);n.push(k);k.animate({opacity:DG.PlotUtilities.kMovableRegionOpacity},DG.PlotUtilities.kDefaultAnimationTime,"<>")}var l=c[i].shadingCounts;while(l.length<g){var j=this.get("paper").text(0,0,"").attr({opacity:0,"text-anchor":f}).addClass("dg-graph-adornment");a.push(j);b.push(j);l.push(j);j.animate({opacity:1},DG.PlotUtilities.kDefaultAnimationTime,"<>")}}.bind(this));this.set("shadingElementsObject",c)},updateToModel:function(){var l=this.get("valueAdornments"),g=this.get("paper");if(!g){return}var f=function(){var m=this.getPath("model.plotModel.secondaryAxisModel.attributeDescription.cellNames");if(!m||m.length===0){m=[DG.MovableValueModel.kSingleCellName]}return m}.bind(this),d=function(){var p=this.getPath("model.valueModels");while(p.length>l.length){var m=DG.MovableValueAdornment.create({parentView:this.get("parentView"),model:p[l.length],paperSource:this.get("paperSource"),layerName:this.get("layerName"),valueAxisView:this.get("valueAxisView")});m.createElements();l.push(m)}while(p.length<l.length){var o=l.findIndex(function(q){return SC.none(q.get("model"))});if(o>=0){var n=l[o];l.splice(o,1);n.destroy()}}}.bind(this),a=function(){if(l.length>1){j.forEach(function(n){var o=l.map(function(s){return s.screenCoord(n)});o.sort(function(t,s){return t-s});var m,r,q,p;o.forEach(function(s,u){if(u%2===0){var y=DG.MovableValueAdornment.kLabelSpace,t=this.shadingElementsObject[n].shadingRegions[u/2],w=e&&e.cellNameToCoordinate(n);if(!DG.isFinite(w)){w=c/2}if(this.getPath("valueAxisView.orientation")===DG.GraphTypes.EOrientation.kHorizontal){var v=u===o.length-1?g.width:o[u+1];m=s;r=w-c/2+y/2;q=Math.abs(v-s);p=Math.abs(c-y/2)}else{var x=(u===o.length-1)?0:o[u+1];m=w-c/2;r=s;q=Math.abs(c-y);p=Math.abs(x-s)}t.attr({x:m,y:r,width:q,height:p})}}.bind(this))}.bind(this))}}.bind(this),h=function(){function o(v){var t="",u=(p&&!SC.empty(v.percent))?(r?"(%@%)":"%@%").fmt(Math.round(v.percent)):"";if(r&&!p){t=v.count.toString()}else{if(p&&!r){t=u}else{if(r&&p){t="%@ %@".fmt(v.count,u)}}}return t}var q=this.get("valueAxisView"),m=q.get("orientation"),s=l.length>0?DG.MovableValueAdornment.kLabelSpace:0,r=this.getPath("model.isShowingCount"),p=this.getPath("model.isShowingPercent"),n=this.getPath("model.countPercentsObject");DG.ObjectMap.forEach(n,function(u,t){var w=this.shadingElementsObject[u].shadingCounts,v=e.cellNameToCoordinate(u);if(!DG.isFinite(v)){v=c/2}t.forEach(function(z,A){var y=q.dataToCoordinate(z.lower),C=q.dataToCoordinate(z.upper),B=m===DG.GraphTypes.EOrientation.kHorizontal?v-c/2+s/2+12:(y+C)/2,x=m===DG.GraphTypes.EOrientation.kHorizontal?(y+C)/2:v+c/2-5;w[A].attr({x:x,y:B,text:o(z)})}.bind(this))}.bind(this))}.bind(this),b=function(m){DG.ObjectMap.forEach(i,function(o,n){var p=this.shadingElementsObject[o].shadingCounts;p.forEach(function(q){if(m){q.show()}else{q.hide()}})}.bind(this))}.bind(this);var j=f(),e=this.get("splitAxisView"),c=e&&e.get("fullCellWidth"),i=this.getPath("model.countPercentsObject"),k=this.get("shadingElementsObject");this.get("model").recomputeValueIfNeeded();d();l.forEach(function(m){m.updateToModel()});if(this.get("myElements").length===0||j.some(function(m){return !k[m]})||Object.keys(k).some(function(m){return j.indexOf(m)<0})){this.removeElements();this.myElements=[];this.createElements()}a();if(this.get("isShowingCountsOrPercents")){h();b(true)}else{b(false)}},numberOfValuesChanged:function(){this.removeElements();this.myElements=[];this.updateToModel()}});sc_require("components/graph/adornments/plot_adornment_model");DG.MultipleMovableValuesModel=DG.PlotAdornmentModel.extend({valueModels:null,axisModel:null,secondaryAxisAttributeDescription:function(){return this.getPath("plotModel.secondaryAxisModel.attributeDescription")}.property(),isShowingCount:false,isShowingPercent:false,countPercentsObject:null,_needsComputing:true,init:function(){arguments.callee.base.apply(this,arguments);this.set("valueModels",[]);this.set("countPercentsObject",{})},destroy:function(){this.beginPropertyChanges();while(this.valueModels.length>0){this.removeValue()}arguments.callee.base.apply(this,arguments)},setComputingNeeded:function(){this._needsComputing=true}.observes("plotModel","isShowingCount","isShowingPercent"),isComputingNeeded:function(a){if(this._needsComputing){return true}},recomputeValue:function(c){var h=this.get("valueModels"),d=this.getPath("secondaryAxisAttributeDescription"),i=d&&d.getPath("attribute.id"),e=this.getPath("plotModel.primaryVarID"),a=this.get("cases"),g=this.get("countPercentsObject"),f=this.getPath("secondaryAxisAttributeDescription.cellNames"),b;DG.ObjectMap.forEach(g,function(j,k){delete g[j]});h.forEach(function(j){j.recomputeValue(this.get("axisModel"),b);b=j.get("values")}.bind(this));if(!f||f.length===0){f=[DG.MovableValueModel.kSingleCellName]}if(h.length>0){f.forEach(function(k){var l=[],j=[];h.forEach(function(o){l.push(o.getValueForCategory(k))});l.sort(function(p,o){return o-p});for(var m=0;m<=l.length;m++){j.push({count:0,percent:0})}var n=0;a.forEach(function(o){var r=o.getForcedNumericValue(e),s=i&&o.getStrValue(i);if(SC.none(s)){s=DG.MovableValueModel.kSingleCellName}if(isFinite(r)&&s===k){var p=l.findIndex(function(t){return r>t});if(p===-1){p=0}else{p=l.length-p}var q=j[p];q.count++;n++}});l.sort(function(p,o){return p-o});j.forEach(function(p,o){p.percent=n===0?"":100*p.count/n;p.lower=(o===0)?c.get("lowerBound"):l[o-1];p.upper=(o===l.length)?c.get("upperBound"):l[o]});g[k]=j}.bind(this))}this._needsComputing=false}.observes("axisModel.lowerBound","axisModel.upperBound"),recomputeValueIfNeeded:function(a){a=a||this.get("axisModel");if(this.isComputingNeeded(a)){this.recomputeValue(a)}},handleChangedAxisAttribute:function(){this.get("valueModels").forEach(function(a){a.handleChangedAxisAttribute(this.get("axisModel"))}.bind(this))},valueDidChange:function(){this.setComputingNeeded();this.notifyPropertyChange("valueChange")},addValue:function(a){var e=this;function c(){var f=[];e.get("valueModels").forEach(function(g){f=f.concat(g.getAllValues())});return f}var b=function(){var k=this.get("axisModel"),n=k.get("lowerBound"),m=n,i=k.get("upperBound"),h=i,f=c(),l=0,o=0;f.sort();while(o<=f.length){var g=(o===f.length)?i:Math.max(n,Math.min(i,f[o])),j=(o===0)?n:f[o-1];if(g-j>l){l=g-j;m=j;h=g}o++}return m+(h-m)/3}.bind(this);var d=DG.MovableValueModel.create({plotModel:this.get("plotModel")});if(a){d.restoreStorage(a)}else{d.setAllValues(b())}this.get("valueModels").push(d);d.addObserver("valueChange",this,"valueDidChange");this.setComputingNeeded();this.notifyPropertyChange("valueModels");return d},addThisValue:function(a){this.get("valueModels").push(a);a.addObserver("valueChange",this,"valueDidChange");this.setComputingNeeded();this.notifyPropertyChange("valueModels")},removeValue:function(){var b=this.get("valueModels");if(b&&b.length>0){var a=b[b.length-1];this.removeThisValue(a);return a}return null},removeThisValue:function(b){var c=this.get("valueModels"),a=c.indexOf(b);DG.assert(a>=0);b.removeObserver("valueChange",this,"valueDidChange");c.splice(a,1);this.recomputeValue(this.get("axisModel"));b.notifyPropertyChange("removed");this.setComputingNeeded();this.notifyPropertyChange("valueModels")},createStorage:function(){var a=arguments.callee.base.apply(this,arguments);a.isShowingCount=this.isShowingCount;a.isShowingPercent=this.isShowingPercent;a.valueModels=[];this.get("valueModels").forEach(function(b){a.valueModels.push(b.createStorage())});return a},restoreStorage:function(a){arguments.callee.base.apply(this,arguments);this.set("isShowingCount",a.isShowingCount);this.set("isShowingPercent",a.isShowingPercent);if(a&&a.valueModels){a.valueModels.forEach(function(b){this.addValue(b)}.bind(this))}}});DG.PlotAdornmentModel.registry.multipleMovableValues=DG.MultipleMovableValuesModel;sc_require("components/graph/adornments/plot_adornment");sc_require("components/graph/adornments/line_label_mixin");DG.PlottedAverageAdornment=DG.PlotAdornment.extend({cellGap:2,hoverWidth:5,hoverDelay:10,symSize:3,symStrokeWidth:1,bgStroke:"black",bgFill:"gray",bgStrokeWidth:0.5,titlePrecision:2,titleFraction:1/5,shadingLayerName:"",shadingLayer:function(){var a=this.getPath("paperSource.layerManager");return(a&&this.layerName)?a[this.shadingLayerName]:null}.property("paperSource","shadingLayerName"),offset:0,lineCovers:null,hoverElements:null,init:function(){arguments.callee.base.apply(this,arguments);this.lineCovers=[];this.hoverElements=[]},wantVisible:function(){return this.getPath("model.isVisible")},updateToModel:function(c){if(c!==true){c=false}var b=this.get("model");if(b.get("isVisible")){this.createEquationViews();if(!this.textElement){this.createTextElement();this.createBackgroundRect();this.textElement.attr("opacity",1)}b.recomputeValueIfNeeded();this.updateSymbols(c)}var a=this.getPath("parentView.parentView.plottedNormalAdorn");(DG.get("gaussianFitEnabled")&&a)&&a.doDraw()},createEquationViews:function(){},updateEquation:function(a){},updateTextElement:function(b,d,c,e,f,a){DG.assert(this.textElement);if(b&&DG.isFinite(d)){this.value=c;this.valueAxisView=this.getPath("parentView.primaryAxisView");this.valueString=this.titleString(d,f);this.updateTextToModel(e);this.textElement.show();this.backgrndRect.show();this.textShowingForID=a}else{this.valueString="";this.textElement.hide();this.backgrndRect.hide();this.textShowingForID=undefined}},updateSymbols:function(e){var D=this,o=this.get("layer"),C=this.get("shadingLayer"),q=this.getPath("parentView.primaryAxisView"),c=this.getPath("parentView.secondaryAxisView"),s=q&&(q.get("orientation")===DG.GraphTypes.EOrientation.kHorizontal),z=this.getPath("model.values"),m=z&&z.length,E=this.myElements.length,G=this.get("paper");if(!c||!m){return}var d=D.getPath("parentView.secondaryAxisView.fullCellWidth"),a=D.getPath("parentView.secondaryAxisView.fullWidth"),t={x:0,y:0,symSize:this.symSize,cellHeight:d-this.cellGap,fullHeight:a},A=-3*this.symSize;var g,y,x,l,r,F,w,v,k;var b,j,h,B,f=4;function u(){D.highlightOne(this._valueIndex);if(!D.get("showMeasureLabels")){D.updateTextElement(true,this.textStatValue,this.textAxisPosition,this.textCrossPosition,this.value,this.id)}}function n(){D.unHighlightOne(this._valueIndex);if(!D.get("showMeasureLabels")){D.updateTextElement(false)}}for(x=0;x<m;++x){v=z[x][this.statisticKey];g=z[x][this.centerKey];l=z[x][this.spreadKey];r=z[x][this.spreadStartKey];F=z[x][this.lowerKey];w=z[x][this.upperKey];k=z[x][this.amplitudeKey];y=(isFinite(g)?q.dataToCoordinate(g):A);t.width=(isFinite(l)?Math.abs(q.dataToCoordinate(g+l)-y):0);t.x=(s?y:x*d);t.y=(s?(m-x)*d:y);t.count=z[x].count;t.center=g;t.spread=l;t.spreadStart=(isFinite(r)?q.dataToCoordinate(r):A);t.lowerWhisker=(isFinite(F)?t.spreadStart-q.dataToCoordinate(F):0);t.upperWhisker=(isFinite(w)?(s?q.dataToCoordinate(w)-(t.spreadStart+t.width):-(t.spreadStart-t.width-q.dataToCoordinate(w))):0);t.amplitude=(isFinite(k)?k:null);if(x*f>=E){B=G.path("M0,0").attr({stroke:this.bgStroke,"stroke-width":this.bgStrokeWidth,fill:this.bgFill,"fill-opacity":0.5});b=G.path("M0,0").attr({stroke:this.symStroke,"stroke-width":this.symStrokeWidth,"stroke-opacity":0});j=G.path("M0,0").attr({"stroke-width":this.hoverWidth,stroke:DG.RenderingUtilities.kTransparent}).hover(u,n);j._valueIndex=x;this.lineCovers[x]=j;h=G.path("M0,0").attr({stroke:this.symStroke,"stroke-width":this.symStrokeWidth,"stroke-opacity":0});h._valueIndex=x;this.hoverElements[x]=h;B.animatable=b.animatable=true;B.animate({"stroke-opacity":1},DG.PlotUtilities.kDefaultAnimationTime,"<>");b.animate({"stroke-opacity":1},DG.PlotUtilities.kDefaultAnimationTime,"<>");this.myElements.push(B);this.myElements.push(b);this.myElements.push(j);this.myElements.push(h);C.push(B);o.push(b);o.push(j);o.push(h)}B=this.myElements[x*f];b=this.myElements[x*f+1];j=this.myElements[x*f+2];h=this.myElements[x*f+3];if(e){B.animate({path:this.backgroundPath(t,s)},DG.PlotUtilities.kDefaultAnimationTime,"<>");b.animate({path:this.symbolPath(t,s)},DG.PlotUtilities.kDefaultAnimationTime,"<>",this.updateToModel.bind(this))}else{B.attr({path:this.backgroundPath(t,s)});b.attr({path:this.symbolPath(t,s)})}j.attr("path",this.coverPath(t,s));h.attr("path",this.hoverElementPath(t,s));j.textStatValue=v;j.textAxisPosition=this.getTextPositionOnAxis(g,l);j.textCrossPosition=s?1-((1/m)*(x+1-this.titleFraction)):((1/m)*(x+this.titleFraction));j.value=z[x];b.toFront();j.toFront();h.toFront();if(!this.get("showMeasureLabels")){if(this.textElement){this.backgrndRect.toFront();this.textElement.toFront()}if(this.textShowingForID===j.id){this.updateTextElement(true,j.textStatValue,j.textAxisPosition,j.textCrossPosition,j.id,j.value)}}this.updateEquation(x)}if(this.myElements.length>(f*m)){this.removeExtraSymbols(f*m)}DG.assert(this.myElements.length===f*z.length)},removeExtraSymbols:function(d){var e=this.get("layer"),f=this.get("shadingLayer"),c,b,a;for(c=d,b=this.myElements.length;c<b;++c){a=this.myElements[c];e.prepareToMoveOrRemove(a);f.prepareToMoveOrRemove(a);a.remove()}this.myElements.length=d},symbolPath:function(b,a){if(a){return"M%@,%@ v%@".fmt(b.x,b.y,-(b.cellHeight))}else{return"M%@,%@ h%@".fmt(b.x,b.y,b.cellHeight)}},coverPath:function(b,a){if(a){return"M%@,%@ v%@".fmt(b.x,b.y,-(b.cellHeight))}else{return"M%@,%@ h%@".fmt(b.x,b.y,b.cellHeight)}},hoverElementPath:function(b,a){return""},backgroundPath:function(b,a){return"M0,0"},getValueString:function(c,d){var b=DG.PlotUtilities.findFractionDigitsForAxis(this.getPath("parentView.primaryAxisView")),a=DG.Format.number().fractionDigits(0,b).group("");return d.loc(a(c))},valueAndUnitsStrings:function(c,d){if(!isFinite(c)){return{}}var b=this.getPath("parentView.primaryAxisView.model.firstAttributeUnit"),a=this.getValueString(c,d);return{valueString:a,unitsString:b}},titleString:function(c){var d=this.valueAndUnitsStrings(c,this.titleResource);if(!d.valueString){return""}if(this.get("showMeasureLabels")){var a='<p style = "color:%@;">%@ %@</p>',b='<span style = "color:grey;">%@</span>'.loc(d.unitsString);return a.loc(this.symStroke,d.valueString,b)}else{return d.valueString+" "+d.unitsString}}});DG.PlottedSimpleAverageAdornment=DG.PlottedAverageAdornment.extend(DG.LineLabelMixin,(function(){return{init:function(){arguments.callee.base.apply(this,arguments);this.equationViews=[]},destroy:function(){this.destroyEquationViews();arguments.callee.base.apply(this,arguments)},showMeasureLabels:function(){return this.getPath("model.plotModel.showMeasureLabels")||SC.platform.touch}.property(),showMeasuresLabelsDidChange:function(){if(this.get("showMeasureLabels")){this.createEquationViews()}else{this.destroyEquationViews()}this.notifyPropertyChange("showMeasureLabels")}.observes("model.plotModel.showMeasureLabels"),equationViews:null,destroyEquationViews:function(){if(this.get("equationViews")){this.get("equationViews").forEach(function(a){a.destroy()})}this.equationViews=[]},setEquationsVisibility:function(a){this.get("equationViews").forEach(function(b){b.set("isVisible",a)})},showElements:function(){arguments.callee.base.apply(this,arguments);this.setEquationsVisibility(true)},hideElements:function(){arguments.callee.base.apply(this,arguments);this.setEquationsVisibility(false)},createEquationViews:function(){var h=this,b,k,f,d;function a(o){h.highlightOne(o)}function e(o){h.unHighlightOne(o)}function l(q){var o=this;function p(){var r=o.get("layer");return{proportionX:r.offsetLeft/h.get("paper").width,proportionY:r.offsetTop/h.get("paper").height}}b=o.get("index");k={x:q.clientX,y:q.clientY};f=h.getPath("model.equationCoordsArray")[b];d=SC.none(f)?p():f;return YES}function m(t){var r=(t.clientX-k.x),q=(t.clientY-k.y),p=h.get("paper");if(r!==0||q!==0){var o=h.getPath("model.equationCoordsArray"),s={proportionX:d.proportionX+r/p.width,proportionY:d.proportionY+q/p.height};o[b]=s;h.updateEquation(b)}}function n(q){var o=f,p;DG.UndoHistory.execute(DG.Command.create({name:"graph.repositionEquation",undoString:"DG.Undo.graph.repositionEquation",redoString:"DG.Redo.graph.repositionEquation",log:"Moved equation from %@ to %@".fmt(o,this.getPath("model.coordinates")),executeNotification:{action:"notify",resource:"component",values:{operation:"reposition equation",type:"DG.GraphView"}},execute:function(){p=h.getPath("model.equationCoordsArray")[b]}.bind(this),undo:function(){h.getPath("model.equationCoordsArray")[b]=o;h.updateEquation(b)}.bind(this),redo:function(){h.getPath("model.equationCoordsArray")[b]=p;h.updateEquation(b)}.bind(this)}))}if(this.get("showMeasureLabels")){if(!this.equationViews){this.equationViews=[]}var c=this.getPath("model.values"),g=c&&c.length;while(this.equationViews.length<g){var j=DG.EquationView.create({index:this.equationViews.length,highlight:a,unhighlight:e,mouseDown:l,mouseDragged:m,mouseUp:n});j.set("isVisible",false);this.get("paperSource").appendChild(j);this.equationViews.push(j)}while(this.equationViews.length>g){this.equationViews.pop().destroy()}for(var i=0;i<this.equationViews.length;i++){this.updateEquation(i)}}},updateEquation:function(i){if(this.getPath("showMeasureLabels")){var o=this.getPath("parentView.primaryAxisView.orientation")===DG.GraphTypes.EOrientation.kHorizontal,t=this.getPath("model.values"),j=t&&t.length,e=t[i][this.centerKey],q=t[i][this.statisticKey],u=this.titleString(q,t[i]),h=this.getPath("parentView.secondaryAxisView.fullCellWidth"),m=this.getPath("parentView.primaryAxisView"),d=this.get("equationViews")[i],k=this.getPath("model.equationCoordsArray")[i],v=this.get("paper"),p,n;if(!d){return}d.show({x:0,y:-100},u);if(k){var b=d.get("layer"),f=b.offsetWidth,l=b.offsetHeight;p=k.proportionX*v.width;p=Math.min(Math.max(p,-f/2),v.width-f/2);n=k.proportionY*v.height;n=Math.min(Math.max(n,-l/2),v.height-l/2);k.proportionX=p/v.width;k.proportionY=n/v.height}else{var g=-9,s=isFinite(e)?m.dataToCoordinate(e):g,a=t[i][this.spreadKey],c=isFinite(a)?Math.abs(m.dataToCoordinate(a)-m.dataToCoordinate(0)):0,w=this.getTextPositionOnAxis(s,c),r=this.get("offset")*DG.EquationView.defaultHeight;p=o?w:i*h;n=o?r+(j-i-1)*h:r+(i%2)*DG.EquationView.defaultHeight}d.set("isVisible",this.getPath("model.isVisible"));d.show({x:p,y:n},u)}},offsetDidChange:function(){this.get("equationViews").forEach(function(a,b){this.updateEquation(b)}.bind(this))}.observes("offset"),highlightOne:function(e){var a={stroke:this.hoverColor},d={"stroke-opacity":1},c=this.lineCovers[e],b=this.hoverElements[e];c.stop();c.animate(a,this.hoverDelay);b.stop();b.animate(d,this.hoverDelay);if(this.get("showMeasureLabels")){this.get("equationViews")[e].set("highlighted",true)}},unHighlightOne:function(e){var a={stroke:DG.RenderingUtilities.kTransparent},d={"stroke-opacity":0},c=this.lineCovers[e],b=this.hoverElements[e];c.stop();c.animate(a,DG.PlotUtilities.kHighlightHideTime);b.stop();b.animate(d,DG.PlotUtilities.kHighlightHideTime);if(this.get("showMeasureLabels")){this.get("equationViews")[e].set("highlighted",false)}},getTextPositionOnAxis:function(a,b){var c=0,d=this.get("valueAxisView");if(d){c=Math.abs(d.coordinateToData(2)-d.coordinateToData(0))}return a+c}}}()));DG.PlottedMeanAdornment=DG.PlottedSimpleAverageAdornment.extend({statisticKey:"mean",centerKey:"mean",titleResource:"DG.PlottedAverageAdornment.meanValueTitle",hoverColor:"rgba(0, 0, 255, 0.3)",symStroke:"#00F",symStrokeWidth:1.5});DG.PlottedMedianAdornment=DG.PlottedSimpleAverageAdornment.extend({statisticKey:"median",centerKey:"median",titleResource:"DG.PlottedAverageAdornment.medianValueTitle",hoverColor:"rgba(193, 0, 32, 0.3)",symStroke:"#C10020",symStrokeWidth:1.5});DG.PlottedDevAdornment=DG.PlottedSimpleAverageAdornment.extend({symbolPath:function(b,a){if(a){return"M%@,%@ v%@ M%@,%@ v%@".fmt(b.x,b.y,-b.cellHeight,b.x+2*b.width,b.y,-b.cellHeight)}else{return"M%@,%@ h%@ M%@,%@ h%@".fmt(b.x,b.y,b.cellHeight,b.x,b.y-2*b.width,b.cellHeight)}},backgroundPath:function(e,c){var a=e.x,f=e.y,b=e.width,d=e.cellHeight;if(c){return"M%@,%@ v%@ h%@ v%@ z M%@,%@ v%@".fmt(a,f,-d,2*b,d,a+b,f,-d)}else{return"M%@,%@ h%@ v%@ h%@ z M%@,%@ h%@".fmt(a,f,d,-2*b,-d,a,f-b,d)}},coverPath:function(b,a){return this.symbolPath(b,a)},getTextPositionOnAxis:function(a,b){return a+b}});DG.PlottedStDevAdornment=DG.PlottedDevAdornment.extend({bgFill:"#9980FF",bgStroke:"#9980FF",bgStrokeWidth:0.5,symStrokeWidth:1,symStroke:"#30F",statisticKey:"stdev",centerKey:"centerMinus1Dev",spreadKey:"stdev",titleResource:"DG.PlottedAverageAdornment.stDevValueTitle",symHeight:0.6,hoverColor:"rgba(48, 0, 255, 0.3)"});DG.PlottedStErrAdornment=DG.PlottedSimpleAverageAdornment.extend({statisticKey:"sterr",centerKey:"mean",spreadKey:"sterr",titleResource:"DG.PlottedAverageAdornment.stErrValueTitle",hoverColor:"rgba(246, 118, 142, 0.3)",bgStroke:"#FFb280",bgStrokeWidth:0.5,bgFill:"#FFb280",symStroke:"#F6768E",offsetFromEdge:10,tickLength:6,modelPropertiesToObserve:[["numberOfStdErrs","updateToModel"]],updateToModel:function(b){arguments.callee.base.apply(this,arguments);var a=this.getPath("parentView.plottedNormalAdorn"),c=this.getPath("model.plotModel.dotsAreFused");DG.get("gaussianFitEnabled")==="yes"&&a&&c&&a.updateToModel()},getValueString:function(f,e){var d=DG.PlotUtilities.findFractionDigitsForAxis(this.getPath("parentView.primaryAxisView")),b=DG.Format.number().fractionDigits(0,d).group(""),a=this.getPath("model.numberOfStdErrs"),c=a===1?"":String(a);return this.get("showMeasureLabels")?e.loc(c,'<sub style="vertical-align: sub">',"</sub>",b(a*f)):e.loc(c,"","",b(a*f))},symbolPath:function(e,a){var d=e.y-e.cellHeight+this.offsetFromEdge,b=e.x+e.cellHeight-this.offsetFromEdge,c=this.getPath("model.numberOfStdErrs")*e.width;if(a){return"M%@,%@ h%@ M%@,%@ v%@ M%@,%@ v%@".fmt(e.x-c,d,2*c,e.x-c,d-this.tickLength/2,this.tickLength,e.x+c,d-this.tickLength/2,this.tickLength)}else{return"M%@,%@ v%@ M%@,%@ h%@ M%@,%@ h%@".fmt(b,e.y+c,-2*c,b-this.tickLength/2,e.y+c,this.tickLength,b-this.tickLength/2,e.y-c,this.tickLength)}},coverPath:function(b,a){return this.symbolPath(b,a)},hoverElementPath:function(c,a){var b=this.getPath("model.numberOfStdErrs")*c.width;if(a){return"M%@,%@ v%@ M%@,%@ v%@".fmt(c.x-b,0,c.fullHeight,c.x+b,0,c.fullHeight)}else{return"M%@,%@ h%@ M%@,%@ h%@".fmt(0,c.y+b,c.fullHeight,0,c.y-b,c.fullHeight)}},getTextPositionOnAxis:function(a,b){return a+b}});DG.PlottedMeanAbsDevAdornment=DG.PlottedDevAdornment.extend({bgFill:"#9ac6ff",bgStroke:"#5bbaff",bgStrokeWidth:0.5,symStrokeWidth:1,symStroke:"#00adff",statisticKey:"mad",centerKey:"centerMinus1Dev",spreadKey:"mad",titleResource:"DG.PlottedAverageAdornment.madValueTitle",symHeight:0.6,hoverColor:"rgba(0, 173, 255, 0.3)"});DG.PlottedNormalAdornment=DG.PlottedSimpleAverageAdornment.extend({statisticKey:"mean",titleResource:"DG.PlottedAverageAdornment.meanValueTitle",centerKey:"mean",spreadKey:"stdev",amplitudeKey:"amplitude",hoverColor:"rgba(0, 125, 52,0.3)",bgStroke:"#FFb280",bgStrokeWidth:0.5,symStroke:"#007D34",symStrokeWidth:1,offsetFromEdge:10,numStdErrors:function(){var a=this.getPath("model.plotModel"),c=a.getAdornmentModel("plottedStErr"),b=c&&c.get("numberOfStdErrs");return DG.get("gaussianFitEnabled")==="yes"&&a.get("dotsAreFused")&&c&&c.get("isVisible")&&b},stdErrorValue:function(d,e){var a=this.getPath("model.plotModel"),f=a.getAdornmentModel("plottedStErr"),c=f&&f.get("numberOfStdErrs"),b=c&&c*e/Math.sqrt(d);return DG.get("gaussianFitEnabled")==="yes"&&a.get("dotsAreFused")&&f&&f.get("isVisible")&&b},symbolPath:function(w,v){function I(p){return DG.MathUtilities.normal(p,l,E,b)}function f(J){var p=(2*y-r)*J+1;return v?w.y-p:w.x+p}var t=Math.sqrt(2*Math.PI),C=this.get("parentView"),i=this.getPath("model.plotModel.dotsAreFused"),z=C.get("primaryAxisView"),u=C.get("secondaryAxisView"),k=i?u.dataToCoordinate.bind(u):f,y=C.calcPointRadius(),r=C.get("overlap"),F=i?C.getPath("model.width"):C.get("binWidthInWorldCoordinates"),x=z.get(v?"pixelMin":"pixelMax"),A=z.get(v?"pixelMax":"pixelMin"),m="",o="",a,G="",H,n="",c,B=w.count,E=w.center,b=w.spread,l=w.amplitude||(1/(b*t)*B*F),D=this.stdErrorValue(B,b),j,q,d,e=[],h=1,s,g;for(s=x;s<=A;s+=h){j=z.coordinateToData(s);q=I(j);if(DG.isFinite(q)){d=k(q);g=v?{left:s,top:d}:{left:d,top:s};e.push(g)}}if(e.length>0){m="M"+e[0].left+","+e[0].top+DG.SvgScene.curveBasis(e)}a=k(I(E))-k(0);o=v?"M%@,%@ v%@".fmt(z.dataToCoordinate(E),k(0),a):"M%@,%@ h%@".fmt(k(0),z.dataToCoordinate(E),a);H=z.dataToCoordinate(E+b)-z.dataToCoordinate(E-b);G=v?" M%@,%@ h%@".fmt(z.dataToCoordinate(E-b),k(I(E-b)),H):" M%@,%@ v%@".fmt(k(I(E-b)),z.dataToCoordinate(E-b),H);if(D){c=z.dataToCoordinate(E+D)-z.dataToCoordinate(E-D);n=v?" M%@,%@ h%@".fmt(z.dataToCoordinate(E-D),k(I(E-D)),c):" M%@,%@ v%@".fmt(k(I(E-D)),z.dataToCoordinate(E-D),c)}return m+o+G+n},coverPath:function(b,a){return this.symbolPath(b,a)},standardErrorAndUnitsStrings:function(f,g,j,a,i){var h=j===1?"":String(j),e=g/Math.sqrt(f),k=this.getPath("parentView.primaryAxisView.model.firstAttributeUnit"),b=DG.PlotUtilities.findFractionDigitsForAxis(this.getPath("parentView.primaryAxisView")),d=DG.Format.number().fractionDigits(0,b).group(""),l=d(j*e),c=i?a.loc(h,'<sub style="vertical-align: sub">',"</sub>",l):a.loc(h,"","",l);return{valueString:c,unitsString:k}},titleString:function(p,a){var g=DG.get("gaussianFitEnabled")==="yes",o=this.getPath("model.plotModel.dotsAreFused"),f=this.get("showMeasureLabels"),l=g&&o?"DG.Inspector.graphPlottedGaussianFit".loc():"",k=typeof a==="object"?a.stdev:a,i=this.valueAndUnitsStrings(p,this.titleResource),n=this.valueAndUnitsStrings(k,"DG.PlottedAverageAdornment.stDevValueTitle"),m=this.stdErrorValue(a.count,a.stdev);var c=m?this.standardErrorAndUnitsStrings(a.count,a.stdev,this.numStdErrors(),"DG.PlottedAverageAdornment.stErrValueTitle",f):{valueString:"",unitsString:""};if(!i.valueString){return""}if(f){l='<p style="text-decoration-line: underline">'+l+"</p>";var d='<div style = "color:%@;">%@</div>',h='<span style = "color:grey;">%@</span>'.loc(i.unitsString),b="<p>%@ %@</p>".loc(i.valueString,h),j="<p>%@ %@</p>".loc(n.valueString,h),e=m?("<p>%@ %@</p>".loc(c.valueString,h)):"";return d.loc(this.symStroke,l+b+j+e,h)}else{if(g){l=l+": "}return l+i.valueString+" "+i.unitsString+", "+n.valueString+" "+n.unitsString+(m?", "+c.valueString+" "+c.unitsString:"")}},getTextPositionOnAxis:function(a,b){return a+b}});sc_require("components/graph/adornments/plot_adornment_model");DG.PlottedAverageModel=DG.PlotAdornmentModel.extend({_values:null,values:function(a,b){if(b){this._values=b}if(!this._values){this.recomputeValue()}return this._values}.property(),enableMeasuresForSelection:false,precision:0});DG.PlottedSimpleAverageModel=DG.PlottedAverageModel.extend({equationCoordsArray:null,init:function(){arguments.callee.base.apply(this,arguments);this.equationCoordsArray=[]},createStorage:function(){var a=arguments.callee.base.apply(this,arguments);DG.ObjectMap.copy(a,{equationCoordsArray:this.get("equationCoordsArray")});return a},restoreStorage:function(a){arguments.callee.base.apply(this,arguments);if(a){if(a.equationCoordsArray){this.set("equationCoordsArray",a.equationCoordsArray)}}}});DG.PlottedMeanStDevModel=DG.PlottedSimpleAverageModel.extend({computeSumCountMeanStdDev:function(g){var b=this.get("cases"),k=this.getPath("plotModel.primaryVarID"),e=this.getPath("plotModel.primaryAxisModel"),f=this.getPath("plotModel.secondaryVarID"),h=this.getPath("plotModel.secondaryAxisModel");if(!(h&&e)){return null}var l=h.get("numberOfCells");var a=[];var d,c;for(d=0,c=l;d<c;++d){a.push({sum:0,sumOfSquares:0,count:0,mean:undefined,stdev:undefined,sterr:undefined,numericValues:[]})}b.forEach(function(m,n){var p=m.getNumValue(k),j=m.getStrValue(f),i=h.cellNameToCellNumber(j);if(i!=null&&DG.MathUtilities.isInIntegerRange(i,0,a.length)){var o=a[i];if(isFinite(p)){o.sum+=p;o.sumOfSquares+=(p*p);o.count+=1;if(g){o.numericValues.push(p)}}}});a.forEach(function(i){if(i.count>0){i.mean=i.sum/i.count;i.stdev=Math.sqrt((i.sumOfSquares-(i.mean*i.mean)*i.count)/(i.count-1));if(g){i.mad=i.numericValues.reduce(function(m,j){return m+Math.abs(i.mean-j)},0)/i.count;delete i.numericValues}}});return a}});DG.PlottedMeanModel=DG.PlottedMeanStDevModel.extend({recomputeValue:function(){var b=this.computeSumCountMeanStdDev();if(b){var a=this.getPath("plotModel.primaryAxisModel");this.set("precision",a.getPath("attributeDescription.attribute.precision"));this.set("values",b);this._needsComputing=false}}});DG.PlotAdornmentModel.registry.plottedMean=DG.PlottedMeanModel;DG.PlottedStDevModel=DG.PlottedMeanStDevModel.extend({recomputeValue:function(){var b=this.computeSumCountMeanStdDev();if(!b){return}b.forEach(function(c){if(c.count>1){c.centerMinus1Dev=c.mean-c.stdev}});var a=this.getPath("plotModel.primaryAxisModel");this.set("precision",a.getPath("attributeDescription.attribute.precision"));this.set("values",b);this._needsComputing=false}});DG.PlotAdornmentModel.registry.plottedStDev=DG.PlottedStDevModel;DG.PlottedStErrModel=DG.PlottedMeanStDevModel.extend({numberOfStdErrs:1,recomputeValue:function(){var b=this.computeSumCountMeanStdDev();if(!b){return}b.forEach(function(c){if(c.count>1){c.sterr=c.stdev/Math.sqrt(c.count);c.centerMinus1Dev=c.mean-c.sterr}});var a=this.getPath("plotModel.primaryAxisModel");this.set("precision",a.getPath("attributeDescription.attribute.precision"));this.set("values",b);this._needsComputing=false},createStorage:function(){var a=arguments.callee.base.apply(this,arguments);a.numberOfStdErrs=this.get("numberOfStdErrs");return a},restoreStorage:function(a){arguments.callee.base.apply(this,arguments);this.set("numberOfStdErrs",a.numberOfStdErrs||1)}});DG.PlotAdornmentModel.registry.plottedStErr=DG.PlottedStErrModel;DG.PlottedNormalModel=DG.PlottedMeanStDevModel.extend({addGaussianFitToValues:function(i){var f=Math.sqrt(2*Math.PI),a=this.get("plotModel"),j=a.get("width"),c=a.get("bars"),h=c.map(function(l){return{x:l.lowerEdgeWorld+j/2,y:l.count}}),g=i.mean,e=i.stdev,k=i.count,b=(1/(e*f))*k*j,d=DG.MathUtilities.fitGaussianLM(h,b,g,e);i.mean=d.mu;i.stdev=d.sigma;i.amplitude=b},recomputeValue:function(){var c=DG.get("gaussianFitEnabled")==="yes",a=this.get("plotModel"),b=this.computeSumCountMeanStdDev();if(b&&a.get("dotsAreFused")&&c){this.addGaussianFitToValues(b[0])}if(b){this.set("values",b);this._needsComputing=false}}});DG.PlotAdornmentModel.registry.plottedNormal=DG.PlottedNormalModel;DG.PlottedMadModel=DG.PlottedMeanStDevModel.extend({recomputeValue:function(){var b=this.computeSumCountMeanStdDev(true);if(!b){return}b.forEach(function(c){c.centerMinus1Dev=c.mean-c.mad});var a=this.getPath("plotModel.primaryAxisModel");this.set("precision",a.getPath("attributeDescription.attribute.precision"));this.set("values",b);this._needsComputing=false}});DG.PlotAdornmentModel.registry.plottedMad=DG.PlottedMadModel;DG.PlottedQuantileModel=DG.PlottedSimpleAverageModel.extend({collectCellValsAndMedian:function(){var g=this.get("cases"),e=this.getPath("plotModel.primaryVarID"),f=this.getPath("plotModel.secondaryVarID"),d=this.getPath("plotModel.secondaryAxisModel");if(!d){return}var b=d.get("numberOfCells"),h=[],c,a;for(c=0,a=b;c<a;++c){h.push({vals:[],cases:[],median:undefined})}g.forEach(function(k,l){var n=k.getNumValue(e),j=k.getStrValue(f),i=d.cellNameToCellNumber(j);if(i!=null&&DG.MathUtilities.isInIntegerRange(i,0,h.length)){var m=h[i];if(isFinite(n)){m.vals.push(n);m.cases.push(k)}}});h.forEach(function(i){if(i.vals.length>0){i.median=DG.MathUtilities.medianOfNumericArray(i.vals)}});return h}});DG.PlottedMedianModel=DG.PlottedQuantileModel.extend({recomputeValue:function(){var a=this.collectCellValsAndMedian();if(a){this.set("values",a);this._needsComputing=false}}});DG.PlotAdornmentModel.registry.plottedMedian=DG.PlottedMedianModel;DG.PlottedIQRModel=DG.PlottedQuantileModel.extend({recomputeValue:function(){var a=this.collectCellValsAndMedian();if(!a){return}a.forEach(function(b){if(b.vals.length>0){b.Q1=DG.MathUtilities.quantileOfSortedArray(b.vals,0.25);b.Q3=DG.MathUtilities.quantileOfSortedArray(b.vals,0.75);b.IQR=(b.Q3-b.Q1)}});this.set("values",a);this._needsComputing=false}});DG.PlotAdornmentModel.registry.plottedIQR=DG.PlottedIQRModel;DG.PlottedBoxPlotModel=DG.PlottedIQRModel.extend({showOutliers:false,showICI:false,recomputeValue:function(){this.beginPropertyChanges();arguments.callee.base.apply(this,arguments);var c=this.get("values"),b=this.get("showOutliers"),a=this.get("showICI");if(c){c.forEach(function(g){g.upperOutliers=[];g.lowerOutliers=[];if(g.vals.length>0){if(b){var f=1.5*g.IQR,d,e;d=g.Q1-f;e=0;while(g.vals[e]<d){g.lowerOutliers.push(g.vals[e]);e++}g.lowerWhisker=g.vals[e];d=g.Q3+f;e=g.vals.length-1;while(g.vals[e]>d){g.upperOutliers.push(g.vals[e]);e--}g.upperWhisker=g.vals[e]}else{g.lowerWhisker=g.vals[0];g.upperWhisker=g.vals[g.vals.length-1]}g.ICI=a?1.5*g.IQR/Math.sqrt(g.vals.length):undefined}})}this.endPropertyChanges()},createStorage:function(){var a=arguments.callee.base.apply(this,arguments);a.showOutliers=this.get("showOutliers")||false;a.showICI=this.get("showICI")||false;return a},restoreStorage:function(a){arguments.callee.base.apply(this,arguments);if(a){this.set("showOutliers",a.showOutliers||false);this.set("showICI",a.showICI||false)}}});DG.PlotAdornmentModel.registry.plottedBoxPlot=DG.PlottedBoxPlotModel;sc_require("components/graph/adornments/plotted_average_adornment");DG.PlottedBoxPlotLogString="";DG.PlottedBoxPlotAdornment=DG.PlottedAverageAdornment.extend((function(){var a=SC.Object.extend({boxSymbol:null,lowerWhiskerCover:null,Q1Cover:null,lowerRect:null,medianCover:null,upperRect:null,Q3Cover:null,upperWhiskerCover:null,outliers:null,outlierCovers:null,ici:null,iciCover:null,iciHoverElement:null,init:function(){arguments.callee.base.apply(this,arguments);this.outliers=[];this.outlierCovers=[]},pushElements:function(b){DG.ObjectMap.forEach(this,function(c,d){if(d.paper){b.push(d)}});this.outliers.forEach(function(c){b.push(c)});this.outlierCovers.forEach(function(c){b.push(c)});this.ici&&b.push(this.ici);this.iciCover&&b.push(this.iciCover);this.iciHoverElement&&b.push(this.iciHoverElement)},removeFromArrayAndLayer:function(c,d){function b(e){if(e){d.prepareToMoveOrRemove(e);e.remove();c.splice(c.indexOf(e),1)}}DG.ObjectMap.forEach(this,function(e,f){if(f.paper){b(f)}});this.outliers.forEach(function(e){b(e)});this.outlierCovers.forEach(function(e){b(e)});b(this.ici);b(this.iciCover);b(this.iciHoverElement)}});return{hoverColor:"rgba(255, 48, 0, 0.3)",bgStroke:"#FFb280",bgStrokeWidth:0.5,bgFill:"#FFb280",symStroke:"#F30",symStrokeWidth:1,iciStroke:"#30F",iciStrokeWidth:2,iciHoverElementStrokeWidth:1,modelPropertiesToObserve:[["showOutliers","updateVisibility"]],boxPlotSymbols:null,init:function(){arguments.callee.base.apply(this,arguments);this.boxPlotSymbols=[]},_infoTip:null,infoTip:function(){if(!this._infoTip){var b=this;this._infoTip=DG.InfoTip.create({paperSource:function(){return b.get("paperSource")}.property()})}return this._infoTip}.property(),updateToModel:function(b){if(b!==true){b=false}var c=this.get("model");if(c&&c.get("isVisible")){c.recomputeValueIfNeeded();this.updateSymbols(b)}},updateTextElement:function(c,e,d,f,g,b){DG.assert(this.textElement);if(c&&DG.isFinite(e)){this.value=d;this.valueAxisView=this.getPath("parentView.primaryAxisView");this.valueString=this.titleString(e,g);this.updateTextToModel(f);this.textElement.show();this.backgrndRect.show();this.textShowingForID=b}else{this.valueString="";this.valueAxisView=null;this.textElement.hide();this.backgrndRect.hide();this.textShowingForID=undefined}},updateHoverLog:function(b){if(b!==DG.PlottedBoxPlotLogString){DG.PlottedBoxPlotLogString=b;DG.logUser("%@: %@","hoverOverGraphLine",DG.PlottedBoxPlotLogString)}},updateSymbols:function(g){if(g&&g!==true){g=false}var k=this,s=DG.PlotUtilities.kDefaultAnimationTime,n=this.get("layer"),o=this.getPath("parentView.primaryAxisView"),d=this.getPath("parentView.secondaryAxisView"),p=o&&(o.get("orientation")===DG.GraphTypes.EOrientation.kHorizontal),u=this.getPath("model.values"),l=u&&u.length,w=this.get("paper");if(!d||!l||!w){return}var h=function(y){var i=DG.PlotUtilities.findFractionDigitsForAxis(o),x=DG.Format.number().fractionDigits(0,i);x.group("");return x(y)};var b=d.get("fullWidth"),e=(l?d.get("fullCellWidth"):0),f={x:0,y:0,symSize:this.symSize,cellHeight:e-this.cellGap,fullHeight:b},v=-3*this.symSize,j=Math.min(e/3,DG.PlotUtilities.kBoxplotMaxWidth);function r(){var y={stroke:k.hoverColor};this.stop();this.animate(y,k.hoverDelay,"<>");var x=this.getBBox();k.get("infoTip").show({x:x.x,y:x.y-2,tipString:this.info.tipString,tipValue:h(this.info.tipValue)});if(this.info.tipString.indexOf("ICI")>=0){var i=k.boxPlotSymbols[this.index].iciHoverElement;i.stop();i.animate({"stroke-opacity":1},k.hoverDelay,"<>")}}function m(){var x={stroke:DG.RenderingUtilities.kTransparent};this.stop();this.animate(x,DG.PlotUtilities.kHighlightHideTime,"<>");k.get("infoTip").hide();if(this.info.tipString.indexOf("ICI")>=0){var i=k.boxPlotSymbols[this.index].iciHoverElement;i.stop();i.animate({"stroke-opacity":0},DG.PlotUtilities.kHighlightHideTime,"<>")}}function q(){var A=k.getPath("model.plotModel.primaryVarID"),y=this.info.range.lower,z=this.info.range.upper,B=this.info.range.cases,i=[],x={operation:"selectCases",collection:k.getPath("model.plotModel.collectionClient"),cases:i,select:true,extend:false};B.forEach(function(C){var D=C.getForcedNumericValue(A);if(D>=y&&D<=z){i.push(C)}});k.getPath("model.plotModel.dataContext").applyChange(x)}var c=function(E){var O=function(){return p?"M%@,%@ h%@ M%@,%@ v%@ h%@ v%@ h%@ z M%@,%@ v%@ M%@,%@ h%@".fmt(f.Q1-f.lowerWhisker,x,f.lowerWhisker,f.Q1,x,-j/2,f.width,j,-f.width,f.x,x-j/2,j,f.Q1+f.width,x,f.upperWhisker):"M%@,%@ v%@ M%@,%@ h%@ v%@ h%@ v%@ z M%@,%@ h%@ M%@,%@ v%@".fmt(y,f.Q1-f.lowerWhisker,f.lowerWhisker,y,f.Q1,-j/2,-f.width,j,f.width,y-j/2,f.y,j,y,f.Q1-f.width,f.upperWhisker)},F=function(){return p?{x:f.Q1,y:f.y-f.cellHeight/2-j/2,width:f.x-f.Q1,height:j}:{x:f.x+f.cellHeight/2-j/2,y:f.y,width:j,height:f.Q1-f.y}},B=function(){return p?{x:f.x,y:f.y-f.cellHeight/2-j/2,width:f.Q3-f.x,height:j}:{x:f.x+f.cellHeight/2-j/2,y:f.Q3,width:j,height:f.y-f.Q3}},J=function(){return p?"M%@,%@ h%@".fmt(f.Q1-f.lowerWhisker,x,f.lowerWhisker):"M%@,%@ v%@".fmt(y,f.Q1-f.lowerWhisker,f.lowerWhisker)},U=function(){return p?"M%@,%@ h%@".fmt(f.Q3,x,f.upperWhisker):"M%@,%@ v%@".fmt(y,f.Q3,f.upperWhisker)},i=function(){return p?"M%@,%@ h%@".fmt(f.iciLower,x,f.iciUpper-f.iciLower):"M%@,%@ v%@".fmt(y,f.iciLower,f.iciUpper-f.iciLower)},H=function(){return p?"M%@,%@ v%@ M%@,%@ v%@".fmt(f.iciLower,0,f.fullHeight,f.iciUpper,0,f.fullHeight):"M%@,%@ h%@ M%@,%@ h%@".fmt(0,f.iciLower,f.fullHeight,0,f.iciUpper,f.fullHeight)},Q=function(V,W){return p?"M%@,%@ v%@".fmt(f[V],x-j/2,j):"M%@,%@ h%@".fmt(y-j/2,f[W],j)},D=function(X){var Y=j/3,W=f.outliers[X],V=p?W:y,Z=p?x:W;return"M%@,%@ h%@ M%@,%@ v%@".fmt(V-Y/2,Z,Y,V,Z-Y/2,Y)},S=function(){var V=a.create();this.boxPlotSymbols.push(V);V.boxSymbol=w.path("M0,0").attr({stroke:this.symStroke,"stroke-width":this.symStrokeWidth,"stroke-opacity":0});V.lowerRect=w.rect(0,0,0,0).attr({stroke:this.bgStroke,"stroke-width":this.bgStrokeWidth,fill:this.bgFill,"fill-opacity":0.5,cursor:"pointer"}).mousedown(q);V.upperRect=V.lowerRect.clone().mousedown(q);V.lowerWhiskerCover=w.path("M0,0").attr({"stroke-width":this.hoverWidth,stroke:DG.RenderingUtilities.kTransparent,cursor:"pointer"}).hover(r,m).mousedown(q);V.upperWhiskerCover=V.lowerWhiskerCover.clone().hover(r,m).mousedown(q);V.medianCover=V.lowerWhiskerCover.clone().hover(r,m);V.Q1Cover=V.lowerWhiskerCover.clone().hover(r,m);V.Q3Cover=V.lowerWhiskerCover.clone().hover(r,m);V.ici=w.path(i()).attr({stroke:this.iciStroke,"stroke-width":this.iciStrokeWidth,"stroke-opacity":0});V.iciCover=w.path(i()).attr({"stroke-width":this.hoverWidth,stroke:DG.RenderingUtilities.kTransparent}).hover(r,m);V.iciCover.index=E;V.iciHoverElement=w.path(H()).attr({"stroke-width":this.iciHoverElementStrokeWidth,stroke:this.iciStroke,"stroke-opacity":0});V.lowerRect.animatable=V.upperRect.animatable=V.boxSymbol.animatable=V.ici.animatable=true;V.lowerRect.animate({"stroke-opacity":1},s,"<>");V.upperRect.animate({"stroke-opacity":1},s,"<>");V.boxSymbol.animate({"stroke-opacity":1},s,"<>");V.ici.animate({"stroke-opacity":1},s,"<>");V.pushElements(this.myElements);V.pushElements(n)}.bind(this),C=function(W){var Y=this.getPath("model.showICI")?1:0;W.lowerRect.info={range:{lower:M,upper:P,cases:I}};W.upperRect.info={range:{lower:P,upper:K,cases:I}};W.lowerWhiskerCover.info={tipString:"lower = %@",tipValue:T,range:{lower:T,upper:M,cases:I}};W.upperWhiskerCover.info={tipString:"upper = %@",tipValue:N,range:{lower:K,upper:N,cases:I}};W.medianCover.info={tipString:"median = %@",tipValue:P};W.Q1Cover.info={tipString:"Q1 = %@",tipValue:M};W.Q3Cover.info={tipString:"Q3 = %@",tipValue:K};if(g){W.boxSymbol.animate({path:O()},s,"<>");W.lowerRect.animate(F(),s,"<>");W.upperRect.animate(B(),s,"<>");W.ici.animate({"stroke-opacity":Y},s,"<>")}else{W.boxSymbol.attr({path:O()});W.lowerRect.attr(F());W.upperRect.attr(B());W.ici.attr({"stroke-opacity":Y})}W.lowerWhiskerCover.attr("path",J());W.upperWhiskerCover.attr("path",U());W.medianCover.attr("path",Q("x","y"));W.Q1Cover.attr("path",Q("Q1","Q1"));W.Q3Cover.attr("path",Q("Q3","Q3"));W.ici.attr("path",i());W.iciCover.attr("path",i());W.iciHoverElement.attr("path",H());W.iciCover.info={tipString:"ICI: [%@, %@]".fmt(h(P-z),h(P+z))};var V,X;while(W.outliers.length<f.outliers.length){V=w.path("M0,0").attr({stroke:this.symStroke,"stroke-width":this.symStrokeWidth,"stroke-opacity":1});X=w.path("M0,0").attr({"stroke-width":this.hoverWidth,stroke:DG.RenderingUtilities.kTransparent,cursor:"pointer"}).hover(r,m).mousedown(q);V.animatable=true;this.myElements.push(V);n.push(V);W.outliers.push(V);this.myElements.push(X);n.push(X);W.outlierCovers.push(X)}while(W.outliers.length>f.outliers.length){V=W.outliers.pop();n.prepareToMoveOrRemove(V);V.remove();this.myElements.splice(this.myElements.indexOf(V),1);X=W.outlierCovers.pop();n.prepareToMoveOrRemove(X);X.remove();this.myElements.splice(this.myElements.indexOf(X),1)}W.outliers.forEach(function(ad,Z){var aa=u[E].lowerOutliers.length,ac=(Z<aa)?u[E].lowerOutliers[Z]:u[E].upperOutliers[Z-aa],ae=W.outlierCovers[Z],ab=D(Z);ad.attr({path:ab});ae.attr({path:ab});ae.info={tipString:"%@",tipValue:ac,range:{lower:ac,upper:ac,cases:I}}});W.boxSymbol.toFront();W.ici.toFront();W.lowerWhiskerCover.toFront();W.upperWhiskerCover.toFront();W.medianCover.toFront();W.Q1Cover.toFront();W.Q3Cover.toFront();W.iciCover.toFront();W.iciHoverElement.toFront()}.bind(this);var I=u[E].cases,P=u[E].median,M=u[E].Q1,K=u[E].Q3,T=u[E].lowerWhisker,N=u[E].upperWhisker,z=u[E].ICI,G=(isFinite(P)?o.dataToCoordinate(P):v),R=(isFinite(M)?o.dataToCoordinate(M):v),A=(isFinite(K)?o.dataToCoordinate(K):v);f.width=(isFinite(A-R)?Math.abs(A-R):0);f.x=(p?G:E*e);f.y=(p?(l-E)*e:G);f.Q1=R;f.Q3=A;f.lowerWhisker=(isFinite(T)?f.Q1-o.dataToCoordinate(T):0);f.upperWhisker=(isFinite(N)?(p?o.dataToCoordinate(N)-(f.Q1+f.width):-(f.Q1-f.width-o.dataToCoordinate(N))):0);f.iciLower=(isFinite(z)?o.dataToCoordinate(P-z):v);f.iciUpper=(isFinite(z)?o.dataToCoordinate(P+z):v);f.outliers=[];u[E].lowerOutliers.forEach(function(V){f.outliers.push(o.dataToCoordinate(V))});u[E].upperOutliers.forEach(function(V){f.outliers.push(o.dataToCoordinate(V))});var y=f.x+f.cellHeight/2,x=f.y-f.cellHeight/2;if(E>=this.boxPlotSymbols.length){S()}C(this.boxPlotSymbols[E])}.bind(this);for(var t=0;t<l;++t){c(t)}while(this.boxPlotSymbols.length>l){this.boxPlotSymbols.pop().removeFromArrayAndLayer(this.myElements,n)}}}}()));sc_require("components/graph/adornments/plot_adornment");sc_require("components/graph/adornments/value_axis_view_mixin");DG.PlottedCountAdornment=DG.PlotAdornment.extend(DG.ValueAxisViewMixin,{marginX:2,marginY:2,textColor:"#315B7D",numCellsOnX:1,numCellsOnY:1,numCellsOnSecondary:1,numCellsOnPrimary:1,xIsPrimaryAxis:true,modelPropertiesToObserve:[["values","updateToModel"],["isShowingCount","updateSymbols"],["isShowingPercent","updateSymbols"],["percentKind","updateToModel"]],wantVisible:function(){return this.getPath("model.isVisible")},updateToModel:function(a){if(typeof a==="object"){a=false}var b=this.get("model");if(b&&b.get("isVisible")){b.recomputeValueIfNeeded();this.updateSymbols(a)}},updateSymbols:function(f){var g=this;function o(J){var I=g.getPath("model.enableMeasuresForSelection"),F,i="",G=I?J.selectedCount:J.count,H=DG.MathUtilities.roundToSignificantDigits(J.percent,2).roundedValue;if(x&&!r){F=I?"DG.PlottedCount.withSelection":"DG.PlottedCount.withoutSelection";i=F.loc(G.toString())}else{if(r&&!x){F=I?"DG.PlottedPercent.withSelection":"DG.PlottedPercent.withoutSelection";i=F.loc(H)}else{if(x&&r){F=I?"DG.PlottedCountPercent.withSelection":"DG.PlottedCountPercent.withoutSelection";i=I?F.loc(G,J.count,H):F.loc(G,H)}}}return i}function B(){var i="";y.forEach(function(G){var F=o(G);if(F.length>i.length){i=F}});return i}var u=this.get("model"),e=u.get("isVisible"),x=u.get("isShowingCount"),r=u.get("isShowingPercent");if(!e||(!x&&!r)){return}var y=u.get("values"),m=y.length,C=this.myElements.length;this.updateNumCells();if(m!==(this.numCellsOnX*this.numCellsOnY)||m===0){if(m>0){DG.logWarn("DG.PlottedCountAdornment.updateSymbols has mismatch of %@ values and %@ cells",m,(this.numCellsOnX*this.numCellsOnY))}this.removeExtraSymbols(0);return}var E=this.get("paper"),q=this.get("layer"),c=this.getPath("yAxisView.fullCellWidth"),h=this.getPath("xAxisView.fullCellWidth"),D=12,j=B(),s=E.text(-100,0,j).attr({"font-size":D}).addClass("dg-graph-adornment-count"),p=DG.RenderingUtilities.getExtentForTextElement(s,11),z=p.height,b,t,A,v;while(p.width>h){D--;s.attr({"font-size":D});p=DG.RenderingUtilities.getExtentForTextElement(s,11)}s.remove();for(v=0;v<m;++v){var d=y[v],a=d.primaryCell,l=d.secondaryCell,n=(this.xIsPrimaryAxis?a:l),k=(this.xIsPrimaryAxis?l:a),w=this.numCellsOnY-k-1;A=(v>=C);b={x:((n+1)*h)-this.marginX,y:this.marginY+z/3+(w*c),"font-size":D,text:o(d)};if(A){t=E.text(b.x,b.y,b.text);t.attr({"text-anchor":"end",fill:this.textColor});t.addClass("dg-graph-adornment-count");this.myElements.push(t);q.push(t)}else{t=this.myElements[v];t.attr(b)}if(f){t.attr({opacity:0}).animate({opacity:1},DG.PlotUtilities.kDefaultAnimationTime,"<>")}}if(m<this.myElements.length){this.removeExtraSymbols(m)}DG.assert(this.myElements.length===y.length)},removeExtraSymbols:function(d){var e=this.get("layer"),c,b,a;for(c=d,b=this.myElements.length;c<b;++c){a=this.myElements[c];e.prepareToMoveOrRemove(a);a.remove();a=null}this.myElements.length=d},getTitle:function(b,a){var c=(b===1?"DG.DataContext.singleCaseName".loc():"DG.DataContext.pluralCaseName".loc());return"DG.PlottedCountAdornment.title".loc(b,c,a.toFixed(0))},updateNumCells:function(){var c=this.getPath("model.plotModel"),e=c.get("xAxis"),a=c.get("yAxis"),b=c.get("secondaryAxisModel"),d=c.get("primaryAxisModel");this.xIsPrimaryAxis=b===a;this.numCellsOnX=e.get("numberOfCells")||1;this.numCellsOnY=a.get("numberOfCells")||1;this.numCellsOnSecondary=b?b.get("numberOfCells"):1;this.numCellsOnPrimary=d?d.get("numberOfCells"):1}});DG.Analysis={EAttributeType:{eNone:0,eNumeric:1,eCategorical:2,eDateTime:3,eBoundary:4,eColor:5},EAnalysisRole:{eInvalid:-1,eNone:0,ePrimaryNumeric:1,eSecondaryNumeric:2,ePrimaryCategorical:3,eSecondaryCategorical:4,eLegendNumeric:5,eLegendCategorical:6,eVerticalSplit:7,eHorizontalSplit:8},EPercentKind:{eCell:0,eRow:1,eColumn:2},EBreakdownType:{eCount:0,ePercent:1},kNullAttribute:null,forceColorToCategorical:function(a){return(a===this.EAttributeType.eColor)?this.EAttributeType.eCategorical:a}};sc_require("components/graph/adornments/plot_adornment_model");sc_require("components/graph/data_model/analysis");DG.PlottedCountModel=DG.PlotAdornmentModel.extend((function(){return{values:null,plotModel:null,isVisible:false,_isShowingCount:false,destroy:function(){this.plotModel=null;arguments.callee.base.apply(this,arguments)},isShowingCount:function(a,b){if(!SC.none(b)&&b!==this._isShowingCount){this._isShowingCount=b;this.set("isVisible",this._isShowingCount||this._isShowingPercent)}return this._isShowingCount}.property(),_isShowingPercent:false,isShowingPercent:function(a,b){if(!SC.none(b)&&b!==this._isShowingPercent){this._isShowingPercent=b;this.set("isVisible",this._isShowingCount||this._isShowingPercent)}return this._isShowingPercent}.property(),enableMeasuresForSelection:false,_percentKind:null,percentKind:function(a,b){if(!SC.none(b)){this._percentKind=b;this._needsComputing=true}if(SC.none(this._percentKind)){this._percentKind=DG.Analysis.EPercentKind.eRow}return this._percentKind}.property(),recomputeValue:function(){function i(){var j=0;if(!a){b.forEach(function(k){j+=k.count})}b.forEach(function(k){var l=a?k.selectedCount:k.count;j=a?k.count:j;if(j>0&&l>0){k.percent=100*l/j}else{k.percent=0}})}function e(){var k=[];for(var j=0;j<d;j++){k[j]=0}b.forEach(function(l,m){var n=m%d;k[n]+=l.count});b.forEach(function(m,o){var n=a?m.selectedCount:m.count,p=o%d,l=k[p];if(a){m.count=l}if(l>0&&n>0){m.percent=100*n/l}else{m.percent=0}})}function f(){var j=[];for(var k=0;k<h;k++){j[k]=0}b.forEach(function(m,n){var l=Math.floor(n/d);j[l]+=m.count});b.forEach(function(m,o){var n=a?m.selectedCount:m.count,l=Math.floor(o/d),p=j[l];if(a){m.count=p}if(p>0&&n>0){m.percent=100*n/p}else{m.percent=0}})}var h=this.getPath("plotModel.primaryAxisModel.numberOfCells"),d=this.getPath("plotModel.secondaryAxisModel.numberOfCells"),g=(h>1&&d>1)?this.get("percentKind"):DG.Analysis.EPercentKind.eCell,c=this.getPath("plotModel.primaryAxisPlace")===DG.GraphTypes.EPlace.eY,a=this.get("enableMeasuresForSelection");if(this.get("isShowingPercent")&&(h*d===1)&&!a){this.set("isShowingPercent",false)}if(c){if(g===DG.Analysis.EPercentKind.eColumn){g=DG.Analysis.EPercentKind.eRow}else{if(g===DG.Analysis.EPercentKind.eRow){g=DG.Analysis.EPercentKind.eColumn}}}DG.assert(this.plotModel&&this.plotModel.getCellCaseCounts);var b=this.plotModel.getCellCaseCounts(a);switch(g){case DG.Analysis.EPercentKind.eCell:i();break;case DG.Analysis.EPercentKind.eRow:e();break;case DG.Analysis.EPercentKind.eColumn:f();break}this.set("values",b);this._needsComputing=false},_needsComputing:true,createStorage:function(){var a=arguments.callee.base.apply(this,arguments);a.isShowingCount=this.get("isShowingCount")||false;a.isShowingPercent=this.get("isShowingPercent")||false;a.percentKind=SC.none(this.get("percentKind"))?undefined:this.get("percentKind");return a},restoreStorage:function(a){this.set("isShowingCount",SC.none(a.isShowingCount)?a.isVisible:a.isShowingCount);this.set("isShowingPercent",a.isShowingPercent||false);this.set("percentKind",SC.none(a.isShowingPercent)?DG.Analysis.EPercentKind.eRow:a.percentKind);arguments.callee.base.apply(this,arguments)}}}()));DG.PlotAdornmentModel.registry.plottedCount=DG.PlottedCountModel;DG.PlottedFormulaEditContext=SC.Object.extend({plottedFormula:null,expressionBinding:".plottedFormula.expression",formulaView:null,formulaDialog:null,createFormulaView:function(c){var d=this,a=c.formulaPrompt.loc(),b=DG.FormulaTextEditView.create({classNames:["dg-wants-sc-touch"],layout:{height:20},borderStyle:SC.BORDER_BEZEL,isVisible:false,isEditable:false,value:d.getPath("plottedFormula.expression"),leftAccessoryView:SC.LabelView.create({layout:{left:0,width:45,height:20,centerY:0},value:a?"\xA0"+a:"",backgroundColor:"gray"}),desiredExtent:20,mouseDown:function(e){d.openFormulaEditorDialog()},touchStart:function(e){this.mouseDown()}});this.set("formulaView",b);this.set("clientOptions",c?DG.copy(c):{});return b},openFormulaEditorDialog:function(){var f=this,b=this.getPath("plottedFormula.plotModel.dataContext"),a=DG.AttributeFormulaView.buildOperandsMenuAndCompletionData(b),d=this.get("clientOptions"),c=Object.assign({applyTarget:f,applyAction:"applyNewFormula",attrNamePrompt:"DG.PlottedFormula.defaultNamePrompt".loc(),attrNameValue:"",attrNameIsEnabled:false,formulaValue:f.get("expression"),formulaCompletions:a.completionData,formulaOperands:a.operandsMenu},d),e=DG.CreateAttributeFormulaView(c);this.set("formulaDialog",e);return e},createEditCommand:function(c){var b=this.get("clientOptions"),d=this.get("expression");var a=function a(e){this.set("expression",e);this.setPath("formulaView.value",e)}.bind(this);return DG.Command.create({name:b.commandName,undoString:b.undoString,redoString:b.redoString,log:b.logMessage&&b.logMessage.fmt(d,c),executeNotification:{action:"notify",resource:"component",values:{operation:"edit plot formula",type:"DG.GraphView"}},execute:function(){a(c)},undo:function(){a(d)},redo:function(){a(c)}})},applyNewFormula:function(){var b=this.createEditCommand(this.getPath("formulaDialog.formula"));DG.UndoHistory.execute(b);var a=this.get("formulaDialog");if(a){a.close();this.set("formulaDialog",null)}}});DG.PlottedFormulaEditContext.formulaEditContexts={};DG.PlottedFormulaEditContext.hasFormulaEditContextFor=function(a){return a&&!SC.none(DG.PlottedFormulaEditContext.formulaEditContexts[a.get("id")])};DG.PlottedFormulaEditContext.getFormulaEditContext=function(b){var a=b.get("id");if(!DG.PlottedFormulaEditContext.formulaEditContexts[a]){DG.PlottedFormulaEditContext.formulaEditContexts[a]=DG.PlottedFormulaEditContext.create({plottedFormula:b})}return DG.PlottedFormulaEditContext.formulaEditContexts[a]};DG.PlottedFormulaEditContext.destroyFormulaEditContext=function(b){var a=DG.PlottedFormulaEditContext.formulaEditContexts[b];if(a){a.destroy();delete DG.PlottedFormulaEditContext.formulaEditContexts[b]}};sc_require("components/graph/adornments/plot_adornment");DG.PlottedFunctionAdornment=DG.PlotAdornment.extend({modelPropertiesToObserve:[["expression","updateToModel"],["dependentChange","updateToModel"]],curve:null,createElements:function(){if(this.myElements&&(this.myElements.length>0)){return}if(!this.get("paper")){return}this.curve=this.get("paper").path("").attr({stroke:"red"});this.curve.animatable=true;this.myElements.push(this.curve);this.get("layer").push(this.curve)},updateToModel:function(){if(!this.getPath("model.isVisible")||!this.get("paper")){return}this.createElements();var g=this.get("xAxisView"),m=this.get("yAxisView"),b=g.get("pixelMin"),e=g.get("pixelMax"),f=1,i,l=this.get("model"),c="",k,j,h,a=[];if(l){try{for(i=b;i<=e;i+=f){k=g.coordinateToData(i);j=l.evaluate({x:k});if(DG.isFinite(j)){h=m.dataToCoordinate(j);a.push({top:h,left:i})}}}catch(d){}if(a.length>0){c="M"+a[0].left+","+a[0].top+DG.SvgScene.curveBasis(a)}}this.curve.attr({path:c})}});DG.PlottedFunctionAdornment.createFormulaEditView=function(b){var a=DG.PlottedFormulaEditContext.getFormulaEditContext(b);return a.createFormulaView({attrNamePrompt:"DG.PlottedFunction.namePrompt",formulaPrompt:"DG.PlottedFunction.formulaPrompt",formulaHint:"DG.PlottedFunction.formulaHint",commandName:"graph.editPlottedFunction",undoString:"DG.Undo.graph.changePlotFunction",redoString:"DG.Redo.graph.changePlotFunction",logMessage:'Change plotted function: "%@1" to "%@2"'})};DG.ObjectMap={length:function(a){return Object.keys(a||{}).length},keys:function(a){return Object.keys(a||{})},values:function(a){var b=[];DG.ObjectMap.forEach(a,function(c,d){b.push(d)});return b},copy:function(b,a){DG.ObjectMap.forEach(a,function(c,d){b[c]=d})},copySome:function(c,b,a){DG.ObjectMap.forEach(b,function(d,e){if(a(d,e)){c[d]=e}})},forEach:function(a,c){if(!a){return}for(var b in a){if(a.hasOwnProperty(b)){c(b,a[b])}}},firstKey:function(a){return DG.ObjectMap.findKey(a,function(b,c){return true})},findKey:function(b,e){if(!b||!e){return undefined}var c,a=e;if(SC.typeOf(e)!==SC.T_FUNCTION){c=String(e);a=function(f,g){return f===c}}for(var d in b){if(b.hasOwnProperty(d)&&a(d,b[d])){return d}}return undefined},findValue:function(a,c){var b=c;return DG.ObjectMap.findKey(a,function(d,e){return e===b})},insert:function(a,b,c){a[b]=c},remove:function(a,b){var c=b?a[b]:undefined;delete a[b];return c},join:function(b,a){DG.ObjectMap.forEach(a,function(c,d){b[c]=d});return b}};sc_require("utilities/object_map");DG.useFunctionDisplayNames=false;DG.FunctionRegistry=SC.Object.extend((function(){var i=[],b={},e=[],c=true,d=null,h={},g={};function a(j){DG.ObjectMap.forEach(j,function(k,p){var r=p.category||"DG.Formula.FuncCategoryOther",m=r.loc(),o=(d&&d[k])||{},n=p.requiredArgs?p.requiredArgs.min:p.minArgs,q=p.requiredArgs?p.requiredArgs.max:p.maxArgs;if(o.args&&o.args.length){q=o.args.length}if(!b[m]){b[m]={}}var l={name:k,displayName:DG.useFunctionDisplayNames?(o.displayName||k):k,category:m,description:o.description,minArgs:n,maxArgs:q,args:o.args,examples:o.examples};if(l.args){l.args=l.args.map(function(s,t){if(s&&(t<n)){s.required=true}return s})}b[m][k]=l;e.push(k);c=false})}function f(){function j(){if(i.length){i.forEach(function(k){a(k)});i=[]}if(!c){e.sort();c=true}}if(!d){$.ajax({url:"../../../../static/dg/fr/cert/resources/json/function_strings.json",dataType:"text"}).done(function(m){try{var k=window.stripJsonComments(m);d=JSON.parse(k)}catch(l){DG.log("%@: %@",l.name,l.message);d={}}}).fail(function(l,m,k){DG.log("Error loading 'function-strings.json': '%@'",k);d={}}).always(function(){j()})}}return{categorizedFunctionInfo:function(){f();return b}.property(),namesArray:function(){f();return e}.property(),namesWithParentheses:function(){var j=this.get("namesArray");return j.map(function(k){return k+"()"})}.property(),functions:function(){return h}.property(),registerFunctions:function(j){i.push(j);DG.ObjectMap.copy(h,j)},registerAggregates:function(j){i.push(j);DG.ObjectMap.copy(g,j)},getFunction:function(j){return j&&h[j]},isAggregate:function(j){return j&&(g[j]!=null)},getAggregate:function(j){return j&&g[j]}}})());DG.functionRegistry=DG.FunctionRegistry.create();$(function(){DG.functionRegistry.get("namesArray")});sc_require("formula/function_registry");DG.FormulaContext=SC.Object.extend((function(){function a(c,b,d){var e=d&&d[c];if(e&&(b.length<e.minArgs)){throw new DG.FuncArgsError(c,e)}}return{_functionContextStack:null,init:function(){this._functionContextStack=[];this._fns=DG.functionRegistry.get("functions")},beginFunctionContext:function(b){this._functionContextStack.push(b)},endFunctionContext:function(d){var e=d&&d.name,c=this._functionContextStack.length,b=c?this._functionContextStack[c-1].name:"";if(e===b){--this._functionContextStack.length}else{DG.logError("Error: DG.FormulaContext.endFunctionContext -- attempt to end incorrect function context")}},getAggregateFunctionIndices:function(){return[]},filterCase:function(b){return true},registerDependency:function(b){},invalidateNamespace:function(){this.notifyPropertyChange("namespaceChange")},invalidateDependent:function(e,b,d,c,f){},isAggregate:function(b){return false},clearCaches:function(){},willCompile:function(){this.clearCaches()},didCompile:function(){},completeCompile:function(){},invalidateFunctions:function(b){},compileVariable:function(b){switch(b){case"pi":case"π":return"Math.PI";case"e":return"Math.E";default:var c=this.get("eVars");if(c&&(c[b]!==undefined)){return"e."+b}var d=this.get("vars");if(d&&(d[b]!==undefined)){return'c.vars["'+b+'"]'}}this.registerDependency({independentSpec:{type:DG.DEP_TYPE_UNDEFINED,id:b,name:b}});return"(function(){throw new DG.VarReferenceError('"+b+"');})()"},evaluateVariable:function(c,d){switch(c){case"pi":case"π":return Math.PI;case"e":return Math.E;default:var b=d&&d[c];if(b!==undefined){return b}var e=this.get("vars");if(e&&(e[c]!==undefined)){return e[c]}}throw new DG.VarReferenceError(c)},hasAggregates:false,compileFunction:function(d,c,f){var b=function(j,i){var h=j&&j.isRandom;a(d,i,j);if(h){this.registerDependency({independentSpec:{type:DG.DEP_TYPE_SPECIAL,id:"random",name:"random"},aggFnIndices:f})}}.bind(this);var g=this._fns&&this._fns[d];if(g){b(g,c);return"c._fns."+d+".evalFn("+c+")"}var e=this.get("fns");if(e&&typeof e[d]==="function"){return"c.fns."+d+"("+c+")"}return"(function(){throw new DG.FuncReferenceError('"+d+"');})()"},evaluateFunction:function(c,b){var e=DG.functionRegistry.getFunction(c);if(e){a(c,b,this._fns);return e.evalFn.apply(this._fns,b)}var d=this.get("fns");if(d&&typeof d[c]==="function"){a(c,b,this.get("fnsProps"));return d[c].apply(d,b)}throw new DG.FuncReferenceError(c)}}}()));DG.FormulaContext.createContextFunction=function(a){return new Function("c","e","return "+a)};sc_require("formula/formula_context");DG.GlobalFormulaContext=DG.FormulaContext.extend({compileVariable:function(a){var b=DG.globalsController.getGlobalValueByName(a);if(b){this.registerDependency({independentSpec:{type:DG.DEP_TYPE_GLOBAL,id:b.get("id"),name:a}});if(!this.g){this.g={}}this.g[a]=function(){return b.get("value")};return'c.g["'+a+'"]()'}return arguments.callee.base.apply(this,arguments)},evaluateVariable:function(a,c){var b=DG.globalsController.findGlobalByName(a);if(b){this.g[a]=true;return b.get("value")}return arguments.callee.base.apply(this,arguments)}});sc_require("formula/global_formula_context");DG.CollectionFormulaContext=DG.GlobalFormulaContext.extend((function(){return{ALL_FUNCTIONS:"__ALL__",ownerSpec:null,collection:null,attrFns:null,collectionAttrRefCounts:null,aggFnInstances:null,aggFnCount:0,dependencyMgr:function(){return this.getPath("collection.context.dependencyMgr")}.property(),init:function(){arguments.callee.base.apply(this,arguments);this.get("dependencyMgr").registerNode(this.get("ownerSpec"));this.clearCaches()},destroy:function(){this.get("dependencyMgr").removeNode(this.get("ownerSpec"));arguments.callee.base.apply(this,arguments)},clearCaches:function(){this.attrFns={};this.collectionAttrRefCounts={};this.aggFnInstances=[];this.aggFnCount=0}.observes("collection"),getCaseIndex:function(b){var a,d;if(typeof b==="object"){a=b.id;d=b.collection}else{a=b;d=this.collection}var c=d&&d.caseIDToGroupedIndexMap;return c&&(c[a]+1)},getAttrValue:function(b,a){var c=b&&a&&b.getTypedValue(a);if(c instanceof Error){throw c}return c},getAttributeByName:function(c){var f=this.get("collection"),a=f&&f.getAttributeByName(c);if(a){return a}var b=this.getPath("collection.context.dataSet.attrs"),e=b&&b.length,d;for(d=0;d<e;++d){a=b[d];if(a.get("name")===c){return a}}return null},getCollectionForAttribute:function(a){if(a.getPath("collection.id")===this.getPath("collection.id")){return this.get("collection")}var c=this.getPath("collection.context.collections"),b=DG.ObjectMap.findKey(c,function(e,d){return d.getAttributeByName(a.get("name"))});return b&&c[b]},getAggregateFunctionIndices:function(){var c,a,b=this._functionContextStack.length,d=[];for(c=0;c<b;++c){a=this._functionContextStack[c];if(a.isAggregate&&(a.aggFnIndex!=null)){d.push(a.aggFnIndex)}}return d},willCompile:function(){arguments.callee.base.apply(this,arguments);this.get("dependencyMgr")._clearDependencies(this.get("ownerSpec"))},completeCompile:function(){arguments.callee.base.apply(this,arguments);this.get("dependencyMgr")._pruneDependencies(this.get("ownerSpec"))},registerDependency:function(c){var a=SC.clone(c);if(!a.dependentSpec){a.dependentSpec=this.get("ownerSpec")}DG.assert(a.independentSpec);if(!a.aggFnIndices){a.aggFnIndices=this.getAggregateFunctionIndices()}else{if(a.aggFnIndices===this.ALL_FUNCTIONS){a.aggFnIndices=[];for(var b=0;b<this.aggFnInstances.length;++b){a.aggFnIndices.push(b)}}}if(!a.dependentContext){a.dependentContext=this}this.get("dependencyMgr").registerDependency(a)},invalidateDependent:function(g,a,f,e,h){var b=a&&a.id,d=b&&DG.Attribute.getAttributeByID(b);if(d&&!h&&f.simpleDependency){d.invalidateCases(e);g.simpleDependencies.push(a)}if(d&&(h||f.aggFnIndices.length)){d.invalidateCases(null,f.aggFnIndices);g.aggregateDependencies.push(a)}var c=this.get("dependencyMgr");if(f.srcDependencyMgr&&(c!==f.srcDependencyMgr)){c.invalidateDependentsOf([a])}},compileVariable:function(d,e){if(d==="caseIndex"){this.registerDependency({independentSpec:{type:DG.DEP_TYPE_SPECIAL,id:"caseIndex",name:"caseIndex"},aggFnIndices:e});return"c.getCaseIndex(e._case_)"}var b=this.getAttributeByName(d),g=this.get("collection"),h=b&&this.getCollectionForAttribute(b),c=h&&h.get("id");function f(){if(e&&e.length){return true}if(h&&h.isDescendantOf(g)){return false}return true}if(b){this.registerDependency({independentSpec:{type:DG.DEP_TYPE_ATTRIBUTE,id:b.get("id"),name:d},aggFnIndices:e});var a=b.get("id");this.attrFns[d]=f()?function(k){var j=k._caseMap_?k._caseMap_[c]:k._case_,l=j&&j.getTypedValue(a);if(l instanceof Error){throw l}return l}:function(j){throw new DG.HierReferenceError(d)};c=h.get("id");var i=this.collectionAttrRefCounts[c]||0;this.collectionAttrRefCounts[c]=i+1;return'c.attrFns["'+d+'"](e)'}return arguments.callee.base.apply(this,arguments)},evaluateVariable:function(a,c){if(a==="caseIndex"){return this.getCaseIndex(c._id_)}var e=this.get("collection"),d=e&&e.getAttributeByName(a),b=d&&d.get("id");if(b){return this.getAttrValue(c._case_,b)}return arguments.callee.base.apply(this,arguments)},getCollectionToIterate:function(){var d=this.getPath("collection.context.dataSet.collectionOrder"),a=d.length,b,e,c;for(b=a-1;b>=0;--b){e=d[b];c=e.get("id");if(this.collectionAttrRefCounts[c]){return e}}return this.get("collection")},hasAggregates:function(){return this.aggFnCount>0}.property("aggFnCount"),isAggregate:function(a){return DG.functionRegistry.isAggregate(a)},marshalArguments:function(a,e,d){var b,h=d.args.length,g=a.get("requiredArgs"),c=Math.min(h,g.max),f=c+1;d.argFns=[];for(b=0;b<c;++b){d.argFns.push(DG.FormulaContext.createContextFunction(d.args[b]))}if(h>=f){d.filterFn=DG.FormulaContext.createContextFunction(d.args[f-1])}},validateArguments:function(a,d,c){var g=a.get("requiredArgs"),e=g.max+1,f=c.args.length,b=c.argFns.length;if((b<g.min)||(f>e)){throw new DG.FuncArgsError(c.name,{min:g.min,max:e})}},evalAggregate:function(c,e){var b=this.aggFnInstances[e];var d=DG.functionRegistry.getAggregate(b.name),a=d&&d.queryCache(this,c,b);if(a!==undefined){return a}this.marshalArguments(d,c,b);this.validateArguments(d,c,b);a=d.evaluate(this,c,b);return a},beginFunctionContext:function(a){if(a.isAggregate){a.aggFnIndex=this.aggFnCount}arguments.callee.base.apply(this,arguments)},invalidateFunctions:function(a){if(a){a.forEach(function(c){var b=this.aggFnInstances&&this.aggFnInstances[c];if(b){b.caches={};b.results={}}}.bind(this))}},compileFunction:function(c,b,d){if(this.isAggregate(c)){var e=DG.functionRegistry.getAggregate(c);if(e&&e.isCaseIndexDependent(b)){this.registerDependency({independentSpec:{type:DG.DEP_TYPE_SPECIAL,id:"caseIndex",name:"caseIndex"},aggFnIndices:d})}var a=this.aggFnCount++;this.aggFnInstances.push({index:a,name:c,args:b,aggFnIndices:d});return"c.evalAggregate(e,"+a+")"}return arguments.callee.base.apply(this,arguments)}}}()));sc_require("formula/collection_formula_context");sc_require("components/graph/adornments/plot_adornment_model");DG.PlottedFunctionContext=DG.CollectionFormulaContext.extend((function(){return{adornmentKey:null,plotModel:null,primaryVarName:function(){var b=this.getPath("plotModel.primaryVarID")||this.getPath("plotModel.xVarID"),a=b&&DG.Attribute.getAttributeByID(b),c=a&&a.get("name");return !SC.empty(c)?c:null}.property("plotModel"),isPrimaryVarName:function(a){if(SC.empty(a)){return false}if(a===this.get("primaryVarName")){return true}if((a==="x")&&(this.get("adornmentKey")==="plottedFunction")){return true}return false}.property("primaryVarName"),groupVarID:function(){return this.getPath("plotModel.secondaryVarID")||-1}.property("plotModel"),filterCase:function(a){var c=arguments.callee.base.apply(this,arguments),b=this.getPath("plotModel.enableMeasuresForSelection")?this.getPath("plotModel.selection"):this.getPath("plotModel.cases");return c&&b.indexOf(a._case_)>=0},compileVariable:function(a){if(this.isPrimaryVarName(a)){if(this.get("adornmentKey")==="plottedValue"){a=this.get("primaryVarName")}else{return"e.x"}}return arguments.callee.base.apply(this,arguments)},didCompile:function(){arguments.callee.base.apply(this,arguments);var a=this.get("plotModel"),b=DG.Debug.scObjectID(a);this.registerDependency({independentSpec:{type:DG.DEP_TYPE_PLOT,id:b,name:"plot-"+b},aggFnIndices:this.ALL_FUNCTIONS})},evaluateVariable:function(a,b){if(this.isPrimaryVarName(a)){if(this.get("adornmentKey")==="plottedValue"){a=this.get("primaryVarName")}else{return b.x}}return arguments.callee.base.apply(this,arguments)},marshalArguments:function(b,d,c){arguments.callee.base.apply(this,arguments);var g=b.get("requiredArgs"),f=c.args.length;if((f<g.min)&&(this.get("adornmentKey")==="plottedValue")){var e=this.get("primaryVarName"),a=e&&this.compileVariable(e,c.aggFnIndices);if(a){c.argFns.unshift(DG.FormulaContext.createContextFunction(a))}}},invalidateDependent:function(d,a,c,b,e){if(c.aggFnIndices){this.invalidateFunctions(c.aggFnIndices)}this.notifyPropertyChange("dependentChange")}}}()));DG.PlottedFunctionModel=DG.PlotAdornmentModel.extend({_expression:null,expression:function(a,c){if(c!==undefined){var b=this.get("siblingPlottedFunctions");if(b){b.forEach(function(d){d.set("expression",c)})}if(SC.empty(c)){this._expression=null}else{if(SC.none(this._expression)){this.createDGFormula(c)}else{this._expression.set("source",c)}}return this}return(this._expression&&this._expression.get("source"))||""}.property(),siblingPlottedFunctions:null,destroy:function(){if(this._expression){this.destroyDGFormula()}DG.PlottedFormulaEditContext.destroyFormulaEditContext(this.get("id"));arguments.callee.base.apply(this,arguments)},createDGFormula:function(d){var b=this.get("adornmentKey"),e=this.get("id"),a={type:b,id:e,name:b+e},c=DG.PlottedFunctionContext.create({ownerSpec:a,adornmentKey:b,plotModel:this.get("plotModel"),collection:this.get("primaryCollection")});this._expression=DG.Formula.create({context:c,source:d});this._expression.addObserver("dependentChange",this,"dependentDidChange")},destroyDGFormula:function(){this._expression.removeObserver("dependentChange",this,"dependentDidChange");this._expression.destroy();this._expression=null},primaryCollection:function(){var b=this.getPath("plotModel.primaryVarID")||this.getPath("plotModel.xVarID"),a=b&&DG.Attribute.getAttributeByID(b),c=a&&a.get("collection");return c}.property("plotModel"),splitAxisModel:function(){if(!this.getPath("plotModel.yAxis.isNumeric")){return this.getPath("plotModel.yAxis")}if(!this.getPath("plotModel.xAxis.isNumeric")){return this.getPath("plotModel.xAxis")}return null}.property("plotModel"),dependentDidChange:function(a,b){this.notifyPropertyChange(b)},globalNamesDidChange:function(){this.invalidateExpression()}.observes("DG.globalsController.globalNameChanges"),enableMeasuresForSelectionDidChange:function(){this.invalidateExpression()}.observes("enableMeasuresForSelection"),invalidateExpression:function(){if(this._expression){this._expression.invalidate()}},evaluate:function(a){if(!this._expression){return}return this._expression.evaluate(a)},createStorage:function(){var a=arguments.callee.base.apply(this,arguments);a.adornmentKey=this.get("adornmentKey");a.expression=this.get("expression");return a},restoreStorage:function(a){arguments.callee.base.apply(this,arguments);this.set("adornmentKey",a.adornmentKey);this.set("expression",a.expression)}});DG.PlotAdornmentModel.registry.plottedValue=DG.PlottedFunctionModel;DG.PlotAdornmentModel.registry.plottedFunction=DG.PlottedFunctionModel;sc_require("components/graph/adornments/plot_adornment");sc_require("components/graph/adornments/line_label_mixin");DG.PlottedValueAdornment=DG.PlotAdornment.extend(DG.LineLabelMixin,{statisticsKey:"plottedValue",lastHoverValue:null,valueAxisView:function(){return this.getPath("parentView.primaryAxisView")}.property(),splitAxisView:function(){return this.getPath("parentView.secondaryAxisView")}.property(),valueTextElement:null,valueSegments:null,values:function(){var b=this.get("splitAxisModel"),a=[];if(b&&b.forEachCellDo){b.forEachCellDo(function(d,c){a.push(this.getValueToPlot(c))}.bind(this))}else{a.push(this.getValueToPlot())}return a}.property(),valueStrings:function(){var c=this.get("values");if(c instanceof Error){return c.message}var a=DG.PlotUtilities.findFractionDigitsForAxis(this.get("valueAxisView")),b=DG.Format.number().fractionDigits(0,a);return c.map(function(d){if(d<2500){b.group("")}else{b.group(",")}return DG.isFinite(d)?b(d):(d!=null?d.toString():null)})}.property("values"),modelPropertiesToObserve:[["expression","updateToModel"],["dependentChange","updateToModel"]],splitAxisModel:function(){return this.getPath("model.splitAxisModel")}.property(),init:function(){arguments.callee.base.apply(this,arguments);this.valueSegments=[];this.myElements=[]},createElements:function(l){var g=this;if(this.valueSegments.length===l){return}function e(){var m=i.path("").addClass("dg-plotted-value");return m}function d(){var m=i.text(0,0,"").attr({"text-anchor":"start",opacity:1}).hide().addClass("dg-graph-adornment");return m}function h(){var m=i.path("").addClass("dg-plotted-value-background");return m}function j(n){var o=5;function p(){var w="rgba(0, 255, 0, 0.2)",s=10,v={stroke:w},u=g.valueTextElement,t=g.get("valueStrings")[n],r=this.getBBox();this.stop();this.animate(v,s);u.attr("text",t);if(r.y===r.y2){u.attr({x:r.x2-5,y:r.y-6,"text-anchor":"end"})}else{u.attr({x:r.x+3,y:r.y+6,"text-anchor":"start"})}u.show();if(t!==g.lastHoverValue){g.updateHoverLog(g.statisticsKey+"="+t);g.lastHoverValue=t}}function m(){var r={stroke:DG.RenderingUtilities.kTransparent};this.stop();this.animate(r,DG.PlotUtilities.kHighlightHideTime);g.valueTextElement.hide()}var q=i.path("M0,0").attr({"stroke-width":o,stroke:DG.RenderingUtilities.kTransparent}).hover(p,m);return q}var c=this.getPath("paperSource.layerManager"),k=this.get("layer"),i=this.get("paper"),f=this.get("valueSegments");if(!this.valueTextElement){this.valueTextElement=d()}while(f.length<l){var b={background:h(),valueSegment:e(),cover:j(f.length)};f.push(b);DG.ObjectMap.forEach(b,function(m,n){this.myElements.push(n);k.push(n)}.bind(this))}while(f.length>l){var a=f.pop();DG.ObjectMap.forEach(a,function(m,n){c.removeElement(n,true);n.remove()})}},updateToModel:function(){if(this.getPath("model.isVisible")){var k=this.get("splitAxisModel"),m=k?k.get("numberOfCells"):1,l=this.get("valueAxisView"),e=this.get("splitAxisView");if(!(l&&e)){return}this.createElements(m);var c=e.get("fullCellWidth"),f=this.get("paper"),i=this.get("values");for(var o=0;o<m;o++){var a=i&&i[o],b=this.get("valueSegments")[o].valueSegment,h=this.get("valueSegments")[o].background,d=this.get("valueSegments")[o].cover,n,j,g;if(DG.isFinite(a)){n=l.dataToCoordinate(a);if(l.get("orientation")===DG.GraphTypes.EOrientation.kHorizontal){j={x:n,y:f.height-o*c};g={x:n,y:f.height-(o+1)*c}}else{j={x:o*c,y:n};g={x:(o+1)*c,y:n}}DG.RenderingUtilities.updateLine(b,j,g);DG.RenderingUtilities.updateLine(d,j,g);DG.RenderingUtilities.updateLine(h,j,g)}else{b.attr({path:""});d.attr({path:""});h.attr({path:""})}}}}.observes("DG.globalsController.globalNameChanges"),valueAxisAttrDidChange:function(){var a=this.get("model");if(a){this.get("model").invalidateExpression()}}.observes("*valueAxisView.model.firstAttributeName"),getValueToPlot:function(f){var a=this.get("model"),b=f?{_groupID_:f}:{},d=NaN;try{if(a){d=a.evaluate(b)}}catch(c){d=c}return d},updateHoverLog:function(a){DG.logUser("%@: %@","hoverOverPlottedValue",a)}});DG.PlottedValueAdornment.createFormulaEditView=function(a){var b=DG.PlottedFormulaEditContext.getFormulaEditContext(a);return b.createFormulaView({attrNamePrompt:"DG.PlottedValue.namePrompt",formulaPrompt:"DG.PlottedValue.formulaPrompt",formulaHint:"DG.PlottedValue.formulaHint",commandName:"graph.editPlottedValue",undoString:"DG.Undo.graph.changePlotValue",redoString:"DG.Redo.graph.changePlotValue",logMessage:'Change plotted value: "%@1" to "%@2"'})};sc_require("components/graph/adornments/data_tip");DG.PointDataTip=DG.DataTip.extend({caseIndex:null,showOnlyLegendData:false,getDataTipText:function(){var d=this,k=this.getPath("plotLayer.model"),b=k&&k.get("cases"),a=b?b.unorderedAt(this.get("caseIndex")):null;function c(q){var m=function(){return DG.PlotUtilities.findFractionDigitsForRange(x.getPath("attributeStats.minMax"))},s=function(){return DG.PlotUtilities.findFractionDigitsForAxis(d.getPath("plotLayer."+q+"AxisView"))};var x=k.getPath("dataConfiguration."+q+"AttributeDescription"),v=x&&x.get("attributes"),n=d.getPath("plotLayer.plotIndex");if(!x){return null}n=(n<v.length)?n:0;var u=v[n],w=(typeof(u)==="object")?u.get("type"):null,t=(typeof(u)==="object")?u.get("id"):null,r=(q==="legend")?m:s,p,o;if(!SC.none(t)&&w!=="qualitative"){p=u.get("name");o=DG.PlotUtilities.getFormattedCaseValue(a,x,r,n);return p+": "+o}return null}function l(m){if(!SC.none(m)&&e.indexOf(m)<0){if(e.length>0){e+="\n"}e+=m}}if(SC.none(a)){return""}var g=c("legend"),j=c("caption"),e="";if(!this.get("showOnlyLegendData")){var i=c("x"),h=this.getPath("plotLayer.isUsingY2")?"y2":"y",f=c(h);l(i);l(f)}l(j);l(g);return e},show:function(a,d,c,b){this.set("tipOrigin",{x:a,y:d});this.set("tipSourceRadius",c);this.set("caseIndex",b);arguments.callee.base.apply(this,arguments)},handleChanges:function(b){var a=(SC.typeOf(b)===SC.T_NUMBER?SC.IndexSet.create(b):b);a=a||[];if(!a.contains(this.get("caseIndex"))){return}this.updateTip()}});DG.AxisCoordinator=SC.Object.extend({xAxisArray:null,yAxisArray:null,y2AxisArray:null,_handlingChange:false,init:function(){this.xAxisArray=[];this.yAxisArray=[];this.y2AxisArray=[]},destroy:function(){this.xAxisArray.forEach(this.removeAxisObservers);this.yAxisArray.forEach(this.removeAxisObservers);this.yAxisArray.forEach(this.removeAxisObservers);this.xAxisArray=[];this.yAxisArray=[];this.y2AxisArray=[]},removeAxisObservers:function(a){if(a){a.removeObserver("lowerBound",this,this.boundChanged);a.removeObserver("upperBound",this,this.boundChanged)}},setAxis:function(a,c,b){var d=this.get(a+"AxisArray");this.removeAxisObservers(d[c]);b.addObserver("lowerBound",this,this.boundChanged,a);b.addObserver("upperBound",this,this.boundChanged,a);d[c]=b},boundChanged:function(d,c,f,b){if(this._handlingChange){return}var a=this.get(b+"AxisArray"),e=d.get(c);this._handlingChange=true;a.forEach(function(g){if(d!==g){g.set(c,e)}});this._handlingChange=false}});DG.GraphDropTarget={kDropFrameClass:"dg-graph-drop-frame",blankDropHint:"",isDropTarget:true,dragData:null,getDataConfiguration:function(){return this.get("dataConfiguration")||this.getPath("model.dataConfiguration")||this.getPath("graphModel.dataConfiguration")},convertFrameToView:function(c,a){var b=$(this.containerLayer()).offset();return{x:b.left-window.pageXOffset,y:b.top-window.pageYOffset,width:c.width,height:c.height}},computeDragOperations:function(a){if(this.isValidAttribute(a)){return SC.DRAG_LINK}else{return SC.DRAG_NONE}},dragEntered:function(a,b){this.borderFrame.addClass("dg-graph-drop-frame-fill");this.showDropHint({x:b.clientX,y:b.clientY})},dragExited:function(a,b){this.borderFrame.removeClass("dg-graph-drop-frame-fill");this.hideDropHint()},acceptDragOperation:function(){return YES},isValidAttributeForPlotSplit:function(d){var c=d.data.attribute,f=this.get("plottedAttribute"),g=this.getDataConfiguration(),a=g.attributeIsNominal(c),b=g&&g.hasAtLeastOneAttributeAssigned(),e=a&&b&&c!==f;return e},isValidAttribute:function(c){var a=c.data.attribute,b=this.get("plottedAttribute");return SC.none(b)||(b!==a)},dragStarted:function(h){var g=this.get("paper");if(!g){return}var i=3,f,j=h.data.attribute.get("name"),e=this.getPath("plottedAttribute.name"),b=this.get("orientation"),a=this.getDataConfiguration(),k;function c(l){return SC.empty(l)||l==="undefined"}if(this.isValidAttribute(h)){if(b===DG.GraphTypes.EOrientation.kVertical2){this.set("isVisible",true);var d=this.get("parentView");if(d){d.makeSubviewFrontmost(this)}}if(a.attributeIsNominal(h.data.attribute)&&b!==DG.GraphTypes.EOrientation.kNone){if(b===DG.GraphTypes.EOrientation.kVertical||b===DG.GraphTypes.EOrientation.kVertical2){k="DG.GraphView.layoutPlotsVertically".loc(j)}else{k="DG.GraphView.layoutPlotsSideBySide".loc(j)}}else{k=(c(e)?this.get("blankDropHint").loc(j):"DG.GraphView.replaceAttribute".loc(e,j))}f={x:i,y:i,width:g.width-2*i,height:g.height-2*i};if(this.get("isVertical")){f.y+=18+2*i;f.height-=18+2*i}if(SC.none(this.borderFrame)){this.borderFrame=g.path("").addClass(this.kDropFrameClass)}this.borderFrame.attr({path:DG.RenderingUtilities.pathForFrame(f)}).show();this.set("dropHintString",k)}},dragEnded:function(){if(this.borderFrame){this.borderFrame.hide()}},borderFrame:null,dropHintString:null,isVertical:function(){var a=this.get("orientation");return a&&[DG.GraphTypes.EOrientation.kVertical,DG.GraphTypes.EOrientation.kVertical2,DG.GraphTypes.EOrientation.kRight].indexOf(a)>=0}.property(),showDropHint:function(a){if(SC.empty(this.dropHintString)){return}a.y+=10;DG.mainPage.getPath("mainPane.tipView").show(a,this.dropHintString)},hideDropHint:function(){DG.mainPage.getPath("mainPane.tipView").hide()},performDragOperation:function(a,b){this.hideDropHint();this.set("dragData",a.data);return SC.DRAG_LINK},_externalDragObject:function(){var a=DG.mainPage.getPath("mainPane.dragAttributeData");if(a){return{data:a}}}.property(),externalDragDidChange:function(){var a=this.get("_externalDragObject");if(!a){return}if(DG.mainPage.getPath("mainPane._isDraggingAttr")){this.dragStarted(a)}else{this.dragEnded()}}.observes("DG.mainPage.mainPane._isDraggingAttr"),dataDragEntered:function(a){var b=this.get("_externalDragObject");if(b&&this.isValidAttribute(b)){this.dragEntered(b,a);a.preventDefault()}},dataDragHovered:function(a){var b=this.get("_externalDragObject");if(b&&this.isValidAttribute(b)){a.dataTransfer.dropEffect="copy";a.preventDefault();a.stopPropagation()}else{return false}},dataDragDropped:function(b){var c=this.get("_externalDragObject");var a;if(c&&this.isValidAttribute(c)){a=DG.mainPage.getPath("mainPane.dragAttributeData");this.hideDropHint();this.set("dragData",a);b.preventDefault()}else{return false}},dataDragExited:function(a){var b=this.get("_externalDragObject");if(b&&this.isValidAttribute(b)){this.dragExited(b,a);a.preventDefault()}}};sc_require("libraries/raphael");DG.RenderingUtilities={_blankCanvas:Raphael(-500,0,500,500),kTransparent:"rgba(255, 255, 255, 0)",kSeeThrough:"rgba(255, 255, 255, 0.001)",kCaptionFontHeight:20,kDefaultFontHeight:12,getExtentForTextElement:function(f,d,g){var e=f.getBBox(g),c=(e&&e.height)||d,b=e?e.width:0;if(!b){var a=this.textExtent(f.attr("text"),f.attr("font-family"),f.attr("font-size"));b=a.x;c=a.y}return{width:b,height:c}},textExtentOnCanvas:function(c,g,d,b){var f=c.text(-500,-5000,g).attr({"font-family":d,"font-size":b}),e=f.getBBox(),a={x:e.width,y:e.height};f.remove();return a},textExtent:function(c,b,a){return this.textExtentOnCanvas(this._blankCanvas,c,b,a)},elideToFit:function(e,h){var b=e.attr("text"),c=b.length,a=0,g=0,d;do{d=this.getExtentForTextElement(e,DG.RenderingUtilities.kDefaultFontHeight,true).width;if(d>h){var f=Math.floor((h/d)*c)-a;b=e.attr("text").substring(0,f)+"…";c=b.length;a++}e.attr("text",b);g++}while(d>h&&g<10)},updateLine:function(b,a,c){b.attr({path:"M"+a.x+" "+a.y+" L"+c.x+" "+c.y})},pathForFrame:function(a){return"M"+a.x+" "+a.y+" L"+(a.x+a.width)+" "+a.y+" L"+(a.x+a.width)+" "+(a.y+a.height)+" L"+a.x+" "+(a.y+a.height)+" L"+a.x+" "+a.y},rotateText:function(b,a,e,d){if(Raphael.version<"2.0"){b.rotate(a,e,d)}else{var c="r%@,%@,%@".fmt(a,e,d);b.attr({transform:c})}},testPaperValidity:function(a){this.printPaper(a);var b={},c=a.bottom;while(c){if(b[c.id]){console.log("Paper is not valid. Element %@ appears twice".fmt(c.id));return false}if(c.prev&&c.prev.next!==c){console.log("Paper is not valid. Prev of %@ not pointing to %@".fmt(c.id,c.id));return false}if(c.next&&c.next.prev!==c){console.log("Paper is not valid. Next of %@ not pointing to %@".fmt(c.id,c.id));return false}b[c.id]=true;c=c.next}return true},svgElementClass:function(a){var b;if(a[0]){switch(a[0].constructor){case SVGImageElement:b="I";break;case SVGRectElement:b="R";break;case SVGPathElement:b="P";break;case SVGCircleElement:b="C";break;default:b="?"}}return b},printPaper:function(a){var d="Paper-> ",c=a.bottom,e={},b=false;while(c&&!b){b=e[c.id];if(!b){e[c.id]=true;d+=c.id+": "+this.svgElementClass(c)+", ";c=c.next}else{d+="FAILED - repetition of "+c.id}}console.log(d)}};sc_require("components/graph/utilities/graph_drop_target");sc_require("views/raphael_base");sc_require("utilities/rendering_utilities");DG.AxisLabelView=DG.RaphaelBaseView.extend(DG.GraphDropTarget,(function(){return{classNames:"dg-axis-view".w(),orientation:null,plottedAttribute:null,blankDropHint:"DG.GraphView.addToEmptyPlace",desiredExtent:DG.RenderingUtilities.kCaptionFontHeight,init:function(){arguments.callee.base.apply(this,arguments);var a;switch(this.get("orientation")){case DG.GraphTypes.EOrientation.kHorizontal:a="dg-h-axis";break;case DG.GraphTypes.EOrientation.kVertical:a="dg-v-axis";break;case DG.GraphTypes.EOrientation.kVertical2:a="dg-v2-axis";break}this.get("classNames").push(a)}}}()));DG.AxisModel=SC.Object.extend({attributeDescription:null,dataConfiguration:null,scaleCanAnimate:true,getPointColor:null,setLinkToPlotIfDesired:function(a){},labels:function(){var b=this.get("attributeDescription"),a=[];if(b){b.get("attributes").forEach(function(d){if(d!==DG.Analysis.kNullAttribute){var c=d.get("name"),f=d.get("unit"),e=c+(!SC.empty(f)?" ("+f+")":"");a.push(e)}})}return a}.property(),labelsDidChange:function(){this.notifyPropertyChange("labels")}.observes("*attributeDescription.attribute"),handleUpdateAttribute:function(a){this.labelsDidChange()},labelDescription:function(){return this.getPath("attributeDescription.attribute.description")||""}.property(),labelDescriptionDidChange:function(){this.notifyPropertyChange("labelDescription")}.observes("*attributeDescription.attribute"),getLabelDescription:function(a){var b=this.getPath("attributeDescription.attributes");return(b&&a<b.length)?b[a].get("description"):""},firstAttribute:function(){var a=this.getPath("attributeDescription.attributes");if(SC.isArray(a)&&(a.length>0)){return a[0]}}.property(),firstAttributeName:function(){var a=this.get("firstAttribute");return a?a.get("name"):""}.property(),firstAttributeNameDidChange:function(){this.notifyPropertyChange("firstAttributeName")}.observes("*attributeDescription.attribute","*attributeDescription.attributes"),firstAttributeUnit:function(){var b="",a=this.get("firstAttribute");if(a){b=a.get("unit")}return b||""}.property(),numberOfCells:function(){return 1}.property().cacheable(),valueToCellNumber:function(){return 0},axisAnimator:null,cellNameToCellNumber:function(a){return 0},isNumeric:null,noAttributes:function(){return this.getPath("attributeDescription.noAttributes")}.property(),setLowerAndUpperBounds:function(){},stopAnimation:function(){var a=this.get("axisAnimator");if(!SC.none(a)){a.endAnimation()}}});sc_require("components/graph/utilities/graph_drop_target");sc_require("views/raphael_base");DG.AxisMultiTarget=DG.RaphaelBaseView.extend(DG.GraphDropTarget,{classNameBindings:["dragIsInside:dg-graph-drop-multi-background"],dragIsInside:false,dataConfiguration:null,attributeDescription:null,otherAttributeDescription:null,plottedAttribute:function(){return this.getPath("attributeDescription.attribute")}.property(),otherPlottedAttribute:function(){return this.getPath("otherAttributeDescription.attribute")}.property(),plusArea:null,desiredExtent:function(){return{width:this.getPath("parentView.layout.width")||24,height:24}}.property(),dragEntered:function(a,b){this.plusArea.addClass("dg-graph-drop-plus-fill");this.set("dragIsInside",true);this.showDropHint({x:b.clientX,y:b.clientY})},dragExited:function(a,b){this.plusArea.removeClass("dg-graph-drop-plus-fill");this.set("dragIsInside",false);this.hideDropHint()},isValidAttribute:function(a){return this.isValidAttributeForScatterplot(a)||this.isValidAttributeForPlotSplit(a)},isValidAttributeForPlotSplit:function(a){return(a.data.attribute!==this.getPath("dataConfiguration.topAttributeDescription.attribute"))&&DG.GraphDropTarget.isValidAttributeForPlotSplit.call(this,a)},isValidAttributeForScatterplot:function(f){var g=f.data.attribute,b=this.getDataConfiguration().attributeIsNominal(g),e=this.get("plottedAttribute"),a=this.getPath("dataConfiguration.xAttributeDescription"),h=a?a.get("attribute"):DG.Analysis.kNullAttribute,d=this.getPath("dataConfiguration.yAttributeDescription"),i=d?d.get("attribute"):DG.Analysis.kNullAttribute,c=(h!==DG.Analysis.kNullAttribute)&&(i!==DG.Analysis.kNullAttribute)&&(i!==g)&&(e!==g)&&a.get("isNumeric")&&d.get("isNumeric")&&!b;return c},dragStarted:function(f){var c=3,k=24,b=this.isValidAttributeForScatterplot(f),d=this.isValidAttributeForPlotSplit(f);function a(){return"M-6,-18 h6 v6 h6 v6 h-6 v6 h-6 v-6 h-6 v-6 h6 v-6Z"}if(b||d){this.set("isVisible",true);var e=this.get("parentView");if(e){e.makeSubviewFrontmost(this)}var j=k/2+c,i=j+2*c;if(SC.none(this.plusArea)){this.plusArea=this._paper.path(a()).addClass(this.kDropFrameClass)}this.plusArea.transform("").transform("T"+j+","+i).show();var h=f.data.attribute.get("name"),g=b?"DG.GraphView.addAttribute".loc(h):"DG.GraphView.layoutPlotsSideBySide".loc(h);this.set("dropHintString",g)}},dragEnded:function(){if(this.plusArea){this.plusArea.hide()}this.set("isVisible",false)}});sc_require("components/graph/utilities/graph_drop_target");sc_require("views/raphael_base");DG.AxisView=DG.RaphaelBaseView.extend(DG.GraphDropTarget,(function(){return{displayProperties:["suppressLabel","model.attributeDescription.attribute","model.attributeDescription.attributeStats.categoricalStats.numberOfCells","model.attributeDescription.attributeStats.cellMap","otherYAttributeDescription.attribute"],classNames:"dg-axis-view".w(),model:null,orientation:null,paperSourceForLabel:null,paperForLabel:function(){if(this.get("paperSourceForLabel")){return this.getPath("paperSourceForLabel.paper")}else{return this.get("paper")}}.property("paperSourceForLabel"),suppressLabel:false,allowCellBoundaries:true,plottedAttribute:function(){return this.getPath("model.attributeDescription.attribute")}.property(),plottedAttributeDidChange:function(){if(this.get("paperSourceForLabel")){this.setPath("paperSourceForLabel.plottedAttribute",this.get("plottedAttribute"))}}.observes("model.attributeDescription.attribute"),xAttributeDescription:null,otherYAttributeDescription:null,blankDropHint:"DG.GraphView.addToEmptyPlace",_hiddenDragView:null,desiredExtent:function(){if(this.get("paperSourceForLabel")){return 0}var a=this.get("labelExtent"),b;switch(this.get("orientation")){case DG.GraphTypes.EOrientation.kHorizontal:case DG.GraphTypes.EOrientation.kTop:b="y";break;case DG.GraphTypes.EOrientation.kVertical:case DG.GraphTypes.EOrientation.kVertical2:case DG.GraphTypes.EOrientation.kRight:b="x";break}return a[b]}.property("labelNode","paperSourceForLabel"),pixelMinOffset:function(){var a=this.get("paperSourceForLabel");return a?a.get("desiredExtent"):0}.property("paperSourceForLabel"),axisLineCoordinate:function(){var a;switch(this.get("orientation")){case DG.GraphTypes.EOrientation.kVertical:a=this.get("drawWidth");break;case DG.GraphTypes.EOrientation.kVertical2:case DG.GraphTypes.EOrientation.kHorizontal:case DG.GraphTypes.EOrientation.kRight:a=0;break;case DG.GraphTypes.EOrientation.kTop:a=this.get("drawHeight");break}return a}.property("drawWidth","drawHeight"),noAttributesOnEitherAxis:function(){var a=this.getPath("model.dataConfiguration");return a&&a.noAttributesFor(["x","y"])},pixelMin:function(){var a=0;if(this.get("isVertical")){a=this.get("drawHeight")}return a}.property(),pixelMinDidChange:function(){this.notifyPropertyChange("pixelMin")}.observes("drawHeight"),pixelMax:function(){return this.get("isVertical")?0:this.get("drawWidth")}.property("drawWidth"),labelExtent:function(){var d=DG.RenderingUtilities.kCaptionFontHeight,b=this.get("labelNode"),a={x:d,y:d};if(!SC.none(b)){var c=b.extent();a={x:isNaN(c.width)?d:Math.max(d,c.width),y:isNaN(c.height)?d:Math.max(d,Math.ceil(c.height/2)*2)}}return a}.property("labelNode").cacheable(),isNumeric:null,labelNodes:function(){var h=this,c=false,j=0,a=this.get("isVertical")?-90:0,d=this.getPath("otherYAttributeDescription.attributes"),b=SC.isArray(d)?d.length:0,f=(this.get("orientation")===DG.GraphTypes.EOrientation.kVertical2)?b:0,l=this.getPath("model.noAttributes"),k=this.noAttributesOnEitherAxis(),g,e,i,n,m;if(SC.none(this.get("paperForLabel"))||(this._labelNodes==null)){return[]}if((this.constructor===DG.AxisView)&&(k||(l&&DG.ComponentView.isComponentViewForViewSelected(this)))){g=["DG.AxisView.emptyGraphCue".loc()];e=0}else{g=this.getPath("model.labels");e=f+g.length+((this.get("orientation")===DG.GraphTypes.EOrientation.kVertical)?b:0)}g.forEach(function(p,o){if(j>=h._labelNodes.length){i=DG.LabelNode.create({paper:h.get("paperForLabel"),rotation:a,colorIndex:f+o,numColors:e,getPointColor:o===0?h.getPath("model.getPointColor"):null,priorNode:(j>0)?g[j-1]:null});n=h.getPath("model.attributeDescription.attributes");m=(SC.isArray(n))?n[o]:null;if(m){i.setDragLabelHandler(DG.DragLabelHandler.create({labelNode:i,labelView:h._hiddenDragView,viewToAddTo:h,attributeDescription:h.getPath("model.attributeDescription"),attributeName:m.get("name"),dataContext:h.getPath("model.dataConfiguration.dataContext")}))}h._labelNodes.push(i);c=true}else{i=h._labelNodes[j];i.beginPropertyChanges();i.setIfChanged("colorIndex",f+o);i.setIfChanged("numColors",e);if(o===0&&e>1){i.numColorsChanged()}i.endPropertyChanges()}c=(p!==i.get("text"));i.setIfChanged("text",p);j++});while(this._labelNodes.length>j){this._labelNodes.pop().remove();c=true}if(c){this.notifyPropertyChange("labelNode",this._labelNodes)}return this._labelNodes}.property(),labelNodesDidChange:function(){this.notifyPropertyChange("labelNodes");this.get("labelNodes")}.observes("*model.labels"),labelNode:function(){var a=this.get("labelNodes");return(a.length>0)?a[0]:null}.property("labelNodes"),_labelNodes:null,init:function(){arguments.callee.base.apply(this,arguments);this._labelNodes=[];var a;switch(this.get("orientation")){case DG.GraphTypes.EOrientation.kVertical2:a="dg-v2-axis";break}this.get("classNames").push(a);this._hiddenDragView=SC.LabelView.create({classNames:"dg-drag-label".w(),layout:{width:100,height:20,top:-50,left:0},value:""});this.appendChild(this._hiddenDragView);if(this.constructor===DG.AxisView){DG.mainPage.docView.addObserver("selectedChildView",this,this.doDraw)}},destroy:function(){if(this.constructor===DG.AxisView){DG.mainPage.docView.removeObserver("selectedChildView",this,this.doDraw)}this.get("labelNodes").forEach(function(a){a.remove();a.destroy()});this._labelNodes=null;arguments.callee.base.apply(this,arguments)},renderLabel:function(){if(this.get("suppressLabel")){this.suppressLabelChanged();return}var f=this.get("labelNodes"),h=this.get("paperForLabel"),i=h?h.width:0,b=h?h.height:0,e=this.get("isVertical"),c=this.get("orientation"),a=0,g=f.map(function(k){var j=k.extent();if(!e&&j.height===0){j.height=b}a+=e?j.height:j.width;return{node:k,extent:j}}),d=e?((b+a)/2):((i-a)/2);f.forEach(function(l,k){var j=this.get("model").getLabelDescription(k)+"—"+"DG.AxisView.labelTooltip".loc(("DG.AxisView."+this.orientation).loc());l._textElement.attr("title",j)}.bind(this));g.forEach(function(k){var l=k.node,j={x:k.extent.width,y:k.extent.height},m={};switch(c){case DG.GraphTypes.EOrientation.kVertical:case DG.GraphTypes.EOrientation.kVertical2:case DG.GraphTypes.EOrientation.kRight:m.x=j.x/4+4;m.y=d-j.y/2;d-=j.y+4;if(c===DG.GraphTypes.EOrientation.kVertical2||c===DG.GraphTypes.EOrientation.kRight){m.x=i-j.x/2-2}break;case DG.GraphTypes.EOrientation.kHorizontal:case DG.GraphTypes.EOrientation.kTop:m.x=d+j.x/2;m.y=b-j.y/2-2;d+=j.x+4;if(c===DG.GraphTypes.EOrientation.kTop){m.y=j.y/3}break}l.set("loc",m)})},suppressLabelChanged:function(){var a=this._labelNodes,b=this.get("suppressLabel");if(a){a.forEach(function(c){if(b){c.hide()}else{c.show()}})}if(!b){this.renderLabel()}}.observes("suppressLabel"),renderAxisLine:function(){var c=this.get("axisLineCoordinate"),a=this.get("pixelMin"),e=this.get("pixelMax"),b,d;switch(this.get("orientation")){case DG.GraphTypes.EOrientation.kVertical:b={x:c-1,y:a};d={x:c-1,y:e};break;case DG.GraphTypes.EOrientation.kHorizontal:b={x:a,y:c+1};d={x:e,y:c+1};break;case DG.GraphTypes.EOrientation.kVertical2:case DG.GraphTypes.EOrientation.kRight:b={x:c+1,y:a};d={x:c+1,y:e};break;case DG.GraphTypes.EOrientation.kTop:b={x:a,y:c-1};d={x:e,y:c-1};break}return this.get("paper").line(b.x,b.y,d.x,d.y).attr({stroke:DG.PlotUtilities.kAxisColor,strokeWidth:2})},dragData:null,performDragOperation:function(a,b){this.hideDropHint();this.set("dragData",a.data);return SC.DRAG_LINK},dragEnded:function(){if((this.get("orientation")===DG.GraphTypes.EOrientation.kVertical2)&&(this.constructor===DG.AxisView)){this.set("isVisible",false)}DG.GraphDropTarget.dragEnded.apply(this,arguments)},numberOfCells:function(){return this.getPath("model.numberOfCells")}.property(),numberOfCellsChanged:function(){this.notifyPropertyChange("numberOfCells")}.observes("*model.numberOfCells"),fullWidth:function(){return Math.abs(this.get("pixelMax")-this.get("pixelMin"))}.property("pixelMax","pixelMin"),fullCellWidth:function(){return this.get("fullWidth")/this.get("numberOfCells")}.property("numberOfCells","pixelMax","pixelMin"),cellWidth:function(){var c=this.get("numberOfCells"),b=this.get("pixelMin"),f=this.get("pixelMax"),h=0.9,g=c+0.5,e=0,a=g-e,d=Math.abs((f-b)/a);return d*h}.property("numberOfCells","pixelMax","pixelMin"),cellToCoordinate:function(a){var c=this.get("numberOfCells"),e=Math.abs(this.get("pixelMax")-this.get("pixelMin")),b=(a+0.5)/c*e,d;switch(this.get("orientation")){case DG.GraphTypes.EOrientation.kHorizontal:case DG.GraphTypes.EOrientation.kTop:d=this.get("pixelMin")+b;break;case DG.GraphTypes.EOrientation.kVertical:case DG.GraphTypes.EOrientation.kVertical2:case DG.GraphTypes.EOrientation.kRight:d=this.get("pixelMin")-b;break}return d},cellNameToCoordinate:function(a){return this.cellToCoordinate(this.model.cellNameToCellNumber(a))},forEachTickDo:function(){},doDraw:function(){this.renderLabel()},dataToCoordinate:function(c){var a=this.get("pixelMin"),b=this.get("pixelMax");return a+c*(b-a)},coordinateToData:function(b){var a=this.get("pixelMin"),c=this.get("pixelMax");return(b-a)/(c-a)},isValidAttribute:function(a){switch(this.get("orientation")){case DG.GraphTypes.EOrientation.kVertical2:return this.isValidAttributeForScatterplot(a)||this.isValidAttributeForPlotSplit(a);case DG.GraphTypes.EOrientation.kTop:case DG.GraphTypes.EOrientation.kRight:return this.isValidAttributeForPlotSplit(a);default:return DG.GraphDropTarget.isValidAttribute.call(this,a)}},isValidAttributeForScatterplot:function(h){var i=h.data.attribute,b=this.getDataConfiguration(),d=b.attributeIsNominal(i),g=this.getPath("model.attributeDescription.attribute"),c=this.get("xAttributeDescription"),j=c&&c.get("attribute"),a=c&&c.get("isNumeric"),e=this.getPath("otherYAttributeDescription.attribute"),f=(j!==DG.Analysis.kNullAttribute&&a)&&(g!==i)&&!d&&e&&!b.attributeIsNominal(e);return f}}}()));DG.AxisViewHelper=SC.Object.extend((function(){return{kAxisGap:1,kTickLength:4,axisView:null,destroy:function(){arguments.callee.base.apply(this,arguments);this.axisView=null},paper:function(){return this.getPath("axisView.paper")}.property(),paperDidChange:function(){this.notifyPropertyChange("paper")}.observes("axisView.paper"),elementsToClear:function(){return this.axisView._elementsToClear}.property("axisView"),orientation:function(){return this.getPath("axisView.orientation")}.property(),orientationDidChange:function(){this.notifyPropertyChange("orientation")}.observes("axisView.orientation"),lowerBound:function(){return this.getPath("axisView.model.lowerBound")}.property(),lowerBoundDidChange:function(){this.notifyPropertyChange("lowerBound")}.observes("axisView.model.lowerBound"),upperBound:function(){return this.getPath("axisView.model.upperBound")}.property(),upperBoundDidChange:function(){this.notifyPropertyChange("upperBound")}.observes("axisView.model.upperBound"),axisLineCoordinate:function(){return this.getPath("axisView.axisLineCoordinate")}.property(),axisLineCoordinateDidChange:function(){this.notifyPropertyChange("axisLineCoordinate")}.observes("axisView.axisLineCoordinate"),tickGap:function(){return this.getPath("axisView.model.tickGap")}.property(),tickGapDidChange:function(){this.notifyPropertyChange("tickGap")}.observes("axisView.model.tickGap"),pixelMin:function(){return this.getPath("axisView.pixelMin")}.property(),pixelMinDidChange:function(){this.notifyPropertyChange("pixelMin")}.observes("axisView.pixelMin"),pixelMax:function(){return this.getPath("axisView.pixelMax")}.property(),pixelMaxDidChange:function(){this.notifyPropertyChange("pixelMax")}.observes("axisView.pixelMax"),isVertical:function(){return this.getPath("axisView.isVertical")}.property(),isVerticalDidChange:function(){this.notifyPropertyChange("isVertical")}.observes("axisView.isVertical"),fullCellWidth:function(){return this.getPath("axisView.fullCellWidth")}.property(),fullCellWidthDidChange:function(){this.notifyPropertyChange("fullCellWidth")}.observes("axisView.fullCellWidth"),maxNumberExtent:function(a,b){if(!SC.none(b)){this.setPath("axisView.maxNumberExtent",b)}return this.getPath("axisView.maxNumberExtent")}.property(),maxNumberExtentDidChange:function(){this.notifyPropertyChange("maxNumberExtent")}.observes("axisView.maxNumberExtent"),info:function(){var a={lowerBound:this.get("lowerBound"),upperBound:this.get("upperBound"),range:null,cellWidth:this.get("fullCellWidth"),pixelMax:this.get("pixelMax")};a.range=a.upperBound-a.lowerBound;return a}.property().cacheable(),infoDidChange:function(){this.notifyPropertyChange("info")}.observes("*axisView.model.lowerBound","*axisView.model.upperBound","axisView.fullCellWidth","axisView.pixelMax"),cellDataToCoordinate:function(a,b){return this.cellDataToCoordinateUsingCache(a,b,this.get("info"))},dataToCoordinate:function(a){return this.cellDataToCoordinate(0,a)},coordinateToData:function(a,b){return this.coordinateToDataGivenCell(0,a,b)},cellDataToCoordinateUsingCache:function(a,d,b){if(!isFinite(d)){return null}var c=SC.empty(d)?null:(d-b.lowerBound)*b.cellWidth/b.range;if(!SC.none(c)){switch(this.get("orientation")){case DG.GraphTypes.EOrientation.kVertical:case DG.GraphTypes.EOrientation.kVertical2:c=b.pixelMax+(a+1)*b.cellWidth-c;break;case DG.GraphTypes.EOrientation.kHorizontal:c=a*b.cellWidth+c;break}}return c},coordinateToDataGivenCell:function(a,k,j){var m=0,c=this.get("fullCellWidth"),f,n,b,g,i,e;if(c!==0){f=this.get("lowerBound");n=this.get("upperBound");if(this.get("isVertical")){b=this.get("pixelMax")+c*(a+1);g=b-c;k+=this.get("pixelMax")}else{b=this.get("pixelMin")+c*a;g=b+c;k+=this.get("pixelMin")}i=k-b;e=(g-b)/(n-f);m=f+i/e;if(j){var l=2,d=this.get("tickGap"),h=Math.round(m/d)*d;if(Math.abs(h-m)*e<l){m=h}}}return m}}}()));sc_require("components/graph/axes/axis_model");DG.BinnedAxisModel=DG.AxisModel.extend({isNumeric:true,binnedPlotModel:null,setLinkToPlotIfDesired:function(a){this.set("binnedPlotModel",a)},init:function(){arguments.callee.base.apply(this,arguments)},destroy:function(){this.binnedPlotModel=null;arguments.callee.base.apply(this,arguments)},lowerBound:function(){return this.getPath("binnedPlotModel.leastBinEdge")}.property(),upperBound:function(){return this.getPath("binnedPlotModel.maxBinEdge")}.property(),numberOfBins:function(){return this.getPath("binnedPlotModel.totalNumberOfBins")}.property(),valueToCellNumber:function(b){var a=this.get("binnedPlotModel");if(a){return a.valueToBinNumber(b)}else{return 0}},numberOfCells:function(){return this.get("numberOfBins")}.property(),binLabels:function(){var b=[],c="[%@, %@)",a="DG.BinnedPlotModel.binLabelTip";this.forEachBinDo(function(d,f,e){b.push({label:c.fmt(f,e),title:a.loc(f,e)})});return b}.property(),binLabelsDidChange:function(){this.notifyPropertyChange("binLabels")}.observes("binnedPlotModel.totalNumberOfBins","binnedPlotModel.alignment","binnedPlotModel.width"),forEachBinDo:function(a){this.get("binnedPlotModel").forEachBinDo(a)}});sc_require("components/graph/axes/axis_view");DG.BinnedAxisView=DG.AxisView.extend((function(){var b=4,c=2;return{desiredExtent:function(){var d=5;return arguments.callee.base.apply(this,arguments)+b+c+d+this.get("maxLabelExtent")}.property("maxLabelExtent"),pixelMinOffset:function(){return this.get("desiredExtent")}.property("desiredExtent"),isNumeric:true,centering:true,maxLabelExtent:0,allowCellBoundaries:false,numberOfBins:function(){return this.getPath("model.binnedPlotModel.totalNumberOfBins")}.property(),numberOfBinsDidChange:function(){this.notifyPropertyChange("numberOfBins");this.displayDidChange()}.observes("model.binnedPlotModel.totalNumberOfBins"),binWidth:function(){var d=this.get("numberOfBins");return Math.abs(this.get("pixelMax")-this.get("pixelMin"))/d}.property("numberOfBins"),labelSpecs:null,binToCoordinate:function(d){var e=(d+0.5)*this.get("binWidth");if(this.get("orientation")===DG.GraphTypes.EOrientation.kVertical){e=-e}return this.get("pixelMin")+e},dataToCoordinate:function(d){return this.binToCoordinate(Math.floor((d-this.getPath("model.binnedPlotModel.alignment"))/this.getPath("model.binnedPlotModel.width")))},binnedPlotModelWidthOrAlignmentDidChange:function(){this.displayDidChange()}.observes("model.binnedPlotModel.width","model.binnedPlotModel.alignment"),doDraw:function a(){var d=this.get("frame");if(!d||(d.height===0||d.width===0)){return}var g=this,x=[DG.GraphTypes.EOrientation.kHorizontal,DG.GraphTypes.EOrientation.kTop],t=this.get("model"),l=t.get("numberOfBins"),k=g.get("axisLineCoordinate"),r=this.get("orientation"),o=x.indexOf(r)>=0,z=o?0:-90,u=DG.RenderingUtilities.kDefaultFontHeight,j=this.get("centering"),h=j?0:this.get("binWidth")/2,i=j?"middle":"start",q=u,w=this.getPath("model.binLabels"),e=this.get("labelSpecs")||[],v=false,p=5,y;function n(E,D){var C=g.binToCoordinate(D);if(!isFinite(C)){return}var B;if(!e[D]){B=g.get("paper").text(0,0,E.label).addClass("dg-axis-tick-label").addClass("dg-binned-axis-label")}else{B=e[D].element;B.attr("text",E.label)}B.attr("title",E.title);var A=DG.RenderingUtilities.getExtentForTextElement(B,DG.RenderingUtilities.kDefaultFontHeight,true);B.binNum=D;e[D]={element:B,coord:C,height:A.height,width:A.width};u=Math.max(u,A.height);q=Math.max(q,A.width);if(SC.none(y)){v=A.width>g.get("binWidth");y=o?C+A.width/2:C-A.width/2}else{if(o){v=v||(C-A.width/2<y+p);y=(C+A.width/2)}else{v=v||(C+A.width/2>y-p);y=(C-A.width/2)}}}function m(D,B){var A=D.coord,E,C;switch(g.get("orientation")){case DG.GraphTypes.EOrientation.kVertical:g._elementsToClear.push(g.get("paper").line(k,A+h,k-b,A+h).attr({stroke:DG.PlotUtilities.kAxisColor}));E=k-b-c-D.height/3;C=A+h-((B===0&&!j)?D.height/2:0);if(z===0){i="end";if(D.width>E&&E>10){DG.RenderingUtilities.elideToFit(D.element,E)}}break;case DG.GraphTypes.EOrientation.kHorizontal:g._elementsToClear.push(g.get("paper").line(A-h,k,A-h,k+b).attr({stroke:DG.PlotUtilities.kAxisColor}));E=A-h+1;C=k+b+c+D.height/3;if(z===-90){i="end";if(B===0&&!j){E+=D.height/3}if(D.width>d.height-C&&d.height-C>10){DG.RenderingUtilities.elideToFit(D.element,d.height-C)}}break}D.element.attr({x:E,y:C,"text-anchor":i});DG.RenderingUtilities.rotateText(D.element,z,E,C)}this._elementsToClear.push(this.renderAxisLine());w.forEach(n);while(e.length>l){var f=e.pop();f.element.remove()}if(v){z=o?-90:0}e.forEach(m);this.set("labelSpecs",e);this.renderLabel();var s;switch(r){case DG.GraphTypes.EOrientation.kHorizontal:s=(z===0)?u:q;break;case DG.GraphTypes.EOrientation.kVertical:s=(z===0)?q:u;break}this.setIfChanged("maxLabelExtent",s)}}}()));sc_require("components/graph/axes/axis_model");DG.CellAxisModel=DG.AxisModel.extend({numberOfCells:function(){return Math.max(1,this.getPath("attributeDescription.attributeStats.numberOfCells"))}.property(),cellNames:function(){var b=[],a=this.getPath("attributeDescription.attribute");if(a){a.forEachCategory(function(c){b.push(c)})}return b}.property(),numberOfCellsDidChange:function(){this.notifyPropertyChange("numberOfCells")}.observes("*attributeDescription.attributeStats.numberOfCells"),numberOfCategoriesLimitDidChange:function(){this.notifyPropertyChange("numberOfCategoriesLimit")}.observes("*attributeDescription.attributeStats.number_of_categories_limit"),maxCellNameLength:function(){var a=0;this.forEachCellDo(function(c,b){a=Math.max(a,b.length)});return a}.property(),maxCellNameLengthDidChange:function(){this.notifyPropertyChange("maxCellNameLength")}.observes("*attributeDescription.attributeStats.cellMap"),isNumeric:false,cellNameToCellNumber:function(b){var a=this.getPath("attributeDescription.attributeStats");return a?a.cellNameToCellNumber(b):0},displayedCellIndexToUnderlyingIndex:function(d){var c=this.getPath("attributeDescription.attributeStats.cellMap"),b=this.getPath("attributeDescription.attribute"),a=0,e=d;if(DG.ObjectMap.length(c)>0){b.forEachCategory(function(f,g,h){var j=c[f],i=j?j.cases.length:0;if(i>0){if(a===d){e=h}a++}})}return e},underlyingIndexToDisplayedIndex:function(e){var c=this.getPath("attributeDescription.attributeStats.cellMap"),b=this.getPath("attributeDescription.attribute"),a=0,d=e;if(DG.ObjectMap.length(c)>0){b.forEachCategory(function(f,g,h){if(h===e){d=a}var j=c[f],i=j?j.cases.length:0;if(i>0){a++}})}return d},forEachCellDo:function(d){var c=this.getPath("attributeDescription.attributeStats.cellMap"),b=this.getPath("attributeDescription.attribute"),a=0;if(DG.ObjectMap.length(c)===0){d(0,"",0,0)}else{b.forEachCategory(function(e,f,h){var j=c[e],i=j?j.cases.length:0,g=0;if(i>0){d(a++,e,i,g)}});if(c[DG.PlotUtilities.kOther]){d(a++,"DG.CellAxis.other".loc(),c[DG.PlotUtilities.kOther].cases.length)}}}});sc_require("components/graph/axes/axis_view");DG.CellAxisView=DG.AxisView.extend((function(){var b=4,c=2;return{displayProperties:["centering"],desiredExtent:function(){var d=arguments.callee.base.apply(this,arguments),e=5;if(!this.get("isNumeric")){d+=b+c+e+this.get("maxLabelExtent")}return d}.property("maxLabelExtent"),pixelMinOffset:function(){return this.get("desiredExtent")}.property("desiredExtent"),isNumeric:false,centering:false,dragInfo:null,maxLabelExtent:0,whichCell:function(f){var g=this.getPath("model.numberOfCells"),e=0;if(g>1){var d=this.get("pixelMin"),h=this.get("pixelMax");if(this.get("isVertical")){f=Math.min(Math.max(h+1,f),d-1);e=Math.floor((d-f)*g/(d-h))}else{f=Math.max(Math.min(h-d-1,f),1);e=Math.floor(f*g/(h-d))}}return e},cellToCoordinate:function(d,e){var f=this.get("dragInfo");if(!e&&f&&f.draggingInProgress&&d===f.cellBeingDragged){return f.position}else{return arguments.callee.base.apply(this,arguments)}},doDraw:function a(){var f=this.get("frame");if(!f||(f.height===0||f.width===0)){return}var m=this,E=[DG.GraphTypes.EOrientation.kHorizontal,DG.GraphTypes.EOrientation.kTop],A=this.get("model"),H=A.get("numberOfCells"),s=m.get("axisLineCoordinate"),y=this.get("orientation"),v=E.indexOf(y)>=0,G=v?0:-90,p=v?"dg-axis-cell-label-x":"dg-axis-cell-label-y",C=DG.RenderingUtilities.kDefaultFontHeight,r=this.get("centering"),n=r?0:this.get("fullCellWidth")/2,o=r?"middle":"start",w=C,h=this.get("labelSpecs")||[],D=false,F,l,t,q,e;var k=function(J,I){e=m.getPath("model.cellNames");q=t=this.cellNum;l=DG.ViewUtilities.windowToViewCoordinates({x:J,y:I},m);l=v?l.x:l.y},B=function(P,O,J,I){var M=m.get("model"),N=l+(v?P:O),K=m.whichCell(N);if(isNaN(N)){return}SC.run(function(){if(K!==t){t=M.underlyingIndexToDisplayedIndex(g(M.get("attributeDescription"),M.displayedCellIndexToUnderlyingIndex(K),M.displayedCellIndexToUnderlyingIndex(t)))}m.set("dragInfo",{cellBeingDragged:t,position:N,draggingInProgress:true});m.displayDidChange();m.propertyDidChange("categoriesDragged")})},x=function(K){SC.run(function(){m.set("dragInfo",null);m.displayDidChange();m.propertyDidChange("categoriesDragged");m.updateLayerIfNeeded()});if(q!==t){var J=e[q],I=e[t];DG.UndoHistory.execute(DG.Command.create({name:"swapCategories",undoString:"DG.Undo.graph.swapCategories",redoString:"DG.Redo.graph.swapCategories",log:"Moved category %@ into position of %@".fmt(J,I),_initialCell:q,_finalCell:t,_axisModel:m.get("model"),executeNotification:{action:"notify",resource:"component",values:{operation:"swap categories",type:"DG.GraphView"}},execute:function(){},undo:function(){g(this._axisModel.get("attributeDescription"),this._initialCell,this._finalCell);var M=this._initialCell;this._initialCell=this._finalCell;this._finalCell=M},redo:function(){this.undo()}}))}},g=function(N,K,J){var I=Math.sign(K-J),M=J+I;while(M!==K+I){DG.PlotUtilities.swapCategoriesByIndex(N,J,M);M+=I;J+=I}return J};function i(){var J=Math.abs(m.get("pixelMax")-m.get("pixelMin")),I=Math.floor(J/DG.RenderingUtilities.kDefaultFontHeight);m.setPathIfChanged("model.attributeDescription.number_of_categories_limit",I)}function d(K,N){var M=m.cellToCoordinate(K);if(!isFinite(M)){return}var J;if(!h[K]){J=m.get("paper").text(0,0,N).addClass("dg-axis-tick-label").addClass(p).drag(B,k,x)}else{J=h[K].element;J.attr("text",N)}var I=DG.RenderingUtilities.getExtentForTextElement(J,DG.RenderingUtilities.kDefaultFontHeight,true);J.cellNum=K;h[K]={element:J,coord:M,height:I.height,width:I.width};C=Math.max(C,I.height);w=Math.max(w,I.width);if(SC.none(F)){D=I.width>m.get("fullCellWidth");F=v?M+I.width/2:M-I.width/2}else{if(v){D=D||(M-I.width/2<F);F=(M+I.width/2)}else{D=D||(M+I.width/2>F);F=(M-I.width/2)}}}function u(O,K){var I=O.coord,P,N;switch(m.get("orientation")){case DG.GraphTypes.EOrientation.kVertical:case DG.GraphTypes.EOrientation.kVertical2:m._elementsToClear.push(m.get("paper").line(s,I+n,s-b,I+n).attr({stroke:DG.PlotUtilities.kAxisColor}));P=s-b-c-O.height/3;N=I+n-((K===0&&!r)?O.height/2:0);if(G===0){o="end";if(O.width>P&&P>10){DG.RenderingUtilities.elideToFit(O.element,P)}}break;case DG.GraphTypes.EOrientation.kHorizontal:m._elementsToClear.push(m.get("paper").line(I-n,s,I-n,s+b).attr({stroke:DG.PlotUtilities.kAxisColor}));P=I-n+1;N=s+b+c+O.height/3;if(G===-90){o="end";if(K===0&&!r){P+=O.height/3}if(O.width>f.height-N&&f.height-N>10){DG.RenderingUtilities.elideToFit(O.element,f.height-N)}}break;case DG.GraphTypes.EOrientation.kTop:m._elementsToClear.push(m.get("paper").line(I-n,s,I-n,s-b).attr({stroke:DG.PlotUtilities.kAxisColor}));P=I-n+1;N=s-b-c-O.height/3;if(G===-90){var M=m.get("labelExtent").y;o="start";if(K===0){P+=O.height/3}if(O.width>N-M&&N-M>10){DG.RenderingUtilities.elideToFit(O.element,N-M)}}break;case DG.GraphTypes.EOrientation.kRight:m._elementsToClear.push(m.get("paper").line(s,I+n,s+b,I+n).attr({stroke:DG.PlotUtilities.kAxisColor}));P=s+b+c+O.height/3;N=I+n;if(G===0){var J=m.get("labelExtent").x;o="start";if(O.width>f.width-P-J){DG.RenderingUtilities.elideToFit(O.element,f.width-P-J)}}break}O.element.attr({x:P,y:N,"text-anchor":o});DG.RenderingUtilities.rotateText(O.element,G,P,N)}i();if(this.getPath("model.maxCellNameLength")<=3){G=0}this._elementsToClear.push(this.renderAxisLine());A.forEachCellDo(d);while(h.length>H){var j=h.pop();j.element.remove()}if(D){G=v?-90:0}h.forEach(u);this.set("labelSpecs",h);this.renderLabel();var z;switch(y){case DG.GraphTypes.EOrientation.kHorizontal:case DG.GraphTypes.EOrientation.kTop:z=(G===0)?C:w;break;case DG.GraphTypes.EOrientation.kVertical:case DG.GraphTypes.EOrientation.kVertical2:case DG.GraphTypes.EOrientation.kRight:z=(G===0)?w:C;break}this.setIfChanged("maxLabelExtent",z)}}}()));sc_require("components/graph/axes/cell_axis_model");DG.CellLinearAxisModel=DG.CellAxisModel.extend({tickGap:null,__lowerBound:null,lowerBound:function(a,b){if(!SC.none(a)&&!SC.none(b)){this.__lowerBound=b}return this.__lowerBound}.property(),__upperBound:null,upperBound:function(a,b){if(!SC.none(a)&&!SC.none(b)){this.__upperBound=b}return this.__upperBound}.property(),preferZeroLowerBound:false,drawZeroLine:false,lockZero:function(b,a){if(a!==undefined){this.beginPropertyChanges();this.set("_lockZero",a);if(a){this.set("lowerBound",0)}else{this.setDataMinAndMax(this._lowerBound,this._upperBound)}this.endPropertyChanges()}return this._lockZero}.property("_lockZero").cacheable(),displayOnlyIntegers:false,isNumeric:true,scaleCanAnimate:true,_lowerBound:null,_upperBound:null,init:function(){arguments.callee.base.apply(this,arguments);this.attributeDescriptionDidChange()},attributeDescriptionDidChange:function(){var a=this.get("attributeDescription");if(a&&Number(a.getPath("attribute.precision"))===0){this.set("displayOnlyIntegers",true)}}.observes("attributeDescription"),numberOfCells:function(){return 1}.property(),_lockZero:false,setLowerAndUpperBounds:function(b,c,a){a=a||false;if(a){if(SC.none(this.axisAnimator)){this.axisAnimator=DG.GraphAnimator.create()}this.axisAnimator.set("axisInfoArray",[{axis:this,newBounds:{lower:b,upper:c}}]).animate()}else{this.beginPropertyChanges();this._lowerBound=b;this._upperBound=c;this.setIfChanged("lowerBound",b);this.setIfChanged("upperBound",c);this.setIfChanged("tickGap",this._computeTickGap(b,c));this.endPropertyChanges()}},translate:function(a){if((a===0)||this._lockZero){return}this.beginPropertyChanges();this._lowerBound+=a;this._upperBound+=a;this._setBoundsFromInternalBounds();this.endPropertyChanges()},computeBoundsForDilation:function(c,a){var b=(!this._lockZero||(this._lowerBound!==0))?c+(this._lowerBound-c)*a:this._lowerBound,d=(!this._lockZero||(this._upperBound!==0))?c+(this._upperBound-c)*a:this._upperBound;return{lower:b,upper:d}},dilate:function(d,b,c){var a=this.computeBoundsForDilation(d,b);c=c||false;if(c){if(SC.none(this.axisAnimator)){this.axisAnimator=DG.GraphAnimator.create()}this.axisAnimator.set("axisInfoArray",[{axis:this,newBounds:a}]).animate()}else{this._lowerBound=a.lower;this._upperBound=a.upper;if(this._setBoundsFromInternalBounds()){this.beginPropertyChanges();this._resetTickGap(this.get("lowerBound"),this.get("upperBound"));this._handleAxisChange();this.endPropertyChanges()}}},setDataMinAndMax:function(b,e,d){if(!d&&(SC.none(b)||SC.none(e))){return}if(!d&&(b>=this.get("lowerBound"))&&(e<=this.get("upperBound"))){return}this._resetScale(b,e);var a=this._setBoundsFromInternalBounds(),c=this._resetTickGap(this.get("lowerBound"),this.get("upperBound"));if(a||c){this._handleAxisChange()}},_resetScale:function(a,c){var b=this._computeBoundsAndTickGap(a,c);this.set("tickGap",b.gap);this._lowerBound=b.lower;this._upperBound=b.upper},_computeBoundsAndTickGap:function(f,a){var g=2.5,h=this.getPath("attributeDescription.attributeType"),d=i(h),b;function i(j){switch(j){case DG.Analysis.EAttributeType.eDateTime:return{min:Date.now()/1000-10*24*60*60,max:Date.now()/1000,addend:5*24*60*60};case DG.Analysis.EAttributeType.eNumeric:default:return{min:0,max:10,addend:5}}}if(!DG.isFinite(a)||!DG.isFinite(f)||(a<f)){var c=this.getPath("attributeDescription.attribute.defaultMin"),e=this.getPath("attributeDescription.attribute.defaultMax");f=SC.none(c)?d.min:c;a=SC.none(e)?d.max:e}else{if((f===a)&&(f===0)){f=-10;a=10}else{if((f===a)&&(Math.floor(f)===f)){a+=d.addend;f-=d.addend}else{if(f===a){switch(h){case DG.Analysis.EAttributeType.eNumeric:a=f+0.1*Math.abs(f);f=f-0.1*Math.abs(f);break;case DG.Analysis.EAttributeType.eDateTime:a+=d.addend;f-=d.addend;break}}else{if(h===DG.Analysis.EAttributeType.eNumeric){if((f>0)&&(a>0)&&(f<=a/g)){f=0}else{if((f<0)&&(a<0)&&(a>=f/g)){a=0}}}}}}}b=this._computeTickGap(f,a);return{lower:this._findLow(f,b),upper:this._findHigh(a,b),gap:b}},_computeTickGap:function(a,d){var b=(a>=d)?Math.abs(a):d-a,c=this._goodTickValue(b/5);if(this.displayOnlyIntegers&&(c<1)){c=1}return c},_resetTickGap:function(a,d){var c=this.tickGap,b=this._computeTickGap(a,d);this.set("tickGap",b);return c!==b},_setBoundsFromInternalBounds:function(){var d=0.05,a=this.get("lowerBound"),c=this.get("upperBound"),b=(this._upperBound-this._lowerBound)*d;this.beginPropertyChanges();if((this.get("lockZero")||((this._lowerBound>0)&&(this._lowerBound-b<0)))){this.set("lowerBound",0)}else{this.set("lowerBound",this._lowerBound)}if((this._upperBound<0)&&(this._upperBound+b>0)){this.set("upperBound",0)}else{this.set("upperBound",this._upperBound)}this.endPropertyChanges();return(a!==this.get("lowerBound"))||(c!==this.get("upperBound"))},_handleAxisChange:function(){},_findLow:function(b,a){if((b>=0)&&this.get("preferZeroLowerBound")){return 0}if(a!==0){return(Math.floor(b/a)-0.5)*a}else{return b-1}},_findHigh:function(b,a){if(a!==0){return(Math.floor(b/a)+1.5)*a}else{return b+1}},_goodTickValue:function(a){return DG.MathUtilities.goodTickValue(a)}});sc_require("components/graph/axes/cell_axis_view");DG.CellLinearAxisView=DG.CellAxisView.extend((function(){var c=1,b=4;return{displayProperties:"model.lowerBound model.upperBound model.tickGap".w(),_axisViewHelper:null,axisViewHelper:function(){var d=(this.get("isDateTime"))?DG.DateTimeAxisViewHelper:DG.NumericAxisViewHelper;if(!this._axisViewHelper||d!==this._axisViewHelper.constructor){if(this._axisViewHelper){this._axisViewHelper.destroy()}this._axisViewHelper=d.create({axisView:this})}return this._axisViewHelper}.property("isDateTime"),attributeDidChange:function(){this._axisViewHelper=null}.observes("model.attributeDescription.attribute"),isNumeric:true,isDateTime:function(){return this.getPath("model.attributeDescription.attributeType")===DG.Analysis.EAttributeType.eDateTime}.property(),attributeTypeChanged:function(){this.notifyPropertyChange("isDateTime")}.observes("model.attributeDescription.attributeType"),zeroPixel:function(){if((0>=this.getPath("model.lowerBound"))&&(0<=this.getPath("model.upperBound"))){return this.dataToCoordinate(0)}else{return null}}.property().cacheable(),zeroPixelDidChange:function(){this.notifyPropertyChange("zeroPixel")}.observes("*model.lowerBound","*model.upperBound","pixelMin","pixelMax"),maxNumberExtent:0,coordToString:function(g){var f=this.coordinateToData(g),e=this.getPath("model.tickGap"),h=(e<1)?1+Math.ceil(Math.abs(Math.log(e)/Math.LN10)):0,d;if((h===0)&&(e<10)){h++}d=DG.Format.number().group("").fractionDigits(0,h);return d(f)},prepareVisualization:function(){this.displayDidChange()},doDraw:function a(){var f=this,d=this.get("orientation");function e(){var m=f.get("frame"),h=false,u=f.getPath("model.lockZero");function o(){f._dragPanel.show();f._isDragging=true;DG.logUser("dragStart: { lower: %@, upper: %@ }",f.getPath("model.lowerBound"),f.getPath("model.upperBound"))}function q(){f._dragPanel.hide();f._isDragging=false;var z=f.getPath("model.lowerBound"),y=f.getPath("model.upperBound"),v=f._lowerBoundAtDragStart,B=f._upperBoundAtDragStart,w=(z===v||y===B),A=f.get("parentView"),C,x;if(d===DG.GraphTypes.EOrientation.kHorizontal){C="xAxisView"}else{if(d===DG.GraphTypes.EOrientation.kVertical){C="yAxisView"}else{C="y2AxisView"}}DG.ObjectMap.forEach(DG.currDocumentController().componentControllersMap,function(E,D){if(D.get("graphView")===A){x=E}});DG.UndoHistory.execute(DG.Command.create({name:(w?"graph.axis.dilate":"graph.axis.drag"),undoString:(w?"DG.Undo.axisDilate":"DG.Undo.axisDrag"),redoString:(w?"DG.Redo.axisDilate":"DG.Redo.axisDrag"),log:"dragEnd: { lower: %@, upper: %@ }".fmt(z,y),_componentId:x,_controller:function(){return DG.currDocumentController().componentControllersMap[this._componentId]},_model:function(){return this._controller().getPath(C+".model")},executeNotification:{action:"notify",resource:"component",values:{operation:"change axis bounds",newBounds:{lower:z,upper:y},type:"DG.GraphView"}},execute:function(){},undo:function(){this._model().setLowerAndUpperBounds(v,B,true)},redo:function(){this._model().setLowerAndUpperBounds(z,y,true)}}))}function n(w,v){if(!h){o();f._lowerBoundAtDragStart=f.getPath("model.lowerBound");f._upperBoundAtDragStart=f.getPath("model.upperBound")}}function s(w,v){SC.run(function(){if(!h&&f._isDragging){var y=f.get("isVertical")?v:w,x=f.get("axisViewHelper"),A=f.getPath("model.lowerBound"),B=x.coordinateToDataGivenCell(0,0)-x.coordinateToDataGivenCell(0,y),z=B-(A-f._lowerBoundAtDragStart);f.get("model").translate(z)}})}function p(x,w){if(!h){var v=DG.ViewUtilities.windowToViewCoordinates({x:x,y:w},f);f._dilationAnchorCoord=f.get("isVertical")?v.y:v.x;f._lowerBoundAtDragStart=f.getPath("model.lowerBound");f._upperBoundAtDragStart=f.getPath("model.upperBound");o()}}function k(w,v){SC.run(function(){if(!h&&f._isDragging){var z=f.get("_lowerBoundAtDragStart"),A=f.getPath("model.upperBound"),x=f.get("isVertical")?v:w,B=f.get("pixelMax"),y=B-f._dilationAnchorCoord,C=y/(y-x);if((C>0)&&(C<10)){f.setPath("model._lowerBound",z);f.get("model").dilate(A,C)}}})}function r(x,w){if(!h){var v=DG.ViewUtilities.windowToViewCoordinates({x:x,y:w},f);f._dilationAnchorCoord=f.get("isVertical")?v.y:v.x;f._upperBoundAtDragStart=f.getPath("model.upperBound");f._lowerBoundAtDragStart=f.getPath("model.lowerBound");o()}}function j(w,v){SC.run(function(){if(!h&&f._isDragging){var A=f.get("_upperBoundAtDragStart"),z=f.getPath("model.lowerBound"),x=f.get("isVertical")?v:w,B=f.get("pixelMin"),y=B-f._dilationAnchorCoord,C=y/(y-x);if((C>0)&&(C<10)){f.setPath("model._upperBound",A);f.get("model").dilate(z,C)}}})}function i(w,v,z,x,y){w.attr({x:v,y:z,width:x,height:y})}function g(v){h=v.altKey}function l(y){var v;if(y.altKey){var w="../../../../static/dg/fr/cert/resources/cursors/MagnifyPlus.cur",z="../../../../static/dg/fr/cert/resources/cursors/MagnifyMinus.cur",x=y.shiftKey?z:w;v=y.shiftKey?"out":"in";this.attr({cursor:DG.Browser.customCursorStr(x,8,8),title:"Click to zoom "+v})}else{this.attr({cursor:this.defaultCursor,title:this.defaultTitle})}}function t(x){var y,w,v;if(x.altKey){y=x.shiftKey?2:0.5;w=DG.ViewUtilities.windowToViewCoordinates({x:x.clientX,y:x.clientY},f);v=f.get("isVertical")?w.y:w.x;f.get("model").dilate(f.coordinateToData(v),y,true);h=false}}if(SC.none(f._midPanel)){f._midPanel=f.get("paper").rect(0,0,0,0).attr({stroke:DG.RenderingUtilities.kTransparent,fill:DG.RenderingUtilities.kSeeThrough});f._lowerPanel=f._midPanel.clone();f._upperPanel=f._midPanel.clone();f._dragPanel=f._midPanel.clone();if(!u){f._midPanel.defaultTitle="DG.CellLinearAxisView.midPanelTooltip".loc();f._midPanel.attr({title:f._midPanel.defaultTitle});f._midPanel.mousedown(g);f._midPanel.mouseup(t);f._midPanel.drag(s,n,q);f._midPanel.mousemove(l);f._lowerPanel.defaultTitle="DG.CellLinearAxisView.lowerPanelTooltip".loc();f._lowerPanel.attr({title:f._lowerPanel.defaultTitle});f._lowerPanel.mousedown(g);f._lowerPanel.mouseup(t);f._lowerPanel.drag(k,p,q);f._lowerPanel.mousemove(l)}f._upperPanel.defaultTitle="DG.CellLinearAxisView.upperPanelTooltip".loc();f._upperPanel.attr({title:f._upperPanel.defaultTitle});f._upperPanel.mousedown(g);f._upperPanel.mouseup(t);f._upperPanel.drag(j,r,q);f._upperPanel.mousemove(l);f._dragPanel.attr({cursor:DG.Browser.customCursorStr("../../../../static/dg/fr/cert/resources/cursors/ClosedHandXY.cur",8,8)})}switch(f.get("orientation")){case DG.GraphTypes.EOrientation.kVertical:case DG.GraphTypes.EOrientation.kVertical2:if(!u){i(f._lowerPanel,0,(5/8)*m.height,m.width,(3/8)*m.height);f._lowerPanel.defaultCursor=DG.Browser.customCursorStr("../../../../static/dg/fr/cert/resources/cursors/DownDilate.cur",8,8);f._lowerPanel.attr({cursor:f._lowerPanel.defaultCursor});i(f._midPanel,0,(3/8)*m.height,m.width,(3/8)*m.height);f._midPanel.defaultCursor=DG.Browser.customCursorStr("../../../../static/dg/fr/cert/resources/cursors/TranslateY.cur",8,8);f._midPanel.attr({cursor:f._midPanel.defaultCursor})}i(f._upperPanel,0,0,m.width,(u?1:(3/8))*m.height);f._upperPanel.defaultCursor=DG.Browser.customCursorStr("../../../../static/dg/fr/cert/resources/cursors/UpDilate.cur",8,8);f._upperPanel.attr({cursor:f._upperPanel.defaultCursor});i(f._dragPanel,0,0,m.width,m.height);break;case DG.GraphTypes.EOrientation.kHorizontal:if(!u){i(f._lowerPanel,0,0,(3/8)*m.width,m.height);f._lowerPanel.defaultCursor=DG.Browser.customCursorStr("../../../../static/dg/fr/cert/resources/cursors/LeftDilate.cur",8,8);f._lowerPanel.attr({cursor:f._lowerPanel.defaultCursor});i(f._midPanel,(3/8)*m.width,0,(3/8)*m.width,m.height);f._midPanel.defaultCursor=DG.Browser.customCursorStr("../../../../static/dg/fr/cert/resources/cursors/TranslateX.cur",8,8);f._midPanel.attr({cursor:f._midPanel.defaultCursor})}i(f._upperPanel,(u?0:(5/8)*m.width),0,(u?1:(3/8))*m.width,m.height);f._upperPanel.defaultCursor=DG.Browser.customCursorStr("../../../../static/dg/fr/cert/resources/cursors/RightDilate.cur",8,8);f._upperPanel.attr({cursor:f._upperPanel.defaultCursor});i(f._dragPanel,0,0,m.width,m.height);break}if(!f._isDragging){f._dragPanel.hide()}}this._elementsToClear.push(this.renderAxisLine());this.get("axisViewHelper").drawTicks();e();this.renderLabel()},dataToCoordinate:function(d){return this.get("axisViewHelper").dataToCoordinate(d)},coordinateToData:function(d,e){return this.get("axisViewHelper").coordinateToData(d,e)},increment:function(){return this.coordinateToData(1)-this.coordinateToData(0)}.property("frame").cacheable(),incrementDidChange:function(){this.notifyPropertyChange("increment")}.observes("*model.lowerBound","*model.upperBound"),desiredExtent:function(){var d=arguments.callee.base.apply(this,arguments)+c+b+this.get("maxNumberExtent");return d}.property("maxNumberExtent"),forEachTickDo:function(d){this.get("axisViewHelper").forEachTickDo(d)},_isDragging:false,_lowerBoundAtDragStart:null,_upperBoundAtDragStart:null,_dilationAnchorCoord:null,_dragPanel:null,_lowerPanel:null,_midPanel:null,_upperPanel:null}}()));sc_require("components/graph/axes/cell_axis_model");DG.CountAxisModel=DG.CellLinearAxisModel.extend({displayOnlyIntegers:true,scaleType:DG.Analysis.EBreakdownType.eCount,_lockZero:true,init:function(){arguments.callee.base.apply(this,arguments);this.set("attributeDescription",DG.AttributePlacementDescription.create())},labels:function(){switch(this.get("scaleType")){case DG.Analysis.EBreakdownType.eCount:return["DG.CountAxisView.countLabel".loc()];case DG.Analysis.EBreakdownType.ePercent:return["DG.CountAxisView.percentLabel".loc()];default:return[]}}.property("scaleType"),getLabelDescription:function(){switch(this.get("scaleType")){case DG.Analysis.EBreakdownType.eCount:return"DG.CountAxisView.countLabelDescription".loc();case DG.Analysis.EBreakdownType.ePercent:return"DG.CountAxisView.percentLabelDescription".loc();default:return""}},cellNameToCellNumber:function(a){return 0}});sc_require("components/graph/axes/cell_linear_axis_view");DG.CountAxisView=DG.CellLinearAxisView.extend((function(){return{_axisViewHelper:null,axisViewHelper:function(){if(!this._axisViewHelper){var a=DG.NumericAxisViewHelper;this._axisViewHelper=a.create({axisView:this})}return this._axisViewHelper}.property()}}()));DG.DateUtilities={EDateTimeLevel:{eSecond:0,eMinute:1,eHour:2,eDay:3,eMonth:4,eYear:5},kSecond:1000,kMinute:(1000)*60,kHour:((1000)*60)*60,kDay:(((1000)*60)*60)*24,kMonth:((((1000)*60)*60)*24)*30,kYear:((((1000)*60)*60)*24)*365};DG.DateUtilities.determineLevels=function(e,a){var d=a-e,c=1,f,b;if(d<3*this.kMinute){f=this.EDateTimeLevel.eDay;b=this.EDateTimeLevel.eSecond}else{if(d<3*this.kHour){f=this.EDateTimeLevel.eDay;b=this.EDateTimeLevel.eMinute}else{if(d<3*this.kDay){f=this.EDateTimeLevel.eDay;b=this.EDateTimeLevel.eHour}else{if(d<3*this.kMonth){f=this.EDateTimeLevel.eMonth;b=this.EDateTimeLevel.eDay}else{if(d<3*this.kYear){f=this.EDateTimeLevel.eYear;b=this.EDateTimeLevel.eMonth}else{f=this.EDateTimeLevel.eYear;b=this.EDateTimeLevel.eYear;c=Math.max(1,DG.MathUtilities.goodTickValue(d/(this.kYear*5)))}}}}}return{increment:c,outerLevel:f,innerLevel:b}};DG.DateUtilities.mapLevelToPrecision=function(a){var b=DG.Attribute.DATE_PRECISION_NONE;switch(a){case this.EDateTimeLevel.eSecond:b=DG.Attribute.DATE_PRECISION_SECOND;break;case this.EDateTimeLevel.eMinute:b=DG.Attribute.DATE_PRECISION_MINUTE;break;case this.EDateTimeLevel.eHour:b=DG.Attribute.DATE_PRECISION_HOUR;break;case this.EDateTimeLevel.eDay:b=DG.Attribute.DATE_PRECISION_DAY;break;case this.EDateTimeLevel.eMonth:b=DG.Attribute.DATE_PRECISION_MONTH;break;case this.EDateTimeLevel.eYear:b=DG.Attribute.DATE_PRECISION_YEAR;break}return b};DG.DateUtilities.defaultToEpochSecs=function(a){return Math.abs(a)>=5000};DG.DateUtilities.createDate=function(){var b=[Date].concat(Array.prototype.slice.call(arguments)),a;if(b.length===2&&typeof b[1]==="string"&&isNaN(b[1])){return DG.DateUtilities.dateParser.parseDate(b[1],true)}if((b.length===2)){if(DG.DateUtilities.defaultToEpochSecs(b[1])){b[1]=Number(b[1])*1000}else{b[2]=0}}a=new (Function.bind.apply(Date,b))();if(isNaN(a)){a=null}if(a){a.valueOf=function(){return Date.prototype.valueOf.apply(this)/1000}}return a};DG.createDate=DG.DateUtilities.createDate;DG.DateUtilities.isDate=function(a){return a instanceof Date};DG.isDate=DG.DateUtilities.isDate;DG._isDateRegex=null;DG.DateUtilities.isDateString=function(b,a){return DG.DateUtilities.dateParser.isDateString(b,a)};DG.isDateString=DG.DateUtilities.isDateString;DG.DateUtilities.formatDate=function(b,d,e){var f={year:{year:"numeric"},month:{year:"numeric",month:"numeric"},day:{year:"numeric",month:"numeric",day:"numeric"},hour:{year:"numeric",month:"numeric",day:"numeric",hour:"numeric"},minute:{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric"},second:{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"},millisecond:{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",fractionalSecondDigits:3}};var c=f[d]||f.minute;if(!(b&&(DG.isDate(b)||DG.isDateString(b)||DG.MathUtilities.isNumeric(b)))){return}if(DG.MathUtilities.isNumeric(b)){b=new Date(b*1000)}else{if(DG.isDateString(b)){b=new Date(b)}}var a=DG.get("currentLanguage");return new Intl.DateTimeFormat(a,c).format(b)};DG.formatDate=DG.DateUtilities.formatDate;DG.DateUtilities.monthName=function(a){if(!(a&&(DG.isDate(a)||DG.isDateString(a)||DG.MathUtilities.isNumeric(a)))){return""}var d;if(DG.isDate(a)){d=a}else{d=DG.createDate(a)}var c=["DG.Formula.DateLongMonthJanuary","DG.Formula.DateLongMonthFebruary","DG.Formula.DateLongMonthMarch","DG.Formula.DateLongMonthApril","DG.Formula.DateLongMonthMay","DG.Formula.DateLongMonthJune","DG.Formula.DateLongMonthJuly","DG.Formula.DateLongMonthAugust","DG.Formula.DateLongMonthSeptember","DG.Formula.DateLongMonthOctober","DG.Formula.DateLongMonthNovember","DG.Formula.DateLongMonthDecember"],b=c[d.getMonth()];return b&&b.loc()};DG.monthName=DG.DateUtilities.monthName;DG.DateUtilities.dateParser=(function(){var s="(\\d\\d?)(?::(\\d\\d?)(?::(\\d\\d)(?:\\.(\\d+))?)?)?";var f=["DG.Formula.DateLongMonthJanuary","DG.Formula.DateLongMonthFebruary","DG.Formula.DateLongMonthMarch","DG.Formula.DateLongMonthApril","DG.Formula.DateLongMonthMay","DG.Formula.DateLongMonthJune","DG.Formula.DateLongMonthJuly","DG.Formula.DateLongMonthAugust","DG.Formula.DateLongMonthSeptember","DG.Formula.DateLongMonthOctober","DG.Formula.DateLongMonthNovember","DG.Formula.DateLongMonthDecember"].map(function(J){return J.loc().toLowerCase()});var k=["DG.Formula.DateShortMonthJanuary","DG.Formula.DateShortMonthFebruary","DG.Formula.DateShortMonthMarch","DG.Formula.DateShortMonthApril","DG.Formula.DateShortMonthMay","DG.Formula.DateShortMonthJune","DG.Formula.DateShortMonthJuly","DG.Formula.DateShortMonthAugust","DG.Formula.DateShortMonthSeptember","DG.Formula.DateShortMonthOctober","DG.Formula.DateShortMonthNovember","DG.Formula.DateShortMonthDecember"].map(function(J){return J.loc().toLowerCase()});var n=["DG.Formula.DateLongDaySunday","DG.Formula.DateLongDayMonday","DG.Formula.DateLongDayTuesday","DG.Formula.DateLongDayWednesday","DG.Formula.DateLongDayThursday","DG.Formula.DateLongDayFriday","DG.Formula.DateLongDaySaturday"].map(function(J){return J.loc().toLowerCase()});var r=["DG.Formula.DateShortDaySunday","DG.Formula.DateShortDayMonday","DG.Formula.DateShortDayTuesday","DG.Formula.DateShortDayWednesday","DG.Formula.DateShortDayThursday","DG.Formula.DateShortDayFriday","DG.Formula.DateShortDaySaturday"].map(function(J){return J.loc().toLowerCase()});var x=k.map(function(J){return J+"\\."});var u=k.map(function(J){return J+"."});var d=k.concat(u,f);var h=k.concat(x,f);var v=n.concat(r);var a=/^(\d{4})-([01]\d)(?:-([0-3]\d)(?:[T ]([0-2]\d)(?::([0-5]\d)(?::([0-5]\d)(?:[.,](\d+))?)?)?(Z|(?:[+-]\d\d:?\d\d?)| ?[a-zA-Z]{1,4}T)?)?)?$/;var G={year:1,month:2,day:3,hour:4,min:5,sec:6,subsec:7,timezone:8};var C=/^([01]?\d)\/([0-3]?\d)\/(\d{4}|\d{2})(?:,? (\d\d?)(?::(\d\d?)(?::(\d\d)(?:\.(\d+))?)?)?(?: ?(am|pm|AM|PM))?)?$/;var l={year:3,month:1,day:2,hour:4,min:5,sec:6,subsec:7,ampm:8,timezone:9};var I=new RegExp("^(\\d\\d?) ("+h.join("|")+"),? (\\d{4})(?: "+s+"(?: (am|pm))?)?$","i");var H={year:3,month:2,day:1,hour:4,min:5,sec:6,subsec:7,ampm:8};var D=new RegExp("^(\\d{4})[./-](\\d\\d?)[./-](\\d\\d?)(?: "+s+"(?: (am|pm|AM|PM))?)?$");var o={year:1,month:2,day:3,hour:4,min:5,sec:6,subsec:7,ampm:8};var B=new RegExp("^(?:(?:"+v.join("|")+"),? )?("+h.join("|")+")(?: (\\d\\d?),)? (\\d{4})(?: "+s+"(?: (am|pm))?)?$","i");var j={year:3,month:1,day:2,hour:4,min:5,sec:6,subsec:7,ampm:8};var A=/(\d\d?):(\d\d)(?::(\d\d))? (AM|PM) on (\d\d?)\/(\d\d?)\/(\d{4})/;var y={year:5,month:6,day:7,hour:1,min:2,sec:3,ampm:4};var w=new RegExp("^(?:(?:"+r.join("|")+") )?("+k.join("|")+") ([ \\d]\\d) ([ \\d]\\d):(\\d\\d):(\\d\\d) ([A-Z]{3}) (\\d{4})$","i");var e={year:7,month:1,day:2,hour:3,min:4,sec:5,timezone:6};var t=new RegExp("^(?:"+r.join("|")+") ("+k.join("|")+") (\\d\\d?),? (\\d{4})(?: "+s+" (GMT(?:[+-]\\d{4})?(?: \\([\\w ]+\\))?))","i");var F={year:3,month:1,day:2,hour:4,min:5,sec:6,subsec:7,timezone:8};var z=new RegExp("^(?:"+r.join("|")+"),? (\\d\\d?) ("+k.join("|")+") (\\d{4}) "+s+" GMT$","i");var b={year:3,month:2,day:1,hour:4,min:5,sec:6,subsec:7,timezone:8};var c=/^\d{4}$/;var q={year:0};var g=[{strict:true,regex:C,groupMap:l},{strict:true,regex:a,groupMap:G},{strict:true,regex:w,groupMap:e},{strict:true,regex:t,groupMap:F},{strict:true,regex:z,groupMap:b},{strict:false,regex:D,groupMap:o},{strict:true,regex:I,groupMap:H},{strict:true,regex:B,groupMap:j},{strict:false,regex:c,groupMap:q},{strict:false,regex:A,groupMap:y}];function p(M,O){function K(Q,P){if(isNaN(Q)){return null}var R=Number(Q);if(P!=null&&(0<R<=12)){R=R%12;if(P&&P.toLowerCase()==="pm"){R+=12}}return R}function J(P){if(!isNaN(P)){return Number(P)}var Q=P.toLowerCase();var R=d.findIndex(function(S){return S===Q});return(R%12)+1}function N(P){if(P.length===2){P=Number(P);if(P<49){return 2000+P}else{return 1900+P}}else{return P}}return{year:Number(N(M[O.year])),month:J(M[O.month]||1),day:Number(M[O.day]||1),hour:K(M[O.hour]||0,M[O.ampm]),min:Number(M[O.min]||0),sec:Number(M[O.sec]||0),subsec:Number(M[O.subsec]||0)}}function m(J){var K=!isNaN(J.year)&&(!isNaN(J.month)&&(1<=J.month<=12))&&(!isNaN(J.day)&&(1<=J.day<=31))&&(!isNaN(J.hour)&&(0<=J.hour<=23))&&(!isNaN(J.min)&&(0<=J.min<=59))&&(!isNaN(J.sec)&&(0<=J.sec<=59))&&!isNaN(J.subsec);if(K){return J}}function E(Q,K){if(Q==null){return Q}if(Q instanceof Date){return Q}Q=String(Q);var O;var J;var P;var N;var M=g.some(function(T){var R;var S=false;if(T.strict||K){R=Q.match(T.regex);if(R){O=R;P=T.groupMap;S=true}}return S});if(M&&O){J=m(p(O,P));if(J){N=new Date(J.year,(-1+J.month),J.day,J.hour,J.min,J.sec,J.subsec);if(N){N.valueOf=function(){return Date.prototype.valueOf.apply(this)/1000}}return N}}}function i(K,J){return(typeof K==="string")&&!!g.find(function(M){if(!(M.strict||J)){return false}return M.regex.test(K)})}return{parseDate:E,isDateString:i}}());DG.parseDate=DG.DateUtilities.dateParser.parseDate;sc_require("utilities/date_utilities");sc_require("components/graph/axes/axis_view_helper");DG.DateTimeAxisViewHelper=DG.AxisViewHelper.extend((function(){var c=DG.DateUtilities.EDateTimeLevel,f=DG.DateUtilities.kMinute,e=DG.DateUtilities.kHour,i=DG.DateUtilities.kDay,h=DG.DateUtilities.kYear,b=["DG.Formula.DateShortMonthJanuary","DG.Formula.DateShortMonthFebruary","DG.Formula.DateShortMonthMarch","DG.Formula.DateShortMonthApril","DG.Formula.DateShortMonthMay","DG.Formula.DateShortMonthJune","DG.Formula.DateShortMonthJuly","DG.Formula.DateShortMonthAugust","DG.Formula.DateShortMonthSeptember","DG.Formula.DateShortMonthOctober","DG.Formula.DateShortMonthNovember","DG.Formula.DateShortMonthDecember"];function g(k,n){var l="",q=NaN;if(!DG.isDate(n)){n=new Date(n)}if(DG.isDate(n)){var t=n.getFullYear(),s=n.getMonth();if(k===c.eYear){l=String(t);q=new Date(t,1,1)}else{if(k===c.eMonth){q=new Date(t,s,1);l=b[s].loc()+", "+t}else{var p=n.getDate(),r=0,o=0,m=0;if(k<c.eDay){r=n.getHours();if(k<c.eHour){o=n.getMinutes();if(k<c.eMinute){m=n.getSeconds()}}}q=new Date(t,s,p,r,o,m);l=q.toLocaleDateString()}}}return{labelString:l,labelDate:q}}function j(k,o){var n;if(!DG.isDate(o)){o=new Date(o)}if(DG.isDate(o)){var s=o.getFullYear(),r=o.getMonth(),m=o.getDate(),q=o.getHours(),p=o.getMinutes(),l=o.getSeconds();switch(k){case c.eYear:s++;break;case c.eMonth:r++;if(r>12){s++;r=1}break;case c.eDay:m++;break;case c.eHour:q++;if(q>24){m++;q=0}break;case c.eMinute:p++;if(p>60){q++;p=0}break;case c.eSecond:l++;if(l>60){p++;l=0}break;default:}if(k<=c.eHour){n=new Date(s,r,m,q,p,l)}else{n=new Date(s,r,m)}}return g(k,n)}function d(k,q,o){var p=NaN,l="";if(!DG.isDate(q)){q=new Date(q)}if(DG.isDate(q)){var u=q.getFullYear(),t=q.getMonth(),n=q.getDate(),s=q.getHours(),r=q.getMinutes(),m=q.getSeconds();switch(k){case c.eYear:u=Math.ceil(u/o)*o;p=new Date(u,0,1);if(p.valueOf()<q.valueOf()){p=new Date(++u,0,1)}l=String(u);break;case c.eMonth:p=new Date(u,t,1);if(p.valueOf()<q.valueOf()){t++;if(t>12){u++;t=1}p=new Date(u,t,1)}l=b[p.getMonth()].loc();break;case c.eDay:p=new Date(u,t,n);if(p.valueOf()<q.valueOf()){n++;p=new Date(u,t,n)}n=p.getDate();l=String(n);break;case c.eHour:p=new Date(u,t,n,s);if(p.valueOf()<q.valueOf()){s++;p=new Date(u,t,n,s)}s=p.getHours();l=s+":00";break;case c.eMinute:p=new Date(u,t,n,s,r);if(p.valueOf()<q.valueOf()){p=new Date(u,t,n,s,++r)}r=p.getMinutes();l=String(r);break;case c.eSecond:p=new Date(u,t,n,s,r,m);if(p.valueOf()<q.valueOf()){p=new Date(u,t,n,s,r,m)}m=p.getSeconds();l=String(m);break;default:}}return{labelString:l,labelDate:p}}function a(k,r,m){var q=NaN,l="";if(!DG.isDate(r)){r=new Date(r)}if(DG.isDate(r)){var w=r.getFullYear(),v=r.getMonth(),p=r.getDate(),u=r.getHours(),t=r.getMinutes(),o=r.getSeconds(),s,n;switch(k){case c.eYear:w+=m;q=new Date(w,0,1);l=String(w);break;case c.eMonth:v+=m;while(v>12){w++;v-=12}q=new Date(w,v,1);l=b[q.getMonth()].loc();break;case c.eDay:p+=m;q=new Date(w,v,p);p=q.getDate();l=String(p);break;case c.eHour:u+=m;while(u>24){p++;u-=24}q=new Date(w,v,p,u);u=q.getHours();l=u+":00";break;case c.eMinute:t+=m;q=new Date(w,v,p,u,t);t=q.getMinutes();s=t<10?"0"+t:String(t);l=u+":"+s;break;case c.eSecond:o+=m;q=new Date(w,v,p,u,t,o);o=q.getSeconds();s=t<10?"0"+t:String(t);n=o<10?"0"+o:String(o);l=u+":"+s+":"+n;break;default:}}return{labelString:l,labelDate:q}}return{drawTicks:function(){var n=1000*this.get("lowerBound"),o=1000*this.get("upperBound");if(SC.none(n)||SC.none(o)||(o===n)){return}var m=DG.DateUtilities.determineLevels(n,o),l=(m.outerLevel!==m.innerLevel)?2:1,k=l*DG.RenderingUtilities.kDefaultFontHeight;if(k!==this.get("maxNumberExtent")){this.set("maxNumberExtent",k)}else{if(l===2){this.drawOuterLabels(m.outerLevel)}this.drawInnerLabels(m.innerLevel,m.increment)}},drawOuterLabels:function(m){var D=this.get("paper"),w=this.get("elementsToClear"),E=0,l={x:0,y:0},z=this.get("orientation"),o=this.get("lowerBound"),v=o*1000,A=this.get("upperBound"),x=A*1000,u=this.get("pixelMin"),y=this.get("pixelMax"),p,s,t,n,r=false;var q=function(H,G,K,F,J){var I;switch(z){case DG.GraphTypes.EOrientation.kHorizontal:H+=u;G.x=H;break;case DG.GraphTypes.EOrientation.kVertical:H+=y;G.y=H;break}I=D.text(G.x,G.y,K).attr({"text-anchor":J});DG.RenderingUtilities.rotateText(I,F,G.x,G.y);w.push(I)}.bind(this);if(z===DG.GraphTypes.EOrientation.kHorizontal){l.y=1.5*DG.RenderingUtilities.kDefaultFontHeight+this.kTickLength+this.kAxisGap}else{l.x=this.getPath("axisView.layout").width-this.kAxisGap-this.kTickLength-1.5*DG.RenderingUtilities.kDefaultFontHeight;E=-90}p=g(m,v);t=p.labelString;while(true){s=j(m,p.labelDate);if(isNaN(s.labelDate)){break}if(p.labelDate>x){if(!r){n=this.dataToCoordinate((o+A)/2);q(n,l,t,E,"middle")}break}else{if(r||(s.labelDate<x)){n=this.dataToCoordinate(Math.max(p.labelDate/1000,o));var B=true;if(p.labelDate<v){var k=DG.RenderingUtilities.textExtentOnCanvas(D,s.labelString),C=this.dataToCoordinate(s.labelDate/1000);if(k.x>7*Math.abs(C-n)/8){B=false}}if(B){q(n,l,p.labelString,E,"start")}r=true}}p=s}},drawInnerLabels:function(l,k){var q=function(J,B){var K=1,E=false;while(!E){var D=B.labelDate,y=B.labelString,H=B,F,G=true,I=false;while(!I&&(D<u)){var C=this.dataToCoordinate(D/1000),A=DG.RenderingUtilities.textExtentOnCanvas(s,y),z=5*A.x/8,x=(p===DG.GraphTypes.EOrientation.kHorizontal)?C-z<F:C+z>F;if(G||!x){G=false;F=C+((p===DG.GraphTypes.EOrientation.kHorizontal)?z:-z);H=a(J,D,K*k);D=H.labelDate;y=H.labelString}else{I=true}}if(I){K++}else{E=true}}return K}.bind(this),n=function(D,C){var z=0,B={x:0,y:0},y=0,A=this.dataToCoordinate(D.labelDate/1000);if(p===DG.GraphTypes.EOrientation.kHorizontal){B.y=this.kTickLength+this.kAxisGap+DG.RenderingUtilities.kDefaultFontHeight/2;y=0;A+=m;B.x=A;t.push(s.line(A,0,A,this.kTickLength))}else{z=-90;y=this.getPath("axisView.layout").width;B.x=y-this.kTickLength-this.kAxisGap-DG.RenderingUtilities.kDefaultFontHeight/2;A+=r;B.y=A;t.push(s.line(y,A,y-this.kTickLength,A))}if(C){var x=s.text(B.x,B.y,D.labelString);DG.RenderingUtilities.rotateText(x,z,B.x,B.y);t.push(x)}}.bind(this);var u=this.get("upperBound")*1000,p=this.get("orientation"),r=this.get("pixelMax"),m=this.get("pixelMin"),t=this.get("elementsToClear"),s=this.get("paper"),o=d(l,this.get("lowerBound")*1000,k),w=q(l,o),v=0;o=a(l,o.labelDate,0);while(o.labelDate<u){n(o,v===0);v=(v+1)%w;o=a(l,o.labelDate,k)}},forEachTickDo:function(l){var m=1000*this.get("lowerBound"),n=1000*this.get("upperBound"),k=DG.DateUtilities.determineLevels(m,n),o=d(k.innerLevel,m,k.increment),p;while(o.labelDate<n){p=o.labelDate.valueOf();l(p,this.dataToCoordinate(p/1000));o=a(k.innerLevel,o.labelDate,k.increment)}},getValueDisplayResolution:function(){var k=(this.coordinateToData(1)-this.coordinateToData(0))*1000,l;if(k<f){l="second"}else{if(k<e){l="minute"}else{if(k<i){l="hour"}else{if(k<i*30){l="day"}else{if(k<h){l="month"}else{l="year"}}}}}return l}}}()));sc_require("components/graph/axes/cell_axis_model");DG.FormulaAxisModel=DG.CellLinearAxisModel.extend({expressionSource:null,init:function(){arguments.callee.base.apply(this,arguments);this.set("attributeDescription",DG.AttributePlacementDescription.create())},destroy:function(){this.expressionSource=null;arguments.callee.base.apply(this,arguments)},labels:function(){var a=this.expressionSource?this.expressionSource.get("expression"):"";if(SC.empty(a)){a="DG.BarChartFunction.emptyExpressionAxisPrompt".loc()}return[a]}.property("scaleType"),getLabelDescription:function(){return"DG.FormulaAxisView.labelDescription".loc()},cellNameToCellNumber:function(a){return 0}});sc_require("components/graph/axes/cell_linear_axis_view");DG.FormulaAxisView=DG.CellLinearAxisView.extend((function(){return{displayProperties:"model.expressionSource.formula".w(),getMenuItems:function(){var a=[{title:"Edit formula",action:null}];return a},menuChangeHandler:function(){var a=this.getPath("model.expressionSource");a.editFormula()}}}()));sc_require("components/graph/axes/axis_view_helper");DG.NumericAxisViewHelper=DG.AxisViewHelper.extend((function(){return{drawTicks:function(){function t(z){return DG.MathUtilities.notAYear(z)?Intl.NumberFormat(i,{maximumFractionDigits:l}).format(z):u(z)}var y=this.get("paper"),m=this.get("elementsToClear"),h=this.get("lowerBound"),e=this.get("upperBound"),g=this.get("axisLineCoordinate"),p=this.get("orientation"),v=this.get("tickGap"),r=Math.ceil(h/v)*v,k=Math.floor(Math.abs((e-r)/v)),a,o=DG.RenderingUtilities.kDefaultFontHeight,l=(v<1)?Math.ceil(Math.abs(Math.log(v)/Math.LN10)):0,u=DG.Format.number().group("").fractionDigits(0,l),i=DG.get("currentLanguage");var s=function(C,G){var M=false,H=1,I=false,E,D;while(!I){var B=0,z=true,N=H*v,A;k=Math.floor(Math.abs((e-C)/N));I=true;for(A=0;(A<=k)&&I;A++){var K=C+A*N,J=this.dataToCoordinate(K+G),F;a=t(K);F=DG.RenderingUtilities.textExtentOnCanvas(y,a);switch(p){case DG.GraphTypes.EOrientation.kVertical:case DG.GraphTypes.EOrientation.kVertical2:D=F.y/2;if(z||(Math.abs(B-J)>D)){z=false;B=J+(M?D:-D)}else{I=false;H++}break;case DG.GraphTypes.EOrientation.kHorizontal:E=5.5*F.x/8;if(z||(Math.abs(J-B)>E)){z=false;B=J+(M?-E:E)}else{I=false;H++}break}}}return H}.bind(this);var q=0,c=s(r,q),b=0,x=b,n=this.get("pixelMax"),j=0,d=(p===DG.GraphTypes.EOrientation.kVertical2)?-this.kTickLength:this.kTickLength,w=(p===DG.GraphTypes.EOrientation.kVertical2)?-this.kAxisGap:this.kAxisGap,f=(p===DG.GraphTypes.EOrientation.kVertical2)?"start":"end";this.forEachTickDo(function(B,E){var A,z,D,C;a=t(B);A=y.text(0,0,a).addClass("dg-axis-tick-label");m.push(A);z=DG.RenderingUtilities.getExtentForTextElement(A,DG.RenderingUtilities.kDefaultFontHeight);D=z.width;C=z.height;switch(p){case DG.GraphTypes.EOrientation.kVertical:case DG.GraphTypes.EOrientation.kVertical2:E+=n;if((E<this.get("pixelMin"))&&(j>=0)){m.push(y.line(g,E,g-d,E).attr({stroke:DG.PlotUtilities.kAxisColor}))}if(x===0){if((E<this.get("pixelMin"))&&(j>=0)){A.attr({x:g-d-w,y:E,"text-anchor":f});o=Math.max(o,D)}}else{A.hide()}break;case DG.GraphTypes.EOrientation.kHorizontal:E+=this.get("pixelMin");if((E>=this.get("pixelMin"))&&(j>=0)){m.push(y.line(E,g,E,g+d).attr({stroke:DG.PlotUtilities.kAxisColor}))}if(x===0){if((E>=this.get("pixelMin"))&&(j>=0)){A.attr({x:E+1,y:g+d+w+C/3});o=Math.max(o,C)}}else{A.hide()}break}if(j>=0){x=(x+1)%c}j++}.bind(this));this.setIfChanged("maxNumberExtent",o)},forEachTickDo:function(b){var e,d=this.get("lowerBound"),g=this.get("upperBound"),f=this.get("tickGap"),a=Math.ceil(d/f)*f,h=Math.abs((g-a)/f),c;for(e=0;e<=h;e++){c=a+e*f;b(c,this.dataToCoordinate(c))}}}}()));sc_require("components/graph/axes/cell_linear_axis_view");DG.QualCellLinearAxisView=DG.CellLinearAxisView.extend((function(){var a=0,f=100,d=f-a,g=0.1,c=a-d*g,b=f+d*g;return{doDraw:function e(){var m=4,k=this.get("axisLineCoordinate"),h=this.get("orientation"),j=DG.RenderingUtilities.kDefaultFontHeight;var i=function(){var n=this.getPath("model.lowerBound"),o=this.getPath("model.upperBound");if(!SC.none(n)&&n>c){this.setPath("model.lowerBound",c)}if(!SC.none(o)&&o<b){this.setPath("model.upperBound",b)}}.bind(this),l=function(){[{value:a,string:""},{value:f,string:""}].forEach(function(q){var p=this.get("paper").text(0,0,q.string).addClass("dg-axis-tick-label");this._elementsToClear.push(p);var o=DG.RenderingUtilities.getExtentForTextElement(p,DG.RenderingUtilities.kDefaultFontHeight),n=this.dataToCoordinate(q.value),r=o.height;switch(h){case DG.GraphTypes.EOrientation.kHorizontal:p.attr({x:n+1,y:k+m+r/3});j=Math.max(j,r);break;case DG.GraphTypes.EOrientation.kVertical:p.attr({x:k-m,y:n,"text-anchor":"end"});j=Math.max(j,o.width);break}}.bind(this))}.bind(this);i();this._elementsToClear.push(this.renderAxisLine());l();this.renderLabel();this.setIfChanged("maxNumberExtent",j)},forEachTickDo:function(){}}}()));DG.AttributePlacementDescription=SC.Object.extend({attribute:function(a,b){if(!SC.none(b)){this._attributes=[b];this.setupStats()}return(this._attributes.length>0)?this._attributes[0]:DG.Analysis.kNullAttribute}.property(),attributes:function(){return this._attributes}.property(),attributeAt:function(a){if((a>=0)&&(a<this._attributes.length)){return this._attributes[a]}else{return DG.Analysis.kNullAttribute}},attributeNamed:function(a){return this.get("attributes").find(function(b){return(b.get("name")===a)})},attributeIDAt:function(b){var a=this.attributeAt(b);return(a!==DG.Analysis.kNullAttribute)?a.get("id"):null},addAttribute:function(a){if(a){if(!this._attributes.contains(a)){this._attributes.push(a)}this.setupStats();this.invalidateCaches();this.notifyPropertyChange("attribute");a.addObserver("collection",this,"collectionDidChange")}},removeAttributeAtIndex:function(b){DG.assert(b<this._attributes.length);var a=this._attributes[b];this._attributes.splice(b,1);this.invalidateCaches();this.notifyPropertyChange("attribute");a.removeObserver("collection",this,"collectionDidChange")},removeAttribute:function(a){this._attributes.removeObject(a);this.invalidateCaches();this.notifyPropertyChange("attribute");a.removeObserver("collection",this,"collectionDidChange")},removeAllAttributes:function(){this._attributes.forEach(function(a){a.removeObserver("collection",this,"collectionDidChange")}.bind(this));this._attributes=[];this.setPath("attributeStats.attributes",[]);this.invalidateCaches();this.notifyPropertyChange("attribute")},removeAllAttributesButFirst:function(){while(this._attributes.length>1){this._attributes.pop().removeObserver("collection",this,"collectionDidChange")}this.invalidateCaches();this.notifyPropertyChange("attribute")},collectionDidChange:function(){this.notifyPropertyChange("collection")},attributeStats:null,number_of_categories_limit:function(a,b){if(b){this.setPath("attributeStats.number_of_categories_limit",b)}return this.getPath("attributeStats.number_of_categories_limit")}.property(),cellNames:function(){return this.getPath("attributeStats.cellNames")}.property(),cellNamesDidChange:function(){this.notifyPropertyChange("cellNames")}.observes("attributeStats.categoricalStats.cellNames"),minMax:function(){var b=this.getPath("attributeStats.minMax"),a=b.max-b.min;b.min-=this.get("offsetMinProportion")*a;return b}.property(),minMaxDidChange:function(){this.notifyPropertyChange("minMax")}.observes("*attributeStats.minMax","offsetMinProportion"),offsetMinProportion:0,_attributes:null,init:function(){this._attributes=[];arguments.callee.base.apply(this,arguments);this.attributeStats=DG.AttributeStats.create()},setupStats:function(){this.attributeStats.beginPropertyChanges();this.attributeStats.set("collectionClient",this.get("collectionClient"));this.attributeStats.set("attributes",this.get("attributes"));this.attributeStats.endPropertyChanges()},setCases:function(a){this.attributeStats.setCases(a)},attributeID:function(){var a=this.get("attribute");return(a!==DG.Analysis.kNullAttribute)?a.get("id"):null}.property("attribute"),isNumeric:function(){var a=this.get("attributeType");return a===DG.Analysis.EAttributeType.eNumeric||a===DG.Analysis.EAttributeType.eDateTime}.property("attributeType"),isCategorical:function(){return this.get("attributeType")===DG.Analysis.EAttributeType.eCategorical}.property("attributeType"),isNull:function(){return this.get("attributeID")===null}.property("attributeID"),isColor:function(){return this.get("attributeType")===DG.Analysis.EAttributeType.eColor}.property("attributeType"),noAttributes:function(){var a=this.get("attributes");return !a||!SC.isArray(a)||(a.length===0)}.property("attributes"),hasFormula:function(){var a=this.getPath("attribute.formula");return !SC.empty(a)}.property(),attributeType:function(){var a=this.get("attributeStats");if(SC.none(a)){return DG.Analysis.EAttributeType.eNone}else{return a.get("attributeType")}}.property(),attributeTypeDidChange:function(){this.notifyPropertyChange("attributeType")}.observes("*attributeStats.attributeType"),role:DG.Analysis.EAnalysisRole.eNone,collectionClient:null,collectionClientDidChange:function(){this.setPath("attributeStats.collectionClient",this.get("collectionClient"))}.observes("collectionClient"),invalidateCaches:function(c,b){var a=this.get("attributeStats");if(a){a.invalidateCaches(c,b)}if(this._attributes.length===0){this.setPath("attributeStats.attributeType",DG.Analysis.EAttributeType.eNone)}},colorMapDidChange:function(){this.invalidateCaches();this.propertyDidChange("categoryMap")}.observes("attribute.categoryMap"),casesForCategory:function(b){var a=this.getPath("attributeStats.cellMap");return(a&&a[b])?a[b].cases:[]}});DG.AttributeStats=SC.Object.extend((function(){return{attributes:null,numericStats:null,categoricalStats:null,number_of_categories_limit:null,number_of_categories_limitDidChange:function(){this._categoricalCacheIsValid=false}.observes("number_of_categories_limit"),_cases:null,_numericCacheIsValid:null,_categoricalCacheIsValid:null,_attributeType:null,init:function(){arguments.callee.base.apply(this,arguments);this._cases=[];this.attributes=[];this.numericStats=DG.UnivariateStats.create();this._numericCacheIsValid=true;this.categoricalStats=DG.CategoricalStats.create();this._categoricalCacheIsValid=true},setCases:function(a){this._cases=a},attributeDidChange:function(){var c=this.get("attributes"),b=(c.length>0)?c[0]:null,a=SC.none(b)?null:b.get("type");switch(a){case"numeric":a=DG.Analysis.EAttributeType.eNumeric;break;case"categorical":a=DG.Analysis.EAttributeType.eCategorical;break;default:a=null}this.invalidateCaches();this.set("attributeType",a)}.observes("attributes"),invalidateCaches:function(n,i){function f(q,p){return SC.none(p)||(q<p)}function m(q,p){return SC.none(p)||(q>p)}var h,e,k=function(p,q){var r={},s=p.getNumValue(q,r);if(isFinite(s)){this.numericStats.incrementProperty("count");this.numericStats.set("sum",this.numericStats.sum+s);if(r.type!=="boolean"){if(f(s,this.numericStats.rangeMin)){this.numericStats.set("rangeMin",s)}if(m(s,this.numericStats.rangeMax)){this.numericStats.set("rangeMax",s)}if(s>0){if(f(s,this.numericStats.positiveMin)){this.numericStats.set("positiveMin",s)}if(m(s,this.numericStats.positiveMax)){this.numericStats.set("positiveMax",s)}}}this.numericStats.setIfChanged("squaredDeviations",null)}else{if(r.isNominal&&!isNaN(s)){this.numericStats.setIfChanged("attributeType",DG.ColorUtilities.isColorSpecString(s)?DG.Analysis.EAttributeType.eColor:DG.Analysis.EAttributeType.eCategorical)}}}.bind(this),b=function(p,w,v){var q=p.getStrValue(w),x;if(!SC.empty(q)){var t=v.__order.indexOf(q),u=Object.getOwnPropertyNames(c).length,r=this.get("number_of_categories_limit");if(SC.none(c[q])){var s=t>=0?t:u;if(SC.none(r)||s<r){c[q]={cases:[],cellNumber:s};x=c[q];h=q}else{if(!SC.none(r)){if(u===r){if(h&&!c[DG.PlotUtilities.kOther]){c[DG.PlotUtilities.kOther]=c[h];delete c[h]}x=c[DG.PlotUtilities.kOther]}}}DG.ObjectMap.forEach(c,function(y,A){var z=v.__order.indexOf(y);if(z>=0&&A.cellNumber!==z){A.cellNumber=z;p._didDisturbCellOrder=true}})}else{x=c[q]}if(x){x.cases.push(p)}this.categoricalStats.incrementProperty("count")}}.bind(this),l=this.get("attributeType"),c=this.getPath("categoricalStats.cellMap"),j=this.get("attributes"),a=this._numericCacheIsValid,o=this._categoricalCacheIsValid&&(l===DG.Analysis.EAttributeType.eCategorical),d,g;if(n){this.setCases(n)}if(i&&((i.operation==="createCase")||(i.operation==="createCases"))){e=i.result.caseIDs||[i.result.caseID];if(a){this.numericStats.beginPropertyChanges()}if(o){this.categoricalStats.beginPropertyChanges();this.setIfChanged("_categoricalCacheIsValid",false)}e.forEach(function(q){var p=DG.store.find(DG.Case,q);if(p){j.forEach(function(r){d=r.get("id");g=r.get("categoryMap");if(a){k(p,d)}if(o){b(p,d,g)}}.bind(this))}}.bind(this));if(a){this.numericStats.endPropertyChanges()}if(o){j.forEach(function(p){p.updateCategoryMap()});this.categoricalStats.endPropertyChanges()}return}else{if(i&&i.operation==="deleteCases"){if(a){this.numericStats.beginPropertyChanges();this.numericStats.reset()}if(o){this.categoricalStats.beginPropertyChanges();this.categoricalStats.reset();this._computeCategoricalStats()}this._cases.forEach(function(p){if(p){j.forEach(function(q){d=q.get("id");g=q.get("categoryMap");if(a){k(p,d)}if(o){b(p,d,g)}else{this.setIfChanged("_categoricalCacheIsValid",false)}}.bind(this))}}.bind(this));if(a){this.numericStats.endPropertyChanges()}if(o){this.categoricalStats.endPropertyChanges()}return}}this.setIfChanged("_numericCacheIsValid",false);this.setIfChanged("_categoricalCacheIsValid",false)},minMax:function(){if(!this._numericCacheIsValid){this._computeNumericStats()}var a=this.numericStats.get("numericRange");return{min:a.min,max:a.max,isDataInteger:this.numericStats.get("dataIsInteger")}}.property(),attributeType:function(a,b){if(b!==undefined){this._attributeType=b}if(!SC.none(this._attributeType)){return this._attributeType}var c=this.get("attributes");if(c.length===0){this._attributeType=DG.Analysis.EAttributeType.eNone}else{switch(c[0].get("type")){case"nominal":case"categorical":this._attributeType=DG.Analysis.EAttributeType.eCategorical;break;case"numeric":this._attributeType=DG.Analysis.EAttributeType.eNumeric;break;case"date":this._attributeType=DG.Analysis.EAttributeType.eDateTime;break;default:}}if(SC.none(this._attributeType)){if(!this._numericCacheIsValid){this._computeNumericStats()}this._attributeType=this.getPath("numericStats.attributeType")}return this._attributeType}.property("attributes"),attributeTypeDidChange:function(){this.notifyPropertyChange("attributeType")}.observes("*numericStats.attributeType"),_computeNumericStats:function(){var n=this._cases,k=this.get("attributes"),o=0,d=this._attributeType===DG.Analysis.EAttributeType.eNumeric||(k.length>0&&k[0].get("type")==="numeric"),p=this._attributeType===DG.Analysis.EAttributeType.eDateTime||(k.length>0&&k[0].get("type")==="date"),s,c=true,b=n.get("length")>0,a=false,j=false,e=Number.POSITIVE_INFINITY,g=Number.NEGATIVE_INFINITY,h=Number.MAX_VALUE,i=-Number.MAX_VALUE,q=0,t=0,f=0,m,l=[];function r(u){var w=d?DG.MathUtilities.extractNumeric(u):Number(u);a=b&&(a||DG.isDate(u)||DG.isDateString(u));b=p||(b&&(SC.empty(u)||DG.isDate(u)||DG.isDateString(u)));if(b&&(!SC.empty(u))){var v=DG.isDate(u)?u:DG.createDate(u);if(v){o++;if(v.valueOf()<e){e=v.valueOf()}if(v.valueOf()>g){g=v.valueOf()}}}else{if(!SC.empty(w)&&(typeof u!=="boolean")&&isFinite(w)){o++;if(w<e){e=w}if(w>g){g=w}q+=w;l.push(w);if(w>0){h=Math.min(w,h);i=Math.max(w,i)}}else{if((typeof u!=="number")&&!SC.empty(u)){w=String(u);c=c&&SC.empty(w);j=j||DG.ColorUtilities.isColorSpecString(w)}}}}this.numericStats.reset();this.numericStats.beginPropertyChanges();if(SC.isArray(n)){k.forEach(function(u){var v=u.get("id");n.forEach(function(w){r(w.getRawValue(v))})})}b=b&&a;if(o>0){this.numericStats.set("count",o);this.numericStats.set("sum",q);this.numericStats.set("rangeMin",e);this.numericStats.set("rangeMax",g);m=q/o;l.forEach(function(v){var u=v-m;t+=u;f+=u*u});f-=t*t/o;this.numericStats.set("squaredDeviations",f);if(h<=i){this.numericStats.set("positiveMin",h);this.numericStats.set("positiveMax",i)}}if(b){s=DG.Analysis.EAttributeType.eDateTime}else{if(c){s=DG.Analysis.EAttributeType.eNumeric}else{if(j){s=DG.Analysis.EAttributeType.eColor}else{s=DG.Analysis.EAttributeType.eCategorical}}}this.numericStats.set("attributeType",s);this._numericCacheIsValid=true;this.numericStats.endPropertyChanges()},numberOfCells:function(){if(this.get("attributeType")===DG.Analysis.EAttributeType.eNumeric){return 1}if(!this._categoricalCacheIsValid){this._computeCategoricalStats()}return this.getPath("categoricalStats.numberOfCells")}.property(),numberOfCellsDidChange:function(){this.notifyPropertyChange("numberOfCells")}.observes("*categoricalStats.numberOfCells"),numericRange:function(){if(!this._numericCacheIsValid){this._computeNumericStats()}return this.getPath("numericStats.numericRange")}.property(),numericRangeDidChange:function(){this.notifyPropertyChange("numericRange")}.observes("*numericStats.numericRange"),dataDidChange:function(){if((this.get("attributeType")===DG.Analysis.EAttributeType.eCategorical)&&!this._categoricalCacheIsValid){var a=this.categoricalStats.get("numberOfCells"),b;this._computeCategoricalStats();b=this.categoricalStats.get("numberOfCells");if(b!==a){this.notifyPropertyChange("numberOfCells")}}}.observes("_categoricalCacheIsValid"),cellMap:function(){if(!this._categoricalCacheIsValid){this._computeCategoricalStats()}return this.categoricalStats.get("cellMap")}.property(),cellMapDidChange:function(){this.notifyPropertyChange("cellMap")}.observes("categoricalStats.cellMap"),cellNames:function(){if(!this._categoricalCacheIsValid){this._computeCategoricalStats()}return this.categoricalStats.get("cellNames")}.property(),cellNamesDidChange:function(){this.notifyPropertyChange("cellNames")}.observes("*categoricalStats.cellMap"),cellNameToCellNumber:function(a){if(!this._categoricalCacheIsValid){this._computeCategoricalStats()}return this.categoricalStats.cellNameToCellNumber(a)},_computeCategoricalStats:function(){var g=this._cases,h=this.get("attributes"),f=0,a={},e=[],c,b=this.get("number_of_categories_limit");function d(j,i){var k=String(i);if(!SC.none(i)&&!SC.empty(k)){if(SC.none(a[k])){a[k]={cases:[],cellNumber:null}}a[k].cases.push(j);f++}}this.categoricalStats.reset();if(SC.isArray(g)){h.forEach(function(k){k.updateCategoryMap();var n=k.get("id");g.forEach(function(o){d(o,o.getValue(n))});var j=0,l=k.get("blockDisplayOfEmptyCategories");k.forEachCategory(function(o,p,q){if(!l||(a[o]&&a[o].cases.length>0)){a[o].cellNumber=j++}});c=j;if(!SC.none(b)&&c>b+1){DG.ObjectMap.forEach(a,function(o,p){e.push({key:o,cellNumber:p.cellNumber})});e.sort(function(p,o){return p.cellNumber-o.cellNumber});var i={cases:[],cellNumber:null},m;while(c>b){m=e.pop();a[m.key].cases.forEach(function(o){i.cases.push(o)});i.cellNumber=m.cellNumber;delete a[m.key];c--}a[DG.PlotUtilities.kOther]=i}});this.categoricalStats.beginPropertyChanges();this.categoricalStats.set("cellMap",a);this.categoricalStats.set("count",f);this._categoricalCacheIsValid=true;this.categoricalStats.endPropertyChanges()}}}}()));DG.CategoricalStats=SC.Object.extend({count:null,cellMap:null,_prevNumberOfCells:0,init:function(){arguments.callee.base.apply(this,arguments);this.cellMap={}},numberOfCells:function(){return DG.ObjectMap.length(this.cellMap)}.property(),countOrNumberOfCellsDidChange:function(){var a=this.get("numberOfCells");if(a!==this._prevNumberOfCells){this.notifyPropertyChange("numberOfCells")}this._prevNumberOfCells=a}.observes("count","cellMap"),cellNameToCellNumber:function(b){var a=SC.empty(b)?null:this.cellMap[b.toString()];a=a||this.cellMap[DG.PlotUtilities.kOther];return a&&a.cellNumber},cellNames:function(){var a=[];DG.ObjectMap.forEach(this.get("cellMap"),function(c,b){a.push({name:c,cellNumber:b.cellNumber})});a=a.sort(function(c,b){return c.cellNumber-b.cellNumber});return a.map(function(b){return b.name})}.property("cellMap"),reset:function(){this.count=0;this.cellMap={}}});DG.PlotDataConfiguration=SC.Object.extend({_dataContext:null,dataContext:function(a,b){if(b){if(this._dataContext){this._dataContext.removeObserver("changeCount",this,"handleDataContextNotification")}this._dataContext=b;this._dataContext.addObserver("changeCount",this,"handleDataContextNotification")}return this._dataContext}.property(),handleDataContextNotification:function(a){a.get("newChanges").forEach(function(b){if(b.operation==="moveAttribute"){this.updateCaptionAttribute()}}.bind(this))},updateCaptionAttribute:function(){var c=this.getPath("dataContext.collections"),f=-1;if(!c){return}["x","y","legend","y2","top","right","polygon"].forEach(function(h){var g=this.getPath(h+"AttributeDescription.attribute.collection"),i=g?c.indexOf(g):-1;f=Math.max(f,i)}.bind(this));if(f===-1){f=c.length-1}var d=this.get("cases"),b=this.get("captionAttributeDescription"),e=c[f].get("attrs"),a=e.find(function(g){return !g.get("hidden")});b.setCases(d);b.set("attribute",null);b.set("attribute",a)},dataContextDidChange:function(){var a=function(){var c=this.get("dataContext"),b=this.get("attributesByPlace").some(function(e){return e&&e[0]&&e[0].getPath("attribute.isDestroyed")});if(b){["x","y","legend","y2","top","right","polygon"].forEach(function(h){var j=h+"AttributeDescription",m=this.get(j),k=(m&&m.get("attributes"))||[],f=k.length>0?k[0]:null,e=f&&c.getAttrRefByID(f.id),g=e&&e.collection,l=k.map(function(n){var o=c.getAttrRefByID(n.id);return o&&o.attribute}),i={collection:g,attributes:l};this.setAttributeAndCollectionClient(j,i)}.bind(this));var d=this.getPath("collectionClient.casesController");if(!d.hasObserverFor("selection",this,this.selectionDidChange)){d.addObserver("selection",this,this.selectionDidChange)}}}.bind(this);a();this.invalidateCaches();this.notifyPropertyChange("defaultTitle")}.observes("dataContext"),attributesByPlace:null,collectionClient:function(){var a=(this.chooseChildCollection(this.get("xCollectionClient"),this.get("yCollectionClient"))||this.get("legendCollectionClient"));if(!a){a=this.getPath("dataContext.childCollection");if(a&&a.getPath("casesController.arrangedObjects").length()===0){a=this.getPath("dataContext.parentCollection")}}return a}.property("xCollectionClient","yCollectionClient","legendCollectionClient","dataContext"),xCollectionClient:function(){return this.getPath("xAttributeDescription.collectionClient")}.property(),yCollectionClient:function(){return this.getPath("yAttributeDescription.collectionClient")}.property(),y2CollectionClient:function(){return this.getPath("y2AttributeDescription.collectionClient")}.property(),legendCollectionClient:function(){return this.getPath("legendAttributeDescription.collectionClient")}.property(),xCollectionDidChange:function(){this.notifyPropertyChange("xCollectionClient")}.observes("*xAttributeDescription.collectionClient"),yCollectionDidChange:function(){this.notifyPropertyChange("yCollectionClient")}.observes("*yAttributeDescription.collectionClient"),y2CollectionDidChange:function(){this.notifyPropertyChange("y2CollectionClient")}.observes("*y2AttributeDescription.collectionClient"),legendCollectionDidChange:function(){this.notifyPropertyChange("legendCollectionClient")}.observes("*legendAttributeDescription.collectionClient"),defaultTitle:function(){return this.getPath("collectionClient.name")}.property("dataContext"),childmostCollection:function(){var a=null;this.get("attributesByPlace").forEach(function(c){var b=c.length>0&&c[0].getPath("collectionClient.collection");if(b&&(!a||b.isDescendantOf(a))){a=b}});return a||this.getPath("collectionClient.collection")}.property(),xAttributeDescription:function(a,b){return this.attributeDescriptionForPlace(a,b,DG.GraphTypes.EPlace.eX)}.property(),yAttributeDescription:function(a,b){return this.attributeDescriptionForPlace(a,b,DG.GraphTypes.EPlace.eY)}.property(),y2AttributeDescription:function(a,b){return this.attributeDescriptionForPlace(a,b,DG.GraphTypes.EPlace.eY2)}.property(),legendAttributeDescription:function(a,b){return this.attributeDescriptionForPlace(a,b,DG.GraphTypes.EPlace.eLegend)}.property(),numberOfLegendQuantiles:5,legendQuantilesAreLocked:false,_legendQuantiles:null,legendQuantiles:function(){if(!this.get("legendQuantilesAreLocked")||!this._legendQuantiles){var b=this.get("numberOfLegendQuantiles"),a=this.numericValuesForPlace(DG.GraphTypes.EPlace.eLegend);this._legendQuantiles=DG.MathUtilities.nQuantileValues(a,b);this._legendQuantiles[b]+=Math.abs(this._legendQuantiles[b]-this._legendQuantiles[0])*0.000001}return this._legendQuantiles}.property("numberOfLegendQuantiles","legendQuantilesAreLocked"),quantilesAreLockedDidChange:function(){if(!this.get("legendQuantilesAreLocked")){this._legendQuantiles=null}else{this.get("legendQuantiles")}}.observes("legendQuantilesAreLocked"),attributeDescriptionForPlace:function(b,c,a){if(c){DG.assert(c instanceof DG.AttributePlacementDescription);this.attributesByPlace[a][0]=c;c.addObserver("collection",this,"collectionDidChange");c.addObserver("categoryMap",this,"categoryMapDidChange")}return !SC.none(this.attributesByPlace)?this.attributesByPlace[a][0]:null}.property(),_tempAttrDescription:null,collectionDidChange:function(a){var c=a.getPath("attribute.collection.id"),b=this.get("dataContext").getCollectionByID(c);a.set("collectionClient",b)},categoryMapDidChange:function(){this.propertyDidChange("categoryMap")},firstAttributeDescriptionForRole:function(a){return this.firstPlaceAndAttributeDescriptionForRole(a).attributeDescription},firstAttributeIDForRole:function(b){var a=this.firstPlaceAndAttributeDescriptionForRole(b);return a.attributeDescription.get("attributeID")},getPlaceForRole:function(a){return this.firstPlaceAndAttributeDescriptionForRole(a).place},xAttributeID:function(){return this.getPath("xAttributeDescription.attributeID")}.property(),yAttributeID:function(){return this.getPath("yAttributeDescription.attributeID")}.property(),y2AttributeID:function(){return this.getPath("y2AttributeDescription.attributeID")}.property(),legendAttributeID:function(){return this.getPath("legendAttributeDescription.attributeID")}.property(),xAttributeIDDidChange:function(){this.notifyPropertyChange("xAttributeID")}.observes("*xAttributeDescription.attributeID"),yAttributeIDDidChange:function(){this.notifyPropertyChange("yAttributeID")}.observes("*yAttributeDescription.attributeID"),y2AttributeIDDidChange:function(){this.notifyPropertyChange("y2AttributeID")}.observes("*y2AttributeDescription.attributeID"),legendAttributeIDDidChange:function(){this.notifyPropertyChange("legendAttributeID")}.observes("*legendAttributeDescription.attributeID"),recomputeLegendQuantilesIfLocked:function(){if(this.get("legendQuantilesAreLocked")){this.set("legendQuantilesAreLocked",false);this.set("legendQuantilesAreLocked",true)}},xIsNumeric:function(){return this.getPath("xAttributeDescription.isNumeric")}.property(),yIsNumeric:function(){return this.getPath("yAttributeDescription.isNumeric")}.property(),y2IsNumeric:function(){return this.getPath("y2AttributeDescription.isNumeric")}.property(),xIsNumericDidChange:function(){this.notifyPropertyChange("xIsNumeric")}.observes("*xAttributeDescription.isNumeric"),yIsNumericDidChange:function(){this.notifyPropertyChange("yIsNumeric")}.observes("*yAttributeDescription.isNumeric"),y2IsNumericDidChange:function(){this.notifyPropertyChange("y2IsNumeric")}.observes("*y2AttributeDescription.isNumeric"),xType:function(){return DG.Analysis.forceColorToCategorical(this.getPath("xAttributeDescription.attributeType"))}.property(),yType:function(){return DG.Analysis.forceColorToCategorical(this.getPath("yAttributeDescription.attributeType"))}.property(),y2Type:function(){return DG.Analysis.forceColorToCategorical(this.getPath("y2AttributeDescription.attributeType"))}.property(),xTypeDidChange:function(){this.notifyPropertyChange("xType")}.observes("*xAttributeDescription.attributeType"),yTypeDidChange:function(){this.notifyPropertyChange("yType")}.observes("*yAttributeDescription.attributeType"),y2TypeDidChange:function(){this.notifyPropertyChange("y2Type")}.observes("*y2AttributeDescription.attributeType"),attributeAssignment:null,hasAtLeastOneAttributeAssigned:function(){return["x","y","legend"].some(function(a){return !this.getPath(a+"AttributeDescription.isNull")}.bind(this))},noAttributesFor:function(a){return a.every(function(b){return this.getPath(b+"AttributeDescription.noAttributes")}.bind(this))},hasAggregates:function(){var b={},c,a=function(d){var f=this.getPath(d+"AttributeDescription.collectionClient"),e=f&&f.get("id");if(!SC.none(e)){b[e]=f}}.bind(this);a("x");a("y");a("legend");c=DG.ObjectMap.findKey(b,function(e,d){return d&&d.get("hasAggregates")});return !SC.none(c)}.property(),yAttributeIDAt:function(a){return this.get("yAttributeDescription").attributeIDAt(a)},y2AttributeIDAt:function(a){return this.get("y2AttributeDescription").attributeIDAt(a)},_hiddenCases:null,hiddenCases:function(a,b){if(b){this._hiddenCases=b;this.invalidateCaches()}return this._hiddenCases}.property(),init:function(){arguments.callee.base.apply(this,arguments);this._hiddenCases=[];this._plotCaseArray=DG.PlotUtilities.PlotCaseArray.create()},destroy:function(){var b=this.get("xAttributeDescription"),d=this.get("yAttributeDescription"),a=this.get("y2AttributeDescription"),c=this.get("legendAttributeDescription");if(b){b.removeObserver("collectionClient",this,"xCollectionDidChange")}if(d){d.removeObserver("collectionClient",this,"yCollectionDidChange")}if(a){a.removeObserver("collectionClient",this,"y2CollectionDidChange")}if(c){c.removeObserver("collectionClient",this,"legendCollectionDidChange")}if(this.get("attributesByPlace")){this.get("attributesByPlace").forEach(function(e){e.removeObserver("collection",this,"collectionDidChange");e.removeObserver("categoryMap",this,"categoryMapDidChange")}.bind(this))}this._hiddenCases=[];arguments.callee.base.apply(this,arguments)},setAttributeAndCollectionClient:function(b,d,f,c){var a=this.get(b);if(a){a.removeAllAttributes();a.beginPropertyChanges();a.set("collectionClient",(d&&d.collection)||null);this._casesCache=null;a.setCases(this.get("cases"));if(!SC.none(d)){var e=d.attributes||[d.attribute];e.forEach(function(g){a.addAttribute(g)})}if(!SC.none(f)){a.set("role",f)}if(!SC.none(c)){a.setPath("attributeStats.attributeType",c)}this._casesCache=null;a.invalidateCaches(this.get("cases"));a.endPropertyChanges()}},setAttributeType:function(f,g){DG.assert(typeof f==="string");DG.assert(typeof g==="boolean");var c=this.get(f),d=(g?DG.Analysis.EAttributeType.eNumeric:DG.Analysis.EAttributeType.eCategorical),b=c&&c.get("attribute"),e=c&&c.get("attributeStats");DG.assert(b!==DG.Analysis.kNullAttribute);c.invalidateCaches(this.get("cases"));if(e){var a=e.getPath("numericStats.attributeType");if(a===DG.Analysis.EAttributeType.eDateTime&&g){d=a}e.set("attributeType",d)}},chooseChildCollection:function(f,e){var c=this.get("dataContext"),d=c?c.get("collections"):[],b=f?d.indexOf(f.get("collection")):-1,a=e?d.indexOf(e.get("collection")):-1;return(b>a)?f:e},plottedCollectionIDs:function(){var d=[],a=this.get("collectionClient"),b=a&&a.get("id"),c=["xCollectionClient","yCollectionClient","y2CollectionClient"];if(a&&!SC.none(b)){d.push(b)}c.forEach(function(e){var g=this.get(e),f=g&&g.get("id");if(!SC.none(f)){if(d.indexOf(f)<0){d.push(f)}}}.bind(this));return d}.property("collectionClient","xCollectionClient","yCollectionClient","y2CollectionClient","legendCollectionClient").cacheable(),placedAttributeIDs:function(){var a,d,g,e,b,f,c=[];for(a=DG.GraphTypes.EPlace.eFirstPlace;a<=DG.GraphTypes.EPlace.eLastPlace;++a){g=this.attributeDescriptionForPlace(null,null,a);b=g&&g.get("attributes");f=b?b.length:0;for(d=0;d<f;++d){e=g.attributeIDAt(d);if(c.indexOf(e)<0){c.push(e)}}}return c}.property(),sortCasesByLegendCategories:true,_casesCache:null,_plotCaseArray:null,allCases:function(){var a=this.get("collectionClient")||DG.currDocumentController().collectionDefaults().collectionClient;return a?a.getPath("casesController.arrangedObjects"):null}.property(),cases:function(){var i=this.get("attributesByPlace")||[];function g(o){var n=DG.GraphTypes.EPlace[o];return i&&i[n]&&i[n][0]&&i[n][0].getPath("attribute.id")}if(SC.none(this._casesCache)){var b=this.get("displayOnlySelected")?this.get("selection"):this.get("allCases"),e=this.get("hiddenCases"),m,a=[],d;if(b){m=DG.ArrayUtils.subtract(b,e,function(n){return n?n.get("id"):null});d={x:g("eX"),y:g("eY"),y2:g("eY2")};m.forEach(function(p){var o=SC.none(d.x)||p.hasValue(d.x),n=SC.none(d.y)||p.hasValue(d.y)||(!SC.none(d.y2)&&p.hasValue(d.y2));if(o&&n){a.push(p)}});var j=i[DG.GraphTypes.EPlace.eLegend],l=j&&j[0],c=[];for(var f=0;f<a.length;f++){c.push(f)}if(this.get("sortCasesByLegendCategories")&&l){var k=l.getPath("attribute.id");switch(l.get("attributeType")){case DG.Analysis.EAttributeType.eCategorical:var h=l.getPath("attribute.categoryMap");c=DG.ArrayUtils.stableSort(c,function(o,n){var q=a[o].getStrValue(k),p=a[n].getStrValue(k);if(SC.empty(q)){return 1}else{if(SC.empty(p)){return -1}else{return h.__order.indexOf(p)-h.__order.indexOf(q)}}});break;case DG.Analysis.EAttributeType.eNumeric:c=DG.ArrayUtils.stableSort(c,function(o,n){var q=a[o].getValue(k),p=a[n].getValue(k);return p-q});break}}this._plotCaseArray.set("_cases",a);this._plotCaseArray.set("_map",c)}}this._casesCache=this._plotCaseArray;return this._casesCache}.property("xCollectionClient","yCollectionClient","legendCollectionClient"),numericValuesForPlace:function(b){var e=[],d=this.get("attributesByPlace")[b][0],a=d.getPath("attribute.id");if(d.get("isNumeric")){var c=this.get("cases");e=[];if(c){c.forEach(function(f){var g=f.getForcedNumericValue(a);if(DG.MathUtilities.isNumeric(g)){e.push(g)}})}}return e},getCaseCount:function(){return this.getPath("cases.length")},_displayOnlySelected:false,displayOnlySelected:function(a,b){if(!SC.none(b)){this.invalidateCaches();this.notifyPropertyChange("hiddenCasesWillChange");this._displayOnlySelected=b}return this._displayOnlySelected}.property(),selection:function(){var a=this.getPath("collectionClient.casesController.selection");a=a?a.toArray():[];return DG.ArrayUtils.subtract(a,this.get("hiddenCases"),function(b){return b?b.get("id"):null})}.property("xCollectionClient","yCollectionClient","y2CollectionClient","legendCollectionClient","hiddenCases"),selectionDidChange:function(){this.notifyPropertyChange("selection")}.observes("collectionClient.casesController.selection"),attributeAssignmentDidChange:function(){this.notifyPropertyChange("attributeAssignment")}.observes(".xAttributeDescription.attribute",".yAttributeDescription.attribute",".y2AttributeDescription.attribute",".legendAttributeDescription.attribute",".topAttributeDescription.attribute",".rightAttributeDescription.attribute"),forEachAttribute:function(a){this.get("attributesByPlace").forEach(function(b){b.forEach(a)})},firstAttributeDescriptionSuchThat:function(f){var c=this.get("attributesByPlace"),g=c.length,d;for(d=0;d<g;d++){var b=c[d],a=!SC.none(b)?b.length:0,e;for(e=0;e<a;e++){if(f(b[e])){return{attributeDescription:b[e],place:d}}}}return{attributeDescription:null,place:DG.GraphTypes.EPlace.eUndefined}},firstPlaceAndAttributeDescriptionForRole:function(a){return this.firstAttributeDescriptionSuchThat(function(b){return b.get("role")===a})},invalidateAttributeDescriptionCaches:function(b,a){if(this.get("xAttributeDescription")){this.get("xAttributeDescription").invalidateCaches(b,a)}if(this.get("yAttributeDescription")){this.get("yAttributeDescription").invalidateCaches(b,a)}if(this.get("y2AttributeDescription")){this.get("y2AttributeDescription").invalidateCaches(b,a)}if(this.get("legendAttributeDescription")){this.get("legendAttributeDescription").invalidateCaches(b,a)}},invalidateCaches:function(f,e){var d;if(!f&&e&&this._casesCache&&((e.operation==="createCase")||(e.operation==="createCases"))){var g=e.collection&&e.collection.get("id"),b=this.getPath("collectionClient.id"),h=e.collections&&e.collections.map(function(i){return i.get("id")}),c=(g===b)||(h&&h.indexOf(b)>=0);c=c&&!this.get("displayOnlySelected");if(!c){return}if(e.result.caseIDs||e.result.caseID){var a=e.result.caseIDs||[e.result.caseID];a.forEach(function(j){var i=this.get("dataContext").getCaseByID(j);if(i){this._casesCache.push(i)}}.bind(this))}d=this._casesCache}else{this._casesCache=null;d=f||this.get("cases")}this.invalidateAttributeDescriptionCaches(d,e)},whatIsBeingDisplayedDidChange:function(){this._casesCache=null;this.invalidateAttributeDescriptionCaches()}.observes("hiddenCases","displayOnlySelected"),synchHiddenCases:function(){var a=this.get("hiddenCases"),b=a.filter(function(c){var d=DG.store.find(DG.Case,c.get("id"));return SC.none(d)});if(b.length>0){this.set("hiddenCases",DG.ArrayUtils.subtract(a,b,function(c){return c.get("id")}))}},arrangedObjectArrays:function(){var b=this.get("xCollectionClient"),f=this.get("yCollectionClient"),a=this.get("legendCollectionClient"),d=this.get("y2CollectionClient"),c=!SC.none(b)?[b.casesController.arrangedObjects()]:[];if((b!==f)&&!SC.none(f)){c.push(f.casesController.arrangedObjects())}if(!SC.none(a)&&(a!==b)&&(a!==f)){c.push(a.casesController.arrangedObjects())}if(!SC.none(d)&&(d!==b)&&(d!==f)&&(d!==a)){c.push(d.casesController.arrangedObjects())}if(c.length===0){var e=DG.currDocumentController().collectionDefaults().collectionClient;if(e){c.push(e.casesController.arrangedObjects())}}return c}.property("xCollectionClient","yCollectionClient","legendCollectionClient"),getDataMinAndMaxForDimension:function(a){var b;switch(a){case DG.GraphTypes.EPlace.eX:b=this.get("xAttributeDescription");break;case DG.GraphTypes.EPlace.eY:b=this.get("yAttributeDescription");break;case DG.GraphTypes.EPlace.eY2:b=this.get("y2AttributeDescription");break;case DG.GraphTypes.EPlace.eLegend:b=this.get("legendAttributeDescription");break}return b.getPath("attributeStats.minMax")},atLeastOneFormula:function(){var a=["xAttributeDescription","yAttributeDescription","legendAttributeDescription","y2AttributeDescription"];return a.some(function(b){return this.getPath(b+".hasFormula")}.bind(this))},hideCases:function(a){if(!a||!a.length){return}this.notifyPropertyChange("hiddenCasesWillChange");this.set("hiddenCases",this.get("hiddenCases").concat(a).uniq())},showCases:function(a){if(!a||!a.length){return}this.notifyPropertyChange("hiddenCasesWillChange");this.set("hiddenCases",DG.ArrayUtils.subtract(this.get("hiddenCases"),a,function(b){return b&&b.get("id")}))},showAllCases:function(){if(this.get("hiddenCases").length>0){this.set("hiddenCases",[])}},restoreHiddenCases:function(a){this.showAllCases();if(!a||!a.length){return}this.set("hiddenCases",a.map(function(b){return this.get("dataContext").getCaseByID(b)}.bind(this)))},addToStorageForDimension:function(a,f){var d=this.get(f+"CollectionClient"),e=this.get(f+"AttributeDescription"),c=(e&&e.get("attributes"))||[];if(d&&(c.length>0)){a._links_[f+"Coll"]=d.toLink();var b=f+"Attr";c.forEach(function(g){DG.ArchiveUtils.addLink(a,b,g)})}if(e){a[f+"Role"]=e.get("role");a[f+"AttributeType"]=e.get("attributeType")}},addLegendQuantilesToStorage:function(a){var b=this.get("legendQuantilesAreLocked");a.numberOfLegendQuantiles=this.get("numberOfLegendQuantiles");a.legendQuantilesAreLocked=b;if(b){a.legendQuantiles=this._legendQuantiles}},restoreLegendQuantiles:function(a){this.set("numberOfLegendQuantiles",a.numberOfLegendQuantiles||5);if(a.legendQuantilesAreLocked){this._legendQuantiles=a.legendQuantiles}this.set("legendQuantilesAreLocked",a.legendQuantilesAreLocked===true)},attributeIsNominal:function(c){function d(g,e){var f=e&&e.get("id");return g&&!SC.none(f)&&g.getCollectionByID(f)}if(!this._tempAttrDescription){this._tempAttrDescription=DG.AttributePlacementDescription.create()}var b=this._tempAttrDescription;if(b.get("attribute")!==c){var a=d(this.get("dataContext"),c.get("collection"));b.removeAllAttributes();b.beginPropertyChanges();b.set("collectionClient",(a)||null);this._casesCache=null;b.setCases(this.get("cases"));b.addAttribute(c);b.invalidateCaches(this.get("cases"));b.endPropertyChanges()}return b.get("isCategorical")}});sc_require("components/graph_map_common/plot_data_configuration");DG.GraphDataConfiguration=DG.PlotDataConfiguration.extend({topCollectionClient:function(){return this.getPath("topAttributeDescription.collectionClient")}.property(),rightCollectionClient:function(){return this.getPath("rightAttributeDescription.collectionClient")}.property(),topCollectionDidChange:function(){this.notifyPropertyChange("topCollectionClient")}.observes("*topAttributeDescription.collectionClient"),rightCollectionDidChange:function(){this.notifyPropertyChange("rightCollectionClient")}.observes("*rightAttributeDescription.collectionClient"),topAttributeDescription:function(a,b){return this.attributeDescriptionForPlace(a,b,DG.GraphTypes.EPlace.eTopSplit)}.property(),captionAttributeDescription:function(a,b){return this.attributeDescriptionForPlace(a,b,DG.GraphTypes.EPlace.eCaption)}.property(),rightAttributeDescription:function(a,b){return this.attributeDescriptionForPlace(a,b,DG.GraphTypes.EPlace.eRightSplit)}.property(),topAttributeID:function(){return this.getPath("topAttributeDescription.attributeID")}.property(),rightAttributeID:function(){return this.getPath("rightAttributeDescription.attributeID")}.property(),topAttributeIDDidChange:function(){this.notifyPropertyChange("topAttributeID")}.observes("*topAttributeDescription.attributeID"),rightAttributeIDDidChange:function(){this.notifyPropertyChange("rightAttributeID")}.observes("*rightAttributeDescription.attributeID"),init:function(){var d={caption:DG.AttributePlacementDescription.create(),x:DG.AttributePlacementDescription.create(),y:DG.AttributePlacementDescription.create(),y2:DG.AttributePlacementDescription.create(),legend:DG.AttributePlacementDescription.create(),top:DG.AttributePlacementDescription.create(),right:DG.AttributePlacementDescription.create()},b,c=DG.currDocumentController().collectionDefaults();arguments.callee.base.apply(this,arguments);var a=function(f,h,e,j){var k=d[f],g=c["plot"+h+"Attr"],i=c["plot"+h+"AttrIsNumeric"];i=SC.none(i)?true:i;DG.assert(k,"Check for missing attribute description.");if(g){k.set("collectionClient",c.collectionClient);k.set("attribute",g);k.setPath("attributeStats.attributeType",SC.none(g)?DG.Analysis.EAttributeType.eNone:i?DG.Analysis.EAttributeType.eNumeric:DG.Analysis.EAttributeType.eCategorical);k.set("role",SC.none(g)?DG.Analysis.EAnalysisRole.eNone:i?e:j)}else{k.set("collectionClient",null);k.removeAllAttributes()}k.addObserver("collectionClient",this,f+"CollectionDidChange");k.addObserver("collection",this,"collectionDidChange")}.bind(this);a("x","X",DG.Analysis.EAnalysisRole.ePrimaryNumeric,DG.Analysis.EAnalysisRole.ePrimaryCategorical);a("y","Y",DG.Analysis.EAnalysisRole.eSecondaryNumeric,DG.Analysis.EAnalysisRole.eSecondaryCategorical);a("y2","Y2",DG.Analysis.EAnalysisRole.eSecondaryNumeric,DG.Analysis.EAnalysisRole.eSecondaryCategorical);a("legend","Legend",DG.Analysis.EAnalysisRole.eLegendNumeric,DG.Analysis.EAnalysisRole.eLegendCategorical);d.legend.addObserver("attributeStats.categoricalStats.cellMap",this,"legendColorMapDidChange");this.attributesByPlace=[];for(b=0;b<DG.GraphTypes.EPlace.eNumPlaces;b++){this.attributesByPlace[b]=[]}this.attributeDescriptionForPlace("caption",d.caption,DG.GraphTypes.EPlace.eCaption);this.attributeDescriptionForPlace("x",d.x,DG.GraphTypes.EPlace.eX);this.attributeDescriptionForPlace("y",d.y,DG.GraphTypes.EPlace.eY);this.attributeDescriptionForPlace("y2",d.y2,DG.GraphTypes.EPlace.eY2);this.attributeDescriptionForPlace("legend",d.legend,DG.GraphTypes.EPlace.eLegend);this.attributeDescriptionForPlace("topSplit",d.top,DG.GraphTypes.EPlace.eTopSplit);this.attributeDescriptionForPlace("right",d.right,DG.GraphTypes.EPlace.eRightSplit);this.set("dataContext",c.dataContext)},destroy:function(){var b=this.get("topAttributeDescription"),a=this.get("rightAttributeDescription");if(b){b.removeObserver("collectionClient",this,"topCollectionDidChange")}if(a){a.removeObserver("collectionClient",this,"rightCollectionDidChange")}arguments.callee.base.apply(this,arguments)},setAttributeAndCollectionClient:function(){arguments.callee.base.apply(this,arguments);this.updateCaptionAttribute()},legendColorMapDidChange:function(){this._casesCache=null},hasAggregates:function(){var d=arguments.callee.base.apply(this,arguments);if(!d){var b={},c,a=function(e){var g=this.getPath(e+"AttributeDescription.collectionClient"),f=g&&g.get("id");if(!SC.none(f)){b[f]=g}}.bind(this);a("top");a("right");c=DG.ObjectMap.findKey(b,function(f,e){return e&&e.get("hasAggregates")});d=!SC.none(c)}return d}.property(),hasSplitAttribute:function(){return !!this.get("rightAttributeID")||!!this.get("topAttributeID")}.property("rightAttributeID","topAttributeID"),invalidateAttributeDescriptionCaches:function(b,a){arguments.callee.base.apply(this,arguments);if(this.get("topAttributeDescription")){this.get("topAttributeDescription").invalidateCaches(b,a)}if(this.get("rightAttributeDescription")){this.get("rightAttributeDescription").invalidateCaches(b,a)}},atLeastOneFormula:function(){var a=["topAttributeDescription","rightAttributeDescription"];return(arguments.callee.base.apply(this,arguments)||a.some(function(b){return this.getPath(b+".hasFormula")}.bind(this)))}});DG.UnivariateStats=SC.Object.extend({count:0,attributeType:null,dataIsInteger:null,sum:null,squaredDeviations:null,rangeMin:null,rangeMax:null,numericRange:function(){return{min:this.get("rangeMin"),max:this.get("rangeMax")}}.property("rangeMin","rangeMax"),positiveMin:null,positiveMax:null,isEmpty:function(){return !this.count}.property("count"),mean:function(){return !this.isEmpty()?this.sum/this.count:NaN}.property("count","sum").cacheable(),hasRange:function(){return DG.isFinite(this.rangeMin)&&DG.isFinite(this.rangeMax)}.property("rangeMin","rangeMax").cacheable(),reset:function(){this.count=0;this.attributeType=null;this.dataIsInteger=null;this.sum=null;this.squaredDeviations=null;this.rangeMin=null;this.rangeMax=null;this.positiveMin=null;this.positiveMax=null}});sc_require("controllers/component_controller");DG.DataDisplayController=DG.ComponentController.extend((function(){var c="moonicon-icon-segmented-bar-chart",b="moonicon-icon-styles";function a(f,d){var e=d.collection&&d.collection.get("id");return f&&!SC.none(e)&&f.getCollectionByID(e)}return{kValuesPaneIconClass:"moonicon-icon-values",dataContext:null,dataDisplayModel:null,legendView:null,stylesPane:null,createComponentStorage:function(){return{}},restoreComponentStorage:function(f,g){arguments.callee.base.apply(this,arguments);var e=this.getLinkID(f,"context"),d=null;if(!SC.none(e)){d=DG.currDocumentController().getContextByID(e);if(d){this.set("dataContext",d);this.setPath("dataDisplayModel.dataConfiguration.dataContext",d)}}},dataContextDidChange:function(){var d=this.get("dataDisplayModel");if(d){d.set("dataContext",this.get("dataContext"))}}.observes("dataContext"),modelDidChange:function(){var d=this.getPath("model.content");this.set("dataDisplayModel",d);if(d){d.set("dataContext",this.get("dataContext"));d.set("componentID",this.getPath("model.id"))}}.observes("model"),init:function(){arguments.callee.base.apply(this,arguments)},childmostCollectionTitle:function(){return this.getPath("dataDisplayModel.childmostCollectionTitle")}.property(),setComponentTitleByChildmostCollection:function(){if(!this.getPath("model.userSetTitle")){this.setPath("model.title",this.get("childmostCollectionTitle"))}},createImageExportMenuItems:function(){var e=this.getPath("model.type")==="DG.MapView",g=this.getPath("graphModel.plotBackgroundImage"),l=g?"DG.DataDisplayMenu.removeBackgroundImage":"DG.DataDisplayMenu.addBackgroundImage",f=g?"removeBackgroundImage":"addBackgroundImage",j=e?[]:[{title:l,isEnabled:true,target:this,action:f}],m=this.getPath("graphModel.bothAxesAreNumeric");if(g&&m){var d=this.getPath("graphModel.plotBackgroundImageLockInfo"),i=d&&d.locked,h=i?"DG.DataDisplayMenu.unlockImageFromAxes":"DG.DataDisplayMenu.lockImageToAxes",k=i?"unlockImageFromAxes":"lockImageToAxes";j.push({title:h,isEnabled:true,target:this,action:k})}return j.concat([{title:("DG.DataDisplayMenu.copyAsImage"),isEnabled:true,target:this,action:"copyAsImage"},{title:("DG.DataDisplayMenu.exportPngImage"),isEnabled:true,target:this,action:"makePngImage"},{title:("DG.DataDisplayMenu.exportSvgImage"),isEnabled:true,target:this,action:"makeSvgImage"}])},createInspectorButtons:function(){var i=arguments.callee.base.apply(this,arguments),k=this;if(!this.get("dataDisplayModel").wantsInspector()){return i}i.push(DG.IconButton.create({layout:{width:32,left:0,height:25},classNames:"dg-display-rescale".w(),iconClass:"moonicon-icon-scaleData",iconExtent:{width:30,height:25},target:this,action:"rescaleFunction",toolTip:"DG.Inspector.rescale.toolTip",localize:true,init:function(){arguments.callee.base.apply(this,arguments);k.get("dataDisplayModel").addObserver("canRescale",this,"plotDidChange")},plotDidChange:function(){this.displayDidChange();this.set("isEnabled",k.getPath("dataDisplayModel.canRescale"));this.set("toolTip",k.getPath("dataDisplayModel.canMixUp")?"DG.Inspector.mixUp.toolTip":"DG.Inspector.rescale.toolTip")}}));var h=function(){var l=DG.MenuPane.create({classNames:"dg-display-hideshow-popup".w(),layout:{width:200,height:150}}),m=this.get("dataDisplayModel").createHideShowSelectionMenuItems();l.set("items",m);l.popup(j)}.bind(this);var j=DG.IconButton.create({layout:{width:32},classNames:"dg-display-hideshow".w(),iconClass:"moonicon-icon-hideShow",showBlip:true,target:this,action:h,toolTip:"DG.Inspector.hideShow.toolTip",localize:true});i.push(j);i.push(DG.IconButton.create({layout:{width:32},classNames:"dg-inspector-pane-button dg-display-values".w(),iconClass:this.kValuesPaneIconClass,showBlip:true,target:this,action:"showHideValuesPane",toolTip:"DG.Inspector.displayValues.toolTip",localize:true}));var g=DG.IconButton.create({layout:{width:32},classNames:"dg-inspector-pane-button dg-display-configuration".w(),iconClass:c,showBlip:true,target:this,action:"showHideConfigurationPane",toolTip:"DG.Inspector.displayConfiguration.toolTip",localize:true,init:function(){arguments.callee.base.apply(this,arguments);k.get("dataDisplayModel").addObserver("canSupportConfigurations",this,"plotDidChange");this.plotDidChange()},plotDidChange:function(){this.set("isVisible",k.getPath("dataDisplayModel.canSupportConfigurations"))}});i.push(g);var e=this.getPath("model.type")==="DG.MapView";i.push(DG.IconButton.create({layout:{width:32},classNames:"dg-inspector-pane-button dg-display-styles".w(),iconClass:e?"moonicon-icon-layers":"moonicon-icon-styles",showBlip:true,target:this,action:"showHideStylesPane",toolTip:e?"DG.Inspector.displayLayers.toolTip":"DG.Inspector.displayStyles.toolTip",localize:true}));var f;var d=function(){var l=DG.MenuPane.create({classNames:"dg-display-show-image-popup".w(),layout:{width:200,height:150}}),m=this.createImageExportMenuItems();l.set("items",m);l.popup(f)}.bind(this);if(this.makePngImage){f=DG.IconButton.create({layout:{width:32},iconExtent:{width:30,height:25},classNames:"dg-display-camera".w(),iconClass:"moonicon-icon-tileScreenshot",target:this,action:d,toolTip:"DG.Inspector.makeImage.toolTip",localize:true});i.push(f)}return i},showHideConfigurationPane:function(){var h=this,e=26,d=20,g=5,f=20;if(DG.InspectorPickerPane.close(c)){return}this.configurationPane=DG.InspectorPickerPane.create({buttonIconClass:c,classNames:"dg-inspector-picker".w(),layout:{width:200,height:260},contentView:SC.View.extend(SC.FlowedLayout,{layoutDirection:SC.LAYOUT_VERTICAL,isResizable:false,isClosable:false,defaultFlowSpacing:{left:d,bottom:g},canWrap:false,align:SC.ALIGN_TOP,layout:{right:22},childViews:"title".w(),title:DG.PickerTitleView.extend({layout:{height:e},flowSpacing:{left:0,bottom:g},title:"DG.Inspector.configuration",localize:true,iconURL:"../../../../static/dg/fr/cert/resources/images/icon-segmented-bar-chart.svg"}),init:function(){arguments.callee.base.apply(this,arguments);h.getPath("dataDisplayModel.configurationDescriptions").forEach(function(i){i.properties.layout=Object.assign({height:f},i.properties.layout);i.properties.localize=true;this.appendChild(i.constructorClass.create(i.properties))}.bind(this));h.getPath("dataDisplayModel.lastConfigurationControls").forEach(function(i){this.appendChild(i)}.bind(this))}})});this.configurationPane.popup(this.get("inspectorButtons")[3],SC.PICKER_POINTER)},showHideStylesPane:function(){var i=this,f=26,d=20,h=5,e=this.getPath("model.type")==="DG.MapView",g=this.get("inspectorButtons").find(function(j){return j.get("classNames").indexOf("dg-display-styles")>=0});if(DG.InspectorPickerPane.close(b)){return}this.stylesPane=DG.InspectorPickerPane.create({buttonIconClass:e?"moonicon-icon-layers":"moonicon-icon-styles",classNames:"dg-inspector-picker".w(),layout:{width:250,height:150},contentView:SC.View.extend(SC.FlowedLayout,{layoutDirection:SC.LAYOUT_VERTICAL,isResizable:false,isClosable:false,defaultFlowSpacing:{left:d,bottom:h},canWrap:false,align:SC.ALIGN_TOP,childViews:"title".w(),title:DG.PickerTitleView.extend({layout:{height:f},flowSpacing:{left:0,bottom:h},title:this.getPath("model.type")==="DG.MapView"?"DG.Inspector.layers":"DG.Inspector.styles",localize:true,iconURL:e?"../../../../static/dg/fr/cert/resources/images/icon-layers.svg":"../../../../static/dg/fr/cert/resources/images/icon-styles.svg"}),init:function(){arguments.callee.base.apply(this,arguments);i.get("styleControls").forEach(function(j){this.appendChild(j)}.bind(this))}})});this.stylesPane.popup(g,SC.PICKER_POINTER)},styleControls:function(){var m=this,z=this.getPath("dataDisplayModel.dataConfiguration"),k=z.get("legendAttributeDescription"),u=k.getPath("attribute.categoryMap"),h=null,B=function(F,G){h=h||Math.random();DG.UndoHistory.execute(DG.Command.create({name:"data.style.categoryColorChange",undoString:"DG.Undo.graph.changePointColor",redoString:"DG.Redo.graph.changePointColor",log:"Changed categorical point color",execute:function(){this.reduceKey=this.name+G+h;this._beforeStorage={color:u[G],alpha:m.getPath("dataDisplayModel.transparency")};u[G]=F.toHexString();m.setPath("dataDisplayModel.transparency",F.getAlpha());m.get("dataDisplayModel").propertyDidChange("pointColor");if(k.get("attribute")){k.get("attribute").propertyDidChange("categoryMap")}},undo:function(){u[G]=this._beforeStorage.color;m.setPath("dataDisplayModel.transparency",this._beforeStorage.alpha);m.get("dataDisplayModel").propertyDidChange("pointColor")},reduce:function(H){if(H.reduceKey===this.reduceKey){this._beforeStorage=H._beforeStorage;return this}}}))},C=function(){h=null},p=function(F,I,H,G){return DG.Command.create({name:"data.style."+F,undoString:"DG.Undo.graph."+F,redoString:"DG.Redo.graph."+F,log:"Changed point color",execute:function(){SC.run(function(){this.reduceKey=this.name+h;this._beforeStorage={color:m.getPath("dataDisplayModel."+I),alpha:m.getPath("dataDisplayModel."+H)};m.setPath("dataDisplayModel."+I,G.toHexString());m.setPath("dataDisplayModel."+H,G.getAlpha());if(k.get("attribute")){k.get("attribute").propertyDidChange("categoryMap")}}.bind(this))},undo:function(){m.setPath("dataDisplayModel."+I,this._beforeStorage.color);m.setPath("dataDisplayModel."+H,this._beforeStorage.alpha)},reduce:function(J){if(J.reduceKey===this.reduceKey){this._beforeStorage=J._beforeStorage;return this}}})},e=function(G,F,I,H){return DG.Command.create({name:"data.style."+G,undoString:"DG.Undo.graph."+G,redoString:"DG.Redo.graph."+G,log:"Changed"+F+" attribute color",execute:function(){this.reduceKey=this.name+h;this._beforeStorage={color:u[F+"-attribute-color"],alpha:m.getPath("dataDisplayModel."+I)};u[F+"-attribute-color"]=H.toHexString();m.setPath("dataDisplayModel."+I,H.getAlpha());m.get("dataDisplayModel").propertyDidChange("pointColor");if(k.get("attribute")){k.get("attribute").propertyDidChange("categoryMap")}},undo:function(){u["attribute-color"]=this._beforeStorage.color;m.setPath("dataDisplayModel."+I,this._beforeStorage.alpha)},reduce:function(J){if(J.reduceKey===this.reduceKey){this._beforeStorage=J._beforeStorage;return this}}})},i=function(F){h=h||Math.random();DG.UndoHistory.execute(p("changePointColor","pointColor","transparency",F))},r=function(F){h=h||Math.random();DG.UndoHistory.execute(e("changeAttributeColor","low","transparency",F))},y=function(F){h=h||Math.random();DG.UndoHistory.execute(e("changeAttributeColor","high","transparency",F))},n=function(){h=null},f=function(F){h=h||Math.random();DG.UndoHistory.execute(p("changeStrokeColor","strokeColor","strokeTransparency",F))},j=function(){h=null},v=function(){return m.stylesPane.layer()},E=20,A=[DG.PickerControlView.create({layout:{height:E},label:"DG.Inspector.pointSize",controlView:SC.SliderView.create({layout:{width:120},classNames:"dg-graph-pointSize-slider".w(),controlSize:SC.SMALL_CONTROL_SIZE,value:this.getPath("dataDisplayModel.pointSizeMultiplier"),minimum:0,maximum:3,step:0,valueChanged:function(){var F=this;DG.UndoHistory.execute(DG.Command.create({name:"data.style.pointSizeChanged",undoString:"DG.Undo.graph.changePointSize",redoString:"DG.Redo.graph.changePointSize",log:"Changed point size",execute:function(){this._beforeStorage=m.getPath("dataDisplayModel.pointSizeMultiplier");m.setPath("dataDisplayModel.pointSizeMultiplier",F.get("value"))},undo:function(){m.setPath("dataDisplayModel.pointSizeMultiplier",this._beforeStorage)},reduce:function(G){if(G.name===this.name){this._beforeStorage=G._beforeStorage;return this}}}))}.observes("value")})})];if(k.get("isNull")){var D=tinycolor(this.getPath("dataDisplayModel.pointColor")).setAlpha(this.getPath("dataDisplayModel.transparency"));A.push(DG.PickerControlView.create({layout:{height:2*E},label:"DG.Inspector.color",controlView:DG.PickerColorControl.create({layout:{width:120},classNames:"dg-graph-point-color".w(),initialColor:D,setColorFunc:i,closedFunc:n,appendToLayerFunc:v})}))}else{if(k.get("isNumeric")){if(u&&SC.none(u["attribute-color"])){var l=DG.ColorUtilities.calcAttributeColor(k);u["attribute-color"]=l.colorString||l}var g=u&&u["attribute-color"],s=SC.View.create(SC.FlowedLayout,{layoutDirection:SC.LAYOUT_HORIZONTAL,layout:{width:120},isResizable:false,isClosable:false,canWrap:false,align:SC.ALIGN_TOP}),o=DG.ColorUtilities.getAttributeColorSpectrumEndsFromColorMap(u,g),q=tinycolor(o.low.colorString).setAlpha(this.getPath("dataDisplayModel.transparency")),d=tinycolor(o.high.colorString).setAlpha(this.getPath("dataDisplayModel.transparency"));s.appendChild(DG.PickerColorControl.create({layout:{width:60},classNames:"dg-graph-point-color".w(),initialColor:q,setColorFunc:r,closedFunc:n,appendToLayerFunc:v}));s.appendChild(DG.PickerColorControl.create({layout:{width:60},classNames:"dg-graph-point-color".w(),initialColor:d,setColorFunc:y,closedFunc:n,appendToLayerFunc:v}));A.push(DG.PickerControlView.create({layout:{height:2*E},label:"DG.Inspector.legendColor",controlView:s}));A.push(SC.CheckboxView.create({layout:{height:25},title:"DG.Inspector.lockLegendQuantiles",toolTip:"DG.Inspector.lockLegendQuantilesTooltip",value:z.get("legendQuantilesAreLocked"),classNames:"dg-graph-lockLegendQuantiles-check".w(),localize:true,valueDidChange:function(){var F=!z.get("legendQuantilesAreLocked"),G="Set quantilesAreLocked to "+F;DG.UndoHistory.execute(DG.Command.create({name:"legend.quantilesAreLockedChange",undoString:F?"DG.Undo.legend.lockQuantiles":"DG.Undo.legend.unlockQuantiles",redoString:F?"DG.Redo.legend.lockQuantiles":"DG.Redo.legend.unlockQuantiles",log:G,execute:function(){z.toggleProperty("legendQuantilesAreLocked")}.bind(this),undo:function(){z.toggleProperty("legendQuantilesAreLocked")}.bind(this)}))}.bind(this).observes("value")}))}}A.push(DG.PickerControlView.create({layout:{height:2*E},label:"DG.Inspector.stroke",controlView:DG.PickerColorControl.create({layout:{width:120},classNames:"dg-graph-stroke-color".w(),initialColor:tinycolor(this.getPath("dataDisplayModel.strokeColor")).setAlpha(this.getPath("dataDisplayModel.strokeTransparency")),setColorFunc:f,closedFunc:j,appendToLayerFunc:v})}));A.push(SC.CheckboxView.create({layout:{height:25},title:"DG.Inspector.strokeSameAsFill",value:this.getPath("dataDisplayModel.strokeSameAsFill"),classNames:"dg-graph-strokeSameAsFill-check".w(),localize:true,valueDidChange:function(){var F=!this.getPath("dataDisplayModel.strokeSameAsFill"),G="Made stroke color "+(F?"same as fill":"independent of fill");DG.UndoHistory.execute(DG.Command.create({name:"plot.strokeSameAsFillChange",undoString:F?"DG.Undo.graph.makeStrokeSameAsFill":"DG.Undo.graph.makeStrokeIndependent",redoString:F?"DG.Redo.graph.makeStrokeSameAsFill":"DG.Redo.graph.makeStrokeIndependent",log:G,execute:function(){this.get("dataDisplayModel").toggleProperty("strokeSameAsFill")}.bind(this),undo:function(){this.get("dataDisplayModel").toggleProperty("strokeSameAsFill")}.bind(this)}))}.bind(this).observes("value")}));if(k.get("isCategorical")){var w=SC.View.create(SC.FlowedLayout,{layoutDirection:SC.LAYOUT_VERTICAL,isResizable:false,isClosable:false,defaultFlowSpacing:{bottom:5},canWrap:false,align:SC.ALIGN_TOP}),x=SC.ScrollView.create({layout:{height:100},hasHorizontalScroller:false,contentView:w}),t=k.get("attribute");t.forEachCategory(function(F){var H=DG.ColorUtilities.calcCaseColor(F,k),G=u[F]?u[F]:H.colorString||H;G=tinycolor(G.colorString||G).setAlpha(this.getPath("dataDisplayModel.transparency"));w.appendChild(DG.PickerControlView.create({layout:{height:2*E},label:F,controlView:DG.PickerColorControl.create({layout:{width:120},classNames:"dg-graph-point-color".w(),initialColor:G,colorKey:F,setColorFunc:B,closedFunc:C,appendToLayerFunc:v})}))}.bind(this));A.push(x)}return A}.property(),addAxisHandler:function(d){var f=this,e=d.get("labelNodes");if(SC.isArray(e)){e.forEach(function(i,h){function g(j){SC.run(function(){f.setupAttributeMenu(j,d,h)});j.preventDefault();j.stopImmediatePropagation()}i.unmousedown(g);i.mousedown(g)})}},axisViewChanged:function(e,f){var g=this,d=this.get(f);if(!SC.none(d)){this.addAxisHandler(d);d.addObserver("labelNode",this,function(){g.addAxisHandler(d)})}}.observes("xAxisView","yAxisView","y2AxisView","legendView","topAxisView","rightAxisView"),setupAttributeMenu:function(e,f,m){var p=this.get("dataDisplayModel"),i={left:e.layerX,top:e.layerY,height:20,width:20},k=SC.View.create({layout:i,backgroundColor:"transparent"}),h=f.get("orientation"),l=(h===DG.GraphTypes.EOrientation.kHorizontal)?[0,2,1,3,0]:[0,1,3,2,0],o="",n,g=DG.MenuPane.create({});var d=f.menuChangeHandler?f.menuChangeHandler.bind(f):this.attributeMenuItemChanged;g.addObserver("selectedItem",this,d);f.appendChild(k);if(f.instanceOf(DG.LegendView)){o="legend"}else{switch(h){case DG.GraphTypes.EOrientation.kHorizontal:o="x";break;case DG.GraphTypes.EOrientation.kVertical:o="y";break;case DG.GraphTypes.EOrientation.kVertical2:o="y2";break;default:o=h}}n=f.getMenuItems?f.getMenuItems():this.getAttributeMenuItems();n.push({isSeparator:YES});var j=false;n.push(p.createRemoveAttributeMenuItem(f,o,j,m));if(o!=="y2"){n.push(p.createChangeAttributeTypeMenuItem(f,o))}g.set("items",n);g.selectedAxis=h;g.isLegend=f.instanceOf(DG.LegendView);SC.run(function(){g.popup(k,l)}.bind(this));f.removeChild(k)},getAttributeMenuItems:function(){var e=[],d=DG.currDocumentController().get("contexts");d.forEach(function(f){f.forEachCollection(function(i){var g=i.get("name"),h=i.getVisibleAttributeNames();e.push({title:g,subMenu:h.map(function(j){return{title:j,collection:i,context:f}})})})});if(e.length===1){return e[0].subMenu}else{return e}},attributeMenuItemChanged:function(h){var f=h.get("selectedItem"),d=f&&f.collection,g=h.selectedAxis,e=h.isLegend;h.removeObserver("selectedItem",this,this.attributeMenuItemChanged);DG.UndoHistory.execute(DG.Command.create({name:"axis.attributeChange",undoString:"DG.Undo.axisAttributeChange",redoString:"DG.Redo.axisAttributeChange",executeNotification:{action:"notify",resource:"component",values:{operation:"attributeChange",type:"DG.GraphView",id:this.getPath("model.id"),attributeName:f.get("title"),axisOrientation:g}},_beforeStorage:null,_afterStorage:null,_componentId:this.getPath("model.id"),_controller:function(){return DG.currDocumentController().componentControllersMap[this._componentId]},execute:function(){var k=this._controller();this._beforeStorage=k.createComponentStorage();var j,l=k.get("dataDisplayModel"),m=f&&f.context;k.handlePossibleForeignDataContext&&k.handlePossibleForeignDataContext(m);if(!f){this.set("causedChange",false);return}if(d){var i=d.attrsController.get("content").find(function(n){return n.name===f.title});j={collection:d,attributes:[i]};if(e){f.log="legendAttributeChange: { to attribute %@ }".fmt(j.attributes[0].get("name"));l.changeAttributeForLegend(m,j)}else{f.log="plotAxisAttributeChange: { orientation: %@, attribute: %@ }".fmt(g,j.attributes[0].get("name"));l.changeAttributeForAxis(m,j,g)}}else{if(f.target===l){f.itemAction.apply(f.target,f.args)}}k.setComponentTitleByChildmostCollection();this.log=f.log||"Axis attribute menu item selected: %@".fmt(f.title)},undo:function(){var i=this._controller();this._afterStorage=i.createComponentStorage();i.restoreComponentStorage(this._beforeStorage);i.setComponentTitleByChildmostCollection()},redo:function(){this._controller().restoreComponentStorage(this._afterStorage);this._afterStorage=null;this._controller().setComponentTitleByChildmostCollection()}}))},plotOrLegendViewDidAcceptDrop:function(e,g,f){if(SC.none(f)){return}var d=this;DG.UndoHistory.execute(DG.Command.create({name:"axis.attributeChange",undoString:"DG.Undo.axisAttributeChange",redoString:"DG.Redo.axisAttributeChange",_beforeStorage:null,_afterStorage:null,_componentId:this.getPath("model.id"),executeNotification:{action:"notify",resource:"component",values:{operation:"legendAttributeChange",type:this.get("dataDisplayModel").constructor.toString(),id:this.getPath("model.id"),attributeName:f.attribute.get("name")}},execute:function(){this._beforeStorage=d.createComponentStorage();var i=f.context,h=a(i,f),j=d.get("dataDisplayModel");j.handleDroppedContext(i);d.set("dataContext",i);e.dragData=null;j.changeAttributeForLegend(i,{collection:h,attributes:[f.attribute]});d.get("view").select();d.setComponentTitleByChildmostCollection();this.log="legendAttributeChange: { to attribute %@ }".fmt(f.attribute.get("name"))},undo:function(){this._afterStorage=d.createComponentStorage();d.restoreComponentStorage(this._beforeStorage);d.setComponentTitleByChildmostCollection()},redo:function(){d.restoreComponentStorage(this._afterStorage);this._afterStorage=null;d.setComponentTitleByChildmostCollection()}}))},convertToImage:function(h,g,f,d,i){function e(l,m,k){var j=new FileReader();j.addEventListener("loadend",function(){var n=j.result.split(",").pop();DG.exportFile(n,m,k)});j.readAsDataURL(l)}if(h==="png"){DG.ImageUtilities.captureSVGElementsToImage(g,f,d,i).then(function(j){e(j,"png","image/png")},function(j){DG.log(j)})}else{if(h==="svg"){DG.exportFile(DG.ImageUtilities.captureGraphToSVG(g,f,d,i),"svg","text/plain")}}},openDrawToolWithImage:function(f,e,d,g){DG.ImageUtilities.captureSVGElementsToImage(f,e,d,g,true).then(function(h){SC.run(function(){DG.appController.importDrawToolWithDataURL(h,g)})},function(h){DG.log(h)})},makePngImage:function(){var h=this.get("view");var e=h&&h.get("contentView");var f=e.getPath("frame.width");var d=e.getPath("frame.height");var g=h.get("title");this.convertToImage("png",e.get("layer"),f,d,g)},makeSvgImage:function(){var h=this.get("view");var e=h&&h.get("contentView");var f=e.getPath("frame.width");var d=e.getPath("frame.height");var g=h.get("title");this.convertToImage("svg",e.get("layer"),f,d,g)},copyAsImage:function(){var i=this.get("view"),h=(i&&i.get("title"))||"DG.DocumentController.graphTitle".loc(),e=i&&i.get("contentView"),f=e&&e.get("layer"),g=e&&e.getPath("frame.width"),d=e&&e.getPath("frame.height");if(e){this.openDrawToolWithImage(f,g,d,h)}}}}()));sc_require("components/graph_map_common/data_display_controller");DG.GraphController=DG.DataDisplayController.extend((function(){function a(d,b){var c=b.collection&&b.collection.get("id");return d&&!SC.none(c)&&d.getCollectionByID(c)}return{graphModel:function(){return this.get("dataDisplayModel")}.property("dataDisplayModel"),xAxisView:null,yAxisView:null,bottomAxisLabelView:null,leftAxisLabelView:null,y2AxisView:null,plotView:null,axisMultiTarget:null,topAxisView:null,rightAxisView:null,createComponentStorage:function(){var g={_links_:{}},b=this.get("dataContext"),e=this.getPath("dataDisplayModel.dataConfiguration"),f=e&&e.get("hiddenCases");if(b){g._links_.context=b.toLink()}g.displayOnlySelected=e.get("displayOnlySelected");e.addToStorageForDimension(g,"legend");e.addLegendQuantilesToStorage(g);if(f){g._links_.hiddenCases=f.filter(function(h){return !!h}).map(function(h){return h.toLink()})}g.pointColor=this.getPath("dataDisplayModel.pointColor");g.strokeColor=this.getPath("dataDisplayModel.strokeColor");g.pointSizeMultiplier=this.getPath("dataDisplayModel.pointSizeMultiplier");g.transparency=this.getPath("dataDisplayModel.transparency");g.strokeTransparency=this.getPath("dataDisplayModel.strokeTransparency");g.strokeSameAsFill=this.getPath("dataDisplayModel.strokeSameAsFill");var c=this.getPath("graphModel.plots");var d=function(i){var h=this.getPath("graphModel."+i+"Axis");if(h){g[i+"AxisClass"]=String(h.constructor)}if(h&&h.get("isNumeric")){g[i+"LowerBound"]=h.get("lowerBound");g[i+"UpperBound"]=h.get("upperBound")}}.bind(this);g.isTransparent=this.getPath("graphModel.isTransparent");g.plotBackgroundColor=this.getPath("graphModel.plotBackgroundColor");g.plotBackgroundOpacity=this.getPath("graphModel.plotBackgroundOpacity");g.plotBackgroundImage=this.getPath("graphModel.plotBackgroundImage");g.plotBackgroundImageLockInfo=this.getPath("graphModel.plotBackgroundImageLockInfo");g.enableNumberToggle=this.getPath("graphModel.enableNumberToggle");if(g.enableNumberToggle){g.numberToggleLastMode=this.getPath("graphModel.numberToggle.lastMode")}g.enableMeasuresForSelection=this.getPath("graphModel.enableMeasuresForSelection");e.addToStorageForDimension(g,"x");e.addToStorageForDimension(g,"y");e.addToStorageForDimension(g,"y2");e.addToStorageForDimension(g,"top");e.addToStorageForDimension(g,"right");d("x");d("y");d("y2");d("top");d("right");if(c){g.plotModels=[];c.forEach(function(h){g.plotModels.push({plotModelStorage:h.createStorage(),plotClass:String(h.constructor)})})}return g},restoreComponentStorage:function(b,d){var c=this.get("dataDisplayModel");arguments.callee.base.apply(this,arguments);if(SC.none(b._links_)){return}c.restoreStorage(b);c.stopAnimation();c.updateAxisArrays();c.updateSplitPlotArray();["x","y","y2"].forEach(function(e){var f=c.get(e+"Axis");if(f&&f.get("isNumeric")&&isFinite(b[e+"LowerBound"])&&isFinite(b[e+"UpperBound"])){f.setLowerAndUpperBounds(b[e+"LowerBound"],b[e+"UpperBound"])}})},graphView:function(){return this.getPath("view.containerView.contentView")}.property("view"),viewDidChange:function(){this.notifyPropertyChange("graphView");var b=this.get("graphView");if(b){this.set("xAxisView",b.get("xAxisView"));this.set("yAxisView",b.get("yAxisView"));this.set("bottomAxisLabelView",b.get("bottomAxisLabelView"));this.set("leftAxisLabelView",b.get("leftAxisLabelView"));this.set("y2AxisView",b.get("y2AxisView"));this.set("plotView",b.get("plotBackgroundView"));this.set("legendView",b.get("legendView"));this.set("axisMultiTarget",b.get("yAxisMultiTarget"));this.set("topAxisView",b.get("topAxisView"));this.set("rightAxisView",b.get("rightAxisView"));b.set("controller",this);b.addObserver("plotViewsReconfigured",this,this.addPlotViewObservers);b.addObserver("plotViewsWillBeDestroyed",this,this.removePlotViewObservers);this.addPlotViewObservers()}}.observes("*view.containerView.contentView"),addPlotViewObservers:function(){var b=this;this.getPath("graphView.plotBackgroundViewArray").forEach(function(c,d){c.forEach(function(f,e){if((d!==0||e!==0)&&f){f.addObserver("dragData",b,b.plotOrLegendViewDidAcceptDrop)}})});this.getPath("graphView.xAxisViewArray").concat(this.getPath("graphView.yAxisViewArray")).forEach(function(c,d){if(c&&!c.hasObserverFor("dragData",b,b.axisViewDidAcceptDrop)){c.addObserver("dragData",b,b.axisViewDidAcceptDrop)}})},removePlotViewObservers:function(){var b=this;this.get("graphView").get("plotBackgroundViewArray").forEach(function(c,d){c.forEach(function(f,e){if((d!==0||e!==0)&&f){f.removeObserver("dragData",b,b.plotOrLegendViewDidAcceptDrop)}})});this.getPath("graphView.xAxisViewArray").concat(this.getPath("graphView.yAxisViewArray")).forEach(function(c,d){if(c){c.removeObserver("dragData",b,b.axisViewDidAcceptDrop)}})},showHideValuesPane:function(){var f=this,c=26,b=20,e=5,d=20;if(DG.InspectorPickerPane.close(this.kValuesPaneIconClass)){return}this.valuesPane=DG.InspectorPickerPane.create({buttonIconClass:this.kValuesPaneIconClass,classNames:"dg-inspector-picker".w(),layout:{width:200,height:260},contentView:SC.View.extend(SC.FlowedLayout,{layoutDirection:SC.LAYOUT_VERTICAL,isResizable:false,isClosable:false,defaultFlowSpacing:{left:b,bottom:e},canWrap:false,align:SC.ALIGN_TOP,layout:{right:22},childViews:"title showLabel".w(),title:DG.PickerTitleView.extend({layout:{height:c},flowSpacing:{left:0,bottom:e},title:"DG.Inspector.values",localize:true,iconURL:"../../../../static/dg/fr/cert/resources/images/icon-values.svg"}),showLabel:SC.LabelView.extend({layout:{height:d},value:"DG.Inspector.displayShow",localize:true}),init:function(){arguments.callee.base.apply(this,arguments);f.getPath("dataDisplayModel.checkboxDescriptions").forEach(function(g){if(g.control){this.appendChild(g.control);if(g.control.instanceOf(SC.ButtonView)&&g.action){g.control.set("action",function(){f.get(g.action)(f.get("dataDisplayModel"),f.get("inspectorButtons")[2])})}}else{g.layout={height:d};g.localize=true;this.appendChild(SC.CheckboxView.create(g))}}.bind(this));f.getPath("dataDisplayModel.lastValueControls").forEach(function(g){this.appendChild(g)}.bind(this))}})});this.valuesPane.popup(this.get("inspectorButtons")[2],SC.PICKER_POINTER)},showHideSpreadsSubPane:function(c,e){var b=20,g=5,f=20,h=DG.get("inspectorPicker");var d=DG.InspectorPickerPane.create({classNames:"dg-inspector-picker ".w(),layout:{width:200,height:260},contentView:SC.View.extend(SC.FlowedLayout,{layoutDirection:SC.LAYOUT_VERTICAL,isResizable:false,isClosable:false,defaultFlowSpacing:{left:b,bottom:g},canWrap:false,align:SC.ALIGN_TOP,layout:{right:22},childViews:"close".w(),close:SC.ButtonView.extend({classNames:"dg-inspector-back".w(),layout:{top:3,height:f+3,width:50},flowSpacing:{top:3,left:b/2,bottom:g},title:"←",action:function(){d.remove();d.destroy()}}),init:function(){arguments.callee.base.apply(this,arguments);c.get("spreadCheckboxDescriptions").forEach(function(i){if(i.control){this.appendChild(i.control)}else{i.layout={height:f};i.localize=true;this.appendChild(SC.CheckboxView.create(i))}}.bind(this))}})});DG.set("inspectorPicker",h);DG.setPath("inspectorPicker.subPane",d);d.popup(e,SC.PICKER_POINTER)}.bind(this),addBackgroundImage:function(){function e(){console.log("Abort or error on file read.")}function d(){var f=this.result;DG.UndoHistory.execute(DG.Command.create({name:"graph.addBackgroundImage",undoString:"DG.Undo.graph.addBackgroundImage",redoString:"DG.Redo.graph.addBackgroundImage",_backgroundImage:null,executeNotification:{action:"notify",resource:"component",values:{operation:"backgroundImage",type:"DG.GraphView"}},execute:function(){b.set("plotBackgroundImage",f)},undo:function(){this._backgroundImage=b.get("plotBackgroundImage");b.set("plotBackgroundImage",null)},redo:function(){b.set("plotBackgroundImage",this._backgroundImage)}}))}function c(f){if(f){var g=new FileReader();g.onabort=e;g.onerror=e;g.onload=d;g.readAsDataURL(f.file.object)}}var b=this.get("graphModel");return DG.cfmClient._ui.importDataDialog((function(f){return function(g){return c(g)}})(this))},removeBackgroundImage:function(){var b=this.get("graphModel");DG.UndoHistory.execute(DG.Command.create({name:"graph.removeBackgroundImage",undoString:"DG.Undo.graph.removeBackgroundImage",redoString:"DG.Redo.graph.removeBackgroundImage",_backgroundImage:null,executeNotification:{action:"notify",resource:"component",values:{operation:"backgroundImage",type:"DG.GraphView"}},execute:function(){this._backgroundImage=b.get("plotBackgroundImage");b.set("plotBackgroundImage",null)},undo:function(){b.set("plotBackgroundImage",this._backgroundImage)},redo:function(){b.set("plotBackgroundImage",null)}}))},lockImageToAxes:function(){var b=this.get("graphModel"),c={locked:true,xAxisLowerBound:b.getPath("xAxis.lowerBound"),xAxisUpperBound:b.getPath("xAxis.upperBound"),yAxisLowerBound:b.getPath("yAxis.lowerBound"),yAxisUpperBound:b.getPath("yAxis.upperBound")};DG.UndoHistory.execute(DG.Command.create({name:"graph.lockBackgroundImage",undoString:"DG.Undo.graph.lockBackgroundImage",redoString:"DG.Redo.graph.lockBackgroundImage",_backgroundImage:null,executeNotification:{action:"notify",resource:"component",values:{operation:"lockBackgroundImage",type:"DG.GraphView"}},execute:function(){b.set("plotBackgroundImageLockInfo",c)},undo:function(){b.set("plotBackgroundImageLockInfo",null)},redo:function(){b.set("plotBackgroundImageLockInfo",c)}}))},unlockImageFromAxes:function(){var b=this.get("graphModel"),c=b.get("plotBackgroundImageLockInfo");DG.UndoHistory.execute(DG.Command.create({name:"graph.unlockBackgroundImage",undoString:"DG.Undo.graph.unlockBackgroundImage",redoString:"DG.Redo.graph.unlockBackgroundImage",_backgroundImage:null,executeNotification:{action:"notify",resource:"component",values:{operation:"unlockBackgroundImage",type:"DG.GraphView"}},execute:function(){b.set("plotBackgroundImageLockInfo",null)},undo:function(){b.set("plotBackgroundImageLockInfo",c)}}))},plotFunction:function(){this.graphModel.get("plot").togglePlotFunction()},rescaleFunction:function(){var b=this.get("graphModel"),c=b.get("plot");if(c&&c.mixUp){b.mixUp()}else{if(b.get("hasNumericAxis")){b.rescaleAxesFromData(true,true,true,true)}}},handlePossibleForeignDataContext:function(d){var b=d,c=this.get("dataContext");if(b&&(b!==c)){if(c){this.get("graphModel").reset()}this.set("dataContext",b);var e=this.getPath("graphModel.dataConfiguration");e.set("dataContext",b);e.invalidateCaches()}},axisViewDidAcceptDrop:function(d,c,b){b=b||d.dragData;if(SC.none(b)){return}DG.UndoHistory.execute(DG.Command.create({name:"axis.attributeChange",undoString:"DG.Undo.axisAttributeChange",redoString:"DG.Redo.axisAttributeChange",executeNotification:{action:"notify",resource:"component",values:{operation:"attributeChange",type:"DG.GraphView",id:this.getPath("model.id"),attributeName:b.attribute.get("name"),axisOrientation:d.get("orientation")}},_beforeStorage:null,_afterStorage:null,_componentId:this.getPath("model.id"),_controller:function(){return DG.currDocumentController().componentControllersMap[this._componentId]},execute:function(){var h=this._controller();this._beforeStorage=h.createComponentStorage();h.handlePossibleForeignDataContext(b.context);var j=h.get("dataContext"),f=a(j,b),e=d.get("orientation"),i=h.get("graphModel"),g={collection:f,attributes:[b.attribute]};d.dragData=null;i.changeAttributeForAxis(j,g,e);this.log="plotAxisAttributeChange: "+'{ "orientation": "%@", "attribute": "%@" }'.fmt(d.get("orientation"),b.attribute.get("name"));h.get("view").select();h.setComponentTitleByChildmostCollection()},undo:function(){var e=this._controller();this._afterStorage=e.createComponentStorage();e.restoreComponentStorage(this._beforeStorage);e.setComponentTitleByChildmostCollection()},redo:function(){this._controller().restoreComponentStorage(this._afterStorage);this._controller().setComponentTitleByChildmostCollection();this._afterStorage=null}}))}.observes("*xAxisView.dragData","*yAxisView.dragData","*bottomAxisLabelView.dragData","*leftAxisLabelView.dragData","*rightAxisView.dragData","*topAxisView.dragData"),multiTargetDidAcceptDrop:function(d,c,b){if(SC.none(b)){return}DG.UndoHistory.execute(DG.Command.create({name:"axis.attributeChangeMultiTarget",undoString:"DG.Undo.axisAttributeAdded",redoString:"DG.Redo.axisAttributeAdded",_beforeStorage:null,_afterStorage:null,_componentId:this.getPath("model.id"),_controller:function(){return DG.currDocumentController().componentControllersMap[this._componentId]},executeNotification:{action:"notify",resource:"component",values:{operation:"add axis attribute",type:"DG.GraphView"}},execute:function(){var g=this._controller(),j=g.getPath("graphModel.dataConfiguration");this._beforeStorage=g.createComponentStorage();g.handlePossibleForeignDataContext(b.context);var i=g.get("dataContext"),e=a(i,b),h=g.get("graphModel"),f={collection:e,attributes:[b.attribute]};d.dragData=null;if(j.attributeIsNominal(b.attribute)){h.splitByAttribute(i,f,"top");this.log="Graph split vertically attribute %@".fmt(b.attribute.get("name"))}else{h.addAttributeToAxis(i,f);this.log="Attribute dragged and dropped: %@, %@".fmt("vertical",b.attribute.get("name"))}g.get("view").select()},undo:function(){var e=this._controller();this._afterStorage=e.createComponentStorage();e.restoreComponentStorage(this._beforeStorage);e.get("graphModel").notifyPropertyChange("attributeRemoved")},redo:function(){this._controller().restoreComponentStorage(this._afterStorage);this._afterStorage=null;this._controller().get("graphModel").notifyPropertyChange("attributeAdded")}}))}.observes("*axisMultiTarget.dragData"),y2AxisDidAcceptDrop:function(d,c,b){if(SC.none(b)){return}DG.UndoHistory.execute(DG.Command.create({name:"axis.attributeChangeY2",undoString:"DG.Undo.axisAttributeChangeY2",redoString:"DG.Redo.axisAttributeChangeY2",_beforeStorage:null,_afterStorage:null,_componentId:this.getPath("model.id"),_controller:function(){return DG.currDocumentController().componentControllersMap[this._componentId]},executeNotification:{action:"notify",resource:"component",values:{operation:"add 2nd axis attribute",type:"DG.GraphView"}},execute:function(){var h=this._controller(),k=h.getPath("graphModel.dataConfiguration");this._beforeStorage=h.createComponentStorage();var j=h.get("dataContext"),f=a(j,b),e=d.get("orientation"),i=h.get("graphModel"),g={collection:f,attributes:[b.attribute]};d.dragData=null;if(k.attributeIsNominal(b.attribute)){i.splitByAttribute(j,g,"right")}else{i.changeAttributeForY2Axis(j,g,e)}h.get("view").select();this.log="changeAttributeOnSecondYAxis: { attribute: %@ }".fmt(b.attribute.get("name"))},undo:function(){var e=this._controller();this._afterStorage=e.createComponentStorage();e.restoreComponentStorage(this._beforeStorage);e.get("graphModel").notifyPropertyChange("attributeRemoved")},redo:function(){this._controller().restoreComponentStorage(this._afterStorage);this._afterStorage=null;this._controller().get("graphModel").notifyPropertyChange("y2AttributeAdded")}}))}.observes("*y2AxisView.dragData"),plotOrLegendViewDidAcceptDrop:function(b,e,d){var c=this.getPath("graphModel.dataConfiguration");d=d||b.get("dragData");if(!c.get("xAttributeID")&&!c.get("yAttributeID")&&!c.get("legendAttributeID")){b.dragData=null;this.axisViewDidAcceptDrop(this.get("xAxisView"),e,d)}else{arguments.callee.base.apply(this,arguments)}}.observes("*plotView.dragData","*legendView.dragData"),styleControls:function(){var d=arguments.callee.base.apply(this,arguments);var c=20,g=this,j=null,b=tinycolor(this.getPath("graphModel.plotBackgroundColor")||"white"),f=this.getPath("graphModel.plotBackgroundOpacity");f=SC.none(f)?1:f;var i=b.setAlpha(f),l=function(){return this.stylesPane.layer()}.bind(this),h=function(m,p,o,n){return DG.Command.create({name:"data.style."+m,undoString:"DG.Undo.graph."+m,redoString:"DG.Redo.graph."+m,log:"Changed background color",executeNotification:{action:"notify",resource:"component",values:{operation:"change background color",type:"DG.GraphView"}},execute:function(){this.reduceKey=this.name+j;this._beforeStorage={color:g.getPath("graphModel."+p),alpha:g.getPath("graphModel."+o)};g.setPath("graphModel."+p,n.toHexString());g.setPath("graphModel."+o,n.getAlpha())},undo:function(){g.setPath("graphModel."+p,this._beforeStorage.color);g.setPath("graphModel."+o,this._beforeStorage.alpha)},reduce:function(q){if(q.reduceKey===this.reduceKey){this._beforeStorage=q._beforeStorage;return this}}})},k=function(m){j=j||Math.random();DG.UndoHistory.execute(h("changeBackgroundColor","plotBackgroundColor","plotBackgroundOpacity",m))},e=function(){j=null};d.push(DG.PickerControlView.create({layout:{height:2*c},label:"DG.Inspector.backgroundColor",controlView:DG.PickerColorControl.create({layout:{width:120},classNames:"dg-graph-point-color".w(),initialColor:i,setColorFunc:k,closedFunc:e,appendToLayerFunc:l})}));d.push(SC.CheckboxView.create({layout:{height:25},title:"DG.Inspector.graphTransparency",value:this.getPath("graphModel.isTransparent"),classNames:"dg-graph-transparent-check".w(),localize:true,valueDidChange:function(){var m=!this.getPath("graphModel.isTransparent"),n="Made plot background "+(m?"transparent":"opaque");DG.UndoHistory.execute(DG.Command.create({name:"plot.transparencyChange",undoString:"DG.Undo.graph.toggleTransparent",redoString:"DG.Redo.graph.toggleTransparent",log:n,executeNotification:{action:"notify",resource:"component",values:{operation:"toggle background transparency",type:"DG.GraphView"}},execute:function(){this.get("graphModel").toggleProperty("isTransparent")}.bind(this),undo:function(){this.get("graphModel").toggleProperty("isTransparent")}.bind(this)}))}.bind(this).observes("value")}));return d}.property()}}()));sc_require("alpha/destroyable");sc_require("components/graph/utilities/plot_utilities");DG.DataLayerModel=SC.Object.extend(DG.Destroyable,{autoDestroyProperties:["legend"],componentID:null,legend:null,dataConfiguration:null,defaultTitle:function(){return this.getPath("dataConfiguration.defaultTitle")}.property(),defaultTitleChanged:function(){this.notifyPropertyChange("defaultTitle")}.observes("*dataConfiguration.defaultTitle"),collectionClient:null,collectionClientBinding:"*dataConfiguration.collectionClient",casesController:null,casesControllerBinding:"*dataConfiguration.collectionClient.casesController",cases:function(){return this.getPath("dataConfiguration.cases")}.property(),casesDidChange:function(){this.notifyPropertyChange("cases")}.observes("*dataConfiguration.cases"),selection:function(){return this.getPath("dataConfiguration.selection")}.property(),selectionDidChange:function(){this.notifyPropertyChange("selection")}.observes("*dataConfiguration.selection"),_oldNumberOfCases:0,pointColor:DG.PlotUtilities.kDefaultPointColor,getPointColor:function(){return this.get("pointColor")},_strokeColor:null,_strokeTransparency:null,strokeColor:function(c,f){var b=this.hasLegendVar()&&this.getPath("dataConfiguration.legendAttributeDescription.attribute"),a=b&&b.get("categoryMap");if(f!==undefined){this._strokeColor=f;if(a){a["stroke-color"]=f}}var d=DG.ColorUtilities.getStrokeColorFromColorMap(a),e=d||this._strokeColor||(b?DG.PlotUtilities.kDefaultStrokeColorWithLegend:DG.PlotUtilities.kDefaultStrokeColor);return e}.property(),strokeTransparency:function(c,f){var b=this.hasLegendVar()&&this.getPath("dataConfiguration.legendAttributeDescription.attribute"),a=b&&b.get("categoryMap");if(f!==undefined){this._strokeTransparency=f;if(a){a["stroke-transparency"]=f}}var e=a?a["stroke-transparency"]:null,d;if(!SC.none(e)){d=e}else{if(!SC.none(this._strokeTransparency)){d=this._strokeTransparency}else{d=b?DG.PlotUtilities.kDefaultStrokeOpacityWithLegend:DG.PlotUtilities.kDefaultStrokeOpacity}}return d}.property(),strokeSameAsFill:false,hasLegendVar:function(){return !SC.none(this.getPath("dataConfiguration.legendAttributeDescription.attributeID"))},pointSizeMultiplier:1,getPointSizeMultiplier:function(){return this.get("pointSizeMultiplier")},transparency:DG.PlotUtilities.kDefaultPointOpacity,init:function(){arguments.callee.base.apply(this,arguments)},destroy:function(){if(this.get("dataContext")){this.get("dataContext").removeObserver("changeCount",this,"handleDataContextNotification")}arguments.callee.base.apply(this,arguments);this.destroyProperty("dataConfiguration")},reset:function(){this.init()},lastValueControls:function(){return[]}.property(),lastConfigurationControls:function(){return[]}.property(),wantsInspector:function(){return true},dataContext:function(b,c){var a=this.getPath("dataConfiguration.dataContext");if(c){if(c!==a){if(a){a.removeObserver("changeCount",this,"handleDataContextNotification")}this.setPath("dataConfiguration.dataContext",c);c.addObserver("changeCount",this,"handleDataContextNotification")}return this}else{if(a&&!a.hasObserverFor("changeCount",this)){a.addObserver("changeCount",this,"handleDataContextNotification")}}return this.getPath("dataConfiguration.dataContext")}.property(),_dataContextDidChange:function(){this.notifyPropertyChange("dataContext")}.observes("*dataConfiguration.dataContext"),dataContextDidChange:function(){var a=this.get("dataConfiguration.dataContext");if(a&&!a.hasObserverFor("changeCount")){a.addObserver("changeCount",this,"handleDataContextNotification")}}.observes("dataContext"),childmostCollectionTitle:function(){return this.getPath("dataConfiguration.childmostCollection.title")}.property(),deleteSelectedCases:function(){var a=this.get("dataContext"),c=this.get("selection"),b;if(a){b={operation:"selectCases",select:false,cases:c};a.applyChange(b);b={operation:"deleteCases",cases:c};a.applyChange(b)}},deleteUnselectedCases:function(){var c=this.getPath("dataConfiguration.cases");var a=DG.ArrayUtils.subtract(c,this.get("selection"),function(d){return d.get("id")});var b={operation:"deleteCases",cases:DG.copy(a)};this.get("dataContext").applyChange(b)},selectAll:function(e){var d=SC.none(e)?true:!!e,c=d?this.get("cases"):null,a=this.get("dataContext"),b={operation:"selectCases",collection:this.get("collectionClient"),cases:c,select:d};if(a){a.applyChange(b)}DG.logUser(e?"selectAll":"deselectAll")},instantiateAttributeRefFromStorage:function(e,k,g){var b={collection:null,attributes:[]},d=this.getPath("dataConfiguration.dataContext");if(SC.empty(k)||SC.empty(g)||!e||!e._links_){return b}var c=e._links_[k],a=c&&c.id&&d.getCollectionByID(c.id),i=[],f=DG.ArchiveUtils.getLinkCount(e,g),j;if(!a){return b}for(j=0;j<f;j++){var h=a.getAttributeByID(DG.ArchiveUtils.getLinkID(e,g,j));if(h){i.push(h)}}return{collection:a,attributes:i}},restoreStorage:function(c){var b=c._links_&&c._links_.hiddenCases;if(SC.isArray(b)){var a=DG.ArchiveUtils.getLinkCount(c,"hiddenCases"),d;c.hiddenCases=[];for(d=0;d<a;d++){c.hiddenCases.push(DG.ArchiveUtils.getLinkID(c,"hiddenCases",d))}}this.get("dataConfiguration").restoreHiddenCases(c.hiddenCases);this.setPath("dataConfiguration.displayOnlySelected",c.displayOnlySelected);if(!SC.none(c.pointColor)){this.set("pointColor",c.pointColor)}if(!SC.none(c.strokeColor)){this.set("strokeColor",c.strokeColor)}if(!SC.none(c.pointSizeMultiplier)){this.set("pointSizeMultiplier",c.pointSizeMultiplier)}if(!SC.none(c.transparency)){this.set("transparency",c.transparency)}if(!SC.none(c.strokeTransparency)){this.set("strokeTransparency",c.strokeTransparency)}if(!SC.none(c.strokeSameAsFill)){this.set("strokeSameAsFill",c.strokeSameAsFill)}},handleOneDataContextChange:function(b,c){var d=c&&c.operation;switch(d){case"deleteAttributes":c.attrs.forEach(function(e){e=e.attribute||e;["x","y","legend","y2","area"].forEach(function(g){var f=g+"AttributeDescription",i=g+"Axis",h=this.getPath("dataConfiguration."+f+".attributes");if(h){h.forEach(function(k,j){if(k===e){if(g==="legend"){this.removeLegendAttribute()}else{this.removeAttribute(f,i,j)}}}.bind(this))}}.bind(this))}.bind(this));break;case"deleteCollection":this.dataContextOrCollectionWasDeleted(c.collection);case"updateAttributes":this.handleUpdateAttributes(c);break;case"createCollection":this.notifyPropertyChange("caseOrder");break;case"deleteDataContext":this.reset();this.dataContextOrCollectionWasDeleted();break;default:}var a=this.get("legend");if(a){a.handleOneDataContextChange(b,c)}},dataContextOrCollectionWasDeleted:function(a){DG.log("dataContextWasDeleted");["x","y","legend","y2","area"].forEach(function(e){var d=e+"AttributeDescription",g=e+"Axis",c=this.getPath("dataConfiguration."+d+".collectionClient"),f=this.getPath("dataConfiguration."+d+".attributes");if(c&&f){if(!a||c===a){f.forEach(function(i,h){if(e==="legend"){this.removeLegendAttribute()}else{this.removeAttribute(d,g,h)}}.bind(this))}}}.bind(this));var b=this.get("dataConfiguration");if(b){b.synchHiddenCases()}},handleUpdateAttributes:function(a){},buildIndices:function(b){var a=this.getPath("dataConfiguration.cases");if((b.operation==="updateCases")&&a&&!SC.none(b.cases)&&!this.getPath("dataConfiguration.hasAggregates")){var d={},c=SC.IndexSet.create();b.cases.forEach(function(e){d[e.get("id")]=e});a.forEach(function(f,g){var e=f.get("id");if(d[e]){c.add(g)}});return c}return SC.IndexSet.create(0,this.getPath("dataConfiguration.cases.length"))},handleDataContextNotification:function(c){var b=c.get("newChanges"),a=b.length,d;for(d=0;d<a;d++){this.handleOneDataContextChange(c,b[d])}},getModelPointStyleAccessors:function(){var a=this;return{getPointColor:a.getPointColor.bind(a),getStrokeColor:function(){return a.get("strokeSameAsFill")?a.get("pointColor"):a.get("strokeColor")},getPointSizeMultiplier:function(){return a.get("pointSizeMultiplier")},getTransparency:function(){return a.get("transparency")},getStrokeTransparency:function(){return a.get("strokeSameAsFill")?a.get("transparency"):a.get("strokeTransparency")},getStrokeSameAsFill:function(){return a.get("strokeSameAsFill")}}},createRemoveAttributeMenuItem:function(l,a,f,h){h=h||0;var b=a+"AttributeDescription",k=a+"Axis",i=this.getPath("dataConfiguration."+b+".attributes"),j=(SC.isArray(i)&&h<i.length)?i[h]:DG.Analysis.kNullAttribute,e=(j===DG.Analysis.kNullAttribute)?"":j.get("name"),g=f?"attribute_":"removeAttribute_",c=("DG.DataDisplayMenu."+g+a).loc(e),d;switch(a){case"x":case"y":case"y2":d=this.removeAttribute;break;case"legend":d=this.removeLegendAttribute;break;case"top":case"right":d=this.removeSplitAttribute;break}return{title:c,target:this,itemAction:d,isEnabled:(j!==DG.Analysis.kNullAttribute),log:"attributeRemoved: { attribute: %@, axis: %@ }".fmt(e,a),args:[b,k,h]}},createChangeAttributeTypeMenuItem:function(f,b){var c=b+"AttributeDescription",i=b+"Axis",g=this.getPath("dataConfiguration."+c),h=g&&g.get("attribute"),e=h&&(h!==-1)?h.get("name"):"",a=g&&g.get("isNumeric"),d=(a?"DG.DataDisplayMenu.treatAsCategorical":"DG.DataDisplayMenu.treatAsNumeric").loc();return{title:d,target:this,itemAction:this.changeAttributeType,isEnabled:(h!==DG.Analysis.kNullAttribute),log:"plotAxisAttributeChangeType: { axis: %@, attribute: %@, numeric: %@ }".fmt(i,e,!a),args:[c,i,!a]}},createHideShowSelectionMenuItems:function(){var f=this.getPath("dataConfiguration.selection").toArray(),g=f&&f.get("length")!==0,b=this.getPath("dataConfiguration.cases"),d=f&&b&&(f.get("length")<b.get("length")),h=this.getPath("dataConfiguration.hiddenCases").length>0,a=(f&&f.length>1)?"Plural":"Sing",i=(f&&b&&(b.get("length")-f.length>1))?"Plural":"Sing",m=this.getPath("dataConfiguration.displayOnlySelected"),k=this;function l(){DG.UndoHistory.execute(DG.Command.create({name:"graph.display.hideSelectedCases",undoString:"DG.Undo.hideSelectedCases",redoString:"DG.Redo.hideSelectedCases",log:"Hide %@ selected cases".fmt(f.length),executeNotification:{action:"notify",resource:"component",values:{operation:"hideSelected",type:"",numberHidden:f.length}},execute:function(){this._undoData=f;k.get("dataConfiguration").hideCases(f)},undo:function(){k.get("dataConfiguration").showCases(this._undoData)},redo:function(){k.get("dataConfiguration").hideCases(this._undoData)}}))}function j(){var n=DG.ArrayUtils.subtract(b,f,function(o){return o.get("id")});DG.UndoHistory.execute(DG.Command.create({name:"graph.display.hideUnselectedCases",undoString:"DG.Undo.hideUnselectedCases",redoString:"DG.Redo.hideUnselectedCases",log:"Hide unselected cases",executeNotification:{action:"notify",resource:"component",values:{operation:"hideUnselected",type:"",numberHidden:n.length}},execute:function(){this._undoData=n;this.log="Hide %@ unselected cases".fmt(n.length);k.get("dataConfiguration").hideCases(n)},undo:function(){k.get("dataConfiguration").showCases(this._undoData)},redo:function(){k.get("dataConfiguration").hideCases(this._undoData)}}))}function e(){DG.UndoHistory.execute(DG.Command.create({name:"graph.display.showAllCases",undoString:"DG.Undo.showAllCases",redoString:"DG.Redo.showAllCases",executeNotification:{action:"notify",resource:"component",values:{operation:"showAllCases",type:""}},log:"Show all cases",execute:function(){k.setPath("dataConfiguration.displayOnlySelected",false);this._undoData=k.getPath("dataConfiguration.hiddenCases");k.get("dataConfiguration").showAllCases()},undo:function(){k.get("dataConfiguration").hideCases(this._undoData)}}))}function c(){DG.UndoHistory.execute(DG.Command.create({name:"graph.display.displayOnlySelected",undoString:"DG.Undo.displayOnlySelected",redoString:"DG.Redo.displayOnlySelected",executeNotification:{action:"notify",resource:"component",values:{operation:"displayOnlySelected",type:""}},log:"Display only selected cases",execute:function(){k.setPath("dataConfiguration.displayOnlySelected",true)}}))}return[{title:("DG.DataDisplayMenu.hideSelected"+a),isEnabled:g,target:this,action:l},{title:("DG.DataDisplayMenu.hideUnselected"+i),isEnabled:d,target:this,action:j},{title:"DG.DataDisplayMenu.showAll",isEnabled:h||m,target:this,action:e},{title:"DG.DataDisplayMenu.displayOnlySelected",isEnabled:!m,target:this,action:c}]},removeLegendAttribute:function(){this.changeAttributeForLegend(null,null)},removeSplitAttribute:function(){},changeAttributeType:function(b,a,c){var d=this.get("dataConfiguration");if(!c&&this.getY2Plot&&this.getY2Plot()){this.removeAttribute("y2AttributeDescription","y2Axis",0)}this.set("aboutToChangeConfiguration",true);d.setAttributeType(b,c);this.invalidate(null,true);this.set("aboutToChangeConfiguration",false)},changeAttributeForLegend:function(c,d){function a(){function j(o,n){var l=n&&n.get("children"),m=false;while(!m&&l){var k=l.length>=0&&l[0];if(k===o){m=true}else{l=k&&k.get("children")}}return m}if(!d){return false}var i=d.collection.get("collection"),e=b.getPath("xAttributeDescription.collectionClient.collection"),h=b.getPath("yAttributeDescription.collectionClient.collection"),f=b.getPath("polygonAttributeDescription.collectionClient.collection"),g;if(f){g=f}else{if(e&&h){g=j(e,h)?e:h}else{g=e||h}}return j(i,g)}var b=this.get("dataConfiguration");if(a()){return}this.set("aboutToChangeConfiguration",true);if(c){b.set("dataContext",c)}b.setAttributeAndCollectionClient("legendAttributeDescription",d);b.recomputeLegendQuantilesIfLocked();this.invalidate();this.set("aboutToChangeConfiguration",false)},dataRangeDidChange:function(d,c,b,a){this.invalidate()},invalidate:function(b,a){this.get("dataConfiguration").invalidateCaches(null,b)}});sc_require("components/graph_map_common/data_layer_model");DG.GraphModel=DG.DataLayerModel.extend({autoDestroyProperties:["plot","xAxis","yAxis","y2Axis"],dataConfigurationClass:function(){return DG.GraphDataConfiguration}.property(),isTransparent:false,plotBackgroundColor:null,plotBackgroundOpacity:1,plotBackgroundImage:null,plotBackgroundImageLockInfo:null,numberToggle:null,enableMeasuresForSelection:null,xAxis:function(a,b){if(b){this.get("axisCoordinator").setAxis("x",0,b)}return this.get("xAxisArray")[0]}.property(),yAxis:function(a,b){if(b){this.get("axisCoordinator").setAxis("y",0,b)}return this.get("yAxisArray")[0]}.property(),y2Axis:function(a,b){if(b){this.get("axisCoordinator").setAxis("y2",0,b)}return this.get("y2AxisArray")[0]}.property(),axisCoordinator:null,xAxisArray:function(){return this.getPath("axisCoordinator.xAxisArray")}.property("axisCoordinator.xAxisArray"),yAxisArray:function(){return this.getPath("axisCoordinator.yAxisArray")}.property("axisCoordinator.yAxisArray"),y2AxisArray:function(){return this.getPath("axisCoordinator.y2AxisArray")}.property("axisCoordinator.y2AxisArray"),topAxis:null,rightAxis:null,getRootPlot:function(){return this.get("plot")},plot:function(a,b){if(!SC.none(b)){this._plots.forEach(function(c){c.removeObserver("connectingLine",this,this.connectingLineChanged);c.removeObserver("canSupportConfigurations",this,this.canSupportConfigurationsChanged);this.removePlotObserver(c);c.destroy()}.bind(this));this._plots[0]=b;this._plots.length=1;b.addObserver("connectingLine",this,this.connectingLineChanged);b.addObserver("canSupportConfigurations",this,this.canSupportConfigurationsChanged);b.set("enableMeasuresForSelection",this.get("enableMeasuresForSelection"))}return(this._plots.length<1)?null:this._plots[0]}.property(),_plots:null,plots:function(){return this._plots}.property(),allPlots:function(){var a=[];this._plots.forEach(function(b){a=a.concat([b].concat(b.get("siblingPlots")))});return a}.property(),lastPlot:function(){var a=this._plots.length;return(a>0)?this._plots[a-1]:null}.property(),getPlotAtIndex:function(a){if(a<this._plots.length){return this._plots[a]}return null},addPlot:function(c){if(!this._plots.contains(c)){var b=this.get("plot");if(b.isAdornmentVisible("connectingLine")){c.setAdornmentVisibility("connectingLine",true)}if(c.get("verticalAxisIsY2")){this._plots.push(c)}else{var a=c.get("yAttributeIndex");this._plots.splice(a,0,c)}c.set("enableMeasuresForSelection",this.get("enableMeasuresForSelection"))}},removePlot:function(b){var a=this._plots.indexOf(b);if(a>=0){this.removePlotAtIndex(a)}},removePlotAtIndex:function(a){var b=this._plots[a];if(b){this._plots.splice(a,1);this.removePlotObserver(b);b.destroy();var c=0;this._plots.forEach(function(e,d){if(!e.get("verticalAxisIsY2")){e.setIfChanged("yAttributeIndex",c);c++}})}},splitPlotArray:null,isSplit:function(){return this.getPath("dataConfiguration.hasSplitAttribute")}.property(),isSplitDidChange:function(){this.propertyDidChange("isSplit")}.observes("dataConfiguration.hasSplitAttribute"),numSplitRows:function(){return this.getPath("dataConfiguration.rightAttributeDescription.attributeStats.numberOfCells")||1}.property(),numSplitColumns:function(){return this.getPath("dataConfiguration.topAttributeDescription.attributeStats.numberOfCells")||1}.property(),aboutToChangeConfiguration:false,setProperBackgroundLockInfo:function(){if(!this.get("aboutToChangeConfiguration")){if(!this.bothAxesAreNumeric()){this.set("plotBackgroundImageLockInfo",null)}}}.observes("aboutToChangeConfiguration"),xAxisChanged:function(){var a=this.get("plot");if(!SC.none(a)){a.set("xAxis",this.get("xAxis"))}}.observes("xAxis"),yAxisChanged:function(){var a=this.get("plot");if(!SC.none(a)){a.set("yAxis",this.get("yAxis"))}}.observes("yAxis"),y2AxisChanged:function(){var a=this.get("plot");if(!SC.none(a)){a.set("y2Axis",this.get("y2Axis"))}}.observes("y2Axis"),connectingLineChanged:function(){var a=this.get("plots"),b=(a.length>0)?a[0].getAdornmentModel("connectingLine").get("isVisible"):false;this.get("plots").forEach(function(d,c){if(c>0){d.setAdornmentVisibility("connectingLine",b)}})},init:function(){arguments.callee.base.apply(this,arguments);function k(o){if(o===DG.Analysis.EAttributeType.eNumeric||o===DG.Analysis.EAttributeType.eDateTime){return DG.CellLinearAxisModel}else{if(o===DG.Analysis.EAttributeType.eCategorical){return DG.CellAxisModel}else{return DG.AxisModel}}}var d=function(q,s){var t=this.get(q+"AttributeName"),p,r=s?s.collectionDefaults():DG.currDocumentController().collectionDefaults(),o=r.collectionClient;if(t){delete this[q+"AttributeName"];p=s?s.getAttributeByName(t):(o?o.getAttributeByName(t):null);if(p){if(s&&!o){o=s.getCollectionForAttribute(p)}this.get("dataConfiguration").setAttributeAndCollectionClient(q+"AttributeDescription",{collection:o,attributes:[p]})}}}.bind(this),b=function(q){var p=this.get(q+"Axis"),o=j.get(q+"AttributeDescription");if(!p){p=DG.CellAxisModel.create();this.set(q+"Axis",p)}p.set("dataConfiguration",j);p.set("attributeDescription",o)}.bind(this);function l(o){var p=o.get("yAttributeName");if(Array.isArray(p)){o.set("yAttributeName",p[0]);return p.slice(1)}else{return[]}}var j=this.get("dataConfigurationClass").create(),n=j.get("dataContext");if(n){n.addObserver("changeCount",this,"handleDataContextNotification")}this.set("dataConfiguration",j);var m=j.get("legendAttributeDescription");this.set("legend",DG.LegendModel.create({dataConfiguration:j}));this.setPath("legend.attributeDescription",m);var c=this.initialDataContext;var f=l(this);if(c){this.setPath("dataConfiguration.initialDataContext");this.setPath("dataConfiguration.dataContext",c);delete this.initialDataContext}this._plots=[];this.splitPlotArray=[[this._plots]];this.axisCoordinator=DG.AxisCoordinator.create();["x","y","y2","legend","right","top"].forEach(function(p){d(p,c);if(["x","y","y2"].indexOf(p)>=0){var o=this.getPath("dataConfiguration."+(p+"AttributeDescription")),r=k(o.get("attributeType")),q=r.create({dataConfiguration:this.dataConfiguration});this.set(p+"Axis",q);this.passGetPointColorToAxis(p,q);this.setPath(p+"Axis.attributeDescription",o)}}.bind(this));this.synchPlotWithAttributes();f.forEach(function(p){if(!c){DG.log("Cannot place y attribute: no Data Context: "+p);return}var o=c.getAttributeByName(p);if(!o){DG.log("Cannot place y attribute: not found: "+p);return}var q={collection:c.getCollectionForAttribute(o),attributes:[o]};this.addAttributeToAxis(c,q)}.bind(this));var g=this.getPath("dataConfiguration.y2AttributeDescription");if(g&&g.get("attributes").length&&c){this.changeAttributeForY2Axis(c,{collection:g.get("collectionClient"),attributes:g.get("attributes")})}b("top");b("right");var h=DG.get("IS_INQUIRY_SPACE_BUILD")||this.get("enableNumberToggle"),e=this.get("numberToggle"),i=this.get("numberToggleLastMode"),a=this.get("dataConfiguration");if(!e){e=DG.NumberToggleModel.create({dataConfiguration:a,isEnabled:h});if(e&&i){e.set("lastMode",i)}this.set("numberToggle",e)}else{e.set("dataConfiguration",a)}this.set("enableNumberToggle",h);this.invalidate();this.rescaleAxesFromData(true,true);this.addObserver("dataConfiguration.hiddenCasesWillChange",this.displayedCasesWillChange);this.addObserver("dataConfiguration.hiddenCases",this.displayedCasesDidChange);this.addObserver("dataConfiguration.displayOnlySelected",this.displayedCasesDidChange)},destroy:function(){this.removeObserver("dataConfiguration.hiddenCasesWillChange",this.displayedCasesWillChange);this.removeObserver("dataConfiguration.hiddenCases",this.displayedCasesDidChange);this.removeObserver("dataConfiguration.displayOnlySelected",this.displayedCasesDidChange);this.axisCoordinator.destroy();arguments.callee.base.apply(this,arguments)},enableNumberToggleDidChange:function(){this.setPath("numberToggle.isEnabled",this.get("enableNumberToggle"))}.observes("enableNumberToggle"),numberToggleLastModeDidChange:function(){this.setPath("numberToggle.lastMode",this.get("numberToggleLastMode"))}.observes("numberToggleLastMode"),enableMeasuresForSelectionDidChange:function(){var a=this.get("enableMeasuresForSelection");this.get("allPlots").forEach(function(b){b.set("enableMeasuresForSelection",a)})}.observes("enableMeasuresForSelection"),createHideShowSelectionMenuItems:function(){var a=arguments.callee.base.apply(this,arguments),c=this.get("enableNumberToggle"),b=c?"DG.DataDisplayMenu.disableNumberToggle":"DG.DataDisplayMenu.enableNumberToggle",d=this.get("enableMeasuresForSelection"),f=d?"DG.DataDisplayMenu.disableMeasuresForSelection":"DG.DataDisplayMenu.enableMeasuresForSelection",i=this;function g(k){var j=i.get("enable"+k);DG.UndoHistory.execute(DG.Command.create({name:j?"graph.display.disable"+k:"graph.display.enable"+k,undoString:j?"DG.Undo.disable"+k:"DG.Undo.enable"+k,redoString:j?"DG.Redo.disable"+k:"DG.Redo.enable"+k,log:j?"Disable"+k:"Enable"+k,executeNotification:{action:"notify",resource:"component",values:{operation:"toggle "+k,type:"DG.GraphView"}},execute:function(){this._undoData=!!i.get("enable"+k);i.set("enable"+k,!j)},undo:function(){i.set("enable"+k,this._undoData)}}))}function h(){g("NumberToggle")}function e(){g("MeasuresForSelection")}a.push({title:b,isEnabled:true,target:this,action:h});a.push({title:f,isEnabled:true,target:this,action:e});return a},getAttributeForAxis:function(b){var a;switch(b){case DG.GraphTypes.EOrientation.kHorizontal:a="xAttributeDescription";break;case DG.GraphTypes.EOrientation.kVertical:a="yAttributeDescription";break;case DG.GraphTypes.EOrientation.kVertical2:a="y2AttributeDescription";break}return this.getPath("dataConfiguration."+a+".attribute")},changeAttributeForAxis:function(h,e,g){var j=this,o,m,l,n=false,f=this.get("isSplit");function b(){function B(H,G,K,M){var J=j.get(G).constructor,I={dataConfiguration:d};if(K!==J){var F=j.get(G),E=K.create(I);E.set("attributeDescription",d.get(H));E.setLinkToPlotIfDesired(j.get("plot"));E.set("scaleType",M);j.passGetPointColorToAxis(G,E);j.set(G,E);F.destroy();j.setPath("plot."+G,E)}}var u=l+"AttributeDescription",s=d.getPath(u+".role"),y=d.getPath(u+".attributeStats.attributeType"),D=d.getPath(o+".role"),r=d.getPath(o+".attributeStats.attributeType"),t=l+"Axis",z=j.get(t).constructor,v=j.getPath(t+".scaleType"),A=j.get(m).constructor,w=j.getPath(m+".scaleType"),q=SC.none(k)?[]:[k],x=d.getPath(u+".collectionClient"),C={attributes:q,collection:x};d.setAttributeAndCollectionClient(o,e,s,y);d.setAttributeAndCollectionClient(u,C,D,r);j.beginPropertyChanges();B(o,m,z,v);B(u,t,A,w);j.endPropertyChanges();j.invalidate();j.rescaleAxesFromData(true,true)}function p(){var q=d.getPath(o+".attributes").length;while(q>1){j.removeAttribute(o,m,--q)}}if(f){this.removeAllSplitPlotsAndAxes()}switch(g){case DG.GraphTypes.EOrientation.kHorizontal:o="xAttributeDescription";m="xAxis";l="y";n=true;break;case DG.GraphTypes.EOrientation.kVertical:o="yAttributeDescription";m="yAxis";l="x";n=true;break;case DG.GraphTypes.EOrientation.kVertical2:o="y2AttributeDescription";m="y2Axis";l="x";break;case DG.GraphTypes.EOrientation.kTop:case DG.GraphTypes.EOrientation.kRight:o=g+"AttributeDescription";m=g+"Axis";break}this.set("aboutToChangeConfiguration",true);var d=this.get("dataConfiguration"),k=d.getPath(o+".attribute"),i=d.getPath(l+"AttributeDescription.attribute"),c=e.attributes[0],a=c===i;d.beginPropertyChanges();if(a){b()}else{if(m==="yAxis"){p()}d.set("dataContext",h);d.setAttributeAndCollectionClient(o,e);this.synchPlotWithAttributes();this.synchAxes();if(n){this.get("allPlots").forEach(function(q){q.xOrYAttributeDidChange(m)})}this.invalidate()}d.endPropertyChanges();this.set("aboutToChangeConfiguration",false);if(f){this.updateAxisArrays();this.updateSplitPlotArray();this.notifyPropertyChange("splitPlotChange")}},addAttributeToAxis:function(e,d){DG.logUser("addAxisAttribute: { attribute: %@ }",d.attributes[0].get("name"));var g=this.getPath("dataConfiguration.yAttributeDescription"),c=g.get("attributes").length,f=this.get("isSplit");if(f){this.removeAllSplitPlotsAndAxes()}if(c===0){this.changeAttributeForAxis(e,d,DG.GraphTypes.EOrientation.kVertical);return}g.addAttribute(d.attributes[0]);var h=this.get("plot"),b=$.extend(this.getModelPointStyleAccessors(),h.getPropsForCopy(),{xAxis:this.get("xAxis"),yAxis:this.get("yAxis"),y2Axis:this.get("y2Axis"),yAttributeIndex:c}),i=DG.ScatterPlotModel.create(b);this.addPlot(i);i.installAdornmentModelsFrom(h);var a=h.getAdornmentModel("connectingLine");if(a){i.setAdornmentVisibility("connectingLine",a.get("isVisible"))}this.notifyPropertyChange("attributeAdded");if(f){this.updateAxisArrays();this.updateSplitPlotArray();this.notifyPropertyChange("splitPlotChange")}},removeSplitAttribute:function(c,a,b){this.removeAllSplitPlotsAndAxes();this.get("dataConfiguration").setAttributeAndCollectionClient(c,null,DG.Analysis.EAnalysisRole.eNone,DG.Analysis.EAttributeType.eNone);this.updateAxisArrays();this.updateSplitPlotArray();this.notifyPropertyChange("splitPlotChange")},getY2Plot:function(){var b,a=this.get("y2Axis");this.get("plots").forEach(function(c){if(c.get("yAxis")===a){b=c}});return b},changeAttributeForY2Axis:function(c,f){if(this.getPath("dataConfiguration.yAttributeDescription.attributes").length===0){this.changeAttributeForAxis(c,f,DG.GraphTypes.EOrientation.kVertical);return}var g=function(){var h=this.get("y2Axis");if(!h||!h.get("isNumeric")){return}var i=this.get("dataConfiguration"),j=i&&i.getDataMinAndMaxForDimension(DG.GraphTypes.EPlace.eY2);h.setDataMinAndMax(j.min,j.max,true)}.bind(this);var e=this.getPath("dataConfiguration.y2AttributeDescription"),b=this.get("isSplit");if(b){this.removeAllSplitPlotsAndAxes()}e.removeAllAttributes();e.addAttribute(f.attributes[0]);e.set("collectionClient",f.collection);this.privSyncAxisWithAttribute("y2AttributeDescription","y2Axis");if(!this.getY2Plot()){var a=$.extend(this.getModelPointStyleAccessors(),{verticalAxisIsY2:true}),d=DG.ScatterPlotModel.create(a);d.beginPropertyChanges();d.setIfChanged("dataConfiguration",this.get("dataConfiguration"));d.setIfChanged("xAxis",this.get("xAxis"));d.setIfChanged("yAxis",this.get("y2Axis"));d.endPropertyChanges();this.addPlot(d)}g();this.notifyPropertyChange("y2AttributeAdded");if(b){this.updateAxisArrays();this.updateSplitPlotArray();this.notifyPropertyChange("splitPlotChange")}},changeAttributeType:function(b,a,c){arguments.callee.base.apply(this,arguments);if(b==="xAttributeDescription"||b==="yAttributeDescription"){this.synchPlotWithAttributes();this.synchAxes();this.rescaleAxesFromData(true,true);this.updateAxisArrays();this.updateSplitPlotArray();this.notifyPropertyChange("splitPlotChange")}},splitByAttribute:function(e,c,i){function d(){g.removeAllSplitPlotsAndAxes();var m=a.getPath(j+".attribute"),l=a.getPath(j+".collection");a.setAttributeAndCollectionClient(h,{attributes:[m],collection:l});g.notifyPropertyChange("removedAllSplitPlotsAndAxes")}this.set("aboutToChangeConfiguration",true);var g=this,a=this.get("dataConfiguration"),b=i==="top"?"right":"top",j=i+"AttributeDescription",h=b+"AttributeDescription",k=c.attributes[0],f=a.getPath(h+".attribute");if(k===f){d()}if(this.get("isSplit")){this.removeAllSplitPlotsAndAxes()}a.set("dataContext",e);a.setAttributeAndCollectionClient(j,c);this.invalidate();this.updateAxisArrays();this.updateSplitPlotArray();this.set("aboutToChangeConfiguration",false);this.notifyPropertyChange("splitPlotChange")},splitCategoriesDidChange:function(){this.forEachSplitPlotElementDo(function(a){a.forEach(function(b){b.invalidateCaches()})})}.observes("dataConfiguration.categoryMap"),hasNumericAxis:function(){return this.getPath("xAxis.isNumeric")||this.getPath("yAxis.isNumeric")}.property("xAxis","yAxis"),bothAxesAreNumeric:function(){return this.getPath("xAxis.isNumeric")&&this.getPath("yAxis.isNumeric")}.property("xAxis","yAxis"),canRescale:function(){return this.get("hasNumericAxis")||(this.get("plot")&&this.get("plot").mixUp)}.property("hasNumericAxis","plot"),canMixUp:function(){var a=this.get("plot");return a&&a.mixUp}.property("plot"),canSupportConfigurations:function(){return this.getPath("plot.canSupportConfigurations")}.property("plot"),canSupportConfigurationsChanged:function(){this.notifyPropertyChange("canSupportConfigurations")},rescaleAxesFromData:function(c,d,a,b){this.forEachSplitPlotElementDo(function(e){if(e[0]){e[0].rescaleAxesFromData(c,d,a,b)}})},mixUp:function(){this.forEachSplitPlotElementDo(function(b){var a=b[0];if(a&&a.mixUp){a.mixUp()}})},passGetPointColorToAxis:function(a,b){if(a.charAt(0)==="y"&&(a.length===1||a.charAt(1)!=="2")&&b.constructor===DG.CellLinearAxisModel){b.set("getPointColor",this.getPointColor.bind(this))}},synchAxes:function(){var d=this,c=this.get("dataConfiguration"),b=this.get("plot");[{place:DG.GraphTypes.EPlace.eX,dim:"x"},{place:DG.GraphTypes.EPlace.eY,dim:"y"},{place:DG.GraphTypes.EPlace.eY2,dim:"y2"}].forEach(function(h){var g=b.getDesiredAxisClassFor(h.place),f=d.get(h.dim+"Axis");if(g&&f.constructor!==g){var e=g.create({dataConfiguration:c,attributeDescription:c.get(h.dim+"AttributeDescription")});d.passGetPointColorToAxis(h.dim,e);d.set(h.dim+"Axis",e);b.set(h.dim+"Axis",e);f.destroy()}});if(c.getPath("xAttributeDescription.isCategorical")&&c.getPath("yAttributeDescription.isNumeric")&&c.getPath("yAttributeDescription.attributes").length>1){var a=c.getPath("yAttributeDescription.attributes").length;while(a>1){this.removeAttribute("yAttributeDescription","yAxis",--a)}}},privSyncAxisWithAttribute:function(a,j){var c=this.get("dataConfiguration"),e=c.getPath(a+".isNumeric"),b=[DG.CellLinearAxisModel,DG.BinnedAxisModel],i=e?DG.CellLinearAxisModel:DG.CellAxisModel,d=this.get(j).constructor,h={dataConfiguration:c};if(i!==d&&!(e&&b.indexOf(d)>=0)){var f=this.get(j),g=i.create(h);g.set("attributeDescription",c.get(a));this.passGetPointColorToAxis(j,g);this.set(j,g);f.destroy()}},addPlotObserver:function(a){switch(a.constructor){case DG.BarChartModel:case DG.ComputedBarChartModel:a.addObserver("isBarHeightComputed",this,this.swapComputedBarChartType);if(a.constructor===DG.BarChartModel){a.addObserver("breakdownType",this,this.propagateBreakdownType)}case DG.DotChartModel:a.addObserver("displayAsBarChart",this,this.swapChartType);break;case DG.BinnedPlotModel:a.addObserver("dotsAreFused",this,this.dotsAreFusedDidChange);case DG.DotPlotModel:case DG.LinePlotModel:a.addObserver("displayAsBinned",this,this.changePlotModelType);if(a.constructor===DG.DotPlotModel){a.addObserver("showMeasureLabels",this,this.propagateShowMeasuresLabels)}break}},removePlotObserver:function(a){a.removeObserver("connectingLine",this,this.connectingLineChanged);switch(a.constructor){case DG.BarChartModel:case DG.ComputedBarChartModel:a.removeObserver("isBarHeightComputed",this,this.swapComputedBarChartType);if(a.constructor===DG.BarChartModel){a.removeObserver("breakdownType",this,this.propagateBreakdownType)}case DG.DotChartModel:a.removeObserver("displayAsBarChart",this,this.swapChartType);break;case DG.BinnedPlotModel:a.removeObserver("dotsAreFused",this,this.dotsAreFusedDidChange);case DG.DotPlotModel:case DG.LinePlotModel:a.removeObserver("displayAsBinned",this,this.changePlotModelType);if(a.constructor===DG.DotPlotModel){a.removeObserver("showMeasureLabels",this,this.propagateShowMeasuresLabels)}break}},swapPlotForNewPlot:function(a){var f=this.get("plot"),b=this.get("dataConfiguration"),d=this.get("isSplit"),i,e;if(d){this.removeAllSplitPlotsAndAxes()}this.set("aboutToChangeConfiguration",true);a.configureRoles(b);var c=this.getModelPointStyleAccessors();c.getRootPlot=this.getRootPlot.bind(this);if(f.kindOf(DG.BarChartBaseModel)){c.breakdownType=f.get("breakdownType")}i=a.create(c);this.addPlotObserver(i);e=f.copyAdornmentModels(i);i.beginPropertyChanges();i.setIfChanged("dataConfiguration",b);i.setIfChanged("xAxis",this.get("xAxis"));i.setIfChanged("yAxis",this.get("yAxis"));for(var g in e){if(e.hasOwnProperty(g)){var h=e[g];i.setIfChanged(g,h)}}i.endPropertyChanges();i.set("isAnimating",false);this.setIfChanged("plot",i);this.removePlotObserver(f);f.destroy();this.synchAxes();i.rescaleAxesFromData(true);this.set("aboutToChangeConfiguration",false);if(d){this.updateAxisArrays();this.updateSplitPlotArray();this.notifyPropertyChange("splitPlotChange")}},swapComputedBarChartType:function(a,g,h){var f=this,d=a.get("isBarHeightComputed"),e=a.constructor,b=e===DG.ComputedBarChartModel?DG.BarChartModel:DG.ComputedBarChartModel,c=d?"DG.Undo.graph.showAsComputedBarChart":"DG.Undo.graph.showAsStandardBarChart",i=d?"DG.Redo.graph.showAsComputedBarChart":"DG.Redo.graph.showAsStandardBarChart";DG.UndoHistory.execute(DG.Command.create({name:"graph.toggleComputedBarChart",undoString:c,redoString:i,log:("toggleShowAs: %@").fmt(d?"ComputedBarChart":"BarChart"),_beforeStorage:null,_afterStorage:null,_componentId:this.get("componentID"),_controller:function(){return DG.currDocumentController().componentControllersMap[this._componentId]},execute:function(){this._beforeStorage=this._controller().createComponentStorage();f.swapPlotForNewPlot(b)},undo:function(){this._afterStorage=this._controller().createComponentStorage();this._controller().restoreComponentStorage(this._beforeStorage)},redo:function(){this._controller().restoreComponentStorage(this._afterStorage);this._afterStorage=null}}))},swapChartType:function(g,f,h){var b=g.get("displayAsBarChart"),e=g.constructor,d=e===DG.DotChartModel?DG.BarChartModel:DG.DotChartModel,a=b?("DG.Undo.graph.showAsBarChart"):("DG.Undo.graph.showAsDotChart"),c=b?("DG.Redo.graph.showAsBarChart"):("DG.Redo.graph.showAsDotChart");DG.UndoHistory.execute(DG.Command.create({name:"graph.toggleBarChart",undoString:a,redoString:c,log:("toggleShowAs: %@").fmt(b?"DotChart":"BarChart"),executeNotification:{action:"notify",resource:"component",values:{operation:"switch bar and dot",type:"DG.GraphView"}},execute:function(){this.swapPlotForNewPlot(d)}.bind(this),undo:function(){this.swapPlotForNewPlot(e)}.bind(this)}))},changePlotModelType:function(b,d,g){var f=b.get("displayAsBinned"),e={"false":{constructor:DG.DotPlotModel,logLabel:"DotPlot",undo:"DG.Undo.graph.showAsDotPlot",redo:"DG.Redo.graph.showAsDotPlot"},"true":{constructor:DG.BinnedPlotModel,logLabel:"BinnedPlot",undo:"DG.Undo.graph.showAsBinnedPlot",redo:"DG.Redo.graph.showAsBinnedPlot"},bars:{constructor:DG.LinePlotModel,logLabel:"LinePlot",undo:"DG.Undo.graph.showAsLinePlot",redo:"DG.Redo.graph.showAsLinePlot"}},c=b.constructor;var a=e[f];if(!a){return}DG.UndoHistory.execute(DG.Command.create({name:"graph.changeDotPlotModelType",undoString:a.undo,redoString:a.redo,log:("toggleShowAs: %@").fmt(a.logLabel),executeNotification:{action:"notify",resource:"component",values:{operation:"toggle show as %@".fmt(a.logLabel),type:"DG.GraphView"}},execute:function(){this.swapPlotForNewPlot(a.constructor)}.bind(this),undo:function(){this.swapPlotForNewPlot(c)}.bind(this)}))},dotsAreFusedDidChange:function(c){var e=this.get("dataConfiguration"),d=c.get("primaryAxisPlace"),f=d===DG.GraphTypes.EPlace.eX?"x":"y",a=c.get("secondaryAxisPlace"),b=a===DG.GraphTypes.EPlace.eX?"x":"y";this.set("aboutToChangeConfiguration",true);this.get("xAxis").destroy();this.get("yAxis").destroy();c.invalidateComputationContext();if(c.get("dotsAreFused")){this.set(f+"Axis",DG.CellLinearAxisModel.create({dataConfiguration:e,attributeDescription:this.getPath("dataConfiguration."+f+"AttributeDescription")}));this.set(b+"Axis",DG.CountAxisModel.create({dataConfiguration:e}))}else{this.set(f+"Axis",DG.BinnedAxisModel.create({dataConfiguration:e,attributeDescription:this.getPath("dataConfiguration."+f+"AttributeDescription"),binnedPlotModel:c}));this.set(b+"Axis",DG.AxisModel.create({dataConfiguration:e,attributeDescription:c.get(b+"AxisDescription")}))}this.propertyDidChange("plot");this.set("aboutToChangeConfiguration",false)},propagateBreakdownType:function(){var b=this.getPath("plot.naturalUpperBound");if(this.get("isSplit")){var a=this.getPath("plot.breakdownType");this.forEachSplitPlotElementDo(function(e,d,c){if(d!==0||c!==0){e[0].set("breakdownType",a);b=Math.max(b,e[0].get("naturalUpperBound"))}})}this.getPath("plot.secondaryAxisModel").setLowerAndUpperBounds(0,b,true)},propagateShowMeasuresLabels:function(){var a=this.getPath("plot.showMeasureLabels");if(this.get("isSplit")){this.forEachSplitPlotElementDo(function(d,c,b){if(c!==0||b!==0){d[0].set("showMeasureLabels",a)}})}},synchPlotWithAttributes:function(){var b=this.get("dataConfiguration"),i=b.get("xType"),h=b.get("yType"),f=this.get("plot"),a,j,g,e,d={};i=(i===DG.Analysis.EAttributeType.eDateTime)?DG.Analysis.EAttributeType.eNumeric:i;h=(h===DG.Analysis.EAttributeType.eDateTime)?DG.Analysis.EAttributeType.eNumeric:h;e=[[DG.CasePlotModel,DG.DotPlotModel,DG.DotChartModel],[DG.DotPlotModel,DG.ScatterPlotModel,DG.DotPlotModel],[DG.DotChartModel,DG.DotPlotModel,DG.DotChartModel]];a=e[i][h];if(SC.none(a)){a=DG.PlotModel}var c=i===DG.Analysis.EAttributeType.eCategorical&&h===DG.Analysis.EAttributeType.eCategorical;if(a===DG.DotPlotModel&&f&&f.constructor===DG.BinnedPlotModel){a=DG.BinnedPlotModel;if(i===DG.Analysis.EAttributeType.eCategorical||h===DG.Analysis.EAttributeType.eCategorical){f.set("dotsAreFused",false)}}else{if(a===DG.DotPlotModel&&f&&f.constructor===DG.LinePlotModel){a=DG.LinePlotModel}else{if(a===DG.DotChartModel&&f&&f.constructor===DG.BarChartModel&&!c){a=DG.BarChartModel}}}a.configureRoles(b);if(SC.none(f)||(a!==f.constructor)){j=g=a.create(this.getModelPointStyleAccessors());j.set("getRootPlot",this.getRootPlot.bind(this));this.addPlotObserver(j)}else{g=f}if(f&&g!==f){d=f.copyAdornmentModels(g)}g.setIfChanged("dataConfiguration",b);g.setIfChanged("xAxis",this.get("xAxis"));g.setIfChanged("yAxis",this.get("yAxis"));g.installAdornmentModels(d);this.setIfChanged("plot",g);if(!SC.none(j)&&!SC.none(f)){this.removePlotObserver(f);f.destroy()}},removeAttribute:function(d,b,a){var f=function(){var k=this.get(b),i=DG.AxisModel.create({dataConfiguration:g}),j=(d==="xAttributeDescription")?"yAttributeDescription":"xAttributeDescription",m=(b==="y2Axis")?this.getY2Plot():null,n,l;this.set("aboutToChangeConfiguration",true);g.setAttributeAndCollectionClient(d,null,DG.Analysis.EAnalysisRole.eNone,DG.Analysis.EAttributeType.eNone);switch(this.getPath("dataConfiguration."+j+".attributeType")){case DG.Analysis.EAttributeType.eNumeric:n=DG.Analysis.EAnalysisRole.eSecondaryNumeric;l=DG.Analysis.EAnalysisRole.ePrimaryNumeric;break;case DG.Analysis.EAttributeType.eCategorical:n=DG.Analysis.EAnalysisRole.eSecondaryCategorical;l=DG.Analysis.EAnalysisRole.ePrimaryCategorical;break;default:n=DG.Analysis.EAnalysisRole.eNone;l=DG.Analysis.EAnalysisRole.eNone}g.get(d).set("role",n);g.get(j).set("role",l);i.set("attributeDescription",g.get(d));this.set(b,i);k.destroy();if(b==="y2Axis"){if(m){this.removePlot(m);this.notifyPropertyChange("attributeRemoved")}}else{this.synchPlotWithAttributes();this.synchAxes()}this.invalidate();this.set("aboutToChangeConfiguration",false)}.bind(this),e=function(){var i=g.get(d);i.removeAttributeAtIndex(a);this.removePlotAtIndex(a);this.notifyPropertyChange("attributeRemoved")}.bind(this);a=a||0;var g=this.get("dataConfiguration"),h=g.getPath(d+".attributes"),c=this.get("isSplit");if(c){this.removeAllSplitPlotsAndAxes()}if(h.length===0){return}if(h.length===1){if(b==="xAxis"){g.get("yAttributeDescription").removeAllAttributesButFirst()}if(((b==="yAxis")||(b==="xAxis"))&&this.getY2Plot()){this.removeAttribute("y2AttributeDescription","y2Axis",0)}f()}else{e()}if(c){this.updateAxisArrays();this.updateSplitPlotArray();this.notifyPropertyChange("splitPlotChange")}},displayedCasesWillChange:function(){if(!this._isBeingRestored&&this.get("isSplit")){this.removeAllSplitPlotsAndAxes()}},displayedCasesDidChange:function(){if(!this._isBeingRestored){this.invalidate();this.rescaleAxesFromData(false,true);this.get("plots").forEach(function(a){a.invalidateAggregateAdornments()});if(this.get("isSplit")){this.updateAxisArrays();this.updateSplitPlotArray();this.notifyPropertyChange("splitPlotChange")}}},updateAxisArrays:function(){var f=this;function a(l,m,n,k){var j=f.get(l+"AxisArray"),i=j[0],h=j[m],g;if(!h||h.constructor!==n){g=n.create({dataConfiguration:b,attributeDescription:b.get(k)});if(i.get("isNumeric")){g.setLowerAndUpperBounds(i.get("lowerBound"),i.get("upperBound"))}f.get("axisCoordinator").setAxis(l,m,g)}}var b=this.get("dataConfiguration"),c=this.get("xAxis").constructor,d=this.get("yAxis").constructor,e=this.get("y2Axis").constructor;this.forEachRowDo(function(g){a("y",g,d,"yAttributeDescription");a("y2",g,e,"y2AttributeDescription")});this.forEachColumnDo(function(g){a("x",g,c,"xAttributeDescription")})},updateSplitPlotArray:function(){var d=this,c=this.get("splitPlotArray")[0][0],b=c.length,a=c[0].constructor;this.forEachSplitPlotElementDo(function(k,l,n){var g=0;for(var e=0;e<b;e++){var m=c[e],j=k[e],i=d.get("xAxisArray")[n],h=d.get("yAxisArray")[l],o;if(!j||j.constructor!==a){var f=$.extend(d.getModelPointStyleAccessors(),m.getPropsForCopy(),{splitPlotRowIndex:l,splitPlotColIndex:n,xAxis:i,yAxis:h,y2Axis:d.get("y2AxisArray")[0],yAttributeIndex:m.get("verticalAxisIsY2")?0:g++,getRootPlot:d.getRootPlot.bind(d)});o=a.create(f);i.setLinkToPlotIfDesired(o);h.setLinkToPlotIfDesired(o);if(e===0){m.addSibling(o)}o.installAdornmentModelsFrom(m);k[e]=o;if(j){d.removePlotObserver(j)}}else{j.set("splitPlotRowIndex",l);j.set("splitPlotColIndex",n);if(!j.get("verticalAxisIsY2")){j.set("yAttributeIndex",g++)}j.invalidateCaches();j.updateAdornmentModels()}}});this.propagateShowMeasuresLabels();this.rescaleAxesFromData(true,false)},removeAllSplitPlotsAndAxes:function(){function b(e){e.forEach(function(g,f){if(f!==0){g.destroy()}});e.length=1}var d=this,c=this.get("splitPlotArray"),a=c[0][0][0];this.forEachSplitPlotElementDo(function(g,f,e){if(f!==0||e!==0){g.forEach(function(h){d.removePlotObserver(h);h.destroy()})}});c.length=1;c[0].length=1;a.set("siblingPlots",[]);b(this.get("xAxisArray"));b(this.get("yAxisArray"));b(this.get("y2AxisArray"));this.notifyPropertyChange("removedAllSplitPlotsAndAxes")},forEachRowDo:function(b){var a=this.getPath("dataConfiguration.rightAttributeDescription"),c=a.getPath("attributeStats.numberOfCells")||1,d;for(d=0;d<c;d++){b(d)}},forEachColumnDo:function(b){var d=this.getPath("dataConfiguration.topAttributeDescription"),c=d.getPath("attributeStats.numberOfCells")||1,a;for(a=0;a<c;a++){b(a)}},forEachSplitPlotElementDo:function(c){var g=this.get("splitPlotArray"),a=this.getPath("dataConfiguration.rightAttributeDescription"),d=a.getPath("attributeStats.numberOfCells")||1,h=this.getPath("dataConfiguration.topAttributeDescription"),f=h.getPath("attributeStats.numberOfCells")||1,e,b;for(e=0;e<d;e++){if(!g[e]){g[e]=[]}for(b=0;b<f;b++){if(!g[e][b]){g[e][b]=[]}c(g[e][b],e,b)}}},selection:function(){var a=[];this.forEachSplitPlotElementDo(function(c){var b=c[0].get("selection");if(Array.isArray(b)){a=a.concat(b)}});return a}.property(),restoreStorage:function(c){var e=this,h=this.get("dataConfiguration"),g=0,d=0,f=this.get("isSplit"),b;if(f){this.removeAllSplitPlotsAndAxes()}this._isBeingRestored=true;h.restoreLegendQuantiles(c);var a=function(j){j.forEach(function(l,m){if(!l.plotClass){return}var n=DG.Core.classFromClassName(l.plotClass).create(this.getModelPointStyleAccessors()),k=l.plotModelStorage.verticalAxisIsY2?d++:g++;n.beginPropertyChanges();n.set("getRootPlot",this.getRootPlot.bind(e));n.set("enableMeasuresForSelection",this.get("enableMeasuresForSelection"));n.setIfChanged("dataConfiguration",h);["xAxis","yAxis","y2Axis"].forEach(function(o){var p=this.get(o);n.setIfChanged(o,p);p.setLinkToPlotIfDesired(n)}.bind(this));n.setIfChanged("yAttributeIndex",k);n.restoreStorage(l.plotModelStorage);n.set("getRootPlot",this.getRootPlot.bind(e));n.endPropertyChanges();this.addPlotObserver(n);if(m===0){this.set("plot",n)}else{this.addPlot(n)}}.bind(this))}.bind(this);arguments.callee.base.apply(this,arguments);while(this._plots.length>0){var i=this._plots.pop();this.removePlotObserver(i);i.destroy()}h.set("displayOnlySelected",c.displayOnlySelected);["isTransparent","plotBackgroundColor","plotBackgroundOpacity","plotBackgroundImage","plotBackgroundImageLockInfo","enableMeasuresForSelection"].forEach(function(j){if(!SC.none(c[j])){e.set(j,c[j])}});if(c.enableNumberToggle&&!SC.none(c.numberToggleLastMode)){this.setPath("numberToggle.lastMode",c.numberToggleLastMode)}this.set("aboutToChangeConfiguration",true);["x","y","y2","legend","top","right"].forEach(function(j){var k=this.instantiateAttributeRefFromStorage(c,j+"Coll",j+"Attr");h.setAttributeAndCollectionClient(j+"AttributeDescription",k,c[j+"Role"],c[j+"AttributeType"])}.bind(this));["x","y","y2","top","right"].forEach(function(k){var m=c[k+"AxisClass"],l=m&&DG[m.substring(3)],o=this.get(k+"Axis"),n=o.constructor;if(l&&l!==n){var j=l.create({dataConfiguration:h});j.set("attributeDescription",h.get(k+"AttributeDescription"));this.passGetPointColorToAxis(k,j);this.set(k+"Axis",j);o.destroy()}}.bind(this));a((c.plotClass?[{plotClass:c.plotClass}]:null)||c.plotModels||[]);this._isBeingRestored=false;this.set("aboutToChangeConfiguration",false);b=this.get("isSplit");if(b){this.updateAxisArrays();this.updateSplitPlotArray()}if(f||b){this.notifyPropertyChange("splitPlotChange")}},checkboxDescriptions:function(){return this.getPath("plot.checkboxDescriptions")}.property("plot"),spreadCheckboxDescriptions:function(){return this.getPath("plot.spreadCheckboxDescriptions")}.property("plot"),configurationDescriptions:function(){return this.getPath("plot.configurationDescriptions")}.property("plot"),lastValueControls:function(){return this.getPath("plot.lastValueControls")}.property("plot"),lastConfigurationControls:function(){return this.getPath("plot.lastConfigurationControls")}.property("plot"),stopAnimation:function(){this.get("plot").stopAnimation();this.get("xAxis").stopAnimation();this.get("yAxis").stopAnimation();var a=this.get("y2Axis");a&&a.stopAnimation()},isParentCase:function(a){var b=a.get("parent");return SC.none(b)},handleDroppedContext:function(a){if(this.get("dataContext")!==a){this.reset()}},isPlotAffectedByChange:function(b){var a=this.get("plot"),c=this.get("enableNumberToggle")&&this.get("numberToggle");return(a&&a.isAffectedByChange(b))||(c&&c.isAffectedByChange(b))},handleOneDataContextChange:function(b,d){arguments.callee.base.apply(this,arguments);var c=this.get("plot"),a=d&&d.operation;if(c&&!this.isPlotAffectedByChange(d)){return}switch(a){case"deleteCases":this.get("dataConfiguration").synchHiddenCases();this.dataDidChange(null,null,d);break;case"createCase":case"createCases":case"createCollection":case"deleteCollection":case"resetCollections":case"moveAttribute":this.dataDidChange(null,null,d);this.get("dataConfiguration").updateCaptionAttribute();break;case"updateCases":case"dependentCases":this.get("dataConfiguration").invalidateCaches(null,d);d.indices=this.buildIndices(d);this.dataRangeDidChange(this,"revision",this,d.indices);break;case"selectCases":if(this.getPath("dataConfiguration.displayOnlySelected")){this.dataDidChange(null,null,d)}if(this.get("enableMeasuresForSelection")){this.get("allPlots").forEach(function(f){f.updateAdornmentModels()})}break}this.get("allPlots").forEach(function(f){f.handleDataContextNotification(b,d)});var e=this.get("numberToggle");if(e){e.handleDataContextNotification(b,d)}},handleUpdateAttributes:function(b){var c=this.get("dataConfiguration"),a=b&&b.result&&b.result.attrIDs;if(SC.isArray(a)){a.forEach(function(d){["x","y","y2","legend"].forEach(function(h){var f=c.getPath(h+"AttributeDescription.attributes"),g=f&&f.map(function(i){return i.get("id")});if(g&&g.indexOf(d)>=0){var e=(h==="legend")?this.get(h):this.get(h+"Axis");if(e){e.handleUpdateAttribute(d)}}}.bind(this))}.bind(this))}},dataDidChange:function(b,e,j){var g=function(n,m){n=this.get("dataContext").getCollectionByID(n.get("id"));return m.some(function(p){var o=n.getCaseByID(p);if(!o){return false}return["x","y","y2"].some(function(t){var u=false,r=this.get(t+"Axis");if(r&&r.get("isNumeric")){var q=r.get("lowerBound"),s=r.get("upperBound");u=this.getPath("dataConfiguration."+t+"AttributeDescription.attributes").some(function(v){var w=o.getNumValue(v.get("id"));return isFinite(w)&&(w<q||w>s)})}return u}.bind(this))}.bind(this))}.bind(this);var k=this.get("plot");if(k&&k.isAffectedByChange(j)){this.invalidate(j);var c=this.get("dataConfiguration"),a=c&&c.get("cases"),l=j.result.caseIDs,i=a?a.length():0,f=j.collection?[j.collection]:j.collections?j.collections:[];if(i!==this._oldNumberOfCases){var h=(i>this._oldNumberOfCases);if(k&&h){var d=a.at(i-1);if(this.isParentCase(d)){k.set("openParentCaseID",d.get("id"))}if(l&&f.some(function(m){return g(m,l)})){k.rescaleAxesFromData(false,false)}}this._oldNumberOfCases=i}return}if(this.getPath("dataConfiguration.hasAggregates")){this.invalidate()}},invalidate:function(c,a){var b=this.get("plot");arguments.callee.base.apply(this,arguments);if(a&&!SC.none(b)){b.invalidateCaches()}}});DG.GraphTypes={EPlace:{eUndefined:-1,eFirstPlace:0,eX:0,eY:1,eLegend:2,eY2:3,ePolygon:4,eCaption:5,eTopSplit:6,eRightSplit:7,eLastPlace:7,eNumPlaces:8},EOrientation:{kNone:"none",kHorizontal:"horizontal",kVertical:"vertical",kVertical2:"vertical2",kTop:"top",kRight:"right"}};DG.GraphView=SC.View.extend({displayProperties:["model.dataConfiguration.attributeAssignment","model.dataConfiguration.legendQuantilesAreLocked"],classNames:["dg-graph-view"],model:null,controller:null,leftEdgeBackground:null,rightEdgeBackground:null,yAxisMultiTarget:null,legendView:null,numberToggleView:null,measuresForSelectedInfoView:null,xAxisViewArray:null,yAxisViewArray:null,y2AxisViewArray:null,topAxisView:null,rightAxisView:null,bottomAxisLabelView:null,leftAxisLabelView:null,xAxisView:function(a,b){if(!this.xAxisViewArray){this.xAxisViewArray=[]}if(b){this.get("xAxisViewArray")[0]=b}return this.xAxisViewArray[0]}.property(),yAxisView:function(a,b){if(!this.yAxisViewArray){this.yAxisViewArray=[]}if(b){this.get("yAxisViewArray")[0]=b}return this.yAxisViewArray[0]}.property(),y2AxisView:function(a,b){if(!this.y2AxisViewArray){this.y2AxisViewArray=[]}if(b){this.get("y2AxisViewArray")[0]=b}return this.y2AxisViewArray[0]}.property(),plotBackgroundView:null,plotBackgroundViewArray:null,_functionEditorView:null,functionEditorView:function(a,b){if(b!==undefined){if(this._functionEditorView){this.removeChild(this._functionEditorView)}if(b){this.appendChild(b);b.addObserver("isVisible",this,this.handleAxisOrLegendLayoutChange)}this._functionEditorView=b}return this._functionEditorView}.property(),_plottedValueEditorView:null,plottedValueEditorView:function(a,b){if(b!==undefined){if(this._plottedValueEditorView){this.removeChild(this._plottedValueEditorView)}if(b){this.appendChild(b);b.addObserver("isVisible",this,this.handleAxisOrLegendLayoutChange)}this._plottedValueEditorView=b}return this._plottedValueEditorView}.property(),plotView:function(a,b){if(!SC.none(b)){this._plotViews.forEach(function(c){c.destroy()});this._plotViews[0]=b;this._plotViews.length=1}return(this._plotViews.length<1)?null:this._plotViews[0]}.property(),_plotViews:null,_drawPlotsInvocations:0,_displayDidChangeInvocationsOfDrawPlots:0,plotViews:function(){return this._plotViews}.property(),splitPlotViewArray:null,addPlotView:function(d){if(!this._plotViews.contains(d)){var c=d.get("model"),a=this.getPath("model.plots"),b=this._plotViews.length;a.forEach(function(f,e){if(f===c){b=e}});this._plotViews.splice(b,0,d);d.setIfChanged("paperSource",this.get("plotBackgroundView"));this._plotViews.forEach(function(e,f){e.setIfChanged("plotIndex",f);e.setIfChanged("numPlots",a.length)});d.set("isFirstPlot",b===0)}},plotDisplayDidChange:function(){this._displayDidChangeInvocationsOfDrawPlots++;this.invokeOnceLater(function(){this._displayDidChangeInvocationsOfDrawPlots--;if(this._displayDidChangeInvocationsOfDrawPlots===0){this.drawPlots()}})},addPlotViewObserver:function(a){if(!a.hasObserverFor("plotDisplayDidChange",this,this.plotDisplayDidChange)){a.addObserver("plotDisplayDidChange",this,this.plotDisplayDidChange)}},removePlotViewObserver:function(a){a.removeObserver("plotDisplayDidChange",this,this.plotDisplayDidChange)},setPlotViewProperties:function(f,b,d,c){var e=false;var a=function(q){var m=q.axisClass,p=q.axisKey;if(!SC.none(m)){var n=this.get(p+"AxisView");if(n.constructor===m){return}var j=DG.PlotUtilities.mapAxisViewClassToAxisModelClass(m),o=this.getPath("model."+p+"Axis"),l=o&&o.constructor,k=n.get("orientation"),h=q.axisKey==="x"?this.get("bottomAxisLabelView"):this.get("leftAxisLabelView"),g=(l===j)?o:j.create(q.axisModelProperties||{},{dataConfiguration:this.getPath("model.dataConfiguration")}),i=m.create({orientation:k,model:g,paperSourceForLabel:h});this.removeChild(n);this.appendChild(i);this.set(p+"AxisView",i);this.setPath("plotBackgroundView."+p+"AxisView",i);this.setPath("plotView."+p+"AxisView",i);this.setPath("controller."+p+"AxisView",i);n.destroy();if(l!==j){g.set("attributeDescription",this.getPath("model.dataConfiguration."+p+"AttributeDescription"));this.setPath("model."+p+"Axis",g);this.setPath("model.plot."+p+"Axis",g);e=true}}}.bind(this);d=d||"yAxisView";f.beginPropertyChanges();f.setIfChanged("paperSource",this.get("plotBackgroundView"));f.setIfChanged("model",b);f.setIfChanged("parentView",this);f.setIfChanged("xAxisView",this.get("xAxisView"));f.setIfChanged("yAxisView",this.get(d));f.getAxisViewDescriptions().forEach(a);if(e&&b.rescaleAxesFromData){b.rescaleAxesFromData(true,true)}f.setupAxes();if(!SC.none(c)){f.set("transferredElementCoordinates",c)}f.endPropertyChanges();this.addPlotViewObserver(f)},init:function(){var h=this;this.currTime=0;function c(x,w){switch(x.constructor){case DG.AxisModel:return DG.AxisView;case DG.CellLinearAxisModel:return(w==="qualitative")?DG.QualCellLinearAxisView:DG.CellLinearAxisView;case DG.FormulaAxisModel:return DG.FormulaAxisView;case DG.CellAxisModel:return DG.CellAxisView;case DG.CountAxisModel:return DG.CountAxisView;case DG.BinnedAxisModel:return DG.BinnedAxisView}return null}function o(){h._plotViews=[];h.splitPlotViewArray=[[h._plotViews]];h.plotBackgroundViewArray=[[h.plotBackgroundView]]}var t=this.getPath("model.xAxis"),r=this.getPath("model.dataConfiguration.xAttributeDescription.attribute.type"),n=this.getPath("model.yAxis"),p=this.getPath("model.dataConfiguration.yAttributeDescription.attribute.type"),l=this.getPath("model.y2Axis"),q=this.getPath("model.dataConfiguration"),k=DG.AxisLabelView.create({orientation:DG.GraphTypes.EOrientation.kHorizontal,plottedAttribute:t.get("firstAttribute"),dataConfiguration:q}),e=DG.AxisLabelView.create({orientation:DG.GraphTypes.EOrientation.kVertical,plottedAttribute:n.get("firstAttribute"),dataConfiguration:q}),m=c(t,r).create({orientation:DG.GraphTypes.EOrientation.kHorizontal,paperSourceForLabel:k}),a=c(n,p).create({orientation:DG.GraphTypes.EOrientation.kVertical,paperSourceForLabel:e}),u=c(l).create({orientation:DG.GraphTypes.EOrientation.kVertical2}),b=this.getPath("model.topAxis"),g=c(b).create({orientation:DG.GraphTypes.EOrientation.kTop,centering:"true"}),s=this.getPath("model.rightAxis"),f=c(s).create({orientation:DG.GraphTypes.EOrientation.kRight,centering:"true"}),v=DG.PlotBackgroundView.create({xAxisView:m,yAxisView:a,graphModel:this.get("model"),rowIndex:0,colIndex:0}),d=DG.SelectedInfoView.create({graphModel:this.get("model")});arguments.callee.base.apply(this,arguments);this.set("leftEdgeBackground",SC.View.create({classNames:"dg-axis-view".w()}));this.appendChild(this.get("leftEdgeBackground"));this.set("rightEdgeBackground",SC.View.create({classNames:"dg-axis-view".w()}));this.appendChild(this.get("rightEdgeBackground"));this.appendChild(k);this.set("bottomAxisLabelView",k);this.appendChild(e);this.set("leftAxisLabelView",e);this.set("plotBackgroundView",v);o();this.set("xAxisView",m);this.appendChild(m);this.set("yAxisView",a);this.appendChild(a);this.set("y2AxisView",u);u.set("xAttributeDescription",this.getPath("model.xAxis.attributeDescription"));u.set("otherYAttributeDescription",this.getPath("model.yAxis.attributeDescription"));a.set("otherYAttributeDescription",this.getPath("model.y2Axis.attributeDescription"));this.set("topAxisView",g);this.appendChild(g);this.set("rightAxisView",f);this.appendChild(f);this.appendChild(v);this.legendView=DG.LegendView.create({model:this.getPath("model.legend")});this.appendChild(this.legendView);this.createMultiTarget();if(this.getPath("model.numberToggle")){var j=this.getPath("model.numberToggle.isEnabled"),i=DG.NumberToggleView.create({model:this.getPath("model.numberToggle"),isVisible:j});this.set("numberToggleView",i);this.appendChild(i)}this.set("measuresForSelectedInfoView",d);this.appendChild(d);m.set("model",t);a.set("model",n);u.set("model",l);g.set("model",b);f.set("model",s);this.assignPlotViewToEachPlot();this.appendChild(u);u.set("isVisible",u.get("model").constructor!==DG.AxisModel);g.set("isVisible",this.getPath("model.numSplitColumns")>1);f.set("isVisible",this.getPath("model.numSplitRows")>1);this.handleSplitAttributeChange()},destroy:function(){var b=this.get("plotViews"),a=this.get("model");arguments.callee.base.apply(this,arguments);b.forEach(function(c){c.destroy()});a.destroy()},removeChild:function(a){if(!a.isDescendantOf(this)){return}if(a&&a===this._functionEditorView){this._functionEditorView.removeObserver("isVisible",this,this.handleAxisOrLegendLayoutChange);this._functionEditorView=null}if(a&&a===this._plottedValueEditorView){this._plottedValueEditorView.removeObserver("isVisible",this,this.handleAxisOrLegendLayoutChange);this._plottedValueEditorView=null}arguments.callee.base.apply(this,arguments)},mouseDown:function(){DG.globalEditorLock.commitCurrentEdit();return false},forEachPlotViewDo:function(a){if(this.getPath("model.isSplit")){this.get("splitPlotViewArray").forEach(function(d,c){d.forEach(function(f,e){f.forEach(function(h,g){a(h,c,e,g)})})})}else{var b=this.get("plotViews");b.forEach(function(d,c){a(d,0,0,c)})}},assignPlotViewToEachPlot:function(){var a=this._plotViews.map(function(b){return b});this.getPath("model.plots").forEach(function(c){var e;this.forEachPlotViewDo(function(f){if(!e&&f.get("model")===c){e=f}});if(!e){var b=this.mapPlotModelToPlotView(c).create({model:c});this.addPlotView(b);this.setPlotViewProperties(b,c,c.get("verticalAxisIsY2")?"y2AxisView":"yAxisView")}else{var d=a.indexOf(e);a.splice(d,1)}}.bind(this));a.forEach(function(b){b.destroy()})},drawPlots:function(a){if(this._isConfigurationInProgress){return}var b=this.get("plotViews").length;this.forEachPlotViewDo(function(e,f,c,d){if(e.readyToDraw()){e.doDraw(d,b,a)}})},pointsDidChange:function(b,a){this.drawPlots(a);this.get("legendView").displayDidChange();this.get("yAxisView").displayDidChange()}.observes("model.pointColor","model.strokeColor","model.pointSizeMultiplier","model.transparency","model.strokeTransparency","model.strokeSameAsFill"),categoriesDidChange:function(b,a){if(this.getPath("model.aboutToChangeConfiguration")||!this.get("plotViews")){return}this.get("plotViews").forEach(function(e,d){e.categoriesDidChange()});var c=this.get("legendView");this.drawPlots();if(c){c.displayDidChange()}}.observes("*xAxisView.categoriesDragged","*yAxisView.categoriesDragged","*topAxisView.categoriesDragged","*rightAxisView.categoriesDragged"),selectionOrDisplayOnlySelectedDidChange:function(){this.invokeLater(function(){var a=[];if(this.getPath("model.dataConfiguration.displayOnlySelected")&&this.getPath("model.dataConfiguration.selection").length===0){a=[0,1,2,3,4,5].map(function(b){return("DG.PlotBackgroundView.msg"+b).loc()})}this.get("plotBackgroundViewArray").forEach(function(b){b[0].setIfChanged("messages",a)})},200)}.observes("model.dataConfiguration.displayOnlySelected","model.dataConfiguration.selection"),prepareToSelectPoints:function(){this.forEachPlotViewDo(function(a){a.hideDataTip();a.preparePointSelection()})},completeSelection:function(){this.get("plotViews").forEach(function(a){a.cleanUpPointSelection()})},selectPointsInRect:function(i,a,c,h,d){a=a||[];var e=this.getPath("model.dataContext");var b=this.getPath("model.collectionClient");var f={operation:"selectCases",collection:b,cases:a,select:true,extend:true};var g={operation:"selectCases",collection:b,cases:[],select:false,extend:true};if(SC.none(e)){return}this.get("splitPlotViewArray")[h][d].forEach(function(k){var l=k.getCasesForDelta(i,c);f.cases=f.cases.concat(l);var j=k.getCasesForDelta(c,i);g.cases=g.cases.concat(j)});if(f.cases.length!==0){e.applyChange(f)}if(g.cases.length!==0){e.applyChange(g)}},handleBackgroundClick:function(a){this.get("plotView").handleBackgroundClick(a)},handleBackgroundDblClick:function(a){this.get("plotView").handleBackgroundDblClick(a)},measuresForSelectedInfoVisibilityDidChange:function(){this.renderLayout(this.renderContext(this.get("tagName")))}.observes("measuresForSelectedInfoView.isVisible"),renderLayout:function(M,i){if(this._isRenderLayoutInProgress){return}this._isRenderLayoutInProgress=true;arguments.callee.base.apply(this,arguments);function c(){N.adjust({width:0,height:0});y.adjust({width:0,height:0});if(i){x.set("layout",{left:O,right:g,bottom:e+J,height:s});a.set("layout",{left:C,top:z,bottom:e+F,width:w});q.set("layout",{right:0,top:z,bottom:e+F,width:D});r.set("layout",{left:O,right:g,top:z,bottom:F+e});h.makeSubviewFrontmost(q)}else{var Q=x.get("layout").height;x.adjust({left:O,right:g,bottom:e+J,height:s});if(Q!==s){x.notifyPropertyChange("drawHeight")}var P=a.get("layout").width;a.adjust({bottom:F+e,width:w,top:z});if(P!==w){a.notifyPropertyChange("drawWidth")}q.adjust({bottom:e+F,width:D,top:z});if(!t){q.set("isVisible",false)}r.adjust({left:O,right:g,top:z,bottom:F+e})}}function I(ab,Z){var ae=h.get("xAxisViewArray"),Y=h.get("yAxisViewArray"),S=h.get("y2AxisViewArray"),ac=h.get("plotBackgroundViewArray"),W=ac.length,ai=ac[0].length,Q=h.get("frame"),U=(Q.height-F-e-z-ab)/W,V=(Q.width-O-g-Z)/ai,X,ag;if(i){N.set("layout",{left:O,top:z,right:Z,height:ab});y.set("layout",{width:Z,top:z+ab,right:0,bottom:e+F})}else{N.adjust({top:z,left:O,right:Z,height:ab});y.adjust({width:Z,top:z+ab,bottom:e+F})}for(X=0;X<W;X++){var aa=Y[X],T=z+ab+(W-X-1)*U;if(aa){if(i){aa.set("layout",{left:C,top:T,height:U,width:w});S[X].set("layout",{right:Z,top:T,height:U,width:D});if(!t){S[X].set("isVisible",false)}}else{var ad=aa.get("layout").width;aa.adjust({left:C,height:U,width:w,top:T});if(ad!==w&&X===0){aa.notifyPropertyChange("drawWidth")}S[X].adjust({right:Z,top:T,height:U,width:D})}for(ag=0;ag<ai;ag++){var ah=ac[X][ag],P=O+ag*V;if(X===0){var af=ae[ag],R;if(af){if(i){af.set("layout",{left:P,width:V+1,bottom:e+J,height:s})}else{R=af.get("layout").height;af.adjust({left:P,width:V+1,bottom:e+J,height:s,top:null,right:null});if(R!==s&&X===0&&ag===0){af.notifyPropertyChange("drawHeight")}}}}if(ah){if(i){ah.set("layout",{left:P,top:T,width:V+1,height:U+1})}else{ah.adjust({left:P,top:T,width:V+1,height:U+1})}}}}}}var h=this,k=this.get("leftEdgeBackground"),A=this.get("rightEdgeBackground"),B=this.get("bottomAxisLabelView"),J=B?B.get("desiredExtent"):0,n=this.get("leftAxisLabelView"),C=n?n.get("desiredExtent"):0,x=this.get("xAxisView"),a=this.get("yAxisView"),q=this.get("y2AxisView"),N=this.get("topAxisView"),y=this.get("rightAxisView"),K=this.getPath("model.dataConfiguration.y2AttributeID"),t=K&&(K!==DG.Analysis.kNullAttribute),r=this.get("plotBackgroundView"),u=this.get("plotViews"),b=this.get("legendView"),o=this.get("numberToggleView"),l=this.get("measuresForSelectedInfoView"),v=this.get("functionEditorView"),f=this.get("plottedValueEditorView"),H=o&&o.shouldShow(),s=!x?0:Math.min(x.get("desiredExtent"),this.get("frame").height/3),F=s+J,w=!a?0:Math.min(a.get("desiredExtent"),this.get("frame").width/3),O=w+C,g=(!q||!t)?0:q.get("desiredExtent"),D=!q?0:q.get("desiredExtent"),e=!b?0:b.get("desiredExtent"),E=H?o.get("desiredExtent"):0,G=l?l.get("desiredExtent"):0,p=(v&&v.get("isVisible"))?v.get("desiredExtent"):0,d=(f&&f.get("isVisible"))?f.get("desiredExtent"):0,z=E+p+d+G;if(!SC.none(x)&&!SC.none(a)&&!SC.none(u)&&(u.length>0)){if(l){l.adjust({height:G,top:E})}N.set("isVisible",h.getPath("model.numSplitColumns")>1);y.set("isVisible",h.getPath("model.numSplitRows")>1);var m=N.get("isVisible")?Math.min(N.get("desiredExtent"),this.get("frame").height/3):0,j=y.get("isVisible")?Math.min(y.get("desiredExtent"),this.get("frame").width/3):0;k.set("layout",{left:0,bottom:0,top:0,width:O});A.set("layout",{right:0,bottom:0,top:0,width:j+g});B.set("layout",{bottom:e,left:O,right:g+j,height:J});n.set("layout",{top:z,bottom:J+e,left:0,width:C});if(this.getPath("model.isSplit")){I(m,j)}else{c()}if(v){v.adjust("top",E+G)}if(f){f.adjust("top",E+p+G)}if(i){b.set("layout",{bottom:0,height:e})}else{b.adjust("height",e);if(o){o.adjust({height:E})}}}this._isRenderLayoutInProgress=false;this._drawPlotsInvocations++;this.invokeOnceLater(function(){this._drawPlotsInvocations--;if(this._drawPlotsInvocations===0){this.drawPlots()}}.bind(this))},viewDidResize:function(){arguments.callee.base.apply(this,arguments);this.renderLayout(this.renderContext(this.get("tagName")))},makeSubviewFrontmost:function(a){if(a&&this.get("childViews").indexOf(a)>=0){this.removeChild(a);this.appendChild(a)}},_isRenderLayoutInProgress:false,_isConfigurationInProgress:false,handleAxisModelChange:function(){var d=this,b=false,c=this.get("plotBackgroundView");function a(q,p){var n=d.getPath(q),h=n&&n.constructor,r=d.get(p),i=r&&r.constructor,k,g,j=d.get("plotView"),e,m,o,f="",l;switch(p){case"xAxisView":e=d.get("bottomAxisLabelView");l={orientation:DG.GraphTypes.EOrientation.kHorizontal,paperSourceForLabel:e};m=DG.GraphTypes.EPlace.eX;break;case"yAxisView":e=d.get("leftAxisLabelView");l={orientation:DG.GraphTypes.EOrientation.kVertical,paperSourceForLabel:e};m=DG.GraphTypes.EPlace.eY;break;case"y2AxisView":l={orientation:DG.GraphTypes.EOrientation.kVertical2};m=DG.GraphTypes.EPlace.eY2;break}if(e&&n){e.set("plottedAttribute",n.get("firstAttribute"))}l.layout={left:0,top:0,width:0,height:0};if(d.getPath("model.dataConfiguration")){o=d.getPath("model.dataConfiguration").attributesByPlace[m][0].get("attribute");if(o!==DG.Analysis.kNullAttribute){f=o.get("type")}}switch(h){case DG.AxisModel:k=DG.AxisView;break;case DG.CellAxisModel:k=DG.CellAxisView;break;case DG.CellLinearAxisModel:k=(f==="qualitative")?DG.QualCellLinearAxisView:DG.CellLinearAxisView;break;case DG.FormulaAxisModel:k=DG.FormulaAxisView;break;case DG.CountAxisModel:k=DG.CountAxisView;break;case DG.BinnedAxisModel:k=DG.BinnedAxisView;break;default:k=null}if(k&&(i!==k)){g=k.create(l);g.set("model",n);d.removeChild(r);d.appendChild(g);d.set(p,g);c.set(p,g);if(!SC.none(j)){j.set(p,g);j.setupAxes()}r.destroy();d.controller.set(p,g);b=true}}this.beginPropertyChanges();a("model.xAxis","xAxisView");a("model.yAxis","yAxisView");a("model.y2Axis","y2AxisView");this.setPath("y2AxisView.otherYAttributeDescription",this.getPath("model.yAxis.attributeDescription"));this.setPath("y2AxisView.xAttributeDescription",this.getPath("model.xAxis.attributeDescription"));this.setPath("yAxisMultiTarget.attributeDescription",this.getPath("model.yAxis.attributeDescription"));this.setPath("yAxisMultiTarget.otherAttributeDescription",this.getPath("model.xAxis.attributeDescription"));this.renderLayout(this.renderContext(this.get("tagName")),b);this.endPropertyChanges()}.observes(".model.xAxis",".model.yAxis",".model.y2Axis"),handleLegendModelChange:function(){var a=this.getPath("model.legend");this.setPath("legendView.model",a)}.observes(".model.legend"),handlePlotModelChange:function(){var f=this.getPath("model.plot"),e=this.get("plotView"),c=e&&e.constructor,g,a,d,b=false;if(!e||f.get("isDestroyed")){return}a=this.mapPlotModelToPlotView(f);if(a&&(c!==a)){d=a.create();b=true}if(!SC.none(e)){g=e.get("cachedPointCoordinates")}if(SC.none(d)){this.setPlotViewProperties(e,f,"yAxisView",g)}else{this.set("plotView",d);this.setPlotViewProperties(d,f,"yAxisView",g);if(b){this.renderLayout(this.renderContext(this.get("tagName")),b)}}}.observes(".model.plot"),handleSplitAttributeChange:function(){var c=this;function b(){function d(f,h){var k=h[0],i=k.constructor,g=k.get("orientation"),j=k.get("centering"),l=f.length,n;for(n=1;n<l;n++){var m=h[n],e;if(!m||m.constructor!==i){e=i.create({orientation:g,centering:j,model:f[n],suppressLabel:true});c.appendChild(e);if(m){c.removeChild(m);m.destroy()}h[n]=e}else{m.set("model",f[n])}}for(n=l;n<h.length;n++){h[n].destroy()}h.length=l}d(c.getPath("model.xAxisArray"),c.get("xAxisViewArray"));d(c.getPath("model.yAxisArray"),c.get("yAxisViewArray"));d(c.getPath("model.y2AxisArray"),c.get("y2AxisViewArray"))}function a(){var g=c.get("model"),f=c.get("splitPlotViewArray"),d=c.get("plotBackgroundViewArray"),e=f[0][0][0].constructor;g.forEachSplitPlotElementDo(function(h,j,i){if(j!==0||i!==0){h.forEach(function(k,n){if(!f[j]){f[j]=[]}if(!f[j][i]){f[j][i]=[]}if(!d[j]){d[j]=[]}var m=d[j][i],o=f[j][i][n],l;if(!m){m=DG.PlotBackgroundView.create({xAxisView:c.get("xAxisViewArray")[i],yAxisView:c.get("yAxisViewArray")[j],graphModel:c.get("model"),darkenBackground:(j+i)%2!==0,rowIndex:j,colIndex:i});d[j][i]=m;c.invokeLast(function(){c.appendChild(m)})}else{m.set("xAxisView",c.get("xAxisViewArray")[i]);m.set("yAxisView",c.get("yAxisViewArray")[j])}m.set("rowIndex",j);m.set("colIndex",i);if(!o||o.constructor!==e){var p=k.get("verticalAxisIsY2")?"y2AxisViewArray":"yAxisViewArray";l=e.create({paperSource:d[j][i],model:k,parentView:c,xAxisView:c.get("xAxisViewArray")[i],yAxisView:c.get(p)[j]});f[j][i][n]=l;c.addPlotViewObserver(l);if(o){c.removePlotViewObserver(o);o.destroy()}}})}});c.notifyPropertyChange("plotViewsReconfigured")}this._isConfigurationInProgress=true;b();a();this._isConfigurationInProgress=false;this.renderLayout(this.renderContext(this.get("tagName")),false);this.invokeLater(function(){this.forEachPlotViewDo(function(d){d.updateSelection()})},10)}.observes(".model.splitPlotChange"),allModelSplitsWereRemoved:function(){var b=this,a=this.get("plotBackgroundViewArray");b.notifyPropertyChange("plotViewsWillBeDestroyed");b.forEachPlotViewDo(function(f,g,c,e){if(g!==0||c!==0){b.removePlotViewObserver(f);f.destroy();if(e===0){var d=a[g][c];b.removeChild(d);d.destroy();a[g][c]=null}}});a[0].length=1;a.length=1;this.get("splitPlotViewArray").length=1;this.get("splitPlotViewArray")[0].length=1}.observes(".model.removedAllSplitPlotsAndAxes"),getPlotViewArray:function(b,a){return this.get("splitPlotViewArray")[b][a]},plotWithoutView:function(){var a=this.getPath("model.plots"),c=this._plotViews,b;a.forEach(function(d){if(!c.some(function(e){return d===e.get("model")})){b=d}});return b},handleAttributeAdded:function(){var b=this.plotWithoutView(),a;if(!SC.none(b)){a=DG.ScatterPlotView.create({model:b,paperSource:this.get("plotBackgroundView")});this.addPlotView(a);this.renderLayout(this.renderContext(this.get("tagName")),false);this.setPlotViewProperties(a,b,"yAxisView")}}.observes("model.attributeAdded"),handleY2AttributeAdded:function(){var b=this.getPath("model.lastPlot"),a;if(!SC.none(b)){this.handleAxisModelChange();a=this.get("plotViews").find(function(c){return c.get("model")===b});if(!a){a=DG.ScatterPlotView.create({model:b,paperSource:this.get("plotBackgroundView")});this.addPlotView(a)}this.renderLayout(this.renderContext(this.get("tagName")),false);this.setPlotViewProperties(a,b,"y2AxisView");this.get("y2AxisView").set("otherYAttributeDescription",this.getPath("model.yAxis.attributeDescription"));this.get("y2AxisView").set("xAttributeDescription",this.getPath("model.xAxis.attributeDescription"));this.get("yAxisView").set("otherYAttributeDescription",this.getPath("model.y2Axis.attributeDescription"));a.displayDidChange()}}.observes("model.y2AttributeAdded"),handleAttributeRemoved:function(){var a=this.getPath("model.plots"),c=this.get("plotViews"),b;c.forEach(function(e,d){if(a.indexOf(e.get("model"))<0){b=d;e.removePlottedElements(true,true);e.destroy()}});if(!SC.none(b)){this.get("plotBackgroundView").shiftPlottedElementsToEndOfMap(b);c.splice(b,1);c.forEach(function(e,d){e.set("isFirstPlot",d===0)})}}.observes("model.attributeRemoved"),axisLabelClick:function(b){var a=this.get("controller");if(a){a.setupAttributeMenu(b,b.clientData.axisView,b.clientData.labelIndex)}return YES},configurationIsAboutToChange:function(){if(this.getPath("model.aboutToChangeConfiguration")){this.get("plotView").prepareForConfigurationChange()}else{this.assignPlotViewToEachPlot();this.get("plotView").handleConfigurationChange();this.synchAxisViewsWithAttributeTypes()}}.observes(".model.aboutToChangeConfiguration"),synchAxisViewsWithAttributeTypes:function(){var a=false;var b=function(h){var i=this.get(h+"AxisView").constructor,g=this.getPath("model.dataConfiguration."+h+"AttributeDescription.attribute.type"),f=this.getPath("model."+h+"Axis"),e=f.constructor,d,j,c;if(i===DG.CellLinearAxisView&&g==="qualitative"){d=DG.QualCellLinearAxisView}else{if(i===DG.QualCellLinearAxisView&&g==="numeric"){d=DG.CellLinearAxisView}else{if(e===DG.CountAxisModel){d=DG.CountAxisView}else{if(e===DG.FormulaAxisModel){d=DG.FormulaAxisView}else{if(e===DG.BinnedAxisModel){d=DG.BinnedAxisView}}}}}if(!SC.none(d)&&d!==i){c=this.get(h+"AxisView");j=d.create({orientation:c.get("orientation"),model:f});this.removeChild(c);this.appendChild(j);this.set(h+"AxisView",j);this.setPath("plotBackgroundView."+h+"AxisView",j);this.setPath("plotView."+h+"AxisView",j);this.setPath("controller."+h+"AxisView",j);c.destroy();a=true}}.bind(this);b("x");b("y");this.setPath("yAxisMultiTarget.dataConfiguration",this.getPath("model.dataConfiguration"));if(a){this.renderLayout(this.renderContext(this.get("tagName")),a);this.invokeLater(function(){this.drawPlots()})}},handleAxisOrLegendLayoutChange:function(){this.renderLayout(this.renderContext(this.get("tagName")))}.observes("*xAxisView.desiredExtent","*yAxisView.desiredExtent",".legendView.desiredExtent",".legendView.labelNode","*y2AxisView.desiredExtent",".rightAxisView.desiredExtent",".topAxisView.desiredExtent"),handleNumberToggleDidChange:function(){this.renderLayout(this.renderContext(this.get("tagName")))}.observes("*model.numberToggle.isEnabled","*model.numberToggle.caseCount"),mapPlotModelToPlotView:function(b){var c=b&&b.constructor,a=null;switch(c){case DG.PlotModel:a=DG.PlotView;break;case DG.CasePlotModel:a=DG.CasePlotView;break;case DG.DotPlotModel:a=DG.DotPlotView;break;case DG.BinnedPlotModel:a=b.get("dotsAreFused")?DG.HistogramView:DG.BinnedPlotView;break;case DG.LinePlotModel:a=DG.LinePlotView;break;case DG.ScatterPlotModel:a=DG.ScatterPlotView;break;case DG.DotChartModel:a=DG.DotChartView;break;case DG.BarChartModel:a=DG.BarChartView;break;case DG.ComputedBarChartModel:a=DG.ComputedBarChartView;break}return a},createMultiTarget:function(){var b=DG.AxisMultiTarget.create(),a=b.get("desiredExtent");this.appendChild(b);b.set("dataConfiguration",this.getPath("model.dataConfiguration"));b.set("attributeDescription",this.getPath("model.yAxis.attributeDescription"));b.set("otherAttributeDescription",this.getPath("model.xAxis.attributeDescription"));b.set("layout",{left:0,top:0,right:0,height:a.height});b.set("isVisible",false);this.set("yAxisMultiTarget",b)}});sc_require("alpha/destroyable");DG.PlotModel=SC.Object.extend(DG.Destroyable,{dataConfiguration:null,splitPlotRowIndex:0,splitPlotColIndex:0,siblingPlots:null,getRootPlot:null,dataContext:function(){return this.getPath("dataConfiguration.dataContext")}.property(),dataContextDidChange:function(){this.notifyPropertyChange("dataContext")}.observes("*dataConfiguration.dataContext"),collectionClient:function(){return this.getPath("dataConfiguration.collectionClient")}.property(),collectionClientDidChange:function(){this.notifyPropertyChange("collectionClient")}.observes("*dataConfiguration.collectionClient"),_casesCache:null,cases:function(){var f;if(this.getPath("dataConfiguration.hasSplitAttribute")){if(!this._casesCache){var a=this.getPath("dataConfiguration.rightAttributeDescription"),g=this.getPath("dataConfiguration.topAttributeDescription"),d=a.getPath("attribute.id"),e=g.getPath("attribute.id"),b=(d===DG.Attribute.kNullAttribute)?null:a.getPath("attributeStats.cellNames")[this.get("splitPlotRowIndex")],c=(e===DG.Attribute.kNullAttribute)?null:g.getPath("attributeStats.cellNames")[this.get("splitPlotColIndex")];this._casesCache=this.getPath("dataConfiguration.cases").filter(function(i){var h=i.getValue(d),j=i.getValue(e);if(["boolean","number"].includes(typeof h)){h=String(h)}if(["boolean","number"].includes(typeof j)){j=String(j)}return(b===null||h===b)&&(c===null||j===c)})}f=this._casesCache}else{f=this.getPath("dataConfiguration.cases");this._casesCache=null}return f}.property(),casesDidChange:function(){this.notifyPropertyChange("cases")}.observes("*dataConfiguration.collectionClient","*dataConfiguration.cases"),casesController:function(){return this.getPath("dataConfiguration.collectionClient.casesController")}.property(),casesControllerDidChange:function(){this.notifyPropertyChange("casesController")}.observes("*dataConfiguration.collectionClient.casesController"),selection:function(){var a=this.getPath("dataConfiguration.selection"),b=this.get("cases").toArray();a=a.filter(function(c){return b.indexOf(c)>=0});return a}.property(),selectionDidChange:function(){this.notifyPropertyChange("selection")}.observes("*dataConfiguration.selection"),xVarID:function(){return this.getPath("dataConfiguration.xAttributeID")}.property(),xVarIDDidChange:function(){this.notifyPropertyChange("xVarID")}.observes("*dataConfiguration.xAttributeID"),yAttributeIndex:0,yVarID:function(){var a=this.get("dataConfiguration");return a?a.yAttributeIDAt(this.yAttributeIndex):null}.property(),yVarIDDidChange:function(){this.notifyPropertyChange("yVarID")}.observes("*dataConfiguration.yAttributeID"),y2VarID:function(){var a=this.get("dataConfiguration");return a?a.y2AttributeIDAt(this.yAttributeIndex):null}.property(),y2VarIDDidChange:function(){this.notifyPropertyChange("y2VarID")}.observes("*dataConfiguration.y2AttributeID"),legendVarID:function(){return this.getPath("dataConfiguration.legendAttributeID")}.property(),legendVarIDDidChange:function(){this.notifyPropertyChange("legendVarID")}.observes("*dataConfiguration.legendAttributeID"),primaryVarID:function(){switch(this.get("primaryAxisPlace")){case DG.GraphTypes.EPlace.eX:return this.get("xVarID");case DG.GraphTypes.EPlace.eY:return this.get("yVarID");default:return null}}.property("xVarID","yVarID"),secondaryVarID:function(){switch(this.get("secondaryAxisPlace")){case DG.GraphTypes.EPlace.eX:return this.get("xVarID");case DG.GraphTypes.EPlace.eY:return this.get("yVarID");default:return null}}.property("xVarID","yVarID"),xAxis:null,yAxis:null,verticalAxisIsY2:false,autoDestroyProperties:["plotAnimator","caseValueAnimator"],plotAnimator:null,caseValueAnimator:null,getPointColor:null,getStrokeColor:null,strokeColor:function(){return this.getStrokeColor()}.property(),getStrokeTransparency:null,strokeTransparency:function(){return this.getStrokeTransparency()}.property(),getStrokeSameAsFill:null,strokeSameAsFill:function(){return this.getStrokeSameAsFill()}.property(),getPointSizeMultiplier:null,getTransparency:null,canSupportConfigurations:function(){return false}.property(),_adornmentModels:null,adornmentModelsAsArray:function(){var a=[];DG.ObjectMap.forEach(this._adornmentModels,function(b,c){a.push(c)});return a}.property(),_plottedCountModel:null,plottedCount:function(a,b){if(b||!this._plottedCountModel){if(b){this._plottedCountModel=b}else{this._plottedCountModel=DG.PlottedCountModel.create({plotModel:this})}this.setAdornmentModel("plottedCount",this._plottedCountModel);this._plottedCountModel.setComputingNeeded()}return this._plottedCountModel}.property(),wantsPercentCheckbox:false,wantsOtherAxis:false,enableMeasuresForSelection:false,enableMeasuresForSelectionDidChange:function(){var a=this.get("enableMeasuresForSelection");this.get("adornmentModelsAsArray").forEach(function(b){b.set("enableMeasuresForSelection",a)})}.observes("enableMeasuresForSelection"),shouldPlottedCountBeChecked:function(a){return this.getPath("plottedCount.isShowing"+a)},togglePlotValue:function(){var d=this;function b(){function e(f){f.toggleAdornmentVisibility("plottedValue","togglePlotValue")}d.get("siblingPlots").forEach(e);e(d)}function c(){var e=d.get("siblingPlots"),f=d.getAdornmentModel("plottedValue");f.set("siblingPlottedFunctions",e.map(function(g){return g.getAdornmentModel("plottedValue")}))}var a=!this.isAdornmentVisible("plottedValue");DG.UndoHistory.execute(DG.Command.create({name:"graph.togglePlotValue",undoString:(a?"DG.Undo.graph.showPlotValue":"DG.Undo.graph.hidePlotValue"),redoString:(a?"DG.Redo.graph.showPlotValue":"DG.Redo.graph.hidePlotValue"),log:"togglePlotValue: %@".fmt(a?"show":"hide"),executeNotification:{action:"notify",resource:"component",values:{operation:"toggle plotted value",type:"DG.GraphView"}},execute:function(){b();c()},undo:function(){b();d.getAdornmentModel("plottedValue").set("siblingPlottedFunctions",null)}}))},togglePlottedCount:function(e){var f=this;function a(){function g(i){var h=i.getPath("plottedCount.isShowing"+e);i.setPath("plottedCount.isShowing"+e,!h)}g(f);f.get("siblingPlots").forEach(g)}var c=f.getPath("plottedCount.isShowing"+e),b=c?("DG.Undo.graph.hide"+e):("DG.Undo.graph.show"+e),d=c?("DG.Redo.graph.hide"+e):("DG.Redo.graph.show"+e);DG.UndoHistory.execute(DG.Command.create({name:"graph.toggleCount",undoString:b,redoString:d,log:("togglePlotted"+e+": %@").fmt(c?"hide":"show"),executeNotification:{action:"notify",resource:"component",values:{operation:"toggle plotted "+e,type:"DG.GraphView"}},execute:function(){a()}.bind(this),undo:function(){a()}.bind(this)}))},init:function(){arguments.callee.base.apply(this,arguments);this._adornmentModels={};this.siblingPlots=[];this.addObserver("dataConfiguration",this,"dataConfigurationDidChange");this.addObserver("xAxis",this,"xAxisDidChange");this.addObserver("yAxis",this,"yAxisDidChange");this.addObserver("dataConfiguration.xAttributeDescription.attribute.categoryMap",this,"colorMapDidChange");this.addObserver("dataConfiguration.yAttributeDescription.attribute.categoryMap",this,"colorMapDidChange");this.addObserver("dataConfiguration.legendAttributeDescription.attribute.categoryMap",this,"colorMapDidChange")},destroy:function(){this.removeObserver("xAxis",this,"xAxisDidChange");this.removeObserver("yAxis",this,"yAxisDidChange");this.removeObserver("dataConfiguration.xAttributeDescription.attribute.categoryMap",this,"colorMapDidChange");this.removeObserver("dataConfiguration.yAttributeDescription.attribute.categoryMap",this,"colorMapDidChange");this.removeObserver("dataConfiguration.legendAttributeDescription.attribute.categoryMap",this,"colorMapDidChange");this.removeObserver("dataConfiguration",this,"dataConfigurationDidChange");DG.ObjectMap.forEach(this._adornmentModels,function(a,b){if(b&&b.destroy){b.destroy()}});this._adornmentModels=null;this.siblingPlots=null;arguments.callee.base.apply(this,arguments);this.set("xAxis",null);this.set("yAxis",null);this.set("dataConfiguration",null)},_observedXAxis:null,_observedYAxis:null,xAxisDidChange:function(){if(this._observedXAxis){this._observedXAxis.removeObserver("lowerBound",this,"axisBoundsDidChange");this._observedXAxis.removeObserver("upperBound",this,"axisBoundsDidChange");this._observedXAxis=null}var a=this.get("xAxis");if(a){a.addObserver("lowerBound",this,"axisBoundsDidChange");a.addObserver("upperBound",this,"axisBoundsDidChange");this._observedXAxis=a}},yAxisDidChange:function(){if(this._observedYAxis){this._observedYAxis.removeObserver("lowerBound",this,"axisBoundsDidChange");this._observedYAxis.removeObserver("upperBound",this,"axisBoundsDidChange");this._observedYAxis=null}var a=this.get("yAxis");if(a){a.addObserver("lowerBound",this,"axisBoundsDidChange");a.addObserver("upperBound",this,"axisBoundsDidChange");this._observedYAxis=a}},addSibling:function(a){this.get("siblingPlots").push(a)},dataArrays:function(){return this.getPath("dataConfiguration.arrangedObjectArrays")}.property("dataConfiguration"),isAnimating:false,getAdornmentModel:function(a){return a&&this._adornmentModels&&this._adornmentModels[a]},setAdornmentModel:function(a,b){if(!this._adornmentModels){this._adornmentModels={}}DG.assert(a);this._adornmentModels[a]=b;this.notifyPropertyChange(a)},isAdornmentVisible:function(b){var a=this.getAdornmentModel(b);return a?a.get("isVisible"):false},setAdornmentVisibility:function(d,c){var b=this.getAdornmentModel(d);if(!b){var a=DG.PlotAdornmentModel.registry[d];DG.assert(a,"No model class registered for '%@'".fmt(d));b=a&&a.create({plotModel:this,adornmentKey:d,enableMeasuresForSelection:this.get("enableMeasuresForSelection")});if(b){this.setAdornmentModel(d,b)}}if(b&&(this.isAdornmentVisible(d)!==c)){b.set("isVisible",c);this.notifyPropertyChange(d)}return b},toggleAdornmentVisibility:function(b,a){DG.assert(!SC.empty(b));var c=this.getAdornmentModel(b),d=c&&c.get("isVisible");return this.setAdornmentVisibility(b,!d)},getAxisForPlace:function(a){switch(a){case DG.GraphTypes.EPlace.eX:return this.get("xAxis");case DG.GraphTypes.EPlace.eY:return this.get("yAxis");case DG.GraphTypes.EPlace.eY2:return this.get("y2Axis");default:return null}},getDesiredAxisClassFor:function(a){return DG.AxisModel},invalidateCaches:function(a){this._casesCache=null;this.invalidateAggregateAdornments();this.notifyPropertyChange("plotConfiguration")},getDataMinAndMaxForDimension:function(a){var b=this.get("dataConfiguration");return b&&b.getDataMinAndMaxForDimension(a)},updateAdornmentModels:function(){var a=this.get("primaryAxisModel");this.get("adornmentModelsAsArray").forEach(function(b){b.setComputingNeeded();b.recomputeValueIfNeeded(a)})},handleDataConfigurationChange:function(){},rescaleAxesFromData:function(c,b,a){},invalidateAggregateAdornments:function(){var b=DG.Debug.scObjectID(this),a=this.getPath("dataConfiguration.dataContext.dependencyMgr");if(a){a.invalidateDependentsOf([{type:DG.DEP_TYPE_PLOT,id:b,name:"plot-"+b}])}},axisBoundsDidChange:function(){this.notifyPropertyChange("axisBounds")},animateSelectionBackToStart:function(a,c,b){if(c.every(function(d){return d===0})){return}if(SC.none(this.caseValueAnimator)){this.caseValueAnimator=DG.CaseValueAnimator.create()}else{this.caseValueAnimator.endAnimation()}this.caseValueAnimator.set("dataContext",this.get("dataContext"));this.caseValueAnimator.set("cases",b||DG.copy(this.get("selection")));this.caseValueAnimator.set("attributeIDs",a);this.caseValueAnimator.set("deltas",c);this.caseValueAnimator.animate()},checkboxDescriptionsForPlotModel:function(){var e=this,c=this.get("xAxis").numberOfCells()>1,a=this.get("yAxis").numberOfCells()>1,d=this.get("wantsPercentCheckbox"),b=[{title:"DG.Inspector.graphCount",value:e.shouldPlottedCountBeChecked("Count"),classNames:"dg-graph-count-check".w(),valueDidChange:function(){e.togglePlottedCount("Count")}.observes("value")}];if(d||c||a){b.push({title:"DG.Inspector.graphPercent",value:e.shouldPlottedCountBeChecked("Percent"),classNames:"dg-graph-percent-check".w(),handlingMovableValueChange:false,valueDidChange:function(){if(!this.handlingMovableValueChange){e.togglePlottedCount("Percent")}}.observes("value"),init:function(){arguments.callee.base.apply(this,arguments);e.addObserver("movableValueChange",this,"handleMovableValueChange")},destroy:function(){e.removeObserver("movableValueChange",this,"handleMovableValueChange");arguments.callee.base.apply(this,arguments)},handleMovableValueChange:function(){this.handlingMovableValueChange=true;this.set("value",e.shouldPlottedCountBeChecked("Percent"));this.set("isEnabled",e.get("wantsPercentCheckbox"));this.handlingMovableValueChange=false}})}return b}.property(),checkboxDescriptions:function(){return this.checkboxDescriptionsForPlotModel()}.property(),configurationDescriptions:function(){return[]}.property(),spreadCheckboxDescriptions:function(){return[]}.property(),lastValueControls:function(){return[]}.property(),lastConfigurationControls:function(){return[]}.property(),forEachCaseDo:function(a){var b=this.get("cases");if(!SC.none(b)){b.forEach(a)}},getPlottedCollectionIDs:function(){return this.getPath("dataConfiguration.plottedCollectionIDs")||[]},getPlottedCollectionIDsIncludesIDs:function(a){var b=this.getPlottedCollectionIDs();return a.some(function(c){return b.indexOf(c)>=0})},getPlottedAttributeIDs:function(){var c=[],b=this.get("dataConfiguration"),a=b.get("attributesByPlace");if(!b){return c}a.forEach(function(d){d.forEach(function(e){e.get("attributes").forEach(function(f){var g=f.get("id");if(!SC.none(g)&&g!==DG.Analysis.kNullAttribute&&c.indexOf(g)<0){c.push(g)}})})});return c},getPlottedAttributesIncludeIDs:function(a){var b=this.getPlottedAttributeIDs();return a.some(function(c){return b.indexOf(Number(c))>=0})},getPlottedAttributesContainFormulas:function(){var a=this.get("dataConfiguration");return a&&a.atLeastOneFormula()},xOrYAttributeDidChange:function(a){},isAffectedByChange:function(k){var l=false;if(!k||!k.operation){return false}switch(k.operation){case"dependentCases":var d,g,c=(k.changes&&k.changes.length)||0;for(d=0;d<c;++d){g=k.changes[d];if(g.attributeIDs&&this.getPlottedAttributesIncludeIDs(g.attributeIDs)){l=true}}break;case"updateCases":var j=Array.isArray(k.attributeIDs)?k.attributeIDs:[];if(SC.none(k.attributeID)&&Array.isArray(k.values)&&k.collection){var a=k.collection.collection,b=new Set();k.values.forEach(function(i){DG.ObjectMap.keys(i).forEach(function(p){b.add(p)})});b.forEach(function(p){var i=a.getAttributeByName(p);if(i){j.push(i.get("id"))}})}else{if(!SC.none(k.attributeID)){j.push(k.attributeID)}}l=this.getPlottedAttributesIncludeIDs(j);break;case"createCase":case"createCases":var o=k.collection&&k.collection.get("id"),e=this.getPlottedCollectionIDs();l=!o||(e.indexOf(o)>=0);break;case"deleteCases":case"selectCases":case"moveCases":l=true;break;case"createCollection":var m=k.attributes,n=m&&m.map(function(i){return i.get&&i.get("id")});if(!SC.none(n)){if(n.length>0&&SC.none(n[0])){l=true}else{l=this.getPlottedAttributesIncludeIDs(n)}}break;case"moveAttribute":var f=k.fromCollection&&k.fromCollection.get("id"),h=k.toCollection&&k.toCollection.get("id");l=this.getPlottedCollectionIDsIncludesIDs([f,h])&&f!==h;break}return l},handleDataContextNotification:function(a,b){this.invalidateCaches();this.set("lastChange",b)},_observedDataConfiguration:null,dataConfigurationDidChange:function(c,a){if(this._observedDataConfiguration&&(a==="dataConfiguration")){this._observedDataConfiguration.removeObserver("cases",this,"dataConfigurationDidChange");this._observedDataConfiguration.removeObserver("attributeAssignment",this,"dataConfigurationDidChange");this._observedDataConfiguration.removeObserver("arrangedObjectArrays",this,"sourceArraysDidChange");this._observedDataConfiguration.removeObserver("hiddenCases",this,"dataConfigurationDidChange");this._observedDataConfiguration.removeObserver("displayOnlySelected",this,"dataConfigurationDidChange");this._observedDataConfiguration.removeObserver("hasSplitAttribute",this,"dataConfigurationDidChange");this._observedDataConfiguration=null}var b=this.get("dataConfiguration");if(b){this.get("siblingPlots").concat([this]).forEach(function(d){d.invalidateCaches(a);d.handleDataConfigurationChange(a)});if(a==="dataConfiguration"){b.addObserver("cases",this,"dataConfigurationDidChange");b.addObserver("attributeAssignment",this,"dataConfigurationDidChange");b.addObserver("arrangedObjectArrays",this,"sourceArraysDidChange");b.addObserver("hiddenCases",this,"dataConfigurationDidChange");b.addObserver("displayOnlySelected",this,"dataConfigurationDidChange");b.addObserver("hasSplitAttribute",this,"dataConfigurationDidChange");this._observedDataConfiguration=b;b.set("sortCasesByLegendCategories",true)}}},sourceArraysDidChange:function(b,a){this.invalidateCaches();this.notifyPropertyChange("dataArrays")},colorMapDidChange:function(){this.invalidateCaches();this.propertyDidChange("colorMap")},selectCasesWithIndices:function(b,d){var c=this.get("cases"),a=[];b.forEach(function(e){if(e<c.get("length")){a.push(c.unorderedAt(e))}});this.get("dataContext").applyChange({operation:"selectCases",collection:this.get("collectionClient"),cases:a,select:true,extend:d})},selectCaseByIndex:function(d,f){var e=this.get("cases"),b=e.unorderedAt(d),a=this.get("selection"),c={operation:"selectCases",collection:this.get("collectionClient"),cases:[b],select:true,extend:f};if(a.get("length")!==0){if(a.contains(b)){if(f){c.select=false}else{return}}else{c.select=true}}this.get("dataContext").applyChange(c);if(c.select){DG.logUser("caseSelected: %@",d)}else{DG.logUser("caseDeselected: %@",d)}},stopAnimation:function(){var a=this.get("plotAnimator"),b=this.get("caseValueAnimator");if(!SC.none(a)){a.endAnimation()}if(!SC.none(b)){b.endAnimation()}},getPropsForCopy:function(){return{dataConfiguration:this.get("dataConfiguration"),verticalAxisIsY2:this.get("verticalAxisIsY2")}},createStorage:function(){var a={verticalAxisIsY2:this.get("verticalAxisIsY2")};if(DG.ObjectMap.length(this._adornmentModels)>0){a.adornments={};DG.ObjectMap.forEach(this._adornmentModels,function(b,d){var c=d.createStorage&&d.createStorage();if(DG.ObjectMap.length(c)){a.adornments[b]=c}})}return a},moveAdornmentStorage:function(c,b,a){if(a){if(!c.adornments){c.adornments={}}c.adornments[b]=a}},restoreStorage:function(a){this.verticalAxisIsY2=a.verticalAxisIsY2;if(this.verticalAxisIsY2){this.set("yAxis",this.get("y2Axis"))}DG.ObjectMap.forEach(a.adornments,function(d,c){var b=DG.PlotAdornmentModel.registry[d],e=b&&b.create({plotModel:this});if(e){e.restoreStorage(c);this.setAdornmentModel(d,e);this.set(d,e)}}.bind(this))},copyAdornmentModels:function(a){DG.assert((typeof a==="object")&&(a instanceof DG.PlotModel));var b={},c=this.get("plottedCount");if(c){b.plottedCount=c;c.set("plotModel",a);this._plottedCountModel=null;this._adornmentModels.plottedCount=null}return b},installAdornmentModels:function(a){var b=this;DG.ObjectMap.forEach(a,function(c,d){b.set(c,d)})},getAdornmentSpecs:function(){var a=[],b=this.get("plottedCount");if(b){a.push({key:"plottedCount","class":b.constructor,storage:b.createStorage()})}return a},installAdornmentModelsFrom:function(a){var c=this,b=a.getAdornmentSpecs();b.forEach(function(e){var d=e["class"].create({plotModel:c});d.restoreStorage(e.storage);if(e.useAdornmentModelsArray){c.setAdornmentModel(e.key,d)}else{c.set(e.key,d)}})},getCellCaseCounts:function(){DG.assert(false,"derived classes must override getCellCaseCounts()");return[]}});DG.PlotModel.configureRoles=function(a){};sc_require("components/graph/plots/plot_model");DG.ChartModel=DG.PlotModel.extend({primaryAxisPlace:function(){var a=this.get("dataConfiguration");return a&&a.getPlaceForRole(DG.Analysis.EAnalysisRole.ePrimaryCategorical)}.property("xVarID","yVarID"),secondaryAxisPlace:function(){var a=this.get("dataConfiguration");return a&&a.getPlaceForRole(DG.Analysis.EAnalysisRole.eSecondaryCategorical)}.property("xVarID","yVarID"),primaryAxisModel:function(){return this.getAxisForPlace(this.get("primaryAxisPlace"))}.property("primaryAxisPlace","xAxis","yAxis"),secondaryAxisModel:function(){return this.getAxisForPlace(this.get("secondaryAxisPlace"))}.property("secondaryAxisPlace","xAxis","yAxis"),orientation:function(){return(this.get("primaryAxisPlace")===DG.GraphTypes.EPlace.eX)?DG.GraphTypes.EOrientation.kVertical:DG.GraphTypes.EOrientation.kHorizontal}.property(),canSupportConfigurations:function(){return this.getPath("dataConfiguration.xAttributeDescription.isNull")||this.getPath("dataConfiguration.yAttributeDescription.isNull")}.property(),canSupportConfigurationsChanged:function(){this.notifyPropertyChange("canSupportConfigurations")}.observes("dataConfiguration.xAttributeDescription.isNull","dataConfiguration.yAttributeDescription.isNull"),displayAsBarChart:null,cachedCells:null,cachedIndex:null,validCachedCells:function(){if(!this._cacheIsValid){this._buildCache()}return this.get("cachedCells")}.property(),xAxisDidChange:function(){arguments.callee.base.apply(this,arguments);this.invalidateCaches()},yAxisDidChange:function(){arguments.callee.base.apply(this,arguments);this.invalidateCaches()},numberOfCategoriesLimitDidChange:function(){this.invalidateCaches()}.observes("*xAxis.numberOfCategoriesLimit","*yAxis.numberOfCategoriesLimit"),maxInCell:function(){if(!this._cacheIsValid){this._buildCache()}return this._maxInCell}.property(),primaryCellCounts:function(){if(!this._cacheIsValid){this._buildCache()}return this.get("cachedCells").map(function(a){return a[0].length})}.property(),handleDataContextNotification:function(d,f){if(!this.isAffectedByChange(f)){return}var a=function(l,n,j,o){var k;if(SC.none(j)||SC.none(o)){return}var i=this.get("cachedCells"),h=this.get("cachedIndex"),m=this.get("_maxInCell");if(SC.none(i[j])){i[j]=[]}if(SC.none(i[j][o])){i[j][o]=[]}i[j][o].push({theCase:l,caseIndex:n});k=i[j][o].length;h[n]={primaryCell:j,secondaryCell:o,indexInCell:k-1};this.beginPropertyChanges();this.set("cachedCells",i);this.set("cachedIndex",h);this.set("_maxInCell",Math.max(m,k));this.endPropertyChanges()}.bind(this);if((f.operation==="createCase")||(f.operation==="createCases")){var e=false,c=f.result.caseIDs||[f.result.caseID],b=this.getPath("dataConfiguration.cases").length()-c.length,g=this.get("computationContext");c.forEach(function(i){var h=DG.store.find(DG.Case,i);if(h){if(h._didDisturbCellOrder){e=true;delete h._didDisturbCellOrder}if(!e){this.doForOneCase(h,b++,g,a)}}}.bind(this));if(e){this.invalidateCaches()}}else{this.invalidateCaches()}arguments.callee.base.apply(this,arguments)},lookupCellForCaseIndex:function(a){if(!this._cacheIsValid){this._buildCache()}return this.get("cachedIndex")[a]},_cachedComputationContext:null,computationContext:function(){if(!this._cachedComputationContext){this._cachedComputationContext={primaryAxis:this.get("primaryAxisModel"),secondaryAxis:this.get("secondaryAxisModel"),primaryVarID:this.get("primaryVarID"),secondaryVarID:this.get("secondaryVarID"),legendVarID:this.get("legendVarID")}}return this._cachedComputationContext}.property("primaryAxisModel","secondaryAxisModel","primaryVarID","secondaryVarID","legendVarID"),doForOneCase:function(a,e,g,i){var h=a.getValue(g.primaryVarID),b=SC.none(g.primaryVarID)||!SC.none(h),c=a.getValue(g.secondaryVarID),f=SC.none(g.secondaryVarID)||!SC.none(c),j,d;if(b&&f){j=g.primaryAxis.cellNameToCellNumber(h);d=g.secondaryAxis.cellNameToCellNumber(c);i(a,e,j,d)}},forEachBivariateCaseDo:function(a,b){var c=b?this.get("selection"):this.get("cases"),d=this.get("computationContext");if(!d.primaryAxis||!c||!d.secondaryAxis){return}c.forEach(function(e,f){this.doForOneCase(e,f,d,a)}.bind(this))},invalidateCaches:function(a){arguments.callee.base.apply(this,arguments);this.set("_cacheIsValid",false);this._cachedComputationContext=null},getCellCaseCounts:function(h){var c=this.get("primaryAxisModel"),a=this.get("secondaryAxisModel"),d=[];if(!(c&&a)){return d}var f=c.get("numberOfCells")||1,e=a.get("numberOfCells")||1;var b=f*e;var g,j;for(g=0;g<b;++g){d.push({count:0,selectedCount:0,primaryCell:Math.floor(g/e),secondaryCell:g%e})}this.forEachBivariateCaseDo(function(k,l,i,m){j=i*e+m;if(isFinite(j)&&DG.MathUtilities.isInIntegerRange(j,0,b)){var n=d[j];n.count+=1}});if(h){this.forEachBivariateCaseDo(function(k,l,i,m){j=i*e+m;if(isFinite(j)&&DG.MathUtilities.isInIntegerRange(j,0,b)){var n=d[j];n.selectedCount+=1}},h)}return d},_buildCache:function(){var b=[],a=[],c=0;this.forEachBivariateCaseDo(function(f,g,d,h){var e;h=h||0;if(SC.none(d)||SC.none(h)){return}if(SC.none(b[d])){b[d]=[]}if(SC.none(b[d][h])){b[d][h]=[]}b[d][h].push({theCase:f,caseIndex:g});e=b[d][h].length;a[g]={primaryCell:d,secondaryCell:h,indexInCell:e-1};c=Math.max(c,e)});this._cacheIsValid=true;this.beginPropertyChanges();this.set("cachedCells",b);this.set("cachedIndex",a);this.set("_maxInCell",c);this.endPropertyChanges()},toggleDisplayAsBarChart:function(){this.toggleProperty("displayAsBarChart")},configurationDescriptions:function(){var b=this,a=arguments.callee.base.apply(this,arguments);a.push({constructorClass:SC.CheckboxView,properties:{title:"DG.Inspector.graphBarChart",value:b.get("displayAsBarChart"),classNames:"dg-graph-barchart-check".w(),valueDidChange:function(){b.toggleDisplayAsBarChart();DG.mainPage.mainPane.hideInspectorPicker()}.observes("value")}});return a}.property(),_cacheIsValid:false,_maxInCell:0});DG.ChartModel.configureRoles=function(b){var c=b.get("xType"),d=(c===DG.Analysis.EAttributeType.eCategorical)?"x":"y",a=(d==="x")?"y":"x";b.setPath(d+"AttributeDescription.role",DG.Analysis.EAnalysisRole.ePrimaryCategorical);b.setPath(a+"AttributeDescription.role",DG.Analysis.EAnalysisRole.eSecondaryCategorical)};DG.NumericPlotModelMixin={doDilation:function(a,e,b){var f=this,d=[];function c(h,i){if(SC.none(h)){return}var g=h.computeBoundsForDilation(i,b);d.push({axis:h,newBounds:g})}a.forEach(function(h){var g=(h===DG.GraphTypes.EPlace.eX)?e.x:e.y;c(f.getAxisForPlace(h),g)});if(SC.none(this.plotAnimator)){this.plotAnimator=DG.GraphAnimator.create({plot:this})}this.plotAnimator.set("axisInfoArray",d).animate()},doRescaleAxesFromData:function(d,e,a,g){if(this.getPath("dataConfiguration.cases").length()===0){return}var i=this,b=[],k=[];function h(n,p,l){var u=p&&p.getPath("attributeDescription.attribute"),q=l||(p&&p.constructor===DG.CountAxisModel);if(!p||!p.setDataMinAndMax||(!q&&u===DG.Analysis.kNullAttribute)){k.push({});return}p.set("scaleCanAnimate",SC.none(u)||u.get("type")!=="qualitative");if(n===DG.GraphTypes.EPlace.eY&&i.get("verticalAxisIsY2")){n=DG.GraphTypes.EPlace.eY2}var r=i.getDataMinAndMaxForDimension(n),o=p.get("lowerBound"),t=p.get("upperBound"),s,m;k.push({lower:o,upper:t});p.setDataMinAndMax(r.min,r.max,e||false);s=p.get("lowerBound");m=p.get("upperBound");b.push({axis:p,newBounds:{lower:s,upper:m}})}function f(m,l){if(!SC.none(m)){m.setLowerAndUpperBounds(l.lower,l.upper)}}function j(n,m){var l;for(l=0;l<n.length;l++){if(!SC.none(m[l].lower)&&!SC.none(m[l].upper)&&((n[l].newBounds.lower!==m[l].lower)||(n[l].newBounds.upper!==m[l].upper))){return true}}return false}function c(m){var l=m;if(i.get("verticalAxisIsY2")){switch(m){case DG.GraphTypes.EPlace.eY:l=DG.GraphTypes.EPlace.eY2;break;case DG.GraphTypes.EPlace.eY2:l=DG.GraphTypes.EPlace.eUndefined;break}}return i.getAxisForPlace(l)}if(SC.none(a)){a=true}DG.UndoHistory.execute(DG.Command.create({name:"axis.rescaleFromData",undoString:"DG.Undo.axisRescaleFromData",redoString:"DG.Redo.axisRescaleFromData",causedChange:g,log:"Rescale axes from data",executeNotification:{action:"notify",resource:"component",values:{operation:"rescaleGraph",type:"DG.GraphView"}},execute:function(){d.forEach(function(l){h(l,c(l),i.get("isBarHeightComputed"))});this._undoData={bounds:k.slice(),places:d.slice()};if(j(b,k)){if(a){DG.sounds.playMixup();i.set("isAnimating",true);while((d.length>0)&&(k.length>0)){f(c(d.pop()),k.pop())}if(SC.none(i.plotAnimator)){i.plotAnimator=DG.GraphAnimator.create({plot:i})}i.plotAnimator.set("axisInfoArray",b).animate(i,i.onRescaleIsComplete)}else{if(i.plotAnimator){i.plotAnimator.reset()}b.forEach(function(l){l.axis.setDataMinAndMax(l.newBounds.lower,l.newBounds.upper)})}}},undo:function(){if(this._undoData){this._undoData.places.forEach(function(l,m){var n=c(l),o=this._undoData.bounds[m];if(n&&o){n.setLowerAndUpperBounds(o.lower,o.upper)}}.bind(this));i.onRescaleIsComplete()}},redo:function(){if(this._undoData){this._undoData.places.forEach(function(l){h(l,c(l),i.get("isBarHeightComputed"))});if(a&&j(b,k)){DG.sounds.playMixup();i.set("isAnimating",true);while((d.length>0)&&(k.length>0)){f(c(d.pop()),k.pop())}if(SC.none(i.plotAnimator)){i.plotAnimator=DG.GraphAnimator.create({plot:i})}i.plotAnimator.set("axisInfoArray",b).animate(i,i.onRescaleIsComplete)}}}}))},onRescaleIsComplete:function(){}};sc_require("components/graph/plots/chart_model");sc_require("components/graph/plots/numeric_plot_model_mixin");DG.BarChartBaseModel=DG.ChartModel.extend(DG.NumericPlotModelMixin,{displayAsBarChart:true,breakdownType:DG.Analysis.EBreakdownType.eCount,isBarHeightComputed:false,wantsOtherAxis:true,getPropsForCopy:function(){var a=arguments.callee.base.apply(this,arguments);return $.extend(a,{breakdownType:this.get("breakdownType")})},getDesiredAxisClassFor:function(a){if(a===this.get("primaryAxisPlace")){return DG.CellAxisModel}return arguments.callee.base.apply(this,arguments)},changeBreakdownType:function(b,c){var a=this.get(b);DG.UndoHistory.execute(DG.Command.create({name:"graph.changeBreakdownType",undoString:"DG.Undo.graph.changeBreakdownType",redoString:"DG.Redo.graph.changeBreakdownType",log:("change %@ from %@ to %@").fmt(b,a,c),execute:function(){this.set(b,c)}.bind(this),undo:function(){this.set(b,a)}.bind(this)}))},lastConfigurationControls:function(){var c=arguments.callee.base.apply(this,arguments),g=this,d=18,b=0,e=1,a=2;function f(){return g.get("isBarHeightComputed")?a:g.get("breakdownType")}c.push(SC.LabelView.create({layout:{height:d},value:"DG.Inspector.displayScale",localize:true}));c.push(SC.RadioView.create({itemTitleKey:"title",itemValueKey:"value",items:[{value:b,title:"DG.Inspector.graphCount".loc()},{value:e,title:"DG.Inspector.graphPercent".loc()},{value:a,title:"DG.Inspector.graphFormula".loc()}],value:f(g),layoutDirection:SC.LAYOUT_VERTICAL,layout:{height:3.5*d},classNames:"dg-inspector-radio".w(),valueDidChange:function(){var h=f(g);switch(this.value){case b:case e:if(h!==a){g.changeBreakdownType("breakdownType",this.value);break}g.set("breakdownType",this.value);case a:g.set("isBarHeightComputed",this.value===a);DG.mainPage.mainPane.hideInspectorPicker();break}}.observes("value")}));return c}.property("plot"),rescaleAxesFromData:function(d,c,a,b){if(c===undefined){c=true}this.doRescaleAxesFromData([this.get("secondaryAxisPlace")],d,c,b);if(a){DG.logUser("rescaleBarChart")}},createStorage:function(){var a=arguments.callee.base.apply(this,arguments);a.breakdownType=this.breakdownType;return a},restoreStorage:function(a){arguments.callee.base.apply(this,arguments);if(!SC.none(a.breakdownType)){this.set("breakdownType",a.breakdownType)}}});sc_require("alpha/destroyable");sc_require("components/graph/utilities/plot_utilities");DG.PlotLayer=SC.Object.extend(DG.Destroyable,{autoDestroyProperties:["_dataTip"],paperSource:null,paper:function(){return this.getPath("paperSource.paper")}.property("paperSource"),paperDidChange:function(){this.notifyPropertyChange("paper")}.observes("*paperSource.paper"),plottedElements:function(){return this.get("paperSource").getPlottedElements(this.plotLayerNumber)}.property("paper"),plotLayerNumber:0,layerManager:function(){return this.getPath("paperSource.layerManager")}.property(),layerManagerDidChange:function(){this.notifyPropertyChange("layerManager")}.observes("*paperSource.layerManager"),frame:function(){return this.getPath("paperSource.frame")}.property(),frameDidChange:function(){this.notifyPropertyChange("frame")}.observes("*paperSource.frame"),elementsToClear:function(){return this.getPath("paperSource._elementsToClear")}.property(),elementsToClearDidChange:function(){this.notifyPropertyChange("elementsToClear")}.observes("*paperSource._elementsToClear"),_dataTip:null,dataTip:function(){if(!this._dataTip){this._dataTip=DG.PointDataTip.create({plotLayer:this,layerName:DG.LayerNames.kDataTip})}return this._dataTip}.property(),displayDidChange:function(){this.notifyPropertyChange("plotDisplayDidChange")}.observes("model.isVisible"),model:null,dataContext:function(){return this.getPath("model.dataContext")}.property(),dataContextDidChange:function(){this.notifyPropertyChange("dataContext")}.observes("*model.dataContext"),caseOrderDidChange:function(){this._mustMoveElementsToNewCoordinates=true},selection:null,selectionBinding:"*model.casesController.selection",cleanupFunc:null,cleanupDelay:300,cleanupInterval:300,waitingForCleanup:false,timeOfLastCleanupCall:null,cleanupTimer:null,installCleanup:function(){if(!this.cleanupFunc){return}var a=function(){var b=Date.now();if(b-this.timeOfLastCleanupCall>this.cleanupDelay){this.cleanupFunc();this.waitingForCleanup=false;this.cleanupTimer=null}else{this.cleanupTimer=SC.Timer.schedule({target:this,action:a,interval:this.cleanupInterval})}};this.timeOfLastCleanupCall=Date.now();if(!this.waitingForCleanup){this.waitingForCleanup=true;this.cleanupTimer=SC.Timer.schedule({target:this,action:a,interval:this.cleanupInterval})}},changeKey:"dataDidChange",_pointRadius:DG.PlotUtilities.kPointRadiusMax,_isRenderingValid:false,blankDropHint:"DG.GraphView.dropInPlot",plottedAttribute:function(){return this.getPath("model.dataConfiguration.legendAttributeDescription.attribute")}.property(),init:function(){arguments.callee.base.apply(this,arguments);if(this.get("model")){this.modelDidChange()}},modelDidChange:function(b,a){this.dataConfigurationDidChange(b,a);this.addObserver("model.dataConfiguration.cases",this,"dataDidChange");this.addObserver("model.dataConfiguration.hiddenCases",this,"dataDidChange");this.addObserver("model.dataConfiguration.dataContext.selectionChangeCount",this,"selectionChangeCount");this._isRenderingValid=false}.observes("model"),dataConfigurationDidChange:function(b,a){this._pointRadius=this.calcPointRadius();this._isRenderingValid=false},destroy:function(){if(this.get("paperSource")){this.removePlottedElements(false,true)}this.removeObserver("model.dataConfiguration.cases",this,"dataDidChange");this.removeObserver("model.dataConfiguration.hiddenCases",this,"dataDidChange");this.removeObserver("model.dataConfiguration.dataContext.selectionChangeCount",this,"selectionChangeCount");if(this.cleanupTimer){this.cleanupTimer.invalidate()}this.hideDataTip();arguments.callee.base.apply(this,arguments);this.model=null},handleDataContextNotification:function(f,c){var e=this.get("model"),g=e&&e.get("lastChange"),b=g&&g.operation;if(!e||!e.isAffectedByChange(g)){return}switch(b){case"createCollection":case"deleteCollection":case"resetCollections":this.caseOrderDidChange();case"createCase":case"createCases":case"deleteCases":var a=this.get("changeKey");if(!SC.empty(a)){var d=this[a];if(d){d.call(this,this,c,b)}}break;case"updateCases":case"dependentCases":case"createAttributes":case"updateAttributes":this.dataRangeDidChange(this,"revision",this,g.indices);break;case"moveAttribute":this.handleMoveAttribute();break;case"moveCases":this.handleMoveCases();break}}.observes(".model.lastChange"),plotConfigurationDidChange:function(){this._isRenderingValid=false;this._elementOrderIsValid=false;this.displayDidChange()}.observes(".model.plotConfiguration"),paperSizeDidChange:function(){this._isRenderingValid=false;this.displayDidChange()}.observes("paperSize"),selectionChangeCount:function(){this._elementOrderIsValid=false},handleMoveAttribute:function(){},handleMoveCases:function(){this.getPath("model.dataConfiguration").invalidateCaches();this.drawData();this.selectionDidChange()},prepareToResetCoordinates:function(){},refreshCoordinates:function(){if(this.get("paper")){this.drawData()}},assignElementAttributes:function(c,b,a){c.undrag();if(c.events){c.events.forEach(function(e){e.unbind()});c.events.length=0}var d=this;c.addClass(DG.PlotUtilities.kColoredDotClassName).attr({cursor:"pointer"}).mousedown(function(e){SC.run(function(){d.get("model").selectCaseByIndex(b,e.shiftKey)})});c.index=b;if(a){DG.PlotUtilities.doCreateCircleAnimation(c)}return c},callCreateElement:function(a,g,h,i){var f=this.get("plottedElements"),b=this.get("layerManager"),d=b.getLayer(DG.LayerNames.kPoints),c,e;if(f[g]&&f[g].node){c=f[g];e=b.layerForElement(c)}else{c=this.createElement(a,g,h);f[g]=c}if(e){b.moveElementFromTo(c,e,d)}else{d.push(c)}this._elementOrderIsValid=false;return this.assignElementAttributes(c,g,h,i)},getStrokeParams:function(){var a=this.get("model");DG.assert(a);return{strokeColor:a.get("strokeColor"),strokeTransparency:a.get("strokeTransparency"),strokeSameAsFill:a.get("strokeSameAsFill")}},dataDidChange:function(e,b,j){if(!this.readyToDraw()){return}var d=this.getPath("model.cases"),i=this.createRenderContext(),g=(this._pointRadius!==this.calcPointRadius());if(!d||!i){return}this._elementOrderIsValid=false;if(g){this._pointRadius=this.calcPointRadius();this._isRenderingValid=false;this.displayDidChange()}this.updateAdornments();var h=d&&d.get("length"),f=this.get("plottedElements"),l=f.length,c=this.get("layerManager"),k;if(h>l){for(k=l;k<h;k++){var a=d.at(k);if(a){this.callCreateElement(a,k,this.animationIsAllowable());this.setCircleCoordinate(i,a,k)}}}if(h<l){for(k=h;k<l;k++){if(!SC.none(f[k])){f[k].stop();c.removeElement(f[k]);DG.PlotUtilities.doHideRemoveAnimation(f[k],c)}}f.length=h}if((b==="hiddenCases")||(j==="deleteCases")){this.notifyPropertyChange("plotDisplayDidChange")}this._isRenderingValid=false;if(b==="hiddenCases"){this.updateSelection()}this.installCleanup()},dataRangeDidChange:function(b,d,a,c){this.removeExtraElements();this.updateAdornments();this.get("dataTip").handleChanges(c);this.updateSelection()},updateAdornments:function(){},animationIsAllowable:function(){var b=Date.now(),a=b-this._timeLastCreate;if(a<DG.PlotUtilities.kDefaultAnimationTime){this._createAnimationOn=false}else{if(b-this._timeLastCreate>this._kAllowableInterval){this._createAnimationOn=true}}this._timeLastCreate=b;return this._createAnimationOn},readyToDraw:function(){return !SC.none(this.get("paper"))&&!SC.none(this.getPath("model.dataConfiguration"))},_timeLastCreate:null,_createAnimationOn:true,_kAllowableInterval:1000,_elementOrderIsValid:false,_mustMoveElementsToNewCoordinates:false,removeExtraElements:function(){var b=this.getPath("model.cases").length(),a=this.get("plottedElements"),c=a.length,e=this.get("layerManager");for(var d=b;d<c;d++){DG.PlotUtilities.doHideRemoveAnimation(a[d],e)}},drawData:function drawData(){if(!this.get("paper")){return}var d=this,c=this.getPath("model.cases"),b=this.createRenderContext(),a=this.get("plottedElements");if(SC.none(c)||!b){return}this._mustMoveElementsToNewCoordinates=false;b.casesAdded=true;if(b.casesRemoved){this.removeExtraElements()}if(b.casesAdded){this._pointRadius=this.calcPointRadius()}if(a.length<c.get("length")){d._elementOrderIsValid=false}if(b.updatedPositions||b.updatedColors||b.casesAdded||this._mustMoveElementsToNewCoordinates){this.resetCoordinates(c,b)}},resetCoordinates:function(c,b){var a=this.get("plottedElements").length;this.prepareToResetCoordinates();c.forEach(function(d,e){if(e>=a){this.callCreateElement(d,e,true,b.isVisible)}this.setCircleCoordinate(b,d,e)}.bind(this));this._mustMoveElementsToNewCoordinates=false},didDraw:function(){arguments.callee.base.apply(this,arguments);this._isRenderingValid=true},clear:function(){var b=this.get("layerManager"),a=this.get("plottedElements");a.forEach(function(c){b.removeElement(c)})},selectionDidChange:function(){this._elementOrderIsValid=false;this.updateSelection();this._isRenderingValid=false;if(this.getPath("model.enableMeasuresForSelection")){this.updateAdornments()}}.observes("selection"),getPlottedElementClass:function(b,a){return(a?(b?DG.PlotUtilities.kSelectedColoredDotClassName:DG.PlotUtilities.kColoredDotClassName):(b?DG.PlotUtilities.kSelectedDotClassName:DG.PlotUtilities.kDotClassName))},updateSelection:function(){if(!this.get("model")){return}if(this._elementOrderIsValid){return}if(!this.get("paper")){return}var d=this,f=this.get("plottedElements"),g=this.getPath("model.selection"),i=(this.getPath("model.dataConfiguration.legendAttributeDescription.attribute")!==DG.Analysis.kNullAttribute)||(this.get("numPlots")>1),a=this.get("layerManager"),c=this.getPath("model.cases"),e=this._pointRadius,j=f[0]&&f[0].node,b=j&&j.constructor===SVGRectElement,h=e+DG.PlotUtilities.kPointRadiusSelectionAddend;if(!c||!g){return}if(this._mustMoveElementsToNewCoordinates){this.resetCoordinates(c,this.createRenderContext())}if(b){h=e=0.1}c.forEach(function(l,o){var q,n,k,m,p,r,s="";if((o<f.length)&&f[o]){n=f[o];q=g.indexOf(l)>=0;k=q?DG.LayerNames.kPoints:DG.LayerNames.kSelectedPoints;m=q?DG.LayerNames.kSelectedPoints:DG.LayerNames.kPoints;p=d.getPlottedElementClass(q,i);r=q?h:e;if(!n.hasClass(p)){if(q){n._selected=true;s=n.transform();n.transform("")}else{delete n._selected}DG.PlotUtilities.kDotClasses.forEach(function(t){n.removeClass(t)});n.addClass(p);a.moveElementFromTo(n,k,m);n.attr({r:r});if(q){n.transform(s)}}}});this._elementOrderIsValid=true},_selectionTree:null,preparePointSelection:function(){var a=function(e,g,f){this._selectionTree.insert({x:e,y:g,w:1,h:1},f)}.bind(this);var d=this.getPath("model.cases"),b=this.get("plottedElements"),c=b.length>0&&b[0][0].constructor===SVGRectElement;this._selectionTree=new RTree();b.forEach(function(g,f){var e=d.unorderedAt(f);if(e){if(c){a(g.attrs.x,g.attrs.y,e);a(g.attrs.x+g.attrs.width,g.attrs.y,e);a(g.attrs.x+g.attrs.width,g.attrs.y+g.attrs.height,e);a(g.attrs.x,g.attrs.y+g.attrs.height,e)}else{a(g.attrs.cx,g.attrs.cy,e)}}}.bind(this))},cleanUpPointSelection:function(){this._selectionTree=null},getCasesForDelta:function(e,a){function f(h,g){var l=Math.max(h.x,g.x);var j=Math.min(h.x+h.width,g.x+g.width);var k=Math.max(h.y,g.y);var i=Math.min(h.y+h.height,g.y+g.height);if(j-l<=0||i-k<=0){return null}return{x:l,y:k,width:j-l,height:i-k}}function c(i,h){var l=f(i,h);var g=[];var k;var j;if(l){k={x:l.x+l.width,y:l.y+l.height};j={x:i.x+i.width,y:i.y+i.height};if(i.x<l.x){g.push({x:i.x,y:i.y,width:l.x-i.x,height:i.height})}if(k.x<j.x){g.push({x:k.x,y:i.y,width:j.x-k.x,height:i.height})}if(i.y<l.y){g.push({x:l.x,y:i.y,width:l.width,height:l.y-i.y})}if(k.y<j.y){g.push({x:l.x,y:k.y,width:l.width,height:j.y-k.y})}}else{g.push(i)}return g}var b=c(e,a);var d=[];b.forEach(function(i){var h;var g;h={x:i.x,y:i.y,w:i.width,h:i.height};g=this._selectionTree.search(h);if(g&&g.length>0){d=d.concat(g)}}.bind(this));return d},getCasesForPointsInRect:function(c){var d,a,b;if(this._selectionTree){b={x:c.x,y:c.y,w:c.width,h:c.height};a=this._selectionTree.search(b)}else{d=this.getPath("model.cases");a=[];this.get("plottedElements").forEach(function(f,e){if(DG.ViewUtilities.ptInRect({x:f.attrs.cx,y:f.attrs.cy},c)){a.push(d.at(e))}})}return a},removePlottedElements:function(c,b){var d=this.get("layerManager"),a=this.get("plottedElements");a.forEach(function(e){if(b){DG.PlotUtilities.doHideRemoveAnimation(e,d)}else{d.removeElement(e,c)}})},drawWidth:function(){return this.get("frame").width-2*DG.ViewUtilities.kBorderWidth}.property("frame"),drawHeight:function(){return this.get("frame").height-2*DG.ViewUtilities.kBorderWidth}.property("frame"),dragData:null,performDragOperation:function(a,b){this.set("dragData",a.data);return SC.DRAG_LINK},showDataTip:function(b,a){if(DG.NO_DATA_TIP_PREF||this.getPath("paperSource.tempDisallowDataTips")){return}this.get("dataTip").show(b.attr("cx"),b.attr("cy"),b.attr("r"),a)},hideDataTip:function(){if(DG.NO_DATA_TIP_PREF){return}var a=this.get("dataTip");if(a){a.hide()}},calcPointRadius:function(){var h=this.get("model");if(!h){return}var a=h.get("dataConfiguration"),f=a?a.getCaseCount():0,j=h.getPointSizeMultiplier,e=j?j.call(this.get("model")):1,g=DG.PlotUtilities.kPointRadiusMax,k=DG.PlotUtilities.kPointRadiusMin,d=DG.PlotUtilities.kPointRadiusLogBase,b;for(var c=d;c<=f;c=c*d){--g;if(g<=k){break}}b=g*e;return b<1?0:b},radiusForCircleElement:function(a){return this._pointRadius+(a._selected?DG.PlotUtilities.kPointRadiusSelectionAddend:0)},createRenderContext:function(){return{}},showHidePlottedElement:function(a,e,d){var b=a.isHidden();if(e){if(!b){a.stop();a.hide();a.attr({cx:0,cy:0,r:1,fill:DG.ColorUtilities.kMissingValueCaseColor.colorString})}}else{if(b){var c={"fill-opacity":DG.PlotUtilities.kDefaultPointOpacity,opacity:1};this.assignElementAttributes(a,d);a.stop();a.attr(c);a.show()}}return !e},updatePlottedElement:function(a,e,c,f){if(a.posAnimation){a.stop(a.posAnimation);a.posAnimation=null}function b(){this.posAnimation=null;if(f){f()}}if(c){a.attr({stroke:e.stroke,"stroke-opacity":e["stroke-opacity"]});if(a.hoverAnimation){a.stop(a.hoverAnimation);a.hoverAnimation=null;a.transform("")}a.posAnimation=Raphael.animation(e,DG.PlotUtilities.kDefaultAnimationTime,"<>",b);a.animate(a.posAnimation)}else{var g=a.transform(),d=SC.empty(g)||(SC.isArray(g)&&g.length===0)||(g.toString()==="s1");if(!d){a.transform("")}DG.PlotUtilities.setPlottedPointAttributes(a,e);if(!d){a.transform(g)}}},vanishPlottedElement:function(c,a){function d(){this.hide()}var b=this.get("paper").circle(-100,-100,this._pointRadius).toBack().addClass(DG.PlotUtilities.kColoredDotClassName).attr(c).animate(a,DG.PlotUtilities.kDefaultAnimationTime,"<>",d);this.get("elementsToClear").push(b)},updatePointSize:function(){this._pointRadius=this.calcPointRadius();var a={r:this._pointRadius};this.get("plottedElements").forEach(function(b){b.animate(a,DG.PlotUtilities.kDefaultAnimationTime,"<>")})},didCreateLayer:function(){}});sc_require("components/graph_map_common/plot_layer");DG.PlotView=DG.PlotLayer.extend({autoDestroyProperties:["plottedCountAdorn","plottedValueAdorn"],plotIndex:0,numPlots:1,plotIndexDidChange:function(){this.set("plotLayerNumber",this.get("plotIndex"))}.observes("plotIndex"),xAxisView:null,yAxisView:null,isUsingY2:function(){return this.getPath("yAxisView.orientation")===DG.GraphTypes.EOrientation.kVertical2}.property(),isUsingY2DidChange:function(){this.notifyPropertyChange("isUsingY2")}.observes("*yAxisView.orientation"),plottedElementType:"circle",cachedPointCoordinates:null,transferredElementCoordinates:null,allowTransferAnimation:true,_areAdornmentsInitialized:false,plottedValueEditView:null,plottedCountAdorn:null,plottedValueAdorn:null,init:function(){arguments.callee.base.apply(this,arguments)},destroy:function(){this.removePlottedValueEditView();arguments.callee.base.apply(this,arguments)},removePlottedValueEditView:function(){if(this.plottedValueEditView){this.plottedValueEditView.removeFromParent();this.plottedValueEditView.destroy();this.plottedValueEditView=null}},setupAxes:function(){},getAxisViewDescriptions:function(){return[]},axisBoundsDidChange:function(){this._isRenderingValid=false;this.displayDidChange()}.observes("xAxisView.model.lowerBound","xAxisView.model.upperBound","yAxisView.model.lowerBound","yAxisView.model.upperBound",".model.axisBounds"),updateAdornments:function(){var b=this.plottedCountAdorn&&this.plottedCountAdorn.get("model");if(b){this.plottedCountAdorn.get("model").setComputingNeeded();this.plottedCountAdorn.updateToModel()}var a=this.get("plottedValueAdorn");if(a){a.updateToModel()}},rescaleOnParentCaseCompletion:function(f){var a=f&&f.length,b=a&&f[a-1],c=b&&b.get("id"),e=this.getPath("model.openParentCaseID");if(!SC.none(c)&&(c===e)){var d=this.get("model");if(d&&d.rescaleAxesFromData){d.rescaleAxesFromData(false,false)}this.setPath("model.openParentCaseID",null)}},initializeAdornments:function(){this.plottedCountChanged();var a=this.get("model"),b=a&&a._adornmentModels;DG.ObjectMap.forEach(b,function(c,d){a.notifyPropertyChange(c)});this._areAdornmentsInitialized=true},doDraw:function doDraw(b,a){if(!SC.none(b)){this.set("plotIndex",b);this.set("numPlots",a)}if(!this._areAdornmentsInitialized){this.initializeAdornments()}else{this.updateAdornments()}},getElementPositionsInParentFrame:function(){var a=this.get("frame"),b=this.get("plottedElements");DG.assert(b.length===0||b[0][0].constructor!==SVGRectElement,"Expecting circle, not rect");return b.map(function(c){var d=(c.isHidden()?0:c.attr("r"));return{cx:c.attr("cx")+a.x,cy:c.attr("cy")+a.y,r:d,fill:c.attr("fill"),type:"circle"}})},getTransferredElementsViewCoords:function(){var a=this.get("transferredElementCoordinates"),b=this.get("frame");if(a&&b){a.forEach(function(c,d){if(c.cx!=null){c.cx-=b.x}if(c.cy!=null){c.cy-=b.y}if(c.x!=null){c.x-=b.x}if(c.y!=null){c.y-=b.y}})}return a},createAnimatingElement:function(b,c,d){var a=this.callCreateElement(b,c,false);d&&a.attr(d);return a},animateFromTransferredElements:function(){var d=this.getPath("model.cases"),m=this.createRenderContext(),a=this.getTransferredElementsViewCoords(),k=a.length>0&&a[0].type,h=[],l=[],n=[];if(!d||!m){return}function c(p){return a[p]}function o(p){return a[l[p]]}this._getTransferredElementsToCasesMap(l,n);this.set("transferredElementCoordinates",null);var b=l.length>0,e=n.length>0,j=(b?o:c),i=false;this._elementOrderIsValid=false;DG.sounds.playMixup();this.prepareToResetCoordinates();if(k!==this.get("plottedElementType")){this.removePlottedElements(true);this.get("plottedElements").forEach(function(p){p.remove()});this.get("plottedElements").length=0}var f=function(q,s,r){if(this.isDestroyed){return}var u=j(s),p=false,t;this.createAnimatingElement(q,s,u);if(!SC.none(u)){p=true;if(r){t=function(){this.setPath("model.isAnimating",false);this.drawData()}.bind(this)}}u=this.setCircleCoordinate(m,q,s,p,t);if(u&&t){i=true}if(e){h.push(u)}return this.getPath("model.isAnimating")}.bind(this),g=function(){if(!i){this.setPath("model.isAnimating",false)}if(e){a.forEach(function(r,s){var q=n[s],p=h[q];if(SC.none(q)||SC.none(p)||(r.r===0)){return}this.vanishPlottedElement(r,p)})}this.notifyPropertyChange("plotDisplayDidChange")}.bind(this);this.setPath("model.isAnimating",true);d.forEachWithInvokeLater(f,g)},_getTransferredElementsToCasesMap:function(m,c){var p=this.get("transferredElementCoordinates"),f=this.getPath("model.cases"),j=this.getPath("model.collectionClient"),h=this.getPath("model.dataContext.childCollection"),d=this.getPath("model.dataContext.parentCollection"),l=d?d.getCaseCount():0,e=h?h.getCaseCount():0,o=f?f.get("length"):0,b=p.length;function g(){return(d&&(l===b)&&(j&&j.isDescendantOf(d)))}function k(){return(h&&(e===b)&&(j&&j.isAncestorOf(h)))}function i(r){var q=d.getCaseAt(r),s=q&&q.get("children");if(s){s=s.filter(function(t){return f.indexOf(t)>=0});return s.get("length")}else{return 0}}function n(s,q){var u,r,t;for(u=0;u<b;++u){t=i(u);for(r=0;r<t;++r){s.push(u)}}if(!DG.assert(s.length===o,"Parent/Child case mismatch")){s.length=0}DG.assert(q.length===0,"another parent/child case mismatch")}function a(u,s){var w,t,v,r,q;w=0;for(t=0;t<o;++t){v=i(t);u.push((v>0)?w:undefined);for(r=0;r<v;++r){q=((r===0)?undefined:u.length-1);s.push(q);++w}}}if(g()){n(m,c)}else{if(k()){a(m,c)}}},prepareForConfigurationChange:function(){this.set("cachedPointCoordinates",this.getElementPositionsInParentFrame())},handleConfigurationChange:function(){if(this.get("allowTransferAnimation")&&!this.get("transferredElementCoordinates")){this.set("transferredElementCoordinates",this.get("cachedPointCoordinates"))}},handleBackgroundClick:function(a){},handleBackgroundDblClick:function(a){},getAttributeColor:function(){var a=this.get("plotIndex"),b=this.get("numPlots");return SC.none(a)||(a===0)?null:DG.ColorUtilities.calcAttributeColorFromIndex(a,b)},getPointColor:function(){var a=this.get("model");return a.getPointColor?a.getPointColor():DG.PlotUtilities.kDefaultPointColor},createRenderContext:function(){var e=this.get("model"),g=e.get("dataConfiguration"),c=g.get("legendAttributeDescription"),b=e.getPath("verticalAxisIsY2")?"y2VarID":"yVarID",f=this.getStrokeParams(),d=c&&c.get("isNumeric"),a=(d)?g.get("legendQuantiles"):[];this._pointRadius=this.calcPointRadius();return{casesAdded:true,casesRemoved:true,updatedColors:true,updatedPositions:true,xAxisView:this.get("xAxisView"),yAxisView:this.get("yAxisView"),xVarID:e.get("xVarID"),yVarID:e.get(b),legendDesc:c,legendVarID:c&&c.get("attributeID"),pointColor:this.getPointColor(),transparency:e.getTransparency?e.getTransparency():DG.PlotUtilities.kDefaultPointOpacity,strokeTransparency:f.strokeTransparency,attrColor:this.getAttributeColor(),calcCaseColorString:function(j){DG.assert(j);var h=d?j.getForcedNumericValue(this.legendVarID):j.getValue(this.legendVarID),i=DG.ColorUtilities.calcCaseColor(h,this.legendDesc,this.attrColor||this.pointColor,a);return i.colorString||i},calcStrokeColorString:function(h){if(f.strokeSameAsFill){return this.calcCaseColorString(h)}else{return f.strokeColor}}}},plottedCountChanged:function(){var a=this.getPath("model.plottedCount");if(a.get("isVisible")){a.setComputingNeeded()}if(this.plottedCountAdorn){this.plottedCountAdorn.destroy();this.plottedCountAdorn=null}if(a&&this.get("paper")){this.plottedCountAdorn=DG.PlottedCountAdornment.create({parentView:this,valueAxisView:this.get("primaryAxisView"),model:a,paperSource:this.get("paperSource"),layerName:DG.LayerNames.kAdornments});this.plottedCountAdorn.updateToModel()}}.observes("*model.plottedCount"),plottedValueChanged:function(){var b=this.get("model"),f=b&&b.getAdornmentModel("plottedValue"),a=this.get("plottedValueAdorn"),c=DG.PlottedFormulaEditContext.hasFormulaEditContextFor(f),d=this.get("plottedValueEditView"),e=f&&f.get("isVisible");if(d&&!e){d.set("isVisible",false)}if(!c&&d){this.removePlottedValueEditView();d=null}if(f){if(f&&!d){d=DG.PlottedValueAdornment.createFormulaEditView(f);this.set("plottedValueEditView",d);this.setPath("parentView.plottedValueEditorView",d)}d.set("isVisible",f.get("isVisible"));if(a){a.set("parentView",this);a.set("model",f);a.set("paperSource",this.get("paperSource"))}else{a=DG.PlottedValueAdornment.create({parentView:this,model:f,paperSource:this.get("paperSource"),layerName:DG.LayerNames.kAdornments});this.set("plottedValueAdorn",a)}}else{if(a){a.destroy();this.set("plottedValueAdorn",null)}}}.observes("*model.plottedValue"),categoriesDidChange:function(a,b){},didCreateLayer:function(){this.plottedCountChanged()}});sc_require("components/graph/plots/plot_view");DG.ChartView=DG.PlotView.extend({displayProperties:["xAxisView.model.numberOfCells","yAxisView.model.numberOfCells"],cleanupFunc:function(){this.computeCellParams();this.displayDidChange()},setupAxes:function(){this.setPath("xAxisView.centering",true);this.setPath("yAxisView.centering",true)},primaryAxisView:function(){return(this.getPath("model.orientation")===DG.GraphTypes.EOrientation.kVertical)?this.get("xAxisView"):this.get("yAxisView")}.property("orientation","yAxisView","xAxisView"),secondaryAxisView:function(){return(this.getPath("model.orientation")===DG.GraphTypes.EOrientation.kVertical)?this.get("yAxisView"):this.get("xAxisView")}.property("orientation","yAxisView","xAxisView"),dataDidChange:function(b,c,a){if(!this.getPath("model.dataConfiguration")){return}if(a!=="createCase"&&a!=="createCases"){this.get("model").invalidateCaches()}this._elementOrderIsValid=false;if(c==="hiddenCases"){this.updateSelection()}this.installCleanup()},createRenderContext:function(){var a=arguments.callee.base.apply(this,arguments);a.primaryAxisView=this.get("primaryAxisView");a.secondaryAxisView=this.get("secondaryAxisView");a.isVerticalOrientation=this.getPath("model.orientation")===DG.GraphTypes.EOrientation.kVertical;a.cellHalfWidth=a.secondaryAxisView.get("fullCellWidth")/2;return a},doDraw:function doDraw(){arguments.callee.base.apply(this,arguments);if(!this.getPath("model._cacheIsValid")){this.updateElements()}this.drawData()},updateElements:function(){this.updateAdornments()},drawData:function drawData(){if(SC.none(this.get("paper"))){return}if(this.getPath("model.isAnimating")){return}if(!SC.none(this.get("transferredElementCoordinates"))){this.animateFromTransferredElements();return}var f=this,c=this.get("model"),e=c.get("cases"),a=this.get("plottedElements"),b=a.length,d;if(!e){return}d=this.createRenderContext();this.computeCellParams();e.forEach(function(g,h){var i=c.lookupCellForCaseIndex(h);if(h>=b){f.callCreateElement(g,h)}f.privSetElementCoords(d,g,h,i)})},privSetElementCoords:function(f,c,d,b,a,e){}});sc_require("components/graph/plots/chart_view");DG.BarChartBaseView=DG.ChartView.extend({plottedElementType:"rect",barSliceHeights:null,_categoryCellToolTip:null,categoryCellToolTip:function(){if(!this._categoryCellToolTip){this._categoryCellToolTip=DG.ToolTip.create({paperSource:this,layerName:"dataTip"})}return this._categoryCellToolTip}.property(),_coverRectsLayer:null,coverRectsLayer:function(){if(!this._coverRectsLayer&&this.getPath("paperSource.layerManager")){this._coverRectsLayer=this.getPath("paperSource.layerManager."+DG.LayerNames.kCoverRects)}return this._coverRectsLayer}.property(),upperBoundDidChange:function(){this.computeCellParams();this.displayDidChange()}.observes("*secondaryAxisView.model.upperBound"),init:function(){arguments.callee.base.apply(this,arguments);this.barSliceHeights=[]},destroy:function(){var b=this.get("layerManager"),a=this.get("plottedElements");a.forEach(function(c){b.removeElement(c,true)});a.length=0;this.get("coverRectsLayer").clear();arguments.callee.base.apply(this,arguments)},dataRangeDidChange:function(c,g,b,e){var h=this,f=this.getPath("model.cases"),d=this.createRenderContext(),a=(SC.typeOf(e)===SC.T_NUMBER?[e]:e);a=a||[];this.model.invalidateCaches();this.computeCellParams();a.forEach(function(i){if(!h.get("plottedElements")[i]){h.callCreateElement(f.at(i),i,h._createAnimationOn)}var j=h.get("model").lookupCellForCaseIndex(i);h.privSetElementCoords(d,f.at(i),i,j)});arguments.callee.base.apply(this,arguments)},createRenderContext:function(){var a=arguments.callee.base.apply(this,arguments);a.barSliceHeights=this.get("barSliceHeights");a.barWidth=a.primaryAxisView.get("fullCellWidth")/2;a.zeroOnSecondaryAxis=a.secondaryAxisView.dataToCoordinate(0);return a},cleanupFunc:function(){this.get("model").rescaleAxesFromData(true,true);arguments.callee.base.apply(this,arguments)},getToolTipText:function(a,d,c,b){return""},createElement:function(b,c,a){if(!this.get("paper")){return}var d=this.get("paper").rect(-1000,-1000,0,0).attr({fill:DG.PlotUtilities.kDefaultPointColor,stroke:"none"});d.node.setAttribute("shape-rendering","geometricPrecision");return d},updateAllCoordinates:function(a,e){var c=this.get("model"),d=this.createRenderContext(),f=this.getPath("model.cases"),b=f&&f.get("length");f.forEach(function(g,h){var j=h===b-1?e:null,i=c.lookupCellForCaseIndex(h);this.privSetElementCoords(d,g,h,i,a,j)}.bind(this))},updateElements:function(j,a){if(!this.get("paper")){return}arguments.callee.base.apply(this,arguments);this.computeCellParams();var h=this.get("model"),c=this.getPath("model.cases"),g=this.createRenderContext(),e=c&&c.get("length"),d=this.get("plottedElements"),k=d.length,b=this.get("layerManager"),i,f;if(e>k){for(i=k;i<e;i++){this.callCreateElement(c.at(i),i,this.animationIsAllowable());f=h.lookupCellForCaseIndex(i);this.privSetElementCoords(g,c.at(i),i,f,j,a)}}if(e<k){for(i=e;i<k;i++){if(!SC.none(d[i])){d[i].stop();DG.PlotUtilities.doHideRemoveAnimation(d[i],b)}}this.updateAllCoordinates(j,a)}this._isRenderingValid=false},drawData:function drawData(){arguments.callee.base.apply(this,arguments);this.drawSubBars()},drawSubBars:function(){var b=function(l,w,q,k,x,p,z,s){var o=this,y,j,B=h?x:s,v=this.getBarHeight(z,q,B),n=e.secondaryAxisView.dataToCoordinate(v),u,t,m,r;if(e.isVerticalOrientation){u=l-e.barWidth/2-1;t=v<0?w:n-1;m=e.barWidth+2;r=Math.abs(w-n+2)}else{u=v<0?n-1:w;t=l-e.barWidth/2-1;m=Math.abs(n+2-w);r=e.barWidth+2}var A=c.rect(u,t,m,r).attr({stroke:"none",fill:"white","fill-opacity":0.001,cursor:"pointer"}).hover(function(C){this.animate({"fill-opacity":0.4},DG.PlotUtilities.kDataTipShowTime);j=o.get("categoryCellToolTip");y=o.getToolTipText(z,p,s,this);j.set("text",y);j.set("tipOrigin",{x:C.layerX,y:C.layerY});j.show()},function(C){this.stop();this.animate({"fill-opacity":0.001},DG.PlotUtilities.kHighlightHideTime);if(j){j.hide()}}).mousedown(function(C){SC.run(function(){o.get("model").selectCasesWithIndices(this.caseIndices,C.shiftKey)}.bind(this))});A.caseIndices=k;A.numCasesInContainingCell=x;i.push(A);return n}.bind(this);var c=this.get("paper"),i=this.get("coverRectsLayer"),d=this.getPath("model.validCachedCells"),e=this.createRenderContext(),f=this.getPath("model.primaryVarID"),g=this.getPath("model.legendVarID"),h=!SC.none(g),a=this.getPath("model.cases").length();i.clear();d.forEach(function(l,m){var j=e.primaryAxisView.cellToCoordinate(m),k=l[0][0].theCase.getValue(f);l.forEach(function(n,w){var v=0,q=n.length,r=h?q:a,t=this.getBarHeight(k,v,r),s=e.secondaryAxisView.dataToCoordinate(t),u=null,p=[],o;n.forEach(function(x,y){o=x.theCase.getValue(g);if(u&&o!==u){s=b(j,s,v,p,q,u,k,r);p=[]}p.push(x.caseIndex);v++;u=o}.bind(this));b(j,s,v,p,q,o,k,a)}.bind(this))}.bind(this))},getElementPositionsInParentFrame:function(){var a=this.get("frame");return this.get("plottedElements").map(function(d){var i=d.attr("x")+a.x,h=d.attr("y")+a.y,e=d.attr("width"),j=d.attr("height"),b=0,g=i+e/2,f=h+j/2,c={x:i,y:h,width:e,height:j,cx:g,cy:f,r:b,fill:d.attr("fill"),type:"rect",stroke:d.attr("stroke"),"stroke-opacity":d.attr("stroke-opacity")};return c})},animateFromTransferredElements:function(){var i=this,q=this.get("model"),m=q.get("cases"),o=this.createRenderContext(),a=this.get("frame"),e=this.get("transferredElementCoordinates"),j=[],f=[],b=[],p=e[0]&&e[0].type==="circle";if(!m){return}function d(){q.set("isAnimating",false);i.get("plottedElements").forEach(function(s){s.stop()});i.displayDidChange()}function g(s){return e[s]}function k(s){return e[f[s]]}DG.sounds.playMixup();this._getTransferredElementsToCasesMap(f,b);var l=f.length>0,c=b.length>0,r=(l?k:g),n=this.get("plottedElements"),h;this.prepareToResetCoordinates();this.removePlottedElements();n.forEach(function(s){s.remove()});n.length=0;this.computeCellParams();e.forEach(function(t,s){t.cx-=a.x;t.cy-=a.y;t.x-=a.x;t.y-=a.y});m.forEach(function(t,u){var w=r(u),v=q.lookupCellForCaseIndex(u),s=i.callCreateElement(t,u,false);if(!SC.none(w)){h={r:p?w.r:0,x:p?w.cx-w.r:w.x,y:p?w.cy-w.r:w.y,width:p?2*w.r:w.width,height:p?2*w.r:w.height,fill:w.fill,stroke:w.fill};s.attr(h)}s=i.privSetElementCoords(o,t,u,v,true);if(c){j.push(s)}});if(c){e.forEach(function(u,v){var t=b[v],s=j[t];if(SC.none(t)||SC.none(s)||(u.r===0)){return}i.vanishPlottedElement(u,s)})}this.set("transferredElementCoordinates",null);q.set("isAnimating",true);SC.Timer.schedule({action:d,interval:DG.PlotUtilities.kDefaultAnimationTime})}});sc_require("formula/collection_formula_context");DG.BarChartFormulaContext=DG.CollectionFormulaContext.extend((function(){return{plotModel:null,primaryVarName:function(){var a=this.getPath("plotModel.primaryVarID"),b=a&&DG.Attribute.getAttributeByID(a),c=b&&b.get("name");return c||null}.property("plotModel"),isPrimaryVarName:function(a){return !!a&&(a===this.get("primaryVarName"))}.property("primaryVarName"),groupVarID:function(){return this.getPath("plotModel.primaryVarID")||-1}.property("plotModel"),filterCase:function(a){var c=arguments.callee.base.apply(this,arguments),b=this.getPath("plotModel.cases");return c&&b.indexOf(a._case_)>=0},didCompile:function(){arguments.callee.base.apply(this,arguments);var a=this.get("plotModel"),b=DG.Debug.scObjectID(a);this.registerDependency({independentSpec:{type:DG.DEP_TYPE_PLOT,id:b,name:"plot-"+b},aggFnIndices:this.ALL_FUNCTIONS})},invalidateDependent:function(d,a,c,b,e){arguments.callee.base.apply(this,arguments);if(c.aggFnIndices){this.invalidateFunctions(c.aggFnIndices)}this.notifyPropertyChange("dependentChange")}}}()));DG.BarChartFormulaEditContext=DG.PlottedFormulaEditContext.extend({plotModel:null,openFormulaEditorDialog:function(){var f=this,b=this.getPath("plotModel.dataContext"),a=DG.AttributeFormulaView.buildOperandsMenuAndCompletionData(b),d=this.get("clientOptions"),c=Object.assign({applyTarget:f,applyAction:"applyNewFormula",attrNamePrompt:"DG.PlottedFormula.defaultNamePrompt".loc(),attrNameValue:"",attrNameIsEnabled:false,formulaValue:f.getPath("plotModel.expression"),formulaCompletions:a.completionData,formulaOperands:a.operandsMenu},d),e=DG.CreateAttributeFormulaView(c);this.set("formulaDialog",e);return e},createEditCommand:function(c){var b=this.get("clientOptions"),d=this.getPath("plotModel.expression");var a=function a(e){this.setPath("plotModel.expression",e)}.bind(this);return DG.Command.create({isUndoable:b.isUndoable,name:b.commandName,undoString:b.undoString,redoString:b.redoString,log:b.logMessage&&b.logMessage.fmt(d,c),execute:function(){a(c)},undo:function(){a(d)},redo:function(){a(c)}})},applyNewFormula:function(){var b=this.createEditCommand(this.getPath("formulaDialog.formula"));if(b.isUndoable){DG.UndoHistory.execute(b)}else{b.execute()}var a=this.get("formulaDialog");if(a){a.close();this.set("formulaDialog",null)}}});DG.BarChartFormulaEditContext.formulaEditContexts={};DG.BarChartFormulaEditContext.hasFormulaEditContextFor=function(a){return a&&!SC.none(DG.BarChartFormulaEditContext.formulaEditContexts[DG.Debug.scObjectID(a)])};DG.BarChartFormulaEditContext.getFormulaEditContext=function(a){var b=DG.Debug.scObjectID(a);if(!DG.BarChartFormulaEditContext.formulaEditContexts[b]){DG.BarChartFormulaEditContext.formulaEditContexts[b]=DG.BarChartFormulaEditContext.create({plotModel:a})}return DG.BarChartFormulaEditContext.formulaEditContexts[b]};DG.BarChartFormulaEditContext.destroyFormulaEditContext=function(b){var a=DG.BarChartFormulaEditContext.formulaEditContexts[b];if(a){a.destroy();delete DG.BarChartFormulaEditContext.formulaEditContexts[b]}};sc_require("components/graph/plots/bar_chart_base_model");DG.BarChartModel=DG.BarChartBaseModel.extend({getDesiredAxisClassFor:function(a){if(a===this.get("secondaryAxisPlace")){return DG.CountAxisModel}return arguments.callee.base.apply(this,arguments)},naturalUpperBound:function(){var a,b=this.get("maxInCell"),c=!SC.none(this.get("legendVarID"));switch(this.get("breakdownType")){case DG.Analysis.EBreakdownType.eCount:a=Math.max(4,b);break;case DG.Analysis.EBreakdownType.ePercent:a=c?100:100*b/this.get("cases").length();break}return 1.05*a}.property("breakdownType"),breakdownTypeDidChange:function(){this.setPath("secondaryAxisModel.scaleType",this.get("breakdownType"))}.observes("breakdownType"),getDataMinAndMaxForDimension:function(a){var b={min:0,max:this.get("naturalUpperBound"),isDataInteger:this.get("breakdownType")===DG.Analysis.EBreakdownType.eCount};return b}});sc_require("components/graph/plots/bar_chart_base_view");DG.BarChartView=DG.BarChartBaseView.extend({setupAxes:function(){arguments.callee.base.apply(this,arguments);var a=this.get("secondaryAxisView");if(a&&SC.none(a.getPath("model.lowerBound"))){a.get("model").setLowerAndUpperBounds(0,this.getPath("model.naturalUpperBound"))}},getAxisViewDescriptions:function(){var b=arguments.callee.base.apply(this,arguments),a=this.getPath("model.orientation")===DG.GraphTypes.EOrientation.kVertical?"y":"x";b.push({axisKey:a,axisClass:DG.CountAxisView});return b},getBarHeight:function(a,c,b){return this.getPath("model.breakdownType")===DG.Analysis.EBreakdownType.eCount?c:100*c/b},privSetElementCoords:function(f,a,j,o,p,b){DG.assert(f&&f.xAxisView);DG.assert(a);DG.assert(DG.MathUtilities.isInIntegerRange(j,0,this.get("plottedElements").length));var q=this.get("plottedElements")[j];if(!o){return}var e=f.barWidth,c=f.secondaryAxisView.get("fullCellWidth"),n=f.barSliceHeights[o.primaryCell],i=(o.indexInCell+1)*n,g=f.primaryAxisView.cellToCoordinate(o.primaryCell)-e/2,m,l,h,k;if(f.isVerticalOrientation){m=g;l=c-i;h=e;k=n}else{m=i-n;l=g;h=n;k=e}var d={x:m,y:l,r:0.1,width:h,height:k,fill:f.calcCaseColorString(a),opacity:f.transparency,"fill-opacity":f.transparency,"stroke-opacity":0};q.show();if(p){q.animate(d,DG.PlotUtilities.kDefaultAnimationTime,"<>",b)}else{q.attr(d)}return q},computeCellParams:function(){var g=this.getPath("model.maxInCell"),a=this.getPath("model.cases").length(),j=!SC.none(this.getPath("model.legendVarID")),m=100*g/a,l=this.get("secondaryAxisView"),e=l.dataToCoordinate(g),d=l.dataToCoordinate(100),c=l.dataToCoordinate(m),k=l.dataToCoordinate(0),i=this.getPath("model.breakdownType"),b=Math.abs(e-k)/g,h=Math.abs(c-k)/g,f=this.getPath("model.primaryCellCounts").map(function(o){var n=0;switch(i){case DG.Analysis.EBreakdownType.eCount:n=b;break;case DG.Analysis.EBreakdownType.ePercent:n=j?Math.abs(d-k)/o:h}return n});this.setIfChanged("barSliceHeights",f)},getToolTipText:function(d,g,f,e){var c=this.getPath("model.legendVarID"),b,a;if(!SC.none(c)){b=e.caseIndices.length>1?"DG.BarChartModel.cellTipPlural":"DG.BarChartModel.cellTipSingular";if(this.numCasesInContainingCell>1){d=pluralize(d);if(d.endsWith("S")){d=d.replace(/S$/,"s")}}a=b.loc(e.caseIndices.length,e.numCasesInContainingCell,d,Math.round(1000*e.caseIndices.length/e.numCasesInContainingCell)/10,g)}else{b=e.caseIndices.length>1?"DG.BarChartModel.cellTipNoLegendPlural":"DG.BarChartModel.cellTipNoLegendSingular";a=b.loc(e.caseIndices.length,f,Math.round(1000*e.caseIndices.length/f)/10,d)}return a}});sc_require("components/graph/plots/plot_model");sc_require("components/graph/plots/numeric_plot_model_mixin");DG.UnivariatePlotModel=DG.PlotModel.extend(DG.NumericPlotModelMixin,{displayAsBinned:null,primaryVarID:function(){return(this.get("primaryAxisPlace")===DG.GraphTypes.EPlace.eX)?this.get("xVarID"):this.get("yVarID")}.property("primaryAxisPlace","xVarID","yVarID"),primaryAxisPlace:function(){var a=this.get("dataConfiguration");return a&&a.getPlaceForRole(DG.Analysis.EAnalysisRole.ePrimaryNumeric)}.property("xVarID","yVarID"),secondaryAxisPlace:function(){var a=this.get("dataConfiguration");return a&&a.getPlaceForRole(DG.Analysis.EAnalysisRole.eSecondaryCategorical)}.property("xVarID","yVarID"),primaryAxisModel:function(){return this.getAxisForPlace(this.get("primaryAxisPlace"))}.property("primaryAxisPlace","xAxis","yAxis"),secondaryAxisModel:function(){return this.getAxisForPlace(this.get("secondaryAxisPlace"))}.property("secondaryAxisPlace","xAxis","yAxis"),orientation:function(){return(this.get("primaryAxisPlace")===DG.GraphTypes.EPlace.eX)?DG.GraphTypes.EOrientation.kVertical:DG.GraphTypes.EOrientation.kHorizontal}.property("primaryAxisPlace"),destroy:function(){this.invalidateComputationContext();arguments.callee.base.apply(this,arguments)},handleDataConfigurationChange:function(c){if(!DG.assert(!this.get("isDestroyed"),"DG.DotPlotModel.handleDataConfiguration() shouldn't be triggered after destroy()!")){return}arguments.callee.base.apply(this,arguments);var b=true,a=false;this.rescaleAxesFromData(c!=="hiddenCases",b,a);this.updateAdornmentModels()},invalidateCaches:function(a){arguments.callee.base.apply(this,arguments);this.invalidateComputationContext()},_cachedComputationContext:null,computationContext:function(){if(!this._cachedComputationContext){this._cachedComputationContext={primaryAxis:this.get("primaryAxisModel"),secondaryAxis:this.get("secondaryAxisModel"),primaryVarID:this.get("primaryVarID"),secondaryVarID:this.get("secondaryVarID"),legendVarID:this.get("legendVarID")}}return this._cachedComputationContext}.property("primaryAxisModel","secondaryAxisModel","primaryVarID","secondaryVarID","legendVarID"),invalidateComputationContext:function(){this._cachedComputationContext=null}.observes("primaryAxisModel","secondaryAxisModel","primaryVarID","secondaryVarID","legendVarID"),doForOneCase:function(a,e,g,i){var h=a.getValue(g.primaryVarID),b=SC.none(g.primaryVarID)||!SC.none(h),c=a.getValue(g.secondaryVarID),f=SC.none(g.secondaryVarID)||!SC.none(c),j,d;if(b&&f){j=g.primaryAxis.valueToCellNumber(h);d=g.secondaryAxis.cellNameToCellNumber(c);i(a,e,j,d)}},forEachBivariateCaseDo:function(a,b){var c=b?this.get("selection"):this.get("cases"),d=this.get("computationContext");if(!d.primaryAxis||!c||!d.secondaryAxis){return}c.forEach(function(e,f){this.doForOneCase(e,f,d,a)}.bind(this))},getCellCaseCounts:function(e){var d=this.get("primaryAxisModel"),f=this.get("secondaryAxisModel"),a=[];if(!(f&&d)){return a}var c=f.get("numberOfCells"),j=d.get("numberOfCells"),h=c*j,g;for(var b=0;b<h;++b){a.push({count:0,selectedCount:0,primaryCell:Math.floor(b/c),secondaryCell:b%c})}this.forEachBivariateCaseDo(function(k,l,i,m){g=i*c+m;if(isFinite(g)&&DG.MathUtilities.isInIntegerRange(g,0,h)){var n=a[g];n.count+=1;DG.assert(n.primaryCell===(i||0),"primary cell index error in DG.UnivariatePlotModel.getCellCaseCounts()");DG.assert(n.secondaryCell===(m||0),"secondary cell index error in DG.UnivariatePlotModel.getCellCaseCounts()")}});if(e){this.forEachBivariateCaseDo(function(k,l,i,m){g=i*c+m;if(isFinite(g)&&DG.MathUtilities.isInIntegerRange(g,0,h)){var n=a[g];n.selectedCount+=1}},e)}return a},canSupportConfigurations:function(){return true}.property(),configurationDescriptions:function(){var c=this,b=20,a=arguments.callee.base.apply(this,arguments);a.push({constructorClass:SC.RadioView,properties:{layout:{height:3*b},items:[{title:"DG.Inspector.graphPlotPoints".loc(),value:false,enabled:YES},{title:"DG.Inspector.graphGroupIntoBins".loc(),value:true,enabled:YES},{title:"DG.Inspector.graphBarForEachPoint".loc(),value:"bars",enabled:YES}],value:c.get("displayAsBinned"),valueDidChange:function(){var d=this.get("value");c.set("displayAsBinned",d);DG.mainPage.mainPane.hideInspectorPicker()}.observes("value"),itemTitleKey:"title",itemValueKey:"value",itemIsEnabledKey:"enabled",isEnabled:YES,layoutDirection:SC.LAYOUT_VERTICAL}});return a}.property()});DG.UnivariatePlotModel.configureRoles=function(b){var d=b.get("xType"),c=d===DG.Analysis.EAttributeType.eNumeric||d===DG.Analysis.EAttributeType.eDateTime,e=c?"x":"y",a=(e==="x")?"y":"x";b.setPath(e+"AttributeDescription.role",DG.Analysis.EAnalysisRole.ePrimaryNumeric);b.setPath(a+"AttributeDescription.role",DG.Analysis.EAnalysisRole.eSecondaryCategorical)};sc_require("components/graph/plots/univariate_plot_model");DG.UnivariateAdornmentBaseModel=DG.UnivariatePlotModel.extend({multipleMovableValuesModel:function(){var a=this.getAdornmentModel("multipleMovableValues");if(!a){a=DG.MultipleMovableValuesModel.create({plotModel:this,axisModel:this.get("primaryAxisModel")});a.addObserver("values",this,"valuesDidChange");this.setAdornmentModel("multipleMovableValues",a)}return a}.property(),isShowingMovableValues:function(){return this.getPath("multipleMovableValuesModel.valueModels").length>0}.property(),wantsPercentCheckbox:function(){return this.get("isShowingMovableValues")||this.get("enableMeasuresForSelection")}.property(),showMeasureLabels:false,destroy:function(){var a=this.getAdornmentModel("multipleMovableValues");if(a){a.removeObserver("valueModels",this,"valuesDidChange")}arguments.callee.base.apply(this,arguments)},togglePlottedCount:function(e){if(!this.get("isShowingMovableValues")){arguments.callee.base.apply(this,arguments);return}var f=this;function a(){function g(j){var i=j.get("multipleMovableValuesModel"),h=i.get("isShowing"+e);i.setComputingNeeded();i.set("isShowing"+e,!h)}g(f);f.get("siblingPlots").forEach(g)}var c=this.getPath("multipleMovableValuesModel.isShowing"+e),b=c?("DG.Undo.graph.hide"+e):("DG.Undo.graph.show"+e),d=c?("DG.Redo.graph.hide"+e):("DG.Redo.graph.show"+e);DG.UndoHistory.execute(DG.Command.create({name:"graph.toggleCount",undoString:b,redoString:d,log:("togglePlotted"+e+": %@").fmt(c?"hide":"show"),executeNotification:{action:"notify",resource:"component",values:{operation:"toggle movable value",type:"DG.GraphView"}},execute:function(){a()}.bind(this),undo:function(){a()}.bind(this)}))},shouldPlottedCountBeChecked:function(a){if(this.get("isShowingMovableValues")){return this.getPath("multipleMovableValuesModel.isShowing"+a)}else{return arguments.callee.base.apply(this,arguments)}},addMovableValue:function(){var d=this,c=[];function b(){function e(l,m){var n=m+1,h=l.get("multipleMovableValuesModel"),f=h.get("valueModels").length,j=l.get("plottedCount"),g=(f===0)&&j&&j.get("isShowingCount"),i=(f===0)&&j&&j.get("isShowingPercent"),k=c[n];if(k){h.addThisValue(k);c[n]=null}else{k=h.addValue();c[n]=k}if(g){j.set("isShowingCount",false);h.set("isShowingCount",true)}if(i){j.set("isShowingPercent",false);h.set("isShowingPercent",true)}l.notifyPropertyChange("movableValueChange")}e(d,-1);d.get("siblingPlots").forEach(e)}function a(){function e(i,h){var f=h+1,g=c[f];i.getAdornmentModel("multipleMovableValues").removeThisValue(g)}e(d,-1);d.get("siblingPlots").forEach(e)}DG.UndoHistory.execute(DG.Command.create({name:"graph.addMovableValue",undoString:"DG.Undo.graph.addMovableValue",redoString:"DG.Redo.graph.addMovableValue",log:"Added Movable Value",executeNotification:{action:"notify",resource:"component",values:{operation:"add movable value",type:"DG.GraphView"}},execute:b,undo:a}))},removeMovableValue:function(){var g=this,a=this.getAdornmentModel("multipleMovableValues"),d={count:a.get("isShowingCount"),percent:a.get("isShowingPercent")},c=a.get("valueModels").length,b=[];function f(){function h(m,l){var j=l+1,i=m.getAdornmentModel("multipleMovableValues"),n,k=b[j];if(!i){return}if(c===1&&(d.count||d.percents)){n=m.get("plottedCount");n.set("isShowingCount",d.count);n.set("isShowingPercent",d.percent)}if(k){i.removeThisValue(k)}else{b[j]=i.removeValue()}m.notifyPropertyChange("movableValueChange")}h(g,-1);g.get("siblingPlots").forEach(h)}function e(){function h(m,l){var j=l+1,i=m.getAdornmentModel("multipleMovableValues"),k=b[j];if(c===1&&(d.count||d.percents)){i.set("isShowingCount",d.count);i.set("isShowingPercent",d.percent);m.setPath("plottedCount.isShowingCount",false);m.setPath("plottedCount.isShowingPercent",false)}i.addThisValue(k);b[j]=null;m.notifyPropertyChange("movableValueChange")}h(g,-1);g.get("siblingPlots").forEach(h)}DG.UndoHistory.execute(DG.Command.create({name:"graph.removeMovableValue",undoString:"DG.Undo.graph.removeMovableValue",redoString:"DG.Redo.graph.removeMovableValue",log:"Added Movable Value",executeNotification:{action:"notify",resource:"component",values:{operation:"remove movable value",type:"DG.GraphView"}},execute:f,undo:e}))},valuesDidChange:function(){this.notifyPropertyChange("valuesDidChange")},toggleAverage:function(c,b){var d=this;function a(){function e(g){var f=g.toggleAdornmentVisibility(c,b);if(f){if(f.get("isVisible")){f.recomputeValue()}else{f.setComputingNeeded()}}}e(d);d.get("siblingPlots").forEach(e);return d.getAdornmentModel(c).get("isVisible")}DG.UndoHistory.execute(DG.Command.create({name:"graph."+b,undoString:null,log:b,executeNotification:{action:"notify",resource:"component",values:{operation:b,type:"DG.GraphView"}},execute:function(){var f=a(),g=f?"show":"hide",e=b.replace("toggle",g);this.set("undoString","DG.Undo.graph."+e);this.set("redoString","DG.Redo.graph."+e)},undo:function(){a()}}))},setNumStdErrs:function(b){var c=this,a="graph.setNumStdErrs: %@".fmt(b);DG.UndoHistory.execute(DG.Command.create({name:"graph.setNumStdErrs",undoString:"DG.Undo.graph.setNumStErrs",redoString:"DG.Redo.graph.setNumStErrs",log:a,executeNotification:{action:"notify",resource:"component",values:{operation:"setNumStdErrs",type:"DG.GraphView"}},execute:function(){this._numStdErrs=c.getAdornmentModel("plottedStErr").get("numberOfStdErrs");c.getAdornmentModel("plottedStErr").set("numberOfStdErrs",b)},undo:function(){var d=c.getAdornmentModel("plottedStErr").get("numberOfStdErrs");c.getAdornmentModel("plottedStErr").set("numberOfStdErrs",this._numStdErrs);this._numStdErrs=d},redo:function(){this.undo()}}))},togglePlottedMean:function(){this.toggleAverage("plottedMean","togglePlottedMean")},togglePlottedMedian:function(){this.toggleAverage("plottedMedian","togglePlottedMedian")},togglePlottedStDev:function(){this.toggleAverage("plottedStDev","togglePlottedStDev")},togglePlottedStErr:function(){this.toggleAverage("plottedStErr","togglePlottedStErr")},togglePlottedMad:function(){this.toggleAverage("plottedMad","togglePlottedMad")},togglePlottedIQR:function(){this.toggleAverage("plottedIQR","togglePlottedIQR")},togglePlottedNormal:function(){this.toggleAverage("plottedNormal","togglePlottedNormal")},togglePlottedBoxPlot:function(){this.toggleAverage("plottedBoxPlot","togglePlottedBoxPlot")},toggleShowOutliers:function(){var b=this;function a(){function c(e){var d=e.getAdornmentModel("plottedBoxPlot");if(d){d.toggleProperty("showOutliers");d.setComputingNeeded()}}c(b);b.get("siblingPlots").forEach(c);return b.getAdornmentModel("plottedBoxPlot").get("showOutliers")}DG.UndoHistory.execute(DG.Command.create({name:"graph.boxPlot.showOutliers",undoString:null,log:"graph.boxPlot.showOutliers",executeNotification:{action:"notify",resource:"component",values:{operation:"toggle show outliers",type:"DG.GraphView"}},execute:function(){var d=a(),e=d?"show":"hide",c="toggleOutliers".replace("toggle",e);this.set("undoString","DG.Undo.graph."+c);this.set("redoString","DG.Redo.graph."+c)},undo:function(){a()}}))},toggleShowICI:function(){var b=this;function a(){function c(e){var d=e.getAdornmentModel("plottedBoxPlot");if(d){d.toggleProperty("showICI");d.setComputingNeeded()}}c(b);b.get("siblingPlots").forEach(c);return b.getAdornmentModel("plottedBoxPlot").get("showICI")}DG.UndoHistory.execute(DG.Command.create({name:"graph.boxPlot.showICI",undoString:null,log:"graph.boxPlot.showICI",executeNotification:{action:"notify",resource:"component",values:{operation:"toggle show outliers",type:"DG.GraphView"}},execute:function(){var d=a(),e=d?"show":"hide",c="toggleICI".replace("toggle",e);this.set("undoString","DG.Undo.graph."+c);this.set("redoString","DG.Redo.graph."+c)},undo:function(){a()}}))},updateAdornmentsModels:function(){arguments.callee.base.apply(this,arguments);["multipleMovableValues","plottedMean","plottedMedian","plottedStDev","plottedStErr","plottedNormal","plottedBoxPlot","plottedCount"].forEach(function(a){var b=this.getAdornmentModel(a);if(b){if(b.setComputingNeeded){b.setComputingNeeded()}if(a==="multipleMovableValues"){b.recomputeValueIfNeeded(this.get("primaryAxisModel"))}else{b.recomputeValueIfNeeded()}}}.bind(this))},onRescaleIsComplete:function(){this.get("multipleMovableValuesModel").handleChangedAxisAttribute()},createStorage:function(){var a=arguments.callee.base.apply(this,arguments);a.showMeasureLabels=this.get("showMeasureLabels");return a},restoreStorage:function(a){arguments.callee.base.apply(this,arguments);this.showMeasureLabels=a.showMeasureLabels||false;var b=this.getAdornmentModel("multipleMovableValues");if(b){b.set("axisModel",this.get("primaryAxisModel"))}},getAdornmentSpecs:function(){var a=arguments.callee.base.apply(this,arguments);DG.ObjectMap.forEach(this._adornmentModels,function(c,b){a.push({key:c,"class":b.constructor,useAdornmentModelsArray:true,storage:b.createStorage()})});return a},installAdornmentModelsFrom:function(a){arguments.callee.base.apply(this,arguments);var b=this.getAdornmentModel("multipleMovableValues");if(b){b.set("axisModel",this.get("primaryAxisModel"))}},createStdErrorOption:function(){function i(){return f.isAdornmentVisible("plottedStErr")}var f=this,k=20,h=5,e=5,c=20,j=this.getAdornmentModel("plottedStErr"),l=j?j.get("numberOfStdErrs"):1,b=l===1?"DG.Inspector.graphPlottedStErr".loc():pluralize("DG.Inspector.graphPlottedStErr".loc()),d=SC.CheckboxView.create({layout:{left:0,top:3,height:c,width:25},localize:true,flowSpacing:{left:k,top:h},title:"",value:this.isAdornmentVisible("plottedStErr"),classNames:"dg-graph-plottedStErr-check dg-ruler-check".w(),valueDidChange:function(){f.togglePlottedStErr();g.set("isEnabled",i())}.observes("value")}),g=SC.TextFieldView.create({layout:{height:c+h,width:50},isEnabled:i(),flowSpacing:{left:0,top:0},supportsAutoResize:true,type:"number",value:l,maxLength:5,valueDidChange:function(){var m=Number(this.get("value"));if(DG.isFinite(m)){if(m>=0){f.setNumStdErrs(m)}else{this.set("value",l)}}}.observes("value")}),a=SC.LabelView.create({layout:{height:c,width:100},value:b,localize:true});this.invokeLater(function(){document.getElementById(g.get("layerId")).style.background="white"},100);return SC.View.create(SC.FlowedLayout,{layoutDirection:SC.LAYOUT_HORIZONTAL,isResizable:false,isClosable:false,layout:{left:0,height:c+h},defaultFlowSpacing:{left:e,top:h},shouldResizeWidth:false,canWrap:false,flowSpacing:{left:0},init:function(){arguments.callee.base.apply(this,arguments);this.appendChild(d);this.appendChild(g);this.appendChild(a)}})},checkboxDescriptions:function(){var e=this,f=[],b=20;function g(){var k=e.get("showMeasureLabels")?"hide":"show";DG.UndoHistory.execute(DG.Command.create({name:"toggle show measure labels",undoString:"DG.Undo.graph."+k+"MeasureLabels",redoString:"DG.Redo.graph."+k+"MeasureLabels",log:k+" measure labels",_redoValue:null,executeNotification:{action:"notify",resource:"component",values:{operation:k+" measure labels",type:"DG.Graph"}},execute:function(){e.toggleProperty("showMeasureLabels")},undo:function(){this.execute()}}))}function c(k,l,n){var m=DG.RulerGroupView.create({title:k.loc(),visibilityStateProperty:l});n.forEach(function(o){if(o.control){m.appendChild(o.control)}else{o.classNames.push("dg-ruler-check");o.layout={height:b};o.localize=true;m.appendChild(SC.CheckboxView.create(o))}}.bind(this));m.syncChildViewVisibility();return m}function h(){var s=20,q=5,l=20,o=e.getAdornmentModel("plottedBoxPlot"),k=DG.get("informalConfidenceIntervalEnabled")==="yes"||(o&&e.getAdornmentModel("plottedBoxPlot").get("showICI")),p=SC.CheckboxView.create({layout:{height:l},localize:true,flowSpacing:{left:2*s},title:"DG.Inspector.graphBoxPlotShowOutliers",value:e.getAdornmentModel("plottedBoxPlot")?e.getAdornmentModel("plottedBoxPlot").get("showOutliers"):false,classNames:"dg-graph-boxPlotShowOutliers-check".w(),valueDidChange:function(){e.toggleShowOutliers()}.observes("value")}),n=SC.CheckboxView.create({layout:{height:l},localize:true,flowSpacing:{left:2*s},title:"DG.Inspector.graphBoxPlotShowICI",value:o?o.get("showICI"):false,classNames:"dg-graph-boxPlotShowICI-check".w(),valueDidChange:function(){e.toggleShowICI()}.observes("value")}),m=SC.CheckboxView.create({layout:{left:s,height:l},localize:true,title:"DG.Inspector.graphPlottedBoxPlot",value:e.isAdornmentVisible("plottedBoxPlot"),classNames:"dg-graph-plottedBoxPlot-check".w(),valueDidChange:function(){e.togglePlottedBoxPlot();p.set("isEnabled",t());n.set("isEnabled",t())}.observes("value")});function t(){return e.isAdornmentVisible("plottedBoxPlot")}var r=SC.View.create(SC.FlowedLayout,{layoutDirection:SC.LAYOUT_VERTICAL,isResizable:false,isClosable:false,layout:{left:s,height:2*(l+q)},defaultFlowSpacing:{left:s,bottom:q},canWrap:false,align:SC.ALIGN_TOP,boxplot:null,showOutliers:null,init:function(){arguments.callee.base.apply(this,arguments);p.set("isEnabled",e.isAdornmentVisible("plottedBoxPlot"));this.appendChild(m);this.appendChild(p);if(k){n.set("isEnabled",e.isAdornmentVisible("plottedBoxPlot"));this.appendChild(n)}}});return r}function d(){return c("DG.Inspector.graphCenterOptions","measuresOfCenter",[{title:"DG.Inspector.graphPlottedMean",value:e.isAdornmentVisible("plottedMean"),classNames:"dg-graph-plottedMean-check".w(),valueDidChange:function(){e.togglePlottedMean()}.observes("value")},{title:"DG.Inspector.graphPlottedMedian",value:e.isAdornmentVisible("plottedMedian"),classNames:"dg-graph-plottedMedian-check".w(),valueDidChange:function(){e.togglePlottedMedian()}.observes("value")}])}function i(){return c("DG.Inspector.graphSpreadOptions","measuresOfSpread",[{title:"DG.Inspector.graphPlottedStDev",value:e.isAdornmentVisible("plottedStDev"),classNames:"dg-graph-plottedStDev-check".w(),valueDidChange:function(){e.togglePlottedStDev()}.observes("value")},{control:e.createStdErrorOption()},{title:"DG.Inspector.graphPlottedMeanAbsDev",value:e.isAdornmentVisible("plottedMad"),classNames:"dg-graph-plottedMad-check".w(),valueDidChange:function(){e.togglePlottedMad()}.observes("value")}])}function j(){var m=DG.get("gaussianFitEnabled")==="yes",l=e.get("dotsAreFused"),k=m&&l?"DG.Inspector.graphBoxPlotGaussianFitOptions":"DG.Inspector.graphBoxPlotNormalCurveOptions";return c(k.loc(),"boxPlotAndNormalCurve",[{control:h()},{title:(l&&m)?"DG.Inspector.graphPlottedGaussianFit":"DG.Inspector.graphPlottedNormal",value:e.isAdornmentVisible("plottedNormal"),classNames:"dg-graph-plottedNormal-check".w(),valueDidChange:function(){e.togglePlottedNormal()}.observes("value")}])}function a(){var k=20,l=5;return c("DG.Inspector.graphOtherValuesOptions","otherValues",[{title:"DG.Inspector.graphPlottedValue",value:e.isAdornmentVisible("plottedValue"),classNames:"dg-graph-plottedValue-check".w(),valueDidChange:function(){e.togglePlotValue()}.observes("value")},{control:SC.ButtonView.create({classNames:"dg-movable-value-button".w(),defaultFlowSpacing:{left:k,bottom:l},themeName:"capsule",title:"DG.Inspector.graphAdd",localize:YES,action:e.addMovableValue.bind(e)})},{control:SC.ButtonView.create({classNames:"dg-movable-value-button",defaultFlowSpacing:{left:k,bottom:l},title:"DG.Inspector.graphRemove",themeName:"capsule",localize:YES,action:e.removeMovableValue.bind(e)})}])}if(!SC.platform.touch){f.push({title:"DG.Inspector.showLabels",value:e.get("showMeasureLabels"),classNames:"dg-graph-showLabels-check".w(),valueDidChange:function(){g()}.observes("value")})}return arguments.callee.base.apply(this,arguments).concat(f.concat([{control:d()},{control:i()},{control:j()},{control:a()}]))}.property()});DG.UnivariateAdornmentBaseModel.rulerState={measuresOfCenter:true,measuresOfSpread:false,boxPlotAndNormalCurve:false,otherValues:false};sc_require("components/graph/plots/univariate_adornment_base_model");DG.BinnedPlotModel=DG.UnivariateAdornmentBaseModel.extend((function(){var a=4;return{displayAsBinned:true,dotsAreFused:false,dotsAreFusedDidChange:function(){if(this.get("dotsAreFused")){this.setPath("plottedCount.isVisible",false)}}.observes("dotsAreFused"),restoreInProgress:false,wantsOtherAxis:function(){return this.get("dotsAreFused")}.property("dotsAreFused"),getDesiredAxisClassFor:function(c){var b=this.get("dotsAreFused");if(c===this.get("primaryAxisPlace")){return b?DG.CellLinearAxisModel:DG.BinnedAxisModel}else{if(c===this.get("secondaryAxisPlace")){if(b){return DG.CountAxisModel}else{return SC.none(this.get("secondaryVarID"))?DG.AxisModel:DG.CellAxisModel}}else{return arguments.callee.base.apply(this,arguments)}}},propagateToSiblings:function(d,e){var c=this.getRootPlot&&this.getRootPlot(),b=c&&c.get("siblingPlots");if(b){c.set(d,e);b.forEach(function(f){f.set(d,e)})}},_leastBinEdge:0,leastBinEdge:function(b,c){if(!SC.none(c)){this._leastBinEdge=c}else{if(!this._casesMap){this.updateCasesMap()}}return this._leastBinEdge}.property(),maxBinEdge:function(){return this.get("leastBinEdge")+this.get("totalNumberOfBins")*this.get("width")}.property("leastBinEdge","width","totalNumberOfBins"),_alignment:null,alignment:function(b,c){if(c!==undefined&&c!==this._alignment){this._alignment=c;this.propagateToSiblings(b,c)}else{if(!this._casesMap){this.updateCasesMap()}}return this._alignment}.property(),_width:null,width:function(b,c){if(c!==undefined&&c!==this._width){this._width=c;this.propagateToSiblings(b,c)}else{if(!this._casesMap){this.updateCasesMap()}}return this._width}.property(),_widthIncrement:null,widthIncrement:function(b,c){if(c!==undefined){this._widthIncrement=c}else{if(!this._casesMap){this.updateCasesMap()}}return this._widthIncrement}.property(),_casesMap:null,casesMap:function(b,c){if(!SC.none(c)){this._casesMap=c}else{if(!this._casesMap){this.updateCasesMap()}}return this._casesMap}.property(),bars:function(){var f=this.get("totalNumberOfBins"),d=this.get("casesMap"),c=new Array(f),g=this.get("width"),b=this.get("leastBinEdge");for(var e=0;e<f;e++){c[e]={count:0,indices:[],lowerEdgeWorld:b+e*g}}d.forEach(function(h,i){c[h.bin].count++;c[h.bin].indices.push(i);b+=g});return c}.property(),totalCount:function(){return this.get("bars").reduce(function(b,c){return b+c.count},0)}.property("bars"),_maxBinCount:0,maxBinCount:function(b,c){if(!SC.none(c)){this._maxBinCount=c}else{if(!this._casesMap){this.updateCasesMap()}}return this._maxBinCount}.property(),_totalNumberOfBins:0,totalNumberOfBins:function(b,c){if(!SC.none(c)){this._totalNumberOfBins=c}else{if(!this._casesMap){this.updateCasesMap()}}return this._totalNumberOfBins}.property(),recomputing:false,isDateTime:function(){var b=this.get("primaryAxisPlace"),c=b===DG.GraphTypes.EPlace.eX?"x":"y";return this.getPath("dataConfiguration."+c+"AttributeDescription.attributeType")===DG.Analysis.EAttributeType.eDateTime}.property(),infoForCase:function(c){var b=this.get("casesMap");return b&&b[c]},valueToBinNumber:function(c){var d=this.get("leastBinEdge"),b=this.get("width");return Math.floor((c-d)/b)},handleDataContextNotification:function(b,c){if(c.operation!=="selectCases"){this.invalidateCasesMap()}arguments.callee.base.apply(this,arguments)},invalidateCaches:function(b){arguments.callee.base.apply(this,arguments);this.invalidateCasesMap()},invalidateCasesMap:function(){this._casesMap=null;this.notifyPropertyChange("changed")}.observes("width","alignment"),xOrYAttributeDidChange:function(c){var b=this.get("primaryAxisPlace"),d=(c==="xAxis")?DG.GraphTypes.EPlace.eX:DG.GraphTypes.EPlace.eY;if(b===d){this.set("width",null);this.set("alignment",null);this.set("widthIncrement",null)}},updateCasesMap:function(){if(this.recomputing){return}this.recomputing=true;var c=this.get("cases"),l=this.get("primaryVarID"),f=this.get("primaryAxisModel"),h=this.get("secondaryVarID"),j=this.get("secondaryAxisModel"),b=Number.MAX_VALUE,e=-Number.MAX_VALUE,o=[],d=this._width,i=this._alignment,n=this._leastBinEdge,g=this._maxBinCount,m=this._totalNumberOfBins;if(!(j&&f)){this.recomputing=false;return}var k=j.get("numberOfCells");this._casesMap=[];if(c.length()===0&&(SC.none(d)||SC.none(i))){d=1;i=0;n=0;g=0;m=0}else{c.forEach(function(r,s){var t=r.getForcedNumericValue(l),q=r.getStrValue(h),p=j.cellNameToCellNumber(q);if(p!=null&&DG.MathUtilities.isInIntegerRange(p,0,k)&&!SC.none(t)){b=Math.min(b,t);e=Math.max(e,t);this._casesMap[s]={value:t,cell:p}}}.bind(this));if(this._casesMap.length!==0){d=this.get("width");if(SC.none(d)){d=DG.MathUtilities.goodTickValue((e-b)/a)}i=this.get("alignment")||Math.floor(b/d)*d;n=i-Math.ceil((i-b)/d)*d;g=0;m=Math.ceil((e-n)/d+0.000001);this._widthIncrement=DG.MathUtilities.goodTickValue((e-b)/m)/20;c.forEach(function(q,r){var p=this._casesMap[r];if(p){p.bin=Math.floor((p.value-n)/d);if(!o[p.cell]){o[p.cell]=[]}if(!o[p.cell][p.bin]){o[p.cell][p.bin]=0}p.indexInBin=o[p.cell][p.bin];o[p.cell][p.bin]++;g=Math.max(g,o[p.cell][p.bin])}}.bind(this))}}this.beginPropertyChanges();this.set("width",d);this.set("alignment",i);this.set("leastBinEdge",n);this.set("maxBinCount",g);this.set("totalNumberOfBins",m);this.endPropertyChanges();this.recomputing=false;this.restoreInProgress=false},forEachBinDo:function(g){if(!this._casesMap){this.updateCasesMap()}var l=this.get("leastBinEdge"),e=this.get("totalNumberOfBins"),f=this.get("width"),h=this.get("widthIncrement"),b=h>=1?0:Math.abs(Math.floor(Math.log10(h))),d=this.get("isDateTime"),i=d?DG.DateUtilities.mapLevelToPrecision(DG.DateUtilities.determineLevels(l,l+(e-1)*f).innerLevel):null;for(var j=0;j<e;j++){var k=d?DG.DateUtilities.formatDate(l,i,true):DG.MathUtilities.formatNumber(l,b),c=d?DG.DateUtilities.formatDate(l+f,i,true):DG.MathUtilities.formatNumber(l+f,b);g(j,k,c);l+=f}},getAdornmentSpecs:function(){var b=arguments.callee.base.apply(this,arguments);DG.ObjectMap.forEach(this._adornmentModels,function(d,c){b.push({key:d,"class":c.constructor,useAdornmentModelsArray:true,storage:c.createStorage()})});return b},installAdornmentModelsFrom:function(b){arguments.callee.base.apply(this,arguments)},rescaleAxesFromData:function(e,d,b,c){if(d===undefined){d=true}this.doRescaleAxesFromData([DG.GraphTypes.EPlace.eX,DG.GraphTypes.EPlace.eY],e,d,c);if(b){DG.logUser("rescaleBinnedPlot")}},getDataMinAndMaxForDimension:function(b){if(b===this.get("secondaryAxisPlace")){return{min:0,max:this.get("maxBinCount"),isDataInteger:true}}else{if(b===this.get("primaryAxisPlace")){return{min:this.get("leastBinEdge"),max:this.get("maxBinEdge")}}}},changeBinParam:function(c,e,d){var b=this.get(c);DG.UndoHistory.execute(DG.Command.create({name:"graph.changeBinParam",undoString:"DG.Undo.graph."+d,redoString:"DG.Redo.graph."+d,log:("change %@ from %@ to %@").fmt(c,b,e),executeNotification:{action:"notify",resource:"component",values:{operation:"change bin parameter",type:"DG.GraphView"}},execute:function(){this.set(c,e)}.bind(this),undo:function(){this.set(c,b)}.bind(this)}))},toggleDotsAreFused:function(){var d=this.get("dotsAreFused"),b=d?"DG.Undo.graph.dissolveRectanglesToDots":"DG.Undo.graph.fuseDotsToRectangles",c=d?"DG.Redo.graph.dissolveRectanglesToDots":"DG.Redo.graph.fuseDotsToRectangles";DG.UndoHistory.execute(DG.Command.create({name:"graph.changeDotPlotModelType",undoString:b,redoString:c,log:("toggleShowAs: %@").fmt(d?"Histogram":"BinnedDotPlot"),executeNotification:{action:"notify",resource:"component",values:{operation:"toggle between histogram and dots",type:"DG.GraphView"}},execute:function(){this.toggleProperty("dotsAreFused")}.bind(this),undo:function(){this.execute()}}))},checkboxDescriptions:function(){if(!this.get("dotsAreFused")){return this.get("checkboxDescriptionsForPlotModel")}return arguments.callee.base.apply(this,arguments)}.property(),lastValueControls:function(){if(!this.get("dotsAreFused")){return[]}return arguments.callee.base.apply(this,arguments)}.property(),lastConfigurationControls:function(){var d=this,b=arguments.callee.base.apply(this,arguments),c=18;[{label:"DG.Inspector.graphBinWidth",key:"width",paramString:"changeBinWidth"},{label:"DG.Inspector.graphAlignment",key:"alignment",paramString:"changeBinAlignment"}].forEach(function(e){b.push(SC.View.create({layout:{height:c},init:function(){arguments.callee.base.apply(this,arguments);this.appendChild(SC.LabelView.create({layout:{height:c},value:e.label,localize:true}));this.appendChild(SC.TextFieldView.create({classNames:"dg-inspector-textentry",layout:{height:c,width:40,right:0},applyImmediately:false,value:d.get(e.key),valueDidChange:function(){var g=Number(this.get("value")),f=d.get(e.key);if(isNaN(g)||(g<=0&&e.key==="width")){this.set("value",f)}else{if(g!==f){d.changeBinParam(e.key,g,e.paramString)}}}.observes("value")}))}}))});if(this.get("secondaryVarID")===DG.Analysis.kNullAttribute){b.push(SC.CheckboxView.create({layout:{height:c},title:"DG.Inspector.graphBarChart",classNames:"dg-graph-fuse-check".w(),value:d.get("dotsAreFused"),valueDidChange:function(){d.toggleDotsAreFused();DG.mainPage.mainPane.hideInspectorPicker()}.observes("value"),localize:true}))}return b}.property("plot"),createStorage:function(){var b=arguments.callee.base.apply(this,arguments);["width","alignment","dotsAreFused","totalNumberOfBins"].forEach(function(c){b[c]=this.get(c)}.bind(this));return b},restoreStorage:function(b){arguments.callee.base.apply(this,arguments);this.restoreInProgress=true;["width","alignment","dotsAreFused","totalNumberOfBins"].forEach(function(c){if(!SC.none(b[c])){this.set(c,b[c])}}.bind(this))}}}()));DG.BinnedPlotModel.configureRoles=function(a){DG.UnivariatePlotModel.configureRoles(a)};sc_require("components/graph/plots/plot_view");DG.UnivariatePlotView=DG.PlotView.extend({displayProperties:["secondaryAxisView.model.numberOfCells","overlap"],getAxisViewDescriptions:function(){var a=arguments.callee.base.apply(this,arguments),d=this.getPath("model.orientation")===DG.GraphTypes.EOrientation.kVertical?"y":"x",c=this.getPath("model."+d+"VarID"),b=c===DG.Analysis.kNullAttribute?DG.AxisView:DG.CellAxisView;a.push({axisKey:d,axisClass:b});return a},primaryAxisView:function(){switch(this.getPath("model.primaryAxisPlace")){case DG.GraphTypes.EPlace.eX:return this.get("xAxisView");case DG.GraphTypes.EPlace.eY:return this.get("yAxisView");default:return null}}.property(),primaryAxisViewDidChange:function(){this.notifyPropertyChange("primaryAxisView")}.observes("*model.primaryAxisPlace","xAxisView","yAxisView"),secondaryAxisView:function(){switch(this.getPath("model.primaryAxisPlace")){case DG.GraphTypes.EPlace.eX:return this.get("yAxisView");case DG.GraphTypes.EPlace.eY:return this.get("xAxisView");default:return null}}.property(),secondaryAxisViewDidChange:function(){this.notifyPropertyChange("secondaryAxisView")}.observes("*model.secondaryAxisPlace","xAxisView","yAxisView"),setupAxes:function(){var a=this.getPath("primaryAxisView.model");if(a){if(a.get("preferZeroLowerBound")){a.set("preferZeroLowerBound",false)}if(a.get("drawZeroLine")){a.set("drawZeroLine",false)}}var b=this.get("secondaryAxisView");if(b){b.set("centering",false)}},overlap:0,dataRangeDidChange:function(b,d,a,c){this.notifyPropertyChange("plotDisplayDidChange");arguments.callee.base.apply(this,arguments)},createRenderContext:function(){var b=arguments.callee.base.apply(this,arguments),a=this.get("model");b.categoryAxisView=this.get("secondaryAxisView");b.categoryAxisModel=b.categoryAxisView&&b.categoryAxisView.get("model");b.categoryVarID=a&&a.get("secondaryVarID");b.primaryVarID=a&&a.get("primaryVarID");b.primaryAxisPlace=a&&a.get("primaryAxisPlace");b.primaryAxisView=this.get("primaryAxisView");if(!b.primaryAxisView){return null}return b},createElement:function(c,d,b){var a=this.get("paper").circle(-100,-100,this._pointRadius);a.node.setAttribute("shape-rendering","geometricPrecision");return this.assignElementAttributes(a,d,b)},drawData:function drawData(){if(this.getPath("model.isAnimating")){return}if(!SC.none(this.get("transferredElementCoordinates"))){this.animateFromTransferredElements();return}arguments.callee.base.apply(this,arguments)},cleanupFunc:function(){this.prepareToResetCoordinates();this.displayDidChange()}});sc_require("components/graph/plots/univariate_plot_view");DG.BinnedPlotView=DG.UnivariatePlotView.extend({kLineSlideHCur:DG.Browser.customCursorStr("../../../../static/dg/fr/cert/resources/cursors/LineSlideH.cur",8,8),kLineSlideVCur:DG.Browser.customCursorStr("../../../../static/dg/fr/cert/resources/cursors/LineSlide.cur",8,8),dragInProgress:false,elementBeingDragged:null,numPointsInRow:0,binBoundaries:null,init:function(){arguments.callee.base.apply(this,arguments);this.binBoundaries=[]},destroy:function(){var a=this.getPath("paperSource.layerManager");this.binBoundaries.forEach(function(b){a.removeElement(b.boundary);b.boundary.remove();a.removeElement(b.cover);b.cover.remove()});this.binBoundaries=null;arguments.callee.base.apply(this,arguments)},getAxisViewDescriptions:function(){var a=arguments.callee.base.apply(this,arguments),b=this.getPath("model.orientation")===DG.GraphTypes.EOrientation.kVertical?"x":"y";a.push({axisKey:b,axisClass:DG.BinnedAxisView,axisModelProperties:{binnedPlotModel:this.get("model")}});return a},createRenderContext:function(){var a=arguments.callee.base.apply(this,arguments);if(a){a.model=this.get("model");a.cellHalfWidth=a.categoryAxisView.get("fullCellWidth")/2}return a},setCircleCoordinate:function(n,k,j,e,f){e=e||this.dragInProgress;var p=this.get("plottedElements"),s=n.model.infoForCase(j);if(!s){return}DG.assert(k,"There must be a case");DG.assert(DG.MathUtilities.isInIntegerRange(j,0,p.length),"index %@ out of bounds for plottedElements of length %@".loc(j,p.length));var d=p[j],w=n.primaryAxisView.binToCoordinate(s.bin),m=(!s||!DG.isFinite(w)||n.primaryAxisPlace===DG.GraphTypes.EPlace.eUndefined);if(this.showHidePlottedElement(d,m,j)&&n.categoryAxisModel){var r=s.cell,i=SC.none(r)?0:n.categoryAxisView.cellToCoordinate(r),v=n.cellHalfWidth,q=this._pointRadius,o=this.get("numPointsInRow"),u=Math.floor(s.indexInBin/o),t=s.indexInBin-u*o,b=w-(o-1)*q+t*2*q,l=this.get("overlap"),a=q+(2*q-l)*u+1,h,g;switch(n.primaryAxisPlace){case DG.GraphTypes.EPlace.eX:h=b;g=i-a+v;break;case DG.GraphTypes.EPlace.eY:h=i+a-v;g=b;break}var c={cx:h,cy:g,r:this.radiusForCircleElement(d),fill:n.calcCaseColorString(k),stroke:n.calcStrokeColorString(k),"fill-opacity":n.transparency,"stroke-opacity":n.strokeTransparency};this.updatePlottedElement(d,c,e,f);return{cx:h,cy:g,r:q}}return null},assignElementAttributes:function(e,d,c){arguments.callee.base.apply(this,arguments);var f=this,a=1,b=null;e.hover(function(g){if(!f.dragInProgress){if(SC.none(b)){b="";this.animate({opacity:a,transform:DG.PlotUtilities.kDataHoverTransform},DG.PlotUtilities.kDataTipShowTime);f.showDataTip(this,d)}}},function(g){if(!f.dragInProgress){this.stop();this.animate({opacity:DG.PlotUtilities.kDefaultPointOpacity,transform:b},DG.PlotUtilities.kHighlightHideTime);b=null;f.hideDataTip()}});return e},modelWidthOrAlignmentDidChange:function(){this.displayDidChange()}.observes("model.changed"),markBinParamsChange:function(d,b){var e=this,c=this.getPath("model.alignment"),a=this.getPath("model.width");DG.UndoHistory.execute(DG.Command.create({name:"graph.drag.binBoundary",undoString:"DG.Undo.graph.dragBinBoundary",redoString:"DG.Redo.graph.dragBinBoundary",log:"dragBinBoundary from { alignment: %@, width: %@ } to { alignment: %@, width: %@ }".fmt(d,b,c,a),executeNotification:{action:"notify",resource:"component",values:{operation:"drag bin boundary",type:"DG.GraphView"}},execute:function(){},undo:function(){e.setPath("model.alignment",d);e.setPath("model.width",b)},redo:function(){e.setPath("model.alignment",c);e.setPath("model.width",a)}}))},doDraw:function doDraw(){var b=this;function a(){var r=20,u,z,e,d,C=b.get("model"),i=C.get("leastBinEdge"),l=C.get("width"),x,K=b.get("paper"),A=b.getPath("primaryAxisView.orientation"),o=b.getPath("layerManager."+DG.LayerNames.kAdornments),G=b.getPath("primaryAxisView.pixelMin"),B=b.getPath("secondaryAxisView.pixelMin"),g=b.getPath("primaryAxisView.binWidth"),D,y=Math.abs(b.getPath("secondaryAxisView.pixelMax")-b.getPath("secondaryAxisView.pixelMin"))-5,v=b.getPath("model.totalNumberOfBins"),J=b.get("binBoundaries"),k=(A===DG.GraphTypes.EOrientation.kVertical)?b.kLineSlideVCur:b.kLineSlideHCur,w="DG.BinnedPlotModel.dragBinTip".loc();function F(){var O=DG.PlotUtilities.kBinBorderLineColor,N="steelblue";function M(P,Q,R){P.attr({stroke:Q,"stroke-width":R})}if(b.dragInProgress){b.binBoundaries.forEach(function(P,Q){if(P.worldValue===e){M(P.boundary,N,2);if(Q>0){M(b.binBoundaries[Q-1].boundary,O,2)}}else{M(P.boundary,O,1)}})}else{b.binBoundaries.forEach(function(P){M(P.boundary,O,1)})}}function f(N,M){b.dragInProgress=true;b.elementBeingDragged=this;g=b.getPath("primaryAxisView.binWidth");u=C.get("alignment");l=C.get("width");z=C.get("width");x=C.get("widthIncrement");D=l/g;d=b.getPath("primaryAxisView.binWidth");b.set("binNumBeingDragged",this.binNum);e=J[this.binNum].worldValue;F()}function t(R,Q){var N=b.getPath("primaryAxisView.orientation"),O=(N===DG.GraphTypes.EOrientation.kVertical)?-Q:R,P=Math.max(r,d+O),M=P*D;M=Math.round(M/x)*x;SC.run(function(){C.beginPropertyChanges();C.set("alignment",e);C.set("width",M);C.endPropertyChanges()});F()}function I(O,N){var M=C.get("width");if(e!==u||z!==M){b.markBinParamsChange(u,z)}b.set("binNumBeingDragged",null);b.dragInProgress=false;if(b.elementBeingDragged.shouldGoAway){o.prepareToMoveOrRemove(b.elementBeingDragged);b.elementBeingDragged.remove();b.elementBeingDragged=null}F();b.displayDidChange()}if(!K){return}for(var E=0;E<v;E++){var n=i+E*l,c,h,s,p,H,m,q;if(A===DG.GraphTypes.EOrientation.kVertical){c=B;h=G-(E+1)*g;s=c+y;p=h;H=h+g}else{c=G+(E+1)*g;h=B-y;s=c;p=B;H=c-g}if(!J[E]){m=K.line(c,h,s,p);q=K.line(c,h,s,p).drag(t,f,I);q.binNum=E;o.push(m.attr({stroke:DG.PlotUtilities.kBinBorderLineColor,"stroke-width":DG.PlotUtilities.kBinBorderWidth}));o.push(q.attr({"stroke-width":6,stroke:DG.RenderingUtilities.kSeeThrough,cursor:k,title:w}));J[E]={boundary:m,cover:q}}else{m=J[E].boundary;q=J[E].cover;q.attr({cursor:k});DG.RenderingUtilities.updateLine(m,{x:c,y:h},{x:s,y:p});DG.RenderingUtilities.updateLine(q,{x:c,y:h},{x:s,y:p})}J[E].worldValue=n;J[E].lowerEdgeScreenCoord=H}while(J.length>v){var j=J.pop();o.prepareToMoveOrRemove(j.boundary);j.boundary.remove();if(j.cover!==b.elementBeingDragged){o.prepareToMoveOrRemove(j.cover);j.cover.remove()}else{b.elementBeingDragged.shouldGoAway=true}}}arguments.callee.base.apply(this,arguments);this.computeBinParams();a();this.drawData();this.updateSelection()},computeBinParams:function(){var h=this.getPath("primaryAxisView.binWidth"),a=this.getPath("secondaryAxisView.fullCellWidth")-5,f=this.getPath("model.maxBinCount"),d=2*this._pointRadius,b=Math.max(1,Math.floor(a/d)),g=Math.max(1,Math.floor(h/d)),c=Math.max(1,Math.min(g,Math.ceil(f/b))),i=Math.ceil(f/c),e=Math.max(0,((i+1)*d-a)/i);e=Math.min(e,d);if(!isFinite(c)){c=0}if(!isFinite(e)){e=0}this.beginPropertyChanges();this.setIfChanged("numPointsInRow",c);this.setIfChanged("overlap",e);this.endPropertyChanges()}});sc_require("components/graph/plots/plot_model");DG.CasePlotModel=DG.PlotModel.extend({dataContextDidChange:function(b,a){arguments.callee.base.apply(this,arguments);if(a==="dataContext"){this.get("dataConfiguration").updateCaptionAttribute()}}.observes("*dataConfiguration.dataContext"),worldValues:null,getWorldCoords:function(b){if(SC.none(this.worldValues)){this.worldValues=[]}var a=this.worldValues;if((b>=a.length)||SC.none(a[b])){a[b]={x:Math.random(),y:Math.random()}}return a[b]},setWorldCoords:function(a,b){if(SC.none(this.worldValues)){this.worldValues=[]}this.worldValues[a]=b},mixUp:function(){this.set("worldValues",[])},getCellCaseCounts:function(c){var a=[];var e=c?this.get("selection"):this.get("cases");var b=e.get("length");var d={primaryCell:0,secondaryCell:0};if(c){d.selectedCount=b}else{d.count=b}a.push(d);return a}});sc_require("components/graph/plots/plot_view");DG.CasePlotView=DG.PlotView.extend((function(){function b(g,e,d,f){return e+f+g*(d-e-2*f)}function c(e,h){function i(j,k){e.get("model").setWorldCoords(j,k)}var f=false,d=1,g=null;if(h.events){h.events.forEach(function(j){j.unbind()});h.events.length=0}h.hover(function(j){if(!f&&SC.none(g)){g=this.transform();this.animate({opacity:d,transform:DG.PlotUtilities.kDataHoverTransform},DG.PlotUtilities.kDataTipShowTime);e.showDataTip(this,this.index)}},function(j){e.hideDataTip();if(!f){this.stop();this.animate({transform:g},DG.PlotUtilities.kHighlightHideTime);g=null}}).mousedown(function(j){e.get("model").selectCaseByIndex(this.index,j.shiftKey)}).drag(function(m,k){var o=e.get("xAxisView").coordinateToData(this.ox+m),n=e.get("yAxisView").coordinateToData(this.oy+k),l={x:o,y:n},p=e.createRenderContext(),j=this.transform();if(isFinite(l.x)&&isFinite(l.y)){this.transform(g);i(this.index,l);this.transform(j)}e.setCircleCoordinate(p,e.getPath("model.cases").at(this.index),this.index)},function(j,k){f=true;this.ox=this.attr("cx");this.oy=this.attr("cy");this.animate({opacity:d},DG.PlotUtilities.kDataTipShowTime,"bounce");this.toFront()},function(){this.animate({transform:g},DG.PlotUtilities.kHighlightHideTime);f=false})}return{handlersMustBeInstalledToExistingElements:true,init:function(){arguments.callee.base.apply(this,arguments)},dataRangeDidChange:function(d,j,g,h){var f=this,l=this.get("plottedElements").length,e=this.getPath("model.cases"),k=this.createRenderContext();var i=(SC.typeOf(h)===SC.T_NUMBER?[h]:h);i=i||[];i.forEach(function(n){var m=e.at(n);if(n>=l){f.callCreateElement(m,n,f._createAnimationOn)}f.setCircleCoordinate(k,m,n)});arguments.callee.base.apply(this,arguments)},assignElementAttributes:function(f,e,d){c(this,f);f.index=e;if(d){DG.PlotUtilities.doCreateCircleAnimation(f)}return f},setCircleCoordinate:function(h,e,j,n,f){DG.assert(h&&h.xAxisView,"incomplete render context");DG.assert(e,"no case");DG.assert(DG.MathUtilities.isInIntegerRange(j,0,this.get("plottedElements").length),"out of bounds","Index for circle element");var d=this.get("plottedElements")[j],k=this.radiusForCircleElement(d),i=this.get("model").getWorldCoords(j),m=b(i.x,h.xAxisView.get("pixelMin"),h.xAxisView.get("pixelMax"),k),l=b(i.y,h.yAxisView.get("pixelMin"),h.yAxisView.get("pixelMax"),k),o=SC.none(m)||SC.none(l);if(this.showHidePlottedElement(d,o,j)){var g={cx:m,cy:l,r:k,fill:h.calcCaseColorString(e),stroke:h.calcStrokeColorString(e),"fill-opacity":h.transparency,"stroke-opacity":h.strokeTransparency};this.updatePlottedElement(d,g,n,f);return{cx:m,cy:l,r:k}}return null},createElement:function(g,h,f){var d=this.get("paper"),e=d.circle(d.width/2,d.height/2,this._pointRadius).attr({cursor:"pointer"}).addClass(DG.PlotUtilities.kDotClassName);e.index=h;e.node.setAttribute("shape-rendering","geometricPrecision");c(this,e);return e},drawData:function(){var h=this;if(!this.get("paper")||!this.get("model")||!this.getPath("model.cases")||this.getPath("model.isAnimating")){return}if(this.handlersMustBeInstalledToExistingElements){this.get("plottedElements").forEach(function(w){c(h,w)});this.handlersMustBeInstalledToExistingElements=false}if(this.getPath("model.isAnimating")){return}function v(x){var w=r.getWorldCoords(x);return{type:"circle",cx:b(w.x,d,f,l),cy:b(w.y,m,q,l),r:s/2,fill:"yellow",stroke:j.strokeColor,"stroke-opacity":j.strokeTransparency,cursor:"pointer"}}function n(){var y=200,x,w=function(){if(o.length>=t){return}var z=o.length,A=[];f=h.getPath("xAxisView.pixelMax");q=h.getPath("yAxisView.pixelMin");if(f<30||q<30){h.invokeLater(w,100);return}for(x=z;x<z+y&&x<t;x++){A.push(v(x))}u=h.get("paper").add(A).forEach(function(C,B){o.push(C);k.push(C);C.addClass(DG.PlotUtilities.kDotClassName);C.index=z+B;C.node.setAttribute("shape-rendering","geometricPrecision");return true});c(h,u);h.setPath("model.isAnimating",true);u.animate({r:s,fill:g},DG.PlotUtilities.kDefaultAnimationTime,"<>");z+=y;y*=2;if(z<t){h.invokeLater(w,10)}else{h.setPath("model.isAnimating",false);h.updateSelection()}u.clear()}.bind(h);w();h._elementOrderIsValid=false}var p=this.createRenderContext(),d=this.getPath("xAxisView.pixelMin"),f=this.getPath("xAxisView.pixelMax"),q=this.getPath("yAxisView.pixelMin"),m=this.getPath("yAxisView.pixelMax"),u,o=this.get("plottedElements"),r=this.get("model"),t=r.get("cases").length(),s=this.calcPointRadius(),l=s,g=r.getPointColor?r.getPointColor():DG.PlotUtilities.kDefaultPointColor,j=this.getStrokeParams(),k=this.getPath("layerManager."+DG.LayerNames.kPoints);if(!o||o.length<t){n()}else{if(o.length>0&&!this.getPath("model.isAnimating")){if(o.length>t){var e=this.get("layerManager");for(var i=t;i<o.length;i++){if(!SC.none(o[i])){o[i].stop();e.removeElement(o[i]);DG.PlotUtilities.doHideRemoveAnimation(o[i],e)}}o.length=t}o.forEach(function(y,x){var w=r.getWorldCoords(x);y.attr({fill:g,"fill-opacity":p.transparency,opacity:p.transparency,r:s});y.show();y.animate({cx:b(w.x,d,f,l),cy:b(w.y,m,q,l)},DG.PlotUtilities.kDefaultAnimationTime,"<>")})}}},doDraw:function a(){arguments.callee.base.apply(this,arguments);this.drawData();this.updateSelection()},worldValuesChanged:function(){var f=this.get("plottedElements"),j=f.length-1,e=this.calcPointRadius(),h=this.getPath("xAxisView.pixelMin"),d=this.getPath("xAxisView.pixelMax"),k=this.getPath("yAxisView.pixelMin"),g=this.getPath("yAxisView.pixelMax"),i=this.get("model");i.set("isAnimating",true);f.forEach(function(n,m){var l=i.getWorldCoords(m);n.animate({cx:b(l.x,h,d,e),cy:b(l.y,g,k,e)},DG.PlotUtilities.kDefaultAnimationTime,"<>",m===j?function(){i.set("isAnimating",false)}:null)});this._isRenderingValid=false}.observes(".model.worldValues")}}()));sc_require("components/graph/plots/bar_chart_base_model");DG.ComputedBarChartModel=DG.BarChartBaseModel.extend({isBarHeightComputed:true,expression:"",formula:null,formulaContext:null,_editInProgress:false,_receivedInitialExpression:false,init:function(){arguments.callee.base.apply(this,arguments)},destroy:function(){this.destroyFormula();DG.BarChartFormulaEditContext.destroyFormulaEditContext(DG.Debug.scObjectID(this));arguments.callee.base.apply(this,arguments)},editFormula:function(a){a=SC.none(a)?true:a;DG.ComputedBarChartView.createFormulaEditView(this,a);this._editInProgress=true},createFormula:function(){var f=DG.Debug.scObjectID(this),c="computedBarChart",b={type:c,id:f,name:c+f},d=this.get("primaryVarID"),a=d&&DG.Attribute.getAttributeByID(d),e=a&&a.get("collection");this.formulaContext=DG.BarChartFormulaContext.create({ownerSpec:b,plotModel:this,collection:e});this.set("formula",DG.Formula.create({context:this.formulaContext,source:this.get("expression")}))},expressionDidChange:function(){this.destroyFormula();this.createFormula();this._editInProgress=false;this._receivedInitialExpression=true}.observes("expression"),destroyFormula:function(){if(this.formula){this.formula.destroy()}},getDesiredAxisClassFor:function(a){if(a===this.get("secondaryAxisPlace")){return DG.FormulaAxisModel}return arguments.callee.base.apply(this,arguments)},getDataMinAndMaxForDimension:function(b){var c=Infinity,a=-Infinity,d=this.get("primaryVarID");this.get("validCachedCells").forEach(function(g){var f=g[0][0].theCase.getValue(d),e=this.getBarHeight(f);c=Math.min(c,e);a=Math.max(a,e)}.bind(this));if(c<0&&a<0){a=0}else{if(c>0&&a>0){c=0}}return{min:c,max:a,isDataInteger:false}},getBarHeight:function(b){if(SC.empty(this.get("expression"))&&!this._receivedInitialExpression){this.invokeLater(function(){if(!this._editInProgress){this.editFormula(false)}}.bind(this),100);return 0}if(!this.get("formula")){this.createFormula()}var f=this.get("formula"),c=b?{_groupID_:b}:{},a=NaN;try{if(f){a=Number(f.evaluate(c))}}catch(d){a=d}return(typeof a==="number")?a:0},createStorage:function(){var a=arguments.callee.base.apply(this,arguments);a.expression=this.expression;return a},restoreStorage:function(a){arguments.callee.base.apply(this,arguments);if(!SC.none(a.expression)){this.set("expression",a.expression)}}});sc_require("components/graph/plots/bar_chart_base_view");DG.ComputedBarChartView=DG.BarChartBaseView.extend({getAxisViewDescriptions:function(){var b=arguments.callee.base.apply(this,arguments),a=this.getPath("model.orientation")===DG.GraphTypes.EOrientation.kVertical?"y":"x";b.push({axisKey:a,axisClass:DG.FormulaAxisView});return b},formulaDidChange:function(){var c=this.get("model");this.set("transferredElementCoordinates",this.getElementPositionsInParentFrame());var b=c.get("secondaryAxisModel"),a={lower:b.get("lowerBound"),upper:b.get("upperBound")};c.doRescaleAxesFromData([c.get("secondaryAxisPlace")],true,false,false);this.animateFromTransferredElements();b.setDataMinAndMax(a.lower,a.upper,true);this.notifyPropertyChange("plotDisplayDidChange");c.doRescaleAxesFromData([c.get("secondaryAxisPlace")],true,true,false)}.observes("model.formula"),getBarHeight:function(b,e,d){var a=this.get("model"),c=a&&a.getBarHeight(b);return a&&c*e/d},setupAxes:function(){var a=this.getPath("secondaryAxisView.model");a.set("drawZeroLine",true);a.set("expressionSource",this.get("model"))},drawData:function drawData(){var a=this.get("model");a._buildCache();arguments.callee.base.apply(this,arguments)},privSetElementCoords:function(f,b,j,o,p,c){DG.assert(f&&f.xAxisView);DG.assert(b);DG.assert(DG.MathUtilities.isInIntegerRange(j,0,this.get("plottedElements").length));var q=this.get("plottedElements")[j];if(!o){return}var e=f.barWidth,n=f.barSliceHeights[o.primaryCell],a=o.indexInCell,g=f.primaryAxisView.cellToCoordinate(o.primaryCell)-e/2,i,m,l,h,k;if(f.isVerticalOrientation){i=n<0?f.zeroOnSecondaryAxis-a*n:f.zeroOnSecondaryAxis-(a+1)*n;m=g;l=i;h=e;k=Math.abs(n)}else{if(n<0){i=f.zeroOnSecondaryAxis+(a+1)*n;m=i}else{i=f.zeroOnSecondaryAxis+(a+1)*n;m=i-n}l=g;h=Math.abs(n);k=e}var d={x:m,y:l,r:0.1,width:h,height:k,fill:f.calcCaseColorString(b),"fill-opacity":f.transparency,"stroke-opacity":0};if(p){q.animate(d,DG.PlotUtilities.kDefaultAnimationTime,"<>",c)}else{q.attr(d)}return q},computeCellParams:function(){var f=this.getPath("model.primaryVarID"),c=this.get("secondaryAxisView"),a=c.get("orientation")==="horizontal",e=c.dataToCoordinate(0),b=[],d=this.get("model");d.get("validCachedCells").forEach(function(j,k){var i=j[0][0].theCase.getValue(f),g=d.getBarHeight(i),l=j.reduce(function(n,m){return n+m.length},0),h=(e-c.dataToCoordinate(g))/l;if(a){h=-h}b.push(h)});this.setIfChanged("barSliceHeights",b)},getToolTipText:function(b,f,e,c){var d=DG.PlotUtilities.findFractionDigitsForAxis(this.get("secondaryAxisView")),a=DG.Format.number().fractionDigits(0,d).group("");return"DG.ComputedBarChartModel.cellTip".loc(b,a(this.get("model").getBarHeight(b)))}});DG.ComputedBarChartView.createFormulaEditView=function(a,b){var c=DG.BarChartFormulaEditContext.getFormulaEditContext(a);c.set("clientOptions",{isUndoable:b,attrNamePrompt:"DG.BarChartFunction.namePrompt",formulaPrompt:"DG.BarChartFunction.formulaPrompt",formulaHint:"DG.BarChartFunction.formulaHint",commandName:"graph.editBarChartFunction",undoString:"DG.Undo.graph.changeBarChartFunction",redoString:"DG.Redo.graph.changeBarChartFunction",logMessage:'Change bar chart function: "%@1" to "%@2"'});c.openFormulaEditorDialog()};sc_require("components/graph/plots/chart_model");DG.DotChartModel=DG.ChartModel.extend({displayAsBarChart:false,getDesiredAxisClassFor:function(a){if(a===this.get("primaryAxisPlace")){return DG.CellAxisModel}else{if(a===this.get("secondaryAxisPlace")){return SC.none(this.get("secondaryVarID"))?DG.AxisModel:DG.CellAxisModel}else{return arguments.callee.base.apply(this,arguments)}}},lastValueControls:function(){var c=arguments.callee.base.apply(this,arguments),h=this,g={row:"DG.Inspector.graphRow".loc(),column:"DG.Inspector.graphColumn".loc(),cell:"DG.Inspector.graphCell".loc()},b=this.getPath("xAxis.numberOfCells"),a=this.getPath("yAxis.numberOfCells");function f(j){function i(k){k.setPath("plottedCount.percentKind",j)}i(h);h.get("siblingPlots").forEach(i)}function e(j){var i=-1;switch(j){case g.row:i=DG.Analysis.EPercentKind.eRow;break;case g.column:i=DG.Analysis.EPercentKind.eColumn;break;case g.cell:i=DG.Analysis.EPercentKind.eCell}return i}function d(i){var j="";switch(i){case DG.Analysis.EPercentKind.eRow:j=g.row;break;case DG.Analysis.EPercentKind.eColumn:j=g.column;break;case DG.Analysis.EPercentKind.eCell:j=g.cell;break}return j}if(b>1&&a>1){c.push(SC.RadioView.create({items:[g.row,g.column,g.cell],value:"DG.Inspector.graphRow".loc(),layoutDirection:SC.LAYOUT_VERTICAL,layout:{height:65},classNames:"dg-inspector-radio".w(),valueDidChange:function(){f(e(this.value))}.observes("value"),init:function(){arguments.callee.base.apply(this,arguments);h.addObserver("plottedCount",this,this.addIsShowingPercentObserver);this.addIsShowingPercentObserver()},addIsShowingPercentObserver:function(){var j=h.get("plottedCount"),i;if(j){j.addObserver("isShowingPercent",this,this.isShowingPercentChanged);i=j.get("percentKind");this.set("value",d(i))}this.isShowingPercentChanged()},isShowingPercentChanged:function(){this.set("isEnabled",h.getPath("plottedCount.isShowingPercent"))},destroy:function(){var i=h.get("plottedCount");if(i){i.removeObserver("isShowingPercent",this,this.isShowingPercentChanged)}h.removeObserver("plottedCount",this,this.addIsShowingPercentObserver)}}))}return c}.property("plot")});sc_require("components/graph/plots/chart_view");DG.DotChartView=DG.ChartView.extend({displayProperties:["numPointsInRow","overlap"],numPointsInRow:1,overlap:0,updateElements:function(){if(!this.get("paper")){return}arguments.callee.base.apply(this,arguments);var d=this,j=this.get("model"),c=this.getPath("model.cases"),i=this.createRenderContext(),g=c&&c.get("length"),e=this.get("plottedElements"),l=e.length,a=this.calcPointRadius(),f=(this._pointRadius!==a),b=this.get("layerManager"),k,h;if(f){this._pointRadius=a}if(g>l){if(f){for(k=0;k<l;k++){h=j.lookupCellForCaseIndex(k);this.privSetElementCoords(i,c.at(k),k,h)}}for(k=l;k<g;k++){this.callCreateElement(c.at(k),k,this.animationIsAllowable());h=j.lookupCellForCaseIndex(k);this.privSetElementCoords(i,c.at(k),k,h)}}if(g<l){for(k=g;k<l;k++){if(!SC.none(e[k])){e[k].stop();DG.PlotUtilities.doHideRemoveAnimation(e[k],b)}}c.forEach(function(m,n){h=j.lookupCellForCaseIndex(n);d.privSetElementCoords(i,m,n,h)})}this._isRenderingValid=false},dataRangeDidChange:function(a,h,d,f){var c=this,b=this.getPath("model.cases"),e=this.get("plottedElements"),i=this.createRenderContext(),g=(SC.typeOf(f)===SC.T_NUMBER?[f]:f);g=g||[];this.model.invalidateCaches();this.computeCellParams();g.forEach(function(j){if(!e[j]){c.callCreateElement(b.at(j),j,c._createAnimationOn)}var k=c.get("model").lookupCellForCaseIndex(j);c.privSetElementCoords(i,b.at(j),j,k)});arguments.callee.base.apply(this,arguments)},setCircleCoordinate:function setCircleCoordinate(f,b,c,a,e){var d=this.get("model").lookupCellForCaseIndex(c);this.privSetElementCoords(f,b,c,d,a,e)},privGetElementCoordAttrs:function(b,j,h,g,d){var q=j.cellHalfWidth,k=this.get("numPointsInRow"),i=this.get("overlap"),p=Math.floor(d.indexInCell/k),o=d.indexInCell-p*k,l=this._pointRadius,r=2*l,a=j.primaryAxisView.cellToCoordinate(d.primaryCell)-(k-1)*r/2+o*r,m=j.secondaryAxisView.cellToCoordinate(d.secondaryCell),n=((p+0.5)*(r-i)+1+i/2),f,e;DG.assert(DG.isFinite(a)&&DG.isFinite(m),"tPrimaryCoord & tSecondaryCoord");if(j.isVerticalOrientation){f=a;e=m+q-n}else{f=m-q+n;e=a}DG.assert(isFinite(f)&&isFinite(e));var c={cx:f,cy:e,r:this.radiusForCircleElement(b),fill:j.calcCaseColorString(h),stroke:j.calcStrokeColorString(h),"fill-opacity":j.transparency,"stroke-opacity":j.strokeTransparency};return c},privSetElementCoords:function(e,a,f,g,h,b){DG.assert(e&&e.xAxisView);DG.assert(a);DG.assert(DG.MathUtilities.isInIntegerRange(f,0,this.get("plottedElements").length));var d=this.get("plottedElements")[f],i=SC.none(g);if(this.showHidePlottedElement(d,i,f)){var c=this.privGetElementCoordAttrs({_selected:false},e,a,f,g);this.updatePlottedElement(d,c,h,b)}},getAxisViewDescriptions:function(){var a=arguments.callee.base.apply(this,arguments),b=this.getPath("model.orientation")===DG.GraphTypes.EOrientation.kVertical?"y":"x";a.push({axisKey:b,axisClass:(this.getPath("model.dataConfiguration."+b+"AttributeDescription.isNull"))?DG.AxisView:DG.CellAxisView});return a},assignElementAttributes:function(g,f,e){arguments.callee.base.apply(this,arguments);var h=this,d=null,a=1,b=this.get("paperSource");function c(j,i,m){b.prepareMarquee();var k=b.startMarquee(j,i,m,true),l=this.attr("r");k.x-=l;k.y-=l}g.hover(function(i){if(SC.none(d)){d="";this.animate({opacity:a,transform:DG.PlotUtilities.kDataHoverTransform},DG.PlotUtilities.kDataTipShowTime);h.showDataTip(this,f)}},function(i){this.stop();this.animate({opacity:DG.PlotUtilities.kDefaultPointOpacity,transform:d},DG.PlotUtilities.kHighlightHideTime);d=null;h.hideDataTip()}).drag(b.continueMarquee,c,b.endMarquee);return g},createElement:function(c,d,b){if(!this.get("paper")){return}var a=this.get("paper").circle(0,0,this._pointRadius).attr({cursor:"pointer",cx:-1000,cy:-1000});a.node.setAttribute("shape-rendering","geometricPrecision");return this.assignElementAttributes(a,d,b)},animateFromTransferredElements:function(){var h=this,p=this.get("model"),m=p.get("cases"),u=this.get("paper"),n=this.createRenderContext(),t=this.calcPointRadius(),a=this.get("frame"),d=this.get("transferredElementCoordinates"),j=[],e=[],b=[];if(!m){return}function f(v){return d[v]}function k(v){return d[e[v]]}DG.sounds.playMixup();p.set("isAnimating",false);this._getTransferredElementsToCasesMap(e,b);var l=e.length>0,c=b.length>0,s=(l?k:f),i=d.length>0&&d[0].type==="rect",o=[],g;this.prepareToResetCoordinates();this.computeCellParams();d.forEach(function(w,v){w.cx-=a.x;w.cy-=a.y;w.x-=a.x;w.y-=a.y});if(i){this.removePlottedElements(true)}var q=function(w,x){var v=s(x),z=p.lookupCellForCaseIndex(x),A;if(i){var B=d[x];A=u.rect(0,0,0,0);A.attr(B);var y=this.privGetElementCoordAttrs(A,n,w,x,z);g={x:y.cx-y.r,y:y.cy-y.r,width:2*y.r,height:2*y.r,r:y.r,fill:(v&&v.fill)||DG.PlotUtilities.kDefaultPointColor,stroke:(v&&v.stroke)||DG.PlotUtilities.kDefaultStrokeColor};A.animate(g,DG.PlotUtilities.kDefaultAnimationTime);o.push(A)}else{A=h.callCreateElement(w,x);if(!SC.none(v)){g={r:DG.isFinite(v.r)&&v.r>0?v.r:t,cx:DG.isFinite(v.cx)?v.cx:v.x+v.width/2,cy:DG.isFinite(v.cy)?v.cy:v.y+v.height/2,fill:v.fill,stroke:v.stroke};A.attr(g)}h.privSetElementCoords(n,w,x,z,true);if(c){j.push(v)}}return p.get("isAnimating")}.bind(this),r=function(){if(c){d.forEach(function(x,y){var w=b[y],v=j[w];if(SC.none(w)||SC.none(v)||(x.r===0)){return}h.vanishPlottedElement(x,v)})}this.set("transferredElementCoordinates",null)}.bind(this);p.set("isAnimating",true);m.forEachWithInvokeLater(q,r);SC.Timer.schedule({action:function(){if(i){o.forEach(function(v){v.remove()});m.forEach(function(w,x){var v=h.callCreateElement(w,x),y=p.lookupCellForCaseIndex(x);v.attr(h.privGetElementCoordAttrs(v,n,w,x,y))}.bind(this))}p.set("isAnimating",false);h.displayDidChange()},interval:DG.PlotUtilities.kDefaultAnimationTime})},computeCellParams:function(){var b=this.getPath("primaryAxisView.cellWidth"),a=this.getPath("secondaryAxisView.fullCellWidth")-5,f=this.getPath("model.maxInCell"),e=2*this._pointRadius,c=Math.max(1,Math.floor(a/e)),h=Math.max(1,Math.floor(b/e)),d=Math.max(1,Math.min(h,Math.ceil(f/c))),i=Math.ceil(f/d),g=Math.max(0,((i+1)*e-a)/i);g=Math.min(g,e);if(!isFinite(d)){d=0}if(!isFinite(g)){g=0}this.beginPropertyChanges();this.setIfChanged("numPointsInRow",d);this.setIfChanged("overlap",g);this.endPropertyChanges()}});sc_require("components/graph/plots/univariate_adornment_base_model");DG.DotPlotModel=DG.UnivariateAdornmentBaseModel.extend({displayAsBinned:false,getDesiredAxisClassFor:function(a){if(a===this.get("primaryAxisPlace")){return DG.CellLinearAxisModel}else{if(a===this.get("secondaryAxisPlace")){return SC.none(this.get("secondaryVarID"))?DG.AxisModel:DG.CellAxisModel}else{return arguments.callee.base.apply(this,arguments)}}},rescaleAxesFromData:function(d,c,a,b){if(c===undefined){c=true}this.doRescaleAxesFromData([this.get("primaryAxisPlace")],d,c,b);if(a){DG.logUser("rescaleDotPlot")}},dilate:function(b,a){this.doDilation([this.get("primaryAxisPlace")],b,a)}});DG.DotPlotModel.configureRoles=function(a){DG.UnivariatePlotModel.configureRoles(a)};sc_require("components/graph/plots/univariate_plot_view");DG.UnivariateAdornmentBaseView=DG.UnivariatePlotView.extend({autoDestroyProperties:["multipleMovableValuesAdorn","plottedValueAdorn","plottedMeanAdorn","plottedMedianAdorn","plottedStDevAdorn","plottedStErrAdorn","plottedNormalAdorn","plottedMadAdorn","plottedBoxPlotAdorn","plottedNormalAdorn"],multipleMovableValuesAdorn:null,plottedMeanAdorn:null,plottedMedianAdorn:null,plottedStDevAdorn:null,plottedStErrAdorn:null,plottedMadAdorn:null,plottedBoxPlotAdorn:null,plottedNormalAdorn:null,primaryAxisViewDidChange:function(){arguments.callee.base.apply(this,arguments);var a=this.get("multipleMovableValuesAdorn");if(a){a.set("valueAxisView",this.get("primaryAxisView"))}},dataDidChange:function(){if(!this.getPath("model.dataConfiguration")){return}arguments.callee.base.apply(this,arguments);if(SC.none(this.get("paper"))){return}this.updateAverages()},dataRangeDidChange:function(b,e,a,c){var d=this.getPath("model.cases");this.notifyPropertyChange("plotDisplayDidChange");this.updateAverages();this.rescaleOnParentCaseCompletion(d);arguments.callee.base.apply(this,arguments)},numberOfCellsDidChange:function(){["plottedMeanAdorn","plottedMedianAdorn","plottedStDevAdorn","plottedStErrAdorn","plottedMadAdorn","plottedBoxPlotAdorn","plottedNormalAdorn"].forEach(function(a){if(this.getPath(a+".model")){this.getPath(a+".model").setComputingNeeded()}}.bind(this))}.observes("*secondaryAxisView.model.numberOfCells"),categoriesDidChange:function(){this.updateAverages()}.observes("model.colorMap"),initializeAdornments:function(){arguments.callee.base.apply(this,arguments);this.setOffsetsForAverages()},setOffsetsForAverages:function(){var a=0;["plottedMeanAdorn","plottedMedianAdorn","plottedStDevAdorn","plottedStErrAdorn","plottedNormalAdorn","plottedMadAdorn"].forEach(function(b){if(this.getPath(b+".model.isVisible")){if(this.getPath(b+".offset")!==a){this.setPath(b+".offset",a)}a++}}.bind(this))},updateAverages:function(a){function b(d){if(d){var c=d.get("model");if(c){c.setComputingNeeded();d.updateToModel(a)}}}if(!this.getPath("model.dataConfiguration")){return}b(this.plottedMeanAdorn);b(this.plottedMedianAdorn);b(this.plottedStDevAdorn);b(this.plottedStErrAdorn);b(this.plottedMadAdorn);b(this.plottedBoxPlotAdorn);b(this.plottedNormalAdorn);b(this.multipleMovableValuesAdorn);if(this.plottedValueAdorn){this.plottedValueAdorn.updateToModel()}this.setOffsetsForAverages()},doDraw:function doDraw(){function a(b){if(!SC.none(b)&&b.wantVisible()){b.get("model").setComputingNeeded();b.updateToModel()}}arguments.callee.base.apply(this,arguments);this.drawData();this.updateSelection();["plottedMeanAdorn","plottedMedianAdorn","plottedStDevAdorn","plottedStErrAdorn","plottedMadAdorn","plottedBoxPlotAdorn","plottedNormalAdorn"].forEach(function(b){a(this[b])}.bind(this));if(!SC.none(this.plottedValueAdorn)){this.plottedValueAdorn.updateToModel()}if(!SC.none(this.multipleMovableValuesAdorn)){this.multipleMovableValuesAdorn.updateToModel()}},movableValueChanged:function(){var a=this.get("model"),c=a&&a.getAdornmentModel("multipleMovableValues"),b=this.get("multipleMovableValuesAdorn");if(c){if(b){b.set("parentView",this);b.set("model",c);b.set("paperSource",this.get("paperSource"))}else{b=DG.MultipleMovableValuesAdornment.create({parentView:this,model:c,paperSource:this.get("paperSource"),layerName:DG.LayerNames.kAdornments,valueAxisView:this.get("primaryAxisView")});this.set("multipleMovableValuesAdorn",b)}b.updateToModel()}}.observes("*model.valuesDidChange","*model.multipleMovableValues"),plottedMeanChanged:function(){this.adornmentDidChange("plottedMean","plottedMeanAdorn",DG.PlottedMeanAdornment)}.observes("*model.plottedMean"),plottedMedianChanged:function(){this.adornmentDidChange("plottedMedian","plottedMedianAdorn",DG.PlottedMedianAdornment)}.observes("*model.plottedMedian"),plottedStDevChanged:function(){this.adornmentDidChange("plottedStDev","plottedStDevAdorn",DG.PlottedStDevAdornment)}.observes("*model.plottedStDev"),plottedStErrChanged:function(){this.adornmentDidChange("plottedStErr","plottedStErrAdorn",DG.PlottedStErrAdornment)}.observes("*model.plottedStErr"),plottedMadChanged:function(){this.adornmentDidChange("plottedMad","plottedMadAdorn",DG.PlottedMeanAbsDevAdornment)}.observes("*model.plottedMad"),plottedBoxPlotChanged:function(){this.adornmentDidChange("plottedBoxPlot","plottedBoxPlotAdorn",DG.PlottedBoxPlotAdornment)}.observes("*model.plottedBoxPlot"),plottedNormalChanged:function(){this.adornmentDidChange("plottedNormal","plottedNormalAdorn",DG.PlottedNormalAdornment)}.observes("*model.plottedNormal"),adornmentDidChange:function(e,f,c){var a=this.get("model"),b=a&&a.getAdornmentModel(e),d=this[f];if(b){if(d){d.set("parentView",this);d.set("model",b);d.set("paperSource",this.get("paperSource"))}else{d=c.create({parentView:this,model:b,paperSource:this.get("paperSource"),layerName:DG.LayerNames.kAdornments,shadingLayerName:DG.LayerNames.kIntervalShading});this[f]=d}d.updateToModel()}else{if(d){d.destroy();delete this[f]}}this.setOffsetsForAverages()}});sc_require("components/graph/plots/univariate_adornment_base_view");DG.DotPlotView=DG.UnivariateAdornmentBaseView.extend({displayProperties:["primaryAxisView.model.lowerBound","primaryAxisView.model.upperBound"],binArrays:null,overlap:0,binWidthInWorldCoordinates:function(){var a=this.get("primaryAxisView"),b=this.calcPointRadius();return Math.abs(a.coordinateToData(2*b)-a.coordinateToData(0))}.property(),primaryAxisViewDidChange:function(){arguments.callee.base.apply(this,arguments);var a=this.get("multipleMovableValuesAdorn");if(a){a.set("valueAxisView",this.get("primaryAxisView"))}},getAxisViewDescriptions:function(){var a=arguments.callee.base.apply(this,arguments),b=this.getPath("model.orientation")===DG.GraphTypes.EOrientation.kVertical?"x":"y";a.push({axisKey:b,axisClass:DG.CellLinearAxisView});return a},prepareToResetCoordinates:function(){this.zeroBinArray()},createAnimatingElement:function(c,g,f){var h=this.getPath("primaryAxisView.orientation")==="horizontal",j=f&&f.type==="rect",d=f&&f.isNegativeBar,e=this.callCreateElement(c,g,false);if(f){var b=j?f.x:f.cx,a=j?f.y:f.cy,i;if(j){b+=h?(d?0:f.width):f.width/2;a+=h?f.height/2:(d?f.height:0)}i=f&&{r:j?Math.min(f.width,f.height)/2:f.r||this._pointRadius,cx:b,cy:a,fill:f.fill,stroke:f.stroke};i&&e.attr(i)}return e},setCircleCoordinate:function(r,n,m,g,i){var t=this.get("plottedElements");DG.assert(n,"There must be a case");DG.assert(DG.MathUtilities.isInIntegerRange(m,0,t.length),"index %@ out of bounds for plottedElements of length %@".loc(m,t.length));var f=t[m],c=n.getForcedNumericValue(r.primaryVarID),h=r.primaryAxisView.dataToCoordinate(c),p=(!DG.isFinite(h)||r.primaryAxisPlace===DG.GraphTypes.EPlace.eUndefined);if(this.showHidePlottedElement(f,p,m)&&r.categoryAxisModel){var v=r.categoryAxisModel.cellNameToCellNumber(n.getStrValue(r.categoryVarID)),l=SC.none(v)?0:r.categoryAxisView.cellToCoordinate(v),x=r.categoryAxisView.get("fullCellWidth")/2,u=this._pointRadius,q=this.get("binArrays"),s=q&&(v<q.length)&&q[v],k,j;var e=Math.round(h/(2*u)),d=(s&&s.length)||0,w=(s&&e>=0&&e<d)?s[e].counter++:0,o=this.get("overlap"),a=u+(2*u-o)*w+1;switch(r.primaryAxisPlace){case DG.GraphTypes.EPlace.eX:k=h;j=l-a+x;break;case DG.GraphTypes.EPlace.eY:k=l+a-x;j=h;break}var b={cx:k,cy:j,r:this.radiusForCircleElement(f),fill:r.calcCaseColorString(n),stroke:r.calcStrokeColorString(n),"fill-opacity":r.transparency,"stroke-opacity":r.strokeTransparency};this.updatePlottedElement(f,b,g,i);return{cx:k,cy:j,r:u}}return null},assignElementAttributes:function(d,g,k){arguments.callee.base.apply(this,arguments);var f=this,e=this.getPath("model.primaryAxisPlace"),b=false,h=1,i=null,c;function j(l){var n=f.getPath("model.primaryVarID"),m={operation:"updateCases",cases:[],attributeIDs:[n],values:[[]],dirtyDocument:false},o=f.get("dataContext");if(!o){return}f.getPath("model.casesController.selection").forEach(function(p){var q=p.getForcedNumericValue(n)+l;if(f.getPath("primaryAxisView.isDateTime")){q=DG.createDate(q)}m.cases.push(p);m.values[0].push(q)});o.applyChange(m)}function a(p,q,m){if(!SC.none(q)){var n=f.getPath("model.cases").unorderedAt(p),o=f.getPath("model.primaryVarID"),l=n.getForcedNumericValue(o)-q;f.get("model").animateSelectionBackToStart([o],[l],m)}}d.hover(function(l){if(!b&&SC.none(i)){i="";this.animate({opacity:h,transform:DG.PlotUtilities.kDataHoverTransform},DG.PlotUtilities.kDataTipShowTime);f.showDataTip(this,g)}},function(l){if(!b){this.stop();this.animate({opacity:DG.PlotUtilities.kDefaultPointOpacity,transform:i},DG.PlotUtilities.kHighlightHideTime);i=null;f.hideDataTip()}}).drag(function(p,o){if(p!==0||o!==0){var l=(e===DG.GraphTypes.EPlace.eX)?this.ox+p:this.oy+o,q=f.get("primaryAxisView").coordinateToData(l),n=f.getPath("model.cases").unorderedAt(this.index).getForcedNumericValue(f.getPath("model.primaryVarID")),m=this.transform();if(isFinite(q)){SC.run(function(){this.transform(i);j(q-n);this.transform(m)}.bind(this))}}},function(l,m){if(!b){this.ox=this.attr("cx");this.oy=this.attr("cy");this.w=f.getPath("model.cases").unorderedAt(this.index).getForcedNumericValue(f.getPath("model.primaryVarID"));this.attr({opacity:h});c=DG.copy(f.getPath("model.selection"));b=true}},function(){if(b){this.animate({transform:i},DG.PlotUtilities.kHighlightHideTime);a(this.index,this.w,c);b=false}this.ox=this.oy=this.w=undefined});return d},zeroBinArray:function(){var a=this._pointRadius===0?10:2*this._pointRadius;this._zeroBinArray(a)},_zeroBinArray:function(f){var h=this,d=this.get("primaryAxisView"),e=this.get("secondaryAxisView");if(!d||!e){return}var g=e.get("model"),c=g.get("numberOfCells"),b=Math.round(Math.abs(d.get("pixelMax")-d.get("pixelMin"))/f)+1;function a(){var j=h.getPath("model.cases"),r=h.getPath("model.primaryVarID"),o=h.getPath("model.secondaryVarID"),q=f/2,k=h.get("binArrays"),l=e.get("fullCellWidth"),i=Math.round(l/(2*q))-1,n=0,p,m;j=j.filter(function(s){return DG.isFinite(s.getForcedNumericValue(r))});if(i<=0){return f}j.forEach(function(v){var s=d.dataToCoordinate(v.getForcedNumericValue(r)),u=Math.round(s/(2*q)),t=g.cellNameToCellNumber(v.getStrValue(o));if((u>=0)&&!SC.none(t)&&(t>=0)&&(t<k.length)&&(u<k[t].length)){k[t][u].total++}});p=DG.MathUtilities.max(k.map(function(s){return DG.MathUtilities.max(s.map(function(t){return t.total}))}));if(p>i){m=(p-i)*2*q;n=m/(p-1)}return n}this.set("binArrays",DG.MathUtilities.range(c).map(function(){return DG.MathUtilities.range(b).map(function(){return{total:0,counter:0}})}));this.set("overlap",a())},zoom:function(d){var f=(this.getPath("model.primaryAxisPlace")===DG.GraphTypes.EPlace.eX)?"x":"y",b=this.get("primaryAxisView"),a={},e=d.shiftKey?2:0.5,c=DG.ViewUtilities.windowToViewCoordinates({x:d.clientX,y:d.clientY},this);a[f]=b.coordinateToData(c[f]);this.get("model").dilate(a,e)},handleBackgroundClick:function(a){if(a.altKey){this.zoom(a)}},handleBackgroundDblClick:function(a){this.zoom(a)}});sc_require("components/graph/plots/univariate_adornment-base_view");DG.HistogramView=DG.UnivariateAdornmentBaseView.extend({kLineSlideHCur:DG.Browser.customCursorStr("../../../../static/dg/fr/cert/resources/cursors/LineSlideH.cur",8,8),kLineSlideVCur:DG.Browser.customCursorStr("../../../../static/dg/fr/cert/resources/cursors/LineSlide.cur",8,8),plottedElementType:"rect",barElements:null,_barToolTip:null,barToolTip:function(){if(!this._barToolTip){this._barToolTip=DG.ToolTip.create({paperSource:this,layerName:"dataTip"})}return this._barToolTip}.property(),dragInProgress:false,elementBeingDragged:null,init:function(){arguments.callee.base.apply(this,arguments);this.barElements=[]},destroy:function(){var b=this.get("layerManager"),a=this.get("plottedElements");a.forEach(function(c){b.removeElement(c,true)});a.length=0;this.barElements.forEach(function(c){["coverRect","draggableEdge"].forEach(function(d){b.removeElement(c[d]);c[d].remove()})});arguments.callee.base.apply(this,arguments)},modelDidChange:function(){var a=this.getPath("model.plottedCount");if(a){a.beginPropertyChanges();a.set("isVisible",false);a.set("isShowingCount",false);a.set("isShowingPercent",false);a.endPropertyChanges()}}.observes("model"),getAxisViewDescriptions:function(){var c=[],b=this.getPath("model.orientation")===DG.GraphTypes.EOrientation.kVertical?"y":"x",a=b==="x"?"y":"x";c.push({axisKey:b,axisClass:DG.CountAxisView});c.push({axisKey:a,axisClass:DG.CellLinearAxisView});return c},_coverRectsLayer:null,coverRectsLayer:function(){if(!this._coverRectsLayer&&this.getPath("paperSource.layerManager")){this._coverRectsLayer=this.getPath("paperSource.layerManager."+DG.LayerNames.kCoverRects)}return this._coverRectsLayer}.property(),setupAxes:function(){arguments.callee.base.apply(this,arguments);var c=this.get("secondaryAxisView"),a=this.get("primaryAxisView"),b=this.getPath("model.width");if(c&&SC.none(c.getPath("model.lowerBound"))){c.get("model").setLowerAndUpperBounds(0,1.05*this.getPath("model.maxBinCount"))}if(a&&SC.none(a.getPath("model.lowerBound"))){a.get("model").setLowerAndUpperBounds(this.getPath("model.leastBinEdge")-b,this.getPath("model.maxBinEdge")+b)}},createRenderContext:function(){var b=arguments.callee.base.apply(this,arguments),a=this.get("model");if(!b){return null}b.isVerticalOrientation=this.getPath("model.orientation")===DG.GraphTypes.EOrientation.kVertical;b.countAxisView=this.get("secondaryAxisView");b.leastBinEdgeWorld=a.get("leastBinEdge");b.leastBinEdgePixels=b.primaryAxisView.dataToCoordinate(b.leastBinEdgeWorld);b.barWidthWorld=a.get("width");b.barWidthPixels=Math.abs(b.primaryAxisView.dataToCoordinate(b.barWidthWorld)-b.primaryAxisView.dataToCoordinate(0));b.sliceHeightPixels=Math.abs(b.countAxisView.dataToCoordinate(1)-b.countAxisView.dataToCoordinate(0));return b},createElement:function(b,c,a){if(!this.get("paper")){return}var d=this.get("paper").rect(-1000,-1000,0,0).attr({fill:DG.PlotUtilities.kDefaultPointColor,stroke:"none"});d.node.setAttribute("shape-rendering","geometricPrecision");return d},updateAllCoordinates:function(a,e){var c=this.get("model"),d=this.createRenderContext(),f=this.getPath("model.cases"),b=f&&f.get("length");f.forEach(function(g,h){var j=h===b-1?e:null,i=c.infoForCase(h);this.privSetElementCoords(d,g,h,i,a,j)}.bind(this))},updateElements:function(j,a){if(!this.get("paper")){return}arguments.callee.base.apply(this,arguments);this.computeCellParams();var h=this.get("model"),c=this.getPath("model.cases"),g=this.createRenderContext(),e=c&&c.get("length"),d=this.get("plottedElements"),k=d.length,b=this.get("layerManager"),i,f;if(e>k){for(i=k;i<e;i++){this.callCreateElement(c.at(i),i,this.animationIsAllowable());f=h.lookupCellForCaseIndex(i);this.privSetElementCoords(g,c.at(i),i,f,j,a)}}if(e<k){for(i=e;i<k;i++){if(!SC.none(d[i])){d[i].stop();DG.PlotUtilities.doHideRemoveAnimation(d[i],b)}}this.updateAllCoordinates(j,a)}this._isRenderingValid=false},modelWidthOrAlignmentDidChange:function(){this.displayDidChange()}.observes("model.changed"),markBinParamsChange:function(d,b){var e=this,c=this.getPath("model.alignment"),a=this.getPath("model.width");DG.UndoHistory.execute(DG.Command.create({name:"graph.drag.binBoundary",undoString:"DG.Undo.graph.dragBinBoundary",redoString:"DG.Redo.graph.dragBinBoundary",log:"dragBinBoundary from { alignment: %@, width: %@ } to { alignment: %@, width: %@ }".fmt(d,b,c,a),executeNotification:{action:"notify",resource:"component",values:{operation:"drag bin boundary",type:"DG.GraphView"}},execute:function(){},undo:function(){e.setPath("model.alignment",d);e.setPath("model.width",b)},redo:function(){e.setPath("model.alignment",c);e.setPath("model.width",a)}}))},getElementPositionsInParentFrame:function(){var a=this.get("frame");return this.get("plottedElements").map(function(d){var i=d.attr("x")+a.x,h=d.attr("y")+a.y,e=d.attr("width"),j=d.attr("height"),b=0,g=i+e/2,f=h+j/2,c={x:i,y:h,width:e,height:j,cx:g,cy:f,r:b,fill:d.attr("fill"),type:"rect",stroke:d.attr("stroke"),"stroke-opacity":d.attr("stroke-opacity")};return c})},animateFromTransferredElements:function(){var d=this,j=this.get("model"),a=j.get("cases"),i=this.createRenderContext(),g=this.get("frame"),f=this.get("transferredElementCoordinates"),c=f[0]&&f[0].type==="circle";if(!a){return}function b(){j.set("isAnimating",false);d.get("plottedElements").forEach(function(k){k.stop()});d.displayDidChange()}DG.sounds.playMixup();var e=this.get("plottedElements"),h;this.prepareToResetCoordinates();this.removePlottedElements();e.forEach(function(k){k.remove()});e.length=0;f.forEach(function(l,k){l.cx-=g.x;l.cy-=g.y;l.x-=g.x;l.y-=g.y});a.forEach(function(l,m){var o=f[m],n=j.infoForCase(m),k=d.callCreateElement(l,m,false);if(!SC.none(o)){h={r:c?o.r:0,x:c?o.cx-o.r:o.x,y:c?o.cy-o.r:o.y,width:c?2*o.r:o.width,height:c?2*o.r:o.height,fill:o.fill,stroke:o.fill};k.attr(h)}k=d.privSetElementCoords(i,l,m,n,true)});this.set("transferredElementCoordinates",null);j.set("isAnimating",true);SC.Timer.schedule({action:b,interval:DG.PlotUtilities.kDefaultAnimationTime})},resetCoordinates:function(d,c){var a=this.get("plottedElements").length,b=this.get("model");this.prepareToResetCoordinates();d.forEach(function(e,f){if(f>=a){this.callCreateElement(e,f,true,c.isVisible)}this.privSetElementCoords(c,e,f,b.infoForCase(f))}.bind(this));this._mustMoveElementsToNewCoordinates=false},setCircleCoordinate:function(c,a,b){this.privSetElementCoords(c,a,b,this.get("model").infoForCase(b))},privSetElementCoords:function(e,b,i,a,m,c){DG.assert(e&&e.xAxisView);DG.assert(b);DG.assert(DG.MathUtilities.isInIntegerRange(i,0,this.get("plottedElements").length));var n=this.get("plottedElements")[i];if(!a){return}var h=e.countAxisView.dataToCoordinate(a.indexInBin+1),f=e.primaryAxisView.dataToCoordinate(e.leastBinEdgeWorld+(a.bin)*e.barWidthWorld),l,k,g,j;if(e.isVerticalOrientation){l=f;k=h;g=e.barWidthPixels;j=e.sliceHeightPixels}else{l=h-e.sliceHeightPixels;k=f-e.barWidthPixels;g=e.sliceHeightPixels;j=e.barWidthPixels}var d={x:l,y:k,r:0.1,width:g,height:j,fill:e.calcCaseColorString(b),"fill-opacity":e.transparency,"stroke-opacity":0,opacity:1};if(m){n.show();n.animate(d,DG.PlotUtilities.kDefaultAnimationTime,"<>",c)}else{n.attr(d);n.show()}return n},drawCoverRectsAndBoundaries:function(){function g(A,y){var w=DG.PlotUtilities.findFractionDigitsForAxis(m),x=DG.Format.number().fractionDigits(0,w),z=u.rect(0,0,0,0).attr({stroke:DG.PlotUtilities.kBinBorderLineColor,fill:"white","fill-opacity":0.001,cursor:"pointer"}).hover(function(B){var C=h.getPath("model.totalCount");if(h.dragInProgress){return}this.animate({"fill-opacity":0.4},DG.PlotUtilities.kDataTipShowTime);d=h.getPath("model.width");t=h.getPath("model.leastBinEdge");a=h.get("barToolTip");s=A.count>1?"DG.HistogramView.barTipNoLegendPlural":"DG.HistogramView.barTipNoLegendSingular";r=s.loc(this.indices.length,C,Math.round(1000*(this.indices.length)/C)/10,x(t+y*d),x(t+(y+1)*d));a.set("text",r);a.set("tipOrigin",{x:B.layerX,y:B.layerY});a.show()},function(B){this.stop();this.animate({"fill-opacity":0.001},DG.PlotUtilities.kHighlightHideTime);if(a){a.hide()}}).mousedown(function(B){SC.run(function(){h.get("model").selectCasesWithIndices(this.indices,B.shiftKey)}.bind(this))});z.indices=A.indices;return z}function b(B,A,z){var w=l?m.dataToCoordinate(t+z*d):0,C=l?o.dataToCoordinate(A.count):m.dataToCoordinate(t+(z+1)*d),y=l?c:o.dataToCoordinate(A.count),x=l?o.get("pixelMin")-o.dataToCoordinate(A.count):c;B.indices=A.indices;B.attr({x:w,y:C,width:y,height:x})}function p(B,F){var J=h.get("model"),x=10,C,z,K,E,H,D,A;function G(N,M){h.dragInProgress=true;h.elementBeingDragged=this;C=J.get("alignment");z=J.get("width");K=J.get("width");E=J.get("widthIncrement");c=Math.abs(m.dataToCoordinate(d)-m.dataToCoordinate(0));H=z/c;D=Math.abs(m.dataToCoordinate(z)-m.dataToCoordinate(0));h.set("binNumBeingDragged",F);A=this.lowerEdgeWorld;J.set("alignment",A)}function I(P,O){var N=l?P:-O,M=(D+N)*H;M=Math.round(M/E)*E;if(D+N>=x){SC.run(function(){J.set("width",M)})}}function y(O,N){var M=J.get("width");if(A!==C||K!==M){h.markBinParamsChange(C,K)}h.set("binNumBeingDragged",null);h.dragInProgress=false;if(h.elementBeingDragged.shouldGoAway){q.prepareToMoveOrRemove(h.elementBeingDragged);h.elementBeingDragged.remove();h.elementBeingDragged=null}h.displayDidChange()}var w=u.line(0,0,0,0).drag(I,G,y);w.binNum=F;return w.attr({"stroke-width":6,stroke:DG.RenderingUtilities.kSeeThrough,cursor:f,title:k})}function e(w,C,B){var y=l?m.dataToCoordinate(t+(B+1)*d):0,A=l?o.dataToCoordinate(C.count):m.dataToCoordinate(t+(B+1)*d),x=l?y:o.dataToCoordinate(C.count),z=l?o.get("pixelMin"):A;w.count=C.count;w.binNum=B;w.lowerEdgeWorld=C.lowerEdgeWorld;DG.RenderingUtilities.updateLine(w,{x:y,y:A},{x:x,y:z})}var h=this,u=this.get("paper"),m=this.get("primaryAxisView"),o=this.get("secondaryAxisView"),l=this.getPath("model.orientation")===DG.GraphTypes.EOrientation.kVertical,q=this.get("coverRectsLayer"),t=this.getPath("model.leastBinEdge"),d=this.getPath("model.width"),c=Math.abs(m.dataToCoordinate(d)-m.dataToCoordinate(0)),v=this.get("barElements"),j=this.getPath("model.bars"),i=j.length,f=l?h.kLineSlideHCur:h.kLineSlideVCur,k="DG.BinnedPlotModel.dragBinTip".loc(),s,r,a;j.forEach(function(x,w){if(!v[w]){v[w]={coverRect:g(x,w),draggableEdge:p(x,w)};q.push(v[w].coverRect);q.push(v[w].draggableEdge)}else{b(v[w].coverRect,x,w);e(v[w].draggableEdge,x,w)}});while(v.length>i){var n=v.pop();["coverRect","draggableEdge"].forEach(function(w){if(n[w]!==h.elementBeingDragged){q.prepareToMoveOrRemove(n[w]);n[w].remove()}else{h.elementBeingDragged.shouldGoAway=true}})}v.forEach(function(w){q.bringToFront(w.draggableEdge)})},doDraw:function doDraw(){arguments.callee.base.apply(this,arguments);this.drawData();this.drawCoverRectsAndBoundaries()}});sc_require("components/graph/plots/dot_plot_model");DG.LinePlotModel=DG.DotPlotModel.extend({displayAsBinned:"bars",handleDataConfigurationChange:function(a){this.updateAdornmentModels()}});DG.LinePlotModel.configureRoles=function(a){DG.UnivariatePlotModel.configureRoles(a)};sc_require("components/graph/plots/dot_plot_view");DG.LinePlotView=DG.DotPlotView.extend({plottedElementType:"rect",cellCaseInfo:null,maxCaseCountInCell:0,setupAxes:function(){arguments.callee.base.apply(this,arguments);this.setPath("primaryAxisView.model.preferZeroLowerBound",true);this.setPath("primaryAxisView.model.drawZeroLine",true);this.setPath("secondaryAxisView.centering",true);var a=this.get("model");a&&a.rescaleAxesFromData(true)},updateCellCaseInfo:function(){var c=this.getPath("secondaryAxisView.model");if(!c){return}var d=c.get("numberOfCells"),g=new Array(d),f=0;for(var b=0;b<d;++b){g[b]={caseCount:0,indexMap:{}}}var e=this.getPath("model.cases"),a=this.getPath("model.secondaryVarID");if(e){e.forEach(function(j,k){var i=c.cellNameToCellNumber(j.getStrValue(a));if(i>=0){var h=g[i];if(h){h.indexMap[k]=h.caseCount;if(++h.caseCount>f){f=h.caseCount}}}})}this.set("cellCaseInfo",g);this.set("maxCaseCountInCell",f)},prepareToResetCoordinates:function(){arguments.callee.base.apply(this,arguments);this.updateCellCaseInfo()},createElement:function(b,c,a){if(!this.get("paper")){return}var d=this.get("paper").rect(-1000,-1000,0,0).attr({fill:DG.PlotUtilities.kDefaultPointColor,stroke:"none"});d.node.setAttribute("shape-rendering","geometricPrecision");return d},getElementPositionsInParentFrame:function(){var a=this.get("frame"),b=this.get("plottedElements");DG.assert(b.length===0||b[0][0].constructor===SVGRectElement,"Expecting rectangle");return b.map(function(e){var c=e.attr("x")+a.x,g=e.attr("y")+a.y,f=e.isHidden()?0:e.attr("width"),d=e.isHidden()?0:e.attr("height");return{x:c,y:g,width:f,height:d,fill:e.attr("fill"),stroke:e.attr("stroke"),type:"rect",isNegativeBar:e._isNegativeBar}})},createAnimatingElement:function(d,e,f){var a=f&&f.type==="circle",b=this.callCreateElement(d,e,false),c=f&&{r:a?f.r:0,x:a?f.cx-f.r:f.x,y:a?f.cy-f.r:f.y,width:a?2*f.r:f.width,height:a?2*f.r:f.height,fill:f.fill,stroke:f.stroke};c&&b.attr(c);return b},setCircleCoordinate:function(t,p,o,f,h){var v=this.get("plottedElements");DG.assert(p,"There must be a case");DG.assert(DG.MathUtilities.isInIntegerRange(o,0,v.length),"index %@ out of bounds for plottedElements of length %@".loc(o,v.length));var y=v[o],e=p.getForcedNumericValue(t.primaryVarID),g=t.primaryAxisView.dataToCoordinate(e),m=t.primaryAxisView.dataToCoordinate(0),r=!DG.isFinite(g)||(t.primaryAxisPlace===DG.GraphTypes.EPlace.eUndefined);y._isNegativeBar=e<0;if(this.showHidePlottedElement(y,r,o)&&t.categoryAxisModel){var w=t.categoryAxisModel.cellNameToCellNumber(p.getStrValue(t.categoryVarID)),a=this.get("maxCaseCountInCell"),u=this.get("cellCaseInfo")[w],z=u?u.indexMap[o]:0,b=u?u.caseCount:0,l=SC.none(w)?0:t.categoryAxisView.cellToCoordinate(w),i=t.categoryAxisView.get("fullCellWidth"),x=l-i/2,n=i/(a+1),q=(a-b)*n/2,k,j,d,s;switch(t.primaryAxisPlace){case DG.GraphTypes.EPlace.eX:k=e<0?g:m;j=x+i-(q+(z+1.5)*n);d=Math.abs(g-m);s=n;break;case DG.GraphTypes.EPlace.eY:k=x+q+(z+0.5)*n;j=e<0?m:g;d=n;s=Math.abs(g-m);break}var c={x:k,y:j,width:d,height:s,r:0.1,fill:t.calcCaseColorString(p),stroke:t.calcStrokeColorString(p),"fill-opacity":t.transparency,"stroke-opacity":t.strokeTransparency};this.updatePlottedElement(y,c,f,h);return{x:k,y:j,width:d,height:s}}return null},showDataTip:function(c,a,b){if(DG.NO_DATA_TIP_PREF||this.getPath("paperSource.tempDisallowDataTips")){return}this.get("dataTip").show(b.offsetX,b.offsetY,8,a)},assignElementAttributes:function(d,c,b){var e=this,a=1;if(d.events){d.events.forEach(function(f){f.unbind()});d.events.length=0}d.addClass(DG.PlotUtilities.kColoredDotClassName).attr({cursor:"pointer"}).mousedown(function(f){SC.run(function(){e.get("model").selectCaseByIndex(c,f.shiftKey)})});d.index=c;d.hover(function(f){this.animate({opacity:a},DG.PlotUtilities.kHighlightHideTime);e.showDataTip(this,c,f)},function(f){this.stop();this.animate({opacity:DG.PlotUtilities.kDefaultPointOpacity},DG.PlotUtilities.kHighlightHideTime);e.hideDataTip()});return d}});DG.NumberToggleModel=SC.Object.extend((function(){function b(d,c){d.push(c);return d}function a(d,f,c){var e=[];f.reduce(b,e);f.forEach(function(h){var g=h.get("children");if(g&&g.length){g.reduce(b,e)}});if(c){d.showCases(e)}else{d.hideCases(e)}}return{dataConfiguration:null,hiddenCasesBinding:"*dataConfiguration.hiddenCases",lastMode:false,_cachedCaseCount:null,_cachedParentCases:null,invalidate:function(){this._cachedCaseCount=this._cachedParentCases=this._isHierarchical=null;this.invokeOnceLater(this.propertyDidChange,1,"caseCount")},isEnabledDidChange:function(){if(this.get("isEnabled")){this.invalidate()}}.observes("isEnabled"),parentCases:function(){var d=[],f=this.getPath("dataConfiguration.allCases"),c=false;if(!f){return[]}f=f.slice();function e(h){var g;while(h){g=h;h=h.get("parent");if(h){c=true}}return g}if(f.get("length")===this._cachedCaseCount){d=this._cachedParentCases}else{f.forEach(function(h){var g=e(h);if(g&&d.indexOf(g)<0){d.push(g)}});this._cachedCaseCount=f.get("length");this._cachedParentCases=d;this._isHierarchical=c}return d}.property(),parentCasesDidChange:function(){this.notifyPropertyChange("parentCases")}.observes("*dataConfiguration.cases"),getFirstParentAttribute:function(){var d=this.getPath("dataConfiguration.dataContext"),c=d&&d.getCollectionAtIndex(0),e=c&&c.getPath("collection.attrs");return e&&e[0]},getParentLabel:function(e){var f=this.get("parentCases"),d=f&&f[e],c=this.getFirstParentAttribute(),g=d&&c&&d.getStrValue(c.get("id"));return !SC.empty(g)?g:(e+1).toString()},getParentTooltip:function(c){return SC.String.loc("DG.NumberToggleView.indexTooltip")},numberOfParents:function(){return this.get("parentCases").length}.property("parentCases"),indicesRepresentChildren:function(){this.get("parentCases");return this._isHierarchical}.property("numberOfParents"),numberOfToggleIndices:function(){var d=this.get("dataConfiguration"),e=(d&&d.get("allCases")),c=e?e.length():0;if(this.get("indicesRepresentChildren")){return this.get("numberOfParents")}else{return c}}.property(),numberOfToggleIndicesDidChange:function(){this.notifyPropertyChange("numberOfToggleIndices")}.observes("*dataConfiguration.allCases"),childrenOfParent:function(g){var c=this.get("parentCases"),d=(g<c.length)?c[g]:null,f=d?d.get("children").slice():[];for(var e=0;e<f.get("length");++e){var j=f.objectAt(e),h=j.get("children");if(h&&h.get("length")){h.forEach(function(i){f.push(i)})}}return f},allCasesAreVisible:function(){var c=this.get("hiddenCases");return !c||!c.length},_isChangingVisibility:0,beginVisibilityChanges:function(){++this._isChangingVisibility},endVisibilityChanges:function(){this.invokeLater(function(){--this._isChangingVisibility}.bind(this))},isChangingVisibility:function(){return this._isChangingVisibility>0},changeAllCaseVisibility:function(){var c=this.get("dataConfiguration");this.beginVisibilityChanges();if(this.allCasesAreVisible()){a(c,c.get("cases"),false)}else{a(c,c.get("hiddenCases"),true)}this.endVisibilityChanges()},getCasesForIndex:function(f){var h=this.get("dataConfiguration"),c;if(this.get("indicesRepresentChildren")){c=this.childrenOfParent(f)}else{var g=h?h.get("allCases"):[],d=g?g.slice():[],e=(d.length>f)?d[f]:null;c=e?[e]:null}return c},toggleChildrenVisibility:function(d){var c=this.childrenOfParent(d),e=this.get("dataConfiguration");this.beginVisibilityChanges();a(e,c,this.allChildrenAreHidden(d));this.endVisibilityChanges()},toggleVisibility:function(f){if(this.get("indicesRepresentChildren")){this.toggleChildrenVisibility(f)}else{var g=this.get("dataConfiguration"),c=g?g.get("allCases").slice():[],d=g?g.get("hiddenCases"):[],e=(c.length>f)?c[f]:null;this.beginVisibilityChanges();a(g,[e],d.indexOf(e)>=0);this.endVisibilityChanges()}},setVisibility:function(e,c){var f=this.get("dataConfiguration"),d=this.getCasesForIndex(e);if(d){this.beginVisibilityChanges();a(f,d,c);this.endVisibilityChanges()}},lastModeDidChange:function(){var c=this.get("lastMode");if(c){this.showOnlyLastParentCase()}}.observes("lastMode"),showOnlyLastParentCase:function(){var f,d=this.get("numberOfToggleIndices"),e=[],c;this.beginVisibilityChanges();for(f=0;f<d-1;++f){c=this.getCasesForIndex(f);c.reduce(b,e)}if(e&&e.length){a(this.get("dataConfiguration"),e,false)}this.setVisibility(f,true);this.endVisibilityChanges()},maintainCurrentParentVisibility:function(f){var g,d=this.get("numberOfToggleIndices"),e=[],c;this.beginVisibilityChanges();for(g=0;g<d;++g){if(f.indexOf(g)<0){c=this.getCasesForIndex(g);c.reduce(b,e)}}if(e&&e.length){a(this.get("dataConfiguration"),e,false)}this.endVisibilityChanges()},allChildrenAreHidden:function(f){var e=this.childrenOfParent(f),h=this.getPath("dataConfiguration.cases"),d=this.get("hiddenCases"),c={},g={};(h||[]).forEach(function(i){c[i.get("id")]=true});(d||[]).forEach(function(i){if(i){g[i.get("id")]=true}});return !e.some(function(j){var i=j.get("id");return c[i]&&!g[i]})},allChildrenAreVisible:function(f){var e=this.childrenOfParent(f),h=this.getPath("dataConfiguration.cases"),d=this.get("hiddenCases"),c={},g={};(h||[]).forEach(function(i){c[i.get("id")]=true});(d||[]).forEach(function(i){if(i){g[i.get("id")]=true}});return e.every(function(j){var i=j.get("id");return !g[i]})},casesForIndexAreHidden:function(f){if(this.get("indicesRepresentChildren")){return this.allChildrenAreHidden(f)}else{var g=this.get("dataConfiguration"),c=g?g.get("allCases").slice():[],d=g?g.get("hiddenCases"):[],e=(c.length>f)?c[f]:null;return(d.indexOf(e)>=0)}},allCasesAreHidden:function(){return this.get("dataConfiguration").getCaseCount()===0},hiddenCasesDidChange:function(){if(this.get("lastMode")&&!this.isChangingVisibility()){this.set("lastMode",false)}}.observes("hiddenCases"),shouldMaintainCurrentParentVisbility:function(f){var c=this.get("numberOfToggleIndices")-1,d=0,e=0;f.parentIndices=[];if(c>1){while(e<c){if(this.allChildrenAreVisible(e)){d++;f.parentIndices.push(e)}e++}}return d>0&&d<c},isAffectedByChange:function(e){function c(g){var f=["createCollection","deleteCollection","moveCases","moveAttribute","createCases","createCase","deleteCases","createAttributes","updateAttributes","deleteAttributes"];return f.indexOf(g.operation)>=0}var d=function(f){if(f.operation==="updateCases"){var g=this.getFirstParentAttribute(),h=g&&g.get("id");if(f.attributeIDs){if(f.attributeIDs.indexOf(h)>=0){return true}}}return false}.bind(this);return c(e)||d(e)},handleDataContextNotification:function(d,e){var c=e.operation.indexOf("createCase")===0,f={parentIndices:null};if(this.get("isEnabled")){if(this.get("lastMode")&&c){this.invokeOnce(function(){this.showOnlyLastParentCase()}.bind(this))}else{if(c&&this.shouldMaintainCurrentParentVisbility(f)){this.invokeOnce(function(){this.maintainCurrentParentVisibility(f.parentIndices)}.bind(this))}else{if(this.isAffectedByChange(e)){this.invalidate()}}}}}}})());sc_require("views/raphael_base");sc_require("utilities/rendering_utilities");DG.NumberToggleView=DG.RaphaelBaseView.extend((function(){var f="Montserrat-Regular, sans-serif",e="11px",c="18px",b=33,a=SC.Object.extend({paper:null,url:null,depressedUrl:null,action:null,target:null,arrow:null,depressedArrow:null,_position:null,_state:null,kHeight:19,init:function(){arguments.callee.base.apply(this,arguments);var g=false,h=this;this._position={x:0,y:0};this.arrow=this.paper.image(this.url,0,0,b,this.kHeight).hide().attr({cursor:"pointer"}).mousedown(function(){g=true;h._state="depressed";h.show()});this.depressedArrow=this.paper.image(this.depressedUrl,0,0,b,this.kHeight).hide().mouseup(function(){if(g&&h.action){h.action.call(h.target)}g=false;h._state="normal";h.show()})},position:function(g,h){if(h){this._position=h;if(this.arrow){this.arrow.attr(this._position)}if(this.depressedArrow){this.depressedArrow.attr(this._position)}}return this._position}.property(),show:function(){if(!this._state){this._state="normal"}switch(this._state){case"normal":this.arrow.show();this.depressedArrow.hide();break;case"depressed":this.depressedArrow.show();this.arrow.hide();break}return this},hide:function(){this.arrow.hide();this.depressedArrow.hide();return this}});return{displayProperties:["lastMode","firstDisplayedIndex","lastDisplayedIndex"],classNames:"dg-number-toggle".w(),model:null,isVisibleBinding:SC.Binding.oneWay("*model.isEnabled"),lastModeBinding:"*model.lastMode",layout:{left:0,top:0,right:0,height:DG.RenderingUtilities.kCaptionFontHeight},firstDisplayedIndex:0,lastDisplayedIndex:0,_leftArrow:null,_rightArrow:null,leftArrow:function(){if(this._paper&&!this._leftArrow){this._leftArrow=a.create({paper:this._paper,url:"../../../../static/dg/fr/cert/source/resources/images/arrow_left.png",depressedUrl:"../../../../static/dg/fr/cert/source/resources/images/arrow_left_depressed.png",action:this.scrollLeft,target:this})}return this._leftArrow}.property(),rightArrow:function(){if(this._paper&&!this._rightArrow){this._rightArrow=a.create({paper:this._paper,url:"../../../../static/dg/fr/cert/source/resources/images/arrow_right.png",depressedUrl:"../../../../static/dg/fr/cert/source/resources/images/arrow_right_depressed.png",action:this.scrollRight,target:this})}return this._rightArrow}.property(),desiredExtent:function(){return DG.RenderingUtilities.kCaptionFontHeight}.property(),init:function(){arguments.callee.base.apply(this,arguments);this.lastDisplayedIndex=this.getPath("model.numberOfToggleIndices")-1},doDraw:function d(){var n=function(i){DG.logUser("Show parent: %@",i.toggleIndex+1);SC.run(function(){this.set("lastMode",false);this.get("model").toggleVisibility(i.toggleIndex)}.bind(this))}.bind(this),y=function(){var i=this.get("model");SC.run(function(){this.set("lastMode",false);i.changeAllCaseVisibility()}.bind(this));if(i.allCasesAreHidden()){DG.logUser("Hide all:")}else{DG.logUser("Show all:")}}.bind(this),F=function(){SC.run(function(){var i=this.get("lastMode");this.set("lastMode",!i)}.bind(this))}.bind(this),G=function(){var i=false,K=x.allCasesAreVisible()?"DG.NumberToggleView.hideAll".loc():"DG.NumberToggleView.showAll".loc(),N=x.allCasesAreVisible()?"DG.NumberToggleView.hideAllTooltip".loc():"DG.NumberToggleView.showAllTooltip".loc(),M=6;return this._paper.text(M,0,K).attr({"font-family":f,"font-size":e,cursor:"pointer","text-anchor":"start",fill:"black",title:N}).mousedown(function(){i=true}).mouseup(function(){if(i){y()}i=false})}.bind(this),k=function(){var S=this.get("lastMode"),i=S?"DG.NumberToggleView.lastChecked".loc():"DG.NumberToggleView.lastUnchecked".loc(),R="DG.NumberToggleView.lastLabel".loc(),K=S?"DG.NumberToggleView.disableLastModeTooltip".loc():"DG.NumberToggleView.enableLastModeTooltip".loc(),M=false,O=this._paper.text(-9999,0,"DG.NumberToggleView.lastDash".loc()).attr({"font-family":f,"font-size":e,cursor:"pointer","text-anchor":"start",fill:"black"}),P=this._paper.text(-9999,0,i).attr({"font-family":f,"font-size":c,cursor:"pointer","text-anchor":"start",fill:"black",title:K}).mousedown(function(){M=true}).mouseup(function(){if(M){F()}M=false}),N=this._paper.text(-9999,0,R).attr({"font-family":f,"font-size":e,cursor:"pointer","text-anchor":"start",fill:"black",title:K}).mousedown(function(){M=true}).mouseup(function(){if(M){F()}M=false});var Q=[O,P,N];Q.forEach(function(T){T.width=T.getBBox().width});return Q}.bind(this),j=function(R){var T,M=false;function i(U){M=true}function Q(U){if(M){n(this)}M=false}var O=function(U){I.push(U);g+=U.width+l;this._elementsToClear.push(U)}.bind(this);var P;for(T=0;T<m;T++){var K=x.getParentLabel(T),S=x.getParentTooltip(T),N=x.casesForIndexAreHidden(T)?"lightGray":"black";P=this._paper.text(-9999,v,K).attr({"font-family":f,"font-size":e,cursor:"pointer","text-anchor":"start",fill:N,title:S}).mousedown(i).mouseup(Q);P.width=P.getBBox().width;P.toggleIndex=T;O(P)}if(R){R.forEach(function(U){O(U)})}}.bind(this),B=function(){var K=s,N,O=m;if(D){J=this.get("leftArrow").show();J.set("position",{x:K,y:0});K+=b}else{this.get("leftArrow").hide()}for(N=this.firstDisplayedIndex;N<=this.lastDisplayedIndex;N++){I[N].attr({x:K});K+=I[N].width+l}if(r){w=this.get("rightArrow").show();w.set("position",{x:K-l,y:0});K+=b}else{this.get("rightArrow").hide()}for(var M=O;M<I.length;++M){if(I[M]){var P=M===I.length-2?-1:0;if(M===I.length-1){K-=5}I[M].attr({x:K,y:v+P});K+=I[M].width+l}}}.bind(this);if(!this.get("isVisible")){return}var l=5,x=this.get("model"),m=x.get("numberOfToggleIndices"),p=G(),A=p.getBBox(),E=k(),v=2+A.height/2,s=A.x+A.width+l,o=E.reduce(function(K,i){return K+i.width+l},0),h=s+l+o+l,t=this._paper.width-h,r,D,w,J,I=[],g=0,C,H,q;this._elementsToClear.push(p);if(!DG.isFinite(s)||!DG.isFinite(v)){return}if(v===0){this.invokeLast(this.displayDidChange);return}p.attr({y:v});j(E);if(g<=t){r=D=false;this.firstDisplayedIndex=0;this.lastDisplayedIndex=m-1}else{r=this.lastDisplayedIndex<m-1;D=true;H=b+(r?b:0);C=this.lastDisplayedIndex+1;while(C>0){q=I[C-1].width+l;if((H+q<t)||(C===this.lastDisplayedIndex+1)){C--;H+=q}else{break}}var z,u=0;for(z=0;z<C;++z){u+=I[z].width+l}if(H+u-b<t){C=0;H+=u}this.firstDisplayedIndex=C;if(this.firstDisplayedIndex===0){D=false;H-=b}if(r){C=this.lastDisplayedIndex+1;while(C<m){q=I[C].width+l;if(H+q<t){this.lastDisplayedIndex=C++;H+=q}else{break}}u=0;for(z=this.lastDisplayedIndex+1;z<m;++z){u+=I[z].width+l}if(H+u-b<t){this.lastDisplayedIndex=m-1;r=false}}if(this._prevScroll&&this._prevScroll.scrollBy&&(this.firstDisplayedIndex===this._prevScroll.first)&&(this.lastDisplayedIndex===this._prevScroll.last)){if(this._prevScroll.scrollBy<0){--this.firstDisplayedIndex;--this.lastDisplayedIndex}else{++this.firstDisplayedIndex;++this.lastDisplayedIndex}D=this.firstDisplayedIndex>0;r=this.lastDisplayedIndex<m-1}}this._prevScroll=null;B()},scrollLeft:function(){var h=this.get("firstDisplayedIndex"),j=this.get("lastDisplayedIndex"),i=(j-h)||1,g=Math.min(h,i);this._prevScroll={first:h,last:j,scrollBy:-g};this.decrementProperty("lastDisplayedIndex",g)},scrollRight:function(){var h=this.get("firstDisplayedIndex"),k=this.get("lastDisplayedIndex"),j=(k-h)||1,i=this.getPath("model.numberOfToggleIndices"),g=Math.min(i-k-1,j);this._prevScroll={first:h,last:k,scrollBy:g};this.incrementProperty("lastDisplayedIndex",g)},shouldShow:function(){return this.getPath("model.isEnabled")},handleCaseCountChange:function(){this.set("lastDisplayedIndex",this.getPath("model.numberOfToggleIndices")-1);this.displayDidChange()}.observes("model.caseCount"),handleHiddenCasesChange:function(){this.displayDidChange()}.observes("model.hiddenCases")}}()));sc_require("components/graph/utilities/graph_drop_target");sc_require("views/raphael_base");DG.PlotBackgroundView=DG.RaphaelBaseView.extend(DG.GraphDropTarget,(function(){var b;return{autoDestroyProperties:["_backgroundForClick"],displayProperties:["xAxisView.model.lowerBound","xAxisView.model.upperBound","xAxisView.model.drawZeroLine","yAxisView.model.lowerBound","yAxisView.model.upperBound","yAxisView.model.drawZeroLine","xAxisView.model.attributeDescription.attributeStats.categoricalStats.numberOfCells","yAxisView.model.attributeDescription.attributeStats.categoricalStats.numberOfCells","graphModel.plotBackgroundColor","graphModel.plotBackgroundOpacity","messages"],classNames:"dg-plot-view".w(),classNameBindings:["graphModel.isTransparent:dg-plot-view-transparent"],graphModel:null,xAxisView:null,yAxisView:null,rowIndex:0,colIndex:0,tempDisallowDataTips:false,_backgroundForClick:null,_backgroundImage:null,darkenBackground:false,messages:null,_messageElements:null,colorDidChange:function(){var c=this.getPath("graphModel.plotBackgroundColor")||"white",e=this.getPath("graphModel.plotBackgroundOpacity"),d=c?SC.Color.from(c):null;if(!d){return}if(this.get("darkenBackground")){d=d.sub(SC.Color.from("#101010"))}if(!SC.none(e)){d.set("a",e)}this.set("backgroundColor",d.get("cssText"))}.observes(".graphModel.plotBackgroundColor",".graphModel.plotBackgroundOpacity"),backgroundImageDidChange:function(){var c=this.getPath("graphModel.plotBackgroundImage");if(c===null){c=""}if(this._backgroundImage.attr("src")!==c){this._backgroundImage.attr("src",c)}}.observes(".graphModel.plotBackgroundImage"),didCreateLayer:function(){var c=this.get("parentView");arguments.callee.base.apply(this,arguments);c.getPlotViewArray(this.get("rowIndex"),this.get("colIndex")).forEach(function(d){d.didCreateLayer()});c.drawPlots()},init:function(){arguments.callee.base.apply(this,arguments);this.set("backgroundColor","white");this.colorDidChange();this.messages=[];this._messageElements=[]},initLayerManager:function(){arguments.callee.base.apply(this,arguments);if(!this._layerManager){return}var c=DG.LayerNames;this.get("layerManager").addNamedLayer(c.kBackgroundImage).addNamedLayer(c.kBackground).addNamedLayer(c.kGrid).addNamedLayer(c.kIntervalShading).addNamedLayer(c.kClick).addNamedLayer(c.kGhost).addNamedLayer(c.kConnectingLines).addNamedLayer(c.kPoints).addNamedLayer(c.kSelectedPoints).addNamedLayer(c.kAdornments).addNamedLayer(c.kDataTip).addNamedLayer(c.kCoverRects);this._backgroundImage=this._paper.image("",0,0,this._paper.width,this._paper.height);this.getPath("layerManager."+DG.LayerNames.kBackgroundImage).push(this._backgroundImage)},prepareMarquee:function(){b={this_:this,marquee:null,lastRect:null,startPt:null,needToDeselectAll:null,baseSelection:[]}},startMarquee:function(d,c,e,f){if(e.altKey){return}b.needToDeselectAll=true;b.this_.set("tempDisallowDataTips",true);if(e.shiftKey||f){b.baseSelection=b.this_.getPath("graphModel.selection").toArray();b.needToDeselectAll=false}else{if(DG.ComponentView.isComponentViewForViewSelected(b.this_)){b.needToDeselectAll=false;SC.run(function(){b.this_.get("graphModel").selectAll(false)})}}b.startPt=DG.ViewUtilities.windowToViewCoordinates({x:d,y:c},b.this_);b.marquee=b.this_._paper.rect(b.startPt.x,b.startPt.y,0,0).attr({fill:DG.PlotUtilities.kMarqueeColor,stroke:DG.RenderingUtilities.kTransparent});b.lastRect={x:b.startPt.x,y:b.startPt.y,width:0,height:0};b.this_.getPath("layerManager."+DG.LayerNames.kAdornments).push(b.marquee);b.this_.get("parentView").prepareToSelectPoints();return b.startPt},continueMarquee:function(i,g){if(SC.none(b.marquee)){return}var c=(i>0)?b.startPt.x:b.startPt.x+i,h=(g>0)?b.startPt.y:b.startPt.y+g,f=Math.abs(i),e=Math.abs(g),d={x:c,y:h,width:f,height:e};b.marquee.attr(d);if(b.needToDeselectAll){SC.run(function(){b.this_.get("graphModel").selectAll(false);b.needToDeselectAll=false})}SC.run(function(){b.this_.get("parentView").selectPointsInRect(d,b.baseSelection,b.lastRect,b.this_.get("rowIndex"),b.this_.get("colIndex"))});b.lastRect=d},endMarquee:function(e,d){b.this_.set("tempDisallowDataTips",false);if(SC.none(b.marquee)){return}b.this_.getPath("layerManager").removeElement(b.marquee,true);b.marquee=null;b.baseSelection=[];var c=b.this_.getPath("graphModel.casesController.selection.length");if(c>0){DG.logUser("marqueeSelection: %@",c)}SC.run(function(){b.this_.get("parentView").completeSelection()})},doDraw:function a(){var f=this,h=this.get("frame"),j=this.get("xAxisView"),p=this.get("yAxisView"),i=j.getPath("model.drawZeroLine"),q=p.getPath("model.drawZeroLine"),g=this.getPath("layerManager."+DG.LayerNames.kBackground),l=this.getPath("layerManager."+DG.LayerNames.kGrid),c=(j.get("isNumeric")&&p.get("isNumeric")),o=this.getPath("graphModel.dataConfiguration.y2AttributeID"),k=o&&(o!==DG.Analysis.kNullAttribute);function e(){if(!f._paper){return}var u=f.getPath("graphModel.plotBackgroundImage"),y=f.getPath("graphModel.plotBackgroundImageLockInfo");if(u===null){u=""}if(f._backgroundImage.attr("src")!==u){f._backgroundImage.attr("src",u)}if(y&&y.locked){var s=f.get("xAxisView"),z=f.get("yAxisView"),x=s.dataToCoordinate(y.xAxisLowerBound),t=s.dataToCoordinate(y.xAxisUpperBound),w=z.dataToCoordinate(y.yAxisUpperBound),v=z.dataToCoordinate(y.yAxisLowerBound);f._backgroundImage.attr({x:x,y:w,width:t-x,height:v-w})}else{f._backgroundImage.attr({width:f._paper.width,height:f._paper.height})}}function n(){function t(x,y,z){l.push(f._paper.line(x,h.height,x,0).attr({stroke:y,"stroke-width":z}))}function u(z,x,y){l.push(f._paper.line(0,z,h.width,z).attr({stroke:x,"stroke-width":y}))}function v(y,x){t(x,DG.PlotUtilities.kRuleColor,DG.PlotUtilities.kRuleWidth)}function s(x,y){u(y,DG.PlotUtilities.kRuleColor,DG.PlotUtilities.kRuleWidth)}function w(z,y,x){function A(B,E){var D=B.get("zeroPixel"),C=x||DG.PlotUtilities.kZeroLineColor;if((D!=null)&&!B.get("isDateTime")){E(D,C,DG.PlotUtilities.kZeroLineWidth)}}z&&A(j,t);y&&A(p,u)}if(c){j.forEachTickDo(v);if(!k){p.forEachTickDo(s)}w(true,true)}else{if(i||q){w(i,q,DG.PlotUtilities.kRuleColor)}}}function r(u){if(u.altKey){var s="../../../../static/dg/fr/cert/resources/cursors/MagnifyPlus.cur",v="../../../../static/dg/fr/cert/resources/cursors/MagnifyMinus.cur",t=u.shiftKey?v:s;this.attr({cursor:DG.Browser.customCursorStr(t,8,8)})}else{this.attr({cursor:"auto"})}}var d=function(){var z=this.get("paper"),I=this.get("xAxisView"),D=I.get("allowCellBoundaries"),H=this.get("yAxisView"),G=H.get("allowCellBoundaries"),s=I.getPath("model.numberOfCells"),v=H.getPath("model.numberOfCells"),t=I.get("fullCellWidth"),B=H.get("fullCellWidth"),E=true,F,u,A,y,x;if(SC.none(z)){return}var C=function(){var K=B*v;A=H.cellToCoordinate(v-1);x=A-B/2;for(F=1;F<s;F++){var J;u=I.cellToCoordinate(F,E);y=u-t/2;J=z.line(y,x,y,x+K);g.push(J.attr({stroke:DG.PlotUtilities.kRuleColor,"stroke-width":1}))}}.bind(this),w=function(){var K=t*s;u=I.cellToCoordinate(0);y=u-t/2;for(F=1;F<v;F++){var J;A=H.cellToCoordinate(F,E);x=A-B/2;J=z.line(y,x+B,y+K,x+B);g.push(J.attr({stroke:DG.PlotUtilities.kRuleColor,"stroke-width":1}))}}.bind(this);if(D){C()}if(G){w()}}.bind(this);function m(t,s,u){f.prepareMarquee();f.startMarquee(t,s,u)}l.clear();g.clear();e();n();d();this.displayMessages();if(SC.none(this._backgroundForClick)){this._backgroundForClick=this.getPath("layerManager."+DG.LayerNames.kClick).push(this._paper.rect(0,0,0,0).attr({fill:DG.RenderingUtilities.kSeeThrough,stroke:DG.RenderingUtilities.kTransparent}).click(function(s){f.get("parentView").handleBackgroundClick(s)}).dblclick(function(s){f.get("parentView").handleBackgroundDblClick(s)}).drag(f.continueMarquee,m,f.endMarquee).mousemove(r))}this._backgroundForClick.attr({width:this.get("drawWidth"),height:this.get("drawHeight")})},dragStarted:function(f){DG.GraphDropTarget.dragStarted.call(this,f);var e=this.getPath("graphModel.dataConfiguration"),d=e&&(e.get("xAttributeID")||e.get("yAttributeID")||e.get("legendAttributeID")),c=(d?"DG.GraphView.dropInPlot":"DG.GraphView.addToEmptyX").loc(f.data.attribute.get("name"));this.set("dropHintString",c)},displayMessages:function(){var f=this.get("messages"),c=f.length,h=this.get("paper"),g=this._messageElements;function e(){g.forEach(function(l){j.prepareToMoveOrRemove(l);l.remove()})}if(!h){return}var j=this.getPath("layerManager."+DG.LayerNames.kDataTip);e();if(c>0){var k=h.text(0,0,f[0]);k.attr("font-size",12);var d=DG.RenderingUtilities.getExtentForTextElement(k).height,i=(h.height-c*d)/2;k.remove();f.forEach(function(n,l){var m=h.text(h.width/2,i+l*d,n);m.attr("font-size",12);j.push(m);g.push(m)})}}}}()));sc_require("components/graph/plots/plot_model");sc_require("components/graph/plots/numeric_plot_model_mixin");DG.ScatterPlotModel=DG.PlotModel.extend(DG.NumericPlotModelMixin,{getDesiredAxisClassFor:function(a){if(a===DG.GraphTypes.EPlace.eX||a===DG.GraphTypes.EPlace.eY){return DG.CellLinearAxisModel}else{if(a===DG.GraphTypes.EPlace.eY2){return(this.getPath("dataConfiguration.y2AttributeID")===DG.Analysis.kNullAttribute)?DG.AxisModel:DG.CellLinearAxisModel}}},movablePoint:null,isMovablePointVisible:function(){return !SC.none(this.movablePoint)&&this.movablePoint.get("isVisible")}.property(),isMovablePointVisibleDidChange:function(){this.notifyPropertyChange("isMovablePointVisible")}.observes("*movablePoint.isVisible"),movableLine:null,isMovableLineVisible:function(){return !SC.none(this.movableLine)&&this.movableLine.get("isVisible")}.property(),isMovableLineVisibleDidChange:function(){this.notifyPropertyChange("isMovableLineVisible")}.observes("*movableLine.isVisible"),multipleLSRLs:null,isLSRLVisible:function(){return !SC.none(this.multipleLSRLs)&&this.multipleLSRLs.get("isVisible")}.property(),isLSRLVisibleDidChange:function(){this.notifyPropertyChange("isLSRLVisible")}.observes("*multipleLSRLs.isVisible"),isInterceptLocked:function(a,b){if(!SC.none(b)){this.setPath("movableLine.isInterceptLocked",b);this.setPath("multipleLSRLs.isInterceptLocked",b)}return !SC.none(this.movableLine)&&this.movableLine.get("isInterceptLocked")||!SC.none(this.multipleLSRLs)&&this.multipleLSRLs.get("isInterceptLocked")}.property(),isInterceptLockedDidChange:function(){this.notifyPropertyChange("isInterceptLocked")}.observes("*movableLine.isInterceptLocked","*multipleLSRLs.isInterceptLocked"),areSquaresVisible:false,squares:null,init:function(){arguments.callee.base.apply(this,arguments);this.addObserver("movableLine.slope",this.lineDidChange);this.addObserver("movableLine.intercept",this.lineDidChange)},destroy:function(){this.removeObserver("movableLine.slope",this.lineDidChange);this.removeObserver("movableLine.intercept",this.lineDidChange);arguments.callee.base.apply(this,arguments)},dataConfigurationDidChange:function(){arguments.callee.base.apply(this,arguments);var a=this.get("dataConfiguration");if(a){a.set("sortCasesByLegendCategories",false);a.invalidateCaches()}}.observes("dataConfiguration"),isAffectedByChange:function(a){if(!a||!a.operation){return false}return arguments.callee.base.apply(this,arguments)||(this.isAdornmentVisible("connectingLine")&&(a.operation==="moveAttribute"||a.operation==="moveCases"))},lineDidChange:function(){SC.run(function(){this.notifyPropertyChange("squares")}.bind(this))},createMovablePoint:function(){if(SC.none(this.movablePoint)){this.beginPropertyChanges();this.set("movablePoint",DG.MovablePointModel.create({plotModel:this}));this.movablePoint.recomputeCoordinates(this.get("xAxis"),this.get("yAxis"));this.endPropertyChanges()}},createMovableLine:function(){if(SC.none(this.movableLine)){this.beginPropertyChanges();this.set("movableLine",DG.MovableLineModel.create({plotModel:this,showSumSquares:this.get("areSquaresVisible")}));this.movableLine.recomputeSlopeAndIntercept(this.get("xAxis"),this.get("yAxis"));this.endPropertyChanges()}},squaresVisibilityChanged:function(){var b=this.get("movableLine"),c=this.get("multipleLSRLs"),a=this.get("areSquaresVisible");if(b){b.set("showSumSquares",a)}if(c){c.set("showSumSquares",a)}}.observes("areSquaresVisible"),enableMeasuresForSelectionDidChange:function(){arguments.callee.base.apply(this,arguments);this.setPath("multipleLSRLs.enableMeasuresForSelection",this.get("enableMeasuresForSelection"))}.observes("enableMeasuresForSelection"),toggleMovablePoint:function(){var c=this;function b(){function d(e){if(SC.none(e.movablePoint)){e.createMovablePoint()}else{e.movablePoint.recomputePositionIfNeeded(e.get("xAxis"),e.get("yAxis"));e.movablePoint.set("isVisible",!e.movablePoint.get("isVisible"))}}d(c);c.get("siblingPlots").forEach(d)}var a=!this.movablePoint||!this.movablePoint.get("isVisible");DG.UndoHistory.execute(DG.Command.create({name:"graph.toggleMovablePoint",undoString:(a?"DG.Undo.graph.showMovablePoint":"DG.Undo.graph.hideMovablePoint"),redoString:(a?"DG.Redo.graph.showMovablePoint":"DG.Redo.graph.hideMovablePoint"),log:"toggleMovablePoint: %@".fmt(a?"show":"hide"),executeNotification:{action:"notify",resource:"component",values:{operation:"toggle movable point",type:"DG.GraphView"}},execute:function(){b()},undo:function(){b()}}))},toggleMovableLine:function(){var c=this;function b(){function d(e){if(SC.none(e.movableLine)){e.createMovableLine()}else{e.movableLine.recomputeSlopeAndInterceptIfNeeded(e.get("xAxis"),e.get("yAxis"));e.movableLine.set("isVisible",!e.movableLine.get("isVisible"))}}d(c);c.get("siblingPlots").forEach(d)}var a=!this.movableLine||!this.movableLine.get("isVisible");DG.UndoHistory.execute(DG.Command.create({name:"graph.toggleMovableLine",undoString:(a?"DG.Undo.graph.showMovableLine":"DG.Undo.graph.hideMovableLine"),redoString:(a?"DG.Redo.graph.showMovableLine":"DG.Redo.graph.hideMovableLine"),log:"toggleMovableLine: %@".fmt(a?"show":"hide"),executeNotification:{action:"notify",resource:"component",values:{operation:"toggle movable line",type:"DG.GraphView"}},execute:function(){b()},undo:function(){b()}}))},createLSRLLines:function(){if(SC.none(this.multipleLSRLs)){this.set("multipleLSRLs",DG.MultipleLSRLsModel.create({plotModel:this,showSumSquares:this.get("areSquaresVisible"),isInterceptLocked:this.get("isInterceptLocked"),enableMeasuresForSelection:this.get("enableMeasuresForSelection")}));this.setPath("multipleLSRLs.isVisible",true)}},toggleLSRLLine:function(){var c=this;function b(){function d(e){if(SC.none(e.get("multipleLSRLs"))){e.createLSRLLines()}else{e.setPath("multipleLSRLs.isVisible",!e.getPath("multipleLSRLs.isVisible"))}}d(c);c.get("siblingPlots").forEach(d)}var a=!this.multipleLSRLs||!this.multipleLSRLs.get("isVisible");DG.UndoHistory.execute(DG.Command.create({name:"graph.toggleLSRLLine",undoString:(a?"DG.Undo.graph.showLSRL":"DG.Undo.graph.hideLSRL"),redoString:(a?"DG.Redo.graph.showLSRL":"DG.Redo.graph.hideLSRL"),log:"toggleLSRL: %@".fmt(a?"show":"hide"),executeNotification:{action:"notify",resource:"component",values:{operation:"toggle LSRL",type:"DG.GraphView"}},execute:function(){b()},undo:function(){b()}}))},toggleInterceptLocked:function(){var e=this;function a(){function f(g){if(!SC.none(g.movableLine)){g.movableLine.toggleInterceptLocked();g.movableLine.recomputeSlopeAndInterceptIfNeeded(g.get("xAxis"),g.get("yAxis"))}if(!SC.none(g.multipleLSRLs)){g.multipleLSRLs.toggleInterceptLocked()}}f(e);e.get("siblingPlots").forEach(f)}function d(){function f(h){g.push({movableLine:h.movableLine?h.movableLine.createStorage():null,lsrlStorage:h.multipleLSRLs?h.multipleLSRLs.createStorage():null})}var g=[];f(e);e.get("siblingPlots").forEach(f);return g}function c(g){function f(j,i){var h=g[i+1];if(j.movableLine){j.movableLine.restoreStorage(h.movableLine)}if(j.multipleLSRLs){j.multipleLSRLs.restoreStorage(h.lsrlStorage)}}f(e,-1);e.get("siblingPlots").forEach(f)}var b=(this.movableLine&&!this.movableLine.get("isInterceptLocked"))||(this.multipleLSRLs&&!this.multipleLSRLs.get("isInterceptLocked"));DG.UndoHistory.execute(DG.Command.create({name:"graph.toggleLockIntercept",undoString:(b?"DG.Undo.graph.lockIntercept":"DG.Undo.graph.unlockIntercept"),redoString:(b?"DG.Redo.graph.lockIntercept":"DG.Redo.graph.unlockIntercept"),log:"lockIntercept: %@".fmt(b),executeNotification:{action:"notify",resource:"component",values:{operation:"toggle lock intercept",type:"DG.GraphView"}},execute:function(){this._undoData=d();a()},undo:function(){c(this._undoData);this._undoData=null}}))},togglePlotFunction:function(){var d=this;function b(){function e(f){f.toggleAdornmentVisibility("plottedFunction","togglePlotFunction")}d.get("siblingPlots").forEach(e);e(d)}function c(){var e=d.get("siblingPlots"),f=d.getAdornmentModel("plottedFunction");f.set("siblingPlottedFunctions",e.map(function(g){return g.getAdornmentModel("plottedFunction")}))}var a=!this.isAdornmentVisible("plottedFunction");DG.UndoHistory.execute(DG.Command.create({name:"graph.togglePlotFunction",undoString:(a?"DG.Undo.graph.showPlotFunction":"DG.Undo.graph.hidePlotFunction"),redoString:(a?"DG.Redo.graph.showPlotFunction":"DG.Redo.graph.hidePlotFunction"),log:"togglePlotFunction: %@".fmt(a?"show":"hide"),executeNotification:{action:"notify",resource:"component",values:{operation:"toggle plot function",type:"DG.GraphView"}},execute:function(){b();c()},undo:function(){b();d.getAdornmentModel("plottedFunction").set("siblingPlottedFunctions",null)}}))},toggleConnectingLine:function(){var c=this;function b(){function d(f){var e=f.toggleAdornmentVisibility("connectingLine","toggleConnectingLine");if(e&&e.get("isVisible")){e.recomputeValue()}}d(c);c.get("siblingPlots").forEach(d)}var a=!this.isAdornmentVisible("connectingLine");DG.UndoHistory.execute(DG.Command.create({name:"graph.toggleConnectingLine",undoString:(a?"DG.Undo.graph.showConnectingLine":"DG.Undo.graph.hideConnectingLine"),redoString:(a?"DG.Redo.graph.showConnectingLine":"DG.Redo.graph.hideConnectingLine"),log:"toggleConnectingLine: %@".fmt(a?"show":"hide"),executeNotification:{action:"notify",resource:"component",values:{operation:"toggle connecting line",type:"DG.GraphView"}},execute:function(){b()},undo:function(){b()}}))},toggleShowSquares:function(){var c=this;function b(){function d(e){e.set("areSquaresVisible",!e.get("areSquaresVisible"))}d(c);c.get("siblingPlots").forEach(d)}var a=!this.get("areSquaresVisible");DG.UndoHistory.execute(DG.Command.create({name:"graph.toggleShowSquares",undoString:(a?"DG.Undo.graph.showSquares":"DG.Undo.graph.hideSquares"),redoString:(a?"DG.Redo.graph.showSquares":"DG.Redo.graph.hideSquares"),log:"toggleShowSquares: %@".fmt(a?"show":"hide"),executeNotification:{action:"notify",resource:"component",values:{operation:"toggle show squares",type:"DG.GraphView"}},execute:function(){b()},undo:function(){b()}}))},handleDataConfigurationChange:function(a){arguments.callee.base.apply(this,arguments);this.rescaleAxesFromData(a!=="hiddenCases",true);var b=this.getAdornmentModel("connectingLine");if(b){b.setComputingNeeded()}},rescaleAxesFromData:function(d,c,a,b){if(c===undefined){c=true}this.doRescaleAxesFromData([DG.GraphTypes.EPlace.eX,DG.GraphTypes.EPlace.eY,DG.GraphTypes.EPlace.eY2],d,c,b);if(a&&!b){DG.logUser("rescaleScatterplot")}},dilate:function(b,a){this.doDilation([DG.GraphTypes.EPlace.eX,DG.GraphTypes.EPlace.eY],b,a)},getAdornmentSpecs:function(){var a=arguments.callee.base.apply(this,arguments),b=this;["movablePoint","movableLine","multipleLSRLs"].forEach(function(d){var c=b.get(d);if(c){a.push({key:d,"class":c.constructor,useAdornmentModelsArray:false,storage:c.createStorage()})}});DG.ObjectMap.forEach(this._adornmentModels,function(d,c){a.push({key:d,"class":c.constructor,useAdornmentModelsArray:true,storage:c.createStorage()})});return a},installAdornmentModelsFrom:function(a){arguments.callee.base.apply(this,arguments);var b=this.get("movablePoint");if(b){b.set("xAxis",this.get("xAxis"));b.set("yAxis",this.get("yAxis"));b.recomputeCoordinates(this.get("xAxis"),this.get("yAxis"))}var c=this.get("multipleLSRLs");if(c){c.recomputeSlopeAndInterceptIfNeeded(this.get("xAxis"),this.get("yAxis"))}},checkboxDescriptions:function(){function b(){return d.get("isLSRLVisible")}function a(){return b()&&!d.getPath("multipleLSRLs.isInterceptLocked")}function c(){var e=20,j=5,h=20,f=SC.CheckboxView.create({layout:{height:h},localize:true,flowSpacing:{left:e},title:"DG.Inspector.graphLSRLSlopeCI",value:d.getPath("multipleLSRLs.showConfidenceBands")&&!d.getPath("multipleLSRLs.isInterceptLocked"),classNames:"dg-graph-LSRLSlopeCI-check".w(),valueDidChange:function(){d.get("multipleLSRLs").toggleProperty("showConfidenceBands");d.get("multipleLSRLs").setComputingNeeded()}.observes("value")}),i=SC.CheckboxView.create({layout:{height:h},localize:true,title:"DG.Inspector.graphLSRL",value:b(),classNames:"dg-graph-lsrl-check".w(),valueDidChange:function(){d.toggleLSRLLine();f.set("isEnabled",a())}.observes("value")});var g=SC.View.create(SC.FlowedLayout,{layoutDirection:SC.LAYOUT_VERTICAL,isResizable:false,isClosable:false,layout:{height:2*(h+j)},defaultFlowSpacing:{bottom:j},canWrap:false,align:SC.ALIGN_TOP,init:function(){arguments.callee.base.apply(this,arguments);f.set("isEnabled",a());this.appendChild(i);this.appendChild(f)}});return g}var d=this;return arguments.callee.base.apply(this,arguments).concat([{title:"DG.Inspector.graphConnectingLine",value:d.isAdornmentVisible("connectingLine"),classNames:"dg-graph-connectingLine-check".w(),valueDidChange:function(){d.toggleConnectingLine()}.observes("value")},{title:"DG.Inspector.graphMovablePoint",value:d.get("isMovablePointVisible"),classNames:"dg-graph-movablePoint-check".w(),valueDidChange:function(){d.toggleMovablePoint()}.observes("value")},{title:"DG.Inspector.graphMovableLine",value:d.get("isMovableLineVisible"),classNames:"dg-graph-movableLine-check".w(),valueDidChange:function(){d.toggleMovableLine()}.observes("value")},{control:c()},{title:"DG.Inspector.graphInterceptLocked",classNames:"dg-graph-interceptLocked-check".w(),_changeInProgress:true,valueDidChange:function(){if(!this._changeInProgress){d.toggleInterceptLocked()}}.observes("value"),lineVisibilityChanged:function(){this._changeInProgress=true;var e=d.get("isMovableLineVisible")||d.get("isLSRLVisible");if(!e){d.set("isInterceptLocked",false)}this.set("value",d.get("isInterceptLocked"));this.set("isEnabled",e);this._changeInProgress=false},init:function(){arguments.callee.base.apply(this,arguments);this.lineVisibilityChanged();d.addObserver("isMovableLineVisible",this,"lineVisibilityChanged");d.addObserver("isLSRLVisible",this,"lineVisibilityChanged");this._changeInProgress=false},destroy:function(){d.removeObserver("isMovableLineVisible",this,"lineVisibilityChanged");d.removeObserver("isLSRLVisible",this,"lineVisibilityChanged");arguments.callee.base.apply(this,arguments)}},{title:"DG.Inspector.graphPlottedFunction",value:d.isAdornmentVisible("plottedFunction"),classNames:"dg-graph-plottedFunction-check".w(),valueDidChange:function(){d.togglePlotFunction()}.observes("value")},{title:"DG.Inspector.graphPlottedValue",value:d.isAdornmentVisible("plottedValue"),classNames:"dg-graph-plottedValue-check".w(),valueDidChange:function(){d.togglePlotValue()}.observes("value")},{title:"DG.Inspector.graphSquares",value:d.get("areSquaresVisible"),classNames:"dg-graph-squares-check".w(),lineVisibilityChanged:function(){var e=d.get("isMovableLineVisible")||d.get("isLSRLVisible");this.set("isEnabled",e);if(d.get("areSquaresVisible")&&!e){this.set("value",false)}},init:function(){arguments.callee.base.apply(this,arguments);this.lineVisibilityChanged();d.addObserver("isMovableLineVisible",this,"lineVisibilityChanged");d.addObserver("isLSRLVisible",this,"lineVisibilityChanged")},destroy:function(){d.removeObserver("isMovableLineVisible",this,"lineVisibilityChanged");d.removeObserver("isLSRLVisible",this,"lineVisibilityChanged")},valueDidChange:function(){d.toggleShowSquares()}.observes("value")}])}.property(),getPropsForCopy:function(){var a=arguments.callee.base.apply(this,arguments);return $.extend(a,{areSquaresVisible:this.get("areSquaresVisible")})},createStorage:function(){var d=arguments.callee.base.apply(this,arguments),a=this.get("movablePoint"),c=this.get("movableLine"),b=this.get("multipleLSRLs");if(!SC.none(a)){d.movablePointStorage=a.createStorage()}if(!SC.none(c)){d.movableLineStorage=c.createStorage()}if(!SC.none(b)&&b.get("isVisible")){d.multipleLSRLsStorage=b.createStorage()}if(this.get("areSquaresVisible")){d.areSquaresVisible=true}if(this.get("isLSRLVisible")){d.isLSRLVisible=true}return d},restoreStorage:function(a){this.moveAdornmentStorage(a,"movableLine",a.movableLineStorage);this.moveAdornmentStorage(a,"multipleLSRLs",a.multipleLSRLsStorage);this.moveAdornmentStorage(a,"plottedFunction",a.plottedFunctionStorage);arguments.callee.base.apply(this,arguments);if(a.movablePointStorage){if(SC.none(this.movablePoint)){this.createMovablePoint()}this.get("movablePoint").restoreStorage(a.movablePointStorage)}if(a.movableLineStorage){if(SC.none(this.movableLine)){this.createMovableLine()}this.get("movableLine").restoreStorage(a.movableLineStorage)}this.areSquaresVisible=a.areSquaresVisible;if(a.multipleLSRLsStorage){if(SC.none(this.multipleLSRLs)){this.createLSRLLines()}this.get("multipleLSRLs").restoreStorage(a.multipleLSRLsStorage)}if(a.plottedFunctionStorage){if(SC.none(this.plottedFunction)){this.set("plottedFunction",DG.PlottedFunctionModel.create())}this.get("plottedFunction").restoreStorage(a.plottedFunctionStorage)}},onRescaleIsComplete:function(){if(!SC.none(this.movableLine)){this.movableLine.recomputeSlopeAndInterceptIfNeeded(this.get("xAxis"),this.get("yAxis"))}if(!SC.none(this.movablePoint)){this.movablePoint.recomputePositionIfNeeded(this.get("xAxis"),this.get("yAxis"))}},getCellCaseCounts:function(d){var f=d?this.get("selection"):this.get("cases"),b=this.get("xVarID"),g=this.get("yVarID"),e=0,c=[];if(!(b&&g)){return c}f.forEach(function(h,j){var k=h.getForcedNumericValue(b),i=h.getForcedNumericValue(g);if(isFinite(k)&&isFinite(i)){++e}});var a={primaryCell:0,secondaryCell:0};if(d){a.selectedCount=e}else{a.count=e}c.push(a);return c}});sc_require("components/graph/plots/plot_view");DG.ScatterPlotView=DG.PlotView.extend({displayProperties:["xAxisView.model.lowerBound","xAxisView.model.upperBound","yAxisView.model.lowerBound","yAxisView.model.upperBound","xAxisView.pixelMin","xAxisView.pixelMax","yAxisView.pixelMin","yAxisView.pixelMax","model.areSquaresVisible","model.squares"],autoDestroyProperties:["movablePointAdorn","movableLineAdorn","functionAdorn","connectingLineAdorn","multipleLSRLsAdorn"],connectingLineAdorn:null,numPlotsOrIndexChanged:function(){if(this.connectingLineAdorn){this.connectingLineChanged()}}.observes("numPlots","plotIndex"),primaryAxisView:function(){return this.get("xAxisView")}.property("xAxisView"),secondaryAxisView:function(){return this.get("yAxisView")}.property("yAxisView"),movablePointAdorn:null,movableLineAdorn:null,multipleLSRLsAdorn:null,functionAdorn:null,isFirstPlot:true,isFirstPlotChanged:function(){if(this.isFirstPlot){if(SC.isArray(this._myPlottedElements)){var a=this.get("layerManager");this._myPlottedElements.forEach(function(b){a.removeElement(b);b.remove()});this._myPlottedElements=[]}}this.get("plottedElements").forEach(function(c,b){this.assignElementAttributes(c,b)}.bind(this))}.observes("isFirstPlot"),_squares:null,cleanupFunc:function(){var a=this.get("connectingLineAdorn");if(a){a.updateToModel()}},init:function(){arguments.callee.base.apply(this,arguments);var a=this.get("model");if(a&&a.getAdornmentModel("connectingLine")){this.connectingLineChanged()}},destroy:function(){var a=this.get("model");if(a){a.removeObserver("squares",this,"squaresDidChange")}if(a){a.removeObserver("areSquaresVisible",this,"squaresDidChange")}var c=this.get("layerManager");if(this._squares){this._squares.forEach(function(d){c.removeElement(d,true)})}var b=this.get("functionEditView");if(b){this.get("parentView").removeChild(b)}if(SC.isArray(this._myPlottedElements)){this._myPlottedElements.forEach(function(d){c.removeElement(d);d.remove()});this._myPlottedElements=[]}arguments.callee.base.apply(this,arguments)},modelDidChange:function(){arguments.callee.base.apply(this,arguments);var a=this.get("model");if(a){a.addObserver("squares",this,"squaresDidChange");a.addObserver("areSquaresVisible",this,"squaresDidChange");this.connectingLineChanged()}},dataDidChange:function(){if(!this.getPath("model.dataConfiguration")){return}arguments.callee.base.apply(this,arguments);if(this.connectingLineAdorn){this.connectingLineAdorn.invalidateModel();this.connectingLineAdorn.updateToModel()}this.updateAdornments()},dataRangeDidChange:function(b,e,a,c){var d=this.getPath("model.cases");this.notifyPropertyChange("plotDisplayDidChange");if(this.getPath("model.areSquaresVisible")){this.squaresDidChange()}if(this.connectingLineAdorn){this.connectingLineAdorn.invalidateModel();this.connectingLineAdorn.updateToModel()}this.updateAdornments();this.rescaleOnParentCaseCompletion(d);arguments.callee.base.apply(this,arguments)},handleUpdateConnectingLine:function(){if(this.connectingLineAdorn&&this.connectingLineAdorn.wantVisible()){this.connectingLineAdorn.invalidateModel();this.connectingLineAdorn.updateToModel(true)}},handleMoveAttribute:function(){this.handleUpdateConnectingLine()},handleMoveCases:function(){arguments.callee.base.apply(this,arguments);this.handleUpdateConnectingLine()},updateAdornments:function(){arguments.callee.base.apply(this,arguments);var a=this.get("multipleLSRLsAdorn"),c=this.get("movableLineAdorn"),b=this.getPath("model.areSquaresVisible");if(a){a.get("model").setComputingNeeded();a.updateToModel()}if(c&&b){c.get("model").slopeOrInterceptChanged()}if(this.functionAdorn){this.functionAdorn.updateToModel()}},calcPointRadius:function(){var a=arguments.callee.base.apply(this,arguments);if(this.connectingLineAdorn&&this.connectingLineAdorn.wantVisible()){a=a/2}return a},setCircleCoordinate:function(e,b,f,i,c){DG.assert(e&&e.xAxisView);DG.assert(b);DG.assert(DG.MathUtilities.isInIntegerRange(f,0,this.get("plottedElements").length));var a=this.get("plottedElements")[f],h=e.xAxisView.dataToCoordinate(b.getForcedNumericValue(e.xVarID)),g=e.yAxisView.dataToCoordinate(b.getForcedNumericValue(e.yVarID)),j=!DG.isFinite(h)||!DG.isFinite(g);if(this.showHidePlottedElement(a,j,f)){var d={cx:h,cy:g,r:this.radiusForCircleElement(a),fill:e.calcCaseColorString(b),stroke:e.calcStrokeColorString(b),"fill-opacity":e.transparency,"stroke-opacity":e.strokeTransparency};this.updatePlottedElement(a,d,i,c);return{cx:h,cy:g,r:this._pointRadius}}return null},assignElementAttributes:function(c,e,k){arguments.callee.base.apply(this,arguments);var d=this;function i(){var l=d.getPath("model.xVarID"),m="model."+(d.getPath("model.verticalAxisIsY2")?"y2VarID":"yVarID"),n=d.getPath(m);return{x:l,y:n}}function j(n){function o(s,q,r){var t=s.getForcedNumericValue(d.getPath("model."+r+"VarID"))+q;if(d.getPath(r+"AxisView.isDateTime")){t=DG.createDate(t)}return t}var l=i(),m={operation:"updateCases",cases:[],attributeIDs:[l.x,l.y],values:[[],[]],dirtyDocument:false},p=d.get("dataContext");if(!p){return}d.getPath("model.casesController.selection").forEach(function(q){m.cases.push(q);m.values[0].push(o(q,n.x,"x"));m.values[1].push(o(q,n.y,"y"))});p.applyChange(m)}function a(q,m){if(!SC.none(m.x)&&!SC.none(m.y)){var n=d.getPath("model.cases").unorderedAt(q),l=i(),p=n.getForcedNumericValue(l.x)-m.x,o=n.getForcedNumericValue(l.y)-m.y;if((p!==0)||(o!==0)){d.get("model").animateSelectionBackToStart([l.x,l.y],[p,o])}}}function f(){this.hoverAnimation=null}var b=false,g=1,h=null;c.hover(function(l){if(!b&&SC.none(h)){h="";if(this.hoverAnimation){this.stop(this.hoverAnimation)}this.hoverAnimation=Raphael.animation({opacity:g,transform:DG.PlotUtilities.kDataHoverTransform},DG.PlotUtilities.kDataTipShowTime,"<>",f);this.animate(this.hoverAnimation);d.showDataTip(this,e)}},function(l){if(!b){if(this.hoverAnimation){this.stop(this.hoverAnimation)}this.hoverAnimation=Raphael.animation({transform:h},DG.PlotUtilities.kHighlightHideTime,"<>",f);this.animate(this.hoverAnimation);h=null;d.hideDataTip()}}).drag(function(m,l){SC.run(function(){var t=d.get("xAxisView").coordinateToData(this.ox+m),s=d.get("yAxisView").coordinateToData(this.oy+l),o=i(),p=d.getPath("model.cases").unorderedAt(this.index),r=p.getForcedNumericValue(o.x),q=p.getForcedNumericValue(o.y),n=this.transform();if(isFinite(t)&&isFinite(s)){this.transform(h);j({x:t-r,y:s-q});this.transform(n)}},this)},function(l,o){if(b){return}var n=d.getPath("model.cases").unorderedAt(this.index),m=i();b=true;this.ox=this.attr("cx");this.oy=this.attr("cy");this.wx=n.getForcedNumericValue(m.x);this.wy=n.getForcedNumericValue(m.y);this.attr({opacity:g})},function(){this.animate({transform:h},DG.PlotUtilities.kHighlightHideTime);h=null;a(this.index,{x:this.wx,y:this.wy});b=false;delete this.ox;delete this.oy;delete this.wx;delete this.wy;d.hideDataTip()});return c},createElement:function(c,d,b){var a=this.get("paper").circle(-100,-100,this._pointRadius);a.node.setAttribute("shape-rendering","geometricPrecision");return a},drawData:function drawData(){if(this.getPath("model.isAnimating")&&this.get("isFirstPlot")){return}if(!SC.none(this.get("transferredElementCoordinates"))){this.animateFromTransferredElements();return}arguments.callee.base.apply(this,arguments)},doDraw:function doDraw(c,b,a){var e=this;function d(){function h(s,w){var t=s.get("slope"),u=s.get("intercept"),z=j,v=s.get("categoryName"),y=e.getPath("model.dataConfiguration.legendAttributeDescription"),x=y.getPath("attribute.id");if(!SC.none(x)&&!SC.none(v)){z=j.filter(function(A){return v===A.getValue(x)})}z.forEach(function(A){if(A.hasValue(o)&&A.hasValue(r)){var C=A.getForcedNumericValue(o),B=A.getForcedNumericValue(r),K=n.dataToCoordinate(C),J=q.dataToCoordinate(B),D=q.dataToCoordinate(t*C+u),E=K+J-D,H=Math.min(K,E),G=Math.min(J,D),I=Math.abs(D-J),F=DG.RenderingUtilities.pathForFrame({x:H,y:G,width:I,height:I}),M=m.path(F).attr({stroke:w});if(k){M.attr({"stroke-opacity":0}).animate({"stroke-opacity":1},DG.PlotUtilities.kDefaultAnimationTime,"<>")}e._squares.push(M);p.push(M)}})}var g=true,f=e.getPath("model.areSquaresVisible"),l=!f&&e._squares&&(e._squares.length>0),k=f&&(!e._squares||(e._squares.length===0)),i=e.get("layerManager"),p=i[DG.LayerNames.kAdornments];if(!e._squares){e._squares=[]}e._squares.forEach(function(s){if(l){s.animate({"stroke-opacity":0},DG.PlotUtilities.kDefaultAnimationTime,"<>",function(){i.removeElement(s,g)})}else{i.removeElement(s,g)}});e._squares=[];if(!f){return}var j=e.getPath("model.cases"),o=e.getPath("model.xVarID"),r=e.getPath("model.yVarID"),n=e.get("xAxisView"),q=e.get("yAxisView"),m=e.get("paper");if(e.getPath("model.isMovableLineVisible")){h(e.getPath("model.movableLine"),DG.PlotUtilities.kDefaultMovableLineColor)}if(e.getPath("model.isLSRLVisible")){e.getPath("multipleLSRLsAdorn.lsrlAdornments").forEach(function(s){h(s.get("model"),s.get("lineColor"))})}}arguments.callee.base.apply(this,arguments);this.drawData();this.updateSelection();if(!SC.none(this.connectingLineAdorn)&&this.connectingLineAdorn.wantVisible()){if(a==="pointColor"){this.connectingLineAdorn.invalidateModel()}this.connectingLineAdorn.updateToModel()}if(!SC.none(this.movablePointAdorn)){this.movablePointAdorn.updateToModel()}if(!SC.none(this.movableLineAdorn)){this.movableLineAdorn.updateToModel()}if(!SC.none(this.multipleLSRLsAdorn)){this.multipleLSRLsAdorn.updateToModel()}if(!SC.none(this.functionAdorn)){this.functionAdorn.updateToModel()}d()},updateSelection:function(){arguments.callee.base.apply(this,arguments);var a=this.get("connectingLineAdorn");if(a&&a.wantVisible()){if(this.getPath("model.dataConfiguration.displayOnlySelected")){a.get("model").setComputingNeeded()}this.connectingLineAdorn.updateSelection()}},movablePointChanged:function(){if(!this.readyToDraw()){return}var a=this.getPath("model.movablePoint"),b=this.get("movablePointAdorn");if(a){if(b){b.set("parentView",this);b.set("model",a);b.set("paperSource",this.get("paperSource"))}else{b=DG.MovablePointAdornment.create({parentView:this,model:a,paperSource:this.get("paperSource")});b.createElements();this.set("movablePointAdorn",b)}this.movablePointAdorn.updateVisibility()}else{if(b){b.destroy();this.set("movablePointAdorn",null)}}}.observes("*model.movablePoint.isVisible"),movableLineChanged:function(){if(!this.readyToDraw()){return}var b=this.getPath("model.movableLine"),a=this.get("movableLineAdorn");if(b){if(a){a.set("parentView",this);a.set("model",b);a.set("paperSource",this.get("paperSource"))}else{a=DG.MovableLineAdornment.create({parentView:this,model:b,paperSource:this.get("paperSource"),layerName:DG.LayerNames.kAdornments});a.createElements();this.set("movableLineAdorn",a)}a.updateVisibility()}else{if(a){a.destroy();this.set("movableLineAdorn",null)}}this.updateSquaresVisibility();this.displayDidChange()}.observes("*model.movableLine.isVisible"),lsrlChanged:function(){if(!this.readyToDraw()){return}var b=this.getPath("model.multipleLSRLs"),a=this.get("multipleLSRLsAdorn");if(b){if(a){a.set("parentView",this);a.set("model",b);a.set("paperSource",this.get("paperSource"))}else{a=DG.MultipleLSRLsAdornment.create({parentView:this,model:b,paperSource:this.get("paperSource"),layerName:DG.LayerNames.kAdornments});this.set("multipleLSRLsAdorn",a)}a.updateVisibility()}else{if(a){a.destroy();this.set("multipleLSRLsAdorn",null)}}this.updateSquaresVisibility();this.displayDidChange()}.observes("*model.multipleLSRLs.isVisible"),connectingLineChanged:function(){var f=function(){if(c){c.updateToModel(true);this.updatePointSize();this._elementOrderIsValid=false;this.updateSelection()}}.bind(this),d=function(){var i=this.getPath("model.dataConfiguration.legendAttributeDescription.attribute.collection"),h=this.getPath("model.dataConfiguration.xAttributeDescription.attribute.collection"),j=this.getPath("model.dataConfiguration.yAttributeDescription.attribute.collection");return !SC.none(i)&&i.get("id")!==h.get("id")&&i.get("id")!==j.get("id")}.bind(this),g=function(){return this.get("numPlots")>1}.bind(this);var b=this.get("model"),e=b&&b.getAdornmentModel("connectingLine"),c=this.get("connectingLineAdorn"),a=d()||!g()?this.getPointColor:this.getAttributeColor;if(e){if(c){c.set("parentView",this);c.set("model",e);c.set("paperSource",this.get("paperSource"))}else{c=DG.ConnectingLineAdornment.create({parentView:this,model:e,paperSource:this.get("paperSource"),layerName:DG.LayerNames.kConnectingLines});this.set("connectingLineAdorn",c)}e.set("getLineColorFunc",a.bind(this));e.setComputingNeeded()}else{if(c){c.destroy();this.set("connectingLineAdorn",null)}}this.invokeLast(f)}.observes("*model.connectingLine"),squaresDidChange:function(){this._isRenderingValid=false;this.displayDidChange()},updateSquaresVisibility:function(){if(this.getPath("model.areSquaresVisible")&&!this.getPath("model.multipleLSRLs.isVisible")&&!this.getPath("model.movableLine.isVisible")){this.setPath("model.areSquaresVisible",false)}},plottedFunctionChanged:function(){var a=this.get("model"),d=a&&a.getAdornmentModel("plottedFunction"),b=this.get("functionAdorn"),c=this.get("functionEditView");if(d){if(!c){c=DG.PlottedFunctionAdornment.createFormulaEditView(d);this.set("functionEditView",c);this.get("parentView").set("functionEditorView",c)}c.set("isVisible",d.get("isVisible"));c.set("formulaExpression",d.get("expression"));if(b){b.set("parentView",this);b.set("model",d);b.set("parentView",this.get("paperSource"))}else{b=DG.PlottedFunctionAdornment.create({parentView:this,model:d,paperSource:this.get("paperSource"),layerName:DG.LayerNames.kAdornments});this.set("functionAdorn",b)}b.updateVisibility()}else{if(b){b.destroy();this.set("functionAdorn",null);if(c){c.set("isVisible",false)}}}}.observes("*model.plottedFunction"),didCreateLayer:function(){arguments.callee.base.apply(this,arguments);this.movablePointChanged();this.movableLineChanged();this.lsrlChanged();this.plottedFunctionChanged()},zoom:function(c){var d=c.shiftKey?2:0.5,b=DG.ViewUtilities.windowToViewCoordinates({x:c.clientX,y:c.clientY},this),a={x:this.get("xAxisView").coordinateToData(b.x),y:this.get("yAxisView").coordinateToData(b.y)};this.get("model").dilate(a,d)},handleBackgroundClick:function(a){if(a.altKey){this.zoom(a)}},handleBackgroundDblClick:function(a){this.zoom(a)}});DG.SelectedInfoView=SC.LabelView.extend((function(){return{classNames:"dg-selected-info-view".w(),graphModel:null,desiredExtent:function(){return this.get("isVisible")?DG.RenderingUtilities.kCaptionFontHeight:0}.property("isVisible"),init:function(){arguments.callee.base.apply(this,arguments);this.enableMeasuresForSelectionDidChange()},enableMeasuresForSelectionDidChange:function(){if(this.getPath("graphModel.enableMeasuresForSelection")){this.set("isVisible",true);this.selectionDidChange()}else{this.set("isVisible",false)}}.observes("graphModel.enableMeasuresForSelection"),selectionDidChange:function(){if(this.get("isVisible")){var b=this.getPath("graphModel.selection").length,a=b===1?"DG.SelectedInfoView.infoSing":"DG.SelectedInfoView.infoPlural";this.set("value",a.loc(b))}}.observes("graphModel.dataConfiguration.selection")}}()));DG.GraphAnimator=SC.Object.extend({isAnimating:false,startTime:null,plot:null,axisInfoArray:null,savedAxisInfoArray:null,destroy:function(){this.endAnimation();this.plot=null;this.axisInfoArray=null;this.savedAxisInfoArray=null;arguments.callee.base.apply(this,arguments)},animate:function(f,d){var h=this,g=50,e=DG.PlotUtilities.kDefaultAnimationTime;function c(){var i=(new Date()).valueOf(),j=(i-h.startTime)/e,l;function m(o){if(o>=1){return 1}else{return DG.AnimationMath.DefaultAnimationTween(o)}}function k(p,o,q){return p+q*(o-p)}function n(q){var o=k(q.oldBounds.lower,q.newBounds.lower,l),p=k(q.oldBounds.upper,q.newBounds.upper,l);q.axis.setLowerAndUpperBounds(o,p)}l=m(j);h.axisInfoArray.forEach(n);if(j<1){DG.assert(!h.animationTimer.get("isPaused"))}else{h.endAnimation(f,d)}}function b(i){i.oldBounds={lower:i.axis.get("lowerBound"),upper:i.axis.get("upperBound")}}var a=function(){var i=this.axisInfoArray.some(function(j){return j.axis.get("scaleCanAnimate")});return !i}.bind(this);if(this.isAnimating){this.endAnimation()}this.isAnimating=true;this.savedAxisInfoArray=this.axisInfoArray;this.axisInfoArray.forEach(b);if(a()){this.endAnimation();return}this.startTime=(new Date()).valueOf();if(SC.none(this.animationTimer)){this.animationTimer=SC.Timer.schedule({action:c,interval:g,repeats:YES,until:false})}this.animationTimer.set("isPaused",NO);c()},reset:function(){this.animationTimer.set("isPaused",YES);if(!SC.none(this.plot)){this.setPath("plot.isAnimating",false)}this.isAnimating=false},endAnimation:function(b,a){if(this.animationTimer){this.animationTimer.set("isPaused",YES)}if(!SC.none(this.plot)){this.setPath("plot.isAnimating",false)}this.savedAxisInfoArray.forEach(function(c){c.axis.setLowerAndUpperBounds(c.newBounds.lower,c.newBounds.upper)});this.isAnimating=false;if(!SC.none(a)){a.call(b)}}});DG.PlotUtilities.PlotCaseArray=SC.Object.extend({_cases:null,_map:null,init:function(){arguments.callee.base.apply(this,arguments);this._cases=this._cases||[];this._map=this._map||[]},length:function(){return this._map.length}.property("_map"),at:function(a){return this._cases[this._map[a]]},unorderedAt:function(a){return this._cases[a]},push:function(a){this._cases.push(a);this._map.push(this._cases.length-1)},indexOf:function(a){return this._cases.indexOf(a)},forEach:function(a){this._map.forEach(function(c,b){a(this._cases[c],c,b)}.bind(this))},forEachWithInvokeLater:function(g,i){var a=0,h=this.length(),f=Math.min(200,h/20),e=(h>1000)?5:0,d=h-e*f,c=true,b=function(){var j=a+(e>0?f:d);e--;if(a<h){for(;c&&a<h&&a<j;a++){if(g){c=g(this._cases[this._map[a]],this._map[a],a===h-1)}}if(c){this.invokeLater(b,100)}}else{if(i){i()}}}.bind(this);b()},map:function(a){var b=DG.PlotUtilities.PlotCaseArray.create();this.forEach(function(c,d){b._cases[d]=a(c,d);b._map.push(d)});return b},filter:function(a){var b=DG.PlotUtilities.PlotCaseArray.create();this.forEach(function(c,e){if(a(c,e)){var d=b._cases.length;b._cases.push(c);b._map.push(d)}}.bind(this));return b},reduce:function(b,a){return this._cases.reduce(b,a)},toArray:function(){return this._cases.slice()}});var kMargin=0,kLeading=5,kPaddingRight=5;DG.RulerGroupView=SC.View.extend(SC.FlowedLayout,{visibilityStateProperty:"",localizable:true,layoutDirection:SC.LAYOUT_VERTICAL,isResizable:false,isClosable:false,defaultFlowSpacing:{left:kMargin,bottom:kLeading},canWrap:false,align:SC.ALIGN_TOP,layout:{top:kLeading,right:kPaddingRight},childViews:"toggleView".w(),toggleView:SC.DisclosureView.design({classNames:"dg-disclosure".w(),layout:{width:200,height:18},value:false}),init:function(){var a=this;arguments.callee.base.apply(this,arguments);this.setPath("toggleView.title",this.get("title"));this.invokeLater(function(){a.setPath("toggleView.value",DG.UnivariateAdornmentBaseModel.rulerState[this.get("visibilityStateProperty")])},100)},forEachControlView:function(a){var b=this.get("toggleView");this.get("childViews").forEach(function(c){c!==b&&a(c)})},syncChildViewVisibility:function(){var a=this;this.forEachControlView(function(b){b.set("isVisible",a.getPath("toggleView.value"))})},toggleViewValueDidChange:function(){this.syncChildViewVisibility();DG.UnivariateAdornmentBaseModel.rulerState[this.get("visibilityStateProperty")]=this.getPath("toggleView.value")}.observes(".toggleView.value")});DG.DragLabelHandler=SC.Object.extend((function(){var a=5;return{labelNode:null,labelView:null,viewToAddTo:null,attributeDescription:null,attributeName:null,attributeDidChange:function(){this.set("attributeName",this.getPath("attributeDescription.attribute.name"))}.observes("attributeDescription.attribute"),dataContext:null,receivedStartDrag:false,receivedDoDrag:false,handleStartDrag:function(b,f,e){var c=this.labelView,d=this.get("attributeName");SC.run(function(){c.set("value",d);this.viewToAddTo.removeChild(c);this.viewToAddTo.appendChild(c)}.bind(this));this.receivedStartDrag=true;this.receivedDoDrag=false},handleDoDrag:function(e,c,h,g,b){var i;if(this.receivedStartDrag&&!this.receivedDoDrag){i=Math.sqrt((e*e)+(c*c));if(i<a){return}this.receivedDoDrag=true;var j=this.labelView,d=this.get("attributeName"),m=this.attributeDescription,k=m.attributeNamed(d),f=m.get("collectionClient"),l=this.dataContext;if(!k){return}this.labelNode.ignoreTouchEnd();SC.run(function(){DG.Drag.start({event:b,source:this.viewToAddTo,dragView:j,ghost:YES,ghostActsLikeCursor:YES,slideBack:YES,origin:{x:b.clientX,y:b.clientY},data:{context:l,collection:f.get("collection"),attribute:k,text:d}})}.bind(this))}},handleEndDrag:function(){this.receivedStartDrag=false;this.receivedDoDrag=false;this.labelNode.reinstateTouchEnd()}}}()));sc_require("utilities/tool_tip");DG.InfoTip=DG.DataTip.extend({layerName:"dataTip",getDataTipText:function(){var a="";if(this.info){a=this.info.tipString.loc(this.info.tipValue)}return a},show:function(a){this.tipOrigin={x:a.x,y:a.y};this.info={tipString:a.tipString,tipValue:a.tipValue};arguments.callee.base.apply(this,arguments)}});DG.LabelNode=SC.Object.extend({paper:null,clickCallback:null,text:null,description:null,labelIndex:0,colorIndex:0,numColors:1,rotation:0,priorNode:null,loc:null,_circleElement:null,_textElement:null,kCircleRadius:6,anchor:"middle",touchEndHandler:null,getPointColor:null,bBox:function(){return this._textElement.getBBox()}.property("text"),init:function(){this._textElement=this.paper.text(0,0,"").attr("text-anchor",this.anchor);DG.RenderingUtilities.rotateText(this._textElement,this.rotation,0,0);this.numColorsChanged()},destroy:function(){var a=this.get("touchEndHandler");this._textElement.undrag();this.unmousedown(a);arguments.callee.base.apply(this,arguments)},hide:function(){this._textElement.hide();if(this._circleElement){this._circleElement.hide()}},show:function(){this._textElement.show();if(this._circleElement){this._circleElement.show()}},numColorsChanged:function(){var a="blue",b="lightblue";this._textElement.addClass("dg-axis-label");this._textElement.removeClass("dg-axis-label-empty-graph");switch(this.numColors){case 0:a=DG.PlotUtilities.kEmptyPromptColor;this._textElement.removeClass("dg-axis-label");this._textElement.addClass("dg-axis-label-empty-graph");break;case 1:a="blue";b="lightblue";break;default:if(this.colorIndex===0){a=this.getPointColor?this.getPointColor():DG.PlotUtilities.kDefaultPointColor}else{a=DG.ColorUtilities.calcAttributeColorFromIndex(this.colorIndex,this.numColors)}b=a}this._textElement.attr("fill",a);if((this.numColors>1)&&!this._circleElement){this._circleElement=this.paper.circle(0,0,this.kCircleRadius).addClass("dg-axis-dot")}else{if((this.numColors<=1)&&this._circleElement){this._circleElement.remove();this._circleElement=null}}if(this._circleElement){this._circleElement.attr("fill",b)}}.observes("numColors"),textChanged:function(){this._textElement.attr("text",this.text)}.observes("text"),descriptionChanged:function(){this._textElement.attr("title",this.description)}.observes("description"),locChanged:function(){var c=this._circleElement?this.kCircleRadius/2:0;this._textElement.attr({x:this.loc.x,y:this.loc.y-c});DG.RenderingUtilities.rotateText(this._textElement,this.rotation,this.loc.x,this.loc.y-c);if(this._circleElement){var b=this._textElement.getBBox(),a;if(this.rotation!==0){a={cx:this.loc.x+1,cy:this.loc.y-c+b.height/2+this.kCircleRadius+2}}else{a={cx:this.loc.x-(b.width/2+this.kCircleRadius+2),cy:this.loc.y}}this._circleElement.attr(a)}}.observes("loc"),extent:function(){var a=this._textElement.getBBox();if(this._circleElement){a.width+=(this.rotation===0)?2*this.kCircleRadius+2:0;a.height+=(this.rotation!==0)?2*this.kCircleRadius+2:0}return a},mousedown:function(a){this._textElement.click(a);this._textElement.touchend(a);this.set("touchEndHandler",a);this._circleElement&&this._circleElement.click(a)},unmousedown:function(b){function a(d){var e=d&&d.events;if(SC.isArray(e)){var c=e.length;while(c--){if(e[c].name==="click"||e[c].name==="touchend"){e[c].unbind();e.splice(c,1);!e.length&&delete d.events}}}}a(this._textElement);a(this._circleElement);this.set("touchEndHandler",null)},ignoreTouchEnd:function(){this._textElement.untouchend()},reinstateTouchEnd:function(){this._textElement.touchend(this.get("touchEndHandler"))},setDragLabelHandler:function(a){this._textElement.drag(a.handleDoDrag,a.handleStartDrag,a.handleEndDrag,a,a,a);return this},remove:function(){this._textElement.remove();this._circleElement&&this._circleElement.remove()}});sc_require("views/raphael_base");DG.CategoriesView=DG.RaphaelBaseView.extend((function(){var a=150,e=20,d=14;var c=SC.Object.extend({model:null,paper:null,cellName:null,coordinatesToCellNum:null,keyRect:null,keyText:null,color:null,left:0,top:0,rectSize:0,spaceForText:0,containingView:null,init:function(){var h=this,s=this.containingView,l,p,g,f,k,n=function(t){this.transform("s1.2")},r=function(t){this.transform("")},q=function(t){SC.run(function(){h.get("model").selectCasesInCell(h.cellName,t.shiftKey)}.bind(this))},j=function(u,t){l=h.getPath("model.cellNames");g=DG.ViewUtilities.windowToViewCoordinates({x:u,y:t},s);p=f=h.coordinatesToCellNum(g);k={x:h.left-g.x,y:h.top-g.y}},o=function(z,y,u,t){var w=h.get("model"),x={x:g.x+z,y:g.y+y},v=h.coordinatesToCellNum(x);if(isNaN(x.x)||isNaN(x.y)||isNaN(v)){return}SC.run(function(){if(v!==f){f=i(w.get("attributeDescription"),v,f)}s.set("dragInfo",{cellBeingDragged:f,offset:k,position:x});s.displayDidChange();s.propertyDidChange("categoriesDragged")})},m=function(v){SC.run(function(){s.set("dragInfo",null);s.displayDidChange();s.propertyDidChange("categoriesDragged");s.updateLayerIfNeeded()});if(p!==f){var u=l[p],t=l[f];DG.UndoHistory.execute(DG.Command.create({name:"swapCategories",undoString:"DG.Undo.graph.swapCategories",redoString:"DG.Redo.graph.swapCategories",log:"Moved category %@ into position of %@".fmt(u,t),_initialCell:p,_finalCell:f,_legendModel:h.get("model"),execute:function(){},undo:function(){i(this._legendModel.get("attributeDescription"),this._initialCell,this._finalCell);var w=this._initialCell;this._initialCell=this._finalCell;this._finalCell=w},redo:function(){this.undo()}}))}},i=function(x,v,u){var t=Math.sign(v-u),w=u+t;while(w!==v+t){DG.PlotUtilities.swapCategoriesByIndex(x,u,w);w+=t;u+=t}return u};this.keyRect=this.paper.rect(0,0,this.rectSize,this.rectSize).attr({fill:this.color}).addClass(DG.PlotUtilities.kLegendKey).mouseover(n).mouseout(r).mousedown(q).drag(o,j,m);this.keyText=this.paper.text(0,0,this.cellName).attr({"text-anchor":"start"}).addClass(DG.PlotUtilities.kLegendKeyName).mousedown(q).drag(o,j,m)},destroy:function(){this.keyRect.remove();this.keyText.remove();this.containingView=null;arguments.callee.base.apply(this,arguments)},draw:function(g){var h={x:this.left,y:this.top,width:this.rectSize,height:this.rectSize,fill:this.color},f={x:this.left+this.rectSize+5,y:this.top+this.rectSize-5};if(g){this.keyRect.animate(h,100,"<>");this.keyText.animate(f,100,"<>")}else{this.keyRect.attr(h);this.keyText.attr(f)}this.keyText.attr("text",this.cellName);DG.RenderingUtilities.elideToFit(this.keyText,this.spaceForText)}});return{displayProperties:["model.attributeDescription.attribute","model.attributeDescription.attributeStats.categoricalStats.numberOfCells","model.updateCases"],model:null,categoryKeys:null,dragInfo:null,colWidth:null,rowHeight:null,numColumns:2,init:function(){arguments.callee.base.apply(this,arguments);this.categoryKeys={}},maxCellNameExtent:function(){var h=0,f=this.get("paper"),g=this.getPath("model.cellNames");if(!f||!g){return a}g.forEach(function(i){h=Math.max(h,DG.RenderingUtilities.textExtent(i).x)});return h+d+10},desiredExtent:function(h){var f=Math.max(e,Math.min(a,this.maxCellNameExtent())),j=this.getPath("frame.width")||f,k=Math.max(2,Math.floor(j/f)),g=this.model?this.getPath("model.numberOfCells"):0,i=Math.ceil(g/k);return i*h},doDraw:function b(){if(!this.get("isVisible")){return}var n=this.getPath("model.attributeDescription"),h=this._paper.width,o=this._paper.height,j=Math.max(e,Math.min(a,this.maxCellNameExtent()+5)),w=Math.max(2,Math.floor(h/j)),v=this.getPath("model.numberOfCells"),l=Math.ceil(v/w),i=o/l,u,g=this.getPath("model.cellNames"),m=this.get("categoryKeys"),f=function(y){var x=Math.min(this.numColumns-1,Math.max(0,Math.floor(y.x/this.colWidth))),A=Math.min(this.numRows-1,Math.max(0,Math.floor(y.y/this.rowHeight))),z=Math.min(this.numCells-1,x+A*this.numColumns);return z}.bind(this);this.set("rowHeight",i);this.set("colWidth",j);this.set("numColumns",w);this.set("numRows",l);this.set("numCells",v);DG.ObjectMap.forEach(m,function(x,y){y.set("inUse",false)});for(u=0;u<v&&u<g.length;u++){var r=g[u],k=DG.ColorUtilities.calcCaseColor(r,n),t=Math.floor(u/w),s=u%w,p=m[r],q=this.dragInfo&&this.dragInfo.cellBeingDragged===u;k=k.colorString||k;if(!p){m[r]=p=c.create({model:this.get("model"),paper:this.get("paper"),containingView:this,coordinatesToCellNum:f})}if(q){p.set("left",this.dragInfo.position.x+this.dragInfo.offset.x);p.set("top",this.dragInfo.position.y+this.dragInfo.offset.y)}else{p.set("left",s*h/w+2);p.set("top",t*i+2)}p.set("rectSize",i-5);p.set("spaceForText",h/w-(i-5)-8);p.set("color",k);p.set("cellName",r);p.set("inUse",true);p.draw(!q)}DG.ObjectMap.forEach(m,function(x,y){if(!y.inUse){y.destroy();delete m[x]}})},selectionDidChange:function(){var f=this.getPath("model.selectionMap"),g=this.get("categoryKeys");if(SC.none(f)||SC.none(g)){return}DG.ObjectMap.forEach(g,function(h,i){if(f[h]){i.keyRect.addClass(DG.PlotUtilities.kLegendKeySelected)}else{i.keyRect.removeClass(DG.PlotUtilities.kLegendKeySelected)}})}.observes("*model.selectionMap")}}()));sc_require("views/raphael_base");DG.ChoroplethView=DG.RaphaelBaseView.extend((function(){var b=16,c=3;return{displayProperties:["model.attributeDescription.attribute","model.numericRange","model.dataConfiguration.legendQuantilesAreLocked"],model:null,desiredExtent:function(d){return b+c+d},doDraw:function a(){var g=0.5,j=this.getPath("model.attributeDescription"),f=j.get("attributeType"),i=this._paper.width-2,k=this.getPath("model.dataConfiguration.legendQuantiles"),d=k.length-1;var h=function(){var q={min:k[0],max:k[d]},o,l;if(f===DG.Analysis.EAttributeType.eNumeric){var m=DG.Format.number().fractionDigits(0,2),p=DG.Format.number().fractionDigits(0,2);if(q.min<2500){m.group("")}if(q.max<2500){p.group("")}o=m(q.min);l=p(q.max)}else{if(f===DG.Analysis.EAttributeType.eDateTime){o=DG.formatDate(q.min);l=DG.formatDate(q.max)}}var n=b+c+DG.RenderingUtilities.kDefaultFontHeight/2;this._elementsToClear.push(this._paper.text(g,n,o).attr({"text-anchor":"start"}));this._elementsToClear.push(this._paper.text(i-2*g,n,l).attr({"text-anchor":"end"}))}.bind(this),e=function(){var o={min:0,max:1},n=j.getPath("attribute.categoryMap"),l=DG.ColorUtilities.calcAttributeColor(j),m=DG.ColorUtilities.getAttributeColorSpectrumEndsFromColorMap(n,l);k.forEach(function(v,s){if((typeof v==="number")&&s<d){var q=k[s+1],w=i*s/d,u=w+i*(s+1)/d,r=DG.ColorUtilities.calcGradientColor(o,m.low,m.high,(s+1)/d),p=f===DG.Analysis.EAttributeType.eNumeric?"%@ – %@".fmt(Math.round(v*100)/100,Math.round(q*100)/100):"%@ – %@".fmt(DG.formatDate(v),DG.formatDate(q)),t=this._paper.rect(w,0,0,0).attr({width:u-w,height:b,fill:r.colorString||r,"stroke-width":g,title:p}).addClass("dg-choro-rect").click(function(x){this.selectCasesBetween(v,q,x.shiftKey)}.bind(this));this._elementsToClear.push(t)}}.bind(this))}.bind(this);if(!j||j.get("attribute")===null){return}h();e()},selectCasesBetween:function(g,h,j){var d=this.getPath("model.attributeDescription.attribute.id"),i=this.getPath("model.dataConfiguration.cases"),e=this.getPath("model.attributeDescription.attribute.name"),f={operation:"selectCases",collection:this.getPath("dataConfiguration.collectionClient"),cases:[],select:true,extend:j};if(SC.none(d)||SC.none(i)){return}i.forEach(function(k){var l=k.getNumValue(d);if(l>=g&&l<=h){f.cases.push(k)}});this.getPath("model.dataConfiguration.dataContext").applyChange(f);DG.logUser("caseSelected with values of: %@ between %@ and %@",e,g,h)}}}()));DG.LegendModel=SC.Object.extend({dataConfiguration:null,attributeDescription:null,selectionMap:null,isNumeric:function(){return this.getPath("attributeDescription.isNumeric")}.property(),isNumericDidChange:function(){this.notifyPropertyChange("isNumeric")}.observes("*attributeDescription.isNumeric"),label:function(){var d="",e=this.get("attributeDescription"),a=SC.none(e)?DG.Analysis.kNullAttribute:e.get("attribute"),b=a&&a.get("name"),c=a&&a.get("unit");if(a!==DG.Analysis.kNullAttribute){d=b+(!SC.empty(c)?" ("+c+")":"")}return d}.property(),labelDidChange:function(){this.notifyPropertyChange("label")}.observes("*attributeDescription.attribute"),handleUpdateAttribute:function(a){this.labelDidChange()},numberOfCells:function(){var a=this.getPath("attributeDescription.attributeStats.numberOfCells");return DG.MathUtilities.isFinite(a)?Math.max(1,a):0}.property(),numberOfCellsDidChange:function(){this.notifyPropertyChange("numberOfCells")}.observes("*attributeDescription.attributeStats.numberOfCells"),cellMapDidChange:function(){this.updateSelection()}.observes("attributeDescription.attributeStats.categoricalStats.cellMap"),numericRange:function(){return this.getPath("attributeDescription.attributeStats.numericRange")}.property(),numericRangeDidChange:function(){this.notifyPropertyChange("numericRange")}.observes("*attributeDescription.attributeStats.numericRange"),cellNames:function(){return this.getPath("attributeDescription.cellNames")}.property(),cellNamesDidChange:function(){this.notifyPropertyChange("cellNames")}.observes("*attributeDescription.attributeStats.cellMap"),selectCasesInCell:function(c,f){var d=this.getPath("attributeDescription.collectionClient"),a=d&&DG.DataContext.getContextFromCollection(d),e=this.get("attributeDescription").casesForCategory(c),b={operation:"selectCases",collection:d,cases:e,select:true,extend:f};if(a&&e){a.applyChange(b)}},attributeDidChange:function(){var c=this.get("attributeDescription"),a=c.get("attribute"),b=a&&(a!==DG.Analysis.kNullAttribute)&&a.get("categoryMap");if(!a||(a===DG.Analysis.kNullAttribute)||c.get("isNumeric")){return}b=b||{};this.get("cellNames").forEach(function(d){var e=b[d];if(!e){b[d]=DG.ColorUtilities.calcCaseColor(d,c,DG.ColorUtilities.kMissingValueCaseColor)}});a.set("categoryMap",b)}.observes("attributeDescription.attribute"),handleOneDataContextChange:function(a,b){var c=b&&b.operation;switch(c){case"createCases":case"deleteCases":case"updateCases":case"dependentCases":if(this.get("isNumeric")){this.numericRangeDidChange()}else{this.notifyPropertyChange("updateCases")}break;case"selectCases":this.updateSelection();break}},updateSelection:function(){var c={},a=this.getPath("dataConfiguration.collectionClient.casesController.selection"),b=this.getPath("attributeDescription.attributeStats.cellMap");DG.ObjectMap.forEach(b,function(e,d){if((d.cases.length>0)&&d.cases.every(function(f){return a.containsObject(f)})){c[e]=true}});this.set("selectionMap",c)}});sc_require("components/graph/utilities/graph_drop_target");sc_require("views/raphael_base");DG.LegendView=DG.RaphaelBaseView.extend(DG.GraphDropTarget,(function(){var c=3,a=6;return{displayProperties:["model.attributeDescription.attribute","model.attributeDescription.attribute.categoryMap"],classNames:["dg-legend-view"],model:null,orientation:DG.GraphTypes.EOrientation.kNone,categoriesView:null,choroplethView:null,modelDidChange:function(){this.setPath("categoriesView.model",this.get("model"));this.setPath("choroplethView.model",this.get("model"))}.observes("model"),plottedAttribute:function(){return this.getPath("model.attributeDescription.attribute")}.property(),desiredExtent:function(){var e=this.get("labelExtent").y,d=e+(e===0?0:2*c);switch(this.get("attributeType")){case DG.Analysis.EAttributeType.eNumeric:case DG.Analysis.EAttributeType.eDateTime:d+=this.get("choroplethView").desiredExtent(e);break;case DG.Analysis.EAttributeType.eCategorical:d+=this.get("categoriesView").desiredExtent(e);break;case DG.Analysis.EAttributeType.eColor:break}return d}.property(),desiredExtentDidChange:function(){this.notifyPropertyChange("desiredExtent")}.observes("labelNode","*model.numberOfCells","model.attributeDescription.attributeStats.attributeType"),labelExtent:function(){var f=DG.RenderingUtilities.kCaptionFontHeight,d=this.get("labelNode"),e;if(!SC.none(d)){e=d.get("bBox");return{x:isNaN(e.width)?f:Math.max(f,e.width),y:isNaN(e.height)?f:Math.max(f,Math.ceil(e.height/2)*2)}}return{x:0,y:0}}.property("labelNode").cacheable(),labelNode:function(){var f=false,e,d;if(SC.none(this._paper)){return}if(SC.none(this._labelNode)){this._labelNode=DG.LabelNode.create({paper:this._paper,rotation:0,colorIndex:0,numColors:1,anchor:"start"});this._labelNode.setDragLabelHandler(DG.DragLabelHandler.create({labelNode:this._labelNode,labelView:this._hiddenDragView,viewToAddTo:this,attributeDescription:this.getPath("model.attributeDescription"),attributeName:this.getPath("model.attributeDescription.attribute.name"),dataContext:this.getPath("model.dataConfiguration.dataContext")}));f=true}e=this.getPath("model.label");if(e!==this._labelNode.get("text")){this._labelNode.set("text",e);f=true}d=this.getPath("model.attributeDescription.attribute.description")+"—"+"DG.LegendView.attributeTooltip".loc();if(d!==this._labelNode.get("description")){this._labelNode.set("description",d);f=true}if(f){this.notifyPropertyChange("labelNode",this._labelNode)}if(SC.empty(e)){return null}else{return this._labelNode}}.property(),labelNodeDidChange:function(){this.notifyPropertyChange("labelNode")}.observes("*model.label"),labelNodes:function(){var d=this.get("labelNode");if(d){return[d]}else{return[]}}.property("labelNode"),_labelNode:null,_hiddenDragView:null,init:function(){arguments.callee.base.apply(this,arguments);this.categoriesView=DG.CategoriesView.create({classNames:"dg-categories".w(),layout:{left:a,right:a,top:c,bottom:c},isVisible:false,model:this.get("model"),rowHeight:DG.RenderingUtilities.kDefaultFontHeight});this.appendChild(this.categoriesView);this.choroplethView=DG.ChoroplethView.create({classNames:"dg-choropleth".w(),layout:{left:a,right:a,top:c,bottom:c},isVisible:false,model:this.get("model")});this.appendChild(this.choroplethView);this._hiddenDragView=SC.LabelView.create({classNames:"dg-drag-label".w(),layout:{width:100,height:20,top:-50,left:0},value:""});this.appendChild(this._hiddenDragView);this.addObserver("model.dataConfiguration.cases",this,"displayDidChange");this.addObserver("model.dataConfiguration.hiddenCases",this,"displayDidChange")},destroy:function(){this.removeObserver("model.dataConfiguration.cases",this,"displayDidChange");this.removeObserver("model.dataConfiguration.hiddenCases",this,"displayDidChange");arguments.callee.base.apply(this,arguments)},displayDidChange:function(){arguments.callee.base.apply(this,arguments);this.get("choroplethView").displayDidChange();this.get("categoriesView").displayDidChange()},doDraw:function b(){var d=function(){var g=this.get("labelNode"),h=this.get("labelExtent"),i=this.getPath("model.attributeDescription.attribute.description")+"—"+"DG.LegendView.attributeTooltip".loc();if(SC.none(g)){return}g.get("_textElement").attr({text:this.getPath("model.label"),x:a,y:h.y/2});g.get("_textElement").attr({title:i})}.bind(this);var f=this.get("categoriesView"),e=this.get("choroplethView");d();switch(this.get("attributeType")){case DG.Analysis.EAttributeType.eNumeric:case DG.Analysis.EAttributeType.eDateTime:e.set("isVisible",true);f.set("isVisible",false);e.adjust("top",c+this.get("labelExtent").y);break;case DG.Analysis.EAttributeType.eCategorical:f.adjust("top",c+this.get("labelExtent").y);f.set("isVisible",true);e.set("isVisible",false);break}},dragData:null,performDragOperation:function(d,e){this.hideDropHint();this.set("dragData",d.data);return SC.DRAG_LINK},drawWidth:function(){return Math.max(0,this.get("frame").width-2*DG.ViewUtilities.kBorderWidth)}.property("frame"),isNumeric:function(){return this.getPath("model.isNumeric")}.property(),isNumericDidChange:function(){this.notifyPropertyChange("isNumeric")}.observes("*model.isNumeric"),attributeType:function(){return this.getPath("model.attributeDescription.attributeType")}.property(),attributeTypeDidChange:function(){this.notifyPropertyChange("attributeType");this.displayDidChange()}.observes("*model.attributeDescription.attributeStats.attributeType")}}()));DG.GuideConfigurationView=SC.PalettePane.extend({itemRow:SC.View.extend({blurAction:null,blurTarget:null,childViews:"itemTitle itemURL".w(),itemTitle:SC.TextFieldView.design({hint:"DG.GuideConfigView.itemTitleHint"}),itemURL:SC.TextFieldView.design({hint:"DG.GuideConfigView.itemURLHint"}),init:function(){arguments.callee.base.apply(this,arguments);var b=this.get("blurAction"),a=this.get("blurTarget");this.setPath("itemTitle.layout",{left:5,width:140});this.setPath("itemURL.layout",{left:150,right:5});this.get("childViews").forEach(function(c){c.set("fieldDidBlur",function(){if(b){b.call(a)}})})},rowObject:function(){var a=this.getPath("itemTitle.value"),b=this.getPath("itemURL.value");if(!SC.empty(a)||!SC.empty(b)){return{itemTitle:a,url:b}}return null}.property(),setItem:function(a){if(a){this.setPath("itemTitle.value",a.itemTitle);this.setPath("itemURL.value",a.url)}}}),model:null,isModal:YES,layout:{width:400,height:400,centerX:0,centerY:0},contentView:SC.View.extend({childViews:"titleField menuItems okButton cancel warning".w(),titleField:SC.TextFieldView.design({layout:{top:5,left:5,right:25,height:24},value:"",spellCheckEnabled:true,hint:"DG.GuideConfigView.titleHint",leftAccessoryView:SC.LabelView.create({layout:{left:1,width:95,height:22,centerY:0},value:"DG.GuideConfigView.titlePrompt",backgroundColor:"lightgray",localize:true})}),menuItems:SC.View.design({layout:{left:5,right:5,top:34,bottom:34},backgroundColor:"white"}),okButton:SC.ButtonView.design({layout:{bottom:5,right:5,height:24,width:90},titleMinWidth:0,title:"DG.GuideConfigView.okBtnTitle",toolTip:"DG.GuideConfigView.okBtnToolTip",target:null,action:null,localize:true,isDefault:true}),cancel:SC.ButtonView.design({layout:{bottom:5,right:115,height:24,width:90},titleMinWidth:0,title:"DG.GuideConfigView.cancelBtnTitle",target:null,action:null,toolTip:"DG.GuideConfigView.cancelBtnTooltip",localize:true,isCancel:true}),warning:SC.LabelView.design({value:"DG.GuideConfigView.httpWarning",classNames:"dg-guide-alert",isVisible:false,transitionShow:SC.View.FADE_IN,localize:true})}),title:function(){return this.getPath("contentView.titleField.value")}.property(),items:function(){return this.get("rowObjects")}.property(),addMenuItemRow:function(d){var a=this.getPath("contentView.menuItems"),b=this.get("rowViews").length,e=5+b*27,c=this.itemRow.create({layout:{border:1,left:5,right:5,top:e+5,height:22},blurAction:this.configureRows,blurTarget:this});c.setItem(d);a.appendChild(c)},rowViews:function(){return this.getPath("contentView.menuItems.childViews")}.property(),rowObjects:function(){return this.get("rowViews").map(function(a){return a.get("rowObject")}).filter(function(a){return !!a})}.property(),configureRows:function(){var b=function(){var f=this.get("rowObjects"),e=this.getPath("contentView.warning"),d=this.getPath("contentView.titleField.layout");e.set("isVisible",false);f.forEach(function(g,j){var i=SC.empty(g.url)?"":g.url.toLowerCase();if(!SC.empty(i)&&(i.indexOf("http://")!==0)&&(i.indexOf("https://")!==0)){var h=this.get("rowViews")[j].get("layout"),k=d.top+d.height+h.top+h.height-3;e.set("layout",{left:160,top:k,height:12});e.set("isVisible",true)}}.bind(this))}.bind(this);var c=this.get("rowViews").length,a=this.get("rowObjects").length;b();while(c<a+1){this.addMenuItemRow();c++}},setupFromModel:function(b){var a=this.get("model");this.setPath("contentView.titleField.value",a.get("title"));a.get("items").forEach(function(c){this.addMenuItemRow(c)}.bind(this))},init:function(){arguments.callee.base.apply(this,arguments);this.setPath("contentView.cancel.target",this);this.setPath("contentView.cancel.action","close");this.setupFromModel();this.configureRows()},close:function(){this.remove();this.destroy()}});DG.CreateGuideConfigurationView=function(b){var d=DG.GuideConfigurationView.create(b),a=d.get("contentView"),c=d.getPath("contentView.titleField");a.setPath("okButton.target",b.okTarget);a.setPath("okButton.action",b.okAction);d.append();c.becomeFirstResponder();return d};DG.StringUtilities={escapeRegExpRE:/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,escapeRegExp:function(a){return a.replace(DG.StringUtilities.escapeRegExpRE,"\\$&")},createEscapedRegExp:function(b,a){return new RegExp(DG.StringUtilities.escapeRegExp(b),a)},guaranteePrefix:function(a,b){return(a.indexOf(b)===0)?a:b+a},scan:function(b,d,e){if(!d.global){throw"regexp must have global flag set"}var a,c=[];while((a=d.exec(b))!==null){if(e===null){c.push(a)}else{c.push(e.call(window,a))}}return c}};sc_require("controllers/component_controller");sc_require("utilities/string_utilities");DG.GuideController=DG.ComponentController.extend({guideModel:null,guideButton:null,guideMenuPane:null,reset:function(){this.guideModel.reset();this.set("view",null)},updateViewTitle:function(){var a=this.getPath("guideModel.title");this.setPath("view.title",a)}.observes("guideModel.title"),modelContentsDidChange:function(){var a=this.getPath("guideModel.title"),j=this.getPath("guideModel.items"),h=this.get("iconMenuItems"),b=this.get("guideButton"),d=this.get("guideMenuPane"),g=!SC.empty(a)||(j.length>0),i=this.getPath("guideModel.currentURL");if(b){b.set("isVisible",g)}if(d){var e="DG.ToolButtonData.guideMenu.showGuide".loc(),f=[{title:e,isEnabled:true,target:this,action:"showGuide"},{isSeparator:true}];d.set("items",f.concat(h))}if((h.length>0)&&SC.empty(i)){var c=h[0];this.setPath("guideModel.currentURL",c.url);this.setPath("guideModel.currentItemTitle",c.title)}}.observes("guideModel.title","guideModel.items"),isVisibleDidChange:function(){var b=this.get("view");var a=this.getPath("guideModel.isVisible");if(!SC.none(a)&&b){if(a){b.set("isVisible",true);b.select();b.scrollToVisible()}else{b.set("isVisible",false)}}}.observes("guideModel.isVisible"),willCloseComponent:function(){this.setPath("guideModel.isVisible",false)},showGuide:function(){DG.UndoHistory.execute(DG.Command.create({name:"guide.show",undoString:"DG.Undo.guide.show",redoString:"DG.Redo.guide.show",log:"Show guide",execute:function(){this.setPath("guideModel.isVisible",true)}.bind(this),undo:function(){this.setPath("guideModel.isVisible",false)}.bind(this)}))},guideNavigation:function(){var d=this,b=d.getPath("guideMenuPane.selectedItem.url"),c=d.getPath("guideMenuPane.selectedItem.title"),a=d.getPath("guideMenuPane.selectedItem.index");DG.UndoHistory.execute(DG.Command.create({name:"guide.navigate",undoString:"DG.Undo.guide.navigate",redoString:"DG.Redo.guide.navigate",_previous:{index:d.getPath("guideModel.currentItemIndex"),wasVisible:d.getPath("view.isVisible")},execute:function(){d.setPath("guideModel.currentItemIndex",a);d.showGuide();this.log="Guide icon navigation: { Title: %@, itemTitle: %@, url: %@ }".fmt(d.getPath("guideModel.title"),c,b)},undo:function(){d.setPath("guideModel.currentItemIndex",this._previous.index);d.setPath("view.isVisible",this._previous.wasVisible)}}))},iconMenuItems:function(){var b=this.getPath("guideModel.items"),c=[],a="guideNavigation";b.forEach(function(e,d){c.push({title:e.itemTitle,url:e.url,index:d,target:this,action:a})}.bind(this));return c}.property(),viewDidChange:function(){if(!SC.none(this.tempIsVisible)){this.setPath("view.isVisible",this.tempIsVisible)}this.tempIsVisible=undefined;this.updateViewTitle()}.observes("view"),createComponentStorage:function(){var a=this.get("guideModel").createComponentStorage();a.isVisible=this.getPath("guideModel.isVisible");return a},restoreComponentStorage:function(a){arguments.callee.base.apply(this,arguments);this.get("guideModel").restoreComponentStorage(a)}});DG.GuideModel=SC.Object.extend({title:"",items:null,isVisible:false,currentURL:function(){var a=this.get("currentItem");return !SC.none(a)&&a.url}.property("currentItem","currentItemIndex"),currentItemTitle:function(){var a=this.get("currentItem");return !SC.none(a)&&a.url}.property("currentItem","currentItemIndex"),currentItemIndex:null,currentItem:function(){var a=this.get("currentItemIndex");if(a&&this.items&&(a>=this.items.length)){a=this.items.length&&this.items.length-1;this.set("currentItemIndex",a);this.notifyPropertyChange("currentURL")}if(!SC.none(a)&&this.items){return this.items[a]}}.property("items","currentItemIndex"),init:function(){arguments.callee.base.apply(this,arguments);this.reset()},reset:function(){this.beginPropertyChanges();this.set("title","");this.set("items",[]);this.endPropertyChanges()},createComponentStorage:function(){return{title:this.title,items:this.items,currentItemIndex:this.currentItemIndex}},restoreComponentStorage:function(a){this.beginPropertyChanges();if(a.currentItemIndex){this.set("currentItemIndex",a.currentItemIndex)}if(a.isVisible){this.set("isVisible",a.isVisible)}if(a.title){this.set("title",a.title)}if(a.items){this.set("items",a.items)}this.endPropertyChanges()},itemsDidChange:function(){if(!this.items){return}var a=this.get("currentItemIndex");if(SC.none(a)){if(this.items.length>0){this.set("currentItemIndex",0)}}this.notifyPropertyChange("currentURL")}.observes("items")});DG.GuideView=SC.WebView.extend((function(){return{guideModel:null,realURL:function(){return this.getPath("guideModel.currentURL")}.property(),realURLDidChange:function(){this.notifyPropertyChange("realURL")}.observes("*guideModel.currentURL"),init:function(){arguments.callee.base.apply(this,arguments);DG.assert(!SC.none(this.get("guideModel")));this.currentURLDidChange()},currentURLDidChange:function(){this.set("value",this.get("realURL"))}.observes("guideModel.currentURL")}}()));sc_require("controllers/component_controller");DG.ImageComponentController=DG.ComponentController.extend({theURL:function(b,a){if(!SC.none(a)){this.setPath("model.content.URL",a)}return this.getPath("model.content.URL")}.property(),theURLDidChange:function(){this.notifyPropertyChange("theURL")}.observes("model.content.URL"),title:"DG.ImageComponent.defaultTitle".loc(),createInspectorButtons:function(){var a=arguments.callee.base.apply(this,arguments);a.push(DG.IconButton.create({layout:{width:32},classNames:"dg-web-view-url".w(),iconClass:"moonicon-icon-mediaTool",showBlip:false,target:this,action:"editURL",toolTip:"DG.Inspector.webViewEditURL.toolTip",localize:true}));return a},editURL:function(){var c=this,b=null;function a(){var d=b.get("value");b.close();c.set("theURL",d)}b=DG.CreateSingleTextDialog({prompt:"DG.DocumentController.enterURLPrompt",textValue:c.get("theURL"),textHint:"URL",okTarget:null,okAction:a,okTooltip:DG.DocumentController.enterViewWebPageOKTip})},createComponentStorage:function(){var a=this.get("theURL"),b={title:this.title};if(!SC.empty(a)){b.URL=a}return b},restoreComponentStorage:function(a){var b=a.URL||"";this.set("theURL",b);this.set("title",a.title)},viewDidChange:function(){var a=this.getPath("view.containerView.contentView");if(a){if(SC.empty(this.theURL)){this.set("theURL",a.get("value"))}a.bind("value",this,"theURL");a.set("controller",this)}}.observes("view.containerView.contentView")});DG.ImageComponentView=SC.View.extend({classNames:["dg-web-view"],childViews:["imageView"],isTextSelectable:YES,value:"",_url:function(){return this.get("value").replace(/^https?:/,"")}.property("value"),imageView:SC.ImageView.extend({classNames:["dg-web-view-frame"],value:function(){return this.getPath("parentView._url")}.property(),valueDidChange:function(){this.notifyPropertyChange("value")}.observes("parentView._url"),scale:SC.BEST_FIT})});DG.BaseMapView=SC.View.extend({model:null,_layerID:null,_map:null,map:function(){return this._map}.property("_map"),baseMapLayer:null,baseMapLabels:null,didCreateMap:function(a){},displayChangeCount:0,lastEventType:null,clickCount:0,idleCount:0,init:function(){arguments.callee.base.apply(this,arguments)},render:function(a,b){if(b){this._layerID=a.push("<div></div>").id()}},didAppendToDocument:function(){if(!this._map){this._createMap()}else{this.viewDidResize()}},_createMap:function(){var b=function(e){var f=this.get("parentView");this._map.off("layeradd",b);this.invokeLater(function(){f.addPointLayers();f.addPolygonLayers();f.adjustLayout()})}.bind(this),c=function(e){SC.run(function(){this.set("lastEventType",e.type);this.incrementProperty("displayChangeCount")}.bind(this))}.bind(this),d=function(e){SC.run(function(){this.incrementProperty("clickCount")}.bind(this))}.bind(this),a=function(e){SC.run(function(){DG.mainPage.mainPane.sendEvent("mouseDown",e,this)}.bind(this))}.bind(this);if(this._map){}else{this._map=L.map(this._layerID,{scrollWheelZoom:false,zoomSnap:0,trackResize:true}).setView(this.getPath("model.center"),this.getPath("model.zoom"));this._map.on("layeradd",b).on("dragstart",c).on("dragend",c).on("moveend",c).on("click",d).on("mousedown",a).on("dragstart drag move",function(){this._clearIdle()}.bind(this)).on("dragend zoomend moveend",function(e){this._setIdle(e.type)}.bind(this));this.backgroundChanged()}},centerDidChange:function(){this.get("map").setView(this.getPath("model.newCenter"),this.getPath("model.newZoom"),{animate:true})}.observes("model.newCenter","model.newZoom"),viewDidResize:function(){var a=this.get("map");if(a){a.invalidateSize()}},_idleTimeout:null,_clearIdle:function(){if(this._idleTimeout){clearTimeout(this._idleTimeout);this._idleTimeout=null}},_setIdle:function(a){if(!this._idleTimeout){this._clearIdle();this._idleTimeout=setTimeout(function(){this._idleTimeout=null;this.set("lastEventType",a);this.incrementProperty("idleCount");this.set("lastEventType",null)}.bind(this),100)}},backgroundChanged:function(){var d=this.get("map"),b=this.getPath("model.baseMapLayerIsVisible")?1:0,c=this.getPath("model.baseMapLayerName"),a;if(!c){return}if(this.get("baseMapLayer")){d.removeLayer(this.get("baseMapLayer"))}if(this.get("baseMapLabels")){d.removeLayer(this.get("baseMapLabels"))}a=L.esri.basemapLayer(c,{crossOrigin:true,opacity:b});this._map.addLayer(a,true);this.set("baseMapLayer",a)}.observes("model.baseMapLayerName")});DG.MapGridLayer=SC.Object.extend({model:null,mapSource:null,paperSource:function(){return this.get("mapSource")}.property("mapSource"),map:function(){return this.getPath("mapSource.mapLayer.map")}.property(),grid:null,_infoTip:null,infoTip:function(){if(!this._infoTip){var a=this;this._infoTip=DG.InfoTip.create({paperSource:function(){return a.get("paperSource")}.property()})}return this._infoTip}.property(),showTips:false,isInMarqueeMode:false,marqueeContext:null,isVisible:function(){return this.getPath("model.isVisible")}.property(),init:function(){arguments.callee.base.apply(this,arguments);this.visibilityHasChanged()},addGridLayer:function(){var d=this,g=this.get("map"),e=this.get("model");if(!g||!e){return}var f={color:"white",fillColor:"red",weight:1},h=[],b=e.get("rectArray").maxCount,c=e.getPath("dataConfiguration.dataContext"),a=e.getPath("dataConfiguration.collectionClient"),i;e.forEachRect(function(o,m,l){var k=function(r){var q=r.originalEvent.shiftKey||r.originalEvent.metaKey;L.DomEvent.stopPropagation(r);SC.run(function(){e.selectCasesInRect(m,l,q)});return false}.bind(this),p=function(t){var r=e.getPath("dataConfiguration.legendAttributeDescription.attributeID");i=e.get("rectArray").getRect(m,l);if((i.count===0)||!this.get("showTips")){return}var s=SC.none(r)?c.getCaseCountString(a,i.count):e.getCategoryBreakdownString(i.cases,r),q=d.get("map").latLngToContainerPoint(i.rect[0]);d.get("infoTip").show({x:q.x,y:q.y,tipString:s})}.bind(this),j=function(q){d.get("infoTip").hide()}.bind(this);f.fillOpacity=o.count/b;var n=L.rectangle(o.rect,f).on("click",k).on("mouseover",p).on("mouseout",j);h.push(n)}.bind(this));this.set("grid",h)},show:function(){if(this.getPath("model.isVisible")){this.addGridToMap()}},hide:function(){if(this.getPath("model.isVisible")){this.removeGridFromMap()}},selectionDidChange:function(){var b=0,a=this.get("grid");if(!a||!this.getPath("model.isVisible")){return}this.get("model").forEachRect(function(g,d,c){var f=a[b],e=g.selected;f.setStyle({color:e?"black":"white",weight:e?2:1});if(e){f.bringToFront()}b++})}.observes("model.selection"),addGridToMap:function(){var b=this.get("map"),a=this.get("grid");if(!a){this.addGridLayer();a=this.get("grid")}a.forEach(function(c){c.addTo(b)})},removeGridFromMap:function(){var b=this.get("map"),a=this.get("grid");if(a){a.forEach(function(c){b.removeLayer(c)})}},visibilityHasChanged:function(){if(this.getPath("model.isVisible")){if(!this.get("grid")){this.addGridLayer()}this.addGridToMap()}else{if(this.get("grid")){this.removeGridFromMap()}}}.observes("model.isVisible"),gridRectArrayChanged:function(){this.removeGridFromMap();this.addGridLayer();this.visibilityHasChanged()}.observes("model.rectArray")});DG.MapGridModel=SC.Object.extend((function(){function b(f){this.rect=f;this.count=0;this.cases=[];this.selected=false}function a(){this.maxCount=0;this.rectangles=[[]];this.getRect=function(g,f){if(this.rectangles[g]&&!SC.none(this.rectangles[g][f])){return this.rectangles[g][f]}else{return null}};this.setRect=function(g,f,h){if(!this.rectangles[g]){this.rectangles[g]=[]}this.rectangles[g][f]=h};this.forEachRect=function(f){this.rectangles.forEach(function(h,g){h.forEach(function(j,i){if(j){f(j,g,i)}})})};this.addCaseToRect=function(g,f,h){var i=this.getRect(g,f);if(i){i.cases.push(h);i.count++;this.maxCount=Math.max(this.maxCount,i.count)}};this.deleteZeroRects=function(){this.rectangles.forEach(function(g,f){g.forEach(function(i,h){if(i.count===0){g[h]=undefined}})})}}var e,c,d=20;return{dataConfiguration:null,gridMultiplier:1,gridWidth:function(){return e*this.gridMultiplier}.property("gridMultiplier"),gridHeight:function(){return c*this.gridMultiplier}.property("gridMultiplier"),startWest:null,startSouth:null,rectArray:null,maxCount:function(){var f=this.get("rectArray");return f?f.maxCount:0}.property(),isVisible:false,forEachRect:function(g){var f=this.get("rectArray");if(f){f.forEachRect(g)}},initializeRectArray:function(){var k=this.getPath("dataConfiguration.cases"),j,h;var i=function(){var r=this.get("rectArray"),z=this.get("dataConfiguration").getLatLongBounds(),y=z.getCenter(),p=y.lng,q=y.lat,m=z.getWest(),x=z.getEast(),w=z.getSouth(),u=z.getNorth();if(m===x){m-=5;x+=5}if(u===w){u+=5;w-=5}e=Math.min((x-m)/d,(u-w)/d);c=e;var o=this.get("gridWidth"),t=Math.ceil((p-m)/o);h=p-o*t;var s=this.get("gridHeight"),v=Math.ceil((q-w)/s),l,n;j=q-s*v;for(n=0;n<2*t;n++){for(l=0;l<2*v;l++){r.setRect(n,l,new b([[j+(l+1)*s,h+n*o],[j+l*s,h+(n+1)*o]]))}}}.bind(this);var g=function(){var p=function(){this.get("rectArray").forEachRect(function(r){r.count=0});this.get("rectArray").maxCount=0}.bind(this);var n=this.get("gridWidth"),m=this.get("gridHeight"),l=this.getPath("dataConfiguration.xAttributeDescription.attributeID"),q=this.getPath("dataConfiguration.yAttributeDescription.attributeID"),o=this.get("rectArray");p();k.forEach(function(t){var s=t.getNumValue(l),v=t.getNumValue(q),r=Math.floor((s-h)/n),u=Math.floor((v-j)/m);o.addCaseToRect(r,u,t)})}.bind(this);var f=this.get("dataConfiguration").getLatLongBounds();this.beginPropertyChanges();this.set("rectArray",new a());if(k.get("length")>0&&f&&f.isValid()){i();g();this.get("rectArray").deleteZeroRects()}this.endPropertyChanges()},clear:function(){this.set("rectArray",new a())},_selectCasesInRect:function(h,g,m,k){var l=this.getPath("dataConfiguration.dataContext"),f=this.getPath("dataConfiguration.collectionClient"),j=this.get("rectArray").getRect(h,g),i={operation:"selectCases",collection:f,cases:j.cases,select:m,extend:k};l.applyChange(i)},selectCasesInRect:function(g,f,h){if(!h){this.forEachRect(function(i){i.selected=false})}this._selectCasesInRect(g,f,true,h)},deselectCasesInRect:function(g,f){this._selectCasesInRect(g,f,false,true)},deselectAll:function(){var g=this.get("dataConfiguration"),f=g.get("dataContext"),h={operation:"selectCases",collection:g.get("collectionClient"),cases:null,select:false};if(f){f.applyChange(h)}},updateSelection:function(){var f=this.getPath("dataConfiguration.collectionClient.casesController.selection");this.forEachRect(function(g){g.selected=g.cases.every(function(h){return f.containsObject(h)})});this.notifyPropertyChange("selection")},rectArrayMustChange:function(){if(this.getPath("dataConfiguration.hasLatLongAttributes")){this.initializeRectArray()}}.observes("gridMultiplier","dataConfiguration.hiddenCases"),getCategoryBreakdownString:function(g,i){var h=0,j={},f="";g.forEach(function(k){var l=k.getStrValue(i);if(!SC.empty(l)){h++;if(!j[l]){j[l]=0}j[l]++}});DG.ObjectMap.forEach(j,function(k,l){if(!SC.empty(f)){f+="\n"}f+=k+": "+l+" ("+(Math.round(1000*l/h)/10)+"%)"});return f},handleDataContextChange:function(g){var f=g&&g.operation;switch(f){case"createCase":case"createCases":case"deleteCases":case"createCollection":case"resetCollections":this.rectArrayMustChange();break;case"selectCases":this.updateSelection();break}},createStorage:function(){var f={};f.gridMultiplier=this.get("gridMultiplier");f.isVisible=this.get("isVisible");return f},restoreStorage:function(f){if(f){this.beginPropertyChanges();this.set("gridMultiplier",f.gridMultiplier?f.gridMultiplier:1);this.set("isVisible",f.isVisible);this.endPropertyChanges()}}}})());DG.MapConstants={kLatNames:["latitude","lat","latitud","breitengrad","緯度","عرض جغرافیایی"],kLongNames:["longitude","long","lng","lon","longitud","längengrad","経度","طول جغرافیایی"],kPolygonNames:["boundary","boundaries","polygon","polygons","grenze","境界","مرز"]};sc_require("components/graph_map_common/data_display_controller");DG.MapController=DG.DataDisplayController.extend((function(){return{mapModel:function(){return this.get("dataDisplayModel")}.property("dataDisplayModel"),mapView:function(){return this.get("contentView")}.property("contentView"),mapViewDidChange:function(){this.setPath("mapView.legendViewCreationCallback",this.setUpLegendView.bind(this));this.setPath("mapView.controller",this)}.observes("mapView"),init:function(){arguments.callee.base.apply(this,arguments);DG.currDocumentController().addObserver("contextsLength",this,this.handleDataContextChange);DG.currDocumentController().notificationManager.addObserver("mostRecentDataContextChanges",this,this.dataContextDidChange)},destroy:function(){var b=DG.currDocumentController(),a=b&&b.notificationManager;b&&b.removeObserver("contextsLength",this,this.handleDataContextChange);a&&a.removeObserver("mostRecentDataContextChanges",this,this.dataContextDidChange);arguments.callee.base.apply(this,arguments)},handleDataContextChange:function(){this.invokeLater(function(){SC.run(function(){this.get("mapModel").adaptToNewOrRemovedContexts();this.destroyInspectorButtons()}.bind(this))}.bind(this),100)},dataContextDidChange:function(b){var a=b.get("mostRecentDataContextChanges"),c=false;if(!a){return}a.forEach(function(d){switch(d.operation){case"updateAttributes":case"createAttributes":c=true;break}});if(c){this.handleDataContextChange()}},setUpLegendView:function(a){this.addAxisHandler(a);a.addObserver("labelNode",this,function(){this.addAxisHandler(a)}.bind(this))},createComponentStorage:function(){var a=arguments.callee.base.apply(this,arguments);a.mapModelStorage=this.get("mapModel").createStorage();return a},restoreComponentStorage:function(a,b){arguments.callee.base.apply(this,arguments);this.get("dataDisplayModel").restoreStorage(a)},plotOrLegendViewDidAcceptDrop:function(a,c,b){arguments.callee.base.apply(this,arguments)}.observes("*mapView.dragData"),showHideValuesPane:function(){var e=this,b=26,a=5,d=5,c=20;if(DG.InspectorPickerPane.close(this.kValuesPaneIconClass)){return}this.valuesPane=DG.InspectorPickerPane.create({buttonIconClass:this.kValuesPaneIconClass,classNames:"dg-inspector-picker".w(),layout:{width:200,height:260},contentView:SC.View.extend(SC.FlowedLayout,{layoutDirection:SC.LAYOUT_VERTICAL,isResizable:false,isClosable:false,defaultFlowSpacing:{left:a,bottom:d},canWrap:false,align:SC.ALIGN_TOP,childViews:"title".w(),title:DG.PickerTitleView.extend({layout:{height:b},flowSpacing:{left:0,bottom:d},title:"DG.Inspector.values",localize:true,iconURL:"../../../../static/dg/fr/cert/resources/images/icon-values.svg"}),init:function(){arguments.callee.base.apply(this,arguments);e.getPath("mapModel.mapLayerModels").forEach(function(h){var g=h.get("checkboxDescriptions");if(g.length>0){var f=SC.View.create(SC.FlowedLayout,{layoutDirection:SC.LAYOUT_VERTICAL,isResizable:false,isCloseable:false,defaultFlowSpacing:{left:a,bottom:d},canWrap:false,align:SC.ALIGN_TOP,childViews:"layerName".w(),layerName:SC.LabelView.extend({classNames:"dg-inspector-layer-title".w(),layout:{left:0,height:c},value:h.getPath("dataConfiguration.collectionClient.name")})});g.forEach(function(i){i.layout={left:20,height:c};i.localize=true;f.appendChild(SC.CheckboxView.create(i))}.bind(this));this.appendChild(f)}}.bind(this));e.getPath("dataDisplayModel.lastValueControls").forEach(function(f){this.appendChild(f)}.bind(this))}})});this.valuesPane.popup(this.get("inspectorButtons")[2],SC.PICKER_POINTER)},styleControls:function(){var a=this.getPath("mapModel.mapLayerModels");var c=[],b=function(){var e=SC.View.create(SC.FlowedLayout,{layoutDirection:SC.LAYOUT_HORIZONTAL,layout:{right:0},isResizable:false,isClosable:false,canWrap:false,align:SC.ALIGN_TOP});e.appendChild(SC.CheckboxView.create({layout:{height:25,width:50},title:"Base",value:this.getPath("mapModel.baseMapLayerIsVisible"),localize:false,valueDidChange:function(g){this.setPath("mapModel.baseMapLayerIsVisible",g.get("value"));var f=this.getPath("mapView.mapLayer");f.getPath("backgroundChanged").call(f)}.bind(this).observes("value")}));var d=[SC.Object.create({label:"Oceans",value:"Oceans",id:"dg-map-oceans-background-button"}),SC.Object.create({label:"Topo",value:"Topographic",id:"dg-map-topographic-background-button"}),SC.Object.create({label:"Streets",value:"Streets",id:"dg-map-streets-background-button"})];e.appendChild(SC.SegmentedView.create({controlSize:SC.SMALL_CONTROL_SIZE,layout:{width:170,height:18,top:5,right:5},items:d,value:this.getPath("mapView.model.baseMapLayerName"),itemTitleKey:"label",itemValueKey:"value",itemLayerIdKey:"id",action:"changeBaseMap",target:this}));return e}.bind(this);c.push(b());a.forEach(function(l){var i=null,s=this,o=l.get("dataConfiguration"),n=o.get("legendAttributeDescription");if(!n){return}var B=n.getPath("attribute.categoryMap"),j=!n.get("isNull")?DG.ColorUtilities.calcAttributeColor(n):null,M=20,I=function(N,O){i=i||Math.random();DG.UndoHistory.execute(DG.Command.create({name:"data.style.categoryColorChange",undoString:"DG.Undo.graph.changePointColor",redoString:"DG.Redo.graph.changePointColor",log:"Changed categorical point color",executeNotification:{action:"notify",resource:"component",values:{operation:"change point color",type:"DG.MapView"}},execute:function(){this.reduceKey=this.name+O+i;this._beforeStorage={color:B[O],alpha:l.getPath("transparency")};B[O]=N.toHexString();l.setPath("transparency",N.getAlpha());l.propertyDidChange("pointColor");if(n.get("attribute")){n.get("attribute").propertyDidChange("categoryMap")}},undo:function(){B[O]=this._beforeStorage.color;l.setPath("transparency",this._beforeStorage.alpha);l.propertyDidChange("pointColor")},reduce:function(P){if(P.reduceKey===this.reduceKey){this._beforeStorage=P._beforeStorage;return this}}}))},u=function(N,Q,P,O){return DG.Command.create({name:"data.style."+N,undoString:"DG.Undo.graph."+N,redoString:"DG.Redo.graph."+N,log:"Changed point color",executeNotification:{action:"notify",resource:"component",values:{operation:"change "+N,type:"DG.MapView"}},execute:function(){SC.run(function(){this.reduceKey=this.name+i;this._beforeStorage={color:l.getPath(Q),alpha:l.getPath(P)};l.setPath(Q,O.toHexString());l.setPath(P,O.getAlpha())}.bind(this))},undo:function(){l.setPath(Q,this._beforeStorage.color);l.setPath(P,this._beforeStorage.alpha)},reduce:function(R){if(R.reduceKey===this.reduceKey){this._beforeStorage=R._beforeStorage;return this}}})},e=function(O,N,Q,P){return DG.Command.create({name:"data.style."+O,undoString:"DG.Undo.graph."+O,redoString:"DG.Redo.graph."+O,log:"Changed "+N+" attribute color",executeNotification:{action:"notify",resource:"component",values:{operation:"change attribute color",type:"DG.MapView"}},execute:function(){this.reduceKey=this.name+i;this._beforeStorage={color:B[N+"-attribute-color"],alpha:l.getPath(Q)};B[N+"-attribute-color"]=P.toHexString();l.setPath(Q,P.getAlpha());l.propertyDidChange("pointColor");if(n.get("attribute")){n.get("attribute").propertyDidChange("categoryMap")}},undo:function(){B["attribute-color"]=this._beforeStorage.color;l.setPath(Q,this._beforeStorage.alpha)},reduce:function(R){if(R.reduceKey===this.reduceKey){this._beforeStorage=R._beforeStorage;return this}}})},y=function(N){i=i||Math.random();DG.UndoHistory.execute(e("changeAttributeColor","low","transparency",N))},F=function(N){i=i||Math.random();DG.UndoHistory.execute(e("changeAttributeColor","high","transparency",N))},C=function(){return s.stylesPane.layer()},z,t,x,d,D,E;var q=SC.View.create(SC.FlowedLayout,{layoutDirection:SC.LAYOUT_VERTICAL,isResizable:false,isClosable:false,canWrap:false,align:SC.ALIGN_CENTER});q.appendChild(SC.CheckboxView.create({layout:{right:0,height:20},title:o.getPath("collectionClient.name"),value:l.get("isVisible"),localize:false,valueDidChange:function(N){l.set("isVisible",N.get("value"))}.bind(this).observes("value")}));c.push(q);var v=SC.View.create(SC.FlowedLayout,{classNames:"dg-inspector-map-color-controls".w(),layoutDirection:SC.LAYOUT_VERTICAL,isResizable:false,isClosable:false,canWrap:false,align:SC.ALIGN_LEFT});q.appendChild(v);if(l.get("hasLatLongAttributes")){var H=function(){i=null},k=function(N){i=i||Math.random();DG.UndoHistory.execute(u("changePointColor","pointColor","transparency",N))},r=function(){i=null},f=function(N){i=i||Math.random();DG.UndoHistory.execute(u("changeStrokeColor","strokeColor","strokeTransparency",N))},m=function(){i=null},G=[DG.PickerControlView.create({layout:{height:M},label:"DG.Inspector.pointSize",controlView:SC.SliderView.create({layout:{left:80,right:25},classNames:"dg-map-pointSize-slider".w(),controlSize:SC.SMALL_CONTROL_SIZE,value:l.getPath("pointSizeMultiplier"),minimum:0,maximum:3,step:0,valueChanged:function(){var N=this;DG.UndoHistory.execute(DG.Command.create({name:"data.style.pointSizeChanged",undoString:"DG.Undo.graph.changePointSize",redoString:"DG.Redo.graph.changePointSize",log:"Changed point size",executeNotification:{action:"notify",resource:"component",values:{operation:"change point size",type:"DG.MapView"}},execute:function(){this._beforeStorage=l.getPath("pointSizeMultiplier");l.setPath("pointSizeMultiplier",N.get("value"))},undo:function(){l.setPath("pointSizeMultiplier",this._beforeStorage)},reduce:function(O){if(O.name===this.name){this._beforeStorage=O._beforeStorage;return this}}}))}.observes("value")})})];if(n.get("isNull")){var K=tinycolor(l.getPath("pointColor")).setAlpha(l.getPath("transparency"));G.push(DG.PickerControlView.create({layout:{height:2*M},label:"DG.Inspector.color",controlView:DG.PickerColorControl.create({layout:{left:80,right:0},classNames:"dg-graph-point-color".w(),initialColor:K,setColorFunc:k,closedFunc:r,appendToLayerFunc:C})}))}else{if(n.get("isNumeric")){if(B&&SC.none(B["attribute-color"])){var p=DG.ColorUtilities.calcAttributeColor(n);B["attribute-color"]=p.colorString||p}j=B&&B["attribute-color"];z=SC.View.create(SC.FlowedLayout,{layoutDirection:SC.LAYOUT_HORIZONTAL,layout:{width:120,right:20},isResizable:false,isClosable:false,canWrap:false,align:SC.ALIGN_TOP});t=DG.ColorUtilities.getAttributeColorSpectrumEndsFromColorMap(B,j);x=tinycolor(t.low.colorString).setAlpha(l.getPath("transparency"));d=tinycolor(t.high.colorString).setAlpha(l.getPath("transparency"));z.appendChild(DG.PickerColorControl.create({layout:{width:60},classNames:"dg-graph-point-color".w(),initialColor:x,setColorFunc:y,closedFunc:r,appendToLayerFunc:C}));z.appendChild(DG.PickerColorControl.create({layout:{width:60},classNames:"dg-graph-point-color".w(),initialColor:d,setColorFunc:F,closedFunc:r,appendToLayerFunc:C}));G.push(DG.PickerControlView.create({layout:{height:2*M},label:"DG.Inspector.legendColor",controlView:z}));G.push(SC.CheckboxView.create({layout:{height:25},title:"DG.Inspector.lockLegendQuantiles",toolTip:"DG.Inspector.lockLegendQuantilesTooltip",value:o.get("legendQuantilesAreLocked"),classNames:"dg-graph-lockLegendQuantiles-check".w(),localize:true,valueDidChange:function(){var N=!o.get("legendQuantilesAreLocked"),O="Set quantilesAreLocked to "+N;DG.UndoHistory.execute(DG.Command.create({name:"legend.quantilesAreLockedChange",undoString:N?"DG.Undo.legend.lockQuantiles":"DG.Undo.legend.unlockQuantiles",redoString:N?"DG.Redo.legend.lockQuantiles":"DG.Redo.legend.unlockQuantiles",log:O,execute:function(){o.toggleProperty("legendQuantilesAreLocked")}.bind(this),undo:function(){o.toggleProperty("legendQuantilesAreLocked")}.bind(this)}))}.bind(this).observes("value")}))}}G.push(DG.PickerControlView.create({layout:{height:2*M},label:"DG.Inspector.stroke",controlView:DG.PickerColorControl.create({layout:{left:80,right:0},classNames:"dg-graph-stroke-color".w(),initialColor:tinycolor(l.get("strokeColor")).setAlpha(l.get("strokeTransparency")),setColorFunc:f,closedFunc:m,appendToLayerFunc:C})}));G.push(SC.CheckboxView.create({layout:{height:25},title:"DG.Inspector.strokeSameAsFill",value:l.get("strokeSameAsFill"),classNames:"dg-graph-strokeSameAsFill-check".w(),localize:true,valueDidChange:function(){var N=!l.get("strokeSameAsFill"),O="Made stroke color "+(N?"same as fill":"independent of fill");DG.UndoHistory.execute(DG.Command.create({name:"map.strokeSameAsFillChange",undoString:N?"DG.Undo.graph.makeStrokeSameAsFill":"DG.Undo.graph.makeStrokeIndependent",redoString:N?"DG.Redo.graph.makeStrokeSameAsFill":"DG.Redo.graph.makeStrokeIndependent",log:O,executeNotification:{action:"notify",resource:"component",values:{operation:"toggle stroke same as fill",type:"DG.MapView"}},execute:function(){l.toggleProperty("strokeSameAsFill")}.bind(this),undo:function(){l.toggleProperty("strokeSameAsFill")}.bind(this)}))}.bind(this).observes("value")}));if(n.get("isCategorical")){D=SC.View.create(SC.FlowedLayout,{layoutDirection:SC.LAYOUT_VERTICAL,isResizable:false,isClosable:false,defaultFlowSpacing:{bottom:5},canWrap:false,align:SC.ALIGN_TOP});E=SC.ScrollView.create({layout:{height:100},hasHorizontalScroller:false,contentView:D});var A=n.get("attribute");A.forEachCategory(function(N){var P=DG.ColorUtilities.calcCaseColor(N,n),O=B[N]?B[N]:P.colorString||P;O=tinycolor(O.colorString||O).setAlpha(l.getPath("transparency"));D.appendChild(DG.PickerControlView.create({layout:{height:2*M},label:N,controlView:DG.PickerColorControl.create({layout:{width:80,right:0},classNames:"dg-graph-point-color".w(),initialColor:O,colorKey:N,setColorFunc:I,closedFunc:H,appendToLayerFunc:C})}))}.bind(this));G.push(E)}G.forEach(function(N){v.appendChild(N)})}else{if(l.get("hasPolygonAttribute")){var g=[],h=function(N){l.setPath("areaColor",N.toHexString());l.setPath("areaTransparency",N.getAlpha())}.bind(this),w=function(N){l.setPath("areaStrokeColor",N.toHexString());l.setPath("areaStrokeTransparency",N.getAlpha())}.bind(this);if(n.get("isNull")){g.push(DG.PickerControlView.create({layout:{height:2*M},label:"DG.Inspector.color",controlView:DG.PickerColorControl.create({layout:{left:80,right:0},classNames:"dg-map-fill-color".w(),initialColor:tinycolor(l.getPath("areaColor")).setAlpha(l.getPath("areaTransparency")),setColorFunc:h,appendToLayerFunc:C})}))}else{if(n.get("isNumeric")){z=SC.View.create(SC.FlowedLayout,{layoutDirection:SC.LAYOUT_HORIZONTAL,layout:{right:0},isResizable:false,isClosable:false,canWrap:false,align:SC.ALIGN_TOP});t=DG.ColorUtilities.getAttributeColorSpectrumEndsFromColorMap(B,j);x=tinycolor(t.low.colorString).setAlpha(l.getPath("transparency"));d=tinycolor(t.high.colorString).setAlpha(l.getPath("transparency"));z.appendChild(DG.PickerColorControl.create({layout:{width:60},classNames:"dg-graph-point-color".w(),initialColor:x,setColorFunc:y,appendToLayerFunc:C}));z.appendChild(DG.PickerColorControl.create({layout:{width:60},classNames:"dg-graph-point-color".w(),initialColor:d,setColorFunc:F,appendToLayerFunc:C}));g.push(DG.PickerControlView.create({layout:{height:2*M},label:"DG.Inspector.legendColor",controlView:z}));g.push(SC.CheckboxView.create({layout:{height:25},title:"DG.Inspector.lockLegendQuantiles",toolTip:"DG.Inspector.lockLegendQuantilesTooltip",value:o.get("legendQuantilesAreLocked"),classNames:"dg-graph-lockLegendQuantiles-check".w(),localize:true,valueDidChange:function(){var N=!o.get("legendQuantilesAreLocked"),O="Set quantilesAreLocked to "+N;DG.UndoHistory.execute(DG.Command.create({name:"legend.quintilesAreLockedChange",undoString:N?"DG.Undo.legend.lockQuantiles":"DG.Undo.legend.unlockQuantiles",redoString:N?"DG.Redo.legend.lockQuantiles":"DG.Redo.legend.unlockQuantiles",log:O,execute:function(){o.toggleProperty("legendQuantilesAreLocked")}.bind(this),undo:function(){o.toggleProperty("legendQuantilesAreLocked")}.bind(this)}))}.bind(this).observes("value")}))}else{if(n.get("isCategorical")){D=SC.View.create(SC.FlowedLayout,{layoutDirection:SC.LAYOUT_VERTICAL,isResizable:false,isClosable:false,defaultFlowSpacing:{bottom:5},canWrap:false,align:SC.ALIGN_TOP});E=SC.ScrollView.create({layout:{height:100},hasHorizontalScroller:false,contentView:D});var J=n.get("attribute");J.forEachCategory(function(N){var P=DG.ColorUtilities.calcCaseColor(N,n),O=B[N]?B[N]:P.colorString||P;O=tinycolor(O.colorString||O).setAlpha(l.get("transparency"));D.appendChild(DG.PickerControlView.create({layout:{height:2*M},label:N,controlView:DG.PickerColorControl.create({layout:{width:80,right:0},classNames:"dg-graph-point-color".w(),initialColor:O,colorKey:N,setColorFunc:I,appendToLayerFunc:C})}))}.bind(this));g.push(E)}}}g.push(DG.PickerControlView.create({layout:{height:2*M},label:"DG.Inspector.stroke",controlView:DG.PickerColorControl.create({layout:{left:80,right:0},classNames:"map-areaStroke-color".w(),initialColor:tinycolor(l.getPath("areaStrokeColor")).setAlpha(l.getPath("areaStrokeTransparency")),setColorFunc:w,appendToLayerFunc:C})}));g.push(SC.CheckboxView.create({layout:{height:25},title:"DG.Inspector.strokeSameAsFill",value:l.get("strokeSameAsFill"),classNames:"dg-graph-strokeSameAsFill-check".w(),localize:true,valueDidChange:function(){var N=!l.get("strokeSameAsFill"),O="Made stroke color "+(N?"same as fill":"independent of fill");DG.UndoHistory.execute(DG.Command.create({name:"map.strokeSameAsFillChange",undoString:N?"DG.Undo.graph.makeStrokeSameAsFill":"DG.Undo.graph.makeStrokeIndependent",redoString:N?"DG.Redo.graph.makeStrokeSameAsFill":"DG.Redo.graph.makeStrokeIndependent",log:O,executeNotification:{action:"notify",resource:"component",values:{operation:"toggle stroke same as fill",type:"DG.MapView"}},execute:function(){l.toggleProperty("strokeSameAsFill")}.bind(this),undo:function(){l.toggleProperty("strokeSameAsFill")}.bind(this)}))}.bind(this).observes("value")}));g.forEach(function(N){v.appendChild(N)})}}}.bind(this));return c}.property(),rescaleFunction:function(){this.get("mapView").fitBounds()},changeBaseMap:function(a){this.getPath("mapView").changeBaseMap(a.get("value"))}}}()));sc_require("components/graph_map_common/plot_data_configuration");DG.MapDataConfiguration=DG.PlotDataConfiguration.extend({collectionClient:function(){return null}.property(),allCases:function(){return[]}.property(),hasLatLongAttributes:false,hasPolygonAttribute:false});sc_require("components/graph_map_common/data_layer_model");DG.MapLayerModel=DG.DataLayerModel.extend({isVisible:true,init:function(){arguments.callee.base.apply(this,arguments)},somethingIsSelectable:function(){return false}.property(),gridIsVisible:function(){return false}.property(),hasValidMapAttributes:function(){return false},handleLegendAttrChange:function(){var a=this.getPath("dataConfiguration.legendAttributeDescription");if(a){a.set("offsetMinProportion",DG.PlotUtilities.kMapColorRangeOffset);a.invalidateCaches()}}.observes("dataConfiguration.legendAttributeDescription.attribute"),handleLegendCategoryMapChange:function(){this.notifyPropertyChange("colorMap")}.observes("dataConfiguration.legendAttributeDescription.attribute.categoryMap"),handleOneDataContextChange:function(a,b){arguments.callee.base.apply(this,arguments);var c=this.get("dataConfiguration"),d=b&&b.operation;if(!c){return}if(d==="deleteCases"){this.get("dataConfiguration").synchHiddenCases()}if(d==="selectCases"){this.notifyPropertyChange("selection")}this.get("dataConfiguration").invalidateCaches(null,b);b.indices=this.buildIndices(b);this.dataRangeDidChange(this,"revision",this,b.indices);this.set("lastChange",b)},handleUpdateAttributes:function(c){if(this.isAffectedByChange(c)){this.notifyPropertyChange("attributeUpdated");var b=this.getPath("dataConfiguration.legendAttributeDescription.attribute"),d=b&&b.get("id");if(!SC.none(d)){var a=this.get("legend");if(a){a.handleUpdateAttribute(d)}}}},removeAttribute:function(b){var a=this.getPath("dataConfiguration."+b);if(a){a.removeAllAttributes();this.notifyPropertyChange("attributeRemoved")}},selectCase:function(b,d){var a=this.get("selection"),c={operation:"selectCases",collection:this.get("collectionClient"),cases:[b],select:true,extend:d};if(a.get("length")!==0){if(a.contains(b)){if(d){c.select=false}else{return}}else{c.select=true}}this.get("dataContext").applyChange(c)},canSupportConfigurations:function(){return false}.property(),isAffectedByChange:function(f){var c,e,b,g,a;var d=function(j){var h=this.getPath("dataConfiguration.placedAttributeIDs"),m=j&&j.length,k,l;for(k=0;k<m;++k){l=j[k];if(h.indexOf(l)>=0){return true}}return false}.bind(this);switch(f.operation){case"createCases":case"deleteCases":return true;case"updateCases":c=f.attributeIDs;if(!c){return true}return d(c);case"dependentCases":g=f.changes;a=g?g.length:0;for(e=0;e<a;++e){b=g[e];if(b){c=b.attributeIDs;if(c&&d(c)){return true}}}return false;case"updateAttributes":c=f.attrPropsArray.map(function(h){return h.id});return d(c)}return true},checkboxDescriptions:function(){return[]}.property(),lastValueControls:function(){return[]}.property(),_observedDataConfiguration:null,createStorage:function(){var b={},d=this.get("dataContext"),c=this.get("dataConfiguration"),a=c&&c.get("hiddenCases");b._links_={};if(a){b._links_.hiddenCases=a.filter(function(e){return !!e}).map(function(e){return e.toLink()})}if(d){b._links_.context=d.toLink()}c.addToStorageForDimension(b,"legend");b.isVisible=this.get("isVisible");return b},restoreStorage:function(a){var e=DG.ArchiveUtils.getLinkID(a,"context");if(!SC.none(e)){this.beginPropertyChanges();var d=DG.currDocumentController().getContextByID(e);this.set("dataContext",d);this.endPropertyChanges()}arguments.callee.base.apply(this,arguments);var c=this.instantiateAttributeRefFromStorage(a,"legendColl","legendAttr"),b=this.get("dataConfiguration");b.setAttributeAndCollectionClient("legendAttributeDescription",c,a.legendRole,a.legendAttributeType);if(!SC.none(a.isVisible)){this.set("isVisible",a.isVisible)}}});DG.MapModel=SC.Object.extend((function(){var a=[45.4408,12.3155];return{center:null,zoom:null,newCenter:null,newZoom:null,baseMapLayerName:null,baseMapLayerIsVisible:true,mapLayerModels:null,centerAndZoomBeingRestored:false,_addLayersForCollection:function(m,k){var f,o,d,j,c,i,n=false,e=(k&&k.getAttributeNames())||[],g=e.map(function(p){return p.toLowerCase()}),l=function(q,r,p){c=r.create({initializer:q});i=DG.LegendModel.create({dataConfiguration:c,attributeDescription:c.get("legendAttributeDescription")});i.addObserver("attributeDescription.attribute",this,this.legendAttributeDidChange);i.addObserver("attributeDescription.attributeStats.attributeType",this,this.legendAttributeDidChange);j=p.create({dataConfiguration:c,legend:i});j.addObserver("somethingIsSelectable",this,this.somethingIsSelectableDidChange);j.addObserver("gridIsVisible",this,this.gridIsVisibleDidChange);j.addObserver("attributeRemoved",this,this.removeMapLayerModel);j.addObserver("attributeUpdated",this,this.handleAttributeUpdated);this.mapLayerModels.push(j);j.invalidate()}.bind(this),b=function(){return this.get("mapLayerModels").some(function(p){var v=p.get("dataConfiguration"),w=v.get("dataContext"),t=v.get("latAttributeID"),q=v.get("longAttributeID"),s=v.get("polygonAttributeID");if(m===w){var u=f&&k.getAttributeByName(f).get("id"),x=o&&k.getAttributeByName(o).get("id"),r=d&&k.getAttributeByName(d).get("id");return(t===u&&q===x)||s===r}else{return false}})}.bind(this);function h(p){return e.find(function(r,q){return p.find(function(s){return(s===g[q])})})}f=h(DG.MapConstants.kLatNames);o=h(DG.MapConstants.kLongNames);d=h(DG.MapConstants.kPolygonNames);if(!d){((k&&k.get("attrs"))||[]).some(function(p){if(p.get("type")==="boundary"){d=p.get("name");return true}else{return false}})}if(!b()){if(f&&o){n=true;l({context:m,collection:k,latName:f,longName:o},DG.MapPointDataConfiguration,DG.MapPointLayerModel)}if(d){n=true;l({context:m,collection:k,polygonName:d},DG.MapPolygonDataConfiguration,DG.MapPolygonLayerModel)}}return n},_processDocumentContexts:function(){var b=false;DG.currDocumentController().get("contexts").forEach(function(c){c.get("collections").forEach(function(d){if(this._addLayersForCollection(c,d)){b=true}}.bind(this))}.bind(this));return b},_processPossibleLegend:function(){var d=this.get("context"),e=this.get("legendAttributeName");if(d&&e){var c=d.getAttributeByName(e),b=d.getCollectionForAttribute(c);this.changeAttributeForLegend(d,{attribute:c,collection:b})}delete this.context;delete this.legendAttributeName},init:function(){arguments.callee.base.apply(this,arguments);this.mapLayerModels=[];var b=this._processDocumentContexts();this._processPossibleLegend();this.set("center",a);this.set("zoom",1);if(!b){if(navigator.geolocation&&navigator.geolocation.getCurrentPosition){navigator.geolocation.getCurrentPosition(function(d){var c=d.coords;this.set("newCenter",[c.latitude,c.longitude]);this.set("newZoom",8)}.bind(this))}}this.set("baseMapLayerName","Topographic")},destroy:function(){this.get("mapLayerModels").forEach(function(b){this.destroyMapLayer(b)}.bind(this));this.set("mapLayerModels",null);arguments.callee.base.apply(this,arguments)},destroyMapLayer:function(c){c.removeObserver("somethingIsSelectable",this,this.somethingIsSelectableDidChange);c.removeObserver("gridIsVisible",this,this.gridIsVisibleDidChange);c.removeObserver("attributeRemoved",this,this.removeMapLayerModel);c.removeObserver("attributeUpdated",this,this.handleAttributeUpdated);var b=c.get("legend");b&&b.removeObserver("attributeDescription.attribute",this,this.legendAttributeDidChange);b&&b.removeObserver("attributeDescription.attributeStats.attributeType",this,this.legendAttributeDidChange);c.destroy()},adaptToNewOrRemovedContexts:function(){var e=DG.currDocumentController().get("contexts"),d=[],c=false,b=this.get("mapLayerModels");b.forEach(function(g){var f=g.getPath("dataConfiguration.dataContext");if(f&&e.indexOf(f)<0){d.push(g)}});d.forEach(function(g){this.destroyMapLayer(g);var f=b.indexOf(g);b.splice(f,1)}.bind(this));c=this._processDocumentContexts();if(d.length>0||c){this.notifyPropertyChange("mapLayerModelsChange")}},legendAttributeDidChange:function(){this.notifyPropertyChange("legendAttributeChange")},handleDroppedContext:function(b){},removeMapLayerModel:function(d){var b=this.get("mapLayerModels"),c=b.indexOf(d);b.splice(c,1);this.destroyMapLayer(d);this.notifyPropertyChange("mapLayerModelsChange")},handleAttributeUpdated:function(b){if(!b.hasValidMapAttributes()){this.removeMapLayerModel(b)}},createRemoveAttributeMenuItem:function(d){var c=d.getPath("model.attributeDescription.attribute")||DG.Analysis.kNullAttribute,e=(c===DG.Analysis.kNullAttribute)?"":c.get("name"),b=("DG.DataDisplayMenu.removeAttribute_legend").loc(e);return{title:b,target:this,itemAction:this.removeLegendAttribute,isEnabled:(c!==DG.Analysis.kNullAttribute),log:"attributeRemoved: { attribute: %@, axis: %@ }".fmt(e,"legend"),args:[d.getPath("model.dataConfiguration")]}},createChangeAttributeTypeMenuItem:function(e){var d=e.getPath("model.attributeDescription"),c=d&&d.get("attribute"),g=c&&(c!==-1)?c.get("name"):"",f=d&&d.get("isNumeric"),b=(f?"DG.DataDisplayMenu.treatAsCategorical":"DG.DataDisplayMenu.treatAsNumeric").loc();return{title:b,target:this,itemAction:this.changeAttributeType,isEnabled:(c!==DG.Analysis.kNullAttribute),log:"plotAxisAttributeChangeType: { axis: legend, attribute: %@, numeric: %@ }".fmt(g,!f),args:[e.getPath("model.dataConfiguration"),!f]}},removeLegendAttribute:function(b){b.setAttributeAndCollectionClient("legendAttributeDescription",null)},changeAttributeType:function(c,b){c.setAttributeType("legendAttributeDescription",b)},changeAttributeForLegend:function(b,c){this.get("mapLayerModels").forEach(function(d){if(b===d.get("dataContext")){d.changeAttributeForLegend(b,c)}})},someLayerReturnsTrue:function(b){var c=this.get("mapLayerModels").some(function(e){var d=e.get(b);return d});return c},somethingIsSelectable:function(){return this.someLayerReturnsTrue("somethingIsSelectable")}.property(),somethingIsSelectableDidChange:function(){this.notifyPropertyChange("somethingIsSelectable")},gridMultiplier:1,gridMultiplerDidChange:function(){this.get("mapLayerModels").forEach(function(b){b.setPath("gridModel.gridMultiplier",this.get("gridMultiplier"))}.bind(this))}.observes("gridMultiplier"),gridIsVisible:function(){return this.someLayerReturnsTrue("gridIsVisible")}.property(),gridIsVisibleDidChange:function(){this.notifyPropertyChange("gridIsVisible")},wantsInspector:function(){return this.someLayerReturnsTrue("wantsInspector")},hasLatLongAttributes:function(){return this.someLayerReturnsTrue("hasLatLongAttributes")}.property(),hasPolygonAttribute:function(){return this.someLayerReturnsTrue("hasPolygonAttribute")}.property("dataConfiguration"),canRescale:function(){return this.someLayerReturnsTrue("canRescale")}.property("hasNumericAxis","plot"),canSupportConfigurations:function(){return false}.property(),selectAll:function(b){this.get("mapLayerModels").forEach(function(c){c.selectAll(b)})},isAffectedByChange:function(g){var d,f,c,h,b;var e=function(k){var j=this.getPath("dataConfiguration.placedAttributeIDs"),n=k&&k.length,l,m;for(l=0;l<n;++l){m=k[l];if(j.indexOf(m)>=0){return true}}return false}.bind(this);switch(g.operation){case"createCases":case"deleteCases":return true;case"updateCases":d=g.attributeIDs;if(!d){return true}return e(d);case"dependentCases":h=g.changes;b=h?h.length:0;for(f=0;f<b;++f){c=h[f];if(c){d=c.attributeIDs;if(d&&e(d)){return true}}}return false}return true},_observedDataConfiguration:null,firstDataConfiguration:function(){var b=this.get("mapLayerModels");if(b.length>0){return b[0].get("dataConfiguration")}else{return null}}.property(),lastValueControls:function(){var b=[];this.get("mapLayerModels").forEach(function(c){b=b.concat(c.get("lastValueControls"))});return b}.property(),createHideShowSelectionMenuItems:function(){var f=function(){var l={numSelected:0,numUnSelected:0,numHidden:0,selectionData:[]};this.get("mapLayerModels").forEach(function(o){var n=o.get("dataConfiguration");if(!l.selectionData.find(function(p){return p.dataConfig===n})){var m={dataConfig:n,cases:n.get("cases").toArray(),selected:n.get("selection").toArray(),hidden:n.get("hiddenCases").toArray()};l.numSelected+=m.selected.length;l.numUnSelected+=(m.cases.length-m.selected.length);l.numHidden+=m.hidden.length;l.selectionData.push(m)}});return l}.bind(this);var b=f(),g=b.numSelected>0,d=b.numUnSelected>0,h=b.numHidden>0,c=b.numSelected>1?"Plural":"Sing",i=b.numUnSelected>1?"Plural":"Sing";function k(){DG.UndoHistory.execute(DG.Command.create({name:"graph.display.hideSelectedCases",undoString:"DG.Undo.hideSelectedCases",redoString:"DG.Redo.hideSelectedCases",log:"Hide %@ selected cases".fmt(b.numSelected.length),executeNotification:{action:"notify",resource:"component",values:{operation:"hide selected cases",type:"DG.MapView"}},execute:function(){this._undoData=b;b.selectionData.forEach(function(l){l.dataConfig.hideCases(l.selected)})},undo:function(){this._undoData.selectionData.forEach(function(l){l.dataConfig.showCases(l.selected)})}}))}function j(){DG.UndoHistory.execute(DG.Command.create({name:"graph.display.hideUnselectedCases",undoString:"DG.Undo.hideUnselectedCases",redoString:"DG.Redo.hideUnselectedCases",log:"Hide %@ unselected cases".fmt(b.numCases-b.numSelected),executeNotification:{action:"notify",resource:"component",values:{operation:"hide unselected cases",type:"DG.MapView"}},execute:function(){this._undoData=b;b.selectionData.forEach(function(m){var l=DG.ArrayUtils.subtract(m.cases,m.selected,function(n){return n.get("id")});m.dataConfig.hideCases(l)})},undo:function(){this._undoData.selectionData.forEach(function(m){var l=DG.ArrayUtils.subtract(m.cases,m.selected,function(n){return n.get("id")});m.dataConfig.showCases(l)})}}))}function e(){DG.UndoHistory.execute(DG.Command.create({name:"graph.display.showAllCases",undoString:"DG.Undo.showAllCases",redoString:"DG.Redo.showAllCases",log:"Show all cases",executeNotification:{action:"notify",resource:"component",values:{operation:"show all cases",type:"DG.MapView"}},execute:function(){this._undoData=b;b.selectionData.forEach(function(l){l.dataConfig.showAllCases()})},undo:function(){this._undoData.selectionData.forEach(function(l){l.dataConfig.hideCases(l.hidden)})}}))}return[{title:("DG.DataDisplayMenu.hideSelected"+c),isEnabled:g,target:this,action:k},{title:("DG.DataDisplayMenu.hideUnselected"+i),isEnabled:d,target:this,action:j},{title:"DG.DataDisplayMenu.showAll",isEnabled:h,target:this,action:e}]},createStorage:function(){var b={};b.center=this.get("center");b.zoom=this.get("zoom");b.baseMapLayerName=this.get("baseMapLayerName");b.gridMultiplier=this.get("gridMultiplier");b.layerModels=this.get("mapLayerModels").map(function(c){return c.createStorage()});return b},restoreStorage:function(b){if(b.mapModelStorage){this.set("newCenter",b.mapModelStorage.center);this.set("newZoom",b.mapModelStorage.zoom);this.set("center",b.mapModelStorage.center);this.set("zoom",b.mapModelStorage.zoom);this.set("baseMapLayerName",b.mapModelStorage.baseMapLayerName);if(!SC.none(b.mapModelStorage.gridMultiplier)){this.set("gridMultiplier",b.mapModelStorage.gridMultiplier)}this.set("centerAndZoomBeingRestored",true);this.get("mapLayerModels").forEach(function(e,d){if(b.mapModelStorage.layerModels&&d<b.mapModelStorage.layerModels.length){var c=SC.isArray(b.mapModelStorage.layerModels)?b.mapModelStorage.layerModels[d]:b;e.restoreStorage(c)}})}}}}()));DG.MapView=SC.View.extend(DG.GraphDropTarget,{displayProperties:["model.dataConfiguration.attributeAssignment","model.dataConfiguration.legendQuantilesAreLocked"],kPadding:[10,10],model:null,orientation:DG.GraphTypes.EOrientation.kNone,plottedAttribute:function(){var a=this.get("legendViews");return a.length===1?a[0].get("plottedAttribute"):null}.property(),mapLayer:null,mapBinding:".mapLayer.map",mapPolygonLayers:null,mapPointView:null,mapGridLayer:null,legendViews:null,legendViewCreationCallback:null,gridControl:null,marqueeTool:null,selection:null,selectionBinding:"*model.casesController.selection",_ignoreMapDisplayChanges:false,_fitBoundsInProgress:false,_mapDisplayChangeInProgress:false,_mapDisplayChange:null,paper:function(){return this.getPath("mapPointView.paper")}.property(),layerManager:function(){return this.getPath("mapPointView.layerManager")}.property(),dataConfiguration:function(){return this.getPath("model.firstDataConfiguration")}.property(),init:function(){arguments.callee.base.apply(this,arguments);var a=DG.BaseMapView.create({model:this.get("model")});this.set("mapLayer",a);this.appendChild(a);this.legendViews=[];this.gridControl=SC.SliderView.create({controlSize:SC.SMALL_CONTROL_SIZE,layout:{width:40,height:16,top:16,right:58},toolTip:"DG.MapView.gridControlHint".loc(),classNames:["dg-map-grid-slider"],minimum:0.1,maximum:2,step:0,value:this.getPath("model.gridMultiplier"),persistedValue:this.getPath("model.gridMultiplier"),previousPersistedValue:this.getPath("model.gridMultiplier"),isVisible:false,mouseUp:function(b){arguments.callee.base.apply(this,arguments);if(this.get("value")!==this.get("persistedValue")){this.set("previousPersistedValue",this.get("persistedValue"));this.set("persistedValue",this.get("value"));DG.logUser("changeGridMultiplier: %@",this.get("value"))}}});this.appendChild(this.gridControl);this.marqueeTool=SC.ImageButtonView.create({buttonBehavior:SC.PUSH_BEHAVIOR,layout:{right:10,top:9,width:32,height:32},toolTip:"DG.MapView.marqueeHint".loc(),image:"dg-map-marquee",action:"setMarqueeMode",isVisible:false});this.appendChild(this.marqueeTool);this._ignoreMapDisplayChanges=true;a._setIdle();DG.globalsController.addObserver("globalValueChanges",this,"globalValueDidChange")},destroy:function(){this._ignoreMapDisplayChanges=true;this.model.destroy();DG.globalsController.removeObserver("globalValueChanges",this,"globalValueDidChange");this.get("legendViews").forEach(function(a){a.removeObserver("dragData",this,this.legendDidAcceptDrop)});arguments.callee.base.apply(this,arguments)},setMarqueeMode:function(){var b=this.get("mapPointView"),a=this.get("mapGridLayer");if(b&&b.get("isVisible")){b.set("isInMarqueeMode",true)}else{if(a&&a.get("isVisible")){a.set("isInMarqueeMode",true)}}DG.logUser("marqueeToolSelect")},marqueeModeChanged:function(){var a=this.getPath("mapGridLayer.isInMarqueeMode"),b=(this.getPath("mapPointView.isInMarqueeMode")||a)?"dg-map-marquee-selected":"dg-map-marquee";this.setPath("marqueeTool.image",b)}.observes("mapPointView.isInMarqueeMode","mapGridLayer.isInMarqueeMode"),changeBaseMap:function(b){var a=this.getPath("model.baseMapLayerName");DG.UndoHistory.execute(DG.Command.create({name:"map.changeBaseMap",undoString:"DG.Undo.map.changeBaseMap",redoString:"DG.Redo.map.changeBaseMap",log:"Map base layer changed: %@".fmt(b),_componentId:this.getPath("controller.model.id"),_controller:function(){return DG.currDocumentController().componentControllersMap[this._componentId]},executeNotification:{action:"notify",resource:"component",values:{operation:"change base map",type:"DG.MapView"}},execute:function(){this._controller().setPath("view.contentView.model.baseMapLayerName",b)},undo:function(){this._controller().setPath("view.contentView.model.baseMapLayerName",a);this._controller().setPath("view.contentView.backgroundControl.value",[a])},redo:function(){this._controller().setPath("view.contentView.model.baseMapLayerName",b);this._controller().setPath("view.contentView.backgroundControl.value",[b])}}))},changeGridSize:function(){var a=this.gridControl.get("value");this.setPath("model.gridMultiplier",a)}.observes("gridControl.value"),changePersistedGridSize:function(){var b=this.gridControl.get("persistedValue"),a=this.gridControl.get("previousPersistedValue");DG.UndoHistory.execute(DG.Command.create({name:"map.changeGridSize",undoString:"DG.Undo.map.changeGridSize",redoString:"DG.Redo.map.changeGridSize",log:"Map grid size changed: {from: %@, to: %@}".fmt(a,b),_componentId:this.getPath("controller.model.id"),_controller:function(){return DG.currDocumentController().componentControllersMap[this._componentId]},executeNotification:{action:"notify",resource:"component",values:{operation:"change grid size",type:"DG.MapView"}},execute:function(){},undo:function(){this._controller().setPath("view.contentView.model.gridMultiplier",a);this._controller().setPath("view.contentView.gridControl.value",a)},redo:function(){this._controller().setPath("view.contentView.model.gridMultiplier",b);this._controller().setPath("view.contentView.gridControl.value",b)}}))}.observes("gridControl.persistedValue"),addPointLayers:function(){if(!this.get("mapPointView")){var a=DG.MapPointView.create({mapLayer:this.get("mapLayer"),model:this.get("model")});this.set("mapPointView",a);this.appendChild(a)}else{this.get("mapPointView").addMapPointLayers()}var b=this.get("legendViews").map(function(d){return d.get("model")}),c=this.getPath("mapPointView.mapPointLayers").filter(function(d){return b.indexOf(d.getPath("model.legend"))<0});c.forEach(function(d){var e=DG.LegendView.create({model:d.getPath("model.legend")});this.observeLegendView(e);this.appendChild(e);this.legendViewCreationCallback(e);this.get("legendViews").push(e)}.bind(this));this.adjustLayout(this.renderContext(this.get("tagName")));this.updateMarqueeToolVisibility();this.updateGridControlVisibility()},numberOfLayerModelsChanged:function(){function c(e){e.filter(function(f){return a.indexOf(f.get("model"))<0}).forEach(function(f){e.splice(e.indexOf(f),1);f.destroy()})}var a=this.getPath("model.mapLayerModels"),b=this.get("mapPolygonLayers"),d=this.getPath("mapPointView.mapPointLayers");if(a.length>b.length+d.length){this.addPointLayers();this.addPolygonLayers();this.displayDidChange();this.fitBounds()}else{c(b);c(d);this.displayDidChange()}this.updateMarqueeToolVisibility()}.observes("model.mapLayerModelsChange"),updateMarqueeToolVisibility:function(){this.setPath("marqueeTool.isVisible",this.getPath("model.somethingIsSelectable"))},somethingIsSelectableDidChange:function(){this.updateMarqueeToolVisibility()}.observes("model.somethingIsSelectable"),updateGridControlVisibility:function(){this.setPath("gridControl.isVisible",this.getPath("model.gridIsVisible"))},gridIsVisibleDidChange:function(){this.updateGridControlVisibility()}.observes("model.gridIsVisible"),addPolygonLayers:function(){var c=false;if(!this.get("mapPolygonLayers")){this.set("mapPolygonLayers",[])}var a=this.get("legendViews"),b=this.get("mapPolygonLayers"),d=b.map(function(e){return e.get("model")});this.getPath("model.mapLayerModels").forEach(function(g){if(g.constructor===DG.MapPolygonLayerModel&&d.indexOf(g)<0){var f=DG.MapPolygonLayer.create({mapSource:this,model:g});b.push(f);f.addFeatures();var e=DG.LegendView.create({model:g.get("legend")});this.observeLegendView(e);this.appendChild(e);a.push(e);this.legendViewCreationCallback(e);c=true}}.bind(this));if(!this.getPath("model.centerAndZoomBeingRestored")&&c){this.fitBounds()}},fitBounds:function(){var c=this.get("mapPolygonLayers"),b=this.get("mapPointView"),a=b?b.getBounds():null;if(c){c.forEach(function(d){if(d.getPath("model.isVisible")){var e=d.getBounds();if(!SC.none(e)){if(!a){a=e}else{a.extend(e)}}}})}if(a&&a.isValid()){this._fitBoundsInProgress=true;this.getPath("mapLayer.map").fitBounds(a,{padding:this.kPadding,animate:true});this.get("mapLayer")._setIdle()}},observeLegendView:function(a){a.addObserver("dragData",this,this.legendDidAcceptDrop)},legendDidAcceptDrop:function(a,b){this.set("dragData",a.get("dragData"))},viewDidResize:function(){arguments.callee.base.apply(this,arguments);this.adjustLayout(this.renderContext(this.get("tagName")))},adjustLayout:function(d,e){var b=this.get("mapLayer"),a=this.get("mapPointView"),c=0;if(this._isRenderLayoutInProgress||!a){return}this._isRenderLayoutInProgress=true;this.get("legendViews").forEach(function(f){var g=f.get("desiredExtent");f.set("layout",{bottom:c,height:g});c+=g}.bind(this));a.adjust("bottom",c);b.adjust("bottom",c);this._isRenderLayoutInProgress=false;this.invokeLast(function(){this.getPath("mapLayer.map").invalidateSize({pan:false})}.bind(this))}.observes("model.legendAttributeChange"),_isRenderLayoutInProgress:false,createVisualization:function(){var a=this.get("mapPolygonLayers");if(a){a.forEach(function(b){b.createVisualization()})}},globalValueDidChange:function(){var a=this.get("mapPolygonLayers");if(a){a.forEach(function(b){b.refreshComputedLegendColors()})}},handleMapLayerDisplayChange:function(){var a=this.get("mapPointView"),d=this.getPath("mapLayer.lastEventType");if(a){if(d==="dragstart"){a.set("isVisible",false)}else{if(d==="moveend"){a.doDraw();a.set("isVisible",true)}}a.updateConnectingLines()}var e=this.getPath("mapLayer.map"),c=e.getCenter(),b=e.getZoom();this._mapDisplayChangeInProgress=true;this._mapDisplayChange={center:c,zoom:b};this.setPath("mapLayer.lastEventType",null)}.observes("mapLayer.displayChangeCount"),handleClick:function(){if(!this.justSelected){this.get("model").selectAll(false)}}.observes("mapLayer.clickCount"),didBecomeSelected:function(){this.justSelected=true;this.invokeLater(function(){this.justSelected=false},500)}.observes("parentView.parentView.isSelected"),handleIdle:function(){var d=this.get("model"),h=d.get("center"),f=d.get("zoom");if(this._ignoreMapDisplayChanges){this._ignoreMapDisplayChanges=false;this._mapDisplayChange=null;this._mapDisplayChangeInProgress=false;return}if(this._mapDisplayChange){var b=this._mapDisplayChange.center,c=this._mapDisplayChange.zoom,e=!b.equals(h),a=c!==f;if(this._mapDisplayChangeInProgress&&(e||a)){var g="change";if(this._fitBoundsInProgress||(e&&a)){g="fitBounds";this._fitBoundsInProgress=false}else{if(e){g="pan"}else{g="zoom"}}DG.UndoHistory.execute(DG.Command.create({name:"map."+g,undoString:"DG.Undo.map."+g,redoString:"DG.Redo.map."+g,causedChange:this.getPath("mapLayer.lastEventType")!=="moveend",log:"mapEvent: %@ at {center: %@, zoom: %@}".fmt(g,b,c),_componentId:this.getPath("controller.model.id"),_controller:function(){return DG.currDocumentController().componentControllersMap[this._componentId]},executeNotification:{action:"notify",resource:"component",values:{operation:"change map coordinates",type:"DG.MapView"}},execute:function(){var i=this._controller().getPath("view.contentView");i.setPath("model.center",b);i.setPath("model.zoom",c)},undo:function(){var j=this._controller(),i=j.getPath("view.contentView"),k=i.getPath("mapLayer.map");i._ignoreMapDisplayChanges=true;k.setView(h,f);i.setPath("model.center",h);i.setPath("model.zoom",f)},redo:function(){var j=this._controller(),i=j.getPath("view.contentView"),k=i.getPath("mapLayer.map");i._ignoreMapDisplayChanges=true;k.setView(b,c);i.setPath("model.center",b);i.setPath("model.zoom",c)}}))}this._mapDisplayChangeInProgress=false}}.observes("mapLayer.idleCount"),dragStarted:function(){if(this.get("dataConfiguration")){DG.GraphDropTarget.dragStarted.apply(this,arguments);if(!this.getPath("model.hasLatLongAttributes")){this.setPath("mapPointView.isVisible",true)}}},dragEntered:function(){if(this.get("dataConfiguration")){DG.GraphDropTarget.dragEntered.apply(this,arguments)}},dragExited:function(){if(this.get("dataConfiguration")){DG.GraphDropTarget.dragExited.apply(this,arguments)}},dragEnded:function(){if(this.get("dataConfiguration")){DG.GraphDropTarget.dragEnded.apply(this,arguments)}},selectionDidChange:function(){var a=this.get("connectingLineAdorn");if(a){a.updateSelection()}}.observes("selection"),didReachInitialPosition:function(){this.fitBounds()}});sc_require("components/graph/adornments/connecting_line_adornment");DG.MapConnectingLineAdornment=DG.ConnectingLineAdornment.extend({mapSource:null,map:function(){return this.getPath("mapSource.mapLayer.map")}.property(),mapDidChange:function(){this.propertyDidChange("map")}.observes("mapSource.mapLayer.map"),init:function(){arguments.callee.base.apply(this,arguments);if(this.getPath("model.isVisible")){this.updateToModel()}},updateLine:function(a){var c;var b=function(d,e){if(!c){c=this.get("map")}return c.latLngToContainerPoint([e,d])}.bind(this);this.doUpdateLine(a,b)}});sc_require("components/map/map_data_configuration");DG.MapPointDataConfiguration=DG.MapDataConfiguration.extend({init:function(){var c={caption:DG.AttributePlacementDescription.create(),x:DG.AttributePlacementDescription.create(),y:DG.AttributePlacementDescription.create(),legend:DG.AttributePlacementDescription.create()},b,a,e,g,f;arguments.callee.base.apply(this,arguments);var d=function(){var h=function(m,l,o){var p=c[m],n;DG.assert(p);if(l){p.set("collectionClient",o);p.set("attribute",l);switch(m){case"x":case"y":n=DG.Analysis.EAttributeType.eNumeric;break;case"caption":n=DG.Analysis.EAttributeType.eCategorical;break}if(n){p.setPath("attributeStats.attributeType",n)}}else{p.set("collectionClient",null);p.removeAllAttributes()}p.addObserver("collectionClient",this,m+"CollectionDidChange");p.addObserver("collection",this,"collectionDidChange")}.bind(this);var i=this.initializer.context,k=this.initializer.collection,j=i&&i.getCollectionByID(k.get("id"));if(k&&j){a=k.getAttributeNames()[0];e=a&&k.getAttributeByName(a);g=this.initializer.latName&&k.getAttributeByName(this.initializer.latName);f=this.initializer.longName&&k.getAttributeByName(this.initializer.longName);h("caption",e,j);h("x",f,j);h("y",g,j);h("legend",null,j)}}.bind(this);d();this.attributesByPlace=[];for(b=0;b<DG.GraphTypes.EPlace.eNumPlaces;b++){this.attributesByPlace[b]=[]}this.attributesByPlace[DG.GraphTypes.EPlace.eCaption][0]=c.caption;this.attributesByPlace[DG.GraphTypes.EPlace.eX][0]=c.x;this.attributesByPlace[DG.GraphTypes.EPlace.eY][0]=c.y;this.attributesByPlace[DG.GraphTypes.EPlace.eLegend][0]=c.legend;this.set("dataContext",this.initializer.context);delete this.initializer},collectionClient:function(){return this.getPath("xAttributeDescription.collectionClient")}.property(),allCases:function(){var a=this.get("collectionClient");return a?a.getPath("casesController.arrangedObjects"):null}.property(),longAttributeDescription:function(){return this.get("xAttributeDescription")}.property("xAttributeDescription"),latAttributeDescription:function(){return this.get("yAttributeDescription")}.property("yAttributeDescription"),latAttributeID:function(){return this.getPath("yAttributeDescription.attributeID")}.property(),latAttributeIDDidChange:function(){this.notifyPropertyChange("latAttributeID")}.observes("*yAttributeDescription.attributeID"),longAttributeID:function(){return this.getPath("xAttributeDescription.attributeID")}.property(),longAttributeIDDidChange:function(){this.notifyPropertyChange("longAttributeID")}.observes("*xAttributeDescription.attributeID"),xVarIDBinding:".longAttributeID",yVarIDBinding:".latAttributeID",hasLatLongAttributes:function(){return !SC.none(this.get("latAttributeID"))&&!SC.none(this.get("longAttributeID"))}.property("latAttributeID","longAttributeID"),captionAttributeDescription:function(a,b){return this.attributeDescriptionForPlace(a,b,DG.GraphTypes.EPlace.eCaption)}.property(),captionCollectionDidChange:function(){this.notifyPropertyChange("captionCollectionClient")},captionCollectionClient:function(){return this.getPath("captionAttributeDescription.collectionClient")}.property(),captionCollectionClientDidChange:function(){this.notifyPropertyChange("captionCollectionClient")}.observes("*captionAttributeDescription.collectionClient"),captionAttributeID:function(){return this.getPath("captionAttributeDescription.attributeID")}.property(),captionAttributeIDDidChange:function(){this.notifyPropertyChange("captionAttributeID")}.observes("*captionAttributeDescription.attributeID"),getLatLongBounds:function(){var d=function(){var m=this.getPath("xAttributeDescription.attribute.id"),i=[];this.get("cases").forEach(function(o){var p=o.getNumValue(m);if(isFinite(p)&&p>=-360&&p<=360){i.push(p)}});i.sort(function(p,o){return p-o});var j=i.length,n=i[0],h=i[j-1],l;while(h-n>180){n=Math.min(n,i[0]);h=Math.max(h,i[j-1]);l=i[Math.floor(j/2)];if(h-l>l-n){h-=360;if(h<i[j-2]){n=Math.min(n,h);h=i[j-2];i.pop()}}else{n+=360;if(n>i[1]){h=Math.max(h,n);n=i[1];i.shift()}}j=i.length;if(h<n){var k=h;h=n;n=k}}return{min:n,max:h}}.bind(this),e=function(h){return DG.isFinite(h.min)&&DG.isFinite(h.max)};var b=this.getPath("yAttributeDescription.attributeStats.minMax"),c=this.getPath("xAttributeDescription.attributeStats.minMax");if(c.max-c.min>180){c=d()}var g=[b.min,c.min],f=[b.max,c.max],a=(e(b)&&e(c))?L.latLngBounds([g,f]):null;return a}});sc_require("components/graph_map_common/plot_layer");DG.MapPointLayer=DG.PlotLayer.extend({autoDestroyProperties:[],model:null,mapSource:null,dataConfiguration:null,map:function(){return this.getPath("mapSource.mapLayer.map")}.property(),isInMarqueeMode:false,gridLayer:null,connectingLinesAdorn:null,init:function(){arguments.callee.base.apply(this,arguments);this.setPath("dataTip.showOnlyLegendData",true);this.addGridLayer();this.lineVisibilityChanged()},destroy:function(){var a=this.get("plottedElements");arguments.callee.base.apply(this,arguments);a.forEach(function(b){b.hide()})},readyToDraw:function(){return !SC.none(this.getPath("dataConfiguration.yAttributeDescription.attributeID"))&&!SC.none(this.getPath("dataConfiguration.xAttributeDescription.attributeID"))},createRenderContext:function(){var e=this.get("model");if(!e){return}var g=this.get("dataConfiguration"),b=g.get("legendAttributeDescription"),d=b&&b.get("attributeID"),c=b.get("attributeType"),f=this.getStrokeParams(),a=(b&&b.get("isNumeric"))?g.get("legendQuantiles"):[];return{casesAdded:true,casesRemoved:true,updatedColors:true,layer:this.getPath("layerManager."+DG.LayerNames.kPoints),map:this.get("map"),westBound:this.get("map").getBounds().getWest(),eastBound:this.get("map").getBounds().getEast(),latVarID:e.getPath("dataConfiguration.latAttributeID"),longVarID:e.getPath("dataConfiguration.longAttributeID"),legendDesc:b,legendVarID:d,legendVarType:c,updatedPositions:true,pointsShouldBeVisible:this.getPath("model.pointsShouldBeVisible"),isVisible:this.getPath("model.isVisible")&&this.getPath("model.pointsShouldBeVisible"),pointColor:e.get("pointColor")||DG.PlotUtilities.kDefaultPointColor,transparency:e.get("transparency")||DG.PlotUtilities.kDefaultPointOpacity,strokeTransparency:f.strokeSameAsFill?(e.get("transparency")||DG.PlotUtilities.kDefaultPointOpacity):f.strokeTransparency,calcCaseColorString:function(j){if(!this.legendVarID){return this.pointColor}DG.assert(j);var h=(this.legendVarType===DG.Analysis.EAttributeType.eDateTime)?j.getForcedNumericValue(this.legendVarID):j.getValue(this.legendVarID),i=DG.ColorUtilities.calcCaseColor(h,this.legendDesc,this.pointColor,a);return i.colorString||i},calcStrokeColorString:function(h){if(f.strokeSameAsFill){return this.calcCaseColorString(h)}else{return f.strokeColor}}}},dataRangeDidChange:function(a,g,d,e){if(!this.readyToDraw()){return}var c=this,i=this.get("plottedElements").length,b=this.getPath("model.cases"),h=this.createRenderContext(),f=(SC.typeOf(e)===SC.T_NUMBER?[e]:e);f=f||[];f.forEach(function(j){if(j>=i){c.callCreateElement(b.at(j),j,c._createAnimationOn)}c.setCircleCoordinate(h,b.at(j),j)});arguments.callee.base.apply(this,arguments)},caseOrderDidChange:function(){if(!SC.none(this.getPath("model.dataConfiguration.latAttributeID")&&!SC.none(this.getPath("model.dataConfiguration.longVarID")))){this._mustMoveElementsToNewCoordinates=true}},setCircleCoordinate:function(f,b,i,m,c){DG.assert(f&&f.map&&f.latVarID&&f.longVarID);DG.assert(b);DG.assert(DG.MathUtilities.isInIntegerRange(i,0,this.get("plottedElements").length));var a=this.get("plottedElements")[i],g=b.getNumValue(f.latVarID),h=b.getNumValue(f.longVarID);if(h<f.westBound){h+=Math.ceil((f.westBound-h)/360)*360}else{if(h>f.eastBound){h-=Math.ceil((h-f.eastBound)/360)*360}}var e=!(Number.isNaN(g)||Number.isNaN(h)),j=e?f.map.latLngToContainerPoint([g,h]):null,l=j&&j.x,k=j&&j.y,n=!DG.isFinite(l)||!DG.isFinite(k);if(!n){var d={cx:l,cy:k,r:this.radiusForCircleElement(a),fill:f.calcCaseColorString(b),stroke:f.calcStrokeColorString(b),"fill-opacity":f.transparency,"stroke-opacity":f.strokeTransparency};this.updatePlottedElement(a,d,m,c);if(f.isVisible){this.assignElementAttributes(a,i,false,true);f.layer.push(a);a.show();a.attr({opacity:1})}else{a.hide()}}a["case"]=b},assignElementAttributes:function(b,d,h,i){function e(){this.hoverAnimation=null}var c=this,a=false,f=1,g=null;b.addClass(DG.PlotUtilities.kColoredDotClassName).attr({cursor:"pointer"}).hover(function(j){if(!a&&SC.none(g)&&!c.get("isInMarqueeMode")){g="";if(this.hoverAnimation){this.stop(this.hoverAnimation)}this.hoverAnimation=Raphael.animation({opacity:f,transform:DG.PlotUtilities.kDataHoverTransform},DG.PlotUtilities.kDataTipShowTime,"<>",e);this.animate(this.hoverAnimation);c.showDataTip(this,d)}},function(j){if(!a){if(this.hoverAnimation){this.stop(this.hoverAnimation)}this.hoverAnimation=Raphael.animation({transform:g},DG.PlotUtilities.kHighlightHideTime,"<>",e);this.animate(this.hoverAnimation);g=null;c.hideDataTip()}}).mousedown(function(j){SC.run(function(){c.get("model").selectCase(this["case"],j.shiftKey||j.metaKey)}.bind(this))});b.index=d;if(h&&i){DG.PlotUtilities.doCreateCircleAnimation(b)}else{if(!i){b.attr({opacity:0});b.hide()}}return b},createElement:function(c,d,b){var a=this.get("paper").circle(-100,-100,this._pointRadius);a["case"]=c;a.node.setAttribute("shape-rendering","geometricPrecision");return a},doDraw:function(){if(this.readyToDraw()){this.drawData();this.updateSelection();this.updateConnectingLine()}}.observes("plotDisplayDidChange","model.pointColor","model.strokeColor","model.pointSizeMultiplier","model.transparency","model.strokeTransparency","model.pointsShouldBeVisible","model.strokeSameAsFill","model.colorMap","model.selection","model.dataConfiguration.legendQuantilesAreLocked"),updateSelection:function(){if(SC.none(this.get("map"))){return}arguments.callee.base.apply(this,arguments)},getBounds:function(){return this.get("dataConfiguration").getLatLongBounds()},isVisibleChanged:function(){var c=this.getPath("model.isVisible"),b=this.get("gridLayer"),a=this.get("connectingLinesAdorn");if(c){b&&b.show();a&&a.show()}else{b&&b.hide();a&&a.hide()}}.observes("model.isVisible"),updateConnectingLine:function(){var a=this.get("connectingLinesAdorn");if(a){a.invalidateModel();a.updateToModel(false)}},pointsDidChange:function(){if(this.getPath("model.isVisible")){var a=this.getPath("gridLayer.model");if(a){a.rectArrayMustChange()}this.updateConnectingLine()}}.observes("pointsDidChange","model.dataConfiguration.hiddenCases","model.lastChange"),casesDidReorder:function(){if(this.getPath("model.isVisible")){var b=this.getPath("model.cases"),c={},a=this.get("plottedElements");b.forEach(function(d,e){c[d.get("id")]=e});a.sort(function(e,d){return c[e["case"].get("id")]-c[d["case"].get("id")]});this.updateConnectingLine()}}.observes("model.casesDidReorder"),addGridLayer:function(){if(this.get("gridLayer")){return}var a=this.getPath("model.gridModel");a.initializeRectArray();this.set("gridLayer",DG.MapGridLayer.create({mapSource:this.get("mapSource"),model:a,showTips:true}))},lineVisibilityChanged:function(){var b=this.getPath("model.connectingLinesModel"),c=b.get("isVisible"),a=this.get("connectingLinesAdorn");if(b&&c&&!a){a=DG.MapConnectingLineAdornment.create({model:b,paperSource:this,mapSource:this.get("mapSource"),layerName:DG.LayerNames.kConnectingLines,unselectedLineWidth:1,selectedLineWidth:3,parentView:this.get("mapSource")});this.set("connectingLinesAdorn",a)}this.invokeLast(function(){if(a){a.updateVisibility()}}.bind(this))}.observes(".model.connectingLinesModel.isVisible")});sc_require("components/map/map_layer_model");DG.MapPointLayerModel=DG.MapLayerModel.extend({pointsShouldBeVisible:true,caseValueAnimator:null,latVarID:function(){return this.getPath("dataConfiguration.latAttributeID")}.property(),latVarIDDidChange:function(){this.notifyPropertyChange("latVarID")}.observes("*dataConfiguration.latAttributeID"),longVarID:function(){return this.getPath("dataConfiguration.longAttributeID")}.property(),longVarIDDidChange:function(){this.notifyPropertyChange("longVarID")}.observes("*dataConfiguration.longAttributeID"),xVarID:function(){return this.get("longVarID")}.property("longVarID"),yVarID:function(){return this.get("latVarID")}.property("latVarID"),gridModel:null,connectingLinesModel:null,init:function(){arguments.callee.base.apply(this,arguments);this.gridModel=DG.MapGridModel.create({dataConfiguration:this.get("dataConfiguration")});this.connectingLinesModel=DG.ConnectingLineModel.create({plotModel:this,isVisible:false})},handleOneDataContextChange:function(b,c){arguments.callee.base.apply(this,arguments);var a=this.get("gridModel");if(a){a.handleDataContextChange(c)}if(c.operation==="moveCases"){this.notifyPropertyChange("casesDidReorder")}},wantsInspector:function(){return true},hasLatLongAttributes:true,canRescale:true,hasValidMapAttributes:function(){var b=this.get("dataConfiguration"),a=["Lat","Long"];return a.every(function(f){var e=f.toLowerCase(),c=b.getPath(e+"AttributeDescription.attribute.name"),d=DG.MapConstants["k"+f+"Names"];return d.indexOf(c.toLowerCase())>=0})},animateSelectionBackToStart:function(a,b){if(SC.none(this.caseValueAnimator)){this.caseValueAnimator=DG.CaseValueAnimator.create()}else{this.caseValueAnimator.endAnimation()}this.caseValueAnimator.set("dataContext",this.get("dataContext"));this.caseValueAnimator.set("cases",DG.copy(this.get("selection")));this.caseValueAnimator.set("attributeIDs",a);this.caseValueAnimator.set("deltas",b);this.caseValueAnimator.animate()},checkboxDescriptions:function(){var b=this,a=[];if(this.getPath("dataConfiguration.hasLatLongAttributes")){a=a.concat([{title:"DG.Inspector.mapGrid",value:b.getPath("gridModel.isVisible"),classNames:"dg-map-grid-check".w(),valueDidChange:function(){b.toggleGrid()}.observes("value")},{title:"DG.Inspector.mapPoints",value:b.get("pointsShouldBeVisible"),classNames:"dg-map-points-check".w(),valueDidChange:function(){b.togglePoints()}.observes("value")},{title:"DG.Inspector.mapLines",value:b.getPath("connectingLinesModel.isVisible"),classNames:"dg-map-lines-check".w(),valueDidChange:function(){b.toggleLines()}.observes("value")}])}return a}.property(),togglePoints:function(){var a=this;DG.UndoHistory.execute(DG.Command.create({name:"map.togglePoints",_firstTime:true,execute:function(){var b=a.get("pointsShouldBeVisible");if(b!==false){b=true}a.set("pointsShouldBeVisible",!b);this.log="mapAction: {mapAction: %@}".fmt(a.get("pointsShouldBeVisible")?"showPoints":"hidePoints");if(this._firstTime){this._firstTime=false;this.set("name",!b?"map.showPoints":"map.hidePoints");this.set("undoString",!b?"DG.Undo.map.showPoints":"DG.Undo.map.hidePoints");this.set("redoString",!b?"DG.Redo.map.showPoints":"DG.Redo.map.hidePoints")}},undo:function(){this.execute()}}))},toggleGrid:function(){var a=this;DG.UndoHistory.execute(DG.Command.create({name:"map.toggleGrid",_firstTime:true,execute:function(){var b=a.getPath("gridModel.isVisible");a.setPath("gridModel.isVisible",!b);this.log="mapAction: {mapAction: %@}".fmt(a.getPath("gridModel.isVisible")?"showGrid":"hideGrid");if(this._firstTime){this._firstTime=false;this.set("name",!b?"map.showGrid":"map.hideGrid");this.set("undoString",!b?"DG.Undo.map.showGrid":"DG.Undo.map.hideGrid");this.set("redoString",!b?"DG.Redo.map.showGrid":"DG.Redo.map.hideGrid")}},undo:function(){this.execute()}}))},toggleLines:function(){var a=this;DG.UndoHistory.execute(DG.Command.create({name:"map.toggleLines",_firstTime:true,execute:function(){var b=a.getPath("connectingLinesModel.isVisible");if(b!==false){b=true}a.setPath("connectingLinesModel.isVisible",!b);this.log="mapAction: {mapAction: %@}".fmt(a.getPath("connectingLinesModel.isVisible")?"showLines":"hideLines");if(this._firstTime){this._firstTime=false;this.set("name",!b?"map.showLines":"map.hideLines");this.set("undoString",!b?"DG.Undo.map.showLines":"DG.Undo.map.hideLines");this.set("redoString",!b?"DG.Redo.map.showLines":"DG.Redo.map.hideLines")}},undo:function(){this.execute()}}))},somethingIsSelectable:function(){return this.get("isVisible")&&(this.get("pointsShouldBeVisible")||this.getPath("gridModel.isVisible")||this.getPath("connectingLinesModel.isVisible"))}.property(),somethingIsSelectableDidChange:function(){this.notifyPropertyChange("somethingIsSelectable")}.observes("isVisible","pointsShouldBeVisible","gridModel.isVisible","connectingLinesModel.isVisible"),gridIsVisible:function(){return this.get("isVisible")&&this.getPath("gridModel.isVisible")}.property(),gridIsVisibleDidChange:function(){this.notifyPropertyChange("gridIsVisible")}.observes("isVisible","pointsShouldBeVisible","gridModel.isVisible","connectingLinesModel.isVisible"),createStorage:function(){var c=arguments.callee.base.apply(this,arguments),d=this.get("dataConfiguration"),e=this.get("pointsShouldBeVisible"),a=this.get("gridModel"),b=this.get("connectingLinesModel");d.addToStorageForDimension(c,"legend");c.pointColor=this.get("pointColor");c.strokeColor=this.get("strokeColor");c.pointSizeMultiplier=this.get("pointSizeMultiplier");c.transparency=this.get("transparency");c.strokeTransparency=this.get("strokeTransparency");c.strokeSameAsFill=this.get("strokeSameAsFill");if(e!==null){c.pointsShouldBeVisible=e}c.linesShouldBeVisible=this.get("linesShouldBeVisible");if(a){c.grid=a.createStorage()}if(b){c.connectingLines=b.createStorage()}return c},restoreStorage:function(b){arguments.callee.base.apply(this,arguments);var d=b.mapModelStorage||b,a=this.get("gridModel"),c=this.get("connectingLinesModel");if(!SC.none(d.pointsShouldBeVisible)){this.set("pointsShouldBeVisible",d.pointsShouldBeVisible)}if(!SC.none(d.linesShouldBeVisible)){this.set("linesShouldBeVisible",d.linesShouldBeVisible)}if(a){a.restoreStorage(d.grid)}if(c){c.restoreStorage(d.connectingLines)}}});sc_require("views/raphael_base");DG.MapPointView=DG.RaphaelBaseView.extend({autoDestroyProperties:[],displayProperties:["model.dataConfiguration.attributeAssignment","model.dataConfiguration.legendAttributeDescription.attributeStats.attributeType","model.dataConfiguration.legendQuantilesAreLocked"],classNames:["dg-map-layer"],classNameBindings:["isInMarqueeMode:dg-marquee-mode"],model:null,mapPointLayers:null,mapLayer:null,isInMarqueeMode:false,marqueeContext:null,marqueeModeDidChange:function(){this.get("mapPointLayers").forEach(function(a){a.set("isInMarqueeMode",this.get("isInMarqueeMode"))}.bind(this))}.observes("isInMarqueeMode"),initLayerManager:function(){arguments.callee.base.apply(this,arguments);if(!this._layerManager){return}var a=DG.LayerNames;this.get("layerManager").addNamedLayer(a.kBackground).addNamedLayer(a.kConnectingLines).addNamedLayer(a.kPoints).addNamedLayer(a.kSelectedPoints).addNamedLayer(a.kAdornments).addNamedLayer(a.kDataTip)},getBounds:function(){var a,b=this.get("mapPointLayers");if(b){b.forEach(function(c){if(c.getPath("model.isVisible")){var d=c.getBounds();if(!SC.none(d)){if(!a){a=d}else{a.extend(d)}}}})}return a},mouseDown:function(a){DG.ViewUtilities.componentViewForView(this).select();if(!this.get("isInMarqueeMode")){return false}this.marqueeContext={};this.marqueeContext.startPt=DG.ViewUtilities.windowToViewCoordinates({x:a.clientX-5,y:a.clientY-5},this);this.marqueeContext.marquee=this._paper.rect(this.marqueeContext.startPt.x,this.marqueeContext.startPt.y,0,0).attr({fill:DG.PlotUtilities.kMarqueeColor,stroke:DG.RenderingUtilities.kTransparent});this.getPath("layerManager."+DG.LayerNames.kAdornments).push(this.marqueeContext.marquee);DG.logUser("marqueeDrag: start");this.marqueeContext.lastRect={x:0,y:0,width:0,height:0};this.get("mapPointLayers").forEach(function(c){c.preparePointSelection();var d=c.getPath("model.dataContext"),b=c.getPath("model.collectionClient");d.applyChange({operation:"selectCases",collection:b,cases:null,select:false})});return true},mouseMoved:function(a){if(!this.get("marqueeContext")){return false}var c=[],d=DG.ViewUtilities.windowToViewCoordinates({x:a.clientX-5,y:a.clientY-5},this),g=Math.min(this.marqueeContext.startPt.x,d.x),f=Math.min(this.marqueeContext.startPt.y,d.y),e=Math.abs(this.marqueeContext.startPt.x-d.x),h=Math.abs(this.marqueeContext.startPt.y-d.y),i={x:g,y:f,width:e,height:h},b=this.marqueeContext.lastRect;this.marqueeContext.marquee.attr(i);this.marqueeContext.lastRect=i;this.selectPointsInRect(i,c,b);return true},selectPointsInRect:function(b,c,a){c=c||[];this.get("mapPointLayers").forEach(function(i){var j=i.getPath("model.dataContext"),h=i.getPath("model.collectionClient");if(SC.none(j)){return}var e=i.getCasesForDelta(b,a),d=i.getCasesForDelta(a,b),f={operation:"selectCases",collection:h,cases:c.concat(e),select:true,extend:true},g={operation:"selectCases",collection:h,cases:c.concat(d),select:false,extend:true};if(f.cases.length!==0){j.applyChange(f)}if(g.cases.length!==0){j.applyChange(g)}})},mouseUp:function(a){if(!this.get("marqueeContext")){return false}this.get("layerManager").removeElement(this.marqueeContext.marquee,true);this.marqueeContext=null;this.set("isInMarqueeMode",false);DG.logUser("marqueeDrag: end");this.get("mapPointLayers").forEach(function(b){b.cleanUpPointSelection()});return true},init:function(){var a;var c=function(){SC.run(function(){a=this.get("isVisible");if(a){this.set("isVisible",false)}}.bind(this))}.bind(this),b=function(){SC.run(function(){if(a){this.set("isVisible",true)}}.bind(this))}.bind(this);arguments.callee.base.apply(this,arguments);this.mapPointLayers=[];this.addMapPointLayers();this.getPath("mapLayer.map").on("zoomstart",c).on("zoomend",b)},addMapPointLayers:function(){var b=this.get("mapPointLayers"),a=b.map(function(c){return c.get("model")});this.getPath("model.mapLayerModels").forEach(function(f,d){var c=f.get("dataConfiguration");if(c.get("hasLatLongAttributes")&&a.indexOf(f)<0){var e=DG.MapPointLayer.create({paperSource:this,model:f,mapSource:this,dataConfiguration:c,plotLayerNumber:d});e.addObserver("plotDisplayDidChange",this,function(){this.invokeLast(this.plottedPointsDidChange)}.bind(this));b.push(e)}}.bind(this))},createLegendViews:function(){var a=this.get("mapPointLayers").map(function(b){return DG.LegendView.create({model:b.getPath("model.legend")})});return a},plottedPointsDidChange:function(){this.notifyPropertyChange("pointsDidChange")},modelDidChange:function(){}.observes("model"),shouldDraw:function(){return !SC.none(this.getPath("mapLayer.map"))},doDraw:function(){this.get("mapPointLayers").forEach(function(a){a.doDraw()})},updateConnectingLines:function(){this.get("mapPointLayers").forEach(function(a){a.updateConnectingLine()})},clear:function(){this.get("mapPointLayers").forEach(function(a){a.clear()})}});sc_require("components/map/map_data_configuration");DG.MapPolygonDataConfiguration=DG.MapDataConfiguration.extend({init:function(){var d={caption:DG.AttributePlacementDescription.create(),legend:DG.AttributePlacementDescription.create(),polygon:DG.AttributePlacementDescription.create()},b,a,f,c;arguments.callee.base.apply(this,arguments);var e=function(){var g=function(l,k,n){var o=d[l],m;DG.assert(o);if(k){o.set("collectionClient",n);o.set("attribute",k);switch(l){case"polygon":m=DG.Analysis.EAttributeType.eBoundary;break;case"caption":m=DG.Analysis.EAttributeType.eCategorical;break}if(m){o.setPath("attributeStats.attributeType",m)}}else{o.set("collectionClient",null);o.removeAllAttributes()}o.addObserver("collectionClient",this,l+"CollectionDidChange");o.addObserver("collection",this,"collectionDidChange")}.bind(this);var h=this.initializer.context,j=this.initializer.collection,i=h&&h.getCollectionByID(j.get("id"));if(j&&i){a=j.getAttributeNames()[0];f=a&&j.getAttributeByName(a);c=this.initializer.polygonName&&j.getAttributeByName(this.initializer.polygonName);g("caption",f,i);g("legend",null,i);g("polygon",c,i)}}.bind(this);e();this.attributesByPlace=[];for(b=0;b<DG.GraphTypes.EPlace.eNumPlaces;b++){this.attributesByPlace[b]=[]}this.attributesByPlace[DG.GraphTypes.EPlace.eCaption][0]=d.caption;this.attributesByPlace[DG.GraphTypes.EPlace.eLegend][0]=d.legend;this.attributesByPlace[DG.GraphTypes.EPlace.ePolygon][0]=d.polygon;this.set("dataContext",this.initializer.context);delete this.initializer},collectionClient:function(){var b=["polygonAttributeDescription","xAttributeDescription"],a;b.forEach(function(d){var c=this.get(d);if(c&&c.collectionClient){a=c.collectionClient}}.bind(this));return a}.property(),allCases:function(){if(this.get("hasPolygonAttribute")){var a=this.get("collectionClient");return a?a.getPath("casesController.arrangedObjects"):[]}else{return[]}}.property(),polygonAttributeDescription:function(a,b){return this.attributeDescriptionForPlace(a,b,DG.GraphTypes.EPlace.ePolygon)}.property(),polygonCollectionDidChange:function(){this.notifyPropertyChange("polygonCollectionClient")},polygonCollectionClient:function(){return this.getPath("polygonAttributeDescription.collectionClient")}.property().cacheable(),polygonCollectionClientDidChange:function(){this.notifyPropertyChange("polygonCollectionClient")}.observes("*polygonAttributeDescription.collectionClient"),polygonAttributeID:function(){return this.getPath("polygonAttributeDescription.attributeID")}.property(),polygonAttributeIDDidChange:function(){this.notifyPropertyChange("polygonAttributeID")}.observes("*polygonAttributeDescription.attributeID"),hasPolygonAttribute:function(){return !SC.none(this.get("polygonAttributeID"))}.property("polygonAttributeID"),captionAttributeDescription:function(a,b){return this.attributeDescriptionForPlace(a,b,DG.GraphTypes.EPlace.eCaption)}.property(),captionCollectionDidChange:function(){this.notifyPropertyChange("captionCollectionClient")},captionCollectionClient:function(){return this.getPath("captionAttributeDescription.collectionClient")}.property(),captionCollectionClientDidChange:function(){this.notifyPropertyChange("captionCollectionClient")}.observes("*captionAttributeDescription.collectionClient"),captionAttributeID:function(){return this.getPath("captionAttributeDescription.attributeID")}.property(),captionAttributeIDDidChange:function(){this.notifyPropertyChange("captionAttributeID")}.observes("*captionAttributeDescription.attributeID"),getPolygonBounds:function(){var f=this.get("cases"),e=this.get("polygonAttributeID"),c=180,g=-180,b=90,d=-90;if(!e){return null}function a(h){h.forEach(function(i){b=Math.min(b,i[1]);d=Math.max(d,i[1]);c=Math.min(c,i[0]);g=Math.max(g,i[0])})}f.forEach(function(j){try{var i=JSON.parse(j.getValue(e)),h=i.geometry.coordinates,k=i.geometry.type;h.forEach(function(m){switch(k){case"Polygon":a(m);break;case"MultiPolygon":m.forEach(function(n){a(n)});break}})}catch(l){console.log(l)}});return L.latLngBounds([[b,c],[d,g]])}});sc_require("components/graph_map_common/plot_layer");DG.MapPolygonLayer=DG.PlotLayer.extend({displayProperties:[],autoDestroyProperties:[],mapSource:null,_areFeaturesAdded:false,_featuresRemainingToFetch:0,features:null,map:function(){return this.getPath("mapSource.mapLayer.map")}.property(),init:function(){arguments.callee.base.apply(this,arguments);this.features=[]},destroy:function(){var a=this.get("map");this.features.forEach(function(b){a.removeLayer(b)});this.features=null;arguments.callee.base.apply(this,arguments)},readyToDraw:function(){var a=this.get("model");return a&&!SC.none(a.getPath("dataConfiguration.polygonAttributeDescription.attributeID"))},createRenderContext:function(){var e=this.get("model");if(!e){return}var f=e.get("dataConfiguration"),b=e.getPath("dataConfiguration.legendAttributeDescription"),d=this.get("areaStrokeColor")===DG.PlotUtilities.kDefaultMapStrokeColor,g=e.get("strokeSameAsFill"),c=b&&b.get("isNumeric"),a=f&&f.get("legendQuantiles");return{map:this.get("map"),polygonVarID:e.getPath("dataConfiguration.polygonAttributeDescription.attributeID"),legendDesc:b,legendVarID:b&&b.get("attributeID"),legendName:b&&b.getPath("attribute.name"),areaTransparency:e.get("areaTransparency"),areaStrokeColor:e.get("areaStrokeColor"),areaStrokeColorIsDefault:d,areaStrokeTransparency:g?e.get("areaTransparency"):e.get("areaStrokeTransparency"),calcCaseColorString:function(j){if(!this.legendVarID){return e.get("areaColor")}DG.assert(j);var h=c?j.getForcedNumericValue(this.legendVarID):j.getValue(this.legendVarID),i=h?DG.ColorUtilities.calcCaseColor(h,this.legendDesc,null,a):DG.ColorUtilities.kMapMissingValueCaseColor;return i.colorString||i},calcStrokeColorString:function(h){if(g){return this.calcCaseColorString(h)}else{return this.areaStrokeColor}}}},calcTooltip:function(a){function d(k,j){function l(){return DG.PlotUtilities.findFractionDigitsForRange(j.getPath("attributeStats.minMax"))}return DG.PlotUtilities.getFormattedCaseValue(k,j,l)}var i=this.getPath("model.dataConfiguration.captionAttributeDescription"),b=i.get("attributeID"),e=i.getPath("attribute.name"),g=this.getPath("model.dataConfiguration.legendAttributeDescription"),h=g&&g.get("attributeID"),c=g.getPath("attribute.name"),f=e+": "+a.getValue(b);if(h&&(h!==b)){f+="<br>"+c+": "+d(a,g)}return f},handleAttributeChange:function(){this.dataDidChange()}.observes("model.dataConfiguration.attributeAssignment","model.dataConfiguration.legendQuantilesAreLocked"),doDraw:function(){if(!this.readyToDraw()){return}var b=this.getPath("model.cases"),a=this.createRenderContext();if(b.get("length")!==this.features.length){this.clear();this.addFeatures()}b.forEach(function(e,f){var g=a.calcCaseColorString(e),d=a.calcStrokeColorString(e),c=this.features[f];if(c){c.setStyle({fillColor:g,color:d,opacity:a.areaStrokeTransparency,fillOpacity:a.areaTransparency})}}.bind(this));this.updateSelection()}.observes("model.areaColor","model.areaTransparency","model.areaStrokeColor","model.areaStrokeTransparency","model.strokeSameAsFill","model.pointColor","model.colorMap"),clear:function(){this._areFeaturesAdded=false;var a=this.get("map");this.features.forEach(function(b){a.removeLayer(b)});this.features=[]},isVisibleChanged:function(){var b=this.getPath("model.isVisible"),a=this.get("map");this.features.forEach(function(c){var d=a.hasLayer(c);if(b&&!d){a.addLayer(c)}else{if(!b&&d){a.removeLayer(c)}}})}.observes("model.isVisible"),hasLegendWithFormula:function(){return this.getPath("model.dataConfiguration.legendAttributeDescription.attribute.hasFormula")},dataDidChange:function(){this.doDraw()},refreshComputedLegendColors:function(){if(this.hasLegendWithFormula()){this.doDraw()}},dataRangeDidChange:function(b,d,a,c){this.doDraw()},mustClearBecauseDataContextDidChange:function(){this.clear()}.observes("model.dataContext"),updateSelection:function(){if(!this.get("model")){return}if(!this.getPath("model.isVisible")){return}var a=this.getPath("model.dataConfiguration.collectionClient.casesController.selection"),d=(this.getPath("model.dataConfiguration.legendAttributeDescription.attribute")!==DG.Analysis.kNullAttribute),c=this.getPath("model.dataConfiguration.allCases"),b=this.createRenderContext();if(!c){return}c.forEach(function(g){var f=this.features.find(function(i){return i&&i.options["case"]===g}),e=a.containsObject(g),h=(e&&!d)?DG.PlotUtilities.kMapAreaNoLegendSelectedColor:b.calcCaseColorString(g);if(!f){return}if(e){f.setStyle({fillColor:h,color:d?DG.PlotUtilities.kMapAreaWithLegendSelectedBorderColor:DG.PlotUtilities.kMapAreaNoLegendSelectedBorderColor,fillOpacity:d?DG.PlotUtilities.kMapAreaWithLegendSelectedOpacity:DG.PlotUtilities.kMapAreaNoLegendSelectedOpacity,weight:DG.PlotUtilities.kMapAreaSelectedBorderWeight});if(!d){f.setStyle({fillColor:h})}}else{f.setStyle({color:b.calcStrokeColorString(g),opacity:b.areaStrokeTransparency,fillOpacity:d?DG.PlotUtilities.kMapAreaWithLegendUnselectedOpacity:b.areaTransparency,weight:DG.PlotUtilities.kMapAreaUnselectedBorderWeight,fillColor:h});f.bringToBack()}}.bind(this))},selectionDidChange:function(){this.updateSelection()}.observes("model.selection"),addFeatures:function(){if(this._areFeaturesAdded||this._featuresRemainingToFetch>0){return}this._featuresRemainingToFetch=0;var b=this.createRenderContext(),a=this.get("model"),d=a.getPath("dataConfiguration.cases"),c=a.get("isVisible");d.forEach(function(f,j){var h,m=function(n,o){if(!n){DG.logWarn(o);return}if(this._featuresRemainingToFetch>0){this._featuresRemainingToFetch--}this.features[j]=L.geoJson(n,{style:function(p){return{color:"yellow",weight:2,fillColor:DG.PlotUtilities.kMapAreaNoLegendColor,smoothFactor:2}},"case":f}).on("click",i).on("mouseover",g).on("mouseout",k).addTo(b.map);if(!c){b.map.removeLayer(this.features[j])}else{this.features[j].bringToBack()}}.bind(this),i=function(n){SC.run(function(){this.get("model").selectCase(f,n.originalEvent.shiftKey||n.originalEvent.metaKey)}.bind(this))}.bind(this),g=function(o){var n=this.features[j];h=L.popup({closeButton:false,autoPan:false,offset:L.point(0,-20)},n);h.setContent(this.calcTooltip(f));SC.Timer.schedule({target:this,action:function(){if(h){n.bindPopup(h).openPopup()}},interval:500})}.bind(this),k=function(n){if(h){h._close();h=null}}.bind(this);try{var e=f.getValue(b.polygonVarID);if(!e){return}if(e instanceof Error){m(null,e.message)}else{if(typeof e==="object"){if(e.jsonBoundaryObject){e=e.jsonBoundaryObject}m(e)}else{if(e.startsWith("http")){this._featuresRemainingToFetch++;$.ajax({url:e,context:this,data:"",success:m,error:function(o,p,n){console.log("Request for boundary failed. Status: "+p+" Error: "+n)},dataType:"json"})}else{if(e.startsWith("{")){m(JSON.parse(e))}}}}}catch(l){DG.logWarn("Invalid JSON for map area, reported from DG.MapPolygonLayer.addFeatures()")}}.bind(this));this._areFeaturesAdded=true},getBounds:function(){var b=this.get("map"),a;b.eachLayer(function(d){if(d.getBounds){var c=d.getBounds();if(!a){a=c}else{a.extend(c)}}});return a}});sc_require("components/map/map_layer_model");DG.MapPolygonLayerModel=DG.MapLayerModel.extend({areaColor:DG.PlotUtilities.kMapAreaNoLegendColor,areaTransparency:DG.PlotUtilities.kDefaultMapFillOpacity,areaStrokeColor:DG.PlotUtilities.kDefaultMapStrokeColor,areaStrokeTransparency:DG.PlotUtilities.kDefaultMapStrokeOpacity,init:function(){arguments.callee.base.apply(this,arguments)},polygonVarID:function(){return this.getPath("dataConfiguration.polygonAttributeDescription.attributeID")}.property(),polygonVarIDDidChange:function(){this.notifyPropertyChange("polygonVarID")}.observes("*dataConfiguration.polygonAttributeDescription.attributeID"),wantsInspector:true,hasPolygonAttribute:true,canRescale:true,hasValidMapAttributes:function(){var c=this.getPath("dataConfiguration.polygonAttributeDescription.attribute"),a=c&&c.get("name"),b=c&&c.get("type");return a&&(DG.MapConstants.kPolygonNames.indexOf(a.toLowerCase())>=0||b===DG.Analysis.EAttributeType.eBoundary||b==="boundary")},createStorage:function(){var a=arguments.callee.base.apply(this,arguments);a.areaColor=this.get("areaColor");a.areaTransparency=this.get("areaTransparency");a.areaStrokeColor=this.get("areaStrokeColor");a.areaStrokeTransparency=this.get("areaStrokeTransparency");a.strokeSameAsFill=this.get("strokeSameAsFill");return a},restoreStorage:function(a){arguments.callee.base.apply(this,arguments);var b=a.mapModelStorage||a;if(b.areaColor){this.set("areaColor",b.areaColor)}if(b.areaTransparency){this.set("areaTransparency",b.areaTransparency)}if(b.areaStrokeColor){this.set("areaStrokeColor",b.areaStrokeColor)}if(b.areaStrokeTransparency){this.set("areaStrokeTransparency",b.areaStrokeTransparency)}if(b.strokeSameAsFill){this.set("strokeSameAsFill",b.strokeSameAsFill)}}});sc_require("controllers/component_controller");DG.SliderController=DG.ComponentController.extend({sliderModel:null,axisModel:null,sliderView:null,axisView:function(){return this.getPath("view.contentView.axisView")}.property(),valueAnimator:null,animationSign:1,isAnimating:function(){return !!this.getPath("valueAnimator.isAnimating")}.property(),isAnimatingDidChange:function(){this.notifyPropertyChange("isAnimating")}.observes("*valueAnimator.isAnimating"),modelDidChange:function(){var a=this.getPath("model.content");this.set("sliderModel",a);if(a){this.set("axisModel",a.get("axis"))}}.observes("model"),toggleAnimation:function(){var d=function(){var e=this.get("axisModel"),f=e&&e.get("lowerBound"),h=e&&e.get("upperBound"),g=this.get("axisView"),j=b.get("value"),i=this.getPath("sliderModel.restrictToMultiplesOf")||(g&&g.get("increment"));if(c===DG.SliderTypes.EAnimationDirection.eLowToHigh&&(j+i>=h)){b.set("value",f)}else{if(c===DG.SliderTypes.EAnimationDirection.eHighToLow&&(j-i<=f)){b.set("value",h)}}a.set("maxPerSecond",this.getPath("sliderModel.maxPerSecond"));a.animate();DG.logUser("sliderBeginAnimation: %@",this.getPath("sliderModel.name"))}.bind(this);var a=this.get("valueAnimator"),b=this.get("sliderModel"),c=b.get("animationDirection");if(c===DG.SliderTypes.EAnimationDirection.eLowToHigh){this.set("animationSign",1)}else{if(c===DG.SliderTypes.EAnimationDirection.eHighToLow){this.set("animationSign",-1)}}if(SC.none(a)){a=DG.ValueAnimator.create({valueHolder:b,incrementProvider:this});this.set("valueAnimator",a)}if(a.get("isAnimating")){a.endAnimation();DG.logUser("sliderEndAnimation: %@",this.getPath("sliderModel.name"))}else{d()}DG.dirtyCurrentDocument()},stopAnimation:function(){var a=this.get("valueAnimator");if(a&&a.get("isAnimating")){a.endAnimation();DG.dirtyCurrentDocument()}},increment:function(){var h=this.get("sliderModel"),i=this.get("axisModel"),k=this.get("axisView"),c=h.get("restrictToMultiplesOf"),a=c||(k&&k.get("increment")),g=i&&i.get("lowerBound"),d=i&&i.get("upperBound"),b=h.get("value"),e=h.get("animationDirection"),f=h.get("animationMode"),j=b+this.get("animationSign")*a;switch(e){case DG.SliderTypes.EAnimationDirection.eBackAndForth:if(j>d){this.set("animationSign",-1);a=j-d}else{if(j<g){this.set("animationSign",1);a=g-j}}break;case DG.SliderTypes.EAnimationDirection.eLowToHigh:if(j>d){if(f===DG.SliderTypes.EAnimationMode.eOnceOnly){if(!DG.isNumeric(c)){h.set("value",d)}a=0;this.stopAnimation()}else{h.set("value",g)}}break;case DG.SliderTypes.EAnimationDirection.eHighToLow:if(j<g){if(!DG.isNumeric(c)){h.set("value",g)}if(f===DG.SliderTypes.EAnimationMode.eOnceOnly){a=0;this.stopAnimation()}else{h.set("value",d)}}break}return this.animationSign*a}.property(),incrementDidChange:function(){this.notifyPropertyChange("increment")}.observes("*axisView.increment","*axisModel.lowerBound","*axisModel.upperBound","*sliderModel.value"),createInspectorButtons:function(){var a=arguments.callee.base.apply(this,arguments);a.push(DG.IconButton.create({layout:{width:32},classNames:"dg-slider-values".w(),iconClass:"moonicon-icon-values",showBlip:true,target:this,action:"showValuesPane",toolTip:"DG.Inspector.sliderValues.toolTip",localize:true}));return a},showValuesPane:function(){var d=this;var c=function(e){return e},a=function(e){if(!DG.isNumeric(e)||e===0){e=null}else{e=Number(e)}return e},b=function(e){var f=Object.assign(e,{name:"slider.change",_newValue:null,_prevValue:null,executeNotification:{action:"notify",resource:"component",values:{operation:"change slider value",type:"DG.SliderView"}},execute:function(){this._prevValue=d.getPath(this.valueKey);this._newValue=this.typeCheckFunc(this.controlView.get("value"));if(this._newValue===this._prevValue){this.causedChange=false}d.setPath(this.valueKey,this._newValue)},undo:function(){d.setPath(this.valueKey,this._prevValue)},redo:function(){d.setPath(this.valueKey,this._newValue)}});DG.UndoHistory.execute(DG.Command.create(f))};DG.InspectorPickerPane.create({classNames:"dg-inspector-picker".w(),layout:{width:275,height:100},contentView:SC.View.extend(SC.FlowedLayout,{layoutDirection:SC.LAYOUT_VERTICAL,isResizable:false,isClosable:false,defaultFlowSpacing:{bottom:10},canWrap:false,align:SC.ALIGN_TOP,childViews:"title multiples maxPerSecond directionControl modeControl".w(),title:DG.PickerTitleView.extend({title:"DG.Inspector.values",localize:true,iconURL:"../../../../static/dg/fr/cert/resources/images/icon-values.svg"}),multiples:SC.View.extend(SC.FlowedLayout,{layoutDirection:SC.LAYOUT_HORIZONTAL,isResizable:false,isClosable:false,defaultFlowSpacing:{right:10},canWrap:false,align:SC.ALIGN_LEFT,layout:{height:24},childViews:"label input".w(),label:SC.LabelView.create({layout:{width:132},value:"DG.Slider.multiples".loc(),classNames:"dg-inspector-picker-tag".w()}),input:SC.TextFieldView.create({layout:{width:80},type:"number",classNames:"dg-inspector-input".w(),applyImmediately:false,value:this.getPath("sliderModel.restrictToMultiplesOf"),valueChanged:function(){b({controlView:this,undoString:"DG.Undo.slider.changeMultiples",redoString:"DG.Redo.slider.changeMultiples",log:'sliderMaxPerSecond: { "name": "%@", " restrictMultiplesOf to": "%@" }'.loc(d.getPath("sliderModel.name"),this.get("value")),valueKey:"sliderModel.restrictToMultiplesOf",typeCheckFunc:a})}.observes("value")})}),maxPerSecond:SC.View.extend(SC.FlowedLayout,{layoutDirection:SC.LAYOUT_HORIZONTAL,isResizable:false,isClosable:false,defaultFlowSpacing:{right:10},canWrap:false,align:SC.ALIGN_LEFT,layout:{height:24},childViews:"label input".w(),label:SC.LabelView.create({layout:{width:190},value:"DG.Slider.maxPerSecond".loc(),classNames:"dg-inspector-picker-tag".w()}),input:SC.TextFieldView.create({layout:{width:60},type:"number",classNames:"dg-inspector-input".w(),applyImmediately:false,value:this.getPath("sliderModel.maxPerSecond"),valueChanged:function(){b({controlView:this,undoString:"DG.Undo.slider.changeSpeed",redoString:"DG.Redo.slider.changeSpeed",log:'sliderMaxPerSecond: { "name": "%@", "maxPerSecond to": "%@" }'.loc(d.getPath("sliderModel.name"),this.get("value")),valueKey:"sliderModel.maxPerSecond",typeCheckFunc:a})}.observes("value")})}),directionControl:DG.PickerControlView.extend({layout:{height:24},label:"DG.Slider.direction",controlView:SC.SelectView.extend({classNames:"dg-inspector-picker-select dg-slider-direction".w(),layout:{right:10,width:130},localize:true,value:d.getPath("sliderModel.animationDirection"),valueChanged:function(){b({controlView:this,undoString:"DG.Undo.slider.changeDirection",redoString:"DG.Redo.slider.changeDirection",log:'sliderAnimationDirection: { "name": "%@", "to": "%@" }'.loc(d.getPath("sliderModel.name"),DG.SliderTypes.directionToString(this.get("value"))),valueKey:"sliderModel.animationDirection",typeCheckFunc:c})}.observes("value"),itemTitleKey:"title",itemValueKey:"value",items:[{title:"DG.Slider.lowToHigh",value:DG.SliderTypes.EAnimationDirection.eLowToHigh},{title:"DG.Slider.backAndForth",value:DG.SliderTypes.EAnimationDirection.eBackAndForth},{title:"DG.Slider.highToLow",value:DG.SliderTypes.EAnimationDirection.eHighToLow}]})}),modeControl:DG.PickerControlView.extend({layout:{height:24},label:"DG.Slider.mode",controlView:SC.SelectView.extend({classNames:"dg-inspector-picker-select dg-slider-mode".w(),layout:{right:10,width:130},localize:true,value:d.getPath("sliderModel.animationMode"),valueChanged:function(){b({controlView:this,undoString:"DG.Undo.slider.changeRepetition",redoString:"DG.Redo.slider.changeRepetition",log:'sliderRepetitionMode: { "name": "%@", "to": "%@" }'.loc(d.getPath("sliderModel.name"),DG.SliderTypes.modeToString(this.get("value"))),valueKey:"sliderModel.animationMode",typeCheckFunc:c})}.observes("value"),itemTitleKey:"title",itemValueKey:"value",items:[{title:"DG.Slider.onceOnly",value:DG.SliderTypes.EAnimationMode.eOnceOnly},{title:"DG.Slider.nonStop",value:DG.SliderTypes.EAnimationMode.eNonStop}]})})}),transitionIn:SC.View.SCALE_IN}).popup(this.get("inspectorButtons")[0],SC.PICKER_POINTER)},createComponentStorage:function(){var c={},b=this.get("sliderModel"),a=this.get("axisModel");if(b){this.addLink(c,"model",b);if(a){c.lowerBound=a.get("lowerBound");c.upperBound=a.get("upperBound")}c.animationDirection=b.get("animationDirection");c.animationMode=b.get("animationMode");c.restrictToMultiplesOf=b.get("restrictToMultiplesOf");c.maxPerSecond=b.get("maxPerSecond");c.userTitle=b.get("userChangedTitle")}return c},restoreComponentStorage:function(a,e){arguments.callee.base.apply(this,arguments);var d=this.getPath("model.content");if(d){var f=this.getLinkID(a,"model");if(f){var c=DG.store.find(DG.GlobalValue,f);if(c){DG.globalsController.registerGlobalValue(c);d.set("content",c)}}d.set("animationDirection",a.animationDirection);d.set("animationMode",a.animationMode);d.set("restrictToMultiplesOf",a.restrictToMultiplesOf);d.set("maxPerSecond",a.maxPerSecond);d.set("userChangedTitle",a.userChangedTitle);var b=d.get("axis");if(b&&!SC.none(a.lowerBound)&&!SC.none(a.upperBound)){b.setLowerAndUpperBounds(a.lowerBound,a.upperBound)}}}});DG.SliderTypes={EAnimationDirection:{eBackAndForth:0,eLowToHigh:1,eHighToLow:2},directionToString:function(a){switch(a){case this.EAnimationDirection.eBackAndForth:return"DG.Slider.backAndForth".loc();case this.EAnimationDirection.eLowToHigh:return"DG.Slider.lowToHigh".loc();case this.EAnimationDirection.eHighToLow:return"DG.Slider.highToLow".loc()}},EAnimationMode:{eNonStop:0,eOnceOnly:1},modeToString:function(a){switch(a){case this.EAnimationMode.eNonStop:return"DG.Slider.nonStop".loc();case this.EAnimationMode.eOnceOnly:return"DG.Slider.onceOnly".loc()}}};DG.SliderModel=SC.Object.extend({axis:null,content:null,id:null,idBinding:"*content.id",name:function(a,b){if(!SC.none(b)){this.setPath("content.name",b)}return this.getPath("content.name")}.property(),defaultTitle:function(){return this.getPath("content.name")}.property(),defaultTitleDidChange:function(){this.notifyPropertyChange("defaultTitle")}.observes("*content.name"),_title:null,title:function(a,b){if(!SC.none(b)){this._title=b}return this._title||this.get("defaultTitle")}.property(),titleDidChange:function(){this.set("userChangedTitle",true)}.observes("title"),value:null,valueBinding:"*content.value",animationDirection:DG.SliderTypes.EAnimationDirection.eLowToHigh,animationMode:DG.SliderTypes.EAnimationMode.eOnceOnly,restrictToMultiplesOf:null,maxPerSecond:null,userChangedTitle:false,animator:null,init:function(){arguments.callee.base.apply(this,arguments);var a=DG.CellLinearAxisModel.create();a.setDataMinAndMax(0,10);this.set("axis",a)},destroy:function(){DG.globalsController.destroyGlobalValue(this.get("content"));arguments.callee.base.apply(this,arguments)},applyRestriction:function(){var a=this.get("value"),c=this.get("restrictToMultiplesOf"),b=(DG.isNumeric(c)&&c!==0)?Math.round(a/c):null;if(DG.isNumeric(b)){this.setIfChanged("value",c*b)}}.observes("restrictToMultiplesOf"),valueChanged:function(){this.applyRestriction()}.observes("value"),encompassValue:function(){var c=this.get("axis"),b=c.get("lowerBound"),f=c.get("upperBound"),g=this.get("value");if((g<b)||(g>f)){var a=b,e=f,d=[];if(g<b){a=g-(f-g)/10}else{e=g+(g-b)/10}if(SC.none(this.get("animator"))){this.set("animator",DG.GraphAnimator.create())}d.push({axis:c,newBounds:{lower:a,upper:e}});DG.sounds.playDrag();this.get("animator").set("axisInfoArray",d).animate()}},bringValueInBounds:function(){if(this.getPath("animator.isAnimating")){return}var b=this.get("axis"),a=b.get("lowerBound"),c=b.get("upperBound"),d=this.get("value");if(d<a){this.set("value",a)}else{if(d>c){this.set("value",c)}}}.observes(".axis.lowerBound",".axis.upperBound"),toLink:function(){var a=this.get("content");return a?a.toLink():null}});DG.SliderView=SC.View.extend((function(){var g=32,d=36,h=20,b=18,c=20,e=5,f,a=false;return{backgroundColor:"white",model:null,axisView:null,thumbView:null,startButton:null,valueView:null,leftMarker:null,rightMarker:null,userEdit:false,_previousValue:0,value:function(){return this.getPath("model.value")}.property("model").cacheable(),valueDidChange:function(){this.notifyPropertyChange("value")}.observes("*model.value"),name:function(){return this.getPath("model.name")}.property("model").cacheable(),nameDidChange:function(){this.notifyPropertyChange("name")}.observes("*model.name","*model.content.name"),thumbCoord:function(){var j=this.get("value"),i=this.get("axisView");return(SC.none(j)||SC.none(i))?null:i.dataToCoordinate(j)}.property("value"),thumbCoordDidChange:function(){this.notifyPropertyChange("thumbCoord")}.observes("*axisView.model.lowerBound","*axisView.model.upperBound"),init:function(){arguments.callee.base.apply(this,arguments);DG.assert(!SC.none(this.get("model")));this.set("valueView",SC.LabelView.create(DG.MouseAndTouchView,{layout:{left:c+e,top:3,bottom:h+16},classNames:"dg-slider-label".w(),isEditable:true,isTextSelectable:YES,exampleNode:null,mouseDown:function(i){if(!this.get("isMouseDown")){this.set("isMouseDown",YES);this.set("isActive",YES)}return YES},inlineEditorWillBeginEditing:function(p,q,m){arguments.callee.base.apply(this,arguments);var n=this.get("frame"),o=4,k=5,i=DG.ViewUtilities.viewToWindowCoordinates({x:o-2,y:k-7},this);this.parentView.set("userEdit",true);var j=this.get("exampleNode");if(!j){var l=this.getPath("parentView.layer");j=this.get("layer").cloneNode(false);j.id=j.id+"-clone";j.style.visibility="hidden";l.appendChild(j);this.set("exampleNode",j)}j.style.left=0+"px";j.style.top=9+"px";p.set({exampleElement:j,exampleFrame:{x:i.x,y:i.y,width:n.width-2*o,height:n.height-2*k}})},doIt:function(){this.beginEditing()}}));this.appendChild(this.valueView);this.set("axisView",DG.CellLinearAxisView.create({layout:{left:g/2,right:g/2,height:h,bottom:0},orientation:DG.GraphTypes.EOrientation.kHorizontal,isDropTarget:false}));this.appendChild(this.axisView);this.setPath("axisView.model",this.getPath("model.axis"));this._previousValue=this.getPath("model.value");this.set("thumbView",DG.IconButton.create({layout:{bottom:h,width:g,height:d},iconExtent:{width:g,height:d},iconClass:"dg-thumb-icon",classNames:"dg-display-styles".w(),toolTip:"DG.SliderView.thumbView.toolTip",localize:true,touchPriority:true,mouseDown:function(){return NO},touchStart:function(){return this.mouseDown()}}));this.appendChild(this.thumbView);this.set("startButton",DG.IconButton.create({layout:{top:e+2,left:2,width:c+2,height:b+2},iconExtent:{width:c,height:b},iconClass:"dg-play-icon",classNames:"dg-display-styles".w(),target:this,action:"toggleAnimation",toolTip:"DG.SliderView.startButton.toolTip",localize:true}));this.appendChild(this.startButton);this.set("leftMarker",SC.View.create({classNames:"dg-slider-marker".w(),layout:{left:15,bottom:12,width:2,height:15}}));this.appendChild(this.leftMarker);this.set("rightMarker",SC.View.create({classNames:"dg-slider-marker".w(),layout:{right:14,bottom:12,width:2,height:15}}));this.appendChild(this.rightMarker)},_destroy:function(){var i=this.get("controller");if(i){i.stopAnimation()}this.model.destroy()},willDestroy:function(){console.log("SliderView.willDestroy");arguments.callee.base.apply(this,arguments)},destroy:function(){console.log("SliderView.destroy");this._destroy();arguments.callee.base.apply(this,arguments)},viewDidResize:function(){arguments.callee.base.apply(this,arguments);this.positionThumb()},positionThumb:function(){var i=this.get("thumbCoord");if(DG.isFinite(i)){var j=this.get("thumbView");if(j){j.adjust({left:Math.round(i)})}}}.observes("thumbCoord"),updateValueView:function(){var n=this.get("axisView"),j=n.coordinateToData(1)-n.coordinateToData(0),i=Math.log(j)/Math.LN10,o=Math.ceil(-i),m=this.get("model"),l=SC.none(m)?"":m.get("name"),k=SC.none(m)?"":DG.Format.number().group("").fractionDigits(0,o)(m.get("value"));this.setPath("valueView.value",l+" = "+k)}.observes("thumbCoord","name"),mouseDown:function(j){DG.globalEditorLock.commitCurrentEdit();var i=this.getPath("thumbView.frame");f={pagePoint:{x:j.pageX,y:j.pageY},viewPoint:DG.ViewUtilities.windowToViewCoordinates({x:j.pageX,y:j.pageY},this),thumbCoord:this.get("thumbCoord")};if(DG.ViewUtilities.ptInRect(f.viewPoint,i)){this._previousValue=this.getPath("model.value");a=true;return YES}else{return YES}},mouseDragged:function(n){if(a){var k=this.getPath("axisView.model.upperBound"),l=this.getPath("axisView.model.lowerBound"),j=n.pageX-f.pagePoint.x,i=f.thumbCoord+j,m;m=Math.min(Math.max(this.get("axisView").coordinateToData(i),l),k);this.setPath("model.value",m)}},mouseUp:function(){if(a){var i=this;DG.UndoHistory.execute(DG.Command.create({name:"slider.change",undoString:"DG.Undo.slider.change",redoString:"DG.Redo.slider.change",log:'sliderThumbDrag: { "name": "%@", "newValue": %@ }'.fmt(i.getPath("model.name"),i.getPath("model.value")),_componentId:i.getPath("controller.model.id"),_newValue:i.getPath("model.value"),_prevValue:i._previousValue,executeNotification:{action:"notify",resource:"component",values:{operation:"change slider value",type:"DG.SliderView"}},execute:function(){i.get("model").encompassValue();if(this._newValue===this._prevValue){this.causedChange=false}},undo:function(){i.setPath("model.value",this._prevValue);i.get("model").encompassValue()},redo:function(){i.setPath("model.value",this._newValue);i.get("model").encompassValue()}}))}a=false},touchStart:function(i){return this.mouseDown(i)},touchEnd:function(i){return this.mouseUp(i)},touchesDragged:function(i,j){return this.mouseDragged(i)},toggleAnimation:function(){var i=this.get("controller");if(i){i.toggleAnimation()}},isAnimatingDidChange:function(){var i=this.get("startButton");if(!this.getPath("controller.isAnimating")){i.set("iconClass","dg-play-icon")}else{i.set("iconClass","dg-pause-icon")}}.observes("*controller.isAnimating"),valueViewWasEdited:function(){var j=/^\s*([a-zA-Z_][\w]*)\s*=\s*([+\-]?[0-9.]+)/,l,k,m;if(this.get("userEdit")){var i=this.getPath("valueView.value");i=i.replace("\u2212","-");this.set("userEdit",false);l=j.exec(i);DG.logUser("sliderEdit: { expression: '%@', result: %@ }",i,!SC.none(l)?"success":"failure");if(!SC.none(l)){k=parseFloat(l[2]);m=l[1];this.setPathIfChanged("model.value",k);this.setPathIfChanged("model.name",m);this.get("model").encompassValue()}else{this.updateValueView()}}}.observes(".valueView.value")}}()));DG.FileImportView=SC.TextFieldView.extend({classNames:["dg-file-import-view"],applyImmediately:NO,type:"file",autoCorrect:NO,autoCapitalize:NO,hintOnFocus:NO,spellCheckEnabled:NO,shouldRenderBorder:NO,stateChangeAction:function(){if(this.action&&this.get("isEditing")){this.action()}}.observes("isEditing"),files:function(){var a=this.$input().prop("files");if(a){console.log("Files: "+Array.prototype.map.call(a,function(b){return b.name}))}return a}.property()});sc_require("controllers/component_controller");DG.TextComponentController=DG.ComponentController.extend({theValue:null,theText:function(b,a){if(!SC.none(a)){this.setPath("model.content.text",a)}return this.getPath("model.content.text")}.property(),theTextDidChange:function(){this.notifyPropertyChange("theText")}.observes("model.content.text"),apiTextDidChange:function(){var b=this.getPath("model.content.apiText");if(!SC.none(b)){try{this.setTheText(JSON.parse(b))}catch(a){this.setTheText(b)}this.setPath("model.content.apiText",null)}}.observes("model.content.apiText"),setTheText:function(a){this._isUpdatingText=true;this.beginPropertyChanges();this.set("theText",a);this.set("theValue",null);this.endPropertyChanges();this.invokeLater(function(){SC.run(function(){this._isUpdatingText=false}.bind(this))})},previousValue:null,_session:null,createComponentStorage:function(){var a=this.get("theText"),b={};if(!SC.empty(a)){if(typeof a==="string"){b.text=a}else{b.text=JSON.stringify(a)}}return b},restoreComponentStorage:function(c,f){arguments.callee.base.apply(this,arguments);var b=c.text||c.apiText||"",a;try{a=JSON.parse(b);if(!a||!a.object||(a.object!=="value")){a=b}}catch(d){a=b}this.setTheText(a);this.set("previousValue",a)},onTextUpdate:function(){if(this._isUpdatingText){return}var b=JSON.stringify(this.get("theText")||"");this._session=this._session||Math.random();function a(d){var c="";try{c=JSON.parse(d)}catch(f){c=""}return c}DG.UndoHistory.execute(DG.Command.create({name:"textComponent.edit",undoString:"DG.Undo.textComponent.edit",redoString:"DG.Redo.textComponent.edit",_componentId:this.getPath("model.id"),_controller:function(){return DG.currDocumentController().componentControllersMap[this._componentId]},_reduceKey:"textComponent.edit"+this._session,executeNotification:{action:"notify",resource:"component",values:{operation:"edit text",type:"DG.TextView"}},execute:function(){this._beforeStorage=this._controller().get("previousValue");this._afterStorage=b;this._controller().set("previousValue",b)},undo:function(){this._reduceKey=Math.random();this._controller().setTheText(a(this._beforeStorage));this._controller().set("previousValue",this._beforeStorage)},redo:function(){this._controller().setTheText(a(this._afterStorage));this._controller().set("previousValue",this._afterStorage)},reduce:function(c){if(c._reduceKey===this._reduceKey){this._beforeStorage=c._beforeStorage;return this}}}))}.observes("theText"),commitEditing:function(){this._session=null;DG.currDocumentController().notificationManager.sendNotification({action:"notify",resource:"component",values:{operation:"commitEdit",type:this.getPath("model.type"),id:this.getPath("model.id"),title:this.getPath("model.title"),text:JSON.stringify(this.get("theText")||"")}})},willCloseComponent:function(){arguments.callee.base.apply(this,arguments);this.commitEditing()},getEditView:function(){return this.getPath("view.containerView.contentView.editView")},viewDidChange:function(){var b=this.getEditView();if(b){var a=this.get("theText");a&&b.set("value",a);b.bind("editorValue",this,"theValue");b.bind("value",this,"theText")}}.observes("*view.containerView.contentView")});DG.TextModel=SC.Object.extend({text:null,_apiText:null,apiText:function(b,a){if(a!=null){this._apiText=a}return this._apiText||this.get("text")}.property(),init:function(){arguments.callee.base.apply(this,arguments)}});DG.TextView=SC.View.extend((function(){var a=" dg-wants-mouse dg-wants-touch dg-wants-keys dg-wants-select";return{backgroundColor:"white",childViews:["editView"],editView:SC.View.design({classNames:["dg-text-view-edit-view","allow-select"],layout:{left:2,right:2,top:2,bottom:2},_editor:null,editorValue:null,value:null,_slatePlugins:null,init:function(){arguments.callee.base.apply(this,arguments);var b={onCommand:function(f,e,d){var c=d();return c}.bind(this)};this._slatePlugins=[b]},getValueForEditor:function(){var b=this.get("editorValue");if(b){return b}var c=this.get("value");if(typeof c==="string"){return SlateEditor.textToSlate(c)}if(!c){return SlateEditor.textToSlate("")}return SlateEditor.deserializeValue(c)},isEditorFocused:function(){return !!(this._editor&&this._editor.value&&this._editor.value.selection&&this._editor.value.selection.isFocused)},editorValueDidChange:function(){this.renderEditor();this.renderToolbar()}.observes("editorValue"),getComponentView:function(){return this.getPath("parentView.parentView.parentView")},isComponentSelected:function(){return this.getPath("parentView.parentView.parentView.isSelected")},isComponentSelectedDidChange:function(){var c=this.isComponentSelected(),d=this.getPath("parentView.parentView.titlebar.userEdit"),b=this.isEditorFocused();if(!c&&b){this._editor&&this._editor.blur()}else{if(c&&!d&&!b){this._editor&&this._editor.focus()}}this.renderToolbar()}.observes(".parentView.parentView.parentView.isSelected"),didCreateLayer:function(){this._controller=this.getPath("parentView.parentView.parentView.controller");this.reactEditorDiv=document.createElement("div");this.reactEditorDiv.className="dg-text-view-react-root"+a;this.get("layer").appendChild(this.reactEditorDiv);this.reactToolbarDiv=document.createElement("div");this.reactToolbarDiv.className="dg-text-view-react-portal";this.reactToolbarDiv.style.position="absolute";DG.mainPage.mainPane.scrollView.contentView.get("layer").appendChild(this.reactToolbarDiv);this.reactModalDiv=document.createElement("div");this.reactModalDiv.className="dg-text-view-modal-portal";DG.mainPage.mainPane.scrollView.contentView.get("layer").appendChild(this.reactModalDiv);this.renderEditor();this.renderToolbar()},willDestroyLayer:function(){ReactDOM.unmountComponentAtNode(this.reactEditorDiv);ReactDOM.unmountComponentAtNode(this.reactToolbarDiv);DG.mainPage.mainPane.scrollView.contentView.get("layer").removeChild(this.reactToolbarDiv)},positionToolbar:function(){var c=this.getComponentView(),b=c&&c.computeFrameWithParentFrame();if(b&&this.reactToolbarDiv){this.reactToolbarDiv.style.left=(b.x+b.width)+"px";this.reactToolbarDiv.style.top=b.y+"px"}}.observes(".parentView.parentView.parentView.frame"),renderToolbar:function(){var b={modalPortalRoot:this.reactModalDiv,modalCoverClassName:"codap-ccrte-cover"+a,modalDialogClassName:"codap-ccrte-modal"+a,className:"codap-ccrte-toolbar"+a,orientation:"vertical",colors:{buttonColors:{fill:"#ffffff",background:"#177991"},selectedColors:{fill:"#177991",background:"#72bfca"}},buttonsPerRow:9,order:["fontDecrease","bold","underlined","superscript","ordered-list","heading1","heading3","color","link","fontIncrease","italic","deleted","subscript","bulleted-list","heading2","block-quote","image"],editor:this._editor,show:this.isComponentSelected()};ReactDOM.render(DG.React.SlateToolbar(b),this.reactToolbarDiv)},renderEditor:function(){var c=this.getValueForEditor();if(c&&!this.get("editorValue")){this.set("editorValue",c)}var b={className:"codap-ccrte-editor",plugins:this._slatePlugins,value:c,history:false,onEditorRef:function(d){this._editor=d}.bind(this),onValueChange:function(d){SC.run(function(){this.set("editorValue",d)}.bind(this))}.bind(this),onContentChange:function(d){SC.run(function(){this.set("value",SlateEditor.serializeValue(d))}.bind(this))}.bind(this),onFocus:function(){if(!this.isComponentSelected()){SC.run(function(){DG.mainPage.mainPane.hideInspectorPicker();var d=this.getComponentView();d&&d.select()}.bind(this))}}.bind(this),onBlur:function(){SC.run(function(){this.commitEditing()}.bind(this))}.bind(this)};ReactDOM.render(DG.React.SlateEditor(b),this.reactEditorDiv)},commitEditing:function(){this._controller.commitEditing()},dataDragDropped:function(c){var b=c.dataTransfer;if(b&&!b.files.length){c.stopPropagation()}else{return false}}}),defaultFirstResponder:function(){return this.get("editView")}.property(),didReachInitialPosition:function(){this.beginEditing()},beginEditing:function(){setTimeout(function(){var c=this.get("editView"),b=c&&c._editor;b&&b.focus()}.bind(this))}}})());DG.config=(function(){return{}}());DG.supportFuncs={caseTableHeaderMenus:function(){return true}};DG.supports=function(b){var a=DG.supportFuncs[b];return a?a():false};DG.DocumentHelper=SC.Object.extend({isValidJsonDocument:function(h){function d(j,m,k){var l=k(j,m);if(l!==false){if(Array.isArray(m)){m.forEach(function(n){d(j,n,k)})}else{if(typeof m==="object"){DG.ObjectMap.forEach(m,function(n,o){d(n,o,k)})}}}}function c(l){var m=g.copy(false);var j=[];var k=[];m.unshift(l);m.forEach(function(n){d("doc",n,function(o,p){if(o==="guid"){j.push(Number(p));return true}else{if(o==="_links_"){d(o,p,function(r,q){if(r==="id"){k.push(Number(q))}return true});return false}else{if(o==="parent"){k.push(Number(p));return true}else{if(o==="contextStorage"){return false}}}}})});k.forEach(function(n){if(j.indexOf(Number(n))<0){e.push("DG.AppController.validateDocument.unresolvedID".loc(n))}})}var a=["appBuildNum","appName","appVersion","changeCount","components","contexts","globalValues","guid","metadata","name","_permissions","_openedFromSharedDocument"];var i=["name"];var e=[];var f;var g=[];if(typeof h==="string"){try{f=JSON.parse(h)}catch(b){e.push("DG.AppController.validateDocument.parseError".loc(b))}}else{f=h}if(f){i.forEach(function(j){if(!f.hasOwnProperty(j)){e.push("DG.AppController.validateDocument.missingRequiredProperty".loc(j))}});DG.ObjectMap.keys(f).forEach(function(j){if(a.indexOf(j)<0){DG.log("DG.AppController.validateDocument.unexpectedProperty".loc(j))}});c(f)}DG.log("Document validation: "+(e.length?JSON.stringify(e):"No Errors"));return e},createNewDocumentWithDataInteractives:function(b){var a=(b||[]).map(function(d){return{type:"DG.GameView",componentStorage:{currentGameName:"",currentGameUrl:d}}});var c={name:"DG.Document.defaultDocumentName".loc(),guid:1,isNewDocument:true,components:a,appName:DG.APPNAME,appVersion:DG.VERSION,appBuildNum:DG.BUILD_NUM,globalValues:[]};return DG.Document.createDocument(c)},updateDataContext:function(c,a){var b=c.dataContext;if(b){["managingController","title","description","preventReorg","metadata","rerandomize","sort"].forEach(function(h){var f;if(!SC.none(a[h])){if(h==="metadata"){if(typeof a[h]==="object"){f=b.getPath("model.metadata")||{};b.setPath("model.metadata",Object.assign(f,a[h]))}}else{if(h==="rerandomize"&&!!a[h]){b.doRerandomizeAll()}else{if(h==="sort"){var g=DG.currDocumentController().get("componentControllersMap");var e=[];for(var d in g){if(g[d].hasOwnProperty("caseTableAdapters")){e.push(g[d]);break}}e.forEach(function(l){var i=l.get("dataContext");var k=typeof(a[h].attr)==="string"?b.getAttributeByName(a[h].attr).id:a[h].attr;if(i.get("id")===b.get("id")){var j=a[h].isDescending;l.sortAttribute(k,j)}})}else{b.set(h,a[h])}}}}})}return{success:true}},deleteCollection:function(b,c){var a=b.dataContext;var d=b.collection;if(!d){return{success:false,values:{error:"Collection not found"}}}return a.applyChange({operation:"deleteCollection",collection:d,requester:c})},createCollection:function(e,b,g){function a(j,l){var i;var k;var m;if(SC.none(l)){k=j.get("collections");if(k&&k.length>0){i=k[k.length-1].get("id")}}else{if(typeof l==="number"){i=l}else{if(l==="_root_"){i=null}else{m=j.getCollectionByName(l);i=m?m.get("id"):null}}}return(!SC.none(i))?j.getCollectionByID(i).collection:null}function c(m,k,i){var o={operation:"createCollection",properties:k,attributes:(k&&k.attributes),requester:i};k.parent=a(m,k.parent);var j=m.applyChange(o);var n=(j&&j.success);var l=j.collection&&{id:j.collection.get("id"),name:j.collection.get("name")};return{success:n,values:l}}var d=e.dataContext;var f=true;var h=[];if(!d){return{success:false,values:{error:"no context"}}}if(!Array.isArray(b)){b=[b]}b.every(function(j){var i=c(d,j,g);f=f&&i.success;if(f){h.push(i.values)}return f});return{success:f,values:h}},applyChangeAndProcessResult:function(e,g,d){if(d&&d.dirtyDocument===false){g.dirtyDocument=false}var c=e.applyChange(g),a=c&&c.attrs,b=DG.DataInteractiveUtils.mapAttributeProperties(a,g.attrPropsArray),f={success:c&&c.success};if(b){f.values={attrs:b}}return f},createAttribute:function(e,c,b,f){if(!e.dataContext){return{success:false,values:{error:"no context"}}}if(!e.collection){return{success:false,values:{error:"Collection not found"}}}var d=e.dataContext;var a=SC.clone(Array.isArray(c)?c:[c]);if(a.some(function(h){return !h.name})){return{success:false,values:{error:"Create attribute: name required"}}}a.forEach(function(h){h.clientName=h.name;h.name=d.canonicalizeName(h.name+" ")});var g={operation:"createAttributes",collection:d.getCollectionByID(e.collection.get("id")),attrPropsArray:a,requester:f,position:e.position};return this.applyChangeAndProcessResult(d,g,b)},updateAttribute:function(d,b,a){var c=d.dataContext;if(!d.collection){return{success:false,values:{error:"Collection not found"}}}if(!d.attribute){return{success:false,values:{error:"Attribute not found"}}}if(!b.id&&d.attribute.id){b.id=d.attribute.id}if(!b.name&&d.attribute.name){b.name=d.attribute.name}else{if(b.name){b.clientName=b.name;b.name=c.canonicalizeName(b.name+" ")}}var e={operation:"updateAttributes",collection:d.collection,attrPropsArray:[b],requester:this.get("id")};return this.applyChangeAndProcessResult(c,e,a)},updateAttributeLocation:function(d,b,a){var c=d.dataContext;if(!c){return{success:false,values:{error:"context not found"}}}var e={operation:"moveAttribute",requester:this.get("id"),attr:d.attributeLocation};if(b&&!SC.none(b.collection)){e.toCollection=c.getCollectionByName(b.collection)||c.getCollectionByID(b.collection);if(!e.toCollection){return{success:false,values:{error:"Target collection not found"}}}}if(b&&!SC.none(b.position)){e.position=b.position}return c.applyChange(e)},createCases:function(f,m,k){function e(n){if(n instanceof Date){n.valueOf=function(){return Date.prototype.valueOf.apply(this)/1000}}}function d(n){if(Array.isArray(n.values)){n.values.forEach(function(o){e(o)})}else{if(typeof n.values==="object"){DG.ObjectMap.forEach(n.values,function(o,p){e(p)})}}}function h(o){d(o);var p=o.parent;var n=o.values;var q=a.find(function(r){return r.properties.parent===p});if(!q){q={operation:"createCases",collection:g,properties:{parent:p},values:[],requester:i};a.push(q)}q.values.push(n)}if(!f.collection){return{success:false,values:{error:"Collection not found"}}}var j=true;var b=f.dataContext;var g=f.collection;var l=Array.isArray(m)?m:[m];var c=[];var i=k;var a=[];l.forEach(h);a.forEach(function(p){var n=b.applyChange(p);var r=r&&(n&&n.success);var o;if(n.success){for(o=0;o<n.caseIDs.length;o++){var s=n.caseIDs[o];var q=(o<=n.itemIDs.length)?n.itemIDs[o]:null;c.push({id:s,itemID:q})}}});return{success:j,values:c}},updateDocument:function(j,e){var f=DG.currDocumentController(),i=f.get("componentControllersMap")||[],a=j.components||[];function h(n){f.notificationManager.sendNotification({action:"notify",resource:"documentChangeNotice",values:{operation:n}},function(o){DG.log("Sent notification for document change: "+n);DG.log("Response: "+JSON.stringify(o))})}function g(){var n=a.map(function(o){return Number(o.guid)});DG.ObjectMap.forEach(i,function(o,p){var q=n.indexOf(Number(o))>=0;if(!q){DG.closeComponent(o)}})}function d(){var n=f.get("contextRecords")||[],o=j.contexts?j.contexts.map(function(p){return Number(p.guid)}):[];DG.ObjectMap.forEach(n,function(p,q){var r=o.indexOf(Number(p))>=0;if(!r){f.destroyDataContext(p)}})}function k(){var n=f.get("contextRecords"),o=j.contexts||[];o.forEach(function(p){var s=p.guid,q;DG.ObjectMap.forEach(n,function(u,v){if(Number(u)===s){q=v}});if(q){var t=q.toArchive(true),r=p.contextStorage;delete p.contextStorage;delete t.contextStorage;if(JSON.stringify(p)!==JSON.stringify(t)){p.contextStorage=r;f.destroyDataContext(s);f.createNewDataContext(p)}else{p.contextStorage=r}}else{f.createNewDataContext(p)}})}function m(){a.forEach(function(r){var p=i[r.guid];if(p){var o=p.get("view"),n=o.get("isMinimized");p.restoreComponentStorage(r.componentStorage);if((n&&SC.none(r.savedHeight))||(!n&&!SC.none(r.savedHeight))){o.toggleMinimization()}else{if(r.layout.isVisible){if(!o.get("isVisible")){o.adjust({left:0,top:0,width:10,height:10});o.set("isVisible",true)}o.adjust({zIndex:r.layout.zIndex,isVisible:r.layout.isVisible});delete r.layout.zIndex;delete r.layout.isVisible;o.animate(r.layout,{duration:0.4,timing:"ease-in-out"})}else{o.set("isVisible",false)}}}else{DG.store.deregister(r.id);r.document=DG.activeDocument;r.allowMoreThanOne=true;var q=DG.Component.createComponent(r);f.createComponentAndView(q)}})}function l(){if(j.globalValues){j.globalValues.forEach(function(n){var o=DG.globalsController.getGlobalValueByID(n.guid);if(o){o.set("value",n.value);o.set("name",n.name)}else{DG.globalsController.createGlobalValue({name:n.name,value:n.value,guid:n.guid})}})}}function b(){var n=f.get("contexts");if(j.contexts){j.contexts.forEach(function(o){var q=n.find(function(r){return r.getPath("model.id")===o.guid});if(q){var p=o.contextStorage._links_.selectedCases.map(function(r){return q.getCaseByID(r.id)});q.invokeOnceLater(function(){q.applyChange({operation:"selectCases",select:true,cases:p})},200)}})}}var c=true;h("updateDocumentBegun");g();d();l();k();m();b();setTimeout(function(){DG.UndoHistory.clearUndoRedoHistory();h("updateDocumentEnded")},500);return c}});sc_require("models/model_store");sc_require("models/base_model");DG.Document=DG.BaseModel.extend({type:"DG.Document",id:null,name:"",appName:"",appVersion:"",appBuildNum:"",components:null,contexts:null,globalValues:null,init:function(){this.components={};this.contexts={};this.globalValues={};arguments.callee.base.apply(this,arguments)},verify:function(){if(SC.empty(this.name)){DG.logWarn("Unnamed document: "+this.id)}},getGlobalValueByName:function(a){return DG.globalsController.getGlobalValueByName(a)},destroy:function(){arguments.callee.base.apply(this,arguments)},createContext:function(a){if(SC.none(a)){a={}}a.document=this;return DG.DataContextRecord.createContext(a)},willSaveRecord:function(){this.set("appName",DG.APPNAME);this.set("appVersion",DG.VERSION);this.set("appBuildNum",DG.BUILD_NUM)},toArchive:function(a){var b={name:this.name,guid:this.id,id:this.id,components:[],contexts:[],globalValues:[],appName:DG.APPNAME,appVersion:DG.VERSION,appBuildNum:DG.BUILD_NUM,lang:SC.Locale.currentLanguage,idCount:DG.store._idCount};DG.ObjectMap.forEach(this.globalValues,function(c){var d=this.globalValues[c];if(d.get("archivable")){b.globalValues.push(d.toArchive())}}.bind(this));DG.ObjectMap.forEach(this.components,function(c){b.components.push(this.components[c].toArchive())}.bind(this));DG.ObjectMap.forEach(this.contexts,function(c){b.contexts.push(this.contexts[c].toArchive(a))}.bind(this));return b}});DG.Document.createDocument=function(b){var c,a=b||{};DG.store=DG.ModelStore.create({_idCount:SC.none(b.idCount)?0:b.idCount});c=DG.Document.create(a);DG.activeDocument=c;if(a.globalValues){a.globalValues.forEach(function(d){d.document=c;DG.globalsController.createGlobalValue(d)})}if(a.components){a.components.forEach(function(d){d.document=c;DG.Component.createComponent(d)})}if(a.contexts){a.contexts.forEach(function(d){d.document=c;DG.DataContextRecord.createContext(d)})}DG.log("Create document: "+[c.name,c.appName].join(", "));return c};DG.Document.destroyDocument=function(a){if(a){a.destroy()}DG.activeDocument=null;DG.store=null;DG.Case._itemCaseMaps={}};sc_require("models/base_model");DG.GlobalValue=DG.BaseModel.extend({name:"",value:"",valueDidChange:function(){var a=this.get("value");DG.currDocumentController().notificationManager.sendNotification({action:"notify",resource:"global[%@]".loc(this.name),values:{globalValue:(typeof a==="object"||typeof a==="function")?a.toString():a}})}.observes("value"),document:null,init:function(){arguments.callee.base.apply(this,arguments)},destroy:function(){if(this.document){delete this.document.globalValues[this.id]}arguments.callee.base.apply(this,arguments)},verify:function(){if(SC.empty(this.document)&&!this.get("allowDetached")){DG.logWarn("Unattached global value: "+this.id)}if(typeof this.document==="number"){DG.logWarn("Unresolved reference to document id, "+this.document+", in global value: "+this.id)}},archivable:true,toArchive:function(){return{name:this.get("name"),value:this.get("value"),guid:this.get("id")}}});DG.GlobalValue.createGlobalValue=function(c){var b=c||{},a=DG.GlobalValue.create(b);if(c.document){b.document.globalValues[a.get("id")]=a}return a};DG.GlobalValue.destroyGlobalValue=function(a){a.destroy()};sc_require("models/global_value_model");DG.PendingRequest=function(){this.name="DG.Formula.PendingRequest.name".loc();this.message="DG.Formula.PendingRequest.message".loc();this.description="DG.Formula.PendingRequest.description".loc()};DG.PendingRequest.prototype=new Error();DG.PendingRequest.prototype.constructor=DG.PendingRequest;DG.FailedRequest=function(a){this.name="DG.Formula.FailedRequest.name".loc();this.message="DG.Formula.FailedRequest.message".loc(a);this.description="DG.Formula.FailedRequest.description".loc(a)};DG.FailedRequest.prototype=new Error();DG.FailedRequest.prototype.constructor=DG.FailedRequest;DG.RemoteResource=DG.GlobalValue.extend({url:null,format:null,archivable:false,pendingValue:new DG.PendingRequest(),_value:null,init:function(){arguments.callee.base.apply(this,arguments)},destroy:function(){arguments.callee.base.apply(this,arguments)},value:function(){if(this._value!=null){return this._value}this._load()}.property(),_load:function(){this._value=this.get("pendingValue");this.notifyPropertyChange("value");$.ajax({url:this.url,context:this,dataType:"json",success:function(c,a,b){SC.run(function(){this._value=this._handleSuccess(c,a,b);this.notifyPropertyChange("value")}.bind(this))}.bind(this),error:function(c,a,b){SC.run(function(){this._value=this._handleError(c,a,b);this.notifyPropertyChange("value")}.bind(this))}})},_handleSuccess:function(a){return a},_handleError:function(c,a,b){return new DG.FailedRequest(b||a)}});sc_require("models/remote_resource");sc_require("controllers/document_controller");DG.PendingBoundaries=function(){this.name="DG.Formula.PendingBoundaries.name".loc();this.message="DG.Formula.PendingBoundaries.message".loc();this.description="DG.Formula.PendingBoundaries.description".loc()};DG.PendingBoundaries.prototype=new DG.PendingRequest();DG.PendingBoundaries.prototype.constructor=DG.PendingBoundaries;DG.FailedBoundaries=function(a){this.name="DG.Formula.FailedBoundaries.name".loc();this.message="DG.Formula.FailedBoundaries.message".loc(a);this.description="DG.Formula.FailedBoundaries.description".loc(a)};DG.FailedBoundaries.prototype=new DG.FailedRequest();DG.FailedBoundaries.prototype.constructor=DG.FailedBoundaries;DG.RemoteBoundaries=DG.RemoteResource.extend({pendingValue:new DG.PendingBoundaries(),init:function(){arguments.callee.base.apply(this,arguments)},destroy:function(){arguments.callee.base.apply(this,arguments)},_handleSuccess:function(d){var f,a,b={},c,e=new DG.BoundaryMap();f=d.contexts[0];f.collections.forEach(function(g){switch(g.name){case"boundaries":a=g;break;case"index":c=g;break}});a.cases.forEach(function(g){b[g.guid]=g.values.boundary});c.cases.forEach(function(i){var g=i&&i.values&&i.values.key&&i.values.key.toLowerCase(),j=null;try{j=JSON.parse(b[i.parent])}catch(h){j=new DG.FailedBoundaries("JSON boundary")}e.map[g]={jsonBoundaryObject:j}}.bind(this));return e},_handleError:function(c,a,b){return new DG.FailedBoundaries(b||a)}});DG.enableBoundariesCache=false;DG.RemoteBoundaries.addBoundaries=function(a){DG.globalsController.registerGlobalValue(a);if(DG.activeDocument){a.set("document",DG.activeDocument);DG.activeDocument.globalValues[a.get("id")]=a}};DG.RemoteBoundaries.registerDefaultBoundaries=function(){var a=DG.get("boundarySpecsUrl");var b=a&&a.replace(/\/[^\/]*$/,"/");if(!DG.currDocumentController().get("ready")){return}function c(){if(DG.activeDocument.remoteBoundaries){DG.activeDocument.remoteBoundaries.forEach(function(d){DG.RemoteBoundaries.addBoundaries(d)})}}if(DG.activeDocument&&!DG.activeDocument.remoteBoundaries){$.ajax({url:DG.get("boundarySpecsUrl"),context:this,dataType:"json",success:function(e,d,g){DG.activeDocument.remoteBoundaries=[];var f=100000000;e.forEach(function(h){var k=DG.store.find(f);while(k){f++;k=DG.store.find(f)}h.guid=f++;var i=h.url;if(!(i.startsWith("http://")||i.startsWith("https://")||i.startsWith("//"))){h.url=b+i}var j=$.extend({allowDetached:true},h);DG.activeDocument.remoteBoundaries.push(DG.RemoteBoundaries.create(j))});c()}.bind(this),error:function(f,d,e){console.log("Unable to read boundary specs: "+e)}})}};sc_require("models/model_store");sc_require("models/base_model");DG.Component=DG.BaseModel.extend({document:null,_title:null,title:function(a,b){if(b!==undefined){this._title=b;if(this.getPath("content.title")){this.setPath("content.title",b)}}else{if(SC.none(this._title)){this._title=this.getPath("content.title")||this.getPath("content.defaultTitle")}}return this._title}.property(),userSetTitle:false,titleChanged:function(){this._title=null;this.notifyPropertyChange("title")}.observes("*content.title","*content.defaultTitle"),dimensions:function(){return this.getPath("content.dimensions")}.property(),contentDimensionsChanged:function(){this.notifyPropertyChange("dimensions")}.observes("*content.dimensions"),_position:null,position:function(a,b){if(b&&typeof b==="object"){if(SC.none(this._position)){this._position={}}this._position.left=b.left;this._position.top=b.top}return this._position}.property(),version:function(){return this.getPath("content.version")}.property(),contentVersionChanged:function(){this.notifyPropertyChange("version")}.observes("*content.version"),_cannotClose:false,cannotClose:function(a,b){if(!SC.none(b)){this._cannotClose=b}return this._cannotClose}.property("_cannotClose"),_isResizable:null,isResizable:function(a,b){if(!SC.empty(b)){if(typeof b==="object"){this._isResizable=b}else{if(typeof b==="boolean"){this._isResizable={width:b,height:b}}}}return this._isResizable.width&&this._isResizable.height}.property(),isWidthResizable:function(a,b){if(!SC.empty(b)&&typeof b==="boolean"){this._isResizable.width=b}return this._isResizable.width}.property(),isHeightResizable:function(a,b){if(!SC.empty(b)&&typeof b==="boolean"){this._isResizable.height=b}return this._isResizable.height}.property(),content:function(a,b){if(b!==undefined){DG.Component.setContent(this,b)}return DG.Component.getContent(this)}.property(),type:"",layout:null,savedHeight:null,componentStorage:null,init:function(){arguments.callee.base.apply(this,arguments);this._isResizable={width:true,height:true};var a=this.get("componentStorage");if(a){if(a.title){this.set("title",a.title)}if(a.name){this.set("name",a.name)}if(a.userSetTitle){this.set("userSetTitle",a.userSetTitle)}if(!SC.none(a.cannotClose)){this.set("cannotClose",a.cannotClose)}}},destroy:function(){var a=DG.currDocumentController().content;if(a){delete a.get("components")[this.id]}arguments.callee.base.apply(this,arguments)},toArchive:function(){function d(f){f.left=f.left||0;f.top=f.top||0;f.width=f.width||300;f.height=f.height||300;f.right=f.right||f.left+f.width;f.bottom=f.bottom||f.top+f.height;return f}var c={},b=this.get("componentStorage"),e=this.get("cannotClose"),a;if(b){b.title=this.get("title")||b.title;b.name=b.name||this.get("name");b.userSetTitle=b.userSetTitle||this.get("userSetTitle");b.cannotClose=SC.none(e)?b.cannotClose:e}a=d(this.layout);c={type:this.type,guid:this.id,id:this.id,componentStorage:b,layout:a,savedHeight:this.get("savedHeight")};return c},verify:function(){if(SC.empty(this.document)){DG.logWarn("Unattached component: "+this.id)}if(typeof this.document==="number"){DG.logWarn("Unresolved reference to document id, "+this.document+", in component: "+this.id)}}});DG.Component.contentMap={};DG.Component.clearContentMap=function(){DG.Component.contentMap={}};DG.Component.getContent=function(a){var b=a&&a.id;return b?DG.Component.contentMap[b]:undefined};DG.Component.setContent=function(a,c){var b=a&&a.id;if(!SC.none(b)){if(c===undefined){delete DG.Component.contentMap[b]}else{DG.Component.contentMap[b]=c}}};DG.Component.createComponent=function(b){var a=b||{},c;c=DG.Component.create(a);if(b.document){b.document.components[c.get("id")]=c}return c};DG.Component.destroyComponent=function(a){a.destroy()};sc_require("models/document_model");sc_require("models/remote_boundaries");sc_require("models/component_model");DG.DocumentController=SC.Object.extend({content:null,contextRecords:function(){return this.getPath("content.contexts")}.property(),contexts:null,components:function(){return this.getPath("content.components")}.property(),_inBoundsScaling:null,inBoundsScaling:function(){return this._inBoundsScaling}.property(),setInBoundsScaleFactor:function(a){if(this._inBoundsScaling&&a){this._inBoundsScaling.scaleFactor=a}},setInBoundsScaleBounds:function(b,a){if(this._inBoundsScaling&&b&&a){this._inBoundsScaling.scaleBoundsX=b;this._inBoundsScaling.scaleBoundsY=a}},setInBoundsScaling:function(a,c,b){if(!this._inBoundsScaling){this._inBoundsScaling={scaleFactor:a,scaleBoundsX:c,scaleBoundsY:b}}else{this.setInBoundsScaleFactor(a);this.setInBoundsScaleBounds(c,b)}},dataInteractives:function(){var b=this.get("componentControllersMap"),a=[];if(b){DG.ObjectMap.forEach(b,function(d,c){var e=c.getPath("model.type");if(e==="DG.GameView"){a.push(c)}})}return a}.property("componentControllersMap"),componentControllersMap:null,_singletonViews:null,tableCardRegistry:DG.TableCardRegistry.create(),ready:true,guideMenuPane:null,guideButton:null,_guideModel:null,guideModel:function(){if(!this._guideModel){this._guideModel=DG.GuideModel.create()}return this._guideModel}.property(),_guideController:null,guideController:function(){if(!this._guideController){this._guideController=DG.GuideController.create({guideModel:this.get("guideModel")})}return this._guideController}.property(),_caseTableComponents:null,getCaseTableComponent:function(f,e,d){if(SC.none(this._caseTableComponents)){this._caseTableComponents={}}var a=e&&e.get("id");var c=f||this._caseTableComponents[a];var b;if(SC.none(c)){b=DG.CaseTableModel.create({context:e});d.document=this.content;d.type="DG.TableView";c=DG.Component.createComponent(d);c.set("content",b)}this._caseTableComponents[a]=c;return c},documentID:function(){return this.getPath("content.id")}.property(),documentIDDidChange:function(){this.notifyPropertyChange("documentID")}.observes("*content.id"),documentName:function(a,c){var b=this.get("content");if(!b){return}if(c!==undefined){b.set("name",c);DG.store.commitRecords()}return b.get("name")}.property(),documentNameDidChange:function(){this.notifyPropertyChange("documentName")}.observes("*content.name"),setPageTitle:function(){if((DG.get("componentMode")==="yes")||(DG.get("embeddedMode")==="yes")){return}var a=this.get("documentName");if(SC.empty(a)){a="DG.Document.defaultDocumentName".loc()}var b="DG.main.page.title".loc(a,DG.USER_APPNAME);$("title").text(b)}.observes("documentName"),sharedMetadata:function(c,b){if(b!==undefined){var d=this.getPath("content.metadata"),a=$.extend(true,{},b);if(d!=null){d.shared=a}else{this.setPath("content.metadata",{shared:a})}this.setPath("content._permissions",a._permissions||0);return this}return this.getPath("content.metadata.shared")}.property(),changeCount:0,savedChangeCount:0,_changedObjects:null,_skipPatchNextTime:[],dataInteractiveLogMonitor:null,init:function(){arguments.callee.base.apply(this,arguments);this._singletonViews={};this.tableCardRegistry=DG.TableCardRegistry.create();this.contexts=[];this.dataInteractiveLogMonitor=SC.Object.create({logMonitors:[],nextLogMonitorId:1});this.clearChangedObjects();this.setDocument(this.get("content")||this.createDocument());if(DG.KEEP_IN_BOUNDS_PREF){this.setInBoundsScaling(1,0,0)}},destroy:function(){this.closeDocument();arguments.callee.base.apply(this,arguments)},createDocument:function(a){var b=DG.Document.createDocument({name:a||SC.String.loc("DG.Document.defaultDocumentName"),isNewDocument:true});if(SC.none(a)){b.set("_isPlaceholder",true)}return b},setDocument:function(a){try{this.set("ready",false);this.set("content",a);if(DG.mainPage.mainPane.hideInspectorPicker){DG.mainPage.mainPane.hideInspectorPicker()}DG.Component.clearContentMap();this.componentControllersMap={};this._caseTableComponents={};this.notificationManager=DG.NotificationManager.create({});this.restoreDataContexts();if(!a.isNewDocument){this.updateGuideFromURL()}SC.run(function(){this.restoreComponentControllersAndViews()}.bind(this));this.clearChangedObjects();this.set("changeCount",0);this.updateSavedChangeCount();this.set("ready",true);this.invokeLater(function(){DG.RemoteBoundaries.registerDefaultBoundaries()})}catch(b){DG.logError(b)}},hasUnsavedChanges:function(){return this.get("changeCount")>this.get("savedChangeCount")}.property("changeCount","savedChangeCount"),updateSavedChangeCount:function(){this.dataInteractives().forEach(function(a){a.updateSavedChangeCount()});this.set("savedChangeCount",this.get("changeCount"))},objectChanged:function(b){var a=this.get("_changedObjects");if(a.indexOf(b)===-1){a.push(b);this.set("_changedObjects",a)}},clearChangedObjects:function(){this.set("_changedObjects",[])},clearChangedObject:function(c){var b=this.get("_changedObjects");var a=b.indexOf(c);if(a!==-1){b.splice(a,1);this.set("_changedObjects",b)}},objectHasUnsavedChanges:function(b){var a=this.get("_changedObjects");return a.indexOf(b)!==-1},getComponentControllerForModel:function(a){var b=a&&a.get("id");return b&&this.componentControllersMap[b]},createDataContextForModel:function(b,c){if(SC.none(b)){b=DG.DataContextRecord.createContext({document:this.get("documentID")})}if(!c){c={}}c.type=b.get("type");c.model=b;var a=DG.DataContext.factory(c);this.get("contexts").pushObject(a);this.propertyDidChange("contextsLength");return a},destroyDataContext:function(c){var a=this.getContextByID(c);var b=this.contexts.findIndex(function(d){return d===a});if(a){if(b>=0){a.applyChange({operation:"deleteDataContext"});this.contexts.splice(b,1);this.propertyDidChange("contextsLength");this.tableCardRegistry.deregisterViews(c);this.notificationManager.sendNotification({action:"notify",resource:"documentChangeNotice",values:{operation:"dataContextDeleted",deletedContext:a.get("name")}},function(d){DG.log("Sent notification for deletion of context "+c);DG.log("Response: "+JSON.stringify(d))})}else{DG.logWarn("Attempt to destroy data context %@. Not known to document".loc(c))}}else{return false}},restoreDataContexts:function(){var a=this.get("contextRecords")||[];DG.ObjectMap.forEach(a,function(b,c){var d=this.createDataContextForModel(c);if(d){d.restoreFromStorage(c.get("contextStorage"))}}.bind(this))},createNewDataContext:function(c){var a=DG.DataContextRecord.createContext(c),b=this.createDataContextForModel(a);if(a.contextStorage){b.restoreFromStorage(a.contextStorage)}return b},createComponentAndView:function(a,f,d){var h=DG.mainPage.get("docView"),g=(a&&a.get("type"))||f,b=null,c=!(d&&d.initiatedViaCommand);try{switch(g){case"DG.FlashView":if(a){a.set("type","DG.GameView")}case"DG.GameView":b=this.addGame(h,a,c);break;case"DG.TableView":if(a&&a.componentStorage&&a.componentStorage._links_){b=this.addCaseTable(h,a)}else{b=this.openCaseTablesForEachContext()}break;case"DG.CaseCard":b=this.addCaseCard(h,null,null,a);break;case"DG.GraphView":b=this.addGraph(h,a,c,d);break;case"DG.SliderView":b=this.addSlider(h,a,c);break;case"DG.Calculator":this.toggleComponent(h,"calcView",a);b=this._singletonViews.calcView;break;case"DG.TextView":b=this.addText(h,a,c);break;case"DG.MapView":b=this.addMap(h,a,c);break;case"SC.WebView":case"DG.WebView":b=this.addWebView(h,a,null,null,null,c);break;case"DG.ImageComponentView":b=this.addImageView(h,a,null,null,null,c);break;case"DG.GuideView":b=this.addGuideView(h,a,c);break;default:break}}catch(i){DG.logError(i)}if(a){a.didLoadRecord()}return b},restoreComponentControllersAndViews:function(){var a=this.get("components");if(a){if(DG.KEEP_IN_BOUNDS_PREF){this.setInBoundsScaling(1,0,0);this.computeScaleBounds();if(Object.keys(a).length){this.computeScaleFactor()}}DG.ObjectMap.forEach(a,function(c,b){this.createComponentAndView(b)}.bind(this))}},enforceViewBounds:function(){this.computeScaleFactor();DG.ObjectMap.forEach(this.componentControllersMap,function(c,b){if(b){var a=b.get("view");if(a&&!a.get("isStandaloneComponent")){a.enforceViewBounds()}}})},computeScaleBounds:function(b){var d=this.get("components");if(d){var e={x:0,y:0},a=this.get("inBoundsScaling").scaleFactor,c=a?a:1;if(c===1){if(b){e.x=Math.max(e.x,b.x+b.width);e.y=Math.max(e.y,b.y+b.height)}DG.ObjectMap.forEach(d,function(i,f){if(f.type!=="DG.GuideView"||!this.guideViewHidden()){if(f.get("isVisible")&&f.layout&&((f.layout.left!=null)&&(f.layout.width!=null)&&(f.layout.top!=null)&&(f.layout.height!=null))){var k={width:0,height:0};var h=DG.currDocumentController().componentControllersMap[f.get("id")];if(h){var g=h.get("view");if(g){k=g.getInspectorDimensions()}}var j=(f.layout.left+f.layout.width);if(k.width){j+=k.width}var l=(f.layout.top+f.layout.height);if(k.height&&k.height>f.layout.height){l=f.layout.top+k.height}e.x=Math.max(e.x,j);e.y=Math.max(e.y,l)}}}.bind(this));this.setInBoundsScaleBounds(e.x,e.y)}}},computeScaleFactor:function(){var e=DG.mainPage.get("docView"),g=$("#codap").width(),f=$("#codap").height(),a=this.get("inBoundsScaling"),c=a.scaleBoundsX,b=a.scaleBoundsY,d=1;if(!SC.none(e)){while(!SC.none(e.parentView.parentView)){e=e.parentView}f-=e.get("frame").y}if(g<c||f<b){d=Math.min(g/c,f/b)}this.setInBoundsScaleFactor(d)},collectionDefaults:function(){var c=this.get("contexts"),b=null;if(c.length===1){b=c[0]}else{c=c.filter(function(e){var d=this.tableCardRegistry.getViewForContext(e);return d&&d.get("isVisible")}.bind(this));if(c.length===1){b=c[0]}}var a=(b&&b.collectionDefaults())||DG.DataContext.collectionDefaults();a.dataContext=b;return a},registerComponent:function(a){var c=this.get("components");var b=a.get("id");if(SC.none(c[b])){c[b]=a}},configureComponent:function(a,c){var e=!SC.none(a),b=this.get("documentID"),g=a,f=c.controller;if(!e){var d={type:c.componentClass.type,id:c.contentProperties.id};if(!SC.none(this.content)){d.document=this.content}g=DG.Component.createComponent(d);if(!SC.none(c.isResizable)){g.set("isResizable",c.isResizable)}}else{this.registerComponent(g)}if(c.contentProperties&&c.contentProperties.model){g.set("content",c.contentProperties.model)}f.set("model",g);this.componentControllersMap[g.get("id")]=f;if(e){f.didRestoreComponent(b)}return g},createComponentView:function(i,e){var f=$.extend({},e,{layout:$.extend(true,{},e.defaultLayout)}),g=!SC.none(i),d,h;DG.globalEditorLock.commitCurrentEdit();d=this.configureComponent(i,e);f.model=d;var j=d.get("layout");if(d&&j&&Object.keys(j).length>0){f.layout=$.extend(true,{},j)}if(g){var b=i.getPath("componentStorage.title");var c=i.getPath("componentStorage.name");i.set("title",b||c);if(c){i.set("name",c)}if(DG.isStandaloneComponent(i.get("name")||i.get("title"),i.get("type"))){f.useLayout=true;f.layout={};f.isStandaloneComponent=true}h=DG.ComponentView.restoreComponent(f)}else{DG.sounds.playCreate();if(DG.isStandaloneComponent(e.name,e.componentClass.type)){f.isStandaloneComponent=true}h=DG.ComponentView.addComponent(f);var a=h&&h.getPath("contentView.defaultFirstResponder");d.set("title",e.title||e.name);d.set("name",e.name||e.title);if(a){if(a.beginEditing){a.beginEditing()}else{if(a.becomeFirstResponder){a.becomeFirstResponder()}}}}if(h){if(e.controller){e.controller.set("view",h)}d.set("layout",h.get("layout"))}return h},addGame:function(c,k,a){function j(n){if(!n){return}var m=document.createElement("a");m.href=n;var o=m.pathname.split("/").slice(-1)[0].split(".");return o[0]}var h={width:300,height:200},e=k&&k.layout,d=e&&!SC.none(e.isVisible)?e.isVisible:true,f=e&&e.zIndex,g=k&&k.getPath("componentStorage.currentGameUrl"),i=DG.finalGameUrl(g),b=(k&&k.getPath("componentStorage.currentGameName"))||j(i)||"Unknown Game",l;if(!DG.STANDALONE_MODE&&k.get("type")==="DG.GameView"&&k.layout&&!k.layout.width){k.layout.width=h.width;k.layout.height=h.height}DG.UndoHistory.execute(DG.Command.create({name:"game.create",undoString:"DG.Undo.game.add",redoString:"DG.Redo.game.add",log:'addGame: {name: "%@", url: "%@"}'.fmt(b,i),isUndoable:!a,_component:null,executeNotification:{action:"notify",resource:"component",values:{operation:"create game controller",type:"DG.WebView"}},execute:function(){var m=DG.GameController.create();l=DG.currDocumentController().createComponentView(k||this._component,{parentView:c,controller:m,componentClass:{type:"DG.GameView",constructor:DG.GameView},contentProperties:{controller:m,value:i,model:DG.DataInteractiveModel.create({title:b})},defaultLayout:{width:h.width,height:h.height},position:k&&k.position,title:b,positionOnCreate:true});if(!d){l.set("isVisible",false)}else{if(!f){l.select()}}this._component=m.get("model")},undo:function(){var n=DG.currDocumentController().componentControllersMap[this._component.get("id")],m=n.get("view");n.willSaveComponent();m.parentView.removeComponentView(m)}}));return l},addCaseTable:function(c,i,j){function k(l){var m=DG.ArchiveUtils.getLinkID(l.componentStorage,"context");if(m){return DG.currDocumentController().get("contexts").find(function(n){return n.get("id")===m})}}if(SC.none(j)){j={}}var a=j.dataContext||k(i);var f=this.tableCardRegistry.getViewForContext(a);var h=this.getCaseTableComponent(i,a,j);var e=h.get("content")||DG.CaseTableModel.create({context:a});if(!f){var d=DG.CaseTableController.create(j);var b={type:"DG.TableView",constructor:DG.HierTableView};var g={parentView:c,controller:d,componentClass:b,contentProperties:{model:e,id:j.id},defaultLayout:{width:500,height:200},useLayout:j.useLayout,position:i?i.position:j.position};f=this.createComponentView(h,g);if(i&&i.layout&&!i.layout.isVisible){f.savedLayout=i.layout}}else{f.set("isVisible",true)}if(f.get("isVisible")){e.set("isActive",true)}this.tableCardRegistry.registerView(a,f);return f},openCaseTablesForEachContext:function(){var b=this,a={};DG.UndoHistory.execute(DG.Command.create({name:"caseTable.display",undoString:"DG.Undo.caseTable.open",redoString:"DG.Redo.caseTable.open",log:"Create caseTable component",executeNotification:{action:"notify",resource:"component",values:{operation:"open case table",type:"DG.CaseTable"}},execute:function(){var c;b.contexts.forEach(function(d){c=this.addCaseTable(DG.mainPage.get("docView"),null,{dataContext:d,id:a[d]});a[d]=c.getPath("controller.model.id")}.bind(b));if(a.length===0){this.causedChange=false}},undo:function(){var d,c,e;DG.ObjectMap.forEach(a,function(f,g){c=b.componentControllersMap[g];d=c.get("view");e=d.parentView;e.removeComponentView(d)})}}));return Object.values(a)},addGraph:function(h,a,e,d){var c,g=this,b=d&&d.layout,f=a&&a.size?a.size:(b?b:{width:300,height:300});d=(d&&d.componentStorage)||(a&&a.componentStorage);DG.UndoHistory.execute(DG.Command.create({name:"graphComponent.create",undoString:"DG.Undo.graphComponent.create",redoString:"DG.Redo.graphComponent.create",executeNotification:DG.UndoHistory.makeComponentNotification("create","graph"),undoNotification:DG.UndoHistory.makeComponentNotification("delete","graph"),log:"Create graph component",_component:null,isUndoable:!e,execute:function(){var i=DG.DataContext.contextIDs(null),j=DG.GraphController.create();if((SC.none(a)&&SC.none(this._component)||!(d&&d.dataContext))&&DG.ObjectMap.length(i)===1){j.set("dataContext",g.getContextByID(i[0]))}else{if(d&&d.dataContext){j.set("dataContext",d.dataContext)}}c=g.createComponentView(a,{parentView:h,controller:j,componentClass:{type:"DG.GraphView",constructor:DG.GraphView},contentProperties:{model:DG.GraphModel.create({initialDataContext:d&&d.dataContext,xAttributeName:d&&d.xAttributeName,yAttributeName:d&&d.yAttributeName,y2AttributeName:d&&d.y2AttributeName,legendAttributeName:d&&d.legendAttributeName,enableNumberToggle:d&&d.enableNumberToggle,numberToggleLastMode:d&&d.numberToggleLastMode,enableMeasuresForSelection:d&&d.enableMeasuresForSelection})},defaultLayout:f,position:a&&a.position});this._component=c.getPath("controller.model");this.executeNotification.values.id=this.undoNotification.values.id=c.getPath("controller.model.id")},undo:function(){var i=DG.currDocumentController().componentControllersMap[this._component.get("id")].get("view");i.parentView.removeComponentView(i)}}));return c},addText:function(e,a,c){var b,d=this;DG.UndoHistory.execute(DG.Command.create({name:"textComponent.create",undoString:"DG.Undo.textComponent.create",redoString:"DG.Redo.textComponent.create",log:"Create text component",isUndoable:!c,_component:null,executeNotification:DG.UndoHistory.makeComponentNotification("create","text"),undoNotification:DG.UndoHistory.makeComponentNotification("delete","text"),execute:function(){b=d.createComponentView(a||this._component,{parentView:e,controller:DG.TextComponentController.create(),componentClass:{type:"DG.TextView",constructor:DG.TextView},contentProperties:{hint:"Type some notes here…",model:DG.TextModel.create({})},defaultLayout:{width:300,height:100},position:a&&a.position,title:"DG.DocumentController.textTitle".loc()});this._component=b.getPath("controller.model")},undo:function(){var g=DG.currDocumentController().componentControllersMap[this._component.get("id")],f=g.get("view");g.willSaveComponent();f.parentView.removeComponentView(f)}}));return b},addMap:function(e,a,c){var b,d=this;DG.UndoHistory.execute(DG.Command.create({name:"map.create",undoString:"DG.Undo.map.create",redoString:"DG.Redo.map.create",log:"Create map component",isUndoable:!c,_component:null,executeNotification:DG.UndoHistory.makeComponentNotification("create","map"),undoNotification:DG.UndoHistory.makeComponentNotification("delete","map"),execute:function(){var g=(a&&a.componentStorage)?{legendAttributeName:a.componentStorage.legendAttributeName,context:a.componentStorage.context}:{},h=DG.MapModel.create(g),f=DG.MapController.create();b=d.createComponentView(a||this._component,{parentView:e,controller:f,componentClass:{type:"DG.MapView",constructor:DG.MapView},contentProperties:{model:h},defaultLayout:{width:530,height:360},position:a&&a.position,title:"DG.DocumentController.mapTitle".loc()});this._component=b.getPath("controller.model")},undo:function(){var f=DG.currDocumentController().componentControllersMap[this._component.get("id")].get("view");f.parentView.removeComponentView(f)}}));return b},addSlider:function(e,a,c){var b,d=this;DG.UndoHistory.execute(DG.Command.create({name:"sliderComponent.create",undoString:"DG.Undo.sliderComponent.create",redoString:"DG.Redo.sliderComponent.create",log:"Create slider component",isUndoable:!c,_global:null,_componentId:null,executeNotification:DG.UndoHistory.makeComponentNotification("create","slider"),undoNotification:DG.UndoHistory.makeComponentNotification("delete","slider"),execute:function(){var g=a&&(a.componentStorage.name||a.componentStorage.title);this._global=this._global||(a&&a.componentStorage&&DG.store.find(DG.GlobalValue,DG.ArchiveUtils.getLinkID(a.componentStorage,"model")))||d.createGlobalValue({name:g});if(!DG.globalsController.getGlobalValueByID(Number(this._global.get("id")))){DG.globalsController.registerGlobalValue(this._global)}var f=DG.SliderModel.create({content:this._global});b=d.createComponentView(a,{parentView:e,controller:DG.SliderController.create(),componentClass:{type:"DG.SliderView",constructor:DG.SliderView},contentProperties:{id:this._componentId,model:f},defaultLayout:{width:300,height:98},position:a&&a.position,isResizable:{width:true,height:false}});this._componentId=b.getPath("controller.model.id")},undo:function(){var g=DG.currDocumentController().componentControllersMap[this._componentId];var f=g.get("view");f.parentView.removeComponentView(f);DG.globalsController.destroyGlobalValue(this._global)}}));return b},addCalculator:function(c,a){var b=this.createComponentView(a,{parentView:c,controller:DG.ComponentController.create(),componentClass:{type:"DG.Calculator",constructor:DG.Calculator},contentProperties:{},defaultLayout:{},position:a&&a.position,title:"DG.DocumentController.calculatorTitle".loc(),isResizable:{width:false,height:false}});this._singletonViews.calcView=b;return b},addCaseCard:function(e,l,o,p,n){function b(){return DG.mainPage.getPath("docView.childViews").find(function(r){return r.contentIsInstanceOf&&r.contentIsInstanceOf(DG.CaseCardView)&&r.getPath("contentView.context")===o})}var d=o&&this.tableCardRegistry.getTableView(o);var f=b();if(f){return f}var k=!(p||f);var q=DG.CaseCardController.create({dataContext:o}),c=n||(o?o.get("name"):"DG.DocumentController.caseCardTitle".loc()),j=p,i=l||{};if(!j){j=this.configureComponent(p,{controller:q,componentClass:{type:"DG.CaseCard"},contentProperties:{}});j.set("content",DG.CaseCardModel.create({context:o}));j.set("title",c)}else{var g=j.getPath("componentStorage.title"),h=j.getPath("componentStorage.name");i=j.get("layout");j.set("content",DG.CaseCardModel.create({context:o}));j.set("title",g||h);if(h){j.set("name",h)}q.set("model",j);this.componentControllersMap[j.get("id")]=q;q.didRestoreComponent(this.get("documentID"));o=q.get("dataContext")}var m=DG.ComponentView.create({layout:i,isVisible:!SC.none(i.isVisible)?i.isVisible:true,showTitleBar:true}),a=DG.CaseCardView.create({classNames:"dg-opaque".w(),model:j.get("content"),isSelectedCallback:function(){return m.get("isSelected")}});m.set("model",j);e.appendChild(m);m.addContent(a);m.set("contentView",a);m.set("controller",q);if(k&&!d){e.positionNewComponent(m)}q.set("view",m);this.registerComponent(j);if(m.get("isVisible")){j.setPath("content.isActive",true)}this.tableCardRegistry.registerView(o,m);return m},viewWebPage:function(){var b=null;function a(){var c=b.get("value");b.close();if(!/^https?:\/\//i.test(c)){c="http://"+c}DG.appController.importURL(c,"DG.WebView",c)}b=DG.CreateSingleTextDialog({prompt:"DG.DocumentController.enterURLPrompt",textValue:"",textHint:"URL",okTarget:null,okAction:a,okTooltip:"DG.DocumentController.enterViewWebPageOKTip"})},addWebView:function(g,b,f,a,e,d){f=f||"";a=a||"";e=e||{width:600,height:400};var c;DG.UndoHistory.execute(DG.Command.create({name:"webView.show",undoString:"DG.Undo.webView.show",redoString:"DG.Redo.webView.show",log:'Show webView: {title: "%@", url: "%@"}'.fmt(a,f),isUndoable:!d,_component:null,model:SC.Object.create({defaultTitle:a,URL:f}),executeNotification:DG.UndoHistory.makeComponentNotification("create","webView"),undoNotification:DG.UndoHistory.makeComponentNotification("delete","webView"),execute:function(){c=DG.currDocumentController().createComponentView(b||this._component,{parentView:g,controller:DG.WebViewController.create({model:this.model}),componentClass:{type:"DG.WebView",constructor:DG.WebView},contentProperties:{value:f,backgroundColor:"white",model:this.model},defaultLayout:e,position:b&&b.position,title:a,useLayout:!SC.none(e.centerX)||!SC.none(e.left)});this._component=c.getPath("controller.model")},undo:function(){var h=DG.currDocumentController().componentControllersMap[this._component.get("id")].get("view");h.parentView.removeComponentView(h)}}));return c},addImageView:function(g,b,f,a,e,d){f=f||"";a=a||f||"";e=e||{width:600,height:400};var c;DG.UndoHistory.execute(DG.Command.create({name:"webView.show",undoString:"DG.Undo.imageComponent.show",redoString:"DG.Redo.imageComponent.show",log:'Show webView: {title: "%@", url: "%@"}'.fmt(a,f),isUndoable:!d,_component:null,model:SC.Object.create({defaultTitle:a||"DG.ImageComponent.defaultTitle".loc(),URL:f}),executeNotification:DG.UndoHistory.makeComponentNotification("create","imageComponent"),undoNotification:DG.UndoHistory.makeComponentNotification("delete","imageComponent"),execute:function(){c=DG.currDocumentController().createComponentView(b||this._component,{parentView:g,controller:DG.ImageComponentController.create({model:this.model}),componentClass:{type:"DG.ImageComponentView",constructor:DG.ImageComponentView},contentProperties:{value:f,backgroundColor:"white",model:this.model},defaultLayout:e,position:b&&b.position,title:a,useLayout:true});this._component=c.getPath("controller.model")},undo:function(){var h=DG.currDocumentController().componentControllersMap[this._component.get("id")].get("view");h.parentView.removeComponentView(h)}}));return c},addGuideView:function(f,a,c){if(this._singletonViews.guideView){DG.UndoHistory.execute(DG.Command.create({name:"guide.show",undoString:"DG.Undo.guide.show",redoString:"DG.Redo.guide.show",log:"Show guide",isUndoable:!c,execute:function(){DG.currDocumentController()._singletonViews.guideView.set("isVisible",true)},undo:function(){DG.currDocumentController()._singletonViews.guideView.set("isVisible",false)}}))}else{var d=this.get("guideModel"),e=this.get("guideController"),b=this.createComponentView(a,{parentView:f,controller:e,componentClass:{type:"DG.GuideView",constructor:DG.GuideView},contentProperties:{backgroundColor:"white",guideModel:d,model:d,controller:e,closeAction:{action:this.closeGuideView,target:this}},defaultLayout:{width:400,height:200},position:a&&a.position,useLayout:true});this._singletonViews.guideView=b}return this._singletonViews.guideView},closeGuideView:function(){var a=this._singletonViews.guideView;if(a){a.set("isVisible",false)}},guideViewHidden:function(){var b=this._singletonViews.guideView,a=false;if(b){a=!b.get("isVisible")}return a},configureGuide:function(){var d=this,c=null,b=this.get("guideModel"),a=function(){DG.UndoHistory.execute(DG.Command.create({name:"guide.configure",undoString:"DG.Undo.guide.configure",redoString:"DG.Redo.guide.configure",log:"Show guide",changedObject:b,_oldValues:{title:b.get("title"),items:b.get("items"),currentItemIndex:b.get("currentItemIndex")},_newValues:{title:c.get("title"),items:c.get("items")},execute:function(){if(c){DG.currDocumentController().addGuideView(DG.mainPage.docView)}b.beginPropertyChanges();b.set("title",this._newValues.title);b.set("items",this._newValues.items);b.endPropertyChanges();if(c){c.close();c=null}if(!SC.empty(this._newValues.title)||this._newValues.items.length!==0){d._singletonViews.guideView.set("isVisible",true)}},undo:function(){b.beginPropertyChanges();b.set("title",this._oldValues.title);b.set("items",this._oldValues.items);b.set("currentItemIndex",this._oldValues.currentItemIndex);b.endPropertyChanges();if(SC.empty(this._oldValues.title)&&this._oldValues.items.length===0){d._singletonViews.guideView.set("isVisible",false)}}}))};c=DG.CreateGuideConfigurationView({okTarget:null,okAction:a,model:b})},guideButtonOrMenuDidChange:function(){var c=this.get("guideButton"),b=this.get("guideMenuPane");if(c&&b){var a=this.get("guideController");a.set("guideButton",c);a.set("guideMenuPane",b)}}.observes("guideButton","guideMenuPane"),toggleComponent:function(c,b,a){var e=this._singletonViews[b],d;if(e){DG.UndoHistory.execute(DG.Command.create({name:"component.toggle.delete",undoString:"DG.Undo.toggleComponent.delete."+b,redoString:"DG.Redo.toggleComponent.delete."+b,log:"Remove toggle component: %@".fmt(b),executeNotification:DG.UndoHistory.makeComponentNotification("hide",b),undoNotification:DG.UndoHistory.makeComponentNotification("show",b),execute:function(){d=this._archiveComponent(b);this._deleteComponent(b)}.bind(this),undo:function(){this._addCalcComponent(b,c,d)}.bind(this),redo:function(){this._deleteComponent(b)}.bind(this)}))}else{DG.UndoHistory.execute(DG.Command.create({name:"component.toggle.add",undoString:"DG.Undo.toggleComponent.add."+b,redoString:"DG.Redo.toggleComponent.add."+b,log:"Add toggle component: %@".fmt(b),executeNotification:DG.UndoHistory.makeComponentNotification("show",b),undoNotification:DG.UndoHistory.makeComponentNotification("hide",b),execute:function(){this._addCalcComponent(b,c,a)}.bind(this),undo:function(){d=this._archiveComponent(b);this._deleteComponent(b)}.bind(this),redo:function(){this._addCalcComponent(b,c,d)}.bind(this)}))}},toggleTableToCard:function(b){var a=200,g=400,h=b.getPath("controller.dataContext"),e=b.getPath("model.cannotClose"),f=b.get("layout"),c={top:f.top,left:f.left,width:a,height:DG.ViewUtilities.kTitleBarHeight},i={height:g},d;b.set("savedLayout",f);b.animate({width:a},{duration:0.3,timing:"ease-in-out"});this.invokeLater(function(){b.animate({height:DG.ViewUtilities.kTitleBarHeight},{duration:0.3,timing:"ease-in-out"})},300);this.invokeLater(function(){b.set("isVisible",false);f.isVisible=false;b.set("layout",f);b.setPath("model.content.isActive",false);d=this.tableCardRegistry.getCardView(h)||this.addCaseCard(b.get("parentView"),c,h,null,b.get("title"));d.setPath("model.cannotClose",e);d.set("layout",c);var j=d.get("savedLayout")||i;if(!d.get("savedLayout")){d.set("savedLayout",j)}d.set("isVisible",true);d.select();d.setPath("model.content.isActive",true);this.tableCardRegistry.registerView(h,d)}.bind(this),600)},toggleCardToTable:function(c){var e=200,b=c.get("layout"),f=c.getPath("model.cannotClose"),d={top:b.top,left:b.left,width:e,height:DG.ViewUtilities.kTitleBarHeight},a=c.getPath("controller.dataContext");c.set("isAnimating",true);c.set("savedLayout",b);c.animate({width:e},{duration:0.3,timing:"ease-in-out"},function(){c.animate({height:DG.ViewUtilities.kTitleBarHeight},{duration:0.3,timing:"ease-in-out"},function(){c.set("isVisible",false);c.set("isAnimating",false);b.isVisible=false;c.set("layout",b);c.setPath("model.content.isActive",false);var i=this.tableCardRegistry.getTableView(a)||this.addCaseTable(c.get("parentView"),null,{dataContext:c.getPath("controller.dataContext"),useLayout:true}),h=i.get("savedLayout")||{width:500,height:200},g={left:h.left,top:h.top,width:h.width,height:h.height};i.setPath("model.cannotClose",f);i.set("layout",d);i.set("isVisible",true);g.height++;i.animate(g,{duration:0.3,timing:"ease-in-out"},function(){SC.run(function(){i.select();g.height--;i.adjust("height",g.height);this.invokeNext(function(){i.get("contentView").scrollSelectionToView()}.bind(this))}.bind(this))});i.setPath("model.content.isActive",true);this.tableCardRegistry.registerView(a,i)}.bind(this))}.bind(this))},_addCalcComponent:function(c,e,f){var a=f&&f.get("id"),b=DG.store.find(a),d=(b&&b===f)?b:(f?DG.Component.createComponent(f):null);switch(c){case"calcView":this.addCalculator(e,d);break}},_archiveComponent:function(a){var b=this._singletonViews[a].getPath("controller.model"),c=b.toArchive();c.document=b.get("document");return c},_deleteComponent:function(a){var b=this._singletonViews[a];this.removeComponentAssociatedWithView(b);b.destroy()},closeDocument:function(){DG.globalsController.stopAnimation();DG.globalsController.reset();DG.mainPage.closeAllComponents();DG.ObjectMap.forEach(this.componentControllersMap,function(b,a){if(a&&a.willDestroy){a.willDestroy()}});this.closeAllComponents();DG.ObjectMap.forEach(this.componentControllersMap,function(b,a){if(a&&a.constructor!==DG.GuideController){a.destroy()}});this.componentControllersMap={};this.contexts=[];if(this.notificationManager){this.notificationManager.destroy();this.notificationManager=null}DG.Document.destroyDocument(DG.activeDocument);DG.UndoHistory.clearUndoRedoHistory()},closeAllComponents:function(){this._singletonViews={};this.tableCardRegistry.reset();if(this._guideController){this._guideController.reset()}},findComponentsByType:function(b){var a=[];DG.ObjectMap.forEach(this.componentControllersMap,function(d,c){if(c.constructor===b&&c.getPath("view.isVisible")){a.push(c)}});return a},removeComponentAssociatedWithView:function(e){var d=null,a=DG.ObjectMap.findKey(this.componentControllersMap,function(g,f){if(f.view===e){d=f;return true}return false});var c=DG.ObjectMap.findValue(this._singletonViews,e);if(c&&this._singletonViews[c]){this._singletonViews[c]=null}if(d){var b=d.get("model");if(b){DG.Component.destroyComponent(b)}delete this.componentControllersMap[a];if(d.get("shouldDestroyOnComponentDestroy")){d.destroy()}else{d.set("model",null);d.set("view",null)}}},addFormulaObject:function(c,h,f,a,b,d,e,g){var i=this.createComponentView(h,{parentView:c,controller:DG.ComponentController.create({}),componentClass:{type:"DG.FormulaObject",constructor:DG.FormulaObject},contentProperties:{description:a,outputSymbol:b,nameSpaceSymbols:d,variableDescriptions:e,allow_user_variables:g},defaultLayout:{},position:h&&h.position,title:f,isResizable:true});return i},createGlobalValue:function(a){a=a||{};a.document=this.get("content");return DG.globalsController.createGlobalValue(a)},getContextByName:function(a){return this.contexts.find(function(b){return b.get("name")===a})},getContextByTitle:function(a){return this.contexts.find(function(b){return b.get("title")===a})},getContextByID:function(b){var a=Number(b);return this.contexts.find(function(c){return c.get("id")===a})},getComponentByName:function(a){var b=DG.ObjectMap.values(DG.currDocumentController().get("components"));return b.find(function(d){return d.get("name")===a})},getComponentByID:function(b){if(isNaN(b)){return}var a=DG.ObjectMap.values(DG.currDocumentController().get("components"));return a.find(function(d){return Number(d.get("id"))===Number(b)})},updateGuideFromURL:function(){var a=DG.get("initialGuideIndex");if(SC.empty(a)){return}DG.set("initialGuideIndex","");var c=this.get("components");var d=Object.keys(c).find(function(f){var e=c[f];return e.type==="DG.GuideView"});var b=d&&c[d];if(b&&!Number.isNaN(a)){b.componentStorage.isVisible=true;b.componentStorage.currentItemIndex=Number(a)}},captureCurrentDocumentState:function(b){var d=this.get("dataInteractives"),c=[],a;if(d){d.forEach(function(e){c.push(new Promise(function(h,g){try{if(e.saveGameState){e.saveGameState(function(i){if(!(i&&i.success)){DG.log("Unable to retrieve plugin state");i={success:false}}h(i)})}else{h({success:true})}}catch(f){DG.logWarn("Exception saving game context: "+f);h({success:false})}}))})}a=Promise.all(c).then(function(){DG.ObjectMap.forEach(this.componentControllersMap,function(f,e){e.willSaveComponent()});this.contexts.forEach(function(e){e.willSaveContext()});return Promise.resolve(this.get("content").toArchive(b))}.bind(this));return a}});DG.currDocumentController=function(){if(!DG._currDocumentController){DG._currDocumentController=DG.DocumentController.create();DG._currDocumentController.set("guideMenuPane",DG.appController.get("guideMenuPane"))}return DG._currDocumentController}.property();DG.dirtyCurrentDocument=function(a,c){if(!c){DG.UndoHistory.documentWasChanged()}if(SC.none(a)){a=DG.currDocumentController().get("content")}var d=function(){DG.currDocumentController().objectChanged(a);DG.currDocumentController().incrementProperty("changeCount")};var b=DG.currDocumentController().get("saveInProgress");if(!SC.none(b)){b.done(d)}else{d()}};DG.MenuItem=SC.MenuItemView.extend({init:function(){arguments.callee.base.apply(this,arguments)},displayProperties:["title","toolTip","isEnabled","icon","isSeparator","shortcut","isChecked","rightIcon"],renderImage:function(a,b){if(b&&SC.ImageView.valueIsUrl(b)){a.begin("img").addClass("image").setAttr("src",b).end()}else{a.begin("div").addClass(b).end()}},render:function(b){var a=this.getContentProperty("itemRightIconKey");arguments.callee.base.apply(this,arguments);if(a){this.renderRightIcon(b,a)}},renderRightIcon:function(d,f){var c=null;var e=null;var b=this.getContentProperty("itemRightToolTipKey");if(b){b=b.loc()}var a=["dg-right-icon"];if(f&&SC.ImageView.valueIsUrl(f)){c=f;e="";d.begin("img").addClass(a).setAttr("src",c).setAttr("title",b).end()}else{e=f;a.push(e);c=SC.BLANK_IMAGE_URL;d.begin("div").addClass(a).setAttr("title",b).end()}},mouseUp:function(b){var a=this.getPath("parentMenu.rootMenu.targetMenuItem"),c=this.getContentProperty("itemRightActionKey");if($(b.target).hasClass("dg-right-icon")&&c){this.performRightMenuAction()}else{if(a){a.performAction()}}return YES},performRightMenuAction:function(){var c=this.getContentProperty("itemRightActionKey"),d=this.getContentProperty("itemRightTargetKey"),b=this.getPath("parentMenu.rootMenu"),a;b.remove();b._isFlashing=NO;c=(c===undefined)?b.get("action"):c;d=(d===undefined)?b.get("target"):d;if(SC.typeOf(c)===SC.T_FUNCTION){c.apply(d,[b])}else{a=this.getPath("pane.rootResponder")||SC.RootResponder.responder;if(a){a.sendAction(c,d,b)}}}});sc_require("utilities/menu_item");DG.MenuPane=SC.MenuPane.extend({dgAction:null,exampleView:DG.MenuItem,getDesiredMenuWidth:function(){var b=0,a=6,c=60;this.get("items").forEach(function(e){if(!e){return}var d=0;if(e.title&&(typeof e.title==="string")){d=e.title.loc().length}if(e.rightIcon){d+=2}b=Math.max(b,d)});return b*a+c},selectedItemDidChange:function(){var c=this.get("selectedItem"),b=c.get("args")||[],a=c.get("dgAction");if(typeof a==="string"){a=c.target[a]||this[a]}if(a){a.apply(c.get("target"),b)}this.selectedItem=null}.observes("selectedItem"),popup:function(){this.adjust("width",this.getDesiredMenuWidth());arguments.callee.base.apply(this,arguments)},itemRightIconKey:"rightIcon",itemRightTargetKey:"rightTarget",itemRightActionKey:"rightAction",itemRightToolTipKey:"rightToolTip",menuItemKeys:["rightIcon","rightTarget","itemRightAction","itemTitleKey","itemValueKey","itemToolTipKey","itemIsEnabledKey","itemIconKey","itemSeparatorKey","itemActionKey","itemCheckboxKey","itemShortCutKey","itemHeightKey","itemSubMenuKey","itemKeyEquivalentKey","itemTargetKey","itemLayerIdKey"]});sc_require("controllers/document_helper");sc_require("controllers/document_controller");sc_require("utilities/menu_pane");sc_require("utilities/clipboard_utilities");DG.appController=SC.Object.create((function(){return{optionMenuPane:null,guideMenuPane:null,helpMenuPane:null,documentArchiver:DG.DocumentHelper.create({}),showCaseDisplayFor:function(b){function d(k){var j=g.componentControllersMap[k];var i=j.get("view");var l=i.parentView;l.removeComponentView(i)}function h(i){if(i){i.invokeLater(function(){i.showAndSelect()})}}var a=b.dataContext;var f=b.dgAction;var g=DG.currDocumentController();var e;var c;if(SC.none(a)&&f==="openCaseTableForNewContext"){DG.UndoHistory.execute(DG.Command.create({name:"dataContext.create",undoString:"DG.Undo.dataContext.create",redoString:"DG.Redo.dataContext.create",log:"createNewEmptyDataSet",isUndoable:false,execute:function(){a=DG.appController.createMinimalDataContext("DG.AppController.createDataSet.initialAttribute".loc(),"DG.AppController.createDataSet.name".loc());c=g.addCaseTable(DG.mainPage.get("docView"),null,{position:"top",dataContext:a});this.invokeLater(function(){c.setFocusToComponentTitle()},1000)},undo:function(){g.destroyDataContext(a.get("id"))},redo:function(){this.execute()}}))}else{if(SC.none(a)&&f==="openNewDataSetFromClipboard"){this.openNewDataSetFromClipboard()}else{e=g.tableCardRegistry.getViewForContext(a);if(e){h(e)}else{DG.UndoHistory.execute(DG.Command.create({name:"caseTable.open",undoString:"DG.Undo.caseTable.open",redoString:"DG.Redo.caseTable.open",log:'openCaseTable: {name: "%@"}'.fmt(a.get("name")),executeNotification:DG.UndoHistory.makeComponentNotification("create","table"),undoNotification:DG.UndoHistory.makeComponentNotification("delete","table"),execute:function(){c=g.addCaseTable(DG.mainPage.get("docView"),null,{position:"top",dataContext:a});h(c)},undo:function(){d(c.getPath("model.id"))},redo:function(){this.execute()}}))}}}return c&&c.controller},init:function(){arguments.callee.base.apply(this,arguments);SC.run(function(){this.tileMenuPane=DG.MenuPane.create({showTileList:function(a){this.set("items",DG.mainPage.mainPane.scrollView.contentView.get("tileMenuItems"));this.popup(a)},layout:{width:150},menuItemDidChange:function(){var b=this.getPath("currentMenuItem.content.target"),a=this.getPath("previousMenuItem.content.target");if(b){b.get("parentView").bringToFront(b);b.$().addClass("dg-component-view-staging");b.scrollToVisible()}if(a&&a!==b){a.$().removeClass("dg-component-view-staging")}}.observes("currentMenuItem","previousMenuItem"),willRemoveFromDocument:function(){var a=this.get("currentMenuItem"),b=this.get("previousMenuItem");if(a){a.getPath("content.target").$().removeClass("dg-component-view-staging")}if(b){b.getPath("content.target").$().removeClass("dg-component-view-staging")}}});this.caseTableMenuPane=DG.MenuPane.create({showMenu:function(a){this.set("items",DG.appController.get("caseTableMenuItems"));this.popup(a)},selectedItemDidChange:function(){DG.appController.showCaseDisplayFor(this.get("selectedItem"))}.observes("selectedItem"),itemLayerIdKey:"id",layout:{width:150}});this.pluginMenuPane=DG.MenuPane.create({init:function(){arguments.callee.base.apply(this,arguments);var a="../../../../static/dg/fr/cert/resources/json/hierarchical_plugins.json";if(!a){DG.logWarn("Plugin metadata URL absent.")}$.ajax(a,{dataType:"json",success:function(b){SC.run(function(){DG.set("pluginMetadata",b);this.set("items",DG.appController.get("pluginMenuItems"))}.bind(this))}.bind(this),error:function(){DG.logError("Plugin Metadata Get failed: "+a)}})},showMenu:function(a){this.popup(a)},openStandardPlugin:function(c){var a=DG.currDocumentController();var b=DG.Component.createComponent({type:"DG.GameView",document:a.get("content"),componentStorage:{currentGameName:c.title,currentGameUrl:c.url,allowInitGameOverride:true}});a.createComponentAndView(b)},selectedItemDidChange:function(){var a=this.get("selectedItem");if(a){this.openStandardPlugin(a);this.set("selectedItem",null)}}.observes("selectedItem"),itemLayerIdKey:"id",layout:{width:150}});this.optionMenuPane=DG.MenuPane.create({items:this.get("optionMenuItems"),itemLayerIdKey:"id",layout:{width:150}});this.guideMenuPane=SC.MenuPane.create({layout:{width:250}});this.helpMenuPane=DG.MenuPane.create({items:this.get("helpMenuItems"),itemLayerIdKey:"id",layout:{width:150}})}.bind(this));window.onbeforeunload=function(a){if(DG.currDocumentController().get("hasUnsavedChanges")&&(DG.get("embeddedMode")==="no")&&(DG.get("componentMode")==="no")){return"DG.AppController.beforeUnload.confirmationMessage".loc()}}},dataSetDeleteAgent:SC.Object.extend({deleteWithAlert:function(a){DG.AlertPane.warn({dataContext:this.dataContext,doDelete:function(){DG.currDocumentController().destroyDataContext(this.get("dataContext").get("id"))},message:"DG.TableController.deleteDataSet.confirmMessage".loc(this.get("dataContext").get("title")),description:"DG.TableController.deleteDataSet.confirmDescription".loc(),buttons:[{title:"DG.TableController.deleteDataSet.okButtonTitle",action:"doDelete",localize:YES},{title:"DG.TableController.deleteDataSet.cancelButtonTitle",localize:YES}],localize:false})}}),caseTableMenuItems:function(){var c=DG.currDocumentController();var b=c.get("contexts");var a=b.map(function(e){var d=c.tableCardRegistry.getActiveViewTypeForContext(e.get("id"));return{localize:false,title:e.get("title"),toolTip:"DG.AppController.caseTableMenu.openCaseTableToolTip",target:DG.appController,icon:d==="DG.CaseCard"?"tile-icon-card":"tile-icon-table",dataContext:e,rightIcon:"dg-trash-icon",rightTarget:this.dataSetDeleteAgent.create({dataContext:e}),rightAction:"deleteWithAlert",rightToolTip:"DG.AppController.caseTableMenu.deleteDataSetToolTip"}}.bind(this));a.push({localize:true,title:"DG.AppController.caseTableMenu.clipboardDataset",toolTip:"DG.AppController.caseTableMenu.clipboardDatasetToolTip",target:DG.appController,isEnabled:DG.ClipboardUtilities.canPaste(),dgAction:"openNewDataSetFromClipboard",icon:"tile-icon-table"});a.push({localize:true,title:"DG.AppController.caseTableMenu.newDataSet",toolTip:"DG.AppController.caseTableMenu.newDataSetToolTip",target:DG.mainPage,dgAction:"openCaseTableForNewContext",icon:"tile-icon-table"});return a}.property(),pluginMenuItems:function(){var c=DG.get("pluginURL");var d=DG.get("pluginMetadata");function a(e){return{localize:true,title:e["title-string"]?e["title-string"].loc():e.title,url:(e.path.includes("http")?"":c)+e.path,target:this,toolTip:e["description-string"]?e["description-string"].loc():e.description,dgAction:"openPlugin",dimensions:{width:e.width||400,height:e.height||300},icon:e.icon?(e.icon.includes("http")?"":c)+e.icon:"tile-icon-mediaTool",id:"dg-pluginMenuItem-"+e.title.replace(/ /g,"-")}}var b=d?d.map(function(e){return{localize:true,title:e["title-string"]?e["title-string"].loc():e.title,subMenu:e.subMenu.map(function(f){return a(f)})}}):[];return b}.property(),optionMenuItems:function(){return[{localize:true,title:"DG.AppController.optionMenuItems.viewWebPage",target:this,dgAction:"viewWebPage",id:"dg-optionMenuItem-view_webpage"},{localize:true,title:"DG.AppController.optionMenuItems.configureGuide",target:this,dgAction:"configureGuide",id:"dg-optionMenuItem-configure-guide"}]}.property(),helpMenuItems:function(){return[{localize:true,title:"DG.AppController.optionMenuItems.help",target:this,dgAction:"showHelpSite",id:"dg-optionMenuItem-help-website"},{localize:true,title:"DG.AppController.optionMenuItems.help-forum",target:this,dgAction:"showHelpForum",id:"dg-optionMenuItem-help-forum"},{localize:true,title:"DG.AppController.optionMenuItems.toWebSite",target:this,dgAction:"showWebSite",id:"dg-optionMenuItem-codap-website"},{localize:true,title:"DG.AppController.optionMenuItems.toPrivacyPage",target:this,dgAction:"showPrivacyPage",id:"dg-optionMenuItem-privacy-page"}]}.property(),openNewDataSetFromClipboard:function(){var a=this;window.focus();if(document.activeElement){document.activeElement.blur()}window.navigator.clipboard.readText().then(function(b){SC.run(function(){if(/^https?:\/\/[^\n]*$/.test(b)){a.importURL(b)}else{a.openCSVImporter({contentType:"text/csv",text:b,datasetName:"clipboard data",showCaseTable:true})}})},function(b){console.log("Error importing from clipboard: ",b)})},extractNameFromURLPath:function(b){function a(g){var f=document.createElement("a");f.href=g;return f}var c=a(b);if(c.protocol==="data:"){return"data"}var e=c.pathname;var d=e?e.replace(/\/$/,"").replace(/.*\//,"").replace(/\.[^.]*$/,"")||b:b;return d},importTextFromUrl:function(c,d,b){var a=b||this.extractNameFromURLPath(c);this.openCSVImporter({contentType:"text/csv",url:c,datasetName:a,showCaseTable:d})},importGeoJSONFromURL:function(b){var a=this.extractNameFromURLPath(b);this.openGeoJSONImporter({contentType:"application/geo+json",url:b,datasetName:a,showCaseTable:false})},openImporterPlugin:function(b,c,a){var d=DG.Component.createComponent({type:"DG.GameView",layout:{isVisible:false},document:DG.currDocumentController(),componentStorage:{currentGameName:b,currentGameUrl:DG.get("pluginURL")+c,savedGameState:a,title:b}});DG.currDocumentController().createComponentAndView(d)},openCSVImporter:function(a){this.openImporterPlugin("Importer","/Importer/",a)},openGeoJSONImporter:function(a){this.openImporterPlugin("Importer","/Importer/",a)},openHTMLImporter:function(a){this.openImporterPlugin("Importer","/Importer/",a)},openGoogleSheetsImporter:function(a){this.openImporterPlugin("Importer","/Importer/",a)},importCSVFromDataUri:function(a){if(a){var d=a.match(/^data:text\/csv;((base64),|(charset)=([^,]+),)?(.*)$/);if(d){var c=d[5];if(d[2]==="base64"){try{c=atob(c)}catch(b){c=null;DG.logWarn(b)}}else{while(c.match(/%[0-9a-f]{2}/i)){c=decodeURIComponent(c)}}if(c!==null){SC.run(function(){return this.importText(c,"Imported CSV")}.bind(this))}}}},createMinimalDataContext:function(g,j){var a,h,f=DG.currDocumentController(),b=j.replace(/.*[\\\/]/g,"").replace(/\.[^.]*/,""),c=b,d="DG.AppController.createDataSet.collectionName".loc(),e=1;while(f.getContextByName(c)||f.getContextByTitle(c)){c=b+" "+(++e)}h=DG.DataContextRecord.createContext({title:c,name:c,collections:[{name:d,attrs:[{name:g}]}],contextStorage:{}});a=f.createDataContextForModel(h);a.restoreFromStorage(h.contextStorage);return a},importText:function(d,a,c,b){this.openCSVImporter({contentType:"text/csv",text:d,datasetName:a,filename:c,showCaseTable:b});return true},importHTMLTable:function(a){this.openHTMLImporter({contentType:"text/html",text:a});return true},importGoogleSheets:function(b){var a={contentType:"application/vnd.google-apps.spreadsheet",url:b,showCaseTable:true};this.openGoogleSheetsImporter(a)},importImage:function(c,b){function e(f,h){var g=new Image();g.onload=function(){var i=g.height;var j=g.width;g=undefined;h(j,i)};g.src=f}var d=DG.currDocumentController();var a=b?b.slice(0,30):"";e(c,function(f,g){SC.run(function(){d.addImageView(DG.mainPage.get("docView"),null,c,a,{width:Math.min(f,480),height:Math.min(g+25,385)})})})},importURL:function(e,d,c){var a=function(){var h=DG.currDocumentController(),i;switch(d||"DG.GameView"){case"DG.GameView":i=DG.Component.createComponent({type:"DG.GameView",document:h.get("content"),componentStorage:{currentGameName:"",currentGameUrl:e,allowInitGameOverride:true}});h.createComponentAndView(i);break;case"DG.WebView":h.addWebView(DG.mainPage.get("docView"),null,e,"Web Page",{width:600,height:400});break}}.bind(this);var b=document.createElement("a");b.href=e;var g=b.protocol+b.host+b.pathname;var f=this.matchMimeSpec(g,d);if(!f){f={group:"UNKOWN",mime:["unkown"]}}DG.log('Opening url "%@" of type %@'.loc(e,f.mime[0]));if(f){switch(f.group){case"TEXT":this.importTextFromUrl(e,false,c);break;case"GEOJSON":this.importGeoJSONFromURL(e);break;case"JSON":DG.cfmClient.openUrlFile(e);break;case"IMAGE":this.importImage(e,c);break;case"SHEETS":this.importGoogleSheets(e);break;default:a()}}return true},importDrawToolWithDataURL:function(n,k){var i=600,a=400,b="DG.GameView",e={width:i,height:a},c=DG.get("drawToolPluginURL"),j="DG.DataDisplayMenu.imageOfTitle".loc(k),g=DG.currDocumentController(),d=DG.Component.createComponent({type:b,document:g.get("content"),layout:e,componentStorage:{currentGameName:j,currentGameUrl:c,allowInitGameOverride:true}}),h={initiatedViaCommand:true},m=g.createComponentAndView(d,b,h),f=m&&m.get("parentView"),l=m&&m.get("controller");if(f&&f.positionNewComponent){f.positionNewComponent(m,"top",true);this.invokeLater(function(){DG.currDocumentController().notificationManager.sendNotification({action:"notify",resource:"component",values:{operation:"resize",type:"DG.GameView",id:m.getPath("model.id"),title:"DrawTool"}})},1000)}if(l&&l.sendCommand){l.sendCommand({action:"update",resource:"backgroundImage",values:{image:n}})}},closeDocument:function(){DG.currDocumentController().closeDocument();DG.store=null},closeCurrentDocument:function(a){this.closeDocumentWithConfirmation(null)},closeDocumentWithConfirmation:function(a){var c=DG.currDocumentController().get("documentName");var d=function(){this.closeAndNewDocument(a);DG.logUser("closeDocument: '%@'",c)}.bind(this);var b=function(){DG.logUser("cancelCloseDocument: '%@'",c)};if(DG.currDocumentController().get("hasUnsavedChanges")){DG.logUser("confirmCloseDocument?: '%@'",c);DG.AlertPane.warn({message:"DG.AppController.closeDocument.warnMessage",description:"DG.AppController.closeDocument.warnDescription",buttons:[{title:"DG.AppController.closeDocument.okButtonTitle",action:d,localize:YES},{title:"DG.AppController.closeDocument.cancelButtonTitle",action:b,localize:YES}],localize:YES})}else{d()}},closeAndNewDocument:function(a){this.closeDocument();DG.currDocumentController().setDocument(DG.currDocumentController().createDocument())},mimeTypesAndExtensions:[{group:"TEXT",mime:["text/csv","application/csv"],extensions:["csv"]},{group:"TEXT",mime:["text/plain"],extensions:["txt"]},{group:"TEXT",mime:["text/tab-separated-values"],extensions:["tsv","tab"]},{group:"JSON",mime:["application/json","application/x-javascript","text/x-json"],extensions:["json","codap"]},{group:"GEOJSON",mime:["application/geo+json","application/vnd.geo+json"],extensions:["geojson"]},{group:"IMAGE",mime:["image/gif"],extensions:["gif"]},{group:"IMAGE",mime:["image/jpeg"],extensions:["jpeg","jpg"]},{group:"IMAGE",mime:["image/png"],extensions:["png"]},{group:"IMAGE",mime:["image/svg+xml"],extensions:["svg","svgz"]},{group:"SHEETS",mime:["application/vnd.google-apps.spreadsheet"],extensions:[]}],matchMimeSpec:function(b,d){var c=/docs.google.com\/spreadsheets/.test(b);var f=/^data:([^;]+);.+$/.exec(b);var a=b&&b.match(/\.([^.\/]+)$/);var g=a&&a[1].toLowerCase();var e;if(d==null&&f){d=f[1]}if(c){d="application/vnd.google-apps.spreadsheet"}e=e||d&&this.mimeTypesAndExtensions.find(function(h){return(d!=null)&&h.mime.find(function(i){return i===d})});e=e||this.mimeTypesAndExtensions.find(function(h){return g&&h.extensions.find(function(i){return g===i})});return e},importFile:function(b){var d=this.matchMimeSpec(b.name,b.type);var c=d?d.group:"JSON";var a={showAlert:function(e){var f="DG.AppController.dropFile.error".loc(e.message);if(DG.cfmClient){DG.cfmClient.alert(f)}else{DG.AlertPane.show({message:f})}},close:function(){}};DG.log('Opening file "%@" of type %@'.loc(b&&b.name,d?d.mime[0]:"unknown"));this.importFileWithConfirmation(b,c,a)},importFileWithConfirmation:function(c,d,a){var e=function(){function i(){console.log("Abort or error on file read.")}var g=function(){SC.run(function(){try{if(d==="JSON"){DG.cfmClient.openLocalFile(c);window.location.hash="";DG.log("Opened: "+c.name)}else{if(d==="GEOJSON"){h.openGeoJSONImporter({contentType:"application/geo+json",text:this.result,datasetName:c.name.replace(/\.[^.]*$/,""),filename:c.name,showCaseTable:true})}else{if(d==="TEXT"){h.importText(this.result,c.name.replace(/\.[^.]*$/,""),c.name)}else{if(d==="IMAGE"){h.importImage(this.result,c.name)}}}}if(a){a.close()}}catch(j){console.log(j);if(a){a.showAlert(j)}}}.bind(this))};var h=this;DG.busyCursor.show(function(){var j=new FileReader();if(c){j.onabort=i;j.onerror=i;j.onload=g;if(d==="IMAGE"){j.readAsDataURL(c)}else{j.readAsText(c)}}})}.bind(this);var f;var b=function(){DG.logUser("cancelCloseDocument: '%@'",f)};if((d==="JSON")&&DG.currDocumentController().get("hasUnsavedChanges")){f=DG.currDocumentController().get("documentName");DG.logUser("confirmCloseDocument?: '%@'",f);DG.AlertPane.warn({message:"DG.AppController.closeDocument.warnMessage",description:"DG.AppController.closeDocument.warnDescription",buttons:[{title:"DG.AppController.closeDocument.okButtonTitle",action:e,localize:YES},{title:"DG.AppController.closeDocument.cancelButtonTitle",action:b,localize:YES}],localize:YES})}else{DG.busyCursor.show(function(){e()})}if(a){a.close()}},reportProblem:function(){var a=function(){console.log(c.contentView.subjectText.value);console.log(c.contentView.feedbackText.value);console.log("Build #"+DG.BUILD_NUM);console.log("Browser: "+SC.browser.name+" v."+SC.browser.version);console.log("Device: "+SC.browser.device);console.log("OS: "+SC.browser.os+" v."+SC.browser.osVersion);SC.Request.postUrl("https://codap.concord.org/help/contact?device="+SC.browser.device+"&os="+SC.browser.os+"&os_version="+SC.browser.osVersion+"&cf_browser="+SC.browser.name+"&cf_browser_version="+SC.browser.version+"&version="+DG.BUILD_NUM+"&description="+c.contentView.subjectText.value+"&comments="+c.contentView.feedbackText.value).send();c.remove();c=null};var b=function(){c.remove();c=null};var c=SC.PanelPane.create({layout:{top:175,centerX:0,width:405,height:350},contentView:SC.View.extend({backgroundColor:"#dde2e8",childViews:"feedbackHeader codapLogo feedbackImage subHeaderText messageText subjectText feedbackText submitFeedbackButton cancelFeedbackButton".w(),feedbackHeader:SC.LabelView.design({layout:{top:27,height:20},controlSize:SC.LARGE_CONTROL_SIZE,fontWeight:SC.BOLD_WEIGHT,textAlign:SC.ALIGN_CENTER,value:"DG.AppController.feedbackDialog.dialogTitle",localize:YES}),codapLogo:SC.ImageView.design({layout:{top:10,left:10,height:35,width:35},value:"../../../../static/dg/fr/cert/source/resources/images/codap_logo.png"}),subHeaderText:SC.LabelView.design({layout:{top:55,left:10},fontWeight:SC.BOLD_WEIGHT,value:"DG.AppController.feedbackDialog.subHeaderText",localize:YES}),messageText:SC.LabelView.design({layout:{top:70,left:10,right:0,width:395},textAlign:SC.ALIGN_LEFT,value:"DG.AppController.feedbackDialog.messageText",localize:YES}),subjectText:SC.TextFieldView.design({layout:{top:110,left:10,width:385,height:20},autoCorrect:false,autoCapitalize:false,hint:"DG.AppController.feedbackDialog.subjectHint"}),feedbackText:SC.TextFieldView.design({layout:{top:140,left:10,height:170,width:385},isTextArea:true,autoCorrect:false,autoCapitalize:false,hint:"DG.AppController.feedbackDialog.feedbackHint"}),submitFeedbackButton:SC.ButtonView.design({layout:{bottom:10,height:24,right:10,width:113},title:"DG.AppController.feedbackDialog.submitFeedbackButton",localize:YES,action:a,isDefault:NO}),cancelFeedbackButton:SC.ButtonView.design({layout:{bottom:10,height:24,right:135,width:113},title:"DG.AppController.feedbackDialog.cancelFeedbackButton",localize:YES,action:b,isDefault:NO})})});c.append();c.contentView.subjectText.becomeFirstResponder()},viewWebPage:function(){DG.currDocumentController().viewWebPage()},configureGuide:function(){DG.currDocumentController().configureGuide()},showHelp:function(){var c=600,b=400,a={width:c,height:b};DG.currDocumentController().addWebView(DG.mainPage.get("docView"),null,(DG.showHelpURL),"DG.AppController.showHelpTitle".loc(),a)},openWebView:function(c,a,e,f){var d=DG.mainPage.mainPane.scrollView.frame(),b={left:(d.width-e)/2,top:(d.height-f)/2,width:e,height:f};DG.currDocumentController().addWebView(DG.mainPage.get("docView"),null,c,a,b)},showWebSite:function(){var a=DG.get("showWebSiteURL");window.open(a)},showPrivacyPage:function(){var a=DG.get("showPrivacyURL");window.open(a)},showHelpSite:function(){var c=DG.get("currentLanguage");var d=DG.get("showHelpURL_"+c)||DG.get("showHelpURL"),b=400,a=400;this.openWebView(d,"DG.AppController.showHelpTitle".loc(),b,a)},showHelpForum:function(){var c=DG.get("showHelpForumURL"),b=400,a=400,d=SC.browser;if(d.name===SC.BROWSER.safari&&d.os===SC.OS.ios){this.openWebView(c,"DG.AppController.showHelpForumTitle".loc(),b,a)}else{window.open(c)}},openPlugin:function(a){this.importURL(a)}}}()));DG.Authorization=SC.Object.extend({isLoggingEnabled:true,logIndex:0,clear:function(){this.set("isLoggingEnabled",true);return this}});sc_require("models/authorization_model");DG.logToServer=function(a,c,b){DG.authorizationController.logToServer(a,c,b)};DG.authorizationController=SC.Controller.create((function(){var a=(function(){var c=new Date();var d=c.getFullYear().toString().slice(-2)+("0"+(c.getMonth()+1)).slice(-2)+("0"+c.getDate()).slice(-2)+("0"+c.getHours()).slice(-2)+("0"+c.getMinutes()).slice(-2)+("0"+c.getSeconds()).slice(-2);var b=Math.random().toPrecision(5).slice(2);return d+"-"+b}());return{logToServer:function(b,n,i){function g(o,q){var e=o[q];o[q]=undefined;return e}var d=window.location.hostname.toLowerCase().endsWith(DG.get("logFromServer")),c=new Date(),f,m={},h;if(!d){SC.run();return}if(DG.get("logServerUrl")){f=g(n,"args");if(/^[a-zA-Z]*$/.test(f)){m={value:f}}else{try{m=JSON.parse(f);if(typeof m!=="object"){m={value:m}}}catch(j){}}if(f&&f.length>255){f=f.substr(0,255)}h={activity:g(n,"activity")||"Unknown",application:g(n,"application"),session:DG.get("runKey")||a,time:c.getTime(),event:b,event_value:f,parameters:m};var k=DG.get("run_remote_endpoint");if(k){h.run_remote_endpoint=k}var l=SC.json.encode(h);$.ajax(DG.get("logServerUrl"),{type:"POST",contentType:"application/json",data:l,xhrFields:{withCredentials:false}});console.log("sent to log server: "+l)}}}})());DG.CollectionClient=SC.Object.extend({collection:null,id:function(){return this.collection&&this.collection.get("id")}.property("collection").cacheable(),name:function(a,b){if(b!==undefined){this.collection.set("name",b)}return this.collection&&this.collection.get("name")}.property("collection").cacheable(),titleBinding:".collection.title",collapseChildren:function(){return this.collection&&this.collection.get("collapseChildren")}.property("collection").cacheable(),defaults:function(){return this.collection&&this.collection.get("defaults")}.property("collection").cacheable(),labels:function(){return this.collection&&this.collection.get("labels")}.property("collection").cacheable(),attrsController:null,casesController:null,attrFormulaChanges:null,hasAggregates:function(){var c=this.attrsController.get("length");for(var b=0;b<c;++b){var a=this.attrsController.objectAt(b);if(a&&a.getPath("_dgFormula.hasAggregates")){return true}}return false}.property(),init:function(){arguments.callee.base.apply(this,arguments);this.attrsController=SC.ArrayController.create({});this.casesController=SC.ArrayController.create({})},destroy:function(){this.attrsController.forEach(function(a){if(a){this.willDestroyAttribute(a)}}.bind(this));this.collection.destroy();arguments.callee.base.apply(this,arguments)},areParentChildLinksConfigured:function(){return this.getPath("collection.areParentChildLinksConfigured")}.property().cacheable(),setParentCollection:function(b){var a=this.get("collection"),c=b.get("collection");if(a&&c){a.set("parent",c);a.set("areParentChildLinksConfigured",true);c.set("areParentChildLinksConfigured",true)}},getParentCollectionID:function(){var a=this.get("collection");var b=a&&a.parent;return(b&&b.id)},isAncestorOf:function(a){var b=this.get("collection");return b&&b.isAncestorOf(a.get("collection"))},isDescendantOf:function(a){var b=this.get("collection");return b&&b.isDescendantOf(a.get("collection"))},setTargetCollection:function(a){this.set("collection",a);this.attrsController.set("content",a.attrs);this.casesController.set("content",a.cases);this.forEachAttribute(function(b){this.didCreateAttribute(b)}.bind(this))},reorderAttributes:function(b){var a=b.length;this.collection.attrs.sort(function(f,e){var d=b.indexOf(f.name),c=b.indexOf(e.name);if(d<0){d=a++}if(c<0){c=a++}return d-c})},getAttributeIDs:function(){return this.attrsController.getEach("id")},getAttributeNames:function(){return this.attrsController.getEach("name")},getVisibleAttributeNames:function(){return this.attrsController.filterProperty("hidden",false).getEach("name")},getAttributeCount:function(){return this.attrsController.get("length")},getAttributeAt:function(a){return this.attrsController.objectAt(a)},getAttributeByID:function(a){return !SC.none(a)?this.attrsController.findProperty("id",Number(a)):undefined},getAttributeByName:function(a){return !SC.empty(a)?this.attrsController.findProperty("name",a):undefined},getAttributeIndexByName:function(a){var b=this.getAttributeNames();return b.indexOf(a)},hasAttribute:function(a){return this.getAttributeIndexByName(a)>=0},createAttribute:function(b){var a=this.collection.createAttribute(b||{});if(a){this.didCreateAttribute(a)}return a},didCreateAttribute:function(a){},willDestroyAttribute:function(a){},canonicalizeName:function(a){return DG.Attribute.canonicalizeName(a)},guaranteeAttribute:function(c,b){var a=null;c=c||{};if(!SC.none(c.name)){c.name=this.canonicalizeName(c.name)}if(!SC.empty(c.name)){a=this.getAttributeByName(c.name);if(a){if(c.formula!==undefined||b){this.setAttributeFormula(a,c.formula,b)}if(!SC.none(c.categoryMap)){a.set("categoryMap",SC.clone(c.categoryMap))}["title","type","description","editable","hidden","precision","unit","blockDisplayOfEmptyCategories"].forEach(function(d){if(!SC.none(c[d])){a.set(d,c[d])}})}else{a=this.createAttribute(c)}}return a},setAttributeFormula:function(d,b,c){var g=d&&d.get("id"),f=d.get("hasFormula"),a=!SC.empty(b),h=f&&!a&&!c,e=[];if(h){this.forEachAttributeValue(g,function(i){e.push(i)})}d.set("formula",b);if(h){this.setAttributeValuesFromArray(g,e);if(!d.get("editable")){d.set("editable",true)}}this.attributeFormulaDidChange(d)},forEachAttribute:function(a){this.collection.attrs.forEach(a);return this},getCaseIDs:function(){return this.casesController.getEach("id")},parseSearchQuery:function(f){if(f==="*"){return{valid:true,op:"*"}}var e=f.match(/([^=!<>]+)(==|!=|<=|<|>=|>)([^=!<>]*)/),b=function(g){return g.replace(/^\s+|\s+$/,"")},d={valid:!!e,left:e&&b(e[1]),op:e&&e[2],right:e&&b(e[3])},c={},a=function(h){var i=Number(h),g=h==="true"?true:(h==="false"?false:(isNaN(i)?h:i));return{value:g,id:c[h]}};this.forEachAttribute(function(g){c[g.name]=g.id});d.left=a(d.left);d.right=a(d.right);d.valid=!!(d.valid&&(d.left.id||d.right.id));return d},testCaseAgainstQuery:function(d,c){var b=function(f){return f.id?d.getValue(f.id):f.value},e=c.left&&b(c.left)||"",a=c.right&&b(c.right)||"";if(!c.valid){return false}switch(c.op){case"*":return true;case"==":return e===a;case"!=":return e!==a;case"<":return e<a;case"<=":return e<=a;case">=":return e>=a;case">":return e>a;default:return false}},searchCases:function(b){var a=this.parseSearchQuery(b);if(!a.valid){return null}return this.casesController.filter(function(c){return this.testCaseAgainstQuery(c,a)}.bind(this))},searchCasesByFormula:function(e){var c=this.get("id");var a=DG.CollectionFormulaContext.create({ownerSpec:{type:DG.DEP_TYPE_UNDEFINED,id:this.get("id"),name:this.get("name")},collection:this.get("collection")});var d=DG.Formula.create({context:a});d.set("source",e);var b=this.casesController.filter(function(f){return d.evaluate({_case_:f,_id_:f&&f.get("id"),_collectionID_:c})});d.destroy();return b},caseCount:function(){return this.getCaseCount()}.property(),getCaseCount:function(){return this.casesController.get("length")},nonemptyCaseCount:function(){return this.getNonemptyCaseCount()}.property("*casesController"),getNonemptyCaseCount:function(){if(this.collection.children&&this.collection.children.length){return this.casesController.get("length")}else{return this.casesController.reduce(function(b,a){if(!a.get("isEmpty")){return b+1}else{return b}},0)}},caseCountDidChange:function(){this.notifyPropertyChange("caseCount")}.observes("*casesController","casesController.length"),getCaseAt:function(a){return this.casesController.objectAt(a)},getCaseIndexByID:function(b){var a=this.get("collection");return a&&a.getCaseIndexByID(b)},getCaseByID:function(b){var a=this.getCaseIndexByID(b);if(!SC.none(a)){return this.getCaseAt(a)}},caseIndicesDidChange:function(){this.notifyPropertyChange("caseIndices")}.observes("*collection.caseIDToIndexMap"),isCaseSelected:function(b){var a=this.getPath("casesController.selection");return b&&a?a.contains(b):false},isCaseAtIndexSelected:function(c){var b=this.getCaseAt(c),a=this.getPath("casesController.selection");return b&&a?a.contains(b):false},createCase:function(a){return this.collection.createCase(a||{})},attributeFormulaDidChange:function(a){var b=a.get("id"),c=this.get("attrFormulaChanges");this.beginPropertyChanges();if(c===b){this.set("attrFormulaChanges",null)}this.set("attrFormulaChanges",b);this.endPropertyChanges()},forEachCase:function(a){this.casesController.forEach(a);return this},forEachAttributeValue:function(a,c){var b=this.getPath("casesController.arrangedObjects");b.forEach(function(e){var d=e.getRawValue(a);c(d)});return this},setCaseValuesFromArray:function(d,b){var a=this.getAttributeIDs(),f=a.length,h=b?b.length:0,c,e=f<h?f:h,g;d.beginCaseValueChanges();for(c=0;c<e;++c){g=DG.DataUtilities.canonicalizeInputValue(b[c]);if(g!==undefined){d.setValue(a[c],g)}}d.endCaseValueChanges()},setAttributeValuesFromArray:function(b,a){var c=this.getPath("casesController.arrangedObjects");c.forEach(function(d,e){if(e<a.length){d.setValue(b,a[e])}})},deleteCase:function(a){this.get("collection").deleteCase(a)},setAsideCase:function(a){this.get("collection").setAsideCase(a)},restoreSetAsideCases:function(){this.get("collection").restoreSetAsideCases()},didDeleteCases:function(){this.get("collection").updateCaseIDToIndexMap()},deleteSelectedCases:function(){var b=this.get("collection"),a=this.getPath("casesController.selection");DG.logUser("deleteSelectedCases: %@",a.length());a.forEach(function(c){b.deleteCase(c)});this.didDeleteCases()},deleteAllCases:function(){var b=this.get("collection"),c=b.get("cases"),a=c.concat();a.forEach(function(d){b.deleteCase(d,true)});this.didDeleteCases()},markCasesForDeletion:function(){var a=this.get("collection"),b=a.get("cases");b.forEach(function(c){c._deletable=true})},deleteMarkedCases:function(){var b=this.get("collection"),c=b.get("cases"),d=[],a=[];if(!c.some(function(e){return(e._deletable)})){return[]}this.getPath("collection.cases").beginPropertyChanges();this.casesController.beginPropertyChanges();this.beginPropertyChanges();try{c.forEach(function(e){if(e._deletable){d.push(e);DG.Case.destroyCase(e)}else{a.push(e)}});this.setPath("collection.cases",a);this.casesController.set("content",a)}finally{this.endPropertyChanges();this.casesController.endPropertyChanges();this.getPath("collection.cases").endPropertyChanges()}if(d.length>0){this.didDeleteCases()}return d},toLink:function(){var a=this.getPath("collection");return a&&a.toLink()},debugLog:function(a){this.get("collection").debugLog(a)}});sc_require("controllers/data_context");DG.GameContext=DG.DataContext.extend({type:"DG.GameContext",gameName:null,gameDimensions:null,gameUrl:null,gameVersion:null,didCreateCollection:function(a){},collectionDefaults:function(){var b={collectionClient:null,plotXAttr:null,plotXAttrIsNumeric:true,plotYAttr:null,plotYAttrIsNumeric:true};if(SC.none(b.collectionClient)){b.collectionClient=this.get("childCollection");b.parentCollectionClient=this.get("parentCollection")}function a(d,e,f){var g=d&&d.getPath("defaults."+e+"Attr"),c,h;if(b.collectionClient&&!SC.empty(g)){c=b.collectionClient.getAttributeByName(g);b["plot"+f+"Attr"]=c;h=d&&d.getPath("defaults."+e+"AttrIsNumeric");if(SC.none(h)){h=(c.get("type")==="numeric")}if(!SC.none(h)){b["plot"+f+"AttrIsNumeric"]=h}}}a(b.collectionClient,"x","X");a(b.collectionClient,"y","Y");a(b.collectionClient,"legend","Legend");return b},getLabelsForCollection:function(a){return a.get("labels")},getCaseNameForCount:function(a,b){var c=this.getLabelsForCollection(a);if(!c||!c.singleCase||!c.pluralCase){return arguments.callee.base.apply(this,arguments)}return b===1?c.singleCase:c.pluralCase},getLabelForSetOfCases:function(b){var c=this.getLabelsForCollection(b),a=c&&c.setOfCasesWithArticle;if(!SC.empty(a)){return a}return arguments.callee.base.apply(this,arguments)},createStorage:function(){var a=arguments.callee.base.apply(this,arguments);a.gameName=this.get("gameName");a.gameUrl=this.get("gameUrl");var b=this.get("savedGameState");if(b){DG.ObjectMap.forEach(b._links_,function(c,d){DG.ArchiveUtils.addLinkID(a,"_game_"+c,"DG.Case",d)});a.gameState=b;this.set("savedGameState",null)}return a},restoreFromStorage:function(a){arguments.callee.base.apply(this,arguments);if(a&&a.gameState){if(a._links_){DG.ObjectMap.forEach(a._links_,function(d,c){if(d.slice(0,6)==="_game_"){var b=d.slice(6);if(!a.gameState._links_){a.gameState._links_={}}a.gameState._links_[b]=c.id}})}this.set("restoredGameState",a.gameState)}}});DG.DataContext.registry["DG.GameContext"]=function(a){return DG.GameContext.create(a)};DG.GameContext.getContextForGame=function(a){if(!a){return null}var d=a.get("context");if(!d){var e={type:a.get("contextType")||"DG.GameContext"};if(e.type==="DG.GameContext"){e.gameSpec=a}var c=DG.currDocumentController().getPath("content.id"),b=DG.DataContextRecord.createContext({type:e.type,document:c});if(b){e.model=b}d=DG.DataContext.factory(e);if(d){a.set("context",d)}}return d};DG.globalsController=SC.Controller.create((function(){return{globalNameChanges:null,globalValueChanges:null,_globalsMap:{},reset:function(){DG.ObjectMap.forEach(this._globalsMap,function(a,b){this.destroyGlobalValue(b)}.bind(this))},isNameInUse:function(a){return !SC.none(this.getGlobalValueByName(a))},getGlobalValueByName:function(a){return this._globalsMap[a]},getGlobalValueByID:function(a){return Object.values(this._globalsMap).find(function(b){return b.id===Number(a)})},getUniqueName:function(a){var c=0,b;a=a||"v";do{++c;b=a+c}while(this.isNameInUse(b));return b},createGlobalValue:function(c,b){c=c||{};if(SC.empty(c.document)){c.document=DG.activeDocument}if(SC.empty(c.name)){c.name=this.getUniqueName(b)}if(SC.none(c.value)){c.value=0.5}var a=DG.GlobalValue.createGlobalValue(c);this.registerGlobalValue(a);return a},destroyGlobalValue:function(a){var b=a&&a.get("name");a.removeObserver("name",this,this.nameDidChange);a.removeObserver("value",this,this.valueDidChange);delete this._globalsMap[b];DG.GlobalValue.destroyGlobalValue(a);this.set("globalNameChanges",[{oldName:b}]);this.valueDidChange()},registerGlobalValue:function(a){var b=a&&a.get("name");if(!SC.none(b)&&!this._globalsMap[b]){this._globalsMap[b]=a;a.addObserver("name",this,this.nameDidChange);a.addObserver("value",this,this.valueDidChange);this.set("globalNameChanges",[{newName:b}])}},nameDidChange:function(b){var a=DG.ObjectMap.findValue(this._globalsMap,b),c=b.get("name");if(a!==c){this._globalsMap[c]=b;DG.ObjectMap.remove(this._globalsMap,a);this.set("globalNameChanges",[{oldName:a,newName:c}])}},valueDidChange:function(a){var b=a&&a.get("name"),c=b?[b]:[];this.set("globalValueChanges",c)},stopAnimation:function(){DG.ObjectMap.forEach(this._globalsMap,function(a,b){if(b&&b.stopAnimation){b.stopAnimation()}})},getGlobalValueNames:function(){return DG.ObjectMap.keys(this._globalsMap)},addGlobalValuesToNamespace:function(a){DG.ObjectMap.forEach(this._globalsMap,function(b,c){a[b]=c.get("value")})}}}()));DG.UndoHistory=SC.Object.create((function(){var a=["nan","executeNotification","undoNotification","redoNotification"];return{EXECUTE:1,UNDO:2,REDO:3,enabledBinding:SC.Binding.oneWay("DG.enableUndoHistory"),_undoStack:[],_redoStack:[],_executeInProgress:false,execute:function(c){try{this._wrapAndRun(c,c.execute)}catch(b){this._clearUndo();this._clearRedo();throw b}if(!c.causedChange){return}if(this._executeInProgress){return}if(this.get("enabled")&&c.isUndoable){if(c.reduce&&this._undoStack.length>0){var d=c.reduce(this._undoStack[this._undoStack.length-1]);if(d){c.reduced=true;this._undoStack.pop();c=d}}this._undoStack.push(c);this.notifyPropertyChange("_undoStack")}else{this._clearUndo()}this._clearRedo();this._logAction(c,this.EXECUTE);this._notify(c,this.EXECUTE);this._dirtyDocument(c.changedObject)},canUndo:function(){return this._undoStack.length>0}.property("_undoStack"),nextUndoCommand:function(){if(this._undoStack.length===0){return null}return this._undoStack[this._undoStack.length-1]}.property("_undoStack"),undo:function(){DG.globalEditorLock.commitCurrentEdit();if(!this.get("enabled")||this._undoStack.length===0){return}var c=this._undoStack.pop();try{this._wrapAndRun(c,c.undo)}catch(b){this.showErrorAlert(true,b)}this._redoStack.push(c);this.notifyPropertyChange("_undoStack");this.notifyPropertyChange("_redoStack");if(!c.undoNotification){c.undoNotification={action:"notify",resource:"document",values:{operation:"undo"}}}this._logAction(c,this.UNDO);this._notify(c,this.UNDO);this._dirtyDocument(c.changedObject)},canRedo:function(){return this._redoStack.length>0}.property("_redoStack"),nextRedoCommand:function(){if(this._redoStack.length===0){return null}return this._redoStack[this._redoStack.length-1]}.property("_redoStack"),redo:function(){DG.globalEditorLock.commitCurrentEdit();if(!this.get("enabled")||this._redoStack.length===0){return}var c=this._redoStack.pop();try{this._wrapAndRun(c,c.redo)}catch(b){this.showErrorAlert(false,b)}this._undoStack.push(c);this.notifyPropertyChange("_undoStack");this.notifyPropertyChange("_redoStack");if(!c.redoNotification){c.redoNotification={action:"notify",resource:"document",values:{operation:"redo"}}}this._logAction(c,this.REDO);this._notify(c,this.REDO);this._dirtyDocument(c.changedObject)},documentWasChanged:function(){if(this._executeInProgress){return}this.clearUndoRedoHistory()},clearUndoRedoHistory:function(){this._clearUndo();this._clearRedo()},showErrorAlert:function(b,c){if(!c||!c.message){c={message:"Unknown error"}}DG.Debug.logErrorRaw("Exception occurred while %@: %@\n%@".fmt((b?"undoing: ":"redoing: "),c.message,c.stack));DG.AlertPane.error({localize:true,message:(b?"DG.Undo.exceptionOccurred":"DG.Redo.exceptionOccurred"),buttons:[{title:"OK",action:function(){this.clearUndoRedoHistory()}.bind(this)}]})},makeComponentNotification:function(b,c){return{action:"notify",resource:"component",values:{operation:b,type:c}}},_wrapAndRun:function(c,b){if(this._executeInProgress){b.call(c)}else{this._executeInProgress=true;try{b.call(c)}finally{this._executeInProgress=false}}},_clearUndo:function(){this._undoStack.length=0;this.notifyPropertyChange("_undoStack");this._sendUndoChangeToDI("clearUndo")},_clearRedo:function(){this._redoStack.length=0;this.notifyPropertyChange("_redoStack");this._sendUndoChangeToDI("clearRedo")},_dirtyDocument:function(b){if(this._executeInProgress){DG.dirtyCurrentDocument(b)}else{this._executeInProgress=true;DG.dirtyCurrentDocument(b);this._executeInProgress=false}},_queuedLogMessage:null,_logAction:function(d,c){var b="";if(c===this.UNDO){b="Undo: "}else{if(c===this.REDO){b="Redo: "}}if(typeof(d.log)==="function"){b+=d.log(c)}else{b+=d.log}if(this._queuedLogMessage&&!d.reduced){DG.logUser(this._queuedLogMessage);this._queuedLogMessage=null}if(d.reduce&&c===this.EXECUTE){this._queuedLogMessage=b}else{DG.logUser(b)}},_notify:function(e,c){var b=a[c]||((c===this.REDO)&&a);var f=e[b];var d=f&&(typeof f==="function")?f(c):f;if(d){DG.currDocumentController().notificationManager.sendNotification(d)}},_sendUndoChangeToDI:function(b){DG.sendCommandToDI({action:"notify",resource:"undoChangeNotice",values:{operation:b,canUndo:this.get("canUndo"),canRedo:this.get("canRedo")}})}}})());sc_require("controllers/component_controller");DG.WebViewController=DG.ComponentController.extend({theURL:function(b,a){if(!SC.none(a)){this.setPath("model.content.URL",a)}return this.getPath("model.content.URL")}.property(),theURLDidChange:function(){this.notifyPropertyChange("theURL")}.observes("model.content.URL"),title:"DG.WebView.defaultTitle".loc(),createInspectorButtons:function(){var a=arguments.callee.base.apply(this,arguments);a.push(DG.IconButton.create({layout:{width:32},classNames:"dg-web-view-url".w(),iconClass:"moonicon-icon-mediaTool",showBlip:false,target:this,action:"editURL",toolTip:"DG.Inspector.webViewEditURL.toolTip",localize:true}));return a},editURL:function(){var c=this,b=null;function a(){var d=b.get("value");b.close();c.set("theURL",d)}b=DG.CreateSingleTextDialog({prompt:"DG.DocumentController.enterURLPrompt",textValue:c.get("theURL"),textHint:"URL",okTarget:null,okAction:a,okTooltip:DG.DocumentController.enterViewWebPageOKTip})},createComponentStorage:function(){var a=this.get("theURL"),b={title:this.title};if(!SC.empty(a)){b.URL=a}return b},restoreComponentStorage:function(a){var b=a.URL||"";this.set("theURL",b);this.set("title",a.title)},viewDidChange:function(){var a=this.getPath("view.containerView.contentView");if(a){if(SC.empty(this.theURL)){this.set("theURL",a.get("value"))}a.bind("value",this,"theURL");a.set("controller",this)}}.observes("view.containerView.contentView")});DG.AggregateFunction=SC.Object.extend({requiredArgs:{min:0,max:999},isCaseIndexDependent:function(a){return false},queryCache:function(c,b,a){return undefined},evaluate:function(c,b,a){}});DG.IteratingAggregate=DG.AggregateFunction.extend({queryCache:function(c,b,a){return a.results?a.results[b._id_]:undefined},preEvaluate:function(c,b,a){a.caches={};a.results={}},evaluate:function(k,h,j){var b=this.queryCache(k,h,j);if(b!==undefined){return b}this.preEvaluate(k,h,j);var f=k&&k.getCollectionToIterate(),l=f&&f.get("cases"),c=l&&l.get("length");for(var d=0;d<c;++d){var a=l.objectAt(d),g={_case_:a,_id_:a&&a.get("id")};if(this.filterCase(k,g,j)){this.evalCase(k,g,j)}}return this.computeResults(k,h,j)},filterCase:function(c,b,a){return c.filterCase(b)},evalCase:function(c,b,a,d){},computeResults:function(c,b,a){return this.queryCache(c,b,a)}});DG.ParentCaseAggregate=DG.IteratingAggregate.extend({category:"DG.Formula.FuncCategoryStatistical",getGroupID:function(e,d){var c=d._case_;if(c){var f=e&&e.get("groupVarID");if(f){var b=e.getAttrValue(c,f);return !SC.empty(b)?b:null}else{var a=c&&c.get("parent");for(;c;c=c.get("parent"),a=c){if(c.getPath("collection.id")===d._collectionID_){return a?a.get("id"):null}}}}else{if(d._groupID_){return d._groupID_}}return null},queryCache:function(c,b,a){if(a.results){if(a.results[b._id_]!==undefined){return a.results[b._id_]}var d=this.getGroupID(c,b);if(a.results[d]!==undefined){return a.results[d]}}return undefined},filterCase:function(c,b,a){var e=arguments.callee.base.apply(this,arguments),d=a.filterFn;return e&&(d?d(c,b):true)},getValue:function(c,b,a){var d=a.argFns[0];return d&&d(c,b)},getNumericValue:function(c,b,a){var d=a.argFns[0];return d&&DG.getNumeric(d(c,b))},evaluate:function(k,h,j){var b=this.queryCache(k,h,j);if(b!==undefined){return b}this.preEvaluate(k,h,j);var g=k&&k.getCollectionToIterate(),l=g&&g.get("cases"),c=l&&l.get("length");for(var f=0;f<c;++f){var a=l.objectAt(f),e=$.extend({},h,{_case_:a,_id_:a&&a.get("id")}),d=this.getGroupID(k,e);if(this.filterCase(k,e,j)){this.evalCase(k,e,j,d)}}return this.computeResults(k,h,j)}});DG.CachedValuesParentCaseAggregate=DG.ParentCaseAggregate.extend({evalCase:function(d,c,b,f){var e=this.getNumericValue(d,c,b);if(e!=null){var a=b.caches[f];if(a){a.sum+=e;a.values.push(e)}else{b.caches[f]={sum:e,values:[e]}}}},computeResultFromCache:function(a){},computeResults:function(c,b,a){DG.ObjectMap.forEach(a.caches,function(e,d){a.results[e]=this.computeResultFromCache(d)}.bind(this));return this.queryCache(c,b,a)},computeVarianceFromCache:function(d){if(d.values&&(d.values.length>1)){var e=d.values.length,a=d.sum/e,f=0,g=0,c,b;for(c=0;c<e;++c){b=d.values[c]-a;f+=b;g+=b*b}return((g-(f*f)/e))/(e-1)}return NaN}});DG.SortDataFunction=DG.ParentCaseAggregate.extend({evalCase:function(d,c,b,f){var e=this.getNumericValue(d,c,b);if(e!=null){var a=b.caches[f];if(a){a.push(e)}else{b.caches[f]=[e]}}},extractResult:function(c,b,a){return null},computeResults:function(c,b,a){DG.ObjectMap.forEach(a.caches,function(d,e){if(e.length>0){e.sort(function(g,f){return g-f})}a.results[d]=this.extractResult(e,b,a)}.bind(this));return this.queryCache(c,b,a)}});DG.BivariateStatsFn=DG.ParentCaseAggregate.extend({requiredArgs:{min:2,max:2},getCoordValue:function(d,c,b){var a=b.argFns[0],e=b.argFns[1];return{x:a&&DG.getNumeric(a(d,c)),y:e&&DG.getNumeric(e(d,c))}},evalCase:function(e,d,c,f){var a=this.getCoordValue(e,d,c);if(a.x!=null&&a.y!=null){var b=c.caches[f];if(b){b.push(a)}else{c.caches[f]=[a]}}}});DG.BivariateSemiAggregateFn=DG.BivariateStatsFn.extend({requiredArgs:{min:2,max:2},yCanBeNonNumeric:false,filterCase:function(e,d,c){function b(i){var h=c.argFns[i];return h&&DG.getNumeric(h(e,d))}var f=arguments.callee.base.apply(this,arguments),a=b(0),g=b(1);return f&&DG.isNumeric(a)&&(DG.isNumeric(g)||this.yCanBeNonNumeric)},preEvaluate:function(j,g,h){arguments.callee.base.apply(this,arguments);var f=j&&j.getCollectionToIterate(),k=f&&f.get("cases"),b=k&&k.get("length");for(var e=0;e<b;++e){var a=k.objectAt(e),d=$.extend({},g,{_case_:a,_id_:a&&a.get("id")}),c=this.getGroupID(j,d);if(this.filterCase(j,d,h)){this.evalCase(j,d,h,c)}}DG.ObjectMap.forEach(h.caches,function(m,l){var n=DG.MathUtilities.computeBivariateStats(l),i=n.sumOfProductDiffs/n.xSumSquaredDeviations;h.caches[m]={slope:i,intercept:n.yMean-i*n.xMean}})},evaluate:function(k,h,j){var b=this.queryCache(k,h,j);if(b!==undefined){return b}this.preEvaluate(k,h,j);var g=k&&k.getCollectionToIterate(),l=g&&g.get("cases"),c=l&&l.get("length");for(var f=0;f<c;++f){var a=l.objectAt(f),e=$.extend({},h,{_case_:a,_id_:a&&a.get("id")}),d=this.getGroupID(k,e);if(this.filterCase(k,e,j)){this.secondPassEvalCase(k,e,j,d)}}return this.computeResults(k,h,j)}});sc_require("formula/function_registry");DG.functionRegistry.registerFunctions((function(){function c(d){return SC.empty(d)?"":(d<0?Math.ceil(d):Math.floor(d))}var a=0;var b;return{abs:{minArgs:1,maxArgs:1,category:"DG.Formula.FuncCategoryArithmetic",evalFn:function(d){return SC.empty(d)?"":Math.abs(d)}},acos:{minArgs:1,maxArgs:1,category:"DG.Formula.FuncCategoryTrigonometric",evalFn:function(d){return SC.empty(d)?"":Math.acos(d)}},asin:{minArgs:1,maxArgs:1,category:"DG.Formula.FuncCategoryTrigonometric",evalFn:function(d){return SC.empty(d)?"":Math.asin(d)}},atan:{minArgs:1,maxArgs:1,category:"DG.Formula.FuncCategoryTrigonometric",evalFn:function(d){return SC.empty(d)?"":Math.atan(d)}},atan2:{minArgs:2,maxArgs:2,category:"DG.Formula.FuncCategoryTrigonometric",evalFn:function(e,d){return SC.empty(d)||SC.empty(e)?"":Math.atan2(e,d)}},ceil:{minArgs:1,maxArgs:1,category:"DG.Formula.FuncCategoryArithmetic",evalFn:function(d){return SC.empty(d)?"":Math.ceil(d)}},combinations:{minArgs:2,maxArgs:2,category:"DG.Formula.FuncCategoryArithmetic",evalFn:function(h,d){function f(i){return Math.floor(Number(i))===Number(i)}var g="";if(!SC.empty(h)&&!SC.empty(d)&&f(d)&&f(h)){d=Number(d);h=Number(h);if(d<0||d>h){g=0}else{if(h>0&&f(h)){d=Math.min(d,h-d)}g=1;var e=1;while(e<=d){g*=h--;if(isFinite(g)){g/=e++}else{g="---OVERFLOW---";e=d}}}}return g}},cos:{minArgs:1,maxArgs:1,category:"DG.Formula.FuncCategoryTrigonometric",evalFn:function(d){return SC.empty(d)?"":Math.cos(d)}},exp:{minArgs:1,maxArgs:1,category:"DG.Formula.FuncCategoryArithmetic",evalFn:function(d){return SC.empty(d)?"":Math.exp(d)}},floor:{minArgs:1,maxArgs:1,category:"DG.Formula.FuncCategoryArithmetic",evalFn:function(d){return SC.empty(d)?"":Math.floor(d)}},pow:{minArgs:2,maxArgs:2,category:"DG.Formula.FuncCategoryArithmetic",evalFn:function(d,e){return SC.empty(d)||SC.empty(e)?"":Math.pow(d,e)}},sin:{minArgs:1,maxArgs:1,category:"DG.Formula.FuncCategoryTrigonometric",evalFn:function(d){return SC.empty(d)?"":Math.sin(d)}},sqrt:{minArgs:1,maxArgs:1,category:"DG.Formula.FuncCategoryArithmetic",evalFn:function(d){return SC.empty(d)?"":Math.sqrt(d)}},tan:{minArgs:1,maxArgs:1,category:"DG.Formula.FuncCategoryTrigonometric",evalFn:function(d){return SC.empty(d)?"":Math.tan(d)}},frac:{minArgs:1,maxArgs:1,category:"DG.Formula.FuncCategoryArithmetic",evalFn:function(d){return SC.empty(d)?"":d-c(d)}},"if":{minArgs:2,maxArgs:3,category:"DG.Formula.FuncCategoryOther",evalFn:function(g,e,f){function d(h){var i={"true":true,TRUE:true,"false":false,FALSE:false};return i[h]!=null?i[h]:!!h}if(SC.empty(g)){return""}return d(g)?(e!=null?e:""):(f!=null?f:"")}},ln:{minArgs:1,maxArgs:1,category:"DG.Formula.FuncCategoryArithmetic",evalFn:function(d){return SC.empty(d)?"":Math.log(d)}},log:{minArgs:1,maxArgs:1,category:"DG.Formula.FuncCategoryArithmetic",evalFn:function(d){return SC.empty(d)?"":Math.log(d)/Math.LN10}},number:{minArgs:1,maxArgs:1,category:"DG.Formula.FuncCategoryConversion",evalFn:function(d){if(DG.isDate(d)){return Number(d)}else{if(DG.isDateString(d)){return Number(DG.parseDate(d))}else{return DG.MathUtilities.extractNumeric(d)}}}},random:{minArgs:0,maxArgs:2,isRandom:true,category:"DG.Formula.FuncCategoryRandom",evalFn:function(e,d){if(SC.empty(e)){return Math.random()}if(SC.empty(d)){return e*Math.random()}return e+(d-e)*Math.random()}},randomNormal:{minArgs:0,maxArgs:2,isRandom:true,category:"DG.Formula.FuncCategoryRandom",evalFn:function(e,g){var f,d,i,h;e=e||0;g=SC.empty(g)?1:g;if(a!==0){i=a;a=0;return g*i+e}do{i=2*Math.random()-1;h=2*Math.random()-1;d=i*i+h*h}while(d>=1);f=Math.sqrt(-2*Math.log(d)/d);a=f*h;return g*f*i+e}},randomBinomial:{minArgs:2,maxArgs:2,isRandom:true,category:"DG.Formula.FuncCategoryRandom",evalFn:function(e,d){if(SC.empty(e)||SC.empty(d)||e<0||Math.floor(e)!==e||d<0||d>1){return""}else{if(!b){b=new RandVarGen.RandVarGen()}return b.binomial(d,e)}}},randomPick:{minArgs:2,maxArgs:1000,isRandom:true,category:"DG.Formula.FuncCategoryRandom",evalFn:function(){var d=Math.floor(arguments.length*Math.random());return arguments[d]}},round:{minArgs:1,maxArgs:2,category:"DG.Formula.FuncCategoryArithmetic",evalFn:function(d,f){if(SC.empty(d)){return""}if(SC.empty(f)){return Math.round(d)}var e=Math.pow(10,c(f));return Math.round(e*d)/e}},string:{minArgs:1,maxArgs:1,category:"DG.Formula.FuncCategoryConversion",evalFn:function(d){return SC.empty(d)?"":String(d)}},trunc:{minArgs:1,maxArgs:1,category:"DG.Formula.FuncCategoryArithmetic",evalFn:c},greatCircleDistance:{minArgs:4,maxArgs:4,category:"DG.Formula.FuncCategoryOther",evalFn:function(j,i,h,g){if(DG.isNumeric(j)&&DG.isNumeric(h)&&DG.isNumeric(i)&&DG.isNumeric(g)){var e=h-j,f=g-i,d=Math.pow(Math.sin((Math.PI/180)*e/2),2)+Math.cos(j*Math.PI/180)*Math.cos(h*Math.PI/180)*Math.pow(Math.sin((Math.PI/180)*f/2),2);return 2*6371*Math.atan2(Math.sqrt(d),Math.sqrt(1-d))}else{return""}}}}})());sc_require("formula/aggregate_function");sc_require("formula/function_registry");DG.functionRegistry.registerAggregates((function(){return{correlation:DG.BivariateStatsFn.create({computeResults:function(c,b,a){DG.ObjectMap.forEach(a.caches,function(e,d){a.results[e]=DG.MathUtilities.correlation(d)});return this.queryCache(c,b,a)}}),rSquared:DG.BivariateStatsFn.create({computeResults:function(c,b,a){DG.ObjectMap.forEach(a.caches,function(e,d){a.results[e]=DG.MathUtilities.rSquared(d)});return this.queryCache(c,b,a)}}),linRegrSlope:DG.BivariateStatsFn.create({computeResults:function(c,b,a){DG.ObjectMap.forEach(a.caches,function(e,d){a.results[e]=DG.MathUtilities.linRegrSlope(d)});return this.queryCache(c,b,a)}}),linRegrSESlope:DG.BivariateStatsFn.create({computeResults:function(c,b,a){DG.ObjectMap.forEach(a.caches,function(e,d){a.results[e]=DG.MathUtilities.linRegrSESlopeAndIntercept(d).seSlope});return this.queryCache(c,b,a)}}),linRegrIntercept:DG.BivariateStatsFn.create({computeResults:function(c,b,a){DG.ObjectMap.forEach(a.caches,function(e,d){a.results[e]=DG.MathUtilities.linRegrIntercept(d)});return this.queryCache(c,b,a)}}),linRegrResidual:DG.BivariateSemiAggregateFn.create({secondPassEvalCase:function(g,e,f,a){var i=f.argFns[0],b=f.argFns[1],h=f.caches[a].slope,d=f.caches[a].intercept,c=e._id_;f.results[c]=DG.getNumeric(b(g,e))-(h*DG.getNumeric(i(g,e))+d)}}),linRegrPredicted:DG.BivariateSemiAggregateFn.create({yCanBeNonNumeric:true,secondPassEvalCase:function(g,e,d,h){var a=d.argFns[0],b=d.caches[h].slope,c=d.caches[h].intercept,f=e._id_;d.results[f]=(b*DG.getNumeric(a(g,e))+c)}})}}()));DG.Formula=SC.Object.extend((function(){return{context:null,source:null,init:function(){arguments.callee.base.apply(this,arguments);var a=this.get("context");if(a){a.addObserver("namespaceChange",this,"namespaceDidChange")}if(a){a.addObserver("dependentChange",this,"dependentDidChange")}},destroy:function(){var a=this.get("context");if(a){a.removeObserver("namespaceChange",this,"namespaceDidChange");a.removeObserver("dependentChange",this,"dependentDidChange");a.destroy();this.context=null}arguments.callee.base.apply(this,arguments)},invalidate:function(){this.notifyPropertyChange("source")},invalidateContext:function(){this.notifyPropertyChange("context")},namespaceDidChange:function(a,b){this.invalidateContext();this.notifyPropertyChange(b);this.notifyPropertyChange("dependentChange")},dependentDidChange:function(a,b){this.notifyPropertyChange(b)},parseCount:0,parsed:function(){++this.parseCount;var c=this.get("source"),a;try{a=c&&DG.formulaParser.parse(c)}catch(b){b.originalMessage=b.message;b.message=b.found?"DG.Formula.SyntaxErrorMiddle".loc(b.found):"DG.Formula.SyntaxErrorEnd".loc();throw b}return a}.property("source").cacheable(),compiled:function(){var b=this.get("parsed"),c=this.get("context"),d=null;if(!c){c=DG.FormulaContext.create({});this.context=c}if(b){c.willCompile();var a=DG.Formula.compileToJavaScript(b,c);c.didCompile();c.completeCompile();d=DG.FormulaContext.createContextFunction(a)}return d}.property("parsed","context","namespaceChange").cacheable(),hasAggregates:function(){var a=false;try{this.get("compiled");var b=this.get("context");if(b){a=b.get("hasAggregates")}}catch(c){}return a}.property("compiled","context").cacheable(),evaluate:function(b){var c=this.get("compiled"),a=this.get("context");return c&&c(a,b)},evaluateDirect:function(c){var a=this.get("parsed"),b=this.get("context");if(!b){b=DG.FormulaContext.create({});this.context=b}return DG.Formula.evaluateParseTree(a,b,c)}}}()));DG.Formula.identifierRegExpFirstCharSet="A-Za-z_\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE";DG.Formula.identifierRegExp=(function(){var b=DG.Formula.identifierRegExpFirstCharSet,a="0-9"+b;return new RegExp("[%@][%@]*".fmt(b,a))}());DG.Formula.functionRegExp=(function(){var b=DG.Formula.identifierRegExpFirstCharSet,a="0-9"+b;return new RegExp("[%@][%@]*(?=\\()".fmt(b,a))}());DG.Formula.whiteSpaceRegExp=/^[\s\uFEFF\xA0]+$/;DG.Formula.arithmeticStarter=function(e,c){var a={isNumeric1:null,isNumeric2:null,isDate1:null,isDate2:null,empty1:null,empty2:null,num1:null,num2:null},d=(typeof e==="string")&&DG.Formula.whiteSpaceRegExp.test(e),b=(typeof c==="string")&&DG.Formula.whiteSpaceRegExp.test(c);a.empty1=SC.empty(e);a.empty2=SC.empty(c);a.isDate1=DG.isDate(e)||(!d&&DG.isDateString(e));a.isDate2=DG.isDate(c)||(!b&&DG.isDateString(c));a.num1=!a.empty1&&!d?(isNaN(e)?Number(DG.createDate(e)):Number(e)):NaN;a.num2=!a.empty2&&!b?(isNaN(c)?Number(DG.createDate(c)):Number(c)):NaN;a.isNumeric1=(a.num1===a.num1);a.isNumeric2=(a.num2===a.num2);if(e instanceof Error){return e}if(c instanceof Error){return c}if((e!==e)||(c!==c)){return NaN}return a};DG.Formula.arithmeticFinisher=function(b,a){if(b.empty1&&b.empty2){return""}if((b.empty1&&b.isNumeric2)||(b.isNumeric1&&b.empty2)){return""}throw new DG.TypeError(a)};DG.Formula.stringFinisher=function(c,d,b,a){if(c.empty1&&c.empty2){return""}if((c.empty1&&c.isNumeric2)||(c.isNumeric1&&c.empty2)){return""}d=String(d);b=String(b);switch(a){case"+":return d+b;case"<":return d<b;case"<=":return d<=b}};DG.Formula.add=function(c,b){var a=DG.Formula.arithmeticStarter(c,b);if((a instanceof Error)||typeof a!=="object"){return a}if(a.isNumeric1&&a.isNumeric2){return a.isDate1!==a.isDate2?DG.createDate((a.num1+a.num2)):a.num1+a.num2}if(a.empty1&&a.empty2){return""}if((a.empty1&&a.isNumeric2)||(a.isNumeric1&&a.empty2)){return""}if(a.empty1&&!a.empty2){return String(b)}if(!a.empty1&&a.empty2){return String(c)}return DG.Formula.stringFinisher(a,c,b,"+")};DG.Formula.subtract=function(c,b){var a=DG.Formula.arithmeticStarter(c,b);if((a instanceof Error)||typeof a!=="object"){return a}if(a.isNumeric1&&a.isNumeric2){return(a.isDate1&&!a.isDate2)?DG.createDate((a.num1-a.num2)):a.num1-a.num2}return DG.Formula.arithmeticFinisher(a,"\u2212")};DG.Formula.lessThan=function(c,b){var a=DG.Formula.arithmeticStarter(c,b);if((a instanceof Error)||typeof a!=="object"){return a}if(a.isNumeric1&&a.isNumeric2){return a.num1<a.num2}return DG.Formula.stringFinisher(a,c,b,"<")};DG.Formula.lessThanOrEqual=function(c,b){var a=DG.Formula.arithmeticStarter(c,b);if((a instanceof Error)||typeof a!=="object"){return a}if(a.isNumeric1&&a.isNumeric2){return a.num1<=a.num2}return DG.Formula.stringFinisher(a,c,b,"<=")};DG.Formula.equals=function(d,c){var b={"true":true,TRUE:true,"false":false,FALSE:false};var a=DG.Formula.arithmeticStarter(d,c);if((a instanceof Error)||typeof a!=="object"){return a}if(d===true||d===false||c===true||c===false){d=b[d]!=null?b[d]:d;c=b[c]!=null?b[c]:c}return d==c};DG.Formula.binaryOperator=function(d,k,j){var b=SC.empty(k),a=SC.empty(j),h=(typeof k==="string")&&DG.Formula.whiteSpaceRegExp.test(k),f=(typeof j==="string")&&DG.Formula.whiteSpaceRegExp.test(j),m=DG.isDate(k)||(!h&&DG.isDateString(k)),l=DG.isDate(j)||(!f&&DG.isDateString(j)),i=!b&&!h?Number(k):NaN,g=!a&&!f?Number(j):NaN,e=(i===i),c=(g===g);if(m||l){throw new DG.TypeError(d)}if(e&&c){switch(d){case"*":return i*g;case"/":return i/g;case"%":return i%g;case"^":return Math.pow(i,g);default:throw new SyntaxError("DG.Formula.SyntaxErrorInvalidOperator").loc(d)}}if(k instanceof Error){return k}if(j instanceof Error){return j}if((k!==k)||(j!==j)){return NaN}if(b&&a){return""}if((b&&c)||(e&&a)){return""}throw new DG.TypeError(d)};DG.Formula.compileToJavaScript=function(a,k){var h;function j(n){var m=h[n.type];return m&&m(n)}function e(m){return m.value}function b(m){return'"'+m.value.replace(/"/g,'\\"')+'"'}function g(m){return k.compileVariable(m.name,k.getAggregateFunctionIndices())}function l(q){var s=q.name.name,n=k.isAggregate(s),p,m=q.args&&q.args.length,r=[],o=[];k.beginFunctionContext({name:s,isAggregate:n});for(p=0;p<m;++p){o.push(j(q.args[p]))}r=k.getAggregateFunctionIndices();k.endFunctionContext({name:s});return k.compileFunction(s,o,r)}function f(n){var m=(n.type==="BinaryExpression"),o=j(n);if(m){o="("+o+")"}return o}function d(m){return m.operator+f(m.expression)}function c(n){var m=f(n.left),o=f(n.right);switch(n.operator){case"+":return"DG.Formula.add("+m+","+o+")";case"-":return"DG.Formula.subtract("+m+","+o+")";case"<":return"DG.Formula.lessThan("+m+","+o+")";case">":return"DG.Formula.lessThan("+o+","+m+")";case"<=":return"DG.Formula.lessThanOrEqual("+m+","+o+")";case">=":return"DG.Formula.lessThanOrEqual("+o+","+m+")";case"==":return"DG.Formula.equals("+m+","+o+")";case"!=":return"!DG.Formula.equals("+m+","+o+")"}if(["*","/","%","^"].indexOf(n.operator)>=0){return'DG.Formula.binaryOperator("'+n.operator+'",'+m+","+o+")"}return m+n.operator+o}function i(m){return"("+f(m.condition)+"?"+f(m.trueExpression)+":"+f(m.falseExpression)+")"}h={BooleanLiteral:e,NumericLiteral:e,StringLiteral:b,Variable:g,FunctionCall:l,UnaryExpression:d,BinaryExpression:c,ConditionalExpression:i};return j(a)};DG.Formula.evaluateParseTree=function(a,j,i){var f;function h(m){var l=f[m.type];return l&&l(m)}function d(l){return l.value}function e(l){return j.evaluateVariable(l.name,i)}function k(o){var n,l=o.args&&o.args.length,m=[];for(n=0;n<l;++n){m.push(h(o.args[n]))}return j.evaluateFunction(o.name.name,m)}function c(l){var m=h(l.expression);switch(l.operator){case"+":return +m;case"-":return -m;case"!":return !m}return undefined}function b(m){var n=h(m.left),l=h(m.right);switch(m.operator){case"^":return DG.Formula.binaryOperator("^",n,l);case"*":return DG.Formula.binaryOperator("*",n,l);case"/":return DG.Formula.binaryOperator("/",n,l);case"%":return DG.Formula.binaryOperator("%",n,l);case"+":return DG.Formula.add(n,l);case"-":return DG.Formula.subtract(n,l);case"<":return DG.Formula.lessThan(n,l);case">":return DG.Formula.lessThan(l,n);case"<=":return DG.Formula.lessThanOrEqual(n,l);case">=":return DG.Formula.lessThanOrEqual(l,n);case"==":case"===":return DG.Formula.equals(n,l);case"!=":case"!==":return !DG.Formula.equals(n,l);case"&&":return n&&l;case"||":return n||l;default:}throw new SyntaxError("DG.Formula.SyntaxErrorInvalidOperator".loc(m.operator))}function g(l){return h(l.condition)?h(l.trueExpression):h(l.falseExpression)}f={BooleanLiteral:d,NumericLiteral:d,StringLiteral:d,Variable:e,FunctionCall:k,UnaryExpression:c,BinaryExpression:b,ConditionalExpression:g};return h(a)};DG.Formula.renameVariable=function(g,b,h){function j(m){var l=e[m.type];return l&&l(m)}function a(l){return l}function f(l){if(l.name===b){return{type:l.type,name:h}}else{return l}}function k(l){return{args:l.args.map(function(m){return j(m)}),name:j(l.name),type:l.type}}function d(l){return{expression:j(l.expression),operator:l.operator,type:l.type}}function c(l){return{left:j(l.left),right:j(l.right),operator:l.operator,type:l.type}}function i(l){return{condition:j(l.condition),trueExpression:j(l.trueExpression),falseExpression:j(l.falseExpression),type:l.type}}var e={BooleanLiteral:a,NumericLiteral:a,StringLiteral:a,Variable:f,FunctionCall:k,UnaryExpression:d,BinaryExpression:c,ConditionalExpression:i};return j(g)};DG.Formula.toString=function(g){function i(l){var k=e[l.type];return k&&k(l)}function a(k){return k.value}function b(k){return'"'+k.value+'"'}function f(l){var k=l.name;if(!/^[a-zA-Z0-9]*$/.test(k)){k="`"+k+"`"}return k}function j(m){var l=m.args.map(function(n){return i(n)});var k=i(m.name);return k+"("+l.join()+")"}function d(l){var m=i(l.expression);var k=l.operator;return"("+k+m+")"}function c(k){var l={left:i(k.left),right:i(k.right),operator:k.operator};return"("+String(l.left)+" "+l.operator+" "+String(l.right)+")"}function h(k){var l={condition:i(k.condition),trueExpression:i(k.trueExpression),falseExpression:i(k.falseExpression)};return"("+String(l.condition)+")? ("+l.trueExpression+"): ("+l.falseExpression+")"}var e={BooleanLiteral:a,NumericLiteral:a,StringLiteral:b,Variable:f,FunctionCall:j,UnaryExpression:d,BinaryExpression:c,ConditionalExpression:h};return i(g)};sc_require("formula/formula");CodeMirror.defineSimpleMode("codapFormula",{start:[{regex:/(?:"(?:[^\\]|\\.)*?(?:"|$))|(?:'(?:[^\\]|\\.)*?(?:'|$))/,token:"string"},{regex:/0x[a-f\d]+|[-+]?(?:\.\d+|\d+\.?\d*)(?:e[-+]?\d+)?|true|false|pi|e|π/i,token:"number"},{regex:/[-+\/*=<>!^]+/,token:"operator"},{regex:DG.Formula.functionRegExp,token:"function"},{regex:DG.Formula.identifierRegExp,token:"variable"},{regex:/(?:`(?:[^\\]|\\.)*?(?:`|$))/,token:"variable"}],meta:{dontIndentStates:["start"]}});sc_require("formula/aggregate_function");sc_require("formula/function_registry");DG.functionRegistry.registerAggregates((function(){var c=function(e){this.name="EvalError";this.message="DG.Formula.LookupDataSetError.message".loc(e);this.description="DG.Formula.LookupDataSetError.description".loc(e);this.reference=e};c.prototype=new Error();c.prototype.constructor=c;var d=function(f,e){this.name="EvalError";this.message="DG.Formula.LookupAttrError.message".loc(f,e);this.description="DG.Formula.LookupAttrError.description".loc(f,e);this.reference=f};d.prototype=new Error();d.prototype.constructor=d;function b(f,e,n,l){var k=e&&e(n,l),h=f&&k&&f.getAttrRefByName(k),g=h&&h.collection,i=h&&h.attribute,m=i&&i.get("id"),j={isValid:!!f&&!!g&&!!m,dataContext:f,collection:g,attribute:i,attributeName:k,attributeID:m};if(!m){throw new d(k,f.get("title"))}return j}function a(e,i,h){if(e.isValid){var f=e.dataContext&&e.dataContext.get("dependencyMgr"),g={dependentSpec:i.get("ownerSpec"),independentSpec:{type:DG.DEP_TYPE_ATTRIBUTE,name:e.attributeName,id:e.attributeID},aggFnIndices:h.aggFnIndices,dependentContext:i,srcDependencyMgr:f};i.registerDependency(g);if(f){f.findOrRegisterNode(g.dependentSpec);f.registerDependency(g)}}}return{lookupByIndex:DG.AggregateFunction.create({category:"DG.Formula.FuncCategoryLookup",requiredArgs:{min:3,max:3},evaluate:function(p,m,n){var k={};if(!n.caches){n.caches={}}if(!n.caches.binding){var e=n.argFns[0],j=e&&e(p,m),g=j&&DG.currDocumentController().getContextByTitle(j);if(!g){throw new c(j)}k=b(g,n.argFns[1],p,m);a(k,p,n);n.caches.binding=k;if(k.isValid){var l=k.dataContext&&k.dataContext.get("dependencyMgr"),i={dependentSpec:p.get("ownerSpec"),independentSpec:{type:DG.DEP_TYPE_ATTRIBUTE,name:k.attributeName,id:k.attributeID},aggFnIndices:n.aggFnIndices,dependentContext:p,srcDependencyMgr:l};p.registerDependency(i);if(l){l.findOrRegisterNode(i.dependentSpec);l.registerDependency(i)}}}else{k=n.caches.binding}var q=k.collection&&k.collection.getPath("casesController.arrangedObjects"),o=n.argFns[2],h=o&&o(p,m),f=q&&q.objectAt(h-1);return(f&&k.attributeID&&f.getValue(k.attributeID))||""}}),lookupByKey:DG.AggregateFunction.create({category:"DG.Formula.FuncCategoryLookup",requiredArgs:{min:4,max:4},evaluate:function(o,m,n){var j={},k={},e,h,f;if(!n.caches){n.caches={}}if(!n.caches.valueBinding||!n.caches.keyBinding){e=n.argFns[0];h=e&&e(o,m);f=h&&DG.currDocumentController().getContextByTitle(h);if(!f){throw new c(h)}}if(!n.caches.valueBinding){j=b(f,n.argFns[1],o,m);a(j,o,n);n.caches.valueBinding=j}else{j=n.caches.valueBinding}if(!n.caches.keyBinding){k=b(f,n.argFns[2],o,m);a(k,o,n);n.caches.keyBinding=k}else{k=n.caches.keyBinding}if(!n.caches.keyValueMap){var l={},p=k.collection&&k.collection.getPath("casesController.arrangedObjects");if(p){p.forEach(function(r){var q=r&&r.getValue(k.attributeID),s=r&&r.getValue(j.attributeID);if(l[q]==null){l[q]=s}})}n.caches.keyValueMap=l}var g=n.argFns[3],i=g&&g(o,m);return n.caches.keyValueMap[i]}}),wordListMatches:DG.AggregateFunction.create({category:"DG.Formula.FuncCategoryString",requiredArgs:{min:3,max:4},evaluate:function(h,l,m){var e={},p,g,k,i;if(!m.caches){m.caches={}}if(!m.caches.wordsBinding||!m.caches.ratingsBinding){g=m.argFns[1];k=g&&g(h,l);i=k&&DG.currDocumentController().getContextByTitle(k);if(!i){throw new c(k)}}if(!m.caches.wordsBinding){e=b(i,m.argFns[2],h,l);a(e,h,m);m.caches.wordsBinding=e}else{e=m.caches.wordsBinding}if(m.argFns[3]){p={};if(!m.caches.ratingsBinding){p=b(i,m.argFns[3],h,l);a(p,h,m);m.caches.ratingsBinding=p}else{p=m.caches.ratingsBinding}}if(!m.caches.wordRatingMap){var o={},n=e.collection&&e.collection.getPath("casesController.arrangedObjects");if(n){n.forEach(function(r){var t=r&&r.getValue(e.attributeID),s=r?((p?r.getValue(p.attributeID):1)):null;if(o[t]==null){o[t]=s}})}m.caches.wordRatingMap=o}var f=m.argFns[0],j=f&&f(h,l),q=0;DG.ObjectMap.forEach(m.caches.wordRatingMap,function(x,t){if(!SC.empty(x)){var w=x.startsWith("/")&&x.endsWith("/"),v=w?x.substring(1,x.length-1):"\\b"+x+"\\b",s=w?"g":"gi",r=new RegExp(v,s),u=j.match(r);q+=t*(!u?0:u.length)}});return q}})}})());sc_require("formula/function_registry");DG.functionRegistry.registerFunctions((function(){function a(b){if(DG.isDate(b)){return b}return DG.createDate(b)}return{date:{minArgs:1,maxArgs:7,category:"DG.Formula.FuncCategoryDateTime",evalFn:function(n,b,s,k,g,o,d){var u,f,c,p=0;for(u=0;u<arguments.length;++u){var h=arguments[u];if(SC.empty(h)){if(!f&&(u>0)){f=u}}else{if(f){return""}if(!DG.isNumeric(h)){return""}c=u;++p}}if(p===0){return DG.createDate()}if((c===0)&&DG.DateUtilities.defaultToEpochSecs(n)){return DG.createDate(n)}var e=new Date(),l=e.getFullYear(),m=(l+10)%100,w=b>0?b-1:0,t=s||1,j=k||0,r=g||0,v=o||0,q=d||0;if(SC.empty(n)){n=l}else{if(n<m){n+=2000}else{if(n<100){n+=1900}}}return DG.createDate(n,w,t,j,r,v,q)}},dayOfMonth:{minArgs:1,maxArgs:1,category:"DG.Formula.FuncCategoryDateTime",evalFn:function(b){var c=a(b);return c&&c.getDate()}},dayOfWeek:{minArgs:1,maxArgs:1,category:"DG.Formula.FuncCategoryDateTime",evalFn:function(b){var c=a(b);return c&&(c.getDay()+1)}},dayOfWeekName:{minArgs:1,maxArgs:1,category:"DG.Formula.FuncCategoryDateTime",evalFn:function(c){var d=a(c),e=["DG.Formula.DateLongDaySunday","DG.Formula.DateLongDayMonday","DG.Formula.DateLongDayTuesday","DG.Formula.DateLongDayWednesday","DG.Formula.DateLongDayThursday","DG.Formula.DateLongDayFriday","DG.Formula.DateLongDaySaturday"],b=d&&e[d.getDay()];return b&&b.loc()}},hours:{minArgs:1,maxArgs:1,category:"DG.Formula.FuncCategoryDateTime",evalFn:function(b){var c=a(b);return c&&c.getHours()}},minutes:{minArgs:1,maxArgs:1,category:"DG.Formula.FuncCategoryDateTime",evalFn:function(b){var c=a(b);return c&&c.getMinutes()}},month:{minArgs:1,maxArgs:1,category:"DG.Formula.FuncCategoryDateTime",evalFn:function(b){var c=a(b);return c&&c.getMonth()+1}},monthName:{minArgs:1,maxArgs:1,category:"DG.Formula.FuncCategoryDateTime",evalFn:function(b){return DG.monthName(b)}},seconds:{minArgs:1,maxArgs:1,category:"DG.Formula.FuncCategoryDateTime",evalFn:function(b){var c=a(b);return c&&c.getSeconds()}},today:{minArgs:0,maxArgs:0,category:"DG.Formula.FuncCategoryDateTime",evalFn:function(){var b=new Date();return DG.createDate(b.getFullYear(),b.getMonth(),b.getDate())}},year:{minArgs:1,maxArgs:1,category:"DG.Formula.FuncCategoryDateTime",evalFn:function(b){var c=a(b);return c&&c.getFullYear()}}}})());DG.depMgrLog=function(){};DG.DEP_TYPE_ATTRIBUTE="attribute";DG.DEP_TYPE_GLOBAL="global";DG.DEP_TYPE_PLOT="plot";DG.DEP_TYPE_SPECIAL="special";DG.DEP_TYPE_UNDEFINED="undefined";DG.DependencyMgr=SC.Object.extend((function(){function a(e,d){if(e.type<d.type){return -1}if(e.type>d.type){return 1}if(e.id<d.id){return -1}if(e.id>d.id){return 1}return 0}function c(g,e,d,f,h){if(d){d.lastInvalidation=e._currentInvalidation}if(f&&f.dependentContext){f.dependentContext.invalidateDependent(g,d,f,[],h)}DG.depMgrLog("DG.DependencyMgr[%@]._invalidateDependency: Invalidating %@ '%@'",e.getPath("dataContext.name"),d.type,d.name);if(d&&f){b(g,e,d,h||(f.aggFnIndices.length>0))}}function b(f,e,d,g){d.dependents.forEach(function(h){if(h.lastInvalidation>=e._currentInvalidation){return}var i=e._findDependency(h,d);if(i){c(f,e,h,i,g)}})}return{dataContext:null,_nodes:null,_currentInvalidation:0,init:function(){this._nodes={}},createKey:function(d){return d.type+":"+d.id},hasNode:function(d){return !!this.findNode(d)},findNode:function(e){var d=this.createKey(e);return this._nodes[d]},findOrRegisterNode:function(d){return this.findNode(d)||this.registerNode(d)},findNodesWithNames:function(e){var d=[];DG.ObjectMap.forEach(this._nodes,function(f,g){if(e.indexOf(g.name)>=0){d.push(g)}});return d},findDependentsOfNodes:function(e){var d=[];e.forEach(function(f){var g=f&&f.dependents;if(g){g.forEach(function(h){if(d.indexOf(h)<0){d.push(h)}})}});return d},registerNode:function(e){if(this.hasNode(e)){return this.findNode(e)}var d=this.createKey(e),f=$.extend({},e,{dependencies:[],dependents:[],lastInvalidation:0});this._nodes[d]=f;return f},removeNode:function(e){this._clearDependencies(e);this._pruneDependencies(e);var d=this.createKey(e),f=this._nodes[d];if(f&&!(f.dependents&&f.dependents.length)){DG.depMgrLog("DG.DependencyMgr[%@].removeNode: Removing %@ '%@' from the dependency graph",this.getPath("dataContext.name"),e.type,e.name);delete this._nodes[d]}},findDependency:function(d,e){var g=this.findNode(d),f=this.findNode(e);return g&&f&&this._findDependency(g,f)},registerDependency:function(h){var g=this.findNode(h.dependentSpec),d=this.findNode(h.independentSpec),e=d?["a non-aggregate","an aggregate"]:["a new non-aggregate","a new aggregate"],f=this.findOrRegisterNode(h.independentSpec);DG.depMgrLog("DG.DependencyMgr[%@].registerDependency:\n%@ '%@' has %@ dependency on %@ '%@'",this.getPath("dataContext.name"),h.dependentSpec.type,h.dependentSpec.name,e[h.aggFnIndices.length>0?1:0],h.independentSpec.type,h.independentSpec.name);DG.assert(g!=null,"DG.DependencyMgr.registerDependency: dependentNode not found!","Formulas should be registered before they are compiled.");this._addDependency(g,f,h);this._addDependent(g,f)},_addDependency:function(p,d,m){var l=p.dependencies,n=l.length,h,e,k=m.aggFnIndices,g,f=k?k.length:0;for(h=0;h<n;++h){e=l[h];if(0===a(e.node,d)){if(f){for(g=0;g<f;++g){var o=k[g];if(e.aggFnIndices.indexOf(o)<0){e.aggFnIndices.push(o)}}}else{e.simpleDependency=true}return}}l.push({node:d,simpleDependency:!f,aggFnIndices:f?k.slice():[],dependentContext:m.dependentContext,srcDependencyMgr:m.srcDependencyMgr})},_findDependency:function(j,d){var k=this.findNode(j),h=k&&k.dependencies,g=h.length,f,e;for(f=0;f<g;++f){e=h[f];if(0===a(e.node,d)){return e}}return null},_addDependent:function(g,d){var j=d.dependents,f=j.length,e,h;for(e=0;e<f;++e){h=j[e];if(0===a(h,g)){return}}j.push(g)},_removeDependent:function(g,d){var j=d.dependents,f=j.length,e,h;for(e=f-1;e>=0;--e){h=j[e];if(0===a(h,g)){j.splice(e,1);return}}},_clearDependencies:function(e){var j=this.findNode(e);if(!j){return}var h=j.dependencies,g=h.length,f,d;for(f=0;f<g;++f){d=h[f];d.simpleDependency=false;d.aggFnIndices=[];if(d.srcDependencyMgr&&(this!==d.srcDependencyMgr)){d.srcDependencyMgr._clearDependencies(e)}}},_pruneDependencies:function(e){var k=this.findNode(e);if(!k){return}var h=k.dependencies,g=h.length,j,f,d;for(f=g-1;f>=0;--f){d=h[f];if(!d.simpleDependency&&!d.aggFnIndices.length){j=d.node;DG.depMgrLog("DG.DependencyMgr[%@]._pruneDependencies:\nRemoving dependence of %@ '%@' on %@ '%@'",this.getPath("dataContext.name"),k.type,k.name,j.type,j.name);this._removeDependent(k,j);h.splice(f,1)}if(d.srcDependencyMgr&&(this!==d.srcDependencyMgr)){d.srcDependencyMgr._pruneDependencies(e)}}},invalidateNames:function(g){var f,d={simpleDependencies:[],aggregateDependencies:[]};++this._currentInvalidation;var e=this.findNodesWithNames(g);e.forEach(function(h){b(d,this,e[f],true)});return d},invalidateDependency:function(f,g,i){var h=this.findNode(f),e=this.findDependency(f,g),d={simpleDependencies:[],aggregateDependencies:[]};if(e){++this._currentInvalidation;c(d,this,h,e,i)}return d},invalidateDependentsOf:function(e){var f,g=e.length,d={simpleDependencies:[],aggregateDependencies:[]};++this._currentInvalidation;for(f=0;f<g;++f){var h=this.findNode(e[f]);if(h){b(d,this,h)}}return d}}}()));DG.UNICODE={PLUS_SIGN:"+",MINUS_SIGN:"\u2212",MULTIPLICATION_SIGN:"\u00D7",DIVISION_SIGN:"\u00F7",EQUALS_SIGN:"=",NOT_EQUAL_TO:"\u2260",LESS_THAN_OR_EQUAL_TO:"\u2264",GREATER_THAN_OR_EQUAL_TO:"\u2265",GREEK_SMALL_LETTER_ALPHA:"\u03B1",GREEK_SMALL_LETTER_BETA:"\u03B2",GREEK_SMALL_LETTER_GAMMA:"\u03B3",GREEK_SMALL_LETTER_DELTA:"\u03B4",GREEK_SMALL_LETTER_EPSILON:"\u03B5",GREEK_SMALL_LETTER_ZETA:"\u03B6",GREEK_SMALL_LETTER_ETA:"\u03B7",GREEK_SMALL_LETTER_THETA:"\u03B8",GREEK_SMALL_LETTER_IOTA:"\u03B9",GREEK_SMALL_LETTER_KAPPA:"\u03BA",GREEK_SMALL_LETTER_LAMDA:"\u03BB",GREEK_SMALL_LETTER_MU:"\u03BC",GREEK_SMALL_LETTER_NU:"\u03BD",GREEK_SMALL_LETTER_XI:"\u03BE",GREEK_SMALL_LETTER_OMICRON:"\u03BF",GREEK_SMALL_LETTER_PI:"\u03C0",GREEK_SMALL_LETTER_RHO:"\u03C1",GREEK_SMALL_LETTER_FINAL_SIGMA:"\u03C2",GREEK_SMALL_LETTER_SIGMA:"\u03C3",GREEK_SMALL_LETTER_TAU:"\u03C4",GREEK_SMALL_LETTER_UPSILON:"\u03C5",GREEK_SMALL_LETTER_PHI:"\u03C6",GREEK_SMALL_LETTER_CHI:"\u03C7",GREEK_SMALL_LETTER_PSI:"\u03C8",GREEK_SMALL_LETTER_OMEGA:"\u03C9",INFINITY:"\u221E"};DG.SimpleMap=function(a){this.map=a||{}};DG.SimpleMap.prototype.toString=function(){var d="",e=16;for(var a in this.map){var c=d.length>=e,b=c?"...":a;d+=(d?", ":"")+b;if(c){break}}return"{"+d+"}"};DG.BoundaryMap=function(a){DG.SimpleMap.call(this,a)};DG.BoundaryMap.prototype=new DG.SimpleMap();DG.BoundaryMap.prototype.constructor=DG.BoundaryMap;DG.TypeError=function(a){this.name="DG.Formula.TypeError.name".loc();this.message="DG.Formula.TypeError.message".loc(a);this.description="DG.Formula.TypeError.description".loc(a)};DG.TypeError.prototype=new Error();DG.TypeError.prototype.constructor=DG.TypeError;DG.VarReferenceError=function(a){this.name="DG.Formula.VarReferenceError.name".loc();this.message="DG.Formula.VarReferenceError.message".loc(a);this.description="DG.Formula.VarReferenceError.description".loc(a);this.reference=a};DG.VarReferenceError.prototype=new Error();DG.VarReferenceError.prototype.constructor=DG.VarReferenceError;DG.HierReferenceError=function(a){this.name="DG.Formula.HierReferenceError.name".loc();this.message="DG.Formula.HierReferenceError.message".loc(a);this.description="DG.Formula.HierReferenceError.description".loc(a);this.reference=a};DG.HierReferenceError.prototype=new Error();DG.HierReferenceError.prototype.constructor=DG.HierReferenceError;DG.FuncReferenceError=function(a){this.name="DG.Formula.FuncReferenceError.name".loc();this.message="DG.Formula.FuncReferenceError.message".loc(a);this.description="DG.Formula.FuncReferenceError.description".loc(a);this.reference=a};DG.FuncReferenceError.prototype=new Error();DG.FuncReferenceError.prototype.constructor=DG.FuncReferenceError;DG.FuncArgsError=function(a,c){var b=c&&c.min,d=c&&c.max;this.name="DG.Formula.FuncArgsError.name".loc();if((b===1)&&(b===d)){this.message="DG.Formula.FuncArgsErrorSingle.message".loc(a,b);this.description="DG.Formula.FuncArgsErrorSingle.description".loc(a,b)}else{if((b>=0)&&!SC.none(d)&&(b!==d)){this.message="DG.Formula.FuncArgsErrorRange.message".loc(a,b,d);this.description="DG.Formula.FuncArgsErrorRange.description".loc(a,b,d)}else{this.message="DG.Formula.FuncArgsErrorPlural.message".loc(a,b);this.description="DG.Formula.FuncArgsErrorPlural.description".loc(a,b)}}this.reference=a};DG.FuncArgsError.prototype=new Error();DG.FuncArgsError.prototype.constructor=DG.FuncArgsError;DG.formulaParser=(function(){function c(f,d){function e(){this.constructor=f}e.prototype=d.prototype;f.prototype=new e()}function b(f,e,g,d){this.message=f;this.expected=e;this.found=g;this.location=d;this.name="SyntaxError";if(typeof Error.captureStackTrace==="function"){Error.captureStackTrace(this,b)}}c(b,Error);b.buildMessage=function(j,l){var i={literal:function(m){return'"'+h(m.text)+'"'},"class":function(m){var o="",n;for(n=0;n<m.parts.length;n++){o+=m.parts[n] instanceof Array?d(m.parts[n][0])+"-"+d(m.parts[n][1]):d(m.parts[n])}return"["+(m.inverted?"^":"")+o+"]"},any:function(m){return"any character"},end:function(m){return"end of input"},other:function(m){return m.description}};function f(m){return m.charCodeAt(0).toString(16).toUpperCase()}function h(m){return m.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(n){return"\\x0"+f(n)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(n){return"\\x"+f(n)})}function d(m){return m.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(n){return"\\x0"+f(n)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(n){return"\\x"+f(n)})}function g(m){return i[m.type](m)}function e(p){var n=new Array(p.length),o,m;for(o=0;o<p.length;o++){n[o]=g(p[o])}n.sort();if(n.length>0){for(o=1,m=1;o<n.length;o++){if(n[o-1]!==n[o]){n[m]=n[o];m++}}n.length=m}switch(n.length){case 1:return n[0];case 2:return n[0]+" or "+n[1];default:return n.slice(0,-1).join(", ")+", or "+n[n.length-1]}}function k(m){return m?'"'+h(m)+'"':"end of input"}return"Expected "+e(j)+" but "+k(l)+" found."};function a(bJ,cC){cC=cC!==void 0?cC:{};var aM={},t={start:di},cx=di,aF=function(dT){return dT},aD=f(),aC=a6("whitespace"),aB=/^[\t\x0B\f \xA0]/,aA=K(["\t","\x0B","\f"," ","\xA0"],false,false),az=/^[\n\r]/,ay=K(["\n","\r"],false,false),ax=a6("end of line"),aw="\n",av=bz("\n",false),dg="\r\n",de=bz("\r\n",false),dc="\r",da=bz("\r",false),c8=a6("identifier"),c6=function(dT){return dT},c4=function(dU,dT){return dU+dT.join("")},c2="_",c0=bz("_",false),cY="`",cQ=bz("`",false),cN=function(dT){return dT[1]},cL=function(dT){return dT.join("")},cJ="\\",cH=bz("\\",false),cG=function(dT){return dT},cF=function(dT){return dT},cE=function(dT){return{type:"NumericLiteral",value:dT}},cD=function(dT){return{type:"StringLiteral",value:dT}},cB=function(){return{type:"BooleanLiteral",value:true}},cy=function(){return{type:"BooleanLiteral",value:false}},cw=a6("number"),cv=function(dT){return dT},ct=".",cs=bz(".",false),cr=function(dU,dV,dT){return parseFloat(dU+"."+dV+dT)},cq=function(dU,dT){return parseFloat("."+dU+dT)},cp=function(dU,dT){return parseFloat(dU+dT)},co="0",cm=bz("0",false),cc=function(dU,dT){return dT?dU+dT:dU},cb=function(dT){return dT.join("")},ca=/^[0-9]/,b9=K([["0","9"]],false,false),b8=/^[1-9]/,b7=K([["1","9"]],false,false),b6=function(dT,dU){return dT+dU},b5=/^[eE]/,b4=K(["e","E"],false,false),b3=/^[\-+]/,bW=K(["-","+"],false,false),bU=function(dT,dU){return dT+dU},bT=/^[0-9a-fA-F]/,bS=K([["0","9"],["a","f"],["A","F"]],false,false),bR=a6("string"),bQ='"',bP=bz('"',false),bO="'",bM=bz("'",false),bK=function(dT){return dT[1]||""},bx=function(dT){return dT},bu=/^['"\\bfnrtv]/,bt=K(["'",'"',"\\","b","f","n","r","t","v"],false,false),bs=function(dT){return dT.replace("b","\b").replace("f","\f").replace("n","\n").replace("r","\r").replace("t","\t").replace("v","\x0B")},br="x",bp=bz("x",false),bo="u",bn=bz("u",false),bl=function(dU,dT){return String.fromCharCode(parseInt("0x"+dU+dT))},bk=function(dW,dV,dU,dT){return String.fromCharCode(parseInt("0x"+dW+dV+dU+dT))},a7="and",a5=bz("and",false),a4=function(){return"&&"},a2="AND",a0=bz("AND",false),aZ="or",aY=bz("or",false),aW=function(){return"||"},aU="OR",aT=bz("OR",false),au="false",at=bz("false",false),ar="FALSE",aq=bz("FALSE",false),ao="true",an=bz("true",false),am="TRUE",al=bz("TRUE",false),ak=/^[a-z|\u03B1-\u03C9]/,aj=K([["a","z"],"|",["\u03B1","\u03C9"]],false,false),T=/^(?!)/,S=K([],false,false),R=/^[A-Z|\u0391-\u03A9]/,Q=K([["A","Z"],"|",["\u0391","\u03A9"]],false,false),P=/^[_]/,O=K(["_"],false,false),M=/^[ \xA0]/,J=K([" ","\xA0"],false,false),I=function(dT){return{type:"Variable",name:dT}},H="(",aR=bz("(",false),aQ=")",aP=bz(")",false),aO=function(dT){return dT},aN=function(dU,dT){return{type:"FunctionCall",name:dU,args:dT}},aL=function(dU,dT){return{type:"FunctionCallArguments",args:dT}},aK=function(dW,dV){var dT=dW;for(var dU=0;dU<dV.length;dU++){switch(dV[dU].type){case"FunctionCallArguments":dT={type:"FunctionCall",name:dT,args:dV[dU].args};break;default:throw new Error("Invalid expression type: "+dV[dU].type)}}return dT},aJ=function(dT){return dT!==""?dT:[]},aH=",",aG=bz(",",false),ah=function(dW,dU){var dT=[dW];for(var dV=0;dV<dU.length;dV++){dT.push(dU[dV][3])}return dT},ag=function(dT,dU){if(dT==="!"){return{type:"UnaryExpression",operator:dT,expression:{type:"FunctionCall",name:{type:"FunctionCall",name:"boolean"},args:[dU]}}}return{type:"UnaryExpression",operator:dT,expression:dU}},af="+",ae=bz("+",false),ad="-",ac=bz("-",false),ab="\u2212",aa=bz("\u2212",false),Z=function(){return"-"},Y="!",G=bz("!",false),F=function(dW,dU){var dT=dU;for(var dV=dW.length-1;dV>=0;dV--){dT={type:"BinaryExpression",operator:"^",left:dW[dV][1],right:dT}}return dT},E="^",D=bz("^",false),z=function(dW,dU){var dT=dW;for(var dV=0;dV<dU.length;dV++){dT={type:"BinaryExpression",operator:dU[dV][1],left:dT,right:dU[dV][3]}}return dT},y="*",x=bz("*",false),w="/",v=bz("/",false),u="%",q=bz("%",false),n="=",m=bz("=",false),k=function(dT){return dT},i="\xD7",h=bz("\xD7",false),g=function(){return"*"},e="\xF7",d=bz("\xF7",false),dS=function(){return"/"},dM="\u22C5",dL=bz("\u22C5",false),dJ=function(){return"+"},dI="<=",dG=bz("<=",false),dF=">=",dE=bz(">=",false),dD="<",dC=bz("<",false),dB=">",dy=bz(">",false),dv="\u2264",du=bz("\u2264",false),dt=function(){return"<="},ds="\u2265",dr=bz("\u2265",false),dq=function(){return">="},dp=function(){return"=="},dn="!=",dm=bz("!=",false),df=function(){return"!="},dd="\u2260",db=bz("\u2260",false),c9=function(dW,dU){var dT=dW;for(var dV=0;dV<dU.length;dV++){dT={type:"BinaryExpression",operator:dU[dV][1],left:{type:"FunctionCall",name:{type:"FunctionCall",name:"boolean"},args:[dT]},right:{type:"FunctionCall",name:{type:"FunctionCall",name:"boolean"},args:[dU[dV][3]]}}}return dT},c7="&",c5=bz("&",false),c3=function(dW,dU){var dT=dW;for(var dV=0;dV<dU.length;dV++){dT={type:"BinaryExpression",operator:dU[dV][1],left:{type:"FunctionCall",name:{type:"FunctionCall",name:"boolean"},args:[dT]},right:{type:"FunctionCall",name:{type:"FunctionCall",name:"boolean"},args:[dU[dV][3]]}}}return dT},c1="|",cZ=bz("|",false),cX="?",cP=bz("?",false),cM=":",cK=bz(":",false),cI=function(dV,dT,dU){return{type:"ConditionalExpression",condition:{type:"FunctionCall",name:{type:"FunctionCall",name:"boolean"},args:[dV]},trueExpression:dT,falseExpression:dU}},bY=0,ap=0,bm=[{line:1,column:1}],bf=0,bh=[],dh=0,bG;if("startRule" in cC){if(!(cC.startRule in t)){throw new Error("Can't start parsing from rule \""+cC.startRule+'".')}cx=t[cC.startRule]}function cO(){return bJ.substring(ap,bY)}function cj(){return ai(ap,bY)}function dQ(dU,dT){dT=dT!==void 0?dT:ai(ap,bY);throw bH([a6(dU)],bJ.substring(ap,bY),dT)}function dA(dU,dT){dT=dT!==void 0?dT:ai(ap,bY);throw cW(dU,dT)}function bz(dU,dT){return{type:"literal",text:dU,ignoreCase:dT}}function K(dV,dU,dT){return{type:"class",parts:dV,inverted:dU,ignoreCase:dT}}function f(){return{type:"any"}}function bw(){return{type:"end"}}function a6(dT){return{type:"other",description:dT}}function N(dV){var dT=bm[dV],dU;if(dT){return dT}else{dU=dV-1;while(!bm[dU]){dU--}dT=bm[dU];dT={line:dT.line,column:dT.column};while(dU<dV){if(bJ.charCodeAt(dU)===10){dT.line++;dT.column=1}else{dT.column++}dU++}bm[dV]=dT;return dT}}function ai(dU,dT){var dW=N(dU),dV=N(dT);return{start:{offset:dU,line:dW.line,column:dW.column},end:{offset:dT,line:dV.line,column:dV.column}}}function cS(dT){if(bY<bf){return}if(bY>bf){bf=bY;bh=[]}bh.push(dT)}function cW(dU,dT){return new b(dU,null,null,dT)}function bH(dU,dV,dT){return new b(b.buildMessage(dU,dV),dU,dV,dT)}function di(){var dW,dV,dU,dT;dW=bY;dV=dH();if(dV!==aM){dU=o();if(dU!==aM){dT=dH();if(dT!==aM){ap=dW;dV=aF(dU);dW=dV}else{bY=dW;dW=aM}}else{bY=dW;dW=aM}}else{bY=dW;dW=aM}return dW}function dK(){var dT;if(bJ.length>bY){dT=bJ.charAt(bY);bY++}else{dT=aM;if(dh===0){cS(aD)}}return dT}function bB(){var dU,dT;dh++;if(aB.test(bJ.charAt(bY))){dU=bJ.charAt(bY);bY++}else{dU=aM;if(dh===0){cS(aA)}}if(dU===aM){dU=a1()}dh--;if(dU===aM){dT=aM;if(dh===0){cS(aC)}}return dU}function bc(){var dT;if(az.test(bJ.charAt(bY))){dT=bJ.charAt(bY);bY++}else{dT=aM;if(dh===0){cS(ay)}}return dT}function bX(){var dU,dT;dh++;if(bJ.charCodeAt(bY)===10){dU=aw;bY++}else{dU=aM;if(dh===0){cS(av)}}if(dU===aM){if(bJ.substr(bY,2)===dg){dU=dg;bY+=2}else{dU=aM;if(dh===0){cS(de)}}if(dU===aM){if(bJ.charCodeAt(bY)===13){dU=dc;bY++}else{dU=aM;if(dh===0){cS(da)}}}}dh--;if(dU===aM){dT=aM;if(dh===0){cS(ax)}}return dU}function dx(){var dV,dU,dT;dh++;dV=bY;dU=bY;dh++;dT=l();dh--;if(dT===aM){dU=void 0}else{bY=dU;dU=aM}if(dU!==aM){dT=X();if(dT!==aM){ap=dV;dU=c6(dT);dV=dU}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}if(dV===aM){dV=U()}dh--;if(dV===aM){dU=aM;if(dh===0){cS(c8)}}return dV}function X(){var dW,dV,dU,dT;dh++;dW=bY;dV=dN();if(dV!==aM){dU=[];dT=W();while(dT!==aM){dU.push(dT);dT=W()}if(dU!==aM){ap=dW;dV=c4(dV,dU);dW=dV}else{bY=dW;dW=aM}}else{bY=dW;dW=aM}dh--;if(dW===aM){dV=aM;if(dh===0){cS(c8)}}return dW}function dN(){var dT;dT=dO();if(dT===aM){if(bJ.charCodeAt(bY)===95){dT=c2;bY++}else{dT=aM;if(dh===0){cS(c0)}}}return dT}function W(){var dT;dT=dN();if(dT===aM){dT=a8();if(dT===aM){dT=V()}}return dT}function U(){var dX,dW,dV,dU,dT;dX=bY;dW=bY;if(bJ.charCodeAt(bY)===96){dV=cY;bY++}else{dV=aM;if(dh===0){cS(cQ)}}if(dV!==aM){dU=cl();if(dU!==aM){if(bJ.charCodeAt(bY)===96){dT=cY;bY++}else{dT=aM;if(dh===0){cS(cQ)}}if(dT!==aM){dV=[dV,dU,dT];dW=dV}else{bY=dW;dW=aM}}else{bY=dW;dW=aM}}else{bY=dW;dW=aM}if(dW!==aM){ap=dX;dW=cN(dW)}dX=dW;return dX}function cl(){var dV,dU,dT;dV=bY;dU=[];dT=bg();if(dT!==aM){while(dT!==aM){dU.push(dT);dT=bg()}}else{dU=aM}if(dU!==aM){ap=dV;dU=cL(dU)}dV=dU;return dV}function bg(){var dV,dU,dT;dV=bY;dU=bY;dh++;if(bJ.charCodeAt(bY)===96){dT=cY;bY++}else{dT=aM;if(dh===0){cS(cQ)}}if(dT===aM){if(bJ.charCodeAt(bY)===92){dT=cJ;bY++}else{dT=aM;if(dh===0){cS(cH)}}if(dT===aM){dT=bc()}}dh--;if(dT===aM){dU=void 0}else{bY=dU;dU=aM}if(dU!==aM){dT=dK();if(dT!==aM){ap=dV;dU=cG(dT);dV=dU}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}if(dV===aM){dV=bY;if(bJ.charCodeAt(bY)===92){dU=cJ;bY++}else{dU=aM;if(dh===0){cS(cH)}}if(dU!==aM){dT=bd();if(dT!==aM){ap=dV;dU=cF(dT);dV=dU}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}}return dV}function dO(){var dT;dT=bE();if(dT===aM){dT=bN()}return dT}function cn(){var dU,dT;dU=l();if(dU===aM){dU=bY;dT=aX();if(dT!==aM){ap=dU;dT=cE(dT)}dU=dT;if(dU===aM){dU=bY;dT=b1();if(dT!==aM){ap=dU;dT=cD(dT)}dU=dT}}return dU}function l(){var dU,dT;dU=bY;dT=be();if(dT!==aM){ap=dU;dT=cB()}dU=dT;if(dU===aM){dU=bY;dT=cu();if(dT!==aM){ap=dU;dT=cy()}dU=dT}return dU}function aX(){var dW,dV,dU,dT;dh++;dW=bY;dV=s();if(dV!==aM){dU=bY;dh++;dT=dN();dh--;if(dT===aM){dU=void 0}else{bY=dU;dU=aM}if(dU!==aM){ap=dW;dV=cv(dV);dW=dV}else{bY=dW;dW=aM}}else{bY=dW;dW=aM}dh--;if(dW===aM){dV=aM;if(dh===0){cS(cw)}}return dW}function s(){var dX,dW,dV,dU,dT;dX=bY;dW=bD();if(dW!==aM){if(bJ.charCodeAt(bY)===46){dV=ct;bY++}else{dV=aM;if(dh===0){cS(cs)}}if(dV!==aM){dU=r();if(dU===aM){dU=null}if(dU!==aM){dT=cA();if(dT===aM){dT=null}if(dT!==aM){ap=dX;dW=cr(dW,dU,dT);dX=dW}else{bY=dX;dX=aM}}else{bY=dX;dX=aM}}else{bY=dX;dX=aM}}else{bY=dX;dX=aM}if(dX===aM){dX=bY;if(bJ.charCodeAt(bY)===46){dW=ct;bY++}else{dW=aM;if(dh===0){cS(cs)}}if(dW!==aM){dV=r();if(dV!==aM){dU=cA();if(dU===aM){dU=null}if(dU!==aM){ap=dX;dW=cq(dV,dU);dX=dW}else{bY=dX;dX=aM}}else{bY=dX;dX=aM}}else{bY=dX;dX=aM}if(dX===aM){dX=bY;dW=bD();if(dW!==aM){dV=cA();if(dV===aM){dV=null}if(dV!==aM){ap=dX;dW=cp(dW,dV);dX=dW}else{bY=dX;dX=aM}}else{bY=dX;dX=aM}}}return dX}function bD(){var dV,dU,dT;if(bJ.charCodeAt(bY)===48){dV=co;bY++}else{dV=aM;if(dh===0){cS(cm)}}if(dV===aM){dV=bY;dU=bq();if(dU!==aM){dT=r();if(dT===aM){dT=null}if(dT!==aM){ap=dV;dU=cc(dU,dT);dV=dU}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}}return dV}function r(){var dV,dU,dT;dV=bY;dU=[];dT=bC();if(dT!==aM){while(dT!==aM){dU.push(dT);dT=bC()}}else{dU=aM}if(dU!==aM){ap=dV;dU=cb(dU)}dV=dU;return dV}function bC(){var dT;if(ca.test(bJ.charAt(bY))){dT=bJ.charAt(bY);bY++}else{dT=aM;if(dh===0){cS(b9)}}return dT}function bq(){var dT;if(b8.test(bJ.charAt(bY))){dT=bJ.charAt(bY);bY++}else{dT=aM;if(dh===0){cS(b7)}}return dT}function cA(){var dV,dU,dT;dV=bY;dU=a3();if(dU!==aM){dT=cf();if(dT!==aM){ap=dV;dU=b6(dU,dT);dV=dU}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}return dV}function a3(){var dT;if(b5.test(bJ.charAt(bY))){dT=bJ.charAt(bY);bY++}else{dT=aM;if(dh===0){cS(b4)}}return dT}function cf(){var dV,dU,dT;dV=bY;if(b3.test(bJ.charAt(bY))){dU=bJ.charAt(bY);bY++}else{dU=aM;if(dh===0){cS(bW)}}if(dU===aM){dU=null}if(dU!==aM){dT=r();if(dT!==aM){ap=dV;dU=bU(dU,dT);dV=dU}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}return dV}function j(){var dT;if(bT.test(bJ.charAt(bY))){dT=bJ.charAt(bY);bY++}else{dT=aM;if(dh===0){cS(bS)}}return dT}function b1(){var dX,dW,dV,dU,dT;dh++;dX=bY;dW=bY;if(bJ.charCodeAt(bY)===34){dV=bQ;bY++}else{dV=aM;if(dh===0){cS(bP)}}if(dV!==aM){dU=aI();if(dU===aM){dU=null}if(dU!==aM){if(bJ.charCodeAt(bY)===34){dT=bQ;bY++}else{dT=aM;if(dh===0){cS(bP)}}if(dT!==aM){dV=[dV,dU,dT];dW=dV}else{bY=dW;dW=aM}}else{bY=dW;dW=aM}}else{bY=dW;dW=aM}if(dW===aM){dW=bY;if(bJ.charCodeAt(bY)===39){dV=bO;bY++}else{dV=aM;if(dh===0){cS(bM)}}if(dV!==aM){dU=cd();if(dU===aM){dU=null}if(dU!==aM){if(bJ.charCodeAt(bY)===39){dT=bO;bY++}else{dT=aM;if(dh===0){cS(bM)}}if(dT!==aM){dV=[dV,dU,dT];dW=dV}else{bY=dW;dW=aM}}else{bY=dW;dW=aM}}else{bY=dW;dW=aM}}if(dW!==aM){ap=dX;dW=bK(dW)}dX=dW;dh--;if(dX===aM){dW=aM;if(dh===0){cS(bR)}}return dX}function aI(){var dV,dU,dT;dV=bY;dU=[];dT=ch();if(dT!==aM){while(dT!==aM){dU.push(dT);dT=ch()}}else{dU=aM}if(dU!==aM){ap=dV;dU=cL(dU)}dV=dU;return dV}function cd(){var dV,dU,dT;dV=bY;dU=[];dT=dP();if(dT!==aM){while(dT!==aM){dU.push(dT);dT=dP()}}else{dU=aM}if(dU!==aM){ap=dV;dU=cL(dU)}dV=dU;return dV}function ch(){var dV,dU,dT;dV=bY;dU=bY;dh++;if(bJ.charCodeAt(bY)===34){dT=bQ;bY++}else{dT=aM;if(dh===0){cS(bP)}}if(dT===aM){if(bJ.charCodeAt(bY)===92){dT=cJ;bY++}else{dT=aM;if(dh===0){cS(cH)}}if(dT===aM){dT=bc()}}dh--;if(dT===aM){dU=void 0}else{bY=dU;dU=aM}if(dU!==aM){dT=dK();if(dT!==aM){ap=dV;dU=bx(dT);dV=dU}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}if(dV===aM){dV=bY;if(bJ.charCodeAt(bY)===92){dU=cJ;bY++}else{dU=aM;if(dh===0){cS(cH)}}if(dU!==aM){dT=bd();if(dT!==aM){ap=dV;dU=cF(dT);dV=dU}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}}return dV}function dP(){var dV,dU,dT;dV=bY;dU=bY;dh++;if(bJ.charCodeAt(bY)===39){dT=bO;bY++}else{dT=aM;if(dh===0){cS(bM)}}if(dT===aM){if(bJ.charCodeAt(bY)===92){dT=cJ;bY++}else{dT=aM;if(dh===0){cS(cH)}}if(dT===aM){dT=bc()}}dh--;if(dT===aM){dU=void 0}else{bY=dU;dU=aM}if(dU!==aM){dT=dK();if(dT!==aM){ap=dV;dU=bx(dT);dV=dU}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}if(dV===aM){dV=bY;if(bJ.charCodeAt(bY)===92){dU=cJ;bY++}else{dU=aM;if(dh===0){cS(cH)}}if(dU!==aM){dT=bd();if(dT!==aM){ap=dV;dU=cF(dT);dV=dU}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}}return dV}function bd(){var dT;dT=b2();if(dT===aM){dT=dj();if(dT===aM){dT=cU()}}return dT}function b2(){var dT;dT=C();if(dT===aM){dT=B()}return dT}function C(){var dU,dT;dU=bY;if(bu.test(bJ.charAt(bY))){dT=bJ.charAt(bY);bY++}else{dT=aM;if(dh===0){cS(bt)}}if(dT!==aM){ap=dU;dT=bs(dT)}dU=dT;return dU}function B(){var dV,dU,dT;dV=bY;dU=bY;dh++;dT=cT();dh--;if(dT===aM){dU=void 0}else{bY=dU;dU=aM}if(dU===aM){dU=bc()}if(dU!==aM){dT=dK();if(dT!==aM){ap=dV;dU=cG(dT);dV=dU}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}return dV}function cT(){var dT;dT=C();if(dT===aM){dT=bC();if(dT===aM){if(bJ.charCodeAt(bY)===120){dT=br;bY++}else{dT=aM;if(dh===0){cS(bp)}}if(dT===aM){if(bJ.charCodeAt(bY)===117){dT=bo;bY++}else{dT=aM;if(dh===0){cS(bn)}}}}}return dT}function dj(){var dW,dV,dU,dT;dW=bY;if(bJ.charCodeAt(bY)===120){dV=br;bY++}else{dV=aM;if(dh===0){cS(bp)}}if(dV!==aM){dU=j();if(dU!==aM){dT=j();if(dT!==aM){ap=dW;dV=bl(dU,dT);dW=dV}else{bY=dW;dW=aM}}else{bY=dW;dW=aM}}else{bY=dW;dW=aM}return dW}function cU(){var dY,dX,dW,dV,dU,dT;dY=bY;if(bJ.charCodeAt(bY)===117){dX=bo;bY++}else{dX=aM;if(dh===0){cS(bn)}}if(dX!==aM){dW=j();if(dW!==aM){dV=j();if(dV!==aM){dU=j();if(dU!==aM){dT=j();if(dT!==aM){ap=dY;dX=bk(dW,dV,dU,dT);dY=dX}else{bY=dY;dY=aM}}else{bY=dY;dY=aM}}else{bY=dY;dY=aM}}else{bY=dY;dY=aM}}else{bY=dY;dY=aM}return dY}function cz(){var dW,dV,dU,dT;dW=bY;if(bJ.substr(bY,3)===a7){dV=a7;bY+=3}else{dV=aM;if(dh===0){cS(a5)}}if(dV!==aM){dU=bY;dh++;dT=W();dh--;if(dT===aM){dU=void 0}else{bY=dU;dU=aM}if(dU!==aM){ap=dW;dV=a4();dW=dV}else{bY=dW;dW=aM}}else{bY=dW;dW=aM}if(dW===aM){dW=bY;if(bJ.substr(bY,3)===a2){dV=a2;bY+=3}else{dV=aM;if(dh===0){cS(a0)}}if(dV!==aM){dU=bY;dh++;dT=W();dh--;if(dT===aM){dU=void 0}else{bY=dU;dU=aM}if(dU!==aM){ap=dW;dV=a4();dW=dV}else{bY=dW;dW=aM}}else{bY=dW;dW=aM}}return dW}function ba(){var dW,dV,dU,dT;dW=bY;if(bJ.substr(bY,2)===aZ){dV=aZ;bY+=2}else{dV=aM;if(dh===0){cS(aY)}}if(dV!==aM){dU=bY;dh++;dT=W();dh--;if(dT===aM){dU=void 0}else{bY=dU;dU=aM}if(dU!==aM){ap=dW;dV=aW();dW=dV}else{bY=dW;dW=aM}}else{bY=dW;dW=aM}if(dW===aM){dW=bY;if(bJ.substr(bY,2)===aU){dV=aU;bY+=2}else{dV=aM;if(dh===0){cS(aT)}}if(dV!==aM){dU=bY;dh++;dT=W();dh--;if(dT===aM){dU=void 0}else{bY=dU;dU=aM}if(dU!==aM){ap=dW;dV=aW();dW=dV}else{bY=dW;dW=aM}}else{bY=dW;dW=aM}}return dW}function cu(){var dW,dV,dU,dT;dW=bY;if(bJ.substr(bY,5)===au){dV=au;bY+=5}else{dV=aM;if(dh===0){cS(at)}}if(dV!==aM){dU=bY;dh++;dT=W();dh--;if(dT===aM){dU=void 0}else{bY=dU;dU=aM}if(dU!==aM){dV=[dV,dU];dW=dV}else{bY=dW;dW=aM}}else{bY=dW;dW=aM}if(dW===aM){if(bJ.substr(bY,5)===ar){dW=ar;bY+=5}else{dW=aM;if(dh===0){cS(aq)}}}return dW}function be(){var dW,dV,dU,dT;dW=bY;if(bJ.substr(bY,4)===ao){dV=ao;bY+=4}else{dV=aM;if(dh===0){cS(an)}}if(dV!==aM){dU=bY;dh++;dT=W();dh--;if(dT===aM){dU=void 0}else{bY=dU;dU=aM}if(dU!==aM){dV=[dV,dU];dW=dV}else{bY=dW;dW=aM}}else{bY=dW;dW=aM}if(dW===aM){if(bJ.substr(bY,4)===am){dW=am;bY+=4}else{dW=aM;if(dh===0){cS(al)}}}return dW}function bN(){var dT;if(ak.test(bJ.charAt(bY))){dT=bJ.charAt(bY);bY++}else{dT=aM;if(dh===0){cS(aj)}}return dT}function bL(){var dT;if(T.test(bJ.charAt(bY))){dT=bJ.charAt(bY);bY++}else{dT=aM;if(dh===0){cS(S)}}return dT}function bI(){var dT;if(T.test(bJ.charAt(bY))){dT=bJ.charAt(bY);bY++}else{dT=aM;if(dh===0){cS(S)}}return dT}function bF(){var dT;if(T.test(bJ.charAt(bY))){dT=bJ.charAt(bY);bY++}else{dT=aM;if(dh===0){cS(S)}}return dT}function bE(){var dT;if(R.test(bJ.charAt(bY))){dT=bJ.charAt(bY);bY++}else{dT=aM;if(dh===0){cS(Q)}}return dT}function by(){var dT;if(T.test(bJ.charAt(bY))){dT=bJ.charAt(bY);bY++}else{dT=aM;if(dh===0){cS(S)}}return dT}function bj(){var dT;if(T.test(bJ.charAt(bY))){dT=bJ.charAt(bY);bY++}else{dT=aM;if(dh===0){cS(S)}}return dT}function a8(){var dT;if(ca.test(bJ.charAt(bY))){dT=bJ.charAt(bY);bY++}else{dT=aM;if(dh===0){cS(b9)}}return dT}function aV(){var dT;if(T.test(bJ.charAt(bY))){dT=bJ.charAt(bY);bY++}else{dT=aM;if(dh===0){cS(S)}}return dT}function V(){var dT;if(P.test(bJ.charAt(bY))){dT=bJ.charAt(bY);bY++}else{dT=aM;if(dh===0){cS(O)}}return dT}function a1(){var dT;if(M.test(bJ.charAt(bY))){dT=bJ.charAt(bY);bY++}else{dT=aM;if(dh===0){cS(J)}}return dT}function bV(){var dU,dT;dU=[];dT=bB();while(dT!==aM){dU.push(dT);dT=bB()}return dU}function dH(){var dU,dT;dU=[];dT=bB();if(dT===aM){dT=bX()}while(dT!==aM){dU.push(dT);dT=bB();if(dT===aM){dT=bX()}}return dU}function bv(){var dY,dX,dW,dV,dU,dT;dY=bY;dX=dx();if(dX!==aM){ap=dY;dX=I(dX)}dY=dX;if(dY===aM){dY=cn();if(dY===aM){dY=bY;if(bJ.charCodeAt(bY)===40){dX=H;bY++}else{dX=aM;if(dh===0){cS(aR)}}if(dX!==aM){dW=dH();if(dW!==aM){dV=o();if(dV!==aM){dU=dH();if(dU!==aM){if(bJ.charCodeAt(bY)===41){dT=aQ;bY++}else{dT=aM;if(dh===0){cS(aP)}}if(dT!==aM){ap=dY;dX=aO(dV);dY=dX}else{bY=dY;dY=aM}}else{bY=dY;dY=aM}}else{bY=dY;dY=aM}}else{bY=dY;dY=aM}}else{bY=dY;dY=aM}}}return dY}function cg(){var dT;dT=bv();return dT}function dk(){var dY,dX,dW,dV,dU,dT;dY=bY;dX=bY;dW=cg();if(dW!==aM){dV=dH();if(dV!==aM){dU=ce();if(dU!==aM){ap=dX;dW=aN(dW,dU);dX=dW}else{bY=dX;dX=aM}}else{bY=dX;dX=aM}}else{bY=dX;dX=aM}if(dX!==aM){dW=[];dV=bY;dU=dH();if(dU!==aM){dT=ce();if(dT!==aM){ap=dV;dU=aL(dX,dT);dV=dU}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}while(dV!==aM){dW.push(dV);dV=bY;dU=dH();if(dU!==aM){dT=ce();if(dT!==aM){ap=dV;dU=aL(dX,dT);dV=dU}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}}if(dW!==aM){ap=dY;dX=aK(dX,dW);dY=dX}else{bY=dY;dY=aM}}else{bY=dY;dY=aM}return dY}function ce(){var dY,dX,dW,dV,dU,dT;dY=bY;if(bJ.charCodeAt(bY)===40){dX=H;bY++}else{dX=aM;if(dh===0){cS(aR)}}if(dX!==aM){dW=dH();if(dW!==aM){dV=bb();if(dV===aM){dV=null}if(dV!==aM){dU=dH();if(dU!==aM){if(bJ.charCodeAt(bY)===41){dT=aQ;bY++}else{dT=aM;if(dh===0){cS(aP)}}if(dT!==aM){ap=dY;dX=aJ(dV);dY=dX}else{bY=dY;dY=aM}}else{bY=dY;dY=aM}}else{bY=dY;dY=aM}}else{bY=dY;dY=aM}}else{bY=dY;dY=aM}return dY}function bb(){var dY,dX,dW,dV,dU,dT,d0,dZ;dY=bY;dX=o();if(dX!==aM){dW=[];dV=bY;dU=dH();if(dU!==aM){if(bJ.charCodeAt(bY)===44){dT=aH;bY++}else{dT=aM;if(dh===0){cS(aG)}}if(dT!==aM){d0=dH();if(d0!==aM){dZ=o();if(dZ!==aM){dU=[dU,dT,d0,dZ];dV=dU}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}while(dV!==aM){dW.push(dV);dV=bY;dU=dH();if(dU!==aM){if(bJ.charCodeAt(bY)===44){dT=aH;bY++}else{dT=aM;if(dh===0){cS(aG)}}if(dT!==aM){d0=dH();if(d0!==aM){dZ=o();if(dZ!==aM){dU=[dU,dT,d0,dZ];dV=dU}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}}if(dW!==aM){ap=dY;dX=ah(dX,dW);dY=dX}else{bY=dY;dY=aM}}else{bY=dY;dY=aM}return dY}function dl(){var dT;dT=dk();if(dT===aM){dT=cg()}return dT}function cV(){var dW,dV,dU,dT;dW=dl();if(dW===aM){dW=bY;dV=bi();if(dV!==aM){dU=dH();if(dU!==aM){dT=cV();if(dT!==aM){ap=dW;dV=ag(dV,dT);dW=dV}else{bY=dW;dW=aM}}else{bY=dW;dW=aM}}else{bY=dW;dW=aM}}return dW}function bi(){var dU,dT;if(bJ.charCodeAt(bY)===43){dU=af;bY++}else{dU=aM;if(dh===0){cS(ae)}}if(dU===aM){if(bJ.charCodeAt(bY)===45){dU=ad;bY++}else{dU=aM;if(dh===0){cS(ac)}}if(dU===aM){dU=bY;if(bJ.charCodeAt(bY)===8722){dT=ab;bY++}else{dT=aM;if(dh===0){cS(aa)}}if(dT!==aM){ap=dU;dT=Z()}dU=dT;if(dU===aM){if(bJ.charCodeAt(bY)===33){dU=Y;bY++}else{dU=aM;if(dh===0){cS(G)}}}}}return dU}function bZ(){var dY,dX,dW,dV,dU,dT,dZ;dY=bY;dX=[];dW=bY;dV=dH();if(dV!==aM){dU=cV();if(dU!==aM){dT=dH();if(dT!==aM){dZ=bA();if(dZ!==aM){dV=[dV,dU,dT,dZ];dW=dV}else{bY=dW;dW=aM}}else{bY=dW;dW=aM}}else{bY=dW;dW=aM}}else{bY=dW;dW=aM}while(dW!==aM){dX.push(dW);dW=bY;dV=dH();if(dV!==aM){dU=cV();if(dU!==aM){dT=dH();if(dT!==aM){dZ=bA();if(dZ!==aM){dV=[dV,dU,dT,dZ];dW=dV}else{bY=dW;dW=aM}}else{bY=dW;dW=aM}}else{bY=dW;dW=aM}}else{bY=dW;dW=aM}}if(dX!==aM){dW=cV();if(dW!==aM){ap=dY;dX=F(dX,dW);dY=dX}else{bY=dY;dY=aM}}else{bY=dY;dY=aM}return dY}function bA(){var dT;if(bJ.charCodeAt(bY)===94){dT=E;bY++}else{dT=aM;if(dh===0){cS(D)}}return dT}function ck(){var dY,dX,dW,dV,dU,dT,d0,dZ;dY=bY;dX=bZ();if(dX!==aM){dW=[];dV=bY;dU=dH();if(dU!==aM){dT=dw();if(dT!==aM){d0=dH();if(d0!==aM){dZ=bZ();if(dZ!==aM){dU=[dU,dT,d0,dZ];dV=dU}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}while(dV!==aM){dW.push(dV);dV=bY;dU=dH();if(dU!==aM){dT=dw();if(dT!==aM){d0=dH();if(d0!==aM){dZ=bZ();if(dZ!==aM){dU=[dU,dT,d0,dZ];dV=dU}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}}if(dW!==aM){ap=dY;dX=z(dX,dW);dY=dX}else{bY=dY;dY=aM}}else{bY=dY;dY=aM}return dY}function dw(){var dW,dV,dU,dT;dW=bY;if(bJ.charCodeAt(bY)===42){dV=y;bY++}else{dV=aM;if(dh===0){cS(x)}}if(dV===aM){if(bJ.charCodeAt(bY)===47){dV=w;bY++}else{dV=aM;if(dh===0){cS(v)}}if(dV===aM){if(bJ.charCodeAt(bY)===37){dV=u;bY++}else{dV=aM;if(dh===0){cS(q)}}}}if(dV!==aM){dU=bY;dh++;if(bJ.charCodeAt(bY)===61){dT=n;bY++}else{dT=aM;if(dh===0){cS(m)}}dh--;if(dT===aM){dU=void 0}else{bY=dU;dU=aM}if(dU!==aM){ap=dW;dV=k(dV);dW=dV}else{bY=dW;dW=aM}}else{bY=dW;dW=aM}if(dW===aM){dW=bY;if(bJ.charCodeAt(bY)===215){dV=i;bY++}else{dV=aM;if(dh===0){cS(h)}}if(dV!==aM){dU=bY;dh++;if(bJ.charCodeAt(bY)===61){dT=n;bY++}else{dT=aM;if(dh===0){cS(m)}}dh--;if(dT===aM){dU=void 0}else{bY=dU;dU=aM}if(dU!==aM){ap=dW;dV=g();dW=dV}else{bY=dW;dW=aM}}else{bY=dW;dW=aM}if(dW===aM){dW=bY;if(bJ.charCodeAt(bY)===247){dV=e;bY++}else{dV=aM;if(dh===0){cS(d)}}if(dV!==aM){dU=bY;dh++;if(bJ.charCodeAt(bY)===61){dT=n;bY++}else{dT=aM;if(dh===0){cS(m)}}dh--;if(dT===aM){dU=void 0}else{bY=dU;dU=aM}if(dU!==aM){ap=dW;dV=dS();dW=dV}else{bY=dW;dW=aM}}else{bY=dW;dW=aM}if(dW===aM){dW=bY;if(bJ.charCodeAt(bY)===8901){dV=dM;bY++}else{dV=aM;if(dh===0){cS(dL)}}if(dV!==aM){dU=bY;dh++;if(bJ.charCodeAt(bY)===61){dT=n;bY++}else{dT=aM;if(dh===0){cS(m)}}dh--;if(dT===aM){dU=void 0}else{bY=dU;dU=aM}if(dU!==aM){ap=dW;dV=g();dW=dV}else{bY=dW;dW=aM}}else{bY=dW;dW=aM}}}}return dW}function a9(){var dY,dX,dW,dV,dU,dT,d0,dZ;dY=bY;dX=ck();if(dX!==aM){dW=[];dV=bY;dU=dH();if(dU!==aM){dT=aE();if(dT!==aM){d0=dH();if(d0!==aM){dZ=ck();if(dZ!==aM){dU=[dU,dT,d0,dZ];dV=dU}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}while(dV!==aM){dW.push(dV);dV=bY;dU=dH();if(dU!==aM){dT=aE();if(dT!==aM){d0=dH();if(d0!==aM){dZ=ck();if(dZ!==aM){dU=[dU,dT,d0,dZ];dV=dU}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}}if(dW!==aM){ap=dY;dX=z(dX,dW);dY=dX}else{bY=dY;dY=aM}}else{bY=dY;dY=aM}return dY}function aE(){var dW,dV,dU,dT;dW=bY;if(bJ.charCodeAt(bY)===43){dV=af;bY++}else{dV=aM;if(dh===0){cS(ae)}}if(dV!==aM){dU=bY;dh++;if(bJ.charCodeAt(bY)===43){dT=af;bY++}else{dT=aM;if(dh===0){cS(ae)}}if(dT===aM){if(bJ.charCodeAt(bY)===61){dT=n;bY++}else{dT=aM;if(dh===0){cS(m)}}}dh--;if(dT===aM){dU=void 0}else{bY=dU;dU=aM}if(dU!==aM){ap=dW;dV=dJ();dW=dV}else{bY=dW;dW=aM}}else{bY=dW;dW=aM}if(dW===aM){dW=bY;if(bJ.charCodeAt(bY)===45){dV=ad;bY++}else{dV=aM;if(dh===0){cS(ac)}}if(dV!==aM){dU=bY;dh++;if(bJ.charCodeAt(bY)===45){dT=ad;bY++}else{dT=aM;if(dh===0){cS(ac)}}if(dT===aM){if(bJ.charCodeAt(bY)===61){dT=n;bY++}else{dT=aM;if(dh===0){cS(m)}}}dh--;if(dT===aM){dU=void 0}else{bY=dU;dU=aM}if(dU!==aM){ap=dW;dV=Z();dW=dV}else{bY=dW;dW=aM}}else{bY=dW;dW=aM}if(dW===aM){dW=bY;if(bJ.charCodeAt(bY)===8722){dV=ab;bY++}else{dV=aM;if(dh===0){cS(aa)}}if(dV!==aM){dU=bY;dh++;if(bJ.charCodeAt(bY)===8722){dT=ab;bY++}else{dT=aM;if(dh===0){cS(aa)}}if(dT===aM){if(bJ.charCodeAt(bY)===61){dT=n;bY++}else{dT=aM;if(dh===0){cS(m)}}}dh--;if(dT===aM){dU=void 0}else{bY=dU;dU=aM}if(dU!==aM){ap=dW;dV=Z();dW=dV}else{bY=dW;dW=aM}}else{bY=dW;dW=aM}}}return dW}function b0(){var dY,dX,dW,dV,dU,dT,d0,dZ;dY=bY;dX=a9();if(dX!==aM){dW=[];dV=bY;dU=dH();if(dU!==aM){dT=dz();if(dT!==aM){d0=dH();if(d0!==aM){dZ=a9();if(dZ!==aM){dU=[dU,dT,d0,dZ];dV=dU}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}while(dV!==aM){dW.push(dV);dV=bY;dU=dH();if(dU!==aM){dT=dz();if(dT!==aM){d0=dH();if(d0!==aM){dZ=a9();if(dZ!==aM){dU=[dU,dT,d0,dZ];dV=dU}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}}if(dW!==aM){ap=dY;dX=z(dX,dW);dY=dX}else{bY=dY;dY=aM}}else{bY=dY;dY=aM}return dY}function dz(){var dU,dT;if(bJ.substr(bY,2)===dI){dU=dI;bY+=2}else{dU=aM;if(dh===0){cS(dG)}}if(dU===aM){if(bJ.substr(bY,2)===dF){dU=dF;bY+=2}else{dU=aM;if(dh===0){cS(dE)}}if(dU===aM){if(bJ.charCodeAt(bY)===60){dU=dD;bY++}else{dU=aM;if(dh===0){cS(dC)}}if(dU===aM){if(bJ.charCodeAt(bY)===62){dU=dB;bY++}else{dU=aM;if(dh===0){cS(dy)}}if(dU===aM){dU=bY;if(bJ.charCodeAt(bY)===8804){dT=dv;bY++}else{dT=aM;if(dh===0){cS(du)}}if(dT!==aM){ap=dU;dT=dt()}dU=dT;if(dU===aM){dU=bY;if(bJ.charCodeAt(bY)===8805){dT=ds;bY++}else{dT=aM;if(dh===0){cS(dr)}}if(dT!==aM){ap=dU;dT=dq()}dU=dT}}}}}return dU}function A(){var dY,dX,dW,dV,dU,dT,d0,dZ;dY=bY;dX=b0();if(dX!==aM){dW=[];dV=bY;dU=dH();if(dU!==aM){dT=aS();if(dT!==aM){d0=dH();if(d0!==aM){dZ=b0();if(dZ!==aM){dU=[dU,dT,d0,dZ];dV=dU}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}while(dV!==aM){dW.push(dV);dV=bY;dU=dH();if(dU!==aM){dT=aS();if(dT!==aM){d0=dH();if(d0!==aM){dZ=b0();if(dZ!==aM){dU=[dU,dT,d0,dZ];dV=dU}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}}if(dW!==aM){ap=dY;dX=z(dX,dW);dY=dX}else{bY=dY;dY=aM}}else{bY=dY;dY=aM}return dY}function aS(){var dU,dT;dU=bY;if(bJ.charCodeAt(bY)===61){dT=n;bY++}else{dT=aM;if(dh===0){cS(m)}}if(dT!==aM){ap=dU;dT=dp()}dU=dT;if(dU===aM){dU=bY;if(bJ.substr(bY,2)===dn){dT=dn;bY+=2}else{dT=aM;if(dh===0){cS(dm)}}if(dT!==aM){ap=dU;dT=df()}dU=dT;if(dU===aM){dU=bY;if(bJ.charCodeAt(bY)===8800){dT=dd;bY++}else{dT=aM;if(dh===0){cS(db)}}if(dT!==aM){ap=dU;dT=df()}dU=dT}}return dU}function ci(){var dY,dX,dW,dV,dU,dT,d0,dZ;dY=bY;dX=A();if(dX!==aM){dW=[];dV=bY;dU=dH();if(dU!==aM){dT=p();if(dT!==aM){d0=dH();if(d0!==aM){dZ=A();if(dZ!==aM){dU=[dU,dT,d0,dZ];dV=dU}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}while(dV!==aM){dW.push(dV);dV=bY;dU=dH();if(dU!==aM){dT=p();if(dT!==aM){d0=dH();if(d0!==aM){dZ=A();if(dZ!==aM){dU=[dU,dT,d0,dZ];dV=dU}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}}if(dW!==aM){ap=dY;dX=c9(dX,dW);dY=dX}else{bY=dY;dY=aM}}else{bY=dY;dY=aM}return dY}function p(){var dW,dV,dU,dT;dW=bY;if(bJ.charCodeAt(bY)===38){dV=c7;bY++}else{dV=aM;if(dh===0){cS(c5)}}if(dV!==aM){dU=bY;dh++;if(bJ.charCodeAt(bY)===61){dT=n;bY++}else{dT=aM;if(dh===0){cS(m)}}dh--;if(dT===aM){dU=void 0}else{bY=dU;dU=aM}if(dU!==aM){ap=dW;dV=a4();dW=dV}else{bY=dW;dW=aM}}else{bY=dW;dW=aM}if(dW===aM){dW=cz()}return dW}function cR(){var dY,dX,dW,dV,dU,dT,d0,dZ;dY=bY;dX=ci();if(dX!==aM){dW=[];dV=bY;dU=dH();if(dU!==aM){dT=dR();if(dT!==aM){d0=dH();if(d0!==aM){dZ=ci();if(dZ!==aM){dU=[dU,dT,d0,dZ];dV=dU}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}while(dV!==aM){dW.push(dV);dV=bY;dU=dH();if(dU!==aM){dT=dR();if(dT!==aM){d0=dH();if(d0!==aM){dZ=ci();if(dZ!==aM){dU=[dU,dT,d0,dZ];dV=dU}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}}else{bY=dV;dV=aM}}if(dW!==aM){ap=dY;dX=c3(dX,dW);dY=dX}else{bY=dY;dY=aM}}else{bY=dY;dY=aM}return dY}function dR(){var dW,dV,dU,dT;dW=bY;if(bJ.charCodeAt(bY)===124){dV=c1;bY++}else{dV=aM;if(dh===0){cS(cZ)}}if(dV!==aM){dU=bY;dh++;if(bJ.charCodeAt(bY)===61){dT=n;bY++}else{dT=aM;if(dh===0){cS(m)}}dh--;if(dT===aM){dU=void 0}else{bY=dU;dU=aM}if(dU!==aM){ap=dW;dV=aW();dW=dV}else{bY=dW;dW=aM}}else{bY=dW;dW=aM}if(dW===aM){dW=ba()}return dW}function o(){var d2,d1,d0,dZ,dY,dX,dW,dV,dU,dT;d2=bY;d1=cR();if(d1!==aM){d0=dH();if(d0!==aM){if(bJ.charCodeAt(bY)===63){dZ=cX;bY++}else{dZ=aM;if(dh===0){cS(cP)}}if(dZ!==aM){dY=dH();if(dY!==aM){dX=o();if(dX!==aM){dW=dH();if(dW!==aM){if(bJ.charCodeAt(bY)===58){dV=cM;bY++}else{dV=aM;if(dh===0){cS(cK)}}if(dV!==aM){dU=dH();if(dU!==aM){dT=o();if(dT!==aM){ap=d2;d1=cI(d1,dX,dT);d2=d1}else{bY=d2;d2=aM}}else{bY=d2;d2=aM}}else{bY=d2;d2=aM}}else{bY=d2;d2=aM}}else{bY=d2;d2=aM}}else{bY=d2;d2=aM}}else{bY=d2;d2=aM}}else{bY=d2;d2=aM}}else{bY=d2;d2=aM}if(d2===aM){d2=cR()}return d2}bG=cx();if(bG!==aM&&bY===bJ.length){return bG}else{if(bG!==aM&&bY<bJ.length){cS(bw())}throw bH(bh,bf<bJ.length?bJ.charAt(bf):null,bf<bJ.length?ai(bf,bf+1):ai(bf,bf))}}return{SyntaxError:b,parse:a}})();DG.GeojsonUtils={boundaryObjectFromBoundaryValue:function(b){if(typeof b==="object"){return b}else{if((typeof b==="string")&&b.startsWith("{")){var a;try{a=JSON.parse(b)}catch(c){console.log(c)}return{jsonBoundaryObject:a}}else{return null}}}};sc_require("formula/function_registry");sc_require("utilities/geojson_utils");DG.functionRegistry.registerFunctions((function(){return{lookupBoundary:{minArgs:2,maxArgs:2,category:"DG.Formula.FuncCategoryLookup",evalFn:function(a,b){if(a instanceof Error){throw a}if(b instanceof Error){throw b}if(!a||!b){return""}if(!(a instanceof DG.BoundaryMap)){throw new DG.TypeError()}return a.map[b.toString().toLowerCase()]||""}}}})());sc_require("formula/function_registry");DG.functionRegistry.registerFunctions((function(){return{"boolean":{minArgs:1,maxArgs:1,category:"DG.Formula.FuncCategoryLogic",evalFn:function(a){return SC.empty(a)?"":!(a===false||(typeof a==="string"&&a.toLowerCase()==="false")||a===0||a==="0")}},isBoolean:{minArgs:1,maxArgs:1,category:"DG.Formula.FuncCategoryLogic",evalFn:function(a){if(typeof a==="string"){a=a.toLowerCase()}return[true,false,"true","false"].indexOf(a)>=0}},isBoundary:{minArgs:1,maxArgs:1,category:"DG.Formula.FuncCategoryLogic",evalFn:function(a){return typeof a==="object"&&a.hasOwnProperty("jsonBoundaryObject")}},isColor:{minArgs:1,maxArgs:1,category:"DG.Formula.FuncCategoryLogic",evalFn:function(a){return DG.ColorUtilities.isColorSpecString(a)}},isDate:{minArgs:1,maxArgs:1,category:"DG.Formula.FuncCategoryLogic",evalFn:function(a){return DG.isDateString(a)||DG.isDate(a)}},isFinite:{minArgs:1,maxArgs:1,category:"DG.Formula.FuncCategoryLogic",evalFn:function(a){return DG.isFinite(a)}},isMissing:{minArgs:1,maxArgs:1,category:"DG.Formula.FuncCategoryLogic",evalFn:function(a){return a===""||SC.none(a)}},isNumber:{minArgs:1,maxArgs:1,category:"DG.Formula.FuncCategoryLogic",evalFn:function(a){return DG.isNumeric(a)}}}})());sc_require("formula/aggregate_function");sc_require("formula/function_registry");DG.functionRegistry.registerAggregates({first:DG.AggregateFunction.create({category:"DG.Formula.FuncCategoryLookup",requiredArgs:{min:1,max:2},isCaseIndexDependent:function(){return true},evaluate:function(d,c,b){var f=b.argFns[0],g=b.argFns[1];function a(m){if(!m){return null}if(!g){return m.firstObject()}var k,j,l=m.get("length");for(k=0;k<l;++k){j=m.objectAt(k);if(g(d,{_case_:j,_id_:j.get("id")})){return j}}}function e(r,p){var j=p._case_,i=j&&j.get("parent"),n=i?i.get("children"):(r&&r.getPath("collection.cases")),k=j&&j.get("children"),m=a(n),q={_caseMap_:{}};if(m){q._caseMap_[m.getPath("collection.id")]=m}while(k&&k.length>0){m=a(k);if(m){var o=m.getPath("collection.id");q._caseMap_[o]=m}k=m&&m.get("children")}for(;i;i=i.get("parent")){var l=i.getPath("collection.id");q._caseMap_[l]=i}q._id_=m&&m.get("id");q._case_=m;return q}var h=f&&e(d,c);if(h&&DG.ObjectMap.length(h._caseMap_)){return f(d,h)}}}),last:DG.AggregateFunction.create({category:"DG.Formula.FuncCategoryLookup",requiredArgs:{min:1,max:2},isCaseIndexDependent:function(){return true},evaluate:function(e,d,c){var f=c.argFns[0],g=c.argFns[1];function h(m){if(!m){return null}if(!g){return m.lastObject()}var k,j,l=m.get("length");for(k=l-1;k>=0;--k){j=m.objectAt(k);if(g(e,{_case_:j,_id_:j.get("id")})){return j}}}function b(r,p){var j=p._case_,i=j&&j.get("parent"),n=i?i.get("children"):(r&&r.getPath("collection.cases")),k=j&&j.get("children"),m=h(n),q={_caseMap_:{}};if(m){q._caseMap_[m.getPath("collection.id")]=m}while(k&&k.length>0){m=h(k);if(m){var o=m.getPath("collection.id");q._caseMap_[o]=m}k=m&&m.get("children")}for(;i;i=i.get("parent")){var l=i.getPath("collection.id");q._caseMap_[l]=i}q._id_=m&&m.get("id");q._case_=m;return q}var a=f&&b(e,d);if(a&&DG.ObjectMap.length(a._caseMap_)){return f(e,a)}}}),next:DG.AggregateFunction.create({category:"DG.Formula.FuncCategoryLookup",requiredArgs:{min:1,max:3},isCaseIndexDependent:function(){return true},evaluate:function(f,d,e){var c=e.argFns[0],h=e.argFns[1],g=e.argFns[2];function i(n,l){if(!n||(l<0)){return null}if(!g){return n.objectAt(l)}var k,j,m=n.get("length");for(k=l;k<m;++k){j=n.objectAt(k);if(g(f,{_case_:j,_id_:j.get("id")})){return j}}}function a(q,o){var k=o._case_,j=k&&k.get("parent"),n=j?j.get("children"):(q&&q.getPath("collection.cases")),m=q.getCaseIndex(o._id_),r=i(n,m),p={_caseMap_:{},_case_:r,_id_:r&&r.get("id")};if(r){p._caseMap_[r.getPath("collection.id")]=r;for(;j;j=j.get("parent")){var l=j.getPath("collection.id");p._caseMap_[l]=j}}return p}var b=c&&a(f,d);return b&&DG.ObjectMap.length(b._caseMap_)?c(f,b):h?h(f,d):undefined}}),prev:DG.AggregateFunction.create({category:"DG.Formula.FuncCategoryLookup",requiredArgs:{min:1,max:3},isCaseIndexDependent:function(){return true},evaluate:function(e,c,d){var b=d.argFns[0],h=d.argFns[1],g=d.argFns[2];function i(m,l){if(!m||(l<0)){return null}if(!g){return m.objectAt(l)}var k,j;for(k=l;k>=0;--k){j=m.objectAt(k);if(g(e,{_case_:j,_id_:j.get("id")})){return j}}}function f(r,p){var k=p._case_,j=k&&k.get("parent"),o=j?j.get("children"):(r&&r.getPath("collection.cases")),m=r.getCaseIndex(p._id_),n=i(o,m-2),q={_caseMap_:{},_case_:n,_id_:n&&n.get("id")};if(n){q._caseMap_[n.getPath("collection.id")]=n;for(;j;j=j.get("parent")){var l=j.getPath("collection.id");q._caseMap_[l]=j}}return q}var a=b&&f(e,c);return a&&DG.ObjectMap.length(a._caseMap_)?b(e,a):h?h(e,c):undefined}})});DG.DataUtilities={};DG.DataUtilities.getMissingValue=function(){return null};DG.DataUtilities.isMissingValue=function(a){switch(typeof a){case"string":return a==="";case"number":return !isFinite(a);case"boolean":return false}return true};DG.DataUtilities.canonicalizeInputValue=function(b){if((b==null)||(b==="undefined")){return""}if(typeof b!=="string"){return b}var a=b.trim();return a};DG.DataUtilities.canonicalizeInternalValue=function(c){if((c==null)||(c==="undefined")){return""}if(typeof c!=="string"){return c}var a=function(d){var e=/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?(([+-]\d\d:\d\d)|Z)?$/i;return(typeof d==="string"&&e.test(d))}.bind(this);var b=c.trim();return a(b)?DG.createDate(b):b};DG.DataUtilities.canonicalizeAttributeValues=function(b,a){var c={};DG.ObjectMap.forEach(a,function(e,g){var d=b.findProperty("name",e)||b.findProperty("name",DG.Attribute.canonicalizeName(e)),f=DG.DataUtilities.canonicalizeInputValue(g);if(d!=null){c[d.id]=f}else{c[e]=f}});return c};DG.DataUtilities.isEqualIgnoreCase=function(f,e){var d=typeof f,c=typeof e,b,a;if(d===c&&d==="string"){b=f.toLowerCase();a=e.toLowerCase();return b===a}else{return f===e}};DG.DataUtilities.toString=function(c){var b=typeof c,a=c;if(DG.isDate(c)){a=DG.formatDate(c);b="string"}else{if(c instanceof Error){a=c.name+" "+c.message;b="string"}else{if(c instanceof DG.SimpleMap){b="map"}}}switch(b){case"string":return a;case"number":case"boolean":case"map":return String(c)}return""};var kTypeError=1,kTypeNaN=2,kTypeNull=3,kTypeString=4,kTypeBoolean=5,kTypeNumber=6,kTypeDate=7,kTypeSimpleMap=8,kTypeUnknown=9;DG.DataUtilities.sortableValue=function(d){function c(e){if(e==null){return kTypeNull}if(e instanceof Error){return kTypeError}if(DG.isDate(e)||DG.isDateString(e)){return kTypeDate}if(e instanceof DG.SimpleMap){return kTypeSimpleMap}switch(typeof e){case"number":return isNaN(e)?kTypeNaN:kTypeNumber;case"boolean":return kTypeBoolean;case"string":return kTypeString;default:return kTypeUnknown}}var b=c(d),a=b===kTypeNumber?d:NaN;if(b===kTypeString&&d.length){a=Number(d);if(!isNaN(a)){return{type:kTypeNumber,value:a}}}else{if(b===kTypeBoolean){return{type:kTypeString,value:d}}else{if(b===kTypeDate){return{type:kTypeNumber,value:Number(DG.createDate(d))}}}}return{type:b,value:d}};DG.DataUtilities.compareAscending=function(b,a){var e=DG.DataUtilities.sortableValue(b),d=DG.DataUtilities.sortableValue(a);if(e.type!==d.type){return e.type-d.type}function c(g,f){return g.localeCompare(f,undefined,{sensitivity:"base"})}switch(e.type){case kTypeNumber:return e.value-d.value;case kTypeString:case kTypeError:return c(String(e.value),String(d.value));default:return 0}};DG.DataUtilities.compareDescending=function(b,a){var e=DG.DataUtilities.sortableValue(b),d=DG.DataUtilities.sortableValue(a);if(e.type!==d.type){return d.type-e.type}function c(g,f){return -g.localeCompare(f,undefined,{sensitivity:"base"})}switch(e.type){case kTypeNumber:return d.value-e.value;case kTypeString:case kTypeError:return c(String(e.value),String(d.value));default:return 0}};DG.DataUtilities.createUniqueID=function(){return"id:"+nanoid(16)};sc_require("formula/function_registry");sc_require("utilities/data_utilities");DG.functionRegistry.registerFunctions((function(){var a=",";return{beginsWith:{minArgs:2,maxArgs:2,category:"DG.Formula.FuncCategoryString",evalFn:function(b,d){var c=DG.DataUtilities.toString(b),e=DG.DataUtilities.toString(d);if(!e){return true}if(!c){return false}return c.indexOf(e)===0}},charAt:{minArgs:1,maxArgs:1,category:"DG.Formula.FuncCategoryString",evalFn:function(b,d){var c=DG.DataUtilities.toString(b);if(d<0){d+=c.length+1}return c.charAt(d-1)}},concat:{minArgs:1,maxArgs:99,category:"DG.Formula.FuncCategoryString",evalFn:function(){var b=Array.prototype.slice.call(arguments);return b.length?b.join(""):""}},endsWith:{minArgs:2,maxArgs:2,category:"DG.Formula.FuncCategoryString",evalFn:function(c,e){var d=DG.DataUtilities.toString(c),f=DG.DataUtilities.toString(e);if(!f){return true}if(!d){return false}if(f.length>d.length){return false}var b=d.substr(-f.length);return b&&b.indexOf(f)===0}},findString:{minArgs:2,maxArgs:3,category:"DG.Formula.FuncCategoryString",evalFn:function(d,f,h){var e=DG.DataUtilities.toString(d),i=DG.DataUtilities.toString(f),b=h||0;if(!DG.isNumeric(b)){return 0}if(!i){return 1}if(!e){return 0}if(b<0){b+=e.length}var c=h?e.substr(b):e,g=c.indexOf(i);return g>=0?b+g+1:0}},patternMatches:{minArgs:2,maxArgs:2,category:"DG.Formula.FuncCategoryString",evalFn:function(d,g){var f=DG.DataUtilities.toString(d),e=DG.DataUtilities.toString(g);if(!e||!f){return 0}var c=new RegExp(e,"gmi"),b=f.match(c);return !b?0:b.length}},includes:{minArgs:2,maxArgs:2,category:"DG.Formula.FuncCategoryString",evalFn:function(b,d){var c=DG.DataUtilities.toString(b),e=DG.DataUtilities.toString(d);if(!e){return true}if(!c){return false}return c.toLowerCase().indexOf(e.toLowerCase())>=0}},join:{minArgs:1,maxArgs:99,category:"DG.Formula.FuncCategoryString",evalFn:function(c){var b=Array.prototype.slice.call(arguments,1),d=c!=null?c:" ";return b.length?b.join(d):""}},repeatString:{minArgs:2,maxArgs:2,category:"DG.Formula.FuncCategoryString",evalFn:function(c,f){var d=DG.DataUtilities.toString(c);if(!d||!f){return""}var e,b="";for(e=0;e<f;++e){b+=d}return b}},replaceChars:{minArgs:4,maxArgs:4,category:"DG.Formula.FuncCategoryString",evalFn:function(c,h,f,g){var d=DG.DataUtilities.toString(c);if(!d){return""}var b;if(!h){b=0}else{if(h>=1){b=h-1}else{if(h<0){b=h+d.length}else{return c}}}var i=d.substr(0,b),e=d.substr(b+f);return i+g+e}},replaceString:{minArgs:3,maxArgs:3,category:"DG.Formula.FuncCategoryString",evalFn:function(b,f,e){var c=DG.DataUtilities.toString(b),g=DG.DataUtilities.toString(f);if(!g){return c}var d=DG.StringUtilities.createEscapedRegExp(g,"g");return c.replace(d,e)}},sortItems:{minArgs:1,maxArgs:2,category:"DG.Formula.FuncCategoryString",evalFn:function(c,b){var d=DG.DataUtilities.toString(c),e;if(b===undefined||b===null){b=a}e=d.split(b).sort();return e.join(b)}},split:{minArgs:2,maxArgs:3,category:"DG.Formula.FuncCategoryString",evalFn:function(b,g,f){var d=DG.DataUtilities.toString(b),c=f?f:1,e=d.split(g);return((c>=1)&&(c<=e.length))?e[c-1]:""}},subString:{minArgs:2,maxArgs:3,category:"DG.Formula.FuncCategoryString",evalFn:function(c,g,e){var d=DG.DataUtilities.toString(c);if(!d){return""}if(!g){g=1}var b=g>=1?g-1:g+d.length,f=e!=null?e:d.length;return d.substr(b,f)}},stringLength:{minArgs:1,maxArgs:1,category:"DG.Formula.FuncCategoryString",evalFn:function(b){return DG.DataUtilities.toString(b).length}},toLower:{minArgs:1,maxArgs:1,category:"DG.Formula.FuncCategoryString",evalFn:function(b){return DG.DataUtilities.toString(b).toLowerCase()}},toUpper:{minArgs:1,maxArgs:1,category:"DG.Formula.FuncCategoryString",evalFn:function(b){return DG.DataUtilities.toString(b).toUpperCase()}},trim:{minArgs:1,maxArgs:1,category:"DG.Formula.FuncCategoryString",evalFn:function(b){return DG.DataUtilities.toString(b).trim().replace(/[\s\uFEFF\xA0][\s\uFEFF\xA0]*/g," ")}}}})());sc_require("formula/aggregate_function");sc_require("formula/function_registry");DG.functionRegistry.registerAggregates((function(){return{count:DG.ParentCaseAggregate.create({requiredArgs:{min:0,max:1},isCaseIndexDependent:function(a){return !a||!a.length},evaluate:function(d,c,b){if(b.argFns[0]!=null){return arguments.callee.base.apply(this,arguments)}var a=c._case_&&c._case_.get("children");return a?a.filter(function(e){return !e.isEmpty()}).length:0},evalCase:function(c,b,a,e){var d=this.getValue(c,b,a);if(!SC.empty(d)&&(d!==false)){if(a.results[e]){++a.results[e]}else{a.results[e]=1}}else{if(!a.results[e]){a.results[e]=0}}},computeResults:function(c,b,a){return arguments.callee.base.apply(this,arguments)||0}}),uniqueValues:DG.ParentCaseAggregate.create({requiredArgs:{min:1,max:1},evalCase:function(c,b,a,e){var d=this.getValue(c,b,a);if(!a.caches[e]){a.caches[e]=new Set()}if(!SC.empty(d)){a.caches[e].add(d)}},computeResults:function(c,b,a){DG.ObjectMap.forEach(a.caches,function(e,d){a.results[e]=d.size});return this.queryCache(c,b,a)}}),min:DG.ParentCaseAggregate.create({requiredArgs:{min:1,max:1},evalCase:function(d,c,b,f){var e=this.getNumericValue(d,c,b);if(e!=null){var a=b.caches[f];if(a){if(a.min>e){a.min=e}}else{b.caches[f]={min:e}}}},computeResults:function(c,b,a){DG.ObjectMap.forEach(a.caches,function(e,d){a.results[e]=d.min});return this.queryCache(c,b,a)}}),max:DG.ParentCaseAggregate.create({requiredArgs:{min:1,max:1},evalCase:function(d,c,b,f){var e=this.getNumericValue(d,c,b);if(e!=null){var a=b.caches[f];if(a){if(a.max<e){a.max=e}}else{b.caches[f]={max:e}}}},computeResults:function(c,b,a){DG.ObjectMap.forEach(a.caches,function(e,d){a.results[e]=d.max});return this.queryCache(c,b,a)}}),mean:DG.ParentCaseAggregate.create({requiredArgs:{min:1,max:1},evalCase:function(d,c,b,f){var e=this.getNumericValue(d,c,b);if(e!=null){var a=b.caches[f];if(a){a.count+=1;a.sum+=e}else{b.caches[f]={count:1,sum:e}}}},computeResults:function(c,b,a){DG.ObjectMap.forEach(a.caches,function(e,d){a.results[e]=d.count>0?d.sum/d.count:null});return this.queryCache(c,b,a)}}),median:DG.SortDataFunction.create({requiredArgs:{min:1,max:1},extractResult:function(c,b,a){return DG.MathUtilities.medianOfNumericArray(c)}}),variance:DG.CachedValuesParentCaseAggregate.create({requiredArgs:{min:1,max:1},computeResultFromCache:function(a){return this.computeVarianceFromCache(a)}}),stdDev:DG.CachedValuesParentCaseAggregate.create({requiredArgs:{min:1,max:1},computeResultFromCache:function(a){return Math.sqrt(this.computeVarianceFromCache(a))}}),stdErr:DG.CachedValuesParentCaseAggregate.create({requiredArgs:{min:1,max:1},computeResultFromCache:function(a){var c=a.values&&a.values.length,b=Math.sqrt(this.computeVarianceFromCache(a));return b/Math.sqrt(c)}}),mad:DG.CachedValuesParentCaseAggregate.create({requiredArgs:{min:1,max:1},computeResultFromCache:function(b){var c=b.values&&b.values.length,a=b.sum/c;return b.values&&b.values.reduce(function(d,e){return d+Math.abs(a-e)},0)/c}}),percentile:DG.SortDataFunction.create({requiredArgs:{min:2,max:2},preEvaluate:function(e,d,c){arguments.callee.base.apply(this,arguments);var a=c.argFns[1],b=a?a(e,d):undefined;if(!c.caches){c.caches={}}c.caches._percentile_=b},extractResult:function(c,b,a){return DG.MathUtilities.quantileOfSortedArray(c,a.caches._percentile_)}}),sum:DG.ParentCaseAggregate.create({requiredArgs:{min:1,max:1},evalCase:function(c,b,a,e){var d=this.getNumericValue(c,b,a);if(a.results[e]==null){a.results[e]=0}if(d!=null){if(a.results[e]){a.results[e]+=d}else{a.results[e]=d}}}}),combine:DG.ParentCaseAggregate.create({category:"DG.Formula.FuncCategoryString",requiredArgs:{min:1,max:1},evalCase:function(c,b,a,e){var d=this.getValue(c,b,a);if(d!=null){if(a.results[e]){a.results[e]+=String(d)}else{a.results[e]=String(d)}}}}),rollingMean:DG.AggregateFunction.create({category:"DG.Formula.FuncCategoryStatistical",requiredArgs:{min:2,max:3},isCaseIndexDependent:function(){return false},evaluate:function(h,e,f){var d=f.argFns[0],b=f.argFns[1],i=f.argFns[2];function a(w,v){var m=Math.round(b(w,v));if(m<1){return[]}var o=Math.floor(m/2);var n=m-1-o;var s=[];var k=v._case_;var j=k&&k.get("parent");var t=j?j.get("children"):(w&&w.getPath("collection.cases"));var r=w.getCaseIndex(v._id_);var p=r-1;var q=o;var l;var u=DG.getNumeric(d(w,v));if(o>p||n>=(t.length-p)){return[]}if(u!=null){s.push(u)}while(p>0&&q>0){p-=1;l=t[p];if(!i||i(w,{_case_:l,_id_:l.get("id")})){u=DG.getNumeric(d(w,{_case_:l,_id_:l&&l.get("id")}));if(u!=null){s.push(u)}q-=1}}p=r-1;q=n;while(p<t.length-1&&q>0){p+=1;l=t[p];if(l&&(!i||i(w,{_case_:l,_id_:l.get("id")}))){u=DG.getNumeric(d(w,{_case_:l,_id_:l&&l.get("id")}));if(u!=null){s.push(u)}q-=1}}return s}var g=a(h,e);if(g.length===0){return null}var c=g.reduce(function(k,l,j){return k+l}.bind(this),0);return c/g.length}})}}()));!function(a){"object"==typeof exports?module.exports=a():"function"==typeof define&&define.amd?define(a):"undefined"!=typeof window?window.iframePhone=a():"undefined"!=typeof global?global.iframePhone=a():"undefined"!=typeof self&&(self.iframePhone=a())}(function(){var d,b,a;return(function c(f,k,h){function g(n,l){if(!k[n]){if(!f[n]){var i=typeof require=="function"&&require;if(!l&&i){return i(n,!0)}if(e){return e(n,!0)}throw new Error("Cannot find module '"+n+"'")}var m=k[n]={exports:{}};f[n][0].call(m.exports,function(o){var p=f[n][1][o];return g(p?p:o)},m,m.exports,c,f,k,h)}return k[n].exports}var e=typeof require=="function"&&require;for(var j=0;j<h.length;j++){g(h[j])}return g})({1:[function(f,e,j){var k=f("./structured-clone");var l=200;var h=60000;function i(){var u={};var v=false;var q=false;var A=[];var s;function t(D){if(k.supported()){window.parent.postMessage(D,"*")}else{window.parent.postMessage(JSON.stringify(D),"*")}}function w(D,F){var E;if(arguments.length===1&&typeof D==="object"&&typeof D.type==="string"){E=D}else{E={type:D,content:F}}if(q){t(E)}else{A.push(E)}}function x(){t({type:"hello"})}function o(E,D){u[E]=D}function C(){u={}}function n(){return Object.keys(u)}function z(E){if(E.source!==window.parent){return}var D=E.data;if(typeof D==="string"){D=JSON.parse(D)}if(!q&&D.type==="hello"){q=true;B();while(A.length>0){w(A.shift())}}if(q&&u[D.type]){u[D.type](D.content)}}function y(){q=false;B();window.removeEventListener("message",z)}function r(){if(v){return}v=true;if(window.parent===window){return}p();window.addEventListener("message",z,false)}function p(){if(s){B()}s=window.setInterval(x,l);window.setTimeout(B,h);x()}function B(){window.clearInterval(s);s=null}return{initialize:r,getListenerNames:n,addListener:o,removeAllListeners:C,disconnect:y,post:w}}var m=null;e.exports=function g(){if(!m){m=new i()}return m}},{"./structured-clone":4}],2:[function(h,i,g){var f=h("./parent-endpoint");var k=h("./iframe-endpoint");function j(){var o="abcdefghijklmnopqrstuvwxyz0123456789";var l=o.length;var m=[];for(var n=0;n<10;n++){m.push(o[Math.floor(Math.random()*l)])}return m.join("")}i.exports=function e(r,q,s,n,l){var o=Object.create({});if(r&&typeof r==="object"){q=r.namespace;s=r.targetWindow;n=r.targetOrigin;l=r.phone;r=r.handler}if(!l){if(s===window.parent){l=k();l.initialize()}else{l=new f(s,n)}}l.addListener(q,function(u){var t;if(u.messageType==="call"&&typeof this.handler==="function"){this.handler.call(undefined,u.value,function(v){l.post(q,{messageType:"returnValue",uuid:u.uuid,value:v})})}else{if(u.messageType==="returnValue"){t=o[u.uuid];if(t){window.clearTimeout(t.timeout);if(t.callback){t.callback.call(undefined,u.value)}o[u.uuid]=null}}}}.bind(this));function p(u,v){var t=j();o[t]={callback:v,timeout:window.setTimeout(function(){if(v){v(undefined,new Error("IframePhone timed out waiting for reply"))}},2000)};l.post(q,{messageType:"call",uuid:t,value:u})}function m(){l.disconnect()}this.handler=r;this.call=p.bind(this);this.disconnect=m.bind(this)}},{"./iframe-endpoint":1,"./parent-endpoint":3}],3:[function(g,h,f){var i=g("./structured-clone");h.exports=function e(x,o,p){var w=[];var m=false;var k={};var l;function r(y){return y.src.match(/(.*?\/\/.*?)\//)[1]}function s(z,B){var A;if(arguments.length===1&&typeof z==="object"&&typeof z.type==="string"){A=z}else{A={type:z,content:B}}if(m){var y=v();if(i.supported()){y.postMessage(A,o)}else{y.postMessage(JSON.stringify(A),o)}}else{w.push(A)}}function j(y,z){k[y]=z}function n(y){k[y]=null}function v(){if(l){var y=x.contentWindow;if(!y){throw"IFrame element needs to be added to DOM before communication can be started (.contentWindow is not available)"}return y}return x}function u(z){var y;if(z.source===v()&&(o==="*"||z.origin===o)){y=z.data;if(typeof y==="string"){y=JSON.parse(y)}if(k[y.type]){k[y.type](y.content)}else{console.log("cant handle type: "+y.type)}}}function t(){m=false;window.removeEventListener("message",u)}try{l=x.constructor===HTMLIFrameElement}catch(q){l=false}if(l){if(!o||o.constructor===Function){p=o;o=r(x)}}if(o==="file://"){o="*"}j("hello",function(){m=true;s({type:"hello",origin:window.location.href.match(/(.*?\/\/.*?)\//)[1]});if(p&&typeof p==="function"){p()}while(w.length>0){s(w.shift())}});window.addEventListener("message",u,false);return{post:s,addListener:j,removeListener:n,disconnect:t,getTargetWindow:v,targetOrigin:o}}},{"./structured-clone":4}],4:[function(h,i,g){var f={structuredClones:0};(function(){var j=0;if(!!window.postMessage){try{window.postMessage(document.createElement("a"),"*")}catch(k){j=(k.DATA_CLONE_ERR||k.message==="Cannot post cyclic structures.")?1:0;f={structuredClones:j}}}}());g.supported=function e(){return f&&f.structuredClones>0}},{}],5:[function(f,g,e){g.exports={ParentEndpoint:f("./lib/parent-endpoint"),getIFrameEndpoint:f("./lib/iframe-endpoint"),structuredClone:f("./lib/structured-clone"),IframePhoneRpcEndpoint:f("./lib/iframe-phone-rpc-endpoint")}},{"./lib/iframe-endpoint":1,"./lib/iframe-phone-rpc-endpoint":2,"./lib/parent-endpoint":3,"./lib/structured-clone":4}]},{},[5])(5)});
/*! 
 * jquery.event.drag - v 2.2
 * Copyright (c) 2010 Three Dub Media - http://threedubmedia.com
 * Open Source MIT License - http://threedubmedia.com/code/license
 */
;(function(e){e.fn.drag=function(k,g,j){var i=typeof k=="string"?k:"",h=e.isFunction(k)?k:e.isFunction(g)?g:null;if(i.indexOf("drag")!==0){i="drag"+i}j=(k==h?g:j)||{};return h?this.bind(i,j,h):this.trigger(i)};var b=e.event,a=b.special,d=a.drag={defaults:{which:1,distance:0,not:":input",handle:null,relative:false,touch:true,drop:true,click:false},datakey:"dragdata",noBubble:true,add:function(i){var h=e.data(this,d.datakey),g=i.data||{};h.related+=1;e.each(d.defaults,function(j,k){if(g[j]!==undefined){h[j]=g[j]}})},remove:function(){e.data(this,d.datakey).related-=1},setup:function(){if(e.data(this,d.datakey)){return}var g=e.extend({related:0},d.defaults);e.data(this,d.datakey,g);b.add(this,"touchstart mousedown",d.init,g);if(this.attachEvent){this.attachEvent("ondragstart",d.dontstart)}},teardown:function(){var g=e.data(this,d.datakey)||{};if(g.related){return}e.removeData(this,d.datakey);b.remove(this,"touchstart mousedown",d.init);d.textselect(true);if(this.detachEvent){this.detachEvent("ondragstart",d.dontstart)}},init:function(j){if(d.touched){return}var g=j.data,h;if(!g.touch&&j.type=="touchstart"){return}if(j.which!=0&&g.which>0&&j.which!=g.which){return}if(e(j.target).is(g.not)){return}if(g.handle&&!e(j.target).closest(g.handle,j.currentTarget).length){return}d.touched=j.type=="touchstart"?this:null;g.propagates=1;g.mousedown=this;g.interactions=[d.interaction(this,g)];g.target=j.target;g.pageX=j.pageX;g.pageY=j.pageY;g.dragging=null;h=d.hijack(j,"draginit",g);if(!g.propagates){return}h=d.flatten(h);if(h&&h.length){g.interactions=[];var i=this;e.each(h,function(){g.interactions.push(d.interaction(i,g))})}g.propagates=g.interactions.length;if(g.drop!==false&&a.drop){a.drop.handler(j,g)}d.textselect(false);if(d.touched){b.add(d.touched,"touchmove touchend",d.handler,g)}else{b.add(document,"mousemove mouseup",d.handler,g)}if(!d.touched||g.live){return false}},interaction:function(h,g){var i=e(h)[g.relative?"position":"offset"]()||{top:0,left:0};return{drag:h,callback:new d.callback(),droppable:[],offset:i}},handler:function(h){var g=h.data;switch(h.type){case !g.dragging&&"touchmove":h.preventDefault();case !g.dragging&&"mousemove":if(Math.pow(h.pageX-g.pageX,2)+Math.pow(h.pageY-g.pageY,2)<Math.pow(g.distance,2)){break}h.target=g.target;d.hijack(h,"dragstart",g);if(g.propagates){g.dragging=true}case"touchmove":h.preventDefault();case"mousemove":if(g.dragging){d.hijack(h,"drag",g);if(g.propagates){if(g.drop!==false&&a.drop){a.drop.handler(h,g)}break}h.type="mouseup"}case"touchend":case"mouseup":default:if(d.touched){b.remove(d.touched,"touchmove touchend",d.handler)}else{b.remove(document,"mousemove mouseup",d.handler)}if(g.dragging){if(g.drop!==false&&a.drop){a.drop.handler(h,g)}d.hijack(h,"dragend",g)}d.textselect(true);if(g.click===false&&g.dragging){e.data(g.mousedown,"suppress.click",new Date().getTime()+5)}g.dragging=d.touched=false;break}},hijack:function(h,o,r,p,k){if(!r){return}var q={event:h.originalEvent,type:h.type},m=o.indexOf("drop")?"drag":"drop",t,l=p||0,j,g,s,n=!isNaN(p)?p:r.interactions.length;h.type=o;h.originalEvent=null;r.results=[];do{if(j=r.interactions[l]){if(o!=="dragend"&&j.cancelled){continue}s=d.properties(h,r,j);j.results=[];e(k||j[m]||r.droppable).each(function(u,i){s.target=i;h.isPropagationStopped=function(){return false};t=i?b.dispatch.call(i,h,s):null;if(t===false){if(m=="drag"){j.cancelled=true;r.propagates-=1}if(o=="drop"){j[m][u]=null}}else{if(o=="dropinit"){j.droppable.push(d.element(t)||i)}}if(o=="dragstart"){j.proxy=e(d.element(t)||j.drag)[0]}j.results.push(t);delete h.result;if(o!=="dropinit"){return t}});r.results[l]=d.flatten(j.results);if(o=="dropinit"){j.droppable=d.flatten(j.droppable)}if(o=="dragstart"&&!j.cancelled){s.update()}}}while(++l<n);h.type=q.type;h.originalEvent=q.event;return d.flatten(r.results)},properties:function(i,g,h){var j=h.callback;j.drag=h.drag;j.proxy=h.proxy||h.drag;j.startX=g.pageX;j.startY=g.pageY;j.deltaX=i.pageX-g.pageX;j.deltaY=i.pageY-g.pageY;j.originalX=h.offset.left;j.originalY=h.offset.top;j.offsetX=j.originalX+j.deltaX;j.offsetY=j.originalY+j.deltaY;j.drop=d.flatten((h.drop||[]).slice());j.available=d.flatten((h.droppable||[]).slice());return j},element:function(g){if(g&&(g.jquery||g.nodeType==1)){return g}},flatten:function(g){return e.map(g,function(h){return h&&h.jquery?e.makeArray(h):h&&h.length?d.flatten(h):h})},textselect:function(g){e(document)[g?"unbind":"bind"]("selectstart",d.dontstart).css("MozUserSelect",g?"":"none");document.unselectable=g?"off":"on"},dontstart:function(){return false},callback:function(){}};d.callback.prototype={update:function(){if(a.drop&&this.available.length){e.each(this.available,function(g){a.drop.locate(this,g)})}}};var f=b.dispatch;b.dispatch=function(g){if(e.data(this,"suppress."+g.type)-new Date().getTime()>0){e.removeData(this,"suppress."+g.type);return}return f.apply(this,arguments)};var c=b.fixHooks.touchstart=b.fixHooks.touchmove=b.fixHooks.touchend=b.fixHooks.touchcancel={props:"clientX clientY pageX pageY screenX screenY".split(" "),filter:function(h,i){if(i){var g=(i.touches&&i.touches[0])||(i.changedTouches&&i.changedTouches[0])||null;if(g){e.each(c.props,function(j,k){h[k]=g[k]})}}return h}};a.draginit=a.dragstart=a.dragend=d})(jQuery);if(window.sc_require){sc_require("libraries/raphael")}if(!Raphael.fn.line){Raphael.fn.line=function(c,e,b,d){var a=this.path("M"+c+","+e+"L"+b+","+d);return a}}if(!Raphael.el.addClass){Raphael.el.addClass=function(c){var b=this.node.className;var a=b.baseVal.trim().split(" ");if(a.indexOf(c)<0){a.push(c);b.baseVal=a.join(" ")}return this}}if(!Raphael.el.setClass){Raphael.el.setClass=function(b){var a=this.node.className;a.baseVal=b;return this}}if(!Raphael.el.hasClass){Raphael.el.hasClass=function(b){var c=this.node.className;var a=c.baseVal;if(a.indexOf(b)<0){return false}else{return new RegExp("\b"+b+"\b").test(a)}}}if(!Raphael.el.removeClass){Raphael.el.removeClass=function(c){function a(i,g){var f,h,e;if(i===g){f=""}else{if(!i){f=i}else{h=i.split(" ");e=h.indexOf(g);if(e>=0){h.splice(e,1);f=h.join(" ")}else{f=i}}}return f}var b=this.node.className.baseVal;var d=a(b,c);this.node.className.baseVal=d}}if(!Raphael.el.setId){Raphael.el.setId=function(a){this.node.id.baseVal=a;return this}}if(!Raphael.el.isHidden){Raphael.el.isHidden=function(){return(this.node.style.display==="none")}}(function(b){b.extend(true,window,{Slick:{Plugins:{HeaderMenu:a}}});function a(r){var m;var k=this;var o=new Slick.EventHandler();var e={buttonCssClass:null,buttonImage:"../images/down.gif"};var d;var f;function q(s){r=b.extend(true,{},e,r);m=s;o.subscribe(m.onHeaderCellRendered,i).subscribe(m.onBeforeHeaderCellDestroy,h);m.setColumns(m.getColumns());b(document.body).bind("mousedown",j);b(document.body).bind("touchstart",j);b(document.body).bind("keydown",c)}function n(){o.unsubscribeAll();b(document.body).unbind("mousedown",j);b(document.body).unbind("touchstart",j);b(document.body).unbind("keydown",c)}function j(s){if(d&&d[0]!=s.target&&!b.contains(d[0],s.target)){l()}}function c(s){if(d&&(s.keyCode===27)){l();s.preventDefault();s.stopPropagation()}}function l(){if(d){d.remove();d=null;f.removeClass("slick-header-column-active")}}function i(w,s){var v=s.column;var x=v.header&&v.header.menu;if(x){var u=r.buttonIsCell?'<div style="display:none"></div>':"<div></div>",t=b(u).addClass("slick-header-menubutton").data("column",v).data("menu",x);if(r.buttonCssClass){t.addClass(r.buttonCssClass)}if(r.buttonImage){t.css("background-image","url("+r.buttonImage+")")}if(x.tooltip){t.attr("title",x.tooltip)}t.appendTo(s.node);if(r.buttonIsCell){b(s.node).bind("click",p)}else{t.bind("click",p)}}}function h(u,s){var t=s.column;if(t.header&&t.header.menu){b(s.node).find(".slick-header-menubutton").remove()}}function p(x){var u=r.buttonIsCell?b(this).find(".slick-header-menubutton"):b(this);var y=u.data("menu");var t=u.data("column");if(k.onBeforeMenuShow.notify({grid:m,column:t,menu:y},x,k)==false){return}if(!d){d=b("<div class='slick-header-menu'></div>").appendTo(document.body)}d.empty();for(var v=0;v<y.items.length;v++){var w=y.items[v];var z=b("<div class='slick-header-menuitem'></div>").data("command",w.command||"").data("column",t).data("item",w).bind("click",g).appendTo(d);if(w.disabled){z.addClass("slick-header-menuitem-disabled")}if(w.tooltip){z.attr("title",w.tooltip)}var s=b("<div class='slick-header-menuicon'></div>").appendTo(z);if(w.iconCssClass){s.addClass(w.iconCssClass)}if(w.iconImage){s.css("background-image","url("+w.iconImage+")")}b("<span class='slick-header-menucontent'></span>").text(w.title).appendTo(z)}d.css("top",b(this).offset().top+b(this).height()).css("left",b(this).offset().left);f=u.closest(".slick-header-column");f.addClass("slick-header-column-active")}function g(u){var v=b(this).data("command");var s=b(this).data("column");var t=b(this).data("item");if(t.disabled){return}l();if(v!=null&&v!=""){k.onCommand.notify({grid:m,column:s,command:v,item:t},u,k)}u.preventDefault();u.stopPropagation()}b.extend(this,{init:q,destroy:n,hideMenu:l,onBeforeMenuShow:new Slick.Event(),onCommand:new Slick.Event()})}})(jQuery);(function(b){b.extend(true,window,{Slick:{RowSelectionModel:a}});function a(f){var r;var o=[];var i=this;var n=new Slick.EventHandler();var m;var q;var s={selectActiveRow:true};function t(x){q=b.extend(true,{},s,f);r=x;n.subscribe(r.onActiveCellChanged,e(v));n.subscribe(r.onKeyDown,e(l));n.subscribe(r.onClick,e(k))}function w(){n.unsubscribeAll()}function e(x){return function(){var y;if(!m){m=true;y=x.apply(this,arguments);m=false;return y}}}function g(x){var A=[];for(var z=0;z<x.length;z++){for(var y=x[z].fromRow;y<=x[z].toRow;y++){A.push(y)}}return A}function h(A){var y=[];var x=r.getColumns().length-1;for(var z=0;z<A.length;z++){y.push(new Slick.Range(A[z],0,A[z],x))}return y}function u(A,z){var x,y=[];for(x=A;x<=z;x++){y.push(x)}for(x=z;x<A;x++){y.push(x)}return y}function d(){return g(o)}function j(x){c(h(x))}function c(x){o=x;i.onSelectedRangesChanged.notify(o)}function p(){return o}function v(y,x){if(q.selectActiveRow&&x.row!=null){c([new Slick.Range(x.row,0,x.row,r.getColumns().length-1)])}}function l(C){var y=r.getActiveCell();if(y&&C.shiftKey&&!C.ctrlKey&&!C.altKey&&!C.metaKey&&(C.which==38||C.which==40)){var B=d();B.sort(function(D,E){return D-E});if(!B.length){B=[y.row]}var A=B[0];var x=B[B.length-1];var z;if(C.which==40){z=y.row<x||A==x?++x:++A}else{z=y.row<x?--x:--A}if(z>=0&&z<r.getDataLength()){r.scrollRowIntoView(z);o=h(u(A,x));c(o)}C.preventDefault();C.stopPropagation()}}function k(C){var y=r.getCellFromEvent(C);if(!y||!r.canCellBeActive(y.row,y.cell)){return false}var A=g(o);var x=b.inArray(y.row,A);if(!C.ctrlKey&&!C.shiftKey&&!C.metaKey){return false}else{if(r.getOptions().multiSelect){if(x===-1&&(C.ctrlKey||C.metaKey)){A.push(y.row);r.setActiveCell(y.row,y.cell)}else{if(x!==-1&&(C.ctrlKey||C.metaKey)){A=b.grep(A,function(G,F){return(G!==y.row)});r.setActiveCell(y.row,y.cell)}else{if(A.length&&C.shiftKey){var B=A.pop();var E=Math.min(y.row,B);var D=Math.max(y.row,B);A=[];for(var z=E;z<=D;z++){if(z!==B){A.push(z)}}A.push(B);r.setActiveCell(y.row,y.cell)}}}}}o=h(A);c(o);C.stopImmediatePropagation();return true}b.extend(this,{getSelectedRows:d,setSelectedRows:j,getSelectedRanges:p,setSelectedRanges:c,init:t,destroy:w,onSelectedRangesChanged:new Slick.Event()})}})(jQuery);(function(c){c.extend(true,window,{Slick:{Event:h,EventData:g,EventHandler:i,Range:b,NonDataRow:e,Group:f,GroupTotals:d,EditorLock:a,GlobalEditorLock:new a()}});function g(){var j=false;var k=false;this.stopPropagation=function(){j=true};this.isPropagationStopped=function(){return j};this.stopImmediatePropagation=function(){k=true};this.isImmediatePropagationStopped=function(){return k}}function h(){var j=[];this.subscribe=function(k){j.push(k)};this.unsubscribe=function(l){for(var k=j.length-1;k>=0;k--){if(j[k]===l){j.splice(k,1)}}};this.notify=function(k,o,n){o=o||new g();n=n||this;var m;for(var l=0;l<j.length&&!(o.isPropagationStopped()||o.isImmediatePropagationStopped());l++){m=j[l].call(n,o,k)}return m}}function i(){var j=[];this.subscribe=function(l,k){j.push({event:l,handler:k});l.subscribe(k);return this};this.unsubscribe=function(m,l){var k=j.length;while(k--){if(j[k].event===m&&j[k].handler===l){j.splice(k,1);m.unsubscribe(l);return}}return this};this.unsubscribeAll=function(){var k=j.length;while(k--){j[k].event.unsubscribe(j[k].handler)}j=[];return this}}function b(k,j,l,m){if(l===undefined&&m===undefined){l=k;m=j}this.fromRow=Math.min(k,l);this.fromCell=Math.min(j,m);this.toRow=Math.max(k,l);this.toCell=Math.max(j,m);this.isSingleRow=function(){return this.fromRow==this.toRow};this.isSingleCell=function(){return this.fromRow==this.toRow&&this.fromCell==this.toCell};this.contains=function(o,n){return o>=this.fromRow&&o<=this.toRow&&n>=this.fromCell&&n<=this.toCell};this.toString=function(){if(this.isSingleCell()){return"("+this.fromRow+":"+this.fromCell+")"}else{return"("+this.fromRow+":"+this.fromCell+" - "+this.toRow+":"+this.toCell+")"}}}function e(){this.__nonDataRow=true}function f(){this.__group=true;this.level=0;this.count=0;this.value=null;this.title=null;this.collapsed=false;this.totals=null;this.rows=null;this.groups=null;this.groupingKey=null}f.prototype=new e();f.prototype.equals=function(j){return this.value===j.value&&this.count===j.count&&this.collapsed===j.collapsed};function d(){this.__groupTotals=true;this.group=null}d.prototype=new e();function a(){var j=null;this.isActive=function(l){return(l?j===l:j!==null)};this.activate=function(l){if(l===j){return}if(j!==null){throw"SlickGrid.EditorLock.activate: an editController is still active, can't activate another editController"}if(!l.commitCurrentEdit){throw"SlickGrid.EditorLock.activate: editController must implement .commitCurrentEdit()"}if(!l.cancelCurrentEdit){throw"SlickGrid.EditorLock.activate: editController must implement .cancelCurrentEdit()"}j=l};this.deactivate=function(l){if(j!==l){throw"SlickGrid.EditorLock.deactivate: specified editController is not the currently active one"}j=null};this.commitCurrentEdit=function(){return(j?j.commitCurrentEdit():true)};this.cancelCurrentEdit=function k(){return(j?j.cancelCurrentEdit():true)}}})(jQuery);(function(d){d.extend(true,window,{Slick:{Data:{DataView:f,Aggregators:{Avg:c,Min:b,Max:a,Sum:e}}}});function f(aa){var av=this;var M={groupItemMetadataProvider:null,inlineFilters:false,showExpandedGroupRows:true};var q="id";var aw=[];var W=[];var aC={};var ax=null;var v=null;var au=null;var E=false;var k=true;var aP;var y;var ag={};var O={};var aI;var n=[];var G;var z;var al=[];var aE={getter:null,formatter:null,comparer:function(aU,aT){return aU.value-aT.value},aggregators:[],aggregateCollapsed:false,aggregateChildGroups:false,collapsed:false};var ar=[];var h=[];var j=[];var aL=":|:";var C=0;var D=0;var g=0;var aG=new Slick.Event();var N=new Slick.Event();var aQ=new Slick.Event();aa=d.extend(true,{},M,aa);function p(){E=true}function r(){E=false;ay()}function aA(aT){ag=aT}function P(aT){aI=aT}function aJ(aV){aV=aV||0;var aW;for(var aU=aV,aT=aw.length;aU<aT;aU++){aW=aw[aU][q];if(aW===undefined){throw"Each data element must implement a unique 'id' property"}aC[aW]=aU}}function F(){var aV;for(var aU=0,aT=aw.length;aU<aT;aU++){aV=aw[aU][q];if(aV===undefined||aC[aV]!==aU){throw"Each data element must implement a unique 'id' property"}}}function aR(){return aw}function U(aU,aT){if(aT!==undefined){q=aT}aw=n=aU;aC={};aJ();F();ay()}function A(aT){if(aT.pageSize!=undefined){C=aT.pageSize;D=C?Math.min(D,Math.max(0,Math.ceil(g/C)-1)):0}if(aT.pageNum!=undefined){D=Math.min(aT.pageNum,Math.max(0,Math.ceil(g/C)-1))}aQ.notify(am(),null,av);ay()}function am(){var aT=C?Math.max(1,Math.ceil(g/C)):1;return{pageSize:C,pageNum:D,totalRows:g,totalPages:aT}}function H(aU,aT){k=aT;y=aU;aP=null;if(aT===false){aw.reverse()}aw.sort(aU);if(aT===false){aw.reverse()}aC={};aJ();ay()}function aK(aV,aU){k=aU;aP=aV;y=null;var aT=Object.prototype.toString;Object.prototype.toString=(typeof aV=="function")?aV:function(){return this[aV]};if(aU===false){aw.reverse()}aw.sort();Object.prototype.toString=aT;if(aU===false){aw.reverse()}aC={};aJ();ay()}function x(){if(y){H(y,k)}else{if(aP){aK(aP,k)}}}function ac(aT){v=aT;if(aa.inlineFilters){G=ak();z=B()}ay()}function ah(){return ar}function J(aW){if(!aa.groupItemMetadataProvider){aa.groupItemMetadataProvider=new Slick.Data.GroupItemMetadataProvider()}h=[];j=[];aW=aW||[];ar=(aW instanceof Array)?aW:[aW];for(var aV=0;aV<ar.length;aV++){var aU=ar[aV]=d.extend(true,{},aE,ar[aV]);aU.getterIsAFn=typeof aU.getter==="function";aU.compiledAccumulators=[];var aT=aU.aggregators.length;while(aT--){aU.compiledAccumulators[aT]=ao(aU.aggregators[aT])}j[aV]={}}ay()}function ad(aT,aU,aV){if(aT==null){J([]);return}J({getter:aT,formatter:aU,comparer:aV})}function aN(aU,aT){if(!ar.length){throw new Error("At least must setGrouping must be specified before calling setAggregators().")}ar[0].aggregators=aU;ar[0].aggregateCollapsed=aT;J(ar)}function aB(aT){return aw[aT]}function I(aT){return aC[aT]}function u(){if(!ax){ax={};for(var aU=0,aT=W.length;aU<aT;aU++){ax[W[aU][q]]=aU}}}function ai(aT){u();return ax[aT]}function Y(aT){return aw[aC[aT]]}function aH(aU){var aV=[];u();for(var aT=0;aT<aU.length;aT++){var aW=ax[aU[aT]];if(aW!=null){aV[aV.length]=aW}}return aV}function T(aV){var aU=[];for(var aT=0;aT<aV.length;aT++){if(aV[aT]<W.length){aU[aU.length]=W[aV[aT]][q]}}return aU}function m(aU,aT){if(aC[aU]===undefined||aU!==aT[q]){throw"Invalid or non-matching id"}aw[aC[aU]]=aT;if(!au){au={}}au[aU]=true;ay()}function aM(aT,aU){aw.splice(aT,0,aU);aJ(aT);ay()}function ap(aT){aw.push(aT);aJ(aw.length-1);ay()}function aS(aU){var aT=aC[aU];if(aT===undefined){throw"Invalid id"}delete aC[aU];aw.splice(aT,1);aJ(aT);ay()}function az(){return W.length}function aF(aT){return W[aT]}function K(aT){var aU=W[aT];if(aU===undefined){return null}if(aU.__group){return aa.groupItemMetadataProvider.getGroupRowMetadata(aU)}if(aU.__groupTotals){return aa.groupItemMetadataProvider.getTotalsRowMetadata(aU)}return null}function aO(aV,aU){if(aV==null){for(var aT=0;aT<ar.length;aT++){j[aT]={};ar[aT].collapsed=aU}}else{j[aV]={};ar[aV].collapsed=aU}ay()}function Q(aT){aO(aT,true)}function aD(aT){aO(aT,false)}function X(aV,aT,aU){j[aV][aT]=ar[aV].collapsed^aU;ay()}function at(aW){var aU=Array.prototype.slice.call(arguments);var aV=aU[0];var aX;var aT;if(aU.length==1&&aV.indexOf(aL)!=-1){aX=aV.split(aL).length-1;aT=aV}else{aX=aU.length-1;aT=aU.join(aL)}return j[aX][aT]}function aj(aV){var aT=Array.prototype.slice.call(arguments);var aU=aT[0];if(aT.length==1&&aU.indexOf(aL)!=-1){X(aU.split(aL).length-1,aU,true)}else{X(aT.length-1,aT.join(aL),true)}}function ae(aV){var aT=Array.prototype.slice.call(arguments);var aU=aT[0];if(aT.length==1&&aU.indexOf(aL)!=-1){X(aU.split(aL).length-1,aU,false)}else{X(aT.length-1,aT.join(aL),false)}}function an(){return h}function Z(a3,a0){var a2;var aV;var aW=[];var a1=[];var aT;var aU=a0?a0.level+1:0;var aZ=ar[aU];for(var aY=0,aX=a3.length;aY<aX;aY++){aT=a3[aY];aV=aZ.getterIsAFn?aZ.getter(aT):aT[aZ.getter];aV=aV||0;a2=a1[aV];if(!a2){a2=new Slick.Group();a2.count=0;a2.value=aV;a2.level=aU;a2.groupingKey=(a0?a0.groupingKey+aL:"")+aV;a2.rows=[];aW[aW.length]=a2;a1[aV]=a2}a2.rows[a2.count++]=aT}if(aU<ar.length-1){for(var aY=0;aY<aW.length;aY++){a2=aW[aY];a2.groups=Z(a2.rows,a2)}}aW.sort(ar[aU].comparer);return aW}function aq(aY){var aV=ar[aY.level];var aX=(aY.level==ar.length);var aW=new Slick.GroupTotals();var aU,aT=aV.aggregators.length;while(aT--){aU=aV.aggregators[aT];aU.init();aV.compiledAccumulators[aT].call(aU,(!aX&&aV.aggregateChildGroups)?aY.groups:aY.rows);aU.storeResult(aW)}aW.group=aY;aY.totals=aW}function af(aU,aX){aX=aX||0;var aV=ar[aX];var aT=aU.length,aW;while(aT--){aW=aU[aT];if(aW.collapsed&&!aV.aggregateCollapsed){continue}if(aW.groups){af(aW.groups,aX+1)}if(aV.aggregators.length){aq(aW)}}}function t(aU,aZ){aZ=aZ||0;var aV=ar[aZ];var aW=aV.collapsed;var aY=j[aZ];var aT=aU.length,aX;while(aT--){aX=aU[aT];aX.collapsed=aW^aY[aX.groupingKey];aX.title=aV.formatter?aV.formatter(aX):aX.value;if(aX.groups){t(aX.groups,aZ+1);aX.rows=null}}}function i(aT){var aU=[],a1,aY=0,a0;for(var aX=0,aV=aT.length;aX<aV;aX++){a0=aT[aX];if(aa.showExpandedGroupRows||a0.collapsed){aU[aY++]=a0}if(!a0.collapsed){a1=a0.groups?i(a0.groups):a0.rows;for(var aW=0,aZ=a1.length;aW<aZ;aW++){aU[aY++]=a1[aW]}}if(a0.totals&&(!a0.collapsed||ar[a0.level].aggregateCollapsed)){aU[aY++]=a0.totals}}return aU}function S(aU){var aT=/^function[^(]*\(([^)]*)\)\s*{([\s\S]*)}$/;var aV=aU.toString().match(aT);return{params:aV[1].split(","),body:aV[2]}}function ao(aV){var aU=S(aV.accumulate);var aT=new Function("_items","for (var "+aU.params[0]+", _i=0, _il=_items.length; _i<_il; _i++) {"+aU.params[0]+" = _items[_i]; "+aU.body+"}");aT.displayName=aT.name="compiledAccumulatorLoop";return aT}function ak(){var aW=S(v);var aT=aW.body.replace(/return false[;}]/gi,"{ continue _coreloop; }").replace(/return true[;}]/gi,"{ _retval[_idx++] = $item$; continue _coreloop; }").replace(/return ([^;}]+?);/gi,"{ if ($1) { _retval[_idx++] = $item$; }; continue _coreloop; }");var aU=["var _retval = [], _idx = 0; ","var $item$, $args$ = _args; ","_coreloop: ","for (var _i = 0, _il = _items.length; _i < _il; _i++) { ","$item$ = _items[_i]; ","$filter$; ","} ","return _retval; "].join("");aU=aU.replace(/\$filter\$/gi,aT);aU=aU.replace(/\$item\$/gi,aW.params[0]);aU=aU.replace(/\$args\$/gi,aW.params[1]);var aV=new Function("_items,_args",aU);aV.displayName=aV.name="compiledFilter";return aV}function B(){var aW=S(v);var aT=aW.body.replace(/return false[;}]/gi,"{ continue _coreloop; }").replace(/return true[;}]/gi,"{ _cache[_i] = true;_retval[_idx++] = $item$; continue _coreloop; }").replace(/return ([^;}]+?);/gi,"{ if ((_cache[_i] = $1)) { _retval[_idx++] = $item$; }; continue _coreloop; }");var aU=["var _retval = [], _idx = 0; ","var $item$, $args$ = _args; ","_coreloop: ","for (var _i = 0, _il = _items.length; _i < _il; _i++) { ","$item$ = _items[_i]; ","if (_cache[_i]) { ","_retval[_idx++] = $item$; ","continue _coreloop; ","} ","$filter$; ","} ","return _retval; "].join("");aU=aU.replace(/\$filter\$/gi,aT);aU=aU.replace(/\$item\$/gi,aW.params[0]);aU=aU.replace(/\$args\$/gi,aW.params[1]);var aV=new Function("_items,_args,_cache",aU);aV.displayName=aV.name="compiledFilterWithCaching";return aV}function o(aV,aW){var aU=[],aT=0;for(var aX=0,aY=aV.length;aX<aY;aX++){if(v(aV[aX],aW)){aU[aT++]=aV[aX]}}return aU}function R(aW,aX,aV){var aU=[],aT=0,a0;for(var aY=0,aZ=aW.length;aY<aZ;aY++){a0=aW[aY];if(aV[aY]){aU[aT++]=a0}else{if(v(a0,aX)){aU[aT++]=a0;aV[aY]=true}}}return aU}function w(aU){if(v){var aT=aa.inlineFilters?G:o;var aW=aa.inlineFilters?z:R;if(ag.isFilterNarrowing){n=aT(n,aI)}else{if(ag.isFilterExpanding){n=aW(aU,aI,al)}else{if(!ag.isFilterUnchanged){n=aT(aU,aI)}}}}else{n=C?aU:aU.concat()}var aV;if(C){if(n.length<D*C){D=Math.floor(n.length/C)}aV=n.slice(C*D,C*D+C)}else{aV=n}return{totalRows:n.length,rows:aV}}function l(a2,aW){var a1,aT,aU,a0=[];var aY=0,aZ=aW.length;if(ag&&ag.ignoreDiffsBefore){aY=Math.max(0,Math.min(aW.length,ag.ignoreDiffsBefore))}if(ag&&ag.ignoreDiffsAfter){aZ=Math.min(aW.length,Math.max(0,ag.ignoreDiffsAfter))}for(var aV=aY,aX=a2.length;aV<aZ;aV++){if(aV>=aX){a0[a0.length]=aV}else{a1=aW[aV];aT=a2[aV];if((ar.length&&(aU=(a1.__nonDataRow)||(aT.__nonDataRow))&&a1.__group!==aT.__group||a1.__group&&!a1.equals(aT))||(aU&&(a1.__groupTotals||aT.__groupTotals))||a1[q]!=aT[q]||(au&&au[a1[q]])){a0[a0.length]=aV}}}return a0}function s(aW){ax=null;if(ag.isFilterNarrowing!=O.isFilterNarrowing||ag.isFilterExpanding!=O.isFilterExpanding){al=[]}var aU=w(aW);g=aU.totalRows;var aT=aU.rows;h=[];if(ar.length){h=Z(aT);if(h.length){af(h);t(h);aT=i(h)}}var aV=l(W,aT);W=aT;return aV}function ay(){if(E){return}var aT=W.length;var aU=g;var aV=s(aw,v);if(C&&g<D*C){D=Math.max(0,Math.ceil(g/C)-1);aV=s(aw,v)}au=null;O=ag;ag={};if(aU!=g){aQ.notify(am(),null,av)}if(aT!=W.length){aG.notify({previous:aT,current:W.length},null,av)}if(aV.length>0){N.notify({rows:aV},null,av)}}function V(aW,aV){var aU=this;var aT=aU.mapRowsToIds(aW.getSelectedRows());var aX;function aY(){if(aT.length>0){aX=true;var aZ=aU.mapIdsToRows(aT);if(!aV){aT=aU.mapRowsToIds(aZ)}aW.setSelectedRows(aZ);aX=false}}aW.onSelectedRowsChanged.subscribe(function(a0,aZ){if(aX){return}aT=aU.mapRowsToIds(aW.getSelectedRows())});this.onRowsChanged.subscribe(aY);this.onRowCountChanged.subscribe(aY)}function ab(aV,aU){var aT;var aX;aW(aV.getCellCssStyles(aU));function aW(aZ){aT={};for(var a0 in aZ){var a1=W[a0][q];aT[a1]=aZ[a0]}}function aY(){if(aT){aX=true;u();var aZ={};for(var a1 in aT){var a0=ax[a1];if(a0!=undefined){aZ[a0]=aT[a1]}}aV.setCellCssStyles(aU,aZ);aX=false}}aV.onCellCssStylesChanged.subscribe(function(a0,aZ){if(aX){return}if(aU!=aZ.key){return}if(aZ.hash){aW(aZ.hash)}});this.onRowsChanged.subscribe(aY);this.onRowCountChanged.subscribe(aY)}return{beginUpdate:p,endUpdate:r,setPagingOptions:A,getPagingInfo:am,getItems:aR,setItems:U,setFilter:ac,sort:H,fastSort:aK,reSort:x,setGrouping:J,getGrouping:ah,groupBy:ad,setAggregators:aN,collapseAllGroups:Q,expandAllGroups:aD,isGroupCollapsed:at,collapseGroup:aj,expandGroup:ae,getGroups:an,getIdxById:I,getRowById:ai,getItemById:Y,getItemByIdx:aB,mapRowsToIds:T,mapIdsToRows:aH,setRefreshHints:aA,setFilterArgs:P,refresh:ay,updateItem:m,insertItem:aM,addItem:ap,deleteItem:aS,syncGridSelection:V,syncGridCellCssStyles:ab,getLength:az,getItem:aF,getItemMetadata:K,onRowCountChanged:aG,onRowsChanged:N,onPagingInfoChanged:aQ}}function c(g){this.field_=g;this.init=function(){this.count_=0;this.nonNullCount_=0;this.sum_=0};this.accumulate=function(h){var i=h[this.field_];this.count_++;if(i!=null&&i!==""&&i!==NaN){this.nonNullCount_++;this.sum_+=parseFloat(i)}};this.storeResult=function(h){if(!h.avg){h.avg={}}if(this.nonNullCount_!=0){h.avg[this.field_]=this.sum_/this.nonNullCount_}}}function b(g){this.field_=g;this.init=function(){this.min_=null};this.accumulate=function(h){var i=h[this.field_];if(i!=null&&i!==""&&i!==NaN){if(this.min_==null||i<this.min_){this.min_=i}}};this.storeResult=function(h){if(!h.min){h.min={}}h.min[this.field_]=this.min_}}function a(g){this.field_=g;this.init=function(){this.max_=null};this.accumulate=function(h){var i=h[this.field_];if(i!=null&&i!==""&&i!==NaN){if(this.max_==null||i>this.max_){this.max_=i}}};this.storeResult=function(h){if(!h.max){h.max={}}h.max[this.field_]=this.max_}}function e(g){this.field_=g;this.init=function(){this.sum_=null};this.accumulate=function(h){var i=h[this.field_];if(i!=null&&i!==""&&i!==NaN){this.sum_+=parseFloat(i)}};this.storeResult=function(h){if(!h.sum){h.sum={}}h.sum[this.field_]=this.sum_}}})(jQuery);if(typeof jQuery==="undefined"){throw"SlickGrid requires jquery module to be loaded"}if(!jQuery.fn.drag){throw"SlickGrid requires jquery.event.drag module to be loaded"}if(typeof Slick==="undefined"){throw"slick.core.js not loaded"}(function($){$.extend(true,window,{Slick:{Grid:SlickGrid}});var scrollbarDimensions;var maxSupportedCssHeight;function SlickGrid(container,data,columns,options){var defaults={explicitInitialization:false,rowHeight:25,minRowHeight:18,rowResizerHeight:null,snapToLineHeight:14,defaultColumnWidth:80,enableAddRow:false,leaveSpaceForNewRows:false,editable:false,autoEdit:true,enableCellNavigation:true,enableColumnReorder:true,asyncEditorLoading:false,asyncEditorLoadDelay:100,forceFitColumns:false,enableAsyncPostRender:false,asyncPostRenderDelay:50,autoHeight:false,editorLock:Slick.GlobalEditorLock,showHeaderRow:false,headerRowHeight:25,showTopPanel:false,topPanelHeight:25,formatterFactory:null,editorFactory:null,cellFlashingCssClass:"flashing",selectedCellCssClass:"selected",multiSelect:true,enableTextSelectionOnCells:false,dataItemColumnValueExtractor:null,fullWidthRows:false,multiColumnSort:false,defaultFormatter:defaultFormatter,forceSyncScrolling:false};var columnDefaults={name:"",resizable:true,sortable:false,minWidth:30,rerenderOnResize:false,headerCssClass:null,defaultSortAsc:true,focusable:true,selectable:true};var th;var h;var ph;var n;var cj;var page=0;var offset=0;var vScrollDir=1;var initialized=false;var $container;var uid="slickgrid_"+Math.round(1000000*Math.random());var self=this;var $focusSink,$focusSink2;var $headerScroller;var $headers;var $headerRow,$headerRowScroller,$headerRowSpacer;var $topPanelScroller;var $topPanel;var $viewport;var $canvas;var $style;var $boundAncestors;var stylesheet,columnCssRulesL,columnCssRulesR;var viewportH,viewportW;var canvasWidth;var viewportHasHScroll,viewportHasVScroll;var headerColumnWidthDiff=0,headerColumnHeightDiff=0,cellWidthDiff=0,cellHeightDiff=0;var absoluteColumnMinWidth;var numberOfRows=0;var tabbingDirection=1;var activePosX;var activeRow,activeCell;var activeCellNode=null;var currentEditor=null;var serializedEditorValue;var editController;var rowsCache={};var rowResizers={};var activeResizeRow=null;var renderedRows=0;var numVisibleRows;var prevScrollTop=0;var scrollTop=0;var lastRenderedScrollTop=0;var lastRenderedScrollLeft=0;var prevScrollLeft=0;var scrollLeft=0;var selectionModel;var selectedRows=[];var plugins=[];var cellCssClasses={};var columnsById={};var sortColumns=[];var columnPosLeft=[];var columnPosRight=[];var h_editorLoader=null;var h_render=null;var h_postrender=null;var postProcessedRows={};var postProcessToRow=null;var postProcessFromRow=null;var counter_rows_rendered=0;var counter_rows_removed=0;function init(){$container=$(container);if($container.length<1){throw new Error("SlickGrid requires a valid container, "+container+" does not exist in the DOM.")}maxSupportedCssHeight=maxSupportedCssHeight||getMaxSupportedCssHeight();scrollbarDimensions=scrollbarDimensions||measureScrollbar();options=$.extend({},defaults,options);validateAndEnforceOptions();columnDefaults.width=options.defaultColumnWidth;columnsById={};for(var i=0;i<columns.length;i++){var m=columns[i]=$.extend({},columnDefaults,columns[i]);columnsById[m.id]=i;if(m.minWidth&&m.width<m.minWidth){m.width=m.minWidth}if(m.maxWidth&&m.width>m.maxWidth){m.width=m.maxWidth}}if(options.enableColumnReorder&&!$.fn.sortable){throw new Error("SlickGrid's 'enableColumnReorder = true' option requires jquery-ui.sortable module to be loaded")}editController={commitCurrentEdit:commitCurrentEdit,cancelCurrentEdit:cancelCurrentEdit};$container.empty().css("overflow","hidden").css("outline",0).addClass(uid).addClass("ui-widget");if(!/relative|absolute|fixed/.test($container.css("position"))){$container.css("position","relative")}$focusSink=$("<div tabIndex='0' hideFocus style='position:fixed;width:0;height:0;top:0;left:0;outline:0;'></div>").appendTo($container);$headerScroller=$("<div class='slick-header ui-state-default' style='overflow:hidden;position:relative;' />").appendTo($container);$headers=$("<div class='slick-header-columns' style='left:-1000px' />").appendTo($headerScroller);$headers.width(getHeadersWidth());$headerRowScroller=$("<div class='slick-headerrow ui-state-default' style='overflow:hidden;position:relative;' />").appendTo($container);$headerRow=$("<div class='slick-headerrow-columns' />").appendTo($headerRowScroller);$headerRowSpacer=$("<div style='display:block;height:1px;position:absolute;top:0;left:0;'></div>").css("width",getCanvasWidth()+scrollbarDimensions.width+"px").appendTo($headerRowScroller);$topPanelScroller=$("<div class='slick-top-panel-scroller ui-state-default' style='overflow:hidden;position:relative;' />").appendTo($container);$topPanel=$("<div class='slick-top-panel' style='width:10000px' />").appendTo($topPanelScroller);if(!options.showTopPanel){$topPanelScroller.hide()}if(!options.showHeaderRow){$headerRowScroller.hide()}$viewport=$("<div class='slick-viewport' style='width:100%;overflow:auto;outline:0;position:relative;;'>").appendTo($container);$viewport.css("overflow-y",options.autoHeight?"hidden":"auto");$canvas=$("<div class='grid-canvas' />").appendTo($viewport);$focusSink2=$focusSink.clone().appendTo($container);if(!options.explicitInitialization){finishInitialization()}}function finishInitialization(){if(!initialized){initialized=true;viewportW=parseFloat($.css($container[0],"width",true));measureCellPaddingAndBorder();disableSelection($headers);if(!options.enableTextSelectionOnCells){$viewport.bind("selectstart.ui",function(event){return $(event.target).is("input,textarea")})}updateColumnCaches();createColumnHeaders();setupColumnSort();createCssRules();resizeCanvas();bindAncestorScrollEvents();$container.bind("resize.slickgrid",resizeCanvas);$viewport.bind("scroll",handleScroll);$headerScroller.bind("contextmenu",handleHeaderContextMenu).bind("click",handleHeaderClick).delegate(".slick-header-column","mouseenter",handleHeaderMouseEnter).delegate(".slick-header-column","mouseleave",handleHeaderMouseLeave).bind("draginit",handleHeaderDragInit).bind("dragstart",handleHeaderDragStart).bind("drag",{distance:5},handleHeaderDrag).bind("dragend",handleHeaderDragEnd);$headerRowScroller.bind("scroll",handleHeaderRowScroll);$focusSink.add($focusSink2).bind("keydown",handleKeyDown);$canvas.bind("keydown",handleKeyDown).bind("click",handleClick).bind("dblclick",handleDblClick).bind("contextmenu",handleContextMenu).bind("draginit",{touch:false},handleDragInit).bind("dragstart",{distance:3},handleDragStart).bind("drag",handleDrag).bind("dragend",handleDragEnd).delegate(".slick-cell","mouseenter",handleMouseEnter).delegate(".slick-cell","mouseleave",handleMouseLeave)}}function registerPlugin(plugin){plugins.unshift(plugin);plugin.init(self)}function unregisterPlugin(plugin){for(var i=plugins.length;i>=0;i--){if(plugins[i]===plugin){if(plugins[i].destroy){plugins[i].destroy()}plugins.splice(i,1);break}}}function setSelectionModel(model){if(selectionModel){selectionModel.onSelectedRangesChanged.unsubscribe(handleSelectedRangesChanged);if(selectionModel.destroy){selectionModel.destroy()}}selectionModel=model;if(selectionModel){selectionModel.init(self);selectionModel.onSelectedRangesChanged.subscribe(handleSelectedRangesChanged)}}function getSelectionModel(){return selectionModel}function getCanvasNode(){return $canvas[0]}function measureScrollbar(){var $c=$("<div style='position:absolute; top:-10000px; left:-10000px; width:100px; height:100px; overflow:scroll;'></div>").appendTo("body");var dim={width:$c.width()-$c[0].clientWidth,height:$c.height()-$c[0].clientHeight};$c.remove();return dim}function getHeadersWidth(){var headersWidth=0;for(var i=0,ii=columns.length;i<ii;i++){var width=columns[i].width;headersWidth+=width}headersWidth+=scrollbarDimensions.width;return Math.max(headersWidth,viewportW)+1000}function getCanvasWidth(){var availableWidth=viewportHasVScroll?viewportW-scrollbarDimensions.width:viewportW;var rowWidth=0;var i=columns.length;while(i--){rowWidth+=columns[i].width}return options.fullWidthRows?Math.max(rowWidth,availableWidth):rowWidth}function updateCanvasWidth(forceColumnWidthsUpdate){var oldCanvasWidth=canvasWidth;canvasWidth=getCanvasWidth();viewportHasHScroll=(canvasWidth>viewportW-scrollbarDimensions.width);if(canvasWidth!=oldCanvasWidth){$canvas.width(canvasWidth);$headerRow.width(canvasWidth);$headers.width(getHeadersWidth());trigger(self.onCanvasWidthChanged,{width:canvasWidth})}$headerRowSpacer.width(canvasWidth+(viewportHasVScroll?scrollbarDimensions.width:0));if(canvasWidth!=oldCanvasWidth||forceColumnWidthsUpdate){applyColumnWidths()}}function disableSelection($target){if($target&&$target.jquery){$target.attr("unselectable","on").css("MozUserSelect","none").bind("selectstart.ui",function(){return false})}}function getMaxSupportedCssHeight(){var supportedHeight=1000000;var testUpTo=navigator.userAgent.toLowerCase().match(/firefox/)?6000000:1000000000;var div=$("<div style='display:none' />").appendTo(document.body);while(true){var test=supportedHeight*2;div.css("height",test);if(test>testUpTo||div.height()!==test){break}else{supportedHeight=test}}div.remove();return supportedHeight}function bindAncestorScrollEvents(){var elem=$canvas[0];while((elem=elem.parentNode)!=document.body&&elem!=null){if(elem==$viewport[0]||elem.scrollWidth!=elem.clientWidth||elem.scrollHeight!=elem.clientHeight){var $elem=$(elem);if(!$boundAncestors){$boundAncestors=$elem}else{$boundAncestors=$boundAncestors.add($elem)}$elem.bind("scroll."+uid,handleActiveCellPositionChange)}}}function unbindAncestorScrollEvents(){if(!$boundAncestors){return}$boundAncestors.unbind("scroll."+uid);$boundAncestors=null}function updateColumnHeader(columnId,title,toolTip){if(!initialized){return}var idx=getColumnIndex(columnId);if(idx==null){return}var columnDef=columns[idx];var $header=$headers.children().eq(idx);if($header){if(title!==undefined){columns[idx].name=title}if(toolTip!==undefined){columns[idx].toolTip=toolTip}trigger(self.onBeforeHeaderCellDestroy,{node:$header[0],column:columnDef});$header.attr("title",toolTip||"").children().eq(0).html(title);trigger(self.onHeaderCellRendered,{node:$header[0],column:columnDef})}}function getHeaderRow(){return $headerRow[0]}function getHeaderRowColumn(columnId){var idx=getColumnIndex(columnId);var $header=$headerRow.children().eq(idx);return $header&&$header[0]}function createColumnHeaders(){function onMouseEnter(){$(this).addClass("ui-state-hover")}function onMouseLeave(){$(this).removeClass("ui-state-hover")}$headers.find(".slick-header-column").each(function(){var columnDef=$(this).data("column");if(columnDef){trigger(self.onBeforeHeaderCellDestroy,{node:this,column:columnDef})}});$headers.empty();$headers.width(getHeadersWidth());$headerRow.find(".slick-headerrow-column").each(function(){var columnDef=$(this).data("column");if(columnDef){trigger(self.onBeforeHeaderRowCellDestroy,{node:this,column:columnDef})}});$headerRow.empty();for(var i=0;i<columns.length;i++){var m=columns[i];var header=$("<div class='ui-state-default slick-header-column' id='"+uid+m.id+"' />").html("<span class='slick-column-name'>"+m.name+"</span>").width(m.width-headerColumnWidthDiff).attr("title",m.toolTip||"").data("column",m).addClass(m.headerCssClass||"").appendTo($headers);if(options.enableColumnReorder||m.sortable){header.on("mouseenter",onMouseEnter).on("mouseleave",onMouseLeave)}if(m.sortable){header.addClass("slick-header-sortable");header.append("<span class='slick-sort-indicator' />")}trigger(self.onHeaderCellRendered,{node:header[0],column:m});if(options.showHeaderRow){var headerRowCell=$("<div class='ui-state-default slick-headerrow-column l"+i+" r"+i+"'></div>").data("column",m).appendTo($headerRow);trigger(self.onHeaderRowCellRendered,{node:headerRowCell[0],column:m})}}setSortColumns(sortColumns);setupColumnResize();if(options.enableColumnReorder){setupColumnReorder()}}function setupColumnSort(){$headers.click(function(e){e.metaKey=e.metaKey||e.ctrlKey;if($(e.target).hasClass("slick-resizable-handle")){return}var $col=$(e.target).closest(".slick-header-column");if(!$col.length){return}var column=$col.data("column");if(column.sortable){if(!getEditorLock().commitCurrentEdit()){return}var sortOpts=null;var i=0;for(;i<sortColumns.length;i++){if(sortColumns[i].columnId==column.id){sortOpts=sortColumns[i];sortOpts.sortAsc=!sortOpts.sortAsc;break}}if(e.metaKey&&options.multiColumnSort){if(sortOpts){sortColumns.splice(i,1)}}else{if((!e.shiftKey&&!e.metaKey)||!options.multiColumnSort){sortColumns=[]}if(!sortOpts){sortOpts={columnId:column.id,sortAsc:column.defaultSortAsc};sortColumns.push(sortOpts)}else{if(sortColumns.length==0){sortColumns.push(sortOpts)}}}setSortColumns(sortColumns);if(!options.multiColumnSort){trigger(self.onSort,{multiColumnSort:false,sortCol:column,sortAsc:sortOpts.sortAsc},e)}else{trigger(self.onSort,{multiColumnSort:true,sortCols:$.map(sortColumns,function(col){return{sortCol:columns[getColumnIndex(col.columnId)],sortAsc:col.sortAsc}})},e)}}})}function setupColumnReorder(){$headers.filter(":ui-sortable").sortable("destroy");$headers.sortable({containment:"parent",distance:3,axis:"x",cursor:"default",tolerance:"intersection",helper:"clone",placeholder:"slick-sortable-placeholder ui-state-default slick-header-column",forcePlaceholderSize:true,start:function(e,ui){$(ui.helper).addClass("slick-header-column-active")},beforeStop:function(e,ui){$(ui.helper).removeClass("slick-header-column-active")},stop:function(e){if(!getEditorLock().commitCurrentEdit()){$(this).sortable("cancel");return}var reorderedIds=$headers.sortable("toArray");var reorderedColumns=[];for(var i=0;i<reorderedIds.length;i++){reorderedColumns.push(columns[getColumnIndex(reorderedIds[i].replace(uid,""))])}setColumns(reorderedColumns);trigger(self.onColumnsReordered,{});e.stopPropagation();setupColumnResize()}})}function setupColumnResize(){var $col,j,c,pageX,columnElements,minPageX,maxPageX,firstResizable,lastResizable;columnElements=$headers.children();columnElements.find(".slick-resizable-handle").remove();columnElements.each(function(i,e){if(columns[i].resizable){if(firstResizable===undefined){firstResizable=i}lastResizable=i}});if(firstResizable===undefined){return}columnElements.each(function(i,e){if(i<firstResizable||(options.forceFitColumns&&i>=lastResizable)){return}$col=$(e);$("<div class='slick-resizable-handle dg-wants-mouse dg-wants-touch' />").appendTo(e).css({width:"ontouchstart" in window?16:(i===lastResizable?10:8)}).bind("dragstart touchstart",function(e,dd){if(!getEditorLock().commitCurrentEdit()){return false}pageX=e.pageX;$(this).parent().addClass("slick-header-column-active");var shrinkLeewayOnRight=null,stretchLeewayOnRight=null;columnElements.each(function(i,e){columns[i].previousWidth=$(e).outerWidth()});if(options.forceFitColumns){shrinkLeewayOnRight=0;stretchLeewayOnRight=0;for(j=i+1;j<columnElements.length;j++){c=columns[j];if(c.resizable){if(stretchLeewayOnRight!==null){if(c.maxWidth){stretchLeewayOnRight+=c.maxWidth-c.previousWidth}else{stretchLeewayOnRight=null}}shrinkLeewayOnRight+=c.previousWidth-Math.max(c.minWidth||0,absoluteColumnMinWidth)}}}var shrinkLeewayOnLeft=0,stretchLeewayOnLeft=0;for(j=0;j<=i;j++){c=columns[j];if(c.resizable){if(stretchLeewayOnLeft!==null){if(c.maxWidth){stretchLeewayOnLeft+=c.maxWidth-c.previousWidth}else{stretchLeewayOnLeft=null}}shrinkLeewayOnLeft+=c.previousWidth-Math.max(c.minWidth||0,absoluteColumnMinWidth)}}if(shrinkLeewayOnRight===null){shrinkLeewayOnRight=100000}if(shrinkLeewayOnLeft===null){shrinkLeewayOnLeft=100000}if(stretchLeewayOnRight===null){stretchLeewayOnRight=100000}if(stretchLeewayOnLeft===null){stretchLeewayOnLeft=100000}maxPageX=pageX+Math.min(shrinkLeewayOnRight,stretchLeewayOnLeft);minPageX=pageX-Math.min(shrinkLeewayOnLeft,stretchLeewayOnRight)}).bind("drag touchmove",function(e,dd){var actualMinWidth,d=Math.min(maxPageX,Math.max(minPageX,e.pageX))-pageX,x;if(d<0){x=d;for(j=i;j>=0;j--){c=columns[j];if(c.resizable){actualMinWidth=Math.max(c.minWidth||0,absoluteColumnMinWidth);if(x&&c.previousWidth+x<actualMinWidth){x+=c.previousWidth-actualMinWidth;c.width=actualMinWidth}else{c.width=c.previousWidth+x;x=0}}}if(options.forceFitColumns){x=-d;for(j=i+1;j<columnElements.length;j++){c=columns[j];if(c.resizable){if(x&&c.maxWidth&&(c.maxWidth-c.previousWidth<x)){x-=c.maxWidth-c.previousWidth;c.width=c.maxWidth}else{c.width=c.previousWidth+x;x=0}}}}}else{x=d;for(j=i;j>=0;j--){c=columns[j];if(c.resizable){if(x&&c.maxWidth&&(c.maxWidth-c.previousWidth<x)){x-=c.maxWidth-c.previousWidth;c.width=c.maxWidth}else{c.width=c.previousWidth+x;x=0}}}if(options.forceFitColumns){x=-d;for(j=i+1;j<columnElements.length;j++){c=columns[j];if(c.resizable){actualMinWidth=Math.max(c.minWidth||0,absoluteColumnMinWidth);if(x&&c.previousWidth+x<actualMinWidth){x+=c.previousWidth-actualMinWidth;c.width=actualMinWidth}else{c.width=c.previousWidth+x;x=0}}}}}applyColumnHeaderWidths();if(options.syncColumnCellResize){applyColumnWidths();updateCanvasWidth(true);trigger(self.onColumnResizing,{})}}).bind("dragend touchend",function(e,dd){var newWidth;$(this).parent().removeClass("slick-header-column-active");for(j=0;j<columnElements.length;j++){c=columns[j];newWidth=$(columnElements[j]).outerWidth();if(c.previousWidth!==newWidth&&c.rerenderOnResize){invalidateAllRows()}}updateCanvasWidth(true);render();trigger(self.onColumnsResized,{})}).bind("click",function(e){e.stopPropagation()})})}function getVBoxDelta($el){var p=["borderTopWidth","borderBottomWidth","paddingTop","paddingBottom"];var delta=0;$.each(p,function(n,val){delta+=parseFloat($el.css(val))||0});return delta}function measureCellPaddingAndBorder(){var el;var h=["borderLeftWidth","borderRightWidth","paddingLeft","paddingRight"];var v=["borderTopWidth","borderBottomWidth","paddingTop","paddingBottom"];el=$("<div class='ui-state-default slick-header-column' style='visibility:hidden'>-</div>").appendTo($headers);headerColumnWidthDiff=headerColumnHeightDiff=0;$.each(h,function(n,val){headerColumnWidthDiff+=parseFloat(el.css(val))||0});$.each(v,function(n,val){headerColumnHeightDiff+=parseFloat(el.css(val))||0});el.remove();var r=$("<div class='slick-row' />").appendTo($canvas);el=$("<div class='slick-cell' id='' style='visibility:hidden'>-</div>").appendTo(r);cellWidthDiff=cellHeightDiff=0;$.each(h,function(n,val){cellWidthDiff+=parseFloat(el.css(val))||0});$.each(v,function(n,val){cellHeightDiff+=parseFloat(el.css(val))||0});r.remove();absoluteColumnMinWidth=Math.max(headerColumnWidthDiff,cellWidthDiff)}function createCssRules(){$style=$("<style type='text/css' rel='stylesheet' />").appendTo($("head"));var rowHeight=(options.rowHeight-cellHeightDiff);var rules=["."+uid+" .slick-header-column { left: 1000px; }","."+uid+" .slick-top-panel { height:"+options.topPanelHeight+"px; }","."+uid+" .slick-headerrow-columns { height:"+options.headerRowHeight+"px; }","."+uid+" .slick-cell { height:"+rowHeight+"px; }","."+uid+" .slick-row { height:"+options.rowHeight+"px; }"];for(var i=0;i<columns.length;i++){rules.push("."+uid+" .l"+i+" { }");rules.push("."+uid+" .r"+i+" { }")}if($style[0].styleSheet){$style[0].styleSheet.cssText=rules.join(" ")}else{$style[0].appendChild(document.createTextNode(rules.join(" ")))}}function getColumnCssRules(idx){if(!stylesheet){var sheets=document.styleSheets;for(var i=0;i<sheets.length;i++){if((sheets[i].ownerNode||sheets[i].owningElement)==$style[0]){stylesheet=sheets[i];break}}if(!stylesheet){throw new Error("Cannot find stylesheet.")}columnCssRulesL=[];columnCssRulesR=[];var cssRules=(stylesheet.cssRules||stylesheet.rules);var matches,columnIdx;for(var i=0;i<cssRules.length;i++){var selector=cssRules[i].selectorText;if(matches=/\.l\d+/.exec(selector)){columnIdx=parseInt(matches[0].substr(2,matches[0].length-2),10);columnCssRulesL[columnIdx]=cssRules[i]}else{if(matches=/\.r\d+/.exec(selector)){columnIdx=parseInt(matches[0].substr(2,matches[0].length-2),10);columnCssRulesR[columnIdx]=cssRules[i]}}}}return{left:columnCssRulesL[idx],right:columnCssRulesR[idx]}}function removeCssRules(){$style.remove();stylesheet=null}function destroy(){getEditorLock().cancelCurrentEdit();trigger(self.onBeforeDestroy,{});var i=plugins.length;while(i--){unregisterPlugin(plugins[i])}if(options.enableColumnReorder&&$headers.sortable){$headers.sortable("destroy")}unbindAncestorScrollEvents();$container.unbind(".slickgrid");removeCssRules();$canvas.unbind("draginit dragstart dragend drag");$container.empty().removeClass(uid)}function trigger(evt,args,e){e=e||new Slick.EventData();args=args||{};args.grid=self;return evt.notify(args,e,self)}function getEditorLock(){return options.editorLock}function getEditController(){return editController}function getColumnIndex(id){return columnsById[id]}function autosizeColumns(){var i,c,widths=[],shrinkLeeway=0,total=0,prevTotal,availWidth=viewportHasVScroll?viewportW-scrollbarDimensions.width:viewportW;for(i=0;i<columns.length;i++){c=columns[i];widths.push(c.width);total+=c.width;if(c.resizable){shrinkLeeway+=c.width-Math.max(c.minWidth,absoluteColumnMinWidth)}}prevTotal=total;while(total>availWidth&&shrinkLeeway){var shrinkProportion=(total-availWidth)/shrinkLeeway;for(i=0;i<columns.length&&total>availWidth;i++){c=columns[i];var width=widths[i];if(!c.resizable||width<=c.minWidth||width<=absoluteColumnMinWidth){continue}var absMinWidth=Math.max(c.minWidth,absoluteColumnMinWidth);var shrinkSize=Math.floor(shrinkProportion*(width-absMinWidth))||1;shrinkSize=Math.min(shrinkSize,width-absMinWidth);total-=shrinkSize;shrinkLeeway-=shrinkSize;widths[i]-=shrinkSize}if(prevTotal==total){break}prevTotal=total}prevTotal=total;while(total<availWidth){var growProportion=availWidth/total;for(i=0;i<columns.length&&total<availWidth;i++){c=columns[i];if(!c.resizable||c.maxWidth<=c.width){continue}var growSize=Math.min(Math.floor(growProportion*c.width)-c.width,(c.maxWidth-c.width)||1000000)||1;total+=growSize;widths[i]+=growSize}if(prevTotal==total){break}prevTotal=total}var reRender=false;for(i=0;i<columns.length;i++){if(columns[i].rerenderOnResize&&columns[i].width!=widths[i]){reRender=true}columns[i].width=widths[i]}applyColumnHeaderWidths();updateCanvasWidth(true);if(reRender){invalidateAllRows();render()}}function applyColumnHeaderWidths(){if(!initialized){return}var h;for(var i=0,headers=$headers.children(),ii=headers.length;i<ii;i++){h=$(headers[i]);if(h.width()!==columns[i].width-headerColumnWidthDiff){h.width(columns[i].width-headerColumnWidthDiff)}}updateColumnCaches()}function applyColumnWidths(){var x=0,w,rule;for(var i=0;i<columns.length;i++){w=columns[i].width;rule=getColumnCssRules(i);rule.left.style.left=x+"px";rule.right.style.right=(canvasWidth-x-w)+"px";x+=columns[i].width}}function setSortColumn(columnId,ascending){setSortColumns([{columnId:columnId,sortAsc:ascending}])}function setSortColumns(cols){sortColumns=cols;var headerColumnEls=$headers.children();headerColumnEls.removeClass("slick-header-column-sorted").find(".slick-sort-indicator").removeClass("slick-sort-indicator-asc slick-sort-indicator-desc");$.each(sortColumns,function(i,col){if(col.sortAsc==null){col.sortAsc=true}var columnIndex=getColumnIndex(col.columnId);if(columnIndex!=null){headerColumnEls.eq(columnIndex).addClass("slick-header-column-sorted").find(".slick-sort-indicator").addClass(col.sortAsc?"slick-sort-indicator-asc":"slick-sort-indicator-desc")}})}function getSortColumns(){return sortColumns}function handleSelectedRangesChanged(e,ranges){selectedRows=[];var hash={};for(var i=0;i<ranges.length;i++){for(var j=ranges[i].fromRow;j<=ranges[i].toRow;j++){if(!hash[j]){selectedRows.push(j);hash[j]={}}for(var k=ranges[i].fromCell;k<=ranges[i].toCell;k++){if(canCellBeSelected(j,k)){hash[j][columns[k].id]=options.selectedCellCssClass}}}}setCellCssStyles(options.selectedCellCssClass,hash);trigger(self.onSelectedRowsChanged,{rows:getSelectedRows()},e)}function getColumns(){return columns}function updateColumnCaches(){columnPosLeft=[];columnPosRight=[];var x=0;for(var i=0,ii=columns.length;i<ii;i++){columnPosLeft[i]=x;columnPosRight[i]=x+columns[i].width;x+=columns[i].width}}function setColumns(columnDefinitions){columns=columnDefinitions;columnsById={};for(var i=0;i<columns.length;i++){var m=columns[i]=$.extend({},columnDefaults,columns[i]);columnsById[m.id]=i;if(m.minWidth&&m.width<m.minWidth){m.width=m.minWidth}if(m.maxWidth&&m.width>m.maxWidth){m.width=m.maxWidth}}updateColumnCaches();if(initialized){invalidateAllRows();createColumnHeaders();removeCssRules();createCssRules();resizeCanvas();applyColumnWidths();handleScroll()}}function getOptions(){return options}function setOptions(args){if(!getEditorLock().commitCurrentEdit()){return}makeActiveCellNormal();if(options.enableAddRow!==args.enableAddRow){invalidateRow(getDataLength())}options=$.extend(options,args);validateAndEnforceOptions();$viewport.css("overflow-y",options.autoHeight?"hidden":"auto");render()}function validateAndEnforceOptions(){if(options.autoHeight){options.leaveSpaceForNewRows=false}}function setData(newData,scrollToTop){data=newData;invalidateAllRows();updateRowCount();if(scrollToTop){scrollTo(0)}}function getData(){return data}function getDataLength(){if(data.getLength){return data.getLength()}else{return data.length}}function getDataItem(i){if(data.getItem){return data.getItem(i)}else{return data[i]}}function getTopPanel(){return $topPanel[0]}function setTopPanelVisibility(visible){if(options.showTopPanel!=visible){options.showTopPanel=visible;if(visible){$topPanelScroller.slideDown("fast",resizeCanvas)}else{$topPanelScroller.slideUp("fast",resizeCanvas)}}}function setHeaderRowVisibility(visible){if(options.showHeaderRow!=visible){options.showHeaderRow=visible;if(visible){$headerRowScroller.slideDown("fast",resizeCanvas)}else{$headerRowScroller.slideUp("fast",resizeCanvas)}}}function scrollTo(y){y=Math.max(y,0);y=Math.min(y,th-viewportH+(viewportHasHScroll?scrollbarDimensions.height:0));var oldOffset=offset;page=Math.min(n-1,Math.floor(y/ph));offset=Math.round(page*cj);var newScrollTop=y-offset;if(offset!=oldOffset){var range=getVisibleRange(newScrollTop);cleanupRows(range);updateRowPositions()}if(prevScrollTop!=newScrollTop){vScrollDir=(prevScrollTop+oldOffset<newScrollTop+offset)?1:-1;$viewport[0].scrollTop=(lastRenderedScrollTop=scrollTop=prevScrollTop=newScrollTop);trigger(self.onViewportChanged,{})}}function defaultFormatter(row,cell,value,columnDef,dataContext){if(value==null){return""}else{return value.toString().replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}}function getFormatter(row,column){var rowMetadata=data.getItemMetadata&&data.getItemMetadata(row);var columnOverrides=rowMetadata&&rowMetadata.columns&&(rowMetadata.columns[column.id]||rowMetadata.columns[getColumnIndex(column.id)]);return(columnOverrides&&columnOverrides.formatter)||(rowMetadata&&rowMetadata.formatter)||column.formatter||(options.formatterFactory&&options.formatterFactory.getFormatter(column))||options.defaultFormatter}function getTooltipFormatter(row,column){var rowMetadata=data.getItemMetadata&&data.getItemMetadata(row);var columnOverrides=rowMetadata&&rowMetadata.columns&&(rowMetadata.columns[column.id]||rowMetadata.columns[getColumnIndex(column.id)]);return(columnOverrides&&columnOverrides.tooltipFormatter)||(rowMetadata&&rowMetadata.tooltipFormatter)||column.tooltipFormatter||(options.tooltipFormatterFactory&&options.tooltipFormatterFactory.getTooltipFormatter(column))||options.defaultTooltipFormatter}function getEditor(row,cell){var column=columns[cell];var rowMetadata=data.getItemMetadata&&data.getItemMetadata(row);var columnMetadata=rowMetadata&&rowMetadata.columns;if(columnMetadata&&columnMetadata[column.id]&&columnMetadata[column.id].editor!==undefined){return columnMetadata[column.id].editor}if(columnMetadata&&columnMetadata[cell]&&columnMetadata[cell].editor!==undefined){return columnMetadata[cell].editor}return column.editor||(options.editorFactory&&options.editorFactory.getEditor(column))}function getDataItemValueForColumn(item,columnDef){if(options.dataItemColumnValueExtractor){return options.dataItemColumnValueExtractor(item,columnDef)}return item[columnDef.field]}function appendRowHtml(stringArray,row,range){var d=getDataItem(row);var dataLoading=row<getDataLength()&&!d;var rowCss="slick-row"+(dataLoading?" loading":"")+(row===activeRow?" active":"")+(row%2==1?" odd":" even");var metadata=data.getItemMetadata&&data.getItemMetadata(row);if(metadata&&metadata.cssClasses){rowCss+=" "+metadata.cssClasses}stringArray.push("<div class='ui-widget-content "+rowCss+"' style='top:"+(options.rowHeight*row-offset)+"px' data-row-id='"+(d?d.get("id"):"")+"'>");var colspan,m;for(var i=0,ii=columns.length;i<ii;i++){m=columns[i];colspan=1;if(metadata&&metadata.columns){var columnData=metadata.columns[m.id]||metadata.columns[i];colspan=(columnData&&columnData.colspan)||1;if(colspan==="*"){colspan=ii-i}}if(columnPosRight[Math.min(ii-1,i+colspan-1)]>range.leftPx){if(columnPosLeft[i]>range.rightPx){break}appendCellHtml(stringArray,row,i,colspan)}if(colspan>1){i+=(colspan-1)}}stringArray.push("</div>")}function appendCellHtml(stringArray,row,cell,colspan){var m=columns[cell];var d=getDataItem(row);var cellCss="slick-cell l"+cell+" r"+Math.min(columns.length-1,cell+colspan-1)+(m.cssClass?" "+m.cssClass:"");if(row===activeRow&&cell===activeCell){cellCss+=(" active")}for(var key in cellCssClasses){if(cellCssClasses[key][row]&&cellCssClasses[key][row][m.id]){cellCss+=(" "+cellCssClasses[key][row][m.id])}}var cellValue="",formattedValue="",tooltipFormatter,tooltipValue="",tooltipAttr="";if(d){cellValue=getDataItemValueForColumn(d,m);formattedValue=getFormatter(row,m)(row,cell,cellValue,m,d);tooltipFormatter=getTooltipFormatter(row,m);tooltipValue=tooltipFormatter?tooltipFormatter(row,cell,cellValue,formattedValue,m,d):"";tooltipAttr=tooltipValue?' title="'+tooltipValue+'"':""}var lineHeight=14,style=" style='-webkit-line-clamp:"+Math.ceil((options.rowHeight-8)/lineHeight)+"'";stringArray.push("<div class='"+cellCss+"'"+tooltipAttr+style+">");if(d){stringArray.push(formattedValue)}stringArray.push("</div>");rowsCache[row].cellRenderQueue.push(cell);rowsCache[row].cellColSpans[cell]=colspan}function handleRowResizeDragInit(e,dd){var retval=trigger(self.onRowResizeDragInit,dd,e);if(e.isImmediatePropagationStopped()){return retval}return false}function handleRowResizeDragStart(e,dd){activeResizeRow=$(dd.target).data("row-index");dd.initialRowHeight=options.rowHeight;dd.minRowHeight=options.minRowHeight;dd.rowHeight=options.rowHeight;var retval=trigger(self.onRowResizeDragStart,dd,e);if(e.isImmediatePropagationStopped()){return retval}return false}function handleRowResizeDrag(e,dd){dd.rowHeight=Math.max(dd.minRowHeight,dd.initialRowHeight+dd.deltaY);if(options.snapToLineHeight){dd.rowHeight=options.snapToLineHeight*Math.round((dd.rowHeight-4)/options.snapToLineHeight)+4}return trigger(self.onRowResizeDrag,dd,e)}function handleRowResizeDragEnd(e,dd){trigger(self.onRowResizeDragEnd,dd,e);activeResizeRow=null}function installRowResizeHandlesForRange(firstRow,lastRow){for(var row=firstRow;row<=lastRow;++row){var cacheEntry=rowsCache[row];if(cacheEntry&&cacheEntry.rowNode&&!cacheEntry.hasRowResizeHandle){cacheEntry.hasRowResizeHandle=installResizeHandleForRow(row,cacheEntry.rowNode)}}}function installResizeHandleForRow(row,rowNode){if($(rowNode).hasClass("dg-proto-row")){return}var resizerHeight=options.rowResizerHeight||options.minRowHeight/2;var resizerTop=options.rowHeight-offset-resizerHeight/2-0.5;var rowResizer=rowResizers[row]?rowResizers[row].css("top",resizerTop):"<div class='slick-row-resizer' data-row-index='"+row+"' style='top:"+resizerTop+"px;height:"+resizerHeight+"px'></div>";$(rowNode).append(rowResizer);var $resizer=$(rowNode).children(".slick-row-resizer");if($resizer){$resizer.on("draginit",handleRowResizeDragInit);$resizer.on("dragstart",handleRowResizeDragStart);$resizer.on("drag",handleRowResizeDrag);$resizer.on("dragend",handleRowResizeDragEnd);return true}return false}function removeResizeHandleForRow(row,rowNode){var $resizer=$(rowNode).children(".slick-row-resizer");if($resizer){$resizer.off("draginit",handleRowResizeDragInit);$resizer.off("dragstart",handleRowResizeDragStart);$resizer.off("drag",handleRowResizeDrag);$resizer.off("dragend",handleRowResizeDragEnd);rowResizers[row]=$resizer.detach()}}function cleanupRows(rangeToKeep){(activeResizeRow!=null)&&(rangeToKeep.bottom=Math.max(rangeToKeep.bottom,activeResizeRow));for(var i in rowsCache){if(((i=parseInt(i,10))!==activeRow)&&(i<rangeToKeep.top||i>rangeToKeep.bottom)){removeRowFromCache(i)}}}function invalidate(){updateRowCount();invalidateAllRows();render()}function invalidateAllRows(){if(currentEditor){makeActiveCellNormal()}for(var row in rowsCache){removeRowFromCache(row)}}function removeRowFromCache(row){var cacheEntry=rowsCache[row];if(!cacheEntry){return}if(cacheEntry.rowNode&&cacheEntry.hasRowResizeHandle){removeResizeHandleForRow(row,cacheEntry.rowNode)}$canvas[0].removeChild(cacheEntry.rowNode);delete rowsCache[row];delete postProcessedRows[row];renderedRows--;counter_rows_removed++}function invalidateRows(rows){var i,rl;if(!rows||!rows.length){return}vScrollDir=0;for(i=0,rl=rows.length;i<rl;i++){if(currentEditor&&activeRow===rows[i]){makeActiveCellNormal()}if(rowsCache[rows[i]]){removeRowFromCache(rows[i])}}}function invalidateRow(row){invalidateRows([row])}function updateCell(row,cell){var cellNode=getCellNode(row,cell);if(!cellNode){return}var m=columns[cell],d=getDataItem(row);if(currentEditor&&activeRow===row&&activeCell===cell){currentEditor.loadValue(d)}else{cellNode.innerHTML=d?getFormatter(row,m)(row,cell,getDataItemValueForColumn(d,m),m,d):"";invalidatePostProcessingResults(row)}}function updateRow(row){var cacheEntry=rowsCache[row];if(!cacheEntry){return}ensureCellNodesInRowsCache(row);for(var columnIdx in cacheEntry.cellNodesByColumnIdx){if(!cacheEntry.cellNodesByColumnIdx.hasOwnProperty(columnIdx)){continue}columnIdx=columnIdx|0;var m=columns[columnIdx],d=getDataItem(row),node=cacheEntry.cellNodesByColumnIdx[columnIdx];if(row===activeRow&&columnIdx===activeCell&&currentEditor){currentEditor.loadValue(d)}else{if(d){node.innerHTML=getFormatter(row,m)(row,columnIdx,getDataItemValueForColumn(d,m),m,d)}else{node.innerHTML=""}}}invalidatePostProcessingResults(row)}function getViewportHeight(){return parseFloat($.css($container[0],"height",true))-parseFloat($.css($container[0],"paddingTop",true))-parseFloat($.css($container[0],"paddingBottom",true))-parseFloat($.css($headerScroller[0],"height"))-getVBoxDelta($headerScroller)-(options.showTopPanel?options.topPanelHeight+getVBoxDelta($topPanelScroller):0)-(options.showHeaderRow?options.headerRowHeight+getVBoxDelta($headerRowScroller):0)}function getContentSize(){var canvasWidth=$canvas.width(),canvasHeight=$canvas.height(),hasVScroll=canvasHeight>$viewport.height(),contentWidth=canvasWidth+(hasVScroll?scrollbarDimensions.width:0),hasHScroll=contentWidth>$viewport.width(),contentHeight=canvasHeight+(hasHScroll?scrollbarDimensions.height:0);return{width:contentWidth,height:contentHeight}}function getVisibleSize(){var width=$viewport.width(),height=$viewport.height(),hasHScroll=$canvas.width()>width-scrollbarDimensions.width,hasVScroll=$canvas.height()>height-scrollbarDimensions.height;width-=hasVScroll?scrollbarDimensions.width:0;height-=hasHScroll?scrollbarDimensions.height:0;return{width:width,height:height}}function resizeCanvas(){if(!initialized){return}if(options.autoHeight){viewportH=options.rowHeight*(getDataLength()+(options.enableAddRow?1:0))}else{viewportH=getViewportHeight()}numVisibleRows=Math.ceil(viewportH/options.rowHeight);viewportW=parseFloat($.css($container[0],"width",true));if(!options.autoHeight){$viewport.height(viewportH)}if(options.forceFitColumns){autosizeColumns()}cleanUpAndRenderCells(getRenderedRange());updateRowCount();handleScroll();render()}function updateRowCount(){if(!initialized){return}numberOfRows=getDataLength()+(options.enableAddRow?1:0)+(options.leaveSpaceForNewRows?numVisibleRows-1:0);var oldViewportHasVScroll=viewportHasVScroll;viewportHasVScroll=!options.autoHeight&&(numberOfRows*options.rowHeight>viewportH);var l=options.enableAddRow?getDataLength():getDataLength()-1;for(var i in rowsCache){if(i>=l){removeRowFromCache(i)}}if(activeCellNode&&activeRow>l){resetActiveCell()}var oldH=h;th=Math.max(options.rowHeight*numberOfRows,viewportH-scrollbarDimensions.height);if(th<maxSupportedCssHeight){h=ph=th;n=1;cj=0}else{h=maxSupportedCssHeight;ph=h/100;n=Math.floor(th/ph);cj=(th-h)/(n-1)}if(h!==oldH){$canvas.css("height",h);scrollTop=$viewport[0].scrollTop}var oldScrollTopInRange=(scrollTop+offset<=th-viewportH);if(th==0||scrollTop==0){page=offset=0}else{if(oldScrollTopInRange){scrollTo(scrollTop+offset)}else{scrollTo(th-viewportH)}}if(h!=oldH&&options.autoHeight){resizeCanvas()}if(options.forceFitColumns&&oldViewportHasVScroll!=viewportHasVScroll){autosizeColumns()}updateCanvasWidth(false)}function getVisibleRange(viewportTop,viewportLeft){if(viewportTop==null){viewportTop=scrollTop}if(viewportLeft==null){viewportLeft=scrollLeft}return{top:Math.floor((viewportTop+offset)/options.rowHeight),bottom:Math.ceil((viewportTop+offset+viewportH)/options.rowHeight),leftPx:viewportLeft,rightPx:viewportLeft+viewportW}}function getRenderedRange(viewportTop,viewportLeft){var range=getVisibleRange(viewportTop,viewportLeft);var buffer=Math.round(viewportH/options.rowHeight);var minBuffer=3;if(vScrollDir==-1){range.top-=buffer;range.bottom+=minBuffer}else{if(vScrollDir==1){range.top-=minBuffer;range.bottom+=buffer}else{range.top-=minBuffer;range.bottom+=minBuffer}}range.top=Math.max(0,range.top);range.bottom=Math.min(options.enableAddRow?getDataLength():getDataLength()-1,range.bottom);range.leftPx-=viewportW;range.rightPx+=viewportW;range.leftPx=Math.max(0,range.leftPx);range.rightPx=Math.min(canvasWidth,range.rightPx);return range}function ensureCellNodesInRowsCache(row){var cacheEntry=rowsCache[row];if(cacheEntry){if(cacheEntry.cellRenderQueue.length){var lastChild=$(cacheEntry.rowNode).children(".slick-cell").last()[0];while(cacheEntry.cellRenderQueue.length){var columnIdx=cacheEntry.cellRenderQueue.pop();cacheEntry.cellNodesByColumnIdx[columnIdx]=lastChild;lastChild=lastChild.previousSibling}}}}function cleanUpCells(range,row){var totalCellsRemoved=0;var cacheEntry=rowsCache[row];var cellsToRemove=[];for(var i in cacheEntry.cellNodesByColumnIdx){if(!cacheEntry.cellNodesByColumnIdx.hasOwnProperty(i)){continue}i=i|0;var colspan=cacheEntry.cellColSpans[i];if(columnPosLeft[i]>range.rightPx||columnPosRight[Math.min(columns.length-1,i+colspan-1)]<range.leftPx){if(!(row==activeRow&&i==activeCell)){cellsToRemove.push(i)}}}var cellToRemove;while((cellToRemove=cellsToRemove.pop())!=null){cacheEntry.rowNode.removeChild(cacheEntry.cellNodesByColumnIdx[cellToRemove]);delete cacheEntry.cellColSpans[cellToRemove];delete cacheEntry.cellNodesByColumnIdx[cellToRemove];if(postProcessedRows[row]){delete postProcessedRows[row][cellToRemove]}totalCellsRemoved++}}function cleanUpAndRenderCells(range){var cacheEntry;var stringArray=[];var processedRows=[];var cellsAdded;var totalCellsAdded=0;var colspan;for(var row=range.top;row<=range.bottom;row++){cacheEntry=rowsCache[row];if(!cacheEntry){continue}ensureCellNodesInRowsCache(row);cleanUpCells(range,row);cellsAdded=0;var metadata=data.getItemMetadata&&data.getItemMetadata(row);metadata=metadata&&metadata.columns;for(var i=0,ii=columns.length;i<ii;i++){if(columnPosLeft[i]>range.rightPx){break}if((colspan=cacheEntry.cellColSpans[i])!=null){i+=(colspan>1?colspan-1:0);continue}colspan=1;if(metadata){var columnData=metadata[columns[i].id]||metadata[i];colspan=(columnData&&columnData.colspan)||1;if(colspan==="*"){colspan=ii-i}}if(columnPosRight[Math.min(ii-1,i+colspan-1)]>range.leftPx){appendCellHtml(stringArray,row,i,colspan);cellsAdded++}i+=(colspan>1?colspan-1:0)}if(cellsAdded){totalCellsAdded+=cellsAdded;processedRows.push(row)}}if(!stringArray.length){return}var x=document.createElement("div");x.innerHTML=stringArray.join("");var processedRow;var node;while((processedRow=processedRows.pop())!=null){cacheEntry=rowsCache[processedRow];var columnIdx;while((columnIdx=cacheEntry.cellRenderQueue.pop())!=null){node=x.lastChild;cacheEntry.rowNode.appendChild(node);cacheEntry.cellNodesByColumnIdx[columnIdx]=node}}}function renderRows(range){var parentNode=$canvas[0],stringArray=[],rows=[],needToReselectCell=false;for(var i=range.top;i<=range.bottom;i++){if(rowsCache[i]){continue}renderedRows++;rows.push(i);rowsCache[i]={rowNode:null,hasRowResizeHandle:false,cellColSpans:[],cellNodesByColumnIdx:[],cellRenderQueue:[]};appendRowHtml(stringArray,i,range);if(activeCellNode&&activeRow===i){needToReselectCell=true}counter_rows_rendered++}if(!rows.length){return}var x=document.createElement("div");x.innerHTML=stringArray.join("");for(var i=0,ii=rows.length;i<ii;i++){rowsCache[rows[i]].rowNode=parentNode.appendChild(x.firstChild)}if(needToReselectCell){activeCellNode=getCellNode(activeRow,activeCell)}}function startPostProcessing(){if(!options.enableAsyncPostRender){return}clearTimeout(h_postrender);h_postrender=setTimeout(asyncPostProcessRows,options.asyncPostRenderDelay)}function invalidatePostProcessingResults(row){delete postProcessedRows[row];postProcessFromRow=Math.min(postProcessFromRow,row);postProcessToRow=Math.max(postProcessToRow,row);startPostProcessing()}function updateRowPositions(){for(var row in rowsCache){rowsCache[row].rowNode.style.top=(row*options.rowHeight-offset)+"px"}}function render(){if(!initialized){return}var visible=getVisibleRange();var rendered=getRenderedRange();cleanupRows(rendered);if(lastRenderedScrollLeft!=scrollLeft){cleanUpAndRenderCells(rendered)}renderRows(rendered);postProcessFromRow=visible.top;postProcessToRow=Math.min(options.enableAddRow?getDataLength():getDataLength()-1,visible.bottom);(activeResizeRow!=null)&&(postProcessToRow=Math.max(postProcessToRow,activeResizeRow));startPostProcessing();installRowResizeHandlesForRange(postProcessFromRow,postProcessToRow);lastRenderedScrollTop=scrollTop;lastRenderedScrollLeft=scrollLeft;h_render=null}function handleHeaderRowScroll(){var scrollLeft=$headerRowScroller[0].scrollLeft;if(scrollLeft!=$viewport[0].scrollLeft){$viewport[0].scrollLeft=scrollLeft}}function handleScroll(){scrollTop=$viewport[0].scrollTop;scrollLeft=$viewport[0].scrollLeft;var vScrollDist=Math.abs(scrollTop-prevScrollTop);var hScrollDist=Math.abs(scrollLeft-prevScrollLeft);if(hScrollDist){prevScrollLeft=scrollLeft;$headerScroller[0].scrollLeft=scrollLeft;$topPanelScroller[0].scrollLeft=scrollLeft;$headerRowScroller[0].scrollLeft=scrollLeft}if(vScrollDist){vScrollDir=prevScrollTop<scrollTop?1:-1;prevScrollTop=scrollTop;if(vScrollDist<viewportH){scrollTo(scrollTop+offset)}else{var oldOffset=offset;if(h==viewportH){page=n-1}else{page=Math.min(n-1,Math.floor(scrollTop*((th-viewportH)/(h-viewportH))*(1/ph)))}offset=Math.round(page*cj);if(oldOffset!=offset){invalidateAllRows()}}}if(hScrollDist||vScrollDist){if(h_render){clearTimeout(h_render)}if(Math.abs(lastRenderedScrollTop-scrollTop)>20||Math.abs(lastRenderedScrollLeft-scrollLeft)>20){if(options.forceSyncScrolling||(Math.abs(lastRenderedScrollTop-scrollTop)<viewportH&&Math.abs(lastRenderedScrollLeft-scrollLeft)<viewportW)){render()}else{h_render=setTimeout(render,50)}trigger(self.onViewportChanged,{})}}trigger(self.onScroll,{scrollLeft:scrollLeft,scrollTop:scrollTop})}function asyncPostProcessRows(){while(postProcessFromRow<=postProcessToRow){var row=(vScrollDir>=0)?postProcessFromRow++:postProcessToRow--;var cacheEntry=rowsCache[row];if(!cacheEntry||row>=getDataLength()){continue}if(!postProcessedRows[row]){postProcessedRows[row]={}}ensureCellNodesInRowsCache(row);for(var columnIdx in cacheEntry.cellNodesByColumnIdx){if(!cacheEntry.cellNodesByColumnIdx.hasOwnProperty(columnIdx)){continue}columnIdx=columnIdx|0;var m=columns[columnIdx];if(m.asyncPostRender&&!postProcessedRows[row][columnIdx]){var node=cacheEntry.cellNodesByColumnIdx[columnIdx];if(node){m.asyncPostRender(node,row,getDataItem(row),m)}postProcessedRows[row][columnIdx]=true}}h_postrender=setTimeout(asyncPostProcessRows,options.asyncPostRenderDelay);return}}function updateCellCssStylesOnRenderedRows(addedHash,removedHash){var node,columnId,addedRowHash,removedRowHash;for(var row in rowsCache){removedRowHash=removedHash&&removedHash[row];addedRowHash=addedHash&&addedHash[row];if(removedRowHash){for(columnId in removedRowHash){if(!addedRowHash||removedRowHash[columnId]!=addedRowHash[columnId]){node=getCellNode(row,getColumnIndex(columnId));if(node){$(node).removeClass(removedRowHash[columnId])}}}}if(addedRowHash){for(columnId in addedRowHash){if(!removedRowHash||removedRowHash[columnId]!=addedRowHash[columnId]){node=getCellNode(row,getColumnIndex(columnId));if(node){$(node).addClass(addedRowHash[columnId])}}}}}}function addCellCssStyles(key,hash){if(cellCssClasses[key]){throw"addCellCssStyles: cell CSS hash with key '"+key+"' already exists."}cellCssClasses[key]=hash;updateCellCssStylesOnRenderedRows(hash,null);trigger(self.onCellCssStylesChanged,{key:key,hash:hash})}function removeCellCssStyles(key){if(!cellCssClasses[key]){return}updateCellCssStylesOnRenderedRows(null,cellCssClasses[key]);delete cellCssClasses[key];trigger(self.onCellCssStylesChanged,{key:key,hash:null})}function setCellCssStyles(key,hash){var prevHash=cellCssClasses[key];cellCssClasses[key]=hash;updateCellCssStylesOnRenderedRows(hash,prevHash);trigger(self.onCellCssStylesChanged,{key:key,hash:hash})}function getCellCssStyles(key){return cellCssClasses[key]}function flashCell(row,cell,speed){speed=speed||100;if(rowsCache[row]){var $cell=$(getCellNode(row,cell));function toggleCellClass(times){if(!times){return}setTimeout(function(){$cell.queue(function(){$cell.toggleClass(options.cellFlashingCssClass).dequeue();toggleCellClass(times-1)})},speed)}toggleCellClass(4)}}function handleHeaderDragInit(e,dd){var $header=$(e.target).closest(".slick-header-column",".slick-header-columns");var column=$header&&$header.data("column");if(!column){return false}dd.column=column;retval=trigger(self.onHeaderDragInit,dd,e);if(e.isImmediatePropagationStopped()){return retval}return false}function handleHeaderDragStart(e,dd){var $header=$(e.target).closest(".slick-header-column",".slick-header-columns");var column=$header&&$header.data("column");if(!column){return false}dd.column=column;var retval=trigger(self.onHeaderDragStart,dd,e);if(e.isImmediatePropagationStopped()){return retval}return false}function handleHeaderDrag(e,dd){return trigger(self.onHeaderDrag,dd,e)}function handleHeaderDragEnd(e,dd){trigger(self.onHeaderDragEnd,dd,e)}function handleDragInit(e,dd){var cell=getCellFromEvent(e);if(!cell||!cellExists(cell.row,cell.cell)){return false}retval=trigger(self.onDragInit,dd,e);if(e.isImmediatePropagationStopped()){return retval}return false}function handleDragStart(e,dd){var cell=getCellFromEvent(e);if(!cell||!cellExists(cell.row,cell.cell)){return false}var retval=trigger(self.onDragStart,dd,e);if(e.isImmediatePropagationStopped()){return retval}return false}function handleDrag(e,dd){return trigger(self.onDrag,dd,e)}function handleDragEnd(e,dd){trigger(self.onDragEnd,dd,e)}function handleKeyDown(e){trigger(self.onKeyDown,{row:activeRow,cell:activeCell},e);var handled=e.isImmediatePropagationStopped();if(!handled){if(!e.shiftKey&&!e.altKey&&!e.ctrlKey){if(e.which==27){if(!getEditorLock().isActive()){return}cancelEditAndSetFocus()}else{if(e.which==37){handled=navigateLeft()}else{if(e.which==39){handled=navigateRight()}else{if(e.which==38){handled=navigateUp()}else{if(e.which==40){handled=navigateDown()}else{if(e.which==9){handled=navigateNext()}else{if(e.which==13){if(options.editable){if(currentEditor){if(activeRow===getDataLength()){navigateDown()}else{commitEditAndSetFocus()}}else{if(getEditorLock().commitCurrentEdit()){makeActiveCellEditable()}}}handled=true}}}}}}}}else{if(e.which==9&&e.shiftKey&&!e.ctrlKey&&!e.altKey){handled=navigatePrev()}}}if(handled){e.stopPropagation();e.preventDefault();try{e.originalEvent.keyCode=0}catch(error){}}}function handleClick(e){if(!currentEditor){if(e.target!=document.activeElement){setFocus()}}var cell=getCellFromEvent(e);if(!cell||(currentEditor!==null&&activeRow==cell.row&&activeCell==cell.cell)){return}trigger(self.onClick,{row:cell.row,cell:cell.cell},e);if(e.isImmediatePropagationStopped()){return}if((activeCell!=cell.cell||activeRow!=cell.row)&&canCellBeActive(cell.row,cell.cell)){if(!getEditorLock().isActive()||getEditorLock().commitCurrentEdit()){scrollRowIntoView(cell.row,false);setActiveCellInternal(getCellNode(cell.row,cell.cell),(cell.row===getDataLength())||canAutoEditCell(cell.row,cell.cell,"click"))}}}function handleContextMenu(e){var $cell=$(e.target).closest(".slick-cell",$canvas);if($cell.length===0){return}if(activeCellNode===$cell[0]&&currentEditor!==null){return}trigger(self.onContextMenu,{},e)}function handleDblClick(e){var cell=getCellFromEvent(e);if(!cell||(currentEditor!==null&&activeRow==cell.row&&activeCell==cell.cell)){return}trigger(self.onDblClick,{row:cell.row,cell:cell.cell},e);if(e.isImmediatePropagationStopped()){return}if(options.editable){gotoCell(cell.row,cell.cell,true)}}function handleHeaderMouseEnter(e){trigger(self.onHeaderMouseEnter,{column:$(this).data("column")},e)}function handleHeaderMouseLeave(e){trigger(self.onHeaderMouseLeave,{column:$(this).data("column")},e)}function handleHeaderContextMenu(e){var $header=$(e.target).closest(".slick-header-column",".slick-header-columns");var column=$header&&$header.data("column");trigger(self.onHeaderContextMenu,{column:column},e)}function handleHeaderClick(e){var $header=$(e.target).closest(".slick-header-column",".slick-header-columns");var column=$header&&$header.data("column");if(column){trigger(self.onHeaderClick,{column:column},e)}}function handleMouseEnter(e){trigger(self.onMouseEnter,{},e)}function handleMouseLeave(e){trigger(self.onMouseLeave,{},e)}function cellExists(row,cell){return !(row<0||row>=getDataLength()||cell<0||cell>=columns.length)}function getCellFromPoint(x,y){var row=Math.floor((y+offset)/options.rowHeight);var cell=0;var w=0;for(var i=0;i<columns.length&&w<x;i++){w+=columns[i].width;cell++}if(cell<0){cell=0}return{row:row,cell:cell-1}}function getCellFromNode(cellNode){var cls=/l\d+/.exec(cellNode.className);if(!cls){throw"getCellFromNode: cannot get cell - "+cellNode.className}return parseInt(cls[0].substr(1,cls[0].length-1),10)}function getRowFromNode(rowNode){for(var row in rowsCache){if(rowsCache[row].rowNode===rowNode){return row|0}}return null}function getCellFromEvent(e){var $cell=$(e.target).closest(".slick-cell",$canvas);if(!$cell.length){return null}var row=getRowFromNode($cell[0].parentNode);var cell=getCellFromNode($cell[0]);if(row==null||cell==null){return null}else{return{row:row,cell:cell}}}function getCellNodeBox(row,cell){if(!cellExists(row,cell)){return null}var y1=row*options.rowHeight-offset;var y2=y1+options.rowHeight-1;var x1=0;for(var i=0;i<cell;i++){x1+=columns[i].width}var x2=x1+columns[cell].width;return{top:y1,left:x1,bottom:y2,right:x2}}function resetActiveCell(){setActiveCellInternal(null,false)}function setFocus(){if(tabbingDirection==-1){$focusSink[0].focus()}else{$focusSink2[0].focus()}}function scrollCellIntoView(row,cell){var colspan=getColspan(row,cell);var left=columnPosLeft[cell],right=columnPosRight[cell+(colspan>1?colspan-1:0)],scrollRight=scrollLeft+viewportW;if(left<scrollLeft){$viewport.scrollLeft(left);handleScroll();render()}else{if(right>scrollRight){$viewport.scrollLeft(Math.min(left,right-$viewport[0].clientWidth));handleScroll();render()}}}function setActiveCellInternal(newCell,editMode){if(activeCellNode!==null){makeActiveCellNormal();$(activeCellNode).removeClass("active");if(rowsCache[activeRow]){$(rowsCache[activeRow].rowNode).removeClass("active")}}var activeCellChanged=(activeCellNode!==newCell);activeCellNode=newCell;if(activeCellNode!=null){activeRow=getRowFromNode(activeCellNode.parentNode);activeCell=activePosX=getCellFromNode(activeCellNode);$(activeCellNode).addClass("active");$(rowsCache[activeRow].rowNode).addClass("active");if(options.editable&&editMode&&isCellPotentiallyEditable(activeRow,activeCell)){clearTimeout(h_editorLoader);if(options.asyncEditorLoading){h_editorLoader=setTimeout(function(){makeActiveCellEditable()},options.asyncEditorLoadDelay)}else{makeActiveCellEditable()}}}else{activeRow=activeCell=null}if(activeCellChanged){trigger(self.onActiveCellChanged,getActiveCell())}}function clearTextSelection(){if(document.selection&&document.selection.empty){document.selection.empty()}else{if(window.getSelection){var sel=window.getSelection();if(sel&&sel.removeAllRanges){sel.removeAllRanges()}}}}function isCellPotentiallyEditable(row,cell){if(row<getDataLength()&&!getDataItem(row)){return false}if(columns[cell].cannotTriggerInsert&&row>=getDataLength()){return false}if(!getEditor(row,cell)){return false}return true}function makeActiveCellNormal(){if(!currentEditor){return}trigger(self.onBeforeCellEditorDestroy,{editor:currentEditor});currentEditor.destroy();currentEditor=null;if(activeCellNode){var d=getDataItem(activeRow);$(activeCellNode).removeClass("editable invalid");if(d){var column=columns[activeCell];var formatter=getFormatter(activeRow,column);activeCellNode.innerHTML=formatter(activeRow,activeCell,getDataItemValueForColumn(d,column),column,getDataItem(activeRow));invalidatePostProcessingResults(activeRow)}}if(navigator.userAgent.toLowerCase().match(/msie/)){clearTextSelection()}getEditorLock().deactivate(editController)}function makeActiveCellEditable(editor){if(!activeCellNode){return}if(!options.editable){throw"Grid : makeActiveCellEditable : should never get called when options.editable is false"}clearTimeout(h_editorLoader);if(!isCellPotentiallyEditable(activeRow,activeCell)){return}var columnDef=columns[activeCell];var item=getDataItem(activeRow);if(trigger(self.onBeforeEditCell,{row:activeRow,cell:activeCell,item:item,column:columnDef})===false){setFocus();return}getEditorLock().activate(editController);$(activeCellNode).addClass("editable");if(!editor){activeCellNode.innerHTML=""}currentEditor=new (editor||getEditor(activeRow,activeCell))({grid:self,gridPosition:absBox($container[0]),position:absBox(activeCellNode),container:activeCellNode,column:columnDef,item:item||{},commitChanges:commitEditAndSetFocus,cancelChanges:cancelEditAndSetFocus});if(item){currentEditor.loadValue(item)}serializedEditorValue=currentEditor.serializeValue();if(currentEditor.position){handleActiveCellPositionChange()}}function commitEditAndSetFocus(){var cell=getActiveCell();if(getEditorLock().commitCurrentEdit()){setFocus();if(canAutoEditCell(cell.row,cell.cell,"commit")){navigateDown()}}}function cancelEditAndSetFocus(){if(getEditorLock().cancelCurrentEdit()){setFocus()}}function absBox(elem){var box={top:elem.offsetTop,left:elem.offsetLeft,bottom:0,right:0,width:$(elem).outerWidth(),height:$(elem).outerHeight(),visible:true};box.bottom=box.top+box.height;box.right=box.left+box.width;var offsetParent=elem.offsetParent;while((elem=elem.parentNode)!=document.body){if(box.visible&&elem.scrollHeight!=elem.offsetHeight&&$(elem).css("overflowY")!="visible"){box.visible=box.bottom>elem.scrollTop&&box.top<elem.scrollTop+elem.clientHeight}if(box.visible&&elem.scrollWidth!=elem.offsetWidth&&$(elem).css("overflowX")!="visible"){box.visible=box.right>elem.scrollLeft&&box.left<elem.scrollLeft+elem.clientWidth}box.left-=elem.scrollLeft;box.top-=elem.scrollTop;if(elem===offsetParent){box.left+=elem.offsetLeft;box.top+=elem.offsetTop;offsetParent=elem.offsetParent}box.bottom=box.top+box.height;box.right=box.left+box.width}return box}function getActiveCellPosition(){return absBox(activeCellNode)}function getGridPosition(){return absBox($container[0])}function handleActiveCellPositionChange(){if(!activeCellNode){return}trigger(self.onActiveCellPositionChanged,{});if(currentEditor){var cellBox=getActiveCellPosition();if(currentEditor.show&&currentEditor.hide){if(!cellBox.visible){currentEditor.hide()}else{currentEditor.show()}}if(currentEditor.position){currentEditor.position(cellBox)}}}function getCellEditor(){return currentEditor}function getActiveCell(){if(!activeCellNode){return null}else{return{row:activeRow,cell:activeCell}}}function getActiveCellNode(){return activeCellNode}function scrollRowIntoView(row,doPaging){var rowAtTop=row*options.rowHeight;var rowAtBottom=(row+1)*options.rowHeight-viewportH+(viewportHasHScroll?scrollbarDimensions.height:0);if((row+1)*options.rowHeight>scrollTop+viewportH+offset){scrollTo(doPaging?rowAtTop:rowAtBottom);render()}else{if(row*options.rowHeight<scrollTop+offset){scrollTo(doPaging?rowAtBottom:rowAtTop);render()}}}function scrollRowToTop(row){scrollTo(row*options.rowHeight);render()}function getColspan(row,cell){var metadata=data.getItemMetadata&&data.getItemMetadata(row);if(!metadata||!metadata.columns){return 1}var columnData=metadata.columns[columns[cell].id]||metadata.columns[cell];var colspan=(columnData&&columnData.colspan);if(colspan==="*"){colspan=columns.length-cell}else{colspan=colspan||1}return colspan}function findFirstFocusableCell(row){var cell=0;while(cell<columns.length){if(canCellBeActive(row,cell)){return cell}cell+=getColspan(row,cell)}return null}function findLastFocusableCell(row){var cell=0;var lastFocusableCell=null;while(cell<columns.length){if(canCellBeActive(row,cell)){lastFocusableCell=cell}cell+=getColspan(row,cell)}return lastFocusableCell}function gotoRight(row,cell,posX){if(cell>=columns.length){return null}do{cell+=getColspan(row,cell)}while(cell<columns.length&&!canCellBeActive(row,cell));if(cell<columns.length){return{row:row,cell:cell,posX:cell}}return null}function gotoLeft(row,cell,posX){if(cell<=0){return null}var firstFocusableCell=findFirstFocusableCell(row);if(firstFocusableCell===null||firstFocusableCell>=cell){return null}var prev={row:row,cell:firstFocusableCell,posX:firstFocusableCell};var pos;while(true){pos=gotoRight(prev.row,prev.cell,prev.posX);if(!pos){return null}if(pos.cell>=cell){return prev}prev=pos}}function gotoDown(row,cell,posX){var prevCell;while(true){if(++row>=getDataLength()+(options.enableAddRow?1:0)){return null}prevCell=cell=0;while(cell<=posX){prevCell=cell;cell+=getColspan(row,cell)}if(canCellBeActive(row,prevCell)){return{row:row,cell:prevCell,posX:posX}}}}function gotoUp(row,cell,posX){var prevCell;while(true){if(--row<0){return null}prevCell=cell=0;while(cell<=posX){prevCell=cell;cell+=getColspan(row,cell)}if(canCellBeActive(row,prevCell)){return{row:row,cell:prevCell,posX:posX}}}}function gotoNext(row,cell,posX){if(row==null&&cell==null){row=cell=posX=0;if(canCellBeActive(row,cell)){return{row:row,cell:cell,posX:cell}}}var pos=gotoRight(row,cell,posX);if(pos){return pos}var firstFocusableCell=null;while(++row<getDataLength()+(options.enableAddRow?1:0)){firstFocusableCell=findFirstFocusableCell(row);if(firstFocusableCell!==null){return{row:row,cell:firstFocusableCell,posX:firstFocusableCell}}}return null}function gotoPrev(row,cell,posX){if(row==null&&cell==null){row=getDataLength()+(options.enableAddRow?1:0)-1;cell=posX=columns.length-1;if(canCellBeActive(row,cell)){return{row:row,cell:cell,posX:cell}}}var pos;var lastSelectableCell;while(!pos){pos=gotoLeft(row,cell,posX);if(pos){break}if(--row<0){return null}cell=0;lastSelectableCell=findLastFocusableCell(row);if(lastSelectableCell!==null){pos={row:row,cell:lastSelectableCell,posX:lastSelectableCell}}}return pos}function navigateRight(){return navigate("right")}function navigateLeft(){return navigate("left")}function navigateDown(){return navigate("down")}function navigateUp(){return navigate("up")}function navigateNext(){return navigate("next")}function navigatePrev(){return navigate("prev")}function navigate(dir){if(!options.enableCellNavigation){return false}if(!activeCellNode&&dir!="prev"&&dir!="next"){return false}if(!getEditorLock().commitCurrentEdit()){return true}setFocus();var tabbingDirections={up:-1,down:1,left:-1,right:1,prev:-1,next:1};tabbingDirection=tabbingDirections[dir];var stepFunctions={up:gotoUp,down:gotoDown,left:gotoLeft,right:gotoRight,prev:gotoPrev,next:gotoNext};var stepFn=stepFunctions[dir];var pos=stepFn(activeRow,activeCell,activePosX);if(pos){var isAddNewRow=(pos.row==getDataLength());scrollRowIntoView(pos.row,!isAddNewRow);scrollCellIntoView(pos.row,pos.cell);setActiveCellInternal(getCellNode(pos.row,pos.cell),isAddNewRow||canAutoEditCell(pos.row,pos.cell,"navigate"));activePosX=pos.posX;return true}else{setActiveCellInternal(getCellNode(activeRow,activeCell),(activeRow==getDataLength())||canAutoEditCell(activeRow,activeCell,"navigate"));return false}}function getCellNode(row,cell){if(rowsCache[row]){ensureCellNodesInRowsCache(row);return rowsCache[row].cellNodesByColumnIdx[cell]}return null}function setActiveCell(row,cell){if(!initialized){return}if(row>getDataLength()||row<0||cell>=columns.length||cell<0){return}if(!options.enableCellNavigation){return}scrollRowIntoView(row,false);scrollCellIntoView(row,cell);setActiveCellInternal(getCellNode(row,cell),false)}function canCellBeActive(row,cell){if(!options.enableCellNavigation||row>=getDataLength()+(options.enableAddRow?1:0)||row<0||cell>=columns.length||cell<0){return false}var rowMetadata=data.getItemMetadata&&data.getItemMetadata(row);if(rowMetadata&&typeof rowMetadata.focusable==="boolean"){return rowMetadata.focusable}var columnMetadata=rowMetadata&&rowMetadata.columns;if(columnMetadata&&columnMetadata[columns[cell].id]&&typeof columnMetadata[columns[cell].id].focusable==="boolean"){return columnMetadata[columns[cell].id].focusable}if(columnMetadata&&columnMetadata[cell]&&typeof columnMetadata[cell].focusable==="boolean"){return columnMetadata[cell].focusable}return columns[cell].focusable}function canCellBeSelected(row,cell){if(row>=getDataLength()||row<0||cell>=columns.length||cell<0){return false}var rowMetadata=data.getItemMetadata&&data.getItemMetadata(row);if(rowMetadata&&typeof rowMetadata.selectable==="boolean"){return rowMetadata.selectable}var columnMetadata=rowMetadata&&rowMetadata.columns&&(rowMetadata.columns[columns[cell].id]||rowMetadata.columns[cell]);if(columnMetadata&&typeof columnMetadata.selectable==="boolean"){return columnMetadata.selectable}return columns[cell].selectable}function canAutoEditCell(row,cell,source){return options.autoEdit||trigger(self.onBeforeAutoEditCell,{row:row,cell:cell,source:source})}function gotoCell(row,cell,forceEdit){if(!initialized){return}if(!canCellBeActive(row,cell)){return}if(!getEditorLock().commitCurrentEdit()){return}scrollRowIntoView(row,false);scrollCellIntoView(row,cell);var newCell=getCellNode(row,cell);setActiveCellInternal(newCell,forceEdit||(row===getDataLength())||canAutoEditCell(row,cell,"goto"));if(!currentEditor){setFocus()}}function commitCurrentEdit(){var item=getDataItem(activeRow);var column=columns[activeCell];if(currentEditor){if(currentEditor.isValueChanged()){var validationResults=currentEditor.validate();if(validationResults.valid){if(activeRow<getDataLength()){var editCommand={row:activeRow,cell:activeCell,editor:currentEditor,serializedValue:currentEditor.serializeValue(),prevSerializedValue:serializedEditorValue,execute:function(){this.editor.applyValue(item,this.serializedValue);updateRow(this.row)},undo:function(){this.editor.applyValue(item,this.prevSerializedValue);updateRow(this.row)}};if(options.editCommandHandler){makeActiveCellNormal();options.editCommandHandler(item,column,editCommand)}else{editCommand.execute();makeActiveCellNormal()}trigger(self.onCellChange,{row:activeRow,cell:activeCell,item:item})}else{var newItem={};currentEditor.applyValue(newItem,currentEditor.serializeValue());makeActiveCellNormal();trigger(self.onAddNewRow,{item:newItem,column:column})}return !getEditorLock().isActive()}else{$(activeCellNode).addClass("invalid");$(activeCellNode).stop(true,true).effect("highlight",{color:"red"},300);trigger(self.onValidationError,{editor:currentEditor,cellNode:activeCellNode,validationResults:validationResults,row:activeRow,cell:activeCell,column:column});currentEditor.focus();return false}}makeActiveCellNormal()}return true}function cancelCurrentEdit(){makeActiveCellNormal();return true}function rowsToRanges(rows){var ranges=[];var lastCell=columns.length-1;for(var i=0;i<rows.length;i++){ranges.push(new Slick.Range(rows[i],0,rows[i],lastCell))}return ranges}function getSelectedRows(){if(!selectionModel){throw"Selection model is not set"}return selectedRows}function setSelectedRows(rows){if(!selectionModel){throw"Selection model is not set"}selectionModel.setSelectedRanges(rowsToRanges(rows))}this.debug=function(){var s="";s+=("\ncounter_rows_rendered:  "+counter_rows_rendered);s+=("\ncounter_rows_removed:  "+counter_rows_removed);s+=("\nrenderedRows:  "+renderedRows);s+=("\nnumVisibleRows:  "+numVisibleRows);s+=("\nmaxSupportedCssHeight:  "+maxSupportedCssHeight);s+=("\nn(umber of pages):  "+n);s+=("\n(current) page:  "+page);s+=("\npage height (ph):  "+ph);s+=("\nvScrollDir:  "+vScrollDir);alert(s)};this.eval=function(expr){return eval(expr)};$.extend(this,{slickGridVersion:"2.1",onScroll:new Slick.Event(),onSort:new Slick.Event(),onHeaderMouseEnter:new Slick.Event(),onHeaderMouseLeave:new Slick.Event(),onHeaderContextMenu:new Slick.Event(),onHeaderClick:new Slick.Event(),onHeaderCellRendered:new Slick.Event(),onBeforeHeaderCellDestroy:new Slick.Event(),onHeaderRowCellRendered:new Slick.Event(),onBeforeHeaderRowCellDestroy:new Slick.Event(),onMouseEnter:new Slick.Event(),onMouseLeave:new Slick.Event(),onClick:new Slick.Event(),onDblClick:new Slick.Event(),onContextMenu:new Slick.Event(),onKeyDown:new Slick.Event(),onAddNewRow:new Slick.Event(),onValidationError:new Slick.Event(),onCanvasWidthChanged:new Slick.Event(),onViewportChanged:new Slick.Event(),onColumnsReordered:new Slick.Event(),onColumnsResized:new Slick.Event(),onCellChange:new Slick.Event(),onBeforeAutoEditCell:new Slick.Event(),onBeforeEditCell:new Slick.Event(),onBeforeCellEditorDestroy:new Slick.Event(),onBeforeDestroy:new Slick.Event(),onActiveCellChanged:new Slick.Event(),onActiveCellPositionChanged:new Slick.Event(),onHeaderDragInit:new Slick.Event(),onHeaderDragStart:new Slick.Event(),onHeaderDrag:new Slick.Event(),onHeaderDragEnd:new Slick.Event(),onDragInit:new Slick.Event(),onDragStart:new Slick.Event(),onDrag:new Slick.Event(),onDragEnd:new Slick.Event(),onSelectedRowsChanged:new Slick.Event(),onCellCssStylesChanged:new Slick.Event(),onColumnResizing:new Slick.Event(),onRowResizeDragInit:new Slick.Event(),onRowResizeDragStart:new Slick.Event(),onRowResizeDrag:new Slick.Event(),onRowResizeDragEnd:new Slick.Event(),registerPlugin:registerPlugin,unregisterPlugin:unregisterPlugin,getColumns:getColumns,setColumns:setColumns,getColumnIndex:getColumnIndex,updateColumnHeader:updateColumnHeader,setSortColumn:setSortColumn,setSortColumns:setSortColumns,getSortColumns:getSortColumns,autosizeColumns:autosizeColumns,getOptions:getOptions,setOptions:setOptions,getData:getData,getDataLength:getDataLength,getDataItem:getDataItem,setData:setData,getSelectionModel:getSelectionModel,setSelectionModel:setSelectionModel,getSelectedRows:getSelectedRows,setSelectedRows:setSelectedRows,render:render,invalidate:invalidate,invalidateRow:invalidateRow,invalidateRows:invalidateRows,invalidateAllRows:invalidateAllRows,updateCell:updateCell,updateRow:updateRow,getViewport:getVisibleRange,getRenderedRange:getRenderedRange,getContentSize:getContentSize,getVisibleSize:getVisibleSize,resizeCanvas:resizeCanvas,updateRowCount:updateRowCount,scrollRowIntoView:scrollRowIntoView,scrollRowToTop:scrollRowToTop,scrollCellIntoView:scrollCellIntoView,getCanvasNode:getCanvasNode,focus:setFocus,getCellFromPoint:getCellFromPoint,getCellFromEvent:getCellFromEvent,getActiveCell:getActiveCell,setActiveCell:setActiveCell,getActiveCellNode:getActiveCellNode,getActiveCellPosition:getActiveCellPosition,resetActiveCell:resetActiveCell,editActiveCell:makeActiveCellEditable,getCellEditor:getCellEditor,getCellNode:getCellNode,getCellNodeBox:getCellNodeBox,canCellBeSelected:canCellBeSelected,canCellBeActive:canCellBeActive,navigatePrev:navigatePrev,navigateNext:navigateNext,navigateUp:navigateUp,navigateDown:navigateDown,navigateLeft:navigateLeft,navigateRight:navigateRight,gotoCell:gotoCell,getTopPanel:getTopPanel,setTopPanelVisibility:setTopPanelVisibility,setHeaderRowVisibility:setHeaderRowVisibility,getHeaderRow:getHeaderRow,getHeaderRowColumn:getHeaderRowColumn,getGridPosition:getGridPosition,flashCell:flashCell,addCellCssStyles:addCellCssStyles,setCellCssStyles:setCellCssStyles,removeCellCssStyles:removeCellCssStyles,getCellCssStyles:getCellCssStyles,init:finishInitialization,destroy:destroy,getEditorLock:getEditorLock,getEditController:getEditController});init()}}(jQuery));(function(b){b.extend(true,window,{Slick:{Data:{GroupItemMetadataProvider:a}}});function a(m){var i;var f={groupCssClass:"slick-group",groupTitleCssClass:"slick-group-title",totalsCssClass:"slick-group-totals",groupSelectable:false,groupFocusable:true,totalsFocusable:false,toggleCssClass:"slick-group-toggle",toggleExpandedCssClass:"expanded",toggleCollapsedCssClass:"collapsed",enableExpandCollapse:true};m=b.extend(true,{},f,m);function h(s,n,r,o,q){if(!m.enableExpandCollapse){return q.title}var p=q.level*15+"px";return"<span class='"+m.toggleCssClass+" "+(q.collapsed?m.toggleCollapsedCssClass:m.toggleExpandedCssClass)+"' style='margin-left:"+p+"'></span><span class='"+m.groupTitleCssClass+"' level='"+q.level+"'>"+q.title+"</span>"}function d(r,n,q,o,p){return(o.groupTotalsFormatter&&o.groupTotalsFormatter(p,o))||""}function l(n){i=n;i.onClick.subscribe(e);i.onKeyDown.subscribe(j)}function k(){if(i){i.onClick.unsubscribe(e);i.onKeyDown.unsubscribe(j)}}function e(p,n){var o=this.getDataItem(n.row);if(o&&o instanceof Slick.Group&&b(p.target).hasClass(m.toggleCssClass)){if(o.collapsed){this.getData().expandGroup(o.groupingKey)}else{this.getData().collapseGroup(o.groupingKey)}p.stopImmediatePropagation();p.preventDefault()}}function j(q,o){if(m.enableExpandCollapse&&(q.which==b.ui.keyCode.SPACE)){var n=this.getActiveCell();if(n){var p=this.getDataItem(n.row);if(p&&p instanceof Slick.Group){if(p.collapsed){this.getData().expandGroup(p.groupingKey)}else{this.getData().collapseGroup(p.groupingKey)}q.stopImmediatePropagation();q.preventDefault()}}}}function c(n){return{selectable:m.groupSelectable,focusable:m.groupFocusable,cssClasses:m.groupCssClass,columns:{0:{colspan:"*",formatter:h,editor:null}}}}function g(n){return{selectable:false,focusable:m.totalsFocusable,cssClasses:m.totalsCssClass,formatter:d,editor:null}}return{init:l,destroy:k,getGroupRowMetadata:c,getTotalsRowMetadata:g}}})(jQuery);(function(a){if(typeof define==="function"&&define.amd){define(["jquery"],a)}else{if(typeof exports=="object"&&typeof module=="object"){module.exports=a}else{a(jQuery)}}})(function(e,g){var m={beforeShow:b,move:b,change:b,show:b,hide:b,color:false,flat:false,showInput:false,allowEmpty:false,showButtons:true,clickoutFiresChange:true,showInitial:false,showPalette:false,showPaletteOnly:false,hideAfterPaletteSelect:false,togglePaletteOnly:false,showSelectionPalette:true,localStorageKey:false,appendTo:"body",maxSelectionSize:7,cancelText:"cancel",chooseText:"choose",togglePaletteMoreText:"more",togglePaletteLessText:"less",clearText:"Clear Color Selection",noColorSelectedText:"No Color Selected",preferredFormat:false,className:"",containerClassName:"",replacerClassName:"",showAlpha:false,theme:"sp-light",palette:[["#ffffff","#000000","#ff0000","#ff8000","#ffff00","#008000","#0000ff","#4b0082","#9400d3"]],selectionPalette:[],disabled:false,offset:null},d=[],h=!!/msie/i.exec(window.navigator.userAgent),l=(function(){function u(y,x){return !!~(""+y).indexOf(x)}var w=document.createElement("div");var v=w.style;v.cssText="background-color:rgba(0,0,0,.5)";return u(v.backgroundColor,"rgba")||u(v.backgroundColor,"hsla")})(),q=["<div class='sp-replacer'>","<div class='sp-preview'><div class='sp-preview-inner'></div></div>","<div class='sp-dd'>&#9660;</div>","</div>"].join(""),p=(function(){var u="";if(h){for(var v=1;v<=6;v++){u+="<div class='sp-"+v+"'></div>"}}return["<div class='sp-container sp-hidden'>","<div class='sp-palette-container'>","<div class='sp-palette sp-thumb sp-cf'></div>","<div class='sp-palette-button-container sp-cf'>","<button type='button' class='sp-palette-toggle'></button>","</div>","</div>","<div class='sp-picker-container'>","<div class='sp-top sp-cf'>","<div class='sp-fill'></div>","<div class='sp-top-inner'>","<div class='sp-color'>","<div class='sp-sat'>","<div class='sp-val'>","<div class='sp-dragger'></div>","</div>","</div>","</div>","<div class='sp-clear sp-clear-display'>","</div>","<div class='sp-hue'>","<div class='sp-slider'></div>",u,"</div>","</div>","<div class='sp-alpha'><div class='sp-alpha-inner'><div class='sp-alpha-handle'></div></div></div>","</div>","<div class='sp-input-container sp-cf'>","<input class='sp-input' type='text' spellcheck='false'  />","</div>","<div class='sp-initial sp-thumb sp-cf'></div>","<div class='sp-button-container sp-cf'>","<a class='sp-cancel' href='#'></a>","<button type='button' class='sp-choose'></button>","</div>","</div>","</div>"].join("")})();function s(w,y,C,u){var A=[];for(var z=0;z<w.length;z++){var B=w[z];if(B){var v=tinycolor(B);var E=v.toHsl().l<0.5?"sp-thumb-el sp-thumb-dark":"sp-thumb-el sp-thumb-light";E+=(tinycolor.equals(y,B))?" sp-thumb-active":"";var D=v.toString(u.preferredFormat||"rgb");var x=l?("background-color:"+v.toRgbString()):"filter:"+v.toFilter();A.push('<span title="'+D+'" data-color="'+v.toRgbString()+'" class="'+E+'"><span class="sp-thumb-inner" style="'+x+';" /></span>')}else{var F="sp-clear-display";A.push(e("<div />").append(e('<span data-color="" style="background-color:transparent;" class="'+F+'"></span>').attr("title",u.noColorSelectedText)).html())}}return"<div class='sp-cf "+C+"'>"+A.join("")+"</div>"}function o(){for(var u=0;u<d.length;u++){if(d[u]){d[u].hide()}}}function n(w,u){var v=e.extend({},m,w);v.callbacks={move:t(v.move,u),change:t(v.change,u),show:t(v.show,u),hide:t(v.hide,u),beforeShow:t(v.beforeShow,u)};return v}function r(a9,ai){var a8=n(ai,a9),a4=a8.flat,X=a8.showSelectionPalette,w=a8.localStorageKey,al=a8.theme,S=a8.callbacks,E=f(ae,10),P=false,aq=false,aN=0,ag=0,aO=0,aA=0,M=0,az=0,aZ=0,at=0,Z=0,Q=0,aD=0,a0=1,aj=[],am=[],a6={},aJ=a8.selectionPalette.slice(0),aI=a8.maxSelectionSize,x="sp-dragging",G=null;var Y=a9.ownerDocument,O=Y.body,D=e(a9),aX=false,aP=e(p,Y).addClass(al),u=aP.find(".sp-picker-container"),I=aP.find(".sp-color"),aM=aP.find(".sp-dragger"),N=aP.find(".sp-hue"),a3=aP.find(".sp-slider"),aF=aP.find(".sp-alpha-inner"),aa=aP.find(".sp-alpha"),aG=aP.find(".sp-alpha-handle"),K=aP.find(".sp-input"),R=aP.find(".sp-palette"),a7=aP.find(".sp-initial"),ar=aP.find(".sp-cancel"),ao=aP.find(".sp-clear"),H=aP.find(".sp-choose"),aR=aP.find(".sp-palette-toggle"),T=D.is("input"),B=T&&D.attr("type")==="color"&&k(),aC=T&&!a4,aV=(aC)?e(q).addClass(al).addClass(a8.className).addClass(a8.replacerClassName):e([]),ax=(aC)?aV:D,J=aV.find(".sp-preview-inner"),U=a8.color||(T&&D.val()),aQ=false,W=a8.preferredFormat,av=W,F=!a8.showButtons||a8.clickoutFiresChange,C=!U,a5=a8.allowEmpty&&!B;function v(){if(a8.showPaletteOnly){a8.showPalette=true}aR.text(a8.showPaletteOnly?a8.togglePaletteMoreText:a8.togglePaletteLessText);if(a8.palette){aj=a8.palette.slice(0);am=e.isArray(aj[0])?aj:[aj];a6={};for(var bd=0;bd<am.length;bd++){for(var bc=0;bc<am[bd].length;bc++){var bb=tinycolor(am[bd][bc]).toRgbString();a6[bb]=true}}}aP.toggleClass("sp-flat",a4);aP.toggleClass("sp-input-disabled",!a8.showInput);aP.toggleClass("sp-alpha-enabled",a8.showAlpha);aP.toggleClass("sp-clear-enabled",a5);aP.toggleClass("sp-buttons-disabled",!a8.showButtons);aP.toggleClass("sp-palette-buttons-disabled",!a8.togglePaletteOnly);aP.toggleClass("sp-palette-disabled",!a8.showPalette);aP.toggleClass("sp-palette-only",a8.showPaletteOnly);aP.toggleClass("sp-initial-disabled",!a8.showInitial);aP.addClass(a8.className).addClass(a8.containerClassName);ae()}function aK(){if(h){aP.find("*:not(input)").attr("unselectable","on")}v();if(aC){D.after(aV).hide()}if(!a5){ao.hide()}if(a4){D.after(aP).hide()}else{var bc=a8.appendTo==="parent"?D.parent():e(a8.appendTo);if(bc.length!==1){bc=e("body")}bc.append(aP)}aS();ax.bind("click.spectrum touchstart.spectrum",function(be){if(!aX){ay()}be.stopPropagation();if(!e(be.target).is("input")){be.preventDefault()}});if(D.is(":disabled")||(a8.disabled===true)){V()}aP.click(j);K.change(aT);K.bind("paste",function(){setTimeout(aT,1)});K.keydown(function(be){if(be.keyCode==13){aT()}});ar.text(a8.cancelText);ar.bind("click.spectrum",function(be){be.stopPropagation();be.preventDefault();aw();aH()});ao.attr("title",a8.clearText);ao.bind("click.spectrum",function(be){be.stopPropagation();be.preventDefault();C=true;aL();if(a4){ap(true)}});H.text(a8.chooseText);H.bind("click.spectrum",function(be){be.stopPropagation();be.preventDefault();if(h&&K.is(":focus")){K.trigger("change")}if(aB()){ap(true);aH()}});aR.text(a8.showPaletteOnly?a8.togglePaletteMoreText:a8.togglePaletteLessText);aR.bind("click.spectrum",function(be){be.stopPropagation();be.preventDefault();a8.showPaletteOnly=!a8.showPaletteOnly;if(!a8.showPaletteOnly&&!a4){aP.css("left","-="+(u.outerWidth(true)+5))}v()});c(aa,function(bg,bf,be){a0=(bg/az);C=false;if(be.shiftKey){a0=Math.round(a0*10)/10}aL()},A,ba);c(N,function(bf,be){Z=parseFloat(be/aA);C=false;if(!a8.showAlpha){a0=1}aL()},A,ba);c(I,function(bl,bj,bi){if(!bi.shiftKey){G=null}else{if(!G){var bg=Q*aN;var be=ag-(aD*ag);var bf=Math.abs(bl-bg)>Math.abs(bj-be);G=bf?"x":"y"}}var bh=!G||G==="x";var bk=!G||G==="y";if(bh){Q=parseFloat(bl/aN)}if(bk){aD=parseFloat((ag-bj)/ag)}C=false;if(!a8.showAlpha){a0=1}aL()},A,ba);if(!!U){ad(U);aE();av=W||tinycolor(U).format;aW(U)}else{aE()}if(a4){z()}function bd(be){if(be.data&&be.data.ignore){ad(e(be.target).closest(".sp-thumb-el").data("color"));aL()}else{ad(e(be.target).closest(".sp-thumb-el").data("color"));aL();ap(true);if(a8.hideAfterPaletteSelect){aH()}}return false}var bb=h?"mousedown.spectrum":"click.spectrum touchstart.spectrum";R.delegate(".sp-thumb-el",bb,bd);a7.delegate(".sp-thumb-el:nth-child(1)",bb,{ignore:true},bd)}function aS(){if(w&&window.localStorage){try{var bb=window.localStorage[w].split(",#");if(bb.length>1){delete window.localStorage[w];e.each(bb,function(bd,be){aW(be)})}}catch(bc){}try{aJ=window.localStorage[w].split(";")}catch(bc){}}}function aW(bb){if(X){var bc=tinycolor(bb).toRgbString();if(!a6[bc]&&e.inArray(bc,aJ)===-1){aJ.push(bc);while(aJ.length>aI){aJ.shift()}}if(w&&window.localStorage){try{window.localStorage[w]=aJ.join(";")}catch(bd){}}}}function aY(){var bd=[];if(a8.showPalette){for(var bc=0;bc<aJ.length;bc++){var bb=tinycolor(aJ[bc]).toRgbString();if(!a6[bb]){bd.push(aJ[bc])}}}return bd.reverse().slice(0,a8.maxSelectionSize)}function a1(){var bb=aU();var bc=e.map(am,function(bd,be){return s(bd,bb,"sp-palette-row sp-palette-row-"+be,a8)});aS();if(aJ){bc.push(s(aY(),bb,"sp-palette-row sp-palette-row-selection",a8))}R.html(bc.join(""))}function au(){if(a8.showInitial){var bb=aQ;var bc=aU();a7.html(s([bb,bc],bc,"sp-palette-row-initial",a8))}}function A(){if(ag<=0||aN<=0||aA<=0){ae()}aq=true;aP.addClass(x);G=null;D.trigger("dragstart.spectrum",[aU()])}function ba(){aq=false;aP.removeClass(x);D.trigger("dragstop.spectrum",[aU()])}function aT(){var bc=K.val();if((bc===null||bc==="")&&a5){ad(null);ap(true)}else{var bb=tinycolor(bc);if(bb.isValid()){ad(bb);ap(true)}else{K.addClass("sp-validation-error")}}}function ay(){if(P){aH()}else{z()}}function z(){var bb=e.Event("beforeShow.spectrum");if(P){ae();return}D.trigger(bb,[aU()]);if(S.beforeShow(aU())===false||bb.isDefaultPrevented()){return}o();P=true;e(Y).bind("keydown.spectrum",ak);e(Y).bind("click.spectrum",ac);e(window).bind("resize.spectrum",E);aV.addClass("sp-active");aP.removeClass("sp-hidden");ae();aE();aQ=aU();au();S.show(aQ);D.trigger("show.spectrum",[aQ])}function ak(bb){if(bb.keyCode===27){aH()}}function ac(bb){if(bb.button==2){return}if(aq){return}if(F){ap(true)}else{aw()}aH()}function aH(){if(!P||a4){return}P=false;e(Y).unbind("keydown.spectrum",ak);e(Y).unbind("click.spectrum",ac);e(window).unbind("resize.spectrum",E);aV.removeClass("sp-active");aP.addClass("sp-hidden");S.hide(aU());D.trigger("hide.spectrum",[aU()])}function aw(){ad(aQ,true)}function ad(bb,bd){if(tinycolor.equals(bb,aU())){aE();return}var bc,be;if(!bb&&a5){C=true}else{C=false;bc=tinycolor(bb);be=bc.toHsv();Z=(be.h%360)/360;Q=be.s;aD=be.v;a0=be.a}aE();if(bc&&bc.isValid()&&!bd){av=W||bc.getFormat()}}function aU(bb){bb=bb||{};if(a5&&C){return null}return tinycolor.fromRatio({h:Z,s:Q,v:aD,a:Math.round(a0*100)/100},{format:bb.format||av})}function aB(){return !K.hasClass("sp-validation-error")}function aL(){aE();S.move(aU());D.trigger("move.spectrum",[aU()])}function aE(){K.removeClass("sp-validation-error");a2();var bd=tinycolor.fromRatio({h:Z,s:1,v:1});I.css("background-color",bd.toHexString());var bi=av;if(a0<1&&!(a0===0&&bi==="name")){if(bi==="hex"||bi==="hex3"||bi==="hex6"||bi==="name"){bi="rgb"}}var bb=aU({format:bi}),be="";J.removeClass("sp-clear-display");J.css("background-color","transparent");if(!bb&&a5){J.addClass("sp-clear-display")}else{var bf=bb.toHexString(),bj=bb.toRgbString();if(l||bb.alpha===1){J.css("background-color",bj)}else{J.css("background-color","transparent");J.css("filter",bb.toFilter())}if(a8.showAlpha){var bg=bb.toRgb();bg.a=0;var bc=tinycolor(bg).toRgbString();var bh="linear-gradient(left, "+bc+", "+bf+")";if(h){aF.css("filter",tinycolor(bc).toFilter({gradientType:1},bf))}else{aF.css("background","-webkit-"+bh);aF.css("background","-moz-"+bh);aF.css("background","-ms-"+bh);aF.css("background","linear-gradient(to right, "+bc+", "+bf+")")}}be=bb.toString(bi)}if(a8.showInput){K.val(be)}if(a8.showPalette){a1()}au()}function a2(){var bd=Q;var bb=aD;if(a5&&C){aG.hide();a3.hide();aM.hide()}else{aG.show();a3.show();aM.show();var bg=bd*aN;var be=ag-(bb*ag);bg=Math.max(-aO,Math.min(aN-aO,bg-aO));be=Math.max(-aO,Math.min(ag-aO,be-aO));aM.css({top:be+"px",left:bg+"px"});var bc=a0*az;aG.css({left:(bc-(aZ/2))+"px"});var bf=(Z)*aA;a3.css({top:(bf-at)+"px"})}}function ap(bc){var bb=aU(),be="",bd=!tinycolor.equals(bb,aQ);if(bb){be=bb.toString(av);aW(bb)}if(T){D.val(be)}if(bc&&bd){S.change(bb);D.trigger("change",[bb])}}function ae(){aN=I.width();ag=I.height();aO=aM.height();M=N.width();aA=N.height();at=a3.height();az=aa.width();aZ=aG.width();if(!a4){aP.css("position","absolute");if(a8.offset){aP.offset(a8.offset)}else{aP.offset(a(aP,ax))}}a2();if(a8.showPalette){a1()}D.trigger("reflow.spectrum")}function y(){D.show();ax.unbind("click.spectrum touchstart.spectrum");aP.remove();aV.remove();d[af.id]=null}function ab(bb,bc){if(bb===g){return e.extend({},a8)}if(bc===g){return a8[bb]}a8[bb]=bc;v()}function ah(){aX=false;D.attr("disabled",false);ax.removeClass("sp-disabled")}function V(){aH();aX=true;D.attr("disabled",true);ax.addClass("sp-disabled")}function an(bb){a8.offset=bb;ae()}aK();var af={show:z,hide:aH,toggle:ay,reflow:ae,option:ab,enable:ah,disable:V,offset:an,set:function(bb){ad(bb);ap()},get:aU,destroy:y,container:aP};af.id=d.push(af)-1;return af}function a(B,C){var A=0;var y=B.outerWidth();var E=B.outerHeight();var u=C.outerHeight();var D=B[0].ownerDocument;var v=D.documentElement;var z=v.clientWidth+e(D).scrollLeft();var w=v.clientHeight+e(D).scrollTop();var x=C.offset();x.top+=u;x.left-=Math.min(x.left,(x.left+y>z&&z>y)?Math.abs(x.left+y-z):0);x.top-=Math.min(x.top,((x.top+E>w&&w>E)?Math.abs(E+u-A):A));return x}function b(){}function j(u){u.stopPropagation()}function t(v,w){var x=Array.prototype.slice;var u=x.call(arguments,2);return function(){return v.apply(w,u.concat(x.call(arguments)))}}function c(z,E,v,w){E=E||function(){};v=v||function(){};w=w||function(){};var F=document;var H=false;var y={};var I=0;var G=0;var B=("ontouchstart" in window);var A={};A.selectstart=D;A.dragstart=D;A["touchmove mousemove"]=x;A["touchend mouseup"]=C;function D(J){if(J.stopPropagation){J.stopPropagation()}if(J.preventDefault){J.preventDefault()}J.returnValue=false}function x(O){if(H){if(h&&F.documentMode<9&&!O.button){return C()}var M=O.originalEvent&&O.originalEvent.touches&&O.originalEvent.touches[0];var K=M&&M.pageX||O.pageX;var J=M&&M.pageY||O.pageY;var P=Math.max(0,Math.min(K-y.left,G));var N=Math.max(0,Math.min(J-y.top,I));if(B){D(O)}E.apply(z,[P,N,O])}}function u(K){var J=(K.which)?(K.which==3):(K.button==2);if(!J&&!H){if(v.apply(z,arguments)!==false){H=true;I=e(z).height();G=e(z).width();y=e(z).offset();e(F).bind(A);e(F.body).addClass("sp-dragging");x(K);D(K)}}}function C(){if(H){e(F).unbind(A);e(F.body).removeClass("sp-dragging");setTimeout(function(){w.apply(z,arguments)},0)}H=false}e(z).bind("touchstart mousedown",u)}function f(v,x,u){var w;return function(){var z=this,y=arguments;var A=function(){w=null;v.apply(z,y)};if(u){clearTimeout(w)}if(u||!w){w=setTimeout(A,x)}}}function k(){return e.fn.spectrum.inputTypeColorSupport()}var i="spectrum.id";e.fn.spectrum=function(x,u){if(typeof x=="string"){var w=this;var v=Array.prototype.slice.call(arguments,1);this.each(function(){var y=d[e(this).data(i)];if(y){var z=y[x];if(!z){throw new Error("Spectrum: no such method: '"+x+"'")}if(x=="get"){w=y.get()}else{if(x=="container"){w=y.container}else{if(x=="option"){w=y.option.apply(y,v)}else{if(x=="destroy"){y.destroy();e(this).removeData(i)}else{z.apply(y,v)}}}}}});return w}return this.spectrum("destroy").each(function(){var y=e.extend({},x,e(this).data());var z=r(this,y);e(this).data(i,z.id)})};e.fn.spectrum.load=true;e.fn.spectrum.loadOpts={};e.fn.spectrum.draggable=c;e.fn.spectrum.defaults=m;e.fn.spectrum.inputTypeColorSupport=function k(){if(typeof k._cachedResult==="undefined"){var u=e("<input type='color' value='!' />")[0];k._cachedResult=u.type==="color"&&u.value!=="!"}return k._cachedResult};e.spectrum={};e.spectrum.localization={};e.spectrum.palettes={};e.fn.spectrum.processNativeColorInputs=function(){var u=e("input[type=color]");if(u.length&&!k()){u.spectrum({preferredFormat:"hex6"})}};(function(){var Z=/^[\s,#]+/,K=/\s+$/,ae=0,Q=Math,U=Q.round,al=Q.min,N=Q.max,D=Q.random;var ag=function(ao,aq){ao=(ao)?ao:"";aq=aq||{};if(ao instanceof ag){return ao}if(!(this instanceof ag)){return new ag(ao,aq)}var ap=ad(ao);this._originalInput=ao,this._r=ap.r,this._g=ap.g,this._b=ap.b,this._a=ap.a,this._roundA=U(100*this._a)/100,this._format=aq.format||ap.format;this._gradientType=aq.gradientType;if(this._r<1){this._r=U(this._r)}if(this._g<1){this._g=U(this._g)}if(this._b<1){this._b=U(this._b)}this._ok=ap.ok;this._tc_id=ae++};ag.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return !this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var ao=this.toRgb();return(ao.r*299+ao.g*587+ao.b*114)/1000},setAlpha:function(ao){this._a=E(ao);this._roundA=U(100*this._a)/100;return this},toHsv:function(){var ao=B(this._r,this._g,this._b);return{h:ao.h*360,s:ao.s,v:ao.v,a:this._a}},toHsvString:function(){var ap=B(this._r,this._g,this._b);var ar=U(ap.h*360),aq=U(ap.s*100),ao=U(ap.v*100);return(this._a==1)?"hsv("+ar+", "+aq+"%, "+ao+"%)":"hsva("+ar+", "+aq+"%, "+ao+"%, "+this._roundA+")"},toHsl:function(){var ao=G(this._r,this._g,this._b);return{h:ao.h*360,s:ao.s,l:ao.l,a:this._a}},toHslString:function(){var ap=G(this._r,this._g,this._b);var ar=U(ap.h*360),aq=U(ap.s*100),ao=U(ap.l*100);return(this._a==1)?"hsl("+ar+", "+aq+"%, "+ao+"%)":"hsla("+ar+", "+aq+"%, "+ao+"%, "+this._roundA+")"},toHex:function(ao){return ac(this._r,this._g,this._b,ao)},toHexString:function(ao){return"#"+this.toHex(ao)},toHex8:function(){return am(this._r,this._g,this._b,this._a)},toHex8String:function(){return"#"+this.toHex8()},toRgb:function(){return{r:U(this._r),g:U(this._g),b:U(this._b),a:this._a}},toRgbString:function(){return(this._a==1)?"rgb("+U(this._r)+", "+U(this._g)+", "+U(this._b)+")":"rgba("+U(this._r)+", "+U(this._g)+", "+U(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:U(ah(this._r,255)*100)+"%",g:U(ah(this._g,255)*100)+"%",b:U(ah(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return(this._a==1)?"rgb("+U(ah(this._r,255)*100)+"%, "+U(ah(this._g,255)*100)+"%, "+U(ah(this._b,255)*100)+"%)":"rgba("+U(ah(this._r,255)*100)+"%, "+U(ah(this._g,255)*100)+"%, "+U(ah(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){if(this._a===0){return"transparent"}if(this._a<1){return false}return an[ac(this._r,this._g,this._b,true)]||false},toFilter:function(ar){var at="#"+am(this._r,this._g,this._b,this._a);var ap=at;var ao=this._gradientType?"GradientType = 1, ":"";if(ar){var aq=ag(ar);ap=aq.toHex8String()}return"progid:DXImageTransform.Microsoft.gradient("+ao+"startColorstr="+at+",endColorstr="+ap+")"},toString:function(ar){var ao=!!ar;ar=ar||this._format;var aq=false;var ap=this._a<1&&this._a>=0;var at=!ao&&ap&&(ar==="hex"||ar==="hex6"||ar==="hex3"||ar==="name");if(at){if(ar==="name"&&this._a===0){return this.toName()}return this.toRgbString()}if(ar==="rgb"){aq=this.toRgbString()}if(ar==="prgb"){aq=this.toPercentageRgbString()}if(ar==="hex"||ar==="hex6"){aq=this.toHexString()}if(ar==="hex3"){aq=this.toHexString(true)}if(ar==="hex8"){aq=this.toHex8String()}if(ar==="name"){aq=this.toName()}if(ar==="hsl"){aq=this.toHslString()}if(ar==="hsv"){aq=this.toHsvString()}return aq||this.toHexString()},_applyModification:function(aq,ap){var ao=aq.apply(null,[this].concat([].slice.call(ap)));this._r=ao._r;this._g=ao._g;this._b=ao._b;this.setAlpha(ao._a);return this},lighten:function(){return this._applyModification(J,arguments)},brighten:function(){return this._applyModification(v,arguments)},darken:function(){return this._applyModification(I,arguments)},desaturate:function(){return this._applyModification(P,arguments)},saturate:function(){return this._applyModification(aa,arguments)},greyscale:function(){return this._applyModification(y,arguments)},spin:function(){return this._applyModification(af,arguments)},_applyCombination:function(ap,ao){return ap.apply(null,[this].concat([].slice.call(ao)))},analogous:function(){return this._applyCombination(S,arguments)},complement:function(){return this._applyCombination(X,arguments)},monochromatic:function(){return this._applyCombination(M,arguments)},splitcomplement:function(){return this._applyCombination(V,arguments)},triad:function(){return this._applyCombination(z,arguments)},tetrad:function(){return this._applyCombination(ak,arguments)}};ag.fromRatio=function(ao,ar){if(typeof ao=="object"){var ap={};for(var aq in ao){if(ao.hasOwnProperty(aq)){if(aq==="a"){ap[aq]=ao[aq]}else{ap[aq]=H(ao[aq])}}}ao=ap}return ag(ao,ar)};function ad(ap){var aq={r:0,g:0,b:0};var ao=1;var ar=false;var at=false;if(typeof ap=="string"){ap=O(ap)}if(typeof ap=="object"){if(ap.hasOwnProperty("r")&&ap.hasOwnProperty("g")&&ap.hasOwnProperty("b")){aq=A(ap.r,ap.g,ap.b);ar=true;at=String(ap.r).substr(-1)==="%"?"prgb":"rgb"}else{if(ap.hasOwnProperty("h")&&ap.hasOwnProperty("s")&&ap.hasOwnProperty("v")){ap.s=H(ap.s);ap.v=H(ap.v);aq=ab(ap.h,ap.s,ap.v);ar=true;at="hsv"}else{if(ap.hasOwnProperty("h")&&ap.hasOwnProperty("s")&&ap.hasOwnProperty("l")){ap.s=H(ap.s);ap.l=H(ap.l);aq=T(ap.h,ap.s,ap.l);ar=true;at="hsl"}}}if(ap.hasOwnProperty("a")){ao=ap.a}}ao=E(ao);return{ok:ar,format:ap.format||at,r:al(255,N(aq.r,0)),g:al(255,N(aq.g,0)),b:al(255,N(aq.b,0)),a:ao}}function A(aq,ap,ao){return{r:ah(aq,255)*255,g:ah(ap,255)*255,b:ah(ao,255)*255}}function G(ao,at,av){ao=ah(ao,255);at=ah(at,255);av=ah(av,255);var aw=N(ao,at,av),aq=al(ao,at,av);var ar,ax,ap=(aw+aq)/2;if(aw==aq){ar=ax=0}else{var au=aw-aq;ax=ap>0.5?au/(2-aw-aq):au/(aw+aq);switch(aw){case ao:ar=(at-av)/au+(at<av?6:0);break;case at:ar=(av-ao)/au+2;break;case av:ar=(ao-at)/au+4;break}ar/=6}return{h:ar,s:ax,l:ap}}function T(au,ax,at){var ao,av,aw;au=ah(au,360);ax=ah(ax,100);at=ah(at,100);function ar(aA,az,ay){if(ay<0){ay+=1}if(ay>1){ay-=1}if(ay<1/6){return aA+(az-aA)*6*ay}if(ay<1/2){return az}if(ay<2/3){return aA+(az-aA)*(2/3-ay)*6}return aA}if(ax===0){ao=av=aw=at}else{var ap=at<0.5?at*(1+ax):at+ax-at*ax;var aq=2*at-ap;ao=ar(aq,ap,au+1/3);av=ar(aq,ap,au);aw=ar(aq,ap,au-1/3)}return{r:ao*255,g:av*255,b:aw*255}}function B(ao,ar,au){ao=ah(ao,255);ar=ah(ar,255);au=ah(au,255);var av=N(ao,ar,au),ap=al(ao,ar,au);var aq,ax,aw=av;var at=av-ap;ax=av===0?0:at/av;if(av==ap){aq=0}else{switch(av){case ao:aq=(ar-au)/at+(ar<au?6:0);break;case ar:aq=(au-ao)/at+2;break;case au:aq=(ao-ar)/at+4;break}aq/=6}return{h:aq,s:ax,v:aw}}function ab(at,aA,ay){at=ah(at,360)*6;aA=ah(aA,100);ay=ah(ay,100);var ar=Q.floor(at),av=at-ar,aq=ay*(1-aA),ap=ay*(1-av*aA),az=ay*(1-(1-av)*aA),ax=ar%6,ao=[ay,ap,aq,aq,az,ay][ax],au=[az,ay,ay,ap,aq,aq][ax],aw=[aq,aq,az,ay,ay,ap][ax];return{r:ao*255,g:au*255,b:aw*255}}function ac(ar,aq,ao,at){var ap=[R(U(ar).toString(16)),R(U(aq).toString(16)),R(U(ao).toString(16))];if(at&&ap[0].charAt(0)==ap[0].charAt(1)&&ap[1].charAt(0)==ap[1].charAt(1)&&ap[2].charAt(0)==ap[2].charAt(1)){return ap[0].charAt(0)+ap[1].charAt(0)+ap[2].charAt(0)}return ap.join("")}function am(at,ar,ao,ap){var aq=[R(W(ap)),R(U(at).toString(16)),R(U(ar).toString(16)),R(U(ao).toString(16))];return aq.join("")}ag.equals=function(ap,ao){if(!ap||!ao){return false}return ag(ap).toRgbString()==ag(ao).toRgbString()};ag.random=function(){return ag.fromRatio({r:D(),g:D(),b:D()})};function P(ap,aq){aq=(aq===0)?0:(aq||10);var ao=ag(ap).toHsl();ao.s-=aq/100;ao.s=u(ao.s);return ag(ao)}function aa(ap,aq){aq=(aq===0)?0:(aq||10);var ao=ag(ap).toHsl();ao.s+=aq/100;ao.s=u(ao.s);return ag(ao)}function y(ao){return ag(ao).desaturate(100)}function J(ap,aq){aq=(aq===0)?0:(aq||10);var ao=ag(ap).toHsl();ao.l+=aq/100;ao.l=u(ao.l);return ag(ao)}function v(ao,aq){aq=(aq===0)?0:(aq||10);var ap=ag(ao).toRgb();ap.r=N(0,al(255,ap.r-U(255*-(aq/100))));ap.g=N(0,al(255,ap.g-U(255*-(aq/100))));ap.b=N(0,al(255,ap.b-U(255*-(aq/100))));return ag(ap)}function I(ap,aq){aq=(aq===0)?0:(aq||10);var ao=ag(ap).toHsl();ao.l-=aq/100;ao.l=u(ao.l);return ag(ao)}function af(aq,ar){var ap=ag(aq).toHsl();var ao=(U(ap.h)+ar)%360;ap.h=ao<0?360+ao:ao;return ag(ap)}function X(ap){var ao=ag(ap).toHsl();ao.h=(ao.h+180)%360;return ag(ao)}function z(ap){var ao=ag(ap).toHsl();var aq=ao.h;return[ag(ap),ag({h:(aq+120)%360,s:ao.s,l:ao.l}),ag({h:(aq+240)%360,s:ao.s,l:ao.l})]}function ak(ap){var ao=ag(ap).toHsl();var aq=ao.h;return[ag(ap),ag({h:(aq+90)%360,s:ao.s,l:ao.l}),ag({h:(aq+180)%360,s:ao.s,l:ao.l}),ag({h:(aq+270)%360,s:ao.s,l:ao.l})]}function V(ap){var ao=ag(ap).toHsl();var aq=ao.h;return[ag(ap),ag({h:(aq+72)%360,s:ao.s,l:ao.l}),ag({h:(aq+216)%360,s:ao.s,l:ao.l})]}function S(ap,at,au){at=at||6;au=au||30;var ao=ag(ap).toHsl();var ar=360/au;var aq=[ag(ap)];for(ao.h=((ao.h-(ar*at>>1))+720)%360;--at;){ao.h=(ao.h+ar)%360;aq.push(ag(ao))}return aq}function M(aq,au){au=au||6;var at=ag(aq).toHsv();var aw=at.h,av=at.s,ap=at.v;var ar=[];var ao=1/au;while(au--){ar.push(ag({h:aw,s:av,v:ap}));ap=(ap+ao)%1}return ar}ag.mix=function(az,ay,av){av=(av===0)?0:(av||50);var at=ag(az).toRgb();var aq=ag(ay).toRgb();var ao=av/100;var ax=ao*2-1;var aw=aq.a-at.a;var au;if(ax*aw==-1){au=ax}else{au=(ax+aw)/(1+ax*aw)}au=(au+1)/2;var ar=1-au;var ap={r:aq.r*au+at.r*ar,g:aq.g*au+at.g*ar,b:aq.b*au+at.b*ar,a:aq.a*ao+at.a*(1-ao)};return ag(ap)};ag.readability=function(ax,aw){var at=ag(ax);var aq=ag(aw);var ar=at.toRgb();var ap=aq.toRgb();var au=at.getBrightness();var ao=aq.getBrightness();var av=(Math.max(ar.r,ap.r)-Math.min(ar.r,ap.r)+Math.max(ar.g,ap.g)-Math.min(ar.g,ap.g)+Math.max(ar.b,ap.b)-Math.min(ar.b,ap.b));return{brightness:Math.abs(au-ao),color:av}};ag.isReadable=function(ap,ao){var aq=ag.readability(ap,ao);return aq.brightness>125&&aq.color>500};ag.mostReadable=function(aw,av){var ar=null;var ap=0;var ax=false;for(var au=0;au<av.length;au++){var aq=ag.readability(aw,av[au]);var at=aq.brightness>125&&aq.color>500;var ao=3*(aq.brightness/125)+(aq.color/500);if((at&&!ax)||(at&&ax&&ao>ap)||((!at)&&(!ax)&&ao>ap)){ax=at;ap=ao;ar=ag(av[au])}}return ar};var ai=ag.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"};var an=ag.hexNames=aj(ai);function aj(aq){var ap={};for(var ao in aq){if(aq.hasOwnProperty(ao)){ap[aq[ao]]=ao}}return ap}function E(ao){ao=parseFloat(ao);if(isNaN(ao)||ao<0||ao>1){ao=1}return ao}function ah(aq,ao){if(Y(aq)){aq="100%"}var ap=F(aq);aq=al(ao,N(0,parseFloat(aq)));if(ap){aq=parseInt(aq*ao,10)/100}if((Q.abs(aq-ao)<0.000001)){return 1}return(aq%ao)/parseFloat(ao)}function u(ao){return al(1,N(0,ao))}function w(ao){return parseInt(ao,16)}function Y(ao){return typeof ao=="string"&&ao.indexOf(".")!=-1&&parseFloat(ao)===1}function F(ao){return typeof ao==="string"&&ao.indexOf("%")!=-1}function R(ao){return ao.length==1?"0"+ao:""+ao}function H(ao){if(ao<=1){ao=(ao*100)+"%"}return ao}function W(ao){return Math.round(parseFloat(ao)*255).toString(16)}function C(ao){return(w(ao)/255)}var x=(function(){var at="[-\\+]?\\d+%?";var ar="[-\\+]?\\d*\\.\\d+%?";var ao="(?:"+ar+")|(?:"+at+")";var aq="[\\s|\\(]+("+ao+")[,|\\s]+("+ao+")[,|\\s]+("+ao+")\\s*\\)?";var ap="[\\s|\\(]+("+ao+")[,|\\s]+("+ao+")[,|\\s]+("+ao+")[,|\\s]+("+ao+")\\s*\\)?";return{rgb:new RegExp("rgb"+aq),rgba:new RegExp("rgba"+ap),hsl:new RegExp("hsl"+aq),hsla:new RegExp("hsla"+ap),hsv:new RegExp("hsv"+aq),hsva:new RegExp("hsva"+ap),hex3:/^([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex8:/^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}})();function O(ap){ap=ap.replace(Z,"").replace(K,"").toLowerCase();var ao=false;if(ai[ap]){ap=ai[ap];ao=true}else{if(ap=="transparent"){return{r:0,g:0,b:0,a:0,format:"name"}}}var aq;if((aq=x.rgb.exec(ap))){return{r:aq[1],g:aq[2],b:aq[3]}}if((aq=x.rgba.exec(ap))){return{r:aq[1],g:aq[2],b:aq[3],a:aq[4]}}if((aq=x.hsl.exec(ap))){return{h:aq[1],s:aq[2],l:aq[3]}}if((aq=x.hsla.exec(ap))){return{h:aq[1],s:aq[2],l:aq[3],a:aq[4]}}if((aq=x.hsv.exec(ap))){return{h:aq[1],s:aq[2],v:aq[3]}}if((aq=x.hsva.exec(ap))){return{h:aq[1],s:aq[2],v:aq[3],a:aq[4]}}if((aq=x.hex8.exec(ap))){return{a:C(aq[1]),r:w(aq[2]),g:w(aq[3]),b:w(aq[4]),format:ao?"name":"hex8"}}if((aq=x.hex6.exec(ap))){return{r:w(aq[1]),g:w(aq[2]),b:w(aq[3]),format:ao?"name":"hex"}}if((aq=x.hex3.exec(ap))){return{r:w(aq[1]+""+aq[1]),g:w(aq[2]+""+aq[2]),b:w(aq[3]+""+aq[3]),format:ao?"name":"hex"}}return false}window.tinycolor=ag})();e(function(){if(e.fn.spectrum.load){e.fn.spectrum.processNativeColorInputs()}})});DG.BaseGameSpec=SC.Object.extend({name:null,url:null,collections:null,dimensions:{width:0,height:0},context:null,collectionName:null,parentCollectionName:null,eventsAttributeName:null,xAttrName:null,xAttrIsNumeric:true,yAttrName:null,yAttrIsNumeric:true,init:function(){arguments.callee.base.apply(this,arguments);this.collections=[]},getCollectionSpecByName:function(b){var d=this.get("collections"),c,a=d&&d.length;for(c=0;c<a;++c){if(d[c].name===b){return d[c]}}return null}});sc_require("models/base_model");DG.Collection=DG.BaseModel.extend((function(){return{id:null,context:null,dataSet:null,_caseCompareFunc:null,getCaseCompareFunc:function(){if(this._caseCompareFunc){return this._caseCompareFunc}var a=this.getPath("dataSet.compareItemsByClientIndex");if(a){this._caseCompareFunc=function(c,b){return a(c.item,b.item)}}return this._caseCompareFunc},parent:null,children:null,attrs:null,cases:null,caseIDToIndexMap:null,caseIDToGroupedIndexMap:null,areParentChildLinksConfigured:false,caseCounts:null,caseName:null,childAttrName:null,collapseChildren:null,defaults:undefined,description:"",labels:undefined,name:"",_title:null,title:function(b,a){if(!SC.none(a)){this._title=a}return this._title||this.name}.property(),init:function(){arguments.callee.base.apply(this,arguments);this.attrs=[];this.cases=[];this.children=this.children||[];this.dataSet=this.context.dataSet;this.dataSet.registerCollection(this,this.children[0]);this.updateCaseIDToIndexMap()},destroy:function(){var b,a;this.cases.forEach(function(c){DG.Case.destroyCase(c)});while(this.attrs.length>0){DG.Attribute.destroyAttribute(this.attrs.pop())}if(this.parent){a=this.parent.children.indexOf(this);if(a>=0){this.parent.children.removeAt(a,1)}}if(this.children){this.children.forEach(function(c){if(this.parent){this.parent.children.pushObject(c)}c.parent=this.parent}.bind(this))}b=this.context;if(b.dataSet){b.dataSet.unregisterCollection(this)}b.removeCollection(this);arguments.callee.base.apply(this,arguments)},verify:function(){if(SC.empty(this.context)){DG.logWarn("Unattached collection: "+this.id)}if(typeof this.context==="number"){DG.logWarn("Unresolved reference in collection "+this.id+" to context "+this.context)}if(!SC.empty(this.parent)&&(typeof this.parent==="number")){DG.logWarn("Collection parent is a key -- collection/key: "+this.name+"/"+this.parent)}if(SC.empty(this.name)){DG.logWarn("Collection with no name: "+this.id)}},isAncestorOf:function(a){return a.isDescendantOf(this)},isDescendantOf:function(a){var b=this.get("parent");if(!b){return false}if(b===a){return true}return b.isDescendantOf(a)},createAttribute:function(b){var a,c;b=b||{};b.collection=this;c=DG.store.find(DG.Attribute,b.guid);if(c){a=c}else{a=DG.Attribute.createAttribute(b)}this.attrs.pushObject(a);if(!this.dataSet.hasAttribute(a)){this.dataSet.addAttributes([a])}return a},addAttribute:function(b,a){b.set("collection",this);if(SC.none(a)){this.attrs.pushObject(b)}else{this.attrs.insertAt(a,b)}},getAttributeByName:function(c){var b=this.get("attrs"),d,e=b&&b.get("length");for(d=0;d<e;++d){var a=b.objectAt(d);if(a&&(a.get("name")===c)){return a}}return null},createCase:function(m){function f(n){if(SC.none(n)){return[]}else{return f(n.get("parent")).concat(n.getAttributeIDs())}}function b(o,n){var p=f(e.get("parent"));p.forEach(function(q){o[q]=n.values[q]});return o}m=m||{};var l=m.item;var d;var e=this;var c=this.get("dataSet");var k=DG.DataUtilities.canonicalizeAttributeValues(this.attrs,m.values);var j=m.parent;var i;var g;var h;var a=m.itemID;m.collection=this;delete m.values;if(!l){if(SC.none(j)){l=c.addDataItem(DG.DataItem.create({id:a,values:k}))}else{i=DG.store.resolve(j);g=i.item.id;h=i.get("children")&&i.get("children").length>0;if(h&&SC.none(a)){l=c.addDataItem(b(k,i.item))}else{if(a&&a!==g){l=c.addDataItem(DG.DataItem.create({id:a,values:b(k,i.item)}))}else{l=i.get("item");l.updateData(k)}}}m.item=l}d=DG.Case.createCase(m);this.addCase(d);return d},lastCase:function(){return this.cases[this.cases.length-1]},addCase:function(b){function e(j,l,m){if(SC.none(j)||SC.none(m)||SC.none(m.parent)){return true}DG.assert(!SC.none(l),"parentCollection should exist");var i=l.caseIDToIndexMap[j];var k=l.caseIDToIndexMap[m.parent.id];return(k<=i)}function d(k,i){var o=h.parent;DG.assert(!SC.none(o),"parentCollection does not exist");var j=o.caseIDToIndexMap[k];DG.assert(!SC.none(j),"parentCaseIndex does not exist");var n=o.cases[j];var l;var m=-1;DG.assert(!SC.none(n),"parentCase does not exist");if(n.children.length>1){l=n.children[n.children.length-2];m=h.caseIDToIndexMap[l.id]}else{h.cases.some(function(q,p){if(o.caseIDToIndexMap[q.parent.id]<=j){m=p;return false}else{return true}})}DG.assert(!SC.none(m),"parent's last child not in index map.");h.cases.insertAt(m+1,i);h.updateCaseIDToIndexMap()}var a=b.get("id"),g=b.getPath("parent.id"),f=this.get("caseIDToIndexMap"),c=this.get("caseCounts"),h=this;if(SC.none(c[g])){c[g]=0}if(e(g,this.parent,this.lastCase())){if(!this.caseIDToIndexMap[a]||!b.isEmpty()||!g){this.caseIDToGroupedIndexMap[a]=c[g]++}f[a]=this.cases.length;this.cases.pushObject(b);this.notifyPropertyChange("caseIDToIndexMap")}else{d(g,b)}},moveCase:function(b,a,d){var c=this.cases.indexOf(b);if(c>=0&&c!==a){this.cases.removeAt(c);this.cases.insertAt(a,b)}if(!d){this.updateCaseIDToIndexMap()}},deleteCase:function(b,a){var c=b.item;DG.Case.destroyCase(b);if(!a){this.dataSet.deleteDataItem(c)}},setAsideCase:function(a){var b=a.item;DG.Case.destroyCase(a);this.dataSet.deleteDataItem(b,true)},restoreSetAsideCases:function(){var a=this.dataSet.restoreSetAsideItems();var b=a.length;if(b>0){this.updateCaseIDToIndexMap()}DG.log("Restored "+b+' cases in collection "'+this.get("name")+'"')},recreateCases:function(c,f){var g=this.get("id"),a=[];function b(i,k,l){var j;i.some(function(m){j=DG.Case.findCase(g,m.get("id"));return !!j});if(!j){j=DG.Case.createCase({parent:k,collection:l,item:i[0]});l.addCase(j);a.push(j)}else{if(k){j.parent=k;k.children.pushObject(j)}else{j.parent=null}j.children=[]}return j}var e=this.children[0];var h={};var d=[];if(SC.none(c)){c=this.dataSet.getDataItems().filter(function(i){return !i.deleted})}d=this.attrs.filter(function(i){return SC.empty(i.formula)});if(SC.none(e)){c.forEach(function(i){var j=b([i],f,this);j._deletable=false}.bind(this))}else{c.forEach(function(j){if(!j.deleted){var i=d.map(function(l){var n=j.values[l.id];var o;if(typeof n==="object"){try{o=JSON.stringify(n)}catch(m){console.warn("In collection "+g+", item "+j.id+", Attribute value is non-serializable object");o="object"}}else{o=n}return o}).join();var k=h[i]||[];if(k.length===0){h[i]=k}k.push(j)}}.bind(this));DG.ObjectMap.forEach(h,function(j,k){var i;var l=b(k,f,this);l.children=[];l._deletable=false;i=e.recreateCases(k,l);a=a.concat(i)}.bind(this))}return a},reorderCases:function(f,a,e,c){var b=this.children[0],d=this.getCaseCompareFunc();if(SC.none(a[f])){a[f]=0}if(SC.none(e)){this.cases.sort(d);if(!SC.none(b)){this.cases.forEach(function(h){var g=h.children;b.reorderCases(f+1,a,g,h)})}}else{e.sort(d);e.forEach(function(g){this.cases[a[f]++]=g;if(g.children&&g.children.length>0){b.reorderCases(f+1,a,g.children,g)}}.bind(this))}},removeAttribute:function(a){var b;for(b=0;b<this.attrs.length;b+=1){if(this.attrs[b].id===a.id){break}}this.attrs.removeAt(b,1);a.set("collection",null);return a},getAttributeIDs:function(){return this.attrs.getEach("id")},getAttributeByID:function(a){return this.attrs.find(function(b){return b.get("id")===a})},getAttributeNames:function(){return this.attrs.getEach("name")},numberOfVisibleAttributes:function(){return this.attrs.reduce(function(b,a){if(!a.get("hidden")){b++}return b},0)},getCaseIDs:function(){return this.cases.getEach("id")},updateCaseIDToIndexMap:function(){var b={},c={},a={};this.cases.forEach(function(f,e){if(!f.get("isDestroyed")){var d=f.get("id"),g=f.getPath("parent.id");if(SC.none(b[g])){b[g]=0}if(!f.isEmpty()||!g){a[d]=b[g]++}c[d]=e}});this.set("caseIDToIndexMap",c);this.set("caseIDToGroupedIndexMap",a);this.set("caseCounts",b)},getCaseIndexByID:function(b){var a=this.get("caseIDToIndexMap");return a&&a[b]},debugLog:function(a){DG.log((a||"")+" Collection "+this.get("id")+", Attrs: ["+this.getAttributeIDs()+"], Cases: ["+this.getCaseIDs()+"]")},toArchive:function(a){var c,b;if(this.parent){if(typeof this.parent==="number"){c=this.parent}else{c=this.parent.id}}b={areParentChildLinksConfigured:this.areParentChildLinksConfigured,attrs:[],cases:[],caseName:this.get("caseName"),childAttrName:this.get("childAttrName"),collapseChildren:this.get("collapseChildren"),defaults:this.get("defaults"),guid:this.get("id"),id:this.get("id"),labels:this.labels,name:this.get("name"),parent:c,title:this.get("title"),type:"DG.Collection"};this.attrs.forEach(function(d){b.attrs.push(d.toArchive())});if(!a){this.cases.forEach(function(d){b.cases.push(d.toArchive())})}return b}}}()));DG.Collection.createCollection=function(e){if(!(e&&e.context)){return}var f=e.context;var b=SC.none(e.parent)?null:DG.store.resolve(e.parent);var a=DG.ObjectMap.values(f.collections).find(function(g){return SC.none(g.parent)});var d;var c=null;if(SC.none(e.type)){e.type="DG.Collection"}if(e.children){c=e.children[0]}e.parent=b;d=DG.Collection.create(e);if(c){if(c.get("parent")){c.get("parent").children[0]=d;d.set("parent",c.get("parent"))}d.children[0]=c;c.set("parent",d)}else{if(b){if(b.children[0]){b.children[0].set("parent",d);d.children[0]=b.children[0]}b.children[0]=d}else{if(a){d.children[0]=a;a.set("parent",d)}}}f.addCollection(d);if(!SC.none(e.areParentChildLinksConfigured)){d.set("areParentChildLinksConfigured",e.areParentChildLinksConfigured)}if(e.attrs){e.attrs.forEach(function(g){g.collection=d;d.createAttribute(g)})}if(e.cases){e.cases.forEach(function(g){g.collection=d;d.createCase(g)})}DG.log("Create collection: "+[d.name,d.description].join());return d};DG.Collection.destroyCollection=function(a){a.destroy()};DG.Command=SC.Object.extend((function(){return{name:null,undoString:null,redoString:null,isUndoable:true,causedChange:true,changedObject:null,execute:function(){},undo:function(){},redo:function(){this.execute()},log:"unknown action",reduce:null}})());sc_require("models/model_store");sc_require("models/base_model");DG.DataContextRecord=DG.BaseModel.extend({type:"DG.DataContext",document:null,name:null,_title:null,title:function(a,b){if(b){this._title=b}return this._title||this.get("defaultTitle")||this.name}.property("_title","name"),description:"",metadata:null,preventReorg:false,collections:null,collectionsChangeCount:0,defaultTitle:function(){var a="";DG.ObjectMap.forEach(this.collections,function(b){if(!SC.empty(a)){a+="/"}a+=this.collections[b].get("name")}.bind(this));return a}.property(),dependencyMgr:null,dataSet:null,flexibleGroupingChangeFlag:false,contextStorage:null,_savedShadowCopy:null,init:function(){this.collections={};this.dependencyMgr=DG.DependencyMgr.create({dataContext:this});this.dataSet=DG.DataSet.create({dataContextRecord:this});arguments.callee.base.apply(this,arguments)},verify:function(){if(SC.empty(this.document)){DG.logWarn("Unattached data context: "+this.id)}if(typeof this.document==="number"){DG.logWarn("Unresolved reference to document id, "+this.document+", in data context: "+this.id)}},destroy:function(){if(this.collections){DG.ObjectMap.forEach(this.collections,function(b,a){DG.Collection.destroyCollection(a)})}delete this.document.contexts[this.id];arguments.callee.base.apply(this,arguments)},createCollection:function(a){a=a||{};a.context=this;return DG.Collection.createCollection(a)},addCollection:function(a){this.collections[a.id]=a;this.incrementProperty("collectionsChangeCount",1)},removeCollection:function(a){delete this.collections[a.id];this.incrementProperty("collectionsChangeCount",1)},toArchive:function(b,d){function c(f){return !(SC.none(f.attrs)||(f.attrs.length===0))}var e;var a;b=true;if(b){e={type:this.type,document:this.document&&this.document.id||undefined,guid:this.id,id:this.id,flexibleGroupingChangeFlag:this.flexibleGroupingChangeFlag,name:this.get("name"),title:this.get("title"),collections:[],description:this.description,metadata:this.metadata,preventReorg:this.preventReorg,setAsideItems:this.get("dataSet").archiveSetAsideItems(),contextStorage:this.contextStorage};DG.ObjectMap.values(this.collections).some(function(f){if(SC.none(f.parent)&&c(f)){a=f;return true}return false});if(a&&a.children){while(a.children.length>0){e.collections.push(a.toArchive(d));a=a.children[0]}}if(!SC.none(a)){e.collections.push(a.toArchive(d))}}return e},savedShadowCopy:function(){return this._savedShadowCopy},updateSavedShadowCopy:function(a){this._savedShadowCopy=a}});DG.DataContextRecord.createContext=function(e){function d(){var h=DG.currDocumentController();var f=1;var g="DG.DataContext.baseName".loc(f);while(h.getContextByName(g)){g="DG.DataContext.baseName".loc(++f)}return g}var c,a={};if(SC.none(e)){e={}}if(SC.none(e.type)){e.type="DG.DataContext"}if(!e.document){e.document=DG.currDocumentController().content}e.document=DG.store.resolve(e.document);c=DG.DataContextRecord.create(e);c.updateSavedShadowCopy(a);if(e.document){e.document.contexts[c.get("id")]=c}if(SC.empty(c.name)){c.name=d()}if(e.collections){e.collections.forEach(function(f){f.context=c;DG.Collection.createCollection(f)})}if(e.setAsideItems){var b=c.get("dataSet");b.createSetAsideItems(e.setAsideItems)}DG.log("Create context: '%@'",c.name);return c};DG.DataContextRecord.destroyContext=function(a){a.destroy()};DG.DataItem=SC.Object.extend({id:null,itemIndex:null,_clientIndex:null,deleted:false,setAside:false,values:null,setValue:function(a,b){this.values[a]=DG.DataUtilities.canonicalizeInputValue(b)},getValue:function(c,d){var a=DG.Attribute.getAttributeByID(c);var b;if(a.hasFormula()){b=DG.Case.findCase(d||a.collection.id,this.id);return(b&&b.getRawValue(c))}else{return this.values[c]}},updateData:function(a){this.values=this.values||{};$.extend(this.values,a)},toArchive:function(){var a={};Object.keys(this.values).map(function(c){var b=DG.Attribute.getAttributeByID(c);if(b){a[b.name]=this.getValue(c)}}.bind(this));return{id:this.id,values:a}}});sc_require("models/data_item");DG.DataSet=SC.Object.extend((function(){return{dataItems:null,attrs:null,collectionOrder:null,init:function(){this.dataItems=[];this.attrs=[];this.collectionOrder=[];this._clientToItemIndexMap=[]},baseCollection:function(){var a=this.get("collectionOrder");return a[a.length-1]}.property("collectionOrder[]").cacheable(),registerCollection:function(c,b){if(b){var a=this.collectionOrder.indexOf(b);if(a>=0){this.collectionOrder.insertAt(a,c)}else{DG.logWarn("Inserting group, cannot find followerGroup");this.collectionOrder.push(c)}}else{this.collectionOrder.push(c)}},unregisterCollection:function(b){var a=this.collectionOrder.indexOf(b);if(a>=0){this.collectionOrder.splice(a,1)}},addAttributes:function(b){var a=Array.isArray(b)?b:[b];a.forEach(function(c){if(c.constructor===DG.Attribute){if(!this.attrs.contains(c)){this.attrs.push(c)}else{DG.logWarn("Duplicate add of attribute.")}}else{DG.logWarn("Attempt to add non-attribute to Data Set for Context: "+this.dataContextRecord.id)}}.bind(this))},hasAttribute:function(a){return this.attrs.contains(a)},deleteAttribute:function(a){var b=this.attrs.findIndex(function(c){return c===a});if(b>=0){this.attrs.splice(b,1)}},addDataItem:function(e,d){var b;var a;e=e||{};if(e.constructor===DG.DataItem){b=e;if(!b.id){b.id=DG.DataUtilities.createUniqueID()}}else{if(typeof e==="object"){if(e.values&&typeof e.values==="object"){e.dataSet=this;if(!e.id){e.id=DG.DataUtilities.createUniqueID()}e.values=DG.DataUtilities.canonicalizeAttributeValues(this.attrs,e.values);b=DG.DataItem.create(e)}else{b=DG.DataItem.create({id:DG.DataUtilities.createUniqueID(),dataSet:this,values:DG.DataUtilities.canonicalizeAttributeValues(this.attrs,e)})}}}if(b){a=this.dataItems.push(b)-1;b.itemIndex=a;if(d==null){b._clientIndex=this._clientToItemIndexMap.push(a)-1}else{var c=this.getDataItemClientIndexByID(d);b._clientIndex=c;this._clientToItemIndexMap.forEach(function(f){var g=this.dataItems[f];if(g._clientIndex>=c){++g._clientIndex}}.bind(this));this._clientToItemIndexMap.splice(c,0,a)}}return b},updateItem:function(c,a){var d=DG.DataUtilities.canonicalizeAttributeValues(this.get("attrs"),a);var b=this.getDataItemByID(c);b.updateData(d);return b},sortItems:function(d,c,b){var e=function(l,k){var j=this.dataItems[l],h=this.dataItems[k],i=c(j.id,d),g=c(h.id,d),f=b(i,g);return f||(j._clientIndex-h._clientIndex)}.bind(this);var a=this._clientToItemIndexMap.slice().sort(e);return this.setClientIndexMap(a)},getClientIndexMapCopy:function(){return this._clientToItemIndexMap.slice()},setClientIndexMap:function(a){var b=this._clientToItemIndexMap;a.forEach(function(c,d){this.dataItems[c]._clientIndex=d}.bind(this));this._clientToItemIndexMap=a;return b},deleteDataItem:function(b,a){if(b){b.deleted=true;b.setAside=a}return b},deleteDataItemByIndex:function(c,a){var b=this._clientToItemIndexMap[c],d=this.getDataItem(b);return d?this.deleteDataItem(d,a):null},undeleteDataItem:function(b){var a=this._clientToItemIndexMap[b],c;if(a>=0&&a<this.dataItems.length){c=this.dataItems[a];c.deleted=false}return c},restoreSetAsideItems:function(){var a=[];this.dataItems.forEach(function(b){if(b.setAside){a.push(b);b.deleted=false;b.setAside=false}});return a},getSetAsideCount:function(){var a=0;this.dataItems.forEach(function(b){if(b.setAside){a++}});return a},cleanDeletedDataItems:function(){this.dataItems.forEach(function(b,a){if(b.deleted){delete this.dataItems[a]}}.bind(this))},value:function(d,c,f){var b=this._clientToItemIndexMap[d],e,a;if(b>=0&&b<this.dataItems.length){e=this.dataItems[b];if(e&&!e.deleted){if(f){e.values[c]=f}a=e.values[c]}}return a},getDataItemCount:function(){return this.getDataItems().length},getDataItems:function(){return this._clientToItemIndexMap.map(function(a){return this.dataItems[a]}.bind(this)).filter(function(a){return !a.deleted})},getDataItem:function(b){var a=this._clientToItemIndexMap[b],c;if(a>=0&&a<this.dataItems.length){c=this.dataItems[a];if(!c.deleted){return c}}},getDataItemByID:function(a){return this.dataItems.find(function(b){return b.id===a})},parseSearchQuery:function(f){if(f==="*"){return{valid:true,op:"*"}}var e=f.match(/([^=!<>]+)(==|!=|<=|<|>=|>)([^=!<>]+)/),b=function(g){return g.replace(/^\s+|\s+$/,"")},c={valid:!!e,left:e&&b(e[1]),op:e&&e[2],right:e&&b(e[3])},d=this.attrs,a=function(h){var i=Number(h),g=h==="true"?true:(h==="false"?false:(isNaN(i)?h:i));return{value:g,attr:d.find(function(j){return j.name===h}),name:h}};c.left=a(c.left);c.right=a(c.right);c.valid=!!(c.valid&&(c.left.attr||c.right.attr));return c},testItemAgainstQuery:function(d,c){var b=function(f){return f.attr?d.getValue(f.attr.id):f.value},e=c.left&&b(c.left),a=c.right&&b(c.right);if(!c.valid){return false}switch(c.op){case"*":return true;case"==":return e==a;case"!=":return e!=a;case"<":return e<a;case"<=":return e<=a;case">=":return e>=a;case">":return e>a;default:return false}},getItemsBySearch:function(b){var a=this.parseSearchQuery(b);if(!a.valid){return null}return this.dataItems.filter(function(c){return(!c.deleted)&&this.testItemAgainstQuery(c,a)}.bind(this))},getDataItemClientIndexByID:function(a){return this._clientToItemIndexMap.findIndex(function(b){var c=this.dataItems[b];return c&&(c.id===a)}.bind(this))},moveDataItemByID:function(d,a){var c=this.getDataItemClientIndexByID(d);var b=this._clientToItemIndexMap[c];if((c!=null)&&(a!=null)){var e=this._clientToItemIndexMap.slice();e.splice(c,1);switch(a){case"first":e.unshift(b);break;case"last":e.push(b);break;default:e.splice(a,0,b);break}this.setClientIndexMap(e)}},compareItemsByClientIndex:function(b,a){return b._clientIndex-a._clientIndex},createSetAsideItems:function(a){a.forEach(function(b){var c=this.addDataItem(b);this.deleteDataItem(c,true)}.bind(this))},archiveSetAsideItems:function(){return this.dataItems.filter(function(a){return a.setAside}).map(function(a){return{id:a.id,values:a.toArchive().values}})},toArchive:function(){return{dataItems:this.dataItems.filterProperty("deleted",false).map(function(a){return{values:a.values,id:a.id,itemIndex:a.itemIndex}})}}}})());sc_require("models/base_game_spec");DG.GameSpec=DG.BaseGameSpec.extend({childCollection:function(){var c=this.get("collections"),b=(c&&c.length)||0,a=b-1;return(a>=0)?c[a]:null}.property("collections").cacheable(),parentCollection:function(){var c=this.get("collections"),b=(c&&c.length)||0,a=b-2;return(a>=0)?c[a]:null}.property("collections").cacheable(),collectionName:function(){var b=this.get("childCollection"),a=b&&b.name;return !SC.empty(a)?a:null}.property("childCollection").cacheable(),parentCollectionName:function(){var b=this.get("parentCollection"),a=b&&b.name;return !SC.empty(a)?a:null}.property("parentCollection").cacheable(),eventsAttributeName:function(){var b=this.get("parentCollection"),a=b&&b.childAttrName;if(SC.empty(a)){var c=this.get("childCollection");a=c&&c.name}return !SC.empty(a)?a:null}.property("parentCollection","childCollection").cacheable(),getAttrType:function(b,e){var c,d=b.attrs.length;for(c=0;c<d;++c){var a=b.attrs[c];if(a&&(a.name===e)){return a.type}}return null},graphDefaults:function(){var a=this.get("childCollection");return a&&a.defaults}.property("childCollection").cacheable(),xAttrName:function(){var a=this.get("graphDefaults");return a&&a.xAttr}.property("graphDefaults").cacheable(),xAttrIsNumeric:function(){var c=this.get("childCollection"),a=this.get("xAttrName"),b=this.getAttrType(c,a);return b==="numeric"}.property("childCollection","xAttrName").cacheable(),yAttrName:function(){var a=this.get("graphDefaults");return a&&a.yAttr}.property("graphDefaults").cacheable(),yAttrIsNumeric:function(){var c=this.get("childCollection"),a=this.get("yAttrName"),b=this.getAttrType(c,a);return b==="numeric"}.property("childCollection","yAttrName").cacheable(),legendAttrName:function(){var a=this.get("graphDefaults");return a&&a.legendAttr}.property("graphDefaults").cacheable(),legendAttrIsNumeric:function(){var c=this.get("childCollection"),a=this.get("legendAttrName"),b=this.getAttrType(c,a);return b==="numeric"}.property("childCollection","legendAttrName").cacheable(),origin:function(){var a=this.get("url").match(/(.*?\/\/.*?)\//);return a?a[1]:null}.property("url").cacheable()});DG.React.ready(function(){var a=ReactDOMFactories.div,e=ReactDOMFactories.ul,j=ReactDOMFactories.li,i=ReactDOMFactories.span,c=ReactDOMFactories.i,h=ReactDOMFactories.h1,f=ReactDOMFactories.h2,b="&#x2039;",g="&#x203a;",d="&#9432;";DG.React.Components.FunctionBrowser=DG.React.createComponent({getInitialState:function(){return{style:null,categories:this.categorize(this.props.categorizedFunctionInfo),category:null,fn:null}},componentDidMount:function(){var r=ReactDOM.findDOMNode(this.props.anchor),q=r.getBoundingClientRect(),m=ReactDOM.findDOMNode(this.props.container),s=m.getBoundingClientRect(),o=q.top-s.top,p=s.bottom-q.bottom,n=300,k=6,l={position:"absolute",left:q.left};if((p<n)&&(p<o)){l.bottom=s.bottom-q.top;l.maxHeight=q.top-k}else{l.top=q.bottom;l.maxHeight=s.bottom-q.bottom-k}this.setState({style:l})},categorize:function(m){var l=[],k;k=Object.keys(m);k.sort();k.forEach(function(n){var p=Object.keys(m[n]),o=[];p.sort();p.forEach(function(v){var t=m[n][v],r=[],s,w,u,q;w=t.args?t.args.length:t.maxArgs>20?2:t.maxArgs;t.args=t.args||[];if(w){for(s=0;s<w;s++){if(s===t.args.length){t.args.push({name:"abcdefghijklmnopqrstuvwxyz"[s],type:"any"})}t.args[s].required=s<t.minArgs}}u=t.args.slice(0,t.minArgs).map(function(x){return x.name}).join(", ");if(u){r.push(u)}q=t.args.slice(t.minArgs).map(function(x){return x.name}).join(", ");if(q){r.push(q)}o.push({name:v,definition:t,argList:r.join(", ")})});l.push({name:n,functions:o})});return l},selectFunction:function(k){if(this.props.onSelect){this.props.onSelect(k.name,k.argList,k)}this.props.unmount()},renderHeader:function(l,k,m){return a({className:"react-function-browser-header clickable",onClick:m},i({dangerouslySetInnerHTML:{__html:b+" "+l}}),k)},renderCategoryList:function(l){var k=this,m=l.map(function(o){var n=function(){k.setState({category:o})};return j({className:"clickable",key:o.name,onClick:n},i({},o.name),a({dangerouslySetInnerHTML:{__html:g}}))});return e({},m)},renderFunctionList:function(l){var k=this,m=l.functions.map(function(p){var q=function(){k.setState({category:l,fn:p})},n=function(){k.selectFunction(p)},o=!!p.definition.description||!!p.definition.examples;return j({key:p.name},i({className:"clickable",onClick:n,title:p.definition.description},p.name,c({},"("+p.argList+")")),o?a({className:"clickable",onClick:q,dangerouslySetInnerHTML:{__html:d}}):null)});return a({},this.renderHeader("Categories",l.name,function(){this.setState({category:null})}.bind(this)),e({},m))},renderFunction:function(p,n){var m=this,o=n.definition.args.map(function(q,r){return j({key:"arg-"+r},c({},q.name+(q.description?": ":"")),i({},q.description||""," (",c({},q.required?"required":"optional"),")"))}),l=(n.definition.examples||[]).map(function(q,r){return j({key:"example-"+r},q)}),k=function(){m.selectFunction(n)};return a({},this.renderHeader(p.name,n.name,function(){this.setState({fn:null})}.bind(this)),a({className:"react-function-browser-function-info"},h({className:"clickable",onClick:k},n.name,c({},"("+n.argList+")")),n.definition.description?a({},n.definition.description):null,o?a({},f({},"Parameters"),e({},o)):null,l?a({},f({},"Examples"),e({},l)):null))},render:function(){var k=null;if(this.state.style){if(this.state.fn){k=this.renderFunction(this.state.category,this.state.fn)}else{if(this.state.category){k=this.renderFunctionList(this.state.category)}else{k=this.renderCategoryList(this.state.categories)}}}return a({className:"react-function-browser dg-wants-touch",style:this.state.style},k)}},[DG.React.HighOrderComponents.UnmountOnOutsideClick,DG.React.HighOrderComponents.UnmountOnEscapeKey])});DG.busyCursor=SC.Object.create({cover:null,invocations:0,show:function(b){var c=function(){this.invocations++;b();this.hide()}.bind(this);var a=DG.getPath("mainPage.mainPane"),d=this.get("cover");if(!d){d=SC.View.create({classNames:["dg-busy-cover"],isVisible:false});this.set("cover",d);a.appendChild(d)}d.set("isVisible",true);this.invokeLater(c,10);SC.run(function(){SC.Event.trigger(DG.mainPage.mainPane.$()[0],"mousemove")},this,true)},hide:function(){this.invocations--;if(this.invocations<=0){var a=this.get("cover");if(a){a.set("isVisible",false)}}}});var splashPanel;var kHeight=200,kPadding=20,kRatio=1936/649;DG.splash=SC.Object.create({isShowing:false,showSplash:function(b,a){if(b&&DG.get("componentMode")!=="yes"){if(this.get("isShowing")){DG.splash.hideSplash()}splashPanel=SC.PanelPane.create({classNames:["dg-splash"],layout:{width:0,height:0,left:-20,top:0},contentView:null,close:function(){this.timer&&this.timer.invalidate();this.destroy();DG.splash.set("isShowing",false)},timer:null,init:function(){if(a){this.timer=SC.Timer.schedule({interval:a,action:DG.splash.hideSplash,target:this})}}}).append();this.set("isShowing",true)}else{if(DG.Browser.isCompatibleBrowser()&&!this.get("isShowing")&&DG.get("componentMode")!=="yes"&&DG.get("hideSplashScreen")!=="yes"){splashPanel=SC.PanelPane.create({classNames:["dg-splash"],layout:{width:kRatio*kHeight+2*kPadding,height:kHeight+2*kPadding,centerX:0,centerY:0},contentView:SC.View.extend({childViews:"splash spinner".w(),backgroundColor:"#FFF",splash:SC.ImageView.extend({layout:{left:kPadding,right:kPadding,top:kPadding,bottom:kPadding},value:DG.get("splashURL"),click:function(){DG.splash.hideSplash()},keyDown:function(){DG.splash.hideSplash()},acceptsFirstResponder:true}),spinner:SC.ImageView.extend({init:function(){arguments.callee.base.apply(this,arguments);var c=this;window.setTimeout(function(){c.set("isVisible",YES)},2000)},layout:{centerX:0,bottom:kPadding+6,height:32,width:32},value:"../../../../static/dg/fr/cert/source/resources/images/spinner.gif",canLoadInBackground:YES,useCanvas:NO,isVisible:NO})}),acceptsKeyPane:true,close:function(){this.destroy();DG.splash.set("isShowing",false)}}).append();splashPanel.contentView&&splashPanel.contentView.becomeFirstResponder();this.set("isShowing",true)}}},hideSplash:function(){if(splashPanel){splashPanel.close()}}});DG.ToolButtonData={tableButton:{title:"DG.ToolButtonData.tableButton.title",iconClass:"moonicon-icon-table",target:"DG.appController.caseTableMenuPane",action:"showMenu",toolTip:"DG.ToolButtonData.tableButton.toolTip",localize:true,isEnabledBinding:SC.Binding.oneWay("DG.currDocumentController.ready"),classNames:["dg-table-button"]},graphButton:{title:"DG.ToolButtonData.graphButton.title",iconClass:"moonicon-icon-graph",target:"DG.mainPage",action:"addGraph",toolTip:"DG.ToolButtonData.graphButton.toolTip",localize:true,isEnabledBinding:SC.Binding.oneWay("DG.currDocumentController.ready"),classNames:["dg-graph-button"]},mapButton:{title:"DG.ToolButtonData.mapButton.title",iconClass:"moonicon-icon-map",target:"DG.mainPage",action:"addMap",toolTip:"DG.ToolButtonData.mapButton.toolTip",localize:true,isEnabledBinding:SC.Binding.oneWay("DG.currDocumentController.ready"),classNames:["dg-map-button"]},sliderButton:{title:"DG.ToolButtonData.sliderButton.title",iconClass:"moonicon-icon-slider",target:"DG.mainPage",action:"addSlider",toolTip:"DG.ToolButtonData.sliderButton.toolTip",localize:true,classNames:["dg-slider-button"]},calcButton:{title:"DG.ToolButtonData.calcButton.title",iconClass:"moonicon-icon-calc",target:"DG.mainPage",action:"toggleCalculator",toolTip:"DG.ToolButtonData.calcButton.toolTip",localize:true,classNames:["dg-calc-button"]},textButton:{title:"DG.ToolButtonData.textButton.title",iconClass:"moonicon-icon-comment",target:"DG.mainPage",action:"addText",toolTip:"DG.ToolButtonData.textButton.toolTip",localize:true,classNames:["dg-text-button"]},pluginButton:{title:"DG.ToolButtonData.pluginMenu.title",iconClass:"moonicon-icon-plug",target:"DG.appController.pluginMenuPane",action:"showMenu",toolTip:"DG.ToolButtonData.pluginMenu.toolTip",localize:true,classNames:["dg-plugin-button"]}};DG.RightButtonData={undoButton:{title:"DG.mainPage.mainPane.undoButton.title",iconClass:"moonicon-arrow-undo",localize:true,toolTip:function(){var a=this.get("nextUndoCommand");return(a?a.get("undoString"):"DG.mainPage.mainPane.undoButton.toolTip")}.property("nextUndoCommand"),target:"DG.UndoHistory",action:"undo",nextUndoCommandBinding:SC.Binding.oneWay("DG.UndoHistory.nextUndoCommand"),isEnabledBinding:SC.Binding.oneWay("DG.UndoHistory.canUndo"),isVisibleBinding:SC.Binding.oneWay("DG.UndoHistory.enabled"),flowSpacing:{right:0,top:17},classNames:["dg-undo-button"]},redoButton:{title:"DG.mainPage.mainPane.redoButton.title",iconClass:"moonicon-arrow-redo",localize:true,toolTip:function(){var a=this.get("nextRedoCommand");return(a?a.get("redoString"):"DG.mainPage.mainPane.redoButton.toolTip")}.property("nextRedoCommand"),target:"DG.UndoHistory",action:"redo",nextRedoCommandBinding:SC.Binding.oneWay("DG.UndoHistory.nextRedoCommand"),isEnabledBinding:SC.Binding.oneWay("DG.UndoHistory.canRedo"),isVisibleBinding:SC.Binding.oneWay("DG.UndoHistory.enabled"),flowSpacing:{right:20,top:17},classNames:["dg-redo-button"]},tileListButton:{title:"DG.ToolButtonData.tileListMenu.title",iconClass:"moonicon-icon-tileList",target:"DG.appController.tileMenuPane",action:"showTileList",toolTip:"DG.ToolButtonData.tileListMenu.toolTip",localize:true,classNames:["dg-tilelist-button"]},optionButton:{title:"DG.ToolButtonData.optionMenu.title",iconClass:"moonicon-icon-options",target:"DG.appController.optionMenuPane",action:"popup",toolTip:"DG.ToolButtonData.optionMenu.toolTip",localize:true,classNames:["dg-option-button"]},guideButton:{title:"DG.ToolButtonData.guideMenu.title",iconClass:"moonicon-icon-guide",target:"DG.appController.guideMenuPane",action:"popup",toolTip:"DG.ToolButtonData.guideMenu.toolTip",localize:true,isVisible:false,classNames:["dg-guide-button"]},helpButton:{title:"DG.ToolButtonData.help.title",iconClass:"moonicon-icon-help",target:"DG.appController.helpMenuPane",action:"popup",toolTip:"DG.ToolButtonData.help.toolTip",localize:true,isVisible:true,classNames:["dg-help-button"]}};DG.Theme=SC.AceTheme.create({name:"dg"});SC.Theme.addTheme(DG.Theme);SC.defaultTheme="dg";DG.AnimationMath={kAnimationBias:0.7,kAnimationGain:0.3,Bias:function(c,b){var d;if(!b){b=this.kAnimationBias}if(b<=0.000001){d=0}else{if(b>=0.999999){d=1}else{d=c/((1/b-2)*(1-c)+1)}}return d},Gain:function(c,b){var d;if(!b){b=this.kAnimationGain}if(b<=0.000001){d=0}else{if(b>=0.999999){d=1}else{d=(1/b-2)*(1-2*c);if(c<0.5){d=c/(d+1)}else{d=(d-c)/(d-1)}}}return d},DefaultAnimationTween:function(a){return this.Gain(this.Bias(a))}};DG.ArrayUtils={remove:function(a,c){var b=a.indexOf(c);if(b>=0){a.splice(b,1)}return a},indexOfMatch:function(b,d){var c,a=b.length;for(c=0;c<a;++c){if(d(b[c])){return c}}return -1},firstMatch:function(b,e){var d,a=b.length;for(d=0;d<a;++d){var c=b[d];if(e(c)){return c}}return null},numericComparator:function(a,b){var c=isNaN(a),d=isNaN(b);if(c&&d){return 0}if(c){return -1}if(d){return 1}if(a<b){return -1}if(a>b){return 1}return 0},binarySearch:function(b,g,d){if(!b||!d){return -1}var a=0,f=b.length-1,c,e;while(a<=f){c=Math.floor((a+f)/2);e=d(b[c],g);if(e<0){a=c+1}else{if(e>0){f=c-1}else{return c}}}return -1},subtract:function(a,d,b){var c=[],e={};if(!a||a.length===0){return a}if(!d||d.length===0){return(!Array.isArray(a)&&a.toArray)?a.toArray():a}a.forEach(function(f){e[b(f)]=f});d.forEach(function(f){delete e[b(f)]});a.forEach(function(f){var g=b(f);if(e[g]){c.push(e[g])}});return c},stableSort:function(b,c){if(!c){c=function(f,e){return(f<=e)?((f<e)?-1:0):1}}if(SC.browser.name!==SC.BROWSER.chrome){return b.sort(c)}function a(e){if(e.length<2){return e}var f=Math.floor(e.length/2);var h=e.slice(0,f);var g=e.slice(f,e.length);return d(a(h),a(g))}function d(k,g){var e=[];var f=k.length;var i=g.length;var h=0;var j=0;while(h<f&&j<i){if(c(k[h],g[j])<=0){e.push(k[h++])}else{e.push(g[j++])}}e=e.concat(k.slice(h));e=e.concat(g.slice(j));return e}return a(b)}};DG.CASE_VALUE_ANIMATOR_DISABLE_ANIMATION=false;DG.CaseValueAnimator=SC.Object.extend({dataContext:null,attributeIDs:null,deltas:null,cases:null,startingValues:null,isAnimating:false,startTime:null,destroy:function(){this.endAnimation();arguments.callee.base.apply(this,arguments)},changeValues:function(b){var g=this,e=this.get("dataContext"),d=[],a=[];if(!e){return}function c(i,h,k){var j;if(DG.isDate(i)){j=DG.createDate(i-k*h)}else{j=i-k*h}return j}this.attributeIDs.forEach(function(h){a.push(h)});this.cases.forEach(function(h){d.push(h)});var f={operation:"updateCases",attributeIDs:a,cases:d,values:[],dirtyDocument:false};this.cases.forEach(function(i,h){var j=g.startingValues[h];g.attributeIDs.forEach(function(l,k){if(!f.values[k]){f.values[k]=[]}f.values[k].push(c(j[k],g.deltas[k],b))})});e.applyChange(f)},animate:function(){var e=this,c=50,b=DG.PlotUtilities.kDefaultAnimationTime;function d(){e.startingValues=[];if(SC.none(e.cases)){return}e.cases.forEach(function(f){var g=[];e.attributeIDs.forEach(function(h){g.push(f.getRawValue(h))});e.startingValues.push(g)})}function a(){var f=(new Date()).valueOf(),g=(f-e.startTime)/b,h;function i(j){if(j>=1){return 1}else{return DG.AnimationMath.DefaultAnimationTween(j)}}h=i(g);if(g<1){DG.assert(!e.animationTimer.get("isPaused"));e.changeValues(h)}else{e.endAnimation()}}if(this.isAnimating){this.endAnimation()}d();this.isAnimating=true;if(DG.CASE_VALUE_ANIMATOR_DISABLE_ANIMATION){this.endAnimation();return}this.startTime=(new Date()).valueOf();if(SC.none(this.animationTimer)){this.animationTimer=SC.Timer.schedule({action:a,interval:c,repeats:YES,until:false})}this.animationTimer.set("isPaused",NO)},endAnimation:function(){if(!SC.none(this.animationTimer)){this.animationTimer.set("isPaused",YES)}if(this.get("isAnimating")){this.changeValues(1);this.set("isAnimating",false)}}});DG.closeComponent=function(c){var b;var a=DG.currDocumentController().componentControllersMap[c];if(!a){return}a.willCloseComponent();DG.UndoHistory.execute(DG.Command.create({name:"component.close",undoString:"DG.Undo.component.close",redoString:"DG.Redo.component.close",_componentId:c,_controller:function(){return DG.currDocumentController().componentControllersMap[this._componentId]},_model:null,execute:function(){a=this._controller();var e=a.get("view"),d=e.get("parentView");this.log="closeComponent: %@".fmt(e.get("title"));this._model=a.get("model");a.willSaveComponent();if(a.saveGameState){a.saveGameState(function(f){if(f&&f.success){b=f.state||f.values}SC.run(function(){d.removeComponentView(e)})})}else{d.removeComponentView(e)}DG.currDocumentController().notificationManager.sendNotification({action:"notify",resource:"component",values:{operation:"delete",type:a.getPath("model.type"),id:a.getPath("model.id"),name:a.getPath("model.name"),title:a.getPath("model.title")}})},undo:function(){DG.currDocumentController().createComponentAndView(this._model);a=this._controller();if(a.restoreGameState&&b){a.restoreGameState({gameState:b})}}}))};DG.ColorUtilities={kStartingHue:(2/3),kCatHueSpread:0.8,kCatSaturation:(2/3),kCatBrightness:1,kBrightnessDampenFactor:1,kStandardMacGammaCorrection:(1/1.8),kStandardWinGammaCorrection:(1/2.5),kBrightnessTable:[0.54,0.05,0.2,0.15,0.75,0.46],kBrightnessTableMaxK:0.75,kNoAttribCaseColor:"#A6CAF0",kMissingValueCaseColor:"#A0A0A0",kMapMissingValueCaseColor:"#ffffff01",kKellyColors:["#FF6800","#803E75","#A6BDD7","#FFB300","#C10020","#CEA262","#817066","#007D34","#00538A","#F13A13","#53377A","#FF8E00","#B32851","#F4C800","#7F180D","#93AA00","#593315","#232C16","#FF7A5C","#F6768E"],Color:function(){return{colorString:""}},rgbColor:function(){return{colorString:"",r:1,g:1,b:1}},isRGB:function(a){return a&&!SC.none(a.r)&&!SC.none(a.g)&&!SC.none(a.b)},isColorSpecString:function(b){if(!this._isColorRegex){var a="^(?:"+"DG.Utilities.colorPattern".loc()+")$";this._isColorRegex=new RegExp(a,"i")}return(typeof b==="string"&&this._isColorRegex.test(b.toLowerCase().replace(/\s/g,"")))},hsbColor:function(){return{colorString:"",h:1,s:1,b:1}},isHSB:function(a){return a&&!SC.none(a.h)&&!SC.none(a.s)&&!SC.none(a.b)},calcAttributeColorFromIndex:function(b,a){if(b===0){return DG.PlotUtilities.kDefaultPointColor}else{if(b<0||b>=a){return this.kNoAttribCaseColor}else{return this.kKellyColors[b%this.kKellyColors.length]}}},calcAttributeColor:function(c){var a=c.get("collectionClient"),b=c.get("attribute"),e=b&&b.get("categoryMap"),d=DG.ColorUtilities.getAttributeColorFromColorMap(e);if(!d){DG.assert(b!==DG.Analysis.kNullAttribute);var g=b.get("name"),f=a.getAttributeIndexByName(g),h=a.getAttributeCount();d=DG.ColorUtilities.calcAttributeColorFromIndex(f,h)}return d},calcCaseColor:function(j,c,e,f){var i=null,n=c.get("attribute"),b=n&&DG.ColorUtilities.calcAttributeColor(c);if(n===DG.Analysis.kNullAttribute){i=e||DG.ColorUtilities.kNoAttribCaseColor}else{if(SC.empty(j)){i=DG.ColorUtilities.kMissingValueCaseColor}else{var l=c.get("attributeType"),a=c.get("isNumeric"),h=n.get("categoryMap");switch(l){case DG.Analysis.EAttributeType.eCategorical:i=DG.ColorUtilities.getCategoryColorFromColorMap(h,j);break;case DG.Analysis.EAttributeType.eColor:var k=tinycolor(j);if(k.isValid()){i=k.toString()}break;case DG.Analysis.EAttributeType.eNumeric:case DG.Analysis.EAttributeType.eDateTime:if(SC.isArray(f)){var o=-1,m=f.length-1,g={min:0,max:1},d=this.getAttributeColorSpectrumEndsFromColorMap(h,b);f.forEach(function(q,p){if(p<m){if(q<=j&&j<f[p+1]){o=p}}});if(o>=0){i=this.calcGradientColor(g,d.low,d.high,(o+1)/m)}else{i=DG.ColorUtilities.kMissingValueCaseColor}}break}if(!i){i=a?DG.ColorUtilities.calcContinuousColor(c.get("minMax"),b,j):DG.ColorUtilities.calcCategoryColor(c.get("attributeStats"),b,j)}}}return i},getCategoryColorFromColorMap:function(c,b){if(c){var a=c[b]||"#000000";if(typeof a==="string"){a={colorString:a}}return a}return null},getAttributeColorFromColorMap:function(b){if(b){var a=b["attribute-color"];if(typeof a==="string"){return DG.ColorUtilities.rgbColorString_to_PlatformColor(a,true)}}return null},getStrokeColorFromColorMap:function(a){return a?a["stroke-color"]:null},getAttributeColorSpectrumEndsFromColorMap:function(e,c){var b={},a,d;if(e){a=e["low-attribute-color"]||"rgb(255,255,255)";d=e["high-attribute-color"]||e["attribute-color"]||c;if(typeof a==="string"){a=DG.ColorUtilities.rgbColorString_to_PlatformColor(a)}if(typeof d==="string"){d=DG.ColorUtilities.rgbColorString_to_PlatformColor(d)}else{if(this.isHSB(d)){d=Raphael.hsb2rgb(d.h,d.s,d.b);d.colorString=d.colorString||"rgb(%@,%@,%@)".fmt(d.r,d.g,d.b);d.r/=255;d.g/=255;d.b/=255}}b={low:a,high:d}}return b},calcContinuousColor:function(d,a,f){var g=DG.ColorUtilities.kMissingValueCaseColor,h=d.max-d.min,c=a.h,i=a.s,b=a.b,e;if(DG.isFinite(h)&&DG.isFinite(f)){e=(h>0)?((f-d.min)/h):1;i*=e;b=DG.ColorUtilities.gammaCorrect(1-((1-b)*e));g=DG.ColorUtilities.hsb_to_PlatformColor(c,i,b)}return g},calcGradientColor:function(d,a,j,e){var h=DG.ColorUtilities.kMissingValueCaseColor,i=d.max-d.min;if(DG.isFinite(i)&&DG.isFinite(e)&&this.isRGB(a)&&this.isRGB(j)){var f=Math.max(0,Math.min(1,(e-d.min)/i)),c=a.r+f*(j.r-a.r),g=a.g+f*(j.g-a.g),b=a.b+f*(j.b-a.b);h=DG.ColorUtilities.rgb_to_PlatformColor(c,g,b)}return h},calcCategoryColor:function(d,b,a){var c=d.cellNameToCellNumber(a),e=DG.ColorUtilities.kKellyColors.length;return{colorString:DG.ColorUtilities.kKellyColors[c%e]}},hsb_to_PlatformColor:function(a,b,c){return{h:a,s:b,b:c,colorString:DG.ColorUtilities.hsb_to_rgb(a,b,c)}},rgb_to_PlatformColor:function(c,b,a){return this.rgb_to_hex(c,b,a)},rgb_to_hex:function(c,b,a){function d(f){var e=(Math.round(f*255)).toString(16);return e.length===1?"0"+e:e}return"#"+d(c)+d(b)+d(a)},hsb_to_rgb:function(e,d,j){var c,g,b,a,k,h;if(d===0){h=DG.ColorUtilities.rgb_to_PlatformColor(j,j,j)}else{g=(e>=1)?0:(e*6);c=Math.floor(g);g=g-c;b=j*(1-d);a=j*(1-(d*g));k=j*(1-(d*(1-g)));switch(c){case 0:h=DG.ColorUtilities.rgb_to_PlatformColor(j,k,b);break;case 1:h=DG.ColorUtilities.rgb_to_PlatformColor(a,j,b);break;case 2:h=DG.ColorUtilities.rgb_to_PlatformColor(b,j,k);break;case 3:h=DG.ColorUtilities.rgb_to_PlatformColor(b,a,j);break;case 4:h=DG.ColorUtilities.rgb_to_PlatformColor(k,b,j);break;case 5:h=DG.ColorUtilities.rgb_to_PlatformColor(j,b,a);break}}return h},gammaCorrect:function(a){return Math.pow(a,DG.ColorUtilities.kStandardMacGammaCorrection)},dampenBrightnessByHue:function(f,g,l){var m=DG.ColorUtilities.kBrightnessTable,h=DG.ColorUtilities.kBrightnessTableMaxK,k=m.length,a=g*k,i=Math.floor(a),b=Math.ceil(a),j=(i<b)?b-a:1,e=a-i,d,c;i=i%k;b=b%k;d=m[i]*j+m[b]*e;c=1-((h-d)*l);return(f*c)},darker:function(c,a){var b=DG.color(c).darker(a).color;return b},rgbColorString_to_PlatformColor:function(e,d){var b,a=DG.ColorUtilities.colorNameToHexColor(e);if(b=/^#([\da-fA-F]{2})([\da-fA-F]{2})([\da-fA-F]{2})/.exec(a)){b=[parseInt(b[1],16),parseInt(b[2],16),parseInt(b[3],16)]}else{if(b=/^#([\da-fA-F])([\da-fA-F])([\da-fA-F])/.exec(a)){b=[parseInt(b[1],16)*17,parseInt(b[2],16)*17,parseInt(b[3],16)*17]}else{if(b=/^rgba\(([\d]+),([\d]+),([\d]+),([\d]+|[\d]*.[\d]+)\)/.exec(a)){b=[+b[1],+b[2],+b[3],+b[4]]}else{if(b=/^rgb\(([\d]+),([\d]+),([\d]+)\)/.exec(a)){b=[+b[1],+b[2],+b[3]]}else{throw new Error(a+" is not supported by parseColor")}}}}var c={r:b[0]/255,g:b[1]/255,b:b[2]/255,colorString:e};if(d){var f=Raphael.rgb2hsb(c.r,c.g,c.b);c.h=f.h;c.s=f.s;c.b=f.b}return c},colorNameToHexColor:function(b){var a="";if(b.charAt(0)==="#"){b=b.substr(1,6);a="#"}b=b.replace(/ /g,"");b=b.toLowerCase();if(DG.ColorUtilities.simpleColorNames.hasOwnProperty(b)){b=DG.ColorUtilities.simpleColorNames[b];a="#"}b=a+b;return b},simpleColorNames:{aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dodgerblue:"1e90ff",feldspar:"d19275",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgrey:"d3d3d3",lightgreen:"90ee90",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslateblue:"8470ff",lightslategray:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370d8",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"d87093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",violetred:"d02090",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"}};DG.isColorSpecString=DG.ColorUtilities.isColorSpecString;DG.DataContextUtilities={isTopLevelReorgPrevented:function(b){var a=b.get("managingController");return !!a&&a.get("preventTopLevelReorg")},getNonTopLevelAttributeCount:function(c){var b=0;var a=c.get("collections");a.forEach(function(e,d){if(d>0){b+=e.getPath("attrs.length")}});return b},isAttributeDeletable:function(g,f){if(!f.get("deleteable")){return false}var i=g.get("managingController");var b=!!i&&i.get("preventTopLevelReorg");var c=!f.getPath("collection.parent");var j=DG.DataContextUtilities.getNonTopLevelAttributeCount(g);var d=!c&&(j===1);if(b&&d){return false}var l=!!i&&i.get("preventAttributeDeletion");var h=!!i&&i.get("allowEmptyAttributeDeletion");var e=f.get("hasFormula");var k=!e&&f.get("hasValues");var a=!e&&!k;return !l||(h&&a)},isCaseEditable:function(d,b){if(!b){return true}var g=d.get("managingController");var j=g&&g.get("respectEditableItemAttribute");if(!j){return true}var c=d.getAttrRefByName("__editable__");var f=c&&c.attribute;if(!f){return true}if(!f.get("hasFormula")){var e=d.getPath("model.dataSet");var a=e&&e.getDataItemClientIndexByID(b.item.id);return !!(e&&(a!=null)&&e.value(a,f.id))}for(var h=b;h;h=h.get("parent")){if(h.getPath("collection.id")===c.collection.get("id")){var i=f.evalFormula(h);return !!i}}return true},canAcceptAttributeDrop:function(f,d,b,h){if(f.get("hasGameInteractive")||f.get("preventReorg")){return false}var g=d&&!SC.none(f.getCollectionByID(d.collection.id));if(!g){return false}var a=f.get("managingController");if(a&&a.get("preventDataContextReorg")){return false}var c=a&&a.get("preventTopLevelReorg");var e=d&&!d.getPath("collection.parent");if(c){if(e&&b&&h){return true}if(e||b){return false}}return true},updateAttribute:function(d,a,c,e){var f=e.name;if(f){f=d.getUniqueAttributeName(f,[c.name]);e.name=f}var b={id:c.get("id"),name:c.get("name"),type:c.get("type"),cid:c.get("cid"),unit:c.get("unit"),editable:c.get("editable"),precision:c.get("precision"),description:c.get("description")};DG.UndoHistory.execute(DG.Command.create({name:"caseTable.editAttribute",undoString:"DG.Undo.caseTable.editAttribute",redoString:"DG.Redo.caseTable.editAttribute",log:'Edit attribute "%@"'.fmt(e.name),execute:function(){var g={operation:"updateAttributes",collection:a,attrPropsArray:[Object.assign({id:c.get("id")},e)]};d.applyChange(g)},undo:function(){var g={operation:"updateAttributes",collection:a,attrPropsArray:[b]};d.applyChange(g)},redo:function(){this.execute()}}))},editAttributeFormula:function(e,d,h,c){h=h||"";c=c||"";var b=e.getCollectionByID(d.get("id")),f=DG.AttributeFormulaView.buildOperandsMenuAndCompletionData(e),a=SC.Object.create({applyFormula:function(){var k=e.getAttrRefByName(h),i=k&&k.attribute.get("formula");var j=g.get("collection"),l=g.get("formula");DG.UndoHistory.execute(DG.Command.create({name:"caseTable.editAttributeFormula",undoString:"DG.Undo.caseTable.editAttributeFormula",redoString:"DG.Redo.caseTable.editAttributeFormula",execute:function(){k=e.getAttrRefByName(h);var m={operation:"createAttributes",collection:j,attrPropsArray:[{name:h,formula:l}]},o=e&&e.applyChange(m);if(o.success){var n="attributeEditFormula";this.log="%@: { name: '%@', collection: '%@', formula: '%@' }".fmt(n,h,j.get("name"),l)}else{this.set("causedChange",false)}},undo:function(){var m,o,n;m={operation:"createAttributes",collection:j,attrPropsArray:[{name:h,formula:i}]};o=e&&e.applyChange(m);if(o.success){n="attributeEditFormula"}else{this.set("causedChange",false)}},redo:function(){this.execute()}}));g.close()}}),g=DG.CreateAttributeFormulaView(SC.mixin({applyTarget:a,applyAction:"applyFormula",applyTooltip:"DG.TableController.newAttrDlg.applyTooltip",attrNameHint:"DG.TableController.newAttrDlg.attrNameHint",attrNameValue:h,attrNameIsEnabled:SC.empty(h),formulaValue:c,formulaCompletions:f.completionData,formulaOperands:f.operandsMenu,formulaHint:"DG.TableController.newAttrDlg.formulaHint"},{collection:b}))},hideAttribute:function(e,c){var f=e&&e.getAttrRefByID(c),b=f.attribute.get("name"),a=f.collection,d=a.get("collection");DG.UndoHistory.execute(DG.Command.create({name:"caseTable.hideAttribute",undoString:"DG.Undo.caseTable.hideAttribute",redoString:"DG.Redo.caseTable.hideAttribute",log:'Hide attribute "%@"'.fmt(b),_beforeStorage:{changeFlag:e.get("flexibleGroupingChangeFlag"),fromCollectionID:d.get("id"),fromCollectionName:d.get("name"),fromCollectionParent:d.get("parent"),fromCollectionChild:d.get("children")[0]},_afterStorage:{},execute:function(){var g;g={operation:"hideAttributes",collection:a,attrs:[{id:c,attribute:f.attribute}]};e.applyChange(g);e.set("flexibleGroupingChangeFlag",true)},undo:function(){var g;if(e.getCollectionByID(d.get("id"))){g={operation:"unhideAttributes",attrs:[{id:c,attribute:f.attribute}]};e.applyChange(g);e.set("flexibleGroupingChangeFlag",this._beforeStorage.changeFlag);this._afterStorage.collection=a}}}))},showAllHiddenAttributes:function(c){var a=c.getHiddenAttributes().map(function(d){return{id:d.get("id"),attribute:d}}),b={attrs:a};DG.UndoHistory.execute(DG.Command.create({name:"caseTable.showAllHiddenAttributes",undoString:"DG.Undo.caseTable.showAllHiddenAttributes",redoString:"DG.Redo.caseTable.showAllHiddenAttributes",log:"Show all hidden attributes",execute:function(){if(a.length>0){b.operation="unhideAttributes";c.applyChange(b)}c.set("flexibleGroupingChangeFlag",true)},undo:function(){b.operation="hideAttributes";c.applyChange(b)}}))},deleteAttribute:function(f,c){var g=f&&f.getAttrRefByID(c),b=g.attribute.get("name"),a=g.collection,d=a.get("collection");var e=function(){DG.UndoHistory.execute(DG.Command.create({name:"caseTable.deleteAttribute",undoString:"DG.Undo.caseTable.deleteAttribute",redoString:"DG.Redo.caseTable.deleteAttribute",log:'Delete attribute "%@"'.fmt(b),_beforeStorage:{changeFlag:f.get("flexibleGroupingChangeFlag"),fromCollectionID:d.get("id"),fromCollectionName:d.get("name"),fromCollectionParent:d.get("parent"),fromCollectionChild:d.get("children")[0]},_afterStorage:{},execute:function(){var h;if((a.get("attrsController").get("length")===1)&&(f.get("collections").length!==1)&&(a.getAttributeByID(c))){h=f.applyChange({operation:"deleteCollection",collection:a});this._afterStorage.deletedItems=h&&h.deletedItems}else{f.applyChange({operation:"deleteAttributes",collection:a,attrs:[{id:c,attribute:g.attribute}]})}f.set("flexibleGroupingChangeFlag",true)},undo:function(){var h;var i;if(f.getCollectionByID(d.get("id"))){h={operation:"createAttributes",collection:g&&g.collection,attrPropsArray:[g.attribute],position:[g.position]};f.applyChange(h);f.set("flexibleGroupingChangeFlag",this._beforeStorage.changeFlag);this._afterStorage.collection=a}else{g.attribute.collection=null;h={operation:"createCollection",properties:{id:this._beforeStorage.fromCollectionID,name:this._beforeStorage.fromCollectionName,parent:this._beforeStorage.fromCollectionParent,children:this._beforeStorage.fromCollectionChild?[this._beforeStorage.fromCollectionChild]:[]},attributes:[g.attribute]};i=f.applyChange(h);this._afterStorage.collection=i.collection;if(this._afterStorage.deletedItems){this._afterStorage.deletedItems.forEach(function(j){if(!j.setAside){j.deleted=false}})}f.regenerateCollectionCases();f.set("flexibleGroupingChangeFlag",this._beforeStorage.changeFlag)}},redo:function(){var i;var h=f.getCollectionByID(this._afterStorage.collection.get("id"));if((h.get("attrsController").get("length")===1)&&(f.get("collections").length!==1)&&(h.getAttributeByID(c))){i={operation:"deleteCollection",collection:h}}else{i={operation:"deleteAttributes",collection:h,attrs:[{id:c,attribute:g.attribute}]}}f.applyChange(i);f.set("flexibleGroupingChangeFlag",true)}}))}.bind(this);if(DG.UndoHistory.get("enabled")){e()}else{DG.AlertPane.warn({message:"DG.TableController.deleteAttribute.confirmMessage".loc(b),description:"DG.TableController.deleteAttribute.confirmDescription".loc(),buttons:[{title:"DG.TableController.deleteAttribute.okButtonTitle",action:e,localize:YES},{title:"DG.TableController.deleteAttribute.cancelButtonTitle",localize:YES}],localize:false})}},deleteAttributeFormula:function(g,b,f){var e=g&&g.getAttrRefByID(b),a=e.attribute.get("name"),d=e&&g.getCollectionForAttribute(e.attribute),h="",c=e&&e.attribute.get("formula");DG.UndoHistory.execute(DG.Command.create({name:"caseTable.editAttributeFormula",undoString:"DG.Undo.caseTable.editAttributeFormula",redoString:"DG.Redo.caseTable.editAttributeFormula",execute:function(){var i={operation:"createAttributes",collection:d,attrPropsArray:[{name:a,formula:h}]},k=g&&g.applyChange(i);if(k.success){e.attribute.set("formula",h);e.attribute.set("deletedFormula",c);f&&f();var j="attributeEditFormula";this.log="%@: { name: '%@', collection: '%@', formula: '%@' }".fmt(j,a,d.get("name"),h)}else{this.set("causedChange",false)}},undo:function(){var i,k,j;i={operation:"createAttributes",collection:d,attrPropsArray:[{name:a,formula:c}]};k=g&&g.applyChange(i);if(k.success){e.attribute.set("formula",c);e.attribute.set("deletedFormula",h);f&&f();j="attributeEditFormula";this.log="%@: { name: '%@', collection: '%@', formula: '%@' }".fmt(j,a,d.get("name"),c)}else{this.set("causedChange",false)}},redo:function(){this.execute()}}))},recoverAttributeFormula:function(g,b,f){var e=g&&g.getAttrRefByID(b),d=e&&g.getCollectionForAttribute(e.attribute),a=e&&e.attribute.get("name"),h=e&&e.attribute.get("deletedFormula"),c="";DG.assert(e&&a,"recoverDeletedFormula() is missing the attribute reference or attribute name");DG.UndoHistory.execute(DG.Command.create({name:"caseTable.editAttributeFormula",undoString:"DG.Undo.caseTable.editAttributeFormula",redoString:"DG.Redo.caseTable.editAttributeFormula",execute:function(){var i={operation:"createAttributes",collection:d,attrPropsArray:[{name:a,formula:h}]},k=g&&g.applyChange(i);if(k.success){e.attribute.set("formula",h);e.attribute.set("deletedFormula",c);f&&f();var j="attributeEditFormula";this.log="%@: { name: '%@', collection: '%@', formula: '%@' }".fmt(j,a,d.get("name"),h)}else{this.set("causedChange",false)}},undo:function(){var i,k,j;i={operation:"createAttributes",collection:d,attrPropsArray:[{name:a,formula:c}]};k=g&&g.applyChange(i);if(k.success){e.attribute.set("formula",c);e.attribute.set("deletedFormula",h);f&&f();j="attributeEditFormula";this.log="%@: { name: '%@', collection: '%@', formula: '%@' }".fmt(j,a,d.get("name"),c)}else{this.set("causedChange",false)}},redo:function(){this.execute()}}))},attributeCanBeRandomized:function(c,b){var d=c&&c.get("dependencyMgr"),a=d&&d.findDependency({type:DG.DEP_TYPE_ATTRIBUTE,id:b},{type:DG.DEP_TYPE_SPECIAL,id:"random"});return a},randomizeAttribute:function(b,a){if(b&&a){b.invalidateDependencyAndNotify({type:DG.DEP_TYPE_ATTRIBUTE,id:a},{type:DG.DEP_TYPE_SPECIAL,id:"random"},true)}},makeUniqueCollectionName:function(d,c){var b=pluralize(c);var a=0;while(!SC.none(d.getCollectionByName(b))){a+=1;b=pluralize(c)+a}return b},createCollectionCommand:function(e,f,d,a){var c=this.makeUniqueCollectionName(d,e.name);var b=null;if(SC.none(a)){b=d.getCollectionAtIndex(0).collection.id}return DG.Command.create({name:"caseTable.createCollection",undoString:"DG.Undo.caseTable.createCollection",redoString:"DG.Redo.caseTable.createCollection",log:"createCollection {name: %@, attr: %@}".loc(c,e.name),_beforeStorage:{context:d,newCollectionName:c,newParentCollectionID:a,newChildCollectionID:b,attributeID:e.id,oldAttributePosition:f.attrs.indexOf(e),oldCollectionID:f.id,changeFlag:d.get("flexibleGroupingChangeFlag")},execute:function(){var h=this._beforeStorage.context;var k=h.getAttrRefByID(this._beforeStorage.attributeID).attribute;var g=this._beforeStorage.newChildCollectionID;var j=g&&h.getCollectionByID(g).collection;var i={operation:"createCollection",properties:{name:this._beforeStorage.newCollectionName,parent:this._beforeStorage.newParentCollectionID},attributes:[k]};if(j){i.properties.children=[j]}h.applyChange(i);h.set("flexibleGroupingChangeFlag",true)},undo:function(){var g=this._beforeStorage.context;var j=g.getAttrRefByID(this._beforeStorage.attributeID).attribute;var i=g.getCollectionByID(this._beforeStorage.oldCollectionID);var h={operation:"moveAttribute",attr:j,toCollection:i,position:this._beforeStorage.oldAttributePosition};g.applyChange(h);g.set("flexibleGroupingChangeFlag",this._beforeStorage.changeFlag)}})},createCaseUndoable:function(c,b){var h=c.get("name");if(!b.collection||!b.attrIDs){return}var g;var e=false;function a(){var i=c.applyChange({operation:"createCases",attributeIDs:b.attrIDs,collection:b.collection,properties:{parent:b.parent},values:[b.values]});if(i.success&&b.beforeCaseID){var m=c.get("dataSet");var j=c.getCaseByID(b.beforeCaseID);var l=j&&j.item;var k=m&&l&&m.getDataItemClientIndexByID(l.id);if(i.itemIDs&&m&&(k!=null)){c.applyChange({operation:"moveItems",items:i.itemIDs.map(function(n){return m.getDataItemByID(n)}),itemOrder:k});e=true}}if(!e){c.regenerateCollectionCases()}return i}function f(i){var j=i.map(function(k){return DG.store.find("DG.Case",k)});return c.applyChange({operation:"deleteCases",cases:j})}var d=DG.Command.create({name:"caseTable.createNewCase",undoString:"DG.Undo.caseTable.createNewCase",redoString:"DG.Redo.caseTable.createNewCase",log:"create new case",execute:function(){g=a()},undo:function(){if(g&&g.caseIDs){f(g.caseIDs)}},redo:function(){c=DG.currDocumentController().getContextByName(h);if(c){g=a()}}});DG.UndoHistory.execute(d)},stashAttributeValue:function(o,a,n,k){var l=n.get("id"),m=a.getStrValue(l),b=DG.DataUtilities.canonicalizeInputValue(k),e=o.get("name"),h=a.get("collection"),f=h&&h.get("name")||"",i=h&&h.getAttributeByID(l),j=i&&i.get("name"),c=h.getCaseIndexByID(a.get("id"));function g(q,r,p){SC.run(function(){o.applyChange({operation:"updateCases",cases:[a],attributeIDs:[q],values:[[r]]})})}var d=DG.Command.create({name:"caseTable.editCellValue",undoString:"DG.Undo.caseTable.editCellValue",redoString:"DG.Redo.caseTable.editCellValue",log:"editValue: { collection: %@, case: %@, attribute: '%@', old: '%@', new: '%@' }".fmt(f,c+1,l,m,b),causedChange:true,execute:function(){g(l,b)},undo:function(){g(l,m,true)},redo:function(){o=DG.currDocumentController().getContextByName(e);h=o&&o.getCollectionByName(f);i=h&&h.getAttributeByName(j);l=i.get("id");var p=h&&h.get("casesController");a=p&&p.objectAt(c);if(a){g(l,b,true)}}});DG.UndoHistory.execute(d)},newAttribute:function(e,c,d,a,g){if(a){DG.globalEditorLock.commitCurrentEdit()}var b=e.getNewAttributeName(),f;DG.UndoHistory.execute(DG.Command.create({name:"caseTable.createAttribute",undoString:"DG.Undo.caseTable.createAttribute",redoString:"DG.Redo.caseTable.createAttribute",execute:function(h){SC.run(function(){f=e.getAttrRefByName(b);var j={operation:"createAttributes",collection:c,attrPropsArray:[{name:b}],position:d},i=e&&e.applyChange(j);if(!h&&i.success){this.log="%@: { name: '%@', collection: '%@', formula: '%@' }".fmt("attributeCreate",b,c.get("name"));if(typeof a==="function"){a(b)}else{if(g&&a){a.invokeLater(function(){a.beginEditAttributeName(b)})}}}else{this.set("causedChange",false)}}.bind(this))},undo:function(){f=e.getAttrRefByName(b);var i=f.attribute,j={operation:"deleteAttributes",collection:c,attrs:[{id:i.get("id"),attribute:i}]},h=e&&e.applyChange(j);if(!h.success){this.set("causedChange",false)}},redo:function(){this.execute(true)}}))},joinSourceToDestCollection:function(f,a,i,e){function b(l){d.forEach(function(n){if(n!==f&&!n.get("hidden")){var o=n.get("name"),m=1;while(k.indexOf(o)>=0){o=n.get("name")+"_"+m;m++}l(n,o)}})}var j=f&&f.get("name"),g=f&&f.collection,c=g&&g.getPath("context.title"),d=g&&g.get("attrs"),h=e&&e.get("name"),k=i.getPath("collection.attrs").map(function(l){return l.get("name")});if(d&&j&&c&&i&&h&&a){DG.UndoHistory.execute(DG.Command.create({name:"dataContext.join",undoString:"DG.Undo.DataContext.join".loc(c,a.get("title")),redoString:"DG.Redo.DataContext.join".loc(c,a.get("title")),log:'Join attributes from "%@" to "%@"'.fmt(c,a.get("title")),executeNotification:{action:"notify",resource:"component",values:{operation:"join",type:DG.CaseTable}},execute:function(){var l=[];b(function(p,m){var o=p.getTransferableProperties(),n=p.get("name");l.push(Object.assign(o,{name:m,title:m,formula:'lookupByKey("%@", "%@", "%@", `%@`)'.fmt(c,n,j,h)}))});a.applyChange({operation:"createAttributes",collection:i,attrPropsArray:l})},undo:function(){var l=[];b(function(n,m){l.push(i.getAttributeByName(m))});a.applyChange({operation:"deleteAttributes",collection:i,attrs:l})}}))}}};DG.doCommandResponseHandler=function(a,c){if(a&&a.error&&a.error instanceof Error){a.error=a.error.message}if(a&&a.values&&a.values.length){a.values=a.values.map(function(d){return d instanceof Error?null:d})}try{c(a)}catch(b){if(b instanceof window.DOMException&&b.name==="DataCloneError"){c({success:false})}}};DG.EditorLock=SC.Object.extend({isActive:function(a){return a===DG.mainPage.getPath("mainPane.firstResponder")||window.Slick.GlobalEditorLock.isActive(a)},activate:function(a){try{window.Slick.GlobalEditorLock.activate(a)}catch(b){DG.logWarn(b.replace("SlickGrid","DG"))}},deactivate:function(a){try{window.Slick.GlobalEditorLock.deactivate(a)}catch(b){DG.logWarn(b.replace("SlickGrid","DG"))}},commitCurrentEdit:function(){var a=window.Slick.GlobalEditorLock.commitCurrentEdit();DG.mainPage.get("mainPane").makeFirstResponder(null);return a},cancelCurrentEdit:function(){return window.Slick.GlobalEditorLock.cancelCurrentEdit()}});DG.globalEditorLock=new DG.EditorLock();DG.IFramePhoneEmulator=function(d,b,e){var a=[];var c=null;return{call:function(f,g){if(c){c._transmit(f,function(h){if(g){g(h)}})}else{a.push({message:f,callback:g})}},connect:function(f){if(!c&&f.connect){DG.log("Local Connection established between %@ and %@".loc(e,f.getConnectorName()));c=f;f.connect(this);if(a.length>0){a.forEach(function(g){this.call(g.message,g.callback)}.bind(this))}}},getConnectorName:function(){return e},_transmit:function(f,g){d(f,g)}}};DG.ImageUtilities=(function(){function f(m,u,s,y,w){function l(){var E=[],z,A;for(z=0;z<document.styleSheets.length;z+=1){try{var F=document.styleSheets[z];if(F){var D=F.rules||F.cssRules||[];for(A=0;A<D.length;A+=1){var C=D[A];E.push(C.cssText)}}}catch(B){DG.logWarn("Exception retrieving stylesheet: "+B)}}return E.join("\n")}function x(C){var B=$(C).clone();var z=$("<style>").text(l());B.prepend(z);var A=new XMLSerializer().serializeToString(B[0]);A=A.replace(new RegExp("url\\('[^#]*#","g"),"url('#");return"data:image/svg+xml;base64,"+window.btoa(window.unescape(window.encodeURIComponent(A)))}function g(C,z){var B=$("<canvas>").prop({width:C,height:z})[0];var A=B.getContext("2d");A.fillStyle="white";A.fillRect(0,0,C,z);return B}function t(C,E,A,F,D,z){var B=C.getContext("2d");B.drawImage(E,A,F,D,z)}function n(D,C,A,F,E,z){var B=D.getContext("2d");B.fillStyle=C;B.fillRect(A,F,E,z)}function j(B){var D=B.toDataURL("image/png");var A=atob(D.substring("data:image/png;base64,".length));var E=new Uint8Array(A.length);for(var C=0,z=A.length;C<z;++C){E[C]=A.charCodeAt(C)}return new Blob([E.buffer],{type:"image/png"})}function r(z){return new Promise(function(D,C){try{var A=$("<img/>")[0];A.onload=function(){D(A)};A.src=z}catch(B){C(B)}})}function i(A,B,C,D){var z=A.getContext("2d");z.fillStyle=B;z.fillRect(0,s,u,20);z.fillStyle=C;z.beginPath();z.moveTo(0,s);z.lineTo(u,s);z.stroke();z.font="10pt MuseoSans-500";z.textAlign="center";z.textBaseline="middle";z.fillText(D,u/2,s+14,u)}var p=$(m).find("div.dg-plot-view,img,div:not(.sc-hidden)>svg");var h=g(u,s+(y?20:0));var k=[];var o=0;function q(A){var z=A&&A.el&&A.el.nodeName.toLowerCase();if(!A){if(y){i(h,"white","black",y)}try{return Promise.resolve(w?h.toDataURL("image/png"):j(h))}catch(B){return Promise.reject(B)}}if(z==="div"){n(h,$(A.el).css("background-color"),A.l,A.t,A.w,A.h);return q(k[o++])}else{if(z==="svg"){return r(x(A.el)).then(function(C){t(h,C,A.l,A.t,A.w,A.h);return q(k[o++])},function(C){return Promise.reject(C)})}else{if(z==="img"){if(!SC.none(A.el.getAttribute("crossorigin"))){t(h,A.el,A.l,A.t,A.w,A.h)}return q(k[o++])}else{return q(k[o++])}}}}try{if(p){p.forEach(function(B){var C=B.offsetWidth||(B.width.baseVal?B.width.baseVal.value:0);var z=B.offsetHeight||(B.height.baseVal?B.height.baseVal.value:0);var F=0;var E=0;var D=B.getBoundingClientRect();var A=m.getBoundingClientRect();if(B.nodeName.toLowerCase()==="img"){k.push({el:B,w:D.width,h:D.height,l:D.left-A.left,t:D.top-A.top})}else{$(B).add($(B).parentsUntil(m)).each(function(){F+=this.offsetLeft||0;E+=this.offsetTop||0});k.push({el:B,w:C,h:z,l:F,t:E})}});return q(k[o++])}}catch(v){DG.logError("saving image: "+v)}return null}function e(i,g){var h=document.createElement("svg");h.setAttribute("width",i);h.setAttribute("height",g);h.setAttribute("xmlns","http://www.w3.org/2000/svg");h.innerHTML="<rect width="+(i-1)+" height="+(g-1)+' stroke="#888" fill="#fff"/>';return h}function c(h,i){var g=0,k=0;var j=h;while(j&&j!==j.parentElement&&j!==i){g+=j.offsetLeft||0;k+=j.offsetTop||0;j=j.parentElement}return{x:g,y:k}}function d(g,j,i){var h=document.createElement("text");h.setAttribute("x",j);h.setAttribute("y",i);h.setAttribute("font-family","MuseoSans-500,arial");h.setAttribute("font-size","14px");h.setAttribute("stroke","none");h.setAttribute("fill","#888");h.setAttribute("text-anchor","middle");h.innerText=g;return h}function a(k,i,j,h){var g=document.createElement("path");g.setAttribute("d","M"+k+" "+i+" L"+j+" "+h);g.setAttribute("stroke","#888");g.setAttribute("fill","#888");return g}function b(i,h,g,l){if(l){g=g+20}var j=i.querySelectorAll("div:not(.sc-hidden)>svg");var k=e(h,g+(l?20:0));j.forEach(function(m){if(m.children){var o=c(m,i);var n=m.cloneNode(true);n.setAttribute("x",o.x);n.setAttribute("y",o.y);n.setAttribute("width",m.width.baseVal.value);n.setAttribute("height",m.height.baseVal.value);if(m.tagName.toLowerCase()==="svg"){k.append(n)}}});if(l){k.append(a(0,g-20,h,g-20));k.append(d(l,h/2,g))}return k.outerHTML}return{captureSVGElementsToImage:f,captureGraphToSVG:b}}());DG.MathUtilities={roundToDecimalPlaces:function(c,b){var a=Math.pow(10,b);return Math.round(c*a)/a},roundToSignificantDigits:function(h,c){var d=1,e=0,g,b,a,f,j;DG.assert(c>0);if(isNaN(h)){return{roundedValue:h,decPlaces:0}}if(h===0){return{roundedValue:0,decPlaces:0}}if(h<0){d=-1;h=-h}g=Math.pow(10,c-1);b=g*10;while(h>b){h=h/10;e++}while(h<g){h=h*10;e--}a=Math.floor(h);if(h-a>0.5){a++}var i=e;while(i<0){a=a/10;i++}if(e<0){a=a.toFixed(-e)}while(i>0){a=a*10;i--}f=d*a;if(e>0){e=0}j=-e;return{roundedValue:f,decPlaces:j}},formatNumber:function(c,b){var a=DG.Format.number().fractionDigits(0,b);a.group("");return a(c)},extractNumeric:function(a){if(SC.empty(a)){return""}var d=Number(a);if(!isNaN(d)){return d}if(typeof a==="string"){var c=/[^.\d-]+/gm,b=/(^-?\.?[\d]+(.?[\d]*)?)/gm,e=a.replace(c,"");a=e.match(b);a=Array.isArray(a)?a[0]:null}return SC.empty(a)?null:Number(a)},clipToIntegerRange:function(c,b,a){DG.assert(c===Math.round(c));if(c<b){return b}else{if(c>=a){return a-1}}return c},isInIntegerRange:function(c,b,a){DG.assert(c===Math.round(c));return(b<=c&&c<a)},clipToRange:function(c,b,a){DG.assert(typeof c==="number"&&isFinite(c));if(c<b){return b}else{if(c>a){return a}}return c},isInRange:function(c,b,a){DG.assert(typeof c==="number");return isFinite(c)?(b<=c&&c<=a):false},distance:function(d,c){var b=d.x-c.x,a=d.y-c.y;return Math.sqrt(b*b+a*a)},medianOfNumericArray:function(c){function b(e,d){return e-d}function a(d){var e=(d.length-1)/2,g=Math.floor(e),f=Math.ceil(e);if(e<0){return undefined}else{if(e===g){return d[e]}else{return(d[g]+d[f])/2}}}c.sort(b);return a(c)},quantileOfSortedArray:function(a,f){var g=a.length-1,b=g*f,e=Math.floor(b),d=Math.ceil(b),c=b-e;if(b<0){return undefined}else{if(b>=g){return a[g]}else{if(b===e){return a[e]}else{return(a[d]*c+a[e]*(1-c))}}}},nQuantileValues:function(a,b){function c(g,f){return g-f}var d=[];a.sort(c);for(var e=0;e<=b;e++){d.push(DG.MathUtilities.quantileOfSortedArray(a,e/b))}return d},tAt0975ForDf:function(a){var b=DG.stat_constants.t_quantile_at_0975_for_df.findIndex(function(c){return c[0]>a});return b<=0?1.96:DG.stat_constants.t_quantile_at_0975_for_df[b-1][1]},computeBivariateStats:function(c){var d={count:0,xSum:0,xMean:0,xSumSquaredDeviations:0,ySum:0,yMean:0,ySumSquaredDeviations:0,sumOfProductDiffs:0},b=0,a=0;c=c.filter(function(e){return !(SC.empty(e.x)||SC.empty(e.y))});c.forEach(function(e){if(isFinite(e.x)&&isFinite(e.y)){d.count+=1;d.xSum+=e.x;d.ySum+=e.y}});if(d.count>0){d.xMean=d.xSum/d.count;d.yMean=d.ySum/d.count;c.forEach(function(g){var f,e;if(isFinite(g.x)&&isFinite(g.y)){d.sumOfProductDiffs+=(g.x-d.xMean)*(g.y-d.yMean);f=g.x-d.xMean;d.xSumSquaredDeviations+=f*f;b+=f;e=g.y-d.yMean;d.ySumSquaredDeviations+=e*e;a+=e}});d.xSumSquaredDeviations-=(b*b/d.count);d.ySumSquaredDeviations-=(a*a/d.count)}return d},correlation:function(b){var c=NaN,a=DG.MathUtilities.computeBivariateStats(b);if(a.count>1){c=Math.sqrt(a.sumOfProductDiffs*a.sumOfProductDiffs/(a.xSumSquaredDeviations*a.ySumSquaredDeviations));if(a.sumOfProductDiffs<0){c=-c}}return c},rSquared:function(b){var c=NaN,a=DG.MathUtilities.computeBivariateStats(b);if(a.count>1){c=(a.sumOfProductDiffs*a.sumOfProductDiffs)/(a.xSumSquaredDeviations*a.ySumSquaredDeviations)}return c},linRegrSlope:function(b,d){var c=NaN,a=DG.MathUtilities.computeBivariateStats(b);if(a.count>1){if(d){c=(a.sumOfProductDiffs+a.xMean*a.ySum)/(a.xSumSquaredDeviations+a.xMean*a.xSum)}else{c=a.sumOfProductDiffs/a.xSumSquaredDeviations}}return c},linRegrIntercept:function(c,e){var d=NaN,b=DG.MathUtilities.computeBivariateStats(c),a=b.sumOfProductDiffs/b.xSumSquaredDeviations;if(b.count>1){if(e){d=0}else{d=b.yMean-a*b.xMean}}return d},leastSquaresLinearRegression:function(a,d){var b={count:null,xMean:null,xSumSquaredDeviations:null,slope:null,intercept:null,sse:0,mse:null,rSquared:null,sdResiduals:null},c=DG.MathUtilities.computeBivariateStats(a);if(c.count>1){if(d){b.slope=(c.sumOfProductDiffs+c.xMean*c.ySum)/(c.xSumSquaredDeviations+c.xMean*c.xSum);b.intercept=0}else{b.count=c.count;b.xMean=c.xMean;b.yMean=c.yMean;b.xSumSquaredDeviations=c.xSumSquaredDeviations;b.slope=c.sumOfProductDiffs/c.xSumSquaredDeviations;b.intercept=c.yMean-b.slope*c.xMean;b.rSquared=(c.sumOfProductDiffs*c.sumOfProductDiffs)/(c.xSumSquaredDeviations*c.ySumSquaredDeviations);a.forEach(function(e){if(isFinite(e.x)&&isFinite(e.y)){var f=e.y-(b.intercept+b.slope*e.x);b.sse+=f*f}});b.sdResiduals=Math.sqrt(b.sse/(c.count-2));b.mse=b.sse/(b.count-2)}}return b},linRegrSESlopeAndIntercept:function(b){var c={seSlope:NaN,seIntercept:NaN},a=DG.MathUtilities.leastSquaresLinearRegression(b,false);if(a.count>1){c.seSlope=Math.sqrt((a.sse/(a.count-2))/a.xSumSquaredDeviations);c.seIntercept=Math.sqrt(a.sse/(a.count-2))*Math.sqrt(1/a.count+Math.pow(a.xMean,2)/a.xSumSquaredDeviations)}return c},normal:function(a,c,b,d){var e=-(Math.pow(a-b,2)/(2*Math.pow(d,2)));return c*Math.exp(e)},fitGaussianLM:function(J,a,H,j){if(!J||J.length===0){return{mu:H,sigma:j}}var S;var N=J.length;var k=0;for(S=0;S<N;S++){k+=J[S].x}var D=k/N;var A=0;for(S=0;S<N;S++){var M=J[S].x-D;A+=M*M}var c=A/N;var G=Math.sqrt(c)||1;var I=new Array(N);for(S=0;S<N;S++){I[S]={x:(J[S].x-D)/G,y:J[S].y/a}}var l=(H-D)/G;var h=j/G;if(!Number.isFinite(h)||h<=0){h=1}var K=Math.log(h);var t=50;var m=1e-12;var Y=0.001;function d(i,g){var ac=Math.exp(g);var ad=0;for(var ab=0;ab<N;ab++){var af=I[ab];var n=DG.MathUtilities.normal(af.x,1,i,ac);var ae=af.y-n;ad+=ae*ae}return ad}var w=d(l,K);for(var B=0;B<t;B++){var e=Math.exp(K);var r=0;var q=0;var W=0;var z=0;var x=0;for(S=0;S<N;S++){var X=I[S];var f=X.x-l;var o=1/(e*e);var V=Math.exp(-0.5*f*f*o);var Z=V;var s=X.y-Z;var u=Z*(f*o);var y=Z*(f*f*o);var R=-u;var Q=-y;r+=R*R;q+=R*Q;W+=Q*Q;z+=-R*s;x+=-Q*s}var U=r+Y;var C=W+Y;var p=U*C-q*q;if(!Number.isFinite(p)||Math.abs(p)<1e-18){Y*=10;continue}var b=(z*C-x*q)/p;var O=(U*x-q*z)/p;if(!Number.isFinite(b)||!Number.isFinite(O)){Y*=10;continue}var v=l+b;var aa=K+O;var T=d(v,aa);if(T<w){l=v;K=aa;var E=w-T;w=T;Y=Math.max(Y/10,1e-12);if(Math.abs(b)+Math.abs(O)<m||E<m){break}}else{Y*=10}}var P=Math.exp(K)*G;var F=l*G+D;return{mu:F,sigma:P}},isFinite:function(a){return !SC.empty(a)&&isFinite(a)},isNumeric:function(a){return !SC.empty(a)&&!isNaN(a)},getNumeric:function(a){return !SC.empty(a)&&!isNaN(a)?Number(a):null},map:function(c,a){var b={};return a?c.map(function(f,e){b.index=e;return a.call(b,f)}):c.slice()},index:function(){return this.index},max:function(b,a){if(a===DG.MathUtilities.index){return b.length-1}return Math.max.apply(null,a?DG.MathUtilities.map(b,a):b)},range:function(f,c,d){if(arguments.length===1){c=f;f=0}if(d===undefined){d=1}if((c-f)/d===Infinity){throw new Error("range must be finite")}var e=[],b=0,a;c-=(c-f)*1e-10;if(d<0){while((a=f+d*b++)>c){e.push(a)}}else{while((a=f+d*b++)<c){e.push(a)}}return e},goodTickValue:function(e){if(e===0){return 1}var d=Math.log(e)/Math.LN10,c=Math.floor(d),b=Math.pow(10,c),a=Math.pow(10,d-c);if(a<2){a=1}else{if(a<5){a=2}else{a=5}}return Math.max(b*a,Number.MIN_VALUE)},notAYear:function(a){return(Math.round(a)!==a||a<0||a>=10000)}};DG.isFinite=DG.MathUtilities.isFinite;DG.isNumeric=DG.MathUtilities.isNumeric;DG.getNumeric=DG.MathUtilities.getNumeric;DG.measureText=(function(){function c(d){return d.scrollHeight-1>d.clientHeight||d.scrollWidth-1>d.clientWidth}var b="dg-text-measurer";var a;return function(f,e){var d={font:"initial"};if(e){d=e}a=$("."+b);if(a.length===0){a=$("<div>").addClass(b);a.appendTo(document.body)}a.attr("style",d).html(f);return{width:a.outerWidth(),height:a.outerHeight(),hasOverflowed:c(a[0])}}}());DG.PluginOverlayContainer=SC.View.extend({overlayPanes:[],isVisibleInWindow:true,isDropTarget:YES,isDropEnabled:YES,acceptDragOperation:function(){return YES},dragStarted:function(j,a){var d=DG.currDocumentController();var e=d.get("dataInteractives");function h(i){var p=i.parentView;var o=i.get("layout");o.right=(o.width==null)?o.right:o.left+o.width;o.bottom=(o.height==null)?o.bottom:o.top+o.height;var n=DG.ViewUtilities.viewToWindowCoordinates({x:o.left,y:o.top+DG.ViewUtilities.kTitleBarHeight},p);var m=DG.ViewUtilities.viewToWindowCoordinates({x:o.right,y:o.bottom},p);return{left:n.x,right:m.x,top:n.y,bottom:m.y,width:m.x-n.x,height:m.y-n.y}}function c(n,i,m){return{action:"notify",resource:"dragDrop[attribute]",values:{operation:n,text:i.text,attribute:{id:i.attribute.get("id"),name:i.attribute.get("name"),title:i.attribute.get("title")},collection:{id:i.collection.get("id"),name:i.collection.get("name"),title:i.collection.get("title")},context:{id:i.context.get("id"),name:i.context.get("name"),title:i.context.get("title")},position:m}}}for(var f=0;f<e.length;f++){var g=e[f];var k=g.get("view");var b=h(k);var l=SC.Pane.extend({context:j.getPath("data.context"),layout:b,gameController:g,dragData:null,isVisible:true,isVisibleInWindow:true,isDropTarget:YES,isDropEnabled:YES,acceptDragOperation:function(){return YES},dragEntered:function(i){d.notificationManager.sendChannelNotification(this.gameController,c("dragenter",i.data))},dragExited:function(i){d.notificationManager.sendChannelNotification(this.gameController,c("dragleave",i.data))},dragUpdated:function(n){var m=this.layout;var i=n.getPath("location.x");var o=n.getPath("location.y");if(i>=m.left&&i<=m.right&&o>=m.top&&o<=m.bottom){d.notificationManager.sendChannelNotification(this.gameController,c("drag",n.data,{x:i-m.left,y:o-m.top}))}},isValidAttribute:function(n){var i=n.data.attribute;var m=this.get("context").getAttributes();return m.indexOf(i)>=0},computeDragOperations:function(i){return this.isValidAttribute(i)?SC.DRAG_LINK:SC.DRAG_NONE},performDragOperation:function(n){var m=this.layout;var i=n.getPath("location.x");var o=n.getPath("location.y");if(i>=m.left&&i<=m.right&&o>=m.top&&o<=m.bottom){d.notificationManager.sendChannelNotification(this.gameController,c("drop",n.data,{x:i-m.left,y:o-m.top}))}return SC.DRAG_LINK},dragStarted:function(i){d.notificationManager.sendChannelNotification(this.gameController,c("dragstart",i.data))},dragEnded:function(i){d.notificationManager.sendChannelNotification(this.gameController,c("dragend",i.data))}}).create();l.appendTo(document.body);this.overlayPanes.pushObject(l);j._cachedDropTargets.pushObject(l);l.tryToPerform("dragStarted",j,a)}},dragEnded:function(a,b){this.overlayPanes.forEach(function(c){c.tryToPerform("dragEnded",a,b);c.remove();c.destroy()}.bind(this));this.overlayPanes=[]}});DG.color=function(m){function e(b){var a=parseFloat(b);return(b[b.length-1]==="%")?Math.round(a*2.55):a}var c,i,j,f,p,d,o,n,k;if(m.rgb){return m.rgb()}o=/([a-z]+)\((.*)\)/i.exec(m);if(o){n=o[2].split(",");k=1;switch(o[1]){case"hsla":case"rgba":k=parseFloat(n[3]);if(!k){return DG.Color.transparent}break}switch(o[1]){case"hsla":case"hsl":f=parseFloat(n[0]);p=parseFloat(n[1])/100;d=parseFloat(n[2])/100;return(new DG.Color.Hsl(f,p,d,k)).rgb();case"rgba":case"rgb":c=e(n[0]);i=e(n[1]);j=e(n[2]);return DG.rgb(c,i,j,k)}}if(m.charAt(0)==="#"){if(m.length===4){c=m.charAt(1);c+=c;i=m.charAt(2);i+=i;j=m.charAt(3);j+=j}else{if(m.length===7){c=m.substring(1,3);i=m.substring(3,5);j=m.substring(5,7)}}return DG.rgb(parseInt(c,16),parseInt(i,16),parseInt(j,16),1)}return new DG.Color(m,1)};DG.Color=function(a,b){this.color=a;this.opacity=b};DG.Color.prototype.brighter=function(a){return this.rgb().brighter(a)};DG.Color.prototype.darker=function(a){return this.rgb().darker(a)};DG.rgb=function(f,e,c,d){return new DG.Color.Rgb(f,e,c,(arguments.length===4)?d:1)};DG.Color.Rgb=function(f,e,c,d){DG.Color.call(this,d?("rgb("+f+","+e+","+c+")"):"none",d);this.r=f;this.g=e;this.b=c;this.a=d};DG.Color.Rgb.prototype=SC.extend(DG.Color);DG.Color.Rgb.prototype.red=function(a){return DG.rgb(a,this.g,this.b,this.a)};DG.Color.Rgb.prototype.green=function(a){return DG.rgb(this.r,a,this.b,this.a)};DG.Color.Rgb.prototype.blue=function(a){return DG.rgb(this.r,this.g,a,this.a)};DG.Color.Rgb.prototype.alpha=function(b){return DG.rgb(this.r,this.g,this.b,b)};DG.Color.Rgb.prototype.rgb=function(){return this};DG.Color.Rgb.prototype.brighter=function(c){c=Math.pow(0.7,arguments.length?c:1);var f=this.r,e=this.g,a=this.b,d=30;if(!f&&!e&&!a){return DG.rgb(d,d,d,this.a)}if(f&&(f<d)){f=d}if(e&&(e<d)){e=d}if(a&&(a<d)){a=d}return DG.rgb(Math.min(255,Math.floor(f/c)),Math.min(255,Math.floor(e/c)),Math.min(255,Math.floor(a/c)),this.a)};DG.Color.Rgb.prototype.darker=function(a){a=Math.pow(0.7,arguments.length?a:1);return DG.rgb(Math.max(0,Math.floor(a*this.r)),Math.max(0,Math.floor(a*this.g)),Math.max(0,Math.floor(a*this.b)),this.a)};sc_require("libraries/raphael");DG.RaphaelLayer=SC.Object.extend({name:null,_map:null,isVisible:true,_prevLayer:null,_firstElement:null,_lastElement:null,_paper:null,init:function(){arguments.callee.base.apply(this,arguments);if(SC.empty(this.name)){this.name="unnamed"}this._firstElement=this._lastElement=null;this._map={}},clear:function(){this.forEach(function(a){a.remove()});this._firstElement=this._lastElement=null;this._map={}},push:function(b){DG.assert(b);if(!this._paper.bottom){this._paper.bottom=b}if(!this._map[b.id]){this._map[b.id]=true;if(!(this._lastElement&&this._lastElement.node)){var a;for(a=this._prevLayer;a;a=a._prevLayer){if(a&&a._lastElement){break}}if(a){b.insertAfter(a._lastElement)}else{b.toBack()}}else{b.insertAfter(this._lastElement)}this._lastElement=b;if(!this._firstElement){this._firstElement=b}DG.assert(b.next||(b===this._lastElement))}return b},prepareToMoveOrRemove:function(a){if(a===this._paper.bottom){this._paper.bottom=a.next;if(this._paper.bottom){this._paper.bottom.prev=null}}if(a===this._paper.top){this._paper.top=a.prev;if(this._paper.top){this._paper.top.next=null}}if(a===this._firstElement){if(this._firstElement===this._lastElement){this._firstElement=this._lastElement=null}else{this._firstElement=a.next}}else{if(a===this._lastElement){this._lastElement=a.prev}}if(this._map[a.id]){if(a.prev&&a.prev.next===a){a.prev.next=a.next}if(a.next&&a.next.prev===a){a.next.prev=a.prev}delete this._map[a.id]}},forEach:function(d){var b,a,c=0;for(b=this._firstElement;b;b=a){a=(b===this._lastElement)?null:b.next;d(b,c++)}},contains:function(a){return this._map[a.id]},bringToFront:function(a){if(this.contains(a)){this.prepareToMoveOrRemove(a);this.push(a)}},isValid:function(){var b=true;if(!this._firstElement&&!this._lastElement){return true}if(!this._firstElement||!this._lastElement||this._firstElement.removed||this._lastElement.removed){b=false}else{var a=false;this.forEach(function(c){b=b&&this._map[c.id];a=a||(c===this._lastElement)}.bind(this));b=b&&a}if(!b){console.log("Invalid layer: "+this.name)}return b},hide:function(){this.set("isVisible",false);this.forEach(function(a){a.animate({"fill-opacity":0,"stroke-opacity":0},DG.PlotUtilities.kDefaultAnimationTime,"<>",function(){this.hide()})})},show:function(a){a=a||{"fill-opacity":1,"stroke-opacity":1};this.set("isVisible",true);this.forEach(function(b){b.show().animate(a,DG.PlotUtilities.kDefaultAnimationTime,"<>")})}});var defaultDiacriticsRemovalMap=[{base:"A",letters:/(&#65;|&#9398;|&#65313;|&#192;|&#193;|&#194;|&#7846;|&#7844;|&#7850;|&#7848;|&#195;|&#256;|&#258;|&#7856;|&#7854;|&#7860;|&#7858;|&#550;|&#480;|&#196;|&#478;|&#7842;|&#197;|&#506;|&#461;|&#512;|&#514;|&#7840;|&#7852;|&#7862;|&#7680;|&#260;|&#570;|&#11375;|[\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F])/g},{base:"AA",letters:/(&#42802;|[\uA732])/g},{base:"AE",letters:/(&#198;|&#508;|&#482;|[\u00C6\u01FC\u01E2])/g},{base:"AO",letters:/(&#42804;|[\uA734])/g},{base:"AU",letters:/(&#42806;|[\uA736])/g},{base:"AV",letters:/(&#42808;|&#42810;|[\uA738\uA73A])/g},{base:"AY",letters:/(&#42812;|[\uA73C])/g},{base:"B",letters:/(&#66;|&#9399;|&#65314;|&#7682;|&#7684;|&#7686;|&#579;|&#386;|&#385;|[\u0042\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181])/g},{base:"C",letters:/(&#67;|&#9400;|&#65315;|&#262;|&#264;|&#266;|&#268;|&#199;|&#7688;|&#391;|&#571;|&#42814;|[\u0043\u24B8\uFF23\u0106\u0108\u010A\u010C\u00C7\u1E08\u0187\u023B\uA73E])/g},{base:"D",letters:/(&#68;|&#9401;|&#65316;|&#7690;|&#270;|&#7692;|&#7696;|&#7698;|&#7694;|&#272;|&#395;|&#394;|&#393;|&#42873;|&#208;|[\u0044\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018B\u018A\u0189\uA779\u00D0])/g},{base:"DZ",letters:/(&#497;|&#452;|[\u01F1\u01C4])/g},{base:"Dz",letters:/(&#498;|&#453;|[\u01F2\u01C5])/g},{base:"E",letters:/(&#69;|&#9402;|&#65317;|&#200;|&#201;|&#202;|&#7872;|&#7870;|&#7876;|&#7874;|&#7868;|&#274;|&#7700;|&#7702;|&#276;|&#278;|&#203;|&#7866;|&#282;|&#516;|&#518;|&#7864;|&#7878;|&#552;|&#7708;|&#280;|&#7704;|&#7706;|&#400;|&#398;|[\u0045\u24BA\uFF25\u00C8\u00C9\u00CA\u1EC0\u1EBE\u1EC4\u1EC2\u1EBC\u0112\u1E14\u1E16\u0114\u0116\u00CB\u1EBA\u011A\u0204\u0206\u1EB8\u1EC6\u0228\u1E1C\u0118\u1E18\u1E1A\u0190\u018E])/g},{base:"F",letters:/(&#70;|&#9403;|&#65318;|&#7710;|&#401;|&#42875;|[\u0046\u24BB\uFF26\u1E1E\u0191\uA77B])/g},{base:"G",letters:/(&#71;|&#9404;|&#65319;|&#500;|&#284;|&#7712;|&#286;|&#288;|&#486;|&#290;|&#484;|&#403;|&#42912;|&#42877;|&#42878;|[\u0047\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E])/g},{base:"H",letters:/(&#72;|&#9405;|&#65320;|&#292;|&#7714;|&#7718;|&#542;|&#7716;|&#7720;|&#7722;|&#294;|&#11367;|&#11381;|&#42893;|[\u0048\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D])/g},{base:"I",letters:/(&#73;|&#9406;|&#65321;|&#204;|&#205;|&#206;|&#296;|&#298;|&#300;|&#304;|&#207;|&#7726;|&#7880;|&#463;|&#520;|&#522;|&#7882;|&#302;|&#7724;|&#407;|[\u0049\u24BE\uFF29\u00CC\u00CD\u00CE\u0128\u012A\u012C\u0130\u00CF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197])/g},{base:"J",letters:/(&#74;|&#9407;|&#65322;|&#308;|&#584;|[\u004A\u24BF\uFF2A\u0134\u0248])/g},{base:"K",letters:/(&#75;|&#9408;|&#65323;|&#7728;|&#488;|&#7730;|&#310;|&#7732;|&#408;|&#11369;|&#42816;|&#42818;|&#42820;|&#42914;|[\u004B\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2])/g},{base:"L",letters:/(&#76;|&#9409;|&#65324;|&#319;|&#313;|&#317;|&#7734;|&#7736;|&#315;|&#7740;|&#7738;|&#321;|&#573;|&#11362;|&#11360;|&#42824;|&#42822;|&#42880;|[\u004C\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780])/g},{base:"LJ",letters:/(&#455;|[\u01C7])/g},{base:"Lj",letters:/(&#456;|[\u01C8])/g},{base:"M",letters:/(&#77;|&#9410;|&#65325;|&#7742;|&#7744;|&#7746;|&#11374;|&#412;|[\u004D\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C])/g},{base:"N",letters:/(&#78;|&#9411;|&#65326;|&#504;|&#323;|&#209;|&#7748;|&#327;|&#7750;|&#325;|&#7754;|&#7752;|&#544;|&#413;|&#42896;|&#42916;|&#330;|[\u004E\u24C3\uFF2E\u01F8\u0143\u00D1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u0220\u019D\uA790\uA7A4\u014A])/g},{base:"NJ",letters:/(&#458;|[\u01CA])/g},{base:"Nj",letters:/(&#459;|[\u01CB])/g},{base:"O",letters:/(&#79;|&#9412;|&#65327;|&#210;|&#211;|&#212;|&#7890;|&#7888;|&#7894;|&#7892;|&#213;|&#7756;|&#556;|&#7758;|&#332;|&#7760;|&#7762;|&#334;|&#558;|&#560;|&#214;|&#554;|&#7886;|&#336;|&#465;|&#524;|&#526;|&#416;|&#7900;|&#7898;|&#7904;|&#7902;|&#7906;|&#7884;|&#7896;|&#490;|&#492;|&#216;|&#510;|&#390;|&#415;|&#42826;|&#42828;|[\u004F\u24C4\uFF2F\u00D2\u00D3\u00D4\u1ED2\u1ED0\u1ED6\u1ED4\u00D5\u1E4C\u022C\u1E4E\u014C\u1E50\u1E52\u014E\u022E\u0230\u00D6\u022A\u1ECE\u0150\u01D1\u020C\u020E\u01A0\u1EDC\u1EDA\u1EE0\u1EDE\u1EE2\u1ECC\u1ED8\u01EA\u01EC\u00D8\u01FE\u0186\u019F\uA74A\uA74C])/g},{base:"OE",letters:/(&#338;|[\u0152])/g},{base:"OI",letters:/(&#418;|[\u01A2])/g},{base:"OO",letters:/(&#42830;|[\uA74E])/g},{base:"OU",letters:/(&#546;|[\u0222])/g},{base:"P",letters:/(&#80;|&#9413;|&#65328;|&#7764;|&#7766;|&#420;|&#11363;|&#42832;|&#42834;|&#42836;|[\u0050\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754])/g},{base:"Q",letters:/(&#81;|&#9414;|&#65329;|&#42838;|&#42840;|&#586;|[\u0051\u24C6\uFF31\uA756\uA758\u024A])/g},{base:"R",letters:/(&#82;|&#9415;|&#65330;|&#340;|&#7768;|&#344;|&#528;|&#530;|&#7770;|&#7772;|&#342;|&#7774;|&#588;|&#11364;|&#42842;|&#42918;|&#42882;|[\u0052\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782])/g},{base:"S",letters:/(&#83;|&#9416;|&#65331;|&#7838;|&#346;|&#7780;|&#348;|&#7776;|&#352;|&#7782;|&#7778;|&#7784;|&#536;|&#350;|&#11390;|&#42920;|&#42884;|[\u0053\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784])/g},{base:"T",letters:/(&#84;|&#9417;|&#65332;|&#7786;|&#356;|&#7788;|&#538;|&#354;|&#7792;|&#7790;|&#358;|&#428;|&#430;|&#574;|&#42886;|[\u0054\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786])/g},{base:"TH",letters:/(&#222;|[\u00DE])/g},{base:"TZ",letters:/(&#42792;|[\uA728])/g},{base:"U",letters:/(&#85;|&#9418;|&#65333;|&#217;|&#218;|&#219;|&#360;|&#7800;|&#362;|&#7802;|&#364;|&#220;|&#475;|&#471;|&#469;|&#473;|&#7910;|&#366;|&#368;|&#467;|&#532;|&#534;|&#431;|&#7914;|&#7912;|&#7918;|&#7916;|&#7920;|&#7908;|&#7794;|&#370;|&#7798;|&#7796;|&#580;|[\u0055\u24CA\uFF35\u00D9\u00DA\u00DB\u0168\u1E78\u016A\u1E7A\u016C\u00DC\u01DB\u01D7\u01D5\u01D9\u1EE6\u016E\u0170\u01D3\u0214\u0216\u01AF\u1EEA\u1EE8\u1EEE\u1EEC\u1EF0\u1EE4\u1E72\u0172\u1E76\u1E74\u0244])/g},{base:"V",letters:/(&#86;|&#9419;|&#65334;|&#7804;|&#7806;|&#434;|&#42846;|&#581;|[\u0056\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245])/g},{base:"VY",letters:/(&#42848;|[\uA760])/g},{base:"W",letters:/(&#87;|&#9420;|&#65335;|&#7808;|&#7810;|&#372;|&#7814;|&#7812;|&#7816;|&#11378;|[\u0057\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72])/g},{base:"X",letters:/(&#88;|&#9421;|&#65336;|&#7818;|&#7820;|[\u0058\u24CD\uFF38\u1E8A\u1E8C])/g},{base:"Y",letters:/(&#89;|&#9422;|&#65337;|&#7922;|&#221;|&#374;|&#7928;|&#562;|&#7822;|&#376;|&#7926;|&#7924;|&#435;|&#590;|&#7934;|[\u0059\u24CE\uFF39\u1EF2\u00DD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE])/g},{base:"Z",letters:/(&#90;|&#9423;|&#65338;|&#377;|&#7824;|&#379;|&#381;|&#7826;|&#7828;|&#437;|&#548;|&#11391;|&#11371;|&#42850;|[\u005A\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762])/g},{base:"a",letters:/(&#97;|&#9424;|&#65345;|&#7834;|&#224;|&#225;|&#226;|&#7847;|&#7845;|&#7851;|&#7849;|&#227;|&#257;|&#259;|&#7857;|&#7855;|&#7861;|&#7859;|&#551;|&#481;|&#228;|&#479;|&#7843;|&#229;|&#507;|&#462;|&#513;|&#515;|&#7841;|&#7853;|&#7863;|&#7681;|&#261;|&#11365;|&#592;|[\u0061\u24D0\uFF41\u1E9A\u00E0\u00E1\u00E2\u1EA7\u1EA5\u1EAB\u1EA9\u00E3\u0101\u0103\u1EB1\u1EAF\u1EB5\u1EB3\u0227\u01E1\u00E4\u01DF\u1EA3\u00E5\u01FB\u01CE\u0201\u0203\u1EA1\u1EAD\u1EB7\u1E01\u0105\u2C65\u0250])/g},{base:"aa",letters:/(&#42803;|[\uA733])/g},{base:"ae",letters:/(&#230;|&#509;|&#483;|[\u00E6\u01FD\u01E3])/g},{base:"ao",letters:/(&#42805;|[\uA735])/g},{base:"au",letters:/(&#42807;|[\uA737])/g},{base:"av",letters:/(&#42809;|&#42811;|[\uA739\uA73B])/g},{base:"ay",letters:/(&#42813;|[\uA73D])/g},{base:"b",letters:/(&#98;|&#9425;|&#65346;|&#7683;|&#7685;|&#7687;|&#384;|&#387;|&#595;|[\u0062\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253])/g},{base:"c",letters:/(&#99;|&#9426;|&#65347;|&#263;|&#265;|&#267;|&#269;|&#231;|&#7689;|&#392;|&#572;|&#42815;|&#8580;|[\u0063\u24D2\uFF43\u0107\u0109\u010B\u010D\u00E7\u1E09\u0188\u023C\uA73F\u2184])/g},{base:"d",letters:/(&#100;|&#9427;|&#65348;|&#7691;|&#271;|&#7693;|&#7697;|&#7699;|&#7695;|&#273;|&#396;|&#598;|&#599;|&#42874;|&#240;|[\u0064\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\uA77A\u00F0])/g},{base:"dz",letters:/(&#499;|&#454;|[\u01F3\u01C6])/g},{base:"e",letters:/(&#101;|&#9428;|&#65349;|&#232;|&#233;|&#234;|&#7873;|&#7871;|&#7877;|&#7875;|&#7869;|&#275;|&#7701;|&#7703;|&#277;|&#279;|&#235;|&#7867;|&#283;|&#517;|&#519;|&#7865;|&#7879;|&#553;|&#7709;|&#281;|&#7705;|&#7707;|&#583;|&#603;|&#477;|[\u0065\u24D4\uFF45\u00E8\u00E9\u00EA\u1EC1\u1EBF\u1EC5\u1EC3\u1EBD\u0113\u1E15\u1E17\u0115\u0117\u00EB\u1EBB\u011B\u0205\u0207\u1EB9\u1EC7\u0229\u1E1D\u0119\u1E19\u1E1B\u0247\u025B\u01DD])/g},{base:"f",letters:/(&#102;|&#9429;|&#65350;|&#7711;|&#402;|&#42876;|[\u0066\u24D5\uFF46\u1E1F\u0192\uA77C])/g},{base:"g",letters:/(&#103;|&#9430;|&#65351;|&#501;|&#285;|&#7713;|&#287;|&#289;|&#487;|&#291;|&#485;|&#608;|&#42913;|&#7545;|&#42879;|[\u0067\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\u1D79\uA77F])/g},{base:"h",letters:/(&#104;|&#9431;|&#65352;|&#293;|&#7715;|&#7719;|&#543;|&#7717;|&#7721;|&#7723;|&#7830;|&#295;|&#11368;|&#11382;|&#613;|[\u0068\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265])/g},{base:"hv",letters:/(&#405;|[\u0195])/g},{base:"i",letters:/(&#105;|&#9432;|&#65353;|&#236;|&#237;|&#238;|&#297;|&#299;|&#301;|&#239;|&#7727;|&#7881;|&#464;|&#521;|&#523;|&#7883;|&#303;|&#7725;|&#616;|&#305;|[\u0069\u24D8\uFF49\u00EC\u00ED\u00EE\u0129\u012B\u012D\u00EF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131])/g},{base:"ij",letters:/(&#307;|[\u0133])/g},{base:"j",letters:/(&#106;|&#9433;|&#65354;|&#309;|&#496;|&#585;|[\u006A\u24D9\uFF4A\u0135\u01F0\u0249])/g},{base:"k",letters:/(&#107;|&#9434;|&#65355;|&#7729;|&#489;|&#7731;|&#311;|&#7733;|&#409;|&#11370;|&#42817;|&#42819;|&#42821;|&#42915;|[\u006B\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3])/g},{base:"l",letters:/(&#108;|&#9435;|&#65356;|&#320;|&#314;|&#318;|&#7735;|&#7737;|&#316;|&#7741;|&#7739;|&#322;|&#410;|&#619;|&#11361;|&#42825;|&#42881;|&#42823;|[\u006C\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u0142\u019A\u026B\u2C61\uA749\uA781\uA747])/g},{base:"lj",letters:/(&#457;|[\u01C9])/g},{base:"m",letters:/(&#109;|&#9436;|&#65357;|&#7743;|&#7745;|&#7747;|&#625;|&#623;|[\u006D\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F])/g},{base:"n",letters:/(&#110;|&#9437;|&#65358;|&#505;|&#324;|&#241;|&#7749;|&#328;|&#7751;|&#326;|&#7755;|&#7753;|&#414;|&#626;|&#329;|&#42897;|&#42917;|&#331;|[\u006E\u24DD\uFF4E\u01F9\u0144\u00F1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5\u014B])/g},{base:"nj",letters:/(&#460;|[\u01CC])/g},{base:"o",letters:/(&#111;|&#9438;|&#65359;|&#242;|&#243;|&#244;|&#7891;|&#7889;|&#7895;|&#7893;|&#245;|&#7757;|&#557;|&#7759;|&#333;|&#7761;|&#7763;|&#335;|&#559;|&#561;|&#246;|&#555;|&#7887;|&#337;|&#466;|&#525;|&#527;|&#417;|&#7901;|&#7899;|&#7905;|&#7903;|&#7907;|&#7885;|&#7897;|&#491;|&#493;|&#248;|&#511;|&#596;|&#42827;|&#42829;|&#629;|[\u006F\u24DE\uFF4F\u00F2\u00F3\u00F4\u1ED3\u1ED1\u1ED7\u1ED5\u00F5\u1E4D\u022D\u1E4F\u014D\u1E51\u1E53\u014F\u022F\u0231\u00F6\u022B\u1ECF\u0151\u01D2\u020D\u020F\u01A1\u1EDD\u1EDB\u1EE1\u1EDF\u1EE3\u1ECD\u1ED9\u01EB\u01ED\u00F8\u01FF\u0254\uA74B\uA74D\u0275])/g},{base:"oe",letters:/(&#339;|[\u0153])/g},{base:"oi",letters:/(&#419;|[\u01A3])/g},{base:"ou",letters:/(&#547;|[\u0223])/g},{base:"oo",letters:/(&#42831;|[\uA74F])/g},{base:"p",letters:/(&#112;|&#9439;|&#65360;|&#7765;|&#7767;|&#421;|&#7549;|&#42833;|&#42835;|&#42837;|[\u0070\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755])/g},{base:"q",letters:/(&#113;|&#9440;|&#65361;|&#587;|&#42839;|&#42841;|[\u0071\u24E0\uFF51\u024B\uA757\uA759])/g},{base:"r",letters:/(&#114;|&#9441;|&#65362;|&#341;|&#7769;|&#345;|&#529;|&#531;|&#7771;|&#7773;|&#343;|&#7775;|&#589;|&#637;|&#42843;|&#42919;|&#42883;|[\u0072\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783])/g},{base:"s",letters:/(&#115;|&#9442;|&#65363;|&#347;|&#7781;|&#349;|&#7777;|&#353;|&#7783;|&#7779;|&#7785;|&#537;|&#351;|&#575;|&#42921;|&#42885;|&#7835;|&#383;|[\u0073\u24E2\uFF53\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B\u017F])/g},{base:"ss",letters:/(&#223;|[\u00DF])/g},{base:"t",letters:/(&#116;|&#9443;|&#65364;|&#7787;|&#7831;|&#357;|&#7789;|&#539;|&#355;|&#7793;|&#7791;|&#359;|&#429;|&#648;|&#11366;|&#42887;|[\u0074\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787])/g},{base:"th",letters:/(&#254;|[\u00FE])/g},{base:"tz",letters:/(&#42793;|[\uA729])/g},{base:"u",letters:/(&#117;|&#9444;|&#65365;|&#249;|&#250;|&#251;|&#361;|&#7801;|&#363;|&#7803;|&#365;|&#252;|&#476;|&#472;|&#470;|&#474;|&#7911;|&#367;|&#369;|&#468;|&#533;|&#535;|&#432;|&#7915;|&#7913;|&#7919;|&#7917;|&#7921;|&#7909;|&#7795;|&#371;|&#7799;|&#7797;|&#649;|[\u0075\u24E4\uFF55\u00F9\u00FA\u00FB\u0169\u1E79\u016B\u1E7B\u016D\u00FC\u01DC\u01D8\u01D6\u01DA\u1EE7\u016F\u0171\u01D4\u0215\u0217\u01B0\u1EEB\u1EE9\u1EEF\u1EED\u1EF1\u1EE5\u1E73\u0173\u1E77\u1E75\u0289])/g},{base:"v",letters:/(&#118;|&#9445;|&#65366;|&#7805;|&#7807;|&#651;|&#42847;|&#652;|[\u0076\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C])/g},{base:"vy",letters:/(&#42849;|[\uA761])/g},{base:"w",letters:/(&#119;|&#9446;|&#65367;|&#7809;|&#7811;|&#373;|&#7815;|&#7813;|&#7832;|&#7817;|&#11379;|[\u0077\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73])/g},{base:"x",letters:/(&#120;|&#9447;|&#65368;|&#7819;|&#7821;|[\u0078\u24E7\uFF58\u1E8B\u1E8D])/g},{base:"y",letters:/(&#121;|&#9448;|&#65369;|&#7923;|&#253;|&#375;|&#7929;|&#563;|&#7823;|&#255;|&#7927;|&#7833;|&#7925;|&#436;|&#591;|&#7935;|[\u0079\u24E8\uFF59\u1EF3\u00FD\u0177\u1EF9\u0233\u1E8F\u00FF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF])/g},{base:"z",letters:/(&#122;|&#9449;|&#65370;|&#378;|&#7825;|&#380;|&#382;|&#7827;|&#7829;|&#438;|&#549;|&#576;|&#11372;|&#42851;|[\u007A\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763])/g}];window.removeDiacritics=function(b){for(var a=0;a<defaultDiacriticsRemovalMap.length;a++){b=b.replace(defaultDiacriticsRemovalMap[a].letters,defaultDiacriticsRemovalMap[a].base)}return b};DG.sounds=SC.Object.extend({sounds:{create:{path:"../../../../static/dg/fr/cert/resources/sounds/create.wav"},drag:{path:"../../../../static/dg/fr/cert/resources/sounds/drag.wav"},mixup:{path:"../../../../static/dg/fr/cert/resources/sounds/mixup.wav"}},init:function(){arguments.callee.base.apply(this,arguments)},initAudio:function(){var a,b;for(a in this.sounds){if(this.sounds.hasOwnProperty(a)){b=this.sounds[a];if(b&&b.path&&!b.audio){b.audio=new Audio(b.path)}}}},playSound:function(a){var b=this.sounds[a];if(true){return}if(b&&b.path&&!b.audio){b.audio=new Audio(b.path)}if(b.audio){if(window.chrome){b.audio.load()}else{b.audio.currentTime=0}b.audio.play()}},playMixup:function(){this.playSound("mixup")},playCreate:function(){this.playSound("create")},playDrag:function(){this.playSound("drag")}}).create();DG.stat_constants={};DG.stat_constants.t_quantile_at_0975_for_df=[[1,12.7062],[2,4.30265],[3,3.18245],[4,2.77645],[5,2.57058],[6,2.44691],[7,2.36462],[8,2.306],[9,2.26216],[10,2.22814],[11,2.20099],[12,2.17881],[13,2.16037],[14,2.14479],[15,2.13145],[16,2.11991],[17,2.10982],[18,2.10092],[19,2.09302],[20,2.08596],[21,2.07961],[22,2.07387],[23,2.06866],[24,2.0639],[25,2.05954],[26,2.05553],[27,2.05183],[28,2.04841],[29,2.04523],[30,2.04227],[40,2.02108],[50,2.00856],[60,2.0003],[70,1.99444],[80,1.99006],[90,1.98667],[100,1.98397],[200,1.9719],[500,1.96472],[1000,1.96234],[2000,1.96115],[10000,1.9602],[100000,1.95999]];var singleComment=1;var multiComment=2;function stripWithoutWhitespace(){return""}function stripWithWhitespace(b,c,a){return b.slice(c,a).replace(/\S/g," ")}window.stripJsonComments=function(k,a){a=a||{};var l;var d;var g=false;var e=false;var f=0;var j="";var c=a.whitespace===false?stripWithoutWhitespace:stripWithWhitespace;for(var h=0;h<k.length;h++){l=k[h];d=k[h+1];if(!e&&l==='"'){var b=k[h-1]==="\\"&&k[h-2]!=="\\";if(!b){g=!g}}if(g){continue}if(!e&&l+d==="//"){j+=k.slice(f,h);f=h;e=singleComment;h++}else{if(e===singleComment&&l+d==="\r\n"){h++;e=false;j+=c(k,f,h);f=h;continue}else{if(e===singleComment&&l==="\n"){e=false;j+=c(k,f,h);f=h}else{if(!e&&l+d==="/*"){j+=k.slice(f,h);f=h;e=multiComment;h++;continue}else{if(e===multiComment&&l+d==="*/"){h++;e=false;j+=c(k,f,h+1);f=h+1;continue}}}}}}return j+(e?c(k.substr(f)):k.substr(f))};DG.Scene=DG.SvgScene={};DG.SvgScene.create=function(a){return document.createElementNS(this.svg,a)};DG.SvgScene.pathBasis=(function(){var c=[[1/6,2/3,1/6,0],[0,2/3,1/3,0],[0,1/3,2/3,0],[0,1/6,2/3,1/6]];function a(d,h,g,f,e){return{x:d[0]*h.left+d[1]*g.left+d[2]*f.left+d[3]*e.left,y:d[0]*h.top+d[1]*g.top+d[2]*f.top+d[3]*e.top}}var b=function(j,i,h,g){var f=a(c[1],j,i,h,g),e=a(c[2],j,i,h,g),d=a(c[3],j,i,h,g);return"C"+f.x+","+f.y+","+e.x+","+e.y+","+d.x+","+d.y};b.segment=function(k,j,i,h){var g=a(c[0],k,j,i,h),f=a(c[1],k,j,i,h),e=a(c[2],k,j,i,h),d=a(c[3],k,j,i,h);return"M"+g.x+","+g.y+"C"+f.x+","+f.y+","+e.x+","+e.y+","+d.x+","+d.y};return b}());DG.SvgScene.curveBasis=function(b){if(b.length<=2){return""}var e="",g=b[0],f=g,d=g,c=b[1];e+=this.pathBasis(g,f,d,c);for(var a=2;a<b.length;a++){g=f;f=d;d=c;c=b[a];e+=this.pathBasis(g,f,d,c)}e+=this.pathBasis(f,d,c,c);e+=this.pathBasis(d,c,c,c);return e};DG.TapHoldGesture=SC.TapGesture.extend({_sc_timerStartTouch:null,name:"tapHold",tapStartDelay:500,_sc_triggerTapStart:function(){this.start(this._sc_timerStartTouch);this.trigger(this._sc_timerStartTouch,this._sc_numberOfTouches);this._sc_isTapping=true},touchSessionStarted:function(a){arguments.callee.base.apply(this,arguments);this._sc_timerStartTouch=a},touchSessionEnded:function(){this._sc_cleanUpTouchSession(false)}});DG.TouchTooltips=(function(){var a=5000,c=8000,b={};return{showTouchTooltip:function(h,f,k,g){var e=h.identifier,i=f instanceof SC.View?f.get("layer"):f,d=DG.mainPage.getPath("mainPane.layer"),j=g||"top-start",l=new Tooltip(i,{boundariesElement:d,container:d,placement:j,trigger:"manual",title:k});DG.TouchTooltips.hideAllTouchTooltips();l.show();b[e]={touch:h,tooltip:l};DG.TouchTooltips.hideTouchTooltip(e,c);return e},hideTouchTooltip:function(g,e){var f=b[g],d=function(){var h=b[g];if(h){if(h.tooltip){h.tooltip.dispose();h.tooltip=null}h.timer=null;if(h.finished){delete b[g]}}};if(!f){return}if(f.timer){clearTimeout(f.timer);f.timer=null}if(e==null){e=a}if(e){f.timer=setTimeout(d,e)}else{d()}},clearTouchTooltip:function(e){var d=b[e];if(d){d.finished=true;DG.TouchTooltips.hideTouchTooltip(e);return true}return false},hideAllTouchTooltips:function(){DG.ObjectMap.forEach(b,function(d){DG.TouchTooltips.hideTouchTooltip(d,0)})}}})();DG.ValueAnimator=SC.Object.extend({valueHolder:null,incrementProvider:null,isAnimating:false,maxPerSecond:null,animate:function(){var e=this,c=this.get("maxPerSecond"),b=(DG.isNumeric(c)&&c>0)?(1000/c):50,a=this.get("valueHolder");function d(){var f=e.getPath("incrementProvider.increment");a.set("value",a.get("value")+f)}if(this.get("isAnimating")){this.endAnimation()}this.set("isAnimating",true);if(SC.none(this.animationTimer)){this.animationTimer=SC.Timer.schedule({action:d,repeats:YES,until:false})}this.animationTimer.set("interval",b);this.animationTimer.set("isPaused",NO)},endAnimation:function(){if(!SC.none(this.animationTimer)){this.animationTimer.set("isPaused",YES)}if(this.get("isAnimating")){this.set("isAnimating",false)}}});DG.ViewUtilities={kTitleBarHeight:25,kDragWidth:8,kBorderWidth:4,kGridSize:5,roundToGrid:function(a){return DG.ViewUtilities.kGridSize*Math.round(a/DG.ViewUtilities.kGridSize)},floorToGrid:function(a){return DG.ViewUtilities.kGridSize*Math.floor(a/DG.ViewUtilities.kGridSize)},horizontalPadding:function(){return 2*DG.ViewUtilities.kDragWidth},verticalPadding:function(){return DG.ViewUtilities.kDragWidth+DG.ViewUtilities.kTitleBarHeight+DG.ViewUtilities.kBorderWidth},windowToViewCoordinates:function(d,c){var b;do{b=c.get("frame");d.x-=b.x;d.y-=b.y;c=c.parentView}while(!SC.none(c));var a=$("#codap").offset();return{x:d.x-a.left,y:d.y-a.top}},viewToWindowCoordinates:function(d,c){var b;do{b=c.get("frame");d.x+=b.x;d.y+=b.y;c=c.parentView}while(!SC.none(c));var a=$("#codap").offset();return{x:d.x+a.left,y:d.y+a.top}},convertViewLayoutToAbsolute:function(b){var a=b.get("layout");if(SC.none(a.left)||SC.none(a.top)||SC.none(a.width)||SC.none(a.height)){var c=b.get("layer");if(!SC.none(c)){b.set("layout",{left:c.offsetLeft,top:c.offsetTop,width:c.offsetWidth,height:c.offsetHeight})}}},findEmptyLocationForRect:function(k,d,f,e,i){var l=DG.ViewUtilities.kGridSize,a=(i==="bottom"),c={x:l+f.x,y:(a?d.height-k.height-l:l)+f.y},h=false;function j(n,m){var o=(!isNaN(n.x)&&!isNaN(n.y))&&!(m.x>n.x+n.width||m.x+m.width<n.x||m.y>n.y+n.height||m.y+m.height<n.y);return o}function g(m){return !e.every(function(n){return !j(n,{x:m.x,y:m.y,width:k.width,height:k.height})})}function b(m){return !e.every(function(n){return !(m.x===n.x&&m.y===n.y)})}if(e.length===0){return c}while(!h&&c.y+k.height<f.y+d.height&&c.y>=f.y+l){c.x=f.x+l;while(!h){if(g(c)){c.x+=l;if(c.x+k.width>f.x+d.x+d.width){break}}else{h=true}}if(!h){c.y+=(a?-l:l)}}if(!h){c={x:f.x+Math.max(this.kGridSize,Math.round((d.width-k.width)/2)),y:f.y+Math.max(this.kGridSize,Math.round((d.height-k.height)/2))};while(!h){if(!b(c)){h=true}else{c={x:c.x+l,y:c.y+this.kTitleBarHeight}}}}return c},normalFormForRect:function(a){return{left:Math.min(a.left,a.right),top:Math.max(a.bottom,a.top),right:Math.max(a.left,a.right),bottom:Math.min(a.bottom,a.top)}},ptInRect:function(a,b){return(a.x>=b.x)&&(a.x<=b.x+b.width)&&(a.y>=b.y)&&(a.y<=b.y+b.height)},componentViewForView:function(a){while(a&&!(a instanceof DG.ComponentView)){a=a.get("parentView")}return a}};DG.AlertPane={processArgs:function(a){if(a.localize){if(!SC.empty(a.message)){a.message=SC.String.loc(a.message)}if(!SC.empty(a.description)){a.description=SC.String.loc(a.description)}if(!SC.empty(a.caption)){a.caption=SC.String.loc(a.caption)}a.localize=false}return a},show:function(a){SC.AlertPane.show(DG.AlertPane.processArgs(a))},warn:function(a){SC.run(function(){SC.AlertPane.warn(DG.AlertPane.processArgs(a))})},info:function(a){SC.AlertPane.info(DG.AlertPane.processArgs(a))},error:function(a){SC.AlertPane.error(DG.AlertPane.processArgs(a))},plain:function(a){SC.AlertPane.plain(DG.AlertPane.processArgs(a))}};DG.TextFieldView=SC.TextFieldView.extend({isTextSelectable:YES,beginEditing:function(){if(DG.globalEditorLock.isActive(this)){return arguments.callee.base.apply(this,arguments)}if(!DG.globalEditorLock.commitCurrentEdit()){return false}var b=this.get("value"),a=arguments.callee.base.apply(this,arguments);if(a){this._prevValue=b;DG.globalEditorLock.activate(this)}return a},commitEditing:function(){var a=arguments.callee.base.apply(this,arguments);if(a&&DG.globalEditorLock.isActive(this)){DG.globalEditorLock.deactivate(this)}return a},discardEditing:function(){this.set("value",this._prevValue||"");this.resignFirstResponder();if(DG.globalEditorLock.isActive(this)){DG.globalEditorLock.deactivate(this)}return true},completeEditing:function(){this.$input().blur()},commitCurrentEdit:function(){return this.commitEditing()},cancelCurrentEdit:function(){return this.discardEditing()},setSelection:function(c,b){if(SC.none(c)){return}var a=b||c;if(a<c){a=c}this.set("selection",SC.TextSelection.create({start:c,end:a}))},replaceSelectionWithString:function(c){var a=this.get("value"),i=this.get("selection"),e=i.get("start"),h=i.get("end"),d=a.substr(0,e),g=a.substr(h),f=d+c+g,b=e+c.length;this.set("value",f);if(!this.get("focused")){this._disableNextSelectRoot=true}this.setSelection(b)}});sc_require("views/text_field_view");DG.FormulaRichEditView=DG.TextFieldView.extend((function(){function d(f){if((f==='"')||(f==="'")){return true}if((f>="0")&&(f<="9")){return true}return DG.Formula.identifierRegExp.test(f)}function b(f){return/\(\)$/.test(f)}function c(n,l,k){var q=k.from||l.from,f=k.to||l.to,h={line:f.line,ch:f.ch+1},i=n.getRange(f,h),g=(k.category==="Functions"),o=g&&(i==="("),j=g?k.text:DG.Attribute.canonicalizeName(k.text,true),m;if(k.text!==j){j="`"+k.text+"`"}m=o?j.slice(0,j.length-2):j;n.replaceRange(m,q,f,"complete");if(g){var p=n.getCursor();n.setCursor(p.line,o?p.ch+1:p.ch-1)}}function a(k,j){var g=(k.category==="Functions"),f=(j.category==="Functions"),i=removeDiacritics(k.text).toLowerCase(),h=removeDiacritics(j.text).toLowerCase();if(!g&&f){return -1}if(g&&!f){return 1}if(i<h){return -1}if(i>h){return 1}return 0}function e(j,n){var l=j.getCursor(),k=j.getLine(l.line),f=l.ch,h=f;while(h<k.length&&d(k.charAt(h))){++h}while(f&&d(k.charAt(f-1))){--f}var g=f!==h&&k.slice(f,h),i=g?new RegExp("^"+DG.StringUtilities.escapeRegExp(g),"i"):null,m={list:(!g||!n.completionData?[]:n.completionData.reduce(function(o,p){if(p&&p.label&&p.label.match(i)){o.push({text:p.value,category:p.category.key,className:"dg-wants-touch",hint:c})}return o},[])).sort(a),from:CodeMirror.Pos(l.line,f),to:CodeMirror.Pos(l.line,h)};if((m.list.length===1)&&(m.list[0].text===g)){m.list=[]}return m}return{isTextArea:true,autoCorrect:false,autoCapitalize:false,classNames:["dg-wants-touch"],names:[],_disableNextSelectRoot:false,init:function(){arguments.callee.base.apply(this,arguments);this.set("isTextArea",true)},didAppendToDocument:function(){var h=this.$("textarea"),f=h[0],g=this.get("hint");if(g){h.attr("placeholder",g.loc())}this._cm=CodeMirror.fromTextArea(f,{lineWrapping:true,extraKeys:{Tab:false},mode:"codapFormula",hintOptions:{completeSingle:false,completionData:this.get("completionData"),hint:e,extraKeys:{Esc:function(i,j){j.close();if(this._lastEscKeyEvent){this._lastEscKeyEvent.stopPropagation();this._lastEscKeyEvent=null}return true}}}});this.addSemanticClasses(this._cm);if(this._cm.display&&this._cm.display.scroller){this._cm.display.scroller.addEventListener("touchend",function(i){i.preventDefault();i.stopImmediatePropagation()})}this._cm.on("keydown",function(i,j){if(j.keyCode===SC.Event.KEY_ESC){this._lastEscKeyEvent=j}});this._cm.on("changes",function(i,j){this.addSemanticClasses(i);SC.run(function(){this._cm.save();this.fieldValueDidChange()}.bind(this))}.bind(this));this._cm.on("inputRead",function(i,j){if(DG.Formula.identifierRegExp.test(j.text)){i.showHint()}});$(".CodeMirror").css({height:"100%"})},becomeFirstResponder:function(){if(this._cm){this._cm.focus()}},addSemanticClasses:function(f){this.$(".cm-variable, .cm-function").each(function(m,j){var k=this.className.split(" ").filter(function(i){return !/codap-[A-Za-z]*/.test(i)}),g=k.indexOf("cm-variable")>=0,h=k.indexOf("cm-function")>=0,o=$(j).text(),n=o?o.length:0,q=f.options.hintOptions&&f.options.hintOptions.completionData,l,p=q&&q.length;if(g&&(n>2)&&(o[0]==="`")&&(o[n-1]==="`")){o=o.substring(1,n-1)}for(l=0;l<p;++l){if((g&&(o===q[l].value))||(h&&(o+"()"===q[l].value))){k.push("codap-"+q[l].category.key)}}this.className=k.join(" ")})},formulaExpression:function(f,h){if(h===undefined){var g=this._cm.getValue();return g?g.trim():""}else{this._cm.setValue(h||"")}}.property("value"),replaceSelectionWithString:function(g){this._cm.replaceSelection(g);if(b(g)){var h=this._cm.getCursor(),j=this._cm.getLine(h.line),i=h.ch-1,f=i;while(i&&(j.charAt(i-1)!=="(")){--i}this._cm.setSelection({line:h.line,ch:i},{line:h.line,ch:f})}}}})());sc_require("formula/formula_context");sc_require("views/formula_rich_edit_view");DG.AttributeFormulaView=SC.PalettePane.extend({isModal:YES,layout:{width:400,height:180,centerX:0,centerY:0},contentView:SC.View.extend({classNames:"dg-formula-dialog",childViews:"attrName equalsLabel formula operandPopup functionPopup apply cancel resizeHandle".w(),attrName:SC.TextFieldView.design({layout:{top:5,left:5,right:25,height:24},value:"",spellCheckEnabled:false,leftAccessoryView:SC.LabelView.create({layout:{left:1,width:95,height:22,centerY:0},value:"DG.AttrFormView.attrNamePrompt",backgroundColor:"lightgray",localize:true})}),equalsLabel:SC.LabelView.extend({layout:{top:5,right:5,width:12,height:24},value:"="}),formula:DG.FormulaRichEditView.design({layout:{top:34,left:5,right:5,bottom:74},value:"",isTextArea:true,spellCheckEnabled:false,hint:"",leftAccessoryView:SC.LabelView.create({layout:{left:1,width:55,bottom:1,top:1},value:"DG.AttrFormView.formulaPrompt",backgroundColor:"lightgray",localize:true}),classNames:"dg-formula-dialog-input-field"}),operandPopup:SC.PopupButtonView.extend({layout:{bottom:44,left:5,width:140,height:24},localize:true,title:"DG.AttrFormView.operandMenuTitle",menu:SC.MenuPane.extend({layout:{width:200},rawItems:function(b,a){var c=0;if(a!==undefined){var d=a.map(function(e){if(c<e.length){c=e.length}return{title:e,isSeparator:e==="--"}});this.set("items",d)}this.adjust("width",40+10*c)}.property()})}),functionPopup:SC.PopupButtonView.extend({layout:{bottom:44,left:150,width:170,height:24},localize:true,title:"DG.AttrFormView.functionMenuTitle",mouseDown:function(){if(this._fbDiv&&DG.React.Components.FunctionBrowser){var b=function(d,c,e){this.getPath("parentView.formula").replaceSelectionWithString("%@(%@)".fmt(d,c))}.bind(this),a=DG.React.Components.FunctionBrowser({anchor:this.get("layer"),container:DG.mainPage.mainPane.get("layer"),categorizedFunctionInfo:DG.functionRegistry.get("categorizedFunctionInfo"),onSelect:b});DG.React.toggleRender(this._fbDiv,a)}},action:null,didAppendToDocument:function(){this._fbDiv=document.createElement("div");document.body.appendChild(this._fbDiv)}}),apply:SC.ButtonView.design({layout:{bottom:5,right:25,height:24,width:90},titleMinWidth:0,title:"DG.AttrFormView.applyBtnTitle",target:null,action:null,toolTip:"",localize:true,isDefault:true,classNames:"dg-formula-dialog-apply"}),cancel:SC.ButtonView.design({layout:{bottom:5,right:135,height:24,width:90},titleMinWidth:0,title:"DG.AttrFormView.cancelBtnTitle",target:null,action:null,toolTip:"DG.AttrFormView.cancelBtnTooltip",localize:true,isCancel:true,classNames:"dg-formula-dialog-cancel"}),resizeHandle:SC.View.extend({classNames:["resize-handle"],layout:{right:0,bottom:0,width:20,height:20},render:function(a){a.begin().addClass("handle-image").end()},mouseDown:function(a){var c=this.get("parentView"),b=c.get("parentView"),d=c.get("borderFrame");b.beginLiveResize();this._initialX=a.clientX;this._initialY=a.clientY;this._initialWidth=d.width;this._initialHeight=d.height;return true},mouseDragged:function(c){var e=this.get("parentView"),d,b,a,f;a=c.clientX-this._initialX;f=c.clientY-this._initialY;d=Math.max(400,this._initialWidth+a);b=Math.max(180,this._initialHeight+f);e.adjust({width:d,height:b})},mouseUp:function(a){var c=this.get("parentView"),b=c.get("parentView");b.endLiveResize();delete this._initialX;delete this._initialY;c.set("transitionAdjust",SC.View.SMOOTH_ADJUST);return true}})}),attributeName:function(a,b){return b===undefined?this.getPath("contentView.attrName.value"):this.setPath("contentView.attrName.value",b)}.property(),formula:function(a,b){return b===undefined?this.getPath("contentView.formula.formulaExpression"):this.setPath("contentView.formula.formulaExpression",b)}.property(),init:function(){arguments.callee.base.apply(this,arguments);this.setPath("contentView.cancel.target",this);this.setPath("contentView.cancel.action","close")},keyDown:function(a){if(a.keyCode===SC.Event.KEY_ESC){this.close();return YES}return NO},userSelectedOperand:function(){var a=this.getPath("contentView.operandPopup.menu.selectedItem.title");if(!SC.empty(a)){var c=DG.Attribute.canonicalizeName(a,true),b=this.getPath("contentView.formula");if(a!==c){a="`"+a+"`"}if(b){b.becomeFirstResponder();b.replaceSelectionWithString(a)}}this.setPath("contentView.operandPopup.menu.selectedItem",null)}.observes(".contentView.operandPopup.menu.selectedItem"),close:function(){this.remove();this.destroy()}});DG.AttributeFormulaView.buildOperandsMenuAndCompletionData=function(h){var b=h.get("collections"),c=DG.globalsController.getGlobalValueNames(),j=[],e=[],g={key:"Attributes",name:"DG.TableController.newAttrDialog.AttributesCategory".loc()},a={key:"Special",name:"DG.TableController.newAttrDialog.SpecialCategory".loc()},l={key:"Globals",name:"DG.TableController.newAttrDialog.GlobalsCategory".loc()},i={key:"Constants",name:"DG.TableController.newAttrDialog.ConstantsCategory".loc()},d={key:"Functions",name:"DG.TableController.newAttrDialog.FunctionsCategory".loc()};function f(n,m){j=j.concat(n.map(function(p){var o=removeDiacritics(p),q=o.indexOf("(");if(q>0){o=o.substr(0,q)}return{label:o,value:p,category:m}}))}function k(n,m){if(!n||!n.length){return}if(e.length){e.push("--")}e=e.concat(n.sort());if(m&&m.name){f(n,m)}}b.forEach(function(m){var n=h.getCollectionByName(m.name);k(n.collection.getAttributeNames(),g)});if(a.name!==i.name){k(["caseIndex"],a)}k(c,l);if(a.name===i.name){k(["caseIndex"],a)}k(["e","π","true","false"]);j.push({label:"e",value:"e",category:i});j.push({label:"π",value:"π",category:i,fontFamily:"Symbol,serif",fontSize:"130%"});j.push({label:"pi",value:"π",category:i,fontFamily:"Symbol,serif",fontSize:"130%"});j.push({label:"true",value:"true",category:i});j.push({label:"false",value:"false",category:i});f(DG.functionRegistry.get("namesWithParentheses"),d);return{operandsMenu:e,completionData:j}};DG.CreateAttributeFormulaView=function(e){var g=DG.AttributeFormulaView.create(e||{}),f={attrNamePrompt:"attrName.leftAccessoryView.value",attrNameValue:"attrName.value",attrNameHint:"attrName.hint",attrNameIsEnabled:"attrName.isEnabled",formulaPrompt:"formula.leftAccessoryView.value",formulaValue:"formula.value",formulaExpression:"formula.formulaExpression",formulaCompletions:"formula.completionData",formulaNames:"formula.names",formulaHint:"formula.hint",formulaIsEnabled:"formula.isEnabled",formulaOperands:"operandPopup.menu.rawItems",applyTitle:"apply.title",applyTarget:"apply.target",applyAction:"apply.action",applyTooltip:"apply.toolTip",cancelTitle:"cancel.title",cancelTooltip:"cancel.toolTip"},d=g.get("contentView"),c=d.attrName,a=d.formula;DG.ObjectMap.forEach(e,function(h,i){var j=f[h];if(!SC.empty(j)){d.setPath(j,i)}});if(!d.getPath("apply.action")){d.setPath("apply.action",d.getPath("cancel.action"))}g.append();var b=c.get("isEnabled")?c:a;b.becomeFirstResponder();return g};var kMinComponentSize=50,kMaxComponentSize=Number.MAX_VALUE,kRightBorderCursor=SC.Cursor.create({cursorStyle:SC.E_RESIZE_CURSOR}),kBottomBorderCursor=SC.Cursor.create({cursorStyle:SC.S_RESIZE_CURSOR}),kLeftBorderCursor=SC.Cursor.create({cursorStyle:SC.W_RESIZE_CURSOR}),kBottomLeftBorderCursor=SC.Cursor.create({cursorStyle:SC.SW_RESIZE_CURSOR}),kBottomRightBorderCursor=SC.Cursor.create({cursorStyle:SC.SE_RESIZE_CURSOR});DG.DragBorderView=SC.View.extend((function(){return{cursor:function(){if(this.canBeDragged()){return this.dragCursor}else{return null}}.property("dragCursor").cacheable(),isResizableDidChange:function(){this.set("isVisible",this.canBeDragged())}.observes("parentView.isResizable"),mouseDown:function(b){if(b.button===2||b.ctrlKey){return NO}DG.globalEditorLock.commitCurrentEdit();var a=this.viewToDrag(),c=a.get("parentView");DG.ViewUtilities.convertViewLayoutToAbsolute(a);a.select();if(!this.canBeDragged()){return NO}if(c.coverUpComponentViews){c.coverUpComponentViews("cover")}var d=this.viewToDrag().get("layout");this._mouseDownInfo={pageX:b.pageX,pageY:b.pageY,left:d.left,top:d.top,height:d.height,width:d.width};a.get("controller").updateModelLayout();return YES},mouseUp:function(d){var f=this.viewToDrag(),c=f.getPath("controller.model.id"),g=f.get("parentView"),b=this._mouseDownInfo,e=f.get("layout"),a=(!SC.none(this.getPath("cursor.cursorStyle")))&&this.getPath("cursor.cursorStyle").indexOf("-resize")!==-1;this.mouseDragged(d);this._mouseDownInfo=null;if(g.coverUpComponentViews){g.coverUpComponentViews("uncover");g.updateFrame()}if((b.left!==e.left)||(b.top!==e.top)||(b.height!==e.height)||(b.width!==e.width)){DG.UndoHistory.execute(DG.Command.create({name:(a?"component.resize":"component.move"),undoString:(a?"DG.Undo.componentResize":"DG.Undo.componentMove"),redoString:(a?"DG.Redo.componentResize":"DG.Redo.componentMove"),executeNotification:{action:"notify",resource:"component",values:{operation:a?"resize":"move",type:f.getPath("controller.model.type"),id:c,title:f.getPath("controller.model.title")}},log:'%@ component "%@"'.fmt((a?"Resized":"Moved"),f.get("title")),_componentId:f.getPath("controller.model.id"),_controller:function(){return DG.currDocumentController().componentControllersMap[this._componentId]},_oldLayout:null,execute:function(){this._oldLayout=this._controller().updateModelLayout();if(!this._oldLayout){this.causedChange=false}},undo:function(){if(!f){return}var h=SC.clone(this._oldLayout);if(f.isMinimized()){this._oldHeight=this._oldLayout.height;h.height=25}f.animate(h,{duration:0.4,timing:"ease-in-out"},function(){f._view_layer.style.transition="";this._oldLayout=this._controller().revertModelLayout(h);g.updateFrame()}.bind(this));if(DG.KEEP_IN_BOUNDS_PREF){f.configureViewBoundsLayout({height:h.height,width:h.width,x:h.left,y:h.top})}},redo:function(){var i=SC.clone(this._oldLayout);var j=DG.currDocumentController();var h=j.componentControllersMap[c];if(h){f=h.get("view");if(f.isMinimized()){i.height=25}f.animate(i,{duration:0.4,timing:"ease-in-out"},function(){f._view_layer.style.transition="";this._oldLayout=this._controller().revertModelLayout(this._oldLayout);g.updateFrame()}.bind(this));if(DG.KEEP_IN_BOUNDS_PREF){f.configureViewBoundsLayout({height:i.height,width:i.width,x:i.left,y:i.top})}}else{f=null}}}))}if(DG.KEEP_IN_BOUNDS_PREF){DG.currDocumentController().computeScaleBounds()}return YES},mouseDragged:function(a){var b=this._mouseDownInfo;if(b){this.dragAdjust(a,b);return YES}else{return NO}},touchStart:function(a){return this.mouseDown(a)},touchEnd:function(a){return this.mouseUp(a)},touchesDragged:function(a,b){return this.mouseDragged(a)},dragAdjust:function(a,b){},viewToDrag:function(){return DG.ComponentView.findComponentViewParent(this)},getContainerWidth:function(){return $("#codap").width()},getContainerHeight:function(){var a=this.viewToDrag();while(!SC.none(a.parentView.parentView)){a=a.parentView}return $("#codap").height()-a.get("frame").y}}}()));DG.DragLeftBorderView=DG.DragBorderView.extend({dragCursor:kLeftBorderCursor,canBeDragged:function(){var a=this.getPath("parentView.isWidthResizable");return a},dragAdjust:function(f,b){var e=this.parentView.get("contentMaxWidth")||kMaxComponentSize,i=this.get("contentMinWidth")||kMinComponentSize,a=this.getContainerWidth();if(DG.KEEP_IN_BOUNDS_PREF){f.pageX=Math.max(0,f.pageX)}var d=DG.ViewUtilities.roundToGrid(b.width-(f.pageX-b.pageX)),c;d=Math.min(Math.max(d,i),e);c=b.left+b.width-d;if(c<a-i){this.parentView.adjust("width",d);this.parentView.adjust("left",c)}if(DG.KEEP_IN_BOUNDS_PREF){var h=DG.currDocumentController().get("inBoundsScaling"),g=h.scaleFactor;this.parentView.originalLayout.width=d/g;this.parentView.originalLayout.left=c/g}}});DG.DragRightBorderView=DG.DragBorderView.extend({dragCursor:kRightBorderCursor,canBeDragged:function(){var a=this.getPath("parentView.isWidthResizable");return a},dragAdjust:function(g,b){var j=this.get("contentMinWidth")||kMinComponentSize,d=Math.max(g.pageX,j),e=DG.ViewUtilities.roundToGrid(b.width+(d-b.pageX)),f=this.parentView.get("contentMaxWidth")||kMaxComponentSize,a=this.getContainerWidth();if(DG.KEEP_IN_BOUNDS_PREF){var c=this.parentView.getInspectorDimensions();f=Math.min(f,a-(b.left+c.width))}e=Math.min(Math.max(e,j),f);this.parentView.adjust("width",e);if(DG.KEEP_IN_BOUNDS_PREF){var i=DG.currDocumentController().get("inBoundsScaling"),h=i.scaleFactor;this.parentView.originalLayout.width=e/h}}});DG.DragBottomBorderView=DG.DragBorderView.extend({dragCursor:kBottomBorderCursor,canBeDragged:function(){var a=this.getPath("parentView.isHeightResizable");return a},dragAdjust:function(b,h){var e=this.get("contentMinHeight")||kMinComponentSize,a=this.get("contentMaxHeight")||kMaxComponentSize,g=h.height+(b.pageY-h.pageY),d=this.getContainerHeight();if(DG.KEEP_IN_BOUNDS_PREF){a=Math.min(a,d-h.top)}g=DG.ViewUtilities.roundToGrid(Math.min(Math.max(g,e),a));this.parentView.adjust("height",g);if(DG.KEEP_IN_BOUNDS_PREF){var f=DG.currDocumentController().get("inBoundsScaling"),c=f.scaleFactor;this.parentView.originalLayout.height=g/c}}});DG.DragBottomLeftBorderView=DG.DragBorderView.extend({dragCursor:kBottomLeftBorderCursor,canBeDragged:function(){var a=this.getPath("parentView.isWidthResizable")||this.getPath("parentView.isHeightResizable");return a},dragAdjust:function(j,b){var m=this.get("contentMinHeight")||kMinComponentSize,g=this.get("contentMaxHeight")||kMaxComponentSize,n=this.get("contentMinWidth")||kMinComponentSize,e=Math.max(j.pageX,n),f=DG.ViewUtilities.roundToGrid(b.width-(j.pageX-b.pageX)),i=DG.ViewUtilities.roundToGrid(b.height+(j.pageY-b.pageY)),h=this.parentView.get("contentMaxWidth")||kMaxComponentSize,a=this.getContainerWidth(),c=this.getContainerHeight();if(DG.KEEP_IN_BOUNDS_PREF){g=c-b.top;var d=this.parentView.getInspectorDimensions();h=Math.min(h,a-(b.left+d.width))}if(!this.getPath("parentView.isWidthResizable")){f=b.width}else{f=Math.min(Math.max(f,n),h);e=b.left+b.width-f;if(e<a-n){this.parentView.adjust("width",f);this.parentView.adjust("left",e)}}if(!this.getPath("parentView.isHeightResizable")){i=b.height}else{i=Math.min(Math.max(i,m),g);this.parentView.adjust("height",i)}if(DG.KEEP_IN_BOUNDS_PREF){var l=DG.currDocumentController().get("inBoundsScaling"),k=l.scaleFactor;this.parentView.originalLayout.height=i/k;this.parentView.originalLayout.width=f/k}}});DG.DragBottomRightBorderView=DG.DragBorderView.extend({dragCursor:kBottomRightBorderCursor,canBeDragged:function(){var a=this.getPath("parentView.isWidthResizable")||this.getPath("parentView.isHeightResizable");return a},dragAdjust:function(j,b){var m=this.get("contentMinHeight")||kMinComponentSize,g=this.get("contentMaxHeight")||kMaxComponentSize,n=this.get("contentMinWidth")||kMinComponentSize,e=Math.max(j.pageX,n),f=DG.ViewUtilities.roundToGrid(b.width+(e-b.pageX)),i=DG.ViewUtilities.roundToGrid(b.height+(j.pageY-b.pageY)),h=this.parentView.get("contentMaxWidth")||kMaxComponentSize,a=this.getContainerWidth(),c=this.getContainerHeight();if(DG.KEEP_IN_BOUNDS_PREF){g=c-b.top;var d=this.parentView.getInspectorDimensions();h=Math.min(h,a-(b.left+d.width))}if(!this.getPath("parentView.isWidthResizable")){f=b.width}else{f=Math.min(Math.max(f,n),h);this.parentView.adjust("width",f)}if(!this.getPath("parentView.isHeightResizable")){i=b.height}else{i=Math.min(Math.max(i,m),g);this.parentView.adjust("height",i)}if(DG.KEEP_IN_BOUNDS_PREF){var l=DG.currDocumentController().get("inBoundsScaling"),k=l.scaleFactor;this.parentView.originalLayout.height=i/k;this.parentView.originalLayout.width=f/k}}});DG.TooltipEnabler={localize:true,toolTipDidChange:function(){this.updateLayer()}.observes("displayToolTip"),render:function(b){arguments.callee.base.apply(this,arguments);var a=this.get("displayToolTip");if(a){b.setAttr("title",a)}}};sc_require("views/mouse_and_touch_view");sc_require("views/tooltip_enabler");DG.TitleBarCloseButton=SC.View.extend(DG.MouseAndTouchView,DG.TooltipEnabler,(function(){return{classNames:"dg-close-icon".w(),toolTip:"DG.Component.closeComponent.toolTip",isSelected:false,classNameBindings:["isSelected:dg-close-icon-selected"],allowParent:NO,init:function(){arguments.callee.base.apply(this,arguments);if(!SC.platform.touch){this.set("isVisible",true);this.invokeLater(function(){this.set("isVisible",false)}.bind(this),1)}},doIt:function(){var a=this.parentView.viewToDrag().getPath("controller.model.id"),e=DG.currDocumentController().componentControllersMap[a],b=e.get("shouldConfirmClose"),f=e.get("confirmCloseMessage")||"DG.Component.closeComponent.confirmCloseMessage",c=e.get("confirmCloseDescription")||"DG.Component.closeComponent.confirmCloseDescription";if(e.toggleViewVisibility){e.toggleViewVisibility()}else{var d=function(){DG.closeComponent(a)}.bind(this);if(b){DG.AlertPane.warn({message:f,description:c,buttons:[{title:"DG.Component.closeComponent.okButtonTitle",action:d,localize:YES},{title:"DG.Component.closeComponent.cancelButtonTitle",localize:YES,isCancel:YES,isDefault:YES}],localize:YES})}else{DG.closeComponent(a)}}},closeComponent:function(c,a){if(a.toggleViewVisibility){a.toggleViewVisibility()}else{var b;a.willCloseComponent();DG.UndoHistory.execute(DG.Command.create({name:"component.close",undoString:"DG.Undo.component.close",redoString:"DG.Redo.component.close",_componentId:c,_controller:function(){return DG.currDocumentController().componentControllersMap[this._componentId]},_model:null,execute:function(){a=this._controller();var e=a.get("view"),d=e.get("parentView");this.log="closeComponent: %@".fmt(e.get("title"));this._model=a.get("model");a.willSaveComponent();if(a.saveGameState){a.saveGameState(function(f){if(f&&f.success){b=f.state}SC.run(function(){if(d.removeComponentView){d.removeComponentView(e)}})})}else{if(d.removeComponentView){d.removeComponentView(e)}}},undo:function(){DG.currDocumentController().createComponentAndView(this._model);a=this._controller();if(a.restoreGameState&&b){a.restoreGameState({gameState:b})}}}))}}}}()));DG.TitleBarMinimizeButton=SC.View.extend(DG.MouseAndTouchView,DG.TooltipEnabler,(function(){return{classNames:"dg-min-icon".w(),allowParent:NO,init:function(){arguments.callee.base.apply(this,arguments);if(!SC.platform.touch){this.set("isVisible",true);this.invokeLater(function(){this.set("isVisible",false)}.bind(this),1)}},isSelected:false,classNameBindings:["isSelected:dg-min-icon-selected"],toolTip:"DG.Component.minimizeComponent.toolTip",doIt:function(){var a=this.parentView.viewToDrag();DG.UndoHistory.execute(DG.Command.create({name:"component.minimize",undoString:"DG.Undo.component.minimize",redoString:"DG.Redo.component.minimize",log:(a.get("isMinimized")?"Expanded component":"Minimized component"),executeNotification:{action:"notify",resource:"component",values:{operation:"toggle minimize component",type:a.getPath("model.type")}},execute:function(){a.toggleMinimization()},undo:function(){this.execute()}}))}}}()));DG.TitleBarUndoRedoButton=SC.View.extend(DG.MouseAndTouchView,DG.TooltipEnabler,(function(){return{localize:true,isVisibleBinding:SC.Binding.oneWay("DG.UndoHistory.enabled"),isVisible:true}}()));DG.TitleBarUndoButton=DG.TitleBarUndoRedoButton.extend((function(){return{toolTip:function(){var a=this.get("nextUndoCommand");return(a?a.get("undoString"):"DG.mainPage.mainPane.undoButton.toolTip")}.property("nextUndoCommand"),nextUndoCommandBinding:SC.Binding.oneWay("DG.UndoHistory.nextUndoCommand"),isEnabledBinding:SC.Binding.oneWay("DG.UndoHistory.canUndo"),classNames:"dg-undo-icon".w(),doIt:function(){DG.UndoHistory.undo()}}}()));DG.TitleBarRedoButton=DG.TitleBarUndoRedoButton.extend((function(){return{toolTip:function(){var a=this.get("nextRedoCommand");return(a?a.get("redoString"):"DG.mainPage.mainPane.redoButton.toolTip")}.property("nextRedoCommand"),nextRedoCommandBinding:SC.Binding.oneWay("DG.UndoHistory.nextRedoCommand"),isEnabledBinding:SC.Binding.oneWay("DG.UndoHistory.canRedo"),classNames:"dg-redo-icon".w(),doIt:function(){DG.UndoHistory.redo()}}}()));DG.CaseCardToggleButton=SC.View.extend(DG.MouseAndTouchView,DG.TooltipEnabler,(function(){return{classNames:"dg-card-icon".w(),toolTip:"DG.DocumentController.toggleToCaseCard",isVisible:true,doIt:function(){var b=this.parentView.viewToDrag(),a=[{title:"DG.DocumentController.toggleToCaseCard".loc()}];DG.MenuPane.create({classNames:"dg-attributes-popup".w(),layout:{width:200,height:150},items:a,selectedItemDidChange:function(){DG.UndoHistory.execute(DG.Command.create({name:"toggle.toCaseCard",undoString:"DG.Undo.component.toggleTableToCard",redoString:"DG.Redo.component.toggleTableToCard",log:"Toggle case table to case card",executeNotification:{action:"notify",resource:"component",values:{operation:"toggle table to card",type:"DG.CaseTable"}},execute:function(){DG.currDocumentController().toggleTableToCard(b)},undo:function(){var e=DG.currDocumentController(),c=b.getPath("controller.dataContext"),d=e.tableCardRegistry.getCardView(c);e.toggleCardToTable(d)}}))}.observes("selectedItem")}).popup(this,[0,-20,SC.POSITION_BOTTOM])}}}()));DG.CaseTableToggleButton=SC.View.extend(DG.MouseAndTouchView,DG.TooltipEnabler,(function(){return{classNames:"dg-table-icon".w(),toolTip:"DG.DocumentController.toggleToCaseTable",isVisible:true,doIt:function(){var b=this.parentView.viewToDrag(),a=[{title:"DG.DocumentController.toggleToCaseTable".loc()}];DG.MenuPane.create({classNames:"dg-attributes-popup".w(),layout:{width:200,height:150},items:a,selectedItemDidChange:function(){DG.UndoHistory.execute(DG.Command.create({name:"toggle.toCaseTable",undoString:"DG.Undo.component.toggleCardToTable",redoString:"DG.Redo.component.toggleCardToTable",log:"Toggle case card to case table",executeNotification:{action:"notify",resource:"component",values:{operation:"toggle card to table",type:"DG.CaseCard"}},execute:function(){DG.currDocumentController().toggleCardToTable(b)},undo:function(){var e=DG.currDocumentController(),c=b.getPath("controller.dataContext"),d=e.tableCardRegistry.getTableView(c);e.toggleTableToCard(d)}}))}.observes("selectedItem")}).popup(this,[0,-20,SC.POSITION_BOTTOM])}}}()));sc_require("views/drag_border_view");sc_require("views/titlebar_button_view");var kResizeHandleSize=26,kResizeHandleInset=4;DG.ComponentView=SC.View.extend((function(){var b=DG.ViewUtilities.kTitleBarHeight,e=50,h=DG.ViewUtilities.kDragWidth,a=DG.ViewUtilities.kBorderWidth,f=DG.get("componentMode")==="yes",d=DG.get("embeddedMode")==="yes",g=DG.get("hideUndoRedoInComponent")==="yes",c=(f||d)&&!g,i=f;return{classNames:["dg-component-view"],classNameBindings:["isSelected:dg-component-view-selected"],isResizable:function(j,k){if(!SC.empty(k)){this.setPath("model.isResizable",k)}return this.getPath("model.isResizable")}.property(),isResizableDidChange:function(){this.propertyDidChange("isResizable")}.observes("model.isResizable"),isWidthResizable:function(){return this.getPath("model.isWidthResizable")}.property(),isHeightResizable:function(){return this.getPath("model.isHeightResizable")}.property(),isClosable:YES,showTitleBar:YES,specialTitleBarButtons:function(){var j=this.get("controller");return j?j.get("specialTitleBarButtons"):[]}.property("controller"),controller:null,controllerDidChange:function(){var j=this.getPath("containerView.titlebar"),m=j&&j.get("titleView"),l=m&&m.get("layer"),k=this.get("specialTitleBarButtons");k.forEach(function(n,o){n.adjust({left:5+o*30,width:25});j.appendChild(n)});if(m&&l){m.adjust({left:0,right:0});l.style.paddingLeft=(k.length*10+5)+"px"}}.observes("controller"),model:null,inspectorButtonsBinding:SC.Binding.from("*controller.inspectorButtons").oneWay(),isSelected:false,isSelectedChanged:function(){this.setPath("containerView.titlebar.isSelected",this.get("isSelected"))}.observes("isSelected"),_modelSavedHeightBinding:SC.Binding.from("*model.savedHeight").oneWay(),modelDidChange:function(){this.setPath("containerView.titlebar.model",this.get("model"))}.observes("model"),isMinimized:function(){return !SC.none(this.get("_modelSavedHeight"))}.property("_modelSavedHeight"),isMinimizedChanged:function(){var j=this.get("isMinimized");this.setPath("contentView.isVisible",!j)}.observes("isMinimized"),init:function(){arguments.callee.base.apply(this,arguments);if(!this.get("showTitleBar")){this.getPath("containerView.titlebar").adjust("height",0)}if(f&&this.get("isVisible")){this.invokeLater(function(){this.select()}.bind(this))}if(DG.KEEP_IN_BOUNDS_PREF&&!this.originalLayout){this.originalLayout={}}if(this.get("isStandaloneComponent")){this.hideBorders()}this.set("title",this.getPath("model.title"))},hideBorders:function(){this.get("borderRight").set("isVisible",false);this.get("borderBottom").set("isVisible",false);this.get("borderLeft").set("isVisible",false);this.get("borderBottomLeft").set("isVisible",false);this.get("borderBottomRight").set("isVisible",false);this.get("resizeBottomRight").set("isVisible",false)},makeStandalone:function(){this.set("isStandaloneComponent",true);this.hideBorders();this.getPath("containerView.titlebar").adjust("height",0);this.getPath("containerView.contentView").adjust("top",0);this.parentView.sendToBack(this);this.layout={}},setFocusToComponentTitle:function(){var j=this.getPath("containerView.titlebar.titleView");if(j){j.beginEditing()}},contentView:function(j,k){if(k){this.setPath("containerView.contentView",k)}return this.getPath("containerView.contentView")}.property(),childViews:("containerView"+(DG.get("componentMode")==="no"?" borderRight borderBottom borderLeft borderBottomLeft borderBottomRight resizeBottomRight":"")).w(),containerView:SC.View.design({classNames:["dg-component-container"],layout:{left:0,bottom:0,right:0},childViews:"titlebar coverSheet".w(),titlebar:DG.DragBorderView.design({layout:{height:b},classNames:["dg-titlebar"],isSelected:false,userEdit:false,classNameBindings:["isSelected:dg-titlebar-selected"],isSelectedDidChange:function(){this.setPath("closeBox.isSelected",this.get("isSelected"));this.setPath("minimize.isSelected",this.get("isSelected"))}.observes("isSelected"),childViews:("statusView versionView titleView "+(!i?"minimize closeBox ":"")+(c?"undo redo ":"")).w(),titleView:SC.LabelView.design(DG.MouseAndTouchView,SC.AutoResize,{classNames:["dg-titleview"],classNameBindings:["valueIsEmpty:dg-titleview-empty"],isEditable:YES,exampleNode:null,_value:null,value:function(j,k){if(!SC.none(k)){this._value=k}return this._value}.property(),inlineEditorWillBeginEditing:function(q,s,n){arguments.callee.base.apply(this,arguments);var r=DG.ComponentView.findComponentViewParent(this),k=this.get("parentView"),o=k.get("frame"),p=4,m=2,j=DG.ViewUtilities.viewToWindowCoordinates({x:p,y:m},k);k.set("userEdit",true);r.select();var l=this.get("exampleNode");if(!l){l=this.get("layer").cloneNode(false);l.id=l.id+"-clone";l.style.visibility="hidden";l.style.textAlign="center";l.className=l.className.replace("dg-titleview","");k.get("layer").appendChild(l);this.set("exampleNode",l)}l.style.left=3+"px";l.style.top=12+"px";q.set({exampleElement:l,exampleFrame:{x:j.x,y:j.y,width:o.width-2*p,height:o.height-2*m}})},inlineEditorDidEndEditing:function(){arguments.callee.base.apply(this,arguments);this.get("parentView").set("userEdit",false)},valueChanged:function(){var k=DG.ComponentView.findComponentViewParent(this),j=this.get("parentView"),l=this.get("value"),m=this;if(!j.userEdit){return}if(k){j.userEdit=false;DG.UndoHistory.execute(DG.Command.create({name:"component.titleChange",executeNotification:{action:"notify",type:k.getPath("model.type"),resource:"component["+k.getPath("model.id")+"]",values:{operation:"titleChange",from:k.getPath("model.title"),to:l}},undoString:"DG.Undo.componentTitleChange",redoString:"DG.Redo.componentTitleChange",_userPreviouslySetTitle:k.getPath("model.userSetTitle"),execute:function(){this._beforeStorage=k.getPath("model.title");if(this._beforeStorage===l){this._beforeStorage=k.getPath("model._prevTitle")}k.setPath("model.title",l);k.setPath("model.userSetTitle",true);this.log="Change title '%@' to '%@'".fmt(this._beforeStorage,l)},undo:function(){var n=this._beforeStorage;k.setPath("model.title",n);k.setPath("model.userSetTitle",this._userPreviouslySetTitle);m._value=n;m.propertyDidChange("value")},redo:function(){k.setPath("model.title",l);k.setPath("model.userSetTitle",true);m._value=l;m.propertyDidChange("value")}}))}return true}.observes("value"),doIt:function(){this.beginEditing()},valueIsEmpty:function(){return SC.empty(this.get("value"))}.property(".value")}),statusView:SC.LabelView.design({textAlign:SC.ALIGN_LEFT,classNames:["dg-status-view"],layout:{left:5},value:""}),versionView:SC.LabelView.design({textAlign:SC.ALIGN_LEFT,classNames:["dg-version-view"],layout:{left:5,top:5},value:""}),minimize:!i?DG.TitleBarMinimizeButton.design({layout:{right:b,top:10,width:24,height:b},classNames:["dg-minimize-view"],isVisible:SC.platform.touch}):null,closeBox:!i?DG.TitleBarCloseButton.design({layout:{right:0,top:4,width:b,height:b},classNames:["dg-close-view"],isVisible:SC.platform.touch}):null,undo:c?DG.TitleBarUndoButton.design({layout:{right:(d?b*3:b),top:10,width:24,height:b},classNames:["dg-undo"]}):null,redo:c?DG.TitleBarRedoButton.design({layout:{right:(d?b*2:0),top:4,width:b,height:b},classNames:["dg-redo"]}):null,mouseEntered:function(j){var k=DG.ComponentView.findComponentViewParent(this),l=k&&k.getPath("model.cannotClose");this.setPath("minimize.isVisible",true);this.setPath("closeBox.isVisible",!l);this.setPath("undo.isVisible",true);this.setPath("redo.isVisible",true);return YES},mouseExited:function(j){this.setPath("minimize.isVisible",false);this.setPath("closeBox.isVisible",false);return YES},dragAdjust:function(o,A){var z=this.viewToDrag(),q=DG.ViewUtilities.roundToGrid(A.left+(o.pageX-A.pageX)),p=DG.ViewUtilities.roundToGrid(A.top+(o.pageY-A.pageY)),w=this.getContainerWidth(),l=this.getContainerHeight(),x=z.parentView.get("containingScrollView"),k=x?x.getPath("horizontalScrollerView.scrollbarThickness"):0,j=(x&&x.get("canScrollHorizontal"))?k:0,m=z.parentView.get("visibleTop"),B=z.parentView.get("visibleLeft"),y=-A.width+e,v=B+w-e,u=-b/2,t=m+l-j-b/2;if(DG.KEEP_IN_BOUNDS_PREF){var n=z.getInspectorDimensions();y=0;v=w-(A.width+n.width);u=0;t=l-(Math.max(A.height,n.height))}q=Math.min(Math.max(q,y),v);z.adjust("left",q);p=Math.min(Math.max(p,u),t);z.adjust("top",p);if(DG.KEEP_IN_BOUNDS_PREF){var s=DG.currDocumentController().get("inBoundsScaling"),r=s.scaleFactor;z.originalLayout.top=p/r;z.originalLayout.left=q/r}},canBeDragged:function(){return !i}}),coverSheet:SC.View.design({backgroundColor:DG.RenderingUtilities.kSeeThrough,isVisible:false,mouseDown:function(j){DG.mainPage.mainPane.getPath("scrollView.contentView").coverUpComponentViews("uncover")}}),setContentView:function(j){this.set("contentView",j)}}),borderRight:DG.DragRightBorderView.design({classNames:["dg-component-border"],layout:{top:b,right:0,width:h}}),borderBottom:DG.DragBottomBorderView.design({classNames:["dg-component-border"],layout:{bottom:0,height:h}}),borderLeft:DG.DragLeftBorderView.design({classNames:["dg-component-border"],layout:{left:0,width:h}}),borderBottomLeft:DG.DragBottomLeftBorderView.design({layout:{left:0,width:2*h,bottom:0,height:2*h}}),borderBottomRight:DG.DragBottomRightBorderView.design({layout:{right:0,width:2*h,bottom:0,height:2*h}}),resizeBottomRight:DG.DragBottomRightBorderView.design({classNames:["dg-component-resize-handle"],layout:{right:-kResizeHandleInset,bottom:-kResizeHandleInset,width:kResizeHandleSize,height:kResizeHandleSize},didCreateLayer:function(){this.set("isVisible",this.canBeDragged())},childViews:["interior"],interior:SC.View.design({classNames:["dg-component-resize-handle-interior"],layout:{left:0,top:0,right:kResizeHandleInset,bottom:kResizeHandleInset}})}),title:function(j,k){if(!SC.none(k)){this.setPath("containerView.titlebar.titleView.value",k)}return this.getPath("containerView.titlebar.titleView.value")}.property(),modelTitleChanged:function(k,j,l){if(!SC.none(l)){this.set("title",l)}}.observes("*model.title"),modelDimensionsChanged:function(k,j,l){if(!SC.none(l)){if(l.width){this.adjust("width",l.width)}if(l.height&&!this.get("isMinimized")){this.adjust("height",l.height)}}}.observes("*model.dimensions"),modelPositionChanged:function(k,j,l){if(!SC.none(l)){if(l.top){this.adjust("top",l.top)}if(l.left){this.adjust("left",l.left)}}}.observes("*model.position"),version:null,versionBinding:".containerView.titlebar.versionView.value",modelVersionChanged:function(k,j,l){if(!SC.none(l)){this.set("version",l)}}.observes("*model.version"),status:null,statusBinding:".containerView.titlebar.statusView.value",contentMinWidth:function(){if(this.get("contentView")){return this.getPath("contentView.containerMinWidth")}}.property(),contentMaxWidth:function(){if(this.get("contentView")){return this.getPath("contentView.containerMaxWidth")}}.property(),contentMinHeight:function(){if(this.get("contentView")){return this.getPath("contentView.containerMinHeight")}}.property(),contentMaxHeight:function(){if(this.get("contentView")){return this.getPath("contentView.containerMaxHeight")}}.property(),getInspectorDimensions:function(){var n=0,k=0,l=this.get("inspectorButtons");if(l&&l.length){if(l[0].parentView&&l[0].parentView.layout){n=l[0].parentView.layout.width;k=l[0].parentView.layout.height}else{var m=50,j=43;n=m;k=j*l.length}}return{width:n,height:k}},enforceViewBounds:function(){var E=this.getPath("containerView.titlebar"),p=this.getPath("controller.model.type"),q=this.getInspectorDimensions(),D=this.get("layout"),o=this.get("originalLayout"),y=E.getContainerWidth(),r=E.getContainerHeight(),x=DG.currDocumentController().get("inBoundsScaling"),w=x.scaleFactor,n=x.scaleBoundsX,k=x.scaleBoundsY,s=this.get("contentMinWidth")||e,C=this.get("contentMinWidth")||e;if(n<(D.left+D.width+q.width)){var m=D.left+D.width+q.width;DG.currDocumentController().setInBoundsScaleBounds(m,k)}if((k<(D.top+D.height)||k<(D.top+q.height))){var u=(D.height>q.height)?D.height:q.height;var j=D.top+u;DG.currDocumentController().set("scaleBoundsY",j)}if(p===DG.Calculator){s=D.width;C=D.height}var z=Math.max(s,DG.ViewUtilities.floorToGrid(o.width*w)),A=Math.max(C,DG.ViewUtilities.floorToGrid(o.height*w)),l=DG.ViewUtilities.floorToGrid(o.left*w),B=DG.ViewUtilities.floorToGrid(o.top*w);if((l+z+q.width)>y){l=Math.max(0,y-z-q.width)}if(B+A>r){B=Math.max(0,r-A)}if(!(isNaN(z)||isNaN(A)||isNaN(l)||isNaN(B))){this.adjust({width:z,height:A,left:l,top:B})}else{var t=[z,A,l,B];console.log("Got NaN for adjust layout: tNewWidth, tNewHeight, tNewLeft, tNewTop: "+t.join())}var v=this.get("controller");if(v&&v.view){v.updateModelLayout()}},configureViewBoundsLayout:function(j){var m=this.get("originalLayout"),l=DG.currDocumentController().get("inBoundsScaling"),k=l.scaleFactor;m.top=j.y/k;m.left=j.x/k;m.height=j.height/k;m.width=j.width/k},destroy:function(){if(this.containerView.contentView){this.containerView.contentView.destroy()}arguments.callee.base.apply(this,arguments)},closeAction:function(){return this.getPath("contentView.closeAction")}.property(),addContent:function(k){var j=k.get("frame");if(j.width>0){this.adjust("width",j.width+2*a)}if(j.height>0){this.adjust("height",j.height+2*a+b)}k.set("layout",{top:this.get("showTitleBar")?b:0});this.containerView.appendChild(k);this.containerView.setContentView(k);if(k.adjustComponentViewClasses){k.adjustComponentViewClasses(this)}},assignZ:function(j){if(!this.getPath("controller.preventBringToFront")){this.adjust("zIndex",j)}},select:function(){var j=this.savedLayout;this.set("isVisible",true);if(j){this.set("savedLayout",null);this.animate(j,{duration:0.4,timing:"ease-in-out"},function(){this.adjust({height:j.height-1})})}if(this.parentView&&this.parentView.select){this.parentView.select(this)}},bringToFront:function(){this.parentView.bringToFront(this)},mouseDown:function(j){this.select();return true},click:function(j){return this.mouseDown(j)},touchStart:function(j){return this.mouseDown(j)},showAndSelect:function(){if(this.get("isMinimized")){this.set("savedLayout",null);this.toggleMinimization()}if(DG.KEEP_IN_BOUNDS_PREF&&!this.get("isStandaloneComponent")){DG.currDocumentController().enforceViewBounds()}this.set("isVisible",true);this.select()},maximizeAndSelect:function(){if(this.get("isMinimized")){this.toggleMinimization()}this.select()},toggleMinimization:function(){DG.log("toggleMinimization");var j=function(m){["Bottom","Corner","Left","Right"].forEach(function(n){this.setPath("border"+n+".isVisible",m)}.bind(this))}.bind(this);if(this.get("isMinimized")){var l=this.getPath("model.savedHeight");this.animate({height:l-1},{duration:0.4,timing:"ease-in-out"},function(){this.adjust("height",l);this.setPath("model.savedHeight",null)}.bind(this));j(true)}else{var k=this.get("layout").height;this.animate({height:b},{duration:0.4,timing:"ease-in-out"},function(){this.setPath("model.savedHeight",k)});j(false);if(this.get("isSelected")){this.parentView.select(null)}}},contentIsInstanceOf:function(j){return this.get("contentView") instanceof j},cover:function(j){var k=this.get("containerView"),l=k.get("coverSheet");k.removeChild(l);k.appendChild(l);l.set("isVisible",j==="cover")},didAppendToDocument:function(){var j=this.get("contentView");if(j&&j.didAppendToDocument){j.didAppendToDocument()}},didReachInitialPosition:function(){var j=this.get("contentView");if(j&&j.didReachInitialPosition){j.didReachInitialPosition()}}}}()));DG.ComponentView._createComponent=function(d){var e=d.componentClass.constructor;var a=(d.layout.isVisible===undefined)||d.layout.isVisible,c=d.isResizable,b=DG.ComponentView.create({layout:d.layout,originalLayout:d.layout,isVisible:a,showTitleBar:!d.isStandaloneComponent,isStandaloneComponent:d.isStandaloneComponent,model:d.model});if(d.controller){d.controller.set("view",b)}d.contentProperties.controller=d.controller;b.addContent(e.create(d.contentProperties));if(d.controller){b.set("controller",d.controller);d.controller.set("contentView",b.getPath("containerView.contentView"))}if(d.isStandaloneComponent){c=false}if(!SC.none(c)){b.set("isResizable",c)}if(!SC.none(d.isVisible)){b.set("isVisible",d.isVisible)}return b};DG.ComponentView.restoreComponent=function(e){var d=this._createComponent(e),a,c=e.parentView,b=e.useLayout;if(e.controller){e.controller.set("view",d);d.set("controller",e.controller)}if(SC.none(b)&&!SC.none(e.layout.left)&&!SC.none(e.layout.top)){b=true}if(!b){a=c.positionNewComponent(d,e.position,e.positionOnCreate)}c.appendChild(d);if(DG.KEEP_IN_BOUNDS_PREF&&!d.get("isStandaloneComponent")){if(!b){d.configureViewBoundsLayout(a)}d.enforceViewBounds()}c.updateFrame();return d};DG.ComponentView.addComponent=function(f){var e=$.extend({},f,{layout:$.extend(true,{},f.layout)}),c=e.parentView,a,b=e.useLayout||false;if(!SC.none(e.layout.width)){e.layout.width+=DG.ViewUtilities.horizontalPadding()}if(!SC.none(e.layout.height)){e.layout.height+=DG.ViewUtilities.verticalPadding()}var d=this._createComponent(f);if(!b){a=c.positionNewComponent(d,f.position)}c.appendChild(d);d.bringToFront();c.updateFrame();if(DG.KEEP_IN_BOUNDS_PREF&&!b){d.configureViewBoundsLayout(a);DG.currDocumentController().computeScaleBounds(a)}return d};DG.ComponentView.findComponentViewParent=function(a){while(a&&!(a instanceof DG.ComponentView)){a=a.get("parentView")}return a};DG.ComponentView.isComponentViewForViewSelected=function(a){return DG.ComponentView.findComponentViewParent(a)===DG.mainPage.docView.get("selectedChildView")};DG.DraggableView=SC.View.extend((function(){return{classNames:"dg-draggable".w(),mouseDown:function(b){DG.globalEditorLock.commitCurrentEdit();var a=this.get("layout");this._mouseDownInfo={pageX:b.pageX,pageY:b.pageY,left:a.left,top:a.top,height:a.height,width:a.width};return YES},mouseUp:function(a){this.mouseDragged(a);this._mouseDownInfo=null;return YES},mouseDragged:function(b){var a=this._mouseDownInfo;if(a){this.dragAdjust(b,a);return YES}else{return NO}},touchStart:function(a){return this.mouseDown(a)},touchEnd:function(a){return this.mouseUp(a)},touchesDragged:function(b,a){return this.mouseDragged(b)},dragAdjust:function(b,a){}}}()));sc_require("views/draggable_view");DG.InspectorView=DG.DraggableView.extend((function(){var d=0.2,c=0,b=50,f=50,a=32,e=(f-a)/2;return{classNames:["dg-inspector-palette","dg-inspector-view"],transitionIn:SC.View,isResizable:false,isClosable:false,componentContainer:null,targetComponent:null,init:function(){arguments.callee.base.apply(this,arguments);this.set("layout",{height:f,width:c});this.selectedComponentDidChange()},adjustLayout:function(){var h=this.get("childViews"),g=e;h.forEach(function(i,j){if(i.get("isVisible")){i.adjust({top:g,left:(f-i.iconExtent.width)/2});g+=i.iconExtent.height+2*e}});this.animate("height",Math.max(f,g-e),d,function(){this.invokeLater(this.scrollToVisible)}.bind(this))},targetComponentDidChange:function(){var g=function(){var j=this.get("childViews"),i;while(i=j[0]){this.removeChild(i)}}.bind(this);var h=this.get("targetComponent");if(h){h.addObserver("layout",this,"targetLayoutDidChange")}this.targetLayoutDidChange();this.get("childViews").forEach(function(i){i.removeObserver("isVisible",this,"adjustLayout")}.bind(this));g();this.inspectorButtonsDidChange()}.observes("targetComponent"),selectedComponentDidChange:function(){var g=this.get("targetComponent");if(g){g.removeObserver("layout",this,"targetLayoutDidChange")}this.set("targetComponent",this.getPath("componentContainer.selectedChildView"))}.observes("*componentContainer.selectedChildView"),targetLayoutDidChange:function(){var g=this.getPath("targetComponent.frame");if(g){this.adjust("top",g.y);this.adjust("left",g.x+g.width)}},inspectorButtonsDidChange:function(){var h,g=this.getPath("targetComponent.inspectorButtons");if(g&&g.length>0){g.forEach(function(i){this.appendChild(i);i.addObserver("isVisible",this,"adjustLayout")}.bind(this));h=b}else{h=c}this.animate("width",h,d,this,"adjustLayout")}.observes("*targetComponent.inspectorButtons"),dragAdjust:function(j,i){var g=this.getPath("targetComponent.frame"),h=j.pageY-i.pageY,k=i.top+h;k=Math.max(g.y,k);k=Math.min(k,g.y+g.height);this.adjust("top",k)}}}()));sc_require("views/inspector/inspector_view");DG.ContainerView=SC.View.extend((function(){var a=16;return{classNames:"dg-container-view".w(),isResizable:YES,nextZIndex:function(){var b=100;this.get("componentViews").forEach(function(c){var d=c.get("layout").zIndex;if(d){b=Math.max(b,d)}});return b+1}.property(),lowerZIndex:function(){var b=100;this.get("componentViews").forEach(function(c){var d=c.get("layout").zIndex;if(d){b=Math.min(b,d)}});return b-1}.property(),inspectorView:null,reservedRects:null,layout:{left:0,top:0,minWidth:"100%",minHeight:"100%"},isFixedLayout:function(){return false}.property(),init:function(){arguments.callee.base.apply(this,arguments);this.reservedRects=[];this.set("inspectorView",DG.InspectorView.create({componentContainer:this}));this.appendChild(this.get("inspectorView"))},parentViewDidResize:function(b){arguments.callee.base.apply(this,arguments);if(DG.STANDALONE_MODE){this.adjust({width:b.width})}},componentViews:function(){return this.get("childViews").filter(function(b){return(b instanceof DG.ComponentView)&&!(DG.STANDALONE_MODE&&b.contentIsInstanceOf(DG.GameView))})}.property("childViews"),allComponentViews:function(){var c=DG.STANDALONE_MODE;DG.STANDALONE_MODE=false;var b=this.get("componentViews");DG.STANDALONE_MODE=c;return b}.property("childViews"),tileMenuItems:function(){function c(d){var e=d.get("contentView");if(e){switch(e.constructor){case DG.TableView:return"tile-icon-table";case DG.CaseCardView:return"tile-icon-card";case DG.GraphView:return"tile-icon-graph";case DG.MapView:return"tile-icon-map";case DG.SliderView:return"tile-icon-slider";case DG.Calculator:return"tile-icon-calc";case DG.TextView:return"tile-icon-comment";case DG.GuideView:return"tile-icon-guide";case DG.GameView:return"tile-icon-dataTool";case DG.WebView:case SC.WebView:return"tile-icon-mediaTool";default:return"tile-icon-dataTool"}}}var b=[];this.get("componentViews").forEach(function(d){if(d.get("isVisible")){b.push({title:d.get("title"),target:d,action:"maximizeAndSelect",icon:c(d)})}});return b}.property(),updateFrame:function(){if(DG.STANDALONE_MODE){return}var c=0,b=0;this.get("childViews").forEach(function(e){var d=e.get("layout");c=Math.max(c,(d.left||0)+(d.width||0));b=Math.max(b,(d.top||0)+(d.height||0))});c+=a;b+=a;this.adjust({width:c,height:b})},removeComponentView:function(c){var b=c.get("closeAction");if(b){b.action.apply(b.target,b.args)}else{this.select(null);DG.currDocumentController().removeComponentAssociatedWithView(c);c.destroy()}this.updateFrame()},destroyAllChildren:function(){this.select(null);var b=this.get("allComponentViews");b.forEach(function(c){if(c&&c.willDestroy){c.willDestroy()}c.destroy()});return this},selectedChildView:null,select:function(d){var b=this.get("selectedChildView"),c=d&&d.get("isMinimized");if(d){this.bringToFront(d)}if(d!==b&&!c){DG.globalEditorLock.commitCurrentEdit();if(b){b.set("isSelected",false)}this.set("selectedChildView",d);if(d){d.set("isSelected",true)}}},bringToFront:function(b){if(b.assignZ){b.assignZ(this.get("nextZIndex"))}},sendToBack:function(b){if(b.assignZ){b.assignZ(this.get("lowerZIndex"))}},positionNewComponent:function(j,r,c){var e=this,m=j.get("frame"),l=this.parentView.get("clippingFrame"),p=this.computeFrameWithParentFrame(),o={x:-p.x,y:-p.y},f=this.get("componentViews").map(function(u){return u.get("isVisible")?u.get("frame"):{x:0,y:0,width:0,height:0}}),g=this.get("reservedRects"),t=DG.ViewUtilities.findEmptyLocationForRect(m,l,o,f.concat(g),r);if(DG.KEEP_IN_BOUNDS_PREF){var b=50,h=$("#codap").width();if((t.x+m.width+b)>h){t.x=Math.max(0,h-m.width-b)}var s=this.parentView;while(!SC.none(s.parentView.parentView)){s=s.parentView}var k=$("#codap").height()-s.get("frame").y;if((t.y+m.height)>k){t.y=Math.max(0,k-m.height)}}var d={x:t.x,y:t.y,width:m.width,height:m.height},n={duration:0.5,timing:"ease-in-out"},i=j.get("contentView").constructor===DG.GameView;if(i){var q={width:d.width,height:d.height};if(c){q.left=d.x;q.top=d.y}j.adjust(q)}else{g.push(d);this.invokeLater(function(){j.adjust({left:DG.ViewUtilities.kGridSize,top:DG.ViewUtilities.kGridSize,width:0,height:0});j.animate({left:t.x,top:t.y,width:m.width,height:m.height},n,function(){this.adjust("width",m.width+1);this.adjust("width",m.width);this.adjust("height",m.height+1);this.adjust("height",m.height);this.select();e.updateFrame();g.splice(g.indexOf(d),1);this.didReachInitialPosition()})}.bind(this),100);j.adjust({width:0,height:0})}return d},coverUpComponentViews:function(b){this.allComponentViews().forEach(function(c){if(c.get("isVisible")){c.cover(b)}})},mouseDown:function(b){this.select(null);return true},touchStart:function(b){return this.mouseDown(b)},containingScrollView:function(){var b=this;while(b.parentView!=null&&!(b.parentView instanceof SC.ScrollView)){b=b.parentView}return b&&b.parentView}.property(),visibleLeft:function(){var b=this.get("containingScrollView");var c=b.get("horizontalScrollOffset");return c}.property(),visibleTop:function(){var c=this.get("containingScrollView");var b=c.get("verticalScrollOffset");return b}.property()}}()));DG.Drag=SC.Drag.extend({startDrag:function(){DG.mainPage.docView.select();if(this.get("sourceIsDraggable")){this._createGhostView()}var j=this.event;var e=SC.none(j.clientX)?{x:j.layerX,y:j.layerY}:{x:j.clientX,y:j.clientY};this.set("location",e);if(this.get("sourceIsDraggable")){var b=this._getDragView();var k=b.get("parentView");var g=k&&$(k.containerLayer()).offset(),i={x:g?g.left:0,y:g?g.top:0};if(this.get("ghost")){this._dragViewWasVisible=b.get("isVisible");b.set("isVisible",NO)}if(this.ghostActsLikeCursor){this.ghostOffset={x:14-window.pageXOffset,y:14-window.pageYOffset}}else{this.ghostOffset={x:(e.x-i.x),y:(e.y-i.y)}}if(!this._ghostViewHidden){this._positionGhostView(j)}if(j.makeTouchResponder){var l=this;SC.Timer.schedule({target:j,action:function(){if(!j.hasEnded){j.makeTouchResponder(l,YES)}},interval:1})}else{this.ghostView.rootResponder.dragDidStart(this,j)}}var a=this.source;if(a&&a.dragDidBegin){a.dragDidBegin(this,e)}var c=this._dropTargets();for(var h=0,d=c.length;h<d;h++){var f=c[h];f.tryToPerform("dragStarted",this,j)}},_findDropTarget:function(b){var g=this._dropTargets(),f={x:b.clientX,y:b.clientY},e=arguments.callee.base.apply(this,arguments),c=g.find(function(k){if((k.constructor===DG.AxisMultiTarget)||(k.get("orientation")===DG.GraphTypes.EOrientation.kVertical2)){var j=k.convertFrameToView(k.get("frame"),null);return SC.pointInRect(f,j)}else{return false}});if(!SC.none(c)){var d=DG.ComponentView.findComponentViewParent(c),i=d?d.get("layout").zIndex:0,h=DG.ComponentView.findComponentViewParent(e),a=h?h.get("layout").zIndex:0;return i>=a?c:e}else{return e}},_slideGhostViewBack:function(){if(!this.origin||SC.none(this.origin.x)||SC.none(this.origin.y)){arguments.callee.base.apply(this,arguments)}else{if(this.ghostView){var c=window.pageXOffset||document.documentElement.scrollLeft,b=window.pageYOffset||document.documentElement.scrollTop,a={top:this.origin.y+b,left:this.origin.x+c};this.ghostView.animate(a,0.5,this,function(){this.invokeNext(function(){var d=this.get("source");if(this.get("slideBack")&&d&&d.dragSlideBackDidEnd){d.dragSlideBackDidEnd(this)}this._endDrag()})})}else{this._endDrag()}}},_dropTargets:function(){if(this._cachedDropTargets){return this._cachedDropTargets}var a=arguments.callee.base.apply(this,arguments);a.forEach(function(c){var b=DG.ComponentView.findComponentViewParent(c);c.parentZIndex=b?b.get("layout").zIndex:null});a.sort(function(e,d){var c=e.parentZIndex,b=d.parentZIndex;if(SC.none(c)){return 1}else{if(SC.none(b)){return -1}}if(c<b){return 1}else{if(b<c){return -1}else{return 0}}});a.forEach(function(b){delete b.parentZIndex});return a}});DG.ExportCaseDataDialog=SC.PalettePane.extend({isModal:true,layout:{width:400,height:120,centerX:0,centerY:0},contentView:SC.View.extend({childViews:"promptView collectionPopup exportButton cancelButton".w(),promptView:SC.LabelView.extend({layerId:"export_case_data_prompt",layout:{top:10,left:10,right:210,height:24},localize:true,value:""}),collectionPopup:SC.PopupButtonView.extend({layout:{top:10,left:200,right:10,height:24},title:"",menu:SC.MenuPane.extend({layout:{width:250},items:null})}),exportButton:SC.ButtonView.design({layout:{bottom:5,right:110,height:24,width:90},titleMinWidth:0,localize:true,title:"",target:null,action:null,isDefault:true}),cancelButton:SC.ButtonView.design({layout:{bottom:5,right:10,height:24,width:90},titleMinWidth:0,localize:true,title:"",target:null,action:null,isDefault:false})}),init:function(){arguments.callee.base.apply(this,arguments);this.setPath("contentView.exportButton.target",this);this.setPath("contentView.exportButton.action","export");this.setPath("contentView.cancelButton.target",this);this.setPath("contentView.cancelButton.action","close")},collectionSelected:function(){var a=this.getPath("contentView.collectionPopup.menu.selectedItem.title");if(!SC.empty(a)){this.setPath("contentView.collectionPopup.title",a)}}.observes(".contentView.collectionPopup.menu.selectedItem"),"export":function(){var a=this.getPath("contentView.collectionPopup.title"),b=this.getPath("contentView.collectionPopup.itemAction");if(!SC.empty(a)){this.close();b(a)}},close:function(){this.remove();this.destroy()}});DG.CreateExportCaseDataDialog=function(b){var d=DG.ExportCaseDataDialog.create(b),c={prompt:"promptView.value",exportTitle:"exportButton.title",exportTooltip:"exportButton.toolTip",cancelTitle:"cancelButton.title",cancelTooltip:"cancelButton.toolTip",collectionMenuTitle:"collectionPopup.title",collectionMenuItems:"collectionPopup.menu.items",collectionMenuItemAction:"collectionPopup.itemAction"},a=d.get("contentView");DG.ObjectMap.forEach(b,function(e,f){var g=c[e];if(!SC.empty(g)){a.setPath(g,f)}});d.append();return d};DG.FontIconView=SC.View.extend({iconClass:null,init:function(){arguments.callee.base.apply(this,arguments)},render:function(a){a.push('<span class="'+this.get("iconClass")+'"></span>')}});sc_require("views/text_field_view");DG.FormulaTextEditView=DG.TextFieldView.extend((function(){return{autoCorrect:false,autoCapitalize:false,names:[],_disableNextSelectRoot:false,_selectRootElement:function(){if(!this._disableNextSelectRoot){arguments.callee.base.apply(this,arguments)}this._disableNextSelectRoot=false},keyDown:function(b){var d=DG.UNICODE.MINUS_SIGN,c=this.get("value"),a=this.get("selection");if(b.getCharString()==="-"){if(!SC.none(c)){c=c.slice(0,a.get("start"))+d+c.slice(a.get("end"))}else{c=d}this.set("value",c);this.setSelection(a.start+1);return true}else{if((b.which===SC.Event.KEY_TAB)&&(a.start!==c.length)&&(a.end===c.length)){this.setSelection(c.length);return true}}return arguments.callee.base.apply(this,arguments)},performValidateKeyDown:function(a){return(a.getCharString()!=="-")&&arguments.callee.base.apply(this,arguments)},formulaExpression:function(a,c){if(c===undefined){var b=this.get("value");return !SC.empty(b)?b.replace(/\u2212/g,"-"):b}else{this.set("value",!SC.empty(c)?c.replace(/-/g,DG.UNICODE.MINUS_SIGN):"")}}.property("value")}})());sc_require("utilities/tap_hold_gesture");sc_require("views/image_view");sc_require("views/tooltip_enabler");DG.IconButton=SC.View.extend(SC.Gesturable,DG.TooltipEnabler,(function(){var b=0,a={width:34,height:25};return{classNames:"dg-toolshelf-button",classNameBindings:["disabled"],iconName:null,depressedIconName:null,title:null,iconExtent:a,showBlip:false,childViews:"iconView labelView".w(),iconView:DG.FontIconView.design({classNames:"dg-icon-button"}),labelView:SC.LabelView.design({classNames:["dg-icon-label"],textAlign:SC.ALIGN_CENTER,valueBinding:".parentView.title",localizeBinding:".parentView.localize"}),gestures:[DG.TapHoldGesture],init:function(){arguments.callee.base.apply(this,arguments);var c=this.get("title")?this.get("title").loc():null,d=SC.empty(c),e=d?0:15,f=d?0:DG.RenderingUtilities.textExtent(c,"MuseoSans-500",12).x;this.iconView.set("layout",{top:b,centerX:0,height:this.iconExtent.height,width:this.iconExtent.width});this.iconView.set("iconClass",this.iconClass);this.setPath("labelView.layout",{top:this.iconExtent.height+b,centerX:0,width:f,height:e});this.labelView.set("isVisible",!d);if(this.get("showBlip")){this.iconView.set("layout",{top:0,right:0,height:this.iconExtent.height,width:this.iconExtent.width});this.adjust("width",this.iconExtent.width+3);this.adjust("height",this.iconExtent.height+3);this.appendChild(DG.ImageView.create({classNames:"dg-icon-button-blip".w(),layout:{left:0,bottom:0,width:3,height:3}}))}},getWidth:function(){return Math.max(this.getPath("iconView.layout").width,this.getPath("labelView.layout").width)},iconClassDidChange:function(){this.iconView.set("iconClass",this.iconClass);this.iconView.displayDidChange()}.observes("iconClass"),adjustHeight:function(){this.adjust("height",this.getPath("iconView.layout").height+this.getPath("labelView.layout").height+b)},isEnabled:true,disabledBinding:SC.Binding.transform(function(c){return !c}).oneWay(".isEnabled"),isMouseDown:NO,isMouseOver:NO,mouseMoved:function(c){this.mouseOver(c);return YES},mouseOver:function(c){this.set("isMouseOver",YES);return YES},mouseExited:function(c){this.set("isMouseOver",NO);return YES},mouseDown:function(c){DG.globalEditorLock.commitCurrentEdit();if(this.get("isEnabled")){this.set("isMouseDown",YES);return YES}return NO},_lastMouseUpTime:0,mouseUp:function(d){var e=d.timeStamp;var c=this.$().within(d.target);if(c&&e-this._lastMouseUpTime>=500){this._action(d);this._lastMouseUpTime=d.timeStamp}this.set("isMouseDown",NO);return YES},_action:function(c){var e=this.get("action");var f=this.get("target")||null;var g=this.get("pane");if(e instanceof Function){e.call(f)}else{var d=g?g.get("rootResponder"):null;if(d){d.sendAction(e,f,this,g)}}},touchStart:function(c){this.gestureTouchStart(c);this.beginPropertyChanges();this.set("isMouseOver",YES);this.set("isMouseDown",YES);this.endPropertyChanges();return YES},touchEnd:function(c){this.gestureTouchEnd(c);if(!DG.TouchTooltips.clearTouchTooltip(c.identifier)){this._action(c)}this.beginPropertyChanges();this.set("isMouseOver",NO);this.set("isMouseDown",NO);this.endPropertyChanges()},tapHold:function(c){this._tooltipTouchID=DG.TouchTooltips.showTouchTooltip(c,this,this.get("displayToolTip"))},tapHoldCancelled:function(){if(this._tooltipTouchID){DG.TouchTooltips.hideTouchTooltip(this._tooltipTouchID)}},toolTipDidChange:function(){this.updateLayer()}.observes("displayToolTip"),render:function(d){arguments.callee.base.apply(this,arguments);var c=this.get("displayToolTip");if(c){d.setAttr("title",c)}}}}()));DG.InspectorPickerPane=SC.PickerPane.extend({removedByClickInButton:false,isModal:false,acceptsKeyPane:false,init:function(){arguments.callee.base.apply(this,arguments);DG.set("inspectorPicker",this);this.set("removeTarget",this)},click:function(b){var a=this.get("subPane");if(this.get("subPane")){a.remove();a.destroy();this.set("subPane",null)}return false},transitionIn:SC.View.SCALE_IN,removeAction:function(){console.log("removeAction")}});DG.InspectorPickerPane.close=function(c){var b=DG.get("inspectorPicker"),a=b&&(b.get("buttonIconClass")===c);if(b){SC.run(function(){var d=b.get("subPane");b.remove();b.destroy();DG.set("inspectorPicker",null);if(d){d.remove();d.destroy()}})}return(b!=null)&&(!c||a)};DG.PickerColorControl=SC.View.extend({classNames:"dg-inspector-picker-color".w(),initialColor:null,colorKey:null,setColorFunc:null,closedFunc:null,appendToLayerFunc:null,lastColor:null,render:function(a,b){a.push('<input type="text" id="custom1" />');if(this.get("lastColor")==null){this.set("lastColor",this.get("initialColor"))}this.invokeLast(function(){this.$("#custom1").spectrum({color:tinycolor(this.initialColor),appendTo:this.appendToLayerFunc(),showAlpha:true,showInitial:true,showButtons:false,togglePaletteOnly:true,togglePaletteMoreText:"DG.Inspector.colorPicker.more".loc(),togglePaletteLessText:"DG.Inspector.colorPicker.less".loc(),showPaletteOnly:true,showPalette:true,palette:[["black","darkgray","lightgray","white"],["rgb(173,35,35);","rgb(255,150,50);","rgb(255,238,51);","rgb(29,105,20);"],["rgb(42,75,215);","rgb(129,74,25);","rgb(129,38,192);","rgb(41,208,208);"],["rgb(233,222,187);","rgb(255,205,243);","rgb(157,175,255);","rgb(129,197,122);"]],move:function(c){SC.run(function(){if(this.setColorFunc){this.setColorFunc(c,this.colorKey)}}.bind(this))}.bind(this),change:function(c){SC.run(function(){if(this.setColorFunc){this.setColorFunc(c,this.colorKey)}if(this.closedFunc){this.closedFunc(this.get("lastColor"),c)}this.set("lastColor",c,this.colorKey)}.bind(this))}.bind(this)})}.bind(this))}});DG.ScrollView=SC.ScrollView.extend({horizontalScrollerView:SC.ScrollerView.extend({buttonOverlap:0}),horizontalScrollerLayout:function(){var a=this.get("isVerticalScrollerVisible")?0:this.getPath("horizontalScrollerView.scrollbarThickness");return{top:0,left:0,bottom:0,right:a}}.property(),verticalScrollerView:SC.ScrollerView.extend({buttonOverlap:0}),verticalScrollerLayout:function(){var a=this.get("isHorizontalScrollerVisible")?0:this.getPath("verticalScrollerView.scrollbarThickness");return{top:0,left:0,bottom:a,right:0}}.property(),scrollToBottom:function(){this.scrollTo(null,this.get("maximumVerticalScrollOffset"))}});DG.SingleTextDialog=SC.PalettePane.extend({isModal:true,escapePromptHTML:true,layout:{width:400,height:120,centerX:0,centerY:0},contentView:SC.View.extend({childViews:"promptView editView okButton cancelButton".w(),promptView:SC.LabelView.extend({displayProperties:["escapeHTML"],layout:{top:10,left:5,right:5,height:24},localize:true,value:"",escapeHTMLBinding:".parentView.parentView.escapePromptHTML"}),editView:SC.TextFieldView.design({layout:{top:40,left:5,right:5,height:24},value:"",isTextArea:false,spellCheckEnabled:false,classNames:"dg-single-text-dialog-textfield"}),okButton:SC.ButtonView.design({layout:{bottom:5,right:5,height:24,width:90},titleMinWidth:0,localize:true,title:"DG.SingleTextDialog.okButton.title",target:null,action:null,isDefault:true,isEnabledBinding:".parentView.editView.value",classNames:"dg-single-text-dialog-ok"}),cancelButton:SC.ButtonView.design({layout:{bottom:5,right:115,height:24,width:90},titleMinWidth:0,localize:true,title:"DG.SingleTextDialog.cancelButton.title",target:null,action:null,toolTip:"DG.SingleTextDialog.cancelButton.toolTip",isVisible:true,isCancel:true,classNames:"dg-single-text-dialog-cancel"})}),value:function(){return this.getPath("contentView.editView.value")}.property(),init:function(){arguments.callee.base.apply(this,arguments);this.setPath("contentView.cancelButton.target",this);this.setPath("contentView.cancelButton.action","close")},close:function(){this.remove();this.destroy()}});DG.CreateSingleTextDialog=function(b){var e=DG.SingleTextDialog.create(b),d={prompt:"promptView.value",textValue:"editView.value",textHint:"editView.hint",textLimit:"editView.maxLength",textIsMultiLine:"editView.isTextArea",okTarget:"okButton.target",okAction:"okButton.action",okTooltip:"okButton.toolTip",cancelTitle:"cancelButton.title",cancelVisible:"cancelButton.isVisible",cancelTooltip:"cancelButton.toolTip"},a=e.get("contentView"),c=a.editView;DG.ObjectMap.forEach(b,function(f,g){var h=d[f];if(!SC.empty(h)){a.setPath(h,g)}});e.append();c.becomeFirstResponder();return e};DG.TipView=SC.LabelView.extend({classNames:"dg-tipview".w(),isEditable:false,localize:true,show:function(e,f){var g=this,b=200,a=DG.ViewUtilities.windowToViewCoordinates(e,this.get("parentView")),d=this.getPath("parentView").clippingFrame(),c;g.set("value",f);g.adjust({left:0,top:-500,width:b,height:0,opacity:0});g.set("isVisible",true);this.invokeLater(function(){c=g._view_layer.scrollHeight;a.x=Math.min(a.x,d.x+d.width-b);a.y=Math.min(a.y,d.y+d.height-c);g.set("isVisible",false);g.adjust({left:a.x,top:a.y});g.set("isVisible",true);g.animate({height:c-10,opacity:1},{duration:0.5,delay:0.25,timing:"ease-in-out"})},10)},hide:function(){this.set("isVisible",false)}});DG.mainPage=SC.Page.design((function(){var f=SC.browser.device!==SC.DEVICE.desktop,e=DG.get("componentMode")==="yes",c=DG.get("embeddedMode")==="yes",d=DG.STANDALONE_MODE?0:66,a=28,b=17;return DG.Browser.isCompatibleBrowser()?{mainPane:SC.MainPane.design({isTextSelectable:c,listeners:null,addListener:function(g){this.listeners.push(g)},removeListener:function(g){this.listeners=this.listeners.filter(function(h){return g.action!==h.action||g.target!==h.target||g.method!==h.method})},sendEvent:function(h,g){if(h==="mouseDown"||h==="touchStart"||h==="click"){this.hideInspectorPicker(g.target)}this.listeners.forEach(function(i){if(i.action===h){i.method.call(i.target,g)}});return arguments.callee.base.apply(this,arguments)},hideInspectorPicker:function(k){var i=DG.get("inspectorPicker");if(i){var h=k&&(typeof k.className==="string")?k.className.split(" "):[],j=k&&k.parentNode,g=j&&(typeof j.className==="string")?j.className.split(" "):[];if((h.indexOf("dg-inspector-pane-button")>=0)||(g.indexOf("dg-inspector-pane-button")>=0)||(h.indexOf(i.get("buttonIconClass"))>=0)){}else{DG.InspectorPickerPane.close()}}},inspectorPicker:null,childViews:"navBar topView scrollView tipView".w(),containerViewBinding:"scrollView.contentView",navBar:SC.View.design({classNames:"navBar".w(),layout:{height:a},childViews:"leftSide".w(),anchorLocation:SC.ANCHOR_TOP,isVisible:!(e||c),leftSide:SC.View.design({layout:{left:0,right:0},captureTouch:function(){return YES},touchStart:function(g){g.allowDefault()},touchesDragged:function(g){g.allowDefault()},touchEnd:function(g){g.allowDefault()},classNames:"leftSide".w(),didAppendToDocument:function(){DG.cfmViewConfig=Promise.resolve({navBarId:this.getPath("layer.id")})}})}),topView:SC.View.design({classNames:"toolshelf-background".w(),layout:{top:a,height:d-1},childViews:"iconButtons rightButtons".w(),iconButtons:SC.View.design(SC.FlowedLayout,{classNames:"dg-icon-buttons".w(),layout:{width:0,height:d-1},align:SC.ALIGN_LEFT,canWrap:false,shouldResizeHeight:false,defaultFlowSpacing:{left:5,top:b,right:5},init:function(){arguments.callee.base.apply(this,arguments);DG.toolButtons.forEach(function(g,h){var i=DG.ToolButtonData[g];if(h===0){i.flowSpacing={left:10,top:b,right:5}}i.classNames=i.classNames||"";i.classNames=(i.classNames+" dg-toolshelf-button").w();this[g]=DG.IconButton.create(i);this[g].set("layout",{width:this[g].getWidth(),height:40});this.appendChild(this[g])}.bind(this))}}),rightButtons:SC.View.design(SC.FlowedLayout,{layout:{top:0,right:10,width:0,height:d-1},align:SC.ALIGN_RIGHT,canWrap:false,shouldResizeHeight:false,defaultFlowSpacing:{right:10,top:b},init:function(){arguments.callee.base.apply(this,arguments);DG.rightButtons.forEach(function(g){var h=DG.RightButtonData[g];h.classNames.push("dg-toolshelf-button");this[g]=DG.IconButton.create(h);this[g].set("layout",{width:this[g].getWidth()});this.appendChild(this[g])}.bind(this));DG.currDocumentController().set("guideButton",this.guideButton)},applyPlanToView:function(g,h){SC.FlowedLayout.applyPlanToView.apply(this,arguments);if(g.adjustHeight){g.adjustHeight()}}})}),scrollView:DG.ScrollView.design({layout:{top:a+d},horizontalAlign:SC.ALIGN_LEFT,verticalAlign:SC.ALIGN_TOP,hasVerticalScroller:!DG.KEEP_IN_BOUNDS_PREF,hasHorizontalScroller:!DG.KEEP_IN_BOUNDS_PREF,horizontalOverlay:f,verticalOverlay:f,classNames:"dg-doc-background".w(),alwaysBounceVertical:false,contentView:DG.ContainerView.design({}),touchStart:function(g){DG.TouchTooltips.hideAllTouchTooltips();g.allowDefault();return arguments.callee.base.apply(this,arguments)}}),tipView:DG.TipView.design({isVisible:false}),flagsChanged:function(g){},init:function(){arguments.callee.base.apply(this,arguments);this.listeners=[];if(e||c){var g=this.get("scrollView");this.setPath("topView.isVisible",false);g.adjust("top",0);g.set("hasHorizontalScroller",false);g.set("hasVerticalScroller",false)}DG.PluginOverlayContainer.create()},viewDidResize:function(){arguments.callee.base.apply(this,arguments);if(DG.KEEP_IN_BOUNDS_PREF){DG.currDocumentController().enforceViewBounds()}},classNameBindings:["_isDraggingFileOrURL:dg-receive-outside-drop","_isDraggingAttr:dg-attr-drop"],dragAttributeData:null,_isDraggingAttr:false,_isDraggingFileOrURL:false,dataDragEntered:function(k){function g(o){var n=DG.currDocumentController().contexts;var m;n&&n.some(function(p){m=p.getAttrRefByID(o);if(m){m.context=p}return !!m});return m}function j(n,m){return{context:m.context,collection:m.collection.get("collection"),attribute:m.attribute,text:m.attribute.get("name")}}var h;var i=k.dataTransfer.types.find(function(m){var n=m.startsWith("application/x-codap-attr-");return n&&m.replace("application/x-codap-attr-","")});i=i&&i.replace("application/x-codap-attr-","");var l=i&&g(i);if(l){this.set("dragAttributeData",j(this,l));this.set("_isDraggingAttr",true)}else{this.set("_isDraggingFileOrURL",true)}if(k.preventDefault){k.preventDefault()}},dataDragHovered:function(g){if(this.get("_isDraggingFileOrURL")){g.dataTransfer.dropEffect="copy"}if(g.preventDefault){g.preventDefault()}return YES},dataDragDropped:function(n){function h(q){var o=["http:","https:","data:"];var p=q.toLowerCase();return o.find(function(r){return p.startsWith(r)})}var g=this.get("layer");var k=n.dataTransfer;var i=(SC.browser.engine===SC.ENGINE.trident);var m=k.files,j=i?"URL":"text/uri-list",l=k.getData(j);if(m&&(m.length>0)){DG.appController.importFile(m[0])}else{if(!SC.empty(l)&&h(l)){SC.run(function(){DG.appController.importURL(l)})}else{if(!this.get("_isDraggingAttr")&&k.types.includes("text/html")){SC.run(function(){DG.appController.importHTMLTable(k.getData("text/html"))})}}}$(g).removeClass("dg-receive-outside-drop");if(n.preventDefault){n.preventDefault()}return false},dataDragExited:function(g){this.set("_isDraggingFileOrURL",false);this.set("_isDraggingAttr",false);this.set("dragAttributeData",null);if(g.preventDefault){g.preventDefault()}},nextValidKeyView:function(){return this}.property(),performKeyEquivalent:function(h,g){var i=YES;switch(h){case"ctrl_alt_c":DG.mainPage.toggleCalculator();break;case"ctrl_alt_t":DG.mainPage.openCaseTablesForEachContext();break;case"ctrl_alt_g":DG.mainPage.addGraph();break;case"ctrl_alt_s":DG.mainPage.addSlider();break;case"ctrl_alt_shift_t":DG.mainPage.addText();break;case"ctrl_z":DG.UndoHistory.undo();break;case"ctrl_y":case"ctrl_shift_z":DG.UndoHistory.redo();break;default:i=arguments.callee.base.apply(this,arguments)}return i},createComponentAndView:function(h,k){var i=k.type,j=i&&i.indexOf("."),m=j>=0?i.slice(j+1):null,l=m&&DG[m],g=l&&DG.mainPage.getComponentsOfType(l);if(k.allowMoreThanOne||!g||!g.length){DG.currDocumentController().createComponentAndView(null,k.type,k)}}}),docView:SC.outlet("mainPane.scrollView.contentView")}:{mainPane:SC.MainPane.design({childViews:"messageView".w(),messageView:SC.LabelView.design({layout:{centerX:0,centerY:0,width:400,height:300},controlSize:SC.LARGE_CONTROL_SIZE,fontWeight:SC.BOLD_WEIGHT,textAlign:SC.ALIGN_LEFT,localize:true,value:"DG.mainPage.mainPane.messageView.value"})})}}()));DG.mainPage.toggleCalculator=function(){DG.currDocumentController().toggleComponent(this.get("docView"),"calcView")};DG.mainPage.openCaseTablesForEachContext=function(){DG.currDocumentController().openCaseTablesForEachContext()};DG.mainPage.openCaseTableForNewContext=function(){DG.appController.importText("new","new_table")};DG.mainPage.addMap=function(){DG.currDocumentController().addMap(this.get("docView"))};DG.mainPage.addSlider=function(){return DG.currDocumentController().addSlider(this.get("docView"))};DG.mainPage.addGraph=function(){return DG.currDocumentController().addGraph(this.get("docView"))};DG.mainPage.addText=function(){return DG.currDocumentController().addText(this.get("docView"))};DG.mainPage.addMap=function(){return DG.currDocumentController().addMap(this.get("docView"))};DG.mainPage.getComponentsOfType=function(b){var c=this.get("docView"),a=c&&c.get("childViews"),d=a&&a.filter(function(e){return e.contentIsInstanceOf&&e.contentIsInstanceOf(b)});return d?d.getEach("contentView"):[]};DG.mainPage.closeAllComponents=function(){this.get("docView").destroyAllChildren()};DG.mainPage.addGameIfNotPresent=function(){if(DG.mainPage.mainPane.addGame&&(DG.mainPage.getComponentsOfType(DG.GameView).length===0)){DG.mainPage.mainPane.addGame()}DG.currDocumentController().updateSavedChangeCount()};sc_require("controllers/app_controller");sc_require("controllers/authorization");sc_require("utilities/iframe-phone-emulator");DG.main=function main(){DG.Browser.init();SC.$("body").addClass("dg");var u=SC.RootResponder.prototype.ignoreTouchHandle;SC.RootResponder.prototype.ignoreTouchHandle=function(x){var y=$(x.target).closest(".dg-wants-touch").length,z=$(x.target).closest(".dg-wants-sc-touch").length;return z?NO:(y?YES:u.call(this,x))};var c=SC.RootResponder.prototype.assignTouch;SC.RootResponder.prototype.assignTouch=function(y,x){if(y.hasEnded){console.warn("Attempt to assign a touch that is already finished.")}else{c.call(this,y,x)}};var e=SC.RootResponder.prototype.ignoreMouseHandle;SC.RootResponder.prototype.ignoreMouseHandle=function(y){var A=$(y.target).closest(".dg-wants-mouse").length,z=$(y.target).closest(".dg-wants-wheel").length&&y.type==="mousewheel",x=$(y.target).closest(".dg-wants-sc-mouse").length;return x?NO:(A?YES:(z?YES:e(y)))};var s=SC.RootResponder.prototype.ignoreKeyHandle;SC.RootResponder.prototype.ignoreKeyHandle=function(y){var x=$(y.target).closest(".dg-wants-keys").length;return x?YES:s.call(this,y)};var l=SC.RootResponder.prototype.ignoreSelectHandle;SC.RootResponder.prototype.ignoreSelectHandle=function(x){var y=$(x.target).closest(".dg-wants-select").length;return y?YES:l.call(this,x)};DG.getPath("mainPage.mainPane").appendTo($("#codap"));DG.showUserEntryView=true;function h(z){if(z){var x=DG.DocumentHelper.create({}),y;DG.currDocumentController().closeDocument();y=x.createNewDocumentWithDataInteractives(z);DG.currDocumentController().setDocument(y)}}function v(){function x(){var B=DG.ComponentController.extend({}).create(),z=DG.DataInteractivePhoneHandler.create({controller:B}),A=function(C,D){z.set("isPhoneInUse",true);z.doCommand(C,function(E){DG.doCommandResponseHandler(E,D)})};z.rpcEndpoint=new iframePhone.IframePhoneRpcEndpoint(A,"data-interactive",window.parent);z.rpcEndpoint.call({message:"codap-present"},function(C){DG.log("Got codap-present reply on embedded server data-interactive channel: "+JSON.stringify(C))});return z}function y(){var B=DG.ComponentController.extend({}).create(),z=DG.DataInteractivePhoneHandler.create({controller:B}),A=function(C,D){z.set("isPhoneInUse",true);z.doCommand(C,function(E){DG.doCommandResponseHandler(E,D)})};z.rpcEndpoint=new DG.IFramePhoneEmulator(A,"data-interactive","codap");DG.localIFramePhoneEndpoint=z.rpcEndpoint;z.rpcEndpoint.call({message:"codap-present"},function(C){DG.log("Got codap-present reply on embedded server data-interactive channel: "+JSON.stringify(C))});return z}DG.embeddedModePhoneHandlers=[];if(window.parent!==window){DG.embeddedModePhoneHandlers.push(x())}DG.embeddedModePhoneHandlers.push(y())}function g(x){if(!x){return null}if(typeof x==="string"&&x[0]!=="{"){return x}x=o(x);if((x.appName==="")&&(x.appVersion==="")&&(x.appBuildNum==="")){DG.log("File '%@' bypassed validation with empty metadata. This file should be re-saved with valid metadata.",x.name);return x}return(x.appName===DG.APPNAME)&&!!x.appVersion&&!!x.appBuildNum?x:null}function b(){var A=DG.get("startingDataInteractive");var y=[];if(A){var x=A.length;if((x>2)&&(A[0]==="[")&&(A[x-1]==="]")){var z=A.substr(1,x-2);y=z.split(",")}else{y.push(A)}}if(DG.get("runKey")){DG.set("showUserEntryView",false)}if(y.length){DG.set("showUserEntryView",false);h(y)}}function o(y){var x={},z={};if(y.contexts){y.contexts.forEach(function(A){if(A.collections){A.collections.forEach(function(B){if(B.cases){B.cases.forEach(function(C){var D=C.guid;if(!x[D]){x[D]=C}else{z[D]=C}})}DG.ObjectMap.forEach(z,function(E,C){var D=B.cases.indexOf(C);if(D>=0){B.cases.splice(D,1);DG.logUser("validateDocument: removed case with duplicate ID: '%@'",E)}});z={}})}})}return y}function q(y){var z=null,x;if(DG.cfmBaseUrl){x=document.createElement("A");x.href=DG.cfmBaseUrl;if(/\.concord\.org$/.test(x.hostname)||(x.hostname.indexOf(".")===-1)){x.pathname=(x.pathname[x.pathname.length-1]==="/"?x.pathname:(x.pathname+"/"))+y;z=x.href;DG.logWarn("Loading the "+y+" CFM file from "+z)}else{DG.logError("The cfmBaseUrl domain ("+x.hostname+") either needs to be *.concord.org or not have a TLD (like localhost)")}}if(!z){if(y==="app.js"){z="../../../../static/dg/fr/cert/resources/cloud-file-manager/js/app.js.ignore"}}return z}function p(){return new Promise(function(y,x){$.ajax({url:q("app.js"),dataType:"script",success:function(){y(true)},failure:function(){x(false)}})})}function w(B,x){var A=x.pathname.match(/(^.*\/static\/dg\/)[^\/]+(\/cert\/.*$)/);var y="https://codap.concord.org/releases/latest/static/dg/%@/cert/".loc(B);if(A){y=x.schema+x.host+A[1]+B+A[2]}var z=x.hash;if(x.pathname.indexOf("static/dg")>0){y="../../%@/cert".loc(B)}if(z.startsWith("#file=examples:")){z=""}return y+x.search+z}function i(x){if(x.run_remote_endpoint){DG.set("run_remote_endpoint",x.run_remote_endpoint)}DG.logUser("laraData: %@".fmt(JSON.stringify(x)))}function r(y,z){var x={autoSaveInterval:5,appName:DG.APPNAME,appVersion:DG.VERSION,appBuildNum:DG.BUILD_NUM,appOrMenuElemId:z.navBarId,hideMenuBar:DG.get("hideCFMMenu"),ui:{menuBar:{info:"Language menu",languageMenu:{currentLang:SC.Locale.currentLanguage,options:DG.locales.map(function(A){return{label:A.langName,langCode:A.langDigraph}}),onLangChanged:function(A){DG.log("Changed language: "+A);window.location=w(A,window.location)}}},menu:[{name:"DG.fileMenu.menuItem.newDocument".loc(),action:"newFileDialog"},{name:"DG.fileMenu.menuItem.openDocument".loc(),action:"openFileDialog"},{name:"DG.fileMenu.menuItem.closeDocument".loc(),action:function(){DG.cfmClient.closeFileDialog(function(){SC.run(function(){DG.appController.closeAndNewDocument()})})}},{name:"DG.fileMenu.menuItem.importFile".loc(),action:"importDataDialog"},{name:"DG.fileMenu.menuItem.revertTo".loc(),items:[{name:"DG.fileMenu.menuItem.revertToOpened".loc(),action:"revertToLastOpenedDialog"},{name:"DG.fileMenu.menuItem.revertToShared".loc(),action:"revertToSharedDialog"}]},"separator",{name:"DG.fileMenu.menuItem.saveDocument".loc(),action:"saveFileAsDialog"},{name:"DG.fileMenu.menuItem.copyDocument".loc(),action:"createCopy"},{name:"DG.fileMenu.menuItem.share".loc(),items:[{name:"DG.fileMenu.menuItem.shareGetLink".loc(),action:"shareGetLink"},{name:"DG.fileMenu.menuItem.shareUpdate".loc(),action:"shareUpdate"}]},{name:"DG.fileMenu.menuItem.renameDocument".loc(),action:"renameDialog"}]},appSetsWindowTitle:true,wrapFileContent:false,mimeType:"application/json",readableMimeTypes:["application/x-codap-document","application/json","text/csv","text/tab-separated-values"],extension:"codap",readableExtensions:["json","","codap","csv","txt"],enableLaraSharing:true,log:function(B,A){var C=A?JSON.stringify(A):"";DG.logUser("%@: %@",B,C)},providers:[{name:"readOnly",displayName:"DG.fileMenu.provider.examples.displayName".loc(),urlDisplayName:"examples",src:DG.get("exampleListURL"),alphabetize:false},{name:"lara",patch:true,patchObjectHash:function(A){return A.guid||JSON.stringify(A)},logLaraData:function(A){i(A)}},{name:"documentStore",displayName:"Concord Cloud",deprecationPhase:(function(){var A=DG.getQueryParam("deprecationPhase");if(A){return Number(A)}var C=new Date(),B=new Date(2016,10,15),D=new Date(2017,0,1);if(C>=D){return 3}if(C>=B){return 2}return 1}()),patch:true,patchObjectHash:function(A){return A.guid||JSON.stringify(A)}},"localFile"]};if(document.location.protocol==="https:"||document.location.hostname==="localhost"||document.location.hostname==="127.0.0.1"){x.providers.splice(1,0,{name:"googleDrive",mimeType:"application/json",clientId:DG.get("googleDriveClientID"),apiKey:DG.get("googleDriveAPIKey"),appId:DG.get("googleDriveAppId")})}if(DG.cfmConfigurationOverride){x=Object.assign(x,DG.cfmConfigurationOverride)}y.init(x)}function n(x){return new Promise(function(A,z){var B={recordid:x.externalDocumentId};if(DG.get("runKey")){B.runKey=DG.get("runKey");var y=B.runKey.indexOf("#");if(y>=0){B.runKey=B.runKey.substr(0,y)}}if(x.externalDocumentId!=null){$.ajax({url:"//document-store.concord.org/document/open",data:B,dataType:"json",xhrFields:{withCredentials:true},success:function(C){A(C)},error:function(C,E,D){z(D||E)}})}else{A(x)}})}function t(x){return new Promise(function(A,z){var y=x&&x.contexts,B=y&&y.map(function(C){return n(C)});if(B){Promise.all(B).then(function(C){x.contexts=C;A(x)},function(C){z(C)})}else{A(x)}})}function j(y){var x=document.createElement("a");x.href=y;return x}function a(B,x){var A={codap:"application/vnd.codap+json",json:"application/json",geojson:"application/geo+json",csv:"application/csv",txt:"application/csv"};var y=x&&j(x);var z=y&&y.pathname;if(B){return B}if(z){return A[z.replace(/.*\./g,"")]}}function k(y,x){return new Promise(function(K,N){function z(){return{name:"Untitled Document",components:[],contexts:[],globals:[],appName:DG.APPNAME,appVersion:DG.VERSION,appBuildNum:DG.BUILD_NUM,lang:SC.Locale.currentLanguage}}function M(P,Q,O){return{name:"Untitled Document",components:[{type:"DG.GameView",document:DG.currDocumentController().content,layout:{isVisible:false},componentStorage:{currentGameName:Q,currentGameUrl:DG.get("pluginURL")+O,savedGameState:P}}],contexts:[],globals:[],appName:DG.APPNAME,appVersion:DG.VERSION,appBuildNum:DG.BUILD_NUM,lang:SC.Locale.currentLanguage}}function I(P,Q,R){var O={contentType:"text/csv",url:Q,text:P,datasetName:R,showCaseTable:true};return M(O,"Import CSV","/Importer/")}function A(P,Q,R){var O={contentType:"application/geo+json",text:P,name:Q,datasetName:R};return M(O,"Import GeoJSON","/Importer/")}var H=x||{};var F=H.url||("file:"+H.filename);var E=a(H.contentType,F);var B=F&&j(F);var D=B&&B.pathname;var C=D?D.replace(/.*\//g,"").replace(/\..*/,""):"data";var J;if(E==="application/json"||typeof y==="object"){if(typeof y==="string"){try{y=JSON.parse(y)}catch(G){N('JSON parse error in "%@"'.fmt(F));return}}if(y.appName!=null&&y.appVersion!=null){J="application/vnd.codap+json"}else{if(y.type&&(y.type==="FeatureCollection"||y.type==="Topology")){J="application/vnd.geo+json"}}}else{J=E}if(!y){K(z())}else{if(J==="application/csv"){K(I(y,F,C))}else{if(J==="application/vnd.geo+json"){K(A(y,F,C))}else{if(J==="application/vnd.codap+json"){t(y).then(function(P){var O=g(y);if(!O){N("DG.AppController.openDocument.error.invalid_format".loc())}else{K(O)}},function(O){N(O)})}else{N("Error opening document: %@ -- unknown mime type: %@".loc(F,J))}}}}})}function f(z,x,y){if(typeof(x[y])!=="undefined"){z[y]=x[y]}else{delete z[y]}}function d(){var x=createReactClassFactory({close:function(){DG.cfmClient.hideBlockingModal()},authorizeUrlDocument:function(){DG.cfmClient.parseUrlAuthorizeAndOpen()},createNewDocument:function(){this.close();DG.cfmClient.newFile()},openDocument:function(){this.close();DG.cfmClient.openFileDialog()},componentDidMount:function(){this.refs.openButton.focus()},render:function(){var y=ReactDOMFactories.button,z=ReactDOMFactories.div;return z({onKeyDown:function(A){if(A.keyCode===27){this.createNewDocument()}else{if(A.keyCode===13){this.openDocument()}}}.bind(this)},[z({style:{margin:10},key:2},y({ref:"openButton",onClick:this.openDocument},"DG.main.userEntryView.openDocument".loc())),z({style:{margin:10},key:1},y({ref:"newButton",onClick:this.createNewDocument},"DG.main.userEntryView.newDocument".loc()))])}});if(DG.get("showUserEntryView")){DG.cfmClient.showBlockingModal({title:"DG.main.userEntryView.title".loc(),message:x({}),onDrop:function(){DG.cfmClient.hideBlockingModal()}})}}function m(y){var x;var z=false;DG.cfm=y;if(DG.cfm){DG.cfm.clientConnect(function(C){var A,D;function B(){!z&&DG.cfmClient&&DG.cfmClient.dirty(DG.currDocumentController().get("hasUnsavedChanges"))}function E(F){return F?F.replace(/\.codap$/,"").replace(/\.json$/,""):"unknown"}switch(C.type){case"connected":DG.cfmClient=C.data.client;DG.cfmClient.setProviderOptions("documentStore",{appName:DG.APPNAME,appVersion:DG.VERSION,appBuildNum:DG.BUILD_NUM});DG.cfmClient._ui.setMenuBarInfo("Version "+DG.VERSION+" ("+DG.BUILD_NUM+")");DG.currDocumentController().addObserver("hasUnsavedChanges",function(){B()});if(!SC.empty(DG.startingDocUrl)){DG.cfmClient.openUrlFile(DG.startingDocUrl)}break;case"requiresUserInteraction":SC.run(function(){DG.splash.hideSplash()});break;case"ready":if(SC.empty(DG.startingDocUrl)){d()}DG.splash.hideSplash();if(C.state.metadata&&C.state.metadata.name){DG.currDocumentController().set("documentName",E(C.state.metadata.name))}break;case"closedFile":d();break;case"getContent":DG.currDocumentController().captureCurrentDocumentState(true).then(function(F){var H=C.data&&C.data.shared||{},I=F.metadata||{},G=g(F);x=DG.currDocumentController().get("changeCount");if(G){f(G,H,"_permissions");I.shared=$.extend(true,{},H);G.metadata=I}else{DG.logUser("getContent: attempted to return invalid document!")}C.callback(G)},function(F){DG.log(F)});break;case"willOpenFile":SC.run(function(){DG.splash.showSplash()});break;case"newedFile":SC.run(function(){DG.appController.closeAndNewDocument();DG.splash.hideSplash()});break;case"openedFile":SC.run(function(){DG.splash.showSplash()});setTimeout(function(){SC.run(function(){DG.cfmClient.hideBlockingModal();if(C&&C.state&&C.state.metadata&&C.state.metadata.provider&&C.state.metadata.provider.name==="localFile"){C.data.metadata.filename=C.state.metadata.providerData.file.name}k(C.data.content,C.data.metadata).then(function(F){SC.run(function(){var H=C.data.content?C.data.content.metadata:C.data.metadata,G=H&&H.shared,I=G?$.extend(true,{},G):{};z=true;DG.appController.closeDocument();DG.store=DG.ModelStore.create();DG.currDocumentController().setDocument(DG.Document.createDocument(F));DG.set("showUserEntryView",false);C.callback(null,I);z=false})},function(F){DG.logWarn(F);C.callback("DG.AppController.openDocument.error.general".loc());C.state.dirty=false;DG.cfmClient.closeFile();z=false})})},0);break;case"savedFile":SC.run(function(){if(DG.currDocumentController().get("changeCount")===x){DG.currDocumentController().updateSavedChangeCount()}B();DG.removeQueryParams(["di","di-override"])});break;case"sharedFile":SC.run(function(){D=(C.data&&C.data.shared)||{};if(DG.appController.get("_undoRedoShareInProgressCount")){DG.currDocumentController().set("sharedMetadata",D)}else{DG.UndoHistory.execute(DG.Command.create({name:"document.share",undoString:"DG.Undo.document.share",redoString:"DG.Redo.document.share",log:"Shared document",execute:function(){var F;this._cfmSharedMetadata=$.extend(true,{},D);this.causedChange=false;if(!DG.appController.get("_undoRedoShareInProgressCount")){F=DG.currDocumentController().get("sharedMetadata");if(!_.isEqual(F,D)){DG.currDocumentController().set("sharedMetadata",D);this.causedChange=true}}},undo:function(){DG.appController.incrementProperty("_undoRedoShareInProgressCount");DG.cfmClient.unshare(function(){DG.appController.decrementProperty("_undoRedoShareInProgressCount")})},redo:function(){DG.appController.incrementProperty("_undoRedoShareInProgressCount");DG.cfmClient.reshare(this._cfmSharedMetadata,function(){DG.appController.decrementProperty("_undoRedoShareInProgressCount")})}}))}});break;case"unsharedFile":SC.run(function(){A=DG.currDocumentController();var F=A.get("sharedMetadata")||{};D=(C.data&&C.data.shared)||{};if(DG.appController.get("_undoRedoShareInProgressCount")){DG.currDocumentController().set("sharedMetadata",D)}else{DG.UndoHistory.execute(DG.Command.create({name:"document.unshare",undoString:"DG.Undo.document.unshare",redoString:"DG.Redo.document.unshare",log:"Unshared document",execute:function(){this.causedChange=false;if(!DG.appController.get("_undoRedoShareInProgressCount")){F=DG.currDocumentController().get("sharedMetadata");this._orgSharedMetadata=$.extend(true,{},F);if(!_.isEqual(F,D)){DG.currDocumentController().set("sharedMetadata",D);this.causedChange=true}}},undo:function(){DG.appController.incrementProperty("_undoRedoShareInProgressCount");DG.cfmClient.reshare(this._orgSharedMetadata,function(){DG.appController.decrementProperty("_undoRedoShareInProgressCount")})},redo:function(){DG.appController.incrementProperty("_undoRedoShareInProgressCount");DG.cfmClient.unshare(function(){DG.appController.decrementProperty("_undoRedoShareInProgressCount")})}}))}});break;case"importedData":SC.run(function(){if(C.data.file){DG.appController.importFile(C.data.file.object)}else{if(C.data.url&&(C.data.via==="select")){DG.appController.importURL(C.data.url,C.data.componentType,C.data.name)}else{if(C.data.text&&C.data.name){DG.appController.importText(C.data.text,C.data.name)}}}});break;case"renamedFile":SC.run(function(){var F=DG.currDocumentController();var G=C.state.metadata.name;F.set("documentName",G)});break;case"log":SC.run(function(){if(C.data.logEvent==="logLaraData"){i(C.data.logEventData)}});break}});DG.exportFile=function(B,D,A,C){DG.cfmClient.saveSecondaryFileAsDialog(B,D,A,C)}}}DG.splash.showSplash();if(DG.get("embeddedMode")==="yes"){$("html").addClass("dg-embedded-mode");v();b()}else{if(DG.get("embeddedServer")==="yes"){v()}b()}Promise.all([p(),DG.cfmViewConfig]).then(function(x){var y=x[1];r(CloudFileManager,y);m(CloudFileManager)})};window.main=function(){DG.main();DG.mainPage.invokeLater(function(){DG.mainPage.mainPane.adjust({height:window.innerHeight});DG.mainPage.invokeLater(function(){DG.mainPage.mainPane.adjust({height:null})},20)},2000)};