agviewermap-react 0.1.24 → 0.1.25

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.
@@ -1,4 +1,4 @@
1
- import { j as e, M as z, u as A, a as H, B as P, T as b, b as U, C as V, c as W, d as O, t as q, S as G, e as J, I as K, f as Q, g as S, h as X } from "./index-yWNhEcu_.js";
1
+ import { j as e, M as z, u as A, a as H, B as P, T as b, b as U, C as V, c as W, d as O, t as q, S as G, e as J, I as K, f as Q, g as S, h as X } from "./index-CENE-1me.js";
2
2
  import { useState as g, useContext as Y, useCallback as o, useRef as Z, useMemo as N, useEffect as $ } from "react";
3
3
  const D = (s) => /* @__PURE__ */ e.jsxs(
4
4
  "svg",
@@ -1,4 +1,4 @@
1
- import { A as p } from "./index-yWNhEcu_.js";
1
+ import { A as p } from "./index-CENE-1me.js";
2
2
  export {
3
3
  p as AgvMap
4
4
  };
@@ -1296,6 +1296,6 @@ function evaluatePixel(samples) {
1296
1296
  Pixel Count: ${this.point.y.toLocaleString()}<br/>
1297
1297
  NDVI Value: ${this.point.ndviValue.toFixed(2)}
1298
1298
  `}},plotOptions:{column:{dataLabels:{enabled:!1},borderWidth:0,groupPadding:.1,pointPadding:.05}},series:[{name:"Pixel Count",data:n}],credits:{enabled:!1},legend:{enabled:!1}};return I.jsx(bv,{highcharts:$s,options:r})}const ag=new Map,Ax=new Map,W5e=(e,t)=>{if(!e||!t||t.length===0)return e;const n=new Map;e.forEach(m=>{const p=new Date(m.x).toDateString();n.set(p,m)});const r=new Map;t.forEach(m=>{const p=new Date(m.date).toDateString();r.set(p,m)});const i=new Set;e.forEach(m=>{i.add(new Date(m.x).toDateString())}),t.forEach(m=>{i.add(new Date(m.date).toDateString())});const o=Array.from(i).sort().map(m=>new Date(m)).map(m=>{const p=m.toDateString(),y=n.get(p),b=r.get(p);if(y&&b){const _=.5*y.y+.5*b.value;return{x:m.getTime(),y:_,min:y.min,max:y.max,stddev:y.stddev,etoValue:b.value,etaActualAvg:y.y,isInterpolated:!0,hasETData:!0,hasEToData:!0}}else return y&&!b?{x:m.getTime(),y:y.y,min:y.min,max:y.max,stddev:y.stddev,isInterpolated:!1,hasETData:!0,hasEToData:!1}:!y&&b?{x:m.getTime(),y:b.value,min:null,max:b.value,stddev:null,etoValue:b.value,isInterpolated:!1,hasETData:!1,hasEToData:!0,isEToOnly:!0}:null}).filter(m=>m!==null);console.log("[useETDataPrefetch] === INTERPOLATED DATA DEBUG ==="),console.log(`[useETDataPrefetch] Total points: ${o.length}`);const s=o.filter(m=>m.isInterpolated).length,u=o.filter(m=>!m.isInterpolated&&m.hasETData).length,h=o.filter(m=>m.isEToOnly).length;return console.log(`[useETDataPrefetch] Breakdown: Interpolated=${s}, Original ET=${u}, ETo-only=${h}`),s>0&&o.filter(p=>p.isInterpolated).slice(0,2).forEach((p,y)=>{var _,x;const b=new Date(p.x).toISOString().split("T")[0];console.log(`[useETDataPrefetch] Sample[${y+1}] ${b}:`,{interpolated:p.y.toFixed(2),etaActual:(_=p.etaActualAvg)==null?void 0:_.toFixed(2),etoActual:(x=p.etoValue)==null?void 0:x.toFixed(2)})}),console.log(`[useETDataPrefetch] === END INTERPOLATED DATA DEBUG ===
1299
- `),o},U5e=e=>{if(!e||!Array.isArray(e))return null;const t={};return e.forEach(r=>{const i=new Date(r.x),a=i.getFullYear(),o=i.getMonth(),s=`${a}-${o}`;t[s]||(t[s]={year:a,month:o,points:[]}),t[s].points.push(r)}),Object.values(t).map(r=>{const i=r.points,a=i.reduce((s,u)=>s+(u.y||0),0),o=new Date(r.year,r.month+1,0);return{x:o.getTime(),y:a,year:r.year,month:r.month,pointCount:i.length,monthName:o.toLocaleDateString("en-US",{month:"short"})}}).sort((r,i)=>r.x-i.x)},H5e=async e=>{var n,r,i;const t=e.id||((n=e.options)==null?void 0:n.id)||((i=(r=e.options)==null?void 0:r.properties)==null?void 0:i.id);if(Ax.has(t))return Ax.get(t);try{const a=await rE({stationId:e==null?void 0:e.device,plotId:t});return Ax.set(t,a),a}catch(a){return console.error(`Error fetching task stats for plot ${t}:`,a),null}},X5e=async(e,t)=>{var r,i,a,o;const n=e.id||((r=e.options)==null?void 0:r.id)||((a=(i=e.options)==null?void 0:i.properties)==null?void 0:a.id);if(ag.has(n))return ag.get(n);try{const s=new Date().getFullYear(),u=new Date(s,0,1),h=new Date(s,11,31,23,59,59,999),m={...e,geometry:((o=e.options)==null?void 0:o.geometry)||e.geometry},p=t.map(O=>O instanceof Date?O:typeof O=="string"||typeof O=="number"?new Date(O):null).filter(O=>O instanceof Date&&!isNaN(O)&&O>=u&&O<=h);if(p.length===0){const O={data:[],etoData:[],monthlyAccumulatedData:[]};return ag.set(n,O),O}const y=p.map(O=>eP({plot:m},{startDate:O,endDate:O}).then(T=>{var k,N;return{data:((N=(k=T==null?void 0:T.features)==null?void 0:k[0])==null?void 0:N.properties)||T,date:(T==null?void 0:T.datetime)||O}}).catch(T=>(console.error(`Error fetching ET data for plot ${n}, date ${O}:`,T),null)));let b=[];if(e.device)try{b=await Kie(e.device,u,h)}catch(O){console.error(`Error fetching ETo data for plot ${n}:`,O)}const C=(await Promise.all(y)).filter(O=>O!==null).map(O=>({x:new Date(O.date).getTime(),y:O.data.avg,min:O.data.min,max:O.data.max,stddev:O.data.stddev})).filter(O=>O.y!==null&&O.y!==void 0&&!isNaN(O.y)&&O.min!==null&&O.min!==void 0&&!isNaN(O.min)&&O.max!==null&&O.max!==void 0&&!isNaN(O.max)),A=W5e(C,b||[]),E=U5e(A),P={data:A,etoData:b||[],monthlyAccumulatedData:E};return ag.set(n,P),P}catch(s){return console.error(`Error fetching ET data for plot ${n}:`,s),{data:null,etoData:[],monthlyAccumulatedData:null}}},Y5e=(e,t,n)=>{const[r,i]=R.useState(!1),a=R.useRef(new Set),o=Tt(m=>m.passDates),s=R.useCallback(()=>{if(!(e!=null&&e.current)||!t||t.length===0)return[];const m=e.current.getMap();if(!m)return[];const p=m.getBounds();return p?t.filter(y=>{var k;if(!((k=y==null?void 0:y.options)!=null&&k.geometry))return!1;const b=ms(y.options.geometry),[_,x,C,A]=b,[[E,P],[O,T]]=p.toArray();return!(_>O||C<E||x>T||A<P)}):[]},[t,e]),u=R.useCallback(async m=>{if(!m||m.length===0)return;const p=m.filter(y=>{var _,x,C;const b=y.id||((_=y.options)==null?void 0:_.id)||((C=(x=y.options)==null?void 0:x.properties)==null?void 0:C.id);return!Ax.has(b)});p.length!==0&&(console.log(`Prefetching task stats for ${p.length} plots`),await Promise.allSettled(p.map(y=>H5e(y))))},[]),h=R.useCallback(async()=>{if(n.value!=="ET"||!o||o.length===0)return;const m=s();if(m.length===0)return;u(m),i(!0);const p=m.filter(b=>{var x,C,A;const _=b.id||((x=b.options)==null?void 0:x.id)||((A=(C=b.options)==null?void 0:C.properties)==null?void 0:A.id);return!a.current.has(_)&&!ag.has(_)});if(p.length===0){i(!1);return}console.log(`Prefetching ET data for ${p.length} visible plots`),p.forEach(b=>{var x,C,A;const _=b.id||((x=b.options)==null?void 0:x.id)||((A=(C=b.options)==null?void 0:C.properties)==null?void 0:A.id);a.current.add(_)});const y=p.map(b=>X5e(b,o).finally(()=>{var x,C,A;const _=b.id||((x=b.options)==null?void 0:x.id)||((A=(C=b.options)==null?void 0:C.properties)==null?void 0:A.id);a.current.delete(_)}));await Promise.allSettled(y),i(!1)},[s,o,n.value,u]);return R.useEffect(()=>{n.value!=="ET"||!t||t.length===0||u(t)},[t,n.value,u]),R.useEffect(()=>{if(n.value!=="ET"||(h(),!(e!=null&&e.current)))return;const m=e.current.getMap();if(!m)return;let p;const y=()=>{clearTimeout(p),p=setTimeout(()=>{h()},500)};return m.on("moveend",y),m.on("zoomend",y),()=>{clearTimeout(p),m.off("moveend",y),m.off("zoomend",y)}},[e,h,n.value]),{prefetching:r}},Hh=new Map,k9=e=>{const t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}`},lT=(e,t)=>{var i,a,o;const n=e.id||((i=e.options)==null?void 0:i.id)||((o=(a=e.options)==null?void 0:a.properties)==null?void 0:o.id),r=k9(t);return`${n}_${r}`},Z5e=async(e,t,n)=>{var i;const r=lT(e,t);if(Hh.has(r))return Hh.get(r);try{const a=new Date(t),o=B1(a),s=R1(a),u=new Date(Date.UTC(o.getFullYear(),o.getMonth(),o.getDate(),0,0,0,0)),h=new Date(Date.UTC(s.getFullYear(),s.getMonth(),s.getDate(),23,59,59,999)),m=await n1({plot:e,accessToken:n,startDate:u.toISOString(),endDate:h.toISOString()});return Hh.set(r,m),m}catch(a){return console.error(`Error prefetching histogram data for plot ${e.id||((i=e.options)==null?void 0:i.id)}:`,a),null}},q5e=(e,t,n,r,i)=>{const[a,o]=R.useState(!1),s=R.useRef(new Set),u=R.useCallback(()=>{if(!(e!=null&&e.current)||!t||t.length===0)return[];const m=e.current.getMap();if(!m)return[];const p=m.getBounds();return p?t.filter(y=>{var k;if(!((k=y==null?void 0:y.options)!=null&&k.geometry))return!1;const b=ms(y.options.geometry),[_,x,C,A]=b,[[E,P],[O,T]]=p.toArray();return!(_>O||C<E||x>T||A<P)}):[]},[t,e]),h=R.useCallback(async()=>{if((n==null?void 0:n.value)==="ET"||!r||!(i!=null&&i.start))return;const m=u();if(m.length===0)return;o(!0);const p=i.start,y=k9(p),b=m.filter(C=>{var P,O,T;const E=`${C.id||((P=C.options)==null?void 0:P.id)||((T=(O=C.options)==null?void 0:O.properties)==null?void 0:T.id)}_${y}`;return!s.current.has(E)&&!Hh.has(E)});if(b.length===0){o(!1);return}console.log(`Prefetching histogram data for ${b.length} visible plots (month: ${y})`),b.forEach(C=>{var P,O,T;const E=`${C.id||((P=C.options)==null?void 0:P.id)||((T=(O=C.options)==null?void 0:O.properties)==null?void 0:T.id)}_${y}`;s.current.add(E)});const _=5,x=[];for(let C=0;C<b.length;C+=_){const E=b.slice(C,C+_).map(P=>Z5e(P,p,r).finally(()=>{var k,N,z;const T=`${P.id||((k=P.options)==null?void 0:k.id)||((z=(N=P.options)==null?void 0:N.properties)==null?void 0:z.id)}_${y}`;s.current.delete(T)}));x.push(...E),C+_<b.length&&await Promise.allSettled(E)}await Promise.allSettled(x),o(!1)},[u,r,i==null?void 0:i.start,n==null?void 0:n.value]);return R.useEffect(()=>{if((n==null?void 0:n.value)==="ET"||!r||!(i!=null&&i.start)||(h(),!(e!=null&&e.current)))return;const m=e.current.getMap();if(!m)return;let p;const y=()=>{clearTimeout(p),p=setTimeout(()=>{h()},500)};return m.on("moveend",y),m.on("zoomend",y),()=>{clearTimeout(p),m.off("moveend",y),m.off("zoomend",y)}},[e,h,n==null?void 0:n.value,r,i==null?void 0:i.start]),{prefetching:a}},J5e=(e,t)=>{if(!e||!t)return null;const n=lT(e,t);return Hh.get(n)||null},K5e=(e,t,n)=>{if(!e||!t||!n)return;const r=lT(e,t);Hh.set(r,n)};function D9({mapRef:e}){var E,P;const t=Dr(),{plots:n,setClickedPlot:r}=R.useContext(Zs),{accessToken:i}=R.useContext(Ym),a=Tt(O=>O.dateRange),o=Tt(O=>O.setPickerData),s=Tt(O=>O.setHoveredPlot),u=Tt(O=>O.rasterLayer),[h,m]=R.useState(null),[p,y]=R.useState(null),[b,_]=R.useState(!1);Y5e(e,n,u),q5e(e,n,u,i,a),R.useEffect(()=>{if(!(e!=null&&e.current)||!h)return;const O=e.current.getMap();if(!O)return;const T=`plot-highlight-${h.id}`,k=`plot-highlight-outline-${h.id}`,N=`plot-highlight-source-${h.id}`;return O.getLayer(T)&&O.removeLayer(T),O.getLayer(k)&&O.removeLayer(k),O.getSource(N)&&O.removeSource(N),O.addSource(N,{type:"geojson",data:h.options.geometry}),O.addLayer({id:k,type:"line",source:N,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#ffffff","line-width":4,"line-opacity":1}}),O.addLayer({id:T,type:"line",source:N,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#16a34a","line-width":6,"line-opacity":1}},k),()=>{O.getLayer(T)&&O.removeLayer(T),O.getLayer(k)&&O.removeLayer(k),O.getSource(N)&&O.removeSource(N)}},[h,e]),R.useEffect(()=>{if(!(e!=null&&e.current))return;const O=e.current.getMap();if(!O)return;const T=N=>{var q,H,V;const z=O.queryRenderedFeatures(N.point,{layers:["plots-layer"]});if(z.length>0){const U=z[0],G=((q=U.properties)==null?void 0:q.plot_id)||((H=U.properties)==null?void 0:H.plotId);let B=G?n.find($=>$.id===G):null;if(!B&&((V=U.properties)!=null&&V.id)&&(B=n.find($=>{var Y;return((Y=$.options)==null?void 0:Y.id)===U.properties.id})),B&&B!==h){m(B),s(B),r(null);const $=Tt.getState().pickerData;$!=null&&$.plot||o(null)}}else h&&(m(null),s(null))},k=()=>{m(null),s(null)};return O.on("mousemove",T),O.on("mouseleave",k),O.getCanvas().style.cursor="default",()=>{O.off("mousemove",T),O.off("mouseleave",k),O.getCanvas().style.cursor=""}},[n,e,h,r,o,s]);const x=R.useCallback(O=>new Date(O).toISOString().split("T")[0],[]),C=R.useCallback((O,T)=>{if(!O||O.length===0)return null;const k=x(T),N=O.find(V=>x(V.interval.from)===k);if(N)return N;const z=new Date(T).getTime();let q=null,H=1/0;return O.forEach(V=>{const U=new Date(V.interval.from).getTime(),G=Math.abs(U-z);G<H&&(H=G,q=V)}),q},[x]);R.useEffect(()=>{if(u.value==="ET"){y(null);return}if(!h||!i||!(a!=null&&a.start)){y(null);return}let O=!1;return(async()=>{var k,N;_(!0);try{const z=new Date(a.start),q=J5e(h,z);if(q){if(O)return;if(((k=q==null?void 0:q.data)==null?void 0:k.length)>0){const $=C(q.data,z);y($?[$]:null)}else y(null);_(!1);return}const H=B1(z),V=R1(z),U=new Date(Date.UTC(H.getFullYear(),H.getMonth(),H.getDate(),0,0,0,0)),G=new Date(Date.UTC(V.getFullYear(),V.getMonth(),V.getDate(),23,59,59,999)),B=await n1({plot:h,accessToken:i,startDate:U.toISOString(),endDate:G.toISOString()});if(O)return;if(B&&K5e(h,z,B),((N=B==null?void 0:B.data)==null?void 0:N.length)>0){const $=C(B.data,z);y($?[$]:null)}else y(null)}catch(z){console.error("Error fetching histogram data:",z),O||y(null)}finally{O||_(!1)}})(),()=>{O=!0}},[h,i,a==null?void 0:a.start,C,u.value]);const A=R.useMemo(()=>{var z,q,H,V,U;if(!(p!=null&&p.length))return null;const O=p[0],T=(V=(H=(q=(z=O==null?void 0:O.outputs)==null?void 0:z.index)==null?void 0:q.bands)==null?void 0:H.B0)==null?void 0:V.histogram;if(!(T!=null&&T.bins))return null;const{bins:k,counts:N}=T;return!N&&((U=k[0])==null?void 0:U.count)!==void 0?k.map(G=>({ndviRange:`${G.lowEdge.toFixed(2)} - ${G.highEdge.toFixed(2)}`,ndviValue:(G.lowEdge+G.highEdge)/2,count:G.count||0,lowEdge:G.lowEdge,highEdge:G.highEdge})):!Array.isArray(N)||N.length!==k.length?null:k.map((G,B)=>({ndviRange:`${G.lowEdge.toFixed(2)} - ${G.highEdge.toFixed(2)}`,ndviValue:(G.lowEdge+G.highEdge)/2,count:N[B]||0,lowEdge:G.lowEdge,highEdge:G.highEdge}))},[p]);return!h||u.value==="ET"?null:I.jsxs("div",{className:`bg-white dark:bg-zinc-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 ${u.value==="ET"?"w-[500px]":"w-[320px]"}`,children:[I.jsx("div",{className:"flex items-center justify-between px-3 py-2 border-b border-gray-200 dark:border-gray-700",children:I.jsxs("div",{className:"flex items-center gap-2",children:[I.jsx(sK,{className:"h-5 w-5 text-primary"}),I.jsxs("div",{children:[I.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:u.value==="ET"?t.formatMessage({id:"app.agviewer_map.et_monthly_graph",defaultMessage:"ET Monthly Graph"}):t.formatMessage({id:"app.agviewer_map.ndvi_histogram",defaultMessage:"NDVI Histogram"})}),h&&I.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:h.name||`Plot ${h.id}`}),!h&&I.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 italic",children:t.formatMessage({id:"app.agviewer_map.hover_plot_histogram",defaultMessage:"Hover over a plot to view its histogram"})})]})]})}),I.jsx("div",{className:"px-3 py-2",children:u.value==="ET"?null:b?I.jsx("div",{className:"flex items-center justify-center h-56",children:I.jsx(ma,{})}):I.jsx(G5e,{data:A})}),u.value!=="ET"&&A&&I.jsx("div",{className:"px-3 py-2 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-zinc-900/50",children:I.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[I.jsxs("div",{children:[I.jsxs("span",{className:"text-gray-600 dark:text-gray-400",children:[t.formatMessage({id:"app.agviewer_map.total_pixels",defaultMessage:"Total Pixels"}),":"]}),I.jsx("span",{className:"ml-2 font-semibold text-gray-900 dark:text-gray-100",children:A.reduce((O,T)=>O+T.count,0).toLocaleString()})]}),I.jsxs("div",{children:[I.jsxs("span",{className:"text-gray-600 dark:text-gray-400",children:[t.formatMessage({id:"app.agviewer_map.ndvi_range",defaultMessage:"NDVI Range"}),":"]}),I.jsxs("span",{className:"ml-2 font-semibold text-gray-900 dark:text-gray-100",children:[(E=A[0])==null?void 0:E.lowEdge.toFixed(2)," to"," ",(P=A[A.length-1])==null?void 0:P.highEdge.toFixed(2)]})]})]})}),u.value==="ET"&&h&&I.jsx("div",{className:"px-3 py-2 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-zinc-900/50",children:I.jsxs("div",{className:"text-xs text-gray-600 dark:text-gray-400",children:[I.jsxs("span",{className:"font-medium",children:[t.formatMessage({id:"app.agviewer_map.year",defaultMessage:"Year"}),":"]}),I.jsx("span",{className:"ml-2 font-semibold text-gray-900 dark:text-gray-100",children:new Date().getFullYear()})]})})]})}function Q5e({isSearchFocused:e,searchQuery:t,searchResults:n,onResultClick:r}){return e?I.jsx("div",{className:"absolute top-12 right-0 w-64 bg-white/90 backdrop-blur-xl rounded-md shadow-2xl border border-white/50 overflow-hidden pointer-events-auto animate-in fade-in zoom-in-95 duration-200 origin-top-right max-h-[400px] overflow-y-auto",children:I.jsx("div",{className:"p-2 space-y-1",children:t.trim()===""?I.jsxs(I.Fragment,{children:[I.jsx("div",{className:"px-2 py-1.5 text-[10px] font-bold text-muted-foreground uppercase tracking-wider",children:"Suggested"}),I.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:"Start typing to search farms, plots, and stations..."})]}):n.length===0?I.jsx("div",{className:"px-2 py-4 text-xs text-muted-foreground text-center",children:"No results found"}):I.jsxs(I.Fragment,{children:[I.jsxs("div",{className:"px-2 py-1.5 text-[10px] font-bold text-muted-foreground uppercase tracking-wider",children:["Results (",n.length,")"]}),n.map(i=>I.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-sm hover:bg-green-50/80 cursor-pointer transition-colors group",onClick:()=>r(i),children:[I.jsxs("div",{className:Rt("w-8 h-8 rounded-sm flex items-center justify-center shrink-0",i.type==="farm"&&"bg-green-100 text-green-600",i.type==="plot"&&"bg-blue-100 text-blue-600",i.type==="station"&&"bg-orange-100 text-orange-600"),children:[i.type==="farm"&&I.jsx(ow,{className:"h-4 w-4"}),i.type==="plot"&&I.jsx(xp,{className:"h-4 w-4"}),i.type==="station"&&I.jsx(Ry,{className:"h-4 w-4"})]}),I.jsxs("div",{className:"flex flex-col min-w-0",children:[I.jsx("span",{className:"text-sm font-medium truncate text-foreground group-hover:text-green-700",children:i.label}),I.jsx("span",{className:"text-xs text-muted-foreground truncate",children:i.subLabel})]})]},i.id))]})})}):null}function e4e(e,t,{checkForDefaultPrevented:n=!0}={}){return function(i){if(e==null||e(i),n===!1||!i.defaultPrevented)return t==null?void 0:t(i)}}function t4e(e){const t=ee.useRef({value:e,previous:e});return ee.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Ix="Switch",[n4e,a$e]=bo(Ix),[r4e,i4e]=n4e(Ix),N9=ee.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:u="on",onCheckedChange:h,form:m,...p}=e,[y,b]=ee.useState(null),_=zn(t,P=>b(P)),x=ee.useRef(!1),C=y?m||!!y.closest("form"):!0,[A,E]=tl({prop:i,defaultProp:a??!1,onChange:h,caller:Ix});return I.jsxs(r4e,{scope:n,checked:A,disabled:s,children:[I.jsx(Dn.button,{type:"button",role:"switch","aria-checked":A,"aria-required":o,"data-state":R9(A),"data-disabled":s?"":void 0,disabled:s,value:u,...p,ref:_,onClick:e4e(e.onClick,P=>{E(O=>!O),C&&(x.current=P.isPropagationStopped(),x.current||P.stopPropagation())})}),C&&I.jsx(F9,{control:y,bubbles:!x.current,name:r,value:u,checked:A,required:o,disabled:s,form:m,style:{transform:"translateX(-100%)"}})]})});N9.displayName=Ix;var L9="SwitchThumb",j9=ee.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,i=i4e(L9,n);return I.jsx(Dn.span,{"data-state":R9(i.checked),"data-disabled":i.disabled?"":void 0,...r,ref:t})});j9.displayName=L9;var a4e="SwitchBubbleInput",F9=ee.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},a)=>{const o=ee.useRef(null),s=zn(o,a),u=t4e(n),h=ev(t);return ee.useEffect(()=>{const m=o.current;if(!m)return;const p=window.HTMLInputElement.prototype,b=Object.getOwnPropertyDescriptor(p,"checked").set;if(u!==n&&b){const _=new Event("click",{bubbles:r});b.call(m,n),m.dispatchEvent(_)}},[u,n,r]),I.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:s,style:{...i.style,...h,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});F9.displayName=a4e;function R9(e){return e?"checked":"unchecked"}var B9=N9,s4e=j9;const cT=ee.forwardRef(({className:e,...t},n)=>I.jsx(B9,{className:Rt("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:I.jsx(s4e,{className:Rt("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));cT.displayName=B9.displayName;function Xh(e,t,{checkForDefaultPrevented:n=!0}={}){return function(i){if(e==null||e(i),n===!1||!i.defaultPrevented)return t==null?void 0:t(i)}}var o4e=ee.createContext(void 0);function l4e(e){const t=ee.useContext(o4e);return e||t||"ltr"}function c4e(e){const t=ee.useRef({value:e,previous:e});return ee.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var $9=["PageUp","PageDown"],z9=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],V9={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},Yh="Slider",[uT,u4e,d4e]=SE(Yh),[G9,s$e]=bo(Yh,[d4e]),[h4e,Px]=G9(Yh),W9=ee.forwardRef((e,t)=>{const{name:n,min:r=0,max:i=100,step:a=1,orientation:o="horizontal",disabled:s=!1,minStepsBetweenThumbs:u=0,defaultValue:h=[r],value:m,onValueChange:p=()=>{},onValueCommit:y=()=>{},inverted:b=!1,form:_,...x}=e,C=ee.useRef(new Set),A=ee.useRef(0),P=o==="horizontal"?f4e:p4e,[O=[],T]=tl({prop:m,defaultProp:h,onChange:V=>{var G;(G=[...C.current][A.current])==null||G.focus(),p(V)}}),k=ee.useRef(O);function N(V){const U=b4e(O,V);H(V,U)}function z(V){H(V,A.current)}function q(){const V=k.current[A.current];O[A.current]!==V&&y(O)}function H(V,U,{commit:G}={commit:!1}){const B=S4e(a),$=C4e(Math.round((V-r)/a)*a+r,B),Y=wx($,[r,i]);T((te=[])=>{const re=y4e(te,Y,U);if(w4e(re,u*a)){A.current=re.indexOf(Y);const ie=String(re)!==String(te);return ie&&G&&y(re),ie?re:te}else return te})}return I.jsx(h4e,{scope:e.__scopeSlider,name:n,disabled:s,min:r,max:i,valueIndexToChangeRef:A,thumbs:C.current,values:O,orientation:o,form:_,children:I.jsx(uT.Provider,{scope:e.__scopeSlider,children:I.jsx(uT.Slot,{scope:e.__scopeSlider,children:I.jsx(P,{"aria-disabled":s,"data-disabled":s?"":void 0,...x,ref:t,onPointerDown:Xh(x.onPointerDown,()=>{s||(k.current=O)}),min:r,max:i,inverted:b,onSlideStart:s?void 0:N,onSlideMove:s?void 0:z,onSlideEnd:s?void 0:q,onHomeKeyDown:()=>!s&&H(r,0,{commit:!0}),onEndKeyDown:()=>!s&&H(i,O.length-1,{commit:!0}),onStepKeyDown:({event:V,direction:U})=>{if(!s){const $=$9.includes(V.key)||V.shiftKey&&z9.includes(V.key)?10:1,Y=A.current,te=O[Y],re=a*$*U;H(te+re,Y,{commit:!0})}}})})})})});W9.displayName=Yh;var[U9,H9]=G9(Yh,{startEdge:"left",endEdge:"right",size:"width",direction:1}),f4e=ee.forwardRef((e,t)=>{const{min:n,max:r,dir:i,inverted:a,onSlideStart:o,onSlideMove:s,onSlideEnd:u,onStepKeyDown:h,...m}=e,[p,y]=ee.useState(null),b=zn(t,P=>y(P)),_=ee.useRef(void 0),x=l4e(i),C=x==="ltr",A=C&&!a||!C&&a;function E(P){const O=_.current||p.getBoundingClientRect(),T=[0,O.width],N=fT(T,A?[n,r]:[r,n]);return _.current=O,N(P-O.left)}return I.jsx(U9,{scope:e.__scopeSlider,startEdge:A?"left":"right",endEdge:A?"right":"left",direction:A?1:-1,size:"width",children:I.jsx(X9,{dir:x,"data-orientation":"horizontal",...m,ref:b,style:{...m.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:P=>{const O=E(P.clientX);o==null||o(O)},onSlideMove:P=>{const O=E(P.clientX);s==null||s(O)},onSlideEnd:()=>{_.current=void 0,u==null||u()},onStepKeyDown:P=>{const T=V9[A?"from-left":"from-right"].includes(P.key);h==null||h({event:P,direction:T?-1:1})}})})}),p4e=ee.forwardRef((e,t)=>{const{min:n,max:r,inverted:i,onSlideStart:a,onSlideMove:o,onSlideEnd:s,onStepKeyDown:u,...h}=e,m=ee.useRef(null),p=zn(t,m),y=ee.useRef(void 0),b=!i;function _(x){const C=y.current||m.current.getBoundingClientRect(),A=[0,C.height],P=fT(A,b?[r,n]:[n,r]);return y.current=C,P(x-C.top)}return I.jsx(U9,{scope:e.__scopeSlider,startEdge:b?"bottom":"top",endEdge:b?"top":"bottom",size:"height",direction:b?1:-1,children:I.jsx(X9,{"data-orientation":"vertical",...h,ref:p,style:{...h.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:x=>{const C=_(x.clientY);a==null||a(C)},onSlideMove:x=>{const C=_(x.clientY);o==null||o(C)},onSlideEnd:()=>{y.current=void 0,s==null||s()},onStepKeyDown:x=>{const A=V9[b?"from-bottom":"from-top"].includes(x.key);u==null||u({event:x,direction:A?-1:1})}})})}),X9=ee.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:i,onSlideEnd:a,onHomeKeyDown:o,onEndKeyDown:s,onStepKeyDown:u,...h}=e,m=Px(Yh,n);return I.jsx(Dn.span,{...h,ref:t,onKeyDown:Xh(e.onKeyDown,p=>{p.key==="Home"?(o(p),p.preventDefault()):p.key==="End"?(s(p),p.preventDefault()):$9.concat(z9).includes(p.key)&&(u(p),p.preventDefault())}),onPointerDown:Xh(e.onPointerDown,p=>{const y=p.target;y.setPointerCapture(p.pointerId),p.preventDefault(),m.thumbs.has(y)?y.focus():r(p)}),onPointerMove:Xh(e.onPointerMove,p=>{p.target.hasPointerCapture(p.pointerId)&&i(p)}),onPointerUp:Xh(e.onPointerUp,p=>{const y=p.target;y.hasPointerCapture(p.pointerId)&&(y.releasePointerCapture(p.pointerId),a(p))})})}),Y9="SliderTrack",Z9=ee.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,i=Px(Y9,n);return I.jsx(Dn.span,{"data-disabled":i.disabled?"":void 0,"data-orientation":i.orientation,...r,ref:t})});Z9.displayName=Y9;var dT="SliderRange",q9=ee.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,i=Px(dT,n),a=H9(dT,n),o=ee.useRef(null),s=zn(t,o),u=i.values.length,h=i.values.map(y=>Q9(y,i.min,i.max)),m=u>1?Math.min(...h):0,p=100-Math.max(...h);return I.jsx(Dn.span,{"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,...r,ref:s,style:{...e.style,[a.startEdge]:m+"%",[a.endEdge]:p+"%"}})});q9.displayName=dT;var hT="SliderThumb",J9=ee.forwardRef((e,t)=>{const n=u4e(e.__scopeSlider),[r,i]=ee.useState(null),a=zn(t,s=>i(s)),o=ee.useMemo(()=>r?n().findIndex(s=>s.ref.current===r):-1,[n,r]);return I.jsx(m4e,{...e,ref:a,index:o})}),m4e=ee.forwardRef((e,t)=>{const{__scopeSlider:n,index:r,name:i,...a}=e,o=Px(hT,n),s=H9(hT,n),[u,h]=ee.useState(null),m=zn(t,E=>h(E)),p=u?o.form||!!u.closest("form"):!0,y=ev(u),b=o.values[r],_=b===void 0?0:Q9(b,o.min,o.max),x=v4e(r,o.values.length),C=y==null?void 0:y[s.size],A=C?x4e(C,_,s.direction):0;return ee.useEffect(()=>{if(u)return o.thumbs.add(u),()=>{o.thumbs.delete(u)}},[u,o.thumbs]),I.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[s.startEdge]:`calc(${_}% + ${A}px)`},children:[I.jsx(uT.ItemSlot,{scope:e.__scopeSlider,children:I.jsx(Dn.span,{role:"slider","aria-label":e["aria-label"]||x,"aria-valuemin":o.min,"aria-valuenow":b,"aria-valuemax":o.max,"aria-orientation":o.orientation,"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,tabIndex:o.disabled?void 0:0,...a,ref:m,style:b===void 0?{display:"none"}:e.style,onFocus:Xh(e.onFocus,()=>{o.valueIndexToChangeRef.current=r})})}),p&&I.jsx(K9,{name:i??(o.name?o.name+(o.values.length>1?"[]":""):void 0),form:o.form,value:b},r)]})});J9.displayName=hT;var g4e="RadioBubbleInput",K9=ee.forwardRef(({__scopeSlider:e,value:t,...n},r)=>{const i=ee.useRef(null),a=zn(i,r),o=c4e(t);return ee.useEffect(()=>{const s=i.current;if(!s)return;const u=window.HTMLInputElement.prototype,m=Object.getOwnPropertyDescriptor(u,"value").set;if(o!==t&&m){const p=new Event("input",{bubbles:!0});m.call(s,t),s.dispatchEvent(p)}},[o,t]),I.jsx(Dn.input,{style:{display:"none"},...n,ref:a,defaultValue:t})});K9.displayName=g4e;function y4e(e=[],t,n){const r=[...e];return r[n]=t,r.sort((i,a)=>i-a)}function Q9(e,t,n){const a=100/(n-t)*(e-t);return wx(a,[0,100])}function v4e(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function b4e(e,t){if(e.length===1)return 0;const n=e.map(i=>Math.abs(i-t)),r=Math.min(...n);return n.indexOf(r)}function x4e(e,t,n){const r=e/2,a=fT([0,50],[0,r]);return(r-a(t)*n)*n}function _4e(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function w4e(e,t){if(t>0){const n=_4e(e);return Math.min(...n)>=t}return!0}function fT(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function S4e(e){return(String(e).split(".")[1]||"").length}function C4e(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}var e8=W9,M4e=Z9,E4e=q9,T4e=J9;const t8=ee.forwardRef(({className:e,...t},n)=>I.jsxs(e8,{ref:n,className:Rt("relative flex w-full touch-none select-none items-center",e),...t,children:[I.jsx(M4e,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:I.jsx(E4e,{className:"absolute h-full bg-primary"})}),I.jsx(T4e,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"})]}));t8.displayName=e8.displayName;function pT(e,t,{checkForDefaultPrevented:n=!0}={}){return function(i){if(e==null||e(i),n===!1||!i.defaultPrevented)return t==null?void 0:t(i)}}function n8(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function r8(...e){return t=>{let n=!1;const r=e.map(i=>{const a=n8(i,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let i=0;i<r.length;i++){const a=r[i];typeof a=="function"?a():n8(e[i],null)}}}}function mT(...e){return ee.useCallback(r8(...e),e)}function i8(e,t=[]){let n=[];function r(a,o){const s=ee.createContext(o),u=n.length;n=[...n,o];const h=p=>{var A;const{scope:y,children:b,..._}=p,x=((A=y==null?void 0:y[e])==null?void 0:A[u])||s,C=ee.useMemo(()=>_,Object.values(_));return I.jsx(x.Provider,{value:C,children:b})};h.displayName=a+"Provider";function m(p,y){var x;const b=((x=y==null?void 0:y[e])==null?void 0:x[u])||s,_=ee.useContext(b);if(_)return _;if(o!==void 0)return o;throw new Error(`\`${p}\` must be used within \`${a}\``)}return[h,m]}const i=()=>{const a=n.map(o=>ee.createContext(o));return function(s){const u=(s==null?void 0:s[e])||a;return ee.useMemo(()=>({[`__scope${e}`]:{...s,[e]:u}}),[s,u])}};return i.scopeName=e,[r,A4e(i,...t)]}function A4e(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(a){const o=r.reduce((s,{useScope:u,scopeName:h})=>{const p=u(a)[`__scope${h}`];return{...s,...p}},{});return ee.useMemo(()=>({[`__scope${t.scopeName}`]:o}),[o])}};return n.scopeName=t.scopeName,n}var a8=ee.forwardRef((e,t)=>{const{children:n,...r}=e,i=ee.Children.toArray(n),a=i.find(P4e);if(a){const o=a.props.children,s=i.map(u=>u===a?ee.Children.count(o)>1?ee.Children.only(null):ee.isValidElement(o)?o.props.children:null:u);return I.jsx(gT,{...r,ref:t,children:ee.isValidElement(o)?ee.cloneElement(o,void 0,s):null})}return I.jsx(gT,{...r,ref:t,children:n})});a8.displayName="Slot";var gT=ee.forwardRef((e,t)=>{const{children:n,...r}=e;if(ee.isValidElement(n)){const i=k4e(n);return ee.cloneElement(n,{...O4e(r,n.props),ref:t?r8(t,i):i})}return ee.Children.count(n)>1?ee.Children.only(null):null});gT.displayName="SlotClone";var I4e=({children:e})=>I.jsx(I.Fragment,{children:e});function P4e(e){return ee.isValidElement(e)&&e.type===I4e}function O4e(e,t){const n={...t};for(const r in t){const i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...s)=>{a(...s),i(...s)}:i&&(n[r]=i):r==="style"?n[r]={...i,...a}:r==="className"&&(n[r]=[i,a].filter(Boolean).join(" "))}return{...e,...n}}function k4e(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var D4e=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],yT=D4e.reduce((e,t)=>{const n=ee.forwardRef((r,i)=>{const{asChild:a,...o}=r,s=a?a8:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),I.jsx(s,{...o,ref:i})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function s8(e){const t=ee.useRef(e);return ee.useEffect(()=>{t.current=e}),ee.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function N4e({prop:e,defaultProp:t,onChange:n=()=>{}}){const[r,i]=L4e({defaultProp:t,onChange:n}),a=e!==void 0,o=a?e:r,s=s8(n),u=ee.useCallback(h=>{if(a){const p=typeof h=="function"?h(e):h;p!==e&&s(p)}else i(h)},[a,e,i,s]);return[o,u]}function L4e({defaultProp:e,onChange:t}){const n=ee.useState(e),[r]=n,i=ee.useRef(r),a=s8(t);return ee.useEffect(()=>{i.current!==r&&(a(r),i.current=r)},[r,i,a]),n}var j4e=ee.createContext(void 0);function F4e(e){const t=ee.useContext(j4e);return e||t||"ltr"}var vT=globalThis!=null&&globalThis.document?ee.useLayoutEffect:()=>{};function R4e(e){const[t,n]=ee.useState(void 0);return vT(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const a=i[0];let o,s;if("borderBoxSize"in a){const u=a.borderBoxSize,h=Array.isArray(u)?u[0]:u;o=h.inlineSize,s=h.blockSize}else o=e.offsetWidth,s=e.offsetHeight;n({width:o,height:s})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}function B4e(e){const t=ee.useRef({value:e,previous:e});return ee.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}function $4e(e,t){return ee.useReducer((n,r)=>t[n][r]??n,e)}var o8=e=>{const{present:t,children:n}=e,r=z4e(t),i=typeof n=="function"?n({present:r.isPresent}):ee.Children.only(n),a=mT(r.ref,V4e(i));return typeof n=="function"||r.isPresent?ee.cloneElement(i,{ref:a}):null};o8.displayName="Presence";function z4e(e){const[t,n]=ee.useState(),r=ee.useRef({}),i=ee.useRef(e),a=ee.useRef("none"),o=e?"mounted":"unmounted",[s,u]=$4e(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return ee.useEffect(()=>{const h=Ox(r.current);a.current=s==="mounted"?h:"none"},[s]),vT(()=>{const h=r.current,m=i.current;if(m!==e){const y=a.current,b=Ox(h);e?u("MOUNT"):b==="none"||(h==null?void 0:h.display)==="none"?u("UNMOUNT"):u(m&&y!==b?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,u]),vT(()=>{if(t){let h;const m=t.ownerDocument.defaultView??window,p=b=>{const x=Ox(r.current).includes(b.animationName);if(b.target===t&&x&&(u("ANIMATION_END"),!i.current)){const C=t.style.animationFillMode;t.style.animationFillMode="forwards",h=m.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=C)})}},y=b=>{b.target===t&&(a.current=Ox(r.current))};return t.addEventListener("animationstart",y),t.addEventListener("animationcancel",p),t.addEventListener("animationend",p),()=>{m.clearTimeout(h),t.removeEventListener("animationstart",y),t.removeEventListener("animationcancel",p),t.removeEventListener("animationend",p)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:ee.useCallback(h=>{h&&(r.current=getComputedStyle(h)),n(h)},[])}}function Ox(e){return(e==null?void 0:e.animationName)||"none"}function V4e(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var bT="Radio",[G4e,l8]=i8(bT),[W4e,U4e]=G4e(bT),c8=ee.forwardRef((e,t)=>{const{__scopeRadio:n,name:r,checked:i=!1,required:a,disabled:o,value:s="on",onCheck:u,form:h,...m}=e,[p,y]=ee.useState(null),b=mT(t,C=>y(C)),_=ee.useRef(!1),x=p?h||!!p.closest("form"):!0;return I.jsxs(W4e,{scope:n,checked:i,disabled:o,children:[I.jsx(yT.button,{type:"button",role:"radio","aria-checked":i,"data-state":h8(i),"data-disabled":o?"":void 0,disabled:o,value:s,...m,ref:b,onClick:pT(e.onClick,C=>{i||u==null||u(),x&&(_.current=C.isPropagationStopped(),_.current||C.stopPropagation())})}),x&&I.jsx(H4e,{control:p,bubbles:!_.current,name:r,value:s,checked:i,required:a,disabled:o,form:h,style:{transform:"translateX(-100%)"}})]})});c8.displayName=bT;var u8="RadioIndicator",d8=ee.forwardRef((e,t)=>{const{__scopeRadio:n,forceMount:r,...i}=e,a=U4e(u8,n);return I.jsx(o8,{present:r||a.checked,children:I.jsx(yT.span,{"data-state":h8(a.checked),"data-disabled":a.disabled?"":void 0,...i,ref:t})})});d8.displayName=u8;var H4e=e=>{const{control:t,checked:n,bubbles:r=!0,...i}=e,a=ee.useRef(null),o=B4e(n),s=R4e(t);return ee.useEffect(()=>{const u=a.current,h=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(h,"checked").set;if(o!==n&&p){const y=new Event("click",{bubbles:r});p.call(u,n),u.dispatchEvent(y)}},[o,n,r]),I.jsx("input",{type:"radio","aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:a,style:{...e.style,...s,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function h8(e){return e?"checked":"unchecked"}var X4e=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],xT="RadioGroup",[Y4e,o$e]=i8(xT,[Kb,l8]),f8=Kb(),p8=l8(),[Z4e,q4e]=Y4e(xT),m8=ee.forwardRef((e,t)=>{const{__scopeRadioGroup:n,name:r,defaultValue:i,value:a,required:o=!1,disabled:s=!1,orientation:u,dir:h,loop:m=!0,onValueChange:p,...y}=e,b=f8(n),_=F4e(h),[x,C]=N4e({prop:a,defaultProp:i,onChange:p});return I.jsx(Z4e,{scope:n,name:r,required:o,disabled:s,value:x,onValueChange:C,children:I.jsx(q$,{asChild:!0,...b,orientation:u,dir:_,loop:m,children:I.jsx(yT.div,{role:"radiogroup","aria-required":o,"aria-orientation":u,"data-disabled":s?"":void 0,dir:_,...y,ref:t})})})});m8.displayName=xT;var g8="RadioGroupItem",y8=ee.forwardRef((e,t)=>{const{__scopeRadioGroup:n,disabled:r,...i}=e,a=q4e(g8,n),o=a.disabled||r,s=f8(n),u=p8(n),h=ee.useRef(null),m=mT(t,h),p=a.value===i.value,y=ee.useRef(!1);return ee.useEffect(()=>{const b=x=>{X4e.includes(x.key)&&(y.current=!0)},_=()=>y.current=!1;return document.addEventListener("keydown",b),document.addEventListener("keyup",_),()=>{document.removeEventListener("keydown",b),document.removeEventListener("keyup",_)}},[]),I.jsx(J$,{asChild:!0,...s,focusable:!o,active:p,children:I.jsx(c8,{disabled:o,required:a.required,checked:p,...u,...i,name:a.name,ref:m,onCheck:()=>a.onValueChange(i.value),onKeyDown:pT(b=>{b.key==="Enter"&&b.preventDefault()}),onFocus:pT(i.onFocus,()=>{var b;y.current&&((b=h.current)==null||b.click())})})})});y8.displayName=g8;var J4e="RadioGroupIndicator",v8=ee.forwardRef((e,t)=>{const{__scopeRadioGroup:n,...r}=e,i=p8(n);return I.jsx(d8,{...i,...r,ref:t})});v8.displayName=J4e;var b8=m8,x8=y8,K4e=v8;const kx=ee.forwardRef(({className:e,...t},n)=>I.jsx(b8,{className:sc("grid gap-2",e),...t,ref:n}));kx.displayName=b8.displayName;const sg=ee.forwardRef(({className:e,...t},n)=>I.jsx(x8,{ref:n,className:sc("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:I.jsx(K4e,{className:"flex items-center justify-center",children:I.jsx(lK,{className:"h-2.5 w-2.5 fill-current text-current"})})}));sg.displayName=x8.displayName;function Q4e({activePanel:e,togglePanel:t,viewType:n,setViewType:r,dataSource:i,setDataSource:a,layerOptions:o=[],layerOpacity:s=[100],setLayerOpacity:u,layerEnabled:h=!0,setLayerEnabled:m}){return I.jsx("div",{className:Rt("absolute top-20 left-1/2 -translate-x-1/2 z-20 w-80 transition-all duration-300 origin-top pointer-events-none",e==="layers"?"opacity-100 translate-y-0 pointer-events-auto":"opacity-0 -translate-y-10 pointer-events-none"),children:I.jsxs("div",{className:"bg-white/90 backdrop-blur-xl rounded-2xl shadow-2xl overflow-hidden flex flex-col max-h-[80vh] border border-white/50",children:[I.jsxs("div",{className:"p-4 border-b border-border flex justify-between items-center bg-white/50",children:[I.jsxs("div",{children:[I.jsx("h2",{className:"font-bold text-foreground",children:"Raster Layers"}),I.jsx("p",{className:"text-xs text-muted-foreground",children:"Manage map overlays"})]}),I.jsxs("div",{className:"flex items-center gap-3",children:[I.jsx(cT,{checked:h,onCheckedChange:m}),I.jsx(ln,{variant:"ghost",size:"icon",className:"h-8 w-8 rounded-full",onClick:()=>t(null),children:I.jsx(pa,{className:"h-5 w-5"})})]})]}),I.jsxs("div",{className:"p-4 space-y-5 overflow-y-auto",children:[I.jsxs("div",{className:"space-y-3",children:[I.jsx(Vs,{className:"text-xs font-bold text-muted-foreground uppercase tracking-wider",children:"Layer Options"}),I.jsxs("div",{children:[I.jsx(Vs,{className:"text-xs font-bold text-muted-foreground uppercase mb-2 block",children:"View Type"}),I.jsxs(kx,{value:n,onValueChange:r,className:"grid grid-cols-2 gap-2",children:[I.jsxs(Vs,{htmlFor:"view-plot",className:Rt("flex flex-col items-center p-3 border-2 rounded-lg cursor-pointer transition-all",n==="plot"?"border-green-500 bg-green-50/50 text-green-600":"border-border hover:border-green-500/50"),children:[I.jsx(sg,{value:"plot",id:"view-plot",className:"sr-only"}),I.jsx(xp,{className:"h-6 w-6 mb-1"}),I.jsx("span",{className:"text-xs font-medium",children:"Plot View"})]}),I.jsxs(Vs,{htmlFor:"view-map",className:Rt("flex flex-col items-center p-3 border-2 rounded-lg cursor-pointer transition-all",n==="map"?"border-green-500 bg-green-50/50 text-green-600":"border-border hover:border-green-500/50"),children:[I.jsx(sg,{value:"map",id:"view-map",className:"sr-only"}),I.jsx(dK,{className:"h-6 w-6 mb-1"}),I.jsx("span",{className:"text-xs font-medium",children:"Map View"})]})]})]})]}),I.jsxs("div",{className:"space-y-2",children:[I.jsx(Vs,{className:"text-xs font-bold text-muted-foreground uppercase tracking-wider",children:"Data Source"}),I.jsx("div",{className:"border rounded-md overflow-hidden",children:I.jsx("div",{className:"max-h-[150px] overflow-y-auto",children:o.length===0?I.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"No data source available."}):I.jsx("div",{className:"p-1",children:o.map(p=>I.jsxs("div",{onClick:()=>a(p),className:Rt("relative flex w-full cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none hover:bg-accent hover:text-accent-foreground",(i==null?void 0:i.value)===p.value&&"bg-accent text-accent-foreground"),children:[I.jsx(lw,{className:Rt("mr-2 h-4 w-4",(i==null?void 0:i.value)===p.value?"opacity-100":"opacity-0")}),I.jsx("span",{children:p.label})]},p.value))})})})]}),I.jsxs("div",{className:"space-y-3 pt-2",children:[I.jsxs("div",{className:"flex justify-between items-center text-xs font-medium text-muted-foreground",children:[I.jsx("span",{children:"Opacity"}),I.jsxs("span",{children:[s[0],"%"]})]}),I.jsx(t8,{value:s,onValueChange:u,max:100,step:1})]})]})]})})}function eFe({error:e,errorInfo:t,onReset:n}){return I.jsxs("div",{children:[I.jsx("h2",{children:"Something went wrong!"}),I.jsx("p",{children:e==null?void 0:e.message}),I.jsx("details",{children:t==null?void 0:t.componentStack}),I.jsx(Fp,{onClick:n,children:"Try Again"})]})}class _8 extends R.Component{constructor(n){super(n);mG(this,"handleReset",()=>{this.setState({hasError:!1,error:null,errorInfo:null}),this.props.onReset&&this.props.onReset()});this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(n){return{hasError:!0,error:n}}componentDidCatch(n,r){this.setState({error:n,errorInfo:r}),console.error("Error caught by ErrorBoundary:",n,r)}render(){const{hasError:n,error:r,errorInfo:i}=this.state,a=this.props.ErrorFallback||eFe;return n?I.jsx(a,{error:r,errorInfo:i,onReset:this.handleReset}):this.props.children}}const tFe=({width:e=24,height:t=24,fill:n="#000"})=>I.jsxs("svg",{width:e,height:t,viewBox:"0 0 32 32",xmlns:"http://www.w3.org/2000/svg",fill:n,children:[I.jsx("path",{d:"M17,28V17h1a2.0023,2.0023,0,0,0,2-2V11a2.0023,2.0023,0,0,0-2-2H14a2.0023,2.0023,0,0,0-2,2v4a2.0023,2.0023,0,0,0,2,2h1V28H2v2H30V28ZM14,11h4l.0015,4H14Z"}),I.jsx("path",{d:"M9.3325,18.2168a7.0007,7.0007,0,0,1,0-10.4341l1.334,1.49a5,5,0,0,0,0,7.4537Z"}),I.jsx("path",{d:"M22.667,18.2168l-1.334-1.49a4.9995,4.9995,0,0,0,0-7.4537l1.334-1.49a7,7,0,0,1,0,10.4341Z"}),I.jsx("path",{d:"M6.3994,21.8008a11.0019,11.0019,0,0,1,0-17.6006L7.6,5.8a9.0009,9.0009,0,0,0,0,14.4014Z"}),I.jsx("path",{d:"M25.6006,21.8008l-1.2012-1.6a9.001,9.001,0,0,0,0-14.4019l1.2012-1.6a11.002,11.002,0,0,1,0,17.6011Z"})]}),nFe=R.lazy(()=>Promise.resolve().then(()=>WFe));function rFe({activePanel:e,togglePanel:t,markerType:n,setMarkerType:r,pawStatus:i,setPawStatus:a,markerTypeOptions:o=[],pawStatusOptions:s=[],showMarkers:u=!0,setShowMarkers:h,formatLabel:m}){const{mapRef:p}=R.useContext(ha),y=Dr(),[b,_]=R.useState(!1),{markers:x,loading:C,handleDeleteMarker:A}=R.useContext(Za),{isConfirmed:E}=Yv(),P=R.useCallback((k,N)=>{if(!(p!=null&&p.current)||!N)return;const{lat:z,lng:q}=N.location;p.current.flyTo({center:[q,z],zoom:14})},[p]),O=R.useCallback(async(k,N)=>{!N||!await E(y.formatMessage({id:"app.agviewer_map.delete_marker_confirm_message",defaultMessage:"Do you want to delete this marker?"}))||A(N.id)},[E,A,y]),T=R.useCallback(()=>{_(k=>!k)},[]);return I.jsx("div",{className:Rt("absolute top-20 left-1/2 -translate-x-1/2 z-20 w-80 transition-all duration-300 origin-top pointer-events-none",e==="stations"?"opacity-100 translate-y-0 pointer-events-auto":"opacity-0 -translate-y-10 pointer-events-none"),children:I.jsxs("div",{className:"bg-white/90 backdrop-blur-xl rounded-2xl shadow-2xl overflow-hidden flex flex-col max-h-[80vh] border border-white/50",children:[I.jsxs("div",{className:"p-4 border-b border-border flex justify-between items-center bg-white/50",children:[I.jsxs("div",{children:[I.jsx("h2",{className:"font-bold text-foreground",children:"Stations"}),I.jsx("p",{className:"text-xs text-muted-foreground",children:"Filter and manage markers"})]}),I.jsxs("div",{className:"flex items-center gap-3",children:[I.jsx(cT,{checked:u,onCheckedChange:h}),I.jsx(ln,{variant:"ghost",size:"icon",className:"h-8 w-8 rounded-full",onClick:()=>t(null),children:I.jsx(pa,{className:"h-5 w-5"})})]})]}),I.jsxs("div",{className:"p-4 space-y-4 overflow-y-auto",children:[I.jsxs("div",{children:[I.jsx(Vs,{className:"text-xs font-bold text-muted-foreground uppercase mb-2 block",children:"Marker Type"}),I.jsx(kx,{value:n||"",onValueChange:r,className:"grid grid-cols-3 gap-2",children:o.map(k=>I.jsxs(Vs,{htmlFor:`type-${k.value}`,className:Rt("flex items-center justify-center py-2 px-3 text-xs font-medium rounded-lg border-2 cursor-pointer transition-all",(n||"")===k.value?"border-green-500 bg-green-50/50 text-green-600":"border-border hover:border-green-500/50"),children:[I.jsx(sg,{value:k.value,id:`type-${k.value}`,className:"sr-only"}),k.label]},k.value))})]}),I.jsxs("div",{children:[I.jsx(Vs,{className:"text-xs font-bold text-muted-foreground uppercase mb-2 block",children:"PAW Status"}),I.jsx(kx,{value:i||"",onValueChange:a,className:"grid grid-cols-4 gap-2",children:s.map(k=>I.jsxs(Vs,{htmlFor:`paw-${k.value}`,className:Rt("flex items-center justify-center py-2 px-2 text-xs font-medium rounded-lg border-2 cursor-pointer transition-all",(i||"")===k.value?"border-green-500 bg-green-50/50 text-green-600":"border-border hover:border-green-500/50"),children:[I.jsx(sg,{value:k.value,id:`paw-${k.value}`,className:"sr-only"}),k.label]},k.value))})]}),I.jsx(_8,{children:I.jsx(rl,{open:b,setOpen:_,titleWithIcon:I.jsxs(I.Fragment,{children:[I.jsx(tFe,{}),I.jsx("span",{children:y.formatMessage({id:"app.agviewer_map.stations",defaultMessage:"Stations"})})]}),trigger:I.jsxs(ln,{variant:"outline",className:"w-full border-2 border-dashed hover:border-green-500 hover:text-green-600 hover:bg-green-50",onClick:()=>{_(!0),t(null)},children:[I.jsx(By,{className:"h-4 w-4 mr-2"}),"Find Specific Station"]}),onClose:T,children:I.jsx(lu,{className:"border-none shadow-md",children:I.jsx(R.Suspense,{fallback:I.jsx("div",{className:"flex justify-center items-center h-40",children:I.jsx(ma,{})}),children:I.jsx(nFe,{markersData:x,loading:C,handleDeleteMarker:O,onMarkerClick:P,onClose:T,intl:y})})})})})]})]})})}const _T=Np,iFe=Lp,w8=ee.forwardRef(({className:e,...t},n)=>I.jsx(su,{ref:n,className:Rt("fixed inset-0 z-50 bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));w8.displayName=su.displayName;const Dx=ee.forwardRef(({className:e,children:t,showCloseButton:n=!0,...r},i)=>I.jsxs(iFe,{children:[I.jsx(w8,{}),I.jsxs(ou,{ref:i,className:Rt("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...r,children:[t,n&&I.jsxs(jp,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[I.jsx(pa,{className:"h-4 w-4"}),I.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Dx.displayName=ou.displayName;const Nx=({className:e,...t})=>I.jsx("div",{className:Rt("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Nx.displayName="DialogHeader";const Lx=({className:e,...t})=>I.jsx("div",{className:Rt("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Lx.displayName="DialogFooter";const jx=ee.forwardRef(({className:e,...t},n)=>I.jsx(So,{ref:n,className:Rt("text-lg font-semibold leading-none tracking-tight",e),...t}));jx.displayName=So.displayName;const Fx=ee.forwardRef(({className:e,...t},n)=>I.jsx(ac,{ref:n,className:Rt("text-sm text-muted-foreground",e),...t}));Fx.displayName=ac.displayName;function aFe({activePanel:e,togglePanel:t,farms:n=[],plots:r=[],markers:i=[],formatLabel:a,onAddFarm:o,onAddPlot:s,onAddStation:u,onFarmsChange:h}){var Ct,Ft,Lt,St;const{markers:m=[],loading:p}=R.useContext(Za)||{},[y,b]=R.useState(!1),[_,x]=R.useState(!1),[C,A]=R.useState(null),[E,P]=R.useState(!1),[O,T]=R.useState(!1),[k,N]=R.useState(!1),[z,q]=R.useState({name:"",marker_set:[],season_start_date:""}),[H,V]=R.useState(!1),[U,G]=R.useState(!1),[B,$]=R.useState(null),[Y,te]=R.useState(!1),[re,ie]=R.useState(!1),[J,fe]=R.useState(!1),[ge,ue]=R.useState({name:"",area:""}),[ve,Ce]=R.useState(!1),[Te,Ee]=R.useState(!1),[ae,ne]=R.useState(null),[he,_e]=R.useState(!1),[Z,se]=R.useState(!1),[le,ye]=R.useState(!1),[de,De]=R.useState({location_name:""}),Oe=R.useMemo(()=>m.map(qe=>({value:qe.id,label:(qe==null?void 0:qe.name)||(qe==null?void 0:qe.title)||(qe==null?void 0:qe.label)||`Marker ${(qe==null?void 0:qe.id)||""}`})),[m]),Me=R.useCallback(()=>{q({name:"",marker_set:[],season_start_date:""}),A(null)},[]),Be=R.useCallback(()=>{b(!1),setTimeout(Me,200)},[Me]),Fe=R.useCallback(qe=>{let yt=qe.replace(/\D/g,"");return yt.length>=2&&(yt=yt.slice(0,2)+"/"+yt.slice(2,4)),yt.length>5&&(yt=yt.slice(0,5)),yt},[]),Xe=R.useCallback((qe=[])=>qe.map(yt=>{var Ue;const jt=(yt==null?void 0:yt.id)||(yt==null?void 0:yt.value),Yt=((Ue=Oe.find(Ie=>Ie.value===jt))==null?void 0:Ue.label)||(yt==null?void 0:yt.name)||(yt==null?void 0:yt.title)||(yt==null?void 0:yt.label)||`Marker ${jt||""}`;return{value:jt,label:Yt}}),[Oe]),ke=R.useCallback(async qe=>{if(qe){A(qe),b(!0),P(!0);try{const yt=await qN(qe.value);q({name:(yt==null?void 0:yt.name)||qe.label||"",marker_set:Xe((yt==null?void 0:yt.marker_set)||(yt==null?void 0:yt.markers)||[]),season_start_date:(yt==null?void 0:yt.season_start_date)||""})}catch(yt){console.error(yt),Gr.error("Failed to load farm details"),b(!1)}finally{P(!1)}}},[Xe]),Ae=R.useCallback(async()=>{var qe;if(C){if(!((qe=z.name)!=null&&qe.trim())){Gr.error("Please provide a farm name");return}T(!0);try{await Yie(C.value,z.name.trim(),z.marker_set||[],z.season_start_date||void 0),Gr.success("Farm updated successfully"),Be(),h&&await h()}catch(yt){console.error(yt),Gr.error("Failed to update farm")}finally{T(!1)}}},[Be,z.marker_set,z.name,z.season_start_date,h,C]),Le=R.useCallback(qe=>{A(qe),x(!0)},[]),ze=R.useCallback(async()=>{if(C){N(!0);try{await Zie(C.value),Gr.success("Farm deleted successfully"),x(!1),Me(),h&&await h()}catch(qe){console.error(qe),Gr.error("Failed to delete farm")}finally{N(!1)}}},[h,Me,C]),Ze=R.useCallback(async qe=>{var yt,jt,Yt,Ue,Ie,be,je,Ve,rt;if(qe){$(qe),V(!0),te(!0);try{const ct=(qe==null?void 0:qe.id)||((jt=(yt=qe==null?void 0:qe.options)==null?void 0:yt.properties)==null?void 0:jt.id)||((Yt=qe==null?void 0:qe.options)==null?void 0:Yt.id),ht=((Ie=(Ue=qe==null?void 0:qe.options)==null?void 0:Ue.properties)==null?void 0:Ie.name)||((be=qe==null?void 0:qe.properties)==null?void 0:be.name)||(qe==null?void 0:qe.name)||"",et=((Ve=(je=qe==null?void 0:qe.options)==null?void 0:je.properties)==null?void 0:Ve.area)||((rt=qe==null?void 0:qe.properties)==null?void 0:rt.area)||(qe==null?void 0:qe.area)||"";ue({name:ht,area:et?String(et):""})}catch(ct){console.error(ct),Gr.error("Failed to load plot details"),V(!1)}finally{te(!1)}}},[]),We=R.useCallback(async()=>{var qe,yt,jt,Yt;if(B){if(!((qe=ge.name)!=null&&qe.trim())){Gr.error("Please provide a plot name");return}ie(!0);try{const Ie={id:(B==null?void 0:B.id)||((jt=(yt=B==null?void 0:B.options)==null?void 0:yt.properties)==null?void 0:jt.id)||((Yt=B==null?void 0:B.options)==null?void 0:Yt.id),name:ge.name.trim()};ge.area&&(Ie.area=parseFloat(ge.area)||null),await r$(Ie),Gr.success("Plot updated successfully"),V(!1),ue({name:"",area:""}),$(null),h&&await h()}catch(Ue){console.error(Ue),Gr.error("Failed to update plot")}finally{ie(!1)}}},[ge.name,ge.area,B,h]),nt=R.useCallback(qe=>{$(qe),G(!0)},[]),lt=R.useCallback(async()=>{var qe,yt,jt;if(B){fe(!0);try{const Yt=(B==null?void 0:B.id)||((yt=(qe=B==null?void 0:B.options)==null?void 0:qe.properties)==null?void 0:yt.id)||((jt=B==null?void 0:B.options)==null?void 0:jt.id);await i$(Yt),Gr.success("Plot deleted successfully"),G(!1),$(null),h&&await h()}catch(Yt){console.error(Yt),Gr.error("Failed to delete plot")}finally{fe(!1)}}},[B,h]),ft=R.useCallback(async qe=>{var yt,jt;if(qe){ne(qe),Ce(!0),_e(!0);try{const Yt=(qe==null?void 0:qe.id)||((yt=qe==null?void 0:qe.properties)==null?void 0:yt.id),Ue=await TD(Yt);De({location_name:(Ue==null?void 0:Ue.location_name)||((jt=qe==null?void 0:qe.properties)==null?void 0:jt.name)||(qe==null?void 0:qe.name)||""})}catch(Yt){console.error(Yt),Gr.error("Failed to load station details"),Ce(!1)}finally{_e(!1)}}},[]),vt=R.useCallback(async()=>{var qe,yt;if(ae){if(!((qe=de.location_name)!=null&&qe.trim())){Gr.error("Please provide a station name");return}se(!0);try{const jt=(ae==null?void 0:ae.id)||((yt=ae==null?void 0:ae.properties)==null?void 0:yt.id),Yt={id:jt,location_name:de.location_name.trim()},Ue=await TD(jt);await AD({...Ue,...Yt}),Gr.success("Station updated successfully"),Ce(!1),De({location_name:""}),ne(null),h&&await h()}catch(jt){console.error(jt),Gr.error("Failed to update station")}finally{se(!1)}}},[de.location_name,ae,h]),st=R.useCallback(qe=>{ne(qe),Ee(!0)},[]),bt=R.useCallback(async()=>{var qe;if(ae){ye(!0);try{const yt=(ae==null?void 0:ae.id)||((qe=ae==null?void 0:ae.properties)==null?void 0:qe.id);await ID(yt),Gr.success("Station deleted successfully"),Ee(!1),ne(null),h&&await h()}catch(yt){console.error(yt),Gr.error("Failed to delete station")}finally{ye(!1)}}},[ae,h]);return I.jsxs("div",{className:Rt("absolute top-20 left-1/2 -translate-x-1/2 z-20 w-96 transition-all duration-300 origin-top pointer-events-none",e==="settings"?"opacity-100 translate-y-0 pointer-events-auto":"opacity-0 -translate-y-10 pointer-events-none"),children:[I.jsxs("div",{className:"bg-white/90 backdrop-blur-xl rounded-2xl shadow-2xl overflow-hidden flex flex-col max-h-[85vh] border border-white/50",children:[I.jsxs("div",{className:"p-4 border-b border-border flex justify-between items-center bg-white/50",children:[I.jsxs("div",{children:[I.jsx("h2",{className:"font-bold text-foreground",children:"Data Management"}),I.jsx("p",{className:"text-xs text-muted-foreground",children:"Manage farms, plots & stations"})]}),I.jsx(ln,{variant:"ghost",size:"icon",className:"h-8 w-8 rounded-full",onClick:()=>t(null),children:I.jsx(pa,{className:"h-5 w-5"})})]}),I.jsxs(aLe,{defaultValue:"farms",className:"flex-1 flex flex-col",children:[I.jsxs(gz,{className:"w-full rounded-none border-b bg-muted/50",children:[I.jsx(tx,{value:"farms",className:"flex-1 text-xs font-bold uppercase tracking-wide",children:"Farms"}),I.jsx(tx,{value:"plots",className:"flex-1 text-xs font-bold uppercase tracking-wide",children:"Plots"}),I.jsx(tx,{value:"stations",className:"flex-1 text-xs font-bold uppercase tracking-wide",children:"Stations"})]}),I.jsxs(nx,{value:"farms",className:"flex-1 overflow-y-auto p-4 space-y-3 mt-0",children:[I.jsx("h3",{className:"font-semibold text-sm mb-3",children:"All Farms"}),I.jsx("div",{className:"space-y-2 mb-4 max-h-[350px] overflow-y-auto",children:n.map(qe=>I.jsx("div",{className:"bg-white/60 p-3 rounded-lg border border-border hover:border-green-500/50 transition-colors cursor-pointer group",children:I.jsxs("div",{className:"flex items-center justify-between",children:[I.jsxs("div",{className:"flex items-center gap-2",children:[I.jsx("div",{className:"w-8 h-8 bg-green-100 rounded-lg flex items-center justify-center",children:I.jsx(ow,{className:"h-4 w-4 text-green-600"})}),I.jsxs("div",{children:[I.jsx("p",{className:"text-sm font-medium",children:qe.label}),I.jsx("p",{className:"text-xs text-muted-foreground",children:qe.details})]})]}),I.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[I.jsx(ln,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>ke(qe),"aria-label":"Edit farm",children:I.jsx(cw,{className:"h-4 w-4"})}),I.jsx(ln,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>Le(qe),"aria-label":"Delete farm",children:I.jsx($y,{className:"h-4 w-4"})})]})]})},qe.value))}),I.jsxs(ln,{variant:"outline",className:"w-full border-2 border-dashed hover:border-green-500 hover:text-green-600 hover:bg-green-50",onClick:o,children:[I.jsx(_p,{className:"h-4 w-4 mr-2"}),"Add New Farm"]})]}),I.jsxs(nx,{value:"plots",className:"flex-1 overflow-y-auto p-4 space-y-3 mt-0",children:[I.jsx("h3",{className:"font-semibold text-sm mb-3",children:"All Plots"}),I.jsx("div",{className:"space-y-2 max-h-[350px] overflow-y-auto",children:r.map(qe=>{var Ue,Ie,be,je,Ve,rt,ct,ht,et,_t,It;const yt=((Ie=(Ue=qe==null?void 0:qe.options)==null?void 0:Ue.properties)==null?void 0:Ie.name)||((be=qe==null?void 0:qe.properties)==null?void 0:be.name)||`Plot ${(qe==null?void 0:qe.id)||""}`,jt=((Ve=(je=qe==null?void 0:qe.options)==null?void 0:je.properties)==null?void 0:Ve.farm_name)||((rt=qe==null?void 0:qe.properties)==null?void 0:rt.farm_name)||"Unknown Farm",Yt=((ht=(ct=qe==null?void 0:qe.options)==null?void 0:ct.properties)==null?void 0:ht.area)||((et=qe==null?void 0:qe.properties)==null?void 0:et.area)||"N/A";return I.jsx("div",{className:"bg-white/60 p-3 rounded-lg border border-border hover:border-green-500/50 transition-colors cursor-pointer group",children:I.jsxs("div",{className:"flex items-center justify-between",children:[I.jsxs("div",{className:"flex items-center gap-2",children:[I.jsx("div",{className:"w-8 h-8 bg-blue-100 rounded-lg flex items-center justify-center",children:I.jsx(xp,{className:"h-4 w-4 text-blue-600"})}),I.jsxs("div",{children:[I.jsx("p",{className:"text-sm font-medium",children:yt}),I.jsxs("p",{className:"text-xs text-muted-foreground",children:[jt," • ",Yt]})]})]}),I.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[I.jsx(ln,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>Ze(qe),"aria-label":"Edit plot",children:I.jsx(cw,{className:"h-4 w-4"})}),I.jsx(ln,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>nt(qe),"aria-label":"Delete plot",children:I.jsx($y,{className:"h-4 w-4"})})]})]})},(qe==null?void 0:qe.id)||((It=(_t=qe==null?void 0:qe.options)==null?void 0:_t.properties)==null?void 0:It.id))})}),I.jsxs(ln,{variant:"outline",className:"w-full border-2 border-dashed hover:border-green-500 hover:text-green-600 hover:bg-green-50",onClick:s,children:[I.jsx(_p,{className:"h-4 w-4 mr-2"}),"Add Plot"]})]}),I.jsxs(nx,{value:"stations",className:"flex-1 overflow-y-auto p-4 space-y-3 mt-0",children:[I.jsx("h3",{className:"font-semibold text-sm mb-3",children:"All Stations"}),I.jsx("div",{className:"space-y-2 max-h-[350px] overflow-y-auto",children:i.map(qe=>{var Ie,be,je,Ve;const yt=((Ie=qe==null?void 0:qe.properties)==null?void 0:Ie.name)||(qe==null?void 0:qe.name)||`Station ${(qe==null?void 0:qe.id)||""}`,jt=((be=qe==null?void 0:qe.properties)==null?void 0:be.farm_name)||(qe==null?void 0:qe.farm_name)||"Unknown Farm",Yt=((je=qe==null?void 0:qe.properties)==null?void 0:je.paw_status)||(qe==null?void 0:qe.paw_status)||"Unknown",Ue=Yt==="OPTIMAL"||Yt==="optimal"?"green":Yt==="STRESS_START"||Yt==="stress"?"orange":"gray";return I.jsx("div",{className:"bg-white/60 p-3 rounded-lg border border-border hover:border-green-500/50 transition-colors cursor-pointer group",children:I.jsxs("div",{className:"flex items-center justify-between",children:[I.jsxs("div",{className:"flex items-center gap-2",children:[I.jsx("div",{className:Rt("w-8 h-8 rounded-lg flex items-center justify-center",Ue==="orange"&&"bg-orange-100",Ue==="green"&&"bg-green-100",Ue==="gray"&&"bg-gray-100"),children:I.jsx(Ry,{className:Rt("h-4 w-4",Ue==="orange"&&"text-orange-600",Ue==="green"&&"text-green-600",Ue==="gray"&&"text-gray-600")})}),I.jsxs("div",{children:[I.jsx("p",{className:"text-sm font-medium",children:yt}),I.jsxs("p",{className:"text-xs text-muted-foreground",children:[jt," • ",a(Yt)]})]})]}),I.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[I.jsx(ln,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>ft(qe),"aria-label":"Edit station",children:I.jsx(cw,{className:"h-4 w-4"})}),I.jsx(ln,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>st(qe),"aria-label":"Delete station",children:I.jsx($y,{className:"h-4 w-4"})})]})]})},(qe==null?void 0:qe.id)||((Ve=qe==null?void 0:qe.properties)==null?void 0:Ve.id))})}),I.jsxs(ln,{variant:"outline",className:"w-full border-2 border-dashed hover:border-green-500 hover:text-green-600 hover:bg-green-50",onClick:u,children:[I.jsx(_p,{className:"h-4 w-4 mr-2"}),"Add Station"]})]})]})]}),I.jsx(_T,{open:y,onOpenChange:qe=>!qe&&Be(),children:I.jsxs(Dx,{className:"sm:max-w-lg",children:[I.jsxs(Nx,{children:[I.jsx(jx,{children:"Edit Farm"}),I.jsx(Fx,{children:"Update the farm name, markers and season start date."})]}),I.jsxs("div",{className:"space-y-4",children:[I.jsxs("div",{className:"space-y-2",children:[I.jsx("p",{className:"text-sm font-medium text-foreground",children:"Farm Name"}),I.jsx(vl,{value:z.name,onChange:qe=>q(yt=>({...yt,name:qe.target.value})),placeholder:"Farm name",disabled:E})]}),I.jsxs("div",{className:"space-y-2",children:[I.jsx("p",{className:"text-sm font-medium text-foreground",children:"Markers"}),I.jsx(To,{value:lc(z.marker_set,Oe),onChange:qe=>q(yt=>({...yt,marker_set:qe||[]})),options:Oe,isMulti:!0,isLoading:p||E,isClearable:!0,placeholder:"Select markers"})]}),I.jsxs("div",{className:"space-y-2",children:[I.jsx("p",{className:"text-sm font-medium text-foreground",children:"Season start date"}),I.jsx(vl,{value:z.season_start_date,onChange:qe=>q(yt=>({...yt,season_start_date:Fe(qe.target.value)})),placeholder:"MM/DD",maxLength:5,disabled:E})]})]}),I.jsxs(Lx,{children:[I.jsx(ln,{variant:"outline",onClick:Be,disabled:O,children:"Cancel"}),I.jsx(ln,{onClick:Ae,disabled:O||E,children:O?"Saving...":"Save changes"})]})]})}),I.jsx(ig,{isOpen:_,onClose:()=>x(!1),onConfirm:ze,onCancel:()=>x(!1),title:"Delete farm",message:`Are you sure you want to delete "${(C==null?void 0:C.label)||"this farm"}"?`,confirmText:k?"Deleting...":"Delete",cancelText:"Cancel",variant:"destructive"}),I.jsx(_T,{open:H,onOpenChange:qe=>!qe&&V(!1),children:I.jsxs(Dx,{className:"sm:max-w-lg",children:[I.jsxs(Nx,{children:[I.jsx(jx,{children:"Edit Plot"}),I.jsx(Fx,{children:"Update the plot name and area."})]}),I.jsxs("div",{className:"space-y-4",children:[I.jsxs("div",{className:"space-y-2",children:[I.jsx("p",{className:"text-sm font-medium text-foreground",children:"Plot Name"}),I.jsx(vl,{value:ge.name,onChange:qe=>ue(yt=>({...yt,name:qe.target.value})),placeholder:"Plot name",disabled:Y})]}),I.jsxs("div",{className:"space-y-2",children:[I.jsx("p",{className:"text-sm font-medium text-foreground",children:"Area"}),I.jsx(vl,{type:"number",value:ge.area,onChange:qe=>ue(yt=>({...yt,area:qe.target.value})),placeholder:"Area (optional)",disabled:Y})]})]}),I.jsxs(Lx,{children:[I.jsx(ln,{variant:"outline",onClick:()=>V(!1),disabled:re,children:"Cancel"}),I.jsx(ln,{onClick:We,disabled:re||Y,children:re?"Saving...":"Save changes"})]})]})}),I.jsx(ig,{isOpen:U,onClose:()=>G(!1),onConfirm:lt,onCancel:()=>G(!1),title:"Delete plot",message:`Are you sure you want to delete "${((Ft=(Ct=B==null?void 0:B.options)==null?void 0:Ct.properties)==null?void 0:Ft.name)||((Lt=B==null?void 0:B.properties)==null?void 0:Lt.name)||(B==null?void 0:B.name)||"this plot"}"?`,confirmText:J?"Deleting...":"Delete",cancelText:"Cancel",variant:"destructive"}),I.jsx(_T,{open:ve,onOpenChange:qe=>!qe&&Ce(!1),children:I.jsxs(Dx,{className:"sm:max-w-lg",children:[I.jsxs(Nx,{children:[I.jsx(jx,{children:"Edit Station"}),I.jsx(Fx,{children:"Update the station name."})]}),I.jsx("div",{className:"space-y-4",children:I.jsxs("div",{className:"space-y-2",children:[I.jsx("p",{className:"text-sm font-medium text-foreground",children:"Station Name"}),I.jsx(vl,{value:de.location_name,onChange:qe=>De(yt=>({...yt,location_name:qe.target.value})),placeholder:"Station name",disabled:he})]})}),I.jsxs(Lx,{children:[I.jsx(ln,{variant:"outline",onClick:()=>Ce(!1),disabled:Z,children:"Cancel"}),I.jsx(ln,{onClick:vt,disabled:Z||he,children:Z?"Saving...":"Save changes"})]})]})}),I.jsx(ig,{isOpen:Te,onClose:()=>Ee(!1),onConfirm:bt,onCancel:()=>Ee(!1),title:"Delete station",message:`Are you sure you want to delete "${((St=ae==null?void 0:ae.properties)==null?void 0:St.name)||(ae==null?void 0:ae.name)||"this station"}"?`,confirmText:le?"Deleting...":"Delete",cancelText:"Cancel",variant:"destructive"})]})}function sFe({selectedFarm:e,farmOpen:t,setFarmOpen:n,farms:r=[],handleFarmSelect:i,onAddFarm:a}){const[o,s]=R.useState(""),u=R.useMemo(()=>{if(!o.trim())return r;const m=o.toLowerCase();return r.filter(p=>{var y,b;return((y=p.label)==null?void 0:y.toLowerCase().includes(m))||((b=p.details)==null?void 0:b.toLowerCase().includes(m))})},[r,o]),h=(m,p)=>{i(e===p||e===m?null:m),n(!1),s("")};return I.jsxs(hv,{open:t,onOpenChange:n,children:[I.jsx(fv,{asChild:!0,children:I.jsxs(ln,{variant:"ghost",className:"h-10 px-4 rounded-none flex items-center gap-3 hover:bg-white/50 text-foreground",children:[I.jsx(ow,{className:"h-4 w-4 text-muted-foreground shrink-0"}),I.jsxs("div",{className:"flex flex-col items-start leading-none",children:[I.jsx("span",{className:"text-[10px] font-bold text-muted-foreground uppercase tracking-wider",children:"Farm"}),I.jsx("span",{className:"text-xs font-bold whitespace-nowrap",children:e||"Select a farm"})]}),I.jsx(mo,{className:"h-3 w-3 text-muted-foreground ml-1 shrink-0"})]})}),I.jsx(rS,{className:"w-[280px] p-0",align:"start",children:I.jsxs("div",{className:"flex flex-col",children:[I.jsxs("div",{className:"flex items-center border-b px-3",children:[I.jsx(By,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),I.jsx(vl,{placeholder:"Search farm...",value:o,onChange:m=>s(m.target.value),className:"border-none focus-visible:ring-0 focus-visible:ring-offset-0 focus-visible:shadow-none h-11 bg-transparent px-0"})]}),I.jsx("div",{className:"max-h-[350px] overflow-y-auto",children:u.length===0?I.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"No farm found."}):I.jsxs(I.Fragment,{children:[I.jsx("div",{className:"px-2 py-1.5 text-xs font-medium text-muted-foreground",children:"Farms"}),I.jsx("div",{className:"p-1",children:u.map(m=>I.jsxs("div",{onClick:()=>h(m.value,m.label),className:Rt("relative flex w-full cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none hover:bg-accent hover:text-accent-foreground",(e===m.label||e===m.value)&&"bg-accent text-accent-foreground"),children:[I.jsx(lw,{className:Rt("mr-2 h-4 w-4",e===m.label||e===m.value?"opacity-100":"opacity-0")}),I.jsxs("div",{className:"flex flex-col",children:[I.jsx("span",{children:m.label}),I.jsx("span",{className:"text-xs text-muted-foreground",children:m.details})]})]},m.value))})]})}),I.jsx("div",{className:"h-px bg-border mx-1"}),I.jsx("div",{className:"p-2 border-t",children:I.jsxs(ln,{variant:"ghost",className:"w-full justify-start h-9 text-sm font-medium text-muted-foreground hover:text-green-600 hover:bg-green-50",onClick:a,children:[I.jsx(_p,{className:"h-4 w-4 mr-2"}),"Add New Farm"]})})]})})]})}function oFe({mapRef:e}){const[t,n]=R.useState(null),[r,i]=R.useState(null),[a,o]=R.useState(!1),[s,u]=R.useState([]),[h,m]=R.useState(""),[p,y]=R.useState(!1);Tt(Oe=>Oe.setSidebarExpanded);const b=Tt(Oe=>Oe.setViewMode),{markerFilters:_,setMarkerFilters:x,showMarkers:C,setShowMarkers:A,markers:E,unfilteredMarkers:P}=R.useContext(Za),{plots:O}=R.useContext(Zs),T=Tt(Oe=>Oe.rasterLayer),k=Tt(Oe=>Oe.setRasterLayer),N=Tt(Oe=>Oe.showCroppedImages),z=Tt(Oe=>Oe.setShowCroppedImages),q=Tt(Oe=>Oe.rasterOpacity),H=Tt(Oe=>Oe.setRasterOpacity),{isVisible:V,setIsVisible:U}=R.useContext(Jm),G=R.useCallback(Oe=>{const Me=Gf("selected-farm");if(Me&&Oe.length>0){const Be=Oe.find(Fe=>Fe.value===Me||Fe.value==Me);if(Be){i(Be.label),x(Fe=>({...Fe,farm_id:Be.value}));return}}i(null),py("selected-farm"),x(Be=>({...Be,farm_id:null}))},[x]),B=R.useCallback(async()=>{try{const Me=(await Iv()).map(Be=>({value:Be.value||Be.id,label:Be.label||Be.name,details:`${Be.plots||0} plots • ${Be.stations||0} stations`}));return u(Me),G(Me),Me}catch(Oe){return console.error("Failed to load farms:",Oe),[]}},[G]);R.useEffect(()=>{B()},[]);const $=R.useCallback(Oe=>{n(t===Oe?null:Oe)},[t]),Y=R.useCallback(Oe=>{const Me=s.find(Xe=>Xe.value===Oe);if(Me?(i(Me.label),fd("selected-farm",Oe)):(i(null),py("selected-farm")),o(!1),x({..._,farm_id:Oe||null}),!Oe||!(e!=null&&e.current))return;const Be=O.filter(Xe=>{const ke=Xe==null?void 0:Xe.farm;return ke?(typeof ke=="object"?ke==null?void 0:ke.id:ke)==Oe:!1});if(Be.length>0){const Xe=new Wf.LngLatBounds;let ke=!1;if(Be.forEach(Ae=>{var ze;const Le=((ze=Ae==null?void 0:Ae.options)==null?void 0:ze.geometry)||(Ae==null?void 0:Ae.geometry);if(Le!=null&&Le.coordinates){const Ze=Le.type==="Polygon"?Le.coordinates[0]:Le.coordinates;Array.isArray(Ze)&&Ze.forEach(We=>{Array.isArray(We)&&We.length>=2&&(Xe.extend([We[0],We[1]]),ke=!0)})}}),ke){const Ae=e.current.getMap();Ae&&Ae.fitBounds(Xe,{padding:100,maxZoom:15,essential:!0});return}}const Fe=P==null?void 0:P.find(Xe=>{var ke;return((ke=Xe==null?void 0:Xe.farm)==null?void 0:ke.id)==Oe});if(Fe!=null&&Fe.lat&&(Fe!=null&&Fe.lng)){const Xe=e.current.getMap();Xe&&Xe.flyTo({center:[Fe.lng,Fe.lat],essential:!0,zoom:12})}},[s,_,x,O,P,e]),te=R.useCallback(()=>B(),[B]),re=R.useCallback(Oe=>!Oe||Oe===""?"All":Oe.charAt(0).toUpperCase()+Oe.slice(1).replace(/_/g," "),[]),ie=(_==null?void 0:_.type)||"",J=(_==null?void 0:_.paw_status)||"",fe=N?"plot":"map",ge=R.useCallback(Oe=>{z(Oe==="plot")},[z]),ue=T,ve=R.useCallback(Oe=>{k(Oe)},[k]),Ce=[{value:"",label:"All"},{value:"station",label:"Station"},{value:"forecast",label:"Forecast"}],Te=[{value:"",label:"All"},{value:"OPTIMAL",label:"Optimal"},{value:"STRESS_START",label:"Stress"},{value:"SEVERE_STRESS",label:"Severe"}],Ee=R.useCallback(Oe=>{x({..._,type:Oe})},[_,x]),ae=R.useCallback(Oe=>{x({..._,paw_status:Oe})},[_,x]),ne=R.useCallback(Oe=>{if(!(e!=null&&e.current))return;const Me=e.current.getMap();Me&&Me.getStyle().layers.forEach(Be=>{Be.id.startsWith("croppedImageLayer-")&&Me.setPaintProperty(Be.id,"raster-opacity",Number(Oe/100))})},[e]),he=Gd(ne,500),_e=[q],Z=R.useCallback(Oe=>{const Me=Oe[0];H(Me),he(Me)},[H,he]),se=R.useCallback(()=>{b(qn.ADD_NEW_FARM),n(null)},[b]),le=R.useCallback(()=>{b(qn.ADD_PLOT),n(null)},[b]),ye=R.useCallback(()=>{b(qn.ADD_MARKER),n(null)},[b]),de=R.useMemo(()=>{if(!h||h.trim()==="")return[];const Oe=h.toLowerCase().trim(),Me=[],Be=E||[];return s.forEach(Fe=>{const Xe=(Fe.label||"").toLowerCase(),ke=(Fe.details||"").toLowerCase();(Xe.includes(Oe)||ke.includes(Oe))&&Me.push({id:`farm-${Fe.value}`,type:"farm",label:Fe.label,subLabel:Fe.details||"Farm",data:Fe})}),O.forEach(Fe=>{var Le,ze,Ze,We,nt,lt,ft,vt,st,bt,Ct,Ft,Lt,St,qe,yt,jt;const Xe=(((ze=(Le=Fe==null?void 0:Fe.options)==null?void 0:Le.properties)==null?void 0:ze.name)||((Ze=Fe==null?void 0:Fe.properties)==null?void 0:Ze.name)||`Plot ${(Fe==null?void 0:Fe.id)||""}`).toLowerCase(),ke=(((nt=(We=Fe==null?void 0:Fe.options)==null?void 0:We.properties)==null?void 0:nt.farm_name)||((lt=Fe==null?void 0:Fe.properties)==null?void 0:lt.farm_name)||"Unknown Farm").toLowerCase(),Ae=((vt=(ft=Fe==null?void 0:Fe.options)==null?void 0:ft.properties)==null?void 0:vt.area)||((st=Fe==null?void 0:Fe.properties)==null?void 0:st.area)||"N/A";if(Xe.includes(Oe)||ke.includes(Oe)){const Yt=((Ct=(bt=Fe==null?void 0:Fe.options)==null?void 0:bt.properties)==null?void 0:Ct.farm_name)||((Ft=Fe==null?void 0:Fe.properties)==null?void 0:Ft.farm_name)||"Unknown Farm";Me.push({id:`plot-${(Fe==null?void 0:Fe.id)||((St=(Lt=Fe==null?void 0:Fe.options)==null?void 0:Lt.properties)==null?void 0:St.id)}`,type:"plot",label:((yt=(qe=Fe==null?void 0:Fe.options)==null?void 0:qe.properties)==null?void 0:yt.name)||((jt=Fe==null?void 0:Fe.properties)==null?void 0:jt.name)||`Plot ${(Fe==null?void 0:Fe.id)||""}`,subLabel:`${Yt} • ${Ae}`,data:Fe})}}),Be.forEach(Fe=>{var We,nt,lt,ft,vt,st;const Xe=((Fe==null?void 0:Fe.title)||"").toLowerCase(),ke=((Fe==null?void 0:Fe.location_name)||"").toLowerCase(),Ae=(((We=Fe==null?void 0:Fe.device)==null?void 0:We.name)||"").toLowerCase(),Le=(((nt=Fe==null?void 0:Fe.device)==null?void 0:nt.serial)||"").toLowerCase(),ze=(((lt=Fe==null?void 0:Fe.farm)==null?void 0:lt.name)||(Fe==null?void 0:Fe.farm_name)||"Unknown Farm").toLowerCase(),Ze=(Fe==null?void 0:Fe.paw_status)||((ft=Fe==null?void 0:Fe.properties)==null?void 0:ft.paw_status)||"Unknown";if(Xe.includes(Oe)||ke.includes(Oe)||Ae.includes(Oe)||Le.includes(Oe)||ze.includes(Oe)){const bt=((vt=Fe==null?void 0:Fe.farm)==null?void 0:vt.name)||(Fe==null?void 0:Fe.farm_name)||"Unknown Farm";Me.push({id:`station-${(Fe==null?void 0:Fe.id)||((st=Fe==null?void 0:Fe.properties)==null?void 0:st.id)}`,type:"station",label:(Fe==null?void 0:Fe.title)||(Fe==null?void 0:Fe.location_name)||`Station ${(Fe==null?void 0:Fe.id)||""}`,subLabel:`${bt} • ${re(Ze)}`,data:Fe})}}),Me},[h,s,O,E,re]),De=R.useCallback(Oe=>{var Me,Be;if(e!=null&&e.current){if(Oe.type==="farm")Y(Oe.data.value),y(!1),m("");else if(Oe.type==="plot"){const Fe=Oe.data,Xe=((Me=Fe==null?void 0:Fe.options)==null?void 0:Me.geometry)||(Fe==null?void 0:Fe.geometry);if(Xe&&Xe.coordinates){const ke=Xe.coordinates[0]||Xe.coordinates;if(ke&&ke.length>0){let Ae=0,Le=0;const ze=ke.filter(Ze=>Ze&&Ze.length>=2);if(ze.forEach(Ze=>{const[We,nt]=Ze;Le+=We,Ae+=nt}),ze.length>0){const Ze=Le/ze.length,We=Ae/ze.length;e.current.flyTo({center:[Ze,We],zoom:14})}}}y(!1),m("")}else if(Oe.type==="station"){const Fe=Oe.data,Xe=(Fe==null?void 0:Fe.location)||((Be=Fe==null?void 0:Fe.properties)==null?void 0:Be.location);if(Xe){const ke=Xe.lat||Xe.latitude,Ae=Xe.lng||Xe.longitude;ke&&Ae&&e.current.flyTo({center:[Ae,ke],zoom:14})}y(!1),m("")}}},[e,Y,y,m]);return I.jsx(lFe,{activePanel:t,togglePanel:$,selectedFarm:r,farmOpen:a,setFarmOpen:o,farms:s,handleFarmSelect:Y,markerType:ie,pawStatus:J,formatLabel:re,searchQuery:h,setSearchQuery:m,isSearchFocused:p,setIsSearchFocused:y,dataSource:ue,setDataSource:ve,viewType:fe,setViewType:ge,layerOptions:dp,layerOpacity:_e,setLayerOpacity:Z,layerEnabled:V,setLayerEnabled:U,setMarkerType:Ee,setPawStatus:ae,markerTypeOptions:Ce,pawStatusOptions:Te,showMarkers:C,setShowMarkers:A,plots:O||[],markers:E||[],onAddFarm:se,onAddPlot:le,onAddStation:ye,searchResults:de,onSearchResultClick:De,onFarmsChange:te})}function lFe({togglePanel:e,activePanel:t,selectedFarm:n,farmOpen:r,setFarmOpen:i,farms:a,handleFarmSelect:o,markerType:s,pawStatus:u,formatLabel:h,searchQuery:m,setSearchQuery:p,isSearchFocused:y,setIsSearchFocused:b,dataSource:_,setDataSource:x,viewType:C,setViewType:A,layerOptions:E=[],layerOpacity:P=[100],setLayerOpacity:O,layerEnabled:T=!0,setLayerEnabled:k,setMarkerType:N,setPawStatus:z,markerTypeOptions:q=[],pawStatusOptions:H=[],showMarkers:V=!0,setShowMarkers:U,plots:G=[],markers:B=[],onAddFarm:$,onAddPlot:Y,onAddStation:te,onFarmsChange:re,searchResults:ie=[],onSearchResultClick:J}){return R.useContext(ha),I.jsxs(I.Fragment,{children:[I.jsx("div",{className:"absolute top-4 w-full z-30 flex justify-center pointer-events-none",children:I.jsxs("div",{className:"bg-white/90 backdrop-blur-xl border border-white/50 shadow-sm rounded-md flex items-center pointer-events-auto",children:[I.jsx(ln,{variant:"ghost",size:"icon",className:"w-10 h-10 rounded-l-md rounded-r-none text-muted-foreground hover:bg-white/50 hover:text-foreground",onClick:()=>e("settings"),children:I.jsx(bK,{className:"h-5 w-5"})}),I.jsx("div",{className:"w-px h-6 bg-border"}),I.jsxs(ln,{variant:"ghost",className:"h-10 px-4 rounded-none flex items-center gap-3 hover:bg-white/50 text-foreground",onClick:()=>e("layers"),children:[I.jsx(xp,{className:"h-4 w-4 text-muted-foreground shrink-0"}),I.jsxs("div",{className:"flex flex-col items-start leading-none",children:[I.jsx("span",{className:"text-[10px] font-bold text-muted-foreground uppercase tracking-wider",children:"Layer"}),I.jsxs("span",{className:"text-xs font-bold whitespace-nowrap",children:[(_==null?void 0:_.label)||"Evapo"," ",I.jsxs("span",{className:"text-muted-foreground font-normal",children:["• ",C==="plot"?"Plot View":"Map View"]})]})]}),I.jsx(mo,{className:"h-3 w-3 text-muted-foreground ml-1 shrink-0"})]}),I.jsx("div",{className:"w-px h-6 bg-border"}),I.jsxs(ln,{variant:"ghost",className:"h-10 px-4 rounded-none flex items-center gap-3 hover:bg-white/50 text-foreground",onClick:()=>e("stations"),children:[I.jsx(Ry,{className:"h-4 w-4 text-muted-foreground shrink-0"}),I.jsxs("div",{className:"flex flex-col items-start leading-none",children:[I.jsx("span",{className:"text-[10px] font-bold text-muted-foreground uppercase tracking-wider",children:"Filter"}),I.jsxs("span",{className:"text-xs font-bold whitespace-nowrap",children:[h(s)," ",I.jsx("span",{className:"text-muted-foreground font-normal",children:"•"})," ",h(u)]})]}),I.jsx(mo,{className:"h-3 w-3 text-muted-foreground ml-1 shrink-0"})]}),I.jsx("div",{className:"w-px h-6 bg-border"}),I.jsx(sFe,{selectedFarm:n,farmOpen:r,setFarmOpen:i,farms:a,handleFarmSelect:o,onAddFarm:$}),I.jsx("div",{className:"w-px h-6 bg-border"}),I.jsxs("div",{className:"relative",children:[I.jsxs("div",{className:Rt("flex items-center gap-2 px-3 h-10 rounded-r-md transition-all duration-300",y?"w-64 bg-white":"w-40 hover:bg-white/50"),children:[I.jsx(By,{className:"h-4 w-4 text-muted-foreground shrink-0"}),I.jsx(vl,{type:"text",placeholder:"Search...",value:m,onChange:fe=>p(fe.target.value),onFocus:()=>b(!0),onBlur:()=>setTimeout(()=>b(!1),200),className:"bg-transparent border-none focus-visible:ring-0 focus-visible:ring-offset-0 focus-visible:shadow-none text-sm h-full placeholder:text-muted-foreground/70 px-0 w-full"})]}),I.jsx(Q5e,{isSearchFocused:y,searchQuery:m,searchResults:ie,onResultClick:J})]})]})}),I.jsx(Q4e,{activePanel:t,togglePanel:e,viewType:C,setViewType:A,dataSource:_,setDataSource:x,layerOptions:E,layerOpacity:P,setLayerOpacity:O,layerEnabled:T,setLayerEnabled:k}),I.jsx(rFe,{activePanel:t,togglePanel:e,markerType:s,setMarkerType:N,pawStatus:u,setPawStatus:z,markerTypeOptions:q,pawStatusOptions:H,showMarkers:V,setShowMarkers:U,formatLabel:h}),I.jsx(aFe,{activePanel:t,togglePanel:e,farms:a,plots:G,markers:B,formatLabel:h,onAddFarm:$,onAddPlot:Y,onAddStation:te,onFarmsChange:re})]})}const S8=ee.forwardRef(({className:e,value:t,...n},r)=>{const i=Math.min(Math.max(t||0,0),100);return I.jsx("div",{ref:r,className:Rt("relative h-4 w-full overflow-hidden rounded-full bg-secondary",e),...n,children:I.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${i}%`}})})});S8.displayName="Progress";function cFe({className:e}){var P,O,T;const t=Tt(k=>k.pickerData),n=Tt(k=>k.hoveredPlot),{plots:r}=R.useContext(Zs),[i,a]=R.useState(null),[o,s]=R.useState(!1),u=R.useRef(null),h=R.useCallback(k=>{var N,z,q,H;return k?(k==null?void 0:k.id)||((N=k==null?void 0:k.options)==null?void 0:N.id)||((q=(z=k==null?void 0:k.options)==null?void 0:z.properties)==null?void 0:q.id)||((H=k==null?void 0:k.properties)==null?void 0:H.id):null},[]),m=R.useMemo(()=>{var k,N;return n||((N=(k=t==null?void 0:t.plot)==null?void 0:k.properties)!=null&&N.id?r==null?void 0:r.find(z=>{var V,U,G,B;const q=((V=z==null?void 0:z.options)==null?void 0:V.id)||(z==null?void 0:z.id),H=((G=(U=t==null?void 0:t.plot)==null?void 0:U.properties)==null?void 0:G.id)||((B=t==null?void 0:t.plot)==null?void 0:B.id);return q===H}):null)},[n,(O=(P=t==null?void 0:t.plot)==null?void 0:P.properties)==null?void 0:O.id,(T=t==null?void 0:t.plot)==null?void 0:T.id,r]);R.useEffect(()=>{if(!m){a(null),s(!1),u.current=null;return}const k=h(m);console.log("ETProgressIndicator: selectedPlot:",m),console.log("ETProgressIndicator: currentPlotId:",k),console.log("ETProgressIndicator: device:",m==null?void 0:m.device),k!==u.current&&(u.current=k,s(!0),rE({stationId:m==null?void 0:m.device,plotId:k}).then(N=>{console.log("ETProgressIndicator: task stats received:",N),a(N)}).catch(N=>{console.error("Error fetching task stats:",N),a(null)}).finally(()=>{s(!1)}))},[m,h]),R.useEffect(()=>{if(!m||!i||!((i.running||0)>0||(i.pending||0)>0))return;const N=h(m),z=setInterval(()=>{rE({stationId:m==null?void 0:m.device,plotId:N}).then(q=>{a(q)}).catch(q=>{console.error("Error polling task stats:",q)})},5e3);return()=>{clearInterval(z)}},[m,i,h]);const p=R.useMemo(()=>{var k,N;return m&&((m==null?void 0:m.enable_satellite_et)||((N=(k=m==null?void 0:m.options)==null?void 0:k.properties)==null?void 0:N.enable_satellite_et))||!1},[m]),y=R.useMemo(()=>{if(!i)return null;const k=i.stopped||0,N=i.running||0,z=i.pending||0,q=i.failed||0,H=k+N+z+q;if(H===0)return null;const V=k,U=H,G=V/U*100,B=Math.max(0,U-V),$=V>=U,Y=(N>0||z>0)&&!$;return{daysGenerated:V,totalDays:U,percentage:G,daysRemaining:B,isComplete:$,isGenerating:Y}},[i]);if(!m||!p)return null;if(o)return I.jsx("div",{className:Rt("bg-card/95 backdrop-blur-sm border border-border rounded-lg shadow-lg p-3 min-w-[280px]",e),children:I.jsx("div",{className:"space-y-2",children:I.jsxs("div",{className:"flex items-center gap-2",children:[I.jsx("div",{className:"w-2 h-2 rounded-full bg-muted-foreground animate-pulse"}),I.jsx("span",{className:"text-sm font-medium text-foreground",children:"Loading ET Data..."})]})})});if(!y)return I.jsx("div",{className:Rt("bg-card/95 backdrop-blur-sm border border-border rounded-lg shadow-lg p-3 min-w-[280px]",e),children:I.jsx("div",{className:"space-y-2",children:I.jsxs("div",{className:"flex items-center gap-2",children:[I.jsx("div",{className:"w-2 h-2 rounded-full bg-chart-1 animate-pulse"}),I.jsx("span",{className:"text-sm font-medium text-foreground",children:"Generating ET Data"})]})})});const{daysGenerated:b,totalDays:_,percentage:x,daysRemaining:C,isComplete:A,isGenerating:E}=y;return I.jsx("div",{className:Rt("bg-card/95 backdrop-blur-sm border border-border rounded-lg shadow-lg p-3 min-w-[280px]",e),children:I.jsxs("div",{className:"space-y-2",children:[I.jsx("div",{className:"flex items-center justify-between gap-2",children:I.jsxs("div",{className:"flex items-center gap-2",children:[I.jsx("div",{className:Rt("w-2 h-2 rounded-full",E?"bg-chart-1 animate-pulse":"bg-green-500")}),I.jsx("span",{className:"text-sm font-medium text-foreground",children:E?"Generating ET Data":"ET Data Ready"})]})}),I.jsx(S8,{value:x,className:"h-2"}),I.jsxs("div",{className:"flex items-center justify-between text-xs",children:[I.jsxs("span",{className:"text-muted-foreground",children:[b," of ",_," days"]}),I.jsx("span",{className:Rt("font-medium",A?"text-green-500":"text-chart-1"),children:A?"100%":C>0?`${C} remaining`:`${Math.round(x)}%`})]})]})})}function uFe({style:e,configs:t,markers:n}){var k;const{settings:r}=R.useContext(hp),{mapRef:i}=R.useContext(ha),a=R.useRef(),o=kY(),[s,u]=R.useState(o),h=Tt(N=>N.viewMode),m=Tt(N=>N.mapMode),p=Tt(N=>N.cursor),y=Tt(N=>N.setConfigs);Tt(N=>N.sidebarExpanded),$h(),qm();const b=Tt(N=>N.dateRange),_=Tt(N=>N.setDateRange),x=Tt(N=>N.dateRange2),C=Tt(N=>N.setDateRange2),A=R.useCallback(N=>u(N.viewState),[]);R.useEffect(()=>{try{const N=s1("map-viewport");N&&u(N)}catch(N){console.error("Failed to load viewport from localStorage:",N)}},[]),R.useEffect(()=>{if(s)try{o1("map-viewport",s)}catch(N){console.error("Failed to save viewport to localStorage:",N)}},[s]),R.useEffect(()=>{if(m)try{fd("map-mode",m)}catch(N){console.error("Failed to save mapMode to localStorage:",N)}},[m]);const E=R.useCallback(N=>{_(N?{start:N,end:N}:{start:void 0,end:void 0})},[_]),P=R.useCallback(N=>{C(N?{start:N,end:N}:{start:void 0,end:void 0})},[C]),[O,T]=R.useState(`${(k=nP.find(N=>N.id===r.basemap.id))==null?void 0:k.url}?key=${t==null?void 0:t.VITE_MAPTILER_ACCESS_KEY}`);return R.useEffect(()=>{var N;T(`${(N=nP.find(z=>z.id===r.basemap.id))==null?void 0:N.url}?key=${t==null?void 0:t.VITE_MAPTILER_ACCESS_KEY}`)},[r]),R.useEffect(()=>{y(t)},[]),R.useEffect(()=>{console.log("fff dateRange is",b),console.log("fff dateRange2 is",x)},[b,x]),R.useEffect(()=>{if(i!=null&&i.current){const N=i.current.getMap();if(N&&N.scrollZoom){const z=()=>{N.scrollZoom&&N.scrollZoom.disable()};return N.loaded()?z():N.once("load",z),()=>{N&&N.off("load",z)}}}},[i]),R.useEffect(()=>{if(a!=null&&a.current){const N=a.current.getMap();if(N&&N.scrollZoom){const z=()=>{N.scrollZoom&&N.scrollZoom.disable()};return N.loaded()?z():N.once("load",z),()=>{N&&N.off("load",z)}}}},[a]),o?I.jsx(cS,{providedMarkers:n,children:I.jsx(sE,{children:I.jsx(O9,{children:I.jsx(Zke,{children:I.jsxs("div",{style:{width:"100%",height:"80vh"},className:"flex flex-row relative",children:[I.jsxs(MP,{id:"myMap",ref:i,initialViewState:o,...s,onMove:A,style:{width:"100%",...e},mapStyle:typeof O=="string"?O:O.toJS(),attributionControl:!1,reuseMaps:!0,preserveDrawingBuffer:!0,cursor:p,children:[I.jsx(g9,{mapRef:i,dateRange:b}),m==Ga.NORMAL&&I.jsx(oFe,{mapRef:i}),m==Ga.NORMAL&&I.jsx("div",{className:"absolute top-4 left-4 z-20 pointer-events-none",children:I.jsx("div",{className:"pointer-events-auto",children:I.jsx(cFe,{})})}),I.jsx("div",{className:"absolute top-0 left-0",children:m==Ga.COMPARISION_VIEW&&I.jsx(pv,{compact:!0,onDateSelect:E,mapRef:i,dateRange:b})}),m===Ga.NORMAL&&I.jsx(b9,{dateRange:b,mapRef:i}),m!==Ga.NORMAL&&I.jsx("div",{className:"absolute top-0 right-0 m-2",style:{zIndex:2},children:I.jsx(v9,{dateRange:b,mapRef:i,showButton:!1})}),I.jsx("div",{className:"absolute bottom-4 left-4",style:{zIndex:3},children:I.jsx(mke,{})}),I.jsxs("div",{className:"absolute bottom-4 right-20 flex flex-col gap-4 items-end",style:{zIndex:10},children:[I.jsx(D9,{mapRef:i}),I.jsx($je,{})]}),I.jsx("div",{className:"absolute bottom-4 left-0 right-0 flex justify-center items-center",style:{zIndex:3},children:I.jsx(One,{mapRef:i,configs:t,onDateSelect:E})}),I.jsx(T3e,{}),h==qn.EDIT_PLOT&&I.jsx(j5e,{}),h==qn.ADD_PLOT&&I.jsx(F5e,{}),h==qn.ADD_MARKER&&I.jsx(R5e,{}),h==qn.ADD_NEW_FARM&&I.jsx(B5e,{}),I.jsx(are,{}),I.jsx(Nle,{}),I.jsx(Fz,{mapRef:i,dateRange:b}),I.jsx(A3e,{}),I.jsx(z5e,{})]}),m===Ga.COMPARISION_VIEW&&I.jsxs(MP,{id:"myMap2",ref:a,initialViewState:o,...s,onMove:A,style:{width:"100%",...e},mapStyle:typeof O=="string"?O:O.toJS(),attributionControl:!1,reuseMaps:!0,preserveDrawingBuffer:!0,cursor:p,children:[I.jsx(g9,{mapRef:a,dateRange:x}),I.jsx("div",{className:"absolute top-0 left-0",children:I.jsx(pv,{compact:!0,onDateSelect:P,mapRef:a,dateRange:x})}),I.jsx(b9,{dateRange:x,mapRef:a}),I.jsx("div",{className:"absolute bottom-4 right-20 flex flex-col gap-4 items-end",style:{zIndex:3},children:I.jsx(D9,{mapRef:a})}),I.jsx(Fz,{mapRef:a,dateRange:x})]}),I.jsx(Bje,{})]})})})})}):I.jsx(ma,{})}var dFe={},C8={};(function(e){function t(A){"@babel/helpers - typeof";return t=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(E){return typeof E}:function(E){return E&&typeof Symbol=="function"&&E.constructor===Symbol&&E!==Symbol.prototype?"symbol":typeof E},t(A)}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=a(R),r=["dispose","reject","resolve"];function i(A){if(typeof WeakMap!="function")return null;var E=new WeakMap,P=new WeakMap;return(i=function(T){return T?P:E})(A)}function a(A,E){if(A&&A.__esModule)return A;if(A===null||t(A)!=="object"&&typeof A!="function")return{default:A};var P=i(E);if(P&&P.has(A))return P.get(A);var O={},T=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var k in A)if(k!=="default"&&Object.prototype.hasOwnProperty.call(A,k)){var N=T?Object.getOwnPropertyDescriptor(A,k):null;N&&(N.get||N.set)?Object.defineProperty(O,k,N):O[k]=A[k]}return O.default=A,P&&P.set(A,O),O}function o(){return o=Object.assign||function(A){for(var E=1;E<arguments.length;E++){var P=arguments[E];for(var O in P)Object.prototype.hasOwnProperty.call(P,O)&&(A[O]=P[O])}return A},o.apply(this,arguments)}function s(A,E){return y(A)||p(A,E)||h(A,E)||u()}function u(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1299
+ `),o},U5e=e=>{if(!e||!Array.isArray(e))return null;const t={};return e.forEach(r=>{const i=new Date(r.x),a=i.getFullYear(),o=i.getMonth(),s=`${a}-${o}`;t[s]||(t[s]={year:a,month:o,points:[]}),t[s].points.push(r)}),Object.values(t).map(r=>{const i=r.points,a=i.reduce((s,u)=>s+(u.y||0),0),o=new Date(r.year,r.month+1,0);return{x:o.getTime(),y:a,year:r.year,month:r.month,pointCount:i.length,monthName:o.toLocaleDateString("en-US",{month:"short"})}}).sort((r,i)=>r.x-i.x)},H5e=async e=>{var n,r,i;const t=e.id||((n=e.options)==null?void 0:n.id)||((i=(r=e.options)==null?void 0:r.properties)==null?void 0:i.id);if(Ax.has(t))return Ax.get(t);try{const a=await rE({stationId:e==null?void 0:e.device,plotId:t});return Ax.set(t,a),a}catch(a){return console.error(`Error fetching task stats for plot ${t}:`,a),null}},X5e=async(e,t)=>{var r,i,a,o;const n=e.id||((r=e.options)==null?void 0:r.id)||((a=(i=e.options)==null?void 0:i.properties)==null?void 0:a.id);if(ag.has(n))return ag.get(n);try{const s=new Date().getFullYear(),u=new Date(s,0,1),h=new Date(s,11,31,23,59,59,999),m={...e,geometry:((o=e.options)==null?void 0:o.geometry)||e.geometry},p=t.map(O=>O instanceof Date?O:typeof O=="string"||typeof O=="number"?new Date(O):null).filter(O=>O instanceof Date&&!isNaN(O)&&O>=u&&O<=h);if(p.length===0){const O={data:[],etoData:[],monthlyAccumulatedData:[]};return ag.set(n,O),O}const y=p.map(O=>eP({plot:m},{startDate:O,endDate:O}).then(T=>{var k,N;return{data:((N=(k=T==null?void 0:T.features)==null?void 0:k[0])==null?void 0:N.properties)||T,date:(T==null?void 0:T.datetime)||O}}).catch(T=>(console.error(`Error fetching ET data for plot ${n}, date ${O}:`,T),null)));let b=[];if(e.device)try{b=await Kie(e.device,u,h)}catch(O){console.error(`Error fetching ETo data for plot ${n}:`,O)}const C=(await Promise.all(y)).filter(O=>O!==null).map(O=>({x:new Date(O.date).getTime(),y:O.data.avg,min:O.data.min,max:O.data.max,stddev:O.data.stddev})).filter(O=>O.y!==null&&O.y!==void 0&&!isNaN(O.y)&&O.min!==null&&O.min!==void 0&&!isNaN(O.min)&&O.max!==null&&O.max!==void 0&&!isNaN(O.max)),A=W5e(C,b||[]),E=U5e(A),P={data:A,etoData:b||[],monthlyAccumulatedData:E};return ag.set(n,P),P}catch(s){return console.error(`Error fetching ET data for plot ${n}:`,s),{data:null,etoData:[],monthlyAccumulatedData:null}}},Y5e=(e,t,n)=>{const[r,i]=R.useState(!1),a=R.useRef(new Set),o=Tt(m=>m.passDates),s=R.useCallback(()=>{if(!(e!=null&&e.current)||!t||t.length===0)return[];const m=e.current.getMap();if(!m)return[];const p=m.getBounds();return p?t.filter(y=>{var k;if(!((k=y==null?void 0:y.options)!=null&&k.geometry))return!1;const b=ms(y.options.geometry),[_,x,C,A]=b,[[E,P],[O,T]]=p.toArray();return!(_>O||C<E||x>T||A<P)}):[]},[t,e]),u=R.useCallback(async m=>{if(!m||m.length===0)return;const p=m.filter(y=>{var _,x,C;const b=y.id||((_=y.options)==null?void 0:_.id)||((C=(x=y.options)==null?void 0:x.properties)==null?void 0:C.id);return!Ax.has(b)});p.length!==0&&(console.log(`Prefetching task stats for ${p.length} plots`),await Promise.allSettled(p.map(y=>H5e(y))))},[]),h=R.useCallback(async()=>{if(n.value!=="ET"||!o||o.length===0)return;const m=s();if(m.length===0)return;u(m),i(!0);const p=m.filter(b=>{var x,C,A;const _=b.id||((x=b.options)==null?void 0:x.id)||((A=(C=b.options)==null?void 0:C.properties)==null?void 0:A.id);return!a.current.has(_)&&!ag.has(_)});if(p.length===0){i(!1);return}console.log(`Prefetching ET data for ${p.length} visible plots`),p.forEach(b=>{var x,C,A;const _=b.id||((x=b.options)==null?void 0:x.id)||((A=(C=b.options)==null?void 0:C.properties)==null?void 0:A.id);a.current.add(_)});const y=p.map(b=>X5e(b,o).finally(()=>{var x,C,A;const _=b.id||((x=b.options)==null?void 0:x.id)||((A=(C=b.options)==null?void 0:C.properties)==null?void 0:A.id);a.current.delete(_)}));await Promise.allSettled(y),i(!1)},[s,o,n.value,u]);return R.useEffect(()=>{n.value!=="ET"||!t||t.length===0||u(t)},[t,n.value,u]),R.useEffect(()=>{if(n.value!=="ET"||(h(),!(e!=null&&e.current)))return;const m=e.current.getMap();if(!m)return;let p;const y=()=>{clearTimeout(p),p=setTimeout(()=>{h()},500)};return m.on("moveend",y),m.on("zoomend",y),()=>{clearTimeout(p),m.off("moveend",y),m.off("zoomend",y)}},[e,h,n.value]),{prefetching:r}},Hh=new Map,k9=e=>{const t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}`},lT=(e,t)=>{var i,a,o;const n=e.id||((i=e.options)==null?void 0:i.id)||((o=(a=e.options)==null?void 0:a.properties)==null?void 0:o.id),r=k9(t);return`${n}_${r}`},Z5e=async(e,t,n)=>{var i;const r=lT(e,t);if(Hh.has(r))return Hh.get(r);try{const a=new Date(t),o=B1(a),s=R1(a),u=new Date(Date.UTC(o.getFullYear(),o.getMonth(),o.getDate(),0,0,0,0)),h=new Date(Date.UTC(s.getFullYear(),s.getMonth(),s.getDate(),23,59,59,999)),m=await n1({plot:e,accessToken:n,startDate:u.toISOString(),endDate:h.toISOString()});return Hh.set(r,m),m}catch(a){return console.error(`Error prefetching histogram data for plot ${e.id||((i=e.options)==null?void 0:i.id)}:`,a),null}},q5e=(e,t,n,r,i)=>{const[a,o]=R.useState(!1),s=R.useRef(new Set),u=R.useCallback(()=>{if(!(e!=null&&e.current)||!t||t.length===0)return[];const m=e.current.getMap();if(!m)return[];const p=m.getBounds();return p?t.filter(y=>{var k;if(!((k=y==null?void 0:y.options)!=null&&k.geometry))return!1;const b=ms(y.options.geometry),[_,x,C,A]=b,[[E,P],[O,T]]=p.toArray();return!(_>O||C<E||x>T||A<P)}):[]},[t,e]),h=R.useCallback(async()=>{if((n==null?void 0:n.value)==="ET"||!r||!(i!=null&&i.start))return;const m=u();if(m.length===0)return;o(!0);const p=i.start,y=k9(p),b=m.filter(C=>{var P,O,T;const E=`${C.id||((P=C.options)==null?void 0:P.id)||((T=(O=C.options)==null?void 0:O.properties)==null?void 0:T.id)}_${y}`;return!s.current.has(E)&&!Hh.has(E)});if(b.length===0){o(!1);return}console.log(`Prefetching histogram data for ${b.length} visible plots (month: ${y})`),b.forEach(C=>{var P,O,T;const E=`${C.id||((P=C.options)==null?void 0:P.id)||((T=(O=C.options)==null?void 0:O.properties)==null?void 0:T.id)}_${y}`;s.current.add(E)});const _=5,x=[];for(let C=0;C<b.length;C+=_){const E=b.slice(C,C+_).map(P=>Z5e(P,p,r).finally(()=>{var k,N,z;const T=`${P.id||((k=P.options)==null?void 0:k.id)||((z=(N=P.options)==null?void 0:N.properties)==null?void 0:z.id)}_${y}`;s.current.delete(T)}));x.push(...E),C+_<b.length&&await Promise.allSettled(E)}await Promise.allSettled(x),o(!1)},[u,r,i==null?void 0:i.start,n==null?void 0:n.value]);return R.useEffect(()=>{if((n==null?void 0:n.value)==="ET"||!r||!(i!=null&&i.start)||(h(),!(e!=null&&e.current)))return;const m=e.current.getMap();if(!m)return;let p;const y=()=>{clearTimeout(p),p=setTimeout(()=>{h()},500)};return m.on("moveend",y),m.on("zoomend",y),()=>{clearTimeout(p),m.off("moveend",y),m.off("zoomend",y)}},[e,h,n==null?void 0:n.value,r,i==null?void 0:i.start]),{prefetching:a}},J5e=(e,t)=>{if(!e||!t)return null;const n=lT(e,t);return Hh.get(n)||null},K5e=(e,t,n)=>{if(!e||!t||!n)return;const r=lT(e,t);Hh.set(r,n)};function D9({mapRef:e}){var E,P;const t=Dr(),{plots:n,setClickedPlot:r}=R.useContext(Zs),{accessToken:i}=R.useContext(Ym),a=Tt(O=>O.dateRange),o=Tt(O=>O.setPickerData),s=Tt(O=>O.setHoveredPlot),u=Tt(O=>O.rasterLayer),[h,m]=R.useState(null),[p,y]=R.useState(null),[b,_]=R.useState(!1);Y5e(e,n,u),q5e(e,n,u,i,a),R.useEffect(()=>{if(!(e!=null&&e.current)||!h)return;const O=e.current.getMap();if(!O)return;const T=`plot-highlight-${h.id}`,k=`plot-highlight-outline-${h.id}`,N=`plot-highlight-source-${h.id}`;return O.getLayer(T)&&O.removeLayer(T),O.getLayer(k)&&O.removeLayer(k),O.getSource(N)&&O.removeSource(N),O.addSource(N,{type:"geojson",data:h.options.geometry}),O.addLayer({id:k,type:"line",source:N,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#ffffff","line-width":4,"line-opacity":1}}),O.addLayer({id:T,type:"line",source:N,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#16a34a","line-width":6,"line-opacity":1}},k),()=>{O.getLayer(T)&&O.removeLayer(T),O.getLayer(k)&&O.removeLayer(k),O.getSource(N)&&O.removeSource(N)}},[h,e]),R.useEffect(()=>{if(!(e!=null&&e.current))return;const O=e.current.getMap();if(!O)return;const T=N=>{var q,H,V;const z=O.queryRenderedFeatures(N.point,{layers:["plots-layer"]});if(z.length>0){const U=z[0],G=((q=U.properties)==null?void 0:q.plot_id)||((H=U.properties)==null?void 0:H.plotId);let B=G?n.find($=>$.id===G):null;if(!B&&((V=U.properties)!=null&&V.id)&&(B=n.find($=>{var Y;return((Y=$.options)==null?void 0:Y.id)===U.properties.id})),B&&B!==h){m(B),s(B),r(null);const $=Tt.getState().pickerData;$!=null&&$.plot||o(null)}}else h&&(m(null),s(null))},k=()=>{m(null),s(null)};return O.on("mousemove",T),O.on("mouseleave",k),O.getCanvas().style.cursor="default",()=>{O.off("mousemove",T),O.off("mouseleave",k),O.getCanvas().style.cursor=""}},[n,e,h,r,o,s]);const x=R.useCallback(O=>new Date(O).toISOString().split("T")[0],[]),C=R.useCallback((O,T)=>{if(!O||O.length===0)return null;const k=x(T),N=O.find(V=>x(V.interval.from)===k);if(N)return N;const z=new Date(T).getTime();let q=null,H=1/0;return O.forEach(V=>{const U=new Date(V.interval.from).getTime(),G=Math.abs(U-z);G<H&&(H=G,q=V)}),q},[x]);R.useEffect(()=>{if(u.value==="ET"){y(null);return}if(!h||!i||!(a!=null&&a.start)){y(null);return}let O=!1;return(async()=>{var k,N;_(!0);try{const z=new Date(a.start),q=J5e(h,z);if(q){if(O)return;if(((k=q==null?void 0:q.data)==null?void 0:k.length)>0){const $=C(q.data,z);y($?[$]:null)}else y(null);_(!1);return}const H=B1(z),V=R1(z),U=new Date(Date.UTC(H.getFullYear(),H.getMonth(),H.getDate(),0,0,0,0)),G=new Date(Date.UTC(V.getFullYear(),V.getMonth(),V.getDate(),23,59,59,999)),B=await n1({plot:h,accessToken:i,startDate:U.toISOString(),endDate:G.toISOString()});if(O)return;if(B&&K5e(h,z,B),((N=B==null?void 0:B.data)==null?void 0:N.length)>0){const $=C(B.data,z);y($?[$]:null)}else y(null)}catch(z){console.error("Error fetching histogram data:",z),O||y(null)}finally{O||_(!1)}})(),()=>{O=!0}},[h,i,a==null?void 0:a.start,C,u.value]);const A=R.useMemo(()=>{var z,q,H,V,U;if(!(p!=null&&p.length))return null;const O=p[0],T=(V=(H=(q=(z=O==null?void 0:O.outputs)==null?void 0:z.index)==null?void 0:q.bands)==null?void 0:H.B0)==null?void 0:V.histogram;if(!(T!=null&&T.bins))return null;const{bins:k,counts:N}=T;return!N&&((U=k[0])==null?void 0:U.count)!==void 0?k.map(G=>({ndviRange:`${G.lowEdge.toFixed(2)} - ${G.highEdge.toFixed(2)}`,ndviValue:(G.lowEdge+G.highEdge)/2,count:G.count||0,lowEdge:G.lowEdge,highEdge:G.highEdge})):!Array.isArray(N)||N.length!==k.length?null:k.map((G,B)=>({ndviRange:`${G.lowEdge.toFixed(2)} - ${G.highEdge.toFixed(2)}`,ndviValue:(G.lowEdge+G.highEdge)/2,count:N[B]||0,lowEdge:G.lowEdge,highEdge:G.highEdge}))},[p]);return!h||u.value==="ET"?null:I.jsxs("div",{className:`bg-white dark:bg-zinc-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 ${u.value==="ET"?"w-[500px]":"w-[320px]"}`,children:[I.jsx("div",{className:"flex items-center justify-between px-3 py-2 border-b border-gray-200 dark:border-gray-700",children:I.jsxs("div",{className:"flex items-center gap-2",children:[I.jsx(sK,{className:"h-5 w-5 text-primary"}),I.jsxs("div",{children:[I.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:u.value==="ET"?t.formatMessage({id:"app.agviewer_map.et_monthly_graph",defaultMessage:"ET Monthly Graph"}):t.formatMessage({id:"app.agviewer_map.ndvi_histogram",defaultMessage:"NDVI Histogram"})}),h&&I.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:h.name||`Plot ${h.id}`}),!h&&I.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 italic",children:t.formatMessage({id:"app.agviewer_map.hover_plot_histogram",defaultMessage:"Hover over a plot to view its histogram"})})]})]})}),I.jsx("div",{className:"px-3 py-2",children:u.value==="ET"?null:b?I.jsx("div",{className:"flex items-center justify-center h-56",children:I.jsx(ma,{})}):I.jsx(G5e,{data:A})}),u.value!=="ET"&&A&&I.jsx("div",{className:"px-3 py-2 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-zinc-900/50",children:I.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[I.jsxs("div",{children:[I.jsxs("span",{className:"text-gray-600 dark:text-gray-400",children:[t.formatMessage({id:"app.agviewer_map.total_pixels",defaultMessage:"Total Pixels"}),":"]}),I.jsx("span",{className:"ml-2 font-semibold text-gray-900 dark:text-gray-100",children:A.reduce((O,T)=>O+T.count,0).toLocaleString()})]}),I.jsxs("div",{children:[I.jsxs("span",{className:"text-gray-600 dark:text-gray-400",children:[t.formatMessage({id:"app.agviewer_map.ndvi_range",defaultMessage:"NDVI Range"}),":"]}),I.jsxs("span",{className:"ml-2 font-semibold text-gray-900 dark:text-gray-100",children:[(E=A[0])==null?void 0:E.lowEdge.toFixed(2)," to"," ",(P=A[A.length-1])==null?void 0:P.highEdge.toFixed(2)]})]})]})}),u.value==="ET"&&h&&I.jsx("div",{className:"px-3 py-2 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-zinc-900/50",children:I.jsxs("div",{className:"text-xs text-gray-600 dark:text-gray-400",children:[I.jsxs("span",{className:"font-medium",children:[t.formatMessage({id:"app.agviewer_map.year",defaultMessage:"Year"}),":"]}),I.jsx("span",{className:"ml-2 font-semibold text-gray-900 dark:text-gray-100",children:new Date().getFullYear()})]})})]})}function Q5e({isSearchFocused:e,searchQuery:t,searchResults:n,onResultClick:r}){return e?I.jsx("div",{className:"absolute top-12 right-0 w-64 bg-white/90 backdrop-blur-xl rounded-md shadow-2xl border border-white/50 overflow-hidden pointer-events-auto animate-in fade-in zoom-in-95 duration-200 origin-top-right max-h-[400px] overflow-y-auto",children:I.jsx("div",{className:"p-2 space-y-1",children:t.trim()===""?I.jsxs(I.Fragment,{children:[I.jsx("div",{className:"px-2 py-1.5 text-[10px] font-bold text-muted-foreground uppercase tracking-wider",children:"Suggested"}),I.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:"Start typing to search farms, plots, and stations..."})]}):n.length===0?I.jsx("div",{className:"px-2 py-4 text-xs text-muted-foreground text-center",children:"No results found"}):I.jsxs(I.Fragment,{children:[I.jsxs("div",{className:"px-2 py-1.5 text-[10px] font-bold text-muted-foreground uppercase tracking-wider",children:["Results (",n.length,")"]}),n.map(i=>I.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-sm hover:bg-green-50/80 cursor-pointer transition-colors group",onClick:()=>r(i),children:[I.jsxs("div",{className:Rt("w-8 h-8 rounded-sm flex items-center justify-center shrink-0",i.type==="farm"&&"bg-green-100 text-green-600",i.type==="plot"&&"bg-blue-100 text-blue-600",i.type==="station"&&"bg-orange-100 text-orange-600"),children:[i.type==="farm"&&I.jsx(ow,{className:"h-4 w-4"}),i.type==="plot"&&I.jsx(xp,{className:"h-4 w-4"}),i.type==="station"&&I.jsx(Ry,{className:"h-4 w-4"})]}),I.jsxs("div",{className:"flex flex-col min-w-0",children:[I.jsx("span",{className:"text-sm font-medium truncate text-foreground group-hover:text-green-700",children:i.label}),I.jsx("span",{className:"text-xs text-muted-foreground truncate",children:i.subLabel})]})]},i.id))]})})}):null}function e4e(e,t,{checkForDefaultPrevented:n=!0}={}){return function(i){if(e==null||e(i),n===!1||!i.defaultPrevented)return t==null?void 0:t(i)}}function t4e(e){const t=ee.useRef({value:e,previous:e});return ee.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Ix="Switch",[n4e,a$e]=bo(Ix),[r4e,i4e]=n4e(Ix),N9=ee.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:u="on",onCheckedChange:h,form:m,...p}=e,[y,b]=ee.useState(null),_=zn(t,P=>b(P)),x=ee.useRef(!1),C=y?m||!!y.closest("form"):!0,[A,E]=tl({prop:i,defaultProp:a??!1,onChange:h,caller:Ix});return I.jsxs(r4e,{scope:n,checked:A,disabled:s,children:[I.jsx(Dn.button,{type:"button",role:"switch","aria-checked":A,"aria-required":o,"data-state":R9(A),"data-disabled":s?"":void 0,disabled:s,value:u,...p,ref:_,onClick:e4e(e.onClick,P=>{E(O=>!O),C&&(x.current=P.isPropagationStopped(),x.current||P.stopPropagation())})}),C&&I.jsx(F9,{control:y,bubbles:!x.current,name:r,value:u,checked:A,required:o,disabled:s,form:m,style:{transform:"translateX(-100%)"}})]})});N9.displayName=Ix;var L9="SwitchThumb",j9=ee.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,i=i4e(L9,n);return I.jsx(Dn.span,{"data-state":R9(i.checked),"data-disabled":i.disabled?"":void 0,...r,ref:t})});j9.displayName=L9;var a4e="SwitchBubbleInput",F9=ee.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},a)=>{const o=ee.useRef(null),s=zn(o,a),u=t4e(n),h=ev(t);return ee.useEffect(()=>{const m=o.current;if(!m)return;const p=window.HTMLInputElement.prototype,b=Object.getOwnPropertyDescriptor(p,"checked").set;if(u!==n&&b){const _=new Event("click",{bubbles:r});b.call(m,n),m.dispatchEvent(_)}},[u,n,r]),I.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:s,style:{...i.style,...h,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});F9.displayName=a4e;function R9(e){return e?"checked":"unchecked"}var B9=N9,s4e=j9;const cT=ee.forwardRef(({className:e,...t},n)=>I.jsx(B9,{className:Rt("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:I.jsx(s4e,{className:Rt("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));cT.displayName=B9.displayName;function Xh(e,t,{checkForDefaultPrevented:n=!0}={}){return function(i){if(e==null||e(i),n===!1||!i.defaultPrevented)return t==null?void 0:t(i)}}var o4e=ee.createContext(void 0);function l4e(e){const t=ee.useContext(o4e);return e||t||"ltr"}function c4e(e){const t=ee.useRef({value:e,previous:e});return ee.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var $9=["PageUp","PageDown"],z9=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],V9={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},Yh="Slider",[uT,u4e,d4e]=SE(Yh),[G9,s$e]=bo(Yh,[d4e]),[h4e,Px]=G9(Yh),W9=ee.forwardRef((e,t)=>{const{name:n,min:r=0,max:i=100,step:a=1,orientation:o="horizontal",disabled:s=!1,minStepsBetweenThumbs:u=0,defaultValue:h=[r],value:m,onValueChange:p=()=>{},onValueCommit:y=()=>{},inverted:b=!1,form:_,...x}=e,C=ee.useRef(new Set),A=ee.useRef(0),P=o==="horizontal"?f4e:p4e,[O=[],T]=tl({prop:m,defaultProp:h,onChange:V=>{var G;(G=[...C.current][A.current])==null||G.focus(),p(V)}}),k=ee.useRef(O);function N(V){const U=b4e(O,V);H(V,U)}function z(V){H(V,A.current)}function q(){const V=k.current[A.current];O[A.current]!==V&&y(O)}function H(V,U,{commit:G}={commit:!1}){const B=S4e(a),$=C4e(Math.round((V-r)/a)*a+r,B),Y=wx($,[r,i]);T((te=[])=>{const re=y4e(te,Y,U);if(w4e(re,u*a)){A.current=re.indexOf(Y);const ie=String(re)!==String(te);return ie&&G&&y(re),ie?re:te}else return te})}return I.jsx(h4e,{scope:e.__scopeSlider,name:n,disabled:s,min:r,max:i,valueIndexToChangeRef:A,thumbs:C.current,values:O,orientation:o,form:_,children:I.jsx(uT.Provider,{scope:e.__scopeSlider,children:I.jsx(uT.Slot,{scope:e.__scopeSlider,children:I.jsx(P,{"aria-disabled":s,"data-disabled":s?"":void 0,...x,ref:t,onPointerDown:Xh(x.onPointerDown,()=>{s||(k.current=O)}),min:r,max:i,inverted:b,onSlideStart:s?void 0:N,onSlideMove:s?void 0:z,onSlideEnd:s?void 0:q,onHomeKeyDown:()=>!s&&H(r,0,{commit:!0}),onEndKeyDown:()=>!s&&H(i,O.length-1,{commit:!0}),onStepKeyDown:({event:V,direction:U})=>{if(!s){const $=$9.includes(V.key)||V.shiftKey&&z9.includes(V.key)?10:1,Y=A.current,te=O[Y],re=a*$*U;H(te+re,Y,{commit:!0})}}})})})})});W9.displayName=Yh;var[U9,H9]=G9(Yh,{startEdge:"left",endEdge:"right",size:"width",direction:1}),f4e=ee.forwardRef((e,t)=>{const{min:n,max:r,dir:i,inverted:a,onSlideStart:o,onSlideMove:s,onSlideEnd:u,onStepKeyDown:h,...m}=e,[p,y]=ee.useState(null),b=zn(t,P=>y(P)),_=ee.useRef(void 0),x=l4e(i),C=x==="ltr",A=C&&!a||!C&&a;function E(P){const O=_.current||p.getBoundingClientRect(),T=[0,O.width],N=fT(T,A?[n,r]:[r,n]);return _.current=O,N(P-O.left)}return I.jsx(U9,{scope:e.__scopeSlider,startEdge:A?"left":"right",endEdge:A?"right":"left",direction:A?1:-1,size:"width",children:I.jsx(X9,{dir:x,"data-orientation":"horizontal",...m,ref:b,style:{...m.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:P=>{const O=E(P.clientX);o==null||o(O)},onSlideMove:P=>{const O=E(P.clientX);s==null||s(O)},onSlideEnd:()=>{_.current=void 0,u==null||u()},onStepKeyDown:P=>{const T=V9[A?"from-left":"from-right"].includes(P.key);h==null||h({event:P,direction:T?-1:1})}})})}),p4e=ee.forwardRef((e,t)=>{const{min:n,max:r,inverted:i,onSlideStart:a,onSlideMove:o,onSlideEnd:s,onStepKeyDown:u,...h}=e,m=ee.useRef(null),p=zn(t,m),y=ee.useRef(void 0),b=!i;function _(x){const C=y.current||m.current.getBoundingClientRect(),A=[0,C.height],P=fT(A,b?[r,n]:[n,r]);return y.current=C,P(x-C.top)}return I.jsx(U9,{scope:e.__scopeSlider,startEdge:b?"bottom":"top",endEdge:b?"top":"bottom",size:"height",direction:b?1:-1,children:I.jsx(X9,{"data-orientation":"vertical",...h,ref:p,style:{...h.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:x=>{const C=_(x.clientY);a==null||a(C)},onSlideMove:x=>{const C=_(x.clientY);o==null||o(C)},onSlideEnd:()=>{y.current=void 0,s==null||s()},onStepKeyDown:x=>{const A=V9[b?"from-bottom":"from-top"].includes(x.key);u==null||u({event:x,direction:A?-1:1})}})})}),X9=ee.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:i,onSlideEnd:a,onHomeKeyDown:o,onEndKeyDown:s,onStepKeyDown:u,...h}=e,m=Px(Yh,n);return I.jsx(Dn.span,{...h,ref:t,onKeyDown:Xh(e.onKeyDown,p=>{p.key==="Home"?(o(p),p.preventDefault()):p.key==="End"?(s(p),p.preventDefault()):$9.concat(z9).includes(p.key)&&(u(p),p.preventDefault())}),onPointerDown:Xh(e.onPointerDown,p=>{const y=p.target;y.setPointerCapture(p.pointerId),p.preventDefault(),m.thumbs.has(y)?y.focus():r(p)}),onPointerMove:Xh(e.onPointerMove,p=>{p.target.hasPointerCapture(p.pointerId)&&i(p)}),onPointerUp:Xh(e.onPointerUp,p=>{const y=p.target;y.hasPointerCapture(p.pointerId)&&(y.releasePointerCapture(p.pointerId),a(p))})})}),Y9="SliderTrack",Z9=ee.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,i=Px(Y9,n);return I.jsx(Dn.span,{"data-disabled":i.disabled?"":void 0,"data-orientation":i.orientation,...r,ref:t})});Z9.displayName=Y9;var dT="SliderRange",q9=ee.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,i=Px(dT,n),a=H9(dT,n),o=ee.useRef(null),s=zn(t,o),u=i.values.length,h=i.values.map(y=>Q9(y,i.min,i.max)),m=u>1?Math.min(...h):0,p=100-Math.max(...h);return I.jsx(Dn.span,{"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,...r,ref:s,style:{...e.style,[a.startEdge]:m+"%",[a.endEdge]:p+"%"}})});q9.displayName=dT;var hT="SliderThumb",J9=ee.forwardRef((e,t)=>{const n=u4e(e.__scopeSlider),[r,i]=ee.useState(null),a=zn(t,s=>i(s)),o=ee.useMemo(()=>r?n().findIndex(s=>s.ref.current===r):-1,[n,r]);return I.jsx(m4e,{...e,ref:a,index:o})}),m4e=ee.forwardRef((e,t)=>{const{__scopeSlider:n,index:r,name:i,...a}=e,o=Px(hT,n),s=H9(hT,n),[u,h]=ee.useState(null),m=zn(t,E=>h(E)),p=u?o.form||!!u.closest("form"):!0,y=ev(u),b=o.values[r],_=b===void 0?0:Q9(b,o.min,o.max),x=v4e(r,o.values.length),C=y==null?void 0:y[s.size],A=C?x4e(C,_,s.direction):0;return ee.useEffect(()=>{if(u)return o.thumbs.add(u),()=>{o.thumbs.delete(u)}},[u,o.thumbs]),I.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[s.startEdge]:`calc(${_}% + ${A}px)`},children:[I.jsx(uT.ItemSlot,{scope:e.__scopeSlider,children:I.jsx(Dn.span,{role:"slider","aria-label":e["aria-label"]||x,"aria-valuemin":o.min,"aria-valuenow":b,"aria-valuemax":o.max,"aria-orientation":o.orientation,"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,tabIndex:o.disabled?void 0:0,...a,ref:m,style:b===void 0?{display:"none"}:e.style,onFocus:Xh(e.onFocus,()=>{o.valueIndexToChangeRef.current=r})})}),p&&I.jsx(K9,{name:i??(o.name?o.name+(o.values.length>1?"[]":""):void 0),form:o.form,value:b},r)]})});J9.displayName=hT;var g4e="RadioBubbleInput",K9=ee.forwardRef(({__scopeSlider:e,value:t,...n},r)=>{const i=ee.useRef(null),a=zn(i,r),o=c4e(t);return ee.useEffect(()=>{const s=i.current;if(!s)return;const u=window.HTMLInputElement.prototype,m=Object.getOwnPropertyDescriptor(u,"value").set;if(o!==t&&m){const p=new Event("input",{bubbles:!0});m.call(s,t),s.dispatchEvent(p)}},[o,t]),I.jsx(Dn.input,{style:{display:"none"},...n,ref:a,defaultValue:t})});K9.displayName=g4e;function y4e(e=[],t,n){const r=[...e];return r[n]=t,r.sort((i,a)=>i-a)}function Q9(e,t,n){const a=100/(n-t)*(e-t);return wx(a,[0,100])}function v4e(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function b4e(e,t){if(e.length===1)return 0;const n=e.map(i=>Math.abs(i-t)),r=Math.min(...n);return n.indexOf(r)}function x4e(e,t,n){const r=e/2,a=fT([0,50],[0,r]);return(r-a(t)*n)*n}function _4e(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function w4e(e,t){if(t>0){const n=_4e(e);return Math.min(...n)>=t}return!0}function fT(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function S4e(e){return(String(e).split(".")[1]||"").length}function C4e(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}var e8=W9,M4e=Z9,E4e=q9,T4e=J9;const t8=ee.forwardRef(({className:e,...t},n)=>I.jsxs(e8,{ref:n,className:Rt("relative flex w-full touch-none select-none items-center",e),...t,children:[I.jsx(M4e,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:I.jsx(E4e,{className:"absolute h-full bg-primary"})}),I.jsx(T4e,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"})]}));t8.displayName=e8.displayName;function pT(e,t,{checkForDefaultPrevented:n=!0}={}){return function(i){if(e==null||e(i),n===!1||!i.defaultPrevented)return t==null?void 0:t(i)}}function n8(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function r8(...e){return t=>{let n=!1;const r=e.map(i=>{const a=n8(i,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let i=0;i<r.length;i++){const a=r[i];typeof a=="function"?a():n8(e[i],null)}}}}function mT(...e){return ee.useCallback(r8(...e),e)}function i8(e,t=[]){let n=[];function r(a,o){const s=ee.createContext(o),u=n.length;n=[...n,o];const h=p=>{var A;const{scope:y,children:b,..._}=p,x=((A=y==null?void 0:y[e])==null?void 0:A[u])||s,C=ee.useMemo(()=>_,Object.values(_));return I.jsx(x.Provider,{value:C,children:b})};h.displayName=a+"Provider";function m(p,y){var x;const b=((x=y==null?void 0:y[e])==null?void 0:x[u])||s,_=ee.useContext(b);if(_)return _;if(o!==void 0)return o;throw new Error(`\`${p}\` must be used within \`${a}\``)}return[h,m]}const i=()=>{const a=n.map(o=>ee.createContext(o));return function(s){const u=(s==null?void 0:s[e])||a;return ee.useMemo(()=>({[`__scope${e}`]:{...s,[e]:u}}),[s,u])}};return i.scopeName=e,[r,A4e(i,...t)]}function A4e(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(a){const o=r.reduce((s,{useScope:u,scopeName:h})=>{const p=u(a)[`__scope${h}`];return{...s,...p}},{});return ee.useMemo(()=>({[`__scope${t.scopeName}`]:o}),[o])}};return n.scopeName=t.scopeName,n}var a8=ee.forwardRef((e,t)=>{const{children:n,...r}=e,i=ee.Children.toArray(n),a=i.find(P4e);if(a){const o=a.props.children,s=i.map(u=>u===a?ee.Children.count(o)>1?ee.Children.only(null):ee.isValidElement(o)?o.props.children:null:u);return I.jsx(gT,{...r,ref:t,children:ee.isValidElement(o)?ee.cloneElement(o,void 0,s):null})}return I.jsx(gT,{...r,ref:t,children:n})});a8.displayName="Slot";var gT=ee.forwardRef((e,t)=>{const{children:n,...r}=e;if(ee.isValidElement(n)){const i=k4e(n);return ee.cloneElement(n,{...O4e(r,n.props),ref:t?r8(t,i):i})}return ee.Children.count(n)>1?ee.Children.only(null):null});gT.displayName="SlotClone";var I4e=({children:e})=>I.jsx(I.Fragment,{children:e});function P4e(e){return ee.isValidElement(e)&&e.type===I4e}function O4e(e,t){const n={...t};for(const r in t){const i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...s)=>{a(...s),i(...s)}:i&&(n[r]=i):r==="style"?n[r]={...i,...a}:r==="className"&&(n[r]=[i,a].filter(Boolean).join(" "))}return{...e,...n}}function k4e(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var D4e=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],yT=D4e.reduce((e,t)=>{const n=ee.forwardRef((r,i)=>{const{asChild:a,...o}=r,s=a?a8:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),I.jsx(s,{...o,ref:i})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function s8(e){const t=ee.useRef(e);return ee.useEffect(()=>{t.current=e}),ee.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function N4e({prop:e,defaultProp:t,onChange:n=()=>{}}){const[r,i]=L4e({defaultProp:t,onChange:n}),a=e!==void 0,o=a?e:r,s=s8(n),u=ee.useCallback(h=>{if(a){const p=typeof h=="function"?h(e):h;p!==e&&s(p)}else i(h)},[a,e,i,s]);return[o,u]}function L4e({defaultProp:e,onChange:t}){const n=ee.useState(e),[r]=n,i=ee.useRef(r),a=s8(t);return ee.useEffect(()=>{i.current!==r&&(a(r),i.current=r)},[r,i,a]),n}var j4e=ee.createContext(void 0);function F4e(e){const t=ee.useContext(j4e);return e||t||"ltr"}var vT=globalThis!=null&&globalThis.document?ee.useLayoutEffect:()=>{};function R4e(e){const[t,n]=ee.useState(void 0);return vT(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const a=i[0];let o,s;if("borderBoxSize"in a){const u=a.borderBoxSize,h=Array.isArray(u)?u[0]:u;o=h.inlineSize,s=h.blockSize}else o=e.offsetWidth,s=e.offsetHeight;n({width:o,height:s})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}function B4e(e){const t=ee.useRef({value:e,previous:e});return ee.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}function $4e(e,t){return ee.useReducer((n,r)=>t[n][r]??n,e)}var o8=e=>{const{present:t,children:n}=e,r=z4e(t),i=typeof n=="function"?n({present:r.isPresent}):ee.Children.only(n),a=mT(r.ref,V4e(i));return typeof n=="function"||r.isPresent?ee.cloneElement(i,{ref:a}):null};o8.displayName="Presence";function z4e(e){const[t,n]=ee.useState(),r=ee.useRef({}),i=ee.useRef(e),a=ee.useRef("none"),o=e?"mounted":"unmounted",[s,u]=$4e(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return ee.useEffect(()=>{const h=Ox(r.current);a.current=s==="mounted"?h:"none"},[s]),vT(()=>{const h=r.current,m=i.current;if(m!==e){const y=a.current,b=Ox(h);e?u("MOUNT"):b==="none"||(h==null?void 0:h.display)==="none"?u("UNMOUNT"):u(m&&y!==b?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,u]),vT(()=>{if(t){let h;const m=t.ownerDocument.defaultView??window,p=b=>{const x=Ox(r.current).includes(b.animationName);if(b.target===t&&x&&(u("ANIMATION_END"),!i.current)){const C=t.style.animationFillMode;t.style.animationFillMode="forwards",h=m.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=C)})}},y=b=>{b.target===t&&(a.current=Ox(r.current))};return t.addEventListener("animationstart",y),t.addEventListener("animationcancel",p),t.addEventListener("animationend",p),()=>{m.clearTimeout(h),t.removeEventListener("animationstart",y),t.removeEventListener("animationcancel",p),t.removeEventListener("animationend",p)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:ee.useCallback(h=>{h&&(r.current=getComputedStyle(h)),n(h)},[])}}function Ox(e){return(e==null?void 0:e.animationName)||"none"}function V4e(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var bT="Radio",[G4e,l8]=i8(bT),[W4e,U4e]=G4e(bT),c8=ee.forwardRef((e,t)=>{const{__scopeRadio:n,name:r,checked:i=!1,required:a,disabled:o,value:s="on",onCheck:u,form:h,...m}=e,[p,y]=ee.useState(null),b=mT(t,C=>y(C)),_=ee.useRef(!1),x=p?h||!!p.closest("form"):!0;return I.jsxs(W4e,{scope:n,checked:i,disabled:o,children:[I.jsx(yT.button,{type:"button",role:"radio","aria-checked":i,"data-state":h8(i),"data-disabled":o?"":void 0,disabled:o,value:s,...m,ref:b,onClick:pT(e.onClick,C=>{i||u==null||u(),x&&(_.current=C.isPropagationStopped(),_.current||C.stopPropagation())})}),x&&I.jsx(H4e,{control:p,bubbles:!_.current,name:r,value:s,checked:i,required:a,disabled:o,form:h,style:{transform:"translateX(-100%)"}})]})});c8.displayName=bT;var u8="RadioIndicator",d8=ee.forwardRef((e,t)=>{const{__scopeRadio:n,forceMount:r,...i}=e,a=U4e(u8,n);return I.jsx(o8,{present:r||a.checked,children:I.jsx(yT.span,{"data-state":h8(a.checked),"data-disabled":a.disabled?"":void 0,...i,ref:t})})});d8.displayName=u8;var H4e=e=>{const{control:t,checked:n,bubbles:r=!0,...i}=e,a=ee.useRef(null),o=B4e(n),s=R4e(t);return ee.useEffect(()=>{const u=a.current,h=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(h,"checked").set;if(o!==n&&p){const y=new Event("click",{bubbles:r});p.call(u,n),u.dispatchEvent(y)}},[o,n,r]),I.jsx("input",{type:"radio","aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:a,style:{...e.style,...s,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function h8(e){return e?"checked":"unchecked"}var X4e=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],xT="RadioGroup",[Y4e,o$e]=i8(xT,[Kb,l8]),f8=Kb(),p8=l8(),[Z4e,q4e]=Y4e(xT),m8=ee.forwardRef((e,t)=>{const{__scopeRadioGroup:n,name:r,defaultValue:i,value:a,required:o=!1,disabled:s=!1,orientation:u,dir:h,loop:m=!0,onValueChange:p,...y}=e,b=f8(n),_=F4e(h),[x,C]=N4e({prop:a,defaultProp:i,onChange:p});return I.jsx(Z4e,{scope:n,name:r,required:o,disabled:s,value:x,onValueChange:C,children:I.jsx(q$,{asChild:!0,...b,orientation:u,dir:_,loop:m,children:I.jsx(yT.div,{role:"radiogroup","aria-required":o,"aria-orientation":u,"data-disabled":s?"":void 0,dir:_,...y,ref:t})})})});m8.displayName=xT;var g8="RadioGroupItem",y8=ee.forwardRef((e,t)=>{const{__scopeRadioGroup:n,disabled:r,...i}=e,a=q4e(g8,n),o=a.disabled||r,s=f8(n),u=p8(n),h=ee.useRef(null),m=mT(t,h),p=a.value===i.value,y=ee.useRef(!1);return ee.useEffect(()=>{const b=x=>{X4e.includes(x.key)&&(y.current=!0)},_=()=>y.current=!1;return document.addEventListener("keydown",b),document.addEventListener("keyup",_),()=>{document.removeEventListener("keydown",b),document.removeEventListener("keyup",_)}},[]),I.jsx(J$,{asChild:!0,...s,focusable:!o,active:p,children:I.jsx(c8,{disabled:o,required:a.required,checked:p,...u,...i,name:a.name,ref:m,onCheck:()=>a.onValueChange(i.value),onKeyDown:pT(b=>{b.key==="Enter"&&b.preventDefault()}),onFocus:pT(i.onFocus,()=>{var b;y.current&&((b=h.current)==null||b.click())})})})});y8.displayName=g8;var J4e="RadioGroupIndicator",v8=ee.forwardRef((e,t)=>{const{__scopeRadioGroup:n,...r}=e,i=p8(n);return I.jsx(d8,{...i,...r,ref:t})});v8.displayName=J4e;var b8=m8,x8=y8,K4e=v8;const kx=ee.forwardRef(({className:e,...t},n)=>I.jsx(b8,{className:sc("grid gap-2",e),...t,ref:n}));kx.displayName=b8.displayName;const sg=ee.forwardRef(({className:e,...t},n)=>I.jsx(x8,{ref:n,className:sc("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:I.jsx(K4e,{className:"flex items-center justify-center",children:I.jsx(lK,{className:"h-2.5 w-2.5 fill-current text-current"})})}));sg.displayName=x8.displayName;function Q4e({activePanel:e,togglePanel:t,viewType:n,setViewType:r,dataSource:i,setDataSource:a,layerOptions:o=[],layerOpacity:s=[100],setLayerOpacity:u,layerEnabled:h=!0,setLayerEnabled:m}){return I.jsx("div",{className:Rt("absolute top-20 left-1/2 -translate-x-1/2 z-20 w-80 transition-all duration-300 origin-top pointer-events-none",e==="layers"?"opacity-100 translate-y-0 pointer-events-auto":"opacity-0 -translate-y-10 pointer-events-none"),children:I.jsxs("div",{className:"bg-white/90 backdrop-blur-xl rounded-2xl shadow-2xl overflow-hidden flex flex-col max-h-[80vh] border border-white/50",children:[I.jsxs("div",{className:"p-4 border-b border-border flex justify-between items-center bg-white/50",children:[I.jsxs("div",{children:[I.jsx("h2",{className:"font-bold text-foreground",children:"Raster Layers"}),I.jsx("p",{className:"text-xs text-muted-foreground",children:"Manage map overlays"})]}),I.jsxs("div",{className:"flex items-center gap-3",children:[I.jsx(cT,{checked:h,onCheckedChange:m}),I.jsx(ln,{variant:"ghost",size:"icon",className:"h-8 w-8 rounded-full",onClick:()=>t(null),children:I.jsx(pa,{className:"h-5 w-5"})})]})]}),I.jsxs("div",{className:"p-4 space-y-5 overflow-y-auto",children:[I.jsxs("div",{className:"space-y-3",children:[I.jsx(Vs,{className:"text-xs font-bold text-muted-foreground uppercase tracking-wider",children:"Layer Options"}),I.jsxs("div",{children:[I.jsx(Vs,{className:"text-xs font-bold text-muted-foreground uppercase mb-2 block",children:"View Type"}),I.jsxs(kx,{value:n,onValueChange:r,className:"grid grid-cols-2 gap-2",children:[I.jsxs(Vs,{htmlFor:"view-plot",className:Rt("flex flex-col items-center p-3 border-2 rounded-lg cursor-pointer transition-all",n==="plot"?"border-green-500 bg-green-50/50 text-green-600":"border-border hover:border-green-500/50"),children:[I.jsx(sg,{value:"plot",id:"view-plot",className:"sr-only"}),I.jsx(xp,{className:"h-6 w-6 mb-1"}),I.jsx("span",{className:"text-xs font-medium",children:"Plot View"})]}),I.jsxs(Vs,{htmlFor:"view-map",className:Rt("flex flex-col items-center p-3 border-2 rounded-lg cursor-pointer transition-all",n==="map"?"border-green-500 bg-green-50/50 text-green-600":"border-border hover:border-green-500/50"),children:[I.jsx(sg,{value:"map",id:"view-map",className:"sr-only"}),I.jsx(dK,{className:"h-6 w-6 mb-1"}),I.jsx("span",{className:"text-xs font-medium",children:"Map View"})]})]})]})]}),I.jsxs("div",{className:"space-y-2",children:[I.jsx(Vs,{className:"text-xs font-bold text-muted-foreground uppercase tracking-wider",children:"Data Source"}),I.jsx("div",{className:"border rounded-md overflow-hidden",children:I.jsx("div",{className:"max-h-[150px] overflow-y-auto",children:o.length===0?I.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"No data source available."}):I.jsx("div",{className:"p-1",children:o.map(p=>I.jsxs("div",{onClick:()=>a(p),className:Rt("relative flex w-full cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none hover:bg-accent hover:text-accent-foreground",(i==null?void 0:i.value)===p.value&&"bg-accent text-accent-foreground"),children:[I.jsx(lw,{className:Rt("mr-2 h-4 w-4",(i==null?void 0:i.value)===p.value?"opacity-100":"opacity-0")}),I.jsx("span",{children:p.label})]},p.value))})})})]}),I.jsxs("div",{className:"space-y-3 pt-2",children:[I.jsxs("div",{className:"flex justify-between items-center text-xs font-medium text-muted-foreground",children:[I.jsx("span",{children:"Opacity"}),I.jsxs("span",{children:[s[0],"%"]})]}),I.jsx(t8,{value:s,onValueChange:u,max:100,step:1})]})]})]})})}function eFe({error:e,errorInfo:t,onReset:n}){return I.jsxs("div",{children:[I.jsx("h2",{children:"Something went wrong!"}),I.jsx("p",{children:e==null?void 0:e.message}),I.jsx("details",{children:t==null?void 0:t.componentStack}),I.jsx(Fp,{onClick:n,children:"Try Again"})]})}class _8 extends R.Component{constructor(n){super(n);mG(this,"handleReset",()=>{this.setState({hasError:!1,error:null,errorInfo:null}),this.props.onReset&&this.props.onReset()});this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(n){return{hasError:!0,error:n}}componentDidCatch(n,r){this.setState({error:n,errorInfo:r}),console.error("Error caught by ErrorBoundary:",n,r)}render(){const{hasError:n,error:r,errorInfo:i}=this.state,a=this.props.ErrorFallback||eFe;return n?I.jsx(a,{error:r,errorInfo:i,onReset:this.handleReset}):this.props.children}}const tFe=({width:e=24,height:t=24,fill:n="#000"})=>I.jsxs("svg",{width:e,height:t,viewBox:"0 0 32 32",xmlns:"http://www.w3.org/2000/svg",fill:n,children:[I.jsx("path",{d:"M17,28V17h1a2.0023,2.0023,0,0,0,2-2V11a2.0023,2.0023,0,0,0-2-2H14a2.0023,2.0023,0,0,0-2,2v4a2.0023,2.0023,0,0,0,2,2h1V28H2v2H30V28ZM14,11h4l.0015,4H14Z"}),I.jsx("path",{d:"M9.3325,18.2168a7.0007,7.0007,0,0,1,0-10.4341l1.334,1.49a5,5,0,0,0,0,7.4537Z"}),I.jsx("path",{d:"M22.667,18.2168l-1.334-1.49a4.9995,4.9995,0,0,0,0-7.4537l1.334-1.49a7,7,0,0,1,0,10.4341Z"}),I.jsx("path",{d:"M6.3994,21.8008a11.0019,11.0019,0,0,1,0-17.6006L7.6,5.8a9.0009,9.0009,0,0,0,0,14.4014Z"}),I.jsx("path",{d:"M25.6006,21.8008l-1.2012-1.6a9.001,9.001,0,0,0,0-14.4019l1.2012-1.6a11.002,11.002,0,0,1,0,17.6011Z"})]}),nFe=R.lazy(()=>Promise.resolve().then(()=>WFe));function rFe({activePanel:e,togglePanel:t,markerType:n,setMarkerType:r,pawStatus:i,setPawStatus:a,markerTypeOptions:o=[],pawStatusOptions:s=[],showMarkers:u=!0,setShowMarkers:h,formatLabel:m}){const{mapRef:p}=R.useContext(ha),y=Dr(),[b,_]=R.useState(!1),{markers:x,loading:C,handleDeleteMarker:A}=R.useContext(Za),{isConfirmed:E}=Yv(),P=R.useCallback((k,N)=>{if(!(p!=null&&p.current)||!N)return;const{lat:z,lng:q}=N.location;p.current.flyTo({center:[q,z],zoom:14})},[p]),O=R.useCallback(async(k,N)=>{!N||!await E(y.formatMessage({id:"app.agviewer_map.delete_marker_confirm_message",defaultMessage:"Do you want to delete this marker?"}))||A(N.id)},[E,A,y]),T=R.useCallback(()=>{_(k=>!k)},[]);return I.jsx("div",{className:Rt("absolute top-20 left-1/2 -translate-x-1/2 z-20 w-80 transition-all duration-300 origin-top pointer-events-none",e==="stations"?"opacity-100 translate-y-0 pointer-events-auto":"opacity-0 -translate-y-10 pointer-events-none"),children:I.jsxs("div",{className:"bg-white/90 backdrop-blur-xl rounded-2xl shadow-2xl overflow-hidden flex flex-col max-h-[80vh] border border-white/50",children:[I.jsxs("div",{className:"p-4 border-b border-border flex justify-between items-center bg-white/50",children:[I.jsxs("div",{children:[I.jsx("h2",{className:"font-bold text-foreground",children:"Stations"}),I.jsx("p",{className:"text-xs text-muted-foreground",children:"Filter and manage markers"})]}),I.jsxs("div",{className:"flex items-center gap-3",children:[I.jsx(cT,{checked:u,onCheckedChange:h}),I.jsx(ln,{variant:"ghost",size:"icon",className:"h-8 w-8 rounded-full",onClick:()=>t(null),children:I.jsx(pa,{className:"h-5 w-5"})})]})]}),I.jsxs("div",{className:"p-4 space-y-4 overflow-y-auto",children:[I.jsxs("div",{children:[I.jsx(Vs,{className:"text-xs font-bold text-muted-foreground uppercase mb-2 block",children:"Marker Type"}),I.jsx(kx,{value:n||"",onValueChange:r,className:"grid grid-cols-3 gap-2",children:o.map(k=>I.jsxs(Vs,{htmlFor:`type-${k.value}`,className:Rt("flex items-center justify-center py-2 px-3 text-xs font-medium rounded-lg border-2 cursor-pointer transition-all",(n||"")===k.value?"border-green-500 bg-green-50/50 text-green-600":"border-border hover:border-green-500/50"),children:[I.jsx(sg,{value:k.value,id:`type-${k.value}`,className:"sr-only"}),k.label]},k.value))})]}),I.jsxs("div",{children:[I.jsx(Vs,{className:"text-xs font-bold text-muted-foreground uppercase mb-2 block",children:"PAW Status"}),I.jsx(kx,{value:i||"",onValueChange:a,className:"grid grid-cols-4 gap-2",children:s.map(k=>I.jsxs(Vs,{htmlFor:`paw-${k.value}`,className:Rt("flex items-center justify-center py-2 px-2 text-xs font-medium rounded-lg border-2 cursor-pointer transition-all",(i||"")===k.value?"border-green-500 bg-green-50/50 text-green-600":"border-border hover:border-green-500/50"),children:[I.jsx(sg,{value:k.value,id:`paw-${k.value}`,className:"sr-only"}),k.label]},k.value))})]}),I.jsx(_8,{children:I.jsx(rl,{open:b,setOpen:_,titleWithIcon:I.jsxs(I.Fragment,{children:[I.jsx(tFe,{}),I.jsx("span",{children:y.formatMessage({id:"app.agviewer_map.stations",defaultMessage:"Stations"})})]}),trigger:I.jsxs(ln,{variant:"outline",className:"w-full border-2 border-dashed hover:border-green-500 hover:text-green-600 hover:bg-green-50",onClick:()=>{_(!0),t(null)},children:[I.jsx(By,{className:"h-4 w-4 mr-2"}),"Find Specific Station"]}),onClose:T,children:I.jsx(lu,{className:"border-none shadow-md",children:I.jsx(R.Suspense,{fallback:I.jsx("div",{className:"flex justify-center items-center h-40",children:I.jsx(ma,{})}),children:I.jsx(nFe,{markersData:x,loading:C,handleDeleteMarker:O,onMarkerClick:P,onClose:T,intl:y})})})})})]})]})})}const _T=Np,iFe=Lp,w8=ee.forwardRef(({className:e,...t},n)=>I.jsx(su,{ref:n,className:Rt("fixed inset-0 z-50 bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));w8.displayName=su.displayName;const Dx=ee.forwardRef(({className:e,children:t,showCloseButton:n=!0,...r},i)=>I.jsxs(iFe,{children:[I.jsx(w8,{}),I.jsxs(ou,{ref:i,className:Rt("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...r,children:[t,n&&I.jsxs(jp,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[I.jsx(pa,{className:"h-4 w-4"}),I.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Dx.displayName=ou.displayName;const Nx=({className:e,...t})=>I.jsx("div",{className:Rt("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Nx.displayName="DialogHeader";const Lx=({className:e,...t})=>I.jsx("div",{className:Rt("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Lx.displayName="DialogFooter";const jx=ee.forwardRef(({className:e,...t},n)=>I.jsx(So,{ref:n,className:Rt("text-lg font-semibold leading-none tracking-tight",e),...t}));jx.displayName=So.displayName;const Fx=ee.forwardRef(({className:e,...t},n)=>I.jsx(ac,{ref:n,className:Rt("text-sm text-muted-foreground",e),...t}));Fx.displayName=ac.displayName;function aFe({activePanel:e,togglePanel:t,farms:n=[],plots:r=[],markers:i=[],formatLabel:a,onAddFarm:o,onAddPlot:s,onAddStation:u,onFarmsChange:h}){var Ct,Ft,Lt,St;const{markers:m=[],loading:p}=R.useContext(Za)||{},[y,b]=R.useState(!1),[_,x]=R.useState(!1),[C,A]=R.useState(null),[E,P]=R.useState(!1),[O,T]=R.useState(!1),[k,N]=R.useState(!1),[z,q]=R.useState({name:"",marker_set:[],season_start_date:""}),[H,V]=R.useState(!1),[U,G]=R.useState(!1),[B,$]=R.useState(null),[Y,te]=R.useState(!1),[re,ie]=R.useState(!1),[J,fe]=R.useState(!1),[ge,ue]=R.useState({name:"",area:""}),[ve,Ce]=R.useState(!1),[Te,Ee]=R.useState(!1),[ae,ne]=R.useState(null),[he,_e]=R.useState(!1),[Z,se]=R.useState(!1),[le,ye]=R.useState(!1),[de,De]=R.useState({location_name:""}),Oe=R.useMemo(()=>m.map(qe=>({value:qe.id,label:(qe==null?void 0:qe.name)||(qe==null?void 0:qe.title)||(qe==null?void 0:qe.label)||`Marker ${(qe==null?void 0:qe.id)||""}`})),[m]),Me=R.useCallback(()=>{q({name:"",marker_set:[],season_start_date:""}),A(null)},[]),Be=R.useCallback(()=>{b(!1),setTimeout(Me,200)},[Me]),Fe=R.useCallback(qe=>{let yt=qe.replace(/\D/g,"");return yt.length>=2&&(yt=yt.slice(0,2)+"/"+yt.slice(2,4)),yt.length>5&&(yt=yt.slice(0,5)),yt},[]),Xe=R.useCallback((qe=[])=>qe.map(yt=>{var Ue;const jt=(yt==null?void 0:yt.id)||(yt==null?void 0:yt.value),Yt=((Ue=Oe.find(Ie=>Ie.value===jt))==null?void 0:Ue.label)||(yt==null?void 0:yt.name)||(yt==null?void 0:yt.title)||(yt==null?void 0:yt.label)||`Marker ${jt||""}`;return{value:jt,label:Yt}}),[Oe]),ke=R.useCallback(async qe=>{if(qe){A(qe),b(!0),P(!0);try{const yt=await qN(qe.value);q({name:(yt==null?void 0:yt.name)||qe.label||"",marker_set:Xe((yt==null?void 0:yt.marker_set)||(yt==null?void 0:yt.markers)||[]),season_start_date:(yt==null?void 0:yt.season_start_date)||""})}catch(yt){console.error(yt),Gr.error("Failed to load farm details"),b(!1)}finally{P(!1)}}},[Xe]),Ae=R.useCallback(async()=>{var qe;if(C){if(!((qe=z.name)!=null&&qe.trim())){Gr.error("Please provide a farm name");return}T(!0);try{await Yie(C.value,z.name.trim(),z.marker_set||[],z.season_start_date||void 0),Gr.success("Farm updated successfully"),Be(),h&&await h()}catch(yt){console.error(yt),Gr.error("Failed to update farm")}finally{T(!1)}}},[Be,z.marker_set,z.name,z.season_start_date,h,C]),Le=R.useCallback(qe=>{A(qe),x(!0)},[]),ze=R.useCallback(async()=>{if(C){N(!0);try{await Zie(C.value),Gr.success("Farm deleted successfully"),x(!1),Me(),h&&await h()}catch(qe){console.error(qe),Gr.error("Failed to delete farm")}finally{N(!1)}}},[h,Me,C]),Ze=R.useCallback(async qe=>{var yt,jt,Yt,Ue,Ie,be,je,Ve,rt;if(qe){$(qe),V(!0),te(!0);try{const ct=(qe==null?void 0:qe.id)||((jt=(yt=qe==null?void 0:qe.options)==null?void 0:yt.properties)==null?void 0:jt.id)||((Yt=qe==null?void 0:qe.options)==null?void 0:Yt.id),ht=((Ie=(Ue=qe==null?void 0:qe.options)==null?void 0:Ue.properties)==null?void 0:Ie.name)||((be=qe==null?void 0:qe.properties)==null?void 0:be.name)||(qe==null?void 0:qe.name)||"",et=((Ve=(je=qe==null?void 0:qe.options)==null?void 0:je.properties)==null?void 0:Ve.area)||((rt=qe==null?void 0:qe.properties)==null?void 0:rt.area)||(qe==null?void 0:qe.area)||"";ue({name:ht,area:et?String(et):""})}catch(ct){console.error(ct),Gr.error("Failed to load plot details"),V(!1)}finally{te(!1)}}},[]),We=R.useCallback(async()=>{var qe,yt,jt,Yt;if(B){if(!((qe=ge.name)!=null&&qe.trim())){Gr.error("Please provide a plot name");return}ie(!0);try{const Ie={id:(B==null?void 0:B.id)||((jt=(yt=B==null?void 0:B.options)==null?void 0:yt.properties)==null?void 0:jt.id)||((Yt=B==null?void 0:B.options)==null?void 0:Yt.id),name:ge.name.trim()};ge.area&&(Ie.area=parseFloat(ge.area)||null),await r$(Ie),Gr.success("Plot updated successfully"),V(!1),ue({name:"",area:""}),$(null),h&&await h()}catch(Ue){console.error(Ue),Gr.error("Failed to update plot")}finally{ie(!1)}}},[ge.name,ge.area,B,h]),nt=R.useCallback(qe=>{$(qe),G(!0)},[]),lt=R.useCallback(async()=>{var qe,yt,jt;if(B){fe(!0);try{const Yt=(B==null?void 0:B.id)||((yt=(qe=B==null?void 0:B.options)==null?void 0:qe.properties)==null?void 0:yt.id)||((jt=B==null?void 0:B.options)==null?void 0:jt.id);await i$(Yt),Gr.success("Plot deleted successfully"),G(!1),$(null),h&&await h()}catch(Yt){console.error(Yt),Gr.error("Failed to delete plot")}finally{fe(!1)}}},[B,h]),ft=R.useCallback(async qe=>{var yt,jt;if(qe){ne(qe),Ce(!0),_e(!0);try{const Yt=(qe==null?void 0:qe.id)||((yt=qe==null?void 0:qe.properties)==null?void 0:yt.id),Ue=await TD(Yt);De({location_name:(Ue==null?void 0:Ue.location_name)||((jt=qe==null?void 0:qe.properties)==null?void 0:jt.name)||(qe==null?void 0:qe.name)||""})}catch(Yt){console.error(Yt),Gr.error("Failed to load station details"),Ce(!1)}finally{_e(!1)}}},[]),vt=R.useCallback(async()=>{var qe,yt;if(ae){if(!((qe=de.location_name)!=null&&qe.trim())){Gr.error("Please provide a station name");return}se(!0);try{const jt=(ae==null?void 0:ae.id)||((yt=ae==null?void 0:ae.properties)==null?void 0:yt.id),Yt={id:jt,location_name:de.location_name.trim()},Ue=await TD(jt);await AD({...Ue,...Yt}),Gr.success("Station updated successfully"),Ce(!1),De({location_name:""}),ne(null),h&&await h()}catch(jt){console.error(jt),Gr.error("Failed to update station")}finally{se(!1)}}},[de.location_name,ae,h]),st=R.useCallback(qe=>{ne(qe),Ee(!0)},[]),bt=R.useCallback(async()=>{var qe;if(ae){ye(!0);try{const yt=(ae==null?void 0:ae.id)||((qe=ae==null?void 0:ae.properties)==null?void 0:qe.id);await ID(yt),Gr.success("Station deleted successfully"),Ee(!1),ne(null),h&&await h()}catch(yt){console.error(yt),Gr.error("Failed to delete station")}finally{ye(!1)}}},[ae,h]);return I.jsxs("div",{className:Rt("absolute top-20 left-1/2 -translate-x-1/2 z-20 w-96 transition-all duration-300 origin-top pointer-events-none",e==="settings"?"opacity-100 translate-y-0 pointer-events-auto":"opacity-0 -translate-y-10 pointer-events-none"),children:[I.jsxs("div",{className:"bg-white/90 backdrop-blur-xl rounded-2xl shadow-2xl overflow-hidden flex flex-col max-h-[85vh] border border-white/50",children:[I.jsxs("div",{className:"p-4 border-b border-border flex justify-between items-center bg-white/50",children:[I.jsxs("div",{children:[I.jsx("h2",{className:"font-bold text-foreground",children:"Data Management"}),I.jsx("p",{className:"text-xs text-muted-foreground",children:"Manage farms, plots & stations"})]}),I.jsx(ln,{variant:"ghost",size:"icon",className:"h-8 w-8 rounded-full",onClick:()=>t(null),children:I.jsx(pa,{className:"h-5 w-5"})})]}),I.jsxs(aLe,{defaultValue:"farms",className:"flex-1 flex flex-col",children:[I.jsxs(gz,{className:"w-full rounded-none border-b bg-muted/50",children:[I.jsx(tx,{value:"farms",className:"flex-1 text-xs font-bold uppercase tracking-wide",children:"Farms"}),I.jsx(tx,{value:"plots",className:"flex-1 text-xs font-bold uppercase tracking-wide",children:"Plots"}),I.jsx(tx,{value:"stations",className:"flex-1 text-xs font-bold uppercase tracking-wide",children:"Stations"})]}),I.jsxs(nx,{value:"farms",className:"flex-1 overflow-y-auto p-4 space-y-3 mt-0",children:[I.jsx("h3",{className:"font-semibold text-sm mb-3",children:"All Farms"}),I.jsx("div",{className:"space-y-2 mb-4 max-h-[350px] overflow-y-auto",children:n.map(qe=>I.jsx("div",{className:"bg-white/60 p-3 rounded-lg border border-border hover:border-green-500/50 transition-colors cursor-pointer group",children:I.jsxs("div",{className:"flex items-center justify-between",children:[I.jsxs("div",{className:"flex items-center gap-2",children:[I.jsx("div",{className:"w-8 h-8 bg-green-100 rounded-lg flex items-center justify-center",children:I.jsx(ow,{className:"h-4 w-4 text-green-600"})}),I.jsxs("div",{children:[I.jsx("p",{className:"text-sm font-medium",children:qe.label}),I.jsx("p",{className:"text-xs text-muted-foreground",children:qe.details})]})]}),I.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[I.jsx(ln,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>ke(qe),"aria-label":"Edit farm",children:I.jsx(cw,{className:"h-4 w-4"})}),I.jsx(ln,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>Le(qe),"aria-label":"Delete farm",children:I.jsx($y,{className:"h-4 w-4"})})]})]})},qe.value))}),I.jsxs(ln,{variant:"outline",className:"w-full border-2 border-dashed hover:border-green-500 hover:text-green-600 hover:bg-green-50",onClick:o,children:[I.jsx(_p,{className:"h-4 w-4 mr-2"}),"Add New Farm"]})]}),I.jsxs(nx,{value:"plots",className:"flex-1 overflow-y-auto p-4 space-y-3 mt-0",children:[I.jsx("h3",{className:"font-semibold text-sm mb-3",children:"All Plots"}),I.jsx("div",{className:"space-y-2 max-h-[350px] overflow-y-auto",children:r.map(qe=>{var Ue,Ie,be,je,Ve,rt,ct,ht,et,_t,It;const yt=((Ie=(Ue=qe==null?void 0:qe.options)==null?void 0:Ue.properties)==null?void 0:Ie.name)||((be=qe==null?void 0:qe.properties)==null?void 0:be.name)||`Plot ${(qe==null?void 0:qe.id)||""}`,jt=((Ve=(je=qe==null?void 0:qe.options)==null?void 0:je.properties)==null?void 0:Ve.farm_name)||((rt=qe==null?void 0:qe.properties)==null?void 0:rt.farm_name)||"Unknown Farm",Yt=((ht=(ct=qe==null?void 0:qe.options)==null?void 0:ct.properties)==null?void 0:ht.area)||((et=qe==null?void 0:qe.properties)==null?void 0:et.area)||"N/A";return I.jsx("div",{className:"bg-white/60 p-3 rounded-lg border border-border hover:border-green-500/50 transition-colors cursor-pointer group",children:I.jsxs("div",{className:"flex items-center justify-between",children:[I.jsxs("div",{className:"flex items-center gap-2",children:[I.jsx("div",{className:"w-8 h-8 bg-blue-100 rounded-lg flex items-center justify-center",children:I.jsx(xp,{className:"h-4 w-4 text-blue-600"})}),I.jsxs("div",{children:[I.jsx("p",{className:"text-sm font-medium",children:yt}),I.jsxs("p",{className:"text-xs text-muted-foreground",children:[jt," • ",Yt]})]})]}),I.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[I.jsx(ln,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>Ze(qe),"aria-label":"Edit plot",children:I.jsx(cw,{className:"h-4 w-4"})}),I.jsx(ln,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>nt(qe),"aria-label":"Delete plot",children:I.jsx($y,{className:"h-4 w-4"})})]})]})},(qe==null?void 0:qe.id)||((It=(_t=qe==null?void 0:qe.options)==null?void 0:_t.properties)==null?void 0:It.id))})}),I.jsxs(ln,{variant:"outline",className:"w-full border-2 border-dashed hover:border-green-500 hover:text-green-600 hover:bg-green-50",onClick:s,children:[I.jsx(_p,{className:"h-4 w-4 mr-2"}),"Add Plot"]})]}),I.jsxs(nx,{value:"stations",className:"flex-1 overflow-y-auto p-4 space-y-3 mt-0",children:[I.jsx("h3",{className:"font-semibold text-sm mb-3",children:"All Stations"}),I.jsx("div",{className:"space-y-2 max-h-[350px] overflow-y-auto",children:i.map(qe=>{var Ie,be,je,Ve;const yt=((Ie=qe==null?void 0:qe.properties)==null?void 0:Ie.name)||(qe==null?void 0:qe.name)||`Station ${(qe==null?void 0:qe.id)||""}`,jt=((be=qe==null?void 0:qe.properties)==null?void 0:be.farm_name)||(qe==null?void 0:qe.farm_name)||"Unknown Farm",Yt=((je=qe==null?void 0:qe.properties)==null?void 0:je.paw_status)||(qe==null?void 0:qe.paw_status)||"Unknown",Ue=Yt==="OPTIMAL"||Yt==="optimal"?"green":Yt==="STRESS_START"||Yt==="stress"?"orange":"gray";return I.jsx("div",{className:"bg-white/60 p-3 rounded-lg border border-border hover:border-green-500/50 transition-colors cursor-pointer group",children:I.jsxs("div",{className:"flex items-center justify-between",children:[I.jsxs("div",{className:"flex items-center gap-2",children:[I.jsx("div",{className:Rt("w-8 h-8 rounded-lg flex items-center justify-center",Ue==="orange"&&"bg-orange-100",Ue==="green"&&"bg-green-100",Ue==="gray"&&"bg-gray-100"),children:I.jsx(Ry,{className:Rt("h-4 w-4",Ue==="orange"&&"text-orange-600",Ue==="green"&&"text-green-600",Ue==="gray"&&"text-gray-600")})}),I.jsxs("div",{children:[I.jsx("p",{className:"text-sm font-medium",children:yt}),I.jsxs("p",{className:"text-xs text-muted-foreground",children:[jt," • ",a(Yt)]})]})]}),I.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[I.jsx(ln,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>ft(qe),"aria-label":"Edit station",children:I.jsx(cw,{className:"h-4 w-4"})}),I.jsx(ln,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>st(qe),"aria-label":"Delete station",children:I.jsx($y,{className:"h-4 w-4"})})]})]})},(qe==null?void 0:qe.id)||((Ve=qe==null?void 0:qe.properties)==null?void 0:Ve.id))})}),I.jsxs(ln,{variant:"outline",className:"w-full border-2 border-dashed hover:border-green-500 hover:text-green-600 hover:bg-green-50",onClick:u,children:[I.jsx(_p,{className:"h-4 w-4 mr-2"}),"Add Station"]})]})]})]}),I.jsx(_T,{open:y,onOpenChange:qe=>!qe&&Be(),children:I.jsxs(Dx,{className:"sm:max-w-lg",children:[I.jsxs(Nx,{children:[I.jsx(jx,{children:"Edit Farm"}),I.jsx(Fx,{children:"Update the farm name, markers and season start date."})]}),I.jsxs("div",{className:"space-y-4",children:[I.jsxs("div",{className:"space-y-2",children:[I.jsx("p",{className:"text-sm font-medium text-foreground",children:"Farm Name"}),I.jsx(vl,{value:z.name,onChange:qe=>q(yt=>({...yt,name:qe.target.value})),placeholder:"Farm name",disabled:E})]}),I.jsxs("div",{className:"space-y-2",children:[I.jsx("p",{className:"text-sm font-medium text-foreground",children:"Markers"}),I.jsx(To,{value:lc(z.marker_set,Oe),onChange:qe=>q(yt=>({...yt,marker_set:qe||[]})),options:Oe,isMulti:!0,isLoading:p||E,isClearable:!0,placeholder:"Select markers"})]}),I.jsxs("div",{className:"space-y-2",children:[I.jsx("p",{className:"text-sm font-medium text-foreground",children:"Season start date"}),I.jsx(vl,{value:z.season_start_date,onChange:qe=>q(yt=>({...yt,season_start_date:Fe(qe.target.value)})),placeholder:"MM/DD",maxLength:5,disabled:E})]})]}),I.jsxs(Lx,{children:[I.jsx(ln,{variant:"outline",onClick:Be,disabled:O,children:"Cancel"}),I.jsx(ln,{onClick:Ae,disabled:O||E,children:O?"Saving...":"Save changes"})]})]})}),I.jsx(ig,{isOpen:_,onClose:()=>x(!1),onConfirm:ze,onCancel:()=>x(!1),title:"Delete farm",message:`Are you sure you want to delete "${(C==null?void 0:C.label)||"this farm"}"?`,confirmText:k?"Deleting...":"Delete",cancelText:"Cancel",variant:"destructive"}),I.jsx(_T,{open:H,onOpenChange:qe=>!qe&&V(!1),children:I.jsxs(Dx,{className:"sm:max-w-lg",children:[I.jsxs(Nx,{children:[I.jsx(jx,{children:"Edit Plot"}),I.jsx(Fx,{children:"Update the plot name and area."})]}),I.jsxs("div",{className:"space-y-4",children:[I.jsxs("div",{className:"space-y-2",children:[I.jsx("p",{className:"text-sm font-medium text-foreground",children:"Plot Name"}),I.jsx(vl,{value:ge.name,onChange:qe=>ue(yt=>({...yt,name:qe.target.value})),placeholder:"Plot name",disabled:Y})]}),I.jsxs("div",{className:"space-y-2",children:[I.jsx("p",{className:"text-sm font-medium text-foreground",children:"Area"}),I.jsx(vl,{type:"number",value:ge.area,onChange:qe=>ue(yt=>({...yt,area:qe.target.value})),placeholder:"Area (optional)",disabled:Y})]})]}),I.jsxs(Lx,{children:[I.jsx(ln,{variant:"outline",onClick:()=>V(!1),disabled:re,children:"Cancel"}),I.jsx(ln,{onClick:We,disabled:re||Y,children:re?"Saving...":"Save changes"})]})]})}),I.jsx(ig,{isOpen:U,onClose:()=>G(!1),onConfirm:lt,onCancel:()=>G(!1),title:"Delete plot",message:`Are you sure you want to delete "${((Ft=(Ct=B==null?void 0:B.options)==null?void 0:Ct.properties)==null?void 0:Ft.name)||((Lt=B==null?void 0:B.properties)==null?void 0:Lt.name)||(B==null?void 0:B.name)||"this plot"}"?`,confirmText:J?"Deleting...":"Delete",cancelText:"Cancel",variant:"destructive"}),I.jsx(_T,{open:ve,onOpenChange:qe=>!qe&&Ce(!1),children:I.jsxs(Dx,{className:"sm:max-w-lg",children:[I.jsxs(Nx,{children:[I.jsx(jx,{children:"Edit Station"}),I.jsx(Fx,{children:"Update the station name."})]}),I.jsx("div",{className:"space-y-4",children:I.jsxs("div",{className:"space-y-2",children:[I.jsx("p",{className:"text-sm font-medium text-foreground",children:"Station Name"}),I.jsx(vl,{value:de.location_name,onChange:qe=>De(yt=>({...yt,location_name:qe.target.value})),placeholder:"Station name",disabled:he})]})}),I.jsxs(Lx,{children:[I.jsx(ln,{variant:"outline",onClick:()=>Ce(!1),disabled:Z,children:"Cancel"}),I.jsx(ln,{onClick:vt,disabled:Z||he,children:Z?"Saving...":"Save changes"})]})]})}),I.jsx(ig,{isOpen:Te,onClose:()=>Ee(!1),onConfirm:bt,onCancel:()=>Ee(!1),title:"Delete station",message:`Are you sure you want to delete "${((St=ae==null?void 0:ae.properties)==null?void 0:St.name)||(ae==null?void 0:ae.name)||"this station"}"?`,confirmText:le?"Deleting...":"Delete",cancelText:"Cancel",variant:"destructive"})]})}function sFe({selectedFarm:e,farmOpen:t,setFarmOpen:n,farms:r=[],handleFarmSelect:i,onAddFarm:a}){const[o,s]=R.useState(""),u=R.useMemo(()=>{if(!o.trim())return r;const m=o.toLowerCase();return r.filter(p=>{var y,b;return((y=p.label)==null?void 0:y.toLowerCase().includes(m))||((b=p.details)==null?void 0:b.toLowerCase().includes(m))})},[r,o]),h=(m,p)=>{i(e===p||e===m?null:m),n(!1),s("")};return I.jsxs(hv,{open:t,onOpenChange:n,children:[I.jsx(fv,{asChild:!0,children:I.jsxs(ln,{variant:"ghost",className:"h-10 px-4 rounded-none flex items-center gap-3 hover:bg-white/50 text-foreground",children:[I.jsx(ow,{className:"h-4 w-4 text-muted-foreground shrink-0"}),I.jsxs("div",{className:"flex flex-col items-start leading-none",children:[I.jsx("span",{className:"text-[10px] font-bold text-muted-foreground uppercase tracking-wider",children:"Farm"}),I.jsx("span",{className:"text-xs font-bold whitespace-nowrap",children:e||"Select a farm"})]}),I.jsx(mo,{className:"h-3 w-3 text-muted-foreground ml-1 shrink-0"})]})}),I.jsx(rS,{className:"w-[280px] p-0",align:"start",children:I.jsxs("div",{className:"flex flex-col",children:[I.jsxs("div",{className:"flex items-center border-b px-3",children:[I.jsx(By,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),I.jsx(vl,{placeholder:"Search farm...",value:o,onChange:m=>s(m.target.value),className:"border-none focus-visible:ring-0 focus-visible:ring-offset-0 focus-visible:shadow-none h-11 bg-transparent px-0"})]}),I.jsx("div",{className:"max-h-[350px] overflow-y-auto",children:u.length===0?I.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"No farm found."}):I.jsxs(I.Fragment,{children:[I.jsx("div",{className:"px-2 py-1.5 text-xs font-medium text-muted-foreground",children:"Farms"}),I.jsx("div",{className:"p-1",children:u.map(m=>I.jsxs("div",{onClick:()=>h(m.value,m.label),className:Rt("relative flex w-full cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none hover:bg-accent hover:text-accent-foreground",(e===m.label||e===m.value)&&"bg-accent text-accent-foreground"),children:[I.jsx(lw,{className:Rt("mr-2 h-4 w-4",e===m.label||e===m.value?"opacity-100":"opacity-0")}),I.jsxs("div",{className:"flex flex-col",children:[I.jsx("span",{children:m.label}),I.jsx("span",{className:"text-xs text-muted-foreground",children:m.details})]})]},m.value))})]})}),I.jsx("div",{className:"h-px bg-border mx-1"}),I.jsx("div",{className:"p-2 border-t",children:I.jsxs(ln,{variant:"ghost",className:"w-full justify-start h-9 text-sm font-medium text-muted-foreground hover:text-green-600 hover:bg-green-50",onClick:a,children:[I.jsx(_p,{className:"h-4 w-4 mr-2"}),"Add New Farm"]})})]})})]})}function oFe({mapRef:e}){const[t,n]=R.useState(null),[r,i]=R.useState(null),[a,o]=R.useState(!1),[s,u]=R.useState([]),[h,m]=R.useState(""),[p,y]=R.useState(!1);Tt(Oe=>Oe.setSidebarExpanded);const b=Tt(Oe=>Oe.setViewMode),{markerFilters:_,setMarkerFilters:x,showMarkers:C,setShowMarkers:A,markers:E,unfilteredMarkers:P}=R.useContext(Za),{plots:O}=R.useContext(Zs),T=Tt(Oe=>Oe.rasterLayer),k=Tt(Oe=>Oe.setRasterLayer),N=Tt(Oe=>Oe.showCroppedImages),z=Tt(Oe=>Oe.setShowCroppedImages),q=Tt(Oe=>Oe.rasterOpacity),H=Tt(Oe=>Oe.setRasterOpacity),{isVisible:V,setIsVisible:U}=R.useContext(Jm),G=R.useCallback(Oe=>{const Me=Gf("selected-farm");if(Me&&Oe.length>0){const Be=Oe.find(Fe=>Fe.value===Me||Fe.value==Me);if(Be){i(Be.label),x(Fe=>({...Fe,farm_id:Be.value}));return}}i(null),py("selected-farm"),x(Be=>({...Be,farm_id:null}))},[x]),B=R.useCallback(async()=>{try{const Me=(await Iv()).map(Be=>({value:Be.value||Be.id,label:Be.label||Be.name,details:`${Be.plots||0} plots • ${Be.stations||0} stations`}));return u(Me),G(Me),Me}catch(Oe){return console.error("Failed to load farms:",Oe),[]}},[G]);R.useEffect(()=>{B()},[]);const $=R.useCallback(Oe=>{n(t===Oe?null:Oe)},[t]),Y=R.useCallback(Oe=>{const Me=s.find(Xe=>Xe.value===Oe);if(Me?(i(Me.label),fd("selected-farm",Oe)):(i(null),py("selected-farm")),o(!1),x({..._,farm_id:Oe||null}),!Oe||!(e!=null&&e.current))return;const Be=O.filter(Xe=>{const ke=Xe==null?void 0:Xe.farm;return ke?(typeof ke=="object"?ke==null?void 0:ke.id:ke)==Oe:!1});if(Be.length>0){const Xe=new Wf.LngLatBounds;let ke=!1;if(Be.forEach(Ae=>{var ze;const Le=((ze=Ae==null?void 0:Ae.options)==null?void 0:ze.geometry)||(Ae==null?void 0:Ae.geometry);if(Le!=null&&Le.coordinates){const Ze=Le.type==="Polygon"?Le.coordinates[0]:Le.coordinates;Array.isArray(Ze)&&Ze.forEach(We=>{Array.isArray(We)&&We.length>=2&&(Xe.extend([We[0],We[1]]),ke=!0)})}}),ke){const Ae=e.current.getMap();Ae&&Ae.fitBounds(Xe,{padding:100,maxZoom:15,essential:!0});return}}const Fe=P==null?void 0:P.find(Xe=>{var ke;return((ke=Xe==null?void 0:Xe.farm)==null?void 0:ke.id)==Oe});if(Fe!=null&&Fe.lat&&(Fe!=null&&Fe.lng)){const Xe=e.current.getMap();Xe&&Xe.flyTo({center:[Fe.lng,Fe.lat],essential:!0,zoom:12})}},[s,_,x,O,P,e]),te=R.useCallback(()=>B(),[B]),re=R.useCallback(Oe=>!Oe||Oe===""?"All":Oe.charAt(0).toUpperCase()+Oe.slice(1).replace(/_/g," "),[]),ie=(_==null?void 0:_.type)||"",J=(_==null?void 0:_.paw_status)||"",fe=N?"plot":"map",ge=R.useCallback(Oe=>{z(Oe==="plot")},[z]),ue=T,ve=R.useCallback(Oe=>{k(Oe)},[k]),Ce=[{value:"",label:"All"},{value:"station",label:"Station"},{value:"forecast",label:"Forecast"}],Te=[{value:"",label:"All"},{value:"OPTIMAL",label:"Optimal"},{value:"STRESS_START",label:"Stress"},{value:"SEVERE_STRESS",label:"Severe"}],Ee=R.useCallback(Oe=>{x({..._,type:Oe})},[_,x]),ae=R.useCallback(Oe=>{x({..._,paw_status:Oe})},[_,x]),ne=R.useCallback(Oe=>{if(!(e!=null&&e.current))return;const Me=e.current.getMap();Me&&Me.getStyle().layers.forEach(Be=>{Be.id.startsWith("croppedImageLayer-")&&Me.setPaintProperty(Be.id,"raster-opacity",Number(Oe/100))})},[e]),he=Gd(ne,500),_e=[q],Z=R.useCallback(Oe=>{const Me=Oe[0];H(Me),he(Me)},[H,he]),se=R.useCallback(()=>{b(qn.ADD_NEW_FARM),n(null)},[b]),le=R.useCallback(()=>{b(qn.ADD_PLOT),n(null)},[b]),ye=R.useCallback(()=>{b(qn.ADD_MARKER),n(null)},[b]),de=R.useMemo(()=>{if(!h||h.trim()==="")return[];const Oe=h.toLowerCase().trim(),Me=[],Be=E||[];return s.forEach(Fe=>{const Xe=(Fe.label||"").toLowerCase(),ke=(Fe.details||"").toLowerCase();(Xe.includes(Oe)||ke.includes(Oe))&&Me.push({id:`farm-${Fe.value}`,type:"farm",label:Fe.label,subLabel:Fe.details||"Farm",data:Fe})}),O.forEach(Fe=>{var Le,ze,Ze,We,nt,lt,ft,vt,st,bt,Ct,Ft,Lt,St,qe,yt,jt;const Xe=(((ze=(Le=Fe==null?void 0:Fe.options)==null?void 0:Le.properties)==null?void 0:ze.name)||((Ze=Fe==null?void 0:Fe.properties)==null?void 0:Ze.name)||`Plot ${(Fe==null?void 0:Fe.id)||""}`).toLowerCase(),ke=(((nt=(We=Fe==null?void 0:Fe.options)==null?void 0:We.properties)==null?void 0:nt.farm_name)||((lt=Fe==null?void 0:Fe.properties)==null?void 0:lt.farm_name)||"Unknown Farm").toLowerCase(),Ae=((vt=(ft=Fe==null?void 0:Fe.options)==null?void 0:ft.properties)==null?void 0:vt.area)||((st=Fe==null?void 0:Fe.properties)==null?void 0:st.area)||"N/A";if(Xe.includes(Oe)||ke.includes(Oe)){const Yt=((Ct=(bt=Fe==null?void 0:Fe.options)==null?void 0:bt.properties)==null?void 0:Ct.farm_name)||((Ft=Fe==null?void 0:Fe.properties)==null?void 0:Ft.farm_name)||"Unknown Farm";Me.push({id:`plot-${(Fe==null?void 0:Fe.id)||((St=(Lt=Fe==null?void 0:Fe.options)==null?void 0:Lt.properties)==null?void 0:St.id)}`,type:"plot",label:((yt=(qe=Fe==null?void 0:Fe.options)==null?void 0:qe.properties)==null?void 0:yt.name)||((jt=Fe==null?void 0:Fe.properties)==null?void 0:jt.name)||`Plot ${(Fe==null?void 0:Fe.id)||""}`,subLabel:`${Yt} • ${Ae}`,data:Fe})}}),Be.forEach(Fe=>{var We,nt,lt,ft,vt,st;const Xe=((Fe==null?void 0:Fe.title)||"").toLowerCase(),ke=((Fe==null?void 0:Fe.location_name)||"").toLowerCase(),Ae=(((We=Fe==null?void 0:Fe.device)==null?void 0:We.name)||"").toLowerCase(),Le=(((nt=Fe==null?void 0:Fe.device)==null?void 0:nt.serial)||"").toLowerCase(),ze=(((lt=Fe==null?void 0:Fe.farm)==null?void 0:lt.name)||(Fe==null?void 0:Fe.farm_name)||"Unknown Farm").toLowerCase(),Ze=(Fe==null?void 0:Fe.paw_status)||((ft=Fe==null?void 0:Fe.properties)==null?void 0:ft.paw_status)||"Unknown";if(Xe.includes(Oe)||ke.includes(Oe)||Ae.includes(Oe)||Le.includes(Oe)||ze.includes(Oe)){const bt=((vt=Fe==null?void 0:Fe.farm)==null?void 0:vt.name)||(Fe==null?void 0:Fe.farm_name)||"Unknown Farm";Me.push({id:`station-${(Fe==null?void 0:Fe.id)||((st=Fe==null?void 0:Fe.properties)==null?void 0:st.id)}`,type:"station",label:(Fe==null?void 0:Fe.title)||(Fe==null?void 0:Fe.location_name)||`Station ${(Fe==null?void 0:Fe.id)||""}`,subLabel:`${bt} • ${re(Ze)}`,data:Fe})}}),Me},[h,s,O,E,re]),De=R.useCallback(Oe=>{var Me,Be;if(e!=null&&e.current){if(Oe.type==="farm")Y(Oe.data.value),y(!1),m("");else if(Oe.type==="plot"){const Fe=Oe.data,Xe=((Me=Fe==null?void 0:Fe.options)==null?void 0:Me.geometry)||(Fe==null?void 0:Fe.geometry);if(Xe&&Xe.coordinates){const ke=Xe.coordinates[0]||Xe.coordinates;if(ke&&ke.length>0){let Ae=0,Le=0;const ze=ke.filter(Ze=>Ze&&Ze.length>=2);if(ze.forEach(Ze=>{const[We,nt]=Ze;Le+=We,Ae+=nt}),ze.length>0){const Ze=Le/ze.length,We=Ae/ze.length;e.current.flyTo({center:[Ze,We],zoom:14})}}}y(!1),m("")}else if(Oe.type==="station"){const Fe=Oe.data,Xe=(Fe==null?void 0:Fe.location)||((Be=Fe==null?void 0:Fe.properties)==null?void 0:Be.location);if(Xe){const ke=Xe.lat||Xe.latitude,Ae=Xe.lng||Xe.longitude;ke&&Ae&&e.current.flyTo({center:[Ae,ke],zoom:14})}y(!1),m("")}}},[e,Y,y,m]);return I.jsx(lFe,{activePanel:t,togglePanel:$,selectedFarm:r,farmOpen:a,setFarmOpen:o,farms:s,handleFarmSelect:Y,markerType:ie,pawStatus:J,formatLabel:re,searchQuery:h,setSearchQuery:m,isSearchFocused:p,setIsSearchFocused:y,dataSource:ue,setDataSource:ve,viewType:fe,setViewType:ge,layerOptions:dp,layerOpacity:_e,setLayerOpacity:Z,layerEnabled:V,setLayerEnabled:U,setMarkerType:Ee,setPawStatus:ae,markerTypeOptions:Ce,pawStatusOptions:Te,showMarkers:C,setShowMarkers:A,plots:O||[],markers:E||[],onAddFarm:se,onAddPlot:le,onAddStation:ye,searchResults:de,onSearchResultClick:De,onFarmsChange:te})}function lFe({togglePanel:e,activePanel:t,selectedFarm:n,farmOpen:r,setFarmOpen:i,farms:a,handleFarmSelect:o,markerType:s,pawStatus:u,formatLabel:h,searchQuery:m,setSearchQuery:p,isSearchFocused:y,setIsSearchFocused:b,dataSource:_,setDataSource:x,viewType:C,setViewType:A,layerOptions:E=[],layerOpacity:P=[100],setLayerOpacity:O,layerEnabled:T=!0,setLayerEnabled:k,setMarkerType:N,setPawStatus:z,markerTypeOptions:q=[],pawStatusOptions:H=[],showMarkers:V=!0,setShowMarkers:U,plots:G=[],markers:B=[],onAddFarm:$,onAddPlot:Y,onAddStation:te,onFarmsChange:re,searchResults:ie=[],onSearchResultClick:J}){return R.useContext(ha),I.jsxs(I.Fragment,{children:[I.jsx("div",{className:"absolute top-4 w-full z-30 flex justify-center pointer-events-none",children:I.jsxs("div",{className:"bg-white/90 backdrop-blur-xl border border-white/50 shadow-sm rounded-md flex items-center pointer-events-auto",children:[I.jsx(ln,{variant:"ghost",size:"icon",className:"w-10 h-10 rounded-l-md rounded-r-none text-muted-foreground hover:bg-white/50 hover:text-foreground",onClick:()=>e("settings"),children:I.jsx(bK,{className:"h-5 w-5"})}),I.jsx("div",{className:"w-px h-6 bg-border"}),I.jsxs(ln,{variant:"ghost",className:"h-10 px-4 rounded-none flex items-center gap-3 hover:bg-white/50 text-foreground",onClick:()=>e("layers"),children:[I.jsx(xp,{className:"h-4 w-4 text-muted-foreground shrink-0"}),I.jsxs("div",{className:"flex flex-col items-start leading-none",children:[I.jsx("span",{className:"text-[10px] font-bold text-muted-foreground uppercase tracking-wider",children:"Layer"}),I.jsxs("span",{className:"text-xs font-bold whitespace-nowrap",children:[(_==null?void 0:_.label)||"Evapo"," ",I.jsxs("span",{className:"text-muted-foreground font-normal",children:["• ",C==="plot"?"Plot View":"Map View"]})]})]}),I.jsx(mo,{className:"h-3 w-3 text-muted-foreground ml-1 shrink-0"})]}),I.jsx("div",{className:"w-px h-6 bg-border"}),I.jsxs(ln,{variant:"ghost",className:"h-10 px-4 rounded-none flex items-center gap-3 hover:bg-white/50 text-foreground",onClick:()=>e("stations"),children:[I.jsx(Ry,{className:"h-4 w-4 text-muted-foreground shrink-0"}),I.jsxs("div",{className:"flex flex-col items-start leading-none",children:[I.jsx("span",{className:"text-[10px] font-bold text-muted-foreground uppercase tracking-wider",children:"Filter"}),I.jsxs("span",{className:"text-xs font-bold whitespace-nowrap",children:[h(s)," ",I.jsx("span",{className:"text-muted-foreground font-normal",children:"•"})," ",h(u)]})]}),I.jsx(mo,{className:"h-3 w-3 text-muted-foreground ml-1 shrink-0"})]}),I.jsx("div",{className:"w-px h-6 bg-border"}),I.jsx(sFe,{selectedFarm:n,farmOpen:r,setFarmOpen:i,farms:a,handleFarmSelect:o,onAddFarm:$}),I.jsx("div",{className:"w-px h-6 bg-border"}),I.jsxs("div",{className:"relative",children:[I.jsxs("div",{className:Rt("flex items-center gap-2 px-3 h-10 rounded-r-md transition-all duration-300",y?"w-64 bg-white":"w-40 hover:bg-white/50"),children:[I.jsx(By,{className:"h-4 w-4 text-muted-foreground shrink-0"}),I.jsx(vl,{type:"text",placeholder:"Search...",value:m,onChange:fe=>p(fe.target.value),onFocus:()=>b(!0),onBlur:()=>setTimeout(()=>b(!1),200),className:"bg-transparent border-none focus-visible:ring-0 focus-visible:ring-offset-0 focus-visible:shadow-none text-sm h-full placeholder:text-muted-foreground/70 px-0 w-full"})]}),I.jsx(Q5e,{isSearchFocused:y,searchQuery:m,searchResults:ie,onResultClick:J})]})]})}),I.jsx(Q4e,{activePanel:t,togglePanel:e,viewType:C,setViewType:A,dataSource:_,setDataSource:x,layerOptions:E,layerOpacity:P,setLayerOpacity:O,layerEnabled:T,setLayerEnabled:k}),I.jsx(rFe,{activePanel:t,togglePanel:e,markerType:s,setMarkerType:N,pawStatus:u,setPawStatus:z,markerTypeOptions:q,pawStatusOptions:H,showMarkers:V,setShowMarkers:U,formatLabel:h}),I.jsx(aFe,{activePanel:t,togglePanel:e,farms:a,plots:G,markers:B,formatLabel:h,onAddFarm:$,onAddPlot:Y,onAddStation:te,onFarmsChange:re})]})}const S8=ee.forwardRef(({className:e,value:t,...n},r)=>{const i=Math.min(Math.max(t||0,0),100);return I.jsx("div",{ref:r,className:Rt("relative h-4 w-full overflow-hidden rounded-full bg-secondary",e),...n,children:I.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${i}%`}})})});S8.displayName="Progress";function cFe({className:e}){var P,O,T;const t=Tt(k=>k.pickerData),n=Tt(k=>k.hoveredPlot),{plots:r}=R.useContext(Zs),[i,a]=R.useState(null),[o,s]=R.useState(!1),u=R.useRef(null),h=R.useCallback(k=>{var N,z,q,H;return k?(k==null?void 0:k.id)||((N=k==null?void 0:k.options)==null?void 0:N.id)||((q=(z=k==null?void 0:k.options)==null?void 0:z.properties)==null?void 0:q.id)||((H=k==null?void 0:k.properties)==null?void 0:H.id):null},[]),m=R.useMemo(()=>{var k,N;return n||((N=(k=t==null?void 0:t.plot)==null?void 0:k.properties)!=null&&N.id?r==null?void 0:r.find(z=>{var V,U,G,B;const q=((V=z==null?void 0:z.options)==null?void 0:V.id)||(z==null?void 0:z.id),H=((G=(U=t==null?void 0:t.plot)==null?void 0:U.properties)==null?void 0:G.id)||((B=t==null?void 0:t.plot)==null?void 0:B.id);return q===H}):null)},[n,(O=(P=t==null?void 0:t.plot)==null?void 0:P.properties)==null?void 0:O.id,(T=t==null?void 0:t.plot)==null?void 0:T.id,r]);R.useEffect(()=>{if(!m){a(null),s(!1),u.current=null;return}const k=h(m);console.log("ETProgressIndicator: selectedPlot:",m),console.log("ETProgressIndicator: currentPlotId:",k),console.log("ETProgressIndicator: device:",m==null?void 0:m.device),k!==u.current&&(u.current=k,s(!0),rE({stationId:m==null?void 0:m.device,plotId:k}).then(N=>{console.log("ETProgressIndicator: task stats received:",N),a(N)}).catch(N=>{console.error("Error fetching task stats:",N),a(null)}).finally(()=>{s(!1)}))},[m,h]),R.useEffect(()=>{if(!m||!i||!((i.running||0)>0||(i.pending||0)>0))return;const N=h(m),z=setInterval(()=>{rE({stationId:m==null?void 0:m.device,plotId:N}).then(q=>{a(q)}).catch(q=>{console.error("Error polling task stats:",q)})},5e3);return()=>{clearInterval(z)}},[m,i,h]);const p=R.useMemo(()=>{var k,N;return m&&((m==null?void 0:m.enable_satellite_et)||((N=(k=m==null?void 0:m.options)==null?void 0:k.properties)==null?void 0:N.enable_satellite_et))||!1},[m]),y=R.useMemo(()=>{if(!i)return null;const k=i.stopped||0,N=i.running||0,z=i.pending||0,q=i.failed||0,H=k+N+z+q;if(H===0)return null;const V=k,U=H,G=V/U*100,B=Math.max(0,U-V),$=V>=U,Y=(N>0||z>0)&&!$;return{daysGenerated:V,totalDays:U,percentage:G,daysRemaining:B,isComplete:$,isGenerating:Y}},[i]);if(!m||!p)return null;if(o)return I.jsx("div",{className:Rt("bg-card/95 backdrop-blur-sm border border-border rounded-lg shadow-lg p-3 min-w-[280px]",e),children:I.jsx("div",{className:"space-y-2",children:I.jsxs("div",{className:"flex items-center gap-2",children:[I.jsx("div",{className:"w-2 h-2 rounded-full bg-muted-foreground animate-pulse"}),I.jsx("span",{className:"text-sm font-medium text-foreground",children:"Loading ET Data..."})]})})});if(!y)return I.jsx("div",{className:Rt("bg-card/95 backdrop-blur-sm border border-border rounded-lg shadow-lg p-3 min-w-[280px]",e),children:I.jsx("div",{className:"space-y-2",children:I.jsxs("div",{className:"flex items-center gap-2",children:[I.jsx("div",{className:"w-2 h-2 rounded-full bg-chart-1 animate-pulse"}),I.jsx("span",{className:"text-sm font-medium text-foreground",children:"Generating ET Data"})]})})});const{daysGenerated:b,totalDays:_,percentage:x,daysRemaining:C,isComplete:A,isGenerating:E}=y;return I.jsx("div",{className:Rt("bg-card/95 backdrop-blur-sm border border-border rounded-lg shadow-lg p-3 min-w-[280px]",e),children:I.jsxs("div",{className:"space-y-2",children:[I.jsx("div",{className:"flex items-center justify-between gap-2",children:I.jsxs("div",{className:"flex items-center gap-2",children:[I.jsx("div",{className:Rt("w-2 h-2 rounded-full",E?"bg-chart-1 animate-pulse":"bg-green-500")}),I.jsx("span",{className:"text-sm font-medium text-foreground",children:E?"Generating ET Data":"ET Data Ready"})]})}),I.jsx(S8,{value:x,className:"h-2"}),I.jsxs("div",{className:"flex items-center justify-between text-xs",children:[I.jsxs("span",{className:"text-muted-foreground",children:[b," of ",_," days"]}),I.jsx("span",{className:Rt("font-medium",A?"text-green-500":"text-chart-1"),children:A?"100%":C>0?`${C} remaining`:`${Math.round(x)}%`})]})]})})}function uFe({style:e,configs:t,markers:n}){var k;const{settings:r}=R.useContext(hp),{mapRef:i}=R.useContext(ha),a=R.useRef(),o=kY(),[s,u]=R.useState(o),h=Tt(N=>N.viewMode),m=Tt(N=>N.mapMode),p=Tt(N=>N.cursor),y=Tt(N=>N.setConfigs);Tt(N=>N.sidebarExpanded),$h(),qm();const b=Tt(N=>N.dateRange),_=Tt(N=>N.setDateRange),x=Tt(N=>N.dateRange2),C=Tt(N=>N.setDateRange2),A=R.useCallback(N=>u(N.viewState),[]);R.useEffect(()=>{try{const N=s1("map-viewport");N&&u(N)}catch(N){console.error("Failed to load viewport from localStorage:",N)}},[]),R.useEffect(()=>{if(s)try{o1("map-viewport",s)}catch(N){console.error("Failed to save viewport to localStorage:",N)}},[s]),R.useEffect(()=>{if(m)try{fd("map-mode",m)}catch(N){console.error("Failed to save mapMode to localStorage:",N)}},[m]);const E=R.useCallback(N=>{_(N?{start:N,end:N}:{start:void 0,end:void 0})},[_]),P=R.useCallback(N=>{C(N?{start:N,end:N}:{start:void 0,end:void 0})},[C]),[O,T]=R.useState(`${(k=nP.find(N=>N.id===r.basemap.id))==null?void 0:k.url}?key=${t==null?void 0:t.VITE_MAPTILER_ACCESS_KEY}`);return R.useEffect(()=>{var N;T(`${(N=nP.find(z=>z.id===r.basemap.id))==null?void 0:N.url}?key=${t==null?void 0:t.VITE_MAPTILER_ACCESS_KEY}`)},[r]),R.useEffect(()=>{y(t)},[]),R.useEffect(()=>{console.log("fff dateRange is",b),console.log("fff dateRange2 is",x)},[b,x]),R.useEffect(()=>{if(i!=null&&i.current){const N=i.current.getMap();if(N&&N.scrollZoom){const z=()=>{N.scrollZoom&&N.scrollZoom.disable()};return N.loaded()?z():N.once("load",z),()=>{N&&N.off("load",z)}}}},[i]),R.useEffect(()=>{if(a!=null&&a.current){const N=a.current.getMap();if(N&&N.scrollZoom){const z=()=>{N.scrollZoom&&N.scrollZoom.disable()};return N.loaded()?z():N.once("load",z),()=>{N&&N.off("load",z)}}}},[a]),o?I.jsx(cS,{providedMarkers:n,children:I.jsx(sE,{children:I.jsx(O9,{children:I.jsx(Zke,{children:I.jsxs("div",{style:{width:"100%",height:"80vh"},className:"flex flex-row relative",children:[I.jsxs(MP,{id:"myMap",ref:i,initialViewState:o,...s,onMove:A,style:{width:"100%",...e},mapStyle:typeof O=="string"?O:O.toJS(),attributionControl:!1,reuseMaps:!0,preserveDrawingBuffer:!0,cursor:p,scrollZoom:!1,children:[I.jsx(g9,{mapRef:i,dateRange:b}),m==Ga.NORMAL&&I.jsx(oFe,{mapRef:i}),m==Ga.NORMAL&&I.jsx("div",{className:"absolute top-4 left-4 z-20 pointer-events-none",children:I.jsx("div",{className:"pointer-events-auto",children:I.jsx(cFe,{})})}),I.jsx("div",{className:"absolute top-0 left-0",children:m==Ga.COMPARISION_VIEW&&I.jsx(pv,{compact:!0,onDateSelect:E,mapRef:i,dateRange:b})}),m===Ga.NORMAL&&I.jsx(b9,{dateRange:b,mapRef:i}),m!==Ga.NORMAL&&I.jsx("div",{className:"absolute top-0 right-0 m-2",style:{zIndex:2},children:I.jsx(v9,{dateRange:b,mapRef:i,showButton:!1})}),I.jsx("div",{className:"absolute bottom-4 left-4",style:{zIndex:3},children:I.jsx(mke,{})}),I.jsxs("div",{className:"absolute bottom-4 right-20 flex flex-col gap-4 items-end",style:{zIndex:10},children:[I.jsx(D9,{mapRef:i}),I.jsx($je,{})]}),I.jsx("div",{className:"absolute bottom-4 left-0 right-0 flex justify-center items-center",style:{zIndex:3},children:I.jsx(One,{mapRef:i,configs:t,onDateSelect:E})}),I.jsx(T3e,{}),h==qn.EDIT_PLOT&&I.jsx(j5e,{}),h==qn.ADD_PLOT&&I.jsx(F5e,{}),h==qn.ADD_MARKER&&I.jsx(R5e,{}),h==qn.ADD_NEW_FARM&&I.jsx(B5e,{}),I.jsx(are,{}),I.jsx(Nle,{}),I.jsx(Fz,{mapRef:i,dateRange:b}),I.jsx(A3e,{}),I.jsx(z5e,{})]}),m===Ga.COMPARISION_VIEW&&I.jsxs(MP,{id:"myMap2",ref:a,initialViewState:o,...s,onMove:A,style:{width:"100%",...e},mapStyle:typeof O=="string"?O:O.toJS(),attributionControl:!1,reuseMaps:!0,preserveDrawingBuffer:!0,cursor:p,scrollZoom:!1,children:[I.jsx(g9,{mapRef:a,dateRange:x}),I.jsx("div",{className:"absolute top-0 left-0",children:I.jsx(pv,{compact:!0,onDateSelect:P,mapRef:a,dateRange:x})}),I.jsx(b9,{dateRange:x,mapRef:a}),I.jsx("div",{className:"absolute bottom-4 right-20 flex flex-col gap-4 items-end",style:{zIndex:3},children:I.jsx(D9,{mapRef:a})}),I.jsx(Fz,{mapRef:a,dateRange:x})]}),I.jsx(Bje,{})]})})})})}):I.jsx(ma,{})}var dFe={},C8={};(function(e){function t(A){"@babel/helpers - typeof";return t=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(E){return typeof E}:function(E){return E&&typeof Symbol=="function"&&E.constructor===Symbol&&E!==Symbol.prototype?"symbol":typeof E},t(A)}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=a(R),r=["dispose","reject","resolve"];function i(A){if(typeof WeakMap!="function")return null;var E=new WeakMap,P=new WeakMap;return(i=function(T){return T?P:E})(A)}function a(A,E){if(A&&A.__esModule)return A;if(A===null||t(A)!=="object"&&typeof A!="function")return{default:A};var P=i(E);if(P&&P.has(A))return P.get(A);var O={},T=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var k in A)if(k!=="default"&&Object.prototype.hasOwnProperty.call(A,k)){var N=T?Object.getOwnPropertyDescriptor(A,k):null;N&&(N.get||N.set)?Object.defineProperty(O,k,N):O[k]=A[k]}return O.default=A,P&&P.set(A,O),O}function o(){return o=Object.assign||function(A){for(var E=1;E<arguments.length;E++){var P=arguments[E];for(var O in P)Object.prototype.hasOwnProperty.call(P,O)&&(A[O]=P[O])}return A},o.apply(this,arguments)}function s(A,E){return y(A)||p(A,E)||h(A,E)||u()}function u(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1300
1300
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function h(A,E){if(A){if(typeof A=="string")return m(A,E);var P=Object.prototype.toString.call(A).slice(8,-1);if(P==="Object"&&A.constructor&&(P=A.constructor.name),P==="Map"||P==="Set")return Array.from(A);if(P==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(P))return m(A,E)}}function m(A,E){(E==null||E>A.length)&&(E=A.length);for(var P=0,O=new Array(E);P<E;P++)O[P]=A[P];return O}function p(A,E){var P=A==null?null:typeof Symbol<"u"&&A[Symbol.iterator]||A["@@iterator"];if(P!=null){var O=[],T=!0,k=!1,N,z;try{for(P=P.call(A);!(T=(N=P.next()).done)&&(O.push(N.value),!(E&&O.length===E));T=!0);}catch(q){k=!0,z=q}finally{try{!T&&P.return!=null&&P.return()}finally{if(k)throw z}}return O}}function y(A){if(Array.isArray(A))return A}function b(A,E){if(A==null)return{};var P=_(A,E),O,T;if(Object.getOwnPropertySymbols){var k=Object.getOwnPropertySymbols(A);for(T=0;T<k.length;T++)O=k[T],!(E.indexOf(O)>=0)&&Object.prototype.propertyIsEnumerable.call(A,O)&&(P[O]=A[O])}return P}function _(A,E){if(A==null)return{};var P={},O=Object.keys(A),T,k;for(k=0;k<O.length;k++)T=O[k],!(E.indexOf(T)>=0)&&(P[T]=A[T]);return P}var x=function(E){return function(P){var O=P.dispose,T=P.reject,k=P.resolve,N=b(P,r),z=(0,n.useState)(!0),q=s(z,2),H=q[0],V=q[1],U=function(){V(!1),O()},G=function(Y){V(!1),T(Y)},B=function(Y){V(!1),k(Y)};return n.default.createElement(E,o({cancel:G,dismiss:U,proceed:B,show:H},N))}},C=x;e.default=C})(C8);var M8={},Rx={},og={},lg=Gi;if(process.env.NODE_ENV==="production")og.createRoot=lg.createRoot,og.hydrateRoot=lg.hydrateRoot;else{var Bx=lg.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;og.createRoot=function(e,t){Bx.usingClientEntryPoint=!0;try{return lg.createRoot(e,t)}finally{Bx.usingClientEntryPoint=!1}},og.hydrateRoot=function(e,t,n){Bx.usingClientEntryPoint=!0;try{return lg.hydrateRoot(e,t,n)}finally{Bx.usingClientEntryPoint=!1}}}Object.defineProperty(Rx,"__esModule",{value:!0}),Rx.createDomTreeMounter=mFe;var hFe=pFe(R),fFe=og;function pFe(e){return e&&e.__esModule?e:{default:e}}function mFe(e){var t={},n={};function r(a,o,s){var u=Math.floor(Math.random()*1073741824).toString(16),h=(s||e||document.body).appendChild(document.createElement("div"));t[u]=h;var m=(0,fFe.createRoot)(h);return m.render(hFe.default.createElement(a,o)),n.mounted&&n.mounted(),u}function i(a){var o=t[a];delete t[a],o&&o.parentNode&&o.parentNode.removeChild(o)}return{mount:r,unmount:i,options:{}}}(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=e.createConfirmationCreater=void 0;var t=Rx;function n(s,u){var h=Object.keys(s);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(s);u&&(m=m.filter(function(p){return Object.getOwnPropertyDescriptor(s,p).enumerable})),h.push.apply(h,m)}return h}function r(s){for(var u=1;u<arguments.length;u++){var h=arguments[u]!=null?arguments[u]:{};u%2?n(Object(h),!0).forEach(function(m){i(s,m,h[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(h)):n(Object(h)).forEach(function(m){Object.defineProperty(s,m,Object.getOwnPropertyDescriptor(h,m))})}return s}function i(s,u,h){return u in s?Object.defineProperty(s,u,{value:h,enumerable:!0,configurable:!0,writable:!0}):s[u]=h,s}var a=function(u){return function(h){var m=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1e3,p=arguments.length>2?arguments[2]:void 0;return function(y){var b,_=new Promise(function(C,A){try{b=u.mount(h,r({reject:A,resolve:C,dispose:x},y),p)}catch(E){throw console.error(E),E}});function x(){setTimeout(function(){u.unmount(b)},m)}return _.then(function(C){return x(),C},function(C){return x(),Promise.reject(C)})}}};e.createConfirmationCreater=a;var o=a((0,t.createDomTreeMounter)());e.default=o})(M8);var $x={};function wT(e){"@babel/helpers - typeof";return wT=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},wT(e)}Object.defineProperty($x,"__esModule",{value:!0}),$x.createMountPoint=EFe,$x.createReactTreeMounter=MFe;var cg=yFe(R),gFe=Gi;function E8(e){if(typeof WeakMap!="function")return null;var t=new WeakMap,n=new WeakMap;return(E8=function(i){return i?n:t})(e)}function yFe(e,t){if(e&&e.__esModule)return e;if(e===null||wT(e)!=="object"&&typeof e!="function")return{default:e};var n=E8(t);if(n&&n.has(e))return n.get(e);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if(a!=="default"&&Object.prototype.hasOwnProperty.call(e,a)){var o=i?Object.getOwnPropertyDescriptor(e,a):null;o&&(o.get||o.set)?Object.defineProperty(r,a,o):r[a]=e[a]}return r.default=e,n&&n.set(e,r),r}function ST(){return ST=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ST.apply(this,arguments)}function T8(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function vFe(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?T8(Object(n),!0).forEach(function(r){bFe(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):T8(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function bFe(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function xFe(e,t){return CFe(e)||SFe(e,t)||wFe(e,t)||_Fe()}function _Fe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1301
1301
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function wFe(e,t){if(e){if(typeof e=="string")return A8(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return A8(e,t)}}function A8(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function SFe(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(u){a=!0,s=u}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function CFe(e){if(Array.isArray(e))return e}function MFe(e){var t={},n={};function r(o,s){var u=Math.floor(Math.random()*1073741824).toString(16);return t[u]={Component:o,props:s},n.mounted&&n.mounted(t),u}function i(o){delete t[o],n.mounted&&n.mounted(t)}function a(o){n.mounted=o}return{mount:r,unmount:i,options:{setMountedCallback:a,mountNode:e}}}function EFe(e){return function(){var t=(0,cg.useState)({}),n=xFe(t,2),r=n[0],i=n[1];(0,cg.useEffect)(function(){return e.options.setMountedCallback(function(o){i(vFe({},o))})},[]);var a=cg.default.createElement(cg.default.Fragment,null,Object.keys(r).map(function(o){var s=r[o],u=s.Component,h=s.props;return cg.default.createElement(u,ST({key:o},h))}));return e.options.mountNode&&(a=(0,gFe.createPortal)(a,e.options.mountNode)),a}}(function(e){function t(h){"@babel/helpers - typeof";return t=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(m){return typeof m}:function(m){return m&&typeof Symbol=="function"&&m.constructor===Symbol&&m!==Symbol.prototype?"symbol":typeof m},t(h)}Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"confirmable",{enumerable:!0,get:function(){return n.default}}),Object.defineProperty(e,"createConfirmation",{enumerable:!0,get:function(){return r.default}}),Object.defineProperty(e,"createConfirmationCreater",{enumerable:!0,get:function(){return r.createConfirmationCreater}}),Object.defineProperty(e,"createDomTreeMounter",{enumerable:!0,get:function(){return i.createDomTreeMounter}}),Object.defineProperty(e,"createMountPoint",{enumerable:!0,get:function(){return a.createMountPoint}}),Object.defineProperty(e,"createReactTreeMounter",{enumerable:!0,get:function(){return a.createReactTreeMounter}});var n=u(C8),r=s(M8),i=Rx,a=$x;function o(h){if(typeof WeakMap!="function")return null;var m=new WeakMap,p=new WeakMap;return(o=function(b){return b?p:m})(h)}function s(h,m){if(h.__esModule)return h;if(h===null||t(h)!=="object"&&typeof h!="function")return{default:h};var p=o(m);if(p&&p.has(h))return p.get(h);var y={},b=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var _ in h)if(_!=="default"&&Object.prototype.hasOwnProperty.call(h,_)){var x=b?Object.getOwnPropertyDescriptor(h,_):null;x&&(x.get||x.set)?Object.defineProperty(y,_,x):y[_]=h[_]}return y.default=h,p&&p.set(h,y),y}function u(h){return h&&h.__esModule?h:{default:h}}})(dFe);const TFe=R.forwardRef(({onClose:e,...t},n)=>I.jsx(ln,{ref:n,variant:"outline",size:"icon",onClick:e,...t,children:I.jsx(pa,{className:"w-5 h-5 action-icon"})})),I8=()=>{const{prompt:e="",isOpen:t=!0,proceed:n,cancel:r}=Yv(),i=()=>{r()};return I.jsx(Np,{open:t,onOpenChange:a=>{a||i()},children:I.jsxs(Lp,{children:[I.jsx(su,{className:"fixed inset-0 bg-black opacity-30 z-[1002]"}),I.jsxs(ou,{className:"fixed top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 bg-white dark:bg-gray-900 p-6 rounded shadow-lg z-[1002]",children:[I.jsx(So,{className:"text-lg font-bold dark:text-gray-200",children:"Warning"}),I.jsx(ac,{className:"mt-2 text-sm text-gray-600 dark:text-gray-200",children:e}),I.jsxs("div",{className:"mt-4 flex justify-end space-x-2",children:[I.jsx(ln,{variant:"outline",onClick:r,children:"Cancel"}),I.jsx(ln,{variant:"destructive",onClick:()=>n(!0),children:"delete"})]}),I.jsx(jp,{asChild:!0,children:I.jsx(TFe,{className:"absolute top-2 right-2"})})]})]})})};I8.propTypes={show:Pt.bool,proceed:Pt.func,confirmation:Pt.string,options:Pt.object};const AFe=R.createContext();function IFe({children:e,defaultTheme:t="system",storageKey:n="vite-ui-theme",...r}){const[i,a]=R.useState(()=>Gf(n)||t);R.useEffect(()=>{const s=document.documentElement;s.classList.remove("light","dark"),i==="system"&&s&&window.matchMedia("(prefers-color-scheme: dark)").matches,s.classList.add("light")},[i]),R.useEffect(()=>{const s=window.matchMedia("(prefers-color-scheme: dark)"),u=()=>a(s.matches?"dark":"light");return u(),s.addEventListener("change",u),()=>s.removeEventListener("change",u)},[]);const o={theme:"light",setTheme:s=>{fd(n,s),a(s)}};return I.jsx(AFe.Provider,{value:o,...r,children:e})}var PFe=(e,t,n,r,i,a,o,s)=>{let u=document.documentElement,h=["light","dark"];function m(b){(Array.isArray(e)?e:[e]).forEach(_=>{let x=_==="class",C=x&&a?i.map(A=>a[A]||A):i;x?(u.classList.remove(...C),u.classList.add(b)):u.setAttribute(_,b)}),p(b)}function p(b){s&&h.includes(b)&&(u.style.colorScheme=b)}function y(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)m(r);else try{let b=localStorage.getItem(t)||n,_=o&&b==="system"?y():b;m(_)}catch{}},OFe=ee.createContext(void 0),kFe={setTheme:e=>{},themes:[]},DFe=()=>{var e;return(e=ee.useContext(OFe))!=null?e:kFe};ee.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:i,defaultTheme:a,value:o,themes:s,nonce:u,scriptProps:h})=>{let m=JSON.stringify([n,t,a,e,s,o,r,i]).slice(1,-1);return ee.createElement("script",{...h,suppressHydrationWarning:!0,nonce:typeof window>"u"?u:"",dangerouslySetInnerHTML:{__html:`(${PFe.toString()})(${m})`}})});const NFe=({...e})=>{const{theme:t="system"}=DFe();return I.jsx(Xke,{theme:t,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...e})},LFe=()=>{try{return s1("agviewer_user_preferences")}catch(e){return console.error("Failed to get stored preferences:",e),{}}};function jFe(){const[e,t]=R.useState(!1),n=R.useRef(!1),r=R.useContext(Jm),i=(r==null?void 0:r.isVisible)??!1,a=r==null?void 0:r.setIsVisible,o=Tt(U=>U.setRasterOpacity),s=Tt(U=>U.setRasterLayer),u=Tt(U=>U.setViewMode),h=Tt(U=>U.setShowCroppedImages),m=Tt(U=>U.setDateRange),p=Tt(U=>U.setSidebarExpanded),y=Tt(U=>U.rasterOpacity),b=Tt(U=>U.rasterLayer),_=Tt(U=>U.viewMode),x=Tt(U=>U.showCroppedImages),C=Tt(U=>U.dateRange),A=Tt(U=>U.sidebarExpanded),E=R.useContext(Za),P=R.useContext(Zs),O=(E==null?void 0:E.showMarkers)??!0,T=E==null?void 0:E.setShowMarkers,k=(E==null?void 0:E.markerFilters)??{},N=E==null?void 0:E.setMarkerFilters,z=(P==null?void 0:P.showPlots)??!0,q=P==null?void 0:P.setShowPlots;return R.useEffect(()=>{if(!n.current){n.current=!0;try{const U=LFe();if(U&&(U.isRasterVisible!==void 0&&a&&a(U.isRasterVisible),U.rasterOpacity!==void 0&&o&&o(U.rasterOpacity),U.rasterLayer!==void 0&&s&&s(U.rasterLayer),U.viewMode!==void 0&&u&&u(U.viewMode),U.showCroppedImages!==void 0&&h&&h(U.showCroppedImages),U.dateRange!==void 0&&m&&m(U.dateRange),U.sidebarExpanded!==void 0&&p&&p(U.sidebarExpanded),U.showMarkers!==void 0&&T&&T(U.showMarkers),U.showPlots!==void 0&&q&&q(U.showPlots),U.markerFilters!==void 0&&N)){const G={type:U.markerFilters.type||"",paw_status:U.markerFilters.paw_status||"",farm_id:U.markerFilters.farm_id||"",batteryLevel:U.markerFilters.batteryLevel||null};console.log("Loading markerFilters from local storage:",G),N(G)}}catch(U){console.error("Failed to load user preferences:",U)}finally{t(!0)}}},[]),R.useEffect(()=>{if(e)try{o1("agviewer_user_preferences",{rasterOpacity:y,rasterLayer:b,viewMode:_,showCroppedImages:x,dateRange:C,sidebarExpanded:A,showMarkers:O,showPlots:z,isRasterVisible:i,markerFilters:k}),console.log("Saved preferences to localStorage")}catch(U){console.error("Failed to save user preferences:",U)}},[e,y,b,_,x,C,A,O,z,i,JSON.stringify(k)]),{initialized:e,saveCurrentPreferences:()=>{try{return o1("agviewer_user_preferences",{rasterOpacity:y,rasterLayer:b,viewMode:_,showCroppedImages:x,dateRange:C,sidebarExpanded:A,showMarkers:O,showPlots:z,isRasterVisible:i,markerFilters:k}),!0}catch(U){return console.error("Failed to manually save user preferences:",U),!1}},clearSavedPreferences:()=>{try{return py("agviewer_user_preferences"),!0}catch(U){return console.error("Failed to clear user preferences:",U),!1}}}}const FFe=R.createContext();function P8({children:e}){const t=jFe();return I.jsx(FFe.Provider,{value:t,children:e})}P8.propTypes={children:Pt.node.isRequired};const RFe={"app.agviewer_map.name":"Name","app.agviewer_map.station_label":"Station (device)","app.agviewer_map.farm_label":"Farm","app.agviewer_map.paw_graphs_label":"Paw Graphs","app.agviewer_map.more_graphs_label":"More Graphs","app.agviewer_map.latitude_label":"Latitude","app.agviewer_map.longitude_label":"Longitude","app.agviewer_map.diff_coords":"Use different coordinates","app.agviewer_map.use_custom_coordinates":"Use marker's coordinates","app.agviewer_map.cancel":"Cancel","app.agviewer_map.loading":"Loading...","app.agviewer_map.add_marker":"Add Marker","app.agviewer_map.all":"All","app.agviewer_map.optimal":"Optimal","app.agviewer_map.stress_start":"Stress Start","app.agviewer_map.severe_stress":"Severe Stress","app.agviewer_map.excess_water":"Excess Water","app.agviewer_map.stations":"Stations","app.agviewer_map.station":"Station","app.agviewer_map.forecast":"Forecast","app.agviewer_map.hide_markers":"Hide Markers","app.agviewer_map.show_markers":"Show Markers","app.agviewer_map.paw_status":"PAW Status","app.agviewer_map.select_status":"Select status","app.agviewer_map.farm":"Farm","app.agviewer_map.select_farm":"Select farm","app.agviewer_map.plots":"Plots","app.agviewer_map.hide_plots":"Hide Plots","app.agviewer_map.show_plots":"Show Plots","app.agviewer_map.delete_marker_confirm_message":"Do you want to delete this marker?","app.agviewer_map.find_station":"Find Station","app.agviewer_map.search_station":"Search Station","app.agviewer_map.focus_marker":"Focus on the marker","app.agviewer_map.delete_marker":"Delete Marker","app.agviewer_map.no_station_found":"No Station Found","app.agviewer_map.search_plots":"Search Plots","app.agviewer_map.focus_plot":"Focus on the plot","app.agviewer_map.delete_plot":"Delete plot","app.agviewer_map.no_plot_found":"No Plots Found for keyword:","app.agviewer_map.no_plots":"No Plots Available","app.agviewer_map.farm_success_message":"Farm Has been created successfully","app.agviewer_map.add_new_farm":"Add New Farm","app.agviewer_map.markers":"Markers","app.agviewer_map.add_farm":"Add Farm","app.agviewer_map.plot_success_message":"Plot created successfully","app.agviewer_map.plot_failed_message":"Could not create the plot","app.agviewer_map.add_new_plot":"Add New Plot","app.agviewer_map.create_plot":"Create Plot","app.agviewer_map.saving_changes":"Saving changes","app.agviewer_map.changes_saved_successfully":"Changes saved successfully","app.agviewer_map.edit_plot":"Edit plot","app.agviewer_map.save_changes":"Save Changes","app.agviewer_map.add_new_marker":"Add New Marker","app.agviewer_map.associated_device":"Associated Station (Device)","app.agviewer_map.sat_et":"Sat-ET","app.agviewer_map.disable_sat_et":"Disable Sat-ET","app.agviewer_map.enable_sat_et":"Enable Sat-ET","app.agviewer_map.change_shape":"Change Shape","app.agviewer_map.submitting":"Submitting...","app.agviewer_map.edit_marker":"Edit Marker","app.agviewer_map.change_view_mode":"Change view mode","app.agviewer_map.add_view_plot":"Add new plot","app.agviewer_map.add_new_station":"Add new station","app.agviewer_map.add_new_farm_title":"Add new farm","app.agviewer_map.restart_tour":"Restart User Guide","app.agviewer_map.date_selector":"Date Selector","app.agviewer_map.select_date":"Select Date","app.agviewer_map.available_days":"Available Days","app.agviewer_map.configurations":"Configurations","app.agviewer_map.raster_layer":"Raster Layer","app.agviewer_map.plot":"Plot","app.agviewer_map.map":"Map","app.agviewer_map.hide_layer":"Hide Layer","app.agviewer_map.show_layer":"Show Layer","app.agviewer_map.opacity":"Opacity","app.agviewer_map.layer_type":"Layer Type","app.agviewer_map.or_select_from_list":"OR SELECT FROM LIST","app.agviewer_map.plot_task_status":"Click the info icon or plot area to view the plot and task status for {plotName}.","app.agviewer_map.activate_picker_mode":"Activate picker mode","app.agviewer_map.plot_deletion_confirm_message":"Do you want to delete this plot?","app.agviewer_map.delete":"Delete","app.agviewer_map.close":"Close","app.agviewer_map.area":"Area ({unit})","app.agviewer_map.sat-et":"SAT-ET","app.agviewer_map.battery":"Battery","app.agviewer_map.avg_paw":"Average PAW","app.agviewer_map.crop":"Crop","app.agviewer_map.min":"min","app.agviewer_map.max":"max","app.agviewer_map.avg":"avg","app.agviewer_map.water":"water","app.agviewer_map.bare_soil":"Bare Soil","app.agviewer_map.low_vegetation":"Low Vegetation","app.agviewer_map.moderate_vegetation":"Moderate Vegetation","app.agviewer_map.healthy_vegetation":"Healthy Vegetation","app.agviewer_map.very_healthy_vegetation":"Very Healthy Vegetation","app.agviewer_map.dense_vegetation":"Dense Vegetation","app.agviewer_map.water_bodies":"Water Bodies","app.agviewer_map.sparse_vegetation":"Sparse Vegetation","app.agviewer_map.light_vegetation":"light veg","app.agviewer_map.irrigated":"irrigated","app.agviewer_map.very_low_et":"very low ET","app.agviewer_map.low_et":"low ET","app.agviewer_map.moderate_et":"moderate ET","app.agviewer_map.high_et":"high ET","app.agviewer_map.very_high_et":"very high ET","app.agviewer_map.ndvi":"NDVI","app.agviewer_map.evapotranspiration":"Evapotranspiration","app.agviewer_map.avg_et":"Avg ET","app.agviewer_map.avg_et_eto":"Avg ET + ETo","app.agviewer_map.min_et":"Min ET","app.agviewer_map.max_et":"Max ET","app.agviewer_map.std_dev":"StdDev","app.agviewer_map.eto_only":"ETo Only (Max ET)","app.agviewer_map.no_et_data_available":"No ET data available for selected date range","app.agviewer_map.very_dry":"Very Dry","app.agviewer_map.dry":"Dry","app.agviewer_map.moderate_moisture":"Moderate Moisture","app.agviewer_map.high_moisture":"High Moisture","app.agviewer_map.very_high_moisture":"Very High Moisture","app.agviewer_map.saturated":"Saturated","app.agviewer_map.water_body":"Water Body","app.agviewer_map.very_low":"Very Low","app.agviewer_map.low":"Low","app.agviewer_map.moderate":"Moderate","app.agviewer_map.high":"High","app.agviewer_map.very_high":"Very High","app.datelist.today":"Today","app.datelist.loading_more":"Loading more dates...","app.datelist.selected":"Selected:","app.agviewer_map.time_period":"Time Period:","app.agviewer_map.time_period_daily":"Daily","app.agviewer_map.time_period_weekly":"Weekly","app.agviewer_map.time_period_monthly":"Monthly"};function BFe({children:e}){let t=!0;try{Dr()}catch{t=!1}return t?e:I.jsx(eK,{locale:"en",messages:RFe,children:e})}function O8({style:e,configs:t,markers:n,authToken:r}){return R.useEffect(()=>{r&&TY({Authorization:r})},[r]),I.jsx(R$,{children:I.jsx(BFe,{children:I.jsx(IFe,{defaultTheme:"light",children:I.jsx(bN,{delayDuration:200,children:I.jsx(DY,{children:I.jsx(Dle,{children:I.jsx(mP,{configs:t,children:I.jsx(GLe,{children:I.jsx(sE,{children:I.jsx(cS,{providedMarkers:n,children:I.jsx(P8,{children:I.jsxs(_8,{children:[I.jsx(uFe,{style:e,configs:t}),I.jsx(NFe,{richColors:!0}),I.jsx(I8,{})]})})})})})})})})})})})})}O8.propTypes={style:Pt.object,configs:Pt.object,markers:Pt.array,authToken:Pt.string};const $Fe=e=>I.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:20,viewBox:"0 0 20 20",fill:"none",...e,children:[I.jsx("path",{stroke:"#373737",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"m5.833 14.167 8.334-8.334"}),I.jsx("path",{stroke:"#000",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5.833 5.833h8.334v8.334"})]}),zFe=({marker:e,markerId:t,buttonClassName:n=""})=>{const[r,i]=R.useState(!1),{handleMarkerUpdate:a}=R.useContext(Za),o=Dr(),s=R.useCallback(()=>{i(h=>!h)},[]),u=h=>(console.log("data after editing",h),console.log("data before editing",e),a(h));return I.jsx(rl,{trigger:I.jsx(ln,{variant:"outline",size:"icon",tabIndex:-1,children:I.jsx(vs,{text:o.formatMessage({id:"app.agviewer_map.edit_marker",defaultMessage:"Edit Marker"}),children:I.jsx(uS,{className:"w-5 h-5 action-icon"})})}),title:o.formatMessage({id:"app.agviewer_map.edit_marker",defaultMessage:"Edit Marker"}),open:r,setOpen:i,headerClassName:"m-4",onClose:s,children:I.jsx(lu,{children:I.jsx(e2,{marker:e,onSubmit:u,onCancel:s,submitButtonText:o.formatMessage({id:"app.agviewer_map.save_changes",defaultMessage:"Save Changes"})})})})},VFe=({marker:e,onMarkerClick:t,onDeleteMarker:n,markersData:r,intl:i})=>I.jsx("div",{className:"marker-item rounded-md hover:bg-gray-50 dark:hover:bg-gray-700 p-2 mb-2",children:I.jsx("div",{className:"marker-item-info",children:I.jsxs("div",{className:"flex justify-between items-center gap-2",children:[I.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[I.jsx(Ry,{className:"h-4 w-4 text-primary flex-shrink-0"}),I.jsx("h5",{className:"text-sm font-medium text-gray-800 dark:text-gray-200 break-words leading-tight",children:e==null?void 0:e.title})]}),I.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[I.jsx(vs,{text:i.formatMessage({id:"app.agviewer_map.focus_marker",defaultMessage:"Focus on the marker"}),children:I.jsx(Fp,{variant:"icon",className:"rounded-full p-1 hover:bg-gray-100 dark:hover:bg-gray-600",onClick:a=>t(a,e),"data-marker-id":e.id,children:I.jsx($Fe,{className:"w-4 h-4"})})}),I.jsx(vs,{text:i.formatMessage({id:"app.agviewer_map.delete_marker",defaultMessage:"Delete Marker"}),children:I.jsx(Fp,{variant:"icon",className:"rounded-full p-1 hover:bg-gray-100 dark:hover:bg-gray-600",onClick:a=>n(a,e),"data-marker-id":e.id,children:I.jsx($y,{className:"w-4 h-4 text-red-500"})})}),I.jsx(zFe,{marker:r.find(a=>a.id===e.id)})]})]})})});function GFe({markersData:e,loading:t,handleDeleteMarker:n,onMarkerClick:r,onClose:i,intl:a}){const[o,s]=R.useState(""),[u,h]=R.useState(""),[m,p]=R.useState(!1),[y,b]=R.useState(20),[_,x]=R.useState(!1),C=R.useRef(null),A=R.useCallback(Gd(H=>{h(H),p(!1)},300),[]),E=R.useCallback(H=>{const V=H.target.value;s(V),p(!0),A(V)},[A]),P=R.useMemo(()=>!e||e.length===0?[]:e.map(H=>kp(H)),[e]),O=R.useMemo(()=>{if(!u)return P;const H=u.toLowerCase();return P.filter(V=>{var U,G;return(G=(U=V==null?void 0:V.title)==null?void 0:U.toLowerCase())==null?void 0:G.includes(H)})},[P,u]),T=R.useMemo(()=>O.slice(0,y),[O,y]);R.useEffect(()=>{b(20)},[u]);const k=R.useCallback(()=>{_||y>=O.length||(x(!0),setTimeout(()=>{b(H=>Math.min(H+20,O.length)),x(!1)},300))},[_,y,O.length]),N=R.useCallback(H=>{const{scrollTop:V,scrollHeight:U,clientHeight:G}=H.target;V+G>=U-100&&!_&&y<O.length&&k()},[k,_,y,O.length]),z=R.useCallback((H,V)=>{r(H,V),i()},[r,i]),q=R.useCallback((H,V)=>{n(H,V)},[n]);return t?I.jsx("div",{className:"flex justify-center items-center h-40",children:I.jsx(ma,{})}):I.jsxs("div",{className:"w-full",children:[I.jsxs("div",{className:"relative mb-4",children:[I.jsx(By,{className:"w-4 h-4 text-gray-500 absolute left-3 top-1/2 transform -translate-y-1/2"}),I.jsx(oc,{className:"pl-9 w-full text-sm h-9",placeholder:a.formatMessage({id:"app.agviewer_map.search_station",defaultMessage:"Search Station"}),value:o,onChange:E}),m&&I.jsx("div",{className:"absolute right-3 top-1/2 transform -translate-y-1/2",children:I.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-primary"})})]}),I.jsx("div",{ref:C,className:"overflow-y-auto h-[350px]",onScroll:N,children:O.length===0?I.jsx("div",{className:"flex items-center justify-center h-20 p-4",children:I.jsx("h5",{className:"text-sm text-gray-500 dark:text-gray-400",children:o?a.formatMessage({id:"app.agviewer_map.no_station_found",defaultMessage:"No Station Found"}):a.formatMessage({id:"app.agviewer_map.no_station_found",defaultMessage:"No Station Found"})})}):I.jsxs(I.Fragment,{children:[T.map(H=>I.jsx(VFe,{marker:H,onMarkerClick:z,onDeleteMarker:q,markersData:e,intl:a},H.id)),_&&I.jsx("div",{className:"flex justify-center items-center py-4",children:I.jsxs("div",{className:"flex items-center gap-2",children:[I.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-primary"}),I.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Loading more..."})]})}),y>=O.length&&O.length>0&&I.jsx("div",{className:"flex justify-center items-center py-4",children:I.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:a.formatMessage({id:"app.agviewer_map.all_results_loaded",defaultMessage:"All results loaded"})})})]})})]})}const WFe=Object.freeze(Object.defineProperty({__proto__:null,default:GFe},Symbol.toStringTag,{value:"Module"}));Ta.AgvMap=O8,Object.defineProperty(Ta,Symbol.toStringTag,{value:"Module"})});
@@ -79567,7 +79567,7 @@ const MBe = ({ width: e = 24, height: t = 24, fill: n = "#000" }) => /* @__PURE_
79567
79567
  /* @__PURE__ */ P.jsx("path", { d: "M25.6006,21.8008l-1.2012-1.6a9.001,9.001,0,0,0,0-14.4019l1.2012-1.6a11.002,11.002,0,0,1,0,17.6011Z" })
79568
79568
  ]
79569
79569
  }
79570
- ), EBe = IW(() => import("./LazyModalContent-DvHhh5a7.js"));
79570
+ ), EBe = IW(() => import("./LazyModalContent-s5BR1Vdi.js"));
79571
79571
  function TBe({
79572
79572
  activePanel: e,
79573
79573
  togglePanel: t,
@@ -81283,6 +81283,7 @@ function NBe({ style: e, configs: t, markers: n }) {
81283
81283
  reuseMaps: !0,
81284
81284
  preserveDrawingBuffer: !0,
81285
81285
  cursor: p,
81286
+ scrollZoom: !1,
81286
81287
  children: [
81287
81288
  /* @__PURE__ */ P.jsx(H3, { mapRef: i, dateRange: b }),
81288
81289
  m == hs.NORMAL && /* @__PURE__ */ P.jsx(OBe, { mapRef: i }),
@@ -81364,6 +81365,7 @@ function NBe({ style: e, configs: t, markers: n }) {
81364
81365
  reuseMaps: !0,
81365
81366
  preserveDrawingBuffer: !0,
81366
81367
  cursor: p,
81368
+ scrollZoom: !1,
81367
81369
  children: [
81368
81370
  /* @__PURE__ */ P.jsx(H3, { mapRef: a, dateRange: x }),
81369
81371
  /* @__PURE__ */ P.jsx("div", { className: "absolute top-0 left-0", children: /* @__PURE__ */ P.jsx(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agviewermap-react",
3
- "version": "0.1.24",
3
+ "version": "0.1.25",
4
4
  "type": "module",
5
5
  "main": "dist/agviewermap-react.umd.cjs",
6
6
  "module": "dist/agviewermap-react.js",