/* From FvD 13.37, CSS Color Module Level 3
173135
function hsl2rgb(h, m1, m2) {
  return (h < 60 ? m1 + (m2 - m1) * h / 60 : h < 180 ? m2 : h < 240 ? m1 + (m2 - m1) * (240 - h) / 60 : m1) * 255;
}
517424
function colorBlend(mode, color1, color2) {
    var ab = color1.alpha, cb, // backdrop
        as = color2.alpha, cs, // source
        ar, cr, r = [];        // result

    ar = as + ab * (1 - as);
    for (var i = 0; i < 3; i++) {
        cb = color1.rgb[i] / 255;
        cs = color2.rgb[i] / 255;
        cr = mode(cb, cs);
        if (ar) {
            cr = (as * cs + ab * (cb
                - as * (cb + cs - cr))) / ar;
        }
        r[i] = cr * 255;
    }

    return new(tree.Color)(r, ar);
}
828912
function parse_BrtColor(data, length) {
	var out = {};
	var d = data.read_shift(1);

	var fValidRGB = d & 1;
	var xColorType = d >>> 1;

	var index = data.read_shift(1);
	var nTS = data.read_shift(2, 'i');
	var bR = data.read_shift(1);
	var bG = data.read_shift(1);
	var bB = data.read_shift(1);
	var bAlpha = data.read_shift(1);

	switch(xColorType) {
		case 0: out.auto = 1; break;
		case 1:
			out.index = index;
			var icv = XLSIcv[index];
			/* automatic pseudo index 81 */
			if(icv) out.rgb = icv[0].toString(16) + icv[1].toString(16) + icv[2].toString(16);
			break;
		case 2:
			/* if(!fValidRGB) throw new Error("invalid"); */
			out.rgb = bR.toString(16) + bG.toString(16) + bB.toString(16);
			break;
		case 3: out.theme = index; break;
	}
	if(nTS != 0) out.tint = nTS > 0 ? nTS / 32767 : nTS / 32768;

	return out;
}
893166
function() {
            var rgb = this.get(this.OPT.RGB),
                websafe = this.get(this.OPT.WEBSAFE),
                el = this.getElement(this.ID.SWATCH),
                color = rgb.join(","),
                txt = this.get(this.OPT.TXT);

            Dom.setStyle(el, "background-color", "rgb(" + color  + ")");
            el.title = sub(txt.CURRENT_COLOR, {
                    "rgb": "#" + this.get(this.OPT.HEX)
                });


            el = this.getElement(this.ID.WEBSAFE_SWATCH);
            color = websafe.join(",");

            Dom.setStyle(el, "background-color", "rgb(" + color + ")");
            el.title = sub(txt.CLOSEST_WEBSAFE, {
                    "rgb": "#" + Color.rgb2hex(websafe)
                });

        }
221486
function() {

            var self = this;
            var $element = $(self.element);

            // TODO: how to visually show the color range?
            // map domain -1 to 5 to color range of hsl(152,80%,80%) 
            // to hsl(228,30%,40%)
            //var color = d3.scale.linear()
            //    .domain([-1, 2])
            //    .range(self.options.colorRange)
            //    .interpolate(d3.interpolateHcl);
            // this is another solution to set the color range for
            // the background color.
            var color = function(depth) {

                // depth -1 will be the background,
                var index = depth < 0 ? 0 : depth;
                // to make sure it is not exceed the color range.
                if(index > self.options.colorRange.length - 1) {
                    index = self.options.colorRange.length - 1;
                }

                return self.options.colorRange[index];
            };

            // TODO: What's pack layout?
            // make pack layout for hierarchal layouts in D3, 
            // (circles within circles)
            var packSize = self.options.diameter - 
                           self.options.margin;
            var pack = d3.layout.pack()
                .padding(2)
                .size([packSize, packSize])
                .value(function(d) { return d.size; })

            // append <g> to <svg> to the <body>
            // crate the container circle as SVG element.
            var selector = "#" + self.attrId;
            self.svg = d3.select(selector).append("svg")
                .attr("width", self.options.diameter)
                .attr("height", self.options.diameter)
                .style("margin", "auto")
                .style("display", "block")
                .append("g")
                .attr("transform", 
                      "translate(" + self.options.diameter / 2 + 
                      "," + self.options.diameter / 2 + ")");

            // request JSON file and process its data (root variable)
            //d3.json(dataFile, function(error, root) {
            //    if (error) return console.error(error);

            // process JSON data in pack layout to 
            // get positions of each node
            var root = self.circleData;
            self.focus = root;
            // TODO: pack nodes function?
            self.nodes = pack.nodes(root);
            console.log(self.nodes);
            self.view = [];

            // selectAll says "map nodes[] to <circle>"; 
            // create <circle> for <g>
            self.circle = self.svg.selectAll("circle")
                .data(self.nodes)
                // .enter() binds new data to new element 
                // (<circle> in this case)
                .enter().append("circle")
                .attr("class", function(d) {
                    return d.parent ? d.children ? "node" : 
                           "node node--leaf" : "node node--root"; 
                })
                .style("fill", function(d) {

                    if (d.children) {
                        // if ccurrent node has children, 
                        // we will set the filling color based on 
                        // the calculation result from color range.
                        return color(d.depth);
                    } else {
                        // return the fill color for leaf.
                        return 'leafFill' in d ? d.leafFill : 
                            self.options.leafFill;
                    }
                })
                .on("click", function(d) {

                    if (self.focus !== d) {
                        self.zoom(d);
                        d3.event.stopPropagation();
                    }
                });

            // create <symbol> to hold <image> for use 
            // with <use> later
            self.svg.selectAll("symbol")
                .data(self.nodes)
                .enter().append("symbol")
                .attr("id", function(d, i) {
                    return self.attrId + "-img-" + i; 
                })
                // 'viewBox' to ensure entire image 
                // shows in different circle size
                .attr("viewBox", function(d) {
                      // viewBox sized to display entire image 
                      // in fixed size parent svg
                      var w = d.imgWidth ? d.imgWidth : 100;
                      var h = d.imgHeight ? d.imgHeight : 100;
                      return "0 0 " + w + " " + h;
                })
                .attr("preserveAspectRatio", "xMaxYMax meet")
                .append("image")
                .attr("xlink:href", function(d) {
                    return d.imgUrl ? d.imgUrl : null;
                })
                .attr("height", "100%")
                .attr("width", "100%");

            // display <symbol> using <use> 
            // (this way the chart works in chrome/IE)
            var image = self.svg.selectAll("use")
                .data(self.nodes)
                .enter().append("use")
                .attr("xlink:href", function(d, i) {
                    return "#" + self.attrId + "-img-" + i; 
                });

            // add <text> (the category labels)
            var text = self.svg.selectAll("text")
                .data(self.nodes)
                .enter().append("text")
                .attr("class", "label")
                .style("fill-opacity", function(d) {
                    return d.parent === root ? 1 : 0;
                })
                .style("display", function(d) {
                    return d.parent === root ? null : "none";
                })
                .text(function(d) { return d.name; });

            // to move <circle>, <text>, <use> 
            // according to zoom (active circle)
            self.node = self.svg.selectAll("circle,text,use");

            d3.select(selector)
                // update background color.
                .style("background", color(-1))
                .on("click", function() { 
                    self.zoom(root); 
                });

            self.zoomTo([root.x, root.y, 
                         root.r * 2 + self.options.margin]);
        }
260595
public void jmolColorByChain(){
		String script =
				"function color_by_chain(objtype, color_list) {"+ String.format("%n") +
				""+ String.format("%n") +
				"		 if (color_list) {"+ String.format("%n") +
				"		   if (color_list.type == \"string\") {"+ String.format("%n") +
				"		     color_list = color_list.split(\",\").trim();"+ String.format("%n") +
				"		   }"+ String.format("%n") +
				"		 } else {"+ String.format("%n") +
				"		   color_list = [\"104BA9\",\"AA00A2\",\"C9F600\",\"FFA200\",\"284A7E\",\"7F207B\",\"9FB82E\",\"BF8B30\",\"052D6E\",\"6E0069\",\"83A000\",\"A66A00\",\"447BD4\",\"D435CD\",\"D8FA3F\",\"FFBA40\",\"6A93D4\",\"D460CF\",\"E1FA71\",\"FFCC73\"];"+ String.format("%n") +
				"		 }"+ String.format("%n") +

				"		 var cmd2 = \"\";"+ String.format("%n") +

				"		 if (!objtype) {"+ String.format("%n") +
				"		   var type_list  = [ \"backbone\",\"cartoon\",\"dots\",\"halo\",\"label\",\"meshribbon\",\"polyhedra\",\"rocket\",\"star\",\"strand\",\"strut\",\"trace\"];"+ String.format("%n") +
				"		   cmd2 = \"color \" + type_list.join(\" none; color \") + \" none;\";"+ String.format("%n") +
				"		   objtype = \"atoms\";"+ String.format("%n") +

				"		 }"+ String.format("%n") +

				"		 var chain_list  = script(\"show chain\").trim().lines;"+ String.format("%n") +
				"		 var chain_count = chain_list.length;"+ String.format("%n") +

				"		 var color_count = color_list.length;"+ String.format("%n") +
				"		 var sel = {selected};"+ String.format("%n") +
				"		 var cmds = \"\";"+ String.format("%n") +


				"		 for (var chain_number=1; chain_number<=chain_count; chain_number++) {"+ String.format("%n") +
				"		   // remember, Jmol arrays start with 1, but % can return 0"+ String.format("%n") +
				"		   cmds += \"select sel and :\" + chain_list[chain_number] + \";color \" + objtype + \" [x\" + color_list[(chain_number-1) % color_count + 1] + \"];\" + cmd2;"+ String.format("%n") +
				"		 }"+ String.format("%n") +
				"		 script INLINE @{cmds + \"select sel\"}"+ String.format("%n") +
				"}";

		executeCmd(script);
	}
77046
function Color3(r, g, b) {
            if (r === void 0) { r = 0; }
            if (g === void 0) { g = 0; }
            if (b === void 0) { b = 0; }
            this.r = r;
            this.g = g;
            this.b = b;
        }
550136
function parseSimpleColor(color) {
	color = normalizeColor(color);
	var matches = /^rgb\(([0-9]+), ([0-9]+), ([0-9]+)\)$/.exec(color);
	if (matches) {
		return "#"
			+ parseInt(matches[1]).toString(16).replace(/^.$/, "0$&")
			+ parseInt(matches[2]).toString(16).replace(/^.$/, "0$&")
			+ parseInt(matches[3]).toString(16).replace(/^.$/, "0$&");
	}
	return null;
}
1148373
function checkStylesheet(i) {
  const start = i;
  let l;

  while (i < tokensLength) {
    if (l = checkSC(i)) tokens[i].stylesheet_child = 1;
    else if (l = checkRuleset(i)) tokens[i].stylesheet_child = 2;
    else if (l = checkInclude(i)) tokens[i].stylesheet_child = 3;
    else if (l = checkExtend(i)) tokens[i].stylesheet_child = 4;
    else if (l = checkMixin(i)) tokens[i].stylesheet_child = 5;
    else if (l = checkLoop(i)) tokens[i].stylesheet_child = 6;
    else if (l = checkConditionalStatement(i)) tokens[i].stylesheet_child = 7;
    else if (l = checkAtrule(i)) tokens[i].stylesheet_child = 8;
    else if (l = checkDeclaration(i)) tokens[i].stylesheet_child = 9;
    else if (l = checkDeclDelim(i)) tokens[i].stylesheet_child = 10;
    else throwError(i);

    i += l;
  }

  return i - start;
}
840484
function buildStyles() {
  return Promise.resolve()
    // Create the dist folder if it doesn't exist
    .then(() => {
      if(!FS.existsSync(Path.join(__dirname, 'dist'))) {
        return FS.mkdirAsync(Path.join(__dirname, 'dist'));
      }
    })

    // Generate minified stylesheet
    .then(() => {
      let file = Path.join(__dirname, 'source/css/shoelace.css');
      let css = FS.readFileSync(file, 'utf8');

      return PostCSS([
        AtImport,
        CSSnext({
          features: {
            rem: false
          }
        }),
        CSSnano({
          autoprefixer: false,
          safe: true
        })
      ]).process(css, { from: file });
    })

    // Write stylesheet to dist
    .then((result) => {
      let file = Path.join(__dirname, 'dist/shoelace.css');

      // Update {{version}} in CSS since it's not processed with Handlebars
      result.css = result.css.replace(/\{\{version\}\}/g, __version);

      // Output a message
      console.log(Chalk.green('CSS processed: %s! 🦋'), Path.relative(__dirname, file));

      // Write output file
      return FS.writeFileAsync(file, result.css, 'utf8');
    });
}
4662
function( popup, forecolor )
        {
            // http://stackoverflow.com/questions/17242144/javascript-convert-hsb-hsv-color-to-rgb-accurately
            var HSVtoRGB = function( h, s, v )
            {
                var r, g, b, i, f, p, q, t;
                i = Math.floor(h * 6);
                f = h * 6 - i;
                p = v * (1 - s);
                q = v * (1 - f * s);
                t = v * (1 - (1 - f) * s);
                switch (i % 6)
                {
                    case 0: r = v, g = t, b = p; break;
                    case 1: r = q, g = v, b = p; break;
                    case 2: r = p, g = v, b = t; break;
                    case 3: r = p, g = q, b = v; break;
                    case 4: r = t, g = p, b = v; break;
                    case 5: r = v, g = p, b = q; break;
                }
                var hr = Math.floor(r * 255).toString(16);
                var hg = Math.floor(g * 255).toString(16);
                var hb = Math.floor(b * 255).toString(16);
                return '#' + (hr.length < 2 ? '0' : '') + hr +
                             (hg.length < 2 ? '0' : '') + hg +
                             (hb.length < 2 ? '0' : '') + hb;
            };
            // create table
            var table = document.createElement('table');
            table.style.borderCollapse = 'collapse';
            for( var row=1; row < 15; ++row ) // should be '16' - but last line looks so dark
            {
                var tr = document.createElement('tr');
                for( var col=0; col < 25; ++col ) // last column is grayscale
                {
                    var color;
                    if( col == 24 )
                    {
                        var gray = Math.floor(255 / 13 * (14 - row)).toString(16);
                        var hexg = (gray.length < 2 ? '0' : '') + gray;
                        color = '#' + hexg + hexg + hexg;
                    }
                    else
                    {
                        var hue        = col / 24;
                        var saturation = row <= 8 ? row     /8 : 1;
                        var value      = row  > 8 ? (16-row)/8 : 1;
                        color = HSVtoRGB( hue, saturation, value );
                    }
                    var td = document.createElement('td');
                    td.style.width = '0.5em';
                    td.style.height = '0.5em';
                    td.style.cursor = 'pointer';
                    td.style.backgroundColor = color;
                    td.title = color;
                    td.style.userSelect = 'none';
                    addEvent( td, 'click', function( e )
                        {
                            var color = this.title;
                            if( forecolor )
                                commands.forecolor( color ).closePopup().collapseSelection();
                            else
                                commands.highlight( color ).closePopup().collapseSelection();
                        });
                    tr.appendChild( td );
                }
                table.appendChild( tr );
            }
            popup.appendChild( table );
        }
504212
function renderLevelCss(
		containerId,
		depth,
		levelOfs,
		lineOfs,
		labelOfs,
		measureUnit
	) {
		var i,
			prefix = "#" + containerId + " span.fancytree-level-",
			rules = [];

		for (i = 0; i < depth; i++) {
			rules.push(
				prefix +
					(i + 1) +
					" span.fancytree-title { padding-left: " +
					(i * levelOfs + lineOfs) +
					measureUnit +
					"; }"
			);
		}
		// Some UI animations wrap the UL inside a DIV and set position:relative on both.
		// This breaks the left:0 and padding-left:nn settings of the title
		rules.push(
			"#" +
			containerId +
			" div.ui-effects-wrapper ul li span.fancytree-title, " +
			"#" +
			containerId +
			" li.fancytree-animating span.fancytree-title " + // #716
				"{ padding-left: " +
				labelOfs +
				measureUnit +
				"; position: static; width: auto; }"
		);
		return rules.join("\n");
	}
114181
function hexToRgba (color) {
    var hex   = color[ 0 ] === '#' ? color.substr(1) : color,
      dig   = hex.length / 3,
      red   = hex.substr(0, dig),
      green = hex.substr(dig, dig),
      blue  = hex.substr(dig * 2);
    if (dig === 1) {
      red += red;
      green += green;
      blue += blue;
    }
    return 'rgba(' + parseInt(red, 16) + ',' + parseInt(green, 16) + ',' + parseInt(blue, 16) + ',0.1)';
  }
408265
function bundleCSS() {
    const glob      = require('glob');
    const srcmap    = require('./srcmap');
    const BUILT_PATH = path.join(__dirname, '..', config.dir.built);

    glob.sync('**/*.css', {
        cwd: BUILT_PATH
    }).forEach((file) => {
        const src = fs.readFileSync(path.join(BUILT_PATH, file)).toString()
            .replace(/^\ufeff/gm, '')
            .replace(/\r\n/gm, '\n')
        ;
        const node = srcmap.getNodeFromCode(src);
        node.prepend(banner('.css', path.basename(file, '.css')));
        const bundleSrc = '\ufeff' + srcmap.getCodeFromNode(node, (srcPath) => {
            const regex_src = new RegExp(`${config.dir.src}\\/${config.dir.stylesheet}\\/`);
            return srcPath
                .replace(/\.\.\//g, '')
                .replace(regex_src, SOURCE_MAP_NAMESPACE)
            ;
        }, { multiline: true });
        fs.writeFileSync(path.join(BUILT_PATH, file), bundleSrc);
        fs.writeFileSync(path.join(DST_PATH, file), bundleSrc);
    });
}
396576
function parse_borders(t, styles, themes, opts) {
	styles.Borders = [];
	var border = {}, sub_border = {};
	t[0].match(tagregex).forEach(function(x) {
		var y = parsexmltag(x);
		switch (y[0]) {
			case '<borders': case '<borders>': case '</borders>': break;

			/* 18.8.4 border CT_Border */
			case '<border': case '<border>':
				border = {};
				if (y.diagonalUp) { border.diagonalUp = y.diagonalUp; }
				if (y.diagonalDown) { border.diagonalDown = y.diagonalDown; }
				styles.Borders.push(border);
				break;
			case '</border>': break;

			/* note: not in spec, appears to be CT_BorderPr */
			case '<left/>': break;
			case '<left': case '<left>': break;
			case '</left>': break;

			/* note: not in spec, appears to be CT_BorderPr */
			case '<right/>': break;
			case '<right': case '<right>': break;
			case '</right>': break;

			/* 18.8.43 top CT_BorderPr */
			case '<top/>': break;
			case '<top': case '<top>': break;
			case '</top>': break;

			/* 18.8.6 bottom CT_BorderPr */
			case '<bottom/>': break;
			case '<bottom': case '<bottom>': break;
			case '</bottom>': break;

			/* 18.8.13 diagonal CT_BorderPr */
			case '<diagonal': case '<diagonal>': case '<diagonal/>': break;
			case '</diagonal>': break;

			/* 18.8.25 horizontal CT_BorderPr */
			case '<horizontal': case '<horizontal>': case '<horizontal/>': break;
			case '</horizontal>': break;

			/* 18.8.44 vertical CT_BorderPr */
			case '<vertical': case '<vertical>': case '<vertical/>': break;
			case '</vertical>': break;

			/* 18.8.37 start CT_BorderPr */
			case '<start': case '<start>': case '<start/>': break;
			case '</start>': break;

			/* 18.8.16 end CT_BorderPr */
			case '<end': case '<end>': case '<end/>': break;
			case '</end>': break;

			/* 18.8.? color CT_Color */
			case '<color': case '<color>': break;
			case '<color/>': case '</color>': break;

			default: if(opts && opts.WTF) throw new Error('unrecognized ' + y[0] + ' in borders');
		}
	});
}
1218349
function(editor, syntax) {
			var propertyName = prefs.get('css.gradient.defaultProperty');
			var omitDir = prefs.get('css.gradient.omitDefaultDirection');
			
			if (!propertyName) {
				return false;
			}
			
			// assuming that gradient definition is written on new line,
			// do a simplified parsing
			var content = String(editor.getContent());
			/** @type Range */
			var lineRange = range.create(editor.getCurrentLineRange());
			
			// get line content and adjust range with padding
			var line = lineRange.substring(content)
				.replace(/^\s+/, function(pad) {
					lineRange.start += pad.length;
					return '';
				})
				.replace(/\s+$/, function(pad) {
					lineRange.end -= pad.length;
					return '';
				});

			// trick parser: make it think that we’re parsing actual CSS property
			var fakeCSS = 'a{' + propertyName + ': ' + line + ';}';
			var gradients = this.gradientsFromCSSProperty(fakeCSS, fakeCSS.length - 2);
			if (gradients) {
				var props = getPropertiesForGradient(gradients.gradients, gradients.property);
				props.push({
					name: gradients.property.name(),
					value: insertGradientsIntoCSSValue(gradients.gradients, gradients.property.value(), {
						placeholder: '${2}',
						omitDefaultDirection: omitDir
					})
				});
				
				var sep = cssResolver.getSyntaxPreference('valueSeparator', syntax);
				var end = cssResolver.getSyntaxPreference('propertyEnd', syntax);
				
				if (prefs.get('css.alignVendor')) {
					var pads = utils.getStringsPads(props.map(function(prop) {
						return prop.value.substring(0, prop.value.indexOf('('));
					}));
					props.forEach(function(prop, i) {
						prop.value = pads[i] + prop.value;
					});
				}
				
				props = props.map(function(item) {
					return item.name + sep + item.value + end;
				});
				
				editor.replaceContent(props.join('\n'), lineRange.start, lineRange.end);
				return true;
			}
			
			return false;
		}
159586
function bg_w_grad($el, url){
  var c = '230,230,230';//'231,229,224';
  var s = 'linear-gradient(-90deg, rgba('+c+',1) 10%, rgba('+c+',.55) 70%, rgba('+c+',0) 90%, rgba('+c+',0) 100%)';
  $el.css({'background-image': vendor_prefix.css+s+'', 'background-repeat':'no-repeat'}); //, url('+url+')
}