(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[405],{8312:function(e,t,s){(window.__NEXT_P=window.__NEXT_P||[]).push(["/",function(){return s(1690)}])},847:function(e,t,s){"use strict";s.d(t,{Z:function(){return f}});var n=s(5893),i=s(1664),a=s.n(i),r=s(7484),l=s.n(r),c=s(4110),o=s.n(c);l().extend(o());var d=l();function x(e){let{until:t}=e;return t&&new Date(t)>new Date?(0,n.jsx)("span",{className:"boost-badge",children:"?? Boosted"}):null}var h=s(7294);let m=()=>(0,n.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 20 20",fill:"none","aria-hidden":!0,children:(0,n.jsx)("path",{d:"M5 12l5-5 5 5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),u=()=>(0,n.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 20 20",fill:"none","aria-hidden":!0,children:(0,n.jsx)("path",{d:"M15 8l-5 5-5-5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})});function f(e){let{p:t,isOwner:s}=e,[i,r]=(0,h.useState)(t.score);async function l(e){try{let s=await fetch("/api/vote",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({post_id:t.id,value:e})}),n=await s.json().catch(()=>({}));if(!s.ok)throw Error(n.error||"Vote failed");r(n.score)}catch(e){console.error("vote error",e)}}return(0,n.jsxs)("div",{className:"card lift p-5",children:[(0,n.jsxs)("div",{className:"mb-2 flex items-center justify-between text-[12px] text-zinc-500",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{className:"pill bg-zinc-100 capitalize text-zinc-700",children:t.tag}),(0,n.jsx)("span",{children:d(t.created_at).fromNow()}),(0,n.jsx)(x,{until:t.boosted_until||void 0})]}),(0,n.jsxs)(a(),{href:"/p/".concat(t.id),className:"pill bg-zinc-100 text-zinc-700 hover:bg-zinc-200 transition",children:[t.replies_count," ",1===t.replies_count?"reply":"replies"]})]}),(0,n.jsx)(a(),{href:"/p/".concat(t.id),children:(0,n.jsx)("p",{className:"whitespace-pre-wrap break-words text-[15px] leading-relaxed",children:t.body})}),(0,n.jsxs)("div",{className:"mt-3 flex items-center justify-between text-sm",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("button",{onClick:()=>l(1),className:"h-9 w-9 rounded-full bg-zinc-100 hover:bg-zinc-200 inline-flex items-center justify-center transition",children:(0,n.jsx)(m,{})}),(0,n.jsx)("span",{className:"min-w-6 text-center num",children:i}),(0,n.jsx)("button",{onClick:()=>l(-1),className:"h-9 w-9 rounded-full bg-zinc-100 hover:bg-zinc-200 inline-flex items-center justify-center transition",children:(0,n.jsx)(u,{})})]}),s?(0,n.jsx)(a(),{href:"/boost/".concat(t.id),className:"btn-ghost",children:"Boost"}):(0,n.jsx)("span",{})]})]})}},1690:function(e,t,s){"use strict";s.r(t),s.d(t,{default:function(){return h}});var n=s(5893),i=s(9008),a=s.n(i),r=s(7294),l=s(6758);function c(e){let{message:t}=e,[s,i]=(0,r.useState)(!!t);return((0,r.useEffect)(()=>i(!!t),[t]),s&&t)?(0,n.jsx)("div",{className:"fixed bottom-4 left-1/2 -translate-x-1/2 rounded-xl bg-zinc-800 px-4 py-2 text-sm shadow-lg",children:t}):null}let o=[{key:"confession",label:"Confession"},{key:"missed",label:"Missed"},{key:"meme",label:"Meme"},{key:"rant",label:"Rant"}];function d(){let[e,t]=(0,r.useState)(""),[s,i]=(0,r.useState)("confession"),[a,l]=(0,r.useState)(),[d,x]=(0,r.useState)(!1),[h,m]=(0,r.useState)(""),u=e.trim().length,f=u>=3&&u<=500,p=(0,r.useMemo)(()=>{let e=2*Math.PI*18;return{offset:e-Math.min(100,Math.round(u/500*100))/100*e,col:!f&&u>0?"#ef4444":u>440?"#f59e0b":"#10b981"}},[u,f]);async function b(){if(!d&&f){x(!0);try{let n=await fetch("/api/post",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:e,tag:s,website_url:h})}),i=await n.json().catch(()=>({}));if(!n.ok)throw Error(i.error||"Failed");t(""),l("Posted")}catch(e){console.error("submit error",e),l((null==e?void 0:e.message)||"Failed")}finally{x(!1),setTimeout(()=>l(void 0),1800)}}}return(0,n.jsxs)("div",{className:"card p-5 card-grid",children:[(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)("textarea",{value:e,onChange:e=>t(e.target.value),rows:5,maxLength:500,placeholder:"Spill the tea... (3–500 chars)",className:"ring-focus w-full resize-none rounded-xl bg-white/70 p-4 leading-relaxed outline-none placeholder:text-zinc-400"}),(0,n.jsxs)("svg",{width:"44",height:"44",viewBox:"0 0 44 44",className:"absolute bottom-2 right-2",children:[(0,n.jsx)("circle",{cx:"22",cy:"22",r:"18",stroke:"rgba(0,0,0,.08)",strokeWidth:"4",fill:"none"}),(0,n.jsx)("circle",{cx:"22",cy:"22",r:"18",stroke:p.col,strokeWidth:"4",fill:"none",strokeDasharray:2*Math.PI*18,strokeDashoffset:p.offset,strokeLinecap:"round",transform:"rotate(-90 22 22)"}),(0,n.jsx)("text",{x:"22",y:"26",textAnchor:"middle",fontSize:"10",fill:"#52525b",children:u})]})]}),(0,n.jsx)("input",{value:h,onChange:e=>m(e.target.value),className:"hidden",name:"website_url"}),(0,n.jsxs)("div",{className:"mt-3 flex items-center justify-between",children:[(0,n.jsx)("div",{className:"flex gap-2",children:o.map(e=>(0,n.jsx)("button",{onClick:()=>i(e.key),className:"pill text-sm ring-focus ".concat(s===e.key?"bg-zinc-900 text-white":"bg-zinc-100 text-zinc-700 hover:bg-zinc-200"),children:e.label},e.key))}),(0,n.jsx)("button",{onClick:b,disabled:d||!f,className:"btn-brand",children:d?"Posting…":"Post"})]}),(0,n.jsx)(c,{message:a})]})}var x=s(847);function h(){let[e,t]=(0,r.useState)([]),[s,i]=(0,r.useState)(!0);return(0,r.useEffect)(()=>{(async()=>{i(!0);let{data:e,error:s}=await l._.from("posts").select("*").order("created_at",{ascending:!1}).limit(50);!s&&e&&t(e),i(!1)})()},[]),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(a(),{children:[(0,n.jsx)("meta",{charSet:"utf-8"}),(0,n.jsx)("title",{children:"AberSpill"}),(0,n.jsx)("meta",{name:"description",content:"Aberystwyth Uni confessions and missed connections. 100% anonymous."})]}),(0,n.jsxs)("header",{className:"sticky top-0 z-20",children:[(0,n.jsx)("div",{className:"bg-emerald-500 text-emerald-950 text-xs sm:text-sm",children:(0,n.jsx)("div",{className:"container-feed py-1 text-center font-bold tracking-wide",children:"100% Anonymous \xb7 No accounts \xb7 No names \xb7 Unfiltered truths"})}),(0,n.jsx)("div",{className:"border-b border-black/5 bg-white/70 backdrop-blur",children:(0,n.jsx)("div",{className:"container-feed flex items-center justify-between py-4",children:(0,n.jsx)("div",{className:"text-2xl font-extrabold neon-text",children:"AberSpill"})})})]}),(0,n.jsx)("section",{className:"container-feed my-8",children:(0,n.jsxs)("div",{className:"card p-10 text-center relative overflow-hidden",children:[(0,n.jsx)("div",{className:"absolute inset-0 bg-gradient-to-br from-pink-200/40 via-transparent to-emerald-200/40 pointer-events-none"}),(0,n.jsxs)("div",{className:"relative space-y-5",children:[(0,n.jsx)("h1",{className:"text-4xl font-extrabold tracking-tight neon-text",children:"100% ANONYMOUS"}),(0,n.jsxs)("p",{className:"mx-auto max-w-xl text-lg font-semibold text-zinc-700",children:["Confess. Gossip. Rant. Missed connections."," ",(0,n.jsx)("span",{className:"text-pink-600",children:"Spill it all, Aber."})]}),(0,n.jsx)("p",{className:"text-base text-zinc-500 italic",children:"No accounts \xb7 No names \xb7 Unfiltered truths"})]})]})}),(0,n.jsxs)("main",{className:"container-feed space-y-4",children:[(0,n.jsx)(d,{}),s&&(0,n.jsx)("p",{className:"text-sm text-zinc-500",children:"Loading…"}),(0,n.jsx)("div",{className:"space-y-3",children:e.map(e=>(0,n.jsx)(x.Z,{p:e},e.id))})]}),(0,n.jsx)("footer",{className:"container-feed px-4 pb-12 pt-10 text-center text-xs text-zinc-500",children:(0,n.jsxs)("span",{children:["\xa9 ",new Date().getFullYear()," AberSpill"]})})]})}},6758:function(e,t,s){"use strict";s.d(t,{_:function(){return a}});var n=s(1608),i=s(3454);let a=(0,n.eI)("https://mwmofriozxhotgcbhjlb.supabase.co","eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im13bW9mcmlvenhob3RnY2JoamxiIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTg1NzgxNTMsImV4cCI6MjA3NDE1NDE1M30.2hjEVxRRRCXUz_tATtSwzfmDqjgU64-h5bDbuycQfyk",{auth:{persistSession:!1},global:{headers:{"x-client-info":"aberspill"}}});i.env.SUPABASE_SERVICE_ROLE_KEY&&(0,n.eI)("https://mwmofriozxhotgcbhjlb.supabase.co",i.env.SUPABASE_SERVICE_ROLE_KEY)}},function(e){e.O(0,[608,344,888,774,179],function(){return e(e.s=8312)}),_N_E=e.O()}]);