PageSourceSearch

https://recoverytrauma.lovable.app/assets/dreams-CCTwbGlp.js

js recoverytrauma.lovable.app collected 2026-10-03 03:43:46 UTC 60,685 bytes, 4 lines download raw bytes

1import{c as T,r as E,a as A,d,m as S,j as e,a5 as $,ai as w,C as M,X as K,L as F,by as xe,bM as O,p as W,y as X,s as fe,g as G,Q as ge,S as pe,ds as be}from"./index-70yz1Rcc.js";import{w as ye}from"./with-member-gate-DPareyqN.js";import{r as we}from"./crisis-report-Bg-ZIUfy.js";import{C as je}from"./CrisisDialog-Bts2V_md.js";import{VoiceRecorder as ve}from"./VoiceRecorder-BAuPx0-H.js";import{F as ke}from"./FavoriteButton-BkoFIPi3.js";import{P as Ne}from"./PrivacyNotice-Codn4iGG.js";import{S as ne}from"./SwipeRail-C0CwhzTB.js";import{n as Se}from"./activity-events-BBZvobF2.js";import{J as Ce}from"./JournalGuide-C2O1yvEl.js";import{u as De}from"./use-scroll-top-on-change-CLTq3qRS.js";import{A as Te,h as Ee}from"./AiConsentDialog-Ow56Wv7G.js";import{C as Z}from"./cloud-C4rWTva9.js";import{S as Ae}from"./star-CfazqeZR.js";import{M as _}from"./mic-DYq_VRoK.js";import{T as ee}from"./trash-2-F1VFByHX.js";import{T as Re}from"./trending-up-DRKiJEHE.js";import"./MemberGate-DBZ5l3we.js";import"./onboarding.functions-B8Dgz2sd.js";import"./MemberLockScreen-BZoYLC_c.js";import"./log-in-BzAzj8k5.js";import"./recent-tools-Bwv98Oha.js";import"./membership-refresh-zb1yQH-m.js";import"./crisis-alerts.functions-C67sVQrh.js";import"./square-Ct_vStCV.js";import"./triangle-alert-CehprHlv.js";import"./useFavorite-Db-qOa84.js";import"./favorites-2715qcDU.js";import"./BeforeYouBegin-D6ckjDLa.js";import"./list-checks-DITvW2kS.js";const Le=T({method:"POST"}).middleware([E]).handler(A("c4509ca5bd49069356512029e8af0fa4d2865e2f53888f4917cdc4387fcf83c4")),Fe=T({method:"POST"}).middleware([E]).handler(A("1534b097cccc539cda11ffbab56b1ef7940b7e491506a8ca39d7f7ddbce82998")),We=T({method:"GET"}).middleware([E]).handler(A("bf45d8a5f7aa84f62b4d0ee4a5f65b7aab625339ff404fbef8851afeefba7b8a")),ie=T({method:"POST"}).middleware([E]).handler(A("ca29bfdf2a0741aff230fb889a59334a45ad6c2ca193a489faca7f4caa59f606")),Ie=T({method:"POST"}).middleware([E]).handler(A("19b0f919224adb6fcb7b5742c6f1025ffe26d43c90c6b3c67040e2e30f52c966")),Me=T({method:"GET"}).middleware([E]).handler(A("cecca853a4b23f203b65f9ca7a756e05627059d0acfe47ee7af85a84691d0698")),Oe=["Peaceful","Heavy","Hopeful","Anxious","Curious","Tender"];function te(t,r){const i=t.toLowerCase().replace(/[^a-z\s]/g," ").split(/\s+/).filter(l=>l.length>4).slice(0,5);return{suggestedTitle:r?`${r} dream`:"Dream reflection",tags:{people:[],places:[],emotions:r?[r.toLowerCase()]:[],symbols:i.slice(0,3),themes:[]},summary:"You shared a dream worth sitting with.",emotionAcknowledgement:r?`You noted feeling ${r.toLowerCase()} on waking.`:"You're welcome to notice what feelings, if any, surface as you sit with this.",gentlePossibilities:["Some people find that returning to a dream gently — without rushing to interpret — lets new noticings surface in their own time."],reflectionQuestions:["What feeling stayed with you after waking?","Was there any image, place, or person that felt important?","What might feel supportive to give yourself today?"],closingReminder:"There is no single correct meaning for a dream. Your own experiences and reflections matter most."}}const qe=[{id:"Dream Entry",label:"Dream",emoji:"🌙",hint:"A dream you'd like to remember"},{id:"Nightmare",label:"Nightmare",emoji:"🌫️",hint:"Something difficult or distressing"},{id:"Recurring Dream",label:"Recurring Dream",emoji:"🔄",hint:"A dream or pattern that keeps returning"},{id:"Lucid Dream",label:"Lucid Dream",emoji:"✨",hint:"A dream where you knew you were dreaming"}],Pe=[{emoji:"🌿",label:"Ground after a difficult dream",dest:"Grounding",to:"/grounding"},{emoji:"🌬️",label:"Settle my body",dest:"Breathing",to:"/breathing"},{emoji:"🎧",label:"Listen to something calming",dest:"Sounds",to:"/sounds"},{emoji:"🛏️",label:"Help me return to sleep",dest:"Sleep & Rest",to:"/sleep-dreams"},{emoji:"📚",label:"Understand dreams",dest:"Library → Dreams & Sleep",to:"/library"}],Ye=["What emotions stood out in the dream?","What part of the dream feels most important to you?","Were there any people, places, objects or symbols that stood out?","Does anything in the dream connect with something happening in your life right now?","Did the dream remind you of a past experience, relationship or feeling?","Was there a moment where you felt safe, unsafe, trapped, curious, powerful or helpless?","If this dream had a message for you, what might it be?","Is there anything you want to remember or take away from this dream?"],re={totals:{dreams:0},people:[],places:[],emotions:[],symbols:[],themes:[],insights:[]};function $e(){return O()}function q(){if(!O()?.user?.id)throw new Error("Please sign in again to save your dream.")}const H="rt.dream.composer.draft.v1";function _e(){if(typeof window>"u")return null;try{const t=window.localStorage.getItem(H);if(!t)return null;const r=JSON.parse(t);return{dream:typeof r.dream=="string"?r.dream:"",mood:typeof r.mood=="string"?r.mood:"",title:typeof r.title=="string"?r.title:""}}catch{return null}}function Ge(t){if(!(typeof window>"u"))try{window.localStorage.setItem(H,JSON.stringify(t))}catch{}}function ae(){if(!(typeof window>"u"))try{window.localStorage.removeItem(H)}catch{}}const He=[{title:"Freud",emoji:"📜",body:"Freud viewed dreams as the 'royal road to the unconscious' — wishes, fears and unfinished feelings finding symbolic expression while we sleep.",more:["For Freud, dreams were a doorway into the parts of the mind we don't usually let ourselves see in daylight — desires, conflicts and old hurts that the waking mind quietly sets aside.","He believed every dream had a 'manifest' surface (what we remember) and a 'latent' meaning underneath (what it might be pointing toward). Symbols, he thought, were the mind's gentle disguise for feelings that felt too tender to name directly.","Modern psychology has moved on from many of Freud's specific ideas, yet the deeper inv
1itation still feels relevant: dreams can be a way of meeting feelings we haven't yet had space to feel."]},{title:"Jung",emoji:"🌒",body:"Jung saw dreams as messengers from the deeper self — images, archetypes and inner figures inviting wholeness rather than diagnosis.",more:["Jung believed dreams weren't trying to hide anything from us — they were trying to show us something we hadn't yet recognised in ourselves.","He spoke of archetypes: universal patterns like the Child, the Shadow, the Wise One, the Lover — figures that appear across cultures and centuries because they live in all of us.","A recurring dream, in Jung's view, is rarely a problem to solve. It's often the psyche returning to an image because something in us is still waiting to be welcomed, integrated, or simply witnessed."]},{title:"Modern science",emoji:"🧠",body:"Sleep researchers see dreaming as the brain weaving memory, emotion and meaning — helping us process the day and regulate our nervous system.",more:["During REM sleep, the brain becomes remarkably active. Memory networks, emotional centres and meaning-making regions all light up together, while the parts that normally hold us to strict logic quiet down.","Researchers think this is partly how the brain digests experience: sorting what to keep, softening emotional intensity, and stitching new events into the longer story of who we are.","It's also one reason dreams can feel strange or symbolic. The mind is associating, not narrating — linking a feeling from today with an image from years ago because they share the same emotional texture."]},{title:"Trauma & dreams",emoji:"🤍",body:"After trauma, dreams may carry strong emotion, repetition or vivid imagery. This is the body's way of trying to integrate — not a sign something is wrong with you.",more:["When something has overwhelmed the nervous system, the mind sometimes returns to it in sleep — through fragments, sensations, or dreams that echo the original feeling rather than the original event.","This can look like nightmares, recurring scenes, sudden waking, or dreams that feel heavier than the day they followed. None of this means you are broken. It often means your system is still working on something that hasn't finished moving through.","Gentle witnessing helps more than analysis here. Grounding before sleep, soft light on waking, a few slow breaths, and writing only as much as feels safe — these small acts can let the body know it is no longer alone with what it carries.","If dreams feel destabilising or persistently distressing, working with a trauma-informed therapist can offer support that journaling alone is not meant to replace."]}],se=[{symbol:"Water",emoji:"🌊",reflection:"Water in dreams may sometimes connect with emotions, change, overwhelm, cleansing, or the unknown. For some people, calm water may feel peaceful, while stormy water may feel intense or hard to manage.",themes:["Emotion","Change","Overwhelm","Cleansing","The unknown"],questions:["What did the water feel like in the dream?","Were you safe, overwhelmed, floating, drowning, or watching from a distance?","Does the water remind you of any emotion in your waking life?"],keywords:["ocean","river","sea","rain","flood"]},{symbol:"House",emoji:"🏠",reflection:"A house may sometimes reflect a sense of self, safety, or different parts of your inner world. For some people, familiar rooms feel comforting, while unknown rooms may feel curious or unsettling.",themes:["Self","Safety","Inner world","Belonging"],questions:["How did the house feel — welcoming, unfamiliar, or in-between?","Were there rooms you wanted to explore, or rooms you wanted to avoid?","Does any part of the house echo something in your waking life?"],keywords:["home","room","hallway","kitchen"]},{symbol:"Door",emoji:"🚪",reflection:"Doors may sometimes invite reflection on transitions, choices, or what feels open or closed right now. For some people, an open door feels inviting, while a locked door may feel protective or limiting.",themes:["Transition","Choice","Boundaries","Possibility"],questions:["Was the door open, closed, or somewhere in between?","Did you want to go through it, or stay where you were?","Is there a threshold in your waking life you are gently considering?"],keywords:["gate","entrance","threshold"]},{symbol:"Child",emoji:"🧒",reflection:"A child in a dream may sometimes connect with tenderness, younger parts of yourself, or feelings that long to be held with care. Only take what feels right — your own meaning matters most.",themes:["Tenderness","Inner child","Vulnerability","Care"],questions:["What did the child seem to need or feel?","How did you respond to them in the dream?","Is there a softer part of you asking for gentleness right now?"],keywords:["kid","baby","infant","young"]},{symbol:"Animal",emoji:"🦌",reflection:"Animals in dreams may sometimes carry instinct, protection, or qualities you recognise in yourself. For some people, a calm animal feels reassuring, while a frightened or fierce animal may feel activating.",themes:["Instinct","Protection","Wildness","Companionship"],questions:["How did the animal feel toward you — safe, wary, distant, close?","What quality of this animal stays with you most?","Is there a part of you that moves a little like this animal?"],keywords:["dog","cat","wolf","bird","snake","horse"]},{symbol:"Falling",emoji:"🪂",reflection:"Falling may sometimes reflect feeling unsupported, a loss of control, or a moment of release. For some people, falling feels frightening, while for others it can feel surprisingly like letting go.",themes:["Loss of control","Letting go","Support","Surrender"],questions:["What was the falling like — sudden, slow, endless, gentle?","Was anything holding you, or were you alone?","Where in your waking life might you be holding on very tightly?"]},{symbol:"Being chased",emoji:"👣",reflection:"Being chased may sometimes point to a feeling, memory, or part of yourself that wants attention rather than escape. Only take what feels right, and move at your own pace.",themes:["Avoidance","Fear","Attention","Self-protection"],questions:["What was chasing you, and how close did it feel?","Was there anywhere in the dream that felt safer?","Is there something in your waking life that feels hard to turn toward?"],keywords:["chase","running","pursued"]},{symbol:"Teeth",emoji:"🦷",reflection:"Teeth dreams are very common and may sometimes connect with feelings about voice, change, vulnerability, or how you appear to others. For some people, they reflect a season of transition.",themes:["Voice","Change","Vulnerability","Self-image"],questions:["What was happening with the teeth — falling, breaking, growing?","How did you feel in the dream — embarrassed, calm, afraid, curious?","Is there something you have been wanting to express or release?"],keywords:["tooth","mouth"]},{symbol:"Death",emoji:"🕊️",reflection:"Death in dreams may sometimes symbolise endings, transitions, or a part of life that is changing shape. It does not usually predict literal events. Only take what feels right, and go gently.",themes:["Endings","Transformation","Grief","Letting go"],questions:["Whose ending or change appeared in the dream?","What feelings stayed with you when you woke?","Is something in your life quietly shifting or coming to a close?"],keywords:["dying","funeral","loss"]},{symbol:"Mother",emoji:"🌷",reflection:"A mother figure in a dream may sometimes connect with feelings about care, safety, comfort, or longing. Mother symbols can feel tender for many people, especially around grief or complicated relationships. Move at your own pace.",themes:["Care","Safety","Longing","Comfort"],questions:["How did the mother figure feel — present, distant, warm, absent?","What feeling stayed strongest after the dream?","What kind of care might you be needing right now?"],keywords:["mum","mom","mama"]},{symbol:"Father",emoji:"🌳",reflection:"A father figure may sometimes connect with themes of protection, authority, support, or absence. The
1se dreams can feel layered, especially around complicated relationships. Be gentle with yourself.",themes:["Protection","Authority","Support","Absence"],questions:["How did the father figure feel toward you in the dream?","What did you wish you could say, hear, or feel?","Where in your life might you be longing for steadiness?"],keywords:["dad","papa"]},{symbol:"Light",emoji:"🕯️",reflection:"Light may sometimes appear as a quiet sense of hope, clarity, or an inner knowing returning. For some people, even a small light in a dream can feel meaningful.",themes:["Hope","Clarity","Guidance","Inner knowing"],questions:["Where was the light coming from, and how did it feel?","Did it change anything in the dream when it appeared?","Is there a small light in your waking life asking to be trusted?"],keywords:["candle","sun","lamp"]}];function Je(){const[t,r]=d.useState({kind:"home"});De(t.kind==="home"?"home":t.kind==="compose"?`compose-${t.mode}-${t.category??""}`:`${t.kind}-${t.dream.id}`);const[i,l]=d.useState(!1),[x,f]=d.useState(!1),[u,n]=d.use
1State(null),[s,y]=d.useState(!1),[b,g]=d.useState(null),j=S(We),k=S(Me),c=S(Ie),o=async()=>{try{const a=await j();n(a.dreams),y(!1)}catch{n([]),y(!0)}},h=async()=>{try{const a=await k();g(a.patterns)}catch{g(re)}};return d.useEffect(()=>{let a=!1;return(async()=>{const p=$e();if(!a){if(!p){n([]),y(!1),g(re);return}o(),h()}})(),()=>{a=!0}},[]),e.jsxs("div",{className:"relative min-h-dvh overflow-hidden bg-background",children:[e.jsxs("div",{className:"pointer-events-none absolute inset-0 overflow-hidden",children:[e.jsx("div",{className:"absolute -top-24 -start-20 h-72 w-72 rounded-full bg-[#cfe0f3] opacity-50 blur-3xl"}),e.jsx("div",{className:"absolute top-40 -end-16 h-80 w-80 rounded-full bg-[#e3d5f5] opacity-50 blur-3xl"}),e.jsx("div",{className:"absolute bottom-0 start-1/3 h-64 w-64 rounded-full bg-white opacity-60 blur-3xl dark:bg-white/10 dark:opacity-30"}),e.jsx($,{className:"absolute top-10 end-10 h-10 w-10 text-[#b9c8df] opacity-70 animate-pulse",style:{animationDuration:"5s"}}),e.jsx(Z,{className:"absolute top-28 start-12 h-12 w-12 text-white opacity-70"}),e.jsx(Z,{className:"absolute top-[55%] end-20 h-10 w-10 text-white opacity-60"}),[...Array(14)].map((a,p)=>
1e.jsx(Ae,{className:"absolute text-[#b9a8d9]",style:{top:`${p*53%95}%`,left:`${p*71%95}%`,width:`${6+p%4*3}px`,height:`${6+p%4*3}px`,opacity:.35+p*13%40/100,animation:`pulse ${3+p%4}s ease-in-out ${p*.3}s infinite`},fill:"currentColor"},p))]}),e.jsxs("div",{className:"relative mx-auto max-w-3xl px-4 pt-6 pb-12 md:pt-12",children:[t.kind==="home"&&e.jsxs(e.Fragment,{children:[e.jsxs("header",{className:"mb-6 text-center",children:[e.jsxs("div",{className:"mb-2 inline-flex items-center gap-2 rounded-full border border-gold/30 bg-card/80 px-3 py-1 text-xs text-foreground/80 backdrop-blur",children:[e.jsx($,{className:"h-3.5 w-3.5 text-[var(--gold-deep)]"})," Dream Journal"]}),e.jsx("h1",{className:"font-display text-[1.7rem] leading-tight tracking-tight text-foreground md:text-5xl",children:"A quiet space for your dreams"}),e.jsx("p",{className:"mx-auto mt-2 max-w-xl text-sm leading-relaxed text-foreground/70",children:"Record what you remember. Explore emotions, symbols and recurring themes — at your own pace."}),e.jsxs("div",{className:"mt-5 flex flex-col items-stretch justify-center gap-2.5 sm:flex-row",children:[e.jsx("button",{type:"button",onClick:()=>r({kind:"compose",mode:"write"}),className:"inline-flex min-h-[48px] items-center justify-center gap-2 rounded-full bg-gradient-to-r from-[#7a6ca8] to-[#a88dc4] px-6 text-sm font-medium text-white shadow-md transition hover:opacity-90",children:"+ Record a Dream"}),e.jsxs("button",{type:"button",onClick:()=>r({kind:"compose",mode:"voice"}),className:"inline-flex min-h-[48px] items-center justify-center gap-2 rounded-full border border-gold/40 bg-card/80 px-5 text-sm font-medium text-foreground backdrop-blur transition hover:bg-gold/10",children:[e.jsx(_,{className:"h-4 w-4 text-[var(--gold-deep)]"})," Record by Voice"]})]}),e.jsxs("p",{className:"mt-3 text-xs leading-relaxed text-foreground/60",children:["🔒 Private to you",e.jsx("br",{}),"Your dream journal entries are visible only to you."]})]}),e.jsx(ze,{}),e.jsxs("section",{className:"mb-6",children:[e.jsx("h2",{className:"mb-3 px-1 font-display text-lg text-foreground md:text-xl",children:"🌙 What would you like to record?"}),e.jsx("div",{className:"grid grid-cols-2 gap-2.5 md:gap-3",children:qe.map(a=>e.jsxs("button",{type:"button",onClick:()=>r({kind:"compose",mode:"write",category:a.id}),className:"group flex min-h-[118px] flex-col items-start gap-1.5 rounded-2xl border border-gold/25 bg-card/80 p-3.5 text-start shadow-sm backdrop-blur transition hover:-translate-y-0.5 hover:border-[var(--gold-deep)]/60 hover:bg-card md:p-4",children:[e.jsx("span",{className:"text-2xl md:text-3xl","aria-hidden":!0,children:a.emoji}),e.jsx("span",{className:"font-display text-sm font-medium text-foreground md:text-base",children:a.label}),e.jsx("span",{className:"text-[11px] leading-snug text-foreground/65 md:text-xs",children:a.hint})]},a.id))}),e.jsxs("button",{type:"button",onClick:()=>r({kind:"compose",mode:"voice"}),className:"mt-3 inline-flex min-h-[44px] items-center gap-2 rounded-full border border-gold/40 bg-card px-4 text-sm font-medium text-foreground transition hover:bg-gold/10",children:[e.jsx(_,{className:"h-4 w-4 text-[var(--gold-deep)]"}),"Rather speak than type? — Record by Voice"]})]}),e.jsxs(Be,{className:"mb-6",title:"💛 A gentle note before you begin",children:[e.jsx("p",{className:"text-sm leading-relaxed text-foreground/80",children:"Dreams can stir emotions, memories or sensations. Move at your own pace, pause whenever you need, and take what helps and leave what doesn't."}),e.jsx("div",{className:"mt-3",children:e.jsx(Ce,{journal:"dreams"})}),e.jsx("div",{className:"mt-3",children:e.jsx(Ne,{children:"Your dream journal entries are private and visible only to you."})})]}),e.jsxs("section",{className:"mb-7",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between px-1",children:[e.jsx("h2",{className:"font-display text-lg text-foreground md:text-xl",children:"🌙 Recent dreams"}),u&&u.length>3&&e.jsx("button",{type:"button",onClick:()=>l(a=>
1!a),className:"text-xs font-medium text-foreground/70 hover:text-foreground hover:underline",children:i?"Show less":"View all dreams →"})]}),e.jsx(Ke,{dreams:u,loadFailed:s,onRetry:()=>{n(null),o()},limit:i?void 0:3,carousel:!i,onOpen:a=>r({kind:"dream",dream:a}),onDelete:async a=>{try{await q(),await c({data:{id:a}}),await o(),await h(),w.success("Dream deleted")}catch(p){const I=p instanceof Error?p.message:"";w.error(I||"Couldn't delete dream — please try again.")}}})]}),b&&b.totals.dreams>=3&&e.jsxs("section",{id:"dream-patterns",className:"mb-7 scroll-mt-4",children:[e.jsxs("div",{className:"mb-2 px-1",children:[e.jsx("h2",{className:"font-display text-lg text-foreground md:text-xl",children:"✨ Your Dream Patterns"}),e.jsx("p",{className:"text-xs text-foreground/60 md:text-sm",children:"Gentle observations from the dreams you've recorded."})]}),e.jsx(et,{patterns:b})]}),e.jsx("section",{className:"mb-7",children:e.jsx("div",{className:"rounded-2xl border border-gold/25 bg-card/80 shadow-sm backdrop-blur",children:x?e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-gold/20 px-4 py-3 md:px-5 md:py-3.5",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-lg","aria-hidden":!0,children:"🔮"}),e.jsx("span",{className:"font-display text-base text-foreground md:text-lg",children:"Symbol Explorer"})]}),e.jsxs("button",{type:"button",onClick:()=>f(!1),className:"inline-flex min-h-[40px] items-center gap-1.5 rounded-full border border-gold/30 bg-card/80 px-3 py-1.5 text-xs text-foreground/80 transition hover:bg-card hover:text-foreground","aria-label":"Close Symbol Explorer",children:[e.jsx(K,{className:"h-4 w-4"}),"Close"]})]}),e.jsxs("div",{className:"px-4 py-4 md:px-5 md:py-5",children:[e.jsx("p",{className:"mb-4 text-xs leading-relaxed text-foreground/65 md:text-sm",children:"A quiet companion for when you'd like to sit with a recurring image or symbol from your dreams. You remain the one who decides what it means to you."}),e.jsx(tt,{autoFocusSearch:!0,onSit:a=>r({kind:"compose",mode:"write",category:`Symbol Exploration — ${a}`})}),e.jsx("div",{className:"mt-6 flex justify-center",children:e.jsxs("button",{type:"button",onClick:()=>f(!1),className:"inline-flex min-h-[44px] items-center gap-1.5 rounded-full border border-gold/30 bg-card/80 px-4 py-2 text-sm text-foreground/80 transition hover:bg-card hover:text-foreground",children:[e.jsx(K,{className:"h-4 w-4"}),"Close Symbol Explorer"]})})]})]}):e.jsxs("button",{type:"button",onClick:()=>f(!0),className:"w-full cursor-pointer px-4 py-4 text-start md:px-5",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-lg","aria-hidden":!0,children:"🔮"}),e.jsx("span",{className:"font-display text-base text-foreground md:text-lg",children:"Curious about a symbol?"})]}),e.jsx("span",{className:"mt-1.5 block text-xs leading-relaxed text-foreground/70 md:text-sm",children:"Explore possible psychological, cultural and personal associations — without treating any interpretation as the answer. You decide what a symbol means to you."}),e.jsxs("span",{className:"mt-2.5 inline-flex items-center gap-1 text-xs font-medium text-[var(--gold-deep)]",children:["Explore a symbol ",e.jsx(M,{className:"h-3.5 w-3.5"})]})]})})}),e.jsxs("section",{className:"mb-7",children:[e.jsxs("div",{className:"mb-3 px-1",children:[e.jsx("h2",{className:"font-display text-lg text-foreground md:text-xl",children:"📚 Four ways of looking at dreams"}),e.jsx("p",{className:"text-xs text-foreground/60 md:text-sm",children:"Historical and scientific perspectives — none of them a settled answer. Swipe to explore →"})]}),e.jsx(ne,{label:"Dream perspectives",children:He.map(a=>e.jsx(rt,{lens:a},a.title))})]}),e.jsxs("section",{className:"mb-7",children:[e.jsxs("div",{className:"mb-3 px-1",children:[e.jsx("h2",{className:"font-display text-lg text-foreground md:text-xl",children:"🤍 What would help right now?"}
1),e.jsx("p",{className:"text-xs text-foreground/60 md:text-sm",children:"If a dream has left you unsettled, everything is one tap away."})]}),e.jsx("div",{className:"grid grid-cols-1 gap-2.5 sm:grid-cols-2",children:Pe.map(a=>e.jsxs(F,{to:a.to,className:"flex items-center gap-3 rounded-2xl border border-gold/25 bg-card/80 px-4 py-3 text-start shadow-sm backdrop-blur transition hover:-translate-y-0.5 hover:bg-card",children:[e.jsx("span",{className:"text-xl","aria-hidden":!0,children:a.emoji}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block text-sm font-medium text-foreground",children:a.label}),e.jsx("span",{className:"block text-[11px] text-foreground/60",children:a.dest})]}),e.jsx(M,{className:"h-4 w-4 shrink-0 text-foreground/40"})]},a.label))})]})]}),t.kind==="compose"&&e.jsx(Ve,{mode:t.mode,category:t.category,onCancel:()=>r({kind:"home"}),onSaved:(a,p)=>{r({kind:"reflect",dream:a,analysis:p}),o(),h()}}),t.kind==="reflect"&&e.jsx(Qe,{dream:t.dream,analysis:t.analysis,onDone:()=>{r({kind:"home"}),o()}}),t.kind==="dream"&&e.jsx(Ze,{dream:t.dream,onBack:()=>r({kind:"home"}),onReflectionSaved:a=>{r({kind:"dream",dream:a}),o()}}),e.jsxs("div",{className:"mt-8 rounded-2xl border border-gold/20 bg-card/60 p-3.5 text-xs leading-relaxed text-foreground/65 backdrop-blur",children:[e.jsx("p",{className:"font-medium text-foreground/80",children:"About dream reflections"}),e.jsx("p",{className:"mt-1",children:"Dream reflections are exploratory prompts, not medical advice, diagnosis or therapy. There is no single correct interpretation of a dream, and you remain the expert on your own experience."}),e.jsxs("p",{className:"mt-2",children:[e.jsx(F,{to:"/crisis",className:"font-medium text-[var(--gold-deep)] underline",children:"Crisis resources"})," · ",e.jsx(F,{to:"/library",className:"font-medium text-[var(--gold-deep)] underline",children:"Library → Dreams & Sleep"})," · ",e.jsx(F,{to:"/sleep-dreams",className:"font-medium text-[var(--gold-deep)] underline",children:"Sleep & Rest"})]})]}),e.jsx("div",{className:"mt-4",children:e.jsx(xe,{variant:"journal"})})]})]})}function ze(){const[t,r]=d.useState(!1);return e.jsx("aside",{className:"mb-6 overflow-hidden rounded-2xl border border-[var(--gold-deep)]/35 bg-gradient-to-br from-gold/12 to-cream/40 shadow-sm backdrop-blur",children:e.jsxs("div",{className:"px-4 py-4 md:px-5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-lg","aria-hidden":!0,children:"💛"}),e.jsx("h2",{className:"font-display text-base text-foreground md:text-lg",children:"A note from Jana"})]}),e.jsx("p",{className:"mt-1 text-[11px] uppercase tracking-wide text-foreground/55",children:"A personal reflection — not clinical or therapeutic guidance"}),e.jsxs("blockquote",{className:"mt-2.5 space-y-2 text-sm italic leading-relaxed text-foreground/85",children:[e.jsxs("p",{children:["“Dreams helped me a lot in my own trauma healing. Over time, paying attention to them helped me understand parts of my unconscious mind — emotions, fears and patterns that I wasn't always able to recognise during the day.",!t&&"”"]}),t&&e.jsxs(e.Fragment,{children:[e.jsx("p",{children:"I don't believe every dream needs to be analysed or given a fixed meaning. For me, the value was learning to become curious about what my inner world might be communicating."}),e.jsx("p",{children:"That's why I wanted the Dream Journal to be part of Recovery Trauma™ — as a private space to notice, reflect and discover what your dreams may mean to you.”"})]})]}),e.jsxs("div",{className:"mt-2.5 flex items-center justify-between gap-3",children:[e.jsx("p",{className:"text-xs font-medium text-foreground/70",children:"— Jana, Founder of Recovery Trauma™"}),e.jsx("button",{type:"button",onClick:()=>r(i=>!i),"aria-expanded":t,className:"shrink-0 text-xs font-medium text-[var(--gold-deep)] hover:underline",children:t?"Show less":"Read more"})]})]})})}function Be({title:t,children:r,className:i=""}){const[l,x]=d.useState(!1);return e.jsxs("div",{className:`rounded-2xl border border-gold/25 bg-card/80 shadow-sm backdrop-blur ${i}`,children:[e.jsxs("button",{type:"button",onClick:()=>x(f=>!f),"aria-expanded":l,className:"flex w-full items-center justify-between gap-3 px-4 py-3.5 text-start md:px-5",children:[e.jsx("span",{className:"font-display text-sm text-foreground md:text-base",children:t}
1),e.jsx(M,{className:`h-4 w-4 shrink-0 text-foreground/50 transition-transform ${l?"rotate-90":""}`})]}),l&&e.jsx("div",{className:"border-t border-gold/20 px-4 py-4 md:px-5",children:r})]})}function Ve({mode:t,category:r,onCancel:i,onSaved:l}){const x=S(Le),f=S(Fe),[u,n]=d.useState(""),[s,y]=d.useState(""),[b,g]=d.useState(r?`${r} — `:""),[j,k]=d.useState(!1),[c,o]=d.useState(null),[h,a]=d.useState(!1),[p,I]=d.useState(t==="voice"),[J,z]=d.useState(null),[de,B]=d.useState(!1),[le,P]=d.useState(!1),R=d.useRef(null),ce=()=>Ee()?Promise.resolve(!0):new Promise(m=>{R.current=m,P(!0)});d.useEffect(()=>{const m=_e();m&&(m.dream&&(n(m.dream),B(!0)),m.mood&&y(m.mood),m.title&&g(m.title))},[]),d.useEffect(()=>{if(!u.trim()&&!b.trim()&&!s)return;const m=window.setTimeout(()=>Ge({dream:u,mood:s,title:b}),400);return()=>window.clearTimeout(m)},[u,s,b]),d.useEffect(()=>{let m=!0;z(!!O());const{data:C}=fe.auth.onAuthStateChange((D,v)=>{m&&z(!!v)});return()=>{m=!1,C.subscription.unsubscribe()}},[]);async function V(m){if(m?.preventDefault?.(),j)return;if(u.trim().length<10){o("Add a few more words about your dream so we can save it.");return}we({text:u,source:"dream"}).then(D=>{D.detected&&a(!0)}),be(u)&&a(!0),o(null),k(!0);const C=window.setTimeout(()=>{k(!1),o("Saving is taking longer than expected. Your words are kept safely on this device, so nothing is lost — please try again in a moment.")},3e4);try{if(!(J===!0||!!O())){const N=te(u.trim(),s||void 0),Y=b.trim()||N.suggestedTitle;l({id:`guest-${Date.now()}`,title:Y,body:u.trim(),mood:s||null,dreamed_at:new Date().toISOString(),reflection:[],tags:N.tags,created_at:new Date().toISOString()},N);return}const v=(N,Y,ue)=>Promise.race([N,new Promise((st,he)=>window.setTimeout(()=>he(new Error(`${ue} timeout`)),Y))]);let L=te(u.trim(),s||void 0);try{if(!await ce())throw new Error("ai-consent-declined");L=(await v(x({data:{dream:u.trim(),mood:s||void 0}}),15e3,"Analyze")).analysis}catch(N){console.warn("[dreams] AI reflection unavailable, using local fallback",N)}const Q=b.trim()||L.suggestedTitle;await q();const U=await v(f({data:{title:Q,body:u.trim(),mood:s||void 0,tags:L.tags}}),15e3,"Save"),me={id:U.id,title:Q,body:u.trim(),mood:s||null,dreamed_at:new Date().toISOString(),reflection:[],tags:L.tags,created_at:new Date().toISOString()};ae(),w.success(U.duplicate?"Dream already saved":"Dream saved"),Se("dream"),l(me,L)}catch(D){const v=D instanceof Error?D.message:"";/unauthor/i.test(v)||/no authorization/i.test(v)?(o("Sign in to save your dream and generate a reflection. Your words are kept safely on this device until you do — nothing is lost."),w.error("Sign in to save your dream",{description:v||void 0})):/timeout/i.test(v)?(o("Saving is taking longer than expected. Your words are kept safely on this device — please try again in a moment."),w.error("Save timed out — your dream is kept, please try again.",{description:v||void 0})):(o(`${v||"Something went wrong."} Your words are kept safely on this device — please try again.`),w.error(v||"Couldn't save dream — please try again.",{description:v?"Server response above. Try again in a moment.":void 0}))}finally{window.clearTimeout(C),k(!1)}}return e.jsxs("div",{children:[e.jsxs("button",{onClick:i,className:"mb-4 inline-flex items-center gap-1.5 text-sm text-[#5a5775] hover:text-[#2c2a4a] dark:text-muted-foreground dark:hover:text-foreground",children:[e.jsx(G,{className:"h-4 w-4"})," Back"]}),e.jsxs("form",{onSubmit:V,className:"rounded-2xl border border-white/70 bg-white/70 p-6 shadow-sm backdrop-blur-md dark:border-border dark:bg-card",children:[J===!1&&e.jsx("div",{className:"mb-4 rounded-xl border border-[#b9a8d9]/60 bg-[#f3edfb] px-4 py-3 text-sm text-[#2c2a4a] dark:border-border dark:bg-card dark:text-foreground",children:e.jsx("span",{children:"Guest testing is on. You can try the reflection flow now; sign in only when you want to save dreams privately."})}),de&&e.jsxs("div",{className:"mb-4 flex items-start justify-between gap-3 rounded-xl border border-[#b9a8d9]/60 bg-white/80 px-4 py-3 text-sm text-[#2c2a4a] dark:border-border dark:bg-background dark:text-foreground",children:[e.jsx("span",{children:"We kept what you were writing last time, so nothing was lost. Carry on whenever you're ready."}),e.jsx("button",{type:"button",onClick:()=>{n(""),y(""),g(r?`${r} — `:""),ae(),B(!1)},className:"shrink-0 rounded-full border border-[#b9a8d9]/60 px-3 py-1 text-xs font-medium text-[#5a4b7a] transition hover:bg-[#f3edfb] dark:border-border dark:text-muted-foreground dark:hover:bg-accent dark:hover:text-accent-foreground",children:"Start fresh"})]}),e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm font-semibold text-[#2c2a4a] dark:text-foreground",children:[e.jsx($,{className:"h-4 w-4 text-[#7a6ca8]"})," Your dream"]}),e.jsxs("button",{type:"button",onClick:()=>I(!0),className:"inline-flex min-h-10 sm:min-h-0 items-center gap-1.5 rounded-full border border-[#b9a8d9]/60 bg-white/80 px-3 py-1 text-xs font-medium text-[#5a4b7a] transition hover:bg-[#f3edfb] dark:border-border dark:bg-background dark:text-muted-foreground dark:hover:bg-accent dark:hover:text-accent-foreground",children:[e.jsx(_,{className:"h-3.5 w-3.5"})," Record"]})]}),e.jsx("textarea",{value:u,onChange:m=>
1n(m.target.value),rows:7,placeholder:"I was walking through an old house I'd never seen before…",className:"w-full resize-y rounded-xl border border-[#dcd6ea] bg-white/80 p-3 text-sm text-[#2c2a4a] placeholder:text-[#777189] focus:outline-none focus:ring-2 focus:ring-[#b9a8d9] dark:border-border dark:bg-background dark:text-foreground dark:placeholder:text-muted-foreground dark:focus:ring-gold",maxLength:8e3}),e.jsxs("div",{className:"mt-4",children:[e.jsx("label",{className:"mb-1 block text-xs font-medium text-[#5a4b7a] dark:text-muted-foreground",children:"Title (optional)"}),e.jsx("input",{value:b,onChange:m=>g(m.target.value),placeholder:"We'll suggest one if you leave it empty",className:"w-full rounded-xl border border-[#dcd6ea] bg-white/80 p-2.5 text-sm text-[#2c2a4a] placeholder:text-[#777189] focus:outline-none focus:ring-2 focus:ring-[#b9a8d9] dark:border-border dark:bg-background dark:text-foreground dark:placeholder:text-muted-foreground dark:focus:ring-gold",maxLength:80})]}),e.jsxs("div",{className:"mt-5",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2 text-sm font-semibold text-[#2c2a4a] dark:text-foreground",children:[e.jsx(ge,{className:"h-4 w-4 text-[#a88dc4]"})," Mood on waking"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Oe.map(m=>e.jsx("button",{type:"button",onClick:()=>y(s===m?"":m),className:["rounded-full border px-3 py-1.5 text-xs font-medium transition-all",s===m?"border-transparent bg-[#7a6ca8] text-white shadow":"border-[#dcd6ea] bg-white/70 text-[#5a5775] hover:text-[#2c2a4a] dark:border-border dark:bg-background dark:text-muted-foreground dark:hover:text-foreground"].join(" "),children:m},m))})]}),c&&e.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-between gap-2 rounded-lg bg-destructive/10 px-3 py-2 text-sm text-destructive",children:[e.jsx("span",{children:c}),/sign in/i.test(c)&&e.jsx(F,{to:"/login",className:"inline-flex shrink-0 items-center gap-1 rounded-full bg-[#7a6ca8] px-3 py-1 text-xs font-semibold text-white hover:opacity-90",children:"Sign in"})]}),e.jsx("div",{className:"mt-6 flex items-center justify-end",children:e.jsx("button",{type:"button",disabled:j,onClick:m=>{j||(m.preventDefault(),typeof document<"u"&&document.activeElement instanceof HTMLElement&&document.activeElement.blur(),V(m))},className:"relative z-20 inline-flex min-h-[48px] touch-manipulation items-center gap-2 rounded-full bg-gradient-to-r from-[#7a6ca8] to-[#a88dc4] px-6 py-3 text-sm font-medium text-white shadow-md transition hover:opacity-90 disabled:opacity-60 sm:min-h-0 sm:py-2.5",children:j?e.jsxs(e.Fragment,{children:[e.jsx(W,{className:"h-4 w-4 animate-spin"})," Saving…"]}):e.jsxs(e.Fragment,{children:[e.jsx(pe,{className:"h-4 w-4"})," Save dream & reflect"]})})})]}),h&&e.jsx(je,{footerNote:"Your dream is being saved.",onClose:()=>a(!1)}),e.jsx(Te,{open:le,onAgree:()=>{P(!1),R.current?.(!0),R.current=null},onDecline:()=>{P(!1),R.current?.(!1),R.current=null}}),e.jsx(ve,{open:p,onClose:()=>I(!1),onTranscript:m=>{n(C=>C.trim()?C.trim()+`
2
3`+m:m)},title:"Record your dream",description:"Speak what you remember — even fragments. You can edit before saving.",accent:"lavender"})]})}function Qe({dream:t,analysis:r,onDone:i}){const l=S(ie),x=d.useMemo(()=>r.reflectionQuestions.length>0?r.reflectionQuestions:Ye,[r.reflectionQuestions]),[f,u]=d.useState(()=>x.map(()=>"")),[n,s]=d.useState(0),[y,b]=d.useState(!1),[g,j]=d.useState(!1),k=n>=x.length;async function c(){if(!g){j(!0);try{const h=x.map((a,p)=>({question:a,answer:f[p]?.trim()??""})).filter(a=>a.answer.length>0);h.length>0&&!t.id.startsWith("guest-")?(w.loading("Saving reflection…",{id:"dream-reflect-save"}),await q(),await l({data:{id:t.id,reflection:h}}),w.success("Reflection saved",{id:"dream-reflect-save"})):h.length===0&&w("Skipped — no reflection added."),i()}catch(h){const a=h instanceof Error?h.message:"";w.error(a||"Couldn't save reflection — please try again.",{id:"dream-reflect-save",description:a?"Exact server response shown above.":void 0,duration:8e3})}finally{j(!1)}}}const o=x[n];return e.jsxs("div",{children:[e.jsxs("button",{onClick:i,className:"mb-4 inline-flex items-center gap-1.5 text-sm text-foreground
3/60 hover:text-foreground",children:[e.jsx(G,{className:"h-4 w-4"})," Skip reflection"]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("h2",{className:"font-display text-xl text-foreground",children:"🤍 Your reflection"}),e.jsx("p",{className:"mt-1 text-sm text-foreground/70",children:"Gentle, optional questions. Answer what you'd like and skip the rest."})]}),!k&&o?e.jsxs("div",{className:"rounded-2xl border border-gold/25 bg-card/80 p-5 shadow-sm backdrop-blur",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[e.jsxs("span",{className:"text-[11px] uppercase tracking-wide text-foreground/50",children:["Question ",n+1," of ",x.length]}),e.jsx(ke,{storageKey:"rt:fav-dream-prompts",id:o,label:o,sub:"Dream prompt",to:"/dreams",size:"sm"})]}),e.jsx("div",{className:"mb-3 h-1 w-full overflow-hidden rounded-full bg-gold/15",children:e.jsx("div",{className:"h-full rounded-full bg-[var(--gold-deep)] transition-all",style:{width:`${(n+1)/x.length*100}%`}})}),e.jsx("label",{className:"block font-display text-base text-foreground",children:o}),e.jsx("textarea",{rows:4,value:f[n]??"",onChange:h=>{const a=[...f];a[n]=h.target.value,u(a)},className:"mt-3 w-full resize-y rounded-xl border border-gold/25 bg-background/70 p-3 text-sm text-foreground placeholder:text-foreground/40 focus:outline-none focus:ring-2 focus:ring-gold/40",maxLength:2e3,placeholder:"A few words is enough…"}),e.jsxs("div",{className:"mt-4 flex items-center justify-between gap-3",children:[e.jsx("button",{type:"button",onClick:()=>s(h=>Math.max(0,h-1)),disabled:n===0,className:"text-sm text-foreground/60 disabled:opacity-40",children:"Back"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>s(h=>h+1),className:"text-sm text-foreground/60 hover:text-foreground",children:"Skip"}),e.jsx("button",{type:"button",onClick:()=>s(h=>h+1),className:"min-h-[44px] rounded-full bg-[var(--gold-deep)] px-5 text-sm font-medium text-background",children:n===x.length-1?"Finish":"Next"})]})]}),e.jsx("button",{type:"button",onClick:()=>s(x.length),className:"mt-3 text-xs text-foreground/50 hover:underline",children:"Finish without answering the rest"})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-2xl border border-gold/25 bg-card/80 p-5 shadow-sm backdrop-blur",children:[e.jsx("h3",{className:"font-display text-base text-foreground",children:"Thank you for reflecting"}),e.jsx("p",{className:"mt-1.5 text-sm leading-relaxed text-foreground/75",children:"Your words are private to you. Save them to keep them with this dream."}),e.jsxs("div",{className:"mt-4 flex flex-col-reverse gap-3 sm:flex-row sm:justify-end",children:[e.jsx("button",{type:"button",onClick:()=>s(0),className:"rounded-full border border-gold/30 px-5 py-2.5 text-sm text-foreground/70",children:"Review answers"}),e.jsx("button",{type:"button",onClick:h=>{g||(h.preventDefault(),typeof document<"u"&&document.activeElement instanceof HTMLElement&&document.activeElement.blur(),c())},disabled:g,className:"inline-flex min-h-[48px] touch-manipulation items-center justify-center gap-2 rounded-full bg-[var(--gold-deep)] px-6 text-sm font-medium text-background disabled:opacity-60",children:g?e.jsxs(e.Fragment,{children:[e.jsx(W,{className:"h-4 w-4 animate-spin"})," Saving…"]}):"Save reflection"})]})]}),e.jsxs("div",{className:"rounded-2xl border border-gold/25 bg-gold/5 p-5 backdrop-blur",children:[e.jsx("h3",{className:"font-display text-base text-foreground",children:"✨ Reflect on this dream"}),e.jsx("p",{className:"mt-1.5 text-sm leading-relaxed text-foreground/75",children:"Optional. A few exploratory prompts — never a meaning or an answer."}),y?e.jsxs("div",{className:"mt-3 space-y-2.5",children:[e.jsx("p",{className:"text-sm leading-relaxed text-foreground/80",children:r.summary}),e.jsx("p",{className:"text-sm leading-relaxed text-foreground/70",children:r.emotionAcknowledgement}),r.gentlePossibilities.length>0&&e.jsx("ul",{className:"space-y-1.5 text-sm leading-relaxed text-foreground
3/80",children:r.gentlePossibilities.map((h,a)=>e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"mt-2 inline-block h-1 w-1 rounded-full bg-[var(--gold-deep)]"}),e.jsxs("span",{children:["One possibility you might explore: ",h]})]},a))}),e.jsx("p",{className:"text-xs italic text-foreground/55",children:"Take what resonates. Skip what doesn't. There's no right answer."})]}):e.jsx("button",{type:"button",onClick:()=>b(!0),className:"mt-3 rounded-full border border-gold/35 px-5 py-2.5 text-sm font-medium text-[var(--gold-deep)]",children:"Show gentle reflections"})]}),e.jsx("p",{className:"rounded-2xl border border-gold/20 bg-card/70 p-4 text-center text-xs leading-relaxed text-foreground/65",children:r.closingReminder})]})]})}function Ue(t){const r=`${t.title??""}`.toLowerCase();return r.includes("nightmare")?{emoji:"🌫️",label:"Nightmare"}:r.includes("recurring")?{emoji:"🔄",label:"Recurring Dream"}:r.includes("lucid")?{emoji:"✨",label:"Lucid Dream"}:{emoji:"🌙",label:"Dream"}}function oe(t){const r=new Date(t).getTime(),i=Date.now()-r,l=1440*60*1e3;return i<l?"Today":i<2*l?"Yesterday":i<7*l?`${Math.floor(i/l)} days ago`:i<30*l?`${Math.floor(i/(7*l))} weeks ago`:new Date(t).toLocaleDateString()}function Ke({dreams:t,loadFailed:r,onRetry:i,limit:l,carousel:x=!1,onOpen:f,onDelete:u}){if(t===null)return e.jsxs("div",{className:"rounded-2xl border border-white/70 bg-white/60 p-5 text-center text-sm text-[#5a5775] backdrop-blur-md dark:border-border dark:bg-card dark:text-muted-foreground",children:[e.jsx(W,{className:"mx-auto mb-2 h-5 w-5 animate-spin text-[#7a6ca8]"}),"Loading your dreams…"]});if(r)return e.jsxs("div",{className:"rounded-2xl border border-white/70 bg-white/60 p-5 text-center text-sm text-[#5a5775] backdrop-blur-md dark:border-border dark:bg-card dark:text-muted-foreground",children:[e.jsx(X,{className:"mx-auto mb-2 h-6 w-6 text-[#7a6ca8]"}),"We couldn’t load your dreams just now. Nothing has been lost — they are safely stored.",i&&e.jsx("button",{type:"button",onClick:i,className:"mt-3 block w-full rounded-full border border-gold/40 bg-card px-4 py-2 text-sm font-medium text-foreground transition hover:bg-gold/10",children:"Try again"})]});if(t.length===0)return e.jsxs("div",{className:"rounded-2xl border border-white/70 bg-white/60 p-5 text-center text-sm text-[#5a5775] backdrop-blur-md dark:border-border dark:bg-card dark:text-muted-foreground",children:[e.jsx(X,{className:"mx-auto mb-2 h-6 w-6 text-[#7a6ca8]"}),"Your dreams will appear here once you record your first one."]});const n=l?t.slice(0,l):t;return x?e.jsx(ne,{label:"Recent dreams",children:n.map(s=>{const y=Ue(s),b=[...s.tags.themes,...s.tags.symbols].slice(0,2);return e.jsxs("article",{className:"flex w-[80%] shrink-0 snap-start flex-col rounded-2xl border border-gold/25 bg-card/80 p-4 shadow-sm backdrop-blur sm:w-[52%] md:w-[40%]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-sm font-medium text-foreground",children:[e.jsx("span",{"aria-hidden":!0,children:y.emoji})," ",y.label]}),e.jsx("button",{onClick:()=>{confirm("Delete this dream? This can't be undone.")&&u(s.id)},"aria-label":"Delete dream",className:"rounded-full p-1.5 text-foreground/35 transition hover:bg-destructive/10 hover:text-destructive",children:e.jsx(ee,{className:"h-3.5 w-3.5"})})]}),e.jsx("p",{className:"mt-0.5 text-[11px] text-foreground/55",children:oe(s.created_at)}),e.jsx("p",{className:"mt-2 line-clamp-2 font-display text-sm text-foreground",children:s.title?.trim()||"Untitled dream"}),s.mood&&e.jsxs("p",{className:"mt-1.5 text-xs text-foreground/70",children:["Feeling: ",s.mood]}),b.length>0&&e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:b.map(g=>e.jsx("span",{className:"rounded-full border border-gold/25 bg-gold/10 px-2 py-0.5 text-[11px] capitalize text-foreground/75",children:g},g))}),e.jsx("button",{type:"button",onClick:()=>f(s),className:"mt-3 inline-flex items-center gap-1 self-start text-xs font-medium text-[var(--gold-deep)] hover:underline",children:"Open dream →"})]},s.id)})}):e.jsx("ul",{className:"divide-y divide-white/60 overflow-hidden rounded-2xl border border-white/70 bg-white/70 shadow-sm backdrop-blur-md dark:divide-border dark:border-border dark:bg-card",children:n.map(s=>e.jsxs("li",{className:"group relative flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>f(s),className:"flex flex-1 items-center gap-3 px-3 py-2.5 text-start transition hover:bg-white/60 dark:hover:bg-accent md:px-4 md:py-3",children:[e.jsx("span",{className:"text-xl","aria-hidden":!0,
3children:"🌙"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate font-display text-sm text-[#2c2a4a] dark:text-foreground md:text-base",children:s.title?.trim()||"Untitled dream"}),e.jsxs("span",{className:"block truncate text-[11px] text-[#68657d] dark:text-muted-foreground md:text-xs",children:[oe(s.created_at),s.mood?` · ${s.mood}`:""]})]}),e.jsx(M,{className:"h-4 w-4 shrink-0 text-[#9c98b3]"})]}),e.jsx("button",{onClick:()=>{confirm("Delete this dream? This can't be undone.")&&u(s.id)},"aria-label":"Delete dream",className:"me-2 rounded-full p-1.5 text-[#9c98b3] opacity-0 transition hover:bg-destructive/10 hover:text-destructive group-hover:opacity-100",children:e.jsx(ee,{className:"h-3.5 w-3.5"})})]},s.id))})}const Xe=["What emotions stood out?","Did anything feel familiar?","What part of the dream stays with you?","What feels important about it right now?"];function Ze({dream:t,onBack:r,onReflectionSaved:i}){const l=S(ie),x=d.useMemo(()=>{const c=t.tags;return[...c.symbols.map(o=>({kind:"symbol",label:o})),...c.emotions.map(o=>({kind:"emotion",label:o})),...c.places.map(o=>({kind:"place",label:o})),...c.people.map(o=>({kind:"person",label:o})),...c.themes.map(o=>({kind:"theme",label:o}))]},[t.tags]),f=t.reflection.map(c=>c.question),u=f.length>0?f:Xe,[n,s]=d.useState(t.reflection.length===0),[y,b]=d.useState(()=>u.map(c=>t.reflection.find(o=>o.question===c)?.answer??"")),[g,j]=d.useState(!1);async function k(){if(!g){j(!0);try{const c=u.map((o,h)=>({question:o,answer:y[h]?.trim()??""})).filter(o=>o.answer.length>0);if(t.id.startsWith("guest-")){w("Sign in to save reflections to your journal."),j(!1);return}w.loading("Saving reflection…",{id:"dream-detail-save"}),await q(),await l({data:{id:t.id,reflection:c}}),w.success("Reflection saved",{id:"dream-detail-save"}),i({...t,reflection:c}),s(!1)}catch(c){const o=c instanceof Error?c.message:"";w.error(o||"Couldn't save reflection — please try again.",{id:"dream-detail-save",description:o?"Exact server response shown above.":void 0,duration:8e3})}finally{j(!1)}}}return e.jsxs("div",{children:[e.jsxs("button",{onClick:r,className:"mb-4 inline-flex items-center gap-1.5 text-sm text-[#5a5775] hover:text-[#2c2a4a] dark:text-muted-foreground dark:hover:text-foreground",children:[e.jsx(G,{className:"h-4 w-4"})," Back to dreams"]}),e.jsxs("article",{className:"rounded-2xl border border-white/70 bg-white/70 p-6 shadow-sm backdrop-blur-md dark:border-border dark:bg-card",children:[e.jsx("h2",{className:"font-display text-2xl text-[#2c2a4a] dark:text-foreground",children:t.title?.trim()||"Untitled dream"}),e.jsxs("p",{className:"mt-1 text-xs text-[#68657d] dark:text-muted-foreground",children:[new Date(t.created_at).toLocaleString(),t.mood?` · Mood: ${t.mood}`:""]}),e.jsx("p",{className:"mt-4 whitespace-pre-wrap text-sm leading-relaxed text-[#2c2a4a] dark:text-foreground/90",children:t.body}),x.length>0&&e.jsx("div",{className:"mt-5 flex flex-wrap gap-1.5",children:x.map((c,o)=>e.jsx("span",{className:"rounded-full border border-[#e6dff2] bg-white/70 px-2.5 py-0.5 text-[11px] font-medium text-[#5a4b7a] dark:border-border dark:bg-background dark:text-muted-foreground",children:c.label},o))})]}),!n&&t.reflection.length>0&&e.jsxs("section",{className:"mt-5 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"font-display text-base text-[#2c2a4a] dark:text-foreground",children:"🤍 Your reflection"}),e.jsx("button",{type:"button",onClick:()=>s(!0),className:"rounded-full border border-[#dcd6ea] bg-white/80 px-3 py-1 text-xs font-medium text-[#5a4b7a] hover:text-[#2c2a4a] dark:border-border dark:bg-background dark:text-muted-foreground dark:hover:text-foreground",children:"Edit"})]}),t.reflection.map((c,o)=>e.jsxs("div",{className:"rounded-2xl border border-white/70 bg-white/60 p-5 backdrop-blur-md dark:border-border dark:bg-card",children:[e.jsx("p",{className:"text-xs font-medium text-[#7a6ca8]",children:c.question}),e.jsx("p",{className:"mt-1 whitespace-pre-wrap text-sm text-[#2c2a4a] dark:text-foreground
3/90",children:c.answer})]},o))]}),n&&e.jsxs("section",{className:"mt-5",children:[e.jsxs("div",{className:"mb-3 rounded-2xl border border-white/70 bg-white/60 p-5 backdrop-blur-md dark:border-border dark:bg-card",children:[e.jsx("h3",{className:"font-display text-base text-[#2c2a4a] dark:text-foreground",children:"🤍 Gentle reflection"}),e.jsx("p",{className:"mt-1 text-sm text-[#5a5775] dark:text-muted-foreground",children:"Take what resonates. Skip what doesn't. There's no right answer."})]}),e.jsx("div",{className:"space-y-3",children:u.map((c,o)=>e.jsxs("div",{className:"rounded-2xl border border-white/70 bg-white/70 p-5 backdrop-blur-md dark:border-border dark:bg-card",children:[e.jsx("label",{className:"block text-sm font-medium text-[#2c2a4a] dark:text-foreground",children:c}),e.jsx("textarea",{rows:3,value:y[o]??"",onChange:h=>{const a=[...y];a[o]=h.target.value,b(a)},className:"mt-2 w-full resize-y rounded-xl border border-[#dcd6ea] bg-white/80 p-3 text-sm text-[#2c2a4a] placeholder:text-[#777189] focus:outline-none focus:ring-2 focus:ring-[#b9a8d9] dark:border-border dark:bg-background dark:text-foreground dark:placeholder:text-muted-foreground dark:focus:ring-gold",maxLength:2e3,placeholder:"A few words is enough…"})]},o))}),e.jsxs("div",{className:"mt-5 flex flex-col-reverse items-stretch justify-end gap-3 sm:flex-row sm:items-center",children:[t.reflection.length>0&&e.jsx("button",{type:"button",onClick:()=>{s(!1),b(u.map(c=>t.reflection.find(o=>o.question===c)?.answer??""))},className:"rounded-full border border-[#dcd6ea] bg-white/80 px-5 py-2.5 text-sm font-medium text-[#5a5775] hover:text-[#2c2a4a] dark:border-border dark:bg-background dark:text-muted-foreground dark:hover:text-foreground",children:"Cancel"}),e.jsx("button",{type:"button",onClick:c=>{g||(c.preventDefault(),typeof document<"u"&&document.activeElement instanceof HTMLElement&&document.activeElement.blur(),k())},disabled:g,className:"relative z-20 inline-flex min-h-[48px] touch-manipulation items-center justify-center gap-2 rounded-full bg-gradient-to-r from-[#7a6ca8] to-[#a88dc4] px-6 py-3 text-sm font-medium text-white shadow-md transition hover:opacity-90 disabled:opacity-60 sm:min-h-0 sm:py-2.5",children:g?e.jsxs(e.Fragment,{children:[e.jsx(W,{className:"h-4 w-4 animate-spin"})," Saving…"]}):"Save reflection"})]})]})]})}function et({patterns:t}){if(t===null)return e.jsxs("div",{className:"rounded-2xl border border-white/70 bg-white/60 p-8 text-center text-sm text-[#5a5775] backdrop-blur-md dark:border-border dark:bg-card dark:text-muted-foreground",children:[e.jsx(W,{className:"mx-auto mb-2 h-5 w-5 animate-spin text-[#7a6ca8]"}),"Looking for patterns in your dreams…"]});if(t.totals.dreams<2)return e.jsxs("div",{className:"rounded-2xl border border-white/70 bg-white/60 p-8 text-center text-sm text-[#5a5775] backdrop-blur-md dark:border-border dark:bg-card dark:text-muted-foreground",children:[e.jsx(Re,{className:"mx-auto mb-2 h-6 w-6 text-[#7a6ca8]"}),"Patterns will appear after you've recorded a few dreams. The more you record, the more you'll notice what gently returns."]});const r=[{title:"Recurring themes",emoji:"💭",buckets:t.themes},{title:"Emotions",emoji:"🤍",buckets:t.emotions},{title:"Symbols",emoji:"🔮",buckets:t.symbols},{title:"People",emoji:"👤",buckets:t.people},{title:"Places",emoji:"📍",buckets:t.places}].filter(i=>i.buckets.length>0);return r.length===0&&t.insights.length===0?null:e.jsxs("div",{className:"space-y-2.5",children:[e.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:r.map(i=>e.jsxs("div",{className:"rounded-2xl border border-gold/25 bg-card/80 p-3.5 shadow-sm backdrop-blur",children:[e.jsxs("h3",{className:"mb-2 flex items-center gap-1.5 font-display text-sm text-foreground",children:[e.jsx("span",{"aria-hidden":!0,children:i.emoji}),e.jsx("span",{className:"truncate",children:i.title})]}),e.jsx("ul",{className:"space-y-1 text-xs",children:i.buckets.slice(0,3).map(l=>e.jsxs("li",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("span",{className:"truncate capitalize text-foreground
3/85",children:l.label}),e.jsxs("span",{className:"shrink-0 text-[11px] text-foreground/55",children:["· ",l.count]})]},l.label))})]},i.title))}),t.insights.length>0&&e.jsxs("div",{className:"rounded-2xl border border-gold/25 bg-gold/5 p-3.5 backdrop-blur",children:[e.jsx("ul",{className:"space-y-1 text-xs leading-relaxed text-foreground/80 md:text-sm",children:t.insights.map((i,l)=>e.jsx("li",{children:i},l))}),e.jsx("p",{className:"mt-2 text-[11px] italic text-foreground/55",children:"Simple counts of what you've written — not an interpretation. What they mean is yours to decide."})]})]})}function tt({onSit:t,autoFocusSearch:r=!1}){const[i,l]=d.useState(""),x=d.useRef(null),f=i.trim().toLowerCase(),u=d.useMemo(()=>f?se.filter(n=>[n.symbol,...n.keywords??[],...n.themes].join(" ").toLowerCase().includes(f)):se,[f]);return d.useEffect(()=>{if(r&&x.current){const n=window.setTimeout(()=>x.current?.focus(),50);return()=>window.clearTimeout(n)}},[r]),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-3 px-1",children:[e.jsx("h2",{className:"font-display text-lg text-foreground md:text-xl",children:"🔮 Symbol Explorer"}),e.jsx("p",{className:"mt-1 text-xs text-foreground/70 md:text-sm",children:"A few common dream images, held lightly. Your own meaning matters most."}),e.jsx("p",{className:"mt-1 text-[11px] italic text-foreground/55 md:text-xs",children:"Dream symbols do not have one fixed meaning. This section is for gentle reflection only — not interpretation, diagnosis, or therapy."})]}),e.jsxs("div",{className:"mb-3 px-1",children:[e.jsx("label",{htmlFor:"symbol-search",className:"sr-only",children:"Search dream symbols"}),e.jsx("input",{ref:x,id:"symbol-search",type:"search",value:i,onChange:n=>l(n.target.value),placeholder:"Search dream symbols…",className:"w-full rounded-2xl border border-sage/30 bg-card/80 px-4 py-2.5 text-sm text-foreground placeholder:text-foreground/40 shadow-sm backdrop-blur focus:border-[var(--gold-deep)] focus:outline-none focus:ring-2 focus:ring-gold/30"}),e.jsx("p",{className:"mt-1.5 px-1 text-[11px] text-foreground/50",children:"Try: water, house, door, child, animal, falling, being chased, teeth, death, mother, father"})]}),u.length===0?e.jsx("p",{className:"rounded-2xl border border-sage/30 bg-card/80 px-4 py-6 text-center text-sm text-foreground/70 shadow-sm backdrop-blur",children:"No matching symbol yet — your own meaning matters most. Try a related word, or sit with the image as it is."}):e.jsx("div",{className:"grid gap-2.5 md:grid-cols-2 md:gap-3",children:u.map(n=>e.jsxs("article",{className:"rounded-2xl border border-sage/30 bg-card/80 p-4 shadow-sm backdrop-blur",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":!0,children:n.emoji}),e.jsx("h3",{className:"font-display text-base text-foreground",children:n.symbol})]}),e.jsx("p",{className:"mt-2 text-sm leading-relaxed text-foreground/80",children:n.reflection}),n.themes.length>0&&e.jsxs("div",{className:"mt-3",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-foreground/55",children:"Possible emotional themes"}),e.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:n.themes.map(s=>e.jsx("span",{className:"rounded-full border border-sage/30 bg-sage/10 px-2.5 py-0.5 text-[11px] text-foreground/75",children:s},s))})]}),e.jsxs("div",{className:"mt-3 rounded-xl border border-gold/25 bg-gold/5 p-3",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-[var(--gold-deep)]",children:"Gentle reflection"}),e.jsx("ul",{className:"mt-1.5 space-y-1 text-xs text-foreground/80 md:text-sm",children:n.questions.map(s=>e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{"aria-hidden":!0,className:"text-[var(--gold-deep)]",children:"•"}),e.jsx("span",{children:s})]},s))})]}),e.jsx("p",{className:"mt-3 text-[11px] italic text-foreground/55",children:"Only take what feels right. You can stop at any time."}),e.jsx("button",{type:"button",onClick:()=>t(n.symbol),className:"mt-3 inline-flex items-center gap-1.5 text-xs font-medium text-[var(--gold-deep)] hover:underline",children:"Sit with this symbol →"})]},n.symbol))})]})}function rt({lens:t}
3){const[r,i]=d.useState(!1);return e.jsxs("article",{className:"flex w-[82%] shrink-0 snap-start flex-col rounded-2xl border border-gold/25 bg-card/80 p-4 shadow-sm backdrop-blur sm:w-[60%] md:w-[46%]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":!0,children:t.emoji}),e.jsx("h3",{className:"font-display text-base text-foreground",children:t.title})]}),e.jsx("p",{className:"mt-1.5 text-sm leading-relaxed text-foreground/80",children:t.body}),r&&e.jsx("div",{className:"mt-3 space-y-2.5 border-t border-gold/20 pt-3",children:t.more.map((l,x)=>e.jsx("p",{className:"text-sm leading-relaxed text-foreground/80",children:l},x))}),e.jsx("button",{type:"button",onClick:()=>i(l=>!l),className:"mt-3 inline-flex items-center gap-1 self-start text-xs font-medium text-[var(--gold-deep)] hover:underline","aria-expanded":r,children:r?"Show less":"Explore →"})]})}const It=ye(Je,"Dream Journal");export{It as component};
4//# sourceMappingURL=dreams-CCTwbGlp.js.map

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.