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