PageSourceSearch

https://digitalicons.lovable.app/assets/OnboardingManager-CZZSZLmd.js

js digitalicons.lovable.app collected 2026-10-03 03:27:16 UTC 22,019 bytes, 1 lines download raw bytes

1import{j as e}from"./ui-radix-Dy8lNabE.js";import{r,d as $,u as Q}from"./react-vendor-CPuvF1Sp.js";import{b as J,s as f,L,B as N,r as ee,Z as H,q as M,o as te,S as ae}from"./index-B3y-uz8q.js";import{s as R}from"./onboardingCompletion-CP-DS7ri.js";import{W as re,a as se}from"./WelcomeBoosterReveal-DAnejKJq.js";import{g as ie}from"./card-image-D3rQfndE.js";import{m as a,A as X}from"./animation-Bth2r7ZN.js";import{S as ne}from"./swords-MCpe904g.js";import{L as oe}from"./loader-circle-CX1gRznA.js";import{C as le}from"./coins-BFvI5_OB.js";import{L as ce}from"./lock-Dhab_LJ2.js";import{U as de}from"./user-plus-DAEGKMVv.js";import{R as ue}from"./rotate-ccw-DFkg8LIg.js";import"./query-D9I7bAJW.js";import"./supabase-DkiBvCxn.js";import"./welcome-booster-DsteMH1m.js";import"./use-mobile-DINd03Pq.js";import"./BoosterCardReveal-Bio8SwkE.js";import"./CardStatsOverlay-By5U1o4K.js";import"./chevron-right-Dn0DGWws.js";const q="di_admin_force_onboarding",G="di_onboarding_state",z="di_onboarding_active",me="di-onboarding-visibility-change",P="di_tutorial_result",pe="di_tutorial_game",D=t=>{typeof window>"u"||(t?localStorage.setItem(z,"true"):localStorage.removeItem(z),document.body.dataset.onboardingActive=t?"true":"false",window.dispatchEvent(new CustomEvent(me,{detail:{active:t}})))},E=()=>{typeof window>"u"||(localStorage.removeItem(G),localStorage.removeItem(P),localStorage.removeItem(pe),D(!1))},fe=()=>typeof window>"u"?!1:localStorage.getItem("di_onboarding_completed")==="true",ge=()=>{const{user:t,loading:h}=J(),y=fe(),[u,o]=r.useState({hasCompletedOnboarding:y,hasPlayedFirstGame:!1,hasOpenedWelcomeBooster:!1,isGuest:!1,sourceAttribution:"organic",currentStep:"idle"}),[x,s]=r.useState(!1),[d,m]=r.useState(y),[g,_]=r.useState(!1);r.useEffect(()=>{if(h)return;(async()=>{if(new URLSearchParams(window.location.search).get("onboarding_preview")==="true"&&t&&!t.is_anonymous){const c=new URL(window.location.href);c.searchParams.delete("onboarding_preview"),window.history.replaceState({},"",c.toString()),o(b=>({...b,hasCompletedOnboarding:!1,isGuest:!1,currentStep:"welcome"})),s(!0),m(!0);return}if(localStorage.getItem(q)==="true"&&(localStorage.removeItem(q),t&&!t.is_anonymous)){o(c=>({...c,hasCompletedOnboarding:!1,isGuest:!1,currentStep:"welcome"})),s(!0),m(!0);return}if(localStorage.getItem("di_onboarding_completed")==="true"){R(!0),E(),o(c=>({...c,hasCompletedOnboarding:!0,currentStep:"idle"})),s(!1),m(!0);return}if(t&&!t.is_anonymous){R(!0),E(),o(c=>({...c,hasCompletedOnboarding:!0,isGuest:!1,currentStep:"idle"})),s(!1),m(!0);return}const{data:C}=await f.from("d1_config").select("config_value").eq("config_key","onboarding_enabled").maybeSingle();if(!(C?.config_value?C.config_value.enabled===!0:!1)){m(!0);return}const k=localStorage.getItem(P);if(k&&t?.is_anonymous){localStorage.removeItem(P);let c=k==="completed";try{c=JSON.parse(k).completed===!0}catch{}if(c){o(b=>({...b,currentStep:"game_result",hasPlayedFirstGame:!0})),s(!0),m(!0);return}}if(t){const{data:c}=await f.from("onboarding_state").select("*").eq("user_id",t.id).maybeSingle();c?c.has_completed_onboarding===!0?(R(!0),E(),o(T=>({...T,hasCompletedOnboarding:!0,currentStep:"idle"})),s(!1)):(o({hasCompletedOnboarding:!1,hasPlayedFirstGame:c.has_played_first_game,hasOpenedWelcomeBooster:c.has_opened_welcome_booster,isGuest:!0,sourceAttribution:c.source_attribution||"organic",currentStep:c.onboarding_step||"welcome"}),s(!0)):(s(!0),o(b=>({...b,isGuest:!0,currentStep:"welcome"}))),m(!0);return}if(localStorage.getItem(G)){m(!0);return}s(!0),o(c=>({...c,currentStep:"welcome"})),m(!0)})()},[t,h]),r.useEffect(()=>{const l=d&&x&&u.currentStep!=="idle"&&u.currentStep!=="completed";D(l)},[d,x,u.currentStep]),r.useEffect(()=>()=>D(!1),[]);const w=r.useCallback(async()=>{if(!g){if(t&&!t.is_anonymous){await f.from("onboarding_state").upsert({user_id:t.id,is_guest:!1,source_attribution:"admin_test",onboarding_step:"welcome",has_opened_welcome_booster:!1,has_played_first_game:!1,has_completed_onboarding:!1,onboarding_completed_at:null,updated_at:new Date().toISOString()},{onConflict:"user_id"}),o(l=>({...l,isGuest:!1,sourceAttribution:"admin_test",currentStep:"welcome"}));return}if(!t){_(!0);try{const l=new URLSearchParams(window.location.search),n=l.get("source")||l.get("utm_source")||"organic",S=l.get("
1code")||l.get("ref")||null,{data:j,error:A}=await f.auth.signInAnonymously();if(A){_(!1);return}j.user&&(await f.from("onboarding_state").insert({user_id:j.user.id,is_guest:!0,source_attribution:n,source_id:S,onboarding_step:"welcome"}),localStorage.setItem(G,JSON.stringify({userId:j.user.id,startedAt:new Date().toISOString()})),o(C=>({...C,isGuest:!0,sourceAttribution:n,currentStep:"welcome"})))}catch{}finally{_(!1)}}}},[t,g]),i=r.useCallback(async l=>{if(o(n=>({...n,currentStep:l})),t){const n={onboarding_step:l,updated_at:new Date().toISOString()};l==="booster_opened"&&(n.has_opened_welcome_booster=!0),l==="game_result"&&(n.has_played_first_game=!0),l==="completed"&&(n.has_completed_onboarding=!0,n.onboarding_completed_at=new Date().toISOString(),R(!0),E()),await f.from("onboarding_state").update(n).eq("user_id",t.id)}},[t]),p=r.useCallback(async()=>{R(!0),E(),o(l=>({...l,hasCompletedOnboarding:!0,currentStep:"idle"})),s(!1),t&&await f.from("onboarding_state").update({has_completed_onboarding:!0,onboarding_completed_at:new Date().toISOString(),onboarding_step:"completed"}).eq("user_id",t.id)},[t]);return{...u,shouldStartOnboarding:x,isReady:d,isCreatingAnonymous:g,startOnboarding:w,advanceStep:i,skipOnboarding:p}},ye=[.16,1,.3,1],v={type:"spring",stiffness:150,damping:12,mass:.8},Z=r.forwardRef(({onLaunchGame:t,onSkip:h},y)=>{const[u,o]=r.useState("creating_deck"),[x,s]=r.useState(null),[d,m]=r.useState(0),g=$();r.useEffect(()=>{(async()=>{try{const{data:p,error:l}=await f.functions.invoke("create-welcome-deck");if(l){const{data:{user:n}}=await f.auth.getUser();if(n){const{data:S}=await f.from("card_ownership").select("id").eq("owner_id",n.id).limit(1);if(S&&S.length>0){const{data:j}=await f.from("decks").select("id").eq("user_id",n.id).eq("is_active",!0).limit(1).maybeSingle();if(j){setTimeout(()=>o("ready"),500);return}}}s("Impossible de préparer le deck. Tes cartes n'ont pas encore été générées.");return}p?.success?setTimeout(()=>o("ready"),800):s(p?.error||"Erreur lors de la création du deck")}catch{s("Erreur de connexion")}})()},[d]);const _=r.useCallback(()=>{s(null),m(i=>i+1)},[]),w=r.useCallback(async()=>{o("launching"),await t(),localStorage.setItem("di_tutorial_game","true"),g("/play")},[g,t]);return u==="creating_deck"?e.jsx(a.div,{ref:y,initial:{opacity:0}
1,animate:{opacity:1},className:"fixed inset-0 z-[200] flex flex-col items-center justify-center bg-background",children:x?e.jsxs(a.div,{className:"text-center px-6 max-w-sm",initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},transition:v,children:[e.jsx(L,{className:"w-10 h-10 text-muted-foreground mx-auto mb-4"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-5",children:x}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(N,{onClick:_,variant:"outline",className:"w-full",children:"Réessayer"}),e.jsx(N,{onClick:h,variant:"ghost",className:"text-muted-foreground text-sm",children:"Passer et explorer l'app"})]})]}):e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx(a.div,{className:"relative w-20 h-28",children:[0,1,2].map(i=>e.jsx(a.div,{className:"absolute inset-0 rounded-xl border border-primary/20",style:{background:"linear-gradient(135deg, hsl(var(--primary) / 0.1), hsl(var(--card)))",boxShadow:"0 4px 12px rgba(0,0,0,0.2)"},initial:{opacity:0,y:30,rotate:-10,scale:.8},animate:{opacity:1,y:i*-4,rotate:(i-1)*5,scale:1,x:(i-1)*3},transition:{delay:.3+i*.2,...v},children:e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:i===2&&e.jsx(a.div,{animate:{rotate:360},transition:{duration:2,repeat:1/0,ease:"linear"},children:e.jsx(L,{className:"w-6 h-6 text-primary/40"})})})},i))}),e.jsx(a.p,{initial:{opacity:0}
1,animate:{opacity:1},transition:{delay:.5},className:"text-sm text-muted-foreground",children:"Préparation de ton deck..."}),e.jsx("div",{className:"flex gap-1.5 mt-1",children:[0,1,2].map(i=>e.jsx(a.div,{className:"w-2 h-2 rounded-full bg-primary",animate:{opacity:[.3,1,.3],scale:[.8,1.2,.8]},transition:{duration:1,repeat:1/0,delay:i*.25}},i))})]})}):u==="ready"?e.jsxs(a.div,{ref:y,initial:{opacity:0},animate:{opacity:1},className:"fixed inset-0 z-[200] flex flex-col items-center justify-center bg-background px-6 overflow-hidden",children:[e.jsx(a.div,{className:"absolute w-[500px] h-[500px] rounded-full",style:{background:"radial-gradient(circle, hsl(var(--primary) / 0.08), transparent 60%)",filter:"blur(40px)"},animate:{scale:[1,1.3,1],opacity:[.15,.3,.15]},transition:{duration:4,repeat:1/0}}),[ne,ee,H].map((i,p)=>e.jsx(a.div,{className:"absolute",style:{left:`${20+p*30}%`,top:`${15+p%2*60}%`},initial:{opacity:0,scale:0},animate:{opacity:[0,.15,0],scale:[.5,1,.5],y:[0,-20,0],rotate:[0,10,-10,0]},transition:{duration:4,repeat:1/0,delay:p*1.2},children:e.jsx(i,{className:"w-8 h-8 text-primary"})},p)),e.jsxs(a.div,{initial:{scale:.8,opacity:0}
1,animate:{scale:1,opacity:1},transition:v,className:"relative z-10 text-center max-w-sm",children:[e.jsxs(a.div,{className:"relative mx-auto mb-4 w-20 h-20 flex items-center justify-center",children:[e.jsx(a.div,{className:"absolute inset-0 rounded-full",style:{border:"2px solid hsl(var(--primary) / 0.2)"},animate:{rotate:360,scale:[1,1.1,1]},transition:{rotate:{duration:8,repeat:1/0,ease:"linear"},scale:{duration:2,repeat:1/0}}}),e.jsx(a.div,{className:"absolute -inset-2 rounded-full",style:{border:"1px dashed hsl(var(--primary) / 0.1)"},animate:{rotate:-360},transition:{duration:12,repeat:1/0,ease:"linear"}}),e.jsx(a.div,{animate:{y:[0,-5,0],scale:[1,1.05,1]},transition:{duration:2.5,repeat:1/0,ease:"easeInOut"},children:e.jsx(L,{className:"w-12 h-12 text-primary",style:{filter:"drop-shadow(0 0 12px hsl(var(--primary) / 0.3))"}})})]}),e.jsx(a.h2,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.2,...v},className:"text-2xl font-black text-foreground mb-1",children:"Partie Tutoriel"}),e.jsx(a.p,{initial:{opacity:0}
1,animate:{opacity:1},transition:{delay:.35},className:"text-xs text-primary font-semibold mb-1",children:"Guidée • 2 victoires pour gagner"}),e.jsx(a.p,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.45},className:"text-sm text-muted-foreground mb-8",children:"Affronte un adversaire facile pour découvrir le jeu !"}),e.jsxs(a.div,{className:"flex flex-col gap-3",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.6},children:[e.jsx(a.div,{whileHover:{scale:1.02},whileTap:{scale:.97},children:e.jsxs(N,{onClick:w,className:"w-full gap-3 py-6 text-base font-bold bg-gradient-to-r from-primary to-accent hover:from-primary/90 hover:to-accent/90 text-primary-foreground relative overflow-hidden",style:{boxShadow:"0 0 30px hsl(var(--primary) / 0.4)"},children:[e.jsx(a.div,{className:"absolute inset-0",style:{background:"linear-gradient(105deg, transparent 30%, rgba(255,255,255,0.15) 45%, transparent 55%)"},animate:{x:["-100%","200%"]},transition:{duration:2.5,repeat:1/0,repeatDelay:1.5}}),e.jsx(L,{className:"w-5 h-5 relative z-10"}),e.jsx("span",{className:"relative z-10",children:"Lancer le combat !"})]})}),e.jsx(N,{onClick:h,variant:"ghost",className:"text-muted-foreground hover:text-foreground text-sm",children:"Plus tard"})]})]})]}):e.jsx(a.div,{ref:y,initial:{opacity:0}
1,animate:{opacity:1},className:"fixed inset-0 z-[200] flex items-center justify-center bg-background",children:e.jsx(a.div,{animate:{rotate:360},transition:{duration:1.5,repeat:1/0,ease:"linear"},children:e.jsx(oe,{className:"w-8 h-8 text-primary"})})})});Z.displayName="TutorialGameLauncher";const xe=({won:t,onReplay:h,onCreateAccount:y,onContinue:u})=>{const{user:o}=J(),[x,s]=r.useState("result"),[d,m]=r.useState({coins:50,xp:100}),[g,_]=r.useState(null);return r.useEffect(()=>{(async()=>{const{data:i}=await f.from("d1_config").select("config_value").eq("config_key","tutorial_rewards").maybeSingle();if(i?.config_value){const n=i.config_value;m({coins:t?n.win_coins||50:n.loss_coins||10,xp:t?n.win_xp||100:n.loss_xp||25})}const{data:p}=await f.from("d1_config").select("config_value").eq("config_key","teasing").maybeSingle();if(p?.config_value?.show_locked_legendary){const{data:n}=await f.from("cards").select("name, rarity, image_url").eq("rarity","legendary").eq("is_token",!1).limit(1).maybeSingle();n&&_(n)}setTimeout(()=>s("rewards"),1500)})()},[t]),r.useEffect(()=>{o&&f.from("onboarding_analytics").insert({user_id:o.id,event_type:"tutorial_game_completed",event_data:{won:t,coins:d.coins,xp:d.xp}}).then(()=>{})},[o,t,d]),e.jsxs(a.div,{initial:{opacity:0}
1,animate:{opacity:1},className:"fixed inset-0 z-[200] flex flex-col items-center justify-center bg-background px-6 overflow-y-auto",children:[t&&e.jsxs(e.Fragment,{children:[e.jsx(a.div,{initial:{scale:0,opacity:0},animate:{scale:2,opacity:.15},transition:{duration:1.5,ease:ye},className:"absolute w-[500px] h-[500px] rounded-full",style:{background:"radial-gradient(circle, hsl(40 90% 55% / 0.5), transparent 60%)"}}),[...Array(12)].map((w,i)=>e.jsx(a.div,{className:"absolute rounded-full",style:{width:4+Math.random()*4,height:4+Math.random()*4,background:i%3===0?"hsl(40 90% 55%)":i%3===1?"hsl(var(--primary))":"hsl(var(--accent))",top:"50%",left:"50%"},initial:{scale:0,opacity:1},animate:{x:Math.cos(i/12*Math.PI*2)*(100+Math.random()*100),y:Math.sin(i/12*Math.PI*2)*(100+Math.random()*100),opacity:0,scale:[0,1.5,0]},transition:{duration:1.5,delay:.3+i*.05,ease:"easeOut"}},`confetti-${i}`))]}),e.jsx(a.div,{initial:{scale:.8,opacity:0},animate:{scale:1,opacity:1},transition:{type:"spring",damping:12},className:"relative z-10 text-center max-w-sm w-full",children:e.jsxs(X,{mode:"wait",children:[x==="result"&&e.jsxs(a.div,{exit:{opacity:0,y:-20,scale:.9},children:[e.jsx(a.div,{initial:{y:-30,opacity:0,scale:.5},animate:{y:0,opacity:1,scale:1},transition:{delay:.2,...v},children:e.jsx(M,{className:`w-16 h-16 mx-auto mb-4 ${t?"text-amber-400":"text-muted-foreground"}`,style:t?{filter:"drop-shadow(0 0 20px hsl(40 90% 55% / 0.5))"}:{}})}),e.jsx(a.h2,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.4},className:"text-2xl font-black text-foreground mb-2",children:t?"Félicitations !":"Bien joué !"}),e.jsx(a.p,{initial:{opacity:0}
1,animate:{opacity:1},transition:{delay:.6},className:"text-sm text-muted-foreground",children:t?"Tu as gagné ta première partie ! 🎉":"Tu as découvert les bases du jeu !"})]},"result"),x==="rewards"&&e.jsxs(a.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},children:[e.jsxs(a.div,{initial:{scale:0},animate:{scale:1},transition:v,className:"mb-6",children:[e.jsx(M,{className:`w-12 h-12 mx-auto mb-2 ${t?"text-amber-400":"text-muted-foreground"}`,style:t?{filter:"drop-shadow(0 0 15px hsl(40 90% 55% / 0.4))"}:{}}),e.jsx("h2",{className:"text-xl font-black text-foreground",children:t?"Victoire !":"Bien joué !"})]}),e.jsxs("div",{className:"flex justify-center gap-3 mb-6",children:[e.jsxs(a.div,{initial:{x:-40,opacity:0,scale:.5},animate:{x:0,opacity:1,scale:1},transition:{delay:.2,...v},className:"flex items-center gap-2 px-4 py-3 rounded-xl border border-primary/30 bg-primary/10",children:[e.jsx(a.div,{animate:{rotate:[0,10,-10,0]},transition:{duration:2,repeat:1/0,delay:.5},children:e.jsx(le,{className:"w-6 h-6 text-primary"})}),e.jsxs("div",{className:"text-left",children:[e.jsxs(a.p,{className:"text-lg font-black text-primary",initial:{scale:0},animate:{scale:[0,1.3,1]},transition:{delay:.4,duration:.5},children:["+",d.coins]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase",children:"Coins"})]})]}),e.jsxs(a.div,{initial:{x:40,opacity:0,scale:.5},animate:{x:0,opacity:1,scale:1},transition:{delay:.35,...v},className:"flex items-center gap-2 px-4 py-3 rounded-xl border border-accent/30 bg-accent/10",children:[e.jsx(a.div,{animate:{scale:[1,1.2,1]},transition:{duration:1.5,repeat:1/0,delay:.8},children:e.jsx(H,{className:"w-6 h-6 text-accent"})}),e.jsxs("div",{className:"text-left",children:[e.jsxs(a.p,{className:"text-lg font-black text-accent",initial:{scale:0},animate:{scale:[0,1.3,1]},transition:{delay:.55,duration:.5},children:["+",d.xp]}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase",children:"XP"})]})]})]}),g&&e.jsxs(a.div,{initial:{opacity:0,scale:.9,y:10},animate:{opacity:1,scale:1,y:0},transition:{delay:.6,...v},className:"mb-6 p-4 rounded-2xl border border-amber-500/20 bg-amber-500/5 relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-5",style:{backgroundImage:`url(${ie(g.image_url,"thumbnail")})`,backgroundSize:"cover",backgroundPosition:"center",filter:"blur(10px)"}}),e.jsx(a.div,{className:"absolute inset-0",style:{background:"linear-gradient(105deg, transparent 30%, hsl(40 90% 55% / 0.05) 45%, transparent 55%)"},animate:{x:["-100%","200%"]},transition:{duration:3,repeat:1/0,repeatDelay:2}}),e.jsxs("div",{className:"relative flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-16 rounded-lg bg-amber-500/10 border border-amber-500/30 flex items-center justify-center",children:e.jsx(ce,{className:"w-5 h-5 text-amber-500/60"})}),e.jsxs("div",{className:"text-left flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(a.div,{animate:{rotate:[0,15,-15,0],scale:[1,1.2,1]},transition:{duration:3,repeat:1/0},children:e.jsx(te,{className:"w-3.5 h-3.5 text-amber-400 fill-amber-400"})}),e.jsx("span",{className:"text-xs font-bold text-amber-400 uppercase",children:"Légendaire"})]}),e.jsx("p",{className:"text-sm font-semibold text-foreground",children:g.name}),e.jsxs("p",{className:"text-[10px] text-muted-foreground flex items-center gap-1",children:[e.jsx(ae,{className:"w-3 h-3"})," Déblocable en progressant"]})]})]})]}),e.jsxs(a.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.8},className:"flex flex-col gap-3",children:[e.jsx(a.div,{whileHover:{scale:1.02},whileTap:{scale:.97},children:e.jsxs(N,{onClick:y,className:"w-full gap-3 py-5 text-base font-bold bg-gradient-to-r from-primary to-accent hover:from-primary/90 hover:to-accent/90 text-primary-foreground relative overflow-hidden",style:{boxShadow:"0 0 30px hsl(var(--primary) / 0.4)"},children:[e.jsx(a.div,{className:"absolute inset-0",style:{background:"linear-gradient(105deg, transparent 30%, rgba(255,255,255,0.15) 45%, transparent 55%)"},animate:{x:["-100%","200%"]},transition:{duration:2.5,repeat:1/0,repeatDelay:1.5}}),e.jsx(de,{className:"w-5 h-5 relative z-10"}),e.jsx("span",{className:"relative z-10",children:"Créer un compte"})]})}),e.jsxs(N,{onClick:h,variant:"outline",className:"w-full gap-3 py-4 bg-card/50 backdrop-blur border-border/50",children:[e.jsx(ue,{className:"w-4 h-4"})," Rejouer"]}),e.jsx(N,{onClick:u,variant:"ghost",className:"text-muted-foreground hover:text-foreground text-sm",children:"Continuer sans compte"})]})]},"rewards")]})})]})},V="di_onboarding_overlay",he="di-onboarding-overlay-change",F=t=>{typeof window>"u"||(t?localStorage.setItem(V,"true"):localStorage.removeItem(V),document.body.dataset.onboardingOverlay=t?"true":"false",window.dispatchEvent(new CustomEvent(he,{detail:{active:t}})))},Y="di-tutorial-game-complete",W="di_tutorial_result",be=new Set(["welcome","booster_reveal","booster_opened","choice","auto_deck","game_result"]),_e=()=>{const t=new Image;t.src="/cards/assemblee.jpg"};typeof window<"u"&&_e();const K=e.jsx("div",{className:"fixed inset-0 z-[180] overflow-hidden pointer-events-none",style:{background:"hsl(var(--background))"},children:e.jsx("div",{className:"absolute inset-0",style:{background:"radial-gradient(circle at center, hsl(var(--primary) / 0.1), transparent 58%)"}})}),qe=()=>{const t=$(),h=Q(),{shouldStartOnboarding:y,currentStep:u,isReady:o,startOnboarding:x,advanceStep:s,skipOnboarding:d}=ge(),[m,g]=r.useState(null),_=h.pathname.startsWith("/qr"),w=h.pathname==="/play",i=h.pathname.startsWith("/preview/onboarding"),p=typeof window<"u"&&localStorage.getItem("di_onboarding_completed")==="true",l=r.useMemo(()=>!p&&!w&&!i&&(!o||y&&be.has(u)),[u,p,w,i,o,y]),n=r.useCallback(async b=>{localStorage.removeItem(W),g(b),await s("game_result")},[s]);r.useEffect(()=>(F(l),()=>F(!1)),[l]),r.useEffect(()=>{const b=async()=>{const O=localStorage.getItem(W);if(O)try{const I=JSON.parse(O);if(I.completed&&typeof I.won=="boolean"){await n(I.won);return}}catch{O==="completed"&&await n(!1)}},T=O=>{const I=O.detail;typeof I?.won=="boolean"&&n(I.won)};return b(),window.addEventListener(Y,T),()=>{window.removeEventListener(Y,T)}},[n]);const S=r.useCallback(async()=>{await x(),await s("booster_reveal")},[x,s]),j=r.useCallback(async()=>{await s("auto_deck")},[s]),A=r.useCallback(async()=>{await s("signup_prompt"),await d(),t("/auth?onboarding=true&returnTo=collection")},[s,d,t]),C=r.useCallback(async()=>{await s("tutorial_game")},[s]),B=r.useCallback(async()=>{await d(),t("/")},[d,t]),k=r.useCallback(async()=>{await s("signup_prompt"),await d(),t("/auth?onboarding=true")},[s,d,t]),U=r.useCallback(()=>{localStorage.setItem("di_tutorial_game","true"),t("/play"),g(null),s("tutorial_game")},[t,s]),c=r.useCallback(async()=>{await d(),t("/")},[d,t]);return _||w||i?null:o?y?e.jsxs(e.Fragment,{children:[l&&K,e.jsxs(X,{mode:"wait",initial:!1,children:[u==="welcome"&&e.jsx(re,{onReady:S},"welcome"),(u==="booster_reveal"||u==="booster_opened"||u==="choice")&&e.jsx(se,{onChoosePlay:j,onChooseCollection:A,resumeFromStep:u,isAdminPreview:!1},"booster-reveal"),u==="auto_deck"&&e.jsx(Z,{onLaunchGame:C,onSkip:B},"tutorial-launcher"),u==="game_result"&&m!==null&&e.jsx(xe,{won:m,onReplay:U,onCreateAccount:k,onContinue:c},"game-result")]})]}):null:typeof window<"u"&&localStorage.getItem("di_onboarding_completed")==="true"?null:K};export{qe 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.