(() => { window.USE_COMMONREND = false; })(); (() => { window.USE_COMMONREND = true; let tdChatLoaded = false; let webchat = null; const chatConfig = { key: "c9b4ad4d23234d83a0ca69371c10bf6d", merchantId: "64a6c9b3660a201cccec022f" }; const initConfig = { tags: ["chat_propertychecker"] }; const loadChatWidget = (items) => { if (tdChatLoaded) return; tdChatLoaded = true; // Create container (must exist, do not hide) const divContainer = document.createElement("div"); divContainer.id = "tdWebchat"; document.body.appendChild(divContainer); // Load V2 SDK const script = document.createElement("script"); script.type = "text/javascript"; script.charset = "UTF-8"; script.async = true; script.id = "tdwebchatscript"; script.src = "https://talkdeskchatsdk.talkdeskapp.com/v2/talkdeskchatsdk.js"; document.head.appendChild(script); script.onload = () => { // Initialize Talkdesk V2 webchat = TalkdeskChatSDK( "tdWebchat", { touchpointId: items.key, accountId: "", region: "td-us-1" }, { enableValidation: false, enableEmoji: true, enableUserInput: true, enableAttachments: true } ); // Init with config webchat.init(initConfig).then(() => { // Manual open for buttons webchat.showTalkdeskChat = () => { webchat.selfHostedApp.open(); }; }); // Set context on conversation start webchat.onConversationStart = () => { webchat.setContextParam({"merchantId":"64a6c9b3660a201cccec022f"}); }; window.webchat = webchat; // Custom buttons also open chat ["btn-chat", "link"].forEach(id => { const el = document.getElementById(id); if (el) { el.addEventListener("click", () => { webchat?.showTalkdeskChat?.(); }); } }); }; }; const safeLoad = () => loadChatWidget(chatConfig); // Lazy load setTimeout(safeLoad, 4000); ["scroll", "mousemove", "touchstart"].forEach(evt => { window.addEventListener(evt, safeLoad, {once: true}); }); })();