(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6164],{1522:function(e,t,a){Promise.resolve().then(a.bind(a,7271)),Promise.resolve().then(a.bind(a,5120)),Promise.resolve().then(a.bind(a,2393)),Promise.resolve().then(a.t.bind(a,5878,23)),Promise.resolve().then(a.t.bind(a,2972,23))},7271:function(e,t,a){"use strict";a.d(t,{default:function(){return o}});var n=a(7437),s=a(2265),r=a(8706),i=a(2876),c=a(2007);function o(e){let{initialRestaurants:t,totalCount:a,title:o,categoryId:l,businessTypeId:u}=e,d=(0,r.T)(),{location:g}=(0,i.T)(),[f,h]=(0,s.useState)(t),[m,x]=(0,s.useState)(0===a?t.length>0:t.length<a),[p,y]=(0,s.useState)(t.length),[v,w]=(0,s.useState)(!1),b=(0,s.useRef)(null);(0,s.useEffect)(()=>{h(t),y(t.length),x(0===a?t.length>0:t.length<a)},[t,a]);let j=(0,s.useCallback)(async()=>{if(!v&&m){w(!0);try{let e="&latitude=".concat(g.latitude,"&longitude=").concat(g.longitude),t=u?"&businessTypeId=".concat(u):"",a=l?"/api/homepage/marketing-category?categoryId=".concat(l,"&offset=").concat(p,"&limit=").concat(20).concat(e).concat(t):"/api/homepage/businesses?offset=".concat(p,"&limit=").concat(20).concat(e).concat(t),n=await fetch(a),s=await n.json();s.restaurants&&s.restaurants.length>0?(h(e=>{let t=new Set(e.map(e=>e.id)),a=s.restaurants.filter(e=>!t.has(e.id));return[...e,...a]}),y(e=>e+s.restaurants.length),x(s.hasMore)):x(!1)}catch(e){x(!1)}finally{w(!1)}}},[v,m,p,l,u,g.latitude,g.longitude]);(0,s.useEffect)(()=>{let e=b.current;if(!e)return;let t=new IntersectionObserver(e=>{e[0].isIntersecting&&j()},{rootMargin:"200px"});return t.observe(e),()=>t.disconnect()},[j]);let N=""===o?null:o||d("all_restaurants",{defaultValue:"T\xeb gjitha Restorantet"});return(0,n.jsxs)("section",{className:"py-5",children:[N&&(0,n.jsxs)("div",{className:"px-4 mb-4",children:[(0,n.jsx)("h2",{className:"text-xl font-bold text-gray-900 dark:text-white",children:N}),a>0&&(0,n.jsxs)("p",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1",children:[f.length," / ",a," ",d("restaurants_lowercase",{defaultValue:"restorante"})]})]}),(0,n.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4 px-4",children:f.map((e,t)=>(0,n.jsx)("div",{className:"w-full",children:(0,n.jsx)(c.Z,{restaurant:e,fullWidth:!0})},"".concat(e.id,"-").concat(t)))}),m&&(0,n.jsx)("div",{ref:b,className:"flex justify-center py-8",children:v&&(0,n.jsxs)("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[(0,n.jsxs)("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[(0,n.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,n.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),(0,n.jsx)("span",{className:"text-sm",children:d("loading_more",{defaultValue:"Duke ngarkuar..."})})]})})]})}},2876:function(e,t,a){"use strict";a.d(t,{LocationProvider:function(){return l},T:function(){return u}});var n=a(7437),s=a(2265),r=a(8685);let i=(0,s.createContext)(void 0),c="baboon-location",o={latitude:r.pH.AL.latitude,longitude:r.pH.AL.longitude,address:"Tiran\xeb, Shqip\xebri",isAutoDetected:!1};function l(e){let{children:t}=e,[a,r]=(0,s.useState)(o),[l,u]=(0,s.useState)(!1),[d,g]=(0,s.useState)(!1),[f,h]=(0,s.useState)(!1);(0,s.useEffect)(()=>{let e=function(){try{let e=localStorage.getItem(c);if(e)return JSON.parse(e)}catch(e){}return null}();e&&r(e),h(!0)},[]),(0,s.useEffect)(()=>{f&&localStorage.setItem(c,JSON.stringify(a))},[a,f]);let m=(0,s.useCallback)((e,t,a)=>{r({latitude:e,longitude:t,address:a,isAutoDetected:!1}),g(!1)},[]),x=(0,s.useCallback)(async()=>{if(navigator.geolocation){u(!0);try{let{latitude:e,longitude:t}=(await new Promise((e,t)=>{navigator.geolocation.getCurrentPosition(e,t,{enableHighAccuracy:!0,timeout:1e4,maximumAge:3e5})})).coords;try{let a=await fetch("https://nominatim.openstreetmap.org/reverse?format=json&lat=".concat(e,"&lon=").concat(t,"&accept-language=sq")),n=await a.json(),s=n.display_name?n.display_name.split(",").slice(0,3).join(",").trim():"".concat(e.toFixed(4),", ").concat(t.toFixed(4));r({latitude:e,longitude:t,address:s,isAutoDetected:!0})}catch(a){r({latitude:e,longitude:t,address:"".concat(e.toFixed(4),", ").concat(t.toFixed(4)),isAutoDetected:!0})}g(!1)}catch(e){}finally{u(!1)}}},[]);return(0,n.jsx)(i.Provider,{value:{location:a,setLocation:m,detectLocation:x,isDetecting:l,showLocationPicker:d,setShowLocationPicker:g},children:t})}function u(){let e=(0,s.useContext)(i);if(!e)throw Error("useLocation must be used within LocationProvider");return e}}},function(e){e.O(0,[8706,3557,2972,5878,6992,4448,2971,2117,1744],function(){return e(e.s=1522)}),_N_E=e.O()}]);