PageSourceSearch

https://myechoboard.com/assets/DraggableMemoryGrid-DcXHxgfa.js

js myechoboard.com collected 2026-09-24 13:50:46 UTC 9,891 bytes, 1 lines download raw bytes

1import{r as e,j as t}from"./vendor-react-C9yDzYQD.js";import{u as r,M as o,T as a,s as n,K as i,a as s,b as d,D as l,c,S as m,r as u,e as f,d as p,C as g}from"./vendor-dnd-CiCtaB0b.js";import{a as h,u as b}from"./vendor-query-DpPswXvj.js";import{a as v}from"./MemoryCard-DJDOd9Hn.js";import{a as x}from"./runtime-utils-GN4cODRt.js";import{supabase as y}from"./supabase-client-_h80EYw_.js";import{g as w}from"./memoryNoteEchoPages-D4iGhN4E.js";import{a as j,b as M}from"./image-utils-AdRSPECl.js";import{b as S,g as C}from"./useUserSettings-COPNty3J.js";import{u as _}from"./useNetworkStatus-pTwuOFZz.js";import{u as k}from"./use-mobile-D5Xf5BKb.js";import{u as N}from"./MoodContext-C8nY2rn-.js";import{u as I}from"./ThemeContext-jMT4gQSB.js";import{u as E}from"./usePerfBudget-B6X6q34-.js";import{b as D}from"./userFilters-Bp32kBo8.js";import{r as P}from"./boundedAsyncPool-BG_N2Lbq.js";import{b as B}from"./echoTypePolicy-DA-PDKiE.js";import{u as L}from"./MemoryFeed-CBvj8dmC.js";import{u as R,i as T,g as z}from"./feedMutationCoordinator-BvkdZE4y.js";import{a as $,u as U}from"./vendor-router-X7RJKav4.js";import{C as q}from"./chevron-up-DmrAct_7.js";import{C as K}from"./chevron-down-BFi_I8Zn.js";const F=120,G=120,O=(e,t)=>e.slice(0,Math.max(1,t)),Q=e.memo(({memory:e,index:r,total:o,onDelete:a,onClick:n,onLike:i,isSelected:s,isSelectionMode:d,onSelect:l,onMoveItem:c,disableDrag:m=!1,preferredBoardId:u,preferredBoardName:f,preferredBoardCanEdit:h,echoPages:b,cardPreferences:y,mutationContext:w,entranceRef:j})=>{const{attributes:M,listeners:S,setNodeRef:C,transform:_,transition:k,isDragging:N}=p({id:e.id,disabled:m}),I=z(e.id,w),E={transform:g.Transform.toString(_),transition:N?void 0:"exiting"===I?"opacity 150ms ease-out, transform 150ms ease-out":k,willChange:_||N?"transform":void 0,contentVisibility:N?"visible":"auto",containIntrinsicSize:"1px 320px"};return t.jsx("div",{ref:C,style:E,...m?{}:M,...m?{}:S,className:x("relative group select-none transition-[opacity,transform] duration-150 ease-out motion-reduce:transition-none",m?"cursor-default":"cursor-grab active:cursor-grabbing",N&&"opacity-40 z-50","exiting"===I&&"pointer-events-none scale-[0.985] opacity-0"),"data-feed-item-id":e.id,"data-feed-mutation-phase":I||void 0,"aria-busy":!!I||void 0,"aria-hidden":"exiting"===I||void 0,..."exiting"===I?{inert:""}:{},children:t.jsxs("div",{ref:j,className:"echo-feed-card-entrance",children:[!d&&!m&&t.jsxs("div",{className:"absolute left-2 bottom-2 z-10 hidden md:flex flex-col gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[t.jsx("button",{onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),c(r,r-1)},disabled:0===r,className:"p-1 rounded-md bg-black/60 backdrop-blur-sm text-white disabled:opacity-30 hover:bg-black/80 transition-colors active:scale-95",title:"Move up",children:t.jsx(q,{className:"w-3 h-3"})}),t.jsx("button",{onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),c(r,r+1)},disabled:r===o-1,className:"p-1 rounded-md bg-black/60 backdrop-blur-sm text-white disabled:opacity-30 hover:bg-black/80 transition-colors active:scale-95",title:"Move down",children:t.jsx(K,{className:"w-3 h-3"})})]}),t.jsx(v,{memory:e,index:r,onDelete:a,onClick:n,onLike:i,isSelected:s,isSelectionMode:d,onSelect:l,preferredBoardId:u,preferredBoardName:f,preferredBoardCanEdit:h,mutationSurfaceId:w.surfaceId,echoPages:b,...y})]})})});Q.displayName="DraggableMemoryItem";const A=({memories:p,onReorder:g,onDelete:v,onClick:z,onLike:q,isSelected:K,isSelectionMode:G,onSelect:A,columns:V=3,gap:H=10,edgePadding:J,isReadOnly:W=!1,selectedIds:X,allowDragInSelectionMode:Y=!1,multiDragEnabled:Z=!1,preferredBoardId:ee,preferredBoardName:te,preferredBoardCanEdit:re=!1,mutationSurfaceId:oe})=>{var ae;const ne=R(),ie=e.useMemo(()=>({boardId:ee||null,surfaceId:oe||null}),[oe,ee]),se=e.useMemo(()=>p.filter(B).filter(e=>!T(e.id,ie)),[ne,p,ie]),[de,le]=e.useState(se),[ce,me]=e.useState(F),[ue,fe]=e.useState(null),pe=h(),{settings:ge}=S(),he=$(),be=U(),{user:ve,profile:xe}=C(),{isOnline:ye,isSlow:we}=_(),je=k(),{activeMood:Me}=N(),Se=I(),{lowEnd:Ce,nativeMobile:_e}=E(),ke=L({scopeKey:`${he.pathname}|${ee||oe||"draggable-board"}`}),Ne=e.useMemo(()=>({showReactButtonSetting:ge.show_react_button,hapticsDisabled:ge.disable_haptics,routePathname:he.pathname,navigateTo:be,authUser:ve,authProfile:xe,isOnline:ye,slowNetwork:we,isMobile:je,activeMoodSetting:Me,themeState:Se,lowEnd:Ce,nativeMobile:_e}),[Me,je,ye,we,he.pathname,Ce,_e,be,xe,ge.disable_haptics,ge.show_react_button,Se,ve]),Ie=e.useRef(!1),Ee=e.useRef(0),De=e.useRef(null);e.useEffect(()=>{if(Ie.current)return;const e=se.map(e=>e.id),t=De.current,r=Date.now();if(t){const n=new Set(e),i=t.length===e.length&&t.every(e=>n.has(e));if(a=e,(o=t).length===a.length&&o.every((e,t)=>e===a[t]))return De.current=null,Ee.current=0,void le(se);if(i&&r<Ee.current)return;De.current=null,Ee.current=0}var o,a;le(se)},[se]),e.useEffect(()=>{me(e=>Math.min(Math.max(F,e),Math.max(F,se.length)))},[se.length]),e.useEffect(()=>{me(F)},[ee]);const Pe=r(o,{activationConstraint:{distance:8}}
1),Be=r(a,{activationConstraint:{delay:_e?240:180,tolerance:_e?14:10}}),Le=r(i,{coordinateGetter:n}),Re=s(..._e?[Be]:[Pe,Be,Le]),Te=e.useCallback(e=>{W||(De.current=e.map(e=>e.id),Ee.current=Date.now()+3e3,g(e.map(e=>e.id)))},[W,g]),ze=e.useCallback((e,t)=>{W||t<0||t>=de.length||le(r=>{const o=d(r,e,t);return Te(o),o})},[Te,W,de.length]),$e=Math.min(5,Math.max(1,V)),Ue=J??H,qe=e.useMemo(()=>O(de,ce),[de,ce]),Ke=e.useMemo(()=>{const e=Array.from({length:$e},()=>[]);return qe.forEach((t,r)=>{e[r%$e].push({memory:t,globalIndex:r})}),e},[qe,$e]),Fe=ue?de.find(e=>e.id===ue):null,Ge=Fe?"video"===Fe.type?j({thumbnailUrl:null==(ae=Fe.metadata)?void 0:ae.thumbnail_url,imageUrl:Fe.image_url,videoUrl:Fe.video_url,size:"medium"}):M(Fe.image_url,"medium"):null,Oe=e.useMemo(()=>qe.filter(e=>"note"===e.type).map(e=>e.id).filter(Boolean).sort(),[qe]),Qe=Oe.join("|"),{data:Ae=new Map}=b({queryKey:["draggable-memory-note-echo-pages",Qe],enabled:Oe.length>0&&!_e&&!ue,staleTime:12e4,queryFn:async()=>{const e=D(Oe,100),t=[];await P(e,2,async e=>{let{data:r,error:o}=await y.from("memory_notes").select("id, memory_id, content, created_at, metadata").in("memory_id",e).is("parent_note_id",null).order("created_at",{ascending:!0});if(o&&("PGRST204"===o.code||"42703"===o.code||String(o.message||"").toLowerCase().includes("metadata"))){const t=await y.from("memory_notes").select("id, memory_id, content, created_at").in("memory_id",e).is("parent_note_id",null).order("created_at",{ascending:!0});r=t.data,o=t.error}if(o)throw o;t.push(...r||[])});const r=new Map;t.forEach(e=>{e.memory_id&&r.set(e.memory_id,[...r.get(e.memory_id)||[],e])});const o=new Map;return r.forEach((e,t)=>{o.set(t,w(e))}),o}});return e.useEffect(()=>{if(_e)return;const e=new Set(Oe),t=t=>{if(Ie.current)return;const r=t.detail;(null==r?void 0:r.memoryId)&&!e.has(r.memoryId)||pe.invalidateQueries({queryKey:["draggable-memory-note-echo-pages"]})};return window.addEventListener("memory-note-added",t),window.addEventListener("memory-note-updated",t),()=>{window.removeEventListener("memory-note-added",t),window.removeEventListener("memory-note-updated",t)}},[Oe,Qe,_e,pe]),t.jsxs(l,{sensors:Re,collisionDetection:c,onDragStart:e=>{W||(Ie.current=!0,fe(e.active.id))},onDragEnd:e=>{Ie.current=!1,fe(null);const{active:t,over:r}=e;r&&t.id!==r.id&&le(e=>{const o=String(t.id),a=String(r.id),n=e.findIndex(e=>e.id===o),i=e.findIndex(e=>e.id===a);if(-1===n||-1===i)return e;const s=!!(null==X?void 0:X.has(o));if(!(Z&&s&&X&&X.size>1)){const t=d(e,n,i);return Te(t),t}const l=X,c=e.filter(e=>l.has(e.id)),m=e.filter(e=>!l.has(e.id));if(0===c.length||0===m.length)return e;let u=m.findIndex(e=>e.id===a);if(-1===u){const t=e.slice(0,i).filter(e=>l.has(e.id)).length;u=Math.max(0,i-t)}const f=[...m.slice(0,u),...c,...m.slice(u)];return Te(f),f})},onDragCancel:()=>{Ie.current=!1,fe(null)},children:[t.jsxs(m,{items:de.map(e=>e.id),strategy:u,children:[t.jsx("div",{className:"flex items-start w-full",style:{gap:`${H}px`,paddingTop:`${Ue}px`,paddingLeft:`${Ue}px`,paddingRight:`${Ue}px`},children:Ke.map((e,r)=>t.jsx("div",{className:"flex-1 min-w-0 flex flex-col",style:{gap:`${H}px`},children:e.map(({memory:e,globalIndex:r})=>t.jsx(Q,{memory:e,index:r,total:de.length,onDelete:v,onClick:z,onLike:q,isSelected:null==K?void 0:K(e.id),isSelectionMode:G,onSelect:A,onMoveItem:ze,disableDrag:W||!!G&&!Y,preferredBoardId:ee,preferredBoardName:te,preferredBoardCanEdit:re,echoPages:Ae.get(e.id),cardPreferences:Ne,mutationContext:ie,entranceRef:ke(e.id)},e.id))},r))}),qe.length<de.length?t.jsx("div",{className:"flex justify-center px-4 py-6",children:t.jsxs("button",{type:"button",className:"min-h-11 rounded-full border border-border bg-background px-5 text-sm font-semibold hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>me(e=>Math.min(de.length,e+120)),children:["Load more echoes (",de.length-qe.length," remaining)"]})}):null]}),t.jsx(f,{adjustScale:!1,children:Fe?t.jsxs("div",{className:x("relative w-48 max-w-[42vw] cursor-grabbing overflow-hidden rounded-2xl border border-white/15 bg-card/95 opacity-95",_e?"shadow-sm":"shadow-2xl rotate-1 scale-[1.02]"),children:[Ge?t.jsx("img",{src:Ge,alt:"",draggable:!1,
1className:"block max-h-64 w-full object-cover",decoding:"async"}):t.jsx("div",{className:"flex min-h-28 items-center justify-center p-4 text-center text-sm font-semibold",children:Fe.title||Fe.content||"Echo"}),(null==X?void 0:X.has(Fe.id))&&X.size>1&&t.jsxs("div",{className:"absolute right-2 top-2 rounded-full bg-black/75 px-2 py-1 text-xs font-bold text-white backdrop-blur-sm",children:[X.size," echoes"]})]}):null})]})};export{A as DraggableMemoryGrid,F as MANUAL_GRID_INITIAL_WINDOW,G as MANUAL_GRID_WINDOW_STEP,O as getBoundedSortableItems};

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.