1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[185],{2388:function(e,t,n){Promise.resolve().then(n.t.bind(n,2679,23)),Promise.resolve().then(n.t.bind(n,1546,23)),Promise.resolve().then(n.t.bind(n,7068,23)),Promise.resolve().then(n.t.bind(n,2778,23)),Promise.resolve().then(n.bind(n,2582))},2582:function(e,t,n){"use strict";n.d(t,{default:function(){return l}});var r=n(7437),o=n(2265),a=n(8123);function l(e){let{children:t}=e,[n,l]=(0,o.useState)(!1);(0,o.useEffect)(()=>{l((0,a.jl)())},[]);let c=(0,o.useCallback)(()=>{(0,a.yE)(),l(!1),window.location.href="/login"},[]),i=(0,o.useCallback)(()=>{l((0,a.jl)())},[]);return(0,r.jsx)(a.Vo.Provider,{value:{loggedIn:n,logout:c,refresh:i},children:t})}},8123:function(e,t,n){"use strict";n.d(t,{IU:function(){return h},Ms:function(){return i},Vo:function(){return d},aC:function(){return k},hP:function(){return a},jb:function(){return _},jl:function(){return u},x4:function(){return m},yE:function(){return s}});var r=n(2265),o=n(3217);function a(){return localStorage.getItem("access_token")}function l(e,t){localStorage.setItem("access_token",e),localStorage.setItem("refresh_token",t)}function c(e){localStorage.setItem("username",e)}function i(){return localStorage.getItem("username")}function s(){localStorage.removeItem("access_token"),localStorage.removeItem("refresh_token"),localStorage.removeItem("username")}function u(){return!!a()}let f=null;async function _(){return f||(f=(async()=>{let e=localStorage.getItem("refresh_token");if(!e)return!1;try{let t=await fetch("".concat(o.T,"/auth/token/refresh/"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refresh:e})});if(t.ok){let e=await t.json();return localStorage.setItem("access_token",e.access),!0}return s(),!1}catch(e){return!1}finally{f=null}})())}async function m(e,t){try{let n=await fetch("".concat(o.T,"/auth/login/"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:t})});if(n.ok){let t=await n.json();return l(t.access,t.refresh),c(t.username||e),{ok:!0}}let r=await n.json().catch(()=>null),a=(null==r?void 0:r.detail)||(null==r?void 0:r.error)||"Invalid credentials";return{ok:!1,error:a}}catch(e){return{ok:!1,error:"Network error â is the backend running?"}}}async function h(e,t,n,r){try{let a=await fetch("".concat(o.T,"/auth/signup/"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,email:t,phone_number:n,password:r})});if(a.ok||201===a.status){let t=await a.json();return l(t.access,t.refresh),c(t.username||e),{ok:!0}}let i=await a.json().catch(()=>null);if(i){let e=Object.values(i).flat()[0];if("string"==typeof e)return{ok:!1,error:e}}return{ok:!1,error:"Signup failed"}}catch(e){return{ok:!1,error:"Network error â is the backend running?"}}}let d=(0,r.createContext)({loggedIn:!1,logout:()=>{},refresh:()=>{}});function k(){return(0,r.useContext)(d)}},3217:function(e,t,n){"use strict";n.d(t,{T:function(){return r}});let r="https://crop-advisor-922c34c099bf.herokuapp.com/api/v1"},2778:function(){},1546:function(e){e.exports={style:{fontFamily:"'__IBM_Plex_Mono_595324', '__IBM_Plex_Mono_Fallback_595324'",fontStyle:"normal"},className:"__className_595324",variable:"__variable_595324"}},7068:function(e){e.exports={style:{fontFamily:"'__Instrument_Serif_9f4838', '__Instrument_Serif_Fallback_9f4838'",fontWeight:400,fontStyle:"italic"},className:"__className_9f4838",variable:"__variable_9f4838"}},2679:function(e){e.exports={style:{fontFamily:"'__Outfit_ed3508', '__Outfit_Fallback_ed3508'",fontStyle:"normal"},className:"__className_ed3508",variable:"__variable_ed3508"}}},function(e){e.O(0,[420,971,117,744],function(){return e(e.s=2388)}),_N_E=e.O()}]);
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.