1import{j as e,u as E,r as p,c as G}from"./vendor-react-BoyrKzsG.js";import{U as Y,u as A,n as _,f as q,a as D,L as J,D as K,C as X,T as L,R as Q,e as Z}from"./index-CKCEYSTE.js";import{m as P}from"./matchingService-DZ7Irfqh.js";import{M as ee,Y as se,o as F,bc as te,ao as W,A as R,r as $,aB as ie,q as oe}from"./vendor-ui-Cy9YOY35.js";import{C as ne}from"./CelebrationOverlay-DBNBYkLQ.js";import{m as ae}from"./moodService-1cF3xmA4.js";import{g as re,a as ce}from"./communityService-CSdb11lr.js";import{C as M}from"./vendor-firebase-DbFCdLkQ.js";const le=({like:s,onAccept:t,onReject:o,onViewProfile:c,isProcessing:h=!1})=>{var S,d,l,g,x,y,b,a;const{userProfile:r}=s;return e.jsxs("div",{className:"likes-card",onClick:()=>c(s.userId),role:"button",tabIndex:0,"aria-label":`View ${r.displayName}'s profile`,onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&c(s.userId)},children:[e.jsx("div",{className:"likes-card-header",children:e.jsx("div",{className:"likes-avatar-container",children:e.jsx(Y,{src:r.photoURL,name:r.displayName,size:"lg",showPhoto:((d=(S=r.settings)==null?void 0:S.privacySettings)==null?void 0:d.showProfilePhoto)!==!1})})}),e.jsxs("div",{className:"likes-card-info",children:[e.jsx("h4",{className:"likes-name",children:r.displayName}),e.jsxs("div",{className:"likes-meta",children:[((l=r.profile)==null?void 0:l.age)>0&&e.jsx("span",{className:"likes-age",children:r.profile.age}),((x=(g=r.profile)==null?void 0:g.location)==null?void 0:x.city)&&e.jsxs("span",{className:"likes-location",children:[e.jsx(ee,{size:14})," ",r.profile.location.city]})]}),((y=r.profile)==null?void 0:y.struggles)&&r.profile.struggles.length>0&&e.jsxs("p",{className:"likes-struggle",children:["Going through ",e.jsx("strong",{children:r.profile.struggles.join(", ")})]}),((b=r.profile)==null?void 0:b.interests)&&r.profile.interests.length>0&&e.jsx("div",{className:"likes-interests",children:r.profile.interests.slice(0,2).map((i,n)=>e.jsx("span",{className:"likes-interest-tag",children:i},n))}),s.message&&e.jsx("div",{className:"likes-message",onClick:i=>i.stopPropagation(),children:e.jsx("p",{className:"message-quote",children:s.message})}),((a=r.profile)==null?void 0:a.bio)&&e.jsx("p",{className:"likes-bio",children:r.profile.bio})]}),e.jsxs("div",{className:"likes-card-actions",children:[e.jsx("button",{className:"likes-reject-btn",onClick:i=>{i.stopPropagation(),o(s.userId)},disabled:h,"aria-label":"Reject",children:e.jsx(se,{size:20})}),e.jsx("button",{className:"likes-accept-btn",onClick:i=>{i.stopPropagation(),t(s.userId)},disabled:h,"aria-label":"Accept",children:e.jsx(F,{size:20,fill:"currentColor"})})]})]})},de=()=>{const{user:s}=A(),t=E(),[o,c]=p.useState(()=>{const a=localStorage.getItem(`cache_incoming_likes_${s==null?void 0:s.uid}`);return a?JSON.parse(a):[]}),[h,r]=p.useState(!0),[S,d]=p.useState(null),[l,g]=p.useState(null);p.useEffect(()=>{if(!s)return;let a;console.log(`[LikesSection] Subscribing to likes for ${s.uid}`),a=P.subscribeToIncomingLikes(s.uid,n=>{console.log(`[LikesSection] Received ${n.length} likes`),c(n),r(!1),localStorage.setItem(`cache_incoming_likes_${s.uid}`,JSON.stringify(n))});const i=setTimeout(async()=>{if(h){console.warn(`[LikesSection] Subscription timeout â forcing manual fetch for ${s.uid}`);try{const n=await P.getIncomingLikes(s.uid);c(n),localStorage.setItem(`cache_incoming_likes_${s.uid}`,JSON.stringify(n))}catch(n){console.error("[LikesSection] Manual fallback fetch failed:",n)}r(!1)}},5e3);return()=>{clearTimeout(i),a&&a.then(n=>n())}},[s]);const x=async a=>{var n,m,f,v,k,I;if(!s)return;const i=o.find(j=>j.userId===a);c(j=>{const u=j.filter(N=>N.userId!==a);return localStorage.setItem(`cache_incoming_likes_${s.uid}`,JSON.stringify(u)),u}),d(a),i!=null&&i.userProfile&&g({name:i.userProfile.displayName,photo:i.userProfile.photoURL||((m=(n=i.userProfile.profile)==null?void 0:n.photos)==null?void 0:m[0]),showPhoto:((v=(f=i.userProfile.settings)==null?void 0:f.privacySettings)==null?void 0:v.showProfilePhoto)!==!1});try{console.log(`[LikesSection] Accepting like from ${a}`);const j=await P.acceptLike(s.uid,a);console.log("[LikesSection] Accept result:",j),j.success?j.isMatch&&console.log(`[LikesSection] MATCH CONFIRMED! ID: ${j.matchId}`):(g(null),(k=j.reason)!=null&&k.toLowerCase().includes("limit")||(I=j.reason)!=null&&I.toLowerCase().includes("upgrade")?q.getState().show({feature:"Unlimited Bonds",description:j.reason,source:"likes_section"}):_.error(j.reason||"Could not accept like"),i&&c(u=>{const N=[i,...u];return localStorage.setItem(`cache_incoming_likes_${s.uid}`,JSON.stringify(N)),N}))}catch(j){console.error("[LikesSection] Error accepting like:",j),g(null),_.error("Failed to accept connection"),i&&c(u=>{const N=[i,...u];return localStorage.setItem(`cache_incoming_likes_${s.uid}`,JSON.stringify(N)),N})}finally{d(null)}},y=async a=>{if(!s)return;const i=o.find(n=>n.userId===a);c(n=>
1{const m=n.filter(f=>f.userId!==a);return localStorage.setItem(`cache_incoming_likes_${s.uid}`,JSON.stringify(m)),m});try{const n=await P.rejectLike(s.uid,a);n.success||(_.error(n.reason||"Failed to skip"),i&&c(m=>{const f=[i,...m];return localStorage.setItem(`cache_incoming_likes_${s.uid}`,JSON.stringify(f)),f}))}catch(n){console.error("[LikesSection] Error rejecting:",n),i&&c(m=>{const f=[i,...m];return localStorage.setItem(`cache_incoming_likes_${s.uid}`,JSON.stringify(f)),f})}},b=a=>{t(`/matching/${a}`,{state:{from:"/dashboard"}})};return h&&o.length===0||o.length===0&&!l?null:e.jsxs("section",{className:"likes-section",style:{position:"relative",minHeight:l?"300px":"auto"},children:[o.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"likes-header",children:[e.jsx("div",{className:"likes-icon-container",children:e.jsx(F,{size:20})}),e.jsx("h2",{children:"Resonates with you"}),e.jsx("span",{className:"likes-count",children:o.length})]}),e.jsx("div",{className:"likes-grid",children:o.map(a=>e.jsx(le,{like:a,onAccept:x,onReject:y,onViewProfile:b,isProcessing:S===a.userId},a.userId))})]}),l&&e.jsx(ne,{userName:l.name,userPhoto:l.photo,showPhoto:l.showPhoto,onClose:()=>{g(null)}})]})},ue=({isOpen:s,onClose:t,tier:o})=>{const{lumoVariant:c}=D();if(!s)return null;const h=o.charAt(0).toUpperCase()+o.slice(1);return e.jsx("div",{className:"celebration-modal-overlay",onClick:t,children:e.jsxs("div",{className:"celebration-modal-content",onClick:r=>r.stopPropagation(),children:[e.jsx("div",{className:"celebration-confetti",children:e.jsx(te,{className:"confetti-icon",size:40})}),e.jsx("div",{className:"lumo-highlight",children:e.jsx(J,{pose:"happy",size:"large",variant:c,className:"lumo-pop"})}),e.jsxs("div",{className:"celebration-text",children:[e.jsxs("h2",{children:["Welcome to ",h,"!"]}),e.jsxs("p",{children:[c==="coffee"?"Lumo":"Blobby"," is so excited! Your Pro features are now active."]})]}),e.jsx("div",{className:"tier-badge-container",children:e.jsxs("div",{className:`tier-badge ${o.toLowerCase()}`,children:[e.jsx(W,{size:16}),e.jsxs("span",{children:[h," Active"]})]})}),e.jsx("button",{className:"celebration-close-btn",onClick:t,children:"Let's Explore!"})]})})},me=({userStruggles:s=[],userId:t})=>{const o=E(),[c,h]=p.useState([]),[r,S]=p.useState(!0),[d,l]=p.useState(!1);p.useEffect(()=>{(async()=>{try{const[y,b]=await Promise.all([re({limit:50}),t?ce(t):Promise.resolve([])]);if(b.length>0)h(b.map(a=>({...a,isJoined:!0}))),l(!1);else{const a=y.filter(i=>s.some(n=>{var m,f;return((f=(m=i.category)==null?void 0:m.struggleCategory)==null?void 0:f.toLowerCase())===n.toLowerCase()||i.name.toLowerCase().includes(n.toLowerCase())||i.id.toLowerCase().includes(n.toLowerCase())})).map(i=>({...i,isJoined:!1}));h(a.slice(0,8)),l(!0)}}catch(y){console.error("[CommunityCarousel] Error loading communities:",y)}finally{S(!1)}})()},[s,t]);const g=x=>{const y=K.find(b=>b.id===x);if(y){const b=X[y.icon];return b?e.jsx(b,{size:24,strokeWidth:1.5}):e.jsx($,{size:24})}return e.jsx($,{size:24,strokeWidth:1.5})};return r||c.length===0?null:e.jsxs("section",{className:"community-carousel-section",children:[e.jsxs("div",{className:"carousel-header",children:[e.jsx("h2",{children:"Communities for you"}),e.jsxs("button",{className:"see-all-btn",onClick:()=>o("/communities/"),children:["See All ",e.jsx(R,{size:14})]})]}),e.jsx("div",{className:"carousel-container",children:c.map(x=>e.jsxs("div",{className:`community-mini-card ${x.isJoined?"is-joined":""}`,onClick:()=>o(`/communities/${x.id}`),children:[x.isJoined&&e.jsx("div",{className:"joined-badge",children:e.jsx(W,{size:12,strokeWidth:3})}),e.jsx("div",{className:"card-icon-wrapper",children:g(x.id)}),e.jsx("div",{className:"card-info",children:e.jsx("h3",{children:x.name})})]},x.id))})]})},T=7001,O=19,z={compatibleCount:0,incomingLikeCount:0,topPeers:[],headlineText:"",subtext:"",hasPulse:!1},he=s=>s&&s.trim().split(/\s+/)[0]||"A peer",pe=()=>{const s=new Date().getHours();return s>=17&&s<=23},ge={EVENING_PULSE_HOUR:O,async getEveningPulseSummary(s){var t,o;try{const h=await(await Q.getUserRepository()).getById(s),[r,S]=await Promise.all([P.getPotentialMatches(s,h==null?void 0:h.searchPreferences),P.getIncomingLikes(s).catch(()=>[])]),d=(r==null?void 0:r.matches)??[],l=d.length,g=(S==null?void 0:S.length)??0;if(l===0&&g===0)return z;const x=((t=h==null?void 0:h.profile)==null?void 0:t.struggles)??[],y=d.slice().sort((m,f)=>(f.compatibilityScore??f.matchScore??0)-(m.compatibilityScore??m.matchScore??0)).slice(0,3).map(m=>{var v;const f=((v=m.profile)==null?void 0:v.struggles)??[];return{id:m.id,displayName:he(m.displayName),photoURL:m.photoURL,matchScore:Math.round(m.compatibilityScore??m.matchScore??0),commonStruggles:f.filter(k=>x.includes(k))}}),b=(o=y.find(m=>m.commonStruggles.length>0))==null?void 0:o.commonStruggles[0],a=pe();let i,n;return g>0?(i=g===1?"1 person wants to connect with you":`${g} people want to connect with you`,n=a?"They reached out first. Tonight is a good time to reply.":"They reached out first â say hello when you are ready."):(i=a?`${l} compatible ${l===1?"peer":"peers"} to connect with tonight`:`${l} compatible ${l===1?"member":"members"} to discover`,n=b?`Peers navigating ${b} are open to talking.`:"Connect with peers who understand what you are working through."),{compatibleCount:l,incomingLikeCount:g,to
1pPeers:y,headlineText:i,subtext:n,hasPulse:!0}}catch(c){return console.error("[EveningPulse] Error building summary:",c),z}},async scheduleEveningPulse(s=!0){if(M.isNativePlatform())try{if(await L.cancel({notifications:[{id:T}]}),!s||(await L.checkPermissions()).display!=="granted"&&(await L.requestPermissions()).display!=="granted")return;await L.schedule({notifications:[{id:T,title:"Your evening Compatibility Pulse",body:"See who is around to connect with tonight.",schedule:{on:{hour:O,minute:30},repeats:!0,allowWhileIdle:!0},sound:"default",extra:{url:"/matching"}}]})}catch(t){console.error("[EveningPulse] Error scheduling:",t)}},async cancelEveningPulse(){if(M.isNativePlatform())try{await L.cancel({notifications:[{id:T}]})}catch(s){console.error("[EveningPulse] Error cancelling:",s)}}},fe=({onPulseStatus:s})=>{const{user:t}=A(),o=E(),[c,h]=p.useState(null),[r,S]=p.useState({});return p.useEffect(()=>{if(!t)return;let d=!1;return ge.getEveningPulseSummary(t.uid).then(l=>{d||(h(l),s==null||s(!!(l!=null&&l.hasPulse)))}).catch(()=>{d||(h(null),s==null||s(!1))}),()=>{d=!0}},[t==null?void 0:t.uid]),c!=null&&c.hasPulse?e.jsxs("section",{className:"evening-pulse-card",children:[e.jsxs("div",{className:"pulse-card-head",children:[e.jsx("span",{className:"pulse-icon","aria-hidden":"true",children:e.jsx(ie,{size:16})}),e.jsxs("div",{children:[e.jsx("h3",{children:c.headlineText}),e.jsx("p",{children:c.subtext})]})]}),c.topPeers.length>0&&e.jsx("ul",{className:"pulse-peer-list",children:c.topPeers.map(d=>{const l=!!d.photoURL&&!r[d.id];return e.jsxs("li",{className:"pulse-peer",children:[e.jsx("div",{className:"pulse-peer-avatar",children:l?e.jsx("img",{src:d.photoURL,alt:d.displayName,loading:"lazy",onError:()=>{S(g=>({...g,[d.id]:!0}))}}):e.jsx("span",{"aria-hidden":"true",children:d.displayName.charAt(0).toUpperCase()})}),e.jsxs("div",{className:"pulse-peer-info",children:[e.jsx("span",{className:"pulse-peer-name",children:d.displayName}),d.commonStruggles.length>0&&e.jsxs("span",{className:"pulse-peer-shared",children:["Also navigating ",d.commonStruggles[0]]})]}),d.matchScore>0&&e.jsxs("span",{className:"pulse-peer-score",children:[d.matchScore,"%"]})]},d.id)})}),e.jsxs("button",{className:"pulse-say-hi",onClick:()=>o("/matching"),children:[e.jsx("span",{children:"Say hi"}),e.jsx(R,{size:16})]})]}):null},U=["Guided breathing & grounding exercises","3â6 min audio meditations","Progressive muscle relaxation","Empathetic AI that remembers your story","EMDR-inspired butterfly hug technique","Guided journaling prompts","Self-compassion & mindfulness practices","24/7 emotional support â always available","Voice input & text-to-speech responses","Crisis support when you need it most"],Ce=()=>{var I,j;const s=E(),{user:t,userProfile:o}=A(),{lumoVariant:c}=D(),[h,r]=G(),[S,d]=p.useState(0),[l,g]=p.useState(!0);p.useEffect(()=>{const u=setInterval(()=>{g(!1),setTimeout(()=>{d(N=>(N+1)%U.length),g(!0)},280)},3e3);return()=>clearInterval(u)},[]),p.useEffect(()=>{window.scrollTo(0,0),document.documentElement.classList.remove("lumo-html-locked"),document.body.classList.remove("lumo-body-locked"),document.body.style.overflow="";const u=document.getElementById("root");u&&(u.scrollTop=0,u.style.overflow="")},[]);const[x,y]=p.useState(!0),[b,a]=p.useState(()=>{const u=localStorage.getItem(`cache_mood_entries_${t==null?void 0:t.uid}`);return u?JSON.parse(u):[]}),[i,n]=p.useState(null),[m,f]=p.useState(!1),v=Z.getTrialDaysRemaining(o==null?void 0:o.subscription),k=((I=o==null?void 0:o.subscription)==null?void 0:I.status)==="trialing"&&v!==null;return p.useEffect(()=>{var C,w;if(!t||!o||t.isAnonymous)return;const u=o.hasCompletedOnboarding||o.displayName&&((C=o.profile)==null?void 0:C.age)&&((w=o.profile)==null?void 0:w.gender),N=sessionStorage.getItem("bp_onboarding_just_finished")==="true";N&&u&&sessionStorage.removeItem("bp_onboarding_just_finished"),!N&&(u||(console.log("[DASHBOARD] Profile incomplete, redirecting to setup..."),s("/profile-setup",{replace:!0})))},[t,o,s]),p.useEffect(()=>{const u=h.get("upgraded");u&&(u==="premium"||u==="pro")&&(console.log("[DASHBOARD] Upgrade detected for tier:",u),n(u),r(N=>{const C=new URLSearchParams(N);return C.delete("upgraded"),C},{replace:!0}))},[h,r]),p.useEffect(()=>{if(!(t!=null&&t.uid))return;let u;return(async()=>{u=await ae.subscribeToMoodEntries(t.uid,w=>{a(w),localStorage.setItem(`cache_mood_entries_${t.uid}`,JSON.stringify(w));const B=new Date().toISOString().split("T")[0],H=w.some(V=>V.checkInDate===B);y(H)},30)})(),()=>{u&&u()}},[t==null?void 0:t.uid]),e.jsxs("div",{className:"modern-dashboard",children:[e.jsxs("header",{className:"dashboard-greeting",children:[e.jsx("h1",{children:t!=null&&t.dis
1playName?`Hello, ${t.displayName.split(" ")[0]}`:"Welcome back"}),e.jsx("p",{children:"Find your balance in the community today."})]}),k&&e.jsxs("div",{className:"trial-active-banner",onClick:()=>s("/subscription/plans"),style:{background:"linear-gradient(135deg, rgba(212, 136, 6, 0.15), rgba(185, 85, 49, 0.15))",border:"1px solid rgba(212, 136, 6, 0.4)",borderRadius:"16px",padding:"12px 18px",marginBottom:"16px",display:"flex",alignItems:"center",justifyContent:"space-between",cursor:"pointer"},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"0.85rem",fontWeight:700,color:"var(--text-primary)"},children:e.jsxs("span",{children:["â ",e.jsx("strong",{children:"Pro Trial Active"})," ⢠",v," Day",v===1?"":"s"," Remaining"]})}),e.jsx("span",{style:{fontSize:"0.75rem",fontWeight:700,color:"var(--color-primary-700)",textDecoration:"underline"},children:"Manage Plan â"})]}),e.jsxs("section",{className:"lumo-navigator-cta",onClick:()=>s("/lumo/navigator"),style:{background:"linear-gradient(135deg, #8b5e3c 0%, #3d2b1f 100%)",borderRadius:"24px",padding:"24px",color:"white",marginBottom:"20px",cursor:"pointer",display:"flex",alignItems:"center",gap:"20px",boxShadow:"0 10px 25px rgba(61, 43, 31, 0.2)",position:"relative",overflow:"hidden"},children:[e.jsxs("div",{style:{position:"relative",zIndex:2},children:[e.jsx("h2",{style:{fontSize:"1rem",fontWeight:800,marginBottom:"4px",whiteSpace:"nowrap"},children:"Lumo Guide - AI Wellbeing Companion"}),e.jsxs("p",{className:"lumo-feature-ticker",style:{fontSize:"0.85rem",marginBottom:"12px",maxWidth:"260px",height:"2.6em",overflow:"hidden",opacity:l?.9:0,transform:l?"translateY(0)":"translateY(6px)",transition:"opacity 0.28s ease, transform 0.28s ease"},children:["⦠",U[S]]}),e.jsx("span",{style:{background:"rgba(255,255,255,0.2)",padding:"6px 14px",borderRadius:"20px",fontSize:"0.75rem",fontWeight:600,backdropFilter:"blur(5px)",display:"inline-block",marginTop:"4px"},children:"Get Help Now"})]}),e.jsx("div",{style:{position:"absolute",right:"-10px",bottom:"-20px",opacity:.8},children:e.jsx(J,{size:"medium",pose:"happy",variant:c})})]}),e.jsx(de,{}),e.jsx(fe,{onPulseStatus:f}),!m&&e.jsxs("section",{className:"primary-cta-card",children:[e.jsxs("div",{className:"cta-content",children:[e.jsx("h2",{children:"Find Someone Who Gets It"}),e.jsx("p",{children:"Connect with kind souls who share similar life journeys."})]}),e.jsx("button",{className:"cta-button",onClick:()=>s("/matching/"),"aria-label":"Match Now",children:e.jsx(R,{size:22})})]}),e.jsx(me,{userStruggles:(j=o==null?void 0:o.profile)==null?void 0:j.struggles,userId:t==null?void 0:t.uid}),!x&&e.jsx("button",{className:"mood-fab",onClick:()=>s("/mood/checkin/"),"aria-label":"Check in your mood",children:e.jsx(oe,{size:32})}),e.jsx(ue,{isOpen:!!i,onClose:()=>n(null),tier:i||""})]})};export{Ce 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.