@biodiv-platform/naksha-maplibre-layers 5.0.11 → 5.0.12-beta.0
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 +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Jo=Object.create;var Ze=Object.defineProperty;var Xo=Object.getOwnPropertyDescriptor;var Qo=Object.getOwnPropertyNames;var en=Object.getPrototypeOf,tn=Object.prototype.hasOwnProperty;var rn=(e,t)=>{for(var r in t)Ze(e,r,{get:t[r],enumerable:!0})},ar=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Qo(t))!tn.call(e,o)&&o!==r&&Ze(e,o,{get:()=>t[o],enumerable:!(n=Xo(t,o))||n.enumerable});return e};var T=(e,t,r)=>(r=e!=null?Jo(en(e)):{},ar(t||!e||!e.__esModule?Ze(r,"default",{value:e,enumerable:!0}):r,e)),on=e=>ar(Ze({},"__esModule",{value:!0}),e);var kn={};rn(kn,{NakshaMaplibreLayers:()=>Sn});module.exports=on(kn);var Uo=require("@biodiv-platform/naksha-commons"),Zo=T(require("react"),1),jo=require("react-map-gl/maplibre"),Yo=require("twind");var sr={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 ir={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 lr={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 cr={en:sr,fr:ir,hi:lr};var Wo=require("@biodiv-platform/naksha-commons"),N=T(require("react"),1),V=T(require("react-map-gl/maplibre"),1),qo=require("maplibre-gl"),Vo=require("twind");var Xe=require("@biodiv-platform/naksha-commons"),c=T(require("react"),1),Ir=require("react-map-gl/maplibre");var br=T(require("colorbrewer"),1),X=T(require("redaxios"),1);var ft=T(require("boundingbox"),1),Ye=require("geohash");var je=require("@biodiv-platform/naksha-commons"),dr={defaultViewState:je.defaultViewState,nakshaApiEndpoint:"/naksha-api/api",geoserver:{endpoint:"/geoserver",workspace:"biodiv",store:"ibp"},mapStyle:je.MapStyles.MAP_STREETS,layers:[],selectedLayers:[]},pr="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",ut={display:"-webkit-box",WebkitLineClamp:1,WebkitBoxOrient:"vertical",overflow:"hidden",wordBreak:"break-word"},ur={...ut,WebkitLineClamp:2},G="ogc_fid",me={ACTIVE:"Active",PENDING:"Pending"},D={TOP:"layer_selection_top",ALL:"layer_selection_all"};var Ke=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],mt="0123456789bcdefghjkmnpqrstuvwxyz",ln=(e,t,r)=>{r=r||16/2**(1-e.length&1)/4**t;let n=e.slice(0,-1),o=~~(mt.indexOf(e.slice(-1))/r);return[n+mt[r*o],n+mt[r*(o+1)-1]]},yt=e=>typeof e=="number"?{count:e}:e,cn=(e,t)=>{for(let[r,n]of Object.entries(t))e[r]=(e[r]||0)+n;return e},dn=function(e,t){var r=new Map,n=new Map;let o=[];for(let[a,s]of Object.entries(e)){let[l,p]=ln(a,t);n.set(l,p),r.set(l,cn(r.get(l)||{},yt(s)))}return r.forEach((a,s)=>{let l=Ye.GeoHash.decodeGeoHash(s),p=Ye.GeoHash.decodeGeoHash(n.get(s)),m=new ft.default({minlat:l.latitude[0],minlon:l.longitude[0],maxlat:p.latitude[1],maxlon:p.longitude[1]}).toGeoJSON();o.push({...m,properties:{...a,[G]:s}})}),o},pn=e=>{let t=[];for(let[r,n]of Object.entries(e)){let o=Ye.GeoHash.decodeGeoHash(r),a=new ft.default({minlat:o.latitude[0],minlon:o.longitude[0],maxlat:o.latitude[1],maxlon:o.longitude[1]}).toGeoJSON();t.push({...a,properties:{...yt(n),[G]:r}})}return t},mr=(e,t)=>({type:"FeatureCollection",features:Object.keys(e).length===0?[]:t===-1?pn(e):dn(e,t)}),fr=(e,t)=>{let r=Object.values(e).map(a=>yt(a).count).sort((a,s)=>a-s),n=Math.floor(r.length/t),o=new Array(t-1).fill(0).map((a,s)=>r[n*(s+1)]);return o.push(r[r.length-1]),o},Je=e=>{let t=[],r=a=>typeof a[0]=="number"?t.push(a):a.forEach(r);if(r(e?.geometry?.coordinates||[]),!t.length)return;let n=t.map(([a])=>a),o=t.map(([,a])=>a);return[Math.min(...n),Math.min(...o),Math.max(...n),Math.max(...o)]};var yr=async(e,t,r,n)=>Promise.all((e||[]).map(async o=>{let a=n?.includes(o.name),s=o.layerType?.toLowerCase()==="raster",l={...o,id:o.name,thumbnail:t+o.thumbnail,source:{type:s?"raster":"vector",scheme:"tms",tiles:[`${r.endpoint}/gwc/service/tms/1.0.0/${r.workspace}:${o.name}@EPSG%3A900913@pbf/{z}/{x}/{y}.pbf`]},data:{styles:[]},isAdded:a};if(a&&!s){let p=await gt(l,0,t,r);return{...l,data:p}}return l})),gt=async(e,t,r,n)=>{let o=e.data||{styles:[]},a=o.layerName,s=o.styles?[...o.styles]:[],l=o.summaryColumn,p=o.titleColumn,m=o.propertyMap;if(s.length===0){let{success:y,data:h}=await gr(e.id,r);y&&h&&(a=h.layerName,s=(h.styles||[]).map(b=>({...b})),l=h.summaryColumn,p=h.titleColumn,m=Object.fromEntries((h.styles||[]).map(b=>[b.styleName,b.styleTitle])))}if(s[t]&&!s[t]?.colors){let y=await hr(e.id,n?.workspace,s[t].styleName,r);s[t]={...s[t],colors:y}}return{...o,layerName:a,styles:s,summaryColumn:l,titleColumn:p,propertyMap:m,styleIndex:t}};var Lr=async(e,t,r,n)=>{try{let o=await X.default.get(`${t}/layer/all`,{headers:{Authorization:e}});return await yr(o.data,t,r,n)}catch(o){return console.error(o),[]}},gr=async(e,t)=>{try{let{data:r}=await X.default.get(`${t}/layer/onClick/${e}`);return{success:!0,data:r}}catch(r){return console.error(r),{success:!1}}},vr=async(e,t,r)=>{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 X.default.get(`${e}/${t}/wms`,{params:{...r,...n}})).data}}catch(o){return console.error(o),{success:!1,data:[]}}},xr=async(e,t,r,n)=>{try{return await X.default.put(`${t}/layer/${n?"active":"pending"}/${r}`,{},{headers:{Authorization:e}}),!0}catch(o){return console.error(o),!1}},wr=async(e,t,r)=>{try{return await X.default.delete(`${t}/layer/${r}`,{headers:{Authorization:e}}),!0}catch(n){return console.error(n),!1}},hr=async(e,t,r,n)=>{try{return(await X.default.get(`${n}/geoserver/workspaces/${t}/styles/${e}_${r}.mbstyle`)).data?.layers?.[0]}catch(o){return console.error(o),{}}},un=(e,t)=>["step",["get","count"],e[0],...t.flatMap((r,n)=>[r,e[n+1]])],Sr=async(e,t,r,n=6,o="YlOrRd",a={})=>{try{let[s,l,p]=Ke(r),{_ne:m,_sw:y}=t,h={top:m.lat,left:y.lng,bottom:y.lat,right:m.lng,geoAggegationPrecision:s},b=await e(h),x=mr(b,l),I=a.colors?.length&&a.breaks?.length===a.colors.length-1,B=I?a.colors.map((Y,U)=>[a.breaks[U]?a.breaks[U]-1:1/0,Y]):fr(b,n).map((Y,U)=>[Y,br.default[o][n][U]]),j={"fill-color":I?un(a.colors,a.breaks):{property:"count",default:"yellow",stops:B},"fill-outline-color":a.outlineColor||"rgba(0,0,0,0.2)","fill-opacity":a.opacity??.7};return{success:!0,geojson:x,paint:j,stops:B,squareSize:p}}catch(s){return console.error(s),{success:!1,geojson:{},paint:{},stops:[],squareSize:0}}},kr=async(e,t,r,n)=>{try{await X.default.post(`${e}/layer/download`,{layerName:r,layerTitle:n,attributeList:[],filterArray:[]},{headers:{Authorization:t}})}catch(o){console.error(o)}};var Rr=require("react/jsx-runtime"),Cr=(0,c.createContext)({}),Pr=({mp:e,children:t})=>{let[r,n]=(0,c.useState)(e),{mapl:o}=(0,Ir.useMap)();(0,c.useEffect)(()=>{n(d=>({...d,...e}))},[e]);let[a,s]=(0,c.useState)(""),l=(0,Xe.useDebounce)(a,500),p=r.mapStyles&&r.mapStyles.length>0?r.mapStyles:Xe.defaultMapStyles,[m,y]=(0,c.useState)(p[r?.mapStyle||0]?.style),[h,b]=(0,c.useState)(p[r?.mapStyle||0]?.maxZoom),[x,I]=(0,c.useState)(D.TOP),[B,j]=(0,c.useState)({}),[Y,U]=(0,c.useState)(!0),[R,dt]=(0,c.useState)(),[C,O]=(0,c.useState)(e.layers||[]),[S,K]=(0,c.useState)(r.selectedLayers||[]);(0,c.useEffect)(()=>{r.selectedLayers&&r.selectedLayers.join(",")!==S.join(",")&&K(r.selectedLayers)},[r.selectedLayers]);let[J,$e]=(0,c.useState)(),[We,qt]=(0,c.useState)(),Vt=(0,c.useMemo)(()=>{let d={};for(let f of We||[])d[f.sourceLayer]=[...d[f.sourceLayer]||[],f?.properties?.[G]];return Object.keys(d).length?d:void 0},[We]),Se=c.default.useMemo(()=>{let d=C.filter(g=>S.includes(g.id)),f=new Array(S.length);for(let g of d){let w=S.findIndex(P=>g.id===P);w>-1&&(f[w]=g)}return f},[C,S]),pe=(0,c.useCallback)(d=>C.findIndex(f=>f.id===d),[C]),qe=(0,c.useCallback)((d,f)=>{O(g=>g.map(w=>w.id===d?{...w,...f}:w))},[]),Ve=(0,c.useCallback)(async(d,f,g)=>{let w=C[d];if(!w)return;let P=await gt(w,f,r.nakshaApiEndpoint,r.geoserver);qe(w.id,{data:P}),g&&o?.fitBounds(w.bbox,{padding:40,duration:1e3})},[C,r.nakshaApiEndpoint,r.geoserver,qe,o]),Ut=(0,c.useCallback)(async(d,f)=>{let g=pe(d);Ve(g,f,!1)},[pe,Ve]),Zt=(0,c.useCallback)(async d=>{if(!(!S.length||!o))try{let f=S[0],g=o.queryRenderedFeatures(d.point,{layers:[f]});if(g.length){let w=g[0]?.id||g[0]?.properties?.[G];if(w===J?.id&&f===J?.layerId)return;let P=C[pe(f)];if(!P)return;let ke=P?.data?.summaryColumn?.map(Ue=>[P.data?.propertyMap?.[Ue]||Ue,g[0].properties?.[Ue]]);$e({id:w,layerId:f,title:P.title,data:ke||[],coordinates:d.lngLat,content:P?.onHover?.({bbox:Je(g[0]),feature:g[0],layerId:f})})}else $e(w=>w!==void 0?void 0:w)}catch{}},[S,o,J?.id,J?.layerId,C,pe]),jt=(0,c.useCallback)(async({layerId:d,add:f,styleIndex:g=0,focus:w=!0})=>{if(!f){K(Ie=>Ie.filter(Ce=>d!==Ce));return}let P=pe(d),ke=C[P];ke?.source.type==="grid"?(K(Ie=>[d,...Ie.filter(Ce=>Ce!==d)]),w&&ke?.bbox&&setTimeout(()=>{o?.fitBounds(ke.bbox,{padding:40,duration:1e3})},100)):(await Ve(P,g,w),K(Ie=>[d,...Ie.filter(Ce=>Ce!==d)]))},[pe,C,o,Ve]),Yt=(0,c.useCallback)(async()=>K([]),[]),Kt=(0,c.useCallback)((d,f)=>{n(g=>({...g,[d]:f}))},[]),Jt=(0,c.useCallback)((d,f)=>{let g=f===me.PENDING;xr(r.nakshaEndpointToken,r.nakshaApiEndpoint,d,g),qe(d,{layerStatus:g?me.ACTIVE:me.PENDING})},[r.nakshaEndpointToken,r.nakshaApiEndpoint,qe]),Xt=(0,c.useCallback)(async(d,f)=>{confirm(f)&&(wr(r.nakshaEndpointToken,r.nakshaApiEndpoint,d),O(g=>g.filter(w=>w.id!==d)))},[r.nakshaEndpointToken,r.nakshaApiEndpoint]),Qt=(0,c.useCallback)(d=>{let f=C.find(g=>g.id===d);f?.bbox&&o?.fitBounds(f.bbox,{padding:40,duration:1e3})},[C,o]),pt=(0,c.useCallback)(()=>R?[R.lng,R.lat,R.lng+.1,R.lat+.1]:[0,0,0,0],[R]),ue=(0,c.useCallback)(d=>{if(!(!R||!o))try{let f=o.project([R.lng,R.lat]),g=o.queryRenderedFeatures(f,{layers:x===D.TOP?[S[0]]:S});if((d||x)===D.ALL){let w=Se.filter(P=>P.layerType=="RASTER").map(P=>({sourceLayer:P.id,layerType:"raster",bbox:pt()}));g=[...g,...w]}qt(Se?.[0]?.layerType==="RASTER"&&x!==D.ALL?S.length&&g?.length?g:[{sourceLayer:S[0],layerType:"raster",bbox:pt()}]:g)}catch(f){console.error(f)}},[R,o,x,S,Se,pt]),er=(0,c.useCallback)(d=>{I(d),d===D.TOP&&ue(d)},[ue]),tr=(0,c.useRef)(!0);(0,c.useEffect)(()=>{if(tr.current){tr.current=!1;return}r.onSelectedLayersChange&&r.onSelectedLayersChange(S)},[S]),(0,c.useEffect)(()=>{let d=setTimeout(ue,300);return()=>clearTimeout(d)},[R,x,S,ue]);let rr=(0,c.useMemo)(()=>({mapStyle:m,featuresAtLatLng:ue,setMapStyle:y,maxZoom:h,setMaxZoom:b,mapStyles:p,all:C,setAll:O,selectedIds:S,handleSelectStyle:er,setSelectedIds:K,selectedLayers:Se,clearAll:Yt,toggle:jt,updateStyle:Ut,selectedFeatures:We,selectedFeaturesId:Vt,setSelectedFeatures:qt,togglePublish:Jt,delete:Xt,selectionStyle:x,setSelectionStyle:I,zoomToExtent:Qt,gridLegends:B,setGridLegends:j}),[m,ue,h,p,C,S,er,Se,Yt,jt,Ut,We,Vt,Jt,Xt,x,Qt,B]),or=(0,c.useMemo)(()=>({term:l,setTerm:s,clickedLngLat:R,setClickedLngLat:dt}),[l,R]),nr=(0,c.useMemo)(()=>({onHover:Zt,features:J}),[Zt,J]),Ko=(0,c.useMemo)(()=>({mp:r,updateMP:Kt,layer:rr,query:or,isInfoBarOpen:Y,setIsInfoBarOpen:U,hover:nr}),[r,Kt,rr,or,Y,nr]);return(0,Rr.jsx)(Cr.Provider,{value:Ko,children:t})};function u(){return(0,c.useContext)(Cr)}var qr=T(require("react"),1),Re=require("twind");var Tr=require("twind"),i=require("react/jsx-runtime"),Mr=()=>(0,i.jsx)("svg",{fill:"none",className:Tr.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"})}),Pe=()=>(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"})]}),Qe=()=>(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"})]}),Er=()=>(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 ht(){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 Nr(){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 _r(){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 Ar(){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 Br(){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 Or(){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 Gr(){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 Dr(){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 Hr(){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 zr(){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 Fr(){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 $r(){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 Wr(){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 ae=require("react/jsx-runtime"),Q=qr.default.forwardRef((e,t)=>(0,ae.jsx)("button",{ref:t,type:"button",className:Re.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 et=e=>(0,ae.jsx)("button",{className:Re.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}),Vr=e=>(0,ae.jsx)("button",{className:Re.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,ae.jsx)(Pe,{})}),Ur=e=>(0,ae.jsx)("button",{className:Re.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,ae.jsx)(Qe,{})});var se=require("twind");var M=require("react/jsx-runtime");var fe=e=>(0,M.jsxs)("div",{children:[e.label&&(0,M.jsx)("label",{className:se.tw`text-gray-700`,htmlFor:e.name,children:e.label}),(0,M.jsx)("select",{id:e.name,name:e.name,className:se.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})]}),Zr=e=>(0,M.jsxs)("div",{className:"relative",children:[(0,M.jsx)("span",{className:se.tw`absolute inset-y-0 left-0 flex items-center pl-3`,children:(0,M.jsx)(Mr,{})}),(0,M.jsx)("input",{type:"search",className:se.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})]}),jr=e=>e.isLoading?(0,M.jsx)("svg",{width:"20px",height:"20px",viewBox:"0 0 20 20",version:"1.1",className:se.tw`inline text-gray-200 animate-spin dark:text-gray-600`,children:(0,M.jsx)("g",{stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:(0,M.jsx)("g",{fill:"#212121",fillRule:"nonzero",children:(0,M.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,M.jsx)("input",{type:"checkbox",className:se.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 ie=require("@bumaga/tabs"),Yr=T(require("clsx"),1),Te=require("twind"),ye=require("react/jsx-runtime"),tt=({children:e,icon:t})=>{let{onClick:r,isActive:n}=(0,ie.useTabState)(),o=(0,Yr.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,ye.jsxs)("button",{className:(0,Te.tw)(o),onClick:r,children:[t,(0,ye.jsx)("span",{className:Te.tw`ml-2 text-base`,children:e})]})},rt=({children:e})=>(0,ie.usePanelState)()?(0,ye.jsx)("div",{className:Te.tw`w-full flex flex-grow-1 overflow-auto`,children:e}):null,Kr=({children:e})=>(0,ye.jsx)("div",{className:Te.tw`flex flex-shrink-0 border-b border-gray-200 justify-around pr-12`,children:e});var le=require("twind"),ee=require("react/jsx-runtime"),Jr=({checked:e=!1,onChange:t,disabled:r=!1,label:n,title:o,id:a})=>(0,ee.jsxs)("label",{htmlFor:a,title:o,className:le.tw`inline-flex items-center gap-2 cursor-pointer select-none ${r?"opacity-50 cursor-not-allowed":""}`,children:[n&&(0,ee.jsx)("span",{className:le.tw`text-sm text-gray-600 font-normal`,children:n}),(0,ee.jsxs)("span",{className:le.tw`relative inline-flex items-center`,children:[(0,ee.jsx)("input",{id:a,type:"checkbox",role:"switch","aria-checked":e,checked:e,disabled:r,onChange:s=>t?.(s.target.checked),className:le.tw`sr-only`}),(0,ee.jsx)("div",{className:le.tw`w-8 h-4 rounded-full transition-colors duration-200 ease-in-out ${e?"bg-blue-600":"bg-gray-300"}`}),(0,ee.jsx)("div",{className:le.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 eo=require("@biodiv-platform/naksha-commons"),_e=require("twind");var Xr=require("@biodiv-platform/naksha-commons");var bt=require("react/jsx-runtime");function Me({hideLabel:e}){let{layer:{selectionStyle:t,handleSelectStyle:r}}=u(),{t:n}=(0,Xr.useT)(),o=a=>{r(a.target.value)};return(0,bt.jsx)(fe,{name:"layer_selection",label:e?null:n("layer_selection"),defaultValue:t,onChange:o,children:Object.values(D).map(a=>(0,bt.jsx)("option",{value:a,children:n(a)},a))})}var Qr=T(require("clsx"),1),Ne=require("react"),Ee=require("twind");var H=require("react/jsx-runtime");function Lt({data:e}){let[t,r]=(0,Ne.useState)(!0),[n,o]=(0,Ne.useState)({title:e.sourceLayer,properties:[]}),{layer:a,mp:s,query:{clickedLngLat:l}}=u(),p=async()=>{let m,y=a.selectedLayers.find(h=>h.id===(e.sourceLayer||e.source));if(y.layerType.toLowerCase()==="raster"){let{data:h}=await vr(s.geoserver?.endpoint,s.geoserver?.workspace,{bbox:e.bbox.toString(),query_layers:`${s.geoserver?.workspace}:${y.id}`,layers:`${s.geoserver?.workspace}:${y.id}`});m=h?.features[0]?Object.entries(h.features[0]?.properties).map(([b,x])=>[x||"-"]):[]}else m=Object.entries(y?.data?.propertyMap||{}).map(([h,b])=>[b,e?.properties?.[h]||"-"]);o({title:y.title,properties:m})};return(0,Ne.useEffect)(()=>{p()},[l]),(0,H.jsxs)("div",{className:Ee.tw`bg-gray-100 rounded-lg`,children:[(0,H.jsxs)("button",{className:(0,Ee.tw)((0,Qr.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:()=>r(!t),children:[n.title," ",t?(0,H.jsx)($r,{}):(0,H.jsx)(Fr,{})]}),t&&(0,H.jsx)("div",{className:Ee.tw`px-4 py-3 flex flex-col gap-3`,children:n.properties.map(([m,y],h)=>(0,H.jsxs)("div",{children:[(0,H.jsx)("div",{className:Ee.tw`text-gray-600`,children:m}),(0,H.jsx)("div",{children:y})]},m+y+h))})]})}var A=require("react/jsx-runtime");function vt({onClose:e}){let{layer:{selectedFeatures:t,selectedLayers:r,selectionStyle:n}}=u(),{t:o}=(0,eo.useT)();return(0,A.jsxs)("div",{className:_e.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,A.jsxs)("div",{className:"flex w-full",children:[(0,A.jsxs)("div",{className:_e.tw`h-12 px-4 flex items-center gap-3 flex-grow bg-gray-200`,children:[(0,A.jsx)(zr,{})," ",o("infobar")]}),(0,A.jsx)(et,{onClick:e})]}),(0,A.jsx)("div",{className:_e.tw`bg-gray-100 p-4 flex-shrink-0 rt`,children:(0,A.jsx)(Me,{hideLabel:!0})}),(0,A.jsx)("div",{className:_e.tw`flex flex-col flex-grow overflow-auto gap-3 p-4`,children:t.flat(1)?.map(a=>(0,A.jsx)(Lt,{data:a},r?.[0]?.source.type==="raster"||n===D.ALL?a?.sourceLayer:a?.sourceLayer+a?.properties[G]))})]})}var xt=require("react/jsx-runtime");function wt(){let{layer:e,isInfoBarOpen:t,setIsInfoBarOpen:r}=u();if(!e.selectedFeatures?.length)return null;let n=()=>r(!t);return t?(0,xt.jsx)(vt,{onClose:n}):(0,xt.jsx)(Ur,{onClick:n})}var q=T(require("react"),1),To=require("react-map-gl/maplibre");var Ro=require("@biodiv-platform/naksha-commons"),Nt=require("twind");var xo=require("twind");var st=T(require("react"),1),go=require("react-virtual"),ho=require("react-virtualized-auto-sizer"),It=require("twind");var fo=require("@biodiv-platform/naksha-commons"),Be=require("react"),yo=require("react-web-share"),$=require("twind");var te=require("react/jsx-runtime"),to=({text:e="",highlight:t=""})=>{if(!t.trim())return(0,te.jsx)(te.Fragment,{children:e});let r=new RegExp(`(${t})`,"gi"),n=e.split(r);return(0,te.jsx)(te.Fragment,{children:n.filter(o=>o).map((o,a)=>r.test(o)?(0,te.jsx)("mark",{children:o},a):(0,te.jsx)("span",{children:o},a))})};var ao=require("twind");var ro=require("@biodiv-platform/naksha-commons"),oo=require("react"),no=require("twind"),ot=require("react/jsx-runtime");function Ae({children:e}){let[t,r]=(0,oo.useState)(!1),{t:n}=(0,ro.useT)();return(0,ot.jsxs)("div",{children:[t&&e,(0,ot.jsx)("button",{onClick:()=>r(!t),className:no.tw`text-blue-600 focus:outline-none focus:outline focus:ring`,children:n(t?"less":"legend")})]})}var z=require("react/jsx-runtime");function St({item:e}){let{layer:t}=u(),r=t.gridLegends[e.id];return r?(0,z.jsx)(Ae,{children:(0,z.jsxs)("ul",{style:{margin:0,padding:0},children:[r?.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:ao.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 = ",r?.squareSize," x ",r?.squareSize," km"]})]})}):null}var nt=require("@biodiv-platform/naksha-commons"),so=require("react"),io=require("react-tiny-popover"),re=require("twind");var L=require("react/jsx-runtime"),ge=({icon:e,name:t,title:r,link:n,children:o})=>{let a=(0,L.jsx)("span",{className:re.tw`flex-1`,children:o||"-"});return(0,L.jsxs)("div",{className:re.tw`flex items-center gap-3 text-sm text-gray-600 break-all`,title:t&&r&&`${t}: ${r}`,children:[(0,L.jsx)("div",{className:re.tw`flex-shrink-0`,children:e}),n?(0,L.jsx)("a",{className:re.tw`text-blue-700 focus:outline-none focus:ring flex-1`,target:"_blank",rel:"noopener",href:n,children:a}):a]})};function mn({item:e,containerStyle:t}){let{t:r}=(0,nt.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,L.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:[o.managePublishing&&e.layerStatus&&(0,L.jsx)(ge,{icon:(0,L.jsx)(Ar,{}),name:r("visiblity"),title:e.layerStatus,children:(0,L.jsxs)("div",{className:re.tw`flex items-center gap-3`,children:[(0,L.jsx)("span",{children:e.layerStatus}),(0,L.jsx)(Jr,{label:r("published"),checked:e.layerStatus?.toLowerCase()===me.ACTIVE.toLowerCase(),onChange:()=>n.togglePublish(e.id,e?.layerStatus)}),(0,L.jsx)("button",{type:"button",title:r("delete"),className:re.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,r("are_you_sure")),children:(0,L.jsx)(Wr,{})})]})}),(0,L.jsx)(ge,{icon:(0,L.jsx)(ht,{}),link:e.url,name:r("uploader"),title:e.createdBy,children:e.createdBy}),(0,L.jsx)(ge,{icon:(0,L.jsx)(ht,{}),link:e.url,name:r("created_by"),title:e.attribution,children:e.attribution}),(0,L.jsx)(ge,{icon:(0,L.jsx)(Br,{}),name:r("created_on"),title:s,children:s}),(0,L.jsx)(ge,{icon:(0,L.jsx)(Nr,{}),name:r("tags"),title:l,children:l}),(0,L.jsx)(ge,{name:r("license"),title:a,link:a&&nt.LICENSES[a],icon:(0,L.jsx)(_r,{}),children:a})]})}var lo=({item:e})=>{let[t,r]=(0,so.useState)(!1),n=()=>r(!t);return(0,L.jsx)(io.Popover,{isOpen:t,padding:10,positions:["right"],containerStyle:{zIndex:"99"},onClickOutside:n,content:(0,L.jsx)(mn,{item:e}),children:(0,L.jsx)(Q,{onClick:n,children:(0,L.jsx)(Qe,{}),title:"Information"})})};var mo=require("twind");var at=require("react"),co=require("@biodiv-platform/naksha-commons"),po=require("twind");var F=require("react/jsx-runtime");function uo({item:e}){let[t,r]=(0,at.useState)(!0),{mp:n}=u(),{t:o}=(0,co.useT)(),a=(0,at.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,p])=>(0,F.jsxs)("li",{className:po.tw`flex gap-2 items-center mb-1`,children:[(0,F.jsx)("svg",{viewBox:"0 0 24 24",height:"14",width:"14",focusable:"false",children:(0,F.jsx)("circle",{cx:"12",fill:p,cy:"12",r:"12",stroke:"none"})}),(0,F.jsx)("div",{children:l})]},p));return(0,F.jsx)("ul",{style:{margin:0,padding:0},children:e.layerType!=="RASTER"?s():t?(0,F.jsx)("li",{children:(0,F.jsx)("img",{style:{margin:"5px"},onError:()=>r(!1),src:`${n?.geoserver?.endpoint}/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&WIDTH=20&HEIGHT=20&STRICT=false&layer=biodiv:${e.id}`})}):(0,F.jsx)("div",{children:o("raster_style_not_found")})})}var ce=require("react/jsx-runtime");function kt({item:e}){if(!e.data?.styles)return null;let{layer:t}=u(),r=n=>{t.updateStyle(e.id,Number(n.target.value))};return(0,ce.jsxs)("div",{className:mo.tw`flex flex-col gap-4 pt-2`,children:[e.layerType!=="RASTER"&&(0,ce.jsx)(fe,{onChange:r,children:e.data?.styles.map((n,o)=>(0,ce.jsx)("option",{value:o,children:n.styleTitle},o))}),(0,ce.jsx)(Ae,{children:(0,ce.jsx)(uo,{item:e})})]})}var v=require("react/jsx-runtime");function fn({dragHandleProps:e}){return(0,v.jsx)("div",{className:$.tw`mt-1 w-6 text-center cursor-move`,style:{touchAction:"none"},...e,children:(0,v.jsx)(Hr,{})})}function Oe({item:e,extended:t,dragHandleProps:r}){let{t:n}=(0,fo.useT)(),{layer:o,query:a,mp:s,query:{setClickedLngLat:l},setIsInfoBarOpen:p}=u(),[m,y]=(0,Be.useState)(o.selectedIds.includes(e.id)),[h,b]=(0,Be.useState)(!1),x=(0,Be.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]),I=async()=>{b(!0),p(!0),o.setSelectedFeatures([]),l(null),await o.toggle({layerId:e.id,add:!m}),y(!m),b(!1)},B=async()=>{await kr(s.nakshaApiEndpoint,s.nakshaEndpointToken,e.id,e.title),s?.onLayerDownload(e.id)},j=()=>o.zoomToExtent(e.id);return(0,v.jsxs)("div",{className:$.tw`z-20 p-3 bg-white`,style:{borderTop:"1px solid #e5e7eb"},children:[(0,v.jsxs)("div",{className:$.tw`flex gap-3`,children:[(0,v.jsxs)("div",{className:$.tw`flex-shrink-0`,children:[(0,v.jsx)(jr,{name:e.id,checked:m,onChange:I,isLoading:h}),t&&(0,v.jsx)(fn,{dragHandleProps:r})]}),(0,v.jsx)("img",{className:$.tw`flex-shrink-0 overflow-hidden h-16 w-16 p-1 mb-2 object-cover border border-gray-200 rounded`,src:e.thumbnail||pr}),(0,v.jsxs)("div",{children:[(0,v.jsx)("div",{title:e.title,className:$.tw`mb-1 leading-tight`,style:ut,children:(0,v.jsx)(to,{text:e.title,highlight:a.term})}),(0,v.jsx)("p",{title:e.description,className:$.tw`text-gray-600 text-sm`,style:ur,children:e.description})]})]}),(0,v.jsxs)("div",{className:$.tw`flex justify-between`,children:[(0,v.jsxs)(Q,{onClick:B,disabled:!e.isDownloadable,children:[(0,v.jsx)(Or,{})," ",n("download")]}),(0,v.jsxs)("div",{className:$.tw`flex gap-3`,children:[x&&(0,v.jsx)(yo.RWebShare,{data:x,children:(0,v.jsx)(Q,{title:"Share",children:(0,v.jsx)(Dr,{})})}),t&&(0,v.jsx)(Q,{onClick:j,title:"Zoom To Extent",children:(0,v.jsx)(Gr,{})}),(0,v.jsx)(lo,{item:e})]})]}),t&&(0,v.jsx)(kt,{item:e}),t&&e.source.type==="grid"&&(0,v.jsx)(St,{item:e})]})}var oe=require("react/jsx-runtime");function bo(){let{layer:e,query:t}=u(),r=(0,st.useMemo)(()=>t.term?e.all.filter(a=>a.title.toLowerCase().includes(t.term.toLowerCase())):e.all,[e.all,t.term]),n=st.default.useRef(null),o=(0,go.useVirtual)({size:r.length,parentRef:n});return(0,oe.jsx)("div",{className:It.tw`flex-grow-1 relative`,children:(0,oe.jsx)(ho.AutoSizer,{renderProp:a=>(0,oe.jsx)("div",{ref:n,className:"List",style:{height:a.height,overflow:"auto"},children:(0,oe.jsx)("div",{style:{height:o.totalSize,width:"100%",position:"relative"},children:o.virtualItems.map(s=>(0,oe.jsx)("div",{ref:s.measureRef,className:It.tw`absolute top-0 left-0 w-full`,style:{transform:`translateY(${s.start}px)`},children:(0,oe.jsx)("div",{style:{height:146},children:(0,oe.jsx)(Oe,{item:r[s.index]})})},s.index))})})})})}var Lo=require("@biodiv-platform/naksha-commons"),vo=require("twind");var Ct=require("react/jsx-runtime");function Pt(){let{t:e}=(0,Lo.useT)(),{query:t}=u(),r=n=>t.setTerm(n.target.value);return(0,Ct.jsx)("div",{className:vo.tw`flex-shrink-0 border-b-2 p-4`,children:(0,Ct.jsx)(Zr,{name:"lyr_search",placeholder:e("find_layer_by_name"),onChange:r})})}var Ge=require("react/jsx-runtime");function Rt(){return(0,Ge.jsxs)("div",{className:xo.tw`flex flex-col w-full`,children:[(0,Ge.jsx)(Pt,{}),(0,Ge.jsx)(bo,{})]})}function yn(e,t,r){let n=t<0?e.length+t:t;if(n>=0&&n<e.length){let o=r<0?e.length+r:r,[a]=e.splice(t,1);e.splice(o,0,a)}}function wo(e,t,r){return e=[...e],yn(e,t,r),e}var W=require("@dnd-kit/core"),he=require("@dnd-kit/sortable"),So=require("@dnd-kit/utilities");var de=require("react/jsx-runtime");function gn({item:e,extended:t}){let{attributes:r,listeners:n,setNodeRef:o,transform:a,transition:s,isDragging:l}=(0,he.useSortable)({id:e.id}),p={transform:So.CSS.Transform.toString(a),transition:s,opacity:l?.5:1};return(0,de.jsx)("div",{ref:o,style:p,children:(0,de.jsx)(Oe,{item:e,extended:t,dragHandleProps:{...r,...n}})})}var ko=({layerList:e,onSortEnd:t})=>{let r=(0,W.useSensors)((0,W.useSensor)(W.PointerSensor,{activationConstraint:{distance:4}}));return(0,de.jsx)(W.DndContext,{sensors:r,collisionDetection:W.closestCenter,onDragEnd:o=>{let{active:a,over:s}=o;if(s&&a.id!==s.id){let l=e.findIndex(m=>m.id===a.id),p=e.findIndex(m=>m.id===s.id);l!==-1&&p!==-1&&t({oldIndex:l,newIndex:p})}},children:(0,de.jsx)(he.SortableContext,{items:e.map(o=>o.id),strategy:he.verticalListSortingStrategy,children:(0,de.jsx)("div",{children:e.map(o=>(0,de.jsx)(gn,{item:o,extended:!0},o.id))})})})};var Io=require("@biodiv-platform/naksha-commons"),Tt=require("twind"),be=require("react/jsx-runtime");function Mt(){let{layer:e}=u(),{t}=(0,Io.useT)(),r=({oldIndex:n,newIndex:o})=>{e.setSelectedIds(wo(e.selectedIds,n,o))};return(0,be.jsxs)("div",{className:Tt.tw`flex flex-col gap-3 w-full`,children:[e.selectedIds.length>0&&(0,be.jsx)("div",{className:Tt.tw`p-3 pb-0`,children:(0,be.jsxs)(Q,{onClick:()=>e.clearAll(),children:["\u2715 ",t("clear")]})}),(0,be.jsx)(ko,{layerList:e.selectedLayers,useDragHandle:!0,onSortEnd:r})]})}var Co=require("@biodiv-platform/naksha-commons"),Po=require("twind");var Le=require("react/jsx-runtime");function Et(){let{layer:e}=u(),{t}=(0,Co.useT)(),r=n=>{e.setMapStyle(n.target.value),e.setMaxZoom(e.mapStyles.find(o=>o.style===n.target.value)?.maxZoom)};return(0,Le.jsxs)("div",{className:Po.tw`w-full p-4 flex flex-col gap-4`,children:[(0,Le.jsx)(fe,{name:"base_style",label:t("base_style"),defaultValue:e.mapStyle,onChange:r,children:e.mapStyles.map(n=>(0,Le.jsx)("option",{value:n.style,children:n.text},n.key))}),(0,Le.jsx)(Me,{})]})}var k=require("react/jsx-runtime");function _t({onClose:e}){let{t}=(0,Ro.useT)();return(0,k.jsxs)("div",{className:Nt.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,k.jsx)(et,{onClick:e}),(0,k.jsx)("div",{className:Nt.tw`flex flex-col h-full`,children:(0,k.jsxs)(ie.Tabs,{children:[(0,k.jsxs)(Kr,{children:[(0,k.jsx)(tt,{icon:(0,k.jsx)(Pe,{}),children:t("layers")}),(0,k.jsx)(tt,{icon:(0,k.jsx)(Pe,{}),children:t("selected")}),(0,k.jsx)(tt,{icon:(0,k.jsx)(Er,{}),children:t("settings")})]}),(0,k.jsx)(rt,{children:(0,k.jsx)(Rt,{})}),(0,k.jsx)(rt,{children:(0,k.jsx)(Mt,{})}),(0,k.jsx)(rt,{children:(0,k.jsx)(Et,{})})]})})]})}var At=require("react/jsx-runtime");function Bt(){let{mp:e,layer:t}=u(),[r,n]=(0,q.useState)(e.showToC),{mapl:o}=(0,To.useMap)(),a=(0,q.useRef)(!1),s=q.default.useCallback(()=>n(p=>!p),[]),l=q.default.useCallback(async()=>{let p=await Lr(e.nakshaEndpointToken,e.nakshaApiEndpoint,e.geoserver,e.selectedLayers),m=[...e.layers||[],...p];if(t.setAll(m),t.selectedIds.length){let y=m.find(h=>h.id===t.selectedIds[0]);y?.bbox&&o?.fitBounds(y.bbox,{padding:40,duration:1e3})}},[e.nakshaEndpointToken,e.nakshaApiEndpoint,e.geoserver,e.selectedLayers,e.layers,t.setAll,t.selectedIds,o]);return(0,q.useEffect)(()=>{e.loadToC&&!a.current&&(a.current=!0,l())},[e.loadToC]),(0,q.useEffect)(()=>{if(o&&t.selectedIds.length&&t.all?.length){let p=t.all.find(m=>m.id===t.selectedIds[0]);p?.bbox&&o.fitBounds(p.bbox,{padding:40,duration:1e3})}},[o]),r?(0,At.jsx)(_t,{onClose:s}):(0,At.jsx)(Vr,{onClick:s})}var Z=require("maplibre-gl"),Mo="https://unpkg.com/maplibre-gl@6.16.0/dist/maplibre-gl-worker.mjs";typeof window<"u"&&!Z.config.WORKER_URL&&(Z.config.WORKER_URL="/maplibre-gl-worker.mjs");var it=null;async function Eo(e){return e?(Z.config.WORKER_URL=e,e):Z.config.WORKER_URL&&Z.config.WORKER_URL!=="/maplibre-gl-worker.mjs"?Z.config.WORKER_URL:typeof window>"u"?"":it||(it=(async()=>{try{let t=await fetch("/maplibre-gl-worker.mjs",{method:"HEAD"}),r=t.headers.get("content-type")||"";if(t.ok&&!r.includes("text/html"))return Z.config.WORKER_URL="/maplibre-gl-worker.mjs","/maplibre-gl-worker.mjs"}catch{}return Z.config.WORKER_URL=Mo,Mo})(),it)}var Ao=require("react-map-gl/maplibre");var No=T(require("@turf/bbox"),1),ne=require("react"),ve=require("react-map-gl/maplibre");var Ot=require("react/jsx-runtime");function Gt({data:e,beforeId:t}){let{layer:r}=u(),{mapl:n}=(0,ve.useMap)(),[o,a]=(0,ne.useState)({geojson:{},paint:{}}),s=(0,ne.useRef)(""),l=r.selectedIds.includes(e.id),p=r.selectedIds[0]===e.id,m=async(y=!1)=>{if(!n)return;let h=n.getBounds(),b=n.getZoom();if(!h)return;let[x]=Ke(b),{_ne:I,_sw:B}=h,j=`${I.lat.toFixed(4)},${B.lng.toFixed(4)},${B.lat.toFixed(4)},${I.lng.toFixed(4)},${x}`;if(j===s.current)return;s.current=j;let{success:Y,geojson:U,paint:R,stops:dt,squareSize:C}=await Sr(e.source.fetcher,h,b,void 0,void 0,e.source);if(Y){if(a({geojson:U,paint:R}),y&&p&&e.zoomToFit)try{let O=(0,No.default)(U);if(O.every(Number.isFinite)){let[S,K,J,$e]=O;n.fitBounds([[S,K],[J,$e]],{padding:40,animate:!0})}}catch(O){console.warn("Failed to compute bbox",O)}r.setGridLegends(O=>({...O,[e.id]:{stops:dt,squareSize:C}}))}};return(0,ne.useEffect)(()=>{l&&p?m(!0):l&&m(!1)},[l,p]),(0,ne.useEffect)(()=>{if(!l||!n)return;let y=()=>m(!1);return n.on("moveend",y),()=>{n.off("moveend",y)}},[l,n]),(0,ne.useEffect)(()=>()=>{r.setGridLegends(y=>{let h={...y};return delete h[e.id],h})},[e.id]),(0,Ot.jsx)(ve.Source,{id:e.id,type:"geojson",data:o.geojson,children:(0,Ot.jsx)(ve.Layer,{beforeId:t,id:e.id,type:"fill",paint:o.paint})})}var _o=require("react"),De=require("react-map-gl/maplibre");var He=require("react/jsx-runtime"),hn={fill:{"line-color":"red","line-width":2},circle:{"circle-stroke-color":"red","circle-stroke-width":2,"circle-opacity":0}};function lt({layer:e,beforeId:t}){let{layer:r}=u(),n=(0,_o.useMemo)(()=>e.data?.styles?.[e.data?.styleIndex]?.colors,[e,r.selectedFeatures]),o=r.selectedFeaturesId?.[e.id];return(0,He.jsxs)(De.Source,{...e.source,children:[n&&(0,He.jsx)(De.Layer,{beforeId:t,...n}),o&&n&&(0,He.jsx)(De.Layer,{...n,beforeId:t,id:`hl_${e.id}`,filter:["in",G,...o],type:n.type==="fill"?"line":n.type,paint:hn[n.type]})]})}var ct=require("react-map-gl/maplibre");var Dt=require("react/jsx-runtime");function Ht({data:e,beforeId:t}){let{mp:r}=u();return(0,Dt.jsx)(ct.Source,{id:e.id,type:"raster",tiles:[`${r?.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,Dt.jsx)(ct.Layer,{id:e.id,beforeId:t,type:"raster",source:"biodiv",layout:{visibility:"visible"},paint:{}})})}var ze=require("react/jsx-runtime");function Bo({layer:e,beforeId:t}){let{mapl:r}=(0,Ao.useMap)();if(!r)return null;switch(e.source.type){case"vector":return(0,ze.jsx)(lt,{beforeId:t,layer:e});case"grid":return(0,ze.jsx)(Gt,{beforeId:t,data:e});case"raster":return(0,ze.jsx)(Ht,{beforeId:t,data:e});default:return(0,ze.jsx)(lt,{beforeId:t,layer:e})}}var Oo=require("react"),Go=require("react-map-gl/maplibre");var xe=require("react/jsx-runtime"),bn=Go.Marker,Ln=()=>{let{mp:e}=u(),t=(0,Oo.useMemo)(()=>e.markers,[e.markers]);return(0,xe.jsx)(xe.Fragment,{children:t?.map(({latitude:r,longitude:n,colorHex:o,anchor:a="bottom",iconUrl:s},l)=>(0,xe.jsx)(bn,{latitude:r,longitude:n,anchor:a,subpixelPositioning:!0,children:(0,xe.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))})},Do=Ln;var zo=T(require("clsx"),1),Fo=require("react-map-gl/maplibre"),we=require("twind");var _=require("react/jsx-runtime"),Ho=Fo.Popup;function zt({coordinates:e}){let{hover:t}=u(),r=e||t.features?.coordinates;return!r?.lat||!t.features?null:t.features.content?(0,_.jsx)(Ho,{latitude:r.lat,longitude:r.lng,closeButton:!1,maxWidth:"320px",children:t.features.content}):(0,_.jsx)(Ho,{latitude:r.lat,longitude:r.lng,closeButton:!1,children:(0,_.jsxs)("table",{className:we.tw`table-auto border`,children:[(0,_.jsx)("thead",{children:(0,_.jsx)("tr",{children:(0,_.jsx)("th",{className:we.tw`bg-gray-200 py-1 px-2`,colSpan:2,children:t.features.title})})}),(0,_.jsx)("tbody",{children:t.features.data.map(([n,o],a)=>(0,_.jsxs)("tr",{className:(0,we.tw)((0,zo.default)({"bg-gray-50":a%2===0,"border-gray-100 border-t":1})),children:[(0,_.jsx)("td",{className:we.tw`py-1 px-2`,children:n}),(0,_.jsx)("td",{className:we.tw`py-1 px-2 border-l border-gray-100`,children:o})]},n+o))})]})})}var $o=require("react-map-gl/maplibre"),vn='<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="margin:auto"><circle cx="12" cy="12" r="7"/><circle cx="12" cy="12" r="2"/><path d="M12 2v3M12 19v3M2 12h3M19 12h3"/></svg>',Ft=class{constructor(t,r){this.onReset=t;this.title=r}onReset;title;container;onAdd(){this.container=document.createElement("div"),this.container.className="maplibregl-ctrl maplibregl-ctrl-group";let t=document.createElement("button");return t.type="button",t.title=this.title,t.setAttribute("aria-label",this.title),t.style.display="flex",t.innerHTML=vn,t.onclick=this.onReset,this.container.appendChild(t),this.container}onRemove(){this.container?.remove()}};function $t({viewState:e,position:t="bottom-right"}){return(0,$o.useControl)(({map:r})=>new Ft(()=>r.flyTo({center:[e.longitude,e.latitude],zoom:e.zoom}),"Reset view"),{position:t}),null}var E=require("react/jsx-runtime"),xn=V.NavigationControl,wn=V.Popup;function Wt(){let{mp:e,layer:t,hover:r,query:n}=u(),[o,a]=(0,N.useState)(e.workerUrl||(typeof window<"u"?qo.config.WORKER_URL||"/maplibre-gl-worker.mjs":void 0));(0,N.useEffect)(()=>{Eo(e.workerUrl).then(a)},[e.workerUrl]);let s=(0,N.useMemo)(()=>e.defaultViewState||Wo.defaultViewState,[e.defaultViewState]),[l,p]=(0,N.useState)();(0,N.useEffect)(()=>p(void 0),[t.selectedIds.join(",")]);let m=N.default.useCallback(b=>{let x=t.selectedLayers[0];if(!x?.onClick){n.setClickedLngLat(b.lngLat);return}let I=b.target.queryRenderedFeatures(b.point,{layers:[x.id]})[0];p(I&&{lngLat:b.lngLat,content:x.onClick({bbox:Je(I),feature:I,layerId:x.id})})},[t.selectedLayers,n]),y=N.default.useRef(null),h=N.default.useCallback(b=>{y.current||(y.current=requestAnimationFrame(()=>{y.current=null,r.onHover(b)}))},[r]);return(0,N.useEffect)(()=>()=>{y.current&&cancelAnimationFrame(y.current)},[]),(0,E.jsxs)("div",{className:Vo.tw`h-full w-full relative bg-gray-100`,children:[e.loadToC&&(0,E.jsx)(Bt,{}),t.selectedFeatures?.length>0&&(0,E.jsx)(wt,{}),(0,E.jsxs)(V.default,{id:"mapl",workerUrl:o,cursor:"default",initialViewState:s,style:{width:"100%",height:"100%"},mapStyle:t.mapStyle,maxZoom:t.maxZoom,onClick:m,onMouseMove:h,children:[e.showScaleControl&&(0,E.jsx)(V.ScaleControl,{position:"bottom-right"}),e.showResetControl&&(0,E.jsx)($t,{viewState:s,position:"bottom-right"}),(0,E.jsx)(xn,{position:"bottom-right",showZoom:!0,showCompass:!0}),e.showFullscreenControl&&(0,E.jsx)(V.FullscreenControl,{position:"bottom-right"}),(0,E.jsx)(Do,{}),t.selectedLayers.map((b,x)=>{let I=x>0?t.selectedIds[x-1]:void 0;return(0,E.jsx)(Bo,{layer:b,beforeId:I},b.id)}),l?(0,E.jsx)(wn,{latitude:l.lngLat.lat,longitude:l.lngLat.lng,closeOnClick:!1,onClose:()=>p(void 0),maxWidth:"320px",children:l.content}):(0,E.jsx)(zt,{},"popup")]})]})}var Fe=require("react/jsx-runtime");(0,Yo.setup)({preflight:!1});var Sn=e=>{let t=Zo.default.useMemo(()=>({...dr,...e}),[e]);return(0,Fe.jsx)(jo.MapProvider,{children:(0,Fe.jsx)(Uo.TranslationProvider,{localeStrings:cr,lang:t.lang,children:(0,Fe.jsx)(Pr,{mp:t,children:(0,Fe.jsx)(Wt,{})})})})};0&&(module.exports={NakshaMaplibreLayers});
|
|
1
|
+
"use strict";var Jo=Object.create;var Ze=Object.defineProperty;var Xo=Object.getOwnPropertyDescriptor;var Qo=Object.getOwnPropertyNames;var en=Object.getPrototypeOf,tn=Object.prototype.hasOwnProperty;var rn=(e,t)=>{for(var r in t)Ze(e,r,{get:t[r],enumerable:!0})},ar=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Qo(t))!tn.call(e,o)&&o!==r&&Ze(e,o,{get:()=>t[o],enumerable:!(n=Xo(t,o))||n.enumerable});return e};var N=(e,t,r)=>(r=e!=null?Jo(en(e)):{},ar(t||!e||!e.__esModule?Ze(r,"default",{value:e,enumerable:!0}):r,e)),on=e=>ar(Ze({},"__esModule",{value:!0}),e);var In={};rn(In,{NakshaMaplibreLayers:()=>kn});module.exports=on(In);var Uo=require("@biodiv-platform/naksha-commons"),Zo=N(require("react"),1),jo=require("react-map-gl/maplibre"),Yo=require("twind");var sr={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 ir={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 lr={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 cr={en:sr,fr:ir,hi:lr};var Wo=require("@biodiv-platform/naksha-commons"),E=N(require("react"),1),j=N(require("react-map-gl/maplibre"),1),qo=require("maplibre-gl"),Vo=require("twind");var Xe=require("@biodiv-platform/naksha-commons"),c=N(require("react"),1),Ir=require("react-map-gl/maplibre");var br=N(require("colorbrewer"),1),X=N(require("redaxios"),1);var ft=N(require("boundingbox"),1),Ye=require("geohash");var je=require("@biodiv-platform/naksha-commons"),dr={defaultViewState:je.defaultViewState,nakshaApiEndpoint:"/naksha-api/api",geoserver:{endpoint:"/geoserver",workspace:"biodiv",store:"ibp"},mapStyle:je.MapStyles.MAP_STREETS,layers:[],selectedLayers:[]},pr="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",ut={display:"-webkit-box",WebkitLineClamp:1,WebkitBoxOrient:"vertical",overflow:"hidden",wordBreak:"break-word"},ur={...ut,WebkitLineClamp:2},z="ogc_fid",me={ACTIVE:"Active",PENDING:"Pending"},F={TOP:"layer_selection_top",ALL:"layer_selection_all"};var Ke=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],mt="0123456789bcdefghjkmnpqrstuvwxyz",ln=(e,t,r)=>{r=r||16/2**(1-e.length&1)/4**t;let n=e.slice(0,-1),o=~~(mt.indexOf(e.slice(-1))/r);return[n+mt[r*o],n+mt[r*(o+1)-1]]},yt=e=>typeof e=="number"?{count:e}:e,cn=(e,t)=>{for(let[r,n]of Object.entries(t))e[r]=(e[r]||0)+n;return e},dn=function(e,t){var r=new Map,n=new Map;let o=[];for(let[a,s]of Object.entries(e)){let[l,p]=ln(a,t);n.set(l,p),r.set(l,cn(r.get(l)||{},yt(s)))}return r.forEach((a,s)=>{let l=Ye.GeoHash.decodeGeoHash(s),p=Ye.GeoHash.decodeGeoHash(n.get(s)),m=new ft.default({minlat:l.latitude[0],minlon:l.longitude[0],maxlat:p.latitude[1],maxlon:p.longitude[1]}).toGeoJSON();o.push({...m,properties:{...a,[z]:s}})}),o},pn=e=>{let t=[];for(let[r,n]of Object.entries(e)){let o=Ye.GeoHash.decodeGeoHash(r),a=new ft.default({minlat:o.latitude[0],minlon:o.longitude[0],maxlat:o.latitude[1],maxlon:o.longitude[1]}).toGeoJSON();t.push({...a,properties:{...yt(n),[z]:r}})}return t},mr=(e,t)=>({type:"FeatureCollection",features:Object.keys(e).length===0?[]:t===-1?pn(e):dn(e,t)}),fr=(e,t)=>{let r=Object.values(e).map(a=>yt(a).count).sort((a,s)=>a-s),n=Math.floor(r.length/t),o=new Array(t-1).fill(0).map((a,s)=>r[n*(s+1)]);return o.push(r[r.length-1]),o},Je=e=>{let t=[],r=a=>typeof a[0]=="number"?t.push(a):a.forEach(r);if(r(e?.geometry?.coordinates||[]),!t.length)return;let n=t.map(([a])=>a),o=t.map(([,a])=>a);return[Math.min(...n),Math.min(...o),Math.max(...n),Math.max(...o)]};var yr=async(e,t,r,n)=>Promise.all((e||[]).map(async o=>{let a=n?.includes(o.name),s=o.layerType?.toLowerCase()==="raster",l={...o,id:o.name,thumbnail:t+o.thumbnail,source:{type:s?"raster":"vector",scheme:"tms",tiles:[`${r.endpoint}/gwc/service/tms/1.0.0/${r.workspace}:${o.name}@EPSG%3A900913@pbf/{z}/{x}/{y}.pbf`]},data:{styles:[]},isAdded:a};if(a&&!s){let p=await gt(l,0,t,r);return{...l,data:p}}return l})),gt=async(e,t,r,n)=>{let o=e.data||{styles:[]},a=o.layerName,s=o.styles?[...o.styles]:[],l=o.summaryColumn,p=o.titleColumn,m=o.propertyMap;if(s.length===0){let{success:y,data:h}=await gr(e.id,r);y&&h&&(a=h.layerName,s=(h.styles||[]).map(S=>({...S})),l=h.summaryColumn,p=h.titleColumn,m=Object.fromEntries((h.styles||[]).map(S=>[S.styleName,S.styleTitle])))}if(s[t]&&!s[t]?.colors){let y=await hr(e.id,n?.workspace,s[t].styleName,r);s[t]={...s[t],colors:y}}return{...o,layerName:a,styles:s,summaryColumn:l,titleColumn:p,propertyMap:m,styleIndex:t}};var Lr=async(e,t,r,n)=>{try{let o=await X.default.get(`${t}/layer/all`,{headers:{Authorization:e}});return await yr(o.data,t,r,n)}catch(o){return console.error(o),[]}},gr=async(e,t)=>{try{let{data:r}=await X.default.get(`${t}/layer/onClick/${e}`);return{success:!0,data:r}}catch(r){return console.error(r),{success:!1}}},vr=async(e,t,r)=>{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 X.default.get(`${e}/${t}/wms`,{params:{...r,...n}})).data}}catch(o){return console.error(o),{success:!1,data:[]}}},xr=async(e,t,r,n)=>{try{return await X.default.put(`${t}/layer/${n?"active":"pending"}/${r}`,{},{headers:{Authorization:e}}),!0}catch(o){return console.error(o),!1}},wr=async(e,t,r)=>{try{return await X.default.delete(`${t}/layer/${r}`,{headers:{Authorization:e}}),!0}catch(n){return console.error(n),!1}},hr=async(e,t,r,n)=>{try{return(await X.default.get(`${n}/geoserver/workspaces/${t}/styles/${e}_${r}.mbstyle`)).data?.layers?.[0]}catch(o){return console.error(o),{}}},un=(e,t)=>["step",["get","count"],e[0],...t.flatMap((r,n)=>[r,e[n+1]])],Sr=async(e,t,r,n=6,o="YlOrRd",a={})=>{try{let[s,l,p]=Ke(r),{_ne:m,_sw:y}=t,h={top:m.lat,left:y.lng,bottom:y.lat,right:m.lng,geoAggegationPrecision:s},S=await e(h),P=mr(S,l),v=a.colors?.length&&a.breaks?.length===a.colors.length-1,x=v?a.colors.map((G,B)=>[a.breaks[B]?a.breaks[B]-1:1/0,G]):fr(S,n).map((G,B)=>[G,br.default[o][n][B]]),T={"fill-color":v?un(a.colors,a.breaks):{property:"count",default:"yellow",stops:x},"fill-outline-color":a.outlineColor||"rgba(0,0,0,0.2)","fill-opacity":a.opacity??.7};return{success:!0,geojson:P,paint:T,stops:x,squareSize:p}}catch(s){return console.error(s),{success:!1,geojson:{},paint:{},stops:[],squareSize:0}}},kr=async(e,t,r,n)=>{try{await X.default.post(`${e}/layer/download`,{layerName:r,layerTitle:n,attributeList:[],filterArray:[]},{headers:{Authorization:t}})}catch(o){console.error(o)}};var Tr=require("react/jsx-runtime"),Cr=(0,c.createContext)({}),Pr=({mp:e,children:t})=>{let[r,n]=(0,c.useState)(e),{mapl:o}=(0,Ir.useMap)();(0,c.useEffect)(()=>{n(d=>({...d,...e}))},[e]);let[a,s]=(0,c.useState)(""),l=(0,Xe.useDebounce)(a,500),p=r.mapStyles&&r.mapStyles.length>0?r.mapStyles:Xe.defaultMapStyles,[m,y]=(0,c.useState)(p[r?.mapStyle||0]?.style),[h,S]=(0,c.useState)(p[r?.mapStyle||0]?.maxZoom),[P,v]=(0,c.useState)(F.TOP),[x,T]=(0,c.useState)({}),[G,B]=(0,c.useState)(!0),[I,dt]=(0,c.useState)(),[R,H]=(0,c.useState)(e.layers||[]),[k,K]=(0,c.useState)(r.selectedLayers||[]);(0,c.useEffect)(()=>{r.selectedLayers&&r.selectedLayers.join(",")!==k.join(",")&&K(r.selectedLayers)},[r.selectedLayers]);let[J,$e]=(0,c.useState)(),[We,qt]=(0,c.useState)(),Vt=(0,c.useMemo)(()=>{let d={};for(let f of We||[])d[f.sourceLayer]=[...d[f.sourceLayer]||[],f?.properties?.[z]];return Object.keys(d).length?d:void 0},[We]),Se=c.default.useMemo(()=>{let d=R.filter(g=>k.includes(g.id)),f=new Array(k.length);for(let g of d){let w=k.findIndex(M=>g.id===M);w>-1&&(f[w]=g)}return f},[R,k]),pe=(0,c.useCallback)(d=>R.findIndex(f=>f.id===d),[R]),qe=(0,c.useCallback)((d,f)=>{H(g=>g.map(w=>w.id===d?{...w,...f}:w))},[]),Ve=(0,c.useCallback)(async(d,f,g)=>{let w=R[d];if(!w)return;let M=await gt(w,f,r.nakshaApiEndpoint,r.geoserver);qe(w.id,{data:M}),g&&o?.fitBounds(w.bbox,{padding:40,duration:1e3})},[R,r.nakshaApiEndpoint,r.geoserver,qe,o]),Ut=(0,c.useCallback)(async(d,f)=>{let g=pe(d);Ve(g,f,!1)},[pe,Ve]),Zt=(0,c.useCallback)(async d=>{if(!(!k.length||!o))try{let f=k[0],g=o.queryRenderedFeatures(d.point,{layers:[f]});if(g.length){let w=g[0]?.id||g[0]?.properties?.[z];if(w===J?.id&&f===J?.layerId)return;let M=R[pe(f)];if(!M)return;let ke=M?.data?.summaryColumn?.map(Ue=>[M.data?.propertyMap?.[Ue]||Ue,g[0].properties?.[Ue]]);$e({id:w,layerId:f,title:M.title,data:ke||[],coordinates:d.lngLat,content:M?.onHover?.({bbox:Je(g[0]),feature:g[0],layerId:f})})}else $e(w=>w!==void 0?void 0:w)}catch{}},[k,o,J?.id,J?.layerId,R,pe]),jt=(0,c.useCallback)(async({layerId:d,add:f,styleIndex:g=0,focus:w=!0})=>{if(!f){K(Ie=>Ie.filter(Ce=>d!==Ce));return}let M=pe(d),ke=R[M];ke?.source.type==="grid"?(K(Ie=>[d,...Ie.filter(Ce=>Ce!==d)]),w&&ke?.bbox&&setTimeout(()=>{o?.fitBounds(ke.bbox,{padding:40,duration:1e3})},100)):(await Ve(M,g,w),K(Ie=>[d,...Ie.filter(Ce=>Ce!==d)]))},[pe,R,o,Ve]),Yt=(0,c.useCallback)(async()=>K([]),[]),Kt=(0,c.useCallback)((d,f)=>{n(g=>({...g,[d]:f}))},[]),Jt=(0,c.useCallback)((d,f)=>{let g=f===me.PENDING;xr(r.nakshaEndpointToken,r.nakshaApiEndpoint,d,g),qe(d,{layerStatus:g?me.ACTIVE:me.PENDING})},[r.nakshaEndpointToken,r.nakshaApiEndpoint,qe]),Xt=(0,c.useCallback)(async(d,f)=>{confirm(f)&&(wr(r.nakshaEndpointToken,r.nakshaApiEndpoint,d),H(g=>g.filter(w=>w.id!==d)))},[r.nakshaEndpointToken,r.nakshaApiEndpoint]),Qt=(0,c.useCallback)(d=>{let f=R.find(g=>g.id===d);f?.bbox&&o?.fitBounds(f.bbox,{padding:40,duration:1e3})},[R,o]),pt=(0,c.useCallback)(()=>I?[I.lng,I.lat,I.lng+.1,I.lat+.1]:[0,0,0,0],[I]),ue=(0,c.useCallback)(d=>{if(!(!I||!o))try{let f=o.project([I.lng,I.lat]),g=o.queryRenderedFeatures(f,{layers:P===F.TOP?[k[0]]:k});if((d||P)===F.ALL){let w=Se.filter(M=>M.layerType=="RASTER").map(M=>({sourceLayer:M.id,layerType:"raster",bbox:pt()}));g=[...g,...w]}qt(Se?.[0]?.layerType==="RASTER"&&P!==F.ALL?k.length&&g?.length?g:[{sourceLayer:k[0],layerType:"raster",bbox:pt()}]:g)}catch(f){console.error(f)}},[I,o,P,k,Se,pt]),er=(0,c.useCallback)(d=>{v(d),d===F.TOP&&ue(d)},[ue]),tr=(0,c.useRef)(!0);(0,c.useEffect)(()=>{if(tr.current){tr.current=!1;return}r.onSelectedLayersChange&&r.onSelectedLayersChange(k)},[k]),(0,c.useEffect)(()=>{let d=setTimeout(ue,300);return()=>clearTimeout(d)},[I,P,k,ue]);let rr=(0,c.useMemo)(()=>({mapStyle:m,featuresAtLatLng:ue,setMapStyle:y,maxZoom:h,setMaxZoom:S,mapStyles:p,all:R,setAll:H,selectedIds:k,handleSelectStyle:er,setSelectedIds:K,selectedLayers:Se,clearAll:Yt,toggle:jt,updateStyle:Ut,selectedFeatures:We,selectedFeaturesId:Vt,setSelectedFeatures:qt,togglePublish:Jt,delete:Xt,selectionStyle:P,setSelectionStyle:v,zoomToExtent:Qt,gridLegends:x,setGridLegends:T}),[m,ue,h,p,R,k,er,Se,Yt,jt,Ut,We,Vt,Jt,Xt,P,Qt,x]),or=(0,c.useMemo)(()=>({term:l,setTerm:s,clickedLngLat:I,setClickedLngLat:dt}),[l,I]),nr=(0,c.useMemo)(()=>({onHover:Zt,features:J}),[Zt,J]),Ko=(0,c.useMemo)(()=>({mp:r,updateMP:Kt,layer:rr,query:or,isInfoBarOpen:G,setIsInfoBarOpen:B,hover:nr}),[r,Kt,rr,or,G,nr]);return(0,Tr.jsx)(Cr.Provider,{value:Ko,children:t})};function u(){return(0,c.useContext)(Cr)}var qr=N(require("react"),1),Te=require("twind");var Rr=require("twind"),i=require("react/jsx-runtime"),Mr=()=>(0,i.jsx)("svg",{fill:"none",className:Rr.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"})}),Pe=()=>(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"})]}),Qe=()=>(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"})]}),Er=()=>(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 ht(){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 Nr(){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 _r(){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 Ar(){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 Br(){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 Or(){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 Gr(){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 Dr(){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 Hr(){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 zr(){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 Fr(){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 $r(){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 Wr(){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 ae=require("react/jsx-runtime"),Q=qr.default.forwardRef((e,t)=>(0,ae.jsx)("button",{ref:t,type:"button",className:Te.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 et=e=>(0,ae.jsx)("button",{className:Te.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}),Vr=e=>(0,ae.jsx)("button",{className:Te.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,ae.jsx)(Pe,{})}),Ur=e=>(0,ae.jsx)("button",{className:Te.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,ae.jsx)(Qe,{})});var se=require("twind");var _=require("react/jsx-runtime");var fe=e=>(0,_.jsxs)("div",{children:[e.label&&(0,_.jsx)("label",{className:se.tw`text-gray-700`,htmlFor:e.name,children:e.label}),(0,_.jsx)("select",{id:e.name,name:e.name,className:se.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})]}),Zr=e=>(0,_.jsxs)("div",{className:"relative",children:[(0,_.jsx)("span",{className:se.tw`absolute inset-y-0 left-0 flex items-center pl-3`,children:(0,_.jsx)(Mr,{})}),(0,_.jsx)("input",{type:"search",className:se.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})]}),jr=e=>e.isLoading?(0,_.jsx)("svg",{width:"20px",height:"20px",viewBox:"0 0 20 20",version:"1.1",className:se.tw`inline text-gray-200 animate-spin dark:text-gray-600`,children:(0,_.jsx)("g",{stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:(0,_.jsx)("g",{fill:"#212121",fillRule:"nonzero",children:(0,_.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,_.jsx)("input",{type:"checkbox",className:se.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 ie=require("@bumaga/tabs"),Yr=N(require("clsx"),1),Re=require("twind"),ye=require("react/jsx-runtime"),tt=({children:e,icon:t})=>{let{onClick:r,isActive:n}=(0,ie.useTabState)(),o=(0,Yr.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,ye.jsxs)("button",{className:(0,Re.tw)(o),onClick:r,children:[t,(0,ye.jsx)("span",{className:Re.tw`ml-2 text-base`,children:e})]})},rt=({children:e})=>(0,ie.usePanelState)()?(0,ye.jsx)("div",{className:Re.tw`w-full flex flex-grow-1 overflow-auto`,children:e}):null,Kr=({children:e})=>(0,ye.jsx)("div",{className:Re.tw`flex flex-shrink-0 border-b border-gray-200 justify-around pr-12`,children:e});var le=require("twind"),ee=require("react/jsx-runtime"),Jr=({checked:e=!1,onChange:t,disabled:r=!1,label:n,title:o,id:a})=>(0,ee.jsxs)("label",{htmlFor:a,title:o,className:le.tw`inline-flex items-center gap-2 cursor-pointer select-none ${r?"opacity-50 cursor-not-allowed":""}`,children:[n&&(0,ee.jsx)("span",{className:le.tw`text-sm text-gray-600 font-normal`,children:n}),(0,ee.jsxs)("span",{className:le.tw`relative inline-flex items-center`,children:[(0,ee.jsx)("input",{id:a,type:"checkbox",role:"switch","aria-checked":e,checked:e,disabled:r,onChange:s=>t?.(s.target.checked),className:le.tw`sr-only`}),(0,ee.jsx)("div",{className:le.tw`w-8 h-4 rounded-full transition-colors duration-200 ease-in-out ${e?"bg-blue-600":"bg-gray-300"}`}),(0,ee.jsx)("div",{className:le.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 eo=require("@biodiv-platform/naksha-commons"),_e=require("twind");var Xr=require("@biodiv-platform/naksha-commons");var bt=require("react/jsx-runtime");function Me({hideLabel:e}){let{layer:{selectionStyle:t,handleSelectStyle:r}}=u(),{t:n}=(0,Xr.useT)(),o=a=>{r(a.target.value)};return(0,bt.jsx)(fe,{name:"layer_selection",label:e?null:n("layer_selection"),defaultValue:t,onChange:o,children:Object.values(F).map(a=>(0,bt.jsx)("option",{value:a,children:n(a)},a))})}var Qr=N(require("clsx"),1),Ne=require("react"),Ee=require("twind");var $=require("react/jsx-runtime");function Lt({data:e}){let[t,r]=(0,Ne.useState)(!0),[n,o]=(0,Ne.useState)({title:e.sourceLayer,properties:[]}),{layer:a,mp:s,query:{clickedLngLat:l}}=u(),p=async()=>{let m,y=a.selectedLayers.find(h=>h.id===(e.sourceLayer||e.source));if(y.layerType.toLowerCase()==="raster"){let{data:h}=await vr(s.geoserver?.endpoint,s.geoserver?.workspace,{bbox:e.bbox.toString(),query_layers:`${s.geoserver?.workspace}:${y.id}`,layers:`${s.geoserver?.workspace}:${y.id}`});m=h?.features[0]?Object.entries(h.features[0]?.properties).map(([S,P])=>[P||"-"]):[]}else m=Object.entries(y?.data?.propertyMap||{}).map(([h,S])=>[S,e?.properties?.[h]||"-"]);o({title:y.title,properties:m})};return(0,Ne.useEffect)(()=>{p()},[l]),(0,$.jsxs)("div",{className:Ee.tw`bg-gray-100 rounded-lg`,children:[(0,$.jsxs)("button",{className:(0,Ee.tw)((0,Qr.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:()=>r(!t),children:[n.title," ",t?(0,$.jsx)($r,{}):(0,$.jsx)(Fr,{})]}),t&&(0,$.jsx)("div",{className:Ee.tw`px-4 py-3 flex flex-col gap-3`,children:n.properties.map(([m,y],h)=>(0,$.jsxs)("div",{children:[(0,$.jsx)("div",{className:Ee.tw`text-gray-600`,children:m}),(0,$.jsx)("div",{children:y})]},m+y+h))})]})}var D=require("react/jsx-runtime");function vt({onClose:e}){let{layer:{selectedFeatures:t,selectedLayers:r,selectionStyle:n}}=u(),{t:o}=(0,eo.useT)();return(0,D.jsxs)("div",{className:_e.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,D.jsxs)("div",{className:"flex w-full",children:[(0,D.jsxs)("div",{className:_e.tw`h-12 px-4 flex items-center gap-3 flex-grow bg-gray-200`,children:[(0,D.jsx)(zr,{})," ",o("infobar")]}),(0,D.jsx)(et,{onClick:e})]}),(0,D.jsx)("div",{className:_e.tw`bg-gray-100 p-4 flex-shrink-0 rt`,children:(0,D.jsx)(Me,{hideLabel:!0})}),(0,D.jsx)("div",{className:_e.tw`flex flex-col flex-grow overflow-auto gap-3 p-4`,children:t.flat(1)?.map(a=>(0,D.jsx)(Lt,{data:a},r?.[0]?.source.type==="raster"||n===F.ALL?a?.sourceLayer:a?.sourceLayer+a?.properties[z]))})]})}var xt=require("react/jsx-runtime");function wt(){let{layer:e,isInfoBarOpen:t,setIsInfoBarOpen:r}=u();if(!e.selectedFeatures?.length)return null;let n=()=>r(!t);return t?(0,xt.jsx)(vt,{onClose:n}):(0,xt.jsx)(Ur,{onClick:n})}var Z=N(require("react"),1),Ro=require("react-map-gl/maplibre");var To=require("@biodiv-platform/naksha-commons"),Nt=require("twind");var xo=require("twind");var st=N(require("react"),1),go=require("react-virtual"),ho=require("react-virtualized-auto-sizer"),It=require("twind");var fo=require("@biodiv-platform/naksha-commons"),Be=require("react"),yo=require("react-web-share"),V=require("twind");var te=require("react/jsx-runtime"),to=({text:e="",highlight:t=""})=>{if(!t.trim())return(0,te.jsx)(te.Fragment,{children:e});let r=new RegExp(`(${t})`,"gi"),n=e.split(r);return(0,te.jsx)(te.Fragment,{children:n.filter(o=>o).map((o,a)=>r.test(o)?(0,te.jsx)("mark",{children:o},a):(0,te.jsx)("span",{children:o},a))})};var ao=require("twind");var ro=require("@biodiv-platform/naksha-commons"),oo=require("react"),no=require("twind"),ot=require("react/jsx-runtime");function Ae({children:e}){let[t,r]=(0,oo.useState)(!1),{t:n}=(0,ro.useT)();return(0,ot.jsxs)("div",{children:[t&&e,(0,ot.jsx)("button",{onClick:()=>r(!t),className:no.tw`text-blue-600 focus:outline-none focus:outline focus:ring`,children:n(t?"less":"legend")})]})}var W=require("react/jsx-runtime");function St({item:e}){let{layer:t}=u(),r=t.gridLegends[e.id];return r?(0,W.jsx)(Ae,{children:(0,W.jsxs)("ul",{style:{margin:0,padding:0},children:[r?.stops.map(([n,o],a,s)=>{let l=(s[a-1]||[0])[0];return l===n?(0,W.jsx)("div",{},o):(0,W.jsxs)("li",{className:ao.tw`flex gap-2 items-center mb-1`,children:[(0,W.jsx)("svg",{viewBox:"0 0 24 24",height:"14",width:"14",focusable:"false",children:(0,W.jsx)("circle",{cx:"12",fill:o,cy:"12",r:"12",stroke:"none"})}),(0,W.jsxs)("div",{children:[l," - ",n]})]},o)}),(0,W.jsxs)("li",{children:["1 Square = ",r?.squareSize," x ",r?.squareSize," km"]})]})}):null}var nt=require("@biodiv-platform/naksha-commons"),so=require("react"),io=require("react-tiny-popover"),re=require("twind");var b=require("react/jsx-runtime"),ge=({icon:e,name:t,title:r,link:n,children:o})=>{let a=(0,b.jsx)("span",{className:re.tw`flex-1`,children:o||"-"});return(0,b.jsxs)("div",{className:re.tw`flex items-center gap-3 text-sm text-gray-600 break-all`,title:t&&r&&`${t}: ${r}`,children:[(0,b.jsx)("div",{className:re.tw`flex-shrink-0`,children:e}),n?(0,b.jsx)("a",{className:re.tw`text-blue-700 focus:outline-none focus:ring flex-1`,target:"_blank",rel:"noopener",href:n,children:a}):a]})};function mn({item:e,containerStyle:t}){let{t:r}=(0,nt.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:re.tw`flex flex-col gap-1 bg-white p-4 rounded-lg w-72 border border-gray-300 border-solid`,style:t,children:[o.managePublishing&&e.layerStatus&&(0,b.jsx)(ge,{icon:(0,b.jsx)(Ar,{}),name:r("visiblity"),title:e.layerStatus,children:(0,b.jsxs)("div",{className:re.tw`flex items-center gap-3`,children:[(0,b.jsx)("span",{children:e.layerStatus}),(0,b.jsx)(Jr,{label:r("published"),checked:e.layerStatus?.toLowerCase()===me.ACTIVE.toLowerCase(),onChange:()=>n.togglePublish(e.id,e?.layerStatus)}),(0,b.jsx)("button",{type:"button",title:r("delete"),className:re.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,r("are_you_sure")),children:(0,b.jsx)(Wr,{})})]})}),(0,b.jsx)(ge,{icon:(0,b.jsx)(ht,{}),link:e.url,name:r("uploader"),title:e.createdBy,children:e.createdBy}),(0,b.jsx)(ge,{icon:(0,b.jsx)(ht,{}),link:e.url,name:r("created_by"),title:e.attribution,children:e.attribution}),(0,b.jsx)(ge,{icon:(0,b.jsx)(Br,{}),name:r("created_on"),title:s,children:s}),(0,b.jsx)(ge,{icon:(0,b.jsx)(Nr,{}),name:r("tags"),title:l,children:l}),(0,b.jsx)(ge,{name:r("license"),title:a,link:a&&nt.LICENSES[a],icon:(0,b.jsx)(_r,{}),children:a})]})}var lo=({item:e})=>{let[t,r]=(0,so.useState)(!1),n=()=>r(!t);return(0,b.jsx)(io.Popover,{isOpen:t,padding:10,positions:["right"],containerStyle:{zIndex:"99"},onClickOutside:n,content:(0,b.jsx)(mn,{item:e}),children:(0,b.jsx)(Q,{onClick:n,children:(0,b.jsx)(Qe,{}),title:"Information"})})};var mo=require("twind");var at=require("react"),co=require("@biodiv-platform/naksha-commons"),po=require("twind");var q=require("react/jsx-runtime");function uo({item:e}){let[t,r]=(0,at.useState)(!0),{mp:n}=u(),{t:o}=(0,co.useT)(),a=(0,at.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,p])=>(0,q.jsxs)("li",{className:po.tw`flex gap-2 items-center mb-1`,children:[(0,q.jsx)("svg",{viewBox:"0 0 24 24",height:"14",width:"14",focusable:"false",children:(0,q.jsx)("circle",{cx:"12",fill:p,cy:"12",r:"12",stroke:"none"})}),(0,q.jsx)("div",{children:l})]},p));return(0,q.jsx)("ul",{style:{margin:0,padding:0},children:e.layerType!=="RASTER"?s():t?(0,q.jsx)("li",{children:(0,q.jsx)("img",{style:{margin:"5px"},onError:()=>r(!1),src:`${n?.geoserver?.endpoint}/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&WIDTH=20&HEIGHT=20&STRICT=false&layer=biodiv:${e.id}`})}):(0,q.jsx)("div",{children:o("raster_style_not_found")})})}var ce=require("react/jsx-runtime");function kt({item:e}){if(!e.data?.styles)return null;let{layer:t}=u(),r=n=>{t.updateStyle(e.id,Number(n.target.value))};return(0,ce.jsxs)("div",{className:mo.tw`flex flex-col gap-4 pt-2`,children:[e.layerType!=="RASTER"&&(0,ce.jsx)(fe,{onChange:r,children:e.data?.styles.map((n,o)=>(0,ce.jsx)("option",{value:o,children:n.styleTitle},o))}),(0,ce.jsx)(Ae,{children:(0,ce.jsx)(uo,{item:e})})]})}var L=require("react/jsx-runtime");function fn({dragHandleProps:e}){return(0,L.jsx)("div",{className:V.tw`mt-1 w-6 text-center cursor-move`,style:{touchAction:"none"},...e,children:(0,L.jsx)(Hr,{})})}function Oe({item:e,extended:t,dragHandleProps:r}){let{t:n}=(0,fo.useT)(),{layer:o,query:a,mp:s,query:{setClickedLngLat:l},setIsInfoBarOpen:p}=u(),[m,y]=(0,Be.useState)(o.selectedIds.includes(e.id)),[h,S]=(0,Be.useState)(!1),P=(0,Be.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]),v=async()=>{S(!0),p(!0),o.setSelectedFeatures([]),l(null),await o.toggle({layerId:e.id,add:!m}),y(!m),S(!1)},x=async()=>{await kr(s.nakshaApiEndpoint,s.nakshaEndpointToken,e.id,e.title),s?.onLayerDownload(e.id)},T=()=>o.zoomToExtent(e.id);return(0,L.jsxs)("div",{className:V.tw`z-20 p-3 bg-white`,style:{borderTop:"1px solid #e5e7eb"},children:[(0,L.jsxs)("div",{className:V.tw`flex gap-3`,children:[(0,L.jsxs)("div",{className:V.tw`flex-shrink-0`,children:[(0,L.jsx)(jr,{name:e.id,checked:m,onChange:v,isLoading:h}),t&&(0,L.jsx)(fn,{dragHandleProps:r})]}),(0,L.jsx)("img",{className:V.tw`flex-shrink-0 overflow-hidden h-16 w-16 p-1 mb-2 object-cover border border-gray-200 rounded`,src:e.thumbnail||pr}),(0,L.jsxs)("div",{children:[(0,L.jsx)("div",{title:e.title,className:V.tw`mb-1 leading-tight`,style:ut,children:(0,L.jsx)(to,{text:e.title,highlight:a.term})}),(0,L.jsx)("p",{title:e.description,className:V.tw`text-gray-600 text-sm`,style:ur,children:e.description})]})]}),(0,L.jsxs)("div",{className:V.tw`flex justify-between`,children:[(0,L.jsxs)(Q,{onClick:x,disabled:!e.isDownloadable,children:[(0,L.jsx)(Or,{})," ",n("download")]}),(0,L.jsxs)("div",{className:V.tw`flex gap-3`,children:[P&&(0,L.jsx)(yo.RWebShare,{data:P,children:(0,L.jsx)(Q,{title:"Share",children:(0,L.jsx)(Dr,{})})}),t&&(0,L.jsx)(Q,{onClick:T,title:"Zoom To Extent",children:(0,L.jsx)(Gr,{})}),(0,L.jsx)(lo,{item:e})]})]}),t&&(0,L.jsx)(kt,{item:e}),t&&e.source.type==="grid"&&(0,L.jsx)(St,{item:e})]})}var oe=require("react/jsx-runtime");function bo(){let{layer:e,query:t}=u(),r=(0,st.useMemo)(()=>t.term?e.all.filter(a=>a.title.toLowerCase().includes(t.term.toLowerCase())):e.all,[e.all,t.term]),n=st.default.useRef(null),o=(0,go.useVirtual)({size:r.length,parentRef:n});return(0,oe.jsx)("div",{className:It.tw`flex-grow-1 relative`,children:(0,oe.jsx)(ho.AutoSizer,{renderProp:a=>(0,oe.jsx)("div",{ref:n,className:"List",style:{height:a.height,overflow:"auto"},children:(0,oe.jsx)("div",{style:{height:o.totalSize,width:"100%",position:"relative"},children:o.virtualItems.map(s=>(0,oe.jsx)("div",{ref:s.measureRef,className:It.tw`absolute top-0 left-0 w-full`,style:{transform:`translateY(${s.start}px)`},children:(0,oe.jsx)("div",{style:{height:146},children:(0,oe.jsx)(Oe,{item:r[s.index]})})},s.index))})})})})}var Lo=require("@biodiv-platform/naksha-commons"),vo=require("twind");var Ct=require("react/jsx-runtime");function Pt(){let{t:e}=(0,Lo.useT)(),{query:t}=u(),r=n=>t.setTerm(n.target.value);return(0,Ct.jsx)("div",{className:vo.tw`flex-shrink-0 border-b-2 p-4`,children:(0,Ct.jsx)(Zr,{name:"lyr_search",placeholder:e("find_layer_by_name"),onChange:r})})}var Ge=require("react/jsx-runtime");function Tt(){return(0,Ge.jsxs)("div",{className:xo.tw`flex flex-col w-full`,children:[(0,Ge.jsx)(Pt,{}),(0,Ge.jsx)(bo,{})]})}function yn(e,t,r){let n=t<0?e.length+t:t;if(n>=0&&n<e.length){let o=r<0?e.length+r:r,[a]=e.splice(t,1);e.splice(o,0,a)}}function wo(e,t,r){return e=[...e],yn(e,t,r),e}var U=require("@dnd-kit/core"),he=require("@dnd-kit/sortable"),So=require("@dnd-kit/utilities");var de=require("react/jsx-runtime");function gn({item:e,extended:t}){let{attributes:r,listeners:n,setNodeRef:o,transform:a,transition:s,isDragging:l}=(0,he.useSortable)({id:e.id}),p={transform:So.CSS.Transform.toString(a),transition:s,opacity:l?.5:1};return(0,de.jsx)("div",{ref:o,style:p,children:(0,de.jsx)(Oe,{item:e,extended:t,dragHandleProps:{...r,...n}})})}var ko=({layerList:e,onSortEnd:t})=>{let r=(0,U.useSensors)((0,U.useSensor)(U.PointerSensor,{activationConstraint:{distance:4}}));return(0,de.jsx)(U.DndContext,{sensors:r,collisionDetection:U.closestCenter,onDragEnd:o=>{let{active:a,over:s}=o;if(s&&a.id!==s.id){let l=e.findIndex(m=>m.id===a.id),p=e.findIndex(m=>m.id===s.id);l!==-1&&p!==-1&&t({oldIndex:l,newIndex:p})}},children:(0,de.jsx)(he.SortableContext,{items:e.map(o=>o.id),strategy:he.verticalListSortingStrategy,children:(0,de.jsx)("div",{children:e.map(o=>(0,de.jsx)(gn,{item:o,extended:!0},o.id))})})})};var Io=require("@biodiv-platform/naksha-commons"),Rt=require("twind"),be=require("react/jsx-runtime");function Mt(){let{layer:e}=u(),{t}=(0,Io.useT)(),r=({oldIndex:n,newIndex:o})=>{e.setSelectedIds(wo(e.selectedIds,n,o))};return(0,be.jsxs)("div",{className:Rt.tw`flex flex-col gap-3 w-full`,children:[e.selectedIds.length>0&&(0,be.jsx)("div",{className:Rt.tw`p-3 pb-0`,children:(0,be.jsxs)(Q,{onClick:()=>e.clearAll(),children:["\u2715 ",t("clear")]})}),(0,be.jsx)(ko,{layerList:e.selectedLayers,useDragHandle:!0,onSortEnd:r})]})}var Co=require("@biodiv-platform/naksha-commons"),Po=require("twind");var Le=require("react/jsx-runtime");function Et(){let{layer:e}=u(),{t}=(0,Co.useT)(),r=n=>{e.setMapStyle(n.target.value),e.setMaxZoom(e.mapStyles.find(o=>o.style===n.target.value)?.maxZoom)};return(0,Le.jsxs)("div",{className:Po.tw`w-full p-4 flex flex-col gap-4`,children:[(0,Le.jsx)(fe,{name:"base_style",label:t("base_style"),defaultValue:e.mapStyle,onChange:r,children:e.mapStyles.map(n=>(0,Le.jsx)("option",{value:n.style,children:n.text},n.key))}),(0,Le.jsx)(Me,{})]})}var C=require("react/jsx-runtime");function _t({onClose:e}){let{t}=(0,To.useT)();return(0,C.jsxs)("div",{className:Nt.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,C.jsx)(et,{onClick:e}),(0,C.jsx)("div",{className:Nt.tw`flex flex-col h-full`,children:(0,C.jsxs)(ie.Tabs,{children:[(0,C.jsxs)(Kr,{children:[(0,C.jsx)(tt,{icon:(0,C.jsx)(Pe,{}),children:t("layers")}),(0,C.jsx)(tt,{icon:(0,C.jsx)(Pe,{}),children:t("selected")}),(0,C.jsx)(tt,{icon:(0,C.jsx)(Er,{}),children:t("settings")})]}),(0,C.jsx)(rt,{children:(0,C.jsx)(Tt,{})}),(0,C.jsx)(rt,{children:(0,C.jsx)(Mt,{})}),(0,C.jsx)(rt,{children:(0,C.jsx)(Et,{})})]})})]})}var At=require("react/jsx-runtime");function Bt(){let{mp:e,layer:t}=u(),[r,n]=(0,Z.useState)(e.showToC),{mapl:o}=(0,Ro.useMap)(),a=(0,Z.useRef)(!1),s=Z.default.useCallback(()=>n(p=>!p),[]),l=Z.default.useCallback(async()=>{let p=await Lr(e.nakshaEndpointToken,e.nakshaApiEndpoint,e.geoserver,e.selectedLayers),m=[...e.layers||[],...p];if(t.setAll(m),t.selectedIds.length){let y=m.find(h=>h.id===t.selectedIds[0]);y?.bbox&&o?.fitBounds(y.bbox,{padding:40,duration:1e3})}},[e.nakshaEndpointToken,e.nakshaApiEndpoint,e.geoserver,e.selectedLayers,e.layers,t.setAll,t.selectedIds,o]);return(0,Z.useEffect)(()=>{e.loadToC&&!a.current&&(a.current=!0,l())},[e.loadToC]),(0,Z.useEffect)(()=>{if(o&&t.selectedIds.length&&t.all?.length){let p=t.all.find(m=>m.id===t.selectedIds[0]);p?.bbox&&o.fitBounds(p.bbox,{padding:40,duration:1e3})}},[o]),r?(0,At.jsx)(_t,{onClose:s}):(0,At.jsx)(Vr,{onClick:s})}var Y=require("maplibre-gl"),Mo="https://unpkg.com/maplibre-gl@6.16.0/dist/maplibre-gl-worker.mjs";typeof window<"u"&&!Y.config.WORKER_URL&&(Y.config.WORKER_URL="/maplibre-gl-worker.mjs");var it=null;async function Eo(e){return e?(Y.config.WORKER_URL=e,e):Y.config.WORKER_URL&&Y.config.WORKER_URL!=="/maplibre-gl-worker.mjs"?Y.config.WORKER_URL:typeof window>"u"?"":it||(it=(async()=>{try{let t=await fetch("/maplibre-gl-worker.mjs",{method:"HEAD"}),r=t.headers.get("content-type")||"";if(t.ok&&!r.includes("text/html"))return Y.config.WORKER_URL="/maplibre-gl-worker.mjs","/maplibre-gl-worker.mjs"}catch{}return Y.config.WORKER_URL=Mo,Mo})(),it)}var Ao=require("react-map-gl/maplibre");var No=N(require("@turf/bbox"),1),ne=require("react"),ve=require("react-map-gl/maplibre");var Ot=require("react/jsx-runtime");function Gt({data:e,beforeId:t}){let{layer:r}=u(),{mapl:n}=(0,ve.useMap)(),[o,a]=(0,ne.useState)({geojson:{},paint:{}}),s=(0,ne.useRef)(""),l=r.selectedIds.includes(e.id),p=r.selectedIds[0]===e.id,m=async(y=!1)=>{if(!n)return;let h=n.getBounds(),S=n.getZoom();if(!h)return;let[P]=Ke(S),{_ne:v,_sw:x}=h,T=`${v.lat.toFixed(4)},${x.lng.toFixed(4)},${x.lat.toFixed(4)},${v.lng.toFixed(4)},${P}`;if(T===s.current)return;s.current=T;let{success:G,geojson:B,paint:I,stops:dt,squareSize:R}=await Sr(e.source.fetcher,h,S,void 0,void 0,e.source);if(G){if(a({geojson:B,paint:I}),y&&p&&e.zoomToFit)try{let H=(0,No.default)(B);if(H.every(Number.isFinite)){let[k,K,J,$e]=H;n.fitBounds([[k,K],[J,$e]],{padding:40,animate:!0})}}catch(H){console.warn("Failed to compute bbox",H)}r.setGridLegends(H=>({...H,[e.id]:{stops:dt,squareSize:R}}))}};return(0,ne.useEffect)(()=>{l&&p?m(!0):l&&m(!1)},[l,p]),(0,ne.useEffect)(()=>{if(!l||!n)return;let y=()=>m(!1);return n.on("moveend",y),()=>{n.off("moveend",y)}},[l,n]),(0,ne.useEffect)(()=>()=>{r.setGridLegends(y=>{let h={...y};return delete h[e.id],h})},[e.id]),(0,Ot.jsx)(ve.Source,{id:e.id,type:"geojson",data:o.geojson,children:(0,Ot.jsx)(ve.Layer,{beforeId:t,id:e.id,type:"fill",paint:o.paint})})}var _o=require("react"),De=require("react-map-gl/maplibre");var He=require("react/jsx-runtime"),hn={fill:{"line-color":"red","line-width":2},circle:{"circle-stroke-color":"red","circle-stroke-width":2,"circle-opacity":0}};function lt({layer:e,beforeId:t}){let{layer:r}=u(),n=(0,_o.useMemo)(()=>e.data?.styles?.[e.data?.styleIndex]?.colors,[e,r.selectedFeatures]),o=r.selectedFeaturesId?.[e.id];return(0,He.jsxs)(De.Source,{...e.source,children:[n&&(0,He.jsx)(De.Layer,{beforeId:t,...n}),o&&n&&(0,He.jsx)(De.Layer,{...n,beforeId:t,id:`hl_${e.id}`,filter:["in",z,...o],type:n.type==="fill"?"line":n.type,paint:hn[n.type]})]})}var ct=require("react-map-gl/maplibre");var Dt=require("react/jsx-runtime");function Ht({data:e,beforeId:t}){let{mp:r}=u();return(0,Dt.jsx)(ct.Source,{id:e.id,type:"raster",tiles:[`${r?.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,Dt.jsx)(ct.Layer,{id:e.id,beforeId:t,type:"raster",source:"biodiv",layout:{visibility:"visible"},paint:{}})})}var ze=require("react/jsx-runtime");function Bo({layer:e,beforeId:t}){let{mapl:r}=(0,Ao.useMap)();if(!r)return null;switch(e.source.type){case"vector":return(0,ze.jsx)(lt,{beforeId:t,layer:e});case"grid":return(0,ze.jsx)(Gt,{beforeId:t,data:e});case"raster":return(0,ze.jsx)(Ht,{beforeId:t,data:e});default:return(0,ze.jsx)(lt,{beforeId:t,layer:e})}}var Oo=require("react"),Go=require("react-map-gl/maplibre");var xe=require("react/jsx-runtime"),bn=Go.Marker,Ln=()=>{let{mp:e}=u(),t=(0,Oo.useMemo)(()=>e.markers,[e.markers]);return(0,xe.jsx)(xe.Fragment,{children:t?.map(({latitude:r,longitude:n,colorHex:o,anchor:a="bottom",iconUrl:s},l)=>(0,xe.jsx)(bn,{latitude:r,longitude:n,anchor:a,subpixelPositioning:!0,children:(0,xe.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))})},Do=Ln;var zo=N(require("clsx"),1),Fo=require("react-map-gl/maplibre"),we=require("twind");var O=require("react/jsx-runtime"),Ho=Fo.Popup;function zt({coordinates:e}){let{hover:t}=u(),r=e||t.features?.coordinates;return!r?.lat||!t.features?null:t.features.content?(0,O.jsx)(Ho,{latitude:r.lat,longitude:r.lng,closeButton:!1,maxWidth:"320px",children:t.features.content}):(0,O.jsx)(Ho,{latitude:r.lat,longitude:r.lng,closeButton:!1,children:(0,O.jsxs)("table",{className:we.tw`table-auto border`,children:[(0,O.jsx)("thead",{children:(0,O.jsx)("tr",{children:(0,O.jsx)("th",{className:we.tw`bg-gray-200 py-1 px-2`,colSpan:2,children:t.features.title})})}),(0,O.jsx)("tbody",{children:t.features.data.map(([n,o],a)=>(0,O.jsxs)("tr",{className:(0,we.tw)((0,zo.default)({"bg-gray-50":a%2===0,"border-gray-100 border-t":1})),children:[(0,O.jsx)("td",{className:we.tw`py-1 px-2`,children:n}),(0,O.jsx)("td",{className:we.tw`py-1 px-2 border-l border-gray-100`,children:o})]},n+o))})]})})}var $o=require("react-map-gl/maplibre"),vn='<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="margin:auto"><circle cx="12" cy="12" r="7"/><circle cx="12" cy="12" r="2"/><path d="M12 2v3M12 19v3M2 12h3M19 12h3"/></svg>',Ft=class{constructor(t,r){this.onReset=t;this.title=r}onReset;title;container;onAdd(){this.container=document.createElement("div"),this.container.className="maplibregl-ctrl maplibregl-ctrl-group";let t=document.createElement("button");return t.type="button",t.title=this.title,t.setAttribute("aria-label",this.title),t.style.display="flex",t.innerHTML=vn,t.onclick=this.onReset,this.container.appendChild(t),this.container}onRemove(){this.container?.remove()}};function $t({viewState:e,position:t="bottom-right"}){return(0,$o.useControl)(({map:r})=>new Ft(()=>r.flyTo({center:[e.longitude,e.latitude],zoom:e.zoom}),"Reset view"),{position:t}),null}var A=require("react/jsx-runtime"),xn=j.NavigationControl,wn=5e3,Sn=j.Popup;function Wt(){let{mp:e,layer:t,hover:r,query:n}=u(),[o,a]=(0,E.useState)(e.workerUrl||(typeof window<"u"?qo.config.WORKER_URL||"/maplibre-gl-worker.mjs":void 0));(0,E.useEffect)(()=>{Eo(e.workerUrl).then(a)},[e.workerUrl]);let s=(0,E.useMemo)(()=>e.defaultViewState||Wo.defaultViewState,[e.defaultViewState]),[l,p]=(0,E.useState)();(0,E.useEffect)(()=>p(void 0),[t.selectedIds.join(",")]);let m=E.default.useCallback(v=>{let x=t.selectedLayers[0];if(!x?.onClick){n.setClickedLngLat(v.lngLat);return}let T=v.target.queryRenderedFeatures(v.point,{layers:[x.id]})[0];p(T&&{lngLat:v.lngLat,content:x.onClick({bbox:Je(T),feature:T,layerId:x.id})})},[t.selectedLayers,n]),y=E.default.useRef(null),h=E.default.useCallback(v=>{y.current||(y.current=requestAnimationFrame(()=>{y.current=null,r.onHover(v)}))},[r]);(0,E.useEffect)(()=>()=>{y.current&&cancelAnimationFrame(y.current)},[]);let S=E.default.useRef({}),P=E.default.useCallback(v=>{if(!e.collapseAttribution)return;let x=v.target.getContainer().querySelector(".maplibregl-ctrl-attrib");if(!x)return;let T=!1;x.querySelector(".maplibregl-ctrl-attrib-button")?.addEventListener("click",()=>{T=!0},{capture:!0,once:!0});let G=()=>x.classList.contains("maplibregl-compact-show"),B=()=>{S.current.timer=setTimeout(()=>{T||x.classList.remove("maplibregl-compact-show")},wn)};if(G()){B();return}let I=new MutationObserver(()=>{G()&&(I.disconnect(),B())});I.observe(x,{attributes:!0,attributeFilter:["class"]}),S.current.observer=I},[e.collapseAttribution]);return(0,E.useEffect)(()=>()=>{let{timer:v}=S.current;v&&clearTimeout(v),S.current.observer?.disconnect()},[]),(0,A.jsxs)("div",{className:Vo.tw`h-full w-full relative bg-gray-100`,children:[e.loadToC&&(0,A.jsx)(Bt,{}),t.selectedFeatures?.length>0&&(0,A.jsx)(wt,{}),(0,A.jsxs)(j.default,{id:"mapl",workerUrl:o,cursor:"default",initialViewState:s,style:{width:"100%",height:"100%"},mapStyle:t.mapStyle,maxZoom:t.maxZoom,onClick:m,onMouseMove:h,attributionControl:e.collapseAttribution?{compact:!0}:void 0,onLoad:P,children:[e.showScaleControl&&(0,A.jsx)(j.ScaleControl,{position:"bottom-right"}),e.showResetControl&&(0,A.jsx)($t,{viewState:s,position:"bottom-right"}),(0,A.jsx)(xn,{position:"bottom-right",showZoom:!0,showCompass:!0}),e.showFullscreenControl&&(0,A.jsx)(j.FullscreenControl,{position:"bottom-right"}),(0,A.jsx)(Do,{}),t.selectedLayers.map((v,x)=>{let T=x>0?t.selectedIds[x-1]:void 0;return(0,A.jsx)(Bo,{layer:v,beforeId:T},v.id)}),l?(0,A.jsx)(Sn,{latitude:l.lngLat.lat,longitude:l.lngLat.lng,closeOnClick:!1,onClose:()=>p(void 0),maxWidth:"320px",children:l.content}):(0,A.jsx)(zt,{},"popup")]})]})}var Fe=require("react/jsx-runtime");(0,Yo.setup)({preflight:!1});var kn=e=>{let t=Zo.default.useMemo(()=>({...dr,...e}),[e]);return(0,Fe.jsx)(jo.MapProvider,{children:(0,Fe.jsx)(Uo.TranslationProvider,{localeStrings:cr,lang:t.lang,children:(0,Fe.jsx)(Pr,{mp:t,children:(0,Fe.jsx)(Wt,{})})})})};0&&(module.exports={NakshaMaplibreLayers});
|
package/dist/index.d.cts
CHANGED
|
@@ -20,6 +20,8 @@ interface NakshaMaplibreLayersProps {
|
|
|
20
20
|
showScaleControl?: boolean;
|
|
21
21
|
/** button that returns the map to `defaultViewState` */
|
|
22
22
|
showResetControl?: boolean;
|
|
23
|
+
/** attribution shows when the map loads, then folds behind its (i) button after 5 seconds */
|
|
24
|
+
collapseAttribution?: boolean;
|
|
23
25
|
managePublishing?: boolean;
|
|
24
26
|
nakshaEndpointToken?: string;
|
|
25
27
|
nakshaApiEndpoint?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -20,6 +20,8 @@ interface NakshaMaplibreLayersProps {
|
|
|
20
20
|
showScaleControl?: boolean;
|
|
21
21
|
/** button that returns the map to `defaultViewState` */
|
|
22
22
|
showResetControl?: boolean;
|
|
23
|
+
/** attribution shows when the map loads, then folds behind its (i) button after 5 seconds */
|
|
24
|
+
collapseAttribution?: boolean;
|
|
23
25
|
managePublishing?: boolean;
|
|
24
26
|
nakshaEndpointToken?: string;
|
|
25
27
|
nakshaApiEndpoint?: string;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{TranslationProvider as fa}from"@biodiv-platform/naksha-commons";import ya from"react";import{MapProvider as ga}from"react-map-gl/maplibre";import{setup as ha}from"twind";var Ht={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 zt={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 Ft={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 $t={en:Ht,fr:zt,hi:Ft};import{defaultViewState as oa}from"@biodiv-platform/naksha-commons";import xt,{useEffect as wt,useMemo as na,useState as so}from"react";import aa,{FullscreenControl as sa,NavigationControl as ia,Popup as la,ScaleControl as ca}from"react-map-gl/maplibre";import{config as da}from"maplibre-gl";import{tw as pa}from"twind";import{defaultMapStyles as xo,useDebounce as wo}from"@biodiv-platform/naksha-commons";import So,{createContext as ko,useCallback as P,useContext as Io,useEffect as Ie,useMemo as pe,useRef as Co,useState as T}from"react";import{useMap as Po}from"react-map-gl/maplibre";import Lo from"colorbrewer";import V from"redaxios";import Ut from"boundingbox";import{GeoHash as Ze}from"geohash";import{MapStyles as mo,defaultViewState as fo}from"@biodiv-platform/naksha-commons";var Wt={defaultViewState:fo,nakshaApiEndpoint:"/naksha-api/api",geoserver:{endpoint:"/geoserver",workspace:"biodiv",store:"ibp"},mapStyle:mo.MAP_STREETS,layers:[],selectedLayers:[]},qt="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",Ve={display:"-webkit-box",WebkitLineClamp:1,WebkitBoxOrient:"vertical",overflow:"hidden",wordBreak:"break-word"},Vt={...Ve,WebkitLineClamp:2},N="ogc_fid",X={ACTIVE:"Active",PENDING:"Pending"},_={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],Ue="0123456789bcdefghjkmnpqrstuvwxyz",yo=(e,t,r)=>{r=r||16/2**(1-e.length&1)/4**t;let n=e.slice(0,-1),o=~~(Ue.indexOf(e.slice(-1))/r);return[n+Ue[r*o],n+Ue[r*(o+1)-1]]},je=e=>typeof e=="number"?{count:e}:e,go=(e,t)=>{for(let[r,n]of Object.entries(t))e[r]=(e[r]||0)+n;return e},ho=function(e,t){var r=new Map,n=new Map;let o=[];for(let[a,s]of Object.entries(e)){let[l,d]=yo(a,t);n.set(l,d),r.set(l,go(r.get(l)||{},je(s)))}return r.forEach((a,s)=>{let l=Ze.decodeGeoHash(s),d=Ze.decodeGeoHash(n.get(s)),u=new Ut({minlat:l.latitude[0],minlon:l.longitude[0],maxlat:d.latitude[1],maxlon:d.longitude[1]}).toGeoJSON();o.push({...u,properties:{...a,[N]:s}})}),o},bo=e=>{let t=[];for(let[r,n]of Object.entries(e)){let o=Ze.decodeGeoHash(r),a=new Ut({minlat:o.latitude[0],minlon:o.longitude[0],maxlat:o.latitude[1],maxlon:o.longitude[1]}).toGeoJSON();t.push({...a,properties:{...je(n),[N]:r}})}return t},Zt=(e,t)=>({type:"FeatureCollection",features:Object.keys(e).length===0?[]:t===-1?bo(e):ho(e,t)}),jt=(e,t)=>{let r=Object.values(e).map(a=>je(a).count).sort((a,s)=>a-s),n=Math.floor(r.length/t),o=new Array(t-1).fill(0).map((a,s)=>r[n*(s+1)]);return o.push(r[r.length-1]),o},ke=e=>{let t=[],r=a=>typeof a[0]=="number"?t.push(a):a.forEach(r);if(r(e?.geometry?.coordinates||[]),!t.length)return;let n=t.map(([a])=>a),o=t.map(([,a])=>a);return[Math.min(...n),Math.min(...o),Math.max(...n),Math.max(...o)]};var Yt=async(e,t,r,n)=>Promise.all((e||[]).map(async o=>{let a=n?.includes(o.name),s=o.layerType?.toLowerCase()==="raster",l={...o,id:o.name,thumbnail:t+o.thumbnail,source:{type:s?"raster":"vector",scheme:"tms",tiles:[`${r.endpoint}/gwc/service/tms/1.0.0/${r.workspace}:${o.name}@EPSG%3A900913@pbf/{z}/{x}/{y}.pbf`]},data:{styles:[]},isAdded:a};if(a&&!s){let d=await Ye(l,0,t,r);return{...l,data:d}}return l})),Ye=async(e,t,r,n)=>{let o=e.data||{styles:[]},a=o.layerName,s=o.styles?[...o.styles]:[],l=o.summaryColumn,d=o.titleColumn,u=o.propertyMap;if(s.length===0){let{success:f,data:g}=await Kt(e.id,r);f&&g&&(a=g.layerName,s=(g.styles||[]).map(h=>({...h})),l=g.summaryColumn,d=g.titleColumn,u=Object.fromEntries((g.styles||[]).map(h=>[h.styleName,h.styleTitle])))}if(s[t]&&!s[t]?.colors){let f=await Jt(e.id,n?.workspace,s[t].styleName,r);s[t]={...s[t],colors:f}}return{...o,layerName:a,styles:s,summaryColumn:l,titleColumn:d,propertyMap:u,styleIndex:t}};var Xt=async(e,t,r,n)=>{try{let o=await V.get(`${t}/layer/all`,{headers:{Authorization:e}});return await Yt(o.data,t,r,n)}catch(o){return console.error(o),[]}},Kt=async(e,t)=>{try{let{data:r}=await V.get(`${t}/layer/onClick/${e}`);return{success:!0,data:r}}catch(r){return console.error(r),{success:!1}}},Qt=async(e,t,r)=>{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 V.get(`${e}/${t}/wms`,{params:{...r,...n}})).data}}catch(o){return console.error(o),{success:!1,data:[]}}},er=async(e,t,r,n)=>{try{return await V.put(`${t}/layer/${n?"active":"pending"}/${r}`,{},{headers:{Authorization:e}}),!0}catch(o){return console.error(o),!1}},tr=async(e,t,r)=>{try{return await V.delete(`${t}/layer/${r}`,{headers:{Authorization:e}}),!0}catch(n){return console.error(n),!1}},Jt=async(e,t,r,n)=>{try{return(await V.get(`${n}/geoserver/workspaces/${t}/styles/${e}_${r}.mbstyle`)).data?.layers?.[0]}catch(o){return console.error(o),{}}},vo=(e,t)=>["step",["get","count"],e[0],...t.flatMap((r,n)=>[r,e[n+1]])],rr=async(e,t,r,n=6,o="YlOrRd",a={})=>{try{let[s,l,d]=Se(r),{_ne:u,_sw:f}=t,g={top:u.lat,left:f.lng,bottom:f.lat,right:u.lng,geoAggegationPrecision:s},h=await e(g),b=Zt(h,l),S=a.colors?.length&&a.breaks?.length===a.colors.length-1,M=S?a.colors.map((H,O)=>[a.breaks[O]?a.breaks[O]-1:1/0,H]):jt(h,n).map((H,O)=>[H,Lo[o][n][O]]),D={"fill-color":S?vo(a.colors,a.breaks):{property:"count",default:"yellow",stops:M},"fill-outline-color":a.outlineColor||"rgba(0,0,0,0.2)","fill-opacity":a.opacity??.7};return{success:!0,geojson:b,paint:D,stops:M,squareSize:d}}catch(s){return console.error(s),{success:!1,geojson:{},paint:{},stops:[],squareSize:0}}},or=async(e,t,r,n)=>{try{await V.post(`${e}/layer/download`,{layerName:r,layerTitle:n,attributeList:[],filterArray:[]},{headers:{Authorization:t}})}catch(o){console.error(o)}};import{jsx as Ro}from"react/jsx-runtime";var nr=ko({}),ar=({mp:e,children:t})=>{let[r,n]=T(e),{mapl:o}=Po();Ie(()=>{n(c=>({...c,...e}))},[e]);let[a,s]=T(""),l=wo(a,500),d=r.mapStyles&&r.mapStyles.length>0?r.mapStyles:xo,[u,f]=T(d[r?.mapStyle||0]?.style),[g,h]=T(d[r?.mapStyle||0]?.maxZoom),[b,S]=T(_.TOP),[M,D]=T({}),[H,O]=T(!0),[C,We]=T(),[k,E]=T(e.layers||[]),[x,z]=T(r.selectedLayers||[]);Ie(()=>{r.selectedLayers&&r.selectedLayers.join(",")!==x.join(",")&&z(r.selectedLayers)},[r.selectedLayers]);let[F,be]=T(),[Le,kt]=T(),It=pe(()=>{let c={};for(let m of Le||[])c[m.sourceLayer]=[...c[m.sourceLayer]||[],m?.properties?.[N]];return Object.keys(c).length?c:void 0},[Le]),ie=So.useMemo(()=>{let c=k.filter(y=>x.includes(y.id)),m=new Array(x.length);for(let y of c){let L=x.findIndex(I=>y.id===I);L>-1&&(m[L]=y)}return m},[k,x]),K=P(c=>k.findIndex(m=>m.id===c),[k]),ve=P((c,m)=>{E(y=>y.map(L=>L.id===c?{...L,...m}:L))},[]),xe=P(async(c,m,y)=>{let L=k[c];if(!L)return;let I=await Ye(L,m,r.nakshaApiEndpoint,r.geoserver);ve(L.id,{data:I}),y&&o?.fitBounds(L.bbox,{padding:40,duration:1e3})},[k,r.nakshaApiEndpoint,r.geoserver,ve,o]),Ct=P(async(c,m)=>{let y=K(c);xe(y,m,!1)},[K,xe]),Pt=P(async c=>{if(!(!x.length||!o))try{let m=x[0],y=o.queryRenderedFeatures(c.point,{layers:[m]});if(y.length){let L=y[0]?.id||y[0]?.properties?.[N];if(L===F?.id&&m===F?.layerId)return;let I=k[K(m)];if(!I)return;let le=I?.data?.summaryColumn?.map(we=>[I.data?.propertyMap?.[we]||we,y[0].properties?.[we]]);be({id:L,layerId:m,title:I.title,data:le||[],coordinates:c.lngLat,content:I?.onHover?.({bbox:ke(y[0]),feature:y[0],layerId:m})})}else be(L=>L!==void 0?void 0:L)}catch{}},[x,o,F?.id,F?.layerId,k,K]),Rt=P(async({layerId:c,add:m,styleIndex:y=0,focus:L=!0})=>{if(!m){z(ce=>ce.filter(de=>c!==de));return}let I=K(c),le=k[I];le?.source.type==="grid"?(z(ce=>[c,...ce.filter(de=>de!==c)]),L&&le?.bbox&&setTimeout(()=>{o?.fitBounds(le.bbox,{padding:40,duration:1e3})},100)):(await xe(I,y,L),z(ce=>[c,...ce.filter(de=>de!==c)]))},[K,k,o,xe]),Tt=P(async()=>z([]),[]),Mt=P((c,m)=>{n(y=>({...y,[c]:m}))},[]),Et=P((c,m)=>{let y=m===X.PENDING;er(r.nakshaEndpointToken,r.nakshaApiEndpoint,c,y),ve(c,{layerStatus:y?X.ACTIVE:X.PENDING})},[r.nakshaEndpointToken,r.nakshaApiEndpoint,ve]),Nt=P(async(c,m)=>{confirm(m)&&(tr(r.nakshaEndpointToken,r.nakshaApiEndpoint,c),E(y=>y.filter(L=>L.id!==c)))},[r.nakshaEndpointToken,r.nakshaApiEndpoint]),_t=P(c=>{let m=k.find(y=>y.id===c);m?.bbox&&o?.fitBounds(m.bbox,{padding:40,duration:1e3})},[k,o]),qe=P(()=>C?[C.lng,C.lat,C.lng+.1,C.lat+.1]:[0,0,0,0],[C]),J=P(c=>{if(!(!C||!o))try{let m=o.project([C.lng,C.lat]),y=o.queryRenderedFeatures(m,{layers:b===_.TOP?[x[0]]:x});if((c||b)===_.ALL){let L=ie.filter(I=>I.layerType=="RASTER").map(I=>({sourceLayer:I.id,layerType:"raster",bbox:qe()}));y=[...y,...L]}kt(ie?.[0]?.layerType==="RASTER"&&b!==_.ALL?x.length&&y?.length?y:[{sourceLayer:x[0],layerType:"raster",bbox:qe()}]:y)}catch(m){console.error(m)}},[C,o,b,x,ie,qe]),At=P(c=>{S(c),c===_.TOP&&J(c)},[J]),Bt=Co(!0);Ie(()=>{if(Bt.current){Bt.current=!1;return}r.onSelectedLayersChange&&r.onSelectedLayersChange(x)},[x]),Ie(()=>{let c=setTimeout(J,300);return()=>clearTimeout(c)},[C,b,x,J]);let Ot=pe(()=>({mapStyle:u,featuresAtLatLng:J,setMapStyle:f,maxZoom:g,setMaxZoom:h,mapStyles:d,all:k,setAll:E,selectedIds:x,handleSelectStyle:At,setSelectedIds:z,selectedLayers:ie,clearAll:Tt,toggle:Rt,updateStyle:Ct,selectedFeatures:Le,selectedFeaturesId:It,setSelectedFeatures:kt,togglePublish:Et,delete:Nt,selectionStyle:b,setSelectionStyle:S,zoomToExtent:_t,gridLegends:M,setGridLegends:D}),[u,J,g,d,k,x,At,ie,Tt,Rt,Ct,Le,It,Et,Nt,b,_t,M]),Gt=pe(()=>({term:l,setTerm:s,clickedLngLat:C,setClickedLngLat:We}),[l,C]),Dt=pe(()=>({onHover:Pt,features:F}),[Pt,F]),lo=pe(()=>({mp:r,updateMP:Mt,layer:Ot,query:Gt,isInfoBarOpen:H,setIsInfoBarOpen:O,hover:Dt}),[r,Mt,Ot,Gt,H,Dt]);return Ro(nr.Provider,{value:lo,children:t})};function p(){return Io(nr)}import Mo from"react";import{tw as Pe}from"twind";import{tw as To}from"twind";import{jsx as i,jsxs as Q}from"react/jsx-runtime";var sr=()=>i("svg",{fill:"none",className:To`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"})}),ue=()=>Q("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"})]}),Ce=()=>Q("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"})]}),ir=()=>Q("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 Ke(){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 lr(){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 cr(){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 dr(){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 pr(){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 ur(){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 mr(){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 fr(){return Q("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 yr(){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 gr(){return Q("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 hr(){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 br(){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 Lr(){return Q("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 ee}from"react/jsx-runtime";var $=Mo.forwardRef((e,t)=>ee("button",{ref:t,type:"button",className:Pe`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 Re=e=>ee("button",{className:Pe`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}),vr=e=>ee("button",{className:Pe`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:ee(ue,{})}),xr=e=>ee("button",{className:Pe`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:ee(Ce,{})});import{tw as te}from"twind";import{jsx as A,jsxs as kr}from"react/jsx-runtime";var re=e=>kr("div",{children:[e.label&&A("label",{className:te`text-gray-700`,htmlFor:e.name,children:e.label}),A("select",{id:e.name,name:e.name,className:te`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=>kr("div",{className:"relative",children:[A("span",{className:te`absolute inset-y-0 left-0 flex items-center pl-3`,children:A(sr,{})}),A("input",{type:"search",className:te`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})]}),Sr=e=>e.isLoading?A("svg",{width:"20px",height:"20px",viewBox:"0 0 20 20",version:"1.1",className:te`inline text-gray-200 animate-spin dark:text-gray-600`,children:A("g",{stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:A("g",{fill:"#212121",fillRule:"nonzero",children:A("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"})})})}):A("input",{type:"checkbox",className:te`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 Ir,usePanelState as Eo,useTabState as No}from"@bumaga/tabs";import _o from"clsx";import{tw as Te}from"twind";import{jsx as Je,jsxs as Ao}from"react/jsx-runtime";var Me=({children:e,icon:t})=>{let{onClick:r,isActive:n}=No(),o=_o(["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 Ao("button",{className:Te(o),onClick:r,children:[t,Je("span",{className:Te`ml-2 text-base`,children:e})]})},Ee=({children:e})=>Eo()?Je("div",{className:Te`w-full flex flex-grow-1 overflow-auto`,children:e}):null,Cr=({children:e})=>Je("div",{className:Te`flex flex-shrink-0 border-b border-gray-200 justify-around pr-12`,children:e});import{tw as oe}from"twind";import{jsx as Ne,jsxs as Pr}from"react/jsx-runtime";var Rr=({checked:e=!1,onChange:t,disabled:r=!1,label:n,title:o,id:a})=>Pr("label",{htmlFor:a,title:o,className:oe`inline-flex items-center gap-2 cursor-pointer select-none ${r?"opacity-50 cursor-not-allowed":""}`,children:[n&&Ne("span",{className:oe`text-sm text-gray-600 font-normal`,children:n}),Pr("span",{className:oe`relative inline-flex items-center`,children:[Ne("input",{id:a,type:"checkbox",role:"switch","aria-checked":e,checked:e,disabled:r,onChange:s=>t?.(s.target.checked),className:oe`sr-only`}),Ne("div",{className:oe`w-8 h-4 rounded-full transition-colors duration-200 ease-in-out ${e?"bg-blue-600":"bg-gray-300"}`}),Ne("div",{className:oe`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 Do}from"@biodiv-platform/naksha-commons";import{tw as Ae}from"twind";import{useT as Bo}from"@biodiv-platform/naksha-commons";import{jsx as Tr}from"react/jsx-runtime";function me({hideLabel:e}){let{layer:{selectionStyle:t,handleSelectStyle:r}}=p(),{t:n}=Bo(),o=a=>{r(a.target.value)};return Tr(re,{name:"layer_selection",label:e?null:n("layer_selection"),defaultValue:t,onChange:o,children:Object.values(_).map(a=>Tr("option",{value:a,children:n(a)},a))})}import Oo from"clsx";import{useEffect as Go,useState as Mr}from"react";import{tw as _e}from"twind";import{jsx as fe,jsxs as Xe}from"react/jsx-runtime";function Qe({data:e}){let[t,r]=Mr(!0),[n,o]=Mr({title:e.sourceLayer,properties:[]}),{layer:a,mp:s,query:{clickedLngLat:l}}=p(),d=async()=>{let u,f=a.selectedLayers.find(g=>g.id===(e.sourceLayer||e.source));if(f.layerType.toLowerCase()==="raster"){let{data:g}=await Qt(s.geoserver?.endpoint,s.geoserver?.workspace,{bbox:e.bbox.toString(),query_layers:`${s.geoserver?.workspace}:${f.id}`,layers:`${s.geoserver?.workspace}:${f.id}`});u=g?.features[0]?Object.entries(g.features[0]?.properties).map(([h,b])=>[b||"-"]):[]}else u=Object.entries(f?.data?.propertyMap||{}).map(([g,h])=>[h,e?.properties?.[g]||"-"]);o({title:f.title,properties:u})};return Go(()=>{d()},[l]),Xe("div",{className:_e`bg-gray-100 rounded-lg`,children:[Xe("button",{className:_e(Oo(["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:()=>r(!t),children:[n.title," ",t?fe(br,{}):fe(hr,{})]}),t&&fe("div",{className:_e`px-4 py-3 flex flex-col gap-3`,children:n.properties.map(([u,f],g)=>Xe("div",{children:[fe("div",{className:_e`text-gray-600`,children:u}),fe("div",{children:f})]},u+f+g))})]})}import{jsx as ne,jsxs as et}from"react/jsx-runtime";function tt({onClose:e}){let{layer:{selectedFeatures:t,selectedLayers:r,selectionStyle:n}}=p(),{t:o}=Do();return et("div",{className:Ae`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:[et("div",{className:"flex w-full",children:[et("div",{className:Ae`h-12 px-4 flex items-center gap-3 flex-grow bg-gray-200`,children:[ne(gr,{})," ",o("infobar")]}),ne(Re,{onClick:e})]}),ne("div",{className:Ae`bg-gray-100 p-4 flex-shrink-0 rt`,children:ne(me,{hideLabel:!0})}),ne("div",{className:Ae`flex flex-col flex-grow overflow-auto gap-3 p-4`,children:t.flat(1)?.map(a=>ne(Qe,{data:a},r?.[0]?.source.type==="raster"||n===_.ALL?a?.sourceLayer:a?.sourceLayer+a?.properties[N]))})]})}import{jsx as Er}from"react/jsx-runtime";function rt(){let{layer:e,isInfoBarOpen:t,setIsInfoBarOpen:r}=p();if(!e.selectedFeatures?.length)return null;let n=()=>r(!t);return t?Er(tt,{onClose:n}):Er(xr,{onClick:n})}import Zr,{useEffect as jr,useRef as Nn,useState as _n}from"react";import{useMap as An}from"react-map-gl/maplibre";import{useT as En}from"@biodiv-platform/naksha-commons";import{tw as Ur}from"twind";import{tw as fn}from"twind";import ln,{useMemo as cn}from"react";import{useVirtual as dn}from"react-virtual";import{AutoSizer as pn}from"react-virtualized-auto-sizer";import{tw as Gr}from"twind";import{useT as on}from"@biodiv-platform/naksha-commons";import{useMemo as nn,useState as Or}from"react";import{RWebShare as an}from"react-web-share";import{tw as G}from"twind";import{Fragment as Nr,jsx as Be}from"react/jsx-runtime";var _r=({text:e="",highlight:t=""})=>{if(!t.trim())return Be(Nr,{children:e});let r=new RegExp(`(${t})`,"gi"),n=e.split(r);return Be(Nr,{children:n.filter(o=>o).map((o,a)=>r.test(o)?Be("mark",{children:o},a):Be("span",{children:o},a))})};import{tw as qo}from"twind";import{useT as Ho}from"@biodiv-platform/naksha-commons";import{useState as zo}from"react";import{tw as Fo}from"twind";import{jsx as $o,jsxs as Wo}from"react/jsx-runtime";function ye({children:e}){let[t,r]=zo(!1),{t:n}=Ho();return Wo("div",{children:[t&&e,$o("button",{onClick:()=>r(!t),className:Fo`text-blue-600 focus:outline-none focus:outline focus:ring`,children:n(t?"less":"legend")})]})}import{jsx as Oe,jsxs as Ge}from"react/jsx-runtime";function ot({item:e}){let{layer:t}=p(),r=t.gridLegends[e.id];return r?Oe(ye,{children:Ge("ul",{style:{margin:0,padding:0},children:[r?.stops.map(([n,o],a,s)=>{let l=(s[a-1]||[0])[0];return l===n?Oe("div",{},o):Ge("li",{className:qo`flex gap-2 items-center mb-1`,children:[Oe("svg",{viewBox:"0 0 24 24",height:"14",width:"14",focusable:"false",children:Oe("circle",{cx:"12",fill:o,cy:"12",r:"12",stroke:"none"})}),Ge("div",{children:[l," - ",n]})]},o)}),Ge("li",{children:["1 Square = ",r?.squareSize," x ",r?.squareSize," km"]})]})}):null}import{LICENSES as Vo,useT as Uo}from"@biodiv-platform/naksha-commons";import{useState as Zo}from"react";import{Popover as jo}from"react-tiny-popover";import{tw as U}from"twind";import{jsx as v,jsxs as nt}from"react/jsx-runtime";var ae=({icon:e,name:t,title:r,link:n,children:o})=>{let a=v("span",{className:U`flex-1`,children:o||"-"});return nt("div",{className:U`flex items-center gap-3 text-sm text-gray-600 break-all`,title:t&&r&&`${t}: ${r}`,children:[v("div",{className:U`flex-shrink-0`,children:e}),n?v("a",{className:U`text-blue-700 focus:outline-none focus:ring flex-1`,target:"_blank",rel:"noopener",href:n,children:a}):a]})};function Yo({item:e,containerStyle:t}){let{t:r}=Uo(),{layer:n,mp:o}=p(),a=e.license||"CC-BY",s=e?.createdDate&&new Date(e.createdDate).toLocaleDateString(),l=e.tags?.join(", ");return nt("div",{className:U`flex flex-col gap-1 bg-white p-4 rounded-lg w-72 border border-gray-300 border-solid`,style:t,children:[o.managePublishing&&e.layerStatus&&v(ae,{icon:v(dr,{}),name:r("visiblity"),title:e.layerStatus,children:nt("div",{className:U`flex items-center gap-3`,children:[v("span",{children:e.layerStatus}),v(Rr,{label:r("published"),checked:e.layerStatus?.toLowerCase()===X.ACTIVE.toLowerCase(),onChange:()=>n.togglePublish(e.id,e?.layerStatus)}),v("button",{type:"button",title:r("delete"),className:U`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,r("are_you_sure")),children:v(Lr,{})})]})}),v(ae,{icon:v(Ke,{}),link:e.url,name:r("uploader"),title:e.createdBy,children:e.createdBy}),v(ae,{icon:v(Ke,{}),link:e.url,name:r("created_by"),title:e.attribution,children:e.attribution}),v(ae,{icon:v(pr,{}),name:r("created_on"),title:s,children:s}),v(ae,{icon:v(lr,{}),name:r("tags"),title:l,children:l}),v(ae,{name:r("license"),title:a,link:a&&Vo[a],icon:v(cr,{}),children:a})]})}var Ar=({item:e})=>{let[t,r]=Zo(!1),n=()=>r(!t);return v(jo,{isOpen:t,padding:10,positions:["right"],containerStyle:{zIndex:"99"},onClickOutside:n,content:v(Yo,{item:e}),children:v($,{onClick:n,children:v(Ce,{}),title:"Information"})})};import{tw as tn}from"twind";import{useMemo as Ko,useState as Jo}from"react";import{useT as Xo}from"@biodiv-platform/naksha-commons";import{tw as Qo}from"twind";import{jsx as Z,jsxs as en}from"react/jsx-runtime";function Br({item:e}){let[t,r]=Jo(!0),{mp:n}=p(),{t:o}=Xo(),a=Ko(()=>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])=>en("li",{className:Qo`flex gap-2 items-center mb-1`,children:[Z("svg",{viewBox:"0 0 24 24",height:"14",width:"14",focusable:"false",children:Z("circle",{cx:"12",fill:d,cy:"12",r:"12",stroke:"none"})}),Z("div",{children:l})]},d));return Z("ul",{style:{margin:0,padding:0},children:e.layerType!=="RASTER"?s():t?Z("li",{children:Z("img",{style:{margin:"5px"},onError:()=>r(!1),src:`${n?.geoserver?.endpoint}/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&WIDTH=20&HEIGHT=20&STRICT=false&layer=biodiv:${e.id}`})}):Z("div",{children:o("raster_style_not_found")})})}import{jsx as De,jsxs as rn}from"react/jsx-runtime";function at({item:e}){if(!e.data?.styles)return null;let{layer:t}=p(),r=n=>{t.updateStyle(e.id,Number(n.target.value))};return rn("div",{className:tn`flex flex-col gap-4 pt-2`,children:[e.layerType!=="RASTER"&&De(re,{onChange:r,children:e.data?.styles.map((n,o)=>De("option",{value:o,children:n.styleTitle},o))}),De(ye,{children:De(Br,{item:e})})]})}import{jsx as w,jsxs as j}from"react/jsx-runtime";function sn({dragHandleProps:e}){return w("div",{className:G`mt-1 w-6 text-center cursor-move`,style:{touchAction:"none"},...e,children:w(yr,{})})}function ge({item:e,extended:t,dragHandleProps:r}){let{t:n}=on(),{layer:o,query:a,mp:s,query:{setClickedLngLat:l},setIsInfoBarOpen:d}=p(),[u,f]=Or(o.selectedIds.includes(e.id)),[g,h]=Or(!1),b=nn(()=>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]),S=async()=>{h(!0),d(!0),o.setSelectedFeatures([]),l(null),await o.toggle({layerId:e.id,add:!u}),f(!u),h(!1)},M=async()=>{await or(s.nakshaApiEndpoint,s.nakshaEndpointToken,e.id,e.title),s?.onLayerDownload(e.id)},D=()=>o.zoomToExtent(e.id);return j("div",{className:G`z-20 p-3 bg-white`,style:{borderTop:"1px solid #e5e7eb"},children:[j("div",{className:G`flex gap-3`,children:[j("div",{className:G`flex-shrink-0`,children:[w(Sr,{name:e.id,checked:u,onChange:S,isLoading:g}),t&&w(sn,{dragHandleProps:r})]}),w("img",{className:G`flex-shrink-0 overflow-hidden h-16 w-16 p-1 mb-2 object-cover border border-gray-200 rounded`,src:e.thumbnail||qt}),j("div",{children:[w("div",{title:e.title,className:G`mb-1 leading-tight`,style:Ve,children:w(_r,{text:e.title,highlight:a.term})}),w("p",{title:e.description,className:G`text-gray-600 text-sm`,style:Vt,children:e.description})]})]}),j("div",{className:G`flex justify-between`,children:[j($,{onClick:M,disabled:!e.isDownloadable,children:[w(ur,{})," ",n("download")]}),j("div",{className:G`flex gap-3`,children:[b&&w(an,{data:b,children:w($,{title:"Share",children:w(fr,{})})}),t&&w($,{onClick:D,title:"Zoom To Extent",children:w(mr,{})}),w(Ar,{item:e})]})]}),t&&w(at,{item:e}),t&&e.source.type==="grid"&&w(ot,{item:e})]})}import{jsx as Y}from"react/jsx-runtime";function Dr(){let{layer:e,query:t}=p(),r=cn(()=>t.term?e.all.filter(a=>a.title.toLowerCase().includes(t.term.toLowerCase())):e.all,[e.all,t.term]),n=ln.useRef(null),o=dn({size:r.length,parentRef:n});return Y("div",{className:Gr`flex-grow-1 relative`,children:Y(pn,{renderProp:a=>Y("div",{ref:n,className:"List",style:{height:a.height,overflow:"auto"},children:Y("div",{style:{height:o.totalSize,width:"100%",position:"relative"},children:o.virtualItems.map(s=>Y("div",{ref:s.measureRef,className:Gr`absolute top-0 left-0 w-full`,style:{transform:`translateY(${s.start}px)`},children:Y("div",{style:{height:146},children:Y(ge,{item:r[s.index]})})},s.index))})})})})}import{useT as un}from"@biodiv-platform/naksha-commons";import{tw as mn}from"twind";import{jsx as Hr}from"react/jsx-runtime";function st(){let{t:e}=un(),{query:t}=p(),r=n=>t.setTerm(n.target.value);return Hr("div",{className:mn`flex-shrink-0 border-b-2 p-4`,children:Hr(wr,{name:"lyr_search",placeholder:e("find_layer_by_name"),onChange:r})})}import{jsx as zr,jsxs as yn}from"react/jsx-runtime";function it(){return yn("div",{className:fn`flex flex-col w-full`,children:[zr(st,{}),zr(Dr,{})]})}function gn(e,t,r){let n=t<0?e.length+t:t;if(n>=0&&n<e.length){let o=r<0?e.length+r:r,[a]=e.splice(t,1);e.splice(o,0,a)}}function Fr(e,t,r){return e=[...e],gn(e,t,r),e}import{closestCenter as hn,DndContext as bn,PointerSensor as Ln,useSensor as vn,useSensors as xn}from"@dnd-kit/core";import{SortableContext as wn,useSortable as Sn,verticalListSortingStrategy as kn}from"@dnd-kit/sortable";import{CSS as In}from"@dnd-kit/utilities";import{jsx as se}from"react/jsx-runtime";function Cn({item:e,extended:t}){let{attributes:r,listeners:n,setNodeRef:o,transform:a,transition:s,isDragging:l}=Sn({id:e.id}),d={transform:In.Transform.toString(a),transition:s,opacity:l?.5:1};return se("div",{ref:o,style:d,children:se(ge,{item:e,extended:t,dragHandleProps:{...r,...n}})})}var $r=({layerList:e,onSortEnd:t})=>{let r=xn(vn(Ln,{activationConstraint:{distance:4}}));return se(bn,{sensors:r,collisionDetection:hn,onDragEnd:o=>{let{active:a,over:s}=o;if(s&&a.id!==s.id){let l=e.findIndex(u=>u.id===a.id),d=e.findIndex(u=>u.id===s.id);l!==-1&&d!==-1&&t({oldIndex:l,newIndex:d})}},children:se(wn,{items:e.map(o=>o.id),strategy:kn,children:se("div",{children:e.map(o=>se(Cn,{item:o,extended:!0},o.id))})})})};import{useT as Pn}from"@biodiv-platform/naksha-commons";import{tw as Wr}from"twind";import{jsx as Vr,jsxs as qr}from"react/jsx-runtime";function lt(){let{layer:e}=p(),{t}=Pn(),r=({oldIndex:n,newIndex:o})=>{e.setSelectedIds(Fr(e.selectedIds,n,o))};return qr("div",{className:Wr`flex flex-col gap-3 w-full`,children:[e.selectedIds.length>0&&Vr("div",{className:Wr`p-3 pb-0`,children:qr($,{onClick:()=>e.clearAll(),children:["\u2715 ",t("clear")]})}),Vr($r,{layerList:e.selectedLayers,useDragHandle:!0,onSortEnd:r})]})}import{useT as Rn}from"@biodiv-platform/naksha-commons";import{tw as Tn}from"twind";import{jsx as ct,jsxs as Mn}from"react/jsx-runtime";function dt(){let{layer:e}=p(),{t}=Rn(),r=n=>{e.setMapStyle(n.target.value),e.setMaxZoom(e.mapStyles.find(o=>o.style===n.target.value)?.maxZoom)};return Mn("div",{className:Tn`w-full p-4 flex flex-col gap-4`,children:[ct(re,{name:"base_style",label:t("base_style"),defaultValue:e.mapStyle,onChange:r,children:e.mapStyles.map(n=>ct("option",{value:n.style,children:n.text},n.key))}),ct(me,{})]})}import{jsx as R,jsxs as pt}from"react/jsx-runtime";function ut({onClose:e}){let{t}=En();return pt("div",{className:Ur`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:[R(Re,{onClick:e}),R("div",{className:Ur`flex flex-col h-full`,children:pt(Ir,{children:[pt(Cr,{children:[R(Me,{icon:R(ue,{}),children:t("layers")}),R(Me,{icon:R(ue,{}),children:t("selected")}),R(Me,{icon:R(ir,{}),children:t("settings")})]}),R(Ee,{children:R(it,{})}),R(Ee,{children:R(lt,{})}),R(Ee,{children:R(dt,{})})]})})]})}import{jsx as Yr}from"react/jsx-runtime";function mt(){let{mp:e,layer:t}=p(),[r,n]=_n(e.showToC),{mapl:o}=An(),a=Nn(!1),s=Zr.useCallback(()=>n(d=>!d),[]),l=Zr.useCallback(async()=>{let d=await Xt(e.nakshaEndpointToken,e.nakshaApiEndpoint,e.geoserver,e.selectedLayers),u=[...e.layers||[],...d];if(t.setAll(u),t.selectedIds.length){let f=u.find(g=>g.id===t.selectedIds[0]);f?.bbox&&o?.fitBounds(f.bbox,{padding:40,duration:1e3})}},[e.nakshaEndpointToken,e.nakshaApiEndpoint,e.geoserver,e.selectedLayers,e.layers,t.setAll,t.selectedIds,o]);return jr(()=>{e.loadToC&&!a.current&&(a.current=!0,l())},[e.loadToC]),jr(()=>{if(o&&t.selectedIds.length&&t.all?.length){let d=t.all.find(u=>u.id===t.selectedIds[0]);d?.bbox&&o.fitBounds(d.bbox,{padding:40,duration:1e3})}},[o]),r?Yr(ut,{onClose:s}):Yr(vr,{onClick:s})}import{config as W}from"maplibre-gl";var Kr="https://unpkg.com/maplibre-gl@6.16.0/dist/maplibre-gl-worker.mjs";typeof window<"u"&&!W.WORKER_URL&&(W.WORKER_URL="/maplibre-gl-worker.mjs");var He=null;async function Jr(e){return e?(W.WORKER_URL=e,e):W.WORKER_URL&&W.WORKER_URL!=="/maplibre-gl-worker.mjs"?W.WORKER_URL:typeof window>"u"?"":He||(He=(async()=>{try{let t=await fetch("/maplibre-gl-worker.mjs",{method:"HEAD"}),r=t.headers.get("content-type")||"";if(t.ok&&!r.includes("text/html"))return W.WORKER_URL="/maplibre-gl-worker.mjs","/maplibre-gl-worker.mjs"}catch{}return W.WORKER_URL=Kr,Kr})(),He)}import{useMap as Zn}from"react-map-gl/maplibre";import Bn from"@turf/bbox";import{useEffect as ft,useRef as On,useState as Gn}from"react";import{Layer as Dn,Source as Hn,useMap as zn}from"react-map-gl/maplibre";import{jsx as Xr}from"react/jsx-runtime";function yt({data:e,beforeId:t}){let{layer:r}=p(),{mapl:n}=zn(),[o,a]=Gn({geojson:{},paint:{}}),s=On(""),l=r.selectedIds.includes(e.id),d=r.selectedIds[0]===e.id,u=async(f=!1)=>{if(!n)return;let g=n.getBounds(),h=n.getZoom();if(!g)return;let[b]=Se(h),{_ne:S,_sw:M}=g,D=`${S.lat.toFixed(4)},${M.lng.toFixed(4)},${M.lat.toFixed(4)},${S.lng.toFixed(4)},${b}`;if(D===s.current)return;s.current=D;let{success:H,geojson:O,paint:C,stops:We,squareSize:k}=await rr(e.source.fetcher,g,h,void 0,void 0,e.source);if(H){if(a({geojson:O,paint:C}),f&&d&&e.zoomToFit)try{let E=Bn(O);if(E.every(Number.isFinite)){let[x,z,F,be]=E;n.fitBounds([[x,z],[F,be]],{padding:40,animate:!0})}}catch(E){console.warn("Failed to compute bbox",E)}r.setGridLegends(E=>({...E,[e.id]:{stops:We,squareSize:k}}))}};return ft(()=>{l&&d?u(!0):l&&u(!1)},[l,d]),ft(()=>{if(!l||!n)return;let f=()=>u(!1);return n.on("moveend",f),()=>{n.off("moveend",f)}},[l,n]),ft(()=>()=>{r.setGridLegends(f=>{let g={...f};return delete g[e.id],g})},[e.id]),Xr(Hn,{id:e.id,type:"geojson",data:o.geojson,children:Xr(Dn,{beforeId:t,id:e.id,type:"fill",paint:o.paint})})}import{useMemo as Fn}from"react";import{Layer as Qr,Source as $n}from"react-map-gl/maplibre";import{jsx as eo,jsxs as qn}from"react/jsx-runtime";var Wn={fill:{"line-color":"red","line-width":2},circle:{"circle-stroke-color":"red","circle-stroke-width":2,"circle-opacity":0}};function ze({layer:e,beforeId:t}){let{layer:r}=p(),n=Fn(()=>e.data?.styles?.[e.data?.styleIndex]?.colors,[e,r.selectedFeatures]),o=r.selectedFeaturesId?.[e.id];return qn($n,{...e.source,children:[n&&eo(Qr,{beforeId:t,...n}),o&&n&&eo(Qr,{...n,beforeId:t,id:`hl_${e.id}`,filter:["in",N,...o],type:n.type==="fill"?"line":n.type,paint:Wn[n.type]})]})}import{Layer as Vn,Source as Un}from"react-map-gl/maplibre";import{jsx as to}from"react/jsx-runtime";function gt({data:e,beforeId:t}){let{mp:r}=p();return to(Un,{id:e.id,type:"raster",tiles:[`${r?.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:to(Vn,{id:e.id,beforeId:t,type:"raster",source:"biodiv",layout:{visibility:"visible"},paint:{}})})}import{jsx as Fe}from"react/jsx-runtime";function ro({layer:e,beforeId:t}){let{mapl:r}=Zn();if(!r)return null;switch(e.source.type){case"vector":return Fe(ze,{beforeId:t,layer:e});case"grid":return Fe(yt,{beforeId:t,data:e});case"raster":return Fe(gt,{beforeId:t,data:e});default:return Fe(ze,{beforeId:t,layer:e})}}import{useMemo as jn}from"react";import{Marker as Yn}from"react-map-gl/maplibre";import{Fragment as Xn,jsx as ht}from"react/jsx-runtime";var Kn=Yn,Jn=()=>{let{mp:e}=p(),t=jn(()=>e.markers,[e.markers]);return ht(Xn,{children:t?.map(({latitude:r,longitude:n,colorHex:o,anchor:a="bottom",iconUrl:s},l)=>ht(Kn,{latitude:r,longitude:n,anchor:a,subpixelPositioning:!0,children:ht("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))})},oo=Jn;import Qn from"clsx";import{Popup as ea}from"react-map-gl/maplibre";import{tw as he}from"twind";import{jsx as q,jsxs as ao}from"react/jsx-runtime";var no=ea;function bt({coordinates:e}){let{hover:t}=p(),r=e||t.features?.coordinates;return!r?.lat||!t.features?null:t.features.content?q(no,{latitude:r.lat,longitude:r.lng,closeButton:!1,maxWidth:"320px",children:t.features.content}):q(no,{latitude:r.lat,longitude:r.lng,closeButton:!1,children:ao("table",{className:he`table-auto border`,children:[q("thead",{children:q("tr",{children:q("th",{className:he`bg-gray-200 py-1 px-2`,colSpan:2,children:t.features.title})})}),q("tbody",{children:t.features.data.map(([n,o],a)=>ao("tr",{className:he(Qn({"bg-gray-50":a%2===0,"border-gray-100 border-t":1})),children:[q("td",{className:he`py-1 px-2`,children:n}),q("td",{className:he`py-1 px-2 border-l border-gray-100`,children:o})]},n+o))})]})})}import{useControl as ta}from"react-map-gl/maplibre";var ra='<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="margin:auto"><circle cx="12" cy="12" r="7"/><circle cx="12" cy="12" r="2"/><path d="M12 2v3M12 19v3M2 12h3M19 12h3"/></svg>',Lt=class{constructor(t,r){this.onReset=t;this.title=r}onReset;title;container;onAdd(){this.container=document.createElement("div"),this.container.className="maplibregl-ctrl maplibregl-ctrl-group";let t=document.createElement("button");return t.type="button",t.title=this.title,t.setAttribute("aria-label",this.title),t.style.display="flex",t.innerHTML=ra,t.onclick=this.onReset,this.container.appendChild(t),this.container}onRemove(){this.container?.remove()}};function vt({viewState:e,position:t="bottom-right"}){return ta(({map:r})=>new Lt(()=>r.flyTo({center:[e.longitude,e.latitude],zoom:e.zoom}),"Reset view"),{position:t}),null}import{jsx as B,jsxs as io}from"react/jsx-runtime";var ua=ia,ma=la;function St(){let{mp:e,layer:t,hover:r,query:n}=p(),[o,a]=so(e.workerUrl||(typeof window<"u"?da.WORKER_URL||"/maplibre-gl-worker.mjs":void 0));wt(()=>{Jr(e.workerUrl).then(a)},[e.workerUrl]);let s=na(()=>e.defaultViewState||oa,[e.defaultViewState]),[l,d]=so();wt(()=>d(void 0),[t.selectedIds.join(",")]);let u=xt.useCallback(h=>{let b=t.selectedLayers[0];if(!b?.onClick){n.setClickedLngLat(h.lngLat);return}let S=h.target.queryRenderedFeatures(h.point,{layers:[b.id]})[0];d(S&&{lngLat:h.lngLat,content:b.onClick({bbox:ke(S),feature:S,layerId:b.id})})},[t.selectedLayers,n]),f=xt.useRef(null),g=xt.useCallback(h=>{f.current||(f.current=requestAnimationFrame(()=>{f.current=null,r.onHover(h)}))},[r]);return wt(()=>()=>{f.current&&cancelAnimationFrame(f.current)},[]),io("div",{className:pa`h-full w-full relative bg-gray-100`,children:[e.loadToC&&B(mt,{}),t.selectedFeatures?.length>0&&B(rt,{}),io(aa,{id:"mapl",workerUrl:o,cursor:"default",initialViewState:s,style:{width:"100%",height:"100%"},mapStyle:t.mapStyle,maxZoom:t.maxZoom,onClick:u,onMouseMove:g,children:[e.showScaleControl&&B(ca,{position:"bottom-right"}),e.showResetControl&&B(vt,{viewState:s,position:"bottom-right"}),B(ua,{position:"bottom-right",showZoom:!0,showCompass:!0}),e.showFullscreenControl&&B(sa,{position:"bottom-right"}),B(oo,{}),t.selectedLayers.map((h,b)=>{let S=b>0?t.selectedIds[b-1]:void 0;return B(ro,{layer:h,beforeId:S},h.id)}),l?B(ma,{latitude:l.lngLat.lat,longitude:l.lngLat.lng,closeOnClick:!1,onClose:()=>d(void 0),maxWidth:"320px",children:l.content}):B(bt,{},"popup")]})]})}import{jsx as $e}from"react/jsx-runtime";ha({preflight:!1});var cd=e=>{let t=ya.useMemo(()=>({...Wt,...e}),[e]);return $e(ga,{children:$e(fa,{localeStrings:$t,lang:t.lang,children:$e(ar,{mp:t,children:$e(St,{})})})})};export{cd as NakshaMaplibreLayers};
|
|
1
|
+
import{TranslationProvider as ya}from"@biodiv-platform/naksha-commons";import ga from"react";import{MapProvider as ha}from"react-map-gl/maplibre";import{setup as ba}from"twind";var Ht={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 zt={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 Ft={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 $t={en:Ht,fr:zt,hi:Ft};import{defaultViewState as oa}from"@biodiv-platform/naksha-commons";import be,{useEffect as We,useMemo as na,useState as so}from"react";import aa,{FullscreenControl as sa,NavigationControl as ia,Popup as la,ScaleControl as ca}from"react-map-gl/maplibre";import{config as da}from"maplibre-gl";import{tw as pa}from"twind";import{defaultMapStyles as xo,useDebounce as wo}from"@biodiv-platform/naksha-commons";import So,{createContext as ko,useCallback as R,useContext as Io,useEffect as Ce,useMemo as pe,useRef as Co,useState as N}from"react";import{useMap as Po}from"react-map-gl/maplibre";import Lo from"colorbrewer";import V from"redaxios";import Ut from"boundingbox";import{GeoHash as Ye}from"geohash";import{MapStyles as mo,defaultViewState as fo}from"@biodiv-platform/naksha-commons";var Wt={defaultViewState:fo,nakshaApiEndpoint:"/naksha-api/api",geoserver:{endpoint:"/geoserver",workspace:"biodiv",store:"ibp"},mapStyle:mo.MAP_STREETS,layers:[],selectedLayers:[]},qt="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",Ze={display:"-webkit-box",WebkitLineClamp:1,WebkitBoxOrient:"vertical",overflow:"hidden",wordBreak:"break-word"},Vt={...Ze,WebkitLineClamp:2},B="ogc_fid",X={ACTIVE:"Active",PENDING:"Pending"},O={TOP:"layer_selection_top",ALL:"layer_selection_all"};var ke=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],je="0123456789bcdefghjkmnpqrstuvwxyz",yo=(e,t,r)=>{r=r||16/2**(1-e.length&1)/4**t;let n=e.slice(0,-1),o=~~(je.indexOf(e.slice(-1))/r);return[n+je[r*o],n+je[r*(o+1)-1]]},Ke=e=>typeof e=="number"?{count:e}:e,go=(e,t)=>{for(let[r,n]of Object.entries(t))e[r]=(e[r]||0)+n;return e},ho=function(e,t){var r=new Map,n=new Map;let o=[];for(let[a,s]of Object.entries(e)){let[l,d]=yo(a,t);n.set(l,d),r.set(l,go(r.get(l)||{},Ke(s)))}return r.forEach((a,s)=>{let l=Ye.decodeGeoHash(s),d=Ye.decodeGeoHash(n.get(s)),u=new Ut({minlat:l.latitude[0],minlon:l.longitude[0],maxlat:d.latitude[1],maxlon:d.longitude[1]}).toGeoJSON();o.push({...u,properties:{...a,[B]:s}})}),o},bo=e=>{let t=[];for(let[r,n]of Object.entries(e)){let o=Ye.decodeGeoHash(r),a=new Ut({minlat:o.latitude[0],minlon:o.longitude[0],maxlat:o.latitude[1],maxlon:o.longitude[1]}).toGeoJSON();t.push({...a,properties:{...Ke(n),[B]:r}})}return t},Zt=(e,t)=>({type:"FeatureCollection",features:Object.keys(e).length===0?[]:t===-1?bo(e):ho(e,t)}),jt=(e,t)=>{let r=Object.values(e).map(a=>Ke(a).count).sort((a,s)=>a-s),n=Math.floor(r.length/t),o=new Array(t-1).fill(0).map((a,s)=>r[n*(s+1)]);return o.push(r[r.length-1]),o},Ie=e=>{let t=[],r=a=>typeof a[0]=="number"?t.push(a):a.forEach(r);if(r(e?.geometry?.coordinates||[]),!t.length)return;let n=t.map(([a])=>a),o=t.map(([,a])=>a);return[Math.min(...n),Math.min(...o),Math.max(...n),Math.max(...o)]};var Yt=async(e,t,r,n)=>Promise.all((e||[]).map(async o=>{let a=n?.includes(o.name),s=o.layerType?.toLowerCase()==="raster",l={...o,id:o.name,thumbnail:t+o.thumbnail,source:{type:s?"raster":"vector",scheme:"tms",tiles:[`${r.endpoint}/gwc/service/tms/1.0.0/${r.workspace}:${o.name}@EPSG%3A900913@pbf/{z}/{x}/{y}.pbf`]},data:{styles:[]},isAdded:a};if(a&&!s){let d=await Je(l,0,t,r);return{...l,data:d}}return l})),Je=async(e,t,r,n)=>{let o=e.data||{styles:[]},a=o.layerName,s=o.styles?[...o.styles]:[],l=o.summaryColumn,d=o.titleColumn,u=o.propertyMap;if(s.length===0){let{success:f,data:g}=await Kt(e.id,r);f&&g&&(a=g.layerName,s=(g.styles||[]).map(v=>({...v})),l=g.summaryColumn,d=g.titleColumn,u=Object.fromEntries((g.styles||[]).map(v=>[v.styleName,v.styleTitle])))}if(s[t]&&!s[t]?.colors){let f=await Jt(e.id,n?.workspace,s[t].styleName,r);s[t]={...s[t],colors:f}}return{...o,layerName:a,styles:s,summaryColumn:l,titleColumn:d,propertyMap:u,styleIndex:t}};var Xt=async(e,t,r,n)=>{try{let o=await V.get(`${t}/layer/all`,{headers:{Authorization:e}});return await Yt(o.data,t,r,n)}catch(o){return console.error(o),[]}},Kt=async(e,t)=>{try{let{data:r}=await V.get(`${t}/layer/onClick/${e}`);return{success:!0,data:r}}catch(r){return console.error(r),{success:!1}}},Qt=async(e,t,r)=>{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 V.get(`${e}/${t}/wms`,{params:{...r,...n}})).data}}catch(o){return console.error(o),{success:!1,data:[]}}},er=async(e,t,r,n)=>{try{return await V.put(`${t}/layer/${n?"active":"pending"}/${r}`,{},{headers:{Authorization:e}}),!0}catch(o){return console.error(o),!1}},tr=async(e,t,r)=>{try{return await V.delete(`${t}/layer/${r}`,{headers:{Authorization:e}}),!0}catch(n){return console.error(n),!1}},Jt=async(e,t,r,n)=>{try{return(await V.get(`${n}/geoserver/workspaces/${t}/styles/${e}_${r}.mbstyle`)).data?.layers?.[0]}catch(o){return console.error(o),{}}},vo=(e,t)=>["step",["get","count"],e[0],...t.flatMap((r,n)=>[r,e[n+1]])],rr=async(e,t,r,n=6,o="YlOrRd",a={})=>{try{let[s,l,d]=ke(r),{_ne:u,_sw:f}=t,g={top:u.lat,left:f.lng,bottom:f.lat,right:u.lng,geoAggegationPrecision:s},v=await e(g),k=Zt(v,l),h=a.colors?.length&&a.breaks?.length===a.colors.length-1,b=h?a.colors.map((_,E)=>[a.breaks[E]?a.breaks[E]-1:1/0,_]):jt(v,n).map((_,E)=>[_,Lo[o][n][E]]),I={"fill-color":h?vo(a.colors,a.breaks):{property:"count",default:"yellow",stops:b},"fill-outline-color":a.outlineColor||"rgba(0,0,0,0.2)","fill-opacity":a.opacity??.7};return{success:!0,geojson:k,paint:I,stops:b,squareSize:d}}catch(s){return console.error(s),{success:!1,geojson:{},paint:{},stops:[],squareSize:0}}},or=async(e,t,r,n)=>{try{await V.post(`${e}/layer/download`,{layerName:r,layerTitle:n,attributeList:[],filterArray:[]},{headers:{Authorization:t}})}catch(o){console.error(o)}};import{jsx as To}from"react/jsx-runtime";var nr=ko({}),ar=({mp:e,children:t})=>{let[r,n]=N(e),{mapl:o}=Po();Ce(()=>{n(c=>({...c,...e}))},[e]);let[a,s]=N(""),l=wo(a,500),d=r.mapStyles&&r.mapStyles.length>0?r.mapStyles:xo,[u,f]=N(d[r?.mapStyle||0]?.style),[g,v]=N(d[r?.mapStyle||0]?.maxZoom),[k,h]=N(O.TOP),[b,I]=N({}),[_,E]=N(!0),[S,Ve]=N(),[P,A]=N(e.layers||[]),[w,z]=N(r.selectedLayers||[]);Ce(()=>{r.selectedLayers&&r.selectedLayers.join(",")!==w.join(",")&&z(r.selectedLayers)},[r.selectedLayers]);let[F,Le]=N(),[ve,kt]=N(),It=pe(()=>{let c={};for(let m of ve||[])c[m.sourceLayer]=[...c[m.sourceLayer]||[],m?.properties?.[B]];return Object.keys(c).length?c:void 0},[ve]),ie=So.useMemo(()=>{let c=P.filter(y=>w.includes(y.id)),m=new Array(w.length);for(let y of c){let L=w.findIndex(T=>y.id===T);L>-1&&(m[L]=y)}return m},[P,w]),K=R(c=>P.findIndex(m=>m.id===c),[P]),xe=R((c,m)=>{A(y=>y.map(L=>L.id===c?{...L,...m}:L))},[]),we=R(async(c,m,y)=>{let L=P[c];if(!L)return;let T=await Je(L,m,r.nakshaApiEndpoint,r.geoserver);xe(L.id,{data:T}),y&&o?.fitBounds(L.bbox,{padding:40,duration:1e3})},[P,r.nakshaApiEndpoint,r.geoserver,xe,o]),Ct=R(async(c,m)=>{let y=K(c);we(y,m,!1)},[K,we]),Pt=R(async c=>{if(!(!w.length||!o))try{let m=w[0],y=o.queryRenderedFeatures(c.point,{layers:[m]});if(y.length){let L=y[0]?.id||y[0]?.properties?.[B];if(L===F?.id&&m===F?.layerId)return;let T=P[K(m)];if(!T)return;let le=T?.data?.summaryColumn?.map(Se=>[T.data?.propertyMap?.[Se]||Se,y[0].properties?.[Se]]);Le({id:L,layerId:m,title:T.title,data:le||[],coordinates:c.lngLat,content:T?.onHover?.({bbox:Ie(y[0]),feature:y[0],layerId:m})})}else Le(L=>L!==void 0?void 0:L)}catch{}},[w,o,F?.id,F?.layerId,P,K]),Tt=R(async({layerId:c,add:m,styleIndex:y=0,focus:L=!0})=>{if(!m){z(ce=>ce.filter(de=>c!==de));return}let T=K(c),le=P[T];le?.source.type==="grid"?(z(ce=>[c,...ce.filter(de=>de!==c)]),L&&le?.bbox&&setTimeout(()=>{o?.fitBounds(le.bbox,{padding:40,duration:1e3})},100)):(await we(T,y,L),z(ce=>[c,...ce.filter(de=>de!==c)]))},[K,P,o,we]),Rt=R(async()=>z([]),[]),Mt=R((c,m)=>{n(y=>({...y,[c]:m}))},[]),Et=R((c,m)=>{let y=m===X.PENDING;er(r.nakshaEndpointToken,r.nakshaApiEndpoint,c,y),xe(c,{layerStatus:y?X.ACTIVE:X.PENDING})},[r.nakshaEndpointToken,r.nakshaApiEndpoint,xe]),Nt=R(async(c,m)=>{confirm(m)&&(tr(r.nakshaEndpointToken,r.nakshaApiEndpoint,c),A(y=>y.filter(L=>L.id!==c)))},[r.nakshaEndpointToken,r.nakshaApiEndpoint]),_t=R(c=>{let m=P.find(y=>y.id===c);m?.bbox&&o?.fitBounds(m.bbox,{padding:40,duration:1e3})},[P,o]),Ue=R(()=>S?[S.lng,S.lat,S.lng+.1,S.lat+.1]:[0,0,0,0],[S]),J=R(c=>{if(!(!S||!o))try{let m=o.project([S.lng,S.lat]),y=o.queryRenderedFeatures(m,{layers:k===O.TOP?[w[0]]:w});if((c||k)===O.ALL){let L=ie.filter(T=>T.layerType=="RASTER").map(T=>({sourceLayer:T.id,layerType:"raster",bbox:Ue()}));y=[...y,...L]}kt(ie?.[0]?.layerType==="RASTER"&&k!==O.ALL?w.length&&y?.length?y:[{sourceLayer:w[0],layerType:"raster",bbox:Ue()}]:y)}catch(m){console.error(m)}},[S,o,k,w,ie,Ue]),At=R(c=>{h(c),c===O.TOP&&J(c)},[J]),Bt=Co(!0);Ce(()=>{if(Bt.current){Bt.current=!1;return}r.onSelectedLayersChange&&r.onSelectedLayersChange(w)},[w]),Ce(()=>{let c=setTimeout(J,300);return()=>clearTimeout(c)},[S,k,w,J]);let Ot=pe(()=>({mapStyle:u,featuresAtLatLng:J,setMapStyle:f,maxZoom:g,setMaxZoom:v,mapStyles:d,all:P,setAll:A,selectedIds:w,handleSelectStyle:At,setSelectedIds:z,selectedLayers:ie,clearAll:Rt,toggle:Tt,updateStyle:Ct,selectedFeatures:ve,selectedFeaturesId:It,setSelectedFeatures:kt,togglePublish:Et,delete:Nt,selectionStyle:k,setSelectionStyle:h,zoomToExtent:_t,gridLegends:b,setGridLegends:I}),[u,J,g,d,P,w,At,ie,Rt,Tt,Ct,ve,It,Et,Nt,k,_t,b]),Gt=pe(()=>({term:l,setTerm:s,clickedLngLat:S,setClickedLngLat:Ve}),[l,S]),Dt=pe(()=>({onHover:Pt,features:F}),[Pt,F]),lo=pe(()=>({mp:r,updateMP:Mt,layer:Ot,query:Gt,isInfoBarOpen:_,setIsInfoBarOpen:E,hover:Dt}),[r,Mt,Ot,Gt,_,Dt]);return To(nr.Provider,{value:lo,children:t})};function p(){return Io(nr)}import Mo from"react";import{tw as Te}from"twind";import{tw as Ro}from"twind";import{jsx as i,jsxs as Q}from"react/jsx-runtime";var sr=()=>i("svg",{fill:"none",className:Ro`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"})}),ue=()=>Q("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"})]}),Pe=()=>Q("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"})]}),ir=()=>Q("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 Xe(){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 lr(){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 cr(){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 dr(){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 pr(){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 ur(){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 mr(){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 fr(){return Q("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 yr(){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 gr(){return Q("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 hr(){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 br(){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 Lr(){return Q("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 ee}from"react/jsx-runtime";var $=Mo.forwardRef((e,t)=>ee("button",{ref:t,type:"button",className:Te`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 Re=e=>ee("button",{className:Te`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}),vr=e=>ee("button",{className:Te`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:ee(ue,{})}),xr=e=>ee("button",{className:Te`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:ee(Pe,{})});import{tw as te}from"twind";import{jsx as G,jsxs as kr}from"react/jsx-runtime";var re=e=>kr("div",{children:[e.label&&G("label",{className:te`text-gray-700`,htmlFor:e.name,children:e.label}),G("select",{id:e.name,name:e.name,className:te`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=>kr("div",{className:"relative",children:[G("span",{className:te`absolute inset-y-0 left-0 flex items-center pl-3`,children:G(sr,{})}),G("input",{type:"search",className:te`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})]}),Sr=e=>e.isLoading?G("svg",{width:"20px",height:"20px",viewBox:"0 0 20 20",version:"1.1",className:te`inline text-gray-200 animate-spin dark:text-gray-600`,children:G("g",{stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:G("g",{fill:"#212121",fillRule:"nonzero",children:G("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"})})})}):G("input",{type:"checkbox",className:te`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 Ir,usePanelState as Eo,useTabState as No}from"@bumaga/tabs";import _o from"clsx";import{tw as Me}from"twind";import{jsx as Qe,jsxs as Ao}from"react/jsx-runtime";var Ee=({children:e,icon:t})=>{let{onClick:r,isActive:n}=No(),o=_o(["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 Ao("button",{className:Me(o),onClick:r,children:[t,Qe("span",{className:Me`ml-2 text-base`,children:e})]})},Ne=({children:e})=>Eo()?Qe("div",{className:Me`w-full flex flex-grow-1 overflow-auto`,children:e}):null,Cr=({children:e})=>Qe("div",{className:Me`flex flex-shrink-0 border-b border-gray-200 justify-around pr-12`,children:e});import{tw as oe}from"twind";import{jsx as _e,jsxs as Pr}from"react/jsx-runtime";var Tr=({checked:e=!1,onChange:t,disabled:r=!1,label:n,title:o,id:a})=>Pr("label",{htmlFor:a,title:o,className:oe`inline-flex items-center gap-2 cursor-pointer select-none ${r?"opacity-50 cursor-not-allowed":""}`,children:[n&&_e("span",{className:oe`text-sm text-gray-600 font-normal`,children:n}),Pr("span",{className:oe`relative inline-flex items-center`,children:[_e("input",{id:a,type:"checkbox",role:"switch","aria-checked":e,checked:e,disabled:r,onChange:s=>t?.(s.target.checked),className:oe`sr-only`}),_e("div",{className:oe`w-8 h-4 rounded-full transition-colors duration-200 ease-in-out ${e?"bg-blue-600":"bg-gray-300"}`}),_e("div",{className:oe`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 Do}from"@biodiv-platform/naksha-commons";import{tw as Be}from"twind";import{useT as Bo}from"@biodiv-platform/naksha-commons";import{jsx as Rr}from"react/jsx-runtime";function me({hideLabel:e}){let{layer:{selectionStyle:t,handleSelectStyle:r}}=p(),{t:n}=Bo(),o=a=>{r(a.target.value)};return Rr(re,{name:"layer_selection",label:e?null:n("layer_selection"),defaultValue:t,onChange:o,children:Object.values(O).map(a=>Rr("option",{value:a,children:n(a)},a))})}import Oo from"clsx";import{useEffect as Go,useState as Mr}from"react";import{tw as Ae}from"twind";import{jsx as fe,jsxs as et}from"react/jsx-runtime";function tt({data:e}){let[t,r]=Mr(!0),[n,o]=Mr({title:e.sourceLayer,properties:[]}),{layer:a,mp:s,query:{clickedLngLat:l}}=p(),d=async()=>{let u,f=a.selectedLayers.find(g=>g.id===(e.sourceLayer||e.source));if(f.layerType.toLowerCase()==="raster"){let{data:g}=await Qt(s.geoserver?.endpoint,s.geoserver?.workspace,{bbox:e.bbox.toString(),query_layers:`${s.geoserver?.workspace}:${f.id}`,layers:`${s.geoserver?.workspace}:${f.id}`});u=g?.features[0]?Object.entries(g.features[0]?.properties).map(([v,k])=>[k||"-"]):[]}else u=Object.entries(f?.data?.propertyMap||{}).map(([g,v])=>[v,e?.properties?.[g]||"-"]);o({title:f.title,properties:u})};return Go(()=>{d()},[l]),et("div",{className:Ae`bg-gray-100 rounded-lg`,children:[et("button",{className:Ae(Oo(["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:()=>r(!t),children:[n.title," ",t?fe(br,{}):fe(hr,{})]}),t&&fe("div",{className:Ae`px-4 py-3 flex flex-col gap-3`,children:n.properties.map(([u,f],g)=>et("div",{children:[fe("div",{className:Ae`text-gray-600`,children:u}),fe("div",{children:f})]},u+f+g))})]})}import{jsx as ne,jsxs as rt}from"react/jsx-runtime";function ot({onClose:e}){let{layer:{selectedFeatures:t,selectedLayers:r,selectionStyle:n}}=p(),{t:o}=Do();return rt("div",{className:Be`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:[rt("div",{className:"flex w-full",children:[rt("div",{className:Be`h-12 px-4 flex items-center gap-3 flex-grow bg-gray-200`,children:[ne(gr,{})," ",o("infobar")]}),ne(Re,{onClick:e})]}),ne("div",{className:Be`bg-gray-100 p-4 flex-shrink-0 rt`,children:ne(me,{hideLabel:!0})}),ne("div",{className:Be`flex flex-col flex-grow overflow-auto gap-3 p-4`,children:t.flat(1)?.map(a=>ne(tt,{data:a},r?.[0]?.source.type==="raster"||n===O.ALL?a?.sourceLayer:a?.sourceLayer+a?.properties[B]))})]})}import{jsx as Er}from"react/jsx-runtime";function nt(){let{layer:e,isInfoBarOpen:t,setIsInfoBarOpen:r}=p();if(!e.selectedFeatures?.length)return null;let n=()=>r(!t);return t?Er(ot,{onClose:n}):Er(xr,{onClick:n})}import Zr,{useEffect as jr,useRef as Nn,useState as _n}from"react";import{useMap as An}from"react-map-gl/maplibre";import{useT as En}from"@biodiv-platform/naksha-commons";import{tw as Ur}from"twind";import{tw as fn}from"twind";import ln,{useMemo as cn}from"react";import{useVirtual as dn}from"react-virtual";import{AutoSizer as pn}from"react-virtualized-auto-sizer";import{tw as Gr}from"twind";import{useT as on}from"@biodiv-platform/naksha-commons";import{useMemo as nn,useState as Or}from"react";import{RWebShare as an}from"react-web-share";import{tw as H}from"twind";import{Fragment as Nr,jsx as Oe}from"react/jsx-runtime";var _r=({text:e="",highlight:t=""})=>{if(!t.trim())return Oe(Nr,{children:e});let r=new RegExp(`(${t})`,"gi"),n=e.split(r);return Oe(Nr,{children:n.filter(o=>o).map((o,a)=>r.test(o)?Oe("mark",{children:o},a):Oe("span",{children:o},a))})};import{tw as qo}from"twind";import{useT as Ho}from"@biodiv-platform/naksha-commons";import{useState as zo}from"react";import{tw as Fo}from"twind";import{jsx as $o,jsxs as Wo}from"react/jsx-runtime";function ye({children:e}){let[t,r]=zo(!1),{t:n}=Ho();return Wo("div",{children:[t&&e,$o("button",{onClick:()=>r(!t),className:Fo`text-blue-600 focus:outline-none focus:outline focus:ring`,children:n(t?"less":"legend")})]})}import{jsx as Ge,jsxs as De}from"react/jsx-runtime";function at({item:e}){let{layer:t}=p(),r=t.gridLegends[e.id];return r?Ge(ye,{children:De("ul",{style:{margin:0,padding:0},children:[r?.stops.map(([n,o],a,s)=>{let l=(s[a-1]||[0])[0];return l===n?Ge("div",{},o):De("li",{className:qo`flex gap-2 items-center mb-1`,children:[Ge("svg",{viewBox:"0 0 24 24",height:"14",width:"14",focusable:"false",children:Ge("circle",{cx:"12",fill:o,cy:"12",r:"12",stroke:"none"})}),De("div",{children:[l," - ",n]})]},o)}),De("li",{children:["1 Square = ",r?.squareSize," x ",r?.squareSize," km"]})]})}):null}import{LICENSES as Vo,useT as Uo}from"@biodiv-platform/naksha-commons";import{useState as Zo}from"react";import{Popover as jo}from"react-tiny-popover";import{tw as U}from"twind";import{jsx as x,jsxs as st}from"react/jsx-runtime";var ae=({icon:e,name:t,title:r,link:n,children:o})=>{let a=x("span",{className:U`flex-1`,children:o||"-"});return st("div",{className:U`flex items-center gap-3 text-sm text-gray-600 break-all`,title:t&&r&&`${t}: ${r}`,children:[x("div",{className:U`flex-shrink-0`,children:e}),n?x("a",{className:U`text-blue-700 focus:outline-none focus:ring flex-1`,target:"_blank",rel:"noopener",href:n,children:a}):a]})};function Yo({item:e,containerStyle:t}){let{t:r}=Uo(),{layer:n,mp:o}=p(),a=e.license||"CC-BY",s=e?.createdDate&&new Date(e.createdDate).toLocaleDateString(),l=e.tags?.join(", ");return st("div",{className:U`flex flex-col gap-1 bg-white p-4 rounded-lg w-72 border border-gray-300 border-solid`,style:t,children:[o.managePublishing&&e.layerStatus&&x(ae,{icon:x(dr,{}),name:r("visiblity"),title:e.layerStatus,children:st("div",{className:U`flex items-center gap-3`,children:[x("span",{children:e.layerStatus}),x(Tr,{label:r("published"),checked:e.layerStatus?.toLowerCase()===X.ACTIVE.toLowerCase(),onChange:()=>n.togglePublish(e.id,e?.layerStatus)}),x("button",{type:"button",title:r("delete"),className:U`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,r("are_you_sure")),children:x(Lr,{})})]})}),x(ae,{icon:x(Xe,{}),link:e.url,name:r("uploader"),title:e.createdBy,children:e.createdBy}),x(ae,{icon:x(Xe,{}),link:e.url,name:r("created_by"),title:e.attribution,children:e.attribution}),x(ae,{icon:x(pr,{}),name:r("created_on"),title:s,children:s}),x(ae,{icon:x(lr,{}),name:r("tags"),title:l,children:l}),x(ae,{name:r("license"),title:a,link:a&&Vo[a],icon:x(cr,{}),children:a})]})}var Ar=({item:e})=>{let[t,r]=Zo(!1),n=()=>r(!t);return x(jo,{isOpen:t,padding:10,positions:["right"],containerStyle:{zIndex:"99"},onClickOutside:n,content:x(Yo,{item:e}),children:x($,{onClick:n,children:x(Pe,{}),title:"Information"})})};import{tw as tn}from"twind";import{useMemo as Ko,useState as Jo}from"react";import{useT as Xo}from"@biodiv-platform/naksha-commons";import{tw as Qo}from"twind";import{jsx as Z,jsxs as en}from"react/jsx-runtime";function Br({item:e}){let[t,r]=Jo(!0),{mp:n}=p(),{t:o}=Xo(),a=Ko(()=>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])=>en("li",{className:Qo`flex gap-2 items-center mb-1`,children:[Z("svg",{viewBox:"0 0 24 24",height:"14",width:"14",focusable:"false",children:Z("circle",{cx:"12",fill:d,cy:"12",r:"12",stroke:"none"})}),Z("div",{children:l})]},d));return Z("ul",{style:{margin:0,padding:0},children:e.layerType!=="RASTER"?s():t?Z("li",{children:Z("img",{style:{margin:"5px"},onError:()=>r(!1),src:`${n?.geoserver?.endpoint}/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&WIDTH=20&HEIGHT=20&STRICT=false&layer=biodiv:${e.id}`})}):Z("div",{children:o("raster_style_not_found")})})}import{jsx as He,jsxs as rn}from"react/jsx-runtime";function it({item:e}){if(!e.data?.styles)return null;let{layer:t}=p(),r=n=>{t.updateStyle(e.id,Number(n.target.value))};return rn("div",{className:tn`flex flex-col gap-4 pt-2`,children:[e.layerType!=="RASTER"&&He(re,{onChange:r,children:e.data?.styles.map((n,o)=>He("option",{value:o,children:n.styleTitle},o))}),He(ye,{children:He(Br,{item:e})})]})}import{jsx as C,jsxs as j}from"react/jsx-runtime";function sn({dragHandleProps:e}){return C("div",{className:H`mt-1 w-6 text-center cursor-move`,style:{touchAction:"none"},...e,children:C(yr,{})})}function ge({item:e,extended:t,dragHandleProps:r}){let{t:n}=on(),{layer:o,query:a,mp:s,query:{setClickedLngLat:l},setIsInfoBarOpen:d}=p(),[u,f]=Or(o.selectedIds.includes(e.id)),[g,v]=Or(!1),k=nn(()=>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]),h=async()=>{v(!0),d(!0),o.setSelectedFeatures([]),l(null),await o.toggle({layerId:e.id,add:!u}),f(!u),v(!1)},b=async()=>{await or(s.nakshaApiEndpoint,s.nakshaEndpointToken,e.id,e.title),s?.onLayerDownload(e.id)},I=()=>o.zoomToExtent(e.id);return j("div",{className:H`z-20 p-3 bg-white`,style:{borderTop:"1px solid #e5e7eb"},children:[j("div",{className:H`flex gap-3`,children:[j("div",{className:H`flex-shrink-0`,children:[C(Sr,{name:e.id,checked:u,onChange:h,isLoading:g}),t&&C(sn,{dragHandleProps:r})]}),C("img",{className:H`flex-shrink-0 overflow-hidden h-16 w-16 p-1 mb-2 object-cover border border-gray-200 rounded`,src:e.thumbnail||qt}),j("div",{children:[C("div",{title:e.title,className:H`mb-1 leading-tight`,style:Ze,children:C(_r,{text:e.title,highlight:a.term})}),C("p",{title:e.description,className:H`text-gray-600 text-sm`,style:Vt,children:e.description})]})]}),j("div",{className:H`flex justify-between`,children:[j($,{onClick:b,disabled:!e.isDownloadable,children:[C(ur,{})," ",n("download")]}),j("div",{className:H`flex gap-3`,children:[k&&C(an,{data:k,children:C($,{title:"Share",children:C(fr,{})})}),t&&C($,{onClick:I,title:"Zoom To Extent",children:C(mr,{})}),C(Ar,{item:e})]})]}),t&&C(it,{item:e}),t&&e.source.type==="grid"&&C(at,{item:e})]})}import{jsx as Y}from"react/jsx-runtime";function Dr(){let{layer:e,query:t}=p(),r=cn(()=>t.term?e.all.filter(a=>a.title.toLowerCase().includes(t.term.toLowerCase())):e.all,[e.all,t.term]),n=ln.useRef(null),o=dn({size:r.length,parentRef:n});return Y("div",{className:Gr`flex-grow-1 relative`,children:Y(pn,{renderProp:a=>Y("div",{ref:n,className:"List",style:{height:a.height,overflow:"auto"},children:Y("div",{style:{height:o.totalSize,width:"100%",position:"relative"},children:o.virtualItems.map(s=>Y("div",{ref:s.measureRef,className:Gr`absolute top-0 left-0 w-full`,style:{transform:`translateY(${s.start}px)`},children:Y("div",{style:{height:146},children:Y(ge,{item:r[s.index]})})},s.index))})})})})}import{useT as un}from"@biodiv-platform/naksha-commons";import{tw as mn}from"twind";import{jsx as Hr}from"react/jsx-runtime";function lt(){let{t:e}=un(),{query:t}=p(),r=n=>t.setTerm(n.target.value);return Hr("div",{className:mn`flex-shrink-0 border-b-2 p-4`,children:Hr(wr,{name:"lyr_search",placeholder:e("find_layer_by_name"),onChange:r})})}import{jsx as zr,jsxs as yn}from"react/jsx-runtime";function ct(){return yn("div",{className:fn`flex flex-col w-full`,children:[zr(lt,{}),zr(Dr,{})]})}function gn(e,t,r){let n=t<0?e.length+t:t;if(n>=0&&n<e.length){let o=r<0?e.length+r:r,[a]=e.splice(t,1);e.splice(o,0,a)}}function Fr(e,t,r){return e=[...e],gn(e,t,r),e}import{closestCenter as hn,DndContext as bn,PointerSensor as Ln,useSensor as vn,useSensors as xn}from"@dnd-kit/core";import{SortableContext as wn,useSortable as Sn,verticalListSortingStrategy as kn}from"@dnd-kit/sortable";import{CSS as In}from"@dnd-kit/utilities";import{jsx as se}from"react/jsx-runtime";function Cn({item:e,extended:t}){let{attributes:r,listeners:n,setNodeRef:o,transform:a,transition:s,isDragging:l}=Sn({id:e.id}),d={transform:In.Transform.toString(a),transition:s,opacity:l?.5:1};return se("div",{ref:o,style:d,children:se(ge,{item:e,extended:t,dragHandleProps:{...r,...n}})})}var $r=({layerList:e,onSortEnd:t})=>{let r=xn(vn(Ln,{activationConstraint:{distance:4}}));return se(bn,{sensors:r,collisionDetection:hn,onDragEnd:o=>{let{active:a,over:s}=o;if(s&&a.id!==s.id){let l=e.findIndex(u=>u.id===a.id),d=e.findIndex(u=>u.id===s.id);l!==-1&&d!==-1&&t({oldIndex:l,newIndex:d})}},children:se(wn,{items:e.map(o=>o.id),strategy:kn,children:se("div",{children:e.map(o=>se(Cn,{item:o,extended:!0},o.id))})})})};import{useT as Pn}from"@biodiv-platform/naksha-commons";import{tw as Wr}from"twind";import{jsx as Vr,jsxs as qr}from"react/jsx-runtime";function dt(){let{layer:e}=p(),{t}=Pn(),r=({oldIndex:n,newIndex:o})=>{e.setSelectedIds(Fr(e.selectedIds,n,o))};return qr("div",{className:Wr`flex flex-col gap-3 w-full`,children:[e.selectedIds.length>0&&Vr("div",{className:Wr`p-3 pb-0`,children:qr($,{onClick:()=>e.clearAll(),children:["\u2715 ",t("clear")]})}),Vr($r,{layerList:e.selectedLayers,useDragHandle:!0,onSortEnd:r})]})}import{useT as Tn}from"@biodiv-platform/naksha-commons";import{tw as Rn}from"twind";import{jsx as pt,jsxs as Mn}from"react/jsx-runtime";function ut(){let{layer:e}=p(),{t}=Tn(),r=n=>{e.setMapStyle(n.target.value),e.setMaxZoom(e.mapStyles.find(o=>o.style===n.target.value)?.maxZoom)};return Mn("div",{className:Rn`w-full p-4 flex flex-col gap-4`,children:[pt(re,{name:"base_style",label:t("base_style"),defaultValue:e.mapStyle,onChange:r,children:e.mapStyles.map(n=>pt("option",{value:n.style,children:n.text},n.key))}),pt(me,{})]})}import{jsx as M,jsxs as mt}from"react/jsx-runtime";function ft({onClose:e}){let{t}=En();return mt("div",{className:Ur`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:[M(Re,{onClick:e}),M("div",{className:Ur`flex flex-col h-full`,children:mt(Ir,{children:[mt(Cr,{children:[M(Ee,{icon:M(ue,{}),children:t("layers")}),M(Ee,{icon:M(ue,{}),children:t("selected")}),M(Ee,{icon:M(ir,{}),children:t("settings")})]}),M(Ne,{children:M(ct,{})}),M(Ne,{children:M(dt,{})}),M(Ne,{children:M(ut,{})})]})})]})}import{jsx as Yr}from"react/jsx-runtime";function yt(){let{mp:e,layer:t}=p(),[r,n]=_n(e.showToC),{mapl:o}=An(),a=Nn(!1),s=Zr.useCallback(()=>n(d=>!d),[]),l=Zr.useCallback(async()=>{let d=await Xt(e.nakshaEndpointToken,e.nakshaApiEndpoint,e.geoserver,e.selectedLayers),u=[...e.layers||[],...d];if(t.setAll(u),t.selectedIds.length){let f=u.find(g=>g.id===t.selectedIds[0]);f?.bbox&&o?.fitBounds(f.bbox,{padding:40,duration:1e3})}},[e.nakshaEndpointToken,e.nakshaApiEndpoint,e.geoserver,e.selectedLayers,e.layers,t.setAll,t.selectedIds,o]);return jr(()=>{e.loadToC&&!a.current&&(a.current=!0,l())},[e.loadToC]),jr(()=>{if(o&&t.selectedIds.length&&t.all?.length){let d=t.all.find(u=>u.id===t.selectedIds[0]);d?.bbox&&o.fitBounds(d.bbox,{padding:40,duration:1e3})}},[o]),r?Yr(ft,{onClose:s}):Yr(vr,{onClick:s})}import{config as W}from"maplibre-gl";var Kr="https://unpkg.com/maplibre-gl@6.16.0/dist/maplibre-gl-worker.mjs";typeof window<"u"&&!W.WORKER_URL&&(W.WORKER_URL="/maplibre-gl-worker.mjs");var ze=null;async function Jr(e){return e?(W.WORKER_URL=e,e):W.WORKER_URL&&W.WORKER_URL!=="/maplibre-gl-worker.mjs"?W.WORKER_URL:typeof window>"u"?"":ze||(ze=(async()=>{try{let t=await fetch("/maplibre-gl-worker.mjs",{method:"HEAD"}),r=t.headers.get("content-type")||"";if(t.ok&&!r.includes("text/html"))return W.WORKER_URL="/maplibre-gl-worker.mjs","/maplibre-gl-worker.mjs"}catch{}return W.WORKER_URL=Kr,Kr})(),ze)}import{useMap as Zn}from"react-map-gl/maplibre";import Bn from"@turf/bbox";import{useEffect as gt,useRef as On,useState as Gn}from"react";import{Layer as Dn,Source as Hn,useMap as zn}from"react-map-gl/maplibre";import{jsx as Xr}from"react/jsx-runtime";function ht({data:e,beforeId:t}){let{layer:r}=p(),{mapl:n}=zn(),[o,a]=Gn({geojson:{},paint:{}}),s=On(""),l=r.selectedIds.includes(e.id),d=r.selectedIds[0]===e.id,u=async(f=!1)=>{if(!n)return;let g=n.getBounds(),v=n.getZoom();if(!g)return;let[k]=ke(v),{_ne:h,_sw:b}=g,I=`${h.lat.toFixed(4)},${b.lng.toFixed(4)},${b.lat.toFixed(4)},${h.lng.toFixed(4)},${k}`;if(I===s.current)return;s.current=I;let{success:_,geojson:E,paint:S,stops:Ve,squareSize:P}=await rr(e.source.fetcher,g,v,void 0,void 0,e.source);if(_){if(a({geojson:E,paint:S}),f&&d&&e.zoomToFit)try{let A=Bn(E);if(A.every(Number.isFinite)){let[w,z,F,Le]=A;n.fitBounds([[w,z],[F,Le]],{padding:40,animate:!0})}}catch(A){console.warn("Failed to compute bbox",A)}r.setGridLegends(A=>({...A,[e.id]:{stops:Ve,squareSize:P}}))}};return gt(()=>{l&&d?u(!0):l&&u(!1)},[l,d]),gt(()=>{if(!l||!n)return;let f=()=>u(!1);return n.on("moveend",f),()=>{n.off("moveend",f)}},[l,n]),gt(()=>()=>{r.setGridLegends(f=>{let g={...f};return delete g[e.id],g})},[e.id]),Xr(Hn,{id:e.id,type:"geojson",data:o.geojson,children:Xr(Dn,{beforeId:t,id:e.id,type:"fill",paint:o.paint})})}import{useMemo as Fn}from"react";import{Layer as Qr,Source as $n}from"react-map-gl/maplibre";import{jsx as eo,jsxs as qn}from"react/jsx-runtime";var Wn={fill:{"line-color":"red","line-width":2},circle:{"circle-stroke-color":"red","circle-stroke-width":2,"circle-opacity":0}};function Fe({layer:e,beforeId:t}){let{layer:r}=p(),n=Fn(()=>e.data?.styles?.[e.data?.styleIndex]?.colors,[e,r.selectedFeatures]),o=r.selectedFeaturesId?.[e.id];return qn($n,{...e.source,children:[n&&eo(Qr,{beforeId:t,...n}),o&&n&&eo(Qr,{...n,beforeId:t,id:`hl_${e.id}`,filter:["in",B,...o],type:n.type==="fill"?"line":n.type,paint:Wn[n.type]})]})}import{Layer as Vn,Source as Un}from"react-map-gl/maplibre";import{jsx as to}from"react/jsx-runtime";function bt({data:e,beforeId:t}){let{mp:r}=p();return to(Un,{id:e.id,type:"raster",tiles:[`${r?.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:to(Vn,{id:e.id,beforeId:t,type:"raster",source:"biodiv",layout:{visibility:"visible"},paint:{}})})}import{jsx as $e}from"react/jsx-runtime";function ro({layer:e,beforeId:t}){let{mapl:r}=Zn();if(!r)return null;switch(e.source.type){case"vector":return $e(Fe,{beforeId:t,layer:e});case"grid":return $e(ht,{beforeId:t,data:e});case"raster":return $e(bt,{beforeId:t,data:e});default:return $e(Fe,{beforeId:t,layer:e})}}import{useMemo as jn}from"react";import{Marker as Yn}from"react-map-gl/maplibre";import{Fragment as Xn,jsx as Lt}from"react/jsx-runtime";var Kn=Yn,Jn=()=>{let{mp:e}=p(),t=jn(()=>e.markers,[e.markers]);return Lt(Xn,{children:t?.map(({latitude:r,longitude:n,colorHex:o,anchor:a="bottom",iconUrl:s},l)=>Lt(Kn,{latitude:r,longitude:n,anchor:a,subpixelPositioning:!0,children:Lt("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))})},oo=Jn;import Qn from"clsx";import{Popup as ea}from"react-map-gl/maplibre";import{tw as he}from"twind";import{jsx as q,jsxs as ao}from"react/jsx-runtime";var no=ea;function vt({coordinates:e}){let{hover:t}=p(),r=e||t.features?.coordinates;return!r?.lat||!t.features?null:t.features.content?q(no,{latitude:r.lat,longitude:r.lng,closeButton:!1,maxWidth:"320px",children:t.features.content}):q(no,{latitude:r.lat,longitude:r.lng,closeButton:!1,children:ao("table",{className:he`table-auto border`,children:[q("thead",{children:q("tr",{children:q("th",{className:he`bg-gray-200 py-1 px-2`,colSpan:2,children:t.features.title})})}),q("tbody",{children:t.features.data.map(([n,o],a)=>ao("tr",{className:he(Qn({"bg-gray-50":a%2===0,"border-gray-100 border-t":1})),children:[q("td",{className:he`py-1 px-2`,children:n}),q("td",{className:he`py-1 px-2 border-l border-gray-100`,children:o})]},n+o))})]})})}import{useControl as ta}from"react-map-gl/maplibre";var ra='<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="margin:auto"><circle cx="12" cy="12" r="7"/><circle cx="12" cy="12" r="2"/><path d="M12 2v3M12 19v3M2 12h3M19 12h3"/></svg>',xt=class{constructor(t,r){this.onReset=t;this.title=r}onReset;title;container;onAdd(){this.container=document.createElement("div"),this.container.className="maplibregl-ctrl maplibregl-ctrl-group";let t=document.createElement("button");return t.type="button",t.title=this.title,t.setAttribute("aria-label",this.title),t.style.display="flex",t.innerHTML=ra,t.onclick=this.onReset,this.container.appendChild(t),this.container}onRemove(){this.container?.remove()}};function wt({viewState:e,position:t="bottom-right"}){return ta(({map:r})=>new xt(()=>r.flyTo({center:[e.longitude,e.latitude],zoom:e.zoom}),"Reset view"),{position:t}),null}import{jsx as D,jsxs as io}from"react/jsx-runtime";var ua=ia,ma=5e3,fa=la;function St(){let{mp:e,layer:t,hover:r,query:n}=p(),[o,a]=so(e.workerUrl||(typeof window<"u"?da.WORKER_URL||"/maplibre-gl-worker.mjs":void 0));We(()=>{Jr(e.workerUrl).then(a)},[e.workerUrl]);let s=na(()=>e.defaultViewState||oa,[e.defaultViewState]),[l,d]=so();We(()=>d(void 0),[t.selectedIds.join(",")]);let u=be.useCallback(h=>{let b=t.selectedLayers[0];if(!b?.onClick){n.setClickedLngLat(h.lngLat);return}let I=h.target.queryRenderedFeatures(h.point,{layers:[b.id]})[0];d(I&&{lngLat:h.lngLat,content:b.onClick({bbox:Ie(I),feature:I,layerId:b.id})})},[t.selectedLayers,n]),f=be.useRef(null),g=be.useCallback(h=>{f.current||(f.current=requestAnimationFrame(()=>{f.current=null,r.onHover(h)}))},[r]);We(()=>()=>{f.current&&cancelAnimationFrame(f.current)},[]);let v=be.useRef({}),k=be.useCallback(h=>{if(!e.collapseAttribution)return;let b=h.target.getContainer().querySelector(".maplibregl-ctrl-attrib");if(!b)return;let I=!1;b.querySelector(".maplibregl-ctrl-attrib-button")?.addEventListener("click",()=>{I=!0},{capture:!0,once:!0});let _=()=>b.classList.contains("maplibregl-compact-show"),E=()=>{v.current.timer=setTimeout(()=>{I||b.classList.remove("maplibregl-compact-show")},ma)};if(_()){E();return}let S=new MutationObserver(()=>{_()&&(S.disconnect(),E())});S.observe(b,{attributes:!0,attributeFilter:["class"]}),v.current.observer=S},[e.collapseAttribution]);return We(()=>()=>{let{timer:h}=v.current;h&&clearTimeout(h),v.current.observer?.disconnect()},[]),io("div",{className:pa`h-full w-full relative bg-gray-100`,children:[e.loadToC&&D(yt,{}),t.selectedFeatures?.length>0&&D(nt,{}),io(aa,{id:"mapl",workerUrl:o,cursor:"default",initialViewState:s,style:{width:"100%",height:"100%"},mapStyle:t.mapStyle,maxZoom:t.maxZoom,onClick:u,onMouseMove:g,attributionControl:e.collapseAttribution?{compact:!0}:void 0,onLoad:k,children:[e.showScaleControl&&D(ca,{position:"bottom-right"}),e.showResetControl&&D(wt,{viewState:s,position:"bottom-right"}),D(ua,{position:"bottom-right",showZoom:!0,showCompass:!0}),e.showFullscreenControl&&D(sa,{position:"bottom-right"}),D(oo,{}),t.selectedLayers.map((h,b)=>{let I=b>0?t.selectedIds[b-1]:void 0;return D(ro,{layer:h,beforeId:I},h.id)}),l?D(fa,{latitude:l.lngLat.lat,longitude:l.lngLat.lng,closeOnClick:!1,onClose:()=>d(void 0),maxWidth:"320px",children:l.content}):D(vt,{},"popup")]})]})}import{jsx as qe}from"react/jsx-runtime";ba({preflight:!1});var dd=e=>{let t=ga.useMemo(()=>({...Wt,...e}),[e]);return qe(ha,{children:qe(ya,{localeStrings:$t,lang:t.lang,children:qe(ar,{mp:t,children:qe(St,{})})})})};export{dd as NakshaMaplibreLayers};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@biodiv-platform/naksha-maplibre-layers",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.12-beta.0",
|
|
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/
|
|
46
|
-
"@biodiv-platform/
|
|
45
|
+
"@biodiv-platform/tsconfig": "4.5.0",
|
|
46
|
+
"@biodiv-platform/eslint-preset": "4.5.0"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@bumaga/tabs": "^0.2.0",
|