1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[701],{273:(e,t,r)=>{r.d(t,{m:()=>i});var s=r(20063),a=r(12115);function i(){let e=(0,s.useRouter)(),t=(0,s.usePathname)(),r=(0,s.useSearchParams)(),i=(0,a.useCallback)((s,a)=>{let i=new URLSearchParams(r.toString());Object.entries(s).forEach(e=>{let[t,r]=e;void 0===r||""===r?i.delete(t):i.set(t,r)}),a?.preservePage||"page"in s||i.delete("page");let n=i.toString();e.replace(n?`${t}?${n}`:t,{scroll:!1})},[t,e,r]);return{searchParams:r,updateUrl:i,clearUrl:(0,a.useCallback)(()=>{e.replace(t,{scroll:!1})},[t,e]),pathname:t}}},14728:(e,t,r)=>{r.d(t,{WinePairings:()=>o});var s=r(95155),a=r(18955),i=r(15239),n=r(52619),l=r.n(n),c=r(12115);function o(e){let{menuItemId:t,locale:r}=e,n=(0,a.c)("wine.pairings"),[o,d]=(0,c.useState)([]),[m,x]=(0,c.useState)(!0),[u,h]=(0,c.useState)(null),p=(0,c.useRef)(!1);return((0,c.useEffect)(()=>{p.current||(p.current=!0,e());async function e(){try{x(!0);let e=await fetch(`/api/wine/pairings?menuItemId=${encodeURIComponent(t)}&locale=${r}`);if(!e.ok)throw Error("Failed to fetch pairings");let s=((await e.json()).pairings||[]).map(e=>{let t=Array.isArray(e.wines)?e.wines[0]:e.wines;return t?{id:e.id,wineId:e.wine_id,wineName:t.name,wineSlug:t.slug,wineType:t.type,wineImage:t.image_url??null,pairingStrength:e.pairing_strength,notes:("th"===r?e.notes_th:e.notes_en)??null,sortOrder:e.sort_order}:null}).filter(Boolean);d(s),h(null)}catch(e){h(n("error"))}finally{x(!1)}}},[t,r,n]),m)?(0,s.jsxs)("div",{className:"card p-6",children:[(0,s.jsx)("h3",{className:"text-xl font-semibold text-primary mb-4",children:n("title")}),(0,s.jsx)("div",{className:"flex items-center justify-center min-h-[100px]",children:(0,s.jsx)("div",{className:"animate-pulse text-3xl",children:"\uD83C\uDF77"})})]}):u?(0,s.jsxs)("div",{className:"card p-6",children:[(0,s.jsx)("h3",{className:"text-xl font-semibold text-primary mb-4",children:n("title")}),(0,s.jsx)("p",{className:"text-secondary text-center",children:u})]}):0===o.length?null:(0,s.jsxs)("div",{className:"card p-6",children:[(0,s.jsx)("h3",{className:"text-xl font-semibold text-primary mb-2",children:n("title")}),(0,s.jsx)("p",{className:"text-secondary mb-6",children:n("subtitle")}),(0,s.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:o.map(e=>(0,s.jsxs)(l(),{href:`/${r}/wine/${e.wineSlug}`,className:"card p-4 hover:shadow-lg transition-shadow",children:[e.wineImage&&(0,s.jsx)("div",{className:"aspect-square mb-4 overflow-hidden rounded-lg bg-surface-elevated relative",children:(0,s.jsx)(i.default,{src:e.wineImage,alt:e.wineName,fill:!0,className:"object-contain",sizes:"(max-width: 768px) 100vw, (max-width: 1024px) 50vw, 33vw"})}),(0,s.jsx)("div",{className:"mb-2",children:(0,s.jsx)("span",{className:`inline-block px-2 py-1 text-xs font-medium rounded ${(e=>{switch(e){case"RED":return"wine-badge-red border";case"WHITE":return"wine-badge-white border";case"ROSE":return"wine-badge-rose border";case"SPARKLING":return"wine-badge-sparkling border";default:return"bg-background-elevated text-primary border border-border"}})(e.wineType)}`,children:e.wineType})}),(0,s.jsx)("h4",{className:"text-lg font-semibold text-primary mb-2",children:e.wineName}),(0,s.jsx)("p",{className:`text-sm font-medium mb-2 ${(e=>{switch(e){case"excellent":return"text-green-600 dark:text-green-400";case"good":return"text-blue-600 dark:text-blue-400";default:return"text-secondary"}})(e.pairingStrength)}`,children:n(`strength.${e.pairingStrength}`)}),e.notes&&(0,s.jsx)("p",{className:"text-sm text-secondary line-clamp-3",children:e.notes}),(0,s.jsxs)("div",{className:"mt-4 text-primary hover:text-primary-dark transition-colors text-sm font-medium",children:[n("viewWine")," â"]})]},e.id))})]})}},15012:(e,t,r)=>{r.d(t,{SearchRedirectHandler:()=>n});var s=r(72772),a=r(20063),i=r(12115);function n(e){let{locale:t}=e,r=(0,a.useRouter)(),n=(0,a.useSearchParams)();return(0,i.useEffect)(()=>{let e=n.get("q");if(e&&e.trim()&&(0,s.shouldCreateSeoUrl)(e)){let a=(0,s.generateSearchSlug)(e);r.replace(`/${t}/wine/search/${a}`)}},[n,r,t]),null}},15908:(e,t,r)=>{r.d(t,{DonutChart:()=>d});var s=r(95155),a=r(26265),i=r(12723),n=r(4035),l=r(69386),c=r(10232);function o(e){let{active:t,payload:r,total:a}=e;if(t&&r&&r.length){let e=r[0],t=a>0?(e.value/a*100).toFixed(1):"0";return(0,s.jsxs)("div",{className:"bg-surface border border-border rounded-lg px-3 py-2 shadow-lg",children:[(0,s.jsx)("p",{className:"font-semibold text-primary",children:e.name}),(0,s.jsxs)("p",{className:"text-sm text-secondary",children:[e.value," (",t,"%)"]})]})}return null}function d(e){let{data:t,title:r,centerLabel:d,showLegend:m=!0,onSegmentClick:x}=e,u=t.reduce((e,t)=>
1e+t.value,0);return(0,s.jsxs)("div",{className:"card p-6",children:[(0,s.jsx)("h3",{className:"text-xl font-semibold text-primary mb-4 text-center",children:r}),(0,s.jsx)(a.u,{width:"100%",height:300,children:(0,s.jsxs)(i.r,{children:[(0,s.jsx)(n.Fq,{data:t,cx:"50%",cy:"50%",innerRadius:60,outerRadius:100,paddingAngle:2,dataKey:"value",onClick:e=>x?.(e),className:"cursor-pointer focus:outline-none",children:t.map((e,t)=>(0,s.jsx)(l.f,{fill:e.color,className:"hover:opacity-80 transition-opacity"},`cell-${t}`))}),(0,s.jsx)(c.m,{content:(0,s.jsx)(o,{total:u})})]})}),d&&(0,s.jsxs)("div",{className:"text-center mt-4 mb-4",children:[(0,s.jsx)("p",{className:"text-2xl font-bold text-primary",children:u}),(0,s.jsx)("p",{className:"text-sm text-secondary",children:d})]}),m&&(0,s.jsx)("div",{className:"mt-4 space-y-2",children:t.map((e,t)=>(0,s.jsxs)("div",{className:"flex items-center justify-between text-sm gap-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[(0,s.jsx)("div",{className:"w-4 h-4 rounded flex-shrink-0",style:{backgroundColor:e.color}}),(0,s.jsx)("span",{className:"text-primary truncate",title:e.name,children:e.name})]}),(0,s.jsxs)("span",{className:"text-secondary font-medium flex-shrink-0",children:["(",e.value,")"]})]},t))})]})}},17644:(e,t,r)=>{r.d(t,{FeaturedWineSelections:()=>x});var s=r(95155),a=r(8237),i=r(69276),n=r(96204),l=r(18955),c=r(15239),o=r(52619),d=r.n(o),m=r(12115);function x(e){let{locale:t}=e,r=(0,l.c)("wine"),{wines:o,loading:x,error:u}=(0,n.P)(),[h,p]=(0,m.useState)("ALL"),g=(0,m.useMemo)(()=>o.filter(e=>e.isFeatured),[o]),f="ALL"===h?g:g.filter(e=>e.type===h),b=e=>{switch(e){case"RED":return"\uD83C\uDF77";case"WHITE":return"\uD83E\uDD42";case"ROSE":return"\uD83C\uDF39";case"SPARKLING":return"\uD83C\uDF7E";default:return"â¨"}};if(x)return(0,s.jsxs)("section",{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{className:"text-xl font-heading font-bold text-primary mb-2",children:r("featured.title")}),(0,s.jsx)("p",{className:"text-sm text-secondary",children:r("featured.subtitle")})]}),(0,s.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,s.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-4 border-primary/20 border-t-primary"})})]});if(u||0===g.length)return null;let y=f.map(e=>{var a;return(0,s.jsxs)("div",{className:"group bg-background-elevated dark:bg-background-elevated rounded-xl p-4 border border-border hover:border-primary/50 transition-all duration-300 hover:shadow-lg flex flex-col h-full",children:[(0,s.jsxs)("div",{className:"aspect-[2/3] mb-3 bg-background rounded-lg overflow-hidden relative",children:[e.image?(0,s.jsx)(c.default,{src:e.image.url,alt:e.name,fill:!0,className:"object-contain p-2 group-hover:scale-105 transition-transform duration-500",sizes:"(max-width: 768px) 50vw, (max-width: 1024px) 33vw, 25vw"}):(0,s.jsx)("div",{className:"w-full h-full bg-muted flex items-center justify-center",children:(0,s.jsx)("span",{className:"text-4xl",children:"\uD83C\uDF77"})}),(0,s.jsx)("span",{className:`absolute bottom-2 left-2 inline-flex items-center px-2 py-0.5 rounded-full text-xs font-semibold shadow-lg backdrop-blur-md ${(e=>{switch(e){case"RED":return"bg-red-600/90 text-white border border-red-700";case"WHITE":return"badge-amber border";case"ROSE":return"bg-pink-500/90 text-white border border-pink-600";case"SPARKLING":return"bg-yellow-500/90 text-white border border-yellow-600";default:return"bg-gray-600/90 text-white border border-gray-700"}})(e.type)}`,children:(a=e.type,({RED:r("types.red"),WHITE:r("types.white"),ROSE:r("types.rose"),SPARKLING:r("types.sparkling"),DESSERT:r("types.dessert"),FORTIFIED:r("types.fortified")})[a]||a)}),e.isOrganic&&(0,s.jsxs)("span",{className:"absolute top-2 right-2 inline-flex items-center px-2 py-0.5 rounded-full text-xs font-semibold bg-accent/90 text-white border border-accent shadow-lg backdrop-blur-md",children:["\uD83C\uDF31 ",r("item.organic")]})]}),(0,s.jsxs)("div",{className:"flex flex-col flex-grow",children:[(0,s.jsx)("h4",{className:"font-medium text-primary font-semibold text-sm line-clamp-2 lg:min-h-[2.5rem] group-hover:text-primary transition-colors duration-300",children:e.name}
1),e.winery&&(0,s.jsxs)("p",{className:"text-xs text-secondary mt-1",children:[e.winery.name,e.vintage&&` ⢠${e.vintage}`]}),e.code&&(0,s.jsx)("p",{className:"text-[10px] font-mono tracking-wide text-muted/70 uppercase mt-0.5",children:e.code}),(0,s.jsx)("div",{className:"flex-grow min-h-2"}),(0,s.jsxs)("div",{className:"mt-2 mb-2",children:[(0,s.jsxs)("div",{className:"text-sm font-semibold text-primary flex items-center gap-1",children:["฿",e.dineInPrice?.toLocaleString()||"0",(0,s.jsx)(i.Q,{iconSize:"sm"})]}),e.byGlassPrice&&(0,s.jsxs)("div",{className:"text-xs text-secondary flex items-center gap-1",children:["฿",e.byGlassPrice.toLocaleString()," ",r("labels.perGlass")]})]}),(0,s.jsx)("div",{className:"flex items-center justify-end pt-3 border-t border-border/50",children:(0,s.jsxs)(d(),{href:`/${t}/wine/${e.slug}`,className:"text-xs font-medium text-primary hover:text-primary/80 hover:underline transition-colors duration-200 flex items-center gap-1","aria-label":r("accessibility.viewDetails",{name:e.name}),children:[r("featured.viewWine"),(0,s.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]})})]})]},e.id)});return(0,s.jsxs)("section",{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{className:"text-xl font-heading font-bold text-primary mb-2",children:r("featured.title")}),(0,s.jsx)("p",{className:"text-sm text-secondary",children:r("featured.subtitle")})]}),(0,s.jsxs)("div",{className:"flex flex-wrap justify-center gap-3",children:[(0,s.jsxs)("button",{onClick:()=>p("ALL"),className:`px-4 py-2 rounded-full text-sm font-medium transition-all duration-200 flex items-center gap-2 ${"ALL"===h?"bg-primary text-primary-foreground border-primary ring-2 ring-primary/30 ring-offset-2 ring-offset-background":"bg-background-paper text-text-secondary border-border hover:border-primary hover:text-primary hover:bg-surface-hover"}`,"aria-label":r("filter.all"),children:[(0,s.jsx)("span",{children:b("ALL")}),r("filter.all")]}),["RED","WHITE","ROSE","SPARKLING"].map(e=>(0,s.jsxs)("button",{onClick:()=>p(e),className:`px-4 py-2 rounded-full text-sm font-medium transition-all duration-200 flex items-center gap-2 ${h===e?"bg-primary text-primary-foreground border-primary ring-2 ring-primary/30 ring-offset-2 ring-offset-background":"bg-background-paper text-text-secondary border-border hover:border-primary hover:text-primary hover:bg-surface-hover"}`,children:[(0,s.jsx)("span",{children:b(e)}),r(`types.${e.toLowerCase()}`)]},e))]}),f.length>0?(0,s.jsx)(a.r,{itemsPerView:{mobile:2,tablet:3,desktop:4},gap:16,showControls:!0,children:y}):(0,s.jsx)("div",{className:"text-center py-8",children:(0,s.jsx)("p",{className:"text-secondary",children:r("selections.noWines")})})]})}},20235:(e,t,r)=>{r.d(t,{WineSearchWithFilters:()=>h});var s=r(95155),a=r(273),i=r(83650);let n={italy:{flag:"\uD83C\uDDEE\uD83C\uDDF9",code:"IT"},france:{flag:"\uD83C\uDDEB\uD83C\uDDF7",code:"FR"},spain:{flag:"\uD83C\uDDEA\uD83C\uDDF8",code:"ES"},germany:{flag:"\uD83C\uDDE9\uD83C\uDDEA",code:"DE"},portugal:{flag:"\uD83C\uDDF5\uD83C\uDDF9",code:"PT"},"united-states":{flag:"\uD83C\uDDFA\uD83C\uDDF8",code:"US"},usa:{flag:"\uD83C\uDDFA\uD83C\uDDF8",code:"US"},australia:{flag:"\uD83C\uDDE6\uD83C\uDDFA",code:"AU"},"new-zealand":{flag:"\uD83C\uDDF3\uD83C\uDDFF",code:"NZ"},"south-africa":{flag:"\uD83C\uDDFF\uD83C\uDDE6",code:"ZA"},chile:{flag:"\uD83C\uDDE8\uD83C\uDDF1",code:"CL"},argentina:{flag:"\uD83C\uDDE6\uD83C\uDDF7",code:"AR"},austria:{flag:"\uD83C\uDDE6\uD83C\uDDF9",code:"AT"},greece:{flag:"\uD83C\uDDEC\uD83C\uDDF7",code:"GR"},hungary:{flag:"\uD83C\uDDED\uD83C\uDDFA",code:"HU"},croatia:{flag:"\uD83C\uDDED\uD83C\uDDF7",code:"HR"},slovenia:{flag:"\uD83C\uDDF8\uD83C\uDDEE",code:"SI"},bulgaria:{flag:"\uD83C\uDDE7\uD83C\uDDEC",code:"BG"},romania:{flag:"\uD83C\uDDF7\uD83C\uDDF4",code:"RO"},japan:{flag:"\uD83C\uDDEF\uD83C\uDDF5",code:"JP"},china:{flag:"\uD83C\uDDE8\uD83C\uDDF3",code:"CN"},india:{flag:"\uD83C\uDDEE\uD83C\uDDF3",code:"IN"},thailand:{flag:"\uD83C\uDDF9\uD83C\uDDED",code:"TH"},israel:{flag:"\uD83C\uDDEE\uD83C\uDDF1",code:"IL"},lebanon:{flag:"\uD83C\uDDF1\uD83C\uDDE7",code:"LB"},turkey:{flag:"\uD83C\uDDF9\uD83C\uDDF7",code:"TR"},georgia:{flag:"\uD83C\uDDEC\uD83C\uDDEA",code:"GE"},armenia:{flag:"\uD83C\uDDE6\uD83C\uDDF2",code:"AM"},unknown:{flag:"\uD83C\uDF0D",code:"XX"}};var l=r(18955),c=r(12115);function o(e){let{title:t,items:r,selectedIds:a,onSelectionChange:i,maxHeight:n="max-h-64",placeholder:o,searchable:d=!0,maxItems:m,disabled:x=!1,className:u="",defaultOpen:h=!1,showSelectAll:p=!0}=e,g=(0,l.c)("wine.filter"),f=(0,l.c)("wine.accessibility"),[b,y]=(0,c.useState)(h),[j,v]=(0,c.useState)(""),w=r.filter(e=>!(j.trim().length>=3)||e.name.toLowerCase().includes(j.toLowerCase())),N=m?w.slice(0,m):w,k=a.length,C=k===N.length&&N.length>0,S=k>0&&k<N.length;return(0,s.jsxs)("div",{className:`w-full ${u}`,children:[(0,s.jsxs)("button",{type:"button",onClick:()=>!x&&y(!b),disabled:x,className:` 2 w-full flex items-center justify-between px-4 py-3 text-left 3 border-2 rounded-lg transition-all duration-200 4 ${x?"bg-background-muted border-border-muted text-muted cursor-not-allowed opacity-50":b?"border-primary bg-background-paper shadow-md":"border-border bg-background hover:border-primary/50 hover:shadow-sm"} 5 `,"aria-label":f("toggleFilter",{filter:t}),"aria-expanded":b,"aria-haspopup":"listbox",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[(0,s.jsx)("span",{className:"text-sm font-medium text-primary truncate",children:t}),k>0&&(0,s.jsx)("span",{className:"px-2 py-0.5 text-xs font-semibold bg-primary text-primary-foreground rounded-full flex-shrink-0",children:k})]}),(0,s.jsx)("svg",{className:`w-5 h-5 text-secondary transition-transform duration-200 flex-shrink-0 ${b?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),b&&(0,s.jsxs)("div",{className:"w-full mt-2 bg-background-paper border border-border rounded-lg shadow-lg",children:[d&&r.length>5&&(0,s.jsx)("div",{className:"p-3 border-b border-border",children:(0,s.jsx)("input",{type:"text",value:j,onChange:e=>v(e.target.value),placeholder:o||g("searchPlaceholder"),className:"w-full px-3 py-2 text-sm border border-border rounded-md focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent","aria-label":f("searchItems",{category:t})})}),p&&N.length>1&&(0,s.jsx)("div",{className:"p-3 border-b border-border",children:(0,s.jsxs)("button",{type:"button",onClick:()=>{a.length===N.length?i([]):i(N.map(e=>e.id))},className:"flex items-center gap-2 text-sm text-primary hover:text-primary/80 transition-colors","aria-label":g(C?"deselectAll":"selectAll"),children:[(0,s.jsx)("div",{className:"relative",children:(0,s.jsx)("input",{type:"checkbox",checked:C,ref:e=>{e&&(e.indeterminate=S)},onChange:()=>{},className:"w-4 h-4 rounded border-border text-primary focus:ring-primary",tabIndex:-1,"aria-hidden":"true"})}),(0,s.jsx)("span",{className:"font-medium",children:g(C?"deselectAll":"selectAll")})]})}),(0,s.jsx)("div",{className:`${n} overflow-y-auto`,role:"listbox",children:0===N.length?(0,s.jsx)("div",{className:"p-4 text-center text-muted text-sm",children:g(j?"noSearchResults":"noItemsAvailable")}):(0,s.jsx)("div",{className:"p-2 space-y-1",children:N.map(e=>(0,s.jsxs)("label",{className:"flex items-center gap-3 p-2 rounded-md cursor-pointer hover:bg-background-hover transition-colors",role:"option","aria-selected":a.includes(e.id),children:[(0,s.jsx)("input",{type:"checkbox",checked:a.includes(e.id),onChange:()=>{var t;return t=e.id,void i(a.includes(t)?a.filter(e=>e!==t):[...a,t])},className:"w-4 h-4 rounded border-border text-primary focus:ring-primary","aria-label":f("selectItem",{item:e.name})}),e.icon&&(0,s.jsx)("span",{className:"text-lg flex-shrink-0","aria-hidden":"true",children:e.icon}),(0,s.jsx)("span",{className:"text-sm text-primary flex-1 truncate",children:e.name}),(0,s.jsxs)("span",{className:"text-xs text-muted flex-shrink-0",children:["(",e.count,")"]})]},e.id))})}),m&&w.length>m&&(0,s.jsx)("div",{className:"p-3 border-t border-border text-center",children:(0,s.jsx)("span",{className:"text-xs text-muted",children:g("showingItems",{shown:m,total:w.length})})})]})]})}var d=r(96547),m=r(96216);let x=["RED","WHITE","ROSE","SPARKLING"],u=[{key:"under500",min:0,max:500},{key:"500to1000",min:500,max:1e3},{key:"1000to2000",min:1e3,max:2e3},{key:"2000to3000",min:2e3,max:3e3},{key:"3000to5000",min:3e3,max:5e3},{key:"over5000",min:5e3,max:999999}];function h(e){let t,{locale:r,initialFilters:h,hideFiltersPanel:p=!1}=e,g=(0,l.c)("wine"),{discover:f}=(0,i.g)(),{searchParams:b,updateUrl:y,clearUrl:j}=(0,a.m)(),v=(0,c.useRef)(0),[w,N]=(0,c.useState)([]),[k,C]=(0,c.useState)(!0),[S,D]=(0,c.useState)(null),[$,I]=(0,c.useState)(!1),[E,F]=(0,c.useState)(!1);(0,c.useEffect)(()=>{let e=()=>{F(window.innerWidth>=1024)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);let R=b.get("q")||"",M=(0,c.useMemo)(()=>
5{if(h&&Object.keys(h).some(e=>{let t=h[e];return Array.isArray(t)?t.length>0:void 0!==t&&!1!==t}))return{...h};let e=b.get("types");return{types:e?e.split(",").filter(e=>x.includes(e)):[],isOrganic:"true"===b.get("isOrganic"),byTheGlass:"true"===b.get("byTheGlass"),countryIds:b.get("countryIds")?.split(",").filter(Boolean)||[],regionIds:b.get("regionIds")?.split(",").filter(Boolean)||[],wineryIds:b.get("wineryIds")?.split(",").filter(Boolean)||[],grapeVarietyIds:b.get("grapeVarietyIds")?.split(",").filter(Boolean)||[],priceMin:b.get("priceMin")?parseInt(b.get("priceMin"),10):void 0,priceMax:b.get("priceMax")?parseInt(b.get("priceMax"),10):void 0}},[b,h]),L=(0,c.useCallback)(e=>{let t="function"==typeof e?e(M):e;y({types:t.types.length>0?t.types.join(","):void 0,isOrganic:t.isOrganic?"true":void 0,byTheGlass:t.byTheGlass?"true":void 0,countryIds:t.countryIds.length>0?t.countryIds.join(","):void 0,regionIds:t.regionIds.length>0?t.regionIds.join(","):void 0,wineryIds:t.wineryIds.length>0?t.wineryIds.join(","):void 0,grapeVarietyIds:t.grapeVarietyIds.length>0?t.grapeVarietyIds.join(","):void 0,priceMin:void 0!==t.priceMin?t.priceMin.toString():void 0,priceMax:void 0!==t.priceMax?t.priceMax.toString():void 0})},[M,y]);(0,c.useEffect)(()=>{let e=new AbortController,t=e.signal;return async function(){let e=R.trim();if(!(e.length>0)||!(e.length<3)){C(!0),D(null);try{if(e.length>=3){let r=await fetch(`/api/wine/search?q=${encodeURIComponent(e)}&pageSize=100`,{signal:t});if(!r.ok)throw Error("Failed to search wines");let s=await r.json();t.aborted||N(s.items||[])}else{let e=new URLSearchParams;M.types.length>0&&e.set("types",M.types.join(",")),M.isOrganic&&e.set("isOrganic","true"),M.byTheGlass&&e.set("byTheGlass","true"),M.countryIds.length>0&&e.set("countryIds",M.countryIds.join(",")),M.regionIds.length>0&&e.set("regionIds",M.regionIds.join(",")),M.wineryIds.length>0&&e.set("wineryIds",M.wineryIds.join(",")),M.grapeVarietyIds.length>0&&e.set("grapeVarietyIds",M.grapeVarietyIds.join(",")),void 0!==M.priceMin&&e.set("priceMin",M.priceMin.toString()),void 0!==M.priceMax&&e.set("priceMax",M.priceMax.toString());let r=e.toString(),s=`/api/wine${r?`?${r}`:""}`,a=await fetch(s,{signal:t});if(!a.ok)throw Error("Failed to fetch wines");let i=await a.json();t.aborted||N(i.items||[])}}catch(e){if(e instanceof DOMException&&"AbortError"===e.name)return;t.aborted||(D(g("filter.error")),N([]))}finally{t.aborted||C(!1)}}}(),()=>e.abort()},[M,R,g]);let T=(0,c.useMemo)(()=>{let e=new Map;w.forEach(t=>{if(t.country){let s=e.get(t.countryId);e.set(t.countryId,{name:"th"===r?t.country.name_th:t.country.name_en,count:(s?.count||0)+1,slug:t.country.slug})}});let t=new Map;w.forEach(e=>{if(e.region&&(0===M.countryIds.length||M.countryIds.includes(e.countryId))){let s=t.get(e.region.id);t.set(e.region.id,{name:"th"===r?e.region.name_th:e.region.name,countryId:e.region.countryId,count:(s?.count||0)+1})}});let s=new Map;w.forEach(e=>{if(e.winery){let t=s.get(e.wineryId);s.set(e.wineryId,{name:e.winery.name,count:(t?.count||0)+1})}});let a=new Map;w.forEach(e=>{e.grapeVarieties.forEach(e=>{let t=a.get(e.id);a.set(e.id,{name:e.name,count:(t?.count||0)+1})})});let i=u.map(e=>{let{min:t,max:r}=e;return{min:t,max:r,count:w.filter(e=>e.dineInPrice>=t&&e.dineInPrice<r).length}});return{countries:Array.from(e.entries()).map(e=>{let[t,r]=e;return{id:t,...r}}).sort((e,t)=>t.count-e.count),regions:Array.from(t.entries()).map(e=>{let[t,r]=e;return{id:t,...r}}).sort((e,t)=>t.count-e.count),wineries:Array.from(s.entries()).map(e=>{let[t,r]=e;return{id:t,...r}}).sort((e,t)=>t.count-e.count),grapeVarieties:Array.from(a.entries()).map(e=>{let[t,r]=e;return{id:t,...r}}).sort((e,t)=>t.count-e.count),priceRanges:i}},[w,M.countryIds,r]),P=()=>{j()},W=(t=0+M.types.length,M.isOrganic&&t++,M.byTheGlass&&t++,t+=M.countryIds.length,t+=M.regionIds.length,t+=M.wineryIds.length,t+=M.grapeVarietyIds.length,(void 0!==M.priceMin||void 0!==M.priceMax)&&t++,t);return(0,s.jsxs)("div",{className:"space-y-4 md:space-y-6",children:[(0,s.jsx)("div",{children:(0,s.jsx)(m.WineSearch,{locale:r})}),!p&&(0,s.jsx)("div",{className:"lg:hidden",children:(0,s.jsxs)("button",{onClick:()=>I(!$),className:"w-full flex items-center justify-between p-4 bg-background-paper border-2 border-border rounded-xl hover:border-primary/50 transition-all duration-200","aria-label":g("accessibility.toggleFilter",{filter:g("filter.title")}),children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("svg",{className:"w-5 h-5 text-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 4a1 1 0 011-1h16a1 1 0 011 1v2.586a1 1 0 01-.293.707l-6.414 6.414a1 1 0 00-.293.707V17l-4 4v-6.586a1 1 0 00-.293-.707L3.293 7.293A1 1 0 013 6.586V4z"})}),(0,s.jsx)("span",{className:"font-semibold text-primary",children:g("filter.title")}),W>0&&(0,s.jsx)("span",{className:"px-2 py-1 text-xs font-bold bg-primary text-primary-foreground rounded-full",children:W})]}),(0,s.jsx)("svg",{className:`w-5 h-5 text-secondary transition-transform duration-200 ${$?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})}),(0,s.jsxs)("div",{className:"flex flex-col lg:grid lg:grid-cols-4 gap-4 lg:gap-6",children:[!p&&(0,s.jsx)("aside",{className:"lg:col-span-1 order-1 lg:order-1",children:(0,s.jsxs)("div",{className:` 6 ${$?"block":"hidden"} lg:block 7 bg-background-paper border-2 border-border rounded-xl lg:sticky lg:top-4 8 shadow-sm hover:shadow-md transition-shadow duration-200 z-40 relative 9 `,children:[(0,s.jsxs)("div",{className:"hidden lg:flex items-center justify-between p-4 lg:p-6 border-b border-border",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("svg",{className:"w-5 h-5 text-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 4a1 1 0 011-1h16a1 1 0 011 1v2.586a1 1 0 01-.293.707l-6.414 6.414a1 1 0 00-.293.707V17l-4 4v-6.586a1 1 0 00-.293-.707L3.293 7.293A1 1 0 013 6.586V4z"})}),(0,s.jsx)("h3",{className:"text-lg font-heading font-bold text-primary",children:g("filter.title")}),W>0&&(0,s.jsx)("span",{className:"px-2 py-1 text-xs font-bold bg-primary text-primary-foreground rounded-full",children:W})]}),W>0&&(0,s.jsx)("button",{onClick:P,className:"text-sm font-medium text-primary hover:text-primary/80 hover:underline transition-colors","aria-label":g("accessibility.clearFilters"),children:g("filter.clearAll")})]}),(0,s.jsxs)("div",{className:"p-4 lg:p-6 space-y-6",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("h4",{className:"text-sm font-bold text-primary mb-4 flex items-center gap-2",children:[(0,s.jsx)("span",{children:"\uD83C\uDF77"}),g("filter.wineType")]}),(0,s.jsx)("div",{className:"grid grid-cols-2 gap-3",children:x.map(e=>{let t=M.types.includes(e);return(0,s.jsx)("button",{onClick:()=>{v.current++,v.current>=5&&f("wine-filter-all"),L(t=>{let r=t.types.includes(e)?t.types.filter(t=>t!==e):[...t.types,e];return r.length>=4&&f("wine-collect-all-types"),{...t,types:r}})},className:` 10 px-3 py-3 rounded-xl text-sm font-semibold transition-all duration-200 11 ${t?"border-4 border-primary bg-primary/10 dark:bg-primary/20 text-primary dark:text-primary shadow-lg ring-2 ring-primary/30":"border-2 border-border bg-background hover:border-primary/50 hover:bg-primary/5 text-primary hover:shadow-sm"} 12 `,"aria-label":g("accessibility.selectType",{type:g(`types.${e.toLowerCase()}`)}),children:g(`types.${e.toLowerCase()}`)},e)})})]}),T.countries.length>0&&(0,s.jsx)("div",{className:"space-y-3",children:(0,s.jsx)(o,{title:g("filter.country"),items:T.countries.map(e=>({id:e.id,name:e.name,count:e.count,icon:function(e){if(!e)return n.unknown;let t=e.toLowerCase().trim();if(n[t])return n[t];let r={united_states:"united-states",us:"usa","united states":"united-states",new_zealand:"new-zealand","new zealand":"new-zealand",south_africa:"south-africa","south africa":"south-africa"};return r[t]&&n[r[t]]?n[r[t]]:n.unknown}(e.slug||e.name).flag})),selectedIds:M.countryIds,onSelectionChange:e=>L(t=>({...t,countryIds:e,regionIds:[]})),maxItems:15,placeholder:g("filter.searchPlaceholder"),defaultOpen:E})}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("h4",{className:"text-sm font-bold text-primary mb-4 flex items-center gap-2",children:[(0,s.jsx)("span",{children:"\uD83C\uDF3F"}),g("filter.organic")," & ",g("filter.byTheGlass")]}),(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("label",{className:"flex items-center gap-3 p-3 rounded-xl border-2 border-border hover:border-primary/50 hover:bg-primary/5 curs
12or-pointer transition-all duration-200",children:[(0,s.jsx)("input",{type:"checkbox",checked:M.isOrganic,onChange:()=>{L(e=>{let t=!e.isOrganic;return t&&f("wine-organic-all"),{...e,isOrganic:t}})},className:"w-5 h-5 rounded border-border text-primary focus:ring-primary focus:ring-2","aria-label":g("accessibility.toggleOrganic")}),(0,s.jsx)("span",{className:"text-lg","aria-hidden":"true",children:"\uD83C\uDF31"}),(0,s.jsx)("span",{className:"text-sm font-medium text-primary flex-1",children:g("filter.organic")})]}),(0,s.jsxs)("label",{className:"flex items-center gap-3 p-3 rounded-xl border-2 border-border hover:border-primary/50 hover:bg-primary/5 cursor-pointer transition-all duration-200",children:[(0,s.jsx)("input",{type:"checkbox",checked:M.byTheGlass,onChange:()=>L(e=>({...e,byTheGlass:!e.byTheGlass})),className:"w-5 h-5 rounded border-border text-primary focus:ring-primary focus:ring-2","aria-label":g("accessibility.toggleByTheGlass")}),(0,s.jsx)("span",{className:"text-lg","aria-hidden":"true",children:"\uD83E\uDD42"}),(0,s.jsx)("span",{className:"text-sm font-medium text-primary flex-1",children:g("filter.byTheGlass")})]})]})]}),M.countryIds.length>0&&T.regions.length>0&&(0,s.jsx)("div",{className:"space-y-3",children:(0,s.jsx)(o,{title:g("filter.region"),items:T.regions.map(e=>({id:e.id,name:e.name,count:e.count})),selectedIds:M.regionIds,onSelectionChange:e=>L(t=>({...t,regionIds:e})),maxItems:15,placeholder:g("filter.searchPlaceholder"),defaultOpen:E})}),T.wineries.length>0&&(0,s.jsx)("div",{className:"space-y-3",children:(0,s.jsx)(o,{title:g("filter.winery"),items:T.wineries.map(e=>({id:e.id,name:e.name,count:e.count})),selectedIds:M.wineryIds,onSelectionChange:e=>L(t=>({...t,wineryIds:e})),maxItems:20,placeholder:g("filter.searchPlaceholder"),defaultOpen:!1})}),T.grapeVarieties.length>0&&(0,s.jsx)("div",{className:"space-y-3",children:(0,s.jsx)(o,{title:g("filter.grapeVariety"),items:T.grapeVarieties.map(e=>({id:e.id,name:e.name,count:e.count})),selectedIds:M.grapeVarietyIds,onSelectionChange:e=>L(t=>({...t,grapeVarietyIds:e})),maxItems:20,placeholder:g("filter.searchPlaceholder"),defaultOpen:!1})}),T.priceRanges.some(e=>e.count>0)&&(0,s.jsx)("div",{className:"space-y-3",children:(0,s.jsx)(o,{title:g("filter.priceRange"),items:u.map((e,t)=>{let{key:r}=e,s=T.priceRanges[t]?.count||0;return{id:r,name:g(`priceRanges.${r}`),count:s}}).filter(e=>e.count>0),selectedIds:void 0!==M.priceMin&&void 0!==M.priceMax?[u.find(e=>e.min===M.priceMin&&e.max===M.priceMax)?.key||""]:[],onSelectionChange:e=>{if(0===e.length)L(e=>({...e,priceMin:void 0,priceMax:void 0}));else{let t=u.find(t=>t.key===e[0]);t&&("over5000"===t.key&&f("wine-price-range-max"),L(e=>({...e,priceMin:t.min,priceMax:t.max})))}},maxItems:10,searchable:!1,showSelectAll:!1,defaultOpen:E})}),W>0&&(0,s.jsx)("div",{className:"lg:hidden pt-4 border-t border-border",children:(0,s.jsx)("button",{onClick:P,className:"w-full px-4 py-3 bg-primary text-primary-foreground rounded-xl font-semibold hover:bg-primary/90 transition-colors","aria-label":g("accessibility.clearFilters"),children:g("filter.clearAll")})})]})]})}),(0,s.jsxs)("main",{className:`${p?"lg:col-span-4":"lg:col-span-3"} order-3 lg:order-2`,children:[(0,s.jsxs)("div",{className:"mb-4 lg:mb-6",children:[R&&(0,s.jsx)("div",{className:"mb-4 p-4 bg-primary/10 dark:bg-primary/20 border-2 border-primary/30 rounded-xl",children:(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("svg",{className:"w-5 h-5 text-primary flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),(0,s.jsx)("div",{className:"flex-1",children:(0,s.jsxs)("p",{className:"text-sm font-medium text-primary",children:[g("search.searchingFor"),":"," ",(0,s.jsxs)("span",{className:"font-bold",children:["â",R,"â"]})]})}),(0,s.jsx)("button",{onClick:()=>{y({q:void 0})},className:"text-sm font-medium text-primary hover:text-primary/80 hover:underline transition-colors",children:g("search.clearSearch")})]})}),(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("h2",{className:"text-xl lg:text-2xl font-heading font-bold text-primary",children:k?g("filter.loading"):R?g("search.resultsFor",{query:R}):g("filter.resultsCount",{count:w.length})}),W>0&&(0,s.jsxs)("button",{onClick:P,className:"hidden lg:flex items-center gap-2 px-4 py-2 text-sm font-medium text-primary hover:text-primary/80 hover:underline transition-colors","aria-label":g("accessibility.clearFilters"),children:[(0,s.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),g("filter.clearAll")]})]})]}
12),k&&(0,s.jsx)("div",{className:"flex items-center justify-center py-16",children:(0,s.jsxs)("div",{className:"flex flex-col items-center gap-4",children:[(0,s.jsx)("div",{className:"animate-spin rounded-full h-12 w-12 border-4 border-primary/20 border-t-primary"}),(0,s.jsx)("p",{className:"text-secondary font-medium",children:g("filter.loading")})]})}),S&&!k&&(0,s.jsx)("div",{className:"bg-red-50 dark:bg-red-900/20 border-2 border-red-200 dark:border-red-800 rounded-xl p-6 text-red-800 dark:text-red-200",children:(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("svg",{className:"w-6 h-6 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,s.jsx)("span",{className:"font-medium",children:S})]})}),!k&&!S&&w.length>0&&(0,s.jsx)(d.WineGrid,{wines:w,locale:r}),!k&&!S&&0===w.length&&(0,s.jsx)("div",{className:"text-center py-16",children:(0,s.jsxs)("div",{className:"max-w-md mx-auto",children:[(0,s.jsx)("div",{className:"text-6xl mb-4",children:"\uD83C\uDF77"}),(0,s.jsx)("h3",{className:"text-xl font-heading font-bold text-primary mb-2",children:g("search.noResults")}),(0,s.jsx)("p",{className:"text-secondary mb-6",children:g("search.tryDifferent")}),(0,s.jsx)("button",{onClick:P,className:"px-6 py-3 bg-primary text-primary-foreground rounded-xl font-semibold hover:bg-primary/90 transition-colors shadow-md hover:shadow-lg","aria-label":g("accessibility.clearFilters"),children:g("filter.clearAll")})]})})]})]})]})}},22729:(e,t,r)=>{r.d(t,{WineToConsider:()=>m});var s=r(95155),a=r(69276),i=r(18955),n=r(15239),l=r(52619),c=r.n(l),o=r(12115);let d={RED:{bg:"bg-[#8B1538]",text:"text-white",border:"border-[#8B1538]"},WHITE:{bg:"bg-[#F5E6D3]",text:"text-[#2C1810]",border:"border-[#D5CCC0]"},ROSE:{bg:"bg-[#FFB6C1]",text:"text-[#2C1810]",border:"border-[#FFB6C1]"},SPARKLING:{bg:"bg-[#FFD700]",text:"text-[#2C1810]",border:"border-[#FFD700]"},DESSERT:{bg:"bg-[#8B6F47]",text:"text-white",border:"border-[#8B6F47]"},FORTIFIED:{bg:"bg-[#8B6F47]",text:"text-white",border:"border-[#8B6F47]"}};function m(e){let{locale:t,wineCandidates:r,statsLoading:l}=e,m=(0,i.c)("wine"),[x]=(0,o.useState)(()=>Math.floor(Date.now()/864e5)),u=(0,o.useMemo)(()=>{if(!r||0===r.length)return null;let e=x%r.length;return r[e]},[r,x]);if(l)return(0,s.jsxs)("div",{className:"card h-full flex flex-col min-h-[300px]",children:[(0,s.jsxs)("div",{className:"mb-4",children:[(0,s.jsx)("h3",{className:"text-xl font-heading font-bold text-primary mb-1",children:m("stats.wineToConsider.title")}),(0,s.jsx)("p",{className:"text-sm text-secondary",children:m("stats.wineToConsider.subtitle")})]}),(0,s.jsxs)("div",{className:"animate-pulse flex-1 flex flex-col items-center",children:[(0,s.jsx)("div",{className:"w-24 h-32 bg-background-elevated rounded-lg mb-2"}),(0,s.jsx)("div",{className:"h-3 bg-background-elevated rounded w-3/4 mb-2"}),(0,s.jsx)("div",{className:"h-3 bg-background-elevated rounded w-1/2 mb-2"}),(0,s.jsx)("div",{className:"h-4 bg-background-elevated rounded w-20"})]})]});if(!u)return(0,s.jsxs)("div",{className:"card-elevated p-6 h-full flex flex-col items-center justify-center min-h-[300px]",children:[(0,s.jsx)("div",{className:"text-6xl mb-4",children:"\uD83C\uDF77"}),(0,s.jsx)("h3",{className:"text-xl font-heading font-bold text-primary mb-2 text-center",children:m("stats.wineToConsider.title")}),(0,s.jsx)("p",{className:"text-sm text-secondary text-center",children:m("errors.loadFailed")})]});let h=d[u.type]||d.RED,p=u.type?m(`types.${u.type.toLowerCase()}`):"";return(0,s.jsxs)("div",{className:"card h-full flex flex-col min-h-[300px]",children:[(0,s.jsxs)("div",{className:"mb-4",children:[(0,s.jsx)("h3",{className:"text-xl font-heading font-bold text-primary mb-1",children:m("stats.wineToConsider.title")}),(0,s.jsx)("p",{className:"text-sm text-secondary",children:m("stats.wineToConsider.subtitle")})]}),(0,s.jsxs)("div",{className:"flex-1 flex flex-col",children:[(0,s.jsxs)("div",{className:"flex gap-4 mb-3 flex-1 min-h-[180px]",children:[(0,s.jsx)("div",{className:"relative w-[30%] h-full flex-shrink-0 rounded-lg overflow-hidden",children:u.imageUrl?(0,s.jsx)(n.default,{src:u.imageUrl,alt:m("accessibility.wineImage",{name:u.name}),fill:!0,className:"object-contain",sizes:"(max-width: 640px) 30vw, (max-width: 1024px) 20vw, 15vw",loading:"lazy"}):(0,s.jsx)("div",{className:"flex items-center justify-center h-full text-muted",children:(0,s.jsx)("span",{className:"text-6xl",children:"\uD83C\uDF77"})})}),(0,s.jsxs)("div",{className:"flex-1 flex flex-col",children:[(0,s.jsx)("div",{className:`inline-block self-start px-2 py-0.5 rounded-full text-xs font-medium border mb-2 ${h.bg} ${h.text} ${h.border}`,children:p}),(0,s.jsx)("h4",{className:"text-sm font-heading font-bold text-primary line-clamp-2 mb-1",children:u.name}),(0,s.jsxs)("p",{className:"text-xs text-secondary line-clamp-1 mb-1",children:[u.wineryName,u.vintage&&` ⢠${u.vintage}`]}),u.code&&(0,s.jsx)("p",{className:"text-[10px] font-mono tracking-wide text-muted/70 uppercase mb-2",children:u.code}),(0,s.jsxs)("div",{className:"flex gap-2 mb-2 flex-wrap",children:[u.isOrganic&&(0,s.jsxs)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-md text-xs font-semibold bg-[#009246] text-white","aria-label":m("accessibility.organicWine"),children:["\uD83C\uDF31 ",m("item.organic")]}),u.byTheGlass&&(0,s.jsxs)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-md text-xs font-semibold bg-[#8B6F47] text-white","aria-label":m("accessibility.byGlass"),children:["\uD83C\uDF77 ",m("item.byGlass")]})]}),(u.tastingNotes_en||u.tastingNotes_th)&&(0,s.jsxs)("div",{className:"mb-2 flex-1",children:[(0,s.jsx)("p",{className:"text-xs font-medium text-secondary mb-0.5",children:m("item.notes")}),(0,s.jsx)("p",{className:"text-xs text-primary line-clamp-3",children:"th"===t&&u.tastingNotes_th?u.tastingNotes_th:u.tastingNotes_en})]}),(0,s.jsxs)("div",{className:"mt-auto",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-0.5",children:[(0,s.jsx)("p",{className:"text-xs text-secondary",children:m("item.dineInPrice")}),(0,s.jsx)(a.Q,{iconSize:"sm"})]}),(0,s.jsxs)("p",{className:"text-base font-bold text-primary",children:["฿",u.dineInPrice?.toLocaleStr
12ing()||"0"]}),u.takeawayPrice&&u.takeawayPrice!==u.dineInPrice&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-0.5 mt-1",children:[(0,s.jsx)("p",{className:"text-xs text-secondary",children:m("item.takeawayPrice")}),(0,s.jsx)(a.Q,{iconSize:"sm"})]}),(0,s.jsxs)("p",{className:"text-sm font-semibold text-primary",children:["฿",u.takeawayPrice?.toLocaleString()||"0"]})]})]})]})]}),(0,s.jsx)("div",{className:"mt-auto pt-4 border-t border-border",children:(0,s.jsx)(c(),{href:`/${t}/wine/${u.slug}`,className:"btn-primary w-full text-center block","aria-label":m("accessibility.viewDetails",{name:u.name}),children:m("stats.wineToConsider.seeMore")})})]})]})}},30730:(e,t,r)=>{r.d(t,{WineStatistics:()=>n});var s=r(95155),a=r(18955),i=r(45987);function n(e){let{statsData:t,statsLoading:r,statsError:n}=e,l=(0,a.c)("wine.stats.statistics");return r?(0,s.jsx)("div",{className:"grid grid-cols-2 sm:grid-cols-2 md:grid-cols-4 lg:grid-cols-4 gap-4 sm:gap-6",children:[1,2,3,4].map(e=>(0,s.jsx)("div",{className:"card h-full flex items-center justify-center min-h-[200px]",children:(0,s.jsx)("div",{className:"animate-pulse text-4xl",children:"\uD83D\uDCCA"})},e))}):n||!t?(0,s.jsx)("div",{className:"card p-6 text-center",children:(0,s.jsx)("p",{className:"text-secondary",children:n||"Unable to load statistics"})}):(0,s.jsxs)("div",{className:"grid grid-cols-2 sm:grid-cols-2 md:grid-cols-2 lg:grid-cols-4 gap-6 lg:gap-8",children:[(0,s.jsx)(i.StatisticsCard,{topSubtitle:l("totalWines.topSubtitle"),title:l("totalWines.label"),count:t.totalWines,subtitle:l("totalWines.subtitle",{organic:t.organicWines,types:t.wineTypes}),icon:"\uD83C\uDF77"}),(0,s.jsx)(i.StatisticsCard,{topSubtitle:l("countries.topSubtitle"),title:l("countries.label"),count:t.totalCountries,subtitle:l("countries.subtitle",{regions:t.totalRegions}),icon:"\uD83C\uDF0D"}),(0,s.jsx)(i.StatisticsCard,{topSubtitle:l("wineries.topSubtitle"),title:l("wineries.label"),count:t.totalWineries,subtitle:l("wineries.subtitle"),icon:"\uD83C\uDFED"}),(0,s.jsx)(i.StatisticsCard,{topSubtitle:l("grapes.topSubtitle"),title:l("grapes.label"),count:t.totalGrapes,subtitle:l("grapes.subtitle"),icon:"\uD83C\uDF47"})]})}},35648:(e,t,r)=>{r.d(t,{X:()=>a});var s=r(12115);
12function a(){let[e,t]=(0,s.useState)(null),[r,a]=(0,s.useState)(!0),[i,n]=(0,s.useState)(null);return(0,s.useEffect)(()=>{let e=!0;return(async()=>{try{let r=await fetch("/api/settings/public"),s=await r.json();if(!e)return;s.success&&s.data?t(s.data.setting_value):n(s.error||"Failed to load tax configuration")}catch(t){if(!e)return;n("Failed to fetch tax configuration")}finally{e&&a(!1)}})(),()=>{e=!1}},[]),{taxConfig:e,isLoading:r,error:i}}},36837:(e,t,r)=>{r.d(t,{WineStatsSection:()=>j});var s=r(95155),a=r(12115);let i=null,n=0,l=null;async function c(){return i&&Date.now()-n<36e5?i:l||(l=fetch("/api/wine/stats").then(e=>{if(!e.ok)throw Error(`Stats API error: ${e.status}`);return e.json()}).then(e=>(i=e,n=Date.now(),l=null,e)).catch(e=>{throw l=null,e}))}var o=r(6092);function d(e){let{title:t,children:r,defaultExpanded:i=!0,icon:n,className:l=""}=e,[c,d]=(0,a.useState)(i);return(0,s.jsxs)("div",{className:l,children:[(0,s.jsxs)("button",{onClick:()=>d(!c),className:"w-full flex items-center justify-between gap-4 py-3 px-4 rounded-lg bg-gradient-to-r from-primary/5 to-accent/5 border border-primary/20 hover:border-primary/40 transition-all duration-300 group","aria-expanded":c,children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[n&&(0,s.jsx)("span",{className:"text-lg sm:text-xl text-primary",children:n}),(0,s.jsx)("h3",{className:"text-lg sm:text-xl font-heading font-bold text-primary text-left",children:t})]}),(0,s.jsx)("div",{className:c?"flex items-center justify-center w-8 h-8 rounded-full bg-primary/10 group-hover:bg-primary/20 transition-all duration-300 rotate-180":"flex items-center justify-center w-8 h-8 rounded-full bg-primary/10 group-hover:bg-primary/20 transition-all duration-300 rotate-0",children:(0,s.jsx)(o.tEr,{className:"text-primary text-lg"})})]}),(0,s.jsx)("div",{className:c?"transition-all duration-300 ease-in-out opacity-100 mt-6":"overflow-hidden transition-all duration-300 ease-in-out max-h-0 opacity-0 mt-0",children:r})]})}var m=r(18955),x=r(80834),u=r(60279),h=r(44326),p=r(85464),g=r(88968),f=r(30730),b=r(22729),y=r(48884);function j(e){let{locale:t}=e,r=(0,m.c)("wine"),{data:l,loading:o,error:j}=function(){let[e,t]=(0,a.useState)(i),[r,s]=(0,a.useState)(!i),[l,o]=(0,a.useState)(null),d=(0,a.useRef)(!1),m=(0,a.useCallback)(async()=>{try{s(!0);let e=await c();t(e),o(null)}catch(e){o("Failed to load wine statistics")}finally{s(!1)}},[]);return(0,a.useEffect)(()=>{if(!d.current){if(d.current=!0,i&&Date.now()-n<36e5){t(i),s(!1);return}m()}},[m]),{data:e,loading:r,error:l}}();return(0,s.jsxs)("div",{className:"space-y-8",children:[(0,s.jsx)("div",{className:"flex items-center gap-4",children:(0,s.jsx)("h2",{className:"text-3xl md:text-4xl font-heading font-bold text-primary wine-accent",children:r("stats.title")})}),(0,s.jsx)("p",{className:"text-base md:text-lg text-secondary max-w-3xl",children:r("stats.subtitle")}),(0,s.jsx)("div",{className:"italian-divider"}),(0,s.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-2 lg:grid-cols-4 gap-6 lg:gap-8",children:[(0,s.jsx)("div",{className:"md:col-span-1",children:(0,s.jsx)(b.WineToConsider,{locale:t,wineCandidates:l?.wineCandidates,statsLoading:o})}),(0,s.jsx)("div",{className:"md:col-span-1",children:(0,s.jsx)(h.FunFactsCard,{locale:t,funFacts:l?.funFacts,statsLoading:o})}),(0,s.jsx)("div",{className:"md:col-span-1",children:(0,s.jsx)(x.CountryOfTheDayCard,{locale:t,countriesWithWines:l?.countriesWithWines,statsLoading:o})}),(0,s.jsx)("div",{className:"md:col-span-1",children:(0,s.jsx)(y.WineryOfTheDayCard,{locale:t,wineriesWithWines:l?.wineriesWithWines,statsLoading:o})})]}),(0,s.jsx)("div",{className:"mt-12",children:(0,s.jsx)(d,{title:r("stats.statistics.title"),icon:"\uD83D\uDCCA",defaultExpanded:!0,children:(0,s.jsx)(f.WineStatistics,{statsData:l?.statistics,statsLoading:o,statsError:j})})}),(0,s.jsx)("div",{className:"mt-12",children:(0,s.jsxs)(d,{title:r("stats.statistics.moreTitle"),icon:"\uD83D\uDCC8",defaultExpanded:!1,children:[(0,s.jsx)("div",{className:"mb-12",children:(0,s.jsx)(g.WineCharts,{locale:t,chartsData:l?.charts,countriesWithWines:l?.countriesWithWines,statsLoading:o})}),(0,s.jsx)("div",{className:"mb-12",children:(0,s.jsx)(u.DualBarChart,{locale:t,chartsData:l?.charts,countriesWithWines:l?.countriesWithWines,statsLoading:o})}),(0,s.jsx)("div",{children:(0,s.jsx)(p.GrapeVarietyCharts,{locale:t,grapeData:l?.grapeData,statsLoading:o})})]})})]})}},44086:(e,t,r)=>{r.d(t,{WineCatalogue:()=>u});var s=r(95155),a=r(69276),i=r(35648),n=r(273),l=r(96204),c=r(26497),o=r(16001),d=r(18955),m=r(15239),x=r(12115);function u(e){let{locale:t,winesPerPage:r=8,enableTouchNavigation:u=!0,enableWineDetailClick:h=!0}=e,p=(0,d.c)("wine"),{taxConfig:g}=(0,i.X)(),{searchParams:f,updateUrl:b}=(0,n.m)(),{wines:y,loading:j,error:v}=(0,l.P)(),[w,N]=(0,x.useState)(null),[k,C]=(0,x.useState)(!1),S=f.get("wineType")||null,D=parseInt(f.get("page")||"0",10),$=(0,x.useMemo)(()=>
12{if(0===y.length)return[];let e=(S?y.filter(e=>e.type===S):y).reduce((e,t)=>(e[t.type]||(e[t.type]=[]),e[t.type].push(t),e),{});Object.keys(e).forEach(t=>{e[t].sort((e,t)=>{let r=e.dineInPrice||0,s=t.dineInPrice||0;return r!==s?r-s:e.name.localeCompare(t.name)})});let t=[];return(S?[S]:["RED","WHITE","ROSE","SPARKLING"]).forEach(s=>{let a=e[s]||[];if(0!==a.length)for(let e=0;e<a.length;e+=r){let i=a.slice(e,e+r),n=Math.floor(e/r)+1,l=Math.ceil(a.length/r);t.push({id:`${s}-${n}`,title:l>1?`${p(`catalogue.sections.${s.toLowerCase()}Wines`)} - ${p("catalogue.pageNavigation.pageOf",{current:n,total:l})}`:p(`catalogue.sections.${s.toLowerCase()}Wines`),wines:i,wineType:s,totalWinesForType:a.length})}}),t},[y,r,S,p]),I=(0,x.useCallback)(e=>{e>=0&&e<$.length&&b({page:e.toString()},{preservePage:!0})},[$.length,b]),E=(0,x.useCallback)(()=>{I(D-1)},[D,I]),F=(0,x.useCallback)(()=>{I(D+1)},[D,I]),R=(0,x.useCallback)(()=>{u&&C(!0)},[u]),M=(0,x.useCallback)((e,t)=>{if(!u)return;let r=t.velocity.x,s=t.offset.x;(Math.abs(s)>50||Math.abs(r)>500)&&(s>0||r>0?(N("right"),E()):(N("left"),F())),setTimeout(()=>{N(null),C(!1)},300)},[u,E,F]),L=(0,x.useCallback)((e,r)=>{if(!h||k)return void r.preventDefault();window.location.href=`/${t}/wine/${e}`},[k,t,h]);(0,x.useEffect)(()=>{let e=e=>{"ArrowLeft"===e.key?(e.preventDefault(),E()):"ArrowRight"===e.key&&(e.preventDefault(),F())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[E,F]);let T=e=>{switch(e){case"RED":default:return"\uD83C\uDF77";case"WHITE":return"\uD83E\uDD42";case"ROSE":return"\uD83C\uDF39";case"SPARKLING":return"\uD83C\uDF7E"}};if(j)return(0,s.jsxs)("div",{className:"flex items-center justify-center py-12",children:[(0,s.jsx)("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-primary"}),(0,s.jsx)("span",{className:"ml-3 text-secondary",children:p("filter.loading")})]});if(v)return(0,s.jsx)("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 text-red-800 dark:text-red-200",children:v});if(0===$.length)return(0,s.jsx)("div",{className:"text-center py-12",children:(0,s.jsx)("p",{className:"text-secondary",children:p("search.noResults")})});let P=$[D];return(0,s.jsxs)("div",{className:"max-w-5xl mx-auto",children:[(0,s.jsxs)("div",{className:"text-center",children:[(0,s.jsx)("h1",{className:"text-4xl md:text-5xl font-heading font-bold text-primary mb-4",children:p("catalogue.title")}),(0,s.jsx)("p",{className:"text-lg text-secondary max-w-2xl mx-auto leading-relaxed",children:p("catalogue.subtitle")}),(0,s.jsx)("div",{className:"mt-6 flex justify-center",children:(0,s.jsx)("div",{className:"w-24 h-1 bg-gradient-to-r from-primary to-accent rounded-full"})})]}),(0,s.jsx)("div",{className:"mt-8 mb-8",children:(0,s.jsxs)("div",{className:"flex flex-wrap justify-center gap-3",children:[(0,s.jsxs)("button",{onClick:()=>b({wineType:void 0,page:"0"},{preservePage:!0}),className:`px-4 py-2 rounded-full text-sm font-medium transition-all duration-200 flex items-center gap-2 ${null===S?"bg-primary text-primary-foreground border-primary ring-2 ring-primary/30 ring-offset-2 ring-offset-background":"bg-background-paper text-text-secondary border-border hover:border-primary hover:text-primary hover:bg-surface-hover"}`,"aria-label":p("filter.all"),children:[(0,s.jsx)("span",{children:"â¨"}),p("filter.all")]}),["RED","WHITE","ROSE","SPARKLING"].map(e=>(0,s.jsxs)("button",{onClick:()=>b({wineType:e,page:"0"},{preservePage:!0}),className:`px-4 py-2 rounded-full text-sm font-medium transition-all duration-200 flex items-center gap-2 ${S===e?"bg-primary text-primary-foreground border-primary ring-2 ring-primary/30 ring-offset-2 ring-offset-background":"bg-background-paper text-text-secondary border-border hover:border-primary hover:text-primary hover:bg-surface-hover"}`,children:[(0,s.jsx)("span",{children:T(e)}),p(`types.${e.toLowerCase()}`)]},e))]})}),(0,s.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,s.jsxs)("button",{onClick:E,disabled:0===D,className:"flex items-center gap-2 px-4 py-2 rounded-lg border border-border bg-background-paper hover:bg-background-elevated disabled:opacity-50 disabled:cursor-not-allowed transition-colors","aria-label":p("catalogue.pageNavigation.previousPage"),children:[(0,s.jsx)("span",{className:"text-lg",children:"â"}),(0,s.jsx)("span",{className:"hidden sm:inline",children:p("catalogue.pageNavigation.previousPage")})]}),(0,s.jsxs)("div",{className:"text-center",children:[(0,s.jsx)("p",{className:"text-sm text-muted",children:p("catalogue.pageNavigation.pageOf",{current:D+1,total:$.length})}),u&&(0,s.jsx)("p",{className:"text-xs text-muted mt-1 hidden sm:block",children:p("catalogue.pageNavigation.swipeHint")})]}),(0,s.jsxs)("button",{onClick:F,disabled:D===$.length-1,className:"flex items-center gap-2 px-4 py-2 rounded-lg border border-border bg-background-paper hover:bg-background-elevated disabled:opacity-50 disabled:cursor-not-allowed transition-colors","aria-label":p("catalogue.pageNavigation.nextPage"),children:[(0,s.jsx)("span",{className:"hidden sm:inline",children:p("catalogue.pageNavigation.nextPage")}),(0,s.jsx)("span",{className:"text-lg",children:"â"})]})]}),(0,s.jsx)("div",{className:"relative overflow-hidden",children:(0,s.jsx)(c.N,{mode:"wait",custom:w,children:(0,s.jsxs)(o.P.div,{custom:w,initial:{opacity:0,x:"left"===w?100:"right"===w?-100:0,rotateY:"left"
12===w?15:"right"===w?-15:0},animate:{opacity:1,x:0,rotateY:0},exit:{opacity:0,x:"left"===w?-100:100*("right"===w),rotateY:"left"===w?-15:15*("right"===w)},transition:{duration:.4,ease:[.4,0,.2,1]},drag:!!u&&"x",dragConstraints:{left:0,right:0},dragElastic:.2,onDragStart:R,onDragEnd:M,className:"bg-background-paper rounded-xl border border-border shadow-lg p-8 min-h-[600px]",style:{perspective:"1000px",transformStyle:"preserve-3d"},children:[(0,s.jsxs)("div",{className:"text-center mb-8",children:[(0,s.jsxs)("div",{className:"flex justify-center items-center gap-4 mb-4",children:[(0,s.jsx)("div",{className:"flex-1 h-px bg-gradient-to-r from-transparent to-primary/30"}),(0,s.jsx)("div",{className:"text-3xl",children:T(P.wineType)}),(0,s.jsx)("div",{className:"flex-1 h-px bg-gradient-to-l from-transparent to-primary/30"})]}),(0,s.jsx)("h2",{className:`text-2xl md:text-3xl font-heading font-bold mb-2 ${(e=>{switch(e){case"RED":return"text-red-700 dark:text-red-400";case"WHITE":return"text-orange-700 dark:text-yellow-400";case"ROSE":return"text-pink-600 dark:text-pink-400";case"SPARKLING":return"text-amber-600 dark:text-amber-400";default:return"text-primary"}})(P.wineType)}`,children:P.title}),(0,s.jsxs)("p",{className:"text-sm text-muted",children:[P.totalWinesForType||P.wines.length," ",p("catalogue.selection")]})]}),(0,s.jsx)("div",{className:"space-y-0",children:P.wines.map((e,r)=>(0,s.jsxs)(o.P.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1*r},className:`group ${h?"cursor-pointer":"cursor-default"}`,onClick:t=>L(e.slug,t),children:[(0,s.jsx)("div",{className:"py-6 group-hover:bg-background-elevated/50 rounded-lg px-4 -mx-4 transition-colors",children:(0,s.jsx)("div",{className:"flex-1",children:(0,s.jsxs)("div",{className:"flex items-stretch gap-4",children:[(0,s.jsx)("div",{className:"flex-shrink-0 w-[75px] min-h-[120px] flex items-center",children:e.image&&(0,s.jsx)("div",{className:"relative rounded-md overflow-hidden p-1 h-full w-full flex items-center justify-center min-h-[100px]",children:(0,s.jsx)(m.default,{src:e.image.url,alt:e.image.alt?"th"===t?e.image.alt.th||e.image.alt.en||p("accessibility.wineImage",{name:e.name}):e.image.alt.en||e.image.alt.th||p("accessibility.wineImage",{name:e.name}):p("accessibility.wineImage",{name:e.name}),fill:!0,className:"object-contain",loading:"lazy"})})}),(0,s.jsxs)("div",{className:"flex-1 grid grid-cols-3 gap-4",children:[(0,s.jsxs)("div",{className:"col-span-2",children:[(0,s.jsx)("h3",{className:"text-lg font-heading font-semibold text-primary mb-1 group-hover:text-primary/80 transition-colors",children:e.name}),(0,s.jsxs)("p",{className:"text-sm text-secondary mb-1",children:[e.winery&&e.winery.name,e.vintage&&` ⢠${e.vintage}`,e.country&&` ⢠${"th"===t?e.country.name_th:e.country.name_en}`]}),(0,s.jsxs)("div",{className:"mb-2 flex items-center gap-2 flex-wrap",children:[e.isOrganic&&(0,s.jsxs)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-accent/10 text-accent",children:["\uD83C\uDF31 ",p("item.organic")]}),e.byTheGlass&&(0,s.jsxs)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-secondary/10 text-secondary",children:["\uD83C\uDF77 ",p("item.byGlass")]})]}),e.grapeVarieties&&e.grapeVarieties.length>0&&(0,s.jsx)("p",{className:"text-xs text-muted mb-2",children:e.grapeVarieties.map(e=>e.name).join(", ")})]}),(0,s.jsx)("div",{className:"col-span-1 text-right",children:(0,s.jsxs)("div",{className:"space-y-1",children:[e.code&&(0,s.jsx)("span",{className:"text-xs font-mono tracking-wide text-muted/80 uppercase",children:e.code}),(0,s.jsxs)("div",{className:"text-lg font-semibold text-primary flex items-center justify-end gap-1",children:["฿",e.dineInPrice?.toLocaleString()||"0",(0,s.jsx)(a.Q,{iconSize:"sm"})]}),(0,s.jsx)("div",{className:"text-xs text-muted",children:p("item.dineInPrice")}),e.takeawayPrice&&e.takeawayPrice!==e.dineInPrice&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"text-sm text-secondary flex items-center justify-end gap-1",children:["฿",e.takeawayPrice?.toLocaleStr
12ing()||"0",(0,s.jsx)(a.Q,{iconSize:"sm"})]}),(0,s.jsx)("div",{className:"text-xs text-muted",children:p("item.takeawayPrice")})]}),e.byGlassPrice&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"text-sm font-medium text-blue-600 dark:text-blue-400 flex items-center justify-end gap-1",children:["฿",e.byGlassPrice.toLocaleString(),(0,s.jsx)(a.Q,{iconSize:"sm"})]}),(0,s.jsxs)("div",{className:"text-xs text-muted",children:["\uD83C\uDF77 ",p("labels.perGlass")]})]})]})}),(0,s.jsx)("div",{className:"col-span-3",children:(e.tastingNotes_en||e.tastingNotes_th)&&(0,s.jsx)("p",{className:"text-sm text-secondary mb-2 italic leading-relaxed hidden md:block",children:"th"===t?e.tastingNotes_th||e.tastingNotes_en:e.tastingNotes_en||e.tastingNotes_th})})]})]})})}),r<P.wines.length-1&&(0,s.jsx)("div",{className:"border-b border-border/30 mx-4"})]},e.id))})]},D)})}),(0,s.jsx)("div",{className:"flex justify-center items-center gap-2 mt-8",children:$.map((e,t)=>(0,s.jsx)("button",{onClick:()=>I(t),className:`w-2 h-2 rounded-full transition-colors ${t===D?"bg-primary":"bg-border hover:bg-border-hover"}`,"aria-label":p("catalogue.pageNavigation.goToPage",{page:t+1})},t))}),(0,s.jsxs)("div",{className:"text-center mt-6",children:[(0,s.jsx)("p",{className:"text-sm text-muted mb-4",children:p("catalogue.footer")}),(0,s.jsxs)("div",{className:"flex justify-center items-center gap-2 text-xs text-muted",children:[(0,s.jsx)("span",{children:"\uD83C\uDF77"},"wine-icon"),(0,s.jsx)("span",{children:p("catalogue.totalWines",{count:y.length})},"total-wines"),(0,s.jsx)("span",{children:"â¢"},"separator-1"),(0,s.jsx)("span",{children:p("catalogue.updated")},"updated"),(0,s.jsx)("span",{children:"â¢"},"separator-2"),(0,s.jsx)("span",{children:g?g.price_includes_tax?p("catalogue.pricesIncludeTax",{taxName:g.tax_name,taxRate:g.tax_rate.toFixed(0)}):p("catalogue.pricesExcludeTax",{taxName:g.tax_name,taxRate:g.tax_rate.toFixed(0)}):p("catalogue.prices")},"prices")]})]})]})}},44326:(e,t,r)=>{r.d(t,{FunFactsCard:()=>n});var s=r(95155),a=r(18955),i=r(12115);function n(e){let{locale:t,funFacts:r,statsLoading:n}=e,l=(0,a.c)("wine.stats.funFacts"),[c,o]=(0,i.useState)(!1),[d]=(0,i.useState)(()=>Math.floor(Date.now()/864e5)),[m,x]=(0,i.useState)(null),u=(0,i.useMemo)(()=>r&&0!==r.length?r[d%r.length]:null,[r,d]),h=m||u,p=!!r,g=(0,i.useCallback)(()=>{if(!r||0===r.length)return;o(!0);let e=Math.floor(Math.random()*r.length);x(r[e]),setTimeout(()=>o(!1),500)},[r]);if(n||!p)return(0,s.jsx)("div",{className:"card h-full flex items-center justify-center min-h-[300px]",children:(0,s.jsxs)("div",{className:"flex flex-col items-center gap-4",children:[(0,s.jsx)("div",{className:"animate-spin text-4xl",children:"\uD83C\uDF77"}),(0,s.jsx)("p",{className:"text-sm text-secondary",children:l("loading")})]})});if(!h)return(0,s.jsx)("div",{className:"card h-full flex items-center justify-center min-h-[300px]",children:(0,s.jsxs)("div",{className:"flex flex-col items-center gap-4 text-center",children:[(0,s.jsx)("div",{className:"text-4xl",children:"\uD83C\uDF47"}),(0,s.jsx)("p",{className:"text-sm text-secondary",children:l("error")})]})});let f="th"===t?h.fact_th:h.fact_en,b={history:"\uD83D\uDCDC",production:"\uD83C\uDF47",tasting:"\uD83D\uDC43",culture:"\uD83C\uDF0D",health:"\uD83D\uDC9A",storage:"\uD83C\uDF7E",serving:"\uD83E\uDD42"}[h.category||""]||"\uD83C\uDF77";return(0,s.jsxs)("div",{className:"card h-full flex flex-col min-h-[300px]","data-egg":"wine-fun-fact","data-egg-mode":"double-click",children:[(0,s.jsxs)("div",{className:"mb-4",children:[(0,s.jsx)("h3",{className:"text-xl font-heading font-bold text-primary mb-1",children:l("title")}),(0,s.jsx)("p",{className:"text-sm text-secondary",children:l("subtitle")})]}),(0,s.jsxs)("div",{className:"flex items-center gap-4 mb-4",children:[(0,s.jsx)("div",{className:"w-16 h-16 rounded-full bg-background-elevated flex items-center justify-center text-3xl flex-shrink-0",children:b}),(0,s.jsx)("div",{className:"flex-1",children:(0,s.jsx)("h4",{className:"text-lg font-heading font-bold text-primary capitalize",children:h.category&&l(`categories.${h.category}`)})})]}),(0,s.jsx)("div",{className:"flex-1"}),(0,s.jsx)("div",{className:`mb-4 transition-all duration-500 ${c?"opacity-0 scale-95":"opacity-100 scale-100"}`,children:(0,s.jsx)("div",{className:"rounded-lg",children:(0,s.jsx)("p",{className:"text-sm text-primary leading-relaxed",children:f})})}),(0,s.jsx)("div",{className:"pt-4 border-t border-border",children:(0,s.jsxs)("button",{onClick:g,disabled:c,
12className:"btn-primary w-full flex items-center justify-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed","aria-label":l("getMoreButton"),children:[(0,s.jsx)("span",{className:c?"animate-spin":"",children:"\uD83D\uDD04"}),(0,s.jsx)("span",{children:l("getMoreButton")})]})})]})}},45740:(e,t,r)=>{r.d(t,{WineTabsWithRouter:()=>o});var s=r(95155),a=r(16001),i=r(18955),n=r(20063),l=r(12115);let c=[{id:"search",icon:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"},{id:"explore",icon:"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"},{id:"catalogue",icon:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"}];function o(e){let{activeTab:t,children:r}=e,o=(0,i.c)("wine.tabs"),d=(0,n.useRouter)(),m=(0,n.usePathname)(),[x,u]=(0,l.useState)(!1),[h,p]=(0,l.useState)(null),g=(0,l.useRef)(null),f=m.split("/")[1],b=async e=>{if(e===t||x)return;u(!0),p(e),g.current&&clearTimeout(g.current);let r=`/${f}/wine/${e}`;d.push(r),g.current=setTimeout(()=>{u(!1),p(null)},5e3)};return(0,l.useEffect)(()=>{if(h&&t===h){let e=setTimeout(()=>{u(!1),p(null),g.current&&(clearTimeout(g.current),g.current=null)},0);return()=>clearTimeout(e)}return()=>{}},[t,h]),(0,l.useEffect)(()=>()=>{g.current&&clearTimeout(g.current)},[]),(0,l.useEffect)(()=>{c.forEach(e=>{e.id!==t&&d.prefetch(`/${f}/wine/${e.id}`)})},[t,f,d]),(0,s.jsxs)("div",{className:"w-full relative",children:[(0,s.jsx)("div",{className:"relative",children:(0,s.jsx)("div",{className:"flex border-b-2 border-border",role:"tablist","aria-label":o("search")+" / "+o("explore")+" / "+o("catalogue"),children:c.map(e=>{let r=t===e.id,i=x&&h===e.id;return(0,s.jsxs)("button",{role:"tab","aria-selected":r,"aria-controls":`${e.id}-panel`,id:`${e.id}-tab`,onClick:()=>b(e.id),disabled:x,className:` 13 relative flex-1 flex items-center justify-center gap-2 14 px-2 py-4 md:px-6 md:py-5 15 font-bold text-sm md:text-base 16 transition-all duration-300 17 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset 18 disabled:cursor-not-allowed 19 ${r?"text-primary-foreground bg-primary hover:bg-primary-hover border-2 border-primary border-b-0 rounded-t-lg":"text-muted hover:text-primary hover:bg-surface-hover"} 20 ${x&&!r?"opacity-50":""} 21 `,children:[(0,s.jsx)("svg",{className:`w-5 h-5 md:w-6 md:h-6 flex-shrink-0 transition-transform duration-300 ${r?"scale-110":""} ${i?"animate-pulse":""}`,fill:"none",stroke:"currentColor",strokeWidth:r?2.5:2,viewBox:"0 0 24 24","aria-hidden":"true",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:e.icon})}),(0,s.jsx)("span",{className:"hidden sm:inline",children:o(e.id)}),(0,s.jsx)("span",{className:"sm:hidden text-xs font-semibold",children:o(e.id)}),r&&!x&&(0,s.jsx)(a.P.div,{layoutId:"activeTabIndicator",className:"absolute bottom-0 left-0 right-0 h-1 bg-gradient-to-r from-primary via-primary to-accent rounded-t-full",initial:!1,transition:{type:"spring",stiffness:500,damping:35}}),i&&(0,s.jsx)("div",{className:"absolute inset-0 bg-primary/10 rounded-t-lg flex items-center justify-center",children:(0,s.jsx)("div",{className:"w-4 h-4 border-2 border-primary/30 border-t-primary rounded-full animate-spin"})})]},e.id)})})}),(0,s.jsx)("div",{className:"pt-6 md:pt-8",children:(0,s.jsxs)("div",{role:"tabpanel",id:`${t}-panel`,"aria-labelledby":`${t}-tab`,className:`transition-opacity duration-300 ${x?"opacity-50 pointer-events-none":"opacity-100"}`,children:[x&&(0,s.jsx)("div",{className:"absolute inset-0 bg-background/80 backdrop-blur-sm z-10 flex items-center justify-center",children:(0,s.jsxs)("div",{className:"flex flex-col items-center gap-4",children:[(0,s.jsx)("div",{className:"w-8 h-8 border-4 border-primary/20 border-t-primary rounded-full animate-spin"}),(0,s.jsxs)("p",{className:"text-secondary font-medium",children:[o(h||t),"..."]})]})}),r]})}),(0,s.jsx)("nav",{className:"sr-only","aria-label":"Wine section navigation",children:(0,s.jsxs)("ul",{children:[(0,s.jsx)("li",{children:(0,s.jsx)("a",{href:`/${f}/wine/search`,rel:"prefetch",children:o("search")})}),(0,s.jsx)("li",{children:(0,s.jsx)("a",{href:`/${f}/wine/explore`,rel:"prefetch",children:o("explore")})}),(0,s.jsx)("li",{children:(0,s.jsx)("a",{href:`/${f}/wine/catalogue`,rel:"prefetch",children:o("catalogue")})})]})})]})}},45987:(e,t,r)=>{r.d(t,{StatisticsCard:()=>a});var s=r(95155);function a(e){let{topSubtitle:t,title:r,count:a,subtitle:i,icon:n}=e;return(0,s.jsxs)("div",{className:"card h-full flex flex-col items-center justify-center text-center p-4 sm:p-6 min-h-[200px] bg-gradient-to-br from-background to-background-elevated hover:shadow-lg transition-shadow duration-300",children:[(0,s.jsx)("p",{className:"text-xs sm:text-sm text-secondary mb-2 sm:mb-3 font-medium",children:t}),(0,s.jsxs)("div",{className:"flex items-center gap-2 sm:gap-3 mb-2",children:[n&&(0,s.jsx)("span",{className:"text-3xl sm:text-4xl md:text-5xl",children:n}),(0,s.jsx)("span",{className:"text-3xl sm:text-4xl md:text-5xl lg:text-6xl font-heading font-bold text-primary",children:a.toLocaleStr
21ing()})]}),(0,s.jsx)("h3",{className:"text-base sm:text-lg md:text-xl font-heading font-bold text-primary mb-1 sm:mb-2",children:r}),(0,s.jsx)("p",{className:"text-xs sm:text-sm text-secondary leading-relaxed max-w-xs",children:i})]})}},48884:(e,t,r)=>{r.d(t,{WineryOfTheDayCard:()=>o});var s=r(95155),a=r(18955),i=r(15239),n=r(52619),l=r.n(n),c=r(12115);function o(e){let{locale:t,wineriesWithWines:r,statsLoading:n}=e,o=(0,a.c)("wine.stats.wineryOfTheDay"),[d]=(0,c.useState)(()=>Math.floor(Date.now()/864e5)),m=(0,c.useMemo)(()=>r&&0!==r.length?r[d%r.length]:null,[r,d]),x=(0,c.useMemo)(()=>m?.facts&&0!==m.facts.length?m.facts[d%m.facts.length]:null,[m,d]),u=!!r;if(n||!u)return(0,s.jsx)("div",{className:"card h-full flex items-center justify-center min-h-[300px]",children:(0,s.jsxs)("div",{className:"flex flex-col items-center gap-4",children:[(0,s.jsx)("div",{className:"animate-spin text-4xl",children:"\uD83C\uDF77"}),(0,s.jsx)("p",{className:"text-sm text-secondary",children:o("loading")})]})});if(!m)return(0,s.jsx)("div",{className:"card h-full flex items-center justify-center min-h-[300px]",children:(0,s.jsxs)("div",{className:"flex flex-col items-center gap-4 text-center",children:[(0,s.jsx)("div",{className:"text-4xl",children:"\uD83C\uDF77"}),(0,s.jsx)("p",{className:"text-sm text-secondary",children:o("error")})]})});let h="th"===t?m.countryName.th:m.countryName.en,p=m.regionName?"th"===t?m.regionName.th:m.regionName.en:null,g=x&&("th"===t?x.fact_th:x.fact_en);return(0,s.jsxs)("div",{className:"card h-full flex flex-col min-h-[300px]",children:[(0,s.jsxs)("div",{className:"mb-4",children:[(0,s.jsx)("h3",{className:"text-xl font-heading font-bold text-primary mb-1",children:o("title")}),(0,s.jsx)("p",{className:"text-sm text-secondary",children:o("subtitle")})]}),(0,s.jsxs)("div",{className:"flex items-center gap-4 mb-4",children:[(0,s.jsx)("div",{className:"w-16 h-16 rounded-full bg-background-elevated flex items-center justify-center text-3xl flex-shrink-0",children:"\uD83C\uDF77"}),(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("h4",{className:"text-lg font-heading font-bold text-primary",children:m.name}),(0,s.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[m.countryFlagUrl&&(0,s.jsx)("div",{className:"relative w-5 h-4 flex-shrink-0",children:(0,s.jsx)(i.default,{src:m.countryFlagUrl,alt:h,fill:!0,className:"rounded-sm object-cover",sizes:"20px"})}),(0,s.jsx)("p",{className:"text-sm text-secondary",children:p?`${p}, ${h}`:h})]}),(0,s.jsx)("p",{className:"text-sm text-secondary mt-1",children:o("wineCount",{count:m.wineCount})})]})]}),g&&(0,s.jsx)("div",{className:"flex-1 mb-4 flex flex-col justify-end rounded-lg",children:(0,s.jsx)("p",{className:"text-sm text-primary leading-relaxed",children:g})}),(0,s.jsx)("div",{className:"mt-auto pt-4 border-t border-border",children:(0,s.jsx)(l(),{href:`/${t}/wine/browse/${m.slug}-winery-wines`,className:"btn-primary w-full text-center block",children:o("viewWines")})})]})}},55893:(e,t,r)=>{r.d(t,{ExploreWines:()=>h});var s=r(95155),a=r(17644),i=r(96204),n=r(18955),l=r(15239),c=r(52619),o=r.n(c),d=r(20063),m=r(12115);function x(e){let{title:t,icon:r,imageSrc:a,href:i,color:n}=e;return(0,s.jsxs)(o(),{href:i,className:`group relative block h-24 rounded-lg border-2 transition-all duration-300 hover:shadow-lg hover:-translate-y-1 ${n}`,children:[a&&(0,s.jsx)("div",{className:"absolute inset-0 rounded-lg overflow-hidden",children:(0,s.jsx)(l.default,{src:a,alt:"",fill:!0,className:"object-contain opacity-70 group-hover:opacity-60 transition-opacity","aria-hidden":"true"})}),(0,s.jsxs)("div",{className:"relative h-full flex flex-col items-center justify-center p-3 z-10",children:[!a&&r&&(0,s.jsx)("div",{className:"mb-2 flex items-center justify-center",children:(0,s.jsx)("span",{className:"text-2xl","aria-hidden":"true",children:r})}),(0,s.jsx)("h3",{className:"text-sm font-heading font-semibold text-primary text-center group-hover:text-primary transition-colors",children:t})]})]})}function u(e){let{locale:t}=e,r=(0,n.c)("wine"),a=(0,d.useRouter)(),[l,c]=(0,m.useState)(!1);(0,i.P)();let o=async()=>{c(!0);try{let e=(0,i.H)()||[];if(0===e.length)return void a.push(`/${t}/wine`);let r=Math.floor(Math.random()*e.length),s=e[r];a.push(`/${t}/wine/${s.slug}`)}catch(e){a.push(`/${t}/wine`)}finally{c(!1)}};return(0,s.jsx)("button",{onClick:o,disabled:l,className:"group relative block h-24 rounded-lg border-2 transition-all duration-300 hover:shadow-lg hover:-translate-y-1 border-primary hover:border-primary/80 bg-background-paper hover:bg-primary/5 disabled:opacity-50 disabled:cursor-not-allowed","aria-label":r("accessibility.surpriseMe"),children:(0,s.jsxs)("div",{className:"relative h-full flex flex-col items-center justify-center p-3 z-10",children:[(0,s.jsx)("div",{className:"mb-2 flex items-center justify-center",children:(0,s.jsx)("span",{className:"text-2xl","aria-hidden":"true",children:l?"â³":"â¨"})}),(0,s.jsx)("h3",{className:"text-sm font-heading font-semibold text-primary text-center group-hover:text-primary transition-colors",children:r(l?"explore.categories.loading":"explore.categories.surpriseMe")})]})})}function h(){let e=(0,n.c)("wine"),t=(0,d.useParams)().locale,[r,i]=(0,m.useState)([]),[l,c]=(0,m.useState)(!0),o=(0,m.useRef)(!1);(0,m.useEffect)(()=>{o.current||(o.current=!0,e());async function e(){try{i([])}catch(e){}finally{c(!1)}}},[]);let h={RED:"\uD83C\uDF77",WHITE:"\uD83E\uDD42",ROSE:"\uD83C\uDF39",SPARKLING:"\uD83C\uDF7E",DESSERT:"\uD83C\uDF6F",FORTIFIED:"\uD83D\uDEE1ï¸"};return(0,s.jsxs)("div",{className:"space-y-10",children:[(0,s.jsxs)("div",{className:"text-center",children:[(0,s.jsx)("h2",{className:"text-3xl lg:text-4xl font-heading font-bold text-primary mb-4",children:e("explore.title")}),(0,s.jsx)("p",{className:"text-lg text-secondary max-w-2xl mx-auto",children:e("explore.subtitle")})]}),(0,s.jsxs)("section",{children:[(0,s.jsxs)("div",{className:"mb-6",children:[(0,s.jsx)("h3",{className:"text-xl font-heading font-bold text-primary mb-2",children:e("explore.sectionTitles.wineTypes")}),(0,s.jsx)("p",{className:"text-sm text-secondary",children:e("explore.sectionSubtitles.wineTypes")})]}),(0,s.jsx)("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[{type:"RED"},{type:"WHITE"},{type:"ROSE"},{type:"SPARKLING"}].map(r=>{let{type:a}=r,i="RED"===a?"red-wines":"WHITE"===a?"white-wines":"ROSE"===a?"rose-wines":"SPARKLING"===a?"sparkling-wines":`${a.toLowerCase()}-wines`;return(0,s.jsx)(x,{title:e(`types.${a.toLowerCase()}`),icon:h[a],href:`/${t}/wine/browse/${i}`,color:"border-primary hover:border-primary/80 bg-surface hover:bg-primary/10"},a)})})]}),(0,s.jsxs)("section",{children:[(0,s.jsxs)("div",{className:"mb-6",children:[(0,s.jsx)("h3",{className:"text-xl font-heading font-bold text-primary mb-2",children:e("explore.sectionTitles.priceRanges")}),(0,s.jsx)("p",{className:"text-sm text-secondary",children:e("explore.sectionSubtitles.priceRanges")})]}),(0,s.jsx)("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-3",children:[{key:"under500",min:0,max:500,imageSrc:"/images/pricerange/optimized/1.webp"},{key:"500to1000",min:500,max:1e3,imageSrc:"/images/pricerange/optimized/2.webp"},{key:"1000to2000",min:1e3,max:2e3,imageSrc:"/images/pricerange/optimized/3.webp"},{key:"2000to3000",min:2e3,max:3e3,imageSrc:"/images/pricerange/optimized/4.webp"},{key:"3000to5000",min:3e3,max:5e3,imageSrc:"/images/pricerange/optimized/5.webp"},{key:"over5000",min:5e3,max:999999,imageSrc:"/images/pricerange/optimized/6.webp"}].map(r=>{let{key:a,min:i,max:n,imageSrc:l}=r,c=0===i&&500===n?"wines-under-500-baht":500===i&&1e3===n?"wines-500-to-1000-baht":1e3===i&&2e3===n?"wines-1000-to-2000-baht":2e3===i&&3e3===n?"wines-2000-to-3000-baht":3e3===i&&5e3===n?"wines-3000-to-5000-baht":5e3===i&&999999===n?"wines-over-5000-baht":`wines-${i}-to-${999999===n?"unlimited":n}-baht`;return(0,s.jsx)(x,{title:e(`priceRanges.${a}`),imageSrc:l,href:`/${t}/wine/browse/${c}`,color:"border-secondary hover:border-secondary/80 bg-surface hover:bg-secondary/10"},a)})})]}),(0,s.jsxs)("section",{children:[(0,s.jsxs)("div",{className:"mb-6",children:[(0,s.jsx)("h3",{className:"text-xl font-heading font-bold text-primary mb-2",children:e("explore.sectionTitles.specialSelections")}),(0,s.jsx)("p",{className:"text-sm text-secondary",children:e("explore.sectionSubtitles.specialSelections")})]}),(0,s.jsxs)("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3",children:[(0,s.jsx)(x,{title:e("explore.categories.organic"),icon:"\uD83C\uDF3F",href:`/${t}/wine/browse/wines-organic`,color:"border-accent hover:border-accent/80 bg-background-paper hover:bg-accent/5"}),(0,s.jsx)(x,{title:e("explore.categories.byTheGlass"),icon:"\uD83C\uDF77",href:`/${t}/wine/browse/wines-by-the-glass`,color:"border-secondary hover:border-secondary/80 bg-background-paper hover:bg-secondary/5"}),(0,s.jsx)(u,{locale:t})]})]}),(0,s.jsx)(a.FeaturedWineSelections,{locale:t}),!l&&r.length>0&&(0,s.jsxs)("section",{children:[(0,s.jsxs)("div",{className:"mb-6",children:[(0,s.jsx)("h3",{className:"text-xl font-heading font-bold text-primary mb-2",children:e("explore.sectionTitles.countries")}),(0,s.jsx)("p",{className:"text-sm text-secondary",children:e("explore.sectionSubtitles.countries")})]}),(0,s.jsx)("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3",children:r.map(e=>(0,s.jsx)(x,{title:"th"===t?e.name.th:e.name.en,icon:"\uD83C\uDF0D",href:`/${t}/wine/filter?countryIds=${e.id}`,color:"border-[#009246] hover:border-[#007236] bg-surface hover:bg-[#009246]/10"},e.id))})]})]})}},60279:(e,t,r)=>{r.d(t,{DualBarChart:()=>p});var s=r(95155),a=r(18955),i=r(20063),n=r(12115),l=r(26265),c=r(96324),o=r(68425),d=r(47734),m=r(73697),x=r(10232),u=r(86618);function h(e){let{active:t,payload:r,winesLabel:a,wineriesLabel:i}=e;return t&&r&&r.length?(0,s.jsxs)("div",{className:"bg-surface border border-border rounded-lg px-3 py-2 shadow-lg",children:[(0,s.jsx)("p",{className:"font-semibold text-primary mb-2",children:r[0].payload.country}),(0,s.jsxs)("p",{className:"text-sm text-secondary",children:[a,": ",r[0].value]}),(0,s.jsxs)("p",{className:"text-sm text-secondary",children:[i,": ",r[1]?.value??0]})]}):null}function p(e){let{locale:t,chartsData:r,countriesWithWines:p,statsLoading:g}=e,f=(0,a.c)("wine.stats.charts"),b=(0,i.useRouter)(),[y,j]=(0,n.use
21State)(""),v=(0,n.useMemo)(()=>{let e=new Map;if(p)for(let t of p)e.set(t.name_en,t.slug),t.name_th&&e.set(t.name_th,t.slug),t.name&&e.set(t.name,t.slug);return e},[p]),w=(0,n.useMemo)(()=>{if(!r)return[];let e=new Map;for(let s of r.winesByCountry){let r="th"===t?s.nameTh:s.nameEn,a=e.get(r)||{country:r,nameEn:s.nameEn,wines:0,wineries:0};a.wines=s.count,e.set(r,a)}for(let s of r.wineriesByCountry){let r="th"===t?s.nameTh:s.nameEn,a=e.get(r)||{country:r,nameEn:s.nameEn,wines:0,wineries:0};a.wineries=s.count,e.set(r,a)}return Array.from(e.values()).sort((e,t)=>t.wines-e.wines)},[r,t]),N=(0,n.useMemo)(()=>{let e=y.trim();return""===e||e.length<3?w:w.filter(t=>t.country.toLowerCase().includes(e.toLowerCase()))},[y,w]);return g?(0,s.jsx)("div",{className:"card p-6",children:(0,s.jsx)("div",{className:"flex items-center justify-center min-h-[400px]",children:(0,s.jsx)("div",{className:"animate-pulse text-4xl",children:"\uD83D\uDCCA"})})}):w.length?(0,s.jsxs)("div",{className:"card p-6",children:[(0,s.jsxs)("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-4 mb-6",children:[(0,s.jsx)("h3",{className:"text-xl font-semibold text-primary",children:f("winesAndWineriesByCountry")}),(0,s.jsx)("div",{className:"w-full md:w-80",children:(0,s.jsx)("input",{type:"text",value:y,onChange:e=>j(e.target.value),placeholder:f("searchPlaceholder"),className:"w-full px-4 py-2 border border-border rounded-lg bg-surface focus:outline-none focus:ring-2 focus:ring-primary text-primary","aria-label":f("searchPlaceholder")})})]}),(0,s.jsx)(l.u,{width:"100%",height:400,children:(0,s.jsxs)(c.E,{data:N,onClick:e=>{let r=e?.activePayload?.[0]?.payload?.nameEn;if(r){let e=v.get(r);e&&b.push(`/${t}/wine/browse/${e}-wines`)}},children:[(0,s.jsx)(o.d,{strokeDasharray:"3 3",stroke:"var(--color-border)"}),(0,s.jsx)(d.W,{dataKey:"country",angle:-45,textAnchor:"end",height:100,stroke:"var(--color-text-secondary)",style:{fontSize:"12px"}}),(0,s.jsx)(m.h,{stroke:"var(--color-text-secondary)",style:{fontSize:"12px"}}),(0,s.jsx)(x.m,{content:(0,s.jsx)(h,{winesLabel:f("wines"),wineriesLabel:f("wineries")})}),(0,s.jsx)(u.yP,{dataKey:"wines",fill:"#8B0000",name:f("wines"),className:"cursor-pointer hover:opacity-80 transition-opacity"}),(0,s.jsx)(u.yP,{dataKey:"wineries",fill:"#006400",name:f("wineries"),className:"cursor-pointer hover:opacity-80 transition-opacity"})]})}),N.length>0&&(0,s.jsxs)("div",{className:"mt-6 flex justify-center gap-8",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("div",{className:"w-4 h-4 rounded",style:{backgroundColor:"#8B0000"}}),(0,s.jsxs)("span",{className:"text-primary text-sm",children:[f("wines"),": (",N.reduce((e,t)=>e+t.wines,0),")"]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("div",{className:"w-4 h-4 rounded",style:{backgroundColor:"#006400"}}),(0,s.jsxs)("span",{className:"text-primary text-sm",children:[f("wineries"),": (",N.reduce((e,t)=>e+t.wineries,0),")"]})]})]}),0===N.length&&y&&(0,s.jsxs)("p",{className:"text-center text-secondary mt-4",children:['No countries found matching "',y,'"']})]}):(0,s.jsx)("div",{className:"card p-6 text-center",children:(0,s.jsx)("p",{className:"text-secondary",children:"No data available"})})}},62727:(e,t,r)=>{r.d(t,{WineTabs:()=>c});var s=r(95155),a=r(16001),i=r(18955),n=r(12115);let l=[{id:"search",icon:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"},{id:"explore",icon:"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"},{id:"catalogue",icon:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"}];function c(e){let{defaultTab:t="search",onTabChange:r,children:c}
21=e,o=(0,i.c)("wine.tabs"),[d,m]=(0,n.useState)(t);return(0,s.jsxs)("div",{className:"w-full",children:[(0,s.jsx)("div",{className:"relative",children:(0,s.jsx)("div",{className:"flex border-b-2 border-border",role:"tablist","aria-label":o("search")+" / "+o("explore")+" / "+o("catalogue"),children:l.map(e=>{let t=d===e.id;return(0,s.jsxs)("button",{role:"tab","aria-selected":t,"aria-controls":`${e.id}-panel`,id:`${e.id}-tab`,onClick:()=>{var t;m(t=e.id),r?.(t)},className:` 22 relative flex-1 flex items-center justify-center gap-2 23 px-2 py-4 md:px-6 md:py-5 24 font-bold text-sm md:text-base 25 transition-all duration-300 26 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset 27 ${t?"text-primary-foreground bg-primary hover:bg-primary-hover border-2 border-primary border-b-0 rounded-t-lg":"text-muted hover:text-primary hover:bg-surface-hover"} 28 `,children:[(0,s.jsx)("svg",{className:`w-5 h-5 md:w-6 md:h-6 flex-shrink-0 transition-transform duration-300 ${t?"scale-110":""}`,fill:"none",stroke:"currentColor",strokeWidth:t?2.5:2,viewBox:"0 0 24 24","aria-hidden":"true",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:e.icon})}),(0,s.jsx)("span",{className:"hidden sm:inline",children:o(e.id)}),(0,s.jsx)("span",{className:"sm:hidden text-xs font-semibold",children:o(e.id)}),t&&(0,s.jsx)(a.P.div,{layoutId:"activeTabIndicator",className:"absolute bottom-0 left-0 right-0 h-1 bg-gradient-to-r from-primary via-primary to-accent rounded-t-full",initial:!1,transition:{type:"spring",stiffness:500,damping:35}})]},e.id)})})}),(0,s.jsx)("div",{className:"pt-6 md:pt-8",children:l.map(e=>(0,s.jsx)("div",{role:"tabpanel",id:`${e.id}-panel`,"aria-labelledby":`${e.id}-tab`,hidden:d!==e.id,className:d===e.id?"block":"hidden",children:c[e.id]},e.id))})]})}},72772:(e,t,r)=>{function s(e){return e.toLowerCase().trim().replace(/\s+/g,"-").replace(/[^a-z0-9\u0E00-\u0E7F-]/g,"").replace(/-+/g,"-").replace(/^-|-$/g,"").substring(0,60)}function a(e){return e.replace(/-/g," ").trim()}function i(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"en",r=s(e);return{slug:r,query:e,title:{en:`"${e}" Wine Search | Why Not? Italian Restaurant`,th:`à¸à¹à¸à¸«à¸² "${e}" | Why Not? Italian Restaurant`},description:{en:`Find wines matching "${e}" at Why Not? Italian Restaurant in Chiang Mai. Browse our curated collection of Italian and international wines.`,th:`à¸à¹à¸à¸«à¸²à¹à¸§à¸à¹à¸à¸µà¹à¸à¸£à¸à¸à¸±à¸ "${e}" à¸à¸µà¹ Why Not? Italian Restaurant à¹à¸à¹à¸à¸µà¸¢à¸à¹à¸«à¸¡à¹ à¹à¸£à¸µà¸¢à¸à¸à¸¹à¸à¸à¸¥à¹à¸¥à¸à¸à¸±à¸à¹à¸§à¸à¹à¸à¸´à¸à¸²à¹à¸¥à¸µà¸¢à¸à¹à¸¥à¸°à¸à¸²à¸à¸²à¸à¸²à¸à¸´à¸à¸µà¹à¸à¸±à¸à¸ªà¸£à¸£`},canonical:`/${t}/wine/search/${r}`}}function n(e){let t=e.trim();return!(t.length<2||/^[\d\s\-_.,!@#$%^&*()]+$/.test(t))&&!!/[a-zA-Z\u0E00-\u0E7F]/.test(t)}function l(){return["red wine","white wine","ros\xe9 wine","sparkling wine","chianti","chianti classico","barolo","brunello","pinot grigio","sangiovese","nebbiolo","prosecco","lambrusco","tuscany","piedmont","veneto","sicily","italian wine","organic wine","biodynamic wine","natural wine","vintage wine","affordable wine","premium wine","luxury wine","wine for pasta","wine for pizza","wine for cheese","wine for meat","à¹à¸§à¸à¹à¹à¸à¸","à¹à¸§à¸à¹à¸à¸²à¸§","à¹à¸§à¸à¹à¸à¸´à¸à¸²à¹à¸¥à¸µà¸¢à¸","à¹à¸§à¸à¹à¸à¸à¸£à¹à¹à¸à¸à¸´à¸"]}function c(){let e=[];return l().forEach(t=>{["en","th"].forEach(r=>{n(t)&&e.push(i(t,r))})}),e}r.r(t),r.d(t,{generateSearchSlug:()=>s,generateSearchUrlInfo:()=>i,getAllSearchUrlCombinations:()=>c,getCommonSearchTerms:()=>l,parseSearchSlug:()=>a,shouldCreateSeoUrl:()=>n})},74967:(e,t,r)=>{r.d(t,{WineSearchResults:()=>x});var s=r(95155),a=r(96547),i=r(96216),n=r(18955),l=r(15239),c=r(52619),o=r.n(c),d=r(20063),m=r(12115);function x(e){let{query:t,page:c,locale:x,seoFriendly:u=!1,searchTerm:h}=e,p=(0,n.c)("wine"),g=(0,n.c)("common.nav"),f=(0,d.useRouter)(),[b,y]=(0,m.useState)([]),[j,v]=(0,m.useState)(0),[w,N]=(0,m.useState)(!0),[k,C]=(0,m.useState)(null);(0,m.useEffect)(()=>{!async function(){N(!0),C(null);try{let e=await fetch(`/api/wine/search?q=${encodeURIComponent(t)}&page=${c}&pageSize=20`);if(!e.ok)throw Error("Failed to fetch search results");let r=await e.json();y(r.items||[]),v(r.total||0),t.trim().length>=2&&fetch("/api/sitemap/search",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:t.trim(),locale:x})}).catch(()=>{})}catch(e){C(p("search.error")||"Failed to load search results")}finally{N(!1)}}()},[t,c,x,p]);let S=e=>{u&&h?f.push(`/${x}/wine/search/${h}?page=${e}`):f.push(`/${x}/wine/search?q=${encodeURIComponent(t)}&page=${e}`)},D=Math.ceil(j/20);return(0,s.jsxs)("div",{className:"min-h-screen bg-background relative overflow-hidden",children:[(0,s.jsx)("div",{className:"absolute top-1/4 -right-24 md:-right-32 xl:-right-40 w-[260px] md:w-[380px] xl:w-[520px] h-[260px] md:h-[380px] xl:h-[520px] opacity-55 dark:opacity-35 rotate-12 pointer-events-none hidden md:block z-0",children:(0,s.jsx)(l.default,{src:"/images/photo elements/Best Pasta Chiang Mai 3 top view anywhere.png",alt:"",fill:!0,sizes:"(max-width: 768px) 260px, (max-width: 1280px) 380px, 520px",className:"object-contain","aria-hidden":"true"})}),(0,s.jsx)("div",{className:"absolute top-1/2 -left-24 md:-left-32 xl:-left-40 w-[260px] md:w-[360px] xl:w-[480px] h-[260px] md:h-[360px] xl:h-[480px] opacity-55 dark:opacity-35 -rotate-12 pointer-events-none hidden md:block z-0",children:(0,s.jsx)(l.default,{src:"/images/photo elements/Best Pizza Chiang Mai 4 top view anywhere.png",alt:"",fill:!0,sizes:"(max-width: 768px) 260px, (max-width: 1280px) 360px, 480px",className:"object-contain","aria-hidden":"true"})}),(0,s.jsx)("div",{className:"bg-background-paper border-b border-border relative z-10",children:(0,s.jsx)("div",{className:"container mx-auto px-4 py-8",children:(0,s.jsxs)("div",{className:" mx-auto",children:[(0,s.jsx)("nav",{className:"mb-6","aria-label":p("accessibility.breadcrumb"),children:(0,s.jsxs)("ol",{className:"flex items-center space-x-2 text-sm text-muted",children:[(0,s.jsx)("li",{children:(0,s.jsx)(o(),{href:`/${x}`,className:"hover:text-primary transition-colors",children:g("home")})}),(0,s.jsxs)("li",{className:"flex items-center",children:[(0,s.jsx)("svg",{className:"w-4 h-4 mx-2",fill:"
28currentColor",viewBox:"0 0 20 20",children:(0,s.jsx)("path",{fillRule:"evenodd",d:"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z",clipRule:"evenodd"})}),(0,s.jsx)(o(),{href:`/${x}/wine`,className:"hover:text-primary transition-colors",children:p("title")})]}),(0,s.jsxs)("li",{className:"flex items-center",children:[(0,s.jsx)("svg",{className:"w-4 h-4 mx-2",fill:"currentColor",viewBox:"0 0 20 20",children:(0,s.jsx)("path",{fillRule:"evenodd",d:"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z",clipRule:"evenodd"})}),(0,s.jsx)("span",{className:"text-primary font-medium",children:p("search.results")})]})]})}),(0,s.jsx)("h1",{className:"text-3xl lg:text-4xl font-heading font-bold text-primary mb-4",children:p("search.resultsFor",{query:t})}),(0,s.jsx)("div",{className:"max-w-2xl",children:(0,s.jsx)(i.WineSearch,{onSearch:e=>{let{generateSearchSlug:t,shouldCreateSeoUrl:s}=r(72772);if(s(e)){let r=t(e);f.push(`/${x}/wine/search/${r}`)}else f.push(`/${x}/wine/search?q=${encodeURIComponent(e)}`)},locale:x,placeholder:p("search.placeholder")})})]})})}),(0,s.jsx)("div",{className:"container mx-auto px-4 py-8 relative z-10",children:(0,s.jsxs)("div",{className:"mx-auto",children:[(0,s.jsx)("div",{className:"mb-6",children:w?(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"animate-spin rounded-full h-5 w-5 border-2 border-primary/20 border-t-primary"}),(0,s.jsx)("span",{className:"text-secondary",children:p("search.loading")})]}):k?(0,s.jsx)("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4",children:(0,s.jsxs)("div",{className:"flex items-center gap-3 text-red-800 dark:text-red-200",children:[(0,s.jsx)("svg",{className:"w-5 h-5 flex-shrink-0",fill:"currentColor",viewBox:"0 0 20 20",children:(0,s.jsx)("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})}),(0,s.jsx)("span",{children:k})]})}):(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("p",{className:"text-secondary",children:0===j?p("search.noResults"):p("search.resultsCount",{count:j,query:t})}),j>0&&D>1&&(0,s.jsx)("p",{className:"text-sm text-muted",children:p("search.pageInfo",{current:c,total:D})})]})}),!w&&!k&&b.length>0&&(0,s.jsx)(a.WineGrid,{wines:b,locale:x,enablePagination:!1}),!w&&!k&&0===b.length&&(0,s.jsx)("div",{className:"text-center py-16",children:(0,s.jsxs)("div",{className:"max-w-md mx-auto",children:[(0,s.jsx)("div",{className:"text-6xl mb-4",children:"\uD83D\uDD0D"}),(0,s.jsx)("h3",{className:"text-xl font-heading font-bold text-primary mb-2",children:p("search.noResults")}),(0,s.jsx)("p",{className:"text-secondary mb-6",children:p("search.noResultsDescription",{query:t})}),(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("p",{className:"text-sm text-muted",children:[p("search.suggestions"),":"]}),(0,s.jsxs)("ul",{className:"text-sm text-muted space-y-1",children:[(0,s.jsxs)("li",{children:["⢠",p("search.suggestion1")]}),(0,s.jsxs)("li",{children:["⢠",p("search.suggestion2")]}),(0,s.jsxs)("li",{children:["⢠",p("search.suggestion3")]})]}),(0,s.jsx)("div",{className:"pt-4",children:(0,s.jsx)(o(),{href:`/${x}/wine`,className:"inline-flex items-center px-6 py-3 bg-primary text-primary-foreground rounded-lg font-semibold hover:bg-primary/90 transition-colors",children:p("search.browseAll")})})]})]})}),!w&&!k&&b.length>0&&D>1&&(0,s.jsx)("div",{className:"mt-12 flex justify-center",children:(0,s.jsxs)("nav",{className:"flex items-center space-x-2","aria-label":p("accessibility.pagination"),children:[c>1&&(0,s.jsx)("button",{onClick:()=>S(c-1),className:"px-4 py-2 text-sm font-medium text-primary bg-background-paper border border-border rounded-lg hover:bg-background-elevated transition-colors","aria-label":p("search.previousPage"),children:p("search.previous")}),Array.from({length:Math.min(5,D)},(e,t)=>{let r=Math.max(1,Math.min(D-4,c-2))+t;return r>D?null:(0,s.jsx)("button",{onClick:()=>S(r),className:`px-4 py-2 text-sm font-medium rounded-lg transition-colors ${r===c?"bg-primary text-primary-foreground":"text-primary bg-background-paper border border-border hover:bg-background-elevated"}`,"aria-label":p("search.goToPage",{page:r}),"aria-current":r===c?"page":void 0,children:r},r)}),c<D&&(0,s.jsx)("button",{onClick:()=>S(c+1),className:"px-4 py-2 text-sm font-medium text-primary bg-background-paper border border-border rounded-lg hover:bg-background-elevated transition-colors","aria-label":p("search.nextPage"),children:p("search.next")})]})})]})})]})}},80834:(e,t,r)=>{r.d(t,{CountryOfTheDayCard:()=>o});var s=r(95155),a=r(18955),i=r(15239),n=r(52619),l=r.n(n),c=r(12115);function o(e){let{locale:t,countriesWithWines:r,statsLoading:n}=e,o=(0,a.c)("wine.stats.countryOfTheDay"),[d]=(0,c.useState)(()=>Math.floor(Date.now()/864e5)),m=(0,c.useMemo)(()=>r&&0!==r.length?r[d%r.length]:null,[r,d]),x=(0,c.useMemo)(()=>m?.facts&&0!==m.facts.length?m.facts[d%m.facts.length]:null,[m,d]),u=!!r;if(n||!u)return(0,s.jsx)("div",{className:"card h-full flex items-center justify-center min-h-[300px]",children:(0,s.jsxs)("div",{className:"flex flex-col items-center gap-4",children:[(0,s.jsx)("div",{className:"animate-spin text-4xl",children:"\uD83C\uDF0D"}),(0,s.jsx)("p",{className:"text-sm text-secondary",children:o("loading")})]})});if(!m)return(0,s.jsx)("div",{className:"card h-full flex items-center justify-center min-h-[300px]",children:(0,s.jsxs)("div",{className:"flex flex-col items-center gap-4 text-center",children:[(0,s.jsx)("div",{className:"text-4xl",children:"\uD83C\uDF0D"}),(0,s.jsx)("p",{className:"text-sm text-secondary",children:o("error")})]})});let h="th"===t?m.name_th:m.name_en,p=x&&("th"===t?x.fact_th:x.fact_en);return(0,s.jsxs)("div",{className:"card h-full flex flex-col min-h-[300px]","data-egg":"wine-country-day","data-egg-mode":"click",children:[(0,s.jsxs)("div",{className:"mb-4",children:[(0,s.jsx)("h3",{className:"text-xl font-heading font-bold text-primary mb-1",children:o("title")}),(0,s.jsx)("p",{className:"text-sm text-secondary",children:o("subtitle")})]}),(0,s.jsxs)("div",{className:"flex items-center gap-4 mb-4",children:[m.flag_url?(0,s.jsx)("div",{className:"relative w-24 h-16 flex-shrink-0 flex items-center justify-center",children:(0,s.jsx)(i.default,{src:m.flag_url,alt:`${h} flag`,fill:!0,className:"object-contain",sizes:"96px"})}):(0,s.jsx)("div",{className:"w-24 h-16 rounded-md bg-background-elevated flex items-center justify-center text-3xl",children:"\uD83C\uDFF3ï¸"}),(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("h4",{className:"text-lg font-heading font-bold text-primary",children:h}),(0,s.jsx)("p",{className:"text-sm text-secondary",children:o("wineCount",{count:m.wineCount})})]})]}),p&&(0,s.jsx)("div",{className:"flex-1 mb-4 flex flex-col justify-end rounded-lg",children:(0,s.jsx)("p",{className:"text-sm text-primary leading-relaxed",children:p})}),(0,s.jsx)("div",{className:"mt-auto pt-4 border-t border-border",children:(0,s.jsx)(l(),{href:`/${t}/wine/browse/${m.slug}-wines`,className:"btn-primary w-full text-center block",children:o("exploreCountry")})})]})}},85464:(e,t,r)=>{r.d(t,{GrapeVarietyCharts:()=>o});var s=r(95155),a=r(18955),i=r(20063),n=r(12115),l=r(15908);let c=["#8B0000","#006400","#FFD700","#4169E1","#FF6347","#9370DB","#20B2AA","#FF8C00","#DC143C","#32CD32","#4682B4","#FF69B4","#8B4513","#2E8B57","#DAA520","#B8860B","#CD5C5C","#4682B4","#D2691E","#FF7F50"];function o(e){let{locale:t,grapeData:r,statsLoading:o}=e,d=(0,a.c)("wine.stats.charts"),m=(0,i.useRouter)(),[x,u]=(0,n.use
28State)(""),{topGrapes:h,uniqueGrapes:p}=(0,n.useMemo)(()=>{if(!r)return{topGrapes:[],uniqueGrapes:[]};let e=[],t=[];return r.forEach((r,s)=>{let a=c[s%c.length],i={name:r.name,value:r.count,color:a};r.count>=10?e.push(i):t.push(i)}),{topGrapes:e,uniqueGrapes:t}},[r]),g=(0,n.useMemo)(()=>{if(""===x.trim())return h;let e=x.toLowerCase();return h.filter(t=>t.name.toLowerCase().includes(e))},[x,h]),f=(0,n.useMemo)(()=>{if(""===x.trim())return p;let e=x.toLowerCase();return p.filter(t=>t.name.toLowerCase().includes(e))},[x,p]),b=e=>{let r=e.name.toLowerCase().trim().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"").replace(/-+/g,"-").replace(/^-|-$/g,"");r&&m.push(`/${t}/wine/browse/grape-${r}`)};return o?(0,s.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[1,2].map(e=>(0,s.jsx)("div",{className:"card h-full flex items-center justify-center min-h-[400px]",children:(0,s.jsx)("div",{className:"animate-pulse text-4xl",children:"\uD83D\uDCCA"})},e))}):r?(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsxs)("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-4",children:[(0,s.jsx)("h3",{className:"font-heading font-bold text-primary",children:d("grapeVarieties")}),(0,s.jsx)("div",{className:"w-full md:w-96",children:(0,s.jsx)("input",{type:"text",value:x,onChange:e=>u(e.target.value),placeholder:d("searchPlaceholder"),className:"w-full px-4 py-2 border border-border rounded-lg bg-surface focus:outline-none focus:ring-2 focus:ring-primary text-primary","aria-label":d("searchPlaceholder")})})]}),(0,s.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[g.length>0&&(0,s.jsx)(l.DonutChart,{data:g,title:d("topGrapes"),centerLabel:d("wines"),showLegend:!1,onSegmentClick:b}),f.length>0&&(0,s.jsx)(l.DonutChart,{data:f,title:d("uniqueGrapes"),centerLabel:d("wines"),showLegend:!1,onSegmentClick:b})]}),x&&0===g.length&&0===f.length&&(0,s.jsx)("div",{className:"card p-6 text-center",children:(0,s.jsxs)("p",{className:"text-secondary",children:['No grape varieties found matching "',x,'"']})})]}):(0,s.jsx)("div",{className:"card p-6 text-center",children:(0,s.jsx)("p",{className:"text-secondary",children:"Failed to load grape data"})})}},88968:(e,t,r)=>{r.d(t,{WineCharts:()=>u});var s=r(95155),a=r(18955),i=r(20063),n=r(12115),l=r(15908);let c={RED:"red-wines",WHITE:"white-wines",ROSE:"rose-wines",SPARKLING:"sparkling-wines",DESSERT:"dessert-wines",FORTIFIED:"fortified-wines"},o={RED:"#8B0000",WHITE:"#DAA520",ROSE:"#FFB6C1",SPARKLING:"#FFD700",DESSERT:"#DDA0DD",FORTIFIED:"#CD853F"},d=["#8B0000","#006400","#FFD700","#4169E1","#FF6347","#9370DB","#20B2AA","#FF8C00","#DC143C","#32CD32","#4682B4","#FF69B4","#8B4513"],m=["#22C55E","#84CC16","#EAB308","#F97316","#EF4444","#DC2626"],x=[{key:"under500",min:0,max:500,browseSlug:"wines-under-500-baht"},{key:"500to1000",min:500,max:1e3,browseSlug:"wines-500-to-1000-baht"},{key:"1000to2000",min:1e3,max:2e3,browseSlug:"wines-1000-to-2000-baht"},{key:"2000to3000",min:2e3,max:3e3,browseSlug:"wines-2000-to-3000-baht"},{key:"3000to5000",min:3e3,max:5e3,browseSlug:"wines-3000-to-5000-baht"},{key:"over5000",min:5e3,max:1/0,browseSlug:"wines-over-5000-baht"}];function u(e){let{locale:t,chartsData:r,countriesWithWines:u,statsLoading:h}=e,p=(0,a.c)("wine"),g=(0,i.useRouter)(),f=(0,n.useMemo)(()=>{let e=new Map;if(u)for(let t of u)e.set(t.name_en,t.slug),t.name_th&&e.set(t.name_th,t.slug),t.name&&e.set(t.name,t.slug);return e},[u]),b=(0,n.useMemo)(()=>{let e=new Map;if(r)for(let t of Object.keys(r.wineTypeCount)){let r=o[t]||"#999999";e.set(r,t)}return e},[r]),y=(0,n.useMemo)(()=>{let e=new Map;return r&&r.winesByCountry.forEach((t,r)=>{e.set(d[r%d.length],t.nameEn)}),e},[r]),j=(0,n.useMemo)(()=>{let e=new Map;return r&&r.wineriesByCountry.forEach((t,r)=>{e.set(d[r%d.length],t.nameEn)}),e},[r]),v=(0,n.useMemo)(()=>{if(!r)return null;let e=Object.entries(r.wineTypeCount).map(e=>{let[t,r]=e;return{name:p(`types.${t.toLowerCase()}`),value:r,color:o[t]||"#999999"}}),s=r.winesByCountry.map((e,r)=>({name:"th"===t?e.nameTh:e.nameEn,value:e.count,color:d[r%d.length]}));return{winesByType:e,winesByCountry:s,winesByPrice:x.map((e,t)=>({name:p(`priceRanges.${e.key}`),value:r.priceData.filter(t=>t>=e.min&&t<e.max).length,color:m[t]}
28)).filter(e=>e.value>0),wineriesByCountry:r.wineriesByCountry.map((e,r)=>({name:"th"===t?e.nameTh:e.nameEn,value:e.count,color:d[r%d.length]}))}},[r,t,p]);return h?(0,s.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[1,2,3,4].map(e=>(0,s.jsx)("div",{className:"card h-full flex items-center justify-center min-h-[400px]",children:(0,s.jsx)("div",{className:"animate-pulse text-4xl",children:"\uD83D\uDCCA"})},e))}):v?(0,s.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6","data-egg":"wine-chart-hover","data-egg-mode":"hover",children:[(0,s.jsx)(l.DonutChart,{data:v.winesByType,title:p("stats.charts.winesByType"),centerLabel:p("stats.charts.wines"),onSegmentClick:e=>{let r=b.get(e.color);if(r){let e=c[r];e&&g.push(`/${t}/wine/browse/${e}`)}}}),(0,s.jsx)(l.DonutChart,{data:v.winesByCountry,title:p("stats.charts.winesByCountry"),centerLabel:p("stats.charts.wines"),onSegmentClick:e=>{let r=y.get(e.color);if(r){let e=f.get(r);e&&g.push(`/${t}/wine/browse/${e}-wines`)}}}),(0,s.jsx)(l.DonutChart,{data:v.winesByPrice,title:p("stats.charts.winesByPrice"),centerLabel:p("stats.charts.wines"),onSegmentClick:e=>{let r=m.indexOf(e.color);if(r>=0&&r<x.length){let e=x[r];g.push(`/${t}/wine/browse/${e.browseSlug}`)}}}),(0,s.jsx)(l.DonutChart,{data:v.wineriesByCountry,title:p("stats.charts.wineriesByCountry"),centerLabel:p("stats.charts.wineries"),onSegmentClick:e=>{let r=j.get(e.color);if(r){let e=f.get(r);e&&g.push(`/${t}/wine/browse/${e}-wines`)}}})]}):(0,s.jsx)("div",{className:"card p-6 text-center",children:(0,s.jsx)("p",{className:"text-secondary",children:"Unable to load charts"})})}},96204:(e,t,r)=>{r.d(t,{H:()=>c,P:()=>o});var s=r(12115);let a=null,i=0,n=null;async function l(e){let t=e||"";if(!t&&a&&Date.now()-i<36e5)return a;if(!t&&n)return n;let r=fetch(e?`/api/wine?${e}`:"/api/wine").then(e=>{if(!e.ok)throw Error(`Wine API error: ${e.status}`);return e.json()}).then(e=>{let r=e.items||[];return t||(a=r,i=Date.now(),n=null),r}).catch(e=>{throw t||(n=null),e});return t||(n=r),r}function c(){return a&&Date.now()-i<36e5?a:null}function o(e){let[t,r]=(0,s.useState)(!e&&c()||[]),[n,o]=(0,s.useState)(!!e||!c()),[d,m]=(0,s.useState)(null),x=(0,s.useRef)(!1),u=(0,s.useCallback)(async()=>{try{o(!0);let t=await l(e);r(t),m(null)}catch(e){m("Failed to load wines")}finally{o(!1)}},[e]);return(0,s.useEffect)(()=>{if(!x.current){if(x.current=!0,!e&&a&&Date.now()-i<36e5){r(a),o(!1);return}u()}},[u,e]),{wines:t,loading:n,error:d}}},96216:(e,t,r)=>{r.d(t,{WineSearch:()=>d});var s=r(95155),a=r(69276),i=r(12115),n=r(83650),l=r(18955),c=r(15239);let o="wine-search-history";function d(e){let{onSearch:t,onSelect:r,placeholder:d,showHistory:m=!0,locale:x="en"}=e,u=(0,l.c)("wine"),{discover:h}=(0,n.g)(),[p,g]=(0,i.useState)(""),[f,b]=(0,i.useState)([]),[y,j]=(0,i.useState)([]),[v,w]=(0,i.useState)(!1),[N,k]=(0,i.useState)(!1),[C,S]=(0,i.useState)(-1),[D,$]=(0,i.useState)(!1),I=(0,i.useRef)(null),E=(0,i.useRef)(null),{debouncedValue:F,isWaiting:R,getAbortSignal:M}=function(e,t){let r=t?.minChars??3,s=t?.delay??300,[a,n]=(0,i.useState)(""),[l,c]=(0,i.useState)(!1),o=(0,i.useRef)(null),d=(0,i.useRef)(null);(0,i.useEffect)(()=>{d.current&&(clearTimeout(d.current),d.current=null);let t=e.trim();if(0===t.length||t.length>0&&t.length<r)return d.current=setTimeout(()=>{n(""),c(!1)},0),()=>{d.current&&clearTimeout(d.current)};d.current=setTimeout(()=>{n(t),c(!1)},s);let a=setTimeout(()=>c(!0),0);return()=>{d.current&&clearTimeout(d.current),clearTimeout(a)}},[e,r,s]);let m=(0,i.useCallback)(()=>{o.current&&o.current.abort();let e=new AbortController;return o.current=e,e.signal},[]);return(0,i.useEffect)(()=>()=>{o.current&&o.current.abort()},[]),{debouncedValue:a,isWaiting:l,getAbortSignal:m}}(p,{minChars:3,delay:300});(0,i.useEffect)(()=>{$(!0)},[]),(0,i.useEffect)(()=>{if(m&&1){let e=localStorage.getItem(o);if(e)try{j(JSON.parse(e))}catch(e){}}},[m]);let L=(0,i.useCallback)(e=>{if(!m||!e.trim())return;let t=[e,...y.filter(t=>t!==e)].slice(0,5);j(t),localStorage.setItem(o,JSON.stringify(t))},[y,m]),T=(0,i.useCallback)(async(e,t)=>{if(!e.trim())return void b([]);w(!0);try{let r=await fetch(`/api/wine/search?q=${encodeURIComponent(e)}&limit=5`,{signal:t});if(r.ok){let e=await r.json();b(e.items||[])}}catch(e){if(e instanceof DOMException&&"AbortError"===e.name)return;b([])}finally{w(!1)}},[]);(0,i.useEffect)(()=>{F?T(F,M()):b([])},[F,T,M]),(0,i.useEffect)(()=>{let e=e=>{I.current&&!I.current.contains(e.target)&&k(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);let P=e=>{if(e.trim())if(e.toLowerCase().includes("chianti")&&h("wine-search-chianti"),L(e),k(!1),t)t(e);else{let t=e.toLowerCase().trim().replace(/\s+/g,"-").replace(/[^a-z0-9\u0E00-\u0E7F-]/g,"").replace(/-+/g,"-").replace(/^-|-$/g,"");window.location.href=`/${x}/wine/browse/search-${t}`}},W=e=>{g(""),k(!1),b([]),r?r(e):window.location.href=`/${x}/wine/${e.slug}`},B=D&&m&&y.length>0&&!p.trim(),A=f.length>0&&p.trim().length>=3;return(0,s.jsxs)("div",{ref:I,className:"relative w-full",children:[(0,s.jsxs)("form",{onSubmit:e=>{e.preventDefault(),C>=0&&f[C]?W(f[C]):P(p)},className:"relative",suppressHydrationWarning:!0,children:[(0,s.jsx)("input",{ref:E,type:"text",value:p,onChange:e=>{g(e.target.value),k(!0),S(-1)},onFocus:()=>k(!0),onKeyDown:e=>{if(!N)return;let t=f.length+(m&&y.length>0?y.length:0);switch(e.key){case"ArrowDown":e.preventDefault(),S(e=>e<t-1?e+1:e);break;case"ArrowUp":e.preventDefault(),S(e=>e>0?e-1:-1);break;case"Escape":k(!1),S(-1)}},placeholder:d||u("search.placeholder"),className:"w-full rounded-lg border border-border bg-background-paper text-primary placeholder:text-muted px-4 py-3 pr-12 focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/20 transition-colors","aria-label":u("search.placeholder"),"aria-autocomplete":"list","aria-controls":"wine-search-suggestions",role:"combobox","aria-expanded":!!(D&&N&&(B||A)),suppressHydrationWarning:!0}),(0,s.jsx)("button",{type:"submit",className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted hover:text-primary transition-colors","aria-label":u("actions.search"),suppressHydrationWarning:!0,children:(0,s.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})})]}),D&&N&&(B||A||v||R)&&(0,s.jsxs)("div",{id:"wine-search-suggestions",className:"absolute z-50 mt-2 w-full rounded-lg border border-border bg-background-paper shadow-xl ring-1 ring-border/50 backdrop-blur-md",role:"listbox",suppressHydrationWarning:!0,children:[v&&(0,s.jsx)("div",{className:"px-4 py-3 text-sm text-muted",children:u("search.loading")}),B&&!v&&(0,s.jsxs)("div",{className:"border-b border-border",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-4 py-2",children:[(0,s.jsx)("span",{className:"text-xs font-medium text-muted",children:u("search.recentSearches")}),(0,s.jsx)("button",{onClick:()=>{j([]),localStorage.removeItem(o)},className:"text-xs text-primary hover:underline","aria-label":u("search.clearHistory"),children:u("search.clear")})]}),y.map((e,t)=>(0,s.jsx)("button",{onClick:()=>{g(e),E.current?.focus(),P(e)},className:`w-full px-4 py-2 text-left text-sm hover:bg-background-elevated transition-colors ${C===t?"bg-background-elevated":""}`,role:"option","aria-selected":C===t,children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 text-muted",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,s.jsx)("span",{children:e})]})},`history-${t}`))]}),A&&!v&&(0,s.jsx)("div",{children:f.map((e,t)=>{let r=B?t+y.length:t;return(0,s.jsx)("button",{onClick:()=>W(e),className:`w-full px-4 py-3 text-left hover:bg-background-elevated transition-colors ${C===r?"bg-background-elevated":""}`,role:"option","aria-selected":C===r,children:(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[e.image&&(0,s.jsx)("div",{className:"relative h-12 w-9 rounded overflow-hidden flex-shrink-0 bg-background-elevated",children:(0,s.jsx)(c.default,{src:e.image.url,alt:"",fill:!0,className:"object-contain",sizes:"36px","aria-hidden":"true"})}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("div",{className:"font-medium text-primary truncate",children:e.name}),(0,s.jsxs)("div",{className:"text-xs text-muted truncate",children:[e.winery?.name," â¢"," ",e.vintage||u("item.noVintage")]})]}),(0,s.jsxs)("div",{className:"text-sm font-medium text-primary whitespace-nowrap flex items-center gap-1",children:["฿",e.dineInPrice?.toLocaleStr
28ing()||"0",(0,s.jsx)(a.Q,{iconSize:"sm"})]})]})},e.id)})}),!v&&!R&&p.trim().length>=3&&0===f.length&&(0,s.jsx)("div",{className:"px-4 py-3 text-sm text-muted",children:u("search.noResults")})]})]})}},96547:(e,t,r)=>{r.d(t,{WineGrid:()=>c});var s=r(95155),a=r(18955),i=r(20063),n=r(12115),l=r(96933);function c(e){let{wines:t,locale:r,itemsPerPage:c=12,enablePagination:o=!0,onPageChange:d}=e,m=(0,a.c)("wine"),x=(0,i.useRouter)(),u=(0,i.usePathname)(),h=(0,i.useSearchParams)(),p=o?Math.max(1,parseInt(h.get("page")||"1",10)):1,g=Math.ceil(t.length/c),f=Math.min(p,Math.max(1,g)),b=(f-1)*c,y=b+c,j=(0,n.useMemo)(()=>o?t.slice(b,y):t,[t,o,b,y]),v=(0,n.useCallback)(e=>{let t=new URLSearchParams(h.toString());e<=1?t.delete("page"):t.set("page",e.toString());let r=t.toString();x.push(r?`${u}?${r}`:u,{scroll:!1}),d?.(e),window.scrollTo({top:0,behavior:"smooth"})},[x,u,h,d]),w=(0,n.useCallback)(()=>{let e=[];if(g<=5)for(let t=1;t<=g;t++)e.push(t);else{e.push(1);let t=Math.max(2,f-1),r=Math.min(g-1,f+1);f<=2&&(r=4),f>=g-1&&(t=g-3),t>2&&e.push("...");for(let s=t;s<=r;s++)e.push(s);r<g-1&&e.push("..."),e.push(g)}return e},[f,g]),N=(0,n.useMemo)(()=>w(),[w]);return 0===t.length?(0,s.jsxs)("div",{className:"text-center py-12",children:[(0,s.jsx)("p",{className:"text-xl text-primary mb-2",children:m("search.noResults")}),(0,s.jsx)("p",{className:"text-sm text-muted",children:m("search.tryDifferent")})]}):(0,s.jsxs)("div",{className:"space-y-8",children:[(0,s.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:j.map(e=>(0,s.jsx)(l.WineCard,{wine:e,locale:r},e.id))}),o&&g>1&&(0,s.jsxs)("div",{className:"flex flex-col items-center gap-6 pt-8 border-t border-border",children:[(0,s.jsxs)("div",{className:"text-center text-sm text-secondary",children:[(0,s.jsx)("p",{children:m("filter.showingResults",{current:j.length,count:t.length})}),(0,s.jsx)("p",{className:"text-xs text-muted mt-1",children:m("catalogue.pageNavigation.pageOf",{current:f,total:g})})]}),(0,s.jsxs)("div",{className:"flex flex-wrap justify-center gap-2",children:[(0,s.jsx)("button",{onClick:()=>{f>1&&v(f-1)},disabled:1===f,"aria-label":m("catalogue.pageNavigation.previousPage"),className:"px-4 py-2 rounded-lg border border-border text-primary hover:bg-background-elevated disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"â"}),N.map((e,t)=>(0,s.jsx)("div",{children:"..."===e?(0,s.jsx)("span",{className:"px-2 py-2 text-muted",children:"â¦"}):(0,s.jsx)("button",{onClick:()=>{v(e)},"aria-label":m("catalogue.pageNavigation.goToPage",{page:e}),"aria-current":f===e?"page":void 0,className:`px-3 py-2 rounded-lg border transition-colors ${f===e?"bg-primary text-primary-foreground border-primary":"border-border text-primary hover:bg-background-elevated"}`,children:e})},`${e}-${t}`)),(0,s.jsx)("button",{onClick:()=>{f<g&&v(f+1)},disabled:f===g,"aria-label":m("catalogue.pageNavigation.nextPage"),className:"px-4 py-2 rounded-lg border border-border text-primary hover:bg-background-elevated disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"â"})]}),(0,s.jsx)("div",{className:"flex items-center gap-2 md:hidden",children:(0,s.jsx)("label",{htmlFor:"page-input",className:"text-sm text-secondary",children:m("catalogue.pageNavigation.pageOf",{current:f,total:g})})})]})]})}},96933:(e,t,r)=>{r.d(t,{WineCard:()=>x});var s=r(95155),a=r(69276),i=r(83650),n=r(18955),l=r(15239),c=r(52619),o=r.n(c),d=r(12115);let m={RED:{bg:"bg-red-600/80 dark:bg-red-700/80",text:"text-white dark:text-white",border:"border-red-700 dark:border-red-800"},WHITE:{bg:"bg-yellow-600/80 dark:bg-yellow-700/80",text:"text-white dark:text-white",border:"border-yellow-700 dark:border-yellow-800"},ROSE:{bg:"bg-pink-600/80 dark:bg-pink-700/80",text:"text-white dark:text-white",border:"border-pink-700 dark:border-pink-800"},SPARKLING:{bg:"bg-amber-600/80 dark:bg-amber-700/80",text:"text-white dark:text-white",border:"border-amber-700 dark:border-amber-800"},DESSERT:{bg:"bg-orange-600/80 dark:bg-orange-700/80",text:"text-white dark:text-white",border:"border-orange-700 dark:border-orange-800"},FORTIFIED:{bg:"bg-purple-600/80 dark:bg-purple-700/80",text:"text-white dark:text-white",border:"border-purple-700 dark:border-purple-800"}},x=(0,d.memo)(function(e){let{wine:t,locale:r}=e,c=(0,n.c)("wine"),{discover:x}=(0,i.g)(),u=(0,d.useRef)(!1),h=m[t.type]||m.RED,p=t.type?c(`types.${t.type.toLowerCase()}`):"";return(0,s.jsxs)(o(),{href:`/${r}/wine/${t.slug}`,className:"group block bg-surface rounded-lg shadow-md hover:shadow-xl transition-shadow duration-300 overflow-hidden border border-border flex flex-col","aria-label":c("accessibility.viewDetails",{name:t.name}),children:[(0,s.jsxs)("div",{className:"relative aspect-[3/4] bg-surface-hover overflow-hidden",onMouseEnter:()=>{u.current||(u.current=!0,x("wine-bottle-tilt"))},onClick:()=>{x("wine-glass-clink")},children:[t.image?(0,s.jsx)(l.default,{src:t.image.url,alt:c("accessibility.wineImage",{name:t.name}),fill:!0,className:"object-contain group-hover:scale-105 transition-transform duration-300 p-2",sizes:"(max-width: 640px) 50vw, (max-width: 1024px) 33vw, 25vw"}):(0,s.jsx)("div",{className:"flex items-center justify-center h-full text-muted",children:(0,s.jsx)("span",{className:"text-4xl",children:"\uD83C\uDF77"})}),(0,s.jsx)("div",{className:`absolute top-2 left-2 px-3 py-1 rounded-full text-xs font-semibold border-2 ${h.bg} ${h.text} ${h.border} backdrop-blur-sm`,children:p}),(0,s.jsxs)("div",{className:"absolute top-2 right-2 flex flex-col gap-1",children:[t.isOrganic&&(0,s.jsxs)("span",{className:"px-2 py-1 bg-green-600/90 text-white text-xs font-semibold rounded-full backdrop-blur-sm border border-green-700","aria-label":c("accessibility.organicBadge"),children:["\uD83C\uDF31 ",c("item.organic")]}),t.byTheGlass&&(0,s.jsxs)("span",{className:"px-2 py-1 bg-blue-600/90 text-white text-xs font-semibold rounded-full backdrop-blur-sm border border-blue-700","aria-label":c("accessibility.byTheGlassBadge"),children:["\uD83C\uDF77"," ",t.byGlassPrice?`฿${t.byGlassPrice.toLocaleStr
28ing()}/${c("labels.perGlass")}`:c("item.byTheGlass")]})]})]}),(0,s.jsxs)("div",{className:"p-4 flex flex-col flex-1",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[t.vintage&&(0,s.jsx)("p",{className:"text-sm text-secondary",children:t.vintage}),t.code&&(0,s.jsx)("span",{className:"text-xs font-mono tracking-wide text-muted/80 uppercase",children:t.code})]}),(0,s.jsx)("h3",{className:"text-lg font-heading font-bold text-heading mb-1 line-clamp-2 group-hover:text-heading transition-colors",children:t.name}),(0,s.jsx)("p",{className:"text-sm text-secondary mb-3",children:t.winery?.name}),(0,s.jsx)("div",{className:"flex-grow"}),(0,s.jsxs)("div",{className:"space-y-1 pt-3 border-t border-border/50",children:[(0,s.jsxs)("div",{className:"flex justify-between items-center",children:[(0,s.jsxs)("span",{className:"text-sm text-secondary flex items-center gap-1",children:[c("item.dineInPrice"),":",(0,s.jsx)(a.Q,{iconSize:"sm"})]}),(0,s.jsxs)("span",{className:"text-lg font-bold text-primary",children:["฿",t.dineInPrice?.toLocaleString()||"0"]})]}),t.takeawayPrice&&t.takeawayPrice!==t.dineInPrice&&(0,s.jsxs)("div",{className:"flex justify-between items-center",children:[(0,s.jsxs)("span",{className:"text-sm text-secondary flex items-center gap-1",children:[c("item.takeawayPrice"),":",(0,s.jsx)(a.Q,{iconSize:"sm"})]}),(0,s.jsxs)("span",{className:"text-base font-semibold text-secondary",children:["฿",t.takeawayPrice?.toLocaleString()||"0"]})]})]}),!t.isAvailable&&(0,s.jsx)("p",{className:"mt-2 text-sm text-red-600 dark:text-red-400 font-medium",children:c("item.unavailable")})]})]})})},99833:(e,t,r)=>{r.d(t,{WineBrowseResults:()=>x});var s=r(95155),a=r(67886),i=r(96547),n=r(18955),l=r(15239),c=r(52619),o=r.n(c),d=r(12115),m=r(6092);function x(e){let{filters:t,locale:r,title:c,description:x,additionalDescription:u,regionData:h,grapeData:p,countryData:g,wineryData:f}=e,b=(0,n.c)("wine"),y=(0,n.c)("common.navigation"),[j,v]=(0,d.useState)([]),[w,N]=(0,d.useState)(0),[k,C]=(0,d.useState)(!0),[S,D]=(0,d.useState)(null),[$,I]=(0,d.useState)(!0),[E,F]=(0,d.useState)(!1),[R,M]=(0,d.useState)(!1),[L,T]=(0,d.useState)(!1),[P,W]=(0,d.useState)(!1);return(0,d.useEffect)(()=>{let e=()=>{window.innerWidth<768?I(!1):I(!0)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),(0,d.useEffect)(()=>{!async function(){C(!0),D(null);try{let e=new URLSearchParams;t.types&&t.types.length>0&&e.set("types",t.types.join(",")),t.isOrganic&&e.set("isOrganic","true"),t.byTheGlass&&e.set("byTheGlass","true"),t.countryIds&&t.countryIds.length>0&&e.set("countryIds",t.countryIds.join(",")),t.countrySlugs&&t.countrySlugs.length>0&&e.set("countrySlugs",t.countrySlugs.join(",")),t.wineryIds&&t.wineryIds.length>0&&e.set("wineryIds",t.wineryIds.join(",")),t.winerySlugs&&t.winerySlugs.length>0&&e.set("winerySlugs",t.winerySlugs.join(",")),t.regionIds&&t.regionIds.length>0&&e.set("regionIds",t.regionIds.join(",")),t.regionSlugs&&t.regionSlugs.length>0&&e.set("regionSlugs",t.regionSlugs.join(",")),t.grapeVarietyIds&&t.grapeVarietyIds.length>0&&e.set("grapeVarietyIds",t.grapeVarietyIds.join(",")),t.grapeVarietySlugs&&t.grapeVarietySlugs.length>0&&e.set("grapeVarietySlugs",t.grapeVarietySlugs.join(",")),void 0!==t.priceMin&&e.set("priceMin",t.priceMin.toString()),void 0!==t.priceMax&&e.set("priceMax",t.priceMax.toString()),t.search&&e.set("q",t.search);let r=e.toString(),s=t.search?`/api/wine/search${r?`?${r}`:""}`:`/api/wine${r?`?${r}`:""}`,a=await fetch(s);if(!a.ok)throw Error("Failed to fetch wine results");let i=await a.json();v(i.items||[]),N(i.total||0)}catch(e){D(b("filter.error")||"Failed to load wine results")}finally{C(!1)}}()},[t,b]),(0,s.jsxs)("div",{className:"min-h-screen bg-background","data-component":"WineBrowseResults",children:[(0,s.jsx)("div",{className:"bg-background-paper border-b border-border",children:(0,s.jsx)("div",{className:"container mx-auto px-4 py-8",children:(0,s.jsxs)("div",{className:"mx-auto",children:[(0,s.jsx)("div",{className:"mb-6",children:(0,s.jsx)(a.BackButton,{fallbackUrl:`/${r}/wine`,className:"flex-shrink-0",children:y("back")})}),(0,s.jsx)("h1",{className:"text-3xl lg:text-4xl font-heading font-bold text-primary mb-4",children:c}),(0,s.jsxs)("div",{className:"mb-6 space-y-4",children:[(0,s.jsx)("p",{className:"text-lg text-secondary",children:x}),u&&(0,s.jsxs)("div",{className:"p-4 bg-background-elevated dark:bg-background-elevated rounded-lg border border-border",children:[(0,s.jsx)("p",{className:`text-base text-primary leading-relaxed ${!R?"md:line-clamp-none line-clamp-1":""}`,children:u}),(0,s.jsx)("button",{onClick:()=>M(!R),className:"mt-2 text-sm text-link hover:underline md:hidden","aria-expanded":R,children:R?"th"===r?"à¹à¸ªà¸à¸à¸à¹à¸à¸¢à¸¥à¸":"Show less":"th"===r?"à¹à¸ªà¸à¸à¹à¸à¸´à¹à¸¡à¹à¸à¸´à¸¡":"Show more"})]}),g?.wineFact&&(0,s.jsxs)("div",{className:"p-4 bg-accent/10 dark:bg-accent/20 rounded-lg border border-accent/30",children:[(0,s.jsx)("p",{className:"text-sm font-semibold text-accent mb-1",children:"th"===r?"\uD83C\uDF77 à¸à¹à¸à¹à¸à¹
28à¸à¸à¸£à¸´à¸à¹à¸à¸µà¹à¸¢à¸§à¸à¸±à¸à¹à¸§à¸à¹":"\uD83C\uDF77 Wine Fact"}),(0,s.jsx)("p",{className:`text-base text-primary leading-relaxed ${!L?"md:line-clamp-none line-clamp-1":""}`,children:g.wineFact}),(0,s.jsx)("button",{onClick:()=>T(!L),className:"mt-2 text-sm text-link hover:underline md:hidden","aria-expanded":L,children:L?"th"===r?"à¹à¸ªà¸à¸à¸à¹à¸à¸¢à¸¥à¸":"Show less":"th"===r?"à¹à¸ªà¸à¸à¹à¸à¸´à¹à¸¡à¹à¸à¸´à¸¡":"Show more"})]}),h&&(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[h.countryFlagUrl&&h.countrySlug&&(0,s.jsx)(o(),{href:`/${r}/wine/browse/${h.countrySlug}-wines`,className:"flex-shrink-0 hover:opacity-80 transition-opacity",title:`${b("filter.viewWinesFrom")} ${"th"===r&&h.countryName_th||h.countryName}`,children:(0,s.jsx)("div",{className:"relative w-12 h-9",children:(0,s.jsx)(l.default,{src:h.countryFlagUrl,alt:"th"===r&&h.countryName_th||h.countryName,fill:!0,className:"object-cover rounded shadow-sm",sizes:"48px"})})}),(0,s.jsxs)("span",{className:"inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-primary/10 text-primary border border-primary/20",children:["\uD83D\uDCCD"," ","th"===r&&h.name_th||h.name," ","(","th"===r&&h.countryName_th||h.countryName,")"]})]}),h&&h.wineries&&h.wineries.length>0&&(0,s.jsxs)("div",{className:"pt-2",children:[(0,s.jsxs)("button",{onClick:()=>F(!E),className:"flex items-center gap-2 text-sm font-semibold text-secondary mb-2 hover:opacity-80 transition-opacity","aria-expanded":E,children:[b("browse.wineries"),(0,s.jsx)(m.tEr,{className:`w-4 h-4 transition-transform ${E?"rotate-180":""}`})]}),(0,s.jsx)("div",{className:`flex flex-wrap gap-2 transition-all duration-300 ${E?"opacity-100 max-h-[1000px]":"opacity-0 max-h-0 overflow-hidden"}`,children:h.wineries.map(e=>(0,s.jsx)(o(),{href:`/${r}/wine/browse/${e.slug}-winery-wines`,className:"inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-secondary/10 text-secondary border border-secondary/20 hover:bg-secondary hover:text-primary-foreground transition-colors",children:e.name},e.id))})]}),p&&(0,s.jsxs)("div",{className:"flex items-center gap-4",children:[p.photoUrl&&(0,s.jsx)("div",{className:"relative w-16 h-16 flex-shrink-0 rounded-full overflow-hidden border-2 border-primary/20 shadow-sm",children:(0,s.jsx)(l.default,{src:p.photoUrl,alt:p.name,fill:!0,className:"object-cover",sizes:"64px"})}),(0,s.jsxs)("span",{className:"inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-accent/10 text-accent border border-accent/20",children:["\uD83C\uDF47 ",p.name]})]}),f&&(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)("div",{className:"flex items-center gap-2",children:(0,s.jsxs)("span",{className:"inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-secondary/10 text-secondary border border-secondary/20",children:["\uD83C\uDFDBï¸ ",f.name]})}),(f.description_en||f.description_th)&&(0,s.jsxs)("div",{className:"p-4 bg-background-elevated dark:bg-background-elevated rounded-lg border border-border",children:[(0,s.jsx)("p",{className:`text-base text-primary leading-relaxed ${!P?"md:line-clamp-none line-clamp-1":""}`,children:"th"===r&&f.description_th||f.description_en}),(0,s.jsx)("button",{onClick:()=>W(!P),className:"mt-2 text-sm text-link hover:underline md:hidden","aria-expanded":P,children:P?"th"===r?"à¹à¸ªà¸à¸à¸à¹à¸à¸¢à¸¥à¸":"Show less":"th"===r?"à¹à¸ªà¸à¸à¹à¸à¸´à¹à¸¡à¹à¸à¸´à¸¡":"Show more"})]}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-3 text-sm",children:[f.location&&(0,s.jsxs)("span",{className:"text-muted",children:["\uD83D\uDCCD ",f.location]}),f.website&&(0,s.jsxs)("a",{href:f.website,target:"_blank",rel:"noopener noreferrer",className:"text-link hover:underline",children:["\uD83C\uDF10 ",b("item.wineryWebsite")]})]}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-2",children:[f.countrySlug&&(0,s.jsxs)(o(),{href:`/${r}/wine/browse/${f.countrySlug}-wines`,className:"inline-flex items-center gap-2 px-3 py-1 rounded-full text-sm font-medium bg-primary/10 text-primary border border-primary/20 hover:bg-primary hover:text-primary-foreground transition-colors",children:[f.countryFlagUrl&&(0,s.jsx)("div",{className:"relative w-5 h-4 flex-shrink-0",children:(0,s.jsx)(l.default,{src:f.countryFlagUrl,alt:f.countryName,fill:!0,className:"rounded-sm object-cover",sizes:"20px"})}),"th"===r&&f.countryName_th||f.countryName]}),f.regionSlug&&f.regionName&&(0,s.jsx)(o(),{href:`/${r}/wine/browse/region-${f.regionSlug}`,className:"inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-primary/10 text-primary border border-primary/20 hover:bg-primary hover:text-primary-foreground transition-colors",children:"th"===r&&f.regionName_th||f.regionName})]})]}),g&&g.regions.length>0&&(0,s.jsxs)("div",{className:"pt-2",children:[(0,s.jsxs)("button",{onClick:()=>I(!$),className:"flex items-center gap-2 text-sm font-semibold text-primary mb-2 hover:opacity-80 transition-opacity","aria-expanded":$,children:[b("browse.regions"),(0,s.jsx)(m.tEr,{className:`w-4 h-4 transition-transform ${$?"rotate-180":""}`})]}),(0,s.jsx)("div",{className:`flex flex-wrap gap-2 transition-all duration-300 ${$?"opacity-100 max-h-[1000px]":"opacity-0 max-h-0 overflow-hidden"}`,children:g.regions.map(e=>(0,s.jsx)(o(),{href:`/${r}/wine/browse/region-${e.slug}`,className:"inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-primary/10 text-primary border border-primary/20 hover:bg-primary hover:text-primary-foreground transition-colors",children:"th"===r&&e.name_th||e.name},e.id))})]}),g&&g.wineries.length>0&&(0,s.jsxs)("div",{className:"pt-2",children:[(0,s.jsxs)("button",{onClick:()=>F(!E),className:"flex items-center gap-2 text-sm font-semibold text-secondary mb-2 hover:opacity-80 transition-opacity","aria-expanded":E,children:[b("browse.wineries"),(0,s.jsx)(m.tEr,{className:`w-4 h-4 transition-transform ${E?"rotate-180":""}`})]}),(0,s.jsx)("div",{className:`flex flex-wrap gap-2 transition-all duration-300 ${E?"opacity-100 max-h-[1000px]":"opacity-0 max-h-0 overflow-hidden"}`,children:g.wineries.map(e=>(0,s.jsx)(o(),{href:`/${r}/wine/browse/${e.slug}-winery-wines`,className:"inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-secondary/10 text-secondary border border-secondary/20 hover:bg-secondary hover:text-primary-foreground transition-colors",children:e.name},e.id))})]})]})]})})}),(0,s.jsx)("div",{className:"container mx-auto px-4 py-8",children:(0,s.jsxs)("div",{className:"mx-auto",children:[(0,s.jsx)("div",{className:"mb-6",children:k?(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"animate-spin rounded-full h-5 w-5 border-2 border-primary/20 border-t-primary"}),(0,s.jsx)("span",{className:"text-secondary",children:b("filter.loading")})]}):S?(0,s.jsx)("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4",children:(0,s.jsxs)("div",{className:"flex items-center gap-3 text-red-800 dark:text-red-200",children:[(0,s.jsx)("svg",{className:"w-5 h-5 flex-shrink-0",fill:"currentColor",viewBox:"0 0 20 20",children:(0,s.jsx)("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})}),(0,s.jsx)("span",{children:S})]})}):(0,s.jsx)("div",{className:"flex items-center justify-between",children:(0,s.jsx)("p",{className:"text-secondary",children:0===w?b("filter.noResults"):b("filter.resultsCount",{count:w})})})}),!k&&!S&&j.length>0&&(0,s.jsx)(i.WineGrid,{wines:j,locale:r,enablePagination:!0}
28),!k&&!S&&0===j.length&&(0,s.jsx)("div",{className:"text-center py-16",children:(0,s.jsxs)("div",{className:"max-w-md mx-auto",children:[(0,s.jsx)("div",{className:"text-6xl mb-4",children:"\uD83C\uDF77"}),(0,s.jsx)("h3",{className:"text-xl font-heading font-bold text-primary mb-2",children:b("filter.noResults")}),(0,s.jsx)("p",{className:"text-secondary mb-6",children:b("filter.noResultsDescription")}),(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("p",{className:"text-sm text-muted",children:[b("filter.suggestions"),":"]}),(0,s.jsxs)("ul",{className:"text-sm text-muted space-y-1",children:[(0,s.jsxs)("li",{children:["⢠",b("filter.suggestion1")]}),(0,s.jsxs)("li",{children:["⢠",b("filter.suggestion2")]}),(0,s.jsxs)("li",{children:["⢠",b("filter.suggestion3")]})]}),(0,s.jsx)("div",{className:"pt-4",children:(0,s.jsx)(o(),{href:`/${r}/wine`,className:"inline-flex items-center px-6 py-3 bg-primary text-primary-foreground rounded-lg font-semibold hover:bg-primary/90 transition-colors",children:b("filter.browseAll")})})]})]})})]})})]})}}}]);
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.