1import{aa as R,a1 as C,ad as D,r as m,o as B,a as F,j as e,m as j,B as L,ae as M,b as E}from"./index-D1aRnlNO.js";import{u as O}from"./useMutation-Dr6hwXg0.js";import{B as _}from"./button-D4DXZUyY.js";import{T as $}from"./textarea-R2BjKJU1.js";import{l as q}from"./dailyAlignmentStore-BsRkN0fG.js";import{a as U,t as G}from"./usePersonalisation-iTkIFKH5.js";import{V as K,m as Q}from"./VoiceJournalInput-CZMVn0EK.js";import{S as V}from"./save--1GnicLd.js";import"./weekCalendar-BExf1LKk.js";import"./practiceLibrary-CaLM5ZUb.js";import"./launchAttribution-CXZJnp8K.js";const N=R,z=Object.freeze({calm:["What feels clear to you in this moment?","What would you like to make space for while things feel settled?","What are you noticing now that the noise feels quieter?"],good:["What is supporting you today?","What would you like to carry forward from this moment?","What feels worth appreciating right now?"],energised:["Where would your energy feel most meaningful today?","What are you feeling ready to move towards?","What possibility feels alive for you right now?"],tired:["What could you gently set down for now?","What kind of rest or support would feel most useful today?","What truly needs your energy, and what can wait?"],overwhelmed:["What feels like itâs asking for too much of you right now?","What is one thing you do not need to solve all at once?","What would make this moment feel a little more manageable?"],unsettled:["What feels unresolved or uncertain for you right now?","What might help you feel a little more anchored today?","What are you noticing beneath the restlessness?"],low:["What would feel like kindness towards yourself today?","What feels hardest to carry at the moment?","What small thing might offer you some support today?"],scattered:["What feels most important to bring your attention back to?","What thoughts are competing for your attention right now?","If you chose one gentle priority, what would it be?"]}),H=["[Tarot:","[Angel Number ","[Intention]"];function S(r){if(!r)return!1;const i=String(r.content||"").trimStart();return H.some(a=>i.startsWith(a))}function Y(r,i,a=null){const o=Array.isArray(r)?r:[];if(a){const s=o.find(l=>l.id===a);return(s==null?void 0:s.date)===i&&!S(s)?s:null}return o.find(s=>s.date===i&&!S(s))||null}function X(r,i=C()){const a=z[r];if(!(a!=null&&a.length))return null;const o=`${i}:${r}`;let s=0;for(let l=0;l<o.length;l+=1)s=s*31+o.charCodeAt(l)>>>0;return a[s%a.length]}function Z(r,i){const a=String(i||"").trim();return r?`${r} 2 3${a}`:a}function me(){const[r]=D(),i=r.get("guided")==="1",a=C(),[o,s]=m.useState(a),[l,p]=m.useState(null),[x,h]=m.useState(""),[d,b]=m.useState(null),[w,W]=m.useState(null),T=B(),{data:u}=F({queryKey:["journalEntries"],queryFn:()=>
3E.entities.JournalEntry.list("-date",30)}),n=m.useMemo(()=>Y(u,o,l),[u,o,l]),g=m.useMemo(()=>l&&u.find(t=>t.id===l)||null,[u,l]),k=S(g);m.useEffect(()=>{let t=!0;return q().then(c=>{t&&N.some(P=>P.id===(c==null?void 0:c.feeling_id))&&W(c.feeling_id)}).catch(()=>{}),()=>{t=!1}},[]),m.useEffect(()=>{if(g){h(g.content||""),b(g.mood||null);return}n?(p(n.id),h(n.content||""),b(n.mood||null)):(h(""),b(o===a?w:null))},[o,g,n,a,w]);const y=X(d,o),v=o===a&&N.find(t=>t.id===w)||null,f=O({mutationFn:async t=>n?E.entities.JournalEntry.update(n.id,t):E.entities.JournalEntry.create(t),onSuccess:t=>{t!=null&&t.id&&p(t.id),T.invalidateQueries({queryKey:["journalEntries"]}),d&&U(d),G("reflect")}}),A=()=>{const t=i&&!n&&y;f.mutate({date:o,content:t?Z(y,x):x.trim(),mood:d})},I=t=>{s(t),p(null)},J=t=>{s(t.date),p(t.id)};return e.jsx("div",{className:"enlighten-experience-page pb-safe",children:e.jsxs("div",{className:"enlighten-experience-content-wide",children:[e.jsxs(j.div,{initial:{opacity:0,y:-20},animate:{opacity:1,y:0},className:"mb-8",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx(L,{className:"w-5 h-5",style:{color:"#c2613a"}}),e.jsx("h1",{className:"enlighten-page-heading",children:"Daily Journal"})]}),e.jsx("p",{className:"enlighten-page-intro",children:i?"Take a moment to notice what is here.":"Reflect and document your inner journey."})]}),e.jsx(j.div,{initial:{opacity:0}
3,animate:{opacity:1},transition:{delay:.1},className:"mb-8 p-4 rounded-[18px] border",style:{background:"linear-gradient(135deg, rgba(194,97,58,0.08), #16241C)",borderLeft:"4px solid rgba(194,97,58,0.4)",borderTop:"1px solid rgba(194,97,58,0.15)",borderRight:"1px solid rgba(194,97,58,0.1)",borderBottom:"1px solid rgba(194,97,58,0.1)"},children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(M,{className:"w-5 h-5 flex-shrink-0 mt-0.5",style:{color:"#c2613a"}}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",style:{color:"#e8d5b0"},children:"Pen to Paper is Always Best"}),e.jsx("p",{className:"text-xs mt-1",style:{color:"#a89070"},children:"This digital space complements your handwritten practice and helps you revisit reflections when needed."})]})]})}),e.jsxs(j.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.15},className:"rounded-[18px] border p-6 mb-6",style:{background:"linear-gradient(135deg, rgba(74,222,128,0.05), #16241C)",borderLeft:"4px solid rgba(74,222,128,0.35)",borderTop:"1px solid rgba(74,222,128,0.12)",borderRight:"1px solid rgba(74,222,128,0.08)",borderBottom:"1px solid rgba(74,222,128,0.08)"},children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("label",{className:"text-sm font-medium",style:{color:"#a89070"},children:"Date"}),e.jsx("input",{type:"date",value:o,onChange:t=>I(t.target.value),className:"w-full mt-2 px-4 py-2 rounded-lg text-sm",style:{background:"rgba(44,32,16,0.8)",borderColor:"rgba(194,97,58,0.2)",color:"#e8d5b0",border:"1px solid rgba(194,97,58,0.2)"}})]}),e.jsxs("fieldset",{className:"mb-6",children:[e.jsx("legend",{className:"text-sm font-medium",style:{color:"#a89070"},children:v?e.jsxs("span",{className:"space-y-1",children:[e.jsxs("span",{className:"block",children:["Earlier today you felt: ",e.jsx("span",{style:{color:"#e8d5b0"},children:v.label})]}),e.jsx("span",{className:"block",style:{color:"#e8d5b0"},children:"Has anything shifted?"})]}):"How are you feeling right now?"}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2 mt-3",children:N.map(t=>e.jsx("button",{type:"button","aria-pressed":d===t.id,onClick:()=>b(t.id),className:"px-3 py-2.5 min-h-[44px] rounded-xl text-sm font-medium transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#c2613a]",style:{background:d===t.id?"rgba(194,97,58,0.3)":"rgba(44,32,16,0.6)",border:`1px solid ${d===t.id?"rgba(194,97,58,0.45)":"rgba(168,144,112,0.12)"}`,color:d===t.id?"#e7b08f":"#a89070"},children:t.label},t.id))}),!v&&(n==null?void 0:n.mood)&&!N.some(t=>t.id===n.mood)&&e.jsxs("p",{className:"text-xs mt-2 capitalize",style:{color:"#7f715d"},children:["Saved feeling: ",n.mood]})]}),y&&e.jsxs("div",{className:"mb-5 rounded-2xl px-4 py-4",style:{background:"rgba(194,97,58,0.07)",border:"1px solid rgba(194,97,58,0.16)"},children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.18em] mb-2",style:{color:"#8c765a"},children:"A reflection for this moment"}),e.jsx("p",{className:"font-serif-editorial text-lg leading-relaxed",style:{color:"#e8d5b0"},children:y})]}),e.jsx("div",{className:"mb-4",children:e.jsx(K,{onTranscript:t=>h(c=>Q(c,t))})}),e.jsxs("div",{className:"mb-6",children:[e.jsx("label",{className:"text-sm font-medium",style:{color:"#a89070"},children:"Your Thoughts"}),e.jsx($,{value:x,onChange:t=>h(t.target.value),readOnly:k,placeholder:y||"Begin your reflection here...",className:"mt-2 min-h-64",style:{background:"rgba(44,32,16,0.8)",borderColor:"rgba(194,97,58,0.2)",color:"#e8d5b0"}})]}),e.jsxs(_,{onClick:A,disabled:k||f.isPending||!x.trim()||!d,className:"w-full flex items-center justify-center gap-2",style:{background:"#c2613a",color:"#1a1208"},children:[e.jsx(V,{className:"w-4 h-4"}),f.isPending?"Saving...":n?"Update Entry":"Save Entry"]}),k&&e.jsx("p",{className:"text-xs text-center mt-3",style:{color:"#7f715d"},children:"This entry was saved by another Enlighten experience and is shown here without editing."}),f.isSuccess&&e.jsxs("a",{href:"/Community",className:"flex items-center justify-between px-4 py-3 rounded-xl border mt-2",style:{background:"rgba(44,32,16,0.4)",borderColor:"rgba(168,144,112,0.1)"},children:[e.jsx("p",{className:"text-xs font-light",style:{color:"#6b5b45"},children:"Others may be experiencing similar themes"}),e.jsx("span",{className:"text-xs font-light flex-shrink-0 ml-2",style:{color:"#4a3a28"},children:"View community â"})]})]}),u&&u.length>0&&e.jsxs(j.div,{initial:{opacity:0,y:20}
3,animate:{opacity:1,y:0},transition:{delay:.2},children:[e.jsx("h2",{className:"text-lg font-light mb-4",style:{color:"#e8d5b0"},children:"Recent Entries"}),e.jsx("div",{className:"space-y-3",children:u.slice(0,5).map(t=>{var c;return e.jsx("button",{onClick:()=>J(t),className:"w-full p-4 rounded-[18px] text-left transition-all",style:{background:l===t.id?"linear-gradient(135deg, rgba(194,97,58,0.12), #16241C)":"linear-gradient(135deg, rgba(255,255,255,0.02), #16241C)",borderLeft:`4px solid ${l===t.id?"rgba(194,97,58,0.5)":"rgba(168,144,112,0.2)"}`,borderTop:"1px solid rgba(168,144,112,0.08)",borderRight:"1px solid rgba(168,144,112,0.06)",borderBottom:"1px solid rgba(168,144,112,0.06)"},children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",style:{color:"#e8d5b0"},children:new Date(t.date+"T12:00:00").toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric"})}),e.jsxs("p",{className:"text-xs mt-1 line-clamp-1",style:{color:"#a89070"},children:[(t.content||"").substring(0,80),((c=t.content)==null?void 0:c.length)>80?"...":""]})]}),e.jsx("span",{className:"text-xs px-2 py-1 rounded-lg",style:{background:"rgba(194,97,58,0.2)",color:"#c2613a"},children:t.mood})]})},t.id)})})]})]})})}export{me 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.