1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[704],{40704:(e,s,t)=>{t.d(s,{F:()=>E});var a=t(95155),r=t(48173),l=t.n(r),i=t(14085),o=t(12115),n=t(69962),d=t(4683),c=t(12472),m=t(53474),u=t(22783),h=t(21354),f=t(689),x=t(87936),p=t(80937),g=t(15325),v=t(27193),w=t(81703),j=t(29602);let y=p.bL,N=p.l9;p.YJ,p.ZL,p.Pb,p.z6,o.forwardRef((e,s)=>{let{className:t,inset:r,children:l,...i}=e;return(0,a.jsxs)(p.ZP,{ref:s,className:(0,j.cn)("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",r&&"pl-8",t),...i,children:[l,(0,a.jsx)(g.A,{className:"ml-auto h-4 w-4"})]})}).displayName=p.ZP.displayName,o.forwardRef((e,s)=>{let{className:t,...r}=e;return(0,a.jsx)(p.G5,{ref:s,className:(0,j.cn)("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in data-[side=bottom]:slide-in-from-top-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1",t),...r})}).displayName=p.G5.displayName;let b=o.forwardRef((e,s)=>{let{className:t,sideOffset:r=4,...l}=e;return(0,a.jsx)(p.ZL,{children:(0,a.jsx)(p.UC,{ref:s,sideOffset:r,className:(0,j.cn)("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...l})})});b.displayName=p.UC.displayName;let A=o.forwardRef((e,s)=>{let{className:t,inset:r,...l}=e;return(0,a.jsx)(p.q7,{ref:s,className:(0,j.cn)("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",r&&"pl-8",t),...l})});A.displayName=p.q7.displayName,o.forwardRef((e,s)=>{let{className:t,children:r,checked:l,...i}=e;return(0,a.jsxs)(p.H_,{ref:s,className:(0,j.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),checked:l,...i,children:[(0,a.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,a.jsx)(p.VF,{children:(0,a.jsx)(v.A,{className:"h-4 w-4"})})}),r]})}).displayName=p.H_.displayName,o.forwardRef((e,s)=>{let{className:t,children:r,...l}=e;return(0,a.jsxs)(p.hN,{ref:s,className:(0,j.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...l,children:[(0,a.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,a.jsx)(p.VF,{children:(0,a.jsx)(w.A,{className:"h-2 w-2 fill-current"})})}),r]})}).displayName=p.hN.displayName;let S=o.forwardRef((e,s)=>{let{className:t,inset:r,...l}=e;return(0,a.jsx)(p.JU,{ref:s,className:(0,j.cn)("px-2 py-1.5 text-sm font-semibold",r&&"pl-8",t),...l})});S.displayName=p.JU.displayName;let k=o.forwardRef((e,s)=>{let{className:t,...r}=e;return(0,a.jsx)(p.wv,{ref:s,className:(0,j.cn)("-mx-1 my-1 h-px bg-muted",t),...r})});k.displayName=p.wv.displayName;var _=t(6888),C=t(63898),z=t(27928),P=t(7088);let R=[{name:"Hackathons",href:"/hackathons"},{name:"Quizzes",href:"/quizzes"},{name:"Protocols",href:"/protocols"},{name:"About",href:"/about"},{name:"Blog",href:"/blog"}];function E(){let[e,s]=(0,o.useState)(!1),[t,r]=(0,o.useState)(!1),{user:p,logout:g}=(0,_.A)(),[v,w]=(0,o.useState)(!1);(0,o.useEffect)(()=>{!async function(){(null==p?void 0:p.id)&&w(await z.A.isProtocolAdmin(p.id))}()},[p]);let j=async()=>{r(!0);try{await g()}finally{r(!1)}};return(0,a.jsxs)("nav",{className:"fixed top-0 z-50 w-full border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60",children:[(0,a.jsx)("div",{className:"mx-auto max-w-7xl px-4 sm:px-6 lg:px-8",children:(0,a.jsxs)("div",{className:"flex h-16 items-center justify-between",children:[(0,a.jsx)("div",{className:"flex items-center",children:(0,a.jsx)(l(),{href:"/",className:"flex items-center space-x-2",children:(0,a.jsx)("span",{className:"text-xl font-bold text-primary",children:"OpenQuest"})})}),(0,a.jsx)("div",{className:"hidden md:block",children:(0,a.jsx)("div",{className:"ml-10 flex items-center space-x-4",children:R.map(e=>(0,a.jsx)(l(),{href:e.href,className:"rounded-md px-3 py-2 text-sm font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground",children:e.name},e.name))})}),(0,a.jsx)("div",{className:"hidden md:block",children:(0,a.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,a.jsx)(P.k,{}),p?(0,a.jsxs)(a.Fragment,{children:[v?(0,a.jsx)(i.$,{variant:"ghost",size:"sm",asChild:!0,children:(0,a.jsxs)(l(),{href:"/admin",children:[(0,a.jsx)(n.A,{className:"mr-2 h-4 w-4"}),"Admin Dashboard"]})}):(0,a.jsx)(i.$,{variant:"ghost",size:"sm",asChild:!0,children:(0,a.jsxs)(l(),{href:"/protocols/new",children:[(0,a.jsx)(d.A,{className:"mr-2 h-4 w-4"}),"Create Protocol"]})}),(0,a.jsxs)(y,{children:[(0,a.jsx)(N,{asChild:!0,children:(0,a.jsx)(i.$,{variant:"ghost",size:"sm",children:(0,a.jsx)(C.eu,{children:(0,a.jsx)(C.q5,{children:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return e.split(" ").map(e=>e[0]).join("").toUpperCase()}(p.username)})})})}),(0,a.jsxs)(b,{align:"end",children:[(0,a.jsx)(S,{children:(0,a.jsxs)("div",{className:"flex flex-col space-y-1",children:[(0,a.jsx)("p",{className:"text-sm font-medium leading-none",children:p.username}),(0,a.jsx)("p",{className:"text-xs leading-none text-muted-foreground",children:p.email})]})}),(0,a.jsx)(k,{}),(0,a.jsx)(A,{asChild:!0,children:(0,a.jsxs)(l(),{href:"/profile",children:[(0,a.jsx)(c.A,{className:"mr-2 h-4 w-4"}),"Profile"]})}),(0,a.jsx)(A,{asChild:!0,children:(0,a.jsxs)(l(),{href:"/settings",children:[(0,a.jsx)(m.A,{className:"mr-2 h-4 w-4"}),"Settings"]})}),(0,a.jsx)(k,{}),(0,a.jsxs)(A,{onClick:j,disabled:t,children:[t?(0,a.jsx)(u.A,{className:"mr-2 h-4 w-4 animate-spin"}):(0,a.jsx)(h.A,{className:"mr-2 h-4 w-4"}),t?"Logging out...":"Log out"]})]})]})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(i.$,{variant:"ghost",asChild:!0,children:(0,a.jsx)(l(),{href:"/login",children:"Log in"})}),(0,a.jsx)(i.$,{asChild:!0,children:(0,a.jsx)(l(),{href:"/register",children:"Sign up"})})]})]})}),(0,a.jsx)("div",{className:"flex md:hidden",children:(0,a.jsxs)(i.$,{variant:"ghost",size:"sm",onClick:()=>s(!e),className:"inline-flex items-center justify-center",children:[(0,a.jsx)("span",{className:"sr-only",children:"Open main menu"}),e?(0,a.jsx)(f.A,{className:"h-6 w-6"}):(0,a.jsx)(x.A,{className:"h-6 w-6"})]})})]})}),e&&(0,a.jsx)("div",{className:"md:hidden",children:(0,a.jsxs)("div",{className:"space-y-1 px-2 pb-3 pt-2",children:[R.map(e=>(0,a.jsx)(l(),{href:e.href,className:"block rounded-md px-3 py-2 text-base font-medium text-muted-foreground hover:bg-accent hover:text-accent-foreground",children:e.name},e.name)),(0,a.jsxs)("div",{className:"mt-4 space-y-2 px-3",children:[(0,a.jsx)(P.k,{}),p?(0,a.jsxs)(a.Fragment,{children:[v?(0,a.jsx)(i.$,{variant:"ghost",asChild:!0,className:"w-full justify-start",children:(0,a.jsxs)(l(),{href:"/admin",children:[(0,a.jsx)(n.A,{className:"mr-2 h-4 w-4"}),"Admin Dashboard"]})}):(0,a.jsx)(i.$,{variant:"ghost",asChild:!0,className:"w-full justify-start",children:(0,a.jsxs)(l(),{href:"/protocols/new",children:[(0,a.jsx)(d.A,{className:"mr-2 h-4 w-4"}),"Create Protocol"]})}),(0,a.jsxs)("div",{className:"space-y-1 pt-2",children:[(0,a.jsxs)("div",{className:"px-3",children:[(0,a.jsx)("p",{className:"text-sm font-medium",children:null==p?void 0:p.username}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:null==p?void 0:p.email})]}),(0,a.jsx)(i.$,{variant:"ghost",asChild:!0,className:"w-full justify-start",children:(0,a.jsxs)(l(),{href:"/profile",children:[(0,a.jsx)(c.A,{className:"mr-2 h-4 w-4"}),"Profile"]})}),(0,a.jsx)(i.$,{variant:"ghost",asChild:!0,className:"w-full justify-start",children:(0,a.jsxs)(l(),{href:"/settings",children:[(0,a.jsx)(m.A,{className:"mr-2 h-4 w-4"}),"Settings"]})}),(0,a.jsxs)(i.$,{variant:"ghost",className:"w-full justify-start text-destructive",children:[(0,a.jsx)(h.A,{className:"mr-2 h-4 w-4"}),"Log out"]})]})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(i.$,{variant:"ghost",asChild:!0,className:"w-full justify-start",children:(0,a.jsx)(l(),{href:"/login",children:"Log in"})}),(0,a.jsx)(i.$,{asChild:!0,className:"w-full justify-start",children:(0,a.jsx)(l(),{href:"/register",children:"Sign up"})})]})]})]})})]})}},63898:(e,s,t)=>{t.d(s,{BK:()=>n,eu:()=>
1o,q5:()=>d});var a=t(95155),r=t(12115),l=t(74920),i=t(29602);let o=r.forwardRef((e,s)=>{let{className:t,...r}=e;return(0,a.jsx)(l.bL,{ref:s,className:(0,i.cn)("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...r})});o.displayName=l.bL.displayName;let n=r.forwardRef((e,s)=>{let{className:t,...r}=e;return(0,a.jsx)(l._V,{ref:s,className:(0,i.cn)("aspect-square h-full w-full",t),...r})});n.displayName=l._V.displayName;let d=r.forwardRef((e,s)=>{let{className:t,...r}=e;return(0,a.jsx)(l.H4,{ref:s,className:(0,i.cn)("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...r})});d.displayName=l.H4.displayName},7088:(e,s,t)=>{t.d(s,{k:()=>f});var a=t(95155),r=t(12115),l=t(97498),i=t(7441),o=t(35096),n=t(14085),d=t(21354),c=t(76398),m=t(41371),u=t(29602);function h(){let{address:e,isConnected:s}=(0,l.F)(),{connect:t}=(0,i.e)(),{disconnect:h}=(0,o.u)(),[f,x]=(0,r.useState)(!1),p=async()=>{try{x(!0),await t({connector:(0,m.e)()})}catch(e){console.error("Failed to connect wallet:",e)}finally{x(!1)}};return s&&e?(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-sm text-muted-foreground",children:(0,u.W)(e)}),(0,a.jsx)(n.$,{variant:"ghost",size:"sm",onClick:()=>h(),className:"text-destructive",children:(0,a.jsx)(d.A,{className:"h-4 w-4"})})]}):(0,a.jsxs)(n.$,{variant:"outline",size:"sm",onClick:p,disabled:f,children:[(0,a.jsx)(c.A,{className:"mr-2 h-4 w-4"}),"Connect Wallet"]})}function f(){return(0,a.jsx)("div",{suppressHydrationWarning:!0,children:(0,a.jsx)(h,{})})}},6888:(e,s,t)=>{t.d(s,{A:()=>m,O:()=>c});var a=t(95155),r=t(12115),l=t(70950),i=t(89134),o=t(14651),n=t(76046);let d=(0,r.createContext)(void 0);function c(e){let{children:s}=e,[t,c]=(0,r.useState)(null),[m,u]=(0,r.useState)(!0),{toast:h}=(0,i.dj)(),f=(0,n.useRouter)();(0,r.useEffect)(()=>{(async()=>{try{if(o.i.canRecover()){let e=o.i.getSession();(null==e?void 0:e.userId)&&c(e.user)}}catch(e){console.error("Session recovery failed:",e),o.i.clearSession()}finally{u(!1)}})()},[]);let x=async(e,s)=>{try{u(!0);let t=await l.y1.login({email:e,password:s});if(!t)throw Error("Failed to get user data");let a={id:t.user_uuid,username:t.username,email:t.email,role:t.role,walletAddress:t.walletAddress,verified:t.verified,created_at:t.created_at,total_reward:t.total_reward,quizzes:t.quizzes,leaderboard_score:t.leaderboard_score};c(a),o.i.startSession(a.id,a),h({title:"Login Successful",description:"Welcome back!"}),"admin"===a.role?f.push("/admin"):"protocol_admin"===a.role?f.push("/admin/protocols"):f.push("/dashboard")}catch(e){var t,a;throw console.error("Login error:",e),h({title:"Login Failed",description:(null===(a=e.response)||void 0===a?void 0:null===(t=a.data)||void 0===t?void 0:t.message)||"Invalid credentials",variant:"destructive"}),e}finally{u(!1)}},p=async(e,s,t)=>{try{u(!0),await l.y1.register({username:e,email:s,password:t}),h({title:"Registration Successful",description:"Your account has been created. Please log in."}),f.push("/login")}catch(e){var a,r;throw console.error("Register error:",e),h({title:"Registration Failed",description:(null===(r=e.response)||void 0===r?void 0:null===(a=r.data)||void 0===a?void 0:a.message)||"Registration failed",variant:"destructive"}),e}finally{u(!1)}},g=async()=>{try{u(!0),o.i.clearSession(),c(null),window.location.href="/login"}catch(e){console.error("Logout failed:",e),h({title:"Error",description:"Failed to logout. Please try again.",variant:"destructive"})}finally{u(!1)}},v=async e=>{try{if(!t)throw Error("No user logged in");await l.y1.linkWallet({user_uuid:t.id,wallet_address:e}),c({...t,walletAddress:e}),h({title:"Wallet Linked",description:"Your wallet has been connected successfully."})}catch(e){var s,a;throw h({title:"Error",description:(null===(a=e.response)||void 0===a?void 0:null===(s=a.data)||void 0===s?void 0:s.message)||"Failed to link wallet",variant:"destructive"}),e}};return(0,r.useEffect)(()=>{let e=()=>{t&&o.i.updateActivity()};return window.addEventListener("mousemove",e),window.addEventListener("keydown",e),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("keydown",e)}},[t]),(0,r.useEffect)(()=>{console.log("Current user state:",t),console.log("Current cookies:",document.cookie)},[t]),(0,a.jsx)(d.Provider,{value:{user:t,isLoading:m,login:x,register:p,logout:g,linkWallet:v,hasRole:e=>(null==t?void 0:t.role)===e},children:s})}let m=()=>{let e=(0,r.useContext)(d);if(void 0===e)throw Error("useAuth must be used within an AuthProvider");return e}},14651:(e,s,t)=>{t.d(s,{i:()=>a});let a={startSession(e,s){let t={isAuthenticated:!0,lastActivity:Date.now(),expiresAt:Date.now()+36e5,userId:e,user:s};sessionStorage.setItem("session",JSON.stringify(t))},updateActivity(){let e=this.getSession();e&&(e.lastActivity=Date.now(),e.expiresAt=Date.now()+36e5,sessionStorage.setItem("session",JSON.stringify(e)))},getSession(){let e=sessionStorage.getItem("session");return e?JSON.parse(e):null},clearSession(){sessionStorage.removeItem("session")},isSessionValid(e){return e||(e=this.getSession()),!!e&&Date.now()<e.expiresAt},canRecover(){let e=sessionStorage.getItem("session");if(!e)return!1;let s=JSON.parse(e);return this.isSessionValid(s)}}},70950:(e,s,t)=>{t.d(s,{y1:()=>l});var a=t(23745),r=t(14651);let l={async register(e){let s=await a.A.post("/user/register",e);return console.log("Register Response:",s.data),s.data},async login(e){try{let s=await a.A.post("/user/login",e,{withCredentials:!0});if(200===s.status){let s=(await a.A.get("/user/by-email/".concat(e.email))).data,t=s.match(/User\s*{\s*user_uuid:\s*"([^"]+)",\s*user_name:\s*"([^"]+)",\s*email:\s*Email\s*{\s*email:\s*"([^"]+)",\s*verified:\s*(true|false)/);if(!t)throw Error("Failed to parse user data");
1let r=s.match(/wallet_address:\s*"([^"]+)"/),l=r?r[1]:null,[i,o,n,d,c]=t;return{user_uuid:o,username:n,email:d,role:"user",walletAddress:l,verified:"true"===c,created_at:new Date().toISOString(),total_reward:0,quizzes:[],leaderboard_score:{}}}throw Error("Login failed")}catch(e){throw console.error("Login error:",e),e}},async logout(){r.i.clearSession(),document.cookie="token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"},linkWallet:async e=>(await a.A.post("/user/wallet",e)).data,getAllUsers:async()=>(await a.A.get("/users")).data,getUserByEmail:async e=>(await a.A.get("/user/by-email/".concat(e))).data,async getUserById(e){try{let s=(await a.A.get("/user/by-id/".concat(e))).data,t=s.match(/User\s*{\s*user_uuid:\s*"([^"]+)",\s*user_name:\s*"([^"]+)",\s*email:\s*Email\s*{\s*email:\s*"([^"]+)",\s*verified:\s*(true|false)/);if(!t)throw Error("Failed to parse user data");let[r,l,i,o,n]=t,d=s.match(/wallet_address:\s*"([^"]+)"/);return{user_uuid:l,username:i,email:o,role:"user",walletAddress:d?d[1]:null,verified:"true"===n,created_at:new Date().toISOString(),total_reward:0,quizzes:[],leaderboard_score:{}}}catch(e){throw console.error("Get user error:",e),e}},async checkAuth(){try{return await a.A.get("/user/me"),!0}catch(e){return!1}},async healthCheck(){try{return(await a.A.get("/health")).data}catch(e){throw console.error("Health check failed:",e),e}}}},27928:(e,s,t)=>{t.d(s,{A:()=>r});var a=t(23745);let r={async getAll(){try{let e=await a.A.get("/protocols");console.log("1. Raw response:",e.data);let s=e.data.replace(/^\[Protocol\s*/,"").replace(/\]$/,"").split(/,\s*Protocol\s*/);console.log("2. After splitting:",s);let t=s.map(e=>{var s,t,a,r,l,i;console.log("3. Processing protocol string:",e);let o=null===(s=e.match(/protocol_uuid:\s*"([^"]+)"/))||void 0===s?void 0:s[1],n=null===(t=e.match(/name:\s*"([^"]+)"/))||void 0===t?void 0:t[1],d=null===(a=e.match(/created_at:\s*"([^"]+)"/))||void 0===a?void 0:a[1],c=null===(r=e.match(/total_expense:\s*([\d.]+)/))||void 0===r?void 0:r[1],m=null===(l=e.match(/staffs:\s*(\[[^\]]*\])/))||void 0===l?void 0:l[1],u=null===(i=e.match(/created_by:\s*"([^"]+)"/))||void 0===i?void 0:i[1];return console.log("4. Extracted values:",{uuid:o,name:n,created_at:d,total_expense:c,staffs:m,created_by:u}),{id:o,name:n,description:"",createdAt:d,members:[],totalQuizzes:0,totalHackathons:0,totalRewards:"".concat(parseFloat(c||"0")," USDC"),website:"",tags:[],status:"active",logo:"/logos/".concat(null==n?void 0:n.toLowerCase(),"-logo.png"),staffs:JSON.parse(m||"[]"),created_by:u}});return console.log("5. Final protocols:",t),t}catch(e){throw console.error("Failed to fetch protocols:",e),e}},getProtocolById:async e=>(await a.A.get("/protocols/".concat(e))).data,getProtocolByName:async e=>(await a.A.get("/protocols/search?name=".concat(e))).data,register:async e=>(await a.A.post("/protocols",e)).data,addStaff:async e=>(await a.A.post("/protocol/team",e)).data,async isProtocolAdmin(e){try{return(await this.getAll()).some(s=>{var t;return(null===(t=s.staffs)||void 0===t?void 0:t.includes(e))||s.created_by===e})}catch(e){return console.error("Failed to check protocol admin status:",e),!1}},async getProtocolStaff(e){return(await this.getProtocolById(e)).staffs.map(e=>({id:e,name:"Staff Member",email:"[email protected]",role:"staff",avatar:"",joinedAt:new Date().toISOString()}))},async getProtocolHackathons(e){return(await this.getProtocolById(e)).hackathons||[]}}}}]);
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.