PageSourceSearch

https://www.vcn.be/assets/AISupportChat-COaMnaZQ.js

js vcn.be collected 2026-10-08 08:07:26 UTC 9,562 bytes, 4 lines download raw bytes

1import{c as Q,r as l,j as e}from"./vendor-react-DtVE4p7m.js";import{B as Y}from"./button-BbC7hWJa.js";import{I as X}from"./input-FK_Vqpem.js";import{p as Z,k as ee,i as ne,s as te}from"./index-CuIfIfPZ.js";import{u as re}from"./useKeyboardVisible-DpWTgLHX.js";import{V as oe,a as se,b as ae}from"./VeenyFrame-BeWm2E9D.js";import{A as ie}from"./index-CWCHH1HQ.js";import{m as le}from"./proxy-CuJZE8q4.js";import{U as ce}from"./user-BzG5OAmz.js";import{L as F}from"./loader-circle-CZSQyEiL.js";import{S as de}from"./send-mcUvXyjf.js";import"./index-CbwLjnrV.js";import"./vendor-supabase-6P6EowNV.js";import"./sparkles-BlhGzX0R.js";import"./createLucideIcon-SnDx3gtb.js";import"./x-B1pGnJqQ.js";const K={reservation:{fr:"Réserver en ligne",nl:"Online boeken",en:"Book online",href:{fr:"/fr/reservation",nl:"/nl/reservering",en:"/en/booking"}},contact:{fr:"Formulaire de contact / devis",nl:"Contactformulier / offerte",en:"Contact form / quote",href:{fr:"/fr/contact",nl:"/nl/contact",en:"/en/contact"}},telephone:{fr:"Appeler le 010 80 20 92",nl:"Bel 010 80 20 92",en:"Call 010 80 20 92",href:{fr:"tel:+3210802092",nl:"tel:+3210802092",en:"tel:+3210802092"}},"simulateur-clim":{fr:"Simulateur climatisation",nl:"Airco-simulator",en:"Air-conditioning simulator",href:{fr:"/fr/climatisation/devis",nl:"/nl/airconditioning/offerte",en:"/en/air-conditioning/quote"}},"simulateur-energie":{fr:"Audit énergétique gratuit",nl:"Gratis energie-audit",en:"Free energy audit",href:{fr:"/fr/simulateur",nl:"/nl/simulator",en:"/en/simulator"}},one:{fr:"Abonnements VCN One",nl:"VCN One-abonnementen",en:"VCN One subscriptions",href:{fr:"/fr/one",nl:"/nl/one",en:"/en/one"}},compte:{fr:"Mon espace client",nl:"Mijn klantenzone",en:"My account",href:{fr:"/fr/compte",nl:"/nl/account",en:"/en/account"}},"codes-erreur":{fr:"Codes erreur",nl:"Foutcodes",en:"Error codes",href:{fr:"/fr/codes-erreur",nl:"/nl/foutcodes",en:"/en/error-codes"}}},H=x=>{const u=[];return{texte:x.replace(/\[\[CTA:([a-z-]+)\]\]/g,(O,m)=>(K[m]&&!u.includes(m)&&u.push(m),"")).replace(/\*\*([^*]+)\*\*/g,"$1").replace(/^#{1,3}\s*/gm,"").replace(/[ \t]+\n/g,`
2`).trim(),ctas:u}},ue={fr:"Bonjour ! Je suis Veeny, l'assistant de VCN Energy. Entretien, dépannage, climatisation, abonnement VCN One, prix de l'énergie, codes erreur… posez-moi votre question, je vous oriente ensuite vers la réservation ou le bon formulaire.",nl:"Hallo! Ik ben Veeny, de assistent van VCN Energy. Onderhoud, herstelling, airco, VCN One-abonnement, energieprijzen, foutcodes… stel uw vraag, daarna leid ik u naar de boeking of het juiste formulier.",en:"Hello! I'm Veeny, the VCN Energy assistant. Maintenance, repairs, air conditioning, VCN One subscription, energy prices, error codes… ask me anything and I'll point you to the booking page or the right form."},me={fr:["Combien coûte un entretien de chaudière gaz ?","Je veux une climatisation pour mon salon","Ma chaudière affiche un code erreur","Intervenez-vous à Waterloo ?","Qu'est-ce que VCN One ?"],nl:["Wat kost een onderhoud van een gasketel?","Ik wil een airco voor mijn woonkamer","Mijn ketel toont een foutcode","Komen jullie naar Waterloo?","Wat is VCN One?"],en:["How much is a gas boiler service?","I want air conditioning for my living room","My boiler shows an error code","Do you cover Waterloo?","What is VCN One?"]},Ie=()=>{const{activeChat:x,setActiveChat:u,isCartOpen:A,bottomBarPresent:O}=Z(),{language:m}=ee(),r=m==="nl"||m==="en"?m:"fr",$=Q(),b=x==="veeny",[h,q]=l.useState(!1),[y,w]=l.useState([{role:"assistant",content:ue[r]}]),[j,I]=l.useState(""),[v,S]=l.useState(!1),_=l.useRef(null),M=l.useRef(null),U=re(),T=l.useCallback((n=!0)=>{const o=()=>{var a;(a=_.current)==null||a.scrollIntoView({behavior:n?"smooth":"instant",block:"end"})};requestAnimationFrame(()=>{o(),setTimeout(o,100),setTimeout(o,300)})},[]);l.useEffect(()=>{b&&!h&&T(!1)},[y,b,h,T]),l.useEffect(()=>{var n;b&&!h&&((n=M.current)==null||n.focus())},[b,h]);const J=async n=>{var W,z,B,L;const o="https://gjqmxhgtwfruwmpgmkka.supabase.co/functions/v1/ai-support-chat";let a="sb_publishable_WVM5-_BY_t9owasok9HwzQ_VbLWAcMb",c=null,t=null;try{const{data:s}=await te.auth.getSession();if((W=s.session)!=null&&W.access_token){a=s.session.access_token,c=s.session.user.email??null;const g=s.session.user.user_metadata;
2t=g&&[g.first_name,g.last_name].filter(Boolean).join(" ")||null}}catch{}const i=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`,apikey:"sb_publishable_WVM5-_BY_t9owasok9HwzQ_VbLWAcMb"},body:JSON.stringify({messages:n,langue:r,page:window.location.pathname,email:c,nom:t})});if(!i.ok){const s=await i.json().catch(()=>({}));throw new Error(s.error||"Erreur de connexion")}if(!i.body)throw new Error("No response body");const f=i.body.getReader(),N=new TextDecoder;let p="",k="";for(w(s=>[...s,{role:"assistant",content:""}]);;){const{done:s,value:g}=await f.read();if(s)break;p+=N.decode(g,{stream:!0});let V;for(;(V=p.indexOf(`
3`))!==-1;){let d=p.slice(0,V);if(p=p.slice(V+1),d.endsWith("\r")&&(d=d.slice(0,-1)),d.startsWith(":")||d.trim()===""||!d.startsWith("data: "))continue;const R=d.slice(6).trim();if(R==="[DONE]")break;try{const D=(L=(B=(z=JSON.parse(R).choices)==null?void 0:z[0])==null?void 0:B.delta)==null?void 0:L.content;D&&(k+=D,w(G=>{const E=[...G];return E[E.length-1]={role:"assistant",content:k},E}))}catch{p=d+`
4`+p;break}}}return k},C=async n=>{const o=(n??j).trim();if(!o||v)return;const a={role:"user",content:o},c=[...y,a];w(c),I(""),S(!0);try{await J(c.filter(t=>t.content).map(t=>({...t,content:t.role==="assistant"?H(t.content).texte:t.content})))}catch(t){console.error("Chat error:",t),ne.error(t instanceof Error?t.message:"Erreur de connexion"),w(i=>i.filter(f=>f.content))}finally{S(!1)}},P=n=>{n.key==="Enter"&&!n.shiftKey&&(n.preventDefault(),C())};return e.jsxs(e.Fragment,{children:[e.jsx(ie,{children:x==="none"&&!A&&e.jsx(oe,{onClick:()=>u("veeny"),bottomOffset:O?88:20})}),e.jsx(se,{open:b,onClose:()=>u("none"),sousTitre:r==="nl"?"AI-assistent VCN Energy":r==="en"?"VCN Energy AI assistant":"Assistant IA VCN Energy",pleinEcran:U,minimise:h,onMinimiser:()=>q(!h),children:e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",style:{background:"rgba(5,15,30,0.3)"},children:[y.map((n,o)=>e.jsxs(le.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex gap-3 ${n.role==="user"?"flex-row-reverse":""}`,children:[e.jsx("div",{className:`w-9 h-9 rounded-full flex items-center justify-center shrink-0 ${n.role==="user"?"bg-cyan-500/20 text-cyan-300 border border-cyan-400/30":"bg-gradient-to-br from-cyan-500/30 to-blue-600/30 text-cyan-200 border border-cyan-400/20"}`,children:n.role==="user"?e.jsx(ce,{className:"w-4 h-4"}):e.jsx("img",{src:ae,alt:"",className:"h-full w-full rounded-full object-cover"})}),e.jsx("div",{className:`max-w-[80%] p-3 rounded-2xl text-sm ${n.role==="user"?"bg-gradient-to-br from-cyan-500 to-blue-600 text-white rounded-br-md shadow-lg shadow-cyan-500/20":"bg-white/10 text-white rounded-bl-md border border-cyan-500/20"}`,children:n.content?(()=>{if(n.role==="user")return e.jsx("span",{className:"whitespace-pre-wrap",children:n.content});const{texte:a,ctas:c}=H(n.content);return e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"whitespace-pre-wrap",children:a}),c.length>0&&e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:c.map(t=>{const i=K[t],f=i.href[r],N=f.startsWith("tel:");return e.jsxs("button",{type:"button",onClick:()=>{N?window.location.href=f:(u("none"),$(f))},className:"inline-flex items-center gap-1.5 rounded-xl border border-cyan-400/40 bg-cyan-500/15 px-3 py-1.5 text-xs font-semibold text-cyan-100 hover:bg-cyan-500/30",children:[i[r]," →"]},t)})})]})})():e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{className:"w-4 h-4 animate-spin text-cyan-300"}),e.jsx("span",{className:"text-cyan-200",children:r==="nl"?"Even nadenken…":r==="en"?"Thinking…":"Réflexion..."})]})})]},o)),y.length===1&&e.jsx("div",{className:"flex flex-wrap gap-2 pl-12",children:me[r].map(n=>e.jsx("button",{type:"button",onClick:()=>void C(n),className:"rounded-xl border border-white/15 bg-white/5 px-3 py-1.5 text-xs text-cyan-100 hover:border-cyan-400/40",children:n},n))}),e.jsx("div",{ref:_})]}),e.jsxs("div",{className:"p-4 pb-[calc(1rem+env(safe-area-inset-bottom))] border-t border-cyan-400/20 shrink-0",style:{background:"linear-gradient(135deg, rgba(6,182,212,0.1) 0%, rgba(59,130,246,0.05) 100%)"},children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx(X,{ref:M,value:j,onChange:n=>I(n.target.value),onKeyDown:P,placeholder:r==="nl"?"Typ uw bericht…":r==="en"?"Type your message…":"Écrivez votre message…",disabled:v,className:"flex-1 h-11 text-base bg-white/8 border-cyan-500/30 text-white placeholder:text-cyan-200/50 focus:border-cyan-400/60 rounded-xl",style:{background:"rgba(255,255,255,0.05)",backdropFilter:"blur(10px)"}}),e.jsx(Y,{onClick:()=>void C(),disabled:!j.trim()||v,size:"icon",className:"h-11 w-11 shrink-0 rounded-xl border-0",style:{background:"linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%)",boxShadow:"0 4px 20px rgba(6,182,212,0.4)"},children:v?e.jsx(F,{className:"w-5 h-5 animate-spin text-white"}):e.jsx(de,{className:"w-5 h-5 text-white"})})]}),e.jsx("p",{className:"text-xs text-cyan-200/50 mt-3 text-center",children:r==="nl"?"Dringend? Bel 010 80 20 92":r==="en"?"Emergency? Call 010 80 20 92":"Pour les urgences, appelez le 010 80 20 92"})]})]})})]})};export{Ie as default};

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.