(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7177],{283:(t,e,o)=>{"use strict";o.d(e,{A:()=>d,O:()=>i});var a=o(5155),r=o(2115),n=o(5731);let s=(0,r.createContext)(null);function i(t){let{children:e}=t,[o,i]=(0,r.useState)(null),[d,c]=(0,r.useState)(!0);(0,r.useEffect)(()=>{n.R2.me().then(i).catch(()=>i(null)).finally(()=>c(!1))},[]);let u=async(t,e)=>{i((await n.R2.login(t,e)).user)},l=async(t,e,o)=>{i((await n.R2.signup(t,e,o)).user)},p=async()=>{await n.R2.logout().catch(()=>{}),i(null)};return(0,a.jsx)(s.Provider,{value:{user:o,loading:d,login:u,signup:l,logout:p,isLoggedIn:!!o},children:e})}function d(){let t=(0,r.useContext)(s);if(!t)throw Error("useAuth must be used inside AuthProvider");return t}},2954:(t,e,o)=>{"use strict";o.d(e,{default:()=>p});var a=o(5155),r=o(1362),n=o(283),s=o(2115),i=o(8354),d=o(9434);let c=i.Kq;i.bL,i.l9,s.forwardRef((t,e)=>{let{className:o,sideOffset:r=4,...n}=t;return(0,a.jsx)(i.UC,{ref:e,sideOffset:r,className:(0,d.cn)("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 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",o),...n})}).displayName=i.UC.displayName;var u=o(6671);let l=t=>{let{...e}=t,{theme:o="system"}=(0,r.D)();return(0,a.jsx)(u.l$,{theme:o,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...e})};function p(t){let{children:e}=t;return(0,a.jsx)(r.N,{attribute:"class",defaultTheme:"dark",enableSystem:!1,children:(0,a.jsx)(n.O,{children:(0,a.jsxs)(c,{children:[e,(0,a.jsx)(l,{})]})})})}},4013:(t,e,o)=>{Promise.resolve().then(o.t.bind(o,5356,23)),Promise.resolve().then(o.bind(o,2954)),Promise.resolve().then(o.t.bind(o,7107,23))},5731:(t,e,o)=>{"use strict";async function a(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=await fetch(t,{headers:{"Content-Type":"application/json",...e.headers||{}},credentials:"include",...e}),a=await o.json();if(!o.ok)throw Error(a.error||"HTTP ".concat(o.status));return a}o.d(e,{Fs:()=>n,Jp:()=>c,Pf:()=>i,R2:()=>r,ZB:()=>p,aE:()=>l,j1:()=>u,oG:()=>s,s2:()=>h,ys:()=>d});let r={signup:(t,e,o)=>a("/api/auth/signup",{method:"POST",body:JSON.stringify({name:t,email:e,password:o})}),login:(t,e)=>a("/api/auth/login",{method:"POST",body:JSON.stringify({email:t,password:e})}),me:()=>a("/api/auth/me"),logout:()=>a("/api/auth/logout",{method:"POST"})},n=()=>a("/api/brands").then(t=>t.brands),s=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=new URLSearchParams;return Object.entries(t).forEach(t=>{let[o,a]=t;void 0!==a&&""!==a&&e.set(o,String(a))}),a("/api/devices?".concat(e))},i=t=>a("/api/devices/".concat(encodeURIComponent(t))),d=t=>a("/api/search?q=".concat(encodeURIComponent(t))),c=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"fans",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10;return a("/api/top-10?sort=".concat(t,"&limit=").concat(e))},u=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=new URLSearchParams;return Object.entries(t).forEach(t=>{let[o,a]=t;a&&e.set(o,a)}),a("/api/upcoming?".concat(e))},l=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=new URLSearchParams;return Object.entries(t).forEach(t=>{let[o,a]=t;void 0!==a&&e.set(o,String(a))}),a("/api/news?".concat(e))},p=(t,e)=>a("/api/compare?slug1=".concat(encodeURIComponent(t),"&slug2=").concat(encodeURIComponent(e))),h={add:t=>a("/api/wishlist",{method:"POST",body:JSON.stringify({slug:t})}),remove:t=>a("/api/wishlist/".concat(t),{method:"DELETE"})}},7107:()=>{},9434:(t,e,o)=>{"use strict";o.d(e,{cn:()=>n});var a=o(2596),r=o(9688);function n(){for(var t=arguments.length,e=Array(t),o=0;o<t;o++)e[o]=arguments[o];return(0,r.QP)((0,a.$)(e))}}},t=>{var e=e=>t(t.s=e);t.O(0,[9897,6578,5469,2538,8441,1684,7358],()=>e(4013)),_N_E=t.O()}]);