forked from barmalei/zebkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
zebra.min.js
1 lines (1 loc) · 333 KB
/
zebra.min.js
1
(function(){(function(){function isString(o){return typeof o!=="undefined"&&o!==null&&(typeof o==="string"||o.constructor===String)}function isNumber(o){return typeof o!=="undefined"&&o!==null&&(typeof o==="number"||o.constructor===Number)}function isBoolean(o){return typeof o!=="undefined"&&o!==null&&(typeof o==="boolean"||o.constructor===Boolean)}if(!String.prototype.trim){String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}}if(!Array.prototype.indexOf){Array.prototype.indexOf=function(searchElement){if(this==null){throw new TypeError()}var t=Object(this),len=t.length>>>0;if(len===0){return -1}var n=0;if(arguments.length>0){n=Number(arguments[1]);if(n!=n){n=0}else{if(n!==0&&n!=Infinity&&n!=-Infinity){n=(n>0||-1)*~~Math.abs(n)}}}if(n>=len){return -1}var k=n>=0?n:Math.max(len-Math.abs(n),0);for(;k<len;k++){if(k in t&&t[k]===searchElement){return k}}return -1}}if(!Array.isArray){Array.isArray=function(a){return Object.prototype.toString.call(a)=="[object Array]"}}var $$$=0,namespaces={},namespace=function(nsname,dontCreate){if(isString(nsname)===false){throw new Error("Invalid name space name : '"+nsname+"'")}if(namespaces.hasOwnProperty(nsname)){return namespaces[nsname]}if(dontCreate===true){throw new Error("Name space '"+nsname+"' doesn't exist")}function Package(){this.$url=null;if(typeof document!=="undefined"){var s=document.getElementsByTagName("script"),ss=s[s.length-1].getAttribute("src"),i=ss==null?-1:ss.lastIndexOf("/");this.$url=(i>0)?new zebra.URL(ss.substring(0,i+1)):new zebra.URL(document.location.toString()).getParentURL()}}if(namespaces.hasOwnProperty(nsname)){throw new Error("Name space '"+nsname+"' already exists")}var f=function(name){if(arguments.length===0){return f.$env}if(typeof name==="function"){for(var k in f){if(f[k] instanceof Package){name(k,f[k])}}return null}var b=Array.isArray(name);if(isString(name)===false&&b===false){for(var k in name){if(name.hasOwnProperty(k)){f.$env[k]=name[k]}}return}if(b){for(var i=0;i<name.length;i++){f(name[i])}return null}if(f[name] instanceof Package){return f[name]}var names=name.split("."),target=f;for(var i=0,k=names[0];i<names.length;i++,k=[k,".",names[i]].join("")){var n=names[i],p=target[n];if(typeof p==="undefined"){p=new Package();target[n]=p;f[k]=p}else{if((p instanceof Package)===false){throw new Error("Package '"+name+"' conflicts with variable '"+n+"'")}}target=p}return target};f.Import=function(){var ns=["=",nsname,"."].join(""),code=[],packages=arguments.length===0?null:Array.prototype.slice.call(arguments,0);f(function(n,p){if(packages==null||packages.indexOf(n)>=0){for(var k in p){if(k[0]!="$"&&k[0]!="_"&&(p[k] instanceof Package)===false&&p.hasOwnProperty(k)){code.push([k,ns,n,".",k].join(""))}}if(packages!=null){packages.splice(packages.indexOf(n),1)}}});if(packages!=null&&packages.length!==0){throw new Error("Unknown package(s): "+packages.join(","))}return code.length>0?["var ",code.join(","),";"].join(""):null};f.$env={};namespaces[nsname]=f;return f};var pkg=zebra=namespace("zebra"),CNAME=pkg.CNAME="$",CDNAME="",FN=pkg.$FN=(typeof namespace.name==="undefined")?(function(f){var mt=f.toString().match(/^function\s+([^\s(]+)/);return(mt==null)?CNAME:mt[1]}):(function(f){return f.name});pkg.namespaces=namespaces;pkg.namespace=namespace;pkg.$global=(typeof window!=="undefined"&&window!=null)?window:this;pkg.isString=isString;pkg.isNumber=isNumber;pkg.isBoolean=isBoolean;pkg.version="4.2014";pkg.$caller=null;function mnf(name,params){var cln=this.$clazz&&this.$clazz.$name?this.$clazz.$name+".":"";throw new ReferenceError("Method '"+cln+(name===CNAME?"constructor":name)+"("+params+")' not found")}function $toString(){return this.$hash$}function make_template(pt,tf,p){tf.$hash$=["$ZBr$",$$$++].join("");tf.toString=$toString;if(pt!=null){tf.prototype.$clazz=tf}tf.$clazz=pt;tf.prototype.toString=$toString;tf.prototype.constructor=tf;if(p&&p.length>0){tf.$parents={};for(var i=0;i<p.length;i++){var l=p[i];if(l==null||typeof l!=="function"){throw new ReferenceError("Undefined parent class or interface ["+i+"]")}tf.$parents[l]=true;if(l.$parents){var pp=l.$parents;for(var k in pp){if(pp.hasOwnProperty(k)){tf.$parents[k]=true}}}}}return tf}pkg.getPropertySetter=function(obj,name){var pi=obj.constructor.$propertyInfo;if(pi!=null){if(typeof pi[name]==="undefined"){var m=obj[["set",name[0].toUpperCase(),name.substring(1)].join("")];pi[name]=(typeof m==="function")?m:null}return pi[name]}var m=obj[["set",name[0].toUpperCase(),name.substring(1)].join("")];return(typeof m==="function")?m:null};pkg.properties=function(target,p){for(var k in p){if(k[0]!="$"&&p.hasOwnProperty(k)&&typeof p[k]!=="function"){var v=p[k],m=zebra.getPropertySetter(target,k);if(v&&v.$new!=null){v=v.$new()}if(m==null){target[k]=v}else{if(Array.isArray(v)){m.apply(target,v)}else{m.call(target,v)}}}}return target};pkg.Interface=make_template(null,function(){var $Interface=make_template(pkg.Interface,function(){if(arguments.length>0){return new (pkg.Class($Interface,arguments[0]))()}},arguments);return $Interface});pkg.$Extended=pkg.Interface();function ProxyMethod(name,f){if(isString(name)===false){throw new TypeError("Method name has not been defined")}var a=null;if(arguments.length==1){a=function(){var nm=a.methods[arguments.length];if(nm!=null){var cm=pkg.$caller;pkg.$caller=nm;try{return nm.apply(this,arguments)}catch(e){throw e}finally{pkg.$caller=cm}}mnf.call(this,a.methodName,arguments.length)};a.methods={}}else{a=function(){var cm=pkg.$caller;pkg.$caller=a.f;try{return a.f.apply(this,arguments)}catch(e){throw e}finally{pkg.$caller=cm}};a.f=f}a.$clone$=function(){if(a.methodName===CNAME){return null}if(a.f){return ProxyMethod(a.methodName,a.f)}var m=ProxyMethod(a.methodName);for(var k in a.methods){if(a.methods.hasOwnProperty(k)){m.methods[k]=a.methods[k]}}return m};a.methodName=name;return a}pkg.Class=make_template(null,function(){if(arguments.length===0){throw new Error("No class definition was found")}if(Array.isArray(arguments[arguments.length-1])===false){throw new Error("Invalid class definition was found")}if(arguments.length>1&&typeof arguments[0]!=="function"){throw new ReferenceError("Invalid parent class '"+arguments[0]+"'")}var df=arguments[arguments.length-1],$parent=null,args=Array.prototype.slice.call(arguments,0,arguments.length-1);if(args.length>0&&(args[0]==null||args[0].$clazz==pkg.Class)){$parent=args[0]}var $template=make_template(pkg.Class,function(){this.$hash$=["$zObj_",$$$++].join("");if(arguments.length>0){var a=arguments[arguments.length-1];if(Array.isArray(a)===true&&typeof a[0]==="function"){a=a[0];var args=[$template],k=arguments.length-2;for(;k>=0&&pkg.instanceOf(arguments[k],pkg.Interface);k--){args.push(arguments[k])}args.push(arguments[arguments.length-1]);var cl=pkg.Class.apply(null,args),f=function(){};cl.$name=$template.$name;f.prototype=cl.prototype;var o=new f();cl.apply(o,Array.prototype.slice.call(arguments,0,k+1));o.constructor=cl;return o}}this[CNAME]&&this[CNAME].apply(this,arguments)},args);$template.$propertyInfo={};$template.$parent=$parent;if($parent!=null){for(var k in $parent.prototype){if($parent.prototype.hasOwnProperty(k)){var f=$parent.prototype[k];if(f!=null&&f.$clone$!=null){f=f.$clone$();if(f==null){continue}}$template.prototype[k]=f}}}$template.prototype.extend=function(){var c=this.$clazz,l=arguments.length,f=arguments[l-1];if(pkg.instanceOf(this,pkg.$Extended)===false){c=Class(c,pkg.$Extended,[]);c.$name=this.$clazz.$name;this.$clazz=c}if(Array.isArray(f)){for(var i=0;i<f.length;i++){var n=FN(f[i]);if(n==CDNAME){n=CNAME}if(n===CNAME){f[i].call(this);continue}else{var pv=this[n];if(pv!=null&&this.hasOwnProperty(n)===false){this[n]=(pv.$clone$!=null?pv.$clone$():ProxyMethod(n,pv))}this[n]=createMethod(n,f[i],this,c)}}l--}for(var i=0;i<l;i++){if(pkg.instanceOf(arguments[i],pkg.Interface)===false){throw new Error("Invalid argument: "+arguments[i])}c.$parents[arguments[i]]=true}return this};$template.prototype.$super=function(){if(pkg.$caller){var name=pkg.$caller.methodName,$s=pkg.$caller.boundTo.$parent,args=arguments;if(arguments.length>0&&typeof arguments[0]==="function"){name=arguments[0].methodName;args=Array.prototype.slice.call(arguments,1)}var params=args.length;while($s!=null){var m=$s.prototype[name];if(m&&(typeof m.methods==="undefined"||m.methods[params])){return m.apply(this,args)}$s=$s.$parent}mnf.call(this,name,params)}throw new Error("$super is called outside of class context")};$template.prototype.$clazz=$template;$template.prototype.$this=function(){return pkg.$caller.boundTo.prototype[CNAME].apply(this,arguments)};if(typeof $template.prototype.properties==="undefined"){$template.prototype.properties=function(p){return pkg.properties(this,p)}}if(typeof $template.prototype.bind==="undefined"){$template.prototype.bind=function(){if(this._==null){throw new Error("Listeners are not supported")}return this._.add.apply(this._,arguments)}}if(typeof $template.prototype.unbind==="undefined"){$template.prototype.unbind=function(){if(this._==null){throw new Error("Listeners are not supported")}this._.remove.apply(this._,arguments)}}function createMethod(n,f,obj,clazz){var arity=f.length,vv=obj[n];if(f.boundTo!=null){f=(function(f){return function(){return f.apply(this,arguments)}})(f,arity,n)}f.boundTo=clazz;f.methodName=n;if(typeof vv==="undefined"){return ProxyMethod(n,f)}if(typeof vv==="function"){if(vv.$clone$!=null){if(typeof vv.methods==="undefined"){if(vv.f.boundTo!=clazz||arity==vv.f.length){vv.f=f;return vv}var sw=ProxyMethod(n);sw.methods[vv.f.length]=vv.f;sw.methods[arity]=f;return sw}vv.methods[arity]=f;return vv}if(arity==vv.length){return ProxyMethod(n,f)}var sw=ProxyMethod(n);vv.methodName=n;vv.boundTo=clazz;sw.methods[vv.length]=vv;sw.methods[arity]=f;return sw}throw new Error("Method '"+n+"' conflicts to property")}extend=function(df){if(Array.isArray(df)===false){throw new Error("Wrong class definition '"+df+"', array is expected")}for(var i=0;i<df.length;i++){var f=df[i],n=FN(f),arity=f.length;if(n==CDNAME){n=CNAME}if(n[0]==="$"){if(n==="$prototype"){var protoFields={};f.call(protoFields,$template);for(var k in protoFields){if(protoFields.hasOwnProperty(k)){var protoFieldVal=protoFields[k];if(k==CDNAME){k=CNAME}$template.prototype[k]=protoFieldVal;if(protoFieldVal&&typeof protoFieldVal==="function"){protoFieldVal.methodName=k;protoFieldVal.boundTo=$template}}}continue}if(n==="$clazz"){f.call($template);continue}}$template.prototype[n]=createMethod(n,f,$template.prototype,$template)}};extend(df);if($parent!=null){for(var k in $parent){if(k[0]!="$"&&$parent.hasOwnProperty(k)&&$template.hasOwnProperty(k)===false){$template[k]=$parent[k]}}}$template.extend=extend;$template.getMethods=function(name){var m=[];if(name==CDNAME){name=CNAME}for(var n in this.prototype){var f=this.prototype[n];if(arguments.length>0&&name!=n){continue}if(typeof f==="function"){if(f.$clone$!=null){if(f.methods!=null){for(var mk in f.methods){m.push(f.methods[mk])}}else{m.push(f.f)}}else{m.push(f)}}}return m};$template.getMethod=function(name,params){if(name==CDNAME){name=CNAME}var m=this.prototype[name];if(typeof m==="function"){if(m.$clone$!=null){if(m.methods==null){return m.f}if(typeof params==="undefined"){if(m.methods[0]){return m.methods[0]}for(var k in m.methods){if(m.methods.hasOwnProperty(k)){return m.methods[k]}}return null}m=m.methods[params]}if(m){return m}}return null};if($template.$parent!=null&&$template.$parent.prototype[CNAME]!=null&&typeof $template.prototype[CNAME]==="undefined"){$template.prototype[CNAME]=$template.$parent.prototype[CNAME]}return $template});var Class=pkg.Class,$busy=1,$cachedO=pkg.$cachedO={},$cachedE=pkg.$cachedE=[],$f=[];pkg.$cacheSize=5000;pkg.$cache=function(key){if(pkg.$global[key]){return pkg.$global[key]}if($cachedO.hasOwnProperty(key)===true){var e=$cachedO[key];if(e.i<($cachedE.length-1)){var pn=$cachedE[e.i+1];$cachedE[e.i]=pn;$cachedE[++e.i]=key;$cachedO[pn].i--}return e.o}var ctx=pkg.$global,i=0,j=0;for(;ctx!=null;){i=key.indexOf(".",j);if(i<0){ctx=ctx[key.substring(j,key.length)];break}ctx=ctx[key.substring(j,i)];j=i+1}if(ctx!=null){if($cachedE.length>=pkg.$cacheSize){var n=$cachedE[0];$cachedE[0]=key;$cachedO[key]={o:ctx,i:0};delete $cachedO[n]}else{$cachedO[key]={o:ctx,i:$cachedE.length};$cachedE[$cachedE.length]=key}return ctx}throw new Error("Class '"+key+"' cannot be found")};Class.forName=function(name){return pkg.$cache(name)};pkg.instanceOf=function(obj,clazz){if(clazz!=null){if(obj==null||typeof obj.$clazz==="undefined"){return false}var c=obj.$clazz;return c!=null&&(c===clazz||(typeof c.$parents!=="undefined"&&c.$parents.hasOwnProperty(clazz)))}throw new Error("instanceOf(): null class")};pkg.ready=function(){if(arguments.length===0){if($busy>0){$busy--}}else{if(arguments.length==1&&$busy===0&&$f.length===0){arguments[0]();return}}for(var i=0;i<arguments.length;i++){$f.push(arguments[i])}while($busy===0&&$f.length>0){$f.shift()()}};pkg.busy=function(){$busy++};pkg.Dummy=Class([]);pkg.isInBrowser=typeof navigator!=="undefined";pkg.isIE=pkg.isInBrowser&&(Object.hasOwnProperty.call(window,"ActiveXObject")||!!window.ActiveXObject);pkg.isFF=pkg.isInBrowser&&window.mozInnerScreenX!=null;pkg.isTouchable=pkg.isInBrowser&&((pkg.isIE===false&&(!!("ontouchstart" in window)||!!("onmsgesturechange" in window)))||(!!window.navigator.msPointerEnabled&&!!window.navigator.msMaxTouchPoints>0));pkg.isMacOS=pkg.isInBrowser&&navigator.platform.toUpperCase().indexOf("MAC")!==-1;function complete(){pkg(function(n,p){function collect(pp,p){for(var k in p){if(k[0]!="$"&&p.hasOwnProperty(k)&&zebra.instanceOf(p[k],Class)){p[k].$name=pp?[pp,k].join("."):k;collect(k,p[k])}}}collect(null,p)});pkg.ready()}if(pkg.isInBrowser){var m=window.location.search.match(/[?&][a-zA-Z0-9_.]+=[^?&=]+/g),env={};for(var i=0;m&&i<m.length;i++){var l=m[i].split("=");env[l[0].substring(1)]=l[1]}pkg(env);var purl=/^([a-zA-Z_0-9]+\:)\/\/([^\/]*)(\/[^?]*)(\?[^?\/]*)?/;pkg.URL=function(url){var a=document.createElement("a");a.href=url;var m=purl.exec(a.href);if(m==null){m=purl.exec(window.location);if(m==null){throw Error("Cannot resolve '"+url+"' url")}var p=m[3];a.href=m[1]+"//"+m[2]+p.substring(0,p.lastIndexOf("/")+1)+url;m=purl.exec(a.href)}this.path=m[3].replace(/[\/]+/g,"/");this.href=a.href;this.protocol=(m[1]!=null?m[1].toLowerCase():null);this.host=m[2];this.qs=m[4]};pkg.URL.prototype.toString=function(){return this.href};pkg.URL.prototype.getParentURL=function(){var i=this.path.lastIndexOf("/");if(i<0){return null}var p=this.path.substring(0,i+1);return new pkg.URL([this.protocol,"//",this.host,p].join(""))};pkg.URL.isAbsolute=function(u){return/^[a-zA-Z]+\:\/\//i.test(u)};pkg.URL.prototype.join=function(p){if(pkg.URL.isAbsolute(p)){throw new Error("Absolute URL '"+p+"' cannot be joined")}return p[0]=="/"?[this.protocol,"//",this.host,p].join(""):[this.protocol,"//",this.host,this.path,this.path[this.path.length-1]=="/"?"":"/",p].join("")};var $interval=setInterval(function(){if(document.readyState=="complete"){clearInterval($interval);complete()}},100)}else{complete()}})();(function(pkg,Class,Interface){pkg.newInstance=function(clazz,args){if(args&&args.length>0){var f=function(){};f.prototype=clazz.prototype;var o=new f();o.constructor=clazz;clazz.apply(o,args);return o}return new clazz()};function hex(v){return(v<16)?["0",v.toString(16)].join(""):v.toString(16)}pkg.findInTree=function(root,path,eq,cb){var findRE=/(\/\/|\/)?([^\[\/]+)(\[\s*(\@[a-zA-Z_][a-zA-Z0-9_\.]*)\s*\=\s*([0-9]+|true|false|\'[^']*\')\s*\])?/g,m=null,res=[];function _find(root,ms,idx,cb){function list_child(r,name,deep,cb){if(r.kids){for(var i=0;i<r.kids.length;i++){var kid=r.kids[i];if(name=="*"||eq(kid,name)){if(cb(kid)){return true}}if(deep&&list_child(kid,name,deep,cb)){return true}}}return false}if(ms==null||idx>=ms.length){return cb(root)}var m=ms[idx];return list_child(root,m[2],m[1]=="//",function(child){if(m[3]&&child[m[4].substring(1)]!=m[5]){return false}return _find(child,ms,idx+1,cb)})}var c=0;while(m=findRE.exec(path)){if(m[1]==null||m[2]==null||m[2].trim().length===0){break}c+=m[0].length;if(m[3]&&m[5][0]=="'"){m[5]=m[5].substring(1,m[5].length-1)}res.push(m)}if(res.length==0||c<path.length){throw new Error("Invalid path: '"+path+"',"+c)}_find({kids:[root]},res,0,cb)};pkg.rgb=function(r,g,b,a){this.isOpaque=false;if(arguments.length==1){if(zebra.isString(r)){this.s=r;if(r[0]==="#"){r=parseInt(r.substring(1),16)}else{if(r[0]==="r"&&r[1]==="g"&&r[2]==="b"){var i=r.indexOf("(",3),p=r.substring(i+1,r.indexOf(")",i+1)).split(",");this.r=parseInt(p[0].trim(),10);this.g=parseInt(p[1].trim(),10);this.b=parseInt(p[2].trim(),10);if(p.length>3){this.a=parseInt(p[3].trim(),10);this.isOpaque=(this.a!=1)}return}}}this.r=r>>16;this.g=(r>>8)&255;this.b=(r&255)}else{this.r=r;this.g=g;this.b=b;if(arguments.length>3){this.a=a}}if(this.s==null){this.s=(typeof this.a!=="undefined")?["rgba(",this.r,",",this.g,",",this.b,",",this.a,")"].join(""):["#",hex(this.r),hex(this.g),hex(this.b)].join("")}};var rgb=pkg.rgb;rgb.prototype.toString=function(){return this.s};rgb.black=new rgb(0);rgb.white=new rgb(16777215);rgb.red=new rgb(255,0,0);rgb.blue=new rgb(0,0,255);rgb.green=new rgb(0,255,0);rgb.gray=new rgb(128,128,128);rgb.lightGray=new rgb(211,211,211);rgb.darkGray=new rgb(169,169,169);rgb.orange=new rgb(255,165,0);rgb.yellow=new rgb(255,255,0);rgb.pink=new rgb(255,192,203);rgb.cyan=new rgb(0,255,255);rgb.magenta=new rgb(255,0,255);rgb.darkBlue=new rgb(0,0,140);rgb.transparent=new rgb(0,0,0,1);pkg.intersection=function(x1,y1,w1,h1,x2,y2,w2,h2,r){r.x=x1>x2?x1:x2;r.width=Math.min(x1+w1,x2+w2)-r.x;r.y=y1>y2?y1:y2;r.height=Math.min(y1+h1,y2+h2)-r.y};pkg.isIntersect=function(x1,y1,w1,h1,x2,y2,w2,h2){return(Math.min(x1+w1,x2+w2)-(x1>x2?x1:x2))>0&&(Math.min(y1+h1,y2+h2)-(y1>y2?y1:y2))>0};pkg.unite=function(x1,y1,w1,h1,x2,y2,w2,h2,r){r.x=x1<x2?x1:x2;r.y=y1<y2?y1:y2;r.width=Math.max(x1+w1,x2+w2)-r.x;r.height=Math.max(y1+h1,y2+h2)-r.y};pkg.arraycopy=function(src,spos,dest,dpos,dlen){for(var i=0;i<dlen;i++){dest[i+dpos]=src[spos+i]}};var letterRE=/[A-Za-z]/;pkg.isLetter=function(ch){if(ch.length!=1){throw new Error("Incorrect character")}return letterRE.test(ch)};var $NewListener=function(){if(arguments.length===0){arguments=["fired"]}var clazz=function(){};if(arguments.length==1){var name=arguments[0];clazz.prototype.add=function(){if(this.v==null){this.v=[]}var ctx=this;l=arguments[arguments.length-1];if(typeof l!=="function"){ctx=l;l=l[name];if(l==null||typeof l!=="function"){throw new Error("Instance doesn't declare '"+name+"' listener method")}}if(arguments.length>1&&arguments[0]!=name){throw new Error("Unknown event type :"+name)}this.v.push(ctx,l);return l};clazz.prototype.remove=function(l){if(this.v!=null){if(arguments.length===0){this.v.length=0}else{var i=0;while((i=this.v.indexOf(l))>=0){if(i%2>0){i--}this.v.splice(i,2)}}}};clazz.prototype[name]=function(){if(this.v!=null){for(var i=0;i<this.v.length;i+=2){this.v[i+1].apply(this.v[i],arguments)}}}}else{var names={};for(var i=0;i<arguments.length;i++){names[arguments[i]]=true}clazz.prototype.add=function(l){if(this.methods==null){this.methods={}}var n=null;if(arguments.length>1){n=arguments[0];l=arguments[arguments.length-1]}if(typeof l==="function"){if(n==null){n=zebra.$FN(l)}if(n!=""&&names.hasOwnProperty(n)===false){throw new Error("Unknown event type "+n)}if(this.methods[n]==null){this.methods[n]=[]}this.methods[n].push(this,l)}else{var b=false;for(var k in names){if(typeof l[k]==="function"){b=true;if(this.methods[k]==null){this.methods[k]=[]}this.methods[k].push(l,l[k])}}if(b===false){throw new Error("No listener methods have been found")}}return l};for(var i=0;i<arguments.length;i++){var m=arguments[i];(function(m){clazz.prototype[m]=function(){if(this.methods!=null){var c=this.methods[m];if(c!=null){for(var i=0;i<c.length;i+=2){c[i+1].apply(c[i],arguments)}}c=this.methods[""];if(c!=null){for(var i=0;i<c.length;i+=2){c[i+1].apply(c[i],arguments)}}}}})(m)}clazz.prototype.remove=function(l){if(this.methods!=null){if(arguments.length===0){for(var k in this.methods){if(this.methods.hasOwnProperty(k)){this.methods[k].length=0}}this.methods={}}else{for(var k in this.methods){var v=this.methods[k],i=0;while((i=v.indexOf(l))>=0){if(i%2>0){i--}v.splice(i,2)}if(v.length===0){delete this.methods[k]}}}}}}return clazz};pkg.Listeners=$NewListener();pkg.ListenersClass=$NewListener;var PosListeners=pkg.ListenersClass("posChanged"),Position=pkg.Position=Class([function $clazz(){this.Metric=Interface();this.DOWN=1;this.UP=2;this.BEG=3;this.END=4},function $prototype(){this.setOffset=function(o){if(o<0){o=-1}else{var max=this.metrics.getMaxOffset();if(o>=max){o=max}}if(o!=this.offset){var prevOffset=this.offset,prevLine=this.currentLine,prevCol=this.currentCol,p=this.getPointByOffset(o);this.offset=o;if(p!=null){this.currentLine=p[0];this.currentCol=p[1]}this.isValid=true;this._.posChanged(this,prevOffset,prevLine,prevCol)}return o};this.seek=function(off){return this.setOffset(this.offset+off)};this.setRowCol=function(r,c){if(r!=this.currentLine||c!=this.currentCol){var prevOffset=this.offset,prevLine=this.currentLine,prevCol=this.currentCol;this.offset=this.getOffsetByPoint(r,c);this.currentLine=r;this.currentCol=c;this._.posChanged(this,prevOffset,prevLine,prevCol)}};this.inserted=function(off,size){if(this.offset>=0&&off<=this.offset){this.isValid=false;this.setOffset(this.offset+size)}};this.removed=function(off,size){if(this.offset>=0&&this.offset>=off){this.isValid=false;if(this.offset>=(off+size)){this.setOffset(this.offset-size)}else{this.setOffset(off)}}};this.getPointByOffset=function(off){if(off==-1){return[-1,-1]}var m=this.metrics,max=m.getMaxOffset();if(off>max){throw new Error("Out of bounds:"+off)}if(max===0){return[(m.getLines()>0?0:-1),0]}if(off===0){return[0,0]}var d=0,sl=0,so=0;if(this.isValid&&this.offset!=-1){sl=this.currentLine;so=this.offset-this.currentCol;if(off>this.offset){d=1}else{if(off<this.offset){d=-1}else{return[sl,this.currentCol]}}}else{d=(~~(max/off)===0)?-1:1;if(d<0){sl=m.getLines()-1;so=max-m.getLineSize(sl)}}for(;sl<m.getLines()&&sl>=0;sl+=d){var ls=m.getLineSize(sl);if(off>=so&&off<so+ls){return[sl,off-so]}so+=d>0?ls:-m.getLineSize(sl-1)}return[-1,-1]};this.getOffsetByPoint=function(row,col){var startOffset=0,startLine=0,m=this.metrics;if(row>=m.getLines()||col>=m.getLineSize(row)){throw new Error()}if(this.isValid&&this.offset!=-1){startOffset=this.offset-this.currentCol;startLine=this.currentLine}if(startLine<=row){for(var i=startLine;i<row;i++){startOffset+=m.getLineSize(i)}}else{for(var i=startLine-1;i>=row;i--){startOffset-=m.getLineSize(i)}}return startOffset+col};this.calcMaxOffset=function(){var max=0,m=this.metrics;for(var i=0;i<m.getLines();i++){max+=m.getLineSize(i)}return max-1};this.seekLineTo=function(t,num){if(this.offset<0){this.setOffset(0);return}if(arguments.length==1){num=1}var prevOffset=this.offset,prevLine=this.currentLine,prevCol=this.currentCol;switch(t){case Position.BEG:if(this.currentCol>0){this.offset-=this.currentCol;this.currentCol=0;this._.posChanged(this,prevOffset,prevLine,prevCol)}break;case Position.END:var maxCol=this.metrics.getLineSize(this.currentLine);if(this.currentCol<(maxCol-1)){this.offset+=(maxCol-this.currentCol-1);this.currentCol=maxCol-1;this._.posChanged(this,prevOffset,prevLine,prevCol)}break;case Position.UP:if(this.currentLine>0){this.offset-=(this.currentCol+1);this.currentLine--;for(var i=0;this.currentLine>0&&i<(num-1);i++,this.currentLine--){this.offset-=this.metrics.getLineSize(this.currentLine)}var maxCol=this.metrics.getLineSize(this.currentLine);if(this.currentCol<maxCol){this.offset-=(maxCol-this.currentCol-1)}else{this.currentCol=maxCol-1}this._.posChanged(this,prevOffset,prevLine,prevCol)}break;case Position.DOWN:if(this.currentLine<(this.metrics.getLines()-1)){this.offset+=(this.metrics.getLineSize(this.currentLine)-this.currentCol);this.currentLine++;var size=this.metrics.getLines()-1;for(var i=0;this.currentLine<size&&i<(num-1);i++,this.currentLine++){this.offset+=this.metrics.getLineSize(this.currentLine)}var maxCol=this.metrics.getLineSize(this.currentLine);if(this.currentCol<maxCol){this.offset+=this.currentCol}else{this.currentCol=maxCol-1;this.offset+=this.currentCol}this._.posChanged(this,prevOffset,prevLine,prevCol)}break;default:throw new Error()}};this[""]=function(pi){this._=new PosListeners();this.isValid=false;this.currentLine=this.currentCol=this.offset=0;this.setMetric(pi)};this.setMetric=function(p){if(p==null){throw new Error("Null metric")}if(p!=this.metrics){this.metrics=p;this.setOffset(-1)}}}]);(function(){var quantum=40,tasks=Array(5),count=0,pid=-1;function dispatcher(){var c=0;for(var i=0;i<tasks.length;i++){var t=tasks[i];if(t.isStarted===true){c++;if(t.si<=0){try{if(t.ctx==null){t.task(t)}else{t.task.call(t.ctx,t)}}catch(e){console.log(e.stack?e.stack:e)}t.si+=t.ri}else{t.si-=quantum}}}if(c===0&&pid>=0){window.clearInterval(pid);pid=-1}}function Task(){this.ctx=this.task=null;this.ri=this.si=0;this.isStarted=false}pkg.TaskCotext=Task;Task.prototype.shutdown=function(){if(this.task!=null){count--;this.ctx=this.task=null;this.isStarted=false;this.ri=this.si=0}if(count===0&&pid>=0){window.clearInterval(pid);pid=-1}};Task.prototype.run=function(startIn,repeatIn){if(this.task==null){throw new Error("Task body has not been defined")}if(arguments.length>0){this.si=startIn}if(arguments.length>1){this.ri=repeatIn}if(this.ri<=0){this.ri=150}this.isStarted=true;if(count>0&&pid<0){pid=window.setInterval(dispatcher,quantum)}return this};Task.prototype.pause=function(t){if(this.task==null){throw new Error()}if(arguments.length===0){this.isStarted=false}else{this.si=t}};for(var i=0;i<tasks.length;i++){tasks[i]=new Task()}pkg.task=function(f,ctx){if(typeof f!="function"){ctx=f;f=f.run}if(f==null){throw new Error()}for(var i=0;i<tasks.length;i++){var j=(i+count)%tasks.length,t=tasks[j];if(t.task==null){t.task=f;t.ctx=ctx;count++;return t}}throw new Error("Out of tasks limit")};pkg.shutdownAll=function(){for(var i=0;i<tasks.length;i++){tasks[i].shutdown()}}})();pkg.Bag=zebra.Class([function $prototype(){this.concatArrays=false;this.usePropertySetters=true;this.ignoreNonExistentKeys=false;this.get=function(key){if(key==null){throw new Error("Null key")}var n=key.split("."),v=this.objects;for(var i=0;i<n.length;i++){v=v[n[i]];if(typeof v==="undefined"){if(this.ignoreNonExistentKeys){return v}throw new Error("Property '"+key+"' not found")}}return v!=null&&v.$new?v.$new():v};this.mergeContent=function(o,v){if(v===null||zebra.isNumber(v)||zebra.isBoolean(v)||zebra.isString(v)){return v}if(Array.isArray(v)){if(this.concatArrays===false){return v}if(o&&Array.isArray(o)===false){throw new Error("Array merging type inconsistency: "+o)}return o?o.concat(v):v}for(var k in v){if(v.hasOwnProperty(k)){if(k[0]=="?"){eval("var x="+k.substring(1).trim());if(x){o=this.mergeContent(o,v[k])}continue}o[k]=o.hasOwnProperty(k)?this.mergeContent(o[k],v[k]):v[k]}}return o};this.mergeObjWithDesc=function(o,d){if(d===null||zebra.isNumber(d)||zebra.isBoolean(d)){return d}if(Array.isArray(d)){var v=[];for(var i=0;i<d.length;i++){v[i]=this.mergeObjWithDesc(null,d[i])}if(this.concatArrays===false){return v}if(o&&Array.isArray(o)===false){throw new Error("Destination has to be array: "+o)}return(o!=null)?o.concat(v):v}if(zebra.isString(d)){if(d[0]=="@"){if(d[1]=="("&&d[d.length-1]==")"){var $this=this,bag=new (this.$clazz)([function resolveVar(name){try{return this.$super(name)}catch(e){}return $this.resolveVar(name)},function resolveClass(className){var clazz=this.vars.hasOwnProperty(className)?this.$super(className):null;return(clazz!=null)?clazz:$this.resolveClass(className)}]);bag.loadByUrl(d.substring(2,d.length-1));return bag.objects}return this.resolveVar(d.substring(1).trim())}return this.decodeStringValue?this.decodeStringValue(d):d}var inh=null;if(d.hasOwnProperty("$inherit")){inh=d["$inherit"];delete d["$inherit"]}for(var k in d){if(k[0]=="$"&&d.hasOwnProperty(k)){var classname=k.substring(1).trim(),args=d[k];args=this.mergeObjWithDesc(null,Array.isArray(args)?args:[args]);delete d[k];if(classname[0]=="*"){return(function(clazz,args){return{$new:function(){return pkg.newInstance(clazz,args)}}})(this.resolveClass(classname.substring(1).trim()),args)}return this.mergeObjWithDesc(pkg.newInstance(this.resolveClass(classname),args),d)}break}var v=(o==null||zebra.isNumber(o)||zebra.isBoolean(o)||zebra.isString(o)||Array.isArray(o))?d:o;for(var k in d){if(d.hasOwnProperty(k)){if(k[0]=="."){var vv=d[k],mn=k.substring(1).trim(),m=this.objects[mn]!=null?this.objects[mn]:this[mn];if(m==null||typeof m!="function"){throw new Error("Method '"+mn+"' cannot be found")}if(Array.isArray(vv)===false){vv=[vv]}return m.apply(this.objects,this.mergeObjWithDesc(null,vv))}var po=o&&o.hasOwnProperty(k)?o[k]:null;var nv=this.mergeObjWithDesc(po,d[k]);if(this.usePropertySetters&&k[0]!="."){m=zebra.getPropertySetter(v,k);if(m!=null){if(Array.isArray(nv)){m.apply(v,nv)}else{m.call(v,nv)}continue}}v[k]=nv}}if(inh!==null){this.inherit(v,inh)}return v};this.resolveClass=function(className){return this.vars.hasOwnProperty(className)?this.vars[className]:zebra.Class.forName(className)};this.inherit=function(o,pp){for(var i=0;i<pp.length;i++){var op=this.objects,n=pp[i].trim(),nn=n.split("."),j=0;while(j<nn.length){op=op[nn[j++]];if(op==null){throw new Error("Wrong inherit path '"+n+"("+nn[j-1]+")'")}}for(var k in op){if(k[0]!="$"&&op.hasOwnProperty(k)&&o.hasOwnProperty(k)===false){o[k]=op[k]}}}};this.load=function(s,b){if(this.isloaded===true){throw new Error("Load is done")}if(b==null){b=true}var content=null;try{content=JSON.parse(s)}catch(e){throw new Error("JSON loading error: "+e)}this.content=this.mergeContent(this.content,content);if(this.contentLoaded){this.contentLoaded(this.content)}if(b===true){this.end()}return this};this.end=function(){if(typeof this.isloaded==="undefined"){this.isloaded=true;if(this.content.hasOwnProperty("variables")){var vars=this.content.variables;for(var k in vars){var v=vars[k].trim();this.vars[k.trim()]=(v[0]=="$"?Class.forName(v.substring(1).trim()):v)}delete this.content.variables}this.objects=this.mergeObjWithDesc(this.objects,this.content)}};this.resolveVar=function(name){if(this.vars.hasOwnProperty(name)){return this.vars[name]}return this.get(name)};this.expr=function(e){var s="var r="+e;eval(s);return r};this[""]=function(container){this.vars={};this.objects=container==null?{}:container;this.content={}}},function loadByUrl(url){this.loadByUrl(url,true)},function loadByUrl(url,b){var p=url.toString();p=p+(p.lastIndexOf("?")>0?"&":"?")+(new Date()).getTime().toString();return this.load(zebra.io.GET(p),b)}])})(zebra("util"),zebra.Class,zebra.Interface);(function(pkg,Class,Interface){pkg.descent=function descent(a,b){if(a==null){return 1}return(zebra.isString(a))?a.localeCompare(b):a-b};pkg.ascent=function ascent(a,b){if(b==null){return 1}return(zebra.isString(b))?b.localeCompare(a):b-a};pkg.TextModel=Interface();var MB=zebra.util,oobi="Index is out of bounds: ";function Line(s){this.s=s;this.l=0}Line.prototype.toString=function(){return this.s};pkg.TextModelListeners=MB.ListenersClass("textUpdated");pkg.Text=Class(pkg.TextModel,[function $prototype(){this.textLength=0;this.getLnInfo=function(lines,start,startOffset,o){for(;start<lines.length;start++){var line=lines[start].s;if(o>=startOffset&&o<=startOffset+line.length){return[start,startOffset]}startOffset+=(line.length+1)}return[]};this.setExtraChar=function(i,ch){this.lines[i].l=ch};this.getExtraChar=function(i){return this.lines[i].l};this.getLine=function(line){return this.lines[line].s};this.getValue=function(){return this.lines.join("\n")};this.getLines=function(){return this.lines.length};this.getTextLength=function(){return this.textLength};this.write=function(s,offset){var slen=s.length,info=this.getLnInfo(this.lines,0,0,offset),line=this.lines[info[0]].s,j=0,lineOff=offset-info[1],tmp=[line.substring(0,lineOff),s,line.substring(lineOff)].join("");for(;j<slen&&s[j]!="\n";j++){}if(j>=slen){this.lines[info[0]].s=tmp;j=1}else{this.lines.splice(info[0],1);j=this.parse(info[0],tmp,this.lines)}this.textLength+=slen;this._.textUpdated(this,true,offset,slen,info[0],j)};this.remove=function(offset,size){var i1=this.getLnInfo(this.lines,0,0,offset),i2=this.getLnInfo(this.lines,i1[0],i1[1],offset+size),l2=this.lines[i2[0]].s,l1=this.lines[i1[0]].s,off1=offset-i1[1],off2=offset+size-i2[1],buf=[l1.substring(0,off1),l2.substring(off2)].join("");if(i2[0]==i1[0]){this.lines.splice(i1[0],1,new Line(buf))}else{this.lines.splice(i1[0],i2[0]-i1[0]+1);this.lines.splice(i1[0],0,new Line(buf))}this.textLength-=size;this._.textUpdated(this,false,offset,size,i1[0],i2[0]-i1[0]+1)};this.parse=function(startLine,text,lines){var size=text.length,prevIndex=0,prevStartLine=startLine;for(var index=0;index<=size;prevIndex=index,startLine++){var fi=text.indexOf("\n",index);index=(fi<0?size:fi);this.lines.splice(startLine,0,new Line(text.substring(prevIndex,index)));index++}return startLine-prevStartLine};this.setValue=function(text){if(text==null){throw new Error("Invalid null string")}var old=this.getValue();if(old!==text){if(old.length>0){var numLines=this.getLines(),txtLen=this.getTextLength();this.lines.length=0;this.lines=[new Line("")];this._.textUpdated(this,false,0,txtLen,0,numLines)}this.lines=[];this.parse(0,text,this.lines);this.textLength=text.length;this._.textUpdated(this,true,0,this.textLength,0,this.getLines())}};this[""]=function(s){this.lines=[new Line("")];this._=new pkg.TextModelListeners();this.setValue(s==null?"":s)}}]);pkg.SingleLineTxt=Class(pkg.TextModel,[function $prototype(){this.setExtraChar=function(i,ch){this.extra=ch};this.getExtraChar=function(i){return this.extra};this.getValue=function(){return this.buf};this.getLines=function(){return 1};this.getTextLength=function(){return this.buf.length};this.getLine=function(line){if(line!=0){throw new Error(oobi+line)}return this.buf};this.write=function(s,offset){var buf=this.buf,j=s.indexOf("\n");if(j>=0){s=s.substring(0,j)}var l=(this.maxLen>0&&(buf.length+s.length)>=this.maxLen)?this.maxLen-buf.length:s.length;if(l!==0){this.buf=[buf.substring(0,offset),s.substring(0,l),buf.substring(offset)].join("");if(l>0){this._.textUpdated(this,true,offset,l,0,1)}}};this.remove=function(offset,size){this.buf=[this.buf.substring(0,offset),this.buf.substring(offset+size)].join("");this._.textUpdated(this,false,offset,size,0,1)};this.setValue=function(text){if(text==null){throw new Error("Invalid null string")}var i=text.indexOf("\n");if(i>=0){text=text.substring(0,i)}if(this.buf==null||this.buf!==text){if(this.buf!=null&&this.buf.length>0){this._.textUpdated(this,false,0,this.buf.length,0,1)}if(this.maxLen>0&&text.length>this.maxLen){text=text.substring(0,this.maxLen)}this.buf=text;this._.textUpdated(this,true,0,text.length,0,1)}};this.setMaxLength=function(max){if(max!=this.maxLen){this.maxLen=max;this.setValue("")}};this[""]=function(s,max){this.maxLen=max==null?-1:max;this.buf=null;this.extra=0;this._=new pkg.TextModelListeners();this.setValue(s==null?"":s)}}]);pkg.ListModelListeners=MB.ListenersClass("elementInserted","elementRemoved","elementSet");pkg.ListModel=Class([function $prototype(){this.get=function(i){if(i<0||i>=this.d.length){throw new Error(oobi+i)}return this.d[i]};this.add=function(o){this.d.push(o);this._.elementInserted(this,o,this.d.length-1)};this.removeAll=function(){var size=this.d.length;for(var i=size-1;i>=0;i--){this.removeAt(i)}};this.removeAt=function(i){var re=this.d[i];this.d.splice(i,1);this._.elementRemoved(this,re,i)};this.remove=function(o){for(var i=0;i<this.d.length;i++){if(this.d[i]===o){this.removeAt(i)}}};this.insert=function(o,i){if(i<0||i>=this.d.length){throw new Error(oobi+i)}this.d.splice(i,0,o);this._.elementInserted(this,o,i)};this.count=function(){return this.d.length};this.set=function(o,i){if(i<0||i>=this.d.length){throw new Error(oobi+i)}var pe=this.d[i];this.d[i]=o;this._.elementSet(this,o,pe,i);return pe};this.contains=function(o){return this.indexOf(o)>=0};this.indexOf=function(o){return this.d.indexOf(o)};this[""]=function(){this._=new pkg.ListModelListeners();this.d=(arguments.length===0)?[]:arguments[0]}}]);var Item=pkg.Item=Class([function $prototype(){this[""]=function(v){this.kids=[];this.value=v}}]);pkg.TreeModelListeners=MB.ListenersClass("itemModified","itemRemoved","itemInserted");pkg.TreeModel=Class([function $clazz(){this.create=function(r,p){var item=new Item(r.hasOwnProperty("value")?r.value:r);item.parent=p;if(r.hasOwnProperty("kids")){for(var i=0;i<r.kids.length;i++){item.kids[i]=pkg.TreeModel.create(r.kids[i],item)}}return item}},function $prototype(){this.setValue=function(item,v){item.value=v;this._.itemModified(this,item)};this.add=function(to,item){this.insert(to,item,to.kids.length)};this.insert=function(to,item,i){if(i<0||to.kids.length<i){throw new Error(oobi+i)}if(zebra.isString(item)){item=new Item(item)}to.kids.splice(i,0,item);item.parent=to;this._.itemInserted(this,item)};this.remove=function(item){if(item==this.root){this.root=null}else{for(var i=0;i<item.kids.length;i++){this.remove(item.kids[i])}item.parent.kids.splice(item.parent.kids.indexOf(item),1);item.parent=null}this._.itemRemoved(this,item)};this.removeKids=function(item){for(var i=0;i<items.kids.length;i++){this.remove(items[i])}};this[""]=function(r){if(arguments.length===0){r=new Item()}this.root=zebra.instanceOf(r,Item)?r:pkg.TreeModel.create(r);this._=new pkg.TreeModelListeners()}}]);pkg.MatrixListeners=MB.ListenersClass("matrixResized","cellModified","matrixSorted");pkg.Matrix=Class([function $prototype(){this.get=function(row,col){if(row<0||row>=this.rows||col<0||col>=this.cols){throw new Error("Row of col is out of bounds: "+row+","+col)}return this.objs[row][col]};this.put=function(row,col,obj){var nr=this.rows,nc=this.cols;if(row>=nr){nr+=(row-nr+1)}if(col>=nc){nc+=(col-nc+1)}this.setRowsCols(nr,nc);var old=this.objs[row]?this.objs[row][col]:undefined;if(obj!=old){this.objs[row][col]=obj;this._.cellModified(this,row,col,old)}};this.puti=function(i,obj){this.put(~~(i/this.cols),i%this.cols,obj)};this.setRowsCols=function(rows,cols){if(rows!=this.rows||cols!=this.cols){var pc=this.cols,pr=this.rows;this.rellocate(rows,cols);this.cols=cols;this.rows=rows;this._.matrixResized(this,pr,pc)}};this.rellocate=function(r,c){if(r>=this.rows){for(var i=this.rows;i<r;i++){this.objs[i]=[]}}};this.setRows=function(rows){this.setRowsCols(rows,this.cols)};this.setCols=function(cols){this.setRowsCols(this.rows,cols)};this.removeRows=function(begrow,count){if(begrow<0||begrow+count>this.rows){throw new Error()}for(var i=(begrow+count);i<this.rows;i++,begrow++){for(var j=0;j<this.cols;j++){this.objs[begrow][j]=this.objs[i][j];this.objs[i][j]=null}}this.rows-=count;this._.matrixResized(this,this.rows+count,this.cols)};this.removeCols=function(begcol,count){if(begcol<0||begcol+count>this.cols){throw new Error()}for(var i=(begcol+count);i<this.cols;i++,begcol++){for(var j=0;j<this.rows;j++){this.objs[j][begcol]=this.objs[j][i];this.objs[j][i]=null}}this.cols-=count;this._.matrixResized(this,this.rows,this.cols+count)};this.sortCol=function(col,f){if(f==null){f=pkg.descent}this.objs.sort(function(a,b){return f(a[col],b[col])});this._.matrixSorted(this,{col:col,func:f,name:zebra.$FN(f).toLowerCase()})};this[""]=function(){this._=new pkg.MatrixListeners();if(arguments.length==1){this.objs=arguments[0];this.cols=(this.objs.length>0)?this.objs[0].length:0;this.rows=this.objs.length}else{this.objs=[];this.rows=this.cols=0;if(arguments.length>1){this.setRowsCols(arguments[0],arguments[1])}}}}])})(zebra("data"),zebra.Class,zebra.Interface);(function(pkg,Class){var HEX="0123456789ABCDEF";pkg.ID=function UUID(size){if(typeof size==="undefined"){size=16}var id=[];for(var i=0;i<36;i++){id[i]=HEX[~~(Math.random()*16)]}return id.join("")};pkg.$sleep=function(){var r=new XMLHttpRequest(),t=(new Date()).getTime().toString(),i=window.location.toString().lastIndexOf("?");r.open("GET",window.location+(i>0?"&":"?")+t,false);r.send(null)};var b64str="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";pkg.b64encode=function(input){var out=[],i=0,len=input.length,c1,c2,c3;if(typeof ArrayBuffer!=="undefined"){if(input instanceof ArrayBuffer){input=new Uint8Array(input)}input.charCodeAt=function(i){return this[i]}}if(Array.isArray(input)){input.charCodeAt=function(i){return this[i]}}while(i<len){c1=input.charCodeAt(i++)&255;out.push(b64str.charAt(c1>>2));if(i==len){out.push(b64str.charAt((c1&3)<<4),"==");break}c2=input.charCodeAt(i++);out.push(b64str.charAt(((c1&3)<<4)|((c2&240)>>4)));if(i==len){out.push(b64str.charAt((c2&15)<<2),"=");break}c3=input.charCodeAt(i++);out.push(b64str.charAt(((c2&15)<<2)|((c3&192)>>6)),b64str.charAt(c3&63))}return out.join("")};pkg.b64decode=function(input){var output=[],chr1,chr2,chr3,enc1,enc2,enc3,enc4;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");while((input.length%4)!==0){input+="="}for(var i=0;i<input.length;){enc1=b64str.indexOf(input.charAt(i++));enc2=b64str.indexOf(input.charAt(i++));enc3=b64str.indexOf(input.charAt(i++));enc4=b64str.indexOf(input.charAt(i++));chr1=(enc1<<2)|(enc2>>4);chr2=((enc2&15)<<4)|(enc3>>2);chr3=((enc3&3)<<6)|enc4;output.push(String.fromCharCode(chr1));if(enc3!=64){output.push(String.fromCharCode(chr2))}if(enc4!=64){output.push(String.fromCharCode(chr3))}}return output.join("")};pkg.dateToISO8601=function(d){function pad(n){return n<10?"0"+n:n}return[d.getUTCFullYear(),"-",pad(d.getUTCMonth()+1),"-",pad(d.getUTCDate()),"T",pad(d.getUTCHours()),":",pad(d.getUTCMinutes()),":",pad(d.getUTCSeconds()),"Z"].join("")};pkg.ISO8601toDate=function(v){var regexp=["([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})))?)?)?)?"].join(""),d=v.match(new RegExp(regexp)),offset=0,date=new Date(d[1],0,1);if(d[3]){date.setMonth(d[3]-1)}if(d[5]){date.setDate(d[5])}if(d[7]){date.setHours(d[7])}if(d[8]){date.setMinutes(d[8])}if(d[10]){date.setSeconds(d[10])}if(d[12]){date.setMilliseconds(Number("0."+d[12])*1000)}if(d[14]){offset=(Number(d[16])*60)+Number(d[17]);offset*=((d[15]=="-")?1:-1)}offset-=date.getTimezoneOffset();date.setTime(Number(date)+(offset*60*1000));return date};pkg.parseXML=function(s){function rmws(node){if(node.childNodes!==null){for(var i=node.childNodes.length;i-->0;){var child=node.childNodes[i];if(child.nodeType===3&&child.data.match(/^\s*$/)){node.removeChild(child)}if(child.nodeType===1){rmws(child)}}}return node}if(typeof DOMParser!=="undefined"){return rmws((new DOMParser()).parseFromString(s,"text/xml"))}else{for(var n in {"Microsoft.XMLDOM":0,"MSXML2.DOMDocument":1,"MSXML.DOMDocument":2}){var p=null;try{p=new ActiveXObject(n);p.async=false}catch(e){continue}if(p===null){throw new Error("XML parser is not available")}p.loadXML(s);return p}}throw new Error("No XML parser is available")};pkg.QS=Class([function $clazz(){this.append=function(url,obj){return url+((obj===null)?"":((url.indexOf("?")>0)?"&":"?")+pkg.QS.toQS(obj,true))};this.parse=function(url){var m=window.location.search.match(/[?&][a-zA-Z0-9_.]+=[^?&=]+/g),r={};for(var i=0;m&&i<m.length;i++){var l=m[i].split("=");r[l[0].substring(1)]=decodeURIComponent(l[1])}return r};this.toQS=function(obj,encode){if(typeof encode==="undefined"){encode=true}if(zebra.isString(obj)||zebra.isBoolean(obj)||zebra.isNumber(obj)){return""+obj}var p=[];for(var k in obj){if(obj.hasOwnProperty(k)){p.push(k+"="+(encode?encodeURIComponent(obj[k].toString()):obj[k].toString()))}}return p.join("&")}}]);function $Request(){this.responseText=this.statusText="";this.onreadystatechange=this.responseXml=null;this.readyState=this.status=0}$Request.prototype.open=function(method,url,async,user,password){if(location.protocol.toLowerCase()=="file:"||(new zebra.URL(url)).host.toLowerCase()==location.host.toLowerCase()){this._request=new XMLHttpRequest();this._xdomain=false;var $this=this;this._request.onreadystatechange=function(){$this.readyState=$this._request.readyState;if($this._request.readyState==4){$this.responseText=$this._request.responseText;$this.responseXml=$this._request.responseXml;$this.status=$this._request.status;$this.statusText=$this._request.statusText}if($this.onreadystatechange){$this.onreadystatechange()}};return this._request.open(method,url,(async!==false),user,password)}else{this._xdomain=true;this._async=(async===true);this._request=new XDomainRequest();return this._request.open(method,url)}};$Request.prototype.send=function(data){if(this._xdomain){var originalReq=this._request,$this=this;originalReq.ontimeout=originalReq.onprogress=function(){};originalReq.onerror=function(){$this.readyState=4;$this.status=404;if($this._async&&$this.onreadystatechange){$this.onreadystatechange()}};originalReq.onload=function(){$this.readyState=4;$this.status=200;if($this._async&&$this.onreadystatechange){$this.onreadystatechange(originalReq.responseText,originalReq)}};originalReq.timeout=0;if(this._async===false){originalReq.send(data);while(this.status===0){pkg.$sleep()}this.readyState=4;this.responseText=originalReq.responseText;return}setTimeout(function(){originalReq.send(data)},10)}else{return this._request.send(data)}};$Request.prototype.abort=function(data){return this._request.abort()};$Request.prototype.setRequestHeader=function(name,value){if(this._xdomain){if(name=="Content-Type"){return}else{throw new Error("Method 'setRequestHeader' is not supported for "+name)}}else{this._request.setRequestHeader(name,value)}};$Request.prototype.getResponseHeader=function(name){if(this._xdomain){throw new Error("Method is not supported")}return this._request.getResponseHeader(name)};$Request.prototype.getAllResponseHeaders=function(){if(this._xdomain){throw new Error("Method is not supported")}return this._request.getAllResponseHeaders()};pkg.getRequest=function(){if(typeof XMLHttpRequest!=="undefined"){var r=new XMLHttpRequest();if(zebra.isFF){r.__send=r.send;r.send=function(data){try{return this.__send(data)}catch(e){if(!e.message||e.message.toUpperCase().indexOf("NS_ERROR_FAILURE")<0){var ee=new Error(e.toString());throw ee}}}}if("withCredentials" in r){return r}return new $Request()}throw new Error("Archaic browser detected")};pkg.HTTP=Class([function(url){this.url=url;this.header={}},function GET(q,f){if(typeof q=="function"){f=q;q=null}return this.SEND("GET",pkg.QS.append(this.url,q),null,f)},function POST(d,f){if(typeof d=="function"){f=d;d=null}if(d!=null&&zebra.isString(d)==false){d=pkg.QS.toQS(d,false)}return this.SEND("POST",this.url,d,f)},function SEND(method,url,data,callback){var r=pkg.getRequest(),$this=this;if(callback!=null){r.onreadystatechange=function(){if(r.readyState==4){callback.call($this,r)}}}r.open(method,url,callback!=null);for(var k in this.header){r.setRequestHeader(k,this.header[k])}try{r.send(data)}catch(e){if(callback==null){var ee=new Error(e.toString());ee.request=r;throw ee}else{r.status=500;r.statusText=e.toString();callback.call(this,r)}}if(callback==null){if(r.status!=200){if(r.status!==0||new zebra.URL(this.url).protocol!="file:"){var e=new Error("HTTP error "+r.status+" response = '"+r.statusText+"' url = "+url);e.request=r;throw e}}return r.responseText}}]);pkg.GET=function(url){if(zebra.isString(url)){var http=new pkg.HTTP(url);return http.GET.apply(http,Array.prototype.slice.call(arguments,1))}else{var http=new pkg.HTTP(url.url);if(url.header){http.header=url.header}var args=[];if(url.parameters){args.push(url.parameters)}if(url.calback){args.push(url.calback)}return http.GET.apply(http,args)}};pkg.POST=function(url){var http=new pkg.HTTP(url);return http.POST.apply(http,Array.prototype.slice.call(arguments,1))};var isBA=typeof(ArrayBuffer)!=="undefined";pkg.InputStream=Class([function(container){if(isBA&&container instanceof ArrayBuffer){this.data=new Uint8Array(container)}else{if(zebra.isString(container)){this.extend([function read(){return this.available()>0?this.data.charCodeAt(this.pos++)&255:-1}])}else{if(Array.isArray(container)===false){throw new Error("Wrong type: "+typeof(container))}}this.data=container}this.marked=-1;this.pos=0},function mark(){if(this.available()<=0){throw new Error()}this.marked=this.pos},function reset(){if(this.available()<=0||this.marked<0){throw new Error()}this.pos=this.marked;this.marked=-1},function close(){this.pos=this.data.length},function read(){return this.available()>0?this.data[this.pos++]:-1},function read(buf){return this.read(buf,0,buf.length)},function read(buf,off,len){for(var i=0;i<len;i++){var b=this.read();if(b<0){return i===0?-1:i}buf[off+i]=b}return len},function readChar(){var c=this.read();if(c<0){return -1}if(c<128){return String.fromCharCode(c)}var c2=this.read();if(c2<0){throw new Error()}if(c>191&&c<224){return String.fromCharCode(((c&31)<<6)|(c2&63))}else{var c3=this.read();if(c3<0){throw new Error()}return String.fromCharCode(((c&15)<<12)|((c2&63)<<6)|(c3&63))}},function readLine(){if(this.available()>0){var line=[],b;while((b=this.readChar())!=-1&&b!="\n"){line.push(b)}var r=line.join("");line.length=0;return r}return null},function available(){return this.data===null?-1:this.data.length-this.pos},function toBase64(){return pkg.b64encode(this.data)}]);pkg.URLInputStream=Class(pkg.InputStream,[function(url){this.$this(url,null)},function(url,f){var r=pkg.getRequest(),$this=this;r.open("GET",url,f!==null);if(f===null||isBA===false){if(!r.overrideMimeType){throw new Error("Binary mode is not supported")}r.overrideMimeType("text/plain; charset=x-user-defined")}if(f!==null){if(isBA){r.responseType="arraybuffer"}r.onreadystatechange=function(){if(r.readyState==4){if(r.status!=200){throw new Error(url)}$this.$clazz.$parent.getMethod("",1).call($this,isBA?r.response:r.responseText);f($this.data,r)}};r.send(null)}else{r.send(null);if(r.status!=200){throw new Error(url)}this.$super(r.responseText)}},function close(){this.$super();if(this.data){this.data.length=0;this.data=null}}]);pkg.Service=Class([function(url,methods){var $this=this;this.url=url;if(Array.isArray(methods)===false){methods=[methods]}for(var i=0;i<methods.length;i++){(function(){var name=methods[i];$this[name]=function(){var args=Array.prototype.slice.call(arguments);if(args.length>0&&typeof args[args.length-1]=="function"){var callback=args.pop();return this.send(url,this.encode(name,args),function(request){var r=null;try{if(request.status==200){r=$this.decode(request.responseText)}else{r=new Error("Status: "+request.status+", '"+request.statusText+"'")}}catch(e){r=e}callback(r)})}return this.decode(this.send(url,this.encode(name,args),null))}})()}},function send(url,data,callback){var http=new pkg.HTTP(url);if(this.contentType!=null){http.header["Content-Type"]=this.contentType}return http.POST(data,callback)}]);pkg.Service.invoke=function(clazz,url,method){var rpc=new clazz(url,method);return function(){return rpc[method].apply(rpc,arguments)}};pkg.JRPC=Class(pkg.Service,[function(url,methods){this.$super(url,methods);this.version="2.0";this.contentType="application/json"},function encode(name,args){return JSON.stringify({jsonrpc:this.version,method:name,params:args,id:pkg.ID()})},function decode(r){if(r===null||r.length===0){throw new Error("Empty JSON result string")}r=JSON.parse(r);if(typeof(r.error)!=="undefined"){throw new Error(r.error.message)}if(typeof r.result==="undefined"||typeof r.id==="undefined"){throw new Error("Wrong JSON response format")}return r.result}]);pkg.Base64=function(s){if(arguments.length>0){this.encoded=pkg.b64encode(s)}};pkg.Base64.prototype.toString=function(){return this.encoded};pkg.Base64.prototype.decode=function(){return pkg.b64decode(this.encoded)};pkg.XRPC=Class(pkg.Service,[function(url,methods){this.$super(url,methods);this.contentType="text/xml"},function encode(name,args){var p=['<?xml version="1.0"?>\n<methodCall><methodName>',name,"</methodName><params>"];for(var i=0;i<args.length;i++){p.push("<param>");this.encodeValue(args[i],p);p.push("</param>")}p.push("</params></methodCall>");return p.join("")},function encodeValue(v,p){if(v===null){throw new Error("Null is not allowed")}if(zebra.isString(v)){v=v.replace("<","<");v=v.replace("&","&");p.push("<string>",v,"</string>")}else{if(zebra.isNumber(v)){if(Math.round(v)==v){p.push("<i4>",v.toString(),"</i4>")}else{p.push("<double>",v.toString(),"</double>")}}else{if(zebra.isBoolean(v)){p.push("<boolean>",v?"1":"0","</boolean>")}else{if(v instanceof Date){p.push("<dateTime.iso8601>",pkg.dateToISO8601(v),"</dateTime.iso8601>")}else{if(Array.isArray(v)){p.push("<array><data>");for(var i=0;i<v.length;i++){p.push("<value>");this.encodeValue(v[i],p);p.push("</value>")}p.push("</data></array>")}else{if(v instanceof pkg.Base64){p.push("<base64>",v.toString(),"</base64>")}else{p.push("<struct>");for(var k in v){if(v.hasOwnProperty(k)){p.push("<member><name>",k,"</name><value>");this.encodeValue(v[k],p);p.push("</value></member>")}}p.push("</struct>")}}}}}}},function decodeValue(node){var tag=node.tagName.toLowerCase();if(tag=="struct"){var p={};for(var i=0;i<node.childNodes.length;i++){var member=node.childNodes[i],key=member.childNodes[0].childNodes[0].nodeValue.trim();p[key]=this.decodeValue(member.childNodes[1].childNodes[0])}return p}if(tag=="array"){var a=[];node=node.childNodes[0];for(var i=0;i<node.childNodes.length;i++){a[i]=this.decodeValue(node.childNodes[i].childNodes[0])}return a}var v=node.childNodes[0].nodeValue.trim();switch(tag){case"datetime.iso8601":return pkg.ISO8601toDate(v);case"boolean":return v=="1";case"int":case"i4":return parseInt(v,10);case"double":return Number(v);case"base64":var b64=new pkg.Base64();b64.encoded=v;return b64;case"string":return v}throw new Error("Unknown tag "+tag)},function decode(r){var p=pkg.parseXML(r),c=p.getElementsByTagName("fault");if(c.length>0){var err=this.decodeValue(c[0].getElementsByTagName("struct")[0]);throw new Error(err.faultString)}c=p.getElementsByTagName("methodResponse")[0];c=c.childNodes[0].childNodes[0];if(c.tagName.toLowerCase()==="param"){return this.decodeValue(c.childNodes[0].childNodes[0])}throw new Error("incorrect XML-RPC response")}]);pkg.XRPC.invoke=function(url,method){return pkg.Service.invoke(pkg.XRPC,url,method)};pkg.JRPC.invoke=function(url,method){return pkg.Service.invoke(pkg.JRPC,url,method)}})(zebra("io"),zebra.Class);(function(pkg,Class){pkg.NONE=0;pkg.LEFT=1;pkg.RIGHT=2;pkg.TOP=4;pkg.BOTTOM=8;pkg.CENTER=16;pkg.HORIZONTAL=32;pkg.VERTICAL=64;pkg.TEMPORARY=128;pkg.USE_PS_SIZE=512;pkg.STRETCH=256;pkg.TLEFT=pkg.LEFT|pkg.TOP;pkg.TRIGHT=pkg.RIGHT|pkg.TOP;pkg.BLEFT=pkg.LEFT|pkg.BOTTOM;pkg.BRIGHT=pkg.RIGHT|pkg.BOTTOM;var $ctrs={};for(var k in pkg){if(pkg.hasOwnProperty(k)&&/^\d+$/.test(pkg[k])){$ctrs[k.toUpperCase()]=pkg[k]}}pkg.$constraints=function(v){return zebra.isString(v)?$ctrs[v.toUpperCase()]:v};var L=pkg.Layout=new zebra.Interface();pkg.getDirectChild=function(parent,child){for(;child!=null&&child.parent!=parent;child=child.parent){}return child};pkg.getDirectAt=function(x,y,p){for(var i=0;i<p.kids.length;i++){var c=p.kids[i];if(c.isVisible===true&&c.x<=x&&c.y<=y&&c.x+c.width>x&&c.y+c.height>y){return i}}return -1};pkg.getTopParent=function(c){for(;c!=null&&c.parent!=null;c=c.parent){}return c};pkg.toParentOrigin=function(x,y,c,p){if(arguments.length==1){c=x;x=y=0;p=null}else{if(arguments.length<4){p=null}}while(c!=p){x+=c.x;y+=c.y;c=c.parent}return{x:x,y:y}};pkg.toChildOrigin=function(x,y,p,c){while(c!=p){x-=c.x;y-=c.y;c=c.parent}return{x:x,y:y}};pkg.xAlignment=function(aow,alignX,aw){if(alignX==pkg.RIGHT){return aw-aow}if(alignX==pkg.CENTER){return ~~((aw-aow)/2)}if(alignX==pkg.LEFT||alignX==pkg.NONE){return 0}throw new Error("Invalid alignment "+alignX)};pkg.yAlignment=function(aoh,alignY,ah){if(alignY==pkg.BOTTOM){return ah-aoh}if(alignY==pkg.CENTER){return ~~((ah-aoh)/2)}if(alignY==pkg.TOP||alignY==pkg.NONE){return 0}throw new Error("Invalid alignment "+alignY)};pkg.getMaxPreferredSize=function(target){var maxWidth=0,maxHeight=0;for(var i=0;i<target.kids.length;i++){var l=target.kids[i];if(l.isVisible===true){var ps=l.getPreferredSize();if(ps.width>maxWidth){maxWidth=ps.width}if(ps.height>maxHeight){maxHeight=ps.height}}}return{width:maxWidth,height:maxHeight}};pkg.isAncestorOf=function(p,c){for(;c!=null&&c!=p;c=c.parent){}return c!=null};pkg.Layoutable=Class(L,[function $prototype(){this.x=this.y=this.height=this.width=this.cachedHeight=0;this.psWidth=this.psHeight=this.cachedWidth=-1;this.isLayoutValid=this.isValid=false;this.constraints=this.parent=null;this.isVisible=true;function $normPath(p){p=p.trim();if(p[0]=="/"){return p}if(p[0]=="#"){return"//*[@id='"+p.substring(1).trim()+"']"}return"//"+(p[0]=="."?p.substring(1).trim():p)}this.find=function(path){var res=null;zebra.util.findInTree(this,$normPath(path),function(node,name){return node.$clazz!=null&&zebra.instanceOf(node,zebra.Class.forName(name))},function(kid){res=kid;return true});return res};this.findAll=function(path,callback){var res=[];if(callback==null){callback=function(kid){res.push(kid);return false}}zebra.util.findInTree(this,$normPath(path),function(node,name){return node.$clazz!=null&&zebra.instanceOf(node,zebra.Class.forName(name))},callback);return res};this.setId=function(id){this.id=id;return this};this.properties=function(path,props){if(arguments.length===1){return zebra.properties(this,path)}this.findAll(path,function(kid){zebra.properties(kid,props)});return this};this.validateMetric=function(){if(this.isValid===false){if(this.recalc!=null){this.recalc()}this.isValid=true}};this.invalidateLayout=function(){this.isLayoutValid=false;if(this.parent!=null){this.parent.invalidateLayout()}};this.invalidate=function(){this.isValid=this.isLayoutValid=false;this.cachedWidth=-1;if(this.parent!=null){this.parent.invalidate()}};this.validate=function(){this.validateMetric();if(this.width>0&&this.height>0&&this.isLayoutValid===false&&this.isVisible===true){this.layout.doLayout(this);for(var i=0;i<this.kids.length;i++){this.kids[i].validate()}this.isLayoutValid=true;if(this.laidout!=null){this.laidout()}}};this.getPreferredSize=function(){this.validateMetric();if(this.cachedWidth<0){var ps=(this.psWidth<0||this.psHeight<0)?this.layout.calcPreferredSize(this):{width:0,height:0};ps.width=this.psWidth>=0?this.psWidth:ps.width+this.getLeft()+this.getRight();ps.height=this.psHeight>=0?this.psHeight:ps.height+this.getTop()+this.getBottom();this.cachedWidth=ps.width;this.cachedHeight=ps.height;return ps}return{width:this.cachedWidth,height:this.cachedHeight}};this.getTop=function(){return 0};this.getLeft=function(){return 0};this.getBottom=function(){return 0};this.getRight=function(){return 0};this.setParent=function(o){if(o!=this.parent){this.parent=o;this.invalidate()}};this.setLayout=function(m){if(m==null){throw new Error("Null layout")}if(this.layout!=m){var pl=this.layout;this.layout=m;this.invalidate()}return this};this.calcPreferredSize=function(target){return{width:10,height:10}};this.doLayout=function(target){};this.indexOf=function(c){return this.kids.indexOf(c)};this.insert=function(i,constr,d){if(d.constraints!=null){constr=d.constraints}else{d.constraints=constr}if(i==this.kids.length){this.kids.push(d)}else{this.kids.splice(i,0,d)}d.setParent(this);if(this.kidAdded!=null){this.kidAdded(i,constr,d)}this.invalidate();return d};this.setLocation=function(xx,yy){if(xx!=this.x||this.y!=yy){var px=this.x,py=this.y;this.x=xx;this.y=yy;if(this.relocated!=null){this.relocated(px,py)}}};this.setBounds=function(x,y,w,h){this.setLocation(x,y);this.setSize(w,h);return this};this.setSize=function(w,h){if(w!=this.width||h!=this.height){var pw=this.width,ph=this.height;this.width=w;this.height=h;this.isLayoutValid=false;if(this.resized!=null){this.resized(pw,ph)}}return this};this.getByConstraints=function(c){if(this.kids.length>0){for(var i=0;i<this.kids.length;i++){var l=this.kids[i];if(c==l.constraints){return l}}}return null};this.remove=function(c){return this.removeAt(this.kids.indexOf(c))};this.removeAt=function(i){var obj=this.kids[i];obj.setParent(null);if(obj.constraints){obj.constraints=null}this.kids.splice(i,1);if(this.kidRemoved!=null){this.kidRemoved(i,obj)}this.invalidate();return obj};this.removeMe=function(){var i=-1;if(this.parent!=null&&(i=this.parent.indexOf(this))>=0){this.parent.removeAt(i)}};this.setPreferredSize=function(w,h){if(w!=this.psWidth||h!=this.psHeight){this.psWidth=w;this.psHeight=h;this.invalidate()}};this.setAt=function(i,d){var pd=this.removeAt(i);if(d!=null){this.insert(i,constr,d)}return pd};this.add=function(constr,d){return(arguments.length==1)?this.insert(this.kids.length,null,constr):this.insert(this.kids.length,constr,d)};this[""]=function(){this.kids=[];this.layout=this}}]);pkg.StackLayout=Class(L,[function $prototype(){this.calcPreferredSize=function(target){return pkg.getMaxPreferredSize(target)};this.doLayout=function(t){var top=t.getTop(),hh=t.height-t.getBottom()-top,left=t.getLeft(),ww=t.width-t.getRight()-left;for(var i=0;i<t.kids.length;i++){var l=t.kids[i];if(l.isVisible===true){if(l.constraints==pkg.USE_PS_SIZE){var ps=l.getPreferredSize();l.setSize(ps.width,ps.height);l.setLocation(left+(ww-ps.width)/2,top+(hh-ps.height)/2)}else{l.setSize(ww,hh);l.setLocation(left,top)}}}}}]);pkg.BorderLayout=Class(L,[function $prototype(){this.hgap=this.vgap=0;this[""]=function(hgap,vgap){if(arguments.length>0){if(arguments.length==1){this.hgap=this.vgap=hgap}else{this.hgap=hgap;this.vgap=vgap}}};this.calcPreferredSize=function(target){var center=null,west=null,east=null,north=null,south=null,d=null;for(var i=0;i<target.kids.length;i++){var l=target.kids[i];if(l.isVisible===true){switch(l.constraints){case pkg.CENTER:center=l;break;case pkg.TOP:north=l;break;case pkg.BOTTOM:south=l;break;case pkg.LEFT:west=l;break;case pkg.RIGHT:east=l;break;default:throw new Error("Invalid constraints: "+l.constraints)}}}var dim={width:0,height:0};if(east!=null){d=east.getPreferredSize();dim.width+=d.width+this.hgap;dim.height=(d.height>dim.height?d.height:dim.height)}if(west!=null){d=west.getPreferredSize();dim.width+=d.width+this.hgap;dim.height=d.height>dim.height?d.height:dim.height}if(center!=null){d=center.getPreferredSize();dim.width+=d.width;dim.height=d.height>dim.height?d.height:dim.height}if(north!=null){d=north.getPreferredSize();dim.width=d.width>dim.width?d.width:dim.width;dim.height+=d.height+this.vgap}if(south!=null){d=south.getPreferredSize();dim.width=d.width>dim.width?d.width:dim.width;dim.height+=d.height+this.vgap}return dim};this.doLayout=function(t){var top=t.getTop(),bottom=t.height-t.getBottom(),left=t.getLeft(),right=t.width-t.getRight(),center=null,west=null,east=null;for(var i=0;i<t.kids.length;i++){var l=t.kids[i];if(l.isVisible===true){switch(l.constraints){case pkg.CENTER:center=l;break;case pkg.TOP:var ps=l.getPreferredSize();l.setLocation(left,top);l.setSize(right-left,ps.height);top+=ps.height+this.vgap;break;case pkg.BOTTOM:var ps=l.getPreferredSize();l.setLocation(left,bottom-ps.height);l.setSize(right-left,ps.height);bottom-=ps.height+this.vgap;break;case pkg.LEFT:west=l;break;case pkg.RIGHT:east=l;break;default:throw new Error("Invalid constraints: "+l.constraints)}}}if(east!=null){var d=east.getPreferredSize();east.setLocation(right-d.width,top);east.setSize(d.width,bottom-top);right-=d.width+this.hgap}if(west!=null){var d=west.getPreferredSize();west.setLocation(left,top);west.setSize(d.width,bottom-top);left+=d.width+this.hgap}if(center!=null){center.setLocation(left,top);center.setSize(right-left,bottom-top)}}}]);pkg.RasterLayout=Class(L,[function $prototype(){this.calcPreferredSize=function(c){var m={width:0,height:0},b=(this.flag&pkg.USE_PS_SIZE)>0;for(var i=0;i<c.kids.length;i++){var el=c.kids[i];if(el.isVisible===true){var ps=b?el.getPreferredSize():{width:el.width,height:el.height},px=el.x+ps.width,py=el.y+ps.height;if(px>m.width){m.width=px}if(py>m.height){m.height=py}}}return m};this.doLayout=function(c){var r=c.width-c.getRight(),b=c.height-c.getBottom(),usePsSize=(this.flag&pkg.USE_PS_SIZE)>0;for(var i=0;i<c.kids.length;i++){var el=c.kids[i],ww=0,hh=0;if(el.isVisible===true){if(usePsSize){var ps=el.getPreferredSize();ww=ps.width;hh=ps.height}else{ww=el.width;hh=el.height}if((this.flag&pkg.HORIZONTAL)>0){ww=r-el.x}if((this.flag&pkg.VERTICAL)>0){hh=b-el.y}el.setSize(ww,hh);if(el.constraints){var x=el.x,y=el.y;if(el.constraints==pkg.CENTER){x=(c.width-ww)/2;y=(c.height-hh)/2}else{if((el.constraints&pkg.TOP)>0){y=0}else{if((el.constraints&pkg.BOTTOM)>0){y=c.height-hh}}if((el.constraints&pkg.LEFT)>0){x=0}else{if((el.constraints&pkg.RIGHT)>0){x=c.width-ww}}}el.setLocation(x,y)}}}};this[""]=function(f){this.flag=f?f:0}}]);pkg.FlowLayout=Class(L,[function $prototype(){this.gap=0;this.ax=pkg.LEFT;this.ay=pkg.TOP;this.direction=pkg.HORIZONTAL;this.stretchLast=false;this[""]=function(ax,ay,dir,g){if(arguments.length==1){this.gap=ax}else{if(arguments.length>=2){this.ax=pkg.$constraints(ax);this.ay=pkg.$constraints(ay)}if(arguments.length>2){dir=pkg.$constraints(dir);if(dir!=pkg.HORIZONTAL&&dir!=pkg.VERTICAL){throw new Error("Invalid direction "+dir)}this.direction=dir}if(arguments.length>3){this.gap=g}}};this.calcPreferredSize=function(c){var m={width:0,height:0},cc=0;for(var i=0;i<c.kids.length;i++){var a=c.kids[i];if(a.isVisible===true){var d=a.getPreferredSize();if(this.direction==pkg.HORIZONTAL){m.width+=d.width;m.height=d.height>m.height?d.height:m.height}else{m.width=d.width>m.width?d.width:m.width;m.height+=d.height}cc++}}var add=this.gap*(cc>0?cc-1:0);if(this.direction==pkg.HORIZONTAL){m.width+=add}else{m.height+=add}return m};this.doLayout=function(c){var psSize=this.calcPreferredSize(c),t=c.getTop(),l=c.getLeft(),lastOne=null,px=pkg.xAlignment(psSize.width,this.ax,c.width-l-c.getRight())+l,py=pkg.yAlignment(psSize.height,this.ay,c.height-t-c.getBottom())+t;for(var i=0;i<c.kids.length;i++){var a=c.kids[i];if(a.isVisible===true){var d=a.getPreferredSize();if(this.direction==pkg.HORIZONTAL){if(a.constraints===pkg.STRETCH){d.height=c.height-t-c.getBottom()}a.setLocation(px,~~((psSize.height-d.height)/2)+py);px+=(d.width+this.gap)}else{if(a.constraints===pkg.STRETCH){d.width=c.width-l-c.getRight()}a.setLocation(px+~~((psSize.width-d.width)/2),py);py+=d.height+this.gap}a.setSize(d.width,d.height);lastOne=a}}if(lastOne!==null&&this.stretchLast===true){if(this.direction==pkg.HORIZONTAL){lastOne.setSize(c.width-lastOne.x-c.getRight(),lastOne.height)}else{lastOne.setSize(lastOne.width,c.height-lastOne.y-c.getBottom())}}}}]);pkg.ListLayout=Class(L,[function $prototype(){this[""]=function(ax,gap){if(arguments.length==1){gap=ax}if(arguments.length<=1){ax=pkg.$constraints(pkg.STRETCH)}if(arguments.length===0){gap=0}if(ax!=pkg.STRETCH&&ax!=pkg.LEFT&&ax!=pkg.RIGHT&&ax!=pkg.CENTER){throw new Error("Invalid alignment")}this.ax=ax;this.gap=gap};this.calcPreferredSize=function(lw){var w=0,h=0,c=0;for(var i=0;i<lw.kids.length;i++){var kid=lw.kids[i];if(kid.isVisible===true){var d=kid.getPreferredSize();h+=(d.height+(c>0?this.gap:0));c++;if(w<d.width){w=d.width}}}return{width:w,height:h}};this.doLayout=function(lw){var x=lw.getLeft(),y=lw.getTop(),psw=lw.width-x-lw.getRight();for(var i=0;i<lw.kids.length;i++){var cc=lw.kids[i];if(cc.isVisible===true){var d=cc.getPreferredSize(),constr=cc.constraints;if(constr==null){constr=this.ax}cc.setSize((constr==pkg.STRETCH)?psw:d.width,d.height);cc.setLocation((constr==pkg.STRETCH)?x:x+pkg.xAlignment(cc.width,constr,psw),y);y+=(d.height+this.gap)}}}}]);pkg.PercentLayout=Class(L,[function $prototype(){this.direction=pkg.HORIZONTAL;this.gap=2;this.stretch=true;this[""]=function(dir,gap,stretch){if(arguments.length>0){this.direction=pkg.$constraints(dir);if(this.direction!=pkg.HORIZONTAL&&this.direction!=pkg.VERTICAL){throw new Error("Invalid direction : "+this.direction)}if(arguments.length>1){this.gap=gap}if(arguments.length>2){this.stretch=stretch}}};this.doLayout=function(target){var right=target.getRight(),top=target.getTop(),bottom=target.getBottom(),left=target.getLeft(),size=target.kids.length,rs=-this.gap*(size===0?0:size-1),loc=0,ns=0;if(this.direction==pkg.HORIZONTAL){rs+=target.width-left-right;loc=left}else{rs+=target.height-top-bottom;loc=top}for(var i=0;i<size;i++){var l=target.kids[i],c=l.constraints,useps=(c==pkg.USE_PS_SIZE);if(this.direction==pkg.HORIZONTAL){ns=((size-1)==i)?target.width-right-loc:(useps?l.getPreferredSize().width:~~((rs*c)/100));var yy=top,hh=target.height-top-bottom;if(this.stretch===false){var ph=hh;hh=l.getPreferredSize().height;yy=top+~~((ph-hh)/2)}l.setLocation(loc,yy);l.setSize(ns,hh)}else{ns=((size-1)==i)?target.height-bottom-loc:(useps?l.getPreferredSize().height:~~((rs*c)/100));var xx=left,ww=target.width-left-right;if(this.stretch===false){var pw=ww;ww=l.getPreferredSize().width;xx=left+~~((pw-ww)/2)}l.setLocation(xx,loc);l.setSize(ww,ns)}loc+=(ns+this.gap)}};this.calcPreferredSize=function(target){var max=0,size=target.kids.length,as=this.gap*(size===0?0:size-1);for(var i=0;i<size;i++){var d=target.kids[i].getPreferredSize();if(this.direction==pkg.HORIZONTAL){if(d.height>max){max=d.height}as+=d.width}else{if(d.width>max){max=d.width}as+=d.height}}return(this.direction==pkg.HORIZONTAL)?{width:as,height:max}:{width:max,height:as}}}]);pkg.Constraints=Class([function $prototype(){this.top=this.bottom=this.left=this.right=0;this.ay=this.ax=pkg.STRETCH;this.rowSpan=this.colSpan=1;this[""]=function(ax,ay,p){if(arguments.length>0){this.ax=ax;if(arguments.length>1){this.ay=ay}if(arguments.length>2){this.setPadding(p)}}};this.setPadding=function(t,l,b,r){if(arguments.length==1){this.bottom=this.left=this.right=t}else{this.top=t;this.bottom=b;this.left=l;this.right=r}}}]);pkg.GridLayout=Class(L,[function(r,c){this.$this(r,c,0)},function(r,c,m){this.rows=r;this.cols=c;this.mask=m;this.colSizes=Array(c+1);this.rowSizes=Array(r+1);this.constraints=new pkg.Constraints()},function $prototype(){this.calcCols=function(c){this.colSizes[this.cols]=0;for(var i=0;i<this.cols;i++){this.colSizes[i]=this.calcCol(i,c);this.colSizes[this.cols]+=this.colSizes[i]}return this.colSizes};this.calcRows=function(c){this.rowSizes[this.rows]=0;for(var i=0;i<this.rows;i++){this.rowSizes[i]=this.calcRow(i,c);this.rowSizes[this.rows]+=this.rowSizes[i]}return this.rowSizes};this.calcRow=function(row,c){var max=0,s=row*this.cols;for(var i=s;i<c.kids.length&&i<s+this.cols;i++){var a=c.kids[i];if(a.isVisible===true){var arg=a.constraints||this.constraints,d=a.getPreferredSize().height;d+=(arg.top+arg.bottom);if(d>max){max=d}}}return max};this.calcCol=function(col,c){var max=0;for(var r=0;r<this.rows;r++){var i=r*this.cols+col;if(i>=c.kids.length){break}var a=c.kids[i];if(a.isVisible===true){var arg=a.constraints||this.constraints,d=a.getPreferredSize().width+arg.left+arg.right;if(d>max){max=d}}}return max};this.calcPreferredSize=function(c){return{width:this.calcCols(c)[this.cols],height:this.calcRows(c)[this.rows]}};this.doLayout=function(c){var rows=this.rows,cols=this.cols,colSizes=this.calcCols(c),rowSizes=this.calcRows(c),top=c.getTop(),left=c.getLeft();if((this.mask&pkg.HORIZONTAL)>0){var dw=c.width-left-c.getRight()-colSizes[cols];for(var i=0;i<cols;i++){colSizes[i]=colSizes[i]+(colSizes[i]!==0?~~((dw*colSizes[i])/colSizes[cols]):0)}}if((this.mask&pkg.VERTICAL)>0){var dh=c.height-top-c.getBottom()-rowSizes[rows];for(var i=0;i<rows;i++){rowSizes[i]=rowSizes[i]+(rowSizes[i]!==0?~~((dh*rowSizes[i])/rowSizes[rows]):0)}}var cc=0;for(var i=0;i<rows&&cc<c.kids.length;i++){var xx=left;for(var j=0;j<cols&&cc<c.kids.length;j++,cc++){var l=c.kids[cc];if(l.isVisible===true){var arg=l.constraints||this.constraints,d=l.getPreferredSize(),cellW=colSizes[j],cellH=rowSizes[i];cellW-=(arg.left+arg.right);cellH-=(arg.top+arg.bottom);if(pkg.STRETCH==arg.ax){d.width=cellW}if(pkg.STRETCH==arg.ay){d.height=cellH}l.setSize(d.width,d.height);l.setLocation(xx+arg.left+(pkg.STRETCH==arg.ax?0:pkg.xAlignment(d.width,arg.ax,cellW)),top+arg.top+(pkg.STRETCH==arg.ay?0:pkg.yAlignment(d.height,arg.ay,cellH)));xx+=colSizes[j]}}top+=rowSizes[i]}}}])})(zebra("layout"),zebra.Class);(function(pkg){zebra.ready(function(){pkg.$deviceRatio=typeof window.devicePixelRatio!=="undefined"?window.devicePixelRatio:(typeof window.screen.deviceXDPI!=="undefined"?window.screen.deviceXDPI/window.screen.logicalXDPI:1);pkg.$applyRenderExploit=(parseInt(pkg.$deviceRatio)!==pkg.$deviceRatio||zebra.isIE);pkg.$elBoundsUpdated=function(){for(var i=pkg.$canvases.length-1;i>=0;i--){var c=pkg.$canvases[i];if(c.isFullScreen){var ws=pkg.$windowSize();c.setSize(ws.width+window.pageXOffset,ws.height+window.pageYOffset)}c.recalcOffset()}};window.requestAFrame=(function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(callback){window.setTimeout(callback,35)}})();pkg.$windowSize=function(){return{width:window.innerWidth-1,height:window.innerHeight}};pkg.$measure=function(e,cssprop){var value=window.getComputedStyle?window.getComputedStyle(e,null).getPropertyValue(cssprop):(e.style?e.style[cssprop]:e.currentStyle[cssprop]);return(value==null||value=="")?0:parseInt(/(^[0-9\.]+)([a-z]+)?/.exec(value)[1],10)};pkg.$canvas={size:function(c,w,h){c.style.width=""+w+"px";c.style.height=""+h+"px";var ctx=pkg.$canvas.context(c);if(ctx.$ratio!=pkg.$deviceRatio){var ratio=pkg.$deviceRatio/ctx.$ratio;c.width=~~(w*ratio);c.height=~~(h*ratio);ctx.$scale(ratio,ratio)}else{c.width=w;c.height=h}return ctx},context:function(c){var ctx=c.getContext("2d");if(typeof ctx.$ratio=="undefined"){var ratio=pkg.$canvas.ratio(ctx);ctx.$getImageData=ctx.getImageData;ctx.$scale=ctx.scale;ctx.$ratio=ratio;if(pkg.$deviceRatio!=ratio){var r=pkg.$deviceRatio/ratio;ctx.getImageData=function(x,y,w,h){return this.$getImageData(x*r,y*r,w,h)}}}return ctx},create:function(w,h){var e=document.createElement("canvas");if(arguments.length===0){w=typeof e.width!="undefined"?e.width:0;h=typeof e.height!="undefined"?e.height:0}pkg.$canvas.size(e,w,h);return e},ratio:function(ctx){return(ctx.webkitBackingStorePixelRatio||ctx.mozBackingStorePixelRatio||ctx.msBackingStorePixelRatio||ctx.backingStorePixelRatio||ctx.backingStorePixelRatio||1)}};var $wrt=null,winSizeUpdated=false,wpw=-1,wph=-1;window.addEventListener("resize",function(e){if(wpw==window.innerWidth&&wph==window.innerHeight){return}wpw=window.innerWidth;wph=window.innerHeight;if($wrt!=null){winSizeUpdated=true;return}$wrt=zebra.util.task(function(t){if(winSizeUpdated===false){pkg.$elBoundsUpdated();t.shutdown();$wrt=null}winSizeUpdated=false}).run(200,150)},false);window.onbeforeunload=function(e){var msgs=[];for(var i=pkg.$canvases.length-1;i>=0;i--){if(pkg.$canvases[i].saveBeforeLeave!=null){var m=pkg.$canvases[i].saveBeforeLeave();if(m!=null){msgs.push(m)}}}if(msgs.length>0){var message=msgs.join(" ");if(typeof e==="undefined"){e=window.event}if(e){e.returnValue=message}return message}};document.addEventListener("DOMNodeInserted",function(e){pkg.$elBoundsUpdated()},false);document.addEventListener("DOMNodeRemoved",function(e){pkg.$elBoundsUpdated();for(var i=pkg.$canvases.length-1;i>=0;i--){var canvas=pkg.$canvases[i];if(e.target==canvas.canvas){pkg.$canvases.splice(i,1);if(canvas.saveBeforeLeave!=null){canvas.saveBeforeLeave()}break}}},false)});var PI4=Math.PI/4,PI4_3=PI4*3,$abs=Math.abs,$atan2=Math.atan2,L=zebra.layout;pkg.MouseWheelSupport=zebra.Class([function $prototype(){this.naturalDirection=true;this.wheeled=function(e){var owner=pkg.$mouseMoveOwner;while(owner!=null&&zebra.instanceOf(owner,pkg.ScrollPan)===false){owner=owner.parent}if(owner!=null&&(owner.vBar!=null||owner.hBar!=null)){var dv=e[this.wheelInfo.dy]*this.wheelInfo.dir;if(dv!==0&&owner.vBar!=null){var bar=owner.vBar;if(Math.abs(dv)<1){dv*=bar.pageIncrement}dv=Math.floor(dv)%100;if(bar.isVisible===true){var v=bar.position.offset+dv;if(v>=0){bar.position.setOffset(v)}}}e.preventDefault()}}},function(canvas){if(canvas==null){throw new Error("Null canvas")}var WHEEL={wheel:{dy:"deltaY",dir:1,test:function(){return"onwheel" in document.createElement("div")}},mousewheel:{dy:"wheelDelta",dir:-1,test:function(){return document.onmousewheel!==undefined}},DOMMouseScroll:{dy:"detail",dir:1,test:function(){return true}}};for(var k in WHEEL){var w=WHEEL[k];if(w.test()){var $this=this;canvas.canvas.addEventListener(k,this.wheeled.bind==null?function(e){return $this.wheeled(e)}:this.wheeled.bind(this),false);this.wheelInfo=w;break}}}]);pkg.TouchHandler=zebra.Class([function $prototype(){this.touchCounter=0;function isIn(t,id){for(var i=0;i<t.length;i++){if(t[i].identifier==id){return true}}return false}this.$fixEnd=function(e){var t=e.touches,ct=e.changedTouches;for(var k in this.touches){if(isIn(ct,k)===true||isIn(t,k)===false){var tt=this.touches[k];this.touchCounter--;if(tt.group!=null){tt.group.active=false}this.ended(tt);delete this.touches[k]}}};this.start=function(e){this.$fixEnd(e);if(this.touchCounter>e.touches.length){return}var t=e.touches;for(var i=0;i<t.length;i++){var tt=t[i];if(this.touches.hasOwnProperty(tt.identifier)===false){this.touchCounter++;var nt={pageX:tt.pageX,pageY:tt.pageY,identifier:tt.identifier,target:tt.target,direction:L.NONE,dx:0,dy:0,dc:0,group:null};this.touches[tt.identifier]=nt;this.queue.push(nt)}}if(this.queue.length>0&&this.timer==null){var $this=this;this.timer=setTimeout(function(){$this.Q();$this.timer=null},25)}};this.end=function(e){if(this.timer!=null){clearTimeout(this.timer);this.timer=null}this.Q();var t=e.changedTouches;for(var i=0;i<t.length;i++){var tt=this.touches[t[i].identifier];if(tt!=null){this.touchCounter--;if(tt.group!=null){tt.group.active=false}this.ended(tt);delete this.touches[t[i].identifier]}}};this.Q=function(){if(this.queue.length>1){for(var i=0;i<this.queue.length;i++){var t=this.queue[i];t.group={size:this.queue.length,index:i,active:true}}}if(this.queue.length>0){for(var i=0;i<this.queue.length;i++){this.started(this.queue[i])}this.queue.length=0}};this[""]=function(element){this.touches={};this.queue=[];this.timer=null;var $this=this;element.addEventListener("touchstart",function(e){$this.start(e)},false);element.addEventListener("touchend",function(e){$this.end(e);e.preventDefault()},false);element.addEventListener("touchmove",function(e){var mt=e.changedTouches;for(var k in $this.touches){$this.touches[k].dx=$this.touches[k].dy=0}for(var i=0;i<mt.length;i++){var nmt=mt[i],t=$this.touches[nmt.identifier];if(t!=null){if(t.pageX!=nmt.pageX||t.pageY!=nmt.pageY){var dx=nmt.pageX-t.pageX,dy=nmt.pageY-t.pageY,d=t.direction,gamma=null,dxs=(dx<0&&t.dx<0)||(dx>0&&t.dx>0),dys=(dy<0&&t.dy<0)||(dy>0&&t.dy>0);t.pageX=nmt.pageX;t.pageY=nmt.pageY;if($abs(dx)>2||$abs(dy)>2){gamma=$atan2(dy,dx);if(gamma>-PI4){d=(gamma<PI4)?L.RIGHT:(gamma<PI4_3?L.BOTTOM:L.LEFT)}else{d=(gamma>-PI4_3)?L.TOP:L.LEFT}if(t.direction!=d){if(t.dc<3){t.direction=d}t.dc=0}else{t.dc++}t.gamma=gamma}if($this.timer==null){t.dx=dx;t.dy=dy;$this.moved(t)}else{$this.dc=0}}}}e.preventDefault()},false)}}])})(zebra("ui"));(function(pkg,Class,Interface){var instanceOf=zebra.instanceOf,L=zebra.layout,MB=zebra.util,$configurators=[],rgb=zebra.util.rgb,temporary={x:0,y:0,width:0,height:0},MS=Math.sin,MC=Math.cos,$fmCanvas=null,$fmText=null,$fmImage=null,$clipboard=null,$clipboardCanvas,$canvases=pkg.$canvases=[];pkg.clipboardTriggerKey=0;function $meX(e,d){return d.$context.tX(e.pageX-d.offx,e.pageY-d.offy)}function $meY(e,d){return d.$context.tY(e.pageX-d.offx,e.pageY-d.offy)}pkg.$view=function(v){if(v==null){return null}if(v.paint!=null){return v}if(zebra.isString(v)){return rgb.hasOwnProperty(v)?rgb[v]:(pkg.borders&&pkg.borders.hasOwnProperty(v)?pkg.borders[v]:new rgb(v))}if(Array.isArray(v)){return new pkg.CompositeView(v)}if(typeof v!=="function"){return new pkg.ViewSet(v)}v=new pkg.View();v.paint=f;return v};pkg.$detectZCanvas=function(canvas){if(zebra.isString(canvas)){canvas=document.getElementById(canvas)}for(var i=0;canvas!=null&&i<$canvases.length;i++){if($canvases[i].canvas==canvas){return $canvases[i]}}return null};pkg.View=Class([function $prototype(){this.gap=2;this.getRight=this.getLeft=this.getBottom=this.getTop=function(){return this.gap};this.getPreferredSize=function(){return{width:0,height:0}};this.paint=function(g,x,y,w,h,c){}}]);pkg.Render=Class(pkg.View,[function $prototype(){this.target=null;this[""]=function(target){this.setTarget(target)};this.setTarget=function(o){if(this.target!=o){var old=this.target;this.target=o;if(this.targetWasChanged!=null){this.targetWasChanged(old,o)}}}}]);pkg.Raised=Class(pkg.View,[function(){this.$this(pkg.lightBrColor,pkg.midBrColor)},function(brightest,middle){this.brightest=brightest==null?"white":brightest;this.middle=middle==null?"gray":middle},function $prototype(){this.paint=function(g,x1,y1,w,h,d){var x2=x1+w-1,y2=y1+h-1;g.setColor(this.brightest);g.drawLine(x1,y1,x2,y1);g.drawLine(x1,y1,x1,y2);g.setColor(this.middle);g.drawLine(x2,y1,x2,y2+1);g.drawLine(x1,y2,x2,y2)}}]);pkg.Sunken=Class(pkg.View,[function(){this.$this(pkg.lightBrColor,pkg.midBrColor,pkg.darkBrColor)},function(brightest,middle,darkest){this.brightest=brightest==null?"white":brightest;this.middle=middle==null?"gray":middle;this.darkest=darkest==null?"black":darkest},function $prototype(){this.paint=function(g,x1,y1,w,h,d){var x2=x1+w-1,y2=y1+h-1;g.setColor(this.middle);g.drawLine(x1,y1,x2-1,y1);g.drawLine(x1,y1,x1,y2-1);g.setColor(this.brightest);g.drawLine(x2,y1,x2,y2+1);g.drawLine(x1,y2,x2,y2);g.setColor(this.darkest);g.drawLine(x1+1,y1+1,x1+1,y2);g.drawLine(x1+1,y1+1,x2,y1+1)}}]);pkg.Etched=Class(pkg.View,[function(){this.$this(pkg.lightBrColor,pkg.midBrColor)},function(brightest,middle){this.brightest=brightest==null?"white":brightest;this.middle=middle==null?"gray":middle},function $prototype(){this.paint=function(g,x1,y1,w,h,d){var x2=x1+w-1,y2=y1+h-1;g.setColor(this.middle);g.drawLine(x1,y1,x1,y2-1);g.drawLine(x2-1,y1,x2-1,y2);g.drawLine(x1,y1,x2,y1);g.drawLine(x1,y2-1,x2-1,y2-1);g.setColor(this.brightest);g.drawLine(x2,y1,x2,y2);g.drawLine(x1+1,y1+1,x1+1,y2-1);g.drawLine(x1+1,y1+1,x2-1,y1+1);g.drawLine(x1,y2,x2+1,y2)}}]);pkg.Dotted=Class(pkg.View,[function $prototype(){this.paint=function(g,x,y,w,h,d){g.setColor(this.color);g.drawDottedRect(x,y,w,h)};this[""]=function(c){this.color=(c==null)?"black":c}}]);pkg.Border=Class(pkg.View,[function $prototype(){this.paint=function(g,x,y,w,h,d){if(this.color!=null){var ps=g.lineWidth;g.lineWidth=this.width;if(this.radius>0){this.outline(g,x,y,w,h,d)}else{var dt=this.width/2;g.beginPath();g.rect(x+dt,y+dt,w-this.width,h-this.width);g.closePath()}g.setColor(this.color);g.stroke();g.lineWidth=ps}};this.outline=function(g,x,y,w,h,d){if(this.radius<=0){return false}var r=this.radius,dt=this.width/2,xx=x+w-dt,yy=y+h-dt;x+=dt;y+=dt;g.beginPath();g.moveTo(x+r,y);g.lineTo(xx-r,y);g.quadraticCurveTo(xx,y,xx,y+r);g.lineTo(xx,yy-r);g.quadraticCurveTo(xx,yy,xx-r,yy);g.lineTo(x+r,yy);g.quadraticCurveTo(x,yy,x,yy-r);g.lineTo(x,y+r);g.quadraticCurveTo(x,y,x+r,y);g.closePath();return true};this[""]=function(c,w,r){this.color=(arguments.length===0)?"gray":c;this.width=(w==null)?1:w;this.radius=(r==null)?0:r;this.gap=this.width}}]);pkg.RoundBorder=Class(pkg.View,[function $prototype(){this.paint=function(g,x,y,w,h,d){if(this.color!=null&&this.width>0){this.outline(g,x,y,w,h,d);g.setColor(this.color);g.stroke()}};this.outline=function(g,x,y,w,h,d){g.beginPath();g.lineWidth=this.width;g.arc(~~(x+w/2),~~(y+h/2),~~(w/2-0.5),0,2*Math.PI,false);g.closePath();return true};this[""]=function(col,width){this.color=null;this.width=1;if(arguments.length>0){if(zebra.isNumber(col)){this.width=col}else{this.color=col;if(zebra.isNumber(width)){this.width=width}}}this.gap=this.width}}]);pkg.Gradient=Class(pkg.View,[function $prototype(){this[""]=function(){this.colors=Array.prototype.slice.call(arguments,0);if(arguments.length>2){this.orientation=L.$constraints(arguments[arguments.length-1]);this.colors.pop()}else{this.orientation=L.VERTICAL}};this.paint=function(g,x,y,w,h,dd){var d=(this.orientation==L.HORIZONTAL?[0,1]:[1,0]),x1=x*d[1],y1=y*d[0],x2=(x+w-1)*d[1],y2=(y+h-1)*d[0];if(this.gradient==null||this.gx1!=x1||this.gx2!=x2||this.gy1!=y1||this.gy2!=y2){this.gx1=x1;this.gx2=x2;this.gy1=y1;this.gy2=y2;this.gradient=g.createLinearGradient(x1,y1,x2,y2);for(var i=0;i<this.colors.length;i++){this.gradient.addColorStop(i,this.colors[i].toString())}}g.fillStyle=this.gradient;g.fillRect(x,y,w,h)}}]);pkg.Radial=Class(pkg.View,[function $prototype(){this[""]=function(){this.colors=Array.prototype.slice.call(arguments,0)};this.paint=function(g,x,y,w,h,d){var cx1=w/2,cy1=w/2;this.gradient=g.createRadialGradient(cx1,cy1,10,cx1,cy1,w<h?w:h);for(var i=0;i<this.colors.length;i++){this.gradient.addColorStop(i,this.colors[i].toString())}g.fillStyle=this.gradient;g.fillRect(x,y,w,h)}}]);pkg.Picture=Class(pkg.Render,[function $prototype(){this[""]=function(img,x,y,w,h){this.setTarget(img);if(arguments.length>4){this.x=x;this.y=y;this.width=w;this.height=h}else{this.x=this.y=this.width=this.height=0}};this.paint=function(g,x,y,w,h,d){if(this.target!=null&&w>0&&h>0){if(this.width>0){g.drawImage(this.target,this.x,this.y,this.width,this.height,x,y,w,h)}else{g.drawImage(this.target,x,y,w,h)}}};this.getPreferredSize=function(){var img=this.target;return img==null?{width:0,height:0}:(this.width>0)?{width:this.width,height:this.height}:{width:img.width,height:img.height}}}]);pkg.Pattern=Class(pkg.Render,[function $prototype(){this.pattern=null;this.paint=function(g,x,y,w,h,d){if(this.pattern==null){this.pattern=g.createPattern(this.target,"repeat")}g.beginPath();g.rect(x,y,w,h);g.closePath();g.fillStyle=this.pattern;g.fill()};targetWasChanged=function(o,n){this.pattern=null}}]);pkg.CompositeView=Class(pkg.View,[function $prototype(){this.left=this.right=this.bottom=this.top=this.height=this.width=0;this.getTop=function(){return this.top};this.getLeft=function(){return this.left};this.getBottom=function(){return this.bottom};this.getRight=function(){return this.right};this.getPreferredSize=function(){return{width:this.width,height:this.height}};this.$recalc=function(v){var b=0,ps=v.getPreferredSize();if(v.getLeft!=null){b=v.getLeft();if(b>this.left){this.left=b}}if(v.getRight!=null){b=v.getRight();if(b>this.right){this.right=b}}if(v.getTop!=null){b=v.getTop();if(b>this.top){this.top=b}}if(v.getBottom!=null){b=v.getBottom();if(b>this.bottom){this.bottom=b}}if(ps.width>this.width){this.width=ps.width}if(ps.height>this.height){this.height=ps.height}if(this.voutline==null&&v.outline){this.voutline=v}};this.iterate=function(f){for(var i=0;i<this.views.length;i++){f.call(this,i,this.views[i])}};this.recalc=function(){this.left=this.right=this.bottom=this.top=this.height=this.width=0;this.iterate(function(k,v){this.$recalc(v)})};this.ownerChanged=function(o){this.iterate(function(k,v){if(v!=null&&v.ownerChanged!=null){v.ownerChanged(o)}})};this.paint=function(g,x,y,w,h,d){for(var i=0;i<this.views.length;i++){var v=this.views[i];v.paint(g,x,y,w,h,d)}};this.outline=function(g,x,y,w,h,d){return this.voutline&&this.voutline.outline(g,x,y,w,h,d)};this[""]=function(){this.views=[];var args=arguments.length==1?arguments[0]:arguments;for(var i=0;i<args.length;i++){this.views[i]=pkg.$view(args[i]);this.$recalc(this.views[i])}}}]);pkg.ViewSet=Class(pkg.CompositeView,[function $prototype(){this.paint=function(g,x,y,w,h,d){if(this.activeView!=null){this.activeView.paint(g,x,y,w,h,d)}};this.activate=function(id){var old=this.activeView;if(this.views.hasOwnProperty(id)){return(this.activeView=this.views[id])!=old}if(id.length>1&&id[0]!="*"&&id[id.length-1]!="*"){var i=id.indexOf(".");if(i>0){var k=id.substring(0,i+1)+"*";if(this.views.hasOwnProperty(k)){return(this.activeView=this.views[k])!=old}k="*"+id.substring(i);if(this.views.hasOwnProperty(k)){return(this.activeView=this.views[k])!=old}}}return this.views.hasOwnProperty("*")?(this.activeView=this.views["*"])!=old:false};this.iterate=function(f){for(var k in this.views){f.call(this,k,this.views[k])}};this[""]=function(args){if(args==null){throw new Error("Null view set")}this.views={};this.activeView=null;for(var k in args){this.views[k]=pkg.$view(args[k]);if(this.views[k]){this.$recalc(this.views[k])}}this.activate("*")}}]);pkg.Bag=Class(zebra.util.Bag,[function $prototype(){this.usePropertySetters=true;this.contentLoaded=function(v){if(v==null||zebra.isNumber(v)||zebra.isBoolean(v)){return v}if(zebra.isString(v)){if(this.root!=null&&v[0]=="%"&&v[1]=="r"){var s="%root%/";if(v.indexOf(s)===0){return this.root.join(v.substring(s.length))}}return v}if(Array.isArray(v)){for(var i=0;i<v.length;i++){v[i]=this.contentLoaded(v[i])}return v}for(var k in v){if(v.hasOwnProperty(k)){v[k]=this.contentLoaded(v[k])}}return v}},function loadByUrl(url,b){this.root=null;if(zebra.URL.isAbsolute(url)){this.root=(new zebra.URL(url)).getParentURL()}this.$super(url,b)}]);rgb.prototype.paint=function(g,x,y,w,h,d){if(this.s!=g.fillStyle){g.fillStyle=this.s}if(g.stack!=null){var t=g.stack[g.counter],rx=x>t.x?x:t.x,rw=Math.min(x+w,t.x+t.width)-rx;if(rw<=0){return}var ry=y>t.y?y:t.y;rh=Math.min(y+h,t.y+t.height)-ry;if(rh<=0){return}g.fillRect(rx,ry,rw,rh)}else{g.fillRect(x,y,w,h)}};rgb.prototype.getPreferredSize=function(){return{width:0,height:0}};pkg.getPreferredSize=function(l){return l!=null&&l.isVisible===true?l.getPreferredSize():{width:0,height:0}};var $cvp=pkg.$cvp=function(c,r){if(c.width>0&&c.height>0&&c.isVisible===true){var p=c.parent,px=-c.x,py=-c.y;if(r==null){r={x:0,y:0,width:0,height:0}}else{r.x=r.y=0}r.width=c.width;r.height=c.height;while(p!=null&&r.width>0&&r.height>0){var xx=r.x>px?r.x:px,yy=r.y>py?r.y:py,w1=r.x+r.width,w2=px+p.width,h1=r.y+r.height,h2=py+p.height;r.width=(w1<w2?w1:w2)-xx,r.height=(h1<h2?h1:h2)-yy;r.x=xx;r.y=yy;px-=p.x;py-=p.y;p=p.parent}return r.width>0&&r.height>0?r:null}return null};pkg.configure=function(c){if(zebra.isString(c)){var path=c;c=function(conf){conf.loadByUrl(path,false)}}$configurators.push(c)};pkg.Font=function(name,style,size){if(arguments.length==1){name=name.replace(/[ ]+/," ");this.s=name.trim()}else{if(arguments.length==2){size=style;style=""}style=style.trim();this.s=[style,(style!==""?" ":""),size,"px ",name].join("")}$fmText.style.font=this.s;this.height=$fmText.offsetHeight;if(this.height===0){this.height=$fmText.offsetHeight}this.ascent=$fmImage.offsetTop-$fmText.offsetTop+1};pkg.Font.prototype.stringWidth=function(s){if(s.length===0){return 0}if($fmCanvas.font!=this.s){$fmCanvas.font=this.s}return($fmCanvas.measureText(s).width+0.5)|0};pkg.Font.prototype.charsWidth=function(s,off,len){if($fmCanvas.font!=this.s){$fmCanvas.font=this.s}return($fmCanvas.measureText(len==1?s[off]:s.substring(off,off+len)).width+0.5)|0};pkg.Font.prototype.toString=function(){return this.s};pkg.Cursor={DEFAULT:"default",MOVE:"move",WAIT:"wait",TEXT:"text",HAND:"pointer",NE_RESIZE:"ne-resize",SW_RESIZE:"sw-resize",SE_RESIZE:"se-resize",NW_RESIZE:"nw-resize",S_RESIZE:"s-resize",W_RESIZE:"w-resize",N_RESIZE:"n-resize",E_RESIZE:"e-resize",COL_RESIZE:"col-resize",HELP:"help"};var Composite=pkg.Composite=Interface(),CopyCutPaste=pkg.CopyCutPaste=Interface(),IE=pkg.InputEvent=Class([function $clazz(){this.MOUSE_UID=1;this.KEY_UID=2;this.FOCUS_UID=3;this.FOCUS_LOST=10;this.FOCUS_GAINED=11},function $prototype(){this[""]=function(target,id,uid){this.source=target;this.ID=id;this.UID=uid}}]),KE=pkg.KeyEvent=Class(IE,[function $clazz(){this.TYPED=15;this.RELEASED=16;this.PRESSED=17;this.M_CTRL=1;this.M_SHIFT=2;this.M_ALT=4;this.M_CMD=8},function $prototype(){this.reset=function(target,id,code,ch,mask){this.source=target;this.ID=id;this.code=code;this.mask=mask;this.ch=ch};this.isControlPressed=function(){return(this.mask&KE.M_CTRL)>0};this.isShiftPressed=function(){return(this.mask&KE.M_SHIFT)>0};this.isAltPressed=function(){return(this.mask&KE.M_ALT)>0};this.isCmdPressed=function(){return(this.mask&KE.M_CMD)>0}},function(target,id,code,ch,mask){this.$super(target,id,IE.KEY_UID);this.reset(target,id,code,ch,mask)}]),ME=pkg.MouseEvent=Class(IE,[function $clazz(){this.CLICKED=21;this.PRESSED=22;this.RELEASED=23;this.ENTERED=24;this.EXITED=25;this.DRAGGED=26;this.DRAGSTARTED=27;this.DRAGENDED=28;this.MOVED=29;this.LEFT_BUTTON=128;this.RIGHT_BUTTON=512},function $prototype(){this.touchCounter=1;this.reset=function(target,id,ax,ay,mask,clicks){this.ID=id;this.mask=mask;this.clicks=clicks;if(this.source==target&&this.source.parent==target.parent&&target.x==this.$px&&target.y==this.$py){this.x+=(ax-this.absX);this.y+=(ay-this.absY);this.absX=ax;this.absY=ay;this.source=target}else{this.source=target;this.absX=ax;this.absY=ay;while(target.parent!=null){ax-=target.x;ay-=target.y;target=target.parent}this.x=ax;this.y=ay}this.$px=target.x;this.$py=target.y};this.isActionMask=function(){return this.mask==ME.LEFT_BUTTON}},function(target,id,ax,ay,mask,clicks){this.$super(target,id,IE.MOUSE_UID);this.reset(target,id,ax,ay,mask,clicks)}]);var MDRAGGED=ME.DRAGGED,EM=null,MMOVED=ME.MOVED,MEXITED=ME.EXITED,KPRESSED=KE.PRESSED,MENTERED=ME.ENTERED,$temporaryWinListener=null,context=Object.getPrototypeOf(document.createElement("canvas").getContext("2d")),$mousePressedEvents={},$keyPressedCode=-1,$keyPressedOwner=null,$keyPressedModifiers=0,KE_STUB=new KE(null,KPRESSED,0,"x",0),ME_STUB=new ME("",ME.PRESSED,0,0,0,1);pkg.paintManager=pkg.events=pkg.$mouseMoveOwner=null;function $cleanDragFix(){if($temporaryWinListener!=null){window.removeEventListener("mousemove",$temporaryWinListener,true);$temporaryWinListener=null}}document.addEventListener("mouseup",function(e){$cleanDragFix();for(var k in $mousePressedEvents){var mp=$mousePressedEvents[k];if(mp.canvas!=null&&mp.canvas.canvas!=e.target){mp.pageX=e.pageX;mp.pageY=e.pageY;mp.canvas.$mouseReleased(k,mp)}}},false);var $alert=(function(){return this.alert}());window.alert=function(){if($keyPressedCode>0){KE_STUB.reset($keyPressedOwner,KE.RELEASED,$keyPressedCode,"",$keyPressedModifiers);EM.fireInputEvent(KE_STUB);$keyPressedCode=-1}$alert.apply(window,arguments);for(var k in $mousePressedEvents){var mp=$mousePressedEvents[k];if(mp.canvas!=null){mp.canvas.$mouseReleased(k,mp)}}};context.setFont=function(f){f=(f.s!=null?f.s:f.toString());if(f!=this.font){this.font=f}};context.setColor=function(c){if(c==null){throw new Error("Null color")}c=(c.s?c.s:c.toString());if(c!=this.fillStyle){this.fillStyle=c}if(c!=this.strokeStyle){this.strokeStyle=c}};context.drawLine=function(x1,y1,x2,y2,w){if(arguments.length<5){w=1}var pw=this.lineWidth;this.beginPath();this.lineWidth=w;if(x1==x2){x1+=w/2;x2=x1}else{if(y1==y2){y1+=w/2;y2=y1}}this.moveTo(x1,y1);this.lineTo(x2,y2);this.stroke();this.lineWidth=pw};context.ovalPath=function(x,y,w,h){this.beginPath();x+=this.lineWidth;y+=this.lineWidth;w-=2*this.lineWidth;h-=2*this.lineWidth;var kappa=0.5522848,ox=(w/2)*kappa,oy=(h/2)*kappa,xe=x+w,ye=y+h,xm=x+w/2,ym=y+h/2;this.moveTo(x,ym);this.bezierCurveTo(x,ym-oy,xm-ox,y,xm,y);this.bezierCurveTo(xm+ox,y,xe,ym-oy,xe,ym);this.bezierCurveTo(xe,ym+oy,xm+ox,ye,xm,ye);this.bezierCurveTo(xm-ox,ye,x,ym+oy,x,ym);this.closePath()};context.polylinePath=function(xPoints,yPoints,nPoints){this.beginPath();this.moveTo(xPoints[0],yPoints[0]);for(var i=1;i<nPoints;i++){this.lineTo(xPoints[i],yPoints[i])}};context.drawDottedRect=function(x,y,w,h){var ctx=this,m=["moveTo","lineTo","moveTo"];function dv(x,y,s){for(var i=0;i<s;i++){ctx[m[i%3]](x+0.5,y+i)}}function dh(x,y,s){for(var i=0;i<s;i++){ctx[m[i%3]](x+i,y+0.5)}}ctx.beginPath();dh(x,y,w);dh(x,y+h-1,w);ctx.stroke();ctx.beginPath();dv(x,y,h);dv(w+x-1,y,h);ctx.stroke()};context.drawDashLine=function(x,y,x2,y2){var pattern=[1,2],count=pattern.length,ctx=this,compute=null,dx=(x2-x),dy=(y2-y),b=(Math.abs(dx)>Math.abs(dy)),slope=b?dy/dx:dx/dy,sign=b?(dx<0?-1:1):(dy<0?-1:1);if(b){compute=function(step){x+=step;y+=slope*step}}else{compute=function(step){x+=slope*step;y+=step}}ctx.beginPath();ctx.moveTo(x,y);var dist=Math.sqrt(dx*dx+dy*dy),i=0;while(dist>=0.1){var idx=i%count;dl=dist<pattern[idx]?dist:pattern[idx],step=Math.sqrt(dl*dl/(1+slope*slope))*sign;compute(step);ctx[(i%2===0)?"lineTo":"moveTo"](x+0.5,y+0.5);dist-=dl;i++}ctx.stroke()};pkg.makeFullyVisible=function(d,c){var right=d.getRight(),top=d.getTop(),bottom=d.getBottom(),left=d.getLeft(),xx=c.x,yy=c.y,ww=c.width,hh=c.height;if(xx<left){xx=left}if(yy<top){yy=top}if(xx+ww>d.width-right){xx=d.width+right-ww}if(yy+hh>d.height-bottom){yy=d.height+bottom-hh}c.setLocation(xx,yy)};pkg.calcOrigin=function(x,y,w,h,px,py,t,tt,ll,bb,rr){if(arguments.length<8){tt=t.getTop();ll=t.getLeft();bb=t.getBottom();rr=t.getRight()}var dw=t.width,dh=t.height;if(dw>0&&dh>0){if(dw-ll-rr>w){var xx=x+px;if(xx<ll){px+=(ll-xx)}else{xx+=w;if(xx>dw-rr){px-=(xx-dw+rr)}}}if(dh-tt-bb>h){var yy=y+py;if(yy<tt){py+=(tt-yy)}else{yy+=h;if(yy>dh-bb){py-=(yy-dh+bb)}}}return[px,py]}return[0,0]};pkg.loadImage=function(img,ready){if(img instanceof Image&&img.complete&&img.naturalWidth!==0){if(arguments.length>1){ready(img.src,true,img)}return img}var i=new Image();i.crossOrigin="";i.crossOrigin="anonymous";zebra.busy();if(arguments.length>1){i.onerror=function(){zebra.ready();ready(img,false,i)};i.onload=function(){zebra.ready();ready(img,true,i)}}else{i.onload=i.onerror=function(){zebra.ready()}}i.src=(img instanceof Image)?img.src:img;return i};var CL=pkg.Panel=Class(L.Layoutable,[function $clazz(){this.ENABLED=1;this.SHOWN=2;this.MOVED=3;this.SIZED=4;this.ADDED=5;this.REMOVED=6},function $prototype(){this.top=this.left=this.right=this.bottom=0;this.isEnabled=true;this.getCanvas=function(){var c=this;for(;c!=null&&c.$isMasterCanvas!==true;c=c.parent){}return c};this.notifyRender=function(o,n){if(o!=null&&o.ownerChanged){o.ownerChanged(null)}if(n!=null&&n.ownerChanged){n.ownerChanged(this)}};this.load=function(jsonPath){new pkg.Bag(this).loadByUrl(jsonPath);return this};this.getComponentAt=function(x,y){var r=$cvp(this,temporary);if(r==null||(x<r.x||y<r.y||x>=r.x+r.width||y>=r.y+r.height)){return null}var k=this.kids;if(k.length>0){for(var i=k.length;--i>=0;){var d=k[i];d=d.getComponentAt(x-d.x,y-d.y);if(d!=null){return d}}}return this.contains==null||this.contains(x,y)?this:null};this.vrp=function(){this.invalidate();if(this.isVisible===true&&this.parent!=null){this.repaint()}};this.getTop=function(){return this.border!=null?this.top+this.border.getTop():this.top};this.getLeft=function(){return this.border!=null?this.left+this.border.getLeft():this.left};this.getBottom=function(){return this.border!=null?this.bottom+this.border.getBottom():this.bottom};this.getRight=function(){return this.border!=null?this.right+this.border.getRight():this.right};this.isInvalidatedByChild=function(c){return true};this.kidAdded=function(index,constr,l){pkg.events.fireCompEvent(CL.ADDED,this,constr,l);if(l.width>0&&l.height>0){l.repaint()}else{this.repaint(l.x,l.y,1,1)}};this.kidRemoved=function(i,l){pkg.events.fireCompEvent(CL.REMOVED,this,i,l);if(l.isVisible===true){if(l.width>0&&l.height>0){var dt=pkg.$applyRenderExploit===true?1:0;this.repaint(l.x-dt,l.y-dt,l.width+2*dt,l.height+2*dt)}}};this.relocated=function(px,py){pkg.events.fireCompEvent(CL.MOVED,this,px,py);var p=this.parent,w=this.width,h=this.height;if(p!=null&&w>0&&h>0){var x=this.x,y=this.y,nx=x<px?x:px,ny=y<py?y:py;nx--;ny--;if(nx<0){nx=0}if(ny<0){ny=0}var w1=p.width-nx,w2=w+(x>px?x-px:px-x),h1=p.height-ny,h2=h+(y>py?y-py:py-y);pkg.paintManager.repaint(p,nx,ny,(w1<w2?w1:w2)+2,(h1<h2?h1:h2)+2)}};this.resized=function(pw,ph){pkg.events.fireCompEvent(CL.SIZED,this,pw,ph);if(this.parent!=null){var dt=pkg.$applyRenderExploit===true?1:0;pkg.paintManager.repaint(this.parent,this.x-dt,this.y-dt,((this.width>pw)?this.width:pw)+2*dt,((this.height>ph)?this.height:ph)+2*dt)}};this.hasFocus=function(){return pkg.focusManager.hasFocus(this)};this.requestFocus=function(){pkg.focusManager.requestFocus(this)};this.requestFocusIn=function(timeout){if(arguments.length===0){timeout=50}var $this=this;setTimeout(function(){$this.requestFocus()},timeout)};this.setVisible=function(b){if(this.isVisible!=b){this.isVisible=b;this.invalidate();pkg.events.fireCompEvent(CL.SHOWN,this,-1,-1);if(this.parent!=null){if(b){this.repaint()}else{this.parent.repaint(this.x,this.y,this.width,this.height)}}}return this};this.setEnabled=function(b){if(this.isEnabled!=b){this.isEnabled=b;pkg.events.fireCompEvent(CL.ENABLED,this,-1,-1);if(this.kids.length>0){for(var i=0;i<this.kids.length;i++){this.kids[i].setEnabled(b)}}this.repaint()}return this};this.setPadding=function(top,left,bottom,right){if(arguments.length==1){left=bottom=right=top}if(this.top!=top||this.left!=left||this.bottom!=bottom||this.right!=right){this.top=top;this.left=left;this.bottom=bottom;this.right=right;this.vrp()}return this},this.setBorder=function(v){var old=this.border;v=pkg.$view(v);if(v!=old){this.border=v;this.notifyRender(old,v);if(old==null||v==null||old.getTop()!=v.getTop()||old.getLeft()!=v.getLeft()||old.getBottom()!=v.getBottom()||old.getRight()!=v.getRight()){this.invalidate()}if(v&&v.activate){v.activate(this.hasFocus()?"function":"focusoff")}this.repaint()}return this};this.setBackground=function(v){var old=this.bg;v=pkg.$view(v);if(v!=old){this.bg=v;this.notifyRender(old,v);this.repaint()}return this};this.setKids=function(a){if(arguments.length==1&&instanceOf(a,pkg.Panel)){this.add(a);return}if(arguments.length>1){for(var i=0;i<arguments.length;i++){var a=arguments[i];this.add(a.$new!=null?a.$new():a)}return}if(Array.isArray(a)){for(var i=0;i<a.length;i++){this.add(a[i])}}else{var kids=a;for(var k in kids){if(kids.hasOwnProperty(k)){var ctr=L.$constraints(k);if(ctr!=null){this.add(L[k],kids[k])}else{this.add(k,kids[k])}}}}};this.focused=function(){if(this.border&&this.border.activate){var id=this.hasFocus()?"focuson":"focusoff";if(this.border.views[id]){this.border.activate(id);this.repaint()}}};this.repaint=function(x,y,w,h){if(arguments.length===0){x=y=0;w=this.width;h=this.height}if(this.parent!=null&&this.width>0&&this.height>0&&pkg.paintManager!=null){pkg.paintManager.repaint(this,x,y,w,h)}};this.removeAll=function(){if(this.kids.length>0){var size=this.kids.length,mx1=Number.MAX_VALUE,my1=mx1,mx2=0,my2=0;for(;size>0;size--){var child=this.kids[size-1];if(child.isVisible===true){var xx=child.x,yy=child.y;mx1=mx1<xx?mx1:xx;my1=my1<yy?my1:yy;mx2=Math.max(mx2,xx+child.width);my2=Math.max(my2,yy+child.height)}this.removeAt(size-1)}this.repaint(mx1,my1,mx2-mx1,my2-my1)}};this.toFront=function(){if(this.parent!=null&&this.parent.kids[this.parent.kids.length-1]!=this){var p=this.parent;p.kids.splice(p.indexOf(this),1);p.kids[p.kids.length]=this;p.vrp()}};this.toBack=function(){if(this.parent!=null&&this.parent.kids[0]!=this){var p=this.parent;p.kids.splice(p.indexOf(this),1);p.kids.unshift(this);p.vrp()}};this.toPreferredSize=function(){var ps=this.getPreferredSize();this.setSize(ps.width,ps.height);return ps};this[""]=function(l){L.Layoutable.prototype[zebra.CNAME].call(this);this.properties(this.$clazz);if(arguments.length>0){if(instanceOf(l,L.Layout)){this.setLayout(l)}else{this.properties(l)}}}}]);pkg.BaseLayer=Class(pkg.Panel,[function $prototype(){this.getFocusRoot=function(){return this};this.activate=function(b){var fo=pkg.focusManager.focusOwner;if(L.isAncestorOf(this,fo)===false){fo=null}if(b){pkg.focusManager.requestFocus(fo!=null?fo:this.$pfo)}else{this.$pfo=fo;pkg.focusManager.requestFocus(null)}}},function(id){if(id==null){throw new Error("Invalid layer id: "+id)}this.$pfo=null;this.$super();this.id=id}]);pkg.RootLayer=Class(pkg.BaseLayer,[function $prototype(){this.layerMousePressed=function(x,y,m){return true};this.layerKeyPressed=function(code,m){return true}}]);pkg.ViewPan=Class(pkg.Panel,[function $prototype(){this.view=null;this.paint=function(g){if(this.view!=null){var l=this.getLeft(),t=this.getTop();this.view.paint(g,l,t,this.width-l-this.getRight(),this.height-t-this.getBottom(),this)}};this.setView=function(v){var old=this.view;v=pkg.$view(v);if(v!=old){this.view=v;this.notifyRender(old,v);this.vrp()}return this};this.calcPreferredSize=function(t){return this.view?this.view.getPreferredSize():{width:0,height:0}}}]);pkg.ImagePan=Class(pkg.ViewPan,[function(){this.$this(null)},function(img){this.setImage(img);this.$super()},function(img,w,h){this.setImage(img!=null?img:null);this.$super();this.setPreferredSize(w,h)},function setImage(img){if(img!=null){var $this=this,isPic=instanceOf(img,pkg.Picture),imgToLoad=isPic?img.target:img;pkg.loadImage(imgToLoad,function(p,b,i){if(b){$this.setView(isPic?img:new pkg.Picture(i));if($this.width===0||$this.height===0){$this.width=i.width;$this.height=i.height}$this.vrp()}if($this.imageLoaded!=null){$this.imageLoaded(p,b,i)}})}else{this.setView(null)}return this}]);pkg.Manager=Class([function(){if(pkg.events!=null&&pkg.events.addListener!=null){pkg.events.addListener(this)}}]);pkg.PaintManager=Class(pkg.Manager,[function $prototype(){var $timers={};this.repaint=function(c,x,y,w,h){if(arguments.length==1){x=y=0;w=c.width;h=c.height}if(w>0&&h>0&&c.isVisible===true){var r=$cvp(c,temporary);if(r==null){return}MB.intersection(r.x,r.y,r.width,r.height,x,y,w,h,r);if(r.width<=0||r.height<=0){return}x=r.x;y=r.y;w=r.width;h=r.height;var canvas=c;for(;canvas!=null&&canvas.$context==null;canvas=canvas.parent){}if(canvas!=null){var x2=canvas.width,y2=canvas.height;var cc=c;while(cc!=canvas){x+=cc.x;y+=cc.y;cc=cc.parent}if(x<0){w+=x;x=0}if(y<0){h+=y;y=0}if(w+x>x2){w=x2-x}if(h+y>y2){h=y2-y}if(w>0&&h>0){var da=canvas.$da;if(da.width>0){if(x>=da.x&&y>=da.y&&x+w<=da.x+da.width&&y+h<=da.y+da.height){return}MB.unite(da.x,da.y,da.width,da.height,x,y,w,h,da)}else{MB.intersection(0,0,canvas.width,canvas.height,x,y,w,h,da)}if(da.width>0&&$timers[canvas]==null){var $this=this;$timers[canvas]=window.requestAFrame(function(){$timers[canvas]=null;if(canvas.$da.width<=0){return}var context=canvas.$context;canvas.validate();context.save();try{context.translate(canvas.x,canvas.y);context.clipRect(canvas.$da.x,canvas.$da.y,canvas.$da.width,canvas.$da.height);if(canvas.bg==null){context.save();context.setTransform(2,0,0,2,0,0);context.clearRect(canvas.$da.x,canvas.$da.y,canvas.$da.width,canvas.$da.height);context.restore()}$this.paint(context,canvas);canvas.$da.width=-1}finally{context.restore()}})}}}}};this.paint=function(g,c){var dw=c.width,dh=c.height,ts=g.stack[g.counter];if(dw!==0&&dh!==0&&ts.width>0&&ts.height>0&&c.isVisible===true){if(c.isValid===false||c.isLayoutValid===false){c.validate()}g.save();g.translate(c.x,c.y);g.clipRect(0,0,dw,dh);ts=g.stack[g.counter];var c_w=ts.width,c_h=ts.height;if(c_w>0&&c_h>0){this.paintComponent(g,c);var count=c.kids.length,c_x=ts.x,c_y=ts.y;for(var i=0;i<count;i++){var kid=c.kids[i];if(kid.isVisible===true){var kidX=kid.x,kidY=kid.y,kidXW=kidX+kid.width,c_xw=c_x+c_w,kidYH=kidY+kid.height,c_yh=c_y+c_h,iw=(kidXW<c_xw?kidXW:c_xw)-(kidX>c_x?kidX:c_x),ih=(kidYH<c_yh?kidYH:c_yh)-(kidY>c_y?kidY:c_y);if(iw>0&&ih>0){this.paint(g,kid)}}}if(c.paintOnTop!=null){c.paintOnTop(g)}}g.restore()}}}]);pkg.PaintManImpl=Class(pkg.PaintManager,[function $prototype(){this.paintComponent=function(g,c){var b=c.bg!=null&&(c.parent==null||c.bg!=c.parent.bg);if((c.border!=null&&c.border.outline!=null)&&(b||c.update!=null)&&c.border.outline(g,0,0,c.width,c.height,c)){g.save();g.clip();if(b){c.bg.paint(g,0,0,c.width,c.height,c)}if(c.update!=null){c.update(g)}g.restore()}else{if(b){c.bg.paint(g,0,0,c.width,c.height,c)}if(c.update!=null){c.update(g)}}if(c.border!=null){c.border.paint(g,0,0,c.width,c.height,c)}if(c.paint!=null){var left=c.getLeft(),top=c.getTop(),bottom=c.getBottom(),right=c.getRight();if(left+right+top+bottom>0){var ts=g.stack[g.counter];if(ts.width>0&&ts.height>0){var cx=ts.x,cy=ts.y,x1=(cx>left?cx:left),y1=(cy>top?cy:top),cxcw=cx+ts.width,cych=cy+ts.height,cright=c.width-right,cbottom=c.height-bottom;g.save();g.clipRect(x1,y1,(cxcw<cright?cxcw:cright)-x1,(cych<cbottom?cych:cbottom)-y1);c.paint(g);g.restore()}}else{c.paint(g)}}}}]);pkg.FocusManager=Class(pkg.Manager,[function $prototype(){function freeFocus(ctx,t){if(t==ctx.focusOwner){ctx.requestFocus(null)}}this.focusOwner=null;this.compEnabled=function(c){if(c.isEnabled===false){freeFocus(this,c)}};this.compShown=function(c){if(c.isVisible===false){freeFocus(this,c)}};this.compRemoved=function(p,i,c){freeFocus(this,c)};this.canvasFocusLost=function(canvas){if(this.focusOwner!=null&&this.focusOwner.getCanvas()==canvas){this.requestFocus(null)}};this.canvasFocusGained=function(canvas){if(canvas.$prevFocusOwner!=null&&zebra.instanceOf(canvas.$prevFocusOwner,pkg.HtmlElement)===false){var d=canvas.$prevFocusOwner.getCanvas();if(d==canvas){this.requestFocus(canvas.$prevFocusOwner)}else{canvas.$prevFocusOwner=null}}};this.hasFocus=function(c){return this.focusOwner==c};this.keyPressed=function(e){if(KE.TAB==e.code){var cc=this.ff(e.source,e.isShiftPressed()?-1:1);if(cc!=null){this.requestFocus(cc)}}};this.findFocusable=function(c){return(this.isFocusable(c)?c:this.fd(c,0,1))};this.isFocusable=function(c){var d=c.getCanvas();return d&&c.isEnabled===true&&c.isVisible===true&&c.canHaveFocus===true||(typeof c.canHaveFocus=="function"&&c.canHaveFocus())};this.fd=function(t,index,d){if(t.kids.length>0){var isNComposite=(instanceOf(t,Composite)===false);for(var i=index;i>=0&&i<t.kids.length;i+=d){var cc=t.kids[i];if(cc.isEnabled===true&&cc.isVisible===true&&cc.width>0&&cc.height>0&&(isNComposite||(t.catchInput&&t.catchInput(cc)===false))&&((cc.canHaveFocus===true||(cc.canHaveFocus!=null&&cc.canHaveFocus!==false&&cc.canHaveFocus()))||(cc=this.fd(cc,d>0?0:cc.kids.length-1,d))!=null)){return cc}}}return null};this.ff=function(c,d){var top=c;while(top&&top.getFocusRoot==null){top=top.parent}top=top.getFocusRoot();for(var index=(d>0)?0:c.kids.length-1;c!=top.parent;){var cc=this.fd(c,index,d);if(cc!=null){return cc}cc=c;c=c.parent;if(c!=null){index=d+c.indexOf(cc)}}return this.fd(top,d>0?0:top.kids.length-1,d)};this.requestFocus=function(c){if(c!=this.focusOwner&&(c==null||this.isFocusable(c))){if(c!=null){var canvas=c.getCanvas();if(canvas.$focusGainedCounter===0){canvas.$prevFocusOwner=c;if(zebra.instanceOf(canvas.$prevFocusOwner,pkg.HtmlElement)==false){canvas.requestFocus();return}}}var oldFocusOwner=this.focusOwner;if(c!=null){var nf=EM.getEventDestination(c);if(nf==null||oldFocusOwner==nf){return}this.focusOwner=nf}else{this.focusOwner=c}if(oldFocusOwner!=null){var ofc=oldFocusOwner.getCanvas();if(ofc!=null){ofc.$prevFocusOwner=oldFocusOwner}}if(oldFocusOwner!=null){pkg.events.fireInputEvent(new IE(oldFocusOwner,IE.FOCUS_LOST,IE.FOCUS_UID))}if(this.focusOwner!=null){pkg.events.fireInputEvent(new IE(this.focusOwner,IE.FOCUS_GAINED,IE.FOCUS_UID))}return this.focusOwner}return null};this.mousePressed=function(e){if(e.isActionMask()){this.requestFocus(e.source)}}}]);pkg.CommandManager=Class(pkg.Manager,[function $prototype(){this.keyPressed=function(e){var fo=pkg.focusManager.focusOwner;if(fo!=null&&this.keyCommands[e.code]){var c=this.keyCommands[e.code];if(c&&c[e.mask]!=null){c=c[e.mask];this._.fired(c);if(fo[c.command]){if(c.args&&c.args.length>0){fo[c.command].apply(fo,c.args)}else{fo[c.command]()}}}}};this.parseKey=function(k){var m=0,c=0,r=k.split("+");for(var i=0;i<r.length;i++){var ch=r[i].trim().toUpperCase();if(KE.hasOwnProperty("M_"+ch)){m+=KE["M_"+ch];continue}if(KE.hasOwnProperty(ch)){c=KE[ch];continue}if(zebra.isNumber(ch)){c=ch}}return[m,c]};this.setCommands=function(commands){for(var i=0;i<commands.length;i++){var c=commands[i],p=this.parseKey(c.key),v=this.keyCommands[p[1]];if(v&&v[p[0]]){throw Error("Duplicated command: '"+c+"'")}if(v==null){v=[]}v[p[0]]=c;this.keyCommands[p[1]]=v}}},function(commands){this.$super();this.keyCommands={};this._=new zebra.util.Listeners("commandFired");this.setCommands(commands.common);if(zebra.isMacOS&&commands.osx!=null){this.setCommands(commands.osx)}}]);pkg.CursorManager=Class(pkg.Manager,[function $prototype(){this.mouseMoved=function(e){if(this.isFunc===true){this.cursorType=this.target.getCursorType(this.target,e.x,e.y);this.canvas.style.cursor=(this.cursorType==null)?"default":this.cursorType}};this.mouseEntered=function(e){if(e.source.cursorType!=null||e.source.getCursorType!=null){this.isFunc=(e.source.getCursorType!=null);this.target=e.source;this.canvas=this.target.getCanvas().canvas;this.cursorType=this.isFunc===true?this.target.getCursorType(this.target,e.x,e.y):this.target.cursorType;this.canvas.style.cursor=(this.cursorType==null)?"default":this.cursorType}};this.mouseExited=function(e){if(this.target!=null){this.cursorType="default";this.canvas.style.cursor=this.cursorType;this.canvas=this.target=null;this.isFunc=false}};this.mouseDragged=function(e){if(this.isFunc===true){this.cursorType=this.target.getCursorType(this.target,e.x,e.y);this.canvas.style.cursor=(this.cursorType==null)?"default":this.cursorType}}},function(){this.$super();this.cursorType="default";this.canvas=this.target=null;this.isFunc=false}]);pkg.EventManager=Class(pkg.Manager,[function $prototype(){var IEHM=[],MUID=IE.MOUSE_UID,KUID=IE.KEY_UID;IEHM[KE.TYPED]="keyTyped";IEHM[KE.RELEASED]="keyReleased";IEHM[KE.PRESSED]="keyPressed";IEHM[ME.DRAGGED]="mouseDragged";IEHM[ME.DRAGSTARTED]="mouseDragStarted";IEHM[ME.DRAGENDED]="mouseDragEnded";IEHM[ME.MOVED]="mouseMoved";IEHM[ME.CLICKED]="mouseClicked";IEHM[ME.PRESSED]="mousePressed";IEHM[ME.RELEASED]="mouseReleased";IEHM[ME.ENTERED]="mouseEntered";IEHM[ME.EXITED]="mouseExited";IEHM[IE.FOCUS_LOST]="focusLost";IEHM[IE.FOCUS_GAINED]="focusGained";IEHM[CL.SIZED]="compSized";IEHM[CL.MOVED]="compMoved";IEHM[CL.ENABLED]="compEnabled";IEHM[CL.SHOWN]="compShown";IEHM[CL.ADDED]="compAdded";IEHM[CL.REMOVED]="compRemoved";this.$hasMethod=function(l,s,e){for(var i=0;i<=e;i++){var k=IEHM[i];if(typeof l[k]=="function"){return true}}return false};this.fireCompEvent=function(id,src,p1,p2){var n=IEHM[id];if(src[n]!=null){src[n].call(src,src,p1,p2)}for(var i=0;i<this.c_l.length;i++){var t=this.c_l[i];if(t[n]!=null){t[n].call(t,src,p1,p2)}}for(var t=src.parent;t!=null;t=t.parent){if(t.childCompEvent!=null){t.childCompEvent(id,src,p1,p2)}}};this.getEventDestination=function(c){if(c==null){return null}var cp=c,p=c;while((p=p.parent)!=null){if(p.$clazz!=null&&p.$clazz.$parents!=null&&p.$clazz.$parents[Composite]==true&&(p.catchInput==null||p.catchInput(cp))){cp=p}}return cp};this.fireInputEvent=function(e){var t=e.source,id=e.ID,it=null,k=IEHM[id],b=false;switch(e.UID){case MUID:if(t[k]!=null){t[k].call(t,e)}if(id>25){for(var i=0;i<this.m_l.length;i++){var tt=this.m_l[i];if(tt[k]!=null){tt[k].call(tt,e)}}return b}it=this.m_l;break;case KUID:if(t[k]!=null){b=t[k].call(t,e)}it=this.k_l;break;case IE.FOCUS_UID:if(t[k]!=null){t[k].call(t,e)}t.focused();it=this.f_l;break;default:throw new Error("Invalid input event UID: "+e.UID)}for(var i=0;i<it.length;i++){var tt=it[i],m=tt[k];if(m!=null){b=m.call(tt,e)||b}}for(t=t.parent;t!=null;t=t.parent){if(t.childInputEvent!=null){t.childInputEvent(e)}}return b};this.addListener=function(l){if(this.$hasMethod(l,CL.ENABLED,CL.REMOVED)){this.addComponentListener(l)}if(this.$hasMethod(l,ME.CLICKED,ME.MOVED)){this.addMouseListener(l)}if(this.$hasMethod(l,KE.TYPED,KE.PRESSED)){this.addKeyListener(l)}if(this.$hasMethod(l,IE.FOCUS_LOST,IE.FOCUS_GAINED)){this.addFocusListener(l)}};this.removeListener=function(l){this.removeComponentListener(l);this.removeMouseListener(l);this.removeKeyListener(l);this.removeFocusListener(l)};this.addComponentListener=function(l){return this.a_(this.c_l,l)};this.removeComponentListener=function(l){return this.r_(this.c_l,l)};this.addMouseListener=function(l){return this.a_(this.m_l,l)};this.removeMouseListener=function(l){return this.r_(this.m_l,l)};this.addFocusListener=function(l){return this.a_(this.f_l,l)};this.removeFocusListener=function(l){return this.r_(this.f_l,l)};this.addKeyListener=function(l){return this.a_(this.k_l,l)};this.removeKeyListener=function(l){return this.r_(this.k_l,l)};this.a_=function(c,l){if(c.indexOf(l)>=0){return false}c.push(l);return true};this.r_=function(c,l){var i=c.indexOf(l);if(i<0){return false}c.splice(i,1);return true}},function(){this.m_l=[];this.k_l=[];this.f_l=[];this.c_l=[];this.$super()}]);pkg.zCanvas=Class(pkg.Panel,[function $prototype(){this.$isMasterCanvas=true;this.$prevFocusOwner=null;this.$focusGainedCounter=0;function km(e){var c=0;if(e.altKey){c+=KE.M_ALT}if(e.shiftKey){c+=KE.M_SHIFT}if(e.ctrlKey){c+=KE.M_CTRL}if(e.metaKey){c+=KE.M_CMD}return c}this.load=function(jsonPath){return this.root.load(jsonPath)};this.$keyTyped=function(e){if(e.charCode==0){if($keyPressedCode!=e.keyCode){this.$keyPressed(e)}$keyPressedCode=-1;return}if(e.charCode>0){var fo=pkg.focusManager.focusOwner;if(fo!=null){KE_STUB.reset(fo,KE.TYPED,e.keyCode,String.fromCharCode(e.charCode),km(e));if(EM.fireInputEvent(KE_STUB)){e.preventDefault()}}}if(e.keyCode<47){e.preventDefault()}};this.$keyPressed=function(e){$keyPressedCode=e.keyCode;var code=e.keyCode,m=km(e),b=false;for(var i=this.kids.length-1;i>=0;i--){var l=this.kids[i];if(l.layerKeyPressed&&l.layerKeyPressed(code,m)){break}}var focusOwner=pkg.focusManager.focusOwner;if(pkg.clipboardTriggerKey>0&&e.keyCode==pkg.clipboardTriggerKey&&focusOwner!=null&&instanceOf(focusOwner,CopyCutPaste)){$clipboardCanvas=this;$clipboard.style.display="block";this.canvas.onfocus=this.canvas.onblur=null;$clipboard.value="1";$clipboard.select();$clipboard.focus();return}$keyPressedOwner=focusOwner;$keyPressedModifiers=m;if(focusOwner!=null){KE_STUB.reset(focusOwner,KPRESSED,code,code<47?KE.CHAR_UNDEFINED:"?",m);b=EM.fireInputEvent(KE_STUB);if(code==KE.ENTER){KE_STUB.reset(focusOwner,KE.TYPED,code,"\n",m);b=EM.fireInputEvent(KE_STUB)||b}}if((code<47&&code!=32)||b){e.preventDefault()}};this.$keyReleased=function(e){$keyPressedCode=-1;var fo=pkg.focusManager.focusOwner;if(fo!=null){KE_STUB.reset(fo,KE.RELEASED,e.keyCode,KE.CHAR_UNDEFINED,km(e));if(EM.fireInputEvent(KE_STUB)){e.preventDefault()}}};this.$mouseEntered=function(id,e){var mp=$mousePressedEvents[id];if(mp!=null&&mp.canvas!=null&&mp.canvas.canvas==e.target){$cleanDragFix()}this.recalcOffset();if(mp==null||mp.canvas==null){var x=$meX(e,this),y=$meY(e,this),d=this.getComponentAt(x,y);if(d!=pkg.$mouseMoveOwner){if(pkg.$mouseMoveOwner!=null){var prev=pkg.$mouseMoveOwner;pkg.$mouseMoveOwner=null;ME_STUB.reset(prev,MEXITED,x,y,-1,0);EM.fireInputEvent(ME_STUB)}if(d!=null&&d.isEnabled===true){pkg.$mouseMoveOwner=d;ME_STUB.reset(d,MENTERED,x,y,-1,0);EM.fireInputEvent(ME_STUB)}}}};this.$mouseExited=function(id,e){var mp=$mousePressedEvents[id];if(mp==null||mp.canvas==null){if(pkg.$mouseMoveOwner!=null){var p=pkg.$mouseMoveOwner;pkg.$mouseMoveOwner=null;ME_STUB.reset(p,MEXITED,$meX(e,this),$meY(e,this),-1,0);EM.fireInputEvent(ME_STUB)}}else{if($temporaryWinListener==null&&ME_STUB.touch==null){var $this=this;$temporaryWinListener=function(ee){ee.stopPropagation();$this.$mouseMoved(id,{pageX:ee.pageX,pageY:ee.pageY,target:e.target});ee.preventDefault()};window.addEventListener("mousemove",$temporaryWinListener,true)}}};this.$mouseMoved=function(id,e){var mp=$mousePressedEvents[id];if(mp!=null&&mp.canvas!=null){if(mp.component!=null&&mp.canvas.canvas==e.target){var x=this.$context.tX(e.pageX-this.offx,e.pageY-this.offy),y=this.$context.tY(e.pageX-this.offx,e.pageY-this.offy),m=mp.button;if(mp.draggedComponent==null){var xx=this.$context.tX(mp.pageX-this.offx,mp.pageY-this.offy),yy=this.$context.tY(mp.pageX-this.offx,mp.pageY-this.offy),d=(pkg.$mouseMoveOwner==null)?this.getComponentAt(xx,yy):pkg.$mouseMoveOwner;if(d!=null&&d.isEnabled===true){mp.draggedComponent=d;ME_STUB.reset(d,ME.DRAGSTARTED,xx,yy,m,0);EM.fireInputEvent(ME_STUB);if(xx!=x||yy!=y){ME_STUB.reset(d,MDRAGGED,x,y,m,0);EM.fireInputEvent(ME_STUB)}}}else{ME_STUB.reset(mp.draggedComponent,MDRAGGED,x,y,m,0);EM.fireInputEvent(ME_STUB)}}}else{var x=this.$context.tX(e.pageX-this.offx,e.pageY-this.offy),y=this.$context.tY(e.pageX-this.offx,e.pageY-this.offy),d=this.getComponentAt(x,y);if(pkg.$mouseMoveOwner!=null){if(d!=pkg.$mouseMoveOwner){var old=pkg.$mouseMoveOwner;pkg.$mouseMoveOwner=null;ME_STUB.reset(old,MEXITED,x,y,-1,0);EM.fireInputEvent(ME_STUB);if(d!=null&&d.isEnabled===true){pkg.$mouseMoveOwner=d;ME_STUB.reset(pkg.$mouseMoveOwner,MENTERED,x,y,-1,0);EM.fireInputEvent(ME_STUB)}}else{if(d!=null&&d.isEnabled===true){ME_STUB.reset(d,MMOVED,x,y,-1,0);EM.fireInputEvent(ME_STUB)}}}else{if(d!=null&&d.isEnabled===true){pkg.$mouseMoveOwner=d;ME_STUB.reset(d,MENTERED,x,y,-1,0);EM.fireInputEvent(ME_STUB)}}}};this.$mouseReleased=function(id,e){var mp=$mousePressedEvents[id];if(mp!=null&&mp.canvas!=null){var x=$meX(e,this),y=$meY(e,this),po=mp.component;if(mp.draggedComponent!=null){ME_STUB.reset(mp.draggedComponent,ME.DRAGENDED,x,y,mp.button,0);EM.fireInputEvent(ME_STUB)}if(po!=null){if(mp.draggedComponent==null&&(e.touch==null||e.touch.group==null)){ME_STUB.reset(po,ME.CLICKED,x,y,mp.button,mp.clicks);EM.fireInputEvent(ME_STUB)}ME_STUB.reset(po,ME.RELEASED,x,y,mp.button,mp.clicks);EM.fireInputEvent(ME_STUB);if(ME_STUB.touch!=null){ME_STUB.reset(po,ME.EXITED,x,y,mp.button,mp.clicks);EM.fireInputEvent(ME_STUB)}}if(ME_STUB.touch==null){var mo=pkg.$mouseMoveOwner;if(mp.draggedComponent!=null||(po!=null&&po!=mo)){var nd=this.getComponentAt(x,y);if(nd!=mo){if(mo!=null){pkg.$mouseMoveOwner=null;ME_STUB.reset(mo,MEXITED,x,y,-1,0);EM.fireInputEvent(ME_STUB)}if(nd!=null&&nd.isEnabled===true){pkg.$mouseMoveOwner=nd;ME_STUB.reset(nd,MENTERED,x,y,-1,0);EM.fireInputEvent(ME_STUB)}}}}mp.canvas=null}};this.$mousePressed=function(id,e,button){var mp=$mousePressedEvents[id];if(mp!=null&&mp.canvas!=null){this.$mouseReleased(id,mp)}var clicks=mp!=null&&(new Date().getTime()-mp.time)<=pkg.doubleClickDelta?2:1;mp=$mousePressedEvents[id]={pageX:e.pageX,pageY:e.pageY,identifier:id,target:e.target,canvas:this,button:button,component:null,mouseDragged:null,time:(new Date()).getTime(),clicks:clicks};var x=$meX(e,this),y=$meY(e,this),tl=null;mp.x=x;mp.y=y;for(var i=this.kids.length-1;i>=0;i--){tl=this.kids[i];if(tl.layerMousePressed!=null&&tl.layerMousePressed(x,y,button)){break}}var d=this.getComponentAt(x,y);if(d!=null&&d.isEnabled===true){mp.component=d;if(ME_STUB.touch!=null){ME_STUB.reset(d,ME.ENTERED,x,y,button,clicks);EM.fireInputEvent(ME_STUB)}ME_STUB.reset(d,ME.PRESSED,x,y,button,clicks);EM.fireInputEvent(ME_STUB)}if(document.activeElement!=this.canvas){this.canvas.focus()}};this.getComponentAt=function(x,y){for(var i=this.kids.length;--i>=0;){var tl=this.kids[i];if(tl.isLayerActiveAt==null||tl.isLayerActiveAt(x,y)){return EM.getEventDestination(tl.getComponentAt(x,y))}}return null};this.recalcOffset=function(){var poffx=this.offx,poffy=this.offy,ba=this.canvas.getBoundingClientRect();this.offx=((ba.left+0.5)|0)+pkg.$measure(this.canvas,"padding-left")+window.pageXOffset;this.offy=((ba.top+0.5)|0)+pkg.$measure(this.canvas,"padding-top")+window.pageYOffset;if(this.offx!=poffx||this.offy!=poffy){this.relocated(this,poffx,poffy)}};this.getLayer=function(id){return this[id]};this.setStyles=function(styles){for(var k in styles){this.canvas.style[k]=styles[k]}};this.setAttribute=function(name,value){this.canvas.setAttribute(name,value)};this.relocated=function(px,py){pkg.events.fireCompEvent(CL.MOVED,this,px,py)};this.resized=function(pw,ph){pkg.events.fireCompEvent(CL.SIZED,this,pw,ph)};this.repaint=function(x,y,w,h){if((document.contains!=null&&document.contains(this.canvas)===false)||this.canvas.style.visibility=="hidden"){return}if(arguments.length===0){x=y=0;w=this.width;h=this.height}if(w>0&&h>0&&pkg.paintManager!=null){pkg.paintManager.repaint(this,x,y,w,h)}};this.setFeatures=function(){for(var i=0;i<arguments.length;i++){new (Class.forName(arguments[i]))(this)}}},function(){this.$this(400,400)},function(w,h){var e=document.createElement("canvas");e.setAttribute("class","zebcanvas");e.setAttribute("id",this.toString());e.onselectstart=function(){return false};this.$this(e,w,h)},function(element){this.$this(element,-1,-1)},function(element,w,h){var $this=this;this.$nativeListeners={onmousemove:null,onmousedown:null,onmouseup:null,onmouseover:null,onmouseout:null,onkeydown:null,onkeyup:null,onkeypress:null};if(zebra.isString(element)){this.canvas=document.getElementById(element);if(this.canvas==null){throw new Error("Canvas element cannot be found")}if(pkg.$detectZCanvas(this.canvas)!=null){throw new Error("Canvas id = '"+element+"'' is already in use")}}else{this.canvas=element;document.body.appendChild(this.canvas)}if(w<0){w=this.canvas.offsetWidth}if(h<0){h=this.canvas.offsetHeight}if(this.canvas.getAttribute("tabindex")===null){this.canvas.setAttribute("tabindex","1")}this.$da={x:0,y:0,width:-1,height:0};if(zebra.isTouchable){new pkg.TouchHandler(this.canvas,[function $prototype(){this.started=function(e){ME_STUB.touch=e;ME_STUB.touches=this.touches;ME_STUB.touchCounter=this.touchCounter;$this.$mousePressed(e.identifier,e,this.touchCounter==1?ME.LEFT_BUTTON:(e.group!=null&&e.group.size==2&&e.group.index==1?ME.RIGHT_BUTTON:0))};this.ended=function(e){ME_STUB.touch=e;ME_STUB.touches=this.touches;ME_STUB.touchCounter=this.touchCounter;$this.$mouseReleased(e.identifier,e)};this.moved=function(e){ME_STUB.touch=e;ME_STUB.touches=this.touches;ME_STUB.touchCounter=this.touchCounter;$this.$mouseMoved(e.identifier,e)}}])}else{var oldPX=-1,oldPY=-1;this.canvas.onmousemove=function(e){if(oldPY!=e.pageY||oldPX!=e.pageX){oldPX=e.pageX;oldPY=e.pageY;$this.$mouseMoved(1,e)}e.stopPropagation()};this.canvas.onmousedown=function(e){$this.$mousePressed(1,e,e.button===0?ME.LEFT_BUTTON:(e.button==2?ME.RIGHT_BUTTON:0));e.stopPropagation()};this.canvas.onmouseup=function(e){$cleanDragFix();$this.$mouseReleased(1,e);e.stopPropagation()};this.canvas.onmouseover=function(e){$this.$mouseEntered(1,e);e.stopPropagation()};this.canvas.onmouseout=function(e){$this.$mouseExited(1,e);oldPX=oldPY=-1;e.stopPropagation()};this.canvas.oncontextmenu=function(e){e.preventDefault()};this.canvas.onkeydown=function(e){$this.$keyPressed(e);e.stopPropagation()};this.canvas.onkeyup=function(e){$this.$keyReleased(e);e.stopPropagation()};this.canvas.onkeypress=function(e){$this.$keyTyped(e);e.stopPropagation()}}this.canvas.onfocus=function(e){if($this.$focusGainedCounter++>0){e.preventDefault();return}if(pkg.focusManager.canvasFocusGained){pkg.focusManager.canvasFocusGained($this)}};this.canvas.onblur=function(e){if(document.activeElement==$this.canvas){e.preventDefault();return}if($this.$focusGainedCounter!==0){$this.$focusGainedCounter=0;if(pkg.focusManager.canvasFocusLost!=null){pkg.focusManager.canvasFocusLost($this)}}};this.$super();$canvases.push(this);this.setSize(w,h);var cvis=(this.canvas.style.visibility=="hidden"?false:true);if(this.isVisible!=cvis){this.setVisible(cvis)}if(this.canvasInitialized!=null){this.canvasInitialized()}},function setLocation(x,y){this.canvas.style.top=y+"px";this.canvas.style.left=x+"px";this.canvas.style.position="absolute";this.recalcOffset();return this},function setSize(w,h){if(this.width!=w||h!=this.height){var pw=this.width,ph=this.height,ctx=pkg.$canvas.size(this.canvas,w,h);this.$context=ctx;if(this.$context.textBaseline!="top"){this.$context.textBaseline="top"}if(typeof ctx.tX!=="undefined"){ctx.reset(w,h)}else{var $scale=ctx.scale,$translate=ctx.translate,$rotate=ctx.rotate,$save=ctx.save,$restore=ctx.restore;ctx.reset=function(w,h){this.counter=0;var s=this.stack[0];s.srot=s.rotateVal=s.x=s.y=s.width=s.height=s.dx=s.dy=0;s.crot=s.sx=s.sy=1;s.width=w;s.height=h;this.setFont(pkg.font);this.setColor("white")};ctx.stack=Array(50);for(var i=0;i<ctx.stack.length;i++){var s={};s.srot=s.rotateVal=s.x=s.y=s.width=s.height=s.dx=s.dy=0;s.crot=s.sx=s.sy=1;ctx.stack[i]=s}ctx.reset(w,h);ctx.getTopStack=function(){return this.stack[this.counter]};ctx.tX=function(x,y){var c=this.stack[this.counter],b=(c.sx!=1||c.sy!=1||c.rotateVal!==0);return(b?(((c.crot*x+y*c.srot)/c.sx+0.5)|0):x)-c.dx};ctx.tY=function(x,y){var c=this.stack[this.counter],b=(c.sx!=1||c.sy!=1||c.rotateVal!==0);return(b?(((y*c.crot-c.srot*x)/c.sy+0.5)|0):y)-c.dy};ctx.translate=function(dx,dy){if(dx!==0||dy!==0){var c=this.stack[this.counter];c.x-=dx;c.y-=dy;c.dx+=dx;c.dy+=dy;$translate.call(this,dx,dy)}};ctx.rotate=function(v){var c=this.stack[this.counter];c.rotateVal+=v;c.srot=MS(c.rotateVal);c.crot=MC(c.rotateVal);$rotate.call(this,v)};ctx.scale=function(sx,sy){var c=this.stack[this.counter];c.sx=c.sx*sx;c.sy=c.sy*sy;$scale.call(this,sx,sy)};ctx.save=function(){this.counter++;var c=this.stack[this.counter],cc=this.stack[this.counter-1];c.x=cc.x;c.y=cc.y;c.width=cc.width;c.height=cc.height;c.dx=cc.dx;c.dy=cc.dy;c.sx=cc.sx;c.sy=cc.sy;c.srot=cc.srot;c.crot=cc.crot;c.rotateVal=cc.rotateVal;$save.call(this);return this.counter-1};ctx.restore=function(){if(this.counter===0){throw new Error("Context restore history is empty")}this.counter--;$restore.call(this);return this.counter};ctx.clipRect=function(x,y,w,h){var c=this.stack[this.counter];if(c.x!=x||y!=c.y||w!=c.width||h!=c.height){var xx=c.x,yy=c.y,ww=c.width,hh=c.height,xw=x+w,xxww=xx+ww,yh=y+h,yyhh=yy+hh;c.x=x>xx?x:xx;c.width=(xw<xxww?xw:xxww)-c.x;c.y=y>yy?y:yy;c.height=(yh<yyhh?yh:yyhh)-c.y;if(c.x!=xx||yy!=c.y||ww!=c.width||hh!=c.height){this.beginPath();this.rect(x,y,w,h);this.closePath();this.clip()}}}}this.width=w;this.height=h;this.invalidate();this.validate();this.repaint();if(w!=pw||h!=ph){this.resized(pw,ph)}pkg.$elBoundsUpdated()}return this},function fullScreen(){this.isFullScreen=true;this.setLocation(0,0);var ws=pkg.$windowSize();this.setSize(ws.width,ws.height)},function setEnabled(b){if(this.isEnabled!=b){for(var k in this.$nativeListeners){if(b){this.canvas[k]=this.$nativeListeners[k];this.$nativeListeners[k]=null}else{this.$nativeListeners[k]=this.canvas[k];this.canvas[k]=null}}this.isEnabled=b}return this},function setVisible(b){var prev=this.isVisible;this.canvas.style.visibility=b?"visible":"hidden";this.$super(b);if(b!=prev){this.repaint()}return this},function vrp(){this.$super();if(document.contains==null||document.contains(this.canvas)){this.repaint()}},function kidAdded(i,constr,c){if(typeof this[c.id]!=="undefined"){throw new Error("Layer '"+c.id+"' already exist")}this[c.id]=c;this.$super(i,constr,c)},function kidRemoved(i,c){delete this[c.id];this.$super(i,c)},function requestFocus(){if(document.activeElement!=this.canvas){this.canvas.focus()}}]);zebra.ready(function(){zebra.busy();$fmCanvas=document.createElement("canvas").getContext("2d");var e=document.getElementById("zebra.fm");if(e==null){e=document.createElement("div");e.setAttribute("id","zebra.fm");e.setAttribute("style","visibility:hidden;line-height:0;height:1px;vertical-align:baseline;");e.innerHTML="<span id='zebra.fm.text' style='display:inline;vertical-align:baseline;'> </span><img id='zebra.fm.image' style='width:1px;height:1px;display:inline;vertical-align:baseline;' width='1' height='1'/>";document.body.appendChild(e)}$fmText=document.getElementById("zebra.fm.text");$fmImage=document.getElementById("zebra.fm.image");$fmImage.onload=function(){zebra.ready()};$fmImage.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII%3D"},function(){try{zebra.busy();pkg.$configuration=new pkg.Bag(pkg);var p=zebra()["zebra.json"];pkg.$configuration.loadByUrl(p?p:pkg.$url.join("canvas.json"),false);while($configurators.length>0){$configurators.shift()(pkg.$configuration)}pkg.$configuration.end();EM=pkg.events;if(pkg.clipboardTriggerKey>0){$clipboard=document.createElement("textarea");$clipboard.setAttribute("style","display:none; position: absolute; left: -99em; top:-99em;");$clipboard.onkeydown=function(ee){$clipboardCanvas.$keyPressed(ee);$clipboard.value="1";$clipboard.select()};$clipboard.onkeyup=function(ee){if(ee.keyCode==pkg.clipboardTriggerKey){$clipboard.style.display="none";$clipboardCanvas.canvas.focus();$clipboardCanvas.canvas.onblur=$clipboardCanvas.focusLost;$clipboardCanvas.canvas.onfocus=$clipboardCanvas.focusGained}$clipboardCanvas.$keyReleased(ee)};$clipboard.onblur=function(){this.value="";this.style.display="none";$clipboardCanvas.canvas.focus()};$clipboard.oncopy=function(ee){if(pkg.focusManager.focusOwner&&pkg.focusManager.focusOwner.copy){var v=pkg.focusManager.focusOwner.copy();$clipboard.value=(v==null?"":v);$clipboard.select()}};$clipboard.oncut=function(ee){if(pkg.focusManager.focusOwner&&pkg.focusManager.focusOwner.cut){$clipboard.value=pkg.focusManager.focusOwner.cut();$clipboard.select()}};if(zebra.isFF){$clipboard.addEventListener("input",function(ee){if(pkg.focusManager.focusOwner&&pkg.focusManager.focusOwner.paste){pkg.focusManager.focusOwner.paste($clipboard.value)}},false)}else{$clipboard.onpaste=function(ee){if(pkg.focusManager.focusOwner&&pkg.focusManager.focusOwner.paste){var txt=(typeof ee.clipboardData=="undefined")?window.clipboardData.getData("Text"):ee.clipboardData.getData("text/plain");pkg.focusManager.focusOwner.paste(txt)}$clipboard.value=""}}document.body.appendChild($clipboard)}if(zebra.isIE){window.focus()}}catch(e){console.log(e.stack?e.stack:e);throw new Error(e.toString())}finally{zebra.ready()}})})(zebra("ui"),zebra.Class,zebra.Interface);(function(pkg,Class){zebra()["zebra.json"]=pkg.$url.join("zebra.json");var MB=zebra.util,ME=pkg.MouseEvent,Cursor=pkg.Cursor,View=pkg.View,Listeners=zebra.util.Listeners,KE=pkg.KeyEvent,L=zebra.layout,task=zebra.util.task,instanceOf=zebra.instanceOf,$invalidA="Invalid alignment",$invalidO="Invalid orientation",$invalidC="Invalid constraints";pkg.$ViewsSetter=function(v){this.views={};for(var k in v){if(v.hasOwnProperty(k)){this.views[k]=pkg.$view(v[k])}}this.vrp()};pkg.CompRender=Class(pkg.Render,[function $prototype(){this.getPreferredSize=function(){return this.target==null||this.target.isVisible===false?{width:0,height:0}:this.target.getPreferredSize()};this.paint=function(g,x,y,w,h,d){var c=this.target;if(c!=null&&c.isVisible===true){c.validate();var prevW=-1,prevH=0,cx=x-c.x,cy=y-c.y;if(c.getCanvas()==null){prevW=c.width;prevH=c.height;c.setSize(w,h)}g.translate(cx,cy);pkg.paintManager.paint(g,c);g.translate(-cx,-cy);if(prevW>=0){c.setSize(prevW,prevH);c.validate()}}}}]);pkg.Line=Class(pkg.Panel,[function(){this.lineColors=["gray"];this.$super()},function $prototype(){this.lineWidth=1;this.setLineColors=function(){this.lineColors=(arguments.length===1)?(Array.isArray(arguments[0])?arguments[0].slice(0):[arguments[0]]):Array.prototype.slice.call(arguments);this.repaint()};this.paint=function(g){var isHor=this.width>this.height,left=this.getLeft(),right=this.getRight(),top=this.getTop(),bottom=this.getBottom(),xy=isHor?top:left;for(var i=0;i<this.lineColors.length;i++){if(this.lineColors[i]!=null){g.setColor(this.lineColors[i]);if(isHor===true){g.drawLine(this.left,xy,this.width-right-left,xy,this.lineWidth)}else{g.drawLine(xy,top,xy,this.height-top-bottom,this.lineWidth)}}xy+=this.lineWidth}};this.calcPreferredSize=function(target){var s=this.lineColors.length*this.lineWidth;return{width:s,height:s}}}]);pkg.StringRender=Class(pkg.Render,[function $prototype(){this.stringWidth=-1;this.owner=null;this[""]=function(txt,font,color){this.setTarget(txt);this.font=font!=null?font:pkg.StringRender.font;this.color=color!=null?color:pkg.StringRender.color};this.ownerChanged=function(v){this.owner=v};this.setFont=function(f){var old=this.font;if(f!=null&&zebra.isString(f)){f=new pkg.Font(f)}if(f!=old&&(f==null||f.s!=old.s)){this.font=f;if(this.owner!=null&&this.owner.isValid===false){this.owner.invalidate()}this.stringWidth=-1;return true}return false};this.paint=function(g,x,y,w,h,d){if(this.font.s!=g.font){g.setFont(this.font)}if(this.color!=g.fillStyle){g.fillStyle=this.color}if(d!=null&&d.isEnabled===false){g.fillStyle=d!=null&&d.disabledColor!=null?d.disabledColor:pkg.StringRender.disabledColor}g.fillText(this.target,x,y)};this.getPreferredSize=function(){if(this.stringWidth<0){this.stringWidth=this.font.stringWidth(this.target)}return{width:this.stringWidth,height:this.font.height}};this.getValue=function(){return this.target};this.setColor=function(c){if(c!=this.color){this.color=c;return true}return false};this.setValue=function(s){this.setTarget(s)};this.targetWasChanged=function(o,n){this.stringWidth=-1;if(this.owner!=null){this.owner.invalidate()}}}]);pkg.TextRender=Class(pkg.Render,zebra.util.Position.Metric,[function $prototype(){this.owner=null;this.getLineIndent=function(){return 1};this.getLines=function(){return this.target.getLines()};this.getLineSize=function(l){return this.target.getLine(l).length+1};this.getLineHeight=function(l){return this.font.height};this.getMaxOffset=function(){return this.target.getTextLength()};this.ownerChanged=function(v){this.owner=v};this.paintLine=function(g,x,y,line,d){g.fillText(this.getLine(line),x,y)};this.getLine=function(r){return this.target.getLine(r)};this.targetWasChanged=function(o,n){if(o!=null){o.unbind(this)}if(n!=null){n.bind(this);this.invalidate(0,this.getLines())}else{this.lines=0}};this.getValue=function(){return this.target==null?null:this.target.getValue()};this.lineWidth=function(line){this.recalc();return this.target.getExtraChar(line)};this.recalc=function(){if(this.lines>0&&this.target!=null){var text=this.target;if(text!=null){if(this.lines>0){for(var i=this.startLine+this.lines-1;i>=this.startLine;i--){text.setExtraChar(i,this.font.stringWidth(this.getLine(i)))}this.startLine=this.lines=0}this.textWidth=0;var size=text.getLines();for(var i=0;i<size;i++){var len=text.getExtraChar(i);if(len>this.textWidth){this.textWidth=len}}this.textHeight=this.getLineHeight()*size+(size-1)*this.getLineIndent()}}};this.textUpdated=function(src,b,off,size,ful,updatedLines){if(b===false){if(this.lines>0){var p1=ful-this.startLine,p2=this.startLine+this.lines-ful-updatedLines;this.lines=((p1>0)?p1:0)+((p2>0)?p2:0)+1;this.startLine=this.startLine<ful?this.startLine:ful}else{this.startLine=ful;this.lines=1}if(this.owner!=null){this.owner.invalidate()}}else{if(this.lines>0){if(ful<=this.startLine){this.startLine+=(updatedLines-1)}else{if(ful<(this.startLine+size)){size+=(updatedLines-1)}}}this.invalidate(ful,updatedLines)}};this.invalidate=function(start,size){if(size>0&&(this.startLine!=start||size!=this.lines)){if(this.lines===0){this.startLine=start;this.lines=size}else{var e=this.startLine+this.lines;this.startLine=start<this.startLine?start:this.startLine;this.lines=Math.max(start+size,e)-this.startLine}if(this.owner!=null){this.owner.invalidate()}}};this.getPreferredSize=function(){if(this.lines>0&&this.target!=null){this.recalc()}return{width:this.textWidth,height:this.textHeight}};this.paint=function(g,x,y,w,h,d){var ts=g.getTopStack();if(ts.width>0&&ts.height>0){var lineIndent=this.getLineIndent(),lineHeight=this.getLineHeight(),lilh=lineHeight+lineIndent,startLine=0;w=ts.width<w?ts.width:w;h=ts.height<h?ts.height:h;if(y<ts.y){startLine=~~((lineIndent+ts.y-y)/lilh);h+=(ts.y-startLine*lineHeight-startLine*lineIndent)}else{if(y>(ts.y+ts.height)){return}}var size=this.target.getLines();if(startLine<size){var lines=~~((h+lineIndent)/lilh)+(((h+lineIndent)%lilh>lineIndent)?1:0);if(startLine+lines>size){lines=size-startLine}y+=startLine*lilh;g.setFont(this.font);if(d==null||d.isEnabled===true){g.setColor(this.color);for(var i=0;i<lines;i++){if(d&&d.getStartSelection!=null){var p1=d.getStartSelection();if(p1!=null){var p2=d.getEndSelection(),line=i+startLine;if((p1[0]!=p2[0]||p1[1]!=p2[1])&&line>=p1[0]&&line<=p2[0]){var s=this.getLine(line),lw=this.lineWidth(line),xx=x;if(line==p1[0]){var ww=this.font.charsWidth(s,0,p1[1]);xx+=ww;lw-=ww;if(p1[0]==p2[0]){lw-=this.font.charsWidth(s,p2[1],s.length-p2[1])}}else{if(line==p2[0]){lw=this.font.charsWidth(s,0,p2[1])}}this.paintSelection(g,xx,y,lw===0?1:lw,lilh,line,d);g.setColor(this.color)}}}this.paintLine(g,x,y,i+startLine,d);y+=lilh}}else{var dcol=d!=null&&d.disabledColor!=null?d.disabledColor:pkg.TextRender.disabledColor;for(var i=0;i<lines;i++){g.setColor(dcol);y+=lilh}}}}};this.paintSelection=function(g,x,y,w,h,line,d){g.setColor(d.selectionColor);g.fillRect(x,y,w,h)};this.setValue=function(s){this.target.setValue(s)};this.setFont=function(f){var old=this.font;if(f&&zebra.isString(f)){f=new pkg.Font(f)}if(f!=old&&(f==null||f.s!=old.s)){this.font=f;this.invalidate(0,this.getLines());return true}return false};this.setColor=function(c){if(c!=this.color){this.color=c;return true}return false};this[""]=function(text){this.color=pkg.TextRender.color;this.font=pkg.TextRender.font;this.textWidth=this.textHeight=this.startLine=this.lines=0;this.setTarget(zebra.isString(text)?new zebra.data.Text(text):text)}}]);pkg.BoldTextRender=Class(pkg.TextRender,[function(t){this.$super(t);this.setFont(pkg.boldFont)}]);pkg.PasswordText=Class(pkg.TextRender,[function(){this.$this(new zebra.data.SingleLineTxt(""))},function(text){this.echo="*";this.showLast=true;this.$super(text)},function setEchoChar(ch){if(this.echo!=ch){this.echo=ch;if(this.target!=null){this.invalidate(0,this.target.getLines())}}},function getLine(r){var buf=[],ln=this.$super(r);for(var i=0;i<ln.length;i++){buf[i]=this.echo}if(this.showLast&&ln.length>0){buf[ln.length-1]=ln[ln.length-1]}return buf.join("")}]);pkg.TabBorder=Class(View,[function(t){this.$this(t,1)},function(t,w){this.type=t;this.left=this.top=this.bottom=this.right=6+w;this.width=w;this.onColor1=pkg.palette.black;this.onColor2=pkg.palette.gray5;this.offColor=pkg.palette.gray1;this.fillColor1="#DCF0F7";this.fillColor2=pkg.palette.white;this.fillColor3=pkg.palette.gray7},function $prototype(){this.paint=function(g,x,y,w,h,d){var xx=x+w-1,yy=y+h-1,o=d.parent.orient,t=this.type,s=this.width,dt=s/2;g.beginPath();g.lineWidth=s;switch(o){case L.LEFT:g.moveTo(xx+1,y+dt);g.lineTo(x+s*2,y+dt);g.lineTo(x+dt,y+s*2);g.lineTo(x+dt,yy-s*2+dt);g.lineTo(x+s*2,yy+dt);g.lineTo(xx+1,yy+dt);if(d.isEnabled===true){g.setColor(t==2?this.fillColor1:this.fillColor2);g.fill()}g.setColor((t===0||t==2)?this.onColor1:this.offColor);g.stroke();if(d.isEnabled===true){var ww=~~((w-6)/2);g.setColor(this.fillColor3);g.fillRect(xx-ww+1,y+s,ww,h-s-1)}if(t==1){g.setColor(this.onColor2);g.drawLine(x+2*s+1,yy-s,xx+1,yy-s,s)}break;case L.RIGHT:xx-=dt;g.moveTo(x,y+dt);g.lineTo(xx-2*s,y+dt);g.lineTo(xx,y+2*s);g.lineTo(xx,yy-2*s);g.lineTo(xx-2*s,yy+dt);g.lineTo(x,yy+dt);if(d.isEnabled===true){g.setColor(t==2?this.fillColor1:this.fillColor2);g.fill()}g.setColor((t===0||t==2)?this.onColor1:this.offColor);g.stroke();if(d.isEnabled===true){var ww=~~((w-6)/2);g.setColor(this.fillColor3);g.fillRect(x,y+s,ww,h-s-1)}if(t==1){g.setColor(this.onColor2);g.drawLine(x,yy-s,xx-s-1,yy-s,s)}break;case L.TOP:g.moveTo(x+dt,yy+1);g.lineTo(x+dt,y+s*2);g.lineTo(x+s*2,y+dt);g.lineTo(xx-s*2+s,y+dt);g.lineTo(xx+dt,y+s*2);g.lineTo(xx+dt,yy+1);if(d.isEnabled===true){g.setColor(t==2?this.fillColor1:this.fillColor2);g.fill()}g.setColor((t===0||t==2)?this.onColor1:this.offColor);g.stroke();if(d.isEnabled===true){g.setColor(this.fillColor3);var hh=~~((h-6)/2);g.fillRect(x+s,yy-hh+1,w-s-1,hh)}if(t===0){g.setColor(this.onColor2);g.beginPath();g.moveTo(xx+dt-s,yy+1);g.lineTo(xx+dt-s,y+s*2);g.stroke()}break;case L.BOTTOM:yy-=dt;g.moveTo(x+dt,y);g.lineTo(x+dt,yy-2*s);g.lineTo(x+2*s+dt,yy);g.lineTo(xx-2*s,yy);g.lineTo(xx+dt,yy-2*s);g.lineTo(xx+dt,y);if(d.isEnabled===true){g.setColor(t==2?this.fillColor1:this.fillColor2);g.fill()}g.setColor((t===0||t==2)?this.onColor1:this.offColor);g.stroke();if(d.isEnabled===true){g.setColor(this.fillColor3);var hh=~~((h-6)/2);g.fillRect(x+s,y,w-s-1,hh)}if(t===0){g.setColor(this.onColor2);g.beginPath();g.moveTo(xx+dt-s,y);g.lineTo(xx+dt-s,yy-s-1);g.stroke()}break;default:throw new Error("Invalid tab alignment")}};this.getTop=function(){return this.top};this.getBottom=function(){return this.bottom};this.getLeft=function(){return this.left};this.getRight=function(){return this.right}}]);pkg.TitledBorder=Class(pkg.Render,[function $prototype(){this.getTop=function(){return this.target.getTop()};this.getLeft=function(){return this.target.getLeft()};this.getRight=function(){return this.target.getRight()};this.getBottom=function(){return this.target.getBottom()};this.outline=function(g,x,y,w,h,d){var xx=x+w,yy=y+h;if(d.getTitleInfo!=null){var r=d.getTitleInfo();if(r!=null){switch(r.orient){case L.BOTTOM:var bottom=this.target.getBottom();switch(this.lineAlignment){case L.CENTER:yy=r.y+~~((r.height-bottom)/2)+bottom;break;case L.TOP:yy=r.y+r.height+bottom;break;case L.BOTTOM:yy=r.y;break}break;case L.TOP:var top=this.target.getTop();switch(this.lineAlignment){case L.CENTER:y=r.y+~~((r.height-top)/2);break;case L.TOP:y=r.y-top;break;case L.BOTTOM:y=r.y+r.height;break}break;case L.LEFT:var left=this.target.getLeft();switch(this.lineAlignment){case L.CENTER:x=r.x+~~((r.width-left)/2);break;case L.TOP:x=r.x-left;break;case L.BOTTOM:x=r.x+r.width;break}break;case L.RIGHT:var right=this.target.getRight();switch(this.lineAlignment){case L.CENTER:xx=r.x+~~((r.width-right)/2)+right;break;case L.TOP:xx=r.x+r.width+right;break;case L.BOTTOM:xx=r.x;break}break}}}if(this.target!=null&&this.target.outline!=null){b=this.target.outline(g,x,y,xx-x,yy-y,d);if(b===true){return b}}g.beginPath();g.rect(x,y,xx-x,yy-y);g.closePath();return true};this.$isIn=function(clip,x,y,w,h){var rx=clip.x>x?clip.x:x,ry=clip.y>y?clip.y:y,rw=Math.min(clip.x+clip.width,x+w)-rx,rh=Math.min(clip.y+clip.height,y+h)-ry;return(clip.x==rx&&clip.y==ry&&clip.width==rw&&clip.height==rh)};this.paint=function(g,x,y,w,h,d){if(d.getTitleInfo!=null){var r=d.getTitleInfo();if(r!=null){var xx=x+w,yy=y+h,t=g.getTopStack();switch(r.orient){case L.TOP:var top=this.target.getTop();switch(this.lineAlignment){case L.CENTER:y=r.y+~~((r.height-top)/2);break;case L.TOP:y=r.y-top;break;case L.BOTTOM:y=r.y+r.height;break}if(this.$isIn(t,x+this.target.getLeft(),y,w-this.target.getRight()-this.target.getLeft(),yy-y-this.target.getBottom())){return}g.save();g.beginPath();g.moveTo(x,y);g.lineTo(r.x,y);g.lineTo(r.x,y+top);g.lineTo(r.x+r.width,y+top);g.lineTo(r.x+r.width,y);g.lineTo(xx,y);g.lineTo(xx,yy);g.lineTo(x,yy);g.lineTo(x,y);break;case L.BOTTOM:var bottom=this.target.getBottom();switch(this.lineAlignment){case L.CENTER:yy=r.y+~~((r.height-bottom)/2)+bottom;break;case L.TOP:yy=r.y+r.height+bottom;break;case L.BOTTOM:yy=r.y;break}if(this.$isIn(t,x+this.target.getLeft(),y+this.target.getTop(),w-this.target.getRight()-this.target.getLeft(),yy-y-this.target.getTop())){return}g.save();g.beginPath();g.moveTo(x,y);g.lineTo(xx,y);g.lineTo(xx,yy);g.lineTo(r.x+r.width,yy);g.lineTo(r.x+r.width,yy-bottom);g.lineTo(r.x,yy-bottom);g.lineTo(r.x,yy);g.lineTo(x,yy);g.lineTo(x,y);break;case L.LEFT:var left=this.target.getLeft();switch(this.lineAlignment){case L.CENTER:x=r.x+~~((r.width-left)/2);break;case L.TOP:x=r.x-left;break;case L.BOTTOM:x=r.x+r.width;break}if(this.$isIn(t,x,y+this.target.getTop(),xx-x-this.target.getRight(),h-this.target.getTop()-this.target.getBottom())){return}g.save();g.beginPath();g.moveTo(x,y);g.lineTo(xx,y);g.lineTo(xx,yy);g.lineTo(x,yy);g.lineTo(x,r.y+r.height);g.lineTo(x+left,r.y+r.height);g.lineTo(x+left,r.y);g.lineTo(x,r.y);g.lineTo(x,y);break;case L.RIGHT:var right=this.target.getRight();switch(this.lineAlignment){case L.CENTER:xx=r.x+~~((r.width-right)/2)+right;break;case L.TOP:xx=r.x+r.width+right;break;case L.BOTTOM:xx=r.x;break}if(this.$isIn(t,x+this.target.getLeft(),y+this.target.getTop(),xx-x-this.target.getLeft(),h-this.target.getTop()-this.target.getBottom())){return}g.save();g.beginPath();g.moveTo(x,y);g.lineTo(xx,y);g.lineTo(xx,r.y);g.lineTo(xx-right,r.y);g.lineTo(xx-right,r.y+r.height);g.lineTo(xx,r.y+r.height);g.lineTo(xx,yy);g.lineTo(x,yy);g.lineTo(x,y);break}g.closePath();g.clip();this.target.paint(g,x,y,xx-x,yy-y,d);g.restore()}}else{this.target.paint(g,x,y,w,h,d)}};this[""]=function(b,a){this.lineAlignment=(a==null?L.BOTTOM:L.$constraints(a));if(b==null&&this.lineAlignment!=L.BOTTOM&&this.lineAlignment!=L.TOP&&this.lineAlignment!=L.CENTER){throw new Error($invalidA)}this.setTarget(b)}}]);pkg.Label=Class(pkg.ViewPan,[function $prototype(){this.getValue=function(){return this.view.getValue()};this.getColor=function(){return this.view.color};this.getFont=function(){return this.view.font};this.setValue=function(s){this.view.setValue(s);this.repaint();return this};this.setColor=function(c){if(this.view.setColor(c)){this.repaint()}return this};this.setFont=function(f){if(this.view.setFont(f)){this.repaint()}return this}},function(){this.$this("")},function(r){if(zebra.isString(r)){this.setView(new pkg.StringRender(r))}else{this.setView(instanceOf(r,zebra.data.TextModel)?new pkg.TextRender(r):r)}this.$super()}]);pkg.MLabel=Class(pkg.Label,[function(){this.$this("")},function(t){this.$super(new zebra.data.Text(t))}]);pkg.BoldLabel=Class(pkg.Label,[]);pkg.ImageLabel=Class(pkg.Panel,[function(txt,img){this.$super(new L.FlowLayout(L.LEFT,L.CENTER,L.HORIZONTAL,6));this.add(new pkg.ImagePan(null));this.add(instanceOf(txt,pkg.Panel)?txt:new pkg.Label(txt));this.kids[1].setVisible(txt!=null);this.setImage(img)},function setCaption(c){this.kids[1].setValue(c);this.kids[1].setVisible(c!=null)},function setImage(p){this.kids[0].setImage(p);this.kids[0].setVisible(p!=null)}]);pkg.StatePan=Class(pkg.ViewPan,[function $prototype(){this.state=null;this.setState=function(s){if(s!==this.state){var prev=this.state;this.state=s;this.stateUpdated(prev,s)}};this.stateUpdated=function(o,n){var b=false,id=(this.toViewId!=null?this.toViewId(n):n);if(id==null){return}for(var i=0;i<this.kids.length;i++){if(this.kids[i].parentStateUpdated!=null){this.kids[i].parentStateUpdated(o,n,id)}}if(this.border!=null&&this.border.activate!=null){b=this.border.activate(id)||b}if(this.view!=null&&this.view.activate!=null){b=this.view.activate(id)||b}if(this.bg!=null&&this.bg.activate!=null){b=this.bg.activate(id)||b}if(b){this.repaint()}};this.syncState=function(){this.stateUpdated(this.state,this.state)}},function setView(v){if(v!=this.view){this.$super(v);this.syncState(this.state,this.state)}return this},function setBorder(v){if(v!=this.border){this.$super(v);this.syncState(this.state,this.state)}return this},function setBackground(v){if(v!=this.bg){this.$super(v);this.syncState(this.state,this.state)}return this}]);var OVER=0,PRESSED_OVER=1,OUT=2,PRESSED_OUT=3,DISABLED=4;pkg.EvStatePan=Class(pkg.StatePan,[function $prototype(){this.state=OUT;this.$isIn=false;var IDS=["over","pressed.over","out","pressed.out","disabled"];this.toViewId=function(state){return IDS[state]};this._keyPressed=function(e){if(this.state!==PRESSED_OVER&&this.state!==PRESSED_OUT&&(e.code==KE.ENTER||e.code==KE.SPACE)){this.setState(PRESSED_OVER)}};this._keyReleased=function(e){if(this.state==PRESSED_OVER||this.state==PRESSED_OUT){var prev=this.state;this.setState(OVER);if(this.$isIn===false){this.setState(OUT)}}};this._mouseEntered=function(e){if(this.isEnabled===true){this.setState(this.state==PRESSED_OUT?PRESSED_OVER:OVER);this.$isIn=true}};this._mousePressed=function(e){if(this.state!=PRESSED_OVER&&this.state!=PRESSED_OUT&&e.isActionMask()){this.setState(PRESSED_OVER)}};this._mouseReleased=function(e){if((this.state===PRESSED_OVER||this.state===PRESSED_OUT)&&e.isActionMask()){if(e.source==this){this.setState(e.x>=0&&e.y>=0&&e.x<this.width&&e.y<this.height?OVER:OUT)}else{var p=L.toParentOrigin(e.x,e.y,e.source,this);this.$isIn=p.x>=0&&p.y>=0&&p.x<this.width&&p.y<this.height;this.setState(this.$isIn?OVER:OUT)}}};this.childInputEvent=function(e){if(e.UID==pkg.InputEvent.MOUSE_UID){switch(e.ID){case ME.ENTERED:this._mouseEntered(e);break;case ME.PRESSED:this._mousePressed(e);break;case ME.RELEASED:this._mouseReleased(e);break;case ME.EXITED:if(e.x>=0&&e.y>=0&&e.x<e.source.width&&e.y<e.source.height){this.$isIn=false}else{var p=L.toParentOrigin(e.x,e.y,e.source,this);this.$isIn=p.x>=0&&p.y>=0&&p.x<this.width&&p.y<this.height}if(this.$isIn===false){this.setState(this.state===PRESSED_OVER?PRESSED_OUT:OUT)}break}}else{if(e.UID==pkg.InputEvent.KEY_UID){if(e.ID==KE.PRESSED){this._keyPressed(e)}else{if(e.ID==KE.RELEASED){this._keyReleased(e)}}}}};this.keyPressed=function(e){this._keyPressed(e)};this.keyReleased=function(e){this._keyReleased(e)};this.mouseEntered=function(e){this._mouseEntered()};this.mouseExited=function(e){if(this.isEnabled===true){this.setState(this.state==PRESSED_OVER?PRESSED_OUT:OUT);this.$isIn=false}};this.mousePressed=function(e){this._mousePressed(e)};this.mouseReleased=function(e){this._mouseReleased(e)};this.mouseDragged=function(e){if(e.isActionMask()){var pressed=(this.state==PRESSED_OUT||this.state==PRESSED_OVER);if(e.x>0&&e.y>0&&e.x<this.width&&e.y<this.height){this.setState(pressed?PRESSED_OVER:OVER)}else{this.setState(pressed?PRESSED_OUT:OUT)}}}},function setEnabled(b){this.$super(b);this.setState(b?OUT:DISABLED)}]);pkg.CompositeEvStatePan=Class(pkg.EvStatePan,pkg.Composite,[function $prototype(){this.canHaveFocus=true;this.focusComponent=null;this.focusMarkerView=null;this.paintOnTop=function(g){var fc=this.focusComponent;if(this.focusMarkerView!=null&&fc!=null&&this.hasFocus()){this.focusMarkerView.paint(g,fc.x,fc.y,fc.width,fc.height,this)}};this.setFocusMarkerView=function(c){if(c!=this.focusMarkerView){this.focusMarkerView=pkg.$view(c);this.repaint()}};this.setCanHaveFocus=function(b){if(this.canHaveFocus!=b){var fm=pkg.focusManager;if(b===false&&fm.focusOwner==this){fm.requestFocus(null)}this.canHaveFocus=b}};this.setFocusAnchorComponent=function(c){if(this.focusComponent!=c){if(c!=null&&this.kids.indexOf(c)<0){throw Error("Focus component doesn't exist")}this.focusComponent=c;this.repaint()}}},function focused(){this.$super();this.repaint()},function kidRemoved(i,l){if(l==this.focusComponent){this.focusComponent=null}this.$super(i,l)}]);pkg.Button=Class(pkg.CompositeEvStatePan,[function $clazz(){this.Label=Class(pkg.Label,[])},function $prototype(){this.canHaveFocus=true;this.isFireByPress=false;this.firePeriod=-1;this.fire=function(){this._.fired(this);if(this.catchFired!=null){this.catchFired()}};this.run=function(){if(this.state===PRESSED_OVER){this.fire()}};this.setFireParams=function(b,time){this.isFireByPress=b;this.firePeriod=time}},function(){this.$this(null)},function(t){this._=new Listeners();if(zebra.isString(t)){t=new this.$clazz.Label(t)}this.$super();if(t!=null){this.add(t);this.setFocusAnchorComponent(t)}},function stateUpdated(o,n){this.$super(o,n);if(n===PRESSED_OVER){if(this.isFireByPress){this.fire();if(this.firePeriod>0){this.repeatTask=task(this.run,this).run(400,this.firePeriod)}}}else{if(this.firePeriod>0&&this.repeatTask!=null){this.repeatTask.shutdown()}if(n===OVER&&(o===PRESSED_OVER&&this.isFireByPress===false)){this.fire()}}}]);pkg.BorderPan=Class(pkg.Panel,[function $clazz(){this.Label=Class(pkg.Label,[])},function $prototype(){this.vGap=this.hGap=2;this.indent=4;this.getTitleInfo=function(){return(this.label!=null)?{x:this.label.x,y:this.label.y,width:this.label.width,height:this.label.height,orient:this.label.constraints&(L.TOP|L.BOTTOM)}:null};this.calcPreferredSize=function(target){var ps=this.content!=null&&this.content.isVisible===true?this.content.getPreferredSize():{width:0,height:0};if(this.label!=null&&this.label.isVisible===true){var lps=this.label.getPreferredSize();ps.height+=lps.height;ps.width=Math.max(ps.width,lps.width+this.indent)}ps.width+=(this.hGap*2);ps.height+=(this.vGap*2);return ps};this.doLayout=function(target){var h=0,right=this.getRight(),left=this.getLeft(),xa=this.label!=null?this.label.constraints&(L.LEFT|L.CENTER|L.RIGHT):0,ya=this.label!=null?this.label.constraints&(L.BOTTOM|L.TOP):0,top=ya==L.TOP?this.top:this.getTop(),bottom=ya==L.BOTTOM?this.bottom:this.getBottom();if(this.label!=null&&this.label.isVisible===true){var ps=this.label.getPreferredSize();h=ps.height;this.label.setSize(ps.width,h);this.label.setLocation((xa==L.LEFT)?left+this.indent:((xa==L.RIGHT)?this.width-right-ps.width-this.indent:~~((this.width-ps.width)/2)),(ya==L.BOTTOM)?(this.height-bottom-ps.height):top)}if(this.content!=null&&this.content.isVisible===true){this.content.setLocation(left+this.hGap,(ya==L.BOTTOM?top:top+h)+this.vGap);this.content.setSize(this.width-right-left-2*this.hGap,this.height-top-bottom-h-2*this.vGap)}};this.setGaps=function(vg,hg){if(this.vGap!=vg||hg!=this.hGap){this.vGap=vg;this.hGap=hg;this.vrp()}return this}},function(title){this.$this(title,null)},function(){this.$this(null)},function(title,center){this.$this(title,center,L.TOP|L.LEFT)},function(title,center,ctr){if(zebra.isString(title)){title=new this.$clazz.Label(title)}this.label=this.content=null;this.$super();if(title!=null){this.add(L.$constraints(ctr),title)}if(center!=null){this.add(L.CENTER,center)}},function setBorder(br){br=pkg.$view(br);if(instanceOf(br,pkg.TitledBorder)===false){br=new pkg.TitledBorder(br,L.CENTER)}return this.$super(br)},function kidAdded(index,id,lw){this.$super(index,id,lw);if(L.CENTER==id){this.content=lw}else{this.label=lw}},function kidRemoved(index,lw){this.$super(index,lw);if(lw==this.label){this.label=null}else{this.content=null}}]);pkg.SwitchManager=Class([function $prototype(){this.getValue=function(o){return this.state};this.setValue=function(o,b){if(this.getValue(o)!=b){this.state=b;this.updated(o,b)}};this.updated=function(o,b){if(o!=null){o.switched(b)}this._.fired(this,o)};this.install=function(o){o.switched(this.getValue(o))};this.uninstall=function(o){};this[""]=function(){this.state=false;this._=new Listeners()}}]);pkg.Group=Class(pkg.SwitchManager,[function(){this.$super();this.state=null},function $prototype(){this.getValue=function(o){return o==this.state};this.setValue=function(o,b){if(this.getValue(o)!=b){this.clearSelected();this.state=o;this.updated(o,true)}};this.clearSelected=function(){if(this.state!=null){var old=this.state;this.state=null;this.updated(old,false)}}}]);pkg.Checkbox=Class(pkg.CompositeEvStatePan,[function $clazz(){this.Box=Class(pkg.StatePan,[function $prototype(){this.parentStateUpdated=function(o,n,id){this.setState(id)}}]);this.Label=Class(pkg.Label,[])},function $prototype(){this.setValue=function(b){this.manager.setValue(this,b);return this};this.getValue=function(){return this.manager?this.manager.getValue(this):false};this.switched=function(b){this.stateUpdated(this.state,this.state)};this.toViewId=function(state){if(this.isEnabled===true){if(this.getValue()){return(this.state==OVER)?"on.over":"on.out"}return(this.state==OVER)?"off.over":"off.out"}return this.getValue()?"don":"doff"}},function(){this.$this(null)},function(c){this.$this(c,new pkg.SwitchManager())},function(c,m){if(zebra.isString(c)){c=new this.$clazz.Label(c)}this.$super();this.box=new this.$clazz.Box();this.add(this.box);if(c!=null){this.add(c);this.setFocusAnchorComponent(c)}this.setSwitchManager(m)},function keyPressed(e){if(instanceOf(this.manager,pkg.Group)&&this.getValue()){var code=e.code,d=0;if(code==KE.LEFT||code==KE.UP){d=-1}else{if(code==KE.RIGHT||code==KE.DOWN){d=1}}if(d!==0){var p=this.parent,idx=p.indexOf(this);for(var i=idx+d;i<p.kids.length&&i>=0;i+=d){var l=p.kids[i];if(l.isVisible===true&&l.isEnabled===true&&instanceOf(l,pkg.Checkbox)&&l.manager==this.manager){l.requestFocus();l.setValue(true);break}}return}}this.$super(e)},function setSwitchManager(m){if(m==null){throw new Error("Null switch manager")}if(this.manager!=m){if(this.manager!=null){this.manager.uninstall(this)}this.manager=m;this.manager.install(this)}},function stateUpdated(o,n){if(o==PRESSED_OVER&&n==OVER){this.setValue(!this.getValue())}this.$super(o,n)},function kidRemoved(index,c){if(this.box==c){this.box=null}this.$super(index,c)}]);pkg.Radiobox=Class(pkg.Checkbox,[function $clazz(){this.Box=Class(pkg.Checkbox.Box,[]);this.Label=Class(pkg.Checkbox.Label,[])},function(c){this.$this(c,new pkg.Group())},function(c,group){this.$super(c,group)}]);pkg.SplitPan=Class(pkg.Panel,[function $clazz(){this.Bar=Class(pkg.EvStatePan,[function $prototype(){this.mouseDragged=function(e){var x=this.x+e.x,y=this.y+e.y;if(this.target.orientation==L.VERTICAL){if(this.prevLoc!=x){x=this.target.normalizeBarLoc(x);if(x>0){this.prevLoc=x;this.target.setGripperLoc(x)}}}else{if(this.prevLoc!=y){y=this.target.normalizeBarLoc(y);if(y>0){this.prevLoc=y;this.target.setGripperLoc(y)}}}};this.mouseDragStarted=function(e){var x=this.x+e.x,y=this.y+e.y;if(e.isActionMask()){if(this.target.orientation==L.VERTICAL){x=this.target.normalizeBarLoc(x);if(x>0){this.prevLoc=x}}else{y=this.target.normalizeBarLoc(y);if(y>0){this.prevLoc=y}}}};this.mouseDragEnded=function(e){var xy=this.target.normalizeBarLoc(this.target.orientation==L.VERTICAL?this.x+e.x:this.y+e.y);if(xy>0){this.target.setGripperLoc(xy)}}},function(target){this.prevLoc=0;this.target=target;this.cursorType=(target.orientation==L.VERTICAL?Cursor.W_RESIZE:Cursor.N_RESIZE);this.$super()}])},function $prototype(){this.leftMinSize=this.rightMinSize=50;this.isMoveable=true;this.gap=1;this.normalizeBarLoc=function(xy){if(xy<this.minXY){xy=this.minXY}else{if(xy>this.maxXY){xy=this.maxXY}}return(xy>this.maxXY||xy<this.minXY)?-1:xy};this.setGripperLoc=function(l){if(l!=this.barLocation){this.barLocation=l;this.vrp()}};this.calcPreferredSize=function(c){var fSize=pkg.getPreferredSize(this.leftComp),sSize=pkg.getPreferredSize(this.rightComp),bSize=pkg.getPreferredSize(this.gripper);if(this.orientation==L.HORIZONTAL){bSize.width=Math.max(((fSize.width>sSize.width)?fSize.width:sSize.width),bSize.width);bSize.height=fSize.height+sSize.height+bSize.height+2*this.gap}else{bSize.width=fSize.width+sSize.width+bSize.width+2*this.gap;bSize.height=Math.max(((fSize.height>sSize.height)?fSize.height:sSize.height),bSize.height)}return bSize};this.doLayout=function(target){var right=this.getRight(),top=this.getTop(),bottom=this.getBottom(),left=this.getLeft(),bSize=pkg.getPreferredSize(this.gripper);if(this.orientation==L.HORIZONTAL){var w=this.width-left-right;if(this.barLocation<top){this.barLocation=top}else{if(this.barLocation>this.height-bottom-bSize.height){this.barLocation=this.height-bottom-bSize.height}}if(this.gripper!=null){if(this.isMoveable){this.gripper.setLocation(left,this.barLocation);this.gripper.setSize(w,bSize.height)}else{this.gripper.setSize(bSize.width,bSize.height);this.gripper.toPreferredSize();this.gripper.setLocation(~~((w-bSize.width)/2),this.barLocation)}}if(this.leftComp!=null){this.leftComp.setLocation(left,top);this.leftComp.setSize(w,this.barLocation-this.gap-top)}if(this.rightComp!=null){this.rightComp.setLocation(left,this.barLocation+bSize.height+this.gap);this.rightComp.setSize(w,this.height-this.rightComp.y-bottom)}}else{var h=this.height-top-bottom;if(this.barLocation<left){this.barLocation=left}else{if(this.barLocation>this.width-right-bSize.width){this.barLocation=this.width-right-bSize.width}}if(this.gripper!=null){if(this.isMoveable){this.gripper.setLocation(this.barLocation,top);this.gripper.setSize(bSize.width,h)}else{this.gripper.setSize(bSize.width,bSize.height);this.gripper.setLocation(this.barLocation,~~((h-bSize.height)/2))}}if(this.leftComp!=null){this.leftComp.setLocation(left,top);this.leftComp.setSize(this.barLocation-left-this.gap,h)}if(this.rightComp!=null){this.rightComp.setLocation(this.barLocation+bSize.width+this.gap,top);this.rightComp.setSize(this.width-this.rightComp.x-right,h)}}};this.setGap=function(g){if(this.gap!=g){this.gap=g;this.vrp()}};this.setLeftMinSize=function(m){if(this.leftMinSize!=m){this.leftMinSize=m;this.vrp()}};this.setRightMinSize=function(m){if(this.rightMinSize!=m){this.rightMinSize=m;this.vrp()}};this.setGripperMovable=function(b){if(b!=this.isMoveable){this.isMoveable=b;this.vrp()}}},function(){this.$this(null,null,L.VERTICAL)},function(f,s){this.$this(f,s,L.VERTICAL)},function(f,s,o){this.minXY=this.maxXY=0;this.barLocation=70;this.leftComp=this.rightComp=this.gripper=null;this.orientation=L.$constraints(o);this.$super();if(f!=null){this.add(L.LEFT,f)}if(s!=null){this.add(L.RIGHT,s)}this.add(L.CENTER,new this.$clazz.Bar(this))},function kidAdded(index,id,c){this.$super(index,id,c);if(L.LEFT==id){this.leftComp=c}else{if(L.RIGHT==id){this.rightComp=c}else{if(L.CENTER==id){this.gripper=c}else{throw new Error($invalidC)}}}},function kidRemoved(index,c){this.$super(index,c);if(c==this.leftComp){this.leftComp=null}else{if(c==this.rightComp){this.rightComp=null}else{if(c==this.gripper){this.gripper=null}}}},function resized(pw,ph){var ps=this.gripper.getPreferredSize();if(this.orientation==L.VERTICAL){this.minXY=this.getLeft()+this.gap+this.leftMinSize;this.maxXY=this.width-this.gap-this.rightMinSize-ps.width-this.getRight()}else{this.minXY=this.getTop()+this.gap+this.leftMinSize;this.maxXY=this.height-this.gap-this.rightMinSize-ps.height-this.getBottom()}this.$super(pw,ph)}]);pkg.Progress=Class(pkg.Panel,[function $prototype(){this.gap=2;this.orientation=L.HORIZONTAL;this.paint=function(g){var left=this.getLeft(),right=this.getRight(),top=this.getTop(),bottom=this.getBottom(),rs=(this.orientation==L.HORIZONTAL)?this.width-left-right:this.height-top-bottom,bundleSize=(this.orientation==L.HORIZONTAL)?this.bundleWidth:this.bundleHeight;if(rs>=bundleSize){var vLoc=~~((rs*this.value)/this.maxValue),x=left,y=this.height-bottom,bundle=this.bundleView,wh=this.orientation==L.HORIZONTAL?this.height-top-bottom:this.width-left-right;while(x<(vLoc+left)&&this.height-vLoc-bottom<y){if(this.orientation==L.HORIZONTAL){bundle.paint(g,x,top,bundleSize,wh,this);x+=(bundleSize+this.gap)}else{bundle.paint(g,left,y-bundleSize,wh,bundleSize,this);y-=(bundleSize+this.gap)}}if(this.titleView!=null){var ps=this.bundleView.getPreferredSize();this.titleView.paint(g,L.xAlignment(ps.width,L.CENTER,this.width),L.yAlignment(ps.height,L.CENTER,this.height),ps.width,ps.height,this)}}};this.calcPreferredSize=function(l){var bundleSize=(this.orientation==L.HORIZONTAL)?this.bundleWidth:this.bundleHeight,v1=(this.maxValue*bundleSize)+(this.maxValue-1)*this.gap,ps=this.bundleView.getPreferredSize();ps=(this.orientation==L.HORIZONTAL)?{width:v1,height:(this.bundleHeight>=0?this.bundleHeight:ps.height)}:{width:(this.bundleWidth>=0?this.bundleWidth:ps.width),height:v1};if(this.titleView!=null){var tp=this.titleView.getPreferredSize();ps.width=Math.max(ps.width,tp.width);ps.height=Math.max(ps.height,tp.height)}return ps}},function(){this.value=0;this.setBundleView("darkBlue");this.bundleWidth=this.bundleHeight=6;this.maxValue=20;this._=new Listeners();this.$super()},function setOrientation(o){o=L.$constraints(o);if(o!=L.HORIZONTAL&&o!=L.VERTICAL){throw new Error($invalidO)}if(o!=this.orientation){this.orientation=o;this.vrp()}},function setMaxValue(m){if(m!=this.maxValue){this.maxValue=m;this.setValue(this.value);this.vrp()}},function setValue(p){p=p%(this.maxValue+1);if(this.value!=p){var old=this.value;this.value=p;this._.fired(this,old);this.repaint()}},function setGap(g){if(this.gap!=g){this.gap=g;this.vrp()}},function setBundleView(v){if(this.bundleView!=v){this.bundleView=pkg.$view(v);this.vrp()}},function setBundleSize(w,h){if(w!=this.bundleWidth&&h!=this.bundleHeight){this.bundleWidth=w;this.bundleHeight=h;this.vrp()}}]);pkg.Link=Class(pkg.Button,[function $prototype(){this.cursorType=Cursor.HAND},function(s){this.view=new pkg.TextRender(s);this.$super(null);this.stateUpdated(this.state,this.state)},function setFont(f){this.view.setFont(f)},function setColor(state,c){if(this.colors[state]!=c){this.colors[state]=c;this.stateUpdated(state,state)}},function stateUpdated(o,n){this.$super(o,n);var r=this.view;if(r&&r.color!=this.colors[n]){r.setColor(this.colors[n]);this.repaint()}}]);pkg.ExtendablePan=Class(pkg.Panel,[function $prototype(){this.toggle=function(){this.isCollapsed=this.isCollapsed?false:true;this.contentPan.setVisible(!this.isCollapsed);this.togglePan.setState(this.isCollapsed?"off":"on");this.repaint();if(this._){this._.fired(this,this.isCollapsed)}}},function $clazz(){this.Label=Class(pkg.Label,[]);this.TitlePan=Class(pkg.Panel,[]);this.TogglePan=Class(pkg.StatePan,[function $prototype(){this.mousePressed=function(e){if(e.isActionMask()){this.parent.parent.toggle()}};this.cursorType=Cursor.HAND}])},function(content,lab){this.isCollapsed=true;this.$super();if(zebra.isString(lab)){lab=new this.$clazz.Label(lab)}this.label=lab;this.titlePan=new this.$clazz.TitlePan();this.add(L.TOP,this.titlePan);this.togglePan=new this.$clazz.TogglePan();this.titlePan.add(this.togglePan);this.titlePan.add(this.label);this.contentPan=content;this.contentPan.setVisible(!this.isCollapsed);this.add(L.CENTER,this.contentPan);this.toggle();this._=new Listeners()}]);var ScrollManagerListeners=zebra.util.ListenersClass("scrolled");pkg.ScrollManager=Class([function $prototype(){this.getSX=function(){return this.sx};this.getSY=function(){return this.sy};this.scrollXTo=function(v){this.scrollTo(v,this.getSY())};this.scrollYTo=function(v){this.scrollTo(this.getSX(),v)};this.scrollTo=function(x,y){var psx=this.getSX(),psy=this.getSY();if(psx!=x||psy!=y){this.sx=x;this.sy=y;if(this.scrollStateUpdated!=null){this.scrollStateUpdated(x,y,psx,psy)}if(this.target.catchScrolled!=null){this.target.catchScrolled(psx,psy)}this._.scrolled(psx,psy)}};this.makeVisible=function(x,y,w,h){var p=pkg.calcOrigin(x,y,w,h,this.getSX(),this.getSY(),this.target);this.scrollTo(p[0],p[1])}},function(c){this.sx=this.sy=0;this._=new ScrollManagerListeners();this.target=c}]);pkg.Scroll=Class(pkg.Panel,zebra.util.Position.Metric,pkg.Composite,[function $clazz(){var SB=Class(pkg.Button,[function $prototype(){this.isDragable=this.isFireByPress=true;this.firePeriod=20}]);this.VIncButton=Class(SB,[]);this.VDecButton=Class(SB,[]);this.HIncButton=Class(SB,[]);this.HDecButton=Class(SB,[]);this.VBundle=Class(pkg.Panel,[]);this.HBundle=Class(pkg.Panel,[]);this.MIN_BUNDLE_SIZE=16},function $prototype(){this.extra=this.max=100;this.pageIncrement=20;this.unitIncrement=5;this.isInBundle=function(x,y){var bn=this.bundle;return(bn!=null&&bn.isVisible===true&&bn.x<=x&&bn.y<=y&&bn.x+bn.width>x&&bn.y+bn.height>y)};this.amount=function(){var db=this.decBt,ib=this.incBt;return(this.type==L.VERTICAL)?ib.y-db.y-db.height:ib.x-db.x-db.width};this.pixel2value=function(p){var db=this.decBt;return(this.type==L.VERTICAL)?~~((this.max*(p-db.y-db.height))/(this.amount()-this.bundle.height)):~~((this.max*(p-db.x-db.width))/(this.amount()-this.bundle.width))};this.value2pixel=function(){var db=this.decBt,bn=this.bundle,off=this.position.offset;return(this.type==L.VERTICAL)?db.y+db.height+~~(((this.amount()-bn.height)*off)/this.max):db.x+db.width+~~(((this.amount()-bn.width)*off)/this.max)};this.catchInput=function(child){return child==this.bundle||(this.bundle.kids.length>0&&L.isAncestorOf(this.bundle,child))};this.posChanged=function(target,po,pl,pc){if(this.bundle!=null){if(this.type==L.HORIZONTAL){this.bundle.setLocation(this.value2pixel(),this.getTop())}else{this.bundle.setLocation(this.getLeft(),this.value2pixel())}}};this.getLines=function(){return this.max};this.getLineSize=function(line){return 1};this.getMaxOffset=function(){return this.max};this.fired=function(src){this.position.setOffset(this.position.offset+((src==this.incBt)?this.unitIncrement:-this.unitIncrement))};this.mouseDragged=function(e){if(Number.MAX_VALUE!=this.startDragLoc){this.position.setOffset(this.pixel2value(this.bundleLoc-this.startDragLoc+((this.type==L.HORIZONTAL)?e.x:e.y)))}};this.mouseDragStarted=function(e){this.startDragLoc=this.type==L.HORIZONTAL?e.x:e.y;this.bundleLoc=this.type==L.HORIZONTAL?this.bundle.x:this.bundle.y};this.mouseDragEnded=function(e){this.startDragLoc=Number.MAX_VALUE};this.mouseClicked=function(e){if(this.isInBundle(e.x,e.y)===false&&e.isActionMask()){var d=this.pageIncrement;if(this.type==L.VERTICAL){if(e.y<(this.bundle!=null?this.bundle.y:~~(this.height/2))){d=-d}}else{if(e.x<(this.bundle!=null?this.bundle.x:~~(this.width/2))){d=-d}}this.position.setOffset(this.position.offset+d)}};this.calcPreferredSize=function(target){var ps1=pkg.getPreferredSize(this.incBt),ps2=pkg.getPreferredSize(this.decBt),ps3=pkg.getPreferredSize(this.bundle);if(this.type==L.HORIZONTAL){ps1.width+=(ps2.width+ps3.width);ps1.height=Math.max((ps1.height>ps2.height?ps1.height:ps2.height),ps3.height)}else{ps1.height+=(ps2.height+ps3.height);ps1.width=Math.max((ps1.width>ps2.width?ps1.width:ps2.width),ps3.width)}return ps1};this.doLayout=function(target){var right=this.getRight(),top=this.getTop(),bottom=this.getBottom(),left=this.getLeft(),ew=this.width-left-right,eh=this.height-top-bottom,b=(this.type==L.HORIZONTAL),ps1=pkg.getPreferredSize(this.decBt),ps2=pkg.getPreferredSize(this.incBt),minbs=pkg.Scroll.MIN_BUNDLE_SIZE;this.decBt.setSize(b?ps1.width:ew,b?eh:ps1.height);this.decBt.setLocation(left,top);this.incBt.setSize(b?ps2.width:ew,b?eh:ps2.height);this.incBt.setLocation(b?this.width-right-ps2.width:left,b?top:this.height-bottom-ps2.height);if(this.bundle!=null&&this.bundle.isVisible===true){var am=this.amount();if(am>minbs){var bsize=Math.max(Math.min(~~((this.extra*am)/this.max),am-minbs),minbs);this.bundle.setSize(b?bsize:ew,b?eh:bsize);this.bundle.setLocation(b?this.value2pixel():left,b?top:this.value2pixel())}else{this.bundle.setSize(0,0)}}};this.setMaximum=function(m){if(m!=this.max){this.max=m;if(this.position.offset>this.max){this.position.setOffset(this.max)}this.vrp()}};this.setPosition=function(p){if(p!=this.position){if(this.position!=null){this.position.unbind(this)}this.position=p;if(this.position!=null){this.position.bind(this);this.position.setMetric(this);this.position.setOffset(0)}}};this.setExtraSize=function(e){if(e!=this.extra){this.extra=e;this.vrp()}}},function(t){t=L.$constraints(t);if(t!=L.VERTICAL&&t!=L.HORIZONTAL){throw new Error($invalidA)}this.incBt=this.decBt=this.bundle=this.position=null;this.bundleLoc=this.type=0;this.startDragLoc=Number.MAX_VALUE;this.$super(this);this.add(L.CENTER,t==L.VERTICAL?new pkg.Scroll.VBundle():new pkg.Scroll.HBundle());this.add(L.TOP,t==L.VERTICAL?new pkg.Scroll.VDecButton():new pkg.Scroll.HDecButton());this.add(L.BOTTOM,t==L.VERTICAL?new pkg.Scroll.VIncButton():new pkg.Scroll.HIncButton());this.type=t;this.setPosition(new zebra.util.Position(this))},function kidAdded(index,id,lw){this.$super(index,id,lw);if(L.CENTER==id){this.bundle=lw}else{if(L.BOTTOM==id){this.incBt=lw;this.incBt.bind(this)}else{if(L.TOP==id){this.decBt=lw;this.decBt.bind(this)}else{throw new Error($invalidC)}}}},function kidRemoved(index,lw){this.$super(index,lw);if(lw==this.bundle){this.bundle=null}else{if(lw==this.incBt){this.incBt.unbind(this);this.incBt=null}else{if(lw==this.decBt){this.decBt.unbind(this);this.decBt=null}}}}]);pkg.ScrollPan=Class(pkg.Panel,[function $clazz(){this.ContentPan=Class(pkg.Panel,[function(c){this.$super(new L.RasterLayout(L.USE_PS_SIZE));this.scrollManager=new pkg.ScrollManager(c,[function $prototype(){this.getSX=function(){return this.target.x};this.getSY=function(){return this.target.y};this.scrollStateUpdated=function(sx,sy,psx,psy){this.target.setLocation(sx,sy)}}]);this.add(c)}])},function $prototype(){this.autoHide=false;this.$interval=0;this.setAutoHide=function(b){if(this.autoHide!=b){this.autoHide=b;if(this.hBar!=null){if(this.hBar.incBt!=null){this.hBar.incBt.setVisible(!b)}if(this.hBar.decBt!=null){this.hBar.decBt.setVisible(!b)}}if(this.vBar!=null){if(this.vBar.incBt!=null){this.vBar.incBt.setVisible(!b)}if(this.vBar.decBt!=null){this.vBar.decBt.setVisible(!b)}}if(this.$interval!=0){clearInterval(this.$interval);$this.$interval=0}this.vrp()}};this.scrolled=function(psx,psy){try{this.validate();this.isPosChangedLocked=true;if(this.hBar!=null){this.hBar.position.setOffset(-this.scrollObj.scrollManager.getSX())}if(this.vBar!=null){this.vBar.position.setOffset(-this.scrollObj.scrollManager.getSY())}if(this.scrollObj.scrollManager==null){this.invalidate()}}catch(e){throw e}finally{this.isPosChangedLocked=false}};this.calcPreferredSize=function(target){return pkg.getPreferredSize(this.scrollObj)};this.doLayout=function(target){var sman=(this.scrollObj==null)?null:this.scrollObj.scrollManager,right=this.getRight(),top=this.getTop(),bottom=this.getBottom(),left=this.getLeft(),ww=this.width-left-right,maxH=ww,hh=this.height-top-bottom,maxV=hh,so=this.scrollObj.getPreferredSize(),vps=this.vBar==null?{width:0,height:0}:this.vBar.getPreferredSize(),hps=this.hBar==null?{width:0,height:0}:this.hBar.getPreferredSize();if(this.hBar!=null&&this.autoHide===false&&(so.width>ww||(so.height>hh&&so.width>(ww-vps.width)))){maxV-=hps.height}maxV=so.height>maxV?(so.height-maxV):-1;if(this.vBar!=null&&this.autoHide===false&&(so.height>hh||(so.width>ww&&so.height>(hh-hps.height)))){maxH-=vps.width}maxH=so.width>maxH?(so.width-maxH):-1;var sy=sman.getSY(),sx=sman.getSX();if(this.vBar!=null){if(maxV<0){if(this.vBar.isVisible===true){this.vBar.setVisible(false);sman.scrollTo(sx,0);this.vBar.position.setOffset(0)}sy=0}else{this.vBar.setVisible(true)}}if(this.hBar!=null){if(maxH<0){if(this.hBar.isVisible===true){this.hBar.setVisible(false);sman.scrollTo(0,sy);this.hBar.position.setOffset(0)}}else{this.hBar.setVisible(true)}}if(this.scrollObj.isVisible===true){this.scrollObj.setLocation(left,top);this.scrollObj.setSize(ww-(this.autoHide===false&&this.vBar!=null&&this.vBar.isVisible===true?vps.width:0),hh-(this.autoHide===false&&this.hBar!=null&&this.hBar.isVisible===true?hps.height:0))}if(this.$interval===0&&this.autoHide){hps.height=vps.width=0}if(this.hBar!=null&&this.hBar.isVisible===true){this.hBar.setLocation(left,this.height-bottom-hps.height);this.hBar.setSize(ww-(this.vBar!=null&&this.vBar.isVisible===true?vps.width:0),hps.height);this.hBar.setMaximum(maxH)}if(this.vBar!=null&&this.vBar.isVisible===true){this.vBar.setLocation(this.width-right-vps.width,top);this.vBar.setSize(vps.width,hh-(this.hBar!=null&&this.hBar.isVisible===true?hps.height:0));this.vBar.setMaximum(maxV)}};this.posChanged=function(target,prevOffset,prevLine,prevCol){if(this.isPosChangedLocked===false){if(this.autoHide){this.$dontHide=true;if(this.$interval===0&&((this.vBar!=null&&this.vBar.isVisible===true)||(this.hBar!=null&&this.hBar.isVisible===true))){var $this=this;if(this.vBar){this.vBar.toFront()}if(this.hBar){this.hBar.toFront()}this.vrp();this.$interval=setInterval(function(){if($this.$dontHide||($this.vBar!=null&&pkg.$mouseMoveOwner==$this.vBar)||($this.hBar!=null&&pkg.$mouseMoveOwner==$this.hBar)){$this.$dontHide=false}else{clearInterval($this.$interval);$this.$interval=0;$this.doLayout()}},500)}}if(this.vBar!=null&&this.vBar.position==target){this.scrollObj.scrollManager.scrollYTo(-this.vBar.position.offset)}else{if(this.hBar!=null){this.scrollObj.scrollManager.scrollXTo(-this.hBar.position.offset)}}}};this.setIncrements=function(hUnit,hPage,vUnit,vPage){if(this.hBar!=null){if(hUnit!=-1){this.hBar.unitIncrement=hUnit}if(hPage!=-1){this.hBar.pageIncrement=hPage}}if(this.vBar!=null){if(vUnit!=-1){this.vBar.unitIncrement=vUnit}if(vPage!=-1){this.vBar.pageIncrement=vPage}}}},function(){this.$this(null,L.HORIZONTAL|L.VERTICAL)},function(c){this.$this(c,L.HORIZONTAL|L.VERTICAL)},function(c,barMask){this.hBar=this.vBar=this.scrollObj=null;this.isPosChangedLocked=false;this.$super();if((L.HORIZONTAL&barMask)>0){this.add(L.BOTTOM,new pkg.Scroll(L.HORIZONTAL))}if((L.VERTICAL&barMask)>0){this.add(L.RIGHT,new pkg.Scroll(L.VERTICAL))}if(c!=null){this.add(L.CENTER,c)}},function insert(i,ctr,c){if(L.CENTER==ctr&&c.scrollManager==null){c=new this.$clazz.ContentPan(c)}return this.$super(i,ctr,c)},function kidAdded(index,id,comp){this.$super(index,id,comp);if(L.CENTER==id){this.scrollObj=comp;this.scrollObj.scrollManager.bind(this);return}if(L.BOTTOM==id||L.TOP==id){this.hBar=comp}else{if(L.LEFT==id||L.RIGHT==id){this.vBar=comp}else{return}}if(comp.incBt!=null){comp.incBt.setVisible(!this.autoHide)}if(comp.decBt!=null){comp.decBt.setVisible(!this.autoHide)}comp.position.bind(this)},function kidRemoved(index,comp){this.$super(index,comp);if(comp==this.scrollObj){this.scrollObj.scrollManager.unbind(this);this.scrollObj=null}else{if(comp==this.hBar){this.hBar.position.unbind(this);this.hBar=null}else{if(comp==this.vBar){this.vBar.position.unbind(this);this.vBar=null}}}}]);pkg.Tabs=Class(pkg.Panel,[function $clazz(){this.TabView=Class(pkg.CompRender,[function $clazz(){this.TabPan=Class(pkg.Panel,[function(){this.$super();this.add(new pkg.ImagePan(null));this.add(new pkg.ViewPan())},function getImagePan(){return this.kids[0]},function getViewPan(){return this.kids[1]}])},function(){this.$this("")},function(caption){this.$this(null,caption)},function(icon,caption){var tp=new this.$clazz.TabPan();this.$super(tp);this.owner=null;var $this=this;tp.getImagePan().imageLoaded=function(p,b,i){$this.vrp();if($this.owner!=null&&$this.owner.parent!=null){$this.owner.repaint()}};var r1=new this.$clazz.captionRender(caption),r2=new this.$clazz.captionRender(caption);r2.setColor(this.$clazz.fontColor);r1.setColor(this.$clazz.selectedFontColor);r2.setFont(this.$clazz.font);r1.setFont(this.$clazz.selectedFont);this.getCaptionPan().setView(new pkg.ViewSet({selected:r1,"*":r2},[function setFont(id,f){var v=this.views[id];if(v!=null){v.setFont(s);this.recalc()}},function setCaption(id,s){var v=this.views[id];if(v!=null){v.setValue(s);this.recalc()}},function getCaption(id){var v=this.views[id];return v==null?null:v.getValue()}]))},function ownerChanged(v){this.owner=v},function vrp(){if(this.owner!=null){this.owner.vrp()}},function setCaption(s){this.setCaption(true,s);this.setCaption(false,s)},function setCaption(b,s){this.getCaptionPan().view.setCaption(this.$toId(b),s);this.vrp()},function getCaption(b){this.getCaptionPan().view.getCaption(this.$toId(b))},function setColor(c){setColor(true,c);setColor(false,c)},function setColor(b,c){var v=this.getCaptionPan().view.views[this.$toId(b)];if(v!=null){v.setColor(c);this.vrp()}},function setFont(f){setFont(true,f);setFont(false,f)},function setFont(b,f){this.getCaptionPan().view.setFont(this.$toId(b),f);this.vrp()},function getCaptionPan(){return this.target.getViewPan()},function setIcon(c){this.target.getImagePan().setImage(c)},function selected(tabs,i,b){this.getCaptionPan().view.activate(this.$toId(b))},function $toId(b){return b?"selected":"*"}])},function $prototype(){this.canHaveFocus=true;this.sideOffset=0;this.mouseMoved=function(e){var i=this.getTabAt(e.x,e.y);if(this.overTab!=i){this.overTab=i;if(this.views.tabover!=null){this.repaint(this.repaintX,this.repaintY,this.repaintWidth,this.repaintHeight)}}};this.mouseDragEnded=function(e){var i=this.getTabAt(e.x,e.y);if(this.overTab!=i){this.overTab=i;if(this.views.tabover!=null){this.repaint(this.repaintX,this.repaintY,this.repaintWidth,this.repaintHeight)}}};this.mouseExited=function(e){if(this.overTab>=0){this.overTab=-1;if(this.views.tabover!=null){this.repaint(this.repaintX,this.repaintY,this.repaintWidth,this.repaintHeight)}}};this.next=function(page,d){for(;page>=0&&page<~~(this.pages.length/2);page+=d){if(this.isTabEnabled(page)===true){return page}}return -1};this.getTitleInfo=function(){var b=(this.orient==L.LEFT||this.orient==L.RIGHT),res=b?{x:this.tabAreaX,y:0,width:this.tabAreaWidth,height:0,orient:this.orient}:{x:0,y:this.tabAreaY,width:0,height:this.tabAreaHeight,orient:this.orient};if(this.selectedIndex>=0){var r=this.getTabBounds(this.selectedIndex);if(b){res.y=r.y;res.height=r.height}else{res.x=r.x;res.width=r.width}}return res};this.isTabEnabled=function(index){return this.kids[index].isEnabled};this.paintOnTop=function(g){var ts=g.stack[g.counter];if(zebra.util.isIntersect(this.repaintX,this.repaintY,this.repaintWidth,this.repaintHeight,ts.x,ts.y,ts.width,ts.height)){if(this.selectedIndex>0){var r=this.getTabBounds(this.selectedIndex)}for(var i=0;i<this.selectedIndex;i++){this.paintTab(g,i)}for(var i=this.selectedIndex+1;i<~~(this.pages.length/2);i++){this.paintTab(g,i)}if(this.selectedIndex>=0){this.paintTab(g,this.selectedIndex);if(this.hasFocus()){this.drawMarker(g,this.getTabBounds(this.selectedIndex))}}}};this.drawMarker=function(g,r){var marker=this.views.marker;if(marker!=null){var bv=this.views.tab;marker.paint(g,r.x+bv.getLeft(),r.y+bv.getTop(),r.width-bv.getLeft()-bv.getRight(),r.height-bv.getTop()-bv.getBottom(),this)}};this.paintTab=function(g,pageIndex){var b=this.getTabBounds(pageIndex),page=this.kids[pageIndex],tab=this.views.tab,tabover=this.views.tabover,tabon=this.views.tabon;if(this.selectedIndex==pageIndex&&tabon!=null){tabon.paint(g,b.x,b.y,b.width,b.height,page)}else{tab.paint(g,b.x,b.y,b.width,b.height,page)}if(this.overTab>=0&&this.overTab==pageIndex&&tabover!=null){tabover.paint(g,b.x,b.y,b.width,b.height,page)}var v=this.pages[pageIndex*2],ps=v.getPreferredSize(),px=b.x+L.xAlignment(ps.width,L.CENTER,b.width),py=b.y+L.yAlignment(ps.height,L.CENTER,b.height);v.paint(g,px,py,ps.width,ps.height,page)};this.getTabBounds=function(i){return this.pages[2*i+1]};this.calcPreferredSize=function(target){var max=L.getMaxPreferredSize(target);if(this.orient==L.BOTTOM||this.orient==L.TOP){max.width=Math.max(max.width,2*this.sideSpace+this.tabAreaWidth);max.height+=this.tabAreaHeight+this.sideSpace}else{max.width+=this.tabAreaWidth+this.sideSpace;max.height=Math.max(max.height,2*this.sideSpace+this.tabAreaHeight)}return max};this.doLayout=function(target){var right=this.orient==L.RIGHT?this.right:this.getRight(),top=this.orient==L.TOP?this.top:this.getTop(),bottom=this.orient==L.BOTTOM?this.bottom:this.getBottom(),left=this.orient==L.LEFT?this.left:this.getLeft(),b=(this.orient==L.TOP||this.orient==L.BOTTOM);if(b){this.repaintX=this.tabAreaX=left+this.sideOffset;this.repaintY=this.tabAreaY=(this.orient==L.TOP)?top:this.height-bottom-this.tabAreaHeight;if(this.orient==L.BOTTOM){this.repaintY-=this.border.getBottom()}}else{this.repaintX=this.tabAreaX=(this.orient==L.LEFT?left:this.width-right-this.tabAreaWidth);this.repaintY=this.tabAreaY=top+this.sideOffset;if(this.orient==L.RIGHT){this.repaintX-=this.border.getRight()}}var count=~~(this.pages.length/2),sp=2*this.sideSpace,xx=(this.orient==L.RIGHT?this.tabAreaX:this.tabAreaX+this.sideSpace),yy=(this.orient==L.BOTTOM?this.tabAreaY:this.tabAreaY+this.sideSpace);for(var i=0;i<count;i++){var r=this.getTabBounds(i);r.x=xx;r.y=yy;if(b){xx+=r.width;if(i==this.selectedIndex){xx-=sp;if(this.orient==L.BOTTOM){r.y-=this.border.getBottom()}}}else{yy+=r.height;if(i==this.selectedIndex){yy-=sp;if(this.orient==L.RIGHT){r.x-=this.border.getRight()}}}}if(this.selectedIndex>=0){var r=this.getTabBounds(this.selectedIndex),dt=0;if(b){r.x-=this.sideSpace;r.y-=((this.orient==L.TOP)?this.sideSpace:0);dt=(r.x<left)?left-r.x:(r.x+r.width>this.width-right)?this.width-right-r.x-r.width:0}else{r.x-=(this.orient==L.LEFT)?this.sideSpace:0;r.y-=this.sideSpace;dt=(r.y<top)?top-r.y:(r.y+r.height>this.height-bottom)?this.height-bottom-r.y-r.height:0}for(var i=0;i<count;i++){var br=this.getTabBounds(i);if(b){br.x+=dt}else{br.y+=dt}}}for(var i=0;i<count;i++){var l=this.kids[i];if(i===this.selectedIndex){if(b){l.setSize(this.width-left-right-2*this.hgap,this.height-this.repaintHeight-top-bottom-2*this.vgap);l.setLocation(left+this.hgap,((this.orient==L.TOP)?top+this.repaintHeight:top)+this.vgap)}else{l.setSize(this.width-this.repaintWidth-left-right-2*this.hgap,this.height-top-bottom-2*this.vgap);l.setLocation(((this.orient==L.LEFT)?left+this.repaintWidth:left)+this.hgap,top+this.vgap)}}else{l.setSize(0,0)}}};this.recalc=function(){var count=~~(this.pages.length/2);if(count>0){this.tabAreaHeight=this.tabAreaWidth=0;var bv=this.views.tab,b=(this.orient==L.LEFT||this.orient==L.RIGHT),max=0,hadd=bv.getLeft()+bv.getRight(),vadd=bv.getTop()+bv.getBottom();for(var i=0;i<count;i++){var ps=this.pages[i*2]!=null?this.pages[i*2].getPreferredSize():{width:0,height:0},r=this.getTabBounds(i);if(b){r.height=ps.height+vadd;if(ps.width+hadd>max){max=ps.width+hadd}this.tabAreaHeight+=r.height}else{r.width=ps.width+hadd;if(ps.height+vadd>max){max=ps.height+vadd}this.tabAreaWidth+=r.width}}for(var i=0;i<count;i++){var r=this.getTabBounds(i);if(b){r.width=max}else{r.height=max}}if(b){this.tabAreaWidth=max+this.sideSpace;this.tabAreaHeight+=(2*this.sideSpace);this.repaintHeight=this.tabAreaHeight;this.repaintWidth=this.tabAreaWidth+(b==L.LEFT?this.border.getLeft():this.border.getRight())}else{this.tabAreaWidth+=(2*this.sideSpace);this.tabAreaHeight=this.sideSpace+max;this.repaintWidth=this.tabAreaWidth;this.repaintHeight=this.tabAreaHeight+(b==L.TOP?this.border.getTop():this.border.getBottom())}if(this.selectedIndex>=0){var r=this.getTabBounds(this.selectedIndex);if(b){r.height+=2*this.sideSpace;r.width+=this.sideSpace+(b==L.LEFT?this.border.getLeft():this.border.getRight())}else{r.height+=this.sideSpace+(b==L.TOP?this.border.getTop():this.border.getBottom());r.width+=2*this.sideSpace}}}};this.getTabAt=function(x,y){this.validate();if(x>=this.tabAreaX&&y>=this.tabAreaY&&x<this.tabAreaX+this.tabAreaWidth&&y<this.tabAreaY+this.tabAreaHeight){if(this.selectedIndex>=0){var tb=this.getTabBounds(this.selectedIndex);if(x>=tb.x&&y>=tb.y&&x<tb.x+tb.width&&y<tb.y+tb.height){return i}}for(var i=0;i<~~(this.pages.length/2);i++){if(this.selectedIndex!=i){var tb=this.getTabBounds(i);if(x>=tb.x&&y>=tb.y&&x<tb.x+tb.width&&y<tb.y+tb.height){return i}}}}return -1};this.keyPressed=function(e){if(this.selectedIndex!=-1&&this.pages.length>0){switch(e.code){case KE.UP:case KE.LEFT:var nxt=this.next(this.selectedIndex-1,-1);if(nxt>=0){this.select(nxt)}break;case KE.DOWN:case KE.RIGHT:var nxt=this.next(this.selectedIndex+1,1);if(nxt>=0){this.select(nxt)}break}}};this.mouseClicked=function(e){if(e.isActionMask()){var index=this.getTabAt(e.x,e.y);if(index>=0&&this.isTabEnabled(index)){this.select(index)}}};this.select=function(index){if(this.selectedIndex!=index){var prev=this.selectedIndex;this.selectedIndex=index;if(prev>=0){this.pages[prev*2].selected(this,prev,false)}if(index>=0){this.pages[index*2].selected(this,index,true)}this._.fired(this,this.selectedIndex);this.vrp()}};this.getTab=function(pageIndex){return this.pages[pageIndex*2]};this.setSideSpace=function(sideSpace){if(sideSpace!=this.sideSpace){this.sideSpace=sideSpace;this.vrp()}};this.setPageGaps=function(vg,hg){if(this.vgap!=vg||hg!=this.hgap){this.vgap=vg;this.hgap=hg;this.vrp()}};this.setAlignment=function(o){o=L.$constraints(o);if(o!=L.TOP&&o!=L.BOTTOM&&o!=L.LEFT&&o!=L.RIGHT){throw new Error($invalidA)}if(this.orient!=o){this.orient=o;this.vrp()}};this.enableTab=function(i,b){var c=this.kids[i];if(c.isEnabled!=b){c.setEnabled(b);if(b===false&&this.selectedIndex==i){this.select(-1)}this.repaint()}}},function(){this.$this(L.TOP)},function(o){this.vgap=this.hgap=this.tabAreaX=0;this.repaintWidth=this.repaintHeight=this.repaintX=this.repaintY=0;this.sideSpace=1;this.tabAreaY=this.tabAreaWidth=this.tabAreaHeight=0;this.overTab=this.selectedIndex=-1;this.orient=L.$constraints(o);this._=new Listeners();this.pages=[];this.views={};if(pkg.Tabs.font!=null){this.render.setFont(pkg.Tabs.font)}if(pkg.Tabs.fontColor!=null){this.render.setColor(pkg.Tabs.fontColor)}this.$super();this.setAlignment(o)},function focused(){this.$super();if(this.selectedIndex>=0){var r=this.getTabBounds(this.selectedIndex);this.repaint(r.x,r.y,r.width,r.height)}else{if(this.hasFocus()===false){this.select(this.next(0,1))}}},function insert(index,constr,c){var render=null;if(instanceOf(constr,this.$clazz.TabView)){render=constr}else{render=new this.$clazz.TabView((constr==null?"Page "+index:constr));render.ownerChanged(this)}this.pages.splice(index*2,0,render,{x:0,y:0,width:0,height:0});var r=this.$super(index,constr,c);if(this.selectedIndex<0){this.select(this.next(0,1))}return r},function removeAt(i){if(this.selectedIndex==i){this.select(-1)}this.pages.splice(i*2,2);this.$super(i)},function removeAll(){if(this.selectedIndex>=0){this.select(-1)}this.pages.splice(0,this.pages.length);this.pages.length=0;this.$super()},function setSize(w,h){if(this.width!=w||this.height!=h){if(this.orient==L.RIGHT||this.orient==L.BOTTOM){this.tabAreaX=-1}this.$super(w,h)}}]);pkg.Tabs.prototype.setViews=pkg.$ViewsSetter;pkg.Slider=Class(pkg.Panel,[function $prototype(){this.max=this.min=this.value=this.roughStep=this.exactStep=0;this.netSize=this.gap=3;this.correctDt=this.scaleStep=this.psW=this.psH=0;this.intervals=this.pl=null;this.canHaveFocus=true;this.paintNums=function(g,loc){if(this.isShowTitle){for(var i=0;i<this.pl.length;i++){var render=this.provider.getView(this,this.getPointValue(i)),d=render.getPreferredSize();if(this.orient==L.HORIZONTAL){render.paint(g,this.pl[i]-~~(d.width/2),loc,d.width,d.height,this)}else{render.paint(g,loc,this.pl[i]-~~(d.height/2),d.width,d.height,this)}}}};this.getScaleSize=function(){var bs=this.views.bundle.getPreferredSize();return(this.orient==L.HORIZONTAL?this.width-this.getLeft()-this.getRight()-bs.width:this.height-this.getTop()-this.getBottom()-bs.height)-2};this.getScaleLocation=function(){var bs=this.views.bundle.getPreferredSize();return(this.orient==L.HORIZONTAL?this.getLeft()+~~(bs.width/2):this.getTop()+~~(bs.height/2))+1};this.mouseDragged=function(e){if(this.dragged){this.setValue(this.findNearest(e.x+(this.orient==L.HORIZONTAL?this.correctDt:0),e.y+(this.orient==L.HORIZONTAL?0:this.correctDt)))}};this.paint=function(g){if(this.pl==null){this.pl=Array(this.intervals.length);for(var i=0,l=this.min;i<this.pl.length;i++){l+=this.intervals[i];this.pl[i]=this.value2loc(l)}}var left=this.getLeft(),top=this.getTop(),right=this.getRight(),bottom=this.getBottom(),bnv=this.views.bundle,gauge=this.views.gauge,bs=bnv.getPreferredSize(),gs=gauge.getPreferredSize(),w=this.width-left-right-2,h=this.height-top-bottom-2;if(this.orient==L.HORIZONTAL){var topY=top+~~((h-this.psH)/2)+1,by=topY;if(this.isEnabled===true){gauge.paint(g,left+1,topY+~~((bs.height-gs.height)/2),w,gs.height,this)}else{g.setColor("gray");g.strokeRect(left+1,topY+~~((bs.height-gs.height)/2),w,gs.height)}topY+=bs.height;if(this.isShowScale){topY+=this.gap;g.setColor(this.isEnabled===true?this.scaleColor:"gray");g.beginPath();for(var i=this.min;i<=this.max;i+=this.scaleStep){var xx=this.value2loc(i)+0.5;g.moveTo(xx,topY);g.lineTo(xx,topY+this.netSize)}for(var i=0;i<this.pl.length;i++){g.moveTo(this.pl[i]+0.5,topY);g.lineTo(this.pl[i]+0.5,topY+2*this.netSize)}g.stroke();topY+=(2*this.netSize)}this.paintNums(g,topY);bnv.paint(g,this.getBundleLoc(this.value),by,bs.width,bs.height,this)}else{var leftX=left+~~((w-this.psW)/2)+1,bx=leftX;if(this.isEnabled===true){gauge.paint(g,leftX+~~((bs.width-gs.width)/2),top+1,gs.width,h,this)}else{g.setColor("gray");g.strokeRect(leftX+~~((bs.width-gs.width)/2),top+1,gs.width,h)}leftX+=bs.width;if(this.isShowScale){leftX+=this.gap;g.setColor(this.scaleColor);g.beginPath();for(var i=this.min;i<=this.max;i+=this.scaleStep){var yy=this.value2loc(i)+0.5;g.moveTo(leftX,yy);g.lineTo(leftX+this.netSize,yy)}for(var i=0;i<this.pl.length;i++){g.moveTo(leftX,this.pl[i]+0.5);g.lineTo(leftX+2*this.netSize,this.pl[i]+0.5)}g.stroke();leftX+=(2*this.netSize)}this.paintNums(g,leftX);bnv.paint(g,bx,this.getBundleLoc(this.value),bs.width,bs.height,this)}if(this.hasFocus()&&this.views.marker){this.views.marker.paint(g,left,top,w+2,h+2,this)}};this.findNearest=function(x,y){var v=this.loc2value(this.orient==L.HORIZONTAL?x:y);if(this.isIntervalMode){var nearest=Number.MAX_VALUE,res=0;for(var i=0;i<this.intervals.length;i++){var pv=this.getPointValue(i),dt=Math.abs(pv-v);if(dt<nearest){nearest=dt;res=pv}}return res}v=this.exactStep*~~((v+v%this.exactStep)/this.exactStep);if(v>this.max){v=this.max}else{if(v<this.min){v=this.min}}return v};this.value2loc=function(v){return ~~((this.getScaleSize()*(v-this.min))/(this.max-this.min))+this.getScaleLocation()};this.loc2value=function(xy){var sl=this.getScaleLocation(),ss=this.getScaleSize();if(xy<sl){xy=sl}else{if(xy>sl+ss){xy=sl+ss}}return this.min+~~(((this.max-this.min)*(xy-sl))/ss)};this.nextValue=function(value,s,d){if(this.isIntervalMode){return this.getNeighborPoint(value,d)}var v=value+(d*s);if(v>this.max){v=this.max}else{if(v<this.min){v=this.min}}return v};this.getBundleLoc=function(v){var bs=this.views.bundle.getPreferredSize();return this.value2loc(v)-(this.orient==L.HORIZONTAL?~~(bs.width/2):~~(bs.height/2))};this.getBundleBounds=function(v){var bs=this.views.bundle.getPreferredSize();return this.orient==L.HORIZONTAL?{x:this.getBundleLoc(v),y:this.getTop()+~~((this.height-this.getTop()-this.getBottom()-this.psH)/2)+1,width:bs.width,height:bs.height}:{x:this.getLeft()+~~((this.width-this.getLeft()-this.getRight()-this.psW)/2)+1,y:this.getBundleLoc(v),width:bs.width,height:bs.height}};this.getNeighborPoint=function(v,d){var left=this.min+this.intervals[0],right=this.getPointValue(this.intervals.length-1);if(v<left){return left}else{if(v>right){return right}}if(d>0){var start=this.min;for(var i=0;i<this.intervals.length;i++){start+=this.intervals[i];if(start>v){return start}}return right}else{var start=right;for(var i=this.intervals.length-1;i>=0;i--){if(start<v){return start}start-=this.intervals[i]}return left}};this.calcPreferredSize=function(l){return{width:this.psW+2,height:this.psH+2}};this.recalc=function(){var ps=this.views.bundle.getPreferredSize(),ns=this.isShowScale?(this.gap+2*this.netSize):0,dt=this.max-this.min,hMax=0,wMax=0;if(this.isShowTitle&&this.intervals.length>0){for(var i=0;i<this.intervals.length;i++){var d=this.provider.getView(this,this.getPointValue(i)).getPreferredSize();if(d.height>hMax){hMax=d.height}if(d.width>wMax){wMax=d.width}}}if(this.orient==L.HORIZONTAL){this.psW=dt*2+ps.width;this.psH=ps.height+ns+hMax}else{this.psW=ps.width+ns+wMax;this.psH=dt*2+ps.height}};this.setValue=function(v){if(v<this.min||v>this.max){throw new Error("Value is out of bounds: "+v)}var prev=this.value;if(this.value!=v){this.value=v;this._.fired(this,prev);this.repaint()}};this.getPointValue=function(i){var v=this.min+this.intervals[0];for(var j=0;j<i;j++,v+=this.intervals[j]){}return v};this.keyPressed=function(e){var b=this.isIntervalMode;switch(e.code){case KE.UP:case KE.LEFT:var v=this.nextValue(this.value,this.exactStep,-1);if(v>=this.min){this.setValue(v)}break;case KE.DOWN:case KE.RIGHT:var v=this.nextValue(this.value,this.exactStep,1);if(v<=this.max){this.setValue(v)}break;case KE.HOME:this.setValue(b?this.getPointValue(0):this.min);break;case KE.END:this.setValue(b?this.getPointValue(this.intervals.length-1):this.max);break}};this.mousePressed=function(e){if(e.isActionMask()){var x=e.x,y=e.y,bb=this.getBundleBounds(this.value);if(x<bb.x||y<bb.y||x>=bb.x+bb.width||y>=bb.y+bb.height){var l=((this.orient==L.HORIZONTAL)?x:y),v=this.loc2value(l);if(this.value!=v){this.setValue(this.isJumpOnPress?v:this.nextValue(this.value,this.roughStep,v<this.value?-1:1))}}}};this.mouseDragStarted=function(e){var r=this.getBundleBounds(this.value);if(e.x>=r.x&&e.y>=r.y&&e.x<r.x+r.width&&e.y<r.y+r.height){this.dragged=true;this.correctDt=this.orient==L.HORIZONTAL?r.x+~~(r.width/2)-e.x:r.y+~~(r.height/2)-e.y}};this.mouseDragEnded=function(e){this.dragged=false};this.getView=function(d,o){this.render.setValue(o!=null?o.toString():"");return this.render}},function(){this.$this(L.HORIZONTAL)},function(o){this._=new Listeners();this.views={};this.isShowScale=this.isShowTitle=true;this.dragged=this.isIntervalMode=false;this.render=new pkg.BoldTextRender("");this.render.setColor("gray");this.orient=L.$constraints(o);this.setValues(0,20,[0,5,10],2,1);this.setScaleStep(1);this.$super();this.views.bundle=(o==L.HORIZONTAL?this.views.hbundle:this.views.vbundle);this.provider=this},function focused(){this.$super();this.repaint()},function setScaleGap(g){if(g!=this.gap){this.gap=g;this.vrp()}},function setScaleColor(c){if(c!=this.scaleColor){this.scaleColor=c;if(this.provider==this){this.render.setColor(c)}this.repaint()}return this},function setScaleStep(s){if(s!=this.scaleStep){this.scaleStep=s;this.repaint()}},function setShowScale(b){if(this.isShowScale!=b){this.isShowScale=b;this.vrp()}},function setShowTitle(b){if(this.isShowTitle!=b){this.isShowTitle=b;this.vrp()}},function setViewProvider(p){if(p!=this.provider){this.provider=p;this.vrp()}},function setValues(min,max,intervals,roughStep,exactStep){if(roughStep<=0||exactStep<0||min>=max||min+roughStep>max||min+exactStep>max){throw new Error("Invalid values")}for(var i=0,start=min;i<intervals.length;i++){start+=intervals[i];if(start>max||intervals[i]<0){throw new Error()}}this.min=min;this.max=max;this.roughStep=roughStep;this.exactStep=exactStep;this.intervals=Array(intervals.length);for(var i=0;i<intervals.length;i++){this.intervals[i]=intervals[i]}if(this.value<min||this.value>max){this.setValue(this.isIntervalMode?min+intervals[0]:min)}this.vrp()},function invalidate(){this.pl=null;this.$super()}]);pkg.Slider.prototype.setViews=pkg.$ViewsSetter;pkg.StatusBar=Class(pkg.Panel,[function(){this.$this(2)},function(gap){this.setPadding(gap,0,0,0);this.$super(new L.PercentLayout(Layout.HORIZONTAL,gap))},function setBorderView(v){if(v!=this.borderView){this.borderView=v;for(var i=0;i<this.kids.length;i++){this.kids[i].setBorder(this.borderView)}this.repaint()}},function insert(i,s,d){d.setBorder(this.borderView);this.$super(i,s,d)}]);pkg.Toolbar=Class(pkg.Panel,[function $clazz(){this.ToolPan=Class(pkg.EvStatePan,[function(c){this.$super(new L.BorderLayout());this.add(L.CENTER,c)},function stateUpdated(o,n){this.$super(o,n);if(o==PRESSED_OVER&&n==OVER){this.parent._.fired(this.kids[0])}}]);this.ImagePan=Class(pkg.ImagePan,[]);this.Line=Class(pkg.Line,[]);this.Checkbox=Class(pkg.Checkbox,[]);this.Radiobox=Class(pkg.Radiobox,[])},function $prototype(){this.isDecorative=function(c){return instanceOf(c,pkg.EvStatePan)===false}},function(){this._=new Listeners();this.$super()},function addRadio(g,c){var cbox=new this.$clazz.Radiobox(c,g);cbox.setCanHaveFocus(false);return this.add(cbox)},function addSwitcher(c){return this.add(new this.$clazz.Checkbox(c))},function addImage(img){this.validateMetric();return this.add(new this.$clazz.ImagePan(img))},function addLine(){var line=new this.$clazz.Line();line.constraints=L.STRETCH;return this.addDecorative(line)},function addDecorative(c){return this.$super(this.insert,this.kids.length,null,c)},function insert(i,id,d){return this.$super(i,id,new this.$clazz.ToolPan(d))}]);pkg.VideoPan=Class(pkg.Panel,[function $prototype(){this.paint=function(g){g.drawImage(this.video,0,0,this.width,this.height)};this.pause=function(){if(this.isPlaying===true){this.isPlaying=false;this.video.pause()}};this.play=function(){if(this.isPlaying===false){this.isPlaying=true;this.video.play();var $this=this;window.requestAFrame(function anim(){if($this.isReady===true){$this.repaint()}if($this.isPlaying===true){window.requestAFrame(anim)}})}}},function(src){this.isPlaying=false;this.isReady=false;var $this=this;this.video=document.createElement("video");this.video.setAttribute("src",src);this.video.addEventListener("canplaythrough",function(){$this.isReady=true},false);this.video.addEventListener("ended",function(){$this.isPlaying=false;if($this.finished!=null){$this.finished()}},false);this.$super()}]);pkg.ArrowView=Class(View,[function $prototype(){this[""]=function(d,col,w){this.direction=d==null?L.BOTTOM:L.$constraints(d);this.color=col==null?"black":col;this.width=this.height=(w==null?6:w)};this.paint=function(g,x,y,w,h,d){var s=Math.min(w,h);x=x+(w-s)/2;y=y+(h-s)/2;g.setColor(this.color);g.beginPath();if(L.BOTTOM==this.direction){g.moveTo(x,y);g.lineTo(x+s,y);g.lineTo(x+s/2,y+s);g.lineTo(x,y)}else{if(L.TOP==this.direction){g.moveTo(x,y+s);g.lineTo(x+s,y+s);g.lineTo(x+s/2,y);g.lineTo(x,y+s)}else{if(L.LEFT==this.direction){g.moveTo(x+s,y);g.lineTo(x+s,y+s);g.lineTo(x,y+s/2);g.lineTo(x+s,y)}else{g.moveTo(x,y);g.lineTo(x,y+s);g.lineTo(x+s,y+s/2);g.lineTo(x,y)}}}g.fill()};this.getPreferredSize=function(){return{width:this.width,height:this.height}}}]);pkg.CheckboxView=Class(View,[function $prototype(){this[""]=function(color){this.color=(color!=null?color:"rgb(65, 131, 255)")};this.paint=function(g,x,y,w,h,d){g.beginPath();g.strokeStyle=this.color;g.lineWidth=2;g.moveTo(x+1,y+2);g.lineTo(x+w-3,y+h-3);g.stroke();g.beginPath();g.moveTo(x+w-2,y+2);g.lineTo(x+2,y+h-2);g.stroke();g.lineWidth=1}}]);pkg.BunldeView=Class(View,[function $prototype(){this[""]=function(dir,color){this.color=(color!=null?color:"#AAAAAA");this.direction=(dir!=null?L.$constraints(dir):L.VERTICAL)};this.paint=function(g,x,y,w,h,d){g.beginPath();if(this.direction==L.VERTICAL){var r=w/2;g.arc(x+r,y+r,r,Math.PI,0,false);g.lineTo(x+w,y+h-r);g.arc(x+r,y+h-r,r,0,Math.PI,false);g.lineTo(x,y+r)}else{var r=h/2;g.arc(x+r,y+r,r,0.5*Math.PI,1.5*Math.PI,false);g.lineTo(x+w-r,y);g.arc(x+w-r,y+h-r,r,1.5*Math.PI,0.5*Math.PI,false);g.lineTo(x+r,y+h)}g.setColor(this.color);g.fill()}}]);pkg.RadioView=Class(View,[function(){this.$this("rgb(15, 81, 205)","rgb(65, 131, 255)")},function(col1,col2){this.color1=col1;this.color2=col2},function $prototype(){this.paint=function(g,x,y,w,h,d){g.beginPath();g.fillStyle=this.color1;g.arc(~~(x+w/2),~~(y+h/2),~~(w/3-0.5),0,2*Math.PI,1,false);g.fill();g.beginPath();g.fillStyle=this.color2;g.arc(~~(x+w/2),~~(y+h/2),~~(w/4-0.5),0,2*Math.PI,1,false);g.fill()}}]);pkg.MobileScrollMan=Class(pkg.Manager,[function $prototype(){this.sx=this.sy=0;this.target=null;this.identifier=-1;this.mouseDragStarted=function(e){if(e.touchCounter==1){this.identifier=e.touch.identifier;var owner=e.source;while(owner!=null&&instanceOf(owner,pkg.ScrollPan)===false){owner=owner.parent}if(owner!=null&&owner.mouseDragged==null){this.target=owner;this.sx=e.x;this.sy=e.y}}};this.mouseDragged=function(e){if(e.touchCounter==1&&this.target!=null&&this.identifier==e.touch.identifier){var d=e.touch.direction;if(d==L.BOTTOM||d==L.TOP){if(this.target.vBar!=null&&this.target.vBar.isVisible===true){var bar=this.target.vBar;bar.position.setOffset(bar.position.offset-e.y+this.sy)}}else{if(d==L.LEFT||d==L.RIGHT){if(this.target.hBar!=null&&this.target.hBar.isVisible===true){var bar=this.target.hBar;bar.position.setOffset(bar.position.offset-e.x+this.sx)}}}this.sx=e.x;this.sy=e.y}};this.mouseDragEnded=function(e){if(this.target!=null&&this.timer==null&&this.identifier==e.touch.identifier&&(e.touch.direction==L.BOTTOM||e.touch.direction==L.TOP)&&this.target.vBar!=null&&this.target.vBar.isVisible===true&&e.touch.dy!=0){this.$dt=2*e.touch.dy;var $this=this,bar=this.target.vBar,k=0;this.timer=setInterval(function(){var o=bar.position.offset;bar.position.setOffset(o-$this.$dt);if(++k%5===0){$this.$dt=~~($this.$dt/2)}if(o==bar.position.offset||($this.$dt>=-1&&$this.$dt<=1)){clearInterval($this.timer);$this.timer=$this.target=null}},10)}};this.mousePressed=function(e){if(this.timer!=null){clearInterval(this.timer);this.timer=null}this.target=null}}])})(zebra("ui"),zebra.Class);(function(pkg,Class){var ME=pkg.MouseEvent,KE=pkg.KeyEvent,PO=zebra.util.Position;pkg.TextField=Class(pkg.Label,pkg.CopyCutPaste,[function $clazz(){this.TextPosition=Class(PO,[function(render){this.$super(render);render.target.bind(this)},function $prototype(){this.textUpdated=function(src,b,off,size,startLine,lines){if(b===true){this.inserted(off,size)}else{this.removed(off,size)}}},function destroy(){this.metrics.target.unbind(this)}])},function $prototype(){this.selectionColor=this.curView=this.position=null;this.blinkingPeriod=-1;this.blinkMe=true;this.blinkMeCounter=0;this.cursorType=pkg.Cursor.TEXT;this.canHaveFocus=this.isEditable=true;this.setBlinking=function(period){if(arguments.length===0){period=500}if(period!=this.blinkingPeriod){this.blinkingPeriod=period;this.repaintCursor()}};this.getTextRowColAt=function(x,y){var size=this.view.target.getLines();if(size===0){return null}var lh=this.view.getLineHeight(),li=this.view.getLineIndent(),ln=(y<0)?0:~~((y+li)/(lh+li))+((y+li)%(lh+li)>li?1:0)-1;if(ln>=size){return[size-1,this.view.getLine(size-1).length]}else{if(ln<0){return[0,0]}}if(x<0){return[ln,0]}var x1=0,x2=0,s=this.view.getLine(ln);for(var c=0;c<s.length;c++){x1=x2;x2=this.view.font.charsWidth(s,0,c+1);if(x>=x1&&x<x2){return[ln,c]}}return[ln,s.length]};this.findNextWord=function(t,line,col,d){if(line<0||line>=t.getLines()){return null}var ln=t.getLine(line);col+=d;if(col<0&&line>0){return[line-1,t.getLine(line-1).length]}else{if(col>ln.length&&line<t.getLines()-1){return[line+1,0]}}var b=false;for(;col>=0&&col<ln.length;col+=d){if(b){if(d>0){if(zebra.util.isLetter(ln[col])){return[line,col]}}else{if(!zebra.util.isLetter(ln[col])){return[line,col+1]}}}else{b=d>0?!zebra.util.isLetter(ln[col]):zebra.util.isLetter(ln[col])}}return(d>0?[line,ln.length]:[line,0])};this.getSubString=function(r,start,end){var res=[],sr=start[0],er=end[0],sc=start[1],ec=end[1];for(var i=sr;i<er+1;i++){var ln=r.getLine(i);if(i!=sr){res.push("\n")}else{ln=ln.substring(sc)}if(i==er){ln=ln.substring(0,ec-((sr==er)?sc:0))}res.push(ln)}return res.join("")};this.removeSelected=function(){if(this.hasSelection()){var start=this.startOff<this.endOff?this.startOff:this.endOff;this.remove(start,(this.startOff>this.endOff?this.startOff:this.endOff)-start);this.clearSelection()}};this.startSelection=function(){if(this.startOff<0){var pos=this.position;this.endLine=this.startLine=pos.currentLine;this.endCol=this.startCol=pos.currentCol;this.endOff=this.startOff=pos.offset}};this.keyTyped=function(e){if(e.isControlPressed()||e.isCmdPressed()||this.isEditable===false||(e.ch=="\n"&&zebra.instanceOf(this.view.target,zebra.data.SingleLineTxt))){return}this.removeSelected();this.write(this.position.offset,e.ch)};this.selectAll_command=function(){this.select(0,this.position.metrics.getMaxOffset())};this.nextWord_command=function(b,d){if(b){this.startSelection()}var p=this.findNextWord(this.view.target,this.position.currentLine,this.position.currentCol,d);if(p!=null){this.position.setRowCol(p[0],p[1])}};this.nextPage_command=function(b,d){if(b){this.startSelection()}this.position.seekLineTo(d==1?PO.DOWN:PO.UP,this.pageSize())};this.keyPressed=function(e){if(this.isFiltered(e)){return}var position=this.position,col=position.currentCol,isShiftDown=e.isShiftPressed(),line=position.currentLine,foff=1;if(isShiftDown&&e.ch==KE.CHAR_UNDEFINED){this.startSelection()}switch(e.code){case KE.DOWN:position.seekLineTo(PO.DOWN);break;case KE.UP:position.seekLineTo(PO.UP);break;case KE.LEFT:foff=-1;case KE.RIGHT:if(e.isControlPressed()===false&&e.isCmdPressed()===false){position.seek(foff)}break;case KE.END:if(e.isControlPressed()){position.seekLineTo(PO.DOWN,position.metrics.getLines()-line-1)}else{position.seekLineTo(PO.END)}break;case KE.HOME:if(e.isControlPressed()){position.seekLineTo(PO.UP,line)}else{position.seekLineTo(PO.BEG)}break;case KE.DELETE:if(this.hasSelection()&&this.isEditable===true){this.removeSelected()}else{if(this.isEditable===true){this.remove(position.offset,1)}}break;case KE.BSPACE:if(this.isEditable===true){if(this.hasSelection()){this.removeSelected()}else{if(this.isEditable===true&&position.offset>0){position.seek(-1);this.remove(position.offset,1)}}}break;default:return}if(isShiftDown===false){this.clearSelection()}};this.isFiltered=function(e){var code=e.code;return code==KE.SHIFT||code==KE.CTRL||code==KE.TAB||code==KE.ALT||(e.mask&KE.M_ALT)>0};this.remove=function(pos,size){if(this.isEditable===true){var position=this.position;if(pos>=0&&(pos+size)<=position.metrics.getMaxOffset()){if(size<10000){this.historyPos=(this.historyPos+1)%this.history.length;this.history[this.historyPos]=[-1,pos,this.getValue().substring(pos,pos+size)];if(this.undoCounter<this.history.length){this.undoCounter++}}var pl=position.metrics.getLines(),old=position.offset;this.view.target.remove(pos,size);if(position.metrics.getLines()!=pl||old==pos){this.repaint()}}}};this.write=function(pos,s){if(this.isEditable===true){if(s.length<10000){this.historyPos=(this.historyPos+1)%this.history.length;this.history[this.historyPos]=[1,pos,s.length];if(this.undoCounter<this.history.length){this.undoCounter++}}var old=this.position.offset,m=this.view.target,pl=m.getLines();m.write(s,pos);if(m.getLines()!=pl||this.position.offset==old){this.repaint()}}};this.recalc=function(){var r=this.view,p=this.position;if(p.offset>=0){var cl=p.currentLine;this.curX=r.font.charsWidth(r.getLine(cl),0,p.currentCol)+this.getLeft();this.curY=cl*(r.getLineHeight()+r.getLineIndent())+this.getTop()}this.curH=r.getLineHeight()-1};this.catchScrolled=function(psx,psy){this.repaint()};this.drawCursor=function(g){if(this.position.offset>=0&&this.curView!=null&&this.blinkMe&&this.hasFocus()){this.curView.paint(g,this.curX,this.curY,this.curW,this.curH,this)}};this.mouseDragStarted=function(e){if(e.mask==ME.LEFT_BUTTON&&this.position.metrics.getMaxOffset()>0){this.startSelection()}};this.mouseDragEnded=function(e){if(e.mask==ME.LEFT_BUTTON&&this.hasSelection()===false){this.clearSelection()}};this.mouseDragged=function(e){if(e.mask==ME.LEFT_BUTTON){var p=this.getTextRowColAt(e.x-this.scrollManager.getSX(),e.y-this.scrollManager.getSY());if(p!=null){this.position.setRowCol(p[0],p[1])}}};this.select=function(startOffset,endOffset){if(endOffset<startOffset||startOffset<0||endOffset>this.position.metrics.getMaxOffset()){throw new Error("Invalid selection offsets")}if(this.startOff!=startOffset||endOffset!=this.endOff){if(startOffset==endOffset){this.clearSelection()}else{this.startOff=startOffset;var p=this.position.getPointByOffset(startOffset);this.startLine=p[0];this.startCol=p[1];this.endOff=endOffset;p=this.position.getPointByOffset(endOffset);this.endLine=p[0];this.endCol=p[1];this.repaint()}}};this.hasSelection=function(){return this.startOff!=this.endOff};this.posChanged=function(target,po,pl,pc){this.recalc();var position=this.position;if(position.offset>=0){this.blinkMeCounter=0;this.blinkMe=true;var lineHeight=this.view.getLineHeight(),top=this.getTop();this.scrollManager.makeVisible(this.curX,this.curY,this.curW,lineHeight);if(pl>=0){if(this.startOff>=0){this.endLine=position.currentLine;this.endCol=position.currentCol;this.endOff=position.offset}var minUpdatedLine=pl<position.currentLine?pl:position.currentLine,li=this.view.getLineIndent(),bottom=this.getBottom(),left=this.getLeft(),y1=lineHeight*minUpdatedLine+minUpdatedLine*li+top+this.scrollManager.getSY();if(y1<top){y1=top}if(y1<this.height-bottom){var h=(((pl>position.currentLine)?pl:position.currentLine)-minUpdatedLine+1)*(lineHeight+li);if(y1+h>this.height-bottom){h=this.height-bottom-y1}this.repaint(left,y1,this.width-left-this.getRight(),h)}}else{this.repaint()}}};this.paintOnTop=function(g){if(this.hint&&this.hasFocus()===false&&this.getValue()==""){this.hint.paint(g,this.getLeft(),this.height-this.getBottom()-this.hint.getLineHeight(),this.width,this.height,this)}};this.setHint=function(hint,font,color){this.hint=hint;if(hint!=null&&zebra.instanceOf(hint,pkg.View)===false){this.hint=new pkg.TextRender(hint);font=font?font:pkg.TextField.hintFont;color=color?color:pkg.TextField.hintColor;this.hint.setColor(color);this.hint.setFont(font)}this.repaint();return this.hint};this.undo_command=function(){if(this.undoCounter>0){var h=this.history[this.historyPos];this.historyPos--;if(h[0]==1){this.remove(h[1],h[2])}else{this.write(h[1],h[2])}this.undoCounter-=2;this.redoCounter++;this.historyPos--;if(this.historyPos<0){this.historyPos=this.history.length-1}this.repaint()}};this.redo_command=function(){if(this.redoCounter>0){var h=this.history[(this.historyPos+1)%this.history.length];if(h[0]==1){this.remove(h[1],h[2])}else{this.write(h[1],h[2])}this.redoCounter--;this.repaint()}};this.getStartSelection=function(){return this.startOff!=this.endOff?((this.startOff<this.endOff)?[this.startLine,this.startCol]:[this.endLine,this.endCol]):null};this.getEndSelection=function(){return this.startOff!=this.endOff?((this.startOff<this.endOff)?[this.endLine,this.endCol]:[this.startLine,this.startCol]):null};this.getSelectedText=function(){return this.startOff!=this.endOff?this.getSubString(this.view,this.getStartSelection(),this.getEndSelection()):null};this.focusGained=function(e){if(this.position.offset<0){this.position.setOffset(0)}else{if(this.hint!=null){this.repaint()}else{if(this.isEditable===true){this.repaintCursor()}}}if(this.isEditable===true&&this.blinkingPeriod>0){this.blinkMeCounter=0;this.blinkMe=true;this.blinkTask=zebra.util.task(this).run(Math.floor(this.blinkingPeriod/3),Math.floor(this.blinkingPeriod/3))}};this.focusLost=function(e){if(this.isEditable===true){if(this.hint){this.repaint()}else{this.repaintCursor()}if(this.blinkingPeriod>0){if(this.blinkTask!=null){this.blinkTask.shutdown();this.blinkTask=null}this.blinkMe=true}}};this.repaintCursor=function(){if(this.curX>0&&this.curW>0&&this.curH>0){this.repaint(this.curX+this.scrollManager.getSX(),this.curY+this.scrollManager.getSY(),this.curW,this.curH)}};this.run=function(){this.blinkMeCounter=(this.blinkMeCounter+1)%3;if(this.blinkMeCounter===0){this.blinkMe=!this.blinkMe;this.repaintCursor()}};this.clearSelection=function(){if(this.startOff>=0){var b=this.hasSelection();this.endOff=this.startOff=-1;if(b){this.repaint()}}};this.pageSize=function(){var height=this.height-this.getTop()-this.getBottom(),indent=this.view.getLineIndent(),textHeight=this.view.getLineHeight();return(((height+indent)/(textHeight+indent)+0.5)|0)+(((height+indent)%(textHeight+indent)>indent)?1:0)};this.createPosition=function(r){return new this.$clazz.TextPosition(r)};this.paste=function(txt){if(txt!=null){this.removeSelected();this.write(this.position.offset,txt)}};this.copy=function(){return this.getSelectedText()};this.cut=function(){var t=this.getSelectedText();if(this.isEditable===true){this.removeSelected()}return t};this.setPosition=function(p){if(this.position!=p){if(this.position!=null){this.position.unbind(this);if(this.position.destroy!=null){this.position.destroy()}}this.position=p;this.position.bind(this);this.invalidate()}};this.setModel=function(m){this.setView(new pkg.TextRender(m))};this.setCursorView=function(v){this.curW=1;this.curView=pkg.$view(v);this.vrp()};this.setPSByRowsCols=function(r,c){var tr=this.view,w=(c>0)?(tr.font.stringWidth("W")*c):this.psWidth,h=(r>0)?(r*tr.getLineHeight()+(r-1)*tr.getLineIndent()):this.psHeight;this.setPreferredSize(w,h)};this.setEditable=function(b){if(b!=this.isEditable){this.isEditable=b;if(b&&this.blinkingPeriod>0&&this.hasFocus()){if(this.blinkTask!=null){this.blinkTask.shutdown()}this.blinkMe=true}this.vrp()}};this.mousePressed=function(e){if(e.isActionMask()){if(e.clicks>1){this.select(0,this.position.metrics.getMaxOffset())}else{if((e.mask&KE.M_SHIFT)>0){this.startSelection()}else{this.clearSelection()}var p=this.getTextRowColAt(e.x-this.scrollManager.getSX()-this.getLeft(),e.y-this.scrollManager.getSY()-this.getTop());if(p!=null){this.position.setRowCol(p[0],p[1])}}}};this.setSelectionColor=function(c){if(c!=this.selectionColor){this.selectionColor=c;if(this.hasSelection()){this.repaint()}}};this.calcPreferredSize=function(t){return this.view.getPreferredSize()};this.paint=function(g){var sx=this.scrollManager.getSX(),sy=this.scrollManager.getSY();try{g.translate(sx,sy);var l=this.getLeft(),t=this.getTop();this.view.paint(g,l,t,this.width-l-this.getRight(),this.height-t-this.getBottom(),this);this.drawCursor(g)}catch(e){throw e}finally{g.translate(-sx,-sy)}}},function(){this.$this("")},function(s,maxCol){var b=zebra.isNumber(maxCol);this.$this(b?new zebra.data.SingleLineTxt(s,maxCol):(maxCol?new zebra.data.Text(s):s));if(b&&maxCol>0){this.setPSByRowsCols(-1,maxCol)}},function(render){if(zebra.isString(render)){render=new pkg.TextRender(new zebra.data.SingleLineTxt(render))}else{if(zebra.instanceOf(render,zebra.data.TextModel)){render=new pkg.TextRender(render)}}this.startLine=this.startCol=this.endLine=this.endCol=this.curX=0;this.startOff=this.endOff=-1;this.history=Array(100);this.historyPos=-1;this.redoCounter=this.undoCounter=this.curY=this.curW=this.curH=0;this.$super(render);this.scrollManager=new pkg.ScrollManager(this)},function setView(v){if(v!=this.view){this.$super(v);this.setPosition(this.createPosition(this.view))}},function setValue(s){var txt=this.getValue();if(txt!=s){this.position.setOffset(0);this.scrollManager.scrollTo(0,0);this.$super(s)}},function setEnabled(b){this.clearSelection();this.$super(b)}]);pkg.TextArea=Class(pkg.TextField,[function(){this.$this("")},function(txt){this.$super(new zebra.data.Text(txt))}]);pkg.PassTextField=Class(pkg.TextField,[function(txt){this.$this(txt,-1)},function(txt,size){this.$this(txt,size,false)},function(txt,size,showLast){var pt=new pkg.PasswordText(new zebra.data.SingleLineTxt(txt,size));pt.showLast=showLast;this.$super(pt)}])})(zebra("ui"),zebra.Class);(function(pkg,Class){var L=zebra.layout,Position=zebra.util.Position,KE=pkg.KeyEvent,Listeners=zebra.util.Listeners;pkg.BaseList=Class(pkg.Panel,Position.Metric,[function $prototype(){this.canHaveFocus=true;this.setValue=function(v){if(v==null){this.select(-1)}else{if(this.model!=null){for(var i=0;i<this.model.count();i++){if(this.model.get(i)==v&&this.isItemSelectable(i)){this.select(i);return i}}}}return -1};this.getValue=function(){return this.getSelected()};this.isItemSelectable=function(i){return true};this.getSelected=function(){return this.selectedIndex<0?null:this.model.get(this.selectedIndex)};this.lookupItem=function(ch){var count=this.model==null?0:this.model.count();if(zebra.util.isLetter(ch)&&count>0){var index=this.selectedIndex<0?0:this.selectedIndex+1;ch=ch.toLowerCase();for(var i=0;i<count-1;i++){var idx=(index+i)%count,item=this.model.get(idx).toString();if(this.isItemSelectable(idx)&&item.length>0&&item[0].toLowerCase()==ch){return idx}}}return -1};this.isSelected=function(i){return i==this.selectedIndex};this.pointerMoved=function(x,y){if(this.isComboMode&&this.model!=null){var index=this.getItemIdxAt(x,y);if(index!=this.position.offset&&(index<0||this.isItemSelectable(index)===true)){this.$triggeredByPointer=true;if(index<0){this.position.setOffset(-1)}else{this.position.setOffset(index)}this.notifyScrollMan(index);this.$triggeredByPointer=false}}};this.getItemLocation=function(i){this.validate();var y=this.getTop()+this.scrollManager.getSY();for(var i=0;i<index;i++){y+=this.getItemSize(i).height}return{x:this.getLeft(),y:y}};this.getItemSize=function(i){throw new Error("Not implemented")};this.getLines=function(){return this.model==null?0:this.model.count()};this.getLineSize=function(l){return 1};this.getMaxOffset=function(){return this.getLines()-1};this.catchScrolled=function(psx,psy){this.repaint()};this.getItemIdxAt=function(x,y){return -1};this.calcMaxItemSize=function(){var maxH=0,maxW=0;this.validate();if(this.model!=null){for(var i=0;i<this.model.count();i++){var is=this.getItemSize(i);if(is.height>maxH){maxH=is.height}if(is.width>maxW){maxW=is.width}}}return{width:maxW,height:maxH}};this.repaintByOffsets=function(p,n){this.validate();var xx=this.width-this.getRight(),count=this.model==null?0:this.model.count();if(p>=0&&p<count){var l=this.getItemLocation(p);this.repaint(l.x,l.y,xx-l.x,this.getItemSize(p).height)}if(n>=0&&n<count){var l=this.getItemLocation(n);this.repaint(l.x,l.y,xx-l.x,this.getItemSize(n).height)}};this.drawViewAt=function(g,id,index){if(index>=0&&this.views[id]!=null&&this.isItemSelectable(index)){var is=this.getItemSize(index),l=this.getItemLocation(index);this.drawView(g,id,this.views[id],l.x,l.y,is.width,is.height)}};this.drawView=function(g,id,v,x,y,w,h){this.views[id].paint(g,x,y,w,h,this)};this.update=function(g){if(this.isComboMode===true||this.hasFocus()){this.drawViewAt(g,"marker",this.position.offset)}this.drawViewAt(g,"select",this.selectedIndex)};this.paintOnTop=function(g){if(this.isComboMode===true||this.hasFocus()){this.drawViewAt(g,"top.marker",this.position.offset)}};this.select=function(index){if(this.model!=null&&index>=this.model.count()){throw new Error("index="+index+",max="+this.model.count())}if(this.selectedIndex!=index){if(index<0||this.isItemSelectable(index)){var prev=this.selectedIndex;this.selectedIndex=index;this.notifyScrollMan(index);this.repaintByOffsets(prev,this.selectedIndex);this.fireSelected(prev)}}else{this.fireSelected(null)}};this.fireSelected=function(prev){this._.fired(this,prev)};this.mouseClicked=function(e){if(this.model!=null&&e.isActionMask()&&this.model.count()>0){this.$select(this.position.offset<0?0:this.position.offset)}};this.mouseReleased=function(e){if(this.model!=null&&this.model.count()>0&&e.isActionMask()&&this.position.offset!=this.selectedIndex){this.position.setOffset(this.selectedIndex)}};this.mousePressed=function(e){if(e.isActionMask()&&this.model!=null&&this.model.count()>0){var index=this.getItemIdxAt(e.x,e.y);if(index>=0&&this.position.offset!=index){this.position.setOffset(index)}}};this.mouseDragged=this.mouseMoved=this.mouseEntered=function(e){this.pointerMoved(e.x,e.y)};this.mouseExited=function(e){this.pointerMoved(-10,-10)};this.mouseDragEnded=function(e){if(this.model!=null&&this.model.count()>0&&this.position.offset>=0){this.select(this.position.offset<0?0:this.position.offset)}};this.keyPressed=function(e){if(this.model!=null&&this.model.count()>0){var po=this.position.offset;switch(e.code){case KE.END:if(e.isControlPressed()){this.position.setOffset(this.position.metrics.getMaxOffset())}else{this.position.seekLineTo(Position.END)}break;case KE.HOME:if(e.isControlPressed()){this.position.setOffset(0)}else{this.position.seekLineTo(Position.BEG)}break;case KE.RIGHT:this.position.seek(1);break;case KE.DOWN:this.position.seekLineTo(Position.DOWN);break;case KE.LEFT:this.position.seek(-1);break;case KE.UP:this.position.seekLineTo(Position.UP);break;case KE.PAGEUP:this.position.seek(this.pageSize(-1));break;case KE.PAGEDOWN:this.position.seek(this.pageSize(1));break;case KE.SPACE:case KE.ENTER:this.$select(this.position.offset);break}}};this.$select=function(o){this.select(o)};this.keyTyped=function(e){var i=this.lookupItem(e.ch);if(i>=0){this.$select(i)}};this.elementInserted=function(target,e,index){this.invalidate();if(this.selectedIndex>=0&&this.selectedIndex>=index){this.selectedIndex++}this.position.inserted(index,1);this.repaint()};this.elementRemoved=function(target,e,index){this.invalidate();if(this.selectedIndex==index||this.model.count()===0){this.select(-1)}else{if(this.selectedIndex>index){this.selectedIndex--}}this.position.removed(index,1);this.repaint()};this.elementSet=function(target,e,pe,index){if(this.selectedIndex==index){this.select(-1)}this.vrp()};this.findSelectable=function(off,d){var c=this.model.count(),i=0,dd=Math.abs(d);while(this.isItemSelectable(off)===false&&i<c){off=(c+off+d)%c;i+=dd}return i<c?off:-1};this.posChanged=function(target,prevOffset,prevLine,prevCol){var off=this.position.offset;if(off>=0){off=this.findSelectable(off,prevOffset<off?1:-1);if(off!=this.position.offset){this.position.setOffset(off);this.repaintByOffsets(prevOffset,off);return}}if(this.isComboMode){this.notifyScrollMan(off)}else{this.select(off)}this.repaintByOffsets(prevOffset,off)};this.setModel=function(m){if(m!=this.model){if(m!=null&&Array.isArray(m)){m=new zebra.data.ListModel(m)}if(this.model!=null&&this.model._!=null){this.model.unbind(this)}this.model=m;if(this.model!=null&&this.model._!=null){this.model.bind(this)}this.vrp()}return this};this.setPosition=function(c){if(c!=this.position){if(this.position!=null){this.position.unbind(this)}this.position=c;this.position.bind(this);this.position.setMetric(this);this.repaint()}};this.setViewProvider=function(v){if(this.provider!=v){if(typeof v=="function"){var o=new zebra.Dummy();o.getView=v;v=o}this.provider=v;this.vrp()}};this.notifyScrollMan=function(index){if(index>=0&&this.scrollManager!=null){this.validate();var is=this.getItemSize(index);if(is.width>0&&is.height>0){var l=this.getItemLocation(index);this.scrollManager.makeVisible(l.x-this.scrollManager.getSX(),l.y-this.scrollManager.getSY(),is.width,is.height)}}};this.pageSize=function(d){var offset=this.position.offset;if(offset>=0){var vp=pkg.$cvp(this,{});if(vp!=null){var sum=0,i=offset;for(;i>=0&&i<=this.position.metrics.getMaxOffset()&&sum<vp.height;i+=d){sum+=(this.getItemSize(i).height)}return i-offset-d}}return 0}},function(m,b){this.selectedIndex=-1;this._=new Listeners();this.isComboMode=b;this.scrollManager=new pkg.ScrollManager(this);this.$super();this.setPosition(new Position(this));this.setModel(m)},function focused(){this.$super();this.repaint()}]);pkg.BaseList.prototype.setViews=pkg.$ViewsSetter;pkg.List=Class(pkg.BaseList,[function $clazz(){this.ViewProvider=Class([function $prototype(){this[""]=function(f,c){this.text=new pkg.StringRender("");zebra.properties(this,this.$clazz);if(f!=null){this.text.setFont(f)}if(c!=null){this.text.setColor(c)}};this.getView=function(target,value,i){if(value!=null&&value.paint!=null){return value}this.text.setValue(value==null?"<null>":value.toString());return this.text}}])},function $prototype(){this.gap=2;this.setItemGap=function(g){if(this.gap!=g){this.gap=g;this.vrp()}};this.paint=function(g){this.vVisibility();if(this.firstVisible>=0){var sx=this.scrollManager.getSX(),sy=this.scrollManager.getSY();try{g.translate(sx,sy);var y=this.firstVisibleY,x=this.getLeft(),yy=this.vArea.y+this.vArea.height-sy,count=this.model.count(),dg=this.gap*2;for(var i=this.firstVisible;i<count;i++){if(i!=this.selectedIndex&&this.provider.getCellColor!=null){var bc=this.provider.getCellColor(this,i);if(bc!=null){g.setColor(bc);g.fillRect(x,y,this.width,this.heights[i])}}this.provider.getView(this,this.model.get(i),i).paint(g,x+this.gap,y+this.gap,this.widths[i]-dg,this.heights[i]-dg,this);y+=this.heights[i];if(y>yy){break}}}catch(e){throw e}finally{g.translate(-sx,-sy)}}};this.recalc=function(){this.psWidth_=this.psHeight_=0;if(this.model!=null){var count=this.model.count();if(this.heights==null||this.heights.length!=count){this.heights=Array(count)}if(this.widths==null||this.widths.length!=count){this.widths=Array(count)}var provider=this.provider;if(provider!=null){var dg=2*this.gap;for(var i=0;i<count;i++){var ps=provider.getView(this,this.model.get(i),i).getPreferredSize();this.heights[i]=ps.height+dg;this.widths[i]=ps.width+dg;if(this.widths[i]>this.psWidth_){this.psWidth_=this.widths[i]}this.psHeight_+=this.heights[i]}}}};this.calcPreferredSize=function(l){return{width:this.psWidth_,height:this.psHeight_}};this.vVisibility=function(){this.validate();var prev=this.vArea;this.vArea=pkg.$cvp(this,{});if(this.vArea==null){this.firstVisible=-1;return}if(this.visValid===false||(prev==null||prev.x!=this.vArea.x||prev.y!=this.vArea.y||prev.width!=this.vArea.width||prev.height!=this.vArea.height)){var top=this.getTop();if(this.firstVisible>=0){var dy=this.scrollManager.getSY();while(this.firstVisibleY+dy>=top&&this.firstVisible>0){this.firstVisible--;this.firstVisibleY-=this.heights[this.firstVisible]}}else{this.firstVisible=0;this.firstVisibleY=top}if(this.firstVisible>=0){var count=this.model==null?0:this.model.count(),hh=this.height-this.getBottom();for(;this.firstVisible<count;this.firstVisible++){var y1=this.firstVisibleY+this.scrollManager.getSY(),y2=y1+this.heights[this.firstVisible]-1;if((y1>=top&&y1<hh)||(y2>=top&&y2<hh)||(y1<top&&y2>=hh)){break}this.firstVisibleY+=(this.heights[this.firstVisible])}if(this.firstVisible>=count){this.firstVisible=-1}}this.visValid=true}};this.getItemLocation=function(index){this.validate();var y=this.getTop()+this.scrollManager.getSY();for(var i=0;i<index;i++){y+=this.heights[i]}return{x:this.getLeft(),y:y}};this.getItemSize=function(i){this.validate();return{width:this.widths[i],height:this.heights[i]}};this.getItemIdxAt=function(x,y){this.vVisibility();if(this.vArea!=null&&this.firstVisible>=0){var yy=this.firstVisibleY+this.scrollManager.getSY(),hh=this.height-this.getBottom(),count=this.model.count();for(var i=this.firstVisible;i<count;i++){if(y>=yy&&y<yy+this.heights[i]){return i}yy+=(this.heights[i]);if(yy>hh){break}}}return -1}},function(){this.$this(false)},function(m){if(zebra.isBoolean(m)){this.$this([],m)}else{this.$this(m,false)}},function(m,b){this.firstVisible=-1;this.firstVisibleY=this.psWidth_=this.psHeight_=0;this.heights=this.widths=this.vArea=null;this.visValid=false;this.setViewProvider(new this.$clazz.ViewProvider());this.$super(m,b)},function invalidate(){this.visValid=false;this.firstVisible=-1;this.$super()},function drawView(g,id,v,x,y,w,h){this.$super(g,id,v,x,y,this.width-this.getRight()-x,h)},function catchScrolled(psx,psy){this.firstVisible=-1;this.visValid=false;this.$super(psx,psy)}]);pkg.CompList=Class(pkg.BaseList,pkg.Composite,[function $clazz(){this.Label=Class(pkg.Label,[]);this.ImageLabel=Class(pkg.ImageLabel,[]);var CompListModelListeners=zebra.util.ListenersClass("elementInserted","elementRemoved");this.CompListModel=Class([function $prototype(){this.get=function(i){return this.src.kids[i]};this.set=function(item,i){this.src.removeAt(i);this.src.insert(i,null,item)};this.add=function(o){this.src.add(o)};this.removeAt=function(i){this.src.removeAt(i)};this.insert=function(item,i){this.src.insert(i,null,item)};this.count=function(){return this.src.kids.length};this.removeAll=function(){this.src.removeAll()}},function(src){this.src=src;this._=new CompListModelListeners()}])},function $prototype(){this.catchScrolled=function(px,py){};this.getItemLocation=function(i){return{x:this.kids[i].x,y:this.kids[i].y}};this.getItemSize=function(i){return this.kids[i].isVisible===false?{width:0,height:0}:{width:this.kids[i].width,height:this.kids[i].height}};this.recalc=function(){this.max=L.getMaxPreferredSize(this)};this.calcMaxItemSize=function(){this.validate();return{width:this.max.width,height:this.max.height}};this.getItemIdxAt=function(x,y){return L.getDirectAt(x,y,this)};this.isItemSelectable=function(i){return this.model.get(i).isVisible===true&&this.model.get(i).isEnabled===true};this.catchInput=function(child){if(this.isComboMode){return true}var p=child;while(p!=this){if(p.stopCatchInput===true){return false}p=p.parent}return true}},function(){this.$this([],false)},function(b){if(zebra.isBoolean(b)){this.$this([],b)}else{this.$this(b,false)}},function(d,b){this.max=null;this.setViewProvider(new zebra.Dummy([function getView(target,obj,i){return new pkg.CompRender(obj)}]));this.$super(d,b)},function setModel(m){var a=[];if(Array.isArray(m)){a=m;m=new this.$clazz.CompListModel(this)}if(zebra.instanceOf(m,this.$clazz.CompListModel)===false){throw new Error("Invalid model")}this.$super(m);for(var i=0;i<a.length;i++){this.add(a[i])}},function setPosition(c){if(c!=this.position){if(zebra.instanceOf(this.layout,Position.Metric)){c.setMetric(this.layout)}this.$super(c)}},function setLayout(layout){if(layout!=this.layout){this.scrollManager=new pkg.ScrollManager(this,[function $prototype(){this.calcPreferredSize=function(t){return layout.calcPreferredSize(t)};this.doLayout=function(t){layout.doLayout(t);for(var i=0;i<t.kids.length;i++){var kid=t.kids[i];if(kid.isVisible===true){kid.setLocation(kid.x+this.getSX(),kid.y+this.getSY())}}};this.scrollStateUpdated=function(sx,sy,px,py){this.target.vrp()}}]);this.$super(this.scrollManager);if(this.position!=null){this.position.setMetric(zebra.instanceOf(layout,Position.Metric)?layout:this)}}return this},function insert(index,constr,e){return this.$super(index,constr,zebra.isString(e)?new this.$clazz.Label(e):e)},function kidAdded(index,constr,e){this.$super(index,constr,e);this.model._.elementInserted(this,e,index)},function kidRemoved(index,e){this.$super(index,e);this.model._.elementRemoved(this,e,index)}]);var ContentListeners=zebra.util.ListenersClass("contentUpdated");pkg.Combo=Class(pkg.Panel,pkg.Composite,[function $clazz(){this.ContentPan=Class(pkg.Panel,[function $prototype(){this.comboValueUpdated=function(combo,value){};this.getCombo=function(){var p=this;while((p=p.parent)&&zebra.instanceOf(p,pkg.Combo)==false){}return p}}]);this.ComboPadPan=Class(pkg.ScrollPan,[function $prototype(){this.closeTime=0;this.childInputEvent=function(e){if(e.ID==KE.PRESSED&&e.code==KE.ESCAPE&&this.parent!=null){this.removeMe()}}},function setParent(l){this.$super(l);if(l==null&&this.owner!=null){this.owner.requestFocus()}this.closeTime=l==null?new Date().getTime():0}]);this.ReadonlyContentPan=Class(this.ContentPan,[function $prototype(){this.calcPreferredSize=function(l){var p=this.getCombo();return p?p.list.calcMaxItemSize():{width:0,height:0}};this.paintOnTop=function(g){var list=this.getCombo().list,selected=list.getSelected(),v=selected!=null?list.provider.getView(list,selected,list.selectedIndex):null;if(v!=null){var ps=v.getPreferredSize();v.paint(g,this.getLeft(),this.getTop()+~~((this.height-this.getTop()-this.getBottom()-ps.height)/2),this.width,ps.height,this)}}}]);this.EditableContentPan=Class(this.ContentPan,[function $clazz(){this.TextField=Class(pkg.TextField,[])},function(){this.$super(new L.BorderLayout());this._=new ContentListeners();this.isEditable=true;this.dontGenerateUpdateEvent=false;this.textField=new this.$clazz.TextField("",-1);this.textField.view.target.bind(this);this.add(L.CENTER,this.textField)},function focused(){this.$super();this.textField.requestFocus()},function $prototype(){this.canHaveFocus=true;this.textUpdated=function(src,b,off,size,startLine,lines){if(this.dontGenerateUpdateEvent===false){this._.contentUpdated(this,this.textField.getValue())}};this.comboValueUpdated=function(combo,v){this.dontGenerateUpdateEvent=true;try{var txt=(v==null?"":v.toString());this.textField.setValue(txt);this.textField.select(0,txt.length)}finally{this.dontGenerateUpdateEvent=false}}}]);this.Button=Class(pkg.Button,[function(){this.setFireParams(true,-1);this.setCanHaveFocus(false);this.$super()}]);this.List=Class(pkg.List,[])},function $prototype(){this.paint=function(g){if(this.content!=null&&this.selectionView!=null&&this.hasFocus()){this.selectionView.paint(g,this.content.x,this.content.y,this.content.width,this.content.height,this)}};this.catchInput=function(child){return child!=this.button&&(this.content==null||!this.content.isEditable)};this.canHaveFocus=function(){return this.winpad.parent==null&&(this.content!=null||!this.content.isEditable)};this.contentUpdated=function(src,text){if(src==this.content){try{this.$lockListSelEvent=true;if(text==null){this.list.select(-1)}else{var m=this.list.model;for(var i=0;i<m.count();i++){var mv=m.get(i);if(mv!=text){this.list.select(i);break}}}}finally{this.$lockListSelEvent=false}this._.fired(this,text)}};this.select=function(i){this.list.select(i)};this.setSelectedIndex=function(i){this.select(i)};this.setValue=function(v){this.list.setValue(v)};this.getValue=function(){return this.list.getValue()};this.mousePressed=function(e){if(e.isActionMask()&&this.content!=null&&(new Date().getTime()-this.winpad.closeTime)>100&&e.x>this.content.x&&e.y>this.content.y&&e.x<this.content.x+this.content.width&&e.y<this.content.y+this.content.height){this.showPad()}};this.hidePad=function(){var d=this.getCanvas();if(d!=null&&this.winpad.parent!=null){d.getLayer(pkg.PopupLayer.ID).remove(this.winpad);this.requestFocus()}};this.showPad=function(){var canvas=this.getCanvas();if(canvas!=null){var winlayer=canvas.getLayer(pkg.PopupLayer.ID),ps=this.winpad.getPreferredSize(),p=L.toParentOrigin(0,0,this),px=p.x,py=p.y;if(this.winpad.hbar&&ps.width>this.width){ps.height+=this.winpad.hbar.getPreferredSize().height}if(this.maxPadHeight>0&&ps.height>this.maxPadHeight){ps.height=this.maxPadHeight}if(py+this.height+ps.height>canvas.height){if(py-ps.height>=0){py-=(ps.height+this.height)}else{var hAbove=canvas.height-py-this.height;if(py>hAbove){ps.height=py;py-=(ps.height+this.height)}else{ps.height=hAbove}}}this.winpad.setSize(this.width,ps.height);this.winpad.setLocation(px,py+this.height);this.list.notifyScrollMan(this.list.selectedIndex);winlayer.add(this,this.winpad);this.list.requestFocus()}};this.setList=function(l){if(this.list!=l){this.hidePad();if(this.list!=null){this.list.unbind(this)}this.list=l;if(this.list._){this.list.bind(this)}this.winpad=new this.$clazz.ComboPadPan(this.list);this.winpad.owner=this;if(this.content!=null){this.content.comboValueUpdated(this,this.list.getSelected())}this.vrp()}};this.keyPressed=function(e){if(this.list.model!=null){var index=this.list.selectedIndex;switch(e.code){case KE.ENTER:this.showPad();break;case KE.LEFT:case KE.UP:if(index>0){this.list.select(index-1)}break;case KE.DOWN:case KE.RIGHT:if(this.list.model.count()-1>index){this.list.select(index+1)}break}}};this.keyTyped=function(e){this.list.keyTyped(e)};this.setSelectionView=function(c){if(c!=this.selectionView){this.selectionView=pkg.$view(c);this.repaint()}};this.setMaxPadHeight=function(h){if(this.maxPadHeight!=h){this.hidePad();this.maxPadHeight=h}}},function(){this.$this(new this.$clazz.List(true))},function(list){if(zebra.isBoolean(list)){this.$this(new this.$clazz.List(true),list)}else{this.$this(list,false)}},function(list,editable){if(zebra.instanceOf(list,pkg.BaseList)===false){list=new this.$clazz.List(list,true)}this.button=this.content=this.winpad=null;this.maxPadHeight=0;this.$lockListSelEvent=false;this._=new Listeners();this.setList(list);this.$super();this.add(L.CENTER,editable?new this.$clazz.EditableContentPan():new this.$clazz.ReadonlyContentPan());this.add(L.RIGHT,new this.$clazz.Button())},function focused(){this.$super();this.repaint()},function kidAdded(index,s,c){if(zebra.instanceOf(c,this.$clazz.ContentPan)){if(this.content!=null){throw new Error("Content panel is set")}if(c._!=null){c.bind(this)}this.content=c;if(this.list!=null){c.comboValueUpdated(this,this.list.getSelected())}}this.$super(index,s,c);if(this.button==null&&c._!=null&&c._.fired!=null){this.button=c;this.button.bind(this)}},function kidRemoved(index,l){if(this.content==l){if(l._!=null){l.unbind(this)}this.content=null}this.$super(index,l);if(this.button==l){this.button.unbind(this);this.button=null}},function fired(src){if((new Date().getTime()-this.winpad.closeTime)>100){this.showPad()}},function fired(src,data){if(this.$lockListSelEvent===false){this.hidePad();if(this.content!=null){this.content.comboValueUpdated(this,this.list.getSelected());if(this.content.isEditable){pkg.focusManager.requestFocus(this.content)}this.repaint()}this._.fired(this,data)}}]);pkg.ComboArrowView=Class(pkg.View,[function $prototype(){this[""]=function(col,state){this.color=col==null?"black":col;this.state=state==null?false:state;this.gap=4};this.paint=function(g,x,y,w,h,d){if(this.state){g.setColor("#CCCCCC");g.drawLine(x,y,x,y+h);g.setColor("gray");g.drawLine(x+1,y,x+1,y+h)}else{g.setColor("#CCCCCC");g.drawLine(x,y,x,y+h);g.setColor("#EEEEEE");g.drawLine(x+1,y,x+1,y+h)}x+=this.gap+1;y+=this.gap+1;w-=this.gap*2;h-=this.gap*2;var s=Math.min(w,h);x=x+(w-s)/2+1;y=y+(h-s)/2;g.setColor(this.color);g.beginPath();g.moveTo(x,y);g.lineTo(x+s,y);g.lineTo(x+s/2,y+s);g.lineTo(x,y);g.fill()};this.getPreferredSize=function(){return{width:2*this.gap+6,height:2*this.gap+6}}}])})(zebra("ui"),zebra.Class);(function(pkg,Class){var KE=pkg.KeyEvent,task=zebra.util.task,L=zebra.layout,MouseEvent=pkg.MouseEvent,WIN_OPENED=1,WIN_CLOSED=2,WIN_ACTIVATED=3,WIN_DEACTIVATED=4,VIS_PART_SIZE=30,WinListeners=zebra.util.ListenersClass("winOpened","winActivated");pkg.showModalWindow=function(context,win,listener){pkg.showWindow(context,"modal",win,listener)};pkg.showWindow=function(context,type,win,listener){if(arguments.length<3){win=type;type="info"}return context.getCanvas().getLayer("win").addWin(type,win,listener)};pkg.WinLayer=Class(pkg.BaseLayer,[function $clazz(){this.ID="win"},function $prototype(){this.isLayerActiveAt=function(x,y){return this.activeWin!=null};this.layerMousePressed=function(x,y,mask){var cnt=this.kids.length;if(cnt>0){if(this.activeWin!=null&&this.indexOf(this.activeWin)==cnt-1){var x1=this.activeWin.x,y1=this.activeWin.y,x2=x1+this.activeWin.width,y2=y1+this.activeWin.height;if(x>=x1&&y>=y1&&x<x2&&y<y2){return true}}for(var i=cnt-1;i>=0&&i>=this.topModalIndex;i--){var d=this.kids[i];if(d.isVisible===true&&d.isEnabled&&this.winsTypes[d]!="info"&&x>=d.x&&y>=d.y&&x<d.x+d.width&&y<d.y+d.height){this.activate(d);return true}}if(this.topModalIndex<0&&this.activeWin!=null){this.activate(null);return false}return true}return false};this.layerKeyPressed=function(keyCode,mask){if(this.kids.length>0&&keyCode==KE.TAB&&(mask&KE.M_SHIFT)>0){if(this.activeWin==null){this.activate(this.kids[this.kids.length-1])}else{var winIndex=this.winsStack.indexOf(this.activeWin)-1;if(winIndex<this.topModalIndex||winIndex<0){winIndex=this.winsStack.length-1}this.activate(this.winsStack[winIndex])}return true}return false};this.childInputEvent=function(e){if(e.ID==pkg.InputEvent.FOCUS_GAINED){this.activate(L.getDirectChild(this,e.source))}};this.getComponentAt=function(x,y){return(this.activeWin==null)?null:this.activeWin.getComponentAt(x-this.activeWin.x,y-this.activeWin.y)};this.getFocusRoot=function(){return this.activeWin};this.getWinType=function(w){return this.winsTypes[w]};this.activate=function(c){if(c!=null&&(this.kids.indexOf(c)<0||this.winsTypes[c]=="info")){throw new Error("Window cannot be activated")}if(c!=this.activeWin){var old=this.activeWin;if(c==null){if(this.winsTypes[this.activeWin]=="modal"){throw new Error()}this.activeWin=null;this.fire(WIN_DEACTIVATED,old);pkg.focusManager.requestFocus(null)}else{if(this.winsStack.indexOf(c)<this.topModalIndex){throw new Error()}this.activeWin=c;this.activeWin.toFront();if(old!=null){this.fire(WIN_DEACTIVATED,old)}this.fire(WIN_ACTIVATED,this.activeWin);this.activeWin.validate();pkg.focusManager.requestFocus(pkg.focusManager.findFocusable(this.activeWin))}}};this.fire=function(id,win,l){if(arguments.length<3){l=this.winsListeners[win]}var b=(id==WIN_OPENED||id==WIN_ACTIVATED),n=(id==WIN_OPENED||id==WIN_CLOSED)?"winOpened":"winActivated";this._[n](this,win,b);if(win[n]!=null){win[n].apply(win,[this,win,b])}if(l!=null&&l[n]!=null){l[n].apply(l,[this,win,b])}};this.addWin=function(type,win,listener){this.winsTypes[win]=type;this.winsListeners[win]=listener;this.add(win)}},function(){this.activeWin=null;this.topModalIndex=-1;this.winsStack=[];this.winsListeners={};this.winsTypes={};this._=new WinListeners();this.$super(pkg.WinLayer.ID)},function insert(index,constr,lw){var type=this.winsTypes[lw];if(typeof type==="undefined"){type="mdi";this.winsTypes[lw]=type}if(type!="mdi"&&type!="modal"&&type!="info"){throw new Error("Invalid window type: "+type)}return this.$super(index,constr,lw)},function kidAdded(index,constr,lw){this.$super(index,constr,lw);var type=this.winsTypes[lw];this.winsStack.push(lw);if(type=="modal"){this.topModalIndex=this.winsStack.length-1}this.fire(WIN_OPENED,lw);if(type=="modal"){this.activate(lw)}},function kidRemoved(index,lw){try{this.$super(this.kidRemoved,index,lw);if(this.activeWin==lw){this.activeWin=null;pkg.focusManager.requestFocus(null)}var ci=this.winsStack.indexOf(lw),l=this.winsListeners[lw];this.winsStack.splice(this.winsStack.indexOf(lw),1);if(ci<this.topModalIndex){this.topModalIndex--}else{if(this.topModalIndex==ci){for(this.topModalIndex=this.kids.length-1;this.topModalIndex>=0;this.topModalIndex--){if(this.winsTypes[this.winsStack[this.topModalIndex]]=="modal"){break}}}}this.fire(WIN_CLOSED,lw,l);if(this.topModalIndex>=0){var aindex=this.winsStack.length-1;while(this.winsTypes[this.winsStack[aindex]]=="info"){aindex--}this.activate(this.winsStack[aindex])}}finally{delete this.winsTypes[lw];delete this.winsListeners[lw]}}]);pkg.Window=Class(pkg.StatePan,pkg.Composite,[function $prototype(){var MOVE_ACTION=1,SIZE_ACTION=2;this.isPopupEditor=true;this.minSize=40;this.isSizeable=true;this.isActive=function(){var c=this.getCanvas();return c!=null&&c.getLayer("win").activeWin==this};this.mouseDragStarted=function(e){this.px=e.x;this.py=e.y;this.psw=this.width;this.psh=this.height;this.action=this.insideCorner(this.px,this.py)?(this.isSizeable?SIZE_ACTION:-1):MOVE_ACTION;if(this.action>0){this.dy=this.dx=0}};this.mouseDragged=function(e){if(this.action>0){if(this.action!=MOVE_ACTION){var nw=this.psw+this.dx,nh=this.psh+this.dy;if(nw>this.minSize&&nh>this.minSize){this.setSize(nw,nh)}}this.dx=(e.x-this.px);this.dy=(e.y-this.py);if(this.action==MOVE_ACTION){this.invalidate();this.setLocation(this.x+this.dx,this.y+this.dy)}}};this.mouseDragEnded=function(e){if(this.action>0){if(this.action==MOVE_ACTION){this.invalidate();this.setLocation(this.x+this.dx,this.y+this.dy)}this.action=-1}};this.insideCorner=function(px,py){return this.getComponentAt(px,py)==this.sizer};this.getCursorType=function(target,x,y){return(this.isSizeable&&this.insideCorner(x,y))?pkg.Cursor.SE_RESIZE:null};this.catchInput=function(c){var tp=this.caption;return c==tp||(L.isAncestorOf(tp,c)&&zebra.instanceOf(c,pkg.Button)===false)||this.sizer==c};this.winOpened=function(winLayer,target,b){var state=this.isActive()?"active":"inactive";if(this.caption!=null&&this.caption.setState){this.caption.setState(state)}this.setState(state)};this.winActivated=function(winLayer,target,b){this.winOpened(winLayer,target,b)};this.mouseClicked=function(e){var x=e.x,y=e.y,cc=this.caption;if(e.clicks==2&&this.isSizeable&&x>cc.x&&x<cc.y+cc.width&&y>cc.y&&y<cc.y+cc.height){if(this.prevW<0){this.maximize()}else{this.restore()}}};this.isMaximized=function(){return this.prevW!=-1};this.createCaptionPan=function(){return new this.$clazz.CaptionPan()};this.createContentPan=function(){return new this.$clazz.ContentPan()};this.createTitle=function(){return new this.$clazz.TitleLab()};this.setIcon=function(i,icon){if(zebra.isString(icon)||zebra.instanceOf(icon,pkg.Picture)){icon=new pkg.ImagePan(icon)}this.icons.setAt(i,icon)}},function $clazz(){this.CaptionPan=Class(pkg.StatePan,[function $prototype(){this.state="inactive"}]);this.TitleLab=Class(pkg.Label,[]);this.StatusPan=Class(pkg.Panel,[]);this.ContentPan=Class(pkg.Panel,[]);this.SizerIcon=Class(pkg.ImagePan,[]);this.Icon=Class(pkg.ImagePan,[]);this.Button=Class(pkg.Button,[])},function(){this.$this(null,null)},function(s){if(s!=null&&zebra.isString(s)){this.$this(s,null)}else{this.$this(null,s)}},function(s,c){this.state="inactive";this.prevH=this.prevX=this.prevY=this.psw=0;this.psh=this.px=this.py=this.dx=this.dy=0;this.prevW=this.action=-1;this.root=(c==null?this.createContentPan():c);this.caption=this.createCaptionPan();this.title=this.createTitle();this.title.setValue((s==null?"":s));this.icons=new pkg.Panel(new L.FlowLayout(L.LEFT,L.CENTER,L.HORIZONTAL,2));this.icons.add(new this.$clazz.Icon());this.buttons=new pkg.Panel(new L.FlowLayout(L.CENTER,L.CENTER));this.caption.add(L.CENTER,this.title);this.caption.add(L.LEFT,this.icons);this.caption.add(L.RIGHT,this.buttons);this.status=new this.$clazz.StatusPan();this.sizer=new this.$clazz.SizerIcon();this.status.add(this.sizer);this.setSizeable(true);this.$super(new L.BorderLayout(2,2));this.add(L.CENTER,this.root);this.add(L.TOP,this.caption);this.add(L.BOTTOM,this.status)},function fired(src){this.removeMe()},function focused(){this.$super();if(this.caption!=null){this.caption.repaint()}},function setSizeable(b){if(this.isSizeable!=b){this.isSizeable=b;if(this.sizer!=null){this.sizer.setVisible(b)}}},function maximize(){if(this.prevW<0){var d=this.getCanvas(),left=d.getLeft(),top=d.getTop();this.prevX=this.x;this.prevY=this.y;this.prevW=this.width;this.prevH=this.height;this.setLocation(left,top);this.setSize(d.width-left-d.getRight(),d.height-top-d.getBottom())}},function restore(){if(this.prevW>=0){this.setLocation(this.prevX,this.prevY);this.setSize(this.prevW,this.prevH);this.prevW=-1}},function close(){this.removeMe()},function setButtons(buttons){for(var i=0;i<this.buttons.length;i++){var kid=this.buttons.kids[i];if(kid._!=null){kid.unbind()}}this.buttons.removeAll();for(var k in buttons){if(buttons.hasOwnProperty(k)){var b=new this.$clazz.Button();b.setView(buttons[k]);this.buttons.add(b);(function(t,f){b.bind(function(){f.call(t)})})(this,this[k])}}}]);pkg.MenuItem=Class(pkg.Panel,[function $clazz(){this.SubImage=Class(pkg.StatePan,[]);this.Label=Class(pkg.Label,[]);this.CheckStatePan=Class(pkg.ViewPan,[])},function $prototype(){this.gap=8;this.manager=null;this.itemSelected=function(){var content=this.getContent();if(zebra.instanceOf(content,pkg.Checkbox)){content.setValue(!content.getValue())}if(this.manager!=null){this.manager.setValue(this,!this.manager.getValue(this))}};this.setIcon=function(img){this.getContent().setImage(img)};this.setCaption=function(caption){this.getContent().setCaption(caption)};this.switched=function(b){this.kids[0].view.activate(b?(this.isEnabled===true?"on":"dis.on"):"off")};this.getCheck=function(){return this.kids[0]};this.getContent=function(){return this.kids[1]};this.getSub=function(){return this.kids[2]};this.hideSub=function(){this.getSub().setVisible(false)};this.activateSub=function(b){var kid=this.getSub();kid.setState(b?"arrow":"*");if(this.parent!=null&&this.parent.noSubIfEmpty===true){kid.setVisible(b)}};this.calcPreferredSize=function(target){var cc=0,pw=0,ph=0;for(var i=0;i<target.kids.length;i++){var k=target.kids[i];if(k.isVisible===true){var ps=k.getPreferredSize();pw+=ps.width+(cc>0?this.gap:0);if(ps.height>ph){ph=ps.height}cc++}}return{width:pw,height:ph}};this.doLayout=function(target){var left=this.getCheck(),right=this.getSub(),content=this.getContent(),t=target.getTop(),l=target.getLeft(),eh=target.height-t-target.getBottom(),ew=target.width-l-target.getRight();if(left!=null&&left.isVisible===true){left.toPreferredSize();left.setLocation(l,t+~~((eh-left.height)/2));l+=this.gap+left.width;ew-=(this.gap+left.width)}if(right!=null&&right.isVisible===true){right.toPreferredSize();right.setLocation(target.width-target.getRight()-right.width,t+~~((eh-right.height)/2));ew-=(this.gap+right.width)}if(content!=null&&content.isVisible===true){content.toPreferredSize();if(content.width>ew){content.setSize(ew,content.height)}content.setLocation(l,t+~~((eh-content.height)/2))}};this.setCheckState=function(b){if(this.manager==null){this.setCheckManager(new pkg.SwitchManager())}this.manager.setValue(this,b)};this.getCheckState=function(){if(this.manager==null){throw new Error()}return this.manager.getValue(this)};this.setCheckManager=function(man){if(this.manager!=man){if(this.manager!=null){this.manager.uninstall(this)}this.manager=man;this.manager.install(this)}}},function setParent(p){this.$super(p);if(p!=null&&p.noSubIfEmpty===true){this.getSub().setVisible(false)}},function(c){this.$super();this.add(new this.$clazz.CheckStatePan());if(zebra.isString(c)){var m=c.match(/(\s*\@\(.*\)\s*)?(\s*\[\s*\]|\s*\[\s*x\s*\]|\s*\(\s*x\s*\)|\s*\(\s*\))?\s*(.*)/);if(m==null){throw new Error("Invalid menu item: "+c)}if(m[2]!=null){var s=m[2].trim();this.setCheckManager(s[0]=="("?new pkg.Group():new pkg.SwitchManager());this.manager.setValue(this,m[2].indexOf("x")>0)}var img=null;if(m[1]!=null){img=m[1].substring(m[1].indexOf("@(")+2,m[1].lastIndexOf(")")).trim();if(img[0]=="'"){img=img.substring(1,img.length-1)}else{var parts=img.split("."),scope=zebra.$global;img=null;for(var i=0;i<parts.length;i++){scope=scope[parts[i]];if(scope==null){break}}img=scope}}c=m[3];m=c.match(/(.*)\s*\[\s*@([a-zA-Z_][a-zA-Z0-9_]+)\s*]\s*/);if(m!=null){this.id=m[2].trim();c=m[1].trim()}else{this.id=c.toLowerCase().replace(/[ ]+/,"_")}c=new pkg.ImageLabel(new this.$clazz.Label(c),img)}else{this.getCheck().setVisible(false)}this.add(c);this.add(new this.$clazz.SubImage());this.setEnabled(c.isEnabled);this.setVisible(c.isVisible)},function setEnabled(b){this.$super(b);if(this.manager!=null){this.switched(this.manager.getValue(this))}}]);pkg.Menu=Class(pkg.CompList,[function $prototype(){this.canHaveFocus=true;this.noSubIfEmpty=false;this.isDecorative=function(i){return this.decoratives[this.kids[i]]===true||this.kids[i].$isDecorative===true};this.childCompEvent=function(id,src,p1,p2){if(id==pkg.Panel.SHOWN||id==pkg.Panel.ENABLED){for(var i=0;i<this.kids.length;i++){if(this.kids[i]==src){if(this.isItemSelectable(i)===false){if(i==this.selectedIndex){this.select(-1)}}break}}}};this.getMenuItem=function(i){if(zebra.isString(i)){var item=this.find(i);if(item!=null){return item}for(var k in this.menus){item=this.menus[k].getMenuItem(i);if(item!=null){return item}}}return this.kids[i]};this.hasSelectableItems=function(){for(var i=0;i<this.kids.length;i++){if(this.isItemSelectable(i)){return true}}return false};this.mouseExited=function(e){this.position.setOffset(-1)};this.getMenuAt=function(index){return this.menus[this.kids[index]]};this.setMenuAt=function(i,m){if(m==this){throw new Error("Menu cannot be sub-menu of its own")}if(this.isDecorative(i)){throw new Error("Decorative element cannot have a sub-menu")}var p=this.kids[i];if(p.activateSub!=null){var sub=this.menus[p];if(m!=null){if(sub==null){p.activateSub(true)}}else{if(sub!=null){p.activateSub(false)}}}if(this.parent!=null&&i==this.selectedIndex){this.select(-1)}this.menus[p]=m};this.indexMenuOf=function(menu){for(var i=0;i<this.kids.length;i++){if(this.menus[this.kids[i]]==menu){return i}}return -1};this.$canceled=function(m){if(this.$parentMenu!=null&&this.$canceled!=null){this.$parentMenu.$canceled(m)}};this.$topMenu=function(){if(this.parent!=null){var t=this;while((p=t.$parentMenu)!=null){t=p}return t}return null};this.$hideMenu=function(triggeredBy){if(this.parent!=null){var ch=this.$childMenu();if(ch!=null){ch.$hideMenu(triggeredBy)}this.removeMe()}};this.$childMenu=function(){if(this.parent!=null){for(var k in this.menus){var m=this.menus[k];if(m.$parentMenu==this){return m}}}return null};this.$showSubMenu=function(sub){sub.setLocation(this.x+this.width-10,this.y+this.kids[this.selectedIndex].y);sub.toPreferredSize();this.parent.add(sub);sub.requestFocus()};this.triggerSelectionByPos=function(i){return this.getMenuAt(i)!=null&&this.$triggeredByPointer}},function $clazz(){this.MenuItem=Class(pkg.MenuItem,[]);this.Line=Class(pkg.Line,[]);this.Line.prototype.$isDecorative=true},function(){this.menus={};this.decoratives={};this.$super(true)},function(d){this.$this();if(Array.isArray(d)){for(var i=0;i<d.length;i++){this.add(d[i])}}else{for(var k in d){if(d.hasOwnProperty(k)){var sub=d[k];this.add(k);if(sub!=null){this.setMenuAt(this.kids.length-1,zebra.instanceOf(sub,pkg.Menu)?sub:new pkg.Menu(sub))}}}}},function keyPressed(e){if(e.code==KE.ESCAPE){if(this.parent!=null){var p=this.$parentMenu;this.$canceled(this);this.$hideMenu(this);if(p!=null){p.requestFocus()}}}else{this.$super(e)}},function insert(i,ctr,c){if(zebra.isString(c)){return this.$super(i,ctr,(c=="-")?new this.$clazz.Line():new this.$clazz.MenuItem(c))}return this.$super(i,ctr,c)},function setParent(p){if(p!=null){this.select(-1);this.position.setOffset(-1)}else{this.$parentMenu=null}this.$super(p)},function addDecorative(c){this.decoratives[c]=true;this.$super(this.insert,this.kids.length,null,c)},function kidRemoved(i,c){if(this.decoratives[c]!==true){delete this.decoratives[c]}this.setMenuAt(i,null);this.$super(i,c)},function isItemSelectable(i){return this.$super(i)&&this.isDecorative(i)===false},function posChanged(target,prevOffset,prevLine,prevCol){var off=target.offset;if(off>=0){var rs=null;if(this.selectedIndex>=0&&off!=this.selectedIndex){var sub=this.getMenuAt(this.selectedIndex);if(sub!=null){sub.$hideMenu(this);rs=-1}}if(this.parent!=null&&off!=this.selectedIndex&&this.isItemSelectable(off)){if(this.triggerSelectionByPos(off)){rs=off}}if(rs!==null){this.select(rs)}}this.$super(target,prevOffset,prevLine,prevCol)},function fireSelected(prev){if(this.parent!=null&&this.selectedIndex>=0){var sub=this.getMenuAt(this.selectedIndex);if(sub!=null){if(sub.parent!=null){sub.$hideMenu(this)}else{sub.$parentMenu=this;this.$showSubMenu(sub)}}else{var k=this.kids[this.selectedIndex];if(k.itemSelected!=null){k.itemSelected()}var top=this.$topMenu();if(top!=null){top.$hideMenu(this)}}pkg.popup._.menuItemSelected(this,this.selectedIndex,this.kids[this.selectedIndex])}this.$super(prev)}]);pkg.Menubar=Class(pkg.Menu,[function $clazz(){this.MenuItem=Class(pkg.MenuItem,[function(c){this.$super(c);this.hideSub();this.getCheck().setVisible(false)}])},function $prototype(){this.$isActive=false;this.triggerSelectionByPos=function(i){return this.isItemSelectable(i)&&this.$isActive===true};this.$hideMenu=function(triggeredBy){var child=this.$childMenu();if(child!=null){child.$hideMenu(triggeredBy)}if(triggeredBy!=this){this.select(-1)}};this.$showSubMenu=function(menu){var d=this.getCanvas(),k=this.kids[this.selectedIndex],pop=d.getLayer(pkg.PopupLayer.ID);if(menu.hasSelectableItems()){var abs=L.toParentOrigin(0,0,k);menu.setLocation(abs.x,abs.y+k.height+1);menu.toPreferredSize();pop.add(menu);menu.requestFocus()}}},function $canceled(m){this.select(-1)},function select(i){var d=this.getCanvas(),pop=d!=null?d.getLayer(pkg.PopupLayer.ID):null;if(pop!=null){if(i<0){pop.setMenubar(null);this.$isActive=false}else{pop.setMenubar(this)}}this.$super(i)},function $select(i){this.$isActive=!this.$isActive;if(this.$isActive===false){i=-1}this.$super(i)}]);pkg.PopupLayer=Class(pkg.BaseLayer,[function $clazz(){this.ID="pop"},function $prototype(){this.mTop=this.mLeft=this.mBottom=this.mRight=0;this.layerMousePressed=function(x,y,mask){if(this.activeMenubar!=null&&y<=this.mBottom&&y>=this.mTop&&x>=this.mLeft&&x<=this.mRight){return false}if(this.getComponentAt(x,y)==this){if(this.activeMenubar!=null){this.activeMenubar.select(-1)}if(this.kids.length>0){this.removeAll()}return false}return true};this.isLayerActiveAt=function(x,y){return this.kids.length>0&&(this.activeMenubar==null||y>this.mBottom||y<this.mTop||x<this.mLeft||x>this.mRight)};this.childInputEvent=function(e){if(e.UID==pkg.InputEvent.KEY_UID&&e.ID==KE.PRESSED){var dc=L.getDirectChild(this,e.source);if(zebra.instanceOf(dc,pkg.Menu)&&this.activeMenubar!=null){var s=this.activeMenubar.selectedIndex;switch(e.code){case KE.RIGHT:if(s<this.activeMenubar.model.count()-1){this.activeMenubar.requestFocus();this.activeMenubar.position.seekLineTo(zebra.util.Position.DOWN)}break;case KE.LEFT:if(s>0){this.activeMenubar.requestFocus();this.activeMenubar.position.seekLineTo(zebra.util.Position.UP)}break}}}};this.calcPreferredSize=function(target){return{width:0,height:0}};this.setMenubar=function(mb){if(this.activeMenubar!=mb){this.removeAll();this.activeMenubar=mb;if(this.activeMenubar!=null){var abs=L.toParentOrigin(0,0,this.activeMenubar);this.mLeft=abs.x;this.mRight=this.mLeft+this.activeMenubar.width-1;this.mTop=abs.y;this.mBottom=this.mTop+this.activeMenubar.height-1}}};this.doLayout=function(target){var cnt=this.kids.length;for(var i=0;i<cnt;i++){var m=this.kids[i];if(zebra.instanceOf(m,pkg.Menu)){var ps=m.getPreferredSize(),xx=(m.x+ps.width>this.width)?this.width-ps.width:m.x,yy=(m.y+ps.height>this.height)?this.height-ps.height:m.y;m.setSize(ps.width,ps.height);if(xx<0){xx=0}if(yy<0){yy=0}m.setLocation(xx,yy)}}}},function(){this.activeMenubar=null;this.$super(pkg.PopupLayer.ID)}]);pkg.Tooltip=Class(pkg.Panel,[function $clazz(){this.borderColor="black";this.borderWidth=1;this.Label=Class(pkg.Label,[]);this.TooltipBorder=Class(pkg.View,[function $prototype(){this[""]=function(col,size){this.color=col!=null?col:"black";this.size=size==null?4:size;this.gap=2*this.size};this.paint=function(g,x,y,w,h,d){if(this.color!=null){var old=g.lineWidth;this.outline(g,x,y,w,h,d);g.setColor(this.color);g.lineWidth=this.size;g.stroke();g.lineWidth=old}};this.outline=function(g,x,y,w,h,d){g.beginPath();h-=2*this.size;w-=2*this.size;x+=this.size;y+=this.size;var w2=(w/2+0.5)|0,h3=(h/3+0.5)|0,w3_8=((3*w)/8+0.5)|0,h2_3=((2*h)/3+0.5)|0,h3=(h/3+0.5)|0,w4=(w/4+0.5)|0;g.moveTo(x+w2,y);g.quadraticCurveTo(x,y,x,y+h3);g.quadraticCurveTo(x,y+h2_3,x+w4,y+h2_3);g.quadraticCurveTo(x+w4,y+h,x,y+h);g.quadraticCurveTo(x+w3_8,y+h,x+w2,y+h2_3);g.quadraticCurveTo(x+w,y+h2_3,x+w,y+h3);g.quadraticCurveTo(x+w,y,x+w2,y);g.closePath();return true}}])},function(content){this.$super();this.setBorder(new this.$clazz.TooltipBorder(pkg.Tooltip.borderColor,pkg.Tooltip.borderWidth));this.add(zebra.instanceOf(content,pkg.Panel)?content:new this.$clazz.Label(content));this.toPreferredSize()},function recalc(){this.$contentPs=(this.kids.length===0?this.$super():this.kids[0].getPreferredSize())},function getBottom(){return this.$super()+this.$contentPs.height},function getTop(){return this.$super()+((this.$contentPs.height/6+0.5)|0)},function getLeft(){return this.$super()+((this.$contentPs.height/6+0.5)|0)},function getRight(){return this.$super()+((this.$contentPs.height/6+0.5)|0)}]);pkg.PopupManager=Class(pkg.Manager,[function $prototype(){this.mouseClicked=function(e){this.$popupMenuX=e.absX;this.$popupMenuY=e.absY;if((e.mask&MouseEvent.RIGHT_BUTTON)>0){var popup=null;if(e.source.popup!=null){popup=e.source.popup}else{if(e.source.getPopup!=null){popup=e.source.getPopup(e.source,e.x,e.y)}}if(popup!=null){popup.setLocation(this.$popupMenuX,this.$popupMenuY);e.source.getCanvas().getLayer(pkg.PopupLayer.ID).add(popup);popup.requestFocus()}}};this.hideTooltipByPress=true;this.mouseEntered=function(e){var c=e.source;if(c.getTooltip!=null||c.tooltip!=null){this.target=c;this.$targetTooltipLayer=c.getCanvas().getLayer(pkg.WinLayer.ID);this.$tooltipX=e.x;this.$tooltipY=e.y;this.$toolTask=task(this).run(this.showTooltipIn,this.showTooltipIn)}};this.mouseExited=function(e){if(this.target!=null){if(this.$toolTask!=null){this.$toolTask.shutdown()}this.target=null;this.hideTooltip()}};this.mouseMoved=function(e){if(this.target!=null){if(this.$toolTask!=null){this.$toolTask.run(this.$toolTask.ri)}this.$tooltipX=e.x;this.$tooltipY=e.y;if(this.tooltip!=null){this.hideTooltip()}}};this.run=function(t){if(this.tooltip==null){this.tooltip=this.target.tooltip!=null?this.target.tooltip:this.target.getTooltip(this.target,this.$tooltipX,this.$tooltipY);if(this.tooltip!=null){var p=L.toParentOrigin(this.$tooltipX,this.$tooltipY,this.target);this.tooltip.toPreferredSize();var tx=p.x,ty=p.y-this.tooltip.height,dw=this.$targetTooltipLayer.width;if(tx+this.tooltip.width>dw){tx=dw-this.tooltip.width-1}this.tooltip.setLocation(tx<0?0:tx,ty<0?0:ty);this.tooltip.winType="info";this.$targetTooltipLayer.add(this.tooltip)}}t.pause()};this.hideTooltip=function(){if(this.tooltip!=null){this.$targetTooltipLayer.remove(this.tooltip);this.tooltip=null}};this.mousePressed=function(e){if(this.hideTooltipByPress&&this.target!=null){if(this.$toolTask!=null){this.$toolTask.shutdown()}this.target=null;this.hideTooltip()}};this.mouseReleased=function(e){if(this.hideTooltipByPress&&this.target!=null){this.x=e.x;this.y=e.y;this.$toolTask=task(this).run(this.showTooltipIn,this.showTooltipIn)}}},function(){this.$super();this.$popupMenuX=this.$popupMenuY=0;this.$tooltipX=this.$tooltipY=0;this.$targetTooltipLayer=this.tooltip=this.target=null;this._=new (zebra.util.ListenersClass("menuItemSelected"));this.showTooltipIn=400}]);pkg.WindowTitleView=Class(pkg.View,[function $prototype(){this[""]=function(bg){this.radius=6;this.gap=this.radius;this.bg=bg!=null?bg:"#66CCFF"};this.paint=function(g,x,y,w,h,d){this.outline(g,x,y,w,h,d);g.setColor(this.bg);g.fill()};this.outline=function(g,x,y,w,h,d){g.beginPath();g.moveTo(x+this.radius,y);g.lineTo(x+w-this.radius*2,y);g.quadraticCurveTo(x+w,y,x+w,y+this.radius);g.lineTo(x+w,y+h);g.lineTo(x,y+h);g.lineTo(x,y+this.radius);g.quadraticCurveTo(x,y,x+this.radius,y);return true}}])})(zebra("ui"),zebra.Class);(function(pkg,Class,ui){var L=zebra.layout,Cursor=ui.Cursor,KeyEvent=ui.KeyEvent,CURSORS=[];CURSORS[L.LEFT]=Cursor.W_RESIZE;CURSORS[L.RIGHT]=Cursor.E_RESIZE;CURSORS[L.TOP]=Cursor.N_RESIZE;CURSORS[L.BOTTOM]=Cursor.S_RESIZE;CURSORS[L.TLEFT]=Cursor.NW_RESIZE;CURSORS[L.TRIGHT]=Cursor.NE_RESIZE;CURSORS[L.BLEFT]=Cursor.SW_RESIZE;CURSORS[L.BRIGHT]=Cursor.SE_RESIZE;CURSORS[L.CENTER]=Cursor.MOVE;CURSORS[L.NONE]=Cursor.DEFAULT;pkg.ShaperBorder=Class(ui.View,[function $prototype(){this.color="blue";this.gap=7;function contains(x,y,gx,gy,ww,hh){return gx<=x&&(gx+ww)>x&&gy<=y&&(gy+hh)>y}this.paint=function(g,x,y,w,h,d){var cx=~~((w-this.gap)/2),cy=~~((h-this.gap)/2);g.setColor(this.color);g.beginPath();g.rect(x,y,this.gap,this.gap);g.rect(x+cx,y,this.gap,this.gap);g.rect(x,y+cy,this.gap,this.gap);g.rect(x+w-this.gap,y,this.gap,this.gap);g.rect(x,y+h-this.gap,this.gap,this.gap);g.rect(x+cx,y+h-this.gap,this.gap,this.gap);g.rect(x+w-this.gap,y+cy,this.gap,this.gap);g.rect(x+w-this.gap,y+h-this.gap,this.gap,this.gap);g.fill();g.beginPath();g.rect(x+~~(this.gap/2),y+~~(this.gap/2),w-this.gap,h-this.gap);g.stroke()};this.detectAt=function(target,x,y){var gap=this.gap,gap2=gap*2,w=target.width,h=target.height;if(contains(x,y,gap,gap,w-gap2,h-gap2)){return L.CENTER}if(contains(x,y,0,0,gap,gap)){return L.TLEFT}if(contains(x,y,0,h-gap,gap,gap)){return L.BLEFT}if(contains(x,y,w-gap,0,gap,gap)){return L.TRIGHT}if(contains(x,y,w-gap,h-gap,gap,gap)){return L.BRIGHT}var mx=~~((w-gap)/2);if(contains(x,y,mx,0,gap,gap)){return L.TOP}if(contains(x,y,mx,h-gap,gap,gap)){return L.BOTTOM}var my=~~((h-gap)/2);if(contains(x,y,0,my,gap,gap)){return L.LEFT}return contains(x,y,w-gap,my,gap,gap)?L.RIGHT:L.NONE}}]);pkg.InsetsArea=Class([function $prototype(){this.top=this.right=this.left=this.bottom=6;this.detectAt=function(c,x,y){var t=0,b1=false,b2=false;if(x<this.left){t+=L.LEFT}else{if(x>(c.width-this.right)){t+=L.RIGHT}else{b1=true}}if(y<this.top){t+=L.TOP}else{if(y>(c.height-this.bottom)){t+=L.BOTTOM}else{b2=true}}return b1&&b2?L.CENTER:t}}]);pkg.ShaperPan=Class(ui.Panel,ui.Composite,[function $prototype(){this.minHeight=this.minWidth=12;this.canHaveFocus=this.isResizeEnabled=this.isMoveEnabled=true;this.state=null;this.getCursorType=function(t,x,y){return this.kids.length>0?CURSORS[this.shaperBr.detectAt(t,x,y)]:null};this.keyPressed=function(e){if(this.kids.length>0){var b=(e.mask&KeyEvent.M_SHIFT)>0,c=e.code,dx=(c==KeyEvent.LEFT?-1:(c==KeyEvent.RIGHT?1:0)),dy=(c==KeyEvent.UP?-1:(c==KeyEvent.DOWN?1:0)),w=this.width+dx,h=this.height+dy,x=this.x+dx,y=this.y+dy;if(b){if(this.isResizeEnabled&&w>this.shaperBr.gap*2&&h>this.shaperBr.gap*2){this.setSize(w,h)}}else{if(this.isMoveEnabled){var ww=this.width,hh=this.height,p=this.parent;if(x+ww/2>0&&y+hh/2>0&&x<p.width-ww/2&&y<p.height-hh/2){this.setLocation(x,y)}}}}};this.mouseDragStarted=function(e){this.state=null;if(this.isResizeEnabled||this.isMoveEnabled){var t=this.shaperBr.detectAt(this,e.x,e.y);if((this.isMoveEnabled===false&&t==L.CENTER)||(this.isResizeEnabled===false&&t!=L.CENTER)){return}this.state={top:((t&L.TOP)>0?1:0),left:((t&L.LEFT)>0?1:0),right:((t&L.RIGHT)>0?1:0),bottom:((t&L.BOTTOM)>0?1:0)};if(this.state!=null){this.px=e.absX;this.py=e.absY}}};this.mouseDragged=function(e){if(this.state!=null){var dy=(e.absY-this.py),dx=(e.absX-this.px),s=this.state,nw=this.width-dx*s.left+dx*s.right,nh=this.height-dy*s.top+dy*s.bottom;if(nw>=this.minWidth&&nh>=this.minHeight){this.px=e.absX;this.py=e.absY;if((s.top+s.right+s.bottom+s.left)===0){this.setLocation(this.x+dx,this.y+dy)}else{this.setSize(nw,nh);this.setLocation(this.x+dx*s.left,this.y+dy*s.top)}}}};this.setColor=function(b,color){this.colors[b?1:0]=color;this.shaperBr.color=this.colors[this.hasFocus()?1:0];this.repaint()}},function(t){this.$super(new L.BorderLayout());this.px=this.py=0;this.shaperBr=new pkg.ShaperBorder();this.colors=["lightGray","blue"];this.shaperBr.color=this.colors[0];this.setBorder(this.shaperBr);if(t!=null){this.add(t)}},function insert(i,constr,d){if(this.kids.length>0){this.removeAll()}var top=this.getTop(),left=this.getLeft();if(d.width===0||d.height===0){d.toPreferredSize()}this.setLocation(d.x-left,d.y-top);this.setSize(d.width+left+this.getRight(),d.height+top+this.getBottom());this.$super(i,L.CENTER,d)},function focused(){this.$super();this.shaperBr.color=this.colors[this.hasFocus()?1:0];this.repaint()}]);pkg.FormTreeModel=Class(zebra.data.TreeModel,[function $prototype(){this.buildModel=function(comp,root){var b=this.exclude&&this.exclude(comp),item=b?root:this.createItem(comp);for(var i=0;i<comp.kids.length;i++){var r=this.buildModel(comp.kids[i],item);if(r){r.parent=item;item.kids.push(r)}}return b?null:item};this.itemByComponent=function(c,r){if(r==null){r=this.root}if(r.comp==c){return c}for(var i=0;i<r.kids.length;i++){var item=this.itemByComponent(c,r.kids[i]);if(item!=null){return item}}return null};this.createItem=function(comp){var name=comp.$clazz.$name;if(name==null){name=comp.toString()}var index=name.lastIndexOf("."),item=new zebra.data.Item(index>0?name.substring(index+1):name);item.comp=comp;return item}},function(target){this.$super(this.buildModel(target,null))}])})(zebra("ui.designer"),zebra.Class,zebra("ui"));(function(pkg,Class){pkg.HtmlElement=Class(pkg.Panel,[function $prototype(){this.isLocAdjusted=false;this.canvas=null;this.ePsW=this.ePsH=0;this.setFont=function(f){this.element.style.font=f.toString();this.vrp()};this.setColor=function(c){this.element.style.color=c.toString()};this.adjustLocation=function(){if(this.isLocAdjusted===false&&this.canvas!=null){var visibility=this.element.style.visibility;this.element.style.visibility="hidden";if(zebra.instanceOf(this.parent,pkg.HtmlElement)){this.element.style.top=""+this.y+"px";this.element.style.left=""+this.x+"px"}else{var a=zebra.layout.toParentOrigin(0,0,this);this.element.style.top=""+(this.canvas.offy+a.y)+"px";this.element.style.left=""+(this.canvas.offx+a.x)+"px"}this.isLocAdjusted=true;this.element.style.visibility=visibility}};this.calcPreferredSize=function(target){return{width:this.ePsW,height:this.ePsH}};var $store=["visibility","paddingTop","paddingLeft","paddingBottom","paddingRight","border","borderStyle","borderWidth","borderTopStyle","borderTopWidth","borderBottomStyle","borderBottomWidth","borderLeftStyle","borderLeftWidth","borderRightStyle","borderRightWidth","width","height"];this.recalc=function(){var e=this.element,vars={};for(var i=0;i<$store.length;i++){var k=$store[i];vars[k]=e.style[k]}e.style.visibility="hidden";e.style.padding="0px";e.style.border="none";e.style.width="auto";e.style.height="auto";this.ePsW=e.offsetWidth;this.ePsH=e.offsetHeight;for(var k in vars){var v=vars[k];if(v!=null){e.style[k]=v}}this.setSize(this.width,this.height)};this.setContent=function(content){this.element.innerHTML=content;this.vrp()};this.setStyles=function(styles){for(var k in styles){this.setStyle(k,styles[k])}};this.setStyle=function(name,value){name=name.trim();var i=name.indexOf(":");if(i>0){if(zebra[name.substring(0,i)]==null){return}name=name.substring(i+1)}this.element.style[name]=value;this.vrp()};this.setAttribute=function(name,value){this.element.setAttribute(name,value)};this.isInInvisibleState=function(){if(this.width<=0||this.height<=0||this.parent==null||this.getCanvas()==null){return true}var p=this.parent;while(p!=null&&p.isVisible===true&&p.width>0&&p.height>0){p=p.parent}return p!=null||pkg.$cvp(this)==null};this.paint=function(g){if(this.element.style.visibility=="hidden"){this.element.style.visibility="visible"}}},function(e){e=this.element=zebra.isString(e)?document.createElement(e):e;e.setAttribute("id",this.toString());e.style.visibility="hidden";this.$super();var $this=this;this.globalCompListener={compShown:function(c){if(c!=$this&&c.isVisible===false&&zebra.layout.isAncestorOf(c,$this)){$this.element.style.visibility="hidden"}},compMoved:function(c,px,py){if(zebra.layout.isAncestorOf(c,$this)){$this.isLocAdjusted=false;$this.adjustLocation()}if(c!=$this&&$this.isInInvisibleState()){$this.element.style.visibility="hidden"}},compRemoved:function(p,i,c){if(c!=$this&&zebra.layout.isAncestorOf(c,$this)){$this.element.style.visibility="hidden"}},compSized:function(c,pw,ph){if(c!=$this&&zebra.layout.isAncestorOf(c,$this)&&$this.isInInvisibleState()){$this.element.style.visibility="hidden"}}};this.globalWinListener={winActivated:function(layer,win,isActive){if(zebra.layout.isAncestorOf(win,$this)==false){$this.element.style.visibility}}};if(zebra.isTouchable===false){e.onmousemove=function(ee){if($this.canvas!=null){$this.canvas.$mouseMoved(1,{target:$this.canvas.canvas,pageX:ee.pageX,pageY:ee.pageY})}};e.onmousedown=function(ee){if($this.canvas!=null){$this.canvas.$mousePressed(1,{target:$this.canvas.canvas,pageX:ee.pageX,pageY:ee.pageY})}};e.onmouseup=function(ee){if($this.canvas!=null){$this.canvas.$mouseReleased(1,{target:$this.canvas.canvas,pageX:ee.pageX,pageY:ee.pageY},ee.button===0?pkg.MouseEvent.LEFT_BUTTON:(ee.button==2?pkg.MouseEvent.RIGHT_BUTTON:0))}}}e.addEventListener("focus",function(ee){$this.element.canvas=$this.canvas;zebra.ui.focusManager.requestFocus($this)},false);e.addEventListener("blur",function(ee){$this.element.canvas=null;if($this.canvas!=null){setTimeout(function(){var fo=zebra.ui.focusManager.focusOwner;if(($this.canvas!=null&&document.activeElement!=$this.canvas.canvas)&&(document.activeElement!=null&&$this.canvas!=document.activeElement.canvas)){zebra.ui.focusManager.requestFocus(null)}},100)}},false);e.onkeydown=function(ee){if($this.canvas!=null){var pfo=zebra.ui.focusManager.focusOwner;$this.canvas.$keyPressed({keyCode:ee.keyCode,target:ee.target,altKey:ee.altKey,shiftKey:ee.shiftKey,ctrlKey:ee.ctrlKey,metaKey:ee.metaKey,preventDefault:function(){}});var nfo=zebra.ui.focusManager.focusOwner;if(nfo!=pfo){ee.preventDefault();if(nfo!=null&&zebra.instanceOf(nfo,pkg.HtmlElement)&&document.activeElement!=nfo.element){nfo.element.focus()}else{$this.canvas.canvas.focus()}}}};e.onkeyup=function(ee){if($this.canvas!=null){$this.canvas.$keyReleased(ee)}};e.onkeypress=function(ee){if($this.canvas!=null){$this.canvas.$keyTyped({keyCode:ee.keyCode,target:ee.target,altKey:ee.altKey,shiftKey:ee.shiftKey,ctrlKey:ee.ctrlKey,metaKey:ee.metaKey,preventDefault:function(){}})}}},function focused(){if(this.hasFocus()){var canvas=this.getCanvas(),pfo=canvas.$prevFocusOwner;if(pfo==null||zebra.instanceOf(pfo,pkg.HtmlElement)===false){this.element.focus()}}this.$super()},function setBorder(b){b=pkg.$view(b);if(b==null){this.element.style.border="none"}else{var e=this.element;e.style.border="0px solid transparent";e.style.borderTopStyle="solid";e.style.borderTopColor="transparent";e.style.borderTopWidth=""+b.getTop()+"px";e.style.borderLeftStyle="solid";e.style.borderLeftColor="transparent";e.style.borderLeftWidth=""+b.getLeft()+"px";e.style.borderBottomStyle="solid";e.style.borderBottomColor="transparent";e.style.borderBottomWidth=""+b.getBottom()+"px";e.style.borderRightStyle="solid";e.style.borderRightColor="transparent";e.style.borderRightWidth=""+b.getRight()+"px"}this.$super(b)},function setPadding(t,l,b,r){if(arguments.length==1){l=b=r=t}var e=this.element;e.style.paddingTop=""+t+"px";e.style.paddingLeft=""+l+"px";e.style.paddingRight=""+r+"px";e.style.paddingBottom=""+b+"px";this.$super.apply(this,arguments)},function setVisible(b){if(this.isInInvisibleState()){this.element.style.visibility="hidden"}else{this.element.style.visibility=b?"visible":"hidden"}this.$super(b)},function setEnabled(b){this.$super(b);this.element.disabled=!b},function setSize(w,h){this.$super(w,h);var visibility=this.element.style.visibility;this.element.style.visibility="hidden";this.element.style.width=""+w+"px";this.element.style.height=""+h+"px";var dx=this.element.offsetWidth-w,dy=this.element.offsetHeight-h;this.element.style.width=""+(w-dx)+"px";this.element.style.height=""+(h-dy)+"px";if(this.isInInvisibleState()){this.element.style.visibility="hidden"}else{this.element.style.visibility=visibility}},function setLocation(x,y){this.$super(x,y);this.isLocAdjusted=false},function validate(){if(this.canvas==null&&this.parent!=null){this.canvas=this.getCanvas()}if(this.canvas!=null&&this.isLocAdjusted===false){this.adjustLocation()}this.$super()},function setParent(p){this.$super(p);if(p==null){if(this.element.parentNode!=null){this.element.parentNode.removeChild(this.element)}this.element.style.visibility="hidden";pkg.events.removeComponentListener(this.globalCompListener)}else{if(zebra.instanceOf(p,pkg.HtmlElement)){p.element.appendChild(this.element)}else{document.body.appendChild(this.element)}if(this.isInInvisibleState()){this.element.style.visibility="hidden"}else{this.element.style.visibility=this.isVisible?"visible":"hidden"}pkg.events.addComponentListener(this.globalCompListener)}this.isLocAdjusted=false;this.canvas=p!=null?this.getCanvas():null}]);pkg.HtmlTextInput=Class(pkg.HtmlElement,[function $prototype(){this.canHaveFocus=true;this.getValue=function(){return this.element.value.toString()};this.setValue=function(t){if(this.element.value!=t){this.element.value=t;this.vrp()}}},function(text,elementName){if(text==null){text=""}this.$super(elementName);this.element.setAttribute("tabindex",0);this.setValue(text)}]);pkg.HtmlContent=Class(pkg.HtmlElement,[function(){this.$super("div");this.setStyle("overflow","hidden")},function loadContent(url){var c=zebra.io.GET(url);this.setContent(c);this.vrp()}]);pkg.HtmlTextField=Class(pkg.HtmlTextInput,[function(text){this.$super(text,"input");this.element.setAttribute("type","text")}]);pkg.HtmlTextArea=Class(pkg.HtmlTextInput,[function setResizeable(b){if(b===false){this.setStyle("resize","none")}else{this.setStyle("resize","both")}},function(text){this.$super(text,"textarea");this.element.setAttribute("rows",10)}])})(zebra("ui"),zebra.Class);(function(pkg,Class,ui){var KE=ui.KeyEvent,IM=function(b){this.width=this.height=this.x=this.y=this.viewHeight=0;this.viewWidth=-1;this.isOpen=b},TreeListeners=zebra.util.ListenersClass("toggled","selected");pkg.DefEditors=Class([function(){this.tf=new ui.TextField(new zebra.data.SingleLineTxt(""));this.tf.setBackground("white");this.tf.setBorder(null);this.tf.setPadding(0)},function $prototype(){this.getEditor=function(src,item){var o=item.value;this.tf.setValue((o==null)?"":o.toString());return this.tf};this.fetchEditedValue=function(src,editor){return editor.view.target.getValue()};this.shouldStartEdit=function(src,e){return(e.ID==ui.MouseEvent.CLICKED&&e.clicks>1)||(e.ID==KE.PRESSED&&e.code==KE.ENTER)}}]);pkg.DefViews=Class([function $prototype(){this.getView=function(d,obj){if(obj.value&&obj.value.paint!=null){return obj.value}this.render.setValue(obj.value==null?"<null>":obj.value);return this.render};this.setFont=function(f){this.render.setFont(f)};this.setColor=function(c){this.render.setColor(c)};this[""]=function(color,font){this.render=new ui.StringRender("");zebra.properties(this,this.$clazz);if(color!=null){this.setColor(color)}if(font!=null){this.setFont(font)}}}]);pkg.Tree=Class(ui.Panel,[function $prototype(){this.itemGapY=this.gapx=this.gapy=2;this.itemGapX=4;this.canHaveFocus=true;this.childInputEvent=function(e){if(e.ID==KE.PRESSED){if(e.code==KE.ESCAPE){this.stopEditing(false)}else{if(e.code==KE.ENTER){if((zebra.instanceOf(e.source,ui.TextField)===false)||(zebra.instanceOf(e.source.view.target,zebra.data.SingleLineTxt))){this.stopEditing(true)}}}}};this.isInvalidatedByChild=function(c){return false};this.catchScrolled=function(psx,psy){this.stopEditing(true);if(this.firstVisible==null){this.firstVisible=this.model.root}this.firstVisible=(this.y<psy)?this.nextVisible(this.firstVisible):this.prevVisible(this.firstVisible);this.repaint()};this.isOpen=function(i){this.validate();return this.isOpen_(i)};this.getItemMetrics=function(i){this.validate();return this.getIM(i)};this.laidout=function(){this.vVisibility()};this.vVisibility=function(){if(this.model==null){this.firstVisible=null}else{var nva=ui.$cvp(this,{});if(nva==null){this.firstVisible=null}else{if(this._isVal===false||(this.visibleArea==null||this.visibleArea.x!=nva.x||this.visibleArea.y!=nva.y||this.visibleArea.width!=nva.width||this.visibleArea.height!=nva.height)){this.visibleArea=nva;if(this.firstVisible!=null){this.firstVisible=this.findOpened(this.firstVisible);this.firstVisible=this.isAbove(this.firstVisible)?this.nextVisible(this.firstVisible):this.prevVisible(this.firstVisible)}else{this.firstVisible=(-this.scrollManager.getSY()>~~(this.maxh/2))?this.prevVisible(this.findLast(this.model.root)):this.nextVisible(this.model.root)}}}}this._isVal=true};this.recalc=function(){this.maxh=this.maxw=0;if(this.model!=null&&this.model.root!=null){this.recalc_(this.getLeft(),this.getTop(),null,this.model.root,true);this.maxw-=this.getLeft();this.maxh-=this.gapy}};this.getViewBounds=function(root){var metrics=this.getIM(root),toggle=this.getToggleBounds(root),image=this.getImageBounds(root);toggle.x=image.x+image.width+(image.width>0||toggle.width>0?this.gapx:0);toggle.y=metrics.y+~~((metrics.height-metrics.viewHeight)/2);toggle.width=metrics.viewWidth;toggle.height=metrics.viewHeight;return toggle};this.getToggleBounds=function(root){var node=this.getIM(root),d=this.getToggleSize(root);return{x:node.x,y:node.y+~~((node.height-d.height)/2),width:d.width,height:d.height}};this.getToggleView=function(i){return i.kids.length>0?(this.getIM(i).isOpen?this.views.on:this.views.off):null};this.recalc_=function(x,y,parent,root,isVis){var node=this.getIM(root);if(isVis===true){if(node.viewWidth<0){var viewSize=this.provider.getView(this,root).getPreferredSize();node.viewWidth=viewSize.width===0?5:viewSize.width+this.itemGapX*2;node.viewHeight=viewSize.height+this.itemGapY*2}var imageSize=this.getImageSize(root),toggleSize=this.getToggleSize(root);if(parent!=null){var pImg=this.getImageBounds(parent);x=pImg.x+~~((pImg.width-toggleSize.width)/2)}node.x=x;node.y=y;node.width=toggleSize.width+imageSize.width+node.viewWidth+(toggleSize.width>0?this.gapx:0)+(imageSize.width>0?this.gapx:0);node.height=Math.max(((toggleSize.height>imageSize.height)?toggleSize.height:imageSize.height),node.viewHeight);if(node.x+node.width>this.maxw){this.maxw=node.x+node.width}this.maxh+=(node.height+this.gapy);x=node.x+toggleSize.width+(toggleSize.width>0?this.gapx:0);y+=(node.height+this.gapy)}var b=node.isOpen&&isVis===true;if(b){var count=root.kids.length;for(var i=0;i<count;i++){y=this.recalc_(x,y,root,root.kids[i],b)}}return y};this.isOpen_=function(i){return i==null||(i.kids.length>0&&this.getIM(i).isOpen&&this.isOpen_(i.parent))};this.getIM=function(i){var node=this.nodes[i];if(typeof node==="undefined"){node=new IM(this.isOpenVal);this.nodes[i]=node}return node};this.getItemAt=function(root,x,y){this.validate();if(arguments.length<3){root=this.model.root}if(this.firstVisible!=null&&y>=this.visibleArea.y&&y<this.visibleArea.y+this.visibleArea.height){var dx=this.scrollManager.getSX(),dy=this.scrollManager.getSY(),found=this.getItemAtInBranch(root,x-dx,y-dy);if(found!=null){return found}var parent=root.parent;while(parent!=null){var count=parent.kids.length;for(var i=parent.kids.indexOf(root)+1;i<count;i++){found=this.getItemAtInBranch(parent.kids[i],x-dx,y-dy);if(found!=null){return found}}root=parent;parent=root.parent}}return null};this.getItemAtInBranch=function(root,x,y){if(root!=null){var node=this.getIM(root);if(x>=node.x&&y>=node.y&&x<node.x+node.width&&y<node.y+node.height+this.gapy){return root}if(this.isOpen_(root)){for(var i=0;i<root.kids.length;i++){var res=this.getItemAtInBranch(root.kids[i],x,y);if(res!=null){return res}}}}return null};this.getImageView=function(i){return i.kids.length>0?(this.getIM(i).isOpen?this.views.open:this.views.close):this.views.leaf};this.getImageSize=function(i){var v=i.kids.length>0?(this.getIM(i).isOpen?this.viewSizes.open:this.viewSizes.close):this.viewSizes.leaf;return v?v:{width:0,height:0}};this.getImageBounds=function(root){var node=this.getIM(root),id=this.getImageSize(root),td=this.getToggleSize(root);return{x:node.x+td.width+(td.width>0?this.gapx:0),y:node.y+~~((node.height-id.height)/2),width:id.width,height:id.height}};this.getImageY=function(root){var node=this.getIM(root);return node.y+~~((node.height-this.getImageSize(root).height)/2)};this.getToggleY=function(root){var node=this.getIM(root);return node.y+~~((node.height-this.getToggleSize(root).height)/2)};this.getToggleSize=function(i){return this.isOpen_(i)?this.viewSizes.on:this.viewSizes.off};this.isAbove=function(i){var node=this.getIM(i);return node.y+node.height+this.scrollManager.getSY()<this.visibleArea.y};this.findOpened=function(item){var parent=item.parent;return(parent==null||this.isOpen_(parent))?item:this.findOpened(parent)};this.findNext=function(item){if(item!=null){if(item.kids.length>0&&this.isOpen_(item)){return item.kids[0]}var parent=null;while((parent=item.parent)!=null){var index=parent.kids.indexOf(item);if(index+1<parent.kids.length){return parent.kids[index+1]}item=parent}}return null};this.findPrev=function(item){if(item!=null){var parent=item.parent;if(parent!=null){var index=parent.kids.indexOf(item);return(index-1>=0)?this.findLast(parent.kids[index-1]):parent}}return null};this.findLast=function(item){return this.isOpen_(item)&&item.kids.length>0?this.findLast(item.kids[item.kids.length-1]):item};this.prevVisible=function(item){if(item==null||this.isAbove(item)){return this.nextVisible(item)}var parent=null;while((parent=item.parent)!=null){for(var i=parent.kids.indexOf(item)-1;i>=0;i--){var child=parent.kids[i];if(this.isAbove(child)){return this.nextVisible(child)}}item=parent}return item};this.isVerVisible=function(item){if(this.visibleArea==null){return false}var node=this.getIM(item),yy1=node.y+this.scrollManager.getSY(),yy2=yy1+node.height-1,by=this.visibleArea.y+this.visibleArea.height;return((this.visibleArea.y<=yy1&&yy1<by)||(this.visibleArea.y<=yy2&&yy2<by)||(this.visibleArea.y>yy1&&yy2>=by))};this.nextVisible=function(item){if(item==null||this.isVerVisible(item)){return item}var res=this.nextVisibleInBranch(item),parent=null;if(res!=null){return res}while((parent=item.parent)!=null){var count=parent.kids.length;for(var i=parent.kids.indexOf(item)+1;i<count;i++){res=this.nextVisibleInBranch(parent.kids[i]);if(res!=null){return res}}item=parent}return null};this.nextVisibleInBranch=function(item){if(this.isVerVisible(item)){return item}if(this.isOpen_(item)){for(var i=0;i<item.kids.length;i++){var res=this.nextVisibleInBranch(item.kids[i]);if(res!=null){return res}}}return null};this.paintTree=function(g,item){this.paintBranch(g,item);var parent=null;while((parent=item.parent)!=null){this.paintChild(g,parent,parent.kids.indexOf(item)+1);item=parent}};this.paintBranch=function(g,root){if(root==null){return false}var node=this.getIM(root),dx=this.scrollManager.getSX(),dy=this.scrollManager.getSY(),va=this.visibleArea;if(zebra.util.isIntersect(node.x+dx,node.y+dy,node.width,node.height,va.x,va.y,va.width,va.height)){var toggle=this.getToggleBounds(root),toggleView=this.getToggleView(root);if(toggleView!=null){toggleView.paint(g,toggle.x,toggle.y,toggle.width,toggle.height,this)}var image=this.getImageBounds(root);if(image.width>0){this.getImageView(root).paint(g,image.x,image.y,image.width,image.height,this)}var vx=image.x+image.width+(image.width>0||toggle.width>0?this.gapx:0),vy=node.y+~~((node.height-node.viewHeight)/2);if(this.selected==root&&root!=this.editedItem){var selectView=this.views[this.hasFocus()?"aselect":"iselect"];if(selectView!=null){selectView.paint(g,vx,vy,node.viewWidth,node.viewHeight,this)}}if(root!=this.editedItem){var vvv=this.provider.getView(this,root),vvvps=vvv.getPreferredSize();vvv.paint(g,vx+this.itemGapX,vy+this.itemGapY,vvvps.width,vvvps.height,this)}if(this.lnColor!=null){g.setColor(this.lnColor);var x1=toggle.x+(toggleView==null?~~(toggle.width/2)+1:toggle.width),yy=toggle.y+~~(toggle.height/2)+0.5;g.beginPath();g.moveTo(x1-1,yy);g.lineTo(image.x,yy);g.stroke()}}else{if(node.y+dy>this.visibleArea.y+this.visibleArea.height||node.x+dx>this.visibleArea.x+this.visibleArea.width){return false}}return this.paintChild(g,root,0)};this.y_=function(item,isStart){var ty=this.getToggleY(item),th=this.getToggleSize(item).height,dy=this.scrollManager.getSY(),y=(item.kids.length>0)?(isStart?ty+th:ty-1):ty+~~(th/2);if(y+dy<0){y=-dy-1}else{if(y+dy>this.height){y=this.height-dy}}return y};this.paintChild=function(g,root,index){var b=this.isOpen_(root),vs=this.viewSizes;if(root==this.firstVisible&&this.lnColor!=null){g.setColor(this.lnColor);var y1=this.getTop(),y2=this.y_(root,false),xx=this.getIM(root).x+~~((b?vs.on.width:vs.off.width)/2);g.beginPath();g.moveTo(xx+0.5,y1);g.lineTo(xx+0.5,y2);g.stroke()}if(b&&root.kids.length>0){var firstChild=root.kids[0];if(firstChild==null){return true}var x=this.getIM(firstChild).x+~~((this.isOpen_(firstChild)?vs.on.width:vs.off.width)/2);var count=root.kids.length;if(index<count){var y=(index>0)?this.y_(root.kids[index-1],true):this.getImageY(root)+this.getImageSize(root).height;for(var i=index;i<count;i++){var child=root.kids[i];if(this.lnColor!=null){g.setColor(this.lnColor);g.beginPath();g.moveTo(x+0.5,y);g.lineTo(x+0.5,this.y_(child,false));g.stroke();y=this.y_(child,true)}if(this.paintBranch(g,child)===false){if(this.lnColor!=null&&i+1!=count){g.setColor(this.lnColor);g.beginPath();g.moveTo(x+0.5,y);g.lineTo(x+0.5,this.height-this.scrollManager.getSY());g.stroke()}return false}}}}return true};this.nextPage=function(item,dir){var sum=0,prev=item;while(item!=null&&sum<this.visibleArea.height){sum+=(this.getIM(item).height+this.gapy);prev=item;item=dir<0?this.findPrev(item):this.findNext(item)}return prev};this.se=function(item,e){if(item!=null){this.stopEditing(true);if(this.editors!=null&&this.editors.shouldStartEdit(item,e)){this.startEditing(item);return true}}return false};this.paint=function(g){if(this.model!=null){this.vVisibility();if(this.firstVisible!=null){var sx=this.scrollManager.getSX(),sy=this.scrollManager.getSY();try{g.translate(sx,sy);this.paintTree(g,this.firstVisible)}finally{g.translate(-sx,-sy)}}}};this.select=function(item){if(this.isSelectable&&item!=this.selected){var old=this.selected,m=null;this.selected=item;if(this.selected!=null){this.makeVisible(this.selected)}this._.selected(this,this.selected);if(old!=null&&this.isVerVisible(old)){m=this.getItemMetrics(old);this.repaint(m.x+this.scrollManager.getSX(),m.y+this.scrollManager.getSY(),m.width,m.height)}if(this.selected!=null&&this.isVerVisible(this.selected)){m=this.getItemMetrics(this.selected);this.repaint(m.x+this.scrollManager.getSX(),m.y+this.scrollManager.getSY(),m.width,m.height)}}};this.makeVisible=function(item){this.validate();var r=this.getViewBounds(item);this.scrollManager.makeVisible(r.x,r.y,r.width,r.height)};this.mouseClicked=function(e){if(this.se(this.pressedItem,e)){this.pressedItem=null}else{if(this.selected!=null&&e.clicks>1&&e.isActionMask()&&this.getItemAt(this.firstVisible,e.x,e.y)==this.selected){this.toggle(this.selected)}}};this.mouseReleased=function(e){if(this.se(this.pressedItem,e)){this.pressedItem=null}};this.keyTyped=function(e){if(this.selected!=null){switch(e.ch){case"+":if(this.isOpen(this.selected)===false){this.toggle(this.selected)}break;case"-":if(this.isOpen(this.selected)){this.toggle(this.selected)}break}}};this.keyPressed=function(e){var newSelection=null;switch(e.code){case KE.DOWN:case KE.RIGHT:newSelection=this.findNext(this.selected);break;case KE.UP:case KE.LEFT:newSelection=this.findPrev(this.selected);break;case KE.HOME:if(e.isControlPressed()){this.select(this.model.root)}break;case KE.END:if(e.isControlPressed()){this.select(this.findLast(this.model.root))}break;case KE.PAGEDOWN:if(this.selected!=null){this.select(this.nextPage(this.selected,1))}break;case KE.PAGEUP:if(this.selected!=null){this.select(this.nextPage(this.selected,-1))}break}if(newSelection!=null){this.select(newSelection)}this.se(this.selected,e)};this.mousePressed=function(e){this.pressedItem=null;this.stopEditing(true);if(this.firstVisible!=null&&e.isActionMask()){var x=e.x,y=e.y,root=this.getItemAt(this.firstVisible,x,y);if(root!=null){x-=this.scrollManager.getSX();y-=this.scrollManager.getSY();var r=this.getToggleBounds(root);if(x>=r.x&&x<r.x+r.width&&y>=r.y&&y<r.y+r.height){if(root.kids.length>0){this.toggle(root)}}else{if(x>r.x+r.width){this.select(root)}if(this.se(root,e)===false){this.pressedItem=root}}}}};this.toggleAll=function(root,b){var model=this.model;if(root.kids.length>0){if(this.getItemMetrics(root).isOpen!=b){this.toggle(root)}for(var i=0;i<root.kids.length;i++){this.toggleAll(root.kids[i],b)}}};this.toggle=function(item){if(item.kids.length>0){this.stopEditing(true);this.validate();var node=this.getIM(item);node.isOpen=(node.isOpen?false:true);this.invalidate();this._.toggled(this,item);if(!node.isOpen&&this.selected!=null){var parent=this.selected;do{parent=parent.parent}while(parent!=item&&parent!=null);if(parent==item){this.select(item)}}this.repaint()}};this.itemInserted=function(target,item){this.stopEditing(false);this.vrp()};this.itemRemoved=function(target,item){if(item==this.firstVisible){this.firstVisible=null}this.stopEditing(false);if(item==this.selected){this.select(null)}delete this.nodes[item];this.vrp()};this.itemModified=function(target,item){var node=this.getIM(item);if(node!=null){node.viewWidth=-1}this.vrp()};this.startEditing=function(item){this.stopEditing(true);if(this.editors!=null){var editor=this.editors.getEditor(this,item);if(editor!=null){this.editedItem=item;var b=this.getViewBounds(this.editedItem),ps=editor.getPreferredSize();editor.setLocation(b.x+this.scrollManager.getSX(),b.y-~~((ps.height-b.height)/2)+this.scrollManager.getSY());editor.setSize(ps.width,ps.height);this.add(editor);ui.focusManager.requestFocus(editor)}}};this.stopEditing=function(applyData){if(this.editors!=null&&this.editedItem!=null){try{if(applyData){this.model.setValue(this.editedItem,this.editors.fetchEditedValue(this.editedItem,this.kids[0]))}}finally{this.editedItem=null;this.removeAt(0);this.requestFocus()}}};this.calcPreferredSize=function(target){return this.model==null?{width:0,height:0}:{width:this.maxw,height:this.maxh}}},function(){this.$this(null)},function(d){this.$this(d,true)},function(d,b){this.provider=this.selected=this.firstVisible=this.editedItem=this.pressedItem=null;this.maxw=this.maxh=0;this.visibleArea=this.lnColor=this.editors=null;this.views={};this.viewSizes={};this._isVal=false;this.nodes={};this._=new TreeListeners();this.setLineColor("gray");this.isOpenVal=b;this.setModel(d);this.setViewProvider(new pkg.DefViews());this.setSelectable(true);this.$super();this.scrollManager=new ui.ScrollManager(this)},function focused(){this.$super();if(this.selected!=null){var m=this.getItemMetrics(this.selected);this.repaint(m.x+this.scrollManager.getSX(),m.y+this.scrollManager.getSY(),m.width,m.height)}},function setEditorProvider(p){if(p!=this.editors){this.stopEditing(false);this.editors=p}},function setSelectable(b){if(this.isSelectable!=b){if(b===false&&this.selected!=null){this.select(null)}this.isSelectable=b;this.repaint()}},function setLineColor(c){this.lnColor=c;this.repaint()},function setGaps(gx,gy){if(gx!=this.gapx||gy!=this.gapy){this.gapx=gx;this.gapy=gy;this.vrp()}},function setViewProvider(p){if(p==null){p=this}if(this.provider!=p){this.stopEditing(false);this.provider=p;delete this.nodes;this.nodes={};this.vrp()}},function setViews(v){for(var k in v){if(v.hasOwnProperty(k)){var vv=ui.$view(v[k]);this.views[k]=vv;if(k!="aselect"&&k!="iselect"){this.stopEditing(false);this.viewSizes[k]=vv?vv.getPreferredSize():null;this.vrp()}}}},function setModel(d){if(this.model!=d){if(zebra.instanceOf(d,zebra.data.TreeModel)===false){d=new zebra.data.TreeModel(d)}this.stopEditing(false);this.select(null);if(this.model!=null&&this.model._){this.model.bind(this)}this.model=d;if(this.model!=null&&this.model._){this.model.bind(this)}this.firstVisible=null;delete this.nodes;this.nodes={};this.vrp()}},function invalidate(){if(this.isValid===true){this._isVal=false;this.$super()}}]);pkg.TreeSignView=Class(ui.View,[function $prototype(){this[""]=function(plus,color,bg){this.color=color==null?"white":color;this.bg=bg==null?"lightGray":bg;this.plus=plus==null?false:plus;this.br=new ui.Border("rgb(65, 131, 215)",1,3);this.width=this.height=12};this.paint=function(g,x,y,w,h,d){this.br.outline(g,x,y,w,h,d);g.setColor(this.bg);g.fill();this.br.paint(g,x,y,w,h,d);g.setColor(this.color);g.lineWidth=2;x+=2;w-=4;h-=4;y+=2;g.beginPath();g.moveTo(x,y+h/2);g.lineTo(x+w,y+h/2);if(this.plus){g.moveTo(x+w/2,y);g.lineTo(x+w/2,y+h)}g.stroke();g.lineWidth=1};this.getPreferredSize=function(){return{width:this.width,height:this.height}}}])})(zebra("ui.tree"),zebra.Class,zebra.ui);(function(pkg,Class,ui){var Matrix=zebra.data.Matrix,L=zebra.layout,WinLayer=ui.WinLayer,MB=zebra.util,Cursor=ui.Cursor,Position=zebra.util.Position,KE=ui.KeyEvent,Listeners=zebra.util.Listeners;function arr(l,v){var a=Array(l);for(var i=0;i<l;i++){a[i]=v}return a}function CellsVisibility(){this.hasVisibleCells=function(){return this.fr!=null&&this.fc!=null&&this.lr!=null&&this.lc!=null};this.fr=this.fc=this.lr=this.lc=null}pkg.Metrics=zebra.Interface();pkg.DefViews=Class([function $prototype(){this[""]=function(render){this.render=(render==null?new ui.StringRender(""):render);zebra.properties(this,this.$clazz)};this.setFont=function(f){this.render.setFont(f)};this.setColor=function(c){this.render.setColor(c)};this.getView=function(target,row,col,obj){if(obj!=null){if(obj&&obj.paint){return obj}this.render.setValue(obj.toString());return this.render}return null}}]);pkg.DefEditors=Class([function $clazz(){this.TextField=Class(ui.TextField,[]);this.Checkbox=Class(ui.Checkbox,[]);this.Combo=Class(ui.Combo,[])},function $prototype(){this[""]=function(){this.textEditor=new this.$clazz.TextField("",150);this.boolEditor=new this.$clazz.Checkbox(null);this.selectorEditor=new this.$clazz.Combo();this.editors={}};this.fetchEditedValue=function(grid,row,col,data,editor){return editor.getValue()};this.getEditor=function(grid,row,col,v){var editor=null;if(this.editors[col]===null){return}if(this.editors[col]!=null){editor=this.editors[col]}else{editor=zebra.isBoolean(v)?this.boolEditor:this.textEditor}editor.setValue(v);editor.setPadding(0);var ah=~~((grid.getRowHeight(row)-editor.getPreferredSize().height)/2);editor.setPadding(ah,grid.cellInsetsLeft,ah,grid.cellInsetsRight);return editor};this.shouldStart=function(grid,row,col,e){return e.ID==ui.MouseEvent.CLICKED&&e.clicks==1};this.shouldCancel=function(grid,row,col,e){return e.ID==KE.PRESSED&&KE.ESCAPE==e.code};this.shouldFinish=function(grid,row,col,e){return e.ID==KE.PRESSED&&KE.ENTER==e.code}}]);pkg.CaptionListeners=new zebra.util.ListenersClass("captionResized");pkg.BaseCaption=Class(ui.Panel,[function $prototype(){this.minSize=10;this.activeAreaSize=5;this.lineColor="gray";this.isAutoFit=this.isResizable=true;this.getCursorType=function(target,x,y){return this.metrics!=null&&this.selectedColRow>=0&&this.isResizable&&this.metrics.isUsePsMetric===false?((this.orient==L.HORIZONTAL)?Cursor.W_RESIZE:Cursor.S_RESIZE):null};this.mouseDragged=function(e){if(this.pxy!=null){var b=(this.orient==L.HORIZONTAL),rc=this.selectedColRow,ns=(b?this.metrics.getColWidth(rc)+e.x:this.metrics.getRowHeight(rc)+e.y)-this.pxy;this.captionResized(rc,ns);if(ns>this.minSize){this.pxy=b?e.x:e.y}}};this.mouseDragStarted=function(e){if(this.metrics!=null&&this.isResizable&&this.metrics.isUsePsMetric===false){this.calcRowColAt(e.x,e.y);if(this.selectedColRow>=0){this.pxy=(this.orient==L.HORIZONTAL)?e.x:e.y}}};this.mouseDragEnded=function(e){if(this.pxy!=null){this.pxy=null}if(this.metrics!=null){this.calcRowColAt(e.x,e.y)}};this.mouseMoved=function(e){if(this.metrics!=null){this.calcRowColAt(e.x,e.y)}};this.mouseClicked=function(e){if(this.pxy==null&&this.metrics!=null&&e.clicks>1&&this.selectedColRow>=0&&this.isAutoFit===true){var size=this.getCaptionPS(this.selectedColRow);if(this.orient==L.HORIZONTAL){this.metrics.setColWidth(this.selectedColRow,size)}else{this.metrics.setRowHeight(this.selectedColRow,size)}this.captionResized(this.selectedColRow,size)}};this.getCaptionPS=function(rowcol){return(this.orient==L.HORIZONTAL)?this.metrics.getColPSWidth(this.selectedColRow):this.metrics.getRowPSHeight(this.selectedColRow)};this.captionResized=function(rowcol,ns){if(ns>this.minSize){if(this.orient==L.HORIZONTAL){var pw=this.metrics.getColWidth(rowcol);this.metrics.setColWidth(rowcol,ns);this._.captionResized(this,rowcol,pw)}else{var ph=this.metrics.getRowHeight(rowcol);this.metrics.setRowHeight(rowcol,ns);this._.captionResized(this,rowcol,ph)}}};this.calcRowColAt=function(x,y){var $this=this;this.selectedColRow=this.getCaptionAt(x,y,function(m,xy,xxyy,wh,i){xxyy+=(wh+m.lineSize);return(xy<xxyy+$this.activeAreaSize&&xy>xxyy-$this.activeAreaSize)})};this.getCaptionAt=function(x,y,f){if(this.metrics!=null&&x>=0&&y>=0&&x<this.width&&y<this.height){var m=this.metrics,cv=m.getCellsVisibility(),isHor=(this.orient==L.HORIZONTAL);if((isHor&&cv.fc!=null)||(isHor===false&&cv.fr!=null)){var gap=m.lineSize,xy=isHor?x:y,xxyy=isHor?cv.fc[1]-this.x-gap+m.getXOrigin():cv.fr[1]-this.y-gap+m.getYOrigin();for(var i=(isHor?cv.fc[0]:cv.fr[0]);i<=(isHor?cv.lc[0]:cv.lr[0]);i++){var wh=isHor?m.getColWidth(i):m.getRowHeight(i);if((f!=null&&f(m,xy,xxyy,wh,i))||(f==null&&xy>xxyy&&xy<xxyy+wh)){return i}xxyy+=wh+gap}}}return -1};this.paintOnTop=function(g){if(this.lineColor!=null&&this.metrics!=null){var v=this.metrics.getCellsVisibility();if(v!=null){var m=this.metrics,b=this.orient==L.HORIZONTAL,startRC=b?v.fc[0]:v.fr[0],endRC=b?v.lc[0]:v.lr[0],xy=b?v.fc[1]-this.x-m.lineSize+m.getXOrigin():v.fr[1]-this.y-m.lineSize+m.getYOrigin();g.setColor(this.lineColor);for(var i=startRC;i<=endRC;i++){if(i!=0){if(b){g.drawLine(xy,0,xy,this.height,m.lineSize)}else{g.drawLine(0,xy,this.width,xy,m.lineSize)}}xy+=(b?m.getColWidth(i):m.getRowHeight(i))+m.lineSize}}}}},function(titles){this._=new pkg.CaptionListeners();this.orient=this.metrics=this.pxy=null;this.selectedColRow=-1;this.$super();if(titles!=null){for(var i=0;i<titles.length;i++){this.putTitle(i,titles[i])}}},function setParent(p){this.$super(p);this.metrics=this.orient=null;if(p==null||zebra.instanceOf(p,pkg.Metrics)){this.metrics=p;if(this.constraints!=null){this.orient=(this.constraints==L.TOP||this.constraints==L.BOTTOM)?L.HORIZONTAL:L.VERTICAL}}}]);pkg.GridCaption=Class(pkg.BaseCaption,[function $prototype(){this.getTitleProps=function(i){return this.titles!=null&&i<this.titles.length/2?this.titles[i*2+1]:null};this.getTitleView=function(i){var data=this.getTitle(i);if(data==null||data.paint){return data}this.render.setValue(data.toString());return this.render};this.calcPreferredSize=function(l){return{width:this.psW,height:this.psH}};this.recalc=function(){this.psW=this.psH=0;if(this.metrics!=null){var m=this.metrics,isHor=(this.orient==L.HORIZONTAL),size=isHor?m.getGridCols():m.getGridRows();for(var i=0;i<size;i++){var v=this.getTitleView(i);if(v!=null){var ps=v.getPreferredSize();if(isHor){if(ps.height>this.psH){this.psH=ps.height}this.psW+=ps.width}else{if(ps.width>this.psW){this.psW=ps.width}this.psH+=ps.height}}}if(this.psH===0){this.psH=pkg.Grid.DEF_ROWHEIGHT}if(this.psW===0){this.psW=pkg.Grid.DEF_COLWIDTH}}};this.paint=function(g){if(this.metrics!=null){var cv=this.metrics.getCellsVisibility();if((cv.fc!=null&&cv.lc!=null&&this.orient==L.HORIZONTAL)||(cv.fr!=null&&cv.lr!=null&&this.orient==L.VERTICAL)){var m=this.metrics,isHor=(this.orient==L.HORIZONTAL),gap=m.lineSize,top=this.getTop(),left=this.getLeft(),bottom=this.getBottom(),right=this.getRight();var x=isHor?cv.fc[1]-this.x+m.getXOrigin()-gap:left,y=isHor?top:cv.fr[1]-this.y+m.getYOrigin()-gap,size=isHor?m.getGridCols():m.getGridRows();for(var i=(isHor?cv.fc[0]:cv.fr[0]);i<=(isHor?cv.lc[0]:cv.lr[0]);i++){var wh1=isHor?m.getColWidth(i)+gap+(((size-1)==i)?gap:0):this.psW,wh2=isHor?this.psH:m.getRowHeight(i)+gap+(((size-1)==i)?gap:0),v=this.getTitleView(i);if(v!=null){var props=this.getTitleProps(i),ps=v.getPreferredSize();if(props!=null&&props[2]!=0){g.setColor(props[2]);g.fillRect(x,y,wh1-1,wh2-1)}g.save();g.clipRect(x,y,wh1,wh2);var vx=x+L.xAlignment(ps.width,props!=null?props[0]:L.CENTER,wh1-left-right)+left,vy=y+L.yAlignment(ps.height,props!=null?props[1]:L.CENTER,wh2-top-bottom)+top;v.paint(g,vx,vy,ps.width,ps.height,this);g.restore()}if(isHor){x+=wh1}else{y+=wh2}}}}};this.getTitle=function(rowcol){return this.titles==null||this.titles.length/2<=rowcol?null:this.titles[rowcol*2]}},function(){this.$this(null)},function(titles){this.$this(titles,new ui.StringRender(""))},function(titles,render){this.psW=this.psH=0;this.render=render;this.render.setFont(pkg.GridCaption.font);this.render.setColor(pkg.GridCaption.fontColor);this.$super(titles)},function putTitle(rowcol,title){var old=this.getTitle(rowcol);if(old!=title){if(this.titles==null){this.titles=arr((rowcol+1)*2,null)}else{if(Math.floor(this.titles.length/2)<=rowcol){var nt=arr((rowcol+1)*2,null);zebra.util.arraycopy(this.titles,0,nt,0,this.titles.length);this.titles=nt}}var index=rowcol*2;this.titles[index]=title;if(title==null&&index+2==this.titles.length){var nt=arr(this.titles.length-2,null);zebra.util.arraycopy(this.titles,0,nt,0,index);this.titles=nt}this.vrp()}},function setTitleProps(rowcol,ax,ay,bg){var p=this.getTitleProps(rowcol);if(p==null){p=[]}p[0]=L.$constraints(ax);p[1]=L.$constraints(ay);p[2]=bg==null?0:bg.getRGB();this.titles[rowcol*2+1]=p;this.repaint()},function getCaptionPS(rowcol){var size=this.$super(rowcol),v=this.getTitleView(this.selectedColRow);if(v!=null){size=Math.max(size,(this.orient==L.HORIZONTAL)?v.getPreferredSize().width:v.getPreferredSize().height)}return size}]);pkg.CompGridCaption=Class(pkg.BaseCaption,ui.Composite,[function $clazz(){this.Layout=Class(L.Layout,[function $prototype(){this.doLayout=function(target){var m=target.metrics,b=target.orient==L.HORIZONTAL,top=target.getTop(),left=target.getLeft(),wh=(b?target.height-top-target.getBottom():target.width-left-target.getRight());xy=(b?left+m.getXOrigin():top+m.getYOrigin());for(var i=0;i<target.kids.length;i++){var kid=target.kids[i],cwh=(b?m.getColWidth(i):m.getRowHeight(i));if(i===0){cwh-=(b?(left-m.lineSize):top)}if(kid.isVisible===true){if(b){kid.setLocation(xy,top);kid.setSize(cwh,wh)}else{kid.setLocation(left,xy);kid.setSize(wh,cwh)}}xy+=(cwh+m.lineSize)}};this.calcPreferredSize=function(target){return L.getMaxPreferredSize(target)}}]);this.Link=Class(ui.Link,[]);this.StatusPan=Class(ui.StatePan,[]);this.TitlePan=Class(ui.Panel,[function(title){this.$super(new L.FlowLayout(L.CENTER,L.CENTER,L.HORIZONTAL,8));this.sortState=0;this.isSortable=false;this.iconPan=new ui.ImagePan(null);this.link=new pkg.CompGridCaption.Link(title);this.statusPan=new pkg.CompGridCaption.StatusPan();this.statusPan.setVisible(this.isSortable);this.add(this.iconPan);this.add(this.link);this.add(this.statusPan)},function getGridCaption(){var c=this.parent;while(c!=null&&zebra.instanceOf(c,pkg.BaseCaption)===false){c=c.parent}return c},function matrixSorted(target,info){if(this.isSortable){var col=this.parent.indexOf(this);if(info.col==col){this.sortState=info.name=="descent"?1:-1;this.statusPan.setState(info.name)}else{this.sortState=0;this.statusPan.setState("*")}}},function setIcon(path){this.iconPan.setImage(path)},function matrixResized(target,prevRows,prevCols){if(this.isSortable){this.sortState=0;this.statusPan.setState("*")}},function fired(target){if(this.isSortable){var f=this.sortState==1?zebra.data.ascent:zebra.data.descent,model=this.getGridCaption().metrics.model,col=this.parent.indexOf(this);model.sortCol(col,f)}},function kidRemoved(index,kid){if(kid._!=null&&kid._.fired!=null){kid.unbind(this)}this.$super(index,kid)},function kidAdded(index,constr,kid){if(kid._!=null&&kid._.fired!=null){kid.bind(this)}this.$super(index,constr,kid)}])},function $prototype(){this.catchInput=function(t){return t._==null||t._.fired==null};this.scrolled=function(){this.vrp()};this.putTitle=function(rowcol,t){for(var i=this.kids.length-1;i<rowcol;i++){this.add(t)}if(rowcol<this.kids.length){this.removeAt(rowcol)}this.insert(rowcol,null,t)};this.setSortable=function(col,b){var c=this.kids[col];if(c.isSortable!=b){c.isSortable=b;c.statusPan.setVisible(b)}};this.matrixSorted=function(target,info){for(var i=0;i<this.kids.length;i++){if(this.kids[i].matrixSorted){this.kids[i].matrixSorted(target,info)}}};this.matrixResized=function(target,prevRows,prevCols){for(var i=0;i<this.kids.length;i++){if(this.kids[i].matrixResized){this.kids[i].matrixResized(target,prevRows,prevCols)}}}},function(){this.$this(null)},function(titles){this.$super(titles);this.setLayout(new this.$clazz.Layout())},function captionResized(rowcol,ns){this.$super(rowcol,ns);this.vrp()},function setParent(p){if(this.parent!=null&&this.parent.scrollManager!=null){this.parent.scrollManager.unbind(this)}if(p!=null&&p.scrollManager!=null){p.scrollManager.bind(this)}this.$super(p)},function insert(i,constr,c){if(zebra.isString(c)){c=new this.$clazz.TitlePan(c)}this.$super(i,constr,c)}]);pkg.Grid=Class(ui.Panel,Position.Metric,pkg.Metrics,[function $clazz(){this.DEF_COLWIDTH=80;this.DEF_ROWHEIGHT=25;this.CornerPan=Class(ui.Panel,[])},function $prototype(){this.lineSize=this.cellInsetsTop=this.cellInsetsBottom=1;this.cellInsetsLeft=this.cellInsetsRight=2;this.defXAlignment=L.LEFT;this.defYAlignment=L.CENTER;this.drawVerLines=this.drawHorLines=true;this.lineColor="gray";this.isUsePsMetric=false;this.getColX_=function(col){var start=0,d=1,x=this.getLeft()+this.getLeftCaptionWidth()+this.lineSize,v=this.visibility;if(v.hasVisibleCells()){start=v.fc[0];x=v.fc[1];d=(col>v.fc[0])?1:-1}for(var i=start;i!=col;x+=((this.colWidths[i]+this.lineSize)*d),i+=d){}return x};this.getRowY_=function(row){var start=0,d=1,y=this.getTop()+this.getTopCaptionHeight()+this.lineSize,v=this.visibility;if(v.hasVisibleCells()){start=v.fr[0];y=v.fr[1];d=(row>v.fr[0])?1:-1}for(var i=start;i!=row;y+=((this.rowHeights[i]+this.lineSize)*d),i+=d){}return y};this.rPs=function(){var cols=this.getGridCols(),rows=this.getGridRows();this.psWidth_=this.lineSize*(cols+1);this.psHeight_=this.lineSize*(rows+1);for(var i=0;i<cols;i++){this.psWidth_+=this.colWidths[i]}for(var i=0;i<rows;i++){this.psHeight_+=this.rowHeights[i]}};this.colVisibility=function(col,x,d,b){var cols=this.getGridCols();if(cols===0){return null}var left=this.getLeft(),dx=this.scrollManager.getSX(),xx1=Math.min(this.visibleArea.x+this.visibleArea.width,this.width-this.getRight()),xx2=Math.max(left,this.visibleArea.x+this.getLeftCaptionWidth());for(;col<cols&&col>=0;col+=d){if(x+dx<xx1&&(x+this.colWidths[col]+dx)>xx2){if(b){return[col,x]}}else{if(b===false){return this.colVisibility(col,x,(d>0?-1:1),true)}}if(d<0){if(col>0){x-=(this.colWidths[col-1]+this.lineSize)}}else{if(col<cols-1){x+=(this.colWidths[col]+this.lineSize)}}}return b?null:((d>0)?[col-1,x]:[0,left+this.getLeftCaptionWidth()+this.lineSize])};this.rowVisibility=function(row,y,d,b){var rows=this.getGridRows();if(rows===0){return null}var top=this.getTop(),dy=this.scrollManager.getSY(),yy1=Math.min(this.visibleArea.y+this.visibleArea.height,this.height-this.getBottom()),yy2=Math.max(this.visibleArea.y,top+this.getTopCaptionHeight());for(;row<rows&&row>=0;row+=d){if(y+dy<yy1&&(y+this.rowHeights[row]+dy)>yy2){if(b){return[row,y]}}else{if(b===false){return this.rowVisibility(row,y,(d>0?-1:1),true)}}if(d<0){if(row>0){y-=(this.rowHeights[row-1]+this.lineSize)}}else{if(row<rows-1){y+=(this.rowHeights[row]+this.lineSize)}}}return b?null:((d>0)?[row-1,y]:[0,top+this.getTopCaptionHeight()+this.lineSize])};this.vVisibility=function(){var va=ui.$cvp(this,{});if(va==null){this.visibleArea=null;this.visibility.cancelVisibleCells();return}else{if(this.visibleArea==null||va.x!=this.visibleArea.x||va.y!=this.visibleArea.y||va.width!=this.visibleArea.width||va.height!=this.visibleArea.height){this.iColVisibility(0);this.iRowVisibility(0);this.visibleArea=va}}var v=this.visibility,b=v.hasVisibleCells();if(this.colOffset!=100){if(this.colOffset>0&&b){v.lc=this.colVisibility(v.lc[0],v.lc[1],-1,true);v.fc=this.colVisibility(v.lc[0],v.lc[1],-1,false)}else{if(this.colOffset<0&&b){v.fc=this.colVisibility(v.fc[0],v.fc[1],1,true);v.lc=this.colVisibility(v.fc[0],v.fc[1],1,false)}else{v.fc=this.colVisibility(0,this.getLeft()+this.lineSize+this.getLeftCaptionWidth(),1,true);v.lc=(v.fc!=null)?this.colVisibility(v.fc[0],v.fc[1],1,false):null}}this.colOffset=100}if(this.rowOffset!=100){if(this.rowOffset>0&&b){v.lr=this.rowVisibility(v.lr[0],v.lr[1],-1,true);v.fr=this.rowVisibility(v.lr[0],v.lr[1],-1,false)}else{if(this.rowOffset<0&&b){v.fr=this.rowVisibility(v.fr[0],v.fr[1],1,true);v.lr=(v.fr!=null)?this.rowVisibility(v.fr[0],v.fr[1],1,false):null}else{v.fr=this.rowVisibility(0,this.getTop()+this.getTopCaptionHeight()+this.lineSize,1,true);v.lr=(v.fr!=null)?this.rowVisibility(v.fr[0],v.fr[1],1,false):null}}this.rowOffset=100}};this.calcOrigin=function(off,y){var top=this.getTop()+this.getTopCaptionHeight(),left=this.getLeft()+this.getLeftCaptionWidth(),o=ui.calcOrigin(this.getColX(0)-this.lineSize,y-this.lineSize,this.psWidth_,this.rowHeights[off]+2*this.lineSize,this.scrollManager.getSX(),this.scrollManager.getSY(),this,top,left,this.getBottom(),this.getRight());this.scrollManager.scrollTo(o[0],o[1])};this.$se=function(row,col,e){if(row>=0){this.stopEditing(true);if(this.editors!=null&&this.editors.shouldStart(this,row,col,e)){return this.startEditing(row,col)}}return false};this.getXOrigin=function(){return this.scrollManager.getSX()};this.getYOrigin=function(){return this.scrollManager.getSY()};this.getColPSWidth=function(col){return this.getPSSize(col,false)};this.getRowPSHeight=function(row){return this.getPSSize(row,true)};this.recalc=function(){if(this.isUsePsMetric){this.rPsMetric()}else{this.rCustomMetric()}this.rPs()};this.getGridRows=function(){return this.model!=null?this.model.rows:0};this.getGridCols=function(){return this.model!=null?this.model.cols:0};this.getRowHeight=function(row){this.validateMetric();return this.rowHeights[row]};this.getColWidth=function(col){this.validateMetric();return this.colWidths[col]};this.getCellsVisibility=function(){this.validateMetric();return this.visibility};this.getColX=function(col){this.validateMetric();return this.getColX_(col)};this.getRowY=function(row){this.validateMetric();return this.getRowY_(row)};this.childInputEvent=function(e){if(this.editingRow>=0){if(this.editors.shouldCancel(this,this.editingRow,this.editingCol,e)){this.stopEditing(false)}else{if(this.editors.shouldFinish(this,this.editingRow,this.editingCol,e)){this.stopEditing(true)}}}};this.dataToPaint=function(row,col){return this.model.get(row,col)};this.iColVisibility=function(off){this.colOffset=(this.colOffset==100)?this.colOffset=off:((off!=this.colOffset)?0:this.colOffset)};this.iRowVisibility=function(off){this.rowOffset=(this.rowOffset==100)?off:(((off+this.rowOffset)===0)?0:this.rowOffset)};this.getTopCaptionHeight=function(){return(this.topCaption!=null&&this.topCaption.isVisible===true)?this.topCaption.height:0};this.getLeftCaptionWidth=function(){return(this.leftCaption!=null&&this.leftCaption.isVisible===true)?this.leftCaption.width:0};this.paint=function(g){this.vVisibility();if(this.visibility.hasVisibleCells()){var dx=this.scrollManager.getSX(),dy=this.scrollManager.getSY(),th=this.getTopCaptionHeight(),tw=this.getLeftCaptionWidth();try{g.save();g.translate(dx,dy);if(th>0||tw>0){g.clipRect(tw-dx,th-dy,this.width-tw,this.height-th)}this.paintSelection(g);this.paintData(g);if(this.drawHorLines||this.drawVerLines){this.paintNet(g)}this.paintMarker(g)}finally{g.restore()}}};this.catchScrolled=function(psx,psy){var offx=this.scrollManager.getSX()-psx,offy=this.scrollManager.getSY()-psy;if(offx!==0){this.iColVisibility(offx>0?1:-1)}if(offy!==0){this.iRowVisibility(offy>0?1:-1)}this.stopEditing(false);this.repaint()};this.isInvalidatedByChild=function(c){return c!=this.editor||this.isUsePsMetric};this.stopEditing=function(applyData){if(this.editors!=null&&this.editingRow>=0&&this.editingCol>=0){try{if(zebra.instanceOf(this.editor,pkg.Grid)){this.editor.stopEditing(applyData)}var data=this.getDataToEdit(this.editingRow,this.editingCol);if(applyData){this.setEditedData(this.editingRow,this.editingCol,this.editors.fetchEditedValue(this,this.editingRow,this.editingCol,data,this.editor))}this.repaintRows(this.editingRow,this.editingRow)}finally{this.editingCol=this.editingRow=-1;if(this.indexOf(this.editor)>=0){this.remove(this.editor)}this.editor=null;this.requestFocus()}}};this.setDrawLines=function(hor,ver){if(this.drawVerLines!=hor||this.drawHorLines!=ver){this.drawHorLines=hor;this.drawVerLines=ver;this.repaint()}};this.getLines=function(){return this.getGridRows()};this.getLineSize=function(line){return 1};this.getMaxOffset=function(){return this.getGridRows()-1};this.posChanged=function(target,prevOffset,prevLine,prevCol){var off=this.position.currentLine;if(off>=0){this.calcOrigin(off,this.getRowY(off));this.select(off,true);this.repaintRows(prevOffset,off)}};this.makeRowVisible=function(row){this.calcOrigin(row,this.getRowY(row));this.repaint()};this.keyPressed=function(e){if(this.position!=null){var cl=this.position.currentLine;switch(e.code){case KE.LEFT:this.position.seek(-1);break;case KE.UP:this.position.seekLineTo(Position.UP);break;case KE.RIGHT:this.position.seek(1);break;case KE.DOWN:this.position.seekLineTo(Position.DOWN);break;case KE.PAGEUP:this.position.seekLineTo(Position.UP,this.pageSize(-1));break;case KE.PAGEDOWN:this.position.seekLineTo(Position.DOWN,this.pageSize(1));break;case KE.END:if(e.isControlPressed()){this.position.setOffset(this.getLines()-1)}break;case KE.HOME:if(e.isControlPressed()){this.position.setOffset(0)}break}this.$se(this.position.currentLine,this.position.currentCol,e);if(cl!=this.position.currentLine&&cl>=0){for(var i=0;i<this.getGridRows();i++){if(i!=this.position.currentLine){this.select(i,false)}}}}};this.isSelected=function(row){return(this.selected==null)?row==this.selectedIndex:this.selected[row]>0};this.repaintRows=function(r1,r2){if(r1<0){r1=r2}if(r2<0){r2=r1}if(r1>r2){var i=r2;r2=r1;r1=i}var rows=this.getGridRows();if(r1<rows){if(r2>=rows){r2=rows-1}var y1=this.getRowY(r1),y2=((r1==r2)?y1:this.getRowY(r2))+this.rowHeights[r2];this.repaint(0,y1+this.scrollManager.getSY(),this.width,y2-y1)}};this.cellByLocation=function(x,y){this.validate();var dx=this.scrollManager.getSX(),dy=this.scrollManager.getSY(),v=this.visibility,ry1=v.fr[1]+dy,rx1=v.fc[1]+dx,row=-1,col=-1,ry2=v.lr[1]+this.rowHeights[v.lr[0]]+dy,rx2=v.lc[1]+this.colWidths[v.lc[0]]+dx;if(y>ry1&&y<ry2){for(var i=v.fr[0];i<=v.lr[0];ry1+=this.rowHeights[i]+this.lineSize,i++){if(y>ry1&&y<ry1+this.rowHeights[i]){row=i;break}}}if(x>rx1&&x<rx2){for(var i=v.fc[0];i<=v.lc[0];rx1+=this.colWidths[i]+this.lineSize,i++){if(x>rx1&&x<rx1+this.colWidths[i]){col=i;break}}}return(col>=0&&row>=0)?[row,col]:null};this.doLayout=function(target){var topHeight=(this.topCaption!=null&&this.topCaption.isVisible===true)?this.topCaption.getPreferredSize().height:0,leftWidth=(this.leftCaption!=null&&this.leftCaption.isVisible===true)?this.leftCaption.getPreferredSize().width:0;if(this.topCaption!=null){this.topCaption.setLocation(this.getLeft()+leftWidth,this.getTop());this.topCaption.setSize(Math.min(target.width-this.getLeft()-this.getRight()-leftWidth,this.psWidth_),topHeight)}if(this.leftCaption!=null){this.leftCaption.setLocation(this.getLeft(),this.getTop()+topHeight);this.leftCaption.setSize(leftWidth,Math.min(target.height-this.getTop()-this.getBottom()-topHeight,this.psHeight_))}if(this.stub!=null&&this.stub.isVisible===true){if(this.topCaption!=null&&this.topCaption.isVisible===true&&this.leftCaption!=null&&this.leftCaption.isVisible===true){this.stub.setLocation(this.getLeft(),this.getTop());this.stub.setSize(this.topCaption.x-this.stub.x,this.leftCaption.y-this.stub.y)}else{this.stub.setSize(0,0)}}if(this.editors!=null&&this.editor!=null&&this.editor.parent==this&&this.editor.isVisible===true){var w=this.colWidths[this.editingCol],h=this.rowHeights[this.editingRow],x=this.getColX_(this.editingCol),y=this.getRowY_(this.editingRow);if(this.isUsePsMetric){x+=this.cellInsetsLeft;y+=this.cellInsetsTop;w-=(this.cellInsetsLeft+this.cellInsetsRight);h-=(this.cellInsetsTop+this.cellInsetsBottom)}this.editor.setLocation(x+this.scrollManager.getSX(),y+this.scrollManager.getSY());this.editor.setSize(w,h)}};this.canHaveFocus=function(){return this.editor==null};this.clearSelect=function(){if(this.selectedIndex>=0){var prev=this.selectedIndex;this.selectedIndex=-1;this._.fired(this,-1,0,false);this.repaintRows(-1,prev)}};this.select=function(row,b){if(b==null){b=true}if(this.isSelected(row)!=b){if(this.selectedIndex>=0){this.clearSelect()}if(b){this.selectedIndex=row;this._.fired(this,row,1,b)}}};this.laidout=function(){this.vVisibility()};this.mouseClicked=function(e){if(this.visibility.hasVisibleCells()){this.stopEditing(true);if(e.isActionMask()){var p=this.cellByLocation(e.x,e.y);if(p!=null){if(this.position!=null){var off=this.position.currentLine;if(off==p[0]){this.calcOrigin(off,this.getRowY(off))}else{this.clearSelect();this.position.setOffset(p[0])}}if(this.$se(p[0],p[1],e)){}}}}};this.calcPreferredSize=function(target){return{width:this.psWidth_+((this.leftCaption!=null&&this.leftCaption.isVisible===true)?this.leftCaption.getPreferredSize().width:0),height:this.psHeight_+((this.topCaption!=null&&this.topCaption.isVisible===true)?this.topCaption.getPreferredSize().height:0)}};this.paintNet=function(g){var v=this.visibility,topX=v.fc[1]-this.lineSize,topY=v.fr[1]-this.lineSize,botX=v.lc[1]+this.colWidths[v.lc[0]],botY=v.lr[1]+this.rowHeights[v.lr[0]],prevWidth=g.lineWidth;g.setColor(this.lineColor);g.lineWidth=this.lineSize;g.beginPath();if(this.drawHorLines){var y=topY+this.lineSize/2,i=v.fr[0];if(i==0&&this.topCaption!=null&&this.topCaption.isVisible===true){i++;y+=this.rowHeights[0]+this.lineSize}for(;i<=v.lr[0];i++){g.moveTo(topX,y);g.lineTo(botX,y);y+=this.rowHeights[i]+this.lineSize}g.moveTo(topX,y);g.lineTo(botX,y)}if(this.drawVerLines){var x=topX+this.lineSize/2,i=v.fc[0];if(i==0&&this.leftCaption!=null&&this.leftCaption.isVisible===true){i++;x+=this.colWidths[0]+this.lineSize}for(;i<=v.lc[0];i++){g.moveTo(x,topY);g.lineTo(x,botY);x+=this.colWidths[i]+this.lineSize}g.moveTo(x,topY);g.lineTo(x,botY)}g.stroke();g.lineWidth=prevWidth};this.paintData=function(g){var y=this.visibility.fr[1]+this.cellInsetsTop,addW=this.cellInsetsLeft+this.cellInsetsRight,addH=this.cellInsetsTop+this.cellInsetsBottom,ts=g.getTopStack(),cx=ts.x,cy=ts.y,cw=ts.width,ch=ts.height,res={};for(var i=this.visibility.fr[0];i<=this.visibility.lr[0]&&y<cy+ch;i++){if(y+this.rowHeights[i]>cy){var x=this.visibility.fc[1]+this.cellInsetsLeft,notSelectedRow=this.isSelected(i)===false;for(var j=this.visibility.fc[0];j<=this.visibility.lc[0];j++){if(notSelectedRow){var bg=this.provider.getCellColor?this.provider.getCellColor(this,i,j):this.defCellColor;if(bg!=null){g.setColor(bg);g.fillRect(x-this.cellInsetsLeft,y-this.cellInsetsTop,this.colWidths[j],this.rowHeights[i])}}var v=(i==this.editingRow&&j==this.editingCol)?null:this.provider.getView(this,i,j,this.model.get(i,j));if(v!=null){var w=this.colWidths[j]-addW,h=this.rowHeights[i]-addH;res.x=x>cx?x:cx;res.width=Math.min(x+w,cx+cw)-res.x;res.y=y>cy?y:cy;res.height=Math.min(y+h,cy+ch)-res.y;if(res.width>0&&res.height>0){if(this.isUsePsMetric){v.paint(g,x,y,w,h,this)}else{var ax=this.provider.getXAlignment?this.provider.getXAlignment(this,i,j):this.defXAlignment,ay=this.provider.getYAlignment?this.provider.getYAlignment(this,i,j):this.defYAlignment,vw=w,vh=h,xx=x,yy=y,id=-1,ps=(ax!=L.NONE||ay!=L.NONE)?v.getPreferredSize():null;if(ax!=L.NONE){xx=x+((ax==L.CENTER)?~~((w-ps.width)/2):((ax==L.RIGHT)?w-ps.width:0));vw=ps.width}if(ay!=L.NONE){yy=y+((ay==L.CENTER)?~~((h-ps.height)/2):((ay==L.BOTTOM)?h-ps.height:0));vh=ps.height}if(xx<res.x||yy<res.y||(xx+vw)>(x+w)||(yy+vh)>(y+h)){id=g.save();g.clipRect(res.x,res.y,res.width,res.height)}v.paint(g,xx,yy,vw,vh,this);if(id>=0){g.restore()}}}}x+=(this.colWidths[j]+this.lineSize)}}y+=(this.rowHeights[i]+this.lineSize)}};this.paintMarker=function(g){var markerView=this.views.marker;if(markerView!=null&&this.position!=null&&this.position.offset>=0&&this.hasFocus()){var offset=this.position.offset,v=this.visibility;if(offset>=v.fr[0]&&offset<=v.lr[0]){g.clipRect(this.getLeftCaptionWidth()-this.scrollManager.getSX(),this.getTopCaptionHeight()-this.scrollManager.getSY(),this.width,this.height);markerView.paint(g,v.fc[1],this.getRowY(offset),v.lc[1]-v.fc[1]+this.getColWidth(v.lc[0]),this.rowHeights[offset],this)}}};this.paintSelection=function(g){if(this.editingRow<0){var v=this.views[this.hasFocus()?"onselection":"offselection"];if(v==null){return}for(var j=this.visibility.fr[0];j<=this.visibility.lr[0];j++){if(this.isSelected(j)){var x=this.visibility.fc[1],y=this.getRowY(j),h=this.rowHeights[j];for(var i=this.visibility.fc[0];i<=this.visibility.lc[0];i++){v.paint(g,x,y,this.colWidths[i],h,this);x+=this.colWidths[i]+this.lineSize}}}}};this.rPsMetric=function(){var cols=this.getGridCols(),rows=this.getGridRows();if(this.colWidths==null||this.colWidths.length!=cols){this.colWidths=arr(cols,0)}else{for(var i=0;i<cols;i++){this.colWidths[i]=0}}if(this.rowHeights==null||this.rowHeights.length!=rows){this.rowHeights=arr(rows,0)}else{for(var i=0;i<rows;i++){this.rowHeights[i]=0}}var addW=this.cellInsetsLeft+this.cellInsetsRight,addH=this.cellInsetsTop+this.cellInsetsBottom;for(var i=0;i<cols;i++){for(var j=0;j<rows;j++){var v=this.provider.getView(this,j,i,this.model.get(j,i));if(v!=null){var ps=v.getPreferredSize();ps.width+=addW;ps.height+=addH;if(ps.width>this.colWidths[i]){this.colWidths[i]=ps.width}if(ps.height>this.rowHeights[j]){this.rowHeights[j]=ps.height}}else{if(pkg.Grid.DEF_COLWIDTH>this.colWidths[i]){this.colWidths[i]=pkg.Grid.DEF_COLWIDTH}if(pkg.Grid.DEF_ROWHEIGHT>this.rowHeights[j]){this.rowHeights[j]=pkg.Grid.DEF_ROWHEIGHT}}}}};this.getPSSize=function(rowcol,b){if(this.isUsePsMetric){return b?this.getRowHeight(rowcol):this.getColWidth(rowcol)}else{var max=0,count=b?this.getGridCols():this.getGridRows();for(var j=0;j<count;j++){var r=b?rowcol:j,c=b?j:rowcol,v=this.provider.getView(this,r,c,this.model.get(r,c));if(v!=null){var ps=v.getPreferredSize();if(b){if(ps.height>max){max=ps.height}}else{if(ps.width>max){max=ps.width}}}}return max+this.lineSize*2+(b?this.cellInsetsTop+this.cellInsetsBottom:this.cellInsetsLeft+this.cellInsetsRight)}};this.rCustomMetric=function(){var start=0;if(this.colWidths!=null){start=this.colWidths.length;if(this.colWidths.length!=this.getGridCols()){var na=arr(this.getGridCols(),0);zebra.util.arraycopy(this.colWidths,0,na,0,this.colWidths.length<na.length?this.colWidths.length:na.length);this.colWidths=na}}else{this.colWidths=arr(this.getGridCols(),0)}for(;start<this.colWidths.length;start++){this.colWidths[start]=pkg.Grid.DEF_COLWIDTH}start=0;if(this.rowHeights!=null){start=this.rowHeights.length;if(this.rowHeights.length!=this.getGridRows()){var na=arr(this.getGridRows(),0);zebra.util.arraycopy(this.rowHeights,0,na,0,this.rowHeights.length<na.length?this.rowHeights.length:na.length);this.rowHeights=na}}else{this.rowHeights=arr(this.getGridRows(),0)}for(;start<this.rowHeights.length;start++){this.rowHeights[start]=pkg.Grid.DEF_ROWHEIGHT}};this.pageSize=function(d){this.validate();if(this.visibility.hasVisibleCells()){var off=this.position.offset;if(off>=0){var hh=this.visibleArea.height-this.getTopCaptionHeight(),sum=0,poff=off;for(;off>=0&&off<this.getGridRows()&&sum<hh;sum+=this.rowHeights[off]+this.lineSize,off+=d){}return Math.abs(poff-off)}}return 0};this.setRowHeight=function(row,h){this.setRowsHeight(row,1,h)};this.setRowsHeight=function(row,len,h){if(this.isUsePsMetric===false){if(arguments.length===1){h=arguments[0];row=0;len=this.getGridRows()}if(len===0){return}this.validateMetric();var b=false;for(var i=row;i<row+len;i++){if(this.rowHeights[i]!=h){this.psHeight_+=(h-this.rowHeights[i]);this.rowHeights[i]=h;b=true}}if(b===true){this.stopEditing(false);this.cachedHeight=this.getTop()+this.getBottom()+this.psHeight_+((this.topCaption!=null&&this.topCaption.isVisible===true)?this.topCaption.getPreferredSize().height:0);if(this.parent!=null){this.parent.invalidate()}this.iRowVisibility(0);this.invalidateLayout();this.repaint()}}};this.setColWidth=function(col,w){this.setColsWidth(col,1,w)};this.setColsWidth=function(col,len,w){if(this.isUsePsMetric===false){if(arguments.length===1){h=arguments[0];col=0;len=this.getGridCols()}if(len===0){return}this.validateMetric();var b=false;for(var i=col;i<col+len;i++){if(this.colWidths[i]!=w){this.psWidth_+=(w-this.colWidths[i]);this.colWidths[i]=w;b=true}}if(b===true){this.stopEditing(false);this.cachedWidth=this.getRight()+this.getLeft()+this.psWidth_+((this.leftCaption!=null&&this.leftCaption.isVisible===true)?this.leftCaption.getPreferredSize().width:0);if(this.parent!=null){this.parent.invalidate()}this.iColVisibility(0);this.invalidateLayout();this.repaint()}}}},function(rows,cols){this.$this(new Matrix(rows,cols))},function(){this.$this(new Matrix(5,5))},function(model){this.defCellColor=pkg.DefViews.cellBackground;this.psWidth_=this.psHeight_=this.colOffset=0;this.rowOffset=this.pressedCol=this.selectedIndex=0;this.visibleArea=this.selected=null;this._=new Listeners();this.views={};this.editingRow=this.editingCol=this.pressedRow=-1;this.editors=this.leftCaption=this.topCaption=this.colWidths=null;this.rowHeights=this.position=this.stub=null;this.visibility=new CellsVisibility();this.$super();this.add(L.NONE,new this.$clazz.CornerPan());this.setModel(model);this.setViewProvider(new pkg.DefViews());this.setPosition(new Position(this));this.scrollManager=new ui.ScrollManager(this)},function focused(){this.$super();this.repaint()},function setEditorProvider(p){if(p!=this.editors){this.stopEditing(true);this.editors=p}},function setUsePsMetric(b){if(this.isUsePsMetric!=b){this.isUsePsMetric=b;this.vrp()}},function setPosition(p){if(this.position!=p){if(this.position!=null){this.position.unbind(this)}this.position=p;if(this.position!=null){this.position.bind(this);this.position.setMetric(this)}this.repaint()}},function setViewProvider(p){if(this.provider!=p){this.provider=p;this.vrp()}},function setModel(d){if(d!=this.model){this.clearSelect();if(Array.isArray(d)){d=new Matrix(d)}if(this.model!=null&&this.model._){this.model.unbind(this)}this.model=d;if(this.model!=null&&this.model._){this.model.bind(this)}if(this.position!=null){this.position.setOffset(-1)}if(this.model!=null&&this.selected!=null){this.selected=arr(this.model.rows,false)}this.vrp()}},function setCellPadding(p){this.setCellPaddings(p,p,p,p)},function setCellPaddings(t,l,b,r){if(t!=this.cellInsetsTop||l!=this.cellInsetsLeft||b!=this.cellInsetsBottom||r!=this.cellInsetsRight){this.cellInsetsTop=t;this.cellInsetsLeft=l;this.cellInsetsBottom=b;this.cellInsetsRight=r;this.vrp()}},function matrixResized(target,prevRows,prevCols){this.clearSelect();if(this.selected!=null){this.selected=arr(this.model.rows,false)}this.vrp();if(this.position!=null){this.position.setOffset(-1)}for(var i=0;i<this.kids.length;i++){if(this.kids[i].matrixResized){this.kids[i].matrixResized(target,prevRows,prevCols)}}},function cellModified(target,row,col,prevValue){if(this.isUsePsMetric){this.invalidate()}for(var i=0;i<this.kids.length;i++){if(this.kids[i].cellModified){this.kids[i].cellModified(target,row,col,prevValue)}}},function matrixSorted(target,info){this.clearSelect();this.vrp();for(var i=0;i<this.kids.length;i++){if(this.kids[i].matrixSorted){this.kids[i].matrixSorted(target,info)}}},function invalidate(){this.$super();this.iColVisibility(0);this.iRowVisibility(0)},function setLineColor(c){if(c!=this.lineColor){this.lineColor=c;if(this.drawVerLines||this.drawHorLines){this.repaint()}}},function kidAdded(index,id,c){this.$super(index,id,c);if(L.TOP==id){this.topCaption=c}else{if(L.TEMPORARY==id){this.editor=c}else{if(L.LEFT==id){this.leftCaption=c}else{if(L.NONE===id){this.stub=c}}}}},function kidRemoved(index,c){this.$super(index,c);if(c==this.editor){this.editor=null}else{if(c==this.topCaption){this.topCaption=null}else{if(c==this.leftCaption){this.leftCaption=null}else{if(c==this.stub){this.stub=null}}}}},function setLineSize(s){if(s!=this.lineSize){this.lineSize=s;this.vrp()}},function startEditing(row,col){this.stopEditing(true);if(this.editors!=null){var editor=this.editors.getEditor(this,row,col,this.getDataToEdit(row,col));if(editor!=null){this.editingRow=row;this.editingCol=col;if(editor.isPopupEditor===true){var p=L.toParentOrigin(this.getColX(col)+this.scrollManager.getSX(),this.getRowY(row)+this.scrollManager.getSY(),this);editor.setLocation(p.x,p.y);ui.makeFullyVisible(this.getCanvas(),editor);this.editor=editor;this.getCanvas().getLayer(WinLayer.ID).addWin("modal",editor,this)}else{this.add(L.TEMPORARY,editor);this.repaintRows(this.editingRow,this.editingRow)}ui.focusManager.requestFocus(editor);return true}}return false},function getEditingCell(){return(this.editingRow>=0&&this.editingCol>=0)?[this.editingRow,this.editingCol]:null},function winOpened(winLayer,target,b){if(this.editor==target&&b===false){this.stopEditing(this.editor.isAccepted())}},function getDataToEdit(row,col){return this.model.get(row,col)},function setEditedData(row,col,value){this.model.put(row,col,value)}]);pkg.Grid.prototype.setViews=ui.$ViewsSetter;pkg.GridStretchPan=Class(ui.Panel,L.Layout,[function $prototype(){this.calcPreferredSize=function(target){this.recalcPS();return(target.kids.length===0||target.grid.isVisible===false)?{width:0,height:0}:{width:this.strPs.width,height:this.strPs.height}};this.doLayout=function(target){this.recalcPS();if(target.kids.length>0){var grid=this.grid;if(grid.isVisible===true){var left=target.getLeft(),top=target.getTop();grid.setLocation(left,top);grid.setSize(target.width-left-target.getRight(),target.height-top-target.getBottom());for(var i=0;i<this.widths.length;i++){grid.setColWidth(i,this.widths[i])}if(this.heights!=null){for(var i=0;i<this.heights.length;i++){grid.setRowHeight(i,this.heights[i])}}}}};this.captionResized=function(src,col,pw){var grid=this.grid;if(col<this.widths.length-1){var w=grid.getColWidth(col),dt=w-pw;if(dt<0){grid.setColWidth(col+1,grid.getColWidth(col+1)-dt)}else{var ww=grid.getColWidth(col+1)-dt,mw=this.getMinWidth();if(ww<mw){grid.setColWidth(col,w-(mw-ww));grid.setColWidth(col+1,mw)}else{grid.setColWidth(col+1,ww)}}this.proportions=null}};this.calcColProportions=function(targetAreaW,targetAreaH){var g=this.grid,cols=g.getGridCols(),sw=0;for(var i=0;i<cols;i++){var w=g.getColWidth(i);if(w===0){w=g.getColPSWidth(i)}sw+=w}var props=Array(cols);for(var i=0;i<cols;i++){var w=g.getColWidth(i);if(w===0){w=g.getColPSWidth(i)}props[i]=w/sw}return props};this.calcRowHeights=function(targetAreaW,targetAreaH,widths){return null};this.getMinWidth=function(){return zebra.instanceOf(this.grid.topCaption,pkg.BaseCaption)?this.grid.topCaption.minSize:10};this.calcColWidths=function(targetAreaW,targetAreaH){var grid=this.grid,w=Array(grid.getGridCols()),ew=targetAreaW-(this.proportions.length+1)*grid.lineSize,sw=0;for(var i=0;i<this.proportions.length;i++){if(this.proportions.length-1==i){w[i]=ew-sw}else{var cw=~~(ew*this.proportions[i]);w[i]=cw;sw+=cw}}return w};this.recalcPS=function(){var grid=this.grid;if(grid==null||grid.isVisible===false){return}var p=this.parent,isScr=zebra.instanceOf(p,ui.ScrollPan),taWidth=(isScr?p.width-p.getLeft()-p.getRight()-this.getRight()-this.getLeft():this.width-this.getRight()-this.getLeft()),taHeight=(isScr?p.height-p.getTop()-p.getBottom()-this.getBottom()-this.getTop():this.height-this.getBottom()-this.getTop());if(this.grid.leftCaption!=null&&this.grid.leftCaption.isVisible===true){taWidth-=this.grid.leftCaption.getPreferredSize().width}if(this.strPs!=null&&this.prevTargetAreaSize.width==taWidth&&this.prevTargetAreaSize.height==taHeight){return}if(this.proportions==null||this.proportions.length!=grid.getGridCols()){this.proportions=this.calcColProportions(taWidth,taHeight)}this.prevTargetAreaSize.width=taWidth;this.prevTargetAreaSize.height=taHeight;this.widths=this.calcColWidths(taWidth,taHeight);this.heights=this.calcRowHeights(taWidth,taHeight,this.widths);this.strPs=this.summarizePS(taWidth,taHeight,this.widths,this.heights);if(isScr===true&&p.height>0&&p.vBar&&p.autoHide===false&&taHeight<this.strPs.height){taWidth-=p.vBar.getPreferredSize().width;this.widths=this.calcColWidths(taWidth,taHeight);this.heights=this.calcRowHeights(taWidth,taHeight,this.widths);this.strPs=this.summarizePS(taWidth,taHeight,this.widths,this.heights)}};this.summarizePS=function(targetAreaW,targetAreaH,widths,heights){var ps={width:targetAreaW,height:0},grid=this.grid;if(heights!=null){for(var i=0;i<heights.length;i++){ps.height+=heights[i]}if(grid.topCaption!=null&&grid.topCaption.isVisible===true){ps.height+=grid.topCaption.getPreferredSize().height}ps.height+=(grid.getTop()+grid.getBottom())}else{ps.height=grid.getPreferredSize().height}return ps}},function(grid){this.$super(this);this.heights=[];this.widths=[];this.grid=grid;this.proportions=this.strPs=null;this.prevTargetAreaSize={width:0,height:0};this.add(grid)},function kidAdded(index,constr,l){this.proportions=null;if(l.topCaption!=null){l.topCaption.bind(this)}this.scrollManager=l.scrollManager;this.$super(index,constr,l)},function kidRemoved(i,l){this.proportions=null;if(l.topCaption!=null){l.topCaption.unbind(this)}this.scrollManager=null;this.$super(i,l)},function invalidate(){this.strPs=null;this.$super()}])})(zebra("ui.grid"),zebra.Class,zebra("ui"))})();