PhotoGalleryModal-7bggvmMY.js 3.5 KB

1
  1. import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,k as n,w as r}from"./client-Bw3urp1w.js";import{t as i}from"./chevron-right-CvxYuARt.js";import{t as a}from"./chevron-left-BP2Jil2b.js";import{t as o}from"./download-C4eI6RUv.js";import{t as s}from"./trash-2-ByYJ3UBe.js";import{t as c}from"./x-D4CM9tS6.js";import{t as l}from"./Button-B9_qjR81.js";import{t as u}from"./ConfirmModal-fFY-Pxek.js";var d=e(n(),1),f=r();function p(e){let{archiveName:n,photos:r,initialIndex:p,onClose:m,onDelete:h}=e,[g,_]=(0,d.useState)(()=>Math.min(Math.max(p??0,0),Math.max(r.length-1,0))),[v,y]=(0,d.useState)(!1);if((0,d.useEffect)(()=>{if(v)return;let e=e=>{e.key===`Escape`&&m(),e.key===`ArrowLeft`&&_(e=>Math.max(0,e-1)),e.key===`ArrowRight`&&_(e=>Math.min(r.length-1,e+1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[m,r.length,v]),(0,d.useEffect)(()=>{g>=r.length&&_(Math.max(0,r.length-1))},[r.length,g]),r.length===0)return m(),null;let b=n=>e.getPhotoUrl?e.getPhotoUrl(n):t.getArchivePhotoUrl(e.archiveId,n),x=r[g],S=b(x);return(0,f.jsxs)(`div`,{className:`fixed inset-0 bg-black/90 flex items-center justify-center z-50`,onClick:e=>{e.stopPropagation(),m()},children:[(0,f.jsxs)(`div`,{className:`relative w-full h-full flex flex-col`,onClick:e=>e.stopPropagation(),children:[(0,f.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 bg-black/50`,children:[(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:n}),(0,f.jsxs)(`p`,{className:`text-sm text-bambu-gray`,children:[`Photo `,g+1,` of `,r.length]})]}),(0,f.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,f.jsxs)(l,{variant:`secondary`,size:`sm`,onClick:()=>{let e=document.createElement(`a`);e.href=S,e.download=`${n}_photo_${g+1}.jpg`,e.click()},children:[(0,f.jsx)(o,{className:`w-4 h-4`}),`Download`]}),h&&(0,f.jsx)(l,{variant:`secondary`,size:`sm`,onClick:()=>{h&&y(!0)},className:`text-red-400 hover:text-red-300`,children:(0,f.jsx)(s,{className:`w-4 h-4`})}),(0,f.jsx)(`button`,{onClick:m,className:`p-2 text-bambu-gray hover:text-white transition-colors`,children:(0,f.jsx)(c,{className:`w-6 h-6`})})]})]}),(0,f.jsxs)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center p-4 relative overflow-hidden`,children:[g>0&&(0,f.jsx)(`button`,{onClick:()=>_(e=>e-1),className:`absolute left-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors`,children:(0,f.jsx)(a,{className:`w-8 h-8 text-white`})}),(0,f.jsx)(`img`,{src:S,alt:`Photo ${g+1}`,className:`max-w-full max-h-full object-contain rounded-lg`,style:{maxHeight:`calc(100vh - 200px)`}}),g<r.length-1&&(0,f.jsx)(`button`,{onClick:()=>_(e=>e+1),className:`absolute right-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors`,children:(0,f.jsx)(i,{className:`w-8 h-8 text-white`})})]}),r.length>1&&(0,f.jsx)(`div`,{className:`flex justify-center gap-2 p-4 bg-black/50`,children:r.map((e,t)=>(0,f.jsx)(`button`,{onClick:()=>_(t),className:`w-16 h-16 rounded-lg overflow-hidden border-2 transition-colors ${t===g?`border-bambu-green`:`border-transparent hover:border-bambu-gray`}`,children:(0,f.jsx)(`img`,{src:b(e),alt:`Thumbnail ${t+1}`,className:`w-full h-full object-cover`})},e))})]}),v&&(0,f.jsx)(`div`,{onClick:e=>e.stopPropagation(),children:(0,f.jsx)(u,{title:`Delete Photo`,message:`Delete this photo? This cannot be undone.`,confirmText:`Delete`,variant:`danger`,onConfirm:()=>{h?.(x),y(!1)},onCancel:()=>y(!1)})})]})}export{p as t};