var l = Object.defineProperty;
var d = (s, e, r) => e in s ? l(s, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : s[e] = r;
var t = (s, e, r) => d(s, typeof e != "symbol" ? e + "" : e, r);
import { ContentType as p } from "./index-Document.types.js";
import { MediaItemValidator as u } from "./index-MediaItemValidator.js";
class x extends u {
  constructor({
    requiredHeaders: r
  }) {
    super();
    t(this, "applicableFileTypes", [p.TEXT_CSV]);
    t(this, "requiredHeaders");
    t(this, "validate", (r) => Promise.all(r.map((i) => this.validateMediaItem(i))));
    t(this, "validateMediaItem", async (r) => {
      r.isInvalid = r.isInvalid ?? !1, r.validationErrors = r.validationErrors ?? [];
      const {
        file: i
      } = r;
      if (!i) return r;
      const o = ((await i.text()).split(/\r?\n/)[0] ?? "").split(",").map((a) => a.trim().toLowerCase()), n = this.requiredHeaders.filter((a) => !o.includes(a.toLowerCase()));
      return n.length > 0 && (r.isInvalid = !0, r.validationErrors.push({
        text: `The CSV is missing required columns: <b>${n.join(", ")}</b>.`
      })), r;
    });
    this.requiredHeaders = r;
  }
}
export {
  x as CsvContentValidator
};
