{"version":3,"file":"LocationMap.CDOFa45H.mjs","names":["React.useRef","React.useState","__esmMin","window","init_ssg_sandbox_shims","init_npm_react_18_3_1","ce","init_jsx_runtime","c","p","_e","de","addPropertyControls","init_framer_Bf4_tcb2","ControlType","toTitleCase","input","prettifyAddress","address","normalizeCoordinates","lat","location","lng","escapeHtml","ensureGoogleMaps","apiKey","existing","SCRIPT_ID","resolve","reject","script","LocationsMapFramer","props","mapRef","error","setError","isLoading","setIsLoading","isMounted","map","markers","infoWindow","init","googleMapsApiKey","locations","PREVIEW_LOCATIONS","res","endpointUrl","defaultLat","defaultLng","defaultZoom","mapId","bounds","markerCount","position","marker","pinColor","imageUrl","safeImageUrl","locationName","shortDesc","path","openLocationBasePath","html","openInfoWindow","iw","iwContainer","iwTip","iwContent","closeButton","clickable","e","init_LocationMap"],"sources":["https:/framerusercontent.com/modules/myajLoZ7BAIhBL6NY0U1/yXiCoBFyYikTetKFd30W/LocationMap.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import*as React from\"react\";const SCRIPT_ID=\"google-maps-js-api\";// Framer's canvas origin cannot request the production API. Keep its preview\n// useful while published pages continue to load the current location records.\nconst PREVIEW_LOCATIONS=[{locationId:\"bermondsey\",location_name:\"Bermondsey\",address:{building_name:\"Biscuit Factory\",street:\"Drummond Rd\",town:\"London\",postcode:\"SE16 4DG\"},geo_location:{lat:51.4942155,lng:-.0640649},shortDesc:\"Located less than 5 minutes from Bermondsey underground station in South East London.\"},{locationId:\"borough\",location_name:\"London Bridge\",address:{street:\"Wardens Grove\",town:\"London\",postcode:\"SE1 0HR\"},geo_location:{lat:51.504385,lng:-.097152},shortDesc:\"Opening February 2027. 5-minute walk from Borough and Southwark stations; 10-minute walk from London Bridge station.\"}];function toTitleCase(input){return input.replace(/[_-]+/g,\" \").replace(/\\s+/g,\" \").trim().replace(/\\b\\w/g,c=>c.toUpperCase());}function prettifyAddress(address){if(!address)return\"\";const line1=[address.building_name,address.building_number,address.street].filter(Boolean).join(\" \");const line2=[address.locality_name,address.town,address.postcode].filter(Boolean).join(\", \");return[line1,line2].filter(Boolean).join(\", \");}function normalizeCoordinates(location){const lat=Number(location.geo_location?.lat);const lng=Number(location.geo_location?.lng);if(Number.isFinite(lat)&&Number.isFinite(lng))return{lat,lng};return null;}function escapeHtml(input){return input.replace(/&/g,\"&amp;\").replace(/</g,\"&lt;\").replace(/>/g,\"&gt;\").replace(/\\\"/g,\"&quot;\").replace(/'/g,\"&#39;\");}function ensureGoogleMaps(apiKey){if(!apiKey)return Promise.reject(new Error(\"Missing Google Maps API key\"));if(window.google?.maps)return Promise.resolve();const existing=document.getElementById(SCRIPT_ID);if(existing){return new Promise((resolve,reject)=>{existing.addEventListener(\"load\",()=>resolve(),{once:true});existing.addEventListener(\"error\",()=>reject(new Error(\"Failed loading Google Maps script\")),{once:true});});}return new Promise((resolve,reject)=>{const script=document.createElement(\"script\");script.id=SCRIPT_ID;script.src=`https://maps.googleapis.com/maps/api/js?key=${encodeURIComponent(apiKey)}`;script.async=true;script.defer=true;script.onload=()=>resolve();script.onerror=()=>reject(new Error(\"Failed loading Google Maps script\"));document.head.appendChild(script);});}export default function LocationsMapFramer(props){const{endpointUrl,googleMapsApiKey,mapId,defaultLat,defaultLng,defaultZoom,pinColor,openLocationBasePath}=props;const mapRef=React.useRef(null);const[error,setError]=React.useState(\"\");const[isLoading,setIsLoading]=React.useState(true);React.useEffect(()=>{let isMounted=true;let map=null;let markers=[];let infoWindow=null;async function init(){try{setError(\"\");setIsLoading(true);await ensureGoogleMaps(googleMapsApiKey);if(!isMounted||!mapRef.current)return;let locations;if(window.location.hostname.endsWith(\".framercanvas.com\")){locations=PREVIEW_LOCATIONS;}else{const res=await fetch(endpointUrl);if(!res.ok)throw new Error(`Request failed: ${res.status}`);locations=await res.json();}if(!Array.isArray(locations))throw new Error(\"Endpoint did not return an array\");if(!isMounted||!mapRef.current)return;map=new window.google.maps.Map(mapRef.current,{center:{lat:defaultLat,lng:defaultLng},zoom:defaultZoom,clickableIcons:false,mapId:mapId||undefined});infoWindow=new window.google.maps.InfoWindow({disableAutoPan:true});const bounds=new window.google.maps.LatLngBounds;let markerCount=0;for(const location of locations){const position=normalizeCoordinates(location);if(!position)continue;const marker=new window.google.maps.Marker({map,position,icon:{path:window.google.maps.SymbolPath.CIRCLE,fillColor:pinColor,fillOpacity:1,strokeColor:\"#ffffff\",strokeOpacity:1,strokeWeight:2,scale:8}});const imageUrl=location.imageUrls?.[0]??\"\";const safeImageUrl=imageUrl.replace(/\"/g,\"%22\");const locationName=escapeHtml(toTitleCase(location.location_name??\"Location\"));const address=escapeHtml(prettifyAddress(location.address));const shortDesc=location.shortDesc?escapeHtml(location.shortDesc):\"\";const path=`${openLocationBasePath.replace(/\\/$/,\"\")}/${encodeURIComponent(location.locationId)}`;const html=`\n<div style=\"display:flex;gap:10px;align-items:flex-start;max-width:260px;cursor:pointer;font-family:Arial,sans-serif;background-color:#F7F0D1;padding:8px;border-radius:8px;\">\n  ${imageUrl?`<img src=\"${safeImageUrl}\" alt=\"${locationName}\" style=\"width:36px;height:36px;border-radius:999px;object-fit:cover;\"/>`:\"\"}\n  <div>\n    <div style=\"font-size:16px;font-weight:600;line-height:1.2;\">${locationName}</div>\n    <div style=\"font-size:11px;color:#666;line-height:1.3;margin-top:2px;\">${address}</div>\n    ${shortDesc?`<div style=\"font-size:12px;color:#333;line-height:1.3;margin-top:4px;\">${shortDesc}</div>`:\"\"}\n  </div>\n</div>\n`;const openInfoWindow=()=>{infoWindow.setContent(html);window.google.maps.event.addListenerOnce(infoWindow,\"domready\",()=>{const iw=document.querySelector(\".gm-style-iw\");if(!iw)return;const iwContainer=document.querySelector(\".gm-style .gm-style-iw-c\");if(iwContainer){iwContainer.style.backgroundColor=\"#F7F0D1\";iwContainer.style.padding=\"0\";iwContainer.style.borderRadius=\"8px\";}const iwTip=document.querySelector(\".gm-style .gm-style-iw-tc\");if(iwTip){iwTip.style.display=\"none\";}const iwContent=document.querySelector(\".gm-style .gm-style-iw-d\");if(iwContent){iwContent.style.overflow=\"hidden\";iwContent.style.maxHeight=\"none\";iwContent.style.padding=\"0\";}const closeButton=document.querySelector(\".gm-style .gm-ui-hover-effect\");if(closeButton){closeButton.style.display=\"none\";}const clickable=iw.querySelector(\"div\");if(!clickable)return;clickable.onclick=()=>{window.location.href=path;};});infoWindow.open({map,anchor:marker});};marker.addListener(\"click\",openInfoWindow);marker.addListener(\"mouseover\",openInfoWindow);markers.push(marker);bounds.extend(position);markerCount+=1;}if(markerCount>1&&!bounds.isEmpty())map.fitBounds(bounds);setIsLoading(false);}catch(e){if(!isMounted)return;setError(e?.message||\"Failed to load map\");setIsLoading(false);}}init();return()=>{isMounted=false;for(const marker of markers)marker.setMap(null);markers=[];if(infoWindow)infoWindow.close();map=null;};},[endpointUrl,googleMapsApiKey,mapId,defaultLat,defaultLng,defaultZoom,pinColor,openLocationBasePath]);return /*#__PURE__*/_jsxs(\"div\",{style:{width:\"100%\",height:\"100%\",position:\"relative\",overflow:\"hidden\",borderRadius:12},children:[/*#__PURE__*/_jsx(\"div\",{ref:mapRef,style:{width:\"100%\",height:\"100%\"}}),isLoading&&/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",inset:0,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",backgroundColor:\"rgba(255,255,255,0.72)\",fontFamily:\"Arial, sans-serif\",fontSize:14},children:\"Loading locations...\"}),error&&/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",left:12,right:12,bottom:12,backgroundColor:\"#fee2e2\",color:\"#991b1b\",border:\"1px solid #fecaca\",borderRadius:8,padding:\"10px 12px\",fontFamily:\"Arial, sans-serif\",fontSize:12},children:error})]});}LocationsMapFramer.defaultProps={endpointUrl:\"https://europe-west2-pocketstorage-prod.cloudfunctions.net/location-getLocations\",googleMapsApiKey:\"AIzaSyAGMJcoGT6ApNggPVf8NFOl37jnvQDgihM\",mapId:\"a7ecbe6fbcb95b61\",defaultLat:51.4942155,defaultLng:-.05,defaultZoom:10,pinColor:\"#f66e9f\",openLocationBasePath:\"https://app.pocket.storage/locations\"};addPropertyControls(LocationsMapFramer,{endpointUrl:{type:ControlType.String,title:\"Endpoint\"},googleMapsApiKey:{type:ControlType.String,title:\"Google API Key\",placeholder:\"AIza...\"},mapId:{type:ControlType.String,title:\"Map ID\"},openLocationBasePath:{type:ControlType.String,title:\"Location Path\"},defaultLat:{type:ControlType.Number,title:\"Default Lat\",step:1e-6},defaultLng:{type:ControlType.Number,title:\"Default Lng\",step:1e-6},defaultZoom:{type:ControlType.Number,title:\"Zoom\",min:1,max:20,step:1},pinColor:{type:ControlType.Color,title:\"Pin Color\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"LocationsMapFramer\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./LocationMap.map"],"mappings":"A,6MAEgmB,SAASe,EAAY,EAAM,CAAC,OAAOC,EAAM,QAAQ,SAAS,GAAG,CAAC,CAAC,QAAQ,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,QAAQ,QAAQ,GAAGR,EAAE,YAAY,CAAC,CAAE,CAAC,SAASS,EAAgB,EAAQ,CAAwN,OAAnNC,EAAyN,CAA5L,CAACA,EAAQ,cAAcA,EAAQ,gBAAgBA,EAAQ,MAAM,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAA6G,EAA5F,CAACA,EAAQ,cAAcA,EAAQ,KAAKA,EAAQ,QAAQ,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,IAAuB,CAAC,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,IAAI,EAAlP,EAAoP,CAAC,SAASC,EAAqB,EAAS,CAAC,IAAMC,EAAI,OAAOC,EAAS,cAAc,GAAG,EAAQC,EAAI,OAAOD,EAA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