//>>built
define("dojox/treemap/_utils",["dojo/_base/array"],function(n){var q={group:function(c,h,e){var f={children:[]},m=function(b,a){b.__treeValue||(b.__treeValue=0);b.__treeValue+=e(a);return b};n.forEach(c,function(b){var a=f;n.forEach(h,function(d,k){var g=d(b),l=q.find(a.children,function(p){return p.__treeName==g});l||a.children.push(l={__treeName:g,__treeID:g+Math.random(),children:[]});l=m(l,b);k!=h.length-1?a=l:l.children.push(b)});a=m(a,b)});return f},find:function(c,h){for(var e=c.length,f=0;f<
e;++f)if(h.call(null,c[f]))return c[f];return null},solve:function(c,h,e,f,m){var b=q.initElements(c,f);f=b.total;b=b.elements;var a=f;if(0==f){if(0==b.length)return{items:c,rects:[],total:0};n.forEach(b,function(d){d.size=d.sizeTmp=100});f=100*b.length}b.sort(function(d,k){return k.size-d.size});q._compute(h,e,b,f);b.sort(function(d,k){return d.index-k.index});c={};c.elements=b;c.size=a;rects=n.map(b,function(d){return{x:m?h-d.x-d.width:d.x,y:d.y,w:d.width,h:d.height}});c.rectangles=rects;return c},
initElements:function(c,h){var e=0;return{elements:n.map(c,function(f,m){var b=null!=h?h(f):0;if(0>b)throw Error("item size dimension must be positive");e+=b;return{index:m,size:b,sizeTmp:b}}),total:e}},_compute:function(c,h,e,f){var m=c*h/f/100;n.forEach(e,function(t){t.sizeTmp*=m});for(var b=f=0,a=2147483647,d,k=0,g=0,l=c,p=h,r=l>p;b!=e.length;)if(d=q._trySolution(e,f,b,r,l,p),d>a||1>d){l=d=0;for(a=f;a<b;a++)e[a].x=k+d,e[a].y=g+l,r?l+=e[a].height:d+=e[a].width;r?k+=e[f].width:g+=e[f].height;l=c-
k;p=h-g;r=l>p;b=f=b;a=2147483647}else{for(a=f;a<=b;a++)e[a].width=e[a].widthTmp,e[a].height=e[a].heightTmp;a=d;b++}h=c=0;for(a=f;a<b;a++)e[a].x=k+c,e[a].y=g+h,r?h+=e[a].height:c+=e[a].width},_trySolution:function(c,h,e,f,m,b){for(var a=0,d=0,k=d=0,g=h;g<=e;g++)a+=c[g].sizeTmp;f?0==b?d=k=0:(d=a/b*100,k=b):0==m?d=k=0:(k=a/m*100,d=m);for(g=h;g<=e;g++)f?(c[g].widthTmp=d,c[g].heightTmp=0==a?0:k*c[g].sizeTmp/a):(c[g].widthTmp=0==a?0:d*c[g].sizeTmp/a,c[g].heightTmp=k);d=Math.max(c[e].heightTmp/c[e].widthTmp,
c[e].widthTmp/c[e].heightTmp);return void 0==d?1:d}};return q});