wineater-bot 1.4.4 → 1.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -276,29 +276,32 @@ const f = `
|
|
|
276
276
|
}`, p = document.createElement("style");
|
|
277
277
|
p.textContent = f;
|
|
278
278
|
document.head.appendChild(p);
|
|
279
|
-
function b(n,
|
|
279
|
+
function b(n, t, e) {
|
|
280
280
|
let o = "";
|
|
281
|
-
if (
|
|
281
|
+
if (e) {
|
|
282
282
|
const i = /* @__PURE__ */ new Date();
|
|
283
|
-
i.setTime(i.getTime() +
|
|
283
|
+
i.setTime(i.getTime() + e * 24 * 60 * 60 * 1e3), o = "; expires=" + i.toUTCString();
|
|
284
284
|
}
|
|
285
|
-
document.cookie = n + "=" + (
|
|
285
|
+
document.cookie = n + "=" + (t || "") + o + "; path=/; secure; samesite=strict";
|
|
286
286
|
}
|
|
287
287
|
function r(n) {
|
|
288
|
-
const
|
|
289
|
-
if (
|
|
290
|
-
return
|
|
288
|
+
const e = `; ${document.cookie}`.split(`; ${n}=`);
|
|
289
|
+
if (e.length === 2)
|
|
290
|
+
return e.pop().split(";").shift();
|
|
291
291
|
}
|
|
292
|
-
function
|
|
292
|
+
function y(n) {
|
|
293
|
+
return Object.keys(n).map((t) => encodeURIComponent(t) + "=" + encodeURIComponent(n[t])).join("&");
|
|
294
|
+
}
|
|
295
|
+
function d(n, t) {
|
|
293
296
|
fetch("https://api-eu.mixpanel.com/track", {
|
|
294
297
|
method: "POST",
|
|
295
298
|
headers: {
|
|
296
|
-
"Content-Type": "application/
|
|
299
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
297
300
|
Authentication: "6f3d90d5b02720f58de3663e3ef675fe"
|
|
298
301
|
},
|
|
299
|
-
body:
|
|
302
|
+
body: y({
|
|
300
303
|
event: n,
|
|
301
|
-
properties:
|
|
304
|
+
properties: t
|
|
302
305
|
})
|
|
303
306
|
}).then((a) => {
|
|
304
307
|
a.ok || console.error("Mixpanel tracking failed", a);
|
|
@@ -312,72 +315,72 @@ function h() {
|
|
|
312
315
|
function g() {
|
|
313
316
|
d("Chatbot Closed", { distinct_id: r("chatbotToken") });
|
|
314
317
|
}
|
|
315
|
-
function
|
|
318
|
+
function w(n) {
|
|
316
319
|
d("Message Sent", { distinct_id: r("chatbotToken"), message_content: n });
|
|
317
320
|
}
|
|
318
|
-
function
|
|
321
|
+
function x(n) {
|
|
319
322
|
d("Message Sent", { distinct_id: r("chatbotToken"), products: n });
|
|
320
323
|
}
|
|
321
|
-
function
|
|
324
|
+
function v(n) {
|
|
322
325
|
d("Product Clicked", { distinct_id: r("chatbotToken"), product_id: n });
|
|
323
326
|
}
|
|
324
327
|
function u() {
|
|
325
|
-
const n = document.getElementById("chat-window"),
|
|
326
|
-
n.classList.contains("visible") ? (g(), n.classList.remove("visible"),
|
|
328
|
+
const n = document.getElementById("chat-window"), t = document.getElementById("chat-icon");
|
|
329
|
+
n.classList.contains("visible") ? (g(), n.classList.remove("visible"), t.style.display = "flex") : (h(), n.classList.add("visible"), t.style.display = "none");
|
|
327
330
|
}
|
|
328
|
-
function
|
|
331
|
+
function k() {
|
|
329
332
|
g(), document.getElementById("chat-window").classList.remove("visible");
|
|
330
333
|
}
|
|
331
|
-
function
|
|
334
|
+
function C() {
|
|
332
335
|
h(), document.getElementById("chat-window").classList.add("visible");
|
|
333
336
|
}
|
|
334
337
|
document.addEventListener("DOMContentLoaded", () => {
|
|
335
338
|
setupCloseButton(), setupOutsideClick();
|
|
336
339
|
});
|
|
337
|
-
const
|
|
340
|
+
const E = ["climats", "telckel", "biobio", "weinpoint"], I = "OuhXJRleF6sROjsQZPWx1yqjrL6APeJxmHswqyOBWbgIqtXcht3MDadvI9DtOOoL";
|
|
338
341
|
class m {
|
|
339
|
-
constructor(
|
|
340
|
-
var
|
|
341
|
-
this.baseURL = "https://api.wineater.com/", this.store =
|
|
342
|
+
constructor(t) {
|
|
343
|
+
var e;
|
|
344
|
+
this.baseURL = "https://api.wineater.com/", this.store = E.find((o) => window.location.href.includes(o)), this.token = ((e = window == null ? void 0 : window.wineaterData) == null ? void 0 : e.CLIENT_TOKEN) || I;
|
|
342
345
|
}
|
|
343
|
-
async getStoreConfig(
|
|
344
|
-
console.log(
|
|
346
|
+
async getStoreConfig(t) {
|
|
347
|
+
console.log(t);
|
|
345
348
|
try {
|
|
346
|
-
const
|
|
349
|
+
const e = await fetch(`${this.baseURL}stores/store`, {
|
|
347
350
|
method: "POST",
|
|
348
351
|
headers: {
|
|
349
352
|
"Content-Type": "application/json",
|
|
350
353
|
Authorization: `Bearer ${this.token}`
|
|
351
354
|
},
|
|
352
|
-
body: JSON.stringify({ store:
|
|
355
|
+
body: JSON.stringify({ store: t })
|
|
353
356
|
});
|
|
354
|
-
if (!
|
|
355
|
-
throw new Error(`HTTP error! Status: ${
|
|
356
|
-
return await
|
|
357
|
-
} catch (
|
|
358
|
-
throw console.error("Error fetching store configuration:",
|
|
357
|
+
if (!e.ok)
|
|
358
|
+
throw new Error(`HTTP error! Status: ${e.status}`);
|
|
359
|
+
return await e.json();
|
|
360
|
+
} catch (e) {
|
|
361
|
+
throw console.error("Error fetching store configuration:", e), e;
|
|
359
362
|
}
|
|
360
363
|
}
|
|
361
|
-
async getWineRecommendations(
|
|
364
|
+
async getWineRecommendations(t) {
|
|
362
365
|
console.log(window.location.href);
|
|
363
366
|
try {
|
|
364
|
-
const
|
|
367
|
+
const e = await fetch(`${this.baseURL}dish/recommendations`, {
|
|
365
368
|
method: "POST",
|
|
366
369
|
headers: {
|
|
367
370
|
"Content-Type": "application/json",
|
|
368
371
|
Authorization: `Bearer ${this.token}`
|
|
369
372
|
},
|
|
370
|
-
body: JSON.stringify({ text:
|
|
371
|
-
}), o = await
|
|
372
|
-
if (!
|
|
373
|
-
throw new Error(`API call failed with status ${
|
|
373
|
+
body: JSON.stringify({ text: t, store: this.store ? this.store.toString().charAt(0).toUpperCase() + this.store.slice(1) : void 0 })
|
|
374
|
+
}), o = await e.json();
|
|
375
|
+
if (!e.ok)
|
|
376
|
+
throw new Error(`API call failed with status ${e.status}: ${o.message || "No additional error information"}`);
|
|
374
377
|
return o;
|
|
375
|
-
} catch (
|
|
376
|
-
throw console.error("Fetching wine recommendations failed:",
|
|
378
|
+
} catch (e) {
|
|
379
|
+
throw console.error("Fetching wine recommendations failed:", e.message), new Error(`Error in getWineRecommendations: ${e.message}`);
|
|
377
380
|
}
|
|
378
381
|
}
|
|
379
382
|
}
|
|
380
|
-
class
|
|
383
|
+
class T {
|
|
381
384
|
constructor() {
|
|
382
385
|
this.api = new m(), this.language = "en", this.translations = {
|
|
383
386
|
fr: {
|
|
@@ -418,18 +421,18 @@ class I {
|
|
|
418
421
|
}
|
|
419
422
|
};
|
|
420
423
|
}
|
|
421
|
-
async fetchConfig(
|
|
422
|
-
if (
|
|
423
|
-
const
|
|
424
|
-
this.language =
|
|
424
|
+
async fetchConfig(t) {
|
|
425
|
+
if (t) {
|
|
426
|
+
const e = await this.api.getStoreConfig(t);
|
|
427
|
+
this.language = e.lang;
|
|
425
428
|
}
|
|
426
429
|
}
|
|
427
|
-
translate(
|
|
428
|
-
return this.translations[this.language][
|
|
430
|
+
translate(t) {
|
|
431
|
+
return this.translations[this.language][t] || t;
|
|
429
432
|
}
|
|
430
433
|
}
|
|
431
|
-
const s = new
|
|
432
|
-
class
|
|
434
|
+
const s = new T();
|
|
435
|
+
class B {
|
|
433
436
|
constructor() {
|
|
434
437
|
this.api = new m(), this.displayFirstMessage(s.translate("welcomeMessage"));
|
|
435
438
|
}
|
|
@@ -438,17 +441,17 @@ class T {
|
|
|
438
441
|
o.key === "Enter" && this.handleUserInput();
|
|
439
442
|
});
|
|
440
443
|
}
|
|
441
|
-
displayFirstMessage(
|
|
444
|
+
displayFirstMessage(t, e = "api") {
|
|
442
445
|
const o = document.getElementById("message-container"), i = document.createElement("div");
|
|
443
|
-
i.className = `message ${
|
|
446
|
+
i.className = `message ${e}`, i.textContent = t, o.appendChild(i), o.scrollTop = o.scrollHeight;
|
|
444
447
|
}
|
|
445
448
|
async handleUserInput() {
|
|
446
|
-
const
|
|
447
|
-
if (
|
|
448
|
-
this.displayMessage(
|
|
449
|
+
const t = document.getElementById("user-input"), e = t.value.trim();
|
|
450
|
+
if (e) {
|
|
451
|
+
this.displayMessage(e, "user"), t.value = "", this.showTypingIndicator();
|
|
449
452
|
try {
|
|
450
|
-
|
|
451
|
-
const o = await this.api.getWineRecommendations(
|
|
453
|
+
w(e);
|
|
454
|
+
const o = await this.api.getWineRecommendations(e);
|
|
452
455
|
this.hideTypingIndicator(), o && o.length ? this.displayResults(o) : this.displayMessage("No results found.", "api");
|
|
453
456
|
} catch {
|
|
454
457
|
this.hideTypingIndicator(), this.displayMessage(s.translate("somethingWentWrong"), "api");
|
|
@@ -461,16 +464,16 @@ class T {
|
|
|
461
464
|
hideTypingIndicator() {
|
|
462
465
|
document.getElementById("typing-indicator").classList.remove("visible");
|
|
463
466
|
}
|
|
464
|
-
displayMessage(
|
|
467
|
+
displayMessage(t, e) {
|
|
465
468
|
const o = document.getElementById("message-container"), i = document.createElement("div");
|
|
466
|
-
i.textContent =
|
|
469
|
+
i.textContent = t, i.className = "message " + e, o.appendChild(i), o.scrollTop = o.scrollHeight;
|
|
467
470
|
}
|
|
468
|
-
sendAnalytics(
|
|
469
|
-
|
|
471
|
+
sendAnalytics(t) {
|
|
472
|
+
v(t);
|
|
470
473
|
}
|
|
471
|
-
displayResults(
|
|
472
|
-
const
|
|
473
|
-
|
|
474
|
+
displayResults(t) {
|
|
475
|
+
const e = document.getElementById("message-container");
|
|
476
|
+
x(t.map((o) => o.Title)), t.forEach((o) => {
|
|
474
477
|
const i = document.createElement("div");
|
|
475
478
|
i.className = "wine-item";
|
|
476
479
|
const a = document.createElement("img");
|
|
@@ -482,14 +485,14 @@ class T {
|
|
|
482
485
|
${s.translate("region")}: ${o.Region}<br>
|
|
483
486
|
${s.translate("type")}: ${o.Type}<br>
|
|
484
487
|
<a href="${o.Url}" onclick="sendAnalytics(${o.Title})" target="_blank">${s.translate("moreInfo")}</a>
|
|
485
|
-
`, i.appendChild(c),
|
|
486
|
-
}),
|
|
488
|
+
`, i.appendChild(c), e.appendChild(i);
|
|
489
|
+
}), e.scrollTop = e.scrollHeight;
|
|
487
490
|
}
|
|
488
491
|
}
|
|
489
492
|
document.addEventListener("DOMContentLoaded", () => {
|
|
490
|
-
window.toggleChatWindow = u, window.closeChatWindow =
|
|
493
|
+
window.toggleChatWindow = u, window.closeChatWindow = k, window.openChatWindow = C;
|
|
491
494
|
});
|
|
492
|
-
function
|
|
495
|
+
function L() {
|
|
493
496
|
const n = `
|
|
494
497
|
<div id="chatbot-container">
|
|
495
498
|
<div id="chat-icon" onclick="toggleChatWindow()">
|
|
@@ -519,32 +522,32 @@ function B() {
|
|
|
519
522
|
`;
|
|
520
523
|
document.body.insertAdjacentHTML("beforeend", n);
|
|
521
524
|
}
|
|
522
|
-
function
|
|
525
|
+
function P() {
|
|
523
526
|
document.getElementById("close-btn").addEventListener("click", u);
|
|
524
527
|
}
|
|
525
|
-
function
|
|
528
|
+
function W() {
|
|
526
529
|
window.addEventListener("click", function(n) {
|
|
527
|
-
const
|
|
528
|
-
!
|
|
530
|
+
const t = document.getElementById("chat-window"), e = document.getElementById("chat-icon");
|
|
531
|
+
!t.contains(n.target) && !e.contains(n.target) && (t.classList.remove("visible"), e.style.display = "flex");
|
|
529
532
|
});
|
|
530
533
|
}
|
|
531
|
-
function
|
|
534
|
+
function S(n) {
|
|
532
535
|
console.log(n);
|
|
533
|
-
const
|
|
534
|
-
|
|
536
|
+
const t = document.getElementById("chat-icon"), e = document.getElementById("chat-window");
|
|
537
|
+
t.className = "", e.className = "", n === "right-center" ? (t.classList.add("chat-icon-right-center"), e.classList.add("right-center-aligned")) : t.classList.add("chat-icon-bottom-right");
|
|
535
538
|
}
|
|
536
539
|
var l;
|
|
537
540
|
if (typeof window < "u") {
|
|
538
541
|
const n = ((l = window.wineaterData) == null ? void 0 : l.POSITION) || "bottom-right";
|
|
539
542
|
window.addEventListener("DOMContentLoaded", async () => {
|
|
540
543
|
var a;
|
|
541
|
-
const
|
|
544
|
+
const e = ["climats", "telckel", "biobio", "weinpoint"].find((c) => window.location.href.includes(c)) || null;
|
|
542
545
|
let o;
|
|
543
|
-
|
|
546
|
+
e && (o = e.charAt(0).toUpperCase() + e.slice(1)), await s.fetchConfig(o || null), L(), P(), W(), S(n), b("chatbotToken", (a = window.wineaterData) == null ? void 0 : a.CLIENT_TOKEN, 365), new B().initialize();
|
|
544
547
|
});
|
|
545
548
|
}
|
|
546
549
|
export {
|
|
547
|
-
|
|
548
|
-
|
|
550
|
+
k as closeChatWindow,
|
|
551
|
+
C as openChatWindow,
|
|
549
552
|
u as toggleChatWindow
|
|
550
553
|
};
|
|
@@ -273,13 +273,13 @@
|
|
|
273
273
|
.typing-indicator.visible {
|
|
274
274
|
visibility: visible;
|
|
275
275
|
height: 50px;
|
|
276
|
-
}`,g=document.createElement("style");g.textContent=d,document.head.appendChild(g);function x(n,t,e){let o="";if(e){const i=new Date;i.setTime(i.getTime()+e*24*60*60*1e3),o="; expires="+i.toUTCString()}document.cookie=n+"="+(t||"")+o+"; path=/; secure; samesite=strict"}function c(n){const e=`; ${document.cookie}`.split(`; ${n}=`);if(e.length===2)return e.pop().split(";").shift()}function l(n,t){fetch("https://api-eu.mixpanel.com/track",{method:"POST",headers:{"Content-Type":"application/
|
|
276
|
+
}`,g=document.createElement("style");g.textContent=d,document.head.appendChild(g);function x(n,t,e){let o="";if(e){const i=new Date;i.setTime(i.getTime()+e*24*60*60*1e3),o="; expires="+i.toUTCString()}document.cookie=n+"="+(t||"")+o+"; path=/; secure; samesite=strict"}function c(n){const e=`; ${document.cookie}`.split(`; ${n}=`);if(e.length===2)return e.pop().split(";").shift()}function v(n){return Object.keys(n).map(t=>encodeURIComponent(t)+"="+encodeURIComponent(n[t])).join("&")}function l(n,t){fetch("https://api-eu.mixpanel.com/track",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Authentication:"6f3d90d5b02720f58de3663e3ef675fe"},body:v({event:n,properties:t})}).then(s=>{s.ok||console.error("Mixpanel tracking failed",s)}).catch(s=>{console.error("Mixpanel tracking error",s)})}function u(){l("Chatbot Opened",{distinct_id:c("chatbotToken")})}function m(){l("Chatbot Closed",{distinct_id:c("chatbotToken")})}function k(n){l("Message Sent",{distinct_id:c("chatbotToken"),message_content:n})}function C(n){l("Message Sent",{distinct_id:c("chatbotToken"),products:n})}function E(n){l("Product Clicked",{distinct_id:c("chatbotToken"),product_id:n})}function h(){const n=document.getElementById("chat-window"),t=document.getElementById("chat-icon");n.classList.contains("visible")?(m(),n.classList.remove("visible"),t.style.display="flex"):(u(),n.classList.add("visible"),t.style.display="none")}function f(){m(),document.getElementById("chat-window").classList.remove("visible")}function b(){u(),document.getElementById("chat-window").classList.add("visible")}document.addEventListener("DOMContentLoaded",()=>{setupCloseButton(),setupOutsideClick()});const I=["climats","telckel","biobio","weinpoint"],T="OuhXJRleF6sROjsQZPWx1yqjrL6APeJxmHswqyOBWbgIqtXcht3MDadvI9DtOOoL";class y{constructor(t){var e;this.baseURL="https://api.wineater.com/",this.store=I.find(o=>window.location.href.includes(o)),this.token=((e=window==null?void 0:window.wineaterData)==null?void 0:e.CLIENT_TOKEN)||T}async getStoreConfig(t){console.log(t);try{const e=await fetch(`${this.baseURL}stores/store`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.token}`},body:JSON.stringify({store:t})});if(!e.ok)throw new Error(`HTTP error! Status: ${e.status}`);return await e.json()}catch(e){throw console.error("Error fetching store configuration:",e),e}}async getWineRecommendations(t){console.log(window.location.href);try{const e=await fetch(`${this.baseURL}dish/recommendations`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.token}`},body:JSON.stringify({text:t,store:this.store?this.store.toString().charAt(0).toUpperCase()+this.store.slice(1):void 0})}),o=await e.json();if(!e.ok)throw new Error(`API call failed with status ${e.status}: ${o.message||"No additional error information"}`);return o}catch(e){throw console.error("Fetching wine recommendations failed:",e.message),new Error(`Error in getWineRecommendations: ${e.message}`)}}}class B{constructor(){this.api=new y,this.language="en",this.translations={fr:{welcomeMessage:"Sublimez votre expérience gastronomique. Il vous suffit de donner les détails de votre plat, et obtenez la recommandation de compagnon de vin idéale. Que voulez-vous manger?",noResultsFound:"Aucun résultat trouvé.",somethingWentWrong:"Désolé, quelque chose a mal tourné.",chatButton:"Accorder le vin au dîner",inputPlaceholder:"ex., Salade de thon",sendButton:"Accorder",price:"Prix",region:"Région",type:"Type",moreInfo:"Plus d'infos"},es:{welcomeMessage:"Mejore su experiencia gastronómica. Solo proporcione los detalles de su plato y obtenga la recomendación de vino ideal. ¿Qué le gustaría comer?",noResultsFound:"No se encontraron resultados.",somethingWentWrong:"Lo sentimos, algo salió mal.",chatButton:"Maridar vino con cena",inputPlaceholder:"ej., Ensalada de atún",sendButton:"Maridar",price:"Precio",region:"Región",type:"Tipo",moreInfo:"Más info"},en:{welcomeMessage:"Enhance your dining experience. Just provide your dish details and get the ideal wine pairing. What would you like to eat?",noResultsFound:"No results found.",somethingWentWrong:"Sorry, something went wrong.",chatButton:"Pair wine with dinner",inputPlaceholder:"e.g., Tuna Salad",sendButton:"Pair",price:"Price",region:"Region",type:"Type",moreInfo:"More info"}}}async fetchConfig(t){if(t){const e=await this.api.getStoreConfig(t);this.language=e.lang}}translate(t){return this.translations[this.language][t]||t}}const a=new B;class L{constructor(){this.api=new y,this.displayFirstMessage(a.translate("welcomeMessage"))}initialize(){document.getElementById("send-button").addEventListener("click",()=>this.handleUserInput()),document.getElementById("user-input").addEventListener("keypress",o=>{o.key==="Enter"&&this.handleUserInput()})}displayFirstMessage(t,e="api"){const o=document.getElementById("message-container"),i=document.createElement("div");i.className=`message ${e}`,i.textContent=t,o.appendChild(i),o.scrollTop=o.scrollHeight}async handleUserInput(){const t=document.getElementById("user-input"),e=t.value.trim();if(e){this.displayMessage(e,"user"),t.value="",this.showTypingIndicator();try{k(e);const o=await this.api.getWineRecommendations(e);this.hideTypingIndicator(),o&&o.length?this.displayResults(o):this.displayMessage("No results found.","api")}catch{this.hideTypingIndicator(),this.displayMessage(a.translate("somethingWentWrong"),"api")}}}showTypingIndicator(){document.getElementById("typing-indicator").classList.add("visible")}hideTypingIndicator(){document.getElementById("typing-indicator").classList.remove("visible")}displayMessage(t,e){const o=document.getElementById("message-container"),i=document.createElement("div");i.textContent=t,i.className="message "+e,o.appendChild(i),o.scrollTop=o.scrollHeight}sendAnalytics(t){E(t)}displayResults(t){const e=document.getElementById("message-container");C(t.map(o=>o.Title)),t.forEach(o=>{const i=document.createElement("div");i.className="wine-item";const s=document.createElement("img");s.src=o.Image,i.appendChild(s);const p=document.createElement("div");p.innerHTML=`
|
|
277
277
|
<strong>${o.Title}</strong><br>
|
|
278
278
|
${a.translate("price")}: ${o.Price}<br>
|
|
279
279
|
${a.translate("region")}: ${o.Region}<br>
|
|
280
280
|
${a.translate("type")}: ${o.Type}<br>
|
|
281
281
|
<a href="${o.Url}" onclick="sendAnalytics(${o.Title})" target="_blank">${a.translate("moreInfo")}</a>
|
|
282
|
-
`,i.appendChild(p),e.appendChild(i)}),e.scrollTop=e.scrollHeight}}document.addEventListener("DOMContentLoaded",()=>{window.toggleChatWindow=h,window.closeChatWindow=f,window.openChatWindow=b});function
|
|
282
|
+
`,i.appendChild(p),e.appendChild(i)}),e.scrollTop=e.scrollHeight}}document.addEventListener("DOMContentLoaded",()=>{window.toggleChatWindow=h,window.closeChatWindow=f,window.openChatWindow=b});function W(){const n=`
|
|
283
283
|
<div id="chatbot-container">
|
|
284
284
|
<div id="chat-icon" onclick="toggleChatWindow()">
|
|
285
285
|
<img src="https://landing-static.s3.eu-central-1.amazonaws.com/images/chat-icon.svg" alt="Chat Icon"> <!-- Update the path to your logo image -->
|
|
@@ -305,4 +305,4 @@
|
|
|
305
305
|
</div>
|
|
306
306
|
</div>
|
|
307
307
|
</div>
|
|
308
|
-
`;document.body.insertAdjacentHTML("beforeend",n)}function
|
|
308
|
+
`;document.body.insertAdjacentHTML("beforeend",n)}function P(){document.getElementById("close-btn").addEventListener("click",h)}function S(){window.addEventListener("click",function(n){const t=document.getElementById("chat-window"),e=document.getElementById("chat-icon");!t.contains(n.target)&&!e.contains(n.target)&&(t.classList.remove("visible"),e.style.display="flex")})}function O(n){console.log(n);const t=document.getElementById("chat-icon"),e=document.getElementById("chat-window");t.className="",e.className="",n==="right-center"?(t.classList.add("chat-icon-right-center"),e.classList.add("right-center-aligned")):t.classList.add("chat-icon-bottom-right")}if(typeof window<"u"){const n=((w=window.wineaterData)==null?void 0:w.POSITION)||"bottom-right";window.addEventListener("DOMContentLoaded",async()=>{var s;const e=["climats","telckel","biobio","weinpoint"].find(p=>window.location.href.includes(p))||null;let o;e&&(o=e.charAt(0).toUpperCase()+e.slice(1)),await a.fetchConfig(o||null),W(),P(),S(),O(n),x("chatbotToken",(s=window.wineaterData)==null?void 0:s.CLIENT_TOKEN,365),new L().initialize()})}r.closeChatWindow=f,r.openChatWindow=b,r.toggleChatWindow=h,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})});
|