PageSourceSearch

https://www.merrypak.co.za/assets/GuestCheckoutSections-B0AwCO3e.js

js merrypak.co.za collected 2026-10-03 22:38:24 UTC 46,649 bytes, 48 lines download raw bytes

1import{y as $e,z as Ne,C as We,D as Ze,u as oi,r as h,d as ue,c as o,l as Ae,j as D,B as ce,I as ri,t as i,T as ke}from"./index-tAWMy1gn.js";import{l as si,C as Ve}from"./googleMapsLoader-Bv6Oy1Uh.js";import{P as He,C as Ke,S as Ye}from"./SuburbLocationDropdown-CXeE6yl2.js";import{n as ui}from"./checkoutSubmitUtils-h_hfxWVw.js";import{G as F}from"./Grid-Cq5Nc5q_.js";import{F as qe,I as Te,S as Ue,T as me}from"./TextField-BylU5aXr.js";import{M as Ce}from"./MenuItem-6X63peVZ.js";import{F as Re}from"./FormControlLabel-CabZ8Ilq.js";import{C as ci}from"./Collapse-_8gmMfnV.js";var we={},Oe;function pi(){if(Oe)return we;Oe=1;var l=$e();Object.defineProperty(we,"__esModule",{value:!0}),we.default=void 0;var x=l(Ne()),B=We;return we.default=(0,x.default)((0,B.jsx)("path",{d:"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"}),"Clear"),we}var ai=pi();const gi=Ze(ai),di=`
2  .pac-container {
3    z-index: 9999 !important;
4    border-radius: 8px !important;
5    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06) !important;
6    border: 1px solid #e0e0e0 !important;
7    overflow: hidden !important;
8  }
9  .pac-item {
10    border-top: none !important;
11    padding: 12px 16px !important;
12    cursor: pointer !important;
13    transition: background-color 0.2s ease !important;
14  }
15  .pac-item:hover {
16    background-color: #f5f5f5 !important;
17  }
18  .pac-item:first-child {
19    border-top: none !important;
20  }
21  .pac-item-selected {
22    background-color: #e3f2fd !important;
23  }
24  .pac-matched {
25    font-weight: 600 !important;
26    color: #1976d2 !important;
27  }
28  .pac-icon {
29    margin-right: 12px !important;
30  }
31  
32  /* Kill Chrome's autocomplete dropdown completely */
33  input[name="street_address_input"]::-webkit-contacts-auto-fill-button {
34    visibility: hidden;
35    display: none !important;
36    pointer-events: none;
37    position: absolute;
38    right: 0;
39  }
40  input[name="street_address_input"]:-webkit-autofill {
41    -webkit-background-clip: text !important;
42    background-color: transparent !important;
43  }
44  /* Hide any Chrome autocomplete dropdowns */
45  input[name="street_address_input"] + div {
46    display: none !important;
47  }
48`,Xe=({isAuthorized:l,deliveryAddresses:x,selectedAddressId:B,setSelectedAddressId:K,setIsManualAddressEntry:ee,formData:c,setFormData:r,onFormDataChange:S,shippingStreetRef:ie,shippingUnitRef:Q,shippingSuburbRef:k,shippingCityRef:E,shippingPostalCodeRef:j,shippingCountryRef:G,additionalInstructionsRef:C,onAddressChange:$,zoom:z,latitude:pe,longitude:be})=>{const{t:Y}=oi("common",{useSuspense:!1}),ae=h.useRef(null),R=h.useRef(null),te=h.useRef(null),a=h.useRef(null),d=h.useRef(null),q=h.useRef(!0),ne=h.useRef(!1),X=h.useRef(!1),N=h.useRef({}),[T,V]=h.useState(null),[P,I]=h.useState(null),[w,U]=h.useState(null);h.useCallback(async e=>{if(!e)return null;try{const n=(await ue.get(`/api/locations/search/?q=${encodeURIComponent(e)}`)).data.results.find(p=>p.type==="province"&&p.name.toLowerCase()===e.toLowerCase());return(n==null?void 0:n.id)||null}catch(t){return console.error("Error looking up province ID:",t),null}},[]);const[fe,Qe]=h.useState({});h.useEffect(()=>{if(c.shippingProvince&&!T){if(fe[c.shippingProvince]){const t={id:fe[c.shippingProvince],name:c.shippingProvince};console.log("🔧 Using cached province:",t),V(t);return}(async()=>{try{const n=(await ue.get(`/api/locations/search/?q=${encodeURIComponent(c.shippingProvince)}`)).data.results.find(p=>p.type==="province"&&p.name.toLowerCase()===c.shippingProvince.toLowerCase());n&&(console.log("🔧 Syncing selectedProvince from formData:",n),V(n),Qe(p=>({...p,[c.shippingProvince]:n.id})))}catch(t){console.error("Error syncing province from formData:",t)}})()}},[c.shippingProvince,T,fe]),h.useEffect(()=>{(async()=>{if(B&&x.length>0){const t=x.find(s=>s.id.toString()===B.toString());if(t)try{if(t.province){const p=(await ue.get(`/api/locations/search/?q=${encodeURIComponent(t.province)}`)).data.results.find(g=>g.type==="province"&&g.name.toLowerCase()===t.province.toLowerCase());if(p&&(console.log("ShippingAddressForm - Setting selectedProvince:",p),V(p),t.city)){const y=(await ue.get(`/api/locations/search/?q=${encodeURIComponent(t.city)}`)).data.results.find(m=>m.type==="city"&&m.name.toLowerCase()===t.city.toLowerCase()&&m.province_id===p.id);if(y&&(console.log("ShippingAddressForm - Setting selectedCity:",y),I(y),t.suburb)){const v=(await ue.get(`/api/locations/search/?q=${encodeURIComponent(t.suburb)}`)).data.results.find(W=>W.type==="suburb"&&W.name.toLowerCase()===t.suburb.toLowerCase()&&W.city_id===y.id);v&&(console.log("ShippingAddressForm - Setting selectedSuburb:",v),U(v))}}}}catch(s){console.error("Error loading location data for selected address:",s)}}})()},[B,x]),h.useEffect(()=>{const e=setTimeout(()=>{q.current=!1},2500);return()=>clearTimeout(e)},[]);const Ee=h.useCallback((e={})=>{var t,s,n,p,g,f;return{shippingStreet:e.shippingStreet??((t=R.current)==null?void 0:t.value)??c.shippingStreet??"",shippingUnit:e.shippingUnit??((s=Q==null?void 0:Q.current)==null?void 0:s.value)??c.shippingUnit??"",shippingBuilding:e.shippingBuilding??c.shippingBuilding??"",shippingSuburb:e.shippingSuburb??((n=k==null?void 0:k.current)==null?void 0:n.value)??c.shippingSuburb??"",shippingCity:e.shippingCity??((p=E==null?void 0:E.
48current)==null?void 0:p.value)??c.shippingCity??"",shippingProvince:e.shippingProvince??c.shippingProvince??"",shippingPostalCode:e.shippingPostalCode??((g=j==null?void 0:j.current)==null?void 0:g.value)??c.shippingPostalCode??"",shippingCountry:e.shippingCountry??((f=G==null?void 0:G.current)==null?void 0:f.value)??c.shippingCountry??"South Africa"}},[c,Q,k,E,j,G]),Le=h.useCallback((e,t)=>{N.current[e]=String(t??"").trim()},[]),Be=h.useCallback((e,t,s={})=>{if(!$)return;const n=String(t??"").trim();Object.prototype.hasOwnProperty.call(N.current,e)&&N.current[e]===n||(delete N.current[e],$(Ee(s)))},[$,Ee]),De=e=>{console.log("🔍 handleProvinceSelect called with:",e),V(e),I(null),U(null),r(t=>({...t,shippingProvince:(e==null?void 0:e.name)||"",shippingCity:"",shippingSuburb:""})),q.current||K(null),$&&$({...c,shippingProvince:(e==null?void 0:e.name)||""})},ei=e=>{I(e),r(t=>({...t,shippingCity:(e==null?void 0:e.name)||"",shippingSuburb:t.shippingSuburb||""})),q.current||K(null),$&&(delete N.current.shippingCity,$(Ee({shippingCity:(e==null?void 0:e.name)||""})))},ii=h.useCallback((e,t={})=>{if(!e)return null;const s={shippingPostalCode:e,...c.sameAsShipping?{billingPostalCode:e}:{},...t};r(p=>({...p,...s})),S&&S(p=>({...p,...s}));const n=document.forms.checkoutForm;return n!=null&&n.elements.shippingPostalCode&&(n.elements.shippingPostalCode.value=e),c.sameAsShipping&&(n!=null&&n.elements.billingPostalCode)&&(n.elements.billingPostalCode.value=e),j!=null&&j.current&&(j.current.value=e),s},[c.sameAsShipping,S]),Fe=h.useCallback(async({postalCode:e,latitude:t,longitude:s,street:n,suburb:p,city:g,province:f,formattedAddress:y})=>{if(e)return e;const m=y||[n,p,g,f,"South Africa"].filter(Boolean).join(", ");return ui(window.google,{lat:t,lng:s,addressString:m})},[]),ni=async e=>{U(e);const t=(e==null?void 0:e.name)||"";let s=(e==null?void 0:e.postal_code)||"";s||(s=await Fe({postalCode:"",latitude:c.shipping_latitude,longitude:c.shipping_longitude,street:c.shippingStreet,suburb:t,city:c.shippingCity,province:c.shippingProvince})),r(n=>({...n,shippingSuburb:t,...s?{shippingPostalCode:s}:{},...s&&n.sameAsShipping?{billingPostalCode:s}:{}})),s&&ii(s,{shippingSuburb:t}),q.current||K(null),$&&(delete N.current.shippingSuburb,delete N.current.shippingPostalCode,$(Ee({shippingSuburb:t,shippingPostalCode:s||c.shippingPostalCode})))},ti=async e=>{let t="",s="",n="";e.forEach(y=>{const m=y.types;m.includes("administrative_area_level_1")?t=y.long_name:m.includes("locality")?s=y.long_name:(m.includes("sublocality_level_1")||m.includes("sublocality")||m.includes("neighborhood"))&&(n=y.long_name)}),console.log("Google Places location data:",{province:t,city:s,suburb:n});let p=null,g=null,f=null;try{if(t){console.log("🔍 Searching for province:",t);const m=(await ue.get(`/api/locations/search/?q=${encodeURIComponent(t)}`)).data;console.log("🔍 Province search results:",m.results);let _=m.results.find(v=>v.type==="province"&&v.name.toLowerCase()===t.toLowerCase());if(_||(_=m.results.find(v=>v.type==="province"&&(v.name.toLowerCase().includes(t.toLowerCase())||t.toLowerCase().includes(v.name.toLowerCase())))),console.log("🔍 Matching province:",_),_){if(V(_),p=_,console.log("✅ Province matched:",_.name),s){console.log("🔍 Searching for city:",s,"in province:",_.name);const W=(await ue.get(`/api/locations/search/?q=${encodeURIComponent(s)}`)).data;console.log("🔍 City search results:",W.results);let M=W.results.find(L=>L.type==="city"&&L.name.toLowerCase()===s.toLowerCase()&&L.province_id===_.id);M||(M=W.results.find(L=>L.type==="city"&&L.province_id===_.id&&(L.name.toLowerCase().includes(s.toLowerCase())||s.toLowerCase().includes(L.name.toLowerCase())))),console.log("🔍 Matching city:",M),M?(console.log("✅ City matched:",M.name),I(M),g=M):(console.log("❌ No matching city found, using Google Places city:",s),g={name:s,isCustom:!0})}}else console.log("❌ No matching province found, using Google Places data:",t),p={name:t,isCustom:!0},s&&(g={name:s,isCustom:!0})}if(n&&g&&!g.isCustom){const m=(await ue.get(`/api/locations/search/?q=${encodeURIComponent(n)}`)).data;let _=m.results.find(v=>v.type==="suburb"&&v.name.toLowerCase()===n.toLowerCase()&&v.city_id===g.id);_||(_=m.results.find(v=>v.type==="suburb"&&v.city_id===g.id&&(v.name.toLowerCase().includes(n.toLowerCase())||n.toLowerCase().includes(v.name.toLowerCase())))),_?(U(_),f=_):f={name:n,isCustom:!0}}else n&&(f={name:n,isCustom:!0})}catch(y){console.error("Error finding matching locations:",y)}return{matchedProvince:p,matchedCity:g,matchedSuburb:f}};h.useEffect(()=>{if(!document.getElementById("google-places-autocomplete-styles")){const e=document.createElement("style");e.id="google-places-autocomplete-styles",e.textContent=di,document.head.appendChild(e)}si().then(()=>
48{if(ae.current){const e=pe&&be?{lat:pe,lng:be}:{lat:-28.4793,lng:24.6727},t=z||12,s=new google.maps.Map(ae.current,{center:e,zoom:t,styles:[{featureType:"poi",elementType:"labels",stylers:[{visibility:"off"}]}],zoomControl:!0,zoomControlOptions:{position:google.maps.ControlPosition.RIGHT_BOTTOM},streetViewControl:!0,mapTypeControl:!0,fullscreenControl:!0}),n=new google.maps.Marker({position:e,map:s,draggable:!0,animation:google.maps.Animation.DROP});google.maps.event.addListener(n,"dragstart",()=>{ne.current=!0}),google.maps.event.addListener(n,"dragend",()=>{const p=n.getPosition();ne.current=!1,X.current=!0,r(g=>({...g,shipping_latitude:p.lat(),shipping_longitude:p.lng()})),S&&S(g=>({...g,shipping_latitude:p.lat(),shipping_longitude:p.lng()})),setTimeout(()=>{X.current=!1},100)}),google.maps.event.addListener(s,"click",p=>{const g=p.latLng;X.current=!0,n.setPosition(g),r(f=>({...f,shipping_latitude:g.lat(),shipping_longitude:g.lng()})),S&&S(f=>({...f,shipping_latitude:g.lat(),shipping_longitude:g.lng()})),setTimeout(()=>{X.current=!1},100)}),te.current=s,a.current=n,setTimeout(()=>{if(B&&x.length>0){const p=x.find(g=>g.id.toString()===B.toString());if(p&&p.latitude&&p.longitude){const g={lat:parseFloat(p.latitude),lng:parseFloat(p.longitude)},f=p.zoom?parseInt(p.zoom):13;n.setPosition(g),s.setCenter(g),setTimeout(()=>{s.setZoom(f)},100),r(y=>({...y,shipping_latitude:g.lat,shipping_longitude:g.lng,shipping_zoom:f}))}}},250)}if(R.current){const e=new google.maps.places.Autocomplete(R.current,{types:["address"],componentRestrictions:{country:["za","na"]},fields:["address_components","formatted_address","geometry","place_id"]});d.current=e,e.addListener("place_changed",async()=>{const t=e.getPlace();if(!t||!t.geometry||!t.place_id)return;!q.current&&ee&&(console.log("🔧 Setting isManualAddressEntry to true IMMEDIATELY"),ee(!0)),q.current||(console.log("🔧 Clearing selectedAddressId because Google Places address selected"),K(null),console.log("🔧 Clearing LocationDropdown selections"),V(null),I(null),U(null),N.current={});const s=t.address_components||[];let n="",p="",g="",f="",y="",m="",_="";s.forEach(A=>{const H=A.types;H.includes("street_number")?n=A.long_name:H.includes("route")?p=A.long_name:H.includes("sublocality_level_1")||H.includes("sublocality")||H.includes("neighborhood")?g=A.long_name:H.includes("locality")||H.includes("administrative_area_level_2")&&!f?f=A.long_name:H.includes("administrative_area_level_1")?y=A.long_name:H.includes("postal_code")||H.includes("postal_code_prefix")?m=A.long_name:H.includes("country")&&(_=A.long_name)}),console.log("🔍 Google Places address components:",s),console.log("🔍 Extracted values:",{streetNumber:n,route:p,suburb:g,city:f,province:y,postalCode:m,country:_}),console.log("🔍 BEFORE findLocationFromGooglePlaces - selectedProvince:",T==null?void 0:T.name,"selectedCity:",P==null?void 0:P.name);const v=`${n} ${p}`.trim(),{matchedProvince:W,matchedCity:M,matchedSuburb:L}=await ti(s);console.log("🔍 AFTER findLocationFromGooglePlaces - matchedProvince:",W==null?void 0:W.name,"matchedCity:",M==null?void 0:M.name,"matchedSuburb:",L==null?void 0:L.name);let le,oe;if(typeof t.geometry.location.lat=="function"?(le=t.geometry.location.lat(),oe=t.geometry.location.lng()):(le=t.geometry.location.lat,oe=t.geometry.location.lng),!m&&t.formatted_address){const A=t.formatted_address.match(/\b(\d{4})\b/);A&&(m=A[1])}const ge=(L==null?void 0:L.name)||g,de=(M==null?void 0:M.name)||f,he=(W==null?void 0:W.name)||y;let re=(L==null?void 0:L.postal_code)||m;re||(re=await Fe({postalCode:"",latitude:le,longitude:oe,street:v,suburb:ge,city:de,province:he,formattedAddress:t.formatted_address}));const O={shippingStreet:v,shippingSuburb:ge,shippingCity:de,shippingProvince:he,shippingPostalCode:re,shippingCountry:_||"",shipping_latitude:le,shipping_longitude:oe};console.log("🔧 Using matched values:",{province:he,city:de,suburb:ge,postalCode:re,googlePostalCode:m,matchedSuburbPostal:(L==null?void 0:L.postal_code)||null}),c.sameAsShipping&&(O.billingStreet=v,O.billingSuburb=ge,O.billingCity=de,O.billingProvince=he,O.billingPostalCode=re,O.billingCountry=_||""),console.log("🔍 Selected location data:",{selectedProvince:T==null?void 0:T.name,selectedCity:P==null?void 0:P.name,selectedSuburb:w==null?void 0:w.name}),console.log("🔍 Google Places fallback data:",{province:y,city:f,suburb:g}),console.log("🔍 Final form data being set:",O),console.log("🔧 Setting form data with Google Places data:",O),r(A=>({...A,...O})),S&&(console.log("🔧 Notifying parent of Google Places form data change"),S(A=>({...A,...O}))),$&&(console.log("🔧 Notifying parent that address changed - trigger shipping calculation with data:",O),$(O)),setTimeout(()=>{const A=te.current,H=a.current;if(A&&H&&le&&oe){const b=new google.maps.LatLng(le,oe);H.setPosition(b),A.panTo(b),A.setZoom(13),r(Z=>({...Z,shipping_latitude:le,shipping_longitude:oe,shipping_zoom:13})),S&&S(Z=>({...Z,shipping_latitude:le,shipping_longitude:oe,shipping_zoom:13}))}},150);const u=document.forms.checkoutForm;u&&(u.elements.shippingStreet&&(u.elements.shippingStreet.value=v),u.elements.shippingSuburb&&(u.elements.shippingSuburb.value=ge),u.elements.shippingCity&&(u.elements.shippingCity.value=de),u.elements.shippingProvince&&(u.elements.shippingProvince.value=he),u.elements.shippingPostalCode&&(u.elements.shippingPostalCode.value=re),u.elements.shippingCountry&&(u.elements.shippingCountry.value=_||""),c.sameAsShipping&&(u.elements.billingStreet&&(u.elements.billingStreet.value=v),u.elements.billingSuburb&&(u.elements.billingSuburb.value=ge),u.elements.billingCity&&(u.elements.billingCity.value=de),u.elements.billingProvince&&(u.elements.billingProvince.value=he),u.elements.billingPostalCode&&(u.elements.billingPostalCode.value=re),u.elements.billingCountry&&(u.elements.billingCountry.value=_||""))),setTimeout(()=>{k!=null&&k.current&&(k.current.value=ge),E!=null&&E.current&&(E.current.value=de),j!=null&&j.current&&(j.current.value=re),R.current&&(R.current.value=v)},100)}),R.current.addEventListener("keydown",t=>{if(t.key==="Enter"){const s=document.querySelector(".pac-container");s&&s.style.display!=="none"&&(t.preventDefault(),t.stopPropagation())}})}})},[B,x]),h.useEffect(()=>{if(B&&x.length>0&&te.current){const e=x.find(t=>
48t.id.toString()===B.toString());if(e&&e.latitude&&e.longitude){const t=e.zoom?parseInt(e.zoom):13;setTimeout(()=>{te.current&&te.current.setZoom(t)},300)}}},[B,x]),h.useEffect(()=>{if(!ne.current&&!X.current&&te.current&&a.current&&pe&&be){const e={lat:pe,lng:be};te.current.setCenter(e),te.current.setZoom(z||13),a.current.setPosition(e)}},[pe,be,z]);const je=h.useRef(null),Se=(e,t)=>{const{value:s}=e.target;q.current||K(null),je.current&&clearTimeout(je.current);const n={street:"shippingStreet",suburb:"shippingSuburb",city:"shippingCity",province:"shippingProvince",postal_code:"shippingPostalCode",country:"shippingCountry",unit:"shippingUnit",building:"shippingBuilding"},p={...c,[n[t]]:s};if(c.sameAsShipping){const y={shippingStreet:"billingStreet",shippingSuburb:"billingSuburb",shippingCity:"billingCity",shippingProvince:"billingProvince",shippingPostalCode:"billingPostalCode",shippingCountry:"billingCountry",shippingUnit:"billingUnit",shippingBuilding:"billingBuilding"};p[y[n[t]]]=s;const m=document.forms.checkoutForm;if(m){const _=y[n[t]];m.elements[_]&&(m.elements[_].value=s)}}r(p),S&&S(p);const g=te.current,f=a.current;if((t==="suburb"||t==="city")&&g&&f){const y={...p},m=[y.shippingStreet,y.shippingSuburb,y.shippingCity,y.shippingProvince,y.shippingPostalCode,y.shippingCountry].filter(Boolean).join(", ");m.trim().length>10&&new google.maps.Geocoder().geocode({address:m},(v,W)=>{if(W==="OK"&&v&&v[0]){const M=v[0].geometry.location;f.setPosition(M),g.panTo(M),r(L=>({...L,shipping_latitude:M.lat(),shipping_longitude:M.lng(),shipping_zoom:g.getZoom()}))}})}},li=e=>{var p,g,f,y,m,_,v,W,M,L,le,oe,ge,de,he,re;const t=e.target.value;if(R.current&&(R.current.blur(),R.current.value="",r(O=>({...O,shippingStreet:""}))),document.querySelectorAll(".pac-container").forEach(O=>{O.style.display="none",O.style.visibility="hidden"}),d.current&&d.current.set("place",null),!t){K(null);return}K(t);const n=x.find(O=>O.id.toString()===t.toString());if(n){(async()=>{try{let b=null,Z=null,se=null;n.province&&(b=(await ue.get(`/api/locations/search/?q=${encodeURIComponent(n.province)}`)).data.results.find(J=>J.type==="province"&&J.name.toLowerCase()===n.province.toLowerCase())),n.city&&b&&(Z=(await ue.get(`/api/locations/search/?q=${encodeURIComponent(n.city)}`)).data.results.find(J=>J.type==="city"&&J.name.toLowerCase()===n.city.toLowerCase()&&J.province_id===b.id)),n.suburb&&Z&&(se=(await ue.get(`/api/locations/search/?q=${encodeURIComponent(n.suburb)}`)).data.results.find(J=>J.type==="suburb"&&J.name.toLowerCase()===n.suburb.toLowerCase()&&J.city_id===Z.id)),b&&V(b),Z&&I(Z),se&&U(se)}catch(b){console.error("Error finding location data for selected address:",b)}})().then(()=>{var Z,se,ye,ve,J,Pe,_e,ze;const b={shippingStreet:((Z=n.street)==null?void 0:Z.trim())||"",shippingSuburb:((se=n.suburb)==null?void 0:se.trim())||"",shippingCity:((ye=n.city)==null?void 0:ye.trim())||"",shippingProvince:((ve=n.province)==null?void 0:ve.trim())||"",shippingPostalCode:((J=n.postal_code)==null?void 0:J.trim())||"",shippingUnit:((Pe=n.unit)==null?void 0:Pe.trim())||"",shippingBuilding:((_e=n.building)==null?void 0:_e.trim())||"",shippingCountry:((ze=n.country)==null?void 0:ze.trim())||"",additionalInstructions:n.additional_instructions||"",shipping_latitude:n.latitude?parseFloat(n.latitude):null,shipping_longitude:n.longitude?parseFloat(n.longitude):null,shipping_zoom:n.zoom?parseInt(n.zoom):13};c.sameAsShipping&&(b.billingStreet=b.shippingStreet,b.billingSuburb=b.shippingSuburb,b.billingCity=b.shippingCity,b.billingProvince=b.shippingProvince,b.billingPostalCode=b.shippingPostalCode,b.billingUnit=b.shippingUnit,b.billingBuilding=b.shippingBuilding,b.billingCountry=b.shippingCountry),r(Ie=>({...Ie,...b})),S&&S(Ie=>({...Ie,...b})),$&&$(b)});const u=document.forms.checkoutForm;u&&(u.elements.shippingStreet&&(u.elements.shippingStreet.value=((p=n.street)==null?void 0:p.trim())||""),u.elements.shippingSuburb&&(u.elements.shippingSuburb.value=((g=n.suburb)==null?void 0:g.trim())||""),u.elements.shippingCity&&(u.elements.shippingCity.value=((f=n.city)==null?void 0:f.trim())||""),u.elements.shippingProvince&&(u.elements.shippingProvince.value=((y=n.province)==null?void 0:y.trim())||""),u.elements.shippingPostalCode&&(u.elements.shippingPostalCode.value=((m=n.postal_code)==null?void 0:m.trim())||""),u.elements.shippingUnit&&(u.elements.shippingUnit.value=((_=n.unit)==null?void 0:_.trim())||""),u.elements.shippingBuilding&&(u.elements.shippingBuilding.value=((v=n.building)==null?void 0:v.trim())||""),u.elements.shippingCountry&&(u.elements.shippingCountry.value=((W=n.country)==null?void 0:W.trim())||""),u.elements.additionalInstructions&&(u.elements.additionalInstructions.value=n.additional_instructions||""),c.sameAsShipping&&(u.elements.billingStreet&&(u.elements.billingStreet.value=((M=n.street)==null?void 0:M.trim())||""),u.elements.billingSuburb&&(u.elements.billingSuburb.value=((L=n.suburb)==null?void 0:L.trim())||""),u.elements.billingCity&&(u.elements.billingCity.value=((le=n.city)==null?void 0:le.trim())||""),u.elements.billingProvince&&(u.elements.billingProvince.value=((oe=n.province)==null?void 0:oe.trim())||""),u.elements.billingPostalCode&&(u.elements.billingPostalCode.value=((ge=n.postal_code)==null?void 0:ge.trim())||""),u.elements.billingUnit&&(u.elements.billingUnit.value=((de=n.unit)==null?void 0:de.trim())||""),u.elements.billingBuilding&&(u.elements.billingBuilding.value=((he=n.building)==null?void 0:he.trim())||""),u.elements.billingCountry&&(u.elements.billingCountry.value=((re=n.country)==null?void 0:re.trim())||"")));const A=te.current,H=a.current;if(A&&H&&n.latitude&&n.longitude){const b={lat:parseFloat(n.latitude),lng:parseFloat(n.longitude)},Z=n.zoom?parseInt(n.zoom):13;H.setPosition(b),A.setCenter(b),setTimeout(()=>{A.setZoom(Z)},150),r(se=>({...se,shipping_latitude:b.lat,shipping_longitude:b.lng,shipping_zoom:Z}))}setTimeout(()=>{var Z,se,ye,ve,J,Pe,_e;d.current&&d.current.setOptions({types:[]}),ie!=null&&ie.current&&(ie.current.value=((Z=n.street)==null?void 0:Z.trim())||"",ie.current.dispatchEvent(new Event("input",{bubbles:!0}))),k!=null&&k.current&&(k.current.value=((se=n.suburb)==null?void 0:se.trim())||"",k.current.dispatchEvent(new Event("input",{bubbles:!0}))),E!=null&&E.current&&(E.current.value=((ye=n.city)==null?void 0:ye.trim())||"",E.current.dispatchEvent(new Event("input",{bubbles:!0})));const b=document.forms.checkoutForm;b&&b.elements.shippingProvince&&(b.elements.shippingProvince.value=((ve=n.province)==null?void 0:ve.trim())||"",b.elements.shippingProvince.dispatchEvent(new Event("input",{bubbles:!0}))),j!=null&&j.current&&(j.current.value=((J=n.postal_code)==null?void 0:J.trim())||"",j.current.dispatchEvent(new Event("input",{bubbles:!0}))),Q!=null&&Q.current&&(Q.current.value=((Pe=n.unit)==null?void 0:Pe.trim())||"",Q.current.dispatchEvent(new Event("input",{bubbles:!0}))),G!=null&&G.current&&(G.current.value=((_e=n.country)==null?void 0:_e.trim())||"",G.current.dispatchEvent(new Event("change",{bubbles:!0}))),C!=null&&C.current&&(C.current.value=n.additional_instructions||"",C.current.dispatchEvent(new Event("input",{bubbles:!0}))),setTimeout(()=>{d.current&&d.current.setOptions({types:["address"]})},100)},100)}};return o(Ae,{children:D(F,{container:!0,spacing:2,children:[l&&x.length>0&&o(F,{item:!0,xs:12,children:D(ce,{sx:{display:"flex",alignItems:"center",gap:1},children:[D(qe,{fullWidth:!0,variant:"outlined",children:[o(Te,{id:"address-select-label",children:Y("
48checkout.form.selectAddress")}),o(Ue,{labelId:"address-select-label",id:"address-select",value:B?B.toString():"",onChange:li,label:Y("checkout.form.selectAddress"),displayEmpty:!1,children:x.map(e=>{var n,p,g,f;const t=e.unit?`Unit ${e.unit.trim()}, `:"",s=e.building?`${e.building.trim()}, `:"";return o(Ce,{value:e.id.toString(),children:`${t}${s}${(n=e.street)==null?void 0:n.trim()}, ${(p=e.suburb)==null?void 0:p.trim()}, ${(g=e.city)==null?void 0:g.trim()}${e.province?`, ${e.province.trim()}`:""}, ${(f=e.postal_code)==null?void 0:f.trim()}${e.country?`, ${e.country.trim()}`:""}`},e.id)})})]}),o(ri,{"aria-label":Y("checkout.form.clearAddress"),onClick:()=>{K(null),V(null),I(null),U(null),r(t=>({...t,shippingStreet:"",shippingUnit:"",shippingBuilding:"",shippingSuburb:"",shippingCity:"",shippingProvince:"",shippingPostalCode:"",shippingCountry:""}));const e=document.forms.checkoutForm;e&&(e.elements.shippingStreet&&(e.elements.shippingStreet.value=""),e.elements.shippingUnit&&(e.elements.shippingUnit.value=""),e.elements.shippingBuilding&&(e.elements.shippingBuilding.value=""),e.elements.shippingSuburb&&(e.elements.shippingSuburb.value=""),e.elements.shippingCity&&(e.elements.shippingCity.value=""),e.elements.shippingProvince&&(e.elements.shippingProvince.value=""),e.elements.shippingPostalCode&&(e.elements.shippingPostalCode.value=""),e.elements.shippingCountry&&(e.elements.shippingCountry.value=""))},sx:{color:"text.secondary"},children:o(gi,{})})]})}),o(F,{item:!0,xs:12,sm:2,children:o(me,{fullWidth:!0,name:"shippingUnit",label:Y("checkout.form.shippingUnit")||"Unit",value:c.shippingUnit||"",onChange:e=>{Se(e,"unit"),r(t=>({...t,shippingUnit:e.target.value}))},variant:"outlined",InputLabelProps:{shrink:!0},inputRef:Q,placeholder:"Unit number"})}),o(F,{item:!0,xs:12,sm:3,children:o(me,{fullWidth:!0,name:"shippingBuilding",label:"Building",value:c.shippingBuilding||"",onChange:e=>{Se(e,"building"),r(t=>({...t,shippingBuilding:e.target.value}))},variant:"outlined",InputLabelProps:{shrink:!0},placeholder:"Building name"})}),o(F,{item:!0,xs:12,sm:7,children:o(me,{fullWidth:!0,name:"street_address_input",label:Y("checkout.form.shippingStreet"),value:c.shippingStreet||"",onChange:e=>{Se(e,"street"),r(t=>({...t,shippingStreet:e.target.value}))},onFocus:e=>{Le("shippingStreet",e.target.value)},onBlur:e=>{Be("shippingStreet",e.target.value,{shippingStreet:e.target.value})},required:!0,variant:"outlined",InputLabelProps:{shrink:!0},inputRef:e=>{R.current=e,ie&&(ie.current=e)},placeholder:"Start typing your street address...",helperText:"🔍 Start typing for address suggestions",onKeyDown:e=>{e.key==="Enter"&&(e.preventDefault(),e.stopPropagation()),e.key===" "&&e.stopPropagation()},inputProps:{maxLength:255,autoComplete:"new-password","data-lpignore":"true","data-form-type":"other"}})}),o(F,{item:!0,xs:12,sm:6,children:o(He,{value:c.shippingProvince||"",onChange:e=>{r(t=>({...t,shippingProvince:e})),q.current||K(null)},onLocationSelect:e=>{De(e)},label:"Province",required:!0,placeholder:"Select province...",apiEndpoint:"/api/"})}),o(F,{item:!0,xs:12,sm:6,children:o(Ke,{value:c.shippingCity||"",onChange:e=>{r(t=>({...t,shippingCity:e})),q.current||K(null)},onLocationSelect:e=>{ei(e)},label:Y("checkout.form.shippingCity"),required:!0,placeholder:"Search for city...",parentValue:T==null?void 0:T.id,apiEndpoint:"/api/",allowCustomEntry:!0,onFocus:()=>{var e;Le("shippingCity",c.shippingCity||((e=E==null?void 0:E.current)==null?void 0:e.value)||"")},onBlur:()=>{var e;Be("shippingCity",((e=E==null?void 0:E.current)==null?void 0:e.value)??c.shippingCity??"")}},`city-${(T==null?void 0:T.id)||"no-province"}`)}),o(F,{item:!0,xs:12,sm:6,children:o(Ye,{value:c.shippingSuburb||"",onChange:e=>{r(t=>({...t,shippingSuburb:e})),q.current||K(null)},onLocationSelect:e=>{ni(e)},label:Y("checkout.form.shippingSuburb"),required:!1,placeholder:"Search for suburb (optional)...",parentValue:P==null?void 0:P.id,parentCityName:c.shippingCity,apiEndpoint:"/api/",onFocus:()=>{var e;Le("shippingSuburb",c.shippingSuburb||((e=k==null?void 0:k.current)==null?void 0:e.value)||"")},onBlur:()=>{var e;Be("shippingSuburb",((e=k==null?void 0:k.current)==null?void 0:e.value)??c.shippingSuburb??"")}},`suburb-${(P==null?void 0:P.id)||c.shippingCity||"no-city"}`)}),o(F,{item:!0,xs:12,sm:6,children:o(me,{fullWidth:!0,name:"shippingPostalCode",label:Y("checkout.form.shippingPostalCode"),value:c.shippingPostalCode||"",onChange:e=>{Se(e,"postal_code"),r(t=>({...t,shippingPostalCode:e.target.value}))},onFocus:e=>{Le("shippingPostalCode",e.target.value)},onBlur:e=>{Be("shippingPostalCode",e.target.value,{shippingPostalCode:e.target.value})},required:!0,variant:"outlined",InputLabelProps:{shrink:!0},inputRef:j,inputProps:{maxLength:20,autoComplete:"postal-code-disabled","data-lpignore":"true"}})}),o(F,{item:!0,xs:12,sm:6,children:D(qe,{fullWidth:!0,variant:"outlined",children:[o(Te,{id:"shipping-country-label",children:Y("
48checkout.form.shippingCountry")}),D(Ue,{labelId:"shipping-country-label",id:"shippingCountry",name:"shippingCountry",value:c.shippingCountry||"",onChange:e=>Se(e,"country"),label:Y("checkout.form.shippingCountry"),inputRef:G,children:[o(Ce,{value:"",children:"--"}),o(Ce,{value:"South Africa",children:"South Africa"}),o(Ce,{value:"Namibia",children:"Namibia"})]})]})}),o(F,{item:!0,xs:12,children:o(ce,{ref:ae,sx:{height:"400px",width:"100%",borderRadius:1,overflow:"hidden",border:"1px solid",borderColor:"divider",mt:1}})}),o(F,{item:!0,xs:12,children:o(me,{fullWidth:!0,multiline:!0,rows:3,name:"additionalInstructions",label:Y("checkout.additionalInstructions.title"),value:c.additionalInstructions||"",onChange:e=>{r(s=>({...s,additionalInstructions:e.target.value}));const t=document.forms.checkoutForm;t&&t.elements.additionalInstructions&&(t.elements.additionalInstructions.value=e.target.value)},placeholder:Y("checkout.additionalInstructions.placeholder"),variant:"outlined",InputLabelProps:{shrink:!0},inputRef:C})})]})})};Xe.propTypes={isAuthorized:i.bool.isRequired,deliveryAddresses:i.arrayOf(i.shape({id:i.oneOfType([i.string,i.number]).isRequired,street:i.string,unit:i.string,suburb:i.string,city:i.string,province:i.string,postal_code:i.string,country:i.string,latitude:i.string,longitude:i.string,zoom:i.oneOfType([i.string,i.number]),additional_instructions:i.string})).isRequired,selectedAddressId:i.oneOfType([i.string,i.number]),setSelectedAddressId:i.func.isRequired,setIsManualAddressEntry:i.func,formData:i.shape({shippingStreet:i.string,shippingUnit:i.string,shippingBuilding:i.string,shippingSuburb:i.string,shippingCity:i.string,
48shippingProvince:i.string,shippingPostalCode:i.string,shippingCountry:i.string,sameAsShipping:i.bool,billingStreet:i.string,billingSuburb:i.string,billingCity:i.string,billingProvince:i.string,billingPostalCode:i.string,billingCountry:i.string,billingUnit:i.string,billingBuilding:i.string,additionalInstructions:i.string,shipping_method:i.string}).isRequired,setFormData:i.func.isRequired,onFormDataChange:i.func,shippingStreetRef:i.object,shippingUnitRef:i.object,shippingSuburbRef:i.object,shippingCityRef:i.object,shippingPostalCodeRef:i.object,shippingCountryRef:i.object,additionalInstructionsRef:i.object,onAddressChange:i.func,zoom:i.number,latitude:i.number,longitude:i.number};const Je=({formData:l,setFormData:x,isLoadingProfileBilling:B=!1,hideCheckbox:K=!1,selectedAddressId:ee=null,deliveryAddresses:c=[]})=>{const[r,S]=h.useState({street:l.billingStreet||"",unit:l.billingUnit||"",building:l.billingBuilding||"",suburb:l.billingSuburb||"",city:l.billingCity||"",province:l.billingProvince||"",postalCode:l.billingPostalCode||"",country:l.billingCountry||""}),[ie,Q]=h.useState(null),[k,E]=h.useState(null),[j,G]=h.useState(null),[C,$]=h.useState(l.sameAsShipping),z=l.shipping_method==="collect",pe=()=>{Q(null),E(null),G(null)},be=a=>{console.log("🔍 BillingAddressForm handleBillingProvinceSelect called with:",a),Q(a),E(null),G(null),S(d=>({...d,province:(a==null?void 0:a.name)||""})),console.log("🔍 BillingAddressForm: Province selected, city and suburb states cleared but localBillingData preserved")},Y=a=>{console.log("🔍 BillingAddressForm handleBillingCitySelect called with:",a),E(a),G(null),S(d=>({...d,city:(a==null?void 0:a.name)||""})),console.log("🔍 BillingAddressForm: City selected, suburb state cleared but localBillingData preserved")},ae=a=>{G(a),S(d=>({...d,suburb:(a==null?void 0:a.name)||""})),a!=null&&a.postal_code&&S(d=>({...d,postalCode:a.postal_code}))};h.useEffect(()=>{(C!==l.sameAsShipping||r.street!==(l.billingStreet||"")||r.unit!==(l.billingUnit||"")||r.building!==(l.billingBuilding||"")||r.suburb!==(l.billingSuburb||"")||r.city!==(l.billingCity||"")||r.province!==(l.billingProvince||"")||r.postalCode!==(l.billingPostalCode||"")||r.country!==(l.billingCountry||""))&&($(l.sameAsShipping),S({street:l.billingStreet||"",unit:l.billingUnit||"",building:l.billingBuilding||"",suburb:l.billingSuburb||"",city:l.billingCity||"",province:l.billingProvince||"",postalCode:l.billingPostalCode||"",country:l.billingCountry||""}),pe())},[l.sameAsShipping]),h.useEffect(()=>{z&&C&&($(!1),x(a=>({...a,sameAsShipping:!1})))},[z]),h.useEffect(()=>{if(C&&!B&&(l.shippingStreet||l.shippingCity||l.shippingProvince)){console.log("🔍 BillingAddressForm: SHIPPING FORM CHANGED - Updating billing form");const d={street:l.shippingStreet||"",unit:l.shippingUnit||"",building:l.shippingBuilding||"",suburb:l.shippingSuburb||"",city:l.shippingCity||"",province:l.shippingProvince||"",postalCode:l.shippingPostalCode||"",country:l.shippingCountry||""};console.log("🔍 BillingAddressForm: UPDATING BILLING DATA FROM SHIPPING FORM:",d),S(d),x(q=>({...q,billingStreet:d.street,billingUnit:d.unit,billingBuilding:d.building,billingSuburb:d.suburb,billingCity:d.city,billingProvince:d.province,billingPostalCode:d.postalCode,billingCountry:d.country}))}},[l.shippingStreet,l.shippingUnit,l.shippingBuilding,l.shippingSuburb,l.shippingCity,l.shippingProvince,l.shippingPostalCode,l.shippingCountry,C,B]),h.useEffect(()=>{var a,d,q,ne,X,N,T,V;if(C&&ee&&c.length>0){const P=c.find(I=>String(I.id)===String(ee));if(P){console.log("🔍 BillingAddressForm: DELIVERY ADDRESS CHANGED - Updating billing form:",P);const I={street:((a=P.street)==null?void 0:a.trim())||"",unit:((d=P.unit)==null?void 0:d.trim())||"",building:((q=P.building)==null?void 0:q.trim())||"",suburb:((ne=P.suburb)==null?void 0:ne.trim())||"",city:((X=P.city)==null?void 0:X.trim())||"",province:((N=P.province)==null?void 0:N.trim())||"",postalCode:((T=P.postal_code)==null?void 0:T.trim())||"",country:((V=P.country)==null?void 0:V.trim())||"South Africa"};console.log("🔍 BillingAddressForm: UPDATING BILLING DATA FROM NEW DELIVERY ADDRESS:",I),S(I),x(w=>({...w,billingStreet:I.street,billingUnit:I.unit,billingBuilding:I.building,billingSuburb:I.suburb,billingCity:I.city,billingProvince:I.province,billingPostalCode:I.postalCode,billingCountry:I.country}))}}},[ee,c,C]),h.useEffect(()=>{var a,d,q,ne,X,N,T,V;if(!K)if(C&&!B){let P={street:"",unit:"",building:"",suburb:"",city:"",province:"",postalCode:"",country:""};if(ee&&c.length>0){const w=c.find(U=>String(U.id)===String(ee));w&&(console.log("🔍 BillingAddressForm useEffect: COMPACT MODE - Using selected delivery address data:",w),P={street:((a=w.street)==null?void 0:a.trim())||"",unit:((d=w.unit)==null?void 0:d.trim())||"",building:((q=w.building)==null?void 0:q.trim())||"",suburb:((ne=w.suburb)==null?void 0:ne.trim())||"",city:((X=w.city)==null?void 0:X.trim())||"",province:((N=w.province)==null?void 0:N.trim())||"",postalCode:((T=w.postal_code)==null?void 0:T.trim())||"",country:((V=w.country)==null?void 0:V.trim())||"South Africa"})}else console.log("🔍 BillingAddressForm useEffect: EXPANDED MODE - Using form data"),P={street:l.shippingStreet||"",unit:l.shippingUnit||"",building:l.shippingBuilding||"",suburb:l.shippingSuburb||"",city:l.shippingCity||"",province:l.shippingProvince||"",postalCode:l.shippingPostalCode||"",country:l.shippingCountry||""};console.log("🔍 BillingAddressForm useEffect: Copying shipping data to billing:",P),console.log("🔍 BillingAddressForm useEffect: Current localBillingData before update:",r),S(P),console.log("🔍 BillingAddressForm useEffect: localBillingData should now be:",P)}else C&&B&&console.log("👤 BillingAddressForm: Not copying shipping to billing because profile billing is loading")},[C,B,ee,c]),h.useEffect(()=>
48{C&&!B&&(l.shippingStreet||l.shippingCity||l.shippingProvince)&&S({street:l.shippingStreet||"",unit:l.shippingUnit||"",building:l.shippingBuilding||"",suburb:l.shippingSuburb||"",city:l.shippingCity||"",province:l.shippingProvince||"",postalCode:l.shippingPostalCode||"",country:l.shippingCountry||""})},[]);const R=a=>{const{name:d,value:q}=a.target,X={billingStreet:"street",billingUnit:"unit",billingBuilding:"building",billingSuburb:"suburb",billingCity:"city",billingProvince:"province",billingPostalCode:"postalCode",billingCountry:"country"}[d]||d;S(N=>({...N,[X]:q}))},te=a=>{var q,ne,X,N,T,V,P,I;const d=a.target.checked;if(!B&&($(d),x(w=>({...w,sameAsShipping:d})),d)){let w={street:"",unit:"",building:"",suburb:"",city:"",province:"",postalCode:"",country:""};if(ee&&c.length>0){const U=c.find(fe=>String(fe.id)===String(ee));U&&(console.log("🔍 BillingAddressForm: POPULATING FROM SELECTED DELIVERY ADDRESS:",U),w={street:((q=U.street)==null?void 0:q.trim())||"",unit:((ne=U.unit)==null?void 0:ne.trim())||"",building:((X=U.building)==null?void 0:X.trim())||"",suburb:((N=U.suburb)==null?void 0:N.trim())||"",city:((T=U.city)==null?void 0:T.trim())||"",province:((V=U.province)==null?void 0:V.trim())||"",postalCode:((P=U.postal_code)==null?void 0:P.trim())||"",country:((I=U.country)==null?void 0:I.trim())||"South Africa"})}console.log("🔍 BillingAddressForm: SETTING LOCAL BILLING DATA:",w),S(w),x(U=>({...U,billingStreet:w.street,billingUnit:w.unit,billingBuilding:w.building,billingSuburb:w.suburb,billingCity:w.city,billingProvince:w.province,billingPostalCode:w.postalCode,billingCountry:w.country}))}};return h.useEffect(()=>{(l.billingStreet!==r.street||l.billingUnit!==r.unit||l.billingBuilding!==r.building||l.billingSuburb!==r.suburb||l.billingCity!==r.city||l.billingProvince!==r.province||l.billingPostalCode!==r.postalCode||l.billingCountry!==r.country)&&x(d=>({...d,billingStreet:r.street,billingUnit:r.unit,billingBuilding:r.building,billingSuburb:r.suburb,billingCity:r.city,billingProvince:r.province,billingPostalCode:r.postalCode,billingCountry:r.country}))},[r,x]),D(F,{container:!0,spacing:2,children:[!K&&!z&&o(F,{item:!0,xs:12,sx:{mt:-1,mb:1},children:o(Re,{control:o(Ve,{checked:C,name:"sameAsShipping",onChange:te}),label:"Same as shipping address"})}),o(F,{item:!0,xs:12,sm:2,children:o(me,{fullWidth:!0,name:"billingUnit",label:"Unit",value:r.unit,onChange:R,disabled:C&&!z,variant:"outlined",InputLabelProps:{shrink:!0},inputProps:{maxLength:50},placeholder:"Unit number"})}),o(F,{item:!0,xs:12,sm:3,children:o(me,{fullWidth:!0,name:"billingBuilding",label:"Building",value:r.building,onChange:R,disabled:C&&!z,variant:"outlined",InputLabelProps:{shrink:!0},inputProps:{maxLength:255},placeholder:"Building name"})}),o(F,{item:!0,xs:12,sm:7,children:o(me,{fullWidth:!0,name:"billingStreet",label:"Street Address",value:r.street,onChange:R,disabled:C&&!z,variant:"outlined",InputLabelProps:{shrink:!0},inputProps:{maxLength:255}})}),D(F,{item:!0,xs:12,sm:6,children:[console.log("🔍 BillingAddressForm rendering with localBillingData:",r),o(He,{value:r.province,onChange:a=>{S(d=>({...d,province:a}))},onLocationSelect:be,label:"Province",disabled:C&&!z,placeholder:"Select province...",apiEndpoint:"/api/",name:"billingProvince"},"billing-province-dropdown")]}),o(F,{item:!0,xs:12,sm:6,children:o(Ke,{value:r.city,onChange:a=>{console.log("🔍 BillingAddressForm CityLocationDropdown onChange:",a),S(d=>({...d,city:a})),a||(E(null),G(null))},onLocationSelect:Y,label:"City",disabled:C&&!z,placeholder:"Search for city...",parentValue:C&&!z?null:(ie==null?void 0:ie.id)||void 0,apiEndpoint:"/api/",allowCustomEntry:!0,name:"billingCity"},"billing-city-dropdown")}),o(F,{item:!0,xs:12,sm:6,children:o(Ye,{value:r.suburb,onChange:a=>{console.log("🔍 BillingAddressForm SuburbLocationDropdown onChange:",a),S(d=>({...d,suburb:a})),a||G(null)},onLocationSelect:ae,label:"Suburb",required:!1,disabled:C&&!z,placeholder:"Search for suburb (optional)...",parentValue:C&&!z?null:(k==null?void 0:k.id)||void 0,parentCityName:C&&!z?"":r.city,apiEndpoint:"/api/",allowCustomEntry:!0,name:"billingSuburb"},"billing-suburb-dropdown")}),o(F,{item:!0,xs:12,sm:6,children:o(me,{fullWidth:!0,name:"billingPostalCode",label:"Postal Code",value:r.postalCode,onChange:R,disabled:C&&!z,variant:"outlined",InputLabelProps:{shrink:!0},inputProps:{maxLength:20}})}),o(F,{item:!0,xs:12,sm:6,children:D(qe,{fullWidth:!0,variant:"outlined",children:[o(Te,{id:"billing-country-label",children:"Country"}),D(Ue,{labelId:"billing-country-label",name:"billingCountry",value:r.country||"",onChange:R,label:"Country",disabled:C&&!z,children:[o(Ce,{value:"",children:"--"}),o(Ce,{value:"South Africa",children:"South Africa"}),o(Ce,{value:"Namibia",children:"Namibia"})]})]})})]})};Je.propTypes={formData:i.shape({billingStreet:i.string,billingUnit:i.string,billingBuilding:i.string,billingSuburb:i.string,billingCity:i.string,billingProvince:i.string,billingPostalCode:i.string,billingCountry:i.string,
48sameAsShipping:i.bool,shippingStreet:i.string,shippingUnit:i.string,shippingBuilding:i.string,shippingSuburb:i.string,shippingCity:i.string,shippingProvince:i.string,shippingPostalCode:i.string,shippingCountry:i.string}).isRequired,setFormData:i.func.isRequired,isLoadingProfileBilling:i.bool,hideCheckbox:i.bool,selectedAddressId:i.oneOfType([i.string,i.number]),deliveryAddresses:i.arrayOf(i.shape({id:i.oneOfType([i.string,i.number]).isRequired,street:i.string,unit:i.string,suburb:i.string,city:i.string,province:i.string,postal_code:i.string,country:i.string}))};var xe={},Ge;function bi(){if(Ge)return xe;Ge=1;var l=$e();Object.defineProperty(xe,"__esModule",{value:!0}),xe.default=void 0;var x=l(Ne()),B=We;return xe.default=(0,x.default)((0,B.jsx)("path",{d:"M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z"}),"ExpandMore"),xe}var hi=bi();const mi=Ze(hi),Me=({formData:l,deliveryAddresses:x,selectedAddressId:B,setSelectedAddressId:K,setFormData:ee,shippingStreetRef:c,shippingUnitRef:r,shippingSuburbRef:S,shippingCityRef:ie,shippingPostalCodeRef:Q,shippingCountryRef:k,additionalInstructionsRef:E,onAddressChange:j,confirmationCheckboxRef:G,highlightConfirmationBlock:C,setShowConfirmationModal:$,onShippingConsentChange:z,billingDetailsExpanded:pe,setBillingDetailsExpanded:be,isLoadingProfileBilling:Y})=>D(Ae,{children:[l.shipping_method==="courier"&&D(Ae,{children:[D(ce,{sx:{display:"flex",alignItems:"center",gap:1.5,mb:.75,mt:.25,p:1,pl:2,borderRadius:1,backgroundColor:"grey.100",flexWrap:"wrap"},children:[o(ce,{sx:{fontSize:"1.5rem",color:"primary.main",display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",fontWeight:"bold"},children:"📍"}),o(ke,{variant:"h6",sx:{mb:0,color:"black",fontWeight:600,fontSize:"1.25rem"},children:"Shipping Address"}),o(ke,{variant:"body2",color:"text.secondary",sx:{fontWeight:700,fontSize:"1rem"},children:"Please complete for courier calculation"})]}),o(ce,{sx:{mt:1,mb:2,p:2,pt:1},children:o(Xe,{isAuthorized:!1,deliveryAddresses:x,selectedAddressId:B,setSelectedAddressId:K,formData:l,setFormData:ee,shippingStreetRef:c,shippingUnitRef:r,shippingSuburbRef:S,shippingCityRef:ie,shippingPostalCodeRef:Q,shippingCountryRef:k,additionalInstructionsRef:E,shipping_method:l.shipping_method,zoom:l.shipping_zoom,latitude:l.shipping_latitude,longitude:l.shipping_longitude,onAddressChange:j})})]}),l.shipping_method==="courier"&&o(ce,{ref:G,sx:{display:"flex",justifyContent:"center",mb:2,mt:0,p:2,bgcolor:"grey.50",borderRadius:1,border:"1px solid",borderColor:C?"warning.main":"grey.200",boxShadow:C?"0 0 0 3px rgba(255, 193, 7, 0.35)":"none",transition:"box-shadow 0.25s ease, border-color 0.25s ease",animation:C?"confirmPulse 0.6s ease-in-out 4":"none","@keyframes confirmPulse":{"0%":{boxShadow:"0 0 0 0 rgba(255, 193, 7, 0.0)"},"50%":{boxShadow:"0 0 0 4px rgba(255, 193, 7, 0.35)"},"100%":{boxShadow:"0 0 0 0 rgba(255, 193, 7, 0.0)"}}},children:o(Re,{control:o(Ve,{checked:l.confirmShippingAddress||!1,onChange:ae=>{z(ae.target.checked),ae.target.checked&&$(!1)},color:"primary",size:"large"}),label:o(ke,{variant:"body1",sx:{fontWeight:500},children:"I confirm this delivery address is correct. Calculate shipping for this address."}),sx:{m:0,"& .MuiFormControlLabel-label":{fontSize:"1rem"}}})}),D(ce,{sx:{mt:1,mb:2},children:[D(ce,{onClick:()=>be(ae=>!ae),sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:1.5,mb:1,p:1,pl:2,borderRadius:1,backgroundColor:"grey.100",cursor:"pointer"},children:[D(ce,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[o(ce,{sx:{fontSize:"1.5rem",color:"primary.main",display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",fontWeight:"bold"},children:"🏠"}),o(ke,{variant:"h6",sx:{mb:0,color:"black",fontWeight:600,fontSize:"1.25rem"},children:"Billing Address (if applicable)"})]}),o(mi,{sx:{transform:pe?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s"}})]}),o(ci,{in:pe,timeout:200,unmountOnExit:!0,children:o(ce,{sx:{mt:1,mb:2,p:2,pt:1},children:o(Je,{formData:l,setFormData:ee,isLoadingProfileBilling:Y})})})]})]});Me.propTypes={formData:i.object.isRequired,deliveryAddresses:i.array.isRequired,selectedAddressId:i.oneOfType([i.string,i.number]),setSelectedAddressId:i.func.isRequired,setFormData:i.func.isRequired,shippingStreetRef:i.object.isRequired,shippingUnitRef:i.object.isRequired,shippingSuburbRef:i.object.isRequired,shippingCityRef:i.object.isRequired,shippingPostalCodeRef:i.object.isRequired,shippingCountryRef:i.object.isRequired,additionalInstructionsRef:i.object.isRequired,onAddressChange:i.func.isRequired,confirmationCheckboxRef:i.object.isRequired,highlightConfirmationBlock:i.bool,setShowConfirmationModal:i.func.isRequired,onShippingConsentChange:i.func.isRequired,billingDetailsExpanded:i.bool.isRequired,setBillingDetailsExpanded:i.func.isRequired,isLoadingProfileBilling:i.bool.isRequired};Me.defaultProps={selectedAddressId:null,highlightConfirmationBlock:!1};const Ei=Object.freeze(Object.defineProperty({__proto__:null,default:Me},Symbol.toStringTag,{value:"Module"}));
48export{Je as B,gi as C,Me as G,Xe as S,Ei as a};

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.