Automatiser WhatsApp Business : Welcome Counter
"}<script src="welcomecounter.com/w.js" data-id="nuee"></script> `,
colors:()=>`
${svg("chat","",2)}
`,
inbox:()=>`
${[["g_ig","Instagram","#D6336C"],["g_web",fr()?"Site web":"Website","#5E82B8"],["g_wa","WhatsApp","#22B573"]].map(([g,n,c])=>`${svg(g,"",2)} ${n} `).join("")}${fr()?"Une seule boîte":"One inbox"}
`,
link:()=>`
${av("av-w4")} lina ${fr()?"le lien ??":"the link??"}
${av("nuee-av")} nuee.skin nuee.fr/gel-nuage ${fr()?"non cliquable":"not clickable"}
${fr()?"En privé :":"In private:"} ${fr()?"Voir le produit":"See the product"}
`,
follow:()=>`
${av("av-w7")} anna ${fr()?"Demande le guide":"Asks for the guide"} ${fr()?"Suivre":"Follow"} ${fr()?"Abonnée":"Following"}
${svg("lock","",2)} ${fr()?"Guide débloqué":"Guide unlocked"}
`};
let liveT=null;
function kPhone(sk,acc,body,F){const nm=esc(t(UC.kName||acc[2]));
if(sk==="tt")return `
${SB("20:14")}
${ic("back")}${av(acc[0])} ${nm} ${acc[1]} ${ic("dots")}
${body}
${F?"Envoyer un message…":"Send a message…"} ${ic("stk2")}${ic("imgi")}
`;
if(sk==="me")return `
${SB("20:14",1)}
${ic("back")}${av(acc[0])} ${nm} ${F?"Actif maintenant":"Active now"} ${ic("call")}${ic("vid")}
${body}
${ic("plus")}${ic("cam")}${ic("imgi")}Aa ${ic("hf")}
`;
if(sk==="wa")return `
${SB("20:14",1)}
${ic("back")} ${av(acc[0])} ${nm} ${F?"Compte professionnel":"Business account"} ${ic("call")}${ic("dots")}
${body}
${ic("plus")} ${ic("stk")} ${ic("mic")}
`;
if(sk==="tg")return `
${SB("20:14")}
${ic("back")}Chats ${nm} bot ${av(acc[0])}
${body}
${svg("grid","",2)} Menu Message ${ic("mic")}
`;
if(sk==="web")return `
${av(acc[0])} ${nm} ${F?"Répond en quelques minutes":"Replies in a few minutes"} ${svg("x","",2)}
${body}
${F?"Écrivez un message…":"Write a message…"} ${svg("send","",2)}
${F?"Propulsé par":"Powered by"} Welcome Counter `;
return `
${SB("20:14",1)}
${ic("back")} ${av(acc[0])} ${nm} ${acc[1]}
${body}
${ic("cam")} ${F?"Votre message…":"Message…"}
`}
const KIC={"Commentaire":"pub","Message":"send","Message privé":"send","Action":"tag","IA":"spark","Transfert":"user","Réponse à une story":"play","Rendez-vous":"cal","Objectif":"flag","Live":"bolt","Lien en bio":"link","Question":"q","Délai":"clock","Carrousel":"grid","Attente":"clock","Mot-clé":"chat","Nouvel abonné":"user","Mention en story":"heart","Condition":"cond","Paiement":"card","E-mail":"mail","Tri IA":"spark","Lecture par l’IA":"spark","Réponse publique":"pub","Lien en bio":"link","Bouton":"check","Menu persistant":"grid","QR code":"link","Clic sur une publicité":"bolt","Mot-clé":"chat","Nouvelle commande":"check","/start":"bolt","Commande":"grid","Visite d’une page":"clock","Inactivité":"clock","Panier abandonné":"card","Avant un rendez-vous":"clock","Shopify":"bolt","WooCommerce":"bolt","Slack":"bolt","Google Sheets":"grid","Axonaut":"bolt","Brevo":"mail","Rendez-vous pris":"cal","Anniversaire":"heart","Étiquette":"tag","SMS":"send"};
function kSel(i){const P=root.querySelector(".k-p");if(!P)return;const [cx,ti,de,steps0]=UC.menu[i],steps=(UC.kSteps&&UC.kSteps[i])||steps0,F=fr(),sc=(UC.kscn||[])[i]||[],acc=AC[UC.hAcc];
root.querySelectorAll(".k-list button").forEach((b,k)=>b.setAttribute("aria-selected",k===i));
const el=([k,tx,j])=>{const x=esc(t(tx));
if(k==="cmt")return `
${av("av-w4")} lina · ${F?"commentaire":"comment"} ${x}
`;
if(k==="rep")return `
${av(acc[0])} ${acc[1]} ${x}
`;
if(k==="evt")return `${x} `;
if(k==="tag")return `${svg("tag","",2)} ${x} `;
if(k==="in")return `
${x}
`;
if(k==="btn")return `
${av(acc[0])} ${x} ${esc(t(tx.b||T("Open","Ouvrir")))}
`;
return `
${av(acc[0])} ${x}
`};
P.innerHTML=`
${esc(t(CH[cx][0]))} · ${F?"Modèle":"Template"} ${esc(t(ti))}
${steps.map((st,j)=>`
${svg(KIC[st]||"bolt","",2)} ${j===0?(F?"Quand":"When"):(F?"Puis":"Then")} · ${esc(F?st:(STEPL[st]||st))} ${(()=>{const e=sc.find(e=>e[2]===j);return e?esc(t(e[1])):""})()}
${j
`:""}`).join("")}
${kPhone(SKN[UC.ch]||"ig",acc,sc.map(el).join(""),F)}
`;
P.classList.remove("go");void P.offsetWidth;P.classList.add("go");
clearTimeout(P._t);const rm=root.classList.contains("rm");const xs=[...P.querySelectorAll(".kx")],ns=[...P.querySelectorAll(".k-node")];
if(rm){xs.forEach(x=>x.classList.add("sh"));return}
const D2=P.querySelector(".k-det");const lab=k=>({cmt:F?"Le client commente":"The customer comments",rep:F?"Réponse publique envoyée":"Public reply sent",out:F?"Message envoyé":"Message sent",btn:F?"Message avec bouton":"Message with button",in:F?"Le client écrit":"The customer writes",evt:F?"Événement":"Event",tag:F?"Action effectuée":"Action done"})[k];
const det=j=>{const n=ns[j];if(!n||!D2)return;D2.querySelector("i").innerHTML=n.querySelector("i").innerHTML;D2.querySelector("b").textContent=(j===0?(F?"Quand · ":"When · "):(F?"Étape "+(j+1)+" · ":"Step "+(j+1)+" · "))+n.querySelector("b").textContent;
D2.querySelector(".k-db").innerHTML=sc.filter(e=>e[2]===j).map(e=>`
${lab(e[0])} ${esc(t(e[1]))} ${e[0]==="btn"?`${esc(t(e[1].b||T("Open","Ouvrir")))} `:""}
`).join("")||`
${F?"Étape automatique, rien à faire.":"Automatic step, nothing to do."}
`;
D2.querySelector(".k-dn").textContent=F?"Réglable en deux clics":"Adjustable in two clicks";D2.classList.remove("go");void D2.offsetWidth;D2.classList.add("go")};
let lastJ=-1;let k=0;const nx=()=>{if(k>=xs.length)return;const x=xs[k];const j=+x.dataset.j;ns.forEach((n,q)=>{n.classList.toggle("on",q===j);n.classList.toggle("dn",q{x.classList.remove("ty");k++;P._t=setTimeout(nx,550)},650)}else{x.classList.add("sh");k++;P._t=setTimeout(nx,800)}};
P._t=setTimeout(nx,700)}
function runPh(S,c,loop){clearTimeout(S._st);(S._tt||[]).forEach(clearTimeout);S._tt=[];const TT=S._tt,later=(f,t)=>TT.push(setTimeout(f,t));
S.querySelectorAll(".u-x").forEach(m=>m.classList.remove("sh","ty"));S.querySelectorAll(".u-nt").forEach(m=>m.classList.remove("in"));
const rm=root.classList.contains("rm"),n=c.r.length;let s=-1;
const tapOn=txt=>{const ch=[...S.querySelectorAll(".u-sc.on .u-qr.sh i,.u-sc.on .m.sh .u-bt")].reverse().find(x=>x.textContent.trim()===txt.trim());if(ch){ch.classList.remove("tap");void ch.offsetWidth;ch.classList.add("tap")}return !!ch};
const apply=()=>{const sc=[...S.querySelectorAll(".u-sc")];let act=0;sc.forEach((x,k)=>{if(+x.dataset.s<=s)act=k});const moved=!sc[act].classList.contains("on");
sc.forEach((x,k)=>{x.classList.toggle("on",k===act);x.classList.toggle("past",k+m.dataset.s<=s);
if(rm){fresh.forEach(m=>m.classList.add("sh"));S.querySelectorAll(".u-nt").forEach(m=>m.classList.toggle("in",+m.dataset.s<=s));return 0}
let t=moved&&s>=0?650:150;
fresh.forEach(m=>{const biz=m.classList.contains("m")&&m.classList.contains("in");const cust=m.classList.contains("out");
if(biz){later(()=>m.classList.add("sh","ty"),t);t+=800;later(()=>m.classList.remove("ty"),t);t+=420}
else if(cust){const tx=(m.querySelector(".bb")||m).textContent;later(()=>{if(tapOn(tx.replace(/\d{1,2}:\d{2}$/,"")))later(()=>m.classList.add("sh"),420);else m.classList.add("sh")},t);t+=800}
else{later(()=>m.classList.add("sh"),t);t+=m.classList.contains("c")?600:380}});
S.querySelectorAll(".u-nt").forEach(m=>{if(+m.dataset.s===s){later(()=>m.classList.add("in"),t);t+=900}else if(+m.dataset.s{s++;const t=apply();if(s>=n-1){if(loop)S._st=setTimeout(()=>runPh(S,c,loop),t+4500);return}S._st=setTimeout(go,Math.max(1000,t+650))};S._st=setTimeout(go,s<0?1100:900)}
function staticPh(S){const sc=[...S.querySelectorAll(".u-sc")];const k=UC.heroScr==null?0:Math.min(UC.heroScr,sc.length-1);sc.forEach((x,j)=>{x.classList.toggle("on",j===k);x.classList.toggle("past",jm.classList.add("sh"))}
let tAct=-2,tickP=false;
function updP(){tickP=false;const vh=innerHeight,F=root.querySelector(".v-flow");if(!F)return;
root.querySelectorAll("h2,.fi,.u-mi").forEach(el=>{if(el.getBoundingClientRect().top900?pt+(vh-pt-pb-ph.offsetHeight)/2:pt;const want=(innerWidth>900?tb+34:root.querySelector(".v-row").getBoundingClientRect().bottom+scrollY+20);F._off=Math.max(0,want-nat);F._vw=innerWidth;F.style.setProperty("--off",F._off+"px")}}
const bd=root.querySelector(".v-bt");if(bd){const r=bd.getBoundingClientRect();bd.style.transform=`translateX(${(-(vh-r.top)*0.35).toFixed(1)}px)`}
if(innerWidth<=900){root.querySelectorAll(".v-ch").forEach((el,i)=>{const ph=el.querySelector(".v-mph");const r=ph.getBoundingClientRect();const v=r.topvh*.25;el.classList.toggle("act",true);if(v&&!ph._run){ph._run=1;runPh(ph,UC.cases[i],true)}else if(!v&&ph._run){ph._run=0;clearTimeout(ph._st);(ph._tt||[]).forEach(clearTimeout)}});return}
let best=-1;root.querySelectorAll(".v-ch").forEach((el,i)=>{const r=el.getBoundingClientRect();if(r.topvh*.4)best=i;el.classList.toggle("act",r.topvh*.4)});
if(best===-1){const first=root.querySelector(".v-ch").getBoundingClientRect();if(first.top>vh*.6)best=-1;else best=tAct<0?-1:tAct}
if(best!==tAct){tAct=best;const sets=[...root.querySelectorAll(".v-set")];
sets.forEach(x=>{const k=+x.dataset.i;x.classList.toggle("on",k===best);x.classList.toggle("up",kx.classList.toggle("on",i===best));F.classList.toggle("tour",best>=0);
if(best>=0)runPh(root.querySelector(`.v-set[data-i="${best}"]`),UC.cases[best],true)}}
function endFx(){const Z=root.querySelector(".z-end");if(Z){const io3=new IntersectionObserver(es=>es.forEach(e=>{if(e.isIntersecting)Z.classList.add("go")}),{threshold:.3});io3.observe(Z)}const E=root.querySelector(".w-end");if(!E)return;const io=new IntersectionObserver(es=>{es.forEach(e=>{if(e.isIntersecting&&!E._on){E._on=1;E.classList.add("go");setTimeout(()=>{const st=E.querySelector(".w-stt");if(st)st.textContent=fr()?"Connecté":"Connected";E.classList.add("ok")},1600)}})},{threshold:.35});io.observe(E);
const W=root.querySelector(".w-rules");if(W){const io2=new IntersectionObserver(es=>es.forEach(e=>{if(e.isIntersecting)W.classList.add("go")}),{threshold:.3});io2.observe(W)}
const t0=Date.now(),lc=root.querySelector(".w-lc");clearInterval(liveT);liveT=setInterval(()=>{if(lc)lc.textContent=Math.floor((Date.now()-t0)/1000*UC.liveRate)},500)}
function kBind(){const L=root.querySelector(".k-list");if(!L)return;let k=0,man=0;kSel(0);
L.querySelectorAll("button").forEach(b=>b.onclick=()=>{man=1;k=+b.dataset.k;kSel(k)});
clearInterval(root._kt);root._kt=setInterval(()=>{if(man||root.classList.contains("rm"))return;const r=L.getBoundingClientRect();if(r.top0){k=(k+1)%UC.menu.length;kSel(k)}},7500)}
function bindP(){
if(matchMedia("(prefers-reduced-motion: reduce)").matches)root.classList.add("rm");
requestAnimationFrame(()=>root.querySelector(".h3").classList.add("in"));
staticPh(root.querySelector('.v-set[data-i="-1"]'));staticPh(root.querySelector('.v-hvp'));
root.querySelectorAll(".fi>button").forEach(b=>b.onclick=()=>{const o=b.getAttribute("aria-expanded")==="true";b.setAttribute("aria-expanded",!o);b.parentNode.classList.toggle("op",!o)});
endFx();kBind();tAct=-2;if(!root._bp){root._bp=1;const req=()=>{if(!tickP){tickP=true;requestAnimationFrame(updP)}};addEventListener("scroll",req,{passive:true});addEventListener("resize",req)}
updP()}
const SVP=[
D=>` ${fr()?"Connecter":"Connect"} ${esc(t(CH[D.ch][0]))}${fr()?"Connexion officielle":"Official login"}
`,
D=>`${fr()?"Modèle":"Template"} ${esc(t(D.menu[0][1]))} ${D.menu[0][3].slice(0,3).map(s=>`${esc(fr()?s:(STEPL[s]||s))} `).join(svg("arr","",2))}
`,
D=>`${fr()?"Essai : rien n’est envoyé":"Test run: nothing is sent"} ${esc(t(COMMON.live))}
`];
function lock(){const N=[...root.querySelectorAll(".p-n")],cnt=root.querySelector(".p-cnt");if(!N.length)return;clearTimeout(root._lk);
const rm=root.classList.contains("rm");let k=0,n0=+String(UC.tk0).replace(/\D/g,""),n=n0;
const show=()=>{if(k>=N.length){root._lk=setTimeout(()=>{N.forEach(x=>{x.classList.remove("in");x.style.order=""});k=0;n=n0;cnt.textContent=fmtN(n.toLocaleString("fr-FR").replace(/\s/g," "));root._lk=setTimeout(show,700)},3200);return}
const x=N[k];x.style.order=-k;x.classList.add("in");if(x.dataset.wc==="1"){n++;cnt.textContent=fmtN(n.toLocaleString("fr-FR").replace(/\s/g," "));cnt.parentNode.classList.remove("bump");void cnt.offsetWidth;cnt.parentNode.classList.add("bump")}
N.forEach((y,j)=>y.classList.toggle("old",j{x.style.order=-j;x.classList.add("in")});return}
root._lk=setTimeout(show,900)}
const SV=[
D=>`${fr()?"Modèle":"Template"} ${esc(t(D.cases[0].tpl))} ${D.menu[0][3].slice(0,3).map(s=>`${esc(fr()?s:(STEPL[s]||s))} `).join(svg("arr","",2))}
`,
D=>`${fr()?"Votre message":"Your message"} ${esc(t(D.sv2))}
`,
D=>`${fr()?"Essai : rien n’est envoyé":"Test run: nothing is sent"} ${esc(t(COMMON.live))}
`];
let tick=false,ci=0,man=0,stepT=null;
function play(i){ci=i;const S=root.querySelector(".u-stage"),c=UC.cases[i];
root.querySelectorAll(".u-tabs button").forEach((b,k)=>b.setAttribute("aria-selected",k===i));
S.innerHTML=caseHtml(c);clearTimeout(stepT);
const rm=root.classList.contains("rm"),n=c.r.length;let s=rm?n-1:-1;const TT=[];const later=(f,t)=>TT.push(setTimeout(f,t));root._tt&&root._tt.forEach(clearTimeout);root._tt=TT;
const pg=S.querySelector(".u-pg i");
const tapOn=txt=>{const ch=[...S.querySelectorAll(".u-sc.on .u-qr.sh i,.u-sc.on .m.sh .u-bt")].reverse().find(x=>x.textContent.trim()===txt.trim());if(ch){ch.classList.remove("tap");void ch.offsetWidth;ch.classList.add("tap")}return !!ch};
const apply=()=>{S.querySelectorAll(".u-ri").forEach(l=>{const k=+l.dataset.s;l.classList.toggle("on",k===s);l.classList.toggle("done",k{if(+x.dataset.s<=s)act=k});
const moved=!sc[act].classList.contains("on");
sc.forEach((x,k)=>{x.classList.toggle("on",k===act);x.classList.toggle("past",k+m.dataset.s<=s);
S.querySelectorAll(".u-nt").forEach(m=>{if(+m.dataset.sm.classList.add("sh"));S.querySelectorAll(".u-nt").forEach(m=>m.classList.toggle("in",+m.dataset.s<=s));return 0}
let t=moved&&s>=0?650:150;
fresh.forEach(m=>{const biz=m.classList.contains("m")&&m.classList.contains("in");const cust=m.classList.contains("out");
if(biz){later(()=>{m.classList.add("sh","ty")},t);t+=850;later(()=>m.classList.remove("ty"),t);t+=450}
else if(cust){const tx=(m.querySelector(".bb")||m).textContent;later(()=>{if(tapOn(tx.replace(/\d{1,2}:\d{2}$/,"")))later(()=>m.classList.add("sh"),450);else m.classList.add("sh")},t);t+=850}
else{later(()=>m.classList.add("sh"),t);t+=m.classList.contains("c")?650:400}});
S.querySelectorAll(".u-nt").forEach(m=>{if(+m.dataset.s===s){later(()=>m.classList.add("in"),t);t+=900}});
return t};
const nxt=()=>{if(!man&&root._v)play((ci+1)%UC.cases.length);else stepT=setTimeout(nxt,2000)};
const go=()=>{const t=apply();if(s>=n-1){S.classList.add("u-done");if(!rm)stepT=setTimeout(nxt,t+4200);return}s++;stepT=setTimeout(go,Math.max(s===0?1600:1100,t+700))};
S.classList.toggle("u-done",rm);if(rm)apply();else{apply();stepT=setTimeout(go,1100)}}
function upd(){tick=false;const vh=innerHeight,q=s=>root.querySelector(s);if(!q(".h3"))return;
root.querySelectorAll("h2,.s3-i,.fi,.u-mi,.u-tkt").forEach(el=>{if(el.getBoundingClientRect().topvh*.3;if(v&&!root._v&&!root._st){root._st=1;play(0)}root._v=v}
function bind(){
if(matchMedia("(prefers-reduced-motion: reduce)").matches)root.classList.add("rm");
requestAnimationFrame(()=>root.querySelector(".h3").classList.add("in"));
root.querySelectorAll(".fi>button").forEach(b=>b.onclick=()=>{const o=b.getAttribute("aria-expanded")==="true";b.setAttribute("aria-expanded",!o);b.parentNode.classList.toggle("op",!o)});
root.querySelectorAll(".u-tabs button").forEach(b=>b.onclick=()=>{man=1;root._st=1;play(+b.dataset.c)});
root._st=0;play(ci);
if(!root._b){root._b=1;const req=()=>{if(!tick){tick=true;requestAnimationFrame(upd)}};addEventListener("scroll",req,{passive:true});addEventListener("resize",req)}
upd()}
window.addEventListener("wc-lang",e=>{if(e.detail!==lang&&LANGS.includes(e.detail)){lang=e.detail;render()}});
render();
})();