1(function () { 2 const pageContext = window.BettybotContext || {}; 3 4 function mergeContext(template, data) { 5 return template.replace(/\{([^}]+)\}/g, (_, key) => data[key.trim()] ?? `{${key}}`); 6 } 7 8 function openChatWindow() { 9 const container = document.getElementById('chatbot-container'); 10 if (container && !container.classList.contains('open')) { 11 container.classList.add('open'); 12 } 13 } 14 15 function sendToBettyBot(text) { 16 const bot = document.querySelector('betty-bot'); 17 if (!bot) return; 18 19 // First question: intro panel is still showing â use betty-bot's own 20 // .static-question click so its native handler manages the introâchat 21 // UI transition (and resolves internal ViewChild refs) before sending. 22 const staticQ = bot.querySelector('.static-question'); 23 if (staticQ) { 24 const original = staticQ.textContent; 25 staticQ.textContent = text; 26 staticQ.click(); 27 staticQ.textContent = original; 28 return; 29 } 30 31 // Subsequent questions: chat is already initialized so sendQuestion 32 // can be called directly without the ViewChild null issue. 33 const componentRef = bot?.ngElementStrategy?.componentRef; 34 const instance = componentRef?.instance; 35 if (!instance) return; 36 37 const textarea = bot.querySelector('textarea#input'); 38 if (textarea) { 39 textarea.value = text; 40 textarea.dispatchEvent(new Event('input', { bubbles: true })); 41 } 42 43 setTimeout(function () { instance.sendQuestion(text); }, 50); 44 } 45 46 function initWrappers() { 47 document.querySelectorAll('.artie-prompt').forEach(function (wrapper) { 48 const displayQ = wrapper.querySelector('.artie-prompt-question'); 49 if (!displayQ) return; 50 51 const contextTemplate = wrapper.dataset.context; 52 53 displayQ.addEventListener('click', function () { 54 const question = displayQ.textContent.trim(); 55 const merged = contextTemplate ? mergeContext(contextTemplate, pageContext) : ''; 56 const fullText = merged ? question + ' ' + merged : question; 57 58 openChatWindow(); 59 setTimeout(function () { sendToBettyBot(fullText); }, 300); 60 }); 61 }); 62 } 63 64 if (document.querySelector('.artie-prompt')) { 65 initWrappers(); 66 } 67})();
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.