import{v as C,j as a,A as T}from"./vendor-mui-69397583.js";import{r as s,f as N,c as r}from"./vendor-react-ece1c85f.js";import{u as b,G as E,I as L,M as I}from"./esm-f306d015.js";import"./Alert-7dfbd254.js";import{B as P}from"./index-c62ac197.js";import"./index-6b6d0f06.js";import"./index-c2088808.js";import"./Drawer-949c18c6.js";import"./FormContainer-91c2b0e4.js";import"./Switcher-c8648037.js";import"./index-36228db5.js";import"./Upload-fb34ce03.js";import{u as A}from"./vendor-i18n-2fcb1983.js";const R=C(a.jsxs("g",{fillRule:"evenodd",children:[a.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8"}),a.jsx("path",{d:"M13.49 11.38c.43-1.22.17-2.64-.81-3.62-1.11-1.11-2.79-1.3-4.1-.59l2.35 2.35-1.41 1.41-2.35-2.35c-.71 1.32-.52 2.99.59 4.1.98.98 2.4 1.24 3.62.81l3.41 3.41c.2.2.51.2.71 0l1.4-1.4c.2-.2.2-.51 0-.71z"})]}),"BuildCircleOutlined"),U=t=>{const[z,o]=s.useState(!1),[d,c]=s.useState(null),u={width:"100%",height:"100%"},m=N(),[B,g]=s.useState(""),[f,h]=s.useState(!1),y=t==null?void 0:t.decryptValue,{t:O,i18n:x}=A(),w=[{featureType:"all",elementType:"labels.text",stylers:[{color:"#878787"}]},{featureType:"all",elementType:"labels.text.stroke",stylers:[{visibility:"off"}]},{featureType:"landscape",elementType:"all",stylers:[{color:"#f9f5ed"}]},{featureType:"road.highway",elementType:"all",stylers:[{color:"#f5f5f5"}]},{featureType:"road.highway",elementType:"geometry.stroke",stylers:[{color:"#c9c9c9"}]},{featureType:"water",elementType:"all",stylers:[{color:"#aee0f4"}]}],{isLoaded:i}=b({googleMapsApiKey:y||"VITE_GOOGLE_MAPS_API_KEY_PLACEHOLDER"}),[n,j]=r.useState(null),v=r.useCallback(function(l){j(l)},[]),S=s.useCallback(e=>{c(e),t!=null&&t.onPinSelect&&(t==null||t.onPinSelect(e==null?void 0:e.id)),o(!0)},[]),k=()=>{c(null),o(!1),t==null||t.onPinSelect(null),g("")};s.useEffect(()=>{if(i&&n&&t.properties.length>0){const e=new window.google.maps.LatLngBounds;t.properties.forEach(l=>{l!=null&&l.latitude&&(l!=null&&l.longitude)&&e.extend(new window.google.maps.LatLng(l.latitude,l.longitude))}),e.isEmpty()||n.fitBounds(e),h(!0)}},[i,n,t.properties]);const M=()=>!i||!n||!f?null:t.properties.map(e=>e.latitude&&e.longitude?a.jsx(I,{icon:{url:e.id===(t==null?void 0:t.hoveredRowKey)?"/img/map/pin-dark.png":"/img/map/pin-orange.png",scaledSize:new window.google.maps.Size(60,60)},position:{lat:e.latitude,lng:e.longitude},onClick:()=>S(e)},e.id):null);return i?a.jsx("div",{style:t!=null&&t.isDashboard?{width:"100%",height:"98%"}:{width:"100%",height:"calc(100vh - 270px)"},children:a.jsxs(E,{mapContainerStyle:u,zoom:8,options:{styles:w},onLoad:v,children:[M(),d&&(()=>{var l;const e=d;return a.jsx(L,{options:{pixelOffset:new window.google.maps.Size(0,-40)},position:{lat:e==null?void 0:e.latitude,lng:e==null?void 0:e.longitude},onCloseClick:k,children:a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"py-4 pt-0",children:a.jsx(T,{className:"mr-4",style:{backgroundColor:"#f1742d",color:"white"},children:`${(l=e==null?void 0:e.leadName)==null?void 0:l[0]}`})}),a.jsxs("div",{className:"py-2 pt-1",children:[a.jsx("div",{className:"font-bold py-1",children:(e==null?void 0:e.leadName)??""}),a.jsx("div",{className:"py-1",children:(e==null?void 0:e.latitude)+","+(e==null?void 0:e.longitude)})]}),a.jsx("div",{className:"py-4",children:a.jsxs("div",{className:"py-1",children:[a.jsx("span",{className:"font-bold",children:a.jsx(R,{})})," ",e==null?void 0:e.address]})}),a.jsx("div",{className:"py-1",children:a.jsx(P,{className:"w-full",variant:"solid",size:"md",onClick:()=>m(`/app/pages/map-details/${e==null?void 0:e.id}`,{state:{leadData:e,leadMeetings:(e==null?void 0:e.meetings)||[]}}),children:"Details"})})]})})})()]},`map-${x.language}`)}):a.jsx(a.Fragment,{})};export{U as M};
