@biodiv-platform/naksha-maplibre-layers 5.0.9-beta.0 → 5.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var Rr=Object.create;var Ne=Object.defineProperty;var _r=Object.getOwnPropertyDescriptor;var Br=Object.getOwnPropertyNames;var Ar=Object.getPrototypeOf,Gr=Object.prototype.hasOwnProperty;var Or=(e,t)=>{for(var o in t)Ne(e,o,{get:t[o],enumerable:!0})},At=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Br(t))!Gr.call(e,n)&&n!==o&&Ne(e,n,{get:()=>t[n],enumerable:!(r=_r(t,n))||r.enumerable});return e};var C=(e,t,o)=>(o=e!=null?Rr(Ar(e)):{},At(t||!e||!e.__esModule?Ne(o,"default",{value:e,enumerable:!0}):o,e)),Dr=e=>At(Ne({},"__esModule",{value:!0}),e);var tn={};Or(tn,{NakshaMaplibreLayers:()=>en});module.exports=Dr(tn);var hr=require("@biodiv-platform/naksha-commons"),br=C(require("react"),1),Lr=require("react-map-gl/maplibre"),vr=require("twind");var Gt={are_you_sure:"Are you sure?",base_style:"Base Style",clear:"Clear Selection",created_by:"Attribution",created_on:"Created On",delete:"Delete",download:"Download",find_layer_by_name:"Find layer by name",infobar:"Attributes at Clicked Location",information:"Information",layer_selection:"Layer Selection",layer_selection_all:"All Layers",layer_selection_top:"Top Layer Only",layers:"Layers",legend:"Legend",less:"Less",license:"License",list_layers:"List Layers",pending:"Pending",publish:"Publish",raster_style_not_found:"Style not available for the given layer",remove:"Remove",selected:"Selected",settings:"Settings",square:"Square",tags:"Tags",toggle:"Toggle Publishing",uploaded:"Uploaded",uploader:"Uploader",url:"URL",visiblity:"Visiblity"};var Ot={are_you_sure:"\xCAtes-vous s\xFBr?",base_style:"Style de base",clear:"Effacer la s\xE9lection",created_by:"Attribution",created_on:"Cr\xE9\xE9 sur",delete:"Effacer",download:"T\xE9l\xE9charger",find_layer_by_name:"Trouver la couche par nom",infobar:"Attributs \xE0 l'emplacement cliqu\xE9",information:"Informations",layer_selection_all:"Toutes les couches",layer_selection_top:"Couche sup\xE9rieure uniquement",layer_selection:"S\xE9lection de calque",layers:"Couches",legend:"L\xE9gende",less:"Moins",license:"Licence",list_layers:"Liste des couches",pending:"En attente",publish:"Publier",remove:"Supprimer",selected:"Choisie",settings:"Param\xE8tres",square:"Carr\xE9",toggle:"Basculer la publication",uploaded:"T\xE9l\xE9charg\xE9",url:"url"};var Dt={are_you_sure:"\u0915\u094D\u092F\u093E \u0906\u092A\u0915\u094B \u092F\u0915\u0940\u0928 \u0939\u0948?",base_style:"\u0906\u0927\u093E\u0930 \u0936\u0948\u0932\u0940",clear:"\u091A\u092F\u0928 \u0938\u093E\u092B\u093C \u0915\u0930\u0947\u0902",created_by:"\u0906\u0930\u094B\u092A\u0923",created_on:"\u092A\u0930 \u092C\u0928\u093E\u092F\u093E",delete:"\u0939\u091F\u093E\u090F\u0902",download:"\u0921\u093E\u0909\u0928\u0932\u094B\u0921",find_layer_by_name:"\u0928\u093E\u092E \u0938\u0947 \u092A\u0930\u0924 \u0916\u094B\u091C\u0947\u0902",infobar:"\u0915\u094D\u0932\u093F\u0915 \u0915\u093F\u090F \u0917\u090F \u0938\u094D\u0925\u093E\u0928 \u092A\u0930 \u0935\u093F\u0936\u0947\u0937\u0924\u093E\u090F\u0902",information:"\u091C\u093E\u0928\u0915\u093E\u0930\u0940",layer_selection_all:"\u0938\u092D\u0940 \u092A\u0930\u0924\u0947\u0902",layer_selection_top:"\u0915\u0947\u0935\u0932 \u0936\u0940\u0930\u094D\u0937 \u092A\u0930\u0924",layer_selection:"\u092A\u0930\u0924 \u091A\u092F\u0928",layers:"\u092A\u0930\u0924\u0947\u0902",legend:"\u0915\u093F\u0902\u0935\u0926\u0902\u0924\u0940",less:"\u0915\u092E",license:"\u0932\u093E\u0907\u0938\u0947\u0902\u0938",list_layers:"\u0938\u0942\u091A\u0940 \u092A\u0930\u0924\u0947\u0902",pending:"\u0932\u0902\u092C\u093F\u0924",publish:"\u092A\u094D\u0930\u0915\u093E\u0936\u093F\u0924",remove:"\u0939\u091F\u093E\u0928\u093E",selected:"\u091A\u092F\u0928\u093F\u0924",settings:"\u0938\u092E\u093E\u092F\u094B\u091C\u0928",square:"\u0938\u094D\u0915\u094D\u0935\u093E\u092F\u0930",tags:"\u091F\u0948\u0917",toggle:"\u092A\u094D\u0930\u0915\u093E\u0936\u0928 \u091F\u0949\u0917\u0932 \u0915\u0930\u0947\u0902",uploaded:"\u0905\u092A\u0932\u094B\u0921 \u0915\u093F\u092F\u093E \u0917\u092F\u093E",url:"\u092F\u0942\u0906\u0930\u090F\u0932"};var zt={en:Gt,fr:Ot,hi:Dt};var yr=require("@biodiv-platform/naksha-commons"),Ze=require("react"),pe=C(require("react-map-gl/maplibre"),1),gr=require("twind");var Be=require("@biodiv-platform/naksha-commons"),g=C(require("react"),1),ro=require("react-map-gl/maplibre");var Jt=C(require("colorbrewer"),1),F=C(require("redaxios"),1);var tt=C(require("boundingbox"),1),_e=require("geohash");var Ee=require("@biodiv-platform/naksha-commons"),Ht={defaultViewState:Ee.defaultViewState,nakshaApiEndpoint:"/naksha-api/api",geoserver:{endpoint:"/geoserver",workspace:"biodiv",store:"ibp"},mapStyle:Ee.MapStyles.MAP_STREETS,layers:[],selectedLayers:[]},$t="data:image/svg+xml,%3Csvg fill='none' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 72 72'%3E%3Cpath fill='%23fff' d='M0 0h72v72H0z'/%3E%3Cpath d='M35.981 48.293l-13.853-10.77-3.045 2.368L36 53.048l16.917-13.157-3.064-2.387-13.872 10.789zM36 43.519l13.834-10.77 3.083-2.388L36 17.204 19.083 30.36l3.064 2.387L36 43.518z' fill='%23A0AEC0'/%3E%3C/svg%3E",Qe={display:"-webkit-box",WebkitLineClamp:1,WebkitBoxOrient:"vertical",overflow:"hidden",wordBreak:"break-word"},qt={...Qe,WebkitLineClamp:2},R="ogc_fid",Re={ACTIVE:"Active",PENDING:"Pending"},_={TOP:"layer_selection_top",ALL:"layer_selection_all"};var Ft=e=>e<6?[4,1,39.2]:e<7?[5,0,19.6]:e<8?[5,1,9.8]:e<9?[5,-1,4.9]:e<10?[6,0,2.45]:e<11?[6,1,1.225]:e<12?[7,0,.612]:e<13?[7,1,.306]:e<14?[7,-1,.153]:e<15?[8,0,.077]:[8,1,.039],et="0123456789bcdefghjkmnpqrstuvwxyz",qr=(e,t,o)=>{o=o||16/2**(1-e.length&1)/4**t;let r=e.slice(0,-1),n=~~(et.indexOf(e.slice(-1))/o);return[r+et[o*n],r+et[o*(n+1)-1]]},Fr=function(e,t){var o=new Map,r=new Map;let n=[];for(let[a,s]of Object.entries(e)){let[l,u]=qr(a,t);r.set(l,u),o.has(l)||o.set(l,0),o.set(l,o.get(l)+s)}return o.forEach((a,s)=>{let l=_e.GeoHash.decodeGeoHash(s),u=_e.GeoHash.decodeGeoHash(r.get(s)),d=new tt.default({minlat:l.latitude[0],minlon:l.longitude[0],maxlat:u.latitude[1],maxlon:u.longitude[1]}).toGeoJSON();n.push({...d,properties:{count:a,[R]:s}})}),n},Vr=e=>{let t=[];for(let[o,r]of Object.entries(e)){let n=_e.GeoHash.decodeGeoHash(o),a=new tt.default({minlat:n.latitude[0],minlon:n.longitude[0],maxlat:n.latitude[1],maxlon:n.longitude[1]}).toGeoJSON();t.push({...a,properties:{count:r,[R]:o}})}return t},Vt=(e,t)=>({type:"FeatureCollection",features:Object.keys(e).length===0?[]:t===-1?Vr(e):Fr(e,t)}),Wt=(e,t)=>{let o=Object.values(e).sort((a,s)=>a-s),r=Math.floor(o.length/t),n=new Array(t-1).fill(0).map((a,s)=>o[r*(s+1)]);return n.push(o[o.length-1]),n};var Zt=require("immer");var Yt=async(e,t,o,r)=>{let n=[];for(let a of e){let s=r.includes(a.name),l={...a,id:a.name,thumbnail:t+a.thumbnail,source:{type:a.layerType.toLowerCase()==="raster"?"raster":"vector",scheme:"tms",tiles:[`${o.endpoint}/gwc/service/tms/1.0.0/${o.workspace}:${a.name}@EPSG%3A900913@pbf/{z}/{x}/{y}.pbf`]},data:{styles:[]},isAdded:s};if(s){let u=await ot(l,0,t,o);n.push({...l,data:u})}else n.push(l)}return n},ot=async(e,t,o,r)=>(0,Zt.produce)(e.data,async a=>{if(a.styles.length===0){let{success:s,data:l}=await Ut(e.id,o);s&&(a.layerName=l.layerName,a.styles=l.styles,a.summaryColumn=l.summaryColumn,a.titleColumn=l.titleColumn,a.propertyMap=Object.fromEntries(l.styles.map(u=>[u.styleName,u.styleTitle])))}a.styles[t]&&!a.styles[t]?.colors&&(a.styles[t].colors=await jt(e.id,r?.workspace,a.styles[t].styleName,o)),a.styleIndex=t});var Kt=async(e,t,o,r)=>{try{let n=await F.default.get(`${t}/layer/all`,{headers:{Authorization:e}});return await Yt(n.data,t,o,r)}catch(n){return console.error(n),[]}},Ut=async(e,t)=>{try{let{data:o}=await F.default.get(`${t}/layer/onClick/${e}`);return{success:!0,data:o}}catch(o){return console.error(o),{success:!1}}},Xt=async(e,t,o)=>{let r={service:"WMS",version:"1.1.1",request:"GetFeatureInfo",info_format:"application/json",width:100,height:100,x:50,y:50,srs:"EPSG:4326"};try{return{success:!0,data:(await F.default.get(`${e}/${t}/wms`,{params:{...o,...r}})).data}}catch(n){return console.error(n),{success:!1,data:[]}}},Qt=async(e,t,o,r)=>{try{return await F.default.put(`${t}/layer/${r?"active":"pending"}/${o}`,{},{headers:{Authorization:e}}),!0}catch(n){return console.error(n),!1}},eo=async(e,t,o)=>{try{return await F.default.delete(`${t}/layer/${o}`,{headers:{Authorization:e}}),!0}catch(r){return console.error(r),!1}},jt=async(e,t,o,r)=>{try{return(await F.default.get(`${r}/geoserver/workspaces/${t}/styles/${e}_${o}.mbstyle`)).data?.layers?.[0]}catch(n){return console.error(n),{}}},to=async(e,t,o,r=6,n="YlOrRd")=>{try{let[a,s,l]=Ft(o),{_ne:u,_sw:d}=t,b={top:u.lat,left:d.lng,bottom:d.lat,right:u.lng,geoAggegationPrecision:a},L=await e(b),P=Vt(L,s),z=Wt(L,r).map((Y,ue)=>[Y,Jt.default[n][r][ue]]);return{success:!0,geojson:P,paint:{"fill-color":{property:"count",default:"yellow",stops:z},"fill-outline-color":"rgba(0,0,0,0.2)","fill-opacity":.7},stops:z,squareSize:l}}catch(a){return console.error(a),{success:!1,geojson:{},paint:{},stops:[],squareSize:0}}},oo=async(e,t,o,r)=>{try{await F.default.post(`${e}/layer/download`,{layerName:o,layerTitle:r,attributeList:[],filterArray:[]},{headers:{Authorization:t}})}catch(n){console.error(n)}};var so=require("react/jsx-runtime"),no=(0,g.createContext)({}),ao=({mp:e,children:t})=>{let[o,r]=(0,g.useState)(e),{mapl:n}=(0,ro.useMap)(),[a,s]=(0,g.useState)(""),l=(0,Be.useDebounce)(a,500),u=o.mapStyles&&o.mapStyles.length>0?o.mapStyles:Be.defaultMapStyles,[d,b]=(0,g.useState)(u[o?.mapStyle||0]?.style),[L,P]=(0,g.useState)(u[o?.mapStyle||0]?.maxZoom),[k,z]=(0,g.useState)(_.TOP),[q,Y]=(0,g.useState)({}),[ue,Ye]=(0,g.useState)(!0),[H,xr]=(0,g.useState)(),[T,Ue]=(0,g.useState)(e.layers||[]),[S,Q]=(0,g.useState)(o.selectedLayers||[]),[Tt,Mt]=(0,g.useState)(),[je,Nt]=(0,g.useState)(),Sr=(0,g.useMemo)(()=>{let p={};for(let m of je||[])p[m.sourceLayer]=[...p[m.sourceLayer]||[],m?.properties?.[R]];return Object.keys(p).length?p:void 0},[je]),Je=g.default.useMemo(()=>{let p=T.filter(f=>S.includes(f.id)),m=new Array(S.length);for(let f of p){let x=S.findIndex(w=>f.id===w);x>-1&&(m[x]=f)}return m},[T,S]),Te=p=>T.findIndex(m=>m.id===p),Et=(p,m)=>{Ue(f=>f.map(x=>x.id===p?{...x,...m}:x))},Rt=async(p,m,f)=>{let x=T[p],w=await ot(x,m,o.nakshaApiEndpoint,o.geoserver);Et(x.id,{data:w}),f&&n?.fitBounds(x.bbox,{padding:40,duration:1e3})},wr=async(p,m)=>{let f=Te(p);Rt(f,m,!1)},Ir=async p=>{if(!(!S.length||!n))try{let m=S[0],f=n.queryRenderedFeatures(p.point,{layers:[m]});if(f.length){let x=f[0]?.id||f[0]?.properties?.[R];if(x===Tt?.id)return;let w=T[Te(m)],Bt=w?.data?.summaryColumn.map($=>[w.data?.propertyMap?.[$]||$,f[0].properties?.[$]]);Mt({id:x,title:w.title,data:Bt})}else Mt(void 0)}catch{}},kr=async({layerId:p,add:m,styleIndex:f=0,focus:x=!0})=>{if(!m){Q(S.filter($=>p!==$));return}let w=Te(p);T[w]?.source.type==="grid"?(Q($=>[p,...$.filter(Xe=>Xe!==p)]),x&&T[w]?.bbox&&setTimeout(()=>{n?.fitBounds(T[w].bbox,{padding:40,duration:1e3})},100)):(await Rt(w,f,x),Q($=>[p,...$.filter(Xe=>Xe!==p)]))},Cr=async()=>Q([]),Pr=(p,m)=>{r({...o,[p]:m})},Tr=(p,m)=>{let f=m===Re.PENDING;Qt(o.nakshaEndpointToken,o.nakshaApiEndpoint,p,f),Et(p,{layerStatus:f?Re.ACTIVE:Re.PENDING})},Mr=async(p,m)=>{confirm(m)&&(eo(o.nakshaEndpointToken,o.nakshaApiEndpoint,p),Ue(T.filter(f=>f.id!==p)))},Nr=p=>{let m=Te(p),f=T[m];n?.fitBounds(f.bbox,{padding:40,duration:1e3})},_t=()=>[H.lng,H.lat,H.lng+.1,H.lat+.1],Er=p=>{z(p),p===_.TOP&&Ke(p)},Ke=p=>{if(H)try{let m=n?.project([H.lng,H.lat]),f=n?.queryRenderedFeatures(m,{layers:k===_.TOP?[S[0]]:S});if((p||k)===_.ALL){let x=Je.filter(w=>w.layerType=="RASTER").map(w=>({sourceLayer:w.id,layerType:"raster",bbox:_t()}));f=[...f,...x]}Nt(Je?.[0].layerType==="RASTER"&&k!==_.ALL?S.length&&f?.length?f:[{sourceLayer:S[0],layerType:"raster",bbox:_t()}]:f)}catch(m){console.error(m)}},Me=(e.selectedLayers||[]).join(",");return(0,g.useEffect)(()=>{Me!==S.join(",")&&Q(Me?Me.split(","):[])},[Me]),(0,g.useEffect)(()=>{o.onSelectedLayersChange&&o.onSelectedLayersChange(S)},[S]),(0,g.useEffect)(()=>{setTimeout(Ke,300)},[H,k,S]),(0,so.jsx)(no.Provider,{value:{mp:o,updateMP:Pr,layer:{mapStyle:d,featuresAtLatLng:Ke,setMapStyle:b,maxZoom:L,setMaxZoom:P,mapStyles:u,all:T,setAll:Ue,selectedIds:S,handleSelectStyle:Er,setSelectedIds:Q,selectedLayers:Je,clearAll:Cr,toggle:kr,updateStyle:wr,selectedFeatures:je,selectedFeaturesId:Sr,setSelectedFeatures:Nt,togglePublish:Tr,delete:Mr,selectionStyle:k,setSelectionStyle:z,zoomToExtent:Nr,gridLegends:q,setGridLegends:Y},query:{term:l,setTerm:s,clickedLngLat:H,setClickedLngLat:xr},isInfoBarOpen:ue,setIsInfoBarOpen:Ye,hover:{onHover:Ir,features:Tt}},children:t})};function c(){return(0,g.useContext)(no)}var So=C(require("react"),1),fe=require("twind");var io=require("twind"),i=require("react/jsx-runtime"),lo=()=>(0,i.jsx)("svg",{fill:"none",className:io.tw`w-5 h-5 text-gray-400`,width:"24",height:"24",viewBox:"0 0 24 24",children:(0,i.jsx)("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),me=()=>(0,i.jsxs)("svg",{width:"18",height:"18",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",children:[(0,i.jsx)("path",{d:"M12 2L2 7 12 12 22 7 12 2z"}),(0,i.jsx)("path",{d:"M2 17L12 22 22 17"}),(0,i.jsx)("path",{d:"M2 12L12 17 22 12"})]}),Ae=()=>(0,i.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,i.jsx)("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),(0,i.jsx)("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),co=()=>(0,i.jsxs)("svg",{width:"18",height:"18",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",children:[(0,i.jsx)("path",{d:"M4 21L4 14"}),(0,i.jsx)("path",{d:"M4 10L4 3"}),(0,i.jsx)("path",{d:"M12 21L12 12"}),(0,i.jsx)("path",{d:"M12 8L12 3"}),(0,i.jsx)("path",{d:"M20 21L20 16"}),(0,i.jsx)("path",{d:"M20 12L20 3"}),(0,i.jsx)("path",{d:"M1 14L7 14"}),(0,i.jsx)("path",{d:"M9 8L15 8"}),(0,i.jsx)("path",{d:"M17 16L23 16"})]});function rt(){return(0,i.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",style:{display:"inline-block"},children:(0,i.jsx)("path",{fillRule:"evenodd",fill:"currentColor",d:"M5.5 3.5a2 2 0 100 4 2 2 0 000-4zM2 5.5a3.5 3.5 0 115.898 2.549 5.507 5.507 0 013.034 4.084.75.75 0 11-1.482.235 4.001 4.001 0 00-7.9 0 .75.75 0 01-1.482-.236A5.507 5.507 0 013.102 8.05 3.49 3.49 0 012 5.5zM11 4a.75.75 0 100 1.5 1.5 1.5 0 01.666 2.844.75.75 0 00-.416.672v.352a.75.75 0 00.574.73c1.2.289 2.162 1.2 2.522 2.372a.75.75 0 101.434-.44 5.01 5.01 0 00-2.56-3.012A3 3 0 0011 4z"})})}function po(){return(0,i.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",style:{display:"inline-block"},children:(0,i.jsx)("path",{fillRule:"evenodd",fill:"currentColor",d:"M2.5 7.775V2.75a.25.25 0 01.25-.25h5.025a.25.25 0 01.177.073l6.25 6.25a.25.25 0 010 .354l-5.025 5.025a.25.25 0 01-.354 0l-6.25-6.25a.25.25 0 01-.073-.177zm-1.5 0V2.75C1 1.784 1.784 1 2.75 1h5.025c.464 0 .91.184 1.238.513l6.25 6.25a1.75 1.75 0 010 2.474l-5.026 5.026a1.75 1.75 0 01-2.474 0l-6.25-6.25A1.75 1.75 0 011 7.775zM6 5a1 1 0 100 2 1 1 0 000-2z"})})}function uo(){return(0,i.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",style:{display:"inline-block"},children:(0,i.jsx)("path",{fillRule:"evenodd",fill:"currentColor",d:"M8.75.75a.75.75 0 00-1.5 0V2h-.984c-.305 0-.604.08-.869.23l-1.288.737A.25.25 0 013.984 3H1.75a.75.75 0 000 1.5h.428L.066 9.192a.75.75 0 00.154.838l.53-.53-.53.53v.001l.002.002.002.002.006.006.016.015.045.04a3.514 3.514 0 00.686.45A4.492 4.492 0 003 11c.88 0 1.556-.22 2.023-.454a3.515 3.515 0 00.686-.45l.045-.04.016-.015.006-.006.002-.002.001-.002L5.25 9.5l.53.53a.75.75 0 00.154-.838L3.822 4.5h.162c.305 0 .604-.08.869-.23l1.289-.737a.25.25 0 01.124-.033h.984V13h-2.5a.75.75 0 000 1.5h6.5a.75.75 0 000-1.5h-2.5V3.5h.984a.25.25 0 01.124.033l1.29.736c.264.152.563.231.868.231h.162l-2.112 4.692a.75.75 0 00.154.838l.53-.53-.53.53v.001l.002.002.002.002.006.006.016.015.045.04a3.517 3.517 0 00.686.45A4.492 4.492 0 0013 11c.88 0 1.556-.22 2.023-.454a3.512 3.512 0 00.686-.45l.045-.04.01-.01.006-.005.006-.006.002-.002.001-.002-.529-.531.53.53a.75.75 0 00.154-.838L13.823 4.5h.427a.75.75 0 000-1.5h-2.234a.25.25 0 01-.124-.033l-1.29-.736A1.75 1.75 0 009.735 2H8.75V.75zM1.695 9.227c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L3 6.327l-1.305 2.9zm10 0c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L13 6.327l-1.305 2.9z"})})}function mo(){return(0,i.jsx)("svg",{viewBox:"0 0 16 16",width:"14",height:"14",style:{display:"inline-block"},children:(0,i.jsx)("path",{fillRule:"evenodd",fill:"currentColor",d:"M1.679 7.932c.412-.621 1.242-1.75 2.366-2.717C5.175 4.242 6.527 3.5 8 3.5c1.473 0 2.824.742 3.955 1.715 1.124.967 1.954 2.096 2.366 2.717a.119.119 0 010 .136c-.412.621-1.242 1.75-2.366 2.717C10.825 11.758 9.473 12.5 8 12.5c-1.473 0-2.824-.742-3.955-1.715C2.92 9.818 2.09 8.69 1.679 8.068a.119.119 0 010-.136zM8 2c-1.981 0-3.67.992-4.933 2.078C1.797 5.169.88 6.423.43 7.1a1.619 1.619 0 000 1.798c.45.678 1.367 1.932 2.637 3.024C4.329 13.008 6.019 14 8 14c1.981 0 3.67-.992 4.933-2.078 1.27-1.091 2.187-2.345 2.637-3.023a1.619 1.619 0 000-1.798c-.45-.678-1.367-1.932-2.637-3.023C11.671 2.992 9.981 2 8 2zm0 8a2 2 0 100-4 2 2 0 000 4z"})})}function fo(){return(0,i.jsx)("svg",{viewBox:"0 0 16 16",width:"14",height:"14",style:{display:"inline-block"},children:(0,i.jsx)("path",{fillRule:"evenodd",fill:"currentColor",d:"M1.5 8a6.5 6.5 0 1113 0 6.5 6.5 0 01-13 0zM8 0a8 8 0 100 16A8 8 0 008 0zm.5 4.75a.75.75 0 00-1.5 0v3.5a.75.75 0 00.471.696l2.5 1a.75.75 0 00.557-1.392L8.5 7.742V4.75z"})})}function yo(){return(0,i.jsx)("svg",{viewBox:"0 0 16 16",width:"16",height:"16",style:{display:"inline-block"},children:(0,i.jsx)("path",{fillRule:"evenodd",fill:"currentColor",d:"M7.47 10.78a.75.75 0 001.06 0l3.75-3.75a.75.75 0 00-1.06-1.06L8.75 8.44V1.75a.75.75 0 00-1.5 0v6.69L4.78 5.97a.75.75 0 00-1.06 1.06l3.75 3.75zM3.75 13a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5z"})})}function go(){return(0,i.jsx)("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:(0,i.jsx)("path",{d:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"})})}function ho(){return(0,i.jsxs)("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:[(0,i.jsx)("circle",{cx:"18",cy:"5",r:"3"}),(0,i.jsx)("circle",{cx:"6",cy:"12",r:"3"}),(0,i.jsx)("circle",{cx:"18",cy:"19",r:"3"}),(0,i.jsx)("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),(0,i.jsx)("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]})}function bo(){return(0,i.jsx)("svg",{viewBox:"0 0 16 16",width:"16",height:"16",style:{display:"inline-block"},children:(0,i.jsx)("path",{fillRule:"evenodd",d:"M10 13a1 1 0 100-2 1 1 0 000 2zm-4 0a1 1 0 100-2 1 1 0 000 2zm1-5a1 1 0 11-2 0 1 1 0 012 0zm3 1a1 1 0 100-2 1 1 0 000 2zm1-5a1 1 0 11-2 0 1 1 0 012 0zM6 5a1 1 0 100-2 1 1 0 000 2z"})})}function Lo(){return(0,i.jsxs)("svg",{style:{display:"inline-block"},width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,i.jsx)("line",{x1:"22",y1:"12",x2:"18",y2:"12"}),(0,i.jsx)("line",{x1:"6",y1:"12",x2:"2",y2:"12"}),(0,i.jsx)("line",{x1:"12",y1:"6",x2:"12",y2:"2"}),(0,i.jsx)("line",{x1:"12",y1:"22",x2:"12",y2:"18"})]})}function vo(){return(0,i.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:(0,i.jsx)("polyline",{points:"6 9 12 15 18 9"})})}function xo(){return(0,i.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:(0,i.jsx)("polyline",{points:"18 15 12 9 6 15"})})}var U=require("react/jsx-runtime"),V=So.default.forwardRef((e,t)=>(0,U.jsx)("button",{ref:t,type:"button",className:fe.tw`h-8 px-3 py-2 rounded-md focus:outline-none focus:ring cursor-pointer text-md flex align-middle items-center gap-2 bg-gray-100 hover:bg-gray-200 text-gray-700 disabled:cursor-not-allowed disabled:bg-gray-100! disabled:opacity-50`,...e}));var Ge=e=>(0,U.jsx)("button",{className:fe.tw`absolute top-0 right-0 h-12 w-12 bg-red-100 cursor-pointer hover:bg-red-200 text-red-800 text-lg`,children:"\u2715",...e}),wo=e=>(0,U.jsx)("button",{className:fe.tw`absolute top-4 left-4 rounded-lg z-10 h-10 w-10 bg-white cursor-pointer hover:bg-gray-100 text-gray-700 text-lg flex items-center justify-center`,...e,children:(0,U.jsx)(me,{})}),Io=e=>(0,U.jsx)("button",{className:fe.tw`absolute top-4 right-4 rounded-lg z-10 h-10 w-10 bg-white cursor-pointer hover:bg-gray-100 text-gray-700 text-lg flex items-center justify-center`,...e,children:(0,U.jsx)(Ae,{})});var j=require("twind");var I=require("react/jsx-runtime");var ee=e=>(0,I.jsxs)("div",{children:[e.label&&(0,I.jsx)("label",{className:j.tw`text-gray-700`,htmlFor:e.name,children:e.label}),(0,I.jsx)("select",{id:e.name,name:e.name,className:j.tw`block w-full px-4 py-2 mt-2 text-gray-700 border bg-white border-gray-200 rounded-md focus:outline-none focus:ring appearance-none text-base`,style:{backgroundImage:`url("data:image/svg+xml,%0A%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3E%3C/svg%3E")`,backgroundPosition:"right 0.75rem center",backgroundSize:"16px 12px",backgroundRepeat:"no-repeat"},...e})]}),ko=e=>(0,I.jsxs)("div",{className:"relative",children:[(0,I.jsx)("span",{className:j.tw`absolute inset-y-0 left-0 flex items-center pl-3`,children:(0,I.jsx)(lo,{})}),(0,I.jsx)("input",{type:"search",className:j.tw`w-full py-2 pl-10 pr-4 text-gray-700 bg-white border border-gray-300 text-base rounded-md focus:outline-none focus:ring`,...e})]}),Co=e=>e.isLoading?(0,I.jsx)("svg",{width:"20px",height:"20px",viewBox:"0 0 20 20",version:"1.1",className:j.tw`inline text-gray-200 animate-spin dark:text-gray-600`,children:(0,I.jsx)("g",{stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:(0,I.jsx)("g",{fill:"#212121",fillRule:"nonzero",children:(0,I.jsx)("path",{d:"M10,3 C6.13401,3 3,6.13401 3,10 C3,10.2761 2.77614,10.5 2.5,10.5 C2.22386,10.5 2,10.2761 2,10 C2,5.58172 5.58172,2 10,2 C14.4183,2 18,5.58172 18,10 C18,14.4183 14.4183,18 10,18 C9.72386,18 9.5,17.7761 9.5,17.5 C9.5,17.2239 9.72386,17 10,17 C13.866,17 17,13.866 17,10 C17,6.13401 13.866,3 10,3 Z"})})})}):(0,I.jsx)("input",{type:"checkbox",className:j.tw`w-5 h-5 border-gray-100 focus:outline-none focus:ring focus:ring-blue-300 focus:ring-opacity-80`,name:e.name,checked:e.checked,onChange:e.onChange});var J=require("@bumaga/tabs"),Po=C(require("clsx"),1),ye=require("twind"),te=require("react/jsx-runtime"),Oe=({children:e,icon:t})=>{let{onClick:o,isActive:r}=(0,J.useTabState)(),n=(0,Po.default)(["flex items-center justify-center h-12 px-2 py-2 bg-transparent -mb-px border-b-2 -px-1 whitespace-nowrap focus:outline-none w-full cursor-pointer",{"text-blue-600 border-blue-500":r,"text-gray-700 border-gray-300 hover:border-gray-400":!r}]);return(0,te.jsxs)("button",{className:(0,ye.tw)(n),onClick:o,children:[t,(0,te.jsx)("span",{className:ye.tw`ml-2 text-base`,children:e})]})},De=({children:e})=>(0,J.usePanelState)()?(0,te.jsx)("div",{className:ye.tw`w-full flex flex-grow-1 overflow-auto`,children:e}):null,To=({children:e})=>(0,te.jsx)("div",{className:ye.tw`flex flex-shrink-0 border-b border-gray-200 justify-around pr-12`,children:e});var Eo=require("@biodiv-platform/naksha-commons"),Le=require("twind");var Mo=require("@biodiv-platform/naksha-commons");var nt=require("react/jsx-runtime");function ge({hideLabel:e}){let{layer:{selectionStyle:t,handleSelectStyle:o}}=c(),{t:r}=(0,Mo.useT)(),n=a=>{o(a.target.value)};return(0,nt.jsx)(ee,{name:"layer_selection",label:e?null:r("layer_selection"),defaultValue:t,onChange:n,children:Object.values(_).map(a=>(0,nt.jsx)("option",{value:a,children:r(a)},a))})}var No=C(require("clsx"),1),be=require("react"),he=require("twind");var B=require("react/jsx-runtime");function at({data:e}){let[t,o]=(0,be.useState)(!0),[r,n]=(0,be.useState)({title:e.sourceLayer,properties:[]}),{layer:a,mp:s,query:{clickedLngLat:l}}=c(),u=async()=>{let d,b=a.selectedLayers.find(L=>L.id===(e.sourceLayer||e.source));if(b.layerType.toLowerCase()==="raster"){let{data:L}=await Xt(s.geoserver?.endpoint,s.geoserver?.workspace,{bbox:e.bbox.toString(),query_layers:`${s.geoserver?.workspace}:${b.id}`,layers:`${s.geoserver?.workspace}:${b.id}`});d=L?.features[0]?Object.entries(L.features[0]?.properties).map(([P,k])=>[k||"-"]):[]}else d=Object.entries(b?.data?.propertyMap||{}).map(([L,P])=>[P,e?.properties?.[L]]);n({title:b.title,properties:d})};return(0,be.useEffect)(()=>{u()},[l]),(0,B.jsxs)("div",{className:he.tw`bg-gray-100 rounded-lg`,children:[(0,B.jsxs)("button",{className:(0,he.tw)((0,No.default)(["px-4 h-10 flex items-center justify-between bg-gray-100 hover:bg-gray-200 transition-colors cursor-pointer w-full focus:outline-none focus:ring",{"bg-gray-200 rounded-t-lg":t,"rounded-lg":!t}])),onClick:()=>o(!t),children:[r.title," ",t?(0,B.jsx)(xo,{}):(0,B.jsx)(vo,{})]}),t&&(0,B.jsx)("div",{className:he.tw`px-4 py-3 flex flex-col gap-3`,children:r.properties.map(([d,b],L)=>(0,B.jsxs)("div",{children:[(0,B.jsx)("div",{className:he.tw`text-gray-600`,children:d}),(0,B.jsx)("div",{children:b})]},d+b+L))})]})}var M=require("react/jsx-runtime");function st({onClose:e}){let{layer:{selectedFeatures:t,selectedLayers:o,selectionStyle:r}}=c(),{t:n}=(0,Eo.useT)();return(0,M.jsxs)("div",{className:Le.tw`absolute top-0 right-0 bottom-0 left-0 md:top-4 md:right-4 md:bottom-4 md:left-auto bg-white rounded-lg overflow-hidden shadow-md md:max-w-sm w-full z-20 flex flex-col`,children:[(0,M.jsxs)("div",{className:"flex w-full",children:[(0,M.jsxs)("div",{className:Le.tw`h-12 px-4 flex items-center gap-3 flex-grow bg-gray-200`,children:[(0,M.jsx)(Lo,{})," ",n("infobar")]}),(0,M.jsx)(Ge,{onClick:e})]}),(0,M.jsx)("div",{className:Le.tw`bg-gray-100 p-4 flex-shrink-0 rt`,children:(0,M.jsx)(ge,{hideLabel:!0})}),(0,M.jsx)("div",{className:Le.tw`flex flex-col flex-grow overflow-auto gap-3 p-4`,children:t.flat(1)?.map(a=>(0,M.jsx)(at,{data:a},o?.[0]?.source.type==="raster"||r===_.ALL?a?.sourceLayer:a?.sourceLayer+a?.properties[R]))})]})}var it=require("react/jsx-runtime");function lt(){let{layer:e,isInfoBarOpen:t,setIsInfoBarOpen:o}=c();if(!e.selectedFeatures?.length)return null;let r=()=>o(!t);return t?(0,it.jsx)(st,{onClose:r}):(0,it.jsx)(Io,{onClick:r})}var Fe=require("react"),ar=require("react-map-gl/maplibre");var nr=require("@biodiv-platform/naksha-commons"),bt=require("twind");var Ko=require("twind");var qe=C(require("react"),1),Zo=require("react-virtual"),Yo=require("react-virtualized-auto-sizer"),pt=require("twind");var Vo=require("@biodiv-platform/naksha-commons"),xe=require("react"),Wo=require("react-web-share"),O=require("twind");var W=require("react/jsx-runtime"),Ro=({text:e="",highlight:t=""})=>{if(!t.trim())return(0,W.jsx)(W.Fragment,{children:e});let o=new RegExp(`(${t})`,"gi"),r=e.split(o);return(0,W.jsx)(W.Fragment,{children:r.filter(n=>n).map((n,a)=>o.test(n)?(0,W.jsx)("mark",{children:n},a):(0,W.jsx)("span",{children:n},a))})};var Go=require("twind");var _o=require("@biodiv-platform/naksha-commons"),Bo=require("react"),Ao=require("twind"),ze=require("react/jsx-runtime");function ve({children:e}){let[t,o]=(0,Bo.useState)(!1),{t:r}=(0,_o.useT)();return(0,ze.jsxs)("div",{children:[t&&e,(0,ze.jsx)("button",{onClick:()=>o(!t),className:Ao.tw`text-blue-600 focus:outline-none focus:outline focus:ring`,children:r(t?"less":"legend")})]})}var A=require("react/jsx-runtime");function ct({item:e}){let{layer:t}=c(),o=t.gridLegends[e.id];return o?(0,A.jsx)(ve,{children:(0,A.jsxs)("ul",{style:{margin:0,padding:0},children:[o?.stops.map(([r,n],a,s)=>{let l=(s[a-1]||[0])[0];return l===r?(0,A.jsx)("div",{},n):(0,A.jsxs)("li",{className:Go.tw`flex gap-2 items-center mb-1`,children:[(0,A.jsx)("svg",{viewBox:"0 0 24 24",height:"14",width:"14",focusable:"false",children:(0,A.jsx)("circle",{cx:"12",fill:n,cy:"12",r:"12",stroke:"none"})}),(0,A.jsxs)("div",{children:[l," - ",r]})]},n)}),(0,A.jsxs)("li",{children:["1 Square = ",o?.squareSize," x ",o?.squareSize," km"]})]})}):null}var He=require("@biodiv-platform/naksha-commons"),Oo=require("react"),Do=require("react-tiny-popover"),re=require("twind");var h=require("react/jsx-runtime"),oe=({icon:e,name:t,title:o,link:r,children:n})=>{let a=(0,h.jsx)("span",{children:n||"-"});return(0,h.jsxs)("div",{className:re.tw`flex gap-3 text-sm text-gray-600 break-all`,title:t&&o&&`${t}: ${o}`,children:[(0,h.jsx)("div",{children:e}),r?(0,h.jsx)("a",{className:re.tw`text-blue-700 focus:outline-none focus:ring`,target:"_blank",rel:"noopener",href:r,children:a}):a]})};function Wr({item:e,containerStyle:t}){let{t:o}=(0,He.useT)(),{layer:r,mp:n}=c(),a=e.license||"CC-BY",s=e?.createdDate&&new Date(e.createdDate).toLocaleDateString(),l=e.tags?.join(", ");return(0,h.jsxs)("div",{className:re.tw`flex flex-col gap-1 bg-white p-4 rounded-lg w-72 border border-gray-300 border-solid`,style:t,children:[n.managePublishing&&e.layerStatus&&(0,h.jsxs)(oe,{icon:(0,h.jsx)(mo,{}),name:o("visiblity"),title:e.layerStatus,children:[e.layerStatus,(0,h.jsx)("button",{className:re.tw`text-blue-600 focus:outline-none ml-4`,onClick:()=>r.togglePublish(e.id,e?.layerStatus),children:o("toggle")}),(0,h.jsx)("button",{className:re.tw`text-red-600 focus:outline-none ml-4`,onClick:()=>r.delete(e.id,o("are_you_sure")),children:o("delete")})]}),(0,h.jsx)(oe,{icon:(0,h.jsx)(rt,{}),link:e.url,name:o("uploader"),title:e.createdBy,children:e.createdBy}),(0,h.jsx)(oe,{icon:(0,h.jsx)(rt,{}),link:e.url,name:o("created_by"),title:e.attribution,children:e.attribution}),(0,h.jsx)(oe,{icon:(0,h.jsx)(fo,{}),name:o("created_on"),title:s,children:s}),(0,h.jsx)(oe,{icon:(0,h.jsx)(po,{}),name:o("tags"),title:l,children:l}),(0,h.jsx)(oe,{name:o("license"),title:a,link:a&&He.LICENSES[a],icon:(0,h.jsx)(uo,{}),children:a})]})}var zo=({item:e})=>{let[t,o]=(0,Oo.useState)(!1),r=()=>o(!t);return(0,h.jsx)(Do.Popover,{isOpen:t,padding:10,positions:["right"],containerStyle:{zIndex:99},onClickOutside:r,content:(0,h.jsx)(Wr,{item:e}),children:(0,h.jsx)(V,{onClick:r,children:(0,h.jsx)(Ae,{}),title:"Information"})})};var Fo=require("twind");var $e=require("react"),Ho=require("@biodiv-platform/naksha-commons"),$o=require("twind");var G=require("react/jsx-runtime");function qo({item:e}){let[t,o]=(0,$e.useState)(!0),{mp:r}=c(),{t:n}=(0,Ho.useT)(),a=(0,$e.useMemo)(()=>e?.data?.styles?.[e.data.styleIndex]?.colors?.paint?.["fill-color"]?.stops||e?.data?.styles?.[e.data.styleIndex]?.colors?.paint?.["circle-color"]?.stops||[],[e]),s=()=>a.map(([l,u])=>(0,G.jsxs)("li",{className:$o.tw`flex gap-2 items-center mb-1`,children:[(0,G.jsx)("svg",{viewBox:"0 0 24 24",height:"14",width:"14",focusable:"false",children:(0,G.jsx)("circle",{cx:"12",fill:u,cy:"12",r:"12",stroke:"none"})}),(0,G.jsx)("div",{children:l})]},u));return(0,G.jsx)("ul",{style:{margin:0,padding:0},children:e.layerType!=="RASTER"?s():t?(0,G.jsx)("li",{children:(0,G.jsx)("img",{style:{margin:"5px"},onError:()=>o(!1),src:`${r?.geoserver?.endpoint}/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&WIDTH=20&HEIGHT=20&STRICT=false&layer=biodiv:${e.id}`})}):(0,G.jsx)("div",{children:n("raster_style_not_found")})})}var K=require("react/jsx-runtime");function dt({item:e}){if(!e.data?.styles)return null;let{layer:t}=c(),o=r=>{t.updateStyle(e.id,Number(r.target.value))};return(0,K.jsxs)("div",{className:Fo.tw`flex flex-col gap-4 pt-2`,children:[e.layerType!=="RASTER"&&(0,K.jsx)(ee,{onChange:o,children:e.data?.styles.map((r,n)=>(0,K.jsx)("option",{value:n,children:r.styleTitle},n))}),(0,K.jsx)(ve,{children:(0,K.jsx)(qo,{item:e})})]})}var y=require("react/jsx-runtime");function Zr({dragHandleProps:e}){return(0,y.jsx)("div",{className:O.tw`mt-1 w-6 text-center cursor-move`,style:{touchAction:"none"},...e,children:(0,y.jsx)(bo,{})})}function Se({item:e,extended:t,dragHandleProps:o}){let{t:r}=(0,Vo.useT)(),{layer:n,query:a,mp:s,query:{setClickedLngLat:l},setIsInfoBarOpen:u}=c(),[d,b]=(0,xe.useState)(n.selectedIds.includes(e.id)),[L,P]=(0,xe.useState)(!1),k=(0,xe.useMemo)(()=>s.canLayerShare?{url:`${window.location.href.split("?")[0]}?layers=${e.id}`,title:e.title}:void 0,[e.id]),z=async()=>{P(!0),u(!0),n.setSelectedFeatures([]),l(null),await n.toggle({layerId:e.id,add:!d}),b(!d),P(!1)},q=async()=>{await oo(s.nakshaApiEndpoint,s.nakshaEndpointToken,e.id,e.title),s?.onLayerDownload(e.id)},Y=()=>n.zoomToExtent(e.id);return(0,y.jsxs)("div",{className:O.tw`z-20 p-3 bg-white`,style:{borderTop:"1px solid #e5e7eb"},children:[(0,y.jsxs)("div",{className:O.tw`flex gap-3`,children:[(0,y.jsxs)("div",{className:O.tw`flex-shrink-0`,children:[(0,y.jsx)(Co,{name:e.id,checked:d,onChange:z,isLoading:L}),t&&(0,y.jsx)(Zr,{dragHandleProps:o})]}),(0,y.jsx)("img",{className:O.tw`flex-shrink-0 overflow-hidden h-16 w-16 p-1 mb-2 object-cover border border-gray-200 rounded`,src:e.thumbnail||$t}),(0,y.jsxs)("div",{children:[(0,y.jsx)("div",{title:e.title,className:O.tw`mb-1 leading-tight`,style:Qe,children:(0,y.jsx)(Ro,{text:e.title,highlight:a.term})}),(0,y.jsx)("p",{title:e.description,className:O.tw`text-gray-600 text-sm`,style:qt,children:e.description})]})]}),(0,y.jsxs)("div",{className:O.tw`flex justify-between`,children:[(0,y.jsxs)(V,{onClick:q,disabled:!e.isDownloadable,children:[(0,y.jsx)(yo,{})," ",r("download")]}),(0,y.jsxs)("div",{className:O.tw`flex gap-3`,children:[k&&(0,y.jsx)(Wo.RWebShare,{data:k,children:(0,y.jsx)(V,{title:"Share",children:(0,y.jsx)(ho,{})})}),t&&(0,y.jsx)(V,{onClick:Y,title:"Zoom To Extent",children:(0,y.jsx)(go,{})}),(0,y.jsx)(zo,{item:e})]})]}),t&&(0,y.jsx)(dt,{item:e}),t&&e.source.type==="grid"&&(0,y.jsx)(ct,{item:e})]})}var Z=require("react/jsx-runtime");function Uo(){let{layer:e,query:t}=c(),o=(0,qe.useMemo)(()=>t.term?e.all.filter(a=>a.title.toLowerCase().includes(t.term.toLowerCase())):e.all,[e.all,t.term]),r=qe.default.useRef(),n=(0,Zo.useVirtual)({size:o.length,parentRef:r});return(0,Z.jsx)("div",{className:pt.tw`flex-grow-1 relative`,children:(0,Z.jsx)(Yo.AutoSizer,{disableWidth:!0,children:a=>(0,Z.jsx)("div",{ref:r,className:"List",style:{height:a.height,overflow:"auto"},children:(0,Z.jsx)("div",{style:{height:n.totalSize,width:"100%",position:"relative"},children:n.virtualItems.map(s=>(0,Z.jsx)("div",{ref:s.measureRef,className:pt.tw`absolute top-0 left-0 w-full`,style:{transform:`translateY(${s.start}px)`},children:(0,Z.jsx)("div",{style:{height:146},children:(0,Z.jsx)(Se,{item:o[s.index]})})},s.index))})})})})}var jo=require("@biodiv-platform/naksha-commons"),Jo=require("twind");var ut=require("react/jsx-runtime");function mt(){let{t:e}=(0,jo.useT)(),{query:t}=c(),o=r=>t.setTerm(r.target.value);return(0,ut.jsx)("div",{className:Jo.tw`flex-shrink-0 border-b-2 p-4`,children:(0,ut.jsx)(ko,{name:"lyr_search",placeholder:e("find_layer_by_name"),onChange:o})})}var we=require("react/jsx-runtime");function ft(){return(0,we.jsxs)("div",{className:Ko.tw`flex flex-col w-full`,children:[(0,we.jsx)(mt,{}),(0,we.jsx)(Uo,{})]})}function Yr(e,t,o){let r=t<0?e.length+t:t;if(r>=0&&r<e.length){let n=o<0?e.length+o:o,[a]=e.splice(t,1);e.splice(n,0,a)}}function Xo(e,t,o){return e=[...e],Yr(e,t,o),e}var D=require("@dnd-kit/core"),ne=require("@dnd-kit/sortable"),Qo=require("@dnd-kit/utilities");var X=require("react/jsx-runtime");function Ur({item:e,extended:t}){let{attributes:o,listeners:r,setNodeRef:n,transform:a,transition:s,isDragging:l}=(0,ne.useSortable)({id:e.id}),u={transform:Qo.CSS.Transform.toString(a),transition:s,opacity:l?.5:1};return(0,X.jsx)("div",{ref:n,style:u,children:(0,X.jsx)(Se,{item:e,extended:t,dragHandleProps:{...o,...r}})})}var er=({layerList:e,onSortEnd:t})=>{let o=(0,D.useSensors)((0,D.useSensor)(D.PointerSensor,{activationConstraint:{distance:4}}));return(0,X.jsx)(D.DndContext,{sensors:o,collisionDetection:D.closestCenter,onDragEnd:n=>{let{active:a,over:s}=n;if(s&&a.id!==s.id){let l=e.findIndex(d=>d.id===a.id),u=e.findIndex(d=>d.id===s.id);l!==-1&&u!==-1&&t({oldIndex:l,newIndex:u})}},children:(0,X.jsx)(ne.SortableContext,{items:e.map(n=>n.id),strategy:ne.verticalListSortingStrategy,children:(0,X.jsx)("div",{children:e.map(n=>(0,X.jsx)(Ur,{item:n,extended:!0},n.id))})})})};var tr=require("@biodiv-platform/naksha-commons"),yt=require("twind"),ae=require("react/jsx-runtime");function gt(){let{layer:e}=c(),{t}=(0,tr.useT)(),o=({oldIndex:r,newIndex:n})=>{e.setSelectedIds(Xo(e.selectedIds,r,n))};return(0,ae.jsxs)("div",{className:yt.tw`flex flex-col gap-3 w-full`,children:[e.selectedIds.length>0&&(0,ae.jsx)("div",{className:yt.tw`p-3 pb-0`,children:(0,ae.jsxs)(V,{onClick:()=>e.clearAll(),children:["\u2715 ",t("clear")]})}),(0,ae.jsx)(er,{layerList:e.selectedLayers,useDragHandle:!0,onSortEnd:o})]})}var or=require("@biodiv-platform/naksha-commons"),rr=require("twind");var se=require("react/jsx-runtime");function ht(){let{layer:e}=c(),{t}=(0,or.useT)(),o=r=>{e.setMapStyle(r.target.value),e.setMaxZoom(e.mapStyles.find(n=>n.style===r.target.value)?.maxZoom)};return(0,se.jsxs)("div",{className:rr.tw`w-full p-4 flex flex-col gap-4`,children:[(0,se.jsx)(ee,{name:"base_style",label:t("base_style"),defaultValue:e.mapStyle,onChange:o,children:e.mapStyles.map(r=>(0,se.jsx)("option",{value:r.style,children:r.text},r.key))}),(0,se.jsx)(ge,{})]})}var v=require("react/jsx-runtime");function Lt({onClose:e}){let{t}=(0,nr.useT)();return(0,v.jsxs)("div",{className:bt.tw`absolute top-0 right-0 bottom-0 left-0 md:right-auto md:top-4 md:left-4 md:bottom-4 bg-white rounded-lg shadow-md md:max-w-sm w-full z-20 overflow-hidden`,children:[(0,v.jsx)(Ge,{onClick:e}),(0,v.jsx)("div",{className:bt.tw`flex flex-col h-full`,children:(0,v.jsxs)(J.Tabs,{children:[(0,v.jsxs)(To,{children:[(0,v.jsx)(Oe,{icon:(0,v.jsx)(me,{}),children:t("layers")}),(0,v.jsx)(Oe,{icon:(0,v.jsx)(me,{}),children:t("selected")}),(0,v.jsx)(Oe,{icon:(0,v.jsx)(co,{}),children:t("settings")})]}),(0,v.jsx)(De,{children:(0,v.jsx)(ft,{})}),(0,v.jsx)(De,{children:(0,v.jsx)(gt,{})}),(0,v.jsx)(De,{children:(0,v.jsx)(ht,{})})]})})]})}var vt=require("react/jsx-runtime");function xt(){let{mp:e,layer:t}=c(),[o,r]=(0,Fe.useState)(e.showToC),{mapl:n}=(0,ar.useMap)(),a=()=>r(!o);async function s(){let l=await Kt(e.nakshaEndpointToken,e.nakshaApiEndpoint,e.geoserver,e.selectedLayers),u=[...e.layers||[],...l];if(t.setAll(u),t.selectedIds.length){let d=u.find(b=>b.id===t.selectedIds[0]);d?.bbox&&n?.fitBounds(d.bbox,{padding:40,duration:1e3})}}return(0,Fe.useEffect)(()=>{n&&e.loadToC&&s()},[n]),o?(0,vt.jsx)(Lt,{onClose:a}):(0,vt.jsx)(wo,{onClick:a})}var lr=require("react-map-gl/maplibre");var sr=C(require("@turf/bbox"),1),ie=require("react"),le=require("react-map-gl/maplibre");var St=require("react/jsx-runtime");function wt({data:e,beforeId:t}){let{layer:o}=c(),{mapl:r}=(0,le.useMap)(),[n,a]=(0,ie.useState)({geojson:{},paint:{}}),s=o.selectedIds.includes(e.id),l=o.selectedIds[0]===e.id,u=async(d=!1)=>{let{success:b,geojson:L,paint:P,stops:k,squareSize:z}=await to(e.source.fetcher,r?.getBounds(),r?.getZoom());if(b){if(a({geojson:L,paint:P}),d&&l&&e.zoomToFit)try{let[q,Y,ue,Ye]=(0,sr.default)(L);r?.fitBounds([[q,Y],[ue,Ye]],{padding:40,animate:!0})}catch(q){console.warn("Failed to compute bbox",q)}o.setGridLegends({[e.id]:{stops:k,squareSize:z}})}};return(0,ie.useEffect)(()=>{s&&l?u(!0):s&&u(!1)},[s,l]),(0,ie.useEffect)(()=>{if(!s||!r)return;let d=()=>u(!1);return r.on("idle",d),()=>{r.off("idle",d)}},[s,r]),(0,ie.useEffect)(()=>()=>{o.setGridLegends(d=>{let b={...d};return delete b[e.id],b})},[e.id]),(0,St.jsx)(le.Source,{id:e.id,type:"geojson",data:n.geojson,children:(0,St.jsx)(le.Layer,{beforeId:t,id:e.id,type:"fill",paint:n.paint})})}var ir=require("react"),Ie=require("react-map-gl/maplibre");var ke=require("react/jsx-runtime"),jr={fill:{"line-color":"red","line-width":2},circle:{"circle-stroke-color":"red","circle-stroke-width":2,"circle-opacity":0}};function Ve({layer:e,beforeId:t}){let{layer:o}=c(),r=(0,ir.useMemo)(()=>e.data?.styles?.[e.data?.styleIndex]?.colors,[e,o.selectedFeatures]),n=o.selectedFeaturesId?.[e.id];return(0,ke.jsxs)(Ie.Source,{...e.source,children:[r&&(0,ke.jsx)(Ie.Layer,{beforeId:t,...r}),n&&r&&(0,ke.jsx)(Ie.Layer,{...r,beforeId:t,id:`hl_${e.id}`,filter:["in",R,...n],type:r.type==="fill"?"line":r.type,paint:jr[r.type]})]})}var We=require("react-map-gl/maplibre");var It=require("react/jsx-runtime");function kt({data:e,beforeId:t}){let{mp:o}=c();return(0,It.jsx)(We.Source,{id:e.id,type:"raster",tiles:[`${o?.geoserver?.endpoint}/wms?bbox={bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:3857&width=256&height=256&transparent=true&layers=biodiv:${e.id}`],tileSize:256,children:(0,It.jsx)(We.Layer,{id:e.id,beforeId:t,type:"raster",source:"biodiv",layout:{visibility:"visible"},paint:{}})})}var Ce=require("react/jsx-runtime");function cr({layer:e,beforeId:t}){let{mapl:o}=(0,lr.useMap)();if(!o)return null;switch(e.source.type){case"vector":return(0,Ce.jsx)(Ve,{beforeId:t,layer:e});case"grid":return(0,Ce.jsx)(wt,{beforeId:t,data:e});case"raster":return(0,Ce.jsx)(kt,{beforeId:t,data:e});default:return(0,Ce.jsx)(Ve,{beforeId:t,layer:e})}}var dr=require("react"),pr=require("react-map-gl/maplibre");var ce=require("react/jsx-runtime"),Jr=pr.Marker,Kr=()=>{let{mp:e}=c(),t=(0,dr.useMemo)(()=>e.markers,[e.markers]);return(0,ce.jsx)(ce.Fragment,{children:t?.map(({latitude:o,longitude:r,colorHex:n},a)=>(0,ce.jsx)(Jr,{latitude:o,longitude:r,children:(0,ce.jsx)("img",{style:{cursor:"pointer"},alt:"Marker",src:"https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon.png"})},a))})},ur=Kr;var mr=C(require("clsx"),1),fr=require("react-map-gl/maplibre"),de=require("twind");var N=require("react/jsx-runtime"),Xr=fr.Popup;function Ct({coordinates:e}){let{hover:t}=c();return e?.lat&&t.features?(0,N.jsx)(Xr,{latitude:e.lat,longitude:e.lng,closeButton:!1,children:(0,N.jsxs)("table",{className:de.tw`table-auto border`,children:[(0,N.jsx)("thead",{children:(0,N.jsx)("tr",{children:(0,N.jsx)("th",{className:de.tw`bg-gray-200 py-1 px-2`,colSpan:2,children:t.features.title})})}),(0,N.jsx)("tbody",{children:t.features.data.map(([o,r],n)=>(0,N.jsxs)("tr",{className:(0,de.tw)((0,mr.default)({"bg-gray-50":n%2===0,"border-gray-100 border-t":1})),children:[(0,N.jsx)("td",{className:de.tw`py-1 px-2`,children:o}),(0,N.jsx)("td",{className:de.tw`py-1 px-2 border-l border-gray-100`,children:r})]},o+r))})]})}):null}var E=require("react/jsx-runtime"),Qr=pe.NavigationControl;function Pt(){let{mp:e,layer:t,hover:o,query:r}=c(),[n,a]=(0,Ze.useState)(),s=(0,Ze.useMemo)(()=>e.defaultViewState||yr.defaultViewState,[e.defaultViewState]),l=d=>r.setClickedLngLat(d.lngLat),u=d=>{a(d.lngLat),o.onHover(d)};return(0,E.jsxs)("div",{className:gr.tw`h-full w-full relative bg-gray-100`,children:[e.loadToC&&(0,E.jsx)(xt,{}),t.selectedFeatures?.length>0&&(0,E.jsx)(lt,{}),(0,E.jsxs)(pe.default,{id:"mapl",cursor:"default",initialViewState:s,style:{width:"100%",height:"100%"},mapStyle:t.mapStyle,maxZoom:t.maxZoom,onClick:l,onMouseMove:u,children:[(0,E.jsx)(Qr,{position:"bottom-right",showZoom:!0,showCompass:!0}),e.showFullscreenControl&&(0,E.jsx)(pe.FullscreenControl,{position:"bottom-right"}),(0,E.jsx)(ur,{}),t.selectedLayers.map((d,b)=>{let L=b>0?t.selectedIds[b-1]:void 0;return(0,E.jsx)(cr,{layer:d,beforeId:L},d.id)}),(0,E.jsx)(Ct,{coordinates:n},"popup")]})]})}var Pe=require("react/jsx-runtime");(0,vr.setup)({preflight:!1});var en=e=>{let t=br.default.useMemo(()=>({...Ht,...e}),[e]);return(0,Pe.jsx)(Lr.MapProvider,{children:(0,Pe.jsx)(hr.TranslationProvider,{localeStrings:zt,lang:t.lang,children:(0,Pe.jsx)(ao,{mp:t,children:(0,Pe.jsx)(Pt,{})})})})};0&&(module.exports={NakshaMaplibreLayers});
1
+ "use strict";var Vo=Object.create;var Ze=Object.defineProperty;var Uo=Object.getOwnPropertyDescriptor;var Zo=Object.getOwnPropertyNames;var Yo=Object.getPrototypeOf,Ko=Object.prototype.hasOwnProperty;var jo=(e,r)=>{for(var t in r)Ze(e,t,{get:r[t],enumerable:!0})},tr=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of Zo(r))!Ko.call(e,o)&&o!==t&&Ze(e,o,{get:()=>r[o],enumerable:!(n=Uo(r,o))||n.enumerable});return e};var T=(e,r,t)=>(t=e!=null?Vo(Yo(e)):{},tr(r||!e||!e.__esModule?Ze(t,"default",{value:e,enumerable:!0}):t,e)),Jo=e=>tr(Ze({},"__esModule",{value:!0}),e);var yn={};jo(yn,{NakshaMaplibreLayers:()=>fn});module.exports=Jo(yn);var Ho=require("@biodiv-platform/naksha-commons"),Fo=T(require("react"),1),$o=require("react-map-gl/maplibre"),Wo=require("twind");var rr={are_you_sure:"Are you sure?",base_style:"Base Style",clear:"Clear Selection",created_by:"Attribution",created_on:"Created On",delete:"Delete",download:"Download",find_layer_by_name:"Find layer by name",infobar:"Attributes at Clicked Location",information:"Information",layer_selection:"Layer Selection",layer_selection_all:"All Layers",layer_selection_top:"Top Layer Only",layers:"Layers",legend:"Legend",less:"Less",license:"License",list_layers:"List Layers",pending:"Pending",publish:"Publish",published:"Published",raster_style_not_found:"Style not available for the given layer",remove:"Remove",selected:"Selected",settings:"Settings",square:"Square",tags:"Tags",toggle:"Toggle Publishing",uploaded:"Uploaded",uploader:"Uploader",url:"URL",visiblity:"Visiblity"};var or={are_you_sure:"\xCAtes-vous s\xFBr?",base_style:"Style de base",clear:"Effacer la s\xE9lection",created_by:"Attribution",created_on:"Cr\xE9\xE9 sur",delete:"Effacer",download:"T\xE9l\xE9charger",find_layer_by_name:"Trouver la couche par nom",infobar:"Attributs \xE0 l'emplacement cliqu\xE9",information:"Informations",layer_selection_all:"Toutes les couches",layer_selection_top:"Couche sup\xE9rieure uniquement",layer_selection:"S\xE9lection de calque",layers:"Couches",legend:"L\xE9gende",less:"Moins",license:"Licence",list_layers:"Liste des couches",pending:"En attente",publish:"Publier",published:"Publi\xE9",remove:"Supprimer",selected:"Choisie",settings:"Param\xE8tres",square:"Carr\xE9",toggle:"Basculer la publication",uploaded:"T\xE9l\xE9charg\xE9",url:"url"};var nr={are_you_sure:"\u0915\u094D\u092F\u093E \u0906\u092A\u0915\u094B \u092F\u0915\u0940\u0928 \u0939\u0948?",base_style:"\u0906\u0927\u093E\u0930 \u0936\u0948\u0932\u0940",clear:"\u091A\u092F\u0928 \u0938\u093E\u092B\u093C \u0915\u0930\u0947\u0902",created_by:"\u0906\u0930\u094B\u092A\u0923",created_on:"\u092A\u0930 \u092C\u0928\u093E\u092F\u093E",delete:"\u0939\u091F\u093E\u090F\u0902",download:"\u0921\u093E\u0909\u0928\u0932\u094B\u0921",find_layer_by_name:"\u0928\u093E\u092E \u0938\u0947 \u092A\u0930\u0924 \u0916\u094B\u091C\u0947\u0902",infobar:"\u0915\u094D\u0932\u093F\u0915 \u0915\u093F\u090F \u0917\u090F \u0938\u094D\u0925\u093E\u0928 \u092A\u0930 \u0935\u093F\u0936\u0947\u0937\u0924\u093E\u090F\u0902",information:"\u091C\u093E\u0928\u0915\u093E\u0930\u0940",layer_selection_all:"\u0938\u092D\u0940 \u092A\u0930\u0924\u0947\u0902",layer_selection_top:"\u0915\u0947\u0935\u0932 \u0936\u0940\u0930\u094D\u0937 \u092A\u0930\u0924",layer_selection:"\u092A\u0930\u0924 \u091A\u092F\u0928",layers:"\u092A\u0930\u0924\u0947\u0902",legend:"\u0915\u093F\u0902\u0935\u0926\u0902\u0924\u0940",less:"\u0915\u092E",license:"\u0932\u093E\u0907\u0938\u0947\u0902\u0938",list_layers:"\u0938\u0942\u091A\u0940 \u092A\u0930\u0924\u0947\u0902",pending:"\u0932\u0902\u092C\u093F\u0924",publish:"\u092A\u094D\u0930\u0915\u093E\u0936\u093F\u0924",published:"\u092A\u094D\u0930\u0915\u093E\u0936\u093F\u0924",remove:"\u0939\u091F\u093E\u0928\u093E",selected:"\u091A\u092F\u0928\u093F\u0924",settings:"\u0938\u092E\u093E\u092F\u094B\u091C\u0928",square:"\u0938\u094D\u0915\u094D\u0935\u093E\u092F\u0930",tags:"\u091F\u0948\u0917",toggle:"\u092A\u094D\u0930\u0915\u093E\u0936\u0928 \u091F\u0949\u0917\u0932 \u0915\u0930\u0947\u0902",uploaded:"\u0905\u092A\u0932\u094B\u0921 \u0915\u093F\u092F\u093E \u0917\u092F\u093E",url:"\u092F\u0942\u0906\u0930\u090F\u0932"};var ar={en:rr,fr:or,hi:nr};var Go=require("@biodiv-platform/naksha-commons"),_=T(require("react"),1),xe=T(require("react-map-gl/maplibre"),1),Do=require("maplibre-gl"),zo=require("twind");var Je=require("@biodiv-platform/naksha-commons"),c=T(require("react"),1),xr=require("react-map-gl/maplibre");var fr=T(require("colorbrewer"),1),Y=T(require("redaxios"),1);var mt=T(require("boundingbox"),1),Ke=require("geohash");var Ye=require("@biodiv-platform/naksha-commons"),sr={defaultViewState:Ye.defaultViewState,nakshaApiEndpoint:"/naksha-api/api",geoserver:{endpoint:"/geoserver",workspace:"biodiv",store:"ibp"},mapStyle:Ye.MapStyles.MAP_STREETS,layers:[],selectedLayers:[]},ir="data:image/svg+xml,%3Csvg fill='none' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 72 72'%3E%3Cpath fill='%23fff' d='M0 0h72v72H0z'/%3E%3Cpath d='M35.981 48.293l-13.853-10.77-3.045 2.368L36 53.048l16.917-13.157-3.064-2.387-13.872 10.789zM36 43.519l13.834-10.77 3.083-2.388L36 17.204 19.083 30.36l3.064 2.387L36 43.518z' fill='%23A0AEC0'/%3E%3C/svg%3E",pt={display:"-webkit-box",WebkitLineClamp:1,WebkitBoxOrient:"vertical",overflow:"hidden",wordBreak:"break-word"},lr={...pt,WebkitLineClamp:2},O="ogc_fid",pe={ACTIVE:"Active",PENDING:"Pending"},G={TOP:"layer_selection_top",ALL:"layer_selection_all"};var je=e=>e<6?[4,1,39.2]:e<7?[5,0,19.6]:e<8?[5,1,9.8]:e<9?[5,-1,4.9]:e<10?[6,0,2.45]:e<11?[6,1,1.225]:e<12?[7,0,.612]:e<13?[7,1,.306]:e<14?[7,-1,.153]:e<15?[8,0,.077]:[8,1,.039],ut="0123456789bcdefghjkmnpqrstuvwxyz",tn=(e,r,t)=>{t=t||16/2**(1-e.length&1)/4**r;let n=e.slice(0,-1),o=~~(ut.indexOf(e.slice(-1))/t);return[n+ut[t*o],n+ut[t*(o+1)-1]]},rn=function(e,r){var t=new Map,n=new Map;let o=[];for(let[a,s]of Object.entries(e)){let[l,d]=tn(a,r);n.set(l,d),t.has(l)||t.set(l,0),t.set(l,t.get(l)+s)}return t.forEach((a,s)=>{let l=Ke.GeoHash.decodeGeoHash(s),d=Ke.GeoHash.decodeGeoHash(n.get(s)),m=new mt.default({minlat:l.latitude[0],minlon:l.longitude[0],maxlat:d.latitude[1],maxlon:d.longitude[1]}).toGeoJSON();o.push({...m,properties:{count:a,[O]:s}})}),o},on=e=>{let r=[];for(let[t,n]of Object.entries(e)){let o=Ke.GeoHash.decodeGeoHash(t),a=new mt.default({minlat:o.latitude[0],minlon:o.longitude[0],maxlat:o.latitude[1],maxlon:o.longitude[1]}).toGeoJSON();r.push({...a,properties:{count:n,[O]:t}})}return r},cr=(e,r)=>({type:"FeatureCollection",features:Object.keys(e).length===0?[]:r===-1?on(e):rn(e,r)}),dr=(e,r)=>{let t=Object.values(e).sort((a,s)=>a-s),n=Math.floor(t.length/r),o=new Array(r-1).fill(0).map((a,s)=>t[n*(s+1)]);return o.push(t[t.length-1]),o};var pr=async(e,r,t,n)=>Promise.all((e||[]).map(async o=>{let a=n?.includes(o.name),s=o.layerType?.toLowerCase()==="raster",l={...o,id:o.name,thumbnail:r+o.thumbnail,source:{type:s?"raster":"vector",scheme:"tms",tiles:[`${t.endpoint}/gwc/service/tms/1.0.0/${t.workspace}:${o.name}@EPSG%3A900913@pbf/{z}/{x}/{y}.pbf`]},data:{styles:[]},isAdded:a};if(a&&!s){let d=await ft(l,0,r,t);return{...l,data:d}}return l})),ft=async(e,r,t,n)=>{let o=e.data||{styles:[]},a=o.layerName,s=o.styles?[...o.styles]:[],l=o.summaryColumn,d=o.titleColumn,m=o.propertyMap;if(s.length===0){let{success:f,data:y}=await ur(e.id,t);f&&y&&(a=y.layerName,s=(y.styles||[]).map(w=>({...w})),l=y.summaryColumn,d=y.titleColumn,m=Object.fromEntries((y.styles||[]).map(w=>[w.styleName,w.styleTitle])))}if(s[r]&&!s[r]?.colors){let f=await mr(e.id,n?.workspace,s[r].styleName,t);s[r]={...s[r],colors:f}}return{...o,layerName:a,styles:s,summaryColumn:l,titleColumn:d,propertyMap:m,styleIndex:r}};var yr=async(e,r,t,n)=>{try{let o=await Y.default.get(`${r}/layer/all`,{headers:{Authorization:e}});return await pr(o.data,r,t,n)}catch(o){return console.error(o),[]}},ur=async(e,r)=>{try{let{data:t}=await Y.default.get(`${r}/layer/onClick/${e}`);return{success:!0,data:t}}catch(t){return console.error(t),{success:!1}}},gr=async(e,r,t)=>{let n={service:"WMS",version:"1.1.1",request:"GetFeatureInfo",info_format:"application/json",width:100,height:100,x:50,y:50,srs:"EPSG:4326"};try{return{success:!0,data:(await Y.default.get(`${e}/${r}/wms`,{params:{...t,...n}})).data}}catch(o){return console.error(o),{success:!1,data:[]}}},hr=async(e,r,t,n)=>{try{return await Y.default.put(`${r}/layer/${n?"active":"pending"}/${t}`,{},{headers:{Authorization:e}}),!0}catch(o){return console.error(o),!1}},br=async(e,r,t)=>{try{return await Y.default.delete(`${r}/layer/${t}`,{headers:{Authorization:e}}),!0}catch(n){return console.error(n),!1}},mr=async(e,r,t,n)=>{try{return(await Y.default.get(`${n}/geoserver/workspaces/${r}/styles/${e}_${t}.mbstyle`)).data?.layers?.[0]}catch(o){return console.error(o),{}}},Lr=async(e,r,t,n=6,o="YlOrRd")=>{try{let[a,s,l]=je(t),{_ne:d,_sw:m}=r,f={top:d.lat,left:m.lng,bottom:m.lat,right:d.lng,geoAggegationPrecision:a},y=await e(f),w=cr(y,s),A=dr(y,n).map((U,ie)=>[U,fr.default[o][n][ie]]);return{success:!0,geojson:w,paint:{"fill-color":{property:"count",default:"yellow",stops:A},"fill-outline-color":"rgba(0,0,0,0.2)","fill-opacity":.7},stops:A,squareSize:l}}catch(a){return console.error(a),{success:!1,geojson:{},paint:{},stops:[],squareSize:0}}},vr=async(e,r,t,n)=>{try{await Y.default.post(`${e}/layer/download`,{layerName:t,layerTitle:n,attributeList:[],filterArray:[]},{headers:{Authorization:r}})}catch(o){console.error(o)}};var kr=require("react/jsx-runtime"),wr=(0,c.createContext)({}),Sr=({mp:e,children:r})=>{let[t,n]=(0,c.useState)(e),{mapl:o}=(0,xr.useMap)();(0,c.useEffect)(()=>{n(p=>({...p,...e}))},[e]);let[a,s]=(0,c.useState)(""),l=(0,Je.useDebounce)(a,500),d=t.mapStyles&&t.mapStyles.length>0?t.mapStyles:Je.defaultMapStyles,[m,f]=(0,c.useState)(d[t?.mapStyle||0]?.style),[y,w]=(0,c.useState)(d[t?.mapStyle||0]?.maxZoom),[I,A]=(0,c.useState)(G.TOP),[V,U]=(0,c.useState)({}),[ie,Fe]=(0,c.useState)(!0),[C,ct]=(0,c.useState)(),[k,B]=(0,c.useState)(e.layers||[]),[x,Z]=(0,c.useState)(t.selectedLayers||[]);(0,c.useEffect)(()=>{t.selectedLayers&&t.selectedLayers.join(",")!==x.join(",")&&Z(t.selectedLayers)},[t.selectedLayers]);let[le,$e]=(0,c.useState)(),[We,Ht]=(0,c.useState)(),Ft=(0,c.useMemo)(()=>{let p={};for(let g of We||[])p[g.sourceLayer]=[...p[g.sourceLayer]||[],g?.properties?.[O]];return Object.keys(p).length?p:void 0},[We]),we=c.default.useMemo(()=>{let p=k.filter(h=>x.includes(h.id)),g=new Array(x.length);for(let h of p){let v=x.findIndex(P=>h.id===P);v>-1&&(g[v]=h)}return g},[k,x]),ce=(0,c.useCallback)(p=>k.findIndex(g=>g.id===p),[k]),qe=(0,c.useCallback)((p,g)=>{B(h=>h.map(v=>v.id===p?{...v,...g}:v))},[]),Ve=(0,c.useCallback)(async(p,g,h)=>{let v=k[p];if(!v)return;let P=await ft(v,g,t.nakshaApiEndpoint,t.geoserver);qe(v.id,{data:P}),h&&o?.fitBounds(v.bbox,{padding:40,duration:1e3})},[k,t.nakshaApiEndpoint,t.geoserver,qe,o]),$t=(0,c.useCallback)(async(p,g)=>{let h=ce(p);Ve(h,g,!1)},[ce,Ve]),Wt=(0,c.useCallback)(async p=>{if(!(!x.length||!o))try{let g=x[0],h=o.queryRenderedFeatures(p.point,{layers:[g]});if(h.length){let v=h[0]?.id||h[0]?.properties?.[O];if(v===le?.id)return;let P=k[ce(g)];if(!P)return;let Se=P?.data?.summaryColumn?.map(Ue=>[P.data?.propertyMap?.[Ue]||Ue,h[0].properties?.[Ue]]);$e({id:v,title:P.title,data:Se||[],coordinates:p.lngLat})}else $e(v=>v!==void 0?void 0:v)}catch{}},[x,o,le?.id,k,ce]),qt=(0,c.useCallback)(async({layerId:p,add:g,styleIndex:h=0,focus:v=!0})=>{if(!g){Z(ke=>ke.filter(Ie=>p!==Ie));return}let P=ce(p),Se=k[P];Se?.source.type==="grid"?(Z(ke=>[p,...ke.filter(Ie=>Ie!==p)]),v&&Se?.bbox&&setTimeout(()=>{o?.fitBounds(Se.bbox,{padding:40,duration:1e3})},100)):(await Ve(P,h,v),Z(ke=>[p,...ke.filter(Ie=>Ie!==p)]))},[ce,k,o,Ve]),Vt=(0,c.useCallback)(async()=>Z([]),[]),Ut=(0,c.useCallback)((p,g)=>{n(h=>({...h,[p]:g}))},[]),Zt=(0,c.useCallback)((p,g)=>{let h=g===pe.PENDING;hr(t.nakshaEndpointToken,t.nakshaApiEndpoint,p,h),qe(p,{layerStatus:h?pe.ACTIVE:pe.PENDING})},[t.nakshaEndpointToken,t.nakshaApiEndpoint,qe]),Yt=(0,c.useCallback)(async(p,g)=>{confirm(g)&&(br(t.nakshaEndpointToken,t.nakshaApiEndpoint,p),B(h=>h.filter(v=>v.id!==p)))},[t.nakshaEndpointToken,t.nakshaApiEndpoint]),Kt=(0,c.useCallback)(p=>{let g=k.find(h=>h.id===p);g?.bbox&&o?.fitBounds(g.bbox,{padding:40,duration:1e3})},[k,o]),dt=(0,c.useCallback)(()=>C?[C.lng,C.lat,C.lng+.1,C.lat+.1]:[0,0,0,0],[C]),de=(0,c.useCallback)(p=>{if(!(!C||!o))try{let g=o.project([C.lng,C.lat]),h=o.queryRenderedFeatures(g,{layers:I===G.TOP?[x[0]]:x});if((p||I)===G.ALL){let v=we.filter(P=>P.layerType=="RASTER").map(P=>({sourceLayer:P.id,layerType:"raster",bbox:dt()}));h=[...h,...v]}Ht(we?.[0]?.layerType==="RASTER"&&I!==G.ALL?x.length&&h?.length?h:[{sourceLayer:x[0],layerType:"raster",bbox:dt()}]:h)}catch(g){console.error(g)}},[C,o,I,x,we,dt]),jt=(0,c.useCallback)(p=>{A(p),p===G.TOP&&de(p)},[de]),Jt=(0,c.useRef)(!0);(0,c.useEffect)(()=>{if(Jt.current){Jt.current=!1;return}t.onSelectedLayersChange&&t.onSelectedLayersChange(x)},[x]),(0,c.useEffect)(()=>{let p=setTimeout(de,300);return()=>clearTimeout(p)},[C,I,x,de]);let Xt=(0,c.useMemo)(()=>({mapStyle:m,featuresAtLatLng:de,setMapStyle:f,maxZoom:y,setMaxZoom:w,mapStyles:d,all:k,setAll:B,selectedIds:x,handleSelectStyle:jt,setSelectedIds:Z,selectedLayers:we,clearAll:Vt,toggle:qt,updateStyle:$t,selectedFeatures:We,selectedFeaturesId:Ft,setSelectedFeatures:Ht,togglePublish:Zt,delete:Yt,selectionStyle:I,setSelectionStyle:A,zoomToExtent:Kt,gridLegends:V,setGridLegends:U}),[m,de,y,d,k,x,jt,we,Vt,qt,$t,We,Ft,Zt,Yt,I,Kt,V]),Qt=(0,c.useMemo)(()=>({term:l,setTerm:s,clickedLngLat:C,setClickedLngLat:ct}),[l,C]),er=(0,c.useMemo)(()=>({onHover:Wt,features:le}),[Wt,le]),qo=(0,c.useMemo)(()=>({mp:t,updateMP:Ut,layer:Xt,query:Qt,isInfoBarOpen:ie,setIsInfoBarOpen:Fe,hover:er}),[t,Ut,Xt,Qt,ie,er]);return(0,kr.jsx)(wr.Provider,{value:qo,children:r})};function u(){return(0,c.useContext)(wr)}var Hr=T(require("react"),1),Pe=require("twind");var Ir=require("twind"),i=require("react/jsx-runtime"),Cr=()=>(0,i.jsx)("svg",{fill:"none",className:Ir.tw`w-5 h-5 text-gray-400`,width:"24",height:"24",viewBox:"0 0 24 24",children:(0,i.jsx)("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),Ce=()=>(0,i.jsxs)("svg",{width:"18",height:"18",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",children:[(0,i.jsx)("path",{d:"M12 2L2 7 12 12 22 7 12 2z"}),(0,i.jsx)("path",{d:"M2 17L12 22 22 17"}),(0,i.jsx)("path",{d:"M2 12L12 17 22 12"})]}),Xe=()=>(0,i.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,i.jsx)("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),(0,i.jsx)("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),Pr=()=>(0,i.jsxs)("svg",{width:"18",height:"18",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",children:[(0,i.jsx)("path",{d:"M4 21L4 14"}),(0,i.jsx)("path",{d:"M4 10L4 3"}),(0,i.jsx)("path",{d:"M12 21L12 12"}),(0,i.jsx)("path",{d:"M12 8L12 3"}),(0,i.jsx)("path",{d:"M20 21L20 16"}),(0,i.jsx)("path",{d:"M20 12L20 3"}),(0,i.jsx)("path",{d:"M1 14L7 14"}),(0,i.jsx)("path",{d:"M9 8L15 8"}),(0,i.jsx)("path",{d:"M17 16L23 16"})]});function yt(){return(0,i.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",style:{display:"inline-block"},children:(0,i.jsx)("path",{fillRule:"evenodd",fill:"currentColor",d:"M5.5 3.5a2 2 0 100 4 2 2 0 000-4zM2 5.5a3.5 3.5 0 115.898 2.549 5.507 5.507 0 013.034 4.084.75.75 0 11-1.482.235 4.001 4.001 0 00-7.9 0 .75.75 0 01-1.482-.236A5.507 5.507 0 013.102 8.05 3.49 3.49 0 012 5.5zM11 4a.75.75 0 100 1.5 1.5 1.5 0 01.666 2.844.75.75 0 00-.416.672v.352a.75.75 0 00.574.73c1.2.289 2.162 1.2 2.522 2.372a.75.75 0 101.434-.44 5.01 5.01 0 00-2.56-3.012A3 3 0 0011 4z"})})}function Tr(){return(0,i.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",style:{display:"inline-block"},children:(0,i.jsx)("path",{fillRule:"evenodd",fill:"currentColor",d:"M2.5 7.775V2.75a.25.25 0 01.25-.25h5.025a.25.25 0 01.177.073l6.25 6.25a.25.25 0 010 .354l-5.025 5.025a.25.25 0 01-.354 0l-6.25-6.25a.25.25 0 01-.073-.177zm-1.5 0V2.75C1 1.784 1.784 1 2.75 1h5.025c.464 0 .91.184 1.238.513l6.25 6.25a1.75 1.75 0 010 2.474l-5.026 5.026a1.75 1.75 0 01-2.474 0l-6.25-6.25A1.75 1.75 0 011 7.775zM6 5a1 1 0 100 2 1 1 0 000-2z"})})}function Rr(){return(0,i.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",style:{display:"inline-block"},children:(0,i.jsx)("path",{fillRule:"evenodd",fill:"currentColor",d:"M8.75.75a.75.75 0 00-1.5 0V2h-.984c-.305 0-.604.08-.869.23l-1.288.737A.25.25 0 013.984 3H1.75a.75.75 0 000 1.5h.428L.066 9.192a.75.75 0 00.154.838l.53-.53-.53.53v.001l.002.002.002.002.006.006.016.015.045.04a3.514 3.514 0 00.686.45A4.492 4.492 0 003 11c.88 0 1.556-.22 2.023-.454a3.515 3.515 0 00.686-.45l.045-.04.016-.015.006-.006.002-.002.001-.002L5.25 9.5l.53.53a.75.75 0 00.154-.838L3.822 4.5h.162c.305 0 .604-.08.869-.23l1.289-.737a.25.25 0 01.124-.033h.984V13h-2.5a.75.75 0 000 1.5h6.5a.75.75 0 000-1.5h-2.5V3.5h.984a.25.25 0 01.124.033l1.29.736c.264.152.563.231.868.231h.162l-2.112 4.692a.75.75 0 00.154.838l.53-.53-.53.53v.001l.002.002.002.002.006.006.016.015.045.04a3.517 3.517 0 00.686.45A4.492 4.492 0 0013 11c.88 0 1.556-.22 2.023-.454a3.512 3.512 0 00.686-.45l.045-.04.01-.01.006-.005.006-.006.002-.002.001-.002-.529-.531.53.53a.75.75 0 00.154-.838L13.823 4.5h.427a.75.75 0 000-1.5h-2.234a.25.25 0 01-.124-.033l-1.29-.736A1.75 1.75 0 009.735 2H8.75V.75zM1.695 9.227c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L3 6.327l-1.305 2.9zm10 0c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L13 6.327l-1.305 2.9z"})})}function Mr(){return(0,i.jsx)("svg",{viewBox:"0 0 16 16",width:"14",height:"14",style:{display:"inline-block"},children:(0,i.jsx)("path",{fillRule:"evenodd",fill:"currentColor",d:"M1.679 7.932c.412-.621 1.242-1.75 2.366-2.717C5.175 4.242 6.527 3.5 8 3.5c1.473 0 2.824.742 3.955 1.715 1.124.967 1.954 2.096 2.366 2.717a.119.119 0 010 .136c-.412.621-1.242 1.75-2.366 2.717C10.825 11.758 9.473 12.5 8 12.5c-1.473 0-2.824-.742-3.955-1.715C2.92 9.818 2.09 8.69 1.679 8.068a.119.119 0 010-.136zM8 2c-1.981 0-3.67.992-4.933 2.078C1.797 5.169.88 6.423.43 7.1a1.619 1.619 0 000 1.798c.45.678 1.367 1.932 2.637 3.024C4.329 13.008 6.019 14 8 14c1.981 0 3.67-.992 4.933-2.078 1.27-1.091 2.187-2.345 2.637-3.023a1.619 1.619 0 000-1.798c-.45-.678-1.367-1.932-2.637-3.023C11.671 2.992 9.981 2 8 2zm0 8a2 2 0 100-4 2 2 0 000 4z"})})}function Er(){return(0,i.jsx)("svg",{viewBox:"0 0 16 16",width:"14",height:"14",style:{display:"inline-block"},children:(0,i.jsx)("path",{fillRule:"evenodd",fill:"currentColor",d:"M1.5 8a6.5 6.5 0 1113 0 6.5 6.5 0 01-13 0zM8 0a8 8 0 100 16A8 8 0 008 0zm.5 4.75a.75.75 0 00-1.5 0v3.5a.75.75 0 00.471.696l2.5 1a.75.75 0 00.557-1.392L8.5 7.742V4.75z"})})}function Nr(){return(0,i.jsx)("svg",{viewBox:"0 0 16 16",width:"16",height:"16",style:{display:"inline-block"},children:(0,i.jsx)("path",{fillRule:"evenodd",fill:"currentColor",d:"M7.47 10.78a.75.75 0 001.06 0l3.75-3.75a.75.75 0 00-1.06-1.06L8.75 8.44V1.75a.75.75 0 00-1.5 0v6.69L4.78 5.97a.75.75 0 00-1.06 1.06l3.75 3.75zM3.75 13a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5z"})})}function _r(){return(0,i.jsx)("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:(0,i.jsx)("path",{d:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"})})}function Ar(){return(0,i.jsxs)("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:[(0,i.jsx)("circle",{cx:"18",cy:"5",r:"3"}),(0,i.jsx)("circle",{cx:"6",cy:"12",r:"3"}),(0,i.jsx)("circle",{cx:"18",cy:"19",r:"3"}),(0,i.jsx)("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),(0,i.jsx)("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]})}function Br(){return(0,i.jsx)("svg",{viewBox:"0 0 16 16",width:"16",height:"16",style:{display:"inline-block"},children:(0,i.jsx)("path",{fillRule:"evenodd",d:"M10 13a1 1 0 100-2 1 1 0 000 2zm-4 0a1 1 0 100-2 1 1 0 000 2zm1-5a1 1 0 11-2 0 1 1 0 012 0zm3 1a1 1 0 100-2 1 1 0 000 2zm1-5a1 1 0 11-2 0 1 1 0 012 0zM6 5a1 1 0 100-2 1 1 0 000 2z"})})}function Or(){return(0,i.jsxs)("svg",{style:{display:"inline-block"},width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,i.jsx)("line",{x1:"22",y1:"12",x2:"18",y2:"12"}),(0,i.jsx)("line",{x1:"6",y1:"12",x2:"2",y2:"12"}),(0,i.jsx)("line",{x1:"12",y1:"6",x2:"12",y2:"2"}),(0,i.jsx)("line",{x1:"12",y1:"22",x2:"12",y2:"18"})]})}function Gr(){return(0,i.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:(0,i.jsx)("polyline",{points:"6 9 12 15 18 9"})})}function Dr(){return(0,i.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:(0,i.jsx)("polyline",{points:"18 15 12 9 6 15"})})}function zr(){return(0,i.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:[(0,i.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,i.jsx)("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),(0,i.jsx)("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),(0,i.jsx)("line",{x1:"14",y1:"11",x2:"14",y2:"17"})]})}var te=require("react/jsx-runtime"),K=Hr.default.forwardRef((e,r)=>(0,te.jsx)("button",{ref:r,type:"button",className:Pe.tw`h-8 px-3 py-2 rounded-md focus:outline-none focus:ring cursor-pointer text-md flex align-middle items-center gap-2 bg-gray-100 hover:bg-gray-200 text-gray-700 disabled:cursor-not-allowed disabled:bg-gray-100! disabled:opacity-50`,...e}));var Qe=e=>(0,te.jsx)("button",{className:Pe.tw`absolute top-0 right-0 h-12 w-12 bg-red-100 cursor-pointer hover:bg-red-200 text-red-800 text-lg`,children:"\u2715",...e}),Fr=e=>(0,te.jsx)("button",{className:Pe.tw`absolute top-4 left-4 rounded-lg z-10 h-10 w-10 bg-white cursor-pointer hover:bg-gray-100 text-gray-700 text-lg flex items-center justify-center`,...e,children:(0,te.jsx)(Ce,{})}),$r=e=>(0,te.jsx)("button",{className:Pe.tw`absolute top-4 right-4 rounded-lg z-10 h-10 w-10 bg-white cursor-pointer hover:bg-gray-100 text-gray-700 text-lg flex items-center justify-center`,...e,children:(0,te.jsx)(Xe,{})});var re=require("twind");var R=require("react/jsx-runtime");var ue=e=>(0,R.jsxs)("div",{children:[e.label&&(0,R.jsx)("label",{className:re.tw`text-gray-700`,htmlFor:e.name,children:e.label}),(0,R.jsx)("select",{id:e.name,name:e.name,className:re.tw`block w-full px-4 py-2 mt-2 text-gray-700 border bg-white border-gray-200 rounded-md focus:outline-none focus:ring appearance-none text-base`,style:{backgroundImage:`url("data:image/svg+xml,%0A%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3E%3C/svg%3E")`,backgroundPosition:"right 0.75rem center",backgroundSize:"16px 12px",backgroundRepeat:"no-repeat"},...e})]}),Wr=e=>(0,R.jsxs)("div",{className:"relative",children:[(0,R.jsx)("span",{className:re.tw`absolute inset-y-0 left-0 flex items-center pl-3`,children:(0,R.jsx)(Cr,{})}),(0,R.jsx)("input",{type:"search",className:re.tw`w-full py-2 pl-10 pr-4 text-gray-700 bg-white border border-gray-300 text-base rounded-md focus:outline-none focus:ring`,...e})]}),qr=e=>e.isLoading?(0,R.jsx)("svg",{width:"20px",height:"20px",viewBox:"0 0 20 20",version:"1.1",className:re.tw`inline text-gray-200 animate-spin dark:text-gray-600`,children:(0,R.jsx)("g",{stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:(0,R.jsx)("g",{fill:"#212121",fillRule:"nonzero",children:(0,R.jsx)("path",{d:"M10,3 C6.13401,3 3,6.13401 3,10 C3,10.2761 2.77614,10.5 2.5,10.5 C2.22386,10.5 2,10.2761 2,10 C2,5.58172 5.58172,2 10,2 C14.4183,2 18,5.58172 18,10 C18,14.4183 14.4183,18 10,18 C9.72386,18 9.5,17.7761 9.5,17.5 C9.5,17.2239 9.72386,17 10,17 C13.866,17 17,13.866 17,10 C17,6.13401 13.866,3 10,3 Z"})})})}):(0,R.jsx)("input",{type:"checkbox",className:re.tw`w-5 h-5 border-gray-100 focus:outline-none focus:ring focus:ring-blue-300 focus:ring-opacity-80`,name:e.name,checked:e.checked,onChange:e.onChange});var oe=require("@bumaga/tabs"),Vr=T(require("clsx"),1),Te=require("twind"),me=require("react/jsx-runtime"),et=({children:e,icon:r})=>{let{onClick:t,isActive:n}=(0,oe.useTabState)(),o=(0,Vr.default)(["flex items-center justify-center h-12 px-2 py-2 bg-transparent -mb-px border-b-2 -px-1 whitespace-nowrap focus:outline-none w-full cursor-pointer",{"text-blue-600 border-blue-500":n,"text-gray-700 border-gray-300 hover:border-gray-400":!n}]);return(0,me.jsxs)("button",{className:(0,Te.tw)(o),onClick:t,children:[r,(0,me.jsx)("span",{className:Te.tw`ml-2 text-base`,children:e})]})},tt=({children:e})=>(0,oe.usePanelState)()?(0,me.jsx)("div",{className:Te.tw`w-full flex flex-grow-1 overflow-auto`,children:e}):null,Ur=({children:e})=>(0,me.jsx)("div",{className:Te.tw`flex flex-shrink-0 border-b border-gray-200 justify-around pr-12`,children:e});var ne=require("twind"),j=require("react/jsx-runtime"),Zr=({checked:e=!1,onChange:r,disabled:t=!1,label:n,title:o,id:a})=>(0,j.jsxs)("label",{htmlFor:a,title:o,className:ne.tw`inline-flex items-center gap-2 cursor-pointer select-none ${t?"opacity-50 cursor-not-allowed":""}`,children:[n&&(0,j.jsx)("span",{className:ne.tw`text-sm text-gray-600 font-normal`,children:n}),(0,j.jsxs)("span",{className:ne.tw`relative inline-flex items-center`,children:[(0,j.jsx)("input",{id:a,type:"checkbox",role:"switch","aria-checked":e,checked:e,disabled:t,onChange:s=>r?.(s.target.checked),className:ne.tw`sr-only`}),(0,j.jsx)("div",{className:ne.tw`w-8 h-4 rounded-full transition-colors duration-200 ease-in-out ${e?"bg-blue-600":"bg-gray-300"}`}),(0,j.jsx)("div",{className:ne.tw`absolute left-0.5 top-0.5 bg-white w-3 h-3 rounded-full shadow-sm transition-transform duration-200 ease-in-out ${e?"transform translate-x-4":""}`})]})]});var jr=require("@biodiv-platform/naksha-commons"),Ne=require("twind");var Yr=require("@biodiv-platform/naksha-commons");var gt=require("react/jsx-runtime");function Re({hideLabel:e}){let{layer:{selectionStyle:r,handleSelectStyle:t}}=u(),{t:n}=(0,Yr.useT)(),o=a=>{t(a.target.value)};return(0,gt.jsx)(ue,{name:"layer_selection",label:e?null:n("layer_selection"),defaultValue:r,onChange:o,children:Object.values(G).map(a=>(0,gt.jsx)("option",{value:a,children:n(a)},a))})}var Kr=T(require("clsx"),1),Ee=require("react"),Me=require("twind");var D=require("react/jsx-runtime");function ht({data:e}){let[r,t]=(0,Ee.useState)(!0),[n,o]=(0,Ee.useState)({title:e.sourceLayer,properties:[]}),{layer:a,mp:s,query:{clickedLngLat:l}}=u(),d=async()=>{let m,f=a.selectedLayers.find(y=>y.id===(e.sourceLayer||e.source));if(f.layerType.toLowerCase()==="raster"){let{data:y}=await gr(s.geoserver?.endpoint,s.geoserver?.workspace,{bbox:e.bbox.toString(),query_layers:`${s.geoserver?.workspace}:${f.id}`,layers:`${s.geoserver?.workspace}:${f.id}`});m=y?.features[0]?Object.entries(y.features[0]?.properties).map(([w,I])=>[I||"-"]):[]}else m=Object.entries(f?.data?.propertyMap||{}).map(([y,w])=>[w,e?.properties?.[y]||"-"]);o({title:f.title,properties:m})};return(0,Ee.useEffect)(()=>{d()},[l]),(0,D.jsxs)("div",{className:Me.tw`bg-gray-100 rounded-lg`,children:[(0,D.jsxs)("button",{className:(0,Me.tw)((0,Kr.default)(["px-4 h-10 flex items-center justify-between bg-gray-100 hover:bg-gray-200 transition-colors cursor-pointer w-full focus:outline-none focus:ring",{"bg-gray-200 rounded-t-lg":r,"rounded-lg":!r}])),onClick:()=>t(!r),children:[n.title," ",r?(0,D.jsx)(Dr,{}):(0,D.jsx)(Gr,{})]}),r&&(0,D.jsx)("div",{className:Me.tw`px-4 py-3 flex flex-col gap-3`,children:n.properties.map(([m,f],y)=>(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:Me.tw`text-gray-600`,children:m}),(0,D.jsx)("div",{children:f})]},m+f+y))})]})}var M=require("react/jsx-runtime");function bt({onClose:e}){let{layer:{selectedFeatures:r,selectedLayers:t,selectionStyle:n}}=u(),{t:o}=(0,jr.useT)();return(0,M.jsxs)("div",{className:Ne.tw`absolute top-0 right-0 bottom-0 left-0 md:top-4 md:right-4 md:bottom-4 md:left-auto bg-white rounded-lg overflow-hidden shadow-md md:max-w-sm w-full z-20 flex flex-col`,children:[(0,M.jsxs)("div",{className:"flex w-full",children:[(0,M.jsxs)("div",{className:Ne.tw`h-12 px-4 flex items-center gap-3 flex-grow bg-gray-200`,children:[(0,M.jsx)(Or,{})," ",o("infobar")]}),(0,M.jsx)(Qe,{onClick:e})]}),(0,M.jsx)("div",{className:Ne.tw`bg-gray-100 p-4 flex-shrink-0 rt`,children:(0,M.jsx)(Re,{hideLabel:!0})}),(0,M.jsx)("div",{className:Ne.tw`flex flex-col flex-grow overflow-auto gap-3 p-4`,children:r.flat(1)?.map(a=>(0,M.jsx)(ht,{data:a},t?.[0]?.source.type==="raster"||n===G.ALL?a?.sourceLayer:a?.sourceLayer+a?.properties[O]))})]})}var Lt=require("react/jsx-runtime");function vt(){let{layer:e,isInfoBarOpen:r,setIsInfoBarOpen:t}=u();if(!e.selectedFeatures?.length)return null;let n=()=>t(!r);return r?(0,Lt.jsx)(bt,{onClose:n}):(0,Lt.jsx)($r,{onClick:n})}var W=T(require("react"),1),Io=require("react-map-gl/maplibre");var ko=require("@biodiv-platform/naksha-commons"),Mt=require("twind");var ho=require("twind");var at=T(require("react"),1),uo=require("react-virtual"),mo=require("react-virtualized-auto-sizer"),St=require("twind");var co=require("@biodiv-platform/naksha-commons"),Ae=require("react"),po=require("react-web-share"),F=require("twind");var J=require("react/jsx-runtime"),Jr=({text:e="",highlight:r=""})=>{if(!r.trim())return(0,J.jsx)(J.Fragment,{children:e});let t=new RegExp(`(${r})`,"gi"),n=e.split(t);return(0,J.jsx)(J.Fragment,{children:n.filter(o=>o).map((o,a)=>t.test(o)?(0,J.jsx)("mark",{children:o},a):(0,J.jsx)("span",{children:o},a))})};var to=require("twind");var Xr=require("@biodiv-platform/naksha-commons"),Qr=require("react"),eo=require("twind"),rt=require("react/jsx-runtime");function _e({children:e}){let[r,t]=(0,Qr.useState)(!1),{t:n}=(0,Xr.useT)();return(0,rt.jsxs)("div",{children:[r&&e,(0,rt.jsx)("button",{onClick:()=>t(!r),className:eo.tw`text-blue-600 focus:outline-none focus:outline focus:ring`,children:n(r?"less":"legend")})]})}var z=require("react/jsx-runtime");function xt({item:e}){let{layer:r}=u(),t=r.gridLegends[e.id];return t?(0,z.jsx)(_e,{children:(0,z.jsxs)("ul",{style:{margin:0,padding:0},children:[t?.stops.map(([n,o],a,s)=>{let l=(s[a-1]||[0])[0];return l===n?(0,z.jsx)("div",{},o):(0,z.jsxs)("li",{className:to.tw`flex gap-2 items-center mb-1`,children:[(0,z.jsx)("svg",{viewBox:"0 0 24 24",height:"14",width:"14",focusable:"false",children:(0,z.jsx)("circle",{cx:"12",fill:o,cy:"12",r:"12",stroke:"none"})}),(0,z.jsxs)("div",{children:[l," - ",n]})]},o)}),(0,z.jsxs)("li",{children:["1 Square = ",t?.squareSize," x ",t?.squareSize," km"]})]})}):null}var ot=require("@biodiv-platform/naksha-commons"),ro=require("react"),oo=require("react-tiny-popover"),X=require("twind");var b=require("react/jsx-runtime"),fe=({icon:e,name:r,title:t,link:n,children:o})=>{let a=(0,b.jsx)("span",{className:X.tw`flex-1`,children:o||"-"});return(0,b.jsxs)("div",{className:X.tw`flex items-center gap-3 text-sm text-gray-600 break-all`,title:r&&t&&`${r}: ${t}`,children:[(0,b.jsx)("div",{className:X.tw`flex-shrink-0`,children:e}),n?(0,b.jsx)("a",{className:X.tw`text-blue-700 focus:outline-none focus:ring flex-1`,target:"_blank",rel:"noopener",href:n,children:a}):a]})};function nn({item:e,containerStyle:r}){let{t}=(0,ot.useT)(),{layer:n,mp:o}=u(),a=e.license||"CC-BY",s=e?.createdDate&&new Date(e.createdDate).toLocaleDateString(),l=e.tags?.join(", ");return(0,b.jsxs)("div",{className:X.tw`flex flex-col gap-1 bg-white p-4 rounded-lg w-72 border border-gray-300 border-solid`,style:r,children:[o.managePublishing&&e.layerStatus&&(0,b.jsx)(fe,{icon:(0,b.jsx)(Mr,{}),name:t("visiblity"),title:e.layerStatus,children:(0,b.jsxs)("div",{className:X.tw`flex items-center gap-3`,children:[(0,b.jsx)("span",{children:e.layerStatus}),(0,b.jsx)(Zr,{label:t("published"),checked:e.layerStatus?.toLowerCase()===pe.ACTIVE.toLowerCase(),onChange:()=>n.togglePublish(e.id,e?.layerStatus)}),(0,b.jsx)("button",{type:"button",title:t("delete"),className:X.tw`text-red-500 hover:text-red-700 focus:outline-none cursor-pointer flex items-center p-0.5 rounded hover:bg-red-50 transition-colors`,onClick:()=>n.delete(e.id,t("are_you_sure")),children:(0,b.jsx)(zr,{})})]})}),(0,b.jsx)(fe,{icon:(0,b.jsx)(yt,{}),link:e.url,name:t("uploader"),title:e.createdBy,children:e.createdBy}),(0,b.jsx)(fe,{icon:(0,b.jsx)(yt,{}),link:e.url,name:t("created_by"),title:e.attribution,children:e.attribution}),(0,b.jsx)(fe,{icon:(0,b.jsx)(Er,{}),name:t("created_on"),title:s,children:s}),(0,b.jsx)(fe,{icon:(0,b.jsx)(Tr,{}),name:t("tags"),title:l,children:l}),(0,b.jsx)(fe,{name:t("license"),title:a,link:a&&ot.LICENSES[a],icon:(0,b.jsx)(Rr,{}),children:a})]})}var no=({item:e})=>{let[r,t]=(0,ro.useState)(!1),n=()=>t(!r);return(0,b.jsx)(oo.Popover,{isOpen:r,padding:10,positions:["right"],containerStyle:{zIndex:"99"},onClickOutside:n,content:(0,b.jsx)(nn,{item:e}),children:(0,b.jsx)(K,{onClick:n,children:(0,b.jsx)(Xe,{}),title:"Information"})})};var lo=require("twind");var nt=require("react"),ao=require("@biodiv-platform/naksha-commons"),so=require("twind");var H=require("react/jsx-runtime");function io({item:e}){let[r,t]=(0,nt.useState)(!0),{mp:n}=u(),{t:o}=(0,ao.useT)(),a=(0,nt.useMemo)(()=>e?.data?.styles?.[e.data.styleIndex]?.colors?.paint?.["fill-color"]?.stops||e?.data?.styles?.[e.data.styleIndex]?.colors?.paint?.["circle-color"]?.stops||[],[e]),s=()=>a.map(([l,d])=>(0,H.jsxs)("li",{className:so.tw`flex gap-2 items-center mb-1`,children:[(0,H.jsx)("svg",{viewBox:"0 0 24 24",height:"14",width:"14",focusable:"false",children:(0,H.jsx)("circle",{cx:"12",fill:d,cy:"12",r:"12",stroke:"none"})}),(0,H.jsx)("div",{children:l})]},d));return(0,H.jsx)("ul",{style:{margin:0,padding:0},children:e.layerType!=="RASTER"?s():r?(0,H.jsx)("li",{children:(0,H.jsx)("img",{style:{margin:"5px"},onError:()=>t(!1),src:`${n?.geoserver?.endpoint}/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&WIDTH=20&HEIGHT=20&STRICT=false&layer=biodiv:${e.id}`})}):(0,H.jsx)("div",{children:o("raster_style_not_found")})})}var ae=require("react/jsx-runtime");function wt({item:e}){if(!e.data?.styles)return null;let{layer:r}=u(),t=n=>{r.updateStyle(e.id,Number(n.target.value))};return(0,ae.jsxs)("div",{className:lo.tw`flex flex-col gap-4 pt-2`,children:[e.layerType!=="RASTER"&&(0,ae.jsx)(ue,{onChange:t,children:e.data?.styles.map((n,o)=>(0,ae.jsx)("option",{value:o,children:n.styleTitle},o))}),(0,ae.jsx)(_e,{children:(0,ae.jsx)(io,{item:e})})]})}var L=require("react/jsx-runtime");function an({dragHandleProps:e}){return(0,L.jsx)("div",{className:F.tw`mt-1 w-6 text-center cursor-move`,style:{touchAction:"none"},...e,children:(0,L.jsx)(Br,{})})}function Be({item:e,extended:r,dragHandleProps:t}){let{t:n}=(0,co.useT)(),{layer:o,query:a,mp:s,query:{setClickedLngLat:l},setIsInfoBarOpen:d}=u(),[m,f]=(0,Ae.useState)(o.selectedIds.includes(e.id)),[y,w]=(0,Ae.useState)(!1),I=(0,Ae.useMemo)(()=>s.canLayerShare?{url:typeof window<"u"?`${window.location.href.split("?")[0]}?layers=${e.id}`:"",title:e.title}:void 0,[s.canLayerShare,e.id,e.title]),A=async()=>{w(!0),d(!0),o.setSelectedFeatures([]),l(null),await o.toggle({layerId:e.id,add:!m}),f(!m),w(!1)},V=async()=>{await vr(s.nakshaApiEndpoint,s.nakshaEndpointToken,e.id,e.title),s?.onLayerDownload(e.id)},U=()=>o.zoomToExtent(e.id);return(0,L.jsxs)("div",{className:F.tw`z-20 p-3 bg-white`,style:{borderTop:"1px solid #e5e7eb"},children:[(0,L.jsxs)("div",{className:F.tw`flex gap-3`,children:[(0,L.jsxs)("div",{className:F.tw`flex-shrink-0`,children:[(0,L.jsx)(qr,{name:e.id,checked:m,onChange:A,isLoading:y}),r&&(0,L.jsx)(an,{dragHandleProps:t})]}),(0,L.jsx)("img",{className:F.tw`flex-shrink-0 overflow-hidden h-16 w-16 p-1 mb-2 object-cover border border-gray-200 rounded`,src:e.thumbnail||ir}),(0,L.jsxs)("div",{children:[(0,L.jsx)("div",{title:e.title,className:F.tw`mb-1 leading-tight`,style:pt,children:(0,L.jsx)(Jr,{text:e.title,highlight:a.term})}),(0,L.jsx)("p",{title:e.description,className:F.tw`text-gray-600 text-sm`,style:lr,children:e.description})]})]}),(0,L.jsxs)("div",{className:F.tw`flex justify-between`,children:[(0,L.jsxs)(K,{onClick:V,disabled:!e.isDownloadable,children:[(0,L.jsx)(Nr,{})," ",n("download")]}),(0,L.jsxs)("div",{className:F.tw`flex gap-3`,children:[I&&(0,L.jsx)(po.RWebShare,{data:I,children:(0,L.jsx)(K,{title:"Share",children:(0,L.jsx)(Ar,{})})}),r&&(0,L.jsx)(K,{onClick:U,title:"Zoom To Extent",children:(0,L.jsx)(_r,{})}),(0,L.jsx)(no,{item:e})]})]}),r&&(0,L.jsx)(wt,{item:e}),r&&e.source.type==="grid"&&(0,L.jsx)(xt,{item:e})]})}var Q=require("react/jsx-runtime");function fo(){let{layer:e,query:r}=u(),t=(0,at.useMemo)(()=>r.term?e.all.filter(a=>a.title.toLowerCase().includes(r.term.toLowerCase())):e.all,[e.all,r.term]),n=at.default.useRef(null),o=(0,uo.useVirtual)({size:t.length,parentRef:n});return(0,Q.jsx)("div",{className:St.tw`flex-grow-1 relative`,children:(0,Q.jsx)(mo.AutoSizer,{renderProp:a=>(0,Q.jsx)("div",{ref:n,className:"List",style:{height:a.height,overflow:"auto"},children:(0,Q.jsx)("div",{style:{height:o.totalSize,width:"100%",position:"relative"},children:o.virtualItems.map(s=>(0,Q.jsx)("div",{ref:s.measureRef,className:St.tw`absolute top-0 left-0 w-full`,style:{transform:`translateY(${s.start}px)`},children:(0,Q.jsx)("div",{style:{height:146},children:(0,Q.jsx)(Be,{item:t[s.index]})})},s.index))})})})})}var yo=require("@biodiv-platform/naksha-commons"),go=require("twind");var kt=require("react/jsx-runtime");function It(){let{t:e}=(0,yo.useT)(),{query:r}=u(),t=n=>r.setTerm(n.target.value);return(0,kt.jsx)("div",{className:go.tw`flex-shrink-0 border-b-2 p-4`,children:(0,kt.jsx)(Wr,{name:"lyr_search",placeholder:e("find_layer_by_name"),onChange:t})})}var Oe=require("react/jsx-runtime");function Ct(){return(0,Oe.jsxs)("div",{className:ho.tw`flex flex-col w-full`,children:[(0,Oe.jsx)(It,{}),(0,Oe.jsx)(fo,{})]})}function sn(e,r,t){let n=r<0?e.length+r:r;if(n>=0&&n<e.length){let o=t<0?e.length+t:t,[a]=e.splice(r,1);e.splice(o,0,a)}}function bo(e,r,t){return e=[...e],sn(e,r,t),e}var $=require("@dnd-kit/core"),ye=require("@dnd-kit/sortable"),Lo=require("@dnd-kit/utilities");var se=require("react/jsx-runtime");function ln({item:e,extended:r}){let{attributes:t,listeners:n,setNodeRef:o,transform:a,transition:s,isDragging:l}=(0,ye.useSortable)({id:e.id}),d={transform:Lo.CSS.Transform.toString(a),transition:s,opacity:l?.5:1};return(0,se.jsx)("div",{ref:o,style:d,children:(0,se.jsx)(Be,{item:e,extended:r,dragHandleProps:{...t,...n}})})}var vo=({layerList:e,onSortEnd:r})=>{let t=(0,$.useSensors)((0,$.useSensor)($.PointerSensor,{activationConstraint:{distance:4}}));return(0,se.jsx)($.DndContext,{sensors:t,collisionDetection:$.closestCenter,onDragEnd:o=>{let{active:a,over:s}=o;if(s&&a.id!==s.id){let l=e.findIndex(m=>m.id===a.id),d=e.findIndex(m=>m.id===s.id);l!==-1&&d!==-1&&r({oldIndex:l,newIndex:d})}},children:(0,se.jsx)(ye.SortableContext,{items:e.map(o=>o.id),strategy:ye.verticalListSortingStrategy,children:(0,se.jsx)("div",{children:e.map(o=>(0,se.jsx)(ln,{item:o,extended:!0},o.id))})})})};var xo=require("@biodiv-platform/naksha-commons"),Pt=require("twind"),ge=require("react/jsx-runtime");function Tt(){let{layer:e}=u(),{t:r}=(0,xo.useT)(),t=({oldIndex:n,newIndex:o})=>{e.setSelectedIds(bo(e.selectedIds,n,o))};return(0,ge.jsxs)("div",{className:Pt.tw`flex flex-col gap-3 w-full`,children:[e.selectedIds.length>0&&(0,ge.jsx)("div",{className:Pt.tw`p-3 pb-0`,children:(0,ge.jsxs)(K,{onClick:()=>e.clearAll(),children:["\u2715 ",r("clear")]})}),(0,ge.jsx)(vo,{layerList:e.selectedLayers,useDragHandle:!0,onSortEnd:t})]})}var wo=require("@biodiv-platform/naksha-commons"),So=require("twind");var he=require("react/jsx-runtime");function Rt(){let{layer:e}=u(),{t:r}=(0,wo.useT)(),t=n=>{e.setMapStyle(n.target.value),e.setMaxZoom(e.mapStyles.find(o=>o.style===n.target.value)?.maxZoom)};return(0,he.jsxs)("div",{className:So.tw`w-full p-4 flex flex-col gap-4`,children:[(0,he.jsx)(ue,{name:"base_style",label:r("base_style"),defaultValue:e.mapStyle,onChange:t,children:e.mapStyles.map(n=>(0,he.jsx)("option",{value:n.style,children:n.text},n.key))}),(0,he.jsx)(Re,{})]})}var S=require("react/jsx-runtime");function Et({onClose:e}){let{t:r}=(0,ko.useT)();return(0,S.jsxs)("div",{className:Mt.tw`absolute top-0 right-0 bottom-0 left-0 md:right-auto md:top-4 md:left-4 md:bottom-4 bg-white rounded-lg shadow-md md:max-w-sm w-full z-20 overflow-hidden`,children:[(0,S.jsx)(Qe,{onClick:e}),(0,S.jsx)("div",{className:Mt.tw`flex flex-col h-full`,children:(0,S.jsxs)(oe.Tabs,{children:[(0,S.jsxs)(Ur,{children:[(0,S.jsx)(et,{icon:(0,S.jsx)(Ce,{}),children:r("layers")}),(0,S.jsx)(et,{icon:(0,S.jsx)(Ce,{}),children:r("selected")}),(0,S.jsx)(et,{icon:(0,S.jsx)(Pr,{}),children:r("settings")})]}),(0,S.jsx)(tt,{children:(0,S.jsx)(Ct,{})}),(0,S.jsx)(tt,{children:(0,S.jsx)(Tt,{})}),(0,S.jsx)(tt,{children:(0,S.jsx)(Rt,{})})]})})]})}var Nt=require("react/jsx-runtime");function _t(){let{mp:e,layer:r}=u(),[t,n]=(0,W.useState)(e.showToC),{mapl:o}=(0,Io.useMap)(),a=(0,W.useRef)(!1),s=W.default.useCallback(()=>n(d=>!d),[]),l=W.default.useCallback(async()=>{let d=await yr(e.nakshaEndpointToken,e.nakshaApiEndpoint,e.geoserver,e.selectedLayers),m=[...e.layers||[],...d];if(r.setAll(m),r.selectedIds.length){let f=m.find(y=>y.id===r.selectedIds[0]);f?.bbox&&o?.fitBounds(f.bbox,{padding:40,duration:1e3})}},[e.nakshaEndpointToken,e.nakshaApiEndpoint,e.geoserver,e.selectedLayers,e.layers,r.setAll,r.selectedIds,o]);return(0,W.useEffect)(()=>{e.loadToC&&!a.current&&(a.current=!0,l())},[e.loadToC]),(0,W.useEffect)(()=>{if(o&&r.selectedIds.length&&r.all?.length){let d=r.all.find(m=>m.id===r.selectedIds[0]);d?.bbox&&o.fitBounds(d.bbox,{padding:40,duration:1e3})}},[o]),t?(0,Nt.jsx)(Et,{onClose:s}):(0,Nt.jsx)(Fr,{onClick:s})}var q=require("maplibre-gl"),Co="https://unpkg.com/maplibre-gl@6.16.0/dist/maplibre-gl-worker.mjs";typeof window<"u"&&!q.config.WORKER_URL&&(q.config.WORKER_URL="/maplibre-gl-worker.mjs");var st=null;async function Po(e){return e?(q.config.WORKER_URL=e,e):q.config.WORKER_URL&&q.config.WORKER_URL!=="/maplibre-gl-worker.mjs"?q.config.WORKER_URL:typeof window>"u"?"":st||(st=(async()=>{try{let r=await fetch("/maplibre-gl-worker.mjs",{method:"HEAD"}),t=r.headers.get("content-type")||"";if(r.ok&&!t.includes("text/html"))return q.config.WORKER_URL="/maplibre-gl-worker.mjs","/maplibre-gl-worker.mjs"}catch{}return q.config.WORKER_URL=Co,Co})(),st)}var Mo=require("react-map-gl/maplibre");var To=T(require("@turf/bbox"),1),ee=require("react"),be=require("react-map-gl/maplibre");var At=require("react/jsx-runtime");function Bt({data:e,beforeId:r}){let{layer:t}=u(),{mapl:n}=(0,be.useMap)(),[o,a]=(0,ee.useState)({geojson:{},paint:{}}),s=(0,ee.useRef)(""),l=t.selectedIds.includes(e.id),d=t.selectedIds[0]===e.id,m=async(f=!1)=>{if(!n)return;let y=n.getBounds(),w=n.getZoom();if(!y)return;let[I]=je(w),{_ne:A,_sw:V}=y,U=`${A.lat.toFixed(4)},${V.lng.toFixed(4)},${V.lat.toFixed(4)},${A.lng.toFixed(4)},${I}`;if(U===s.current)return;s.current=U;let{success:ie,geojson:Fe,paint:C,stops:ct,squareSize:k}=await Lr(e.source.fetcher,y,w);if(ie){if(a({geojson:Fe,paint:C}),f&&d&&e.zoomToFit)try{let B=(0,To.default)(Fe);if(B.every(Number.isFinite)){let[x,Z,le,$e]=B;n.fitBounds([[x,Z],[le,$e]],{padding:40,animate:!0})}}catch(B){console.warn("Failed to compute bbox",B)}t.setGridLegends(B=>({...B,[e.id]:{stops:ct,squareSize:k}}))}};return(0,ee.useEffect)(()=>{l&&d?m(!0):l&&m(!1)},[l,d]),(0,ee.useEffect)(()=>{if(!l||!n)return;let f=()=>m(!1);return n.on("moveend",f),()=>{n.off("moveend",f)}},[l,n]),(0,ee.useEffect)(()=>()=>{t.setGridLegends(f=>{let y={...f};return delete y[e.id],y})},[e.id]),(0,At.jsx)(be.Source,{id:e.id,type:"geojson",data:o.geojson,children:(0,At.jsx)(be.Layer,{beforeId:r,id:e.id,type:"fill",paint:o.paint})})}var Ro=require("react"),Ge=require("react-map-gl/maplibre");var De=require("react/jsx-runtime"),cn={fill:{"line-color":"red","line-width":2},circle:{"circle-stroke-color":"red","circle-stroke-width":2,"circle-opacity":0}};function it({layer:e,beforeId:r}){let{layer:t}=u(),n=(0,Ro.useMemo)(()=>e.data?.styles?.[e.data?.styleIndex]?.colors,[e,t.selectedFeatures]),o=t.selectedFeaturesId?.[e.id];return(0,De.jsxs)(Ge.Source,{...e.source,children:[n&&(0,De.jsx)(Ge.Layer,{beforeId:r,...n}),o&&n&&(0,De.jsx)(Ge.Layer,{...n,beforeId:r,id:`hl_${e.id}`,filter:["in",O,...o],type:n.type==="fill"?"line":n.type,paint:cn[n.type]})]})}var lt=require("react-map-gl/maplibre");var Ot=require("react/jsx-runtime");function Gt({data:e,beforeId:r}){let{mp:t}=u();return(0,Ot.jsx)(lt.Source,{id:e.id,type:"raster",tiles:[`${t?.geoserver?.endpoint}/wms?bbox={bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:3857&width=256&height=256&transparent=true&layers=biodiv:${e.id}`],tileSize:256,children:(0,Ot.jsx)(lt.Layer,{id:e.id,beforeId:r,type:"raster",source:"biodiv",layout:{visibility:"visible"},paint:{}})})}var ze=require("react/jsx-runtime");function Eo({layer:e,beforeId:r}){let{mapl:t}=(0,Mo.useMap)();if(!t)return null;switch(e.source.type){case"vector":return(0,ze.jsx)(it,{beforeId:r,layer:e});case"grid":return(0,ze.jsx)(Bt,{beforeId:r,data:e});case"raster":return(0,ze.jsx)(Gt,{beforeId:r,data:e});default:return(0,ze.jsx)(it,{beforeId:r,layer:e})}}var No=require("react"),_o=require("react-map-gl/maplibre");var Le=require("react/jsx-runtime"),dn=_o.Marker,pn=()=>{let{mp:e}=u(),r=(0,No.useMemo)(()=>e.markers,[e.markers]);return(0,Le.jsx)(Le.Fragment,{children:r?.map(({latitude:t,longitude:n,colorHex:o,anchor:a="bottom",iconUrl:s},l)=>(0,Le.jsx)(dn,{latitude:t,longitude:n,anchor:a,subpixelPositioning:!0,children:(0,Le.jsx)("img",{style:{cursor:"pointer",display:"block",width:"25px",height:"41px"},width:25,height:41,alt:"Marker",src:s||"https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon.png"})},l))})},Ao=pn;var Bo=T(require("clsx"),1),Oo=require("react-map-gl/maplibre"),ve=require("twind");var E=require("react/jsx-runtime"),un=Oo.Popup;function Dt({coordinates:e}){let{hover:r}=u(),t=e||r.features?.coordinates;return t?.lat&&r.features?(0,E.jsx)(un,{latitude:t.lat,longitude:t.lng,closeButton:!1,children:(0,E.jsxs)("table",{className:ve.tw`table-auto border`,children:[(0,E.jsx)("thead",{children:(0,E.jsx)("tr",{children:(0,E.jsx)("th",{className:ve.tw`bg-gray-200 py-1 px-2`,colSpan:2,children:r.features.title})})}),(0,E.jsx)("tbody",{children:r.features.data.map(([n,o],a)=>(0,E.jsxs)("tr",{className:(0,ve.tw)((0,Bo.default)({"bg-gray-50":a%2===0,"border-gray-100 border-t":1})),children:[(0,E.jsx)("td",{className:ve.tw`py-1 px-2`,children:n}),(0,E.jsx)("td",{className:ve.tw`py-1 px-2 border-l border-gray-100`,children:o})]},n+o))})]})}):null}var N=require("react/jsx-runtime"),mn=xe.NavigationControl;function zt(){let{mp:e,layer:r,hover:t,query:n}=u(),[o,a]=(0,_.useState)(e.workerUrl||(typeof window<"u"?Do.config.WORKER_URL||"/maplibre-gl-worker.mjs":void 0));(0,_.useEffect)(()=>{Po(e.workerUrl).then(a)},[e.workerUrl]);let s=(0,_.useMemo)(()=>e.defaultViewState||Go.defaultViewState,[e.defaultViewState]),l=_.default.useCallback(f=>n.setClickedLngLat(f.lngLat),[n]),d=_.default.useRef(null),m=_.default.useCallback(f=>{d.current||(d.current=requestAnimationFrame(()=>{d.current=null,t.onHover(f)}))},[t]);return(0,_.useEffect)(()=>()=>{d.current&&cancelAnimationFrame(d.current)},[]),(0,N.jsxs)("div",{className:zo.tw`h-full w-full relative bg-gray-100`,children:[e.loadToC&&(0,N.jsx)(_t,{}),r.selectedFeatures?.length>0&&(0,N.jsx)(vt,{}),(0,N.jsxs)(xe.default,{id:"mapl",workerUrl:o,cursor:"default",initialViewState:s,style:{width:"100%",height:"100%"},mapStyle:r.mapStyle,maxZoom:r.maxZoom,onClick:l,onMouseMove:m,children:[(0,N.jsx)(mn,{position:"bottom-right",showZoom:!0,showCompass:!0}),e.showFullscreenControl&&(0,N.jsx)(xe.FullscreenControl,{position:"bottom-right"}),(0,N.jsx)(Ao,{}),r.selectedLayers.map((f,y)=>{let w=y>0?r.selectedIds[y-1]:void 0;return(0,N.jsx)(Eo,{layer:f,beforeId:w},f.id)}),(0,N.jsx)(Dt,{},"popup")]})]})}var He=require("react/jsx-runtime");(0,Wo.setup)({preflight:!1});var fn=e=>{let r=Fo.default.useMemo(()=>({...sr,...e}),[e]);return(0,He.jsx)($o.MapProvider,{children:(0,He.jsx)(Ho.TranslationProvider,{localeStrings:ar,lang:r.lang,children:(0,He.jsx)(Sr,{mp:r,children:(0,He.jsx)(zt,{})})})})};0&&(module.exports={NakshaMaplibreLayers});
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { JSX } from 'react';
2
2
  import { ViewState } from 'react-map-gl/maplibre';
3
3
  import { MapStyles } from '@biodiv-platform/naksha-commons';
4
4
 
@@ -6,10 +6,13 @@ type LayerType = "grid" | "vector" | "raster";
6
6
  interface ExtendedMarkerProps {
7
7
  latitude: number;
8
8
  longitude: number;
9
- colorHex: string;
9
+ colorHex?: string;
10
+ anchor?: "center" | "top" | "bottom" | "left" | "right" | "top-left" | "top-right" | "bottom-left" | "bottom-right";
11
+ iconUrl?: string;
10
12
  }
11
13
  interface NakshaMaplibreLayersProps {
12
14
  defaultViewState?: Partial<ViewState>;
15
+ workerUrl?: string;
13
16
  loadToC?: boolean;
14
17
  showToC?: boolean;
15
18
  showFullscreenControl?: boolean;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { JSX } from 'react';
2
2
  import { ViewState } from 'react-map-gl/maplibre';
3
3
  import { MapStyles } from '@biodiv-platform/naksha-commons';
4
4
 
@@ -6,10 +6,13 @@ type LayerType = "grid" | "vector" | "raster";
6
6
  interface ExtendedMarkerProps {
7
7
  latitude: number;
8
8
  longitude: number;
9
- colorHex: string;
9
+ colorHex?: string;
10
+ anchor?: "center" | "top" | "bottom" | "left" | "right" | "top-left" | "top-right" | "bottom-left" | "bottom-right";
11
+ iconUrl?: string;
10
12
  }
11
13
  interface NakshaMaplibreLayersProps {
12
14
  defaultViewState?: Partial<ViewState>;
15
+ workerUrl?: string;
13
16
  loadToC?: boolean;
14
17
  showToC?: boolean;
15
18
  showFullscreenControl?: boolean;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{TranslationProvider as Gn}from"@biodiv-platform/naksha-commons";import On from"react";import{MapProvider as Dn}from"react-map-gl/maplibre";import{setup as zn}from"twind";var pt={are_you_sure:"Are you sure?",base_style:"Base Style",clear:"Clear Selection",created_by:"Attribution",created_on:"Created On",delete:"Delete",download:"Download",find_layer_by_name:"Find layer by name",infobar:"Attributes at Clicked Location",information:"Information",layer_selection:"Layer Selection",layer_selection_all:"All Layers",layer_selection_top:"Top Layer Only",layers:"Layers",legend:"Legend",less:"Less",license:"License",list_layers:"List Layers",pending:"Pending",publish:"Publish",raster_style_not_found:"Style not available for the given layer",remove:"Remove",selected:"Selected",settings:"Settings",square:"Square",tags:"Tags",toggle:"Toggle Publishing",uploaded:"Uploaded",uploader:"Uploader",url:"URL",visiblity:"Visiblity"};var ut={are_you_sure:"\xCAtes-vous s\xFBr?",base_style:"Style de base",clear:"Effacer la s\xE9lection",created_by:"Attribution",created_on:"Cr\xE9\xE9 sur",delete:"Effacer",download:"T\xE9l\xE9charger",find_layer_by_name:"Trouver la couche par nom",infobar:"Attributs \xE0 l'emplacement cliqu\xE9",information:"Informations",layer_selection_all:"Toutes les couches",layer_selection_top:"Couche sup\xE9rieure uniquement",layer_selection:"S\xE9lection de calque",layers:"Couches",legend:"L\xE9gende",less:"Moins",license:"Licence",list_layers:"Liste des couches",pending:"En attente",publish:"Publier",remove:"Supprimer",selected:"Choisie",settings:"Param\xE8tres",square:"Carr\xE9",toggle:"Basculer la publication",uploaded:"T\xE9l\xE9charg\xE9",url:"url"};var mt={are_you_sure:"\u0915\u094D\u092F\u093E \u0906\u092A\u0915\u094B \u092F\u0915\u0940\u0928 \u0939\u0948?",base_style:"\u0906\u0927\u093E\u0930 \u0936\u0948\u0932\u0940",clear:"\u091A\u092F\u0928 \u0938\u093E\u092B\u093C \u0915\u0930\u0947\u0902",created_by:"\u0906\u0930\u094B\u092A\u0923",created_on:"\u092A\u0930 \u092C\u0928\u093E\u092F\u093E",delete:"\u0939\u091F\u093E\u090F\u0902",download:"\u0921\u093E\u0909\u0928\u0932\u094B\u0921",find_layer_by_name:"\u0928\u093E\u092E \u0938\u0947 \u092A\u0930\u0924 \u0916\u094B\u091C\u0947\u0902",infobar:"\u0915\u094D\u0932\u093F\u0915 \u0915\u093F\u090F \u0917\u090F \u0938\u094D\u0925\u093E\u0928 \u092A\u0930 \u0935\u093F\u0936\u0947\u0937\u0924\u093E\u090F\u0902",information:"\u091C\u093E\u0928\u0915\u093E\u0930\u0940",layer_selection_all:"\u0938\u092D\u0940 \u092A\u0930\u0924\u0947\u0902",layer_selection_top:"\u0915\u0947\u0935\u0932 \u0936\u0940\u0930\u094D\u0937 \u092A\u0930\u0924",layer_selection:"\u092A\u0930\u0924 \u091A\u092F\u0928",layers:"\u092A\u0930\u0924\u0947\u0902",legend:"\u0915\u093F\u0902\u0935\u0926\u0902\u0924\u0940",less:"\u0915\u092E",license:"\u0932\u093E\u0907\u0938\u0947\u0902\u0938",list_layers:"\u0938\u0942\u091A\u0940 \u092A\u0930\u0924\u0947\u0902",pending:"\u0932\u0902\u092C\u093F\u0924",publish:"\u092A\u094D\u0930\u0915\u093E\u0936\u093F\u0924",remove:"\u0939\u091F\u093E\u0928\u093E",selected:"\u091A\u092F\u0928\u093F\u0924",settings:"\u0938\u092E\u093E\u092F\u094B\u091C\u0928",square:"\u0938\u094D\u0915\u094D\u0935\u093E\u092F\u0930",tags:"\u091F\u0948\u0917",toggle:"\u092A\u094D\u0930\u0915\u093E\u0936\u0928 \u091F\u0949\u0917\u0932 \u0915\u0930\u0947\u0902",uploaded:"\u0905\u092A\u0932\u094B\u0921 \u0915\u093F\u092F\u093E \u0917\u092F\u093E",url:"\u092F\u0942\u0906\u0930\u090F\u0932"};var ft={en:pt,fr:ut,hi:mt};import{defaultViewState as Tn}from"@biodiv-platform/naksha-commons";import{useMemo as Mn,useState as Nn}from"react";import En,{FullscreenControl as Rn,NavigationControl as _n}from"react-map-gl/maplibre";import{tw as Bn}from"twind";import{defaultMapStyles as Uo,useDebounce as jo}from"@biodiv-platform/naksha-commons";import Jo,{createContext as Ko,useContext as Xo,useEffect as _e,useMemo as Qo,useState as I}from"react";import{useMap as er}from"react-map-gl/maplibre";import Yo from"colorbrewer";import O from"redaxios";import bt from"boundingbox";import{GeoHash as Ee}from"geohash";import{MapStyles as $o,defaultViewState as qo}from"@biodiv-platform/naksha-commons";var yt={defaultViewState:qo,nakshaApiEndpoint:"/naksha-api/api",geoserver:{endpoint:"/geoserver",workspace:"biodiv",store:"ibp"},mapStyle:$o.MAP_STREETS,layers:[],selectedLayers:[]},gt="data:image/svg+xml,%3Csvg fill='none' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 72 72'%3E%3Cpath fill='%23fff' d='M0 0h72v72H0z'/%3E%3Cpath d='M35.981 48.293l-13.853-10.77-3.045 2.368L36 53.048l16.917-13.157-3.064-2.387-13.872 10.789zM36 43.519l13.834-10.77 3.083-2.388L36 17.204 19.083 30.36l3.064 2.387L36 43.518z' fill='%23A0AEC0'/%3E%3C/svg%3E",Me={display:"-webkit-box",WebkitLineClamp:1,WebkitBoxOrient:"vertical",overflow:"hidden",wordBreak:"break-word"},ht={...Me,WebkitLineClamp:2},P="ogc_fid",ie={ACTIVE:"Active",PENDING:"Pending"},T={TOP:"layer_selection_top",ALL:"layer_selection_all"};var Lt=e=>e<6?[4,1,39.2]:e<7?[5,0,19.6]:e<8?[5,1,9.8]:e<9?[5,-1,4.9]:e<10?[6,0,2.45]:e<11?[6,1,1.225]:e<12?[7,0,.612]:e<13?[7,1,.306]:e<14?[7,-1,.153]:e<15?[8,0,.077]:[8,1,.039],Ne="0123456789bcdefghjkmnpqrstuvwxyz",Fo=(e,o,t)=>{t=t||16/2**(1-e.length&1)/4**o;let r=e.slice(0,-1),n=~~(Ne.indexOf(e.slice(-1))/t);return[r+Ne[t*n],r+Ne[t*(n+1)-1]]},Vo=function(e,o){var t=new Map,r=new Map;let n=[];for(let[a,s]of Object.entries(e)){let[i,u]=Fo(a,o);r.set(i,u),t.has(i)||t.set(i,0),t.set(i,t.get(i)+s)}return t.forEach((a,s)=>{let i=Ee.decodeGeoHash(s),u=Ee.decodeGeoHash(r.get(s)),d=new bt({minlat:i.latitude[0],minlon:i.longitude[0],maxlat:u.latitude[1],maxlon:u.longitude[1]}).toGeoJSON();n.push({...d,properties:{count:a,[P]:s}})}),n},Wo=e=>{let o=[];for(let[t,r]of Object.entries(e)){let n=Ee.decodeGeoHash(t),a=new bt({minlat:n.latitude[0],minlon:n.longitude[0],maxlat:n.latitude[1],maxlon:n.longitude[1]}).toGeoJSON();o.push({...a,properties:{count:r,[P]:t}})}return o},vt=(e,o)=>({type:"FeatureCollection",features:Object.keys(e).length===0?[]:o===-1?Wo(e):Vo(e,o)}),xt=(e,o)=>{let t=Object.values(e).sort((a,s)=>a-s),r=Math.floor(t.length/o),n=new Array(o-1).fill(0).map((a,s)=>t[r*(s+1)]);return n.push(t[t.length-1]),n};import{produce as Zo}from"immer";var St=async(e,o,t,r)=>{let n=[];for(let a of e){let s=r.includes(a.name),i={...a,id:a.name,thumbnail:o+a.thumbnail,source:{type:a.layerType.toLowerCase()==="raster"?"raster":"vector",scheme:"tms",tiles:[`${t.endpoint}/gwc/service/tms/1.0.0/${t.workspace}:${a.name}@EPSG%3A900913@pbf/{z}/{x}/{y}.pbf`]},data:{styles:[]},isAdded:s};if(s){let u=await Re(i,0,o,t);n.push({...i,data:u})}else n.push(i)}return n},Re=async(e,o,t,r)=>Zo(e.data,async a=>{if(a.styles.length===0){let{success:s,data:i}=await wt(e.id,t);s&&(a.layerName=i.layerName,a.styles=i.styles,a.summaryColumn=i.summaryColumn,a.titleColumn=i.titleColumn,a.propertyMap=Object.fromEntries(i.styles.map(u=>[u.styleName,u.styleTitle])))}a.styles[o]&&!a.styles[o]?.colors&&(a.styles[o].colors=await It(e.id,r?.workspace,a.styles[o].styleName,t)),a.styleIndex=o});var kt=async(e,o,t,r)=>{try{let n=await O.get(`${o}/layer/all`,{headers:{Authorization:e}});return await St(n.data,o,t,r)}catch(n){return console.error(n),[]}},wt=async(e,o)=>{try{let{data:t}=await O.get(`${o}/layer/onClick/${e}`);return{success:!0,data:t}}catch(t){return console.error(t),{success:!1}}},Ct=async(e,o,t)=>{let r={service:"WMS",version:"1.1.1",request:"GetFeatureInfo",info_format:"application/json",width:100,height:100,x:50,y:50,srs:"EPSG:4326"};try{return{success:!0,data:(await O.get(`${e}/${o}/wms`,{params:{...t,...r}})).data}}catch(n){return console.error(n),{success:!1,data:[]}}},Pt=async(e,o,t,r)=>{try{return await O.put(`${o}/layer/${r?"active":"pending"}/${t}`,{},{headers:{Authorization:e}}),!0}catch(n){return console.error(n),!1}},Tt=async(e,o,t)=>{try{return await O.delete(`${o}/layer/${t}`,{headers:{Authorization:e}}),!0}catch(r){return console.error(r),!1}},It=async(e,o,t,r)=>{try{return(await O.get(`${r}/geoserver/workspaces/${o}/styles/${e}_${t}.mbstyle`)).data?.layers?.[0]}catch(n){return console.error(n),{}}},Mt=async(e,o,t,r=6,n="YlOrRd")=>{try{let[a,s,i]=Lt(t),{_ne:u,_sw:d}=o,y={top:u.lat,left:d.lng,bottom:d.lat,right:u.lng,geoAggegationPrecision:a},g=await e(y),k=vt(g,s),N=xt(g,r).map((G,J)=>[G,Yo[n][r][J]]);return{success:!0,geojson:k,paint:{"fill-color":{property:"count",default:"yellow",stops:N},"fill-outline-color":"rgba(0,0,0,0.2)","fill-opacity":.7},stops:N,squareSize:i}}catch(a){return console.error(a),{success:!1,geojson:{},paint:{},stops:[],squareSize:0}}},Nt=async(e,o,t,r)=>{try{await O.post(`${e}/layer/download`,{layerName:t,layerTitle:r,attributeList:[],filterArray:[]},{headers:{Authorization:o}})}catch(n){console.error(n)}};import{jsx as tr}from"react/jsx-runtime";var Et=Ko({}),Rt=({mp:e,children:o})=>{let[t,r]=I(e),{mapl:n}=er(),[a,s]=I(""),i=jo(a,500),u=t.mapStyles&&t.mapStyles.length>0?t.mapStyles:Uo,[d,y]=I(u[t?.mapStyle||0]?.style),[g,k]=I(u[t?.mapStyle||0]?.maxZoom),[w,N]=I(T.TOP),[B,G]=I({}),[J,we]=I(!0),[E,Po]=I(),[C,Ie]=I(e.layers||[]),[v,F]=I(t.selectedLayers||[]),[nt,at]=I(),[ke,st]=I(),To=Qo(()=>{let p={};for(let m of ke||[])p[m.sourceLayer]=[...p[m.sourceLayer]||[],m?.properties?.[P]];return Object.keys(p).length?p:void 0},[ke]),Ce=Jo.useMemo(()=>{let p=C.filter(f=>v.includes(f.id)),m=new Array(v.length);for(let f of p){let b=v.findIndex(x=>f.id===x);b>-1&&(m[b]=f)}return m},[C,v]),ae=p=>C.findIndex(m=>m.id===p),it=(p,m)=>{Ie(f=>f.map(b=>b.id===p?{...b,...m}:b))},lt=async(p,m,f)=>{let b=C[p],x=await Re(b,m,t.nakshaApiEndpoint,t.geoserver);it(b.id,{data:x}),f&&n?.fitBounds(b.bbox,{padding:40,duration:1e3})},Mo=async(p,m)=>{let f=ae(p);lt(f,m,!1)},No=async p=>{if(!(!v.length||!n))try{let m=v[0],f=n.queryRenderedFeatures(p.point,{layers:[m]});if(f.length){let b=f[0]?.id||f[0]?.properties?.[P];if(b===nt?.id)return;let x=C[ae(m)],dt=x?.data?.summaryColumn.map(R=>[x.data?.propertyMap?.[R]||R,f[0].properties?.[R]]);at({id:b,title:x.title,data:dt})}else at(void 0)}catch{}},Eo=async({layerId:p,add:m,styleIndex:f=0,focus:b=!0})=>{if(!m){F(v.filter(R=>p!==R));return}let x=ae(p);C[x]?.source.type==="grid"?(F(R=>[p,...R.filter(Te=>Te!==p)]),b&&C[x]?.bbox&&setTimeout(()=>{n?.fitBounds(C[x].bbox,{padding:40,duration:1e3})},100)):(await lt(x,f,b),F(R=>[p,...R.filter(Te=>Te!==p)]))},Ro=async()=>F([]),_o=(p,m)=>{r({...t,[p]:m})},Bo=(p,m)=>{let f=m===ie.PENDING;Pt(t.nakshaEndpointToken,t.nakshaApiEndpoint,p,f),it(p,{layerStatus:f?ie.ACTIVE:ie.PENDING})},Ao=async(p,m)=>{confirm(m)&&(Tt(t.nakshaEndpointToken,t.nakshaApiEndpoint,p),Ie(C.filter(f=>f.id!==p)))},Go=p=>{let m=ae(p),f=C[m];n?.fitBounds(f.bbox,{padding:40,duration:1e3})},ct=()=>[E.lng,E.lat,E.lng+.1,E.lat+.1],Oo=p=>{N(p),p===T.TOP&&Pe(p)},Pe=p=>{if(E)try{let m=n?.project([E.lng,E.lat]),f=n?.queryRenderedFeatures(m,{layers:w===T.TOP?[v[0]]:v});if((p||w)===T.ALL){let b=Ce.filter(x=>x.layerType=="RASTER").map(x=>({sourceLayer:x.id,layerType:"raster",bbox:ct()}));f=[...f,...b]}st(Ce?.[0].layerType==="RASTER"&&w!==T.ALL?v.length&&f?.length?f:[{sourceLayer:v[0],layerType:"raster",bbox:ct()}]:f)}catch(m){console.error(m)}},se=(e.selectedLayers||[]).join(",");return _e(()=>{se!==v.join(",")&&F(se?se.split(","):[])},[se]),_e(()=>{t.onSelectedLayersChange&&t.onSelectedLayersChange(v)},[v]),_e(()=>{setTimeout(Pe,300)},[E,w,v]),tr(Et.Provider,{value:{mp:t,updateMP:_o,layer:{mapStyle:d,featuresAtLatLng:Pe,setMapStyle:y,maxZoom:g,setMaxZoom:k,mapStyles:u,all:C,setAll:Ie,selectedIds:v,handleSelectStyle:Oo,setSelectedIds:F,selectedLayers:Ce,clearAll:Ro,toggle:Eo,updateStyle:Mo,selectedFeatures:ke,selectedFeaturesId:To,setSelectedFeatures:st,togglePublish:Bo,delete:Ao,selectionStyle:w,setSelectionStyle:N,zoomToExtent:Go,gridLegends:B,setGridLegends:G},query:{term:i,setTerm:s,clickedLngLat:E,setClickedLngLat:Po},isInfoBarOpen:J,setIsInfoBarOpen:we,hover:{onHover:No,features:nt}},children:o})};function c(){return Xo(Et)}import rr from"react";import{tw as ce}from"twind";import{tw as or}from"twind";import{jsx as l,jsxs as X}from"react/jsx-runtime";var _t=()=>l("svg",{fill:"none",className:or`w-5 h-5 text-gray-400`,width:"24",height:"24",viewBox:"0 0 24 24",children:l("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),K=()=>X("svg",{width:"18",height:"18",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",children:[l("path",{d:"M12 2L2 7 12 12 22 7 12 2z"}),l("path",{d:"M2 17L12 22 22 17"}),l("path",{d:"M2 12L12 17 22 12"})]}),le=()=>X("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l("circle",{cx:"12",cy:"12",r:"10"}),l("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),l("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),Bt=()=>X("svg",{width:"18",height:"18",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",children:[l("path",{d:"M4 21L4 14"}),l("path",{d:"M4 10L4 3"}),l("path",{d:"M12 21L12 12"}),l("path",{d:"M12 8L12 3"}),l("path",{d:"M20 21L20 16"}),l("path",{d:"M20 12L20 3"}),l("path",{d:"M1 14L7 14"}),l("path",{d:"M9 8L15 8"}),l("path",{d:"M17 16L23 16"})]});function Be(){return l("svg",{width:"14",height:"14",viewBox:"0 0 16 16",style:{display:"inline-block"},children:l("path",{fillRule:"evenodd",fill:"currentColor",d:"M5.5 3.5a2 2 0 100 4 2 2 0 000-4zM2 5.5a3.5 3.5 0 115.898 2.549 5.507 5.507 0 013.034 4.084.75.75 0 11-1.482.235 4.001 4.001 0 00-7.9 0 .75.75 0 01-1.482-.236A5.507 5.507 0 013.102 8.05 3.49 3.49 0 012 5.5zM11 4a.75.75 0 100 1.5 1.5 1.5 0 01.666 2.844.75.75 0 00-.416.672v.352a.75.75 0 00.574.73c1.2.289 2.162 1.2 2.522 2.372a.75.75 0 101.434-.44 5.01 5.01 0 00-2.56-3.012A3 3 0 0011 4z"})})}function At(){return l("svg",{width:"14",height:"14",viewBox:"0 0 16 16",style:{display:"inline-block"},children:l("path",{fillRule:"evenodd",fill:"currentColor",d:"M2.5 7.775V2.75a.25.25 0 01.25-.25h5.025a.25.25 0 01.177.073l6.25 6.25a.25.25 0 010 .354l-5.025 5.025a.25.25 0 01-.354 0l-6.25-6.25a.25.25 0 01-.073-.177zm-1.5 0V2.75C1 1.784 1.784 1 2.75 1h5.025c.464 0 .91.184 1.238.513l6.25 6.25a1.75 1.75 0 010 2.474l-5.026 5.026a1.75 1.75 0 01-2.474 0l-6.25-6.25A1.75 1.75 0 011 7.775zM6 5a1 1 0 100 2 1 1 0 000-2z"})})}function Gt(){return l("svg",{width:"14",height:"14",viewBox:"0 0 16 16",style:{display:"inline-block"},children:l("path",{fillRule:"evenodd",fill:"currentColor",d:"M8.75.75a.75.75 0 00-1.5 0V2h-.984c-.305 0-.604.08-.869.23l-1.288.737A.25.25 0 013.984 3H1.75a.75.75 0 000 1.5h.428L.066 9.192a.75.75 0 00.154.838l.53-.53-.53.53v.001l.002.002.002.002.006.006.016.015.045.04a3.514 3.514 0 00.686.45A4.492 4.492 0 003 11c.88 0 1.556-.22 2.023-.454a3.515 3.515 0 00.686-.45l.045-.04.016-.015.006-.006.002-.002.001-.002L5.25 9.5l.53.53a.75.75 0 00.154-.838L3.822 4.5h.162c.305 0 .604-.08.869-.23l1.289-.737a.25.25 0 01.124-.033h.984V13h-2.5a.75.75 0 000 1.5h6.5a.75.75 0 000-1.5h-2.5V3.5h.984a.25.25 0 01.124.033l1.29.736c.264.152.563.231.868.231h.162l-2.112 4.692a.75.75 0 00.154.838l.53-.53-.53.53v.001l.002.002.002.002.006.006.016.015.045.04a3.517 3.517 0 00.686.45A4.492 4.492 0 0013 11c.88 0 1.556-.22 2.023-.454a3.512 3.512 0 00.686-.45l.045-.04.01-.01.006-.005.006-.006.002-.002.001-.002-.529-.531.53.53a.75.75 0 00.154-.838L13.823 4.5h.427a.75.75 0 000-1.5h-2.234a.25.25 0 01-.124-.033l-1.29-.736A1.75 1.75 0 009.735 2H8.75V.75zM1.695 9.227c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L3 6.327l-1.305 2.9zm10 0c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L13 6.327l-1.305 2.9z"})})}function Ot(){return l("svg",{viewBox:"0 0 16 16",width:"14",height:"14",style:{display:"inline-block"},children:l("path",{fillRule:"evenodd",fill:"currentColor",d:"M1.679 7.932c.412-.621 1.242-1.75 2.366-2.717C5.175 4.242 6.527 3.5 8 3.5c1.473 0 2.824.742 3.955 1.715 1.124.967 1.954 2.096 2.366 2.717a.119.119 0 010 .136c-.412.621-1.242 1.75-2.366 2.717C10.825 11.758 9.473 12.5 8 12.5c-1.473 0-2.824-.742-3.955-1.715C2.92 9.818 2.09 8.69 1.679 8.068a.119.119 0 010-.136zM8 2c-1.981 0-3.67.992-4.933 2.078C1.797 5.169.88 6.423.43 7.1a1.619 1.619 0 000 1.798c.45.678 1.367 1.932 2.637 3.024C4.329 13.008 6.019 14 8 14c1.981 0 3.67-.992 4.933-2.078 1.27-1.091 2.187-2.345 2.637-3.023a1.619 1.619 0 000-1.798c-.45-.678-1.367-1.932-2.637-3.023C11.671 2.992 9.981 2 8 2zm0 8a2 2 0 100-4 2 2 0 000 4z"})})}function Dt(){return l("svg",{viewBox:"0 0 16 16",width:"14",height:"14",style:{display:"inline-block"},children:l("path",{fillRule:"evenodd",fill:"currentColor",d:"M1.5 8a6.5 6.5 0 1113 0 6.5 6.5 0 01-13 0zM8 0a8 8 0 100 16A8 8 0 008 0zm.5 4.75a.75.75 0 00-1.5 0v3.5a.75.75 0 00.471.696l2.5 1a.75.75 0 00.557-1.392L8.5 7.742V4.75z"})})}function zt(){return l("svg",{viewBox:"0 0 16 16",width:"16",height:"16",style:{display:"inline-block"},children:l("path",{fillRule:"evenodd",fill:"currentColor",d:"M7.47 10.78a.75.75 0 001.06 0l3.75-3.75a.75.75 0 00-1.06-1.06L8.75 8.44V1.75a.75.75 0 00-1.5 0v6.69L4.78 5.97a.75.75 0 00-1.06 1.06l3.75 3.75zM3.75 13a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5z"})})}function Ht(){return l("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:l("path",{d:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"})})}function $t(){return X("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:[l("circle",{cx:"18",cy:"5",r:"3"}),l("circle",{cx:"6",cy:"12",r:"3"}),l("circle",{cx:"18",cy:"19",r:"3"}),l("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),l("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]})}function qt(){return l("svg",{viewBox:"0 0 16 16",width:"16",height:"16",style:{display:"inline-block"},children:l("path",{fillRule:"evenodd",d:"M10 13a1 1 0 100-2 1 1 0 000 2zm-4 0a1 1 0 100-2 1 1 0 000 2zm1-5a1 1 0 11-2 0 1 1 0 012 0zm3 1a1 1 0 100-2 1 1 0 000 2zm1-5a1 1 0 11-2 0 1 1 0 012 0zM6 5a1 1 0 100-2 1 1 0 000 2z"})})}function Ft(){return X("svg",{style:{display:"inline-block"},width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l("circle",{cx:"12",cy:"12",r:"10"}),l("line",{x1:"22",y1:"12",x2:"18",y2:"12"}),l("line",{x1:"6",y1:"12",x2:"2",y2:"12"}),l("line",{x1:"12",y1:"6",x2:"12",y2:"2"}),l("line",{x1:"12",y1:"22",x2:"12",y2:"18"})]})}function Vt(){return l("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:l("polyline",{points:"6 9 12 15 18 9"})})}function Wt(){return l("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:l("polyline",{points:"18 15 12 9 6 15"})})}import{jsx as V}from"react/jsx-runtime";var A=rr.forwardRef((e,o)=>V("button",{ref:o,type:"button",className:ce`h-8 px-3 py-2 rounded-md focus:outline-none focus:ring cursor-pointer text-md flex align-middle items-center gap-2 bg-gray-100 hover:bg-gray-200 text-gray-700 disabled:cursor-not-allowed disabled:bg-gray-100! disabled:opacity-50`,...e}));var de=e=>V("button",{className:ce`absolute top-0 right-0 h-12 w-12 bg-red-100 cursor-pointer hover:bg-red-200 text-red-800 text-lg`,children:"\u2715",...e}),Zt=e=>V("button",{className:ce`absolute top-4 left-4 rounded-lg z-10 h-10 w-10 bg-white cursor-pointer hover:bg-gray-100 text-gray-700 text-lg flex items-center justify-center`,...e,children:V(K,{})}),Yt=e=>V("button",{className:ce`absolute top-4 right-4 rounded-lg z-10 h-10 w-10 bg-white cursor-pointer hover:bg-gray-100 text-gray-700 text-lg flex items-center justify-center`,...e,children:V(le,{})});import{tw as W}from"twind";import{jsx as M,jsxs as Jt}from"react/jsx-runtime";var Z=e=>Jt("div",{children:[e.label&&M("label",{className:W`text-gray-700`,htmlFor:e.name,children:e.label}),M("select",{id:e.name,name:e.name,className:W`block w-full px-4 py-2 mt-2 text-gray-700 border bg-white border-gray-200 rounded-md focus:outline-none focus:ring appearance-none text-base`,style:{backgroundImage:`url("data:image/svg+xml,%0A%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3E%3C/svg%3E")`,backgroundPosition:"right 0.75rem center",backgroundSize:"16px 12px",backgroundRepeat:"no-repeat"},...e})]}),Ut=e=>Jt("div",{className:"relative",children:[M("span",{className:W`absolute inset-y-0 left-0 flex items-center pl-3`,children:M(_t,{})}),M("input",{type:"search",className:W`w-full py-2 pl-10 pr-4 text-gray-700 bg-white border border-gray-300 text-base rounded-md focus:outline-none focus:ring`,...e})]}),jt=e=>e.isLoading?M("svg",{width:"20px",height:"20px",viewBox:"0 0 20 20",version:"1.1",className:W`inline text-gray-200 animate-spin dark:text-gray-600`,children:M("g",{stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:M("g",{fill:"#212121",fillRule:"nonzero",children:M("path",{d:"M10,3 C6.13401,3 3,6.13401 3,10 C3,10.2761 2.77614,10.5 2.5,10.5 C2.22386,10.5 2,10.2761 2,10 C2,5.58172 5.58172,2 10,2 C14.4183,2 18,5.58172 18,10 C18,14.4183 14.4183,18 10,18 C9.72386,18 9.5,17.7761 9.5,17.5 C9.5,17.2239 9.72386,17 10,17 C13.866,17 17,13.866 17,10 C17,6.13401 13.866,3 10,3 Z"})})})}):M("input",{type:"checkbox",className:W`w-5 h-5 border-gray-100 focus:outline-none focus:ring focus:ring-blue-300 focus:ring-opacity-80`,name:e.name,checked:e.checked,onChange:e.onChange});import{Tabs as Kt,usePanelState as nr,useTabState as ar}from"@bumaga/tabs";import sr from"clsx";import{tw as pe}from"twind";import{jsx as Ae,jsxs as ir}from"react/jsx-runtime";var ue=({children:e,icon:o})=>{let{onClick:t,isActive:r}=ar(),n=sr(["flex items-center justify-center h-12 px-2 py-2 bg-transparent -mb-px border-b-2 -px-1 whitespace-nowrap focus:outline-none w-full cursor-pointer",{"text-blue-600 border-blue-500":r,"text-gray-700 border-gray-300 hover:border-gray-400":!r}]);return ir("button",{className:pe(n),onClick:t,children:[o,Ae("span",{className:pe`ml-2 text-base`,children:e})]})},me=({children:e})=>nr()?Ae("div",{className:pe`w-full flex flex-grow-1 overflow-auto`,children:e}):null,Xt=({children:e})=>Ae("div",{className:pe`flex flex-shrink-0 border-b border-gray-200 justify-around pr-12`,children:e});import{useT as pr}from"@biodiv-platform/naksha-commons";import{tw as ye}from"twind";import{useT as lr}from"@biodiv-platform/naksha-commons";import{jsx as Qt}from"react/jsx-runtime";function Q({hideLabel:e}){let{layer:{selectionStyle:o,handleSelectStyle:t}}=c(),{t:r}=lr(),n=a=>{t(a.target.value)};return Qt(Z,{name:"layer_selection",label:e?null:r("layer_selection"),defaultValue:o,onChange:n,children:Object.values(T).map(a=>Qt("option",{value:a,children:r(a)},a))})}import cr from"clsx";import{useEffect as dr,useState as eo}from"react";import{tw as fe}from"twind";import{jsx as ee,jsxs as Ge}from"react/jsx-runtime";function Oe({data:e}){let[o,t]=eo(!0),[r,n]=eo({title:e.sourceLayer,properties:[]}),{layer:a,mp:s,query:{clickedLngLat:i}}=c(),u=async()=>{let d,y=a.selectedLayers.find(g=>g.id===(e.sourceLayer||e.source));if(y.layerType.toLowerCase()==="raster"){let{data:g}=await Ct(s.geoserver?.endpoint,s.geoserver?.workspace,{bbox:e.bbox.toString(),query_layers:`${s.geoserver?.workspace}:${y.id}`,layers:`${s.geoserver?.workspace}:${y.id}`});d=g?.features[0]?Object.entries(g.features[0]?.properties).map(([k,w])=>[w||"-"]):[]}else d=Object.entries(y?.data?.propertyMap||{}).map(([g,k])=>[k,e?.properties?.[g]]);n({title:y.title,properties:d})};return dr(()=>{u()},[i]),Ge("div",{className:fe`bg-gray-100 rounded-lg`,children:[Ge("button",{className:fe(cr(["px-4 h-10 flex items-center justify-between bg-gray-100 hover:bg-gray-200 transition-colors cursor-pointer w-full focus:outline-none focus:ring",{"bg-gray-200 rounded-t-lg":o,"rounded-lg":!o}])),onClick:()=>t(!o),children:[r.title," ",o?ee(Wt,{}):ee(Vt,{})]}),o&&ee("div",{className:fe`px-4 py-3 flex flex-col gap-3`,children:r.properties.map(([d,y],g)=>Ge("div",{children:[ee("div",{className:fe`text-gray-600`,children:d}),ee("div",{children:y})]},d+y+g))})]})}import{jsx as Y,jsxs as De}from"react/jsx-runtime";function ze({onClose:e}){let{layer:{selectedFeatures:o,selectedLayers:t,selectionStyle:r}}=c(),{t:n}=pr();return De("div",{className:ye`absolute top-0 right-0 bottom-0 left-0 md:top-4 md:right-4 md:bottom-4 md:left-auto bg-white rounded-lg overflow-hidden shadow-md md:max-w-sm w-full z-20 flex flex-col`,children:[De("div",{className:"flex w-full",children:[De("div",{className:ye`h-12 px-4 flex items-center gap-3 flex-grow bg-gray-200`,children:[Y(Ft,{})," ",n("infobar")]}),Y(de,{onClick:e})]}),Y("div",{className:ye`bg-gray-100 p-4 flex-shrink-0 rt`,children:Y(Q,{hideLabel:!0})}),Y("div",{className:ye`flex flex-col flex-grow overflow-auto gap-3 p-4`,children:o.flat(1)?.map(a=>Y(Oe,{data:a},t?.[0]?.source.type==="raster"||r===T.ALL?a?.sourceLayer:a?.sourceLayer+a?.properties[P]))})]})}import{jsx as to}from"react/jsx-runtime";function He(){let{layer:e,isInfoBarOpen:o,setIsInfoBarOpen:t}=c();if(!e.selectedFeatures?.length)return null;let r=()=>t(!o);return o?to(ze,{onClose:r}):to(Yt,{onClick:r})}import{useEffect as nn,useState as an}from"react";import{useMap as sn}from"react-map-gl/maplibre";import{useT as rn}from"@biodiv-platform/naksha-commons";import{tw as ho}from"twind";import{tw as Hr}from"twind";import Br,{useMemo as Ar}from"react";import{useVirtual as Gr}from"react-virtual";import{AutoSizer as Or}from"react-virtualized-auto-sizer";import{tw as io}from"twind";import{useT as Nr}from"@biodiv-platform/naksha-commons";import{useMemo as Er,useState as so}from"react";import{RWebShare as Rr}from"react-web-share";import{tw as _}from"twind";import{Fragment as oo,jsx as ge}from"react/jsx-runtime";var ro=({text:e="",highlight:o=""})=>{if(!o.trim())return ge(oo,{children:e});let t=new RegExp(`(${o})`,"gi"),r=e.split(t);return ge(oo,{children:r.filter(n=>n).map((n,a)=>t.test(n)?ge("mark",{children:n},a):ge("span",{children:n},a))})};import{tw as hr}from"twind";import{useT as ur}from"@biodiv-platform/naksha-commons";import{useState as mr}from"react";import{tw as fr}from"twind";import{jsx as yr,jsxs as gr}from"react/jsx-runtime";function te({children:e}){let[o,t]=mr(!1),{t:r}=ur();return gr("div",{children:[o&&e,yr("button",{onClick:()=>t(!o),className:fr`text-blue-600 focus:outline-none focus:outline focus:ring`,children:r(o?"less":"legend")})]})}import{jsx as he,jsxs as be}from"react/jsx-runtime";function $e({item:e}){let{layer:o}=c(),t=o.gridLegends[e.id];return t?he(te,{children:be("ul",{style:{margin:0,padding:0},children:[t?.stops.map(([r,n],a,s)=>{let i=(s[a-1]||[0])[0];return i===r?he("div",{},n):be("li",{className:hr`flex gap-2 items-center mb-1`,children:[he("svg",{viewBox:"0 0 24 24",height:"14",width:"14",focusable:"false",children:he("circle",{cx:"12",fill:n,cy:"12",r:"12",stroke:"none"})}),be("div",{children:[i," - ",r]})]},n)}),be("li",{children:["1 Square = ",t?.squareSize," x ",t?.squareSize," km"]})]})}):null}import{LICENSES as br,useT as Lr}from"@biodiv-platform/naksha-commons";import{useState as vr}from"react";import{Popover as xr}from"react-tiny-popover";import{tw as oe}from"twind";import{jsx as h,jsxs as qe}from"react/jsx-runtime";var U=({icon:e,name:o,title:t,link:r,children:n})=>{let a=h("span",{children:n||"-"});return qe("div",{className:oe`flex gap-3 text-sm text-gray-600 break-all`,title:o&&t&&`${o}: ${t}`,children:[h("div",{children:e}),r?h("a",{className:oe`text-blue-700 focus:outline-none focus:ring`,target:"_blank",rel:"noopener",href:r,children:a}):a]})};function Sr({item:e,containerStyle:o}){let{t}=Lr(),{layer:r,mp:n}=c(),a=e.license||"CC-BY",s=e?.createdDate&&new Date(e.createdDate).toLocaleDateString(),i=e.tags?.join(", ");return qe("div",{className:oe`flex flex-col gap-1 bg-white p-4 rounded-lg w-72 border border-gray-300 border-solid`,style:o,children:[n.managePublishing&&e.layerStatus&&qe(U,{icon:h(Ot,{}),name:t("visiblity"),title:e.layerStatus,children:[e.layerStatus,h("button",{className:oe`text-blue-600 focus:outline-none ml-4`,onClick:()=>r.togglePublish(e.id,e?.layerStatus),children:t("toggle")}),h("button",{className:oe`text-red-600 focus:outline-none ml-4`,onClick:()=>r.delete(e.id,t("are_you_sure")),children:t("delete")})]}),h(U,{icon:h(Be,{}),link:e.url,name:t("uploader"),title:e.createdBy,children:e.createdBy}),h(U,{icon:h(Be,{}),link:e.url,name:t("created_by"),title:e.attribution,children:e.attribution}),h(U,{icon:h(Dt,{}),name:t("created_on"),title:s,children:s}),h(U,{icon:h(At,{}),name:t("tags"),title:i,children:i}),h(U,{name:t("license"),title:a,link:a&&br[a],icon:h(Gt,{}),children:a})]})}var no=({item:e})=>{let[o,t]=vr(!1),r=()=>t(!o);return h(xr,{isOpen:o,padding:10,positions:["right"],containerStyle:{zIndex:99},onClickOutside:r,content:h(Sr,{item:e}),children:h(A,{onClick:r,children:h(le,{}),title:"Information"})})};import{tw as Tr}from"twind";import{useMemo as wr,useState as Ir}from"react";import{useT as kr}from"@biodiv-platform/naksha-commons";import{tw as Cr}from"twind";import{jsx as D,jsxs as Pr}from"react/jsx-runtime";function ao({item:e}){let[o,t]=Ir(!0),{mp:r}=c(),{t:n}=kr(),a=wr(()=>e?.data?.styles?.[e.data.styleIndex]?.colors?.paint?.["fill-color"]?.stops||e?.data?.styles?.[e.data.styleIndex]?.colors?.paint?.["circle-color"]?.stops||[],[e]),s=()=>a.map(([i,u])=>Pr("li",{className:Cr`flex gap-2 items-center mb-1`,children:[D("svg",{viewBox:"0 0 24 24",height:"14",width:"14",focusable:"false",children:D("circle",{cx:"12",fill:u,cy:"12",r:"12",stroke:"none"})}),D("div",{children:i})]},u));return D("ul",{style:{margin:0,padding:0},children:e.layerType!=="RASTER"?s():o?D("li",{children:D("img",{style:{margin:"5px"},onError:()=>t(!1),src:`${r?.geoserver?.endpoint}/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&WIDTH=20&HEIGHT=20&STRICT=false&layer=biodiv:${e.id}`})}):D("div",{children:n("raster_style_not_found")})})}import{jsx as Le,jsxs as Mr}from"react/jsx-runtime";function Fe({item:e}){if(!e.data?.styles)return null;let{layer:o}=c(),t=r=>{o.updateStyle(e.id,Number(r.target.value))};return Mr("div",{className:Tr`flex flex-col gap-4 pt-2`,children:[e.layerType!=="RASTER"&&Le(Z,{onChange:t,children:e.data?.styles.map((r,n)=>Le("option",{value:n,children:r.styleTitle},n))}),Le(te,{children:Le(ao,{item:e})})]})}import{jsx as L,jsxs as z}from"react/jsx-runtime";function _r({dragHandleProps:e}){return L("div",{className:_`mt-1 w-6 text-center cursor-move`,style:{touchAction:"none"},...e,children:L(qt,{})})}function re({item:e,extended:o,dragHandleProps:t}){let{t:r}=Nr(),{layer:n,query:a,mp:s,query:{setClickedLngLat:i},setIsInfoBarOpen:u}=c(),[d,y]=so(n.selectedIds.includes(e.id)),[g,k]=so(!1),w=Er(()=>s.canLayerShare?{url:`${window.location.href.split("?")[0]}?layers=${e.id}`,title:e.title}:void 0,[e.id]),N=async()=>{k(!0),u(!0),n.setSelectedFeatures([]),i(null),await n.toggle({layerId:e.id,add:!d}),y(!d),k(!1)},B=async()=>{await Nt(s.nakshaApiEndpoint,s.nakshaEndpointToken,e.id,e.title),s?.onLayerDownload(e.id)},G=()=>n.zoomToExtent(e.id);return z("div",{className:_`z-20 p-3 bg-white`,style:{borderTop:"1px solid #e5e7eb"},children:[z("div",{className:_`flex gap-3`,children:[z("div",{className:_`flex-shrink-0`,children:[L(jt,{name:e.id,checked:d,onChange:N,isLoading:g}),o&&L(_r,{dragHandleProps:t})]}),L("img",{className:_`flex-shrink-0 overflow-hidden h-16 w-16 p-1 mb-2 object-cover border border-gray-200 rounded`,src:e.thumbnail||gt}),z("div",{children:[L("div",{title:e.title,className:_`mb-1 leading-tight`,style:Me,children:L(ro,{text:e.title,highlight:a.term})}),L("p",{title:e.description,className:_`text-gray-600 text-sm`,style:ht,children:e.description})]})]}),z("div",{className:_`flex justify-between`,children:[z(A,{onClick:B,disabled:!e.isDownloadable,children:[L(zt,{})," ",r("download")]}),z("div",{className:_`flex gap-3`,children:[w&&L(Rr,{data:w,children:L(A,{title:"Share",children:L($t,{})})}),o&&L(A,{onClick:G,title:"Zoom To Extent",children:L(Ht,{})}),L(no,{item:e})]})]}),o&&L(Fe,{item:e}),o&&e.source.type==="grid"&&L($e,{item:e})]})}import{jsx as H}from"react/jsx-runtime";function lo(){let{layer:e,query:o}=c(),t=Ar(()=>o.term?e.all.filter(a=>a.title.toLowerCase().includes(o.term.toLowerCase())):e.all,[e.all,o.term]),r=Br.useRef(),n=Gr({size:t.length,parentRef:r});return H("div",{className:io`flex-grow-1 relative`,children:H(Or,{disableWidth:!0,children:a=>H("div",{ref:r,className:"List",style:{height:a.height,overflow:"auto"},children:H("div",{style:{height:n.totalSize,width:"100%",position:"relative"},children:n.virtualItems.map(s=>H("div",{ref:s.measureRef,className:io`absolute top-0 left-0 w-full`,style:{transform:`translateY(${s.start}px)`},children:H("div",{style:{height:146},children:H(re,{item:t[s.index]})})},s.index))})})})})}import{useT as Dr}from"@biodiv-platform/naksha-commons";import{tw as zr}from"twind";import{jsx as co}from"react/jsx-runtime";function Ve(){let{t:e}=Dr(),{query:o}=c(),t=r=>o.setTerm(r.target.value);return co("div",{className:zr`flex-shrink-0 border-b-2 p-4`,children:co(Ut,{name:"lyr_search",placeholder:e("find_layer_by_name"),onChange:t})})}import{jsx as po,jsxs as $r}from"react/jsx-runtime";function We(){return $r("div",{className:Hr`flex flex-col w-full`,children:[po(Ve,{}),po(lo,{})]})}function qr(e,o,t){let r=o<0?e.length+o:o;if(r>=0&&r<e.length){let n=t<0?e.length+t:t,[a]=e.splice(o,1);e.splice(n,0,a)}}function uo(e,o,t){return e=[...e],qr(e,o,t),e}import{closestCenter as Fr,DndContext as Vr,PointerSensor as Wr,useSensor as Zr,useSensors as Yr}from"@dnd-kit/core";import{SortableContext as Ur,useSortable as jr,verticalListSortingStrategy as Jr}from"@dnd-kit/sortable";import{CSS as Kr}from"@dnd-kit/utilities";import{jsx as j}from"react/jsx-runtime";function Xr({item:e,extended:o}){let{attributes:t,listeners:r,setNodeRef:n,transform:a,transition:s,isDragging:i}=jr({id:e.id}),u={transform:Kr.Transform.toString(a),transition:s,opacity:i?.5:1};return j("div",{ref:n,style:u,children:j(re,{item:e,extended:o,dragHandleProps:{...t,...r}})})}var mo=({layerList:e,onSortEnd:o})=>{let t=Yr(Zr(Wr,{activationConstraint:{distance:4}}));return j(Vr,{sensors:t,collisionDetection:Fr,onDragEnd:n=>{let{active:a,over:s}=n;if(s&&a.id!==s.id){let i=e.findIndex(d=>d.id===a.id),u=e.findIndex(d=>d.id===s.id);i!==-1&&u!==-1&&o({oldIndex:i,newIndex:u})}},children:j(Ur,{items:e.map(n=>n.id),strategy:Jr,children:j("div",{children:e.map(n=>j(Xr,{item:n,extended:!0},n.id))})})})};import{useT as Qr}from"@biodiv-platform/naksha-commons";import{tw as fo}from"twind";import{jsx as go,jsxs as yo}from"react/jsx-runtime";function Ze(){let{layer:e}=c(),{t:o}=Qr(),t=({oldIndex:r,newIndex:n})=>{e.setSelectedIds(uo(e.selectedIds,r,n))};return yo("div",{className:fo`flex flex-col gap-3 w-full`,children:[e.selectedIds.length>0&&go("div",{className:fo`p-3 pb-0`,children:yo(A,{onClick:()=>e.clearAll(),children:["\u2715 ",o("clear")]})}),go(mo,{layerList:e.selectedLayers,useDragHandle:!0,onSortEnd:t})]})}import{useT as en}from"@biodiv-platform/naksha-commons";import{tw as tn}from"twind";import{jsx as Ye,jsxs as on}from"react/jsx-runtime";function Ue(){let{layer:e}=c(),{t:o}=en(),t=r=>{e.setMapStyle(r.target.value),e.setMaxZoom(e.mapStyles.find(n=>n.style===r.target.value)?.maxZoom)};return on("div",{className:tn`w-full p-4 flex flex-col gap-4`,children:[Ye(Z,{name:"base_style",label:o("base_style"),defaultValue:e.mapStyle,onChange:t,children:e.mapStyles.map(r=>Ye("option",{value:r.style,children:r.text},r.key))}),Ye(Q,{})]})}import{jsx as S,jsxs as je}from"react/jsx-runtime";function Je({onClose:e}){let{t:o}=rn();return je("div",{className:ho`absolute top-0 right-0 bottom-0 left-0 md:right-auto md:top-4 md:left-4 md:bottom-4 bg-white rounded-lg shadow-md md:max-w-sm w-full z-20 overflow-hidden`,children:[S(de,{onClick:e}),S("div",{className:ho`flex flex-col h-full`,children:je(Kt,{children:[je(Xt,{children:[S(ue,{icon:S(K,{}),children:o("layers")}),S(ue,{icon:S(K,{}),children:o("selected")}),S(ue,{icon:S(Bt,{}),children:o("settings")})]}),S(me,{children:S(We,{})}),S(me,{children:S(Ze,{})}),S(me,{children:S(Ue,{})})]})})]})}import{jsx as bo}from"react/jsx-runtime";function Ke(){let{mp:e,layer:o}=c(),[t,r]=an(e.showToC),{mapl:n}=sn(),a=()=>r(!t);async function s(){let i=await kt(e.nakshaEndpointToken,e.nakshaApiEndpoint,e.geoserver,e.selectedLayers),u=[...e.layers||[],...i];if(o.setAll(u),o.selectedIds.length){let d=u.find(y=>y.id===o.selectedIds[0]);d?.bbox&&n?.fitBounds(d.bbox,{padding:40,duration:1e3})}}return nn(()=>{n&&e.loadToC&&s()},[n]),t?bo(Je,{onClose:a}):bo(Zt,{onClick:a})}import{useMap as Ln}from"react-map-gl/maplibre";import ln from"@turf/bbox";import{useEffect as Xe,useState as cn}from"react";import{Layer as dn,Source as pn,useMap as un}from"react-map-gl/maplibre";import{jsx as Lo}from"react/jsx-runtime";function Qe({data:e,beforeId:o}){let{layer:t}=c(),{mapl:r}=un(),[n,a]=cn({geojson:{},paint:{}}),s=t.selectedIds.includes(e.id),i=t.selectedIds[0]===e.id,u=async(d=!1)=>{let{success:y,geojson:g,paint:k,stops:w,squareSize:N}=await Mt(e.source.fetcher,r?.getBounds(),r?.getZoom());if(y){if(a({geojson:g,paint:k}),d&&i&&e.zoomToFit)try{let[B,G,J,we]=ln(g);r?.fitBounds([[B,G],[J,we]],{padding:40,animate:!0})}catch(B){console.warn("Failed to compute bbox",B)}t.setGridLegends({[e.id]:{stops:w,squareSize:N}})}};return Xe(()=>{s&&i?u(!0):s&&u(!1)},[s,i]),Xe(()=>{if(!s||!r)return;let d=()=>u(!1);return r.on("idle",d),()=>{r.off("idle",d)}},[s,r]),Xe(()=>()=>{t.setGridLegends(d=>{let y={...d};return delete y[e.id],y})},[e.id]),Lo(pn,{id:e.id,type:"geojson",data:n.geojson,children:Lo(dn,{beforeId:o,id:e.id,type:"fill",paint:n.paint})})}import{useMemo as mn}from"react";import{Layer as vo,Source as fn}from"react-map-gl/maplibre";import{jsx as xo,jsxs as gn}from"react/jsx-runtime";var yn={fill:{"line-color":"red","line-width":2},circle:{"circle-stroke-color":"red","circle-stroke-width":2,"circle-opacity":0}};function ve({layer:e,beforeId:o}){let{layer:t}=c(),r=mn(()=>e.data?.styles?.[e.data?.styleIndex]?.colors,[e,t.selectedFeatures]),n=t.selectedFeaturesId?.[e.id];return gn(fn,{...e.source,children:[r&&xo(vo,{beforeId:o,...r}),n&&r&&xo(vo,{...r,beforeId:o,id:`hl_${e.id}`,filter:["in",P,...n],type:r.type==="fill"?"line":r.type,paint:yn[r.type]})]})}import{Layer as hn,Source as bn}from"react-map-gl/maplibre";import{jsx as So}from"react/jsx-runtime";function et({data:e,beforeId:o}){let{mp:t}=c();return So(bn,{id:e.id,type:"raster",tiles:[`${t?.geoserver?.endpoint}/wms?bbox={bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:3857&width=256&height=256&transparent=true&layers=biodiv:${e.id}`],tileSize:256,children:So(hn,{id:e.id,beforeId:o,type:"raster",source:"biodiv",layout:{visibility:"visible"},paint:{}})})}import{jsx as xe}from"react/jsx-runtime";function wo({layer:e,beforeId:o}){let{mapl:t}=Ln();if(!t)return null;switch(e.source.type){case"vector":return xe(ve,{beforeId:o,layer:e});case"grid":return xe(Qe,{beforeId:o,data:e});case"raster":return xe(et,{beforeId:o,data:e});default:return xe(ve,{beforeId:o,layer:e})}}import{useMemo as vn}from"react";import{Marker as xn}from"react-map-gl/maplibre";import{Fragment as In,jsx as tt}from"react/jsx-runtime";var Sn=xn,wn=()=>{let{mp:e}=c(),o=vn(()=>e.markers,[e.markers]);return tt(In,{children:o?.map(({latitude:t,longitude:r,colorHex:n},a)=>tt(Sn,{latitude:t,longitude:r,children:tt("img",{style:{cursor:"pointer"},alt:"Marker",src:"https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon.png"})},a))})},Io=wn;import kn from"clsx";import{Popup as Cn}from"react-map-gl/maplibre";import{tw as ne}from"twind";import{jsx as $,jsxs as ko}from"react/jsx-runtime";var Pn=Cn;function ot({coordinates:e}){let{hover:o}=c();return e?.lat&&o.features?$(Pn,{latitude:e.lat,longitude:e.lng,closeButton:!1,children:ko("table",{className:ne`table-auto border`,children:[$("thead",{children:$("tr",{children:$("th",{className:ne`bg-gray-200 py-1 px-2`,colSpan:2,children:o.features.title})})}),$("tbody",{children:o.features.data.map(([t,r],n)=>ko("tr",{className:ne(kn({"bg-gray-50":n%2===0,"border-gray-100 border-t":1})),children:[$("td",{className:ne`py-1 px-2`,children:t}),$("td",{className:ne`py-1 px-2 border-l border-gray-100`,children:r})]},t+r))})]})}):null}import{jsx as q,jsxs as Co}from"react/jsx-runtime";var An=_n;function rt(){let{mp:e,layer:o,hover:t,query:r}=c(),[n,a]=Nn(),s=Mn(()=>e.defaultViewState||Tn,[e.defaultViewState]),i=d=>r.setClickedLngLat(d.lngLat),u=d=>{a(d.lngLat),t.onHover(d)};return Co("div",{className:Bn`h-full w-full relative bg-gray-100`,children:[e.loadToC&&q(Ke,{}),o.selectedFeatures?.length>0&&q(He,{}),Co(En,{id:"mapl",cursor:"default",initialViewState:s,style:{width:"100%",height:"100%"},mapStyle:o.mapStyle,maxZoom:o.maxZoom,onClick:i,onMouseMove:u,children:[q(An,{position:"bottom-right",showZoom:!0,showCompass:!0}),e.showFullscreenControl&&q(Rn,{position:"bottom-right"}),q(Io,{}),o.selectedLayers.map((d,y)=>{let g=y>0?o.selectedIds[y-1]:void 0;return q(wo,{layer:d,beforeId:g},d.id)}),q(ot,{coordinates:n},"popup")]})]})}import{jsx as Se}from"react/jsx-runtime";zn({preflight:!1});var hc=e=>{let o=On.useMemo(()=>({...yt,...e}),[e]);return Se(Dn,{children:Se(Gn,{localeStrings:ft,lang:o.lang,children:Se(Rt,{mp:o,children:Se(rt,{})})})})};export{hc as NakshaMaplibreLayers};
1
+ import{TranslationProvider as oa}from"@biodiv-platform/naksha-commons";import na from"react";import{MapProvider as aa}from"react-map-gl/maplibre";import{setup as sa}from"twind";var At={are_you_sure:"Are you sure?",base_style:"Base Style",clear:"Clear Selection",created_by:"Attribution",created_on:"Created On",delete:"Delete",download:"Download",find_layer_by_name:"Find layer by name",infobar:"Attributes at Clicked Location",information:"Information",layer_selection:"Layer Selection",layer_selection_all:"All Layers",layer_selection_top:"Top Layer Only",layers:"Layers",legend:"Legend",less:"Less",license:"License",list_layers:"List Layers",pending:"Pending",publish:"Publish",published:"Published",raster_style_not_found:"Style not available for the given layer",remove:"Remove",selected:"Selected",settings:"Settings",square:"Square",tags:"Tags",toggle:"Toggle Publishing",uploaded:"Uploaded",uploader:"Uploader",url:"URL",visiblity:"Visiblity"};var Bt={are_you_sure:"\xCAtes-vous s\xFBr?",base_style:"Style de base",clear:"Effacer la s\xE9lection",created_by:"Attribution",created_on:"Cr\xE9\xE9 sur",delete:"Effacer",download:"T\xE9l\xE9charger",find_layer_by_name:"Trouver la couche par nom",infobar:"Attributs \xE0 l'emplacement cliqu\xE9",information:"Informations",layer_selection_all:"Toutes les couches",layer_selection_top:"Couche sup\xE9rieure uniquement",layer_selection:"S\xE9lection de calque",layers:"Couches",legend:"L\xE9gende",less:"Moins",license:"Licence",list_layers:"Liste des couches",pending:"En attente",publish:"Publier",published:"Publi\xE9",remove:"Supprimer",selected:"Choisie",settings:"Param\xE8tres",square:"Carr\xE9",toggle:"Basculer la publication",uploaded:"T\xE9l\xE9charg\xE9",url:"url"};var Ot={are_you_sure:"\u0915\u094D\u092F\u093E \u0906\u092A\u0915\u094B \u092F\u0915\u0940\u0928 \u0939\u0948?",base_style:"\u0906\u0927\u093E\u0930 \u0936\u0948\u0932\u0940",clear:"\u091A\u092F\u0928 \u0938\u093E\u092B\u093C \u0915\u0930\u0947\u0902",created_by:"\u0906\u0930\u094B\u092A\u0923",created_on:"\u092A\u0930 \u092C\u0928\u093E\u092F\u093E",delete:"\u0939\u091F\u093E\u090F\u0902",download:"\u0921\u093E\u0909\u0928\u0932\u094B\u0921",find_layer_by_name:"\u0928\u093E\u092E \u0938\u0947 \u092A\u0930\u0924 \u0916\u094B\u091C\u0947\u0902",infobar:"\u0915\u094D\u0932\u093F\u0915 \u0915\u093F\u090F \u0917\u090F \u0938\u094D\u0925\u093E\u0928 \u092A\u0930 \u0935\u093F\u0936\u0947\u0937\u0924\u093E\u090F\u0902",information:"\u091C\u093E\u0928\u0915\u093E\u0930\u0940",layer_selection_all:"\u0938\u092D\u0940 \u092A\u0930\u0924\u0947\u0902",layer_selection_top:"\u0915\u0947\u0935\u0932 \u0936\u0940\u0930\u094D\u0937 \u092A\u0930\u0924",layer_selection:"\u092A\u0930\u0924 \u091A\u092F\u0928",layers:"\u092A\u0930\u0924\u0947\u0902",legend:"\u0915\u093F\u0902\u0935\u0926\u0902\u0924\u0940",less:"\u0915\u092E",license:"\u0932\u093E\u0907\u0938\u0947\u0902\u0938",list_layers:"\u0938\u0942\u091A\u0940 \u092A\u0930\u0924\u0947\u0902",pending:"\u0932\u0902\u092C\u093F\u0924",publish:"\u092A\u094D\u0930\u0915\u093E\u0936\u093F\u0924",published:"\u092A\u094D\u0930\u0915\u093E\u0936\u093F\u0924",remove:"\u0939\u091F\u093E\u0928\u093E",selected:"\u091A\u092F\u0928\u093F\u0924",settings:"\u0938\u092E\u093E\u092F\u094B\u091C\u0928",square:"\u0938\u094D\u0915\u094D\u0935\u093E\u092F\u0930",tags:"\u091F\u0948\u0917",toggle:"\u092A\u094D\u0930\u0915\u093E\u0936\u0928 \u091F\u0949\u0917\u0932 \u0915\u0930\u0947\u0902",uploaded:"\u0905\u092A\u0932\u094B\u0921 \u0915\u093F\u092F\u093E \u0917\u092F\u093E",url:"\u092F\u0942\u0906\u0930\u090F\u0932"};var Gt={en:At,fr:Bt,hi:Ot};import{defaultViewState as Yn}from"@biodiv-platform/naksha-commons";import ht,{useEffect as eo,useMemo as Kn,useState as jn}from"react";import Jn,{FullscreenControl as Xn,NavigationControl as Qn}from"react-map-gl/maplibre";import{config as ea}from"maplibre-gl";import{tw as ta}from"twind";import{defaultMapStyles as mo,useDebounce as fo}from"@biodiv-platform/naksha-commons";import yo,{createContext as go,useCallback as C,useContext as ho,useEffect as ke,useMemo as de,useRef as bo,useState as T}from"react";import{useMap as Lo}from"react-map-gl/maplibre";import uo from"colorbrewer";import H from"redaxios";import Ft from"boundingbox";import{GeoHash as Ue}from"geohash";import{MapStyles as so,defaultViewState as io}from"@biodiv-platform/naksha-commons";var Dt={defaultViewState:io,nakshaApiEndpoint:"/naksha-api/api",geoserver:{endpoint:"/geoserver",workspace:"biodiv",store:"ibp"},mapStyle:so.MAP_STREETS,layers:[],selectedLayers:[]},zt="data:image/svg+xml,%3Csvg fill='none' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 72 72'%3E%3Cpath fill='%23fff' d='M0 0h72v72H0z'/%3E%3Cpath d='M35.981 48.293l-13.853-10.77-3.045 2.368L36 53.048l16.917-13.157-3.064-2.387-13.872 10.789zM36 43.519l13.834-10.77 3.083-2.388L36 17.204 19.083 30.36l3.064 2.387L36 43.518z' fill='%23A0AEC0'/%3E%3C/svg%3E",qe={display:"-webkit-box",WebkitLineClamp:1,WebkitBoxOrient:"vertical",overflow:"hidden",wordBreak:"break-word"},Ht={...qe,WebkitLineClamp:2},E="ogc_fid",J={ACTIVE:"Active",PENDING:"Pending"},N={TOP:"layer_selection_top",ALL:"layer_selection_all"};var Se=e=>e<6?[4,1,39.2]:e<7?[5,0,19.6]:e<8?[5,1,9.8]:e<9?[5,-1,4.9]:e<10?[6,0,2.45]:e<11?[6,1,1.225]:e<12?[7,0,.612]:e<13?[7,1,.306]:e<14?[7,-1,.153]:e<15?[8,0,.077]:[8,1,.039],Ve="0123456789bcdefghjkmnpqrstuvwxyz",lo=(e,r,t)=>{t=t||16/2**(1-e.length&1)/4**r;let n=e.slice(0,-1),o=~~(Ve.indexOf(e.slice(-1))/t);return[n+Ve[t*o],n+Ve[t*(o+1)-1]]},co=function(e,r){var t=new Map,n=new Map;let o=[];for(let[a,s]of Object.entries(e)){let[l,c]=lo(a,r);n.set(l,c),t.has(l)||t.set(l,0),t.set(l,t.get(l)+s)}return t.forEach((a,s)=>{let l=Ue.decodeGeoHash(s),c=Ue.decodeGeoHash(n.get(s)),u=new Ft({minlat:l.latitude[0],minlon:l.longitude[0],maxlat:c.latitude[1],maxlon:c.longitude[1]}).toGeoJSON();o.push({...u,properties:{count:a,[E]:s}})}),o},po=e=>{let r=[];for(let[t,n]of Object.entries(e)){let o=Ue.decodeGeoHash(t),a=new Ft({minlat:o.latitude[0],minlon:o.longitude[0],maxlat:o.latitude[1],maxlon:o.longitude[1]}).toGeoJSON();r.push({...a,properties:{count:n,[E]:t}})}return r},$t=(e,r)=>({type:"FeatureCollection",features:Object.keys(e).length===0?[]:r===-1?po(e):co(e,r)}),Wt=(e,r)=>{let t=Object.values(e).sort((a,s)=>a-s),n=Math.floor(t.length/r),o=new Array(r-1).fill(0).map((a,s)=>t[n*(s+1)]);return o.push(t[t.length-1]),o};var qt=async(e,r,t,n)=>Promise.all((e||[]).map(async o=>{let a=n?.includes(o.name),s=o.layerType?.toLowerCase()==="raster",l={...o,id:o.name,thumbnail:r+o.thumbnail,source:{type:s?"raster":"vector",scheme:"tms",tiles:[`${t.endpoint}/gwc/service/tms/1.0.0/${t.workspace}:${o.name}@EPSG%3A900913@pbf/{z}/{x}/{y}.pbf`]},data:{styles:[]},isAdded:a};if(a&&!s){let c=await Ze(l,0,r,t);return{...l,data:c}}return l})),Ze=async(e,r,t,n)=>{let o=e.data||{styles:[]},a=o.layerName,s=o.styles?[...o.styles]:[],l=o.summaryColumn,c=o.titleColumn,u=o.propertyMap;if(s.length===0){let{success:m,data:f}=await Vt(e.id,t);m&&f&&(a=f.layerName,s=(f.styles||[]).map(v=>({...v})),l=f.summaryColumn,c=f.titleColumn,u=Object.fromEntries((f.styles||[]).map(v=>[v.styleName,v.styleTitle])))}if(s[r]&&!s[r]?.colors){let m=await Ut(e.id,n?.workspace,s[r].styleName,t);s[r]={...s[r],colors:m}}return{...o,layerName:a,styles:s,summaryColumn:l,titleColumn:c,propertyMap:u,styleIndex:r}};var Zt=async(e,r,t,n)=>{try{let o=await H.get(`${r}/layer/all`,{headers:{Authorization:e}});return await qt(o.data,r,t,n)}catch(o){return console.error(o),[]}},Vt=async(e,r)=>{try{let{data:t}=await H.get(`${r}/layer/onClick/${e}`);return{success:!0,data:t}}catch(t){return console.error(t),{success:!1}}},Yt=async(e,r,t)=>{let n={service:"WMS",version:"1.1.1",request:"GetFeatureInfo",info_format:"application/json",width:100,height:100,x:50,y:50,srs:"EPSG:4326"};try{return{success:!0,data:(await H.get(`${e}/${r}/wms`,{params:{...t,...n}})).data}}catch(o){return console.error(o),{success:!1,data:[]}}},Kt=async(e,r,t,n)=>{try{return await H.put(`${r}/layer/${n?"active":"pending"}/${t}`,{},{headers:{Authorization:e}}),!0}catch(o){return console.error(o),!1}},jt=async(e,r,t)=>{try{return await H.delete(`${r}/layer/${t}`,{headers:{Authorization:e}}),!0}catch(n){return console.error(n),!1}},Ut=async(e,r,t,n)=>{try{return(await H.get(`${n}/geoserver/workspaces/${r}/styles/${e}_${t}.mbstyle`)).data?.layers?.[0]}catch(o){return console.error(o),{}}},Jt=async(e,r,t,n=6,o="YlOrRd")=>{try{let[a,s,l]=Se(t),{_ne:c,_sw:u}=r,m={top:c.lat,left:u.lng,bottom:u.lat,right:c.lng,geoAggegationPrecision:a},f=await e(m),v=$t(f,s),R=Wt(f,n).map((O,Z)=>[O,uo[o][n][Z]]);return{success:!0,geojson:v,paint:{"fill-color":{property:"count",default:"yellow",stops:R},"fill-outline-color":"rgba(0,0,0,0.2)","fill-opacity":.7},stops:R,squareSize:l}}catch(a){return console.error(a),{success:!1,geojson:{},paint:{},stops:[],squareSize:0}}},Xt=async(e,r,t,n)=>{try{await H.post(`${e}/layer/download`,{layerName:t,layerTitle:n,attributeList:[],filterArray:[]},{headers:{Authorization:r}})}catch(o){console.error(o)}};import{jsx as vo}from"react/jsx-runtime";var Qt=go({}),er=({mp:e,children:r})=>{let[t,n]=T(e),{mapl:o}=Lo();ke(()=>{n(d=>({...d,...e}))},[e]);let[a,s]=T(""),l=fo(a,500),c=t.mapStyles&&t.mapStyles.length>0?t.mapStyles:mo,[u,m]=T(c[t?.mapStyle||0]?.style),[f,v]=T(c[t?.mapStyle||0]?.maxZoom),[S,R]=T(N.TOP),[B,O]=T({}),[Z,he]=T(!0),[k,$e]=T(),[w,M]=T(e.layers||[]),[L,G]=T(t.selectedLayers||[]);ke(()=>{t.selectedLayers&&t.selectedLayers.join(",")!==L.join(",")&&G(t.selectedLayers)},[t.selectedLayers]);let[Y,be]=T(),[Le,Lt]=T(),vt=de(()=>{let d={};for(let y of Le||[])d[y.sourceLayer]=[...d[y.sourceLayer]||[],y?.properties?.[E]];return Object.keys(d).length?d:void 0},[Le]),se=yo.useMemo(()=>{let d=w.filter(g=>L.includes(g.id)),y=new Array(L.length);for(let g of d){let h=L.findIndex(I=>g.id===I);h>-1&&(y[h]=g)}return y},[w,L]),K=C(d=>w.findIndex(y=>y.id===d),[w]),ve=C((d,y)=>{M(g=>g.map(h=>h.id===d?{...h,...y}:h))},[]),xe=C(async(d,y,g)=>{let h=w[d];if(!h)return;let I=await Ze(h,y,t.nakshaApiEndpoint,t.geoserver);ve(h.id,{data:I}),g&&o?.fitBounds(h.bbox,{padding:40,duration:1e3})},[w,t.nakshaApiEndpoint,t.geoserver,ve,o]),xt=C(async(d,y)=>{let g=K(d);xe(g,y,!1)},[K,xe]),wt=C(async d=>{if(!(!L.length||!o))try{let y=L[0],g=o.queryRenderedFeatures(d.point,{layers:[y]});if(g.length){let h=g[0]?.id||g[0]?.properties?.[E];if(h===Y?.id)return;let I=w[K(y)];if(!I)return;let ie=I?.data?.summaryColumn?.map(we=>[I.data?.propertyMap?.[we]||we,g[0].properties?.[we]]);be({id:h,title:I.title,data:ie||[],coordinates:d.lngLat})}else be(h=>h!==void 0?void 0:h)}catch{}},[L,o,Y?.id,w,K]),St=C(async({layerId:d,add:y,styleIndex:g=0,focus:h=!0})=>{if(!y){G(le=>le.filter(ce=>d!==ce));return}let I=K(d),ie=w[I];ie?.source.type==="grid"?(G(le=>[d,...le.filter(ce=>ce!==d)]),h&&ie?.bbox&&setTimeout(()=>{o?.fitBounds(ie.bbox,{padding:40,duration:1e3})},100)):(await xe(I,g,h),G(le=>[d,...le.filter(ce=>ce!==d)]))},[K,w,o,xe]),kt=C(async()=>G([]),[]),It=C((d,y)=>{n(g=>({...g,[d]:y}))},[]),Ct=C((d,y)=>{let g=y===J.PENDING;Kt(t.nakshaEndpointToken,t.nakshaApiEndpoint,d,g),ve(d,{layerStatus:g?J.ACTIVE:J.PENDING})},[t.nakshaEndpointToken,t.nakshaApiEndpoint,ve]),Pt=C(async(d,y)=>{confirm(y)&&(jt(t.nakshaEndpointToken,t.nakshaApiEndpoint,d),M(g=>g.filter(h=>h.id!==d)))},[t.nakshaEndpointToken,t.nakshaApiEndpoint]),Tt=C(d=>{let y=w.find(g=>g.id===d);y?.bbox&&o?.fitBounds(y.bbox,{padding:40,duration:1e3})},[w,o]),We=C(()=>k?[k.lng,k.lat,k.lng+.1,k.lat+.1]:[0,0,0,0],[k]),j=C(d=>{if(!(!k||!o))try{let y=o.project([k.lng,k.lat]),g=o.queryRenderedFeatures(y,{layers:S===N.TOP?[L[0]]:L});if((d||S)===N.ALL){let h=se.filter(I=>I.layerType=="RASTER").map(I=>({sourceLayer:I.id,layerType:"raster",bbox:We()}));g=[...g,...h]}Lt(se?.[0]?.layerType==="RASTER"&&S!==N.ALL?L.length&&g?.length?g:[{sourceLayer:L[0],layerType:"raster",bbox:We()}]:g)}catch(y){console.error(y)}},[k,o,S,L,se,We]),Rt=C(d=>{R(d),d===N.TOP&&j(d)},[j]),Mt=bo(!0);ke(()=>{if(Mt.current){Mt.current=!1;return}t.onSelectedLayersChange&&t.onSelectedLayersChange(L)},[L]),ke(()=>{let d=setTimeout(j,300);return()=>clearTimeout(d)},[k,S,L,j]);let Et=de(()=>({mapStyle:u,featuresAtLatLng:j,setMapStyle:m,maxZoom:f,setMaxZoom:v,mapStyles:c,all:w,setAll:M,selectedIds:L,handleSelectStyle:Rt,setSelectedIds:G,selectedLayers:se,clearAll:kt,toggle:St,updateStyle:xt,selectedFeatures:Le,selectedFeaturesId:vt,setSelectedFeatures:Lt,togglePublish:Ct,delete:Pt,selectionStyle:S,setSelectionStyle:R,zoomToExtent:Tt,gridLegends:B,setGridLegends:O}),[u,j,f,c,w,L,Rt,se,kt,St,xt,Le,vt,Ct,Pt,S,Tt,B]),Nt=de(()=>({term:l,setTerm:s,clickedLngLat:k,setClickedLngLat:$e}),[l,k]),_t=de(()=>({onHover:wt,features:Y}),[wt,Y]),ro=de(()=>({mp:t,updateMP:It,layer:Et,query:Nt,isInfoBarOpen:Z,setIsInfoBarOpen:he,hover:_t}),[t,It,Et,Nt,Z,_t]);return vo(Qt.Provider,{value:ro,children:r})};function p(){return ho(Qt)}import wo from"react";import{tw as Ce}from"twind";import{tw as xo}from"twind";import{jsx as i,jsxs as X}from"react/jsx-runtime";var tr=()=>i("svg",{fill:"none",className:xo`w-5 h-5 text-gray-400`,width:"24",height:"24",viewBox:"0 0 24 24",children:i("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),pe=()=>X("svg",{width:"18",height:"18",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",children:[i("path",{d:"M12 2L2 7 12 12 22 7 12 2z"}),i("path",{d:"M2 17L12 22 22 17"}),i("path",{d:"M2 12L12 17 22 12"})]}),Ie=()=>X("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i("circle",{cx:"12",cy:"12",r:"10"}),i("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),i("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),rr=()=>X("svg",{width:"18",height:"18",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",children:[i("path",{d:"M4 21L4 14"}),i("path",{d:"M4 10L4 3"}),i("path",{d:"M12 21L12 12"}),i("path",{d:"M12 8L12 3"}),i("path",{d:"M20 21L20 16"}),i("path",{d:"M20 12L20 3"}),i("path",{d:"M1 14L7 14"}),i("path",{d:"M9 8L15 8"}),i("path",{d:"M17 16L23 16"})]});function Ye(){return i("svg",{width:"14",height:"14",viewBox:"0 0 16 16",style:{display:"inline-block"},children:i("path",{fillRule:"evenodd",fill:"currentColor",d:"M5.5 3.5a2 2 0 100 4 2 2 0 000-4zM2 5.5a3.5 3.5 0 115.898 2.549 5.507 5.507 0 013.034 4.084.75.75 0 11-1.482.235 4.001 4.001 0 00-7.9 0 .75.75 0 01-1.482-.236A5.507 5.507 0 013.102 8.05 3.49 3.49 0 012 5.5zM11 4a.75.75 0 100 1.5 1.5 1.5 0 01.666 2.844.75.75 0 00-.416.672v.352a.75.75 0 00.574.73c1.2.289 2.162 1.2 2.522 2.372a.75.75 0 101.434-.44 5.01 5.01 0 00-2.56-3.012A3 3 0 0011 4z"})})}function or(){return i("svg",{width:"14",height:"14",viewBox:"0 0 16 16",style:{display:"inline-block"},children:i("path",{fillRule:"evenodd",fill:"currentColor",d:"M2.5 7.775V2.75a.25.25 0 01.25-.25h5.025a.25.25 0 01.177.073l6.25 6.25a.25.25 0 010 .354l-5.025 5.025a.25.25 0 01-.354 0l-6.25-6.25a.25.25 0 01-.073-.177zm-1.5 0V2.75C1 1.784 1.784 1 2.75 1h5.025c.464 0 .91.184 1.238.513l6.25 6.25a1.75 1.75 0 010 2.474l-5.026 5.026a1.75 1.75 0 01-2.474 0l-6.25-6.25A1.75 1.75 0 011 7.775zM6 5a1 1 0 100 2 1 1 0 000-2z"})})}function nr(){return i("svg",{width:"14",height:"14",viewBox:"0 0 16 16",style:{display:"inline-block"},children:i("path",{fillRule:"evenodd",fill:"currentColor",d:"M8.75.75a.75.75 0 00-1.5 0V2h-.984c-.305 0-.604.08-.869.23l-1.288.737A.25.25 0 013.984 3H1.75a.75.75 0 000 1.5h.428L.066 9.192a.75.75 0 00.154.838l.53-.53-.53.53v.001l.002.002.002.002.006.006.016.015.045.04a3.514 3.514 0 00.686.45A4.492 4.492 0 003 11c.88 0 1.556-.22 2.023-.454a3.515 3.515 0 00.686-.45l.045-.04.016-.015.006-.006.002-.002.001-.002L5.25 9.5l.53.53a.75.75 0 00.154-.838L3.822 4.5h.162c.305 0 .604-.08.869-.23l1.289-.737a.25.25 0 01.124-.033h.984V13h-2.5a.75.75 0 000 1.5h6.5a.75.75 0 000-1.5h-2.5V3.5h.984a.25.25 0 01.124.033l1.29.736c.264.152.563.231.868.231h.162l-2.112 4.692a.75.75 0 00.154.838l.53-.53-.53.53v.001l.002.002.002.002.006.006.016.015.045.04a3.517 3.517 0 00.686.45A4.492 4.492 0 0013 11c.88 0 1.556-.22 2.023-.454a3.512 3.512 0 00.686-.45l.045-.04.01-.01.006-.005.006-.006.002-.002.001-.002-.529-.531.53.53a.75.75 0 00.154-.838L13.823 4.5h.427a.75.75 0 000-1.5h-2.234a.25.25 0 01-.124-.033l-1.29-.736A1.75 1.75 0 009.735 2H8.75V.75zM1.695 9.227c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L3 6.327l-1.305 2.9zm10 0c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L13 6.327l-1.305 2.9z"})})}function ar(){return i("svg",{viewBox:"0 0 16 16",width:"14",height:"14",style:{display:"inline-block"},children:i("path",{fillRule:"evenodd",fill:"currentColor",d:"M1.679 7.932c.412-.621 1.242-1.75 2.366-2.717C5.175 4.242 6.527 3.5 8 3.5c1.473 0 2.824.742 3.955 1.715 1.124.967 1.954 2.096 2.366 2.717a.119.119 0 010 .136c-.412.621-1.242 1.75-2.366 2.717C10.825 11.758 9.473 12.5 8 12.5c-1.473 0-2.824-.742-3.955-1.715C2.92 9.818 2.09 8.69 1.679 8.068a.119.119 0 010-.136zM8 2c-1.981 0-3.67.992-4.933 2.078C1.797 5.169.88 6.423.43 7.1a1.619 1.619 0 000 1.798c.45.678 1.367 1.932 2.637 3.024C4.329 13.008 6.019 14 8 14c1.981 0 3.67-.992 4.933-2.078 1.27-1.091 2.187-2.345 2.637-3.023a1.619 1.619 0 000-1.798c-.45-.678-1.367-1.932-2.637-3.023C11.671 2.992 9.981 2 8 2zm0 8a2 2 0 100-4 2 2 0 000 4z"})})}function sr(){return i("svg",{viewBox:"0 0 16 16",width:"14",height:"14",style:{display:"inline-block"},children:i("path",{fillRule:"evenodd",fill:"currentColor",d:"M1.5 8a6.5 6.5 0 1113 0 6.5 6.5 0 01-13 0zM8 0a8 8 0 100 16A8 8 0 008 0zm.5 4.75a.75.75 0 00-1.5 0v3.5a.75.75 0 00.471.696l2.5 1a.75.75 0 00.557-1.392L8.5 7.742V4.75z"})})}function ir(){return i("svg",{viewBox:"0 0 16 16",width:"16",height:"16",style:{display:"inline-block"},children:i("path",{fillRule:"evenodd",fill:"currentColor",d:"M7.47 10.78a.75.75 0 001.06 0l3.75-3.75a.75.75 0 00-1.06-1.06L8.75 8.44V1.75a.75.75 0 00-1.5 0v6.69L4.78 5.97a.75.75 0 00-1.06 1.06l3.75 3.75zM3.75 13a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5z"})})}function lr(){return i("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:i("path",{d:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"})})}function cr(){return X("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:[i("circle",{cx:"18",cy:"5",r:"3"}),i("circle",{cx:"6",cy:"12",r:"3"}),i("circle",{cx:"18",cy:"19",r:"3"}),i("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),i("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]})}function dr(){return i("svg",{viewBox:"0 0 16 16",width:"16",height:"16",style:{display:"inline-block"},children:i("path",{fillRule:"evenodd",d:"M10 13a1 1 0 100-2 1 1 0 000 2zm-4 0a1 1 0 100-2 1 1 0 000 2zm1-5a1 1 0 11-2 0 1 1 0 012 0zm3 1a1 1 0 100-2 1 1 0 000 2zm1-5a1 1 0 11-2 0 1 1 0 012 0zM6 5a1 1 0 100-2 1 1 0 000 2z"})})}function pr(){return X("svg",{style:{display:"inline-block"},width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i("circle",{cx:"12",cy:"12",r:"10"}),i("line",{x1:"22",y1:"12",x2:"18",y2:"12"}),i("line",{x1:"6",y1:"12",x2:"2",y2:"12"}),i("line",{x1:"12",y1:"6",x2:"12",y2:"2"}),i("line",{x1:"12",y1:"22",x2:"12",y2:"18"})]})}function ur(){return i("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:i("polyline",{points:"6 9 12 15 18 9"})})}function mr(){return i("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:i("polyline",{points:"18 15 12 9 6 15"})})}function fr(){return X("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:[i("polyline",{points:"3 6 5 6 21 6"}),i("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),i("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),i("line",{x1:"14",y1:"11",x2:"14",y2:"17"})]})}import{jsx as Q}from"react/jsx-runtime";var D=wo.forwardRef((e,r)=>Q("button",{ref:r,type:"button",className:Ce`h-8 px-3 py-2 rounded-md focus:outline-none focus:ring cursor-pointer text-md flex align-middle items-center gap-2 bg-gray-100 hover:bg-gray-200 text-gray-700 disabled:cursor-not-allowed disabled:bg-gray-100! disabled:opacity-50`,...e}));var Pe=e=>Q("button",{className:Ce`absolute top-0 right-0 h-12 w-12 bg-red-100 cursor-pointer hover:bg-red-200 text-red-800 text-lg`,children:"\u2715",...e}),yr=e=>Q("button",{className:Ce`absolute top-4 left-4 rounded-lg z-10 h-10 w-10 bg-white cursor-pointer hover:bg-gray-100 text-gray-700 text-lg flex items-center justify-center`,...e,children:Q(pe,{})}),gr=e=>Q("button",{className:Ce`absolute top-4 right-4 rounded-lg z-10 h-10 w-10 bg-white cursor-pointer hover:bg-gray-100 text-gray-700 text-lg flex items-center justify-center`,...e,children:Q(Ie,{})});import{tw as ee}from"twind";import{jsx as _,jsxs as Lr}from"react/jsx-runtime";var te=e=>Lr("div",{children:[e.label&&_("label",{className:ee`text-gray-700`,htmlFor:e.name,children:e.label}),_("select",{id:e.name,name:e.name,className:ee`block w-full px-4 py-2 mt-2 text-gray-700 border bg-white border-gray-200 rounded-md focus:outline-none focus:ring appearance-none text-base`,style:{backgroundImage:`url("data:image/svg+xml,%0A%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3E%3C/svg%3E")`,backgroundPosition:"right 0.75rem center",backgroundSize:"16px 12px",backgroundRepeat:"no-repeat"},...e})]}),hr=e=>Lr("div",{className:"relative",children:[_("span",{className:ee`absolute inset-y-0 left-0 flex items-center pl-3`,children:_(tr,{})}),_("input",{type:"search",className:ee`w-full py-2 pl-10 pr-4 text-gray-700 bg-white border border-gray-300 text-base rounded-md focus:outline-none focus:ring`,...e})]}),br=e=>e.isLoading?_("svg",{width:"20px",height:"20px",viewBox:"0 0 20 20",version:"1.1",className:ee`inline text-gray-200 animate-spin dark:text-gray-600`,children:_("g",{stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:_("g",{fill:"#212121",fillRule:"nonzero",children:_("path",{d:"M10,3 C6.13401,3 3,6.13401 3,10 C3,10.2761 2.77614,10.5 2.5,10.5 C2.22386,10.5 2,10.2761 2,10 C2,5.58172 5.58172,2 10,2 C14.4183,2 18,5.58172 18,10 C18,14.4183 14.4183,18 10,18 C9.72386,18 9.5,17.7761 9.5,17.5 C9.5,17.2239 9.72386,17 10,17 C13.866,17 17,13.866 17,10 C17,6.13401 13.866,3 10,3 Z"})})})}):_("input",{type:"checkbox",className:ee`w-5 h-5 border-gray-100 focus:outline-none focus:ring focus:ring-blue-300 focus:ring-opacity-80`,name:e.name,checked:e.checked,onChange:e.onChange});import{Tabs as vr,usePanelState as So,useTabState as ko}from"@bumaga/tabs";import Io from"clsx";import{tw as Te}from"twind";import{jsx as Ke,jsxs as Co}from"react/jsx-runtime";var Re=({children:e,icon:r})=>{let{onClick:t,isActive:n}=ko(),o=Io(["flex items-center justify-center h-12 px-2 py-2 bg-transparent -mb-px border-b-2 -px-1 whitespace-nowrap focus:outline-none w-full cursor-pointer",{"text-blue-600 border-blue-500":n,"text-gray-700 border-gray-300 hover:border-gray-400":!n}]);return Co("button",{className:Te(o),onClick:t,children:[r,Ke("span",{className:Te`ml-2 text-base`,children:e})]})},Me=({children:e})=>So()?Ke("div",{className:Te`w-full flex flex-grow-1 overflow-auto`,children:e}):null,xr=({children:e})=>Ke("div",{className:Te`flex flex-shrink-0 border-b border-gray-200 justify-around pr-12`,children:e});import{tw as re}from"twind";import{jsx as Ee,jsxs as wr}from"react/jsx-runtime";var Sr=({checked:e=!1,onChange:r,disabled:t=!1,label:n,title:o,id:a})=>wr("label",{htmlFor:a,title:o,className:re`inline-flex items-center gap-2 cursor-pointer select-none ${t?"opacity-50 cursor-not-allowed":""}`,children:[n&&Ee("span",{className:re`text-sm text-gray-600 font-normal`,children:n}),wr("span",{className:re`relative inline-flex items-center`,children:[Ee("input",{id:a,type:"checkbox",role:"switch","aria-checked":e,checked:e,disabled:t,onChange:s=>r?.(s.target.checked),className:re`sr-only`}),Ee("div",{className:re`w-8 h-4 rounded-full transition-colors duration-200 ease-in-out ${e?"bg-blue-600":"bg-gray-300"}`}),Ee("div",{className:re`absolute left-0.5 top-0.5 bg-white w-3 h-3 rounded-full shadow-sm transition-transform duration-200 ease-in-out ${e?"transform translate-x-4":""}`})]})]});import{useT as Mo}from"@biodiv-platform/naksha-commons";import{tw as _e}from"twind";import{useT as Po}from"@biodiv-platform/naksha-commons";import{jsx as kr}from"react/jsx-runtime";function ue({hideLabel:e}){let{layer:{selectionStyle:r,handleSelectStyle:t}}=p(),{t:n}=Po(),o=a=>{t(a.target.value)};return kr(te,{name:"layer_selection",label:e?null:n("layer_selection"),defaultValue:r,onChange:o,children:Object.values(N).map(a=>kr("option",{value:a,children:n(a)},a))})}import To from"clsx";import{useEffect as Ro,useState as Ir}from"react";import{tw as Ne}from"twind";import{jsx as me,jsxs as je}from"react/jsx-runtime";function Je({data:e}){let[r,t]=Ir(!0),[n,o]=Ir({title:e.sourceLayer,properties:[]}),{layer:a,mp:s,query:{clickedLngLat:l}}=p(),c=async()=>{let u,m=a.selectedLayers.find(f=>f.id===(e.sourceLayer||e.source));if(m.layerType.toLowerCase()==="raster"){let{data:f}=await Yt(s.geoserver?.endpoint,s.geoserver?.workspace,{bbox:e.bbox.toString(),query_layers:`${s.geoserver?.workspace}:${m.id}`,layers:`${s.geoserver?.workspace}:${m.id}`});u=f?.features[0]?Object.entries(f.features[0]?.properties).map(([v,S])=>[S||"-"]):[]}else u=Object.entries(m?.data?.propertyMap||{}).map(([f,v])=>[v,e?.properties?.[f]||"-"]);o({title:m.title,properties:u})};return Ro(()=>{c()},[l]),je("div",{className:Ne`bg-gray-100 rounded-lg`,children:[je("button",{className:Ne(To(["px-4 h-10 flex items-center justify-between bg-gray-100 hover:bg-gray-200 transition-colors cursor-pointer w-full focus:outline-none focus:ring",{"bg-gray-200 rounded-t-lg":r,"rounded-lg":!r}])),onClick:()=>t(!r),children:[n.title," ",r?me(mr,{}):me(ur,{})]}),r&&me("div",{className:Ne`px-4 py-3 flex flex-col gap-3`,children:n.properties.map(([u,m],f)=>je("div",{children:[me("div",{className:Ne`text-gray-600`,children:u}),me("div",{children:m})]},u+m+f))})]})}import{jsx as oe,jsxs as Xe}from"react/jsx-runtime";function Qe({onClose:e}){let{layer:{selectedFeatures:r,selectedLayers:t,selectionStyle:n}}=p(),{t:o}=Mo();return Xe("div",{className:_e`absolute top-0 right-0 bottom-0 left-0 md:top-4 md:right-4 md:bottom-4 md:left-auto bg-white rounded-lg overflow-hidden shadow-md md:max-w-sm w-full z-20 flex flex-col`,children:[Xe("div",{className:"flex w-full",children:[Xe("div",{className:_e`h-12 px-4 flex items-center gap-3 flex-grow bg-gray-200`,children:[oe(pr,{})," ",o("infobar")]}),oe(Pe,{onClick:e})]}),oe("div",{className:_e`bg-gray-100 p-4 flex-shrink-0 rt`,children:oe(ue,{hideLabel:!0})}),oe("div",{className:_e`flex flex-col flex-grow overflow-auto gap-3 p-4`,children:r.flat(1)?.map(a=>oe(Je,{data:a},t?.[0]?.source.type==="raster"||n===N.ALL?a?.sourceLayer:a?.sourceLayer+a?.properties[E]))})]})}import{jsx as Cr}from"react/jsx-runtime";function et(){let{layer:e,isInfoBarOpen:r,setIsInfoBarOpen:t}=p();if(!e.selectedFeatures?.length)return null;let n=()=>t(!r);return r?Cr(Qe,{onClose:n}):Cr(gr,{onClick:n})}import $r,{useEffect as Wr,useRef as kn,useState as In}from"react";import{useMap as Cn}from"react-map-gl/maplibre";import{useT as Sn}from"@biodiv-platform/naksha-commons";import{tw as Fr}from"twind";import{tw as an}from"twind";import Qo,{useMemo as en}from"react";import{useVirtual as tn}from"react-virtual";import{AutoSizer as rn}from"react-virtualized-auto-sizer";import{tw as Nr}from"twind";import{useT as Ko}from"@biodiv-platform/naksha-commons";import{useMemo as jo,useState as Er}from"react";import{RWebShare as Jo}from"react-web-share";import{tw as A}from"twind";import{Fragment as Pr,jsx as Ae}from"react/jsx-runtime";var Tr=({text:e="",highlight:r=""})=>{if(!r.trim())return Ae(Pr,{children:e});let t=new RegExp(`(${r})`,"gi"),n=e.split(t);return Ae(Pr,{children:n.filter(o=>o).map((o,a)=>t.test(o)?Ae("mark",{children:o},a):Ae("span",{children:o},a))})};import{tw as Oo}from"twind";import{useT as Eo}from"@biodiv-platform/naksha-commons";import{useState as No}from"react";import{tw as _o}from"twind";import{jsx as Ao,jsxs as Bo}from"react/jsx-runtime";function fe({children:e}){let[r,t]=No(!1),{t:n}=Eo();return Bo("div",{children:[r&&e,Ao("button",{onClick:()=>t(!r),className:_o`text-blue-600 focus:outline-none focus:outline focus:ring`,children:n(r?"less":"legend")})]})}import{jsx as Be,jsxs as Oe}from"react/jsx-runtime";function tt({item:e}){let{layer:r}=p(),t=r.gridLegends[e.id];return t?Be(fe,{children:Oe("ul",{style:{margin:0,padding:0},children:[t?.stops.map(([n,o],a,s)=>{let l=(s[a-1]||[0])[0];return l===n?Be("div",{},o):Oe("li",{className:Oo`flex gap-2 items-center mb-1`,children:[Be("svg",{viewBox:"0 0 24 24",height:"14",width:"14",focusable:"false",children:Be("circle",{cx:"12",fill:o,cy:"12",r:"12",stroke:"none"})}),Oe("div",{children:[l," - ",n]})]},o)}),Oe("li",{children:["1 Square = ",t?.squareSize," x ",t?.squareSize," km"]})]})}):null}import{LICENSES as Go,useT as Do}from"@biodiv-platform/naksha-commons";import{useState as zo}from"react";import{Popover as Ho}from"react-tiny-popover";import{tw as F}from"twind";import{jsx as b,jsxs as rt}from"react/jsx-runtime";var ne=({icon:e,name:r,title:t,link:n,children:o})=>{let a=b("span",{className:F`flex-1`,children:o||"-"});return rt("div",{className:F`flex items-center gap-3 text-sm text-gray-600 break-all`,title:r&&t&&`${r}: ${t}`,children:[b("div",{className:F`flex-shrink-0`,children:e}),n?b("a",{className:F`text-blue-700 focus:outline-none focus:ring flex-1`,target:"_blank",rel:"noopener",href:n,children:a}):a]})};function Fo({item:e,containerStyle:r}){let{t}=Do(),{layer:n,mp:o}=p(),a=e.license||"CC-BY",s=e?.createdDate&&new Date(e.createdDate).toLocaleDateString(),l=e.tags?.join(", ");return rt("div",{className:F`flex flex-col gap-1 bg-white p-4 rounded-lg w-72 border border-gray-300 border-solid`,style:r,children:[o.managePublishing&&e.layerStatus&&b(ne,{icon:b(ar,{}),name:t("visiblity"),title:e.layerStatus,children:rt("div",{className:F`flex items-center gap-3`,children:[b("span",{children:e.layerStatus}),b(Sr,{label:t("published"),checked:e.layerStatus?.toLowerCase()===J.ACTIVE.toLowerCase(),onChange:()=>n.togglePublish(e.id,e?.layerStatus)}),b("button",{type:"button",title:t("delete"),className:F`text-red-500 hover:text-red-700 focus:outline-none cursor-pointer flex items-center p-0.5 rounded hover:bg-red-50 transition-colors`,onClick:()=>n.delete(e.id,t("are_you_sure")),children:b(fr,{})})]})}),b(ne,{icon:b(Ye,{}),link:e.url,name:t("uploader"),title:e.createdBy,children:e.createdBy}),b(ne,{icon:b(Ye,{}),link:e.url,name:t("created_by"),title:e.attribution,children:e.attribution}),b(ne,{icon:b(sr,{}),name:t("created_on"),title:s,children:s}),b(ne,{icon:b(or,{}),name:t("tags"),title:l,children:l}),b(ne,{name:t("license"),title:a,link:a&&Go[a],icon:b(nr,{}),children:a})]})}var Rr=({item:e})=>{let[r,t]=zo(!1),n=()=>t(!r);return b(Ho,{isOpen:r,padding:10,positions:["right"],containerStyle:{zIndex:"99"},onClickOutside:n,content:b(Fo,{item:e}),children:b(D,{onClick:n,children:b(Ie,{}),title:"Information"})})};import{tw as Zo}from"twind";import{useMemo as $o,useState as Wo}from"react";import{useT as qo}from"@biodiv-platform/naksha-commons";import{tw as Vo}from"twind";import{jsx as $,jsxs as Uo}from"react/jsx-runtime";function Mr({item:e}){let[r,t]=Wo(!0),{mp:n}=p(),{t:o}=qo(),a=$o(()=>e?.data?.styles?.[e.data.styleIndex]?.colors?.paint?.["fill-color"]?.stops||e?.data?.styles?.[e.data.styleIndex]?.colors?.paint?.["circle-color"]?.stops||[],[e]),s=()=>a.map(([l,c])=>Uo("li",{className:Vo`flex gap-2 items-center mb-1`,children:[$("svg",{viewBox:"0 0 24 24",height:"14",width:"14",focusable:"false",children:$("circle",{cx:"12",fill:c,cy:"12",r:"12",stroke:"none"})}),$("div",{children:l})]},c));return $("ul",{style:{margin:0,padding:0},children:e.layerType!=="RASTER"?s():r?$("li",{children:$("img",{style:{margin:"5px"},onError:()=>t(!1),src:`${n?.geoserver?.endpoint}/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&WIDTH=20&HEIGHT=20&STRICT=false&layer=biodiv:${e.id}`})}):$("div",{children:o("raster_style_not_found")})})}import{jsx as Ge,jsxs as Yo}from"react/jsx-runtime";function ot({item:e}){if(!e.data?.styles)return null;let{layer:r}=p(),t=n=>{r.updateStyle(e.id,Number(n.target.value))};return Yo("div",{className:Zo`flex flex-col gap-4 pt-2`,children:[e.layerType!=="RASTER"&&Ge(te,{onChange:t,children:e.data?.styles.map((n,o)=>Ge("option",{value:o,children:n.styleTitle},o))}),Ge(fe,{children:Ge(Mr,{item:e})})]})}import{jsx as x,jsxs as W}from"react/jsx-runtime";function Xo({dragHandleProps:e}){return x("div",{className:A`mt-1 w-6 text-center cursor-move`,style:{touchAction:"none"},...e,children:x(dr,{})})}function ye({item:e,extended:r,dragHandleProps:t}){let{t:n}=Ko(),{layer:o,query:a,mp:s,query:{setClickedLngLat:l},setIsInfoBarOpen:c}=p(),[u,m]=Er(o.selectedIds.includes(e.id)),[f,v]=Er(!1),S=jo(()=>s.canLayerShare?{url:typeof window<"u"?`${window.location.href.split("?")[0]}?layers=${e.id}`:"",title:e.title}:void 0,[s.canLayerShare,e.id,e.title]),R=async()=>{v(!0),c(!0),o.setSelectedFeatures([]),l(null),await o.toggle({layerId:e.id,add:!u}),m(!u),v(!1)},B=async()=>{await Xt(s.nakshaApiEndpoint,s.nakshaEndpointToken,e.id,e.title),s?.onLayerDownload(e.id)},O=()=>o.zoomToExtent(e.id);return W("div",{className:A`z-20 p-3 bg-white`,style:{borderTop:"1px solid #e5e7eb"},children:[W("div",{className:A`flex gap-3`,children:[W("div",{className:A`flex-shrink-0`,children:[x(br,{name:e.id,checked:u,onChange:R,isLoading:f}),r&&x(Xo,{dragHandleProps:t})]}),x("img",{className:A`flex-shrink-0 overflow-hidden h-16 w-16 p-1 mb-2 object-cover border border-gray-200 rounded`,src:e.thumbnail||zt}),W("div",{children:[x("div",{title:e.title,className:A`mb-1 leading-tight`,style:qe,children:x(Tr,{text:e.title,highlight:a.term})}),x("p",{title:e.description,className:A`text-gray-600 text-sm`,style:Ht,children:e.description})]})]}),W("div",{className:A`flex justify-between`,children:[W(D,{onClick:B,disabled:!e.isDownloadable,children:[x(ir,{})," ",n("download")]}),W("div",{className:A`flex gap-3`,children:[S&&x(Jo,{data:S,children:x(D,{title:"Share",children:x(cr,{})})}),r&&x(D,{onClick:O,title:"Zoom To Extent",children:x(lr,{})}),x(Rr,{item:e})]})]}),r&&x(ot,{item:e}),r&&e.source.type==="grid"&&x(tt,{item:e})]})}import{jsx as q}from"react/jsx-runtime";function _r(){let{layer:e,query:r}=p(),t=en(()=>r.term?e.all.filter(a=>a.title.toLowerCase().includes(r.term.toLowerCase())):e.all,[e.all,r.term]),n=Qo.useRef(null),o=tn({size:t.length,parentRef:n});return q("div",{className:Nr`flex-grow-1 relative`,children:q(rn,{renderProp:a=>q("div",{ref:n,className:"List",style:{height:a.height,overflow:"auto"},children:q("div",{style:{height:o.totalSize,width:"100%",position:"relative"},children:o.virtualItems.map(s=>q("div",{ref:s.measureRef,className:Nr`absolute top-0 left-0 w-full`,style:{transform:`translateY(${s.start}px)`},children:q("div",{style:{height:146},children:q(ye,{item:t[s.index]})})},s.index))})})})})}import{useT as on}from"@biodiv-platform/naksha-commons";import{tw as nn}from"twind";import{jsx as Ar}from"react/jsx-runtime";function nt(){let{t:e}=on(),{query:r}=p(),t=n=>r.setTerm(n.target.value);return Ar("div",{className:nn`flex-shrink-0 border-b-2 p-4`,children:Ar(hr,{name:"lyr_search",placeholder:e("find_layer_by_name"),onChange:t})})}import{jsx as Br,jsxs as sn}from"react/jsx-runtime";function at(){return sn("div",{className:an`flex flex-col w-full`,children:[Br(nt,{}),Br(_r,{})]})}function ln(e,r,t){let n=r<0?e.length+r:r;if(n>=0&&n<e.length){let o=t<0?e.length+t:t,[a]=e.splice(r,1);e.splice(o,0,a)}}function Or(e,r,t){return e=[...e],ln(e,r,t),e}import{closestCenter as cn,DndContext as dn,PointerSensor as pn,useSensor as un,useSensors as mn}from"@dnd-kit/core";import{SortableContext as fn,useSortable as yn,verticalListSortingStrategy as gn}from"@dnd-kit/sortable";import{CSS as hn}from"@dnd-kit/utilities";import{jsx as ae}from"react/jsx-runtime";function bn({item:e,extended:r}){let{attributes:t,listeners:n,setNodeRef:o,transform:a,transition:s,isDragging:l}=yn({id:e.id}),c={transform:hn.Transform.toString(a),transition:s,opacity:l?.5:1};return ae("div",{ref:o,style:c,children:ae(ye,{item:e,extended:r,dragHandleProps:{...t,...n}})})}var Gr=({layerList:e,onSortEnd:r})=>{let t=mn(un(pn,{activationConstraint:{distance:4}}));return ae(dn,{sensors:t,collisionDetection:cn,onDragEnd:o=>{let{active:a,over:s}=o;if(s&&a.id!==s.id){let l=e.findIndex(u=>u.id===a.id),c=e.findIndex(u=>u.id===s.id);l!==-1&&c!==-1&&r({oldIndex:l,newIndex:c})}},children:ae(fn,{items:e.map(o=>o.id),strategy:gn,children:ae("div",{children:e.map(o=>ae(bn,{item:o,extended:!0},o.id))})})})};import{useT as Ln}from"@biodiv-platform/naksha-commons";import{tw as Dr}from"twind";import{jsx as Hr,jsxs as zr}from"react/jsx-runtime";function st(){let{layer:e}=p(),{t:r}=Ln(),t=({oldIndex:n,newIndex:o})=>{e.setSelectedIds(Or(e.selectedIds,n,o))};return zr("div",{className:Dr`flex flex-col gap-3 w-full`,children:[e.selectedIds.length>0&&Hr("div",{className:Dr`p-3 pb-0`,children:zr(D,{onClick:()=>e.clearAll(),children:["\u2715 ",r("clear")]})}),Hr(Gr,{layerList:e.selectedLayers,useDragHandle:!0,onSortEnd:t})]})}import{useT as vn}from"@biodiv-platform/naksha-commons";import{tw as xn}from"twind";import{jsx as it,jsxs as wn}from"react/jsx-runtime";function lt(){let{layer:e}=p(),{t:r}=vn(),t=n=>{e.setMapStyle(n.target.value),e.setMaxZoom(e.mapStyles.find(o=>o.style===n.target.value)?.maxZoom)};return wn("div",{className:xn`w-full p-4 flex flex-col gap-4`,children:[it(te,{name:"base_style",label:r("base_style"),defaultValue:e.mapStyle,onChange:t,children:e.mapStyles.map(n=>it("option",{value:n.style,children:n.text},n.key))}),it(ue,{})]})}import{jsx as P,jsxs as ct}from"react/jsx-runtime";function dt({onClose:e}){let{t:r}=Sn();return ct("div",{className:Fr`absolute top-0 right-0 bottom-0 left-0 md:right-auto md:top-4 md:left-4 md:bottom-4 bg-white rounded-lg shadow-md md:max-w-sm w-full z-20 overflow-hidden`,children:[P(Pe,{onClick:e}),P("div",{className:Fr`flex flex-col h-full`,children:ct(vr,{children:[ct(xr,{children:[P(Re,{icon:P(pe,{}),children:r("layers")}),P(Re,{icon:P(pe,{}),children:r("selected")}),P(Re,{icon:P(rr,{}),children:r("settings")})]}),P(Me,{children:P(at,{})}),P(Me,{children:P(st,{})}),P(Me,{children:P(lt,{})})]})})]})}import{jsx as qr}from"react/jsx-runtime";function pt(){let{mp:e,layer:r}=p(),[t,n]=In(e.showToC),{mapl:o}=Cn(),a=kn(!1),s=$r.useCallback(()=>n(c=>!c),[]),l=$r.useCallback(async()=>{let c=await Zt(e.nakshaEndpointToken,e.nakshaApiEndpoint,e.geoserver,e.selectedLayers),u=[...e.layers||[],...c];if(r.setAll(u),r.selectedIds.length){let m=u.find(f=>f.id===r.selectedIds[0]);m?.bbox&&o?.fitBounds(m.bbox,{padding:40,duration:1e3})}},[e.nakshaEndpointToken,e.nakshaApiEndpoint,e.geoserver,e.selectedLayers,e.layers,r.setAll,r.selectedIds,o]);return Wr(()=>{e.loadToC&&!a.current&&(a.current=!0,l())},[e.loadToC]),Wr(()=>{if(o&&r.selectedIds.length&&r.all?.length){let c=r.all.find(u=>u.id===r.selectedIds[0]);c?.bbox&&o.fitBounds(c.bbox,{padding:40,duration:1e3})}},[o]),t?qr(dt,{onClose:s}):qr(yr,{onClick:s})}import{config as z}from"maplibre-gl";var Vr="https://unpkg.com/maplibre-gl@6.16.0/dist/maplibre-gl-worker.mjs";typeof window<"u"&&!z.WORKER_URL&&(z.WORKER_URL="/maplibre-gl-worker.mjs");var De=null;async function Ur(e){return e?(z.WORKER_URL=e,e):z.WORKER_URL&&z.WORKER_URL!=="/maplibre-gl-worker.mjs"?z.WORKER_URL:typeof window>"u"?"":De||(De=(async()=>{try{let r=await fetch("/maplibre-gl-worker.mjs",{method:"HEAD"}),t=r.headers.get("content-type")||"";if(r.ok&&!t.includes("text/html"))return z.WORKER_URL="/maplibre-gl-worker.mjs","/maplibre-gl-worker.mjs"}catch{}return z.WORKER_URL=Vr,Vr})(),De)}import{useMap as zn}from"react-map-gl/maplibre";import Pn from"@turf/bbox";import{useEffect as ut,useRef as Tn,useState as Rn}from"react";import{Layer as Mn,Source as En,useMap as Nn}from"react-map-gl/maplibre";import{jsx as Zr}from"react/jsx-runtime";function mt({data:e,beforeId:r}){let{layer:t}=p(),{mapl:n}=Nn(),[o,a]=Rn({geojson:{},paint:{}}),s=Tn(""),l=t.selectedIds.includes(e.id),c=t.selectedIds[0]===e.id,u=async(m=!1)=>{if(!n)return;let f=n.getBounds(),v=n.getZoom();if(!f)return;let[S]=Se(v),{_ne:R,_sw:B}=f,O=`${R.lat.toFixed(4)},${B.lng.toFixed(4)},${B.lat.toFixed(4)},${R.lng.toFixed(4)},${S}`;if(O===s.current)return;s.current=O;let{success:Z,geojson:he,paint:k,stops:$e,squareSize:w}=await Jt(e.source.fetcher,f,v);if(Z){if(a({geojson:he,paint:k}),m&&c&&e.zoomToFit)try{let M=Pn(he);if(M.every(Number.isFinite)){let[L,G,Y,be]=M;n.fitBounds([[L,G],[Y,be]],{padding:40,animate:!0})}}catch(M){console.warn("Failed to compute bbox",M)}t.setGridLegends(M=>({...M,[e.id]:{stops:$e,squareSize:w}}))}};return ut(()=>{l&&c?u(!0):l&&u(!1)},[l,c]),ut(()=>{if(!l||!n)return;let m=()=>u(!1);return n.on("moveend",m),()=>{n.off("moveend",m)}},[l,n]),ut(()=>()=>{t.setGridLegends(m=>{let f={...m};return delete f[e.id],f})},[e.id]),Zr(En,{id:e.id,type:"geojson",data:o.geojson,children:Zr(Mn,{beforeId:r,id:e.id,type:"fill",paint:o.paint})})}import{useMemo as _n}from"react";import{Layer as Yr,Source as An}from"react-map-gl/maplibre";import{jsx as Kr,jsxs as On}from"react/jsx-runtime";var Bn={fill:{"line-color":"red","line-width":2},circle:{"circle-stroke-color":"red","circle-stroke-width":2,"circle-opacity":0}};function ze({layer:e,beforeId:r}){let{layer:t}=p(),n=_n(()=>e.data?.styles?.[e.data?.styleIndex]?.colors,[e,t.selectedFeatures]),o=t.selectedFeaturesId?.[e.id];return On(An,{...e.source,children:[n&&Kr(Yr,{beforeId:r,...n}),o&&n&&Kr(Yr,{...n,beforeId:r,id:`hl_${e.id}`,filter:["in",E,...o],type:n.type==="fill"?"line":n.type,paint:Bn[n.type]})]})}import{Layer as Gn,Source as Dn}from"react-map-gl/maplibre";import{jsx as jr}from"react/jsx-runtime";function ft({data:e,beforeId:r}){let{mp:t}=p();return jr(Dn,{id:e.id,type:"raster",tiles:[`${t?.geoserver?.endpoint}/wms?bbox={bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:3857&width=256&height=256&transparent=true&layers=biodiv:${e.id}`],tileSize:256,children:jr(Gn,{id:e.id,beforeId:r,type:"raster",source:"biodiv",layout:{visibility:"visible"},paint:{}})})}import{jsx as He}from"react/jsx-runtime";function Jr({layer:e,beforeId:r}){let{mapl:t}=zn();if(!t)return null;switch(e.source.type){case"vector":return He(ze,{beforeId:r,layer:e});case"grid":return He(mt,{beforeId:r,data:e});case"raster":return He(ft,{beforeId:r,data:e});default:return He(ze,{beforeId:r,layer:e})}}import{useMemo as Hn}from"react";import{Marker as Fn}from"react-map-gl/maplibre";import{Fragment as qn,jsx as yt}from"react/jsx-runtime";var $n=Fn,Wn=()=>{let{mp:e}=p(),r=Hn(()=>e.markers,[e.markers]);return yt(qn,{children:r?.map(({latitude:t,longitude:n,colorHex:o,anchor:a="bottom",iconUrl:s},l)=>yt($n,{latitude:t,longitude:n,anchor:a,subpixelPositioning:!0,children:yt("img",{style:{cursor:"pointer",display:"block",width:"25px",height:"41px"},width:25,height:41,alt:"Marker",src:s||"https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon.png"})},l))})},Xr=Wn;import Vn from"clsx";import{Popup as Un}from"react-map-gl/maplibre";import{tw as ge}from"twind";import{jsx as V,jsxs as Qr}from"react/jsx-runtime";var Zn=Un;function gt({coordinates:e}){let{hover:r}=p(),t=e||r.features?.coordinates;return t?.lat&&r.features?V(Zn,{latitude:t.lat,longitude:t.lng,closeButton:!1,children:Qr("table",{className:ge`table-auto border`,children:[V("thead",{children:V("tr",{children:V("th",{className:ge`bg-gray-200 py-1 px-2`,colSpan:2,children:r.features.title})})}),V("tbody",{children:r.features.data.map(([n,o],a)=>Qr("tr",{className:ge(Vn({"bg-gray-50":a%2===0,"border-gray-100 border-t":1})),children:[V("td",{className:ge`py-1 px-2`,children:n}),V("td",{className:ge`py-1 px-2 border-l border-gray-100`,children:o})]},n+o))})]})}):null}import{jsx as U,jsxs as to}from"react/jsx-runtime";var ra=Qn;function bt(){let{mp:e,layer:r,hover:t,query:n}=p(),[o,a]=jn(e.workerUrl||(typeof window<"u"?ea.WORKER_URL||"/maplibre-gl-worker.mjs":void 0));eo(()=>{Ur(e.workerUrl).then(a)},[e.workerUrl]);let s=Kn(()=>e.defaultViewState||Yn,[e.defaultViewState]),l=ht.useCallback(m=>n.setClickedLngLat(m.lngLat),[n]),c=ht.useRef(null),u=ht.useCallback(m=>{c.current||(c.current=requestAnimationFrame(()=>{c.current=null,t.onHover(m)}))},[t]);return eo(()=>()=>{c.current&&cancelAnimationFrame(c.current)},[]),to("div",{className:ta`h-full w-full relative bg-gray-100`,children:[e.loadToC&&U(pt,{}),r.selectedFeatures?.length>0&&U(et,{}),to(Jn,{id:"mapl",workerUrl:o,cursor:"default",initialViewState:s,style:{width:"100%",height:"100%"},mapStyle:r.mapStyle,maxZoom:r.maxZoom,onClick:l,onMouseMove:u,children:[U(ra,{position:"bottom-right",showZoom:!0,showCompass:!0}),e.showFullscreenControl&&U(Xn,{position:"bottom-right"}),U(Xr,{}),r.selectedLayers.map((m,f)=>{let v=f>0?r.selectedIds[f-1]:void 0;return U(Jr,{layer:m,beforeId:v},m.id)}),U(gt,{},"popup")]})]})}import{jsx as Fe}from"react/jsx-runtime";sa({preflight:!1});var Vc=e=>{let r=na.useMemo(()=>({...Dt,...e}),[e]);return Fe(aa,{children:Fe(oa,{localeStrings:Gt,lang:r.lang,children:Fe(er,{mp:r,children:Fe(bt,{})})})})};export{Vc as NakshaMaplibreLayers};
package/locales/en.json CHANGED
@@ -19,6 +19,7 @@
19
19
  "list_layers": "List Layers",
20
20
  "pending": "Pending",
21
21
  "publish": "Publish",
22
+ "published": "Published",
22
23
  "raster_style_not_found": "Style not available for the given layer",
23
24
  "remove": "Remove",
24
25
  "selected": "Selected",
package/locales/fr.json CHANGED
@@ -19,6 +19,7 @@
19
19
  "list_layers": "Liste des couches",
20
20
  "pending": "En attente",
21
21
  "publish": "Publier",
22
+ "published": "Publié",
22
23
  "remove": "Supprimer",
23
24
  "selected": "Choisie",
24
25
  "settings": "Paramètres",
package/locales/hi.json CHANGED
@@ -19,6 +19,7 @@
19
19
  "list_layers": "सूची परतें",
20
20
  "pending": "लंबित",
21
21
  "publish": "प्रकाशित",
22
+ "published": "प्रकाशित",
22
23
  "remove": "हटाना",
23
24
  "selected": "चयनित",
24
25
  "settings": "समायोजन",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@biodiv-platform/naksha-maplibre-layers",
3
- "version": "5.0.9-beta.0",
3
+ "version": "5.0.10",
4
4
  "type": "module",
5
5
  "author": "harshzalavadiya",
6
6
  "main": "./dist/index.cjs",
@@ -42,8 +42,8 @@
42
42
  "react-map-gl": "^8.1.3",
43
43
  "tsup": "^9.0.0",
44
44
  "typescript": "^5.8.3",
45
- "@biodiv-platform/eslint-preset": "4.4.9",
46
- "@biodiv-platform/tsconfig": "4.4.9"
45
+ "@biodiv-platform/eslint-preset": "4.5.0",
46
+ "@biodiv-platform/tsconfig": "4.5.0"
47
47
  },
48
48
  "dependencies": {
49
49
  "@bumaga/tabs": "^0.2.0",
@@ -60,7 +60,7 @@
60
60
  "react-web-share": "^2.0.2",
61
61
  "redaxios": "^0.5.1",
62
62
  "twind": "^0.16.19",
63
- "@biodiv-platform/naksha-commons": "5.0.0-beta.3"
63
+ "@biodiv-platform/naksha-commons": "5.0.0"
64
64
  },
65
65
  "scripts": {
66
66
  "clean": "rm -rf node_modules dist .turbo",