1import{j as e,r as o,a as J}from"./vendor-ebxS2RN4.js";import{l as K,P as b,T as V,G as _,i as E}from"./index-9erSEm9O.js";import{N as Y}from"./NextCard-Dwo7KJl-.js";const S=[3,5,10,15,20,30],B=[{text:"Settle. Let the body grow heavy and still, as if just about to fall asleep.",seconds:30},{text:"Soften the breath. Let attention sink from the head down into the chest.",seconds:25},{text:"Choose a single short scene that implies your wish is already fulfilled.",seconds:25},{text:"Enter the scene from the inside â see through your own eyes, not from outside.",seconds:30},{text:"Bring in touch, sound, warmth â make one detail vivid and real.",seconds:30},{text:"Feel the quiet relief and gratitude of it being already done.",seconds:35},{text:"Loop the scene gently, like a short film, and let it carry you toward sleep.",seconds:40}],P=[{text:"Settle, and let the dayâs busyness loosen. Breathe slowly a few times.",seconds:30},{text:"Invite an image to appear â from a dream, a mood, or simply what arises.",seconds:30},{text:"Let it take form. Donât direct it; watch what it does on its own.",seconds:35},{text:"Greet it. Ask, honestly: âWho are you? What do you want me to know?â",seconds:40},{text:"Listen for its reply, even if it surprises you â then answer back truthfully.",seconds:45},{text:"Stay in the exchange a little longer; let it reach its own natural pause.",seconds:40},{text:"Thank the figure and gently return. Soon, write down what passed between you.",seconds:25}],R=[{text:"Settle and soften. Let the breath be natural for a few rounds.",seconds:30},{text:"Bring to mind someone who is suffering â you may include yourself.",seconds:30},{text:"Breathing in, take in their pain as a warm, dark cloud â willingly, without flinching.",seconds:40},{text:"Let it dissolve in the openness of the heart. There is room for it here.",seconds:35},{text:"Breathing out, send relief, ease, and light â whatever they most need.",seconds:40},{text:"Keep the rhythm: in with the pain, out with relief. Widen it to all who share it.",seconds:45},{text:"Rest. Let the breath return to normal, and carry the warmth with you.",seconds:25}],$=[{text:"Settle comfortably and let the breath be easy. Rest a hand over the heart if you like.",seconds:30},{text:"Bring yourself to mind, and silently offer: âMay I be safe. May I be well. May I be at ease.â",seconds:40},{text:"Let the words be a wish, not a demand â feel whatever warmth arises, however small.",seconds:35},{text:"Picture someone dear to you, and offer them the same: âMay you be safe, well, and at ease.â",seconds:40},{text:"Bring to mind someone neutral â a stranger you barely know â and wish them the same.",seconds:40},{text:"If you can, include someone difficult, holding only the simple wish for their peace.",seconds:40},{text:"Widen the circle to all beings everywhere: âMay all be safe. May all be well. May all be at ease.â",seconds:45}],D=["So Ham","Om","Om Mani Padme Hum","Ram","Om Namah Shivaya","Hare Krishna","Sat Nam"],Q={meditation:"Meditation",sats:"SATS",imagination:"Active Imagination",japa:"Japa",tonglen:"Tonglen",metta:"Loving-kindness",immerse:"Immersion"};function W({progress:n,size:t=200,stroke:a=9,children:l}){const r=Math.max(0,Math.min(1,n||0)),i=(t-a)/2,s=2*Math.PI*i,c=s*(1-r);return e.jsxs("div",{className:"progress-ring",style:{width:t,height:t},children:[e.jsxs("svg",{width:t,height:t,viewBox:`0 0 ${t} ${t}`,"aria-hidden":"true",children:[e.jsx("circle",{cx:t/2,cy:t/2,r:i,fill:"none",stroke:"rgba(184,170,235,0.16)",strokeWidth:a}),e.jsx("circle",{cx:t/2,cy:t/2,r:i,fill:"none",stroke:"url(#ringgrad)",strokeWidth:a,strokeLinecap:"round",strokeDasharray:s,strokeDashoffset:c,transform:`rotate(-90 ${t/2} ${t/2})`,style:{transition:"stroke-dashoffset .4s ease"}}),e.jsx("defs",{children:e.jsxs("linearGradient",{id:"ringgrad",x1:"0",y1:"0",x2:"1",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#f6dca6"}),e.jsx("stop",{offset:"100%",stopColor:"#e09bb6"})]})})]}),e.jsx("div",{className:"progress-ring-center",children:l})]})}function I(n){o.useEffect(()=>{if(!n)return;const t=navigator;if(!t.wakeLock)return;let a=null,l=!1;const r=async()=>{try{const s=await t.wakeLock.request("screen");if(l){s.release().catch(()=>{});return}a=s}catch{}},i=()=>{document.visibilityState==="visible"&&!l&&r()};
1return r(),document.addEventListener("visibilitychange",i),()=>{l=!0,document.removeEventListener("visibilitychange",i),a==null||a.release().catch(()=>{})}},[n])}const M=[{id:"coherent",name:"Coherent",hint:"Even & easy · 5.5 in · 5.5 out",steps:[{phase:"in",ms:5500},{phase:"out",ms:5500}]},{id:"478",name:"4·7·8",hint:"Deeply calming · in 4 · hold 7 · out 8",steps:[{phase:"in",ms:4e3},{phase:"hold",ms:7e3},{phase:"out",ms:8e3}]},{id:"box",name:"Box",hint:"Steady focus · 4 · 4 · 4 · 4",steps:[{phase:"in",ms:4e3},{phase:"hold",ms:4e3},{phase:"out",ms:4e3},{phase:"hold",ms:4e3}]},{id:"calm",name:"Calm",hint:"Longer exhale · in 4 · out 6",steps:[{phase:"in",ms:4e3},{phase:"out",ms:6e3}]}],G=M[0];function F(n){return M.find(t=>t.id===n)??G}const U={in:"Breathe in",hold:"Hold",out:"Breathe out"};function H({active:n,pattern:t=G,size:a=168,label:l=!0}){const[r,i]=o.useState(t.steps[0].phase);return o.useEffect(()=>{if(!n){i(t.steps[0].phase);return}let s=0;i(t.steps[0].phase);let c=window.setTimeout(function x(){s=(s+1)%t.steps.length,i(t.steps[s].phase),c=window.setTimeout(x,t.steps[s].ms)},t.steps[0].ms);return()=>clearTimeout(c)},[n,t]),e.jsxs("div",{className:"breath",children:[e.jsxs("div",{className:`breathorb${n?" breathing":""}`,"data-pattern":t.id,style:{width:a,height:a},"aria-hidden":"true",children:[e.jsx("span",{className:"bo-aura"}),e.jsx("span",{className:"bo-ring bo-ring3"}),e.jsx("span",{className:"bo-ring bo-ring2"}),e.jsx("span",{className:"bo-ring"}),e.jsx("span",{className:"bo-core"})]}),l&&e.jsx("p",{className:"breath-label",children:n?U[r]:"Paused"})]})}const L={stillness:{src:"/audio/stillness.mp3",name:"Stillness"},threshold:{src:"/audio/threshold.mp3",name:"Threshold"},reverie:{src:"/audio/reverie.mp3",name:"Reverie"}},X=.5;let f=null,T=null,y=null;function q(){return f||(f=new Audio,f.loop=!0,f.preload="auto"),f}function A(n,t,a){const l=q();y&&(cancelAnimationFrame(y),y=null);const r=l.volume,i=performance.now(),s=c=>{const x=Math.min(1,(c-i)/t);l.volume=Math.max(0,Math.min(1,r+(n-r)*x)),x<1?y=requestAnimationFrame(s):(y=null,a==null||a())};y=requestAnimationFrame(s)}function Z(n,t=X){const a=q();if(T===n&&!a.paused){A(t,800);return}T=n,a.src=L[n].src,a.volume=0,a.play().catch(()=>{}),A(t,1400)}function O(n=1100){if(!f||f.paused){T=null;return}A(0,n,()=>{f==null||f.pause(),T=null})}const z=Object.keys(L),ee=n=>`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`;function te({start:n="stillness",onLog:t,onClose:a}){const[l,r]=o.useState(n),[i,s]=o.useState(!1),[c,x]=o.useState(()=>{try{return localStorage.getItem("imaginal-breath-pattern")||"478"}catch{return"478"}}),u=F(c),g=m=>{x(m);try{localStorage.setItem("imaginal-breath-pattern",m)}catch{}},[j,p]=o.useState(!0),[d,h]=o.useState(0),N=o.useRef(Date.now());I(!0),o.useEffect(()=>{i?O(600):Z(l)},[l,i]),o.useEffect(()=>()=>O(900),[]),o.useEffect(()=>{try{localStorage.setItem("imaginal-immerse-seen","1")}catch{}},[]),o.useEffect(()=>{const m=setInterval(()=>h(Math.round((Date.now()-N.current)/1e3)),1e3);return()=>clearInterval(m)},[]),o.useEffect(()=>{if(!j)return;const m=setTimeout(()=>p(!1),4500);return()=>clearTimeout(m)},[j]);function v(){d>=20&&t({kind:"immerse",duration_s:d,count:0,data:{track:l}}),a()}return J.createPortal(e.jsxs("div",{className:"immerse",onClick:()=>p(!0),children:[e.jsxs("div",{className:"immerse-mist","aria-hidden":"true",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}),e.jsxs("div",{className:"immerse-orb",children:[e.jsx("span",{className:"immerse-glow","aria-hidden":"true"}),e.jsx(H,{active:!0,size:280,pattern:u})]}),e.jsxs("div",{className:`immerse-chrome${j?"":" hidden"}`,onClick:m=>m.stopPropagation(),children:[e.jsx("button",{type:"button",className:"immerse-close",onClick:v,"aria-label":"End the session",children:"â"}),e.jsx("div",{className:"immerse-time","aria-hidden":"true",children:ee(d)}),e.jsxs("div",{className:"immerse-controls",children:[e.jsx("div",{className:"immerse-row",role:"group","aria-label":"Breathing pattern",children:M.map(m=>e.jsx("button",{type:"button",className:`chip${m.id===u.id?" active":""}`,onClick:()=>g(m.id),children:m.name},m.id))}),e.jsx("p",{className:"immerse-hint",children:u.hint}),e.jsxs("div",{className:"immerse-row",role:"group","aria-label":"Ambient sound",children:[z.map(m=>e.jsx("button",{type:"button",className:`chip${m===l&&!i?" active":""}`,onClick:()=>{s(!1),r(m)},children:L[m].name},m)),e.jsx("button",{type:"button",className:`chip${i?" active":""}`,onClick:()=>s(m=>!m),children:i?"Silent":"Mute"})]})]})]})]}),document.body)}const se=n=>`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`,k=n=>Math.max(1,Math.round(n.reduce((t,a)=>t+a.seconds,0)/60)),ne=`${S[0]}â${S[S.length-1]} min`;function ae(n){if(!n)return"";const t=new Date(n),a=r=>new Date(r.getFullYear(),r.getMonth(),r.getDate()).getTime(),l=Math.round((a(new Date)-a(t))/864e5);return l===0?"Today":l===1?"Yesterday":l>1&&l<7?`${l}d ago`:t.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function de({user:n,onLog:t,initialTool:a,onConsumed:l,onGo:r}
1){const[i,s]=o.useState(null),[c,x]=o.useState([]);return o.useEffect(()=>{i===null&&K(n).then(x).catch(()=>{})},[i,n]),o.useEffect(()=>{a&&(s(a),l==null||l())},[a]),i==="meditation"?e.jsx(ie,{onLog:t,onBack:()=>s(null)}):i==="sats"?e.jsx(w,{steps:B,kind:"sats",title:"SATS â living in the end",onLog:t,onBack:()=>s(null)}):i==="imagination"?e.jsx(w,{steps:P,kind:"imagination",title:"Active Imagination",onLog:t,onBack:()=>s(null)}):i==="tonglen"?e.jsx(w,{steps:R,kind:"tonglen",title:"Tonglen â giving & taking",onLog:t,onBack:()=>s(null)}):i==="metta"?e.jsx(w,{steps:$,kind:"metta",title:"Loving-kindness",onLog:t,onBack:()=>s(null)}):i==="japa"?e.jsx(re,{onLog:t,onBack:()=>s(null)}):i==="immerse"?e.jsx(te,{onLog:t,onClose:()=>s(null)}):e.jsxs("div",{className:"screen",children:[e.jsxs("div",{className:"screen-head",children:[e.jsx("h1",{className:"screen-title",children:"Practice"}),e.jsx("p",{className:"screen-sub",children:"Sit, visualize, reflect. A few minutes is enough."})]}),e.jsxs("button",{type:"button",className:"immerse-cta",onClick:()=>s("immerse"),children:[e.jsx("span",{className:"immerse-cta-orb","aria-hidden":"true"}),e.jsxs("span",{className:"immerse-cta-text",children:[e.jsx("span",{className:"immerse-cta-title",children:"Immerse"}),e.jsx("span",{className:"immerse-cta-sub",children:"A breathing space â sound & sky"})]}),e.jsx("span",{className:"immerse-cta-go","aria-hidden":"true",children:"â"})]}),e.jsxs("div",{className:"tool-grid",children:[e.jsxs("button",{type:"button",className:"tool",onClick:()=>s("meditation"),children:[e.jsx("div",{className:"tool-ico","aria-hidden":"true",children:e.jsx(b,{kind:"meditation"})}),e.jsx("div",{className:"tool-name",children:"Meditation"}),e.jsx("div",{className:"tool-desc",children:"Quiet-sitting timer"}),e.jsx("div",{className:"tool-len",children:ne})]}),e.jsxs("button",{type:"button",className:"tool",onClick:()=>s("sats"),children:[e.jsx("div",{className:"tool-ico","aria-hidden":"true",children:e.jsx(b,{kind:"sats"})}),e.jsx("div",{className:"tool-name",children:"SATS"}),e.jsx("div",{className:"tool-desc",children:"Guided, living in the end"}),e.jsxs("div",{className:"tool-len",children:["~",k(B)," min"]})]}),e.jsxs("button",{type:"button",className:"tool",onClick:()=>s("imagination"),children:[e.jsx("div",{className:"tool-ico","aria-hidden":"true",children:e.jsx(b,{kind:"imagination"})}),e.jsx("div",{className:"tool-name",children:"Active Imagination"}),e.jsx("div",{className:"tool-desc",children:"Guided inner dialogue"}),e.jsxs("div",{className:"tool-len",children:["~",k(P)," min"]})]}),e.jsxs("button",{type:"button",className:"tool",onClick:()=>s("japa"),children:[e.jsx("div",{className:"tool-ico","aria-hidden":"true",children:e.jsx(b,{kind:"japa"})}),e.jsx("div",{className:"tool-name",children:"Japa"}),e.jsx("div",{className:"tool-desc",children:"Mala mantra counter"}),e.jsx("div",{className:"tool-len",children:"108 beads"})]}),e.jsxs("button",{type:"button",className:"tool",onClick:()=>s("tonglen"),children:[e.jsx("div",{className:"tool-ico","aria-hidden":"true",children:e.jsx(b,{kind:"tonglen"})}),e.jsx("div",{className:"tool-name",children:"Tonglen"}),e.jsx("div",{className:"tool-desc",children:"Giving & taking (Tibetan)"}),e.jsxs("div",{className:"tool-len",children:["~",k(R)," min"]})]}),e.jsxs("button",{type:"button",className:"tool",onClick:()=>s("metta"),children:[e.jsx("div",{className:"tool-ico","aria-hidden":"true",children:e.jsx(b,{kind:"metta"})}),e.jsx("div",{className:"tool-name",children:"Loving-kindness"}),e.jsx("div",{className:"tool-desc",children:"Metta â a heart practice"}),e.jsxs("div",{className:"tool-len",children:["~",k($)," min"]})]})]}),c.length>0&&e.jsxs("div",{className:"card practice-recent",children:[e.jsx("h3",{className:"serif",style:{margin:"0 0 8px",fontSize:"1.15rem"},children:"Recent sessions"}),c.slice(0,5).map(u=>e.jsxs("div",{className:"plog-row",children:[e.jsx("span",{className:"plog-ico","aria-hidden":"true",children:e.jsx(b,{kind:u.kind})}),e.jsx("span",{className:"plog-name",children:Q[u.kind]??u.kind}),e.jsxs("span",{className:"plog-meta",children:[Math.max(1,Math.round(u.duration_s/60))," min · ",ae(u.createdAt)]})]},u.id))]}),e.jsx(Y,{icon:e.jsx(V,{name:"today"}),title:"Back to today",onClick:()=>r("today")})]})}function C({title:n,onBack:t}){return e.jsxs("div",{className:"editor-head",children:[e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Back",onClick:t,children:"â"}),e.jsx("h2",{className:"screen-title",style:{fontSize:"1.5rem",margin:0},children:n})]})}function ie({onLog:n,onBack:t}){const[a,l]=o.useState(10),[r,i]=o.useState(0),[s,c]=o.useState(!1),[x,u]=o.useState(!1),g=o.useRef(0);I(s),o.useEffect(()=>{if(!s)return;let d=!1;const h=()=>{const m=Math.max(0,Math.round((g.current-Date.now())/1e3));i(m),m<=0&&!d&&(d=!0,c(!1),u(!0),n({kind:"meditation",duration_s:a
1*60,count:0,data:{}}),E())},N=setInterval(h,250),v=()=>{document.visibilityState==="visible"&&h()};return document.addEventListener("visibilitychange",v),h(),()=>{clearInterval(N),document.removeEventListener("visibilitychange",v)}},[s]);const j=()=>{const d=r>0?r:a*60;g.current=Date.now()+d*1e3,i(d),c(!0)},p=s||r>0?r:a*60;return e.jsxs("div",{className:"screen",children:[e.jsx(C,{title:"Meditation",onBack:t}),x?e.jsxs("div",{className:"card center",children:[e.jsxs("p",{className:"serif",style:{fontSize:"1.6rem",margin:"6px 0"},children:["Well sat. ",e.jsx("span",{className:"ico-inline","aria-hidden":"true",children:e.jsx(_,{name:"bloom"})})]}),e.jsxs("p",{className:"muted",children:[a," minutes of calm-abiding, logged."]}),e.jsx("button",{type:"button",className:"btn btn-primary",style:{marginTop:12},onClick:()=>{u(!1),i(0)},children:"Again"})]}):e.jsxs("div",{className:"card center",children:[e.jsx(W,{progress:s||r>0?(a*60-r)/(a*60):0,size:210,stroke:9,children:e.jsxs("div",{className:"med-dial",children:[e.jsx("span",{className:`med-glow${s?" breathing":""}`,"aria-hidden":"true"}),e.jsx("span",{className:"dial-time",children:se(p)})]})}),!s&&r===0&&e.jsx("div",{className:"row wrap",style:{justifyContent:"center",margin:"14px 0"},children:S.map(d=>e.jsxs("button",{type:"button",className:`chip${d===a?" active":""}`,onClick:()=>l(d),children:[d," min"]},d))}),e.jsxs("div",{className:"row",style:{justifyContent:"center",marginTop:8},children:[s?e.jsx("button",{type:"button",className:"btn",onClick:()=>c(!1),children:"Pause"}):e.jsx("button",{type:"button",className:"btn btn-primary",onClick:j,children:r===0?"Begin":"Resume"}),r>0&&e.jsx("button",{type:"button",className:"btn btn-ghost",onClick:()=>{c(!1),i(0)},children:"Reset"})]})]})]})}function w({steps:n,kind:t,title:a,onLog:l,onBack:r}){const[i,s]=o.useState(0),[c,x]=o.useState(!0),[u,g]=o.useState(()=>{try{return localStorage.getItem("imaginal-breath-pattern")||"478"}catch{return"478"}}),j=h=>{g(h);try{localStorage.setItem("imaginal-breath-pattern",h)}catch{}},p=o.useRef(Date.now()),d=i>=n.length;return I(c&&!d),o.useEffect(()=>{if(!c||d)return;const h=setTimeout(()=>s(N=>N+1),n[i].seconds*1e3);return()=>clearTimeout(h)},[i,c,d,n]),o.useEffect(()=>{d&&(l({kind:t,duration_s:Math.round((Date.now()-p.current)/1e3),count:0,data:{}}),E())},[d]),d?e.jsxs("div",{className:"screen",children:[e.jsx(C,{title:a,onBack:r}),e.jsxs("div",{className:"card center",children:[e.jsxs("p",{className:"serif",style:{fontSize:"1.6rem",margin:"6px 0"},children:["Complete. ",e.jsx("span",{className:"ico-inline","aria-hidden":"true",children:e.jsx(_,{name:"bloom"})})]}),e.jsx("p",{className:"muted",children:"Practice logged."}),e.jsx("button",{type:"button",className:"btn btn-primary",style:{marginTop:12},onClick:()=>{s(0),p.current=Date.now()},children:"Again"})]})]}):e.jsxs("div",{className:"screen",children:[e.jsx(C,{title:a,onBack:r}),e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"gprog",children:e.jsx("div",{className:"gprog-fill",style:{width:`${i/n.length*100}%`}})}),e.jsx(H,{active:c,size:168,pattern:F(u)}),e.jsx("div",{className:"chips breath-pattern-chips",children:M.map(h=>e.jsx("button",{type:"button",className:`chip${h.id===u?" active":""}`,onClick:()=>j(h.id),children:h.name},h.id))}),e.jsx("div",{className:"guided-step",children:n[i].text}),e.jsxs("div",{className:"muted center",style:{fontSize:".82rem"},children:["Step ",i+1," of ",n.length]}),e.jsxs("div",{className:"row",style:{justifyContent:"center",marginTop:14},children:[e.jsx("button",{type:"button",className:"btn",onClick:()=>x(h=>!h),children:c?"Pause":"Play"}),e.jsx("button",{type:"button",className:"btn btn-primary",onClick:()=>s(h=>h+1),children:"Next â"})]})]})]})}function re({onLog:n,onBack:t}){const[a,l]=o.useState(0),[r,i]=o.useState(0),[s,c]=o.useState(D[0]),x=o.useRef(Date.now()),u=a%108;function g(){l(p=>{const d=p+1;return d%108===0&&(i(h=>h+1),E()),d}),typeof navigator<"u"&&navigator.vibrate&&navigator.vibrate(8)}function j(){a>0&&n({kind:"japa",duration_s:Math.max(1,Math.round((Date.now()-x.current)/1e3)),count:a,data:{mantra:s}}),t()}return e.jsxs("div",{className:"screen",children:[e.jsx(C,{title:"Japa â mala counter",onBack:t}),e.jsxs("div",{className:"card center",children:[e.jsx("div",{className:"row wrap",style:{justifyContent:"center",marginBottom:16},children:D.map(p=>e.jsx("button",{type:"button",className:`chip${p===s?" active":""}`,onClick:()=>c(p),children:p},p))}),e.jsx("button",{type:"button",className:"japa-bead",onClick:g,"aria-label":"Count one repetition",children:e.jsx(W,{progress:u/108,size:224,stroke:9,children:e.jsxs("div",{className:"japa-dial",children:[e.jsx("span",{className:"japa-num",children:u}),e.jsx("span",{className:"japa-of",children:"of 108"})]})})}),e.jsxs("p",{className:"muted center",style:{marginTop:12},children:["Tap the bead with each repetition of â",s,"â",r>0?` · ${r} mala${r>1?"s":""} complete`:""]}),e.jsxs("div",{className:"row",style:{justifyContent:"center",marginTop:10},children:[e.jsx("button",{type:"button",className:"btn btn-ghost",onClick:()=>{l(0),i(0)},children:"Reset"}),e.jsx("button",{type:"button",className:"btn btn-primary",onClick:j,children:"End & log"})]})]})]})}export{de 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.