import { slogans } from "./../assets/slogans.js";
import { style } from "styled-string-builder";
/**
 * @description Array of ANSI color codes for banner styling.
 * @summary Defines a set of ANSI color codes used to style the banner text.
 * @memberOf module:utils
 */
const colors = [
    "\x1b[38;5;215m", // soft orange
    "\x1b[38;5;209m", // coral
    "\x1b[38;5;205m", // pink
    "\x1b[38;5;210m", // peachy
    "\x1b[38;5;217m", // salmon
    "\x1b[38;5;216m", // light coral
    "\x1b[38;5;224m", // light peach
    "\x1b[38;5;230m", // soft cream
    "\x1b[38;5;230m", // soft cream
];
/**
 * @description Prints a styled banner to the console.
 * @summary Generates and prints a colorful ASCII art banner with a random slogan.
 * @param {Logger} [logger] - Optional logger for verbose output.
 * @memberOf module:utils
 * @function printBanner
 * @mermaid
 * sequenceDiagram
 *   participant printBanner
 *   participant getSlogan
 *   participant padEnd
 *   participant console
 *   printBanner->>getSlogan: Call getSlogan()
 *   getSlogan-->>printBanner: Return random slogan
 *   printBanner->>printBanner: Create banner ASCII art
 *   printBanner->>printBanner: Split banner into lines
 *   printBanner->>printBanner: Calculate max line length
 *   printBanner->>padEnd: Call padEnd with slogan
 *   padEnd-->>printBanner: Return padded slogan line
 *   loop For each banner line
 *     printBanner->>style: Call style(line)
 *     style-->>printBanner: Return styled line
 *     printBanner->>console: Log styled line
 *   end
 */
export function printBanner(logger) {
    const message = getSlogan();
    const banner = `#                 ░▒▓███████▓▒░  ░▒▓████████▓▒░  ░▒▓██████▓▒░   ░▒▓██████▓▒░  ░▒▓████████▓▒░       ░▒▓████████▓▒░  ░▒▓███████▓▒░ 
#      ( (        ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░        ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░                 ░▒▓█▓▒░     ░▒▓█▓▒░        
#       ) )       ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░        ░▒▓█▓▒░        ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░                 ░▒▓█▓▒░     ░▒▓█▓▒░        
#    [=======]    ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓██████▓▒░   ░▒▓█▓▒░        ░▒▓████████▓▒░ ░▒▓██████▓▒░            ░▒▓█▓▒░      ░▒▓██████▓▒░  
#     \`-----´     ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░        ░▒▓█▓▒░        ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░                 ░▒▓█▓▒░            ░▒▓█▓▒░ 
#                 ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░        ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░                 ░▒▓█▓▒░            ░▒▓█▓▒░ 
#                 ░▒▓███████▓▒░  ░▒▓████████▓▒░  ░▒▓██████▓▒░  ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░                 ░▒▓█▓▒░     ░▒▓███████▓▒░  
#`.split("\n");
    const maxLength = banner.reduce((max, line) => Math.max(max, line.length), 0);
    banner.push(`#  ${message.padStart(maxLength - 3)}`);
    banner.forEach((line, index) => {
        (logger ? logger.info.bind(logger) : console.log.bind(console))(style(line || "").raw(colors[index]).text);
    });
}
/**
 * @description Retrieves a slogan from the predefined list.
 * @summary Fetches a random slogan or a specific one by index from the slogans list.
 * @param {number} [i] - Optional index to retrieve a specific slogan.
 * @return {string} The selected slogan.
 * @function getSlogan
 * @memberOf module:utils
 * @mermaid
 * sequenceDiagram
 *   participant getSlogan
 *   participant Math.random
 *   participant slogans
 *   alt i is undefined
 *     getSlogan->>Math.random: Generate random index
 *     Math.random-->>getSlogan: Return random index
 *   else i is defined
 *     Note over getSlogan: Use provided index
 *   end
 *   getSlogan->>slogans: Access slogan at index
 *   slogans-->>getSlogan: Return slogan
 *   alt Error occurs
 *     getSlogan->>getSlogan: Throw error
 *   end
 *   getSlogan-->>Caller: Return slogan
 */
export function getSlogan(i) {
    try {
        i =
            typeof i === "undefined" ? Math.floor(Math.random() * slogans.length) : i;
        return slogans[i].Slogan;
    }
    catch (error) {
        throw new Error(`Failed to retrieve slogans: ${error}`);
    }
}
//# sourceMappingURL=common.js.map