PageSourceSearch

https://hintermoos.at/assets/OwnersMonitoring-Cf7wdHO6.js

js hintermoos.at collected 2026-10-09 22:01:55 UTC 35,598 bytes, 7 lines download raw bytes

1import{c as Se,Y as se,s as ne,u as W,r as f,j as e,w as ee,x as te,G as A,H as $,J as z,K as xe,N as he,B as ue,X as De,T as ke,k as ae,Z as Me,m as Fe}from"./index-MoAbC8_9.js";import{O as Te}from"./OwnersLayout-Cd0M3dw8.js";import{E as Ae}from"./exceljs.min-Bp1_LhuQ.js";import{C as $e,a as ze,b as Ee}from"./collapsible-BIxz44zB.js";import{B as Pe}from"./breadcrumb-CmKLwRya.js";import{B as le}from"./badge-BHbYeRgi.js";import{S as Be}from"./scroll-area-CoT3wSM0.js";import{C as V}from"./circle-help-BFmb_2uk.js";import{R as Ie,C as Oe,X as Re,Y as Ye,T as He}from"./generateCategoricalChart-C2b_mvpD.js";import{L as Ve}from"./LineChart-CgmaZj2v.js";import{L as fe}from"./Line-DFydwSLz.js";import{C as We,M as Ge}from"./Header-CnJGZ8vQ.js";import{I as ge}from"./info-CZr0REZX.js";import{T as qe}from"./trending-down-EHPUNHPt.js";import{C as Ke}from"./calendar-CnsXUgOr.js";import{F as Ue}from"./file-spreadsheet-DYxjeH4g.js";import"./separator-CQ84aZ0V.js";import"./skeleton-ClxqB572.js";import"./switch-BHj3-8MN.js";import"./index-D9-GACGG.js";import"./house-DjS1WMqx.js";import"./receipt-DnGXta2k.js";import"./building-crte1H4H.js";import"./file-text-Bif0RP8Y.js";import"./user-Cvsz7Lm_.js";import"./chart-column-Bo5i9GGE.js";import"./upload-BH1HltYO.js";import"./piggy-bank-DP-A2O0m.js";import"./landmark-C0TkBs1l.js";import"./flame-wMx8KIS8.js";import"./trending-up-Cg9WFJWB.js";import"./users-xui-UtA1.js";import"./euro-Cc6O9qjZ.js";import"./eye-DKrvAixa.js";import"./dialog-DrI7Oddz.js";import"./tabs-5EVsfllK.js";import"./textarea-4z16PwID.js";import"./mountain-BHfTfCFy.js";import"./index-BdQq_4o_.js";import"./index-Dh4i1-J3.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const Xe=Se("Map",[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]]),B={title:{cs:"Monitoring sedání budovy",de:"Setzungsmonitoring des Gebäudes",en:"Building settlement monitoring"},cum:{cs:"Kumulativní změna",de:"Kumulative Änderung",en:"Cumulative change"},int:{cs:"Změna od předchozího",de:"Änderung seit Vormessung",en:"Change since previous"},abs:{cs:"Absolutní hodnoty",de:"Absolutwerte",en:"Absolute values"},point:{cs:"Bod",de:"Punkt",en:"Point"},area:{cs:"Oblast",de:"Bereich",en:"Area"},status:{cs:"Stav",de:"Status",en:"Status"},unit:{cs:"Hodnoty v mm. Záporné = pokles.",de:"Werte in mm. Negativ = Setzung.",en:"Values in mm. Negative = settlement."},legend:{cs:"Legenda",de:"Legende",en:"Legend"},missing:{cs:"bez dat",de:"keine Daten",en:"no data"},created:{cs:"Vytvořeno",de:"Erstellt",en:"Created"}},ye=[{max:-50,fill:"FFF87171",label:"< -50 mm"},{max:-30,fill:"FFFB923C",label:"-30 … -50 mm"},{max:-10,fill:"FFFACC15",label:"-10 … -30 mm"},{max:1/0,fill:"FF86EFAC",label:"0 … -10 mm"}],Ze=t=>ye.find(n=>t<=n.max).fill,oe={style:"thin",color:{argb:"FFD1D5DB"}},de={top:oe,left:oe,bottom:oe,right:oe};async function Qe(t){const{lang:n,points:i,areas:d,campaigns:m,measurements:h}=t,y=new Ae.Workbook,x=new Map(h.map(g=>[`${g.point_id}|${g.campaign_id}`,g])),_=g=>{const D=d.find(S=>S.id===g);return D?(n==="cs"?D.name_cs:n==="en"?D.name_en:null)||D.name:""},s=g=>g?n==="cs"?g:g.replace(/^Výchozí měření/i,n==="de"?"Nullmessung":"Baseline").replace(/^Měření/i,n==="de"?"Messung":"Survey"):"",j={active:{cs:"aktivní",de:"aktiv",en:"active"},lost:{cs:"ztracený",de:"verloren",en:"lost"},historical:{cs:"historický",de:"historisch",en:"historical"},planned:{cs:"plánovaný",de:"geplant",en:"planned"}},N=g=>new Date(g.measured_at).toLocaleDateString(n==="cs"?"cs-CZ":n==="de"?"de-AT":"en-GB"),k=(g,D,S)=>{const a=y.addWorksheet(g,{views:[{state:"frozen",xSplit:3,ySplit:4}]}),w=3+m.length;a.mergeCells(1,1,1,w),Object.assign(a.getCell(1,1),{value:`${B.title[n]} – ${g}`}),a.getCell(1,1).font={name:"Arial",size:14,bold:!0,color:{argb:"FF1F3A2E"}},a.mergeCells(2,1,2,w),a.getCell(2,1).value=`${B.unit[n]}  ${B.created[n]}: ${new Date().toLocaleDateString()}`,a.getCell(2,1).font={name:"Arial",size:9,italic:!0,color:{argb:"FF6B7280"}};const T=a.getRow(4);[B.point[n],B.area[n],B.status[n],...m.map(u=>`${s(u.label)}
7${N(u)}
7`)].forEach((u,c)=>{const l=T.getCell(c+1);l.value=u,l.font={name:"Arial",bold:!0,size:10,color:{argb:"FFFFFFFF"}},l.fill={type:"pattern",pattern:"solid",fgColor:{argb:"FF2F5D45"}},l.alignment={horizontal:"center",vertical:"middle",wrapText:!0},l.border=de}),T.height=46,i.forEach((u,c)=>{var r;const l=a.getRow(5+c);l.getCell(1).value=u.code,l.getCell(1).font={name:"Arial",bold:!0,size:10},l.getCell(2).value=_(u.area_id),l.getCell(3).value=((r=j[u.status])==null?void 0:r[n])||u.status,m.forEach((p,C)=>{var G;const M=l.getCell(4+C),Y=(G=x.get(`${u.id}|${p.id}`))==null?void 0:G[D];Y==null?(M.value="—",M.font={name:"Arial",size:10,color:{argb:"FF9CA3AF"}}):(M.value=Number(Y),M.numFmt="0.0;-0.0;0.0",M.font={name:"Arial",size:10},S&&(M.fill={type:"pattern",pattern:"solid",fgColor:{argb:Ze(Number(Y))}})),M.alignment={horizontal:"center"}});for(let p=1;p<=w;p++){const C=l.getCell(p);C.border=de,p<=3&&(C.font={...C.font||{},name:"Arial",size:10},c%2&&(C.fill={type:"pattern",pattern:"solid",fgColor:{argb:"FFF3F4F6"}}))}}),a.getColumn(1).width=10,a.getColumn(2).width=18,a.getColumn(3).width=11;for(let u=4;u<=w;u++)a.getColumn(u).width=14;if(S){let u=6+i.length;a.getCell(u,1).value=B.legend[n],a.getCell(u,1).font={name:"Arial",bold:!0,size:10},[...ye].reverse().forEach(c=>{u++,a.getCell(u,1).fill={type:"pattern",pattern:"solid",fgColor:{argb:c.fill}},a.getCell(u,1).border=de,a.getCell(u,2).value=c.label,a.getCell(u,2).font={name:"Arial",size:9}}),u++,a.getCell(u,1).value="—",a.getCell(u,2).value=B.missing[n],a.getCell(u,2).font={name:"Arial",size:9}}a.pageSetup={orientation:"landscape",fitToPage:!0,fitToWidth:1,fitToHeight:0}};k(B.cum[n],"delta_from_baseline_mm",!0),k(B.int[n],"delta_from_previous_mm",!0),k(B.abs[n],"absolute_value_mm",!1);const L=await y.xlsx.writeBuffer(),v=URL.createObjectURL(new Blob([L],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})),b=document.createElement("a");b.href=v,b.download=`monitoring-${new Date().toISOString().slice(0,10)}.xlsx`,b.click(),URL.revokeObjectURL(v)}function Je(){return se({queryKey:["monitoring-areas"],queryFn:async()=>{const{data:t,error:n}=await ne.from("monitoring_areas").select("*").order("sort_order");if(n)throw n;return t}})}function et(){return se({queryKey:["monitoring-points"],queryFn:async()=>{const{data:t,error:n}=await ne.from("monitoring_points").select("*").order("display_order");if(n)throw n;return t}})}function tt(){return se({queryKey:["measurement-campaigns"],queryFn:async()=>{const{data:t,error:n}=await ne.from("measurement_campaigns").select("*").order("measured_at");if(n)throw n;return t}})}function st(){return se({queryKey:["monitoring-measurements"],queryFn:async()=>{const{data:t,error:n}=await ne.from("monitoring_measurements").select("*");if(n)throw n;return t}})}function nt(){return se({queryKey:["monitoring-plan"],queryFn:async()=>{const{data:t,error:n}=await ne.from("monitoring_plans").select("*").eq("is_active",!0).limit(1).maybeSingle();if(n)throw n;return t}})}const rt=[{max:-50,color:"#ef4444",label:"> -50 mm"},{max:-30,color:"#f97316",label:"-30 to -50 mm"},{max:-10,color:"#eab308",label:"-10 to -30 mm"},{max:0,color:"#22c55e",label:"0 to -10 mm"}];function we(t,n){if(t==null)return"#9ca3af";const d=[...rt].sort((m,h)=>m.max-h.max);for(const m of d)if(t<=m.max)return m.color;return"#22c55e"}function Ce(t){switch(t){case"active":return"#22c55e";case"lost":return"#9ca3af";case"historical":return"#6b7280";case"planned":return"#3b82f6";default:return"#9ca3af"}}const Z=730,Q=1470,at="/floorplan-monitoring.svg",H={x1:20,y1:170,x2:700,y2:1120},pe=(t,n)=>t>1?t:t*n,J=(t,...n)=>t.replace(/\{(\d+)\}/g,(i,d)=>String(n[Number(d)])),be=({points:t,plan:n,activeCampaign:i,campaigns:d,measurementsByPoint:m,getPointValue:h,selectedPointId:y,onPointSelect:x,viewMode:_})=>{const{t:s,language:j}=W(),N=j==="de"?"de-DE":j==="cs"?"cs-CZ":"en-GB",k=o=>j==="cs"?o:o.replace(/^Výchozí měření/i,s("mon.campaignLabelBaseline")).replace(/^Měření/i,s("mon.campaignLabelMeasurement")),L={active:s("mon.statusActive"),lost:s("mon.statusLost"),historical:s("mon.statusHistorical"),planned:s("mon.statusPlanned")},v=f.useRef(null),[b,g]=f.useState(1),[D,S]=f.useState({x:0,y:0}),[a,w]=f.useState(!1),[T,u]=f.useState({x:0,y:0}),[c,l]=f.useState(!1),[r,p]=f.useState("building"),C=f.useCallback(()=>
7{if(!v.current)return;const o=v.current.getBoundingClientRect(),E=H.x2-H.x1,F=H.y2-H.y1,P=Math.min(o.width/Z,o.height/Q),q=Z*P,I=Q*P,K=(o.width-q)/2,U=(o.height-I)/2,re=Math.min(o.width/(E*P),o.height/(F*P)),R=Math.min(4,Math.max(.5,re)),X=K+(H.x1+H.x2)/2*P,ce=U+(H.y1+H.y2)/2*P,_e=o.width/2-X*R,Le=o.height/2-ce*R;g(R),S({x:_e,y:Le})},[]);f.useEffect(()=>{!c&&v.current&&requestAnimationFrame(()=>{C(),l(!0)})},[c,C]);const M=f.useCallback(o=>{o.preventDefault();const E=o.deltaY>0?.9:1.1;g(F=>Math.max(.5,Math.min(4,F*E))),p("manual")},[]),Y=f.useCallback(o=>{o.button===0&&(w(!0),u({x:o.clientX-D.x,y:o.clientY-D.y}))},[D]),G=f.useCallback(o=>{a&&S({x:o.clientX-T.x,y:o.clientY-T.y})},[a,T]),O=f.useCallback(()=>{w(!1)},[]),ie=f.useMemo(()=>{const o=new Map;for(const E of t){const F=m.get(E.id);if(!F)continue;const P=Array.from(F.keys()),q=d.filter(I=>P.includes(I.id)).map(I=>new Date(I.measured_at).getFullYear());q.length>0&&o.set(E.id,Math.max(...q))}return o},[t,d,m]);return e.jsx(ee,{className:"overflow-hidden",children:e.jsx(te,{className:"p-0",children:e.jsxs("div",{ref:v,className:"relative overflow-hidden bg-muted/30 cursor-grab active:cursor-grabbing",style:{height:"600px"},onWheel:M,onMouseDown:Y,onMouseMove:G,onMouseUp:O,onMouseLeave:O,children:[e.jsx("div",{style:{transform:`translate(${D.x}px, ${D.y}px) scale(${b})`,transformOrigin:"0 0",transition:a?"none":"transform 0.15s ease-out",position:"relative",width:"100%",height:"100%"},children:e.jsxs("svg",{viewBox:`0 0 ${Z} ${Q}`,className:"w-full h-full",style:{maxHeight:"100%"},preserveAspectRatio:"xMidYMid meet",children:[e.jsx("image",{href:at,x:"0",y:"0",width:Z,height:Q,preserveAspectRatio:"none",pointerEvents:"none"}),t.map(o=>{const E=h(o.id),F=o.status==="lost"||o.status==="historical",P=F?Ce(o.status):we(E),q=o.id===y,I=pe(Number(o.x),Z),K=pe(Number(o.y),Q),U=q?20:16,re=ie.get(o.id),R=[J(s("mon.tooltipPoint"),o.code),J(s("mon.tooltipStatus"),L[o.status]||o.status)];return i&&R.push(J(s("mon.tooltipMeasurement"),k(i.label||new Date(i.measured_at).toLocaleDateString(N)))),E!==null?R.push(J(s("mon.tooltipValue"),E.toFixed(1))):F||R.push(s("mon.tooltipNoData")),F&&re&&R.push(J(s("mon.tooltipHistorical"),re)),e.jsxs(A,{children:[e.jsx($,{asChild:!0,children:e.jsxs("g",{style:{cursor:"pointer"},onClick:X=>{X.stopPropagation(),x(o.id===y?null:o.id)},children:[q&&e.jsx("circle",{cx:I,cy:K,r:U+5,fill:"none",stroke:"hsl(var(--primary))",strokeWidth:2.5,className:"animate-pulse"}),e.jsx("circle",{cx:I,cy:K,r:U,fill:P,fillOpacity:F?.4:.85,stroke:F?"hsl(var(--muted-foreground))":P,strokeWidth:F?1.5:2,strokeDasharray:F?"5 3":"none"}),e.jsx("text",{x:I,y:K,textAnchor:"middle",dominantBaseline:"central",fill:"white",fontSize:11,fontWeight:"bold",style:{pointerEvents:"none"},children:o.code}),E!==null&&!F&&e.jsxs("text",{x:I,y:K+U+12,textAnchor:"middle",fill:"hsl(var(--foreground))",fontSize:10,fontWeight:"600",style:{pointerEvents:"none"},children:[E.toFixed(1)," mm"]})]})}),e.jsx(z,{side:"top",className:"text-xs space-y-0.5 max-w-[200px]",children:R.map((X,ce)=>e.jsx("p",{children:X},ce))})]},o.id)})]})}),e.jsxs("div",{className:"absolute bottom-3 right-3 flex flex-col gap-1",children:[e.jsx("button",{onClick:()=>{g(o=>Math.min(4,o*1.2)),p("manual")},className:"w-8 h-8 bg-background border rounded-md flex items-center justify-center text-sm font-bold hover:bg-muted",children:"+"}),e.jsx("button",{onClick:()=>{g(o=>Math.max(.5,o/1.2)),p("manual")},className:"w-8 h-8 bg-background border rounded-md flex items-center justify-center text-sm font-bold hover:bg-muted",children:"−"}),e.jsx("button",{onClick:()=>{g(1),S({x:0,y:0}),p("reset")},className:`w-8 h-8 border rounded-md flex items-center justify-center text-xs hover:bg-muted ${r==="reset"?"bg-primary text-primary-foreground border-primary":"bg-background"}`,children:"⟲"}),e.jsx("button",{onClick:()=>{C(),p("building")},className:`w-8 h-8 border rounded-md flex items-center justify-center hover:bg-muted ${r==="building"?"bg-primary text-primary-foreground border-primary":"bg-background"}`,title:"Focus on building",children:e.jsx(Pe,{className:"h-4 w-4"})})]}),i&&e.jsxs(A,{children:[e.jsx($,{asChild:!0,children:e.jsxs("div",{className:"absolute top-3 left-3 bg-background/95 border rounded-lg px-3 py-2 text-xs cursor-help shadow-sm flex items-center gap-2",children:[e.jsx("span",{className:"font-semibold text-foreground",children:k(i.label||new Date(i.measured_at).toLocaleDateString(N))}),e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-[11px] font-semibold ${_==="cumulative"?"bg-primary/15 text-primary border border-primary/30":"bg-orange-500/15 text-orange-600 border border-orange-500/30"}`,children:s(_==="cumulative"?"mon.cumulative":"mon.interval")})]})}),e.jsx(z,{side:"bottom",className:"max-w-[260px] text-xs",children:s("mon.floorplanTooltip")})]})]})})})},lt=({data:t})=>{const{t:n}=W();return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx("h4",{className:"text-xs font-medium text-muted-foreground",children:n("mon.historyTitle")}),e.jsxs(A,{children:[e.jsx($,{asChild:!0,children:e.jsx(V,{className:"h-3 w-3 text-muted-foreground
7/50 cursor-help"})}),e.jsxs(z,{side:"top",className:"max-w-[260px] text-xs",children:[e.jsx("p",{className:"mb-1",children:n("mon.historyGreenTooltip")}),e.jsx("p",{children:n("mon.historyOrangeTooltip")})]})]})]}),e.jsx("div",{className:"h-48",children:e.jsx(Ie,{width:"100%",height:"100%",children:e.jsxs(Ve,{data:t,margin:{top:5,right:40,bottom:20,left:-10},children:[e.jsx(Oe,{strokeDasharray:"3 3",stroke:"hsl(var(--border))"}),e.jsx(Re,{dataKey:"label",tick:({x:i,y:d,payload:m,index:h})=>{const y=String(m.value),x=y.match(/(\d{4})$/),_=x?y.replace(/\s*\d{4}$/,"").trim():y,s=x?x[1]:"",j=h%2===0;return e.jsxs("g",{transform:`translate(${i},${d})`,children:[j&&_&&e.jsx("text",{x:0,y:0,dy:10,textAnchor:"middle",fontSize:9,fill:"hsl(var(--muted-foreground))",children:_}),s&&e.jsx("text",{x:0,y:0,dy:22,textAnchor:"middle",fontSize:9,fill:"hsl(var(--muted-foreground))",children:s})]})},tickLine:!1,axisLine:!1,interval:0}),e.jsx(Ye,{tick:{fontSize:10,fill:"hsl(var(--muted-foreground))"},tickLine:!1,axisLine:!1,unit:" mm"}),e.jsx(He,{contentStyle:{backgroundColor:"hsl(var(--background))",border:"1px solid hsl(var(--border))",borderRadius:"6px",fontSize:"12px"},formatter:(i,d)=>[`${i==null?void 0:i.toFixed(1)} mm`,n(d==="cumulative"?"mon.chartCumulative":"mon.chartInterval")]}),e.jsx(fe,{type:"monotone",dataKey:"cumulative",stroke:"hsl(var(--primary))",strokeWidth:2,dot:{r:3,fill:"hsl(var(--primary))"},connectNulls:!1,name:"cumulative"}),e.jsx(fe,{type:"monotone",dataKey:"interval",stroke:"#f97316",strokeWidth:1.5,dot:{r:2},connectNulls:!1,strokeDasharray:"5 5",name:"interval"})]})})})]})},me=(t,...n)=>t.replace(/\{(\d+)\}/g,(i,d)=>String(n[Number(d)])),ot={active:"default",lost:"destructive",historical:"secondary",planned:"outline"},je=({point:t,points:n,areas:i,campaigns:d,measurementsByPoint:m,activeCampaign:h,getPointValue:y,onClose:x,onPointSelect:_})=>{const{t:s,language:j}=W(),N=j==="de"?"de-DE":j==="cs"?"cs-CZ":"en-GB",k={active:s("mon.statusActive"),lost:s("mon.statusLost"),historical:s("mon.statusHistorical"),planned:s("mon.statusPlanned")},L=f.useMemo(()=>i.find(c=>c.id===(t==null?void 0:t.area_id)),[i,t==null?void 0:t.area_id]),v=f.useMemo(()=>{var c;return!t||!h?null:((c=m.get(t.id))==null?void 0:c.get(h.id))||null},[t,h,m]),b=f.useMemo(()=>{if(!t)return null;const c=m.get(t.id);if(!c||c.size===0)return null;const l=Array.from(c.keys()),r=d.filter(O=>l.includes(O.id)).sort((O,ie)=>new Date(O.measured_at).getTime()-new Date(ie.measured_at).getTime());if(r.length===0)return null;const p=r[0],C=r[r.length-1],M=new Date(p.measured_at).getFullYear(),Y=new Date(C.measured_at).getFullYear(),G=O=>j==="cs"?O:O.replace(/^Výchozí měření/i,s("mon.campaignLabelBaseline")).replace(/^Měření/i,s("mon.campaignLabelMeasurement"));return{firstLabel:G(p.label||M.toString()),lastLabel:G(C.label||Y.toString()),firstYear:M,lastYear:Y,count:r.length}},[t,d,m]),g=(t==null?void 0:t.status)==="lost"||(t==null?void 0:t.status)==="historical",D=f.useMemo(()=>{if(!t)return[];const c=m.get(t.id);if(!c)return[];const l=r=>j==="cs"?r:r.replace(/^Výchozí měření/i,s("mon.campaignLabelBaseline")).replace(/^Měření/i,s("mon.campaignLabelMeasurement"));return d.map(r=>{const p=c.get(r.id);if(!p)return null;const C=r.label||new Date(r.measured_at).toLocaleDateString(N,{month:"short",year:"numeric"});return{date:r.measured_at,label:l(C),cumulative:p.delta_from_baseline_mm,interval:p.delta_from_previous_mm,absolute:p.absolute_value_mm}}).filter(Boolean)},[t,d,m,N]),S=f.useMemo(()=>{if(t)return[];const c=(h==null?void 0:h.measured_at)||null;return console.log("DEBUG activeDate:",c,"points count:",n.length),n.map(l=>{const r=y(l.id),p=l.status==="lost"||l.status==="historical",C=p?Ce(l.status):we(r),M=!!(c&&l.installed_at&&l.installed_at.slice(0,10)===c.slice(0,10));return["BN","HB"].includes(l.code)&&console.log("DEBUG",l.code,"installed:",l.installed_at,"activeDate:",c,"isNewlySet:",M),{...l,value:r,color:C,isLost:p,isNewlySet:M}})},[t,n,y,h]),[a,w]=f.useState("active"),T=f.useMemo(()=>a==="active"?S.filter(c=>!c.isLost):a==="lost"?S.filter(c=>c.isLost):S,[S,a]),u=c=>j==="en"&&c.name_en?c.name_en:j==="cs"&&c.name_cs?c.name_cs:c.name;if(!t){const c=S.filter(r=>!r.isLost).length,l=S.filter(r=>r.isLost).length;return e.jsxs(ee,{className:"h-full",children:[e.jsxs(xe,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(he,{className:"text-sm font-semibold",children:s("mon.surveyPoints")}),e.jsxs(A,{children:[e.jsx($,{asChild:!0,children:e.jsx(V,{className:"h-3.5 w-3.5 text-muted-foreground
7/50 cursor-help"})}),e.jsx(z,{side:"left",className:"max-w-[220px] text-xs",children:s("mon.surveyPointsTooltip")})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>w("all"),className:`inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-medium border transition-colors ${a==="all"?"bg-primary/15 text-primary border-primary/40":"bg-muted/50 text-muted-foreground border-transparent hover:border-border"}`,children:s("mon.all")}),e.jsxs("button",{onClick:()=>w("active"),className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-medium border transition-colors ${a==="active"?"bg-green-500/15 text-green-700 border-green-500/40":"bg-muted/50 text-muted-foreground border-transparent hover:border-border"}`,children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500"}),c]}),e.jsxs("button",{onClick:()=>w("lost"),className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-medium border transition-colors ${a==="lost"?"bg-muted text-foreground border-border":"bg-muted/50 text-muted-foreground border-transparent hover:border-border"}`,children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-gray-400"}),l]})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:me(s("mon.activeOf"),c,S.length)})]}),e.jsx(te,{className:"p-0",children:e.jsx(Be,{className:"h-[540px]",children:e.jsx("div",{className:"divide-y divide-border",children:T.map(r=>{var p;return e.jsxs("button",{onClick:()=>_(r.id),className:"w-full flex items-center gap-2 px-3 py-1.5 hover:bg-muted/50 transition-colors text-left",children:[e.jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center text-white shrink-0",style:{backgroundColor:r.color,opacity:r.isLost?.5:1,fontSize:"8px",fontWeight:700}}),e.jsx("span",{className:"text-xs font-medium text-foreground w-10",children:r.code}),r.isLost?e.jsx(le,{variant:"secondary",className:"text-[10px] px-1.5 py-0 ml-auto mr-1",children:s("mon.lost")}):e.jsxs("span",{className:"text-xs text-muted-foreground ml-auto mr-1 flex items-center gap-1.5",children:[r.isNewlySet&&e.jsxs(A,{children:[e.jsx($,{asChild:!0,children:e.jsx("span",{className:"inline-flex items-center px-1.5 py-0 rounded-sm text-[9px] font-bold bg-blue-100 text-blue-700 border border-blue-300 cursor-help",onClick:C=>C.stopPropagation(),children:s("mon.newlySet")})}),e.jsx(z,{side:"left",className:"max-w-[260px] text-xs",children:s("mon.newlySetTooltip")})]}),e.jsxs("span",{className:"text-[8px] text-orange-500",children:["i:",((p=r.installed_at)==null?void 0:p.slice(0,10))||"null"]}),r.value!==null?`${r.value.toFixed(1)} mm`:"—"]}),e.jsx(We,{className:"h-3 w-3 text-muted-foreground/40 shrink-0"})]},r.id)})})})})]})}return e.jsxs(ee,{className:"h-full overflow-y-auto",children:[e.jsxs(xe,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx(he,{className:"text-lg font-serif",children:me(s("mon.pointDetail"),t.code)}),t.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:t.label})]}),e.jsx(ue,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:x,children:e.jsx(De,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[e.jsx(le,{variant:ot[t.status]||"secondary",children:k[t.status]||t.status}),L&&e.jsx(le,{variant:"outline",className:"text-xs",children:u(L)}),t.is_reference_point&&e.jsx(le,{variant:"outline",className:"text-xs",children:s("mon.reference")})]})]}),e.jsxs(te,{className:"space-y-4",children:[g&&e.jsxs("div",{className:"flex items-start gap-2 bg-muted/60 border border-border rounded-md p-3",children:[e.jsx(ge,{className:"h-4 w-4 text-muted-foreground mt-0.5 shrink-0"}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[e.jsx("p",{children:s("mon.lostPointExplanation")}),b&&e.jsx("p",{className:"mt-1 font-medium text-foreground",children:me(s("mon.historicalData"),b.firstYear,b.lastYear)})]})]}),!g&&h&&t.installed_at&&t.installed_at.slice(0,10)===h.measured_at.slice(0,10)&&e.jsxs("div",{className:"flex items-start gap-2 bg-blue-50 border border-blue-200 rounded-md p-3",children:[e.jsx(ge,{className:"h-4 w-4 text-blue-600 mt-0.5 shrink-0"}),e.jsxs("div",{className:"text-xs text-blue-900",children:[e.jsxs("p",{className:"font-semibold mb-0.5",children:[s("mon.newlySet")," — ",new Date(t.installed_at).toLocaleDateString(N)]}),e.jsx("p",{children:s("mon.newlySetTooltip")})]})]}),v?e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs(A,{children:[e.jsx($,{asChild:!0,children:e.jsxs("div",{className:"bg-muted/50 rounded-md p-3 cursor-help",children:[e.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[s("mon.cumulativeChange"),e.jsx(V,{className:"h-3 w-3"})]}),e.jsx("div",{className:"text-lg font-bold",children:v.delta_from_baseline_mm!==null?`${v.delta_from_baseline_mm.toFixed(1)} mm`:"—"})]})}),e.jsx(z,{side:"bottom",className:"max-w-[220px] text-xs",children:s("mon.cumulativeChangeTooltip")})]}),e.jsxs(A,{children:[e.jsx($,{asChild:!0,children:e.jsxs("div",{className:"bg-muted/50 rounded-md p-3 cursor-help",children:[e.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[s("mon.intervalChange"),e.jsx(V,{className:"h-3 w-3"})]}),e.jsx("div",{className:"text-lg font-bold",children:v.delta_from_previous_mm!==null?`${v.delta_from_previous_mm.toFixed(1)} mm`:"—"})]})}),e.jsx(z,{side:"bottom",className:"max-w-[220px] text-xs",children:s("mon.intervalChangeTooltip")})]})]}):!g&&e.jsxs("div",{className:"bg-muted/50 rounded-md p-3 text-center",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:s("mon.noCurrentDataDetail")}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-0.5",children:s("mon.noCurrentDataDetailSub")})]}),D.length>1&&e.jsx(lt,{data:D}),e.jsxs("div",{className:"border-t pt-3 space-y-1.5 text-xs text-muted-foreground",children:[e.jsx("h4",{className:"text-xs font-medium text-foreground mb-1",children:s("mon.pointInfo")}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:s("mon.status")}),e.jsx("span",{className:"font-medium text-foreground",children:k[t.status]||t.status})]}),L&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:s("mon.area")}),e.jsx("span",{className:"font-medium text-foreground",children:u(L)})]}),b&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:s("mon.firstMeasurement")}),e.jsx("span",{className:"font-medium text-foreground",children:b.firstLabel})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:s("mon.lastAvailMeasurement")}),e.jsx("span",{className:"font-medium text-foreground",children:b.lastLabel})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:s("mon.measurementCount")}),e.jsx("span",{className:"font-medium text-foreground",children:b.count})]})]}),t.installed_at&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:s("mon.installation")}),e.jsx("span",{className:"font-medium text-foreground",children:new Date(t.installed_at).toLocaleDateString(N)})]}),t.deactivated_at&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:s("mon.deactivation")}),e.jsx("span",{className:"font-medium text-foreground",children:new Date(t.deactivated_at).toLocaleDateString(N)})]}),t.notes&&e.jsx("div",{className:"mt-2 text-foreground bg-muted/50 rounded p-2",children:t.notes})]})]})]})},ve=(t,...n)=>t.replace(/\{(\d+)\}/g,(i,d)=>String(n[Number(d)])),it=({points:t,measurements:n,activeCampaign:i,measurementsByPoint:d})=>{const{t:m,language:h}=W(),y=h==="de"?"de-DE":h==="cs"?"cs-CZ":"en-GB",x=f.useMemo(()=>{const s=t.filter(L=>L.status==="active").length,j=t.filter(L=>L.status==="lost"||L.status==="historical").length;let N=0,k="";if(i)for(const L of t){const v=d.get(L.id);if(!v)continue;const b=v.get(i.id);b&&b.delta_from_baseline_mm!==null&&b.delta_from_baseline_mm<N&&(N=b.delta_from_baseline_mm,k=L.code)}return{activePoints:s,lostPoints:j,maxCumulative:N,maxCumulativeCode:k}},[t,i,d]),_=[{icon:Ge,label:m("mon.activePoints"),value:x.activePoints,sub:ve(m("mon.ofTotal"),t.length),color:"text-green-600",tooltip:m("mon.activePointsTooltip")},{icon:ke,label:m("mon.lostInactive"),value:x.lostPoints,sub:x.lostPoints>0?m("mon.noCurrentData"):m("mon.allOk"),color:x.lostPoints>0?"text-amber-500":"text-muted-foreground",tooltip:m("mon.lostInactiveTooltip")},{icon:qe,label:m("mon.maxCumulative"),value:x.maxCumulative!==0?`${x.maxCumulative.toFixed(1)} mm`:"—",sub:x.maxCumulativeCode?ve(m("mon.point"),x.maxCumulativeCode):m("mon.noData2"),color:"text-red-500",tooltip:m("mon.maxCumulativeTooltip")},{icon:Ke,label:m("mon.lastMeasurement"),value:i?new Date(i.measured_at).toLocaleDateString(y,{month:"long",year:"numeric"}).replace(/^./,s=>s.toUpperCase()):"—",sub:(i==null?void 0:i.label)||"",color:"text-primary",tooltip:m("mon.lastMeasurementTooltip")}];return e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:_.map((s,j)=>e.jsx(ee,{children:e.jsxs(te,{className:"p-3 lg:p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(s.icon,{className:`h-4 w-4 ${s.color}`}),e.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:s.label}),e.jsxs(A,{children:[e.jsx($,{asChild:!0,children:e.jsx(V,{className:"h-3 w-3 text-muted-foreground
7/50 cursor-help"})}),e.jsx(z,{side:"bottom",className:"max-w-[240px] text-xs",children:s.tooltip})]})]}),e.jsx("div",{className:"text-lg lg:text-xl font-bold text-foreground",children:s.value}),e.jsx("div",{className:"text-xs text-muted-foreground mt-0.5",children:s.sub})]})},j))})},ct=({campaigns:t,activeCampaignId:n,onSelectCampaign:i,viewMode:d,onViewModeChange:m})=>{const{t:h,language:y}=W(),x=y==="de"?"de-DE":y==="cs"?"cs-CZ":"en-GB";return t.length?e.jsx(ee,{children:e.jsx(te,{className:"p-3 sm:p-4",children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-1 bg-muted rounded-lg p-1",children:[e.jsxs(A,{children:[e.jsx($,{asChild:!0,children:e.jsx("button",{onClick:()=>m("cumulative"),className:ae("px-3 py-1.5 text-xs font-medium rounded-md transition-colors",d==="cumulative"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:h("mon.cumulative")})}),e.jsx(z,{side:"top",className:"max-w-[220px] text-xs",children:h("mon.cumulativeTooltip")})]}),e.jsxs(A,{children:[e.jsx($,{asChild:!0,children:e.jsx("button",{onClick:()=>m("interval"),className:ae("px-3 py-1.5 text-xs font-medium rounded-md transition-colors",d==="interval"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:h("mon.interval")})}),e.jsx(z,{side:"top",className:"max-w-[220px] text-xs",children:h("mon.intervalTooltip")})]})]}),e.jsxs(A,{children:[e.jsx($,{asChild:!0,children:e.jsx(V,{className:"h-3.5 w-3.5 text-muted-foreground/50 cursor-help"})}),e.jsx(z,{side:"top",className:"max-w-[260px] text-xs",children:h("mon.viewModeTooltip")})]})]}),e.jsx("div",{className:"overflow-x-auto -mx-3 sm:-mx-4 px-3 sm:px-4 pb-1",children:e.jsx("div",{className:"flex items-center gap-0.5 sm:gap-1 min-w-max",children:t.map((_,s)=>{const j=_.id===n,N=new Date(_.measured_at);return e.jsxs("div",{className:"flex items-center",children:[s>0&&e.jsx("div",{className:"w-2 sm:w-4 h-px bg-border"}),e.jsxs("button",{onClick:()=>i(_.id),className:ae("flex flex-col items-center px-1.5 sm:px-2 py-1 sm:py-1.5 rounded-md transition-all text-[11px] sm:text-xs",j?"bg-primary text-primary-foreground shadow-sm":"hover:bg-muted text-muted-foreground hover:text-foreground"),children:[e.jsx("span",{className:"font-medium",children:N.toLocaleDateString(x,{month:"short"})}),e.jsx("span",{className:ae("text-[9px] sm:text-[10px]",j?"text-primary-foreground/80":""),children:N.getFullYear()})]})]},_.id)})})})]})})}):null},Ne=()=>{const{t}=W(),n=[{color:"#22c55e",label:"0 … -10 mm"},{color:"#eab308",label:"-10 … -30 mm"},{color:"#f97316",label:"-30 … -50 mm"},{color:"#ef4444",label:"> -50 mm"},{color:"#9ca3af",label:t("mon.legendLost"),dashed:!0}];return e.jsxs("div",{className:"flex flex-wrap items-center gap-4 mt-2 px-1",children:[e.jsxs(A,{children:[e.jsx($,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 cursor-help",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:t("mon.legendTitle")}),e.jsx(V,{className:"h-3 w-3 text-muted-foreground/50"})]})}),e.jsx(z,{side:"bottom",className:"max-w-[280px] text-xs",children:t("mon.legendTooltip")})]}),n.map(i=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:i.color,opacity:i.dashed?.4:1,border:i.dashed?`2px dashed ${i.color}`:"none"}}),e.jsx("span",{className:"text-xs text-muted-foreground",children:i.label})]},i.label))]})},dt=()=>{const{t,language:n}=W(),i=Me(),{data:d,isLoading:m}=et(),{data:h,isLoading:y}=Je(),{data:x,isLoading:_}=tt(),{data:s,isLoading:j}=st(),{data:N}=nt();f.useEffect(()=>{i.invalidateQueries({queryKey:["monitoring-points"]})},[i]);const[k,L]=f.useState(null),[v,b]=f.useState(null),[g,D]=f.useState("cumulative"),S=m||y||_||j,a=f.useMemo(()=>x!=null&&x.length?k?x.find(l=>l.id===k)||null:x[x.length-1]:null,[x,k]),w=f.useMemo(()=>{const l=new Map;if(!s)return l;for(const r of s)l.has(r.point_id)||l.set(r.point_id,new Map),l.get(r.point_id).set(r.campaign_id,r);return l},[s]),T=f.useCallback(l=>{if(!a)return null;const r=w.get(l);if(!r)return null;const p=r.get(a.id);return p?g==="cumulative"?p.delta_from_baseline_mm:p.delta_from_previous_mm:null},[a,w,g]),u=f.useMemo(()=>
7{if(!d||!a)return d||[];const l=new Date(a.measured_at);return d.filter(r=>!(r.installed_at&&new Date(r.installed_at)>l))},[d,a]),c=f.useMemo(()=>(d==null?void 0:d.find(l=>l.id===v))||null,[d,v]);return S?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx(Fe,{className:"h-8 w-8 animate-spin text-primary"})}):d!=null&&d.length?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h1",{className:"text-xl lg:text-2xl font-serif font-bold text-foreground",children:t("mon.title")}),e.jsxs(A,{children:[e.jsx($,{asChild:!0,children:e.jsx(V,{className:"h-4 w-4 text-muted-foreground/50 cursor-help"})}),e.jsx(z,{side:"right",className:"max-w-[300px] text-xs",children:t("mon.titleTooltip")})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:t("mon.subtitle")})]}),e.jsxs(ue,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>Qe({lang:n,points:d||[],areas:h||[],campaigns:x||[],measurements:s||[]}),children:[e.jsx(Ue,{className:"h-4 w-4"}),n==="de"?"Excel herunterladen":n==="en"?"Download Excel":"Stáhnout do Excelu"]})]}),e.jsx(it,{points:u,measurements:s||[],activeCampaign:a,measurementsByPoint:w}),e.jsxs("div",{className:"lg:hidden space-y-4",children:[e.jsxs($e,{children:[e.jsx(ze,{asChild:!0,children:e.jsxs(ue,{variant:"outline",className:"w-full gap-2",children:[e.jsx(Xe,{className:"h-4 w-4"}),t("mon.showFloorplan")]})}),e.jsxs(Ee,{className:"mt-2",children:[e.jsx(be,{points:u,areas:h||[],plan:N,activeCampaign:a,campaigns:x||[],measurementsByPoint:w,getPointValue:T,selectedPointId:v,onPointSelect:b,viewMode:g}),e.jsx(Ne,{})]})]}),e.jsx(je,{point:c,points:u,areas:h||[],campaigns:x||[],measurementsByPoint:w,activeCampaign:a,getPointValue:T,onClose:()=>b(null),onPointSelect:b})]}),e.jsxs("div",{className:"hidden lg:grid lg:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"lg:col-span-2",children:[e.jsx(be,{points:u,areas:h||[],plan:N,activeCampaign:a,campaigns:x||[],measurementsByPoint:w,getPointValue:T,selectedPointId:v,onPointSelect:b,viewMode:g}),e.jsx(Ne,{})]}),e.jsx("div",{className:"lg:col-span-1",children:e.jsx(je,{point:c,points:u,areas:h||[],campaigns:x||[],measurementsByPoint:w,activeCampaign:a,getPointValue:T,onClose:()=>b(null),onPointSelect:b})})]}),e.jsx(ct,{campaigns:x||[],activeCampaignId:(a==null?void 0:a.id)||null,onSelectCampaign:L,viewMode:g,onViewModeChange:D})]}):e.jsxs("div",{className:"text-center py-16 text-muted-foreground",children:[e.jsx("p",{className:"text-lg font-medium",children:t("mon.noData")}),e.jsx("p",{className:"text-sm mt-1",children:t("mon.noDataSub")})]})},Zt=()=>{const{t}=W();return e.jsx(Te,{breadcrumbs:[{label:t("sidebar.monitoring")}],children:e.jsx(dt,{})})};export{Zt as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.