@nice2dev/ui-buildings 1.0.20 → 1.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("react"),H=require("@nice2dev/spatial-core"),ss=require("@nice2dev/ui"),ns="_root_hctnw_1",os="_dark_hctnw_27",as="_topBar_hctnw_41",cs="_floorTabs_hctnw_71",rs="_floorTab_hctnw_71",is="_floorTabActive_hctnw_107",ls="_overlayControls_hctnw_119",ds="_overlayBtn_hctnw_131",us="_overlayBtnActive_hctnw_163",ps="_zoomBar_hctnw_175",_s="_editorBody_hctnw_229",hs="_toolPalette_hctnw_243",ms="_toolBtn_hctnw_273",xs="_toolBtnActive_hctnw_309",ys="_canvasWrapper_hctnw_323",vs="_canvas_hctnw_323",fs="_cur_select_hctnw_359",gs="_cur_drawzone_hctnw_361",bs="_cur_drawwall_hctnw_363",js="_cur_placedevice_hctnw_365",ws="_cur_placedoor_hctnw_367",Ns="_cur_placewindow_hctnw_369",ks="_cur_pan_hctnw_371",Cs="_cur_erase_hctnw_373",Is="_cur_measure_hctnw_375",Ss="_cur_annotate_hctnw_377",Ls="_gridLine_hctnw_383",zs="_zoneGroup_hctnw_397",$s="_zonePath_hctnw_405",Bs="_zoneLabel_hctnw_413",Ts="_climateLabel_hctnw_431",Ps="_occupancyLabel_hctnw_443",Ms="_dimLabel_hctnw_455",Os="_deviceGroup_hctnw_467",As="_devCircle_hctnw_471",Es="_devOnline_hctnw_483",Ds="_devOffline_hctnw_485",Rs="_devSelected_hctnw_487",Ws="_propPanel_hctnw_499",Gs="_propTitle_hctnw_527",qs="_propRow_hctnw_545",Fs="_statusBar_hctnw_581",Vs="_emptyState_hctnw_613",se={root:ns,dark:os,topBar:as,floorTabs:cs,floorTab:rs,floorTabActive:is,overlayControls:ls,overlayBtn:ds,overlayBtnActive:us,zoomBar:ps,editorBody:_s,toolPalette:hs,toolBtn:ms,toolBtnActive:xs,canvasWrapper:ys,canvas:vs,cur_select:fs,cur_drawzone:gs,cur_drawwall:bs,cur_placedevice:js,cur_placedoor:ws,cur_placewindow:Ns,cur_pan:ks,cur_erase:Cs,cur_measure:Is,cur_annotate:Ss,gridLine:Ls,zoneGroup:zs,zonePath:$s,zoneLabel:Bs,climateLabel:Ts,occupancyLabel:Ps,dimLabel:Ms,deviceGroup:Os,devCircle:As,devOnline:Es,devOffline:Ds,devSelected:Rs,propPanel:Ws,propTitle:Gs,propRow:qs,statusBar:Fs,emptyState:Vs},Hs={living_room:"var(--nice-primary-bg, #dbeafe)",bedroom:"var(--nice-accent-bg, #fce7f3)",master_bedroom:"#f3e8ff",kids_room:"var(--nice-warning-bg, #fef3c7)",bathroom:"#cffafe",kitchen:"var(--nice-warning-bg, #fef9c3)",dining_room:"var(--nice-warning-bg, #fde8d8)",hallway:"var(--nice-bg-secondary, #f1f5f9)",office:"var(--nice-success-bg, #dcfce7)",garage:"var(--nice-border, #e2e8f0)",basement:"var(--nice-border, #e5e7eb)",attic:"var(--nice-success-bg, #f0fdf4)",balcony:"var(--nice-success-bg, #ecfdf5)",garden:"var(--nice-success-bg, #d1fae5)",gym:"var(--nice-danger-bg, #fee2e2)",cinema:"var(--nice-accent-bg, #ede9fe)",open_office:"var(--nice-success-bg, #dcfce7)",private_office:"var(--nice-success-bg, #d1fae5)",meeting_room:"var(--nice-primary-bg, #dbeafe)",boardroom:"var(--nice-accent-bg, #ede9fe)",reception:"var(--nice-warning-bg, #fef3c7)",waiting_area:"var(--nice-warning-bg, #fef9c3)",server_room:"var(--nice-danger-bg, #fee2e2)",it_room:"var(--nice-warning-bg, #fde8d8)",break_room:"var(--nice-accent-bg, #fce7f3)",lobby:"var(--nice-primary-bg, #f0f4ff)",corridor:"var(--nice-bg-secondary, #f8fafc)",stairwell:"var(--nice-bg-secondary, #f1f5f9)",parking:"var(--nice-border, #e2e8f0)",mechanical_room:"var(--nice-bg-secondary, #f3f4f6)"};function Us(t){return Hs[t]??"var(--nice-primary-bg, #f0f4ff)"}function St(t){if(!t.length)return{x:0,y:0};const s=t.reduce((a,o)=>({x:a.x+o.x,y:a.y+o.y}),{x:0,y:0});return{x:s.x/t.length,y:s.y/t.length}}function Lt(t,s=!0){return t.length<2?"":t.map((a,o)=>`${o===0?"M":"L"}${a.x.toFixed(1)},${a.y.toFixed(1)}`).join(" ")+(s?" Z":"")}function Zs(t,s,a){return a?{x:Math.round(t.x/s)*s,y:Math.round(t.y/s)*s}:t}function Ys(t,s){switch(s.t){case"TOOL":return{...t,tool:s.v,drawing:null,selected:null};case"FLOOR":return{...t,floorId:s.v,drawing:null,selected:null};case"SELECT":return{...t,selected:s.v};case"ZOOM":return{...t,zoom:Math.max(.15,Math.min(5,s.v))};case"PAN":return{...t,pan:s.v};case"DRAW_PT":return{...t,drawing:[...t.drawing??[],s.v]};case"DRAW_END":return{...t,drawing:null};case"TOGGLE":return s.v==="grid"?{...t,showGrid:!t.showGrid}:s.v==="dim"?{...t,showDim:!t.showDim}:s.v==="labels"?{...t,showLabels:!t.showLabels}:s.v==="occupancy"?{...t,showOccupancy:!t.showOccupancy}:{...t,showClimate:!t.showClimate};default:return t}}const Ks=[{tool:"select",icon:"↖",label:"Zaznaczenie"},{tool:"draw_zone",icon:"⬡",label:"Rysuj strefę"},{tool:"draw_wall",icon:"▬",label:"Rysuj ścianę"},{tool:"place_device",icon:"📡",label:"Urządzenie"},{tool:"place_door",icon:"🚪",label:"Drzwi"},{tool:"place_window",icon:"🪟",label:"Okno"},{tool:"annotate",icon:"✏",label:"Adnotacja"},{tool:"measure",icon:"📏",label:"Miarka"},{tool:"erase",icon:"🗑",label:"Usuń"},{tool:"pan",icon:"✋",label:"Przesuń"}],Xs={light:"💡",dimmer:"🔆",rgb_light:"🌈",led_strip:"〰",thermostat:"🌡",air_conditioner:"❄",fan:"💨",heat_pump:"♨",lock:"🔒",door:"🚪",window:"🪟",blind:"▦",camera:"📷",doorbell:"🔔",alarm:"🚨",motion_sensor:"👁",smoke_detector:"🔴",temperature_sensor:"🌡",humidity_sensor:"💧",switch:"🔌",outlet:"🔌",speaker:"🔈",tv:"📺",vacuum:"🤖",ev_charger:"⚡",solar_panel:"☀",energy_meter:"⚡",hub:"📡",router:"📡"},Js=({floors:t,devices:s=[],onFloorChange:a,onDeviceMove:o,readOnly:n=!1,initialFloorId:c,showDevices:d=!0,showDimensions:y=!1,showGrid:f=!0,showOccupancy:g=!1,showClimate:u=!0,className:N,style:b,theme:v="light"})=>{var oe,U;const h=r.useRef(null),x=r.useRef(!1),j=r.useRef({x:0,y:0}),[i,L]=r.useReducer(Ys,{floorId:c??((oe=t[0])==null?void 0:oe.id)??"",tool:"select",selected:null,zoom:1,pan:{x:0,y:0},drawing:null,showGrid:f,showDim:y,showLabels:!0,showOccupancy:g,showClimate:u,snapGrid:!0,gridSize:20}),p=t.find(k=>k.id===i.floorId)??t[0],C=r.useCallback(k=>{var ie;const q=(ie=h.current)==null?void 0:ie.getBoundingClientRect();return q?{x:(k.clientX-q.left-i.pan.x)/i.zoom,y:(k.clientY-q.top-i.pan.y)/i.zoom}:{x:0,y:0}},[i.pan,i.zoom]),w=r.useCallback(k=>{i.tool==="pan"&&(x.current=!0,j.current={x:k.clientX,y:k.clientY})},[i.tool]),l=r.useCallback(k=>{x.current&&(L({t:"PAN",v:{x:i.pan.x+k.clientX-j.current.x,y:i.pan.y+k.clientY-j.current.y}}),j.current={x:k.clientX,y:k.clientY})},[i.pan]),$=r.useCallback(()=>{x.current=!1},[]),E=r.useCallback(k=>{if(i.tool==="draw_zone"){const q=Zs(C(k),i.gridSize,i.snapGrid);L({t:"DRAW_PT",v:q})}else i.tool==="select"&&L({t:"SELECT",v:null})},[i.tool,i.gridSize,i.snapGrid,C]),V=r.useCallback(k=>{if(i.tool==="draw_zone"&&i.drawing&&i.drawing.length>=3&&a&&p){const q={id:`zone-${Date.now()}`,name:"Nowa strefa",type:"other",floorId:p.id,polygon:[...i.drawing]};a(t.map(ie=>ie.id===p.id?{...p,zones:[...p.zones,q]}:ie)),L({t:"DRAW_END"})}},[i.tool,i.drawing,p,t,a]),G=r.useCallback(k=>{k.preventDefault(),L({t:"ZOOM",v:i.zoom*(k.deltaY>0?.9:1.1)})},[i.zoom]),me=r.useCallback((k,q)=>{k.stopPropagation(),i.tool==="select"?L({t:"SELECT",v:{type:"zone",id:q.id}}):i.tool==="erase"&&!n&&a&&p&&a(t.map(ie=>ie.id===p.id?{...p,zones:p.zones.filter(je=>je.id!==q.id)}:ie))},[i.tool,n,p,t,a]);if(!p)return e.jsx("div",{className:se.emptyState,children:"Brak kondygnacji."});const Q=((U=i.selected)==null?void 0:U.type)==="zone"?p.zones.find(k=>{var q;return k.id===((q=i.selected)==null?void 0:q.id)}):null,ge=d?s.filter(k=>p.zones.some(q=>q.id===k.zoneId)||k.floorPlanPosition):[],be=[{key:"grid",icon:"⊞",active:i.showGrid},{key:"dim",icon:"↔",active:i.showDim},{key:"labels",icon:"🏷",active:i.showLabels},{key:"occupancy",icon:"👥",active:i.showOccupancy},{key:"climate",icon:"🌡",active:i.showClimate}];return e.jsxs("div",{className:`${se.root} ${v==="dark"?se.dark:""} ${N??""}`,style:b,children:[e.jsxs("div",{className:se.topBar,children:[e.jsx("div",{className:se.floorTabs,children:[...t].sort((k,q)=>k.level-q.level).map(k=>e.jsx("button",{className:`${se.floorTab} ${i.floorId===k.id?se.floorTabActive:""}`,onClick:()=>L({t:"FLOOR",v:k.id}),children:k.name},k.id))}),e.jsx("div",{className:se.overlayControls,children:be.map(k=>e.jsx("button",{title:k.key,className:`${se.overlayBtn} ${k.active?se.overlayBtnActive:""}`,onClick:()=>L({t:"TOGGLE",v:k.key}),children:k.icon},k.key))}),e.jsxs("div",{className:se.zoomBar,children:[e.jsx("button",{onClick:()=>L({t:"ZOOM",v:i.zoom*1.2}),children:"+"}),e.jsxs("span",{children:[Math.round(i.zoom*100),"%"]}),e.jsx("button",{onClick:()=>L({t:"ZOOM",v:i.zoom*.8}),children:"−"}),e.jsx("button",{title:"Resetuj widok",onClick:()=>{L({t:"ZOOM",v:1}),L({t:"PAN",v:{x:0,y:0}})},children:"⊡"})]})]}),e.jsxs("div",{className:se.editorBody,children:[!n&&e.jsx("div",{className:se.toolPalette,children:Ks.map(({tool:k,icon:q,label:ie})=>e.jsx("button",{title:ie,className:`${se.toolBtn} ${i.tool===k?se.toolBtnActive:""}`,onClick:()=>L({t:"TOOL",v:k}),children:q},k))}),e.jsx("div",{className:se.canvasWrapper,children:e.jsxs("svg",{ref:h,className:`${se.canvas} ${se[`cur_${i.tool.replace("_","")}`]??""}`,onMouseDown:w,onMouseMove:l,onMouseUp:$,onClick:E,onDoubleClick:V,onWheel:G,children:[p.backgroundImage&&e.jsx("image",{href:p.backgroundImage,x:i.pan.x,y:i.pan.y,width:p.width*i.zoom,height:p.height*i.zoom,preserveAspectRatio:"xMidYMid meet",opacity:.35}),e.jsxs("g",{transform:`translate(${i.pan.x},${i.pan.y}) scale(${i.zoom})`,children:[i.showGrid&&(()=>{const k=[];for(let q=0;q<=p.width;q+=i.gridSize)k.push(e.jsx("line",{x1:q,y1:0,x2:q,y2:p.height,className:se.gridLine},`v${q}`));for(let q=0;q<=p.height;q+=i.gridSize)k.push(e.jsx("line",{x1:0,y1:q,x2:p.width,y2:q,className:se.gridLine},`h${q}`));return e.jsx("g",{children:k})})(),p.zones.map(k=>{var ke;const q=((ke=i.selected)==null?void 0:ke.id)===k.id,ie=St(k.polygon),je=k.color??Us(k.type);return e.jsxs("g",{className:se.zoneGroup,onClick:xe=>me(xe,k),children:[e.jsx("path",{d:Lt(k.polygon),fill:je,fillOpacity:k.opacity??.55,stroke:q?"var(--nice-primary-hover, #2563eb)":"var(--nice-text-muted, #94a3b8)",strokeWidth:q?2.5:1.5,className:se.zonePath}),i.showLabels&&e.jsx("text",{x:ie.x,y:ie.y,textAnchor:"middle",dominantBaseline:"middle",className:se.zoneLabel,children:k.name}),i.showClimate&&k.temperature!=null&&e.jsxs("text",{x:ie.x,y:ie.y+14,textAnchor:"middle",className:se.climateLabel,children:[k.temperature.toFixed(1),"°C"," ",k.humidity!=null?`· ${k.humidity}%`:""]}),i.showOccupancy&&k.occupancy!=null&&e.jsxs("text",{x:ie.x,y:ie.y+26,textAnchor:"middle",className:se.occupancyLabel,children:["👥 ",k.occupancy]}),i.showDim&&k.polygon.length>1&&k.polygon.map((xe,Te)=>{const Se=k.polygon[(Te+1)%k.polygon.length],De=(xe.x+Se.x)/2,Ze=(xe.y+Se.y)/2,Re=Math.sqrt((Se.x-xe.x)**2+(Se.y-xe.y)**2),Le=p.scale??0;return e.jsx("text",{x:De,y:Ze-4,textAnchor:"middle",className:se.dimLabel,children:Le>0?`${(Re/Le).toFixed(1)}m`:`${Re.toFixed(0)}px`},Te)})]},k.id)}),ge.map(k=>{var ke;const q=p.zones.find(xe=>xe.id===k.zoneId),ie=k.floorPlanPosition??(q?St(q.polygon):null);if(!ie)return null;const je=((ke=i.selected)==null?void 0:ke.id)===k.id;return e.jsxs("g",{transform:`translate(${ie.x},${ie.y})`,className:se.deviceGroup,onClick:xe=>{xe.stopPropagation(),L({t:"SELECT",v:{type:"device",id:k.id}})},children:[e.jsx("circle",{r:14,className:`${se.devCircle} ${k.status==="online"?se.devOnline:se.devOffline} ${je?se.devSelected:""}`}),e.jsx("text",{y:5,textAnchor:"middle",fontSize:12,children:Xs[k.type]??"📟"})]},k.id)}),i.drawing&&i.drawing.length>0&&e.jsxs("g",{children:[e.jsx("path",{d:Lt(i.drawing,!1),fill:"none",stroke:"var(--nice-primary-hover, #2563eb)",strokeWidth:2,strokeDasharray:"6,3"}),i.drawing.map((k,q)=>e.jsx("circle",{cx:k.x,cy:k.y,r:4,fill:"var(--nice-primary-hover, #2563eb)"},q))]})]})]})}),Q&&e.jsxs("div",{className:se.propPanel,children:[e.jsx("div",{className:se.propTitle,children:Q.name}),e.jsxs("div",{className:se.propRow,children:[e.jsx("span",{children:"Typ"}),e.jsx("span",{children:Q.type})]}),Q.area!=null&&e.jsxs("div",{className:se.propRow,children:[e.jsx("span",{children:"Pow."}),e.jsxs("span",{children:[Q.area," m²"]})]}),Q.temperature!=null&&e.jsxs("div",{className:se.propRow,children:[e.jsx("span",{children:"Temp."}),e.jsxs("span",{children:[Q.temperature.toFixed(1)," °C"]})]}),Q.humidity!=null&&e.jsxs("div",{className:se.propRow,children:[e.jsx("span",{children:"Wilgotność"}),e.jsxs("span",{children:[Q.humidity," %"]})]}),Q.co2!=null&&e.jsxs("div",{className:se.propRow,children:[e.jsx("span",{children:"CO₂"}),e.jsxs("span",{children:[Q.co2," ppm"]})]}),Q.occupancy!=null&&e.jsxs("div",{className:se.propRow,children:[e.jsx("span",{children:"Obecność"}),e.jsxs("span",{children:[Q.occupancy," os."]})]})]})]}),e.jsxs("div",{className:se.statusBar,children:[i.tool==="draw_zone"?"Klikaj punkty, dwa kliknięcia by zamknąć strefę.":i.selected?`Zaznaczono: ${i.selected.type} #${i.selected.id}`:`${p.name} — ${p.zones.length} strefa(y)`,i.tool==="draw_zone"&&i.drawing&&` (${i.drawing.length} pkt)`]})]})},Qs="_overlay_58xqu_9",en="_dialog_58xqu_55",tn="_header_58xqu_103",sn="_title_58xqu_119",nn="_closeButton_58xqu_133",on="_content_58xqu_163",an="_preview_58xqu_179",cn="_previewCanvas_58xqu_199",rn="_previewSvg_58xqu_217",ln="_info_58xqu_227",dn="_section_58xqu_237",un="_sectionTitle_58xqu_245",pn="_statGrid_58xqu_265",_n="_stat_58xqu_265",hn="_statLabel_58xqu_289",mn="_statValue_58xqu_301",xn="_warningsList_58xqu_313",yn="_warning_58xqu_313",vn="_warningIcon_58xqu_357",fn="_error_58xqu_367",gn="_errorIcon_58xqu_399",bn="_footer_58xqu_409",jn="_cancelButton_58xqu_429",wn="_confirmButton_58xqu_461",Nn="_noWarnings_58xqu_503",kn="_layersList_58xqu_515",Cn="_layer_58xqu_515",In="_layerIcon_58xqu_557",Sn="_layerName_58xqu_565",Ln="_layerCount_58xqu_575",W={overlay:Qs,dialog:en,header:tn,title:sn,closeButton:nn,content:on,preview:an,previewCanvas:cn,previewSvg:rn,info:ln,section:dn,sectionTitle:un,statGrid:pn,stat:_n,statLabel:hn,statValue:mn,warningsList:xn,warning:yn,warningIcon:vn,error:fn,errorIcon:gn,footer:bn,cancelButton:jn,confirmButton:wn,noWarnings:Nn,layersList:kn,layer:Cn,layerIcon:In,layerName:Sn,layerCount:Ln},zn=()=>e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M15 5L5 15M5 5L15 15",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),zt=()=>e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"currentColor",children:e.jsx("path",{d:"M7 0a7 7 0 1 0 0 14A7 7 0 0 0 7 0zm0 12.5a.75.75 0 1 1 0-1.5.75.75 0 0 1 0 1.5zm.75-3.25a.75.75 0 0 1-1.5 0v-4a.75.75 0 0 1 1.5 0v4z"})}),$t=()=>e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"currentColor",children:e.jsx("path",{d:"M7 0a7 7 0 1 0 0 14A7 7 0 0 0 7 0zm2.8 9.15a.5.5 0 0 1-.65.65L7 8.45l-2.15 1.35a.5.5 0 0 1-.65-.65L5.55 7 4.2 4.85a.5.5 0 0 1 .65-.65L7 5.55l2.15-1.35a.5.5 0 0 1 .65.65L8.45 7l1.35 2.15z"})}),Bt=()=>e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"currentColor",children:e.jsx("path",{d:"M6 0L0 3l6 3 6-3-6-3zM0 6l6 3 6-3M0 9l6 3 6-3",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})}),$n=()=>e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"currentColor",children:e.jsx("path",{d:"M2 12h2V5H2v7zm4 0h2V2H6v10zm4 0h2V7h-2v5z"})});function Bn({result:t,onConfirm:s,onCancel:a}){const o=t.document,n=r.useMemo(()=>{var L,p;if(!((L=o==null?void 0:o.floors)!=null&&L.length))return null;const u=o.floors[0],N=(u==null?void 0:u.layers)||[],b=N.flatMap(C=>C.objects);let v=1/0,h=1/0,x=-1/0,j=-1/0;for(const C of b)C.bounds?(v=Math.min(v,C.bounds.x),h=Math.min(h,C.bounds.y),x=Math.max(x,C.bounds.x+C.bounds.width),j=Math.max(j,C.bounds.y+C.bounds.height)):(p=C.transform)!=null&&p.position&&(v=Math.min(v,C.transform.position.x),h=Math.min(h,C.transform.position.y),x=Math.max(x,C.transform.position.x),j=Math.max(j,C.transform.position.y));isFinite(v)||(u!=null&&u.bounds?(v=u.bounds.x,h=u.bounds.y,x=u.bounds.x+u.bounds.width,j=u.bounds.y+u.bounds.height):(v=0,h=0,x=1e3,j=800));const i=20;return{viewBox:{x:v-i,y:h-i,width:x-v+i*2,height:j-h+i*2},objects:b,layers:N}},[o]),c=r.useMemo(()=>{if(!n||!o)return null;const{viewBox:u,objects:N}=n,b=[],v=50,h=`
2
- <pattern id="grid" width="${v}" height="${v}" patternUnits="userSpaceOnUse">
3
- <path d="M ${v} 0 L 0 0 0 ${v}" fill="none" stroke="var(--nice-border, #e2e8f0)" strokeWidth="0.5"/>
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("react"),Me=require("@nice2dev/ui"),V=require("@nice2dev/spatial-core"),os="_root_hctnw_1",as="_dark_hctnw_27",cs="_topBar_hctnw_41",rs="_floorTabs_hctnw_71",is="_floorTab_hctnw_71",ls="_floorTabActive_hctnw_107",ds="_overlayControls_hctnw_119",us="_overlayBtn_hctnw_131",ps="_overlayBtnActive_hctnw_163",_s="_zoomBar_hctnw_175",hs="_editorBody_hctnw_229",ms="_toolPalette_hctnw_243",xs="_toolBtn_hctnw_273",ys="_toolBtnActive_hctnw_309",vs="_canvasWrapper_hctnw_323",fs="_canvas_hctnw_323",gs="_cur_select_hctnw_359",bs="_cur_drawzone_hctnw_361",js="_cur_drawwall_hctnw_363",ws="_cur_placedevice_hctnw_365",Ns="_cur_placedoor_hctnw_367",ks="_cur_placewindow_hctnw_369",Cs="_cur_pan_hctnw_371",Is="_cur_erase_hctnw_373",Ss="_cur_measure_hctnw_375",Ls="_cur_annotate_hctnw_377",zs="_gridLine_hctnw_383",Ts="_zoneGroup_hctnw_397",Bs="_zonePath_hctnw_405",$s="_zoneLabel_hctnw_413",Ps="_climateLabel_hctnw_431",Ms="_occupancyLabel_hctnw_443",Os="_dimLabel_hctnw_455",As="_deviceGroup_hctnw_467",Es="_devCircle_hctnw_471",Ds="_devOnline_hctnw_483",Rs="_devOffline_hctnw_485",Gs="_devSelected_hctnw_487",Ws="_propPanel_hctnw_499",qs="_propTitle_hctnw_527",Fs="_propRow_hctnw_545",Vs="_statusBar_hctnw_581",Hs="_emptyState_hctnw_613",Q={root:os,dark:as,topBar:cs,floorTabs:rs,floorTab:is,floorTabActive:ls,overlayControls:ds,overlayBtn:us,overlayBtnActive:ps,zoomBar:_s,editorBody:hs,toolPalette:ms,toolBtn:xs,toolBtnActive:ys,canvasWrapper:vs,canvas:fs,cur_select:gs,cur_drawzone:bs,cur_drawwall:js,cur_placedevice:ws,cur_placedoor:Ns,cur_placewindow:ks,cur_pan:Cs,cur_erase:Is,cur_measure:Ss,cur_annotate:Ls,gridLine:zs,zoneGroup:Ts,zonePath:Bs,zoneLabel:$s,climateLabel:Ps,occupancyLabel:Ms,dimLabel:Os,deviceGroup:As,devCircle:Es,devOnline:Ds,devOffline:Rs,devSelected:Gs,propPanel:Ws,propTitle:qs,propRow:Fs,statusBar:Vs,emptyState:Hs},Us=[{target:".nice-floor-plan-editor",titleKey:"tutorial.floorPlanEditor.intro.title",title:"Floor plan editor",contentKey:"tutorial.floorPlanEditor.intro.content",content:"Draw rooms and zones with the tools, place devices on the plan, switch floors and toggle overlays like dimensions, grid and occupancy.",placement:"auto"}],Zs={living_room:"var(--nice-primary-bg, #dbeafe)",bedroom:"var(--nice-accent-bg, #fce7f3)",master_bedroom:"#f3e8ff",kids_room:"var(--nice-warning-bg, #fef3c7)",bathroom:"#cffafe",kitchen:"var(--nice-warning-bg, #fef9c3)",dining_room:"var(--nice-warning-bg, #fde8d8)",hallway:"var(--nice-bg-secondary, #f1f5f9)",office:"var(--nice-success-bg, #dcfce7)",garage:"var(--nice-border, #e2e8f0)",basement:"var(--nice-border, #e5e7eb)",attic:"var(--nice-success-bg, #f0fdf4)",balcony:"var(--nice-success-bg, #ecfdf5)",garden:"var(--nice-success-bg, #d1fae5)",gym:"var(--nice-danger-bg, #fee2e2)",cinema:"var(--nice-accent-bg, #ede9fe)",open_office:"var(--nice-success-bg, #dcfce7)",private_office:"var(--nice-success-bg, #d1fae5)",meeting_room:"var(--nice-primary-bg, #dbeafe)",boardroom:"var(--nice-accent-bg, #ede9fe)",reception:"var(--nice-warning-bg, #fef3c7)",waiting_area:"var(--nice-warning-bg, #fef9c3)",server_room:"var(--nice-danger-bg, #fee2e2)",it_room:"var(--nice-warning-bg, #fde8d8)",break_room:"var(--nice-accent-bg, #fce7f3)",lobby:"var(--nice-primary-bg, #f0f4ff)",corridor:"var(--nice-bg-secondary, #f8fafc)",stairwell:"var(--nice-bg-secondary, #f1f5f9)",parking:"var(--nice-border, #e2e8f0)",mechanical_room:"var(--nice-bg-secondary, #f3f4f6)"};function Ys(t){return Zs[t]??"var(--nice-primary-bg, #f0f4ff)"}function zt(t){if(!t.length)return{x:0,y:0};const s=t.reduce((a,o)=>({x:a.x+o.x,y:a.y+o.y}),{x:0,y:0});return{x:s.x/t.length,y:s.y/t.length}}function Tt(t,s=!0){return t.length<2?"":t.map((a,o)=>`${o===0?"M":"L"}${a.x.toFixed(1)},${a.y.toFixed(1)}`).join(" ")+(s?" Z":"")}function Ks(t,s,a){return a?{x:Math.round(t.x/s)*s,y:Math.round(t.y/s)*s}:t}function Xs(t,s){switch(s.t){case"TOOL":return{...t,tool:s.v,drawing:null,selected:null};case"FLOOR":return{...t,floorId:s.v,drawing:null,selected:null};case"SELECT":return{...t,selected:s.v};case"ZOOM":return{...t,zoom:Math.max(.15,Math.min(5,s.v))};case"PAN":return{...t,pan:s.v};case"DRAW_PT":return{...t,drawing:[...t.drawing??[],s.v]};case"DRAW_END":return{...t,drawing:null};case"TOGGLE":return s.v==="grid"?{...t,showGrid:!t.showGrid}:s.v==="dim"?{...t,showDim:!t.showDim}:s.v==="labels"?{...t,showLabels:!t.showLabels}:s.v==="occupancy"?{...t,showOccupancy:!t.showOccupancy}:{...t,showClimate:!t.showClimate};default:return t}}const Js=[{tool:"select",icon:"↖",label:"Zaznaczenie"},{tool:"draw_zone",icon:"⬡",label:"Rysuj strefę"},{tool:"draw_wall",icon:"▬",label:"Rysuj ścianę"},{tool:"place_device",icon:"📡",label:"Urządzenie"},{tool:"place_door",icon:"🚪",label:"Drzwi"},{tool:"place_window",icon:"🪟",label:"Okno"},{tool:"annotate",icon:"✏",label:"Adnotacja"},{tool:"measure",icon:"📏",label:"Miarka"},{tool:"erase",icon:"🗑",label:"Usuń"},{tool:"pan",icon:"✋",label:"Przesuń"}],Qs={light:"💡",dimmer:"🔆",rgb_light:"🌈",led_strip:"〰",thermostat:"🌡",air_conditioner:"❄",fan:"💨",heat_pump:"♨",lock:"🔒",door:"🚪",window:"🪟",blind:"▦",camera:"📷",doorbell:"🔔",alarm:"🚨",motion_sensor:"👁",smoke_detector:"🔴",temperature_sensor:"🌡",humidity_sensor:"💧",switch:"🔌",outlet:"🔌",speaker:"🔈",tv:"📺",vacuum:"🤖",ev_charger:"⚡",solar_panel:"☀",energy_meter:"⚡",hub:"📡",router:"📡"},en=({floors:t,devices:s=[],onFloorChange:a,onDeviceMove:o,readOnly:n=!1,initialFloorId:c,showDevices:l=!0,showDimensions:y=!1,showGrid:v=!0,showOccupancy:k=!1,showClimate:d=!0,className:C,style:b,theme:p="light",tutorial:N})=>{var re,ce;const u=r.useRef(null),w=r.useRef(!1),T=r.useRef({x:0,y:0}),[i,h]=r.useReducer(Xs,{floorId:c??((re=t[0])==null?void 0:re.id)??"",tool:"select",selected:null,zoom:1,pan:{x:0,y:0},drawing:null,showGrid:v,showDim:y,showLabels:!0,showOccupancy:k,showClimate:d,snapGrid:!0,gridSize:20}),j=t.find(S=>S.id===i.floorId)??t[0],f=r.useCallback(S=>{var ie;const F=(ie=u.current)==null?void 0:ie.getBoundingClientRect();return F?{x:(S.clientX-F.left-i.pan.x)/i.zoom,y:(S.clientY-F.top-i.pan.y)/i.zoom}:{x:0,y:0}},[i.pan,i.zoom]),g=r.useCallback(S=>{i.tool==="pan"&&(w.current=!0,T.current={x:S.clientX,y:S.clientY})},[i.tool]),m=r.useCallback(S=>{w.current&&(h({t:"PAN",v:{x:i.pan.x+S.clientX-T.current.x,y:i.pan.y+S.clientY-T.current.y}}),T.current={x:S.clientX,y:S.clientY})},[i.pan]),A=r.useCallback(()=>{w.current=!1},[]),H=r.useCallback(S=>{if(i.tool==="draw_zone"){const F=Ks(f(S),i.gridSize,i.snapGrid);h({t:"DRAW_PT",v:F})}else i.tool==="select"&&h({t:"SELECT",v:null})},[i.tool,i.gridSize,i.snapGrid,f]),W=r.useCallback(S=>{if(i.tool==="draw_zone"&&i.drawing&&i.drawing.length>=3&&a&&j){const F={id:`zone-${Date.now()}`,name:"Nowa strefa",type:"other",floorId:j.id,polygon:[...i.drawing]};a(t.map(ie=>ie.id===j.id?{...j,zones:[...j.zones,F]}:ie)),h({t:"DRAW_END"})}},[i.tool,i.drawing,j,t,a]),me=r.useCallback(S=>{S.preventDefault(),h({t:"ZOOM",v:i.zoom*(S.deltaY>0?.9:1.1)})},[i.zoom]),ue=r.useCallback((S,F)=>{S.stopPropagation(),i.tool==="select"?h({t:"SELECT",v:{type:"zone",id:F.id}}):i.tool==="erase"&&!n&&a&&j&&a(t.map(ie=>ie.id===j.id?{...j,zones:j.zones.filter(Ne=>Ne.id!==F.id)}:ie))},[i.tool,n,j,t,a]);if(!j)return e.jsx("div",{className:Q.emptyState,children:"Brak kondygnacji."});const de=((ce=i.selected)==null?void 0:ce.type)==="zone"?j.zones.find(S=>{var F;return S.id===((F=i.selected)==null?void 0:F.id)}):null,ye=l?s.filter(S=>j.zones.some(F=>F.id===S.zoneId)||S.floorPlanPosition):[],ne=[{key:"grid",icon:"⊞",active:i.showGrid},{key:"dim",icon:"↔",active:i.showDim},{key:"labels",icon:"🏷",active:i.showLabels},{key:"occupancy",icon:"👥",active:i.showOccupancy},{key:"climate",icon:"🌡",active:i.showClimate}];return e.jsxs("div",{className:`nice-floor-plan-editor ${Q.root} ${p==="dark"?Q.dark:""} ${C??""}`,style:{position:"relative",...b},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:30},children:e.jsx(Me.NiceTutorialButton,{steps:Me.resolveTutorial(N,Us)})}),e.jsxs("div",{className:Q.topBar,children:[e.jsx("div",{className:Q.floorTabs,children:[...t].sort((S,F)=>S.level-F.level).map(S=>e.jsx("button",{className:`${Q.floorTab} ${i.floorId===S.id?Q.floorTabActive:""}`,onClick:()=>h({t:"FLOOR",v:S.id}),children:S.name},S.id))}),e.jsx("div",{className:Q.overlayControls,children:ne.map(S=>e.jsx("button",{title:S.key,className:`${Q.overlayBtn} ${S.active?Q.overlayBtnActive:""}`,onClick:()=>h({t:"TOGGLE",v:S.key}),children:S.icon},S.key))}),e.jsxs("div",{className:Q.zoomBar,children:[e.jsx("button",{onClick:()=>h({t:"ZOOM",v:i.zoom*1.2}),children:"+"}),e.jsxs("span",{children:[Math.round(i.zoom*100),"%"]}),e.jsx("button",{onClick:()=>h({t:"ZOOM",v:i.zoom*.8}),children:"−"}),e.jsx("button",{title:"Resetuj widok",onClick:()=>{h({t:"ZOOM",v:1}),h({t:"PAN",v:{x:0,y:0}})},children:"⊡"})]})]}),e.jsxs("div",{className:Q.editorBody,children:[!n&&e.jsx("div",{className:Q.toolPalette,children:Js.map(({tool:S,icon:F,label:ie})=>e.jsx("button",{title:ie,className:`${Q.toolBtn} ${i.tool===S?Q.toolBtnActive:""}`,onClick:()=>h({t:"TOOL",v:S}),children:F},S))}),e.jsx("div",{className:Q.canvasWrapper,children:e.jsxs("svg",{ref:u,className:`${Q.canvas} ${Q[`cur_${i.tool.replace("_","")}`]??""}`,onMouseDown:g,onMouseMove:m,onMouseUp:A,onClick:H,onDoubleClick:W,onWheel:me,children:[j.backgroundImage&&e.jsx("image",{href:j.backgroundImage,x:i.pan.x,y:i.pan.y,width:j.width*i.zoom,height:j.height*i.zoom,preserveAspectRatio:"xMidYMid meet",opacity:.35}),e.jsxs("g",{transform:`translate(${i.pan.x},${i.pan.y}) scale(${i.zoom})`,children:[i.showGrid&&(()=>{const S=[];for(let F=0;F<=j.width;F+=i.gridSize)S.push(e.jsx("line",{x1:F,y1:0,x2:F,y2:j.height,className:Q.gridLine},`v${F}`));for(let F=0;F<=j.height;F+=i.gridSize)S.push(e.jsx("line",{x1:0,y1:F,x2:j.width,y2:F,className:Q.gridLine},`h${F}`));return e.jsx("g",{children:S})})(),j.zones.map(S=>{var ke;const F=((ke=i.selected)==null?void 0:ke.id)===S.id,ie=zt(S.polygon),Ne=S.color??Ys(S.type);return e.jsxs("g",{className:Q.zoneGroup,onClick:fe=>ue(fe,S),children:[e.jsx("path",{d:Tt(S.polygon),fill:Ne,fillOpacity:S.opacity??.55,stroke:F?"var(--nice-primary-hover, #2563eb)":"var(--nice-text-muted, #94a3b8)",strokeWidth:F?2.5:1.5,className:Q.zonePath}),i.showLabels&&e.jsx("text",{x:ie.x,y:ie.y,textAnchor:"middle",dominantBaseline:"middle",className:Q.zoneLabel,children:S.name}),i.showClimate&&S.temperature!=null&&e.jsxs("text",{x:ie.x,y:ie.y+14,textAnchor:"middle",className:Q.climateLabel,children:[S.temperature.toFixed(1),"°C"," ",S.humidity!=null?`· ${S.humidity}%`:""]}),i.showOccupancy&&S.occupancy!=null&&e.jsxs("text",{x:ie.x,y:ie.y+26,textAnchor:"middle",className:Q.occupancyLabel,children:["👥 ",S.occupancy]}),i.showDim&&S.polygon.length>1&&S.polygon.map((fe,Te)=>{const Be=S.polygon[(Te+1)%S.polygon.length],Ge=(fe.x+Be.x)/2,tt=(fe.y+Be.y)/2,Oe=Math.sqrt((Be.x-fe.x)**2+(Be.y-fe.y)**2),$e=j.scale??0;return e.jsx("text",{x:Ge,y:tt-4,textAnchor:"middle",className:Q.dimLabel,children:$e>0?`${(Oe/$e).toFixed(1)}m`:`${Oe.toFixed(0)}px`},Te)})]},S.id)}),ye.map(S=>{var ke;const F=j.zones.find(fe=>fe.id===S.zoneId),ie=S.floorPlanPosition??(F?zt(F.polygon):null);if(!ie)return null;const Ne=((ke=i.selected)==null?void 0:ke.id)===S.id;return e.jsxs("g",{transform:`translate(${ie.x},${ie.y})`,className:Q.deviceGroup,onClick:fe=>{fe.stopPropagation(),h({t:"SELECT",v:{type:"device",id:S.id}})},children:[e.jsx("circle",{r:14,className:`${Q.devCircle} ${S.status==="online"?Q.devOnline:Q.devOffline} ${Ne?Q.devSelected:""}`}),e.jsx("text",{y:5,textAnchor:"middle",fontSize:12,children:Qs[S.type]??"📟"})]},S.id)}),i.drawing&&i.drawing.length>0&&e.jsxs("g",{children:[e.jsx("path",{d:Tt(i.drawing,!1),fill:"none",stroke:"var(--nice-primary-hover, #2563eb)",strokeWidth:2,strokeDasharray:"6,3"}),i.drawing.map((S,F)=>e.jsx("circle",{cx:S.x,cy:S.y,r:4,fill:"var(--nice-primary-hover, #2563eb)"},F))]})]})]})}),de&&e.jsxs("div",{className:Q.propPanel,children:[e.jsx("div",{className:Q.propTitle,children:de.name}),e.jsxs("div",{className:Q.propRow,children:[e.jsx("span",{children:"Typ"}),e.jsx("span",{children:de.type})]}),de.area!=null&&e.jsxs("div",{className:Q.propRow,children:[e.jsx("span",{children:"Pow."}),e.jsxs("span",{children:[de.area," m²"]})]}),de.temperature!=null&&e.jsxs("div",{className:Q.propRow,children:[e.jsx("span",{children:"Temp."}),e.jsxs("span",{children:[de.temperature.toFixed(1)," °C"]})]}),de.humidity!=null&&e.jsxs("div",{className:Q.propRow,children:[e.jsx("span",{children:"Wilgotność"}),e.jsxs("span",{children:[de.humidity," %"]})]}),de.co2!=null&&e.jsxs("div",{className:Q.propRow,children:[e.jsx("span",{children:"CO₂"}),e.jsxs("span",{children:[de.co2," ppm"]})]}),de.occupancy!=null&&e.jsxs("div",{className:Q.propRow,children:[e.jsx("span",{children:"Obecność"}),e.jsxs("span",{children:[de.occupancy," os."]})]})]})]}),e.jsxs("div",{className:Q.statusBar,children:[i.tool==="draw_zone"?"Klikaj punkty, dwa kliknięcia by zamknąć strefę.":i.selected?`Zaznaczono: ${i.selected.type} #${i.selected.id}`:`${j.name} — ${j.zones.length} strefa(y)`,i.tool==="draw_zone"&&i.drawing&&` (${i.drawing.length} pkt)`]})]})},tn="_overlay_58xqu_9",sn="_dialog_58xqu_55",nn="_header_58xqu_103",on="_title_58xqu_119",an="_closeButton_58xqu_133",cn="_content_58xqu_163",rn="_preview_58xqu_179",ln="_previewCanvas_58xqu_199",dn="_previewSvg_58xqu_217",un="_info_58xqu_227",pn="_section_58xqu_237",_n="_sectionTitle_58xqu_245",hn="_statGrid_58xqu_265",mn="_stat_58xqu_265",xn="_statLabel_58xqu_289",yn="_statValue_58xqu_301",vn="_warningsList_58xqu_313",fn="_warning_58xqu_313",gn="_warningIcon_58xqu_357",bn="_error_58xqu_367",jn="_errorIcon_58xqu_399",wn="_footer_58xqu_409",Nn="_cancelButton_58xqu_429",kn="_confirmButton_58xqu_461",Cn="_noWarnings_58xqu_503",In="_layersList_58xqu_515",Sn="_layer_58xqu_515",Ln="_layerIcon_58xqu_557",zn="_layerName_58xqu_565",Tn="_layerCount_58xqu_575",G={overlay:tn,dialog:sn,header:nn,title:on,closeButton:an,content:cn,preview:rn,previewCanvas:ln,previewSvg:dn,info:un,section:pn,sectionTitle:_n,statGrid:hn,stat:mn,statLabel:xn,statValue:yn,warningsList:vn,warning:fn,warningIcon:gn,error:bn,errorIcon:jn,footer:wn,cancelButton:Nn,confirmButton:kn,noWarnings:Cn,layersList:In,layer:Sn,layerIcon:Ln,layerName:zn,layerCount:Tn},Bn=()=>e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M15 5L5 15M5 5L15 15",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),Bt=()=>e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"currentColor",children:e.jsx("path",{d:"M7 0a7 7 0 1 0 0 14A7 7 0 0 0 7 0zm0 12.5a.75.75 0 1 1 0-1.5.75.75 0 0 1 0 1.5zm.75-3.25a.75.75 0 0 1-1.5 0v-4a.75.75 0 0 1 1.5 0v4z"})}),$t=()=>e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"currentColor",children:e.jsx("path",{d:"M7 0a7 7 0 1 0 0 14A7 7 0 0 0 7 0zm2.8 9.15a.5.5 0 0 1-.65.65L7 8.45l-2.15 1.35a.5.5 0 0 1-.65-.65L5.55 7 4.2 4.85a.5.5 0 0 1 .65-.65L7 5.55l2.15-1.35a.5.5 0 0 1 .65.65L8.45 7l1.35 2.15z"})}),Pt=()=>e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"currentColor",children:e.jsx("path",{d:"M6 0L0 3l6 3 6-3-6-3zM0 6l6 3 6-3M0 9l6 3 6-3",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})}),$n=()=>e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"currentColor",children:e.jsx("path",{d:"M2 12h2V5H2v7zm4 0h2V2H6v10zm4 0h2V7h-2v5z"})});function Pn({result:t,onConfirm:s,onCancel:a}){const o=t.document,n=r.useMemo(()=>{var i,h;if(!((i=o==null?void 0:o.floors)!=null&&i.length))return null;const d=o.floors[0],C=(d==null?void 0:d.layers)||[],b=C.flatMap(j=>j.objects);let p=1/0,N=1/0,u=-1/0,w=-1/0;for(const j of b)j.bounds?(p=Math.min(p,j.bounds.x),N=Math.min(N,j.bounds.y),u=Math.max(u,j.bounds.x+j.bounds.width),w=Math.max(w,j.bounds.y+j.bounds.height)):(h=j.transform)!=null&&h.position&&(p=Math.min(p,j.transform.position.x),N=Math.min(N,j.transform.position.y),u=Math.max(u,j.transform.position.x),w=Math.max(w,j.transform.position.y));isFinite(p)||(d!=null&&d.bounds?(p=d.bounds.x,N=d.bounds.y,u=d.bounds.x+d.bounds.width,w=d.bounds.y+d.bounds.height):(p=0,N=0,u=1e3,w=800));const T=20;return{viewBox:{x:p-T,y:N-T,width:u-p+T*2,height:w-N+T*2},objects:b,layers:C}},[o]),c=r.useMemo(()=>{if(!n||!o)return null;const{viewBox:d,objects:C}=n,b=[],p=50,N=`
2
+ <pattern id="grid" width="${p}" height="${p}" patternUnits="userSpaceOnUse">
3
+ <path d="M ${p} 0 L 0 0 0 ${p}" fill="none" stroke="var(--nice-border, #e2e8f0)" strokeWidth="0.5"/>
4
4
  </pattern>
5
- `;return N.forEach((x,j)=>{if(x.type==="wall"&&x.bounds)b.push(e.jsx("rect",{x:x.bounds.x,y:x.bounds.y,width:x.bounds.width,height:x.bounds.height,fill:"var(--nice-text-secondary, #475569)",stroke:"var(--nice-text, #334155)",strokeWidth:"1"},`wall-${j}`));else if(x.type==="zone"&&x.boundary){const L=x.boundary.map((p,C)=>`${C===0?"M":"L"} ${p.x} ${p.y}`).join(" ")+" Z";b.push(e.jsx("path",{d:L,fill:"var(--nice-primary-tint-20, rgba(59, 130, 246, 0.2))",stroke:"var(--nice-primary, #3b82f6)",strokeWidth:"1"},`zone-${j}`))}else if(x.type==="room"&&x.boundary){const L=x.boundary.map((p,C)=>`${C===0?"M":"L"} ${p.x} ${p.y}`).join(" ")+" Z";b.push(e.jsx("path",{d:L,fill:"var(--nice-success-tint-15, rgba(34, 197, 94, 0.15))",stroke:"var(--nice-success, #22c55e)",strokeWidth:"1"},`room-${j}`))}else x.bounds&&b.push(e.jsx("rect",{x:x.bounds.x,y:x.bounds.y,width:x.bounds.width,height:x.bounds.height,fill:"var(--nice-accent-tint-30, rgba(99, 102, 241, 0.3))",stroke:"var(--nice-info, #6366f1)",strokeWidth:"0.5",rx:"2"},`obj-${j}`))}),e.jsxs("svg",{viewBox:`${u.x} ${u.y} ${u.width} ${u.height}`,className:W.previewSvg,preserveAspectRatio:"xMidYMid meet",children:[e.jsx("defs",{dangerouslySetInnerHTML:{__html:h}}),e.jsx("rect",{x:u.x,y:u.y,width:u.width,height:u.height,fill:"url(#grid)"}),b]})},[n,o]),d=r.useCallback(u=>{u.key==="Escape"&&a()},[a]),y=r.useCallback(u=>{u.target===u.currentTarget&&a()},[a]),f=t.errors.some(u=>u.fatal),g=t.errors.filter(u=>!u.fatal);return e.jsx("div",{className:W.overlay,onClick:y,onKeyDown:d,tabIndex:-1,role:"dialog","aria-modal":"true","aria-labelledby":"import-preview-title",children:e.jsxs("div",{className:W.dialog,children:[e.jsxs("div",{className:W.header,children:[e.jsx("h2",{id:"import-preview-title",className:W.title,children:"Import Preview"}),e.jsx("button",{className:W.closeButton,onClick:a,title:"Close","aria-label":"Close dialog",children:e.jsx(zn,{})})]}),e.jsxs("div",{className:W.content,children:[e.jsx("div",{className:W.preview,children:c||e.jsx("div",{className:W.previewCanvas,children:"No preview available"})}),e.jsxs("div",{className:W.info,children:[e.jsxs("div",{className:W.section,children:[e.jsxs("h3",{className:W.sectionTitle,children:[e.jsx($n,{})," Import Statistics"]}),e.jsxs("div",{className:W.statGrid,children:[e.jsxs("div",{className:W.stat,children:[e.jsx("div",{className:W.statLabel,children:"Walls"}),e.jsx("div",{className:W.statValue,children:t.stats.wallsImported})]}),e.jsxs("div",{className:W.stat,children:[e.jsx("div",{className:W.statLabel,children:"Zones"}),e.jsx("div",{className:W.statValue,children:t.stats.zonesImported})]}),e.jsxs("div",{className:W.stat,children:[e.jsx("div",{className:W.statLabel,children:"Objects"}),e.jsx("div",{className:W.statValue,children:t.stats.objectsImported})]}),e.jsxs("div",{className:W.stat,children:[e.jsx("div",{className:W.statLabel,children:"Skipped"}),e.jsx("div",{className:W.statValue,children:t.stats.entitiesSkipped})]})]})]}),n&&n.layers.length>0&&e.jsxs("div",{className:W.section,children:[e.jsxs("h3",{className:W.sectionTitle,children:[e.jsx(Bt,{})," Layers (",n.layers.length,")"]}),e.jsxs("ul",{className:W.layersList,children:[n.layers.slice(0,6).map((u,N)=>{var b;return e.jsxs("li",{className:W.layer,children:[e.jsx("span",{className:W.layerIcon,children:e.jsx(Bt,{})}),e.jsx("span",{className:W.layerName,children:u.name}),e.jsx("span",{className:W.layerCount,children:((b=u.objects)==null?void 0:b.length)||0})]},u.id||N)}),n.layers.length>6&&e.jsx("li",{className:W.layer,children:e.jsxs("span",{className:W.layerName,children:["+",n.layers.length-6," more..."]})})]})]}),t.warnings.length>0&&e.jsxs("div",{className:W.section,children:[e.jsxs("h3",{className:W.sectionTitle,children:[e.jsx(zt,{})," Warnings (",t.warnings.length,")"]}),e.jsxs("ul",{className:W.warningsList,children:[t.warnings.slice(0,5).map((u,N)=>e.jsxs("li",{className:W.warning,children:[e.jsx("span",{className:W.warningIcon,children:e.jsx(zt,{})}),e.jsx("span",{children:u.message})]},N)),t.warnings.length>5&&e.jsxs("li",{className:W.warning,children:["+",t.warnings.length-5," more warnings..."]})]})]}),g.length>0&&e.jsxs("div",{className:W.section,children:[e.jsxs("h3",{className:W.sectionTitle,children:[e.jsx($t,{})," Errors (",g.length,")"]}),e.jsx("ul",{className:W.warningsList,children:g.slice(0,5).map((u,N)=>e.jsxs("li",{className:W.error,children:[e.jsx("span",{className:W.errorIcon,children:e.jsx($t,{})}),e.jsx("span",{children:u.message})]},N))})]}),t.warnings.length===0&&g.length===0&&e.jsx("div",{className:W.section,children:e.jsx("p",{className:W.noWarnings,children:"✓ No warnings or errors found"})})]})]}),e.jsxs("div",{className:W.footer,children:[e.jsx("button",{className:W.cancelButton,onClick:a,children:"Cancel"}),e.jsx("button",{className:W.confirmButton,onClick:s,disabled:f,children:f?"Cannot Import (Fatal Errors)":"Confirm Import"})]})]})})}const Tn="_overlay_1okdy_9",Pn="_dialog_1okdy_55",Mn="_header_1okdy_103",On="_title_1okdy_119",An="_closeButton_1okdy_133",En="_content_1okdy_163",Dn="_description_1okdy_175",Rn="_mappingTable_1okdy_187",Wn="_sourceLayer_1okdy_237",Gn="_layerIcon_1okdy_249",qn="_layerName_1okdy_257",Fn="_objectCount_1okdy_269",Vn="_targetSelect_1okdy_281",Hn="_skipOption_1okdy_323",Un="_arrowIcon_1okdy_333",Zn="_presets_1okdy_343",Yn="_presetButton_1okdy_357",Kn="_footer_1okdy_389",Xn="_footerLeft_1okdy_409",Jn="_checkbox_1okdy_421",Qn="_checkboxLabel_1okdy_433",eo="_footerRight_1okdy_443",to="_cancelButton_1okdy_453",so="_confirmButton_1okdy_485",ae={overlay:Tn,dialog:Pn,header:Mn,title:On,closeButton:An,content:En,description:Dn,mappingTable:Rn,sourceLayer:Wn,layerIcon:Gn,layerName:qn,objectCount:Fn,targetSelect:Vn,skipOption:Hn,arrowIcon:Un,presets:Zn,presetButton:Yn,footer:Kn,footerLeft:Xn,checkbox:Jn,checkboxLabel:Qn,footerRight:eo,cancelButton:to,confirmButton:so},Tt=()=>e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M15 5L5 15M5 5L15 15",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),no=()=>e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.2",children:e.jsx("path",{d:"M7 1L1 4l6 3 6-3-6-3zM1 7l6 3 6-3M1 10l6 3 6-3"})}),oo=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{d:"M4 8h8M9 5l3 3-3 3",strokeLinecap:"round",strokeLinejoin:"round"})}),Pt={"floor-plan":"Plan piętra",walls:"Ściany",rooms:"Pomieszczenia",zones:"Strefy","doors-windows":"Drzwi i okna",furniture:"Meble",devices:"Urządzenia",network:"Sieć",infrastructure:"Infrastruktura",electrical:"Elektryka",plumbing:"Hydraulika",hvac:"HVAC",annotations:"Adnotacje",dimensions:"Wymiary",grid:"Siatka",background:"Tło","game-objects":"Obiekty gry",collision:"Kolizje",custom:"Własne"};function ao(t){if(!t.document)return[];const s=[];for(const a of t.document.floors)for(const o of a.layers)s.push({id:o.id,name:o.name,type:o.type,objectCount:o.objects.length});return s}function co(t){if(!t)return[];const s=[];for(const a of t.floors)for(const o of a.layers)s.find(n=>n.id===o.id)||s.push(o);return s}function Mt(t,s){const a=new Map;for(const o of t){const n=s.find(y=>y.type===o.type);if(n){a.set(o.id,n.id);continue}const c=o.name.toLowerCase(),d=s.find(y=>y.name.toLowerCase()===c);if(d){a.set(o.id,d.id);continue}a.set(o.id,o.id)}return a}const ro=({importResult:t,existingDocument:s,onConfirm:a,onCancel:o})=>{const n=r.useMemo(()=>ao(t),[t]),c=r.useMemo(()=>co(s),[s]),[d,y]=r.useState(()=>Mt(n,c)),[f,g]=r.useState(!0),u=r.useCallback((x,j)=>{y(i=>{const L=new Map(i);return L.set(x,j),L})},[]),N=r.useCallback(x=>{const j=new Map;switch(x){case"auto":y(Mt(n,c));return;case"skip-all":for(const i of n)j.set(i.id,"skip");break;case"preserve":for(const i of n)j.set(i.id,i.id);break}y(j)},[n,c]),b=r.useCallback(()=>{a(d,f)},[d,f,a]),v=r.useCallback(x=>{x.key==="Escape"?o():x.key==="Enter"&&(x.ctrlKey||x.metaKey)&&b()},[o,b]),h=r.useCallback(x=>{x.target===x.currentTarget&&o()},[o]);return n.length===0?e.jsx("div",{className:ae.overlay,onClick:h,onKeyDown:v,tabIndex:-1,children:e.jsxs("div",{className:ae.dialog,children:[e.jsxs("div",{className:ae.header,children:[e.jsx("h2",{className:ae.title,children:"Mapowanie warstw"}),e.jsx("button",{className:ae.closeButton,onClick:o,children:e.jsx(Tt,{})})]}),e.jsx("div",{className:ae.content,children:e.jsx("p",{className:ae.description,children:"Importowany plik nie zawiera żadnych warstw."})}),e.jsxs("div",{className:ae.footer,children:[e.jsx("div",{className:ae.footerLeft}),e.jsx("div",{className:ae.footerRight,children:e.jsx("button",{className:ae.cancelButton,onClick:o,children:"Zamknij"})})]})]})}):e.jsx("div",{className:ae.overlay,onClick:h,onKeyDown:v,tabIndex:-1,children:e.jsxs("div",{className:ae.dialog,children:[e.jsxs("div",{className:ae.header,children:[e.jsx("h2",{className:ae.title,children:"Mapowanie warstw"}),e.jsx("button",{className:ae.closeButton,onClick:o,children:e.jsx(Tt,{})})]}),e.jsxs("div",{className:ae.content,children:[e.jsx("p",{className:ae.description,children:"Wybierz jak warstwy z importowanego pliku mają być przypisane do warstw w edytorze."}),e.jsxs("table",{className:ae.mappingTable,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Warstwa źródłowa"}),e.jsx("th",{}),e.jsx("th",{children:"Warstwa docelowa"})]})}),e.jsx("tbody",{children:n.map(x=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsxs("div",{className:ae.sourceLayer,children:[e.jsx("span",{className:ae.layerIcon,children:e.jsx(no,{})}),e.jsx("span",{className:ae.layerName,children:x.name}),e.jsxs("span",{className:ae.objectCount,children:["(",x.objectCount," ",x.objectCount===1?"obiekt":"obiektów",")"]})]})}),e.jsx("td",{className:ae.arrowIcon,children:e.jsx(oo,{})}),e.jsx("td",{children:e.jsxs("select",{className:ae.targetSelect,value:d.get(x.id)||x.id,onChange:j=>u(x.id,j.target.value),children:[e.jsx("option",{value:"skip",className:ae.skipOption,children:"— Pomiń tę warstwę —"}),e.jsxs("option",{value:x.id,children:["Utwórz: ",x.name," (",Pt[x.type],")"]}),c.map(j=>e.jsxs("option",{value:j.id,children:[j.name," (",Pt[j.type],")"]},j.id))]})})]},x.id))})]}),e.jsxs("div",{className:ae.presets,children:[e.jsx("button",{className:ae.presetButton,onClick:()=>N("auto"),children:"Auto-mapowanie"}),e.jsx("button",{className:ae.presetButton,onClick:()=>N("preserve"),children:"Zachowaj wszystkie"}),e.jsx("button",{className:ae.presetButton,onClick:()=>N("skip-all"),children:"Pomiń wszystkie"})]})]}),e.jsxs("div",{className:ae.footer,children:[e.jsxs("div",{className:ae.footerLeft,children:[e.jsx("input",{type:"checkbox",id:"createMissing",className:ae.checkbox,checked:f,onChange:x=>g(x.target.checked)}),e.jsx("label",{htmlFor:"createMissing",className:ae.checkboxLabel,children:"Utwórz brakujące warstwy"})]}),e.jsxs("div",{className:ae.footerRight,children:[e.jsx("button",{className:ae.cancelButton,onClick:o,children:"Anuluj"}),e.jsx("button",{className:ae.confirmButton,onClick:b,children:"Zastosuj mapowanie"})]})]})]})})},io="_root_4ino1_9",lo="_header_4ino1_21",uo="_title_4ino1_31",po="_layerList_4ino1_45",_o="_layerItem_4ino1_55",ho="_hidden_4ino1_83",mo="_locked_4ino1_91",xo="_visibilityBtn_4ino1_99",yo="_lockBtn_4ino1_101",vo="_layerIcon_4ino1_139",fo="_layerName_4ino1_147",go="_opacitySlider_4ino1_157",Ne={root:io,header:lo,title:uo,layerList:po,layerItem:_o,hidden:ho,locked:mo,visibilityBtn:xo,lockBtn:yo,layerIcon:vo,layerName:fo,opacitySlider:go},bo={"floor-plan":{icon:"🏠",label:"Floor Plan"},zones:{icon:"⬡",label:"Zones"},devices:{icon:"📡",label:"Devices"},furniture:{icon:"🛋️",label:"Furniture"},network:{icon:"🌐",label:"Network"},infrastructure:{icon:"⚙️",label:"Infrastructure"},annotations:{icon:"📝",label:"Annotations"},dimensions:{icon:"↔",label:"Dimensions"},grid:{icon:"⊞",label:"Grid"},background:{icon:"🖼️",label:"Background"},"game-objects":{icon:"🎮",label:"Game Objects"},collision:{icon:"⬜",label:"Collision"}},Ut=({layers:t,onVisibilityToggle:s,onLockToggle:a,onOpacityChange:o,className:n})=>{const c=[...t].sort((d,y)=>y.zIndex-d.zIndex);return e.jsxs("div",{className:`${Ne.root} ${n??""}`,children:[e.jsx("div",{className:Ne.header,children:e.jsx("h3",{className:Ne.title,children:"Layers"})}),e.jsx("div",{className:Ne.layerList,children:c.map(d=>{const y=bo[d.type]||{icon:"📦",label:d.type};return e.jsxs("div",{className:`${Ne.layerItem} ${d.visible?"":Ne.hidden} ${d.locked?Ne.locked:""}`,children:[e.jsx("button",{className:Ne.visibilityBtn,onClick:()=>s(d.type),title:d.visible?"Hide layer":"Show layer",children:d.visible?"👁":"👁‍🗨"}),e.jsx("button",{className:Ne.lockBtn,onClick:()=>a(d.type),title:d.locked?"Unlock layer":"Lock layer",children:d.locked?"🔒":"🔓"}),e.jsx("span",{className:Ne.layerIcon,children:y.icon}),e.jsx("span",{className:Ne.layerName,children:y.label}),e.jsx("input",{type:"range",min:"0",max:"1",step:"0.1",value:d.opacity,onChange:f=>o(d.type,parseFloat(f.target.value)),className:Ne.opacitySlider,title:`Opacity: ${Math.round(d.opacity*100)}%`})]},d.type)})})]})},jo="_root_1lufq_9",wo="_svg_1lufq_31",No="_viewportRect_1lufq_41",ko="_zoomIndicator_1lufq_49",nt={root:jo,svg:wo,viewportRect:No,zoomIndicator:ko},Zt=({document:t,activeFloorId:s,viewport:a,onViewportChange:o,size:n=150,className:c})=>{var p,C;const d=r.useRef(null),y=r.useMemo(()=>t.floors.find(w=>w.id===s)??t.floors[0]??null,[t,s]);if(!y)return null;const f=((p=y.dimensions)==null?void 0:p.width)??1e3,g=((C=y.dimensions)==null?void 0:C.height)??800,u=Math.min(n/f,n/g)*.9,N=f*u,b=g*u,v=n/a.zoom*u,h=n/a.zoom*u,x=-a.pan.x/a.zoom*u,j=-a.pan.y/a.zoom*u,i=r.useCallback(w=>{var me;const l=(me=d.current)==null?void 0:me.getBoundingClientRect();if(!l)return;const $=(w.clientX-l.left-(n-N)/2)/u,E=(w.clientY-l.top-(n-b)/2)/u,V=-($-n/a.zoom/2)*a.zoom,G=-(E-n/a.zoom/2)*a.zoom;o({pan:{x:V,y:G}})},[u,n,N,b,a.zoom,o]),L=r.useMemo(()=>{const w=y.layers.find(l=>l.name==="zones");return w?w.objects.map(l=>{const $=l;if(!$.polygon||$.polygon.length<3)return null;const E=$.polygon.map((V,G)=>`${G===0?"M":"L"}${V.x*u},${V.y*u}`).join(" ")+" Z";return e.jsx("path",{d:E,fill:$.color??"var(--nice-primary-bg, #dbeafe)",fillOpacity:.6,stroke:"var(--nice-text-muted, #94a3b8)",strokeWidth:.5},$.id)}):null},[y,u]);return e.jsxs("div",{className:`${nt.root} ${c??""}`,children:[e.jsxs("svg",{ref:d,width:n,height:n,viewBox:`0 0 ${n} ${n}`,className:nt.svg,onClick:i,children:[e.jsx("rect",{x:(n-N)/2,y:(n-b)/2,width:N,height:b,fill:"var(--nice-text, #1e293b)",stroke:"var(--nice-text-secondary, #475569)",strokeWidth:1}),e.jsx("g",{transform:`translate(${(n-N)/2}, ${(n-b)/2})`,children:L}),e.jsx("rect",{x:(n-N)/2+x,y:(n-b)/2+j,width:Math.min(v,N),height:Math.min(h,b),fill:"var(--nice-primary-tint-20, rgba(59, 130, 246, 0.2))",stroke:"var(--nice-primary, #3b82f6)",strokeWidth:1.5,rx:2,className:nt.viewportRect})]}),e.jsxs("div",{className:nt.zoomIndicator,children:[Math.round(a.zoom*100),"%"]})]})},Co="_panel_vacy7_9",Io="_header_vacy7_27",So="_title_vacy7_45",Lo="_closeButton_vacy7_59",zo="_content_vacy7_85",$o="_endpointSection_vacy7_99",Bo="_endpointLabel_vacy7_107",To="_endpointSelect_vacy7_123",Po="_optionsSection_vacy7_157",Mo="_metricButton_vacy7_169",Oo="_metricButtonActive_vacy7_205",Ao="_analyzeButton_vacy7_219",Eo="_resultsSection_vacy7_267",Do="_resultsTitle_vacy7_277",Ro="_noResults_vacy7_293",Wo="_pathCard_vacy7_309",Go="_pathCardSelected_vacy7_333",qo="_pathCardHeader_vacy7_343",Fo="_pathCardTitle_vacy7_361",Vo="_pathBadge_vacy7_373",Ho="_badgePrimary_vacy7_389",Uo="_badgeAlternate_vacy7_399",Zo="_pathName_vacy7_409",Yo="_pathStatus_vacy7_421",Ko="_statusDot_vacy7_435",Xo="_statusActive_vacy7_447",Jo="_statusDegraded_vacy7_449",Qo="_statusInactive_vacy7_451",ea="_statusError_vacy7_453",ta="_pathStats_vacy7_459",sa="_statItem_vacy7_473",na="_statValue_vacy7_481",oa="_statLabel_vacy7_493",aa="_pathVisualization_vacy7_507",ca="_pathDiagram_vacy7_519",ra="_pathNode_vacy7_535",ia="_pathNodeStart_vacy7_567",la="_pathNodeEnd_vacy7_569",da="_pathLink_vacy7_579",ua="_pathLinkLine_vacy7_591",pa="_showOnMapButton_vacy7_605",_a="_loading_vacy7_641",ha="_spinner_vacy7_655",ma="_spin_vacy7_655",R={panel:Co,header:Io,title:So,closeButton:Lo,content:zo,endpointSection:$o,endpointLabel:Bo,endpointSelect:To,optionsSection:Po,metricButton:Mo,metricButtonActive:Oo,analyzeButton:Ao,resultsSection:Eo,resultsTitle:Do,noResults:Ro,pathCard:Wo,pathCardSelected:Go,pathCardHeader:qo,pathCardTitle:Fo,pathBadge:Vo,badgePrimary:Ho,badgeAlternate:Uo,pathName:Zo,pathStatus:Yo,statusDot:Ko,statusActive:Xo,statusDegraded:Jo,statusInactive:Qo,statusError:ea,pathStats:ta,statItem:sa,statValue:na,statLabel:oa,pathVisualization:aa,pathDiagram:ca,pathNode:ra,pathNodeStart:ia,pathNodeEnd:la,pathLink:da,pathLinkLine:ua,showOnMapButton:pa,loading:_a,spinner:ha,spin:ma},xa=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:e.jsx("path",{d:"M12 4L4 12M4 4L12 12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),ya=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{d:"M4 8h8M9 5l3 3-3 3",strokeLinecap:"round",strokeLinejoin:"round"})});function va(t){switch(t){case"active":return"Aktywna";case"degraded":return"Degradacja";case"inactive":return"Nieaktywna";case"error":return"Błąd";default:return"Nieznany"}}function fa(t){return t<1?"<1ms":t<1e3?`${Math.round(t)}ms`:`${(t/1e3).toFixed(1)}s`}function ga(t){return t>=1e3?`${(t/1e3).toFixed(1)} Gbps`:`${Math.round(t)} Mbps`}const ba=({document:t,connections:s,onHighlightPath:a,onClose:o})=>{const[n,c]=r.useState(""),[d,y]=r.useState(""),[f,g]=r.useState("latency"),[u,N]=r.useState([]),[b,v]=r.useState(null),[h,x]=r.useState(!1),j=r.useMemo(()=>{const w=[];for(const l of t.floors)for(const $ of l.layers)if($.type==="network"||$.type==="devices"||$.type==="infrastructure")for(const E of $.objects)w.push({id:E.id,name:E.name??E.id});return w},[t]),i=r.useCallback(w=>{var l;return((l=j.find($=>$.id===w))==null?void 0:l.name)??w},[j]),L=r.useCallback(()=>{!n||!d||n===d||(x(!0),N([]),v(null),setTimeout(()=>{const w=H.findShortestPath(s,n,d,f),l=H.findAllPaths(s,n,d,5),$=[];w&&$.push(w);for(const E of l)$.some(V=>V.connectionIds.length===E.connectionIds.length&&V.connectionIds.every((G,me)=>E.connectionIds[me]===G))||$.push({...E,isPrimary:!1});N($),$.length>0&&(v($[0].id),a==null||a($[0])),x(!1)},300))},[n,d,f,s,a]),p=r.useCallback(w=>{v(w.id),a==null||a(w)},[a]),C=r.useCallback(w=>{const l=[w.startDeviceId];for(const $ of w.connectionIds){const E=s.find(V=>V.id===$);if(E){const V=l[l.length-1],G=E.sourceId===V?E.targetId:E.sourceId;l.includes(G)||l.push(G)}}return l},[s]);return e.jsxs("div",{className:R.panel,children:[e.jsxs("div",{className:R.header,children:[e.jsx("h3",{className:R.title,children:"Analiza ścieżki sieciowej"}),o&&e.jsx("button",{className:R.closeButton,onClick:o,children:e.jsx(xa,{})})]}),e.jsxs("div",{className:R.content,children:[e.jsxs("div",{className:R.endpointSection,children:[e.jsx("label",{className:R.endpointLabel,children:"Urządzenie źródłowe"}),e.jsxs("select",{className:R.endpointSelect,value:n,onChange:w=>c(w.target.value),children:[e.jsx("option",{value:"",children:"— Wybierz urządzenie —"}),j.map(w=>e.jsx("option",{value:w.id,children:w.name},w.id))]})]}),e.jsxs("div",{className:R.endpointSection,children:[e.jsx("label",{className:R.endpointLabel,children:"Urządzenie docelowe"}),e.jsxs("select",{className:R.endpointSelect,value:d,onChange:w=>y(w.target.value),children:[e.jsx("option",{value:"",children:"— Wybierz urządzenie —"}),j.filter(w=>w.id!==n).map(w=>e.jsx("option",{value:w.id,children:w.name},w.id))]})]}),e.jsxs("div",{className:R.optionsSection,children:[e.jsx("button",{className:`${R.metricButton} ${f==="latency"?R.metricButtonActive:""}`,onClick:()=>g("latency"),children:"Latencja"}),e.jsx("button",{className:`${R.metricButton} ${f==="hops"?R.metricButtonActive:""}`,onClick:()=>g("hops"),children:"Hops"}),e.jsx("button",{className:`${R.metricButton} ${f==="bandwidth"?R.metricButtonActive:""}`,onClick:()=>g("bandwidth"),children:"Przepustowość"})]}),e.jsx("button",{className:R.analyzeButton,onClick:L,disabled:!n||!d||n===d||h,children:h?"Analizowanie...":"Analizuj ścieżkę"}),h?e.jsx("div",{className:R.loading,children:e.jsx("div",{className:R.spinner})}):u.length>0?e.jsxs("div",{className:R.resultsSection,children:[e.jsxs("div",{className:R.resultsTitle,children:["Znalezione ścieżki (",u.length,")"]}),u.map((w,l)=>{const $=C(w),E=b===w.id;return e.jsxs("div",{className:`${R.pathCard} ${E?R.pathCardSelected:""}`,onClick:()=>p(w),children:[e.jsxs("div",{className:R.pathCardHeader,children:[e.jsxs("div",{className:R.pathCardTitle,children:[e.jsx("span",{className:`${R.pathBadge} ${w.isPrimary?R.badgePrimary:R.badgeAlternate}`,children:w.isPrimary?"Optymalna":`Alt ${l}`}),e.jsxs("span",{className:R.pathName,children:[w.connectionIds.length," połączeń"]})]}),e.jsxs("div",{className:R.pathStatus,children:[e.jsx("span",{className:`${R.statusDot} ${R[`status${w.status.charAt(0).toUpperCase()+w.status.slice(1)}`]??""}`}),e.jsx("span",{children:va(w.status)})]})]}),e.jsxs("div",{className:R.pathStats,children:[e.jsxs("div",{className:R.statItem,children:[e.jsx("div",{className:R.statValue,children:fa(w.totalLatency)}),e.jsx("div",{className:R.statLabel,children:"Latencja"})]}),e.jsxs("div",{className:R.statItem,children:[e.jsx("div",{className:R.statValue,children:w.connectionIds.length}),e.jsx("div",{className:R.statLabel,children:"Hops"})]}),e.jsxs("div",{className:R.statItem,children:[e.jsx("div",{className:R.statValue,children:w.bottleneckBandwidth>0?ga(w.bottleneckBandwidth):"N/A"}),e.jsx("div",{className:R.statLabel,children:"Przepustowość"})]})]}),E&&e.jsxs("div",{className:R.pathVisualization,children:[e.jsx("div",{className:R.pathDiagram,children:$.map((V,G)=>e.jsxs(r.Fragment,{children:[e.jsx("div",{className:`${R.pathNode} ${G===0?R.pathNodeStart:G===$.length-1?R.pathNodeEnd:""}`,children:i(V).substring(0,8)}),G<$.length-1&&e.jsxs("div",{className:R.pathLink,children:[e.jsx("div",{className:R.pathLinkLine}),e.jsx(ya,{})]})]},V))}),e.jsx("button",{className:R.showOnMapButton,onClick:V=>{V.stopPropagation(),a==null||a(w)},children:"Pokaż na mapie"})]})]},w.id)})]}):n&&d&&n!==d?e.jsx("div",{className:R.noResults,children:'Wybierz urządzenia i kliknij „Analizuj ścieżkę"'}):e.jsx("div",{className:R.noResults,children:"Wybierz urządzenie źródłowe i docelowe"})]})]})},ja="_root_6pirz_9",wa="_header_6pirz_27",Na="_title_6pirz_37",ka="_search_6pirz_51",Ca="_categories_6pirz_79",Ia="_category_6pirz_91",Sa="_categoryHeader_6pirz_107",La="_categoryIcon_6pirz_143",za="_categoryLabel_6pirz_151",$a="_categoryCount_6pirz_161",Ba="_expandIcon_6pirz_171",Ta="_items_6pirz_181",Pa="_item_6pirz_181",Ma="_itemIcon_6pirz_241",Oa="_itemName_6pirz_249",Aa="_emptyState_6pirz_269",fe={root:ja,header:wa,title:Na,search:ka,categories:Ca,category:Ia,categoryHeader:Sa,categoryIcon:La,categoryLabel:za,categoryCount:$a,expandIcon:Ba,items:Ta,item:Pa,itemIcon:Ma,itemName:Oa,emptyState:Aa},Ea={"floor-plan":["smart-home","building"],"network-topology":["network"],infrastructure:["infrastructure","network"],cad:["building"],interior:["furniture","smart-home"],"game-scene":["game"]},Da={"smart-home":{icon:"🏠",label:"Smart Home"},furniture:{icon:"🛋️",label:"Furniture"},network:{icon:"🌐",label:"Network"},infrastructure:{icon:"⚙️",label:"Infrastructure"},building:{icon:"🏗️",label:"Building"},zone:{icon:"🗺️",label:"Zones"},game:{icon:"🎮",label:"Game Objects"},annotation:{icon:"📝",label:"Annotations"}},Yt=({mode:t,onObjectSelect:s,customObjects:a=[],className:o})=>{const[n,c]=r.useState(""),[d,y]=r.useState(new Set(["smart-home","furniture","network"])),f=Ea[t]||[],g=r.useMemo(()=>{const b={},v=H.OBJECT_CATALOG.reduce((h,x)=>{var j;return(h[j=x.category]??(h[j]=[])).push(x),h},{});return Object.entries(v).forEach(([h,x])=>{if(!f.includes(h))return;const j=x.filter(i=>!n||i.name.toLowerCase().includes(n.toLowerCase()));j.length>0&&(b[h]=j.map(i=>({id:i.id,name:i.name,category:h,icon:i.icon})))}),a.forEach(h=>{f.includes(h.category)&&(!n||h.name.toLowerCase().includes(n.toLowerCase()))&&(b[h.category]||(b[h.category]=[]),b[h.category].push(h))}),b},[f,n,a]),u=b=>{y(v=>{const h=new Set(v);return h.has(b)?h.delete(b):h.add(b),h})},N=(b,v)=>{b.dataTransfer.setData("application/json",JSON.stringify(v)),b.dataTransfer.effectAllowed="copy"};return e.jsxs("div",{className:`${fe.root} ${o??""}`,children:[e.jsxs("div",{className:fe.header,children:[e.jsx("h3",{className:fe.title,children:"Objects"}),e.jsx("input",{type:"text",className:fe.search,placeholder:"Search...",value:n,onChange:b=>c(b.target.value)})]}),e.jsxs("div",{className:fe.categories,children:[Object.entries(g).map(([b,v])=>{const h=Da[b]||{icon:"📦",label:b},x=d.has(b);return e.jsxs("div",{className:fe.category,children:[e.jsxs("button",{className:fe.categoryHeader,onClick:()=>u(b),children:[e.jsx("span",{className:fe.categoryIcon,children:h.icon}),e.jsx("span",{className:fe.categoryLabel,children:h.label}),e.jsxs("span",{className:fe.categoryCount,children:["(",v.length,")"]}),e.jsx("span",{className:fe.expandIcon,children:x?"▼":"▶"})]}),x&&e.jsx("div",{className:fe.items,children:v.map(j=>e.jsxs("div",{className:fe.item,draggable:!0,onDragStart:i=>N(i,j),onClick:()=>s(j),title:j.name,children:[e.jsx("span",{className:fe.itemIcon,children:j.icon||"📦"}),e.jsx("span",{className:fe.itemName,children:j.name})]},j.id))})]},b)}),Object.keys(g).length===0&&e.jsx("div",{className:fe.emptyState,children:n?`No objects matching "${n}"`:"No objects available for this mode"})]})]})},Ra="_root_o3eqo_9",Wa="_header_o3eqo_23",Ga="_title_o3eqo_39",qa="_multiSelect_o3eqo_53",Fa="_content_o3eqo_63",Va="_section_o3eqo_73",Ha="_sectionHeader_o3eqo_89",Ua="_sectionContent_o3eqo_127",Za="_fieldRow_o3eqo_135",Ya="_fieldLabel_o3eqo_157",Ka="_textInput_o3eqo_169",Xa="_numberInput_o3eqo_171",Ja="_select_o3eqo_173",Qa="_checkbox_o3eqo_215",ec="_colorInput_o3eqo_227",tc="_readOnly_o3eqo_245",sc="_emptyState_o3eqo_263",ne={root:Ra,header:Wa,title:Ga,multiSelect:qa,content:Fa,section:Va,sectionHeader:Ha,sectionContent:Ua,fieldRow:Za,fieldLabel:Ya,textInput:Ka,numberInput:Xa,select:Ja,checkbox:Qa,colorInput:ec,readOnly:tc,emptyState:sc},jt=[{key:"name",label:"Name",type:"text"},{key:"position.x",label:"X",type:"number",step:1},{key:"position.y",label:"Y",type:"number",step:1},{key:"rotation",label:"Rotation",type:"number",min:0,max:360,step:1},{key:"visible",label:"Visible",type:"boolean"},{key:"locked",label:"Locked",type:"boolean"}],nc=[{key:"type",label:"Zone Type",type:"select",options:[{value:"living_room",label:"Living Room"},{value:"bedroom",label:"Bedroom"},{value:"bathroom",label:"Bathroom"},{value:"kitchen",label:"Kitchen"},{value:"office",label:"Office"},{value:"hallway",label:"Hallway"},{value:"other",label:"Other"}]},{key:"color",label:"Color",type:"color"},{key:"opacity",label:"Opacity",type:"number",min:0,max:1,step:.1}],oc=[{key:"deviceType",label:"Device Type",type:"text"},{key:"status",label:"Status",type:"select",options:[{value:"online",label:"Online"},{value:"offline",label:"Offline"},{value:"error",label:"Error"}]}],Kt=({selection:t,document:s,onPropertyChange:a,className:o})=>{const[n,c]=r.useState(new Set(["general","position","appearance"])),d=t.objectIds.map(v=>{for(const h of s.floors)for(const x of h.layers){const j=x.objects.find(i=>i.id===v);if(j)return j}return null}).filter(Boolean),y=v=>{c(h=>{const x=new Set(h);return x.has(v)?x.delete(v):x.add(v),x})},f=r.useCallback((v,h)=>{const x=h.split(".");let j=v;for(const i of x)if(j&&typeof j=="object"&&i in j)j=j[i];else return;return j},[]),g=r.useCallback((v,h)=>{var j;const x=f(h,v.key);switch(v.type){case"text":return e.jsx("input",{type:"text",value:String(x??""),onChange:i=>a(h.id,v.key,i.target.value),className:ne.textInput});case"number":return e.jsx("input",{type:"number",value:Number(x??0),min:v.min,max:v.max,step:v.step,onChange:i=>a(h.id,v.key,parseFloat(i.target.value)),className:ne.numberInput});case"boolean":return e.jsx("input",{type:"checkbox",checked:!!x,onChange:i=>a(h.id,v.key,i.target.checked),className:ne.checkbox});case"color":return e.jsx("input",{type:"color",value:String(x??"var(--nice-bg, #fff)"),onChange:i=>a(h.id,v.key,i.target.value),className:ne.colorInput});case"select":return e.jsx("select",{value:String(x??""),onChange:i=>a(h.id,v.key,i.target.value),className:ne.select,children:(j=v.options)==null?void 0:j.map(i=>e.jsx("option",{value:i.value,children:i.label},i.value))});default:return e.jsx("span",{children:String(x??"-")})}},[f,a]);if(d.length===0)return e.jsxs("div",{className:`${ne.root} ${o??""}`,children:[e.jsx("div",{className:ne.header,children:e.jsx("h3",{className:ne.title,children:"Properties"})}),e.jsx("div",{className:ne.emptyState,children:"No object selected"})]});const u=d[0],N=d.length>1,b=u.category==="zone"?nc:["smart-home","network","infrastructure"].includes(u.category??"")?oc:[];return e.jsxs("div",{className:`${ne.root} ${o??""}`,children:[e.jsxs("div",{className:ne.header,children:[e.jsx("h3",{className:ne.title,children:"Properties"}),N&&e.jsxs("span",{className:ne.multiSelect,children:[d.length," selected"]})]}),e.jsxs("div",{className:ne.content,children:[e.jsxs("div",{className:ne.section,children:[e.jsxs("button",{className:ne.sectionHeader,onClick:()=>y("general"),children:[e.jsx("span",{children:n.has("general")?"▼":"▶"}),e.jsx("span",{children:"General"})]}),n.has("general")&&e.jsxs("div",{className:ne.sectionContent,children:[jt.slice(0,1).map(v=>e.jsxs("div",{className:ne.fieldRow,children:[e.jsx("label",{className:ne.fieldLabel,children:v.label}),g(v,u)]},v.key)),e.jsxs("div",{className:ne.fieldRow,children:[e.jsx("label",{className:ne.fieldLabel,children:"ID"}),e.jsx("span",{className:ne.readOnly,children:u.id})]}),e.jsxs("div",{className:ne.fieldRow,children:[e.jsx("label",{className:ne.fieldLabel,children:"Category"}),e.jsx("span",{className:ne.readOnly,children:u.category})]})]})]}),e.jsxs("div",{className:ne.section,children:[e.jsxs("button",{className:ne.sectionHeader,onClick:()=>y("position"),children:[e.jsx("span",{children:n.has("position")?"▼":"▶"}),e.jsx("span",{children:"Transform"})]}),n.has("position")&&e.jsx("div",{className:ne.sectionContent,children:jt.slice(1,4).map(v=>e.jsxs("div",{className:ne.fieldRow,children:[e.jsx("label",{className:ne.fieldLabel,children:v.label}),g(v,u)]},v.key))})]}),b.length>0&&e.jsxs("div",{className:ne.section,children:[e.jsxs("button",{className:ne.sectionHeader,onClick:()=>y("appearance"),children:[e.jsx("span",{children:n.has("appearance")?"▼":"▶"}),e.jsx("span",{children:"Appearance"})]}),n.has("appearance")&&e.jsx("div",{className:ne.sectionContent,children:b.map(v=>e.jsxs("div",{className:ne.fieldRow,children:[e.jsx("label",{className:ne.fieldLabel,children:v.label}),g(v,u)]},v.key))})]}),e.jsxs("div",{className:ne.section,children:[e.jsxs("button",{className:ne.sectionHeader,onClick:()=>y("visibility"),children:[e.jsx("span",{children:n.has("visibility")?"▼":"▶"}),e.jsx("span",{children:"Visibility"})]}),n.has("visibility")&&e.jsx("div",{className:ne.sectionContent,children:jt.slice(4).map(v=>e.jsxs("div",{className:ne.fieldRow,children:[e.jsx("label",{className:ne.fieldLabel,children:v.label}),g(v,u)]},v.key))})]})]})]})},ac="_panel_ldte3_9",cc="_header_ldte3_33",rc="_headerTitle_ldte3_51",ic="_title_ldte3_65",lc="_closeButton_ldte3_79",dc="_summarySection_ldte3_111",uc="_summaryStats_ldte3_121",pc="_statBadge_ldte3_133",_c="_statValue_ldte3_147",hc="_statLabel_ldte3_159",mc="_visibilityControls_ldte3_175",xc="_visibilityLabel_ldte3_193",yc="_visibilityButtons_ldte3_203",vc="_visibilityBtn_ldte3_213",fc="_active_ldte3_243",gc="_content_ldte3_257",bc="_emptyState_ldte3_271",jc="_emptyHint_ldte3_317",wc="_vlanList_ldte3_329",Nc="_vlanCard_ldte3_343",kc="_highlighted_ldte3_369",Cc="_hidden_ldte3_379",Ic="_vlanHeader_ldte3_387",Sc="_colorIndicator_ldte3_413",Lc="_vlanInfo_ldte3_427",zc="_vlanName_ldte3_437",$c="_vlanId_ldte3_451",Bc="_vlanNameText_ldte3_463",Tc="_vlanSubnet_ldte3_479",Pc="_vlanStats_ldte3_495",Mc="_chipStat_ldte3_507",Oc="_vlanActions_ldte3_537",Ac="_iconBtn_ldte3_549",Ec="_inactive_ldte3_587",Dc="_expanded_ldte3_603",Rc="_vlanDetails_ldte3_615",Wc="_detailRow_ldte3_627",Gc="_detailLabel_ldte3_649",qc="_detailValue_ldte3_667",Fc="_badge_ldte3_679",Vc="_badgeSuccess_ldte3_693",Hc="_badgeNeutral_ldte3_703",Uc="_deviceList_ldte3_715",Zc="_deviceItems_ldte3_723",Yc="_deviceItem_ldte3_723",Kc="_deviceDot_ldte3_757",Xc="_deviceMore_ldte3_771",Jc="_highlightButton_ldte3_787",Qc="_footer_ldte3_827",er="_legendTitle_ldte3_839",tr="_legend_ldte3_839",sr="_legendItem_ldte3_867",nr="_legendColor_ldte3_879",or="_legendLabel_ldte3_893",T={panel:ac,header:cc,headerTitle:rc,title:ic,closeButton:lc,summarySection:dc,summaryStats:uc,statBadge:pc,statValue:_c,statLabel:hc,visibilityControls:mc,visibilityLabel:xc,visibilityButtons:yc,visibilityBtn:vc,active:fc,content:gc,emptyState:bc,emptyHint:jc,vlanList:wc,vlanCard:Nc,highlighted:kc,hidden:Cc,vlanHeader:Ic,colorIndicator:Sc,vlanInfo:Lc,vlanName:zc,vlanId:$c,vlanNameText:Bc,vlanSubnet:Tc,vlanStats:Pc,chipStat:Mc,vlanActions:Oc,iconBtn:Ac,inactive:Ec,expanded:Dc,vlanDetails:Rc,detailRow:Wc,detailLabel:Gc,detailValue:qc,badge:Fc,badgeSuccess:Vc,badgeNeutral:Hc,deviceList:Uc,deviceItems:Zc,deviceItem:Yc,deviceDot:Kc,deviceMore:Xc,highlightButton:Jc,footer:Qc,legendTitle:er,legend:tr,legendItem:sr,legendColor:nr,legendLabel:or},ar=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:e.jsx("path",{d:"M12 4L4 12M4 4L12 12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),cr=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("ellipse",{cx:"8",cy:"8",rx:"6",ry:"4"}),e.jsx("circle",{cx:"8",cy:"8",r:"2"})]}),rr=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("path",{d:"M2 8s2.5-4 6-4 6 4 6 4-2.5 4-6 4-6-4-6-4z"}),e.jsx("path",{d:"M3 13L13 3",strokeLinecap:"round"})]}),Ot=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("rect",{x:"2",y:"2",width:"4",height:"4",rx:"1"}),e.jsx("rect",{x:"10",y:"2",width:"4",height:"4",rx:"1"}),e.jsx("rect",{x:"6",y:"10",width:"4",height:"4",rx:"1"}),e.jsx("path",{d:"M4 6v2a2 2 0 002 2h4a2 2 0 002-2V6"}),e.jsx("path",{d:"M8 10V8"})]}),ir=()=>e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("circle",{cx:"7",cy:"7",r:"6"}),e.jsx("path",{d:"M7 6v4M7 4h0",strokeLinecap:"round"})]});function lr(t){var s;return((s=t.deviceIds)==null?void 0:s.length)??0}function dr(t,s){return s.filter(a=>a.vlanId===t.id).length}function ur(t){return t||"—"}const pr=({document:t,connections:s,vlans:a,visibleVlanIds:o,onVlanVisibilityChange:n,onHighlightVlan:c,onClose:d})=>{const[y,f]=r.useState(null),[g,u]=r.useState(null),N=r.useMemo(()=>[...a].sort((p,C)=>p.id-C.id),[a]),b=r.useMemo(()=>{const p=new Set,C=new Set;for(const w of a)for(const l of w.deviceIds??[])p.add(l);for(const w of s)w.vlanId!==void 0&&C.add(w.id);return{vlanCount:a.length,deviceCount:p.size,connectionCount:C.size}},[a,s]),v=r.useCallback(p=>{const C=o.has(p);n==null||n(p,!C)},[o,n]),h=r.useCallback(p=>{for(const C of a)n==null||n(C.id,p)},[a,n]),x=r.useCallback(p=>{f((p==null?void 0:p.id)??null),c==null||c(p)},[c]),j=r.useCallback(p=>{u(C=>C===p?null:p)},[]),i=r.useCallback(p=>{const C=[];for(const w of p.deviceIds??[])for(const l of t.floors)for(const $ of l.layers){const E=$.objects.find(V=>V.id===w);E&&C.push({id:w,name:E.name??w})}return C},[t]),L=r.useMemo(()=>{const p=a.filter(C=>o.has(C.id)).length;return{visible:p,total:a.length,allVisible:p===a.length,noneVisible:p===0}},[a,o]);return e.jsxs("div",{className:T.panel,children:[e.jsxs("div",{className:T.header,children:[e.jsxs("div",{className:T.headerTitle,children:[e.jsx(Ot,{}),e.jsx("h3",{className:T.title,children:"Nakładka VLAN"})]}),d&&e.jsx("button",{className:T.closeButton,onClick:d,title:"Zamknij",children:e.jsx(ar,{})})]}),e.jsx("div",{className:T.summarySection,children:e.jsxs("div",{className:T.summaryStats,children:[e.jsxs("div",{className:T.statBadge,children:[e.jsx("span",{className:T.statValue,children:b.vlanCount}),e.jsx("span",{className:T.statLabel,children:"VLAN"})]}),e.jsxs("div",{className:T.statBadge,children:[e.jsx("span",{className:T.statValue,children:b.deviceCount}),e.jsx("span",{className:T.statLabel,children:"Urządzeń"})]}),e.jsxs("div",{className:T.statBadge,children:[e.jsx("span",{className:T.statValue,children:b.connectionCount}),e.jsx("span",{className:T.statLabel,children:"Połączeń"})]})]})}),e.jsxs("div",{className:T.visibilityControls,children:[e.jsxs("span",{className:T.visibilityLabel,children:["Widoczność: ",L.visible,"/",L.total]}),e.jsxs("div",{className:T.visibilityButtons,children:[e.jsx("button",{className:`${T.visibilityBtn} ${L.allVisible?T.active:""}`,onClick:()=>h(!0),title:"Pokaż wszystkie",children:"Wszystkie"}),e.jsx("button",{className:`${T.visibilityBtn} ${L.noneVisible?T.active:""}`,onClick:()=>h(!1),title:"Ukryj wszystkie",children:"Żaden"})]})]}),e.jsx("div",{className:T.content,children:N.length===0?e.jsxs("div",{className:T.emptyState,children:[e.jsx(Ot,{}),e.jsx("p",{children:"Brak zdefiniowanych VLAN-ów"}),e.jsx("span",{className:T.emptyHint,children:"Dodaj VLAN w trybie network-topology lub infrastructure"})]}):e.jsx("div",{className:T.vlanList,children:N.map(p=>{const C=o.has(p.id),w=y===p.id,l=g===p.id,$=lr(p),E=dr(p,s),V=l?i(p):[];return e.jsxs("div",{className:`${T.vlanCard} ${w?T.highlighted:""} ${C?"":T.hidden}`,onMouseEnter:()=>x(p),onMouseLeave:()=>x(null),children:[e.jsxs("div",{className:T.vlanHeader,children:[e.jsx("div",{className:T.colorIndicator,style:{backgroundColor:p.color}}),e.jsxs("div",{className:T.vlanInfo,children:[e.jsxs("div",{className:T.vlanName,children:[e.jsxs("span",{className:T.vlanId,children:["VLAN ",p.id]}),p.name&&e.jsx("span",{className:T.vlanNameText,children:p.name})]}),p.subnet&&e.jsx("div",{className:T.vlanSubnet,children:ur(p.subnet)})]}),e.jsxs("div",{className:T.vlanStats,children:[e.jsx("span",{className:T.chipStat,title:"Urządzenia",children:$}),e.jsx("span",{className:T.chipStat,title:"Połączenia",children:E})]}),e.jsxs("div",{className:T.vlanActions,children:[e.jsx("button",{className:`${T.iconBtn} ${C?"":T.inactive}`,onClick:G=>{G.stopPropagation(),v(p.id)},title:C?"Ukryj VLAN":"Pokaż VLAN",children:C?e.jsx(cr,{}):e.jsx(rr,{})}),e.jsx("button",{className:`${T.iconBtn} ${l?T.expanded:""}`,onClick:G=>{G.stopPropagation(),j(p.id)},title:"Szczegóły",children:e.jsx(ir,{})})]})]}),l&&e.jsxs("div",{className:T.vlanDetails,children:[p.description&&e.jsxs("div",{className:T.detailRow,children:[e.jsx("span",{className:T.detailLabel,children:"Opis:"}),e.jsx("span",{className:T.detailValue,children:p.description})]}),p.subnet&&e.jsxs("div",{className:T.detailRow,children:[e.jsx("span",{className:T.detailLabel,children:"Podsieć:"}),e.jsx("span",{className:T.detailValue,children:p.subnet})]}),p.gateway&&e.jsxs("div",{className:T.detailRow,children:[e.jsx("span",{className:T.detailLabel,children:"Brama:"}),e.jsx("span",{className:T.detailValue,children:p.gateway})]}),e.jsxs("div",{className:T.detailRow,children:[e.jsx("span",{className:T.detailLabel,children:"DHCP:"}),e.jsx("span",{className:`${T.detailValue} ${T.badge} ${p.dhcpEnabled?T.badgeSuccess:T.badgeNeutral}`,children:p.dhcpEnabled?"Włączone":"Wyłączone"})]}),V.length>0&&e.jsxs("div",{className:T.deviceList,children:[e.jsxs("span",{className:T.detailLabel,children:["Urządzenia (",V.length,"):"]}),e.jsxs("ul",{className:T.deviceItems,children:[V.slice(0,10).map(G=>e.jsxs("li",{className:T.deviceItem,children:[e.jsx("span",{className:T.deviceDot,style:{backgroundColor:p.color}}),G.name]},G.id)),V.length>10&&e.jsxs("li",{className:T.deviceMore,children:["... i ",V.length-10," więcej"]})]})]}),e.jsx("button",{className:T.highlightButton,onClick:()=>c==null?void 0:c(p),children:"Zaznacz na mapie"})]})]},p.id)})})}),N.length>0&&e.jsxs("div",{className:T.footer,children:[e.jsx("div",{className:T.legendTitle,children:"Legenda kolorów"}),e.jsx("div",{className:T.legend,children:N.map(p=>e.jsxs("div",{className:T.legendItem,children:[e.jsx("span",{className:T.legendColor,style:{backgroundColor:p.color}}),e.jsxs("span",{className:T.legendLabel,children:[p.id,p.name?`: ${p.name}`:""]})]},p.id))})]})]})},_r="_root_e4i3q_9",hr="_dark_e4i3q_35",mr="_topBar_e4i3q_59",xr="_modeSwitcher_e4i3q_77",yr="_modeBtn_e4i3q_87",vr="_modeBtnActive_e4i3q_123",fr="_modeIcon_e4i3q_135",gr="_modeLabel_e4i3q_143",br="_floorTabs_e4i3q_151",jr="_floorTab_e4i3q_151",wr="_floorTabActive_e4i3q_195",Nr="_viewportControls_e4i3q_207",kr="_active_e4i3q_249",Cr="_disabled_e4i3q_259",Ir="_separator_e4i3q_273",Sr="_zoomLevel_e4i3q_287",Lr="_exportDropdown_e4i3q_305",zr="_exportMenu_e4i3q_353",$r="_mainContent_e4i3q_427",Br="_editorContainer_e4i3q_443",Tr="_toolbar_e4i3q_461",Pr="_toolGroup_e4i3q_481",Mr="_toolBtn_e4i3q_509",Or="_toolBtnActive_e4i3q_549",Ar="_canvasWrapper_e4i3q_573",Er="_canvas_e4i3q_573",Dr="_cursor_select_e4i3q_601",Rr="_cursor_multi_select_e4i3q_603",Wr="_cursor_pan_e4i3q_605",Gr="_cursor_zoom_e4i3q_609",qr="_cursor_draw_wall_e4i3q_611",Fr="_cursor_draw_zone_e4i3q_613",Vr="_cursor_draw_polyline_e4i3q_615",Hr="_cursor_draw_rectangle_e4i3q_617",Ur="_cursor_draw_circle_e4i3q_619",Zr="_cursor_draw_arc_e4i3q_621",Yr="_cursor_place_device_e4i3q_623",Kr="_cursor_place_furniture_e4i3q_625",Xr="_cursor_place_network_e4i3q_627",Jr="_cursor_place_infra_e4i3q_629",Qr="_cursor_place_door_e4i3q_631",ei="_cursor_place_window_e4i3q_633",ti="_cursor_place_stairs_e4i3q_635",si="_cursor_connect_e4i3q_637",ni="_cursor_route_cable_e4i3q_639",oi="_cursor_annotate_e4i3q_641",ai="_cursor_dimension_e4i3q_643",ci="_cursor_label_e4i3q_645",ri="_cursor_measure_distance_e4i3q_647",ii="_cursor_measure_angle_e4i3q_649",li="_cursor_measure_area_e4i3q_651",di="_cursor_move_e4i3q_653",ui="_cursor_rotate_e4i3q_655",pi="_cursor_scale_e4i3q_657",_i="_cursor_erase_e4i3q_659",hi="_cursor_copy_e4i3q_661",mi="_cursor_paste_e4i3q_663",xi="_grid_e4i3q_669",yi="_gridLine_e4i3q_671",vi="_zonesLayer_e4i3q_683",fi="_zone_e4i3q_683",gi="_zoneLabel_e4i3q_689",bi="_connectionsLayer_e4i3q_703",ji="_connection_e4i3q_703",wi="_connectionPreview_e4i3q_709",Ni="_guides_e4i3q_715",ki="_guideLine_e4i3q_717",Ci="_drawingPreview_e4i3q_731",Ii="_rightSidebar_e4i3q_739",Si="_statusBar_e4i3q_761",Li="_modeIndicator_e4i3q_783",zi="_toolIndicator_e4i3q_785",$i="_selectionInfo_e4i3q_797",Bi="_drawingInfo_e4i3q_799",Ti="_connectingInfo_e4i3q_813",Pi="_gridInfo_e4i3q_827",Mi="_emptyState_e4i3q_839",Oi="_emptyIcon_e4i3q_861",Ai="_primaryBtn_e4i3q_891",Ei="_modeActions_e4i3q_925",Di="_actionBtn_e4i3q_943",O={root:_r,dark:hr,topBar:mr,modeSwitcher:xr,modeBtn:yr,modeBtnActive:vr,modeIcon:fr,modeLabel:gr,floorTabs:br,floorTab:jr,floorTabActive:wr,viewportControls:Nr,active:kr,disabled:Cr,separator:Ir,zoomLevel:Sr,exportDropdown:Lr,exportMenu:zr,mainContent:$r,editorContainer:Br,toolbar:Tr,toolGroup:Pr,toolBtn:Mr,toolBtnActive:Or,canvasWrapper:Ar,canvas:Er,cursor_select:Dr,cursor_multi_select:Rr,cursor_pan:Wr,cursor_zoom:Gr,cursor_draw_wall:qr,cursor_draw_zone:Fr,cursor_draw_polyline:Vr,cursor_draw_rectangle:Hr,cursor_draw_circle:Ur,cursor_draw_arc:Zr,cursor_place_device:Yr,cursor_place_furniture:Kr,cursor_place_network:Xr,cursor_place_infra:Jr,cursor_place_door:Qr,cursor_place_window:ei,cursor_place_stairs:ti,cursor_connect:si,cursor_route_cable:ni,cursor_annotate:oi,cursor_dimension:ai,cursor_label:ci,cursor_measure_distance:ri,cursor_measure_angle:ii,cursor_measure_area:li,cursor_move:di,cursor_rotate:ui,cursor_scale:pi,cursor_erase:_i,cursor_copy:hi,cursor_paste:mi,grid:xi,gridLine:yi,zonesLayer:vi,zone:fi,zoneLabel:gi,connectionsLayer:bi,connection:ji,connectionPreview:wi,guides:Ni,guideLine:ki,drawingPreview:Ci,rightSidebar:Ii,statusBar:Si,modeIndicator:Li,toolIndicator:zi,selectionInfo:$i,drawingInfo:Bi,connectingInfo:Ti,gridInfo:Pi,emptyState:Mi,emptyIcon:Oi,primaryBtn:Ai,modeActions:Ei,actionBtn:Di},Ue={"floor-plan":{mode:"floor-plan",label:"Floor Plan",icon:"🏠",tools:["select","pan","draw-zone","draw-wall","place-device","place-door","place-window","annotate","dimension","measure-distance","measure-area","erase"],layerTypes:["background","floor-plan","zones","devices","annotations","dimensions","grid"],defaultGridSize:20,enable3D:!1},"network-topology":{mode:"network-topology",label:"Network Topology",icon:"🌐",tools:["select","pan","place-network","connect","route-cable","annotate","label","measure-distance","erase"],layerTypes:["background","floor-plan","network","annotations","grid"],defaultGridSize:40,enable3D:!1},infrastructure:{mode:"infrastructure",label:"Infrastructure",icon:"🏢",tools:["select","pan","draw-zone","place-infra","place-network","connect","route-cable","annotate","dimension","measure-distance","measure-area","erase"],layerTypes:["background","floor-plan","zones","infrastructure","network","annotations","dimensions","grid"],defaultGridSize:50,enable3D:!1},cad:{mode:"cad",label:"CAD",icon:"📐",tools:["select","multi-select","pan","draw-wall","draw-zone","draw-polyline","draw-rectangle","draw-circle","draw-arc","place-door","place-window","place-stairs","annotate","dimension","measure-distance","measure-angle","measure-area","move","rotate","scale","copy","paste","erase"],layerTypes:["background","floor-plan","zones","annotations","dimensions","grid"],defaultGridSize:10,enable3D:!0},interior:{mode:"interior",label:"Interior Design",icon:"🛋️",tools:["select","pan","draw-zone","draw-wall","place-furniture","place-device","place-door","place-window","annotate","measure-distance","measure-area","move","rotate","erase"],layerTypes:["background","floor-plan","zones","furniture","devices","annotations","grid"],defaultGridSize:25,enable3D:!0},"game-scene":{mode:"game-scene",label:"Game Scene",icon:"🎮",tools:["select","multi-select","pan","draw-zone","draw-polyline","draw-rectangle","draw-circle","annotate","move","rotate","scale","copy","paste","erase"],layerTypes:["background","floor-plan","zones","game-objects","collision","annotations","grid"],defaultGridSize:32,enable3D:!0}},kt={select:{tool:"select",icon:"↖",label:"Select",shortcut:"V",group:"select"},"multi-select":{tool:"multi-select",icon:"⊞",label:"Multi-Select",shortcut:"M",group:"select"},pan:{tool:"pan",icon:"✋",label:"Pan",shortcut:"H",group:"select"},zoom:{tool:"zoom",icon:"🔍",label:"Zoom",shortcut:"Z",group:"select"},"draw-wall":{tool:"draw-wall",icon:"▬",label:"Wall",shortcut:"W",group:"draw"},"draw-zone":{tool:"draw-zone",icon:"⬡",label:"Zone",shortcut:"R",group:"draw"},"draw-polyline":{tool:"draw-polyline",icon:"〰",label:"Polyline",shortcut:"L",group:"draw"},"draw-rectangle":{tool:"draw-rectangle",icon:"▢",label:"Rectangle",shortcut:"U",group:"draw"},"draw-circle":{tool:"draw-circle",icon:"○",label:"Circle",shortcut:"C",group:"draw"},"draw-arc":{tool:"draw-arc",icon:"⌒",label:"Arc",shortcut:"A",group:"draw"},"place-device":{tool:"place-device",icon:"📡",label:"Device",shortcut:"D",group:"place"},"place-furniture":{tool:"place-furniture",icon:"🪑",label:"Furniture",shortcut:"F",group:"place"},"place-network":{tool:"place-network",icon:"🖧",label:"Network",shortcut:"N",group:"place"},"place-infra":{tool:"place-infra",icon:"⚙",label:"Infrastructure",shortcut:"I",group:"place"},"place-door":{tool:"place-door",icon:"🚪",label:"Door",group:"place"},"place-window":{tool:"place-window",icon:"🪟",label:"Window",group:"place"},"place-stairs":{tool:"place-stairs",icon:"🪜",label:"Stairs",group:"place"},connect:{tool:"connect",icon:"⟷",label:"Connect",shortcut:"K",group:"connect"},"route-cable":{tool:"route-cable",icon:"〰",label:"Cable Route",group:"connect"},annotate:{tool:"annotate",icon:"✏",label:"Annotate",shortcut:"T",group:"annotate"},dimension:{tool:"dimension",icon:"↔",label:"Dimension",group:"annotate"},label:{tool:"label",icon:"🏷",label:"Label",group:"annotate"},"measure-distance":{tool:"measure-distance",icon:"📏",label:"Distance",group:"measure"},"measure-angle":{tool:"measure-angle",icon:"∠",label:"Angle",group:"measure"},"measure-area":{tool:"measure-area",icon:"⊡",label:"Area",group:"measure"},move:{tool:"move",icon:"✥",label:"Move",shortcut:"G",group:"edit"},rotate:{tool:"rotate",icon:"↻",label:"Rotate",shortcut:"R",group:"edit"},scale:{tool:"scale",icon:"⤡",label:"Scale",shortcut:"S",group:"edit"},erase:{tool:"erase",icon:"🗑",label:"Delete",shortcut:"Del",group:"edit"},copy:{tool:"copy",icon:"📋",label:"Copy",shortcut:"Ctrl+C",group:"edit"},paste:{tool:"paste",icon:"📄",label:"Paste",shortcut:"Ctrl+V",group:"edit"}};function Ri(t){var n,c;const s=t.defaultMode??"floor-plan",a=Ue[s],o=[{type:"grid",visible:!0,locked:!0,opacity:.3,zIndex:0},{type:"background",visible:!0,locked:!0,opacity:.5,zIndex:1},{type:"floor-plan",visible:!0,locked:!1,opacity:1,zIndex:10},{type:"zones",visible:!0,locked:!1,opacity:.6,zIndex:20},{type:"furniture",visible:!0,locked:!1,opacity:1,zIndex:30},{type:"devices",visible:!0,locked:!1,opacity:1,zIndex:40},{type:"network",visible:!0,locked:!1,opacity:1,zIndex:50},{type:"infrastructure",visible:!0,locked:!1,opacity:1,zIndex:60},{type:"game-objects",visible:!0,locked:!1,opacity:1,zIndex:70},{type:"collision",visible:!1,locked:!1,opacity:.4,zIndex:80},{type:"annotations",visible:!0,locked:!1,opacity:1,zIndex:90},{type:"dimensions",visible:!0,locked:!1,opacity:1,zIndex:100}];return{mode:s,tool:a.tools[0]??"select",document:t.document??t.initialDocument??null,activeFloorId:((c=(n=t.document)==null?void 0:n.floors[0])==null?void 0:c.id)??null,layers:o,selection:{objectIds:[],bounds:null,locked:!1},viewport:{zoom:1,pan:{x:0,y:0},rotation:0,showGrid:!0,gridSize:t.gridSize??a.defaultGridSize,snapEnabled:t.snapEnabled??!0,snapModes:["grid","endpoint","midpoint"]},drawing:{active:!1,points:[],preview:null},connecting:{active:!1,sourceId:null,sourcePosition:null,previewPosition:null},history:{past:[],future:[]},guides:[],dragging:null,clipboard:[],ui:{showObjectLibrary:t.showObjectLibrary??!0,showLayerPanel:t.showLayerPanel??!0,showPropertiesPanel:t.showPropertiesPanel??!0,showMinimap:t.showMinimap??!0}}}function Ve(t,s,a,o){return{id:`${Date.now()}-${Math.random().toString(36).slice(2,9)}`,timestamp:Date.now(),type:t,objectIds:s,before:a,after:o}}function He(t,s){return{history:{past:[...t.history.past.slice(-49),s],future:[]}}}function Ee(t,s){if(t)for(const a of t.floors)for(const o of a.layers){const n=o.objects.find(c=>c.id===s);if(n)return n}}function ot(t,s,a){return{...t,floors:t.floors.map(o=>({...o,layers:o.layers.map(n=>({...n,objects:n.objects.map(c=>c.id===s?{...c,...a}:c)}))})),metadata:{...t.metadata,modified:new Date().toISOString()}}}function at(t,s){const a=new Set(s);return{...t,floors:t.floors.map(o=>({...o,layers:o.layers.map(n=>({...n,objects:n.objects.filter(c=>!a.has(c.id))}))})),metadata:{...t.metadata,modified:new Date().toISOString()}}}function ct(t,s,a,o){return{...t,floors:t.floors.map(n=>n.id!==s?n:{...n,layers:n.layers.map(c=>c.name!==a?c:{...c,objects:[...c.objects,o]})}),metadata:{...t.metadata,modified:new Date().toISOString()}}}function Wi(t,s){var a;switch(s.type){case"SET_MODE":{const o=Ue[s.mode];return{...t,mode:s.mode,tool:o.tools.includes(t.tool)?t.tool:o.tools[0],viewport:{...t.viewport,gridSize:o.defaultGridSize}}}case"SET_TOOL":return{...t,tool:s.tool,drawing:{active:!1,points:[],preview:null},connecting:{active:!1,sourceId:null,sourcePosition:null,previewPosition:null}};case"SET_DOCUMENT":return{...t,document:s.document,activeFloorId:((a=s.document.floors[0])==null?void 0:a.id)??null};case"SET_ACTIVE_FLOOR":return{...t,activeFloorId:s.floorId};case"SET_SELECTION":return{...t,selection:s.selection};case"CLEAR_SELECTION":return{...t,selection:{objectIds:[],bounds:null,locked:!1}};case"SET_VIEWPORT":return{...t,viewport:{...t.viewport,...s.viewport}};case"ZOOM":{const o=Math.max(.1,Math.min(10,t.viewport.zoom*(1+s.delta*.1)));return{...t,viewport:{...t.viewport,zoom:o}}}case"PAN":return{...t,viewport:{...t.viewport,pan:{x:t.viewport.pan.x+s.delta.x,y:t.viewport.pan.y+s.delta.y}}};case"RESET_VIEW":return{...t,viewport:{...t.viewport,zoom:1,pan:{x:0,y:0}}};case"TOGGLE_GRID":return{...t,viewport:{...t.viewport,showGrid:!t.viewport.showGrid}};case"TOGGLE_SNAP":return{...t,viewport:{...t.viewport,snapEnabled:!t.viewport.snapEnabled}};case"SET_GRID_SIZE":return{...t,viewport:{...t.viewport,gridSize:s.size}};case"SET_SNAP_MODES":return{...t,viewport:{...t.viewport,snapModes:s.modes}};case"SET_LAYER_VISIBILITY":return{...t,layers:t.layers.map(o=>o.type===s.layerType?{...o,visible:s.visible}:o)};case"SET_LAYER_LOCKED":return{...t,layers:t.layers.map(o=>o.type===s.layerType?{...o,locked:s.locked}:o)};case"SET_LAYER_OPACITY":return{...t,layers:t.layers.map(o=>o.type===s.layerType?{...o,opacity:s.opacity}:o)};case"START_DRAWING":return{...t,drawing:{active:!0,points:[s.point],preview:null}};case"ADD_DRAWING_POINT":return{...t,drawing:{...t.drawing,points:[...t.drawing.points,s.point]}};case"UPDATE_DRAWING_PREVIEW":return{...t,drawing:{...t.drawing,preview:s.point}};case"FINISH_DRAWING":return{...t,drawing:{active:!1,points:[],preview:null}};case"CANCEL_DRAWING":return{...t,drawing:{active:!1,points:[],preview:null}};case"START_CONNECTING":return{...t,connecting:{active:!0,sourceId:s.sourceId,sourcePort:s.sourcePort,sourcePosition:s.sourcePosition,previewPosition:s.sourcePosition}};case"UPDATE_CONNECTING_PREVIEW":return{...t,connecting:{...t.connecting,previewPosition:s.position}};case"FINISH_CONNECTING":return{...t,connecting:{active:!1,sourceId:null,sourcePosition:null,previewPosition:null}};case"CANCEL_CONNECTING":return{...t,connecting:{active:!1,sourceId:null,sourcePosition:null,previewPosition:null}};case"SET_GUIDES":return{...t,guides:s.guides};case"TOGGLE_OBJECT_LIBRARY":return{...t,ui:{...t.ui,showObjectLibrary:!t.ui.showObjectLibrary}};case"TOGGLE_LAYER_PANEL":return{...t,ui:{...t.ui,showLayerPanel:!t.ui.showLayerPanel}};case"TOGGLE_PROPERTIES_PANEL":return{...t,ui:{...t.ui,showPropertiesPanel:!t.ui.showPropertiesPanel}};case"TOGGLE_MINIMAP":return{...t,ui:{...t.ui,showMinimap:!t.ui.showMinimap}};case"ADD_OBJECT":{if(!t.document||!t.activeFloorId)return t;const o=s.object.layer||"devices",n=ct(t.document,t.activeFloorId,o,s.object),c=Ve("create",[s.object.id],null,s.object);return{...t,document:n,...He(t,c)}}case"UPDATE_OBJECT":{if(!t.document)return t;const o=Ee(t.document,s.objectId);if(!o)return t;const n=ot(t.document,s.objectId,s.updates),c=Ve("update",[s.objectId],o,{...o,...s.updates});return{...t,document:n,...He(t,c)}}case"DELETE_OBJECTS":{if(!t.document||s.objectIds.length===0)return t;const o=s.objectIds.map(d=>Ee(t.document,d)).filter(Boolean),n=at(t.document,s.objectIds),c=Ve("delete",s.objectIds,o,null);return{...t,document:n,selection:{objectIds:[],bounds:null,locked:!1},...He(t,c)}}case"MOVE_OBJECTS":{if(!t.document||s.objectIds.length===0)return t;const o=s.objectIds.map(y=>Ee(t.document,y)).filter(Boolean);let n=t.document;for(const y of s.objectIds){const f=Ee(n,y);if(f&&"transform"in f&&f.transform&&"position"in f.transform){const g=f.transform.position;n=ot(n,y,{transform:{...f.transform,position:{x:g.x+s.delta.x,y:g.y+s.delta.y}}})}}const c=s.objectIds.map(y=>Ee(n,y)).filter(Boolean),d=Ve("move",s.objectIds,o,c);return{...t,document:n,...He(t,d)}}case"UNDO":{if(t.history.past.length===0||!t.document)return t;const o=t.history.past[t.history.past.length-1];let n=t.document;switch(o.type){case"create":{n=at(n,o.objectIds);break}case"delete":{const c=o.before;for(const d of c){const y=d.layer||"devices";n=ct(n,t.activeFloorId??n.floors[0].id,y,d)}break}case"update":case"move":{const c=o.before;for(const d of c)n=ot(n,d.id,d);break}}return{...t,document:n,history:{past:t.history.past.slice(0,-1),future:[o,...t.history.future]}}}case"REDO":{if(t.history.future.length===0||!t.document)return t;const o=t.history.future[0];let n=t.document;switch(o.type){case"create":{const c=o.after,d=c.layer||"devices";n=ct(n,t.activeFloorId??n.floors[0].id,d,c);break}case"delete":{n=at(n,o.objectIds);break}case"update":case"move":{const c=o.after;for(const d of c)n=ot(n,d.id,d);break}}return{...t,document:n,history:{past:[...t.history.past,o],future:t.history.future.slice(1)}}}case"COPY":{if(!t.document||t.selection.objectIds.length===0)return t;const o=t.selection.objectIds.map(n=>Ee(t.document,n)).filter(Boolean);return{...t,clipboard:o}}case"CUT":{if(!t.document||t.selection.objectIds.length===0)return t;const o=t.selection.objectIds.map(d=>Ee(t.document,d)).filter(Boolean),n=at(t.document,t.selection.objectIds),c=Ve("delete",t.selection.objectIds,o,null);return{...t,document:n,clipboard:o,selection:{objectIds:[],bounds:null,locked:!1},...He(t,c)}}case"PASTE":{if(!t.document||!t.activeFloorId||t.clipboard.length===0)return t;let o=t.document;const n=[],c=[];for(const y of t.clipboard){const f=`${y.id}-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,g=y.transform,u={position:{x:g.position.x+s.position.x+20,y:g.position.y+s.position.y+20},rotation:g.rotation,scale:g.scale},N={...y,id:f,transform:u},b=N.layer||"devices";o=ct(o,t.activeFloorId,b,N),n.push(f),c.push(N)}const d=Ve("create",n,null,c);return{...t,document:o,selection:{objectIds:n,bounds:null,locked:!1},...He(t,d)}}case"START_DRAG":return{...t,dragging:{objectType:s.objectType,objectData:s.objectData,position:null}};case"UPDATE_DRAG_POSITION":return t.dragging?{...t,dragging:{...t.dragging,position:s.position}}:t;case"END_DRAG":return{...t,dragging:null};case"CANCEL_DRAG":return{...t,dragging:null};default:return t}}const Gi=({mode:t,activeTool:s,onToolSelect:a,readOnly:o})=>{const c=Ue[t].tools.map(y=>kt[y]).filter(Boolean),d=["select","draw","place","connect","annotate","measure","edit"];return e.jsx("div",{className:O.toolbar,children:d.map(y=>{const f=c.filter(g=>g.group===y);return f.length===0?null:e.jsx("div",{className:O.toolGroup,children:f.map(({tool:g,icon:u,label:N,shortcut:b})=>e.jsx("button",{title:`${N}${b?` (${b})`:""}`,className:`${O.toolBtn} ${s===g?O.toolBtnActive:""}`,onClick:()=>a(g),disabled:o&&!["select","pan","zoom","measure-distance","measure-angle","measure-area"].includes(g),children:u},g))},y)})})},qi=({currentMode:t,availableModes:s,onModeChange:a})=>e.jsx("div",{className:O.modeSwitcher,children:s.map(o=>{const n=Ue[o];return e.jsxs("button",{title:n.label,className:`${O.modeBtn} ${t===o?O.modeBtnActive:""}`,onClick:()=>a(o),children:[e.jsx("span",{className:O.modeIcon,children:n.icon}),e.jsx("span",{className:O.modeLabel,children:n.label})]},o)})});function At(t){if(!t)return[];const s=[];for(const a of t.floors)for(const o of a.layers)if(o.type==="network"||o.type==="infrastructure"){for(const n of o.objects)if(n.type==="connection"){const c=n.metadata;c!=null&&c.sourceId&&(c!=null&&c.targetId)&&s.push({id:n.id,sourceId:c.sourceId,sourcePort:c.sourcePort,targetId:c.targetId,targetPort:c.targetPort,medium:c.medium??"ethernet-cat6",status:c.status??"unknown",bandwidth:c.bandwidth,latency:c.latency??1,waypoints:c.waypoints??[]})}}return s}function Fi(t){if(!t)return[];const s=[],a=new Set;for(const o of t.floors)for(const n of o.layers)if(n.type==="network"||n.type==="infrastructure")for(const c of n.objects){const d=c.metadata;if((d==null?void 0:d.vlanId)!==void 0&&!a.has(d.vlanId))a.add(d.vlanId),s.push({id:d.vlanId,name:d.vlanName??`VLAN ${d.vlanId}`,color:d.vlanColor??Vi(d.vlanId),deviceIds:[c.id],subnet:d.subnet,gateway:d.gateway,dhcpEnabled:d.dhcpEnabled});else if((d==null?void 0:d.vlanId)!==void 0){const y=s.find(f=>f.id===d.vlanId);y&&!y.deviceIds.includes(c.id)&&y.deviceIds.push(c.id)}}return s.sort((o,n)=>o.id-n.id)}function Vi(t){const s=["var(--nice-primary, #3b82f6)","var(--nice-success, #22c55e)","var(--nice-warning, #f59e0b)","var(--nice-danger, #ef4444)","var(--nice-accent, #8b5cf6)","var(--nice-accent-pink, #ec4899)","var(--nice-info, #06b6d4)","var(--nice-warning, #f97316)","var(--nice-info, #14b8a6)","var(--nice-accent, #a855f7)"];return s[t%s.length]}const Hi=t=>{var Ce,It;const{defaultMode:s="floor-plan",availableModes:a=Object.keys(Ue),readOnly:o=!1,theme:n="light",locale:c="en",onDocumentChange:d,onSelectionChange:y,onModeChange:f,onExport:g,onImport:u,className:N,style:b,cookies:v=!1,localStorage:h=!0,sessionStorage:x=!1,storageMode:j,storageKey:i,persistPreferences:L=!1}=t,p=ss.useStorageAdapter(i??"nice-spatial-editor"),[C]=r.useState(()=>L?p.get("prefs")??{}:{}),[w,l]=r.useReducer(Wi,t,Ri),$=r.useRef(null),E=r.useRef(!1),V=r.useRef({x:0,y:0}),[G,me]=r.useState(!1),[Q,ge]=r.useState(!1),[be,oe]=r.useState(null),[U,k]=r.useState(null),[q,ie]=r.useState(!1),[je,ke]=r.useState(!1),[xe,Te]=r.useState(!1),[Se,De]=r.useState(new Set),[Ze,Re]=r.useState(null),Le=r.useRef(null),We=r.useRef(null),ze=r.useRef(null),{mode:we,tool:pe,document:J,activeFloorId:Pe,layers:Me,selection:he,viewport:ee,drawing:_e,connecting:ce,guides:ye,ui:Be,history:Ye}=w,Ae=Ue[we],Qe=Ye.past.length>0,et=Ye.future.length>0;r.useEffect(()=>{var m,M,P;!L||!C||((C.zoom||C.pan)&&l({type:"SET_VIEWPORT",viewport:{zoom:C.zoom,pan:C.pan,showGrid:(m=C.gridConfig)==null?void 0:m.visible,gridSize:(M=C.gridConfig)==null?void 0:M.size,snapEnabled:(P=C.gridConfig)==null?void 0:P.snapEnabled}}),C.mode&&l({type:"SET_MODE",mode:C.mode}),C.tool&&l({type:"SET_TOOL",tool:C.tool}),C.layerVisibility&&Object.entries(C.layerVisibility).forEach(([D,Z])=>{Z!==void 0&&l({type:"SET_LAYER_VISIBILITY",layerType:D,visible:Z})}))},[]),r.useEffect(()=>{if(!L)return;const m={zoom:ee.zoom,pan:ee.pan,gridConfig:{size:ee.gridSize,visible:ee.showGrid,snapEnabled:ee.snapEnabled},mode:we,tool:pe,layerVisibility:Object.fromEntries(Me.map(M=>[M.type,M.visible])),uiPanels:Be};p.set("prefs",m)},[L,ee,we,pe,Me,Be,p]);const ue=r.useMemo(()=>(J==null?void 0:J.floors.find(m=>m.id===Pe))??(J==null?void 0:J.floors[0])??null,[J,Pe]),Oe=r.useCallback((m,M)=>{var D;const P=(D=$.current)==null?void 0:D.getBoundingClientRect();return P?{x:(m-P.left-ee.pan.x)/ee.zoom,y:(M-P.top-ee.pan.y)/ee.zoom}:{x:0,y:0}},[ee.pan,ee.zoom]),Ge=r.useCallback(m=>{if(!ee.snapEnabled)return m;const M={cellSize:ee.gridSize,majorInterval:10,origin:{x:0,y:0},visible:ee.showGrid,color:"var(--nice-border, #e5e7eb)",majorColor:"var(--nice-text-muted, #9ca3af)",opacity:1,snapModes:["grid"],snapThreshold:10,angleIncrement:15};return H.snapToGrid(m,M)},[ee.snapEnabled,ee.gridSize,ee.showGrid]),dt=r.useCallback(m=>{if(pe==="pan"||m.button===1){E.current=!0,V.current={x:m.clientX,y:m.clientY};return}const M=Ge(Oe(m.clientX,m.clientY));if(pe==="draw-zone"||pe==="draw-wall"||pe==="draw-polyline")_e.active?l({type:"ADD_DRAWING_POINT",point:M}):l({type:"START_DRAWING",point:M});else if(pe==="connect"){const P=ue==null?void 0:ue.layers.flatMap(D=>D.objects).find(D=>{if(!D.bounds)return!1;const Z=D.bounds;return M.x>=Z.x&&M.x<=Z.x+Z.width&&M.y>=Z.y&&M.y<=Z.y+Z.height});if(P)if(ce.active){l({type:"FINISH_CONNECTING",targetId:P.id});const D=`conn-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,Z=P.bounds?{x:P.bounds.x+P.bounds.width/2,y:P.bounds.y+P.bounds.height/2}:M,K={id:D,type:"connection",category:"network",name:"Connection",transform:{position:{x:0,y:0},rotation:0,scale:{x:1,y:1}},layer:"network",locked:!1,visible:!0,childIds:[],bounds:{x:Math.min(ce.sourcePosition.x,Z.x),y:Math.min(ce.sourcePosition.y,Z.y),width:Math.abs(Z.x-ce.sourcePosition.x),height:Math.abs(Z.y-ce.sourcePosition.y)},metadata:{sourceId:ce.sourceId,targetId:P.id,sourcePosition:ce.sourcePosition,targetPosition:Z,medium:"ethernet-cat6",status:"active"}};l({type:"ADD_OBJECT",object:K})}else{const D=P.bounds?{x:P.bounds.x+P.bounds.width/2,y:P.bounds.y+P.bounds.height/2}:M;l({type:"START_CONNECTING",sourceId:P.id,sourcePosition:D})}else ce.active&&l({type:"CANCEL_CONNECTING"})}else pe==="select"&&l({type:"CLEAR_SELECTION"})},[pe,_e.active,ce.active,ce.sourceId,ce.sourcePosition,Ge,Oe,ue]),ut=r.useCallback(m=>{if(E.current){const P=m.clientX-V.current.x,D=m.clientY-V.current.y;l({type:"PAN",delta:{x:P,y:D}}),V.current={x:m.clientX,y:m.clientY};return}const M=Ge(Oe(m.clientX,m.clientY));if(_e.active&&(l({type:"UPDATE_DRAWING_PREVIEW",point:M}),ee.snapEnabled&&ue)){const P=ue.layers.flatMap(K=>K.objects.filter(re=>re.bounds).map(re=>({id:re.id,bounds:re.bounds}))),D={x:M.x,y:M.y,width:1,height:1},Z=H.generateAlignmentGuides(D,P,10);l({type:"SET_GUIDES",guides:Z})}ce.active&&l({type:"UPDATE_CONNECTING_PREVIEW",position:M})},[_e.active,ce.active,Ge,Oe,ee.snapEnabled,ue]),pt=r.useCallback(()=>{E.current=!1},[]),_t=r.useCallback(m=>{_e.active&&_e.points.length>=2&&l({type:"FINISH_DRAWING"})},[_e.active,_e.points.length]),ht=r.useCallback(m=>{m.preventDefault();const M=m.deltaY>0?-1:1;l({type:"ZOOM",delta:M,center:Oe(m.clientX,m.clientY)})},[Oe]),mt=r.useCallback(m=>{m.key==="Escape"&&(_e.active?l({type:"CANCEL_DRAWING"}):ce.active?l({type:"CANCEL_CONNECTING"}):l({type:"CLEAR_SELECTION"})),m.key==="Delete"&&he.objectIds.length>0&&l({type:"DELETE_OBJECTS",objectIds:he.objectIds}),(m.ctrlKey||m.metaKey)&&(m.key==="z"&&l({type:"UNDO"}),m.key==="y"&&l({type:"REDO"}),m.key==="c"&&l({type:"COPY"}),m.key==="v"&&l({type:"PASTE",position:{x:0,y:0}}),m.key==="x"&&l({type:"CUT"}))},[_e.active,ce.active,he.objectIds]),xt=r.useCallback(m=>{l({type:"SET_MODE",mode:m}),f==null||f(m)},[f]),yt=r.useCallback(m=>{l({type:"SET_TOOL",tool:m})},[]),qe=r.useCallback(async m=>{var M;if(J){me(!1);try{const P={includeGrid:!1,includeDimensions:!0};if(m==="nsp"){const D=H.exportToNSP(J,P);H.downloadExport(D),g==null||g(m,D.data)}else if(m==="svg"){const D=H.exportToSVG(J,P);H.downloadExport(D),g==null||g(m,D.data)}else if(m==="dxf"){const D=H.exportToDXF(J,P);H.downloadExport(D),g==null||g(m,D.data)}else if(m==="png"&&$.current){const D=await H.exportSVGToPNG($.current,((M=J.metadata)==null?void 0:M.name)||"export");H.downloadExport(D),g==null||g(m,D.data)}}catch(P){console.error(`Export to ${m} failed:`,P)}}},[J,g]),vt=r.useCallback(async m=>{var P;const M=(P=m.target.files)==null?void 0:P[0];if(M){ge(!1);try{const D={convertClosedPolylinesToZones:!0,minZoneArea:1},Z=await H.importFromBrowserFile(M,D);Z.success&&Z.document?k(Z):oe(Z),ze.current&&(ze.current.value="")}catch(D){console.error("Import failed:",D),oe({success:!1,warnings:[],errors:[{code:"IMPORT_ERROR",message:D instanceof Error?D.message:"Unknown import error",fatal:!0}],stats:{wallsImported:0,zonesImported:0,objectsImported:0,layersFound:0,entitiesSkipped:0,importTimeMs:0}})}}},[]),ft=r.useCallback(()=>{U!=null&&U.success&&U.document?ie(!0):k(null)},[U]),gt=r.useCallback(()=>{k(null),ie(!1)},[]),tt=r.useCallback((m,M)=>{if(!(U!=null&&U.document)){ie(!1);return}const P=U.document,D={...P,floors:P.floors.map(Z=>({...Z,layers:Z.layers.filter(K=>m.get(K.id)!=="skip").map(K=>{const re=m.get(K.id);if(re===K.id||!re)return K;const Ie=J==null?void 0:J.floors.flatMap(Fe=>Fe.layers).find(Fe=>Fe.id===re);return Ie?{...K,id:Ie.id,name:Ie.name,type:Ie.type}:K})}))};l({type:"SET_DOCUMENT",document:D}),u==null||u(D),oe(U),ie(!1),k(null)},[U,J,u]),_=r.useCallback(()=>{ie(!1)},[]),I=r.useCallback(m=>{if(ze.current){let M=".dxf,.svg,.geojson,.json,.ifc";m==="dxf"?M=".dxf":m==="svg"?M=".svg":m==="geojson"?M=".geojson,.json":m==="ifc"&&(M=".ifc"),ze.current.accept=M,ze.current.click()}ge(!1)},[]);r.useEffect(()=>{const m=M=>{Le.current&&!Le.current.contains(M.target)&&me(!1),We.current&&!We.current.contains(M.target)&&ge(!1)};return(G||Q)&&document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m)}},[G,Q]);const z=r.useCallback(()=>{var Z,K;if(!ee.showGrid||!ue)return null;const m=[],{gridSize:M}=ee,P=((Z=ue.bounds)==null?void 0:Z.width)??1e3,D=((K=ue.bounds)==null?void 0:K.height)??800;for(let re=0;re<=P;re+=M)m.push(e.jsx("line",{x1:re,y1:0,x2:re,y2:D,className:O.gridLine},`v${re}`));for(let re=0;re<=D;re+=M)m.push(e.jsx("line",{x1:0,y1:re,x2:P,y2:re,className:O.gridLine},`h${re}`));return e.jsx("g",{className:O.grid,children:m})},[ee.showGrid,ee.gridSize,ue]),X=r.useCallback(()=>{if(!ue)return null;const m=ue.layers.find(M=>M.name==="zones");return m?e.jsx("g",{className:O.zonesLayer,children:m.objects.map(M=>{const P=M;if(!P.boundary||P.boundary.length<3)return null;const D=P.boundary.map((re,Ie)=>`${Ie===0?"M":"L"}${re.x},${re.y}`).join(" ")+" Z",Z=he.objectIds.includes(P.id),K=P.boundary.reduce((re,Ie)=>({x:re.x+Ie.x/P.boundary.length,y:re.y+Ie.y/P.boundary.length}),{x:0,y:0});return e.jsxs("g",{className:O.zone,onClick:re=>{re.stopPropagation(),l({type:"SET_SELECTION",selection:{objectIds:[P.id],bounds:null,locked:!1}})},children:[e.jsx("path",{d:D,fill:P.color??"var(--nice-primary-bg, #dbeafe)",fillOpacity:.5,stroke:Z?"var(--nice-primary-hover, #2563eb)":"var(--nice-text-muted, #94a3b8)",strokeWidth:Z?2:1}),P.name&&e.jsx("text",{x:K.x,y:K.y,textAnchor:"middle",dominantBaseline:"middle",className:O.zoneLabel,children:P.name})]},P.id)})}):null},[ue,he.objectIds]),le=r.useCallback(()=>ye.length===0?null:e.jsx("g",{className:O.guides,children:ye.map((m,M)=>e.jsx("line",{x1:m.start.x,y1:m.start.y,x2:m.end.x,y2:m.end.y,className:O.guideLine},M))}),[ye]),te=r.useCallback(()=>{if(!_e.active||_e.points.length===0)return null;const m=[..._e.points];_e.preview&&m.push(_e.preview);const M=m.map((D,Z)=>`${Z===0?"M":"L"}${D.x},${D.y}`).join(" "),P=pe==="draw-zone"&&m.length>2;return e.jsxs("g",{className:O.drawingPreview,children:[e.jsx("path",{d:M+(P?" Z":""),fill:P?"var(--nice-primary-tint-10, rgba(37, 99, 235, 0.1))":"none",stroke:"var(--nice-primary-hover, #2563eb)",strokeWidth:2,strokeDasharray:P?"none":"6,3"}),m.map((D,Z)=>e.jsx("circle",{cx:D.x,cy:D.y,r:4,fill:"var(--nice-primary-hover, #2563eb)"},Z))]})},[_e,pe]),de=r.useCallback(()=>!ce.active||!ce.sourcePosition||!ce.previewPosition?null:e.jsxs("g",{className:O.connectionPreview,children:[e.jsx("line",{x1:ce.sourcePosition.x,y1:ce.sourcePosition.y,x2:ce.previewPosition.x,y2:ce.previewPosition.y,stroke:"var(--nice-success, #10b981)",strokeWidth:2,strokeDasharray:"8,4",markerEnd:"url(#connectionArrow)"}),e.jsx("circle",{cx:ce.sourcePosition.x,cy:ce.sourcePosition.y,r:6,fill:"var(--nice-success, #10b981)"}),e.jsx("circle",{cx:ce.previewPosition.x,cy:ce.previewPosition.y,r:6,fill:"var(--nice-success, #10b981)",fillOpacity:.5,stroke:"var(--nice-success, #10b981)",strokeWidth:2}),e.jsx("defs",{children:e.jsx("marker",{id:"connectionArrow",markerWidth:"10",markerHeight:"10",refX:"9",refY:"3",orient:"auto",markerUnits:"strokeWidth",children:e.jsx("path",{d:"M0,0 L0,6 L9,3 z",fill:"var(--nice-success, #10b981)"})})})]}),[ce]),ve=r.useCallback(()=>{if(!ue)return null;const m=ue.layers.find(Z=>Z.type==="network");if(!m)return null;const M=m.objects.filter(Z=>Z.type==="connection");if(M.length===0)return null;const P={"ethernet-cat5":{color:"var(--nice-primary, #3b82f6)",width:2},"ethernet-cat6":{color:"var(--nice-primary-hover, #2563eb)",width:2},"ethernet-cat6a":{color:"var(--nice-primary-dark, #1d4ed8)",width:2},"ethernet-cat7":{color:"var(--nice-primary-dark, #1e40af)",width:3},"fiber-single":{color:"var(--nice-warning, #f59e0b)",width:3},"fiber-multi":{color:"var(--nice-warning-dark, #d97706)",width:3},"wifi-2.4ghz":{color:"var(--nice-accent, #8b5cf6)",dashArray:"6,4",width:2},"wifi-5ghz":{color:"var(--nice-accent, #7c3aed)",dashArray:"6,4",width:2},"wifi-6ghz":{color:"var(--nice-accent-dark, #6d28d9)",dashArray:"6,4",width:2},default:{color:"var(--nice-text-secondary, #64748b)",width:2}},D={active:"var(--nice-success, #10b981)",inactive:"var(--nice-text-muted, #94a3b8)",error:"var(--nice-danger, #ef4444)",degraded:"var(--nice-warning, #f59e0b)",unknown:"var(--nice-text-secondary, #64748b)"};return e.jsx("g",{className:O.connectionsLayer,children:M.map(Z=>{const K=Z.metadata;if(!(K!=null&&K.sourcePosition)||!(K!=null&&K.targetPosition))return null;const re=P[K.medium??"default"]||P.default,Ie=D[K.status??"unknown"]||D.unknown,Fe=he.objectIds.includes(Z.id);let bt=`M${K.sourcePosition.x},${K.sourcePosition.y}`;if(K.waypoints&&K.waypoints.length>0)for(const st of K.waypoints)bt+=` L${st.x},${st.y}`;return bt+=` L${K.targetPosition.x},${K.targetPosition.y}`,e.jsxs("g",{className:O.connection,onClick:st=>{st.stopPropagation(),l({type:"SET_SELECTION",selection:{objectIds:[Z.id],bounds:null,locked:!1}})},children:[e.jsx("path",{d:bt,fill:"none",stroke:Fe?"var(--nice-primary-hover, #2563eb)":re.color,strokeWidth:Fe?re.width+1:re.width,strokeDasharray:re.dashArray,strokeLinecap:"round",strokeLinejoin:"round"}),K.status&&K.status!=="active"&&e.jsx("circle",{cx:(K.sourcePosition.x+K.targetPosition.x)/2,cy:(K.sourcePosition.y+K.targetPosition.y)/2,r:5,fill:Ie}),e.jsx("circle",{cx:K.sourcePosition.x,cy:K.sourcePosition.y,r:4,fill:re.color,stroke:"white",strokeWidth:1}),e.jsx("circle",{cx:K.targetPosition.x,cy:K.targetPosition.y,r:4,fill:re.color,stroke:"white",strokeWidth:1})]},Z.id)})})},[ue,he.objectIds]);return!J&&!ue?e.jsx("div",{className:`${O.root} ${O[n]} ${N??""}`,style:b,children:e.jsxs("div",{className:O.emptyState,children:[e.jsx("div",{className:O.emptyIcon,children:Ae.icon}),e.jsx("h3",{children:"No Document Open"}),e.jsx("p",{children:"Create a new document or open an existing .nsp.json file"}),e.jsx("button",{className:O.primaryBtn,onClick:()=>{const m=H.createFloorPlanDocument("New Project","floor-plan");l({type:"SET_DOCUMENT",document:m})},children:"Create New Document"})]})}):e.jsxs("div",{className:`${O.root} ${O[n]} ${N??""}`,style:b,tabIndex:0,onKeyDown:mt,children:[e.jsxs("div",{className:O.topBar,children:[e.jsx(qi,{currentMode:we,availableModes:a,onModeChange:xt}),J&&J.floors.length>1&&e.jsx("div",{className:O.floorTabs,children:J.floors.map(m=>e.jsx("button",{className:`${O.floorTab} ${Pe===m.id?O.floorTabActive:""}`,onClick:()=>l({type:"SET_ACTIVE_FLOOR",floorId:m.id}),children:m.name},m.id))}),e.jsxs("div",{className:O.viewportControls,children:[!o&&e.jsxs(e.Fragment,{children:[e.jsx("button",{title:"Undo (Ctrl+Z)",onClick:()=>l({type:"UNDO"}),disabled:!Qe,className:Qe?"":O.disabled,children:"↶"}),e.jsx("button",{title:"Redo (Ctrl+Y)",onClick:()=>l({type:"REDO"}),disabled:!et,className:et?"":O.disabled,children:"↷"}),e.jsx("div",{className:O.separator})]}),e.jsx("button",{title:"Toggle Grid",onClick:()=>l({type:"TOGGLE_GRID"}),className:ee.showGrid?O.active:"",children:"⊞"}),e.jsx("button",{title:"Toggle Snap",onClick:()=>l({type:"TOGGLE_SNAP"}),className:ee.snapEnabled?O.active:"",children:"🧲"}),e.jsxs("span",{className:O.zoomLevel,children:[Math.round(ee.zoom*100),"%"]}),e.jsx("button",{title:"Zoom In",onClick:()=>l({type:"ZOOM",delta:1}),children:"+"}),e.jsx("button",{title:"Zoom Out",onClick:()=>l({type:"ZOOM",delta:-1}),children:"−"}),e.jsx("button",{title:"Reset View",onClick:()=>l({type:"RESET_VIEW"}),children:"⊡"}),!o&&e.jsxs("div",{className:O.exportDropdown,ref:We,children:[e.jsx("input",{type:"file",ref:ze,onChange:vt,style:{display:"none"}}),e.jsx("button",{title:"Import",onClick:()=>ge(!Q),className:Q?O.active:"",children:"📥 Import"}),Q&&e.jsxs("div",{className:O.exportMenu,children:[e.jsx("button",{onClick:()=>I(),children:"📄 Auto-detect format"}),e.jsx("button",{onClick:()=>I("dxf"),children:"📐 AutoCAD DXF (.dxf)"}),e.jsx("button",{onClick:()=>I("svg"),children:"🖼️ SVG Vector Graphics (.svg)"}),e.jsx("button",{onClick:()=>I("geojson"),children:"🌍 GeoJSON (.geojson)"}),e.jsx("button",{onClick:()=>I("ifc"),children:"🏗️ IFC (BIM) (.ifc)"})]})]}),J&&e.jsxs("div",{className:O.exportDropdown,ref:Le,children:[e.jsx("button",{title:"Export",onClick:()=>me(!G),className:G?O.active:"",children:"📤 Export"}),G&&e.jsxs("div",{className:O.exportMenu,children:[e.jsx("button",{onClick:()=>qe("nsp"),children:"📄 NiceToDev Spatial Plan (.nsp.json)"}),e.jsx("button",{onClick:()=>qe("svg"),children:"🖼️ SVG Vector Graphics (.svg)"}),e.jsx("button",{onClick:()=>qe("dxf"),children:"📐 AutoCAD DXF (.dxf)"}),e.jsx("button",{onClick:()=>qe("png"),children:"🖼️ PNG Image (.png)"})]})]})]})]}),e.jsxs("div",{className:O.mainContent,children:[Be.showObjectLibrary&&!o&&e.jsx(Yt,{mode:we,onObjectSelect:m=>{l({type:"SET_TOOL",tool:`place-${m.category}`}),l({type:"START_DRAG",objectType:m.category,objectData:m})}}),e.jsxs("div",{className:O.editorContainer,children:[!o&&e.jsx(Gi,{mode:we,activeTool:pe,onToolSelect:yt,readOnly:o}),(we==="network-topology"||we==="infrastructure")&&e.jsxs("div",{className:O.modeActions,children:[e.jsx("button",{className:`${O.actionBtn} ${je?O.active:""}`,onClick:()=>ke(!je),title:"Analiza ścieżki sieciowej",children:"📊 Analiza ścieżki"}),e.jsx("button",{className:`${O.actionBtn} ${xe?O.active:""}`,onClick:()=>Te(!xe),title:"Nakładka VLAN",children:"🌐 VLAN Overlay"})]}),e.jsxs("div",{className:O.canvasWrapper,children:[e.jsx("svg",{ref:$,className:`${O.canvas} ${O[`cursor_${pe.replace("-","_")}`]??""}`,onMouseDown:dt,onMouseMove:ut,onMouseUp:pt,onDoubleClick:_t,onWheel:ht,children:e.jsxs("g",{transform:`translate(${ee.pan.x}, ${ee.pan.y}) scale(${ee.zoom})`,children:[z(),X(),ve(),le(),te(),de()]})}),Be.showMinimap&&e.jsx(Zt,{document:J,activeFloorId:Pe,viewport:ee,onViewportChange:m=>l({type:"SET_VIEWPORT",viewport:m})})]})]}),e.jsxs("div",{className:O.rightSidebar,children:[Be.showLayerPanel&&e.jsx(Ut,{layers:Me.filter(m=>Ae.layerTypes.includes(m.type)),onVisibilityToggle:m=>{var M;return l({type:"SET_LAYER_VISIBILITY",layerType:m,visible:!((M=Me.find(P=>P.type===m))!=null&&M.visible)})},onLockToggle:m=>{var M;return l({type:"SET_LAYER_LOCKED",layerType:m,locked:!((M=Me.find(P=>P.type===m))!=null&&M.locked)})},onOpacityChange:(m,M)=>l({type:"SET_LAYER_OPACITY",layerType:m,opacity:M})}),Be.showPropertiesPanel&&he.objectIds.length>0&&e.jsx(Kt,{selection:he,document:J,onPropertyChange:(m,M,P)=>{l({type:"UPDATE_OBJECT",objectId:m,updates:{[M]:P}})}})]})]}),e.jsxs("div",{className:O.statusBar,children:[e.jsxs("span",{className:O.modeIndicator,children:[Ae.icon," ",Ae.label]}),e.jsxs("span",{className:O.toolIndicator,children:[(Ce=kt[pe])==null?void 0:Ce.icon," ",(It=kt[pe])==null?void 0:It.label]}),he.objectIds.length>0&&e.jsxs("span",{className:O.selectionInfo,children:[he.objectIds.length," selected"]}),_e.active&&e.jsxs("span",{className:O.drawingInfo,children:["Drawing: ",_e.points.length," points"]}),ce.active&&e.jsx("span",{className:O.connectingInfo,children:"Connecting: click target device or ESC to cancel"}),e.jsxs("span",{className:O.gridInfo,children:["Grid: ",ee.gridSize,"px | Snap: ",ee.snapEnabled?"ON":"OFF"]})]}),U&&!q&&e.jsx(Bn,{result:U,onConfirm:ft,onCancel:gt}),U&&q&&e.jsx(ro,{importResult:U,existingDocument:J??void 0,onConfirm:tt,onCancel:_}),je&&J&&e.jsx(ba,{document:J,connections:At(J),onHighlightPath:m=>{l(m?{type:"SET_SELECTION",selection:{objectIds:m.connectionIds,bounds:null,locked:!1}}:{type:"SET_SELECTION",selection:{objectIds:[],bounds:null,locked:!1}})},onClose:()=>ke(!1)}),xe&&J&&e.jsx(pr,{document:J,connections:At(J),vlans:Fi(J),visibleVlanIds:Se,onVlanVisibilityChange:(m,M)=>{De(P=>{const D=new Set(P);return M?D.add(m):D.delete(m),D})},onHighlightVlan:m=>{Re((m==null?void 0:m.id)??null),l(m?{type:"SET_SELECTION",selection:{objectIds:m.deviceIds,bounds:null,locked:!1}}:{type:"SET_SELECTION",selection:{objectIds:[],bounds:null,locked:!1}})},onClose:()=>Te(!1)})]})},Ui="_viewer_fazwr_13",Zi="_theme_light_fazwr_37",Yi="_theme_dark_fazwr_59",Ki="_debugOverlay_fazwr_85",Xi="_topBar_fazwr_137",Ji="_searchContainer_fazwr_159",Qi="_searchInput_fazwr_171",el="_clearBtn_fazwr_227",tl="_searchResults_fazwr_261",sl="_searchResultItem_fazwr_291",nl="_searchResultInfo_fazwr_335",ol="_searchResultName_fazwr_347",al="_searchResultDesc_fazwr_357",cl="_floorSelector_fazwr_371",rl="_navBtn_fazwr_421",il="_active_fazwr_459",ll="_layersBtn_fazwr_475",dl="_legendBtn_fazwr_529",ul="_content_fazwr_583",pl="_navPanel_fazwr_599",_l="_navPanelHeader_fazwr_617",hl="_routeInputs_fazwr_671",ml="_routeInput_fazwr_671",xl="_routeMarker_fazwr_705",yl="_routeHint_fazwr_745",vl="_routeInfo_fazwr_761",fl="_routeStat_fazwr_779",gl="_routeStatLabel_fazwr_791",bl="_routeStatValue_fazwr_805",jl="_clearRouteBtn_fazwr_817",wl="_refPointsList_fazwr_851",Nl="_refPointItem_fazwr_879",kl="_refPointIcon_fazwr_917",Cl="_layersPanel_fazwr_929",Il="_layersPanelHeader_fazwr_947",Sl="_layersList_fazwr_1001",Ll="_layerItem_fazwr_1015",zl="_layerToggle_fazwr_1039",$l="_layerName_fazwr_1075",Bl="_layerType_fazwr_1087",Tl="_canvasWrapper_fazwr_1101",Pl="_canvas_fazwr_1101",Ml="_grid_fazwr_1137",Ol="_gridLine_fazwr_1145",Al="_zonesLayer_fazwr_1161",El="_zone_fazwr_1161",Dl="_zoneSelected_fazwr_1185",Rl="_zoneLabel_fazwr_1195",Wl="_objectsLayer_fazwr_1211",Gl="_object_fazwr_1211",ql="_objectSelected_fazwr_1233",Fl="_objectLabel_fazwr_1241",Vl="_referencePoints_fazwr_1257",Hl="_referencePoint_fazwr_1257",Ul="_refLabel_fazwr_1277",Zl="_routeLayer_fazwr_1293",Yl="_routePath_fazwr_1297",Kl="_routeDash_fazwr_1",Xl="_routeMarkers_fazwr_1323",Jl="_currentLocation_fazwr_1331",Ql="_locationPulse_fazwr_1335",ed="_pulse_fazwr_1",td="_zoomControls_fazwr_1369",sd="_minimap_fazwr_1445",nd="_minimapContent_fazwr_1471",od="_minimapViewport_fazwr_1485",ad="_legendPanel_fazwr_1505",cd="_legendPanelHeader_fazwr_1537",rd="_legendList_fazwr_1593",id="_legendItem_fazwr_1609",ld="_legendColor_fazwr_1633",dd="_legendIcon_fazwr_1649",ud="_legendLabel_fazwr_1663",pd="_legendType_fazwr_1675",_d="_objectInfo_fazwr_1693",hd="_objectInfoHeader_fazwr_1721",md="_navigateBtn_fazwr_1791",S={viewer:Ui,theme_light:Zi,theme_dark:Yi,debugOverlay:Ki,topBar:Xi,searchContainer:Ji,searchInput:Qi,clearBtn:el,searchResults:tl,searchResultItem:sl,searchResultInfo:nl,searchResultName:ol,searchResultDesc:al,floorSelector:cl,navBtn:rl,active:il,layersBtn:ll,legendBtn:dl,content:ul,navPanel:pl,navPanelHeader:_l,routeInputs:hl,routeInput:ml,routeMarker:xl,routeHint:yl,routeInfo:vl,routeStat:fl,routeStatLabel:gl,routeStatValue:bl,clearRouteBtn:jl,refPointsList:wl,refPointItem:Nl,refPointIcon:kl,layersPanel:Cl,layersPanelHeader:Il,layersList:Sl,layerItem:Ll,layerToggle:zl,layerName:$l,layerType:Bl,canvasWrapper:Tl,canvas:Pl,grid:Ml,gridLine:Ol,zonesLayer:Al,zone:El,zoneSelected:Dl,zoneLabel:Rl,objectsLayer:Wl,object:Gl,objectSelected:ql,objectLabel:Fl,referencePoints:Vl,referencePoint:Hl,refLabel:Ul,routeLayer:Zl,routePath:Yl,routeDash:Kl,routeMarkers:Xl,currentLocation:Jl,locationPulse:Ql,pulse:ed,zoomControls:td,minimap:sd,minimapContent:nd,minimapViewport:od,legendPanel:ad,legendPanelHeader:cd,legendList:rd,legendItem:id,legendColor:ld,legendIcon:dd,legendLabel:ud,legendType:pd,objectInfo:_d,objectInfoHeader:hd,navigateBtn:md},xd=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("circle",{cx:"7",cy:"7",r:"5"}),e.jsx("path",{d:"M11 11l3 3",strokeLinecap:"round"})]}),Et=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{d:"M8 1l6 14-6-4-6 4 6-14z"})}),yd=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("circle",{cx:"8",cy:"6",r:"3"}),e.jsx("path",{d:"M8 15c4-4 6-6.7 6-9a6 6 0 10-12 0c0 2.3 2 5 6 9z"})]}),vd=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("rect",{x:"2",y:"2",width:"12",height:"12",rx:"1"}),e.jsx("line",{x1:"2",y1:"6",x2:"14",y2:"6"}),e.jsx("line",{x1:"2",y1:"10",x2:"14",y2:"10"})]}),fd=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("circle",{cx:"4",cy:"4",r:"2"}),e.jsx("circle",{cx:"12",cy:"12",r:"2"}),e.jsx("path",{d:"M6 4h4a2 2 0 012 2v4",strokeLinecap:"round"})]}),gd=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("circle",{cx:"7",cy:"7",r:"5"}),e.jsx("path",{d:"M11 11l3 3M7 5v4M5 7h4",strokeLinecap:"round"})]}),bd=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("circle",{cx:"7",cy:"7",r:"5"}),e.jsx("path",{d:"M11 11l3 3M5 7h4",strokeLinecap:"round"})]}),Ke=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{d:"M12 4L4 12M4 4l8 8",strokeLinecap:"round"})}),Dt=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("path",{d:"M2 6l6-4 6 4-6 4-6-4z"}),e.jsx("path",{d:"M2 10l6 4 6-4"}),e.jsx("path",{d:"M2 8l6 4 6-4",opacity:"0.5"})]}),Rt=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("rect",{x:"2",y:"3",width:"4",height:"3",rx:"0.5",fill:"currentColor",opacity:"0.3"}),e.jsx("rect",{x:"2",y:"8",width:"4",height:"3",rx:"0.5",fill:"currentColor",opacity:"0.3"}),e.jsx("line",{x1:"8",y1:"4.5",x2:"14",y2:"4.5"}),e.jsx("line",{x1:"8",y1:"9.5",x2:"14",y2:"9.5"})]}),jd=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("path",{d:"M1 8c1.5-3 4-5 7-5s5.5 2 7 5c-1.5 3-4 5-7 5s-5.5-2-7-5z"}),e.jsx("circle",{cx:"8",cy:"8",r:"2"})]}),wd=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("path",{d:"M6.5 6.5a2 2 0 012.8 2.8M3 3l10 10",strokeLinecap:"round"}),e.jsx("path",{d:"M4.5 5.5C2.8 6.8 1.5 8 1 8c1.5 3 4 5 7 5 1 0 2-.3 3-.7"}),e.jsx("path",{d:"M12.5 9.5c1-.9 2-2 2.5-3-1.5-3-4-5-7-5-.6 0-1.2.1-1.8.2"})]});function Nd(t,s){return Math.sqrt((s.x-t.x)**2+(s.y-t.y)**2)}function kd(t){return t<1?"<1m":t<1e3?`${Math.round(t)}m`:`${(t/1e3).toFixed(1)}km`}function Cd(t){if(t<60)return"<1 min";const s=Math.round(t/60);if(s<60)return`${s} min`;const a=Math.floor(s/60),o=s%60;return`${a}h ${o}min`}const Id=({document:t,initialFloorId:s,showNavigation:a=!0,showMinimap:o=!0,showFloorSelector:n=!0,showSearch:c=!0,showLayersPanel:d=!0,showLegend:y=!0,enableRoutePlanning:f=!0,referencePoints:g=[],onObjectClick:u,onRouteCalculated:N,currentLocation:b,theme:v="light",className:h,virtualRendering:x,virtualRenderingThreshold:j=200,debugVirtualRendering:i=!1})=>{var tt;const[L,p]=r.useState(s??((tt=t.floors[0])==null?void 0:tt.id)??""),[C,w]=r.useState({zoom:1,pan:{x:0,y:0}}),[l,$]=r.useState(""),[E,V]=r.useState([]),[G,me]=r.useState(null),[Q,ge]=r.useState(null),[be,oe]=r.useState(null),[U,k]=r.useState(null),[q,ie]=r.useState(!1),[je,ke]=r.useState(!1),[xe,Te]=r.useState(!1),[Se,De]=r.useState(new Map),[Ze,Re]=r.useState({width:1e3,height:600}),Le=r.useRef(null),We=r.useRef(null),ze=r.useRef(!1),we=r.useRef({x:0,y:0}),pe=r.useMemo(()=>{const _=t.floors.find(I=>I.id===L);return _?_.layers.reduce((I,z)=>{var X;return I+(((X=z.objects)==null?void 0:X.length)??0)},0):0},[t.floors,L]),J=x??H.shouldUseVirtualRendering(pe,j),Pe=r.useMemo(()=>{if(!J)return null;const _=t.floors.find(z=>z.id===L);if(!_)return null;const I=[];for(const z of _.layers)if(!(z.type==="zones"||z.type==="grid"||z.type==="background"))for(const X of z.objects??[]){const le=X.position??{x:0,y:0},te=X.size??{width:20,height:20};I.push({id:X.id,position:le,size:te,data:{object:X,layerId:z.id}})}return H.createFloorPlanQuadTree(I)},[t.floors,L,J]),Me=r.useMemo(()=>H.calculateVisibleBounds(C,Ze,100),[C,Ze]),he=r.useMemo(()=>!J||!Pe?null:Pe.query(Me),[J,Pe,Me]),ee=r.useMemo(()=>!i||!J?null:H.calculateRenderStats(pe,(he==null?void 0:he.length)??pe,C),[i,J,pe,he,C]);r.useEffect(()=>{const _=We.current;if(!_)return;const I=new ResizeObserver(z=>{for(const X of z)Re({width:X.contentRect.width,height:X.contentRect.height})});return I.observe(_),()=>I.disconnect()},[]),r.useEffect(()=>{const _=t.floors.find(I=>I.id===L);if(_){const I=new Map;for(const z of _.layers)I.set(z.id,Se.get(z.id)??!0);De(I)}},[L,t.floors]);const _e=r.useCallback(_=>{De(I=>{const z=new Map(I);return z.set(_,!I.get(_)),z})},[]),ce=r.useCallback(_=>Se.get(_)!==!1,[Se]),ye=r.useMemo(()=>t.floors.find(_=>_.id===L)??t.floors[0],[t.floors,L]),Be=r.useMemo(()=>{if(!ye)return[];const _=[],I=ye.layers.find(te=>te.type==="zones");if(I){const te=new Map;for(const de of I.objects){const ve=de.metadata,Ce=(ve==null?void 0:ve.zoneType)??de.type??"zone";te.has(Ce)||te.set(Ce,(ve==null?void 0:ve.fill)??"var(--nice-primary, #3b82f6)")}for(const[de,ve]of te)_.push({id:`zone-${de}`,label:de.charAt(0).toUpperCase()+de.slice(1).replace(/-/g," "),color:ve,type:"zone"})}const z=new Map;for(const te of ye.layers)if(!(te.type==="zones"||te.type==="grid"||te.type==="background"))for(const de of te.objects){const ve=de.type??"object",Ce=z.get(ve);Ce?Ce.count++:z.set(ve,{count:1,color:"var(--nice-text-secondary, #64748b)"})}for(const[te,de]of z)_.push({id:`obj-${te}`,label:`${te.charAt(0).toUpperCase()+te.slice(1).replace(/-/g," ")} (${de.count})`,color:de.color,type:"object"});const X=new Map,le={entrance:"🚪",elevator:"🛗",stairs:"🪜",exit:"🚨",poi:"📍",parking:"🅿️"};for(const te of g.filter(de=>de.floorId===L))X.has(te.type)||X.set(te.type,le[te.type]??"📍");for(const[te,de]of X)_.push({id:`ref-${te}`,label:te.charAt(0).toUpperCase()+te.slice(1),color:"var(--nice-primary, #3b82f6)",icon:de,type:"reference"});return _},[ye,g,L]),Ye=r.useCallback((_,I)=>{var X;const z=(X=Le.current)==null?void 0:X.getBoundingClientRect();return z?{x:(_-z.left-C.pan.x)/C.zoom,y:(I-z.top-C.pan.y)/C.zoom}:{x:0,y:0}},[C]);r.useEffect(()=>{if(!l.trim()){V([]);return}const _=l.toLowerCase(),I=[];for(const z of t.floors)for(const X of z.layers)for(const le of X.objects){const te=(le.name??le.id).toLowerCase(),de=(le.description??"").toLowerCase();(te.includes(_)||de.includes(_))&&I.push(le)}V(I.slice(0,10))},[l,t.floors]);const Ae=r.useCallback((_,I)=>{const z=Nd(_,I);return{id:`route-${Date.now()}`,startPoint:_,endPoint:I,path:[_,I],floorTransitions:[],totalDistance:z,estimatedTime:z/1.4,instructions:[{type:"straight",distance:z,direction:"forward"},{type:"arrive"}]}},[]);r.useEffect(()=>{if(Q&&be){const _=Ae(Q,be);k(_),N==null||N(_)}else k(null),N==null||N(null)},[Q,be,Ae,N]);const Qe=r.useCallback(_=>{(_.button===1||_.button===0&&_.altKey)&&(ze.current=!0,we.current={x:_.clientX,y:_.clientY},_.preventDefault())},[]),et=r.useCallback(_=>{if(ze.current){const I=_.clientX-we.current.x,z=_.clientY-we.current.y;we.current={x:_.clientX,y:_.clientY},w(X=>({...X,pan:{x:X.pan.x+I,y:X.pan.y+z}}))}},[]),ue=r.useCallback(()=>{ze.current=!1},[]),Oe=r.useCallback(_=>{var te;_.preventDefault();const I=_.deltaY>0?.9:1.1,z=(te=Le.current)==null?void 0:te.getBoundingClientRect();if(!z)return;const X=_.clientX-z.left,le=_.clientY-z.top;w(de=>{const ve=Math.min(Math.max(de.zoom*I,.1),10),Ce=ve/de.zoom;return{zoom:ve,pan:{x:X-(X-de.pan.x)*Ce,y:le-(le-de.pan.y)*Ce}}})},[]),Ge=r.useCallback(_=>{if(f&&_.ctrlKey){const I=Ye(_.clientX,_.clientY);Q?be?(ge(I),oe(null)):oe(I):ge(I)}},[f,Q,be,Ye]),dt=r.useCallback(()=>{w(_=>({..._,zoom:Math.min(_.zoom*1.25,10)}))},[]),ut=r.useCallback(()=>{w(_=>({..._,zoom:Math.max(_.zoom/1.25,.1)}))},[]),pt=r.useCallback(()=>{w({zoom:1,pan:{x:0,y:0}})},[]),_t=r.useCallback(_=>{me(_);for(const z of t.floors)for(const X of z.layers)if(X.objects.find(le=>le.id===_.id)){p(z.id);break}const I=_.position??{x:0,y:0};w(z=>({...z,pan:{x:-(I.x*z.zoom)+400,y:-(I.y*z.zoom)+300}})),$(""),V([]),u==null||u(_)},[t.floors,u]),ht=r.useCallback(()=>{ge(null),oe(null),k(null)},[]),mt=r.useCallback(()=>{const I=[];for(let z=-2e3;z<=2e3;z+=50)I.push(e.jsx("line",{x1:z,y1:-2e3,x2:z,y2:2e3,className:S.gridLine},`v-${z}`));for(let z=-2e3;z<=2e3;z+=50)I.push(e.jsx("line",{x1:-2e3,y1:z,x2:2e3,y2:z,className:S.gridLine},`h-${z}`));return e.jsx("g",{className:S.grid,children:I})},[]),xt=r.useCallback(()=>{if(!ye)return null;const _=ye.layers.find(I=>I.type==="zones");return!_||!ce(_.id)?null:e.jsx("g",{className:S.zonesLayer,children:_.objects.map(I=>{const z=I.metadata;if(!(z!=null&&z.points)||z.points.length<3)return null;const X=`M${z.points.map(te=>`${te.x},${te.y}`).join(" L")} Z`,le=(G==null?void 0:G.id)===I.id;return e.jsxs("g",{className:`${S.zone} ${le?S.zoneSelected:""}`,onClick:()=>{me(I),u==null||u(I)},children:[e.jsx("path",{d:X,fill:z.fill??"var(--nice-primary, #3b82f6)",fillOpacity:.2,stroke:z.fill??"var(--nice-primary, #3b82f6)",strokeWidth:le?2:1}),I.name&&e.jsx("text",{x:z.points[0].x+10,y:z.points[0].y+20,className:S.zoneLabel,children:I.name})]},I.id)})})},[ye,G,u,ce]),yt=r.useCallback(()=>ye?J&&he?e.jsx("g",{className:S.objectsLayer,children:he.map(_=>{const{object:I,layerId:z}=_.data;if(!ce(z))return null;const X=I.position??{x:0,y:0},le=I.size??{width:20,height:20},te=(G==null?void 0:G.id)===I.id;return e.jsxs("g",{className:`${S.object} ${te?S.objectSelected:""}`,transform:`translate(${X.x}, ${X.y})`,onClick:de=>{de.stopPropagation(),me(I),u==null||u(I)},children:[e.jsx("rect",{x:-le.width/2,y:-le.height/2,width:le.width,height:le.height,rx:4,fill:te?"var(--nice-primary, #3b82f6)":"var(--nice-text-secondary, #64748b)",fillOpacity:.8,stroke:te?"var(--nice-primary-dark, #1d4ed8)":"transparent",strokeWidth:2}),I.name&&e.jsx("text",{y:le.height/2+14,textAnchor:"middle",className:S.objectLabel,children:I.name})]},I.id)})}):e.jsx("g",{className:S.objectsLayer,children:ye.layers.map(_=>_.type==="zones"||_.type==="grid"||_.type==="background"||!ce(_.id)?null:_.objects.map(I=>{const z=I.position??{x:0,y:0},X=I.size??{width:20,height:20},le=(G==null?void 0:G.id)===I.id;return e.jsxs("g",{className:`${S.object} ${le?S.objectSelected:""}`,transform:`translate(${z.x}, ${z.y})`,onClick:te=>{te.stopPropagation(),me(I),u==null||u(I)},children:[e.jsx("rect",{x:-X.width/2,y:-X.height/2,width:X.width,height:X.height,rx:4,fill:le?"var(--nice-primary, #3b82f6)":"var(--nice-text-secondary, #64748b)",fillOpacity:.8,stroke:le?"var(--nice-primary-dark, #1d4ed8)":"transparent",strokeWidth:2}),I.name&&e.jsx("text",{y:X.height/2+14,textAnchor:"middle",className:S.objectLabel,children:I.name})]},I.id)}))}):null,[ye,G,u,ce,J,he]),qe=r.useCallback(()=>{const _=g.filter(z=>z.floorId===L),I={entrance:"🚪",elevator:"🛗",stairs:"🪜",exit:"🚨",poi:"📍",parking:"🅿️"};return e.jsx("g",{className:S.referencePoints,children:_.map(z=>e.jsxs("g",{className:S.referencePoint,transform:`translate(${z.position.x}, ${z.position.y})`,onClick:()=>{f&&(Q?oe(z.position):ge(z.position))},children:[e.jsx("circle",{r:16,fill:"white",stroke:"var(--nice-primary, #3b82f6)",strokeWidth:2}),e.jsx("text",{y:5,textAnchor:"middle",fontSize:"16",children:z.icon??I[z.type]??"📍"}),e.jsx("text",{y:30,textAnchor:"middle",className:S.refLabel,children:z.name})]},z.id))})},[g,L,f,Q]),vt=r.useCallback(()=>{if(!U)return null;const _=`M${U.path.map(I=>`${I.x},${I.y}`).join(" L")}`;return e.jsxs("g",{className:S.routeLayer,children:[e.jsx("path",{d:_,fill:"none",stroke:"var(--nice-primary, #3b82f6)",strokeWidth:4,strokeLinecap:"round",strokeLinejoin:"round",strokeDasharray:"12,6",className:S.routePath}),e.jsx("circle",{cx:U.startPoint.x,cy:U.startPoint.y,r:8,fill:"var(--nice-success, #10b981)",stroke:"white",strokeWidth:2}),e.jsx("circle",{cx:U.endPoint.x,cy:U.endPoint.y,r:8,fill:"var(--nice-danger, #ef4444)",stroke:"white",strokeWidth:2})]})},[U]),ft=r.useCallback(()=>b?e.jsxs("g",{className:S.currentLocation,children:[e.jsx("circle",{cx:b.x,cy:b.y,r:12,fill:"var(--nice-primary, #3b82f6)",fillOpacity:.3,className:S.locationPulse}),e.jsx("circle",{cx:b.x,cy:b.y,r:6,fill:"var(--nice-primary, #3b82f6)",stroke:"white",strokeWidth:2})]}):null,[b]),gt=r.useCallback(()=>e.jsx("g",{className:S.routeMarkers,children:Q&&!U&&e.jsx("circle",{cx:Q.x,cy:Q.y,r:8,fill:"var(--nice-success, #10b981)",stroke:"white",strokeWidth:2})}),[Q,U]);return e.jsxs("div",{ref:We,className:`${S.viewer} ${S[`theme_${v}`]} ${h??""}`,children:[i&&ee&&e.jsxs("div",{className:S.debugOverlay,children:[e.jsx("div",{children:"Virtual: ON"}),e.jsxs("div",{children:["Total: ",ee.total]}),e.jsxs("div",{children:["Visible: ",ee.visible]}),e.jsxs("div",{children:["Culled: ",ee.culled," (",ee.cullPercentage,"%)"]}),e.jsxs("div",{children:["Zoom: ",ee.zoom.toFixed(2),"x"]})]}),e.jsxs("div",{className:S.topBar,children:[c&&e.jsxs("div",{className:S.searchContainer,children:[e.jsxs("div",{className:S.searchInput,children:[e.jsx(xd,{}),e.jsx("input",{type:"text",placeholder:"Szukaj lokalizacji...",value:l,onChange:_=>$(_.target.value)}),l&&e.jsx("button",{className:S.clearBtn,onClick:()=>$(""),children:e.jsx(Ke,{})})]}),E.length>0&&e.jsx("div",{className:S.searchResults,children:E.map(_=>e.jsxs("button",{className:S.searchResultItem,onClick:()=>_t(_),children:[e.jsx(yd,{}),e.jsxs("div",{className:S.searchResultInfo,children:[e.jsx("span",{className:S.searchResultName,children:_.name??_.id}),_.description&&e.jsx("span",{className:S.searchResultDesc,children:_.description})]})]},_.id))})]}),n&&t.floors.length>1&&e.jsxs("div",{className:S.floorSelector,children:[e.jsx(vd,{}),e.jsx("select",{value:L,onChange:_=>p(_.target.value),children:t.floors.map(_=>e.jsx("option",{value:_.id,children:_.name??`Piętro ${_.level}`},_.id))})]}),a&&e.jsxs("button",{className:`${S.navBtn} ${q?S.active:""}`,onClick:()=>ie(!q),children:[e.jsx(Et,{}),e.jsx("span",{children:"Nawigacja"})]}),d&&e.jsxs("button",{className:`${S.layersBtn} ${je?S.active:""}`,onClick:()=>ke(!je),children:[e.jsx(Dt,{}),e.jsx("span",{children:"Warstwy"})]}),y&&e.jsxs("button",{className:`${S.legendBtn} ${xe?S.active:""}`,onClick:()=>Te(!xe),children:[e.jsx(Rt,{}),e.jsx("span",{children:"Legenda"})]})]}),e.jsxs("div",{className:S.content,children:[q&&e.jsxs("div",{className:S.navPanel,children:[e.jsxs("div",{className:S.navPanelHeader,children:[e.jsx(fd,{}),e.jsx("span",{children:"Planowanie trasy"}),e.jsx("button",{onClick:()=>ie(!1),children:e.jsx(Ke,{})})]}),e.jsxs("div",{className:S.routeInputs,children:[e.jsxs("div",{className:S.routeInput,children:[e.jsx("div",{className:S.routeMarker,style:{background:"var(--nice-success, #10b981)"}}),e.jsx("input",{type:"text",placeholder:"Punkt startowy",value:Q?`${Q.x.toFixed(0)}, ${Q.y.toFixed(0)}`:"",readOnly:!0})]}),e.jsxs("div",{className:S.routeInput,children:[e.jsx("div",{className:S.routeMarker,style:{background:"var(--nice-danger, #ef4444)"}}),e.jsx("input",{type:"text",placeholder:"Punkt docelowy",value:be?`${be.x.toFixed(0)}, ${be.y.toFixed(0)}`:"",readOnly:!0})]})]}),e.jsx("p",{className:S.routeHint,children:"Ctrl+kliknięcie na mapie, aby wybrać punkty"}),U&&e.jsxs("div",{className:S.routeInfo,children:[e.jsxs("div",{className:S.routeStat,children:[e.jsx("span",{className:S.routeStatLabel,children:"Dystans"}),e.jsx("span",{className:S.routeStatValue,children:kd(U.totalDistance)})]}),e.jsxs("div",{className:S.routeStat,children:[e.jsx("span",{className:S.routeStatLabel,children:"Czas"}),e.jsx("span",{className:S.routeStatValue,children:Cd(U.estimatedTime)})]})]}),(Q||be)&&e.jsx("button",{className:S.clearRouteBtn,onClick:ht,children:"Wyczyść trasę"}),g.length>0&&e.jsxs("div",{className:S.refPointsList,children:[e.jsx("h4",{children:"Punkty odniesienia"}),g.filter(_=>_.floorId===L).map(_=>e.jsxs("button",{className:S.refPointItem,onClick:()=>{Q?oe(_.position):ge(_.position)},children:[e.jsx("span",{className:S.refPointIcon,children:_.icon??"📍"}),e.jsx("span",{children:_.name})]},_.id))]})]}),je&&ye&&e.jsxs("div",{className:S.layersPanel,children:[e.jsxs("div",{className:S.layersPanelHeader,children:[e.jsx(Dt,{}),e.jsx("span",{children:"Warstwy"}),e.jsx("button",{onClick:()=>ke(!1),children:e.jsx(Ke,{})})]}),e.jsx("div",{className:S.layersList,children:ye.layers.map(_=>{const I=ce(_.id);return e.jsxs("div",{className:S.layerItem,children:[e.jsx("button",{className:S.layerToggle,onClick:()=>_e(_.id),title:I?"Ukryj warstwę":"Pokaż warstwę",children:I?e.jsx(jd,{}):e.jsx(wd,{})}),e.jsx("span",{className:S.layerName,children:_.name??_.id}),e.jsxs("span",{className:S.layerType,children:["(",_.type,")"]})]},_.id)})})]}),e.jsxs("div",{className:S.canvasWrapper,children:[e.jsx("svg",{ref:Le,className:S.canvas,onMouseDown:Qe,onMouseMove:et,onMouseUp:ue,onMouseLeave:ue,onWheel:Oe,onClick:Ge,children:e.jsxs("g",{transform:`translate(${C.pan.x}, ${C.pan.y}) scale(${C.zoom})`,children:[mt(),xt(),yt(),qe(),gt(),vt(),ft()]})}),e.jsxs("div",{className:S.zoomControls,children:[e.jsx("button",{onClick:dt,title:"Powiększ",children:e.jsx(gd,{})}),e.jsx("button",{onClick:ut,title:"Pomniejsz",children:e.jsx(bd,{})}),e.jsx("button",{onClick:pt,title:"Resetuj widok",children:"⟲"})]}),o&&e.jsx("div",{className:S.minimap,children:e.jsx("div",{className:S.minimapContent,children:e.jsx("div",{className:S.minimapViewport})})}),xe&&Be.length>0&&e.jsxs("div",{className:S.legendPanel,children:[e.jsxs("div",{className:S.legendPanelHeader,children:[e.jsx(Rt,{}),e.jsx("span",{children:"Legenda"}),e.jsx("button",{onClick:()=>Te(!1),children:e.jsx(Ke,{})})]}),e.jsx("div",{className:S.legendList,children:Be.map(_=>e.jsxs("div",{className:S.legendItem,children:[_.icon?e.jsx("span",{className:S.legendIcon,children:_.icon}):e.jsx("span",{className:S.legendColor,style:{background:_.color}}),e.jsx("span",{className:S.legendLabel,children:_.label}),e.jsx("span",{className:S.legendType,children:_.type==="zone"?"strefa":_.type==="object"?"obiekt":"punkt ref."})]},_.id))})]})]})]}),G&&e.jsxs("div",{className:S.objectInfo,children:[e.jsxs("div",{className:S.objectInfoHeader,children:[e.jsx("h4",{children:G.name??G.id}),e.jsx("button",{onClick:()=>me(null),children:e.jsx(Ke,{})})]}),G.description&&e.jsx("p",{children:G.description}),f&&e.jsxs("button",{className:S.navigateBtn,onClick:()=>{const _=G.position??{x:0,y:0};Q?oe(_):ge(_)},children:[e.jsx(Et,{}),Q?"Ustaw jako cel":"Ustaw jako start"]})]})]})};function Sd(t={}){var be;const{initialDocument:s,defaultMode:a="floor-plan",gridSize:o=20,snapEnabled:n=!0,onChange:c}=t,d={mode:a,tool:"select",document:s??null,activeFloorId:((be=s==null?void 0:s.floors[0])==null?void 0:be.id)??null,layers:[],selection:{objectIds:[],bounds:null,locked:!1},viewport:{zoom:1,pan:{x:0,y:0},rotation:0,showGrid:!0,gridSize:o,snapEnabled:n,snapModes:["grid","endpoint","midpoint"]},drawing:{active:!1,points:[],preview:null},history:{past:[],future:[]},guides:[],dragging:null,connecting:{active:!1,sourceId:null,sourcePosition:null,previewPosition:null},clipboard:[],ui:{showObjectLibrary:!0,showLayerPanel:!0,showPropertiesPanel:!0,showMinimap:!0}},[y,f]=r.useReducer((oe,U)=>({...oe,...U}),d),g=r.useCallback(oe=>{f({mode:oe})},[]),u=r.useCallback(oe=>{f({tool:oe})},[]),N=r.useCallback((oe="Untitled")=>{var k;const U=H.createFloorPlanDocument(oe,"floor-plan");f({document:U,activeFloorId:((k=U.floors[0])==null?void 0:k.id)??null}),c==null||c(U)},[c]),b=r.useCallback(oe=>{var U;f({document:oe,activeFloorId:((U=oe.floors[0])==null?void 0:U.id)??null}),c==null||c(oe)},[c]),v=r.useCallback(oe=>{f({viewport:{...y.viewport,zoom:Math.max(.1,Math.min(10,y.viewport.zoom*(1+oe*.1)))}})},[y.viewport]),h=r.useCallback(oe=>{f({viewport:{...y.viewport,pan:{x:y.viewport.pan.x+oe.x,y:y.viewport.pan.y+oe.y}}})},[y.viewport]),x=r.useCallback(()=>{f({viewport:{...y.viewport,zoom:1,pan:{x:0,y:0}}})},[y.viewport]),j=r.useCallback(()=>{f({viewport:{...y.viewport,showGrid:!y.viewport.showGrid}})},[y.viewport]),i=r.useCallback(()=>{f({viewport:{...y.viewport,snapEnabled:!y.viewport.snapEnabled}})},[y.viewport]),L=r.useCallback(oe=>{f({viewport:{...y.viewport,gridSize:oe}})},[y.viewport]),p=r.useCallback((oe,U)=>{f({layers:y.layers.map(k=>k.type===oe?{...k,visible:U}:k)})},[y.layers]),C=r.useCallback((oe,U)=>{f({layers:y.layers.map(k=>k.type===oe?{...k,locked:U}:k)})},[y.layers]),w=r.useCallback(oe=>{f({selection:{objectIds:oe,bounds:null,locked:!1}})},[]),l=r.useCallback(()=>{f({selection:{objectIds:[],bounds:null,locked:!1}})},[]),$=r.useCallback(()=>{},[]),E=r.useCallback(()=>{},[]),V=y.history.past.length>0,G=y.history.future.length>0,me=r.useCallback(()=>{},[]),Q=r.useCallback(oe=>{},[]),ge=r.useCallback(()=>{},[]);return{state:y,setMode:g,setTool:u,newDocument:N,loadDocument:b,zoom:v,pan:h,resetView:x,toggleGrid:j,toggleSnap:i,setGridSize:L,setLayerVisible:p,setLayerLocked:C,select:w,clearSelection:l,undo:$,redo:E,canUndo:V,canRedo:G,copy:me,paste:Q,cut:ge}}function Ld(t={}){const{gridSize:s=20,enabled:a=!0,snapModes:o=["grid","endpoint","midpoint"],objects:n=[],threshold:c=10}=t,d=r.useMemo(()=>({...H.DEFAULT_GRID_CONFIG,cellSize:s,snapModes:o,snapThreshold:c}),[s,o,c]),y=r.useMemo(()=>n.map((v,h)=>({id:`obj-${h}`,bounds:v})),[n]),f=r.useCallback(v=>a?H.snapToGrid(v,d):v,[a,d]),g=r.useCallback(v=>a?H.snapToGrid3D(v,s):v,[a,s]),u=r.useCallback(v=>{if(!a||y.length===0)return[];const h={x:v.x,y:v.y,width:0,height:0};return H.generateAlignmentGuides(h,y,c)},[a,y,c]),N=r.useCallback(v=>{if(!a)return{point:v,snapped:!1,guides:[]};const h=H.performSnap(v,y,d);return{point:h.position,snapped:h.snapped,guides:h.guides??[]}},[a,d,y]),b=r.useCallback((v,h)=>{const x=[];for(let j=0;j<=v;j+=s)x.push({x1:j,y1:0,x2:j,y2:h});for(let j=0;j<=h;j+=s)x.push({x1:0,y1:j,x2:v,y2:j});return x},[s]);return{snap:f,snap3D:g,getGuides:u,performAdvancedSnap:N,generateGridLines:b}}function zd(t={}){const{unitSystem:s="metric",lengthUnit:a="m",areaUnit:o="m2",angleUnit:n="deg",scale:c=100}=t,[d,y]=r.useState(null),[f,g]=r.useState([]),u=r.useCallback(l=>l/c,[c]),N=r.useCallback(l=>{y(l),g([])},[]),b=r.useCallback((l,$=!1)=>{g(E=>[...E,{position:l,snapped:$}])},[]),v=r.useCallback(()=>{y(null),g([])},[]),h=r.useCallback(()=>{if(!d||f.length<2)return null;const l=f.map($=>$.position);if(d==="distance"&&f.length===2){const $=H.distance2D(l[0],l[1]),E=u($);return{type:"distance",value:E,formatted:H.autoFormatLength(E,s).formatted,points:l}}if(d==="angle"&&f.length===3){const $=H.angleAtVertex(l[0],l[1],l[2]);return{type:"angle",value:$,formatted:H.formatAngle($,n).formatted,points:l}}if(d==="area"&&f.length>=3){const E=H.polygonArea(l)/(c*c);return{type:"area",value:E,formatted:H.autoFormatArea(E,s).formatted,points:l}}return null},[d,f,c,s,n,u]),x=f.length>=2&&d==="distance"?H.autoFormatLength(u(H.distance2D(f[0].position,f[f.length-1].position)),s).formatted:null,j=f.length>=3&&d==="angle"?H.formatAngle(H.angleAtVertex(f[0].position,f[1].position,f[2].position),n).formatted:null,i=f.length>=3&&d==="area"?H.autoFormatArea(H.polygonArea(f.map(l=>l.position))/(c*c),s).formatted:null,L=r.useCallback((l,$)=>{const E=H.distance2D(l,$),V=u(E);return{value:V,formatted:H.autoFormatLength(V,s).formatted}},[u,s]),p=r.useCallback((l,$,E)=>{const V=H.angleAtVertex(l,$,E);return{value:V,formatted:H.formatAngle(V,n).formatted}},[n]),C=r.useCallback(l=>{const E=H.polygonArea(l)/(c*c);return{value:E,formatted:H.autoFormatArea(E,s).formatted}},[c,s]),w=r.useCallback(l=>{const $=H.polylineLength(l),E=u($);return{value:E,formatted:H.autoFormatLength(E,s).formatted}},[u,s]);return{startMeasurement:N,addPoint:b,clearMeasurement:v,finishMeasurement:h,measurementType:d,points:f,liveDistance:x,liveAngle:j,liveArea:i,getDistance:L,getAngle:p,getArea:C,getLength:w}}const $d="_root_1er3p_3",Bd="_dark_1er3p_25",Td="_header_1er3p_31",Pd="_buildingInfo_1er3p_45",Md="_buildingName_1er3p_49",Od="_buildingAddress_1er3p_67",Ad="_modeSelector_1er3p_81",Ed="_modeBtn_1er3p_93",Dd="_modeBtnActive_1er3p_127",Rd="_weather_1er3p_141",Wd="_weatherTemp_1er3p_155",Gd="_weatherDesc_1er3p_171",qd="_statsRow_1er3p_183",Fd="_statsCard_1er3p_195",Vd="_statsHeader_1er3p_225",Hd="_statsIcon_1er3p_239",Ud="_statsLabel_1er3p_243",Zd="_statsValue_1er3p_257",Yd="_statsSub_1er3p_275",Kd="_zoneGrid_1er3p_289",Xd="_zoneCard_1er3p_303",Jd="_zoneOccupied_1er3p_347",Qd="_zoneCardHeader_1er3p_351",eu="_zoneCardIcon_1er3p_365",tu="_zoneCardTitles_1er3p_369",su="_zoneCardName_1er3p_379",nu="_zoneCardArea_1er3p_403",ou="_occupancyBadge_1er3p_413",au="_occupancyBadgeOn_1er3p_431",cu="_sensorRow_1er3p_443",ru="_sensorChip_1er3p_457",iu="_sensorWarn_1er3p_475",lu="_deviceList_1er3p_489",du="_deviceChip_1er3p_501",uu="_deviceChipOn_1er3p_535",pu="_deviceChipName_1er3p_547",_u="_deviceChipVal_1er3p_561",hu="_moreBtn_1er3p_571",mu="_scenesBar_1er3p_597",xu="_sceneBarLabel_1er3p_627",yu="_sceneList_1er3p_645",vu="_sceneBtn_1er3p_657",fu="_sceneBtnActive_1er3p_683",F={root:$d,dark:Bd,header:Td,buildingInfo:Pd,buildingName:Md,buildingAddress:Od,modeSelector:Ad,modeBtn:Ed,modeBtnActive:Dd,weather:Rd,weatherTemp:Wd,weatherDesc:Gd,statsRow:qd,statsCard:Fd,statsHeader:Vd,statsIcon:Hd,statsLabel:Ud,statsValue:Zd,statsSub:Yd,zoneGrid:Kd,zoneCard:Xd,zoneOccupied:Jd,zoneCardHeader:Qd,zoneCardIcon:eu,zoneCardTitles:tu,zoneCardName:su,zoneCardArea:nu,occupancyBadge:ou,occupancyBadgeOn:au,sensorRow:cu,sensorChip:ru,sensorWarn:iu,deviceList:lu,deviceChip:du,deviceChipOn:uu,deviceChipName:pu,deviceChipVal:_u,moreBtn:hu,scenesBar:mu,sceneBarLabel:xu,sceneList:yu,sceneBtn:vu,sceneBtnActive:fu},Xt={living_room:"🛋",bedroom:"🛏",master_bedroom:"🛏",kids_room:"🧸",bathroom:"🚿",kitchen:"🍳",dining_room:"🍽",hallway:"🚪",office:"💼",garage:"🚗",gym:"🏋",cinema:"🎬",balcony:"🌿",garden:"🌳",open_office:"💼",private_office:"🖥",meeting_room:"📋",boardroom:"🤝",reception:"🏢",server_room:"🖥",lobby:"🏛",corridor:"↔",stairwell:"🪜",parking:"🅿",break_room:"☕",it_room:"💻",cafeteria:"🍽"};function gu(t){return Xt[t]??"🏠"}function bu(t){if(!t.state)return null;const s=t.state;return typeof s.brightness=="number"?`${s.brightness}%`:typeof s.on=="boolean"?s.on?"Wł":"Wył":typeof s.temperature=="number"?`${s.temperature.toFixed(1)}°`:typeof s.locked=="boolean"?s.locked?"🔒":"🔓":null}const Jt=({zone:t,devices:s=[],expanded:a=!1,onExpand:o,onDeviceControl:n,onClick:c,theme:d="light",className:y,style:f})=>{const g=t.occupancy!=null&&t.occupancy>0,u=a?s:s.slice(0,4);return e.jsxs("div",{className:`${F.zoneCard} ${d==="dark"?F.dark:""} ${g?F.zoneOccupied:""} ${y??""}`,style:f,onClick:c,children:[e.jsxs("div",{className:F.zoneCardHeader,children:[e.jsx("span",{className:F.zoneCardIcon,children:gu(t.type)}),e.jsxs("div",{className:F.zoneCardTitles,children:[e.jsx("span",{className:F.zoneCardName,children:t.name}),t.area!=null&&e.jsxs("span",{className:F.zoneCardArea,children:[t.area," m²"]})]}),t.occupancy!=null&&e.jsxs("span",{className:`${F.occupancyBadge} ${g?F.occupancyBadgeOn:""}`,children:["👥 ",t.occupancy]})]}),(t.temperature!=null||t.humidity!=null||t.co2!=null)&&e.jsxs("div",{className:F.sensorRow,children:[t.temperature!=null&&e.jsxs("span",{className:F.sensorChip,children:["🌡 ",t.temperature.toFixed(1),"°C"]}),t.humidity!=null&&e.jsxs("span",{className:F.sensorChip,children:["💧 ",t.humidity,"%"]}),t.co2!=null&&e.jsxs("span",{className:`${F.sensorChip} ${t.co2>1e3?F.sensorWarn:""}`,children:["CO₂ ",t.co2]})]}),u.length>0&&e.jsxs("div",{className:F.deviceList,children:[u.map(N=>{const b=N.state,v=(b==null?void 0:b.on)===!0||(b==null?void 0:b.locked)===!1;return e.jsxs("button",{className:`${F.deviceChip} ${v?F.deviceChipOn:""}`,onClick:h=>{h.stopPropagation(),n==null||n(N.id,{on:!v})},title:N.name,children:[e.jsx("span",{children:Xt[N.type]??"📟"}),e.jsx("span",{className:F.deviceChipName,children:N.name}),e.jsx("span",{className:F.deviceChipVal,children:bu(N)})]},N.id)}),s.length>4&&e.jsx("button",{className:F.moreBtn,onClick:N=>{N.stopPropagation(),o==null||o()},children:a?"−":`+${s.length-4}`})]})]})},wt={home:"Dom",away:"Wyjazd",night:"Noc",vacation:"Urlop",guest:"Gość",party:"Impreza",occupied:"Zajęty",closed:"Zamknięty",weekend:"Weekend",event:"Wydarzenie",emergency:"Alarm",maintenance:"Serwis"},Wt={home:"🏠",away:"🚗",night:"🌙",vacation:"✈",guest:"👋",party:"🎉",occupied:"🏢",closed:"🔒",weekend:"☀",event:"🎉",emergency:"🚨",maintenance:"🔧"},ju=({temperature:t,description:s})=>t!=null?e.jsxs("div",{className:F.weather,children:[e.jsxs("span",{className:F.weatherTemp,children:[t,"°C"]}),s&&e.jsx("span",{className:F.weatherDesc,children:s})]}):null,rt=({label:t,value:s,sub:a,icon:o,accent:n})=>e.jsxs("div",{className:F.statsCard,style:n?{borderTopColor:n}:void 0,children:[e.jsxs("div",{className:F.statsHeader,children:[o&&e.jsx("span",{className:F.statsIcon,children:o}),e.jsx("span",{className:F.statsLabel,children:t})]}),e.jsx("div",{className:F.statsValue,children:s}),a&&e.jsx("div",{className:F.statsSub,children:a})]}),wu=({building:t,state:s,onModeChange:a,onDeviceControl:o,onSceneActivate:n,onZoneClick:c,className:d,style:y,theme:f="light",weather:g})=>{var p,C,w;const[u,N]=r.useState(null);t.floors[0];const b=t.floors.flatMap(l=>l.zones??[]).filter(l=>l.type!=="hallway"&&l.type!=="corridor"),v=((p=s==null?void 0:s.activeAlerts)==null?void 0:p.length)??0,h=(C=s==null?void 0:s.energy)==null?void 0:C.currentPowerW,x=(w=s==null?void 0:s.energy)==null?void 0:w.todayKwh,j=s!=null&&s.occupancy?Object.values(s.occupancy).reduce((l,$)=>l+(($==null?void 0:$.occupancy)??0),0):null;t.floors.flatMap(l=>l.zones??[]).flatMap(l=>l.deviceIds??[]).slice(0,8);const i=t.type==="office"||t.type==="retail"?["occupied","closed","weekend","event","emergency","maintenance"]:["home","away","night","vacation","guest","emergency"],L=(s==null?void 0:s.mode)??"home";return e.jsxs("div",{className:`${F.root} ${f==="dark"?F.dark:""} ${d??""}`,style:y,children:[e.jsxs("div",{className:F.header,children:[e.jsxs("div",{className:F.buildingInfo,children:[e.jsx("h2",{className:F.buildingName,children:t.name}),t.address&&e.jsx("p",{className:F.buildingAddress,children:t.address})]}),e.jsx("div",{className:F.modeSelector,children:i.map(l=>e.jsxs("button",{title:wt[l],className:`${F.modeBtn} ${L===l?F.modeBtnActive:""}`,onClick:()=>a==null?void 0:a(l),children:[Wt[l],e.jsx("span",{children:wt[l]})]},l))}),e.jsx(ju,{temperature:g==null?void 0:g.temperature,description:g==null?void 0:g.description})]}),e.jsxs("div",{className:F.statsRow,children:[h!=null&&e.jsx(rt,{icon:"⚡",label:"Moc",value:h>=1e3?`${(h/1e3).toFixed(2)} kW`:`${h} W`,sub:x!=null?`Dziś: ${x.toFixed(2)} kWh`:void 0,accent:"var(--nice-warning, #f59e0b)"}),j!=null&&e.jsx(rt,{icon:"👥",label:"Obecność",value:`${j} os.`,sub:`${b.length} stref`,accent:"var(--nice-success, #22c55e)"}),v>0&&e.jsx(rt,{icon:"🚨",label:"Alarmy",value:e.jsx("span",{style:{color:"var(--nice-danger, #ef4444)"},children:v}),sub:"aktywnych",accent:"var(--nice-danger, #ef4444)"}),e.jsx(rt,{icon:Wt[L],label:"Tryb",value:wt[L],accent:"var(--nice-accent, #8b5cf6)"})]}),e.jsx("div",{className:F.zoneGrid,children:b.map(l=>{const $=t.floors.flatMap(E=>(E.zones??[]).find(V=>V.id===l.id)?t.devices??[]:[]).filter(E=>E.zoneId===l.id);return e.jsx(Jt,{zone:l,devices:$,expanded:u===l.id,onExpand:()=>N(u===l.id?null:l.id),onDeviceControl:o,onClick:()=>c==null?void 0:c(l.id),theme:f},l.id)})}),t.scenes&&t.scenes.length>0&&e.jsxs("div",{className:F.scenesBar,children:[e.jsx("span",{className:F.sceneBarLabel,children:"Sceny"}),e.jsx("div",{className:F.sceneList,children:t.scenes.map(l=>{var $;return e.jsxs("button",{className:`${F.sceneBtn} ${($=s==null?void 0:s.activeScenes)!=null&&$.includes(l.id)?F.sceneBtnActive:""}`,onClick:()=>n==null?void 0:n(l.id),children:[l.icon??"🎭"," ",l.name]},l.id)})})]})]})},Nu="_deviceControl_ev96o_3",ku="_dark_ev96o_23",Cu="_compact_ev96o_35",Iu="_offline_ev96o_39",Su="_offlineBanner_ev96o_43",Lu="_toggleControl_ev96o_67",zu="_toggleLabel_ev96o_81",$u="_toggleBtn_ev96o_97",Bu="_toggleOn_ev96o_123",Tu="_blindControl_ev96o_137",Pu="_blindLabel_ev96o_139",Mu="_blindActions_ev96o_143",Ou="_blindBtn_ev96o_145",Au="_blindSlider_ev96o_149",Eu="_blindPct_ev96o_151",Du="_lockControl_ev96o_157",Ru="_lockLabel_ev96o_159",Wu="_lockBtn_ev96o_163",Gu="_lockLocked_ev96o_165",qu="_lockUnlocked_ev96o_167",Fu="_cameraControl_ev96o_173",Vu="_cameraLabel_ev96o_175",Hu="_cameraSnapshot_ev96o_179",Uu="_cameraPlaceholder_ev96o_181",Zu="_cameraStatus_ev96o_183",Yu="_cameraDot_ev96o_185",Ku="_cameraOnline_ev96o_187",Xu="_cameraOffline_ev96o_189",Ju="_sensorControl_ev96o_195",Qu="_sensorLabel_ev96o_197",ep="_sensorValues_ev96o_201",tp="_sensorRow_ev96o_203",sp="_sensorKey_ev96o_205",np="_sensorVal_ev96o_201",op="_thermostat_ev96o_215",ap="_thermostatTitle_ev96o_229",cp="_thermostatDial_ev96o_247",rp="_dialTempCurrent_ev96o_257",ip="_dialTempLabel_ev96o_273",lp="_dialTempTarget_ev96o_283",dp="_dialHumidity_ev96o_299",up="_thermostatAdjust_ev96o_309",pp="_adjustBtn_ev96o_321",_p="_adjustTemp_ev96o_355",hp="_hvacModes_ev96o_375",mp="_hvacModeBtn_ev96o_389",xp="_hvacModeBtnActive_ev96o_413",yp="_hvacAction_ev96o_425",vp="_hvacActionDot_ev96o_441",fp="_lightControl_ev96o_455",gp="_lightHeader_ev96o_467",bp="_lightIcon_ev96o_479",jp="_lightName_ev96o_483",wp="_lightToggle_ev96o_507",Np="_lightToggleOn_ev96o_535",kp="_sliderRow_ev96o_547",Cp="_sliderIcon_ev96o_561",Ip="_slider_ev96o_547",Sp="_sliderVal_ev96o_579",Lp="_colorRow_ev96o_591",zp="_colorSwatch_ev96o_605",$p="_colorPicker_ev96o_621",Bp="_colorPresets_ev96o_637",Tp="_colorPreset_ev96o_637",Pp="_lightOff_ev96o_663",B={deviceControl:Nu,dark:ku,compact:Cu,offline:Iu,offlineBanner:Su,toggleControl:Lu,toggleLabel:zu,toggleBtn:$u,toggleOn:Bu,blindControl:Tu,blindLabel:Pu,blindActions:Mu,blindBtn:Ou,blindSlider:Au,blindPct:Eu,lockControl:Du,lockLabel:Ru,lockBtn:Wu,lockLocked:Gu,lockUnlocked:qu,cameraControl:Fu,cameraLabel:Vu,cameraSnapshot:Hu,cameraPlaceholder:Uu,cameraStatus:Zu,cameraDot:Yu,cameraOnline:Ku,cameraOffline:Xu,sensorControl:Ju,sensorLabel:Qu,sensorValues:ep,sensorRow:tp,sensorKey:sp,sensorVal:np,thermostat:op,thermostatTitle:ap,thermostatDial:cp,dialTempCurrent:rp,dialTempLabel:ip,dialTempTarget:lp,dialHumidity:dp,thermostatAdjust:up,adjustBtn:pp,adjustTemp:_p,hvacModes:hp,hvacModeBtn:mp,hvacModeBtnActive:xp,hvacAction:yp,hvacActionDot:vp,lightControl:fp,lightHeader:gp,lightIcon:bp,lightName:jp,lightToggle:wp,lightToggleOn:Np,sliderRow:kp,sliderIcon:Cp,slider:Ip,sliderVal:Sp,colorRow:Lp,colorSwatch:zp,colorPicker:$p,colorPresets:Bp,colorPreset:Tp,lightOff:Pp};function Gt(t){const s=Math.max(0,Math.min(1,(t-2700)/3800)),a=Math.round(255-s*80),o=Math.round(200+s*30),n=Math.round(100+s*155);return`rgb(${a},${o},${n})`}function Mp(t,s,a){return"#"+[t,s,a].map(o=>o.toString(16).padStart(2,"0")).join("")}function qt(t){const s=parseInt(t.slice(1,3),16),a=parseInt(t.slice(3,5),16),o=parseInt(t.slice(5,7),16);return[s,a,o]}const Qt=({device:t,onControl:s,compact:a=!1,theme:o="light",className:n,style:c})=>{var L,p,C;const d=t.state,y=(d==null?void 0:d.on)??!1,f=(d==null?void 0:d.brightness)??100,g=(d==null?void 0:d.colorTemperature)??4e3,u=d==null?void 0:d.rgbColor,[N,b]=r.useState(!1),v=r.useCallback(w=>{s==null||s(t.id,w)},[t.id,s]),h=u?Mp(u[0],u[1],u[2]):"var(--nice-bg, #fff)",x=((L=t.capabilities)==null?void 0:L.includes("dimming"))??f!==void 0,j=(p=t.capabilities)==null?void 0:p.includes("color_temperature"),i=((C=t.capabilities)==null?void 0:C.includes("color"))||t.type==="rgb_light";return e.jsxs("div",{className:`${B.lightControl} ${a?B.compact:""} ${o==="dark"?B.dark:""} ${n??""}`,style:c,children:[e.jsxs("div",{className:B.lightHeader,children:[e.jsx("span",{className:B.lightIcon,style:{opacity:y?1:.4},children:"💡"}),e.jsx("span",{className:B.lightName,children:t.name}),e.jsx("button",{className:`${B.lightToggle} ${y?B.lightToggleOn:""}`,onClick:()=>v({on:!y}),children:y?"●":"○"})]}),y&&e.jsxs(e.Fragment,{children:[x&&e.jsxs("div",{className:B.sliderRow,children:[e.jsx("span",{className:B.sliderIcon,children:"🔅"}),e.jsx("input",{type:"range",min:1,max:100,value:f,className:B.slider,style:{"--pct":`${f}%`},onChange:w=>v({brightness:+w.target.value})}),e.jsxs("span",{className:B.sliderVal,children:[f,"%"]})]}),j&&e.jsxs("div",{className:B.sliderRow,children:[e.jsx("span",{className:B.sliderIcon,children:"🌡"}),e.jsx("input",{type:"range",min:2700,max:6500,step:100,value:g,className:B.slider,style:{background:`linear-gradient(to right, ${Gt(2700)}, ${Gt(6500)})`},onChange:w=>v({colorTemperature:+w.target.value})}),e.jsxs("span",{className:B.sliderVal,children:[Math.round(g/100)*100,"K"]})]}),i&&e.jsxs("div",{className:B.colorRow,children:[e.jsx("span",{className:B.sliderIcon,children:"🎨"}),e.jsx("button",{className:B.colorSwatch,style:{background:h},onClick:()=>b(w=>!w)}),N&&e.jsx("input",{type:"color",value:h,className:B.colorPicker,onChange:w=>{const[l,$,E]=qt(w.target.value);v({rgbColor:[l,$,E]})}}),e.jsx("div",{className:B.colorPresets,children:["var(--nice-bg, #fff)","var(--nice-warning-bg, #fde68a)","var(--nice-danger-bg, #fca5a5)","var(--nice-primary-light, #93c5fd)","var(--nice-success-light, #86efac)","var(--nice-accent, #c4b5fd)"].map(w=>e.jsx("button",{className:B.colorPreset,style:{background:w},onClick:()=>{const[l,$,E]=qt(w);v({rgbColor:[l,$,E]})}},w))})]})]}),!y&&!a&&e.jsx("div",{className:B.lightOff,children:"Wyłączone"})]})},Ft={heat:"🔥 Grzanie",cool:"❄ Chłodzenie",auto:"⚡ Auto",off:"⏻ Wyłącz",fan_only:"💨 Wentylacja",dry:"💧 Osuszanie"},Op={heating:"var(--nice-danger, #ef4444)",cooling:"var(--nice-primary, #3b82f6)",fan:"var(--nice-success, #22c55e)",drying:"var(--nice-warning, #f59e0b)",idle:"var(--nice-text-muted, #94a3b8)",off:"var(--nice-border, #e2e8f0)"};function Vt(t,s,a,o,n){const c=N=>(N-90)*(Math.PI/180),d=t+a*Math.cos(c(o)),y=s+a*Math.sin(c(o)),f=t+a*Math.cos(c(n)),g=s+a*Math.sin(c(n)),u=n-o>180?1:0;return`M${d.toFixed(2)},${y.toFixed(2)} A${a},${a} 0 ${u},1 ${f.toFixed(2)},${g.toFixed(2)}`}const Xe=5,it=35,lt=-140,es=140;function Ht(t){return lt+(t-Xe)/(it-Xe)*(es-lt)}const ts=({device:t,onControl:s,compact:a=!1,theme:o="light",className:n,style:c})=>{const d=t.state,y=(d==null?void 0:d.temperature)??20,f=(d==null?void 0:d.targetTemperature)??21,g=d==null?void 0:d.humidity,u=(d==null?void 0:d.mode)??"auto",N=(d==null?void 0:d.hvacAction)??"idle",b=80,v=80,h=60,x=Vt(b,v,h,lt,es),j=Ht(Math.min(Math.max(y,Xe),it)),i=Ht(Math.min(Math.max(f,Xe),it)),L=Vt(b,v,h,lt,Math.min(j,i)),p=Op[N]??"var(--nice-text-muted, #94a3b8)",C=r.useCallback(l=>{const $=Math.round((f+l)*2)/2;$>=Xe&&$<=it&&(s==null||s(t.id,{targetTemperature:$}))},[f,t.id,s]),w=r.useCallback(l=>{s==null||s(t.id,{mode:l})},[t.id,s]);return e.jsxs("div",{className:`${B.thermostat} ${a?B.compact:""} ${o==="dark"?B.dark:""} ${n??""}`,style:c,children:[e.jsx("div",{className:B.thermostatTitle,children:t.name}),e.jsxs("svg",{width:160,height:160,className:B.thermostatDial,children:[e.jsx("path",{d:x,fill:"none",stroke:"var(--nice-border, #e2e8f0)",strokeWidth:8,strokeLinecap:"round"}),e.jsx("path",{d:L,fill:"none",stroke:p,strokeWidth:8,strokeLinecap:"round",opacity:.4}),e.jsx("circle",{cx:b+h*Math.cos((i-90)*(Math.PI/180)),cy:v+h*Math.sin((i-90)*(Math.PI/180)),r:7,fill:p,stroke:"var(--nice-bg, #fff)",strokeWidth:2}),e.jsxs("text",{x:b,y:v-6,textAnchor:"middle",className:B.dialTempCurrent,children:[y.toFixed(1),"°"]}),e.jsx("text",{x:b,y:v+14,textAnchor:"middle",className:B.dialTempLabel,children:"aktualnie"}),e.jsxs("text",{x:b,y:v+32,textAnchor:"middle",className:B.dialTempTarget,children:["▶ ",f.toFixed(1),"°"]}),g!=null&&e.jsxs("text",{x:b,y:v+48,textAnchor:"middle",className:B.dialHumidity,children:["💧 ",g,"%"]})]}),e.jsxs("div",{className:B.thermostatAdjust,children:[e.jsx("button",{className:B.adjustBtn,onClick:()=>C(-.5),children:"−"}),e.jsxs("span",{className:B.adjustTemp,children:[f.toFixed(1)," °C"]}),e.jsx("button",{className:B.adjustBtn,onClick:()=>C(.5),children:"+"})]}),!a&&e.jsx("div",{className:B.hvacModes,children:["heat","cool","auto","fan_only","off"].map(l=>e.jsx("button",{title:Ft[l],className:`${B.hvacModeBtn} ${u===l?B.hvacModeBtnActive:""}`,onClick:()=>w(l),children:Ft[l].split(" ")[0]},l))}),e.jsxs("div",{className:B.hvacAction,style:{color:p},children:[e.jsx("span",{className:B.hvacActionDot,style:{background:p}}),N]})]})},Ap=({device:t,onControl:s})=>{const a=t.state,o=(a==null?void 0:a.on)===!0;return e.jsxs("div",{className:B.toggleControl,children:[e.jsx("span",{className:B.toggleLabel,children:t.name}),e.jsx("button",{className:`${B.toggleBtn} ${o?B.toggleOn:""}`,onClick:()=>s==null?void 0:s(t.id,{on:!o}),children:o?"WŁĄCZONE":"WYŁĄCZONE"})]})},Ep=({device:t,onControl:s})=>{const a=t.state,o=typeof(a==null?void 0:a.position)=="number"?a.position:50;return e.jsxs("div",{className:B.blindControl,children:[e.jsx("span",{className:B.blindLabel,children:t.name}),e.jsxs("div",{className:B.blindActions,children:[e.jsx("button",{className:B.blindBtn,onClick:()=>s==null?void 0:s(t.id,{command:"open"}),children:"▲"}),e.jsx("button",{className:B.blindBtn,onClick:()=>s==null?void 0:s(t.id,{command:"stop"}),children:"■"}),e.jsx("button",{className:B.blindBtn,onClick:()=>s==null?void 0:s(t.id,{command:"close"}),children:"▼"})]}),e.jsx("input",{type:"range",min:0,max:100,value:o,className:B.blindSlider,onChange:n=>s==null?void 0:s(t.id,{position:+n.target.value})}),e.jsxs("span",{className:B.blindPct,children:[o,"%"]})]})},Dp=({device:t,onControl:s})=>{const a=t.state,o=(a==null?void 0:a.locked)!==!1;return e.jsxs("div",{className:B.lockControl,children:[e.jsx("span",{className:B.lockLabel,children:t.name}),e.jsx("button",{className:`${B.lockBtn} ${o?B.lockLocked:B.lockUnlocked}`,onClick:()=>s==null?void 0:s(t.id,{locked:!o}),children:o?"🔒 Zablokowany":"🔓 Odblokowany"})]})},Rp=({device:t})=>{const s=t.state;return e.jsxs("div",{className:B.cameraControl,children:[e.jsx("span",{className:B.cameraLabel,children:t.name}),s!=null&&s.snapshotUrl?e.jsx("img",{src:s.snapshotUrl,alt:"snapshot",className:B.cameraSnapshot}):e.jsxs("div",{className:B.cameraPlaceholder,children:[e.jsx("span",{children:"📷"}),e.jsx("span",{children:s!=null&&s.streaming?"Streaming":"Brak podglądu"})]}),e.jsxs("div",{className:B.cameraStatus,children:[e.jsx("span",{className:`${B.cameraDot} ${t.status==="online"?B.cameraOnline:B.cameraOffline}`}),t.status]})]})},Wp=({device:t})=>{const s=t.state;return e.jsxs("div",{className:B.sensorControl,children:[e.jsx("span",{className:B.sensorLabel,children:t.name}),e.jsx("div",{className:B.sensorValues,children:Object.entries(s??{}).map(([a,o])=>o!=null&&e.jsxs("div",{className:B.sensorRow,children:[e.jsx("span",{className:B.sensorKey,children:a}),e.jsx("span",{className:B.sensorVal,children:String(o)})]},a))})]})},Gp=({device:t,onControl:s,compact:a=!1,className:o,style:n,theme:c="light"})=>{const d=t.type,y=["light","dimmer","rgb_light","led_strip"].includes(d)?e.jsx(Qt,{device:t,onControl:s,compact:a,theme:c}):["thermostat","air_conditioner","heat_pump","floor_heating"].includes(d)?e.jsx(ts,{device:t,onControl:s,compact:a,theme:c}):["blind","shutter","curtain","awning","garage_door"].includes(d)?e.jsx(Ep,{device:t,onControl:s}):["lock","door"].includes(d)?e.jsx(Dp,{device:t,onControl:s}):["camera","doorbell"].includes(d)?e.jsx(Rp,{device:t}):d.endsWith("_sensor")||["motion_sensor","smoke_detector","water_leak_sensor","alarm"].includes(d)?e.jsx(Wp,{device:t}):e.jsx(Ap,{device:t,onControl:s});return e.jsxs("div",{className:`${B.deviceControl} ${c==="dark"?B.dark:""} ${a?B.compact:""} ${t.status==="offline"?B.offline:""} ${o??""}`,style:n,children:[y,t.status==="offline"&&e.jsx("div",{className:B.offlineBanner,children:"Offline"})]})},qp="_root_o9ptx_3",Fp="_dark_o9ptx_27",Vp="_listPanel_o9ptx_33",Hp="_listHeader_o9ptx_55",Up="_listTitle_o9ptx_75",Zp="_addBtn_o9ptx_89",Yp="_list_o9ptx_33",Kp="_listItem_o9ptx_117",Xp="_listItemActive_o9ptx_145",Jp="_listItemName_o9ptx_151",Qp="_listItemMeta_o9ptx_175",e_="_enableToggle_o9ptx_189",t_="_enableOn_o9ptx_207",s_="_detailPanel_o9ptx_213",n_="_detailHeader_o9ptx_225",o_="_nameInput_o9ptx_239",a_="_deleteBtn_o9ptx_267",c_="_section_o9ptx_293",r_="_sectionHeader_o9ptx_301",i_="_sectionTitle_o9ptx_315",l_="_sectionAddBtn_o9ptx_331",d_="_ruleBlock_o9ptx_357",u_="_ruleBlockHeader_o9ptx_377",p_="_typeSelect_o9ptx_391",__="_removeBtn_o9ptx_415",h_="_ruleFields_o9ptx_447",m_="_input_o9ptx_479",x_="_textarea_o9ptx_503",y_="_dayPicker_o9ptx_531",v_="_dayBtn_o9ptx_535",f_="_dayBtnActive_o9ptx_555",g_="_noSelection_o9ptx_561",b_="_emptyHint_o9ptx_561",A={root:qp,dark:Fp,listPanel:Vp,listHeader:Hp,listTitle:Up,addBtn:Zp,list:Yp,listItem:Kp,listItemActive:Xp,listItemName:Jp,listItemMeta:Qp,enableToggle:e_,enableOn:t_,detailPanel:s_,detailHeader:n_,nameInput:o_,deleteBtn:a_,section:c_,sectionHeader:r_,sectionTitle:i_,sectionAddBtn:l_,ruleBlock:d_,ruleBlockHeader:u_,typeSelect:p_,removeBtn:__,ruleFields:h_,input:m_,textarea:x_,dayPicker:y_,dayBtn:v_,dayBtnActive:f_,noSelection:g_,emptyHint:b_},$e=(t,s,a="")=>{const o=t[s];return typeof o=="string"?o:a},Ct=(t,s,a=0)=>{const o=t[s];return typeof o=="number"?o:a},j_=(t,s,a)=>{const o=t[s];return Array.isArray(o)?o:a},w_=(t,s)=>{const a=t[s];return a&&typeof a=="object"?a:{}},N_=({trigger:t,devices:s,onChange:a,onRemove:o})=>{const n=c=>a({...t,...c});return e.jsxs("div",{className:A.ruleBlock,children:[e.jsxs("div",{className:A.ruleBlockHeader,children:[e.jsxs("select",{className:A.typeSelect,value:t.type,onChange:c=>a({type:c.target.value}),children:[e.jsx("option",{value:"time",children:"⏰ Czas"}),e.jsx("option",{value:"sunrise",children:"🌅 Wschód słońca"}),e.jsx("option",{value:"sunset",children:"🌇 Zachód słońca"}),e.jsx("option",{value:"device_state",children:"📡 Stan urządzenia"}),e.jsx("option",{value:"sensor_threshold",children:"📊 Próg sensora"}),e.jsx("option",{value:"occupancy",children:"👥 Obecność"}),e.jsx("option",{value:"webhook",children:"🔗 Webhook"}),e.jsx("option",{value:"calendar",children:"📅 Kalendarz"})]}),e.jsx("button",{className:A.removeBtn,onClick:o,title:"Usuń",children:"✕"})]}),t.type==="time"&&e.jsxs("div",{className:A.ruleFields,children:[e.jsxs("label",{children:["Godzina",e.jsx("input",{type:"time",className:A.input,value:$e(t,"time","08:00"),onChange:c=>n({time:c.target.value})})]}),e.jsxs("label",{children:["Dni",e.jsx("div",{className:A.dayPicker,children:["Pon","Wt","Śr","Czw","Pt","Sob","Nd"].map((c,d)=>{const y=j_(t,"days",[0,1,2,3,4]),f=y.includes(d);return e.jsx("button",{className:`${A.dayBtn} ${f?A.dayBtnActive:""}`,onClick:()=>n({days:f?y.filter(g=>g!==d):[...y,d]}),children:c},d)})})]})]}),(t.type==="sunrise"||t.type==="sunset")&&e.jsx("div",{className:A.ruleFields,children:e.jsxs("label",{children:["Offset (minuty)",e.jsx("input",{type:"number",className:A.input,min:-120,max:120,step:5,value:Ct(t,"offsetMinutes",0),onChange:c=>n({offsetMinutes:+c.target.value})})]})}),(t.type==="device_state"||t.type==="sensor_threshold")&&e.jsxs("div",{className:A.ruleFields,children:[e.jsxs("label",{children:["Urządzenie",e.jsxs("select",{className:A.input,value:$e(t,"deviceId",""),onChange:c=>n({deviceId:c.target.value}),children:[e.jsx("option",{value:"",children:"— wybierz —"}),s.map(c=>e.jsx("option",{value:c.id,children:c.name},c.id))]})]}),t.type==="sensor_threshold"&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{children:["Atrybut",e.jsx("input",{className:A.input,value:$e(t,"attribute",""),onChange:c=>n({attribute:c.target.value})})]}),e.jsxs("label",{children:["Operator",e.jsxs("select",{className:A.input,value:$e(t,"operator","above"),onChange:c=>n({operator:c.target.value}),children:[e.jsx("option",{value:"above",children:"powyżej"}),e.jsx("option",{value:"below",children:"poniżej"}),e.jsx("option",{value:"equals",children:"równe"})]})]}),e.jsxs("label",{children:["Próg",e.jsx("input",{type:"number",className:A.input,value:Ct(t,"threshold",0),onChange:c=>n({threshold:+c.target.value})})]})]})]}),t.type==="webhook"&&e.jsx("div",{className:A.ruleFields,children:e.jsxs("label",{children:["Endpoint ID",e.jsx("input",{className:A.input,value:$e(t,"webhookId",""),onChange:c=>n({webhookId:c.target.value})})]})})]})},k_=({action:t,devices:s,onChange:a,onRemove:o})=>{const n=c=>a({...t,...c});return e.jsxs("div",{className:A.ruleBlock,children:[e.jsxs("div",{className:A.ruleBlockHeader,children:[e.jsxs("select",{className:A.typeSelect,value:t.type,onChange:c=>a({type:c.target.value}),children:[e.jsx("option",{value:"device_control",children:"📡 Urządzenie"}),e.jsx("option",{value:"scene_activate",children:"🎭 Aktywuj scenę"}),e.jsx("option",{value:"notification",children:"🔔 Powiadomienie"}),e.jsx("option",{value:"delay",children:"⏱ Opóźnienie"}),e.jsx("option",{value:"http_request",children:"🌐 HTTP Request"})]}),e.jsx("button",{className:A.removeBtn,onClick:o,title:"Usuń",children:"✕"})]}),t.type==="device_control"&&e.jsxs("div",{className:A.ruleFields,children:[e.jsxs("label",{children:["Urządzenie",e.jsxs("select",{className:A.input,value:$e(t,"deviceId",""),onChange:c=>n({deviceId:c.target.value}),children:[e.jsx("option",{value:"",children:"— wybierz —"}),s.map(c=>e.jsx("option",{value:c.id,children:c.name},c.id))]})]}),e.jsxs("label",{children:["Stan (JSON)",e.jsx("textarea",{className:A.textarea,rows:3,value:JSON.stringify(w_(t,"state"),null,2),onChange:c=>{try{n({state:JSON.parse(c.target.value)})}catch{}}})]})]}),t.type==="notification"&&e.jsxs("div",{className:A.ruleFields,children:[e.jsxs("label",{children:["Kanał",e.jsxs("select",{className:A.input,value:$e(t,"channel","push"),onChange:c=>n({channel:c.target.value}),children:[e.jsx("option",{value:"push",children:"Push"}),e.jsx("option",{value:"email",children:"Email"}),e.jsx("option",{value:"sms",children:"SMS"}),e.jsx("option",{value:"in_app",children:"In-app"}),e.jsx("option",{value:"teams",children:"Teams"}),e.jsx("option",{value:"slack",children:"Slack"})]})]}),e.jsxs("label",{children:["Wiadomość",e.jsx("input",{className:A.input,value:$e(t,"message",""),onChange:c=>n({message:c.target.value})})]})]}),t.type==="delay"&&e.jsx("div",{className:A.ruleFields,children:e.jsxs("label",{children:["Opóźnienie (sekundy)",e.jsx("input",{type:"number",className:A.input,min:1,value:Ct(t,"delaySeconds",60),onChange:c=>n({delaySeconds:+c.target.value})})]})}),t.type==="http_request"&&e.jsxs("div",{className:A.ruleFields,children:[e.jsxs("label",{children:["URL",e.jsx("input",{className:A.input,value:$e(t,"url",""),onChange:c=>n({url:c.target.value})})]}),e.jsxs("label",{children:["Metoda",e.jsxs("select",{className:A.input,value:$e(t,"method","POST"),onChange:c=>n({method:c.target.value}),children:[e.jsx("option",{children:"GET"}),e.jsx("option",{children:"POST"}),e.jsx("option",{children:"PUT"}),e.jsx("option",{children:"PATCH"})]})]})]})]})},C_=({automations:t,devices:s=[],onAutomationsChange:a,readOnly:o=!1,className:n,style:c,theme:d="light"})=>{var v;const[y,f]=r.useState(((v=t[0])==null?void 0:v.id)??null),g=t.find(h=>h.id===y)??null,u=r.useCallback(h=>{g&&(a==null||a(t.map(x=>x.id===g.id?{...x,...h}:x)))},[g,t,a]),N=r.useCallback(()=>{const h={id:`auto-${Date.now()}`,name:"Nowa automatyzacja",enabled:!0,triggers:[],conditions:[],actions:[]};a==null||a([...t,h]),f(h.id)},[t,a]),b=r.useCallback(h=>{var x;a==null||a(t.filter(j=>j.id!==h)),y===h&&f(((x=t.find(j=>j.id!==h))==null?void 0:x.id)??null)},[t,y,a]);return e.jsxs("div",{className:`${A.root} ${d==="dark"?A.dark:""} ${n??""}`,style:c,children:[e.jsxs("div",{className:A.listPanel,children:[e.jsxs("div",{className:A.listHeader,children:[e.jsx("span",{className:A.listTitle,children:"Automatyzacje"}),!o&&e.jsx("button",{className:A.addBtn,onClick:N,children:"+ Dodaj"})]}),e.jsxs("div",{className:A.list,children:[t.map(h=>e.jsxs("div",{className:`${A.listItem} ${y===h.id?A.listItemActive:""}`,onClick:()=>f(h.id),children:[e.jsx("div",{className:A.listItemName,children:h.name}),e.jsxs("div",{className:A.listItemMeta,children:[h.triggers.length," wyzw · ",h.actions.length," akcji"]}),e.jsx("button",{className:`${A.enableToggle} ${h.enabled?A.enableOn:""}`,onClick:x=>{x.stopPropagation(),u({enabled:!h.enabled})},title:h.enabled?"Wyłącz":"Włącz",children:h.enabled?"●":"○"})]},h.id)),t.length===0&&e.jsx("div",{className:A.emptyHint,children:"Brak automatyzacji"})]})]}),e.jsx("div",{className:A.detailPanel,children:g?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:A.detailHeader,children:[e.jsx("input",{className:A.nameInput,value:g.name,onChange:h=>u({name:h.target.value}),readOnly:o}),!o&&e.jsx("button",{className:A.deleteBtn,onClick:()=>b(g.id),children:"Usuń"})]}),e.jsxs("section",{className:A.section,children:[e.jsxs("div",{className:A.sectionHeader,children:[e.jsx("span",{className:A.sectionTitle,children:"Wyzwalacze"}),!o&&e.jsx("button",{className:A.sectionAddBtn,onClick:()=>u({triggers:[...g.triggers,{type:"time"}]}),children:"+ Dodaj"})]}),g.triggers.map((h,x)=>e.jsx(N_,{trigger:h,devices:s,onChange:j=>u({triggers:g.triggers.map((i,L)=>L===x?j:i)}),onRemove:()=>u({triggers:g.triggers.filter((j,i)=>i!==x)})},x)),g.triggers.length===0&&e.jsx("div",{className:A.emptyHint,children:"Brak wyzwalaczy"})]}),e.jsxs("section",{className:A.section,children:[e.jsxs("div",{className:A.sectionHeader,children:[e.jsx("span",{className:A.sectionTitle,children:"Akcje"}),!o&&e.jsx("button",{className:A.sectionAddBtn,onClick:()=>u({actions:[...g.actions,{type:"device_control"}]}),children:"+ Dodaj"})]}),g.actions.map((h,x)=>e.jsx(k_,{action:h,devices:s,onChange:j=>u({actions:g.actions.map((i,L)=>L===x?j:i)}),onRemove:()=>u({actions:g.actions.filter((j,i)=>i!==x)})},x)),g.actions.length===0&&e.jsx("div",{className:A.emptyHint,children:"Brak akcji"})]})]}):e.jsx("div",{className:A.noSelection,children:"Wybierz automatyzację lub dodaj nową"})})]})},I_="_root_1sm37_3",S_="_dark_1sm37_27",L_="_gridPanel_1sm37_33",z_="_gridHeader_1sm37_55",$_="_gridTitle_1sm37_75",B_="_addBtn_1sm37_81",T_="_sceneGrid_1sm37_105",P_="_sceneCard_1sm37_123",M_="_sceneCardActive_1sm37_147",O_="_sceneCardSelected_1sm37_149",A_="_sceneCardIcon_1sm37_153",E_="_sceneCardName_1sm37_157",D_="_sceneCardDevices_1sm37_175",R_="_activeBadge_1sm37_193",W_="_activateBtn_1sm37_197",G_="_emptyGrid_1sm37_237",q_="_detailPanel_1sm37_255",F_="_metaRow_1sm37_273",V_="_iconPicker_1sm37_285",H_="_currentIcon_1sm37_289",U_="_iconGrid_1sm37_307",Z_="_iconOpt_1sm37_323",Y_="_iconOptActive_1sm37_345",K_="_metaFields_1sm37_349",X_="_nameInput_1sm37_353",J_="_descInput_1sm37_381",Q_="_colorPicker_1sm37_411",eh="_colorOpt_1sm37_421",th="_colorOptActive_1sm37_437",sh="_targetsSection_1sm37_443",nh="_targetsSectionHeader_1sm37_447",oh="_addTargetBtn_1sm37_469",ah="_targetRow_1sm37_493",ch="_targetSelect_1sm37_517",rh="_targetState_1sm37_541",ih="_targetField_1sm37_555",lh="_tempInput_1sm37_575",dh="_removeTargetBtn_1sm37_593",uh="_noTargets_1sm37_627",ph="_detailActions_1sm37_647",_h="_activateFullBtn_1sm37_661",hh="_deleteBtn_1sm37_689",Y={root:I_,dark:S_,gridPanel:L_,gridHeader:z_,gridTitle:$_,addBtn:B_,sceneGrid:T_,sceneCard:P_,sceneCardActive:M_,sceneCardSelected:O_,sceneCardIcon:A_,sceneCardName:E_,sceneCardDevices:D_,activeBadge:R_,activateBtn:W_,emptyGrid:G_,detailPanel:q_,metaRow:F_,iconPicker:V_,currentIcon:H_,iconGrid:U_,iconOpt:Z_,iconOptActive:Y_,metaFields:K_,nameInput:X_,descInput:J_,colorPicker:Q_,colorOpt:eh,colorOptActive:th,targetsSection:sh,targetsSectionHeader:nh,addTargetBtn:oh,targetRow:ah,targetSelect:ch,targetState:rh,targetField:ih,tempInput:lh,removeTargetBtn:dh,noTargets:uh,detailActions:ph,activateFullBtn:_h,deleteBtn:hh},Je=t=>t&&typeof t=="object"?t:{},mh=(t,s,a=!1)=>{const o=Je(t)[s];return typeof o=="boolean"?o:a},Nt=(t,s,a=0)=>{const o=Je(t)[s];return typeof o=="number"?o:a},xh=["🎭","🌙","🌅","🎬","🎮","💼","🍽","☕","🏃","🛁","🎵","🌿","🔆","❄","🔒","🏠"],yh=["var(--nice-primary-bg, #e0f2fe)","var(--nice-accent-bg, #fce7f3)","var(--nice-success-bg, #dcfce7)","var(--nice-warning-bg, #fef9c3)","var(--nice-accent-bg, #ede9fe)","var(--nice-danger-bg, #fee2e2)","var(--nice-success-bg, #f0fdf4)","#fff7ed"],vh=({target:t,devices:s,onChange:a,onRemove:o})=>{const n=s.find(c=>c.id===t.deviceId);return e.jsxs("div",{className:Y.targetRow,children:[e.jsxs("select",{className:Y.targetSelect,value:t.deviceId,onChange:c=>a({...t,deviceId:c.target.value}),children:[e.jsx("option",{value:"",children:"— urządzenie —"}),s.map(c=>e.jsx("option",{value:c.id,children:c.name},c.id))]}),n&&e.jsxs("div",{className:Y.targetState,children:[e.jsxs("label",{className:Y.targetField,children:[e.jsx("span",{children:"Wł/Wył"}),e.jsx("input",{type:"checkbox",checked:mh(t.state,"on",!1),onChange:c=>a({...t,state:{...Je(t.state),on:c.target.checked}})})]}),(n.type==="dimmer"||n.type==="light"||n.type==="rgb_light"||n.type==="led_strip")&&e.jsxs("label",{className:Y.targetField,children:[e.jsx("span",{children:"Jasność"}),e.jsx("input",{type:"range",min:0,max:100,value:Nt(t.state,"brightness",100),onChange:c=>a({...t,state:{...Je(t.state),brightness:+c.target.value}})}),e.jsxs("span",{children:[Nt(t.state,"brightness",100),"%"]})]}),(n.type==="thermostat"||n.type==="air_conditioner")&&e.jsxs("label",{className:Y.targetField,children:[e.jsx("span",{children:"Temp."}),e.jsx("input",{type:"number",className:Y.tempInput,min:10,max:30,step:.5,value:Nt(t.state,"targetTemperature",20),onChange:c=>a({...t,state:{...Je(t.state),targetTemperature:+c.target.value}})}),e.jsx("span",{children:"°C"})]})]}),e.jsx("button",{className:Y.removeTargetBtn,onClick:o,title:"Usuń",children:"✕"})]})},fh=({scenes:t,devices:s=[],activeSceneIds:a=[],onScenesChange:o,onActivate:n,readOnly:c=!1,className:d,style:y,theme:f="light"})=>{var j;const[g,u]=r.useState(((j=t[0])==null?void 0:j.id)??null),N=t.find(i=>i.id===g)??null,b=r.useCallback(i=>{N&&(o==null||o(t.map(L=>L.id===N.id?{...L,...i}:L)))},[N,t,o]),v=r.useCallback(()=>{const i={id:`scene-${Date.now()}`,name:"Nowa scena",deviceTargets:[],icon:"🎭",color:"var(--nice-primary-bg, #e0f2fe)"};o==null||o([...t,i]),u(i.id)},[t,o]),h=r.useCallback(i=>{var L;o==null||o(t.filter(p=>p.id!==i)),g===i&&u(((L=t.find(p=>p.id!==i))==null?void 0:L.id)??null)},[t,g,o]),x=()=>{if(!N)return;const i={deviceId:"",state:{on:!0},transitionMs:1e3};b({deviceTargets:[...N.deviceTargets,i]})};return e.jsxs("div",{className:`${Y.root} ${f==="dark"?Y.dark:""} ${d??""}`,style:y,children:[e.jsxs("div",{className:Y.gridPanel,children:[e.jsxs("div",{className:Y.gridHeader,children:[e.jsx("span",{className:Y.gridTitle,children:"Sceny"}),!c&&e.jsx("button",{className:Y.addBtn,onClick:v,children:"+ Nowa"})]}),e.jsxs("div",{className:Y.sceneGrid,children:[t.map(i=>{const L=a.includes(i.id),p=g===i.id;return e.jsxs("div",{className:`${Y.sceneCard} ${L?Y.sceneCardActive:""} ${p?Y.sceneCardSelected:""}`,style:{background:i.color??"var(--nice-bg-secondary, #f8fafc)"},onClick:()=>u(i.id),children:[e.jsx("div",{className:Y.sceneCardIcon,children:i.icon??"🎭"}),e.jsx("div",{className:Y.sceneCardName,children:i.name}),e.jsxs("div",{className:Y.sceneCardDevices,children:[i.deviceTargets.length," urządzeń",L&&e.jsx("span",{className:Y.activeBadge,children:"●"})]}),e.jsx("button",{className:Y.activateBtn,onClick:C=>{C.stopPropagation(),n==null||n(i.id)},children:"▶"})]},i.id)}),t.length===0&&e.jsx("div",{className:Y.emptyGrid,children:"Brak scen. Dodaj pierwszą!"})]})]}),N&&e.jsxs("div",{className:Y.detailPanel,children:[e.jsxs("div",{className:Y.metaRow,children:[e.jsxs("div",{className:Y.iconPicker,children:[e.jsx("span",{className:Y.currentIcon,children:N.icon??"🎭"}),e.jsx("div",{className:Y.iconGrid,children:xh.map(i=>e.jsx("button",{className:`${Y.iconOpt} ${N.icon===i?Y.iconOptActive:""}`,onClick:()=>b({icon:i}),children:i},i))})]}),e.jsxs("div",{className:Y.metaFields,children:[e.jsx("input",{className:Y.nameInput,value:N.name,readOnly:c,onChange:i=>b({name:i.target.value}),placeholder:"Nazwa sceny"}),e.jsx("textarea",{className:Y.descInput,value:N.description??"",readOnly:c,onChange:i=>b({description:i.target.value}),placeholder:"Opis (opcjonalny)",rows:2})]})]}),!c&&e.jsx("div",{className:Y.colorPicker,children:yh.map(i=>e.jsx("button",{className:`${Y.colorOpt} ${N.color===i?Y.colorOptActive:""}`,style:{background:i},onClick:()=>b({color:i})},i))}),e.jsxs("div",{className:Y.targetsSection,children:[e.jsxs("div",{className:Y.targetsSectionHeader,children:[e.jsx("span",{children:"Urządzenia w scenie"}),!c&&e.jsx("button",{className:Y.addTargetBtn,onClick:x,children:"+ Dodaj"})]}),N.deviceTargets.map((i,L)=>e.jsx(vh,{target:i,devices:s,onChange:p=>b({deviceTargets:N.deviceTargets.map((C,w)=>w===L?p:C)}),onRemove:()=>b({deviceTargets:N.deviceTargets.filter((p,C)=>C!==L)})},L)),N.deviceTargets.length===0&&e.jsx("div",{className:Y.noTargets,children:"Dodaj urządzenia, które powinna kontrolować ta scena."})]}),e.jsxs("div",{className:Y.detailActions,children:[e.jsx("button",{className:Y.activateFullBtn,onClick:()=>n==null?void 0:n(N.id),children:"▶ Aktywuj scenę"}),!c&&e.jsx("button",{className:Y.deleteBtn,onClick:()=>h(N.id),children:"Usuń"})]})]})]})};exports.LayerPanel=Ut;exports.Minimap=Zt;exports.NiceAutomationEditor=C_;exports.NiceBuildingDashboard=wu;exports.NiceDeviceControl=Gp;exports.NiceFloorPlanEditor=Js;exports.NiceLightControl=Qt;exports.NiceSceneEditor=fh;exports.NiceSpatialEditor=Hi;exports.NiceSpatialViewer=Id;exports.NiceThermostatControl=ts;exports.NiceZoneCard=Jt;exports.ObjectLibrary=Yt;exports.PropertiesPanel=Kt;exports.useMeasurement=zd;exports.useSnapToGrid=Ld;exports.useSpatialEditor=Sd;
5
+ `;return C.forEach((u,w)=>{if(u.type==="wall"&&u.bounds)b.push(e.jsx("rect",{x:u.bounds.x,y:u.bounds.y,width:u.bounds.width,height:u.bounds.height,fill:"var(--nice-text-secondary, #475569)",stroke:"var(--nice-text, #334155)",strokeWidth:"1"},`wall-${w}`));else if(u.type==="zone"&&u.boundary){const i=u.boundary.map((h,j)=>`${j===0?"M":"L"} ${h.x} ${h.y}`).join(" ")+" Z";b.push(e.jsx("path",{d:i,fill:"var(--nice-primary-tint-20, rgba(59, 130, 246, 0.2))",stroke:"var(--nice-primary, #3b82f6)",strokeWidth:"1"},`zone-${w}`))}else if(u.type==="room"&&u.boundary){const i=u.boundary.map((h,j)=>`${j===0?"M":"L"} ${h.x} ${h.y}`).join(" ")+" Z";b.push(e.jsx("path",{d:i,fill:"var(--nice-success-tint-15, rgba(34, 197, 94, 0.15))",stroke:"var(--nice-success, #22c55e)",strokeWidth:"1"},`room-${w}`))}else u.bounds&&b.push(e.jsx("rect",{x:u.bounds.x,y:u.bounds.y,width:u.bounds.width,height:u.bounds.height,fill:"var(--nice-accent-tint-30, rgba(99, 102, 241, 0.3))",stroke:"var(--nice-info, #6366f1)",strokeWidth:"0.5",rx:"2"},`obj-${w}`))}),e.jsxs("svg",{viewBox:`${d.x} ${d.y} ${d.width} ${d.height}`,className:G.previewSvg,preserveAspectRatio:"xMidYMid meet",children:[e.jsx("defs",{dangerouslySetInnerHTML:{__html:N}}),e.jsx("rect",{x:d.x,y:d.y,width:d.width,height:d.height,fill:"url(#grid)"}),b]})},[n,o]),l=r.useCallback(d=>{d.key==="Escape"&&a()},[a]),y=r.useCallback(d=>{d.target===d.currentTarget&&a()},[a]),v=t.errors.some(d=>d.fatal),k=t.errors.filter(d=>!d.fatal);return e.jsx("div",{className:G.overlay,onClick:y,onKeyDown:l,tabIndex:-1,role:"dialog","aria-modal":"true","aria-labelledby":"import-preview-title",children:e.jsxs("div",{className:G.dialog,children:[e.jsxs("div",{className:G.header,children:[e.jsx("h2",{id:"import-preview-title",className:G.title,children:"Import Preview"}),e.jsx("button",{className:G.closeButton,onClick:a,title:"Close","aria-label":"Close dialog",children:e.jsx(Bn,{})})]}),e.jsxs("div",{className:G.content,children:[e.jsx("div",{className:G.preview,children:c||e.jsx("div",{className:G.previewCanvas,children:"No preview available"})}),e.jsxs("div",{className:G.info,children:[e.jsxs("div",{className:G.section,children:[e.jsxs("h3",{className:G.sectionTitle,children:[e.jsx($n,{})," Import Statistics"]}),e.jsxs("div",{className:G.statGrid,children:[e.jsxs("div",{className:G.stat,children:[e.jsx("div",{className:G.statLabel,children:"Walls"}),e.jsx("div",{className:G.statValue,children:t.stats.wallsImported})]}),e.jsxs("div",{className:G.stat,children:[e.jsx("div",{className:G.statLabel,children:"Zones"}),e.jsx("div",{className:G.statValue,children:t.stats.zonesImported})]}),e.jsxs("div",{className:G.stat,children:[e.jsx("div",{className:G.statLabel,children:"Objects"}),e.jsx("div",{className:G.statValue,children:t.stats.objectsImported})]}),e.jsxs("div",{className:G.stat,children:[e.jsx("div",{className:G.statLabel,children:"Skipped"}),e.jsx("div",{className:G.statValue,children:t.stats.entitiesSkipped})]})]})]}),n&&n.layers.length>0&&e.jsxs("div",{className:G.section,children:[e.jsxs("h3",{className:G.sectionTitle,children:[e.jsx(Pt,{})," Layers (",n.layers.length,")"]}),e.jsxs("ul",{className:G.layersList,children:[n.layers.slice(0,6).map((d,C)=>{var b;return e.jsxs("li",{className:G.layer,children:[e.jsx("span",{className:G.layerIcon,children:e.jsx(Pt,{})}),e.jsx("span",{className:G.layerName,children:d.name}),e.jsx("span",{className:G.layerCount,children:((b=d.objects)==null?void 0:b.length)||0})]},d.id||C)}),n.layers.length>6&&e.jsx("li",{className:G.layer,children:e.jsxs("span",{className:G.layerName,children:["+",n.layers.length-6," more..."]})})]})]}),t.warnings.length>0&&e.jsxs("div",{className:G.section,children:[e.jsxs("h3",{className:G.sectionTitle,children:[e.jsx(Bt,{})," Warnings (",t.warnings.length,")"]}),e.jsxs("ul",{className:G.warningsList,children:[t.warnings.slice(0,5).map((d,C)=>e.jsxs("li",{className:G.warning,children:[e.jsx("span",{className:G.warningIcon,children:e.jsx(Bt,{})}),e.jsx("span",{children:d.message})]},C)),t.warnings.length>5&&e.jsxs("li",{className:G.warning,children:["+",t.warnings.length-5," more warnings..."]})]})]}),k.length>0&&e.jsxs("div",{className:G.section,children:[e.jsxs("h3",{className:G.sectionTitle,children:[e.jsx($t,{})," Errors (",k.length,")"]}),e.jsx("ul",{className:G.warningsList,children:k.slice(0,5).map((d,C)=>e.jsxs("li",{className:G.error,children:[e.jsx("span",{className:G.errorIcon,children:e.jsx($t,{})}),e.jsx("span",{children:d.message})]},C))})]}),t.warnings.length===0&&k.length===0&&e.jsx("div",{className:G.section,children:e.jsx("p",{className:G.noWarnings,children:"✓ No warnings or errors found"})})]})]}),e.jsxs("div",{className:G.footer,children:[e.jsx("button",{className:G.cancelButton,onClick:a,children:"Cancel"}),e.jsx("button",{className:G.confirmButton,onClick:s,disabled:v,children:v?"Cannot Import (Fatal Errors)":"Confirm Import"})]})]})})}const Mn="_overlay_1okdy_9",On="_dialog_1okdy_55",An="_header_1okdy_103",En="_title_1okdy_119",Dn="_closeButton_1okdy_133",Rn="_content_1okdy_163",Gn="_description_1okdy_175",Wn="_mappingTable_1okdy_187",qn="_sourceLayer_1okdy_237",Fn="_layerIcon_1okdy_249",Vn="_layerName_1okdy_257",Hn="_objectCount_1okdy_269",Un="_targetSelect_1okdy_281",Zn="_skipOption_1okdy_323",Yn="_arrowIcon_1okdy_333",Kn="_presets_1okdy_343",Xn="_presetButton_1okdy_357",Jn="_footer_1okdy_389",Qn="_footerLeft_1okdy_409",eo="_checkbox_1okdy_421",to="_checkboxLabel_1okdy_433",so="_footerRight_1okdy_443",no="_cancelButton_1okdy_453",oo="_confirmButton_1okdy_485",te={overlay:Mn,dialog:On,header:An,title:En,closeButton:Dn,content:Rn,description:Gn,mappingTable:Wn,sourceLayer:qn,layerIcon:Fn,layerName:Vn,objectCount:Hn,targetSelect:Un,skipOption:Zn,arrowIcon:Yn,presets:Kn,presetButton:Xn,footer:Jn,footerLeft:Qn,checkbox:eo,checkboxLabel:to,footerRight:so,cancelButton:no,confirmButton:oo},Mt=()=>e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M15 5L5 15M5 5L15 15",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),ao=()=>e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.2",children:e.jsx("path",{d:"M7 1L1 4l6 3 6-3-6-3zM1 7l6 3 6-3M1 10l6 3 6-3"})}),co=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{d:"M4 8h8M9 5l3 3-3 3",strokeLinecap:"round",strokeLinejoin:"round"})}),Ot={"floor-plan":"Plan piętra",walls:"Ściany",rooms:"Pomieszczenia",zones:"Strefy","doors-windows":"Drzwi i okna",furniture:"Meble",devices:"Urządzenia",network:"Sieć",infrastructure:"Infrastruktura",electrical:"Elektryka",plumbing:"Hydraulika",hvac:"HVAC",annotations:"Adnotacje",dimensions:"Wymiary",grid:"Siatka",background:"Tło","game-objects":"Obiekty gry",collision:"Kolizje",custom:"Własne"};function ro(t){if(!t.document)return[];const s=[];for(const a of t.document.floors)for(const o of a.layers)s.push({id:o.id,name:o.name,type:o.type,objectCount:o.objects.length});return s}function io(t){if(!t)return[];const s=[];for(const a of t.floors)for(const o of a.layers)s.find(n=>n.id===o.id)||s.push(o);return s}function At(t,s){const a=new Map;for(const o of t){const n=s.find(y=>y.type===o.type);if(n){a.set(o.id,n.id);continue}const c=o.name.toLowerCase(),l=s.find(y=>y.name.toLowerCase()===c);if(l){a.set(o.id,l.id);continue}a.set(o.id,o.id)}return a}const lo=({importResult:t,existingDocument:s,onConfirm:a,onCancel:o})=>{const n=r.useMemo(()=>ro(t),[t]),c=r.useMemo(()=>io(s),[s]),[l,y]=r.useState(()=>At(n,c)),[v,k]=r.useState(!0),d=r.useCallback((u,w)=>{y(T=>{const i=new Map(T);return i.set(u,w),i})},[]),C=r.useCallback(u=>{const w=new Map;switch(u){case"auto":y(At(n,c));return;case"skip-all":for(const T of n)w.set(T.id,"skip");break;case"preserve":for(const T of n)w.set(T.id,T.id);break}y(w)},[n,c]),b=r.useCallback(()=>{a(l,v)},[l,v,a]),p=r.useCallback(u=>{u.key==="Escape"?o():u.key==="Enter"&&(u.ctrlKey||u.metaKey)&&b()},[o,b]),N=r.useCallback(u=>{u.target===u.currentTarget&&o()},[o]);return n.length===0?e.jsx("div",{className:te.overlay,onClick:N,onKeyDown:p,tabIndex:-1,children:e.jsxs("div",{className:te.dialog,children:[e.jsxs("div",{className:te.header,children:[e.jsx("h2",{className:te.title,children:"Mapowanie warstw"}),e.jsx("button",{className:te.closeButton,onClick:o,children:e.jsx(Mt,{})})]}),e.jsx("div",{className:te.content,children:e.jsx("p",{className:te.description,children:"Importowany plik nie zawiera żadnych warstw."})}),e.jsxs("div",{className:te.footer,children:[e.jsx("div",{className:te.footerLeft}),e.jsx("div",{className:te.footerRight,children:e.jsx("button",{className:te.cancelButton,onClick:o,children:"Zamknij"})})]})]})}):e.jsx("div",{className:te.overlay,onClick:N,onKeyDown:p,tabIndex:-1,children:e.jsxs("div",{className:te.dialog,children:[e.jsxs("div",{className:te.header,children:[e.jsx("h2",{className:te.title,children:"Mapowanie warstw"}),e.jsx("button",{className:te.closeButton,onClick:o,children:e.jsx(Mt,{})})]}),e.jsxs("div",{className:te.content,children:[e.jsx("p",{className:te.description,children:"Wybierz jak warstwy z importowanego pliku mają być przypisane do warstw w edytorze."}),e.jsxs("table",{className:te.mappingTable,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Warstwa źródłowa"}),e.jsx("th",{}),e.jsx("th",{children:"Warstwa docelowa"})]})}),e.jsx("tbody",{children:n.map(u=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsxs("div",{className:te.sourceLayer,children:[e.jsx("span",{className:te.layerIcon,children:e.jsx(ao,{})}),e.jsx("span",{className:te.layerName,children:u.name}),e.jsxs("span",{className:te.objectCount,children:["(",u.objectCount," ",u.objectCount===1?"obiekt":"obiektów",")"]})]})}),e.jsx("td",{className:te.arrowIcon,children:e.jsx(co,{})}),e.jsx("td",{children:e.jsxs("select",{className:te.targetSelect,value:l.get(u.id)||u.id,onChange:w=>d(u.id,w.target.value),children:[e.jsx("option",{value:"skip",className:te.skipOption,children:"— Pomiń tę warstwę —"}),e.jsxs("option",{value:u.id,children:["Utwórz: ",u.name," (",Ot[u.type],")"]}),c.map(w=>e.jsxs("option",{value:w.id,children:[w.name," (",Ot[w.type],")"]},w.id))]})})]},u.id))})]}),e.jsxs("div",{className:te.presets,children:[e.jsx("button",{className:te.presetButton,onClick:()=>C("auto"),children:"Auto-mapowanie"}),e.jsx("button",{className:te.presetButton,onClick:()=>C("preserve"),children:"Zachowaj wszystkie"}),e.jsx("button",{className:te.presetButton,onClick:()=>C("skip-all"),children:"Pomiń wszystkie"})]})]}),e.jsxs("div",{className:te.footer,children:[e.jsxs("div",{className:te.footerLeft,children:[e.jsx("input",{type:"checkbox",id:"createMissing",className:te.checkbox,checked:v,onChange:u=>k(u.target.checked)}),e.jsx("label",{htmlFor:"createMissing",className:te.checkboxLabel,children:"Utwórz brakujące warstwy"})]}),e.jsxs("div",{className:te.footerRight,children:[e.jsx("button",{className:te.cancelButton,onClick:o,children:"Anuluj"}),e.jsx("button",{className:te.confirmButton,onClick:b,children:"Zastosuj mapowanie"})]})]})]})})},uo="_root_4ino1_9",po="_header_4ino1_21",_o="_title_4ino1_31",ho="_layerList_4ino1_45",mo="_layerItem_4ino1_55",xo="_hidden_4ino1_83",yo="_locked_4ino1_91",vo="_visibilityBtn_4ino1_99",fo="_lockBtn_4ino1_101",go="_layerIcon_4ino1_139",bo="_layerName_4ino1_147",jo="_opacitySlider_4ino1_157",Ce={root:uo,header:po,title:_o,layerList:ho,layerItem:mo,hidden:xo,locked:yo,visibilityBtn:vo,lockBtn:fo,layerIcon:go,layerName:bo,opacitySlider:jo},wo={"floor-plan":{icon:"🏠",label:"Floor Plan"},zones:{icon:"⬡",label:"Zones"},devices:{icon:"📡",label:"Devices"},furniture:{icon:"🛋️",label:"Furniture"},network:{icon:"🌐",label:"Network"},infrastructure:{icon:"⚙️",label:"Infrastructure"},annotations:{icon:"📝",label:"Annotations"},dimensions:{icon:"↔",label:"Dimensions"},grid:{icon:"⊞",label:"Grid"},background:{icon:"🖼️",label:"Background"},"game-objects":{icon:"🎮",label:"Game Objects"},collision:{icon:"⬜",label:"Collision"}},Yt=({layers:t,onVisibilityToggle:s,onLockToggle:a,onOpacityChange:o,className:n})=>{const c=[...t].sort((l,y)=>y.zIndex-l.zIndex);return e.jsxs("div",{className:`${Ce.root} ${n??""}`,children:[e.jsx("div",{className:Ce.header,children:e.jsx("h3",{className:Ce.title,children:"Layers"})}),e.jsx("div",{className:Ce.layerList,children:c.map(l=>{const y=wo[l.type]||{icon:"📦",label:l.type};return e.jsxs("div",{className:`${Ce.layerItem} ${l.visible?"":Ce.hidden} ${l.locked?Ce.locked:""}`,children:[e.jsx("button",{className:Ce.visibilityBtn,onClick:()=>s(l.type),title:l.visible?"Hide layer":"Show layer",children:l.visible?"👁":"👁‍🗨"}),e.jsx("button",{className:Ce.lockBtn,onClick:()=>a(l.type),title:l.locked?"Unlock layer":"Lock layer",children:l.locked?"🔒":"🔓"}),e.jsx("span",{className:Ce.layerIcon,children:y.icon}),e.jsx("span",{className:Ce.layerName,children:y.label}),e.jsx("input",{type:"range",min:"0",max:"1",step:"0.1",value:l.opacity,onChange:v=>o(l.type,parseFloat(v.target.value)),className:Ce.opacitySlider,title:`Opacity: ${Math.round(l.opacity*100)}%`})]},l.type)})})]})},No="_root_1lufq_9",ko="_svg_1lufq_31",Co="_viewportRect_1lufq_41",Io="_zoomIndicator_1lufq_49",at={root:No,svg:ko,viewportRect:Co,zoomIndicator:Io},Kt=({document:t,activeFloorId:s,viewport:a,onViewportChange:o,size:n=150,className:c})=>{var h,j;const l=r.useRef(null),y=r.useMemo(()=>t.floors.find(f=>f.id===s)??t.floors[0]??null,[t,s]);if(!y)return null;const v=((h=y.dimensions)==null?void 0:h.width)??1e3,k=((j=y.dimensions)==null?void 0:j.height)??800,d=Math.min(n/v,n/k)*.9,C=v*d,b=k*d,p=n/a.zoom*d,N=n/a.zoom*d,u=-a.pan.x/a.zoom*d,w=-a.pan.y/a.zoom*d,T=r.useCallback(f=>{var me;const g=(me=l.current)==null?void 0:me.getBoundingClientRect();if(!g)return;const m=(f.clientX-g.left-(n-C)/2)/d,A=(f.clientY-g.top-(n-b)/2)/d,H=-(m-n/a.zoom/2)*a.zoom,W=-(A-n/a.zoom/2)*a.zoom;o({pan:{x:H,y:W}})},[d,n,C,b,a.zoom,o]),i=r.useMemo(()=>{const f=y.layers.find(g=>g.name==="zones");return f?f.objects.map(g=>{const m=g;if(!m.polygon||m.polygon.length<3)return null;const A=m.polygon.map((H,W)=>`${W===0?"M":"L"}${H.x*d},${H.y*d}`).join(" ")+" Z";return e.jsx("path",{d:A,fill:m.color??"var(--nice-primary-bg, #dbeafe)",fillOpacity:.6,stroke:"var(--nice-text-muted, #94a3b8)",strokeWidth:.5},m.id)}):null},[y,d]);return e.jsxs("div",{className:`${at.root} ${c??""}`,children:[e.jsxs("svg",{ref:l,width:n,height:n,viewBox:`0 0 ${n} ${n}`,className:at.svg,onClick:T,children:[e.jsx("rect",{x:(n-C)/2,y:(n-b)/2,width:C,height:b,fill:"var(--nice-text, #1e293b)",stroke:"var(--nice-text-secondary, #475569)",strokeWidth:1}),e.jsx("g",{transform:`translate(${(n-C)/2}, ${(n-b)/2})`,children:i}),e.jsx("rect",{x:(n-C)/2+u,y:(n-b)/2+w,width:Math.min(p,C),height:Math.min(N,b),fill:"var(--nice-primary-tint-20, rgba(59, 130, 246, 0.2))",stroke:"var(--nice-primary, #3b82f6)",strokeWidth:1.5,rx:2,className:at.viewportRect})]}),e.jsxs("div",{className:at.zoomIndicator,children:[Math.round(a.zoom*100),"%"]})]})},So="_panel_vacy7_9",Lo="_header_vacy7_27",zo="_title_vacy7_45",To="_closeButton_vacy7_59",Bo="_content_vacy7_85",$o="_endpointSection_vacy7_99",Po="_endpointLabel_vacy7_107",Mo="_endpointSelect_vacy7_123",Oo="_optionsSection_vacy7_157",Ao="_metricButton_vacy7_169",Eo="_metricButtonActive_vacy7_205",Do="_analyzeButton_vacy7_219",Ro="_resultsSection_vacy7_267",Go="_resultsTitle_vacy7_277",Wo="_noResults_vacy7_293",qo="_pathCard_vacy7_309",Fo="_pathCardSelected_vacy7_333",Vo="_pathCardHeader_vacy7_343",Ho="_pathCardTitle_vacy7_361",Uo="_pathBadge_vacy7_373",Zo="_badgePrimary_vacy7_389",Yo="_badgeAlternate_vacy7_399",Ko="_pathName_vacy7_409",Xo="_pathStatus_vacy7_421",Jo="_statusDot_vacy7_435",Qo="_statusActive_vacy7_447",ea="_statusDegraded_vacy7_449",ta="_statusInactive_vacy7_451",sa="_statusError_vacy7_453",na="_pathStats_vacy7_459",oa="_statItem_vacy7_473",aa="_statValue_vacy7_481",ca="_statLabel_vacy7_493",ra="_pathVisualization_vacy7_507",ia="_pathDiagram_vacy7_519",la="_pathNode_vacy7_535",da="_pathNodeStart_vacy7_567",ua="_pathNodeEnd_vacy7_569",pa="_pathLink_vacy7_579",_a="_pathLinkLine_vacy7_591",ha="_showOnMapButton_vacy7_605",ma="_loading_vacy7_641",xa="_spinner_vacy7_655",ya="_spin_vacy7_655",R={panel:So,header:Lo,title:zo,closeButton:To,content:Bo,endpointSection:$o,endpointLabel:Po,endpointSelect:Mo,optionsSection:Oo,metricButton:Ao,metricButtonActive:Eo,analyzeButton:Do,resultsSection:Ro,resultsTitle:Go,noResults:Wo,pathCard:qo,pathCardSelected:Fo,pathCardHeader:Vo,pathCardTitle:Ho,pathBadge:Uo,badgePrimary:Zo,badgeAlternate:Yo,pathName:Ko,pathStatus:Xo,statusDot:Jo,statusActive:Qo,statusDegraded:ea,statusInactive:ta,statusError:sa,pathStats:na,statItem:oa,statValue:aa,statLabel:ca,pathVisualization:ra,pathDiagram:ia,pathNode:la,pathNodeStart:da,pathNodeEnd:ua,pathLink:pa,pathLinkLine:_a,showOnMapButton:ha,loading:ma,spinner:xa,spin:ya},va=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:e.jsx("path",{d:"M12 4L4 12M4 4L12 12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),fa=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{d:"M4 8h8M9 5l3 3-3 3",strokeLinecap:"round",strokeLinejoin:"round"})});function ga(t){switch(t){case"active":return"Aktywna";case"degraded":return"Degradacja";case"inactive":return"Nieaktywna";case"error":return"Błąd";default:return"Nieznany"}}function ba(t){return t<1?"<1ms":t<1e3?`${Math.round(t)}ms`:`${(t/1e3).toFixed(1)}s`}function ja(t){return t>=1e3?`${(t/1e3).toFixed(1)} Gbps`:`${Math.round(t)} Mbps`}const wa=({document:t,connections:s,onHighlightPath:a,onClose:o})=>{const[n,c]=r.useState(""),[l,y]=r.useState(""),[v,k]=r.useState("latency"),[d,C]=r.useState([]),[b,p]=r.useState(null),[N,u]=r.useState(!1),w=r.useMemo(()=>{const f=[];for(const g of t.floors)for(const m of g.layers)if(m.type==="network"||m.type==="devices"||m.type==="infrastructure")for(const A of m.objects)f.push({id:A.id,name:A.name??A.id});return f},[t]),T=r.useCallback(f=>{var g;return((g=w.find(m=>m.id===f))==null?void 0:g.name)??f},[w]),i=r.useCallback(()=>{!n||!l||n===l||(u(!0),C([]),p(null),setTimeout(()=>{const f=V.findShortestPath(s,n,l,v),g=V.findAllPaths(s,n,l,5),m=[];f&&m.push(f);for(const A of g)m.some(H=>H.connectionIds.length===A.connectionIds.length&&H.connectionIds.every((W,me)=>A.connectionIds[me]===W))||m.push({...A,isPrimary:!1});C(m),m.length>0&&(p(m[0].id),a==null||a(m[0])),u(!1)},300))},[n,l,v,s,a]),h=r.useCallback(f=>{p(f.id),a==null||a(f)},[a]),j=r.useCallback(f=>{const g=[f.startDeviceId];for(const m of f.connectionIds){const A=s.find(H=>H.id===m);if(A){const H=g[g.length-1],W=A.sourceId===H?A.targetId:A.sourceId;g.includes(W)||g.push(W)}}return g},[s]);return e.jsxs("div",{className:R.panel,children:[e.jsxs("div",{className:R.header,children:[e.jsx("h3",{className:R.title,children:"Analiza ścieżki sieciowej"}),o&&e.jsx("button",{className:R.closeButton,onClick:o,children:e.jsx(va,{})})]}),e.jsxs("div",{className:R.content,children:[e.jsxs("div",{className:R.endpointSection,children:[e.jsx("label",{className:R.endpointLabel,children:"Urządzenie źródłowe"}),e.jsxs("select",{className:R.endpointSelect,value:n,onChange:f=>c(f.target.value),children:[e.jsx("option",{value:"",children:"— Wybierz urządzenie —"}),w.map(f=>e.jsx("option",{value:f.id,children:f.name},f.id))]})]}),e.jsxs("div",{className:R.endpointSection,children:[e.jsx("label",{className:R.endpointLabel,children:"Urządzenie docelowe"}),e.jsxs("select",{className:R.endpointSelect,value:l,onChange:f=>y(f.target.value),children:[e.jsx("option",{value:"",children:"— Wybierz urządzenie —"}),w.filter(f=>f.id!==n).map(f=>e.jsx("option",{value:f.id,children:f.name},f.id))]})]}),e.jsxs("div",{className:R.optionsSection,children:[e.jsx("button",{className:`${R.metricButton} ${v==="latency"?R.metricButtonActive:""}`,onClick:()=>k("latency"),children:"Latencja"}),e.jsx("button",{className:`${R.metricButton} ${v==="hops"?R.metricButtonActive:""}`,onClick:()=>k("hops"),children:"Hops"}),e.jsx("button",{className:`${R.metricButton} ${v==="bandwidth"?R.metricButtonActive:""}`,onClick:()=>k("bandwidth"),children:"Przepustowość"})]}),e.jsx("button",{className:R.analyzeButton,onClick:i,disabled:!n||!l||n===l||N,children:N?"Analizowanie...":"Analizuj ścieżkę"}),N?e.jsx("div",{className:R.loading,children:e.jsx("div",{className:R.spinner})}):d.length>0?e.jsxs("div",{className:R.resultsSection,children:[e.jsxs("div",{className:R.resultsTitle,children:["Znalezione ścieżki (",d.length,")"]}),d.map((f,g)=>{const m=j(f),A=b===f.id;return e.jsxs("div",{className:`${R.pathCard} ${A?R.pathCardSelected:""}`,onClick:()=>h(f),children:[e.jsxs("div",{className:R.pathCardHeader,children:[e.jsxs("div",{className:R.pathCardTitle,children:[e.jsx("span",{className:`${R.pathBadge} ${f.isPrimary?R.badgePrimary:R.badgeAlternate}`,children:f.isPrimary?"Optymalna":`Alt ${g}`}),e.jsxs("span",{className:R.pathName,children:[f.connectionIds.length," połączeń"]})]}),e.jsxs("div",{className:R.pathStatus,children:[e.jsx("span",{className:`${R.statusDot} ${R[`status${f.status.charAt(0).toUpperCase()+f.status.slice(1)}`]??""}`}),e.jsx("span",{children:ga(f.status)})]})]}),e.jsxs("div",{className:R.pathStats,children:[e.jsxs("div",{className:R.statItem,children:[e.jsx("div",{className:R.statValue,children:ba(f.totalLatency)}),e.jsx("div",{className:R.statLabel,children:"Latencja"})]}),e.jsxs("div",{className:R.statItem,children:[e.jsx("div",{className:R.statValue,children:f.connectionIds.length}),e.jsx("div",{className:R.statLabel,children:"Hops"})]}),e.jsxs("div",{className:R.statItem,children:[e.jsx("div",{className:R.statValue,children:f.bottleneckBandwidth>0?ja(f.bottleneckBandwidth):"N/A"}),e.jsx("div",{className:R.statLabel,children:"Przepustowość"})]})]}),A&&e.jsxs("div",{className:R.pathVisualization,children:[e.jsx("div",{className:R.pathDiagram,children:m.map((H,W)=>e.jsxs(r.Fragment,{children:[e.jsx("div",{className:`${R.pathNode} ${W===0?R.pathNodeStart:W===m.length-1?R.pathNodeEnd:""}`,children:T(H).substring(0,8)}),W<m.length-1&&e.jsxs("div",{className:R.pathLink,children:[e.jsx("div",{className:R.pathLinkLine}),e.jsx(fa,{})]})]},H))}),e.jsx("button",{className:R.showOnMapButton,onClick:H=>{H.stopPropagation(),a==null||a(f)},children:"Pokaż na mapie"})]})]},f.id)})]}):n&&l&&n!==l?e.jsx("div",{className:R.noResults,children:'Wybierz urządzenia i kliknij „Analizuj ścieżkę"'}):e.jsx("div",{className:R.noResults,children:"Wybierz urządzenie źródłowe i docelowe"})]})]})},Na="_root_6pirz_9",ka="_header_6pirz_27",Ca="_title_6pirz_37",Ia="_search_6pirz_51",Sa="_categories_6pirz_79",La="_category_6pirz_91",za="_categoryHeader_6pirz_107",Ta="_categoryIcon_6pirz_143",Ba="_categoryLabel_6pirz_151",$a="_categoryCount_6pirz_161",Pa="_expandIcon_6pirz_171",Ma="_items_6pirz_181",Oa="_item_6pirz_181",Aa="_itemIcon_6pirz_241",Ea="_itemName_6pirz_249",Da="_emptyState_6pirz_269",be={root:Na,header:ka,title:Ca,search:Ia,categories:Sa,category:La,categoryHeader:za,categoryIcon:Ta,categoryLabel:Ba,categoryCount:$a,expandIcon:Pa,items:Ma,item:Oa,itemIcon:Aa,itemName:Ea,emptyState:Da},Ra={"floor-plan":["smart-home","building"],"network-topology":["network"],infrastructure:["infrastructure","network"],cad:["building"],interior:["furniture","smart-home"],"game-scene":["game"]},Ga={"smart-home":{icon:"🏠",label:"Smart Home"},furniture:{icon:"🛋️",label:"Furniture"},network:{icon:"🌐",label:"Network"},infrastructure:{icon:"⚙️",label:"Infrastructure"},building:{icon:"🏗️",label:"Building"},zone:{icon:"🗺️",label:"Zones"},game:{icon:"🎮",label:"Game Objects"},annotation:{icon:"📝",label:"Annotations"}},Xt=({mode:t,onObjectSelect:s,customObjects:a=[],className:o})=>{const[n,c]=r.useState(""),[l,y]=r.useState(new Set(["smart-home","furniture","network"])),v=Ra[t]||[],k=r.useMemo(()=>{const b={},p=V.OBJECT_CATALOG.reduce((N,u)=>{var w;return(N[w=u.category]??(N[w]=[])).push(u),N},{});return Object.entries(p).forEach(([N,u])=>{if(!v.includes(N))return;const w=u.filter(T=>!n||T.name.toLowerCase().includes(n.toLowerCase()));w.length>0&&(b[N]=w.map(T=>({id:T.id,name:T.name,category:N,icon:T.icon})))}),a.forEach(N=>{v.includes(N.category)&&(!n||N.name.toLowerCase().includes(n.toLowerCase()))&&(b[N.category]||(b[N.category]=[]),b[N.category].push(N))}),b},[v,n,a]),d=b=>{y(p=>{const N=new Set(p);return N.has(b)?N.delete(b):N.add(b),N})},C=(b,p)=>{b.dataTransfer.setData("application/json",JSON.stringify(p)),b.dataTransfer.effectAllowed="copy"};return e.jsxs("div",{className:`${be.root} ${o??""}`,children:[e.jsxs("div",{className:be.header,children:[e.jsx("h3",{className:be.title,children:"Objects"}),e.jsx("input",{type:"text",className:be.search,placeholder:"Search...",value:n,onChange:b=>c(b.target.value)})]}),e.jsxs("div",{className:be.categories,children:[Object.entries(k).map(([b,p])=>{const N=Ga[b]||{icon:"📦",label:b},u=l.has(b);return e.jsxs("div",{className:be.category,children:[e.jsxs("button",{className:be.categoryHeader,onClick:()=>d(b),children:[e.jsx("span",{className:be.categoryIcon,children:N.icon}),e.jsx("span",{className:be.categoryLabel,children:N.label}),e.jsxs("span",{className:be.categoryCount,children:["(",p.length,")"]}),e.jsx("span",{className:be.expandIcon,children:u?"▼":"▶"})]}),u&&e.jsx("div",{className:be.items,children:p.map(w=>e.jsxs("div",{className:be.item,draggable:!0,onDragStart:T=>C(T,w),onClick:()=>s(w),title:w.name,children:[e.jsx("span",{className:be.itemIcon,children:w.icon||"📦"}),e.jsx("span",{className:be.itemName,children:w.name})]},w.id))})]},b)}),Object.keys(k).length===0&&e.jsx("div",{className:be.emptyState,children:n?`No objects matching "${n}"`:"No objects available for this mode"})]})]})},Wa="_root_o3eqo_9",qa="_header_o3eqo_23",Fa="_title_o3eqo_39",Va="_multiSelect_o3eqo_53",Ha="_content_o3eqo_63",Ua="_section_o3eqo_73",Za="_sectionHeader_o3eqo_89",Ya="_sectionContent_o3eqo_127",Ka="_fieldRow_o3eqo_135",Xa="_fieldLabel_o3eqo_157",Ja="_textInput_o3eqo_169",Qa="_numberInput_o3eqo_171",ec="_select_o3eqo_173",tc="_checkbox_o3eqo_215",sc="_colorInput_o3eqo_227",nc="_readOnly_o3eqo_245",oc="_emptyState_o3eqo_263",ee={root:Wa,header:qa,title:Fa,multiSelect:Va,content:Ha,section:Ua,sectionHeader:Za,sectionContent:Ya,fieldRow:Ka,fieldLabel:Xa,textInput:Ja,numberInput:Qa,select:ec,checkbox:tc,colorInput:sc,readOnly:nc,emptyState:oc},wt=[{key:"name",label:"Name",type:"text"},{key:"position.x",label:"X",type:"number",step:1},{key:"position.y",label:"Y",type:"number",step:1},{key:"rotation",label:"Rotation",type:"number",min:0,max:360,step:1},{key:"visible",label:"Visible",type:"boolean"},{key:"locked",label:"Locked",type:"boolean"}],ac=[{key:"type",label:"Zone Type",type:"select",options:[{value:"living_room",label:"Living Room"},{value:"bedroom",label:"Bedroom"},{value:"bathroom",label:"Bathroom"},{value:"kitchen",label:"Kitchen"},{value:"office",label:"Office"},{value:"hallway",label:"Hallway"},{value:"other",label:"Other"}]},{key:"color",label:"Color",type:"color"},{key:"opacity",label:"Opacity",type:"number",min:0,max:1,step:.1}],cc=[{key:"deviceType",label:"Device Type",type:"text"},{key:"status",label:"Status",type:"select",options:[{value:"online",label:"Online"},{value:"offline",label:"Offline"},{value:"error",label:"Error"}]}],Jt=({selection:t,document:s,onPropertyChange:a,className:o})=>{const[n,c]=r.useState(new Set(["general","position","appearance"])),l=t.objectIds.map(p=>{for(const N of s.floors)for(const u of N.layers){const w=u.objects.find(T=>T.id===p);if(w)return w}return null}).filter(Boolean),y=p=>{c(N=>{const u=new Set(N);return u.has(p)?u.delete(p):u.add(p),u})},v=r.useCallback((p,N)=>{const u=N.split(".");let w=p;for(const T of u)if(w&&typeof w=="object"&&T in w)w=w[T];else return;return w},[]),k=r.useCallback((p,N)=>{var w;const u=v(N,p.key);switch(p.type){case"text":return e.jsx("input",{type:"text",value:String(u??""),onChange:T=>a(N.id,p.key,T.target.value),className:ee.textInput});case"number":return e.jsx("input",{type:"number",value:Number(u??0),min:p.min,max:p.max,step:p.step,onChange:T=>a(N.id,p.key,parseFloat(T.target.value)),className:ee.numberInput});case"boolean":return e.jsx("input",{type:"checkbox",checked:!!u,onChange:T=>a(N.id,p.key,T.target.checked),className:ee.checkbox});case"color":return e.jsx("input",{type:"color",value:String(u??"var(--nice-bg, #fff)"),onChange:T=>a(N.id,p.key,T.target.value),className:ee.colorInput});case"select":return e.jsx("select",{value:String(u??""),onChange:T=>a(N.id,p.key,T.target.value),className:ee.select,children:(w=p.options)==null?void 0:w.map(T=>e.jsx("option",{value:T.value,children:T.label},T.value))});default:return e.jsx("span",{children:String(u??"-")})}},[v,a]);if(l.length===0)return e.jsxs("div",{className:`${ee.root} ${o??""}`,children:[e.jsx("div",{className:ee.header,children:e.jsx("h3",{className:ee.title,children:"Properties"})}),e.jsx("div",{className:ee.emptyState,children:"No object selected"})]});const d=l[0],C=l.length>1,b=d.category==="zone"?ac:["smart-home","network","infrastructure"].includes(d.category??"")?cc:[];return e.jsxs("div",{className:`${ee.root} ${o??""}`,children:[e.jsxs("div",{className:ee.header,children:[e.jsx("h3",{className:ee.title,children:"Properties"}),C&&e.jsxs("span",{className:ee.multiSelect,children:[l.length," selected"]})]}),e.jsxs("div",{className:ee.content,children:[e.jsxs("div",{className:ee.section,children:[e.jsxs("button",{className:ee.sectionHeader,onClick:()=>y("general"),children:[e.jsx("span",{children:n.has("general")?"▼":"▶"}),e.jsx("span",{children:"General"})]}),n.has("general")&&e.jsxs("div",{className:ee.sectionContent,children:[wt.slice(0,1).map(p=>e.jsxs("div",{className:ee.fieldRow,children:[e.jsx("label",{className:ee.fieldLabel,children:p.label}),k(p,d)]},p.key)),e.jsxs("div",{className:ee.fieldRow,children:[e.jsx("label",{className:ee.fieldLabel,children:"ID"}),e.jsx("span",{className:ee.readOnly,children:d.id})]}),e.jsxs("div",{className:ee.fieldRow,children:[e.jsx("label",{className:ee.fieldLabel,children:"Category"}),e.jsx("span",{className:ee.readOnly,children:d.category})]})]})]}),e.jsxs("div",{className:ee.section,children:[e.jsxs("button",{className:ee.sectionHeader,onClick:()=>y("position"),children:[e.jsx("span",{children:n.has("position")?"▼":"▶"}),e.jsx("span",{children:"Transform"})]}),n.has("position")&&e.jsx("div",{className:ee.sectionContent,children:wt.slice(1,4).map(p=>e.jsxs("div",{className:ee.fieldRow,children:[e.jsx("label",{className:ee.fieldLabel,children:p.label}),k(p,d)]},p.key))})]}),b.length>0&&e.jsxs("div",{className:ee.section,children:[e.jsxs("button",{className:ee.sectionHeader,onClick:()=>y("appearance"),children:[e.jsx("span",{children:n.has("appearance")?"▼":"▶"}),e.jsx("span",{children:"Appearance"})]}),n.has("appearance")&&e.jsx("div",{className:ee.sectionContent,children:b.map(p=>e.jsxs("div",{className:ee.fieldRow,children:[e.jsx("label",{className:ee.fieldLabel,children:p.label}),k(p,d)]},p.key))})]}),e.jsxs("div",{className:ee.section,children:[e.jsxs("button",{className:ee.sectionHeader,onClick:()=>y("visibility"),children:[e.jsx("span",{children:n.has("visibility")?"▼":"▶"}),e.jsx("span",{children:"Visibility"})]}),n.has("visibility")&&e.jsx("div",{className:ee.sectionContent,children:wt.slice(4).map(p=>e.jsxs("div",{className:ee.fieldRow,children:[e.jsx("label",{className:ee.fieldLabel,children:p.label}),k(p,d)]},p.key))})]})]})]})},rc="_panel_ldte3_9",ic="_header_ldte3_33",lc="_headerTitle_ldte3_51",dc="_title_ldte3_65",uc="_closeButton_ldte3_79",pc="_summarySection_ldte3_111",_c="_summaryStats_ldte3_121",hc="_statBadge_ldte3_133",mc="_statValue_ldte3_147",xc="_statLabel_ldte3_159",yc="_visibilityControls_ldte3_175",vc="_visibilityLabel_ldte3_193",fc="_visibilityButtons_ldte3_203",gc="_visibilityBtn_ldte3_213",bc="_active_ldte3_243",jc="_content_ldte3_257",wc="_emptyState_ldte3_271",Nc="_emptyHint_ldte3_317",kc="_vlanList_ldte3_329",Cc="_vlanCard_ldte3_343",Ic="_highlighted_ldte3_369",Sc="_hidden_ldte3_379",Lc="_vlanHeader_ldte3_387",zc="_colorIndicator_ldte3_413",Tc="_vlanInfo_ldte3_427",Bc="_vlanName_ldte3_437",$c="_vlanId_ldte3_451",Pc="_vlanNameText_ldte3_463",Mc="_vlanSubnet_ldte3_479",Oc="_vlanStats_ldte3_495",Ac="_chipStat_ldte3_507",Ec="_vlanActions_ldte3_537",Dc="_iconBtn_ldte3_549",Rc="_inactive_ldte3_587",Gc="_expanded_ldte3_603",Wc="_vlanDetails_ldte3_615",qc="_detailRow_ldte3_627",Fc="_detailLabel_ldte3_649",Vc="_detailValue_ldte3_667",Hc="_badge_ldte3_679",Uc="_badgeSuccess_ldte3_693",Zc="_badgeNeutral_ldte3_703",Yc="_deviceList_ldte3_715",Kc="_deviceItems_ldte3_723",Xc="_deviceItem_ldte3_723",Jc="_deviceDot_ldte3_757",Qc="_deviceMore_ldte3_771",er="_highlightButton_ldte3_787",tr="_footer_ldte3_827",sr="_legendTitle_ldte3_839",nr="_legend_ldte3_839",or="_legendItem_ldte3_867",ar="_legendColor_ldte3_879",cr="_legendLabel_ldte3_893",$={panel:rc,header:ic,headerTitle:lc,title:dc,closeButton:uc,summarySection:pc,summaryStats:_c,statBadge:hc,statValue:mc,statLabel:xc,visibilityControls:yc,visibilityLabel:vc,visibilityButtons:fc,visibilityBtn:gc,active:bc,content:jc,emptyState:wc,emptyHint:Nc,vlanList:kc,vlanCard:Cc,highlighted:Ic,hidden:Sc,vlanHeader:Lc,colorIndicator:zc,vlanInfo:Tc,vlanName:Bc,vlanId:$c,vlanNameText:Pc,vlanSubnet:Mc,vlanStats:Oc,chipStat:Ac,vlanActions:Ec,iconBtn:Dc,inactive:Rc,expanded:Gc,vlanDetails:Wc,detailRow:qc,detailLabel:Fc,detailValue:Vc,badge:Hc,badgeSuccess:Uc,badgeNeutral:Zc,deviceList:Yc,deviceItems:Kc,deviceItem:Xc,deviceDot:Jc,deviceMore:Qc,highlightButton:er,footer:tr,legendTitle:sr,legend:nr,legendItem:or,legendColor:ar,legendLabel:cr},rr=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:e.jsx("path",{d:"M12 4L4 12M4 4L12 12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),ir=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("ellipse",{cx:"8",cy:"8",rx:"6",ry:"4"}),e.jsx("circle",{cx:"8",cy:"8",r:"2"})]}),lr=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("path",{d:"M2 8s2.5-4 6-4 6 4 6 4-2.5 4-6 4-6-4-6-4z"}),e.jsx("path",{d:"M3 13L13 3",strokeLinecap:"round"})]}),Et=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("rect",{x:"2",y:"2",width:"4",height:"4",rx:"1"}),e.jsx("rect",{x:"10",y:"2",width:"4",height:"4",rx:"1"}),e.jsx("rect",{x:"6",y:"10",width:"4",height:"4",rx:"1"}),e.jsx("path",{d:"M4 6v2a2 2 0 002 2h4a2 2 0 002-2V6"}),e.jsx("path",{d:"M8 10V8"})]}),dr=()=>e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("circle",{cx:"7",cy:"7",r:"6"}),e.jsx("path",{d:"M7 6v4M7 4h0",strokeLinecap:"round"})]});function ur(t){var s;return((s=t.deviceIds)==null?void 0:s.length)??0}function pr(t,s){return s.filter(a=>a.vlanId===t.id).length}function _r(t){return t||"—"}const hr=({document:t,connections:s,vlans:a,visibleVlanIds:o,onVlanVisibilityChange:n,onHighlightVlan:c,onClose:l})=>{const[y,v]=r.useState(null),[k,d]=r.useState(null),C=r.useMemo(()=>[...a].sort((h,j)=>h.id-j.id),[a]),b=r.useMemo(()=>{const h=new Set,j=new Set;for(const f of a)for(const g of f.deviceIds??[])h.add(g);for(const f of s)f.vlanId!==void 0&&j.add(f.id);return{vlanCount:a.length,deviceCount:h.size,connectionCount:j.size}},[a,s]),p=r.useCallback(h=>{const j=o.has(h);n==null||n(h,!j)},[o,n]),N=r.useCallback(h=>{for(const j of a)n==null||n(j.id,h)},[a,n]),u=r.useCallback(h=>{v((h==null?void 0:h.id)??null),c==null||c(h)},[c]),w=r.useCallback(h=>{d(j=>j===h?null:h)},[]),T=r.useCallback(h=>{const j=[];for(const f of h.deviceIds??[])for(const g of t.floors)for(const m of g.layers){const A=m.objects.find(H=>H.id===f);A&&j.push({id:f,name:A.name??f})}return j},[t]),i=r.useMemo(()=>{const h=a.filter(j=>o.has(j.id)).length;return{visible:h,total:a.length,allVisible:h===a.length,noneVisible:h===0}},[a,o]);return e.jsxs("div",{className:$.panel,children:[e.jsxs("div",{className:$.header,children:[e.jsxs("div",{className:$.headerTitle,children:[e.jsx(Et,{}),e.jsx("h3",{className:$.title,children:"Nakładka VLAN"})]}),l&&e.jsx("button",{className:$.closeButton,onClick:l,title:"Zamknij",children:e.jsx(rr,{})})]}),e.jsx("div",{className:$.summarySection,children:e.jsxs("div",{className:$.summaryStats,children:[e.jsxs("div",{className:$.statBadge,children:[e.jsx("span",{className:$.statValue,children:b.vlanCount}),e.jsx("span",{className:$.statLabel,children:"VLAN"})]}),e.jsxs("div",{className:$.statBadge,children:[e.jsx("span",{className:$.statValue,children:b.deviceCount}),e.jsx("span",{className:$.statLabel,children:"Urządzeń"})]}),e.jsxs("div",{className:$.statBadge,children:[e.jsx("span",{className:$.statValue,children:b.connectionCount}),e.jsx("span",{className:$.statLabel,children:"Połączeń"})]})]})}),e.jsxs("div",{className:$.visibilityControls,children:[e.jsxs("span",{className:$.visibilityLabel,children:["Widoczność: ",i.visible,"/",i.total]}),e.jsxs("div",{className:$.visibilityButtons,children:[e.jsx("button",{className:`${$.visibilityBtn} ${i.allVisible?$.active:""}`,onClick:()=>N(!0),title:"Pokaż wszystkie",children:"Wszystkie"}),e.jsx("button",{className:`${$.visibilityBtn} ${i.noneVisible?$.active:""}`,onClick:()=>N(!1),title:"Ukryj wszystkie",children:"Żaden"})]})]}),e.jsx("div",{className:$.content,children:C.length===0?e.jsxs("div",{className:$.emptyState,children:[e.jsx(Et,{}),e.jsx("p",{children:"Brak zdefiniowanych VLAN-ów"}),e.jsx("span",{className:$.emptyHint,children:"Dodaj VLAN w trybie network-topology lub infrastructure"})]}):e.jsx("div",{className:$.vlanList,children:C.map(h=>{const j=o.has(h.id),f=y===h.id,g=k===h.id,m=ur(h),A=pr(h,s),H=g?T(h):[];return e.jsxs("div",{className:`${$.vlanCard} ${f?$.highlighted:""} ${j?"":$.hidden}`,onMouseEnter:()=>u(h),onMouseLeave:()=>u(null),children:[e.jsxs("div",{className:$.vlanHeader,children:[e.jsx("div",{className:$.colorIndicator,style:{backgroundColor:h.color}}),e.jsxs("div",{className:$.vlanInfo,children:[e.jsxs("div",{className:$.vlanName,children:[e.jsxs("span",{className:$.vlanId,children:["VLAN ",h.id]}),h.name&&e.jsx("span",{className:$.vlanNameText,children:h.name})]}),h.subnet&&e.jsx("div",{className:$.vlanSubnet,children:_r(h.subnet)})]}),e.jsxs("div",{className:$.vlanStats,children:[e.jsx("span",{className:$.chipStat,title:"Urządzenia",children:m}),e.jsx("span",{className:$.chipStat,title:"Połączenia",children:A})]}),e.jsxs("div",{className:$.vlanActions,children:[e.jsx("button",{className:`${$.iconBtn} ${j?"":$.inactive}`,onClick:W=>{W.stopPropagation(),p(h.id)},title:j?"Ukryj VLAN":"Pokaż VLAN",children:j?e.jsx(ir,{}):e.jsx(lr,{})}),e.jsx("button",{className:`${$.iconBtn} ${g?$.expanded:""}`,onClick:W=>{W.stopPropagation(),w(h.id)},title:"Szczegóły",children:e.jsx(dr,{})})]})]}),g&&e.jsxs("div",{className:$.vlanDetails,children:[h.description&&e.jsxs("div",{className:$.detailRow,children:[e.jsx("span",{className:$.detailLabel,children:"Opis:"}),e.jsx("span",{className:$.detailValue,children:h.description})]}),h.subnet&&e.jsxs("div",{className:$.detailRow,children:[e.jsx("span",{className:$.detailLabel,children:"Podsieć:"}),e.jsx("span",{className:$.detailValue,children:h.subnet})]}),h.gateway&&e.jsxs("div",{className:$.detailRow,children:[e.jsx("span",{className:$.detailLabel,children:"Brama:"}),e.jsx("span",{className:$.detailValue,children:h.gateway})]}),e.jsxs("div",{className:$.detailRow,children:[e.jsx("span",{className:$.detailLabel,children:"DHCP:"}),e.jsx("span",{className:`${$.detailValue} ${$.badge} ${h.dhcpEnabled?$.badgeSuccess:$.badgeNeutral}`,children:h.dhcpEnabled?"Włączone":"Wyłączone"})]}),H.length>0&&e.jsxs("div",{className:$.deviceList,children:[e.jsxs("span",{className:$.detailLabel,children:["Urządzenia (",H.length,"):"]}),e.jsxs("ul",{className:$.deviceItems,children:[H.slice(0,10).map(W=>e.jsxs("li",{className:$.deviceItem,children:[e.jsx("span",{className:$.deviceDot,style:{backgroundColor:h.color}}),W.name]},W.id)),H.length>10&&e.jsxs("li",{className:$.deviceMore,children:["... i ",H.length-10," więcej"]})]})]}),e.jsx("button",{className:$.highlightButton,onClick:()=>c==null?void 0:c(h),children:"Zaznacz na mapie"})]})]},h.id)})})}),C.length>0&&e.jsxs("div",{className:$.footer,children:[e.jsx("div",{className:$.legendTitle,children:"Legenda kolorów"}),e.jsx("div",{className:$.legend,children:C.map(h=>e.jsxs("div",{className:$.legendItem,children:[e.jsx("span",{className:$.legendColor,style:{backgroundColor:h.color}}),e.jsxs("span",{className:$.legendLabel,children:[h.id,h.name?`: ${h.name}`:""]})]},h.id))})]})]})},mr="_root_e4i3q_9",xr="_dark_e4i3q_35",yr="_topBar_e4i3q_59",vr="_modeSwitcher_e4i3q_77",fr="_modeBtn_e4i3q_87",gr="_modeBtnActive_e4i3q_123",br="_modeIcon_e4i3q_135",jr="_modeLabel_e4i3q_143",wr="_floorTabs_e4i3q_151",Nr="_floorTab_e4i3q_151",kr="_floorTabActive_e4i3q_195",Cr="_viewportControls_e4i3q_207",Ir="_active_e4i3q_249",Sr="_disabled_e4i3q_259",Lr="_separator_e4i3q_273",zr="_zoomLevel_e4i3q_287",Tr="_exportDropdown_e4i3q_305",Br="_exportMenu_e4i3q_353",$r="_mainContent_e4i3q_427",Pr="_editorContainer_e4i3q_443",Mr="_toolbar_e4i3q_461",Or="_toolGroup_e4i3q_481",Ar="_toolBtn_e4i3q_509",Er="_toolBtnActive_e4i3q_549",Dr="_canvasWrapper_e4i3q_573",Rr="_canvas_e4i3q_573",Gr="_cursor_select_e4i3q_601",Wr="_cursor_multi_select_e4i3q_603",qr="_cursor_pan_e4i3q_605",Fr="_cursor_zoom_e4i3q_609",Vr="_cursor_draw_wall_e4i3q_611",Hr="_cursor_draw_zone_e4i3q_613",Ur="_cursor_draw_polyline_e4i3q_615",Zr="_cursor_draw_rectangle_e4i3q_617",Yr="_cursor_draw_circle_e4i3q_619",Kr="_cursor_draw_arc_e4i3q_621",Xr="_cursor_place_device_e4i3q_623",Jr="_cursor_place_furniture_e4i3q_625",Qr="_cursor_place_network_e4i3q_627",ei="_cursor_place_infra_e4i3q_629",ti="_cursor_place_door_e4i3q_631",si="_cursor_place_window_e4i3q_633",ni="_cursor_place_stairs_e4i3q_635",oi="_cursor_connect_e4i3q_637",ai="_cursor_route_cable_e4i3q_639",ci="_cursor_annotate_e4i3q_641",ri="_cursor_dimension_e4i3q_643",ii="_cursor_label_e4i3q_645",li="_cursor_measure_distance_e4i3q_647",di="_cursor_measure_angle_e4i3q_649",ui="_cursor_measure_area_e4i3q_651",pi="_cursor_move_e4i3q_653",_i="_cursor_rotate_e4i3q_655",hi="_cursor_scale_e4i3q_657",mi="_cursor_erase_e4i3q_659",xi="_cursor_copy_e4i3q_661",yi="_cursor_paste_e4i3q_663",vi="_grid_e4i3q_669",fi="_gridLine_e4i3q_671",gi="_zonesLayer_e4i3q_683",bi="_zone_e4i3q_683",ji="_zoneLabel_e4i3q_689",wi="_connectionsLayer_e4i3q_703",Ni="_connection_e4i3q_703",ki="_connectionPreview_e4i3q_709",Ci="_guides_e4i3q_715",Ii="_guideLine_e4i3q_717",Si="_drawingPreview_e4i3q_731",Li="_rightSidebar_e4i3q_739",zi="_statusBar_e4i3q_761",Ti="_modeIndicator_e4i3q_783",Bi="_toolIndicator_e4i3q_785",$i="_selectionInfo_e4i3q_797",Pi="_drawingInfo_e4i3q_799",Mi="_connectingInfo_e4i3q_813",Oi="_gridInfo_e4i3q_827",Ai="_emptyState_e4i3q_839",Ei="_emptyIcon_e4i3q_861",Di="_primaryBtn_e4i3q_891",Ri="_modeActions_e4i3q_925",Gi="_actionBtn_e4i3q_943",O={root:mr,dark:xr,topBar:yr,modeSwitcher:vr,modeBtn:fr,modeBtnActive:gr,modeIcon:br,modeLabel:jr,floorTabs:wr,floorTab:Nr,floorTabActive:kr,viewportControls:Cr,active:Ir,disabled:Sr,separator:Lr,zoomLevel:zr,exportDropdown:Tr,exportMenu:Br,mainContent:$r,editorContainer:Pr,toolbar:Mr,toolGroup:Or,toolBtn:Ar,toolBtnActive:Er,canvasWrapper:Dr,canvas:Rr,cursor_select:Gr,cursor_multi_select:Wr,cursor_pan:qr,cursor_zoom:Fr,cursor_draw_wall:Vr,cursor_draw_zone:Hr,cursor_draw_polyline:Ur,cursor_draw_rectangle:Zr,cursor_draw_circle:Yr,cursor_draw_arc:Kr,cursor_place_device:Xr,cursor_place_furniture:Jr,cursor_place_network:Qr,cursor_place_infra:ei,cursor_place_door:ti,cursor_place_window:si,cursor_place_stairs:ni,cursor_connect:oi,cursor_route_cable:ai,cursor_annotate:ci,cursor_dimension:ri,cursor_label:ii,cursor_measure_distance:li,cursor_measure_angle:di,cursor_measure_area:ui,cursor_move:pi,cursor_rotate:_i,cursor_scale:hi,cursor_erase:mi,cursor_copy:xi,cursor_paste:yi,grid:vi,gridLine:fi,zonesLayer:gi,zone:bi,zoneLabel:ji,connectionsLayer:wi,connection:Ni,connectionPreview:ki,guides:Ci,guideLine:Ii,drawingPreview:Si,rightSidebar:Li,statusBar:zi,modeIndicator:Ti,toolIndicator:Bi,selectionInfo:$i,drawingInfo:Pi,connectingInfo:Mi,gridInfo:Oi,emptyState:Ai,emptyIcon:Ei,primaryBtn:Di,modeActions:Ri,actionBtn:Gi},Ye={"floor-plan":{mode:"floor-plan",label:"Floor Plan",icon:"🏠",tools:["select","pan","draw-zone","draw-wall","place-device","place-door","place-window","annotate","dimension","measure-distance","measure-area","erase"],layerTypes:["background","floor-plan","zones","devices","annotations","dimensions","grid"],defaultGridSize:20,enable3D:!1},"network-topology":{mode:"network-topology",label:"Network Topology",icon:"🌐",tools:["select","pan","place-network","connect","route-cable","annotate","label","measure-distance","erase"],layerTypes:["background","floor-plan","network","annotations","grid"],defaultGridSize:40,enable3D:!1},infrastructure:{mode:"infrastructure",label:"Infrastructure",icon:"🏢",tools:["select","pan","draw-zone","place-infra","place-network","connect","route-cable","annotate","dimension","measure-distance","measure-area","erase"],layerTypes:["background","floor-plan","zones","infrastructure","network","annotations","dimensions","grid"],defaultGridSize:50,enable3D:!1},cad:{mode:"cad",label:"CAD",icon:"📐",tools:["select","multi-select","pan","draw-wall","draw-zone","draw-polyline","draw-rectangle","draw-circle","draw-arc","place-door","place-window","place-stairs","annotate","dimension","measure-distance","measure-angle","measure-area","move","rotate","scale","copy","paste","erase"],layerTypes:["background","floor-plan","zones","annotations","dimensions","grid"],defaultGridSize:10,enable3D:!0},interior:{mode:"interior",label:"Interior Design",icon:"🛋️",tools:["select","pan","draw-zone","draw-wall","place-furniture","place-device","place-door","place-window","annotate","measure-distance","measure-area","move","rotate","erase"],layerTypes:["background","floor-plan","zones","furniture","devices","annotations","grid"],defaultGridSize:25,enable3D:!0},"game-scene":{mode:"game-scene",label:"Game Scene",icon:"🎮",tools:["select","multi-select","pan","draw-zone","draw-polyline","draw-rectangle","draw-circle","annotate","move","rotate","scale","copy","paste","erase"],layerTypes:["background","floor-plan","zones","game-objects","collision","annotations","grid"],defaultGridSize:32,enable3D:!0}},Ct={select:{tool:"select",icon:"↖",label:"Select",shortcut:"V",group:"select"},"multi-select":{tool:"multi-select",icon:"⊞",label:"Multi-Select",shortcut:"M",group:"select"},pan:{tool:"pan",icon:"✋",label:"Pan",shortcut:"H",group:"select"},zoom:{tool:"zoom",icon:"🔍",label:"Zoom",shortcut:"Z",group:"select"},"draw-wall":{tool:"draw-wall",icon:"▬",label:"Wall",shortcut:"W",group:"draw"},"draw-zone":{tool:"draw-zone",icon:"⬡",label:"Zone",shortcut:"R",group:"draw"},"draw-polyline":{tool:"draw-polyline",icon:"〰",label:"Polyline",shortcut:"L",group:"draw"},"draw-rectangle":{tool:"draw-rectangle",icon:"▢",label:"Rectangle",shortcut:"U",group:"draw"},"draw-circle":{tool:"draw-circle",icon:"○",label:"Circle",shortcut:"C",group:"draw"},"draw-arc":{tool:"draw-arc",icon:"⌒",label:"Arc",shortcut:"A",group:"draw"},"place-device":{tool:"place-device",icon:"📡",label:"Device",shortcut:"D",group:"place"},"place-furniture":{tool:"place-furniture",icon:"🪑",label:"Furniture",shortcut:"F",group:"place"},"place-network":{tool:"place-network",icon:"🖧",label:"Network",shortcut:"N",group:"place"},"place-infra":{tool:"place-infra",icon:"⚙",label:"Infrastructure",shortcut:"I",group:"place"},"place-door":{tool:"place-door",icon:"🚪",label:"Door",group:"place"},"place-window":{tool:"place-window",icon:"🪟",label:"Window",group:"place"},"place-stairs":{tool:"place-stairs",icon:"🪜",label:"Stairs",group:"place"},connect:{tool:"connect",icon:"⟷",label:"Connect",shortcut:"K",group:"connect"},"route-cable":{tool:"route-cable",icon:"〰",label:"Cable Route",group:"connect"},annotate:{tool:"annotate",icon:"✏",label:"Annotate",shortcut:"T",group:"annotate"},dimension:{tool:"dimension",icon:"↔",label:"Dimension",group:"annotate"},label:{tool:"label",icon:"🏷",label:"Label",group:"annotate"},"measure-distance":{tool:"measure-distance",icon:"📏",label:"Distance",group:"measure"},"measure-angle":{tool:"measure-angle",icon:"∠",label:"Angle",group:"measure"},"measure-area":{tool:"measure-area",icon:"⊡",label:"Area",group:"measure"},move:{tool:"move",icon:"✥",label:"Move",shortcut:"G",group:"edit"},rotate:{tool:"rotate",icon:"↻",label:"Rotate",shortcut:"R",group:"edit"},scale:{tool:"scale",icon:"⤡",label:"Scale",shortcut:"S",group:"edit"},erase:{tool:"erase",icon:"🗑",label:"Delete",shortcut:"Del",group:"edit"},copy:{tool:"copy",icon:"📋",label:"Copy",shortcut:"Ctrl+C",group:"edit"},paste:{tool:"paste",icon:"📄",label:"Paste",shortcut:"Ctrl+V",group:"edit"}};function Wi(t){var n,c;const s=t.defaultMode??"floor-plan",a=Ye[s],o=[{type:"grid",visible:!0,locked:!0,opacity:.3,zIndex:0},{type:"background",visible:!0,locked:!0,opacity:.5,zIndex:1},{type:"floor-plan",visible:!0,locked:!1,opacity:1,zIndex:10},{type:"zones",visible:!0,locked:!1,opacity:.6,zIndex:20},{type:"furniture",visible:!0,locked:!1,opacity:1,zIndex:30},{type:"devices",visible:!0,locked:!1,opacity:1,zIndex:40},{type:"network",visible:!0,locked:!1,opacity:1,zIndex:50},{type:"infrastructure",visible:!0,locked:!1,opacity:1,zIndex:60},{type:"game-objects",visible:!0,locked:!1,opacity:1,zIndex:70},{type:"collision",visible:!1,locked:!1,opacity:.4,zIndex:80},{type:"annotations",visible:!0,locked:!1,opacity:1,zIndex:90},{type:"dimensions",visible:!0,locked:!1,opacity:1,zIndex:100}];return{mode:s,tool:a.tools[0]??"select",document:t.document??t.initialDocument??null,activeFloorId:((c=(n=t.document)==null?void 0:n.floors[0])==null?void 0:c.id)??null,layers:o,selection:{objectIds:[],bounds:null,locked:!1},viewport:{zoom:1,pan:{x:0,y:0},rotation:0,showGrid:!0,gridSize:t.gridSize??a.defaultGridSize,snapEnabled:t.snapEnabled??!0,snapModes:["grid","endpoint","midpoint"]},drawing:{active:!1,points:[],preview:null},connecting:{active:!1,sourceId:null,sourcePosition:null,previewPosition:null},history:{past:[],future:[]},guides:[],dragging:null,clipboard:[],ui:{showObjectLibrary:t.showObjectLibrary??!0,showLayerPanel:t.showLayerPanel??!0,showPropertiesPanel:t.showPropertiesPanel??!0,showMinimap:t.showMinimap??!0}}}function Ue(t,s,a,o){return{id:`${Date.now()}-${Math.random().toString(36).slice(2,9)}`,timestamp:Date.now(),type:t,objectIds:s,before:a,after:o}}function Ze(t,s){return{history:{past:[...t.history.past.slice(-49),s],future:[]}}}function Re(t,s){if(t)for(const a of t.floors)for(const o of a.layers){const n=o.objects.find(c=>c.id===s);if(n)return n}}function ct(t,s,a){return{...t,floors:t.floors.map(o=>({...o,layers:o.layers.map(n=>({...n,objects:n.objects.map(c=>c.id===s?{...c,...a}:c)}))})),metadata:{...t.metadata,modified:new Date().toISOString()}}}function rt(t,s){const a=new Set(s);return{...t,floors:t.floors.map(o=>({...o,layers:o.layers.map(n=>({...n,objects:n.objects.filter(c=>!a.has(c.id))}))})),metadata:{...t.metadata,modified:new Date().toISOString()}}}function it(t,s,a,o){return{...t,floors:t.floors.map(n=>n.id!==s?n:{...n,layers:n.layers.map(c=>c.name!==a?c:{...c,objects:[...c.objects,o]})}),metadata:{...t.metadata,modified:new Date().toISOString()}}}function qi(t,s){var a;switch(s.type){case"SET_MODE":{const o=Ye[s.mode];return{...t,mode:s.mode,tool:o.tools.includes(t.tool)?t.tool:o.tools[0],viewport:{...t.viewport,gridSize:o.defaultGridSize}}}case"SET_TOOL":return{...t,tool:s.tool,drawing:{active:!1,points:[],preview:null},connecting:{active:!1,sourceId:null,sourcePosition:null,previewPosition:null}};case"SET_DOCUMENT":return{...t,document:s.document,activeFloorId:((a=s.document.floors[0])==null?void 0:a.id)??null};case"SET_ACTIVE_FLOOR":return{...t,activeFloorId:s.floorId};case"SET_SELECTION":return{...t,selection:s.selection};case"CLEAR_SELECTION":return{...t,selection:{objectIds:[],bounds:null,locked:!1}};case"SET_VIEWPORT":return{...t,viewport:{...t.viewport,...s.viewport}};case"ZOOM":{const o=Math.max(.1,Math.min(10,t.viewport.zoom*(1+s.delta*.1)));return{...t,viewport:{...t.viewport,zoom:o}}}case"PAN":return{...t,viewport:{...t.viewport,pan:{x:t.viewport.pan.x+s.delta.x,y:t.viewport.pan.y+s.delta.y}}};case"RESET_VIEW":return{...t,viewport:{...t.viewport,zoom:1,pan:{x:0,y:0}}};case"TOGGLE_GRID":return{...t,viewport:{...t.viewport,showGrid:!t.viewport.showGrid}};case"TOGGLE_SNAP":return{...t,viewport:{...t.viewport,snapEnabled:!t.viewport.snapEnabled}};case"SET_GRID_SIZE":return{...t,viewport:{...t.viewport,gridSize:s.size}};case"SET_SNAP_MODES":return{...t,viewport:{...t.viewport,snapModes:s.modes}};case"SET_LAYER_VISIBILITY":return{...t,layers:t.layers.map(o=>o.type===s.layerType?{...o,visible:s.visible}:o)};case"SET_LAYER_LOCKED":return{...t,layers:t.layers.map(o=>o.type===s.layerType?{...o,locked:s.locked}:o)};case"SET_LAYER_OPACITY":return{...t,layers:t.layers.map(o=>o.type===s.layerType?{...o,opacity:s.opacity}:o)};case"START_DRAWING":return{...t,drawing:{active:!0,points:[s.point],preview:null}};case"ADD_DRAWING_POINT":return{...t,drawing:{...t.drawing,points:[...t.drawing.points,s.point]}};case"UPDATE_DRAWING_PREVIEW":return{...t,drawing:{...t.drawing,preview:s.point}};case"FINISH_DRAWING":return{...t,drawing:{active:!1,points:[],preview:null}};case"CANCEL_DRAWING":return{...t,drawing:{active:!1,points:[],preview:null}};case"START_CONNECTING":return{...t,connecting:{active:!0,sourceId:s.sourceId,sourcePort:s.sourcePort,sourcePosition:s.sourcePosition,previewPosition:s.sourcePosition}};case"UPDATE_CONNECTING_PREVIEW":return{...t,connecting:{...t.connecting,previewPosition:s.position}};case"FINISH_CONNECTING":return{...t,connecting:{active:!1,sourceId:null,sourcePosition:null,previewPosition:null}};case"CANCEL_CONNECTING":return{...t,connecting:{active:!1,sourceId:null,sourcePosition:null,previewPosition:null}};case"SET_GUIDES":return{...t,guides:s.guides};case"TOGGLE_OBJECT_LIBRARY":return{...t,ui:{...t.ui,showObjectLibrary:!t.ui.showObjectLibrary}};case"TOGGLE_LAYER_PANEL":return{...t,ui:{...t.ui,showLayerPanel:!t.ui.showLayerPanel}};case"TOGGLE_PROPERTIES_PANEL":return{...t,ui:{...t.ui,showPropertiesPanel:!t.ui.showPropertiesPanel}};case"TOGGLE_MINIMAP":return{...t,ui:{...t.ui,showMinimap:!t.ui.showMinimap}};case"ADD_OBJECT":{if(!t.document||!t.activeFloorId)return t;const o=s.object.layer||"devices",n=it(t.document,t.activeFloorId,o,s.object),c=Ue("create",[s.object.id],null,s.object);return{...t,document:n,...Ze(t,c)}}case"UPDATE_OBJECT":{if(!t.document)return t;const o=Re(t.document,s.objectId);if(!o)return t;const n=ct(t.document,s.objectId,s.updates),c=Ue("update",[s.objectId],o,{...o,...s.updates});return{...t,document:n,...Ze(t,c)}}case"DELETE_OBJECTS":{if(!t.document||s.objectIds.length===0)return t;const o=s.objectIds.map(l=>Re(t.document,l)).filter(Boolean),n=rt(t.document,s.objectIds),c=Ue("delete",s.objectIds,o,null);return{...t,document:n,selection:{objectIds:[],bounds:null,locked:!1},...Ze(t,c)}}case"MOVE_OBJECTS":{if(!t.document||s.objectIds.length===0)return t;const o=s.objectIds.map(y=>Re(t.document,y)).filter(Boolean);let n=t.document;for(const y of s.objectIds){const v=Re(n,y);if(v&&"transform"in v&&v.transform&&"position"in v.transform){const k=v.transform.position;n=ct(n,y,{transform:{...v.transform,position:{x:k.x+s.delta.x,y:k.y+s.delta.y}}})}}const c=s.objectIds.map(y=>Re(n,y)).filter(Boolean),l=Ue("move",s.objectIds,o,c);return{...t,document:n,...Ze(t,l)}}case"UNDO":{if(t.history.past.length===0||!t.document)return t;const o=t.history.past[t.history.past.length-1];let n=t.document;switch(o.type){case"create":{n=rt(n,o.objectIds);break}case"delete":{const c=o.before;for(const l of c){const y=l.layer||"devices";n=it(n,t.activeFloorId??n.floors[0].id,y,l)}break}case"update":case"move":{const c=o.before;for(const l of c)n=ct(n,l.id,l);break}}return{...t,document:n,history:{past:t.history.past.slice(0,-1),future:[o,...t.history.future]}}}case"REDO":{if(t.history.future.length===0||!t.document)return t;const o=t.history.future[0];let n=t.document;switch(o.type){case"create":{const c=o.after,l=c.layer||"devices";n=it(n,t.activeFloorId??n.floors[0].id,l,c);break}case"delete":{n=rt(n,o.objectIds);break}case"update":case"move":{const c=o.after;for(const l of c)n=ct(n,l.id,l);break}}return{...t,document:n,history:{past:[...t.history.past,o],future:t.history.future.slice(1)}}}case"COPY":{if(!t.document||t.selection.objectIds.length===0)return t;const o=t.selection.objectIds.map(n=>Re(t.document,n)).filter(Boolean);return{...t,clipboard:o}}case"CUT":{if(!t.document||t.selection.objectIds.length===0)return t;const o=t.selection.objectIds.map(l=>Re(t.document,l)).filter(Boolean),n=rt(t.document,t.selection.objectIds),c=Ue("delete",t.selection.objectIds,o,null);return{...t,document:n,clipboard:o,selection:{objectIds:[],bounds:null,locked:!1},...Ze(t,c)}}case"PASTE":{if(!t.document||!t.activeFloorId||t.clipboard.length===0)return t;let o=t.document;const n=[],c=[];for(const y of t.clipboard){const v=`${y.id}-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,k=y.transform,d={position:{x:k.position.x+s.position.x+20,y:k.position.y+s.position.y+20},rotation:k.rotation,scale:k.scale},C={...y,id:v,transform:d},b=C.layer||"devices";o=it(o,t.activeFloorId,b,C),n.push(v),c.push(C)}const l=Ue("create",n,null,c);return{...t,document:o,selection:{objectIds:n,bounds:null,locked:!1},...Ze(t,l)}}case"START_DRAG":return{...t,dragging:{objectType:s.objectType,objectData:s.objectData,position:null}};case"UPDATE_DRAG_POSITION":return t.dragging?{...t,dragging:{...t.dragging,position:s.position}}:t;case"END_DRAG":return{...t,dragging:null};case"CANCEL_DRAG":return{...t,dragging:null};default:return t}}const Fi=({mode:t,activeTool:s,onToolSelect:a,readOnly:o})=>{const c=Ye[t].tools.map(y=>Ct[y]).filter(Boolean),l=["select","draw","place","connect","annotate","measure","edit"];return e.jsx("div",{className:O.toolbar,children:l.map(y=>{const v=c.filter(k=>k.group===y);return v.length===0?null:e.jsx("div",{className:O.toolGroup,children:v.map(({tool:k,icon:d,label:C,shortcut:b})=>e.jsx("button",{title:`${C}${b?` (${b})`:""}`,className:`${O.toolBtn} ${s===k?O.toolBtnActive:""}`,onClick:()=>a(k),disabled:o&&!["select","pan","zoom","measure-distance","measure-angle","measure-area"].includes(k),children:d},k))},y)})})},Vi=({currentMode:t,availableModes:s,onModeChange:a})=>e.jsx("div",{className:O.modeSwitcher,children:s.map(o=>{const n=Ye[o];return e.jsxs("button",{title:n.label,className:`${O.modeBtn} ${t===o?O.modeBtnActive:""}`,onClick:()=>a(o),children:[e.jsx("span",{className:O.modeIcon,children:n.icon}),e.jsx("span",{className:O.modeLabel,children:n.label})]},o)})});function Dt(t){if(!t)return[];const s=[];for(const a of t.floors)for(const o of a.layers)if(o.type==="network"||o.type==="infrastructure"){for(const n of o.objects)if(n.type==="connection"){const c=n.metadata;c!=null&&c.sourceId&&(c!=null&&c.targetId)&&s.push({id:n.id,sourceId:c.sourceId,sourcePort:c.sourcePort,targetId:c.targetId,targetPort:c.targetPort,medium:c.medium??"ethernet-cat6",status:c.status??"unknown",bandwidth:c.bandwidth,latency:c.latency??1,waypoints:c.waypoints??[]})}}return s}function Hi(t){if(!t)return[];const s=[],a=new Set;for(const o of t.floors)for(const n of o.layers)if(n.type==="network"||n.type==="infrastructure")for(const c of n.objects){const l=c.metadata;if((l==null?void 0:l.vlanId)!==void 0&&!a.has(l.vlanId))a.add(l.vlanId),s.push({id:l.vlanId,name:l.vlanName??`VLAN ${l.vlanId}`,color:l.vlanColor??Ui(l.vlanId),deviceIds:[c.id],subnet:l.subnet,gateway:l.gateway,dhcpEnabled:l.dhcpEnabled});else if((l==null?void 0:l.vlanId)!==void 0){const y=s.find(v=>v.id===l.vlanId);y&&!y.deviceIds.includes(c.id)&&y.deviceIds.push(c.id)}}return s.sort((o,n)=>o.id-n.id)}function Ui(t){const s=["var(--nice-primary, #3b82f6)","var(--nice-success, #22c55e)","var(--nice-warning, #f59e0b)","var(--nice-danger, #ef4444)","var(--nice-accent, #8b5cf6)","var(--nice-accent-pink, #ec4899)","var(--nice-info, #06b6d4)","var(--nice-warning, #f97316)","var(--nice-info, #14b8a6)","var(--nice-accent, #a855f7)"];return s[t%s.length]}const Zi=[{target:".nice-spatial-editor",titleKey:"tutorial.spatialEditor.intro.title",title:"Spatial editor",contentKey:"tutorial.spatialEditor.intro.content",content:"Lay out floor plans across modes: draw walls, rooms and objects with the tools, manage layers, snap to the grid, then export.",placement:"auto"}],Yi=t=>{var St,Lt;const{defaultMode:s="floor-plan",availableModes:a=Object.keys(Ye),readOnly:o=!1,theme:n="light",locale:c="en",onDocumentChange:l,onSelectionChange:y,onModeChange:v,onExport:k,onImport:d,tutorial:C,className:b,style:p,cookies:N=!1,localStorage:u=!0,sessionStorage:w=!1,storageMode:T,storageKey:i,persistPreferences:h=!1}=t,j=Me.useStorageAdapter(i??"nice-spatial-editor"),[f]=r.useState(()=>h?j.get("prefs")??{}:{}),[g,m]=r.useReducer(qi,t,Wi),A=r.useRef(null),H=r.useRef(!1),W=r.useRef({x:0,y:0}),[me,ue]=r.useState(!1),[de,ye]=r.useState(!1),[ne,re]=r.useState(null),[ce,S]=r.useState(null),[F,ie]=r.useState(!1),[Ne,ke]=r.useState(!1),[fe,Te]=r.useState(!1),[Be,Ge]=r.useState(new Set),[tt,Oe]=r.useState(null),$e=r.useRef(null),Ee=r.useRef(null),Ie=r.useRef(null),{mode:je,tool:he,document:se,activeFloorId:De,layers:we,selection:ve,viewport:oe,drawing:_e,connecting:X,guides:We,ui:Pe,history:Ke}=g,qe=Ye[je],st=Ke.past.length>0,Xe=Ke.future.length>0;r.useEffect(()=>{var x,M,P;!h||!f||((f.zoom||f.pan)&&m({type:"SET_VIEWPORT",viewport:{zoom:f.zoom,pan:f.pan,showGrid:(x=f.gridConfig)==null?void 0:x.visible,gridSize:(M=f.gridConfig)==null?void 0:M.size,snapEnabled:(P=f.gridConfig)==null?void 0:P.snapEnabled}}),f.mode&&m({type:"SET_MODE",mode:f.mode}),f.tool&&m({type:"SET_TOOL",tool:f.tool}),f.layerVisibility&&Object.entries(f.layerVisibility).forEach(([D,U])=>{U!==void 0&&m({type:"SET_LAYER_VISIBILITY",layerType:D,visible:U})}))},[]),r.useEffect(()=>{if(!h)return;const x={zoom:oe.zoom,pan:oe.pan,gridConfig:{size:oe.gridSize,visible:oe.showGrid,snapEnabled:oe.snapEnabled},mode:je,tool:he,layerVisibility:Object.fromEntries(we.map(M=>[M.type,M.visible])),uiPanels:Pe};j.set("prefs",x)},[h,oe,je,he,we,Pe,j]);const xe=r.useMemo(()=>(se==null?void 0:se.floors.find(x=>x.id===De))??(se==null?void 0:se.floors[0])??null,[se,De]),Ae=r.useCallback((x,M)=>{var D;const P=(D=A.current)==null?void 0:D.getBoundingClientRect();return P?{x:(x-P.left-oe.pan.x)/oe.zoom,y:(M-P.top-oe.pan.y)/oe.zoom}:{x:0,y:0}},[oe.pan,oe.zoom]),Fe=r.useCallback(x=>{if(!oe.snapEnabled)return x;const M={cellSize:oe.gridSize,majorInterval:10,origin:{x:0,y:0},visible:oe.showGrid,color:"var(--nice-border, #e5e7eb)",majorColor:"var(--nice-text-muted, #9ca3af)",opacity:1,snapModes:["grid"],snapThreshold:10,angleIncrement:15};return V.snapToGrid(x,M)},[oe.snapEnabled,oe.gridSize,oe.showGrid]),pt=r.useCallback(x=>{if(he==="pan"||x.button===1){H.current=!0,W.current={x:x.clientX,y:x.clientY};return}const M=Fe(Ae(x.clientX,x.clientY));if(he==="draw-zone"||he==="draw-wall"||he==="draw-polyline")_e.active?m({type:"ADD_DRAWING_POINT",point:M}):m({type:"START_DRAWING",point:M});else if(he==="connect"){const P=xe==null?void 0:xe.layers.flatMap(D=>D.objects).find(D=>{if(!D.bounds)return!1;const U=D.bounds;return M.x>=U.x&&M.x<=U.x+U.width&&M.y>=U.y&&M.y<=U.y+U.height});if(P)if(X.active){m({type:"FINISH_CONNECTING",targetId:P.id});const D=`conn-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,U=P.bounds?{x:P.bounds.x+P.bounds.width/2,y:P.bounds.y+P.bounds.height/2}:M,Y={id:D,type:"connection",category:"network",name:"Connection",transform:{position:{x:0,y:0},rotation:0,scale:{x:1,y:1}},layer:"network",locked:!1,visible:!0,childIds:[],bounds:{x:Math.min(X.sourcePosition.x,U.x),y:Math.min(X.sourcePosition.y,U.y),width:Math.abs(U.x-X.sourcePosition.x),height:Math.abs(U.y-X.sourcePosition.y)},metadata:{sourceId:X.sourceId,targetId:P.id,sourcePosition:X.sourcePosition,targetPosition:U,medium:"ethernet-cat6",status:"active"}};m({type:"ADD_OBJECT",object:Y})}else{const D=P.bounds?{x:P.bounds.x+P.bounds.width/2,y:P.bounds.y+P.bounds.height/2}:M;m({type:"START_CONNECTING",sourceId:P.id,sourcePosition:D})}else X.active&&m({type:"CANCEL_CONNECTING"})}else he==="select"&&m({type:"CLEAR_SELECTION"})},[he,_e.active,X.active,X.sourceId,X.sourcePosition,Fe,Ae,xe]),_t=r.useCallback(x=>{if(H.current){const P=x.clientX-W.current.x,D=x.clientY-W.current.y;m({type:"PAN",delta:{x:P,y:D}}),W.current={x:x.clientX,y:x.clientY};return}const M=Fe(Ae(x.clientX,x.clientY));if(_e.active&&(m({type:"UPDATE_DRAWING_PREVIEW",point:M}),oe.snapEnabled&&xe)){const P=xe.layers.flatMap(Y=>Y.objects.filter(ae=>ae.bounds).map(ae=>({id:ae.id,bounds:ae.bounds}))),D={x:M.x,y:M.y,width:1,height:1},U=V.generateAlignmentGuides(D,P,10);m({type:"SET_GUIDES",guides:U})}X.active&&m({type:"UPDATE_CONNECTING_PREVIEW",position:M})},[_e.active,X.active,Fe,Ae,oe.snapEnabled,xe]),ht=r.useCallback(()=>{H.current=!1},[]),mt=r.useCallback(x=>{_e.active&&_e.points.length>=2&&m({type:"FINISH_DRAWING"})},[_e.active,_e.points.length]),xt=r.useCallback(x=>{x.preventDefault();const M=x.deltaY>0?-1:1;m({type:"ZOOM",delta:M,center:Ae(x.clientX,x.clientY)})},[Ae]),yt=r.useCallback(x=>{x.key==="Escape"&&(_e.active?m({type:"CANCEL_DRAWING"}):X.active?m({type:"CANCEL_CONNECTING"}):m({type:"CLEAR_SELECTION"})),x.key==="Delete"&&ve.objectIds.length>0&&m({type:"DELETE_OBJECTS",objectIds:ve.objectIds}),(x.ctrlKey||x.metaKey)&&(x.key==="z"&&m({type:"UNDO"}),x.key==="y"&&m({type:"REDO"}),x.key==="c"&&m({type:"COPY"}),x.key==="v"&&m({type:"PASTE",position:{x:0,y:0}}),x.key==="x"&&m({type:"CUT"}))},[_e.active,X.active,ve.objectIds]),vt=r.useCallback(x=>{m({type:"SET_MODE",mode:x}),v==null||v(x)},[v]),ft=r.useCallback(x=>{m({type:"SET_TOOL",tool:x})},[]),Ve=r.useCallback(async x=>{var M;if(se){ue(!1);try{const P={includeGrid:!1,includeDimensions:!0};if(x==="nsp"){const D=V.exportToNSP(se,P);V.downloadExport(D),k==null||k(x,D.data)}else if(x==="svg"){const D=V.exportToSVG(se,P);V.downloadExport(D),k==null||k(x,D.data)}else if(x==="dxf"){const D=V.exportToDXF(se,P);V.downloadExport(D),k==null||k(x,D.data)}else if(x==="png"&&A.current){const D=await V.exportSVGToPNG(A.current,((M=se.metadata)==null?void 0:M.name)||"export");V.downloadExport(D),k==null||k(x,D.data)}}catch(P){console.error(`Export to ${x} failed:`,P)}}},[se,k]),gt=r.useCallback(async x=>{var P;const M=(P=x.target.files)==null?void 0:P[0];if(M){ye(!1);try{const D={convertClosedPolylinesToZones:!0,minZoneArea:1},U=await V.importFromBrowserFile(M,D);U.success&&U.document?S(U):re(U),Ie.current&&(Ie.current.value="")}catch(D){console.error("Import failed:",D),re({success:!1,warnings:[],errors:[{code:"IMPORT_ERROR",message:D instanceof Error?D.message:"Unknown import error",fatal:!0}],stats:{wallsImported:0,zonesImported:0,objectsImported:0,layersFound:0,entitiesSkipped:0,importTimeMs:0}})}}},[]),bt=r.useCallback(()=>{ce!=null&&ce.success&&ce.document?ie(!0):S(null)},[ce]),nt=r.useCallback(()=>{S(null),ie(!1)},[]),_=r.useCallback((x,M)=>{if(!(ce!=null&&ce.document)){ie(!1);return}const P=ce.document,D={...P,floors:P.floors.map(U=>({...U,layers:U.layers.filter(Y=>x.get(Y.id)!=="skip").map(Y=>{const ae=x.get(Y.id);if(ae===Y.id||!ae)return Y;const Se=se==null?void 0:se.floors.flatMap(He=>He.layers).find(He=>He.id===ae);return Se?{...Y,id:Se.id,name:Se.name,type:Se.type}:Y})}))};m({type:"SET_DOCUMENT",document:D}),d==null||d(D),re(ce),ie(!1),S(null)},[ce,se,d]),z=r.useCallback(()=>{ie(!1)},[]),I=r.useCallback(x=>{if(Ie.current){let M=".dxf,.svg,.geojson,.json,.ifc";x==="dxf"?M=".dxf":x==="svg"?M=".svg":x==="geojson"?M=".geojson,.json":x==="ifc"&&(M=".ifc"),Ie.current.accept=M,Ie.current.click()}ye(!1)},[]);r.useEffect(()=>{const x=M=>{$e.current&&!$e.current.contains(M.target)&&ue(!1),Ee.current&&!Ee.current.contains(M.target)&&ye(!1)};return(me||de)&&document.addEventListener("mousedown",x),()=>{document.removeEventListener("mousedown",x)}},[me,de]);const K=r.useCallback(()=>{var U,Y;if(!oe.showGrid||!xe)return null;const x=[],{gridSize:M}=oe,P=((U=xe.bounds)==null?void 0:U.width)??1e3,D=((Y=xe.bounds)==null?void 0:Y.height)??800;for(let ae=0;ae<=P;ae+=M)x.push(e.jsx("line",{x1:ae,y1:0,x2:ae,y2:D,className:O.gridLine},`v${ae}`));for(let ae=0;ae<=D;ae+=M)x.push(e.jsx("line",{x1:0,y1:ae,x2:P,y2:ae,className:O.gridLine},`h${ae}`));return e.jsx("g",{className:O.grid,children:x})},[oe.showGrid,oe.gridSize,xe]),le=r.useCallback(()=>{if(!xe)return null;const x=xe.layers.find(M=>M.name==="zones");return x?e.jsx("g",{className:O.zonesLayer,children:x.objects.map(M=>{const P=M;if(!P.boundary||P.boundary.length<3)return null;const D=P.boundary.map((ae,Se)=>`${Se===0?"M":"L"}${ae.x},${ae.y}`).join(" ")+" Z",U=ve.objectIds.includes(P.id),Y=P.boundary.reduce((ae,Se)=>({x:ae.x+Se.x/P.boundary.length,y:ae.y+Se.y/P.boundary.length}),{x:0,y:0});return e.jsxs("g",{className:O.zone,onClick:ae=>{ae.stopPropagation(),m({type:"SET_SELECTION",selection:{objectIds:[P.id],bounds:null,locked:!1}})},children:[e.jsx("path",{d:D,fill:P.color??"var(--nice-primary-bg, #dbeafe)",fillOpacity:.5,stroke:U?"var(--nice-primary-hover, #2563eb)":"var(--nice-text-muted, #94a3b8)",strokeWidth:U?2:1}),P.name&&e.jsx("text",{x:Y.x,y:Y.y,textAnchor:"middle",dominantBaseline:"middle",className:O.zoneLabel,children:P.name})]},P.id)})}):null},[xe,ve.objectIds]),J=r.useCallback(()=>We.length===0?null:e.jsx("g",{className:O.guides,children:We.map((x,M)=>e.jsx("line",{x1:x.start.x,y1:x.start.y,x2:x.end.x,y2:x.end.y,className:O.guideLine},M))}),[We]),pe=r.useCallback(()=>{if(!_e.active||_e.points.length===0)return null;const x=[..._e.points];_e.preview&&x.push(_e.preview);const M=x.map((D,U)=>`${U===0?"M":"L"}${D.x},${D.y}`).join(" "),P=he==="draw-zone"&&x.length>2;return e.jsxs("g",{className:O.drawingPreview,children:[e.jsx("path",{d:M+(P?" Z":""),fill:P?"var(--nice-primary-tint-10, rgba(37, 99, 235, 0.1))":"none",stroke:"var(--nice-primary-hover, #2563eb)",strokeWidth:2,strokeDasharray:P?"none":"6,3"}),x.map((D,U)=>e.jsx("circle",{cx:D.x,cy:D.y,r:4,fill:"var(--nice-primary-hover, #2563eb)"},U))]})},[_e,he]),ge=r.useCallback(()=>!X.active||!X.sourcePosition||!X.previewPosition?null:e.jsxs("g",{className:O.connectionPreview,children:[e.jsx("line",{x1:X.sourcePosition.x,y1:X.sourcePosition.y,x2:X.previewPosition.x,y2:X.previewPosition.y,stroke:"var(--nice-success, #10b981)",strokeWidth:2,strokeDasharray:"8,4",markerEnd:"url(#connectionArrow)"}),e.jsx("circle",{cx:X.sourcePosition.x,cy:X.sourcePosition.y,r:6,fill:"var(--nice-success, #10b981)"}),e.jsx("circle",{cx:X.previewPosition.x,cy:X.previewPosition.y,r:6,fill:"var(--nice-success, #10b981)",fillOpacity:.5,stroke:"var(--nice-success, #10b981)",strokeWidth:2}),e.jsx("defs",{children:e.jsx("marker",{id:"connectionArrow",markerWidth:"10",markerHeight:"10",refX:"9",refY:"3",orient:"auto",markerUnits:"strokeWidth",children:e.jsx("path",{d:"M0,0 L0,6 L9,3 z",fill:"var(--nice-success, #10b981)"})})})]}),[X]),Le=r.useCallback(()=>{if(!xe)return null;const x=xe.layers.find(U=>U.type==="network");if(!x)return null;const M=x.objects.filter(U=>U.type==="connection");if(M.length===0)return null;const P={"ethernet-cat5":{color:"var(--nice-primary, #3b82f6)",width:2},"ethernet-cat6":{color:"var(--nice-primary-hover, #2563eb)",width:2},"ethernet-cat6a":{color:"var(--nice-primary-dark, #1d4ed8)",width:2},"ethernet-cat7":{color:"var(--nice-primary-dark, #1e40af)",width:3},"fiber-single":{color:"var(--nice-warning, #f59e0b)",width:3},"fiber-multi":{color:"var(--nice-warning-dark, #d97706)",width:3},"wifi-2.4ghz":{color:"var(--nice-accent, #8b5cf6)",dashArray:"6,4",width:2},"wifi-5ghz":{color:"var(--nice-accent, #7c3aed)",dashArray:"6,4",width:2},"wifi-6ghz":{color:"var(--nice-accent-dark, #6d28d9)",dashArray:"6,4",width:2},default:{color:"var(--nice-text-secondary, #64748b)",width:2}},D={active:"var(--nice-success, #10b981)",inactive:"var(--nice-text-muted, #94a3b8)",error:"var(--nice-danger, #ef4444)",degraded:"var(--nice-warning, #f59e0b)",unknown:"var(--nice-text-secondary, #64748b)"};return e.jsx("g",{className:O.connectionsLayer,children:M.map(U=>{const Y=U.metadata;if(!(Y!=null&&Y.sourcePosition)||!(Y!=null&&Y.targetPosition))return null;const ae=P[Y.medium??"default"]||P.default,Se=D[Y.status??"unknown"]||D.unknown,He=ve.objectIds.includes(U.id);let jt=`M${Y.sourcePosition.x},${Y.sourcePosition.y}`;if(Y.waypoints&&Y.waypoints.length>0)for(const ot of Y.waypoints)jt+=` L${ot.x},${ot.y}`;return jt+=` L${Y.targetPosition.x},${Y.targetPosition.y}`,e.jsxs("g",{className:O.connection,onClick:ot=>{ot.stopPropagation(),m({type:"SET_SELECTION",selection:{objectIds:[U.id],bounds:null,locked:!1}})},children:[e.jsx("path",{d:jt,fill:"none",stroke:He?"var(--nice-primary-hover, #2563eb)":ae.color,strokeWidth:He?ae.width+1:ae.width,strokeDasharray:ae.dashArray,strokeLinecap:"round",strokeLinejoin:"round"}),Y.status&&Y.status!=="active"&&e.jsx("circle",{cx:(Y.sourcePosition.x+Y.targetPosition.x)/2,cy:(Y.sourcePosition.y+Y.targetPosition.y)/2,r:5,fill:Se}),e.jsx("circle",{cx:Y.sourcePosition.x,cy:Y.sourcePosition.y,r:4,fill:ae.color,stroke:"white",strokeWidth:1}),e.jsx("circle",{cx:Y.targetPosition.x,cy:Y.targetPosition.y,r:4,fill:ae.color,stroke:"white",strokeWidth:1})]},U.id)})})},[xe,ve.objectIds]);return!se&&!xe?e.jsx("div",{className:`${O.root} ${O[n]} ${b??""}`,style:p,children:e.jsxs("div",{className:O.emptyState,children:[e.jsx("div",{className:O.emptyIcon,children:qe.icon}),e.jsx("h3",{children:"No Document Open"}),e.jsx("p",{children:"Create a new document or open an existing .nsp.json file"}),e.jsx("button",{className:O.primaryBtn,onClick:()=>{const x=V.createFloorPlanDocument("New Project","floor-plan");m({type:"SET_DOCUMENT",document:x})},children:"Create New Document"})]})}):e.jsxs("div",{className:`nice-spatial-editor ${O.root} ${O[n]} ${b??""}`,style:{position:"relative",...p},tabIndex:0,onKeyDown:yt,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:30},children:e.jsx(Me.NiceTutorialButton,{steps:Me.resolveTutorial(C,Zi)})}),e.jsxs("div",{className:O.topBar,children:[e.jsx(Vi,{currentMode:je,availableModes:a,onModeChange:vt}),se&&se.floors.length>1&&e.jsx("div",{className:O.floorTabs,children:se.floors.map(x=>e.jsx("button",{className:`${O.floorTab} ${De===x.id?O.floorTabActive:""}`,onClick:()=>m({type:"SET_ACTIVE_FLOOR",floorId:x.id}),children:x.name},x.id))}),e.jsxs("div",{className:O.viewportControls,children:[!o&&e.jsxs(e.Fragment,{children:[e.jsx("button",{title:"Undo (Ctrl+Z)",onClick:()=>m({type:"UNDO"}),disabled:!st,className:st?"":O.disabled,children:"↶"}),e.jsx("button",{title:"Redo (Ctrl+Y)",onClick:()=>m({type:"REDO"}),disabled:!Xe,className:Xe?"":O.disabled,children:"↷"}),e.jsx("div",{className:O.separator})]}),e.jsx("button",{title:"Toggle Grid",onClick:()=>m({type:"TOGGLE_GRID"}),className:oe.showGrid?O.active:"",children:"⊞"}),e.jsx("button",{title:"Toggle Snap",onClick:()=>m({type:"TOGGLE_SNAP"}),className:oe.snapEnabled?O.active:"",children:"🧲"}),e.jsxs("span",{className:O.zoomLevel,children:[Math.round(oe.zoom*100),"%"]}),e.jsx("button",{title:"Zoom In",onClick:()=>m({type:"ZOOM",delta:1}),children:"+"}),e.jsx("button",{title:"Zoom Out",onClick:()=>m({type:"ZOOM",delta:-1}),children:"−"}),e.jsx("button",{title:"Reset View",onClick:()=>m({type:"RESET_VIEW"}),children:"⊡"}),!o&&e.jsxs("div",{className:O.exportDropdown,ref:Ee,children:[e.jsx("input",{type:"file",ref:Ie,onChange:gt,style:{display:"none"}}),e.jsx("button",{title:"Import",onClick:()=>ye(!de),className:de?O.active:"",children:"📥 Import"}),de&&e.jsxs("div",{className:O.exportMenu,children:[e.jsx("button",{onClick:()=>I(),children:"📄 Auto-detect format"}),e.jsx("button",{onClick:()=>I("dxf"),children:"📐 AutoCAD DXF (.dxf)"}),e.jsx("button",{onClick:()=>I("svg"),children:"🖼️ SVG Vector Graphics (.svg)"}),e.jsx("button",{onClick:()=>I("geojson"),children:"🌍 GeoJSON (.geojson)"}),e.jsx("button",{onClick:()=>I("ifc"),children:"🏗️ IFC (BIM) (.ifc)"})]})]}),se&&e.jsxs("div",{className:O.exportDropdown,ref:$e,children:[e.jsx("button",{title:"Export",onClick:()=>ue(!me),className:me?O.active:"",children:"📤 Export"}),me&&e.jsxs("div",{className:O.exportMenu,children:[e.jsx("button",{onClick:()=>Ve("nsp"),children:"📄 NiceToDev Spatial Plan (.nsp.json)"}),e.jsx("button",{onClick:()=>Ve("svg"),children:"🖼️ SVG Vector Graphics (.svg)"}),e.jsx("button",{onClick:()=>Ve("dxf"),children:"📐 AutoCAD DXF (.dxf)"}),e.jsx("button",{onClick:()=>Ve("png"),children:"🖼️ PNG Image (.png)"})]})]})]})]}),e.jsxs("div",{className:O.mainContent,children:[Pe.showObjectLibrary&&!o&&e.jsx(Xt,{mode:je,onObjectSelect:x=>{m({type:"SET_TOOL",tool:`place-${x.category}`}),m({type:"START_DRAG",objectType:x.category,objectData:x})}}),e.jsxs("div",{className:O.editorContainer,children:[!o&&e.jsx(Fi,{mode:je,activeTool:he,onToolSelect:ft,readOnly:o}),(je==="network-topology"||je==="infrastructure")&&e.jsxs("div",{className:O.modeActions,children:[e.jsx("button",{className:`${O.actionBtn} ${Ne?O.active:""}`,onClick:()=>ke(!Ne),title:"Analiza ścieżki sieciowej",children:"📊 Analiza ścieżki"}),e.jsx("button",{className:`${O.actionBtn} ${fe?O.active:""}`,onClick:()=>Te(!fe),title:"Nakładka VLAN",children:"🌐 VLAN Overlay"})]}),e.jsxs("div",{className:O.canvasWrapper,children:[e.jsx("svg",{ref:A,className:`${O.canvas} ${O[`cursor_${he.replace("-","_")}`]??""}`,onMouseDown:pt,onMouseMove:_t,onMouseUp:ht,onDoubleClick:mt,onWheel:xt,children:e.jsxs("g",{transform:`translate(${oe.pan.x}, ${oe.pan.y}) scale(${oe.zoom})`,children:[K(),le(),Le(),J(),pe(),ge()]})}),Pe.showMinimap&&e.jsx(Kt,{document:se,activeFloorId:De,viewport:oe,onViewportChange:x=>m({type:"SET_VIEWPORT",viewport:x})})]})]}),e.jsxs("div",{className:O.rightSidebar,children:[Pe.showLayerPanel&&e.jsx(Yt,{layers:we.filter(x=>qe.layerTypes.includes(x.type)),onVisibilityToggle:x=>{var M;return m({type:"SET_LAYER_VISIBILITY",layerType:x,visible:!((M=we.find(P=>P.type===x))!=null&&M.visible)})},onLockToggle:x=>{var M;return m({type:"SET_LAYER_LOCKED",layerType:x,locked:!((M=we.find(P=>P.type===x))!=null&&M.locked)})},onOpacityChange:(x,M)=>m({type:"SET_LAYER_OPACITY",layerType:x,opacity:M})}),Pe.showPropertiesPanel&&ve.objectIds.length>0&&e.jsx(Jt,{selection:ve,document:se,onPropertyChange:(x,M,P)=>{m({type:"UPDATE_OBJECT",objectId:x,updates:{[M]:P}})}})]})]}),e.jsxs("div",{className:O.statusBar,children:[e.jsxs("span",{className:O.modeIndicator,children:[qe.icon," ",qe.label]}),e.jsxs("span",{className:O.toolIndicator,children:[(St=Ct[he])==null?void 0:St.icon," ",(Lt=Ct[he])==null?void 0:Lt.label]}),ve.objectIds.length>0&&e.jsxs("span",{className:O.selectionInfo,children:[ve.objectIds.length," selected"]}),_e.active&&e.jsxs("span",{className:O.drawingInfo,children:["Drawing: ",_e.points.length," points"]}),X.active&&e.jsx("span",{className:O.connectingInfo,children:"Connecting: click target device or ESC to cancel"}),e.jsxs("span",{className:O.gridInfo,children:["Grid: ",oe.gridSize,"px | Snap: ",oe.snapEnabled?"ON":"OFF"]})]}),ce&&!F&&e.jsx(Pn,{result:ce,onConfirm:bt,onCancel:nt}),ce&&F&&e.jsx(lo,{importResult:ce,existingDocument:se??void 0,onConfirm:_,onCancel:z}),Ne&&se&&e.jsx(wa,{document:se,connections:Dt(se),onHighlightPath:x=>{m(x?{type:"SET_SELECTION",selection:{objectIds:x.connectionIds,bounds:null,locked:!1}}:{type:"SET_SELECTION",selection:{objectIds:[],bounds:null,locked:!1}})},onClose:()=>ke(!1)}),fe&&se&&e.jsx(hr,{document:se,connections:Dt(se),vlans:Hi(se),visibleVlanIds:Be,onVlanVisibilityChange:(x,M)=>{Ge(P=>{const D=new Set(P);return M?D.add(x):D.delete(x),D})},onHighlightVlan:x=>{Oe((x==null?void 0:x.id)??null),m(x?{type:"SET_SELECTION",selection:{objectIds:x.deviceIds,bounds:null,locked:!1}}:{type:"SET_SELECTION",selection:{objectIds:[],bounds:null,locked:!1}})},onClose:()=>Te(!1)})]})},Ki="_viewer_fazwr_13",Xi="_theme_light_fazwr_37",Ji="_theme_dark_fazwr_59",Qi="_debugOverlay_fazwr_85",el="_topBar_fazwr_137",tl="_searchContainer_fazwr_159",sl="_searchInput_fazwr_171",nl="_clearBtn_fazwr_227",ol="_searchResults_fazwr_261",al="_searchResultItem_fazwr_291",cl="_searchResultInfo_fazwr_335",rl="_searchResultName_fazwr_347",il="_searchResultDesc_fazwr_357",ll="_floorSelector_fazwr_371",dl="_navBtn_fazwr_421",ul="_active_fazwr_459",pl="_layersBtn_fazwr_475",_l="_legendBtn_fazwr_529",hl="_content_fazwr_583",ml="_navPanel_fazwr_599",xl="_navPanelHeader_fazwr_617",yl="_routeInputs_fazwr_671",vl="_routeInput_fazwr_671",fl="_routeMarker_fazwr_705",gl="_routeHint_fazwr_745",bl="_routeInfo_fazwr_761",jl="_routeStat_fazwr_779",wl="_routeStatLabel_fazwr_791",Nl="_routeStatValue_fazwr_805",kl="_clearRouteBtn_fazwr_817",Cl="_refPointsList_fazwr_851",Il="_refPointItem_fazwr_879",Sl="_refPointIcon_fazwr_917",Ll="_layersPanel_fazwr_929",zl="_layersPanelHeader_fazwr_947",Tl="_layersList_fazwr_1001",Bl="_layerItem_fazwr_1015",$l="_layerToggle_fazwr_1039",Pl="_layerName_fazwr_1075",Ml="_layerType_fazwr_1087",Ol="_canvasWrapper_fazwr_1101",Al="_canvas_fazwr_1101",El="_grid_fazwr_1137",Dl="_gridLine_fazwr_1145",Rl="_zonesLayer_fazwr_1161",Gl="_zone_fazwr_1161",Wl="_zoneSelected_fazwr_1185",ql="_zoneLabel_fazwr_1195",Fl="_objectsLayer_fazwr_1211",Vl="_object_fazwr_1211",Hl="_objectSelected_fazwr_1233",Ul="_objectLabel_fazwr_1241",Zl="_referencePoints_fazwr_1257",Yl="_referencePoint_fazwr_1257",Kl="_refLabel_fazwr_1277",Xl="_routeLayer_fazwr_1293",Jl="_routePath_fazwr_1297",Ql="_routeDash_fazwr_1",ed="_routeMarkers_fazwr_1323",td="_currentLocation_fazwr_1331",sd="_locationPulse_fazwr_1335",nd="_pulse_fazwr_1",od="_zoomControls_fazwr_1369",ad="_minimap_fazwr_1445",cd="_minimapContent_fazwr_1471",rd="_minimapViewport_fazwr_1485",id="_legendPanel_fazwr_1505",ld="_legendPanelHeader_fazwr_1537",dd="_legendList_fazwr_1593",ud="_legendItem_fazwr_1609",pd="_legendColor_fazwr_1633",_d="_legendIcon_fazwr_1649",hd="_legendLabel_fazwr_1663",md="_legendType_fazwr_1675",xd="_objectInfo_fazwr_1693",yd="_objectInfoHeader_fazwr_1721",vd="_navigateBtn_fazwr_1791",L={viewer:Ki,theme_light:Xi,theme_dark:Ji,debugOverlay:Qi,topBar:el,searchContainer:tl,searchInput:sl,clearBtn:nl,searchResults:ol,searchResultItem:al,searchResultInfo:cl,searchResultName:rl,searchResultDesc:il,floorSelector:ll,navBtn:dl,active:ul,layersBtn:pl,legendBtn:_l,content:hl,navPanel:ml,navPanelHeader:xl,routeInputs:yl,routeInput:vl,routeMarker:fl,routeHint:gl,routeInfo:bl,routeStat:jl,routeStatLabel:wl,routeStatValue:Nl,clearRouteBtn:kl,refPointsList:Cl,refPointItem:Il,refPointIcon:Sl,layersPanel:Ll,layersPanelHeader:zl,layersList:Tl,layerItem:Bl,layerToggle:$l,layerName:Pl,layerType:Ml,canvasWrapper:Ol,canvas:Al,grid:El,gridLine:Dl,zonesLayer:Rl,zone:Gl,zoneSelected:Wl,zoneLabel:ql,objectsLayer:Fl,object:Vl,objectSelected:Hl,objectLabel:Ul,referencePoints:Zl,referencePoint:Yl,refLabel:Kl,routeLayer:Xl,routePath:Jl,routeDash:Ql,routeMarkers:ed,currentLocation:td,locationPulse:sd,pulse:nd,zoomControls:od,minimap:ad,minimapContent:cd,minimapViewport:rd,legendPanel:id,legendPanelHeader:ld,legendList:dd,legendItem:ud,legendColor:pd,legendIcon:_d,legendLabel:hd,legendType:md,objectInfo:xd,objectInfoHeader:yd,navigateBtn:vd},fd=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("circle",{cx:"7",cy:"7",r:"5"}),e.jsx("path",{d:"M11 11l3 3",strokeLinecap:"round"})]}),Rt=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{d:"M8 1l6 14-6-4-6 4 6-14z"})}),gd=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("circle",{cx:"8",cy:"6",r:"3"}),e.jsx("path",{d:"M8 15c4-4 6-6.7 6-9a6 6 0 10-12 0c0 2.3 2 5 6 9z"})]}),bd=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("rect",{x:"2",y:"2",width:"12",height:"12",rx:"1"}),e.jsx("line",{x1:"2",y1:"6",x2:"14",y2:"6"}),e.jsx("line",{x1:"2",y1:"10",x2:"14",y2:"10"})]}),jd=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("circle",{cx:"4",cy:"4",r:"2"}),e.jsx("circle",{cx:"12",cy:"12",r:"2"}),e.jsx("path",{d:"M6 4h4a2 2 0 012 2v4",strokeLinecap:"round"})]}),wd=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("circle",{cx:"7",cy:"7",r:"5"}),e.jsx("path",{d:"M11 11l3 3M7 5v4M5 7h4",strokeLinecap:"round"})]}),Nd=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("circle",{cx:"7",cy:"7",r:"5"}),e.jsx("path",{d:"M11 11l3 3M5 7h4",strokeLinecap:"round"})]}),Je=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{d:"M12 4L4 12M4 4l8 8",strokeLinecap:"round"})}),Gt=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("path",{d:"M2 6l6-4 6 4-6 4-6-4z"}),e.jsx("path",{d:"M2 10l6 4 6-4"}),e.jsx("path",{d:"M2 8l6 4 6-4",opacity:"0.5"})]}),Wt=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("rect",{x:"2",y:"3",width:"4",height:"3",rx:"0.5",fill:"currentColor",opacity:"0.3"}),e.jsx("rect",{x:"2",y:"8",width:"4",height:"3",rx:"0.5",fill:"currentColor",opacity:"0.3"}),e.jsx("line",{x1:"8",y1:"4.5",x2:"14",y2:"4.5"}),e.jsx("line",{x1:"8",y1:"9.5",x2:"14",y2:"9.5"})]}),kd=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("path",{d:"M1 8c1.5-3 4-5 7-5s5.5 2 7 5c-1.5 3-4 5-7 5s-5.5-2-7-5z"}),e.jsx("circle",{cx:"8",cy:"8",r:"2"})]}),Cd=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("path",{d:"M6.5 6.5a2 2 0 012.8 2.8M3 3l10 10",strokeLinecap:"round"}),e.jsx("path",{d:"M4.5 5.5C2.8 6.8 1.5 8 1 8c1.5 3 4 5 7 5 1 0 2-.3 3-.7"}),e.jsx("path",{d:"M12.5 9.5c1-.9 2-2 2.5-3-1.5-3-4-5-7-5-.6 0-1.2.1-1.8.2"})]});function Id(t,s){return Math.sqrt((s.x-t.x)**2+(s.y-t.y)**2)}function Sd(t){return t<1?"<1m":t<1e3?`${Math.round(t)}m`:`${(t/1e3).toFixed(1)}km`}function Ld(t){if(t<60)return"<1 min";const s=Math.round(t/60);if(s<60)return`${s} min`;const a=Math.floor(s/60),o=s%60;return`${a}h ${o}min`}const zd=({document:t,initialFloorId:s,showNavigation:a=!0,showMinimap:o=!0,showFloorSelector:n=!0,showSearch:c=!0,showLayersPanel:l=!0,showLegend:y=!0,enableRoutePlanning:v=!0,referencePoints:k=[],onObjectClick:d,onRouteCalculated:C,currentLocation:b,theme:p="light",className:N,virtualRendering:u,virtualRenderingThreshold:w=200,debugVirtualRendering:T=!1})=>{var nt;const[i,h]=r.useState(s??((nt=t.floors[0])==null?void 0:nt.id)??""),[j,f]=r.useState({zoom:1,pan:{x:0,y:0}}),[g,m]=r.useState(""),[A,H]=r.useState([]),[W,me]=r.useState(null),[ue,de]=r.useState(null),[ye,ne]=r.useState(null),[re,ce]=r.useState(null),[S,F]=r.useState(!1),[ie,Ne]=r.useState(!1),[ke,fe]=r.useState(!1),[Te,Be]=r.useState(new Map),[Ge,tt]=r.useState({width:1e3,height:600}),Oe=r.useRef(null),$e=r.useRef(null),Ee=r.useRef(!1),Ie=r.useRef({x:0,y:0}),je=r.useMemo(()=>{const _=t.floors.find(z=>z.id===i);return _?_.layers.reduce((z,I)=>{var K;return z+(((K=I.objects)==null?void 0:K.length)??0)},0):0},[t.floors,i]),he=u??V.shouldUseVirtualRendering(je,w),se=r.useMemo(()=>{if(!he)return null;const _=t.floors.find(I=>I.id===i);if(!_)return null;const z=[];for(const I of _.layers)if(!(I.type==="zones"||I.type==="grid"||I.type==="background"))for(const K of I.objects??[]){const le=K.position??{x:0,y:0},J=K.size??{width:20,height:20};z.push({id:K.id,position:le,size:J,data:{object:K,layerId:I.id}})}return V.createFloorPlanQuadTree(z)},[t.floors,i,he]),De=r.useMemo(()=>V.calculateVisibleBounds(j,Ge,100),[j,Ge]),we=r.useMemo(()=>!he||!se?null:se.query(De),[he,se,De]),ve=r.useMemo(()=>!T||!he?null:V.calculateRenderStats(je,(we==null?void 0:we.length)??je,j),[T,he,je,we,j]);r.useEffect(()=>{const _=$e.current;if(!_)return;const z=new ResizeObserver(I=>{for(const K of I)tt({width:K.contentRect.width,height:K.contentRect.height})});return z.observe(_),()=>z.disconnect()},[]),r.useEffect(()=>{const _=t.floors.find(z=>z.id===i);if(_){const z=new Map;for(const I of _.layers)z.set(I.id,Te.get(I.id)??!0);Be(z)}},[i,t.floors]);const oe=r.useCallback(_=>{Be(z=>{const I=new Map(z);return I.set(_,!z.get(_)),I})},[]),_e=r.useCallback(_=>Te.get(_)!==!1,[Te]),X=r.useMemo(()=>t.floors.find(_=>_.id===i)??t.floors[0],[t.floors,i]),We=r.useMemo(()=>{if(!X)return[];const _=[],z=X.layers.find(J=>J.type==="zones");if(z){const J=new Map;for(const pe of z.objects){const ge=pe.metadata,Le=(ge==null?void 0:ge.zoneType)??pe.type??"zone";J.has(Le)||J.set(Le,(ge==null?void 0:ge.fill)??"var(--nice-primary, #3b82f6)")}for(const[pe,ge]of J)_.push({id:`zone-${pe}`,label:pe.charAt(0).toUpperCase()+pe.slice(1).replace(/-/g," "),color:ge,type:"zone"})}const I=new Map;for(const J of X.layers)if(!(J.type==="zones"||J.type==="grid"||J.type==="background"))for(const pe of J.objects){const ge=pe.type??"object",Le=I.get(ge);Le?Le.count++:I.set(ge,{count:1,color:"var(--nice-text-secondary, #64748b)"})}for(const[J,pe]of I)_.push({id:`obj-${J}`,label:`${J.charAt(0).toUpperCase()+J.slice(1).replace(/-/g," ")} (${pe.count})`,color:pe.color,type:"object"});const K=new Map,le={entrance:"🚪",elevator:"🛗",stairs:"🪜",exit:"🚨",poi:"📍",parking:"🅿️"};for(const J of k.filter(pe=>pe.floorId===i))K.has(J.type)||K.set(J.type,le[J.type]??"📍");for(const[J,pe]of K)_.push({id:`ref-${J}`,label:J.charAt(0).toUpperCase()+J.slice(1),color:"var(--nice-primary, #3b82f6)",icon:pe,type:"reference"});return _},[X,k,i]),Pe=r.useCallback((_,z)=>{var K;const I=(K=Oe.current)==null?void 0:K.getBoundingClientRect();return I?{x:(_-I.left-j.pan.x)/j.zoom,y:(z-I.top-j.pan.y)/j.zoom}:{x:0,y:0}},[j]);r.useEffect(()=>{if(!g.trim()){H([]);return}const _=g.toLowerCase(),z=[];for(const I of t.floors)for(const K of I.layers)for(const le of K.objects){const J=(le.name??le.id).toLowerCase(),pe=(le.description??"").toLowerCase();(J.includes(_)||pe.includes(_))&&z.push(le)}H(z.slice(0,10))},[g,t.floors]);const Ke=r.useCallback((_,z)=>{const I=Id(_,z);return{id:`route-${Date.now()}`,startPoint:_,endPoint:z,path:[_,z],floorTransitions:[],totalDistance:I,estimatedTime:I/1.4,instructions:[{type:"straight",distance:I,direction:"forward"},{type:"arrive"}]}},[]);r.useEffect(()=>{if(ue&&ye){const _=Ke(ue,ye);ce(_),C==null||C(_)}else ce(null),C==null||C(null)},[ue,ye,Ke,C]);const qe=r.useCallback(_=>{(_.button===1||_.button===0&&_.altKey)&&(Ee.current=!0,Ie.current={x:_.clientX,y:_.clientY},_.preventDefault())},[]),st=r.useCallback(_=>{if(Ee.current){const z=_.clientX-Ie.current.x,I=_.clientY-Ie.current.y;Ie.current={x:_.clientX,y:_.clientY},f(K=>({...K,pan:{x:K.pan.x+z,y:K.pan.y+I}}))}},[]),Xe=r.useCallback(()=>{Ee.current=!1},[]),xe=r.useCallback(_=>{var J;_.preventDefault();const z=_.deltaY>0?.9:1.1,I=(J=Oe.current)==null?void 0:J.getBoundingClientRect();if(!I)return;const K=_.clientX-I.left,le=_.clientY-I.top;f(pe=>{const ge=Math.min(Math.max(pe.zoom*z,.1),10),Le=ge/pe.zoom;return{zoom:ge,pan:{x:K-(K-pe.pan.x)*Le,y:le-(le-pe.pan.y)*Le}}})},[]),Ae=r.useCallback(_=>{if(v&&_.ctrlKey){const z=Pe(_.clientX,_.clientY);ue?ye?(de(z),ne(null)):ne(z):de(z)}},[v,ue,ye,Pe]),Fe=r.useCallback(()=>{f(_=>({..._,zoom:Math.min(_.zoom*1.25,10)}))},[]),pt=r.useCallback(()=>{f(_=>({..._,zoom:Math.max(_.zoom/1.25,.1)}))},[]),_t=r.useCallback(()=>{f({zoom:1,pan:{x:0,y:0}})},[]),ht=r.useCallback(_=>{me(_);for(const I of t.floors)for(const K of I.layers)if(K.objects.find(le=>le.id===_.id)){h(I.id);break}const z=_.position??{x:0,y:0};f(I=>({...I,pan:{x:-(z.x*I.zoom)+400,y:-(z.y*I.zoom)+300}})),m(""),H([]),d==null||d(_)},[t.floors,d]),mt=r.useCallback(()=>{de(null),ne(null),ce(null)},[]),xt=r.useCallback(()=>{const z=[];for(let I=-2e3;I<=2e3;I+=50)z.push(e.jsx("line",{x1:I,y1:-2e3,x2:I,y2:2e3,className:L.gridLine},`v-${I}`));for(let I=-2e3;I<=2e3;I+=50)z.push(e.jsx("line",{x1:-2e3,y1:I,x2:2e3,y2:I,className:L.gridLine},`h-${I}`));return e.jsx("g",{className:L.grid,children:z})},[]),yt=r.useCallback(()=>{if(!X)return null;const _=X.layers.find(z=>z.type==="zones");return!_||!_e(_.id)?null:e.jsx("g",{className:L.zonesLayer,children:_.objects.map(z=>{const I=z.metadata;if(!(I!=null&&I.points)||I.points.length<3)return null;const K=`M${I.points.map(J=>`${J.x},${J.y}`).join(" L")} Z`,le=(W==null?void 0:W.id)===z.id;return e.jsxs("g",{className:`${L.zone} ${le?L.zoneSelected:""}`,onClick:()=>{me(z),d==null||d(z)},children:[e.jsx("path",{d:K,fill:I.fill??"var(--nice-primary, #3b82f6)",fillOpacity:.2,stroke:I.fill??"var(--nice-primary, #3b82f6)",strokeWidth:le?2:1}),z.name&&e.jsx("text",{x:I.points[0].x+10,y:I.points[0].y+20,className:L.zoneLabel,children:z.name})]},z.id)})})},[X,W,d,_e]),vt=r.useCallback(()=>X?he&&we?e.jsx("g",{className:L.objectsLayer,children:we.map(_=>{const{object:z,layerId:I}=_.data;if(!_e(I))return null;const K=z.position??{x:0,y:0},le=z.size??{width:20,height:20},J=(W==null?void 0:W.id)===z.id;return e.jsxs("g",{className:`${L.object} ${J?L.objectSelected:""}`,transform:`translate(${K.x}, ${K.y})`,onClick:pe=>{pe.stopPropagation(),me(z),d==null||d(z)},children:[e.jsx("rect",{x:-le.width/2,y:-le.height/2,width:le.width,height:le.height,rx:4,fill:J?"var(--nice-primary, #3b82f6)":"var(--nice-text-secondary, #64748b)",fillOpacity:.8,stroke:J?"var(--nice-primary-dark, #1d4ed8)":"transparent",strokeWidth:2}),z.name&&e.jsx("text",{y:le.height/2+14,textAnchor:"middle",className:L.objectLabel,children:z.name})]},z.id)})}):e.jsx("g",{className:L.objectsLayer,children:X.layers.map(_=>_.type==="zones"||_.type==="grid"||_.type==="background"||!_e(_.id)?null:_.objects.map(z=>{const I=z.position??{x:0,y:0},K=z.size??{width:20,height:20},le=(W==null?void 0:W.id)===z.id;return e.jsxs("g",{className:`${L.object} ${le?L.objectSelected:""}`,transform:`translate(${I.x}, ${I.y})`,onClick:J=>{J.stopPropagation(),me(z),d==null||d(z)},children:[e.jsx("rect",{x:-K.width/2,y:-K.height/2,width:K.width,height:K.height,rx:4,fill:le?"var(--nice-primary, #3b82f6)":"var(--nice-text-secondary, #64748b)",fillOpacity:.8,stroke:le?"var(--nice-primary-dark, #1d4ed8)":"transparent",strokeWidth:2}),z.name&&e.jsx("text",{y:K.height/2+14,textAnchor:"middle",className:L.objectLabel,children:z.name})]},z.id)}))}):null,[X,W,d,_e,he,we]),ft=r.useCallback(()=>{const _=k.filter(I=>I.floorId===i),z={entrance:"🚪",elevator:"🛗",stairs:"🪜",exit:"🚨",poi:"📍",parking:"🅿️"};return e.jsx("g",{className:L.referencePoints,children:_.map(I=>e.jsxs("g",{className:L.referencePoint,transform:`translate(${I.position.x}, ${I.position.y})`,onClick:()=>{v&&(ue?ne(I.position):de(I.position))},children:[e.jsx("circle",{r:16,fill:"white",stroke:"var(--nice-primary, #3b82f6)",strokeWidth:2}),e.jsx("text",{y:5,textAnchor:"middle",fontSize:"16",children:I.icon??z[I.type]??"📍"}),e.jsx("text",{y:30,textAnchor:"middle",className:L.refLabel,children:I.name})]},I.id))})},[k,i,v,ue]),Ve=r.useCallback(()=>{if(!re)return null;const _=`M${re.path.map(z=>`${z.x},${z.y}`).join(" L")}`;return e.jsxs("g",{className:L.routeLayer,children:[e.jsx("path",{d:_,fill:"none",stroke:"var(--nice-primary, #3b82f6)",strokeWidth:4,strokeLinecap:"round",strokeLinejoin:"round",strokeDasharray:"12,6",className:L.routePath}),e.jsx("circle",{cx:re.startPoint.x,cy:re.startPoint.y,r:8,fill:"var(--nice-success, #10b981)",stroke:"white",strokeWidth:2}),e.jsx("circle",{cx:re.endPoint.x,cy:re.endPoint.y,r:8,fill:"var(--nice-danger, #ef4444)",stroke:"white",strokeWidth:2})]})},[re]),gt=r.useCallback(()=>b?e.jsxs("g",{className:L.currentLocation,children:[e.jsx("circle",{cx:b.x,cy:b.y,r:12,fill:"var(--nice-primary, #3b82f6)",fillOpacity:.3,className:L.locationPulse}),e.jsx("circle",{cx:b.x,cy:b.y,r:6,fill:"var(--nice-primary, #3b82f6)",stroke:"white",strokeWidth:2})]}):null,[b]),bt=r.useCallback(()=>e.jsx("g",{className:L.routeMarkers,children:ue&&!re&&e.jsx("circle",{cx:ue.x,cy:ue.y,r:8,fill:"var(--nice-success, #10b981)",stroke:"white",strokeWidth:2})}),[ue,re]);return e.jsxs("div",{ref:$e,className:`${L.viewer} ${L[`theme_${p}`]} ${N??""}`,children:[T&&ve&&e.jsxs("div",{className:L.debugOverlay,children:[e.jsx("div",{children:"Virtual: ON"}),e.jsxs("div",{children:["Total: ",ve.total]}),e.jsxs("div",{children:["Visible: ",ve.visible]}),e.jsxs("div",{children:["Culled: ",ve.culled," (",ve.cullPercentage,"%)"]}),e.jsxs("div",{children:["Zoom: ",ve.zoom.toFixed(2),"x"]})]}),e.jsxs("div",{className:L.topBar,children:[c&&e.jsxs("div",{className:L.searchContainer,children:[e.jsxs("div",{className:L.searchInput,children:[e.jsx(fd,{}),e.jsx("input",{type:"text",placeholder:"Szukaj lokalizacji...",value:g,onChange:_=>m(_.target.value)}),g&&e.jsx("button",{className:L.clearBtn,onClick:()=>m(""),children:e.jsx(Je,{})})]}),A.length>0&&e.jsx("div",{className:L.searchResults,children:A.map(_=>e.jsxs("button",{className:L.searchResultItem,onClick:()=>ht(_),children:[e.jsx(gd,{}),e.jsxs("div",{className:L.searchResultInfo,children:[e.jsx("span",{className:L.searchResultName,children:_.name??_.id}),_.description&&e.jsx("span",{className:L.searchResultDesc,children:_.description})]})]},_.id))})]}),n&&t.floors.length>1&&e.jsxs("div",{className:L.floorSelector,children:[e.jsx(bd,{}),e.jsx("select",{value:i,onChange:_=>h(_.target.value),children:t.floors.map(_=>e.jsx("option",{value:_.id,children:_.name??`Piętro ${_.level}`},_.id))})]}),a&&e.jsxs("button",{className:`${L.navBtn} ${S?L.active:""}`,onClick:()=>F(!S),children:[e.jsx(Rt,{}),e.jsx("span",{children:"Nawigacja"})]}),l&&e.jsxs("button",{className:`${L.layersBtn} ${ie?L.active:""}`,onClick:()=>Ne(!ie),children:[e.jsx(Gt,{}),e.jsx("span",{children:"Warstwy"})]}),y&&e.jsxs("button",{className:`${L.legendBtn} ${ke?L.active:""}`,onClick:()=>fe(!ke),children:[e.jsx(Wt,{}),e.jsx("span",{children:"Legenda"})]})]}),e.jsxs("div",{className:L.content,children:[S&&e.jsxs("div",{className:L.navPanel,children:[e.jsxs("div",{className:L.navPanelHeader,children:[e.jsx(jd,{}),e.jsx("span",{children:"Planowanie trasy"}),e.jsx("button",{onClick:()=>F(!1),children:e.jsx(Je,{})})]}),e.jsxs("div",{className:L.routeInputs,children:[e.jsxs("div",{className:L.routeInput,children:[e.jsx("div",{className:L.routeMarker,style:{background:"var(--nice-success, #10b981)"}}),e.jsx("input",{type:"text",placeholder:"Punkt startowy",value:ue?`${ue.x.toFixed(0)}, ${ue.y.toFixed(0)}`:"",readOnly:!0})]}),e.jsxs("div",{className:L.routeInput,children:[e.jsx("div",{className:L.routeMarker,style:{background:"var(--nice-danger, #ef4444)"}}),e.jsx("input",{type:"text",placeholder:"Punkt docelowy",value:ye?`${ye.x.toFixed(0)}, ${ye.y.toFixed(0)}`:"",readOnly:!0})]})]}),e.jsx("p",{className:L.routeHint,children:"Ctrl+kliknięcie na mapie, aby wybrać punkty"}),re&&e.jsxs("div",{className:L.routeInfo,children:[e.jsxs("div",{className:L.routeStat,children:[e.jsx("span",{className:L.routeStatLabel,children:"Dystans"}),e.jsx("span",{className:L.routeStatValue,children:Sd(re.totalDistance)})]}),e.jsxs("div",{className:L.routeStat,children:[e.jsx("span",{className:L.routeStatLabel,children:"Czas"}),e.jsx("span",{className:L.routeStatValue,children:Ld(re.estimatedTime)})]})]}),(ue||ye)&&e.jsx("button",{className:L.clearRouteBtn,onClick:mt,children:"Wyczyść trasę"}),k.length>0&&e.jsxs("div",{className:L.refPointsList,children:[e.jsx("h4",{children:"Punkty odniesienia"}),k.filter(_=>_.floorId===i).map(_=>e.jsxs("button",{className:L.refPointItem,onClick:()=>{ue?ne(_.position):de(_.position)},children:[e.jsx("span",{className:L.refPointIcon,children:_.icon??"📍"}),e.jsx("span",{children:_.name})]},_.id))]})]}),ie&&X&&e.jsxs("div",{className:L.layersPanel,children:[e.jsxs("div",{className:L.layersPanelHeader,children:[e.jsx(Gt,{}),e.jsx("span",{children:"Warstwy"}),e.jsx("button",{onClick:()=>Ne(!1),children:e.jsx(Je,{})})]}),e.jsx("div",{className:L.layersList,children:X.layers.map(_=>{const z=_e(_.id);return e.jsxs("div",{className:L.layerItem,children:[e.jsx("button",{className:L.layerToggle,onClick:()=>oe(_.id),title:z?"Ukryj warstwę":"Pokaż warstwę",children:z?e.jsx(kd,{}):e.jsx(Cd,{})}),e.jsx("span",{className:L.layerName,children:_.name??_.id}),e.jsxs("span",{className:L.layerType,children:["(",_.type,")"]})]},_.id)})})]}),e.jsxs("div",{className:L.canvasWrapper,children:[e.jsx("svg",{ref:Oe,className:L.canvas,onMouseDown:qe,onMouseMove:st,onMouseUp:Xe,onMouseLeave:Xe,onWheel:xe,onClick:Ae,children:e.jsxs("g",{transform:`translate(${j.pan.x}, ${j.pan.y}) scale(${j.zoom})`,children:[xt(),yt(),vt(),ft(),bt(),Ve(),gt()]})}),e.jsxs("div",{className:L.zoomControls,children:[e.jsx("button",{onClick:Fe,title:"Powiększ",children:e.jsx(wd,{})}),e.jsx("button",{onClick:pt,title:"Pomniejsz",children:e.jsx(Nd,{})}),e.jsx("button",{onClick:_t,title:"Resetuj widok",children:"⟲"})]}),o&&e.jsx("div",{className:L.minimap,children:e.jsx("div",{className:L.minimapContent,children:e.jsx("div",{className:L.minimapViewport})})}),ke&&We.length>0&&e.jsxs("div",{className:L.legendPanel,children:[e.jsxs("div",{className:L.legendPanelHeader,children:[e.jsx(Wt,{}),e.jsx("span",{children:"Legenda"}),e.jsx("button",{onClick:()=>fe(!1),children:e.jsx(Je,{})})]}),e.jsx("div",{className:L.legendList,children:We.map(_=>e.jsxs("div",{className:L.legendItem,children:[_.icon?e.jsx("span",{className:L.legendIcon,children:_.icon}):e.jsx("span",{className:L.legendColor,style:{background:_.color}}),e.jsx("span",{className:L.legendLabel,children:_.label}),e.jsx("span",{className:L.legendType,children:_.type==="zone"?"strefa":_.type==="object"?"obiekt":"punkt ref."})]},_.id))})]})]})]}),W&&e.jsxs("div",{className:L.objectInfo,children:[e.jsxs("div",{className:L.objectInfoHeader,children:[e.jsx("h4",{children:W.name??W.id}),e.jsx("button",{onClick:()=>me(null),children:e.jsx(Je,{})})]}),W.description&&e.jsx("p",{children:W.description}),v&&e.jsxs("button",{className:L.navigateBtn,onClick:()=>{const _=W.position??{x:0,y:0};ue?ne(_):de(_)},children:[e.jsx(Rt,{}),ue?"Ustaw jako cel":"Ustaw jako start"]})]})]})};function Td(t={}){var ye;const{initialDocument:s,defaultMode:a="floor-plan",gridSize:o=20,snapEnabled:n=!0,onChange:c}=t,l={mode:a,tool:"select",document:s??null,activeFloorId:((ye=s==null?void 0:s.floors[0])==null?void 0:ye.id)??null,layers:[],selection:{objectIds:[],bounds:null,locked:!1},viewport:{zoom:1,pan:{x:0,y:0},rotation:0,showGrid:!0,gridSize:o,snapEnabled:n,snapModes:["grid","endpoint","midpoint"]},drawing:{active:!1,points:[],preview:null},history:{past:[],future:[]},guides:[],dragging:null,connecting:{active:!1,sourceId:null,sourcePosition:null,previewPosition:null},clipboard:[],ui:{showObjectLibrary:!0,showLayerPanel:!0,showPropertiesPanel:!0,showMinimap:!0}},[y,v]=r.useReducer((ne,re)=>({...ne,...re}),l),k=r.useCallback(ne=>{v({mode:ne})},[]),d=r.useCallback(ne=>{v({tool:ne})},[]),C=r.useCallback((ne="Untitled")=>{var ce;const re=V.createFloorPlanDocument(ne,"floor-plan");v({document:re,activeFloorId:((ce=re.floors[0])==null?void 0:ce.id)??null}),c==null||c(re)},[c]),b=r.useCallback(ne=>{var re;v({document:ne,activeFloorId:((re=ne.floors[0])==null?void 0:re.id)??null}),c==null||c(ne)},[c]),p=r.useCallback(ne=>{v({viewport:{...y.viewport,zoom:Math.max(.1,Math.min(10,y.viewport.zoom*(1+ne*.1)))}})},[y.viewport]),N=r.useCallback(ne=>{v({viewport:{...y.viewport,pan:{x:y.viewport.pan.x+ne.x,y:y.viewport.pan.y+ne.y}}})},[y.viewport]),u=r.useCallback(()=>{v({viewport:{...y.viewport,zoom:1,pan:{x:0,y:0}}})},[y.viewport]),w=r.useCallback(()=>{v({viewport:{...y.viewport,showGrid:!y.viewport.showGrid}})},[y.viewport]),T=r.useCallback(()=>{v({viewport:{...y.viewport,snapEnabled:!y.viewport.snapEnabled}})},[y.viewport]),i=r.useCallback(ne=>{v({viewport:{...y.viewport,gridSize:ne}})},[y.viewport]),h=r.useCallback((ne,re)=>{v({layers:y.layers.map(ce=>ce.type===ne?{...ce,visible:re}:ce)})},[y.layers]),j=r.useCallback((ne,re)=>{v({layers:y.layers.map(ce=>ce.type===ne?{...ce,locked:re}:ce)})},[y.layers]),f=r.useCallback(ne=>{v({selection:{objectIds:ne,bounds:null,locked:!1}})},[]),g=r.useCallback(()=>{v({selection:{objectIds:[],bounds:null,locked:!1}})},[]),m=r.useCallback(()=>{},[]),A=r.useCallback(()=>{},[]),H=y.history.past.length>0,W=y.history.future.length>0,me=r.useCallback(()=>{},[]),ue=r.useCallback(ne=>{},[]),de=r.useCallback(()=>{},[]);return{state:y,setMode:k,setTool:d,newDocument:C,loadDocument:b,zoom:p,pan:N,resetView:u,toggleGrid:w,toggleSnap:T,setGridSize:i,setLayerVisible:h,setLayerLocked:j,select:f,clearSelection:g,undo:m,redo:A,canUndo:H,canRedo:W,copy:me,paste:ue,cut:de}}function Bd(t={}){const{gridSize:s=20,enabled:a=!0,snapModes:o=["grid","endpoint","midpoint"],objects:n=[],threshold:c=10}=t,l=r.useMemo(()=>({...V.DEFAULT_GRID_CONFIG,cellSize:s,snapModes:o,snapThreshold:c}),[s,o,c]),y=r.useMemo(()=>n.map((p,N)=>({id:`obj-${N}`,bounds:p})),[n]),v=r.useCallback(p=>a?V.snapToGrid(p,l):p,[a,l]),k=r.useCallback(p=>a?V.snapToGrid3D(p,s):p,[a,s]),d=r.useCallback(p=>{if(!a||y.length===0)return[];const N={x:p.x,y:p.y,width:0,height:0};return V.generateAlignmentGuides(N,y,c)},[a,y,c]),C=r.useCallback(p=>{if(!a)return{point:p,snapped:!1,guides:[]};const N=V.performSnap(p,y,l);return{point:N.position,snapped:N.snapped,guides:N.guides??[]}},[a,l,y]),b=r.useCallback((p,N)=>{const u=[];for(let w=0;w<=p;w+=s)u.push({x1:w,y1:0,x2:w,y2:N});for(let w=0;w<=N;w+=s)u.push({x1:0,y1:w,x2:p,y2:w});return u},[s]);return{snap:v,snap3D:k,getGuides:d,performAdvancedSnap:C,generateGridLines:b}}function $d(t={}){const{unitSystem:s="metric",lengthUnit:a="m",areaUnit:o="m2",angleUnit:n="deg",scale:c=100}=t,[l,y]=r.useState(null),[v,k]=r.useState([]),d=r.useCallback(g=>g/c,[c]),C=r.useCallback(g=>{y(g),k([])},[]),b=r.useCallback((g,m=!1)=>{k(A=>[...A,{position:g,snapped:m}])},[]),p=r.useCallback(()=>{y(null),k([])},[]),N=r.useCallback(()=>{if(!l||v.length<2)return null;const g=v.map(m=>m.position);if(l==="distance"&&v.length===2){const m=V.distance2D(g[0],g[1]),A=d(m);return{type:"distance",value:A,formatted:V.autoFormatLength(A,s).formatted,points:g}}if(l==="angle"&&v.length===3){const m=V.angleAtVertex(g[0],g[1],g[2]);return{type:"angle",value:m,formatted:V.formatAngle(m,n).formatted,points:g}}if(l==="area"&&v.length>=3){const A=V.polygonArea(g)/(c*c);return{type:"area",value:A,formatted:V.autoFormatArea(A,s).formatted,points:g}}return null},[l,v,c,s,n,d]),u=v.length>=2&&l==="distance"?V.autoFormatLength(d(V.distance2D(v[0].position,v[v.length-1].position)),s).formatted:null,w=v.length>=3&&l==="angle"?V.formatAngle(V.angleAtVertex(v[0].position,v[1].position,v[2].position),n).formatted:null,T=v.length>=3&&l==="area"?V.autoFormatArea(V.polygonArea(v.map(g=>g.position))/(c*c),s).formatted:null,i=r.useCallback((g,m)=>{const A=V.distance2D(g,m),H=d(A);return{value:H,formatted:V.autoFormatLength(H,s).formatted}},[d,s]),h=r.useCallback((g,m,A)=>{const H=V.angleAtVertex(g,m,A);return{value:H,formatted:V.formatAngle(H,n).formatted}},[n]),j=r.useCallback(g=>{const A=V.polygonArea(g)/(c*c);return{value:A,formatted:V.autoFormatArea(A,s).formatted}},[c,s]),f=r.useCallback(g=>{const m=V.polylineLength(g),A=d(m);return{value:A,formatted:V.autoFormatLength(A,s).formatted}},[d,s]);return{startMeasurement:C,addPoint:b,clearMeasurement:p,finishMeasurement:N,measurementType:l,points:v,liveDistance:u,liveAngle:w,liveArea:T,getDistance:i,getAngle:h,getArea:j,getLength:f}}const Pd="_root_1er3p_3",Md="_dark_1er3p_25",Od="_header_1er3p_31",Ad="_buildingInfo_1er3p_45",Ed="_buildingName_1er3p_49",Dd="_buildingAddress_1er3p_67",Rd="_modeSelector_1er3p_81",Gd="_modeBtn_1er3p_93",Wd="_modeBtnActive_1er3p_127",qd="_weather_1er3p_141",Fd="_weatherTemp_1er3p_155",Vd="_weatherDesc_1er3p_171",Hd="_statsRow_1er3p_183",Ud="_statsCard_1er3p_195",Zd="_statsHeader_1er3p_225",Yd="_statsIcon_1er3p_239",Kd="_statsLabel_1er3p_243",Xd="_statsValue_1er3p_257",Jd="_statsSub_1er3p_275",Qd="_zoneGrid_1er3p_289",eu="_zoneCard_1er3p_303",tu="_zoneOccupied_1er3p_347",su="_zoneCardHeader_1er3p_351",nu="_zoneCardIcon_1er3p_365",ou="_zoneCardTitles_1er3p_369",au="_zoneCardName_1er3p_379",cu="_zoneCardArea_1er3p_403",ru="_occupancyBadge_1er3p_413",iu="_occupancyBadgeOn_1er3p_431",lu="_sensorRow_1er3p_443",du="_sensorChip_1er3p_457",uu="_sensorWarn_1er3p_475",pu="_deviceList_1er3p_489",_u="_deviceChip_1er3p_501",hu="_deviceChipOn_1er3p_535",mu="_deviceChipName_1er3p_547",xu="_deviceChipVal_1er3p_561",yu="_moreBtn_1er3p_571",vu="_scenesBar_1er3p_597",fu="_sceneBarLabel_1er3p_627",gu="_sceneList_1er3p_645",bu="_sceneBtn_1er3p_657",ju="_sceneBtnActive_1er3p_683",q={root:Pd,dark:Md,header:Od,buildingInfo:Ad,buildingName:Ed,buildingAddress:Dd,modeSelector:Rd,modeBtn:Gd,modeBtnActive:Wd,weather:qd,weatherTemp:Fd,weatherDesc:Vd,statsRow:Hd,statsCard:Ud,statsHeader:Zd,statsIcon:Yd,statsLabel:Kd,statsValue:Xd,statsSub:Jd,zoneGrid:Qd,zoneCard:eu,zoneOccupied:tu,zoneCardHeader:su,zoneCardIcon:nu,zoneCardTitles:ou,zoneCardName:au,zoneCardArea:cu,occupancyBadge:ru,occupancyBadgeOn:iu,sensorRow:lu,sensorChip:du,sensorWarn:uu,deviceList:pu,deviceChip:_u,deviceChipOn:hu,deviceChipName:mu,deviceChipVal:xu,moreBtn:yu,scenesBar:vu,sceneBarLabel:fu,sceneList:gu,sceneBtn:bu,sceneBtnActive:ju},Qt={living_room:"🛋",bedroom:"🛏",master_bedroom:"🛏",kids_room:"🧸",bathroom:"🚿",kitchen:"🍳",dining_room:"🍽",hallway:"🚪",office:"💼",garage:"🚗",gym:"🏋",cinema:"🎬",balcony:"🌿",garden:"🌳",open_office:"💼",private_office:"🖥",meeting_room:"📋",boardroom:"🤝",reception:"🏢",server_room:"🖥",lobby:"🏛",corridor:"↔",stairwell:"🪜",parking:"🅿",break_room:"☕",it_room:"💻",cafeteria:"🍽"};function wu(t){return Qt[t]??"🏠"}function Nu(t){if(!t.state)return null;const s=t.state;return typeof s.brightness=="number"?`${s.brightness}%`:typeof s.on=="boolean"?s.on?"Wł":"Wył":typeof s.temperature=="number"?`${s.temperature.toFixed(1)}°`:typeof s.locked=="boolean"?s.locked?"🔒":"🔓":null}const es=({zone:t,devices:s=[],expanded:a=!1,onExpand:o,onDeviceControl:n,onClick:c,theme:l="light",className:y,style:v})=>{const k=t.occupancy!=null&&t.occupancy>0,d=a?s:s.slice(0,4);return e.jsxs("div",{className:`${q.zoneCard} ${l==="dark"?q.dark:""} ${k?q.zoneOccupied:""} ${y??""}`,style:v,onClick:c,children:[e.jsxs("div",{className:q.zoneCardHeader,children:[e.jsx("span",{className:q.zoneCardIcon,children:wu(t.type)}),e.jsxs("div",{className:q.zoneCardTitles,children:[e.jsx("span",{className:q.zoneCardName,children:t.name}),t.area!=null&&e.jsxs("span",{className:q.zoneCardArea,children:[t.area," m²"]})]}),t.occupancy!=null&&e.jsxs("span",{className:`${q.occupancyBadge} ${k?q.occupancyBadgeOn:""}`,children:["👥 ",t.occupancy]})]}),(t.temperature!=null||t.humidity!=null||t.co2!=null)&&e.jsxs("div",{className:q.sensorRow,children:[t.temperature!=null&&e.jsxs("span",{className:q.sensorChip,children:["🌡 ",t.temperature.toFixed(1),"°C"]}),t.humidity!=null&&e.jsxs("span",{className:q.sensorChip,children:["💧 ",t.humidity,"%"]}),t.co2!=null&&e.jsxs("span",{className:`${q.sensorChip} ${t.co2>1e3?q.sensorWarn:""}`,children:["CO₂ ",t.co2]})]}),d.length>0&&e.jsxs("div",{className:q.deviceList,children:[d.map(C=>{const b=C.state,p=(b==null?void 0:b.on)===!0||(b==null?void 0:b.locked)===!1;return e.jsxs("button",{className:`${q.deviceChip} ${p?q.deviceChipOn:""}`,onClick:N=>{N.stopPropagation(),n==null||n(C.id,{on:!p})},title:C.name,children:[e.jsx("span",{children:Qt[C.type]??"📟"}),e.jsx("span",{className:q.deviceChipName,children:C.name}),e.jsx("span",{className:q.deviceChipVal,children:Nu(C)})]},C.id)}),s.length>4&&e.jsx("button",{className:q.moreBtn,onClick:C=>{C.stopPropagation(),o==null||o()},children:a?"−":`+${s.length-4}`})]})]})},Nt={home:"Dom",away:"Wyjazd",night:"Noc",vacation:"Urlop",guest:"Gość",party:"Impreza",occupied:"Zajęty",closed:"Zamknięty",weekend:"Weekend",event:"Wydarzenie",emergency:"Alarm",maintenance:"Serwis"},qt={home:"🏠",away:"🚗",night:"🌙",vacation:"✈",guest:"👋",party:"🎉",occupied:"🏢",closed:"🔒",weekend:"☀",event:"🎉",emergency:"🚨",maintenance:"🔧"},ku=({temperature:t,description:s})=>t!=null?e.jsxs("div",{className:q.weather,children:[e.jsxs("span",{className:q.weatherTemp,children:[t,"°C"]}),s&&e.jsx("span",{className:q.weatherDesc,children:s})]}):null,lt=({label:t,value:s,sub:a,icon:o,accent:n})=>e.jsxs("div",{className:q.statsCard,style:n?{borderTopColor:n}:void 0,children:[e.jsxs("div",{className:q.statsHeader,children:[o&&e.jsx("span",{className:q.statsIcon,children:o}),e.jsx("span",{className:q.statsLabel,children:t})]}),e.jsx("div",{className:q.statsValue,children:s}),a&&e.jsx("div",{className:q.statsSub,children:a})]}),Cu=({building:t,state:s,onModeChange:a,onDeviceControl:o,onSceneActivate:n,onZoneClick:c,className:l,style:y,theme:v="light",weather:k})=>{var h,j,f;const[d,C]=r.useState(null);t.floors[0];const b=t.floors.flatMap(g=>g.zones??[]).filter(g=>g.type!=="hallway"&&g.type!=="corridor"),p=((h=s==null?void 0:s.activeAlerts)==null?void 0:h.length)??0,N=(j=s==null?void 0:s.energy)==null?void 0:j.currentPowerW,u=(f=s==null?void 0:s.energy)==null?void 0:f.todayKwh,w=s!=null&&s.occupancy?Object.values(s.occupancy).reduce((g,m)=>g+((m==null?void 0:m.occupancy)??0),0):null;t.floors.flatMap(g=>g.zones??[]).flatMap(g=>g.deviceIds??[]).slice(0,8);const T=t.type==="office"||t.type==="retail"?["occupied","closed","weekend","event","emergency","maintenance"]:["home","away","night","vacation","guest","emergency"],i=(s==null?void 0:s.mode)??"home";return e.jsxs("div",{className:`${q.root} ${v==="dark"?q.dark:""} ${l??""}`,style:y,children:[e.jsxs("div",{className:q.header,children:[e.jsxs("div",{className:q.buildingInfo,children:[e.jsx("h2",{className:q.buildingName,children:t.name}),t.address&&e.jsx("p",{className:q.buildingAddress,children:t.address})]}),e.jsx("div",{className:q.modeSelector,children:T.map(g=>e.jsxs("button",{title:Nt[g],className:`${q.modeBtn} ${i===g?q.modeBtnActive:""}`,onClick:()=>a==null?void 0:a(g),children:[qt[g],e.jsx("span",{children:Nt[g]})]},g))}),e.jsx(ku,{temperature:k==null?void 0:k.temperature,description:k==null?void 0:k.description})]}),e.jsxs("div",{className:q.statsRow,children:[N!=null&&e.jsx(lt,{icon:"⚡",label:"Moc",value:N>=1e3?`${(N/1e3).toFixed(2)} kW`:`${N} W`,sub:u!=null?`Dziś: ${u.toFixed(2)} kWh`:void 0,accent:"var(--nice-warning, #f59e0b)"}),w!=null&&e.jsx(lt,{icon:"👥",label:"Obecność",value:`${w} os.`,sub:`${b.length} stref`,accent:"var(--nice-success, #22c55e)"}),p>0&&e.jsx(lt,{icon:"🚨",label:"Alarmy",value:e.jsx("span",{style:{color:"var(--nice-danger, #ef4444)"},children:p}),sub:"aktywnych",accent:"var(--nice-danger, #ef4444)"}),e.jsx(lt,{icon:qt[i],label:"Tryb",value:Nt[i],accent:"var(--nice-accent, #8b5cf6)"})]}),e.jsx("div",{className:q.zoneGrid,children:b.map(g=>{const m=t.floors.flatMap(A=>(A.zones??[]).find(H=>H.id===g.id)?t.devices??[]:[]).filter(A=>A.zoneId===g.id);return e.jsx(es,{zone:g,devices:m,expanded:d===g.id,onExpand:()=>C(d===g.id?null:g.id),onDeviceControl:o,onClick:()=>c==null?void 0:c(g.id),theme:v},g.id)})}),t.scenes&&t.scenes.length>0&&e.jsxs("div",{className:q.scenesBar,children:[e.jsx("span",{className:q.sceneBarLabel,children:"Sceny"}),e.jsx("div",{className:q.sceneList,children:t.scenes.map(g=>{var m;return e.jsxs("button",{className:`${q.sceneBtn} ${(m=s==null?void 0:s.activeScenes)!=null&&m.includes(g.id)?q.sceneBtnActive:""}`,onClick:()=>n==null?void 0:n(g.id),children:[g.icon??"🎭"," ",g.name]},g.id)})})]})]})},Iu="_deviceControl_ev96o_3",Su="_dark_ev96o_23",Lu="_compact_ev96o_35",zu="_offline_ev96o_39",Tu="_offlineBanner_ev96o_43",Bu="_toggleControl_ev96o_67",$u="_toggleLabel_ev96o_81",Pu="_toggleBtn_ev96o_97",Mu="_toggleOn_ev96o_123",Ou="_blindControl_ev96o_137",Au="_blindLabel_ev96o_139",Eu="_blindActions_ev96o_143",Du="_blindBtn_ev96o_145",Ru="_blindSlider_ev96o_149",Gu="_blindPct_ev96o_151",Wu="_lockControl_ev96o_157",qu="_lockLabel_ev96o_159",Fu="_lockBtn_ev96o_163",Vu="_lockLocked_ev96o_165",Hu="_lockUnlocked_ev96o_167",Uu="_cameraControl_ev96o_173",Zu="_cameraLabel_ev96o_175",Yu="_cameraSnapshot_ev96o_179",Ku="_cameraPlaceholder_ev96o_181",Xu="_cameraStatus_ev96o_183",Ju="_cameraDot_ev96o_185",Qu="_cameraOnline_ev96o_187",ep="_cameraOffline_ev96o_189",tp="_sensorControl_ev96o_195",sp="_sensorLabel_ev96o_197",np="_sensorValues_ev96o_201",op="_sensorRow_ev96o_203",ap="_sensorKey_ev96o_205",cp="_sensorVal_ev96o_201",rp="_thermostat_ev96o_215",ip="_thermostatTitle_ev96o_229",lp="_thermostatDial_ev96o_247",dp="_dialTempCurrent_ev96o_257",up="_dialTempLabel_ev96o_273",pp="_dialTempTarget_ev96o_283",_p="_dialHumidity_ev96o_299",hp="_thermostatAdjust_ev96o_309",mp="_adjustBtn_ev96o_321",xp="_adjustTemp_ev96o_355",yp="_hvacModes_ev96o_375",vp="_hvacModeBtn_ev96o_389",fp="_hvacModeBtnActive_ev96o_413",gp="_hvacAction_ev96o_425",bp="_hvacActionDot_ev96o_441",jp="_lightControl_ev96o_455",wp="_lightHeader_ev96o_467",Np="_lightIcon_ev96o_479",kp="_lightName_ev96o_483",Cp="_lightToggle_ev96o_507",Ip="_lightToggleOn_ev96o_535",Sp="_sliderRow_ev96o_547",Lp="_sliderIcon_ev96o_561",zp="_slider_ev96o_547",Tp="_sliderVal_ev96o_579",Bp="_colorRow_ev96o_591",$p="_colorSwatch_ev96o_605",Pp="_colorPicker_ev96o_621",Mp="_colorPresets_ev96o_637",Op="_colorPreset_ev96o_637",Ap="_lightOff_ev96o_663",B={deviceControl:Iu,dark:Su,compact:Lu,offline:zu,offlineBanner:Tu,toggleControl:Bu,toggleLabel:$u,toggleBtn:Pu,toggleOn:Mu,blindControl:Ou,blindLabel:Au,blindActions:Eu,blindBtn:Du,blindSlider:Ru,blindPct:Gu,lockControl:Wu,lockLabel:qu,lockBtn:Fu,lockLocked:Vu,lockUnlocked:Hu,cameraControl:Uu,cameraLabel:Zu,cameraSnapshot:Yu,cameraPlaceholder:Ku,cameraStatus:Xu,cameraDot:Ju,cameraOnline:Qu,cameraOffline:ep,sensorControl:tp,sensorLabel:sp,sensorValues:np,sensorRow:op,sensorKey:ap,sensorVal:cp,thermostat:rp,thermostatTitle:ip,thermostatDial:lp,dialTempCurrent:dp,dialTempLabel:up,dialTempTarget:pp,dialHumidity:_p,thermostatAdjust:hp,adjustBtn:mp,adjustTemp:xp,hvacModes:yp,hvacModeBtn:vp,hvacModeBtnActive:fp,hvacAction:gp,hvacActionDot:bp,lightControl:jp,lightHeader:wp,lightIcon:Np,lightName:kp,lightToggle:Cp,lightToggleOn:Ip,sliderRow:Sp,sliderIcon:Lp,slider:zp,sliderVal:Tp,colorRow:Bp,colorSwatch:$p,colorPicker:Pp,colorPresets:Mp,colorPreset:Op,lightOff:Ap};function Ft(t){const s=Math.max(0,Math.min(1,(t-2700)/3800)),a=Math.round(255-s*80),o=Math.round(200+s*30),n=Math.round(100+s*155);return`rgb(${a},${o},${n})`}function Ep(t,s,a){return"#"+[t,s,a].map(o=>o.toString(16).padStart(2,"0")).join("")}function Vt(t){const s=parseInt(t.slice(1,3),16),a=parseInt(t.slice(3,5),16),o=parseInt(t.slice(5,7),16);return[s,a,o]}const ts=({device:t,onControl:s,compact:a=!1,theme:o="light",className:n,style:c})=>{var i,h,j;const l=t.state,y=(l==null?void 0:l.on)??!1,v=(l==null?void 0:l.brightness)??100,k=(l==null?void 0:l.colorTemperature)??4e3,d=l==null?void 0:l.rgbColor,[C,b]=r.useState(!1),p=r.useCallback(f=>{s==null||s(t.id,f)},[t.id,s]),N=d?Ep(d[0],d[1],d[2]):"var(--nice-bg, #fff)",u=((i=t.capabilities)==null?void 0:i.includes("dimming"))??v!==void 0,w=(h=t.capabilities)==null?void 0:h.includes("color_temperature"),T=((j=t.capabilities)==null?void 0:j.includes("color"))||t.type==="rgb_light";return e.jsxs("div",{className:`${B.lightControl} ${a?B.compact:""} ${o==="dark"?B.dark:""} ${n??""}`,style:c,children:[e.jsxs("div",{className:B.lightHeader,children:[e.jsx("span",{className:B.lightIcon,style:{opacity:y?1:.4},children:"💡"}),e.jsx("span",{className:B.lightName,children:t.name}),e.jsx("button",{className:`${B.lightToggle} ${y?B.lightToggleOn:""}`,onClick:()=>p({on:!y}),children:y?"●":"○"})]}),y&&e.jsxs(e.Fragment,{children:[u&&e.jsxs("div",{className:B.sliderRow,children:[e.jsx("span",{className:B.sliderIcon,children:"🔅"}),e.jsx("input",{type:"range",min:1,max:100,value:v,className:B.slider,style:{"--pct":`${v}%`},onChange:f=>p({brightness:+f.target.value})}),e.jsxs("span",{className:B.sliderVal,children:[v,"%"]})]}),w&&e.jsxs("div",{className:B.sliderRow,children:[e.jsx("span",{className:B.sliderIcon,children:"🌡"}),e.jsx("input",{type:"range",min:2700,max:6500,step:100,value:k,className:B.slider,style:{background:`linear-gradient(to right, ${Ft(2700)}, ${Ft(6500)})`},onChange:f=>p({colorTemperature:+f.target.value})}),e.jsxs("span",{className:B.sliderVal,children:[Math.round(k/100)*100,"K"]})]}),T&&e.jsxs("div",{className:B.colorRow,children:[e.jsx("span",{className:B.sliderIcon,children:"🎨"}),e.jsx("button",{className:B.colorSwatch,style:{background:N},onClick:()=>b(f=>!f)}),C&&e.jsx("input",{type:"color",value:N,className:B.colorPicker,onChange:f=>{const[g,m,A]=Vt(f.target.value);p({rgbColor:[g,m,A]})}}),e.jsx("div",{className:B.colorPresets,children:["var(--nice-bg, #fff)","var(--nice-warning-bg, #fde68a)","var(--nice-danger-bg, #fca5a5)","var(--nice-primary-light, #93c5fd)","var(--nice-success-light, #86efac)","var(--nice-accent, #c4b5fd)"].map(f=>e.jsx("button",{className:B.colorPreset,style:{background:f},onClick:()=>{const[g,m,A]=Vt(f);p({rgbColor:[g,m,A]})}},f))})]})]}),!y&&!a&&e.jsx("div",{className:B.lightOff,children:"Wyłączone"})]})},Ht={heat:"🔥 Grzanie",cool:"❄ Chłodzenie",auto:"⚡ Auto",off:"⏻ Wyłącz",fan_only:"💨 Wentylacja",dry:"💧 Osuszanie"},Dp={heating:"var(--nice-danger, #ef4444)",cooling:"var(--nice-primary, #3b82f6)",fan:"var(--nice-success, #22c55e)",drying:"var(--nice-warning, #f59e0b)",idle:"var(--nice-text-muted, #94a3b8)",off:"var(--nice-border, #e2e8f0)"};function Ut(t,s,a,o,n){const c=C=>(C-90)*(Math.PI/180),l=t+a*Math.cos(c(o)),y=s+a*Math.sin(c(o)),v=t+a*Math.cos(c(n)),k=s+a*Math.sin(c(n)),d=n-o>180?1:0;return`M${l.toFixed(2)},${y.toFixed(2)} A${a},${a} 0 ${d},1 ${v.toFixed(2)},${k.toFixed(2)}`}const Qe=5,dt=35,ut=-140,ss=140;function Zt(t){return ut+(t-Qe)/(dt-Qe)*(ss-ut)}const ns=({device:t,onControl:s,compact:a=!1,theme:o="light",className:n,style:c})=>{const l=t.state,y=(l==null?void 0:l.temperature)??20,v=(l==null?void 0:l.targetTemperature)??21,k=l==null?void 0:l.humidity,d=(l==null?void 0:l.mode)??"auto",C=(l==null?void 0:l.hvacAction)??"idle",b=80,p=80,N=60,u=Ut(b,p,N,ut,ss),w=Zt(Math.min(Math.max(y,Qe),dt)),T=Zt(Math.min(Math.max(v,Qe),dt)),i=Ut(b,p,N,ut,Math.min(w,T)),h=Dp[C]??"var(--nice-text-muted, #94a3b8)",j=r.useCallback(g=>{const m=Math.round((v+g)*2)/2;m>=Qe&&m<=dt&&(s==null||s(t.id,{targetTemperature:m}))},[v,t.id,s]),f=r.useCallback(g=>{s==null||s(t.id,{mode:g})},[t.id,s]);return e.jsxs("div",{className:`${B.thermostat} ${a?B.compact:""} ${o==="dark"?B.dark:""} ${n??""}`,style:c,children:[e.jsx("div",{className:B.thermostatTitle,children:t.name}),e.jsxs("svg",{width:160,height:160,className:B.thermostatDial,children:[e.jsx("path",{d:u,fill:"none",stroke:"var(--nice-border, #e2e8f0)",strokeWidth:8,strokeLinecap:"round"}),e.jsx("path",{d:i,fill:"none",stroke:h,strokeWidth:8,strokeLinecap:"round",opacity:.4}),e.jsx("circle",{cx:b+N*Math.cos((T-90)*(Math.PI/180)),cy:p+N*Math.sin((T-90)*(Math.PI/180)),r:7,fill:h,stroke:"var(--nice-bg, #fff)",strokeWidth:2}),e.jsxs("text",{x:b,y:p-6,textAnchor:"middle",className:B.dialTempCurrent,children:[y.toFixed(1),"°"]}),e.jsx("text",{x:b,y:p+14,textAnchor:"middle",className:B.dialTempLabel,children:"aktualnie"}),e.jsxs("text",{x:b,y:p+32,textAnchor:"middle",className:B.dialTempTarget,children:["▶ ",v.toFixed(1),"°"]}),k!=null&&e.jsxs("text",{x:b,y:p+48,textAnchor:"middle",className:B.dialHumidity,children:["💧 ",k,"%"]})]}),e.jsxs("div",{className:B.thermostatAdjust,children:[e.jsx("button",{className:B.adjustBtn,onClick:()=>j(-.5),children:"−"}),e.jsxs("span",{className:B.adjustTemp,children:[v.toFixed(1)," °C"]}),e.jsx("button",{className:B.adjustBtn,onClick:()=>j(.5),children:"+"})]}),!a&&e.jsx("div",{className:B.hvacModes,children:["heat","cool","auto","fan_only","off"].map(g=>e.jsx("button",{title:Ht[g],className:`${B.hvacModeBtn} ${d===g?B.hvacModeBtnActive:""}`,onClick:()=>f(g),children:Ht[g].split(" ")[0]},g))}),e.jsxs("div",{className:B.hvacAction,style:{color:h},children:[e.jsx("span",{className:B.hvacActionDot,style:{background:h}}),C]})]})},Rp=({device:t,onControl:s})=>{const a=t.state,o=(a==null?void 0:a.on)===!0;return e.jsxs("div",{className:B.toggleControl,children:[e.jsx("span",{className:B.toggleLabel,children:t.name}),e.jsx("button",{className:`${B.toggleBtn} ${o?B.toggleOn:""}`,onClick:()=>s==null?void 0:s(t.id,{on:!o}),children:o?"WŁĄCZONE":"WYŁĄCZONE"})]})},Gp=({device:t,onControl:s})=>{const a=t.state,o=typeof(a==null?void 0:a.position)=="number"?a.position:50;return e.jsxs("div",{className:B.blindControl,children:[e.jsx("span",{className:B.blindLabel,children:t.name}),e.jsxs("div",{className:B.blindActions,children:[e.jsx("button",{className:B.blindBtn,onClick:()=>s==null?void 0:s(t.id,{command:"open"}),children:"▲"}),e.jsx("button",{className:B.blindBtn,onClick:()=>s==null?void 0:s(t.id,{command:"stop"}),children:"■"}),e.jsx("button",{className:B.blindBtn,onClick:()=>s==null?void 0:s(t.id,{command:"close"}),children:"▼"})]}),e.jsx("input",{type:"range",min:0,max:100,value:o,className:B.blindSlider,onChange:n=>s==null?void 0:s(t.id,{position:+n.target.value})}),e.jsxs("span",{className:B.blindPct,children:[o,"%"]})]})},Wp=({device:t,onControl:s})=>{const a=t.state,o=(a==null?void 0:a.locked)!==!1;return e.jsxs("div",{className:B.lockControl,children:[e.jsx("span",{className:B.lockLabel,children:t.name}),e.jsx("button",{className:`${B.lockBtn} ${o?B.lockLocked:B.lockUnlocked}`,onClick:()=>s==null?void 0:s(t.id,{locked:!o}),children:o?"🔒 Zablokowany":"🔓 Odblokowany"})]})},qp=({device:t})=>{const s=t.state;return e.jsxs("div",{className:B.cameraControl,children:[e.jsx("span",{className:B.cameraLabel,children:t.name}),s!=null&&s.snapshotUrl?e.jsx("img",{src:s.snapshotUrl,alt:"snapshot",className:B.cameraSnapshot}):e.jsxs("div",{className:B.cameraPlaceholder,children:[e.jsx("span",{children:"📷"}),e.jsx("span",{children:s!=null&&s.streaming?"Streaming":"Brak podglądu"})]}),e.jsxs("div",{className:B.cameraStatus,children:[e.jsx("span",{className:`${B.cameraDot} ${t.status==="online"?B.cameraOnline:B.cameraOffline}`}),t.status]})]})},Fp=({device:t})=>{const s=t.state;return e.jsxs("div",{className:B.sensorControl,children:[e.jsx("span",{className:B.sensorLabel,children:t.name}),e.jsx("div",{className:B.sensorValues,children:Object.entries(s??{}).map(([a,o])=>o!=null&&e.jsxs("div",{className:B.sensorRow,children:[e.jsx("span",{className:B.sensorKey,children:a}),e.jsx("span",{className:B.sensorVal,children:String(o)})]},a))})]})},Vp=({device:t,onControl:s,compact:a=!1,className:o,style:n,theme:c="light"})=>{const l=t.type,y=["light","dimmer","rgb_light","led_strip"].includes(l)?e.jsx(ts,{device:t,onControl:s,compact:a,theme:c}):["thermostat","air_conditioner","heat_pump","floor_heating"].includes(l)?e.jsx(ns,{device:t,onControl:s,compact:a,theme:c}):["blind","shutter","curtain","awning","garage_door"].includes(l)?e.jsx(Gp,{device:t,onControl:s}):["lock","door"].includes(l)?e.jsx(Wp,{device:t,onControl:s}):["camera","doorbell"].includes(l)?e.jsx(qp,{device:t}):l.endsWith("_sensor")||["motion_sensor","smoke_detector","water_leak_sensor","alarm"].includes(l)?e.jsx(Fp,{device:t}):e.jsx(Rp,{device:t,onControl:s});return e.jsxs("div",{className:`${B.deviceControl} ${c==="dark"?B.dark:""} ${a?B.compact:""} ${t.status==="offline"?B.offline:""} ${o??""}`,style:n,children:[y,t.status==="offline"&&e.jsx("div",{className:B.offlineBanner,children:"Offline"})]})},Hp="_root_o9ptx_3",Up="_dark_o9ptx_27",Zp="_listPanel_o9ptx_33",Yp="_listHeader_o9ptx_55",Kp="_listTitle_o9ptx_75",Xp="_addBtn_o9ptx_89",Jp="_list_o9ptx_33",Qp="_listItem_o9ptx_117",e_="_listItemActive_o9ptx_145",t_="_listItemName_o9ptx_151",s_="_listItemMeta_o9ptx_175",n_="_enableToggle_o9ptx_189",o_="_enableOn_o9ptx_207",a_="_detailPanel_o9ptx_213",c_="_detailHeader_o9ptx_225",r_="_nameInput_o9ptx_239",i_="_deleteBtn_o9ptx_267",l_="_section_o9ptx_293",d_="_sectionHeader_o9ptx_301",u_="_sectionTitle_o9ptx_315",p_="_sectionAddBtn_o9ptx_331",__="_ruleBlock_o9ptx_357",h_="_ruleBlockHeader_o9ptx_377",m_="_typeSelect_o9ptx_391",x_="_removeBtn_o9ptx_415",y_="_ruleFields_o9ptx_447",v_="_input_o9ptx_479",f_="_textarea_o9ptx_503",g_="_dayPicker_o9ptx_531",b_="_dayBtn_o9ptx_535",j_="_dayBtnActive_o9ptx_555",w_="_noSelection_o9ptx_561",N_="_emptyHint_o9ptx_561",E={root:Hp,dark:Up,listPanel:Zp,listHeader:Yp,listTitle:Kp,addBtn:Xp,list:Jp,listItem:Qp,listItemActive:e_,listItemName:t_,listItemMeta:s_,enableToggle:n_,enableOn:o_,detailPanel:a_,detailHeader:c_,nameInput:r_,deleteBtn:i_,section:l_,sectionHeader:d_,sectionTitle:u_,sectionAddBtn:p_,ruleBlock:__,ruleBlockHeader:h_,typeSelect:m_,removeBtn:x_,ruleFields:y_,input:v_,textarea:f_,dayPicker:g_,dayBtn:b_,dayBtnActive:j_,noSelection:w_,emptyHint:N_},k_=[{target:".nice-building-automation-editor",titleKey:"tutorial.buildingAutomationEditor.intro.title",title:"Automation editor",contentKey:"tutorial.buildingAutomationEditor.intro.content",content:"Create building automations: pick one from the list, define its triggers, conditions and actions, then save, enable or delete it.",placement:"auto"}],ze=(t,s,a="")=>{const o=t[s];return typeof o=="string"?o:a},It=(t,s,a=0)=>{const o=t[s];return typeof o=="number"?o:a},C_=(t,s,a)=>{const o=t[s];return Array.isArray(o)?o:a},I_=(t,s)=>{const a=t[s];return a&&typeof a=="object"?a:{}},S_=({trigger:t,devices:s,onChange:a,onRemove:o})=>{const n=c=>a({...t,...c});return e.jsxs("div",{className:E.ruleBlock,children:[e.jsxs("div",{className:E.ruleBlockHeader,children:[e.jsxs("select",{className:E.typeSelect,value:t.type,onChange:c=>a({type:c.target.value}),children:[e.jsx("option",{value:"time",children:"⏰ Czas"}),e.jsx("option",{value:"sunrise",children:"🌅 Wschód słońca"}),e.jsx("option",{value:"sunset",children:"🌇 Zachód słońca"}),e.jsx("option",{value:"device_state",children:"📡 Stan urządzenia"}),e.jsx("option",{value:"sensor_threshold",children:"📊 Próg sensora"}),e.jsx("option",{value:"occupancy",children:"👥 Obecność"}),e.jsx("option",{value:"webhook",children:"🔗 Webhook"}),e.jsx("option",{value:"calendar",children:"📅 Kalendarz"})]}),e.jsx("button",{className:E.removeBtn,onClick:o,title:"Usuń",children:"✕"})]}),t.type==="time"&&e.jsxs("div",{className:E.ruleFields,children:[e.jsxs("label",{children:["Godzina",e.jsx("input",{type:"time",className:E.input,value:ze(t,"time","08:00"),onChange:c=>n({time:c.target.value})})]}),e.jsxs("label",{children:["Dni",e.jsx("div",{className:E.dayPicker,children:["Pon","Wt","Śr","Czw","Pt","Sob","Nd"].map((c,l)=>{const y=C_(t,"days",[0,1,2,3,4]),v=y.includes(l);return e.jsx("button",{className:`${E.dayBtn} ${v?E.dayBtnActive:""}`,onClick:()=>n({days:v?y.filter(k=>k!==l):[...y,l]}),children:c},l)})})]})]}),(t.type==="sunrise"||t.type==="sunset")&&e.jsx("div",{className:E.ruleFields,children:e.jsxs("label",{children:["Offset (minuty)",e.jsx("input",{type:"number",className:E.input,min:-120,max:120,step:5,value:It(t,"offsetMinutes",0),onChange:c=>n({offsetMinutes:+c.target.value})})]})}),(t.type==="device_state"||t.type==="sensor_threshold")&&e.jsxs("div",{className:E.ruleFields,children:[e.jsxs("label",{children:["Urządzenie",e.jsxs("select",{className:E.input,value:ze(t,"deviceId",""),onChange:c=>n({deviceId:c.target.value}),children:[e.jsx("option",{value:"",children:"— wybierz —"}),s.map(c=>e.jsx("option",{value:c.id,children:c.name},c.id))]})]}),t.type==="sensor_threshold"&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{children:["Atrybut",e.jsx("input",{className:E.input,value:ze(t,"attribute",""),onChange:c=>n({attribute:c.target.value})})]}),e.jsxs("label",{children:["Operator",e.jsxs("select",{className:E.input,value:ze(t,"operator","above"),onChange:c=>n({operator:c.target.value}),children:[e.jsx("option",{value:"above",children:"powyżej"}),e.jsx("option",{value:"below",children:"poniżej"}),e.jsx("option",{value:"equals",children:"równe"})]})]}),e.jsxs("label",{children:["Próg",e.jsx("input",{type:"number",className:E.input,value:It(t,"threshold",0),onChange:c=>n({threshold:+c.target.value})})]})]})]}),t.type==="webhook"&&e.jsx("div",{className:E.ruleFields,children:e.jsxs("label",{children:["Endpoint ID",e.jsx("input",{className:E.input,value:ze(t,"webhookId",""),onChange:c=>n({webhookId:c.target.value})})]})})]})},L_=({action:t,devices:s,onChange:a,onRemove:o})=>{const n=c=>a({...t,...c});return e.jsxs("div",{className:E.ruleBlock,children:[e.jsxs("div",{className:E.ruleBlockHeader,children:[e.jsxs("select",{className:E.typeSelect,value:t.type,onChange:c=>a({type:c.target.value}),children:[e.jsx("option",{value:"device_control",children:"📡 Urządzenie"}),e.jsx("option",{value:"scene_activate",children:"🎭 Aktywuj scenę"}),e.jsx("option",{value:"notification",children:"🔔 Powiadomienie"}),e.jsx("option",{value:"delay",children:"⏱ Opóźnienie"}),e.jsx("option",{value:"http_request",children:"🌐 HTTP Request"})]}),e.jsx("button",{className:E.removeBtn,onClick:o,title:"Usuń",children:"✕"})]}),t.type==="device_control"&&e.jsxs("div",{className:E.ruleFields,children:[e.jsxs("label",{children:["Urządzenie",e.jsxs("select",{className:E.input,value:ze(t,"deviceId",""),onChange:c=>n({deviceId:c.target.value}),children:[e.jsx("option",{value:"",children:"— wybierz —"}),s.map(c=>e.jsx("option",{value:c.id,children:c.name},c.id))]})]}),e.jsxs("label",{children:["Stan (JSON)",e.jsx("textarea",{className:E.textarea,rows:3,value:JSON.stringify(I_(t,"state"),null,2),onChange:c=>{try{n({state:JSON.parse(c.target.value)})}catch{}}})]})]}),t.type==="notification"&&e.jsxs("div",{className:E.ruleFields,children:[e.jsxs("label",{children:["Kanał",e.jsxs("select",{className:E.input,value:ze(t,"channel","push"),onChange:c=>n({channel:c.target.value}),children:[e.jsx("option",{value:"push",children:"Push"}),e.jsx("option",{value:"email",children:"Email"}),e.jsx("option",{value:"sms",children:"SMS"}),e.jsx("option",{value:"in_app",children:"In-app"}),e.jsx("option",{value:"teams",children:"Teams"}),e.jsx("option",{value:"slack",children:"Slack"})]})]}),e.jsxs("label",{children:["Wiadomość",e.jsx("input",{className:E.input,value:ze(t,"message",""),onChange:c=>n({message:c.target.value})})]})]}),t.type==="delay"&&e.jsx("div",{className:E.ruleFields,children:e.jsxs("label",{children:["Opóźnienie (sekundy)",e.jsx("input",{type:"number",className:E.input,min:1,value:It(t,"delaySeconds",60),onChange:c=>n({delaySeconds:+c.target.value})})]})}),t.type==="http_request"&&e.jsxs("div",{className:E.ruleFields,children:[e.jsxs("label",{children:["URL",e.jsx("input",{className:E.input,value:ze(t,"url",""),onChange:c=>n({url:c.target.value})})]}),e.jsxs("label",{children:["Metoda",e.jsxs("select",{className:E.input,value:ze(t,"method","POST"),onChange:c=>n({method:c.target.value}),children:[e.jsx("option",{children:"GET"}),e.jsx("option",{children:"POST"}),e.jsx("option",{children:"PUT"}),e.jsx("option",{children:"PATCH"})]})]})]})]})},z_=({automations:t,devices:s=[],onAutomationsChange:a,readOnly:o=!1,className:n,style:c,theme:l="light",tutorial:y})=>{var N;const[v,k]=r.useState(((N=t[0])==null?void 0:N.id)??null),d=t.find(u=>u.id===v)??null,C=r.useCallback(u=>{d&&(a==null||a(t.map(w=>w.id===d.id?{...w,...u}:w)))},[d,t,a]),b=r.useCallback(()=>{const u={id:`auto-${Date.now()}`,name:"Nowa automatyzacja",enabled:!0,triggers:[],conditions:[],actions:[]};a==null||a([...t,u]),k(u.id)},[t,a]),p=r.useCallback(u=>{var w;a==null||a(t.filter(T=>T.id!==u)),v===u&&k(((w=t.find(T=>T.id!==u))==null?void 0:w.id)??null)},[t,v,a]);return e.jsxs("div",{className:`nice-building-automation-editor ${E.root} ${l==="dark"?E.dark:""} ${n??""}`,style:{position:"relative",...c},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:30},children:e.jsx(Me.NiceTutorialButton,{steps:Me.resolveTutorial(y,k_)})}),e.jsxs("div",{className:E.listPanel,children:[e.jsxs("div",{className:E.listHeader,children:[e.jsx("span",{className:E.listTitle,children:"Automatyzacje"}),!o&&e.jsx("button",{className:E.addBtn,onClick:b,children:"+ Dodaj"})]}),e.jsxs("div",{className:E.list,children:[t.map(u=>e.jsxs("div",{className:`${E.listItem} ${v===u.id?E.listItemActive:""}`,onClick:()=>k(u.id),children:[e.jsx("div",{className:E.listItemName,children:u.name}),e.jsxs("div",{className:E.listItemMeta,children:[u.triggers.length," wyzw · ",u.actions.length," akcji"]}),e.jsx("button",{className:`${E.enableToggle} ${u.enabled?E.enableOn:""}`,onClick:w=>{w.stopPropagation(),C({enabled:!u.enabled})},title:u.enabled?"Wyłącz":"Włącz",children:u.enabled?"●":"○"})]},u.id)),t.length===0&&e.jsx("div",{className:E.emptyHint,children:"Brak automatyzacji"})]})]}),e.jsx("div",{className:E.detailPanel,children:d?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:E.detailHeader,children:[e.jsx("input",{className:E.nameInput,value:d.name,onChange:u=>C({name:u.target.value}),readOnly:o}),!o&&e.jsx("button",{className:E.deleteBtn,onClick:()=>p(d.id),children:"Usuń"})]}),e.jsxs("section",{className:E.section,children:[e.jsxs("div",{className:E.sectionHeader,children:[e.jsx("span",{className:E.sectionTitle,children:"Wyzwalacze"}),!o&&e.jsx("button",{className:E.sectionAddBtn,onClick:()=>C({triggers:[...d.triggers,{type:"time"}]}),children:"+ Dodaj"})]}),d.triggers.map((u,w)=>e.jsx(S_,{trigger:u,devices:s,onChange:T=>C({triggers:d.triggers.map((i,h)=>h===w?T:i)}),onRemove:()=>C({triggers:d.triggers.filter((T,i)=>i!==w)})},w)),d.triggers.length===0&&e.jsx("div",{className:E.emptyHint,children:"Brak wyzwalaczy"})]}),e.jsxs("section",{className:E.section,children:[e.jsxs("div",{className:E.sectionHeader,children:[e.jsx("span",{className:E.sectionTitle,children:"Akcje"}),!o&&e.jsx("button",{className:E.sectionAddBtn,onClick:()=>C({actions:[...d.actions,{type:"device_control"}]}),children:"+ Dodaj"})]}),d.actions.map((u,w)=>e.jsx(L_,{action:u,devices:s,onChange:T=>C({actions:d.actions.map((i,h)=>h===w?T:i)}),onRemove:()=>C({actions:d.actions.filter((T,i)=>i!==w)})},w)),d.actions.length===0&&e.jsx("div",{className:E.emptyHint,children:"Brak akcji"})]})]}):e.jsx("div",{className:E.noSelection,children:"Wybierz automatyzację lub dodaj nową"})})]})},T_="_root_1sm37_3",B_="_dark_1sm37_27",$_="_gridPanel_1sm37_33",P_="_gridHeader_1sm37_55",M_="_gridTitle_1sm37_75",O_="_addBtn_1sm37_81",A_="_sceneGrid_1sm37_105",E_="_sceneCard_1sm37_123",D_="_sceneCardActive_1sm37_147",R_="_sceneCardSelected_1sm37_149",G_="_sceneCardIcon_1sm37_153",W_="_sceneCardName_1sm37_157",q_="_sceneCardDevices_1sm37_175",F_="_activeBadge_1sm37_193",V_="_activateBtn_1sm37_197",H_="_emptyGrid_1sm37_237",U_="_detailPanel_1sm37_255",Z_="_metaRow_1sm37_273",Y_="_iconPicker_1sm37_285",K_="_currentIcon_1sm37_289",X_="_iconGrid_1sm37_307",J_="_iconOpt_1sm37_323",Q_="_iconOptActive_1sm37_345",eh="_metaFields_1sm37_349",th="_nameInput_1sm37_353",sh="_descInput_1sm37_381",nh="_colorPicker_1sm37_411",oh="_colorOpt_1sm37_421",ah="_colorOptActive_1sm37_437",ch="_targetsSection_1sm37_443",rh="_targetsSectionHeader_1sm37_447",ih="_addTargetBtn_1sm37_469",lh="_targetRow_1sm37_493",dh="_targetSelect_1sm37_517",uh="_targetState_1sm37_541",ph="_targetField_1sm37_555",_h="_tempInput_1sm37_575",hh="_removeTargetBtn_1sm37_593",mh="_noTargets_1sm37_627",xh="_detailActions_1sm37_647",yh="_activateFullBtn_1sm37_661",vh="_deleteBtn_1sm37_689",Z={root:T_,dark:B_,gridPanel:$_,gridHeader:P_,gridTitle:M_,addBtn:O_,sceneGrid:A_,sceneCard:E_,sceneCardActive:D_,sceneCardSelected:R_,sceneCardIcon:G_,sceneCardName:W_,sceneCardDevices:q_,activeBadge:F_,activateBtn:V_,emptyGrid:H_,detailPanel:U_,metaRow:Z_,iconPicker:Y_,currentIcon:K_,iconGrid:X_,iconOpt:J_,iconOptActive:Q_,metaFields:eh,nameInput:th,descInput:sh,colorPicker:nh,colorOpt:oh,colorOptActive:ah,targetsSection:ch,targetsSectionHeader:rh,addTargetBtn:ih,targetRow:lh,targetSelect:dh,targetState:uh,targetField:ph,tempInput:_h,removeTargetBtn:hh,noTargets:mh,detailActions:xh,activateFullBtn:yh,deleteBtn:vh},fh=[{target:".nice-scene-editor",titleKey:"tutorial.buildingSceneEditor.intro.title",title:"Scene editor",contentKey:"tutorial.buildingSceneEditor.intro.content",content:"Create scenes that set multiple devices at once: pick a scene, choose device target states, then save or activate it.",placement:"auto"}],et=t=>t&&typeof t=="object"?t:{},gh=(t,s,a=!1)=>{const o=et(t)[s];return typeof o=="boolean"?o:a},kt=(t,s,a=0)=>{const o=et(t)[s];return typeof o=="number"?o:a},bh=["🎭","🌙","🌅","🎬","🎮","💼","🍽","☕","🏃","🛁","🎵","🌿","🔆","❄","🔒","🏠"],jh=["var(--nice-primary-bg, #e0f2fe)","var(--nice-accent-bg, #fce7f3)","var(--nice-success-bg, #dcfce7)","var(--nice-warning-bg, #fef9c3)","var(--nice-accent-bg, #ede9fe)","var(--nice-danger-bg, #fee2e2)","var(--nice-success-bg, #f0fdf4)","#fff7ed"],wh=({target:t,devices:s,onChange:a,onRemove:o})=>{const n=s.find(c=>c.id===t.deviceId);return e.jsxs("div",{className:Z.targetRow,children:[e.jsxs("select",{className:Z.targetSelect,value:t.deviceId,onChange:c=>a({...t,deviceId:c.target.value}),children:[e.jsx("option",{value:"",children:"— urządzenie —"}),s.map(c=>e.jsx("option",{value:c.id,children:c.name},c.id))]}),n&&e.jsxs("div",{className:Z.targetState,children:[e.jsxs("label",{className:Z.targetField,children:[e.jsx("span",{children:"Wł/Wył"}),e.jsx("input",{type:"checkbox",checked:gh(t.state,"on",!1),onChange:c=>a({...t,state:{...et(t.state),on:c.target.checked}})})]}),(n.type==="dimmer"||n.type==="light"||n.type==="rgb_light"||n.type==="led_strip")&&e.jsxs("label",{className:Z.targetField,children:[e.jsx("span",{children:"Jasność"}),e.jsx("input",{type:"range",min:0,max:100,value:kt(t.state,"brightness",100),onChange:c=>a({...t,state:{...et(t.state),brightness:+c.target.value}})}),e.jsxs("span",{children:[kt(t.state,"brightness",100),"%"]})]}),(n.type==="thermostat"||n.type==="air_conditioner")&&e.jsxs("label",{className:Z.targetField,children:[e.jsx("span",{children:"Temp."}),e.jsx("input",{type:"number",className:Z.tempInput,min:10,max:30,step:.5,value:kt(t.state,"targetTemperature",20),onChange:c=>a({...t,state:{...et(t.state),targetTemperature:+c.target.value}})}),e.jsx("span",{children:"°C"})]})]}),e.jsx("button",{className:Z.removeTargetBtn,onClick:o,title:"Usuń",children:"✕"})]})},Nh=({scenes:t,devices:s=[],activeSceneIds:a=[],onScenesChange:o,onActivate:n,readOnly:c=!1,className:l,style:y,theme:v="light",tutorial:k})=>{var T;const[d,C]=r.useState(((T=t[0])==null?void 0:T.id)??null),b=t.find(i=>i.id===d)??null,p=r.useCallback(i=>{b&&(o==null||o(t.map(h=>h.id===b.id?{...h,...i}:h)))},[b,t,o]),N=r.useCallback(()=>{const i={id:`scene-${Date.now()}`,name:"Nowa scena",deviceTargets:[],icon:"🎭",color:"var(--nice-primary-bg, #e0f2fe)"};o==null||o([...t,i]),C(i.id)},[t,o]),u=r.useCallback(i=>{var h;o==null||o(t.filter(j=>j.id!==i)),d===i&&C(((h=t.find(j=>j.id!==i))==null?void 0:h.id)??null)},[t,d,o]),w=()=>{if(!b)return;const i={deviceId:"",state:{on:!0},transitionMs:1e3};p({deviceTargets:[...b.deviceTargets,i]})};return e.jsxs("div",{className:`nice-scene-editor ${Z.root} ${v==="dark"?Z.dark:""} ${l??""}`,style:{position:"relative",...y},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:30},children:e.jsx(Me.NiceTutorialButton,{steps:Me.resolveTutorial(k,fh)})}),e.jsxs("div",{className:Z.gridPanel,children:[e.jsxs("div",{className:Z.gridHeader,children:[e.jsx("span",{className:Z.gridTitle,children:"Sceny"}),!c&&e.jsx("button",{className:Z.addBtn,onClick:N,children:"+ Nowa"})]}),e.jsxs("div",{className:Z.sceneGrid,children:[t.map(i=>{const h=a.includes(i.id),j=d===i.id;return e.jsxs("div",{className:`${Z.sceneCard} ${h?Z.sceneCardActive:""} ${j?Z.sceneCardSelected:""}`,style:{background:i.color??"var(--nice-bg-secondary, #f8fafc)"},onClick:()=>C(i.id),children:[e.jsx("div",{className:Z.sceneCardIcon,children:i.icon??"🎭"}),e.jsx("div",{className:Z.sceneCardName,children:i.name}),e.jsxs("div",{className:Z.sceneCardDevices,children:[i.deviceTargets.length," urządzeń",h&&e.jsx("span",{className:Z.activeBadge,children:"●"})]}),e.jsx("button",{className:Z.activateBtn,onClick:f=>{f.stopPropagation(),n==null||n(i.id)},children:"▶"})]},i.id)}),t.length===0&&e.jsx("div",{className:Z.emptyGrid,children:"Brak scen. Dodaj pierwszą!"})]})]}),b&&e.jsxs("div",{className:Z.detailPanel,children:[e.jsxs("div",{className:Z.metaRow,children:[e.jsxs("div",{className:Z.iconPicker,children:[e.jsx("span",{className:Z.currentIcon,children:b.icon??"🎭"}),e.jsx("div",{className:Z.iconGrid,children:bh.map(i=>e.jsx("button",{className:`${Z.iconOpt} ${b.icon===i?Z.iconOptActive:""}`,onClick:()=>p({icon:i}),children:i},i))})]}),e.jsxs("div",{className:Z.metaFields,children:[e.jsx("input",{className:Z.nameInput,value:b.name,readOnly:c,onChange:i=>p({name:i.target.value}),placeholder:"Nazwa sceny"}),e.jsx("textarea",{className:Z.descInput,value:b.description??"",readOnly:c,onChange:i=>p({description:i.target.value}),placeholder:"Opis (opcjonalny)",rows:2})]})]}),!c&&e.jsx("div",{className:Z.colorPicker,children:jh.map(i=>e.jsx("button",{className:`${Z.colorOpt} ${b.color===i?Z.colorOptActive:""}`,style:{background:i},onClick:()=>p({color:i})},i))}),e.jsxs("div",{className:Z.targetsSection,children:[e.jsxs("div",{className:Z.targetsSectionHeader,children:[e.jsx("span",{children:"Urządzenia w scenie"}),!c&&e.jsx("button",{className:Z.addTargetBtn,onClick:w,children:"+ Dodaj"})]}),b.deviceTargets.map((i,h)=>e.jsx(wh,{target:i,devices:s,onChange:j=>p({deviceTargets:b.deviceTargets.map((f,g)=>g===h?j:f)}),onRemove:()=>p({deviceTargets:b.deviceTargets.filter((j,f)=>f!==h)})},h)),b.deviceTargets.length===0&&e.jsx("div",{className:Z.noTargets,children:"Dodaj urządzenia, które powinna kontrolować ta scena."})]}),e.jsxs("div",{className:Z.detailActions,children:[e.jsx("button",{className:Z.activateFullBtn,onClick:()=>n==null?void 0:n(b.id),children:"▶ Aktywuj scenę"}),!c&&e.jsx("button",{className:Z.deleteBtn,onClick:()=>u(b.id),children:"Usuń"})]})]})]})};exports.LayerPanel=Yt;exports.Minimap=Kt;exports.NiceAutomationEditor=z_;exports.NiceBuildingDashboard=Cu;exports.NiceDeviceControl=Vp;exports.NiceFloorPlanEditor=en;exports.NiceLightControl=ts;exports.NiceSceneEditor=Nh;exports.NiceSpatialEditor=Yi;exports.NiceSpatialViewer=zd;exports.NiceThermostatControl=ns;exports.NiceZoneCard=es;exports.ObjectLibrary=Xt;exports.PropertiesPanel=Jt;exports.useMeasurement=$d;exports.useSnapToGrid=Bd;exports.useSpatialEditor=Td;