import{d as E,c as F,a as z,o as p,e as k,b as x,E as L,t as S,F as A,r as R,g as c,s as V,w as y,f as $,A as B,B as C,bZ as Z,h as I,N as T,u as P,a$ as U,j as w,a2 as D,O as J,$ as G,k as H,i as W}from"./dVzHJMF1.js";import{r as Q}from"./pI06Dkb8.js";import{_ as q,n as K,y as X,L as u}from"./D8XE_5qi.js";import{c as Y}from"./DcOKUJR4.js";import{u as ee}from"./9Jp4JupG.js";import{c as oe}from"./CWHHmK0V.js";const te={class:"text-center"},ae={class:"text-sm font-semibold"},se={class:"flex flex-col gap-2 mt-2"},ne={class:"min-w-0 break-words text-left"},re={class:"font-semibold shrink-0 max-w-[50%] break-words text-right"},ie=E({__name:"MonitoracaoPopup",props:{feature:{},idMonitoracaoAtual:{default:()=>{}},contentFields:{default:()=>[]}},setup(l){const v=F(()=>l.contentFields.filter(t=>t.value!==void 0&&t.value!==null));return(t,d)=>{const h=B,m=V;return p(),z("div",te,[k("h1",ae,S(t.feature.properties.codigoElemento),1),k("div",se,[(p(!0),z(A,null,R(c(v),(a,g)=>(p(),z("div",{key:g,class:"flex justify-between gap-2"},[k("h4",ne,S(a.label),1),k("h3",re,S(a.value??""),1)]))),128))]),!t.idMonitoracaoAtual||t.feature.properties.idMonitoracao!==t.idMonitoracaoAtual?(p(),x(m,{key:0,severity:"secondary",size:"small","as-child":""},{default:y(a=>[$(h,C({to:("resolveRelativeRoute"in t?t.resolveRelativeRoute:c(Q))(((t._.provides[Z]||t.$route).params.id!==void 0?"../":"")+t.feature.properties.idMonitoracao)},a,{target:"_blank",class:"mt-4"}),{default:y(()=>d[0]||(d[0]=[I(" Visualizar ")])),_:2},1040,["to"])]),_:1})):L("",!0)])}}}),fe=Object.assign(ie,{__name:"UiMapMonitoracaoPopup"}),le=E({__name:"GeoJson",props:T({geojson:{},isMarkerHighlighted:{type:Function,default:void 0},zoomed:{type:Boolean,default:!1},center:{default:()=>{}},zoom:{default:()=>{}}},{modelValue:{},modelModifiers:{}}),emits:["update:modelValue"],setup(l){const v=P(l,"modelValue"),t=U(),d=e=>({latitudeInicial:e.getSouth(),latitudeFinal:e.getNorth(),longitudeInicial:e.getWest(),longitudeFinal:e.getEast()}),h=({cluster:e,count:o})=>e===!0&&o>1,m=w(null),a=w(null),g={pointToLayer:(e,o)=>{var s;function _(i,{sourceMin:n,sourceMax:M,targetMin:b,targetMax:N}){const j=Y(i,n,M);return b+(j-n)*(N-b)/(M-n)}if(h(e.properties)){const i=e.properties.count||0,n=_(i,{sourceMin:10,sourceMax:1e3,targetMin:32,targetMax:72});return u.marker(o,{icon:u.divIcon({html:`<div class="flex items-center justify-center bg-secondary border border-white rounded-full  text-white text-lg cluster-marker" style="width: ${n}px; height: ${n}px; box-shadow: 0 2px 6px rgba(0,0,0,0.3);"><span>${i}</span></div>`,className:"cluster-marker-container",iconSize:[n,n],iconAnchor:[n/2,n/2]}),riseOnHover:!0})}else if((s=l.isMarkerHighlighted)!=null&&s.call(l,e.properties))return u.marker(o,{icon:u.divIcon({html:'<div class="bg-primary rounded-full border-8 border-white" style="width: 32px; height: 32px; box-shadow: 0 2px 6px rgba(0,0,0,0.3);"></div>',className:"",iconAnchor:[16,16],iconSize:[32,32]})});return u.marker(o,{icon:u.divIcon({html:'<div class="bg-secondary rounded-full" style="width: 14px; height: 14px;"></div>',className:"",iconSize:[20,20],iconAnchor:[10,10]})})},onEachFeature:(e,o)=>{o.on("mousedown",_=>{const s=_.target,i=s._map;if(i instanceof u.Map)if(h(e.properties)&&s instanceof u.Marker){m.value=null,a.value=null;const M=i.getZoom()+2,b=Math.min(M,i.getMaxZoom());i.flyTo(s.getLatLng(),b)}else m.value=e,a.value=s.getLatLng()})}},r=w({});function f({bounds:e,zoom:o}){e&&(r.value.bounds=d(e)),o!==void 0&&(r.value.zoom=o),v.value={...r.value.bounds,zoom:parseInt((r.value.zoom||0).toString())}}function O(e){f({bounds:e.getBounds(),zoom:e.getZoom()})}return(e,o)=>{const _=q;return p(),x(_,{"center-button":"",center:e.center,zoom:e.zoom,zoomed:e.zoomed,"onUpdate:bounds":o[0]||(o[0]=s=>f({bounds:s})),"onUpdate:zoom":o[1]||(o[1]=s=>f({zoom:s})),onReady:O},{default:y(()=>[e.geojson?(p(),x(c(K),{key:0,geojson:e.geojson,options:g},{default:y(()=>[c(t).popup&&c(a)?(p(),x(c(X),{key:0,"lat-lng":c(a)},{default:y(()=>[D(e.$slots,"popup",{feature:c(m)})]),_:3},8,["lat-lng"])):L("",!0)]),_:3},8,["geojson"])):L("",!0)]),_:3},8,["center","zoom","zoomed"])}}}),ve=Object.assign(le,{__name:"UiMapGeoJson"}),he=async l=>{const{tipoAtivo:v,additionalFilters:t={},syncWithUrl:d=!1}=l,m=await J().getEmpresaSelecionada(),a=G(),g=F(()=>a.query),r=w(),f=ee(o=>W.ativos.monitoracoes.getGeoJson(m.sigla,v,o)),e=oe(()=>{if(!r.value)return;const o={...r.value,...t};d&&Object.assign(o,g.value),f.execute(o)},500);return H([r,d?g:()=>null],()=>{e()},{deep:!0}),{mapData:r,geojson:f}};export{ve as _,fe as a,he as u};
