1import{j as e,r as t,R as r}from"./vendor-react-BfgFmtGS.js";import{B as a}from"./button-CYJdLL_L.js";import{S as i}from"./slider-BHeJnrnC.js";import{u as n}from"./MoodContext-C3yPuVY1.js";import{a as s}from"./runtime-utils-GN4cODRt.js";import{g as o}from"./image-utils-BFdDQ3hX.js";import{u as l}from"./MusicContext-DlSu8MMY.js";import{V as c,a as u}from"./volume-x-DUBvGFGQ.js";import{u as d}from"./use-mobile-CmledQOG.js";import{s as m}from"./documentVisibilitySubscriptions-CqVNm4Da.js";import{s as h}from"./nativeAppStateSubscriptions-Cv_2m-ZS.js";import{i as f}from"./perfConfig-SmqTTOuO.js";import{u as w}from"./useDocumentVisibility-Df0RjsX7.js";import{a as p}from"./startup-platform-OWIpYyjW.js";import{A as x,m as v}from"./vendor-animation-C4YilBxg.js";import{H as y}from"./heart-CdAafllh.js";import{C as g}from"./chevron-left-BP2GmtNQ.js";import{C as b}from"./chevron-right-aaxqAI6v.js";import{X as j}from"./x-DV2I6wJI.js";import{C as N}from"./clock-BF-8ZufU.js";import{P as k}from"./pause-Bf1g_19A.js";import{P as E}from"./play-Cxv-fZlT.js";const C=({className:t,isHeader:r,hasHeaderImage:a})=>{const{isPlaying:i,isMuted:n,togglePlayback:o}=l(),d=!i||n;return e.jsx("button",{onClick:o,className:s("p-2.5 rounded-full transition-all duration-300 border",r?a?"bg-transparent text-white border-white/40 hover:bg-white/10":"bg-background text-foreground border-border hover:bg-muted":d?"bg-muted/30 border-white/5 text-ink/80 hover:text-ink":"bg-primary/10 border-primary/20 text-primary shadow-sm","hover:scale-105 active:scale-95",t),title:i?n?"Unmute music":"Mute music":"Play music",children:d?e.jsx(c,{className:"w-4 h-4"}):e.jsx(u,{className:"w-4 h-4 animate-pulse"})})};function T({memories:l,isOpen:c,onClose:u,onLike:T,startIndex:M=0}){const L=d(),S=p(),R=w(),[A,P]=t.useState(M),[I,z]=t.useState(!0),[D,H]=t.useState(30),[$,_]=t.useState(!0),[O,V]=t.useState(0),[W,Y]=t.useState([]),q=t.useRef([]),F=t.useRef(new Map),X=t.useRef(new Set),B=t.useRef(null),{activeMood:G}=n(),J=t.useRef(null),K=t.useRef(null),U=l[A],Q=(null==G?void 0:G.primary_color)||"hsl(var(--primary))",Z=null==U?void 0:U.id,ee=r.useMemo(()=>Z?{x:30*(Math.random()-.5),y:20*(Math.random()-.5)}:{x:0,y:0},[Z]),te=t.useCallback(()=>{const e=Date.now()+Math.random(),t=50+Math.random()*(window.innerWidth-100),r=100+Math.random()*(window.innerHeight-300),a={id:e,x:t,y:r,color:Q,rotation:40*Math.random()-20,targetRotation:60*Math.random()-30,targetY:S?-110:-700},i=S?3:9,n=q.current,s=[...n,a].slice(-i),o=new Set(s.map(e=>e.id));n.forEach(e=>{if(o.has(e.id))return;const t=F.current.get(e.id);void 0!==t&&window.clearTimeout(t),F.current.delete(e.id)}),q.current=s,Y(s);const l=window.setTimeout(()=>{F.current.delete(e),q.current=q.current.filter(t=>t.id!==e),Y(q.current)},S?750:4e3);F.current.set(e,l)},[S,Q]),re=t.useCallback(()=>{if(!U)return;const e=S?1:3;for(let t=0;t<e;t++){const e=window.setTimeout(()=>{X.current.delete(e),te()},100*t);X.current.add(e)}T&&T(U.id)},[U,S,T,te]);t.useEffect(()=>{c||(F.current.forEach(e=>window.clearTimeout(e)),F.current.clear(),X.current.forEach(e=>window.clearTimeout(e)),X.current.clear(),q.current=[],Y([]))},[c]),t.useEffect(()=>()=>{F.current.forEach(e=>window.clearTimeout(e)),F.current.clear(),X.current.forEach(e=>window.clearTimeout(e)),X.current.clear(),q.current=[]},[]),t.useEffect(()=>{if(c)return R&&(async()=>{try{if("wakeLock"in navigator){if(B.current)try{await B.current.release()}catch{}B.current=await navigator.wakeLock.request("screen"),B.current.addEventListener("release",()=>{})}}catch(e){}})(),()=>{B.current&&B.current.release().then(()=>{B.current=null}).catch(e=>{})}},[R,c]),t.useEffect(()=>{c&&U&&window.dispatchEvent(new CustomEvent("echoWatched",{detail:{memoryId:U.id}}))},[A,c,U]);const ae=t.useRef(null),ie=t.useCallback(e=>{const t=ae.current;t&&t!==e&&(t.pause(),t.removeAttribute("src"),t.load()),ae.current=e},[]);t.useEffect(()=>{if(!c||!I||l.length<=1||"video"===(null==U?void 0:U.type))return void V(0);const e=1e3*D,t=L?100:50;let r=0,a=performance.now(),i=null;const n=()=>{null===i&&f()&&(i=window.setTimeout(s,t))},s=()=>
1{if(i=null,!f())return;const t=performance.now();r+=Math.max(0,t-a),a=t,V(r/e*100),r>=e?P(e=>(e+1)%l.length):n()},o=()=>{f()?(a=performance.now(),n()):null!==i&&(window.clearTimeout(i),i=null)},u=m(o),d=h(o);return n(),()=>{u(),d(),null!==i&&window.clearTimeout(i)}},[c,I,D,l.length,A,null==U?void 0:U.type,L]),t.useEffect(()=>{let e=!0,t=0,r=null;if("video"===(null==U?void 0:U.type)&&ae.current&&I&&R){const a=ae.current;if(!a.currentSrc&&!a.src)return;const i=async()=>{if(e&&ae.current&&(a.paused||a.ended||!(a.readyState>2)))try{await a.play()}catch(n){if(!e)return;const o=n instanceof Error?n.name:"";if("NotAllowedError"===o){a.muted=!0;try{await a.play()}catch(s){}}else"AbortError"===o&&t<3&&(t++,r=window.setTimeout(()=>{i()},300))}};i()}return()=>{var t;e=!1,null!==r&&window.clearTimeout(r),R||null==(t=ae.current)||t.pause()}},[A,I,U,R]),t.useEffect(()=>()=>{const e=ae.current;e&&(e.pause(),e.removeAttribute("src"),e.load())},[]),t.useEffect(()=>{if(!c)return;const e=e=>{switch(e.key){case"Escape":u();break;case"ArrowLeft":P(e=>(e-1+l.length)%l.length),V(0);break;case"ArrowRight":P(e=>(e+1)%l.length),V(0);break;case" ":e.preventDefault(),z(e=>!e);break;case"l":case"L":re()}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[c,l.length,u,re]),t.useEffect(()=>{if(!c)return;let e,t=null;const r=()=>{_(!0),clearTimeout(e),e=setTimeout(()=>_(!1),3e3)},a=()=>{null===t&&(t=window.requestAnimationFrame(()=>{t=null,r()}))};return window.addEventListener("mousemove",a),window.addEventListener("click",r),window.addEventListener("touchstart",r,{passive:!0}),r(),()=>{window.removeEventListener("mousemove",a),window.removeEventListener("click",r),window.removeEventListener("touchstart",r),null!==t&&window.cancelAnimationFrame(t),clearTimeout(e)}},[c]);const ne=t.useCallback(()=>{P(e=>(e+1)%l.length),V(0)},[l.length]),se=t.useCallback(()=>{P(e=>(e-1+l.length)%l.length),V(0)},[l.length]);return c&&U?e.jsxs("div",{className:"fixed inset-0 z-[100] bg-black flex items-center justify-center overflow-hidden",onTouchStart:e=>{K.current=null,J.current=e.targetTouches[0].clientX},onTouchMove:e=>{K.current=e.targetTouches[0].clientX},onTouchEnd:()=>{const e=J.current,t=K.current;if(J.current=null,K.current=null,null===e||null===t)return;const r=e-t,a=r<-50;r>50?ne():a&&se()},children:[e.jsx(x,{children:W.map(t=>e.jsx(v.div,{initial:{opacity:1,scale:.5,y:0,rotate:t.rotation},animate:{opacity:0,y:t.targetY,scale:S?1.15:2.5,rotate:S?t.rotation:t.targetRotation},exit:{opacity:0},transition:{duration:S?.6:3.5,ease:"easeOut"},className:s("fixed pointer-events-none z-[110]",S?"text-4xl":"text-6xl"),style:{left:t.x,top:t.y,color:t.color,filter:S?void 0:"drop-shadow(0 4px 12px rgba(0,0,0,0.4))"},children:e.jsx(y,{className:S?"h-10 w-10 fill-current":"h-16 w-16 fill-current",strokeWidth:1.7})},t.id))}),e.jsx("div",{className:"w-full h-full flex items-center justify-center p-4 overflow-hidden",children:e.jsx(x,{mode:"wait",children:"video"===U.type&&U.video_url?e.jsx(v.div,{className:"relative w-full h-full flex items-center justify-center bg-black",initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},transition:{duration:.5},children:e.jsx("video",{ref:ie,src:(R||!S)&&o(U.video_url||"")||void 0,className:"max-w-full max-h-full object-contain",crossOrigin:"anonymous",autoPlay:R,playsInline:!0,controls:$,muted:!1,onEnded:ne})},U.id):U.image_url?e.jsx(v.div,{className:"relative w-full h-full flex items-center justify-center overflow-hidden",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.8,ease:"easeInOut"},children:e.jsx(v.img,{src:U.image_url,alt:U.title||U.description||"Echo",className:"max-w-full max-h-full object-contain",initial:{scale:1,x:0,y:0},animate:{scale:S?1:1.08,x:S?0:ee.x,y:S?0:ee.y},transition:{duration:S?.15:D,ease:"linear"}})},U.id):e.jsx(v.div,{className:"max-w-2xl p-8 text-center",initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.5},children:e.jsx("p",{className:"text-2xl text-white/90 leading-relaxed",children:U.content})},U.id)})}),e.jsx("button",{onClick:se,className:s("absolute left-4 top-1/2 -translate-y-1/2 p-4 rounded-full bg-white/10 hover:bg-white/20 transition-all",L&&"hidden",$?"opacity-100":"opacity-0"),children:e.jsx(g,{className:"w-8 h-8 text-white"})}),e.jsx("button",{onClick:ne,className:s("absolute right-4 top-1/2 -translate-y-1/2 p-4 rounded-full bg-white/10 hover:bg-white/20 transition-all",L&&"hidden",$?"opacity-100":"opacity-0"),children:e.jsx(b,{className:"w-8 h-8 text-white"})}),L&&e.jsx("button",{onClick:u,className:"absolute right-4 z-20 flex h-12 w-12 items-center justify-center rounded-full border border-white/15 bg-black/45 text-white shadow-soft backdrop-blur-md",style:{to
1p:"calc(env(safe-area-inset-top, 0px) + 12px)"},"aria-label":"Close cinema view",children:e.jsx(j,{className:"w-5 h-5"})}),e.jsxs("div",{className:s("absolute top-0 left-0 right-0 p-4 flex justify-between items-center bg-gradient-to-b from-black/50 to-transparent transition-opacity",L&&"pr-20 pt-[calc(env(safe-area-inset-top,0px)+12px)]",$?"opacity-100":"opacity-0"),children:[e.jsxs("div",{className:"text-white/70 text-sm font-medium",children:[A+1," / ",l.length]}),!L&&e.jsx(a,{variant:"ghost",size:"icon",onClick:u,className:"text-white hover:bg-white/20",children:e.jsx(j,{className:"w-6 h-6"})})]}),e.jsx("div",{className:s("absolute bottom-0 left-0 right-0 p-6 bg-gradient-to-t from-black/70 to-transparent transition-opacity",$?"opacity-100":"opacity-0"),children:e.jsxs("div",{className:"max-w-xl mx-auto space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-4 px-2",children:[e.jsx(N,{className:"w-4 h-4 text-white/70 shrink-0"}),e.jsx(i,{value:[D],onValueChange:([e])=>H(e),min:3,max:60,step:1,className:"flex-1"}),e.jsx("span",{className:"text-white/70 text-sm font-mono w-12 text-right shrink-0",children:(e=>{if(e>=60){const t=Math.floor(e/60),r=e%60;return r>0?`${t}m ${r}s`:`${t}m`}return`${e}s`})(D)})]}),e.jsxs("div",{className:"flex items-center justify-center gap-6",children:[e.jsx(a,{variant:"ghost",size:"lg",onClick:()=>z(!I),className:"text-white hover:bg-white/20 rounded-full w-14 h-14",children:I?e.jsx(k,{className:"w-7 h-7"}):e.jsx(E,{className:"w-7 h-7"})}),e.jsx("button",{onClick:re,className:"flex h-14 w-14 items-center justify-center rounded-full bg-white/10 transition-all hover:scale-110 hover:bg-white/20 active:scale-95 focus:outline-none focus:ring-0",title:"React (L)",children:e.jsx(y,{className:"h-8 w-8 fill-current",style:{color:Q},strokeWidth:1.7})}),e.jsx("div",{className:"flex items-center justify-center w-14 h-14 rounded-full hover:bg-white/20 transition-all",children:e.jsx(C,{className:"text-white !p-0 !bg-transparent !border-none hover:!bg-transparent"})})]})]})}),e.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-1 bg-white/20",children:e.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${O}%`}})})]}):null}C.displayName="MusicPlayer";export{T as SlideshowMode};
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.