import hanmac from '../assets/affiliations/hanmac.png?inline'; import saman from '../assets/affiliations/saman.png?inline'; import jangheon from '../assets/affiliations/jangheon.png?inline'; import jangheonIndustry from '../assets/affiliations/jangheon-industry.png?inline'; import ptc from '../assets/affiliations/ptc.png?inline'; import halla from '../assets/affiliations/halla.png?inline'; import baron from '../assets/affiliations/baron.png?inline'; // Asset mapping is an internal presentation concern; the employee/affiliation // JSON contract continues to use only its existing id and name fields. const logos = new Map([ ['hanmac', hanmac], ['saman', saman], ['jangheon', jangheon], ['jangheon-industry', jangheonIndustry], ['ptc', ptc], ['halla', halla], ['baron', baron], ]); /** Shared by employee cards and the affiliation summary footer. */ export function createAffiliationMark( document: Document, affiliationId: string, name: string, signal?: AbortSignal, ): HTMLElement { const mark = document.createElement('span'); mark.className = 'hm-orgchart-affiliation-mark'; mark.dataset.affiliationId = affiliationId; mark.setAttribute('role', 'img'); mark.setAttribute('aria-label', `관계사 ${name}`); mark.title = name; const fallback = document.createElement('span'); fallback.className = 'hm-orgchart-affiliation-fallback'; fallback.textContent = Array.from(name.trim()).slice(0, 2).join('') || '?'; mark.append(fallback); const logo = logos.get(affiliationId); mark.dataset.logoAvailable = String(Boolean(logo)); if (logo) { const image = document.createElement('img'); image.alt = ''; image.decoding = 'async'; image.addEventListener('error', () => { image.remove(); mark.dataset.logoAvailable = 'false'; }, { once: true, ...(signal ? { signal } : {}) }); image.src = logo; mark.append(image); } return mark; }