import{d as I,c as f,e as j}from"./index-BagLllOy.js";import{j as e,b as q,T as J,I as G,V as X,c as Q,d as Z,e as ee,f as te,g as re,h as se,i as ae,k as ne,l as le,m as oe,n as ce,o as ie,p as de}from"./ui-vendor-8uIfD_JC.js";import{i as ue,r as o}from"./react-vendor-28t7dxFl.js";import{C as B}from"./chevron-down-BbzELEph.js";import{B as P,a as $}from"./badge-DdeHRCon.js";import{E as fe,a as xe,b as me,c as pe,d as he}from"./empty-CqAWvc3s.js";import{S as F}from"./status-badge-Ci7U3cAc.js";import{M as R}from"./header-B8URyXEE.js";import{S as U}from"./analytics-DwWXTewx.js";/**
 * @license lucide-react v0.546.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ge=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],ve=I("check",ge);/**
 * @license lucide-react v0.546.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const je=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],be=I("chevron-up",je);/**
 * @license lucide-react v0.546.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ye=[["polygon",{points:"12 2 19 21 12 17 5 21 12 2",key:"x8c0qg"}]],Pe=I("navigation-2",ye);function $e({...t}){return e.jsx(q,{"data-slot":"select",...t})}function Fe({...t}){return e.jsx(X,{"data-slot":"select-value",...t})}function Ue({className:t,size:r="default",children:s,...a}){return e.jsxs(J,{"data-slot":"select-trigger","data-size":r,className:f("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...a,children:[s,e.jsx(G,{asChild:!0,children:e.jsx(B,{className:"size-4 opacity-50"})})]})}function Ve({className:t,children:r,position:s="popper",align:a="center",...l}){return e.jsx(Q,{children:e.jsxs(Z,{"data-slot":"select-content",className:f("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",s==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:s,align:a,...l,children:[e.jsx(Ne,{}),e.jsx(ee,{className:f("p-1",s==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:r}),e.jsx(we,{})]})})}function He({className:t,children:r,...s}){return e.jsxs(te,{"data-slot":"select-item",className:f("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",t),...s,children:[e.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:e.jsx(re,{children:e.jsx(ve,{className:"size-4"})})}),e.jsx(se,{children:r})]})}function Ne({className:t,...r}){return e.jsx(ae,{"data-slot":"select-scroll-up-button",className:f("flex cursor-default items-center justify-center py-1",t),...r,children:e.jsx(be,{className:"size-4"})})}function we({className:t,...r}){return e.jsx(ne,{"data-slot":"select-scroll-down-button",className:f("flex cursor-default items-center justify-center py-1",t),...r,children:e.jsx(B,{className:"size-4"})})}function Se({className:t,children:r,...s}){return e.jsxs(le,{"data-slot":"scroll-area",className:f("relative",t),...s,children:[e.jsx(oe,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:r}),e.jsx(_e,{}),e.jsx(ce,{})]})}function _e({className:t,orientation:r="vertical",...s}){return e.jsx(ie,{"data-slot":"scroll-area-scrollbar",orientation:r,className:f("flex touch-none p-px transition-colors select-none",r==="vertical"&&"h-full w-2.5 border-l border-l-transparent",r==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",t),...s,children:e.jsx(de,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}function Ce({item:t,onClick:r}){const[s,a]=o.useState(!1),l=t.main_image?.url??t.icon_image?.url??null;return e.jsxs("div",{onClick:r,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),className:f("rounded-[14px] overflow-hidden cursor-pointer bg-card border transition-all duration-200",s?t.selected?"border-primary/40 -translate-y-1 shadow-xl":"border-border -translate-y-1 shadow-lg":t.selected?"border-primary/25":"border-border/60"),children:[e.jsxs("div",{className:"h-[175px] relative overflow-hidden bg-secondary",children:[l?e.jsx("img",{src:l,alt:t.name,className:"w-full h-full object-cover transition-transform duration-300",style:{transform:s?"scale(1.04)":"scale(1)"}}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-4xl text-muted-foreground/20 select-none",children:"🌿"}),e.jsxs("div",{className:"absolute bottom-2.5 left-2.5 right-2.5 flex items-center justify-between gap-1.5 flex-wrap",children:[e.jsx(F,{item:t}),t.selected&&e.jsxs(P,{className:"gap-1 text-[10px] font-semibold h-5 px-1.5",children:[e.jsx($,{className:"size-2.5"}),"Партнёр"]})]})]}),e.jsxs("div",{className:"p-3.5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1.5",children:[e.jsx("h3",{className:"font-bold text-[15px] leading-tight",children:t.name}),t.rate!=null&&e.jsxs("span",{className:"flex items-center gap-1 text-primary text-[13px] font-bold shrink-0",children:[e.jsx(U,{className:"size-3 fill-primary"}),t.rate.toFixed(1)]})]}),e.jsxs("div",{className:"flex items-start gap-1 text-[12px] text-muted-foreground",children:[e.jsx(R,{className:"size-3 mt-0.5 shrink-0"}),e.jsx("span",{className:"line-clamp-1",children:t.address})]})]})]})}function ze({item:t,selected:r,onClick:s}){const[a,l]=o.useState(!1),i=t.icon_image?.url??t.main_image?.url??null;return e.jsxs("div",{onClick:s,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),className:f("flex gap-3 p-3.5 rounded-[12px] cursor-pointer bg-card border transition-all duration-150",a||r?t.selected?"border-primary/40 bg-primary/5":"border-border bg-secondary/60":t.selected?"border-primary/20":"border-border/60",a&&"translate-x-1"),children:[e.jsx("div",{className:"w-[68px] h-[68px] rounded-[10px] overflow-hidden bg-secondary shrink-0",children:i?e.jsx("img",{src:i,alt:t.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-xl text-muted-foreground/25 select-none",children:"🌿"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-start justify-between gap-1.5 mb-1",children:[e.jsx("h3",{className:"font-bold text-[13px] leading-tight truncate",children:t.name}),t.selected&&e.jsxs(P,{variant:"default",className:"gap-0.5 text-[9px] h-4 px-1 shrink-0",children:[e.jsx($,{className:"size-2"}),"Партнёр"]})]}),e.jsxs("div",{className:"flex items-center gap-1 text-[11px] text-muted-foreground mb-1.5",children:[e.jsx(R,{className:"size-2.5 shrink-0"}),e.jsx("span",{className:"line-clamp-1",children:t.address})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{item:t}),t.rate!=null&&e.jsxs("span",{className:"flex items-center gap-0.5 text-primary text-[11px] font-bold",children:[e.jsx(U,{className:"size-2.5 fill-primary"}),t.rate.toFixed(1)]})]})]})]})}function Ke({establishments:t,selectedEstablishment:r,onEstablishmentClick:s,establishmentType:a,cities:l,compact:i=!1}){const u=ue();if(t.length===0)return e.jsx("div",{className:"h-full flex items-center justify-center p-8",children:e.jsx(fe,{children:e.jsxs(xe,{children:[e.jsx(me,{variant:"icon",children:e.jsx(R,{})}),e.jsx(pe,{children:"Заведения не найдены"}),e.jsx(he,{children:"Попробуйте изменить фильтры или выбрать другой город"})]})})});const x=n=>{s(n);const m=l.find(b=>b.id===n.city_id)?.slug??n.city_id,h=a==="places"?`/place/${m}/${n.slug}`:`/shop/${m}/${n.slug}`;u(h)};return i?e.jsx(Se,{className:"h-full",children:e.jsx("div",{className:"p-3 space-y-2",children:t.map(n=>e.jsx(ze,{item:n,selected:r?.id===n.id,onClick:()=>x(n)},n.id))})}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:t.map(n=>e.jsx(Ce,{item:n,onClick:()=>x(n)},n.id))})}async function A(){const t=await fetch("https://ipapi.co/json/");if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);const r=await t.json();if(r.error)throw new Error(r.reason||"Location detection failed");const s={country:r.country_name||"",city:r.city||"",countryCode:r.country_code||"",lat:r.latitude||0,lon:r.longitude||0};if(!s.country||!s.lat||!s.lon)throw new Error("Incomplete location data");return localStorage.setItem("user_location",JSON.stringify(s)),s}function We(){const[t,r]=o.useState({data:null,isLoading:!0,error:null}),s=o.useCallback(async()=>{r(a=>({...a,isLoading:!0,error:null})),localStorage.removeItem("user_location");try{const a=await A();return r({data:a,isLoading:!1,error:null}),a}catch(a){throw r({data:null,isLoading:!1,error:a}),a}},[]);return o.useEffect(()=>{const a=localStorage.getItem("user_location");if(a)try{const l=JSON.parse(a);r({data:l,isLoading:!1,error:null});return}catch{}A().then(l=>{r({data:l,isLoading:!1,error:null})}).catch(l=>{r({data:null,isLoading:!1,error:l})})},[]),{...t,refresh:s}}function Ee(t,r,s,a){var l=this,i=o.useRef(null),u=o.useRef(0),x=o.useRef(0),n=o.useRef(null),p=o.useRef([]),m=o.useRef(),h=o.useRef(),b=o.useRef(t),g=o.useRef(!0);b.current=t;var _=typeof window<"u",y=!r&&r!==0&&_;if(typeof t!="function")throw new TypeError("Expected a function");r=+r||0;var C=!!(s=s||{}).leading,T=!("trailing"in s)||!!s.trailing,v="maxWait"in s,D="debounceOnServer"in s&&!!s.debounceOnServer,z=v?Math.max(+s.maxWait||0,r):null;o.useEffect(function(){return g.current=!0,function(){g.current=!1}},[]);var K=o.useMemo(function(){var E=function(c){var d=p.current,S=m.current;return p.current=m.current=null,u.current=c,x.current=x.current||c,h.current=b.current.apply(S,d)},N=function(c,d){y&&cancelAnimationFrame(n.current),n.current=y?requestAnimationFrame(c):setTimeout(c,d)},M=function(c){if(!g.current)return!1;var d=c-i.current;return!i.current||d>=r||d<0||v&&c-u.current>=z},O=function(c){return n.current=null,T&&p.current?E(c):(p.current=m.current=null,h.current)},k=function c(){var d=Date.now();if(C&&x.current===u.current&&W(),M(d))return O(d);if(g.current){var S=r-(d-i.current),Y=v?Math.min(S,z-(d-u.current)):S;N(c,Y)}},W=function(){a&&a({})},w=function(){if(_||D){var c=Date.now(),d=M(c);if(p.current=[].slice.call(arguments),m.current=l,i.current=c,d){if(!n.current&&g.current)return u.current=i.current,N(k,r),C?E(i.current):h.current;if(v)return N(k,r),E(i.current)}return n.current||N(k,r),h.current}};return w.cancel=function(){var c=n.current;c&&(y?cancelAnimationFrame(n.current):clearTimeout(n.current)),u.current=0,p.current=i.current=m.current=n.current=null,c&&a&&a({})},w.isPending=function(){return!!n.current},w.flush=function(){return n.current?O(Date.now()):h.current},w},[C,v,r,z,T,y,_,D,a]);return K}function ke(t,r){return t===r}function Ye(t,r,s){var a=ke,l=o.useRef(t),i=o.useState({})[1],u=Ee(o.useCallback(function(n){l.current=n,i({})},[i]),r,s,i),x=o.useRef(t);return a(x.current,t)||(u(t),x.current=t),[l.current,u]}const V="goh_selected_country",L="goh_selected_city",H=365;function qe(){return{countryId:j.get(V)||null,cityId:j.get(L)||null}}function Je(t){j.set(V,t,{expires:H})}function Ge(t){j.set(L,t,{expires:H})}function Xe(){j.remove(L)}export{ve as C,Ke as E,Pe as N,$e as S,Ye as a,Ge as b,Xe as c,Ue as d,Fe as e,Ve as f,qe as g,He as h,Je as s,We as u};