// icon_utils - Utility for loading SVG icons
import { app } from "../../../scripts/app.js";
const SVG_ICONS = {
chevronDown: ``,
circleCheckBig: ``,
circlePlus: ``,
file: ``,
fileCheck: ``,
fileQuestion: ``,
fileText: ``,
hash: ``,
cpu: ``,
pencil: ``,
triangleAlert: ``,
users: ``,
scale: ``,
box: ``,
hardDrive: ``,
bookType: ``,
search: ``,
refreshCw: ``,
locate: ``,
download: ``,
cloudDownload: ``,
skull: ``,
shield: ``,
copy: ``,
externalLink: ``,
moreCircle: ``,
internalLink: ``,
database: ``,
wrench: ``,
comfyui: ``,
archive: ``,
civarchive: ``,
loraManager: ``,
star: ``,
lightbulb: ``,
link: ``,
globe: ``,
eye: ``,
eyeOff: ``,
folderOpen: ``,
windowMaximize: ``,
windowRestore: ``,
x: ``,
civitai: ``,
huggingface: ``
};
/**
* Generates HTML string for an icon with standardized styling
* @param {Image} icon - The icon Image object (or null)
* @param {string} fallback - Fallback text/emoji if icon is not available (default: '')
* @param {number} size - Size of the icon in pixels (default: 14)
* @param {string} extraStyles - Optional additional CSS styles
* @returns {string} HTML string for the icon or fallback
*/
export function getIconHtml(icon, fallback = '', size = 14, extraStyles = '') {
if (!icon) return fallback;
const styleAttr = extraStyles ? ` style="${extraStyles}"` : '';
return `
`;
}
/**
* Returns inline SVG markup by icon name.
* @param {string} name - Icon identifier
* @param {string} color - Stroke color placeholder value
* @param {string} className - Optional class name for the svg element
* @returns {string} SVG markup or empty string
*/
export function getSvgIcon(name, color = 'currentColor', className = '') {
const template = SVG_ICONS[name];
if (!template) return '';
let svg = template.replaceAll('{color}', color);
if (className) {
svg = svg.replace('