1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2527],{64908:(e,t,r)=>{r.r(t),r.d(t,{default:()=>m});var a=r(70022),s=r(55822),l=r(48774),o=r(25898),n=r(16518),i=r(46975),d=r(45483);r(97274);var c=r(86033),u=r(78360);let h=c._.NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN;function m(e){let{handleSelectAddress:t,longitude:r,latitude:c}=e,m=(0,n.useRef)(null),[f,v]=(0,n.useState)(r&&c?[r,c]:null),[b,w]=(0,n.useState)(""),[y]=(0,d.Q3)(b,300),[j,N]=(0,n.useState)([]),[_,k]=(0,n.useState)(!1);return(0,n.useEffect)(()=>{r&&c&&(v([r,c]),setTimeout(()=>{var e;null===(e=m.current)||void 0===e||e.flyTo({center:[r,c],zoom:14,duration:1e3})},100))},[r,c]),(0,n.useEffect)(()=>{if(!y.trim()){N([]),k(!1);return}(async()=>{let e=await g(y);N(e),k(e.length>0)})()},[y]),(0,a.jsxs)("div",{className:"relative h-96",children:[(0,a.jsx)("div",{className:"absolute left-2.5 right-2.5 top-2.5 z-10 flex max-w-3xl items-start gap-2",children:(0,a.jsxs)("div",{className:"w-[70%] rounded-lg bg-white shadow-md",children:[(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)(s.A,{className:"absolute left-3 top-1/2 z-10 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),(0,a.jsx)(u.p,{value:b,onChange:e=>w(e.target.value),onFocus:()=>k(!0),onBlur:()=>setTimeout(()=>k(!1),500),onKeyDown:e=>{"Enter"===e.key&&j.length>0&&(e.preventDefault(),x({suggestion:j[0],setMarkerCoords:v,mapRef:m,setShowSuggestions:k,setSuggestions:N,handleSelectAddress:t}))},name:"address",autoComplete:"address-line1",placeholder:"Search for an address...",className:"w-[95%] border-0 pl-10 pr-4 shadow-none focus-visible:ring-0"}),b&&(0,a.jsx)(l.A,{onClick:()=>{w("")},className:"absolute right-3 top-1/2 z-10 h-4 w-4 -translate-y-1/2 cursor-pointer text-muted-foreground"})]}),_&&!!j.length&&(0,a.jsx)("div",{className:"absolute left-0 right-0 top-full z-[1001] mt-1 max-h-60 w-[70%] overflow-y-auto rounded-lg border border-gray-200 bg-white shadow-lg",children:j.map((e,r)=>(0,a.jsx)("div",{className:"cursor-pointer border-b border-gray-100 px-4 py-3 last:border-b-0 hover:bg-gray-50",onClick:()=>x({suggestion:e,setMarkerCoords:v,mapRef:m,setShowSuggestions:k,setSuggestions:N,handleSelectAddress:t}),children:(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)(s.A,{className:"mt-0.5 h-4 w-4 flex-shrink-0 text-gray-400"}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("div",{className:"truncate text-sm font-medium text-gray-900",children:e.text}),(0,a.jsx)("div",{className:"text-xs text-gray-500",children:e.place_name})]})]})},r))})]})}),(0,a.jsx)(i.Ay,{ref:m,initialViewState:{longitude:r||-122.4,latitude:c||37.8,zoom:14},style:{width:"100%",height:"100%"},mapStyle:"mapbox://styles/mapbox/streets-v12",mapboxAccessToken:h,attributionControl:!1,children:f&&(0,a.jsx)(i.pH,{longitude:f[0],latitude:f[1],draggable:!0,onDragEnd:async e=>{let{lng:r,lat:a}=e.lngLat;v([r,a]);let s=await p(r,a);s?await t({address:s.address,city:s.city,state:s.state,zip:s.zip,latitude:a,longitude:r}):await t({latitude:a,longitude:r})},children:(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("div",{className:"flex h-11 w-11 cursor-move items-center justify-center rounded-full border-2 border-white bg-gray-900 shadow-lg",children:(0,a.jsx)(o.A,{className:"h-5 w-5 text-white"})}),(0,a.jsx)("div",{className:"absolute left-1/2 top-full -translate-x-1/2 -translate-y-1 transform",children:(0,a.jsx)("div",{className:"h-0 w-0 border-l-8 border-r-8 border-t-8 border-l-transparent border-r-transparent border-t-gray-900"})})]})})})]})}let p=async(e,t)=>{if(!h)return console.error("Mapbox access token not found"),null;try{let r=await fetch("https://api.mapbox.com/geocoding/v5/mapbox.places/".concat(e,",").concat(t,".json?access_token=").concat(h,"&types=address,poi&limit=1")),a=await r.json();if(a.features&&a.features.length>0){let r=a.features[0],s=r.context||[],l=e=>{var t;return(null===(t=s.find(t=>t.id.includes(e)))||void 0===t?void 0:t.text)||""},o=r.place_name.split(",")[0]||r.text||"",n=l("place")||"",i=(()=>{let e=s.find(e=>e.id.includes("region"));return(null==e?void 0:e.short_code)&&e.short_code.split("-")[1]||""}
1)(),d=l("postcode")||"",c=[o,n,i,d].filter(Boolean).join(", ");return{address:o,city:n,state:i,zip:d,addressText:c,latitude:t,longitude:e}}return null}catch(e){return console.error("Error with reverse geocoding:",e),null}},x=async e=>{var t;let{suggestion:r,setMarkerCoords:a,mapRef:s,setShowSuggestions:l,setSuggestions:o,handleSelectAddress:n}=e,[i,d]=r.center,c=r.context||[],u=e=>{var t;return(null===(t=c.find(t=>t.id.includes(e)))||void 0===t?void 0:t.text)||""},h={address:r.place_name.split(",")[0]||r.text||"",city:u("place")||"",state:(()=>{let e=c.find(e=>e.id.includes("region"));return(null==e?void 0:e.short_code)&&e.short_code.split("-")[1]||""})(),zip:u("postcode")||"",latitude:d,longitude:i};a([i,d]),null===(t=s.current)||void 0===t||t.flyTo({center:[i,d],zoom:14,speed:1.2}),l(!1),o([]),await n(h)},g=async e=>{if(!h)return console.error("Mapbox access token not found"),[];try{let t=await fetch("https://api.mapbox.com/geocoding/v5/mapbox.places/".concat(encodeURIComponent(e),".json?access_token=").concat(h,"&country=US&types=address,poi&limit=5"));return(await t.json()).features||[]}catch(e){return console.error("Error fetching suggestions:",e),[]}}}}]);
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.