import{i as e}from"./chunk-aKtaBQYM.js";import{Vt as t,Y as n,zt as r}from"./mui-B6lh3XSP.js";import{A as i,I as a,M as o,R as s}from"./index-KVuxnkWj.js";var c=e(t(),1),l=()=>{let e=(0,c.useId)(),t=n(),l=s(`mapGeofences`,!0),u=r(e=>e.geofences.items);return(0,c.useEffect)(()=>l?(a.addSource(e,{type:`geojson`,data:{type:`FeatureCollection`,features:[]}}),a.addLayer({source:e,id:`geofences-fill`,type:`fill`,filter:[`all`,[`==`,`$type`,`Polygon`]],paint:{"fill-color":[`get`,`color`],"fill-outline-color":[`get`,`color`],"fill-opacity":.1}}),a.addLayer({source:e,id:`geofences-line`,type:`line`,paint:{"line-color":[`get`,`color`],"line-width":[`get`,`width`],"line-opacity":[`get`,`opacity`]}}),a.addLayer({source:e,id:`geofences-title`,type:`symbol`,layout:{"text-field":`{name}`,"text-font":i(a),"text-size":12},paint:{"text-halo-color":`white`,"text-halo-width":1}}),()=>{a.getLayer(`geofences-fill`)&&a.removeLayer(`geofences-fill`),a.getLayer(`geofences-line`)&&a.removeLayer(`geofences-line`),a.getLayer(`geofences-title`)&&a.removeLayer(`geofences-title`),a.getSource(e)&&a.removeSource(e)}):()=>{},[l,e]),(0,c.useEffect)(()=>{l&&a.getSource(e)?.setData({type:`FeatureCollection`,features:Object.values(u).filter(e=>!e.attributes.hide).map(e=>o(t,e))})},[l,u,e,t]),null};export{l as t};