(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3185],{26862:function(e,t,r){Promise.resolve().then(r.t.bind(r,72972,23)),Promise.resolve().then(r.t.bind(r,88003,23)),Promise.resolve().then(r.bind(r,81523)),Promise.resolve().then(r.bind(r,70049)),Promise.resolve().then(r.bind(r,75013)),Promise.resolve().then(r.bind(r,37795)),Promise.resolve().then(r.bind(r,34645)),Promise.resolve().then(r.t.bind(r,2778,23))},75013:function(e,t,r){"use strict";r.r(t);var i=r(57437),a=r(2265),n=r(8626),o=r(20096),s=r(3289),c=r(47969),l=r(66314),u=r(36549),d=r(59559),h=r(62360),g=r(25361);let m=()=>{var e,t,r,m,y,f,p,v,x,w,b,C,S,j,N,k,E,I;let[R,A]=(0,a.useState)(!1),[D,W]=(0,a.useState)(100),[T,O]=(0,a.useState)(null),[F,L]=(0,a.useState)(null),[Z,P]=(0,a.useState)(!1),[M,H]=(0,a.useState)(!1),[z,B]=(0,a.useState)("");(0,a.useEffect)(()=>{_();let e=setInterval(()=>{_()},6e4);return()=>clearInterval(e)},[]);let _=async()=>{try{let e=await n.ZP.runQuickDiagnostic();W(e.health||100),O(e);let t=o.x.getStats();L(t),B(new Date().toLocaleTimeString())}catch(e){console.error("Diagnostic error:",e)}},J=async()=>{P(!0);try{var e;let t=await n.ZP.runFullDiagnostic();O(t),W((null===(e=t.overallHealth)||void 0===e?void 0:e.score)||100),B(new Date().toLocaleTimeString())}catch(e){console.error("Full diagnostic error:",e)}finally{P(!1)}},G=async()=>{H(!0);try{let e=await n.ZP.repairCacheSystem();return await _(),e}catch(e){console.error("Fix error:",e)}finally{H(!1)}},U=async()=>{H(!0);try{await n.ZP.forceRefreshAllCaches(),await _()}catch(e){console.error("Refresh error:",e)}finally{H(!1)}},Q=e=>(null==e?void 0:e.toLocaleString())||"0";return(0,i.jsxs)("div",{className:"fixed bottom-4 right-4 z-50 w-64 shadow-lg rounded-lg overflow-hidden bg-white border border-gray-200 text-sm",children:[(0,i.jsxs)("div",{className:"p-2 flex justify-between items-center cursor-pointer bg-gray-100",onClick:()=>A(!R),children:[(0,i.jsxs)("div",{className:"flex items-center",children:[(0,i.jsx)("div",{className:"".concat(D>=90?"bg-green-500":D>=70?"bg-yellow-500":D>=50?"bg-orange-500":"bg-red-500"," h-3 w-3 rounded-full mr-2")}),(0,i.jsxs)("span",{className:"font-medium",children:["Cache Health: ",D,"%"]})]}),R?(0,i.jsx)(s.Z,{size:16}):(0,i.jsx)(c.Z,{size:16})]}),R&&(0,i.jsxs)("div",{className:"p-3 border-t border-gray-200",children:[(0,i.jsxs)("div",{className:"mb-3",children:[(0,i.jsxs)("div",{className:"flex justify-between text-xs mb-2",children:[(0,i.jsx)("span",{className:"text-gray-600",children:"Last checked:"}),(0,i.jsx)("span",{children:z})]}),(0,i.jsxs)("div",{className:"grid grid-cols-2 gap-2 text-xs mb-3",children:[(0,i.jsxs)("div",{className:"bg-gray-100 p-2 rounded",children:[(0,i.jsx)("div",{className:"text-gray-500",children:"Reads"}),(0,i.jsx)("div",{className:"font-semibold",children:Q(null==F?void 0:null===(e=F.counters)||void 0===e?void 0:e.reads)})]}),(0,i.jsxs)("div",{className:"bg-gray-100 p-2 rounded",children:[(0,i.jsx)("div",{className:"text-gray-500",children:"Writes"}),(0,i.jsx)("div",{className:"font-semibold",children:Q(null==F?void 0:null===(t=F.counters)||void 0===t?void 0:t.writes)})]}),(0,i.jsxs)("div",{className:"bg-gray-100 p-2 rounded",children:[(0,i.jsx)("div",{className:"text-gray-500",children:"Syncs"}),(0,i.jsx)("div",{className:"font-semibold",children:Q(null==F?void 0:null===(r=F.counters)||void 0===r?void 0:r.syncs)})]}),(0,i.jsxs)("div",{className:"bg-gray-100 p-2 rounded",children:[(0,i.jsx)("div",{className:"text-gray-500",children:"Errors"}),(0,i.jsx)("div",{className:"font-semibold",children:Q(null==F?void 0:null===(m=F.counters)||void 0===m?void 0:m.errors)})]})]}),T&&(0,i.jsxs)("div",{className:"text-xs space-y-1 mb-3",children:[(0,i.jsxs)("div",{className:"flex justify-between",children:[(0,i.jsx)("span",{className:"text-gray-600",children:"SWR Cache:"}),(0,i.jsx)("span",{className:(null===(y=T.swr)||void 0===y?void 0:y.exists)?"text-green-600":"text-red-600",children:(null===(f=T.swr)||void 0===f?void 0:f.exists)?"".concat(T.swr.entryCount," entries"):"Not found"})]}),(0,i.jsxs)("div",{className:"flex justify-between",children:[(0,i.jsx)("span",{className:"text-gray-600",children:"Country Cache:"}),(0,i.jsxs)("span",{className:(null===(v=T.country)||void 0===v?void 0:null===(p=v.allCountries)||void 0===p?void 0:p.exists)?"text-green-600":"text-red-600",children:[(null===(w=T.country)||void 0===w?void 0:null===(x=w.allCountries)||void 0===x?void 0:x.count)||0," ","countries"]})]}),(0,i.jsxs)("div",{className:"flex justify-between",children:[(0,i.jsx)("span",{className:"text-gray-600",children:"City Cache:"}),(0,i.jsxs)("span",{className:(null===(C=T.city)||void 0===C?void 0:null===(b=C.allCities)||void 0===b?void 0:b.exists)?"text-green-600":"text-red-600",children:[(null===(j=T.city)||void 0===j?void 0:null===(S=j.allCities)||void 0===S?void 0:S.count)||0," cities"]})]}),(0,i.jsxs)("div",{className:"flex justify-between",children:[(0,i.jsx)("span",{className:"text-gray-600",children:"Sync Status:"}),(0,i.jsx)("span",{className:(null===(N=T.inSync)||void 0===N?void 0:N.countriesInSync)&&(null===(k=T.inSync)||void 0===k?void 0:k.citiesInSync)?"text-green-600":"text-yellow-600",children:(null===(E=T.inSync)||void 0===E?void 0:E.countriesInSync)&&(null===(I=T.inSync)||void 0===I?void 0:I.citiesInSync)?"In sync":"Out of sync"})]})]})]}),(0,i.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,i.jsxs)("button",{className:"bg-blue-500 hover:bg-blue-600 text-white py-1 px-2 rounded text-xs flex items-center justify-center",onClick:J,disabled:Z,children:[Z?(0,i.jsx)(l.Z,{className:"animate-spin h-3 w-3 mr-1"}):(0,i.jsx)(u.Z,{className:"h-3 w-3 mr-1"}),"Diagnose"]}),(0,i.jsxs)("button",{className:"bg-green-500 hover:bg-green-600 text-white py-1 px-2 rounded text-xs flex items-center justify-center",onClick:G,disabled:M||D>90,children:[M?(0,i.jsx)(l.Z,{className:"animate-spin h-3 w-3 mr-1"}):(0,i.jsx)(d.Z,{className:"h-3 w-3 mr-1"}),"Fix Issues"]}),(0,i.jsxs)("button",{className:"bg-yellow-500 hover:bg-yellow-600 text-white py-1 px-2 rounded text-xs flex items-center justify-center col-span-2",onClick:U,disabled:M,children:[M?(0,i.jsx)(l.Z,{className:"animate-spin h-3 w-3 mr-1"}):(0,i.jsx)(h.Z,{className:"h-3 w-3 mr-1"}),"Force Refresh All Caches"]})]}),D<70&&(0,i.jsxs)("div",{className:"mt-3 bg-red-50 border border-red-200 rounded p-2 flex items-start text-xs",children:[(0,i.jsx)(g.Z,{className:"h-3 w-3 text-red-500 mt-0.5 mr-1 flex-shrink-0"}),(0,i.jsx)("div",{className:"text-red-700",children:D<50?"Critical cache issues detected. Click 'Fix Issues' to repair.":"Cache health issues detected. Consider fixing soon."})]}),(0,i.jsx)("div",{className:"mt-3 text-xs text-gray-500",children:(0,i.jsxs)("p",{children:["Tip: Open browser console and try ",(0,i.jsx)("code",{children:"cacheDebug.help()"})," ","for more tools."]})})]})]})};t.default=()=>{let[e,t]=(0,a.useState)(!1),[r,s]=(0,a.useState)(!1);return((0,a.useEffect)(()=>{let e=new URLSearchParams(window.location.search).has("debug-cache");if(t(e),e&&!r)return o.x.enable({autoSync:!0}),n.ZP.startMonitoring(6e4),s(!0),()=>{r&&(n.ZP.stopMonitoring(),o.x.disable(),s(!1))}},[r]),e)?(0,i.jsx)(m,{}):null}},37795:function(e,t,r){"use strict";r.d(t,{default:function(){return h}});var i=r(57437),a=r(2265),n=r(86484),o=r(94242);r(2648);var s=r(28634),c=r(2938);r(61582),r(3479);var l=r(6021);r(46215),r(6275),r(8626),r(20096),r(40257);let u="swr-cache-v1.0.0",d="swr-cache";function h(e){let{children:t}=e,[h]=a.useState(()=>new n.QueryClient),[g,m]=a.useState(!1),y=(0,a.useRef)(new Map);return((0,a.useEffect)(()=>{(()=>{try{if(0===y.current.size){if(!(0,l.safeGetItem)(u)){let e=(0,l.safeGetItem)(d);if(e){console.log("Found legacy unversioned cache, migrating it to versioned format...");try{(0,l.safeSetItem)(u,e),console.log("Legacy cache migrated to versioned format")}catch(e){console.error("Failed to migrate legacy cache:",e)}}}let e=(0,l.safeGetItem)(u);if(e)try{let t=JSON.parse(e);y.current=new Map(t.map(e=>{let[t,r]=e;return[t,r]})),console.log("Initialized SWR cache with",y.current.size,"entries.");try{(0,l.safeSetItem)(d,e)}catch(e){console.warn("Failed to sync unversioned cache:",e)}}catch(e){console.error("Failed to parse SWR cache:",e),y.current=new Map}else console.log("No existing SWR cache found, initializing new cache.")}else console.log("SWR cache already initialized with",y.current.size,"entries");m(!0)}catch(e){console.error("Failed to initialize SWR cache:",e),y.current=new Map;try{localStorage.removeItem(u),localStorage.removeItem(d)}catch(e){}m(!0)}})()},[]),(0,a.useEffect)(()=>{if(!g)return;(async()=>{try{let e=(0,l.safeGetItem)(u);console.log("Existing SWR cache:",e?"found":"not found"),(0,l.validateAndRepairCache)()&&console.log("Cache was repaired during validation"),(0,l.migrateCache)(),(0,l.initializeGlobalCache)(),console.log("Global cache system initialized");try{let{synchronizeCacheReferences:e,verifyCacheIntegrity:t,migrateDataBetweenCaches:i}=await r.e(1605).then(r.bind(r,71605));await i(),await t()||console.warn("Cache integrity check failed, attempting repair"),await e()}catch(e){console.debug("Advanced cache sync utilities not available:",e)}try{let{initializeMapboxCache:e}=await Promise.all([r.e(2560),r.e(8030)]).then(r.bind(r,98030));e(),console.log("Mapbox cache system initialized")}catch(e){console.debug("Mapbox cache service not available:",e)}}catch(e){console.error("Failed to initialize caches:",e)}})();let e=setInterval(()=>{try{let e=Array.from(y.current.entries());if(e.length>0){console.debug("Periodic save of SWR cache with",e.length,"entries.");try{(0,l.flushCachesToStorage)()}catch(t){(0,l.safeSetItem)(u,JSON.stringify(e)),(0,l.safeSetItem)(d,JSON.stringify(e))}}}catch(e){console.error("Failed to save SWR cache in interval:",e)}},3e5),t=()=>{try{let e=Array.from(y.current.entries());console.log("Saving SWR cache before unload with",e.length,"entries.");try{(0,l.flushCachesToStorage)()}catch(t){(0,l.safeSetItem)(u,JSON.stringify(e)),(0,l.safeSetItem)(d,JSON.stringify(e))}}catch(e){console.error("Failed to save SWR cache on unload:",e)}};return window.addEventListener("beforeunload",t),()=>{clearInterval(e),window.removeEventListener("beforeunload",t)}},[g]),g)?(0,i.jsx)(s.H,{children:(0,i.jsx)(c.J$,{value:{provider:()=>y.current,revalidateOnFocus:!1,dedupingInterval:36e5,onSuccess:async(e,t)=>{if(Array.isArray(e)&&e.length>0?console.log("SWR success for key: ".concat(t," (").concat(e.length," items)")):console.debug("SWR success for key: ".concat(t)),t.includes("/trip/"))try{let t=(0,l.syncAllCachesWithSWR)();if(t.success||console.warn("Cache sync warning:",t.error),Array.isArray(e)&&e.length>5)try{let e=Array.from(y.current.entries());if(e.length>0){console.log("Saving SWR cache after successful request:",e.length);try{(0,l.flushCachesToStorage)()}catch(t){(0,l.safeSetItem)(u,JSON.stringify(e)),(0,l.safeSetItem)(d,JSON.stringify(e))}}}catch(e){console.error("Failed to save SWR cache after success:",e)}try{let{synchronizeCacheReferences:e}=await r.e(1605).then(r.bind(r,71605));e()}catch(e){}}catch(e){console.error("Failed to sync caches:",e)}},onError:async(e,t)=>{if(console.error("SWR error for key: ".concat(t),e),t.includes("/trip/"))try{(0,l.validateAndRepairCache)();try{let{synchronizeCacheReferences:e}=await r.e(1605).then(r.bind(r,71605));await e()}catch(e){}}catch(e){console.error("Error during recovery attempt:",e)}}},children:(0,i.jsxs)(n.QueryClientProvider,{client:h,children:[t,(0,i.jsx)(o.Ix,{position:"top-right",autoClose:3e3,hideProgressBar:!1,newestOnTop:!0,closeOnClick:!0,pauseOnHover:!0,draggable:!0})]})})}):null}},34645:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return j}});var i=r(57437),a=r(27648),n=r(28634),o=r(99376),s=r(2265),c=r(75183),l=r(48614),u=r(99049),d=r(98012),h=r(38704),g=r(67541),m=r(15847),y=r(3289),f=r(28505),p=r(67350),v=r(40339),x=r(3683),w=r(25824),b=r(44986),C=r(96818);let S={background:{light:"from-gray-900/95 via-blue-800/90 to-blue-900/90",dark:"from-gray-900 via-blue-800 to-blue-900"}};function j(){let{isAuthenticated:e,username:t,isVerifying:r,logout:j,firstName:I}=(0,n.a)(),R=(0,o.useRouter)(),A=(0,o.usePathname)(),[D,W]=(0,s.useState)(!1),[T,O]=(0,s.useState)(!1),[F,L]=(0,s.useState)(!1),Z=(0,s.useRef)(null),P=(0,s.useRef)(null),M=(0,s.useRef)(null),H=(0,s.useCallback)(()=>{L(window.scrollY>20)},[]),z=(0,s.useCallback)(()=>{W(e=>!e)},[]),B=(0,s.useCallback)(()=>{O(e=>(e?document.body.style.overflow="":document.body.style.overflow="hidden",!e))},[]),_=(0,s.useCallback)(()=>{let e=document.getElementById("world-map-section");e&&(e.scrollIntoView({behavior:"smooth"}),O(!1))},[]),J=(0,s.useCallback)(async()=>{if(window.confirm("Are you sure you want to log out?"))try{await j(),R.push("/")}catch(e){console.error("Failed to log out:",e)}},[j,R]),G=(0,s.useCallback)(e=>{var t;Z.current&&!Z.current.contains(e.target)&&W(!1),P.current&&!P.current.contains(e.target)&&(null===(t=e.target.closest("button"))||void 0===t?void 0:t.getAttribute("aria-label"))!=="Toggle mobile menu"&&(O(!1),document.body.style.overflow="")},[]);if((0,s.useEffect)(()=>{O(!1),document.body.style.overflow=""},[A]),(0,s.useEffect)(()=>{let e=!1,t=()=>{e||(window.requestAnimationFrame(()=>{H(),e=!1}),e=!0)};return document.addEventListener("mousedown",G),window.addEventListener("scroll",t),H(),()=>{document.removeEventListener("mousedown",G),window.removeEventListener("scroll",t)}},[H,G]),(0,s.useEffect)(()=>{let e=e=>{"Escape"===e.key&&(W(!1),O(!1),document.body.style.overflow="")};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]),r)return null;let U=[{name:"Home",href:"/",icon:(0,i.jsx)(u.Z,{className:"w-4 h-4 mr-2","aria-hidden":"true"})},{name:"Explore Cities",href:"/explore-cities",icon:(0,i.jsx)(d.Z,{className:"w-4 h-4 mr-2","aria-hidden":"true"})},{name:"Explore Countries",href:"/explore-countries",icon:(0,i.jsx)(h.Z,{className:"w-4 h-4 mr-2","aria-hidden":"true"})},{name:"Travel Guides",href:"/explore-travel-guides",icon:(0,i.jsx)(g.Z,{className:"w-4 h-4 mr-2","aria-hidden":"true"})},{name:"Blogs",href:"/blogs",icon:(0,i.jsx)(m.Z,{className:"w-4 h-4 mr-2","aria-hidden":"true"})}],Q=I||t||"";return(0,i.jsxs)(c.E.header,{ref:M,initial:{y:0},animate:{y:0,boxShadow:F?"0 10px 30px -10px rgba(0, 0, 0, 0.3)":"0 0 0 rgba(0, 0, 0, 0)"},transition:{duration:.3},className:"\n fixed top-0 left-0 w-full z-50 transition-all duration-300\n ".concat(F?"py-2 shadow-xl bg-gradient-to-r ".concat(S.background.light," backdrop-blur-md border-b border-white/10"):"py-4 bg-gradient-to-r ".concat(S.background.dark),"\n "),role:"banner","aria-labelledby":"site-header",children:[(0,i.jsx)("h1",{id:"site-header",className:"sr-only",children:"Nomad - Travel navigation"}),(0,i.jsxs)("div",{className:"flex justify-between items-center max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 w-full",children:[(0,i.jsx)(a.default,{href:"/","aria-label":"Nomad - Homepage",className:"focus-visible:outline-white focus-visible:outline-2 focus-visible:outline-offset-4 rounded-md",children:(0,i.jsxs)(c.E.div,{className:"flex items-center",whileHover:{scale:1.05},whileTap:{scale:.95},children:[(0,i.jsxs)(c.E.div,{className:"w-10 h-10 rounded-full flex items-center justify-center mr-2 overflow-hidden group relative",whileHover:{rotate:15},children:[(0,i.jsx)(c.E.div,{className:"absolute inset-0 bg-gradient-to-br from-blue-500 to-blue-700 opacity-80",animate:{rotate:[0,360],background:["linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)","linear-gradient(225deg, #3B82F6 0%, #2563EB 100%)"]},transition:{rotate:{repeat:1/0,duration:10,ease:"linear"},background:{repeat:1/0,duration:3,repeatType:"reverse"}}}),(0,i.jsx)("div",{className:"w-full h-full bg-gradient-to-br from-blue-500 to-blue-700 rounded-full flex items-center justify-center shadow-md border border-white/20 group-hover:from-blue-700 group-hover:to-blue-500 transition-all duration-300 relative z-10",children:(0,i.jsx)("span",{className:"text-white text-lg font-bold","aria-hidden":"true",children:"N"})})]}),(0,i.jsx)(c.E.span,{className:"text-2xl sm:text-3xl font-playfair font-bold text-white tracking-tight drop-shadow-md",initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:.1},children:"Nomad"})]})}),(0,i.jsxs)("nav",{className:"hidden md:flex space-x-1 lg:space-x-4 text-base items-center font-cabin","aria-label":"Desktop Navigation",children:[U.map(e=>(0,i.jsx)(N,{href:e.href,icon:e.icon,active:A===e.href,children:e.name},e.href)),e?(0,i.jsxs)("div",{className:"relative",ref:Z,children:[(0,i.jsxs)(c.E.button,{onClick:z,className:"flex items-center text-white font-medium px-3 py-2 rounded-full hover:bg-white/10 focus:bg-white/10 focus:outline-none focus:ring-2 focus:ring-white/30 transition duration-300 group","aria-haspopup":"true","aria-expanded":D,"aria-label":"User menu for ".concat(Q),whileHover:{scale:1.02},whileTap:{scale:.98},children:[(0,i.jsxs)(c.E.span,{className:"flex items-center",whileHover:{x:2},children:[(0,i.jsx)("span",{className:"w-8 h-8 bg-gradient-to-br from-blue-500 to-blue-700 rounded-full flex items-center justify-center mr-2 text-white shadow-md border border-white/20",children:Q.charAt(0).toUpperCase()}),(0,i.jsx)("span",{className:"hidden lg:inline group-hover:underline truncate max-w-[100px]",children:Q})]}),(0,i.jsx)(c.E.div,{animate:{rotate:D?180:0},transition:{duration:.2},"aria-hidden":"true",children:(0,i.jsx)(y.Z,{className:"ml-1 w-4 h-4"})})]}),(0,i.jsx)(l.M,{children:D&&(0,i.jsxs)(c.E.div,{initial:{opacity:0,y:-10,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-10,scale:.95},transition:{duration:.2,type:"spring",stiffness:300,damping:25},className:"absolute right-0 mt-2 w-64 bg-white/95 dark:bg-gray-900/95 rounded-xl shadow-2xl py-2 border border-gray-200/30 backdrop-blur-md z-50",role:"menu","aria-orientation":"vertical","aria-labelledby":"user-menu-button",children:[(0,i.jsxs)("div",{className:"px-4 py-3 border-b border-gray-100 dark:border-gray-700/30",children:[(0,i.jsx)("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Signed in as"}),(0,i.jsx)("p",{className:"font-medium text-gray-900 dark:text-white text-lg",children:Q}),(0,i.jsx)("div",{className:"absolute -top-1 right-3 w-2 h-2 bg-white dark:bg-gray-900 rotate-45 border-t border-l border-gray-200/30 dark:border-gray-700/30","aria-hidden":"true"})]}),(0,i.jsxs)("div",{className:"py-1",children:[(0,i.jsx)(k,{href:"/my-itineraries",icon:(0,i.jsx)(f.Z,{className:"w-4 h-4","aria-hidden":"true"}),onClick:()=>W(!1),children:"My Itineraries"}),(0,i.jsx)(k,{href:"/account",icon:(0,i.jsx)(p.Z,{className:"w-4 h-4","aria-hidden":"true"}),onClick:()=>W(!1),children:"My Account"}),(0,i.jsx)(k,{href:"/settings",icon:(0,i.jsx)(v.Z,{className:"w-4 h-4","aria-hidden":"true"}),onClick:()=>W(!1),children:"Settings"})]}),(0,i.jsx)("div",{className:"border-t border-gray-100 dark:border-gray-700/30 mt-1 pt-1",children:(0,i.jsxs)("button",{onClick:J,className:"flex items-center w-full text-left px-4 py-2 text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 transition focus:outline-none focus:bg-red-50 dark:focus:bg-red-900/20",role:"menuitem",children:[(0,i.jsx)(x.Z,{className:"w-4 h-4 mr-2","aria-hidden":"true"}),"Logout"]})})]})})]}):(0,i.jsxs)(c.E.div,{whileHover:{scale:1.03},whileTap:{scale:.97},className:"relative group overflow-hidden rounded-full",children:[(0,i.jsx)(c.E.div,{className:"absolute inset-0 bg-gradient-to-r from-blue-500 via-blue-600 to-blue-500 bg-size-200",animate:{backgroundPosition:["0% center","100% center"]},transition:{duration:3,repeat:1/0,repeatType:"reverse"},"aria-hidden":"true"}),(0,i.jsx)(a.default,{href:"/login",className:"relative flex items-center font-medium text-white px-5 py-2.5 rounded-full shadow-md border border-white/20 z-10 focus:outline-none focus:ring-2 focus:ring-white/30 focus:ring-offset-2 focus:ring-offset-blue-600",children:(0,i.jsx)("span",{className:"drop-shadow-sm",children:"Login"})})]})]}),(0,i.jsxs)("div",{className:"flex md:hidden items-center space-x-2",children:[(0,i.jsx)(c.E.button,{className:"p-2 text-white rounded-full hover:bg-white/20 active:bg-white/30 focus:bg-white/20 focus:outline-none focus:ring-2 focus:ring-white/30 border border-white/10",onClick:_,whileHover:{scale:1.1},whileTap:{scale:.9},"aria-label":"Go to world map",children:(0,i.jsx)(w.Z,{className:"w-5 h-5","aria-hidden":"true"})}),(0,i.jsx)(c.E.button,{onClick:B,className:"p-2 text-white rounded-full hover:bg-white/20 active:bg-white/30 focus:bg-white/20 focus:outline-none focus:ring-2 focus:ring-white/30 border border-white/10",whileHover:{scale:1.1},whileTap:{scale:.9},"aria-label":"Toggle mobile menu","aria-expanded":T,"aria-controls":"mobile-menu",children:(0,i.jsx)(l.M,{mode:"wait",children:(0,i.jsx)(c.E.div,{initial:{rotate:-90,opacity:0},animate:{rotate:0,opacity:1},exit:{rotate:90,opacity:0},transition:{duration:.15},children:T?(0,i.jsx)(b.Z,{className:"w-5 h-5","aria-hidden":"true"}):(0,i.jsx)(C.Z,{className:"w-5 h-5","aria-hidden":"true"})},T?"close":"menu")})})]})]}),(0,i.jsx)(l.M,{children:T&&(0,i.jsx)(c.E.div,{ref:P,id:"mobile-menu",initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.3,type:"spring",stiffness:300,damping:30},className:"md:hidden fixed top-[60px] left-0 w-full bg-white/95 dark:bg-gray-900/95 shadow-2xl overflow-hidden backdrop-blur-md border-t border-white/10 z-50",role:"dialog","aria-modal":"true","aria-label":"Mobile navigation menu",children:(0,i.jsx)(c.E.nav,{className:"max-h-[calc(100vh-60px)] overflow-y-auto","aria-label":"Mobile Navigation",initial:{opacity:0},animate:{opacity:1},transition:{delay:.1},children:(0,i.jsxs)("ul",{className:"flex flex-col py-2",role:"menu",children:[U.map((e,t)=>(0,i.jsx)(c.E.li,{initial:{x:-20,opacity:0},animate:{x:0,opacity:1},transition:{delay:.05*t},role:"none",children:(0,i.jsx)(E,{href:e.href,active:A===e.href,onClick:()=>O(!1),icon:e.icon,children:e.name})},e.href)),(0,i.jsx)(c.E.li,{className:"px-4 py-2",initial:{x:-20,opacity:0},animate:{x:0,opacity:1},transition:{delay:.2},role:"none",children:(0,i.jsxs)("button",{onClick:_,className:"w-full text-left py-3 px-4 text-gray-900 dark:text-white rounded-lg flex items-center hover:bg-gray-100 dark:hover:bg-gray-800/30 transition-all active:scale-95 focus:outline-none focus:bg-gray-100 dark:focus:bg-gray-800/30",role:"menuitem",children:[(0,i.jsx)(w.Z,{className:"w-5 h-5 mr-3","aria-hidden":"true"}),"World Map"]})}),(0,i.jsx)("li",{className:"border-t border-gray-100 dark:border-gray-700/30 my-1",role:"separator","aria-hidden":"true"}),e?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(c.E.li,{className:"px-4 py-2",initial:{opacity:0},animate:{opacity:1},transition:{delay:.3},role:"none",children:(0,i.jsxs)("div",{className:"py-2 px-4 flex items-center",children:[(0,i.jsx)("div",{className:"w-10 h-10 bg-gradient-to-br from-blue-500 to-blue-700 rounded-full flex items-center justify-center text-white shadow-md mr-3 border border-white/20","aria-hidden":"true",children:Q.charAt(0).toUpperCase()}),(0,i.jsxs)("div",{children:[(0,i.jsx)("p",{className:"font-medium text-gray-900 dark:text-white",children:Q}),(0,i.jsx)("p",{className:"text-xs text-gray-500",children:"Logged in"})]})]})}),(0,i.jsx)(c.E.li,{initial:{x:-20,opacity:0},animate:{x:0,opacity:1},transition:{delay:.35},role:"none",children:(0,i.jsx)(E,{href:"/my-itineraries",onClick:()=>O(!1),icon:(0,i.jsx)(f.Z,{className:"w-5 h-5 mr-3","aria-hidden":"true"}),children:"My Itineraries"})}),(0,i.jsx)(c.E.li,{initial:{x:-20,opacity:0},animate:{x:0,opacity:1},transition:{delay:.4},role:"none",children:(0,i.jsx)(E,{href:"/account",onClick:()=>O(!1),icon:(0,i.jsx)(p.Z,{className:"w-5 h-5 mr-3","aria-hidden":"true"}),children:"My Account"})}),(0,i.jsx)(c.E.li,{initial:{x:-20,opacity:0},animate:{x:0,opacity:1},transition:{delay:.45},role:"none",children:(0,i.jsx)(E,{href:"/settings",onClick:()=>O(!1),icon:(0,i.jsx)(v.Z,{className:"w-5 h-5 mr-3","aria-hidden":"true"}),children:"Settings"})}),(0,i.jsx)(c.E.li,{className:"px-4 py-2",initial:{x:-20,opacity:0},animate:{x:0,opacity:1},transition:{delay:.5},role:"none",children:(0,i.jsxs)("button",{onClick:()=>{J(),O(!1)},className:"w-full text-left py-3 px-4 text-red-500 rounded-lg flex items-center hover:bg-red-50 dark:hover:bg-red-900/20 transition-all active:scale-95 focus:outline-none focus:ring-2 focus:ring-red-500/40",role:"menuitem",children:[(0,i.jsx)(x.Z,{className:"w-5 h-5 mr-3","aria-hidden":"true"}),"Logout"]})})]}):(0,i.jsx)(c.E.li,{className:"px-4 py-2",initial:{y:20,opacity:0},animate:{y:0,opacity:1},transition:{delay:.3},role:"none",children:(0,i.jsx)(a.default,{href:"/login",className:"block w-full py-3 px-4 bg-gradient-to-r from-blue-500 to-blue-700 text-white font-medium rounded-lg text-center transition shadow-md active:scale-95 border border-white/20 focus:outline-none focus:ring-2 focus:ring-blue-500/50",onClick:()=>O(!1),role:"menuitem",children:"Login"})})]})})})})]})}function N(e){let{href:t,children:r,icon:n,active:o}=e,s=o||!1;return(0,i.jsxs)(a.default,{href:t,className:"relative px-3 py-2 rounded-md text-white font-medium transition-all duration-200 ".concat(s?"bg-white/15":"hover:bg-white/10"," focus:bg-white/15 focus:outline-none focus:ring-2 focus:ring-white/30 group"),"aria-current":s?"page":void 0,children:[(0,i.jsxs)("span",{className:"flex items-center ".concat(s?"opacity-100":"opacity-90 group-hover:opacity-100"),children:[n&&(0,i.jsx)(c.E.span,{animate:s?{scale:[1,1.2,1],rotate:[0,5,0],transition:{repeat:1/0,repeatDelay:5}}:{},className:"".concat(s?"text-white":"text-white/90 group-hover:text-white"),children:n}),(0,i.jsx)("span",{className:"".concat(s?"translate-x-0.5":""," group-hover:translate-x-0.5 transition-transform duration-200"),children:r})]}),s&&(0,i.jsx)(c.E.div,{layoutId:"navigation-underline",className:"absolute bottom-0 left-0 right-0 h-0.5 bg-white rounded-full",initial:{opacity:0,width:0,x:"50%"},animate:{opacity:1,width:"100%",x:0},transition:{duration:.3},"aria-hidden":"true"})]})}function k(e){let{href:t,children:r,icon:n,onClick:o}=e;return(0,i.jsx)(c.E.div,{whileHover:{x:3},transition:{type:"spring",stiffness:400},children:(0,i.jsxs)(a.default,{href:t,className:"flex items-center px-4 py-2 text-gray-900 dark:text-white hover:bg-gray-100 dark:hover:bg-gray-800/30 transition-all rounded-md mx-1 focus:outline-none focus:bg-gray-100 dark:focus:bg-gray-800/30",onClick:o,role:"menuitem",children:[n&&(0,i.jsx)(c.E.span,{className:"mr-2 text-gray-600 dark:text-gray-300",whileHover:{rotate:15},"aria-hidden":"true",children:n}),(0,i.jsx)("span",{className:"font-medium",children:r})]})})}function E(e){let{href:t,children:r,active:n,onClick:o,icon:s}=e;return(0,i.jsx)(a.default,{href:t,className:"block py-3 px-8 text-gray-900 dark:text-white transition-all active:scale-95 focus:outline-none focus:ring-2 focus:ring-gray-500/40 rounded-md mx-2 ".concat(n?"bg-gray-50 dark:bg-gray-800/30 font-medium border-l-4 border-blue-600":"hover:bg-gray-50 dark:hover:bg-gray-800/20 focus:bg-gray-50 dark:focus:bg-gray-800/20"),onClick:o,role:"menuitem","aria-current":n?"page":void 0,children:(0,i.jsxs)("div",{className:"flex items-center",children:[s&&(0,i.jsx)("span",{"aria-hidden":"true",className:n?"text-blue-600":"",children:s}),(0,i.jsx)("span",{className:"ml-1 ".concat(n?"text-blue-600 dark:text-blue-400":""),children:r})]})})}},28634:function(e,t,r){"use strict";r.d(t,{H:function(){return y},a:function(){return m}});var i=r(57437),a=r(2265),n=r(3141),o=r(57685),s=r.n(o),c=r(50309),l=r.n(c),u=r(6021);let d="auth_data",h="/api/auth/user",g=(0,a.createContext)({isAuthenticated:!1,isVerifying:!0,username:null,firstName:null,email:null,login:()=>{},logout:()=>{},refreshAuth:async()=>{}}),m=()=>(0,a.useContext)(g),y=e=>{let{children:t}=e,[r,o]=(0,a.useState)(!1),[c,m]=(0,a.useState)(!0),[y,f]=(0,a.useState)(null),[p,v]=(0,a.useState)(null),[x,w]=(0,a.useState)(null),b=(0,a.useRef)(!1),[C]=(0,a.useState)(!1),S=(0,a.useCallback)(e=>{if(!e){(0,u.safeSetItem)(d,""),(0,u.writeToSWRCache)(h,null);return}let t={userData:e,expiresAt:Date.now()+864e5};(0,u.safeSetItem)(d,JSON.stringify(t)),(0,u.writeToSWRCache)(h,e),console.debug("Auth data cached successfully")},[]),j=(0,a.useCallback)(()=>{try{let e=(0,u.safeGetItem)(d);if(!e)return null;let t=JSON.parse(e);if(t.expiresAt&&t.expiresAt0&&void 0!==arguments[0]&&arguments[0];if(C){o(!1),f(null),v(null),w(null),m(!1);return}if(!b.current){b.current=!0,m(!0);try{console.log("Checking authentication status...");let t=null;if(!e&&(t=j())){let e=t.username||"",r=t.first_name?s()(l()(t.first_name)):null,i=t.email||null;console.log("✅ Using cached auth data for:",e),f(e),v(r),w(i),o(!0),m(!1),b.current=!1;return}let r=await (0,n.WX)();if(r){let e=r.username||"",i=r.first_name?s()(l()(r.first_name)):null,a=r.email||null;t={username:e,first_name:i,email:a},f(e),v(i),w(a),o(!0),S(t),console.log("✅ User authenticated via API:",e)}else S(null),o(!1),f(null),v(null),w(null)}catch(e){console.error("❌ Token verification failed:",e),o(!1),f(null),v(null),w(null),S(null)}finally{m(!1),b.current=!1}}},[C,j,S]),k=(0,a.useCallback)(async()=>{await N(!0)},[N]);(0,a.useEffect)(()=>{N()},[N]);let E=(0,a.useCallback)(()=>{console.log("Starting logout process"),S(null),window.location.href="/logout"},[S]),I=(0,a.useCallback)((e,t,r)=>{f(e),v(s()(l()(t))),w(r),o(!0),S({username:e,first_name:t,email:r})},[S]);return(0,i.jsxs)(g.Provider,{value:{isAuthenticated:r,isVerifying:c,username:y,firstName:p,email:x,login:I,logout:E,refreshAuth:k},children:[!c&&t," "]})}},3141:function(e,t,r){"use strict";r.d(t,{WX:function(){return c},a$:function(){return u},pH:function(){return l}});var i=r(41121),a=r(43577);let n=(e,t)=>{if(e instanceof a.d7){if("ECONNABORTED"===e.code)throw Error("Connection timeout. Please check your network");if(!e.response)throw Error("Network error. Please check your connection");throw Error(e.response.data.detail||e.response.data.error||t)}throw Error(t)},o=async()=>{try{return(await i.Z.post("/auth/token/refresh/")).data}catch(e){return n(e,"Session expired. Please log in again.")}},s=0,c=async()=>{try{let e=await i.Z.get("/auth/verify/");return s=0,e.data}catch(t){var e;if(t instanceof a.d7&&(null===(e=t.response)||void 0===e?void 0:e.status)===401&&s<2)return s++,await o(),c();return n(t,"Authentication failed")}},l=async(e,t)=>{try{console.log("Sending login request with:",{username:e,password:"****"});let r=await i.Z.post("/auth/login/",{username:e,password:t});return console.log("Login response received"),r.data}catch(e){return console.error("Login error:",e),n(e,"Login failed")}},u=async(e,t,r,a,o)=>{try{return(await i.Z.post("/auth/register/",{username:e,email:t,password:r,first_name:a,last_name:o})).data}catch(e){return n(e,"Registration failed")}}},8626:function(e,t,r){"use strict";r.d(t,{cW:function(){return s}});var i=r(6021),a=r(9212),n=r(96965),o=r(6275);class s{static async runFullDiagnostic(){console.log("\uD83D\uDD0D Starting full cache diagnostic...");let e=performance.now(),t={timestamp:Date.now(),formattedTime:new Date().toISOString(),tests:{}};t.tests.localStorage=this.testLocalStorage(),t.tests.swrCache=await this.testSWRCache(),t.tests.countryCache=this.testCountryCache(),t.tests.cityCache=this.testCityCache(),t.tests.cacheSync=await this.testCacheSync(),t.overallHealth=this.calculateOverallHealth(t.tests);let r=performance.now();return t.diagnosticTime=r-e,this.diagnosticHistory.push({timestamp:Date.now(),diagnosticType:"full",result:t}),console.log("✅ Full diagnostic completed in ".concat(t.diagnosticTime.toFixed(2),"ms")),console.log("Diagnostic results:",t),t}static testLocalStorage(){console.log("Testing localStorage...");let e={available:!1,writePerformance:void 0,readPerformance:void 0,size:void 0};try{let t="__cache_test_key__",r="Cache test value: "+Date.now(),n=performance.now();localStorage.setItem(t,r);let o=performance.now();e.writePerformance=o-n;let s=performance.now(),c=localStorage.getItem(t),l=performance.now();e.readPerformance=l-s,e.available=c===r,localStorage.removeItem(t);let u=(0,i.safeGetItem)(a.oy);u&&(e.size=Math.round(u.length/1024)+" KB"),console.log("localStorage test successful")}catch(t){console.error("localStorage test failed:",t),e.error=String(t)}return e}static async testSWRCache(){console.log("Testing SWR cache...");let e={exists:!1,valid:!1,entryCount:0,keyTypes:{},repairAttempted:!1,repairResult:null};try{var t,r,n,o,s,c,l;let u=(0,i.getCacheStatus)();if(e.status=u,e.exists=!!(null===(t=u.swr)||void 0===t?void 0:t.exists),e.entryCount=(null===(r=u.swr)||void 0===r?void 0:r.entryCount)||0,e.exists){e.valid=null===(n=u.swr)||void 0===n||!n.parseError;let t=(0,i.safeGetItem)(a.oy);if(t)try{let r=JSON.parse(t);if(Array.isArray(r)){let t={};r.forEach(e=>{if(Array.isArray(e)&&e.length>0){let r=e[0],i=this.categorizeKey(r);t[i]=(t[i]||0)+1}}),e.keyTypes=t}}catch(t){e.parseError=String(t)}if(!e.valid){console.log("SWR cache is invalid, attempting repair..."),e.repairAttempted=!0;let t=(0,i.validateAndRepairCache)();e.repairResult=t;let r=(0,i.getCacheStatus)();e.valid=null===(o=r.swr)||void 0===o||!o.parseError}}else{console.log("SWR cache not found, attempting to initialize..."),e.initializationAttempted=!0,(0,i.syncAllCachesWithSWR)();let t=(0,i.getCacheStatus)();e.exists=!!(null===(s=t.swr)||void 0===s?void 0:s.exists),e.entryCount=(null===(c=t.swr)||void 0===c?void 0:c.entryCount)||0,e.valid=null===(l=t.swr)||void 0===l||!l.parseError}console.log("SWR cache test completed")}catch(t){console.error("SWR cache test failed:",t),e.error=String(t)}return e}static testCountryCache(){var e,t,r;console.log("Testing country cache...");let i={allCountries:{exists:!!n.cache.allCountries,count:(null===(e=n.cache.allCountries)||void 0===e?void 0:e.length)||0,timestamp:n.cache.timestamps.allCountries,fresh:!1},featuredCountries:{exists:!!n.cache.featuredCountries,count:(null===(t=n.cache.featuredCountries)||void 0===t?void 0:t.length)||0,timestamp:n.cache.timestamps.featuredCountries,fresh:!1},minimalCountries:{exists:!!n.cache.minimalCountries,count:(null===(r=n.cache.minimalCountries)||void 0===r?void 0:r.length)||0,timestamp:n.cache.timestamps.minimalCountries,fresh:!1},countriesByRegion:{count:Object.keys(n.cache.countriesByRegion).length,regions:Object.keys(n.cache.countriesByRegion)},countriesByContinent:{count:Object.keys(n.cache.countriesByContinent).length,continents:Object.keys(n.cache.countriesByContinent)}},a=Date.now();if(n.cache.timestamps.allCountries>0){let e=a-n.cache.timestamps.allCountries;i.allCountries.age=e,i.allCountries.fresh=e0){let e=a-n.cache.timestamps.featuredCountries;i.featuredCountries.age=e,i.featuredCountries.fresh=e0){let e=a-n.cache.timestamps.minimalCountries;i.minimalCountries.age=e,i.minimalCountries.fresh=e0){let e=r-o.cache.timestamps.allCities;t.allCities.age=e,t.allCities.fresh=e0,e.citiesInSync=k===I&&I>0,e.isFullyInSync=e.countriesInSync&&e.citiesInSync,console.log("Cache sync test completed")}catch(t){console.error("Cache sync test failed:",t),e.error=String(t)}return e}static startMonitoring(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:6e4;if(this.isMonitoring){console.log("Cache monitoring is already active");return}console.log("Starting cache monitoring every ".concat(e/1e3," seconds")),this.monitoringFrequency=e,this.isMonitoring=!0,this.runQuickDiagnostic(),this.monitoringInterval=setInterval(()=>{this.runQuickDiagnostic()},e)}static stopMonitoring(){if(!this.isMonitoring){console.log("Cache monitoring is not active");return}console.log("Stopping cache monitoring"),this.monitoringInterval&&(clearInterval(this.monitoringInterval),this.monitoringInterval=null),this.isMonitoring=!1}static async runQuickDiagnostic(){var e,t,r,n,o,s,c,l,u,d,h,g,m,y,f,p,v,x,w,b,C,S,j;let N=performance.now(),k={timestamp:Date.now(),formattedTime:new Date().toISOString()},E=(0,i.getCacheStatus)();k.swr={exists:!!(null===(e=E.swr)||void 0===e?void 0:e.exists),entryCount:(null===(t=E.swr)||void 0===t?void 0:t.entryCount)||0,valid:!(null===(r=E.swr)||void 0===r?void 0:r.parseError)},k.country={allCountries:{exists:!!(null===(o=E.countryCache)||void 0===o?void 0:null===(n=o.allCountries)||void 0===n?void 0:n.exists),count:(null===(c=E.countryCache)||void 0===c?void 0:null===(s=c.allCountries)||void 0===s?void 0:s.count)||0,fresh:((null===(u=E.countryCache)||void 0===u?void 0:null===(l=u.allCountries)||void 0===l?void 0:l.age)||1/0)=90?"Excellent":Number(t.score)>=70?"Good":Number(t.score)>=50?"Fair":"Poor",t}static getHistory(){return this.diagnosticHistory}static clearHistory(){this.diagnosticHistory=[]}static categorizeKey(e){return e.includes("/trip/countries/")?"country":e.includes("/trip/cities/")?"city":e.includes("/trip/regions/")?"region":e.includes("/search/")?"search":e.includes("/authentication/")?"auth":"other"}static async repairCacheSystem(){console.log("\uD83D\uDD27 Starting cache system repair...");let e={timestamp:Date.now(),repairSteps:[]},t=await this.runFullDiagnostic();e.initialDiagnostic=t;let r=t.tests,a=null==r?void 0:r.swrCache;a&&!1===a.valid&&(console.log("Repairing SWR cache..."),e.repairSteps.push({step:"Repair SWR cache",success:(0,i.validateAndRepairCache)()})),console.log("Running cache migration..."),e.repairSteps.push({step:"Cache migration",success:(0,i.migrateCache)()}),console.log("Syncing all caches...");let n=(0,i.syncAllCachesWithSWR)();e.repairSteps.push({step:"Sync all caches",success:n.success,details:n});let o=await this.runFullDiagnostic();e.finalDiagnostic=o;let s=t.overallHealth.score,c=o.overallHealth.score;return e.overallSuccess=c>s,e.improvement=c-s,console.log("✅ Cache repair completed with ".concat(e.overallSuccess?"success":"partial success")),console.log("Health score improvement: ".concat(e.improvement," points")),e}static async forceRefreshAllCaches(){console.log("\uD83D\uDD04 Forcing refresh of all caches from API...");let e=performance.now(),t={timestamp:Date.now(),refreshed:{countries:!1,cities:!1}};try{let{fetchCountries:i}=await Promise.resolve().then(r.bind(r,46215)),{fetchCities:a}=await Promise.resolve().then(r.bind(r,6275));console.log("Fetching countries from API...");try{let e=await i();t.refreshed.countries=!0,t.countriesCount=e.length}catch(e){console.error("Failed to refresh countries:",e),t.countryError=String(e)}console.log("Fetching cities from API...");try{let e=await a();t.refreshed.cities=!0,t.citiesCount=e.length}catch(e){console.error("Failed to refresh cities:",e),t.cityError=String(e)}let n=await this.runQuickDiagnostic();t.diagnostic=n;let o=performance.now();t.refreshTime=o-e,console.log("✅ Cache refresh completed in ".concat(t.refreshTime.toFixed(2),"ms"))}catch(e){console.error("Cache refresh failed:",e),t.error=String(e)}return t}}s.diagnosticHistory=[],s.isMonitoring=!1,s.monitoringInterval=null,s.monitoringFrequency=6e4,t.ZP=s},20096:function(e,t,r){"use strict";r.d(t,{x:function(){return s}});var i=r(6021),a=r(9212),n=r(96965),o=r(6275);class s{static getInstance(){return s.instance||(s.instance=new s),s.instance}static logOperation(e,t,r,i,a){s.isEnabled&&("read"===e?s.counters.reads++:"write"===e?s.counters.writes++:"sync"===e&&s.counters.syncs++,!i&&s.counters.errors++,s.operationLog.push({timestamp:Date.now(),operation:e,source:t,key:r,success:i,dataSize:a}),s.operationLog.length>s.maxLogEntries&&(s.operationLog=s.operationLog.slice(s.operationLog.length-s.maxLogEntries)))}static getStats(){let e=s.counters.reads+s.counters.writes;return{enabled:s.isEnabled,autoSync:s.autoSyncEnabled,counters:{...s.counters},logEntries:s.operationLog.length,recentOperations:s.operationLog.slice(-5),errorRate:0===e?0:s.counters.errors/e*100}}static getLog(){return[...s.operationLog]}static clearLog(){s.operationLog=[],console.log("Cache operation log cleared")}static resetCounters(){s.counters={reads:0,writes:0,syncs:0,errors:0,repairs:0},console.log("Cache operation counters reset")}static enable(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(s.isEnabled){console.log("Cache interceptor is already enabled");return}console.log("Enabling cache interceptor"),s.isEnabled=!0,void 0!==e.autoSync&&(s.autoSyncEnabled=e.autoSync),e.maxLogEntries&&(s.maxLogEntries=e.maxLogEntries),s.installInterceptors(),console.log("Cache interceptor enabled with autoSync=".concat(s.autoSyncEnabled))}static disable(){if(!s.isEnabled){console.log("Cache interceptor is already disabled");return}console.log("Disabling cache interceptor"),s.isEnabled=!1,s.removeInterceptors(),console.log("Cache interceptor disabled")}static forceSync(){console.log("Forcing cache synchronization...");try{let e=(0,i.syncAllCachesWithSWR)();return s.logOperation("sync","manual","all",e.success),s.counters.syncs++,console.log("Cache sync ".concat(e.success?"successful":"failed")),!e.success&&e.error&&console.error("Sync error:",e.error),e.success}catch(e){return console.error("Force sync failed:",e),s.logOperation("sync","manual","all",!1),s.counters.errors++,!1}}static autoFix(){console.log("Auto-fixing cache issues...");let e={timestamp:Date.now(),fixAttempts:[]};try{console.log("Step 1: Validating and repairing SWR cache...");let t=(console.log("validateAndRepairCache implementation pending"),!0);e.fixAttempts.push({step:"Repair SWR cache",success:t}),console.log("Step 2: Syncing all caches...");let r=(0,i.syncAllCachesWithSWR)();e.fixAttempts.push({step:"Sync caches",success:r.success,details:r});let o=this.checkCacheStatus();if(e.cacheStatus=o,!o.cacheSync.countriesInSync&&o.countryCache.exists&&o.swrCache.exists){console.log("Step 3: Fixing country cache sync issue...");try{if(o.countryCache.count>o.swrCache.countryCount&&o.countryCache.count>0)console.log("Country cache has more data, updating SWR..."),(0,i.writeToSWRCache)("/trip/countries/",n.cache.allCountries),e.fixAttempts.push({step:"Update SWR with country cache",success:!0});else if(o.swrCache.countryCount>0){console.log("SWR has more data, updating country cache...");let t=(0,i.safeGetItem)(a.oy);if(t)try{let r=JSON.parse(t);if(Array.isArray(r)){let t=r.find(e=>Array.isArray(e)&&e.length>1&&e[0]&&"string"==typeof e[0]&&e[0].includes("/trip/countries/"));t&&t[1]&&"object"==typeof t[1]&&null!==t[1]&&"data"in t[1]&&((0,n.ax)("allCountries",t[1].data),e.fixAttempts.push({step:"Update country cache with SWR",success:!0}))}}catch(t){console.error("Error parsing SWR cache:",t),e.fixAttempts.push({step:"Update country cache with SWR",success:!1,error:String(t)})}}}catch(t){console.error("Error fixing country sync:",t),e.fixAttempts.push({step:"Fix country sync",success:!1,error:String(t)})}}!o.cacheSync.citiesInSync&&o.cityCache.exists&&o.swrCache.exists&&(console.log("Step 4: Fixing city cache sync issue..."),e.fixAttempts.push({step:"Fix city sync",note:"City sync fix implementation pending"}));let s=this.checkCacheStatus();return e.finalStatus=s,e.improved=s.cacheSync.countriesInSync&&!o.cacheSync.countriesInSync||s.cacheSync.citiesInSync&&!o.cacheSync.citiesInSync,console.log("Auto-fix completed with ".concat(e.improved?"improvements":"no change")),e}catch(t){return console.error("Auto-fix failed:",t),e.error=String(t),e}}static checkCacheStatus(){try{var e,t;let r=(0,i.safeGetItem)(a.oy),s={exists:!!r,valid:!1,count:0,countryCount:0,cityCount:0};if(r)try{let e=JSON.parse(r);if(s.valid=Array.isArray(e),s.count=s.valid?e.length:0,s.valid){let t=e.find(e=>Array.isArray(e)&&e.length>1&&e[0]&&"string"==typeof e[0]&&e[0].includes("/trip/countries/")),r=e.find(e=>Array.isArray(e)&&e.length>1&&e[0]&&"string"==typeof e[0]&&e[0].includes("/trip/cities/"));if(t&&t[1]&&"object"==typeof t[1]&&null!==t[1]&&"data"in t[1]){let e=t[1].data;s.countryCount=Array.isArray(e)?e.length:0}if(r&&r[1]&&"object"==typeof r[1]&&null!==r[1]&&"data"in r[1]){let e=r[1].data;s.cityCount=Array.isArray(e)?e.length:0}}}catch(e){s.valid=!1}let c={exists:!!n.cache.allCountries,count:(null===(e=n.cache.allCountries)||void 0===e?void 0:e.length)||0},l={exists:!!o.cache.allCities,count:(null===(t=o.cache.allCities)||void 0===t?void 0:t.length)||0},u={countriesInSync:s.countryCount===c.count&&c.count>0,citiesInSync:s.cityCount===l.count&&l.count>0};return{swrCache:s,countryCache:c,cityCache:l,cacheSync:u}}catch(e){return console.error("Error checking cache status:",e),{error:String(e),swrCache:{exists:!1,valid:!1,count:0,countryCount:0,cityCount:0},countryCache:{exists:!1,count:0},cityCache:{exists:!1,count:0},cacheSync:{countriesInSync:!1,citiesInSync:!1}}}}static removeInterceptors(){console.log("Interceptor removal not fully implemented")}static installInterceptors(){try{let e=localStorage.setItem;localStorage.setItem=function(t,r){if(e.call(localStorage,t,r),(t===a.oy||t===a.TI)&&(s.logOperation("write","localStorage",t,!0,r.length),s.autoSyncEnabled&&t===a.oy))try{t===a.oy&&(e.call(localStorage,a.TI,r),s.logOperation("sync","interceptor",a.TI,!0)),setTimeout(()=>{try{(0,i.syncAllCachesWithSWR)(),s.counters.syncs++}catch(e){console.error("Auto-sync error:",e),s.counters.errors++}},50)}catch(e){console.error("Error during cache sync:",e),s.logOperation("sync","interceptor","all",!1),s.counters.errors++}};let t=localStorage.getItem;localStorage.getItem=function(r){let n=t.call(localStorage,r);if((r===a.oy||r===a.TI)&&(s.logOperation("read","localStorage",r,null!==n,null==n?void 0:n.length),s.autoSyncEnabled&&r===a.oy&&n))try{try{let r=JSON.parse(n),o=(0,i.validateCacheData)(r);o.valid||(console.warn("Cache validation failed on read: ".concat(o.reason)),s.counters.errors++,setTimeout(()=>{try{let r=t.call(localStorage,a.TI);if(r)try{let t=JSON.parse(r);(0,i.validateCacheData)(t).valid&&(e.call(localStorage,a.oy,r),s.logOperation("repair","interceptor",a.oy,!0),s.counters.repairs++)}catch(e){console.error("Both caches are invalid, cannot auto-repair")}}catch(e){console.error("Auto-repair failed:",e)}},10))}catch(e){console.error("Cache parse error during validation:",e),s.counters.errors++}}catch(e){console.error("Error during cache validation:",e)}return n};let r=i.writeToSWRCache,o=window;o.originalWriteToSWR=i.writeToSWRCache,o.writeToSWRCache=function(e,t){let i=!(arguments.length>2)||void 0===arguments[2]||arguments[2];return s.logOperation("write","writeToSWRCache",e,!0),s.counters.writes++,r(e,t,i)};let c=n.ax;o.originalSetCountryCache=n.ax,o.setCountryCache=function(e,t,r){s.logOperation("write","countryCache",r?"".concat(e,":").concat(r):String(e),!0),s.counters.writes++,c(e,t,r),s.autoSyncEnabled&&"allCountries"===e&&setTimeout(()=>{try{(0,i.writeToSWRCache)("/trip/countries/",t),s.logOperation("sync","interceptor","/trip/countries/",!0)}catch(e){console.error("Error syncing country data to SWR:",e)}},10)},console.log("Cache interceptors installed successfully")}catch(e){console.error("Failed to install cache interceptors:",e)}}constructor(){}}s.operationLog=[],s.isEnabled=!1,s.autoSyncEnabled=!1,s.maxLogEntries=100,s.counters={reads:0,writes:0,syncs:0,errors:0,repairs:0}},2778:function(){}},function(e){e.O(0,[5676,7110,9237,2461,3464,5183,156,7648,6484,422,3495,3354,6706,6215,2971,2117,1744],function(){return e(e.s=26862)}),_N_E=e.O()}]);