import{Q as E,bq as k,br as j,bs as R,bt as U,N as M,l as F,a5 as X,F as w,a3 as G}from"./index-DXdAv5n3.js";import{r as h,u as $,f as H,j as m,L as q}from"./vendor-react-CVHocMAO.js";import{p as Q}from"./parseISO-BeqhIhSi.js";var B=class extends E{constructor(e,n){super(e,n)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type="infinite",super.setOptions(e)}getOptimisticResult(e){return e._type="infinite",super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,n){var p,v;const{state:r}=e,t=super.createResult(e,n),{isFetching:d,isRefetching:s,isError:l,isRefetchError:a}=t,u=(v=(p=r.fetchMeta)==null?void 0:p.fetchMore)==null?void 0:v.direction,i=l&&u==="forward",f=d&&u==="forward",c=l&&u==="backward",o=d&&u==="backward";return{...t,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:j(n,r.data),hasPreviousPage:k(n,r.data),isFetchNextPageError:i,isFetchingNextPage:f,isFetchPreviousPageError:c,isFetchingPreviousPage:o,isRefetchError:a&&!i&&!c,isRefetching:s&&!f&&!o}}};function Z(e,n){return R(e,B)}const S="plec_location",N=30;function Y(e,n,r=N){if(typeof document>"u")return;const t=new Date(Date.now()+r*864e5).toUTCString();document.cookie=`${e}=${encodeURIComponent(n)}; expires=${t}; path=/; SameSite=Lax`}function C(){const e=U(S);if(!e)return null;try{return JSON.parse(e)}catch{return null}}function x(e){Y(S,JSON.stringify(e),N)}const O=30*24*60*60*1e3;function ee(e){const n=I(e);if(!(n!=null&&n.city)||!(n!=null&&n.state))return;const r={city:n.city,state:n.state,detectedAt:new Date().toISOString()};x(r)}function te(){const e=C();return!(e!=null&&e.city)||!(e!=null&&e.state)||Date.now()-new Date(e.detectedAt).getTime()>=O?"":`${e.city}, ${e.state}`}function I(e){if(!e)return null;const n=e.trim(),t=n.replace(/,?\s*(USA|U\.S\.A\.?|US|United States)$/i,"").trim().match(/^([^,]+)[,\s]+([A-Z]{2}|[A-Za-z\s]+)$/);if(t){const d=t[1].trim();let s=t[2].trim();if(s.includes(",")&&(s=s.split(",")[0].trim()),s.length>2){const u=s.toLowerCase(),i={texas:"TX",california:"CA","new york":"NY",florida:"FL",pennsylvania:"PA",illinois:"IL",ohio:"OH",georgia:"GA","north carolina":"NC",michigan:"MI"};i[u]?s=i[u]:s=s.substring(0,2).toUpperCase()}else s=s.toUpperCase();const l={texas:"TX",california:"CA","new york":"NY",florida:"FL",pennsylvania:"PA",illinois:"IL",ohio:"OH",georgia:"GA","north carolina":"NC",michigan:"MI"},a=s.toLowerCase();return l[a]?s=l[a]:s.length>2&&(s=s.substring(0,2).toUpperCase()),{city:d,state:s.toUpperCase()}}return{city:n,state:"TX"}}function K(){if(typeof window>"u")return null;const n=new URLSearchParams(window.location.search).get("location");return!n||n.toLowerCase()==="nearby"||n.toLowerCase()==="current location"?null:I(n)}function W(){return new Promise(e=>{if(typeof navigator>"u"||!navigator.geolocation){e(null);return}navigator.geolocation.getCurrentPosition(async n=>{var d;const{latitude:r,longitude:t}=n.coords;try{const s=window.google;(d=s==null?void 0:s.maps)!=null&&d.Geocoder?new s.maps.Geocoder().geocode({location:{lat:r,lng:t}},(a,u)=>{if(u==="OK"&&(a!=null&&a[0])){const i=a[0].address_components,f=i.find(o=>o.types.includes("locality")),c=i.find(o=>o.types.includes("administrative_area_level_1"));if(f&&c){const o={city:f.long_name,state:c.short_name,formatted:a[0].formatted_address,coordinates:{lat:r,lng:t},detectedAt:new Date().toISOString()};x(o),e(o)}else e(null)}else e(null)}):e(null)}catch(s){console.warn("Geolocation error:",s),e(null)}},n=>{console.warn("Geolocation denied or failed:",n),e(null)},{timeout:5e3,maximumAge:3e5})})}function A(e,n){var t;const r=typeof window<"u"&&window.google;if((t=r==null?void 0:r.maps)!=null&&t.Geocoder)try{new r.maps.Geocoder().geocode({location:{lat:e,lng:n}},(s,l)=>{if(l!=="OK"||!(s!=null&&s[0]))return;const a=s[0].address_components,u=a.find(c=>c.types.includes("locality")),i=a.find(c=>c.types.includes("administrative_area_level_1"));if(!u||!i)return;const f={city:u.long_name,state:i.short_name,formatted:s[0].formatted_address,coordinates:{lat:e,lng:n},detectedAt:new Date().toISOString()};x(f)})}catch{}}const P=[{city:"Austin",state:"TX",lat:30.2672,lng:-97.7431},{city:"Houston",state:"TX",lat:29.7604,lng:-95.3698},{city:"Dallas",state:"TX",lat:32.7767,lng:-96.797},{city:"Philadelphia",state:"PA",lat:39.9526,lng:-75.1652}];function L(e,n,r){const t=e.toLowerCase(),d=n.toUpperCase();if(P.some(l=>l.city.toLowerCase()===t&&l.state===d))return{city:e,state:n};if(r){let l=P[0],a=1/0;for(const u of P){const i=r.lat-u.lat,f=r.lng-u.lng,c=Math.sqrt(i*i+f*f);c<a&&(a=c,l=u)}return{city:l.city,state:l.state}}return d==="TX"?["menchaca","round rock","cedar park","pflugerville","georgetown","leander","bee cave","lakeway","dripping springs","buddy","kyle","san marcos"].some(i=>t.includes(i)||i.includes(t))?{city:"Austin",state:"TX"}:["sugar land","the woodlands","pearland","katy","cypress","spring","league city","pasadena"].some(i=>t.includes(i)||i.includes(t))?{city:"Houston",state:"TX"}:["plano","frisco","irving","garland","mckinney","carrollton","richardson","allen","lewisville"].some(i=>t.includes(i)||i.includes(t))?{city:"Dallas",state:"TX"}:{city:"Austin",state:"TX"}:d==="PA"?["philadelphia","philly","conshehocken","bala cynwyd","wynnewood","ardmore"].some(a=>t.includes(a)||a.includes(t))?{city:"Philadelphia",state:"PA"}:{city:"Philadelphia",state:"PA"}:{city:"Austin",state:"TX"}}async function ae(e){const n=K();if(n){const a={...L(n.city,n.state),detectedAt:new Date().toISOString()};return x(a),a}const r=C();if(r&&Date.now()-new Date(r.detectedAt).getTime()<O){const a=L(r.city,r.state,r.coordinates);return{...r,...a}}const t=await Promise.race([W(),new Promise(l=>setTimeout(()=>l(null),3e3))]);if(t){const l=L(t.city,t.state,t.coordinates),a={...t,...l};return x(a),a}const d=(e==null?void 0:e.defaultCity)??{city:"Austin",state:"TX"};return{city:d.city,state:d.state,detectedAt:new Date().toISOString()}}function ne(){const[e,n]=h.useState(null),[r,t]=h.useState(!1),[d,s]=h.useState(!1),[l,a]=h.useState(!1),[u,i]=h.useState(!1),f=h.useCallback(()=>{if(!navigator.geolocation){t(!0),a(!1);return}s(!0),t(!1),a(!1);let c=null;"permissions"in navigator&&navigator.permissions.query({name:"geolocation"}).then(o=>{c=o.state,i(o.state==="denied"),o.addEventListener("change",()=>{o.state==="granted"?(i(!1),navigator.geolocation.getCurrentPosition(g=>{const p={lat:g.coords.latitude,lng:g.coords.longitude};n(p),A(p.lat,p.lng),t(!1),a(!1),s(!1)},()=>{s(!1)},{enableHighAccuracy:!1,timeout:1e4,maximumAge:0})):o.state==="prompt"&&(i(!1),a(!0),t(!1))})}).catch(()=>{}),navigator.geolocation.getCurrentPosition(o=>{const g={lat:o.coords.latitude,lng:o.coords.longitude};n(g),A(g.lat,g.lng),t(!1),a(!1),i(!1),s(!1)},o=>{s(!1),o.code===o.PERMISSION_DENIED?(t(!0),a(!0),i(c==="denied")):o.code===o.POSITION_UNAVAILABLE?(t(!0),a(!1),i(!1)):o.code===o.TIMEOUT&&(t(!1),a(!0),i(!1))},{enableHighAccuracy:!1,timeout:1e4,maximumAge:0})},[]);return h.useEffect(()=>{if(!navigator.geolocation){t(!0),a(!1);return}const c=C(),o=c==null?void 0:c.coordinates;if(o&&Number.isFinite(o.lat)&&Number.isFinite(o.lng)){n({lat:o.lat,lng:o.lng}),t(!1),a(!1),i(!1);return}"permissions"in navigator?navigator.permissions.query({name:"geolocation"}).then(g=>{g.state==="granted"?(f(),a(!1)):g.state==="prompt"?(t(!1),a(!0),i(!1)):g.state==="denied"&&(t(!0),a(!0),i(!0),g.addEventListener("change",()=>{g.state==="granted"?(i(!1),f()):g.state==="prompt"&&(i(!1),a(!0),t(!1))}))}).catch(()=>{f()}):f()},[f]),{location:e,permissionDenied:r,isRequesting:d,shouldShowPrompt:l,isBlocked:u,requestLocation:f}}const se=({onOpenSearch:e,searchQuery:n=""})=>{const r=$(),[t]=H(),d=r.pathname==="/services"||r.pathname.startsWith("/services"),s=t.get("category"),l=h.useRef(null),[a,u]=h.useState(!1);h.useEffect(()=>{const c=()=>{u(window.scrollY>12)};return c(),window.addEventListener("scroll",c,{passive:!0}),()=>window.removeEventListener("scroll",c)},[]);const{displayQuery:i,subtitle:f}=h.useMemo(()=>{const c=t.get("q"),o=t.get("location"),g=t.get("date")||t.get("start"),p=t.get("guests"),v=n||c||o||"",b=[];if(g)try{let y;if(g.includes("T"))y=Q(g);else{const[T,_,D]=g.split("-").map(Number);y=new Date(T,_-1,D)}b.push(M(y,"MMM d, yyyy"))}catch{}if(p){const y=parseInt(p,10);!isNaN(y)&&y>0&&b.push(`${y} ${y===1?"guest":"guests"}`)}return{displayQuery:v,subtitle:b.length>0?b.join(" • "):void 0}},[n,t]);return m.jsx("div",{ref:l,className:"sticky top-0 z-40 bg-white/95 border-b border-gray-200 shadow-sm backdrop-blur-md",children:m.jsxs("div",{className:w("px-4 transition-[padding] duration-200",a?"py-1.5":"py-4"),children:[m.jsxs("button",{type:"button",onClick:e,className:"w-full relative flex items-center rounded-full border border-gray-200 bg-white px-4 py-3 shadow-sm transition-colors hover:bg-gray-50 pointer-events-auto",children:[m.jsx(F,{className:"h-4 w-4 text-gray-500 flex-shrink-0"}),m.jsx("div",{className:"absolute inset-0 flex flex-col items-center justify-center text-center",children:i?m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"text-sm font-semibold text-gray-900 truncate w-full px-8",children:t.get("location")?`${d?"Services":"Venues"} in ${t.get("location")}`:i}),f&&m.jsx("div",{className:"text-xs text-gray-500 truncate mt-0.5 w-full px-8",children:f})]}):m.jsx("span",{className:"text-sm text-gray-500 w-full px-8",children:"Start your search"})})]}),m.jsx("div",{className:w("grid grid-cols-2 gap-2 text-[13px] font-semibold text-gray-900 transition-[margin] duration-200",a?"mt-1.5":"mt-3"),children:X.map(c=>{const o=d?c.id==="services":c.id==="venues"&&(r.pathname==="/"||r.pathname==="/venues"||r.pathname.startsWith("/venues")||!!s);return m.jsxs(q,{to:G(c.id,t),className:w("relative rounded-full px-3 text-center transition-all duration-200",a?"py-1.5":"py-2.5",o?"bg-white text-gray-950 shadow-sm ring-1 ring-gray-200":"text-gray-600 hover:bg-gray-50 active:bg-gray-100"),children:[m.jsxs("span",{className:w("inline-flex items-center justify-center truncate leading-tight transition-[gap] duration-200",a?"gap-1.5":"gap-2"),children:[!a&&m.jsx("img",{src:c.icon,alt:"","aria-hidden":"true",className:"h-6 w-6 flex-shrink-0 object-contain transition-transform duration-200"}),m.jsx("span",{className:w("truncate",a?"text-[11px]":"text-xs"),children:a?c.shortLabel:c.label})]}),o&&m.jsx("span",{"aria-hidden":"true",className:"absolute inset-x-8 bottom-1 h-0.5 rounded-full bg-[hsl(var(--brand))]"})]},c.id)})})]})})};export{se as U,Z as a,C as b,ae as c,te as g,I as p,ee as s,ne as u};