1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4086],{2102:function(e,t,r){r.r(t),r.d(t,{default:function(){return O}});var n=r(7437),o=r(2265),l=r(7748),a=r.n(l),i=r(3732),s=r(8224);let c="sylvie:mapOverlayIds",d="sylvie:mapTemporalDates",u=[{id:"ign-plan",name:"Carte IGN",group:"France",tiles:["https://data.geopf.fr/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=GEOGRAPHICALGRIDSYSTEMS.PLANIGNV2&STYLE=normal&TILEMATRIXSET=PM&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&FORMAT=image/png"],maxZoom:18,attribution:"© IGN"},{id:"ign-topo",name:"Topo IGN",group:"France",tiles:["https://data.geopf.fr/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=GEOGRAPHICALGRIDSYSTEMS.MAPS.BDUNI.J1&STYLE=normal&TILEMATRIXSET=PM&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&FORMAT=image/jpeg"],maxZoom:18,attribution:"© IGN"},{id:"ign-ortho",name:"Photo aerienne IGN",group:"France",tiles:["https://data.geopf.fr/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=ORTHOIMAGERY.ORTHOPHOTOS&STYLE=normal&TILEMATRIXSET=PM&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&FORMAT=image/jpeg"],maxZoom:18,attribution:"© IGN"},{id:"ign-ortho-irc",name:"BD Ortho IRC",group:"France",tiles:["https://data.geopf.fr/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=ORTHOIMAGERY.ORTHOPHOTOS.IRC&STYLE=normal&TILEMATRIXSET=PM&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&FORMAT=image/jpeg"],maxZoom:18,attribution:"© IGN"},{id:"ign-cadastre",name:"Cadastre",group:"France",tiles:["https://data.geopf.fr/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=CADASTRALPARCELS.PARCELLAIRE_EXPRESS&STYLE=normal&TILEMATRIXSET=PM&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&FORMAT=image/png"],maxZoom:18,attribution:"© IGN",overlayEligible:!0,overlayOpacity:.62,overlayOrder:30},{id:"ign-pentes",name:"Carte des pentes",group:"France",tiles:["https://data.geopf.fr/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=GEOGRAPHICALGRIDSYSTEMS.SLOPES.MOUNTAIN&STYLE=normal&TILEMATRIXSET=PM&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&FORMAT=image/png"],maxZoom:18,attribution:"© IGN",overlayEligible:!0,overlayOpacity:.65,overlayOrder:10},{id:"ign-bd-foret-v2",name:"BD For\xeat v2 (IGN)",group:"France",tiles:["https://data.geopf.fr/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=LANDCOVER.FORESTINVENTORY.V2&STYLE=normal&TILEMATRIXSET=PM&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&FORMAT=image/png"],maxZoom:18,attribution:"© IGN â BD For\xeat\xae",overlayEligible:!0,overlayOpacity:.65,overlayOrder:20},{id:"ign-old",name:"D\xe9broussaillement (OLD)",group:"France",tiles:["https://data.geopf.fr/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=DEBROUSSAILLEMENT&STYLE=nolegend&TILEMATRIXSET=PM&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&FORMAT=image/png"],maxZoom:18,attribution:"© IGN â Obligations l\xe9gales de d\xe9broussaillement \xb7 Licence Ouverte 2.0",overlayEligible:!0,overlayOpacity:.55,overlayOrder:25,notice:"Couverture tr\xe8s in\xe9gale selon les d\xe9partements â cf. pastille dâavertissement."},{id:"ign-dfci",name:"Carroyage DFCI",group:"France",tiles:["https://data.geopf.fr/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=GEOGRAPHICALGRIDSYSTEM.DFCI&STYLE=normal&TILEMATRIXSET=PM&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&FORMAT=image/png"],maxZoom:16,attribution:"© IGN â Carroyage DFCI \xb7 Licence Ouverte 2.0",overlayEligible:!0,overlayOpacity:.7,overlayOrder:40},{id:"gibs-modis-721",name:"MODIS SWIR (br\xfbl\xe9)",group:"Imagerie dat\xe9e",tiles:["https://gibs.earthdata.nasa.gov/wmts/epsg3857/best/MODIS_Terra_CorrectedReflectance_Bands721/default/{date}/GoogleMapsCompatible_Level9/{z}/{y}/{x}.jpg"],maxZoom:9,attribution:"Imagery from NASA Worldview / GIBS, part of NASA EOSDIS",overlayEligible:!0,overlayOpacity:1,overlayOrder:5,temporal:{defaultOffsetDays:1,minDate:"2000-02-24"},notice:"Composition SWIR : les surfaces br\xfbl\xe9es ressortent en brun-rouge."},{id:"gibs-viirs-truecolor",name:"VIIRS vraie couleur",group:"Imagerie dat\xe9e",tiles:["https://gibs.earthdata.nasa.gov/wmts/epsg3857/best/VIIRS_NOAA20_CorrectedReflectance_True
1Color/default/{date}/GoogleMapsCompatible_Level9/{z}/{y}/{x}.jpg"],maxZoom:9,attribution:"Imagery from NASA Worldview / GIBS, part of NASA EOSDIS",overlayEligible:!0,overlayOpacity:1,overlayOrder:6,temporal:{defaultOffsetDays:1,minDate:"2018-01-05"},notice:"Le panache de fum\xe9e est visible. Une date post-feu est souvent nuageuse : faire varier la date."},{id:"osm",name:"OpenStreetMap",group:"International",tiles:["https://tile.openstreetmap.org/{z}/{x}/{y}.png"],maxZoom:19,attribution:"© OpenStreetMap contributors"},{id:"otm",name:"OpenTopoMap",group:"International",tiles:["https://tile.opentopomap.org/{z}/{x}/{y}.png"],maxZoom:17,attribution:"© OpenTopoMap"},{id:"esri-sat",name:"Satellite (Esri)",group:"International",tiles:["https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"],maxZoom:19,attribution:"© Esri"},{id:"cyclosm",name:"CyclOSM",group:"International",tiles:["https://a.tile-cyclosm.openstreetmap.fr/cyclosm/{z}/{x}/{y}.png"],maxZoom:19,attribution:"© CyclOSM / OpenStreetMap"},{id:"swiss-color",name:"Carte nationale",group:"Suisse",tiles:["https://wmts.geo.admin.ch/1.0.0/ch.swisstopo.pixelkarte-farbe/default/current/3857/{z}/{x}/{y}.jpeg"],maxZoom:18,attribution:"© swisstopo"},{id:"swiss-ortho",name:"SWISSIMAGE",group:"Suisse",tiles:["https://wmts.geo.admin.ch/1.0.0/ch.swisstopo.swissimage/default/current/3857/{z}/{x}/{y}.jpeg"],maxZoom:18,attribution:"© swisstopo"},{id:"spain-topo",name:"Carte topographique",group:"Espagne",tiles:["https://www.ign.es/wmts/mapa-raster?request=getTile&layer=MTN&TileMatrixSet=GoogleMapsCompatible&TileMatrix={z}&TileCol={x}&TileRow={y}&format=image/jpeg"],maxZoom:20,attribution:"© IGN Espana"},{id:"spain-ortho",name:"Orthophotos PNOA",group:"Espagne",tiles:["https://www.ign.es/wmts/pnoa-ma?request=getTile&layer=OI.OrthoimageCoverage&TileMatrixSet=GoogleMapsCompatible&TileMatrix={z}&TileCol={x}&TileRow={y}&format=image/jpeg"],maxZoom:20,attribution:"© IGN Espana"},{id:"norway-topo",name:"Carte topographique",group:"Norvege",tiles:["https://cache.kartverket.no/v1/wmts/1.0.0/topo/default/webmercator/{z}/{y}/{x}.png"],maxZoom:18,attribution:"© Kartverket"}],p=u.filter(e=>e.overlayEligible),g=u.filter(e=>e.temporal),f=e=>e.toISOString().slice(0,10);function y(e){let t=new Date;return t.setUTCDate(t.getUTCDate()-e),f(t)}function m(e){var t,r;return y(null!==(r=null===(t=e.temporal)||void 0===t?void 0:t.defaultOffsetDays)&&void 0!==r?r:1)}let h=()=>y(1);function v(e,t){if(!e.temporal)return e.tiles;let r=t&&/^\d{4}-\d{2}-\d{2}$/.test(t)?t:m(e);return e.tiles.map(e=>e.replace("{date}",r))}function x(e,t){var r,n,o;let l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=[...t].sort((e,t)=>{var r,n;return(null!==(r=e.overlayOrder)&&void 0!==r?r:0)-(null!==(n=t.overlayOrder)&&void 0!==n?n:0)}),i={"base-tiles":{type:"raster",tiles:v(e,l[e.id]),tileSize:null!==(r=e.tileSize)&&void 0!==r?r:256,attribution:e.attribution,maxzoom:e.maxZoom}},s=[{id:"base-tiles",type:"raster",source:"base-tiles",minzoom:0,maxzoom:24,paint:{"raster-resampling":"linear"}}];for(let e of a){let t="overlay-tiles-".concat(e.id);i[t]={type:"raster",tiles:v(e,l[e.id]),tileSize:null!==(n=e.tileSize)&&void 0!==n?n:256,attribution:e.attribution,maxzoom:e.maxZoom},s.push({id:"overlay-layer-".concat(e.id),type:"raster",source:t,minzoom:0,maxzoom:24,paint:{"raster-opacity":null!==(o=e.overlayOpacity)&&void 0!==o?o:.65,"raster-resampling":"linear"}})}return{version:8,glyphs:"https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf",sources:i,layers:s}}let b="sylvie:forestOverlayIds",L=[{id:"itineraires-bois-ronds",name:"Itin\xe9raires bois ronds",typeName:"NAVIFOREST_PUBLIC:itineraires-bois-ronds",access:"public",geometry:"line",color:"#b45309",attribution:"\xa9 IGN â NaviForest"},{id:"dessertes-forestieres",name:"Dessertes foresti\xe8res",typeName:"NAVIFOREST_PRIVE:dessertes-forestieres",access:"private",geometry:"line",color:"#7c3aed",attribution:"\xa9 IGN â NaviForest"},{id:"equipements",name:"\xc9quipements forestiers",typeName:"NAVIFOREST_PRIVE:equipements",access:"private",geometry:"point",color:"#2563eb",attribution:"\xa9 IGN â NaviForest"},{id:"contraintes",name:"Contraintes",typeName:"NAVIFOREST_PRIVE:contraintes",access:"private",geometry:"point",color:"#dc2626",attribution:"\xa9 IGN â NaviForest"},{id:"old-debroussaillement",name:"Zones OLD (d\xe9tail)",typeName:"DEBROUSSAILLEMENT:debroussaillement",access:"public",geometry:"polygon",color:"#ea580c",attribution:"\xa9 IGN â DEBROUSSAILLEMENT \xb7 Licence Ouverte 2.0",popupFields:[{key:"nature",label:"Nature"},{key:"millesime",label:"Mill\xe9sime"},{key:"dat_ap_old",label:"Arr\xeat\xe9 du"},{key:"source",label:"Source"},{key:"url",label:"Arr\xeat\xe9 pr\xe9fectoral",link:!0}]}
1,{id:"bd-foret-v2-vecteur",name:"BD For\xeat v2 (d\xe9tail)",typeName:"LANDCOVER.FORESTINVENTORY.V2:formation_vegetale",access:"public",geometry:"polygon",color:"#16a34a",attribution:"\xa9 IGN â BD For\xeat\xae \xb7 Licence Ouverte 2.0",popupFields:[{key:"tfv",label:"Type de formation"},{key:"essence",label:"Essence"},{key:"tfv_g11",label:"Groupe"},{key:"code_tfv",label:"Code TFV"}]}],w="sylvie:fireOverlayIds",S=[{id:"feux-recents",name:"Feux r\xe9cents (12 mois)",description:"Surfaces br\xfbl\xe9es cartographi\xe9es depuis 12 mois (Copernicus EFFIS et EMS).",kind:"polygon",sources:["effis","ems"],windowDays:365,color:"#dc2626",fillOpacity:.35,outline:!0,attribution:"Source : Copernicus EMS / EFFIS, \xa9 Union europ\xe9enne"},{id:"feux-historique",name:"Historique des surfaces br\xfbl\xe9es",description:"Toutes les surfaces br\xfbl\xe9es connues : EFFIS depuis 2000, contours DDT depuis 1949.",kind:"polygon",sources:["effis","ems","ddt_02a","ddt_034","ddt_083"],windowDays:null,color:"#78350f",fillOpacity:.2,outline:!1,attribution:"Source : Copernicus EMS / EFFIS, \xa9 Union europ\xe9enne \xb7 \xa9 DDTM (contours d\xe9partementaux)"},{id:"points-chauds",name:"Points chauds (7 jours)",description:"D\xe9tections thermiques VIIRS des 7 derniers jours. Position \xe0 \xb1375 m, non confirm\xe9e au sol.",kind:"point",sources:["firms"],windowDays:7,color:"#f97316",attribution:"NASA FIRMS / LANCE, NASA EOSDIS"}],E={"001":0,"002":0,"003":0,"004":1,"005":12,"006":12338,"007":18283,"008":0,"009":1363,"010":0,"011":1694,"012":1,"013":490,"014":0,"015":0,"016":20,"017":7723,"018":580,"019":2,"021":0,"022":14,"023":0,"024":1,"025":0,"026":13801,"027":226,"028":223,"029":5667,"02A":33475,"02B":34409,"030":3663,"031":2345,"032":16,"033":27107,"034":4493,"035":3868,"036":764,"037":709,"038":2,"039":0,"040":14960,"041":2492,"042":616,"043":588,"044":0,"045":1764,"046":1299,"047":7795,"048":3806,"049":72,"050":0,"051":0,"052":0,"053":0,"054":0,"055":0,"056":7494,"057":0,"058":0,"059":0,"060":0,"061":0,"062":0,"063":0,"064":22307,"065":7485,"066":9,"067":0,"068":0,"069":0,"070":0,"071":0,"072":40,"073":4,"074":0,"075":0,"076":0,"077":94,"078":0,"079":112,"080":0,"081":777,"082":588,"083":1,"084":1595,"085":0,"086":56,"087":0,"088":0,"089":0,"090":0,"091":4,"092":0,"093":0,"094":0,"095":0,971:0,972:0,973:0,974:0,976:0};function k(e){if(!e)return null;let t=e.trim().toUpperCase();return/^[0-9AB]{2,3}$/.test(t)?2===t.length?"0".concat(t):t:null}async function T(e,t,r){let n="https://geo.api.gouv.fr/communes?lat=".concat(e.toFixed(5),"&lon=").concat(t.toFixed(5),"&fields=codeDepartement");try{var o;let e=await fetch(n,{signal:r});if(!e.ok)return null;let t=await e.json();return k(null==t?void 0:null===(o=t[0])||void 0===o?void 0:o.codeDepartement)}catch(e){return null}}var I=r(2904),M=r(4598),C=r(1474);let N=28*Math.PI/180;function R(e,t){let r=111320*Math.cos(t.lat*Math.PI/180),n=(t.lng-e.lng)*r,o=(t.lat-e.lat)*111320,l=Math.hypot(n,o);if(l<.001)return{left:t,right:t};let a=Math.atan2(o,n),i=a+Math.PI-N,s=a+Math.PI+N,c=Math.min(25,.4*l);return{left:{lng:t.lng+Math.cos(i)*c/r,lat:t.lat+Math.sin(i)*c/111320},right:{lng:t.lng+Math.cos(s)*c/r,lat:t.lat+Math.sin(s)*c/111320}}}function j(e,t,r,n,o){let l=(0,I.aH)(o),a=l.map(e=>[e.lng,e.lat]);try{let r=e.getSource(t);null==r||r.setData({type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[a]}})}catch(e){}let i=null==n?void 0:n.trim();if(r&&i){let t=l.slice(0,-1);if(0===t.length)return;let n=0,o=0;for(let e of t)n+=e.lng,o+=e.lat;n/=t.length,o/=t.length;try{let t=e.getSource(r);null==t||t.setData({type:"Feature",properties:{label:i},geometry:{type:"Point",coordinates:[n,o]}})}catch(e){}}}function O(e){var t,r;let{traces:l,coordonnees:f,selectedTraceId:y,onSelectTrace:v,onPointMoved:N,onVertexDeleted:O,onVertexInserted:A,onContinueTrace:F,readOnly:_=!1,drawMode:P,drawPoints:D,onMapClick:z,onMapDblClick:G,initialCenter:W,captureRequest:V,onCaptureComplete:Z,peerCursors:B,onLocalCursorMove:q,onLocalCursorLeave:Y,annotations:U,selectedAnnotationId:H,onSelectAnnotation:X,onAnnotationGeometryChanged:J,showAnnotations:Q,legendeArrowOrigin:$,legendeShapeOrigin:K,legendeEllipseMajorEnd:ee=null,legendePendingPreview:et=null,legende:er=null,onLegendeRequestEdit:en,onLegendeToggleVisible:eo,legendeReadOnly:el=!1,excludeLegendeFromCapture:ea=!1,legendeVisitorVisible:ei,externalFocus:es=null,onExternalFocusConsumed:ec,discussionPins:ed,selectedDiscussionId:eu=null,onSelectDiscussionPin:ep,overlayCartes:eg=[],overlayCarteIds:ef=[],onOpenOverlayPicker:ey,onSelectOverlayTrace:em,onMapReady:eh,onMapContextMenu:ev,cadastreHighlight:ex=null}=e,eb=(0,o.useRef)(null),eL=(0,o.useRef)(null),ew=(0,o.useRef)(null),eS=(0,o.useRef)(!0),eE=(0,o.useRef)(!1),ek=(0,o.useRef)([]),eT=(0,o.useRef)([]),eI=(0,o.useRef)([]),eM=(0,o.useRef)(new Map),eC=(0,o.useRef)(new Map),eN=(0,o.useRef)([]),eR=(0,o.useRef)(null),ej=(0,o.useRef)([]),eO=(0,o.useRef)(null),eA=(0,o.useRef)(null),[eF,e_]=(0,o.useState)("ign-plan"),[eP,eD]=(0,o.useState)([]),ez=(0,o.useMemo)(()=>"cadastre"!==P||eP.includes("ign-cadastre")?eP:[...eP,"ign-cadastre"],[P,eP]),eG=(0,o.useMemo)(()=>[...ez].sort().join(","),[ez]),eW=(0,o.useMemo)(()=>ez.filter(e=>e!==eF).map(e=>u.find(t=>
1t.id===e)).filter(e=>null!=e),[ez,eF]),eV=eW.length;(0,o.useEffect)(()=>{eE.current&&window.localStorage.setItem(c,JSON.stringify(eP))},[eP]);let[eZ,eB]=(0,o.useState)([]),eq=(0,o.useMemo)(()=>[...eZ].sort().join(","),[eZ]);(0,o.useRef)([]).current=eZ;let eY=(0,o.useRef)(new Map),[eU,eH]=(0,o.useState)(!1);(0,o.useEffect)(()=>{eE.current&&window.localStorage.setItem(b,JSON.stringify(eZ))},[eZ]);let[eX,eJ]=(0,o.useState)([]),eQ=(0,o.useMemo)(()=>[...eX].sort().join(","),[eX]),e$=(0,o.useRef)(new Map),[eK,e0]=(0,o.useState)(!1);(0,o.useEffect)(()=>{eE.current&&window.localStorage.setItem(w,JSON.stringify(eX))},[eX]);let[e1,e2]=(0,o.useState)({}),e5=(0,o.useMemo)(()=>Object.entries(e1).sort().map(e=>{let[t,r]=e;return"".concat(t,":").concat(r)}).join(","),[e1]);(0,o.useEffect)(()=>{eE.current&&window.localStorage.setItem(d,JSON.stringify(e1))},[e1]);let[e3,e4]=(0,o.useState)(null),[e8,e6]=(0,o.useState)(!1),[e7,e9]=(0,o.useState)(!1),[te,tt]=(0,o.useState)(!0),tr=(0,o.useRef)(te);tr.current=te;let tn=(0,o.useRef)(P);tn.current=P;let[to,tl]=(0,o.useState)(()=>{let e=window.localStorage.getItem("sylvie:showAnnotations");if(null!==e)return"1"===e;let t=window.localStorage.getItem("sylvie:showLegendes");return null===t||"1"===t}),ta=null!=Q?Q:to,ti=(0,o.useRef)(!1),ts=(0,o.useRef)(v),tc=(0,o.useRef)(N),td=(0,o.useRef)(z),tu=(0,o.useRef)(G),tp=(0,o.useRef)(X),tg=(0,o.useRef)(J);(0,o.useEffect)(()=>{ts.current=v},[v]),(0,o.useEffect)(()=>{tc.current=N},[N]),(0,o.useEffect)(()=>{td.current=z},[z]),(0,o.useEffect)(()=>{tu.current=G},[G]),(0,o.useEffect)(()=>{tp.current=X},[X]),(0,o.useEffect)(()=>{tg.current=J},[J]);let tf=(0,o.useRef)(ep);(0,o.useEffect)(()=>{tf.current=ep},[ep]);let ty=(0,o.useRef)(ec);(0,o.useEffect)(()=>{ty.current=ec},[ec]);let tm=(0,o.useRef)(em);(0,o.useEffect)(()=>{tm.current=em},[em]);let th=(0,o.useRef)(ev);(0,o.useEffect)(()=>{th.current=ev},[ev]);let tv=!!ev;(0,o.useEffect)(()=>{var e;if(!V||!eb.current||e7)return;e9(!0);let t=null!==(e=eL.current)&&void 0!==e?e:eb.current,r=document.createElement("div");r.className="capture-title-overlay",r.innerHTML='\n <div style="padding: 12px 20px; background: rgba(255,255,255,0.9); border-bottom: 1px solid rgba(0,0,0,0.1);">\n <div style="font-size: 18px; font-weight: 600; color: #1a1a1a;">'.concat(V.title,'</div>\n <div style="font-size: 13px; color: #6b7280; margin-top: 2px;">').concat(V.date,"</div>\n </div>\n "),r.style.cssText="position: absolute; top: 0; left: 0; right: 0; z-index: 20; pointer-events: none;",eb.current.appendChild(r),requestAnimationFrame(async()=>{try{let e=await (0,i.toPng)(t,{cacheBust:!0,pixelRatio:2,filter:e=>{var t,r;return!((null===(t=e.classList)||void 0===t?void 0:t.contains("map-controls-overlay"))||(null===(r=e.classList)||void 0===r?void 0:r.contains("legende-no-capture")))}}),r=V.title.replace(/[^a-zA-Z0-9_\-\s]/g,"").trim().replace(/\s+/g,"_")||"carte",n=document.createElement("a");n.download="".concat(r,"_").concat(new Date().toISOString().slice(0,10),".png"),n.href=e,n.click()}catch(e){console.error("Capture failed:",e)}finally{r.remove(),e9(!1),null==Z||Z()}})},[V]);let tx=(0,o.useCallback)(()=>{let e={};for(let t of f)e[t.trace_id]||(e[t.trace_id]=[]),e[t.trace_id].push(t);for(let t of Object.keys(e))e[t].sort((e,t)=>e.ordre-t.ordre);return e},[f]);(0,o.useEffect)(()=>{var e;if(!eb.current||ew.current)return;let t=function(e){if(!e)return[];try{let t=JSON.parse(e);if(!Array.isArray(t))return[];let r=new Set(p.map(e=>e.id));return t.filter(e=>"string"==typeof e&&r.has(e))}catch(e){return[]}}(window.localStorage.getItem(c));eD(t),eB(function(e){if(!e)return[];try{let t=JSON.parse(e);if(!Array.isArray(t))return[];let r=new Set(L.map(e=>e.id));return t.filter(e=>"string"==typeof e&&r.has(e))}catch(e){return[]}}(window.localStorage.getItem(b))),eJ(function(e){if(!e)return[];try{let t=JSON.parse(e);if(!Array.isArray(t))return[];let r=new Set(S.map(e=>e.id));return t.filter(e=>"string"==typeof e&&r.has(e))}catch(e){return[]}}(window.localStorage.getItem(w)));let r=function(e){if(!e)return{};try{let t=JSON.parse(e);if(!t||"object"!=typeof t||Array.isArray(t))return{};let r=new Set(g.map(e=>e.id)),n={};for(let[e,o]of Object.entries(t))r.has(e)&&"string"==typeof o&&/^\d{4}-\d{2}-\d{2}$/.test(o)&&(n[e]=o);return n}catch(e){return{}}}(window.localStorage.getItem(d));e2(r);let n=null!==(e=u.find(e=>e.id===eF))&&void 0!==e?e:u[0],o=t.filter(e=>e!==eF).map(e=>u.find(t=>
1t.id===e)).filter(e=>null!=e),l=new(a()).Map({container:eb.current,style:x(n,o,r),center:W?[W.lng,W.lat]:[2.5,46.5],zoom:W?W.zoom:6,preserveDrawingBuffer:!0});return l.addControl(new(a()).NavigationControl,"top-right"),ew.current=l,eE.current=!0,l.on("load",()=>null==eh?void 0:eh(l)),()=>{eE.current=!1,null==eh||eh(null),l.remove(),ew.current=null}},[]),(0,o.useEffect)(()=>{var e,t,r;let n=ew.current;if(!n||!es)return;let o=[es.lng,es.lat];if(n.resize(),null!=es.zoom)n.flyTo({center:o,zoom:es.zoom,essential:!0});else if(es.bounds){let e=n.cameraForBounds(es.bounds,{padding:60});n.easeTo({center:null!==(t=null==e?void 0:e.center)&&void 0!==t?t:o,zoom:Math.min(n.getZoom(),null!==(r=null==e?void 0:e.zoom)&&void 0!==r?r:1/0),duration:500})}else n.easeTo({center:o,duration:500});null===(e=ty.current)||void 0===e||e.call(ty)},[es]);let tb=(0,o.useRef)(null);(0,o.useEffect)(()=>{let e=tb.current;tb.current=null;let t=ew.current;t&&e&&e.traceId===y&&(t.resize(),t.easeTo({center:[e.lng,e.lat],duration:500}))},[y]),(0,o.useEffect)(()=>{var e;let t=ew.current;if(!t)return;if(eS.current){eS.current=!1;return}let r=null!==(e=u.find(e=>e.id===eF))&&void 0!==e?e:u[0],n=t.getCenter(),o=t.getZoom();t.setStyle(x(r,eW,e1)),t.once("styledata",()=>{t.setCenter(n),t.setZoom(o)})},[eF,eG,e5]),(0,o.useEffect)(()=>{let e=ew.current;if(!e)return;let t=eZ.map(e=>L.find(t=>t.id===e)).filter(e=>null!=e),r=null,n=!1,o=e=>{let t=eY.current.get(e);t&&(t.abort(),eY.current.delete(e))},l=e=>"forest-src-".concat(e),a=e=>"point"===e.geometry?["forest-ly-".concat(e.id,"-circle")]:"polygon"===e.geometry?["forest-ly-".concat(e.id,"-fill"),"forest-ly-".concat(e.id,"-outline")]:["forest-ly-".concat(e.id,"-halo"),"forest-ly-".concat(e.id,"-line")],i=t=>{for(let r of(o(t.id),a(t)))try{e.getLayer(r)&&e.removeLayer(r)}catch(e){}try{e.getSource(l(t.id))&&e.removeSource(l(t.id))}catch(e){}},s=t=>{var r,n;if(e.getSource(l(t.id)))return;e.addSource(l(t.id),{type:"geojson",data:{type:"FeatureCollection",features:[]}});let o=(null!==(n=null===(r=e.getStyle())||void 0===r?void 0:r.layers)&&void 0!==n?n:[]).find(e=>e.id.startsWith("trace-")),a=null==o?void 0:o.id,i=t=>{try{a&&e.getLayer(a)?e.addLayer(t,a):e.addLayer(t)}catch(e){console.warn("Forest addLayer failed:",e)}};"point"===t.geometry?i({id:"forest-ly-".concat(t.id,"-circle"),type:"circle",source:l(t.id),paint:{"circle-radius":5,"circle-color":t.color,"circle-stroke-color":"#ffffff","circle-stroke-width":2,"circle-opacity":.9}}):"polygon"===t.geometry?(i({id:"forest-ly-".concat(t.id,"-fill"),type:"fill",source:l(t.id),paint:{"fill-color":t.color,"fill-opacity":.18}}),i({id:"forest-ly-".concat(t.id,"-outline"),type:"line",source:l(t.id),layout:{"line-join":"round"},paint:{"line-color":t.color,"line-width":1.5,"line-opacity":.9}})):(i({id:"forest-ly-".concat(t.id,"-halo"),type:"line",source:l(t.id),layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":"#ffffff","line-width":5,"line-opacity":.85}}),i({id:"forest-ly-".concat(t.id,"-line"),type:"line",source:l(t.id),layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":t.color,"line-width":2.5}}))},c=async t=>{let r=e.getBounds(),a="".concat(r.getSouth(),",").concat(r.getWest(),",").concat(r.getNorth(),",").concat(r.getEast());o(t.id);let i=new AbortController;eY.current.set(t.id,i);try{let r=await fetch("/api/ign/wfs?layer=".concat(encodeURIComponent(t.id),"&bbox=").concat(encodeURIComponent(a)),{signal:i.signal});if(!r.ok)return;let o=await r.json();if(n)return;let s=e.getSource(l(t.id));null==s||s.setData(o)}catch(e){}finally{eY.current.delete(t.id)}},d=()=>{if(n)return;let r=12>e.getZoom();for(let n of(eH(r&&t.length>0),t))if(s(n),r){o(n.id);let t=e.getSource(l(n.id));null==t||t.setData({type:"FeatureCollection",features:[]})}else c(n)},u=()=>{r&&clearTimeout(r),r=setTimeout(d,350)},p=()=>{let e=new Set(t.map(e=>e.id));for(let t of L)e.has(t.id)||i(t);if(0===t.length){eH(!1);return}d()};return e.isStyleLoaded()?p():e.once("styledata",()=>{n||p()}),e.on("moveend",u),()=>{n=!0,r&&clearTimeout(r),e.off("moveend",u),eY.current.forEach(e=>e.abort()),eY.current.clear()}},[eq,eF,eG,e5]),(0,o.useEffect)(()=>{let e=ew.current;if(!e)return;let t=eX.map(e=>S.find(t=>
1t.id===e)).filter(e=>null!=e),r=null,n=!1,o=e=>{let t=e$.current.get(e);t&&(t.abort(),e$.current.delete(e))},l=e=>"fire-src-".concat(e),a=e=>"point"===e.kind?["fire-ly-".concat(e.id,"-uncertainty")]:["fire-ly-".concat(e.id,"-fill"),"fire-ly-".concat(e.id,"-outline-fin"),"fire-ly-".concat(e.id,"-outline-auto")],i=t=>{for(let r of(o(t.id),a(t)))try{e.getLayer(r)&&e.removeLayer(r)}catch(e){}try{e.getSource(l(t.id))&&e.removeSource(l(t.id))}catch(e){}},s=t=>{var r,n,o;if(e.getSource(l(t.id)))return;e.addSource(l(t.id),{type:"geojson",data:{type:"FeatureCollection",features:[]}});let a=(null!==(n=null===(r=e.getStyle())||void 0===r?void 0:r.layers)&&void 0!==n?n:[]).find(e=>e.id.startsWith("trace-")),i=null==a?void 0:a.id,s=t=>{try{i&&e.getLayer(i)?e.addLayer(t,i):e.addLayer(t)}catch(e){console.warn("Fire addLayer failed:",e)}};if("point"===t.kind){s({id:"fire-ly-".concat(t.id,"-uncertainty"),type:"circle",source:l(t.id),paint:{"circle-radius":function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:375,t=Math.cos(46.5*Math.PI/180),r=[];for(let n=7;n<=18;n+=1){let o=156543.03392*t/2**n;r.push(n,Math.max(4,e/o))}return["interpolate",["exponential",2],["zoom"],...r]}(),"circle-color":t.color,"circle-opacity":.25,"circle-blur":.4,"circle-stroke-color":t.color,"circle-stroke-width":1,"circle-stroke-opacity":.5}});return}s({id:"fire-ly-".concat(t.id,"-fill"),type:"fill",source:l(t.id),paint:{"fill-color":t.color,"fill-opacity":null!==(o=t.fillOpacity)&&void 0!==o?o:.3}}),t.outline&&(s({id:"fire-ly-".concat(t.id,"-outline-fin"),type:"line",source:l(t.id),filter:["==",["get","precision_geom"],"polygone_fin"],layout:{"line-join":"round"},paint:{"line-color":t.color,"line-width":2}}),s({id:"fire-ly-".concat(t.id,"-outline-auto"),type:"line",source:l(t.id),filter:["!=",["get","precision_geom"],"polygone_fin"],layout:{"line-join":"round"},paint:{"line-color":t.color,"line-width":2,"line-dasharray":[3,2]}}))},c=async t=>{let r=e.getBounds(),a="".concat(r.getSouth(),",").concat(r.getWest(),",").concat(r.getNorth(),",").concat(r.getEast());o(t.id);let i=new AbortController;e$.current.set(t.id,i);try{let r=await fetch("/api/feux?layer=".concat(encodeURIComponent(t.id),"&bbox=").concat(encodeURIComponent(a)),{signal:i.signal});if(!r.ok)return;let o=await r.json();if(n)return;let s=e.getSource(l(t.id));null==s||s.setData(o)}catch(e){}finally{e$.current.delete(t.id)}},d=()=>{if(n)return;let r=7>e.getZoom();for(let n of(e0(r&&t.length>0),t))if(s(n),r){o(n.id);let t=e.getSource(l(n.id));null==t||t.setData({type:"FeatureCollection",features:[]})}else c(n)},u=()=>{r&&clearTimeout(r),r=setTimeout(d,350)},p=()=>{let e=new Set(t.map(e=>e.id));for(let t of S)e.has(t.id)||i(t);if(0===t.length){e0(!1);return}d()};return e.isStyleLoaded()?p():e.once("styledata",()=>{n||p()}),e.on("moveend",u),()=>{n=!0,r&&clearTimeout(r),e.off("moveend",u),e$.current.forEach(e=>e.abort()),e$.current.clear()}},[eQ,eF,eG,e5]),(0,o.useEffect)(()=>{let e=ew.current;if(!e)return;let t=new(a()).Popup({closeButton:!0,maxWidth:"320px"}),r=[],n=e=>String(null!=e?e:"").replace(/[&<>"]/g,e=>({"&":"&","<":"<",">":">",'"':"""})[e]),o=e=>e.filter(e=>{let[,t]=e;return""!==t}).map(e=>{let[t,r]=e;return'<div style="display:flex;gap:8px;justify-content:space-between"><span style="color:#6b7280">'.concat(n(t),'</span><span style="text-align:right">').concat(r,"</span></div>")}).join(""),l=(r,o,l,a)=>{tn.current||t.setLngLat(r.lngLat).setHTML('<div style="font-size:12px;line-height:1.5">\n <div style="font-weight:600;font-size:13px;margin-bottom:4px">'.concat(n(o),"</div>\n ").concat(l,"\n ").concat(a?'<div style="margin-top:6px;color:#6b7280;font-size:11px">'.concat(n(a),"</div>"):"","\n </div>")).addTo(e)},i=(t,n)=>{if(!e.getLayer(t))return;let o=()=>{e.getCanvas().style.cursor="pointer"},l=()=>{e.getCanvas().style.cursor=""};e.on("click",t,n),e.on("mouseenter",t,o),e.on("mouseleave",t,l),r.push({layerId:t,handler:n,enter:o,leave:l})},s=()=>{for(let t of r.splice(0))try{e.off("click",t.layerId,t.handler),e.off("mouseenter",t.layerId,t.enter),e.off("mouseleave",t.layerId,t.leave)}catch(e){}},c=e=>{if(!e)return"";let t=new Date(String(e));return Number.isNaN(t.getTime())?String(e):t.toLocaleDateString("fr-FR")},d={polygone_fin:"P\xe9rim\xe8tre photo-interpr\xe9t\xe9 (Copernicus EMS)",polygone_auto:"P\xe9rim\xe8tre d\xe9tect\xe9 automatiquement (EFFIS)",point_375m:"D\xe9tection thermique, position \xe0 \xb1375 m"},u=()=>{for(let e of L)"polygon"===e.geometry&&e.popupFields&&i("forest-ly-".concat(e.id,"-fill"),t=>{var r,a,i;let s=null!==(i=null===(a=t.features)||void 0===a?void 0:null===(r=a[0])||void 0===r?void 0:r.properties)&&void 0!==i?i:{},c=o(e.popupFields.map(e=>{let t=s[e.key],r=null==t||""===t?"":String(t);return r?[e.label,e.link?'<a href="'.concat(n(r),'" target="_blank" rel="noopener noreferrer" style="color:#2563eb;text-decoration:underline">Consulter</a>'):n(r)]:[e.label,""]}));l(t,e.name,c||'<div style="color:#6b7280">Aucun attribut publi\xe9.</div>',e.attribution)});for(let e of S)for(let t of"point"===e.kind?["fire-ly-".concat(e.id,"-uncertainty")]:["fire-ly-".concat(e.id,"-fill")])i(t,t=>{var r,a,i,s,u,p,g,f,y,m,h;let v=null!==(i=null===(a=t.features)||void 0===a?void 0:null===(r=a[0])||void 0===r?void 0:r.properties)&&void 0!==i?i:{},x=null==v.surface_ha?"":"".concat(Number(v.surface_ha).toLocaleStr
1ing("fr-FR")," ha"),b=null==v.conifer||0===Number(v.conifer)?"":"".concat(Number(v.conifer).toFixed(0)," %"),L=o([["Date",n(c(v.date_feu))],["Surface",n(x)],["Commune",n(null!==(s=v.commune)&&void 0!==s?s:"")],["D\xe9partement",n(null!==(u=v.departement)&&void 0!==u?u:"")],["Lieu-dit",n(null!==(p=v.lieu_dit)&&void 0!==p?p:"")],["Cause",n(null!==(g=v.cause)&&void 0!==g?g:"")],["Part de conif\xe8res",n(b)],["Natura 2000",null==v.percna2k?"":"".concat(Number(v.percna2k).toFixed(1)," %")],["Puissance (FRP)",null==v.frp?"":"".concat(Number(v.frp).toFixed(1)," MW")],["Confiance",n(null!==(f=v.confidence)&&void 0!==f?f:"")],["Source",n(String(null!==(y=v.source)&&void 0!==y?y:"").toUpperCase())]]),w=null!==(h=d[String(null!==(m=v.precision_geom)&&void 0!==m?m:"")])&&void 0!==h?h:"";l(t,"point"===e.kind?"D\xe9tection thermique":"Surface br\xfbl\xe9e",L,[w,e.attribution].filter(Boolean).join(" \xb7 "))})},p=()=>{s(),u()};return e.on("idle",p),()=>{e.off("idle",p),s(),t.remove()}},[eq,eQ,eF,eG,e5]);let tL=eP.includes("ign-old")||"ign-old"===eF||eZ.includes("old-debroussaillement");(0,o.useEffect)(()=>{let e=ew.current;if(!e||!tL){e4(null);return}let t=!1,r=null,n=new AbortController,o=async()=>{let r=e.getCenter(),o=await T(r.lat,r.lng,n.signal);t||e4(function(e){var t;let r=k(e),n=function(e){let t=k(e);if(!t)return null;let r=E[t];return void 0===r?null:0===r?"aucune":r<=500?"degradee":r<=5e3?"partielle":"bonne"}(r);if(!r||!n||"bonne"===n||"partielle"===n)return null;let o=null!==(t=E[r])&&void 0!==t?t:0;return"aucune"===n?"Aucune zone OLD publi\xe9e pour le d\xe9partement ".concat(r," : l'absence d'affichage ne signifie pas l'absence d'obligation."):"Couverture OLD tr\xe8s partielle pour le d\xe9partement ".concat(r," (").concat(o," objet").concat(o>1?"s":""," publi\xe9").concat(o>1?"s":"",") : l'absence d'affichage ne signifie pas l'absence d'obligation.")}(o))},l=()=>{r&&clearTimeout(r),r=setTimeout(()=>{o()},600)};return o(),e.on("moveend",l),()=>{t=!0,r&&clearTimeout(r),n.abort(),e.off("moveend",l)}},[tL]),(0,o.useEffect)(()=>{let e=ew.current;if(e)return e.on("click",t),e.on("dblclick",r),P&&td.current?e.getCanvas().style.cursor="crosshair":e.getCanvas().style.cursor="",()=>{e.off("click",t),e.off("dblclick",r),e.getCanvas()&&(e.getCanvas().style.cursor="")};function t(e){let t=td.current;P&&t&&t(e.lngLat.lat,e.lngLat.lng)}function r(e){let t=tu.current;P&&t&&(e.preventDefault(),t(e.lngLat.lat,e.lngLat.lng))}},[P]),(0,o.useEffect)(()=>{let e=ew.current;if(e&&tv)return e.on("contextmenu",t),()=>{e.off("contextmenu",t)};function t(e){let t=th.current;t&&(e.preventDefault(),t(e.lngLat.lat,e.lngLat.lng,{x:e.point.x,y:e.point.y}))}},[tv]),(0,o.useEffect)(()=>{let e=ew.current;e&&("chemin"===P||"surface"===P?e.doubleClickZoom.disable():e.doubleClickZoom.enable())},[P]),(0,o.useEffect)(()=>{let e=ew.current;if(!e)return;eI.current.forEach(e=>e.remove()),eI.current=[];try{e.getLayer("draw-line")&&e.removeLayer("draw-line"),e.getLayer("draw-fill")&&e.removeLayer("draw-fill"),e.getLayer("draw-border")&&e.removeLayer("draw-border"),e.getSource("draw-line")&&e.removeSource("draw-line"),e.getSource("draw-poly")&&e.removeSource("draw-poly")}catch(e){}if(!P||0===D.length)return;let t="legende:shape:polygon"===P?"#0ea5e9":"#22c55e",r="legende:shape:polygon"===P?"#0284c7":"#16a34a",n="surface"===P||"legende:shape:polygon"===P,o="chemin"===P,l="legende:shape:ellipse"===P;function i(){if(!l){for(let o=0;o<D.length;o++){let[l,i]=D[o],s=document.createElement("div");s.style.width="12px",s.style.height="12px",s.style.borderRadius="50%",s.style.backgroundColor=t,s.style.border="2px solid white",s.style.boxShadow="0 1px 3px rgba(0,0,0,0.3)",0===o&&n&&D.length>=3&&(s.style.width="16px",s.style.height="16px",s.style.backgroundColor=r,s.style.cursor="pointer");let c=new(a()).Marker({element:s}).setLngLat([i,l]).addTo(e);eI.current.push(c)}if(o&&D.length>=2){let r=D.map(e=>{let[t,r]=e;return[r,t]});e.addSource("draw-line",{type:"geojson",data:{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:r}}}),e.addLayer({id:"draw-line",type:"line",source:"draw-line",paint:{"line-color":t,"line-width":3,"line-dasharray":[3,2]}})}if(n&&D.length>=3){let r=D.map(e=>{let[t,r]=e;return[r,t]});r.push(r[0]),e.addSource("draw-poly",{type:"geojson",data:{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[r]}}}
1),e.addLayer({id:"draw-fill",type:"fill",source:"draw-poly",paint:{"fill-color":t,"fill-opacity":.15}}),e.addLayer({id:"draw-border",type:"line",source:"draw-poly",paint:{"line-color":t,"line-width":2,"line-dasharray":[3,2]}})}if(n&&2===D.length){let r=D.map(e=>{let[t,r]=e;return[r,t]});e.addSource("draw-line",{type:"geojson",data:{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:r}}}),e.addLayer({id:"draw-line",type:"line",source:"draw-line",paint:{"line-color":t,"line-width":2,"line-dasharray":[3,2]}})}}}(()=>{if(!e.isStyleLoaded()){e.once("styledata",()=>setTimeout(i,50));return}i()})()},[P,D]),(0,o.useEffect)(()=>{let e=ew.current;if(!e)return;let t="cadastre-sel",r=["cadastre-sel-fill","cadastre-sel-line","cadastre-sel-label"],n=!1,o=()=>{if(!n&&e.getStyle()){for(let t of r)e.getLayer(t)&&e.removeLayer(t);e.getSource(t)&&e.removeSource(t),ex&&0!==ex.features.length&&(e.addSource(t,{type:"geojson",data:ex}),e.addLayer({id:"cadastre-sel-fill",type:"fill",source:t,filter:["==","$type","Polygon"],paint:{"fill-color":"#f59e0b","fill-opacity":.28}}),e.addLayer({id:"cadastre-sel-line",type:"line",source:t,filter:["==","$type","Polygon"],paint:{"line-color":"#b45309","line-width":2.5}}),e.addLayer({id:"cadastre-sel-label",type:"symbol",source:t,filter:["==","$type","Point"],layout:{"text-field":["get","ref"],"text-font":["Open Sans Semibold"],"text-size":13,"text-allow-overlap":!1},paint:{"text-color":"#78350f","text-halo-color":"#ffffff","text-halo-width":1.5}}))}};e.isStyleLoaded()?o():e.once("styledata",()=>setTimeout(o,50));let l=()=>setTimeout(o,100);return e.once("styledata",l),()=>{if(n=!0,e.off("styledata",l),e.getStyle()){for(let t of r)e.getLayer(t)&&e.removeLayer(t);e.getSource(t)&&e.removeSource(t)}}},[ex,eF,eG]),(0,o.useEffect)(()=>{let e=ew.current;if(!e)return;let t=()=>{var t,r;for(let t of(ek.current.forEach(e=>e.remove()),ek.current=[],eT.current.splice(0)))e.off(t.type,t.layerId,t.fn);let n=(t,r,n)=>{e.on(t,r,n),eT.current.push({type:t,layerId:r,fn:n})};for(let r of(P||(e.getCanvas().style.cursor=""),(null===(t=e.getStyle())||void 0===t?void 0:t.layers)||[]))r.id.startsWith("trace-")&&e.removeLayer(r.id);for(let t of Object.keys((null===(r=e.getStyle())||void 0===r?void 0:r.sources)||{}))t.startsWith("trace-")&&e.removeSource(t);let o=tx(),i=new(a()).LngLatBounds,c=!1;for(let t of l){let r=o[t.id]||[];if(0===r.length)continue;let l=t.id===y,d=t.couleur||"#22c55e";if("point"===t.type){let n=r[0];i.extend([n.longitude,n.latitude]),c=!0;let o=document.createElement("div");o.className=l?"marker-point is-selected":"marker-point",o.style.backgroundColor=d,o.style.setProperty("--marker-color",d);let s=new(a()).Marker({element:o,draggable:!P&&!_}).setLngLat([n.longitude,n.latitude]).addTo(e);if(o.addEventListener("click",r=>{if(r.stopPropagation(),P)return;let{lng:n,lat:o}=s.getLngLat();l?e.easeTo({center:[n,o],duration:500}):tb.current={traceId:t.id,lng:n,lat:o},ts.current(t.id)}),s.on("dragend",()=>{var e;if(_)return;let t=s.getLngLat();null===(e=tc.current)||void 0===e||e.call(tc,n.id,t.lat,t.lng)}),ek.current.push(s),t.nom)try{let r="trace-label-".concat(t.id);e.addSource(r,{type:"geojson",data:{type:"Feature",properties:{label:t.nom},geometry:{type:"Point",coordinates:[n.longitude,n.latitude]}}}),e.addLayer({id:"trace-label-layer-".concat(t.id),type:"symbol",source:r,layout:{visibility:tr.current?"visible":"none","text-field":["get","label"],"text-font":["Open Sans Semibold"],"text-size":l?15:14,"text-anchor":"left","text-offset":[l?1.7:1.2,0],"text-allow-overlap":!1},paint:{"text-color":d,"text-halo-color":"#ffffff","text-halo-width":1.5,"text-halo-blur":.5}})}catch(e){console.warn("Failed to add point label:",e)}}else if("chemin"===t.type||"parcoursGPS"===t.type){let o=r.map(e=>(i.extend([e.longitude,e.latitude]),c=!0,[e.longitude,e.latitude])),a="trace-line-".concat(t.id),u=(0,s.$E)(r),p="(".concat((0,s.Bb)(u),")");e.addSource(a,{type:"geojson",data:{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:o}}});let g="trace-layer-".concat(t.id),f=l?5:3,y=l?1:.8;if(l&&(e.addLayer({id:"trace-halo-".concat(t.id),type:"line",source:a,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":d,"line-width":20,"line-opacity":.5,"line-blur"
1:6}}),e.addLayer({id:"trace-casing-".concat(t.id),type:"line",source:a,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#ffffff","line-width":f+4}})),e.addLayer({id:g,type:"line",source:a,paint:{"line-color":d,"line-width":f,"line-opacity":y}}),!P){let r="trace-hit-".concat(t.id);e.addLayer({id:r,type:"line",source:a,paint:{"line-color":d,"line-width":14,"line-opacity":0}}),n("click",r,()=>ts.current(t.id)),n("mouseenter",r,()=>{e.getCanvas().style.cursor="pointer",e.getLayer(g)&&(e.setPaintProperty(g,"line-width",f+2),e.setPaintProperty(g,"line-opacity",1))}),n("mouseleave",r,()=>{e.getCanvas().style.cursor="",e.getLayer(g)&&(e.setPaintProperty(g,"line-width",f),e.setPaintProperty(g,"line-opacity",y))})}if(t.nom&&o.length>=2)try{let r="".concat(t.nom," ").concat(p),n="trace-label-".concat(t.id);e.addSource(n,{type:"geojson",data:{type:"Feature",properties:{label:r},geometry:{type:"LineString",coordinates:o}}}),e.addLayer({id:"trace-label-layer-".concat(t.id),type:"symbol",source:n,layout:{visibility:tr.current?"visible":"none","text-field":["get","label"],"text-font":["Open Sans Semibold"],"text-size":15,"symbol-placement":"line-center","text-keep-upright":!0,"text-allow-overlap":!1,"text-padding":2,"symbol-sort-key":l?0:1},paint:{"text-color":d,"text-halo-color":"#ffffff","text-halo-width":1.5,"text-halo-blur":.5}})}catch(e){console.warn("Failed to add chemin label:",e)}}else if("surface"===t.type){let o=r.map(e=>(i.extend([e.longitude,e.latitude]),c=!0,[e.longitude,e.latitude]));o.length>2&&o.push(o[0]);let a="trace-poly-".concat(t.id);e.addSource(a,{type:"geojson",data:{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[o]}}});let u="trace-fill-".concat(t.id),p="trace-border-".concat(t.id),g=l?.4:.2,f=l?3:2;if(l&&e.addLayer({id:"trace-halo-".concat(t.id),type:"line",source:a,layout:{"line-join":"round"},paint:{"line-color":d,"line-width":16,"line-opacity":.4,"line-blur":6}}),e.addLayer({id:u,type:"fill",source:a,paint:{"fill-color":d,"fill-opacity":g}}),l&&e.addLayer({id:"trace-casing-".concat(t.id),type:"line",source:a,layout:{"line-join":"round"},paint:{"line-color":"#ffffff","line-width":f+4}}),e.addLayer({id:p,type:"line",source:a,paint:{"line-color":d,"line-width":f}}),P||(n("click",u,()=>ts.current(t.id)),n("mouseenter",u,()=>{e.getCanvas().style.cursor="pointer",e.getLayer(u)&&e.getLayer(p)&&(e.setPaintProperty(u,"fill-opacity",g+.12),e.setPaintProperty(p,"line-width",f+1))}),n("mouseleave",u,()=>{e.getCanvas().style.cursor="",e.getLayer(u)&&e.getLayer(p)&&(e.setPaintProperty(u,"fill-opacity",g),e.setPaintProperty(p,"line-width",f))})),t.nom&&r.length>=3)try{let n=(0,s.mZ)(r),o=(0,s.Ok)(r),l="".concat(t.nom,"\n(").concat((0,s.Se)(o),")"),a="trace-label-".concat(t.id);e.addSource(a,{type:"geojson",data:{type:"Feature",properties:{label:l},geometry:{type:"Point",coordinates:n}}}),e.addLayer({id:"trace-label-layer-".concat(t.id),type:"symbol",source:a,layout:{visibility:tr.current?"visible":"none","text-field":["get","label"],"text-font":["Open Sans Semibold"],"text-size":15,"text-anchor":"center","text-allow-overlap":!1,"text-max-width":12},paint:{"text-color":d,"text-halo-color":"#ffffff","text-halo-width":1.5,"text-halo-blur":.5}})}catch(e){console.warn("Failed to add surface label:",e)}}}c&&!ti.current&&(e.fitBounds(i,{padding:60,maxZoom:16}),ti.current=!0)};e.isStyleLoaded()?t():e.once("load",t),e.once("styledata",()=>{setTimeout(t,100)})},[l,f,y,eF,eG,P,tx,_]),(0,o.useEffect)(()=>{let e=ew.current;if(!e)return;let t=()=>{var t,r,n,o,l,i,s,c,d;let u=eg.map(e=>"".concat(e.id,"|").concat(e.traces.map(e=>"".concat(e.id,":").concat(e.type,":").concat(e.couleur)).join(","),"|").concat(e.coordonnees.length)).join(";"),p=eg.some(e=>e.traces.some(e=>"point"!==e.type)),g=(null!==(l=null===(t=e.getStyle())||void 0===t?void 0:t.layers)&&void 0!==l?l:[]).some(e=>e.id.startsWith("overlay-trace-")),f=eR.current;if(f&&f.fingerprint===u&&(!p||g))return;for(let t of(eN.current.forEach(e=>e.remove()),eN.current=[],null!==(i=null===(r=e.getStyle())||void 0===r?void 0:r.layers)&&void 0!==i?i:[]))if(t.id.startsWith("overlay-trace-"))try{e.removeLayer(t.id)}catch(e){}for(let t of Object.keys(null!==(s=null===(n=e.getStyle())||void 0===n?void 0:n.sources)&&void 0!==s?s:{}))if(t.startsWith("overlay-trace-"))try{e.removeSource(t)}catch(e){}if(0===eg.length){eR.current={fingerprint:u,expectsLayers:p};return}let y=(null!==(c=null===(o=e.getStyle())||void 0===o?void 0:o.layers)&&void 0!==c?c:[]).find(e=>e.id.startsWith("trace-")),m=null==y?void 0:y.id,h=t=>{try{m&&e.getLayer(m)?e.addLayer(t,m):e.addLayer(t)}catch(e){console.warn("Overlay addLayer failed:",e)}};for(let t of eg){let r={};for(let e of t.coordonnees)r[e.trace_id]||(r[e.trace_id]=[]),r[e.trace_id].push(e);for(let e of Object.keys(r))r[e].sort((e,t)=>
1e.ordre-t.ordre);for(let n of t.traces){let o=null!==(d=r[n.id])&&void 0!==d?d:[];if(0===o.length)continue;let l=n.couleur||"#22c55e",i="overlay-trace-".concat(t.id,"-").concat(n.id),s=()=>{var e;null===(e=tm.current)||void 0===e||e.call(tm,{carteId:t.id,carteNom:t.nom,carteOwnerId:t.ownerUserId,trace:n,coordonnees:o})};if("point"===n.type){let r=o[0],i=document.createElement("div");i.className="marker-point",i.style.backgroundColor=l,i.style.opacity="0.7",i.style.cursor="pointer",i.style.boxShadow="0 0 0 1.5px rgba(255,255,255,0.85), 0 1px 4px rgba(0,0,0,0.25)",i.title="".concat(n.nom||"Sans nom"," â ").concat(t.nom);let c=new(a()).Marker({element:i,draggable:!1}).setLngLat([r.longitude,r.latitude]).addTo(e);i.addEventListener("click",e=>{e.stopPropagation(),s()}),eN.current.push(c);continue}if("chemin"===n.type||"parcoursGPS"===n.type){let r=o.map(e=>[e.longitude,e.latitude]),a="".concat(i,"-line");try{e.addSource(a,{type:"geojson",data:{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:r}}})}catch(e){continue}let c="overlay-trace-".concat(t.id,"-").concat(n.id,"-line"),d="parcoursGPS"===n.type?[2,2]:null;h({id:c,type:"line",source:a,paint:{"line-color":l,"line-width":3,"line-opacity":.6,...d?{"line-dasharray":d}:{}}}),e.on("click",c,s),e.on("mouseenter",c,()=>{e.getCanvas().style.cursor="pointer"}),e.on("mouseleave",c,()=>{e.getCanvas().style.cursor=""});continue}if("surface"===n.type){let r=o.map(e=>[e.longitude,e.latitude]);r.length>2&&r.push(r[0]);let a="".concat(i,"-poly");try{e.addSource(a,{type:"geojson",data:{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[r]}}})}catch(e){continue}let c="overlay-trace-".concat(t.id,"-").concat(n.id,"-fill"),d="overlay-trace-".concat(t.id,"-").concat(n.id,"-border");h({id:c,type:"fill",source:a,paint:{"fill-color":l,"fill-opacity":.15}}),h({id:d,type:"line",source:a,paint:{"line-color":l,"line-width":2,"line-opacity":.6}}),e.on("click",c,s),e.on("mouseenter",c,()=>{e.getCanvas().style.cursor="pointer"}),e.on("mouseleave",c,()=>{e.getCanvas().style.cursor=""});continue}}}eR.current={fingerprint:u,expectsLayers:p}};e.isStyleLoaded()?t():e.once("load",t),e.once("styledata",()=>setTimeout(t,100))},[eg,eF,eG]),(0,o.useEffect)(()=>{let e=ew.current;if(!e)return;let t=()=>{var t,r;for(let n of null!==(r=null===(t=e.getStyle())||void 0===t?void 0:t.layers)&&void 0!==r?r:[])if(n.id.startsWith("trace-label-layer-"))try{e.setLayoutProperty(n.id,"visibility",te?"visible":"none")}catch(e){}};e.isStyleLoaded()?t():e.once("styledata",t)},[te]),(0,o.useEffect)(()=>{let e=ew.current;if(!e)return;let t=()=>{var t,r,n,o,l,i,s,c,d;for(let r of(ej.current.forEach(e=>e.remove()),ej.current=[],(null===(t=e.getStyle())||void 0===t?void 0:t.layers)||[]))if(r.id.startsWith("legende-"))try{e.removeLayer(r.id)}catch(e){}for(let t of Object.keys((null===(r=e.getStyle())||void 0===r?void 0:r.sources)||{}))if(t.startsWith("legende-"))try{e.removeSource(t)}catch(e){}if(!ta||!U||0===U.length)return;let u=(e,t)=>{e.on("dragend",()=>{let r=tg.current;if(!r)return;let n=e.getLngLat();r(t.id,{lat:n.lat,lng:n.lng})})};for(let t of U){let r=t.id===H,p=!P&&!_;if("text"===t.type){let{lat:l,lng:i}=t.geometry,s=t.props,c=null!==(n=I.d5[s.size])&&void 0!==n?n:16,d=s.halo?"1px 1px 0 #fff, -1px 1px 0 #fff, 1px -1px 0 #fff, -1px -1px 0 #fff, 0 0 4px rgba(255,255,255,0.8)":"none",g="string"==typeof s.background&&s.background.length>0,f=g?"background-color: ".concat(s.background,";"):"",y=g?"padding: 4px 8px;":"padding: 2px 4px;",m=document.createElement("div");m.className="legende-text",m.style.cssText="\n user-select: none;\n cursor: ".concat(p?"move":"pointer",";\n font-family: 'Open Sans', system-ui, sans-serif;\n font-weight: 600;\n font-size: ").concat(c,"px;\n line-height: 1.15;\n color: ").concat(s.color,";\n text-shadow: ").concat(d,";\n white-space: pre-line;\n text-align: center;\n ").concat(f,"\n ").concat(y,"\n border-radius: 4px;\n transform: rotate(").concat(null!==(o=s.rotation_deg)&&void 0!==o?o:0,"deg);\n ").concat(r?"outline: 2px solid #0ea5e9; outline-offset: 2px;":"","\n "),m.textContent=s.value,m.addEventListener("click",e=>{var r;e.stopPropagation(),null===(r=tp.current)||void 0===r||r.call(tp,t.id)});let h=new(a()).Marker({element:m,anchor:"center",draggable:p}
1).setLngLat([i,l]).addTo(e);p&&u(h,t),ej.current.push(h);continue}if("arrow"===t.type){let{from:n,to:o}=t.geometry,d=t.props,u=null!==(i=I.gE[d.width])&&void 0!==i?i:3.5,g=null!==(s=null===(l=d.label)||void 0===l?void 0:l.trim())&&void 0!==s?s:"",f=g.length>0,y=f?"legende-arrow-label-source-".concat(t.id):null,m=null!==(c=d.heads)&&void 0!==c?c:I.ke,h="legende-arrow-source-".concat(t.id),v="legende-arrow-line-".concat(t.id),x=(e,t)=>[{type:"Feature",properties:{kind:"body"},geometry:{type:"LineString",coordinates:[[e.lng,e.lat],[t.lng,t.lat]]}},...function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:I.ke,n=[];if("end"===r||"both"===r){let r=R(e,t);n.push({type:"Feature",properties:{kind:"head"},geometry:{type:"LineString",coordinates:[[r.left.lng,r.left.lat],[t.lng,t.lat],[r.right.lng,r.right.lat]]}})}if("start"===r||"both"===r){let r=R(t,e);n.push({type:"Feature",properties:{kind:"head"},geometry:{type:"LineString",coordinates:[[r.left.lng,r.left.lat],[e.lng,e.lat],[r.right.lng,r.right.lat]]}})}return n}(e,t,m)],b=(t,r)=>{try{let n=e.getSource(h);null==n||n.setData({type:"FeatureCollection",features:x(t,r)})}catch(e){}if(y)try{let n=e.getSource(y);null==n||n.setData({type:"Feature",properties:{label:g},geometry:{type:"Point",coordinates:[(t.lng+r.lng)/2,(t.lat+r.lat)/2]}})}catch(e){}};e.addSource(h,{type:"geojson",data:{type:"FeatureCollection",features:x(n,o)}}),e.addLayer({id:v,type:"line",source:h,paint:{"line-color":d.color,"line-width":r?u+1:u,"line-opacity":1},layout:{"line-cap":"round","line-join":"round"}});let L="legende-arrow-hit-".concat(t.id);if(e.addLayer({id:L,type:"line",source:h,filter:["==",["get","kind"],"body"],paint:{"line-color":"#000","line-opacity":0,"line-width":u+14},layout:{"line-cap":"round","line-join":"round"}}),f&&y){let r="legende-arrow-label-".concat(t.id);e.addSource(y,{type:"geojson",data:{type:"Feature",properties:{label:g},geometry:{type:"Point",coordinates:[(n.lng+o.lng)/2,(n.lat+o.lat)/2]}}}),e.addLayer({id:r,type:"symbol",source:y,layout:{"text-field":["get","label"],"text-font":["Open Sans Semibold"],"text-size":13,"text-anchor":"center","text-allow-overlap":!0,"text-offset":[0,-1.2]},paint:{"text-color":d.color,"text-halo-color":"#ffffff","text-halo-width":1.5,"text-halo-blur":.5}})}if(!P){let r=r=>{e.on("click",r,e=>{var r,n;null===(r=e.originalEvent)||void 0===r||r.stopPropagation(),null===(n=tp.current)||void 0===n||n.call(tp,t.id)}),e.on("mouseenter",r,()=>{e.getCanvas().style.cursor="pointer"}),e.on("mouseleave",r,()=>{P||(e.getCanvas().style.cursor="")})};r(v),r(L)}if(p){let l=(l,i)=>{let s=document.createElement("div");s.style.cssText="\n width: 14px; height: 14px;\n border-radius: 50%;\n background: ".concat(r?"#0ea5e9":"rgba(14,165,233,0.3)",";\n border: 2px solid white;\n box-shadow: 0 1px 3px rgba(0,0,0,0.3);\n cursor: ").concat(r?"move":"pointer",";\n "),s.addEventListener("click",e=>{var r;e.stopPropagation(),null===(r=tp.current)||void 0===r||r.call(tp,t.id)});let c=new(a()).Marker({element:s,draggable:!0}).setLngLat([l.lng,l.lat]).addTo(e);c.on("drag",()=>{let e=c.getLngLat();b("from"===i?{lat:e.lat,lng:e.lng}:n,"to"===i?{lat:e.lat,lng:e.lng}:o)}),c.on("dragend",()=>{let e=tg.current;if(!e)return;let r=c.getLngLat(),l="from"===i?{from:{lat:r.lat,lng:r.lng},to:o}:{from:n,to:{lat:r.lat,lng:r.lng}};e(t.id,l)}),ej.current.push(c)};if(l(n,"from"),l(o,"to"),r){let r=(n.lat+o.lat)/2,l=(n.lng+o.lng)/2,i=document.createElement("div");i.style.cssText="\n width: 16px; height: 16px;\n border-radius: 50%;\n background: #0284c7;\n border: 2px solid white;\n box-shadow: 0 1px 3px rgba(0,0,0,0.3);\n cursor: move;\n ",i.addEventListener("click",e=>{var r;e.stopPropagation(),null===(r=tp.current)||void 0===r||r.call(tp,t.id)});let s=new(a()).Marker({element:i,draggable:!0}).setLngLat([l,r]).addTo(e);s.on("drag",()=>{let e=s.getLngLat(),t=e.lat-r,a=e.lng-l;b({lat:n.lat+t,lng:n.lng+a},{lat:o.lat+t,lng:o.lng+a})}),s.on("dragend",()=>{let e=tg.current;if(!e)return;let a=s.getLngLat(),i=a.lat-r,c=a.lng-l;e(t.id,{from:{lat:n.lat+i,lng:n.lng+c},to:{lat:o.lat+i,lng:o.lng+c}})}),ej.current.push(s)}}continue}if("shape"===t.type){let n=t.geometry,o=t.props,l=(0,I.aH)(n),i=l.map(e=>[e.lng,e.lat]),s="legende-shape-source-".concat(t.id),c="legende-shape-fill-".concat(t.id),d="legende-shape-line-".concat(t.id);e.addSource(s,{type:"geojson",data:{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[i]}}}
1),e.addLayer({id:c,type:"fill",source:s,paint:{"fill-color":o.fill,"fill-opacity":o.fill_opacity}}),e.addLayer({id:d,type:"line",source:s,paint:{"line-color":o.stroke,"line-width":r?o.stroke_width+1:o.stroke_width},layout:{"line-cap":"round","line-join":"round"}});let u=o.label&&o.label.trim().length>0?"legende-shape-label-source-".concat(t.id):null;if(o.label&&o.label.trim().length>0){let r=l.slice(0,-1),n=0,a=0;for(let e of r)n+=e.lng,a+=e.lat;n/=r.length,a/=r.length;let i="legende-shape-label-".concat(t.id);e.addSource(u,{type:"geojson",data:{type:"Feature",properties:{label:o.label.trim()},geometry:{type:"Point",coordinates:[n,a]}}}),e.addLayer({id:i,type:"symbol",source:u,layout:{"text-field":["get","label"],"text-font":["Open Sans Semibold"],"text-size":13,"text-anchor":"center","text-allow-overlap":!0},paint:{"text-color":o.stroke,"text-halo-color":"#ffffff","text-halo-width":1.5,"text-halo-blur":.5}})}if(!P){let r=r=>{e.on("click",r,e=>{var r,n;null===(r=e.originalEvent)||void 0===r||r.stopPropagation(),null===(n=tp.current)||void 0===n||n.call(tp,t.id)}),e.on("mouseenter",r,()=>{e.getCanvas().style.cursor="pointer"}),e.on("mouseleave",r,()=>{P||(e.getCanvas().style.cursor="")})};r(c),r(d)}p&&r&&function(e,t,r,n,o,l,i,s){let c=(t,r,n)=>{var o,i;let c=document.createElement("div"),d=null!==(o=null==n?void 0:n.size)&&void 0!==o?o:12,u=null!==(i=null==n?void 0:n.color)&&void 0!==i?i:"#0ea5e9";c.style.cssText="\n width: ".concat(d,"px; height: ").concat(d,"px;\n border-radius: 50%;\n background: ").concat(u,";\n border: 2px solid white;\n box-shadow: 0 1px 3px rgba(0,0,0,0.3);\n cursor: move;\n "),c.addEventListener("click",e=>{e.stopPropagation(),s()});let p=new(a()).Marker({element:c,draggable:!0}).setLngLat([r,t]).addTo(e);return l.push(p),p};if("rect"===o.kind){let{ne:l,sw:a}=o,s={lat:l.lat,lng:a.lng},d={lat:a.lat,lng:l.lng};for(let[o,u,p]of[["ne",l,a],["sw",a,l],["nw",s,d],["se",d,s]]){let o=c(u.lat,u.lng);o.on("drag",()=>{let l=o.getLngLat(),a={lat:l.lat,lng:l.lng},i=(0,I.x9)(a,p);j(e,t,r,n,{kind:"rect",ne:i.ne,sw:i.sw})}),o.on("dragend",()=>{let e=o.getLngLat(),t={lat:e.lat,lng:e.lng},r=(0,I.x9)(t,p);i({kind:"rect",ne:r.ne,sw:r.sw})})}let u=(l.lat+a.lat)/2,p=(l.lng+a.lng)/2,g=c(u,p,{color:"#0369a1",size:14});g.on("drag",()=>{let o=g.getLngLat(),i=o.lat-u,s=o.lng-p;j(e,t,r,n,{kind:"rect",ne:{lat:l.lat+i,lng:l.lng+s},sw:{lat:a.lat+i,lng:a.lng+s}})}),g.on("dragend",()=>{let e=g.getLngLat(),t=e.lat-u,r=e.lng-p;i({kind:"rect",ne:{lat:l.lat+t,lng:l.lng+r},sw:{lat:a.lat+t,lng:a.lng+r}})});return}if("circle"===o.kind){let l=o.center,a=c(l.lat,l.lng,{color:"#0284c7",size:14});a.on("drag",()=>{let l=a.getLngLat();j(e,t,r,n,{kind:"circle",center:{lat:l.lat,lng:l.lng},radius_m:o.radius_m})}),a.on("dragend",()=>{let e=a.getLngLat();i({kind:"circle",center:{lat:e.lat,lng:e.lng},radius_m:o.radius_m})});let s=111320*Math.cos(l.lat*Math.PI/180),d=l.lng+o.radius_m/s,u=c(l.lat,d);u.on("drag",()=>{let o=u.getLngLat(),a=Math.max(1,(0,I.Di)(l,{lat:o.lat,lng:o.lng}));j(e,t,r,n,{kind:"circle",center:l,radius_m:a})}),u.on("dragend",()=>{let e=u.getLngLat(),t=Math.max(1,(0,I.Di)(l,{lat:e.lat,lng:e.lng}));i({kind:"circle",center:l,radius_m:t})});return}if("ellipse"===o.kind){let l=o.center,a=o.semi_major_m,s=o.semi_minor_m,d=o.rotation_deg,u=d*Math.PI/180,p=(0,I.Y6)(l,a*Math.cos(u),a*Math.sin(u)),g=(0,I.Y6)(l,-s*Math.sin(u),s*Math.cos(u)),f=c(l.lat,l.lng,{color:"#0284c7",size:14});f.on("drag",()=>{let o=f.getLngLat(),l={lat:o.lat,lng:o.lng};j(e,t,r,n,{kind:"ellipse",...(0,I.d3)({center:l,semi_major_m:a,semi_minor_m:s,rotation_deg:d})})}),f.on("dragend",()=>{let e=f.getLngLat();i({kind:"ellipse",...(0,I.d3)({center:{lat:e.lat,lng:e.lng},semi_major_m:a,semi_minor_m:s,rotation_deg:d})})});let y=c(p.lat,p.lng);y.on("drag",()=>{let o=y.getLngLat(),{dLatPerM:a,dLngPerM:i}=(0,I.nh)(l),c=(o.lng-l.lng)/i,d=(o.lat-l.lat)/a;j(e,t,r,n,{kind:"ellipse",...(0,I.d3)({center:l,semi_major_m:Math.max(1,Math.hypot(c,d)),semi_minor_m:s,rotation_deg:180*Math.atan2(d,c)/Math.PI})})}),y.on("dragend",()=>{let e=y.getLngLat(),{dLatPerM:t,dLngPerM:r}=(0,I.nh)(l),n=(e.lng-l.lng)/r,o=(e.lat-l.lat)/t;i({kind:"ellipse",...(0,I.d3)({center:l,semi_major_m:Math.max(1,Math.hypot(n,o)),semi_minor_m:s,rotation_deg:180*Math.atan2(o,n)/Math.PI})})});let m=c(g.lat,g.lng);m.on("drag",()=>{let o=m.getLngLat(),{dLatPerM:i,dLngPerM:s}=(0,I.nh)(l),c=(o.lng-l.lng)/s,u=(o.lat-l.lat)/i,p=d*Math.PI/180;j(e,t,r,n,{kind:"ellipse",...(0,I.d3)({center:l,semi_major_m:a,semi_minor_m:Math.max(1,Math.abs(-(c*Math.sin(p))+u*Math.cos(p))),rotation_deg:d})})}),m.on("dragend",()=>{let e=m.getLngLat(),{dLatPerM:t,dLngPerM:r}
1=(0,I.nh)(l),n=(e.lng-l.lng)/r,o=(e.lat-l.lat)/t,s=d*Math.PI/180;i({kind:"ellipse",...(0,I.d3)({center:l,semi_major_m:a,semi_minor_m:Math.max(1,Math.abs(-(n*Math.sin(s))+o*Math.cos(s))),rotation_deg:d})})});return}let d=o.ring,u=d.length,p=u>1&&1e-9>Math.abs(d[0].lat-d[u-1].lat)&&1e-9>Math.abs(d[0].lng-d[u-1].lng),g=p?d.slice(0,-1):d.slice(),f=0,y=0;for(let e of g)f+=e.lat,y+=e.lng;f/=g.length,y/=g.length;let m=c(f,y,{color:"#0369a1",size:14});m.on("drag",()=>{let o=m.getLngLat(),l=o.lat-f,a=o.lng-y,i=g.map(e=>({lat:e.lat+l,lng:e.lng+a}));j(e,t,r,n,{kind:"polygon",ring:p&&i.length>0?[...i,i[0]]:i})}),m.on("dragend",()=>{let e=m.getLngLat(),t=e.lat-f,r=e.lng-y,n=g.map(e=>({lat:e.lat+t,lng:e.lng+r}));i({kind:"polygon",ring:p&&n.length>0?[...n,n[0]]:n})}),d.forEach((o,l)=>{let a=c(o.lat,o.lng);a.on("drag",()=>{let o=a.getLngLat(),i=d.slice();i[l]={lat:o.lat,lng:o.lng},j(e,t,r,n,{kind:"polygon",ring:i})}),a.on("dragend",()=>{let e=a.getLngLat(),t=d.slice();t[l]={lat:e.lat,lng:e.lng},i({kind:"polygon",ring:t})})})}(e,s,u,o.label,n,ej.current,e=>{let r=tg.current;r&&r(t.id,e)},()=>{var e;return null===(e=tp.current)||void 0===e?void 0:e.call(tp,t.id)});continue}if("icon"===t.type){let{lat:n,lng:o}=t.geometry,l=t.props,i=null!==(d=I.Y2[l.size])&&void 0!==d?d:28,s=document.createElement("div");s.className="legende-icon",s.style.cssText="\n user-select: none;\n cursor: ".concat(p?"move":"pointer",";\n width: ").concat(i,"px;\n height: ").concat(i,"px;\n display: flex;\n align-items: center;\n justify-content: center;\n ").concat(r?"outline: 2px solid #0ea5e9; outline-offset: 4px; border-radius: 4px;":"","\n "),s.innerHTML=(0,M.Uh)({glyph:l.glyph,color:l.color,sizePx:i,number:"pin"===l.glyph?l.number:void 0,halo:!0}),s.addEventListener("click",e=>{var r;e.stopPropagation(),null===(r=tp.current)||void 0===r||r.call(tp,t.id)});let c=new(a()).Marker({element:s,anchor:"center",draggable:p}).setLngLat([o,n]).addTo(e);p&&u(c,t),ej.current.push(c);continue}}};e.isStyleLoaded()?t():e.once("load",t),e.once("styledata",()=>{setTimeout(t,100)})},[U,H,ta,P,_,eF,eG]),(0,o.useEffect)(()=>{var e,t;null===(e=eO.current)||void 0===e||e.remove(),eO.current=null,null===(t=eA.current)||void 0===t||t.remove(),eA.current=null;let r=ew.current,n=null!=$?$:K;if(!r||!n)return;let o=e=>{let t=document.createElement("div");return t.style.cssText="\n width: 12px; height: 12px;\n border-radius: 50%;\n background: #0ea5e9;\n border: 2px solid ".concat(e,";\n box-shadow: 0 1px 3px rgba(0,0,0,0.3);\n pointer-events: none;\n "),t},l=new(a()).Marker({element:o("white")}).setLngLat([n.lng,n.lat]).addTo(r);if(eO.current=l,"legende:shape:ellipse"===P&&ee&&K){let e=new(a()).Marker({element:o("#bae6fd")}).setLngLat([ee.lng,ee.lat]).addTo(r);eA.current=e}return()=>{var e;l.remove(),eO.current===l&&(eO.current=null),null===(e=eA.current)||void 0===e||e.remove(),eA.current=null}},[$,K,ee,P]),(0,o.useEffect)(()=>{let e=ew.current;if(!e||!("legende:shape:ellipse"===P&&K))return;let t="legende-preview-ellipse-axis",r="legende-preview-ellipse-axis-line",n="legende-preview-shape",o="legende-preview-shape-fill",l="legende-preview-shape-line",a=()=>{try{e.getLayer(r)&&e.removeLayer(r),e.getLayer(o)&&e.removeLayer(o),e.getLayer(l)&&e.removeLayer(l),e.getSource(t)&&e.removeSource(t),e.getSource(n)&&e.removeSource(n)}catch(e){}},i=!!ee,s=()=>{a(),i?(e.addSource(n,{type:"geojson",data:{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[]]}}}),e.addLayer({id:o,type:"fill",source:n,paint:{"fill-color":"#0ea5e9","fill-opacity":.12}}),e.addLayer({id:l,type:"line",source:n,paint:{"line-color":"#0ea5e9","line-width":2,"line-dasharray":[3,2]}})):(e.addSource(t,{type:"geojson",data:{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[]}}}),e.addLayer({id:r,type:"line",source:t,paint:{"line-color":"#0ea5e9","line-width":2,"line-dasharray":[3,2]}}))},c=(r,o)=>{if(K){if(i){if(ee){let t=e.getSource(n);if(!t)return;let l=(0,I.di)(K,ee),a=(0,I.lZ)(K,ee,{lat:r,lng:o}),i=(0,I.T0)(K,ee),s=(0,I.d3)({center:K,semi_major_m:l,semi_minor_m:a,rotation_deg:i}),c=(0,I.dP)(s.center,s.semi_major_m,s.semi_minor_m,s.rotation_deg,64).map(e=>[e.lng,e.lat]);t.setData({type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[c]}})}}else{let n=e.getSource(t);if(!n)return;n.setData({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[[K.lng,K.lat],[o,r]]}})}}},d=e=>{c(e.lngLat.lat,e.lngLat.lng)};return e.isStyleLoaded()?s():e.once("load",s),e.on("mousemove",d),()=>{e.off("mousemove",d),a()}},[P,K,ee]),(0,o.useEffect)(()=>{let e=ew.current;if(!e||!et)return;let t="legende-pending-shape",r="legende-pending-shape-fill",n="legende-pending-shape-line",o="legende-pending-arrow-shaft",l="legende-pending-arrow-head",i="legende-pending-arrow-shaft-line",s="legende-pending-arrow-head-line",c="legende-pending-point",d="legende-pending-point-line",u={"line-color":"#0ea5e9","line-width":2,"line-dasharray":[3,2]},p={"fill-color":"#0ea5e9","fill-opacity":.12},g=null,f=()=>{try{e.getLayer(r)&&e.removeLayer(r),e.getLayer(n)&&e.removeLayer(n),e.getLayer(i)&&e.removeLayer(i),e.getLayer(s)&&e.removeLayer(s),e.getLayer(d)&&e.removeLayer(d
1),e.getSource(t)&&e.removeSource(t),e.getSource(o)&&e.removeSource(o),e.getSource(l)&&e.removeSource(l),e.getSource(c)&&e.removeSource(c)}catch(e){}null==g||g.remove(),g=null},y=()=>{if(f(),!et)return;if("shape"===et.kind){let o=(0,I.aH)(et.geometry).map(e=>[e.lng,e.lat]);e.addSource(t,{type:"geojson",data:{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[o]}}}),e.addLayer({id:r,type:"fill",source:t,paint:p}),e.addLayer({id:n,type:"line",source:t,paint:u});return}if("arrow"===et.kind){let{from:t,to:r}=et.geometry;e.addSource(o,{type:"geojson",data:{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[[t.lng,t.lat],[r.lng,r.lat]]}}}),e.addLayer({id:i,type:"line",source:o,paint:u});let n=R(t,r);e.addSource(l,{type:"geojson",data:{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[[n.left.lng,n.left.lat],[r.lng,r.lat],[n.right.lng,n.right.lat]]}}}),e.addLayer({id:s,type:"line",source:l,paint:u});return}let c=document.createElement("div");c.style.cssText="\n width: 22px; height: 22px;\n border-radius: 50%;\n border: 2px dashed #0ea5e9;\n background: rgba(14, 165, 233, 0.10);\n pointer-events: none;\n box-sizing: border-box;\n ",g=new(a()).Marker({element:c}).setLngLat([et.geometry.lng,et.geometry.lat]).addTo(e)};return e.isStyleLoaded()?y():e.once("load",y),()=>{f()}},[et]);let tw={};for(let e of u)tw[e.group]||(tw[e.group]=[]),tw[e.group].push(e);let tS=l.find(e=>e.id===y)||null;return!function(e,t,r,n,l){let i=(0,o.useRef)([]),s=(0,o.useRef)([]),c=(0,o.useRef)(null);(0,o.useEffect)(()=>{if(i.current.forEach(e=>e.remove()),i.current=[],s.current.forEach(e=>e.remove()),s.current=[],c.current&&(c.current.remove(),c.current=null),!e||!l||!t||"chemin"!==t.type&&"surface"!==t.type&&"parcoursGPS"!==t.type)return;let o=r.filter(e=>e.trace_id===t.id).sort((e,t)=>e.ordre-t.ordre);if(0===o.length)return;let d=t.couleur||"#22c55e",u=t.type,p=t.id,g="chemin"===u||"parcoursGPS"===u,f="surface"===u?"trace-poly-".concat(p):"trace-line-".concat(p);function y(){c.current&&(c.current.remove(),c.current=null)}for(let t=0;t<o.length;t++){let r=o[t],l=g&&(0===t||t===o.length-1),s=document.createElement("div");s.className="vertex-marker",s.style.borderColor=d,l&&(s.style.width="16px",s.style.height="16px");let m=!1,h=new(a()).Marker({element:s,draggable:!0}).setLngLat([r.longitude,r.latitude]).addTo(e);h.on("dragstart",()=>{m=!0,y()}),h.on("drag",()=>{try{let t=e.getSource(f);t&&t.setData(function(e){let t=i.current.map(e=>{let t=e.getLngLat();return[t.lng,t.lat]});return"surface"===u?{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[...t,t[0]]]}}:{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:t}}}())}catch(e){}}),h.on("dragend",()=>{var e;let t=h.getLngLat();null===(e=n.onVertexMoved)||void 0===e||e.call(n,r.id,t.lat,t.lng)}),s.addEventListener("click",o=>{if(o.stopPropagation(),m){m=!1;return}y();let i=document.createElement("div");if(i.style.cssText="padding: 4px; display: flex; flex-direction: column; gap: 4px;",l&&n.onContinueTrace){let e=document.createElement("button");e.textContent="Prolonger",e.style.cssText="padding: 6px 12px; background: #16a34a; color: white; border: none; border-radius: 6px; font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;",e.addEventListener("mouseenter",()=>{e.style.background="#15803d"}),e.addEventListener("mouseleave",()=>{e.style.background="#16a34a"}),e.addEventListener("click",()=>{y();let e=0===t?"start":"end";n.onContinueTrace(p,e)}),i.appendChild(e)}let s=document.createElement("button");s.textContent="Supprimer",s.style.cssText="padding: 6px 12px; background: #ef4444; color: white; border: none; border-radius: 6px; font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;",s.addEventListener("mouseenter",()=>{s.style.background="#dc2626"}),s.addEventListener("mouseleave",()=>{s.style.background="#ef4444"}),s.addEventListener("click",()=>{var e;y(),null===(e=n.onVertexDeleted)||void 0===e||e.call(n,r.id)}),i.appendChild(s);let d=new(a()).Popup({closeButton:!1,offset:12,className:"vertex-popup"}).setLngLat([r.longitude,r.latitude]).setDOMContent(i).addTo(e);c.current=d}),i.current.push(h)}if("surface"===u){let t=(t,r,o,l,c,u)=>{let g=document.createElement("div");g.className="midpoint-marker",g.style.color=d,g.textContent="+";let m=new(a()).Marker({element:g,draggable:!0}).setLngLat([(t+o)/2,(r+l)/2]).addTo(e),h=!1;m.on("dragstart",()=>{h=!0,y(),g.className="vertex-marker",g.style.borderColor=d,g.textContent=""}),m.on("drag",()=>{if(!h)return;let t=m.getLngLat(),r=i.current.map(e=>{let t=e.getLngLat();return[t.lng,t.lat]});r.splice(u,0,[t.lng,t.lat]);try{let t=e.getSource(f);if(t){let e=[...r,r[0]];t.setData({type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[e]}})}}catch(e){}}),m.on("dragend",()=>{var e;if(!h)return;let t=m.getLngLat();null===(e=n.onVertexInserted)||void 0===e||e.call(n,p,c,t.lat,t.lng)}),s.current.push(m)};for(let e=0;e<o.length-1;e++)t(o[e].longitude,o[e].latitude,o[e+1].longitude,o[e+1].latitude,o[e].ordre,e+1);if(o.length>
1=3){let e=o[o.length-1],r=o[0];t(e.longitude,e.latitude,r.longitude,r.latitude,e.ordre,o.length)}}return()=>{i.current.forEach(e=>e.remove()),i.current=[],s.current.forEach(e=>e.remove()),s.current=[],y()}},[e,null==t?void 0:t.id,r,l])}(ew.current,tS,f,{onVertexMoved:N,onVertexDeleted:O,onVertexInserted:A,onContinueTrace:F},!P&&!_),(0,o.useEffect)(()=>{let e=ew.current;if(!e)return;let t=null!=B?B:[],r=eM.current,n=new Map;for(let o of t){let t=r.get(o.userId);if(t){t.setLngLat([o.lng,o.lat]);let e=t.getElement().querySelector(".peer-label");e&&e.dataset.name!==o.name&&(e.textContent=o.name,e.dataset.name=o.name);let l=t.getElement().querySelector(".peer-label");l&&(l.style.backgroundColor=o.color);let a=t.getElement().querySelector(".peer-arrow");a&&a.setAttribute("fill",o.color);let i=t.getElement().querySelector(".peer-drawing-badge");i&&(i.style.display=o.drawing?"inline-block":"none"),n.set(o.userId,t),r.delete(o.userId);continue}let l=document.createElement("div");l.className="peer-cursor",l.style.cssText="position:relative;pointer-events:none;width:0;height:0;",l.innerHTML='\n <svg class="peer-arrow" width="20" height="20" viewBox="0 0 20 20" fill="'.concat(o.color,'" style="position:absolute;top:0;left:0;filter:drop-shadow(0 1px 2px rgba(0,0,0,0.3));">\n <path d="M2 2 L18 9 L10 11 L8 18 Z" stroke="white" stroke-width="1" stroke-linejoin="round" />\n </svg>\n <div class="peer-label" data-name="').concat(o.name.replace(/"/g,"""),'" style="position:absolute;top:18px;left:18px;background-color:').concat(o.color,';color:white;font-size:10px;font-weight:600;padding:2px 6px;border-radius:6px;white-space:nowrap;box-shadow:0 1px 2px rgba(0,0,0,0.2);">').concat(o.name.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),'<span class="peer-drawing-badge" style="display:').concat(o.drawing?"inline-block":"none",';margin-left:4px;background:rgba(255,255,255,0.25);border-radius:4px;padding:0 4px;">dessine</span></div>\n ');let i=new(a()).Marker({element:l,anchor:"top-left"}).setLngLat([o.lng,o.lat]).addTo(e);n.set(o.userId,i)}r.forEach(e=>e.remove()),eM.current=n},[B]),(0,o.useEffect)(()=>()=>{eM.current.forEach(e=>e.remove()),eM.current.clear()},[]),(0,o.useEffect)(()=>{let e=ew.current;if(!e)return;let t=null!=ed?ed:[],r=eC.current,n=new Map;for(let o of t){let t=r.get(o.id),l=eu===o.id?"#15803d":"#0ea5e9";if(t){t.setLngLat([o.lng,o.lat]);
1let e=t.getElement().querySelector(".discussion-pin-dot");e&&(e.style.backgroundColor=l),n.set(o.id,t),r.delete(o.id);continue}let i=document.createElement("div");i.className="discussion-pin",i.style.cssText="cursor:pointer;position:relative;width:28px;height:28px;display:flex;align-items:center;justify-content:center;",i.innerHTML='<div class="discussion-pin-dot" style="width:14px;height:14px;border-radius:9999px;background:'.concat(l,';border:2px solid white;box-shadow:0 1px 3px rgba(0,0,0,0.35);"></div>'),i.addEventListener("click",e=>{var t;e.stopPropagation(),null===(t=tf.current)||void 0===t||t.call(tf,o.id)});let s=new(a()).Marker({element:i}).setLngLat([o.lng,o.lat]).addTo(e);n.set(o.id,s)}r.forEach(e=>e.remove()),eC.current=n},[ed,eu]),(0,o.useEffect)(()=>()=>{eC.current.forEach(e=>e.remove()),eC.current.clear()},[]),(0,o.useEffect)(()=>{let e=ew.current;if(e&&(q||Y))return e.on("mousemove",t),e.getCanvas().addEventListener("mouseleave",r),()=>{var n;e.off("mousemove",t),null===(n=e.getCanvas())||void 0===n||n.removeEventListener("mouseleave",r)};function t(e){null==q||q(e.lngLat.lat,e.lngLat.lng)}function r(){null==Y||Y()}},[q,Y]),(0,n.jsxs)("div",{ref:eL,className:"relative w-full h-full",children:[(0,n.jsx)("div",{ref:eb,className:"w-full h-full"}),(0,n.jsxs)("div",{className:"map-controls-overlay absolute top-3 left-3 z-10 flex items-start gap-2",children:[(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsxs)("button",{onClick:()=>e6(!e8),className:"bg-white rounded-lg shadow-md px-3 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50 transition flex items-center gap-2 border border-gray-200 max-w-[min(100vw-2rem,14rem)]",children:[(0,n.jsx)("svg",{className:"w-4 h-4 shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 20l-5.447-2.724A1 1 0 013 16.382V5.618a1 1 0 011.447-.894L9 7m0 13l6-3m-6 3V7m6 10l4.553 2.276A1 1 0 0021 18.382V7.618a1 1 0 00-.553-.894L15 4m0 13V4m0 0L9 7"})}),(0,n.jsx)("span",{className:"truncate min-w-0",children:null!==(r=null===(t=u.find(e=>e.id===eF))||void 0===t?void 0:t.name)&&void 0!==r?r:"Carte"}),eV>0&&(0,n.jsxs)("span",{className:"shrink-0 text-[11px] font-semibold tabular-nums text-forest-700 bg-forest-100 px-1.5 py-0.5 rounded",title:"".concat(eV," superposition").concat(eV>1?"s":""),children:["+",eV]})]}),e8&&(0,n.jsxs)("div",{className:"absolute top-full left-0 mt-1 bg-white rounded-lg shadow-lg border border-gray-200 py-2 w-60 max-h-[min(24rem,calc(100vh-6rem))] overflow-y-auto",children:[Object.entries(tw).map(e=>{let[t,r]=e;return(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"px-3 py-1 text-xs font-semibold text-gray-400 uppercase tracking-wide",children:t}),r.map(e=>(0,n.jsxs)("button",{type:"button",onClick:()=>{e_(e.id),e6(!1)},className:"w-full text-left px-3 py-1.5 text-sm hover:bg-gray-50 transition flex items-center justify-between ".concat(e.id===eF?"text-forest-700 font-medium bg-forest-50":"text-gray-700"),children:[e.name,e.id===eF&&(0,n.jsx)("svg",{className:"w-4 h-4 shrink-0 text-forest-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]},e.id))]},t)}),(0,n.jsxs)("div",{className:"border-t border-gray-100 mt-1 pt-2",children:[(0,n.jsx)("p",{className:"px-3 py-1 text-xs font-semibold text-gray-400 uppercase tracking-wide",children:"Superpositions"}),(0,n.jsx)("p",{className:"px-3 pb-1 text-[11px] text-gray-500 leading-snug",children:"Au-dessus du fond (IGN France). Ignor\xe9 si identique au fond choisi."}),[...p].sort((e,t)=>{var r,n;return(null!==(r=e.overlayOrder)&&void 0!==r?r:0)-(null!==(n=t.overlayOrder)&&void 0!==n?n:0)}).map(e=>{var t;let r=eP.includes(e.id),o=r||e.id===eF;return(0,n.jsxs)("div",{children:[(0,n.jsxs)("label",{className:"flex items-center gap-2 px-3 py-1.5 text-sm text-gray-700 hover:bg-gray-50 cursor-pointer",children:[(0,n.jsx)("input",{type:"checkbox",checked:r,onChange:()=>{eD(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id])},className:"rounded border-gray-300 text-forest-600 focus:ring-forest-500 shrink-0"}),(0,n.jsx)("span",{className:"leading-tight",children:e.name})]}),e.temporal&&o&&(0,n.jsx)("div",{className:"px-3 pb-1.5 pl-8",children:(0,n.jsx)("input",{type:"date",value:null!==(t=e1[e.id])&&void 0!==t?t:m(e),min:e.temporal.minDate,max:h(),onChange:t=>{let r=t.target.value;r&&e2(t=>
1({...t,[e.id]:r}))},className:"w-full text-[12px] border border-gray-200 rounded px-1.5 py-1 text-gray-700"})}),e.notice&&o&&(0,n.jsx)("p",{className:"px-3 pb-1 pl-8 text-[11px] text-gray-500 leading-snug",children:e.notice}),"ign-old"===e.id&&o&&e3&&(0,n.jsxs)("p",{className:"mx-3 mb-1.5 px-2 py-1 text-[11px] text-amber-800 bg-amber-50 border border-amber-200 rounded leading-snug",children:["â ï¸ ",e3]})]},e.id)})]}),(0,n.jsxs)("div",{className:"border-t border-gray-100 mt-1 pt-2",children:[(0,n.jsx)("p",{className:"px-3 py-1 text-xs font-semibold text-gray-400 uppercase tracking-wide",children:"Couches foresti\xe8res (IGN)"}),(0,n.jsx)("p",{className:"px-3 pb-1 text-[11px] text-gray-500 leading-snug",children:"Dessertes, itin\xe9raires bois ronds, \xe9quipements et contraintes (NaviForest)."}),L.map(e=>(0,n.jsxs)("label",{className:"flex items-center gap-2 px-3 py-1.5 text-sm text-gray-700 hover:bg-gray-50 cursor-pointer",children:[(0,n.jsx)("input",{type:"checkbox",checked:eZ.includes(e.id),onChange:()=>{eB(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id])},className:"rounded border-gray-300 text-forest-600 focus:ring-forest-500 shrink-0"}),(0,n.jsx)("span",{className:"inline-block w-2.5 h-2.5 rounded-full shrink-0",style:{backgroundColor:e.color}}),(0,n.jsx)("span",{className:"leading-tight",children:e.name})]},e.id)),eU&&(0,n.jsxs)("p",{className:"px-3 pt-1 text-[11px] text-amber-600 leading-snug",children:["Zoomez (niveau ⥠",12,") pour afficher ces couches."]}),eZ.includes("old-debroussaillement")&&e3&&(0,n.jsxs)("p",{className:"mx-3 mt-1 mb-1 px-2 py-1 text-[11px] text-amber-800 bg-amber-50 border border-amber-200 rounded leading-snug",children:["â ï¸ ",e3]})]}),(0,n.jsxs)("div",{className:"border-t border-gray-100 mt-1 pt-2",children:[(0,n.jsx)("p",{className:"px-3 py-1 text-xs font-semibold text-gray-400 uppercase tracking-wide",children:"Feux"}),S.map(e=>(0,n.jsxs)("div",{children:[(0,n.jsxs)("label",{className:"flex items-center gap-2 px-3 py-1.5 text-sm text-gray-700 hover:bg-gray-50 cursor-pointer",children:[(0,n.jsx)("input",{type:"checkbox",checked:eX.includes(e.id),onChange:()=>{eJ(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id])},className:"rounded border-gray-300 text-forest-600 focus:ring-forest-500 shrink-0"}),(0,n.jsx)("span",{className:"inline-block w-2.5 h-2.5 rounded-full shrink-0",style:{backgroundColor:e.color}}),(0,n.jsx)("span",{className:"leading-tight",children:e.name})]}),eX.includes(e.id)&&(0,n.jsx)("p",{className:"px-3 pb-1 pl-8 text-[11px] text-gray-500 leading-snug",children:e.description})]},e.id)),eK&&(0,n.jsxs)("p",{className:"px-3 pt-1 text-[11px] text-amber-600 leading-snug",children:["Zoomez (niveau ⥠",7,") pour afficher ces couches."]}),eX.length>0&&(0,n.jsx)("p",{className:"mx-3 mt-1 mb-1 px-2 py-1 text-[11px] text-gray-600 bg-gray-50 border border-gray-200 rounded leading-snug",children:"Ces donn\xe9es sont fournies \xe0 titre dâinformation cartographique. Elles ne sont ni exhaustives ni temps r\xe9el, et ne se substituent pas aux services officiels. En cas dâincendie, composez le 18 ou le 112."})]})]})]}),ey&&(0,n.jsxs)("button",{onClick:ey,className:"rounded-lg shadow-md px-3 py-2 text-sm font-medium transition flex items-center gap-2 border ".concat(ef.length>0?"bg-sky-600 text-white border-sky-600 hover:bg-sky-700":"bg-white text-gray-700 border-gray-200 hover:bg-gray-50"),title:ef.length>0?"".concat(ef.length," carte").concat(ef.length>1?"s":""," superpos\xe9e").concat(ef.length>1?"s":""):"Afficher dâautres cartes en lecture seule",children:[(0,n.jsxs)("svg",{className:"w-4 h-4 shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6l8-3 8 3-8 3-8-3z"}),(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 12l8 3 8-3"}),(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 18l8 3 8-3"})]}),(0,n.jsx)("span",{className:"hidden sm:inline",children:"Cartes"}),ef.length>0&&(0,n.jsxs)("span",{className:"shrink-0 text-[11px] font-semibold tabular-nums px-1.5 py-0.5 rounded ".concat(ef.length>0?"bg-white/20 text-white":"text-forest-700 bg-forest-100"),children:["+",ef.length]})]}),(0,n.jsxs)("button",{onClick:()=>tt(!te),className:"rounded-lg shadow-md px-3 py-2 text-sm font-medium transition flex items-center gap-2 border ".concat(te?"bg-forest-700 text-white border-forest-700 hover:bg-forest-800":"bg-white text-gray-700 border-gray-200 hover:bg-gray-50"),title:te?"Masquer les libell\xe9s":"Afficher les libell\xe9s",children:[(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 7h.01M7 3h5c.512 0 1.024.195 1.414.586l7 7a2 2 0 010 2.828l-7 7a2 2 0 01-2.828 0l-7-7A2 2 0 013 12V7a4 4 0 014-4z"})}),"Libell\xe9s"]}),void 0===Q&&(0,n.jsxs)("button",{onClick:()=>{let e=!to;tl(e),window.localStorage.setItem("sylvie:showAnnotations",e?"1":"0")},className:"rounded-lg shadow-md px-3 py-2 text-sm font-medium transition flex items-center gap-2 border ".concat(to?"bg-sky-600 text-white border-sky-600 hover:bg-sky-700":"bg-white text-gray-700 border-gray-200 hover:bg-gray-50"),title:to?"Masquer les annotations":"Afficher les annotations",children:[(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 8h14M5 12h14M5 16h7"})}),"Annotations"]}),!er&&!el&&en&&(0,n.jsxs)("button",{onClick:en,className:"rounded-lg shadow-md px-3 py-2 text-sm font-medium transition flex items-center gap-2 border bg-white text-forest-700 border-forest-200 hover:bg-forest-50",title:"Cr\xe9er un cartouche de l\xe9gende cartographique",children:[(0,n.jsxs)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 5h16M4 9h16M4 13h10M4 17h10"}
1),(0,n.jsx)("circle",{cx:"18",cy:"15",r:"2",fill:"currentColor"})]}),"Cr\xe9er la l\xe9gende"]}),er&&(0,n.jsxs)("div",{className:"flex items-center bg-white rounded-lg shadow-md border border-gray-200 overflow-hidden",children:[(0,n.jsxs)("button",{onClick:eo,className:"px-3 py-2 text-sm font-medium transition flex items-center gap-2 ".concat((null!=ei?ei:er.visible)?"bg-forest-700 text-white hover:bg-forest-800":"bg-white text-gray-700 hover:bg-gray-50"),title:(null!=ei?ei:er.visible)?"Masquer la l\xe9gende":"Afficher la l\xe9gende",children:[(0,n.jsxs)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 5h16M4 9h16M4 13h10M4 17h10"}),(0,n.jsx)("circle",{cx:"18",cy:"15",r:"2",fill:"currentColor"})]}),"L\xe9gende"]}),!el&&en&&(0,n.jsx)("button",{onClick:en,className:"px-2 py-2 text-gray-500 hover:text-forest-700 hover:bg-forest-50 transition border-l border-gray-200",title:"Modifier la l\xe9gende","aria-label":"Modifier la l\xe9gende",children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})})]})]}),er&&(null!=ei?ei:er.visible)&&(0,n.jsx)(C.Z,{legende:void 0!==ei&&ei!==er.visible?{...er,visible:ei}:er,editable:!el,onRequestEdit:en,excludeFromCapture:ea}),P&&(0,n.jsx)("div",{className:"absolute top-3 right-16 z-10 map-controls-overlay",children:(0,n.jsx)("div",{className:"bg-forest-700 text-white px-3 py-1.5 rounded-lg text-sm font-medium shadow-md",children:"Mode creation"})})]})}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.