"use strict";(()=>{vare={};e.id=3751,e.ids=[636,3751],e.modules={30671:(e,t)=>{Object.defineProperty(t,"M",{enumerable:!0,get:function(){returnfunctione(t,r){returnrint?t[r]:"then"int&&"function"==typeoft.then?t.then(t=>e(t,r)):"function"==typeoft&&"default"===r?t:void0}}})},76048:(e,t,r)=>{r.r(t),r.d(t,{config:()=>E,default:()=>P,getServerSideProps:()=>v,getStaticPaths:()=>j,getStaticProps:()=>q,reportWebVitals:()=>A,routeModule:()=>w,unstable_getServerProps:()=>N,unstable_getServerSideProps:()=>L,unstable_getStaticParams:()=>k,unstable_getStaticPaths:()=>M,unstable_getStaticProps:()=>D});vars={};r.r(s),r.d(s,{default:()=>y,getServerSideProps:()=>_});vari=r(63865),a=r(9455),n=r(30671),o=r(49407),u=r(68268),l=r(8732),c=r(82015),p=r.n(c),m=r(32415),x=r(87472),d=r(20048),h=r.n(d),f=r(63715),g=r(71457),S=r(67216),b=r.n(S);functiony({user:e,email:t,productionEnvironment:r,existingAlerts:s}){leti="Unsubscribe | Datasquirel",a="Unsubscribe from email alerts",n=(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("title",{children:i}),(0,l.jsx)("meta",{name:"description",content:a}),(0,l.jsx)(x.A,{pageTitle:i,pageDescription:a,pagePathname:"/unsubscribe"})]}),[o,u]=p().useState(!1);return(0,l.jsx)(p().Fragment,{children:(0,l.jsx)(g.A,{head:n,user:e,productionEnvironment:r,children:(0,l.jsx)("main",{children:(0,l.jsxs)("section",{children:[o&&(0,l.jsx)(m.A,{}),(0,l.jsxs)("div",{className:"flex-col",children:[(0,l.jsx)("h1",{className:"text-2xl",children:"Unsubscribe from Email alerts"}),!t&&(0,l.jsxs)("p",{className:"max-w-md",children:["No email please ",(0,l.jsx)("a",{href:"/login",children:"Login"})," ","to Access Email Subscriptions or click on"," ",(0,l.jsx)("i",{children:'"unsubscribe"'})," from your mail box"]}),t&&(0,l.jsxs)("form",{className:"flex flex-col items-start gap-4",onSubmit:r=>{r.preventDefault(),u(!0);lets=r.target;(0,f.A)("/api/unsubscribe",{method:"post",body:{email:t,alerts:s.alerts_checkbox.checked,userId:e?.id?e.id:null}}).then(e=>{console.log(e),u(!1)})},children:[(0,l.jsx)("span",{className:"bg-slate-100 py-1 px-3 rounded-full",children:t}),(0,l.jsxs)("div",{className:"flex items-center gap-1",children:[(0,l.jsx)("input",{type:"checkbox",name:"alerts_checkbox",id:"alerts_checkbox",defaultChecked:!!s,className:"w-6 h-6"}),(0,l.jsx)("label",{htmlFor:"alerts_checkbox",className:"text-base whitespace-nowrap text-slate-800",children:"Alerts"})]}),(0,l.jsx)("button",{children:"Save Settings"})]})]})]})})})})}asyncfunction_({req:e,res:t,query:r}){lets=process.env.DSQL_HOST_ENV,i=awaith()(e,t),a=r.email?r.email:i?.email?i.email:null,n=awaitb()(`SELECT email FROM unsubscribes WHERE email='${a}' AND type='alerts'`);return{props:{user:i,email:a,productionEnvironment:s,existingAlerts:!n[0]}}}letP=(0,n.M)(s,"default"),q=(0,n.M)(s,"getStaticProps"),j=(0,n.M)(s,"getStaticPaths"),v=(0,n.M)(s,"getServerSideProps"),E=(0,n.M)(s,"config"),A=(0,n.M)(s,"reportWebVitals"),D=(0,n.M)(s,"unstable_getStaticProps"),M=(0,n.M)(s,"unstable_getStaticPaths"),k=(0,n.M)(s,"unstable_getStaticParams"),N=(0,n.M)(s,"unstable_getServerProps"),L=(0,n.M)(s,"unstable_getServerSideProps"),w=newi.PagesRouteModule({definition:{kind:a.A.PAGES,page:"/unsubscribe",pathname:"/unsubscribe",bundlePath:"",filename:""},components:{App:u.default,Document:o.default},userland:s})},20048:(e,t,r)=>{r(81630);lets=r(67216),i=r(83007),a=r(29021);asyncfunctionn(e,t,r,n){if(!e.cookies?.datasquirelAuthKey?.match(/./))returnnull;leto=i(e.cookies.datasquirelAuthKey);if(!o)returnnull;letu=JSON.parse(o);if(!u.csrf_k||r&&!e.headers["x-csrf-auth"]?.match(RegExp(`${u.csrf_k}`)))returnnull;letl=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!l)returnconsole.log("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable."),null;if(r&&!a.existsSync(`${l}/${u.csrf_k}`))returnnull;if(0==u.verification_status&&!r){lete=awaits(`SELECT verification_status FROM users WHERE id='${u.id}'`);e&&e[0]&&1==e[0].verification_status&&t.setHeader("Set-Cookie",["user_refresh=1"])}returnu?.date&&Date.now()-u.date>6048e5?null:u}e.exports=n},83007:(e,t,r)=>{