//>>built
define("dojox/color/Palette",["dojo/_base/lang","dojo/_base/array","./_base"],function(h,l,d){function v(b,a,e){var f=new d.Palette;f.colors=[];l.forEach(b.colors,function(c){f.colors.push(new d.Color({r:Math.min(255,Math.max(0,"dr"==a?c.r+e:c.r)),g:Math.min(255,Math.max(0,"dg"==a?c.g+e:c.g)),b:Math.min(255,Math.max(0,"db"==a?c.b+e:c.b)),a:Math.min(1,Math.max(0,"da"==a?c.a+e:c.a))}))});return f}function p(b,a,e){var f=new d.Palette;f.colors=[];l.forEach(b.colors,function(c){c=c.toCmy();f.colors.push(d.fromCmy(Math.min(100,
Math.max(0,"dc"==a?c.c+e:c.c)),Math.min(100,Math.max(0,"dm"==a?c.m+e:c.m)),Math.min(100,Math.max(0,"dy"==a?c.y+e:c.y))))});return f}function q(b,a,e){var f=new d.Palette;f.colors=[];l.forEach(b.colors,function(c){c=c.toCmyk();f.colors.push(d.fromCmyk(Math.min(100,Math.max(0,"dc"==a?c.c+e:c.c)),Math.min(100,Math.max(0,"dm"==a?c.m+e:c.m)),Math.min(100,Math.max(0,"dy"==a?c.y+e:c.y)),Math.min(100,Math.max(0,"dk"==a?c.b+e:c.b))))});return f}function r(b,a,e){var f=new d.Palette;f.colors=[];l.forEach(b.colors,
function(c){c=c.toHsl();f.colors.push(d.fromHsl(("dh"==a?c.h+e:c.h)%360,Math.min(100,Math.max(0,"ds"==a?c.s+e:c.s)),Math.min(100,Math.max(0,"dl"==a?c.l+e:c.l))))});return f}function t(b,a,e){var f=new d.Palette;f.colors=[];l.forEach(b.colors,function(c){c=c.toHsv();f.colors.push(d.fromHsv(("dh"==a?c.h+e:c.h)%360,Math.min(100,Math.max(0,"ds"==a?c.s+e:c.s)),Math.min(100,Math.max(0,"dv"==a?c.v+e:c.v))))});return f}d.Palette=function(b){this.colors=[];b instanceof d.Palette?this.colors=b.colors.slice(0):
b instanceof d.Color?this.colors=[null,null,b,null,null]:h.isArray(b)?this.colors=l.map(b.slice(0),function(a){return h.isString(a)?new d.Color(a):a}):h.isString(b)&&(this.colors=[null,null,new d.Color(b),null,null])};h.extend(d.Palette,{transform:function(b){var a=v;if(b.use){var e=b.use.toLowerCase();0==e.indexOf("hs")?a="l"==e.charAt(2)?r:t:0==e.indexOf("cmy")&&(a="k"==e.charAt(3)?q:p)}else if("dc"in b||"dm"in b||"dy"in b)a="dk"in b?q:p;else if("dh"in b||"ds"in b)a="dv"in b?t:r;e=this;for(var f in b)"use"!=
f&&(e=a(e,f,b[f]));return e},clone:function(){return new d.Palette(this)}});h.mixin(d.Palette,{generators:{analogous:function(b){var a=b.high||60,e=b.low||18;b=(h.isString(b.base)?new d.Color(b.base):b.base).toHsv();var f=Math.max(10,95>=b.s?b.s+5:100-(b.s-95)),c=92<=b.v?b.v-9:Math.max(b.v+9,20),g=90>=b.v?Math.max(b.v+5,20):95+Math.ceil((b.v-90)/2),k=[f,1<b.s?b.s-1:21-b.s,b.s,f,f],m=[c,g,b.v,c,g];return new d.Palette(l.map([(b.h+e+360)%360,(b.h+Math.round(e/2)+360)%360,b.h,(b.h-Math.round(a/2)+360)%
360,(b.h-a+360)%360],function(n,u){return d.fromHsv(n,k[u],m[u])}))},monochromatic:function(b){b=h.isString(b.base)?new d.Color(b.base):b.base;var a=b.toHsv(),e=9<a.s-30?a.s-30:a.s+30,f=a.s,c=20<a.v-20?a.v-20:a.v+60,g=20<a.v-50?a.v-50:a.v+30;return new d.Palette([d.fromHsv(a.h,e,100-.8*(100-a.v)),d.fromHsv(a.h,f,g),b,d.fromHsv(a.h,e,g),d.fromHsv(a.h,f,c)])},triadic:function(b){b=h.isString(b.base)?new d.Color(b.base):b.base;var a=b.toHsv(),e=(a.h-157+360)%360,f=90<a.s?a.s-10:a.s+10,c=95<a.s?a.s-5:
a.s+5,g=20<a.v-20?a.v-20:a.v+20,k=20<a.v-30?a.v-30:a.v+30,m=70<a.v-30?a.v-30:a.v+30;return new d.Palette([d.fromHsv((a.h+57+360)%360,20<a.s?a.s-10:a.s+10,a.v),d.fromHsv(a.h,f,k),b,d.fromHsv(e,f,g),d.fromHsv(e,c,m)])},complementary:function(b){b=h.isString(b.base)?new d.Color(b.base):b.base;var a=b.toHsv(),e=360>2*a.h+137?2*a.h+137:Math.floor(a.h/2)-137,f=100-.9*(100-a.s),c=Math.min(100,a.s+20),g=20<a.v?a.v-30:a.v+30;return new d.Palette([d.fromHsv(a.h,Math.max(a.s-10,0),Math.min(100,a.v+30)),d.fromHsv(a.h,
f,g),b,d.fromHsv(e,c,g),d.fromHsv(e,a.s,a.v)])},splitComplementary:function(b){var a=h.isString(b.base)?new d.Color(b.base):b.base,e=b.da||30;b=a.toHsv();var f=360>2*b.h+137?2*b.h+137:Math.floor(b.h/2)-137,c=(f-e+360)%360;e=(f+e)%360;f=100-.9*(100-b.s);var g=Math.min(100,b.s+20),k=20<b.v?b.v-30:b.v+30;return new d.Palette([d.fromHsv(c,Math.max(b.s-10,0),Math.min(100,b.v+30)),d.fromHsv(c,f,k),a,d.fromHsv(e,g,k),d.fromHsv(e,b.s,b.v)])},compound:function(b){b=h.isString(b.base)?new d.Color(b.base):b.base;
var a=b.toHsv(),e=360>2*a.h+18?2*a.h+18:Math.floor(a.h/2)-18,f=360>2*a.h+120?2*a.h+120:Math.floor(a.h/2)-120,c=360>2*a.h+99?2*a.h+99:Math.floor(a.h/2)-99,g=80<a.s-10?a.s-10:a.s+10,k=10<a.s-25?a.s-25:a.s+25,m=80<a.v-20?a.v-20:a.v+20,n=Math.max(a.v,20);return new d.Palette([d.fromHsv(e,10<a.s-40?a.s-40:a.s+40,10<a.v-40?a.v-40:a.v+40),d.fromHsv(e,g,m),b,d.fromHsv(f,k,n),d.fromHsv(c,g,m)])},shades:function(b){b=h.isString(b.base)?new d.Color(b.base):b.base;var a=b.toHsv(),e=100==a.s&&0==a.v?0:a.s,f=20<=
a.v-25?a.v-25:a.v+55,c=20<=a.v-75?a.v-75:a.v+5,g=Math.max(a.v-10,20);return new d.Palette([new d.fromHsv(a.h,e,20<a.v-50?a.v-50:a.v+30),new d.fromHsv(a.h,e,f),b,new d.fromHsv(a.h,e,c),new d.fromHsv(a.h,e,g)])}},generate:function(b,a){if(h.isFunction(a))return a({base:b});if(d.Palette.generators[a])return d.Palette.generators[a]({base:b});throw Error("dojox.color.Palette.generate: the specified generator ('"+a+"') does not exist.");}});return d.Palette});