1import{D as I,I as G,f as M,q as e}from"./index-D10rljXA.js";import{i as W,k as F,h as o}from"./react-vendor-BDGRZpCk.js";import"./firebase-B1bfOdnZ.js";import{A as N}from"./ArtworkCard-6wt1LtMq.js";const L=["G","T","M","E"],k=24;function K(){const{currentUser:c}=I(),p=W(),{t}=G(),[B,C]=F(),S=B.get("tab")==="mine"?"mine":"browse",[n,w]=o.useState(S),[u,f]=o.useState([]),[m,y]=o.useState(!0),[g,h]=o.useState(null),[A,R]=o.useState(!1),[x,b]=o.useState(0),[i,v]=o.useState(""),[l,z]=o.useState("newest"),j=o.useCallback(async(r=!0)=>{y(!0),h(null);const d=r?0:x;try{let s;s=await M("/api/gallery",{rating:i||void 0,sort:l,limit:k,offset:d,mine:n==="mine"?"true":void 0}),f(r?s:E=>[...E,...s]),R(s.length===k),b(d+s.length)}catch(s){h(s.message)}finally{y(!1)}},[n,i,l,x]);o.useEffect(()=>{j(!0)},[n,i,l,c]);function T(r){w(r),C(r==="mine"?{tab:"mine"}:{}),b(0)}return e.jsxs("div",{style:{maxWidth:1600,margin:"0 auto",padding:"2rem 1.5rem"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-end",marginBottom:"1.5rem",flexWrap:"wrap",gap:"1rem"},children:[e.jsxs("div",{children:[e.jsxs("h1",{style:{fontSize:"1.6rem",fontWeight:700,margin:"0 0 0.25rem"},children:["ð¨ ",t("gallery.title")]}),e.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-muted)",margin:0},children:t("gallery.subtitle")})]}),c&&e.jsx("button",{onClick:()=>p("/gallery/new"),style:a.uploadBtn,children:t("gallery.upload")})]}),e.jsx("div",{style:{display:"flex",gap:"0.25rem",marginBottom:"1.25rem",borderBottom:"1px solid var(--border)",paddingBottom:"0"},children:[{key:"browse",label:t("gallery.browseAll")},...c?[{key:"mine",label:t("gallery.myGallery")}]:[]].map(({key:r,label:d})=>e.jsx("button",{onClick:()=>T(r),style:{...a.tabBtn,...n===r?a.tabBtnActive:{}},children:d},r))}),n==="browse"&&e.jsxs("div",{style:{display:"flex",gap:"0.75rem",marginBottom:"1.5rem",flexWrap:"wrap"},children:[e.jsxs("div",{style:{display:"flex",gap:"0.35rem"},children:[e.jsx("button",{onClick:()=>v(""),style:{...a.filterChip,...i===""?a.filterChipActive:{}},children:t("gallery.allRatings")}),L.map(r=>e.jsx("button",{onClick:()=>v(i===r?"":r),style:{...a.filterChip,...i===r?a.filterChipActive:{}},children:r},r))]}),e.jsxs("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"0.5rem"},children:[e.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-muted)"},children:t("gallery.sort")}),["newest","kudos"].map(r=>e.jsx("button",{onClick:()=>z(r),style:{...a.filterChip,...l===r?a.filterChipActive:{}},children:t(r==="kudos"?"gallery.mostLoved":"gallery.newest")},r))]})]}),n==="mine"&&e.jsx("div",{style:{marginBottom:"1rem",display:"flex",gap:"0.75rem"},children:e.jsx("button",{onClick:()=>p("/gallery/my"),style:a.manageBtn,children:t("gallery.manage")})}),g&&e.jsxs("div",{style:{color:"#fca5a5",padding:"1rem"},children:["â ",g]}),!m&&!g&&u.length===0&&e.jsx("div",{style:{textAlign:"center",padding:"4rem 1rem",color:"var(--text-muted)"},children:t(n==="mine"?"gallery.noArtwork":"gallery.noResults")}),e.jsx("div",{className:"sm-gallery-grid",style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(280px, 1fr))",gap:"1rem"},children:u.map(r=>e.jsx(N,{artwork:r,showStatus:n==="mine"},r.id))}),m&&e.jsx("div",{className:"spinner-wrap",children:e.jsx("div",{className:"spinner"})}),!m&&A&&e.jsx("div",{style:{textAlign:"center",marginTop:"2rem"},children:e.jsx("button",{onClick:()=>
1j(!1),style:a.loadMoreBtn,children:t("gallery.loadMore")})})]})}const a={uploadBtn:{padding:"0.5rem 1.1rem",borderRadius:8,background:"var(--accent)",color:"#fff",border:"none",cursor:"pointer",fontSize:"0.875rem",fontWeight:600,fontFamily:"inherit"},tabBtn:{padding:"0.55rem 1rem",background:"none",border:"none",borderBottom:"2px solid transparent",cursor:"pointer",fontSize:"0.875rem",fontWeight:500,color:"var(--text-secondary)",fontFamily:"inherit",marginBottom:"-1px",transition:"color 0.15s, border-color 0.15s"},tabBtnActive:{color:"var(--accent-light)",borderBottomColor:"var(--accent-light)"},filterChip:{padding:"0.3rem 0.75rem",borderRadius:999,border:"1px solid var(--border)",background:"transparent",cursor:"pointer",fontSize:"0.78rem",color:"var(--text-secondary)",fontFamily:"inherit",transition:"border-color 0.15s, background 0.15s"},filterChipActive:{background:"var(--accent-dim)",borderColor:"var(--border-accent)",color:"var(--accent-light)"},manageBtn:{background:"none",border:"1px solid var(--border)",borderRadius:8,padding:"0.4rem 0.85rem",cursor:"pointer",fontSize:"0.82rem",color:"var(--accent-light)",fontFamily:"inherit"},loadMoreBtn:{padding:"0.55rem 1.5rem",borderRadius:8,border:"1px solid var(--border)",background:"transparent",cursor:"pointer",color:"var(--text-secondary)",fontSize:"0.875rem",fontFamily:"inherit"}};export{K 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.