/* global colorScheme, Color */
/**
 * Add a listener to the Color Scheme control to update other color controls to new values/defaults.
 * Also trigger an update of the Color Scheme CSS when a color is changed.
 */

( function( api ) {
	var cssTemplate = wp.template( 'prestasi-color-scheme' ),
		colorSchemeKeys = [
			'background_color',
			'press_color1',
			'press_color2',
			'press_color3',
			'press_color4',
			'press_color5',
			'press_color6',
			'press_color7',
			'press_color8',
			'press_color9',
			'press_color10',
			'press_color11',
			'press_color12',
			'press_color13',
			'press_color14',
			'press_color15',
			'press_color16',
			'press_color17',
			'press_color18',
			'press_color19',
			'press_color20',
			'press_color21',
			'press_color22',
			'press_color23',
			'press_color22',
			'press_color31',
			'press_color32',
			'press_color33',
			'press_color34',
			'press_color35',
			'press_color36',
			'press_color37',
			'press_color38',
			'press_color39',
			'press_color40',
			'press_color41',
			'press_color42',
			'press_color43',
			'press_color44',
			'press_color45',
			'press_color46',
			'press_color47',
			'press_color48',
			'press_color49',
			'press_color50',
			'press_color51',
			'press_color52',
			'press_color53',
			'press_color54',
			'press_color55',
			'press_color56',
			'press_color57',
			'press_color58',
			'press_color59',
			'press_color60',
			'press_color61',
			'press_color62',
			'press_color63',
			'press_color64',
			'press_color65',
			'press_color66',
			'press_color67',
			'press_color68',
			'press_color69',
			'press_color70',
			'press_color71',
			'press_color72',
			'press_color73',
			'press_color74',
			'press_color75',
			'press_color76',
			'press_color77',
			'press_color78',
			'press_color79',
			'press_color80',
			'press_color81',
			'press_color82',
			'press_color83',
			'press_color84',
			'press_color85',
			'press_color86',
			'press_color87',
			'press_color88',
			'press_color89',
			'press_color90',
			'press_color91',
			'press_color92',
			'press_color93',
			'press_color94',
			'press_color95',
			'press_color96',
			'press_color97',
			'press_color98',
			'press_color99',
			'press_color100',
			'press_color101',
			'press_color102',
			'press_color103',
			'press_color104',
			'press_color105',
			'press_color106',
			'press_color107',
			'press_color108',
			'press_color109',
			'press_color110',
			'press_color111',
			'press_color112',
			'press_color113',
			'press_color114',
			'press_color115',
			'press_color116',
			'press_color117',
			'press_color118',
			'press_color119',
			'press_color120',
			'press_color121',
			'press_color122',
			'press_color123',
			'press_color124',
			'press_color125',
			'press_color126',
			'press_color127',
		],
		colorSettings = [
			'background_color',
			'press_color1',
			'press_color2',
			'press_color3',
			'press_color4',
			'press_color5',
			'press_color6',
			'press_color7',
			'press_color8',
			'press_color9',
			'press_color10',
			'press_color11',
			'press_color12',
			'press_color13',
			'press_color14',
			'press_color15',
			'press_color16',
			'press_color17',
			'press_color18',
			'press_color19',
			'press_color20',
			'press_color21',
			'press_color22',
			'press_color23',
			'press_color24',
			'press_color25',
			'press_color26',
			'press_color27',
			'press_color28',
			'press_color29',
			'press_color30',
			'press_color31',
			'press_color32',
			'press_color33',
			'press_color34',
			'press_color35',
			'press_color36',
			'press_color37',
			'press_color38',
			'press_color39',
			'press_color40',
			'press_color41',
			'press_color42',
			'press_color43',
			'press_color44',
			'press_color45',
			'press_color46',
			'press_color47',
			'press_color48',
			'press_color49',
			'press_color50',
			'press_color51',
			'press_color52',
			'press_color53',
			'press_color54',
			'press_color55',
			'press_color56',
			'press_color57',
			'press_color58',
			'press_color59',
			'press_color60',
			'press_color61',
			'press_color62',
			'press_color63',
			'press_color64',
			'press_color65',
			'press_color66',
			'press_color67',
			'press_color68',
			'press_color69',
			'press_color70',
			'press_color71',
			'press_color72',
			'press_color73',
			'press_color74',
			'press_color75',
			'press_color76',
			'press_color77',
			'press_color78',
			'press_color79',
			'press_color80',
			'press_color81',
			'press_color82',
			'press_color83',
			'press_color84',
			'press_color85',
			'press_color86',
			'press_color87',
			'press_color88',
			'press_color89',
			'press_color90',
			'press_color91',
			'press_color92',
			'press_color93',
			'press_color94',
			'press_color95',
			'press_color96',
			'press_color97',
			'press_color98',
			'press_color99',
			'press_color100',
			'press_color101',
			'press_color102',
			'press_color103',
			'press_color104',
			'press_color105',
			'press_color106',
			'press_color107',
			'press_color108',
			'press_color109',
			'press_color110',
			'press_color111',
			'press_color112',
			'press_color113',
			'press_color114',
			'press_color115',
			'press_color116',
			'press_color117',
			'press_color118',
			'press_color119',
			'press_color120',
			'press_color121',
			'press_color122',
			'press_color123',
			'press_color124',
			'press_color125',
			'press_color126',
			'press_color127',
		];

	api.controlConstructor.select = api.Control.extend( {
		ready: function() {
			if ( 'color_scheme' === this.id ) {
				this.setting.bind( 'change', function( value ) {
					var colors = colorScheme[value].colors;

					// Update Background Color.
					var color = colors[0];
					api( 'background_color' ).set( color );
					api.control( 'background_color' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );

					// Update Page Background Color.
					color = colors[1];
					api( 'press_color1' ).set( color );
					api.control( 'press_color1' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );

					// Update Link Color.
					color = colors[2];
					api( 'press_color2' ).set( color );
					api.control( 'press_color2' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );

					// Update Main Text Color.
					color = colors[3];
					api( 'press_color3' ).set( color );
					api.control( 'press_color3' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );

					// Update Secondary Text Color.
					color = colors[4];
					api( 'press_color4' ).set( color );
					api.control( 'press_color4' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					
					color = colors[5];
					api( 'press_color5' ).set( color );
					api.control( 'press_color5' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[6];
					api( 'press_color6' ).set( color );
					api.control( 'press_color6' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
						
					color = colors[7];
					api( 'press_color7' ).set( color );
					api.control( 'press_color7' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[8];
					api( 'press_color8' ).set( color );
					api.control( 'press_color8' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
						
					color = colors[9];
					api( 'press_color9' ).set( color );
					api.control( 'press_color9' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[10];
					api( 'press_color10' ).set( color );
					api.control( 'press_color10' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[11];
					api( 'press_color11' ).set( color );
					api.control( 'press_color11' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[12];
					api( 'press_color12' ).set( color );
					api.control( 'press_color12' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[13];
					api( 'press_color13' ).set( color );
					api.control( 'press_color13' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[14];
					api( 'press_color14' ).set( color );
					api.control( 'press_color14' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[15];
					api( 'press_color15' ).set( color );
					api.control( 'press_color15' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[16];
					api( 'press_color16' ).set( color );
					api.control( 'press_color16' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[17];
					api( 'press_color17' ).set( color );
					api.control( 'press_color17' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[18];
					api( 'press_color18' ).set( color );
					api.control( 'press_color18' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[19];
					api( 'press_color19' ).set( color );
					api.control( 'press_color19' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[20];
					api( 'press_color20' ).set( color );
					api.control( 'press_color20' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[21];
					api( 'press_color21' ).set( color );
					api.control( 'press_color21' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[22];
					api( 'press_color22' ).set( color );
					api.control( 'press_color22' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[23];
					api( 'press_color23' ).set( color );
					api.control( 'press_color23' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[24];
					api( 'press_color24' ).set( color );
					api.control( 'press_color24' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[25];
					api( 'press_color25' ).set( color );
					api.control( 'press_color25' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[26];
					api( 'press_color26' ).set( color );
					api.control( 'press_color26' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[27];
					api( 'press_color27' ).set( color );
					api.control( 'press_color27' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[28];
					api( 'press_color28' ).set( color );
					api.control( 'press_color28' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[29];
					api( 'press_color29' ).set( color );
					api.control( 'press_color29' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[30];
					api( 'press_color30' ).set( color );
					api.control( 'press_color30' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[31];
					api( 'press_color31' ).set( color );
					api.control( 'press_color31' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[32];
					api( 'press_color32' ).set( color );
					api.control( 'press_color32' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[33];
					api( 'press_color33' ).set( color );
					api.control( 'press_color33' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[34];
					api( 'press_color34' ).set( color );
					api.control( 'press_color34' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[35];
					api( 'press_color35' ).set( color );
					api.control( 'press_color35' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[36];
					api( 'press_color36' ).set( color );
					api.control( 'press_color36' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[37];
					api( 'press_color37' ).set( color );
					api.control( 'press_color37' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[38];
					api( 'press_color38' ).set( color );
					api.control( 'press_color38' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[39];
					api( 'press_color39' ).set( color );
					api.control( 'press_color39' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[40];
					api( 'press_color40' ).set( color );
					api.control( 'press_color40' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[41];
					api( 'press_color41' ).set( color );
					api.control( 'press_color41' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[42];
					api( 'press_color42' ).set( color );
					api.control( 'press_color42' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[43];
					api( 'press_color43' ).set( color );
					api.control( 'press_color43' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[44];
					api( 'press_color44' ).set( color );
					api.control( 'press_color44' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[45];
					api( 'press_color45' ).set( color );
					api.control( 'press_color45' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[46];
					api( 'press_color46' ).set( color );
					api.control( 'press_color46' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[47];
					api( 'press_color47' ).set( color );
					api.control( 'press_color47' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[48];
					api( 'press_color48' ).set( color );
					api.control( 'press_color48' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[49];
					api( 'press_color49' ).set( color );
					api.control( 'press_color49' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[50];
					api( 'press_color50' ).set( color );
					api.control( 'press_color50' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[51];
					api( 'press_color51' ).set( color );
					api.control( 'press_color51' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[52];
					api( 'press_color52' ).set( color );
					api.control( 'press_color52' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[53];
					api( 'press_color53' ).set( color );
					api.control( 'press_color53' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[54];
					api( 'press_color54' ).set( color );
					api.control( 'press_color54' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[55];
					api( 'press_color55' ).set( color );
					api.control( 'press_color55' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[56];
					api( 'press_color56' ).set( color );
					api.control( 'press_color56' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[57];
					api( 'press_color57' ).set( color );
					api.control( 'press_color57' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[58];
					api( 'press_color58' ).set( color );
					api.control( 'press_color58' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[59];
					api( 'press_color59' ).set( color );
					api.control( 'press_color59' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[60];
					api( 'press_color60' ).set( color );
					api.control( 'press_color60' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[61];
					api( 'press_color61' ).set( color );
					api.control( 'press_color61' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[62];
					api( 'press_color62' ).set( color );
					api.control( 'press_color62' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[63];
					api( 'press_color63' ).set( color );
					api.control( 'press_color63' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[64];
					api( 'press_color64' ).set( color );
					api.control( 'press_color64' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[65];
					api( 'press_color65' ).set( color );
					api.control( 'press_color65' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[66];
					api( 'press_color66' ).set( color );
					api.control( 'press_color66' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[67];
					api( 'press_color67' ).set( color );
					api.control( 'press_color67' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[68];
					api( 'press_color68' ).set( color );
					api.control( 'press_color68' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[69];
					api( 'press_color69' ).set( color );
					api.control( 'press_color69' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[70];
					api( 'press_color70' ).set( color );
					api.control( 'press_color70' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[71];
					api( 'press_color71' ).set( color );
					api.control( 'press_color71' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[72];
					api( 'press_color72' ).set( color );
					api.control( 'press_color72' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[73];
					api( 'press_color73' ).set( color );
					api.control( 'press_color73' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[74];
					api( 'press_color74' ).set( color );
					api.control( 'press_color74' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[75];
					api( 'press_color75' ).set( color );
					api.control( 'press_color75' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
                    color = colors[76];
					api( 'press_color76' ).set( color );
					api.control( 'press_color76' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
                    color = colors[77];
					api( 'press_color77' ).set( color );
					api.control( 'press_color77' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[78];
					api( 'press_color78' ).set( color );
					api.control( 'press_color78' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[79];
					api( 'press_color79' ).set( color );
					api.control( 'press_color79' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[80];
					api( 'press_color80' ).set( color );
					api.control( 'press_color80' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[81];
					api( 'press_color81' ).set( color );
					api.control( 'press_color81' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[82];
					api( 'press_color82' ).set( color );
					api.control( 'press_color82' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[83];
					api( 'press_color83' ).set( color );
					api.control( 'press_color83' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[84];
					api( 'press_color84' ).set( color );
					api.control( 'press_color84' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[85];
					api( 'press_color85' ).set( color );
					api.control( 'press_color85' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[86];
					api( 'press_color86' ).set( color );
					api.control( 'press_color86' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[87];
					api( 'press_color87' ).set( color );
					api.control( 'press_color87' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[88];
					api( 'press_color88' ).set( color );
					api.control( 'press_color88' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
                    color = colors[89];
					api( 'press_color89' ).set( color );
					api.control( 'press_color89' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
                    color = colors[90];
					api( 'press_color90' ).set( color );
					api.control( 'press_color90' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[91];
					api( 'press_color91' ).set( color );
					api.control( 'press_color91' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[92];
					api( 'press_color92' ).set( color );
					api.control( 'press_color92' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[93];
					api( 'press_color93' ).set( color );
					api.control( 'press_color93' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[94];
					api( 'press_color94' ).set( color );
					api.control( 'press_color94' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[95];
					api( 'press_color95' ).set( color );
					api.control( 'press_color95' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[96];
					api( 'press_color96' ).set( color );
					api.control( 'press_color96' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[97];
					api( 'press_color97' ).set( color );
					api.control( 'press_color97' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[98];
					api( 'press_color98' ).set( color );
					api.control( 'press_color98' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[99];
					api( 'press_color99' ).set( color );
					api.control( 'press_color99' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[100];
					api( 'press_color100' ).set( color );
					api.control( 'press_color100' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[101];
					api( 'press_color101' ).set( color );
					api.control( 'press_color101' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[102];
					api( 'press_color102' ).set( color );
					api.control( 'press_color102' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[103];
					api( 'press_color103' ).set( color );
					api.control( 'press_color103' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[104];
					api( 'press_color104' ).set( color );
					api.control( 'press_color104' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[105];
					api( 'press_color105' ).set( color );
					api.control( 'press_color105' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
                    color = colors[106];
					api( 'press_color106' ).set( color );
					api.control( 'press_color106' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
                    color = colors[107];
					api( 'press_color107' ).set( color );
					api.control( 'press_color107' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[108];
					api( 'press_color108' ).set( color );
					api.control( 'press_color108' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[109];
					api( 'press_color109' ).set( color );
					api.control( 'press_color109' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[110];
					api( 'press_color110' ).set( color );
					api.control( 'press_color110' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[111];
					api( 'press_color111' ).set( color );
					api.control( 'press_color111' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[112];
					api( 'press_color112' ).set( color );
					api.control( 'press_color112' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[113];
					api( 'press_color113' ).set( color );
					api.control( 'press_color113' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[114];
					api( 'press_color114' ).set( color );
					api.control( 'press_color114' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[115];
					api( 'press_color115' ).set( color );
					api.control( 'press_color115' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
                    color = colors[116];
					api( 'press_color116' ).set( color );
					api.control( 'press_color116' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
                    color = colors[117];
					api( 'press_color117' ).set( color );
					api.control( 'press_color117' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[118];
					api( 'press_color118' ).set( color );
					api.control( 'press_color118' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[119];
					api( 'press_color119' ).set( color );
					api.control( 'press_color119' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[120];
					api( 'press_color120' ).set( color );
					api.control( 'press_color120' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[121];
					api( 'press_color121' ).set( color );
					api.control( 'press_color121' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[122];
					api( 'press_color122' ).set( color );
					api.control( 'press_color122' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[123];
					api( 'press_color123' ).set( color );
					api.control( 'press_color123' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[124];
					api( 'press_color124' ).set( color );
					api.control( 'press_color124' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
					color = colors[125];
					api( 'press_color125' ).set( color );
					api.control( 'press_color125' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
                    color = colors[126];
					api( 'press_color126' ).set( color );
					api.control( 'press_color126' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
                    color = colors[127];
					api( 'press_color127' ).set( color );
					api.control( 'press_color127' ).container.find( '.color-picker-hex' )
						.data( 'data-default-color', color )
						.wpColorPicker( 'defaultColor', color );
				} );
			}
		}
	} );

	// Generate the CSS for the current Color Scheme.
	function updateCSS() {
		var scheme = api( 'color_scheme' )(),
			css,
			colors = _.object( colorSchemeKeys, colorScheme[ scheme ].colors );

		// Merge in color scheme overrides.
		_.each( colorSettings, function( setting ) {
			colors[ setting ] = api( setting )();
		} );
		
		css = cssTemplate( colors );

		api.previewer.send( 'update-color-scheme-css', css );
	}

	// Update the CSS whenever a color setting is changed.
	_.each( colorSettings, function( setting ) {
		api( setting, function( setting ) {
			setting.bind( updateCSS );
		} );
	} );
} )( wp.customize );
