1import{c as st,b as at,r as a,_ as it,j as e,f as ot,t as u}from"./index-Cf_ajVON.js";import{B as E}from"./button-B3Z62-N_.js";import{I as z}from"./input-B3lgn3HG.js";import{L as F}from"./label-CPIICQK5.js";import{u as nt}from"./UserRouter-8XtuC7qu.js";import{u as lt}from"./ProfileContext-BZ3PpXCb.js";import"./index-BZFWozEr.js";import{L as Ne}from"./index-93e-Jyro.js";import{A as je}from"./AnimatedPage-B7ZsTwkH.js";import{u as dt}from"./useAppBackNavigation-CgW7jO2C.js";import{r as de,g as ct,a as ke}from"./googleGeocoding-kn-gUS38.js";import{C as ze}from"./chevron-left-DBuShpHf.js";import{S as Ce}from"./search-CI5-KVok.js";import{X as Ae}from"./x-BzwCsDoT.js";import{M as te}from"./map-pin-7Ib88_8s.js";import{N as ut}from"./navigation-Bq1tKfII.js";import{C as re}from"./chevron-right-Bcul0bS7.js";import{P as mt}from"./plus-BpcropP-.js";import{P as pt}from"./pencil-u9GUEip8.js";import{T as Se}from"./trash-2-B1Y_baWX.js";import{H as De}from"./house-DmDkqbY-.js";import{B as xt}from"./briefcase-3ehau_sR.js";import{B as ft}from"./building-2-RhnM0eh6.js";import"./index-Bx4n9Pg3.js";import"./index-DvNrSChk.js";import"./index-D2QmRZ8G.js";import"./foodVariants-COegQ4Wo.js";import"./clock-BLUAwf4T.js";import"./proxy-C1jOxt1V.js";import"./truck-QhgJc4-J.js";import"./shopping-bag-DS7253no.js";import"./tag-BuvDaRmB.js";import"./utensils-crossed-CcT55kZ-.js";import"./switch-Br_IXA23.js";import"./index-BH0fEq1S.js";import"./index-Dr9tQ8T6.js";import"./index-J_fU13zv.js";import"./quicky-spicy-logo-BF3ck9UZ.js";import"./businessSettings-C2lRlxRl.js";import"./chevron-down-DvOvGc9V.js";import"./wallet-Fp8jgvR5.js";import"./shopping-cart-qTOihUB7.js";import"./index-C8y2MLsj.js";import"./index-BkL6vOXg.js";import"./useNotificationInbox-VAdTR4w4.js";import"./log-out-CnE_25s1.js";import"./useCompanyName-BqFrmMXi.js";import"./phone-DYx2euUu.js";import"./mail-BWqemxpl.js";import"./twitter-DzJYxJDu.js";import"./heart-ClQB289i.js";import"./card-Dg3aNavH.js";import"./checkbox--5h1dBUf.js";import"./index-BgkASZz5.js";import"./check-DGtdSv1T.js";import"./index-Bkla0msJ.js";import"./index-CeGv2iRN.js";import"./OptimizedImage-BXY4yO8G.js";import"./dish_fallback-D6DhqKcF.js";import"./routes-B2m2vR37.js";import"./circle-check-CLROJLC6.js";import"./bell-DTCvULxx.js";import"./index.esm-BzR8oUpF.js";import"./utensils-cjWp27Tl.js";import"./zap-TlV55XhQ.js";import"./shopping-basket-BQqZHEve.js";import"./star-B2ou6rgX.js";import"./sliders-horizontal-DI91i5Lq.js";import"./circle-alert-Dghg6EjM.js";import"./indian-rupee-Jn7bSe7x.js";import"./shield-check-eqx3FUHD.js";import"./ProtectedRoute-D0_enUO-.js";import"./Loader-DmtRw6uv.js";import"./AuthRedirect-BEzTws_f.js";import"./common-K-jRlMr2.js";const gt=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]],ht=st("crosshair",gt),Le="pl-12 pr-10 h-14 bg-white dark:bg-[#1a1a1a] border-2 border-zinc-200/90 dark:border-zinc-700 rounded-2xl focus:ring-0 focus-visible:ring-0 focus-visible:ring-offset-0 focus:border-zinc-400 dark:focus:border-zinc-500 text-zinc-900 dark:text-zinc-50 placeholder:!text-neutral-400 dark:placeholder:!text-neutral-500 font-medium text-sm transition-all shadow-sm w-full",bt=d=>{const m=(d.label||d.additionalDetails||"").toLowerCase();return m.includes("home")?De:m.includes("work")||m.includes("office")?xt:m.includes("building")||m.includes("apt")?ft:De},yt=d=>{const m=d?.location?.coordinates;if(Array.isArray(m)&&m.length>=2){const I=Number(m[0]),g=Number(m[1]);if(Number.isFinite(g)&&Number.isFinite(I))return{lat:g,lng:I}}const l=Number(d?.latitude??d?.lat),G=Number(d?.longitude??d?.lng);return Number.isFinite(l)&&Number.isFinite(G)?{lat:l,lng:G}:null},wt=d=>{const m=String(d||"Home").toLowerCase();return m.includes("office")||m.includes("work")?"Work":m.includes("other")?"Other":"Home"},vt=d=>d?[d.additionalDetails,d.street,d.city,d.state,d.zipCode].filter(Boolean).join(", "):"",se=220,Nt=()=>{u.custom(()=>e.jsxs("div",{className:"w-[calc(100vw-28px)] sm:w-[340px] flex items-center gap-2.5 py-2 px-3 rounded-2xl bg-white/72 dark:bg-zinc-900/72 backdrop-blur-xl border border-white/60 dark:border-white/10 shadow-[0_8px_28px_rgba(0,0,0,0.14)] ring-1 ring-black/5 animate-in fade-in slide-in-from-top-2 duration-300",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-gradient-to-br from-[#DC2626]/95 to-[#991B1B]/95 flex items-center justify-center p-0.5
1shadow-md flex-shrink-0",children:e.jsx("img",{src:"/assets/images/redgo-toast-logo.png",alt:"RedGo",className:"w-full h-full object-contain brightness-0 invert scale-110"})}),e.jsx("p",{className:"text-[13px] font-semibold text-gray-900/90 dark:text-white leading-none pr-1",children:"Address Removed Successfully"})]}),{id:"address-removed-toast",duration:4e3,position:"top-center",unstyled:!0})};function Kr(){const d=at(),m=dt(),{location:l,requestLocation:G,requestLocationFast:I}=nt(),{addresses:g=[],addAddress:Ee,updateAddress:Fe,deleteAddress:Ie,setDefaultAddress:ce,userProfile:jt,isAuthenticated:H,loading:Me}=lt(),[h,U]=a.useState(!1),[C,$]=a.useState(null),[b,q]=a.useState(null),[V,ue]=a.useState(!1),y=a.useRef(null),[x,M]=a.useState(()=>{try{const r=localStorage.getItem("userLocation");if(r){const t=JSON.parse(r);if(Number.isFinite(t?.latitude)&&Number.isFinite(t?.longitude))return[t.latitude,t.longitude]}}catch{}return[22.7196,75.8577]}),[n,w]=a.useState({street:"",city:"",state:"",zipCode:"",additionalDetails:"",label:"Home",phone:""}),[Pe,P]=a.useState(!1),[K,me]=a.useState(!1),[pe,xe]=a.useState(!1),[_e,Y]=a.useState(!1),_=a.useRef(null),W=a.useRef(null);a.useRef(null),a.useRef(null),a.useRef(null);const[j,J]=a.useState(""),[v,N]=a.useState(""),[Z,k]=a.useState([]),[fe,ae]=a.useState(!1),[kt,zt]=a.useState(!0),[ie,Re]=a.useState(null),[ge,Te]=a.useState(!1),oe=a.useRef(null),R=a.useRef(null),ne=a.useRef(null),A=a.useRef(x),T=a.useRef(null),[he,be]=a.useState(0),[X,Be]=a.useState(0),[Oe,Ge]=a.useState(320),ye=a.useRef(null),S=a.useRef({}),He=!0,D=r=>r?.id||r?._id||null,Ue=a.useCallback(r=>{const t=r==="open";return{opacity:t?1:0,transform:t?"translateY(0) scale(1)":"translateY(10px) scale(0.97)",transition:`transform ${se}ms cubic-bezier(0.16, 1, 0.3, 1), opacity ${se-40}ms ease`,willChange:"transform, opacity"}},[]),Q=a.useCallback(()=>{q(r=>r?{...r,phase:"exit"}:null),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{q(null),y.current=null},se)},[]);a.useEffect(()=>{if(b?.phase!=="enter")return;const r=requestAnimationFrame(()=>{requestAnimationFrame(()=>{q(t=>t?.phase==="enter"?{...t,phase:"open"}:t)})});return()=>cancelAnimationFrame(r)},[b?.phase]),a.useEffect(()=>()=>{y.current&&clearTimeout(y.current)},[]);const B=()=>{m()};a.useMemo(()=>{const r=String(v||"").trim().toLowerCase();return r?(Array.isArray(g)?g:[]).map(s=>{const o=[s?.label,s?.additionalDetails,s?.street,s?.city,s?.state,s?.zipCode].filter(Boolean).join(" ").toLowerCase();return{addr:s,text:o}}).filter(s=>s.text.includes(r)).slice(0,6).map(s=>s.addr):[]},[g,v]),a.useEffect(()=>{let r=!1;return it(async()=>{const{getGoogleMapsApiKey:t}=await import("./googleMapsApiKey-COZSPuTB.js");return{getGoogleMapsApiKey:t}},[]).then(({getGoogleMapsApiKey:t})=>{t().then(async s=>{if(!(r||!s)){Re(s);try{const i=await new Ne({apiKey:s,version:"weekly",libraries:["places"]}).load();if(r)return;oe.current=i,R.current=new i.maps.places.AutocompleteService,Te(!0)}catch{}}})}),()=>{r=!0}},[]),a.useEffect(()=>{const r=t=>{if(!t)return;const o=(t.formattedAddress||t.address||"").replace(/^[a-z0-9]{2,8}\+[a-z0-9]{0,3}[,\s]*/i,"").replace(/,\s*India$/,"");if(o&&J(o),Number.isFinite(Number(t.latitude))&&Number.isFinite(Number(t.longitude))){const i=[Number(t.latitude),Number(t.longitude)];M(i),A.current=i}};r(l);try{const t=localStorage.getItem("userLocation");t&&r(JSON.parse(t))}catch{}},[]),a.useEffect(()=>{const r=l?.formattedAddress||l?.address,t=r?r.replace(/^[a-z0-9]{2,8}\+[a-z0-9]{0,3}[,\s]*/i,"").replace(/,\s*India$/,""):"";t&&J(t)},[l?.formattedAddress,l?.address,l?.latitude,l?.longitude]),a.useEffect(()=>{const r=String(v||"").trim();if(!ge||!R.current||r.length<3){k([]),ae(!1);return}const t=setTimeout(()=>{ae(!0);const s=oe.current,o=R.current,i={input:r,componentRestrictions:{country:"in"}};Number.isFinite(l?.latitude)&&Number.isFinite(l?.longitude)&&(i.location=new s.maps.LatLng(l.latitude,l.longitude),i.radius=5e4),o.getPlacePredictions(i,(c,f)=>{if(ae(!1),f!==s.maps.places.PlacesServiceStatus.OK||!Array.isArray(c)){k([]);return}k(c.slice(0,6).map(p=>({id:p.place_id,placeId:p.place_id,display:p.description})))})},350);return()=>clearTimeout(t)},[v,ge,l?.latitude,l?.longitude]);const L=a.useCallback((r,t)=>{const s=t||r?.formattedAddress||r?.address||"",o=s.replace(/^[a-z0-9]{2,8}\+[a-z0-9]{0,3}[,\s]*/i,"").replace(/,\s*India$/,"");J(o),w(i=>{let c=r?.area||r?.address||s.split(",")[0]||i.street;return c&&(c=c.replace(/^[a-z0-9]{2,8}\+[a-z0-9]{0,3}[,\s]*/i,"").replace(/,\s*India$/,"").trim(),c.endsWith(",")&&(c=c.slice(0,-1).trim())),{...i,street:c||i.street,city:r?.city||i.city,state:r?.state||i.state,zipCode:r?.pincode||i.zipCode}}
1)},[]),we=a.useCallback(async(r,t)=>{ne.current&&clearTimeout(ne.current),ne.current=setTimeout(async()=>{try{const s=await de(r,t);L(s)}catch{}},400)},[He,L]);a.useEffect(()=>{if(!h||!ie)return;let r=!0;return Y(!0),(async()=>{try{let s=0;for(;!_.current&&s<10;)await new Promise(p=>setTimeout(p,50)),s++;if(!r||!_.current){Y(!1);return}const i=await new Ne({apiKey:ie,version:"weekly",libraries:["places"]}).load();if(!r||!_.current)return;oe.current=i,R.current||(R.current=new i.maps.places.AutocompleteService);const c={lat:A.current[0],lng:A.current[1]},f=new i.maps.Map(_.current,{center:c,zoom:16,mapTypeId:i.maps.MapTypeId.ROADMAP,disableDefaultUI:!0,zoomControl:!0,gestureHandling:"greedy"});if(W.current=f,T.current){const p=T.current;f.panTo({lat:p.lat,lng:p.lng}),f.setZoom(p.zoom||17),T.current=null}f.addListener("idle",()=>{const p=f.getCenter(),ee=p.lat(),ve=p.lng();M([ee,ve]),we(ee,ve)}),Y(!1)}catch{Y(!1)}})(),()=>{r=!1}},[h,ie,we]);const $e=async()=>{try{P(!0),(typeof I=="function"?await I():await G())?(sessionStorage.setItem("manual_location_update","true"),localStorage.setItem("deliveryAddressMode","current"),window.dispatchEvent(new CustomEvent("userLocationUpdated")),B()):P(!1)}catch{P(!1),u.error("Failed to get current location",{id:"geo"})}},qe=async r=>{const t=D(r);if(t){sessionStorage.setItem("manual_location_update","true"),ce(t);try{localStorage.setItem("deliveryAddressMode","saved"),window.dispatchEvent(new CustomEvent("userLocationUpdated")),B()}catch(s){console.error("Failed to select saved address:",s)}}},le=a.useCallback(async(r,t,s=17)=>{M([r,t]),A.current=[r,t];const o=()=>W.current?(W.current.panTo({lat:r,lng:t}),W.current.setZoom(s),!0):!1;if(!o()){T.current={lat:r,lng:t,zoom:s};for(let i=0;i<30;i+=1)if(await new Promise(c=>setTimeout(c,100)),o()){T.current=null;return}}},[]),Ve=async()=>{if(!K){me(!0);try{const r=await ct(),{latitude:t,longitude:s}=r;await le(t,s);const o=await de(t,s);L(o),u.success("Moved to your current location",{id:"geo-map"})}catch(r){console.error("Map GPS error:",r),l?.latitude&&l?.longitude?(await le(l.latitude,l.longitude),L(l,l.formattedAddress||l.address),u.info("Using last known location",{id:"geo-map"})):u.error("Allow location permission to use GPS",{id:"geo-map"})}finally{me(!1)}}},Ke=async r=>{P(!0);try{let t,s,o,i;if(r.placeId)i=await ke(r.placeId),t=i.latitude,s=i.longitude,o=i.formattedAddress;else if(r.lat&&r.lng)t=r.lat,s=r.lng,o=r.display,i=await de(t,s);else{u.error("Could not resolve location coordinates");return}const c={latitude:t,longitude:s,city:i.city||"",state:i.state||"",country:i.country||"India",area:i.area||"",address:i.address||o,formattedAddress:o||i.formattedAddress,pincode:i.pincode||""};localStorage.setItem("userLocation",JSON.stringify(c)),sessionStorage.setItem("manual_location_update","true"),localStorage.setItem("deliveryAddressMode","current"),window.dispatchEvent(new CustomEvent("userLocationUpdated")),B()}catch(t){console.error("Error selecting search suggestion:",t),u.error("Failed to select location")}finally{P(!1)}},Ye=async r=>{try{const t=await ke(r.placeId||r.id),s=t.latitude,o=t.longitude;if(!Number.isFinite(s)||!Number.isFinite(o)){u.error("Could not resolve location coordinates");return}await le(s,o),N(t.formattedAddress||r.display||""),L(t),k([])}catch(t){console.error("Error selecting map suggestion:",t),u.error("Failed to select location")}},We=a.useCallback(()=>{if(Number.isFinite(l?.latitude)&&Number.isFinite(l?.longitude))return l;try{const r=localStorage.getItem("userLocation");if(r){const t=JSON.parse(r);if(Number.isFinite(t?.latitude)&&Number.isFinite(t?.longitude))return t}}catch{}return Number.isFinite(x[0])&&Number.isFinite(x[1])?{latitude:x[0],longitude:x[1],formattedAddress:j,address:j}:null},[l,x,j]),Je=()=>{if(!H){u.info("Please login to add an address"),d("/user/auth/login");return}$(null),N(""),k([]);const r=We();r?.latitude&&r?.longitude&&(A.current=[r.latitude,r.longitude],M([r.latitude,r.longitude]),L(r,r.formattedAddress||r.address||j)),U(!0)},Ze=(r,t)=>{if(r.stopPropagation(),!H){u.info("Please login to edit an address"),d("/user/auth/login");return}const s=D(t);if(!s)return;const o=yt(t);$(s),N(""),k([]),w({street:t.street||"",city:t.city||"",state:t.state||"",zipCode:t.zipCode||"",additionalDetails:t.additionalDetails||"",label:wt(t.label),phone:t.phone||""}),J([t.additionalDetails,t.street,t.city,t.state,t.zipCode].filter(
1Boolean).join(", ")),o&&(A.current=[o.lat,o.lng],M([o.lat,o.lng])),U(!0)},Xe=(r,t)=>{if(r.stopPropagation(),!H){u.info("Please login to delete an address"),d("/user/auth/login");return}y.current&&clearTimeout(y.current),q({address:t,phase:"enter"})},Qe=async()=>{const r=D(b?.address);if(!r){Q();return}ue(!0);try{await Ie(r),Q(),Nt()}catch{u.error("Failed to delete address")}finally{ue(!1)}},et=()=>{N(""),k([]),$(null),U(!1)},O=a.useCallback(r=>{const t=S.current?.[r];t&&setTimeout(()=>{try{const s=ye.current;if(!s){t.scrollIntoView({behavior:"smooth",block:"center"});return}const o=s.getBoundingClientRect(),i=t.getBoundingClientRect(),f=(typeof window<"u"&&window.visualViewport?window.visualViewport.height:window.innerHeight)-X-90,p=i.bottom-f;if(p>0){s.scrollTo({top:s.scrollTop+p+24,behavior:"smooth"});return}if(i.top<o.top+70){const ee=o.top+70-i.top;s.scrollTo({top:Math.max(0,s.scrollTop-ee-12),behavior:"smooth"});return}t.scrollIntoView({behavior:"smooth",block:"center"})}catch{}},120)},[X]),tt=(r,t,s)=>Math.min(s,Math.max(t,r)),rt=async r=>{if(r.preventDefault(),!H){u.info("Please login to save an address"),d("/user/auth/login");return}if(!n.street||!n.city){u.error("Please fill required fields");return}xe(!0);try{const t={...n,label:n.label==="Work"?"Office":n.label,location:{type:"Point",coordinates:[x[1],x[0]]},latitude:x[0],longitude:x[1]};if(C){const o=await Fe(C,t);if(o){try{const i=g.find(f=>f.isDefault)||o;if(String(D(i))===String(C)||!!o?.isDefault){sessionStorage.setItem("manual_location_update","true"),localStorage.setItem("deliveryAddressMode","saved");const f={latitude:x[0],longitude:x[1],city:n.city||"",state:n.state||"",address:[n.street,n.city,n.state,n.zipCode].filter(Boolean).join(", "),area:n.additionalDetails||n.street||"",pincode:n.zipCode||"",formattedAddress:[n.street,n.city,n.state,n.zipCode].filter(Boolean).join(", ")};localStorage.setItem("userLocation",JSON.stringify(f)),window.dispatchEvent(new CustomEvent("userLocationUpdated"))}}catch{}u.success("Address updated"),$(null),U(!1)}return}const s=await Ee(t);if(s){const o=D(s);o&&await ce(o);try{sessionStorage.setItem("manual_location_update","true"),localStorage.setItem("deliveryAddressMode","saved");const i={latitude:x[0],longitude:x[1],city:n.city||"",state:n.state||"",address:[n.street,n.city,n.state,n.zipCode].filter(Boolean).join(", "),area:n.additionalDetails||n.street||"",pincode:n.zipCode||"",formattedAddress:[n.street,n.city,n.state,n.zipCode].filter(Boolean).join(", ")};localStorage.setItem("userLocation",JSON.stringify(i)),window.dispatchEvent(new CustomEvent("userLocationUpdated"))}catch{}B()}}catch{u.error("Failed to save address")}finally{xe(!1)}};if(a.useEffect(()=>{if(!h)return;const r=()=>{const t=typeof window<"u"?window.innerHeight:800,s=Math.round(t*.45);Ge(Math.max(260,Math.min(420,s)))};return r(),window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)},[h]),a.useEffect(()=>{h&&be(0)},[h]),a.useEffect(()=>{if(!h||typeof window>"u"||!window.visualViewport)return;const r=window.visualViewport,t=()=>{const s=Math.max(0,window.innerHeight-r.height-r.offsetTop);Be(s>0?s:0)};return t(),r.addEventListener("resize",t),r.addEventListener("scroll",t),()=>{r.removeEventListener("resize",t),r.removeEventListener("scroll",t)}},[h]),h){const r=Oe;return e.jsxs(je,{className:"fixed inset-0 z-50 bg-white dark:bg-[#0a0a0a] flex flex-col h-screen overflow-hidden",children:[e.jsxs("div",{className:"flex-shrink-0 bg-white dark:bg-[#1a1a1a] border-b border-gray-100 dark:border-gray-800 px-4 py-3 flex items-center gap-4",children:[e.jsx(E,{variant:"ghost",size:"icon",onClick:et,className:"rounded-full",children:e.jsx(ze,{className:"h-6 w-6"})}),e.jsx("h1",{className:"text-lg font-bold",children:C?"Edit delivery location":"Add delivery location"})]}),e.jsxs("div",{ref:ye,onScroll:t=>{be(t.currentTarget.scrollTop)},className:"flex-1 overflow-y-auto",style:{paddingBottom:`${96+X}px`},children:[e.jsxs("div",{className:"flex-shrink-0 relative z-0",style:{height:`${r}px`,transform:`translateY(${he*.4}px)`,opacity:tt(1-he/500,.4,1)},children:[e.jsx("div",{className:"absolute top-4 left-4 right-4 z-20",children:e.jsxs("div",{className:"relative group shadow-2xl",children:[e.jsx("div",{className:"absolute inset-y-0 left-0 pl-4 flex items-center pointer-events-none",children:e.jsx(Ce,{className:"h-5 w-5 text-neutral-400 dark:text-neutral-500"})}
1),e.jsx(z,{value:v,onChange:t=>N(t.target.value),placeholder:"Search area, street, landmark...",className:Le}),v&&e.jsx("button",{onClick:()=>N(""),className:"absolute right-3.5 top-1/2 -translate-y-1/2 p-1 rounded-full hover:bg-zinc-200 dark:hover:bg-zinc-800 text-zinc-400 hover:text-zinc-600 dark:hover:text-zinc-200 transition-colors",children:e.jsx(Ae,{className:"h-4 w-4"})}),fe&&e.jsx("div",{className:"absolute right-10 top-1/2 -translate-y-1/2",children:e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-2 border-[#DC2626] border-t-transparent"})}),Z.length>0&&e.jsxs("div",{className:"absolute top-full left-0 right-0 mt-2 bg-white dark:bg-[#1a1a1a] rounded-xl shadow-2xl border border-gray-100 dark:border-gray-800 overflow-hidden z-30 animate-in fade-in slide-in-from-top-2 duration-200",children:[e.jsx("p",{className:"px-4 py-2 text-[10px] font-bold uppercase tracking-wider text-gray-400 bg-gray-50 dark:bg-gray-800/50",children:"Suggestions"}),Z.map(t=>e.jsxs("button",{onClick:()=>Ye(t),className:"w-full px-4 py-3 flex items-start gap-3 hover:bg-[#DC2626]/5 dark:hover:bg-[#DC2626]/10 transition-colors text-left border-b border-gray-50 dark:border-gray-800 last:border-none",children:[e.jsx(te,{className:"h-4 w-4 text-gray-400 mt-1 flex-shrink-0"}),e.jsx("div",{className:"min-w-0",children:e.jsx("p",{className:"text-sm font-semibold text-gray-900 dark:text-white truncate",children:t.display})})]},t.id))]})]})}),e.jsx("div",{ref:_,className:"w-full h-full bg-gray-100 dark:bg-gray-800"}),e.jsx("div",{className:"absolute inset-0 pointer-events-none flex items-center justify-center",children:e.jsxs("div",{className:"relative mb-8 flex flex-col items-center",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center p-2 mb-[-6px] shadow-sm animate-bounce-short",children:e.jsx("div",{className:"w-6 h-6 rounded-full bg-green-600 flex items-center justify-center border-2 border-white",children:e.jsx("div",{className:"w-2 h-2 rounded-full bg-white animate-pulse"})})}),e.jsx("div",{className:"w-1.5 h-6 bg-green-600 border-x border-white shadow-xl rounded-b-full shadow-green-900/40"}),e.jsx("div",{className:"w-3 h-1.5 bg-black/20 rounded-full blur-[1px] transform scale-x-150 absolute bottom-[-4px]"})]})}),_e&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-white/50 backdrop-blur-sm z-10",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-[#DC2626]"})}),e.jsx("div",{className:"absolute bottom-10 right-4 z-10 pointer-events-auto",children:e.jsxs(E,{type:"button",onClick:Ve,disabled:K,className:"bg-white text-black hover:bg-gray-100 shadow-xl border border-gray-200 rounded-full h-12 px-6 disabled:opacity-70",children:[K?e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-2 border-[#DC2626] border-t-transparent mr-2"}):e.jsx(ut,{className:"h-4 w-4 mr-2 text-[#DC2626]"}),K?"Locating...":"Use My Location"]})})]}),e.jsxs("div",{className:"relative bg-white dark:bg-[#0a0a0a] rounded-t-[32px] -mt-8 z-10 p-4 space-y-6 shadow-[0_-12px_24px_-10px_rgba(0,0,0,0.1)]",children:[e.jsxs("div",{className:"bg-[#DC2626]/5 dark:bg-[#DC2626]/10 border border-[#DC2626]/10 dark:border-[#DC2626]/20 rounded-xl p-4 flex gap-3",children:[e.jsx(te,{className:"h-5 w-5 text-[#DC2626] mt-0.5"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-bold text-[#DC2626] dark:text-[#DC2626]/80 uppercase mb-1",children:"Pinnned Location"}),e.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300 line-clamp-2",children:j||"Select a location on map"})]})]}),e.jsxs("div",{children:[e.jsx(F,{className:"text-sm font-bold mb-2 block",children:"Primary Address (Street / Area / Landmark)"}),e.jsx(z,{placeholder:"Search or drag to update street/area",value:n.street,onChange:t=>w({...n,street:t.target.value}),onFocus:()=>O("street"),ref:t=>{S.current.street=t},className:"mb-4 h-12 rounded-xl bg-gray-50 dark:bg-gray-800/50",required:!0}),e.jsx(F,{className:"text-sm font-bold mb-2 block text-gray-700 dark:text-gray-300",children:"Secondary Address (House No. / Flat / Floor)"}),e.jsx(z,{placeholder:"E.g. Flat 402, 4th Floor, AppZeto Building",value:n.additionalDetails,onChange:t=>w({...n,additionalDetails:t.target.value}),onFocus:()=>O("additionalDetails"),ref:t=>{S.current.additionalDetails=t},className:"h-12 rounded-xl border-gray-200 dark:border-gray-800 focus:ring-[#DC2626]"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(F,{className:"text-xs mb-1 block",children:"City"}),e.jsx(z,{value:n.city,onChange:t=>w({...n,city:t.target.value}),onFocus:()=>O("city"),ref:t=>{S.current.city=t},className:"h-12 rounded-xl",required:!0})]}),e.jsxs("div",{children:[e.jsx(F,{className:"text-xs mb-1 block",children:"State"}),e.jsx(z,{value:n.state,onChange:t=>w({...n,state:t.target.value}),onFocus:()=>O("state"),ref:t=>{S.current.state=t},className:"h-12 rounded-xl",required:!0})]})]}),e.jsxs("div",{children:[e.jsx(F,{className:"text-xs mb-1 block",children:"Pincode / ZIP"}),e.jsx(z,{placeholder:"Pincode",value:n.zipCode||"",onChange:t=>w({...n,zipCode:t.target.value}),onFocus:()=>O("zipCode"),ref:t=>{S.current.zipCode=t},className:"h-12 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx(F,{className:"text-sm font-bold mb-2 block",children:"Save address as"}),e.jsx("div",{className:"flex gap-2",children:[{value:"Home",label:"Home"},{value:"Work",label:"Work"},{value:"Other",label:"Other"}].map(({value:t,label:s})=>{const o=n.label===t;return e.jsx("button",{type:"button",onClick:()=>w({...n,label:t}),className:`flex-1 h-11 rounded-xl text-sm font-semibold transition-colors ${o?"bg-[#DC2626] text-white shadow-sm":"bg-zinc-100 dark:bg-zinc-800 text-zinc-700 dark:text-zinc-200 border border-zinc-200 dark:border-zinc-700"}`,children:s},t)})})]})]})]}),e.jsx("div",{className:"fixed left-0 right-0 p-4 bg-white dark:bg-[#1a1a1a] border-t dark:border-gray-800 transition-[bottom] duration-150",style:{bottom:`${X}px`},children:e.jsx(E,{className:"w-full h-12 text-white font-bold text-lg",style:{backgroundColor:"#DC2626"},onClick:rt,disabled:pe,children:pe?C?"Updating...":"Saving...":C?"Update Address":"Save Address & Proceed"})})]})}return e.jsxs(je,{className:"min-h-screen bg-white dark:bg-[#0a0a0a] flex flex-col",children:[e.jsxs("div",{className:"flex-shrink-0 bg-white dark:bg-[#1a1a1a] border-b border-gray-100 dark:border-gray-800 px-4 py-4 flex items-center gap-4",children:[e.jsx(E,{variant:"ghost",size:"icon",onClick:B,className:"rounded-full",children:e.jsx(ze,{className:"h-6 w-6"})}),e.jsx("h1",{className:"text-xl font-bold",children:"Select Location"})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto pb-10",children:[e.jsx("div",{className:"p-4 bg-white dark:bg-[#0a0a0a] border-b dark:border-gray-800/10",children:e.jsxs("div",{className:"relative group",children:[e.jsx("div",{className:"absolute inset-y-0 left-0 pl-4 flex items-center pointer-events-none",children:e.jsx(Ce,{className:"h-5 w-5 text-neutral-400 dark:text-neutral-500"})}
1),e.jsx(z,{value:v,onChange:r=>N(r.target.value),placeholder:"Search for area, street name...",className:Le}),v&&e.jsx("button",{onClick:()=>N(""),className:"absolute right-3.5 top-1/2 -translate-y-1/2 p-1 rounded-full hover:bg-zinc-200 dark:hover:bg-zinc-800 text-zinc-400 hover:text-zinc-600 dark:hover:text-zinc-200 transition-colors",children:e.jsx(Ae,{className:"h-4 w-4"})})]})}),Z.length>0&&e.jsx("div",{className:"mx-4 mt-2 mb-4 bg-white dark:bg-zinc-900 border border-zinc-150 dark:border-zinc-800 rounded-2xl shadow-xl overflow-hidden divide-y divide-zinc-100 dark:divide-zinc-850 z-50 animate-in fade-in duration-200",children:Z.map(r=>{const t=r.display.split(",")[0]||r.display,s=r.display.split(",").slice(1).join(",").trim()||r.display;return e.jsxs("button",{onClick:()=>Ke(r),className:"w-full px-4 py-3.5 flex items-start gap-3.5 hover:bg-[#DC2626]/5 dark:hover:bg-[#DC2626]/10 transition-colors text-left",children:[e.jsx("div",{className:"h-9 w-9 rounded-full bg-red-50 dark:bg-red-950/20 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(te,{className:"h-4.5 w-4.5 text-[#DC2626]"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-bold text-zinc-900 dark:text-zinc-50 truncate",children:t}),e.jsx("p",{className:"text-xs text-zinc-500 dark:text-zinc-400 truncate mt-0.5",children:s})]}),e.jsx(re,{className:"h-4 w-4 text-zinc-300 dark:text-zinc-600 mt-2.5 flex-shrink-0"})]},r.id)})}),fe&&e.jsxs("div",{className:"mx-4 mt-2 mb-4 p-4 flex items-center justify-center gap-2 text-xs text-zinc-500 bg-zinc-50 dark:bg-zinc-900/50 rounded-xl",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-2 border-[#DC2626] border-t-transparent"}),"Searching location..."]}),e.jsxs("div",{className:"bg-white dark:bg-[#0a0a0a] border-b border-zinc-100 dark:border-zinc-800/60 divide-y divide-zinc-100 dark:divide-zinc-800/40",children:[e.jsxs("button",{onClick:$e,className:"w-full flex items-center gap-4 py-4 px-6 hover:bg-zinc-50 dark:hover:bg-zinc-900/40 transition-all text-left",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-red-50 dark:bg-red-950/10 flex items-center justify-center flex-shrink-0",children:e.jsx(ht,{className:"h-5 w-5 text-[#DC2626]"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-bold text-[#DC2626] text-[15px]",children:"Use current location"}),e.jsx("p",{className:"text-xs text-zinc-400 dark:text-zinc-500 truncate mt-0.5",children:j?j.replace(/^[a-z0-9]{2,8}\+[a-z0-9]{0,3}[,\s]*/i,"").replace(/,\s*India$/,""):"Enable GPS for accuracy"})]}),e.jsx(re,{className:"h-5 w-5 text-zinc-300 dark:text-zinc-600 flex-shrink-0"})]}),e.jsxs("button",{onClick:Je,className:"w-full flex items-center gap-4 py-4 px-6 hover:bg-zinc-50 dark:hover:bg-zinc-900/40 transition-all text-left",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-red-50 dark:bg-red-950/10 flex items-center justify-center flex-shrink-0",children:e.jsx(mt,{className:"h-5 w-5 text-[#DC2626]"})}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"font-bold text-[#DC2626] text-[15px]",children:"Add Address"})}),e.jsx(re,{className:"h-5 w-5 text-zinc-300 dark:text-zinc-600 flex-shrink-0"})]})]}),e.jsxs("div",{className:"p-6",children:[e.jsx("div",{className:"flex items-center justify-between mb-4",children:e.jsx("h2",{className:"text-xs font-bold uppercase tracking-wider text-zinc-400 dark:text-zinc-500",children:"Saved Addresses"})}),e.jsx("div",{className:"space-y-4",children:Me&&g.length===0?[1,2].map(r=>e.jsxs("div",{className:"w-full flex items-start gap-4 p-4 bg-slate-50 dark:bg-[#1a1a1a] rounded-xl animate-pulse",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-gray-200 dark:bg-gray-800 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("div",{className:"h-4 bg-gray-200 dark:bg-gray-800 rounded w-1/4"}),e.jsx("div",{className:"h-3 bg-gray-200 dark:bg-gray-800 rounded w-3/4"})]})]},r)):g.length===0?e.jsxs("div",{className:"text-center py-10 opacity-50",children:[e.jsx(te,{className:"h-12 w-12 mx-auto mb-2 text-gray-400"}),e.jsx("p",{children:"No addresses saved yet"})]}):g.map((r,t)=>{const s=bt(r),o=[r.additionalDetails,r.street,r.city,r.state].filter(
1Boolean).join(", ").replace(/^[a-z0-9]{2,8}\+[a-z0-9]{0,3}[,\s]*/i,"");return e.jsxs("div",{className:"w-full flex items-start gap-3 p-4 bg-slate-50 dark:bg-[#1a1a1a] rounded-xl border border-transparent hover:border-[#DC2626]/15 transition-colors",children:[e.jsxs("button",{type:"button",onClick:()=>qe(r),className:"flex flex-1 items-start gap-3 text-left min-w-0 pr-1",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-white dark:bg-gray-800 flex items-center justify-center shadow-sm flex-shrink-0",children:e.jsx(s,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("p",{className:"font-bold text-gray-900 dark:text-white capitalize truncate",children:r.label||"Address"}),e.jsx("span",{className:"inline-flex h-6 w-6 items-center justify-center rounded-full bg-[#DC2626]/10 flex-shrink-0",children:e.jsx(re,{className:"h-4 w-4 text-[#DC2626]",strokeWidth:2.5})})]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 line-clamp-2 mt-1 pr-2",children:o})]})]}),e.jsxs("div",{className:"flex flex-col gap-1.5 pt-1 flex-shrink-0",children:[e.jsx("button",{type:"button",onClick:i=>Ze(i,r),className:"h-9 w-9 rounded-full bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 flex items-center justify-center text-gray-500 hover:text-[#DC2626] hover:border-[#DC2626]/30 transition-colors","aria-label":"Edit address",children:e.jsx(pt,{className:"h-4 w-4"})}),e.jsx("button",{type:"button",onClick:i=>Xe(i,r),className:"h-9 w-9 rounded-full bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 flex items-center justify-center text-gray-500 hover:text-red-600 hover:border-red-200 transition-colors","aria-label":"Delete address",children:e.jsx(Se,{className:"h-4 w-4"})})]})]},D(r)||t)})})]})]}),e.jsx("style",{children:` 2 @keyframes bounce-short { 3 0%, 100% { transform: translateY(0); } 4 50% { transform: translateY(-4px); } 5 } 6 .animate-bounce-short { 7 animation: bounce-short 1s infinite ease-in-out; 8 } 9 `}),Pe&&e.jsxs("div",{className:"fixed inset-0 z-[10000] bg-white/60 dark:bg-[#0a0a0a]/60 backdrop-blur-sm flex flex-col items-center justify-center animate-in fade-in duration-300 pointer-events-auto",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"w-10 h-10 border-[3px] border-gray-100/30 rounded-full"}),e.jsx("div",{className:"absolute top-0 left-0 w-10 h-10 border-[3px] border-[#DC2626] border-t-transparent rounded-full animate-spin"})]}),e.jsx("p",{className:"mt-4 text-[13px] font-bold text-gray-800 dark:text-gray-200 tracking-tight animate-pulse",children:"Fetching Location..."})]}),b&&ot.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[10001] flex items-center justify-center p-4",children:[e.jsx("button",{type:"button",className:"absolute inset-0 bg-black/45",style:{opacity:b.phase==="open"?1:0,transition:`opacity ${se}ms ease`},onClick:()=>!V&&Q(),"aria-label":"Close delete dialog"}),e.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"delete-address-title",className:"relative w-full max-w-[340px] rounded-3xl bg-white dark:bg-[#1a1a1a] shadow-2xl",style:Ue(b.phase),children:e.jsxs("div",{className:"px-6 pt-8 pb-6",children:[e.jsxs("div",{className:"flex flex-col items-center text-center",children:[e.jsx("div",{className:"h-14 w-14 rounded-full bg-red-50 dark:bg-red-950/30 flex items-center justify-center mb-4 ring-8 ring-red-50/60 dark:ring-red-950/20",children:e.jsx(Se,{className:"h-6 w-6 text-red-600"})}),e.jsxs("div",{className:"space-y-2 w-full",children:[e.jsx("h2",{id:"delete-address-title",className:"text-xl font-bold text-zinc-900 dark:text-white",children:"Delete address?"}),e.jsx("p",{className:"text-sm text-zinc-500 dark:text-zinc-400 leading-relaxed",children:"This action cannot be undone. You will need to add this address again."})]})]}),e.jsxs("div",{className:"mt-5 rounded-2xl border border-zinc-100 dark:border-zinc-800 bg-zinc-50 dark:bg-zinc-900/60 px-4 py-3.5 text-left",children:[e.jsx("p",{className:"text-xs font-bold uppercase tracking-wider text-zinc-400 dark:text-zinc-500 mb-1",children:b.address?.label||"Address"}),e.jsx("p",{className:"text-sm font-medium text-zinc-800 dark:text-zinc-100 leading-relaxed break-words",children:vt(b.address)||"Saved delivery address"})]}),e.jsxs("div",{className:"mt-6 flex flex-col gap-3",children:[e.jsx(E,{onClick:Qe,disabled:V,className:"w-full h-12 rounded-xl bg-red-600 hover:bg-red-700 text-white font-semibold text-[15px] shadow-sm",children:V?"Deleting...":"Delete address"}),e.jsx(E,{type:"button",variant:"ghost",onClick:Q,disabled:V,className:"w-full h-12 rounded-xl border border-zinc-200/80 dark:border-zinc-700 bg-zinc-100 hover:bg-zinc-200/90 dark:bg-zinc-800/90 dark:hover:bg-zinc-700 text-zinc-700 dark:text-zinc-100 font-semibold text-[15px] shadow-sm",children:"Cancel"})]})]})})]}),document.body)]})}
9export{Kr 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.