1import{j as e}from"./index-jKTyR-Oz.js";import{f as _,b as a}from"./vendor-react-Cipdfa8D.js";import{i as S,e as y,G as C,a as d}from"./BlobImage-CyV_QrJF.js";import{E}from"./eye-B4L6KDIW.js";import{E as G}from"./external-link-CEmV19Jp.js";const b="gg-guest-claim-token";function L(){const{token:l}=_(),[s,j]=a.useState(null),[N,w]=a.useState(!1),[r,n]=a.useState(null);S(()=>n(null),r!==null);const[i,v]=a.useState(localStorage.getItem("gg-guest-name")||""),[x,h]=a.useState(""),[g,p]=a.useState(!1),[u,o]=a.useState(""),m=localStorage.getItem(b)||"";function c(){const t=m?`?guest_token=${encodeURIComponent(m)}`:"";d.get(`/share/${l}/${t}`).then(j).catch(()=>w(!0))}a.useEffect(c,[l]);async function f(){if(!(!r||i.trim().length<2)){p(!0),o("");try{const t=await d.post(`/share/${l}/claim/`,{item_id:r.id,guest_name:i.trim(),guest_email:x.trim(),guest_token:m});localStorage.setItem(b,t.guest_token),localStorage.setItem("gg-guest-name",i.trim()),n(null),h(""),c()}catch(t){o(t?.data?.error||"Could not claim that â try again?")}finally{p(!1)}}}async function k(t){try{await d.post(`/share/${l}/claim/`,{item_id:t.id,guest_token:m,release:!0}),c()}catch{o("Could not release that one")}}return N?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-primary-50/40 p-6 text-center",children:e.jsxs("div",{children:[e.jsx("p",{className:"text-4xl",children:"ð"}),e.jsx("p",{className:"mt-2 font-display text-lg text-gray-700",children:"This list is no longer shared."}),e.jsx("a",{href:"https://giftgambit.com",className:"mt-2 inline-block text-primary-600",children:"Make your own on GiftGambit â"})]})}):s?e.jsxs("div",{className:"min-h-screen bg-primary-50/40",children:[e.jsxs("div",{className:"bg-gradient-to-r from-primary-700 via-primary-600 to-rose-500 px-4 py-10 text-center text-white",children:[s.photo&&e.jsx("img",{src:s.photo,alt:"",className:"mx-auto mb-3 h-20 w-20 rounded-full object-cover ring-4 ring-white/30"}),e.jsxs("h1",{className:"font-display text-3xl font-semibold",children:[s.display_name,"'s Wishlist"]}),e.jsxs("p",{className:"mt-1 text-white/80",children:["shared from ",s.circle_name," on GiftGambit"]})]}),e.jsxs("div",{className:"mx-auto max-w-2xl space-y-3 px-4 py-8",children:[s.owner_view&&e.jsxs("div",{className:"flex items-start gap-3 rounded-2xl bg-amber-50 p-4 text-sm text-amber-900 ring-1 ring-amber-200",children:[e.jsx(E,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsx("p",{children:"This is your own list, so we're hiding what's been claimed â no spoiling your own surprises. Your family will see the claim buttons."})]}),s.can_claim&&s.items.length>0&&e.jsxs("p",{className:"pb-1 text-center text-sm text-gray-500",children:["Grabbing one? Tap ",e.jsx("strong",{children:"I'll get this"})," so nobody doubles up. No account needed."]}),s.items.length===0&&e.jsx("p",{className:"py-10 text-center text-gray-400",children:"Nothing on the list yet â check back soon ð"}),s.items.map(t=>e.jsxs("div",{className:`flex gap-4 rounded-3xl p-4 shadow-sm ring-1 transition-colors ${t.claimed?"bg-gray-50 ring-gray-200":"bg-white ring-primary-100/70"}`,children:[t.photo&&e.jsx("img",{src:t.photo,alt:"",className:`h-16 w-16 shrink-0 rounded-2xl object-cover ${t.claimed?"opacity-60":""}`}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:`font-display font-medium ${t.claimed?"text-gray-500":"text-gray-900"}`,children:t.title}),t.description&&e.jsx("p",{className:"mt-0.5 line-clamp-2 text-sm text-gray-500",children:t.description}),e.jsxs("p",{className:"mt-1 flex flex-wrap items-center gap-3 text-sm text-gray-500",children:[t.price_estimate&&e.jsxs("span",{children:[t.price_estimate," ",t.currency]}),t.external_url&&e.jsxs("a",{href:t.external_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-primary-600 hover:text-primary-800",children:[e.jsx(G,{className:"h-3.5 w-3.5"})," View"]})]}),s.can_claim&&e.jsx("div",{className:"mt-2",children:t.claimed_by_me?e.jsxs("button",{onClick:()=>k(t),className:"inline-flex items-center gap-1.5 rounded-full bg-teal-100 px-3 py-1 text-sm font-medium text-teal-800 hover:bg-teal-200",children:[e.jsx(y,{className:"h-3.5 w-3.5"}),"You're getting this â tap to undo"]}):t.claimed?e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-gray-200 px-3 py-1 text-sm text-gray-600",children:[e.jsx(y,{className:"h-3.5 w-3.5"}),"Someone's got this one"]}):e.jsx("button",{onClick:()=>{n(t),o("")},className:"rounded-full bg-primary-600 px-3 py-1 text-sm font-medium text-white hover:bg-primary-700",children:"I'll get this"})})]})]},t.id)),e.jsxs("div",{className:"mt-8 rounded-3xl bg-gradient-to-r from-primary-600 to-rose-500 p-6 text-center text-white shadow-md",children:[e.jsx(C,{className:"mx-auto h-8 w-8"}),e.jsx("p",{className:"mt-2 font-display text-lg font-semibold",children:"Coordinate gifts without spoiling surprises"}),e.jsx("p",{className:"mt-1 text-sm text-white/85",children:"GiftGambit keeps wishlists, claims and Secret Santa draws in one place â free for families."}),s.invite_code?e.jsxs("div",{className:"mt-4",children:[e.jsxs("p",{className:"text-sm text-white/85",children:["Join ",s.circle_name," with code"]}),e.jsx("p",{className:"mt-1 font-mono text-2xl font-bold tracking-widest",children:s.inv
1ite_code}),e.jsx("a",{href:"https://app.giftgambit.com/auth/login?mode=signup",className:"mt-3 inline-block rounded-full bg-white px-5 py-2 font-medium text-primary-700 shadow hover:bg-primary-50",children:"Sign up & join"})]}):e.jsx("a",{href:"https://giftgambit.com",className:"mt-4 inline-block rounded-full bg-white px-5 py-2 font-medium text-primary-700 shadow hover:bg-primary-50",children:"Get started free"})]})]}),r&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-end justify-center bg-black/40 p-0 sm:items-center sm:p-4 pb-[calc(1rem+env(safe-area-inset-bottom))]",children:e.jsxs("div",{className:"w-full max-w-md rounded-t-3xl bg-white p-5 shadow-xl sm:rounded-3xl",children:[e.jsxs("p",{className:"font-display text-lg font-semibold text-gray-900",children:[`You're getting "`,r.title,'"']}),e.jsxs("p",{className:"mt-1 text-sm text-gray-500",children:["Just your name, so ",s.display_name," can say thank you. No account needed."]}),e.jsx("input",{autoFocus:!0,value:i,onChange:t=>v(t.target.value),onKeyDown:t=>{t.key==="Enter"&&f()},placeholder:"Your name",className:"mt-3 h-11 w-full rounded-xl border border-gray-300 px-3"}),e.jsx("input",{value:x,onChange:t=>h(t.target.value),placeholder:"Email (optional â for a reminder before the day)",className:"mt-2 h-11 w-full rounded-xl border border-gray-300 px-3 text-sm"}),e.jsx("p",{className:"mt-1.5 text-xs text-gray-400",children:"We'll only ever email you about this gift. No marketing, no sharing your details â ever."}),u&&e.jsx("p",{className:"mt-2 rounded-lg bg-red-50 p-2 text-sm text-red-600",children:u}),e.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[e.jsx("button",{onClick:()=>n(null),className:"rounded-full px-4 py-2 text-sm text-gray-500 hover:bg-gray-100",children:"Cancel"}),e.jsx("button",{onClick:f,disabled:g||i.trim().length<2,className:"rounded-full bg-primary-600 px-5 py-2 text-sm font-medium text-white hover:bg-primary-700 disabled:opacity-50",children:g?"Savingâ¦":"I'll get this"})]})]})})]}):e.jsx("div",{className:"flex min-h-screen items-center justify-center text-gray-400",children:"Loadingâ¦"})}export{L as SharedWishlistPage};
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.