import u from "./utils/clip_rgb.js";
import n from "./utils/type.js";
import l from "./utils/last.js";
import o from "./io/input.js";
class d {
  constructor(...t) {
    const i = this;
    if (n(t[0]) === "object" && t[0].constructor && t[0].constructor === this.constructor)
      return t[0];
    let r = l(t), c = !1;
    if (!r) {
      c = !0, o.sorted || (o.autodetect = o.autodetect.sort((e, f) => f.p - e.p), o.sorted = !0);
      for (let e of o.autodetect)
        if (r = e.test(...t), r) break;
    }
    if (o.format[r]) {
      const e = o.format[r].apply(
        null,
        c ? t : t.slice(0, -1)
      );
      i._rgb = u(e);
    } else
      throw new Error("unknown format: " + t);
    i._rgb.length === 3 && i._rgb.push(1);
  }
  toString() {
    return n(this.hex) == "function" ? this.hex() : `[${this._rgb.join(",")}]`;
  }
}
export {
  d as default
};
//# sourceMappingURL=Color.js.map
