import{j as i}from"./query-vendor-CZu0EHPe.js";import{r as n}from"./react-vendor-0bvDbF03.js";import{aX as K,b as Z,m as H}from"./index-D1vbIJ-B.js";import{u as U}from"./useIOSAudioContext-DtqQj9l7.js";import{E as Q}from"./ExploreThemesButton-CCh98AuG.js";import{u as q}from"./i18n-vendor-Cl4-lKeC.js";import"./supabase-vendor-CNV44oIa.js";import"./helmet-vendor-NlTFkN97.js";const ee=()=>{const{getContext:b}=U(),f=n.useRef(0);return n.useCallback(()=>{const d=Date.now();if(!(d-f.current<80)){f.current=d;try{const a=b();if(!a)return;const u=a.createOscillator(),s=a.createGain();u.connect(s),s.connect(a.destination),u.type="sine",u.frequency.setValueAtTime(600,a.currentTime),u.frequency.exponentialRampToValueAtTime(300,a.currentTime+.05),s.gain.setValueAtTime(.08,a.currentTime),s.gain.exponentialRampToValueAtTime(.01,a.currentTime+.05),u.start(a.currentTime),u.stop(a.currentTime+.05)}catch{}}},[b])},te=[{id:"magic-wonder",name:"Magic & Wonder",description:"Stories that inspire awe and imagination through magical elements",imageSrc:"https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Magic%20and%20Wonder.webp"},{id:"nature-animals",name:"Nature & Animals",description:"Stories that explore the natural world and creatures",imageSrc:"https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Nature%20and%20Animals.webp"},{id:"adventure-curiosity",name:"Adventure & Curiosity",description:"Exciting journeys of discovery and exploration",imageSrc:"https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Adventure%20and%20Curiosity.webp"},{id:"problem-solution",name:"Problem & Solution",description:"Challenges to overcome through critical thinking",imageSrc:"https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Problem%20and%20Solution.webp"},{id:"friendship-teamwork",name:"Friendship & Teamwork",description:"Stories about bonds and collaborative efforts",imageSrc:"https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Friendship%20and%20Teamwork.webp"},{id:"fun-wit",name:"Fun & Wit",description:"Lighthearted stories with humor and clever situations",imageSrc:"https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Fun%20and%20Wit.webp"},{id:"kindness-empathy",name:"Kindness & Empathy",description:"Stories highlighting compassion and helping others",imageSrc:"https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Kindness%20and%20Empathy.webp"},{id:"fear-courage",name:"Fear & Courage",description:"Facing fears and finding bravery in challenges",imageSrc:"https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Fear%20and%20Courage.webp"},{id:"sadness-loss",name:"Sadness & Loss",description:"Exploring feelings of grief and saying goodbye",imageSrc:"https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Sadness%20and%20Loss.webp"},{id:"anger-frustration",name:"Anger & Frustration",description:"Managing strong emotions constructively",imageSrc:"https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Anger%20and%20Frustration.webp"},{id:"confidence-determination",name:"Confidence & Determination",description:"Perseverance and believing in oneself",imageSrc:"https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Confidence%20and%20Determination.webp"},{id:"jealousy-appreciation",name:"Jealousy & Appreciation",description:"Learning gratitude and valuing what one has",imageSrc:"https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Jealousy%20and%20Appreciation.webp"}],M=100,ne=({resistance:b=50,onActiveChange:f,onInteraction:y,themes:d=te,autoRotate:a=!1,autoRotateSpeed:u=.08})=>{const s=n.useRef(null),R=n.useRef([]),k=ee(),{unlockOn:m}=U();n.useEffect(()=>m(s.current,["pointerdown","touchstart","mouseenter"]),[m]);const p=n.useRef(180),c=n.useRef(0),N=n.useRef(!1),C=n.useRef(0),_=n.useRef(),E=n.useRef(!1),v=n.useRef(null),w=n.useRef(a),S=n.useRef(!1),T=n.useRef([]),[j,z]=n.useState(180),[re,G]=n.useState(!1),[F,Y]=n.useState(0),O=n.useRef(0);n.useEffect(()=>{const e=()=>{const r=window.innerWidth<768;G(r),z(r?200:300)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),n.useEffect(()=>{w.current=a},[a]);const I=n.useCallback(()=>{const e=p.current;s.current&&(s.current.style.transform=`translate(-50%, 0) rotate(${e}deg)`,s.current.style.left="100%"),R.current.forEach((r,t)=>{if(!r)return;const o=t*30;let l=e%360;l<0&&(l+=360);let g=(o+l)%360,h=Math.abs(g-180);h>180&&(h=360-h);const D=1.6,x=.5,A=Math.max(0,1-h/80),P=x+(D-x)*A,V=100-Math.round(h);r.style.transform=`rotate(${o}deg) translate(${j}px) rotate(-${o}deg) rotate(${-e}deg) scale(${P})`,r.style.zIndex=V.toString(),r.style.opacity=A>.2?"1":"0.3"})},[j]);n.useEffect(()=>{I()},[I]);const W=(e,r)=>{if(!s.current)return 0;const t=s.current.getBoundingClientRect(),o=t.left+t.width/2,l=t.top+t.height/2;return Math.atan2(r-l,e-o)*(180/Math.PI)},X=e=>{e.preventDefault(),N.current=!0,S.current=!0,w.current=!1,C.current=W(e.clientX,e.clientY),c.current=0,T.current=[],e.target.setPointerCapture(e.pointerId),v.current&&clearTimeout(v.current),E.current||(E.current=!0,y?.())},B=e=>{if(!N.current)return;const r=W(e.clientX,e.clientY);let t=r-C.current;t>180&&(t-=360),t<-180&&(t+=360),C.current=r,p.current+=t;const o=Date.now();T.current.push({t:o,v:t}),T.current=T.current.filter(l=>o-l.t<100),I(),c.current=t},$=e=>{N.current=!1,e.target.releasePointerCapture(e.pointerId);const r=Date.now(),t=T.current.filter(o=>r-o.t<100);if(t.length>0){const o=t.reduce((l,g)=>l+g.v,0)/t.length;c.current=o}else c.current=0;T.current=[],setTimeout(()=>{S.current=!1},500),a&&(v.current=setTimeout(()=>{w.current=!0},1500))},J=(e,r)=>{r.stopPropagation(),S.current=!0;const o=180-e*30,l=p.current,g=o-l,h=Math.round(g/360),x=l+(g-h*360)-l;c.current=x*.1,E.current||(E.current=!0,y?.()),setTimeout(()=>{S.current=!1},500)};n.useEffect(()=>()=>{v.current&&clearTimeout(v.current)},[]);const L=n.useCallback(()=>{if(!N.current){if(w.current&&Math.abs(c.current)<.1&&(c.current=u),Math.abs(c.current)<.12&&!w.current){const x=p.current,A=Math.round(x/30)*30,P=A-x,V=P*.03;c.current+=V,c.current*=.92,Math.abs(c.current)<.001&&Math.abs(P)<.01?(c.current=0,p.current=A):p.current+=c.current}else p.current+=c.current,w.current||(c.current*=.97);I()}let e=p.current%360;e<0&&(e+=360);const r=(180-e+360)%360,t=Math.round(r/30)%12;t!==O.current&&(S.current&&k(),O.current=t,Y(t),f&&f(d[t])),_.current=requestAnimationFrame(L)},[u,f,I,d]);return n.useEffect(()=>(_.current=requestAnimationFrame(L),()=>{_.current&&cancelAnimationFrame(_.current)}),[L]),i.jsxs("div",{className:"relative w-full h-[500px] flex items-center touch-none select-none overflow-x-clip overflow-y-visible",children:[i.jsx("div",{ref:s,className:"relative rounded-full cursor-grab active:cursor-grabbing",style:{width:j*2.5,height:j*2.5,position:"absolute",touchAction:"none",left:"100%",transform:"translate(-50%, 0) rotate(180deg)"},onPointerDown:X,onPointerMove:B,onPointerUp:$,onPointerLeave:$,children:d.map((e,r)=>{const t=F===r;return i.jsx("div",{ref:o=>R.current[r]=o,className:"absolute flex items-center justify-center cursor-pointer",onClick:o=>J(r,o),"data-lumi-interactive":!0,style:{width:M,height:M,left:"50%",top:"50%",marginTop:-M/2,marginLeft:-M/2},children:i.jsx("div",{className:`
flex items-center justify-center rounded-full transition-all duration-300 overflow-hidden
${t?"w-24 h-24":"w-20 h-20 hover:opacity-80"}
`,style:t?{boxShadow:"0 0 30px 8px rgba(251, 191, 36, 0.6), 0 0 60px 15px rgba(251, 191, 36, 0.3)"}:void 0,children:e.imageSrc?i.jsx("img",{src:e.imageSrc,alt:e.name,className:"w-full h-full object-cover"}):i.jsx(K,{placeholder:e.name.substring(0,3).toUpperCase(),description:`Theme: ${e.name}`,size:"full",aspectRatio:"square",className:"w-full h-full text-[8px]"})})},e.id)})}),i.jsxs("div",{className:"absolute right-4 md:right-6 lg:right-8 top-1/2 -translate-y-1/2 max-w-[120px] md:max-w-[160px] z-10 text-right",children:[i.jsx("h3",{className:"text-base md:text-2xl font-normal text-foreground mb-2 transition-all duration-300",children:d[F]?.name}),i.jsx("p",{className:"font-noto text-xs md:text-[16px] text-muted-foreground transition-all duration-300",children:d[F]?.description})]})]})},me=({onInteractionComplete:b=()=>{},hasCarouselInteracted:f=!1})=>{Z();const{t:y}=q("landing"),{t:d}=q("themes"),a=["magic-wonder","nature-animals","adventure-curiosity","problem-solution","friendship-teamwork","fun-wit","kindness-empathy","fear-courage","sadness-loss","anger-frustration","confidence-determination","jealousy-appreciation"],u=["https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Magic%20and%20Wonder.webp","https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Nature%20and%20Animals.webp","https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Adventure%20and%20Curiosity.webp","https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Problem%20and%20Solution.webp","https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Friendship%20and%20Teamwork.webp","https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Fun%20and%20Wit.webp","https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Kindness%20and%20Empathy.webp","https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Fear%20and%20Courage.webp","https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Sadness%20and%20Loss.webp","https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Anger%20and%20Frustration.webp","https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Confidence%20and%20Determination.webp","https://cdn.storysparkle.org/ui_elements/Theme%20Icons/Jealousy%20and%20Appreciation.webp"],s=d("themes",{returnObjects:!0}),R=a.map((k,m)=>({id:k,name:Array.isArray(s)&&s[m]?s[m].name:k,description:Array.isArray(s)&&s[m]?s[m].description:"",imageSrc:u[m]}));return i.jsx("section",{className:"relative min-h-0 py-8 lg:py-16 ipad-portrait:!py-8 lg:min-h-screen flex items-center justify-center",style:{background:"#F0FDF4"},children:i.jsx("div",{className:"container mx-auto max-w-6xl px-6",children:i.jsxs("div",{className:"flex flex-col-reverse lg:flex-row ipad-portrait:!flex-col-reverse items-center gap-4 lg:gap-12",children:[i.jsxs(H.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.6},className:"max-w-lg text-center lg:text-left ipad-portrait:!text-center flex flex-col",children:[i.jsx("h2",{className:"section-header text-[22px] lg:text-[32px] mb-2 lg:mb-4",children:y("themes.heading")}),i.jsx("p",{className:"section-subtext text-sm lg:text-xl",children:y("themes.subtext")}),i.jsx("div",{className:"mt-4 lg:mt-10",children:i.jsx(Q,{})})]}),i.jsx(H.div,{initial:{x:50,opacity:0},whileInView:{x:0,opacity:1},viewport:{once:!0},transition:{delay:.5},className:"flex-1 w-full",children:i.jsx(ne,{onInteraction:b,autoRotate:!0,autoRotateSpeed:.08,themes:R})})]})})})};export{me as default};
//# sourceMappingURL=ThemesSection-Bgh4-QhR.js.map