(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[811],{454:function(e,t,r){Promise.resolve().then(r.bind(r,8090))},9376:function(e,t,r){"use strict";var n=r(5475);r.o(n,"useRouter")&&r.d(t,{useRouter:function(){return n.useRouter}})},257:function(e,t,r){"use strict";var n,o;e.exports=(null==(n=r.g.process)?void 0:n.env)&&"object"==typeof(null==(o=r.g.process)?void 0:o.env)?r.g.process:r(4227)},4227:function(e){!function(){var t={229:function(e){var t,r,n,o=e.exports={};function a(){throw Error("setTimeout has not been defined")}function s(){throw Error("clearTimeout has not been defined")}function i(e){if(t===setTimeout)return setTimeout(e,0);if((t===a||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:a}catch(e){t=a}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(e){r=s}}();var c=[],l=!1,u=-1;function f(){l&&n&&(l=!1,n.length?c=n.concat(c):u=-1,c.length&&d())}function d(){if(!l){var e=i(f);l=!0;for(var t=c.length;t;){for(n=c,c=[];++u1)for(var r=1;r{if(u(),!localStorage.getItem("token")){f.push("/login");return}i.h.history().then(t).catch(()=>{}).finally(()=>l(!1))},[]);let d=e=>e>=71?"text-green-400":e>=51?"text-yellow-400":e>=31?"text-orange-400":"text-red-400";return(0,n.jsxs)("div",{className:"min-h-screen bg-dark px-4 py-6 max-w-lg mx-auto",children:[(0,n.jsxs)("nav",{className:"flex items-center justify-between mb-8",children:[(0,n.jsx)(s.default,{href:"/scan",className:"text-gray-400 hover:text-white",children:"← Voltar"}),(0,n.jsx)("span",{className:"font-bold tracking-wider text-primary",children:"Hist\xf3rico"}),(0,n.jsx)("div",{})]}),r?(0,n.jsx)("div",{className:"text-center py-20 text-gray-400",children:"Carregando..."}):0===e.length?(0,n.jsxs)("div",{className:"text-center py-20",children:[(0,n.jsx)("p",{className:"text-gray-500 text-lg mb-4",children:"Nenhum scan ainda"}),(0,n.jsx)(s.default,{href:"/scan",className:"bg-primary text-dark px-6 py-3 rounded-xl font-bold",children:"Escanear agora"})]}):(0,n.jsx)("div",{className:"space-y-3",children:e.map(e=>(0,n.jsxs)("div",{className:"bg-dark-light rounded-xl p-4 flex items-center justify-between",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"font-medium text-sm",children:e.product_name||e.barcode}),e.brand&&(0,n.jsx)("p",{className:"text-gray-500 text-xs",children:e.brand}),(0,n.jsx)("p",{className:"text-gray-600 text-xs mt-1",children:new Date(e.scanned_at).toLocaleDateString("pt-BR")})]}),(0,n.jsx)("span",{className:"text-2xl font-black ".concat(d(e.score)),children:e.score})]},e.id))})]})}},1837:function(e,t,r){"use strict";r.d(t,{h:function(){return a}});let n=r(257).env.NEXT_PUBLIC_API_URL||"http://localhost:8090";async function o(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=localStorage.getItem("token"),o={"Content-Type":"application/json",...t.headers||{}};r&&(o.Authorization="Bearer ".concat(r));let a=await fetch("".concat(n).concat(e),{...t,headers:o});if(!a.ok)throw Error((await a.json().catch(()=>({detail:"Erro de rede"}))).detail||"HTTP ".concat(a.status));return a.json()}let a={register:e=>o("/api/auth/register",{method:"POST",body:JSON.stringify(e)}),login:e=>o("/api/auth/login",{method:"POST",body:JSON.stringify(e)}),me:()=>o("/api/auth/me"),scan:e=>o("/api/scan",{method:"POST",body:JSON.stringify({barcode:e})}),history:()=>o("/api/history")}},1768:function(e,t,r){"use strict";let n;r.d(t,{t:function(){return l}});var o=r(2265);let a=e=>{let t;let r=new Set,n=(e,n)=>{let o="function"==typeof e?e(t):e;if(!Object.is(o,t)){let e=t;t=(null!=n?n:"object"!=typeof o||null===o)?o:Object.assign({},t,o),r.forEach(r=>r(t,e))}},o=()=>t,a={setState:n,getState:o,getInitialState:()=>s,subscribe:e=>(r.add(e),()=>r.delete(e))},s=t=e(n,o,a);return a},s=e=>e?a(e):a,i=e=>e,c=e=>{let t=s(e),r=e=>(function(e,t=i){let r=o.useSyncExternalStore(e.subscribe,o.useCallback(()=>t(e.getState()),[e,t]),o.useCallback(()=>t(e.getInitialState()),[e,t]));return o.useDebugValue(r),r})(t,e);return Object.assign(r,t),r},l=(n=e=>({user:null,token:null,setAuth:(t,r)=>{localStorage.setItem("token",t),localStorage.setItem("user",JSON.stringify(r)),e({token:t,user:r})},logout:()=>{localStorage.removeItem("token"),localStorage.removeItem("user"),e({token:null,user:null})},hydrate:()=>{let t=localStorage.getItem("token"),r=localStorage.getItem("user");t&&r&&e({token:t,user:JSON.parse(r)})}}))?c(n):c}},function(e){e.O(0,[648,971,117,744],function(){return e(e.s=454)}),_N_E=e.O()}]);