1import{j as e,a as ge}from"./vendor-query-DFKzjVri.js";import{r as n,u as fe}from"./vendor-react-B9UTwVUJ.js";import{L as B}from"./Layout-U3hfl5tA.js";import{S as H}from"./SEO-DL9ijUL0.js";import{s as C,B as q}from"./index-BmRjENVC.js";import{P as pe}from"./progress-Sr1UYujC.js";import{toast as T}from"./index-CqtmjIGR.js";import{a as he}from"./utils-DwDCYpck.js";import{u as xe}from"./useProfileManager-Caeai6EV.js";import{A as ve,b as be,c as je,d as ke,e as we,f as ye,g as Ne}from"./alert-dialog-DsTGn1RY.js";import{g as $,f as Ye,i as Se,a as W,b as F,c as J,d as Q,e as V,h as Me,j as De,k as Ie,l as Ee}from"./yuki-DODgXMWw.js";import{f as Le,a as Pe}from"./fr-FC4MUEWM.js";import"./use-toast-tfTEdvO_.js";import"./sheet-CR4W5BFg.js";import"./vendor-ui-5lK0Gku8.js";import"./dialog-DtmeHtV9.js";import"./createLucideIcon-DcuJWPyU.js";import"./separator-DO-uaT3r.js";import"./engagementMilestones-JMZ1KSvC.js";import"./crown-Ulhw-YL6.js";import"./settings-k-fEU8RX.js";import"./vendor-supabase-IraqMp5m.js";const _e=["ð","ð¦´","ð£"],qe=({open:s,onOpenChange:t,foodItems:r,onFeed:o})=>{const i=r.filter(a=>_e.includes(a.emoji)),p=i.some(a=>a.count>0);return e.jsx(ve,{open:s,onOpenChange:t,children:e.jsxs(be,{className:"max-w-md",children:[e.jsxs(je,{children:[e.jsx(ke,{className:"text-center text-xl",children:"ð± Donner à manger à Yuki"}),e.jsx(we,{className:"text-center",children:p?"Choisis une nourriture pour Yuki !":"Tu n'as pas de nourriture pour Yuki. Continue à lire des histoires pour en gagner !"})]}),p&&e.jsx("div",{className:"flex flex-col gap-3 my-4",children:i.map(a=>e.jsxs("button",{onClick:()=>a.count>0&&o(a.emoji),disabled:a.count===0,className:`flex items-center justify-between p-4 rounded-lg border-2 transition-all ${a.count>0?"border-primary/30 hover:border-primary hover:bg-primary/5 curs
1or-pointer":"border-border opacity-50 cursor-not-allowed"}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-4xl",children:a.emoji}),e.jsx("span",{className:"font-medium",children:a.item_name})]}),e.jsxs("span",{className:`text-lg font-bold ${a.count>0?"text-primary":"text-muted-foreground"}`,children:["x",a.count]})]},a.emoji))}),e.jsx(ye,{children:e.jsx(Ne,{children:"Fermer"})})]})})},Te=["La neige tombe⦠Yuki écoute le silence. âï¸ð±","Un flocon spécial brille pour toi aujourd'hui. âï¸â¨","Le monde est blanc⦠parfait pour une aventure. ð¤"],Fe=["Yuki cligne des yeux : le soleil brille pour toi. ðð±","Le ciel est grand aujourd'hui⦠comme tes rêves. âï¸â¨","Le monde sourit⦠et Yuki aussi. ðð¾"],Ce=()=>{const s=new Date,t=s.getMonth(),r=s.getDate();if(t===11&&r===25)return"christmas";if(t===0&&r===1)return"newyear";if(t===9&&r===31)return"halloween";if(t===1&&r===14)return"valentine";if(t===0&&r===6)return"epiphany";if(t===10&&r===1)return"allsaints";const o=s.getFullYear(),i=Ue(o);return t===i.getMonth()&&r===i.getDate()?"easter":t===10||t===11||t===0||t===1?"winter":t>=2&&t<=4?"spring":t>=5&&t<=7?"sunny":"autumn"},Ue=s=>{const t=s%19,r=Math.floor(s/100),o=s%100,i=Math.floor(r/4),p=r%4,a=Math.floor((r+8)/25),y=Math.floor((r-a+1)/3),m=(19*t+r-i-y+15)%30,f=Math.floor(o/4),b=o%4,l=(32+2*p+2*f-m-b)%7,N=Math.floor((t+11*m+22*l)/451),D=Math.floor((m+l-7*N+114)/31)-1,Y=(m+l-7*N+114)%31+1;return new Date(s,D,Y)},Ae=()=>ge({queryKey:["daily-phrases"],queryFn:async()=>{const{data:s,error:t}=await C.from("daily_phrases").select("*").eq("is_active",!0).order("created_at",{ascending:!0});if(t)throw t;return s||[]},staleTime:1e3*60*60}),ze=()=>{const{data:s}=Ae();return n.useMemo(()=>{const t=new Date,r=Math.floor((t.getTime()-new Date(t.getFullYear(),0,0).getTime())/864e5),o=Ce();let i=[];if(s&&s.length>0){const m=s.filter(f=>f.season===o);if(m.length>0)i=m.map(f=>f.phrase);else{const f=new Date().getMonth()>=10||new Date().getMonth()<=2?"winter":"sunny",b=s.filter(l=>l.season===f);i=b.length>0?b.map(l=>l.phrase):s.map(l=>l.phrase)}}else i=new Date().getMonth()>=10||new Date().getMonth()<=2?Te:Fe;const p=r%Math.max(i.length,1),a=Le(t,"EEEE d MMMM yyyy",{locale:Pe});return{dateStr:a.charAt(0).toUpperCase()+a.slice(1),phrase:i[p]||i[0]||""}},[s])},Re=({className:s=""})=>{const{phrase:t}=ze();return e.jsx("span",{className:`text-foreground/80 italic font-medium ${s}`,children:t})},Oe={1:"ð¤ Yuki découvre le monde à tes côtés.",2:"ð Yuki te fait confiance⦠sa magie s'éveille doucement.",3:"⨠Yuki rayonne de magie et t'accompagne avec assurance.",4:"ð Yuki est devenu un véritable compagnon magique. Ensemble, rien ne vous arrête."},Be={1:"Yuki bébé",2:"Yuki grandit",3:"Yuki confiant",4:"Yuki magique"},G=["Yuki dort paisiblement⦠les aventures rêvent aussi. ðð±","Chut⦠Yuki se repose sous les étoiles. â¨","Le monde est calme, Yuki veille en dormant.","La magie se repose pour mieux briller demain. ð","Yuki fait de beaux rêves d'aventure.","Yuki dort. Bonne nuit. ð","Chut⦠tout est calme. ð¤","Les rêves commencent ici. â¨","La nuit protège les héros. ð","à demain, aventurier. ð¾","Sous la lune, Yuki rêve de chemins lumineux. ðâ¨","Même endormi, Yuki n'est jamais loin.","Les étoiles gardent les histoires jusqu'au matin. â","La nuit ferme le livre⦠pour mieux l'ouvrir demain. ðð","Le silence prépare la prochaine aventure."],K=()=>{const s=new Date,t=s.getHours(),r=s.getMinutes(),o=t*60+r;return o>=1230||o<420},X=()=>G[Math.floor(Math.random()*G.length)],gt=()=>{const s=fe();xe();const[t,r]=n.useState(!0),[o,i]=n.useState(null),[p,a]=n.useState([]),[y,m]=n.useState(!1),[f,b]=n.useState(null),[l,N]=n.useState($()),[D,Y]=n.useState(!1),[x,U]=n.useState(!1),[A,I]=n.useState(!1),[Z,z]=n.useState(!1),[ee,R]=n.useState(!1),[h,te]=n.useState(K()),[se,re]=n.useState(X()),[ae,E]=n.useState(!1),v=he(),L=ae;n.useEffect(()=>{ne()},[v]),n.useEffect(()=>{const c=setInterval(()=>{N($());const u=K();te(u),u&&re(X())},6e4),g=setInterval(()=>{!x&&!L&&!h&&(Y(!0),setTimeout(()=>Y(!1),150))},3e3+Math.random()*3e3);return()=>{clearInterval(c),clearInterval(g)}},[x,L,h]),n.useEffect(()=>{if((o?.level||1)===4){const g=setInterval(()=>{R(u=>!u)},1200);return()=>clearInterval(g)}R(!1)},[o?.level]),n.useEffect(()=>
1{[F(),J(),Q(),V(),W()].forEach(g=>{const u=new Image;u.src=g})},[]);const ne=async()=>{if(!v){T.error("ð Inscris-toi pour rencontrer Yuki ! ð±â¨",{id:"yuki-auth",duration:5e3}),s("/auth",{replace:!0});return}r(!0),await O(),r(!1)},O=async()=>{if(v)try{let c=await Ye(v);c||(c=await Se(v)),i(c);const{data:g}=await C.from("child_profiles").select("earned_rewards").eq("id",v).single(),u=g?.earned_rewards||[],{data:P}=await C.from("reward_catalog").select("emoji, item_name").eq("category","food"),M=(P||[]).map(w=>({emoji:w.emoji,item_name:w.item_name,count:u.filter(_=>_===w.emoji).length}));a(M)}catch{}},j=n.useRef(null),oe=async c=>{if(!v)return;m(!1),j.current&&(window.clearTimeout(j.current),j.current=null),U(!0),z(!0),I(!0);const g=Me(v,c);await new Promise(P=>{let M=0;const w=10,_=setInterval(()=>{M++,I(de=>!de),M>=w&&(clearInterval(_),P())},250)}),U(!1),I(!1),z(!1),E(!0),j.current=window.setTimeout(()=>E(!1),6e4);const u=await g;u.success?(b(u.message),u.levelUp&&T.success(u.message,{duration:5e3}),O(),setTimeout(()=>b(null),4e3)):(E(!1),j.current&&(window.clearTimeout(j.current),j.current=null),T.error(u.message))},d=o?.level||1,S=o?.food_given_count||0,ie=Ee(d),le=d>=4?100:(S-(d===1?0:d===2?10:20))/(ie-(d===1?0:d===2?10:20))*100,ce=De(l),ue=x&&A?Q():x&&!A?F():L?V():D?J():F(),me=Ie(d),k=p.reduce((c,g)=>c+g.count,0);return t?e.jsxs(B,{children:[e.jsx(H,{title:"Yuki - Mon compagnon magique",description:"Découvre Yuki, ton compagnon chat magique qui évolue avec toi !"}),e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-bounce text-6xl mb-4",children:"ð±"}),e.jsx("p",{className:"text-lg",children:"Yuki arrive..."})]})})]}):e.jsxs(B,{children:[e.jsx(H,{title:"Yuki - Mon compagnon magique",description:"Découvre Yuki, ton compagnon chat magique qui évolue avec toi !"}),e.jsxs("div",{className:"container mx-auto px-4 py-8 max-w-2xl",children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsx("h1",{className:"text-3xl font-bold text-foreground mb-2",children:"ð± Yuki"}),e.jsx("p",{className:"text-muted-foreground",children:"Mon compagnon magique"}),e.jsx("p",{className:"text-sm text-muted-foreground/70 mt-1",children:new Date().toLocaleDateString("fr-FR",{weekday:"long",day:"numeric",month:"long",year:"numeric"})})]}),e.jsxs("div",{className:"relative w-full max-w-md mx-auto mb-4",children:[e.jsxs("div",{className:"aspect-square rounded-2xl overflow-hidden border-4 border-primary/20 shadow-xl relative",children:[e.jsx("img",{src:ce,alt:`Fond ${l==="day"?"jour":l==="evening"?"soir":"nuit"}`,className:"absolute inset-0 w-full h-full object-cover"}),!h&&e.jsxs(e.Fragment,{children:[e.jsx("img",{src:ue,alt:`Yuki niveau ${d}`,className:"absolute inset-0 w-full h-full object-contain transition-opacity duration-75",onError:c=>{c.target.src="https://iwgcbgtzfpzeqvgjjlyw.supabase.co/storage/v1/object/public/images-generales/yuki/yuki_level1.png"}}),d>=2&&e.jsx("img",{src:d===4?ee?"https://iwgcbgtzfpzeqvgjjlyw.supabase.co/storage/v1/object/public/images-generales/yuki/yuki_queue_level2.png":"https://iwgcbgtzfpzeqvgjjlyw.supabase.co/storage/v1/object/public/images-generales/yuki/yuki_queue_level3.png":me,alt:"Queue magique",className:"absolute inset-0 w-full h-full object-contain transition-opacity duration-500"}),Z&&e.jsx("img",{src:W(),alt:"",className:"absolute inset-0 w-full h-full object-contain pointer-events-none opacity-90"})]})]}),e.jsx("div",{className:"absolute top-3 right-3 bg-background/90 backdrop-blur-sm rounded-full px-3 py-1 text-sm font-medium",children:h?"ð¤ Dodo":l==="day"?"âï¸ Jour":l==="evening"?"ð
Soir":"ð Nuit"})]}),e.jsxs("div",{className:"max-w-md mx-auto mb-6",children:[e.jsxs(q,{onClick:()=>m(!0),size:"lg",className:"w-full text-lg py-6",disabled:k===0||h||x,children:[h?"ð¤ Yuki dort...":x?"ð½ï¸ Miam miam...":"ð½ï¸ Nourrir Yuki",!h&&!x&&k>0&&e.jsxs("span",{className:"ml-2 bg-background/20 px-2 py-0.5 rounded-full text-sm",children:[k," disponible",k>1?"s":""]})]}),h?e.jsx("p",{className:"text-sm text-muted-foreground text-center mt-2",children:"Yuki fait dodo et revient bientôt ! ð¤ð±"}):k===0&&!x&&e.jsx("p",{className:"text-sm text-muted-foreground text-center mt-2",children:"Lis de
1s histoires pour gagner de la nourriture pour Yuki !"})]}),f&&e.jsx("div",{className:"bg-background/70 backdrop-blur-sm border border-border rounded-xl p-4 mb-6 text-center animate-fade-in max-w-md mx-auto shadow-sm",children:e.jsx("p",{className:"text-lg font-medium text-foreground",children:f})}),e.jsx("div",{className:"bg-background/80 backdrop-blur-sm border border-border rounded-xl p-4 mb-6 text-center shadow-sm",children:e.jsx("p",{className:"text-foreground italic font-medium",children:h?se:e.jsx(Re,{})})}),e.jsxs("div",{className:"bg-card border border-border rounded-xl p-6 mb-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-lg font-bold",children:Be[d]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[S," récompense",S>1?"s":""," donnée",S>1?"s":""]})]}),e.jsx(pe,{value:le,className:"h-3 mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground text-center",children:Oe[d]})]}),e.jsxs("div",{className:"flex flex-col gap-3 mt-8 max-w-md mx-auto",children:[e.jsx(q,{onClick:()=>s("/bibliotheque"),size:"lg",className:"w-full",children:"ð Choisir une aventure"}),e.jsx(q,{onClick:()=>s("/mon-univers"),variant:"outline",size:"lg",className:"w-full",children:"ð Retour à Mon Univers"})]}),e.jsx(qe,{open:y,onOpenChange:m,foodItems:p,onFeed:oe})]})]})};export{gt 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.