1import{e as _,r as o,u as le,j as e,L as b,bV as re,aP as B}from"./index-C0ZerVyI.js";import{c as ke,l as we,a as Ce,M as Pe,T as Le,b as ee,L as te,u as Se}from"./leaflet-DPke3uE0.js";import{f as oe,o as Me,u as $e,D as se,g as W,S as Oe,L as Te}from"./LocationPrompt-DTF78O_c.js";import{B as Ee}from"./business-category-qlvxQrzl.js";import{M as Ae}from"./map-pin-DhRms3EV.js";import{S as De}from"./search-BO1Mbmbv.js";import{C as Fe}from"./clock-Dx9uIjka.js";import"./loader-circle-lEKHLar6.js";const Re=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],Ie=_("arrow-left",Re);const Ke=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}]],Be=_("compass",Ke);const We=[["polygon",{points:"3 11 22 2 13 21 11 13 3 11",key:"1ltx0t"}]],_e=_("navigation",We),ae=ke(function(l,s){const p=new we.Popup(l,s.overlayContainer);return Ce(p,s)},function(l,s,{position:p},d){o.useEffect(function(){const{instance:m}=l;function x(f){f.popup===m&&(m.update(),d(!0))}function j(f){f.popup===m&&d(!1)}return s.map.on({popupopen:x,popupclose:j}),s.overlayContainer==null?(p!=null&&m.setLatLng(p),m.openOn(s.map)):s.overlayContainer.bindPopup(m),function(){s.map.off({popupopen:x,popupclose:j}),s.overlayContainer?.unbindPopup(),s.map.removeLayer(m)}},[l,s,d,p])});function He({business:i,campaign:l,distanceKm:s,userLocation:p}){const{copy:d,t:r}=le();return e.jsxs("div",{className:"map-popup-card",children:[e.jsxs("div",{className:"map-popup-header",children:[e.jsx("img",{src:i.logo,alt:"",className:"h-11 w-11 shrink-0 rounded-xl object-cover ring-1 ring-border/80"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm font-bold leading-tight text-foreground",children:i.name}),e.jsxs("p",{className:"truncate text-[11px] text-muted-foreground",children:["@",i.handle]})]}),s!==void 0&&e.jsx("span",{className:"shrink-0 rounded-md bg-primary/10 px-2 py-0.5 text-[10px] font-bold text-primary",children:oe(s)})]}),e.jsxs("p",{className:"map-popup-address",children:[e.jsx(Ae,{className:"h-3.5 w-3.5 shrink-0 text-primary","aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:i.address})]}),e.jsxs("button",{type:"button",className:"map-popup-directions",onClick:()=>Me(p,{lat:i.lat,lng:i.lng}),children:[e.jsx(_e,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),d.mapPage.getDirections]}),l?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"map-popup-campaign",children:[e.jsx("span",{className:"map-popup-badge",children:l.discountLabel}),e.jsx("p",{className:"mt-1.5 text-xs font-semibold leading-snug text-foreground",children:l.title}),e.jsx("p",{className:"mt-0.5 text-[10px] text-muted-foreground",children:r(d.mapPage.daysLeft,{count:l.daysLeft})})]}),e.jsxs("div",{className:"map-popup-actions",children:[e.jsxs(b,{to:"/campaign/$id",params:{id:l.id},className:"map-popup-link",children:[d.mapPage.viewDetails,e.jsx(re,{className:"h-3 w-3","aria-hidden":"true"})]}),e.jsx(b,{to:"/campaign/$id/join",params:{id:l.id},className:"map-popup-cta",children:d.mapPage.join})]})]}):e.jsx("p",{className:"map-popup-empty",children:d.mapPage.noCampaignNow})]})}const qe={Food:"ð",Fashion:"ð",Fitness:"ðª",Beauty:"ð",Books:"ð"};function Ue(i){return[{id:"all",label:i.common.all,icon:"ð"},...Ee.map(l=>({id:l,label:i.categories[l]??l,icon:qe[l]??"ð"}))]}function ne(i){const l=i.getElement();l&&l.querySelectorAll(".leaflet-popup-content-wrapper, .leaflet-popup-tip-container").forEach(s=>{s.style.animation="none",s.offsetWidth,s.style.animation=""})}function Ge({center:i}){const l=Se();return o.useEffect(()=>{i&&l.flyTo(i,15,{duration:1.2})},[i,l]),null}function tt({businesses:i,campaigns:l}){const{copy:s,t:p}=le(),d=o.useMemo(()=>Ue(s),[s]),{location:r,isLoading:m,isFallback:x,error:j,blockReason:f,hasRequested:ie,showLocationPrompt:ce,requestLocation:H}=$e(),[P,de]=o.useState(null),[me,L]=o.useState([se.lat,se.lng]),[S,q]=o.useState(""),[h,U]=o.useState("all"),[ue,v]=o.useState(!1),[y,M]=o.use
1State(!1),[$,O]=o.useState(10),[N,G]=o.useState(!1),[g,Q]=o.useState(0),[T,E]=o.useState(!1),[A,D]=o.useState(10),[V,F]=o.useState(!1),[k,R]=o.useState(0),[w,Y]=o.useState(!1),[pe,J]=o.useState(!1),[xe,fe]=o.useState(""),X=o.useRef({}),C=o.useRef(null);o.useEffect(()=>{!x&&!m&&L([r.lat,r.lng])},[x,m,r.lat,r.lng]);const I=(t,n,a)=>{de(t),L([n,a]);const c=X.current[t];c&&c.openPopup();const u=document.getElementById(`carousel-card-${t}`);if(u&&C.current){const ve=u.offsetLeft,ye=C.current.clientWidth/2,Ne=u.clientWidth/2;C.current.scrollTo({left:ve-ye+Ne,behavior:"smooth"})}},K=o.useMemo(()=>{const t=S.trim().toLowerCase();return i.filter(n=>Number.isFinite(n.lat)&&Number.isFinite(n.lng)&&!(n.lat===0&&n.lng===0)).map(n=>{const a=W(r.lat,r.lng,n.lat,n.lng),c=l.find(u=>u.businessId===n.id&&u.status==="active");return{biz:n,distanceKm:a,campaign:c}}).filter(({biz:n,distanceKm:a,campaign:c})=>h!=="all"&&n.category!==h||y&&a>$||N&&!c||g>0&&(!c||c.discountValue<g)?!1:t?n.name.toLowerCase().includes(t)||n.address.toLowerCase().includes(t)||n.handle.toLowerCase().includes(t)||c?.title.toLowerCase().includes(t)||c?.shortTitle?.toLowerCase().includes(t):!0).sort((n,a)=>n.distanceKm-a.distanceKm)},[i,l,r.lat,r.lng,S,h,y,$,N,g]),he=K.map(t=>t.biz),Z=y||N||g>0||h!=="all",ge=()=>{E(y),D($),F(N),R(g),v(!0)},be=()=>{M(T),O(A),G(V),Q(k),v(!1)},z=()=>{E(!1),D(10),F(!1),R(0),M(!1),O(10),G(!1),Q(0),U("all"),q(""),v(!1)},je=()=>{Y(!0),setTimeout(()=>{const n=i.filter(a=>Number.isFinite(a.lat)&&Number.isFinite(a.lng)&&!(a.lat===0&&a.lng===0)).filter(a=>W(r.lat,r.lng,a.lat,a.lng)<=10).length;M(!0),O(10),Y(!1),fe(n>0?`${n} yakın mekan bulundu (10 km içinde)`:"10 km içinde mekan bulunamadı"),J(!0),L([r.lat,r.lng]),setTimeout(()=>J(!1),3e3)},2e3)};return e.jsxs("div",{className:"relative h-full w-full overflow-hidden bg-background text-foreground",children:[e.jsxs(Pe,{center:[r.lat,r.lng],zoom:14,zoomControl:!1,attributionControl:!1,className:"h-full w-full z-10",children:[e.jsx(Le,{attribution:'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>',url:"https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}{r}.png"}),e.jsx(ee,{position:[r.lat,r.lng],icon:te.divIcon({className:"custom-user-marker",html:` 2 <div class="relative flex h-8 w-8 items-center justify-center"> 3 <span class="absolute inline-flex h-full w-full animate-ping rounded-full bg-ink/30 opacity-75"></span> 4 <span class="absolute inline-flex h-6 w-6 rounded-full bg-ink/20"></span> 5 <span class="relative inline-flex h-4 w-4 rounded-full bg-ink border-2 border-white shadow-lg"></span> 6 </div> 7 `,iconSize:[32,32],iconAnchor:[16,16]}),children:e.jsx(ae,{className:"custom-leaflet-popup",eventHandlers:{popupopen:t=>ne(t.target)},children:e.jsx("div",{className:"p-1 font-semibold text-xs text-center text-ink",children:s.mapPage.youAreHere})})}),he.map(t=>{const n=l.find(c=>c.businessId===t.id&&c.status==="active"),a=te.divIcon({className:"custom-business-marker",html:` 8 <div class="group relative flex h-12 w-12 items-center justify-center transition-all duration-300"> 9 <!-- Outer glowing ring if active --> 10 <div class="absolute inset-0 rounded-2xl bg-ink/30 opacity-0 group-hover:opacity-100 blur-sm transition-all duration-300 ${P===t.id?"opacity-100 scale-105":""}"></div> 11 12 <!-- Main container --> 13 <div class="relative flex h-10 w-10 items-center justify-center rounded-2xl border-2 bg-white shadow-xl transition-all duration-300 ${P===t.id?"border-ink scale-110":"border-muted/80"}"> 14 <img src="${t.logo}" class="h-8 w-8 rounded-xl object-cover" alt="" /> 15 16 <!-- Floating Badge --> 17 ${n?` 18 <div class="absolute -top-2 -right-2 flex h-5 min-w-[20px] items-center justify-center rounded-full bg-ink px-1 text-[8px] font-black text-lime shadow-md border border-white"> 19 ${n.discountLabel} 20 </div> 21 `:""} 22 </div> 23 </div> 24 `,iconSize:[48,48],iconAnchor:[24,24],popupAnchor:[0,-24]});return e.jsx(ee,{position:[t.lat,t.lng],icon:a,ref:c=>{c&&(X.current[t.id]=c)},eventHandlers:{click:()=>{I(t.id,t.lat,t.lng)}},children:e.jsx(ae,{className:"custom-leaflet-popup",minWidth:240,maxWidth:260,eventHandlers:{popupopen:c=>ne(c.target)},children:e.jsx(He,{business:t,campaign:n,distanceKm:W(r.lat,r.lng,t.lat,t.lng),userLocation:r})})},t.id)}),e.jsx(Ge,{center:me})]}),e.jsx("div",{className:"absolute top-4 left-0 right-0 z-20 px-4 pointer-events-none",children:e.jsxs("div",{className:"max-w-md mx-auto flex flex-col gap-2 pointer-events-auto",children:[e.jsxs("div",{className:"flex items-center gap-2.5 bg-background/85 backdrop-blur-lg border border-border/60 shadow-xl rounded-2xl p-2 pl-3",children:[e.jsx(b,{to:"/discover",className:"flex h-9 w-9 items-center justify-center rounded-xl bg-secondary hover:bg-secondary/80 text-foreground transition-all active:scale-95",children:e.jsx(Ie,{className:"h-4.5 w-4.5"})}),e.jsxs("div",{className:"relative flex-1",children:[e.jsx(De,{className:"absolute left-3 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx("input",{type:"text",placeholder:s.mapPage.searchPlaceholder,value:S,onChange:t=>q(t.target.value),className:"w-full bg-secondary/50 hover:bg-secondary/70 focus:bg-background border-0 rounded-xl py-2 pl-9 pr-4 text-xs font-medium focus:ring-2 focus:ring-ink/30 transition-all outline-none"})]}),e.jsxs("button",{type:"button",onClick:ge,className:`relative flex h-9 w-9 items-center justify-center rounded-xl transition-all ${Z?"bg-ink text-lime shadow-md shadow-ink/20":"bg-secondary hover:bg-secondary/80 text-foreground"}`,title:s.mapPage.filterButton,children:[e.jsx(Oe,{className:"h-4 w-4"}),Z&&e.jsx("span",{className:"absolute -right-0.5 -top-0.5 h-2 w-2 rounded-full bg-amber-400 ring-2 ring-background"})]})]}),e.jsx("div",{className:"flex gap-1.5 overflow-x-auto pb-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden mask-image-gradient",children:d.map(t=>e.jsxs("button",{onClick:()=>U(t.id),className:`flex-none flex items-center gap-1 px-3 py-1.5 rounded-xl text-xs font-semibold shadow-sm border transition-all active:scale-95 ${h===t.id?"bg-ink border-ink text-lime shadow-ink/20":"bg-background/90 backdrop-blur-md border-border/60 text-muted-foreground hover:bg-background"}`,children:[e.jsx("span",{children:t.icon}),e.jsx("span",{children:t.label})]},t.id))})]})}),ce&&e.jsx("div",{className:"absolute left-4 right-4 top-24 z-30",children:e.jsx(Te,{onRequest:H,isLoading:m,error:j,blockReason:f,hasRequested:ie})}),e.jsxs("div",{className:"absolute right-4 top-36 z-20 flex flex-col gap-2",children:[e.jsx("button",{onClick:()=>
24{if(x){H();return}I("user",r.lat,r.lng)},className:"flex h-10 w-10 items-center justify-center rounded-xl bg-background/90 backdrop-blur-md border border-border/60 shadow-lg hover:bg-background text-ink transition-all active:scale-90",title:s.mapPage.myLocation,children:e.jsx(Be,{className:"h-5 w-5 animate-pulse"})}),e.jsx("button",{onClick:je,disabled:w,className:`flex h-10 w-10 items-center justify-center rounded-xl border shadow-lg transition-all active:scale-90 ${w?"bg-ink border-ink text-lime animate-spin":"bg-background/90 backdrop-blur-md border-border/60 text-ink hover:bg-background"}`,title:s.mapPage.scanArea,children:e.jsx(B,{className:`h-5 w-5 ${w?"animate-pulse":""}`})})]}),w&&e.jsxs("div",{className:"absolute inset-0 bg-ink/90 backdrop-blur-md z-40 flex flex-col items-center justify-center text-white pointer-events-auto",children:[e.jsxs("div",{className:"relative flex h-40 w-40 items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-lime/40 animate-ping opacity-75"}),e.jsx("div",{className:"absolute inset-4 rounded-full border border-lime/30 animate-pulse"}),e.jsx("div",{className:"absolute inset-10 rounded-full bg-ink opacity-90 flex items-center justify-center shadow-2xl border border-lime/30",children:e.jsx(B,{className:"h-10 w-10 text-lime animate-pulse"})}),e.jsx("div",{className:"absolute inset-0 rounded-full border-t border-r border-lime/80 animate-spin",style:{animationDuration:"1s"}})]}),e.jsx("h3",{className:"mt-8 text-lg font-black tracking-wide text-lime",children:s.mapPage.scanningTitle}),e.jsx("p",{className:"mt-2 text-xs text-white/80 font-medium animate-pulse",children:s.mapPage.scanningBody})]}),pe&&e.jsx("div",{className:"absolute top-24 left-0 right-0 z-30 mx-auto max-w-xs px-4 animate-in fade-in slide-in-from-top-4 duration-300",children:e.jsxs("div",{className:"flex items-center gap-2 bg-ink text-lime text-xs font-bold px-4 py-2.5 rounded-xl shadow-xl border border-lime/20 justify-center",children:[e.jsx(B,{className:"h-4 w-4"}),e.jsx("span",{children:xe||s.mapPage.mapUpdated})]})}),ue&&e.jsx("div",{className:"absolute inset-0 z-50 flex flex-col justify-end bg-black/50 backdrop-blur-sm",children:e.jsxs("div",{className:"max-h-[70vh] overflow-y-auto rounded-t-3xl bg-card p-5 shadow-2xl animate-in slide-in-from-bottom",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg font-bold",children:s.mapPage.filtersTitle}),e.jsx("button",{type:"button",onClick:z,className:"text-xs font-bold text-destructive",children:s.common.reset})]}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("label",{className:"flex items-center justify-between rounded-xl border border-border/60 bg-secondary/30 px-4 py-3",children:[e.jsx("span",{className:"text-sm font-semibold",children:s.mapPage.nearbyOnly}),e.jsx("input",{type:"checkbox",checked:T,onChange:t=>E(t.target.checked),className:"h-4 w-4 accent-ink"})]}),T&&e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2 flex justify-between text-sm font-semibold",children:[e.jsx("span",{children:s.mapPage.maxDistance}),e.jsxs("span",{className:"text-ink",children:[A," km"]})]}),e.jsx("input",{type:"range",min:1,max:25,step:1,value:A,onChange:t=>D(Number(t.target.value)),className:"w-full accent-ink"})]}),e.jsxs("label",{className:"flex items-center justify-between rounded-xl border border-border/60 bg-secondary/30 px-4 py-3",children:[e.jsx("span",{className:"text-sm font-semibold",children:s.mapPage.activeCampaignOnly}),e.jsx("input",{type:"checkbox",checked:V,onChange:t=>F(t.target.checked),className:"h-4 w-4 accent-ink"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2 flex justify-between text-sm font-semibold",children:[e.jsx("span",{children:s.mapPage.minDiscount}),e.jsx("span",{className:"text-ink",children:k>0?`${k}%`:s.common.none})]}),e.jsx("input",{type:"range",min:0,max:50,step:5,value:k,onChange:t=>R(Number(t.target.value)),className:"w-full accent-ink"})]})]}),e.jsxs("div",{className:"mt-6 flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>v(!1),className:"flex-1 rounded-xl border border-border py-3 text-sm font-bold",children:s.mapPage.cancel}),e.jsx("button",{type:"button",onClick:be,className:"flex-1 rounded-xl bg-ink py-3 text-sm font-bold text-lime",children:s.common.apply})]})]})}),e.jsx("div",{className:"absolute bottom-6 left-0 right-0 z-20 mx-auto max-w-md px-4",children:e.jsx("div",{ref:C,className:"flex snap-x snap-mandatory gap-4 overflow-x-auto pb-4 pt-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden mask-image-gradient-side",children:K.length===0?e.jsxs("div",{className:"w-full rounded-2xl border border-dashed border-border/80 bg-background/95 p-6 text-center backdrop-blur-md",children:[e.jsx("p",{className:"text-sm font-bold text-foreground",children:s.mapPage.noResults}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:s.mapPage.noResultsHint}),e.jsx("button",{type:"button",onClick:z,className:"mt-3 rounded-xl bg-primary px-4 py-2 text-xs font-bold text-primary-foreground",children:s.mapPage.resetFilters})]}):K.map(({biz:t,distanceKm:n,campaign:a})=>{const c=P===t.id;return e.jsxs("div",{id:`carousel-card-${t.id}`,onClick:()=>I(t.id,t.lat,t.lng),className:`w-[310px] flex-none snap-center cursor-pointer rounded-2xl p-3.5 shadow-2xl transition-all duration-300 border flex gap-3 relative overflow-hidden ${c?"bg-background border-ink ring-4 ring-ink/10 scale-[1.02]":"bg-background/95 backdrop-blur-md border-border/80 hover:bg-background"}`,children:[c&&e.jsx("div",{className:"absolute -right-10 -bottom-10 h-32 w-32 rounded-full bg-ink/5 blur-2xl pointer-events-none"}),e.jsxs("div",{className:"relative w-20 h-20 rounded-xl overflow-hidden bg-secondary flex-shrink-0",children:[e.jsx("img",{src:a?a.image:t.logo,className:"w-full h-full object-cover",alt:t.name}),a&&e.jsx("div",{className:"absolute top-1 left-1 bg-ink text-lime text-[8px] font-black px-1.5 py-0.5 rounded-md shadow-md",children:a.discountLabel})]}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col justify-between",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1 justify-between",children:[e.jsxs("span",{className:"text-[10px] font-bold text-muted-foreground truncate",children:["@",t.handle]}),e.jsx("span",{className:"shrink-0 rounded-full bg-ink/10 px-1.5 py-0.5 text-[9px] font-bold text-ink",children:oe(n)})]}),e.jsx("h4",{className:"font-extrabold text-sm leading-snug text-foreground truncate mt-0.5",children:t.name}),a?e.jsx("p",{className:"text-[11px] text-muted-foreground line-clamp-1 mt-0.5",children:a.title}):e.jsx("p",{className:"text-[10px] text-muted-foreground italic mt-0.5",children:s.mapPage.noActiveCampaign})]}),a?e.jsxs("div",{className:"mt-2.5 flex items-center justify-between pt-1 border-t border-border/30",children:[e.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-muted-foreground font-semibold",children:[e.jsx(Fe,{className:"h-3 w-3 text-ink"}),p(s.mapPage.daysLeft,{count:a.daysLeft})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(b,{to:"/campaign/$id",params:{id:a.id},onClick:u=>u.stopPropagation(),className:"flex items-center justify-center text-[10px] font-black text-ink hover:text-ink/80 px-2 py-1 transition-all",children:s.mapPage.
24inspect}),e.jsxs(b,{to:"/campaign/$id/join",params:{id:a.id},onClick:u=>u.stopPropagation(),className:"flex items-center gap-0.5 bg-ink text-lime text-[10px] font-black px-2.5 py-1 rounded-lg hover:bg-ink/90 shadow-md active:scale-95 transition-all",children:[s.mapPage.join,e.jsx(re,{className:"h-3 w-3"})]})]})]}):e.jsx("span",{className:"text-[10px] text-muted-foreground italic",children:s.mapPage.visitAgain})]})]},t.id)})})})]})}export{tt as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.