1var ea=Object.defineProperty;var ta=(n,s,l)=>s in n?ea(n,s,{enumerable:!0,configurable:!0,writable:!0,value:l}):n[s]=l;var St=(n,s,l)=>ta(n,typeof s!="symbol"?s+"":s,l);import{o as aa,u as sa,j as t,a3 as oa,X as at,J as st,a4 as tt,a5 as Ke,a6 as ke,a7 as ra,a8 as ia,a9 as na,f as la,w as ca,aa as Ce,ab as U,y as da,ac as ua,ad as ma,i as Ct,l as ga,h as fa,U as $t,L as It,z as xa,ae as Lt,af as At,V as ha,S as pa,ag as ya,g as ba}from"./main-BR3rc-Qy.js";import{r as o,R as _a}from"./vendor-CtfvRvi8.js";import Na from"./CurationDetailPage-DRqUTvod.js";import{L as Mt}from"./log-in-CIFkWipF.js";import{P as wa}from"./pen-aq2fSb9x.js";import{u as va}from"./router-BamZFab8.js";import"./categoryIconMapping-CpWJBcs7.js";import"./flame-VZc6otD1.js";import"./sliders-horizontal-y5ygA4EC.js";/** 2 * @license lucide-react v0.562.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const ja=[["path",{d:"M18 21a8 8 0 0 0-16 0",key:"3ypg7q"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M22 20c0-3.37-2-6.5-4-8a5 5 0 0 0-.45-8.3",key:"10s06x"}]],Sa=aa("users-round",ja),Ca=["1 mile","3 miles","5 miles","10 miles","15 miles","25 miles","Custom"],Ia=["$","$$","$$$","$$$$"],La=["trendy","cozy","casual","elegant","rustic","modern","lively","quiet"],Aa=["romantic","family friendly","celebrations","solo dining","quick bite","group dining","business casual"],Ma=["vegan","vegetarian","gluten-free","halal","kosher","dairy-free"],$a=["American","Italian","Mexican","Chinese","Japanese","Indian","Thai","Mediterranean","French","Korean","Vietnamese","Greek","Spanish","Lebanese"];function Ta({isOpen:n,onClose:s,onNearMeSelected:l,onLoginClick:c}){const{user:y}=sa(),C=!!y,[S,Y]=o.useState("3 miles"),[v,K]=o.useState(!1),[k,P]=o.useState(""),[p,h]=o.useState(),[d,j]=o.useState([]),[x,b]=o.useState([]),[E,W]=o.useState([]),[R,H]=o.useState(),[M,D]=o.useState(!1),[N,ie]=o.useState(!0),[ue,Ie]=o.useState(""),[ye,me]=o.useState("Current Location (GPS)"),[Pe,oe]=o.useState(!0),[Z,O]=o.useState(!0),[be,ge]=o.useState(!0),[Le,Oe]=o.useState(!0),[Ue,Re]=o.useState(!1),[Ae,_e]=o.useState(null),Q=o.useRef(null),fe=o.useRef(null);o.useEffect(()=>{n&&We()},[n]);const We=async()=>{try{if(!navigator.geolocation){me("Location not supported");return}navigator.geolocation.getCurrentPosition(async u=>{const{latitude:L,longitude:F}=u.coords;try{const B=(await(await fetch(`https://nominatim.openstreetmap.org/reverse?format=json&lat=${L}&lon=${F}`,{headers:{"User-Agent":"GrubTok/1.0.0 (web-app; [email protected])"}})).json()).address||{},J=B.state;let re=null;if(B.city)re=J?`${B.city}, ${J}`:B.city;else if(B.town)re=J?`${B.town}, ${J}`:B.town;else if(B.village)re=J?`${B.village}, ${J}`:B.village;else{const ne=B.city||B.town||B.village||B.suburb||B.island;ne&&(re=J?`${ne}, ${J}`:ne)}me(re||"Current Location")}catch{me("Current Location")}},()=>{me("Location Permission Required")},{timeout:1e4})}catch{me("Current Location")}},xe=u=>{u==="Custom"?(K(!0),Y("Custom")):(K(!1),Y(u),P(""))},Ve=u=>{j(L=>L.includes(u)?L.filter(F=>F!==u):[...L,u])},qe=u=>{b(L=>L.includes(u)?L.filter(F=>F!==u):[...L,u])},he=u=>{W(L=>L.includes(u)?L.filter(F=>F!==u):[...L,u])},De=()=>v&&(!k||parseFloat(k)<=0)?"Please enter a valid distance greater than 0":v&&parseFloat(k)>100?"Maximum distance is 100 miles":!N&&!ue.trim()?"Please enter a location (zip code, address, or city)":null,Fe=async u=>{try{const F=await(await fetch(`https://nominatim.openstreetmap.org/search?q=${encodeURIComponent(u)}&format=json&limit=1&addressdetails=1`,{headers:{"User-Agent":"GrubTok/1.0.0 (web-app; [email protected])"}})).json();return F&&F.length>0?{lat:parseFloat(F[0].lat),lng:parseFloat(F[0].lon),name:u.trim()}:null}catch(L){return console.error("Geocoding error:",L),null}},pe=async()=>{if(!C){_e("Please sign in to use Near Me recommendations"),c&&setTimeout(()=>{s(),c()},1500);return}const u=De();if(u){_e(u);return}_e(null),Re(!0);try{let L,F,X;if(N){const J=await new Promise((re,ne)=>{if(!navigator.geolocation){ne(new Error("Geolocation not supported"));return}navigator.geolocation.getCurrentPosition(re,ne,{timeout:1e4})});L=J.coords.latitude,F=J.coords.longitude}else{const J=await Fe(ue.trim());if(!J)throw new Error(`Unable to find location: ${ue}. Please try a different address or use current location.`);L=J.lat,F=J.lng,X=J.name}let Ne=S;v&&k&&(Ne=`${k} miles`);const B={distance:Ne,price:p,vibes:d.length>0?d:void 0,experience:x.length>0?x:void 0,dietary:E.length>0?E:void 0,cuisine:R,latitude:L,longitude:F,customLocationName:X,filters:{openNow:M}};l(B),s()}catch(L){_e(L.message||"Unable to get your location. Please try again.")}finally{Re(!1)}};return n?t.jsx("div",{className:"fixed inset-0 z-50 flex items-end justify-center bg-black bg-opacity-50",onClick:s,children:t.jsxs("div",{className:"bg-surface rounded-t-2xl w-full max-w-2xl max-h-[90vh] flex flex-col shadow-xl",onClick:u=>u.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center justify-between px-5 py-4 rounded-t-2xl shadow-md shadow-black/5 z-10",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(oa,{className:"w-5 h-5 text-teal",fill:"
6currentColor"}),t.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:"Filters"})]}),t.jsx("button",{onClick:s,className:"p-1 hover:bg-gray-100 rounded-full transition-colors",children:t.jsx(at,{className:"w-5 h-5 text-gray-500"})})]}),Ae&&t.jsxs("div",{className:"mx-5 mt-4 p-3 bg-red-900/20 border border-red-700 rounded-lg flex items-start gap-2",children:[t.jsx("span",{className:"text-red-600 text-sm",children:"â ï¸"}),t.jsx("p",{className:"text-sm text-red-700 flex-1",children:Ae})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4",children:[t.jsxs("div",{className:"mb-5",children:[t.jsx("label",{className:"block text-base font-semibold text-gray-900 mb-3",children:"Location*"}),t.jsxs("div",{className:"flex gap-2 mb-3",children:[t.jsx("button",{onClick:()=>{ie(!0),Ie(""),setTimeout(()=>{We()},0)},className:`px-4 py-2 rounded-lg text-sm font-medium transition-colors ${N?"bg-teal/10 text-teal border-2 border-teal/70":"bg-gray-100 text-gray-700 border-2 border-transparent"}`,children:"Current Location"}),t.jsx("button",{onClick:()=>{ie(!1),me("Enter zip, address or city")},className:`px-4 py-2 rounded-lg text-sm font-medium transition-colors ${N?"bg-gray-100 text-gray-700 border-2 border-transparent":"bg-teal/10 text-teal border-2 border-teal/70"}`,children:"Enter Location"})]}),t.jsx("div",{className:`p-3 rounded-lg border ${N?"bg-gray-50 border-gray-300":"bg-surface border-gray-300"}`,children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(st,{className:`w-5 h-5 ${N?"text-gray-400":"text-teal"}`}),N?t.jsx("span",{className:"text-gray-600",children:ye}):t.jsx(t.Fragment,{children:t.jsx("input",{ref:fe,type:"text",value:ue,onChange:u=>Ie(u.target.value),placeholder:"Enter any zip code, address, or city",className:"flex-1 bg-transparent border-none outline-none text-sm"})})]})}),!N&&t.jsx("p",{className:"mt-2 text-xs text-gray-500 italic",children:"Examples: 06902, 123 Main St, San Francisco CA, London UK"})]}),t.jsxs("div",{className:"mb-5",children:[t.jsx("label",{className:"block text-base font-semibold text-gray-900 mb-3",children:"Distance*"}),t.jsx("div",{className:"flex flex-wrap gap-2",children:Ca.map(u=>t.jsx("button",{onClick:()=>xe(u),className:`px-4 py-2 rounded-lg text-sm font-medium transition-colors ${v&&u==="Custom"||!v&&S===u?"bg-teal/10 text-teal border-2 border-teal/70":"bg-gray-100 text-gray-700 border-2 border-transparent"}`,children:u},u))}),v&&t.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[t.jsx("input",{ref:Q,type:"number",value:k,onChange:u=>P(u.target.value),placeholder:"Enter distance",min:"0.1",max:"100",step:"0.1",className:"flex-1 px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-teal"}),t.jsx("span",{className:"text-gray-600",children:"miles"})]})]}),t.jsxs("div",{className:"mb-5",children:[t.jsxs("button",{onClick:()=>oe(!Pe),className:"flex items-center justify-between w-full mb-3",children:[t.jsx("label",{className:"text-base font-semibold text-gray-900",children:"Price"}),Pe?t.jsx(tt,{className:"w-5 h-5 text-gray-400"}):t.jsx(Ke,{className:"w-5 h-5 text-gray-400"})]}),Pe&&t.jsx("div",{className:"grid grid-cols-2 gap-3",children:Ia.map(u=>t.jsx("button",{onClick:()=>h(p===u?void 0:u),className:`p-2 rounded-lg border transition-colors ${p===u?"bg-teal/10 border-2 border-teal/70 text-teal":"bg-surface border-gray-300 text-gray-700"}`,children:t.jsx("span",{className:"font-semibold",children:u})},u))})]}),t.jsxs("div",{className:"mb-5",children:[t.jsxs("button",{onClick:()=>O(!Z),className:"flex items-center justify-between w-full mb-3",children:[t.jsx("label",{className:"text-base font-semibold text-gray-900",children:"Vibes"}),Z?t.jsx(tt,{className:"w-5 h-5 text-gray-400"}):t.jsx(Ke,{className:"w-5 h-5 text-gray-400"})]}),Z&&t.jsx("div",{className:"grid grid-cols-2 gap-3",children:La.map(u=>t.jsx("button",{onClick:()=>Ve(u),className:`p-2 rounded-lg border transition-colors text-sm font-medium ${d.includes(u)?"bg-teal/10 border-2 border-teal/70 text-teal":"bg-surface border-gray-300 text-gray-700"}`,children:u},u))})]}),t.jsxs("div",{className:"mb-5",children:[t.jsxs("button",{onClick:()=>ge(!be),className:"flex items-center justify-between w-full mb-3",children:[t.jsx("label",{className:"text-base font-semibold text-gray-900",children:"Experience"}),be?t.jsx(tt,{className:"w-5 h-5 text-gray-400"}):t.jsx(Ke,{className:"w-5 h-5 text-gray-400"})]}),be&&t.jsx("div",{className:"grid grid-cols-2 gap-3",children:Aa.map(u=>t.jsx("button",{onClick:()=>qe(u),className:`p-2 rounded-lg border transition-colors text-sm font-medium ${x.includes(u)?"bg-teal/10 border-2 border-teal/70 text-teal":"bg-surface border-gray-300 text-gray-700"}`,children:u},u))})]}),t.jsxs("div",{className:"mb-5",children:[t.jsxs("button",{onClick:()=>Oe(!Le),className:"flex items-center justify-between w-full mb-3",children:[t.jsx("label",{className:"text-base font-semibold text-gray-900",children:"Dietary"}),Le?t.jsx(tt,{className:"w-5 h-5 text-gray-400"}):t.jsx(Ke,{className:"w-5 h-5 text-gray-400"})]}),Le&&t.jsx("div",{className:"grid grid-cols-2 gap-3",children:Ma.map(u=>t.jsx("button",{onClick:()=>he(u),className:`p-2 rounded-lg border transition-colors text-sm font-medium ${E.includes(u)?"bg-teal/10 border-2 border-teal/70 text-teal":"bg-surface border-gray-300 text-gray-700"}`,children:u},u))})]}),t.jsxs("div",{className:"mb-5",children:[t.jsx("label",{className:"block text-base font-semibold text-gray-900 mb-3",children:"Cuisine"}),t.jsxs("select",{value:R||"",onChange:u=>H(u.target.value||void 0),className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-teal",children:[t.jsx("option",{value:"",children:"Any cuisine"}),$a.map(u=>t.jsx("option",{value:u,children:u},u))]})]}),t.jsxs("div",{className:"mb-5",children:[t.jsx("label",{className:"block text-base font-semibold text-gray-900 mb-3",children:"Additional Filters"}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-sm text-gray-700",children:"Open Now"}),t.jsx("button",{onClick:()=>D(!M),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${M?"bg-teal":"bg-gray-300"}`,children:t.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-surface transition-transform ${M?"translate-x-6":"translate-x-1"}`})})]})]})]}),t.jsx("div",{className:"border-t border-gray-200 px-5 pt-4 pb-6",children:C?t.jsx("button",{onClick:pe,disabled:Ue,className:"w-full gradient-bg hover:scale-[1.01] hover:shadow-lg text-white py-3 rounded-xl font-semibold text-base disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2 transition-all duration-200",children:Ue?t.jsxs(t.Fragment,{children:[t.jsx(ke,{className:"w-5 h-5 animate-spin"}),t.jsx("span",{children:"Loading..."})]}):"Apply Filters"}):t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"p-3 bg-amber-50 border border-amber-200 rounded-lg flex items-start gap-2",children:[t.jsx("span",{className:"text-amber-600 text-sm",children:"ð"}),t.jsx("p",{className:"text-sm text-amber-700 flex-1",children:"Sign in required to use Near Me recommendations"})]}),c?t.jsxs("button",{onClick:()=>{s(),c()},className:"w-full gradient-bg hover:opacity-90 text-white py-3 rounded-xl font-semibold text-base flex items-center justify-center gap-2 transition-all duration-200",children:[t.jsx(Mt,{className:"w-5 h-5"}),t.jsx("span",{children:"Sign In to Continue"})]}):t.jsxs("button",{disabled:!0,className:"w-full bg-gray-300 text-gray-500 py-3 rounded-xl font-semibold text-base cursor-not-allowed flex items-center justify-center gap-2",children:[t.jsx(Mt,{className:"w-5 h-5"}),t.jsx("span",{children:"Sign In Required"})]})]})})]})}):null}function Ea({params:n,isStreaming:s=!1,streamStatus:l=null,onEdit:c}){var C;if(!n)return null;const y=[n.distance];return n.price&&y.push(n.price),n.cuisine&&y.push(n.cuisine),n.vibes&&n.vibes.length>0&&y.push(...n.vibes),n.experience&&n.experience.length>0&&y.push(...n.experience),n.dietary&&n.dietary.length>0&&y.push(...n.dietary),(C=n.filters)!=null&&C.openNow&&y.push("Open Now"),t.jsxs("div",{className:"mx-2 md:mx-0 my-2 mb-4 p-3 bg-teal/10 rounded-md border border-teal/70/20",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-semibold text-teal",children:s?"Finding your restaurants...":"Your Real-Time Top 3 Criteria:"}),s&&t.jsx(ke,{className:"w-4 h-4 text-teal animate-spin"})]}),c&&!s&&t.jsxs("button",{onClick:c,className:"flex items-center gap-1.5 px-2 py-1.5 shadow-sm text-xs text-teal border border-teal/80 hover:text-teal hover:bg-teal/10 font-semibold rounded-lg transition-all duration-200",children:[t.jsx(wa,{className:"w-3 h-3",strokeWidth:2.5}),t.jsx("span",{children:"Edit"})]})]}),s&&l&&t.jsx("div",{className:"mb-2 px-2 py-1 bg-blue-900/20 rounded-lg border border-blue-700",children:t.jsx("p",{className:"text-xs text-blue-700 font-medium",children:l})}),y.length>0&&t.jsx("div",{className:"flex items-center gap-2 overflow-x-auto scrollbar-hide mt-1",children:y.map((S,Y)=>t.jsx("span",{className:"px-2 py-1 bg-surface text-teal border border-teal/60/50 shadow-md text-xs font-medium rounded-full whitespace-nowrap",children:S},Y))})]})}class ka{constructor(){St(this,"restaurantApi");this.restaurantApi=new ra}buildNearMePrompt(s){var y;let l=`Top 3 best restaurants within ${s.distance}`;s.cuisine&&(l+=` that serve ${s.cuisine} cuisine`);const c=[];return s.price&&c.push(`${s.price} price range`),s.vibes&&s.vibes.length>0&&c.push(`${s.vibes.join(" or ")} atmosphere`),s.experience&&s.experience.length>0&&c.push(`good for ${s.experience.join(" or ")}`),s.dietary&&s.dietary.length>0&&c.push(`${s.dietary.join(" or ")} options available`),(y=s.filters)!=null&&y.openNow&&c.push("currently open"),c.length>0&&(l+=` with ${c.join(", ")}`),l}parseDistance(s){const l=s.match(/(\d+)/);return l?parseInt(l[1],10):3}convertPriceToNumber(s){switch(s){case"$":return 1;case"$$":return 2;case"$$$":return 3;case"$$$$":return 4;default:return 2}}async getNearMeRecommendations(s,l){const c=this.buildNearMePrompt(s),y=this.parseDistance(s.distance),C=s.price?this.convertPriceToNumber(s.price):void 0,S=[],Y=new Set,v=new Set;let K=!1,k=c,P,p;const h={onStatus:b=>{var E;(E=l.onStatus)==null||E.call(l,b)},onResult:async b=>{var W,R,H,M;const E=b.message||b;if(E.session_id&&(P=E.session_id),E.content_tags&&Array.isArray(E.content_tags)?p=E.content_tags.map(D=>
6typeof D=="string"?D.trim():"").filter(D=>D.length>0):s.cuisine&&(p=[s.cuisine]),(b.conversation_text||b.follow_up_questions||b.citations)&&((W=l.onResultData)==null||W.call(l,{conversation_text:b.conversation_text,follow_up_questions:b.follow_up_questions,citations:b.citations})),b.final_results&&!K){K=!0;const D=b.final_results;if(D.length>0){for(const N of D){const ie=N.miso_id||"";if(!ie)continue;const ue=Array.isArray(N.videos)?N.videos.map(ye=>typeof ye=="string"?{url:ye,verified:!1}:ye):[],Ie={id:N.id||"",miso_id:ie,name:N.name||"Unknown Restaurant",address:N.address||"",reason:"",summary:N.summary||"",rating:N.rating||4.5,price:N.price||2,cuisine:N.cuisine?Array.isArray(N.cuisine)?N.cuisine:[N.cuisine]:[],photos:N.photos||[],videos:ue,loading_details:!0,business_status:N.business_status||"OPERATIONAL",recommended_sources:N.recommended_sources||[],website:N.website||"",phone:N.phone||"",latitude:N.latitude,longitude:N.longitude,hours:N.hours,orders:N.orders,reservations:N.reservations,dietary_tags:N.dietary_tags||N.dietary,image:N.image||N.imageUrl,accepts_phone_reservations:N.accepts_phone_reservations,reward_program_ids:N.reward_program_ids};S.push(Ie)}(R=l.onProgressiveUpdate)==null||R.call(l,S),await this.fetchRestaurantDetails(S,l,Y,v,k,P,p)}else(H=l.onProgressiveUpdate)==null||H.call(l,[])}else!K&&(!b.final_results||Array.isArray(b.final_results)&&b.final_results.length===0)&&(K=!0,(M=l.onProgressiveUpdate)==null||M.call(l,[]))},onUpdate:async()=>{Y.size>0&&Y.size<=3&&await this.retryFailedRestaurantDetails(S,Y,l,v,k,P,p)},onEnd:()=>{l.onComplete(S)},onError:b=>{l.onError(b)}},d=await this.getUserId(),j=s.customLocationName||s.locationName||"Current Location",x={query:c,conversation_id:0,user_distance:y,user_price:C,user_vibes:s.vibes,user_experience:s.experience,user_cuisine:s.cuisine?[s.cuisine]:void 0,user_dietary:s.dietary,location:j,location_lat:s.latitude,location_lon:s.longitude,gps_lat:s.latitude,gps_lon:s.longitude,...s.location_changed!==void 0&&{location_changed:s.location_changed},user_id:d};return await ia.createAIQueryStream(x,h),S}async fetchRestaurantDetails(s,l,c,y,C,S,Y){var K,k,P,p;for(let h=0;h<s.length;h++){const d=s[h],j=d.miso_id;if(!j||y.has(j)){s[h].loading_details=!1;continue}y.add(j);try{const x=await this.restaurantApi.getRestaurantDetails(j,void 0,C,S,Y);x?(s[h]={...s[h],id:x.id||s[h].miso_id||s[h].id,phone:x.phone||s[h].phone,website:x.website||s[h].website,rating:x.rating||s[h].rating,price:x.price||s[h].price,hours:x.hours||s[h].hours,cuisine:x.cuisine&&x.cuisine.length>0?x.cuisine:s[h].cuisine||[],videos:Array.isArray(x.videos)&&x.videos.length>0?x.videos.map(b=>typeof b=="string"?{url:b,verified:!1}:b):s[h].videos||[],photos:x.photos&&x.photos.length>0?x.photos:s[h].photos||[],orders:x.orders||s[h].orders,reservations:x.reservations||s[h].reservations,latitude:x.latitude||s[h].latitude,longitude:x.longitude||s[h].longitude,loading_details:!1,business_status:x.business_status||s[h].business_status,recommended_sources:x.recommended_sources&&x.recommended_sources.length>0?x.recommended_sources:s[h].recommended_sources||[],reason:"",summary:s[h].summary||x.description||"",image:x.image||s[h].image,dietary_tags:s[h].dietary_tags||x.dietary_tags,accepts_phone_reservations:x.accepts_phone_reservations??s[h].accepts_phone_reservations,reward_program_ids:x.reward_program_ids??s[h].reward_program_ids},this.isRestaurantDataIncomplete(x)&&c.add(j),(K=l.onProgressiveUpdate)==null||K.call(l,[...s])):(s[h].loading_details=!1,j&&c.add(j),(k=l.onProgressiveUpdate)==null||k.call(l,[...s]))}catch(x){console.error(`â Failed to fetch details for ${d.name}:`,x),s[h].loading_details=!1,j&&c.add(j),(P=l.onProgressiveUpdate)==null||P.call(l,[...s])}}s.every(h=>!h.loading_details)&&s.length>0&&((p=l.onProgressiveUpdate)==null||p.call(l,s))}async retryFailedRestaurantDetails(s,l,c,y,C,S,Y){var k;const v=Array.from(l);if(v.length===0)return;const K=v.slice(0,3);for(const P of K){if(y.has(P))continue;const p=s.findIndex(d=>d.miso_id===P);if(p===-1){l.delete(P);continue}const h=s[p];y.add(P);try{const d=await this.restaurantApi.getRestaurantDetails(P,void 0,C,S,Y);d?(s[p]={...s[p],id:d.id||s[p].miso_id||s[p].id,phone:d.phone||s[p].phone,website:d.website||s[p].website,rating:d.rating||s[p].rating,price:d.price||s[p].price,hours:d.hours||s[p].hours,cuisine:d.cuisine&&d.cuisine.length>0?d.cuisine:s[p].cuisine||[],videos:Array.isArray(d.videos)&&d.videos.length>0?d.videos.map(j=>typeof j=="string"?{url:j,verified:!1}:j):s[p].videos||[],photos:d.photos&&d.photos.length>0?d.photos:s[p].photos||[],orders:d.orders||s[p].orders,reservations:d.reservations||s[p].reservations,latitude:d.latitude||s[p].latitude,longitude:d.longitude||s[p].longitude,loading_details:!1,business_status:d.business_status||s[p].business_status,recommended_sources:d.recommended_sources&&d.recommended_sources.length>0?d.recommended_sources:s[p].recommended_sources||[],reason:"",summary:s[p].summary||d.description||"",image:d.image||s[p].image,dietary_tags:s[p].dietary_tags||d.dietary_tags,accepts_ph
6one_reservations:d.accepts_phone_reservations??s[p].accepts_phone_reservations,reward_program_ids:d.reward_program_ids??s[p].reward_program_ids},this.isRestaurantDataIncomplete(d)||l.delete(P),(k=c.onProgressiveUpdate)==null||k.call(c,[...s])):l.add(P)}catch(d){console.error(`â Retry failed for ${h.name}:`,d),y.delete(P)}}}isRestaurantDataIncomplete(s){return!s.image||s.image.length===0||!s.photos||s.photos.length===0||!s.description||s.description.length===0}async getUserId(){try{return}catch{return}}}const Pa=new ka,Tt=({curation:n,kind:s,isSelected:l=!1,size:c="md"})=>{const[y,C]=o.useState(!1),[S,Y]=o.useState(!1),v=n.recommended_by?n.recommended_by.charAt(0).toUpperCase():s==="Miso AI"?"A":"E",K={sm:"w-5 h-5",md:"w-9 h-9",lg:"w-12 h-12"},k={sm:"w-3 h-3",md:"w-5 h-5",lg:"w-6 h-6"},p=s==="expert"?n.profile_picture_url?n.profile_picture_url:n.image_url?n.image_url:null:s==="community"?n.image_url?n.image_url:null:(s==="Miso AI"||s==="guide")&&n.image_url?n.image_url:null,h=p&&!y&&(s!=="community"||!S),d=s==="community"&&!p&&!S,j=!h&&!d,x=()=>h||d?"bg-transparent":s==="Miso AI"||s==="guide"?l?"bg-gradient-to-br from-emerald-700 to-emerald-600":"bg-gradient-to-br from-gray-700 to-gray-500":s==="expert"?l?"bg-gradient-to-br from-purple-600 to-purple-500":"bg-gradient-to-br from-gray-600 to-gray-500":s==="community"?l?"bg-gradient-to-br from-red-500 to-orange-500":"bg-gradient-to-br from-gray-600 to-gray-500":"bg-gray-100",b=()=>{if(s==="Miso AI"||s==="guide"){const E=c==="sm"?"w-10 h-10 translate-y-0.5 object-contain":"w-14 h-14 translate-y-1 object-contain";return t.jsx("img",{src:"/images/miso_ai_chef_robot.png",alt:"Miso AI",className:E})}else{if(s==="expert")return t.jsx($t,{className:`${k[c]} text-white`,strokeWidth:2.5});if(s==="community")return t.jsx(Sa,{className:`${k[c]} text-white`,strokeWidth:2.5})}return t.jsx("span",{className:"text-xs font-semibold text-white",children:v})};return t.jsx("div",{className:`relative ${K[c]} rounded-full flex items-center justify-center flex-shrink-0 overflow-hidden ${x()} ${l&&(h||d)&&(s==="community"||s==="expert")?"ring-1 ring-gray-400 shadow-md shadow-gray-300/30":l&&!h&&!d?"shadow-md shadow-emerald-600/30":""}`,children:h?t.jsx("img",{src:p||"",alt:n.recommended_by||s,className:"w-full h-full object-cover",onError:()=>{C(!0),s==="community"&&Y(!0)}}):d?t.jsx("img",{src:"/images/community_image.jpg",alt:"Community",className:"w-full h-full object-cover",onError:()=>Y(!0)}):j?b():t.jsx("span",{className:"text-xs font-semibold text-white",children:v})})},Ye=({curation:n,isSelected:s,onSelect:l,onShare:c,kind:y})=>t.jsxs("button",{onClick:l,className:`w-full flex items-center gap-4 p-3 transition-all duration-150 hover:bg-gray-200/50 active:bg-gray-100 group ${s?"bg-emerald-900/10":""}`,children:[t.jsx(Tt,{curation:n,kind:y,isSelected:s,size:"md"}),t.jsx("div",{className:"flex items-center gap-4 flex-1 min-w-0",children:t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[n.recommended_by&&t.jsx("p",{className:`text-base font-semibold text-left ${s?"text-emerald-700":"text-gray-900"}`,children:n.recommended_by}),y==="Miso AI"&&!n.recommended_by&&t.jsx("p",{className:`text-base font-semibold text-left ${s?"text-emerald-700":"text-gray-900"}`,children:"Miso AI"}),(()=>{let C="";return y==="Miso AI"||y==="guide"?C=n.curator_title&&n.curator_title.trim()||n.title&&n.title.trim()||"":y==="expert"?C=n.curator_title&&n.curator_title.trim()||n.description&&n.description.trim()||"":C=n.description&&n.description.trim()||"",C?t.jsx("p",{className:`text-xs text-left mt-0.5 line-clamp-2 ${s?"text-gray-500":"text-gray-400"}`,children:C}):null})()]}),s&&t.jsx("div",{className:"flex items-center justify-center bg-emerald-700 rounded-full p-1.5 ms-2 shadow-sm",children:t.jsx(ya,{className:"w-4 h-4 text-white flex-shrink-0",strokeWidth:3})})]})}),t.jsx("button",{onClick:C=>{C.stopPropagation(),c()},className:"p-2 hover:bg-emerald-50 rounded-full transition-all duration-150 flex-shrink-0 opacity-60 group-hover:opacity-100","aria-label":"Share curation",children:t.jsx(ba,{className:"w-4 h-4 text-emerald-700",strokeWidth:2})})]});function Xa({onLocationChange:n,onLoginClick:s}){const l=va(),{currentLocationName:c,currentLocationId:y,setCurrentLocationName:C,isInitialized:S}=na(),{handleReservationSubmit:Y}
6=la(),[v,K]=o.useState([]),[k,P]=o.useState(!0),[p,h]=o.useState(null),[d,j]=o.useState(null),[x,b]=o.useState(null),[E,W]=o.useState("Miso AI"),[R,H]=o.useState(y||null),[M,D]=o.useState(""),[N,ie]=o.useState(!1),[ue,Ie]=o.useState(""),[ye,me]=o.useState(""),[Pe,oe]=o.useState(!1),Z=o.useRef(""),O=o.useRef(!1),[be,ge]=o.useState(!1),[Le,Oe]=o.useState([]),[Ue,Re]=o.useState(!1),[Ae,_e]=o.useState(null),[Q,fe]=o.useState([]),[We,xe]=o.useState([]),[Ve,qe]=o.useState([]),[he,De]=o.useState(!1),[Fe,pe]=o.useState(""),[u,L]=o.useState([]),[F,X]=o.useState([]),[Ne,B]=o.useState(!1),[J,re]=o.useState(!1),[ne,ut]=o.useState(null),ee=o.useRef(null),mt=o.useRef(null),{addToast:gt}=ca(),[Be,ot]=o.useState("cityGuides"),[V,Et]=o.useState(null),[Qe,Xe]=o.useState([]),[Oa,Ua]=o.useState([]),[Ze,Me]=o.useState(!1),[kt,we]=o.useState(null),[Pt,et]=o.useState(!1),[ft,$e]=o.useState(!1),[Ot,Ut]=o.useState("main"),[xt,ht]=o.useState(null),[Ra,Da]=o.useState([]),[Rt,pt]=o.useState([]),Te=o.useRef(!1),yt=o.useRef(!1),[Dt,bt]=o.useState(!0),Ge=o.useRef(0),Ft=10,rt="curation_recent_locations",te="curation_navigation_path",ve="curation_selected",Ee=o.useCallback(e=>{if(!e||e.length===0)return!1;if(e.length===1&&e[0].location_type==="GLOBAL")return!0;if(e.length<2||e[0].location_type!=="GLOBAL")return!1;const a=["GLOBAL","COUNTRY","STATE","COUNTY","CITY","NEIGHBORHOOD"];return e.every(r=>a.includes(r.location_type))},[]),je=o.useCallback(e=>{const a=e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return a.endsWith("-top-eats")?a:`${a}-top-eats`},[]),it=o.useCallback(e=>{const a=e.split("-");if(a.length>=2){const i=`${a[0]}-${a[1]}`,r=e.lastIndexOf("-by-");return r!==-1?e.substring(r+4):i}return null},[]),nt=o.useCallback((e,a)=>{if(!a)return!1;const i=e.split("-").map(r=>r.charAt(0).toUpperCase()+r.slice(1).toLowerCase()).join(" ");return a.toLowerCase()===i.toLowerCase()},[]),le=o.useCallback(async e=>{try{const a=await Ce.getLocationHierarchyBySlug(e);if(a&&a.hierarchy&&a.hierarchy.length>0)return localStorage.setItem(te,JSON.stringify(a.hierarchy)),xe(a.hierarchy),a.hierarchy}catch{}return null},[]);o.useEffect(()=>{if(!S)return;const e=window.location.pathname.split("/").filter(Boolean);if(e.length===3&&(e[0]==="curation-cards"||e[0]==="guide")){const a=e[1],i=e[2],r=parseInt(a);if(!isNaN(r)&&i){const m=i.split("-").map($=>$.charAt(0).toUpperCase()+$.slice(1)).join(" ");H(r);const w=m.toLowerCase();C(w,r),H(r),D(m),n&&n(m,r);const g=je(i),f=localStorage.getItem(te);if(!f)le(g);else try{const $=JSON.parse(f);Ee($)||le(g)}catch{le(g)}Te.current=!0}}else if(e.length>=2&&e[0]==="guide"){const a=e[1],i=e[2],r=e[3];if(a){Te.current=!0,yt.current=!0;const m=a.split("-").map(w=>w.charAt(0).toUpperCase()+w.slice(1)).join(" ");Ce.getLocationHierarchyBySlug(a).then(w=>{const g=w.location_id,f=w.location_name||m,$=f.split(",")[0].trim().toLowerCase();C($,g),H(g),D(f);const q=f.includes(",")?f.split(",")[0].trim():f;n&&n(q,g),w.hierarchy&&w.hierarchy.length>0&&(localStorage.setItem(te,JSON.stringify(w.hierarchy)),xe(w.hierarchy));const _=a.replace(/-top-eats$/,"");i==="community-favorites"?localStorage.setItem("url_curation_selection",JSON.stringify({type:"community",locationSlug:_})):i==="expert"&&r?localStorage.setItem("url_curation_selection",JSON.stringify({type:"expert",expertSlug:r,locationSlug:_})):localStorage.setItem("url_curation_selection",JSON.stringify({type:"default",locationSlug:_}))}).catch(()=>{const w=m.toLowerCase();C(w,void 0),H(null),D(m);const g=m.includes(",")?m.split(",")[0].trim():m;n&&n(g,void 0)})}}},[S,l,C,n,le,Ee,je]),o.useEffect(()=>{if(!S)return;const e=window.location.pathname.split("/").filter(Boolean);if((e[0]==="guide"||e[0]==="top-eats")&&e.length>=2&&e[1]){Te.current=!0;return}if(c&&c!=="Global"&&c.toLowerCase()!==U.location_name.toLowerCase()){Te.current=!0;return}if(Te.current)return;const r=async()=>{if(Te.current=!0,!navigator.geolocation){const m=U.location_name.split(",")[0].trim().toLowerCase();C(m,U.location_id),H(U.location_id),D(U.location_name),n&&n(U.location_name,U.location_id);return}try{const m=await new Promise(($,q)=>{navigator.geolocation.getCurrentPosition($,q,{enableHighAccuracy:!0,timeout:1e4,maximumAge:3e5})}),{latitude:w,longitude:g}=m.coords,f=await Ct.findDefaultLocation(w,g);
6if(f&&f.location_id&&f.location_name){const $=f.location_name.split(",")[0].trim().toLowerCase();C($,f.location_id),H(f.location_id),D(f.location_name);try{const _={NEIGHBORHOOD:"NEIGHBORHOOD",CITY:"CITY",COUNTY:"COUNTY",STATE:"STATE",COUNTRY:"COUNTRY",GLOBAL:"GLOBAL"}[f.location_type]||"CITY",z=[{location_id:f.location_id,location_name:f.location_name,location_type:_,country_code:void 0,created_at:new Date().toISOString(),updated_at:new Date().toISOString()}];localStorage.setItem(te,JSON.stringify(z)),xe(z)}catch(q){console.warn("Failed to save navigation path:",q)}n&&n(f.location_name,f.location_id)}else{const $=U.location_name.split(",")[0].trim().toLowerCase();C($,U.location_id),H(U.location_id),D(U.location_name),n&&n(U.location_name)}}catch{const w=U.location_name.split(",")[0].trim().toLowerCase();C(w,U.location_id),H(U.location_id),D(U.location_name),n&&n(U.location_name,U.location_id)}};(!c||c.toLowerCase()===U.location_name.toLowerCase()||c==="Global")&&r()},[S,c,C,n]);const _t=e=>{try{const a=localStorage.getItem(rt);let i=a?JSON.parse(a):[];i=i.filter(r=>r.location_id!==e.location_id),i.unshift(e),i=i.slice(0,3),localStorage.setItem(rt,JSON.stringify(i)),qe(i)}catch(a){console.error("Error saving recent location:",a)}},Bt=()=>{try{const e=localStorage.getItem(rt);if(e){const a=JSON.parse(e);qe(a)}}catch(e){console.error("Error loading recent locations:",e)}},Gt=e=>{const a=e.location_name.split(",")[0].trim().toLowerCase(),i=a.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),r=i.endsWith("-top-eats")?i:`${i}-top-eats`;Z.current="",j(null),b(null),W("Miso AI"),O.current=!1,localStorage.removeItem(ve),localStorage.removeItem("url_curation_selection"),C(a,e.location_id),H(e.location_id),D(e.location_name),n&&n(e.location_name,e.location_id),_t(e),l(`/guide/${r}`,{replace:!0}),ge(!1)},ce=async e=>{Re(!0),_e(null);try{try{const a=await Ce.getLocationChildren(e);Oe(a.locations);return}catch(a){if(console.log("Hierarchical endpoint not available, falling back to food hubs:",a),!e){const i=await Ce.getFoodHubLocations();Oe(i.locations);return}Oe([])}}catch(a){console.error("Error loading location children:",a),_e("Failed to load locations. Please try again.")}finally{Re(!1)}},Ht=async()=>{ge(!0),Bt();let e=We;if(e.length===0)try{const a=localStorage.getItem(te);if(a){const i=JSON.parse(a);Ee(i)?(e=i,xe(i)):e=[]}}catch{e=[]}else Ee(e)||(e=[]);if(e.length===0){const a=M||c||U.location_name;{const i=je(a),r=await le(i);r&&(e=r)}}if(e.length>0){const a=e.slice(0,-1);if(fe(a),a.length>0){const i=a[a.length-1];ce(i.location_id)}else ce()}else fe([]),ce()},Jt=e=>{const a=[...Q,e];fe(a),ce(e.location_id)},lt=e=>{const a=e.location_name.split(",")[0].trim().toLowerCase(),i=a.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),r=i.endsWith("-top-eats")?i:`${i}-top-eats`;Z.current="",j(null),b(null),W("Miso AI"),O.current=!1,localStorage.removeItem(ve),localStorage.removeItem("url_curation_selection"),C(a,e.location_id),H(e.location_id),D(e.location_name),n&&n(e.location_name,e.location_id);const m=[...Q,e];xe(m);try{localStorage.setItem(te,JSON.stringify(m))}catch(w){console.error("Error saving navigation path:",w)}_t(e),l(`/guide/${r}`,{replace:!0}),ge(!1)},Nt=e=>{if(e===-1)fe([]),ce();else{const a=Q.slice(0,e+1);fe(a);const i=a[a.length-1].location_id;ce(i)}},zt=()=>{if(Q.length>0){const e=Q.slice(0,-1);if(fe(e),e.length>0){const a=e[e.length-1].location_id;ce(a)}else ce()}},Yt=e=>({location_id:e.location_id,location_name:e.display_name||e.location_name,location_type:e.location_type.toUpperCase(),country_code:e.country?e.country.substring(0,2).toUpperCase():void 0,created_at:new Date().toISOString(),updated_at:new Date().toISOString()}),Kt=o.useCallback(async e=>{if(pe(e),ee.current&&clearTimeout(ee.current),e.trim().length<2){L([]),X([]);return}ee.current=setTimeout(async()=>{B(!0);try{const a=await da.searchLocationsUnified(e.trim(),{limit:10,fast_mode:!0}),i=a.filter(m=>m.source==="db"&&m.location_id!=null).map(ua),r=a.filter(m=>m.source==="google"&&m.place_id).map(ma);L(i),X(r)}catch(a){console.error("Error searching locations:",a),L([]),X([])}finally{B(!1)}},300)},[]),Wt=e=>{const a=Yt(e);De(!1),pe(""),L([]),X([]),lt(a)},Vt=async e=>{if(!(J||ne===e.place_id)){re(!0),ut(e.place_id);
6try{const a=await Ce.getLocationDetails(e.place_id),i=e.latitude??a.latitude??0,r=e.longitude??a.longitude??0,m=a.boundary_box,w=m?{min_lat:m.southwest_lat,max_lat:m.northeast_lat,min_lng:m.southwest_lng,max_lng:m.northeast_lng}:{min_lat:i-.1,max_lat:i+.1,min_lng:r-.1,max_lng:r+.1},g=await Ce.addLocation({location_name:e.name||e.city||"Unknown",location_type:"city",parent_location_id:null,city_lat:i,city_long:r,boundary_box:w}),f=a.city||a.name||e.name||"Unknown",q={location_id:g.location_id,location_name:f,location_type:"CITY",parent_location_id:void 0,latitude:i,longitude:r,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};pe(""),L([]),X([]),lt(q),gt({message:`${f} has been added successfully!`,type:"success",duration:5e3})}catch(a){console.error("Failed to add location:",a),gt({message:`Failed to add location: ${a instanceof Error?a.message:"Unknown error"}`,type:"error",duration:5e3})}finally{re(!1),ut(null)}}},qt=()=>{De(!he),he?ee.current&&(clearTimeout(ee.current),ee.current=null):(pe(""),L([]),X([]),setTimeout(()=>{var e;(e=mt.current)==null||e.focus()},100))};o.useEffect(()=>()=>{ee.current&&clearTimeout(ee.current)},[]),o.useEffect(()=>{be||(De(!1),pe(""),L([]),X([]),ee.current&&(clearTimeout(ee.current),ee.current=null))},[be]),o.useEffect(()=>{const e=()=>Ht();return window.__curationLocationHandler=e,()=>{delete window.__curationLocationHandler}},[]),o.useEffect(()=>{const e=()=>{if(!R)try{const a=localStorage.getItem(te);if(a){const i=JSON.parse(a);if(i.length>0){const r=i[i.length-1];r.location_name.split(",")[0].trim().toLowerCase()===c.toLowerCase()&&(H(r.location_id),D(r.location_name))}}}catch(a){console.error("Error getting location ID for share:",a)}ie(!0)};return window.__curationShareHandler=e,()=>{delete window.__curationShareHandler}},[R,c,te]),o.useEffect(()=>{if(S&&!R)try{const e=localStorage.getItem(te);if(e){const a=JSON.parse(e);if(a.length>0){const i=a[a.length-1];c&&c!=="Global"&&c.toLowerCase()!==U.location_name.toLowerCase()&&i.location_name.split(",")[0].trim().toLowerCase()===c.toLowerCase()&&(H(i.location_id),D(i.location_name))}}}catch(e){console.error("Error restoring location ID from navigation path:",e)}},[S,c,R]),o.useEffect(()=>{S&&y&&!R&&H(y)},[S,y,R]),o.useEffect(()=>{if(!n||!S)return;const e=R||y;if(M){const a=M.includes(",")?M.split(",")[0].trim():M;if(a&&a!=="Global"&&a.toLowerCase()!==U.location_name.toLowerCase()){n(a,e||void 0);return}}if(c&&c!=="Global"&&c.toLowerCase()!==U.location_name.toLowerCase()){const a=c.charAt(0).toUpperCase()+c.slice(1);n(a,e||void 0)}},[M,c,R,y,S,n]);const wt=o.useCallback(e=>{const a=window.location.origin;return e.slug_path?`${a}${e.slug_path}`:""},[]),He=o.useCallback(e=>{const a=wt(e),m=`Check out ${e.recommended_by||e.title||"Curation"}'s Top Eats in ${M||c||"Location"}!`;Ie(a),me(m),ie(!0)},[wt,M,c]),ae=o.useCallback((e,a,i,r=!0)=>{const m=v.find(g=>g.curation_id===e||g.slug===a);j(e),b(a),W(i==="guide"?"Miso AI":i),O.current=!0;const w=R||y;if(w)try{localStorage.setItem(ve,JSON.stringify({locationId:w,curationId:e,slug:a,kind:i}))}catch(g){console.error("Error saving selected curation:",g)}if(r&&(m!=null&&m.slug_path)){const g=window.location.pathname,f=new URLSearchParams(window.location.search);let $="",q="";const _=g.split("/"),I=_[_.length-1];I.startsWith("best-")&&($=`/${I}`);const z=f.get("category");z&&(q=`?category=${z}`),i==="Miso AI"||i==="guide"?l(`${m.slug_path}${$}`,{replace:!0}):l(`${m.slug_path}${q}`,{replace:!0})}},[R,y,v,l]),ct=o.useCallback(async()=>{var w;if(!S)return;const e=window.location.pathname.split("/").filter(Boolean),i=(e[0]==="guide"||e[0]==="top-eats")&&e.length>=2?e[1]:null;let r="";if(i)r=i;else if(c&&M){const g=M||c||"";r=g?je(g):""}else{(!c||c==="Global")&&(K([]),P(!1),j(null),b(null),localStorage.removeItem(ve));return}const m=`slug:${r}`;if(Z.current!==m){Z.current&&Z.current!==m&&(j(null),b(null),O.current=!1);try{P(!0),h(null),Z.current=m;const g=await Ct.getCurationsWithLocationSlug(r);K(g.data||[]),Ce.getLocationHierarchyBySlug(r).then(_=>{if(_&&_.location_name){const I=window.location.pathname.split("/").filter(
6Boolean);if(((I[0]==="guide"||I[0]==="top-eats")&&I.length>=2?I[1]:null)===r){const A=_.location_name.includes(",")?_.location_name.split(",")[0].trim():_.location_name;n&&n(A,_.location_id);const G=A.toLowerCase();C(G,_.location_id),H(_.location_id),D(_.location_name),_.hierarchy&&_.hierarchy.length>0&&(localStorage.setItem(te,JSON.stringify(_.hierarchy)),xe(_.hierarchy))}}}).catch(()=>{});let f=!1;const $=window.location.pathname.split("/").filter(Boolean),q=window.location.pathname;if($.length>=2&&($[0]==="guide"||$[0]==="top-eats")){const _=$[2],I=$[3];if(g.data&&g.data.length>0){let z=g.data.find(A=>{if(!A.slug_path)return!1;if(_&&_.startsWith("best-")){const G=`/guide/${$[1]}`;return A.slug_path===G}return A.slug_path===q});if(z){j(z.curation_id),b(z.slug);const A=z.curation_kind||"Miso AI";W(A==="guide"?"Miso AI":A),O.current=!0,f=!0}else if(_==="community-favorites"){const A=g.data.find(G=>G.curation_kind==="community");A&&(j(A.curation_id),b(A.slug),W("community"),O.current=!0,f=!0)}else if(_==="expert"&&I){const A=g.data.find(G=>{if(G.curation_kind!=="expert")return!1;const se=it(G.slug);return se&&se===I?!0:nt(I,G.recommended_by)});A&&(j(A.curation_id),b(A.slug),W("expert"),O.current=!0,f=!0)}}}if(!f)try{const _=localStorage.getItem("url_curation_selection");if(_){const I=JSON.parse(_),z=M||c||"",A=z?z.split(",")[0].trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""):"";if(I.locationSlug===A&&g.data){if(I.type==="community"){const G=g.data.find(se=>se.curation_kind==="community");G&&(j(G.curation_id),b(G.slug),W("community"),O.current=!0,f=!0)}else if(I.type==="expert"&&I.expertSlug){const G=g.data.find(se=>{if(se.curation_kind!=="expert")return!1;const Je=it(se.slug);return Je&&Je===I.expertSlug?!0:nt(I.expertSlug,se.recommended_by)});G&&(j(G.curation_id),b(G.slug),W("expert"),O.current=!0,f=!0)}localStorage.removeItem("url_curation_selection")}}}catch{localStorage.removeItem("url_curation_selection")}if(!f)try{const _=localStorage.getItem(ve);if(_){const I=JSON.parse(_);if(I.curationId&&I.slug)if((w=g.data)==null?void 0:w.find(A=>A.curation_id===I.curationId||A.slug===I.slug)){j(I.curationId),b(I.slug);const A=I.kind||"Miso AI";W(A==="guide"?"Miso AI":A),O.current=!0,f=!0}else localStorage.removeItem(ve)}}catch{localStorage.removeItem(ve)}if(!f){const _=window.location.pathname.split("/").filter(Boolean),z=(_[0]==="guide"||_[0]==="top-eats")&&_.length>=2?_[1]:null;if(!z||z!==r)if(g.data&&g.data.length>0){const A=g.data.find(Se=>Se.curation_kind==="expert"),G=g.data.find(Se=>Se.curation_kind==="community"),se=g.data.find(Se=>Se.curation_kind==="guide"),Je=g.data.find(Se=>Se.curation_kind==="Miso AI");let de,ze="Miso AI";A?(de=A,ze="expert"):G?(de=G,ze="community"):Je?(de=Je,ze="Miso AI"):se&&(de=se,ze="Miso AI"),de&&de.slug_path?(j(de.curation_id),b(de.slug),W(ze),O.current=!0,l(de.slug_path,{replace:!0})):(l(`/guide/${r}`,{replace:!0}),j(null),b(null),W("Miso AI"),O.current=!1)}else l(`/guide/${r}`,{replace:!0}),j(null),b(null),W("Miso AI"),O.current=!1;else j(null),b(null),W("Miso AI"),O.current=!1}}catch{h("Failed to load curations"),Z.current=""}finally{P(!1)}}},[R,y,S,c,je,it,nt]);o.useEffect(()=>{if(!d||!x||k||v.length===0)return;const e=window.location.pathname.split("/").filter(Boolean);if(!(e[0]==="guide"||e[0]==="top-eats"))return;const i=v.find(A=>A.curation_id===d||A.slug===x);if(!(i!=null&&i.slug_path))return;const r=window.location.pathname,m=new URLSearchParams(window.location.search);let w="",g="";const f=r.split("/"),$=f[f.length-1];$.startsWith("best-")&&(w=`/${$}`);const q=m.get("category");q&&(g=`?category=${q}`);const _=i.curation_kind||E;let I=i.slug_path;_==="Miso AI"?I=`${i.slug_path}${w}`:I=`${i.slug_path}${g}`,(r==="/guide"||r!==I)&&l(I,{replace:!0})},[d,x,v,E,k,l]),o.useEffect(()=>{if(!S)return;const e=window.location.pathname.split("/").filter(Boolean);(((e[0]==="guide"||e[0]==="top-eats")&&e.length>=2?e[1]:null)||R||y)&&ct()},[S,ct,R,y]),o.useEffect(()=>{if(!S||yt.current)return;const e=window.location.pathname.split("/").filter(Boolean);if(!((e[0]==="guide"||e[0]==="top-eats")&&e.length>=2&&e[1])&&(M||c)){const r=M||c;if(r&&r!=="Global"&&r.toLowerCase()!==U.location_name.toLowerCase()){const m=je(r),w=localStorage.getItem(te);if(!w)le(m);else try{const g=JSON.parse(w);Ee(g)||le(m)}catch{le(m)}}}},[S,M,c,le,Ee,je]),o.useEffect(()=>()=>{K([]),P(!1),h(null)},[]);const dt=Array.from(new Set(v.map(e=>e.curation_kind).filter(e=>!!e))),vt=["Miso AI","expert","locals","community"].filter(e=>e==="Miso AI"?dt.includes("Miso AI")||dt.includes("guide"):dt.includes(e)),T=o.useMemo(()=>({community:v.filter(e=>e.curation_kind==="community"),expert:v.filter(e=>e.curation_kind==="expert"),locals:v.filter(e=>e.curation_kind==="locals"),miso_ai:v.filter(e=>e.curation_kind==="Miso AI"),guide:v.filter(e=>e.curation_kind==="guide")}),[v]),Qt=(()=>
6{if(d){const e=v.find(i=>i.curation_id===d),a=(e==null?void 0:e.curation_kind)||E;return a==="guide"?"Miso AI":a}return E==="guide"?"Miso AI":E})();o.useEffect(()=>{if(k)return;if(v.length===0){O.current=!1;return}if(O.current)return;const e=window.location.pathname.split("/").filter(Boolean);if(e.length>=3&&(e[0]==="guide"||e[0]==="top-eats")){const a=e[2];if(a==="community-favorites"||a==="expert"||a==="locals"){O.current=!0;return}a&&a.startsWith("best-")}T.miso_ai.length>0?(ae(T.miso_ai[0].curation_id,T.miso_ai[0].slug,"Miso AI"),O.current=!0):T.guide.length>0?(ae(T.guide[0].curation_id,T.guide[0].slug,"Miso AI"),O.current=!0):T.expert.length>0?(ae(T.expert[0].curation_id,T.expert[0].slug,"expert"),O.current=!0):T.locals.length>0?(ae(T.locals[0].curation_id,T.locals[0].slug,"locals"),O.current=!0):T.community.length>0&&(ae(T.community[0].curation_id,T.community[0].slug,"community"),O.current=!0)},[v,k,ae,T]);const Xt=E==="expert"?[]:E==="Miso AI"?v.filter(e=>e.curation_kind==="Miso AI"||e.curation_kind==="guide"):v.filter(e=>e.curation_kind===E),Zt=o.useCallback(async e=>{Xe([]),ht(null),pt([]);const a={...e,locationName:M||c||void 0};Et(a),ot("nearMe"),$e(!0),Me(!0),we("Initializing...");const i=setTimeout(()=>{console.warn("â ï¸ Near Me stream timeout - clearing loading state"),Me(!1),we(null),$e(!1)},6e4);try{await Pa.getNearMeRecommendations(a,{onStatus:r=>{we(r)},onResultData:r=>{r.conversation_text&&ht(r.conversation_text),r.citations&&pt(r.citations)},onProgressiveUpdate:r=>{const m=r.map(w=>({...w}));Xe(m),$e(!1),m.length>0&&m.every(g=>!g.loading_details)&&(Me(!1),we(null))},onComplete:r=>{clearTimeout(i);const m=r.map(g=>({...g}));Xe(m),Me(!1),we(null),$e(!1);const w=m.map(g=>({...g,loading_details:!1}));Xe(w)},onError:r=>{clearTimeout(i),console.error("Near Me error:",r),Me(!1),we(null),$e(!1)}})}catch(r){clearTimeout(i),console.error("Error fetching Near Me recommendations:",r),Me(!1),we(null),$e(!1)}},[M,c]),jt=o.useCallback(e=>{e==="nearMe"?V&&Qe.length>0?ot("nearMe"):et(!0):ot("cityGuides")},[V,Qe]);return o.useEffect(()=>{const e=a=>{jt(a)};return window.__curationModeChangeHandler=e,()=>{delete window.__curationModeChangeHandler}},[jt]),o.useEffect(()=>(window.__curationCurrentMode=Be,()=>{delete window.__curationCurrentMode}),[Be]),o.useCallback(e=>{var a,i;return!V||V.distance!==e.distance||V.price!==e.price||V.cuisine!==e.cuisine||JSON.stringify(V.vibes)!==JSON.stringify(e.vibes)||JSON.stringify(V.experience)!==JSON.stringify(e.experience)||JSON.stringify(V.dietary)!==JSON.stringify(e.dietary)||((a=V.filters)==null?void 0:a.openNow)!==((i=e.filters)==null?void 0:i.openNow)||Math.abs(V.latitude-e.latitude)>1e-4||Math.abs(V.longitude-e.longitude)>1e-4},[V]),o.useEffect(()=>{Ge.current=window.scrollY;const e=()=>{const a=window.scrollY;Math.abs(a-Ge.current)<Ft||(a<Ge.current?bt(!0):a>Ge.current&&bt(!1),Ge.current=a)};return window.addEventListener("scroll",e,{passive:!0}),()=>window.removeEventListener("scroll",e)},[]),t.jsxs("div",{className:"bg-gray-50 mt-10",children:[t.jsx(ga,{title:`Best Restaurants in ${M||c||"Top Cities"} | Food Guide`,description:`Discover the best restaurants, dishes, and local favorites in ${M||c||"top cities"}. Expert-curated food recommendations from chefs and critics.`,canonicalUrl:window.location.pathname}),t.jsxs("div",{className:"max-w-4xl mx-auto py-6",children:[Be==="nearMe"&&V&&t.jsx(Ea,{params:V,isStreaming:Ze,streamStatus:kt,onEdit:()=>et(!0)}),Be==="cityGuides"&&vt.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`fixed top-16 left-0 right-0 z-40 bg-gray-50 px-3 py-4 transition-transform duration-300 ${Dt?"translate-y-0":"-translate-y-full"}`,children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx("div",{className:"flex gap-2 overflow-x-auto scrollbar-hide",children:vt.map(e=>{const a=Qt===e,i=e.charAt(0).toLocaleLowerCase()+e.slice(1),r=a&&d?v.find(f=>e==="Miso AI"?f.curation_id===d&&(f.curation_kind==="Miso AI"||f.curation_kind==="guide"):f.curation_id===d&&f.curation_kind===e):null,m=r||{curation_id:"",slug:"",title:"",recommended_by:"",curation_kind:e,profile_picture_url:null,image_url:null},w=()=>
6{if(e==="expert"&&(r!=null&&r.recommended_by)){const f=r.recommended_by;return t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"hidden sm:inline",children:f.length>20?`${f.substring(0,15)}...`:f}),t.jsx("span",{className:"sm:hidden",children:f.length>15?`${f.substring(0,10)}...`:f})]})}return i},g=e==="expert"&&(r!=null&&r.recommended_by)?`expert-${r.recommended_by}`:e;return t.jsxs("button",{onClick:()=>oe(!0),className:`flex items-center gap-2 px-3 py-1.5 mb-2 rounded-full text-sm font-medium transition-all duration-200 whitespace-nowrap ${a?"border text-emerald-800 border-emerald-800 shadow-sm bg-surface hover:shadow-md":"bg-gray-50 text-gray-700 border border-gray-300 hover:bg-surface hover:border-gray-400 hover:shadow-md"}`,title:e==="expert"&&(r!=null&&r.recommended_by)?r.recommended_by:i,children:[t.jsx(Tt,{curation:m,kind:e,isSelected:a,size:"sm"}),t.jsx("span",{className:"text-[15px] font-medium",children:w()}),t.jsx(Ke,{className:`w-4 h-4 transition-transform ${a?"text-emerald-800":"text-gray-500"}`,strokeWidth:2.5})]},g)})})})}),t.jsx("div",{className:"h-16 mb-4"})]}),Be==="nearMe"?(Qe.length>0||xt)&&!ft&&!Ze?t.jsx("div",{children:(()=>{const e={id:1,title:"Near Me Recommendations",sender:"ai",ts:new Date().toISOString(),data:{conversation_text:xt||`Top restaurants within ${(V==null?void 0:V.distance)||""} based on your preferences`,final_results:Qe,follow_up_questions:[],conversation_summary:"Near Me Recommendations",citations:Rt}};return t.jsx(fa,{message:e,activeTab:Ot,onTabChange:a=>Ut(a),isStreaming:Ze,mapViewMode:"inline",fullscreenTitle:"Near Me Recommendations",onReservationSubmit:Y})})()}):ft||Ze?null:t.jsxs("div",{className:"text-center py-16",children:[t.jsx($t,{className:"w-16 h-16 text-gray-400 mx-auto mb-4"}),t.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:"No Restaurants Found"}),t.jsx("p",{className:"text-gray-600 mb-6",children:"Try adjusting your filters or expanding your search radius."}),t.jsx("button",{onClick:()=>et(!0),className:"bg-emerald-700 hover:bg-emerald-800 text-white px-6 py-3 rounded-lg transition-colors",children:"Adjust Filters"})]}):k?t.jsx("div",{className:"flex justify-center items-center py-16",children:t.jsx(ke,{className:"w-10 h-10 animate-spin text-emerald-700 mx-auto"})}):p?t.jsxs("div",{className:"text-center py-16 px-4",children:[t.jsx(It,{className:"w-16 h-16 text-gray-400 mx-auto mb-4"}),t.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:"No Curations Found"}),t.jsx("p",{className:"text-gray-600 mb-6",children:c?`No curations available for ${c}. Try selecting a different location above.`:"No curations available for your selected location. Try selecting a different location above."}),t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-3 max-w-md mx-auto px-3",children:[t.jsx("button",{onClick:()=>l("/"),className:"flex-1 bg-emerald-600 hover:bg-emerald-700 text-white px-6 py-2.5 rounded-xl shadow-md transition-all font-medium whitespace-nowrap",children:"Ask Miso"}),t.jsx("button",{onClick:()=>ge(!0),className:"flex-1 bg-surface border-2 border-emerald-600 text-emerald-700 hover:bg-emerald-800/5 px-6 py-2.5 rounded-xl shadow-md transition-all font-medium whitespace-nowrap",children:"Select Location"})]})]}):Xt.length>0||E==="expert"&&d?t.jsx("div",{children:d&&x?(()=>{const e=v.find(a=>a.curation_id===d||a.slug===x);return t.jsx("div",{id:"curation-detail-embedded",className:"mt-2 scroll-mt-16",children:t.jsx(Na,{curationId:d,slug:x,onBack:()=>{j(null),b(null)},sidebarLocation:null,curationLocation:null,curation:e||null},`${d}-${x}-${E}`)})})():null}):t.jsxs("div",{className:"text-center py-16 px-3",children:[t.jsx(It,{className:"w-16 h-16 text-gray-400 mx-auto mb-4"}),t.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:"No Curations Found"}),t.jsx("p",{className:"text-gray-600 mb-6",children:c?`No curations available for ${c}. Try selecting a different location above.`:"No curations available for your selected location. Try selecting a different location above."}),t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-3 max-w-md mx-auto px-3",children:[t.jsx("button",{onClick:()=>l("/"),className:"flex-1 bg-emerald-600 hover:bg-emerald-700 text-white px-6 py-2.5 rounded-xl shadow-md transition-all font-medium whitespace-nowrap",children:"Ask Miso"}),t.jsx("button",{onClick:()=>ge(!0),className:"flex-1 bg-surface border-2 border-emerald-600 text-emerald-700 hover:bg-emerald-800/5 px-6 py-2.5 rounded-xl shadow-md transition-all font-medium whitespace-nowrap",children:"Select Location"})]})]})]}),be&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 z-50",onClick:()=>ge(!1)}),t.jsxs("div",{className:"fixed left-0 right-0 bottom-0 z-50 bg-surface rounded-t-3xl shadow-2xl border-t border-gray-200 max-h-[80vh] max-w-2xl mx-auto overflow-hidden flex flex-col",children:[t.jsx("div",{className:"flex-shrink-0 py-4 border-b border-gray-200 bg-surface",children:t.jsxs("div",{className:"px-6",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("button",{onClick:zt,disabled:Q.length===0,className:`p-2 rounded-full transition-colors ${Q.length===0?"text-gray-300 cursor-not-allowed":"text-gray-700 hover:bg-gray-100"}
6`,"aria-label":"Go back",children:t.jsx(xa,{className:"w-5 h-5"})}),t.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:"Select Location"}),t.jsx("button",{onClick:qt,className:`p-2 rounded-full transition-colors ${he?"text-emerald-600 bg-emerald-50":"text-gray-700 hover:bg-gray-100"}`,"aria-label":he?"Close search":"Search locations",children:he?t.jsx(at,{className:"w-5 h-5"}):t.jsx(Lt,{className:"w-5 h-5"})})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1 text-sm",children:[t.jsx("button",{onClick:()=>Nt(-1),className:"px-2 py-1 text-emerald-600 hover:bg-emerald-50 rounded transition-colors",children:"Home"}),Q.map((e,a)=>t.jsxs(_a.Fragment,{children:[t.jsx(At,{className:"w-3 h-3 text-gray-400 flex-shrink-0"}),t.jsx("button",{onClick:()=>Nt(a),className:`px-2 py-1 rounded transition-colors truncate max-w-[120px] ${a===Q.length-1?"text-gray-900 font-medium bg-gray-100":"text-emerald-600 hover:bg-emerald-50"}`,title:e.location_name,children:e.location_name})]},e.location_id))]}),t.jsx("div",{className:`overflow-hidden transition-all duration-300 ease-in-out ${he?"max-h-96 opacity-100 mt-4":"max-h-0 opacity-0"}`,children:t.jsxs("div",{className:"my-2 mx-1",children:[t.jsxs("div",{className:"relative",children:[t.jsx(Lt,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400"}),t.jsx("input",{ref:mt,type:"text",value:Fe,onChange:e=>Kt(e.target.value),placeholder:"Search for a location...",className:"w-full pl-10 pr-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-emerald-700 focus:border-transparent"}),Fe&&t.jsx("button",{onClick:()=>{pe(""),L([]),X([])},className:"absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-gray-600",children:t.jsx(at,{className:"w-4 h-4"})})]}),(Ne||u.length>0||F.length>0||!Ne&&Fe.trim().length>=2)&&t.jsx("div",{className:"mt-2 max-h-60 overflow-y-auto border border-gray-200 rounded-lg bg-surface shadow-lg",children:Ne?t.jsxs("div",{className:"flex items-center justify-center py-4",children:[t.jsx(ke,{className:"w-4 h-4 animate-spin text-emerald-700"}),t.jsx("span",{className:"ml-2 text-sm text-gray-500",children:"Searching..."})]}):u.length>0||F.length>0?t.jsxs("div",{children:[u.map(e=>{var i;const a=[e.city,e.state,e.country].filter(Boolean).join(", ");return t.jsx("button",{onClick:()=>Wt(e),className:"w-full p-3 text-left text-sm text-gray-700 hover:bg-gray-200/50 border-b border-gray-100 last:border-b-0 transition-colors",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(st,{className:"w-4 h-4 text-teal flex-shrink-0"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"font-medium text-gray-900 truncate flex items-center gap-2",children:[t.jsx("span",{children:e.display_name||e.location_name}),e.location_type&&t.jsx("span",{className:"text-xs font-normal text-gray-500 bg-gray-100 px-2 py-0.5 rounded-full",children:e.location_type.toLowerCase()})]}),(i=e.children)!=null&&i.length?t.jsxs("div",{className:"text-xs text-gray-700 truncate my-1",children:["Covers (",e.children.join(", "),")"]}):null,a?t.jsx("div",{className:"text-xs text-gray-400 truncate",children:a}):null]})]})},e.location_id)}),F.length>0&&t.jsxs(t.Fragment,{children:[u.length>0&&t.jsx("div",{className:"px-3 py-2 bg-gray-50 border-t border-b border-gray-200",children:t.jsx("p",{className:"text-xs font-semibold text-gray-600 uppercase tracking-wide",children:"Add Your City"})}),F.map(e=>{const a=J&&ne===e.place_id;return t.jsx("div",{className:"w-full p-3 border-b border-gray-100 last:border-b-0",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-8 h-8 rounded-lg bg-emerald-700/10 flex items-center justify-center flex-shrink-0",children:t.jsx(st,{className:"w-4 h-4 text-emerald-800 fill-emerald-800/40"})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"font-medium text-gray-900 truncate",children:e.name}),e.formatted_address&&t.jsx("div",{className:"text-xs text-gray-500 truncate mt-0.5",children:e.formatted_address})]}),t.jsx("button",{onClick:()=>Vt(e),disabled:a,className:"px-3 py-1.5 bg-emerald-700 text-white text-xs font-medium rounded-full hover:bg-emerald-600 transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-1.5 flex-shrink-0",children:a?t.jsxs(t.Fragment,{children:[t.jsx(ke,{className:"w-3 h-3 animate-spin"}),t.jsx("span",{children:"Adding..."})]}):t.jsx("span",{children:"Add"})})]})},e.place_id)})]})]}):t.jsxs("div",{className:"p-4 text-center",children:[t.jsx("p",{className:"text-sm font-medium text-gray-700 mb-1",children:"No locations foun
6d"}),t.jsx("p",{className:"text-xs text-gray-500",children:"Try searching with a different name or browse locations below"})]})})]})})]})}),t.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:[Ue&&t.jsxs("div",{className:"flex items-center justify-center pt-4 pb-8",children:[t.jsx(ke,{className:"w-4 h-4 animate-spin text-emerald-700"}),t.jsx("span",{className:"ml-2 text-gray-500",children:"Loading locations..."})]}),Ae&&t.jsxs("div",{className:"text-center py-8",children:[t.jsx("p",{className:"text-red-600 mb-4",children:Ae}),t.jsx(ha,{onClick:()=>ce(Q.length>0?Q[Q.length-1].location_id:void 0),variant:"outline",size:"sm",children:"Try Again"})]}),!Ue&&!Ae&&t.jsx("div",{className:"space-y-3",children:Le.length===0?t.jsx("div",{className:"text-center py-8 text-gray-500",children:t.jsx("p",{children:"No locations available at this level."})}):Le.map(e=>t.jsx("div",{onClick:()=>Jt(e),className:"w-full px-4 py-2 rounded-lg border bg-surface border-gray-200 hover:bg-gray-200/50 transition-colors cursor-pointer",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(st,{className:"w-5 h-5 text-gray-400"}),t.jsxs("div",{className:"flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"font-medium",children:e.location_name}),t.jsx(At,{className:"w-4 h-4 text-gray-800"})]}),t.jsxs("div",{className:"text-xs text-gray-500 mt-1 flex items-center gap-2",children:[t.jsx("span",{className:"bg-gray-100 px-2 py-1 rounded-full",children:e.location_type.toLowerCase()}),e.country_code&&t.jsx("span",{children:e.country_code.toUpperCase()})]})]}),t.jsx("div",{className:"flex gap-2",children:t.jsx("button",{onClick:a=>{a.stopPropagation(),lt(e)},className:"px-4 py-2 text-sm bg-emerald-700/90 text-white shadow-md rounded-lg hover:bg-emerald-700 hover:scale-105 transition-all",children:"Select"})})]})},e.location_id))})]}),Ve.length>0&&t.jsxs("div",{className:"flex-shrink-0 px-6 py-4 border-t border-gray-200 bg-surface",children:[t.jsx("h4",{className:"text-xs font-semibold text-gray-500 mb-2 uppercase tracking-wide",children:"Recent Locations"}),t.jsx("div",{className:"flex flex-wrap gap-2",children:Ve.map(e=>t.jsx("button",{onClick:()=>Gt(e),className:"px-3 py-1.5 text-sm bg-gray-100 text-gray-700 rounded-lg hover:bg-emerald-100 hover:text-emerald-700 transition-colors",children:e.location_name},e.location_id))})]})]})]}),Pe&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 z-50",onClick:()=>oe(!1)}),t.jsxs("div",{className:"fixed left-0 right-0 bottom-0 z-50 bg-surface rounded-t-3xl shadow-2xl border-t border-gray-200 max-h-[80vh] w-full max-w-2xl mx-auto overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:"Select Curator"}),t.jsx("button",{onClick:()=>oe(!1),className:"p-1 hover:bg-gray-100 rounded-full transition-colors","aria-label":"Close",children:t.jsx(at,{className:"w-5 h-5 text-gray-500"})})]}),t.jsxs("div",{className:"max-h-[60vh] overflow-y-auto px-3 py-4",children:[(T.miso_ai.length>0||T.guide.length>0)&&t.jsxs("div",{className:"mb-6",children:[t.jsx("h4",{className:"text-xs font-semibold text-gray-600 uppercase tracking-wide mb-3",children:"MISO AI"}),t.jsxs("div",{className:"space-y-1",children:[T.miso_ai.map(e=>{const a=d===e.curation_id;return t.jsx(Ye,{curation:e,isSelected:a,kind:"Miso AI",onSelect:()=>{ae(e.curation_id,e.slug,"Miso AI"),oe(!1)},onShare:()=>{He(e)}},e.curation_id)}),T.guide.map(e=>{const a=d===e.curation_id;return t.jsx(Ye,{curation:e,isSelected:a,kind:"guide",onSelect:()=>{ae(e.curation_id,e.slug,"Miso AI"),oe(!1)},onShare:()=>{He(e)}},e.curation_id)})]})]}),T.expert.length>0&&t.jsxs("div",{className:"mb-6",children:[t.jsx("h4",{className:"text-xs font-semibold text-gray-600 uppercase tracking-wide mb-3",children:"EXPERT"}),t.jsx("div",{className:"space-y-1",children:T.expert.map(e=>{const a=d===e.curation_id;return t.jsx(Ye,{curation:e,isSelected:a,kind:"expert",onSelect:()=>{ae(e.curation_id,e.slug,"expert"),oe(!1)},onShare:()=>{He(e)}},e.curation_id)})})]}),T.locals.length>0&&t.jsxs("div",{className:"mb-6",children:[t.jsx("h4",{className:"text-xs font-semibold text-gray-600 uppercase tracking-wide mb-3",children:"LOCALS"}),t.jsx("div",{className:"space-y-1",children:T.locals.map(e=>{const a=d===e.curation_id;return t.jsx(Ye,{curation:e,isSelected:a,kind:"locals",onSelect:()=>{ae(e.curation_id,e.slug,"locals"),oe(!1)},onShare:()=>{He(e)}},e.curation_id)})})]}),T.community.length>0&&t.jsxs("div",{className:"mb-6",children:[t.jsx("h4",{className:"text-xs font-semibold text-gray-600 uppercase tracking-wide mb-3",children:"COMMUNITY"}),t.jsx("div",{className:"space-y-1",children:T.community.map(e=>{const a=d===e.curation_id;return t.jsx(Ye,{curation:e,isSelected:a,kind:"community",onSelect:()=>{ae(e.curation_id,e.slug,"community"),oe(!1)},onShare:()=>{He(e)}},e.curation_id)})})]})]})]})]}),t.jsx(pa,{isOpen:N,onClose:()=>ie(!1),shareType:"curation",locationId:R==null?void 0:R.toString(),locationName:M||c,messageTitle:ye||`Check out Top Eats in ${M||c}!`,directUrl:ue}),t.jsx(Ta,{isOpen:Pt,onClose:()=>et(!1),onNearMeSelected:Zt,onLoginClick:s})]})}export{Xa as default};
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.