1(() => { 2 const config = (typeof window !== 'undefined' && window.WCTW2026_LUCIDE_LOADER) ? window.WCTW2026_LUCIDE_LOADER : {}; 3 const CDN = (config && config.cdn) ? String(config.cdn) : 'https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/lucide.min.js'; 4 const INIT = (config && config.init) ? String(config.init) : ''; 5 const MAX_WAIT_MS = 8000; 6 7 function hasFallbackIcons() { 8 return !!document.querySelector('i[data-lucide]'); 9 } 10 11 function loadScript(src) { 12 return new Promise((resolve, reject) => { 13 if (!src) return resolve(); 14 15 const existing = document.querySelector(`script[src="${CSS.escape(src)}"]`); 16 if (existing) { 17 if (existing.dataset.loaded === '1') return resolve(); 18 existing.addEventListener('load', () => resolve(), { once: true }); 19 existing.addEventListener('error', () => reject(new Error(`Failed to load ${src}`)), { once: true }); 20 return; 21 } 22 23 const s = document.createElement('script'); 24 s.src = src; 25 s.async = true; 26 s.dataset.loaded = '0'; 27 s.addEventListener('load', () => { 28 s.dataset.loaded = '1'; 29 resolve(); 30 }, { once: true }); 31 s.addEventListener('error', () => reject(new Error(`Failed to load ${src}`)), { once: true }); 32 document.head.appendChild(s); 33 }); 34 } 35 36 let loadingPromise = null; 37 38 async function ensureLucideLoadedIfNeeded() { 39 if (!hasFallbackIcons()) return; 40 41 if (window.lucide && typeof window.lucide.createIcons === 'function') { 42 try { 43 window.lucide.createIcons(); 44 } catch (_) { 45 // ignore 46 } 47 return; 48 } 49 50 if (!loadingPromise) { 51 loadingPromise = (async () => { 52 await loadScript(CDN); 53 if (INIT) { 54 await loadScript(INIT); 55 } else if (window.lucide && typeof window.lucide.createIcons === 'function') { 56 try { 57 window.lucide.createIcons(); 58 } catch (_) { 59 // ignore 60 } 61 } 62 })(); 63 } 64 65 try { 66 await loadingPromise; 67 } catch (_) { 68 // ignore 69 } 70 } 71 72 function scheduleCheck() { 73 void ensureLucideLoadedIfNeeded(); 74 } 75 76 if (document.readyState === 'loading') { 77 document.addEventListener('DOMContentLoaded', scheduleCheck, { once: true }); 78 } else { 79 scheduleCheck(); 80 } 81 82 window.addEventListener('pageshow', scheduleCheck); 83 84 const obs = new MutationObserver(() => { 85 if (hasFallbackIcons()) { 86 scheduleCheck(); 87 obs.disconnect(); 88 } 89 }); 90 91 try { 92 obs.observe(document.documentElement, { childList: true, subtree: true }); 93 window.setTimeout(() => { 94 try { 95 obs.disconnect(); 96 } catch (_) { 97 // ignore 98 } 99 }, MAX_WAIT_MS); 100 } catch (_) { 101 // ignore 102 } 103})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.