!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.Palette=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
(function (global){
var Color, LoadingErrors, P, Palette, RandomColor, RandomPalette, load_palette, options,
  extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  hasProp = {}.hasOwnProperty;

Palette = require("./Palette");

Color = require("./Color");

RandomColor = (function(superClass) {
  extend(RandomColor, superClass);

  function RandomColor() {
    this.randomize();
  }

  RandomColor.prototype.randomize = function() {
    this.h = Math.random() * 360;
    this.s = Math.random() * 100;
    return this.l = Math.random() * 100;
  };

  RandomColor.prototype.toString = function() {
    this.randomize();
    return "hsl(" + this.h + ", " + this.s + "%, " + this.l + "%)";
  };

  RandomColor.prototype.is = function() {
    return false;
  };

  return RandomColor;

})(Color);

RandomPalette = (function(superClass) {
  extend(RandomPalette, superClass);

  function RandomPalette() {
    var i, j, ref;
    RandomPalette.__super__.constructor.call(this);
    this.loaded_as = "Completely Random Colors™";
    this.loaded_as_clause = "(.crc sjf(Df09sjdfksdlfmnm ';';";
    this.confidence = 0;
    this.finalize();
    for (i = j = 0, ref = Math.random() * 15 + 5; 0 <= ref ? j <= ref : j >= ref; i = 0 <= ref ? ++j : --j) {
      this.push(new RandomColor());
    }
  }

  return RandomPalette;

})(Palette);

LoadingErrors = (function(superClass) {
  extend(LoadingErrors, superClass);

  function LoadingErrors(errors1) {
    var error;
    this.errors = errors1;
    this.message = "Some errors were encountered when loading:" + (function() {
      var j, len, ref, results;
      ref = this.errors;
      results = [];
      for (j = 0, len = ref.length; j < len; j++) {
        error = ref[j];
        results.push("\n\t" + error.message);
      }
      return results;
    }).call(this);
  }

  return LoadingErrors;

})(Error);

load_palette = function(o, callback) {
  var e, err, errors, exts_pretty, j, k, len, len1, msg, palette, palette_loaders, pl;
  palette_loaders = [
    {
      name: "Paint Shop Pro palette",
      exts: ["pal", "psppalette"],
      load: require("./loaders/PaintShopPro")
    }, {
      name: "RIFF PAL",
      exts: ["pal"],
      load: require("./loaders/RIFF")
    }, {
      name: "ColorSchemer palette",
      exts: ["cs"],
      load: require("./loaders/ColorSchemer")
    }, {
      name: "Paint.NET palette",
      exts: ["txt", "pdn"],
      load: require("./loaders/Paint.NET")
    }, {
      name: "GIMP palette",
      exts: ["gpl", "gimp", "colors"],
      load: require("./loaders/GIMP")
    }, {
      name: "hey look some colors",
      exts: ["txt", "html", "css", "xml", "svg", "etc"],
      load: require("./loaders/Generic")
    }, {
      name: "Houndstooth Palette Locellate",
      exts: ["hpl"],
      load: require("./loaders/HPL")
    }, {
      name: "StarCraft palette",
      exts: ["pal"],
      load: require("./loaders/StarCraft")
    }, {
      name: "StarCraft terrain palette",
      exts: ["wpe"],
      load: require("./loaders/StarCraftPadded")
    }
  ];
  for (j = 0, len = palette_loaders.length; j < len; j++) {
    pl = palette_loaders[j];
    pl.matches_ext = pl.exts.indexOf(o.file_ext) !== -1;
  }
  palette_loaders.sort(function(pl1, pl2) {
    return pl2.matches_ext - pl1.matches_ext;
  });
  errors = [];
  for (k = 0, len1 = palette_loaders.length; k < len1; k++) {
    pl = palette_loaders[k];
    try {
      palette = pl.load(o);
      if (palette.length === 0) {
        palette = null;
        throw new Error("no colors returned");
      }
    } catch (_error) {
      e = _error;
      msg = "failed to load " + o.file_name + " as " + pl.name + ": " + e.message;
      if (pl.matches_ext && !e.message.match(/not a/i)) {
        if (typeof console !== "undefined" && console !== null) {
          if (typeof console.error === "function") {
            console.error(msg);
          }
        }
      } else {
        if (typeof console !== "undefined" && console !== null) {
          if (typeof console.warn === "function") {
            console.warn(msg);
          }
        }
      }
      err = new Error(msg);
      err.error = e;
      errors.push(err);
    }
    if (palette) {
      if (typeof console !== "undefined" && console !== null) {
        if (typeof console.info === "function") {
          console.info("loaded " + o.file_name + " as " + pl.name);
        }
      }
      palette.confidence = pl.matches_ext ? 0.9 : 0.01;
      palette.loaded_as = pl.name;
      exts_pretty = "(." + (pl.exts.join(", .")) + ")";
      if (pl.matches_ext) {
        palette.loaded_as_clause = exts_pretty;
      } else {
        palette.loaded_as_clause = " for some reason";
      }
      palette.finalize();
      callback(null, palette);
      return;
    }
  }
  callback(new LoadingErrors(errors));
};

options = function(o) {
  var ref, ref1, ref2, ref3, ref4, ref5;
  if (o == null) {
    o = {};
  }
  if (typeof o === "string" || o instanceof String) {
    o = {
      file_name: o
    };
  }
  if ((typeof File !== "undefined" && File !== null) && o instanceof File) {
    o = {
      file: o
    };
  }
  if (o.min_colors == null) {
    o.min_colors = (ref = o.minColors) != null ? ref : 2;
  }
  if (o.max_colors == null) {
    o.max_colors = (ref1 = o.maxColors) != null ? ref1 : 256;
  }
  if (o.file_name == null) {
    o.file_name = (ref2 = (ref3 = o.fileName) != null ? ref3 : o.fname) != null ? ref2 : (ref4 = o.file) != null ? ref4.name : void 0;
  }
  if (o.file_ext == null) {
    o.file_ext = (ref5 = o.fileExt) != null ? ref5 : ("" + o.file_name).split(".").pop();
  }
  o.file_ext = ("" + o.file_ext).toLowerCase();
  return o;
};

Palette.load = function(o, callback) {
  var fr, fs;
  if (!o) {
    throw new Error("Parameters required: Palette.load(options, function callback(err, palette){})");
  }
  if (!callback) {
    throw new Error("Callback required: Palette.load(options, function callback(err, palette){})");
  }
  o = options(o);
  if (o.data) {
    return load_palette(o, callback);
  } else if ((typeof File !== "undefined" && File !== null) && o.file instanceof File) {
    fr = new FileReader;
    fr.onload = function() {
      o.data = fr.result;
      return load_palette(o, callback);
    };
    return fr.readAsBinaryString(o.file);
  } else if (typeof global !== "undefined" && global !== null) {
    fs = require("fs");
    return fs.readFile(o.file_name, function(err, data) {
      if (err) {
        return callback(err);
      } else {
        o.data = data.toString("binary");
        return load_palette(o, callback);
      }
    });
  } else {
    return callback(new Error("Could not load. The File API may not be supported."));
  }
};

Palette.gimme = function(o, callback) {
  o = options(o);
  return Palette.load(o, function(err, palette) {
    return callback(null, palette != null ? palette : new RandomPalette);
  });
};

P = module.exports = Palette;

P.Color = Color;

P.Palette = Palette;

P.RandomColor = RandomColor;

P.RandomPalette = RandomPalette;



}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})

},{"./Color":3,"./Palette":4,"./loaders/ColorSchemer":5,"./loaders/GIMP":6,"./loaders/Generic":7,"./loaders/HPL":8,"./loaders/Paint.NET":9,"./loaders/PaintShopPro":10,"./loaders/RIFF":11,"./loaders/StarCraft":12,"./loaders/StarCraftPadded":13,"fs":"fs"}],2:[function(require,module,exports){

/*
BinaryReader

Modified by Isaiah Odhner
@TODO: use jDataView + jBinary instead

Refactored by Vjeux <vjeuxx@gmail.com>
http://blog.vjeux.com/2010/javascript/javascript-binary-reader.html

Original
+ Jonas Raoni Soares Silva
@ http://jsfromhell.com/classes/binary-parser [rev. #1]
 */
var BinaryReader;

module.exports = BinaryReader = (function() {
  function BinaryReader(data) {
    this._buffer = data;
    this._pos = 0;
  }

  BinaryReader.prototype.readByte = function() {
    var ch;
    this._checkSize(8);
    ch = this._buffer.charCodeAt(this._pos) & 0xff;
    this._pos += 1;
    return ch & 0xff;
  };

  BinaryReader.prototype.readUnicodeString = function() {
    var i, j, length, ref, str;
    length = this.readUInt16();
    console.log({
      length: length
    });
    this._checkSize(length * 16);
    str = "";
    for (i = j = 0, ref = length; 0 <= ref ? j <= ref : j >= ref; i = 0 <= ref ? ++j : --j) {
      str += String.fromCharCode(this._buffer.substr(this._pos, 1) | (this._buffer.substr(this._pos + 1, 1) << 8));
      this._pos += 2;
    }
    return str;
  };

  BinaryReader.prototype.readInt8 = function() {
    return this._decodeInt(8, true);
  };

  BinaryReader.prototype.readUInt8 = function() {
    return this._decodeInt(8, false);
  };

  BinaryReader.prototype.readInt16 = function() {
    return this._decodeInt(16, true);
  };

  BinaryReader.prototype.readUInt16 = function() {
    return this._decodeInt(16, false);
  };

  BinaryReader.prototype.readInt32 = function() {
    return this._decodeInt(32, true);
  };

  BinaryReader.prototype.readUInt32 = function() {
    return this._decodeInt(32, false);
  };

  BinaryReader.prototype.readFloat = function() {
    return this._decodeFloat(23, 8);
  };

  BinaryReader.prototype.readDouble = function() {
    return this._decodeFloat(52, 11);
  };

  BinaryReader.prototype.readChar = function() {
    return this.readString(1);
  };

  BinaryReader.prototype.readString = function(length) {
    var result;
    this._checkSize(length * 8);
    result = this._buffer.substr(this._pos, length);
    this._pos += length;
    return result;
  };

  BinaryReader.prototype.seek = function(pos) {
    this._pos = pos;
    return this._checkSize(0);
  };

  BinaryReader.prototype.getPosition = function() {
    return this._pos;
  };

  BinaryReader.prototype.getSize = function() {
    return this._buffer.length;
  };

  BinaryReader.prototype._decodeFloat = function(precisionBits, exponentBits){
		var length = precisionBits + exponentBits + 1;
		var size = length >> 3;
		this._checkSize(length);

		var bias = Math.pow(2, exponentBits - 1) - 1;
		var signal = this._readBits(precisionBits + exponentBits, 1, size);
		var exponent = this._readBits(precisionBits, exponentBits, size);
		var significand = 0;
		var divisor = 2;
		var curByte = 0; //length + (-precisionBits >> 3) - 1;
		do {
			var byteValue = this._readByte(++curByte, size);
			var startBit = precisionBits % 8 || 8;
			var mask = 1 << startBit;
			while (mask >>= 1) {
				if (byteValue & mask) {
					significand += 1 / divisor;
				}
				divisor *= 2;
			}
		} while (precisionBits -= startBit);

		this._pos += size;

		return exponent == (bias << 1) + 1 ? significand ? NaN : signal ? -Infinity : +Infinity
			: (1 + signal * -2) * (exponent || significand ? !exponent ? Math.pow(2, -bias + 1) * significand
			: Math.pow(2, exponent - bias) * (1 + significand) : 0);
	};

  BinaryReader.prototype._decodeInt = function(bits, signed){
		var x = this._readBits(0, bits, bits / 8), max = Math.pow(2, bits);
		var result = signed && x >= max / 2 ? x - max : x;

		this._pos += bits / 8;
		return result;
	};

  BinaryReader.prototype._shl = function (a, b){
		for (++b; --b; a = ((a %= 0x7fffffff + 1) & 0x40000000) == 0x40000000 ? a * 2 : (a - 0x40000000) * 2 + 0x7fffffff + 1);
		return a;
	};

  BinaryReader.prototype._readByte = function (i, size) {
		return this._buffer.charCodeAt(this._pos + size - i - 1) & 0xff;
	};

  BinaryReader.prototype._readBits = function (start, length, size) {
		var offsetLeft = (start + length) % 8;
		var offsetRight = start % 8;
		var curByte = size - (start >> 3) - 1;
		var lastByte = size + (-(start + length) >> 3);
		var diff = curByte - lastByte;

		var sum = (this._readByte(curByte, size) >> offsetRight) & ((1 << (diff ? 8 - offsetRight : length)) - 1);

		if (diff && offsetLeft) {
			sum += (this._readByte(lastByte++, size) & ((1 << offsetLeft) - 1)) << (diff-- << 3) - offsetRight; 
		}

		while (diff) {
			sum += this._shl(this._readByte(lastByte++, size), (diff-- << 3) - offsetRight);
		}

		return sum;
	};

  BinaryReader.prototype._checkSize = function(neededBits) {
    if (this._pos + Math.ceil(neededBits / 8) > this._buffer.length) {
      throw new Error("Index out of bound");
    }
  };

  return BinaryReader;

})();



},{}],3:[function(require,module,exports){
var Color;

module.exports = Color = (function() {
  function Color(arg) {
    var _, c, i, j, k, len, len1, m, powed, ref, ref1, rgb, white, xyz, y;
    this.r = arg.r, this.g = arg.g, this.b = arg.b, this.h = arg.h, this.s = arg.s, this.v = arg.v, this.l = arg.l, c = arg.c, m = arg.m, y = arg.y, k = arg.k, this.name = arg.name;
    if ((this.r != null) && (this.g != null) && (this.b != null)) {

    } else if ((this.h != null) && (this.s != null)) {
      if (this.v != null) {
        this.l = (2 - this.s / 100) * this.v / 2;
        this.s = this.s * this.v / (this.l < 50 ? this.l * 2 : 200 - this.l * 2);
        if (isNaN(this.s)) {
          this.s = 0;
        }
      } else if (this.l != null) {

      } else {
        throw new Error("Hue, saturation, and...? (either lightness or value)");
      }
    } else if ((c != null) && (m != null) && (y != null) && (k != null)) {
      c /= 100;
      m /= 100;
      y /= 100;
      k /= 100;
      this.r = 255 * (1 - Math.min(1, c * (1 - k) + k));
      this.g = 255 * (1 - Math.min(1, m * (1 - k) + k));
      this.b = 255 * (1 - Math.min(1, y * (1 - k) + k));
    } else {
      if ((this.l != null) && (this.a != null) && (this.b != null)) {
        white = {
          x: 95.047,
          y: 100.000,
          z: 108.883
        };
        xyz = {
          y: (raw.l + 16) / 116,
          x: raw.a / 500 + xyz.y,
          z: xyz.y - raw.b / 200
        };
        ref = "xyz";
        for (i = 0, len = ref.length; i < len; i++) {
          _ = ref[i];
          powed = Math.pow(xyz[_], 3);
          if (powed > 0.008856) {
            xyz[_] = powed;
          } else {
            xyz[_] = (xyz[_] - 16 / 116) / 7.787;
          }
        }
      }
      if ((this.x != null) && (this.y != null) && (this.z != null)) {
        xyz = {
          x: raw.x / 100,
          y: raw.y / 100,
          z: raw.z / 100
        };
        rgb = {
          r: xyz.x * 3.2406 + xyz.y * -1.5372 + xyz.z * -0.4986,
          g: xyz.x * -0.9689 + xyz.y * 1.8758 + xyz.z * 0.0415,
          b: xyz.x * 0.0557 + xyz.y * -0.2040 + xyz.z * 1.0570
        };
        ref1 = "rgb";
        for (j = 0, len1 = ref1.length; j < len1; j++) {
          _ = ref1[j];
          if (rgb[_] < 0) {
            rgb[_] = 0;
          }
          if (rgb[_] > 0.0031308) {
            rgb[_] = 1.055 * Math.pow(rgb[_], 1 / 2.4) - 0.055;
          } else {
            rgb[_] *= 12.92;
          }
        }
      } else {
        throw new Error("Color constructor must be called with {r,g,b} or {h,s,v} or {h,s,l} or {c,m,y,k} or {x,y,z} or {l,a,b}");
      }
    }
  }

  Color.prototype.toString = function() {
    if (this.r != null) {
      if (this.a != null) {
        return "rgba(" + this.r + ", " + this.g + ", " + this.b + ", " + this.a + ")";
      } else {
        return "rgb(" + this.r + ", " + this.g + ", " + this.b + ")";
      }
    } else if (this.h != null) {
      if (this.a != null) {
        return "hsla(" + this.h + ", " + this.s + "%, " + this.l + "%, " + this.a + ")";
      } else {
        return "hsl(" + this.h + ", " + this.s + "%, " + this.l + "%)";
      }
    }
  };

  Color.prototype.is = function(color) {
    return ("" + this) === ("" + color);
  };

  return Color;

})();



},{}],4:[function(require,module,exports){
var Color, Palette,
  extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  hasProp = {}.hasOwnProperty;

Color = require("./Color");

module.exports = Palette = (function(superClass) {
  extend(Palette, superClass);

  function Palette() {
    Palette.__super__.constructor.call(this);
    this.with_duplicates = this;
  }

  Palette.prototype.add = function(o) {
    var color, i, len1, new_color;
    new_color = new Color(o);
    if (this.with_duplicates === this) {
      this.with_duplicates = new Palette();
    }
    this.with_duplicates.push(new_color);
    for (i = 0, len1 = this.length; i < len1; i++) {
      color = this[i];
      if (color.is(new_color)) {
        new_color.is_duplicate = true;
        return;
      }
    }
    return this.push(new_color);
  };

  Palette.prototype.finalize = function() {
    if (!this.n_columns) {
      this.guess_dimensions();
    }
    if (this.with_duplicates) {
      return this.with_duplicates.guess_dimensions();
    }
  };

  Palette.prototype.guess_dimensions = function() {
    var candidate_dimensions, cd, i, j, len, len1, n_columns, n_rows, ref, results, squarest;
    len = this.length;
    candidate_dimensions = [];
    for (n_columns = i = 0, ref = len; 0 <= ref ? i <= ref : i >= ref; n_columns = 0 <= ref ? ++i : --i) {
      n_rows = len / n_columns;
      if (n_rows === Math.round(n_rows)) {
        candidate_dimensions.push([n_rows, n_columns]);
      }
    }
    squarest = [0, 3495093];
    results = [];
    for (j = 0, len1 = candidate_dimensions.length; j < len1; j++) {
      cd = candidate_dimensions[j];
      if (Math.abs(cd[0] - cd[1]) < Math.abs(squarest[0] - squarest[1])) {
        results.push(squarest = cd);
      } else {
        results.push(void 0);
      }
    }
    return results;
  };

  return Palette;

})(Array);



},{"./Color":3}],5:[function(require,module,exports){
var BinaryReader, Palette;

BinaryReader = require("../BinaryReader");

Palette = require("../Palette");

module.exports = function(arg) {
  var br, data, i, length, palette, version;
  data = arg.data;
  palette = new Palette();
  br = new BinaryReader(data);
  version = br.readUInt16();
  length = br.readUInt16();
  i = 0;
  while (i < length) {
    br.seek(8 + i * 26);
    palette.add({
      r: br.readByte(),
      g: br.readByte(),
      b: br.readByte()
    });
    i += 1;
  }
  return palette;
};



},{"../BinaryReader":2,"../Palette":4}],6:[function(require,module,exports){
var Palette;

Palette = require("../Palette");

module.exports = function(arg) {
  var data, i, line, lines, m, palette, r_g_b_name;
  data = arg.data;
  lines = data.split(/[\n\r]+/m);
  if (lines[0] !== "GIMP Palette") {
    throw new Error("Not a GIMP Palette");
  }
  palette = new Palette();
  i = 1;
  while ((i += 1) < lines.length) {
    line = lines[i];
    if (line.match(/^#/) || line === "") {
      continue;
    }
    m = line.match(/Name:\s*(.*)/);
    if (m) {
      palette.name = m[1];
      continue;
    }
    m = line.match(/Columns:\s*(.*)/);
    if (m) {
      palette.n_columns = Number(m[1]);
      palette.has_dimensions = true;
      continue;
    }
    r_g_b_name = line.match(/^\s*([0-9]+)\s+([0-9]+)\s+([0-9]+)(?:\s+(.*))?$/);
    if (!r_g_b_name) {
      throw new Error("Line " + i + " doesn't match pattern r_g_b_name");
    }
    palette.add({
      r: r_g_b_name[1],
      g: r_g_b_name[2],
      b: r_g_b_name[3],
      name: r_g_b_name[4]
    });
  }
  return palette;
};



},{"../Palette":4}],7:[function(require,module,exports){
var Palette;

Palette = require("../Palette");

module.exports = function(arg) {
  var data, hex, i, len, most_colors, n, palette, palette_hsl, palette_hsla, palette_rgb, palette_rgba, palette_xRGB, palette_xRRGGBB, palettes;
  data = arg.data;
  palettes = [palette_xRRGGBB = new Palette(), palette_xRGB = new Palette(), palette_rgb = new Palette(), palette_hsl = new Palette(), palette_hsla = new Palette(), palette_rgba = new Palette()];
  hex = function(x) {
    return parseInt(x, 16);
  };
  data.replace(/\#([0-9A-F]{2})?([0-9A-F]{3})([0-9A-F]{3})?(?![0-9A-F])/gim, function(m, $0, $1, $2) {
    var alpha, xRGB;
    alpha = hex($0);
    if ($2) {
      xRGB = $1 + $2;
      return palette_xRRGGBB.add({
        r: hex(xRGB[0] + xRGB[1]),
        g: hex(xRGB[2] + xRGB[3]),
        b: hex(xRGB[4] + xRGB[5]),
        a: alpha
      });
    } else {
      xRGB = $1;
      return palette_xRGB.add({
        r: hex(xRGB[0] + xRGB[0]),
        g: hex(xRGB[1] + xRGB[1]),
        b: hex(xRGB[2] + xRGB[2]),
        a: alpha
      });
    }
  });
  data.replace(/rgb\(\s*([0-9]{1,3}),\s*([0-9]{1,3}),\s*([0-9]{1,3})\s*\)/gim, function(m) {
    return palette_rgb.add({
      r: Number(m[1]),
      g: Number(m[2]),
      b: Number(m[3])
    });
  });
  data.replace(/rgba\(\s*([0-9]{1,3}),\s*([0-9]{1,3}),\s*([0-9]{1,3}),\s*([0-9]{1,3}|0\.[0-9]+)\s*\)/gim, function(m) {
    return palette_rgb.add({
      r: Number(m[1]),
      g: Number(m[2]),
      b: Number(m[3]),
      a: Number(m[4])
    });
  });
  data.replace(/hsl\(\s*([0-9]{1,3}),\s*([0-9]{1,3}),\s*([0-9]{1,3})\s*\)/gim, function(m) {
    return palette_rgb.add({
      h: Number(m[1]),
      s: Number(m[2]),
      l: Number(m[3])
    });
  });
  most_colors = [];
  for (i = 0, len = palettes.length; i < len; i++) {
    palette = palettes[i];
    if (palette.length >= most_colors.length) {
      most_colors = palette;
    }
  }
  n = most_colors.length;
  if (n < 4) {
    throw new Error(["No colors found", "Only one color found", "Only a couple colors found", "Only a few colors found"][n] + (" (" + n + ")"));
  }
  return most_colors;
};



},{"../Palette":4}],8:[function(require,module,exports){
var Palette;

Palette = require("../Palette");

module.exports = function(arg) {
  var data, i, j, len, line, lines, palette, rgb;
  data = arg.data;
  lines = data.split(/[\n\r]+/m);
  if (lines[0] !== "Palette") {
    throw new Error("Not an HPL palette");
  }
  if (!lines[1].match(/Version [34]\.0/)) {
    throw new Error("Unsupported HPL version");
  }
  palette = new Palette();
  for (i = j = 0, len = lines.length; j < len; i = ++j) {
    line = lines[i];
    if (line.match(/.+ .* .+/)) {
      rgb = line.split(" ");
      palette.add({
        r: rgb[0],
        g: rgb[1],
        b: rgb[2]
      });
    }
  }
  return palette;
};



},{"../Palette":4}],9:[function(require,module,exports){
var BinaryReader, Palette;

BinaryReader = require("../BinaryReader");

Palette = require("../Palette");

module.exports = function(arg) {
  var data, hex, i, len, line, m, palette, ref;
  data = arg.data;
  palette = new Palette();
  hex = function(x) {
    return parseInt(x, 16);
  };
  ref = data.split(/[\n\r]+/m);
  for (i = 0, len = ref.length; i < len; i++) {
    line = ref[i];
    m = line.match(/^([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$/i);
    if (m) {
      palette.add({
        a: hex(m[1]),
        r: hex(m[2]),
        g: hex(m[3]),
        b: hex(m[4])
      });
    }
  }
  return palette;
};



},{"../BinaryReader":2,"../Palette":4}],10:[function(require,module,exports){
var BinaryReader, Palette;

BinaryReader = require("../BinaryReader");

Palette = require("../Palette");

module.exports = function(arg) {
  var data, i, j, len, line, lines, palette, rgb;
  data = arg.data;
  lines = data.split(/[\n\r]+/m);
  if (lines[0] !== "JASC-PAL") {
    throw new Error("Not a JASC-PAL");
  }
  if (lines[1] !== "0100") {
    throw new Error("Unknown JASC-PAL version");
  }
  if (lines[2] !== "256") {
    "that's ok";
  }
  palette = new Palette();
  for (i = j = 0, len = lines.length; j < len; i = ++j) {
    line = lines[i];
    if (line !== "" && i > 2) {
      rgb = line.split(" ");
      palette.add({
        r: rgb[0],
        g: rgb[1],
        b: rgb[2]
      });
    }
  }
  return palette;
};



},{"../BinaryReader":2,"../Palette":4}],11:[function(require,module,exports){
var BinaryReader, Palette;

BinaryReader = require("../BinaryReader");

Palette = require("../Palette");

module.exports = function(arg) {
  var br, chunkSize, chunkType, data, dataSize, i, palNumEntries, palVersion, palette, riff, type;
  data = arg.data;
  br = new BinaryReader(data);
  riff = br.readString(4);
  dataSize = br.readUInt32();
  type = br.readString(4);
  if (riff !== "RIFF") {
    throw new Error("RIFF header not found; not a RIFF PAL file");
  }
  if (type !== "PAL ") {
    throw new Error("RIFF header says this isn't a PAL file,\nmore of a sort of " + ((type + "").trim()) + " file");
  }
  chunkType = br.readString(4);
  chunkSize = br.readUInt32();
  palVersion = br.readUInt16();
  palNumEntries = br.readUInt16();
  if (chunkType !== "data") {
    throw new Error("Data chunk not found (...'" + chunkType + "'?)");
  }
  if (palVersion !== 0x0300) {
    throw new Error("Unsupported PAL file version: 0x" + (palVersion.toString(16)));
  }
  palette = new Palette();
  i = 0;
  while ((i += 1) < palNumEntries - 1) {
    palette.add({
      r: br.readByte(),
      g: br.readByte(),
      b: br.readByte(),
      _: br.readByte()
    });
  }
  return palette;
};



},{"../BinaryReader":2,"../Palette":4}],12:[function(require,module,exports){
var BinaryReader, Palette;

BinaryReader = require("../BinaryReader");

Palette = require("../Palette");

module.exports = function(arg) {
  var br, data, i, j, palette;
  data = arg.data;
  palette = new Palette();
  br = new BinaryReader(data);
  for (i = j = 0; j < 255; i = ++j) {
    palette.add({
      r: br.readByte(),
      g: br.readByte(),
      b: br.readByte()
    });
  }
  return palette;
};



},{"../BinaryReader":2,"../Palette":4}],13:[function(require,module,exports){
var BinaryReader, Palette;

BinaryReader = require("../BinaryReader");

Palette = require("../Palette");

module.exports = function(arg) {
  var br, data, i, j, palette;
  data = arg.data;
  palette = new Palette();
  br = new BinaryReader(data);
  for (i = j = 0; j < 255; i = ++j) {
    palette.add({
      r: br.readByte(),
      g: br.readByte(),
      b: br.readByte(),
      _: br.readByte()
    });
  }
  palette.n_columns = 16;
  return palette;
};



},{"../BinaryReader":2,"../Palette":4}]},{},[1])(1)
});
//# sourceMappingURL=data:application/json;base64,[encoded data, 65308 characters]
