class ConsoleProvider {
  enabled;
  logLevel;
  constructor(options) {
    this.enabled = (options == null ? void 0 : options.enabled) ?? true;
    this.logLevel = (options == null ? void 0 : options.logLevel) ?? "summary";
  }
  async send(options) {
    if (!this.enabled) {
      return {
        id: `console-${Date.now()}`,
        success: true
      };
    }
    const emailId = `console-${Date.now()}`;
    console.log("\n" + "=".repeat(60));
    console.log("\u{1F4E7} EMAIL INTERCEPTED (Console Provider)");
    console.log("=".repeat(60));
    if (this.logLevel === "links-only") {
      const links = this.extractLinks(options.html || "");
      console.log("\u{1F4EE} To:", Array.isArray(options.to) ? options.to.join(", ") : options.to);
      console.log("\u{1F4DD} Subject:", options.subject);
      if (links.length > 0) {
        console.log("\n\u{1F517} Links found:");
        links.forEach((link, index) => {
          console.log(`   ${index + 1}. ${link}`);
        });
      }
    } else if (this.logLevel === "summary") {
      console.log("\u{1F4EE} To:", Array.isArray(options.to) ? options.to.join(", ") : options.to);
      console.log("\u{1F4DD} Subject:", options.subject);
      console.log("\u2709\uFE0F  From:", options.from || "default");
      const links = this.extractLinks(options.html || "");
      if (links.length > 0) {
        console.log("\n\u{1F517} Links in email:");
        links.forEach((link, index) => {
          console.log(`   ${index + 1}. ${link}`);
        });
      }
      if (options.text) {
        console.log("\n\u{1F4C4} Text preview:");
        console.log(options.text.substring(0, 200) + (options.text.length > 200 ? "..." : ""));
      }
    } else {
      console.log("\u{1F194} Email ID:", emailId);
      console.log("\u{1F4EE} To:", Array.isArray(options.to) ? options.to.join(", ") : options.to);
      console.log("\u2709\uFE0F  From:", options.from || "default");
      console.log("\u{1F4DD} Subject:", options.subject);
      if (options.cc) {
        console.log("\u{1F4CB} CC:", Array.isArray(options.cc) ? options.cc.join(", ") : options.cc);
      }
      if (options.bcc) {
        console.log("\u{1F512} BCC:", Array.isArray(options.bcc) ? options.bcc.join(", ") : options.bcc);
      }
      if (options.replyTo) {
        console.log("\u21A9\uFE0F  Reply-To:", options.replyTo);
      }
      if (options.html) {
        console.log("\n\u{1F4E7} HTML Content:");
        console.log("-".repeat(40));
        const textContent = options.html.replace(/<[^>]*>/g, "").replace(/&nbsp;/g, " ").replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#39;/g, "'").trim();
        console.log(textContent);
        const links = this.extractLinks(options.html);
        if (links.length > 0) {
          console.log("\n\u{1F517} Links:");
          links.forEach((link, index) => {
            console.log(`   ${index + 1}. ${link}`);
          });
        }
      }
      if (options.text) {
        console.log("\n\u{1F4C4} Text Content:");
        console.log("-".repeat(40));
        console.log(options.text);
      }
      if (options.attachments && options.attachments.length > 0) {
        console.log("\n\u{1F4CE} Attachments:");
        options.attachments.forEach((att, index) => {
          console.log(`   ${index + 1}. ${att.filename} (${att.contentType || "unknown type"})`);
        });
      }
    }
    console.log("=".repeat(60) + "\n");
    return {
      id: emailId,
      success: true
    };
  }
  async verify() {
    console.log("\u2705 ConsoleProvider is always ready");
    return true;
  }
  extractLinks(html) {
    const linkRegex = /href=["']([^"']+)["']/g;
    const links = [];
    let match;
    while ((match = linkRegex.exec(html)) !== null) {
      const url = match[1];
      if (!url.startsWith("mailto:") && !url.startsWith("#")) {
        links.push(url);
      }
    }
    return [...new Set(links)];
  }
}
export {
  ConsoleProvider
};
