import{a as e}from"./chunk-BNv3lrIs.js";import{n as t,t as n}from"./jsx-runtime-pmtNMKr4.js";import{o as r}from"./axios-Ba4xKhTU.js";import{a as i,t as a}from"./auth-BMqSpi21.js";import{i as o}from"./usuarios-uLfQbCp9.js";import{n as s}from"./toast-hrvP3G3Q.js";import{t as c}from"./Button-_yTP2B6J.js";import{t as l}from"./load-HIf6x4Qy.js";import{li as u,lr as d}from"./index-CBXvBSuP.js";import{t as f}from"./MapQuest-BSpkG3Jc.js";import{n as p}from"./coordenadas-DpjfBhY8.js";var m=e(t(),1),h=n(),g=({setCenter:e,setMaker:t})=>{let n=()=>{s.success(`¡Coordenadas registradas éxitosamente!`,{position:s.POSITION.TOP_RIGHT,autoClose:2e3})},[l,f]=(0,m.useState)(``),g=()=>{try{o(i(a())).then(e=>{let{data:t}=e;f(t.nombre)}).catch(e=>{e.message===`Network Error`&&s.error(`Conexión al servidor no disponible`)})}catch(e){console.log(e)}};return(0,m.useEffect)(()=>{g()},[]),(0,h.jsx)(`div`,{style:{textAlign:`center`,marginTop:`2%`,marginBottom:`2%`},children:(0,h.jsxs)(c,{onClick:async()=>{if(!navigator.geolocation){s.error(`El navegador no soporta geolocalización`,{position:s.POSITION.TOP_RIGHT,autoClose:2e3});return}navigator.geolocation.getCurrentPosition(async i=>{let{latitude:a,longitude:o}=i.coords,s=await(await fetch(`https://www.mapquestapi.com/geocoding/v1/reverse?key=${r}&location=${a},${o}`)).json();e&&e(a,o),t&&t(a,o,`Mi ubicacion`);let c=s.results[0].locations[0];p({latitud:a,longitud:o,ubicacion:`${c.street}, ${c.adminArea5}, ${c.adminArea3}, ${c.adminArea1}`,usuario:l,estado:`true`}),n()},e=>{alert(`Error al obtener ubicación`)})},variant:`danger`,children:[(0,h.jsx)(u,{icon:d}),`\xA0 Ubicar`]})})},_=()=>{let[e,t]=(0,m.useState)(`20.394990760246436`),[n,i]=(0,m.useState)(`-99.98675954006715`),[a,o]=(0,m.useState)(!0);(0,m.useEffect)(()=>{setTimeout(()=>{o(!1)},500)},[]);let s=[];return(0,h.jsxs)(h.Fragment,{children:[a&&(0,h.jsx)(l,{}),(0,h.jsxs)(`div`,{className:`containerFluid`,children:[(0,h.jsx)(`div`,{children:(0,h.jsx)(`div`,{children:(0,h.jsx)(g,{setCenter:(e,n)=>{t(e),i(n),window.L.mapquest.Map.getMap(`map`).setView(new window.L.LatLng(e,n),12)},setMaker:(e,t,n)=>{let r=window.L.mapquest.textMarker(new window.L.LatLng(e,t),{text:n||``,subtext:``,position:`right`,type:`marker`,icon:{primaryColor:`#a8190f`,secondaryColor:`db2c2c`,size:`md`}}).addTo(window.L.mapquest.Map.getMap(`map`));s.push(r)}})})}),(0,h.jsx)(`div`,{children:(0,h.jsx)(f,{height:`80vh`,width:`100%`,center:[e,n],tileLayer:`map`,zoom:12,apiKey:r})})]})]})};export{_ as MapaUbicacion};