import {
  BaseComponent
} from "./chunk-4YEN7HVQ.js";
// src/templates/error_metadata/main.ts
import { dump, themes } from "@poppinss/dumper/html";
var ErrorMetadata = class extends BaseComponent {
  #primitives = ["string", "boolean", "number", "undefined"];
  /**
   * Formats the error row value
   */
  #formatRowValue(value, dumpValue, cspNonce) {
    if (dumpValue === true) {
      return dump(value, { styles: themes.cssVariables, cspNonce });
    }
    if (this.#primitives.includes(typeof value) || value === null) {
      return value;
    }
    return dump(value, { styles: themes.cssVariables });
  }
  /**
   * Returns HTML fragment with HTML table containing rows
   * metadata section rows
   */
  #renderRows(rows, cspNonce) {
    return `
      
        ${rows.map((row) => {
      return `
              | ${row.key} | ${this.#formatRowValue(row.value, row.dump, cspNonce)} | 
`;
    }).join("\n")}
      
    
`;
  }
  /**
   * Renders each section with its rows inside a table
   */
  #renderSection(section, rows, cspNonce) {
    return `
      
${section}
      ${Array.isArray(rows) ? this.#renderRows(rows, cspNonce) : `${this.#formatRowValue(rows.value, rows.dump, cspNonce)}`}
    `;
  }
  /**
   * Renders each group as a card
   */
  #renderGroup(group, sections, cspNonce) {
    return `
      
        
          
${group}
        
        
          ${Object.keys(sections).map((section) => this.#renderSection(section, sections[section], cspNonce)).join("\n")}
        
       
    `;
  }
  /**
   * The toHTML method is used to output the HTML for the
   * web view
   */
  async toHTML(props) {
    const groups = props.metadata.toJSON();
    const groupsNames = Object.keys(groups);
    if (!groupsNames.length) {
      return "";
    }
    return groupsNames.map((group) => this.#renderGroup(group, groups[group], props.cspNonce)).join("\n");
  }
  /**
   * The toANSI method is used to output the text for the console
   */
  async toANSI() {
    return "";
  }
};
export {
  ErrorMetadata
};