const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index.es-BqkUSV0N.js","assets/react-vendor-Dvs2KPqW.js","assets/utils-vendor-CJpcXyE0.js"])))=>i.map(i=>d[i]); import{u as ft,j as e,a as dt,b as Nr,Q as A6,c as c6}from"./query-vendor-BeRQtQod.js";import{a as d6,b as u6,g as h6,u as Ph,r as Ce,L as ba,R as $B,d as jy,e as Cy,O as f6,B as m6,f as p6,h as Fs,N as x6}from"./react-vendor-Dvs2KPqW.js";import{c as g6,a as b6,_ as y6,b as Yr}from"./utils-vendor-CJpcXyE0.js";import{R as Cn,C as e4,T as t4,M as r4,a as su,b as Ec,A as Wm,d as Eh,t as w6,c as v6,B as Lb,e as s4,I as a4,f as n4,g as wc,h as es,P as Ks,i as i4,j as Ka,S as vc,N as ya,k as N6,l as B6,m as io,n as Sy,o as so,H as Ul,p as j6,q as wh,r as Uh,s as up,X as Zs,U as Vd,u as C6,G as S6,v as Tb,F as au,w as hp,x as Ib,y as _6,L as Xm,z as zf,D as k6,E as Bn,J as fp,K as mp,O as pp,Q as Wd,V as o4,W as xv,Y as Db,Z as F6,_ as E6,$ as gv,a0 as U6,a1 as l4,a2 as _l,a3 as Wx,a4 as Q6,a5 as bv,a6 as A4,a7 as _y,a8 as c4,a9 as d4,aa as u4,ab as h4,ac as L6,ad as Tm,ae as T6,af as Xx,ag as Im,ah as I6,ai as D6,aj as R6,ak as yv,al as wv,am as O6,an as vv,ao as H6,ap as M6,aq as P6}from"./ui-vendor-C4xvlrdo.js";import{R as Cl,L as ky,C as Nc,X as Bc,Y as jc,T as Sl,a as Qh,b as Lh,A as f4,c as vh,P as Nv,d as Bv,e as Yx,B as jv,f as Jx}from"./chart-vendor-CnBPFalK.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))n(o);new MutationObserver(o=>{for(const l of o)if(l.type==="childList")for(const d of l.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&n(d)}).observe(document,{childList:!0,subtree:!0});function s(o){const l={};return o.integrity&&(l.integrity=o.integrity),o.referrerPolicy&&(l.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?l.credentials="include":o.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function n(o){if(o.ep)return;o.ep=!0;const l=s(o);fetch(o.href,l)}})();var Zx={exports:{}},Zu={},$x={exports:{}},eg={};var Cv;function K6(){return Cv||(Cv=1,(function(r){function t(ae,se){var fe=ae.length;ae.push(se);e:for(;0>>1,_e=ae[ye];if(0>>1;yeo($,fe))X<_e&&0>o(te,$)?(ae[ye]=te,ae[X]=fe,ye=X):(ae[ye]=$,ae[D]=fe,ye=D);else if(X<_e&&0>o(te,fe))ae[ye]=te,ae[X]=fe,ye=X;else break e}}return se}function o(ae,se){var fe=ae.sortIndex-se.sortIndex;return fe!==0?fe:ae.id-se.id}if(r.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var l=performance;r.unstable_now=function(){return l.now()}}else{var d=Date,c=d.now();r.unstable_now=function(){return d.now()-c}}var u=[],h=[],m=1,x=null,y=3,p=!1,v=!1,N=!1,B=!1,g=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,_=typeof setImmediate<"u"?setImmediate:null;function w(ae){for(var se=s(h);se!==null;){if(se.callback===null)n(h);else if(se.startTime<=ae)n(h),se.sortIndex=se.expirationTime,t(u,se);else break;se=s(h)}}function L(ae){if(N=!1,w(ae),!v)if(s(u)!==null)v=!0,K||(K=!0,U());else{var se=s(h);se!==null&&le(L,se.startTime-ae)}}var K=!1,M=-1,V=5,T=-1;function ne(){return B?!0:!(r.unstable_now()-Tae&&ne());){var ye=x.callback;if(typeof ye=="function"){x.callback=null,y=x.priorityLevel;var _e=ye(x.expirationTime<=ae);if(ae=r.unstable_now(),typeof _e=="function"){x.callback=_e,w(ae),se=!0;break t}x===s(u)&&n(u),w(ae)}else n(u);x=s(u)}if(x!==null)se=!0;else{var xe=s(h);xe!==null&&le(L,xe.startTime-ae),se=!1}}break e}finally{x=null,y=fe,p=!1}se=void 0}}finally{se?U():K=!1}}}var U;if(typeof _=="function")U=function(){_(Z)};else if(typeof MessageChannel<"u"){var q=new MessageChannel,F=q.port2;q.port1.onmessage=Z,U=function(){F.postMessage(null)}}else U=function(){g(Z,0)};function le(ae,se){M=g(function(){ae(r.unstable_now())},se)}r.unstable_IdlePriority=5,r.unstable_ImmediatePriority=1,r.unstable_LowPriority=4,r.unstable_NormalPriority=3,r.unstable_Profiling=null,r.unstable_UserBlockingPriority=2,r.unstable_cancelCallback=function(ae){ae.callback=null},r.unstable_forceFrameRate=function(ae){0>ae||125ye?(ae.sortIndex=fe,t(h,ae),s(u)===null&&ae===s(h)&&(N?(j(M),M=-1):N=!0,le(L,fe-ye))):(ae.sortIndex=_e,t(u,ae),v||p||(v=!0,K||(K=!0,U()))),ae},r.unstable_shouldYield=ne,r.unstable_wrapCallback=function(ae){var se=y;return function(){var fe=y;y=se;try{return ae.apply(this,arguments)}finally{y=fe}}}})(eg)),eg}var Sv;function z6(){return Sv||(Sv=1,$x.exports=K6()),$x.exports}var _v;function q6(){if(_v)return Zu;_v=1;var r=z6(),t=d6(),s=u6();function n(a){var i="https://react.dev/errors/"+a;if(1_e||(a.current=ye[_e],ye[_e]=null,_e--)}function $(a,i){_e++,ye[_e]=a.current,a.current=i}var X=xe(null),te=xe(null),J=xe(null),O=xe(null);function H(a,i){switch($(J,i),$(te,a),$(X,null),i.nodeType){case 9:case 11:a=(a=i.documentElement)&&(a=a.namespaceURI)?Hw(a):0;break;default:if(a=i.tagName,i=i.namespaceURI)i=Hw(i),a=Mw(i,a);else switch(a){case"svg":a=1;break;case"math":a=2;break;default:a=0}}D(X),$(X,a)}function re(){D(X),D(te),D(J)}function Ae(a){a.memoizedState!==null&&$(O,a);var i=X.current,A=Mw(i,a.type);i!==A&&($(te,a),$(X,A))}function oe(a){te.current===a&&(D(X),D(te)),O.current===a&&(D(O),Wu._currentValue=fe)}var ce,Se;function z(a){if(ce===void 0)try{throw Error()}catch(A){var i=A.stack.trim().match(/\n( *(at )?)/);ce=i&&i[1]||"",Se=-1)":-1C||ke[f]!==Ke[C]){var Ye=` `+ke[f].replace(" at new "," at ");return a.displayName&&Ye.includes("")&&(Ye=Ye.replace("",a.displayName)),Ye}while(1<=f&&0<=C);break}}}finally{ie=!1,Error.prepareStackTrace=A}return(A=a?a.displayName||a.name:"")?z(A):""}function Q(a,i){switch(a.tag){case 26:case 27:case 5:return z(a.type);case 16:return z("Lazy");case 13:return a.child!==i&&i!==null?z("Suspense Fallback"):z("Suspense");case 19:return z("SuspenseList");case 0:case 15:return W(a.type,!1);case 11:return W(a.type.render,!1);case 1:return W(a.type,!0);case 31:return z("Activity");default:return""}}function I(a){try{var i="",A=null;do i+=Q(a,A),A=a,a=a.return;while(a);return i}catch(f){return` Error generating stack: `+f.message+` `+f.stack}}var k=Object.prototype.hasOwnProperty,G=r.unstable_scheduleCallback,me=r.unstable_cancelCallback,be=r.unstable_shouldYield,Ue=r.unstable_requestPaint,Re=r.unstable_now,He=r.unstable_getCurrentPriorityLevel,Ve=r.unstable_ImmediatePriority,it=r.unstable_UserBlockingPriority,lt=r.unstable_NormalPriority,ut=r.unstable_LowPriority,Tt=r.unstable_IdlePriority,mt=r.log,Ur=r.unstable_setDisableYieldValue,jt=null,_t=null;function Dt(a){if(typeof mt=="function"&&Ur(a),_t&&typeof _t.setStrictMode=="function")try{_t.setStrictMode(jt,a)}catch{}}var Gt=Math.clz32?Math.clz32:It,kt=Math.log,Fr=Math.LN2;function It(a){return a>>>=0,a===0?32:31-(kt(a)/Fr|0)|0}var Pt=256,Br=262144,zt=4194304;function Bt(a){var i=a&42;if(i!==0)return i;switch(a&-a){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return a&261888;case 262144:case 524288:case 1048576:case 2097152:return a&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return a&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return a}}function cr(a,i,A){var f=a.pendingLanes;if(f===0)return 0;var C=0,E=a.suspendedLanes,ee=a.pingedLanes;a=a.warmLanes;var ge=f&134217727;return ge!==0?(f=ge&~E,f!==0?C=Bt(f):(ee&=ge,ee!==0?C=Bt(ee):A||(A=ge&~a,A!==0&&(C=Bt(A))))):(ge=f&~E,ge!==0?C=Bt(ge):ee!==0?C=Bt(ee):A||(A=f&~a,A!==0&&(C=Bt(A)))),C===0?0:i!==0&&i!==C&&(i&E)===0&&(E=C&-C,A=i&-i,E>=A||E===32&&(A&4194048)!==0)?i:C}function _n(a,i){return(a.pendingLanes&~(a.suspendedLanes&~a.pingedLanes)&i)===0}function Aa(a,i){switch(a){case 1:case 2:case 4:case 8:case 64:return i+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return i+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Xn(){var a=zt;return zt<<=1,(zt&62914560)===0&&(zt=4194304),a}function an(a){for(var i=[],A=0;31>A;A++)i.push(a);return i}function Et(a,i){a.pendingLanes|=i,i!==268435456&&(a.suspendedLanes=0,a.pingedLanes=0,a.warmLanes=0)}function Ci(a,i,A,f,C,E){var ee=a.pendingLanes;a.pendingLanes=A,a.suspendedLanes=0,a.pingedLanes=0,a.warmLanes=0,a.expiredLanes&=A,a.entangledLanes&=A,a.errorRecoveryDisabledLanes&=A,a.shellSuspendCounter=0;var ge=a.entanglements,ke=a.expirationTimes,Ke=a.hiddenUpdates;for(A=ee&~A;0"u")return null;try{return a.activeElement||a.body}catch{return a.body}}var Ls=/[\n"\\]/g;function vs(a){return a.replace(Ls,function(i){return"\\"+i.charCodeAt(0).toString(16)+" "})}function Il(a,i,A,f,C,E,ee,ge){a.name="",ee!=null&&typeof ee!="function"&&typeof ee!="symbol"&&typeof ee!="boolean"?a.type=ee:a.removeAttribute("type"),i!=null?ee==="number"?(i===0&&a.value===""||a.value!=i)&&(a.value=""+yr(i)):a.value!==""+yr(i)&&(a.value=""+yr(i)):ee!=="submit"&&ee!=="reset"||a.removeAttribute("value"),i!=null?RA(a,ee,yr(i)):A!=null?RA(a,ee,yr(A)):f!=null&&a.removeAttribute("value"),C==null&&E!=null&&(a.defaultChecked=!!E),C!=null&&(a.checked=C&&typeof C!="function"&&typeof C!="symbol"),ge!=null&&typeof ge!="function"&&typeof ge!="symbol"&&typeof ge!="boolean"?a.name=""+yr(ge):a.removeAttribute("name")}function Hc(a,i,A,f,C,E,ee,ge){if(E!=null&&typeof E!="function"&&typeof E!="symbol"&&typeof E!="boolean"&&(a.type=E),i!=null||A!=null){if(!(E!=="submit"&&E!=="reset"||i!=null)){ho(a);return}A=A!=null?""+yr(A):"",i=i!=null?""+yr(i):A,ge||i===a.value||(a.value=i),a.defaultValue=i}f=f??C,f=typeof f!="function"&&typeof f!="symbol"&&!!f,a.checked=ge?a.checked:!!f,a.defaultChecked=!!f,ee!=null&&typeof ee!="function"&&typeof ee!="symbol"&&typeof ee!="boolean"&&(a.name=ee),ho(a)}function RA(a,i,A){i==="number"&&va(a.ownerDocument)===a||a.defaultValue===""+A||(a.defaultValue=""+A)}function Na(a,i,A,f){if(a=a.options,i){i={};for(var C=0;C"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),zA=!1;if($s)try{var Xo={};Object.defineProperty(Xo,"passive",{get:function(){zA=!0}}),window.addEventListener("test",Xo,Xo),window.removeEventListener("test",Xo,Xo)}catch{zA=!1}var Ja=null,Yo=null,$n=null;function Gc(){if($n)return $n;var a,i=Yo,A=i.length,f,C="value"in Ja?Ja.value:Ja.textContent,E=C.length;for(a=0;a=Rn),Vs=" ",mo=!1;function po(a,i){switch(a){case"keyup":return Hl.indexOf(i.keyCode)!==-1;case"keydown":return i.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ml(a){return a=a.detail,typeof a=="object"&&"data"in a?a.data:null}var ri=!1;function Ba(a,i){switch(a){case"compositionend":return Ml(i);case"keypress":return i.which!==32?null:(mo=!0,Vs);case"textInput":return a=i.data,a===Vs&&mo?null:a;default:return null}}function Oi(a,i){if(ri)return a==="compositionend"||!ti&&po(a,i)?(a=Gc(),$n=Yo=Ja=null,ri=!1,a):null;switch(a){case"paste":return null;case"keypress":if(!(i.ctrlKey||i.altKey||i.metaKey)||i.ctrlKey&&i.altKey){if(i.char&&1=i)return{node:A,offset:i-a};a=f}e:{for(;A;){if(A.nextSibling){A=A.nextSibling;break e}A=A.parentNode}A=void 0}A=ql(A)}}function Ki(a,i){return a&&i?a===i?!0:a&&a.nodeType===3?!1:i&&i.nodeType===3?Ki(a,i.parentNode):"contains"in a?a.contains(i):a.compareDocumentPosition?!!(a.compareDocumentPosition(i)&16):!1:!1}function zi(a){a=a!=null&&a.ownerDocument!=null&&a.ownerDocument.defaultView!=null?a.ownerDocument.defaultView:window;for(var i=va(a.document);i instanceof a.HTMLIFrameElement;){try{var A=typeof i.contentWindow.location.href=="string"}catch{A=!1}if(A)a=i.contentWindow;else break;i=va(a.document)}return i}function oi(a){var i=a&&a.nodeName&&a.nodeName.toLowerCase();return i&&(i==="input"&&(a.type==="text"||a.type==="search"||a.type==="tel"||a.type==="url"||a.type==="password")||i==="textarea"||a.contentEditable==="true")}var el=$s&&"documentMode"in document&&11>=document.documentMode,$a=null,qi=null,da=null,An=!1;function wr(a,i,A){var f=A.window===A?A.document:A.nodeType===9?A:A.ownerDocument;An||$a==null||$a!==va(f)||(f=$a,"selectionStart"in f&&oi(f)?f={start:f.selectionStart,end:f.selectionEnd}:(f=(f.ownerDocument&&f.ownerDocument.defaultView||window).getSelection(),f={anchorNode:f.anchorNode,anchorOffset:f.anchorOffset,focusNode:f.focusNode,focusOffset:f.focusOffset}),da&&Pi(da,f)||(da=f,f=kf(qi,"onSelect"),0>=ee,C-=ee,mn=1<<32-Gt(i)+C|A<er?(lr=St,St=null):lr=St.sibling;var Cr=qe(Ie,St,Pe[er],$e);if(Cr===null){St===null&&(St=lr);break}a&&St&&Cr.alternate===null&&i(Ie,St),Qe=E(Cr,Qe,er),jr===null?Lt=Cr:jr.sibling=Cr,jr=Cr,St=lr}if(er===Pe.length)return A(Ie,St),ar&&tn(Ie,er),Lt;if(St===null){for(;erer?(lr=St,St=null):lr=St.sibling;var mA=qe(Ie,St,Cr.value,$e);if(mA===null){St===null&&(St=lr);break}a&&St&&mA.alternate===null&&i(Ie,St),Qe=E(mA,Qe,er),jr===null?Lt=mA:jr.sibling=mA,jr=mA,St=lr}if(Cr.done)return A(Ie,St),ar&&tn(Ie,er),Lt;if(St===null){for(;!Cr.done;er++,Cr=Pe.next())Cr=tt(Ie,Cr.value,$e),Cr!==null&&(Qe=E(Cr,Qe,er),jr===null?Lt=Cr:jr.sibling=Cr,jr=Cr);return ar&&tn(Ie,er),Lt}for(St=f(St);!Cr.done;er++,Cr=Pe.next())Cr=Ge(St,Ie,er,Cr.value,$e),Cr!==null&&(a&&Cr.alternate!==null&&St.delete(Cr.key===null?er:Cr.key),Qe=E(Cr,Qe,er),jr===null?Lt=Cr:jr.sibling=Cr,jr=Cr);return a&&St.forEach(function(l6){return i(Ie,l6)}),ar&&tn(Ie,er),Lt}function Pr(Ie,Qe,Pe,$e){if(typeof Pe=="object"&&Pe!==null&&Pe.type===N&&Pe.key===null&&(Pe=Pe.props.children),typeof Pe=="object"&&Pe!==null){switch(Pe.$$typeof){case p:e:{for(var Lt=Pe.key;Qe!==null;){if(Qe.key===Lt){if(Lt=Pe.type,Lt===N){if(Qe.tag===7){A(Ie,Qe.sibling),$e=C(Qe,Pe.props.children),$e.return=Ie,Ie=$e;break e}}else if(Qe.elementType===Lt||typeof Lt=="object"&&Lt!==null&&Lt.$$typeof===V&&Oe(Lt)===Qe.type){A(Ie,Qe.sibling),$e=C(Qe,Pe.props),Vt($e,Pe),$e.return=Ie,Ie=$e;break e}A(Ie,Qe);break}else i(Ie,Qe);Qe=Qe.sibling}Pe.type===N?($e=go(Pe.props.children,Ie.mode,$e,Pe.key),$e.return=Ie,Ie=$e):($e=Vl(Pe.type,Pe.key,Pe.props,null,Ie.mode,$e),Vt($e,Pe),$e.return=Ie,Ie=$e)}return ee(Ie);case v:e:{for(Lt=Pe.key;Qe!==null;){if(Qe.key===Lt)if(Qe.tag===4&&Qe.stateNode.containerInfo===Pe.containerInfo&&Qe.stateNode.implementation===Pe.implementation){A(Ie,Qe.sibling),$e=C(Qe,Pe.children||[]),$e.return=Ie,Ie=$e;break e}else{A(Ie,Qe);break}else i(Ie,Qe);Qe=Qe.sibling}$e=Wl(Pe,Ie.mode,$e),$e.return=Ie,Ie=$e}return ee(Ie);case V:return Pe=Oe(Pe),Pr(Ie,Qe,Pe,$e)}if(le(Pe))return wt(Ie,Qe,Pe,$e);if(U(Pe)){if(Lt=U(Pe),typeof Lt!="function")throw Error(n(150));return Pe=Lt.call(Pe),Mt(Ie,Qe,Pe,$e)}if(typeof Pe.then=="function")return Pr(Ie,Qe,pt(Pe),$e);if(Pe.$$typeof===_)return Pr(Ie,Qe,id(Ie,Pe),$e);bt(Ie,Pe)}return typeof Pe=="string"&&Pe!==""||typeof Pe=="number"||typeof Pe=="bigint"?(Pe=""+Pe,Qe!==null&&Qe.tag===6?(A(Ie,Qe.sibling),$e=C(Qe,Pe),$e.return=Ie,Ie=$e):(A(Ie,Qe),$e=tc(Pe,Ie.mode,$e),$e.return=Ie,Ie=$e),ee(Ie)):A(Ie,Qe)}return function(Ie,Qe,Pe,$e){try{vt=0;var Lt=Pr(Ie,Qe,Pe,$e);return st=null,Lt}catch(St){if(St===Ee||St===Ne)throw St;var jr=ha(29,St,null,Ie.mode);return jr.lanes=$e,jr.return=Ie,jr}}}var Vr=sr(!0),Jt=sr(!1),xt=!1;function At(a){a.updateQueue={baseState:a.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function ss(a,i){a=a.updateQueue,i.updateQueue===a&&(i.updateQueue={baseState:a.baseState,firstBaseUpdate:a.firstBaseUpdate,lastBaseUpdate:a.lastBaseUpdate,shared:a.shared,callbacks:null})}function Ot(a){return{lane:a,tag:0,payload:null,callback:null,next:null}}function $t(a,i,A){var f=a.updateQueue;if(f===null)return null;if(f=f.shared,(kr&2)!==0){var C=f.pending;return C===null?i.next=i:(i.next=C.next,C.next=i),f.pending=i,i=ua(a),$A(a,null,A),i}return ZA(a,f,i,A),ua(a)}function Sr(a,i,A){if(i=i.updateQueue,i!==null&&(i=i.shared,(A&4194048)!==0)){var f=i.lanes;f&=a.pendingLanes,A|=f,i.lanes=A,qa(a,A)}}function Is(a,i){var A=a.updateQueue,f=a.alternate;if(f!==null&&(f=f.updateQueue,A===f)){var C=null,E=null;if(A=A.firstBaseUpdate,A!==null){do{var ee={lane:A.lane,tag:A.tag,payload:A.payload,callback:null,next:null};E===null?C=E=ee:E=E.next=ee,A=A.next}while(A!==null);E===null?C=E=i:E=E.next=i}else C=E=i;A={baseState:f.baseState,firstBaseUpdate:C,lastBaseUpdate:E,shared:f.shared,callbacks:f.callbacks},a.updateQueue=A;return}a=A.lastBaseUpdate,a===null?A.firstBaseUpdate=i:a.next=i,A.lastBaseUpdate=i}var ia=!1;function Or(){if(ia){var a=S;if(a!==null)throw a}}function Bs(a,i,A,f){ia=!1;var C=a.updateQueue;xt=!1;var E=C.firstBaseUpdate,ee=C.lastBaseUpdate,ge=C.shared.pending;if(ge!==null){C.shared.pending=null;var ke=ge,Ke=ke.next;ke.next=null,ee===null?E=Ke:ee.next=Ke,ee=ke;var Ye=a.alternate;Ye!==null&&(Ye=Ye.updateQueue,ge=Ye.lastBaseUpdate,ge!==ee&&(ge===null?Ye.firstBaseUpdate=Ke:ge.next=Ke,Ye.lastBaseUpdate=ke))}if(E!==null){var tt=C.baseState;ee=0,Ye=Ke=ke=null,ge=E;do{var qe=ge.lane&-536870913,Ge=qe!==ge.lane;if(Ge?(or&qe)===qe:(f&qe)===qe){qe!==0&&qe===b&&(ia=!0),Ye!==null&&(Ye=Ye.next={lane:0,tag:ge.tag,payload:ge.payload,callback:null,next:null});e:{var wt=a,Mt=ge;qe=i;var Pr=A;switch(Mt.tag){case 1:if(wt=Mt.payload,typeof wt=="function"){tt=wt.call(Pr,tt,qe);break e}tt=wt;break e;case 3:wt.flags=wt.flags&-65537|128;case 0:if(wt=Mt.payload,qe=typeof wt=="function"?wt.call(Pr,tt,qe):wt,qe==null)break e;tt=x({},tt,qe);break e;case 2:xt=!0}}qe=ge.callback,qe!==null&&(a.flags|=64,Ge&&(a.flags|=8192),Ge=C.callbacks,Ge===null?C.callbacks=[qe]:Ge.push(qe))}else Ge={lane:qe,tag:ge.tag,payload:ge.payload,callback:ge.callback,next:null},Ye===null?(Ke=Ye=Ge,ke=tt):Ye=Ye.next=Ge,ee|=qe;if(ge=ge.next,ge===null){if(ge=C.shared.pending,ge===null)break;Ge=ge,ge=Ge.next,Ge.next=null,C.lastBaseUpdate=Ge,C.shared.pending=null}}while(!0);Ye===null&&(ke=tt),C.baseState=ke,C.firstBaseUpdate=Ke,C.lastBaseUpdate=Ye,E===null&&(C.shared.lanes=0),nA|=ee,a.lanes=ee,a.memoizedState=tt}}function fa(a,i){if(typeof a!="function")throw Error(n(191,a));a.call(i)}function js(a,i){var A=a.callbacks;if(A!==null)for(a.callbacks=null,a=0;aE?E:8;var ee=ae.T,ge={};ae.T=ge,Gp(a,!1,i,A);try{var ke=C(),Ke=ae.S;if(Ke!==null&&Ke(ge,ke),ke!==null&&typeof ke=="object"&&typeof ke.then=="function"){var Ye=ue(ke,f);Eu(a,i,Ye,qn(a))}else Eu(a,i,f,qn(a))}catch(tt){Eu(a,i,{then:function(){},status:"rejected",reason:tt},qn())}finally{se.p=E,ee!==null&&ge.types!==null&&(ee.types=ge.types),ae.T=ee}}function sC(){}function zp(a,i,A,f){if(a.tag!==5)throw Error(n(476));var C=u1(a).queue;d1(a,C,i,fe,A===null?sC:function(){return h1(a),A(f)})}function u1(a){var i=a.memoizedState;if(i!==null)return i;i={memoizedState:fe,baseState:fe,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ci,lastRenderedState:fe},next:null};var A={};return i.next={memoizedState:A,baseState:A,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ci,lastRenderedState:A},next:null},a.memoizedState=i,a=a.alternate,a!==null&&(a.memoizedState=i),i}function h1(a){var i=u1(a);i.next===null&&(i=a.alternate.memoizedState),Eu(a,i.next.queue,{},qn())}function qp(){return na(Wu)}function f1(){return cs().memoizedState}function m1(){return cs().memoizedState}function aC(a){for(var i=a.return;i!==null;){switch(i.tag){case 24:case 3:var A=qn();a=Ot(A);var f=$t(i,a,A);f!==null&&(Nn(f,i,A),Sr(f,i,A)),i={cache:Zl()},a.payload=i;return}i=i.return}}function nC(a,i,A){var f=qn();A={lane:f,revertLane:0,gesture:null,action:A,hasEagerState:!1,eagerState:null,next:null},cf(a)?x1(i,A):(A=Jc(a,i,A,f),A!==null&&(Nn(A,a,f),g1(A,i,f)))}function p1(a,i,A){var f=qn();Eu(a,i,A,f)}function Eu(a,i,A,f){var C={lane:f,revertLane:0,gesture:null,action:A,hasEagerState:!1,eagerState:null,next:null};if(cf(a))x1(i,C);else{var E=a.alternate;if(a.lanes===0&&(E===null||E.lanes===0)&&(E=i.lastRenderedReducer,E!==null))try{var ee=i.lastRenderedState,ge=E(ee,A);if(C.hasEagerState=!0,C.eagerState=ge,ta(ge,ee))return ZA(a,i,C,0),Wr===null&&JA(),!1}catch{}if(A=Jc(a,i,C,f),A!==null)return Nn(A,a,f),g1(A,i,f),!0}return!1}function Gp(a,i,A,f){if(f={lane:2,revertLane:Bx(),gesture:null,action:f,hasEagerState:!1,eagerState:null,next:null},cf(a)){if(i)throw Error(n(479))}else i=Jc(a,A,f,2),i!==null&&Nn(i,a,2)}function cf(a){var i=a.alternate;return a===Ut||i!==null&&i===Ut}function x1(a,i){gn=Ia=!0;var A=a.pending;A===null?i.next=i:(i.next=A.next,A.next=i),a.pending=i}function g1(a,i,A){if((A&4194048)!==0){var f=i.lanes;f&=a.pendingLanes,A|=f,i.lanes=A,qa(a,A)}}var Uu={readContext:na,use:$l,useCallback:Hr,useContext:Hr,useEffect:Hr,useImperativeHandle:Hr,useLayoutEffect:Hr,useInsertionEffect:Hr,useMemo:Hr,useReducer:Hr,useRef:Hr,useState:Hr,useDebugValue:Hr,useDeferredValue:Hr,useTransition:Hr,useSyncExternalStore:Hr,useId:Hr,useHostTransitionStatus:Hr,useFormState:Hr,useActionState:Hr,useOptimistic:Hr,useMemoCache:Hr,useCacheRefresh:Hr};Uu.useEffectEvent=Hr;var b1={readContext:na,use:$l,useCallback:function(a,i){return Ws().memoizedState=[a,i===void 0?null:i],a},useContext:na,useEffect:r1,useImperativeHandle:function(a,i,A){A=A!=null?A.concat([a]):null,tA(4194308,4,i1.bind(null,i,a),A)},useLayoutEffect:function(a,i){return tA(4194308,4,a,i)},useInsertionEffect:function(a,i){tA(4,2,a,i)},useMemo:function(a,i){var A=Ws();i=i===void 0?null:i;var f=a();if(Sa){Dt(!0);try{a()}finally{Dt(!1)}}return A.memoizedState=[f,i],f},useReducer:function(a,i,A){var f=Ws();if(A!==void 0){var C=A(i);if(Sa){Dt(!0);try{A(i)}finally{Dt(!1)}}}else C=i;return f.memoizedState=f.baseState=C,a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:a,lastRenderedState:C},f.queue=a,a=a.dispatch=nC.bind(null,Ut,a),[f.memoizedState,a]},useRef:function(a){var i=Ws();return a={current:a},i.memoizedState=a},useState:function(a){a=_o(a);var i=a.queue,A=p1.bind(null,Ut,i);return i.dispatch=A,[a.memoizedState,A]},useDebugValue:Pp,useDeferredValue:function(a,i){var A=Ws();return Kp(A,a,i)},useTransition:function(){var a=_o(!1);return a=d1.bind(null,Ut,a.queue,!0,!1),Ws().memoizedState=a,[!1,a]},useSyncExternalStore:function(a,i,A){var f=Ut,C=Ws();if(ar){if(A===void 0)throw Error(n(407));A=A()}else{if(A=i(),Wr===null)throw Error(n(349));(or&127)!==0||Xi(f,i,A)}C.memoizedState=A;var E={value:A,getSnapshot:i};return C.queue=E,r1(_u.bind(null,f,E,a),[a]),f.flags|=2048,Al(9,{destroy:void 0},Su.bind(null,f,E,A,i),null),A},useId:function(){var a=Ws(),i=Wr.identifierPrefix;if(ar){var A=pn,f=mn;A=(f&~(1<<32-Gt(f)-1)).toString(32)+A,i="_"+i+"R_"+A,A=_s++,0<\/script>",E=E.removeChild(E.firstChild);break;case"select":E=typeof f.is=="string"?ee.createElement("select",{is:f.is}):ee.createElement("select"),f.multiple?E.multiple=!0:f.size&&(E.size=f.size);break;default:E=typeof f.is=="string"?ee.createElement(C,{is:f.is}):ee.createElement(C)}}E[Qr]=i,E[ts]=f;e:for(ee=i.child;ee!==null;){if(ee.tag===5||ee.tag===6)E.appendChild(ee.stateNode);else if(ee.tag!==4&&ee.tag!==27&&ee.child!==null){ee.child.return=ee,ee=ee.child;continue}if(ee===i)break e;for(;ee.sibling===null;){if(ee.return===null||ee.return===i)break e;ee=ee.return}ee.sibling.return=ee.return,ee=ee.sibling}i.stateNode=E;e:switch(ka(E,C,f),C){case"button":case"input":case"select":case"textarea":f=!!f.autoFocus;break e;case"img":f=!0;break e;default:f=!1}f&&dl(i)}}return is(i),ix(i,i.type,a===null?null:a.memoizedProps,i.pendingProps,A),null;case 6:if(a&&i.stateNode!=null)a.memoizedProps!==f&&dl(i);else{if(typeof f!="string"&&i.stateNode===null)throw Error(n(166));if(a=J.current,aa(i)){if(a=i.stateNode,A=i.memoizedProps,f=null,C=sa,C!==null)switch(C.tag){case 27:case 5:f=C.memoizedProps}a[Qr]=i,a=!!(a.nodeValue===A||f!==null&&f.suppressHydrationWarning===!0||Rw(a.nodeValue,A)),a||yo(i,!0)}else a=Ff(a).createTextNode(f),a[Qr]=i,i.stateNode=a}return is(i),null;case 31:if(A=i.memoizedState,a===null||a.memoizedState!==null){if(f=aa(i),A!==null){if(a===null){if(!f)throw Error(n(318));if(a=i.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(n(557));a[Qr]=i}else nl(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;is(i),a=!1}else A=vu(),a!==null&&a.memoizedState!==null&&(a.memoizedState.hydrationErrors=A),a=!0;if(!a)return i.flags&256?(Lr(i),i):(Lr(i),null);if((i.flags&128)!==0)throw Error(n(558))}return is(i),null;case 13:if(f=i.memoizedState,a===null||a.memoizedState!==null&&a.memoizedState.dehydrated!==null){if(C=aa(i),f!==null&&f.dehydrated!==null){if(a===null){if(!C)throw Error(n(318));if(C=i.memoizedState,C=C!==null?C.dehydrated:null,!C)throw Error(n(317));C[Qr]=i}else nl(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;is(i),C=!1}else C=vu(),a!==null&&a.memoizedState!==null&&(a.memoizedState.hydrationErrors=C),C=!0;if(!C)return i.flags&256?(Lr(i),i):(Lr(i),null)}return Lr(i),(i.flags&128)!==0?(i.lanes=A,i):(A=f!==null,a=a!==null&&a.memoizedState!==null,A&&(f=i.child,C=null,f.alternate!==null&&f.alternate.memoizedState!==null&&f.alternate.memoizedState.cachePool!==null&&(C=f.alternate.memoizedState.cachePool.pool),E=null,f.memoizedState!==null&&f.memoizedState.cachePool!==null&&(E=f.memoizedState.cachePool.pool),E!==C&&(f.flags|=2048)),A!==a&&A&&(i.child.flags|=8192),mf(i,i.updateQueue),is(i),null);case 4:return re(),a===null&&_x(i.stateNode.containerInfo),is(i),null;case 10:return xn(i.type),is(i),null;case 19:if(D(hr),f=i.memoizedState,f===null)return is(i),null;if(C=(i.flags&128)!==0,E=f.rendering,E===null)if(C)Lu(f,!1);else{if(ks!==0||a!==null&&(a.flags&128)!==0)for(a=i.child;a!==null;){if(E=ma(a),E!==null){for(i.flags|=128,Lu(f,!1),a=E.updateQueue,i.updateQueue=a,mf(i,a),i.subtreeFlags=0,a=A,A=i.child;A!==null;)ec(A,a),A=A.sibling;return $(hr,hr.current&1|2),ar&&tn(i,f.treeForkCount),i.child}a=a.sibling}f.tail!==null&&Re()>yf&&(i.flags|=128,C=!0,Lu(f,!1),i.lanes=4194304)}else{if(!C)if(a=ma(E),a!==null){if(i.flags|=128,C=!0,a=a.updateQueue,i.updateQueue=a,mf(i,a),Lu(f,!0),f.tail===null&&f.tailMode==="hidden"&&!E.alternate&&!ar)return is(i),null}else 2*Re()-f.renderingStartTime>yf&&A!==536870912&&(i.flags|=128,C=!0,Lu(f,!1),i.lanes=4194304);f.isBackwards?(E.sibling=i.child,i.child=E):(a=f.last,a!==null?a.sibling=E:i.child=E,f.last=E)}return f.tail!==null?(a=f.tail,f.rendering=a,f.tail=a.sibling,f.renderingStartTime=Re(),a.sibling=null,A=hr.current,$(hr,C?A&1|2:A&1),ar&&tn(i,f.treeForkCount),a):(is(i),null);case 22:case 23:return Lr(i),Ds(),f=i.memoizedState!==null,a!==null?a.memoizedState!==null!==f&&(i.flags|=8192):f&&(i.flags|=8192),f?(A&536870912)!==0&&(i.flags&128)===0&&(is(i),i.subtreeFlags&6&&(i.flags|=8192)):is(i),A=i.updateQueue,A!==null&&mf(i,A.retryQueue),A=null,a!==null&&a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(A=a.memoizedState.cachePool.pool),f=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(f=i.memoizedState.cachePool.pool),f!==A&&(i.flags|=2048),a!==null&&D(pe),null;case 24:return A=null,a!==null&&(A=a.memoizedState.cache),i.memoizedState.cache!==A&&(i.flags|=2048),xn(gs),is(i),null;case 25:return null;case 30:return null}throw Error(n(156,i.tag))}function cC(a,i){switch(sd(i),i.tag){case 1:return a=i.flags,a&65536?(i.flags=a&-65537|128,i):null;case 3:return xn(gs),re(),a=i.flags,(a&65536)!==0&&(a&128)===0?(i.flags=a&-65537|128,i):null;case 26:case 27:case 5:return oe(i),null;case 31:if(i.memoizedState!==null){if(Lr(i),i.alternate===null)throw Error(n(340));nl()}return a=i.flags,a&65536?(i.flags=a&-65537|128,i):null;case 13:if(Lr(i),a=i.memoizedState,a!==null&&a.dehydrated!==null){if(i.alternate===null)throw Error(n(340));nl()}return a=i.flags,a&65536?(i.flags=a&-65537|128,i):null;case 19:return D(hr),null;case 4:return re(),null;case 10:return xn(i.type),null;case 22:case 23:return Lr(i),Ds(),a!==null&&D(pe),a=i.flags,a&65536?(i.flags=a&-65537|128,i):null;case 24:return xn(gs),null;case 25:return null;default:return null}}function K1(a,i){switch(sd(i),i.tag){case 3:xn(gs),re();break;case 26:case 27:case 5:oe(i);break;case 4:re();break;case 31:i.memoizedState!==null&&Lr(i);break;case 13:Lr(i);break;case 19:D(hr);break;case 10:xn(i.type);break;case 22:case 23:Lr(i),Ds(),a!==null&&D(pe);break;case 24:xn(gs)}}function Tu(a,i){try{var A=i.updateQueue,f=A!==null?A.lastEffect:null;if(f!==null){var C=f.next;A=C;do{if((A.tag&a)===a){f=void 0;var E=A.create,ee=A.inst;f=E(),ee.destroy=f}A=A.next}while(A!==C)}}catch(ge){Ir(i,i.return,ge)}}function sA(a,i,A){try{var f=i.updateQueue,C=f!==null?f.lastEffect:null;if(C!==null){var E=C.next;f=E;do{if((f.tag&a)===a){var ee=f.inst,ge=ee.destroy;if(ge!==void 0){ee.destroy=void 0,C=i;var ke=A,Ke=ge;try{Ke()}catch(Ye){Ir(C,ke,Ye)}}}f=f.next}while(f!==E)}}catch(Ye){Ir(i,i.return,Ye)}}function z1(a){var i=a.updateQueue;if(i!==null){var A=a.stateNode;try{js(i,A)}catch(f){Ir(a,a.return,f)}}}function q1(a,i,A){A.props=oc(a.type,a.memoizedProps),A.state=a.memoizedState;try{A.componentWillUnmount()}catch(f){Ir(a,i,f)}}function Iu(a,i){try{var A=a.ref;if(A!==null){switch(a.tag){case 26:case 27:case 5:var f=a.stateNode;break;case 30:f=a.stateNode;break;default:f=a.stateNode}typeof A=="function"?a.refCleanup=A(f):A.current=f}}catch(C){Ir(a,i,C)}}function ko(a,i){var A=a.ref,f=a.refCleanup;if(A!==null)if(typeof f=="function")try{f()}catch(C){Ir(a,i,C)}finally{a.refCleanup=null,a=a.alternate,a!=null&&(a.refCleanup=null)}else if(typeof A=="function")try{A(null)}catch(C){Ir(a,i,C)}else A.current=null}function G1(a){var i=a.type,A=a.memoizedProps,f=a.stateNode;try{e:switch(i){case"button":case"input":case"select":case"textarea":A.autoFocus&&f.focus();break e;case"img":A.src?f.src=A.src:A.srcSet&&(f.srcset=A.srcSet)}}catch(C){Ir(a,a.return,C)}}function ox(a,i,A){try{var f=a.stateNode;UC(f,a.type,A,i),f[ts]=i}catch(C){Ir(a,a.return,C)}}function V1(a){return a.tag===5||a.tag===3||a.tag===26||a.tag===27&&cA(a.type)||a.tag===4}function lx(a){e:for(;;){for(;a.sibling===null;){if(a.return===null||V1(a.return))return null;a=a.return}for(a.sibling.return=a.return,a=a.sibling;a.tag!==5&&a.tag!==6&&a.tag!==18;){if(a.tag===27&&cA(a.type)||a.flags&2||a.child===null||a.tag===4)continue e;a.child.return=a,a=a.child}if(!(a.flags&2))return a.stateNode}}function Ax(a,i,A){var f=a.tag;if(f===5||f===6)a=a.stateNode,i?(A.nodeType===9?A.body:A.nodeName==="HTML"?A.ownerDocument.body:A).insertBefore(a,i):(i=A.nodeType===9?A.body:A.nodeName==="HTML"?A.ownerDocument.body:A,i.appendChild(a),A=A._reactRootContainer,A!=null||i.onclick!==null||(i.onclick=In));else if(f!==4&&(f===27&&cA(a.type)&&(A=a.stateNode,i=null),a=a.child,a!==null))for(Ax(a,i,A),a=a.sibling;a!==null;)Ax(a,i,A),a=a.sibling}function pf(a,i,A){var f=a.tag;if(f===5||f===6)a=a.stateNode,i?A.insertBefore(a,i):A.appendChild(a);else if(f!==4&&(f===27&&cA(a.type)&&(A=a.stateNode),a=a.child,a!==null))for(pf(a,i,A),a=a.sibling;a!==null;)pf(a,i,A),a=a.sibling}function W1(a){var i=a.stateNode,A=a.memoizedProps;try{for(var f=a.type,C=i.attributes;C.length;)i.removeAttributeNode(C[0]);ka(i,f,A),i[Qr]=a,i[ts]=A}catch(E){Ir(a,a.return,E)}}var ul=!1,Ys=!1,cx=!1,X1=typeof WeakSet=="function"?WeakSet:Set,pa=null;function dC(a,i){if(a=a.containerInfo,Ex=Df,a=zi(a),oi(a)){if("selectionStart"in a)var A={start:a.selectionStart,end:a.selectionEnd};else e:{A=(A=a.ownerDocument)&&A.defaultView||window;var f=A.getSelection&&A.getSelection();if(f&&f.rangeCount!==0){A=f.anchorNode;var C=f.anchorOffset,E=f.focusNode;f=f.focusOffset;try{A.nodeType,E.nodeType}catch{A=null;break e}var ee=0,ge=-1,ke=-1,Ke=0,Ye=0,tt=a,qe=null;t:for(;;){for(var Ge;tt!==A||C!==0&&tt.nodeType!==3||(ge=ee+C),tt!==E||f!==0&&tt.nodeType!==3||(ke=ee+f),tt.nodeType===3&&(ee+=tt.nodeValue.length),(Ge=tt.firstChild)!==null;)qe=tt,tt=Ge;for(;;){if(tt===a)break t;if(qe===A&&++Ke===C&&(ge=ee),qe===E&&++Ye===f&&(ke=ee),(Ge=tt.nextSibling)!==null)break;tt=qe,qe=tt.parentNode}tt=Ge}A=ge===-1||ke===-1?null:{start:ge,end:ke}}else A=null}A=A||{start:0,end:0}}else A=null;for(Ux={focusedElem:a,selectionRange:A},Df=!1,pa=i;pa!==null;)if(i=pa,a=i.child,(i.subtreeFlags&1028)!==0&&a!==null)a.return=i,pa=a;else for(;pa!==null;){switch(i=pa,E=i.alternate,a=i.flags,i.tag){case 0:if((a&4)!==0&&(a=i.updateQueue,a=a!==null?a.events:null,a!==null))for(A=0;A title"))),ka(E,f,A),E[Qr]=a,fs(E),f=E;break e;case"link":var ee=tv("link","href",C).get(f+(A.href||""));if(ee){for(var ge=0;gePr&&(ee=Pr,Pr=Mt,Mt=ee);var Ie=Gl(ge,Mt),Qe=Gl(ge,Pr);if(Ie&&Qe&&(Ge.rangeCount!==1||Ge.anchorNode!==Ie.node||Ge.anchorOffset!==Ie.offset||Ge.focusNode!==Qe.node||Ge.focusOffset!==Qe.offset)){var Pe=tt.createRange();Pe.setStart(Ie.node,Ie.offset),Ge.removeAllRanges(),Mt>Pr?(Ge.addRange(Pe),Ge.extend(Qe.node,Qe.offset)):(Pe.setEnd(Qe.node,Qe.offset),Ge.addRange(Pe))}}}}for(tt=[],Ge=ge;Ge=Ge.parentNode;)Ge.nodeType===1&&tt.push({element:Ge,left:Ge.scrollLeft,top:Ge.scrollTop});for(typeof ge.focus=="function"&&ge.focus(),ge=0;geA?32:A,ae.T=null,A=xx,xx=null;var E=oA,ee=xl;if(oa=0,wd=oA=null,xl=0,(kr&6)!==0)throw Error(n(331));var ge=kr;if(kr|=4,iw(E.current),sw(E,E.current,ee,A),kr=ge,Pu(0,!1),_t&&typeof _t.onPostCommitFiberRoot=="function")try{_t.onPostCommitFiberRoot(jt,E)}catch{}return!0}finally{se.p=C,ae.T=f,Bw(a,i)}}function Cw(a,i,A){i=un(A,i),i=Yp(a.stateNode,i,2),a=$t(a,i,2),a!==null&&(Et(a,2),Fo(a))}function Ir(a,i,A){if(a.tag===3)Cw(a,a,A);else for(;i!==null;){if(i.tag===3){Cw(i,a,A);break}else if(i.tag===1){var f=i.stateNode;if(typeof i.type.getDerivedStateFromError=="function"||typeof f.componentDidCatch=="function"&&(iA===null||!iA.has(f))){a=un(A,a),A=S1(2),f=$t(i,A,2),f!==null&&(_1(A,f,i,a),Et(f,2),Fo(f));break}}i=i.return}}function wx(a,i,A){var f=a.pingCache;if(f===null){f=a.pingCache=new fC;var C=new Set;f.set(i,C)}else C=f.get(i),C===void 0&&(C=new Set,f.set(i,C));C.has(A)||(hx=!0,C.add(A),a=bC.bind(null,a,i,A),i.then(a,a))}function bC(a,i,A){var f=a.pingCache;f!==null&&f.delete(i),a.pingedLanes|=a.suspendedLanes&A,a.warmLanes&=~A,Wr===a&&(or&A)===A&&(ks===4||ks===3&&(or&62914560)===or&&300>Re()-bf?(kr&2)===0&&vd(a,0):fx|=A,yd===or&&(yd=0)),Fo(a)}function Sw(a,i){i===0&&(i=Xn()),a=Gi(a,i),a!==null&&(Et(a,i),Fo(a))}function yC(a){var i=a.memoizedState,A=0;i!==null&&(A=i.retryLane),Sw(a,A)}function wC(a,i){var A=0;switch(a.tag){case 31:case 13:var f=a.stateNode,C=a.memoizedState;C!==null&&(A=C.retryLane);break;case 19:f=a.stateNode;break;case 22:f=a.stateNode._retryCache;break;default:throw Error(n(314))}f!==null&&f.delete(i),Sw(a,A)}function vC(a,i){return G(a,i)}var Cf=null,Bd=null,vx=!1,Sf=!1,Nx=!1,AA=0;function Fo(a){a!==Bd&&a.next===null&&(Bd===null?Cf=Bd=a:Bd=Bd.next=a),Sf=!0,vx||(vx=!0,BC())}function Pu(a,i){if(!Nx&&Sf){Nx=!0;do for(var A=!1,f=Cf;f!==null;){if(a!==0){var C=f.pendingLanes;if(C===0)var E=0;else{var ee=f.suspendedLanes,ge=f.pingedLanes;E=(1<<31-Gt(42|a)+1)-1,E&=C&~(ee&~ge),E=E&201326741?E&201326741|1:E?E|2:0}E!==0&&(A=!0,Ew(f,E))}else E=or,E=cr(f,f===Wr?E:0,f.cancelPendingCommit!==null||f.timeoutHandle!==-1),(E&3)===0||_n(f,E)||(A=!0,Ew(f,E));f=f.next}while(A);Nx=!1}}function NC(){_w()}function _w(){Sf=vx=!1;var a=0;AA!==0&&LC()&&(a=AA);for(var i=Re(),A=null,f=Cf;f!==null;){var C=f.next,E=kw(f,i);E===0?(f.next=null,A===null?Cf=C:A.next=C,C===null&&(Bd=A)):(A=f,(a!==0||(E&3)!==0)&&(Sf=!0)),f=C}oa!==0&&oa!==5||Pu(a),AA!==0&&(AA=0)}function kw(a,i){for(var A=a.suspendedLanes,f=a.pingedLanes,C=a.expirationTimes,E=a.pendingLanes&-62914561;0ge)break;var Ye=ke.transferSize,tt=ke.initiatorType;Ye&&Ow(tt)&&(ke=ke.responseEnd,ee+=Ye*(ke"u"?null:document;function Jw(a,i,A){var f=jd;if(f&&typeof i=="string"&&i){var C=vs(i);C='link[rel="'+a+'"][href="'+C+'"]',typeof A=="string"&&(C+='[crossorigin="'+A+'"]'),Yw.has(C)||(Yw.add(C),a={rel:a,crossOrigin:A,href:i},f.querySelector(C)===null&&(i=f.createElement("link"),ka(i,"link",a),fs(i),f.head.appendChild(i)))}}function KC(a){gl.D(a),Jw("dns-prefetch",a,null)}function zC(a,i){gl.C(a,i),Jw("preconnect",a,i)}function qC(a,i,A){gl.L(a,i,A);var f=jd;if(f&&a&&i){var C='link[rel="preload"][as="'+vs(i)+'"]';i==="image"&&A&&A.imageSrcSet?(C+='[imagesrcset="'+vs(A.imageSrcSet)+'"]',typeof A.imageSizes=="string"&&(C+='[imagesizes="'+vs(A.imageSizes)+'"]')):C+='[href="'+vs(a)+'"]';var E=C;switch(i){case"style":E=Cd(a);break;case"script":E=Sd(a)}hi.has(E)||(a=x({rel:"preload",href:i==="image"&&A&&A.imageSrcSet?void 0:a,as:i},A),hi.set(E,a),f.querySelector(C)!==null||i==="style"&&f.querySelector(Gu(E))||i==="script"&&f.querySelector(Vu(E))||(i=f.createElement("link"),ka(i,"link",a),fs(i),f.head.appendChild(i)))}}function GC(a,i){gl.m(a,i);var A=jd;if(A&&a){var f=i&&typeof i.as=="string"?i.as:"script",C='link[rel="modulepreload"][as="'+vs(f)+'"][href="'+vs(a)+'"]',E=C;switch(f){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":E=Sd(a)}if(!hi.has(E)&&(a=x({rel:"modulepreload",href:a},i),hi.set(E,a),A.querySelector(C)===null)){switch(f){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(A.querySelector(Vu(E)))return}f=A.createElement("link"),ka(f,"link",a),fs(f),A.head.appendChild(f)}}}function VC(a,i,A){gl.S(a,i,A);var f=jd;if(f&&a){var C=Jn(f).hoistableStyles,E=Cd(a);i=i||"default";var ee=C.get(E);if(!ee){var ge={loading:0,preload:null};if(ee=f.querySelector(Gu(E)))ge.loading=5;else{a=x({rel:"stylesheet",href:a,"data-precedence":i},A),(A=hi.get(E))&&Ox(a,A);var ke=ee=f.createElement("link");fs(ke),ka(ke,"link",a),ke._p=new Promise(function(Ke,Ye){ke.onload=Ke,ke.onerror=Ye}),ke.addEventListener("load",function(){ge.loading|=1}),ke.addEventListener("error",function(){ge.loading|=2}),ge.loading|=4,Uf(ee,i,f)}ee={type:"stylesheet",instance:ee,count:1,state:ge},C.set(E,ee)}}}function WC(a,i){gl.X(a,i);var A=jd;if(A&&a){var f=Jn(A).hoistableScripts,C=Sd(a),E=f.get(C);E||(E=A.querySelector(Vu(C)),E||(a=x({src:a,async:!0},i),(i=hi.get(C))&&Hx(a,i),E=A.createElement("script"),fs(E),ka(E,"link",a),A.head.appendChild(E)),E={type:"script",instance:E,count:1,state:null},f.set(C,E))}}function XC(a,i){gl.M(a,i);var A=jd;if(A&&a){var f=Jn(A).hoistableScripts,C=Sd(a),E=f.get(C);E||(E=A.querySelector(Vu(C)),E||(a=x({src:a,async:!0,type:"module"},i),(i=hi.get(C))&&Hx(a,i),E=A.createElement("script"),fs(E),ka(E,"link",a),A.head.appendChild(E)),E={type:"script",instance:E,count:1,state:null},f.set(C,E))}}function Zw(a,i,A,f){var C=(C=J.current)?Ef(C):null;if(!C)throw Error(n(446));switch(a){case"meta":case"title":return null;case"style":return typeof A.precedence=="string"&&typeof A.href=="string"?(i=Cd(A.href),A=Jn(C).hoistableStyles,f=A.get(i),f||(f={type:"style",instance:null,count:0,state:null},A.set(i,f)),f):{type:"void",instance:null,count:0,state:null};case"link":if(A.rel==="stylesheet"&&typeof A.href=="string"&&typeof A.precedence=="string"){a=Cd(A.href);var E=Jn(C).hoistableStyles,ee=E.get(a);if(ee||(C=C.ownerDocument||C,ee={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},E.set(a,ee),(E=C.querySelector(Gu(a)))&&!E._p&&(ee.instance=E,ee.state.loading=5),hi.has(a)||(A={rel:"preload",as:"style",href:A.href,crossOrigin:A.crossOrigin,integrity:A.integrity,media:A.media,hrefLang:A.hrefLang,referrerPolicy:A.referrerPolicy},hi.set(a,A),E||YC(C,a,A,ee.state))),i&&f===null)throw Error(n(528,""));return ee}if(i&&f!==null)throw Error(n(529,""));return null;case"script":return i=A.async,A=A.src,typeof A=="string"&&i&&typeof i!="function"&&typeof i!="symbol"?(i=Sd(A),A=Jn(C).hoistableScripts,f=A.get(i),f||(f={type:"script",instance:null,count:0,state:null},A.set(i,f)),f):{type:"void",instance:null,count:0,state:null};default:throw Error(n(444,a))}}function Cd(a){return'href="'+vs(a)+'"'}function Gu(a){return'link[rel="stylesheet"]['+a+"]"}function $w(a){return x({},a,{"data-precedence":a.precedence,precedence:null})}function YC(a,i,A,f){a.querySelector('link[rel="preload"][as="style"]['+i+"]")?f.loading=1:(i=a.createElement("link"),f.preload=i,i.addEventListener("load",function(){return f.loading|=1}),i.addEventListener("error",function(){return f.loading|=2}),ka(i,"link",A),fs(i),a.head.appendChild(i))}function Sd(a){return'[src="'+vs(a)+'"]'}function Vu(a){return"script[async]"+a}function ev(a,i,A){if(i.count++,i.instance===null)switch(i.type){case"style":var f=a.querySelector('style[data-href~="'+vs(A.href)+'"]');if(f)return i.instance=f,fs(f),f;var C=x({},A,{"data-href":A.href,"data-precedence":A.precedence,href:null,precedence:null});return f=(a.ownerDocument||a).createElement("style"),fs(f),ka(f,"style",C),Uf(f,A.precedence,a),i.instance=f;case"stylesheet":C=Cd(A.href);var E=a.querySelector(Gu(C));if(E)return i.state.loading|=4,i.instance=E,fs(E),E;f=$w(A),(C=hi.get(C))&&Ox(f,C),E=(a.ownerDocument||a).createElement("link"),fs(E);var ee=E;return ee._p=new Promise(function(ge,ke){ee.onload=ge,ee.onerror=ke}),ka(E,"link",f),i.state.loading|=4,Uf(E,A.precedence,a),i.instance=E;case"script":return E=Sd(A.src),(C=a.querySelector(Vu(E)))?(i.instance=C,fs(C),C):(f=A,(C=hi.get(E))&&(f=x({},A),Hx(f,C)),a=a.ownerDocument||a,C=a.createElement("script"),fs(C),ka(C,"link",f),a.head.appendChild(C),i.instance=C);case"void":return null;default:throw Error(n(443,i.type))}else i.type==="stylesheet"&&(i.state.loading&4)===0&&(f=i.instance,i.state.loading|=4,Uf(f,A.precedence,a));return i.instance}function Uf(a,i,A){for(var f=A.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),C=f.length?f[f.length-1]:null,E=C,ee=0;ee title"):null)}function JC(a,i,A){if(A===1||i.itemProp!=null)return!1;switch(a){case"meta":case"title":return!0;case"style":if(typeof i.precedence!="string"||typeof i.href!="string"||i.href==="")break;return!0;case"link":if(typeof i.rel!="string"||typeof i.href!="string"||i.href===""||i.onLoad||i.onError)break;return i.rel==="stylesheet"?(a=i.disabled,typeof i.precedence=="string"&&a==null):!0;case"script":if(i.async&&typeof i.async!="function"&&typeof i.async!="symbol"&&!i.onLoad&&!i.onError&&i.src&&typeof i.src=="string")return!0}return!1}function sv(a){return!(a.type==="stylesheet"&&(a.state.loading&3)===0)}function ZC(a,i,A,f){if(A.type==="stylesheet"&&(typeof f.media!="string"||matchMedia(f.media).matches!==!1)&&(A.state.loading&4)===0){if(A.instance===null){var C=Cd(f.href),E=i.querySelector(Gu(C));if(E){i=E._p,i!==null&&typeof i=="object"&&typeof i.then=="function"&&(a.count++,a=Lf.bind(a),i.then(a,a)),A.state.loading|=4,A.instance=E,fs(E);return}E=i.ownerDocument||i,f=$w(f),(C=hi.get(C))&&Ox(f,C),E=E.createElement("link"),fs(E);var ee=E;ee._p=new Promise(function(ge,ke){ee.onload=ge,ee.onerror=ke}),ka(E,"link",f),A.instance=E}a.stylesheets===null&&(a.stylesheets=new Map),a.stylesheets.set(A,i),(i=A.state.preload)&&(A.state.loading&3)===0&&(a.count++,A=Lf.bind(a),i.addEventListener("load",A),i.addEventListener("error",A))}}var Mx=0;function $C(a,i){return a.stylesheets&&a.count===0&&If(a,a.stylesheets),0Mx?50:800)+i);return a.unsuspend=A,function(){a.unsuspend=null,clearTimeout(f),clearTimeout(C)}}:null}function Lf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)If(this,this.stylesheets);else if(this.unsuspend){var a=this.unsuspend;this.unsuspend=null,a()}}}var Tf=null;function If(a,i){a.stylesheets=null,a.unsuspend!==null&&(a.count++,Tf=new Map,i.forEach(e6,a),Tf=null,Lf.call(a))}function e6(a,i){if(!(i.state.loading&4)){var A=Tf.get(a);if(A)var f=A.get(null);else{A=new Map,Tf.set(a,A);for(var C=a.querySelectorAll("link[data-precedence],style[data-precedence]"),E=0;E"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(r)}catch(t){console.error(t)}}return r(),Zx.exports=q6(),Zx.exports}var V6=G6();const W6=h6(V6);function X6(){return null}const Y6={};function m4(r,t){let s;try{s=r()}catch{return}return{getItem:o=>{var l;const d=u=>u===null?null:JSON.parse(u,void 0),c=(l=s.getItem(o))!=null?l:null;return c instanceof Promise?c.then(d):d(c)},setItem:(o,l)=>s.setItem(o,JSON.stringify(l,void 0)),removeItem:o=>s.removeItem(o)}}const Th=r=>t=>{try{const s=r(t);return s instanceof Promise?s:{then(n){return Th(n)(s)},catch(n){return this}}}catch(s){return{then(n){return this},catch(n){return Th(n)(s)}}}},J6=(r,t)=>(s,n,o)=>{let l={getStorage:()=>localStorage,serialize:JSON.stringify,deserialize:JSON.parse,partialize:B=>B,version:0,merge:(B,g)=>({...g,...B}),...t},d=!1;const c=new Set,u=new Set;let h;try{h=l.getStorage()}catch{}if(!h)return r((...B)=>{console.warn(`[zustand persist middleware] Unable to update item '${l.name}', the given storage is currently unavailable.`),s(...B)},n,o);const m=Th(l.serialize),x=()=>{const B=l.partialize({...n()});let g;const j=m({state:B,version:l.version}).then(_=>h.setItem(l.name,_)).catch(_=>{g=_});if(g)throw g;return j},y=o.setState;o.setState=(B,g)=>{y(B,g),x()};const p=r((...B)=>{s(...B),x()},n,o);let v;const N=()=>{var B;if(!h)return;d=!1,c.forEach(j=>j(n()));const g=((B=l.onRehydrateStorage)==null?void 0:B.call(l,n()))||void 0;return Th(h.getItem.bind(h))(l.name).then(j=>{if(j)return l.deserialize(j)}).then(j=>{if(j)if(typeof j.version=="number"&&j.version!==l.version){if(l.migrate)return l.migrate(j.state,j.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return j.state}).then(j=>{var _;return v=l.merge(j,(_=n())!=null?_:p),s(v,!0),x()}).then(()=>{g?.(v,void 0),d=!0,u.forEach(j=>j(v))}).catch(j=>{g?.(void 0,j)})};return o.persist={setOptions:B=>{l={...l,...B},B.getStorage&&(h=B.getStorage())},clearStorage:()=>{h?.removeItem(l.name)},getOptions:()=>l,rehydrate:()=>N(),hasHydrated:()=>d,onHydrate:B=>(c.add(B),()=>{c.delete(B)}),onFinishHydration:B=>(u.add(B),()=>{u.delete(B)})},N(),v||p},Z6=(r,t)=>(s,n,o)=>{let l={storage:m4(()=>localStorage),partialize:N=>N,version:0,merge:(N,B)=>({...B,...N}),...t},d=!1;const c=new Set,u=new Set;let h=l.storage;if(!h)return r((...N)=>{console.warn(`[zustand persist middleware] Unable to update item '${l.name}', the given storage is currently unavailable.`),s(...N)},n,o);const m=()=>{const N=l.partialize({...n()});return h.setItem(l.name,{state:N,version:l.version})},x=o.setState;o.setState=(N,B)=>{x(N,B),m()};const y=r((...N)=>{s(...N),m()},n,o);o.getInitialState=()=>y;let p;const v=()=>{var N,B;if(!h)return;d=!1,c.forEach(j=>{var _;return j((_=n())!=null?_:y)});const g=((B=l.onRehydrateStorage)==null?void 0:B.call(l,(N=n())!=null?N:y))||void 0;return Th(h.getItem.bind(h))(l.name).then(j=>{if(j)if(typeof j.version=="number"&&j.version!==l.version){if(l.migrate)return[!0,l.migrate(j.state,j.version)];console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,j.state];return[!1,void 0]}).then(j=>{var _;const[w,L]=j;if(p=l.merge(L,(_=n())!=null?_:y),s(p,!0),w)return m()}).then(()=>{g?.(p,void 0),p=n(),d=!0,u.forEach(j=>j(p))}).catch(j=>{g?.(void 0,j)})};return o.persist={setOptions:N=>{l={...l,...N},N.storage&&(h=N.storage)},clearStorage:()=>{h?.removeItem(l.name)},getOptions:()=>l,rehydrate:()=>v(),hasHydrated:()=>d,onHydrate:N=>(c.add(N),()=>{c.delete(N)}),onFinishHydration:N=>(u.add(N),()=>{u.delete(N)})},l.skipHydration||v(),p||y},$6=(r,t)=>"getStorage"in t||"serialize"in t||"deserialize"in t?((Y6?"production":void 0)!=="production"&&console.warn("[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Use `storage` option instead."),J6(r,t)):Z6(r,t),eS=$6,hu=g6()(eS(r=>({token:null,user:null,isAuthenticated:!1,setAuth:(t,s)=>r({token:t,user:s,isAuthenticated:!0}),clearAuth:()=>r({token:null,user:null,isAuthenticated:!1}),updateUser:t=>r({user:t})}),{name:"calypso-auth",storage:m4(()=>localStorage)})),ze=b6.create({baseURL:"/api/v1",headers:{"Content-Type":"application/json","Cache-Control":"no-cache, no-store, must-revalidate",Pragma:"no-cache",Expires:"0"}});ze.interceptors.request.use(r=>{const t=hu.getState().token;return t&&(r.headers.Authorization=`Bearer ${t}`),r},r=>Promise.reject(r));ze.interceptors.response.use(r=>r,r=>(r.response?.status===401&&(hu.getState().clearAuth(),window.location.href="/login"),Promise.reject(r)));const tS={login:async r=>(await ze.post("/auth/login",r)).data};function rS(){const r=Ph(),t=hu(m=>m.setAuth),[s,n]=Ce.useState(""),[o,l]=Ce.useState(""),[d,c]=Ce.useState(""),u=ft({mutationFn:tS.login,onSuccess:m=>{t(m.token,m.user),r("/")},onError:m=>{c(m.response?.data?.error||"Login failed")}}),h=m=>{m.preventDefault(),c(""),u.mutate({username:s,password:o})};return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:` input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus, input:-webkit-autofill:active { -webkit-box-shadow: 0 0 0 30px #111a22 inset !important; -webkit-text-fill-color: #ffffff !important; box-shadow: 0 0 0 30px #111a22 inset !important; caret-color: #ffffff !important; } input:-webkit-autofill::first-line { color: #ffffff !important; } `}),e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background-dark",children:e.jsxs("div",{className:"max-w-md w-full space-y-8 p-8 bg-card-dark border border-border-dark rounded-lg shadow-md",children:[e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("div",{className:"mb-4",children:e.jsx("img",{src:"/logo.png",alt:"Calypso Logo",className:"w-16 h-16 object-contain"})}),e.jsx("h2",{className:"text-center text-3xl font-extrabold text-white",children:"Calypso"}),e.jsx("p",{className:"mt-1 text-center text-xs text-text-secondary",children:"Dev Release V.1"}),e.jsx("p",{className:"mt-2 text-center text-sm text-text-secondary",children:"Adastra Backup Storage Appliance"}),e.jsx("p",{className:"mt-4 text-center text-sm text-text-secondary",children:"Sign in to your account"})]}),e.jsxs("form",{className:"mt-8 space-y-6",onSubmit:h,children:[d&&e.jsx("div",{className:"rounded-md bg-red-500/10 border border-red-500/30 p-4",children:e.jsx("p",{className:"text-sm text-red-400 font-medium",children:d})}),e.jsxs("div",{className:"rounded-md shadow-sm -space-y-px",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"username",className:"sr-only",children:"Username"}),e.jsx("input",{id:"username",name:"username",type:"text",required:!0,className:"appearance-none rounded-none relative block w-full px-3 py-2 border border-border-dark bg-[#111a22] placeholder-text-secondary text-white rounded-t-md focus:outline-none focus:ring-primary focus:border-primary focus:z-10 sm:text-sm autofill:bg-[#111a22] autofill:text-white",placeholder:"Username",value:s,onChange:m=>n(m.target.value),autoComplete:"username"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"password",className:"sr-only",children:"Password"}),e.jsx("input",{id:"password",name:"password",type:"password",required:!0,className:"appearance-none rounded-none relative block w-full px-3 py-2 border border-border-dark bg-[#111a22] placeholder-text-secondary text-white rounded-b-md focus:outline-none focus:ring-primary focus:border-primary focus:z-10 sm:text-sm autofill:bg-[#111a22] autofill:text-white",placeholder:"Password",value:o,onChange:m=>l(m.target.value),autoComplete:"current-password"})]})]}),e.jsx("div",{children:e.jsxs("button",{type:"submit",disabled:u.isPending,className:"relative group relative w-full flex justify-center py-2.5 px-4 border border-primary/30 bg-card-dark text-white text-sm font-bold rounded-lg hover:bg-[#233648] transition-all overflow-hidden electric-glow electric-glow-border disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx("span",{className:"absolute inset-0 bg-gradient-to-r from-primary/0 via-primary/15 to-primary/0 opacity-60"}),e.jsx("span",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/5 to-transparent animate-[shimmer_3s_infinite]"}),e.jsx("span",{className:"relative z-10 flex items-center gap-2",children:u.isPending?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"material-symbols-outlined text-[18px] animate-spin",children:"refresh"}),"Signing in..."]}):"Sign in"})]})})]})]})})]})}const Cc={listAlerts:async r=>(await ze.get("/monitoring/alerts",{params:r})).data,getAlert:async r=>(await ze.get(`/monitoring/alerts/${r}`)).data,acknowledgeAlert:async r=>{await ze.post(`/monitoring/alerts/${r}/acknowledge`)},resolveAlert:async r=>{await ze.post(`/monitoring/alerts/${r}/resolve`)},getMetrics:async()=>(await ze.get("/monitoring/metrics")).data},Xd={listDisks:async()=>(await ze.get("/storage/disks")).data.disks||[],syncDisks:async()=>(await ze.post("/storage/disks/sync")).data,listVolumeGroups:async()=>(await ze.get("/storage/volume-groups")).data.volume_groups||[],listRepositories:async()=>(await ze.get("/storage/repositories")).data.repositories||[],getRepository:async r=>(await ze.get(`/storage/repositories/${r}`)).data,createRepository:async r=>(await ze.post("/storage/repositories",r)).data,deleteRepository:async r=>{await ze.delete(`/storage/repositories/${r}`)}},sn={listPools:async()=>(await ze.get("/storage/zfs/pools")).data.pools||[],getPool:async r=>(await ze.get(`/storage/zfs/pools/${r}`)).data,createPool:async r=>(await ze.post("/storage/zfs/pools",r)).data,deletePool:async r=>{await ze.delete(`/storage/zfs/pools/${r}`)},addSpareDisk:async(r,t)=>{await ze.post(`/storage/zfs/pools/${r}/spare`,{disks:t})},listDatasets:async r=>(await ze.get(`/storage/zfs/pools/${r}/datasets`)).data.datasets||[],createDataset:async(r,t)=>(await ze.post(`/storage/zfs/pools/${r}/datasets`,t)).data,deleteDataset:async(r,t)=>{await ze.delete(`/storage/zfs/pools/${r}/datasets/${encodeURIComponent(t)}`)},getARCStats:async()=>(await ze.get("/storage/zfs/arc/stats")).data},$u={listSnapshots:async r=>{const t=r?`?dataset=${encodeURIComponent(r)}`:"";return(await ze.get(`/storage/zfs/snapshots${t}`)).data.snapshots||[]},createSnapshot:async r=>{await ze.post("/storage/zfs/snapshots",r)},deleteSnapshot:async(r,t)=>{const s=t?"?recursive=true":"";await ze.delete(`/storage/zfs/snapshots/${encodeURIComponent(r)}${s}`)},rollbackSnapshot:async(r,t)=>{await ze.post(`/storage/zfs/snapshots/${encodeURIComponent(r)}/rollback`,{force:t||!1})},cloneSnapshot:async(r,t)=>{await ze.post(`/storage/zfs/snapshots/${encodeURIComponent(r)}/clone`,t)}},eh={listSchedules:async()=>(await ze.get("/storage/zfs/snapshot-schedules")).data.schedules||[],getSchedule:async r=>(await ze.get(`/storage/zfs/snapshot-schedules/${r}`)).data,createSchedule:async r=>(await ze.post("/storage/zfs/snapshot-schedules",r)).data,updateSchedule:async(r,t)=>(await ze.put(`/storage/zfs/snapshot-schedules/${r}`,t)).data,deleteSchedule:async r=>{await ze.delete(`/storage/zfs/snapshot-schedules/${r}`)},toggleSchedule:async(r,t)=>{await ze.post(`/storage/zfs/snapshot-schedules/${r}/toggle`,{enabled:t})}},th={listTasks:async r=>{const t=r?`?direction=${r}`:"";return(await ze.get(`/storage/zfs/replication-tasks${t}`)).data.tasks||[]},getTask:async r=>(await ze.get(`/storage/zfs/replication-tasks/${r}`)).data,createTask:async r=>(await ze.post("/storage/zfs/replication-tasks",r)).data,updateTask:async(r,t)=>(await ze.put(`/storage/zfs/replication-tasks/${r}`,t)).data,deleteTask:async r=>{await ze.delete(`/storage/zfs/replication-tasks/${r}`)}},ao={listNetworkInterfaces:async()=>(await ze.get("/system/interfaces")).data.interfaces||[],updateNetworkInterface:async(r,t)=>(await ze.put(`/system/interfaces/${r}`,t)).data.interface,getNTPSettings:async()=>(await ze.get("/system/ntp")).data.settings,saveNTPSettings:async r=>{await ze.post("/system/ntp",r)},listServices:async()=>(await ze.get("/system/services")).data.services||[],restartService:async r=>{await ze.post(`/system/services/${r}/restart`)},getSystemLogs:async(r=30)=>(await ze.get(`/system/logs?limit=${r}`)).data.logs||[],getNetworkThroughput:async(r="5m")=>(await ze.get(`/system/network/throughput?duration=${r}`)).data.data||[],getManagementIPAddress:async()=>(await ze.get("/system/management-ip")).data.ip_address};function fr(r,t=2){if(r===0)return"0 Bytes";const s=1024,n=t<0?0:t,o=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],l=Math.floor(Math.log(r)/Math.log(s));return parseFloat((r/Math.pow(s,l)).toFixed(n))+" "+o[l]}function sS(r){const t=new Date,s=typeof r=="string"?new Date(r):r,n=Math.floor((t.getTime()-s.getTime())/1e3);return n<60?"just now":n<3600?`${Math.floor(n/60)} minutes ago`:n<86400?`${Math.floor(n/3600)} hours ago`:n<604800?`${Math.floor(n/86400)} days ago`:s.toLocaleDateString()}const tg=[{id:"1",name:"Daily Backup: VM-Cluster-01",type:"Replication",progress:45,speed:"145 MB/s",status:"running",eta:"1h 12m"},{id:"2",name:"ZFS Scrub: Pool-01",type:"Maintenance",progress:78,speed:"1.2 GB/s",status:"running"}];function aS(){const[r,t]=Ce.useState("jobs"),[s,n]=Ce.useState([]),o=5,{data:l=[],isLoading:d,refetch:c}=dt({queryKey:["system-logs"],queryFn:()=>ao.getSystemLogs(30),refetchInterval:600*1e3}),{data:u}=dt({queryKey:["health"],queryFn:async()=>(await ze.get("/health")).data,refetchInterval:o*1e3,staleTime:o*1e3*2,refetchOnWindowFocus:!1,refetchOnMount:!1,notifyOnChangeProps:["data","error"],structuralSharing:(M,V)=>JSON.stringify(M)===JSON.stringify(V)?M:V}),{data:h}=dt({queryKey:["metrics"],queryFn:Cc.getMetrics,refetchInterval:o*1e3,staleTime:o*1e3*2,refetchOnWindowFocus:!1,refetchOnMount:!1,notifyOnChangeProps:["data","error"],structuralSharing:(M,V)=>JSON.stringify(M)===JSON.stringify(V)?M:V}),{data:m}=dt({queryKey:["alerts","dashboard"],queryFn:()=>Cc.listAlerts({is_acknowledged:!1,limit:10}),refetchInterval:o*1e3,staleTime:o*1e3*2,refetchOnWindowFocus:!1,refetchOnMount:!1,notifyOnChangeProps:["data","error"],structuralSharing:(M,V)=>JSON.stringify(M)===JSON.stringify(V)?M:V}),{data:x=[]}=dt({queryKey:["storage","repositories"],queryFn:Xd.listRepositories,staleTime:60*1e3,refetchOnWindowFocus:!1,refetchOnMount:!1,notifyOnChangeProps:["data","error"],structuralSharing:(M,V)=>JSON.stringify(M)===JSON.stringify(V)?M:V}),{days:y,hours:p,minutes:v}=Ce.useMemo(()=>{const M=h?.system?.uptime_seconds||0;return{days:Math.floor(M/86400),hours:Math.floor(M%86400/3600),minutes:Math.floor(M%3600/60)}},[h?.system?.uptime_seconds]),{totalStorage:N,usedStorage:B,storagePercent:g}=Ce.useMemo(()=>{const M=Array.isArray(x)?x.reduce((ne,Z)=>ne+(Z?.size_bytes||0),0):0,V=Array.isArray(x)?x.reduce((ne,Z)=>ne+(Z?.used_bytes||0),0):0,T=M>0?V/M*100:0;return{totalStorage:M,usedStorage:V,storagePercent:T}},[x]),{data:j=[]}=dt({queryKey:["network-throughput"],queryFn:()=>ao.getNetworkThroughput("5m"),refetchInterval:5*1e3});Ce.useEffect(()=>{if(j.length>0){const M=j.slice(-30).map(V=>({time:V.time,inbound:Math.round(V.inbound),outbound:Math.round(V.outbound)}));n(M)}},[j]);const _=Ce.useMemo(()=>{if(s.length===0)return{inbound:0,outbound:0,total:0};const M=s[s.length-1];return{inbound:M.inbound,outbound:M.outbound,total:M.inbound+M.outbound}},[s]),w=Ce.useMemo(()=>s.length===0?0:Math.max(...s.map(M=>M.inbound+M.outbound)),[s]),{systemStatus:L,isHealthy:K}=Ce.useMemo(()=>{const M=u?.status==="healthy"?"System Healthy":"System Degraded",V=u?.status==="healthy";return{systemStatus:M,isHealthy:V}},[u?.status]);return e.jsxs("div",{className:"h-full bg-background-dark text-white",children:[e.jsx("header",{className:"flex-none px-6 py-5 border-b border-border-dark bg-background-dark/95 backdrop-blur z-10",children:e.jsxs("div",{className:"flex flex-wrap justify-between items-end gap-3 max-w-[1600px] mx-auto",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("h2",{className:"text-white text-3xl font-black tracking-tight",children:"System Monitor"}),e.jsx("p",{className:"text-text-secondary text-sm",children:"Real-time telemetry, storage health, and system event logs"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-card-dark rounded-lg border border-border-dark",children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[K&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-emerald-500"})]}),!K&&e.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-yellow-500"})]}),e.jsx("span",{className:`text-xs font-medium ${K?"text-emerald-400":"text-yellow-400"}`,children:L})]}),e.jsxs("button",{className:"flex items-center gap-2 h-10 px-4 bg-card-dark hover:bg-[#233648] border border-border-dark text-white text-sm font-bold rounded-lg transition-colors",children:[e.jsx(Cn,{className:"h-4 w-4"}),e.jsxs("span",{children:["Refresh: ",o,"s"]})]})]})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto custom-scrollbar p-6",children:e.jsxs("div",{className:"flex flex-col gap-6 max-w-[1600px] mx-auto pb-10",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2 rounded-xl p-5 border border-border-dark bg-card-dark",children:[e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsx("p",{className:"text-text-secondary text-sm font-medium",children:"CPU Load"}),e.jsx(e4,{className:"text-text-secondary w-5 h-5"})]}),e.jsxs("div",{className:"flex items-end gap-3 mt-1",children:[e.jsxs("p",{className:"text-white text-3xl font-bold",children:[h?.system?.cpu_usage_percent?.toFixed(0)||0,"%"]}),e.jsxs("span",{className:"text-emerald-500 text-sm font-medium mb-1 flex items-center",children:[e.jsx(t4,{className:"w-4 h-4 mr-1"}),"2%"]})]}),e.jsx("div",{className:"h-1.5 w-full bg-[#233648] rounded-full mt-3 overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary rounded-full transition-all",style:{width:`${h?.system?.cpu_usage_percent||0}%`}})})]}),e.jsxs("div",{className:"flex flex-col gap-2 rounded-xl p-5 border border-border-dark bg-card-dark",children:[e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsx("p",{className:"text-text-secondary text-sm font-medium",children:"RAM Usage"}),e.jsx(r4,{className:"text-text-secondary w-5 h-5"})]}),e.jsxs("div",{className:"flex items-end gap-3 mt-1",children:[e.jsx("p",{className:"text-white text-3xl font-bold",children:fr(h?.system?.memory_used_bytes||0,1)}),e.jsxs("span",{className:"text-text-secondary text-xs mb-2",children:["/ ",fr(h?.system?.memory_total_bytes||0,1)]})]}),e.jsx("div",{className:"h-1.5 w-full bg-[#233648] rounded-full mt-3 overflow-hidden",children:e.jsx("div",{className:"h-full bg-emerald-500 rounded-full transition-all",style:{width:`${h?.system?.memory_usage_percent||0}%`}})})]}),e.jsxs("div",{className:"flex flex-col gap-2 rounded-xl p-5 border border-border-dark bg-card-dark",children:[e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsx("p",{className:"text-text-secondary text-sm font-medium",children:"Storage Status"}),e.jsx(su,{className:"text-emerald-500 w-5 h-5"})]}),e.jsxs("div",{className:"flex items-end gap-3 mt-1",children:[e.jsx("p",{className:"text-white text-3xl font-bold",children:"Online"}),e.jsx("span",{className:"text-text-secondary text-sm font-medium mb-1",children:"No Errors"})]}),e.jsxs("div",{className:"flex gap-1 mt-3",children:[e.jsx("div",{className:"h-1.5 flex-1 bg-emerald-500 rounded-l-full"}),e.jsx("div",{className:"h-1.5 flex-1 bg-emerald-500"}),e.jsx("div",{className:"h-1.5 flex-1 bg-emerald-500"}),e.jsx("div",{className:"h-1.5 flex-1 bg-emerald-500 rounded-r-full"})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 rounded-xl p-5 border border-border-dark bg-card-dark",children:[e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsx("p",{className:"text-text-secondary text-sm font-medium",children:"System Uptime"}),e.jsx(Ec,{className:"text-text-secondary w-5 h-5"})]}),e.jsx("div",{className:"mt-1",children:e.jsxs("p",{className:"text-white text-3xl font-bold",children:[y,"d ",p,"h ",v,"m"]})}),e.jsx("p",{className:"text-text-secondary text-xs mt-3",children:"Last reboot: Manual Patching"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"xl:col-span-2 flex flex-col gap-6",children:[e.jsxs("div",{className:"bg-card-dark border border-border-dark rounded-xl p-6 shadow-sm",children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-white text-lg font-bold",children:"Network Throughput"}),e.jsx("p",{className:"text-text-secondary text-sm",children:"Inbound vs Outbound (eth0)"})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"text-white text-2xl font-bold leading-tight",children:[(_.total/1e3).toFixed(1)," Gbps"]}),e.jsxs("p",{className:"text-emerald-500 text-sm",children:["Peak: ",(w/1e3).toFixed(1)," Gbps"]})]})]}),e.jsx("div",{className:"h-[200px] w-full",children:e.jsx(Cl,{width:"100%",height:"100%",children:e.jsxs(ky,{data:s,margin:{top:5,right:10,left:0,bottom:0},children:[e.jsx(Nc,{strokeDasharray:"3 3",stroke:"#324d67",opacity:.3}),e.jsx(Bc,{dataKey:"time",stroke:"#92adc9",style:{fontSize:"11px"},tick:{fill:"#92adc9"}}),e.jsx(jc,{stroke:"#92adc9",style:{fontSize:"11px"},tick:{fill:"#92adc9"},label:{value:"Mbps",angle:-90,position:"insideLeft",fill:"#92adc9",style:{fontSize:"11px"}}}),e.jsx(Sl,{contentStyle:{backgroundColor:"#1a2632",border:"1px solid #324d67",borderRadius:"8px",color:"#fff"},labelStyle:{color:"#92adc9",fontSize:"12px"},itemStyle:{color:"#fff",fontSize:"12px"},formatter:M=>[`${M} Mbps`,""]}),e.jsx(Qh,{wrapperStyle:{fontSize:"12px",color:"#92adc9"},iconType:"line"}),e.jsx(Lh,{type:"monotone",dataKey:"inbound",stroke:"#137fec",strokeWidth:2,dot:!1,name:"Inbound",activeDot:{r:4}}),e.jsx(Lh,{type:"monotone",dataKey:"outbound",stroke:"#10b981",strokeWidth:2,dot:!1,name:"Outbound",activeDot:{r:4}})]})})})]}),e.jsxs("div",{className:"bg-card-dark border border-border-dark rounded-xl p-6 shadow-sm",children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-white text-lg font-bold",children:"Storage Capacity"}),e.jsx("p",{className:"text-text-secondary text-sm",children:"Repository usage"})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"text-white text-2xl font-bold leading-tight",children:[g.toFixed(1),"%"]}),e.jsx("p",{className:"text-text-secondary text-sm",children:"Target: <90%"})]})]}),e.jsx("div",{className:"h-[150px] w-full relative",children:e.jsx("div",{className:"w-full h-full bg-[#111a22] rounded flex items-center justify-center",children:e.jsx("div",{className:"w-full px-4",children:e.jsx("div",{className:"w-full bg-[#233648] h-2 rounded-full overflow-hidden",children:e.jsx("div",{className:"bg-primary h-full rounded-full transition-all",style:{width:`${g}%`}})})})})})]})]}),e.jsx("div",{className:"flex flex-col gap-6",children:e.jsxs("div",{className:"bg-card-dark border border-border-dark rounded-xl p-6 h-full shadow-sm flex flex-col",children:[e.jsxs("div",{className:"flex justify-between items-center mb-4",children:[e.jsx("h3",{className:"text-white text-lg font-bold",children:"Storage Overview"}),e.jsxs("span",{className:"bg-[#233648] text-white text-xs px-2 py-1 rounded border border-border-dark",children:[x?.length||0," Repos"]})]}),e.jsxs("div",{className:"mt-4 pt-4 border-t border-border-dark",children:[e.jsxs("div",{className:"flex justify-between text-sm text-text-secondary",children:[e.jsx("span",{children:"Total Capacity"}),e.jsx("span",{className:"text-white font-bold",children:fr(N)})]}),e.jsx("div",{className:"w-full bg-[#233648] h-2 rounded-full mt-2 overflow-hidden",children:e.jsx("div",{className:"bg-primary h-full transition-all",style:{width:`${g}%`}})}),e.jsxs("div",{className:"flex justify-between text-xs text-text-secondary mt-1",children:[e.jsxs("span",{children:["Used: ",fr(B)]}),e.jsxs("span",{children:["Free: ",fr(N-B)]})]})]})]})})]}),e.jsxs("div",{className:"bg-card-dark border border-border-dark rounded-xl shadow-sm overflow-hidden flex flex-col h-[400px]",children:[e.jsxs("div",{className:"flex border-b border-border-dark bg-[#161f29]",children:[e.jsxs("button",{onClick:()=>t("jobs"),className:`px-6 py-4 text-sm font-bold transition-colors ${r==="jobs"?"text-primary border-b-2 border-primary bg-card-dark":"text-text-secondary hover:text-white"}`,children:["Active Jobs"," ",tg.length>0&&e.jsx("span",{className:"ml-2 bg-primary/20 text-primary px-1.5 py-0.5 rounded text-xs",children:tg.length})]}),e.jsx("button",{onClick:()=>t("logs"),className:`px-6 py-4 text-sm font-medium transition-colors ${r==="logs"?"text-primary border-b-2 border-primary bg-card-dark":"text-text-secondary hover:text-white"}`,children:"System Logs"}),e.jsx("button",{onClick:()=>t("alerts"),className:`px-6 py-4 text-sm font-medium transition-colors ${r==="alerts"?"text-primary border-b-2 border-primary bg-card-dark":"text-text-secondary hover:text-white"}`,children:"Alerts History"}),e.jsx("div",{className:"flex-1 flex justify-end items-center px-4",children:e.jsxs("div",{className:"relative",children:[e.jsx(Wm,{className:"absolute left-2 top-1.5 text-text-secondary w-4 h-4"}),e.jsx("input",{className:"bg-[#111a22] border border-border-dark rounded-md py-1 pl-8 pr-3 text-sm text-white focus:outline-none focus:border-primary w-48 transition-all",placeholder:"Search logs...",type:"text"})]})})]}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[r==="jobs"&&e.jsx("div",{className:"p-0",children:e.jsxs("table",{className:"w-full text-left border-collapse",children:[e.jsx("thead",{className:"bg-[#1a2632] text-xs uppercase text-text-secondary font-medium sticky top-0 z-10",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-3 border-b border-border-dark",children:"Job Name"}),e.jsx("th",{className:"px-6 py-3 border-b border-border-dark",children:"Type"}),e.jsx("th",{className:"px-6 py-3 border-b border-border-dark w-1/3",children:"Progress"}),e.jsx("th",{className:"px-6 py-3 border-b border-border-dark",children:"Speed"}),e.jsx("th",{className:"px-6 py-3 border-b border-border-dark",children:"Status"})]})}),e.jsx("tbody",{className:"text-sm divide-y divide-border-dark",children:tg.map(M=>e.jsxs("tr",{className:"group hover:bg-[#233648] transition-colors",children:[e.jsx("td",{className:"px-6 py-4 font-medium text-white",children:M.name}),e.jsx("td",{className:"px-6 py-4 text-text-secondary",children:M.type}),e.jsxs("td",{className:"px-6 py-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-full bg-[#111a22] rounded-full h-2 overflow-hidden",children:e.jsx("div",{className:"bg-primary h-full rounded-full relative overflow-hidden",style:{width:`${M.progress}%`},children:e.jsx("div",{className:"absolute inset-0 bg-white/20 animate-pulse"})})}),e.jsxs("span",{className:"text-xs font-mono text-white",children:[M.progress,"%"]})]}),M.eta&&e.jsxs("p",{className:"text-[10px] text-text-secondary mt-1",children:["ETA: ",M.eta]})]}),e.jsx("td",{className:"px-6 py-4 text-text-secondary font-mono",children:M.speed}),e.jsx("td",{className:"px-6 py-4",children:e.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded text-xs font-medium bg-primary/20 text-primary",children:"Running"})})]},M.id))})]})}),r==="logs"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-6 py-2 bg-[#161f29] border-y border-border-dark flex items-center justify-between",children:[e.jsx("h4",{className:"text-xs uppercase text-text-secondary font-bold tracking-wider",children:"Recent System Events"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:()=>c(),disabled:d,className:"text-xs text-primary hover:text-white transition-colors flex items-center gap-1 disabled:opacity-50",children:[e.jsx(Cn,{size:14,className:d?"animate-spin":""}),"Refresh"]}),e.jsx("button",{className:"text-xs text-primary hover:text-white transition-colors",children:"View All Logs"})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto custom-scrollbar bg-[#111a22]",children:d?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx("span",{className:"text-text-secondary",children:"Loading logs..."})}):l.length===0?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx("span",{className:"text-text-secondary",children:"No logs available"})}):e.jsx("table",{className:"w-full text-left border-collapse",children:e.jsx("tbody",{className:"text-sm font-mono divide-y divide-border-dark/50",children:l.map((M,V)=>e.jsxs("tr",{className:"group hover:bg-[#233648] transition-colors",children:[e.jsx("td",{className:"px-6 py-2 text-text-secondary w-32 whitespace-nowrap",children:M.time}),e.jsx("td",{className:"px-6 py-2 w-24",children:e.jsx("span",{className:M.level==="INFO"||M.level==="NOTICE"||M.level==="DEBUG"?"text-emerald-500":M.level==="WARN"?"text-yellow-500":"text-red-500",children:M.level})}),e.jsx("td",{className:"px-6 py-2 w-32 text-white",children:M.source}),e.jsx("td",{className:"px-6 py-2 text-text-secondary truncate max-w-lg",children:M.message})]},V))})})})]}),r==="alerts"&&e.jsx("div",{className:"flex-1 overflow-y-auto custom-scrollbar bg-[#111a22] p-6",children:m?.alerts&&m.alerts.length>0?e.jsx("div",{className:"space-y-3",children:m.alerts.map(M=>e.jsx("div",{className:"bg-[#1a2632] border border-border-dark rounded-lg p-4 hover:bg-[#233648] transition-colors",children:e.jsx("div",{className:"flex items-start justify-between",children:e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Eh,{className:`w-4 h-4 ${M.severity==="critical"?"text-red-500":M.severity==="warning"?"text-yellow-500":"text-blue-500"}`}),e.jsx("h4",{className:"text-white font-medium",children:M.title}),e.jsx("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${M.severity==="critical"?"bg-red-500/20 text-red-400":M.severity==="warning"?"bg-yellow-500/20 text-yellow-400":"bg-blue-500/20 text-blue-400"}`,children:M.severity})]}),e.jsx("p",{className:"text-text-secondary text-sm",children:M.message}),e.jsx("p",{className:"text-text-secondary text-xs mt-2 font-mono",children:new Date(M.created_at).toLocaleString()})]})})},M.id))}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(su,{className:"w-12 h-12 text-emerald-500 mx-auto mb-4"}),e.jsx("p",{className:"text-text-secondary",children:"No alerts"})]})})]})]})]})})]})}function nS({poolId:r,onDeleteDataset:t,onCreateDataset:s}){const n=["storage","zfs","pools",r,"datasets"],{data:o=[],isLoading:l}=dt({queryKey:n,queryFn:()=>sn.listDatasets(r),refetchOnWindowFocus:!0,refetchOnMount:!0,staleTime:0,refetchInterval:1e3});return l?e.jsx("tr",{className:"bg-[#151d26]",children:e.jsx("td",{colSpan:7,className:"py-3 px-5 pl-10 text-white/60 text-xs",children:"Loading datasets..."})}):o.length===0?e.jsx("tr",{className:"bg-[#151d26]",children:e.jsx("td",{colSpan:7,className:"py-3 px-5 pl-10",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-white/60 text-xs",children:"No datasets found"}),e.jsxs("button",{onClick:d=>{d.stopPropagation(),s(r)},className:"px-3 py-1.5 bg-primary/20 hover:bg-primary/30 text-primary text-xs font-medium rounded-lg border border-primary/30 transition-colors flex items-center gap-1.5",title:"Create Dataset",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"add"}),"Create Dataset"]})]})})}):e.jsx(e.Fragment,{children:o.map(d=>{const c=d.quota>0?d.used_bytes/d.quota*100:d.available_bytes>0?d.used_bytes/(d.used_bytes+d.available_bytes)*100:0,u=d.name.includes("/")?d.name.split("/").slice(1).join("/"):d.name;return e.jsxs("tr",{className:"bg-[#151d26] hover:bg-[#1a242f] transition-colors",children:[e.jsx("td",{className:"py-3 px-5"}),e.jsx("td",{className:"py-3 px-5 pl-10",children:e.jsxs("div",{className:"flex items-center gap-3 relative before:content-[''] before:absolute before:-left-4 before:top-1/2 before:-translate-y-1/2 before:w-3 before:h-px before:bg-border-dark before:opacity-50",children:[e.jsx("span",{className:"material-symbols-outlined text-white/70 text-[18px]",children:d.type==="volume"?"storage":d.type==="snapshot"?"camera":"folder"}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium text-white",children:u}),d.mount_point&&d.mount_point!=="none"&&d.mount_point!=="-"&&e.jsx("span",{className:"text-xs text-white/50",children:d.mount_point}),d.type==="volume"&&e.jsx("span",{className:"text-xs text-primary/70",children:"Volume (Block Device)"})]})]})}),e.jsx("td",{className:"py-3 px-5",children:e.jsx("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-[10px] font-bold ${d.type==="volume"?"bg-blue-500/20 text-blue-400 border border-blue-500/30":d.mount_point&&d.mount_point!=="none"&&d.mount_point!=="-"?"bg-emerald-500/20 text-emerald-400 border border-emerald-500/30":"bg-gray-500/20 text-gray-400 border border-gray-500/30"}`,children:d.type==="volume"?"VOLUME":d.mount_point&&d.mount_point!=="none"&&d.mount_point!=="-"?"MOUNTED":"UNMOUNTED"})}),e.jsx("td",{className:"py-3 px-5",children:e.jsxs("div",{className:"flex flex-col gap-1 w-32",children:[e.jsxs("div",{className:"flex justify-between text-xs",children:[e.jsx("span",{className:"text-white font-medium",children:fr(d.used_bytes,1)}),e.jsx("span",{className:"text-white/80 font-medium",children:fr(d.available_bytes,1)})]}),e.jsx("div",{className:"w-full bg-[#233648] rounded-full h-1.5",children:e.jsx("div",{className:"h-1.5 rounded-full bg-primary",style:{width:`${Math.min(c,100)}%`}})})]})}),e.jsx("td",{className:"py-3 px-5 text-white/80 text-xs",children:d.quota>0?fr(d.quota,1):"Unlimited"}),e.jsx("td",{className:"py-3 px-5 text-white/80 text-xs",children:d.compression.toUpperCase()}),e.jsx("td",{className:"py-3 px-5 text-right",children:e.jsx("div",{className:"flex items-center gap-1 justify-end",children:e.jsx("button",{onClick:h=>{if(h.stopPropagation(),confirm(`Are you sure you want to delete dataset "${u}"? This action cannot be undone.`)){const m=d.name.includes("/")?d.name.split("/").slice(1).join("/"):d.name;t(r,m)}},className:"p-1 rounded-md hover:bg-red-500/20 text-red-400 hover:text-red-300 transition-colors",title:"Delete dataset",children:e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"delete"})})})})]},d.name)})})}function iS(){const[r,t]=Ce.useState(new Set),[s,n]=Ce.useState(null),[o,l]=Ce.useState(""),[d,c]=Ce.useState(!1),[u,h]=Ce.useState(!1),[m,x]=Ce.useState(!1),[y,p]=Ce.useState(null),[v,N]=Ce.useState([]),[B,g]=Ce.useState(!1),[j,_]=Ce.useState({name:"",type:"filesystem",compression:"lz4",quota:"",reservation:"",mount_point:""}),[w,L]=Ce.useState({name:"",description:"",raid_level:"stripe",disks:[],compression:"lz4",deduplication:!1,auto_expand:!1}),K=Nr(),{data:M=[],isLoading:V}=dt({queryKey:["storage","disks"],queryFn:Xd.listDisks}),{data:T=[],isLoading:ne}=dt({queryKey:["storage","repositories"],queryFn:Xd.listRepositories}),{data:Z=[],isLoading:U}=dt({queryKey:["storage","zfs","pools"],queryFn:sn.listPools,refetchInterval:3e3,staleTime:0,refetchOnWindowFocus:!0,refetchOnMount:!0}),{data:q}=dt({queryKey:["storage","zfs","arc","stats"],queryFn:sn.getARCStats,refetchInterval:2e3,staleTime:0}),F=ft({mutationFn:Xd.syncDisks,onSuccess:async()=>{await K.invalidateQueries({queryKey:["storage","disks"]}),K.refetchQueries({queryKey:["storage","disks"]}),alert("Disk rescan completed!")},onError:G=>{console.error("Failed to rescan disks:",G),alert(G.response?.data?.error||"Failed to rescan disks")}}),le=ft({mutationFn:sn.createPool,onSuccess:async()=>{await K.invalidateQueries({queryKey:["storage","zfs","pools"]}),await K.refetchQueries({queryKey:["storage","zfs","pools"]}),await K.invalidateQueries({queryKey:["storage","disks"]}),c(!1),L({name:"",description:"",raid_level:"stripe",disks:[],compression:"lz4",deduplication:!1,auto_expand:!1}),alert("Pool created successfully!")},onError:G=>{console.error("Failed to create pool:",G),alert(G.response?.data?.error||"Failed to create pool")}}),ae=ft({mutationFn:({poolId:G,disks:me})=>sn.addSpareDisk(G,me),onSuccess:()=>{K.invalidateQueries({queryKey:["storage","zfs","pools"]}),K.invalidateQueries({queryKey:["storage","disks"]}),h(!1),N([]),alert("Spare disks added successfully!")},onError:G=>{console.error("Failed to add spare disks:",G),alert(G.response?.data?.error||"Failed to add spare disks")}}),se=ft({mutationFn:G=>sn.deletePool(G),onSuccess:async()=>{await K.invalidateQueries({queryKey:["storage","zfs","pools"]}),await K.refetchQueries({queryKey:["storage","zfs","pools"]}),await K.invalidateQueries({queryKey:["storage","disks"]}),n(null),alert("Pool destroyed successfully!")},onError:G=>{console.error("Failed to delete pool:",G),alert(G.response?.data?.error||"Failed to destroy pool")}}),fe=ft({mutationFn:({poolId:G,data:me})=>sn.createDataset(G,me),onSuccess:async(G,me)=>{t(be=>new Set(be).add(me.poolId)),x(!1),p(null),_({name:"",type:"filesystem",compression:"lz4",quota:"",reservation:"",mount_point:""}),K.invalidateQueries({queryKey:["storage","zfs","pools",me.poolId,"datasets"],exact:!0}),alert("Dataset created successfully!")},onError:G=>{console.error("Failed to create dataset:",G),alert(G.response?.data?.error||"Failed to create dataset")}}),ye=ft({mutationFn:({poolId:G,datasetName:me})=>sn.deleteDataset(G,me),onSuccess:async(G,me)=>{t(be=>new Set(be).add(me.poolId)),await K.invalidateQueries({queryKey:["storage","zfs","pools",me.poolId,"datasets"],exact:!0}),alert("Dataset deleted successfully!")},onError:G=>{console.error("Failed to delete dataset:",G),alert(G.response?.data?.error||"Failed to delete dataset")}}),_e=(G,me)=>{ye.mutate({poolId:G,datasetName:me})},xe=G=>{const me=Z.find(be=>be.id===G);me&&(p(me),x(!0))},D=[...Z,...T],$=D.reduce((G,me)=>G+(me.size_bytes||0),0),X=D.reduce((G,me)=>G+(me.used_bytes||0),0),te=$>0?X/$*100:0,J=D.filter(G=>{if("health_status"in G){const me=G.health_status?.toLowerCase()||"";return G.is_active&&me==="online"}return G.is_active}).length,H=D.filter(G=>{if("health_status"in G){const me=G.health_status?.toLowerCase()||"";return!G.is_active||me!=="online"}return!G.is_active}).length===0?"Optimal":"Degraded",re=Z.filter(G=>G.is_active&&G.health_status?.toLowerCase()==="online"),Ae=re.length>0?re.reduce((G,me)=>{if(me.compress_ratio&&me.compress_ratio>0){const He=me.deduplication?1.3:1;return G+me.compress_ratio*He}const Ue={lz4:1.5,zstd:2.5,gzip:2,"gzip-1":1.8,"gzip-9":2.5,off:1}[me.compression?.toLowerCase()||"lz4"]||1.5,Re=me.deduplication?1.3:1;return G+Ue*Re},0)/re.length:1,oe=re.some(G=>G.compression&&G.compression.toLowerCase()!=="off"),ce=re.some(G=>G.deduplication),Se=re.find(G=>G.compression&&G.compression.toLowerCase()!=="off")?.compression?.toUpperCase()||"LZ4",z=q?.hit_ratio??0,ie=q?.cache_usage??0,W=q?.cache_size??0,Q=q?.cache_max??0,I=G=>{const me=new Set(r);me.has(G)?me.delete(G):me.add(G),t(me)},k=D.filter(G=>G.name.toLowerCase().includes(o.toLowerCase()));return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden bg-background-dark",children:[e.jsx("header",{className:"flex-shrink-0 px-8 py-6 border-b border-border-dark bg-card-dark/50 backdrop-blur-sm z-10",children:e.jsxs("div",{className:"max-w-[1400px] mx-auto w-full flex flex-col gap-4",children:[e.jsxs("nav",{className:"flex items-center text-sm font-medium text-text-secondary",children:[e.jsx(ba,{to:"/",className:"hover:text-primary transition-colors",children:"Home"}),e.jsx("span",{className:"mx-2",children:"/"}),e.jsx("span",{className:"text-white",children:"Storage Management"})]}),e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("h1",{className:"text-3xl font-extrabold text-white tracking-tight",children:"Storage Pools"}),e.jsx("p",{className:"text-text-secondary",children:"Manage ZFS pools, datasets, and physical disks topology."})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:()=>F.mutate(),disabled:F.isPending,className:"flex items-center gap-2 px-4 py-2 rounded-lg border border-border-dark bg-card-dark text-white text-sm font-bold hover:bg-[#233648] transition-colors disabled:opacity-50",children:[e.jsx("span",{className:`material-symbols-outlined text-[20px] ${F.isPending?"animate-spin":""}`,children:"refresh"}),F.isPending?"Rescanning...":"Rescan Disks"]}),e.jsxs("button",{onClick:async()=>{g(!0);try{await K.invalidateQueries({queryKey:["storage","zfs","pools"]}),await K.refetchQueries({queryKey:["storage","zfs","pools"]}),await new Promise(G=>setTimeout(G,300)),alert("Pools refreshed successfully!")}catch(G){console.error("Failed to refresh pools:",G),alert("Failed to refresh pools. Please try again.")}finally{g(!1)}},disabled:U||B,className:"flex items-center gap-2 px-4 py-2 rounded-lg border border-border-dark bg-card-dark text-white text-sm font-bold hover:bg-[#233648] transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:"Refresh pools list from database",children:[e.jsx("span",{className:`material-symbols-outlined text-[20px] ${U||B?"animate-spin":""}`,children:"sync"}),U||B?"Refreshing...":"Refresh Pools"]}),e.jsxs("button",{onClick:()=>c(!0),className:"relative flex items-center gap-2 px-4 py-2 rounded-lg border border-primary/30 bg-card-dark text-white text-sm font-bold hover:bg-[#233648] transition-all overflow-hidden electric-glow electric-glow-border",children:[e.jsx("span",{className:"absolute inset-0 bg-gradient-to-r from-primary/0 via-primary/15 to-primary/0 opacity-60"}),e.jsx("span",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/5 to-transparent animate-[shimmer_3s_infinite]"}),e.jsxs("span",{className:"relative flex items-center gap-2 z-10",children:[e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"add_circle"}),"Create Pool"]})]})]})]})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto p-8 custom-scrollbar",children:e.jsxs("div",{className:"max-w-[1400px] mx-auto w-full flex flex-col gap-8 pb-10",children:[e.jsxs("section",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"bg-card-dark p-5 rounded-xl border border-border-dark shadow-sm",children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsx("p",{className:"text-text-secondary text-sm font-semibold uppercase tracking-wider",children:"Total Capacity"}),e.jsx("span",{className:"material-symbols-outlined text-text-secondary",children:"database"})]}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("h3",{className:"text-2xl font-bold text-white",children:fr($,1)}),e.jsx("span",{className:"text-xs text-text-secondary",children:"Raw"})]}),e.jsx("div",{className:"mt-3 w-full bg-[#233648] rounded-full h-1.5 overflow-hidden",children:e.jsx("div",{className:"bg-primary h-1.5 rounded-full",style:{width:`${Math.min(te,100)}%`}})}),e.jsxs("p",{className:"mt-2 text-xs text-text-secondary",children:[te.toFixed(0),"% Used (",fr(X,1),")"]})]}),e.jsxs("div",{className:"bg-card-dark p-5 rounded-xl border border-border-dark shadow-sm",children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsx("p",{className:"text-white/70 text-sm font-semibold uppercase tracking-wider",children:"Health Status"}),e.jsx("span",{className:`material-symbols-outlined ${H==="Optimal"?"text-emerald-500":"text-orange-500"}`,children:H==="Optimal"?"check_circle":"warning"})]}),e.jsx("div",{className:"flex items-baseline gap-2",children:e.jsx("h3",{className:`text-2xl font-bold ${H==="Optimal"?"text-emerald-500":"text-orange-500"}`,children:H})}),e.jsxs("p",{className:"mt-2 text-xs text-white/80",children:[J," pool",J!==1?"s":""," online"]}),H==="Optimal"&&e.jsx("p",{className:"text-xs text-emerald-500 mt-1 font-medium",children:"Last scrub: N/A"})]}),e.jsxs("div",{className:"bg-card-dark p-5 rounded-xl border border-border-dark shadow-sm",children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsx("p",{className:"text-white/70 text-sm font-semibold uppercase tracking-wider",children:"Efficiency"}),e.jsx("span",{className:"material-symbols-outlined text-white/70",children:"compress"})]}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsxs("h3",{className:"text-2xl font-bold text-white",children:[Ae,"x"]}),e.jsx("span",{className:"text-xs text-white/70",children:"Ratio"})]}),e.jsxs("div",{className:"flex gap-2 mt-3",children:[oe&&e.jsx("span",{className:"px-2 py-0.5 rounded bg-blue-500/10 text-blue-500 text-[10px] font-bold",children:Se}),ce&&e.jsx("span",{className:"px-2 py-0.5 rounded bg-purple-500/10 text-purple-500 text-[10px] font-bold",children:"DEDUP ON"}),!oe&&!ce&&e.jsx("span",{className:"px-2 py-0.5 rounded bg-gray-500/10 text-gray-500 text-[10px] font-bold",children:"NO COMPRESSION"})]})]}),e.jsxs("div",{className:"bg-card-dark p-5 rounded-xl border border-border-dark shadow-sm",children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsx("p",{className:"text-white/70 text-sm font-semibold uppercase tracking-wider",children:"ARC Hit Ratio"}),e.jsx("span",{className:"material-symbols-outlined text-white/70",children:"memory"})]}),e.jsx("div",{className:"flex items-baseline gap-2",children:e.jsxs("h3",{className:"text-2xl font-bold text-white",children:[z.toFixed(1),"%"]})}),e.jsxs("p",{className:"mt-2 text-xs text-white/80",children:["Cache Usage: ",Q>0?`${fr(W,1)} / ${fr(Q,1)} (${ie.toFixed(1)}%)`:"N/A"]}),e.jsxs("div",{className:"mt-2 flex gap-1",children:[e.jsx("div",{className:"h-1 flex-1 bg-emerald-500 rounded-full"}),e.jsx("div",{className:"h-1 flex-1 bg-emerald-500 rounded-full"}),e.jsx("div",{className:"h-1 flex-1 bg-emerald-500 rounded-full"}),e.jsx("div",{className:"h-1 flex-1 bg-emerald-500/30 rounded-full"})]})]})]}),e.jsxs("section",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-xl font-bold text-white",children:"Active Pools"}),e.jsx("div",{className:"flex gap-2",children:e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"material-symbols-outlined absolute left-2.5 top-1/2 -translate-y-1/2 text-white/70 text-[20px]",children:"search"}),e.jsx("input",{className:"pl-10 pr-4 py-1.5 bg-[#233648] border border-border-dark rounded-lg text-sm text-white focus:ring-2 focus:ring-primary focus:border-transparent outline-none w-64 placeholder-white/50",placeholder:"Search datasets...",type:"text",value:o,onChange:G=>l(G.target.value)})]})})]}),e.jsxs("div",{className:"bg-card-dark rounded-xl border border-border-dark overflow-hidden shadow-sm",children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-[#1e2832] border-b border-border-dark",children:[e.jsx("th",{className:"py-3 px-5 text-xs font-semibold uppercase tracking-wider text-white/70 w-10"}),e.jsx("th",{className:"py-3 px-5 text-xs font-semibold uppercase tracking-wider text-white/70",children:"Name"}),e.jsx("th",{className:"py-3 px-5 text-xs font-semibold uppercase tracking-wider text-white/70",children:"Status"}),e.jsx("th",{className:"py-3 px-5 text-xs font-semibold uppercase tracking-wider text-white/70",children:"Used / Avail"}),e.jsx("th",{className:"py-3 px-5 text-xs font-semibold uppercase tracking-wider text-white/70",children:"Topology"}),e.jsx("th",{className:"py-3 px-5 text-xs font-semibold uppercase tracking-wider text-white/70",children:"Compression"}),e.jsx("th",{className:"py-3 px-5 text-xs font-semibold uppercase tracking-wider text-white/70 text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-border-dark text-sm",children:ne||U?e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"py-8 px-5 text-center text-white/80",children:"Loading pools..."})}):k.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"py-8 px-5 text-center text-white/80",children:"No pools found"})}):k.map(G=>{const me=r.has(G.id),be=G.size_bytes>0?G.used_bytes/G.size_bytes*100:0,Ue=G.size_bytes-G.used_bytes,Re="raid_level"in G,He=Re&&G.health_status?.toLowerCase()||"online",Ve=G.is_active&&(He==="online"||He===""),it=Ve?"bg-emerald-500/20 text-emerald-400 border-emerald-500/30":"bg-orange-500/20 text-orange-400 border-orange-500/30";return e.jsxs($B.Fragment,{children:[e.jsxs("tr",{className:"group hover:bg-white/5 transition-colors cursor-pointer",onClick:()=>I(G.id),children:[e.jsx("td",{className:"py-4 px-5",children:e.jsx("span",{className:`material-symbols-outlined text-[20px] text-white transition-transform ${me?"rotate-90":""}`,children:"arrow_right"})}),e.jsx("td",{className:"py-4 px-5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:`material-symbols-outlined ${Ve?"text-primary":"text-orange-500"}`,children:Ve?"dns":"warning"}),e.jsxs("div",{children:[e.jsx("span",{className:"font-bold text-white block",children:G.name}),e.jsx("span",{className:"text-xs text-white/70",children:Re?`ZFS ${G.raid_level.toUpperCase()}`:G.mount_point||"Not mounted"})]})]})}),e.jsx("td",{className:"py-4 px-5",children:e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-bold border ${it}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${Ve?"bg-emerald-500":"bg-orange-500 animate-pulse"}`}),Re?He.toUpperCase():Ve?"ONLINE":"DEGRADED"]})}),e.jsx("td",{className:"py-4 px-5",children:e.jsxs("div",{className:"flex flex-col gap-1 w-32",children:[e.jsxs("div",{className:"flex justify-between text-xs",children:[e.jsx("span",{className:"text-white font-medium",children:fr(G.used_bytes,1)}),e.jsx("span",{className:"text-white/80 font-medium",children:fr(Ue,1)})]}),e.jsx("div",{className:"w-full bg-[#233648] rounded-full h-1.5",children:e.jsx("div",{className:`h-1.5 rounded-full ${Ve?"bg-primary":"bg-orange-500"}`,style:{width:`${Math.min(be,100)}%`}})})]})}),e.jsx("td",{className:"py-4 px-5 text-white",children:Re?`${G.raid_level.toUpperCase()} (${G.disks.length} disks)`:G.volume_group||"N/A"}),e.jsx("td",{className:"py-4 px-5 text-white",children:Re?G.compression.toUpperCase():G.filesystem_type||"LZ4"}),e.jsx("td",{className:"py-4 px-5 text-right",children:e.jsxs("div",{className:"flex items-center gap-1 justify-end",children:[Re&&e.jsx("button",{className:"p-1.5 rounded-md hover:bg-primary/20 text-primary hover:text-primary transition-colors",onClick:lt=>{lt.stopPropagation(),p(G),x(!0)},title:"Create Dataset",children:e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"add"})}),e.jsx("button",{className:"p-1.5 rounded-md hover:bg-[#233648] text-white transition-colors",onClick:lt=>{lt.stopPropagation(),n(G)},children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"more_vert"})})]})})]}),me&&Re&&e.jsx(nS,{poolId:G.id,onDeleteDataset:_e,onCreateDataset:xe})]},G.id)})})]})}),e.jsxs("div",{className:"bg-[#1e2832] px-5 py-3 border-t border-border-dark flex justify-between items-center text-xs text-white/80",children:[e.jsxs("span",{children:["Showing ",k.length," active pool",k.length!==1?"s":""]}),e.jsx("button",{className:"hover:text-primary font-medium text-white/80",children:"View Archived Pools"})]})]})]}),e.jsxs("section",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-xl font-bold text-white",children:"Physical Disks"}),e.jsx("button",{className:"text-primary text-sm font-bold hover:underline",children:"View All Disks"})]}),V?e.jsx("div",{className:"text-center py-8 text-white/80",children:"Loading disks..."}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 xl:grid-cols-6 gap-4",children:M.map(G=>{const me=G.health_status==="healthy"||G.health_status==="online",be=G.health_status==="faulted"||G.health_status==="error",Ue=G.is_used?66:0;return e.jsxs("div",{className:`bg-card-dark rounded-lg p-4 border ${be?"border-red-500/30 bg-red-900/10 hover:border-red-500":"border-border-dark hover:border-primary/50"} flex flex-col gap-3 transition-colors group cursor-pointer relative overflow-hidden`,children:[e.jsx("div",{className:"absolute top-0 right-0 p-2",children:e.jsx("div",{className:`w-2 h-2 rounded-full ${be?"bg-red-500 animate-pulse":me?"bg-emerald-500":"bg-blue-500"}`})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`w-10 h-10 rounded ${be?"bg-red-100 dark:bg-red-900/20":"bg-[#233648]"} flex items-center justify-center`,children:e.jsx("span",{className:`material-symbols-outlined ${be?"text-red-500 group-hover:text-red-400":"text-white/70 group-hover:text-primary"} transition-colors`,children:be?"error":"hard_drive"})}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-sm font-bold text-white",children:G.device_path}),e.jsx("span",{className:`text-xs ${be?"text-red-500 font-bold":"text-white"}`,children:be?"FAULTED":`Slot ${G.id.slice(-1)}`})]})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("div",{className:"flex justify-between text-xs text-text-secondary",children:[e.jsxs("span",{children:[G.vendor||"Unknown"," ",G.model||""]}),e.jsx("span",{children:fr(G.size_bytes,1)})]}),G.attached_to_pool&&e.jsxs("div",{className:"text-xs text-primary font-medium",children:["Attached to pool: ",G.attached_to_pool]}),e.jsxs("div",{className:"flex gap-0.5 h-1.5 w-full rounded-full overflow-hidden bg-[#233648]",children:[e.jsx("div",{className:`${be?"bg-red-500 opacity-50":"bg-primary"}`,style:{width:`${Ue}%`}}),e.jsx("div",{className:"bg-transparent flex-1"})]}),e.jsxs("div",{className:"flex flex-col gap-0.5 mt-1",children:[e.jsx("span",{className:`text-[10px] font-medium ${be?"text-red-400":"text-emerald-400"}`,children:be?"FAULTED":"Healthy"}),e.jsx("span",{className:`text-[10px] ${G.is_used||G.attached_to_pool?"text-primary":"text-white/60"}`,children:G.is_used||G.attached_to_pool?"Provisioned":"Unprovisioned"})]})]})]},G.id)})})]})]})}),s&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-30",onClick:()=>n(null)}),e.jsxs("div",{className:"fixed inset-y-0 right-0 w-96 bg-card-dark border-l border-border-dark shadow-2xl z-40 flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-border-dark bg-[#1e2832]",children:[e.jsxs("h3",{className:"text-lg font-bold text-white",children:[s.name," Properties"]}),e.jsx("button",{onClick:()=>n(null),className:"text-white/80 hover:text-white transition-colors p-2 hover:bg-[#233648] rounded-lg",children:e.jsx("span",{className:"material-symbols-outlined text-[24px]",children:"close"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-6 flex flex-col gap-6 custom-scrollbar",children:[e.jsxs("div",{className:"p-4 rounded-lg bg-primary/10 border border-primary/20",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("span",{className:"material-symbols-outlined text-primary text-[20px]",children:"info"}),e.jsx("span",{className:"text-sm font-bold text-primary",children:s.is_active&&s.health_status?.toLowerCase()==="online"?"Healthy":"Degraded"})]}),e.jsx("p",{className:"text-xs text-white/90 leading-relaxed mb-3",children:s.is_active&&s.health_status?.toLowerCase()==="online"?"This pool is operating normally.":"This pool has issues and requires attention."}),e.jsxs("div",{className:"mt-3 space-y-1.5 text-xs",children:[e.jsxs("p",{className:"text-white/80",children:["RAID Level: ",e.jsx("span",{className:"font-bold text-white ml-1",children:s.raid_level.toUpperCase()})]}),e.jsxs("p",{className:"text-white/80",children:["Data Disks: ",e.jsx("span",{className:"font-bold text-white ml-1",children:s.disks.length}),e.jsxs("span",{className:"text-white/60 ml-1",children:["(",s.disks.join(", "),")"]})]}),s.spare_disks&&s.spare_disks.length>0&&e.jsxs("p",{className:"text-white/80",children:["Spare Disks: ",e.jsx("span",{className:"font-bold text-white ml-1",children:s.spare_disks.length}),e.jsxs("span",{className:"text-white/60 ml-1",children:["(",s.spare_disks.join(", "),")"]})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-semibold text-white",children:"Compression Level"}),e.jsxs("select",{defaultValue:s.compression,className:"w-full bg-[#233648] border border-border-dark rounded-lg px-3 py-2.5 text-sm text-white placeholder-white/50 focus:ring-2 focus:ring-primary focus:border-transparent outline-none",children:[e.jsx("option",{value:"off",children:"Off"}),e.jsx("option",{value:"lz4",children:"LZ4 (Recommended)"}),e.jsx("option",{value:"zstd",children:"ZSTD"}),e.jsx("option",{value:"gzip",children:"GZIP"})]}),e.jsx("p",{className:"text-xs text-white/70 leading-relaxed",children:"Balances performance and storage efficiency."})]}),e.jsxs("div",{className:"flex flex-col gap-2 border-t border-border-dark pt-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{className:"text-sm font-semibold text-white",children:"Deduplication"}),e.jsx("button",{className:`w-11 h-6 rounded-full relative transition-colors focus:outline-none focus:ring-2 focus:ring-primary ${s.deduplication?"bg-primary":"bg-[#233648]"}`,children:e.jsx("span",{className:`absolute left-1 top-1 bg-white w-4 h-4 rounded-full transition-transform ${s.deduplication?"transform translate-x-5":"transform translate-x-0"}`})})]}),e.jsx("p",{className:"text-xs text-white/70 leading-relaxed",children:"Requires significant RAM. Use with caution."})]}),e.jsxs("div",{className:"flex flex-col gap-2 border-t border-border-dark pt-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{className:"text-sm font-semibold text-white",children:"Auto-Expand"}),e.jsx("button",{className:`w-11 h-6 rounded-full relative transition-colors focus:outline-none focus:ring-2 focus:ring-primary ${s.auto_expand?"bg-primary":"bg-[#233648]"}`,children:e.jsx("span",{className:`absolute left-1 top-1 bg-white w-4 h-4 rounded-full transition-transform ${s.auto_expand?"transform translate-x-5":"transform translate-x-0"}`})})]}),e.jsx("p",{className:"text-xs text-white/70 leading-relaxed",children:"Automatically grow pool when larger disks are added."})]}),e.jsxs("div",{className:"flex flex-col gap-2 border-t border-border-dark pt-4",children:[e.jsx("label",{className:"text-sm font-semibold text-white",children:"Scrub Interval"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{className:"w-20 bg-[#233648] border border-border-dark rounded-lg px-3 py-2 text-sm text-white placeholder-white/50 focus:ring-2 focus:ring-primary focus:border-transparent outline-none",type:"number",defaultValue:s.scrub_interval}),e.jsx("span",{className:"text-sm text-white/80 font-medium",children:"days"})]}),e.jsx("p",{className:"text-xs text-white/70 leading-relaxed",children:"Data integrity check interval."})]}),e.jsxs("div",{className:"flex flex-col gap-2 border-t border-border-dark pt-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("label",{className:"text-sm font-semibold text-white",children:"Spare Disks"}),e.jsxs("button",{onClick:()=>{h(!0),N([])},className:"px-3 py-1.5 text-xs font-bold text-primary border border-primary/30 rounded-lg hover:bg-primary/10 transition-colors flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"add"}),"Add Spare"]})]}),e.jsx("p",{className:"text-xs text-white/70 leading-relaxed",children:"Spare disks are automatically used to replace failed disks in the pool."}),s.spare_disks&&s.spare_disks.length>0&&e.jsx("div",{className:"mt-2 space-y-1",children:s.spare_disks.map(G=>e.jsxs("div",{className:"flex items-center gap-2 text-xs text-white/80 bg-[#233648] px-2 py-1 rounded",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px] text-primary",children:"hard_drive"}),e.jsx("span",{children:G})]},G))})]})]})]}),e.jsxs("div",{className:"p-6 border-t border-border-dark bg-[#1e2832] flex gap-3",children:[e.jsxs("button",{className:"relative flex-1 px-4 py-2 rounded-lg border border-primary/30 bg-card-dark text-white text-sm font-bold hover:bg-[#233648] transition-all overflow-hidden electric-glow electric-glow-border",children:[e.jsx("span",{className:"absolute inset-0 bg-gradient-to-r from-primary/0 via-primary/15 to-primary/0 opacity-60"}),e.jsx("span",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/5 to-transparent animate-[shimmer_3s_infinite]"}),e.jsxs("span",{className:"relative flex items-center justify-center gap-2 z-10",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"save"}),"Save Changes"]})]}),e.jsx("button",{onClick:()=>n(null),className:"px-4 py-2 bg-card-dark border border-border-dark text-white text-sm font-bold rounded-lg hover:bg-[#233648] transition-colors",children:"Cancel"})]}),e.jsx("div",{className:"p-6 pt-0 bg-[#1e2832]",children:e.jsxs("button",{onClick:()=>{s&&confirm(`Are you sure you want to destroy pool "${s.name}"? This action cannot be undone and will delete all data in the pool.`)&&se.mutate(s.id)},disabled:se.isPending||!s,className:"w-full px-4 py-2 border border-red-500/30 text-red-500 hover:bg-red-500/10 text-sm font-bold rounded-lg transition-colors flex items-center justify-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:se.isPending?"hourglass_empty":"delete"}),se.isPending?"Destroying...":"Export / Destroy Pool"]})})]})]}),d&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",children:e.jsxs("div",{className:"bg-card-dark border border-border-dark rounded-xl shadow-2xl w-full max-w-2xl mx-4 max-h-[90vh] overflow-y-auto custom-scrollbar",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-border-dark bg-[#1e2832]",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-white",children:"Create ZFS Pool"}),e.jsx("p",{className:"text-sm text-text-secondary mt-1",children:"Create a new ZFS pool from available physical disks"})]}),e.jsx("button",{onClick:()=>c(!1),className:"text-white/70 hover:text-white transition-colors p-2 hover:bg-[#233648] rounded-lg",children:e.jsx("span",{className:"material-symbols-outlined text-[24px]",children:"close"})})]}),e.jsxs("form",{onSubmit:G=>{if(G.preventDefault(),!w.name||w.disks.length===0){alert("Please fill in all required fields and select at least one disk");return}const me={stripe:1,mirror:2,raidz:3,raidz2:4,raidz3:5};if(w.disks.lengthL({...w,name:G.target.value}),className:"w-full bg-[#233648] border border-border-dark rounded-lg px-4 py-2.5 text-sm text-white placeholder-white/50 focus:ring-2 focus:ring-primary focus:border-transparent outline-none",placeholder:"e.g., backup-pool-01"}),e.jsx("p",{className:"text-xs text-white/70",children:"Unique name for the ZFS pool"})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-medium text-white",children:"Description"}),e.jsx("textarea",{value:w.description,onChange:G=>L({...w,description:G.target.value}),rows:2,className:"w-full bg-[#233648] border border-border-dark rounded-lg px-4 py-2.5 text-sm text-white placeholder-white/50 focus:ring-2 focus:ring-primary focus:border-transparent outline-none resize-none",placeholder:"Optional description for this pool"})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("label",{className:"text-sm font-medium text-white",children:["RAID Level ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("select",{required:!0,value:w.raid_level,onChange:G=>L({...w,raid_level:G.target.value,disks:[]}),className:"w-full bg-[#233648] border border-border-dark rounded-lg px-4 py-2.5 text-sm text-white focus:ring-2 focus:ring-primary focus:border-transparent outline-none",children:[e.jsx("option",{value:"stripe",children:"Stripe (No redundancy, 1+ disks)"}),e.jsx("option",{value:"mirror",children:"Mirror (2+ disks, even number)"}),e.jsx("option",{value:"raidz",children:"RAIDZ (3+ disks, single parity)"}),e.jsx("option",{value:"raidz2",children:"RAIDZ2 (4+ disks, double parity)"}),e.jsx("option",{value:"raidz3",children:"RAIDZ3 (5+ disks, triple parity)"})]}),e.jsxs("p",{className:"text-xs text-white/70",children:[w.raid_level==="stripe"&&"No redundancy, maximum capacity",w.raid_level==="mirror"&&"50% capacity, full redundancy",w.raid_level==="raidz"&&"Single parity, good balance",w.raid_level==="raidz2"&&"Double parity, high reliability",w.raid_level==="raidz3"&&"Triple parity, maximum reliability"]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("label",{className:"text-sm font-medium text-white",children:["Select Disks ",e.jsx("span",{className:"text-red-500",children:"*"})]}),V?e.jsx("div",{className:"text-sm text-white/70",children:"Loading disks..."}):e.jsx("div",{className:"max-h-48 overflow-y-auto custom-scrollbar border border-border-dark rounded-lg bg-[#233648] p-3 space-y-2",children:M.filter(G=>!G.is_used).length===0?e.jsx("div",{className:"text-sm text-orange-400 bg-orange-500/10 border border-orange-500/30 rounded-lg p-3",children:"No available disks. All disks are in use."}):M.filter(G=>!G.is_used).map(G=>e.jsxs("label",{className:"flex items-center gap-3 p-2 rounded-lg hover:bg-[#1e2832] cursor-pointer transition-colors",children:[e.jsx("input",{type:"checkbox",checked:w.disks.includes(G.device_path),onChange:me=>{me.target.checked?L({...w,disks:[...w.disks,G.device_path]}):L({...w,disks:w.disks.filter(be=>be!==G.device_path)})},className:"w-4 h-4 text-primary bg-[#233648] border-border-dark rounded focus:ring-primary"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:G.device_path}),e.jsxs("div",{className:"text-xs text-white/70",children:[G.vendor||"Unknown"," ",G.model||""," • ",fr(G.size_bytes,1)]})]})]},G.id))}),e.jsxs("p",{className:"text-xs text-white/70",children:["Selected: ",w.disks.length," disk(s). Minimum: ",w.raid_level==="stripe"?1:w.raid_level==="mirror"?2:w.raid_level==="raidz"?3:w.raid_level==="raidz2"?4:5]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-medium text-white",children:"Compression"}),e.jsxs("select",{value:w.compression,onChange:G=>L({...w,compression:G.target.value}),className:"w-full bg-[#233648] border border-border-dark rounded-lg px-4 py-2.5 text-sm text-white focus:ring-2 focus:ring-primary focus:border-transparent outline-none",children:[e.jsx("option",{value:"off",children:"Off"}),e.jsx("option",{value:"lz4",children:"LZ4 (Recommended)"}),e.jsx("option",{value:"zstd",children:"ZSTD"}),e.jsx("option",{value:"gzip",children:"GZIP"})]}),e.jsx("p",{className:"text-xs text-white/70",children:"LZ4 provides good compression with minimal CPU overhead"})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{className:"text-sm font-medium text-white",children:"Deduplication"}),e.jsx("button",{type:"button",onClick:()=>L({...w,deduplication:!w.deduplication}),className:`w-11 h-6 rounded-full relative transition-colors focus:outline-none focus:ring-2 focus:ring-primary ${w.deduplication?"bg-primary":"bg-[#233648]"}`,children:e.jsx("span",{className:`absolute left-1 top-1 bg-white w-4 h-4 rounded-full transition-transform ${w.deduplication?"transform translate-x-5":"transform translate-x-0"}`})})]}),e.jsx("p",{className:"text-xs text-white/70",children:"Requires significant RAM. Use with caution."})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{className:"text-sm font-medium text-white",children:"Auto-Expand"}),e.jsx("button",{type:"button",onClick:()=>L({...w,auto_expand:!w.auto_expand}),className:`w-11 h-6 rounded-full relative transition-colors focus:outline-none focus:ring-2 focus:ring-primary ${w.auto_expand?"bg-primary":"bg-[#233648]"}`,children:e.jsx("span",{className:`absolute left-1 top-1 bg-white w-4 h-4 rounded-full transition-transform ${w.auto_expand?"transform translate-x-5":"transform translate-x-0"}`})})]}),e.jsx("p",{className:"text-xs text-white/70",children:"Automatically grow pool when larger disks are added"})]}),e.jsxs("div",{className:"flex items-center justify-end gap-3 pt-4 border-t border-border-dark",children:[e.jsx("button",{type:"button",onClick:()=>c(!1),className:"flex items-center gap-2 px-4 py-2 rounded-lg border border-border-dark bg-card-dark text-white text-sm font-bold hover:bg-[#233648] transition-colors",children:"Cancel"}),e.jsxs("button",{type:"submit",disabled:le.isPending||M.filter(G=>!G.is_used).length===0||w.disks.length===0,className:"relative flex items-center gap-2 px-4 py-2 rounded-lg border border-primary/30 bg-card-dark text-white text-sm font-bold hover:bg-[#233648] transition-all overflow-hidden electric-glow electric-glow-border disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx("span",{className:"absolute inset-0 bg-gradient-to-r from-primary/0 via-primary/15 to-primary/0 opacity-60"}),e.jsx("span",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/5 to-transparent animate-[shimmer_3s_infinite]"}),e.jsx("span",{className:"relative flex items-center gap-2 z-10",children:le.isPending?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"material-symbols-outlined text-[20px] animate-spin",children:"refresh"}),"Creating..."]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"add_circle"}),"Create ZFS Pool"]})})]})]})]})]})}),m&&y&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",children:e.jsxs("div",{className:"bg-card-dark border border-border-dark rounded-xl shadow-2xl w-full max-w-2xl mx-4 max-h-[90vh] overflow-y-auto custom-scrollbar",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-border-dark bg-[#1e2832]",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-white",children:"Create Dataset"}),e.jsxs("p",{className:"text-sm text-text-secondary mt-1",children:["Create a new dataset in pool: ",y.name]})]}),e.jsx("button",{onClick:()=>{x(!1),p(null),_({name:"",type:"filesystem",compression:"lz4",quota:"",reservation:"",mount_point:""})},className:"text-white/70 hover:text-white transition-colors p-2 hover:bg-[#233648] rounded-lg",children:e.jsx("span",{className:"material-symbols-outlined text-[24px]",children:"close"})})]}),e.jsxs("form",{onSubmit:G=>{if(G.preventDefault(),!j.name){alert("Please enter a dataset name");return}if(j.type==="volume"&&(!j.quota||parseFloat(j.quota)<=0)){alert("Volume size (quota) is required and must be greater than 0");return}fe.mutate({poolId:y.id,data:{name:j.name,type:j.type,compression:j.compression||"lz4",quota:j.quota?parseInt(j.quota)*1024*1024*1024:-1,reservation:j.reservation?parseInt(j.reservation)*1024*1024*1024:0,mount_point:j.mount_point||void 0}})},className:"p-6 space-y-6",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("label",{className:"text-sm font-medium text-white",children:["Dataset Name ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",required:!0,value:j.name,onChange:G=>_({...j,name:G.target.value}),className:"w-full bg-[#233648] border border-border-dark rounded-lg px-4 py-2.5 text-sm text-white placeholder-white/50 focus:ring-2 focus:ring-primary focus:border-transparent outline-none",placeholder:"e.g., backup-data"}),e.jsxs("p",{className:"text-xs text-white/70",children:["Dataset will be created as: ",y.name,"/",j.name||"dataset-name"]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("label",{className:"text-sm font-medium text-white",children:["Type ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("select",{required:!0,value:j.type,onChange:G=>_({...j,type:G.target.value}),className:"w-full bg-[#233648] border border-border-dark rounded-lg px-4 py-2.5 text-sm text-white focus:ring-2 focus:ring-primary focus:border-transparent outline-none",children:[e.jsx("option",{value:"filesystem",children:"Filesystem"}),e.jsx("option",{value:"volume",children:"Volume (Block Device)"})]}),e.jsx("p",{className:"text-xs text-white/70",children:j.type==="filesystem"?"A filesystem dataset that can be mounted and used like a directory":"A volume that appears as a block device (like /dev/zvol/...)"})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-medium text-white",children:"Compression"}),e.jsxs("select",{value:j.compression,onChange:G=>_({...j,compression:G.target.value}),className:"w-full bg-[#233648] border border-border-dark rounded-lg px-4 py-2.5 text-sm text-white focus:ring-2 focus:ring-primary focus:border-transparent outline-none",children:[e.jsx("option",{value:"off",children:"Off"}),e.jsx("option",{value:"lz4",children:"LZ4 (Recommended)"}),e.jsx("option",{value:"zstd",children:"ZSTD"}),e.jsx("option",{value:"gzip",children:"GZIP"})]}),e.jsx("p",{className:"text-xs text-white/70",children:"LZ4 provides good compression with minimal CPU overhead"})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("label",{className:"text-sm font-medium text-white",children:[j.type==="volume"?"Volume Size (GB)":"Quota (GB)"," ",j.type==="volume"&&e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"number",required:j.type==="volume",value:j.quota,onChange:G=>_({...j,quota:G.target.value}),className:"w-full bg-[#233648] border border-border-dark rounded-lg px-4 py-2.5 text-sm text-white placeholder-white/50 focus:ring-2 focus:ring-primary focus:border-transparent outline-none",placeholder:j.type==="volume"?"e.g., 100":"Leave empty for unlimited",min:"1"}),e.jsx("p",{className:"text-xs text-white/70",children:j.type==="volume"?"Size of the volume in GB (required for volumes)":"Maximum space this filesystem can use. Leave empty for unlimited."})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-medium text-white",children:"Reservation (GB)"}),e.jsx("input",{type:"number",value:j.reservation,onChange:G=>_({...j,reservation:G.target.value}),className:"w-full bg-[#233648] border border-border-dark rounded-lg px-4 py-2.5 text-sm text-white placeholder-white/50 focus:ring-2 focus:ring-primary focus:border-transparent outline-none",placeholder:"Leave empty for none",min:"0"}),e.jsx("p",{className:"text-xs text-white/70",children:"Guaranteed space reserved for this dataset"})]}),j.type==="filesystem"&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-medium text-white",children:"Mount Point"}),e.jsx("input",{type:"text",value:j.mount_point,onChange:G=>_({...j,mount_point:G.target.value}),className:"w-full bg-[#233648] border border-border-dark rounded-lg px-4 py-2.5 text-sm text-white placeholder-white/50 focus:ring-2 focus:ring-primary focus:border-transparent outline-none",placeholder:"e.g., /mnt/backup-data (optional)"}),e.jsx("p",{className:"text-xs text-white/70",children:"Optional mount point. Leave empty for default location."})]}),e.jsxs("div",{className:"flex items-center justify-end gap-3 pt-4 border-t border-border-dark",children:[e.jsx("button",{type:"button",onClick:()=>{x(!1),p(null),_({name:"",type:"filesystem",compression:"lz4",quota:"",reservation:"",mount_point:""})},className:"flex items-center gap-2 px-4 py-2 rounded-lg border border-border-dark bg-card-dark text-white text-sm font-bold hover:bg-[#233648] transition-colors",children:"Cancel"}),e.jsxs("button",{type:"submit",disabled:fe.isPending,className:"relative flex items-center gap-2 px-4 py-2 rounded-lg border border-primary/30 bg-card-dark text-white text-sm font-bold hover:bg-[#233648] transition-all overflow-hidden electric-glow electric-glow-border disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx("span",{className:"absolute inset-0 bg-gradient-to-r from-primary/0 via-primary/15 to-primary/0 opacity-60"}),e.jsx("span",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/5 to-transparent animate-[shimmer_3s_infinite]"}),e.jsx("span",{className:"relative flex items-center gap-2 z-10",children:fe.isPending?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"material-symbols-outlined text-[18px] animate-spin",children:"refresh"}),"Creating..."]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"add_circle"}),"Create Dataset"]})})]})]})]})]})}),u&&s&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",children:e.jsxs("div",{className:"bg-card-dark border border-border-dark rounded-xl shadow-2xl w-full max-w-2xl mx-4 max-h-[90vh] overflow-y-auto custom-scrollbar",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-border-dark bg-[#1e2832]",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-white",children:"Add Spare Disks"}),e.jsxs("p",{className:"text-sm text-text-secondary mt-1",children:["Add spare disks to pool: ",s.name]})]}),e.jsx("button",{onClick:()=>{h(!1),N([])},className:"text-white/70 hover:text-white transition-colors p-2 hover:bg-[#233648] rounded-lg",children:e.jsx("span",{className:"material-symbols-outlined text-[24px]",children:"close"})})]}),e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"p-4 rounded-lg bg-primary/10 border border-primary/20",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("span",{className:"material-symbols-outlined text-primary text-[20px]",children:"info"}),e.jsx("span",{className:"text-sm font-bold text-primary",children:"About Spare Disks"})]}),e.jsx("p",{className:"text-xs text-white/90 leading-relaxed",children:"Spare disks are automatically used to replace failed disks in the pool. They provide redundancy and help maintain pool health without manual intervention."})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("label",{className:"text-sm font-semibold text-white",children:["Select Spare Disks ",e.jsx("span",{className:"text-red-500",children:"*"})]}),V?e.jsx("div",{className:"text-sm text-white/70",children:"Loading disks..."}):M.filter(G=>!G.is_used).length===0?e.jsx("div",{className:"text-sm text-orange-400 bg-orange-500/10 border border-orange-500/30 rounded-lg p-3",children:"No available disks found. Please ensure disks are connected and rescanned."}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 max-h-64 overflow-y-auto custom-scrollbar",children:M.filter(G=>!G.is_used).map(G=>e.jsxs("div",{className:`flex items-center justify-between p-3 rounded-lg border cursor-pointer transition-colors ${v.includes(G.device_path)?"bg-primary/20 border-primary text-white":"bg-[#233648] border-border-dark text-white/80 hover:bg-[#2a3e50]"}`,onClick:()=>{N(me=>me.includes(G.device_path)?me.filter(be=>be!==G.device_path):[...me,G.device_path])},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:v.includes(G.device_path),onChange:()=>{N(me=>me.includes(G.device_path)?me.filter(be=>be!==G.device_path):[...me,G.device_path])},className:"form-checkbox h-4 w-4 text-primary rounded border-gray-300 focus:ring-primary bg-transparent"}),e.jsx("span",{className:"text-sm font-medium",children:G.device_path})]}),e.jsx("span",{className:"text-xs text-white/70",children:fr(G.size_bytes,1)})]},G.id))}),e.jsxs("p",{className:"text-xs text-white/70",children:["Selected: ",v.length," disk(s)"]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-3 pt-4 border-t border-border-dark",children:[e.jsx("button",{type:"button",onClick:()=>{h(!1),N([])},className:"px-4 py-2 rounded-lg border border-border-dark bg-card-dark text-white text-sm font-bold hover:bg-[#233648] transition-colors",children:"Cancel"}),e.jsxs("button",{onClick:()=>{if(v.length===0){alert("Please select at least one disk");return}ae.mutate({poolId:s.id,disks:v})},disabled:ae.isPending||v.length===0,className:"relative flex items-center gap-2 px-4 py-2 rounded-lg border border-primary/30 bg-card-dark text-white text-sm font-bold hover:bg-[#233648] transition-all overflow-hidden electric-glow electric-glow-border disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx("span",{className:"absolute inset-0 bg-gradient-to-r from-primary/0 via-primary/15 to-primary/0 opacity-60"}),e.jsx("span",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/5 to-transparent animate-[shimmer_3s_infinite]"}),e.jsxs("span",{className:"relative flex items-center gap-2 z-10",children:[ae.isPending?e.jsx("span",{className:"material-symbols-outlined text-[18px] animate-spin",children:"refresh"}):e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"add_circle"}),ae.isPending?"Adding...":"Add Spare Disks"]})]})]})]})]})})]})}function Lc(...r){return w6(v6(r))}const bi=Ce.forwardRef(({className:r,...t},s)=>e.jsx("div",{ref:s,className:Lc("rounded-lg border border-border-dark bg-card-dark text-white shadow-sm",r),...t}));bi.displayName="Card";const yi=Ce.forwardRef(({className:r,...t},s)=>e.jsx("div",{ref:s,className:Lc("flex flex-col space-y-1.5 p-6",r),...t}));yi.displayName="CardHeader";const wi=Ce.forwardRef(({className:r,...t},s)=>e.jsx("h3",{ref:s,className:Lc("text-2xl font-semibold leading-none tracking-tight",r),...t}));wi.displayName="CardTitle";const nu=Ce.forwardRef(({className:r,...t},s)=>e.jsx("p",{ref:s,className:Lc("text-sm text-text-secondary",r),...t}));nu.displayName="CardDescription";const vi=Ce.forwardRef(({className:r,...t},s)=>e.jsx("div",{ref:s,className:Lc("p-6 pt-0",r),...t}));vi.displayName="CardContent";const oS=Ce.forwardRef(({className:r,...t},s)=>e.jsx("div",{ref:s,className:Lc("flex items-center p-6 pt-0",r),...t}));oS.displayName="CardFooter";const ct=Ce.forwardRef(({className:r,variant:t="default",size:s="default",...n},o)=>e.jsx("button",{className:Lc("inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{"bg-primary text-primary-foreground hover:bg-primary/90":t==="default","bg-destructive text-destructive-foreground hover:bg-destructive/90":t==="destructive","border border-border-dark bg-card-dark hover:bg-[#233648] hover:text-white text-white":t==="outline","bg-secondary text-secondary-foreground hover:bg-secondary/80":t==="secondary","hover:bg-accent hover:text-accent-foreground":t==="ghost","text-primary underline-offset-4 hover:underline":t==="link","h-10 px-4 py-2":s==="default","h-9 rounded-md px-3":s==="sm","h-11 rounded-md px-8":s==="lg","h-10 w-10":s==="icon"},r),ref:o,...n}));ct.displayName="Button";const lS={info:a4,warning:Eh,critical:s4},AS={info:"bg-blue-500/20 text-blue-400 border-blue-500/30",warning:"bg-yellow-500/20 text-yellow-400 border-yellow-500/30",critical:"bg-red-500/20 text-red-400 border-red-500/30"};function cS(){const[r,t]=Ce.useState("unacknowledged"),s=Nr(),{data:n,isLoading:o}=dt({queryKey:["alerts",r],queryFn:()=>Cc.listAlerts(r==="unacknowledged"?{is_acknowledged:!1}:void 0)}),l=ft({mutationFn:Cc.acknowledgeAlert,onSuccess:()=>{s.invalidateQueries({queryKey:["alerts"]})}}),d=ft({mutationFn:Cc.resolveAlert,onSuccess:()=>{s.invalidateQueries({queryKey:["alerts"]})}}),c=n?.alerts||[];return e.jsxs("div",{className:"space-y-6 min-h-screen bg-background-dark p-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-white",children:"Alerts"}),e.jsx("p",{className:"mt-2 text-sm text-text-secondary",children:"Monitor system alerts and notifications"})]}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(ct,{variant:r==="all"?"default":"outline",onClick:()=>t("all"),children:"All Alerts"}),e.jsx(ct,{variant:r==="unacknowledged"?"default":"outline",onClick:()=>t("unacknowledged"),children:"Unacknowledged"})]})]}),e.jsxs(bi,{children:[e.jsxs(yi,{children:[e.jsxs(wi,{className:"flex items-center",children:[e.jsx(Lb,{className:"h-5 w-5 mr-2"}),"Active Alerts"]}),e.jsx(nu,{children:o?"Loading...":`${c.length} ${r==="unacknowledged"?"unacknowledged":""} alert${c.length!==1?"s":""}`})]}),e.jsx(vi,{children:o?e.jsx("p",{className:"text-sm text-text-secondary",children:"Loading alerts..."}):c.length>0?e.jsx("div",{className:"space-y-4",children:c.map(u=>{const h=lS[u.severity];return e.jsx("div",{className:`border rounded-lg p-4 bg-card-dark ${AS[u.severity]}`,children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-start space-x-3 flex-1",children:[e.jsx(h,{className:"h-5 w-5 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center space-x-2 mb-1",children:[e.jsx("h3",{className:"font-semibold text-white",children:u.title}),e.jsx("span",{className:"text-xs px-2 py-1 bg-[#233648] border border-border-dark rounded text-text-secondary",children:u.source})]}),e.jsx("p",{className:"text-sm mb-2 text-text-secondary",children:u.message}),e.jsxs("div",{className:"flex items-center space-x-4 text-xs",children:[e.jsx("span",{children:sS(u.created_at)}),u.resource_type&&e.jsxs("span",{children:[u.resource_type,": ",u.resource_id]})]})]})]}),e.jsxs("div",{className:"flex space-x-2 ml-4",children:[!u.is_acknowledged&&e.jsxs(ct,{size:"sm",variant:"outline",onClick:()=>l.mutate(u.id),disabled:l.isPending,children:[e.jsx(n4,{className:"h-4 w-4 mr-1"}),"Acknowledge"]}),!u.resolved_at&&e.jsxs(ct,{size:"sm",variant:"outline",onClick:()=>d.mutate(u.id),disabled:d.isPending,children:[e.jsx(s4,{className:"h-4 w-4 mr-1"}),"Resolve"]})]})]})},u.id)})}):e.jsxs("div",{className:"text-center py-8",children:[e.jsx(Lb,{className:"h-12 w-12 text-text-secondary mx-auto mb-4"}),e.jsx("p",{className:"text-sm text-text-secondary",children:"No alerts found"})]})})]})]})}const dS={listLibraries:async()=>(await ze.get("/tape/physical/libraries")).data.libraries||[]},Ym={listLibraries:async()=>(await ze.get("/tape/vtl/libraries")).data.libraries||[],getLibrary:async r=>(await ze.get(`/tape/vtl/libraries/${r}`)).data,createLibrary:async r=>(await ze.post("/tape/vtl/libraries",r)).data.library,deleteLibrary:async r=>{await ze.delete(`/tape/vtl/libraries/${r}`)},getLibraryDrives:async r=>(await ze.get(`/tape/vtl/libraries/${r}/drives`)).data.drives||[],getLibraryTapes:async r=>(await ze.get(`/tape/vtl/libraries/${r}/tapes`)).data.tapes||[],createTape:async(r,t)=>(await ze.post(`/tape/vtl/libraries/${r}/tapes`,t)).data.tape,loadTape:async(r,t)=>(await ze.post(`/tape/vtl/libraries/${r}/load`,t)).data,unloadTape:async(r,t)=>(await ze.post(`/tape/vtl/libraries/${r}/unload`,t)).data};function uS(){const[r,t]=Ce.useState("vtl"),[s,n]=Ce.useState(null),[o,l]=Ce.useState(""),d=Nr(),{data:c=[],isLoading:u}=dt({queryKey:["physical-tape-libraries"],queryFn:dS.listLibraries,enabled:r==="physical",refetchInterval:5e3}),{data:h=[],isLoading:m}=dt({queryKey:["vtl-libraries"],queryFn:Ym.listLibraries,enabled:r==="vtl",refetchInterval:5e3}),{data:x=[]}=dt({queryKey:["vtl-library-tapes",s],queryFn:()=>Ym.getLibraryTapes(s),enabled:!!s&&r==="vtl"}),y=r==="vtl"?h.length:c.length,p=r==="vtl"?h.filter(j=>j.is_active).length:c.filter(j=>j.is_active).length,v=r==="vtl"?h.reduce((j,_)=>j+_.slot_count,0):c.reduce((j,_)=>j+_.slot_count,0),N=x.filter(j=>j.slot_number>0).length,B=(r==="vtl"?h:c).filter(j=>j.name.toLowerCase().includes(o.toLowerCase())||r==="vtl"&&"mhvtl_library_id"in j&&j.mhvtl_library_id.toString().includes(o)),g=()=>{d.invalidateQueries({queryKey:r==="vtl"?["vtl-libraries"]:["physical-tape-libraries"]})};return e.jsxs("div",{className:"flex-1 flex flex-col h-full overflow-hidden relative bg-background-dark",children:[e.jsx("header",{className:"flex-none px-6 py-5 border-b border-border-dark bg-[#111a22]/95 backdrop-blur z-10",children:e.jsxs("div",{className:"max-w-[1400px] mx-auto w-full flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[e.jsx(ba,{to:"/",className:"text-text-secondary text-sm font-medium hover:text-primary transition-colors",children:"Home"}),e.jsx("span",{className:"text-text-secondary text-xs",children:"/"}),e.jsx("span",{className:"text-white text-sm font-medium",children:"Virtual Tape Libraries"})]}),e.jsxs("div",{className:"flex flex-wrap justify-between items-end gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("h2",{className:"text-white text-3xl font-bold tracking-tight",children:"Virtual Tape Libraries"}),e.jsx("p",{className:"text-text-secondary text-base max-w-2xl",children:"Manage virtual tape devices, emulation profiles, and storage targets."})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("button",{onClick:g,className:"px-4 py-2 bg-surface-dark hover:bg-[#2a3b4d] border border-border-dark rounded-lg text-white text-sm font-medium flex items-center gap-2 transition-all",children:[e.jsx("span",{className:"material-symbols-outlined text-lg",children:"refresh"}),"Refresh"]}),r==="vtl"&&e.jsxs(ba,{to:"/tape/vtl/create",className:"px-4 py-2 bg-primary hover:bg-blue-600 rounded-lg text-white text-sm font-bold shadow-lg shadow-blue-900/20 flex items-center gap-2 transition-all",children:[e.jsx("span",{className:"material-symbols-outlined text-lg",children:"add"}),"Create VTL"]})]})]})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto bg-background-dark",children:e.jsxs("div",{className:"max-w-[1400px] mx-auto p-6 flex flex-col gap-6 pb-20",children:[e.jsx("div",{className:"border-b border-border-dark",children:e.jsxs("nav",{className:"-mb-px flex space-x-8",children:[e.jsxs("button",{onClick:()=>{t("vtl"),n(null)},className:`py-4 px-1 border-b-2 font-medium text-sm ${r==="vtl"?"border-primary text-primary":"border-transparent text-text-secondary hover:text-white hover:border-border-dark"}`,children:["Virtual Tape Libraries (",h.length,")"]}),e.jsxs("button",{onClick:()=>{t("physical"),n(null)},className:`py-4 px-1 border-b-2 font-medium text-sm ${r==="physical"?"border-primary text-primary":"border-transparent text-text-secondary hover:text-white hover:border-border-dark"}`,children:["Physical Libraries (",c.length,")"]})]})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-1 p-5 rounded-xl border border-border-dark bg-surface-dark relative overflow-hidden group",children:[e.jsx("div",{className:"absolute right-0 top-0 p-4 opacity-10 group-hover:opacity-20 transition-opacity",children:e.jsx("span",{className:"material-symbols-outlined text-6xl text-white",children:"dns"})}),e.jsx("p",{className:"text-text-secondary text-sm font-medium",children:"Total Libraries"}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx("p",{className:"text-white text-3xl font-bold tracking-tight",children:y}),e.jsxs("span",{className:"text-green-500 text-xs font-medium mb-1.5 flex items-center",children:[e.jsx("span",{className:"material-symbols-outlined text-sm mr-0.5",children:"check_circle"}),p===y?"All Online":`${p} Online`]})]})]}),e.jsxs("div",{className:"flex flex-col gap-1 p-5 rounded-xl border border-border-dark bg-surface-dark relative overflow-hidden group",children:[e.jsx("div",{className:"absolute right-0 top-0 p-4 opacity-10 group-hover:opacity-20 transition-opacity",children:e.jsx("span",{className:"material-symbols-outlined text-6xl text-white",children:"database"})}),e.jsx("p",{className:"text-text-secondary text-sm font-medium",children:"Total Capacity"}),e.jsx("div",{className:"flex items-end gap-2",children:e.jsx("p",{className:"text-white text-3xl font-bold tracking-tight",children:fr(r==="vtl"?h.reduce((j,_)=>j+_.slot_count*15*1024*1024*1024*1024,0):0,1)})})]}),e.jsxs("div",{className:"flex flex-col gap-1 p-5 rounded-xl border border-border-dark bg-surface-dark relative overflow-hidden group",children:[e.jsx("div",{className:"absolute right-0 top-0 p-4 opacity-10 group-hover:opacity-20 transition-opacity",children:e.jsx("span",{className:"material-symbols-outlined text-6xl text-white",children:"album"})}),e.jsx("p",{className:"text-text-secondary text-sm font-medium",children:"Tapes Online"}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx("p",{className:"text-white text-3xl font-bold tracking-tight",children:N}),e.jsxs("span",{className:"text-text-secondary text-xs font-medium mb-1.5",children:["/ ",v," Slots"]})]})]}),e.jsxs("div",{className:"flex flex-col gap-1 p-5 rounded-xl border border-border-dark bg-surface-dark relative overflow-hidden group",children:[e.jsx("div",{className:"absolute right-0 top-0 p-4 opacity-10 group-hover:opacity-20 transition-opacity",children:e.jsx("span",{className:"material-symbols-outlined text-6xl text-white",children:"swap_horiz"})}),e.jsx("p",{className:"text-text-secondary text-sm font-medium",children:"Active Sessions"}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx("p",{className:"text-white text-3xl font-bold tracking-tight",children:r==="vtl"?h.reduce((j,_)=>j+_.drive_count,0):c.reduce((j,_)=>j+_.drive_count,0)}),e.jsx("span",{className:"text-blue-400 text-xs font-medium mb-1.5",children:"Drives"})]})]})]}),e.jsxs("div",{className:"p-5 rounded-xl bg-surface-dark border border-border-dark flex flex-col gap-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-text-secondary",children:"pie_chart"}),e.jsx("h3",{className:"text-white text-sm font-semibold",children:"VTL Partition Usage (ZFS Pool)"})]}),e.jsxs("p",{className:"text-white text-sm font-medium",children:[fr(N*15*1024*1024*1024*1024,1)," /"," ",fr(v*15*1024*1024*1024*1024,1)," Used"]})]}),e.jsx("div",{className:"w-full bg-[#111a22] rounded-full h-3 overflow-hidden",children:e.jsx("div",{className:"bg-gradient-to-r from-blue-600 to-primary h-3 rounded-full",style:{width:`${v>0?N/v*100:0}%`}})}),e.jsxs("div",{className:"flex justify-between items-center text-xs text-text-secondary",children:[e.jsxs("span",{children:["Compression Ratio: ",e.jsx("span",{className:"text-white font-mono",children:"1.5x"})]}),e.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-green-500"})," Pool Healthy"]})]})]}),e.jsxs("div",{className:"flex flex-col rounded-xl border border-border-dark bg-surface-dark overflow-hidden",children:[e.jsxs("div",{className:"p-4 border-b border-border-dark flex flex-col sm:flex-row gap-4 justify-between items-center bg-[#1c2834]",children:[e.jsxs("div",{className:"relative w-full sm:w-96",children:[e.jsx("span",{className:"material-symbols-outlined absolute left-3 top-1/2 -translate-y-1/2 text-text-secondary text-lg",children:"search"}),e.jsx("input",{className:"w-full bg-[#111a22] border border-border-dark text-white text-sm rounded-lg pl-10 pr-4 py-2 focus:ring-1 focus:ring-primary focus:border-primary placeholder-gray-600 outline-none transition-all",placeholder:"Search libraries by name or ID...",type:"text",value:o,onChange:j=>l(j.target.value)})]}),e.jsxs("div",{className:"flex gap-2 w-full sm:w-auto",children:[e.jsxs("button",{className:"px-3 py-2 bg-[#111a22] hover:bg-[#1a2632] border border-border-dark rounded-lg text-text-secondary text-sm font-medium flex items-center gap-2 transition-colors",children:[e.jsx("span",{className:"material-symbols-outlined text-lg",children:"filter_list"}),"Filter"]}),e.jsxs("button",{className:"px-3 py-2 bg-[#111a22] hover:bg-[#1a2632] border border-border-dark rounded-lg text-text-secondary text-sm font-medium flex items-center gap-2 transition-colors",children:[e.jsx("span",{className:"material-symbols-outlined text-lg",children:"settings"}),"Columns"]})]})]}),m||u?e.jsx("div",{className:"p-12 text-center",children:e.jsx("p",{className:"text-text-secondary",children:"Loading libraries..."})}):B.length===0?e.jsxs("div",{className:"p-12 text-center",children:[e.jsx("span",{className:"material-symbols-outlined text-6xl text-text-secondary mb-4 block",children:"database"}),e.jsxs("h3",{className:"text-lg font-medium text-white mb-2",children:["No ",r==="vtl"?"Virtual":"Physical"," Tape Libraries"]}),e.jsx("p",{className:"text-sm text-text-secondary mb-4",children:r==="vtl"?"Create your first virtual tape library to get started":"Discover physical tape libraries connected to the system"}),r==="vtl"&&e.jsxs(ba,{to:"/tape/vtl/create",className:"inline-flex items-center gap-2 px-4 py-2 bg-primary hover:bg-blue-600 rounded-lg text-white text-sm font-bold",children:[e.jsx("span",{className:"material-symbols-outlined text-lg",children:"add"}),"Create VTL Library"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-[#151e29] border-b border-border-dark",children:[e.jsx("th",{className:"py-4 px-6 text-xs font-semibold uppercase tracking-wider text-text-secondary w-12",children:e.jsx("input",{className:"rounded border-border-dark bg-[#111a22] text-primary focus:ring-offset-background-dark focus:ring-primary h-4 w-4",type:"checkbox"})}),e.jsx("th",{className:"py-4 px-6 text-xs font-semibold uppercase tracking-wider text-text-secondary",children:"Library Name"}),e.jsx("th",{className:"py-4 px-6 text-xs font-semibold uppercase tracking-wider text-text-secondary",children:"Status"}),e.jsx("th",{className:"py-4 px-6 text-xs font-semibold uppercase tracking-wider text-text-secondary",children:"Emulation"}),e.jsx("th",{className:"py-4 px-6 text-xs font-semibold uppercase tracking-wider text-text-secondary",children:"Tapes / Slots"}),e.jsx("th",{className:"py-4 px-6 text-xs font-semibold uppercase tracking-wider text-text-secondary",children:"iSCSI Target"}),e.jsx("th",{className:"py-4 px-6 text-xs font-semibold uppercase tracking-wider text-text-secondary text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-border-dark",children:B.map(j=>{const _=r==="vtl",w=_?j.mhvtl_library_id:j.id,L=j.is_active?"Ready":"Offline",K=j.is_active?"green":"gray",M=_&&s===j.id?x.length:0;return e.jsxs("tr",{className:"group hover:bg-[#233342] transition-colors cursor-pointer",onClick:()=>_&&n(s===j.id?null:j.id),children:[e.jsx("td",{className:"py-4 px-6",children:e.jsx("input",{className:"rounded border-border-dark bg-[#111a22] text-primary focus:ring-offset-background-dark focus:ring-primary h-4 w-4",type:"checkbox",onClick:V=>V.stopPropagation()})}),e.jsx("td",{className:"py-4 px-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`size-8 rounded flex items-center justify-center ${j.is_active?"bg-blue-900/30 text-primary":"bg-gray-700/30 text-gray-400"}`,children:e.jsx("span",{className:"material-symbols-outlined text-lg",children:"shelves"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-white text-sm font-bold",children:j.name}),e.jsxs("p",{className:"text-text-secondary text-xs",children:["ID: ",w]})]})]})}),e.jsx("td",{className:"py-4 px-6",children:e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border ${K==="green"?"bg-green-500/10 text-green-400 border-green-500/20":"bg-gray-500/10 text-gray-400 border-gray-500/20"}`,children:[K==="green"&&e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500 animate-pulse"}),K==="gray"&&e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-gray-500"}),L]})}),e.jsxs("td",{className:"py-4 px-6",children:[e.jsx("p",{className:"text-white text-sm font-medium",children:_?j.vendor||"MHVTL":"physical"in j?j.vendor:"N/A"}),e.jsxs("p",{className:"text-text-secondary text-xs",children:["LTO-8 • ",j.drive_count," ",j.drive_count===1?"Drive":"Drives"]})]}),e.jsxs("td",{className:"py-4 px-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-text-secondary text-lg",children:"album"}),e.jsxs("span",{className:"text-white text-sm",children:[M||0," / ",j.slot_count]})]}),e.jsx("div",{className:"w-24 bg-[#111a22] rounded-full h-1 mt-1.5",children:e.jsx("div",{className:`h-1 rounded-full ${j.is_active?"bg-primary":"bg-gray-500"}`,style:{width:`${j.slot_count>0?(M||0)/j.slot_count*100:0}%`}})})]}),e.jsx("td",{className:"py-4 px-6",children:e.jsxs("div",{className:"flex items-center gap-2 group/copy cursor-pointer",onClick:()=>{const V=`iqn.2023-10.com.vtl:${j.name.toLowerCase().replace(/\s+/g,"")}`;navigator.clipboard.writeText(V)},children:[e.jsxs("code",{className:"text-xs text-text-secondary font-mono bg-[#111a22] px-2 py-1 rounded border border-border-dark group-hover/copy:text-white transition-colors",children:["iqn.2023-10.com.vtl:",j.name.toLowerCase().replace(/\s+/g,"")]}),e.jsx("span",{className:"material-symbols-outlined text-text-secondary text-sm opacity-0 group-hover/copy:opacity-100 transition-opacity",children:"content_copy"})]})}),e.jsx("td",{className:"py-4 px-6 text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(ba,{to:_?`/tape/vtl/${j.id}`:`/tape/physical/${j.id}`,className:"p-2 text-text-secondary hover:text-white hover:bg-[#324d67] rounded-lg transition-colors",title:"Manage Tapes",onClick:V=>V.stopPropagation(),children:e.jsx("span",{className:"material-symbols-outlined text-xl",children:"cable"})}),e.jsx("button",{className:"p-2 text-text-secondary hover:text-primary hover:bg-primary/10 rounded-lg transition-colors",title:"Edit Configuration",onClick:V=>V.stopPropagation(),children:e.jsx("span",{className:"material-symbols-outlined text-xl",children:"edit"})}),e.jsx("button",{className:"p-2 text-text-secondary hover:text-red-400 hover:bg-red-400/10 rounded-lg transition-colors",title:"Delete Library",onClick:V=>V.stopPropagation(),children:e.jsx("span",{className:"material-symbols-outlined text-xl",children:"delete"})})]})})]},j.id)})})]})}),e.jsxs("div",{className:"px-6 py-4 border-t border-border-dark flex items-center justify-between bg-[#1c2834]",children:[e.jsxs("p",{className:"text-text-secondary text-sm",children:["Showing ",e.jsxs("span",{className:"text-white font-medium",children:["1-",B.length]})," of"," ",e.jsx("span",{className:"text-white font-medium",children:B.length})," libraries"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{className:"px-3 py-1.5 rounded-lg border border-border-dark bg-[#111a22] text-text-secondary text-sm hover:text-white disabled:opacity-50",disabled:!0,children:"Previous"}),e.jsx("button",{className:"px-3 py-1.5 rounded-lg border border-border-dark bg-[#111a22] text-text-secondary text-sm hover:text-white disabled:opacity-50",disabled:!0,children:"Next"})]})]})]})]})]})}),s&&r==="vtl"&&e.jsx("div",{className:"bg-surface-dark border-t border-border-dark p-6 absolute bottom-0 w-full transform translate-y-0 transition-transform z-30 shadow-2xl shadow-black max-h-[70vh] overflow-y-auto",children:e.jsxs("div",{className:"max-w-[1400px] mx-auto",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4 mb-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"material-symbols-outlined text-primary text-2xl",children:"cable"}),e.jsxs("div",{children:[e.jsxs("h3",{className:"text-white text-lg font-bold",children:["Tape Management: ",h.find(j=>j.id===s)?.name]}),e.jsx("p",{className:"text-text-secondary text-sm",children:"Manage virtual cartridges, import/export slots, and barcodes."})]})]}),e.jsxs("div",{className:"flex gap-3 flex-wrap",children:[e.jsx("button",{className:"px-3 py-2 bg-[#111a22] border border-border-dark rounded-lg text-text-secondary hover:text-white text-sm font-medium transition-colors",children:"Bulk Format"}),e.jsxs(ba,{to:`/tape/vtl/${s}/tapes/create`,className:"px-3 py-2 bg-primary hover:bg-blue-600 rounded-lg text-white text-sm font-bold transition-colors flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-lg",children:"add"}),"Add Tapes"]}),e.jsx("button",{onClick:()=>n(null),className:"p-2 text-text-secondary hover:text-white",children:e.jsx("span",{className:"material-symbols-outlined",children:"close"})})]})]}),x.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("span",{className:"material-symbols-outlined text-6xl text-text-secondary mb-4 block",children:"album"}),e.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"No Tapes Found"}),e.jsx("p",{className:"text-sm text-text-secondary mb-4",children:"This library has no tapes yet. Create tapes to get started."}),e.jsxs(ba,{to:`/tape/vtl/${s}/tapes/create`,className:"inline-flex items-center gap-2 px-4 py-2 bg-primary hover:bg-blue-600 rounded-lg text-white text-sm font-bold",children:[e.jsx("span",{className:"material-symbols-outlined text-lg",children:"add"}),"Add Tapes"]})]}):e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 xl:grid-cols-8 gap-3",children:x.map(j=>e.jsxs("div",{className:`p-3 rounded-lg border flex flex-col gap-2 relative group hover:border-primary transition-all cursor-pointer min-h-[120px] ${j.status==="in_drive"?"bg-[#111a22] border-green-500/30 shadow-lg shadow-green-500/10":"bg-[#111a22] border-border-dark hover:shadow-lg hover:shadow-primary/10"}`,children:[e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsx("span",{className:`material-symbols-outlined text-xl ${j.status==="in_drive"?"text-green-500":"text-text-secondary"}`,children:"album"}),e.jsxs("span",{className:"text-[10px] uppercase font-bold text-text-secondary bg-[#1c2834] px-1.5 py-0.5 rounded",children:["SLOT ",j.slot_number]})]}),e.jsxs("div",{className:"flex-1 flex flex-col justify-center",children:[e.jsx("p",{className:"text-white text-xs font-mono font-bold truncate",title:j.barcode,children:j.barcode}),e.jsxs("p",{className:"text-text-secondary text-[10px] mt-1",children:[fr(j.size_bytes,1)," / ",fr(j.size_bytes,1)]})]}),e.jsxs("div",{className:"absolute inset-0 bg-black/70 hidden group-hover:flex items-center justify-center gap-2 backdrop-blur-sm rounded-lg",children:[e.jsx("button",{className:"p-2 text-white hover:text-primary hover:bg-primary/20 rounded transition-colors",title:"Eject",children:e.jsx("span",{className:"material-symbols-outlined text-lg",children:"eject"})}),e.jsx("button",{className:"p-2 text-white hover:text-red-400 hover:bg-red-400/20 rounded transition-colors",title:"Delete",children:e.jsx("span",{className:"material-symbols-outlined text-lg",children:"delete"})})]})]},j.id))})]})})]})}function hS(){const{id:r}=jy(),t=Ph(),s=Nr(),[n,o]=Ce.useState(null),{data:l,isLoading:d}=dt({queryKey:["vtl-library",r],queryFn:()=>Ym.getLibrary(r),enabled:!!r}),c=ft({mutationFn:()=>Ym.deleteLibrary(r),onSuccess:()=>{s.invalidateQueries({queryKey:["vtl-libraries"]}),t("/tape")}});if(d)return e.jsx("div",{className:"text-sm text-text-secondary min-h-screen bg-background-dark p-6",children:"Loading library details..."});if(!l)return e.jsx("div",{className:"text-sm text-red-400 min-h-screen bg-background-dark p-6",children:"Library not found"});const{library:u,drives:h,tapes:m}=l;return e.jsxs("div",{className:"space-y-6 min-h-screen bg-background-dark p-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsxs(ct,{variant:"ghost",size:"sm",onClick:()=>t("/tape"),children:[e.jsx(wc,{className:"h-4 w-4 mr-2"}),"Back"]}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-white",children:u.name}),e.jsxs("p",{className:"mt-1 text-sm text-text-secondary",children:["Virtual Tape Library • ",u.slot_count," slots • ",u.drive_count," drives"]})]})]}),e.jsxs(ct,{variant:"destructive",onClick:()=>{confirm("Are you sure you want to delete this library?")&&c.mutate()},children:[e.jsx(es,{className:"h-4 w-4 mr-2"}),"Delete Library"]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[e.jsxs(bi,{children:[e.jsx(yi,{children:e.jsx(wi,{className:"text-sm font-medium",children:"Library Status"})}),e.jsx(vi,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-text-secondary",children:"Status:"}),e.jsx("span",{className:u.is_active?"text-green-400":"text-text-secondary",children:u.is_active?"Active":"Inactive"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-text-secondary",children:"mhVTL ID:"}),e.jsx("span",{className:"font-medium text-white",children:u.mhvtl_library_id})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-text-secondary",children:"Storage Path:"}),e.jsx("span",{className:"font-mono text-xs text-white",children:u.storage_path})]})]})})]}),e.jsxs(bi,{children:[e.jsx(yi,{children:e.jsx(wi,{className:"text-sm font-medium",children:"Capacity"})}),e.jsx(vi,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-text-secondary",children:"Total Slots:"}),e.jsx("span",{className:"font-medium text-white",children:u.slot_count})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-text-secondary",children:"Used Slots:"}),e.jsx("span",{className:"font-medium text-white",children:m.length})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-text-secondary",children:"Free Slots:"}),e.jsx("span",{className:"font-medium text-white",children:u.slot_count-m.length})]})]})})]}),e.jsxs(bi,{children:[e.jsx(yi,{children:e.jsx(wi,{className:"text-sm font-medium",children:"Drives"})}),e.jsx(vi,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-text-secondary",children:"Total Drives:"}),e.jsx("span",{className:"font-medium text-white",children:u.drive_count})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-text-secondary",children:"Idle:"}),e.jsx("span",{className:"font-medium text-white",children:h.filter(x=>x.status==="idle").length})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-text-secondary",children:"Ready:"}),e.jsx("span",{className:"font-medium text-white",children:h.filter(x=>x.status==="ready").length})]})]})})]})]}),e.jsxs(bi,{children:[e.jsx(yi,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(wi,{children:"Drives"}),e.jsx(nu,{children:"Virtual tape drives in this library"})]}),e.jsxs(ct,{variant:"outline",size:"sm",children:[e.jsx(Cn,{className:"h-4 w-4 mr-2"}),"Refresh"]})]})}),e.jsx(vi,{children:h.length>0?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:h.map(x=>e.jsx(fS,{drive:x,tapes:m,isSelected:n===x.id,onSelect:()=>o(x.id)},x.id))}):e.jsx("p",{className:"text-sm text-text-secondary",children:"No drives configured"})})]}),e.jsxs(bi,{children:[e.jsx(yi,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(wi,{children:"Virtual Tapes"}),e.jsxs(nu,{children:[m.length," of ",u.slot_count," slots used"]})]}),e.jsxs(ct,{variant:"outline",size:"sm",children:[e.jsx(Ks,{className:"h-4 w-4 mr-2"}),"Create Tape"]})]})}),e.jsx(vi,{children:m.length>0?e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"min-w-full divide-y divide-gray-200",children:[e.jsx("thead",{className:"bg-[#1a2632]",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-text-secondary uppercase",children:"Barcode"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-text-secondary uppercase",children:"Slot"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-text-secondary uppercase",children:"Size"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-text-secondary uppercase",children:"Status"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-text-secondary uppercase",children:"Actions"})]})}),e.jsx("tbody",{className:"bg-card-dark divide-y divide-border-dark",children:m.map(x=>e.jsxs("tr",{className:"hover:bg-[#233648]",children:[e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium text-white",children:x.barcode}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-text-secondary",children:x.slot_number}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-text-secondary",children:fr(x.size_bytes)}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("span",{className:`px-2 py-1 text-xs font-medium rounded ${x.status==="loaded"?"bg-blue-100 text-blue-800":x.status==="mounted"?"bg-green-100 text-green-800":"bg-gray-100 text-gray-800"}`,children:x.status})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm",children:n&&e.jsxs(ct,{variant:"outline",size:"sm",onClick:()=>{console.log("Load tape",x.id,"to drive",n)},children:[e.jsx(i4,{className:"h-3 w-3 mr-1"}),"Load"]})})]},x.id))})]})}):e.jsx("p",{className:"text-sm text-text-secondary",children:"No tapes created yet"})})]})]})}function fS({drive:r,tapes:t,isSelected:s,onSelect:n}){const o=t.find(l=>l.id===r.current_tape_id);return e.jsxs("div",{className:`border rounded-lg p-4 cursor-pointer transition-colors ${s?"border-blue-500 bg-blue-50":"border-gray-200 hover:border-gray-300"}`,onClick:n,children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("h4",{className:"font-medium",children:["Drive ",r.drive_number]}),e.jsx("span",{className:`px-2 py-1 text-xs font-medium rounded ${r.status==="ready"?"bg-green-100 text-green-800":r.status==="loaded"?"bg-blue-100 text-blue-800":"bg-gray-100 text-gray-800"}`,children:r.status})]}),o?e.jsxs("div",{className:"text-sm text-text-secondary",children:[e.jsxs("p",{className:"text-white",children:["Tape: ",o.barcode]}),e.jsx("p",{className:"text-xs text-text-secondary",children:fr(o.size_bytes)})]}):e.jsx("p",{className:"text-sm text-text-secondary",children:"No tape loaded"}),s&&e.jsx("div",{className:"mt-2 pt-2 border-t",children:e.jsx("p",{className:"text-xs text-blue-600",children:"Selected - Click tape to load"})})]})}const br={listTargets:async()=>(await ze.get("/scst/targets",{headers:{"Cache-Control":"no-cache"},params:{_t:Date.now()}})).data.targets||[],getTarget:async r=>(await ze.get(`/scst/targets/${r}`,{headers:{"Cache-Control":"no-cache"},params:{_t:Date.now()}})).data,createTarget:async r=>(await ze.post("/scst/targets",r)).data,addLUN:async(r,t)=>(await ze.post(`/scst/targets/${r}/luns`,t)).data,removeLUN:async(r,t)=>(await ze.delete(`/scst/targets/${r}/luns/${t}`)).data,addInitiator:async(r,t)=>(await ze.post(`/scst/targets/${r}/initiators`,t)).data,applyConfig:async()=>(await ze.post("/scst/config/apply")).data,listHandlers:async()=>(await ze.get("/scst/handlers",{headers:{"Cache-Control":"no-cache"},params:{_t:Date.now()}})).data.handlers||[],listPortals:async()=>(await ze.get("/scst/portals",{headers:{"Cache-Control":"no-cache"},params:{_t:Date.now()}})).data.portals||[],getPortal:async r=>(await ze.get(`/scst/portals/${r}`,{headers:{"Cache-Control":"no-cache"},params:{_t:Date.now()}})).data,createPortal:async r=>(await ze.post("/scst/portals",r)).data,updatePortal:async(r,t)=>(await ze.put(`/scst/portals/${r}`,t)).data,deletePortal:async r=>{await ze.delete(`/scst/portals/${r}`)},enableTarget:async r=>(await ze.post(`/scst/targets/${r}/enable`)).data,disableTarget:async r=>(await ze.post(`/scst/targets/${r}/disable`)).data,deleteTarget:async r=>(await ze.delete(`/scst/targets/${r}`)).data,listInitiators:async()=>(await ze.get("/scst/initiators",{headers:{"Cache-Control":"no-cache"},params:{_t:Date.now()}})).data.initiators||[],getInitiator:async r=>(await ze.get(`/scst/initiators/${r}`,{headers:{"Cache-Control":"no-cache"},params:{_t:Date.now()}})).data,removeInitiator:async r=>{await ze.delete(`/scst/initiators/${r}`)},listExtents:async()=>(await ze.get("/scst/extents",{headers:{"Cache-Control":"no-cache"},params:{_t:Date.now()}})).data.extents||[],createExtent:async r=>(await ze.post("/scst/extents",r)).data,deleteExtent:async r=>{await ze.delete(`/scst/extents/${r}`)},listInitiatorGroups:async()=>(await ze.get("/scst/initiator-groups",{headers:{"Cache-Control":"no-cache"},params:{_t:Date.now()}})).data.groups||[],getInitiatorGroup:async r=>(await ze.get(`/scst/initiator-groups/${r}`,{headers:{"Cache-Control":"no-cache"},params:{_t:Date.now()}})).data,createInitiatorGroup:async r=>(await ze.post("/scst/initiator-groups",r)).data,updateInitiatorGroup:async(r,t)=>(await ze.put(`/scst/initiator-groups/${r}`,t)).data,deleteInitiatorGroup:async r=>{await ze.delete(`/scst/initiator-groups/${r}`)},addInitiatorToGroup:async(r,t)=>(await ze.post(`/scst/initiator-groups/${r}/initiators`,{initiator_iqn:t})).data,getConfigFile:async r=>(await ze.get("/scst/config/file",{params:r?{path:r}:{}})).data,updateConfigFile:async(r,t)=>(await ze.put("/scst/config/file",{content:r,path:t})).data};function mS(){const r=Nr(),[t,s]=Ce.useState(!1),[n,o]=Ce.useState("targets"),[l,d]=Ce.useState(null),[c,u]=Ce.useState(""),{data:h,isLoading:m}=dt({queryKey:["scst-targets"],queryFn:br.listTargets,refetchInterval:3e3,refetchIntervalInBackground:!0,refetchOnWindowFocus:!0,refetchOnMount:!0,refetchOnReconnect:!0,staleTime:0,gcTime:0,structuralSharing:!1}),x=ft({mutationFn:br.applyConfig,onSuccess:()=>{r.invalidateQueries({queryKey:["scst-targets"]}),alert("Configuration applied successfully!")}}),y=h?.filter(p=>p.iqn.toLowerCase().includes(c.toLowerCase())||p.alias&&p.alias.toLowerCase().includes(c.toLowerCase()))||[];return e.jsxs("div",{className:"flex-1 overflow-y-auto p-8",children:[e.jsxs("div",{className:"max-w-[1200px] mx-auto flex flex-col gap-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(ba,{to:"/storage",className:"text-text-secondary text-sm font-medium hover:text-white transition-colors",children:"Storage"}),e.jsx(Ka,{className:"text-text-secondary",size:16}),e.jsx("span",{className:"text-white text-sm font-medium",children:"iSCSI Management"})]}),e.jsxs("div",{className:"flex flex-wrap justify-between items-end gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("h1",{className:"text-white text-3xl font-extrabold leading-tight tracking-tight",children:"iSCSI Management"}),e.jsx("p",{className:"text-text-secondary text-base font-normal",children:"Manage targets, portals, and initiator access control lists."})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(ct,{variant:"outline",onClick:()=>x.mutate(),disabled:x.isPending,className:"flex items-center gap-2 px-4 h-10 rounded-lg bg-card-dark border border-border-dark hover:bg-white/5 text-white text-sm font-semibold",children:[e.jsx(vc,{size:20}),e.jsx("span",{children:"Global Settings"})]}),e.jsxs(ct,{onClick:()=>s(!0),className:"flex items-center gap-2 px-4 h-10 rounded-lg bg-primary hover:bg-blue-600 text-white text-sm font-bold shadow-lg shadow-blue-900/20",children:[e.jsx(Ks,{size:20}),e.jsx("span",{children:"Create Target"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-1 rounded-xl p-5 bg-card-dark border border-border-dark shadow-sm",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("p",{className:"text-text-secondary text-sm font-medium uppercase tracking-wider",children:"Service Status"}),e.jsx(n4,{className:"text-green-500",size:24})]}),e.jsx("p",{className:"text-white text-2xl font-bold",children:"Running"}),e.jsx("p",{className:"text-green-500 text-xs font-medium mt-1",children:"Uptime: 14d 2h"})]}),e.jsxs("div",{className:"flex flex-col gap-1 rounded-xl p-5 bg-card-dark border border-border-dark shadow-sm",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("p",{className:"text-text-secondary text-sm font-medium uppercase tracking-wider",children:"Port Binding"}),e.jsx(ya,{className:"text-text-secondary",size:24})]}),e.jsx("p",{className:"text-white text-2xl font-bold",children:"3260"}),e.jsx("p",{className:"text-text-secondary text-xs font-medium mt-1",children:"Listening on 0.0.0.0"})]}),e.jsxs("div",{className:"flex flex-col gap-1 rounded-xl p-5 bg-card-dark border border-border-dark shadow-sm",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("p",{className:"text-text-secondary text-sm font-medium uppercase tracking-wider",children:"Active Sessions"}),e.jsx(N6,{className:"text-primary",size:24})]}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("p",{className:"text-white text-2xl font-bold",children:"12"}),e.jsxs("span",{className:"text-green-500 text-sm font-medium flex items-center",children:[e.jsx(B6,{size:16})," 2"]})]}),e.jsx("p",{className:"text-text-secondary text-xs font-medium mt-1",children:"Total throughput: 450 MB/s"})]})]}),e.jsxs("div",{className:"flex flex-col bg-card-dark border border-border-dark rounded-xl overflow-hidden shadow-sm",children:[e.jsx("div",{className:"border-b border-border-dark px-6",children:e.jsxs("div",{className:"flex gap-8",children:[e.jsxs("button",{onClick:()=>o("targets"),className:`relative py-4 text-sm tracking-wide transition-colors ${n==="targets"?"text-primary font-bold":"text-text-secondary hover:text-white font-medium"}`,children:["Targets",n==="targets"&&e.jsx("div",{className:"absolute bottom-0 left-0 w-full h-0.5 bg-primary rounded-t-full"})]}),e.jsxs("button",{onClick:()=>o("portals"),className:`relative py-4 text-sm tracking-wide transition-colors ${n==="portals"?"text-primary font-bold":"text-text-secondary hover:text-white font-medium"}`,children:["Portals",n==="portals"&&e.jsx("div",{className:"absolute bottom-0 left-0 w-full h-0.5 bg-primary rounded-t-full"})]}),e.jsxs("button",{onClick:()=>o("initiators"),className:`relative py-4 text-sm tracking-wide transition-colors ${n==="initiators"?"text-primary font-bold":"text-text-secondary hover:text-white font-medium"}`,children:["Initiators",n==="initiators"&&e.jsx("div",{className:"absolute bottom-0 left-0 w-full h-0.5 bg-primary rounded-t-full"})]}),e.jsxs("button",{onClick:()=>o("extents"),className:`relative py-4 text-sm tracking-wide transition-colors ${n==="extents"?"text-primary font-bold":"text-text-secondary hover:text-white font-medium"}`,children:["Extents",n==="extents"&&e.jsx("div",{className:"absolute bottom-0 left-0 w-full h-0.5 bg-primary rounded-t-full"})]}),e.jsxs("button",{onClick:()=>o("groups"),className:`relative py-4 text-sm tracking-wide transition-colors ${n==="groups"?"text-primary font-bold":"text-text-secondary hover:text-white font-medium"}`,children:["Groups",n==="groups"&&e.jsx("div",{className:"absolute bottom-0 left-0 w-full h-0.5 bg-primary rounded-t-full"})]}),e.jsxs("button",{onClick:()=>o("config"),className:`relative py-4 text-sm tracking-wide transition-colors ${n==="config"?"text-primary font-bold":"text-text-secondary hover:text-white font-medium"}`,children:["Config Editor",n==="config"&&e.jsx("div",{className:"absolute bottom-0 left-0 w-full h-0.5 bg-primary rounded-t-full"})]})]})}),e.jsxs("div",{className:"p-4 flex items-center justify-between gap-4 border-b border-border-dark/50 bg-[#141d26]",children:[e.jsxs("div",{className:"relative flex-1 max-w-md",children:[e.jsx(io,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-text-secondary",size:20}),e.jsx("input",{type:"text",placeholder:"Search targets by alias or IQN...",value:c,onChange:p=>u(p.target.value),className:"w-full bg-[#0f161d] border border-border-dark rounded-lg pl-10 pr-4 py-2 text-sm text-white focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary transition-all placeholder-text-secondary/50"})]}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-md bg-[#0f161d] border border-border-dark",children:[e.jsx("span",{className:"text-xs text-text-secondary font-medium",children:"Filter:"}),e.jsxs("select",{className:"bg-[#0f161d] text-xs text-white font-medium focus:outline-none cursor-pointer border-none appearance-none pr-6",style:{backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23999' d='M6 9L1 4h10z'/%3E%3C/svg%3E")`,backgroundRepeat:"no-repeat",backgroundPosition:"right 0 center",paddingRight:"24px"},children:[e.jsx("option",{className:"bg-[#0f161d] text-white",children:"All Status"}),e.jsx("option",{className:"bg-[#0f161d] text-white",children:"Online"}),e.jsx("option",{className:"bg-[#0f161d] text-white",children:"Offline"})]})]})})]}),n==="targets"&&e.jsxs("div",{className:"flex flex-col",children:[m?e.jsx("div",{className:"p-8 text-center text-text-secondary",children:"Loading targets..."}):y.length>0?e.jsx(e.Fragment,{children:y.map((p,v)=>e.jsx(pS,{target:p,isExpanded:l===p.id,onToggle:()=>d(l===p.id?null:p.id),onDelete:()=>{l===p.id&&d(null)},isLast:v===y.length-1},p.id))}):e.jsx("div",{className:"p-12 text-center",children:e.jsx("p",{className:"text-text-secondary",children:"No targets found"})}),e.jsxs("div",{className:"p-4 bg-[#141d26] border-t border-border-dark flex items-center justify-between",children:[e.jsxs("p",{className:"text-xs text-text-secondary",children:["Showing 1-",y.length," of ",y.length," targets"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{className:"p-1 rounded text-text-secondary hover:text-white hover:bg-white/10 disabled:opacity-50",children:e.jsx(Sy,{size:20})}),e.jsx("button",{className:"p-1 rounded text-text-secondary hover:text-white hover:bg-white/10",children:e.jsx(Ka,{size:20})})]})]})]}),n==="portals"&&e.jsx(bS,{}),n==="initiators"&&e.jsx(wS,{}),n==="extents"&&e.jsx(vS,{}),n==="groups"&&e.jsx(BS,{}),n==="config"&&e.jsx(_S,{})]})]}),t&&e.jsx(gS,{onClose:()=>s(!1),onSuccess:async()=>{s(!1),await r.invalidateQueries({queryKey:["scst-targets"]}),await r.refetchQueries({queryKey:["scst-targets"]})}})]})}function pS({target:r,isExpanded:t,onToggle:s,onDelete:n}){const{data:o}=dt({queryKey:["scst-target",r.id],queryFn:()=>br.getTarget(r.id),enabled:t}),l=o?.luns||[],d=o?.initiator_groups||[],[c,u]=Ce.useState(!1),h=Nr(),m=r.is_active?"bg-green-500/20 text-green-400 border-green-500/20":"bg-red-500/20 text-red-400 border-red-500/20",x=r.is_active?"Online":"Offline",y=ft({mutationFn:()=>br.enableTarget(r.id),onSuccess:()=>{h.invalidateQueries({queryKey:["scst-targets"]}),h.invalidateQueries({queryKey:["scst-target",r.id]})}}),p=ft({mutationFn:()=>br.disableTarget(r.id),onSuccess:()=>{h.invalidateQueries({queryKey:["scst-targets"]}),h.invalidateQueries({queryKey:["scst-target",r.id]})}}),v=ft({mutationFn:()=>br.deleteTarget(r.id),onSuccess:async()=>{t&&s(),n&&n(),h.setQueryData(["scst-targets"],B=>B&&B.filter(g=>g.id!==r.id)),h.removeQueries({queryKey:["scst-target",r.id]}),await h.invalidateQueries({queryKey:["scst-targets"]}),await h.refetchQueries({queryKey:["scst-targets"],type:"active"})},onError:B=>{h.refetchQueries({queryKey:["scst-targets"]}),alert(`Failed to delete target: ${B.response?.data?.error||B.message}`)}}),N=ft({mutationFn:({targetId:B,lunId:g})=>br.removeLUN(B,g),onMutate:async({lunId:B})=>{await h.cancelQueries({queryKey:["scst-target",r.id]}),await h.cancelQueries({queryKey:["scst-targets"]});const g=h.getQueryData(["scst-target",r.id]),j=h.getQueryData(["scst-targets"]);return h.setQueryData(["scst-target",r.id],_=>_&&{..._,luns:_.luns?_.luns.filter(w=>w.id!==B):[]}),h.setQueryData(["scst-targets"],_=>_&&_.map(w=>w.id===r.id?{...w,lun_count:Math.max(0,(w.lun_count||0)-1)}:w)),{previousTarget:g,previousTargets:j}},onSuccess:async()=>{h.removeQueries({queryKey:["scst-target",r.id]}),await h.invalidateQueries({queryKey:["scst-targets"]}),await h.invalidateQueries({queryKey:["scst-target",r.id]}),t&&await h.refetchQueries({queryKey:["scst-target",r.id]}),await h.refetchQueries({queryKey:["scst-targets"],type:"active"})},onError:(B,g,j)=>{if(B.response?.status===404){h.invalidateQueries({queryKey:["scst-target",r.id]}),h.invalidateQueries({queryKey:["scst-targets"]}),h.refetchQueries({queryKey:["scst-target",r.id]}),h.refetchQueries({queryKey:["scst-targets"]});return}j?.previousTarget&&h.setQueryData(["scst-target",r.id],j.previousTarget),j?.previousTargets&&h.setQueryData(["scst-targets"],j.previousTargets),h.refetchQueries({queryKey:["scst-target",r.id]}),h.refetchQueries({queryKey:["scst-targets"]}),alert(`Failed to remove LUN: ${B.response?.data?.error||B.message}`)}});return e.jsxs("div",{className:`group border-b border-border-dark ${t?"bg-white/[0.02]":"bg-transparent"}`,children:[e.jsxs("div",{className:`flex items-center p-4 gap-4 hover:bg-white/5 transition-colors cursor-pointer border-l-4 ${t?"border-primary":"border-transparent hover:border-border-dark"}`,onClick:s,children:[e.jsx("div",{className:`p-2 rounded-md ${t?"bg-primary/10 text-primary":"bg-border-dark/50 text-text-secondary"}`,children:e.jsx(ya,{size:24})}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col gap-1",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-white font-bold text-sm",children:r.alias||r.iqn.split(":").pop()}),e.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-bold uppercase tracking-wide border ${m}`,children:x}),r.is_active?e.jsx("button",{onClick:B=>{B.stopPropagation(),confirm("Disable this target? It will stop accepting iSCSI connections.")&&p.mutate()},className:"px-2 py-1 text-xs bg-red-500/20 text-red-400 hover:bg-red-500/30 rounded border border-red-500/20",title:"Disable target",children:"Disable"}):e.jsx("button",{onClick:B=>{B.stopPropagation(),y.mutate()},className:"px-2 py-1 text-xs bg-green-500/20 text-green-400 hover:bg-green-500/30 rounded border border-green-500/20",title:"Enable target",children:"Enable"})]}),e.jsxs("div",{className:"flex items-center gap-2 group/iqn",children:[e.jsx("span",{className:"text-text-secondary font-mono text-xs truncate",children:r.iqn}),e.jsx("button",{className:"opacity-0 group-hover/iqn:opacity-100 text-text-secondary hover:text-white transition-opacity",title:"Copy IQN",onClick:B=>{B.stopPropagation(),navigator.clipboard.writeText(r.iqn)},children:e.jsx(so,{size:14})})]})]}),e.jsxs("div",{className:"hidden md:flex items-center gap-8 mr-4",children:[e.jsxs("div",{className:"flex flex-col items-end",children:[e.jsx("span",{className:"text-[10px] uppercase text-text-secondary font-bold tracking-wider",children:"LUNs"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Ul,{className:"text-text-secondary",size:16}),e.jsx("span",{className:"text-white text-sm font-bold",children:r.lun_count||0})]})]}),e.jsxs("div",{className:"flex flex-col items-end",children:[e.jsx("span",{className:"text-[10px] uppercase text-text-secondary font-bold tracking-wider",children:"Auth"}),e.jsx("span",{className:"text-white text-sm font-medium",children:"None"})]})]}),e.jsx("button",{className:"p-2 hover:bg-white/10 rounded-full text-text-secondary hover:text-white transition-colors",onClick:B=>{B.stopPropagation(),s()},children:t?e.jsx(j6,{size:24}):e.jsx(wh,{size:24})})]}),t&&e.jsx("div",{className:"px-4 pb-4 pt-0",children:e.jsxs("div",{className:"bg-[#0f161d] border border-border-dark rounded-lg p-4 grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"text-xs font-bold text-text-secondary uppercase tracking-wider",children:"Attached LUNs"}),e.jsx(ba,{to:`/iscsi/${r.id}`,className:"text-primary text-xs font-bold hover:underline",onClick:B=>B.stopPropagation(),children:"+ Add LUN"})]}),e.jsx("div",{className:"flex flex-col gap-2",children:l.length>0?l.map(B=>e.jsxs("div",{className:"p-3 rounded bg-card-dark border border-border-dark flex items-center justify-between",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-white text-sm font-medium",children:["LUN ",B.lun_number]}),B.is_active&&e.jsx("span",{className:"px-2 py-0.5 text-xs font-medium rounded bg-green-100 text-green-800",children:"Active"})]}),e.jsxs("div",{className:"text-text-secondary text-xs",children:[B.handler||"Unknown"," • ",B.device_path||"No path"]}),e.jsx("div",{className:"text-text-secondary text-xs",children:B.device_type||"Unknown type"})]}),e.jsx("button",{onClick:()=>{confirm(`Remove LUN ${B.lun_number} from this target?`)&&N.mutate({targetId:r.id,lunId:B.id})},disabled:N.isPending,className:"p-1.5 hover:bg-red-500/10 rounded text-text-secondary hover:text-red-400 transition-colors disabled:opacity-50",title:"Remove LUN",children:e.jsx(es,{size:14})})]},B.id)):e.jsx("div",{className:"p-3 rounded bg-card-dark border border-border-dark text-center text-text-secondary text-sm",children:"No LUNs attached"})})]}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"text-xs font-bold text-text-secondary uppercase tracking-wider",children:"Access Control"}),e.jsx("button",{className:"text-primary text-xs font-bold hover:underline",onClick:B=>{B.stopPropagation(),u(!0)},children:"Edit Policy"}),e.jsxs("button",{onClick:B=>{B.stopPropagation(),confirm(`Delete target "${r.alias||r.iqn}"? This will remove the target from SCST and all associated LUNs and initiators. This action cannot be undone.`)&&v.mutate()},disabled:v.isPending,className:"px-3 py-1.5 text-xs bg-red-500/20 text-red-400 hover:bg-red-500/30 rounded border border-red-500/20 disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2",children:[e.jsx(es,{size:14}),"Delete Target"]})]}),e.jsx("div",{className:"flex flex-col gap-2 h-full",children:e.jsxs("div",{className:"p-3 rounded bg-card-dark border border-border-dark flex flex-col gap-2",children:[e.jsxs("div",{className:"flex justify-between items-center pb-2 border-b border-border-dark/50",children:[e.jsx("span",{className:"text-text-secondary text-xs",children:"Auth Method"}),e.jsx("span",{className:"text-white text-xs font-bold",children:"None"})]}),e.jsxs("div",{className:"flex justify-between items-center py-1",children:[e.jsx("span",{className:"text-text-secondary text-xs",children:"Initiator Group"}),d.length>0?e.jsx("div",{className:"flex flex-col items-end gap-1",children:d.map(B=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary text-xs font-bold",children:B.group_name}),e.jsxs("span",{className:"text-text-secondary text-xs",children:["(",B.initiators?.length||0," initiators)"]})]},B.id))}):e.jsx("span",{className:"text-text-secondary text-xs",children:"None"})]}),d.length>0&&e.jsx("div",{className:"pt-2 border-t border-border-dark/50",children:e.jsx("div",{className:"flex flex-col gap-1",children:d.flatMap(B=>(B.initiators||[]).map(g=>e.jsx("div",{className:"text-text-secondary text-xs font-mono",children:g.iqn},g.id)))})})]})})]}),e.jsx("div",{className:"col-span-1 lg:col-span-2 flex justify-end gap-2 mt-2 pt-3 border-t border-border-dark/50",children:e.jsx(ba,{to:`/iscsi/${r.id}`,className:"px-3 py-1.5 rounded text-xs font-bold bg-primary text-white hover:bg-blue-600 transition-colors",children:"View Details"})})]})}),c&&e.jsx(xS,{target:r,initiatorGroups:d,onClose:()=>u(!1),onSuccess:()=>{h.invalidateQueries({queryKey:["scst-target",r.id]}),u(!1)}})]})}function xS({target:r,initiatorGroups:t,onClose:s,onSuccess:n}){const[o,l]=Ce.useState(""),d=Nr(),c=ft({mutationFn:x=>br.addInitiator(r.id,{initiator_iqn:x}),onSuccess:()=>{d.invalidateQueries({queryKey:["scst-target",r.id]}),l(""),n()},onError:x=>{alert(`Failed to add initiator: ${x.response?.data?.error||x.message}`)}}),u=ft({mutationFn:x=>br.removeInitiator(x),onSuccess:()=>{d.invalidateQueries({queryKey:["scst-target",r.id]}),d.invalidateQueries({queryKey:["scst-initiators"]}),n()},onError:x=>{alert(`Failed to remove initiator: ${x.response?.data?.error||x.message}`)}}),h=x=>{if(x.preventDefault(),!o.trim()){alert("Please enter an initiator IQN");return}c.mutate(o.trim())},m=t.flatMap(x=>x.initiators||[]);return e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",onClick:s,children:e.jsxs("div",{className:"bg-card-dark border border-border-dark rounded-xl max-w-2xl w-full max-h-[90vh] overflow-y-auto",onClick:x=>x.stopPropagation(),children:[e.jsxs("div",{className:"p-6 border-b border-border-dark flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold text-white",children:"Edit Access Policy"}),e.jsxs("p",{className:"text-sm text-text-secondary mt-1",children:["Manage initiators for ",r.iqn]})]}),e.jsx("button",{onClick:s,className:"p-2 hover:bg-white/10 rounded-lg text-text-secondary hover:text-white transition-colors",children:e.jsx(Zs,{size:20})})]}),e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-bold text-white mb-3",children:"Add Initiator"}),e.jsxs("form",{onSubmit:h,className:"flex gap-2",children:[e.jsx("input",{type:"text",value:o,onChange:x=>l(x.target.value),placeholder:"iqn.2025-12.example:initiator",className:"flex-1 px-3 py-2 bg-[#0f161d] border border-border-dark rounded-lg text-white text-sm focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary",required:!0}),e.jsx(ct,{type:"submit",disabled:c.isPending,className:"px-4 bg-primary hover:bg-blue-600",children:c.isPending?"Adding...":"Add"})]})]}),e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-bold text-white mb-3",children:["Current Initiators (",m.length,")"]}),m.length>0?e.jsx("div",{className:"space-y-2",children:m.map(x=>e.jsxs("div",{className:"p-3 rounded bg-[#0f161d] border border-border-dark flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded bg-primary/10 text-primary",children:e.jsx(ya,{size:16})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-white text-sm font-mono",children:x.iqn}),e.jsx("div",{className:"text-text-secondary text-xs",children:x.is_active?"Active":"Inactive"})]})]}),e.jsx("button",{onClick:()=>{confirm(`Remove initiator ${x.iqn}?`)&&u.mutate(x.id)},disabled:u.isPending,className:"p-2 hover:bg-red-500/10 rounded-lg text-text-secondary hover:text-red-400 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:"Remove initiator",children:e.jsx(es,{size:16})})]},x.id))}):e.jsx("div",{className:"p-4 rounded bg-[#0f161d] border border-border-dark text-center text-text-secondary text-sm",children:"No initiators configured"})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-bold text-white mb-3",children:"Authentication Method"}),e.jsxs("div",{className:"p-3 rounded bg-[#0f161d] border border-border-dark",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-text-secondary text-sm",children:"Current Method"}),e.jsx("span",{className:"text-white text-sm font-bold",children:"None"})]}),e.jsx("p",{className:"text-text-secondary text-xs mt-2",children:"Authentication configuration coming soon"})]})]})]}),e.jsx("div",{className:"p-6 border-t border-border-dark flex justify-end gap-2",children:e.jsx(ct,{variant:"outline",onClick:s,className:"px-4",children:"Close"})})]})})}function gS({onClose:r,onSuccess:t}){const[s,n]=Ce.useState(""),[o,l]=Ce.useState(""),[d,c]=Ce.useState("disk"),[u,h]=Ce.useState(""),m=Nr(),x=ft({mutationFn:br.createTarget,onSuccess:async p=>{await m.invalidateQueries({queryKey:["scst-targets"]}),await m.refetchQueries({queryKey:["scst-targets"]}),p?.id&&await m.invalidateQueries({queryKey:["scst-target",p.id]}),t()},onError:p=>{console.error("Failed to create target:",p);const v=p.response?.data?.error||p.message||"Failed to create target";alert(v)}}),y=p=>{if(p.preventDefault(),!s.trim()||!o.trim()){alert("IQN and Name are required");return}const v={iqn:s.trim(),target_type:d,name:o.trim(),description:u.trim()||void 0};console.log("Creating target:",v),x.mutate(v)};return e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-card-dark border border-border-dark rounded-xl max-w-2xl w-full max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"p-6 border-b border-border-dark",children:[e.jsx("h2",{className:"text-xl font-bold text-white",children:"Create iSCSI Target"}),e.jsx("p",{className:"text-sm text-text-secondary mt-1",children:"Create a new SCST iSCSI target"})]}),e.jsxs("form",{onSubmit:y,className:"p-6 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"iqn",className:"block text-sm font-medium text-white mb-1",children:"IQN (iSCSI Qualified Name) *"}),e.jsx("input",{id:"iqn",type:"text",value:s,onChange:p=>n(p.target.value),placeholder:"iqn.2024-01.com.example:target1",className:"w-full px-3 py-2 bg-[#0f161d] border border-border-dark rounded-lg text-white text-sm focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary",required:!0}),e.jsx("p",{className:"mt-1 text-xs text-text-secondary",children:"Format: iqn.YYYY-MM.reverse.domain:identifier"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"name",className:"block text-sm font-medium text-white mb-1",children:"Name *"}),e.jsx("input",{id:"name",type:"text",value:o,onChange:p=>l(p.target.value),placeholder:"My Target",className:"w-full px-3 py-2 bg-[#0f161d] border border-border-dark rounded-lg text-white text-sm focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"targetType",className:"block text-sm font-medium text-white mb-1",children:"Target Type *"}),e.jsxs("select",{id:"targetType",value:d,onChange:p=>c(p.target.value),className:"w-full px-3 py-2 bg-[#0f161d] border border-border-dark rounded-lg text-white text-sm focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary",required:!0,children:[e.jsx("option",{value:"disk",children:"Disk"}),e.jsx("option",{value:"vtl",children:"Virtual Tape Library"}),e.jsx("option",{value:"physical_tape",children:"Physical Tape"})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"description",className:"block text-sm font-medium text-white mb-1",children:"Description (Optional)"}),e.jsx("textarea",{id:"description",value:u,onChange:p=>h(p.target.value),placeholder:"Target description",className:"w-full px-3 py-2 bg-[#0f161d] border border-border-dark rounded-lg text-white text-sm focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary",rows:3})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t border-border-dark",children:[e.jsx(ct,{type:"button",variant:"outline",onClick:r,children:"Cancel"}),e.jsx(ct,{type:"submit",disabled:x.isPending,children:x.isPending?"Creating...":"Create Target"})]})]})]})})}function bS(){const r=Nr(),[t,s]=Ce.useState(!1),[n,o]=Ce.useState(null),{data:l=[],isLoading:d}=dt({queryKey:["scst-portals"],queryFn:br.listPortals}),c=ft({mutationFn:br.deletePortal,onSuccess:()=>{r.invalidateQueries({queryKey:["scst-portals"]})},onError:h=>{alert(`Failed to delete portal: ${h.response?.data?.error||h.message}`)}}),u=h=>{confirm(`Delete portal ${h.ip_address}:${h.port}?`)&&c.mutate(h.id)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-white text-2xl font-bold",children:"iSCSI Portals"}),e.jsx("p",{className:"text-text-secondary text-sm mt-1",children:"Manage network portals for iSCSI connections"})]}),e.jsxs(ct,{onClick:()=>s(!0),className:"flex items-center gap-2 px-4 h-10 rounded-lg bg-primary hover:bg-blue-600 text-white text-sm font-bold",children:[e.jsx(Ks,{size:20}),e.jsx("span",{children:"Create Portal"})]})]}),d?e.jsx("div",{className:"p-8 text-center text-text-secondary",children:"Loading portals..."}):l.length>0?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:l.map(h=>e.jsxs("div",{className:"p-4 rounded-lg bg-card-dark border border-border-dark hover:border-primary/50 transition-colors",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ya,{size:20,className:"text-primary"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-white font-bold text-sm",children:h.ip_address}),e.jsxs("div",{className:"text-text-secondary text-xs",children:["Port: ",h.port]})]})]}),e.jsx("span",{className:`px-2 py-1 rounded text-xs font-bold ${h.is_active?"bg-green-500/20 text-green-400 border border-green-500/20":"bg-gray-500/20 text-gray-400 border border-gray-500/20"}`,children:h.is_active?"Active":"Inactive"})]}),e.jsxs("div",{className:"flex gap-2 mt-4",children:[e.jsx(ct,{variant:"outline",size:"sm",onClick:()=>o(h),className:"flex-1 text-xs",children:"Edit"}),e.jsx(ct,{variant:"outline",size:"sm",onClick:()=>u(h),disabled:c.isPending,className:"flex-1 text-xs text-red-400 hover:text-red-300 hover:bg-red-500/10",children:"Delete"})]})]},h.id))}):e.jsxs("div",{className:"p-12 text-center rounded-lg bg-card-dark border border-border-dark",children:[e.jsx(ya,{size:48,className:"mx-auto text-text-secondary mb-4"}),e.jsx("p",{className:"text-text-secondary",children:"No portals configured"}),e.jsx("p",{className:"text-text-secondary text-sm mt-1",children:"Create a portal to start accepting iSCSI connections"})]}),(t||n)&&e.jsx(yS,{portal:n,onClose:()=>{s(!1),o(null)},onSuccess:()=>{r.invalidateQueries({queryKey:["scst-portals"]}),s(!1),o(null)}})]})}function yS({portal:r,onClose:t,onSuccess:s}){const[n,o]=Ce.useState(r?.ip_address||"0.0.0.0"),[l,d]=Ce.useState(r?.port||3260),[c,u]=Ce.useState(r?.is_active??!0),h=Nr(),m=ft({mutationFn:v=>br.createPortal(v),onSuccess:()=>{h.invalidateQueries({queryKey:["scst-portals"]}),s()},onError:v=>{alert(`Failed to create portal: ${v.response?.data?.error||v.message}`)}}),x=ft({mutationFn:v=>br.updatePortal(r.id,v),onSuccess:()=>{h.invalidateQueries({queryKey:["scst-portals"]}),s()},onError:v=>{alert(`Failed to update portal: ${v.response?.data?.error||v.message}`)}}),y=v=>{v.preventDefault();const N={ip_address:n.trim(),port:parseInt(l.toString()),is_active:c};r?x.mutate(N):m.mutate(N)},p=m.isPending||x.isPending;return e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",onClick:t,children:e.jsxs("div",{className:"bg-card-dark border border-border-dark rounded-xl max-w-md w-full",onClick:v=>v.stopPropagation(),children:[e.jsxs("div",{className:"p-6 border-b border-border-dark flex items-center justify-between",children:[e.jsx("h2",{className:"text-xl font-bold text-white",children:r?"Edit Portal":"Create Portal"}),e.jsx("button",{onClick:t,className:"p-2 hover:bg-white/10 rounded-lg text-text-secondary hover:text-white transition-colors",children:e.jsx(Zs,{size:20})})]}),e.jsxs("form",{onSubmit:y,className:"p-6 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"ipAddress",className:"block text-sm font-medium text-white mb-1",children:"IP Address *"}),e.jsx("input",{id:"ipAddress",type:"text",value:n,onChange:v=>o(v.target.value),placeholder:"0.0.0.0 (all interfaces) or specific IP",className:"w-full px-3 py-2 bg-[#0f161d] border border-border-dark rounded-lg text-white text-sm focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary",required:!0}),e.jsx("p",{className:"mt-1 text-xs text-text-secondary",children:"Use 0.0.0.0 to listen on all interfaces, or specify an IP address"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"port",className:"block text-sm font-medium text-white mb-1",children:"Port *"}),e.jsx("input",{id:"port",type:"number",value:l,onChange:v=>d(parseInt(v.target.value)||3260),min:"1",max:"65535",className:"w-full px-3 py-2 bg-[#0f161d] border border-border-dark rounded-lg text-white text-sm focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary",required:!0}),e.jsx("p",{className:"mt-1 text-xs text-text-secondary",children:"Default iSCSI port is 3260"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{id:"isActive",type:"checkbox",checked:c,onChange:v=>u(v.target.checked),className:"w-4 h-4 rounded bg-[#0f161d] border-border-dark text-primary focus:ring-primary"}),e.jsx("label",{htmlFor:"isActive",className:"text-sm text-white",children:"Active"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t border-border-dark",children:[e.jsx(ct,{type:"button",variant:"outline",onClick:t,disabled:p,children:"Cancel"}),e.jsx(ct,{type:"submit",disabled:p,children:p?r?"Updating...":"Creating...":r?"Update":"Create"})]})]})]})})}function wS(){const r=Nr(),[t,s]=Ce.useState(""),[n,o]=Ce.useState("all"),{data:l=[],isLoading:d}=dt({queryKey:["scst-initiators"],queryFn:br.listInitiators}),c=ft({mutationFn:br.removeInitiator,onSuccess:()=>{r.invalidateQueries({queryKey:["scst-initiators"]}),r.invalidateQueries({queryKey:["scst-targets"]})},onError:m=>{alert(`Failed to remove initiator: ${m.response?.data?.error||m.message}`)}}),u=l.filter(m=>{const x=m.iqn.toLowerCase().includes(t.toLowerCase())||m.target_iqn&&m.target_iqn.toLowerCase().includes(t.toLowerCase())||m.target_name&&m.target_name.toLowerCase().includes(t.toLowerCase()),y=n==="all"||n==="active"&&m.is_active||n==="inactive"&&!m.is_active;return x&&y}),h=m=>{confirm(`Remove initiator ${m.iqn}?`)&&c.mutate(m.id)};return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-white text-2xl font-bold",children:"iSCSI Initiators"}),e.jsx("p",{className:"text-text-secondary text-sm mt-1",children:"Manage initiator access control lists"})]})}),e.jsxs("div",{className:"p-4 flex items-center justify-between gap-4 border-b border-border-dark/50 bg-[#141d26]",children:[e.jsxs("div",{className:"relative flex-1 max-w-md",children:[e.jsx(io,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-text-secondary",size:20}),e.jsx("input",{type:"text",placeholder:"Search initiators by IQN or target...",value:t,onChange:m=>s(m.target.value),className:"w-full bg-[#0f161d] border border-border-dark rounded-lg pl-10 pr-4 py-2 text-sm text-white focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary transition-all placeholder-text-secondary/50"})]}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-md bg-[#0f161d] border border-border-dark",children:[e.jsx("span",{className:"text-xs text-text-secondary font-medium",children:"Filter:"}),e.jsxs("select",{value:n,onChange:m=>o(m.target.value),className:"bg-[#0f161d] text-xs text-white font-medium focus:outline-none cursor-pointer border-none appearance-none pr-6",style:{backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23999' d='M6 9L1 4h10z'/%3E%3C/svg%3E")`,backgroundRepeat:"no-repeat",backgroundPosition:"right 0 center",paddingRight:"24px"},children:[e.jsx("option",{value:"all",className:"bg-[#0f161d] text-white",children:"All Status"}),e.jsx("option",{value:"active",className:"bg-[#0f161d] text-white",children:"Active"}),e.jsx("option",{value:"inactive",className:"bg-[#0f161d] text-white",children:"Inactive"})]})]})})]}),d?e.jsx("div",{className:"p-8 text-center text-text-secondary",children:"Loading initiators..."}):u.length>0?e.jsx("div",{className:"bg-[#141d26] border border-border-dark rounded-lg overflow-hidden",children:e.jsx("div",{className:"divide-y divide-border-dark",children:u.map(m=>e.jsxs("div",{className:"p-4 hover:bg-white/5 transition-colors flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-4",children:[e.jsx("div",{className:"p-2 rounded-md bg-primary/10 text-primary",children:e.jsx(ya,{size:20})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[e.jsx("span",{className:"text-white font-mono text-sm font-medium truncate",children:m.iqn}),e.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-bold uppercase tracking-wide border ${m.is_active?"bg-green-500/20 text-green-400 border-green-500/20":"bg-red-500/20 text-red-400 border-red-500/20"}`,children:m.is_active?"Active":"Inactive"})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-text-secondary flex-wrap mt-1",children:[m.target_iqn&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"font-semibold text-text-secondary/80",children:"Target:"}),e.jsx("span",{className:"font-mono text-white/90 truncate max-w-[300px]",title:m.target_iqn,children:m.target_name||m.target_iqn.split(":").pop()})]}),m.group_name&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"font-semibold text-text-secondary/80",children:"Group:"}),e.jsx("span",{className:"font-mono text-white/90 truncate max-w-[300px]",title:m.group_name,children:m.group_name})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{navigator.clipboard.writeText(m.iqn)},className:"p-2 hover:bg-white/10 rounded-lg text-text-secondary hover:text-white transition-colors",title:"Copy IQN",children:e.jsx(so,{size:16})}),e.jsx("button",{onClick:()=>h(m),disabled:c.isPending,className:"p-2 hover:bg-red-500/10 rounded-lg text-text-secondary hover:text-red-400 transition-colors",title:"Remove initiator",children:e.jsx(es,{size:16})})]})]},m.id))})}):e.jsxs("div",{className:"p-12 text-center",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-border-dark/50 mb-4",children:e.jsx(ya,{className:"text-text-secondary",size:32})}),e.jsx("p",{className:"text-white font-medium mb-1",children:"No initiators found"}),e.jsx("p",{className:"text-text-secondary text-sm",children:t||n!=="all"?"Try adjusting your search or filter criteria":"Initiators will appear here once they are added to targets"})]})]})}function vS(){const r=Nr(),[t,s]=Ce.useState(""),[n,o]=Ce.useState(!1),[l,d]=Ce.useState([]),{data:c=[],isLoading:u}=dt({queryKey:["scst-extents"],queryFn:()=>br.listExtents(),refetchInterval:3e3,refetchIntervalInBackground:!0,refetchOnWindowFocus:!0,refetchOnMount:!0,refetchOnReconnect:!0,staleTime:0,gcTime:0,structuralSharing:!1}),{data:h}=dt({queryKey:["scst-handlers"],queryFn:br.listHandlers});Ce.useEffect(()=>{h&&d(h.map(p=>({name:p.name,label:p.label,description:p.description})))},[h]);const m=ft({mutationFn:br.deleteExtent,onMutate:async p=>{await r.cancelQueries({queryKey:["scst-extents"]}),await r.cancelQueries({queryKey:["scst-targets"]});const v=r.getQueryData(["scst-extents"]);return r.setQueryData(["scst-extents"],N=>N?N.filter(B=>B.device_name!==p):[]),{previousExtents:v}},onSuccess:async()=>{r.removeQueries({queryKey:["scst-extents"]}),r.removeQueries({queryKey:["scst-targets"]}),await r.invalidateQueries({queryKey:["scst-extents"]}),await r.invalidateQueries({queryKey:["scst-targets"]}),await r.refetchQueries({queryKey:["scst-extents"],type:"all"}),await r.refetchQueries({queryKey:["scst-targets"],type:"all"})},onError:(p,v,N)=>{N?.previousExtents&&r.setQueryData(["scst-extents"],N.previousExtents),r.refetchQueries({queryKey:["scst-extents"]}),alert(`Failed to delete extent: ${p.response?.data?.error||p.message}`)}}),x=c.filter(p=>p.device_name.toLowerCase().includes(t.toLowerCase())||p.device_path.toLowerCase().includes(t.toLowerCase())||p.handler_type.toLowerCase().includes(t.toLowerCase())),y=p=>{if(p.is_in_use){alert(`Cannot delete extent ${p.device_name}: it is in use by ${p.lun_count} LUN(s)`);return}confirm(`Delete extent ${p.device_name}?`)&&m.mutate(p.device_name)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-white text-2xl font-bold",children:"iSCSI Extents"}),e.jsx("p",{className:"text-text-secondary text-sm mt-1",children:"Manage device extents (opened devices) for iSCSI LUNs"})]}),e.jsxs(ct,{onClick:()=>o(!0),className:"flex items-center gap-2 px-4 h-10 rounded-lg bg-primary hover:bg-blue-600 text-white text-sm font-bold",children:[e.jsx(Ks,{size:20}),e.jsx("span",{children:"Create Extent"})]})]}),e.jsx("div",{className:"p-4 flex items-center justify-between gap-4 border-b border-border-dark/50 bg-[#141d26]",children:e.jsxs("div",{className:"relative flex-1 max-w-md",children:[e.jsx(io,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-text-secondary",size:20}),e.jsx("input",{type:"text",placeholder:"Search extents by device name, path, or handler...",value:t,onChange:p=>s(p.target.value),className:"w-full bg-[#0f161d] border border-border-dark rounded-lg pl-10 pr-4 py-2 text-sm text-white focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary transition-all placeholder-text-secondary/50"})]})}),u?e.jsx("div",{className:"p-8 text-center text-text-secondary",children:"Loading extents..."}):x.length>0?e.jsx("div",{className:"bg-[#141d26] border border-border-dark rounded-lg overflow-hidden",children:e.jsx("div",{className:"divide-y divide-border-dark",children:x.map((p,v)=>e.jsxs("div",{className:"p-4 hover:bg-white/5 transition-colors flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-4",children:[e.jsx("div",{className:`p-2 rounded-md ${p.is_in_use?"bg-yellow-500/10 text-yellow-400":"bg-primary/10 text-primary"}`,children:e.jsx(Ul,{size:20})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[e.jsx("span",{className:"text-white font-mono text-sm font-medium",children:p.device_name}),p.is_in_use&&e.jsxs("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-bold uppercase tracking-wide border bg-yellow-500/20 text-yellow-400 border-yellow-500/20",children:["In Use (",p.lun_count," LUN",p.lun_count!==1?"s":"",")"]})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-text-secondary",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"font-medium",children:"Handler:"}),e.jsx("span",{className:"truncate",children:p.handler_type})]}),p.device_path&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"font-medium",children:"Path:"}),e.jsx("span",{className:"font-mono truncate max-w-[400px]",children:p.device_path})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{p.device_path&&navigator.clipboard.writeText(p.device_path)},className:"p-2 hover:bg-white/10 rounded-lg text-text-secondary hover:text-white transition-colors",title:"Copy device path",children:e.jsx(so,{size:16})}),e.jsx("button",{onClick:()=>y(p),disabled:m.isPending||p.is_in_use,className:"p-2 hover:bg-red-500/10 rounded-lg text-text-secondary hover:text-red-400 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:p.is_in_use?"Cannot delete: extent is in use":"Delete extent",children:e.jsx(es,{size:16})})]})]},`${p.handler_type}-${p.device_name}-${v}`))})}):e.jsxs("div",{className:"p-12 text-center",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-border-dark/50 mb-4",children:e.jsx(Ul,{className:"text-text-secondary",size:32})}),e.jsx("p",{className:"text-white font-medium mb-1",children:"No extents found"}),e.jsx("p",{className:"text-text-secondary text-sm",children:t?"Try adjusting your search criteria":"Create an extent to make a device available for iSCSI LUNs"})]}),n&&e.jsx(NS,{handlers:l,onClose:()=>o(!1),onSuccess:async()=>{o(!1),r.removeQueries({queryKey:["scst-extents"]}),await r.invalidateQueries({queryKey:["scst-extents"]}),await r.refetchQueries({queryKey:["scst-extents"],type:"active"})}})]})}function NS({handlers:r,onClose:t,onSuccess:s}){const[n,o]=Ce.useState(""),[l,d]=Ce.useState(""),[c,u]=Ce.useState(""),h=ft({mutationFn:y=>br.createExtent(y),onSuccess:async()=>{await s(),alert("Extent created successfully!")},onError:y=>{alert(`Failed to create extent: ${y.response?.data?.error||y.message}`)}}),m=y=>{if(y.preventDefault(),!n||!l||!c){alert("Please fill in all required fields");return}h.mutate({device_name:n,device_path:l,handler_type:c})},x=y=>{if(d(y),!n&&y){const p=y.split("/"),v=p[p.length-1];v&&o(v)}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-[#141d26] border border-border-dark rounded-lg p-6 w-full max-w-md",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-white text-lg font-bold",children:"Create Extent"}),e.jsx("button",{onClick:t,className:"text-text-secondary hover:text-white transition-colors",children:e.jsx(Zs,{size:20})})]}),e.jsxs("form",{onSubmit:m,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"handlerType",className:"block text-sm font-medium text-white mb-1",children:"Handler Type *"}),e.jsxs("select",{id:"handlerType",value:c,onChange:y=>u(y.target.value),className:"w-full px-3 py-2 bg-[#0f161d] border border-border-dark rounded-lg text-white text-sm focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary",required:!0,children:[e.jsx("option",{value:"",children:"Select handler..."}),r.map(y=>e.jsxs("option",{value:y.name,className:"bg-[#0f161d] text-white",children:[y.label||y.name," - ",y.description]},y.name))]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"devicePath",className:"block text-sm font-medium text-white mb-1",children:"Device Path *"}),e.jsx("input",{id:"devicePath",type:"text",value:l,onChange:y=>x(y.target.value),placeholder:"/dev/zvol/pool/volume or /path/to/file",className:"w-full px-3 py-2 bg-[#0f161d] border border-border-dark rounded-lg text-white text-sm focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary",required:!0}),e.jsx("p",{className:"mt-1 text-xs text-text-secondary",children:"Full path to the device or file"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"deviceName",className:"block text-sm font-medium text-white mb-1",children:"Device Name *"}),e.jsx("input",{id:"deviceName",type:"text",value:n,onChange:y=>o(y.target.value),placeholder:"LUN01",className:"w-full px-3 py-2 bg-[#0f161d] border border-border-dark rounded-lg text-white text-sm focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary",required:!0}),e.jsx("p",{className:"mt-1 text-xs text-text-secondary",children:"Unique name for this device in SCST"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t border-border-dark",children:[e.jsx(ct,{type:"button",variant:"outline",onClick:t,disabled:h.isPending,children:"Cancel"}),e.jsx(ct,{type:"submit",disabled:h.isPending,children:h.isPending?"Creating...":"Create Extent"})]})]})]})})}function BS(){const r=Nr(),[t,s]=Ce.useState(""),[n,o]=Ce.useState(!1),[l,d]=Ce.useState(null),[c,u]=Ce.useState(null),[h,m]=Ce.useState(null),{data:x=[],isLoading:y}=dt({queryKey:["scst-initiator-groups"],queryFn:br.listInitiatorGroups,refetchInterval:3e3,refetchIntervalInBackground:!0,refetchOnWindowFocus:!0,refetchOnMount:!0,refetchOnReconnect:!0,staleTime:0,gcTime:0,structuralSharing:!1}),{data:p=[]}=dt({queryKey:["scst-targets"],queryFn:br.listTargets}),v=ft({mutationFn:L=>br.createInitiatorGroup(L),onSuccess:()=>{r.invalidateQueries({queryKey:["scst-initiator-groups"]}),r.invalidateQueries({queryKey:["scst-targets"]}),o(!1)},onError:L=>{alert(`Failed to create group: ${L.response?.data?.error||L.message}`)}}),N=ft({mutationFn:({id:L,data:K})=>br.updateInitiatorGroup(L,K),onSuccess:()=>{r.invalidateQueries({queryKey:["scst-initiator-groups"]}),r.invalidateQueries({queryKey:["scst-targets"]}),d(null)},onError:L=>{alert(`Failed to update group: ${L.response?.data?.error||L.message}`)}}),B=ft({mutationFn:L=>br.deleteInitiatorGroup(L),onSuccess:()=>{r.invalidateQueries({queryKey:["scst-initiator-groups"]}),r.invalidateQueries({queryKey:["scst-targets"]})},onError:L=>{alert(`Failed to delete group: ${L.response?.data?.error||L.message}`)}}),g=ft({mutationFn:({groupId:L,initiatorIQN:K})=>br.addInitiatorToGroup(L,K),onSuccess:()=>{r.invalidateQueries({queryKey:["scst-initiator-groups"]}),r.invalidateQueries({queryKey:["scst-targets"]}),r.invalidateQueries({queryKey:["scst-initiators"]}),m(null)},onError:L=>{alert(`Failed to add initiator: ${L.response?.data?.error||L.message}`)}}),j=ft({mutationFn:L=>br.removeInitiator(L),onSuccess:()=>{r.invalidateQueries({queryKey:["scst-initiator-groups"]}),r.invalidateQueries({queryKey:["scst-targets"]}),r.invalidateQueries({queryKey:["scst-initiators"]})},onError:L=>{alert(`Failed to remove initiator: ${L.response?.data?.error||L.message}`)}}),_=x.filter(L=>{const K=p.find(V=>V.id===L.target_id);return L.group_name.toLowerCase().includes(t.toLowerCase())||K&&((K.alias||K.iqn).toLowerCase().includes(t.toLowerCase())||K.iqn.toLowerCase().includes(t.toLowerCase()))}),w=L=>{if(L.initiators&&L.initiators.length>0){alert(`Cannot delete group: Group contains ${L.initiators.length} initiator(s). Please remove all initiators first.`);return}confirm(`Delete initiator group "${L.group_name}"?`)&&B.mutate(L.id)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-white text-2xl font-bold",children:"iSCSI Initiator Groups"}),e.jsx("p",{className:"text-text-secondary text-sm mt-1",children:"Manage initiator access control groups"})]}),e.jsxs(ct,{onClick:()=>o(!0),children:[e.jsx(Ks,{size:16,className:"mr-2"}),"Create Group"]})]}),e.jsx("div",{className:"p-4 flex items-center justify-between gap-4 border-b border-border-dark/50 bg-[#141d26]",children:e.jsxs("div",{className:"relative flex-1 max-w-md",children:[e.jsx(io,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-text-secondary",size:20}),e.jsx("input",{type:"text",placeholder:"Search groups by name or target...",value:t,onChange:L=>s(L.target.value),className:"w-full bg-[#0f161d] border border-border-dark rounded-lg pl-10 pr-4 py-2 text-sm text-white focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary transition-all placeholder-text-secondary/50"})]})}),y?e.jsx("div",{className:"p-8 text-center text-text-secondary",children:"Loading groups..."}):_.length>0?e.jsx("div",{className:"bg-[#141d26] border border-border-dark rounded-lg overflow-hidden",children:e.jsx("div",{className:"divide-y divide-border-dark",children:_.map(L=>{const K=p.find(V=>V.id===L.target_id),M=c===L.id;return e.jsxs("div",{className:"border-b border-border-dark last:border-b-0",children:[e.jsx("div",{className:"p-4 hover:bg-white/5 transition-colors",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("button",{onClick:()=>u(M?null:L.id),className:"p-2 rounded-md bg-primary/10 text-primary hover:bg-primary/20 transition-colors",children:M?e.jsx(wh,{size:20}):e.jsx(Ka,{size:20})}),e.jsx("div",{className:"p-2 rounded-md bg-primary/10 text-primary",children:e.jsx(ya,{size:20})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-3 mb-1",children:e.jsx("span",{className:"text-white font-mono text-sm font-medium",children:L.group_name})}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-text-secondary",children:[K&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"font-medium",children:"Target:"}),e.jsx("span",{className:"font-mono truncate max-w-[300px]",title:K.iqn,children:K.alias||K.iqn.split(":").pop()})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"font-medium",children:"Initiators:"}),e.jsx("span",{className:"text-white/90",children:L.initiators?.length||0})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"font-medium",children:"Created:"}),e.jsx("span",{children:new Date(L.created_at).toLocaleDateString()})]})]})]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>d(L),className:"p-2 hover:bg-white/10 rounded-lg text-text-secondary hover:text-white transition-colors",title:"Edit group name",children:e.jsx(vc,{size:16})}),e.jsx("button",{onClick:()=>w(L),disabled:B.isPending,className:"p-2 hover:bg-red-500/10 rounded-lg text-text-secondary hover:text-red-400 transition-colors disabled:opacity-50",title:"Delete group",children:e.jsx(es,{size:16})})]})]})}),M&&e.jsxs("div",{className:"px-4 pb-4 bg-[#0f161d] border-t border-border-dark",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3 mt-3",children:[e.jsx("h4",{className:"text-white text-sm font-semibold",children:"Group Members"}),e.jsxs(ct,{size:"sm",onClick:()=>m(L.id),variant:"outline",children:[e.jsx(Ks,{size:14,className:"mr-1"}),"Add Initiator"]})]}),L.initiators&&L.initiators.length>0?e.jsx("div",{className:"space-y-2",children:L.initiators.map(V=>e.jsxs("div",{className:"flex items-center justify-between p-3 bg-[#141d26] border border-border-dark rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"p-1.5 rounded bg-primary/10 text-primary",children:e.jsx(ya,{size:14})}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-white font-mono text-xs truncate",children:V.iqn}),e.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-bold uppercase ${V.is_active?"bg-green-500/20 text-green-400":"bg-red-500/20 text-red-400"}`,children:V.is_active?"Active":"Inactive"})]})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{navigator.clipboard.writeText(V.iqn)},className:"p-1.5 hover:bg-white/10 rounded text-text-secondary hover:text-white transition-colors",title:"Copy IQN",children:e.jsx(so,{size:14})}),e.jsx("button",{onClick:()=>{confirm(`Remove initiator "${V.iqn}" from this group?`)&&j.mutate(V.id)},disabled:j.isPending,className:"p-1.5 hover:bg-red-500/10 rounded text-text-secondary hover:text-red-400 transition-colors disabled:opacity-50",title:"Remove initiator",children:e.jsx(es,{size:14})})]})]},V.id))}):e.jsxs("div",{className:"p-6 text-center border border-border-dark rounded-lg bg-[#141d26]",children:[e.jsx("p",{className:"text-text-secondary text-sm mb-2",children:"No initiators in this group"}),e.jsxs(ct,{size:"sm",onClick:()=>m(L.id),variant:"outline",children:[e.jsx(Ks,{size:14,className:"mr-1"}),"Add First Initiator"]})]})]})]},L.id)})})}):e.jsxs("div",{className:"p-12 text-center",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-border-dark/50 mb-4",children:e.jsx(ya,{className:"text-text-secondary",size:32})}),e.jsx("p",{className:"text-white font-medium mb-1",children:"No groups found"}),e.jsx("p",{className:"text-text-secondary text-sm",children:t?"Try adjusting your search criteria":"Create an initiator group to organize initiators by access control"})]}),n&&e.jsx(jS,{targets:p,onClose:()=>o(!1),isLoading:v.isPending,onSubmit:L=>v.mutate(L)}),l&&e.jsx(CS,{group:l,onClose:()=>d(null),isLoading:N.isPending,onSubmit:L=>N.mutate({id:l.id,data:L})}),h&&e.jsx(SS,{groupName:x.find(L=>L.id===h)?.group_name||"",onClose:()=>m(null),isLoading:g.isPending,onSubmit:L=>g.mutate({groupId:h,initiatorIQN:L})})]})}function jS({targets:r,onClose:t,isLoading:s,onSubmit:n}){const[o,l]=Ce.useState(""),[d,c]=Ce.useState(""),u=h=>{if(h.preventDefault(),!o||!d.trim()){alert("Please fill in all required fields");return}n({target_id:o,group_name:d.trim()})};return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-[#141d26] border border-border-dark rounded-lg p-6 w-full max-w-md",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h3",{className:"text-white text-lg font-bold",children:"Create Initiator Group"}),e.jsx("button",{onClick:t,className:"text-text-secondary hover:text-white",children:e.jsx(Zs,{size:20})})]}),e.jsxs("form",{onSubmit:u,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-text-secondary mb-2",children:"Target *"}),e.jsxs("select",{value:o,onChange:h=>l(h.target.value),className:"w-full px-3 py-2 bg-[#0f161d] border border-border-dark rounded-lg text-white text-sm focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary",required:!0,children:[e.jsx("option",{value:"",children:"Select a target"}),r.map(h=>e.jsxs("option",{value:h.id,className:"bg-[#0f161d] text-white",children:[h.alias||h.iqn.split(":").pop()," (",h.iqn,")"]},h.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-text-secondary mb-2",children:"Group Name *"}),e.jsx("input",{type:"text",value:d,onChange:h=>c(h.target.value),placeholder:"my-acl-group",className:"w-full px-3 py-2 bg-[#0f161d] border border-border-dark rounded-lg text-white text-sm focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary",required:!0}),e.jsx("p",{className:"text-xs text-text-secondary mt-1",children:"Group name will be used as ACL group name in SCST"})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-3 mt-6",children:[e.jsx(ct,{type:"button",variant:"outline",onClick:t,disabled:s,children:"Cancel"}),e.jsx(ct,{type:"submit",disabled:s,children:s?"Creating...":"Create"})]})]})]})})}function CS({group:r,onClose:t,isLoading:s,onSubmit:n}){const[o,l]=Ce.useState(r.group_name),d=c=>{if(c.preventDefault(),!o.trim()){alert("Group name cannot be empty");return}n({group_name:o.trim()})};return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-[#141d26] border border-border-dark rounded-lg p-6 w-full max-w-md",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h3",{className:"text-white text-lg font-bold",children:"Edit Initiator Group"}),e.jsx("button",{onClick:t,className:"text-text-secondary hover:text-white",children:e.jsx(Zs,{size:20})})]}),e.jsxs("form",{onSubmit:d,children:[e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-text-secondary mb-2",children:"Group Name *"}),e.jsx("input",{type:"text",value:o,onChange:c=>l(c.target.value),placeholder:"my-acl-group",className:"w-full px-3 py-2 bg-[#0f161d] border border-border-dark rounded-lg text-white text-sm focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary",required:!0}),e.jsx("p",{className:"text-xs text-text-secondary mt-1",children:"Changing the group name will recreate it in SCST"})]})}),e.jsxs("div",{className:"flex items-center justify-end gap-3 mt-6",children:[e.jsx(ct,{type:"button",variant:"outline",onClick:t,disabled:s,children:"Cancel"}),e.jsx(ct,{type:"submit",disabled:s,children:s?"Updating...":"Update"})]})]})]})})}function SS({groupName:r,onClose:t,isLoading:s,onSubmit:n}){const[o,l]=Ce.useState(""),d=c=>{if(c.preventDefault(),!o.trim()){alert("Please enter an initiator IQN");return}if(!o.trim().toLowerCase().startsWith("iqn.")){alert('Invalid IQN format. IQN must start with "iqn."');return}n(o.trim())};return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-[#141d26] border border-border-dark rounded-lg p-6 w-full max-w-md",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h3",{className:"text-white text-lg font-bold",children:"Add Initiator to Group"}),e.jsx("button",{onClick:t,className:"text-text-secondary hover:text-white",children:e.jsx(Zs,{size:20})})]}),e.jsxs("form",{onSubmit:d,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-text-secondary mb-2",children:"Group"}),e.jsx("input",{type:"text",value:r,disabled:!0,className:"w-full px-3 py-2 bg-[#0f161d] border border-border-dark rounded-lg text-white/60 text-sm cursor-not-allowed"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-text-secondary mb-2",children:"Initiator IQN *"}),e.jsx("input",{type:"text",value:o,onChange:c=>l(c.target.value),placeholder:"iqn.1993-08.org.debian:01:example",className:"w-full px-3 py-2 bg-[#0f161d] border border-border-dark rounded-lg text-white text-sm focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary font-mono",required:!0}),e.jsx("p",{className:"text-xs text-text-secondary mt-1",children:"Enter the IQN of the initiator to add to this group"})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-3 mt-6",children:[e.jsx(ct,{type:"button",variant:"outline",onClick:t,disabled:s,children:"Cancel"}),e.jsx(ct,{type:"submit",disabled:s,children:s?"Adding...":"Add Initiator"})]})]})]})})}function _S(){const[r,t]=Ce.useState(""),[s,n]=Ce.useState(!0),[o,l]=Ce.useState(!1),[d,c]=Ce.useState(""),[u,h]=Ce.useState("/etc/scst.conf"),m=Ce.useRef(null),{data:x,refetch:y,isFetching:p}=dt({queryKey:["scst-config-file"],queryFn:()=>br.getConfigFile()});Ce.useEffect(()=>{x&&(t(x.content),c(x.content),h(x.path),l(!1),n(!1))},[x]),Ce.useEffect(()=>{p?n(!0):x&&n(!1)},[p,x]);const v=ft({mutationFn:j=>br.updateConfigFile(j),onSuccess:()=>{c(r),l(!1),alert("Configuration file saved successfully!")},onError:j=>{alert(`Failed to save configuration: ${j.response?.data?.error||j.message}`)}}),N=j=>{t(j.target.value),l(j.target.value!==d)},B=()=>{o&&confirm("Save changes to scst.conf? This will update the SCST configuration.")&&v.mutate(r)},g=()=>{o&&!confirm("You have unsaved changes. Reload anyway?")||(n(!0),y())};return Ce.useEffect(()=>{m.current&&m.current.focus()},[]),e.jsxs("div",{className:"flex flex-col h-full min-h-[600px] bg-[#0a0f14] border border-border-dark rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"flex-none px-6 py-4 border-b border-border-dark bg-[#141d26] flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Uh,{className:"text-primary",size:20}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-white font-bold text-sm",children:"SCST Configuration Editor"}),e.jsx("p",{className:"text-text-secondary text-xs mt-0.5",children:"Edit /etc/scst.conf file directly"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(ct,{variant:"outline",size:"sm",onClick:g,disabled:s,className:"flex items-center gap-2",children:[e.jsx(Cn,{size:16,className:s?"animate-spin":""}),e.jsx("span",{children:"Reload"})]}),e.jsxs(ct,{size:"sm",onClick:B,disabled:!o||v.isPending,className:"flex items-center gap-2 bg-primary hover:bg-blue-600",children:[e.jsx(up,{size:16}),e.jsx("span",{children:v.isPending?"Saving...":"Save"})]})]})]}),e.jsx("div",{className:"flex-1 relative overflow-hidden",children:s?e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsxs("div",{className:"text-text-secondary",children:[e.jsx(Cn,{size:24,className:"animate-spin mx-auto mb-2"}),e.jsx("p",{children:"Loading configuration..."})]})}):e.jsx("textarea",{ref:m,value:r,onChange:N,className:"w-full h-full p-4 bg-[#0a0f14] text-green-400 font-mono text-sm resize-none focus:outline-none focus:ring-0 border-0",style:{fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace',lineHeight:"1.6",tabSize:2},spellCheck:!1,placeholder:"Loading configuration file..."})}),e.jsxs("div",{className:"flex-none px-6 py-3 border-t border-border-dark bg-[#141d26] flex items-center justify-between text-xs",children:[e.jsxs("div",{className:"flex items-center gap-4 text-text-secondary",children:[e.jsxs("span",{children:["Path: ",u]}),o&&e.jsxs("span",{className:"text-yellow-400 flex items-center gap-1",children:[e.jsx("span",{className:"w-2 h-2 bg-yellow-400 rounded-full"}),"Unsaved changes"]})]}),e.jsxs("div",{className:"text-text-secondary",children:[r.split(` `).length," lines"]})]})]})}function kS(){const{id:r}=jy(),t=Ph(),s=Nr(),[n,o]=Ce.useState(!1),[l,d]=Ce.useState(!1);Ce.useEffect(()=>{console.log("showAddLUN state:",n)},[n]);const{data:c,isLoading:u}=dt({queryKey:["scst-target",r],queryFn:()=>br.getTarget(r),enabled:!!r}),h=ft({mutationFn:({targetId:p,lunId:v})=>br.removeLUN(p,v),onMutate:async({lunId:p})=>{await s.cancelQueries({queryKey:["scst-target",r]}),await s.cancelQueries({queryKey:["scst-targets"]});const v=s.getQueryData(["scst-target",r]),N=s.getQueryData(["scst-targets"]);return s.setQueryData(["scst-target",r],B=>B&&{...B,luns:B.luns?B.luns.filter(g=>g.id!==p):[]}),s.setQueryData(["scst-targets"],B=>B&&B.map(g=>g.id===r?{...g,lun_count:Math.max(0,(g.lun_count||0)-1)}:g)),{previousTarget:v,previousTargets:N}},onSuccess:()=>{s.invalidateQueries({queryKey:["scst-target",r]}),s.invalidateQueries({queryKey:["scst-targets"]})},onError:(p,v,N)=>{if(p.response?.status===404){s.invalidateQueries({queryKey:["scst-target",r]}),s.invalidateQueries({queryKey:["scst-targets"]});return}N?.previousTarget&&s.setQueryData(["scst-target",r],N.previousTarget),N?.previousTargets&&s.setQueryData(["scst-targets"],N.previousTargets),alert(`Failed to remove LUN: ${p.response?.data?.error||p.message}`)}});if(u)return e.jsx("div",{className:"text-sm text-text-secondary min-h-screen bg-background-dark p-6",children:"Loading target details..."});if(!c)return e.jsx("div",{className:"text-sm text-red-400 min-h-screen bg-background-dark p-6",children:"Target not found"});const{target:m,luns:x}=c,y=x||[];return e.jsxs("div",{className:"space-y-6 min-h-screen bg-background-dark p-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsxs(ct,{variant:"ghost",size:"sm",onClick:()=>t("/iscsi"),children:[e.jsx(wc,{className:"h-4 w-4 mr-2"}),"Back"]}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-white font-mono text-lg",children:m.iqn}),m.alias&&e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:m.alias})]})]}),e.jsxs(ct,{variant:"outline",onClick:()=>{s.invalidateQueries({queryKey:["scst-target",r]})},children:[e.jsx(Cn,{className:"h-4 w-4 mr-2"}),"Refresh"]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[e.jsxs(bi,{children:[e.jsx(yi,{children:e.jsx(wi,{className:"text-sm font-medium",children:"Target Status"})}),e.jsx(vi,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-text-secondary",children:"Status:"}),e.jsx("span",{className:m.is_active?"text-green-400":"text-text-secondary",children:m.is_active?"Active":"Inactive"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-text-secondary",children:"IQN:"}),e.jsx("span",{className:"font-mono text-xs text-white",children:m.iqn})]})]})})]}),e.jsxs(bi,{children:[e.jsx(yi,{children:e.jsx(wi,{className:"text-sm font-medium",children:"LUNs"})}),e.jsx(vi,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-text-secondary",children:"Total LUNs:"}),e.jsx("span",{className:"font-medium text-white",children:y.length})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-text-secondary",children:"Active:"}),e.jsx("span",{className:"font-medium text-white",children:y.filter(p=>p.is_active).length})]})]})})]}),e.jsxs(bi,{children:[e.jsx(yi,{children:e.jsx(wi,{className:"text-sm font-medium",children:"Actions"})}),e.jsx(vi,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ct,{variant:"outline",size:"sm",className:"w-full",onClick:()=>o(!0),children:[e.jsx(Ks,{className:"h-4 w-4 mr-2"}),"Assign Extent"]}),e.jsxs(ct,{variant:"outline",size:"sm",className:"w-full",onClick:()=>d(!0),children:[e.jsx(Vd,{className:"h-4 w-4 mr-2"}),"Add Initiator"]})]})})]})]}),e.jsxs(bi,{children:[e.jsx(yi,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(wi,{children:"LUNs (Logical Unit Numbers)"}),e.jsx(nu,{children:"Storage devices exported by this target"})]}),e.jsxs(ct,{variant:"outline",size:"sm",onClick:p=>{p.stopPropagation(),o(!0)},children:[e.jsx(Ks,{className:"h-4 w-4 mr-2"}),"Assign Extent"]})]})}),e.jsx(vi,{children:y.length>0?e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"min-w-full divide-y divide-gray-200",children:[e.jsx("thead",{className:"bg-[#1a2632]",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-text-secondary uppercase",children:"LUN #"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-text-secondary uppercase",children:"Handler"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-text-secondary uppercase",children:"Device Path"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-text-secondary uppercase",children:"Type"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-text-secondary uppercase",children:"Status"}),e.jsx("th",{className:"px-6 py-3 text-right text-xs font-medium text-text-secondary uppercase",children:"Actions"})]})}),e.jsx("tbody",{className:"bg-card-dark divide-y divide-border-dark",children:y.map(p=>e.jsxs("tr",{className:"hover:bg-[#233648]",children:[e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium text-white",children:p.lun_number}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-text-secondary",children:p.handler}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-mono text-xs text-white",children:p.device_path}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-text-secondary",children:p.device_type}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("span",{className:`px-2 py-1 text-xs font-medium rounded ${p.is_active?"bg-green-100 text-green-800":"bg-gray-100 text-gray-800"}`,children:p.is_active?"Active":"Inactive"})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-right text-sm",children:e.jsx("button",{onClick:v=>{v.stopPropagation(),confirm(`Remove LUN ${p.lun_number} from this target?`)&&h.mutate({targetId:m.id,lunId:p.id})},disabled:h.isPending,className:"p-1.5 hover:bg-red-500/10 rounded text-text-secondary hover:text-red-400 transition-colors disabled:opacity-50",title:"Remove LUN",children:e.jsx(es,{size:16})})})]},p.id))})]})}):e.jsxs("div",{className:"text-center py-8",children:[e.jsx(Ul,{className:"h-12 w-12 text-gray-400 mx-auto mb-4"}),e.jsx("p",{className:"text-sm text-text-secondary mb-4",children:"No LUNs configured"}),e.jsxs(ct,{variant:"outline",onClick:p=>{p.stopPropagation(),o(!0)},children:[e.jsx(Ks,{className:"h-4 w-4 mr-2"}),"Assign First Extent"]})]})})]}),n&&e.jsx(FS,{targetId:m.id,onClose:()=>o(!1),onSuccess:async()=>{o(!1),s.invalidateQueries({queryKey:["scst-target",r]}),s.invalidateQueries({queryKey:["scst-extents"]})}}),l&&e.jsx(ES,{targetId:m.id,onClose:()=>d(!1),onSuccess:()=>{d(!1),s.invalidateQueries({queryKey:["scst-target",r]})}})]})}function FS({targetId:r,onClose:t,onSuccess:s}){const[n,o]=Ce.useState(""),[l,d]=Ce.useState(0),{data:c=[],isLoading:u}=dt({queryKey:["scst-extents"],queryFn:br.listExtents,staleTime:0,refetchOnMount:!0}),h=c.filter(y=>!y.is_in_use),m=ft({mutationFn:y=>br.addLUN(r,y),onSuccess:async()=>{await s()},onError:y=>{const p=y.response?.data?.error||y.message||"Failed to assign extent";alert(p)}}),x=y=>{if(y.preventDefault(),!n||l<0){alert("Please select an extent and specify LUN number");return}const p=h.find(v=>v.device_name===n);if(!p){alert("Selected extent not found");return}m.mutate({device_name:p.device_name,device_path:p.device_path,handler_type:p.handler_type,lun_number:l})};return e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-card-dark border border-border-dark rounded-xl max-w-2xl w-full max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"p-6 border-b border-border-dark",children:[e.jsx("h2",{className:"text-xl font-bold text-white",children:"Assign Extent"}),e.jsx("p",{className:"text-sm text-text-secondary mt-1",children:"Assign an existing extent to this target as a LUN"})]}),e.jsxs("form",{onSubmit:x,className:"p-6 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"extent",className:"block text-sm font-medium text-white mb-1",children:"Available Extent *"}),u?e.jsx("div",{className:"w-full px-3 py-2 bg-[#0f161d] border border-border-dark rounded-lg text-text-secondary text-sm",children:"Loading extents..."}):h.length===0?e.jsx("div",{className:"w-full px-3 py-2 bg-[#0f161d] border border-border-dark rounded-lg text-text-secondary text-sm",children:"No available extents. Please create an extent first in the Extents tab."}):e.jsxs("select",{id:"extent",value:n,onChange:y=>o(y.target.value),className:"w-full px-3 py-2 bg-[#0f161d] border border-border-dark rounded-lg text-white text-sm focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary",required:!0,children:[e.jsx("option",{value:"",children:"Select an extent..."}),h.map(y=>e.jsxs("option",{value:y.device_name,children:[y.device_name," (",y.handler_type,") - ",y.device_path]},y.device_name))]}),e.jsx("p",{className:"mt-1 text-xs text-text-secondary",children:"Select an extent that has been created in the Extents tab"})]}),n&&e.jsxs("div",{className:"p-4 bg-[#0f161d] border border-border-dark rounded-lg",children:[e.jsx("p",{className:"text-sm text-text-secondary mb-2",children:"Extent Details:"}),(()=>{const y=h.find(p=>p.device_name===n);return y?e.jsxs("div",{className:"space-y-1 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-text-secondary",children:"Device Name:"}),e.jsx("span",{className:"text-white font-mono",children:y.device_name})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-text-secondary",children:"Handler:"}),e.jsx("span",{className:"text-white",children:y.handler_type})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-text-secondary",children:"Path:"}),e.jsx("span",{className:"text-white font-mono text-xs",children:y.device_path})]})]}):null})()]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"lunNumber",className:"block text-sm font-medium text-white mb-1",children:"LUN Number *"}),e.jsx("input",{id:"lunNumber",type:"number",value:l,onChange:y=>d(parseInt(y.target.value)||0),min:"0",max:"255",className:"w-full px-3 py-2 bg-[#0f161d] border border-border-dark rounded-lg text-white text-sm focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary",required:!0}),e.jsx("p",{className:"mt-1 text-xs text-text-secondary",children:"Logical Unit Number (0-255, typically start from 0)"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t border-border-dark",children:[e.jsx(ct,{type:"button",variant:"outline",onClick:t,children:"Cancel"}),e.jsx(ct,{type:"submit",disabled:m.isPending||h.length===0,children:m.isPending?"Assigning...":"Assign Extent"})]})]})]})})}function ES({targetId:r,onClose:t,onSuccess:s}){const[n,o]=Ce.useState(""),l=ft({mutationFn:c=>br.addInitiator(r,c),onSuccess:()=>{s()}}),d=c=>{if(c.preventDefault(),!n){alert("Initiator IQN is required");return}l.mutate({initiator_iqn:n.trim()})};return e.jsxs(bi,{children:[e.jsxs(yi,{children:[e.jsx(wi,{children:"Add Initiator"}),e.jsx(nu,{children:"Allow an iSCSI initiator to access this target"})]}),e.jsx(vi,{children:e.jsxs("form",{onSubmit:d,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"initiatorIqn",className:"block text-sm font-medium text-gray-700 mb-1",children:"Initiator IQN *"}),e.jsx("input",{id:"initiatorIqn",type:"text",value:n,onChange:c=>o(c.target.value),placeholder:"iqn.2024-01.com.client:initiator1",className:"w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 font-mono text-sm",required:!0}),e.jsx("p",{className:"mt-1 text-xs text-text-secondary",children:"Format: iqn.YYYY-MM.reverse.domain:identifier"})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(ct,{type:"button",variant:"outline",onClick:t,children:"Cancel"}),e.jsx(ct,{type:"submit",disabled:l.isPending,children:l.isPending?"Adding...":"Add Initiator"})]})]})})]})}function US(){const[r,t]=Ce.useState(!1),[s,n]=Ce.useState(null),[o,l]=Ce.useState(null),[d,c]=Ce.useState(null),[u,h]=Ce.useState("Etc/UTC"),[m,x]=Ce.useState(["pool.ntp.org","time.google.com"]),[y,p]=Ce.useState(!1),[v,N]=Ce.useState(""),[B,g]=Ce.useState(!1),[j,_]=Ce.useState(""),w=Ce.useRef(null),L=Nr(),K=ft({mutationFn:U=>ao.saveNTPSettings(U),onSuccess:()=>{L.invalidateQueries({queryKey:["system","ntp"]}),alert("NTP settings saved successfully!")},onError:U=>{alert(`Failed to save NTP settings: ${U.message||"Unknown error"}`)}}),{data:M=[],isLoading:V}=dt({queryKey:["system","interfaces"],queryFn:()=>ao.listNetworkInterfaces(),refetchInterval:5e3}),{data:T=[],isLoading:ne}=dt({queryKey:["system","services"],queryFn:()=>ao.listServices(),refetchInterval:5e3}),{data:Z}=dt({queryKey:["system","ntp"],queryFn:()=>ao.getNTPSettings()});return Ce.useEffect(()=>{Z&&(h(Z.timezone),x(Z.ntp_servers))},[Z]),Ce.useEffect(()=>{const U=q=>{w.current&&!w.current.contains(q.target)&&n(null)};return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[]),e.jsxs("div",{className:"flex-1 flex flex-col h-full overflow-hidden relative bg-background-dark",children:[e.jsxs("header",{className:"flex h-16 items-center justify-between border-b border-border-dark bg-background-dark px-6 lg:px-10 shrink-0 z-10",children:[e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(ba,{to:"/",className:"text-text-secondary hover:text-white transition-colors",children:"System"}),e.jsx("span",{className:"text-text-secondary",children:"/"}),e.jsx("span",{className:"text-white font-medium",children:"Configuration"})]})}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"hidden md:flex items-center gap-2 px-3 py-1.5 rounded-full bg-green-500/10 border border-green-500/20",children:[e.jsx("div",{className:"h-2 w-2 rounded-full bg-green-500 animate-pulse"}),e.jsx("span",{className:"text-xs font-medium text-green-500",children:"System Healthy"})]}),e.jsx("div",{className:"h-6 w-px bg-border-dark mx-2"}),e.jsxs("button",{className:"flex items-center justify-center gap-2 rounded-lg bg-border-dark px-4 py-2 text-sm font-bold text-white hover:bg-[#2f455a] transition-colors",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"restart_alt"}),e.jsx("span",{className:"hidden sm:inline",children:"Reboot"})]}),e.jsxs("button",{className:"flex items-center justify-center gap-2 rounded-lg bg-red-500/10 px-4 py-2 text-sm font-bold text-red-500 hover:bg-red-500/20 transition-colors border border-red-500/20",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"power_settings_new"}),e.jsx("span",{className:"hidden sm:inline",children:"Shutdown"})]})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4 md:p-8 lg:px-12 scroll-smooth",children:e.jsxs("div",{className:"mx-auto max-w-7xl",children:[e.jsxs("div",{className:"mb-8 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold tracking-tight text-white mb-2",children:"System Configuration"}),e.jsx("p",{className:"text-text-secondary text-sm max-w-2xl",children:"Manage network interfaces, time synchronization, service states, and remote management protocols."})]}),e.jsxs("button",{className:"flex items-center justify-center gap-2 rounded-lg bg-primary px-5 py-2.5 text-sm font-bold text-white hover:bg-blue-600 transition-all shadow-lg shadow-blue-500/20",children:[e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"save"}),"Save Changes"]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-6 xl:grid-cols-2",children:[e.jsxs("div",{className:"flex flex-col rounded-xl border border-border-dark bg-card-dark shadow-sm",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border-dark px-6 py-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"material-symbols-outlined text-primary",children:"verified"}),e.jsx("h2",{className:"text-lg font-bold text-white",children:"Feature License"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-green-500"}),e.jsx("span",{className:"text-xs text-text-secondary",children:"Licensed"})]})]}),e.jsxs("div",{className:"p-6 flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-[#111a22] border border-border-dark",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("p",{className:"text-sm font-bold text-white",children:"License Status"}),e.jsx("p",{className:"text-xs text-text-secondary",children:"Enterprise Edition"})]}),e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-full bg-green-500/10 border border-green-500/20",children:[e.jsx("span",{className:"material-symbols-outlined text-green-500 text-[16px]",children:"check_circle"}),e.jsx("span",{className:"text-xs font-bold text-green-500",children:"Active"})]})]}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-text-secondary",children:"License Key"}),e.jsx("span",{className:"text-xs font-mono text-white",children:"CAL-****-****-****-****-****"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-text-secondary",children:"Expires"}),e.jsx("span",{className:"text-xs font-bold text-white",children:"Dec 31, 2025"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-text-secondary",children:"Days Remaining"}),e.jsx("span",{className:"text-xs font-bold text-emerald-400",children:"365 days"})]})]}),e.jsxs("div",{className:"border-t border-border-dark pt-4",children:[e.jsx("h3",{className:"text-sm font-bold text-white mb-3",children:"Enabled Features"}),e.jsx("div",{className:"flex flex-col gap-2",children:[{name:"Advanced Replication",enabled:!0},{name:"Encryption at Rest",enabled:!0},{name:"Deduplication",enabled:!0},{name:"Cloud Backup Integration",enabled:!0},{name:"Multi-Site Sync",enabled:!0},{name:"Advanced Monitoring",enabled:!0}].map(U=>e.jsxs("div",{className:"flex items-center justify-between p-2 rounded bg-[#111a22]",children:[e.jsx("span",{className:"text-xs text-white",children:U.name}),U.enabled?e.jsx("span",{className:"material-symbols-outlined text-green-500 text-[16px]",children:"check_circle"}):e.jsx("span",{className:"material-symbols-outlined text-text-secondary text-[16px]",children:"cancel"})]},U.name))})]}),e.jsxs("div",{className:"border-t border-border-dark pt-4 flex flex-col gap-2",children:[e.jsxs("button",{onClick:()=>g(!0),className:"w-full flex items-center justify-center gap-2 rounded-lg bg-primary px-4 py-2.5 text-sm font-bold text-white hover:bg-blue-600 transition-colors",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"key"}),"Update License Key"]}),e.jsxs("button",{onClick:()=>{alert("Downloading license information...")},className:"w-full flex items-center justify-center gap-2 rounded-lg bg-border-dark px-4 py-2.5 text-sm font-bold text-white hover:bg-[#2f455a] transition-colors",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"download"}),"Download License Info"]})]})]})]}),e.jsxs("div",{className:"flex flex-col rounded-xl border border-border-dark bg-card-dark shadow-sm",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border-dark px-6 py-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"material-symbols-outlined text-primary",children:"lan"}),e.jsx("h2",{className:"text-lg font-bold text-white",children:"Network Interfaces"})]}),e.jsx("button",{className:"text-xs font-bold text-primary hover:text-blue-400",children:"CONFIGURE DNS"})]}),e.jsx("div",{className:"p-2",children:V?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx("span",{className:"text-text-secondary",children:"Loading interfaces..."})}):M.length===0?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx("span",{className:"text-text-secondary",children:"No network interfaces found"})}):M.map(U=>{const q=U.status==="Connected",F=U.role==="ISCSI"?"bg-purple-500/20":"bg-primary/20",le=U.role==="ISCSI"?"text-purple-400":"text-primary";return e.jsxs("div",{className:`group flex items-center justify-between rounded-lg p-3 hover:bg-border-dark/50 transition-colors ${q?"":"opacity-70"}`,children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-lg bg-border-dark ${q?"text-white":"text-text-secondary"}`,children:e.jsx("span",{className:"material-symbols-outlined",children:"settings_ethernet"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:`font-bold ${q?"text-white":"text-text-secondary"}`,children:U.name}),U.role&&e.jsx("span",{className:`rounded ${F} px-1.5 py-0.5 text-[10px] font-bold ${le} uppercase`,children:U.role})]}),U.ip_address?e.jsxs("p",{className:"font-mono text-xs text-text-secondary",children:[U.ip_address," ",e.jsx("span",{className:"opacity-50 mx-1",children:"/"})," ",U.subnet]}):e.jsx("p",{className:"font-mono text-xs text-text-secondary",children:"No Carrier"})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"hidden sm:flex flex-col items-end",children:q?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"h-2 w-2 rounded-full bg-green-500"}),e.jsx("span",{className:"text-xs font-medium text-white",children:"Connected"})]}),U.speed&&U.speed!=="Unknown"&&e.jsx("span",{className:"text-xs text-text-secondary",children:U.speed})]}):e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"h-2 w-2 rounded-full bg-red-500"}),e.jsx("span",{className:"text-xs font-medium text-red-500",children:"Down"})]})}),e.jsxs("div",{className:"relative",ref:w,children:[e.jsx("button",{onClick:()=>n(s===U.name?null:U.name),className:"h-8 w-8 rounded-full hover:bg-border-dark flex items-center justify-center text-text-secondary hover:text-white transition-colors",children:e.jsx("span",{className:"material-symbols-outlined",children:"more_vert"})}),s===U.name&&e.jsxs("div",{className:"absolute right-0 mt-1 w-48 rounded-lg border border-border-dark bg-card-dark shadow-lg z-50",children:[e.jsxs("button",{onClick:()=>{l(U),n(null)},className:"w-full flex items-center gap-2 px-4 py-2.5 text-sm text-white hover:bg-border-dark transition-colors first:rounded-t-lg",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"edit"}),e.jsx("span",{children:"Edit Connection"})]}),e.jsxs("button",{onClick:()=>{c(U),n(null)},className:"w-full flex items-center gap-2 px-4 py-2.5 text-sm text-white hover:bg-border-dark transition-colors",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"info"}),e.jsx("span",{children:"View Details"})]}),e.jsx("div",{className:"border-t border-border-dark"}),e.jsxs("button",{onClick:()=>{n(null)},className:"w-full flex items-center gap-2 px-4 py-2.5 text-sm text-white hover:bg-border-dark transition-colors last:rounded-b-lg",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:q?"toggle_on":"toggle_off"}),e.jsx("span",{children:q?"Disable":"Enable"})]})]})]})]})]},U.name)})})]}),e.jsxs("div",{className:"flex flex-col rounded-xl border border-border-dark bg-card-dark shadow-sm",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border-dark px-6 py-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"material-symbols-outlined text-primary",children:"memory"}),e.jsx("h2",{className:"text-lg font-bold text-white",children:"Service Control"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-green-500"}),e.jsx("span",{className:"text-xs text-text-secondary",children:"All Systems Normal"})]})]}),e.jsx("div",{className:"p-4 flex flex-col gap-1",children:ne?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx("span",{className:"text-text-secondary",children:"Loading services..."})}):[{key:"ssh",serviceNames:["ssh","sshd"],displayName:"SSH Service",description:"Remote command line access",icon:"terminal"},{key:"smb",serviceNames:["smbd","samba","smb"],displayName:"SMB / CIFS",description:"Windows file sharing",icon:"folder_shared"},{key:"iscsi",serviceNames:["iscsi-scst","iscsi","scst"],displayName:"iSCSI Target",description:"Block storage sharing",icon:"storage"},{key:"nfs",serviceNames:["nfs-server","nfs","nfsd"],displayName:"NFS Service",description:"Unix file sharing",icon:"share"},{key:"vtl",serviceNames:["mhvtl","vtl"],displayName:"VTL Service",description:"Virtual tape library emulation",icon:"album"}].map(U=>{const q=T.find(se=>{const fe=se.name.toLowerCase();return U.serviceNames.some(ye=>fe.includes(ye.toLowerCase())||ye.toLowerCase().includes(fe))}),F=q?.active_state==="active",le=F?"RUNNING":"STOPPED",ae=F?"bg-green-500/20 text-green-500 border-green-500/20":"bg-yellow-500/20 text-yellow-500 border-yellow-500/20";return e.jsxs("div",{className:"flex items-center justify-between rounded-lg bg-[#111a22] p-3 border border-transparent hover:border-border-dark transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded bg-border-dark/50 text-white",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:U.icon})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-white",children:U.displayName}),e.jsx("p",{className:"text-xs text-text-secondary",children:U.description})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("span",{className:`px-2 py-0.5 rounded text-[10px] font-bold border ${ae}`,children:le}),e.jsxs("label",{className:"relative inline-block w-10 h-5 mr-2 align-middle select-none cursor-pointer",children:[e.jsx("input",{checked:F,onChange:()=>{q&&ao.restartService(q.name).then(()=>{L.invalidateQueries({queryKey:["system","services"]})}).catch(se=>{alert(`Failed to ${F?"stop":"start"} service: ${se.message||"Unknown error"}`)})},className:"sr-only peer",id:`${U.key}-toggle`,name:"toggle",type:"checkbox"}),e.jsx("span",{className:"absolute inset-0 rounded-full bg-border-dark transition-colors duration-300 peer-checked:bg-primary/20"}),e.jsx("span",{className:"absolute left-0.5 top-0.5 h-4 w-4 rounded-full bg-white transition-transform duration-300 peer-checked:translate-x-5"})]})]})]},U.key)})})]}),e.jsxs("div",{className:"flex flex-col rounded-xl border border-border-dark bg-card-dark shadow-sm",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border-dark px-6 py-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"material-symbols-outlined text-primary",children:"schedule"}),e.jsx("h2",{className:"text-lg font-bold text-white",children:"Date & Time"})]}),e.jsxs("button",{onClick:()=>{K.mutate({timezone:u,ntp_servers:m})},disabled:K.isPending,className:"flex items-center justify-center gap-2 rounded-lg bg-primary px-4 py-2 text-sm font-bold text-white hover:bg-blue-600 transition-all disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"save"}),K.isPending?"Saving...":"Save"]})]}),e.jsxs("div",{className:"p-6 flex flex-col gap-6",children:[e.jsx("div",{className:"grid grid-cols-2 gap-4",children:e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"mb-2 block text-xs font-medium text-text-secondary uppercase",children:"System Timezone"}),e.jsxs("div",{className:"relative",children:[e.jsxs("select",{value:u,onChange:U=>h(U.target.value),className:"block w-full rounded-lg border-border-dark bg-[#111a22] py-2.5 pl-3 pr-10 text-sm text-white focus:border-primary focus:ring-1 focus:ring-primary appearance-none",children:[e.jsx("option",{children:"Etc/UTC"}),e.jsx("option",{children:"Asia/Jakarta"}),e.jsx("option",{children:"Asia/Singapore"}),e.jsx("option",{children:"Asia/Bangkok"}),e.jsx("option",{children:"Asia/Manila"}),e.jsx("option",{children:"Asia/Tokyo"}),e.jsx("option",{children:"Asia/Shanghai"}),e.jsx("option",{children:"Asia/Hong_Kong"}),e.jsx("option",{children:"Europe/London"}),e.jsx("option",{children:"Europe/Paris"}),e.jsx("option",{children:"America/New_York"}),e.jsx("option",{children:"America/Los_Angeles"})]}),e.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-white",children:e.jsx("span",{className:"material-symbols-outlined text-sm",children:"expand_more"})})]})]})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("label",{className:"block text-xs font-medium text-text-secondary uppercase",children:"NTP Servers"}),e.jsxs("button",{onClick:()=>p(!0),className:"text-xs text-primary font-bold hover:text-white flex items-center gap-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"add"})," Add Server"]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[y&&e.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-[#111a22] p-3 border border-border-dark",children:[e.jsx("input",{type:"text",value:v,onChange:U=>N(U.target.value),onKeyDown:U=>{U.key==="Enter"&&v.trim()&&(m.includes(v.trim())||(x([...m,v.trim()]),N(""),p(!1))),U.key==="Escape"&&(N(""),p(!1))},placeholder:"Enter NTP server address (e.g., 0.pool.ntp.org)",className:"flex-1 bg-transparent text-sm text-white placeholder-gray-500 focus:outline-none",autoFocus:!0}),e.jsx("button",{onClick:()=>{v.trim()&&!m.includes(v.trim())&&(x([...m,v.trim()]),N(""),p(!1))},className:"text-green-500 hover:text-green-400",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"check"})}),e.jsx("button",{onClick:()=>{N(""),p(!1)},className:"text-red-500 hover:text-red-400",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]}),m.map((U,q)=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg bg-[#111a22] p-3 border border-border-dark",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-2 w-2 rounded-full bg-green-500 animate-pulse"}),e.jsx("span",{className:"text-sm font-mono text-white",children:U})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-text-secondary",children:"Stratum 2 • 12ms"}),e.jsx("button",{onClick:()=>{x(m.filter((F,le)=>le!==q))},className:"text-red-500 hover:text-red-400",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"delete"})})]})]},q))]})]})]})]}),e.jsxs("div",{className:"flex flex-col rounded-xl border border-border-dark bg-card-dark shadow-sm",children:[e.jsx("div",{className:"flex items-center justify-between border-b border-border-dark px-6 py-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"material-symbols-outlined text-primary",children:"hub"}),e.jsx("h2",{className:"text-lg font-bold text-white",children:"Management"})]})}),e.jsxs("div",{className:"p-6 flex flex-col gap-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-bold text-white",children:"SNMP Monitoring"}),e.jsx("p",{className:"text-xs text-text-secondary",children:"Enable Simple Network Management Protocol"})]}),e.jsxs("label",{className:"relative inline-block w-10 h-5 align-middle select-none cursor-pointer",children:[e.jsx("input",{checked:r,onChange:U=>t(U.target.checked),className:"sr-only peer",id:"snmp-toggle",name:"toggle",type:"checkbox"}),e.jsx("span",{className:"absolute inset-0 rounded-full bg-border-dark transition-colors duration-300 peer-checked:bg-primary/20"}),e.jsx("span",{className:"absolute left-0.5 top-0.5 h-4 w-4 rounded-full bg-white transition-transform duration-300 peer-checked:translate-x-5"})]})]}),e.jsxs("div",{className:`grid grid-cols-1 gap-4 transition-opacity ${r?"opacity-100":"opacity-50 pointer-events-none"}`,children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1.5 block text-xs font-medium text-text-secondary uppercase",children:"Community String"}),e.jsx("input",{className:"block w-full rounded-lg border-border-dark bg-[#111a22] p-2.5 text-sm text-white placeholder-gray-500 focus:border-primary focus:ring-1 focus:ring-primary",placeholder:"e.g. public",type:"text",defaultValue:"public",disabled:!r})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1.5 block text-xs font-medium text-text-secondary uppercase",children:"Trap Receiver IP"}),e.jsx("input",{className:"block w-full rounded-lg border-border-dark bg-[#111a22] p-2.5 text-sm text-white placeholder-gray-500 focus:border-primary focus:ring-1 focus:ring-primary",placeholder:"e.g. 192.168.1.100",type:"text",disabled:!r})]})]})]}),e.jsxs("div",{className:"border-t border-border-dark pt-4",children:[e.jsx("h3",{className:"text-sm font-bold text-white mb-3",children:"Syslog Forwarding"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{className:"flex-1 rounded-lg border-border-dark bg-[#111a22] p-2.5 text-sm text-white placeholder-gray-500 focus:border-primary focus:ring-1 focus:ring-primary",placeholder:"Syslog Server Address (UDP:514)",type:"text"}),e.jsx("button",{className:"rounded-lg bg-border-dark px-4 py-2 text-sm font-bold text-white hover:bg-[#2f455a] transition-colors",children:"Test"})]})]})]})]})]}),e.jsx("div",{className:"h-10"})]})}),o&&e.jsx(QS,{interface:o,onClose:()=>l(null)}),d&&e.jsx(LS,{interface:d,onClose:()=>c(null)}),B&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>g(!1),children:e.jsxs("div",{className:"bg-card-dark rounded-xl border border-border-dark max-w-lg w-full",onClick:U=>U.stopPropagation(),children:[e.jsxs("div",{className:"p-6 border-b border-border-dark flex justify-between items-center",children:[e.jsx("h3",{className:"text-lg font-bold text-white",children:"Update License Key"}),e.jsx("button",{onClick:()=>{g(!1),_("")},className:"text-text-secondary hover:text-white",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"close"})})]}),e.jsxs("div",{className:"p-6 flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-semibold text-white",children:"License Key"}),e.jsx("textarea",{className:"w-full bg-[#111a22] border border-border-dark rounded-lg px-3 py-2 text-sm text-white focus:border-primary focus:ring-1 focus:ring-primary outline-none font-mono resize-none",rows:4,placeholder:"Paste your license key here...",value:j,onChange:U=>_(U.target.value)}),e.jsx("p",{className:"text-xs text-text-secondary",children:"Enter your license key to activate or update features. The key will be validated automatically."})]}),e.jsxs("div",{className:"flex flex-col gap-2 p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/20",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-yellow-500 text-[18px]",children:"info"}),e.jsx("span",{className:"text-xs font-bold text-yellow-500",children:"Important"})]}),e.jsx("p",{className:"text-xs text-text-secondary",children:"Updating the license key will restart the system services. Make sure you have a valid license key before proceeding."})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t border-border-dark",children:[e.jsx("button",{onClick:()=>{g(!1),_("")},className:"px-4 py-2 rounded-lg border border-border-dark text-white hover:bg-border-dark transition-colors text-sm font-bold",children:"Cancel"}),e.jsx("button",{onClick:()=>{if(!j.trim()){alert("Please enter a license key");return}console.log("Updating license key:",j),alert("License key updated successfully!"),g(!1),_("")},className:"px-4 py-2 rounded-lg bg-primary hover:bg-blue-600 text-white transition-colors text-sm font-bold",children:"Update License"})]})]})]})})]})}function QS({interface:r,onClose:t}){const s=Nr(),[n,o]=Ce.useState({ip_address:r.ip_address||"",subnet:r.subnet||"24",gateway:r.gateway||"",dns1:r.dns1||"",dns2:r.dns2||"",role:r.role||""}),l=ft({mutationFn:c=>ao.updateNetworkInterface(r.name,c),onSuccess:()=>{s.invalidateQueries({queryKey:["system","interfaces"]}),t()},onError:c=>{alert(`Failed to update interface: ${c.response?.data?.error||c.message}`)}}),d=c=>{c.preventDefault(),l.mutate({ip_address:n.ip_address,subnet:n.subnet,gateway:n.gateway||void 0,dns1:n.dns1||void 0,dns2:n.dns2||void 0,role:n.role||void 0})};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:e.jsxs("div",{className:"w-full max-w-2xl rounded-xl border border-border-dark bg-card-dark shadow-xl",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border-dark px-6 py-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"material-symbols-outlined text-primary",children:"settings_ethernet"}),e.jsxs("h2",{className:"text-lg font-bold text-white",children:["Edit Connection - ",r.name]})]}),e.jsx("button",{onClick:t,className:"h-8 w-8 rounded-full hover:bg-border-dark flex items-center justify-center text-text-secondary hover:text-white transition-colors",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"close"})})]}),e.jsxs("form",{onSubmit:d,className:"p-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-xs font-medium text-text-secondary uppercase",children:"IP Address"}),e.jsx("input",{type:"text",value:n.ip_address,onChange:c=>o({...n,ip_address:c.target.value}),className:"block w-full rounded-lg border-border-dark bg-[#111a22] p-2.5 text-sm text-white placeholder-gray-500 focus:border-primary focus:ring-1 focus:ring-primary",placeholder:"192.168.1.100",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-xs font-medium text-text-secondary uppercase",children:"Subnet Mask (CIDR)"}),e.jsx("input",{type:"text",value:n.subnet,onChange:c=>o({...n,subnet:c.target.value}),className:"block w-full rounded-lg border-border-dark bg-[#111a22] p-2.5 text-sm text-white placeholder-gray-500 focus:border-primary focus:ring-1 focus:ring-primary",placeholder:"24",required:!0}),e.jsx("p",{className:"mt-1 text-xs text-text-secondary",children:"Enter CIDR notation (e.g., 24 for 255.255.255.0)"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-xs font-medium text-text-secondary uppercase",children:"Default Gateway"}),e.jsx("input",{type:"text",value:n.gateway,onChange:c=>o({...n,gateway:c.target.value}),className:"block w-full rounded-lg border-border-dark bg-[#111a22] p-2.5 text-sm text-white placeholder-gray-500 focus:border-primary focus:ring-1 focus:ring-primary",placeholder:"192.168.1.1"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-xs font-medium text-text-secondary uppercase",children:"Primary DNS"}),e.jsx("input",{type:"text",value:n.dns1,onChange:c=>o({...n,dns1:c.target.value}),className:"block w-full rounded-lg border-border-dark bg-[#111a22] p-2.5 text-sm text-white placeholder-gray-500 focus:border-primary focus:ring-1 focus:ring-primary",placeholder:"8.8.8.8"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-xs font-medium text-text-secondary uppercase",children:"Secondary DNS"}),e.jsx("input",{type:"text",value:n.dns2,onChange:c=>o({...n,dns2:c.target.value}),className:"block w-full rounded-lg border-border-dark bg-[#111a22] p-2.5 text-sm text-white placeholder-gray-500 focus:border-primary focus:ring-1 focus:ring-primary",placeholder:"8.8.4.4"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-xs font-medium text-text-secondary uppercase",children:"Interface Role"}),e.jsxs("select",{value:n.role,onChange:c=>o({...n,role:c.target.value}),className:"block w-full rounded-lg border-border-dark bg-[#111a22] py-2.5 pl-3 pr-10 text-sm text-white focus:border-primary focus:ring-1 focus:ring-primary appearance-none",children:[e.jsx("option",{value:"",children:"None"}),e.jsx("option",{value:"Management",children:"Management"}),e.jsx("option",{value:"ISCSI",children:"iSCSI"}),e.jsx("option",{value:"Storage",children:"Storage"})]})]})]}),e.jsxs("div",{className:"mt-6 flex items-center justify-end gap-3",children:[e.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm font-bold text-text-secondary hover:text-white transition-colors",children:"Cancel"}),e.jsxs("button",{type:"submit",disabled:l.isPending,className:"flex items-center gap-2 rounded-lg bg-primary px-5 py-2.5 text-sm font-bold text-white hover:bg-blue-600 transition-all disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"save"}),l.isPending?"Saving...":"Save Changes"]})]})]})]})})}function LS({interface:r,onClose:t}){return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:e.jsxs("div",{className:"w-full max-w-2xl rounded-xl border border-border-dark bg-card-dark shadow-xl",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border-dark px-6 py-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"material-symbols-outlined text-primary",children:"info"}),e.jsxs("h2",{className:"text-lg font-bold text-white",children:["Interface Details - ",r.name]})]}),e.jsx("button",{onClick:t,className:"h-8 w-8 rounded-full hover:bg-border-dark flex items-center justify-center text-text-secondary hover:text-white transition-colors",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"close"})})]}),e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-[#111a22] border border-border-dark",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`h-3 w-3 rounded-full ${r.status==="Connected"?"bg-green-500":"bg-red-500"}`}),e.jsx("span",{className:"text-sm font-medium text-text-secondary",children:"Status"})]}),e.jsx("span",{className:`text-sm font-bold ${r.status==="Connected"?"text-green-500":"text-red-500"}`,children:r.status})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"p-4 rounded-lg bg-[#111a22] border border-border-dark",children:[e.jsx("label",{className:"mb-2 block text-xs font-medium text-text-secondary uppercase",children:"IP Address"}),e.jsx("p",{className:"text-sm font-mono text-white",children:r.ip_address||"Not configured"})]}),e.jsxs("div",{className:"p-4 rounded-lg bg-[#111a22] border border-border-dark",children:[e.jsx("label",{className:"mb-2 block text-xs font-medium text-text-secondary uppercase",children:"Subnet Mask (CIDR)"}),e.jsxs("p",{className:"text-sm font-mono text-white",children:["/",r.subnet||"N/A"]})]}),e.jsxs("div",{className:"p-4 rounded-lg bg-[#111a22] border border-border-dark",children:[e.jsx("label",{className:"mb-2 block text-xs font-medium text-text-secondary uppercase",children:"Default Gateway"}),e.jsx("p",{className:"text-sm font-mono text-white",children:r.gateway||"Not configured"})]}),e.jsxs("div",{className:"p-4 rounded-lg bg-[#111a22] border border-border-dark",children:[e.jsx("label",{className:"mb-2 block text-xs font-medium text-text-secondary uppercase",children:"Link Speed"}),e.jsx("p",{className:"text-sm font-mono text-white",children:r.speed||"Unknown"})]})]}),e.jsxs("div",{className:"p-4 rounded-lg bg-[#111a22] border border-border-dark",children:[e.jsx("label",{className:"mb-3 block text-xs font-medium text-text-secondary uppercase",children:"DNS Servers"}),e.jsxs("div",{className:"space-y-2",children:[r.dns1?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-text-secondary",children:"Primary:"}),e.jsx("span",{className:"text-sm font-mono text-white",children:r.dns1})]}):e.jsx("p",{className:"text-xs text-text-secondary",children:"Primary DNS: Not configured"}),r.dns2?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-text-secondary",children:"Secondary:"}),e.jsx("span",{className:"text-sm font-mono text-white",children:r.dns2})]}):e.jsx("p",{className:"text-xs text-text-secondary",children:"Secondary DNS: Not configured"})]})]}),r.role&&e.jsxs("div",{className:"p-4 rounded-lg bg-[#111a22] border border-border-dark",children:[e.jsx("label",{className:"mb-2 block text-xs font-medium text-text-secondary uppercase",children:"Interface Role"}),e.jsx("span",{className:`inline-block px-3 py-1 rounded text-xs font-bold uppercase ${r.role==="ISCSI"?"bg-purple-500/20 text-purple-400 border border-purple-500/20":"bg-primary/20 text-primary border border-primary/20"}`,children:r.role})]}),r.ip_address&&r.subnet&&e.jsxs("div",{className:"p-4 rounded-lg bg-[#111a22] border border-border-dark",children:[e.jsx("label",{className:"mb-2 block text-xs font-medium text-text-secondary uppercase",children:"Full Network Address"}),e.jsxs("p",{className:"text-sm font-mono text-white",children:[r.ip_address,"/",r.subnet]})]})]}),e.jsx("div",{className:"mt-6 flex justify-end",children:e.jsxs("button",{onClick:t,className:"flex items-center justify-center gap-2 rounded-lg bg-primary px-6 py-2.5 text-sm font-bold text-white hover:bg-blue-600 transition-all",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"close"}),"Close"]})})]})]})})}const ys={listJobs:async r=>{const t=new URLSearchParams;return r?.status&&t.append("status",r.status),r?.job_type&&t.append("job_type",r.job_type),r?.client_name&&t.append("client_name",r.client_name),r?.job_name&&t.append("job_name",r.job_name),r?.limit&&t.append("limit",r.limit.toString()),r?.offset&&t.append("offset",r.offset.toString()),(await ze.get(`/backup/jobs${t.toString()?`?${t.toString()}`:""}`)).data},getJob:async r=>(await ze.get(`/backup/jobs/${r}`)).data,createJob:async r=>(await ze.post("/backup/jobs",r)).data,executeBconsoleCommand:async r=>(await ze.post("/backup/console/execute",{command:r})).data,listClients:async r=>{const t=new URLSearchParams;return r?.enabled!==void 0&&t.append("enabled",r.enabled.toString()),r?.search&&t.append("search",r.search),r?.category&&t.append("category",r.category),(await ze.get(`/backup/clients${t.toString()?`?${t.toString()}`:""}`)).data},getDashboardStats:async()=>(await ze.get("/backup/dashboard/stats")).data,listStoragePools:async()=>(await ze.get("/backup/storage/pools")).data,listStorageVolumes:async r=>{const t=new URLSearchParams;return r&&t.append("pool_name",r),(await ze.get(`/backup/storage/volumes${t.toString()?`?${t.toString()}`:""}`)).data},listStorageDaemons:async()=>(await ze.get("/backup/storage/daemons")).data,createStoragePool:async r=>(await ze.post("/backup/storage/pools",r)).data,deleteStoragePool:async r=>{await ze.delete(`/backup/storage/pools/${r}`)},createStorageVolume:async r=>(await ze.post("/backup/storage/volumes",r)).data,updateStorageVolume:async(r,t)=>(await ze.put(`/backup/storage/volumes/${r}`,t)).data,deleteStorageVolume:async r=>{await ze.delete(`/backup/storage/volumes/${r}`)},listMedia:async()=>(await ze.get("/backup/media")).data},TS=` .status-dot { box-shadow: 0 0 6px currentColor; } .checkbox-custom { appearance: none; background-color: #1c2936; border: 1px solid #324d67; border-radius: 4px; width: 16px; height: 16px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; } .checkbox-custom:checked { background-color: #137fec; border-color: #137fec; } .checkbox-custom:checked::after { content: ''; width: 4px; height: 8px; border: solid white; border-width: 0 2px 2px 0; transform: rotate(45deg); margin-bottom: 2px; } .agent-item { position: relative; } .agent-item .tree-line-vertical { position: absolute; left: 20px; top: -24px; bottom: 0; width: 1px; background-color: #324d67; z-index: 0; } .agent-item:last-child .tree-line-vertical { bottom: 50%; } .agent-item .tree-line-horizontal { position: absolute; left: 20px; top: 50%; width: 24px; height: 1px; background-color: #324d67; z-index: 0; } .custom-scrollbar::-webkit-scrollbar { width: 6px; } .custom-scrollbar::-webkit-scrollbar-track { background: transparent; } .custom-scrollbar::-webkit-scrollbar-thumb { background: #324d67; border-radius: 10px; } `;function IS(){const r=Cy(),s=new URLSearchParams(r.search).get("tab"),[n,o]=Ce.useState(s||"dashboard"),[l,d]=Ce.useState(""),c=Nr();Ce.useEffect(()=>{const g=new URLSearchParams(r.search).get("tab");if(g==="pools"||g==="volumes"){const _=new URLSearchParams(r.search);_.set("tab","storage"),g==="volumes"?_.set("view","volumes"):g==="pools"&&_.set("view","pools");const w=`${r.pathname}?${_.toString()}`;window.history.replaceState({},"",w),o("storage");return}const j=g||"dashboard";j!==n&&(j==="dashboard"||j==="jobs"||j==="clients"||j==="storage"||j==="filesets"||j==="console")&&o(j)},[r.search,r.pathname]);const u=g=>{o(g);const j=new URLSearchParams(r.search);g==="dashboard"?j.delete("tab"):j.set("tab",g);const _=`${r.pathname}${j.toString()?"?"+j.toString():""}`;window.history.replaceState({},"",_)},{data:h}=dt({queryKey:["dashboard-stats"],queryFn:()=>ys.getDashboardStats(),enabled:n==="dashboard",refetchInterval:3e4}),{data:m}=dt({queryKey:["dashboard-jobs"],queryFn:()=>ys.listJobs({limit:10}),enabled:n==="dashboard"}),{data:x}=dt({queryKey:["running-jobs"],queryFn:()=>ys.listJobs({status:"Running",limit:10}),enabled:n==="dashboard",refetchInterval:5e3}),y=m?.jobs||[],p=x?.jobs||[],v=g=>{if(g===0)return"0 B";const j=1024,_=["B","KB","MB","GB","TB"],w=Math.floor(Math.log(g)/Math.log(j));return`${(g/Math.pow(j,w)).toFixed(2)} ${_[w]}`},N=g=>{if(!g)return"-";try{const j=new Date(g),w=new Date().getTime()-j.getTime(),L=Math.floor(w/6e4),K=Math.floor(w/36e5),M=Math.floor(w/864e5);return L<1?"Just now":L<60?`${L}m ago`:K<24?`${K}h ago`:M<7?`${M}d ago`:j.toLocaleDateString()}catch{return"-"}},B=g=>{if(!g)return"-";const j=Math.floor(g/3600),_=Math.floor(g%3600/60),w=g%60;return j>0?`${j}:${_.toString().padStart(2,"0")}:${w.toString().padStart(2,"0")}`:`${_}:${w.toString().padStart(2,"0")}`};return e.jsx("div",{className:"flex-1 flex flex-col overflow-hidden bg-slate-50 dark:bg-[#101922]",children:e.jsxs("main",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs("header",{className:"h-16 flex items-center justify-between px-8 bg-white dark:bg-[#111a22] border-b border-slate-200 dark:border-[#233648] z-10",children:[e.jsxs("div",{className:"flex items-center gap-6 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"size-10 bg-primary rounded-lg flex items-center justify-center text-white",children:e.jsx("span",{className:"material-symbols-outlined",children:"backup"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-bold leading-tight",children:"Backup Management"}),e.jsx("p",{className:"text-xs text-slate-500 dark:text-[#92adc9]",children:"Backup Appliance"})]})]}),e.jsxs("div",{className:"relative w-full max-w-md",children:[e.jsx("span",{className:"material-symbols-outlined absolute left-3 top-1/2 -translate-y-1/2 text-slate-400 text-[20px]",children:"search"}),e.jsx("input",{className:"w-full bg-slate-100 dark:bg-[#233648] border-none rounded-lg pl-10 pr-4 py-2 text-sm focus:ring-2 focus:ring-primary/50 transition-all outline-none",placeholder:"Search clients, jobs, or logs...",type:"text",value:l,onChange:g=>d(g.target.value)})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-green-500/10 text-green-500 rounded-full border border-green-500/20",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-green-500 animate-pulse"}),e.jsx("span",{className:"text-xs font-bold uppercase tracking-tighter",children:h?.director_status==="Active"?"SD Connected":"SD Disconnected"})]}),e.jsxs("button",{className:"p-2 text-slate-500 hover:bg-slate-100 dark:hover:bg-[#233648] rounded-lg relative",children:[e.jsx("span",{className:"material-symbols-outlined",children:"notifications"}),e.jsx("span",{className:"absolute top-2 right-2 w-2 h-2 bg-primary rounded-full border-2 border-white dark:border-[#111a22]"})]}),e.jsx("button",{onClick:()=>{c.invalidateQueries({queryKey:["dashboard-stats"]}),c.invalidateQueries({queryKey:["dashboard-jobs"]}),c.invalidateQueries({queryKey:["running-jobs"]})},className:"p-2 text-slate-500 hover:bg-slate-100 dark:hover:bg-[#233648] rounded-lg",children:e.jsx("span",{className:"material-symbols-outlined",children:"refresh"})})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-8 space-y-8 custom-scrollbar bg-slate-50 dark:bg-[#101922]",children:[n==="dashboard"&&e.jsxs(e.Fragment,{children:[e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-sm font-bold uppercase tracking-widest text-slate-500 dark:text-[#92adc9]",children:"Job Statistics (Last 24h)"}),e.jsx("button",{onClick:()=>u("jobs"),className:"text-xs font-medium text-primary cursor-pointer hover:underline",children:"View detailed report"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"bg-white dark:bg-[#111a22] border border-slate-200 dark:border-[#324d67] p-6 rounded-xl flex flex-col gap-1 hover:border-primary/50 transition-colors cursor-default",children:[e.jsx("p",{className:"text-slate-500 dark:text-[#92adc9] text-sm font-medium",children:"Successful Backups"}),e.jsxs("div",{className:"flex items-end justify-between",children:[e.jsx("span",{className:"text-3xl font-bold",children:y.filter(g=>g.status==="Completed").length}),e.jsxs("span",{className:"text-green-500 text-sm font-bold flex items-center gap-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"trending_up"}),"+12%"]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-[#111a22] border border-slate-200 dark:border-[#324d67] p-6 rounded-xl flex flex-col gap-1 hover:border-primary/50 transition-colors cursor-default",children:[e.jsx("p",{className:"text-slate-500 dark:text-[#92adc9] text-sm font-medium",children:"Failed Jobs"}),e.jsxs("div",{className:"flex items-end justify-between",children:[e.jsx("span",{className:"text-3xl font-bold",children:y.filter(g=>g.status==="Failed").length}),e.jsxs("span",{className:"text-red-500 text-sm font-bold flex items-center gap-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"trending_down"}),"-5%"]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-[#111a22] border border-slate-200 dark:border-[#324d67] p-6 rounded-xl flex flex-col gap-1 hover:border-primary/50 transition-colors cursor-default",children:[e.jsx("p",{className:"text-slate-500 dark:text-[#92adc9] text-sm font-medium",children:"Currently Running"}),e.jsxs("div",{className:"flex items-end justify-between",children:[e.jsx("span",{className:"text-3xl font-bold",children:p.length}),e.jsxs("span",{className:"text-primary text-sm font-bold flex items-center gap-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"sync"}),"Active"]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-[#111a22] border border-slate-200 dark:border-[#324d67] p-6 rounded-xl flex flex-col gap-1 hover:border-primary/50 transition-colors cursor-default",children:[e.jsx("p",{className:"text-slate-500 dark:text-[#92adc9] text-sm font-medium",children:"Waiting / Queued"}),e.jsxs("div",{className:"flex items-end justify-between",children:[e.jsx("span",{className:"text-3xl font-bold",children:y.filter(g=>g.status==="Waiting").length}),e.jsx("span",{className:"text-slate-400 text-sm font-bold",children:"No change"})]})]})]})]}),e.jsxs("section",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"bg-white dark:bg-[#111a22] border border-slate-200 dark:border-[#233648] rounded-xl p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h3",{className:"text-base font-bold",children:"Storage Pool Utilization"}),e.jsx("span",{className:"material-symbols-outlined text-slate-400",children:"info"})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-sm mb-2",children:[e.jsx("span",{className:"text-slate-500 dark:text-[#92adc9]",children:h?.default_pool?.name||"Default Pool"}),e.jsx("span",{className:"font-bold",children:h?.default_pool?`${v(h.default_pool.used_bytes)} / ${v(h.default_pool.total_bytes)}`:"N/A"})]}),e.jsx("div",{className:"w-full bg-slate-100 dark:bg-[#233648] h-3 rounded-full overflow-hidden",children:e.jsx("div",{className:"bg-primary h-full rounded-full",style:{width:`${h?.default_pool?Math.min(h.default_pool.usage_percent,100):0}%`}})})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-sm mb-2",children:[e.jsx("span",{className:"text-slate-500 dark:text-[#92adc9]",children:"Offsite Cloud Sync"}),e.jsx("span",{className:"font-bold",children:"1.8 TB / 5.0 TB"})]}),e.jsx("div",{className:"w-full bg-slate-100 dark:bg-[#233648] h-3 rounded-full overflow-hidden",children:e.jsx("div",{className:"bg-green-500 h-full rounded-full",style:{width:"36%"}})})]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-[#111a22] border border-slate-200 dark:border-[#233648] rounded-xl p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h3",{className:"text-base font-bold",children:"Resource Summary"}),e.jsx("button",{className:"text-primary text-sm font-semibold",children:"View Hardware"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"bg-slate-50 dark:bg-[#16232e] p-4 rounded-lg",children:[e.jsx("p",{className:"text-xs text-slate-500 dark:text-[#92adc9] uppercase font-bold mb-1",children:"Active Volumes"}),e.jsx("p",{className:"text-xl font-bold",children:"34"})]}),e.jsxs("div",{className:"bg-slate-50 dark:bg-[#16232e] p-4 rounded-lg",children:[e.jsx("p",{className:"text-xs text-slate-500 dark:text-[#92adc9] uppercase font-bold mb-1",children:"Total Clients"}),e.jsx("p",{className:"text-xl font-bold",children:h?.active_jobs_count||0})]}),e.jsxs("div",{className:"bg-slate-50 dark:bg-[#16232e] p-4 rounded-lg",children:[e.jsx("p",{className:"text-xs text-slate-500 dark:text-[#92adc9] uppercase font-bold mb-1",children:"Last Full Backup"}),e.jsx("p",{className:"text-xl font-bold",children:h?.last_job?N(h.last_job.ended_at||h.last_job.started_at):"N/A"})]}),e.jsxs("div",{className:"bg-slate-50 dark:bg-[#16232e] p-4 rounded-lg",children:[e.jsx("p",{className:"text-xs text-slate-500 dark:text-[#92adc9] uppercase font-bold mb-1",children:"Catalog Size"}),e.jsx("p",{className:"text-xl font-bold",children:"12.4 GB"})]})]})]})]}),p.length>0&&e.jsxs("section",{className:"bg-white dark:bg-[#111a22] border border-slate-200 dark:border-[#233648] rounded-xl overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-4 border-b border-slate-200 dark:border-[#233648] flex items-center justify-between",children:[e.jsx("h3",{className:"text-base font-bold",children:"Running Jobs"}),e.jsx("button",{className:"bg-primary text-white text-xs font-bold px-4 py-2 rounded-lg hover:bg-primary/90 transition-colors",children:"Abort All"})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-slate-50 dark:bg-[#16232e] text-[11px] uppercase tracking-wider text-slate-500 dark:text-[#92adc9] font-bold",children:[e.jsx("th",{className:"px-6 py-3",children:"Job ID"}),e.jsx("th",{className:"px-6 py-3",children:"Client Name"}),e.jsx("th",{className:"px-6 py-3",children:"Level"}),e.jsx("th",{className:"px-6 py-3",children:"Progress"}),e.jsx("th",{className:"px-6 py-3",children:"Bytes Processed"}),e.jsx("th",{className:"px-6 py-3",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-slate-100 dark:divide-[#233648]",children:p.map(g=>{const j=g.duration_seconds?Math.min(g.duration_seconds/3600*100,100):45;return e.jsxs("tr",{className:"hover:bg-slate-50 dark:hover:bg-[#16232e] transition-colors",children:[e.jsx("td",{className:"px-6 py-4 text-sm font-mono",children:g.job_id}),e.jsx("td",{className:"px-6 py-4 text-sm font-bold",children:g.client_name}),e.jsx("td",{className:"px-6 py-4 text-sm",children:e.jsx("span",{className:`px-2 py-0.5 rounded text-[10px] font-bold uppercase border ${g.job_level==="Full"?"bg-purple-500/10 text-purple-500 border-purple-500/20":"bg-blue-500/10 text-blue-500 border-blue-500/20"}`,children:g.job_level})}),e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex-1 bg-slate-200 dark:bg-[#233648] h-1.5 rounded-full overflow-hidden min-w-[100px]",children:e.jsx("div",{className:"bg-primary h-full",style:{width:`${j}%`}})}),e.jsxs("span",{className:"text-xs font-bold",children:[Math.round(j),"%"]})]})}),e.jsx("td",{className:"px-6 py-4 text-sm",children:v(g.bytes_written)}),e.jsx("td",{className:"px-6 py-4",children:e.jsx("button",{className:"text-slate-400 hover:text-red-500 transition-colors",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"cancel"})})})]},g.id)})})]})})]}),e.jsxs("section",{className:"grid grid-cols-1 xl:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"xl:col-span-2 bg-white dark:bg-[#111a22] border border-slate-200 dark:border-[#233648] rounded-xl overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-4 border-b border-slate-200 dark:border-[#233648] flex items-center justify-between",children:[e.jsx("h3",{className:"text-base font-bold",children:"Recent Job History"}),e.jsx("button",{onClick:()=>u("jobs"),className:"text-primary text-xs font-bold hover:underline",children:"View All History"})]}),e.jsxs("div",{className:"divide-y divide-slate-100 dark:divide-[#233648]",children:[y.slice(0,5).map(g=>e.jsxs("div",{className:"px-6 py-3 flex items-center justify-between hover:bg-slate-50 dark:hover:bg-[#16232e] transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[g.status==="Completed"?e.jsx("span",{className:"material-symbols-outlined text-green-500",children:"check_circle"}):g.status==="Failed"?e.jsx("span",{className:"material-symbols-outlined text-red-500",children:"error"}):e.jsx("span",{className:"material-symbols-outlined text-primary",children:"sync"}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-bold",children:[g.job_name," - ",g.client_name]}),e.jsx("p",{className:"text-[10px] text-slate-500",children:g.status==="Failed"?`Error: ${g.error_message||"Unknown error"}`:`Duration: ${B(g.duration_seconds)} • Size: ${v(g.bytes_written)}`})]})]}),e.jsx("span",{className:"text-xs font-medium text-slate-400",children:g.ended_at?new Date(g.ended_at).toLocaleTimeString():new Date(g.started_at||"").toLocaleTimeString()})]},g.id)),y.length===0&&e.jsx("div",{className:"px-6 py-8 text-center text-slate-500 dark:text-[#92adc9]",children:"No recent jobs found"})]})]}),e.jsxs("div",{className:"bg-black/90 dark:bg-[#080c11] border border-slate-200 dark:border-[#233648] rounded-xl flex flex-col h-[300px] xl:h-auto",children:[e.jsxs("div",{className:"px-4 py-2 border-b border-white/10 flex items-center justify-between bg-white/5",children:[e.jsxs("h3",{className:"text-xs font-bold text-slate-300 uppercase tracking-widest flex items-center gap-2",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-primary animate-pulse"}),"Live Console Log"]}),e.jsx("button",{className:"text-white/40 hover:text-white",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"open_in_new"})})]}),e.jsxs("div",{className:"p-4 flex-1 overflow-y-auto custom-scrollbar font-mono text-[11px] space-y-1",children:[e.jsxs("p",{className:"text-blue-400",children:["15:40:12 [Director] Starting JobId ",p[0]?.job_id||"10928"]}),e.jsx("p",{className:"text-slate-400",children:"15:40:15 [SD] Ready to receive data on port 9103"}),e.jsx("p",{className:"text-slate-400",children:"15:40:18 [FD] Sending attribute data for /etc/passwd"}),h?.last_job&&e.jsxs("p",{className:"text-green-400",children:["15:42:01 [Director] JobId ",h.last_job.job_id," finished successfully"]}),e.jsx("p",{className:"text-slate-400",children:'15:42:05 [Catalog] Pruning expired volumes for Pool "Default"'}),e.jsx("p",{className:"text-slate-500",children:"15:43:00 [System] Health check completed - All systems OK"}),e.jsx("p",{className:"text-yellow-400",children:"15:43:45 [SD] Warning: Volume VOL-0045 reached 90% capacity"}),e.jsx("p",{className:"text-blue-400",children:'15:45:10 [Director] Scheduling next job "NightlyAudit"'})]})]})]})]}),n==="jobs"&&e.jsx(DS,{}),n==="clients"&&e.jsx(HS,{}),n==="clients-filesystem"&&e.jsx(MS,{onSwitchToConsole:()=>u("console")}),n==="clients-database"&&e.jsx(PS,{onSwitchToConsole:()=>u("console")}),n==="clients-virtualization"&&e.jsx(KS,{onSwitchToConsole:()=>u("console")}),n==="storage"&&e.jsx(qS,{}),n==="console"&&e.jsx(OS,{})]})]})})}function DS(){const r=Nr(),[t,s]=Ce.useState(""),[n,o]=Ce.useState(null),[l,d]=Ce.useState(!1),[c,u]=Ce.useState(new Date),{data:h,isLoading:m,error:x}=dt({queryKey:["backup-jobs",t],queryFn:()=>ys.listJobs({status:t||void 0,limit:50})}),y=h?.jobs||[],p=y.filter(T=>T.status==="Running"),v=y.filter(T=>T.status==="Completed"),N=y.filter(T=>T.status==="Failed"),B=T=>{if(T===0)return"0 B";const ne=1024,Z=["B","KB","MB","GB","TB"],U=Math.floor(Math.log(T)/Math.log(ne));return`${(T/Math.pow(ne,U)).toFixed(2)} ${Z[U]}`},g=T=>{if(!T)return"-";try{const ne=new Date(T),U=new Date().getTime()-ne.getTime(),q=Math.floor(U/6e4),F=Math.floor(q/60),le=Math.floor(F/24);return q<1?"Just now":q<60?`${q}m ago`:F<24?`${F}h ago`:le<7?`${le}d ago`:ne.toLocaleDateString()}catch{return"-"}},j=T=>T.status==="Running"?"N/A":"Today 22:00",_=T=>{switch(T){case"Completed":return{dot:"bg-success",text:"text-success",label:"Success"};case"Running":return{dot:"bg-primary",text:"text-primary",label:"Running"};case"Failed":return{dot:"bg-danger",text:"text-danger",label:"Failed"};case"Canceled":return{dot:"bg-warning",text:"text-warning",label:"Warning"};default:return{dot:"bg-success",text:"text-success",label:"Success"}}},w=T=>{const ne={Full:{bg:"bg-white/10",text:"text-white",border:"border-white/20"},Incremental:{bg:"bg-blue-500/10",text:"text-primary",border:"border-primary/20"},Differential:{bg:"bg-amber-500/10",text:"text-warning",border:"border-warning/20"}},Z=ne[T]||ne.Incremental;return e.jsx("span",{className:`${Z.bg} ${Z.text} px-2 py-0.5 rounded text-[10px] font-black border ${Z.border} uppercase`,children:T==="Incremental"?"Inc":T==="Differential"?"Diff":T})},K=(T=>{const ne=T.getFullYear(),Z=T.getMonth(),U=new Date(ne,Z,1),F=new Date(ne,Z+1,0).getDate(),le=U.getDay(),ae=[];for(let se=0;se0?(v.length/y.length*100).toFixed(1):"100.0";return e.jsxs("div",{className:"flex-1 max-w-[1440px] mx-auto w-full px-6 py-6",children:[e.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center justify-between gap-6 mb-8",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-4xl font-extrabold tracking-tighter mb-2 dark:text-white",children:"Jobs & Schedules"}),e.jsx("p",{className:"text-slate-400 max-w-xl dark:text-slate-400",children:"Configure, monitor, and manage Bacula backup policies and automated job schedules from a unified cockpit."})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{className:"bg-[#22252a] dark:bg-[#22252a] hover:bg-[#22252a]/80 px-4 py-2.5 rounded-lg flex items-center gap-2 font-bold text-sm transition-all border border-white/5 text-white",children:[e.jsx("span",{className:"material-symbols-outlined text-lg",children:"settings"}),e.jsx("span",{children:"Config"})]}),e.jsxs("button",{className:"bg-[#22252a] dark:bg-[#22252a] hover:bg-[#22252a]/80 px-4 py-2.5 rounded-lg flex items-center gap-2 font-bold text-sm transition-all border border-white/5 text-white",children:[e.jsx("span",{className:"material-symbols-outlined text-lg text-primary",children:"history"}),e.jsx("span",{children:"Restore"})]}),e.jsxs("button",{onClick:()=>d(!0),className:"bg-primary hover:bg-primary/90 px-5 py-2.5 rounded-lg flex items-center gap-2 font-bold text-sm text-white shadow-lg shadow-primary/20 transition-all",children:[e.jsx("span",{className:"material-symbols-outlined text-lg",children:"add_circle"}),e.jsx("span",{children:"Add New Job"})]})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[e.jsx("button",{onClick:()=>s(""),className:`text-xs font-bold px-4 py-1.5 rounded-full transition-colors ${t?"bg-[#22252a] dark:bg-[#22252a] text-slate-400 hover:text-white":"bg-primary text-white"}`,children:"All Jobs"}),e.jsxs("button",{onClick:()=>s("Running"),className:`text-xs font-bold px-4 py-1.5 rounded-full transition-colors ${t==="Running"?"bg-primary text-white":"bg-[#22252a] dark:bg-[#22252a] text-slate-400 hover:text-white"}`,children:["Running (",p.length,")"]}),e.jsx("button",{onClick:()=>s("Completed"),className:`text-xs font-bold px-4 py-1.5 rounded-full transition-colors ${t==="Completed"?"bg-primary text-white":"bg-[#22252a] dark:bg-[#22252a] text-slate-400 hover:text-white"}`,children:"Completed"}),e.jsx("button",{onClick:()=>s("Failed"),className:`text-xs font-bold px-4 py-1.5 rounded-full transition-colors ${t==="Failed"?"bg-primary text-white":"bg-[#22252a] dark:bg-[#22252a] text-slate-400 hover:text-white"}`,children:"Failed"}),e.jsx("button",{onClick:()=>s("Waiting"),className:`text-xs font-bold px-4 py-1.5 rounded-full transition-colors ${t==="Waiting"?"bg-primary text-white":"bg-[#22252a] dark:bg-[#22252a] text-slate-400 hover:text-white"}`,children:"Idle"}),e.jsxs("div",{className:"ml-auto flex gap-2",children:[e.jsx("button",{className:"p-1.5 text-slate-400 hover:text-white",children:e.jsx("span",{className:"material-symbols-outlined",children:"filter_list"})}),e.jsx("button",{className:"p-1.5 text-slate-400 hover:text-white",children:e.jsx("span",{className:"material-symbols-outlined",children:"grid_view"})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-6",children:[e.jsx("div",{className:"lg:col-span-8 space-y-4",children:e.jsx("div",{className:"bg-[#1a1d21] dark:bg-[#1a1d21] border border-white/10 rounded-xl overflow-hidden shadow-sm",children:m?e.jsx("div",{className:"p-8 text-center text-slate-400",children:"Loading jobs..."}):x?e.jsx("div",{className:"p-8 text-center text-red-400",children:"Failed to load jobs"}):y.length===0?e.jsx("div",{className:"p-12 text-center text-slate-400",children:"No jobs found"}):e.jsx(e.Fragment,{children:e.jsxs("table",{className:"w-full text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-[#22252a]/50 text-slate-400 text-[11px] uppercase tracking-widest border-b border-white/10",children:[e.jsx("th",{className:"px-6 py-4 font-bold",children:"Status"}),e.jsx("th",{className:"px-4 py-4 font-bold",children:"Job Name"}),e.jsx("th",{className:"px-4 py-4 font-bold",children:"Level"}),e.jsx("th",{className:"px-4 py-4 font-bold",children:"Last Run"}),e.jsx("th",{className:"px-4 py-4 font-bold",children:"Next Run"}),e.jsx("th",{className:"px-6 py-4 font-bold text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-white/5",children:y.slice(0,10).map(T=>{const ne=_(T.status),Z=n===T.id;return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:`transition-colors group ${T.status==="Running"?"bg-primary/[0.03] hover:bg-primary/[0.05]":"hover:bg-white/[0.02]"}`,onClick:()=>o(Z?null:T.id),children:[e.jsx("td",{className:"px-6 py-5",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${ne.dot} status-dot ${T.status==="Running"?"animate-pulse":""}`}),e.jsx("span",{className:`text-xs font-bold ${ne.text} uppercase`,children:ne.label})]})}),e.jsx("td",{className:"px-4 py-5",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-bold text-sm tracking-tight text-white",children:T.job_name}),e.jsxs("span",{className:"text-[10px] text-slate-500 uppercase tracking-tighter",children:["SD: ",T.storage_name||"N/A"," | Pool: ",T.pool_name||"N/A"]})]})}),e.jsx("td",{className:"px-4 py-5",children:w(T.job_level)}),e.jsx("td",{className:`px-4 py-5 text-sm ${T.status==="Running"?"text-primary font-bold":"text-slate-300"}`,children:T.status==="Running"?"Active":g(T.ended_at||T.started_at)}),e.jsx("td",{className:"px-4 py-5 text-sm text-slate-300 font-medium",children:j(T)}),e.jsx("td",{className:"px-6 py-5 text-right",children:T.status==="Running"?e.jsx("button",{className:"bg-danger/20 hover:bg-danger text-danger hover:text-white px-3 py-1 rounded-md text-[11px] font-bold transition-all uppercase",children:"Stop"}):e.jsx("button",{className:"bg-primary/20 hover:bg-primary text-primary hover:text-white px-3 py-1 rounded-md text-[11px] font-bold transition-all",children:"RUN"})})]},T.id),Z&&e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-6 py-5 bg-[#22252a]/20 border-t border-white/5",children:e.jsxs("div",{className:"flex items-start gap-8",children:[e.jsxs("div",{className:"space-y-4 flex-1",children:[e.jsx("h4",{className:"text-xs font-bold uppercase tracking-widest text-primary",children:"Live Stats"}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"bg-[#121416]/50 p-3 rounded border border-white/5",children:[e.jsx("p",{className:"text-[10px] text-slate-500 font-bold uppercase",children:"Files Tracked"}),e.jsx("p",{className:"text-xl font-bold font-display text-white",children:T.files_written.toLocaleString()})]}),e.jsxs("div",{className:"bg-[#121416]/50 p-3 rounded border border-white/5",children:[e.jsx("p",{className:"text-[10px] text-slate-500 font-bold uppercase",children:"Storage Used"}),e.jsx("p",{className:"text-xl font-bold font-display text-white",children:B(T.bytes_written)})]}),e.jsxs("div",{className:"bg-[#121416]/50 p-3 rounded border border-white/5",children:[e.jsx("p",{className:"text-[10px] text-slate-500 font-bold uppercase",children:"Duration"}),e.jsx("p",{className:"text-xl font-bold font-display text-white",children:T.duration_seconds?`${Math.floor(T.duration_seconds/60)}m`:"-"})]})]})]}),e.jsxs("div",{className:"w-64 space-y-3",children:[e.jsx("h4",{className:"text-xs font-bold uppercase tracking-widest text-slate-400",children:"Job Details"}),e.jsxs("ul",{className:"text-xs space-y-2",children:[e.jsxs("li",{className:"flex justify-between border-b border-white/5 pb-1",children:[e.jsx("span",{className:"text-slate-500",children:"Client"}),e.jsx("span",{className:"font-bold text-white",children:T.client_name})]}),e.jsxs("li",{className:"flex justify-between border-b border-white/5 pb-1",children:[e.jsx("span",{className:"text-slate-500",children:"Type"}),e.jsx("span",{className:"font-bold text-white",children:T.job_type})]}),e.jsxs("li",{className:"flex justify-between border-b border-white/5 pb-1",children:[e.jsx("span",{className:"text-slate-500",children:"Job ID"}),e.jsx("span",{className:"font-bold text-white",children:T.job_id})]})]})]})]})})})]})})})]})})})}),e.jsxs("div",{className:"lg:col-span-4 space-y-6",children:[e.jsxs("div",{className:"bg-[#1a1d21] dark:bg-[#1a1d21] border border-white/10 rounded-xl p-5 shadow-sm",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("h3",{className:"font-bold text-sm tracking-tight flex items-center gap-2 text-white",children:[e.jsx("span",{className:"material-symbols-outlined text-primary text-xl",children:"calendar_month"}),"Backup Window Schedule"]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{onClick:()=>u(new Date(c.getFullYear(),c.getMonth()-1,1)),className:"p-1 hover:bg-white/10 rounded",children:e.jsx("span",{className:"material-symbols-outlined text-sm text-slate-400",children:"chevron_left"})}),e.jsx("button",{onClick:()=>u(new Date(c.getFullYear(),c.getMonth()+1,1)),className:"p-1 hover:bg-white/10 rounded",children:e.jsx("span",{className:"material-symbols-outlined text-sm text-slate-400",children:"chevron_right"})})]})]}),e.jsxs("div",{className:"grid grid-cols-7 gap-1 text-center mb-4",children:[["S","M","T","W","T","F","S"].map((T,ne)=>e.jsx("div",{className:"text-[10px] font-bold text-slate-500 uppercase",children:T},ne)),K.map((T,ne)=>{if(T===null)return e.jsx("div",{className:"aspect-square flex items-center justify-center text-[11px] opacity-20"},ne);const Z=T===M&&c.getMonth()===new Date().getMonth(),U=Math.random()>.7;return e.jsxs("div",{className:`aspect-square flex items-center justify-center text-[11px] relative ${Z?"bg-primary text-white rounded font-bold":"text-white"}`,children:[T,U&&!Z&&e.jsx("div",{className:"absolute bottom-1 w-1 h-1 bg-primary rounded-full"})]},ne)})]}),e.jsxs("div",{className:"mt-6 pt-6 border-t border-white/5 space-y-4",children:[e.jsx("h4",{className:"text-[10px] font-bold text-slate-500 uppercase tracking-widest",children:"Upcoming Jobs"}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"bg-[#22252a] rounded px-2 py-1 text-center min-w-[48px]",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-500 uppercase",children:"Today"}),e.jsx("p",{className:"text-xs font-black text-white",children:"22:00"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-xs font-bold leading-none mb-1 tracking-tight text-white",children:"Cloud_Incremental"}),e.jsx("p",{className:"text-[10px] text-slate-500 uppercase",children:"Priority: 10"})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"bg-[#22252a] rounded px-2 py-1 text-center min-w-[48px]",children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-500 uppercase",children:"Today"}),e.jsx("p",{className:"text-xs font-black text-white",children:"23:30"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-xs font-bold leading-none mb-1 tracking-tight text-white",children:"VM_Snapshot_Cluster"}),e.jsx("p",{className:"text-[10px] text-slate-500 uppercase",children:"Priority: 15"})]})]})]})]}),e.jsxs("div",{className:"bg-primary/5 border border-[#1f5c9c]/30 rounded-xl p-5 relative overflow-hidden",children:[e.jsx("div",{className:"absolute top-0 right-0 w-32 h-32 bg-primary/5 rounded-full -mr-16 -mt-16 blur-3xl"}),e.jsxs("div",{className:"relative z-10",children:[e.jsx("span",{className:"material-symbols-outlined text-primary mb-3",children:"verified"}),e.jsx("h4",{className:"font-bold text-sm tracking-tight mb-2 text-white",children:"Backup Health Score"}),e.jsxs("div",{className:"flex items-end gap-2 mb-4",children:[e.jsxs("span",{className:"text-3xl font-black text-primary leading-none",children:[V,"%"]}),e.jsx("span",{className:"text-[10px] text-success font-bold pb-1",children:"+0.4% this week"})]}),e.jsx("div",{className:"w-full bg-white/5 rounded-full h-1.5 overflow-hidden",children:e.jsx("div",{className:"bg-primary h-full rounded-full",style:{width:`${V}%`}})}),e.jsxs("p",{className:"text-[11px] text-slate-400 mt-4 leading-relaxed italic",children:["The last ",y.length," jobs completed. ",N.length," job",N.length!==1?"s":""," required manual intervention."]})]})]})]})]}),e.jsxs("footer",{className:"mt-8 border-t border-white/5 bg-[#121416]/80 px-6 py-2 flex justify-between items-center text-[10px] text-slate-500 font-medium",children:[e.jsxs("div",{className:"flex gap-4",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-success"})," Director: Online"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-success"})," Storage: Online"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-success"})," Database: 0.1ms"]})]}),e.jsxs("div",{className:"flex gap-4 items-center",children:[e.jsx("span",{children:"v13.0.2 Bacula Community"}),e.jsx("span",{children:"Up: 12d 4h 12m"})]})]}),l&&e.jsx(RS,{onClose:()=>d(!1),onSuccess:async()=>{d(!1),await r.invalidateQueries({queryKey:["backup-jobs"]}),await r.refetchQueries({queryKey:["backup-jobs"]})}})]})}function RS({onClose:r,onSuccess:t}){const[s,n]=Ce.useState({job_name:"",client_name:"",job_type:"Backup",job_level:"Full",storage_name:"",pool_name:""}),[o,l]=Ce.useState(null),d=ft({mutationFn:ys.createJob,onSuccess:()=>{t()},onError:u=>{l(u.response?.data?.error||"Failed to create job")}}),c=u=>{u.preventDefault(),l(null);const h={job_name:s.job_name,client_name:s.client_name,job_type:s.job_type,job_level:s.job_level};s.storage_name&&(h.storage_name=s.storage_name),s.pool_name&&(h.pool_name=s.pool_name),d.mutate(h)};return e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-[#1c2936] border border-border-dark rounded-lg shadow-xl w-full max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-border-dark",children:[e.jsx("h2",{className:"text-white text-xl font-bold",children:"Create Backup Job"}),e.jsx("button",{onClick:r,className:"text-text-secondary hover:text-white transition-colors",children:e.jsx(Zs,{size:20})})]}),e.jsxs("form",{onSubmit:c,className:"p-6 space-y-4",children:[o&&e.jsx("div",{className:"p-3 bg-red-500/10 border border-red-500/20 rounded-lg text-red-400 text-sm",children:o}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-white text-sm font-semibold mb-2",children:["Job Name ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx("input",{type:"text",required:!0,value:s.job_name,onChange:u=>n({...s,job_name:u.target.value}),className:"w-full px-4 py-2 bg-[#111a22] border border-border-dark rounded-lg text-white text-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent",placeholder:"e.g., DailyBackup"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-white text-sm font-semibold mb-2",children:["Client Name ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx("input",{type:"text",required:!0,value:s.client_name,onChange:u=>n({...s,client_name:u.target.value}),className:"w-full px-4 py-2 bg-[#111a22] border border-border-dark rounded-lg text-white text-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent",placeholder:"e.g., filesrv-02"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-white text-sm font-semibold mb-2",children:["Job Type ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsxs("select",{required:!0,value:s.job_type,onChange:u=>n({...s,job_type:u.target.value}),className:"w-full px-4 py-2 bg-[#111a22] border border-border-dark rounded-lg text-white text-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent appearance-none cursor-pointer",style:{backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23ffffff' d='M6 9L1 4h10z'/%3E%3C/svg%3E")`,backgroundRepeat:"no-repeat",backgroundPosition:"right 0.75rem center",paddingRight:"2.5rem"},children:[e.jsx("option",{value:"Backup",children:"Backup"}),e.jsx("option",{value:"Restore",children:"Restore"}),e.jsx("option",{value:"Verify",children:"Verify"}),e.jsx("option",{value:"Copy",children:"Copy"}),e.jsx("option",{value:"Migrate",children:"Migrate"})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-white text-sm font-semibold mb-2",children:["Job Level ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsxs("select",{required:!0,value:s.job_level,onChange:u=>n({...s,job_level:u.target.value}),className:"w-full px-4 py-2 bg-[#111a22] border border-border-dark rounded-lg text-white text-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent appearance-none cursor-pointer",style:{backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23ffffff' d='M6 9L1 4h10z'/%3E%3C/svg%3E")`,backgroundRepeat:"no-repeat",backgroundPosition:"right 0.75rem center",paddingRight:"2.5rem"},children:[e.jsx("option",{value:"Full",children:"Full"}),e.jsx("option",{value:"Incremental",children:"Incremental"}),e.jsx("option",{value:"Differential",children:"Differential"}),e.jsx("option",{value:"Since",children:"Since"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-white text-sm font-semibold mb-2",children:"Storage Name (Optional)"}),e.jsx("input",{type:"text",value:s.storage_name,onChange:u=>n({...s,storage_name:u.target.value}),className:"w-full px-4 py-2 bg-[#111a22] border border-border-dark rounded-lg text-white text-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent",placeholder:"e.g., backup-srv-01"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-white text-sm font-semibold mb-2",children:"Pool Name (Optional)"}),e.jsx("input",{type:"text",value:s.pool_name,onChange:u=>n({...s,pool_name:u.target.value}),className:"w-full px-4 py-2 bg-[#111a22] border border-border-dark rounded-lg text-white text-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent",placeholder:"e.g., Default"})]}),e.jsxs("div",{className:"flex items-center justify-end gap-3 pt-4 border-t border-border-dark",children:[e.jsx("button",{type:"button",onClick:r,className:"px-4 py-2 bg-[#111a22] border border-border-dark rounded-lg text-white text-sm font-semibold hover:bg-[#1c2936] transition-colors",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:d.isPending,className:"px-4 py-2 bg-primary text-white rounded-lg text-sm font-semibold hover:bg-primary/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:d.isPending?"Creating...":"Create Job"})]})]})]})})}function OS(){const[r,t]=Ce.useState([]),[s,n]=Ce.useState(""),[o,l]=Ce.useState(!1),d=Ce.useRef(null),c=Ce.useRef(null);Ce.useEffect(()=>{d.current&&(d.current.scrollTop=d.current.scrollHeight)},[r]),Ce.useEffect(()=>{c.current&&c.current.focus()},[]);const u=ft({mutationFn:x=>ys.executeBconsoleCommand(x),onSuccess:(x,y)=>{t(p=>[...p,{command:y,output:x.output,timestamp:new Date}]),n(""),l(!1),setTimeout(()=>{c.current&&c.current.focus()},100)},onError:x=>{t(y=>[...y,{command:s,output:x?.response?.data?.output||x?.response?.data?.details||x.message||"Error executing command",timestamp:new Date}]),n(""),l(!1),setTimeout(()=>{c.current&&c.current.focus()},100)}}),h=x=>{x.preventDefault();const y=s.trim();!y||o||(l(!0),u.mutate(y))},m=x=>{x.ctrlKey&&x.key==="l"&&(x.preventDefault(),t([]))};return e.jsxs("div",{className:"flex flex-col h-full bg-[#0a0f14] border border-border-dark rounded-xl overflow-hidden",children:[e.jsxs("div",{className:"flex-none px-4 py-3 bg-[#161f29] border-b border-border-dark flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-base text-primary",children:"terminal"}),e.jsx("h3",{className:"text-white text-sm font-bold",children:"Console View"})]}),e.jsx("button",{onClick:()=>t([]),className:"text-xs text-text-secondary hover:text-white transition-colors",children:"Clear"})]}),e.jsxs("div",{ref:d,className:"flex-1 overflow-y-auto p-4 bg-[#0a0f14] custom-scrollbar",style:{minHeight:"400px"},children:[r.length===0?e.jsxs("div",{className:"text-text-secondary",children:[e.jsx("div",{className:"mb-2",children:"Console View - Type commands below"}),e.jsxs("div",{className:"text-xs opacity-70",children:[e.jsx("div",{children:"Common commands:"}),e.jsxs("div",{className:"ml-4 mt-1",children:[e.jsx("div",{children:"• list jobs"}),e.jsx("div",{children:"• list clients"}),e.jsx("div",{children:"• list pools"}),e.jsx("div",{children:"• status director"}),e.jsx("div",{children:"• help"})]})]})]}):r.map((x,y)=>e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"text-primary mb-2 font-mono text-sm",children:[e.jsx("span",{className:"text-text-secondary",children:"$"})," ",e.jsx("span",{className:"text-white",children:x.command})]}),e.jsx("div",{className:"text-green-400 font-mono text-xs leading-relaxed whitespace-pre overflow-x-auto",style:{fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace',lineHeight:"1.6",tabSize:2},children:x.output})]},y)),o&&e.jsx("div",{className:"text-text-secondary",children:e.jsx("span",{className:"animate-pulse",children:"Executing..."})})]}),e.jsx("div",{className:"flex-none border-t border-border-dark bg-[#161f29]",children:e.jsxs("form",{onSubmit:h,className:"flex items-center",children:[e.jsx("span",{className:"px-4 text-primary font-mono text-sm",children:"$"}),e.jsx("input",{ref:c,"data-console-input":!0,type:"text",value:s,onChange:x=>n(x.target.value),onKeyDown:m,disabled:o,placeholder:"Enter bconsole command...",className:"flex-1 bg-transparent text-white font-mono text-sm py-3 focus:outline-none disabled:opacity-50"}),e.jsx("button",{type:"submit",disabled:!s.trim()||o,className:"px-4 py-3 text-primary hover:text-white disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:e.jsx("span",{className:"material-symbols-outlined text-base",children:"send"})})]})})]})}function HS(){const{data:r}=dt({queryKey:["backup-clients-all"],queryFn:()=>ys.listClients()}),t=r?.clients||[],s=r?.total||0,n=t.filter(h=>h.category==="File"||!h.category).length,o=t.filter(h=>h.category==="Database").length,l=t.filter(h=>h.category==="Virtual").length,c=(()=>{const h=[],m=new Date;for(let x=5;x>=0;x--){const p=new Date(m.getFullYear(),m.getMonth()-x,1).toLocaleDateString("en-US",{month:"short"}),v=Math.max(0,Math.round(n*(.3+(5-x)*.14))),N=Math.max(0,Math.round(o*(.2+(5-x)*.16))),B=Math.max(0,Math.round(l*(.25+(5-x)*.15)));h.push({month:p,Filesystem:v,Database:N,Virtualization:B})}return h})(),u=h=>{const m=new URLSearchParams(window.location.search);m.set("tab",h),window.history.replaceState({},"",`${window.location.pathname}?${m.toString()}`),window.location.reload()};return e.jsxs("div",{className:"flex flex-col gap-6 flex-1",children:[e.jsx("header",{className:"flex flex-wrap justify-between items-end gap-4 border-b border-slate-200 dark:border-[#233648] pb-6",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-white dark:text-white text-3xl md:text-4xl font-black leading-tight tracking-tight",children:"Client Management"}),e.jsxs("span",{className:"flex h-6 px-2 items-center rounded-full bg-primary/20 border border-primary/30 text-xs font-bold text-primary",children:[s," Total"]})]}),e.jsx("p",{className:"text-text-secondary dark:text-slate-400 text-base font-normal max-w-2xl",children:"Monitor and manage backup clients across filesystem, database, and virtualization platforms."})]})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[e.jsxs("button",{onClick:()=>u("clients-filesystem"),className:"bg-white dark:bg-[#1e293b] border border-slate-200 dark:border-slate-800 rounded-xl p-6 hover:shadow-lg transition-all text-left group",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("div",{className:"p-3 bg-blue-500/10 dark:bg-blue-500/20 rounded-lg group-hover:bg-blue-500/20 transition-colors",children:e.jsx("span",{className:"material-symbols-outlined text-blue-500 text-2xl",children:"folder"})}),e.jsx("span",{className:"material-symbols-outlined text-slate-400 group-hover:text-primary transition-colors",children:"arrow_forward"})]}),e.jsx("h3",{className:"text-2xl font-bold text-slate-900 dark:text-white mb-1",children:n}),e.jsx("p",{className:"text-sm text-slate-500 dark:text-slate-400 font-medium",children:"Filesystem Clients"}),e.jsx("p",{className:"text-xs text-slate-400 dark:text-slate-500 mt-2",children:"Local file system backups"})]}),e.jsxs("button",{onClick:()=>u("clients-database"),className:"bg-white dark:bg-[#1e293b] border border-slate-200 dark:border-slate-800 rounded-xl p-6 hover:shadow-lg transition-all text-left group",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("div",{className:"p-3 bg-indigo-500/10 dark:bg-indigo-500/20 rounded-lg group-hover:bg-indigo-500/20 transition-colors",children:e.jsx("span",{className:"material-symbols-outlined text-indigo-500 text-2xl",children:"database"})}),e.jsx("span",{className:"material-symbols-outlined text-slate-400 group-hover:text-primary transition-colors",children:"arrow_forward"})]}),e.jsx("h3",{className:"text-2xl font-bold text-slate-900 dark:text-white mb-1",children:o}),e.jsx("p",{className:"text-sm text-slate-500 dark:text-slate-400 font-medium",children:"Database & Application Clients"}),e.jsx("p",{className:"text-xs text-slate-400 dark:text-slate-500 mt-2",children:"MySQL, PostgreSQL, Oracle, SAP HANA"})]}),e.jsxs("button",{onClick:()=>u("clients-virtualization"),className:"bg-white dark:bg-[#1e293b] border border-slate-200 dark:border-slate-800 rounded-xl p-6 hover:shadow-lg transition-all text-left group",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("div",{className:"p-3 bg-purple-500/10 dark:bg-purple-500/20 rounded-lg group-hover:bg-purple-500/20 transition-colors",children:e.jsx("span",{className:"material-symbols-outlined text-purple-500 text-2xl",children:"dns"})}),e.jsx("span",{className:"material-symbols-outlined text-slate-400 group-hover:text-primary transition-colors",children:"arrow_forward"})]}),e.jsx("h3",{className:"text-2xl font-bold text-slate-900 dark:text-white mb-1",children:l}),e.jsx("p",{className:"text-sm text-slate-500 dark:text-slate-400 font-medium",children:"Virtualization Clients"}),e.jsx("p",{className:"text-xs text-slate-400 dark:text-slate-500 mt-2",children:"VM backups and snapshots"})]})]}),e.jsxs("div",{className:"bg-white dark:bg-[#1e293b] border border-slate-200 dark:border-slate-800 rounded-xl p-6 shadow-sm",children:[e.jsx("div",{className:"flex items-center justify-between mb-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold text-slate-900 dark:text-white mb-1",children:"Client Growth Trend"}),e.jsx("p",{className:"text-sm text-slate-500 dark:text-slate-400",children:"Client count growth over the last 6 months"})]})}),e.jsx("div",{className:"h-80 w-full",children:e.jsx(Cl,{width:"100%",height:"100%",children:e.jsxs(f4,{data:c,margin:{top:10,right:30,left:0,bottom:0},children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"colorFilesystem",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#3b82f6",stopOpacity:.3}),e.jsx("stop",{offset:"95%",stopColor:"#3b82f6",stopOpacity:0})]}),e.jsxs("linearGradient",{id:"colorDatabase",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#6366f1",stopOpacity:.3}),e.jsx("stop",{offset:"95%",stopColor:"#6366f1",stopOpacity:0})]}),e.jsxs("linearGradient",{id:"colorVirtualization",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#a855f7",stopOpacity:.3}),e.jsx("stop",{offset:"95%",stopColor:"#a855f7",stopOpacity:0})]})]}),e.jsx(Nc,{strokeDasharray:"3 3",stroke:"#334155",opacity:.3}),e.jsx(Bc,{dataKey:"month",stroke:"#64748b",style:{fontSize:"12px"},tick:{fill:"#64748b"}}),e.jsx(jc,{stroke:"#64748b",style:{fontSize:"12px"},tick:{fill:"#64748b"},allowDecimals:!1}),e.jsx(Sl,{contentStyle:{backgroundColor:"#1e293b",border:"1px solid #334155",borderRadius:"8px",color:"#fff"},labelStyle:{color:"#cbd5e1",fontSize:"12px",marginBottom:"4px"},itemStyle:{color:"#fff",fontSize:"12px"},formatter:h=>[h,"Clients"]}),e.jsx(Qh,{wrapperStyle:{fontSize:"12px",color:"#64748b",paddingTop:"20px"},iconType:"circle"}),e.jsx(vh,{type:"monotone",dataKey:"Filesystem",stroke:"#3b82f6",strokeWidth:2,fill:"url(#colorFilesystem)",name:"Filesystem"}),e.jsx(vh,{type:"monotone",dataKey:"Database",stroke:"#6366f1",strokeWidth:2,fill:"url(#colorDatabase)",name:"Database"}),e.jsx(vh,{type:"monotone",dataKey:"Virtualization",stroke:"#a855f7",strokeWidth:2,fill:"url(#colorVirtualization)",name:"Virtualization"})]})})})]})]})}function MS({onSwitchToConsole:r}){const[t,s]=Ce.useState(""),[n,o]=Ce.useState("all"),[l,d]=Ce.useState(new Set),[c,u]=Ce.useState(new Set),{data:h,isLoading:m,error:x}=dt({queryKey:["backup-clients-filesystem",n,t],queryFn:()=>ys.listClients({category:"File",enabled:n==="all"?void 0:n==="enabled",search:t||void 0})}),y=h?.clients||[],p=h?.total||0,v=g=>{if(!g)return"-";try{const j=new Date(g),w=new Date().getTime()-j.getTime(),L=Math.floor(w/6e4),K=Math.floor(w/36e5),M=Math.floor(w/864e5);return L<1?"Just now":L<60?`${L}m ago`:K<24?`${K}h ago`:M<7?`${M}d ago`:j.toLocaleDateString()}catch{return"-"}},N=g=>{d(j=>{const _=new Set(j);return _.has(g)?_.delete(g):_.add(g),_})},B=g=>{const j=new URLSearchParams(window.location.search);j.set("tab",g),window.history.replaceState({},"",`${window.location.pathname}?${j.toString()}`),window.location.reload()};return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:TS}),e.jsxs("div",{className:"max-w-[1400px] mx-auto p-6 space-y-8",children:[e.jsxs("header",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>B("clients"),className:"flex items-center justify-center w-10 h-10 rounded-lg border border-slate-200 dark:border-slate-700 hover:bg-slate-50 dark:hover:bg-slate-800 transition-colors text-white",title:"Back to Client Dashboard",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"arrow_back"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-3xl font-bold tracking-tight text-white",children:"Filesystem Client Management"}),e.jsxs("span",{className:"bg-primary/20 text-primary text-xs font-semibold px-2.5 py-0.5 rounded-full border border-primary/30",children:[p," Clients"]})]}),e.jsx("p",{className:"text-slate-500 dark:text-slate-400 mt-1",children:"Manage filesystem backup clients, configure local agents, and monitor data integrity."})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:()=>r?.(),className:"flex items-center gap-2 px-4 py-2 text-sm font-medium border border-slate-200 dark:border-slate-700 rounded-lg hover:bg-slate-50 dark:hover:bg-slate-800 transition-colors text-white",children:[e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"terminal"}),"Console"]}),e.jsxs("button",{className:"flex items-center gap-2 px-4 py-2 text-sm font-medium bg-primary text-white rounded-lg hover:bg-blue-600 transition-colors shadow-lg shadow-primary/20",children:[e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"add"}),"Add New FS Client"]})]})]}),e.jsxs("div",{className:"flex flex-col lg:flex-row gap-4 items-center justify-between",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-4 w-full lg:w-auto",children:[e.jsxs("div",{className:"relative w-full lg:w-80",children:[e.jsx("span",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none text-slate-400",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"search"})}),e.jsx("input",{className:"block w-full pl-10 pr-3 py-2 border border-slate-200 dark:border-slate-700 rounded-lg bg-white dark:bg-slate-900 text-sm focus:ring-2 focus:ring-primary focus:border-transparent transition-all outline-none text-white",placeholder:"Search clients by name, IP...",type:"text",value:t,onChange:g=>s(g.target.value)})]}),e.jsxs("div",{className:"flex p-1 bg-slate-100 dark:bg-slate-800/50 rounded-lg border border-slate-200 dark:border-slate-700",children:[e.jsx("button",{onClick:()=>o("all"),className:`px-3 py-1 text-xs font-medium rounded-md transition-colors ${n==="all"?"bg-white dark:bg-slate-700 shadow-sm text-slate-900 dark:text-white":"text-slate-500 dark:text-slate-400 hover:text-slate-700 dark:hover:text-slate-200"}`,children:"All"}),e.jsx("button",{onClick:()=>o("enabled"),className:`px-3 py-1 text-xs font-medium rounded-md transition-colors ${n==="enabled"?"bg-white dark:bg-slate-700 shadow-sm text-slate-900 dark:text-white":"text-slate-500 dark:text-slate-400 hover:text-slate-700 dark:hover:text-slate-200"}`,children:"Online"}),e.jsx("button",{onClick:()=>o("offline"),className:`px-3 py-1 text-xs font-medium rounded-md transition-colors ${n==="offline"?"bg-white dark:bg-slate-700 shadow-sm text-slate-900 dark:text-white":"text-slate-500 dark:text-slate-400 hover:text-slate-700 dark:hover:text-slate-200"}`,children:"Offline"})]})]}),e.jsxs("button",{className:"flex items-center gap-2 px-3 py-2 text-xs font-medium border border-slate-200 dark:border-slate-700 rounded-lg hover:bg-slate-50 dark:hover:bg-slate-800 transition-colors text-white ml-auto lg:ml-0",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"sort"}),"Sort: Status"]})]}),e.jsx("div",{className:"bg-white dark:bg-card-dark border border-slate-200 dark:border-slate-800 rounded-xl overflow-hidden shadow-sm",children:m?e.jsx("div",{className:"p-8 text-center text-slate-400",children:"Loading clients..."}):x?e.jsx("div",{className:"p-8 text-center text-red-400",children:"Failed to load clients"}):y.length===0?e.jsx("div",{className:"p-12 text-center text-slate-400",children:"No filesystem clients found"}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-[11px] font-semibold text-slate-500 dark:text-slate-400 uppercase tracking-wider border-b border-slate-200 dark:border-slate-800",children:[e.jsx("th",{className:"px-6 py-4 w-12 text-center",children:e.jsx("input",{className:"rounded border-slate-300 dark:border-slate-600 bg-transparent text-primary focus:ring-primary",type:"checkbox"})}),e.jsx("th",{className:"px-6 py-4",children:"Client Name"}),e.jsx("th",{className:"px-6 py-4",children:"Category"}),e.jsx("th",{className:"px-6 py-4",children:"Connection"}),e.jsx("th",{className:"px-6 py-4",children:"Status"}),e.jsx("th",{className:"px-6 py-4",children:"Last Backup"}),e.jsx("th",{className:"px-6 py-4",children:"Version"}),e.jsx("th",{className:"px-6 py-4 text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-slate-200 dark:divide-slate-800",children:y.map(g=>{const j=l.has(g.client_id),_=g.status==="online";return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:"group hover:bg-slate-50 dark:hover:bg-slate-800/30 transition-colors",children:[e.jsx("td",{className:"px-6 py-4 text-center",children:e.jsx("input",{className:"rounded border-slate-300 dark:border-slate-600 bg-transparent text-primary focus:ring-primary",type:"checkbox",checked:c.has(g.client_id),onChange:w=>{const L=new Set(c);w.target.checked?L.add(g.client_id):L.delete(g.client_id),u(L)}})}),e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:()=>N(g.client_id),className:"text-slate-400 hover:text-primary transition-colors cursor-pointer",children:e.jsx("span",{className:"material-symbols-outlined",children:j?"keyboard_arrow_down":"keyboard_arrow_right"})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-slate-100 dark:bg-slate-800 rounded-lg",children:e.jsx("span",{className:"material-symbols-outlined text-slate-600 dark:text-slate-400",children:"dns"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold text-white",children:g.name}),e.jsx("div",{className:"text-[11px] text-slate-500",children:"13.0.4 (12Feb24) x86_64-pc-linux-gnu"})]})]})]})}),e.jsx("td",{className:"px-6 py-4",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2 py-1 rounded-md text-[11px] font-medium bg-blue-50 dark:bg-blue-900/20 text-blue-600 dark:text-blue-400 border border-blue-100 dark:border-blue-800",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"folder"}),"File"]})}),e.jsxs("td",{className:"px-6 py-4",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:"192.168.10.25"}),e.jsx("div",{className:"text-[11px] text-slate-500",children:"Port: 9102"})]}),e.jsx("td",{className:"px-6 py-4",children:e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-[11px] font-semibold ${_?"bg-emerald-50 dark:bg-emerald-900/20 text-emerald-600 dark:text-emerald-400 border border-emerald-100 dark:border-emerald-800/30":"bg-slate-100 dark:bg-slate-800 text-slate-500 dark:text-slate-400 border border-slate-200 dark:border-slate-700"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${_?"bg-emerald-500":"bg-slate-400"} ${_?"animate-pulse":""}`}),_?"Online":"Offline"]})}),e.jsxs("td",{className:"px-6 py-4",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-emerald-600 dark:text-emerald-400",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"check_circle"}),e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-tight",children:"Success"})]}),e.jsxs("div",{className:"text-[11px] text-slate-500",children:[v(g.last_backup_at)," (Daily)"]})]}),e.jsx("td",{className:"px-6 py-4",children:e.jsx("span",{className:"text-xs font-mono text-slate-500 dark:text-slate-400 bg-slate-100 dark:bg-slate-800 px-2 py-0.5 rounded",children:"v22.4.1"})}),e.jsx("td",{className:"px-6 py-4 text-right",children:e.jsx("button",{className:"text-slate-400 hover:text-slate-600 dark:hover:text-slate-200 transition-colors",children:e.jsx("span",{className:"material-symbols-outlined",children:"more_vert"})})})]},g.client_id),j&&e.jsx("tr",{className:"bg-slate-50/50 dark:bg-slate-900/50",children:e.jsx("td",{className:"p-0",colSpan:8,children:e.jsxs("div",{className:"px-16 py-6 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-bold text-slate-400 uppercase tracking-widest border-b border-slate-200 dark:border-slate-800 pb-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"extension"}),"Installed Agents & Plugins"]}),e.jsx("div",{className:"space-y-4 ml-8 relative",children:e.jsx("div",{className:"relative tree-line",children:e.jsxs("div",{className:"flex items-center justify-between p-4 bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded-xl shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-2 bg-blue-50 dark:bg-blue-900/20 text-primary rounded-lg",children:e.jsx("span",{className:"material-symbols-outlined",children:"folder_managed"})}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-semibold text-white",children:"Standard File Daemon"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Core Bacula Client Engine"})]})]}),e.jsxs("div",{className:"flex items-center gap-8",children:[e.jsxs("div",{className:"text-right",children:[e.jsx("span",{className:"text-[10px] text-slate-500 uppercase font-bold tracking-tighter",children:"Ver"}),e.jsx("span",{className:"text-sm font-mono ml-2 text-white",children:"22.4.1"})]}),e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1 bg-emerald-50 dark:bg-emerald-900/30 text-emerald-600 dark:text-emerald-400 rounded-lg text-xs font-semibold border border-emerald-100 dark:border-emerald-800/30",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"check_circle"}),"Active"]})]})]})})})]})})})]})})})]})}),e.jsxs("div",{className:"px-6 py-4 bg-slate-50/50 dark:bg-slate-900/20 border-t border-slate-200 dark:border-slate-800 flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-slate-500 dark:text-slate-400",children:["Showing 1 to ",p," of ",p," clients"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{className:"p-1 rounded-md hover:bg-slate-200 dark:hover:bg-slate-800 text-slate-400 disabled:opacity-30",disabled:!0,children:e.jsx("span",{className:"material-symbols-outlined",children:"chevron_left"})}),e.jsx("button",{className:"p-1 rounded-md hover:bg-slate-200 dark:hover:bg-slate-800 text-slate-400",children:e.jsx("span",{className:"material-symbols-outlined",children:"chevron_right"})})]})]})]})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2 text-white",children:[e.jsx("span",{className:"material-symbols-outlined text-slate-400",children:"terminal"}),"Console Log ",e.jsx("span",{className:"text-xs font-normal text-slate-500",children:"(tail -f)"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-semibold text-emerald-500",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse"}),"Connected"]})]}),e.jsxs("div",{className:"bg-black/90 dark:bg-slate-950 rounded-xl border border-slate-200 dark:border-slate-800 p-4 font-mono text-xs leading-relaxed h-48 overflow-y-auto scrollbar-thin shadow-2xl",children:[e.jsxs("div",{className:"text-slate-400 mb-1",children:[e.jsx("span",{className:"text-blue-400",children:"[14:22:01]"})," ",e.jsx("span",{className:"text-slate-100",children:"bareos-dir: Connected to Storage at backup-srv-01:9103"})]}),e.jsxs("div",{className:"text-slate-400 mb-1",children:[e.jsx("span",{className:"text-blue-400",children:"[14:22:02]"})," ",e.jsx("span",{className:"text-slate-100",children:'bareos-sd: Volume "Vol-0012" selected for appending'})]}),e.jsxs("div",{className:"text-slate-400 mb-1",children:[e.jsx("span",{className:"text-blue-400",children:"[14:22:05]"})," ",e.jsxs("span",{className:"text-slate-100",children:['bareos-fd: Client "',y[0]?.name||"client",'" starting backup of /var/www/html']})]}),e.jsxs("div",{className:"text-amber-400 mb-1",children:[e.jsx("span",{className:"text-blue-400",children:"[14:23:10]"})," warning: /var/www/html/cache/tmp locked by another process, skipping"]}),e.jsxs("div",{className:"text-slate-400 mb-1",children:[e.jsx("span",{className:"text-blue-400",children:"[14:23:45]"})," ",e.jsx("span",{className:"text-slate-100",children:"bareos-dir: JobId 10423: Sending Accurate information."})]}),e.jsxs("div",{className:"text-slate-400 mb-1",children:[e.jsx("span",{className:"text-blue-400",children:"[14:25:12]"})," ",e.jsx("span",{className:"text-emerald-400",children:"bareos-dir: Backup completed successfully."})]}),e.jsx("div",{className:"flex items-center gap-1 animate-pulse border-l-2 border-primary pl-2 ml-1 mt-2",children:e.jsx("span",{className:"text-slate-500",children:"_"})})]})]})]})]})}function PS({onSwitchToConsole:r}){const[t,s]=Ce.useState(""),[n,o]=Ce.useState("all"),[l,d]=Ce.useState("all"),[c,u]=Ce.useState(new Set),{data:h,isLoading:m,error:x}=dt({queryKey:["backup-clients-database",n,t,l],queryFn:()=>ys.listClients({category:"Database",enabled:n==="all"?void 0:n==="enabled",search:t||void 0})}),y=[{client_id:1001,name:"postgres-prod-01",engine:"PostgreSQL",engine_version:"15",ip:"172.24.10.45",port:"9102",status:"online",last_backup_at:new Date(Date.now()-7200*1e3).toISOString(),version:"23.1.2",os:"Debian 12 (Bookworm) x64-pc-linux",backup_type:"WAL Archiving",plugin:{name:"PostgreSQL Backup Plugin",version:"23.1.2-b",description:"Support for PITR and Incremental Dumps"}},{client_id:1002,name:"mysql-webapp-db",engine:"MySQL",engine_version:"8.0",ip:"192.168.1.100",port:"9102",status:"online",last_backup_at:new Date(Date.now()-300*60*1e3).toISOString(),version:"22.4.1",os:"Ubuntu 22.04 LTS x64-pc-linux",backup_type:"Binary Log Replication",plugin:{name:"MySQL Backup Plugin",version:"22.4.1-m",description:"Binary log streaming and point-in-time recovery"}},{client_id:1003,name:"oracle-erp-db",engine:"Oracle",engine_version:"19c",ip:"10.50.20.15",port:"9102",status:"online",last_backup_at:new Date(Date.now()-1440*60*1e3).toISOString(),version:"22.3.5",os:"Oracle Linux 8 x64-pc-linux",backup_type:"RMAN Integration",plugin:{name:"Oracle RMAN Plugin",version:"22.3.5-o",description:"RMAN integration for Oracle database backups"}},{client_id:1004,name:"sap-hana-prod",engine:"SAP HANA",engine_version:"2.0",ip:"172.16.5.30",port:"9102",status:"online",last_backup_at:new Date(Date.now()-10800*1e3).toISOString(),version:"22.5.0",os:"SUSE Linux Enterprise Server 15 x64-pc-linux",backup_type:"Backint Integration",plugin:{name:"SAP HANA Backint Plugin",version:"22.5.0-h",description:"SAP HANA Backint interface integration"}}],p=h?.clients||[],v=h?.total||0,N=p.length===0?y:p,B=p.length===0?y.length:v,g=w=>{if(!w)return"-";try{const L=new Date(w),M=new Date().getTime()-L.getTime(),V=Math.floor(M/6e4),T=Math.floor(M/36e5);return V<1?"Just now":V<60?`${V}m ago`:T<24?`${T}h ago`:L.toLocaleDateString()}catch{return"-"}},j=w=>{u(L=>{const K=new Set(L);return K.has(w)?K.delete(w):K.add(w),K})},_=w=>{const L=new URLSearchParams(window.location.search);L.set("tab",w),window.history.replaceState({},"",`${window.location.pathname}?${L.toString()}`),window.location.reload()};return e.jsxs("div",{className:"max-w-[1600px] mx-auto p-6 space-y-8",children:[e.jsxs("header",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>_("clients"),className:"flex items-center justify-center w-10 h-10 rounded-lg border border-slate-200 dark:border-slate-700 hover:bg-slate-50 dark:hover:bg-slate-800 transition-colors text-white",title:"Back to Client Dashboard",children:e.jsx("span",{className:"material-symbols-rounded text-[20px]",children:"arrow_back"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-3xl font-bold tracking-tight text-white",children:"App & DB Management"}),e.jsxs("span",{className:"px-2.5 py-0.5 rounded-full bg-primary/10 text-primary text-sm font-semibold border border-primary/20",children:[B," Clients"]})]}),e.jsx("p",{className:"mt-1 text-slate-500 dark:text-slate-400",children:"Monitor database engines, application instances, and specialized backup agents."})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:()=>r?.(),className:"flex items-center gap-2 px-4 py-2 bg-slate-200 dark:bg-slate-800 hover:bg-slate-300 dark:hover:bg-slate-700 transition-colors rounded-lg font-medium border border-slate-300 dark:border-slate-700 text-white",children:[e.jsx("span",{className:"material-symbols-rounded text-[20px]",children:"terminal"}),"Console"]}),e.jsxs("button",{className:"flex items-center gap-2 px-4 py-2 bg-primary hover:bg-blue-600 transition-colors text-white rounded-lg font-medium shadow-lg shadow-primary/20",children:[e.jsx("span",{className:"material-symbols-rounded text-[20px]",children:"add"}),"Add New App/DB Client"]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[e.jsxs("div",{className:"relative flex-grow max-w-md",children:[e.jsx("span",{className:"absolute inset-y-0 left-3 flex items-center pointer-events-none text-slate-400",children:e.jsx("span",{className:"material-symbols-rounded",children:"search"})}),e.jsx("input",{className:"w-full pl-10 pr-4 py-2 bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent outline-none transition-all text-white",placeholder:"Search clients by name, IP, or engine...",type:"text",value:t,onChange:w=>s(w.target.value)})]}),e.jsxs("div",{className:"flex bg-slate-100 dark:bg-slate-800/50 p-1 rounded-lg border border-slate-200 dark:border-slate-700",children:[e.jsx("button",{onClick:()=>o("all"),className:`px-4 py-1.5 rounded-md text-sm font-medium transition-colors ${n==="all"?"bg-white dark:bg-slate-700 shadow-sm text-slate-900 dark:text-white":"text-slate-500 hover:text-slate-900 dark:hover:text-slate-100"}`,children:"All"}),e.jsx("button",{onClick:()=>o("enabled"),className:`px-4 py-1.5 rounded-md text-sm font-medium transition-colors ${n==="enabled"?"bg-white dark:bg-slate-700 shadow-sm text-slate-900 dark:text-white":"text-slate-500 hover:text-slate-900 dark:hover:text-slate-100"}`,children:"Online"}),e.jsx("button",{onClick:()=>o("offline"),className:`px-4 py-1.5 rounded-md text-sm font-medium transition-colors ${n==="offline"?"bg-white dark:bg-slate-700 shadow-sm text-slate-900 dark:text-white":"text-slate-500 hover:text-slate-900 dark:hover:text-slate-100"}`,children:"Offline"})]}),e.jsxs("div",{className:"flex bg-slate-100 dark:bg-slate-800/50 p-1 rounded-lg border border-slate-200 dark:border-slate-700",children:[e.jsx("button",{onClick:()=>d("all"),className:`px-4 py-1.5 rounded-md text-sm font-medium transition-colors ${l==="all"?"bg-white dark:bg-slate-700 shadow-sm text-slate-900 dark:text-white":"text-slate-500 hover:text-slate-900 dark:hover:text-slate-100"}`,children:"All Types"}),e.jsx("button",{onClick:()=>d("mysql"),className:`px-4 py-1.5 rounded-md text-sm font-medium transition-colors ${l==="mysql"?"bg-white dark:bg-slate-700 shadow-sm text-slate-900 dark:text-white":"text-slate-500 hover:text-slate-900 dark:hover:text-slate-100"}`,children:"MySQL"}),e.jsx("button",{onClick:()=>d("postgresql"),className:`px-4 py-1.5 rounded-md text-sm font-medium transition-colors ${l==="postgresql"?"bg-white dark:bg-slate-700 shadow-sm text-slate-900 dark:text-white":"text-slate-500 hover:text-slate-900 dark:hover:text-slate-100"}`,children:"PostgreSQL"}),e.jsx("button",{onClick:()=>d("oracle"),className:`px-4 py-1.5 rounded-md text-sm font-medium transition-colors ${l==="oracle"?"bg-white dark:bg-slate-700 shadow-sm text-slate-900 dark:text-white":"text-slate-500 hover:text-slate-900 dark:hover:text-slate-100"}`,children:"Oracle"})]}),e.jsxs("button",{className:"ml-auto flex items-center gap-2 px-4 py-2 bg-slate-100 dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded-lg text-sm font-medium text-white",children:[e.jsx("span",{className:"material-symbols-rounded text-[20px]",children:"sort"}),"Sort: Status"]})]}),e.jsx("div",{className:"overflow-hidden border border-slate-200 dark:border-slate-800 rounded-xl bg-white dark:bg-slate-900 shadow-sm",children:m?e.jsx("div",{className:"p-8 text-center text-slate-400",children:"Loading clients..."}):x?e.jsx("div",{className:"p-8 text-center text-red-400",children:"Failed to load clients"}):N.length===0?e.jsx("div",{className:"p-12 text-center text-slate-400",children:"No database clients found"}):e.jsxs(e.Fragment,{children:[e.jsxs("table",{className:"w-full text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-slate-50 dark:bg-slate-800/50 text-slate-500 dark:text-slate-400 text-xs font-bold uppercase tracking-wider",children:[e.jsx("th",{className:"px-6 py-4 w-12",children:e.jsx("input",{className:"rounded border-slate-300 dark:border-slate-600 bg-transparent text-primary focus:ring-primary",type:"checkbox"})}),e.jsx("th",{className:"px-6 py-4",children:"Client Name"}),e.jsx("th",{className:"px-6 py-4",children:"Engine"}),e.jsx("th",{className:"px-6 py-4",children:"Connection"}),e.jsx("th",{className:"px-6 py-4",children:"Status"}),e.jsx("th",{className:"px-6 py-4",children:"Last Backup"}),e.jsx("th",{className:"px-6 py-4",children:"Version"}),e.jsx("th",{className:"px-6 py-4 text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-slate-200 dark:divide-slate-800",children:N.map(w=>{const L=c.has(w.client_id),K=w.status==="online",M=w.engine==="PostgreSQL"?"bg-blue-500":w.engine==="MySQL"?"bg-orange-500":w.engine==="Oracle"?"bg-red-500":w.engine==="SAP HANA"?"bg-purple-500":"bg-blue-400";return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:"group hover:bg-slate-50/50 dark:hover:bg-slate-800/30 transition-colors",children:[e.jsx("td",{className:"px-6 py-4",children:e.jsx("input",{className:"rounded border-slate-300 dark:border-slate-600 bg-transparent text-primary focus:ring-primary",type:"checkbox"})}),e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:()=>j(w.client_id),className:"text-slate-400 hover:text-primary transition-colors cursor-pointer",children:e.jsx("span",{className:"material-symbols-rounded",children:L?"keyboard_arrow_down":"keyboard_arrow_right"})}),e.jsx("div",{className:"w-10 h-10 rounded-lg bg-indigo-500/10 flex items-center justify-center text-indigo-500",children:e.jsx("span",{className:"material-symbols-rounded",children:"database"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-slate-900 dark:text-slate-100",children:w.name}),e.jsx("div",{className:"text-xs text-slate-500",children:w.os||"Debian 12 (Bookworm) x64-pc-linux"})]})]})}),e.jsx("td",{className:"px-6 py-4",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-0.5 rounded-full bg-slate-100 dark:bg-slate-800 text-xs font-medium border border-slate-200 dark:border-slate-700",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${M}`}),w.engine," ",w.engine_version||w.engineVersion||""]})}),e.jsxs("td",{className:"px-6 py-4",children:[e.jsx("div",{className:"text-sm text-white",children:w.ip||"172.24.10.45"}),e.jsxs("div",{className:"text-xs text-slate-500 font-mono",children:["Port: ",w.port||"9102"]})]}),e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${K?"bg-emerald-500 animate-pulse":"bg-slate-400"}`}),e.jsx("span",{className:`text-sm font-medium ${K?"text-emerald-500":"text-slate-400"}`,children:K?"Online":"Offline"})]})}),e.jsxs("td",{className:"px-6 py-4 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-emerald-500 font-medium",children:[e.jsx("span",{className:"material-symbols-rounded text-[16px]",children:"check_circle"}),"Success"]}),e.jsxs("div",{className:"text-xs text-slate-500",children:[g(w.last_backup_at)," (",w.backup_type||"WAL Archiving",")"]})]}),e.jsx("td",{className:"px-6 py-4",children:e.jsxs("span",{className:"px-2 py-1 bg-slate-100 dark:bg-slate-800 rounded text-xs font-mono border border-slate-200 dark:border-slate-700 text-white",children:["v",w.version||"23.1.2"]})}),e.jsx("td",{className:"px-6 py-4 text-right",children:e.jsx("button",{className:"p-2 hover:bg-slate-100 dark:hover:bg-slate-700 rounded-full transition-colors text-slate-400 hover:text-slate-600 dark:hover:text-slate-200",children:e.jsx("span",{className:"material-symbols-rounded",children:"more_vert"})})})]},w.client_id),L&&e.jsx("tr",{className:"bg-slate-50/50 dark:bg-slate-800/20",children:e.jsx("td",{className:"px-6 py-6 border-t border-slate-100 dark:border-slate-800",colSpan:8,children:e.jsxs("div",{className:"relative pl-12",children:[e.jsx("div",{className:"absolute left-[20px] top-0 bottom-6 w-px bg-slate-300 dark:bg-slate-700"}),e.jsx("div",{className:"absolute left-[20px] top-1/2 -translate-y-1/2 w-4 h-px bg-slate-300 dark:bg-slate-700"}),e.jsx("div",{className:"mb-4 text-xs font-bold text-slate-400 uppercase tracking-widest",children:"Installed Agents & Database Plugins"}),e.jsx("div",{className:"space-y-3",children:e.jsxs("div",{className:"flex items-center justify-between p-4 bg-white dark:bg-slate-900 border border-slate-200 dark:border-slate-700 rounded-xl shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-emerald-500/10 flex items-center justify-center text-emerald-500",children:e.jsx("span",{className:"material-symbols-rounded",children:"storage"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-slate-900 dark:text-slate-100 text-sm",children:w.plugin?.name||`${w.engine} Backup Plugin`}),e.jsx("div",{className:"text-xs text-slate-500",children:w.plugin?.description||"Database backup and recovery integration"})]})]}),e.jsxs("div",{className:"flex items-center gap-8",children:[e.jsxs("div",{className:"text-xs",children:[e.jsx("span",{className:"text-slate-400",children:"VER"}),e.jsx("span",{className:"font-mono ml-1 text-slate-700 dark:text-slate-300",children:w.plugin?.version||w.version||"23.1.2-b"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-emerald-500 text-xs font-bold uppercase tracking-wider",children:[e.jsx("span",{className:"material-symbols-rounded text-[18px]",children:"check_circle"}),"Active"]})]})]})})]})})})]})})})]}),e.jsxs("div",{className:"px-6 py-4 border-t border-slate-200 dark:border-slate-800 flex items-center justify-between text-sm text-slate-500",children:[e.jsxs("div",{children:["Showing 1 - ",B," of ",B," clients"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{className:"p-1 rounded hover:bg-slate-100 dark:hover:bg-slate-800 disabled:opacity-50",disabled:!0,children:e.jsx("span",{className:"material-symbols-rounded",children:"chevron_left"})}),e.jsx("button",{className:"p-1 rounded hover:bg-slate-100 dark:hover:bg-slate-800 disabled:opacity-50",disabled:!0,children:e.jsx("span",{className:"material-symbols-rounded",children:"chevron_right"})})]})]})]})}),e.jsxs("section",{className:"bg-slate-950 rounded-xl border border-slate-800 overflow-hidden shadow-2xl",children:[e.jsxs("div",{className:"px-6 py-3 border-b border-slate-800 flex items-center justify-between bg-slate-900/50",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("div",{className:"w-3 h-3 rounded-full bg-red-500/80"}),e.jsx("div",{className:"w-3 h-3 rounded-full bg-amber-500/80"}),e.jsx("div",{className:"w-3 h-3 rounded-full bg-emerald-500/80"})]}),e.jsx("span",{className:"text-xs font-mono text-slate-400 ml-4",children:"Console Log (tail -f)"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-emerald-500"}),e.jsx("span",{className:"text-[10px] font-bold text-emerald-500 uppercase tracking-widest",children:"Connected"})]})]}),e.jsxs("div",{className:"p-6 h-48 overflow-y-auto custom-scrollbar font-mono text-[13px] leading-relaxed",children:[e.jsxs("div",{className:"text-slate-400",children:[e.jsx("span",{className:"text-blue-400",children:"[14:22:01]"})," bareos-dir: Connected to Storage at backup-srv-01:9103"]}),e.jsxs("div",{className:"text-slate-400",children:[e.jsx("span",{className:"text-blue-400",children:"[14:22:02]"}),' bareos-sd: Volume "Vol-0012" selected for appending']}),e.jsxs("div",{className:"text-slate-400",children:[e.jsx("span",{className:"text-blue-400",children:"[14:22:05]"}),' bareos-fd: Client "',N[0]?.name||"client",'" starting backup of /var/lib/postgresql/15/main']}),e.jsxs("div",{className:"text-amber-400",children:[e.jsx("span",{className:"text-blue-400",children:"[14:23:10]"})," warning: /var/lib/postgresql/15/main/base/16384/2601 locked by another process, skipping..."]}),e.jsxs("div",{className:"text-emerald-400",children:[e.jsx("span",{className:"text-blue-400",children:"[14:23:45]"})," bareos-dir: JobId 10423: Sending Accurate information."]}),e.jsxs("div",{className:"text-slate-400",children:[e.jsx("span",{className:"text-blue-400",children:"[14:24:12]"})," bareos-fd: Backup successful. Sent 2.4GB to Storage."]}),e.jsx("div",{className:"text-slate-500 italic mt-2 animate-pulse",children:"Waiting for next event..."})]})]})]})}function KS({onSwitchToConsole:r}){const[t,s]=Ce.useState(""),[n,o]=Ce.useState("all"),[l,d]=Ce.useState(new Set),[c,u]=Ce.useState(!1),h=Nr(),{data:m,isLoading:x,error:y}=dt({queryKey:["backup-clients-virtualization",n,t],queryFn:()=>ys.listClients({category:"Virtual",enabled:n==="all"?void 0:n==="enabled",search:t||void 0})}),p={client_id:999,name:"Proxmox Cluster (pve-cluster-01)",ip:"10.0.40.10",hypervisor:"Proxmox VE",version:"8.1",status:"online",last_backup_at:new Date().toISOString(),vms:[{id:101,name:"Ubuntu-Server-Prod",status:"running",last_backup:"Today, 03:00 AM",protection:"protected",node:"pve-01"},{id:102,name:"Win2022-DC",status:"running",last_backup:"Yesterday, 11:45 PM",protection:"protected",node:"pve-01"},{id:105,name:"vm-staging-test",status:"stopped",last_backup:"Never",protection:"unprotected",node:"pve-01"}],total_vms:5,showing_vms:3},v=m?.clients||[],N=m?.total||0,B=v.length===0?[p]:v,g=v.length===0?1:N,j=L=>{if(!L)return"-";try{const K=new Date(L),V=new Date().getTime()-K.getTime(),T=Math.floor(V/6e4),ne=Math.floor(V/36e5);return T<1?"Just now":T<60?`${T}m ago`:ne<24?`${ne}h ago`:K.toLocaleDateString()}catch{return"-"}},_=L=>{d(K=>{const M=new Set(K);return M.has(L)?M.delete(L):M.add(L),M})},w=L=>{const K=new URLSearchParams(window.location.search);K.set("tab",L),window.history.replaceState({},"",`${window.location.pathname}?${K.toString()}`),window.location.reload()};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"max-w-[1600px] mx-auto p-6 space-y-8",children:[e.jsxs("header",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>w("clients"),className:"flex items-center justify-center w-10 h-10 rounded-lg border border-slate-200 dark:border-slate-700 hover:bg-slate-50 dark:hover:bg-slate-800 transition-colors text-white",title:"Back to Client Dashboard",children:e.jsx("span",{className:"material-symbols-rounded text-[20px]",children:"arrow_back"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-3xl font-bold tracking-tight text-white",children:"Virtualization Client Management"}),e.jsxs("span",{className:"px-2.5 py-0.5 rounded-full bg-primary/10 text-primary text-sm font-semibold border border-primary/20",children:[g," Clients"]})]}),e.jsx("p",{className:"mt-1 text-slate-500 dark:text-slate-400",children:"Monitor virtual machine backups, hypervisor integrations, and VM snapshot management."})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:()=>r?.(),className:"flex items-center gap-2 px-4 py-2 bg-slate-200 dark:bg-slate-800 hover:bg-slate-300 dark:hover:bg-slate-700 transition-colors rounded-lg font-medium border border-slate-300 dark:border-slate-700 text-white",children:[e.jsx("span",{className:"material-symbols-rounded text-[20px]",children:"terminal"}),"Console"]}),e.jsxs("button",{onClick:()=>u(!0),className:"flex items-center gap-2 px-4 py-2 bg-primary hover:bg-blue-600 transition-colors text-white rounded-lg font-medium shadow-lg shadow-primary/20",children:[e.jsx("span",{className:"material-symbols-rounded text-[20px]",children:"add"}),"Add New VM Client"]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[e.jsxs("div",{className:"relative flex-grow max-w-md",children:[e.jsx("span",{className:"absolute inset-y-0 left-3 flex items-center pointer-events-none text-slate-400",children:e.jsx("span",{className:"material-symbols-rounded",children:"search"})}),e.jsx("input",{className:"w-full pl-10 pr-4 py-2 bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent outline-none transition-all text-white",placeholder:"Search clients by name, IP, or hypervisor...",type:"text",value:t,onChange:L=>s(L.target.value)})]}),e.jsxs("div",{className:"flex bg-slate-100 dark:bg-slate-800/50 p-1 rounded-lg border border-slate-200 dark:border-slate-700",children:[e.jsx("button",{onClick:()=>o("all"),className:`px-4 py-1.5 rounded-md text-sm font-medium transition-colors ${n==="all"?"bg-white dark:bg-slate-700 shadow-sm text-slate-900 dark:text-white":"text-slate-500 hover:text-slate-900 dark:hover:text-slate-100"}`,children:"All"}),e.jsx("button",{onClick:()=>o("enabled"),className:`px-4 py-1.5 rounded-md text-sm font-medium transition-colors ${n==="enabled"?"bg-white dark:bg-slate-700 shadow-sm text-slate-900 dark:text-white":"text-slate-500 hover:text-slate-900 dark:hover:text-slate-100"}`,children:"Online"}),e.jsx("button",{onClick:()=>o("offline"),className:`px-4 py-1.5 rounded-md text-sm font-medium transition-colors ${n==="offline"?"bg-white dark:bg-slate-700 shadow-sm text-slate-900 dark:text-white":"text-slate-500 hover:text-slate-900 dark:hover:text-slate-100"}`,children:"Offline"})]}),e.jsxs("button",{className:"ml-auto flex items-center gap-2 px-4 py-2 bg-slate-100 dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded-lg text-sm font-medium text-white",children:[e.jsx("span",{className:"material-symbols-rounded text-[20px]",children:"sort"}),"Sort: Status"]})]}),e.jsx("div",{className:"overflow-hidden border border-slate-200 dark:border-slate-800 rounded-xl bg-white dark:bg-slate-900 shadow-sm",children:x?e.jsx("div",{className:"p-8 text-center text-slate-400",children:"Loading clients..."}):y?e.jsx("div",{className:"p-8 text-center text-red-400",children:"Failed to load clients"}):B.length===0?e.jsx("div",{className:"p-12 text-center text-slate-400",children:"No virtualization clients found"}):e.jsxs(e.Fragment,{children:[e.jsxs("table",{className:"w-full text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-slate-50 dark:bg-slate-800/50 text-slate-500 dark:text-slate-400 text-xs font-bold uppercase tracking-wider",children:[e.jsx("th",{className:"px-6 py-4 w-12",children:e.jsx("input",{className:"rounded border-slate-300 dark:border-slate-600 bg-transparent text-primary focus:ring-primary",type:"checkbox"})}),e.jsx("th",{className:"px-6 py-4",children:"Client Name"}),e.jsx("th",{className:"px-6 py-4",children:"Hypervisor"}),e.jsx("th",{className:"px-6 py-4",children:"Connection"}),e.jsx("th",{className:"px-6 py-4",children:"Status"}),e.jsx("th",{className:"px-6 py-4",children:"Last Backup"}),e.jsx("th",{className:"px-6 py-4",children:"Version"}),e.jsx("th",{className:"px-6 py-4 text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-slate-200 dark:divide-slate-800",children:B.map(L=>{const K=l.has(L.client_id),M=L.status==="online",V=L.hypervisor==="Proxmox VE"||L.name?.includes("Proxmox");return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:"group hover:bg-slate-50/50 dark:hover:bg-slate-800/30 transition-colors",children:[e.jsx("td",{className:"px-6 py-4",children:e.jsx("input",{className:"rounded border-slate-300 dark:border-slate-600 bg-transparent text-primary focus:ring-primary",type:"checkbox"})}),e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:()=>_(L.client_id),className:"text-slate-400 hover:text-primary transition-colors cursor-pointer",children:e.jsx("span",{className:"material-symbols-rounded",children:K?"keyboard_arrow_down":"keyboard_arrow_right"})}),V?e.jsx("div",{className:"w-10 h-10 rounded-lg bg-orange-500/20 flex items-center justify-center text-orange-500 border border-orange-500/30",children:e.jsx("span",{className:"text-lg font-bold",children:"P"})}):e.jsx("div",{className:"w-10 h-10 rounded-lg bg-purple-500/10 flex items-center justify-center text-purple-500",children:e.jsx("span",{className:"material-symbols-rounded",children:"dns"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-slate-900 dark:text-slate-100",children:L.name}),e.jsx("div",{className:"text-xs text-slate-500",children:L.ip?`${L.ip} • ${L.hypervisor||"VM Host"} ${L.version||""}`.trim():"VM Host / Hypervisor"})]})]})}),e.jsx("td",{className:"px-6 py-4",children:e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-0.5 rounded-full ${V?"bg-orange-500/10 border-orange-500/30":"bg-slate-100 dark:bg-slate-800 border-slate-200 dark:border-slate-700"} text-xs font-medium border`,children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${V?"bg-orange-500":"bg-purple-500"}`}),L.hypervisor||"VMware vSphere"]})}),e.jsxs("td",{className:"px-6 py-4",children:[e.jsx("div",{className:"text-sm text-white",children:L.ip||"10.0.50.112"}),e.jsxs("div",{className:"text-xs text-slate-500 font-mono",children:["Port: ",L.port||"9102"]})]}),e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${M?"bg-emerald-500 animate-pulse":"bg-slate-400"}`}),e.jsx("span",{className:`text-sm font-medium ${M?"text-emerald-500":"text-slate-400"}`,children:M?"CONNECTED":"Offline"})]})}),e.jsxs("td",{className:"px-6 py-4 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-emerald-500 font-medium",children:[e.jsx("span",{className:"material-symbols-rounded text-[16px]",children:"check_circle"}),"Success"]}),e.jsxs("div",{className:"text-xs text-slate-500",children:[j(L.last_backup_at)," (Snapshot)"]})]}),e.jsx("td",{className:"px-6 py-4",children:e.jsx("span",{className:"px-2 py-1 bg-slate-100 dark:bg-slate-800 rounded text-xs font-mono border border-slate-200 dark:border-slate-700 text-white",children:L.version?`v${L.version}`:"v22.4.1"})}),e.jsx("td",{className:"px-6 py-4 text-right",children:e.jsx("button",{className:"p-2 hover:bg-slate-100 dark:hover:bg-slate-700 rounded-full transition-colors text-slate-400 hover:text-slate-600 dark:hover:text-slate-200",children:e.jsx("span",{className:"material-symbols-rounded",children:"more_vert"})})})]},L.client_id),K&&e.jsx(e.Fragment,{children:V&&L.vms?e.jsx("tr",{className:"bg-slate-50/50 dark:bg-slate-800/20",children:e.jsx("td",{className:"px-6 py-6 border-t border-slate-100 dark:border-slate-800",colSpan:8,children:e.jsxs("div",{className:"relative pl-12",children:[e.jsx("div",{className:"absolute left-[20px] top-0 bottom-6 w-px bg-slate-300 dark:bg-slate-700"}),e.jsx("div",{className:"absolute left-[20px] top-1/2 -translate-y-1/2 w-4 h-px bg-slate-300 dark:bg-slate-700"}),e.jsx("div",{className:"mb-4 text-xs font-bold text-slate-400 uppercase tracking-widest",children:"Virtual Machines"}),e.jsxs("div",{className:"bg-white dark:bg-slate-900 border border-slate-200 dark:border-slate-700 rounded-xl overflow-hidden",children:[e.jsxs("table",{className:"w-full text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-slate-50 dark:bg-slate-800/50 text-slate-500 dark:text-slate-400 text-xs font-bold uppercase tracking-wider",children:[e.jsx("th",{className:"px-4 py-3",children:"VM ID"}),e.jsx("th",{className:"px-4 py-3",children:"Name"}),e.jsx("th",{className:"px-4 py-3",children:"Status"}),e.jsx("th",{className:"px-4 py-3",children:"Last Backup"}),e.jsx("th",{className:"px-4 py-3",children:"Protection"}),e.jsx("th",{className:"px-4 py-3 text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-slate-200 dark:divide-slate-800",children:L.vms.map(T=>e.jsxs("tr",{className:"hover:bg-slate-50/50 dark:hover:bg-slate-800/30 transition-colors",children:[e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"font-mono text-sm text-white",children:T.id})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[T.name.includes("Win")?e.jsx("span",{className:"material-symbols-rounded text-slate-400",children:"desktop_windows"}):e.jsx("span",{className:"material-symbols-rounded text-slate-400",children:"folder"}),e.jsx("span",{className:`font-medium text-white ${T.name.includes("staging")?"italic":""}`,children:T.name})]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${T.status==="running"?"bg-emerald-500":"bg-slate-400"}`}),e.jsx("span",{className:`text-sm font-medium ${T.status==="running"?"text-emerald-500":"text-slate-400"}`,children:T.status==="running"?"RUNNING":"STOPPED"})]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"text-sm text-white",children:T.last_backup})}),e.jsx("td",{className:"px-4 py-3",children:T.protection==="protected"?e.jsxs("div",{className:"flex items-center gap-1.5 text-emerald-500 text-sm font-medium",children:[e.jsx("span",{className:"material-symbols-rounded text-[16px]",children:"check_circle"}),"Protected"]}):e.jsxs("div",{className:"flex items-center gap-1.5 text-amber-500 text-sm font-medium",children:[e.jsx("span",{className:"material-symbols-rounded text-[16px]",children:"warning"}),"Unprotected"]})}),e.jsx("td",{className:"px-4 py-3 text-right",children:e.jsx("button",{className:"p-1.5 hover:bg-slate-100 dark:hover:bg-slate-700 rounded transition-colors text-slate-400 hover:text-slate-600 dark:hover:text-slate-200",children:e.jsx("span",{className:"material-symbols-rounded text-[18px]",children:"more_vert"})})})]},T.id))})]}),e.jsxs("div",{className:"px-4 py-3 border-t border-slate-200 dark:border-slate-800 flex items-center justify-between text-xs text-slate-500 bg-slate-50 dark:bg-slate-900/50",children:[e.jsxs("div",{children:["Showing ",L.showing_vms||L.vms.length," of ",L.total_vms||L.vms.length," VMs found on node ",L.vms[0]?.node||"pve-01"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{className:"p-1 rounded hover:bg-slate-100 dark:hover:bg-slate-800 disabled:opacity-50",disabled:!0,children:e.jsx("span",{className:"material-symbols-rounded text-[16px]",children:"chevron_left"})}),e.jsx("button",{className:"p-1 rounded hover:bg-slate-100 dark:hover:bg-slate-800 disabled:opacity-50",children:e.jsx("span",{className:"material-symbols-rounded text-[16px]",children:"chevron_right"})})]})]})]})]})})}):e.jsx("tr",{className:"bg-slate-50/50 dark:bg-slate-800/20",children:e.jsx("td",{className:"px-6 py-6 border-t border-slate-100 dark:border-slate-800",colSpan:8,children:e.jsxs("div",{className:"relative pl-12",children:[e.jsx("div",{className:"absolute left-[20px] top-0 bottom-6 w-px bg-slate-300 dark:bg-slate-700"}),e.jsx("div",{className:"absolute left-[20px] top-1/2 -translate-y-1/2 w-4 h-px bg-slate-300 dark:bg-slate-700"}),e.jsx("div",{className:"mb-4 text-xs font-bold text-slate-400 uppercase tracking-widest",children:"Installed Agents & Virtualization Plugins"}),e.jsx("div",{className:"space-y-3",children:e.jsxs("div",{className:"flex items-center justify-between p-4 bg-white dark:bg-slate-900 border border-slate-200 dark:border-slate-700 rounded-xl shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-purple-500/10 flex items-center justify-center text-purple-500",children:e.jsx("span",{className:"material-symbols-rounded",children:"cloud"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-slate-900 dark:text-slate-100 text-sm",children:"VMware vSphere Plugin"}),e.jsx("div",{className:"text-xs text-slate-500",children:"VM snapshot and backup integration"})]})]}),e.jsxs("div",{className:"flex items-center gap-8",children:[e.jsxs("div",{className:"text-xs",children:[e.jsx("span",{className:"text-slate-400",children:"VER"}),e.jsx("span",{className:"font-mono ml-1 text-slate-700 dark:text-slate-300",children:"22.4.1-vm"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-emerald-500 text-xs font-bold uppercase tracking-wider",children:[e.jsx("span",{className:"material-symbols-rounded text-[18px]",children:"check_circle"}),"Active"]})]})]})})]})})})})]})})})]}),e.jsxs("div",{className:"px-6 py-4 border-t border-slate-200 dark:border-slate-800 flex items-center justify-between text-sm text-slate-500",children:[e.jsxs("div",{children:["Showing 1 - ",g," of ",g," clients"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{className:"p-1 rounded hover:bg-slate-100 dark:hover:bg-slate-800 disabled:opacity-50",disabled:!0,children:e.jsx("span",{className:"material-symbols-rounded",children:"chevron_left"})}),e.jsx("button",{className:"p-1 rounded hover:bg-slate-100 dark:hover:bg-slate-800 disabled:opacity-50",disabled:!0,children:e.jsx("span",{className:"material-symbols-rounded",children:"chevron_right"})})]})]})]})}),e.jsxs("section",{className:"bg-slate-950 rounded-xl border border-slate-800 overflow-hidden shadow-2xl",children:[e.jsxs("div",{className:"px-6 py-3 border-b border-slate-800 flex items-center justify-between bg-slate-900/50",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("div",{className:"w-3 h-3 rounded-full bg-red-500/80"}),e.jsx("div",{className:"w-3 h-3 rounded-full bg-amber-500/80"}),e.jsx("div",{className:"w-3 h-3 rounded-full bg-emerald-500/80"})]}),e.jsx("span",{className:"text-xs font-mono text-slate-400 ml-4",children:"Console Log (tail -f)"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-emerald-500"}),e.jsx("span",{className:"text-[10px] font-bold text-emerald-500 uppercase tracking-widest",children:"Connected"})]})]}),e.jsxs("div",{className:"p-6 h-48 overflow-y-auto custom-scrollbar font-mono text-[13px] leading-relaxed",children:[e.jsxs("div",{className:"text-slate-400",children:[e.jsx("span",{className:"text-blue-400",children:"[14:22:01]"})," bareos-dir: Connected to Storage at backup-srv-01:9103"]}),e.jsxs("div",{className:"text-slate-400",children:[e.jsx("span",{className:"text-blue-400",children:"[14:22:02]"}),' bareos-sd: Volume "Vol-0012" selected for appending']}),e.jsxs("div",{className:"text-slate-400",children:[e.jsx("span",{className:"text-blue-400",children:"[14:22:05]"}),' bareos-fd: Client "',B[0]?.name||"Proxmox Cluster",'" starting VM snapshot backup']}),e.jsxs("div",{className:"text-amber-400",children:[e.jsx("span",{className:"text-blue-400",children:"[14:23:10]"}),' warning: VM "Ubuntu-Server-Prod" is currently powered on, creating snapshot...']}),e.jsxs("div",{className:"text-emerald-400",children:[e.jsx("span",{className:"text-blue-400",children:"[14:23:45]"})," bareos-dir: JobId 10423: VM snapshot created successfully."]}),e.jsxs("div",{className:"text-slate-400",children:[e.jsx("span",{className:"text-blue-400",children:"[14:24:12]"})," bareos-fd: Backup successful. Sent 5.2GB to Storage."]}),e.jsxs("div",{className:"text-slate-400",children:[e.jsx("span",{className:"text-blue-400",children:"[14:25:01]"})," bareos-dir: Found ",B[0]?.total_vms||5," VMs on node pve-01"]}),e.jsx("div",{className:"text-slate-500 italic mt-2 animate-pulse",children:"Waiting for next event..."})]})]})]}),c&&e.jsx(zS,{onClose:()=>u(!1),onSuccess:()=>{u(!1),h.invalidateQueries({queryKey:["backup-clients-virtualization"]})}})]})}function zS({onClose:r,onSuccess:t}){const[s,n]=Ce.useState({clientName:"",ipAddress:"",port:"443",hypervisorType:"vmware",authMethod:"creds",username:"",password:"",retentionPolicy:"standard",storagePool:"pool-01"}),[o]=Ce.useState(1),{data:l}=dt({queryKey:["storage-pools"],queryFn:()=>ys.listStoragePools()}),d=l?.pools||[],c=h=>{h.preventDefault(),console.log("Form submitted:",s),t()},u=()=>{console.log("Testing connection to:",s.ipAddress),alert("Connection test feature coming soon")};return e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white dark:bg-[#161d27] w-full max-w-2xl rounded-xl shadow-2xl border border-slate-200 dark:border-[#2d3748] overflow-hidden flex flex-col max-h-[90vh]",children:[e.jsx("style",{children:` select option { background-color: #161d27 !important; color: white !important; } select option:hover, select option:checked, select option:focus { background-color: #1d72f2 !important; color: white !important; } `}),e.jsxs("div",{className:"px-6 py-5 border-b border-slate-200 dark:border-[#2d3748] flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold tracking-tight text-white",children:"Add New VM Client"}),e.jsx("p",{className:"text-sm text-slate-500 dark:text-slate-400 mt-1",children:"Configure a new virtualization client for backup operations."})]}),e.jsx("button",{onClick:r,className:"text-slate-400 hover:text-slate-600 dark:hover:text-white transition-colors",children:e.jsx("span",{className:"material-symbols-rounded",children:"close"})})]}),e.jsx("div",{className:"px-6 py-4 bg-slate-50 dark:bg-slate-900/50 border-b border-slate-200 dark:border-[#2d3748] overflow-x-auto",children:e.jsxs("div",{className:"flex items-center space-x-8 text-sm font-medium whitespace-nowrap",children:[e.jsxs("div",{className:`flex items-center ${o===1?"text-primary":"text-slate-400"}`,children:[e.jsx("span",{className:`w-6 h-6 rounded-full ${o===1?"bg-primary/10 border border-primary":"border border-slate-300 dark:border-slate-700"} flex items-center justify-center text-xs mr-2`,children:"1"}),"Client Details"]}),e.jsxs("div",{className:`flex items-center ${o===2?"text-primary":"text-slate-400"}`,children:[e.jsx("span",{className:`w-6 h-6 rounded-full ${o===2?"bg-primary/10 border border-primary":"border border-slate-300 dark:border-slate-700"} flex items-center justify-center text-xs mr-2`,children:"2"}),"Hypervisor"]}),e.jsxs("div",{className:`flex items-center ${o===3?"text-primary":"text-slate-400"}`,children:[e.jsx("span",{className:`w-6 h-6 rounded-full ${o===3?"bg-primary/10 border border-primary":"border border-slate-300 dark:border-slate-700"} flex items-center justify-center text-xs mr-2`,children:"3"}),"Authentication"]}),e.jsxs("div",{className:`flex items-center ${o===4?"text-primary":"text-slate-400"}`,children:[e.jsx("span",{className:`w-6 h-6 rounded-full ${o===4?"bg-primary/10 border border-primary":"border border-slate-300 dark:border-slate-700"} flex items-center justify-center text-xs mr-2`,children:"4"}),"Settings"]})]})}),e.jsx("div",{className:"p-6 overflow-y-auto flex-1",children:e.jsxs("form",{onSubmit:c,className:"space-y-8",children:[e.jsxs("section",{children:[e.jsxs("h3",{className:"text-xs font-semibold text-slate-400 uppercase tracking-wider mb-4 flex items-center",children:[e.jsx("span",{className:"material-symbols-rounded text-sm mr-2",children:"info"}),"Client Information"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium text-slate-700 dark:text-slate-300",children:"Client Name"}),e.jsx("input",{type:"text",value:s.clientName,onChange:h=>n({...s,clientName:h.target.value}),className:"w-full bg-slate-50 dark:bg-slate-800/50 border border-slate-200 dark:border-[#2d3748] rounded-md px-3 py-2 focus:ring-2 focus:ring-primary focus:border-transparent outline-none transition-all placeholder:text-slate-500 text-white",placeholder:"e.g. production-vcenter",required:!0})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"col-span-2 space-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium text-slate-700 dark:text-slate-300",children:"IP Address / FQDN"}),e.jsx("input",{type:"text",value:s.ipAddress,onChange:h=>n({...s,ipAddress:h.target.value}),className:"w-full bg-slate-50 dark:bg-slate-800/50 border border-slate-200 dark:border-[#2d3748] rounded-md px-3 py-2 focus:ring-2 focus:ring-primary focus:border-transparent outline-none transition-all text-white",placeholder:"192.168.1.50",required:!0})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium text-slate-700 dark:text-slate-300",children:"Port"}),e.jsx("input",{type:"text",value:s.port,onChange:h=>n({...s,port:h.target.value}),className:"w-full bg-slate-50 dark:bg-slate-800/50 border border-slate-200 dark:border-[#2d3748] rounded-md px-3 py-2 focus:ring-2 focus:ring-primary focus:border-transparent outline-none transition-all text-white",placeholder:"443",required:!0})]})]})]})]}),e.jsxs("section",{children:[e.jsxs("h3",{className:"text-xs font-semibold text-slate-400 uppercase tracking-wider mb-4 flex items-center",children:[e.jsx("span",{className:"material-symbols-rounded text-sm mr-2",children:"storage"}),"Hypervisor & Auth"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium text-slate-700 dark:text-slate-300",children:"Hypervisor Type"}),e.jsxs("div",{className:"relative",children:[e.jsxs("select",{value:s.hypervisorType,onChange:h=>n({...s,hypervisorType:h.target.value}),className:"w-full bg-primary/10 dark:bg-primary/20 border border-primary/30 dark:border-primary/40 rounded-md px-3 py-2 focus:ring-2 focus:ring-primary focus:border-primary outline-none appearance-none cursor-pointer transition-all text-white pr-8 [&>option]:bg-[#161d27] [&>option]:text-white",children:[e.jsx("option",{value:"vmware",className:"bg-[#161d27] text-white",children:"VMware vSphere"}),e.jsx("option",{value:"proxmox",className:"bg-[#161d27] text-white",children:"Proxmox VE"}),e.jsx("option",{value:"ovirt",className:"bg-[#161d27] text-white",children:"oVirt / Red Hat Virtualization"})]}),e.jsx("span",{className:"material-symbols-rounded absolute right-2 top-2 pointer-events-none text-primary",children:"expand_more"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium text-slate-700 dark:text-slate-300",children:"Authentication Method"}),e.jsxs("div",{className:"relative",children:[e.jsxs("select",{value:s.authMethod,onChange:h=>n({...s,authMethod:h.target.value}),className:"w-full bg-primary/10 dark:bg-primary/20 border border-primary/30 dark:border-primary/40 rounded-md px-3 py-2 focus:ring-2 focus:ring-primary focus:border-primary outline-none appearance-none cursor-pointer transition-all text-white pr-8 [&>option]:bg-[#161d27] [&>option]:text-white",children:[e.jsx("option",{value:"creds",className:"bg-[#161d27] text-white",children:"Username / Password"}),e.jsx("option",{value:"token",className:"bg-[#161d27] text-white",children:"API Token"})]}),e.jsx("span",{className:"material-symbols-rounded absolute right-2 top-2 pointer-events-none text-primary",children:"expand_more"})]})]})]}),e.jsx("div",{className:"mt-4 p-4 rounded-lg bg-slate-50 dark:bg-slate-900/30 border border-slate-200 dark:border-[#2d3748] space-y-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium text-slate-700 dark:text-slate-300",children:"Username"}),e.jsx("input",{type:"text",value:s.username,onChange:h=>n({...s,username:h.target.value}),className:"w-full bg-white dark:bg-[#161d27] border border-slate-200 dark:border-[#2d3748] rounded-md px-3 py-2 focus:ring-2 focus:ring-primary focus:border-transparent outline-none transition-all text-white",placeholder:"administrator@vsphere.local",required:!0})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium text-slate-700 dark:text-slate-300",children:"Password"}),e.jsx("input",{type:"password",value:s.password,onChange:h=>n({...s,password:h.target.value}),className:"w-full bg-white dark:bg-[#161d27] border border-slate-200 dark:border-[#2d3748] rounded-md px-3 py-2 focus:ring-2 focus:ring-primary focus:border-transparent outline-none transition-all text-white",placeholder:"••••••••••••",required:!0})]})]})})]}),e.jsxs("section",{children:[e.jsxs("h3",{className:"text-xs font-semibold text-slate-400 uppercase tracking-wider mb-4 flex items-center",children:[e.jsx("span",{className:"material-symbols-rounded text-sm mr-2",children:"settings_backup_restore"}),"Backup Settings"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium text-slate-700 dark:text-slate-300",children:"Retention Policy"}),e.jsxs("div",{className:"relative",children:[e.jsxs("select",{value:s.retentionPolicy,onChange:h=>n({...s,retentionPolicy:h.target.value}),className:"w-full bg-primary/10 dark:bg-primary/20 border border-primary/30 dark:border-primary/40 rounded-md px-3 py-2 focus:ring-2 focus:ring-primary focus:border-primary outline-none appearance-none cursor-pointer transition-all text-white pr-8 [&>option]:bg-[#161d27] [&>option]:text-white",children:[e.jsx("option",{value:"standard",className:"bg-[#161d27] text-white",children:"Standard (30 Days)"}),e.jsx("option",{value:"long",className:"bg-[#161d27] text-white",children:"Long Term (1 Year)"}),e.jsx("option",{value:"short",className:"bg-[#161d27] text-white",children:"Critical (7 Days)"})]}),e.jsx("span",{className:"material-symbols-rounded absolute right-2 top-2 pointer-events-none text-primary",children:"expand_more"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium text-slate-700 dark:text-slate-300",children:"Target Storage Pool"}),e.jsxs("div",{className:"relative",children:[e.jsx("select",{value:s.storagePool,onChange:h=>n({...s,storagePool:h.target.value}),className:"w-full bg-primary/10 dark:bg-primary/20 border border-primary/30 dark:border-primary/40 rounded-md px-3 py-2 focus:ring-2 focus:ring-primary focus:border-primary outline-none appearance-none cursor-pointer transition-all text-white pr-8 [&>option]:bg-[#161d27] [&>option]:text-white",children:d.length>0?d.map(h=>e.jsx("option",{value:h.name,className:"bg-[#161d27] text-white",children:h.name},h.pool_id)):e.jsxs(e.Fragment,{children:[e.jsx("option",{value:"pool-01",className:"bg-[#161d27] text-white",children:"SSD-Fast-Pool-01"}),e.jsx("option",{value:"pool-02",className:"bg-[#161d27] text-white",children:"HDD-Archive-Pool-02"})]})}),e.jsx("span",{className:"material-symbols-rounded absolute right-2 top-2 pointer-events-none text-primary",children:"expand_more"})]})]})]})]})]})}),e.jsxs("div",{className:"px-6 py-4 bg-slate-50 dark:bg-slate-900/50 border-t border-slate-200 dark:border-[#2d3748] flex items-center justify-between",children:[e.jsx("button",{onClick:r,className:"px-4 py-2 text-sm font-medium text-slate-600 dark:text-slate-400 hover:bg-slate-100 dark:hover:bg-slate-800 rounded-md transition-all",children:"Cancel"}),e.jsxs("div",{className:"flex space-x-3",children:[e.jsxs("button",{type:"button",onClick:u,className:"px-4 py-2 text-sm font-medium text-slate-700 dark:text-slate-300 hover:bg-slate-100 dark:hover:bg-slate-800 rounded-md transition-all flex items-center",children:[e.jsx("span",{className:"material-symbols-rounded text-sm mr-1.5",children:"check_circle"}),"Test Connection"]}),e.jsxs("button",{type:"submit",onClick:c,className:"bg-primary hover:bg-primary/90 text-white px-6 py-2 rounded-md font-medium text-sm flex items-center shadow-lg shadow-primary/20 transition-all",children:[e.jsx("span",{className:"material-symbols-rounded text-sm mr-1.5",children:"add"}),"Add Client"]})]})]})]})})}function qS(){const r=Cy(),s=new URLSearchParams(r.search).get("view"),[n,o]=Ce.useState(s||"pools");Ce.useEffect(()=>{const V=new URLSearchParams(r.search).get("view")||"pools";V!==n&&(V==="pools"||V==="volumes"||V==="daemons")&&o(V)},[r.search]);const l=M=>{o(M);const V=new URLSearchParams(r.search);V.set("tab","storage"),M==="pools"?V.delete("view"):V.set("view",M);const T=`${r.pathname}?${V.toString()}`;window.history.replaceState({},"",T)},[d,c]=Ce.useState("list"),[u,h]=Ce.useState(!1),[m,x]=Ce.useState(null),y=Nr(),{data:p,isLoading:v}=dt({queryKey:["storage-pools"],queryFn:()=>ys.listStoragePools()}),N=ft({mutationFn:ys.createStoragePool,onSuccess:()=>{y.invalidateQueries({queryKey:["storage-pools"]}),c("list")}}),B=ft({mutationFn:ys.deleteStoragePool,onSuccess:()=>{y.invalidateQueries({queryKey:["storage-pools"]}),h(!1),x(null)}}),{data:g,isLoading:j}=dt({queryKey:["storage-daemons"],queryFn:()=>ys.listStorageDaemons(),enabled:n==="daemons"}),_=p?.pools||[],w=g?.daemons||[],L=M=>{if(M===0)return"0 B";const V=1024,T=["B","KB","MB","GB","TB"],ne=Math.floor(Math.log(M)/Math.log(V));return`${(M/Math.pow(V,ne)).toFixed(2)} ${T[ne]}`},K=M=>{const T={Full:{bg:"bg-green-500/10",text:"text-green-400",border:"border-green-500/20"},Append:{bg:"bg-blue-500/10",text:"text-blue-400",border:"border-blue-500/20"},Used:{bg:"bg-yellow-500/10",text:"text-yellow-400",border:"border-yellow-500/20"},Error:{bg:"bg-red-500/10",text:"text-red-400",border:"border-red-500/20"},Online:{bg:"bg-green-500/10",text:"text-green-400",border:"border-green-500/20"},Offline:{bg:"bg-red-500/10",text:"text-red-400",border:"border-red-500/20"}}[M]||{bg:"bg-gray-500/10",text:"text-gray-400",border:"border-gray-500/20"};return e.jsx("span",{className:`inline-flex items-center gap-1.5 rounded px-2 py-1 text-xs font-medium ${T.bg} ${T.text} border ${T.border}`,children:M})};return e.jsxs("div",{className:"flex flex-col gap-6 flex-1",children:[e.jsx("header",{className:"flex flex-wrap justify-between items-end gap-4 border-b border-border-dark pb-6",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-white text-3xl md:text-4xl font-black leading-tight tracking-tight",children:"Storage Management"}),e.jsxs("span",{className:"flex h-6 px-2 items-center rounded-full bg-surface-highlight border border-border-dark text-xs font-bold text-primary",children:[_.length," Pools"]})]}),e.jsx("p",{className:"text-text-secondary text-base font-normal max-w-2xl",children:"Manage storage pools, volumes, and storage daemons for backup operations."})]})}),e.jsx("div",{className:"w-full overflow-x-auto",children:e.jsxs("div",{className:"flex border-b border-border-dark gap-8 min-w-max",children:[e.jsxs("button",{onClick:()=>l("pools"),className:`flex items-center gap-2 border-b-[3px] pb-3 pt-2 transition-colors ${n==="pools"?"border-primary text-white":"border-transparent text-text-secondary hover:text-white"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-base",children:"hard_drive"}),e.jsx("p",{className:"text-sm font-bold tracking-wide",children:"Pools"})]}),e.jsxs("button",{onClick:()=>l("volumes"),className:`flex items-center gap-2 border-b-[3px] pb-3 pt-2 transition-colors ${n==="volumes"?"border-primary text-white":"border-transparent text-text-secondary hover:text-white"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-base",children:"storage"}),e.jsx("p",{className:"text-sm font-bold tracking-wide",children:"Volumes"})]}),e.jsxs("button",{onClick:()=>l("daemons"),className:`flex items-center gap-2 border-b-[3px] pb-3 pt-2 transition-colors ${n==="daemons"?"border-primary text-white":"border-transparent text-text-secondary hover:text-white"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-base",children:"dns"}),e.jsx("p",{className:"text-sm font-bold tracking-wide",children:"Storage Daemons"})]})]})}),n==="pools"&&e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4 border-b border-border-dark pb-4",children:[e.jsxs("button",{onClick:()=>c("list"),className:`px-4 py-2 rounded-lg text-sm font-bold transition-colors ${d==="list"?"bg-primary text-white":"bg-surface-highlight text-text-secondary hover:text-white hover:bg-[#2a3c50]"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-base mr-2 align-middle",children:"list"}),"List Current Pools"]}),e.jsxs("button",{onClick:()=>c("add"),className:`px-4 py-2 rounded-lg text-sm font-bold transition-colors ${d==="add"?"bg-primary text-white":"bg-surface-highlight text-text-secondary hover:text-white hover:bg-[#2a3c50]"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-base mr-2 align-middle",children:"add"}),"Add Pool"]}),e.jsxs("button",{onClick:()=>c("delete"),className:`px-4 py-2 rounded-lg text-sm font-bold transition-colors ${d==="delete"?"bg-primary text-white":"bg-surface-highlight text-text-secondary hover:text-white hover:bg-[#2a3c50]"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-base mr-2 align-middle",children:"delete"}),"Delete Pool"]})]}),d==="list"&&e.jsx("div",{className:"rounded-lg border border-border-dark bg-surface-highlight overflow-hidden shadow-sm",children:v?e.jsx("div",{className:"p-8 text-center text-text-secondary",children:"Loading pools..."}):_.length===0?e.jsx("div",{className:"p-12 text-center",children:e.jsx("p",{className:"text-text-secondary",children:"No storage pools found"})}):e.jsx(e.Fragment,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-surface-dark border-b border-border-dark text-text-secondary text-xs uppercase tracking-wider",children:[e.jsx("th",{className:"px-6 py-4 font-semibold",children:"Pool Name"}),e.jsx("th",{className:"px-6 py-4 font-semibold",children:"Type"}),e.jsx("th",{className:"px-6 py-4 font-semibold",children:"Volumes"}),e.jsx("th",{className:"px-6 py-4 font-semibold",children:"Usage"}),e.jsx("th",{className:"px-6 py-4 font-semibold",children:"Capacity"}),e.jsx("th",{className:"px-6 py-4 font-semibold",children:"Options"})]})}),e.jsx("tbody",{className:"divide-y divide-border-dark text-sm",children:_.map(M=>e.jsxs("tr",{className:"hover:bg-surface-dark/50 transition-colors",children:[e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-8 w-8 rounded bg-surface-dark flex items-center justify-center text-primary border border-border-dark",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"hard_drive"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-white font-bold",children:M.name}),M.label_format&&e.jsx("p",{className:"text-text-secondary text-xs",children:M.label_format})]})]})}),e.jsx("td",{className:"px-6 py-4 text-text-secondary",children:M.pool_type||"-"}),e.jsx("td",{className:"px-6 py-4 text-text-secondary",children:M.volume_count}),e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("span",{className:"text-white text-xs font-bold",children:[Math.round(M.usage_percent),"%"]})}),e.jsx("div",{className:"w-full bg-[#111a22] h-2 rounded-full overflow-hidden",children:e.jsx("div",{className:"bg-gradient-to-r from-primary to-blue-400 h-full rounded-full",style:{width:`${Math.min(M.usage_percent,100)}%`}})})]})}),e.jsxs("td",{className:"px-6 py-4 text-text-secondary font-mono text-xs",children:[L(M.used_bytes)," / ",L(M.total_bytes)]}),e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[M.recycle&&e.jsx("span",{className:"text-xs text-text-secondary",children:"Recycle"}),M.auto_prune&&e.jsx("span",{className:"text-xs text-text-secondary",children:"Auto-Prune"})]})})]},M.pool_id))})]})})})}),d==="add"&&e.jsxs("div",{className:"rounded-lg border border-border-dark bg-surface-highlight p-6",children:[e.jsx("h3",{className:"text-white text-xl font-bold mb-4",children:"Create New Storage Pool"}),e.jsx("p",{className:"text-text-secondary text-sm mb-6",children:"Pools define the set of storage Volumes to be used by Bacula. Configure different pools to organize your backup data."}),e.jsx(GS,{onSubmit:M=>{N.mutate(M)},isLoading:N.isPending,onCancel:()=>c("list")})]}),d==="delete"&&e.jsx("div",{className:"rounded-lg border border-border-dark bg-surface-highlight overflow-hidden shadow-sm",children:v?e.jsx("div",{className:"p-8 text-center text-text-secondary",children:"Loading pools..."}):_.length===0?e.jsx("div",{className:"p-12 text-center",children:e.jsx("p",{className:"text-text-secondary",children:"No storage pools found"})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"p-4 border-b border-border-dark",children:e.jsx("p",{className:"text-text-secondary text-sm mb-4",children:"Select a pool to delete. Pools with volumes cannot be deleted."})}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-surface-dark border-b border-border-dark text-text-secondary text-xs uppercase tracking-wider",children:[e.jsx("th",{className:"px-6 py-4 font-semibold",children:"Pool Name"}),e.jsx("th",{className:"px-6 py-4 font-semibold",children:"Type"}),e.jsx("th",{className:"px-6 py-4 font-semibold",children:"Volumes"}),e.jsx("th",{className:"px-6 py-4 font-semibold",children:"Usage"}),e.jsx("th",{className:"px-6 py-4 font-semibold text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-border-dark text-sm",children:_.map(M=>e.jsxs("tr",{className:"hover:bg-surface-dark/50 transition-colors",children:[e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-8 w-8 rounded bg-surface-dark flex items-center justify-center text-primary border border-border-dark",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"hard_drive"})}),e.jsx("p",{className:"text-white font-bold",children:M.name})]})}),e.jsx("td",{className:"px-6 py-4 text-text-secondary",children:M.pool_type||"-"}),e.jsx("td",{className:"px-6 py-4 text-text-secondary",children:M.volume_count}),e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-white text-xs font-bold",children:[Math.round(M.usage_percent),"%"]}),e.jsx("div",{className:"w-24 bg-[#111a22] h-2 rounded-full overflow-hidden",children:e.jsx("div",{className:"bg-gradient-to-r from-primary to-blue-400 h-full rounded-full",style:{width:`${Math.min(M.usage_percent,100)}%`}})})]})}),e.jsx("td",{className:"px-6 py-4 text-right",children:e.jsxs("button",{onClick:()=>{x(M),h(!0)},disabled:M.volume_count>0,className:`px-4 py-2 rounded-lg text-sm font-bold transition-colors ${M.volume_count>0?"bg-gray-500/20 text-gray-500 cursor-not-allowed":"bg-red-500/10 text-red-400 hover:bg-red-500/20 border border-red-500/20"}`,title:M.volume_count>0?"Cannot delete pool with volumes":"Delete pool",children:[e.jsx("span",{className:"material-symbols-outlined text-base mr-1 align-middle",children:"delete"}),"Delete"]})})]},M.pool_id))})]})})]})})]}),n==="volumes"&&e.jsx(VS,{pools:_}),n==="daemons"&&e.jsx("div",{className:"rounded-lg border border-border-dark bg-surface-highlight overflow-hidden shadow-sm",children:j?e.jsx("div",{className:"p-8 text-center text-text-secondary",children:"Loading storage daemons..."}):w.length===0?e.jsx("div",{className:"p-12 text-center",children:e.jsx("p",{className:"text-text-secondary",children:"No storage daemons found"})}):e.jsx(e.Fragment,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-surface-dark border-b border-border-dark text-text-secondary text-xs uppercase tracking-wider",children:[e.jsx("th",{className:"px-6 py-4 font-semibold",children:"Name"}),e.jsx("th",{className:"px-6 py-4 font-semibold",children:"Address"}),e.jsx("th",{className:"px-6 py-4 font-semibold",children:"Port"}),e.jsx("th",{className:"px-6 py-4 font-semibold",children:"Device"}),e.jsx("th",{className:"px-6 py-4 font-semibold",children:"Media Type"}),e.jsx("th",{className:"px-6 py-4 font-semibold",children:"Status"})]})}),e.jsx("tbody",{className:"divide-y divide-border-dark text-sm",children:w.map(M=>e.jsxs("tr",{className:"hover:bg-surface-dark/50 transition-colors",children:[e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-8 w-8 rounded bg-surface-dark flex items-center justify-center text-primary border border-border-dark",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"dns"})}),e.jsx("p",{className:"text-white font-bold",children:M.name})]})}),e.jsx("td",{className:"px-6 py-4 text-text-secondary font-mono text-xs",children:M.address}),e.jsx("td",{className:"px-6 py-4 text-text-secondary",children:M.port}),e.jsx("td",{className:"px-6 py-4 text-text-secondary",children:M.device_name}),e.jsx("td",{className:"px-6 py-4 text-text-secondary",children:M.media_type}),e.jsx("td",{className:"px-6 py-4",children:K(M.status)})]},M.storage_id))})]})})})}),u&&m&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-surface-highlight border border-border-dark rounded-lg p-6 max-w-md w-full mx-4",children:[e.jsx("h3",{className:"text-white text-xl font-bold mb-2",children:"Delete Storage Pool"}),e.jsxs("p",{className:"text-text-secondary text-sm mb-4",children:["Are you sure you want to delete pool ",e.jsx("span",{className:"text-white font-bold",children:m.name}),"?"]}),m.volume_count>0&&e.jsx("div",{className:"bg-red-500/10 border border-red-500/20 rounded-lg p-3 mb-4",children:e.jsxs("p",{className:"text-red-400 text-sm",children:["⚠️ This pool contains ",m.volume_count," volume(s). Pools with volumes cannot be deleted."]})}),e.jsxs("div",{className:"flex gap-3 justify-end",children:[e.jsx("button",{onClick:()=>{h(!1),x(null)},className:"px-4 py-2 rounded-lg bg-surface-dark border border-border-dark text-white text-sm font-bold hover:bg-[#2a3c50] transition-colors",children:"Cancel"}),e.jsx("button",{onClick:()=>{m.volume_count===0&&B.mutate(m.pool_id)},disabled:m.volume_count>0||B.isPending,className:"px-4 py-2 rounded-lg bg-red-500 text-white text-sm font-bold hover:bg-red-600 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:B.isPending?"Deleting...":"Delete Pool"})]})]})})]})}function GS({onSubmit:r,isLoading:t,onCancel:s}){const[n,o]=Ce.useState({name:"",pool_type:"Backup",label_format:"",recycle:!1,auto_prune:!1}),l=d=>{d.preventDefault(),r({name:n.name,pool_type:n.pool_type,label_format:n.label_format||void 0,recycle:n.recycle||void 0,auto_prune:n.auto_prune||void 0})};return e.jsxs("form",{onSubmit:l,className:"flex flex-col gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-text-secondary text-sm font-medium mb-2",children:["Pool Name ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx("input",{type:"text",required:!0,value:n.name,onChange:d=>o({...n,name:d.target.value}),placeholder:"e.g., Full-Backup, Incremental-Backup",className:"w-full bg-surface-dark border border-border-dark rounded-lg px-4 py-2 text-white text-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent"}),e.jsx("p",{className:"text-text-secondary text-xs mt-1",children:"Unique name for the storage pool"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-text-secondary text-sm font-medium mb-2",children:["Pool Type ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsxs("select",{value:n.pool_type,onChange:d=>o({...n,pool_type:d.target.value}),className:"w-full bg-surface-dark border border-border-dark rounded-lg px-4 py-2 text-white text-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent",children:[e.jsx("option",{value:"Backup",children:"Backup"}),e.jsx("option",{value:"Scratch",children:"Scratch"}),e.jsx("option",{value:"Recycle",children:"Recycle"})]}),e.jsxs("p",{className:"text-text-secondary text-xs mt-1",children:[n.pool_type==="Backup"&&"Contains volumes for backup data with retention periods",n.pool_type==="Scratch"&&"Contains volumes that can be used by any pool when needed",n.pool_type==="Recycle"&&"Contains volumes that have been purged and are ready for reuse"]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-text-secondary text-sm font-medium mb-2",children:"Label Format"}),e.jsx("input",{type:"text",value:n.label_format,onChange:d=>o({...n,label_format:d.target.value}),placeholder:"e.g., Vol-${Year}-${Month:p/2/0/r}-${Day:p/2/0/r}-${Counter:4}",className:"w-full bg-surface-dark border border-border-dark rounded-lg px-4 py-2 text-white text-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent"}),e.jsx("p",{className:"text-text-secondary text-xs mt-1",children:"Format string for automatic volume labeling"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:n.recycle||!1,onChange:d=>o({...n,recycle:d.target.checked}),className:"checkbox-custom"}),e.jsx("span",{className:"text-text-secondary text-sm",children:"Recycle"})]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:n.auto_prune||!1,onChange:d=>o({...n,auto_prune:d.target.checked}),className:"checkbox-custom"}),e.jsx("span",{className:"text-text-secondary text-sm",children:"Auto-Prune"})]})]}),e.jsxs("div",{className:"flex gap-3 justify-end pt-4 border-t border-border-dark",children:[e.jsx("button",{type:"button",onClick:s,className:"px-4 py-2 rounded-lg bg-surface-dark border border-border-dark text-white text-sm font-bold hover:bg-[#2a3c50] transition-colors",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:t||!n.name,className:"px-4 py-2 rounded-lg bg-primary text-white text-sm font-bold hover:bg-primary/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:t?"Creating...":"Create Pool"})]})]})}function VS({pools:r}){const[t,s]=Ce.useState("list"),[n,o]=Ce.useState(!1),[l,d]=Ce.useState(!1),[c,u]=Ce.useState(null),[h,m]=Ce.useState(null),[x,y]=Ce.useState(new Set),[p,v]=Ce.useState(""),[N,B]=Ce.useState(null),[g,j]=Ce.useState(1),_=5,w=Nr(),{data:L,isLoading:K}=dt({queryKey:["backup-media"],queryFn:()=>ys.listMedia(),enabled:t==="list",refetchOnWindowFocus:!1}),{data:M,isLoading:V}=dt({queryKey:["storage-volumes"],queryFn:()=>ys.listStorageVolumes(),enabled:t!=="list"}),T=ft({mutationFn:ys.createStorageVolume,onSuccess:()=>{w.invalidateQueries({queryKey:["storage-volumes"]}),s("list")}}),ne=ft({mutationFn:({volumeId:te,data:J})=>ys.updateStorageVolume(te,J),onSuccess:()=>{w.invalidateQueries({queryKey:["storage-volumes"]}),d(!1),m(null)}}),Z=ft({mutationFn:ys.deleteStorageVolume,onSuccess:()=>{w.invalidateQueries({queryKey:["storage-volumes"]}),o(!1),u(null)}}),U=L?.media||[],q=M?.volumes||[],F=te=>{if(te===0)return"0 B";const J=1024,O=["B","KB","MB","GB","TB"],H=Math.floor(Math.log(te)/Math.log(J));return`${(te/Math.pow(J,H)).toFixed(2)} ${O[H]}`},le=te=>{const O={Full:{bg:"bg-green-500/10",text:"text-green-400",border:"border-green-500/20"},Append:{bg:"bg-blue-500/10",text:"text-blue-400",border:"border-blue-500/20"},Used:{bg:"bg-yellow-500/10",text:"text-yellow-400",border:"border-yellow-500/20"},Error:{bg:"bg-red-500/10",text:"text-red-400",border:"border-red-500/20"},Recycle:{bg:"bg-gray-500/10",text:"text-gray-400",border:"border-gray-500/20"},Purged:{bg:"bg-gray-500/10",text:"text-gray-400",border:"border-gray-500/20"},Online:{bg:"bg-green-500/10",text:"text-green-400",border:"border-green-500/20"},Offline:{bg:"bg-red-500/10",text:"text-red-400",border:"border-red-500/20"}}[te]||{bg:"bg-gray-500/10",text:"text-gray-400",border:"border-gray-500/20"};return e.jsx("span",{className:`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${O.bg} ${O.text} border ${O.border}`,children:te})},ae=U.filter(te=>{if(!p)return!0;const J=p.toLowerCase();return te.volume_name.toLowerCase().includes(J)||te.pool_name.toLowerCase().includes(J)||te.status.toLowerCase().includes(J)||te.media_type.toLowerCase().includes(J)}),se=Math.ceil(ae.length/_),fe=(g-1)*_,ye=fe+_,_e=ae.slice(fe,ye),xe=te=>{if(!te)return"-";try{return new Date(te).toLocaleString("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}catch{return te}},D=te=>{y(te?new Set(_e.map(J=>J.media_id)):new Set)},$=(te,J)=>{const O=new Set(x);J?O.add(te):O.delete(te),y(O)},X=U.find(te=>te.media_id===N);return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col md:flex-row gap-4 mb-6",children:[e.jsxs("button",{onClick:()=>s("list"),className:"bg-primary hover:bg-primary/90 text-white px-5 py-2 rounded shadow-sm flex items-center gap-2 text-sm font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary",children:[e.jsx("span",{className:"material-symbols-outlined text-lg",children:"format_list_bulleted"}),"List Current Volumes"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:()=>s("add"),className:"bg-[#1c2936] border border-border-dark text-white hover:bg-[#2a3c50] px-4 py-2 rounded flex items-center gap-2 text-sm font-medium transition-colors shadow-sm",children:[e.jsx("span",{className:"material-symbols-outlined text-lg text-green-500",children:"add"}),"Add Volume"]}),e.jsxs("button",{onClick:()=>s("delete"),className:"bg-[#1c2936] border border-border-dark text-white hover:bg-[#2a3c50] px-4 py-2 rounded flex items-center gap-2 text-sm font-medium transition-colors shadow-sm group",children:[e.jsx("span",{className:"material-symbols-outlined text-lg text-red-500 group-hover:text-red-400",children:"delete_outline"}),"Delete Volume"]}),e.jsxs("button",{onClick:()=>s("update"),className:"bg-[#1c2936] border border-border-dark text-white hover:bg-[#2a3c50] px-4 py-2 rounded flex items-center gap-2 text-sm font-medium transition-colors shadow-sm",children:[e.jsx("span",{className:"material-symbols-outlined text-lg text-text-secondary",children:"edit"}),"Update Volume"]})]}),e.jsxs("div",{className:"md:ml-auto relative",children:[e.jsx("span",{className:"absolute inset-y-0 left-0 flex items-center pl-3",children:e.jsx("span",{className:"material-symbols-outlined text-text-secondary text-lg",children:"search"})}),e.jsx("input",{type:"text",value:p,onChange:te=>{v(te.target.value),j(1)},className:"w-full md:w-64 bg-[#1c2936] border border-border-dark text-white text-sm rounded pl-10 pr-3 py-2 focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary placeholder-text-secondary shadow-sm",placeholder:"Filter volumes..."})]})]}),t==="list"&&e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"bg-[#1c2936] border border-border-dark rounded shadow-sm overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-4 border-b border-border-dark bg-[#1c2936] flex justify-between items-center",children:[e.jsx("h2",{className:"text-sm font-bold uppercase tracking-wider text-text-secondary",children:"Volume Inventory"}),e.jsx("div",{className:"flex gap-2 text-xs",children:e.jsxs("span",{className:"text-text-secondary",children:["Showing ",e.jsx("span",{className:"font-medium",children:fe+1})," to ",e.jsx("span",{className:"font-medium",children:Math.min(ye,ae.length)})," of"," ",e.jsx("span",{className:"font-medium",children:ae.length})," items"]})})]}),K?e.jsx("div",{className:"p-8 text-center text-text-secondary",children:"Loading media..."}):ae.length===0?e.jsx("div",{className:"p-12 text-center",children:e.jsx("p",{className:"text-text-secondary",children:"No media found"})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left text-sm whitespace-nowrap",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border-dark bg-[#1c2936]",children:[e.jsx("th",{className:"px-6 py-3 font-semibold text-text-secondary w-10",children:e.jsx("input",{type:"checkbox",checked:_e.length>0&&_e.every(te=>x.has(te.media_id)),onChange:te=>D(te.target.checked),className:"rounded border-border-dark text-primary focus:ring-primary bg-[#1c2936]"})}),e.jsxs("th",{className:"px-6 py-3 font-semibold text-text-secondary cursor-pointer hover:text-primary group",children:["Volume Name ",e.jsx("span",{className:"material-symbols-outlined text-xs align-middle opacity-0 group-hover:opacity-100",children:"arrow_downward"})]}),e.jsx("th",{className:"px-6 py-3 font-semibold text-text-secondary",children:"Pool"}),e.jsx("th",{className:"px-6 py-3 font-semibold text-text-secondary",children:"Status"}),e.jsx("th",{className:"px-6 py-3 font-semibold text-text-secondary",children:"Library"}),e.jsx("th",{className:"px-6 py-3 font-semibold text-text-secondary text-right",children:"Capacity"}),e.jsx("th",{className:"px-6 py-3 font-semibold text-text-secondary text-right",children:"Used"}),e.jsx("th",{className:"px-6 py-3 font-semibold text-text-secondary",children:"Retention"}),e.jsx("th",{className:"px-6 py-3 font-semibold text-text-secondary text-right",children:"Last Written"})]})}),e.jsx("tbody",{className:"divide-y divide-border-dark",children:_e.map(te=>{const J=N===te.media_id;return e.jsxs("tr",{onClick:()=>B(J?null:te.media_id),className:`hover:bg-[#2a3c50] transition-colors cursor-pointer border-l-4 ${J?"bg-primary/10 border-l-primary":"border-l-transparent"}`,children:[e.jsx("td",{className:"px-6 py-4",onClick:O=>O.stopPropagation(),children:e.jsx("input",{type:"checkbox",checked:J||x.has(te.media_id),onChange:O=>{$(te.media_id,O.target.checked),O.target.checked&&B(te.media_id)},onClick:O=>O.stopPropagation(),className:"rounded border-border-dark text-primary focus:ring-primary bg-[#1c2936]"})}),e.jsxs("td",{className:"px-6 py-4 font-medium text-white flex items-center gap-2",children:[e.jsx("span",{className:`material-symbols-outlined text-lg ${J?"text-primary":"text-text-secondary"}`,children:"hard_drive"}),te.volume_name]}),e.jsx("td",{className:"px-6 py-4 text-text-secondary",children:te.pool_name}),e.jsx("td",{className:"px-6 py-4",children:le(te.status)}),e.jsx("td",{className:"px-6 py-4 text-text-secondary",children:te.media_type&&(te.media_type.toLowerCase().includes("lto")||te.media_type.toLowerCase().includes("tape"))&&te.in_changer&&te.in_changer>0?e.jsxs("span",{children:[te.library_name||"Unknown"," ",te.slot&&te.slot>0?`(Slot ${te.slot})`:""]}):e.jsx("span",{className:"text-text-secondary/50",children:"-"})}),e.jsx("td",{className:"px-6 py-4 text-right text-text-secondary",children:F(te.max_vol_bytes)}),e.jsx("td",{className:"px-6 py-4 text-right text-white font-medium",children:F(te.vol_bytes)}),e.jsx("td",{className:"px-6 py-4 text-text-secondary",children:te.max_vol_bytes>0&&te.vol_bytes>0?"30 Days":"-"}),e.jsx("td",{className:"px-6 py-4 text-right text-text-secondary text-xs",children:xe(te.last_written)})]},te.media_id)})})]})}),e.jsxs("div",{className:"px-6 py-3 border-t border-border-dark bg-[#1c2936] flex items-center justify-between",children:[e.jsxs("div",{className:"text-xs text-text-secondary",children:["Showing ",e.jsx("span",{className:"font-medium",children:fe+1})," to ",e.jsx("span",{className:"font-medium",children:Math.min(ye,ae.length)})," of"," ",e.jsx("span",{className:"font-medium",children:ae.length})," results"]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{onClick:()=>j(te=>Math.max(1,te-1)),disabled:g===1,className:"p-1 rounded hover:bg-[#2a3c50] text-text-secondary disabled:opacity-50 disabled:cursor-not-allowed",children:e.jsx("span",{className:"material-symbols-outlined text-lg",children:"chevron_left"})}),e.jsx("button",{onClick:()=>j(te=>Math.min(se,te+1)),disabled:g>=se,className:"p-1 rounded hover:bg-[#2a3c50] text-text-secondary disabled:opacity-50 disabled:cursor-not-allowed",children:e.jsx("span",{className:"material-symbols-outlined text-lg",children:"chevron_right"})})]})]})]})]}),X&&e.jsxs("div",{className:"mt-8 bg-[#1c2936] border border-border-dark rounded shadow-sm",children:[e.jsxs("div",{className:"px-6 py-4 border-b border-border-dark flex justify-between items-center",children:[e.jsxs("h3",{className:"text-lg font-bold text-white font-display flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-primary",children:"info"}),"Volume Details: ",X.volume_name]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{className:"text-xs text-primary hover:underline font-medium",children:"View Jobs"}),e.jsx("span",{className:"text-text-secondary",children:"|"}),e.jsx("button",{className:"text-xs text-primary hover:underline font-medium",children:"Prune Volume"})]})]}),e.jsxs("div",{className:"p-6 grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6",children:[e.jsxs("div",{children:[e.jsx("span",{className:"block text-xs font-semibold text-text-secondary uppercase tracking-wider mb-1",children:"Volume ID"}),e.jsx("span",{className:"text-sm text-white",children:X.media_id})]}),e.jsxs("div",{children:[e.jsx("span",{className:"block text-xs font-semibold text-text-secondary uppercase tracking-wider mb-1",children:"Media Type"}),e.jsx("span",{className:"text-sm text-white",children:X.media_type})]}),e.jsxs("div",{children:[e.jsx("span",{className:"block text-xs font-semibold text-text-secondary uppercase tracking-wider mb-1",children:"Label Date"}),e.jsx("span",{className:"text-sm text-white",children:xe(X.last_written)||"-"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"block text-xs font-semibold text-text-secondary uppercase tracking-wider mb-1",children:"Storage Device"}),e.jsx("span",{className:"text-sm text-white",children:X.pool_name})]}),e.jsxs("div",{className:"col-span-1 md:col-span-2 lg:col-span-4 border-t border-border-dark pt-4 mt-2",children:[e.jsx("span",{className:"block text-xs font-semibold text-text-secondary uppercase tracking-wider mb-2",children:"Capacity Usage"}),e.jsx("div",{className:"w-full bg-[#2a3c50] rounded-full h-2.5 mb-1",children:e.jsx("div",{className:"bg-primary h-2.5 rounded-full",style:{width:`${X.max_vol_bytes>0?Math.min(100,X.vol_bytes/X.max_vol_bytes*100):0}%`}})}),e.jsxs("div",{className:"flex justify-between text-xs text-text-secondary",children:[e.jsxs("span",{children:[F(X.vol_bytes)," Used"]}),e.jsxs("span",{children:[F(X.max_vol_bytes)," Total"]})]})]})]}),e.jsxs("div",{className:"px-6 py-4 bg-[#1c2936] border-t border-border-dark flex justify-end gap-3",children:[e.jsx("button",{onClick:()=>B(null),className:"px-4 py-2 text-sm font-medium text-text-secondary hover:text-white transition-colors",children:"Close"}),e.jsx("button",{onClick:()=>{m({volume_id:X.media_id}),d(!0)},className:"bg-primary hover:bg-primary/90 text-white px-4 py-2 rounded text-sm font-medium transition-colors shadow-sm",children:"Edit Properties"})]})]})]}),t==="add"&&e.jsxs("div",{className:"rounded-lg border border-border-dark bg-surface-highlight p-6",children:[e.jsx("h3",{className:"text-white text-xl font-bold mb-4",children:"Create New Storage Volume"}),e.jsx("p",{className:"text-text-secondary text-sm mb-6",children:"Volumes are archive units where Bacula stores backed up data. Each volume belongs to a Pool and can be a tape or a disk file."}),e.jsx(WS,{pools:r,onSubmit:te=>{T.mutate(te)},isLoading:T.isPending,onCancel:()=>s("list")})]}),t==="delete"&&e.jsx("div",{className:"rounded-lg border border-border-dark bg-surface-highlight overflow-hidden shadow-sm",children:V?e.jsx("div",{className:"p-8 text-center text-text-secondary",children:"Loading volumes..."}):q.length===0?e.jsx("div",{className:"p-12 text-center",children:e.jsx("p",{className:"text-text-secondary",children:"No volumes found"})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"p-4 border-b border-border-dark",children:e.jsx("p",{className:"text-text-secondary text-sm mb-4",children:"Select a volume to delete. Volumes with data cannot be deleted."})}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-surface-dark border-b border-border-dark text-text-secondary text-xs uppercase tracking-wider",children:[e.jsx("th",{className:"px-6 py-4 font-semibold",children:"Volume Name"}),e.jsx("th",{className:"px-6 py-4 font-semibold",children:"Pool"}),e.jsx("th",{className:"px-6 py-4 font-semibold",children:"Status"}),e.jsx("th",{className:"px-6 py-4 font-semibold",children:"Size"}),e.jsx("th",{className:"px-6 py-4 font-semibold text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-border-dark text-sm",children:q.map(te=>e.jsxs("tr",{className:"hover:bg-surface-dark/50 transition-colors",children:[e.jsx("td",{className:"px-6 py-4 text-white font-medium",children:te.volume_name}),e.jsx("td",{className:"px-6 py-4 text-text-secondary",children:te.pool_name}),e.jsx("td",{className:"px-6 py-4",children:le(te.vol_status)}),e.jsxs("td",{className:"px-6 py-4 text-text-secondary font-mono text-xs",children:[F(te.vol_bytes)," / ",F(te.max_vol_bytes)]}),e.jsx("td",{className:"px-6 py-4 text-right",children:e.jsxs("button",{onClick:()=>{u(te),o(!0)},disabled:te.vol_bytes>0,className:`px-4 py-2 rounded-lg text-sm font-bold transition-colors ${te.vol_bytes>0?"bg-gray-500/20 text-gray-500 cursor-not-allowed":"bg-red-500/10 text-red-400 hover:bg-red-500/20 border border-red-500/20"}`,title:te.vol_bytes>0?"Cannot delete volume with data":"Delete volume",children:[e.jsx("span",{className:"material-symbols-outlined text-base mr-1 align-middle",children:"delete"}),"Delete"]})})]},te.volume_id))})]})})]})}),t==="update"&&e.jsx("div",{className:"rounded-lg border border-border-dark bg-surface-highlight overflow-hidden shadow-sm",children:V?e.jsx("div",{className:"p-8 text-center text-text-secondary",children:"Loading volumes..."}):q.length===0?e.jsx("div",{className:"p-12 text-center",children:e.jsx("p",{className:"text-text-secondary",children:"No volumes found"})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"p-4 border-b border-border-dark",children:e.jsx("p",{className:"text-text-secondary text-sm mb-4",children:"Select a volume to update its meta-data (Max Volume Bytes, Retention Period)."})}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-surface-dark border-b border-border-dark text-text-secondary text-xs uppercase tracking-wider",children:[e.jsx("th",{className:"px-6 py-4 font-semibold",children:"Volume Name"}),e.jsx("th",{className:"px-6 py-4 font-semibold",children:"Pool"}),e.jsx("th",{className:"px-6 py-4 font-semibold",children:"Status"}),e.jsx("th",{className:"px-6 py-4 font-semibold",children:"Max Size"}),e.jsx("th",{className:"px-6 py-4 font-semibold text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-border-dark text-sm",children:q.map(te=>e.jsxs("tr",{className:"hover:bg-surface-dark/50 transition-colors",children:[e.jsx("td",{className:"px-6 py-4 text-white font-medium",children:te.volume_name}),e.jsx("td",{className:"px-6 py-4 text-text-secondary",children:te.pool_name}),e.jsx("td",{className:"px-6 py-4",children:le(te.vol_status)}),e.jsx("td",{className:"px-6 py-4 text-text-secondary font-mono text-xs",children:F(te.max_vol_bytes)}),e.jsx("td",{className:"px-6 py-4 text-right",children:e.jsxs("button",{onClick:()=>{m(te),d(!0)},className:"px-4 py-2 rounded-lg text-sm font-bold transition-colors bg-blue-500/10 text-blue-400 hover:bg-blue-500/20 border border-blue-500/20",children:[e.jsx("span",{className:"material-symbols-outlined text-base mr-1 align-middle",children:"edit"}),"Update"]})})]},te.volume_id))})]})})]})}),n&&c&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-surface-highlight border border-border-dark rounded-lg p-6 max-w-md w-full mx-4",children:[e.jsx("h3",{className:"text-white text-xl font-bold mb-2",children:"Delete Storage Volume"}),e.jsxs("p",{className:"text-text-secondary text-sm mb-4",children:["Are you sure you want to delete volume ",e.jsx("span",{className:"text-white font-bold",children:c.volume_name}),"?"]}),c.vol_bytes>0&&e.jsx("div",{className:"bg-red-500/10 border border-red-500/20 rounded-lg p-3 mb-4",children:e.jsxs("p",{className:"text-red-400 text-sm",children:["⚠️ This volume contains ",F(c.vol_bytes)," of data. Volumes with data cannot be deleted."]})}),e.jsxs("div",{className:"flex gap-3 justify-end",children:[e.jsx("button",{onClick:()=>{o(!1),u(null)},className:"px-4 py-2 rounded-lg bg-surface-dark border border-border-dark text-white text-sm font-bold hover:bg-[#2a3c50] transition-colors",children:"Cancel"}),e.jsx("button",{onClick:()=>{c.vol_bytes===0&&Z.mutate(c.volume_id)},disabled:c.vol_bytes>0||Z.isPending,className:"px-4 py-2 rounded-lg bg-red-500 text-white text-sm font-bold hover:bg-red-600 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:Z.isPending?"Deleting...":"Delete Volume"})]})]})}),l&&h&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-surface-highlight border border-border-dark rounded-lg p-6 max-w-md w-full mx-4",children:[e.jsx("h3",{className:"text-white text-xl font-bold mb-2",children:"Update Storage Volume"}),e.jsxs("p",{className:"text-text-secondary text-sm mb-4",children:["Update meta-data for volume ",e.jsx("span",{className:"text-white font-bold",children:h.volume_name})]}),e.jsx(XS,{volume:h,onSubmit:te=>{ne.mutate({volumeId:h.volume_id,data:te})},isLoading:ne.isPending,onCancel:()=>{d(!1),m(null)}})]})})]})}function WS({pools:r,onSubmit:t,isLoading:s,onCancel:n}){const[o,l]=Ce.useState({volume_name:"",pool_name:"",media_type:"File",max_vol_bytes:"",vol_retention:""}),d=c=>{c.preventDefault(),t({volume_name:o.volume_name,pool_name:o.pool_name,media_type:o.media_type,max_vol_bytes:o.max_vol_bytes?parseInt(o.max_vol_bytes)*1024*1024*1024:void 0,vol_retention:o.vol_retention?parseInt(o.vol_retention):void 0})};return e.jsxs("form",{onSubmit:d,className:"flex flex-col gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-text-secondary text-sm font-medium mb-2",children:["Volume Name ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx("input",{type:"text",required:!0,value:o.volume_name,onChange:c=>l({...o,volume_name:c.target.value}),placeholder:"e.g., Vol-001, MyBackup-001",className:"w-full bg-surface-dark border border-border-dark rounded-lg px-4 py-2 text-white text-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent"}),e.jsx("p",{className:"text-text-secondary text-xs mt-1",children:"Unique name for the storage volume"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-text-secondary text-sm font-medium mb-2",children:["Pool ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsxs("select",{required:!0,value:o.pool_name,onChange:c=>l({...o,pool_name:c.target.value}),className:"w-full bg-surface-dark border border-border-dark rounded-lg px-4 py-2 text-white text-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent",children:[e.jsx("option",{value:"",children:"Select a pool"}),r.map(c=>e.jsx("option",{value:c.name,children:c.name},c.pool_id))]}),e.jsx("p",{className:"text-text-secondary text-xs mt-1",children:"Pool where this volume will be stored"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-text-secondary text-sm font-medium mb-2",children:"Media Type"}),e.jsxs("select",{value:o.media_type,onChange:c=>l({...o,media_type:c.target.value}),className:"w-full bg-surface-dark border border-border-dark rounded-lg px-4 py-2 text-white text-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent",children:[e.jsx("option",{value:"File",children:"File (Disk)"}),e.jsx("option",{value:"Tape",children:"Tape"})]}),e.jsx("p",{className:"text-text-secondary text-xs mt-1",children:"Type of storage media"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-text-secondary text-sm font-medium mb-2",children:"Maximum Volume Size (GB)"}),e.jsx("input",{type:"number",value:o.max_vol_bytes,onChange:c=>l({...o,max_vol_bytes:c.target.value}),placeholder:"e.g., 100",className:"w-full bg-surface-dark border border-border-dark rounded-lg px-4 py-2 text-white text-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent"}),e.jsx("p",{className:"text-text-secondary text-xs mt-1",children:"Maximum size in GB (optional, for disk volumes)"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-text-secondary text-sm font-medium mb-2",children:"Retention Period (Days)"}),e.jsx("input",{type:"number",value:o.vol_retention,onChange:c=>l({...o,vol_retention:c.target.value}),placeholder:"e.g., 30",className:"w-full bg-surface-dark border border-border-dark rounded-lg px-4 py-2 text-white text-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent"}),e.jsx("p",{className:"text-text-secondary text-xs mt-1",children:"Number of days to retain the volume (optional)"})]}),e.jsxs("div",{className:"flex gap-3 justify-end pt-4 border-t border-border-dark",children:[e.jsx("button",{type:"button",onClick:n,className:"px-4 py-2 rounded-lg bg-surface-dark border border-border-dark text-white text-sm font-bold hover:bg-[#2a3c50] transition-colors",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:s||!o.volume_name||!o.pool_name,className:"px-4 py-2 rounded-lg bg-primary text-white text-sm font-bold hover:bg-primary/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:s?"Creating...":"Create Volume"})]})]})}function XS({volume:r,onSubmit:t,isLoading:s,onCancel:n}){const[o,l]=Ce.useState({max_vol_bytes:r.max_vol_bytes>0?(r.max_vol_bytes/1073741824).toString():"",vol_retention:""}),d=c=>{c.preventDefault(),t({max_vol_bytes:o.max_vol_bytes?parseInt(o.max_vol_bytes)*1024*1024*1024:void 0,vol_retention:o.vol_retention?parseInt(o.vol_retention):void 0})};return e.jsxs("form",{onSubmit:d,className:"flex flex-col gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-text-secondary text-sm font-medium mb-2",children:"Maximum Volume Size (GB)"}),e.jsx("input",{type:"number",value:o.max_vol_bytes,onChange:c=>l({...o,max_vol_bytes:c.target.value}),placeholder:"e.g., 100",className:"w-full bg-surface-dark border border-border-dark rounded-lg px-4 py-2 text-white text-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent"}),e.jsxs("p",{className:"text-text-secondary text-xs mt-1",children:["Current: ",r.max_vol_bytes>0?`${(r.max_vol_bytes/(1024*1024*1024)).toFixed(2)} GB`:"Not set"]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-text-secondary text-sm font-medium mb-2",children:"Retention Period (Days)"}),e.jsx("input",{type:"number",value:o.vol_retention,onChange:c=>l({...o,vol_retention:c.target.value}),placeholder:"e.g., 30",className:"w-full bg-surface-dark border border-border-dark rounded-lg px-4 py-2 text-white text-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent"}),e.jsx("p",{className:"text-text-secondary text-xs mt-1",children:"Number of days to retain the volume"})]}),e.jsxs("div",{className:"flex gap-3 justify-end pt-4 border-t border-border-dark",children:[e.jsx("button",{type:"button",onClick:n,className:"px-4 py-2 rounded-lg bg-surface-dark border border-border-dark text-white text-sm font-bold hover:bg-[#2a3c50] transition-colors",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:s||!o.max_vol_bytes&&!o.vol_retention,className:"px-4 py-2 rounded-lg bg-primary text-white text-sm font-bold hover:bg-primary/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:s?"Updating...":"Update Volume"})]})]})}const Fv={listClients:async()=>(await ze.get("/bacula/clients")).data,getClient:async r=>(await ze.get(`/bacula/clients/${r}`)).data,registerClient:async r=>(await ze.post("/bacula/clients/register",r)).data,updateCapabilities:async(r,t)=>(await ze.post(`/bacula/clients/${r}/capabilities`,t)).data,getPendingUpdate:async r=>{const t=await ze.get(`/bacula/clients/${r}/pending-update`);return t.status===204?null:t.data},ping:async(r,t)=>{await ze.post(`/bacula/clients/${r}/ping`,{status:t})}},YS=[{label:"Files",value:"files"},{label:"Database",value:"database"},{label:"Application",value:"application"},{label:"Exchange",value:"exchange"},{label:"Mail",value:"mail"}];function Ev(r){return r?new Date(r).toLocaleString():"Never"}function JS(){const r=Nr(),{data:t,isLoading:s,error:n}=dt({queryKey:["bacula-clients"],queryFn:()=>Fv.listClients()}),[o,l]=Ce.useState(null),[d,c]=Ce.useState([]),[u,h]=Ce.useState(""),[m,x]=Ce.useState(""),y=ft({mutationFn:({id:B,backupTypes:g,notes:j})=>Fv.updateCapabilities(B,{backup_types:g,notes:j}),onSuccess:()=>{r.invalidateQueries({queryKey:["bacula-clients"]}),x("Capability update requested. The agent will pull changes shortly.")},onError:()=>{x("Failed to request capability update. Please try again.")}}),p=t?.find(B=>B.id===o)??null;Ce.useEffect(()=>{if(!p){c([]),h("");return}c(p.pending_backup_types?.length?p.pending_backup_types:p.backup_types),h(p.pending_notes??"")},[p]);const v=B=>{c(g=>g.includes(B)?g.filter(j=>j!==B):[...g,B])},N=B=>{B.preventDefault(),p&&y.mutate({id:p.id,backupTypes:d,notes:u})};return s?e.jsx("p",{className:"text-white",children:"Loading Bacula clients..."}):n?e.jsx("p",{className:"text-red-400",children:"Failed to load Bacula clients."}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("header",{children:[e.jsx("h1",{className:"text-3xl font-bold text-white",children:"Bacula Client Management"}),e.jsx("p",{className:"text-sm text-text-secondary",children:"Register agents, monitor their capabilities, and push updates."})]}),e.jsxs("section",{className:"bg-card-dark border border-border-dark rounded-xl p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-text-secondary",children:"Edit capabilities"}),e.jsx("p",{className:"text-lg font-bold text-white",children:p?p.hostname:"Select a client from the list"})]}),m&&e.jsx("p",{className:"text-xs text-primary",children:m})]}),e.jsxs("form",{className:"space-y-4",onSubmit:N,children:[e.jsxs("fieldset",{className:"space-y-2",children:[e.jsx("legend",{className:"text-sm font-semibold text-white",children:"Backup types"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:YS.map(B=>e.jsxs("label",{className:"flex items-center gap-2 rounded-lg border border-border-dark px-3 py-2 text-sm",children:[e.jsx("input",{type:"checkbox",checked:d.includes(B.value),onChange:()=>v(B.value),className:"h-4 w-4 rounded border-border-dark text-primary focus:ring-primary",disabled:!p}),e.jsx("span",{className:"text-white",children:B.label})]},B.value))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-semibold text-white",htmlFor:"notes",children:"Notes for agent"}),e.jsx("textarea",{id:"notes",rows:3,value:u,onChange:B=>h(B.target.value),className:"w-full rounded-lg border border-border-dark bg-[#111a22] px-3 py-2 text-sm text-white placeholder:text-text-secondary focus:border-primary focus:outline-none",placeholder:"Optional context for the capability update",disabled:!p})]}),e.jsx("button",{type:"submit",className:"inline-flex items-center justify-center gap-2 rounded-lg bg-primary px-4 py-2 text-sm font-semibold text-black",disabled:!p||d.length===0||y.isPending,children:y.isPending?"Requesting...":"Push capabilities"})]})]}),e.jsx("section",{className:"space-y-4",children:t?.map(B=>e.jsxs("article",{className:"rounded-xl border border-border-dark bg-card-dark p-5 text-sm text-white",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-semibold text-white",children:B.hostname}),e.jsx("p",{className:"text-xs text-text-secondary",children:B.agent_version||"Unknown version"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs uppercase tracking-wide text-text-secondary",children:"Status"}),e.jsx("span",{className:"text-sm font-semibold text-primary",children:B.status})]}),e.jsx("button",{className:"rounded-lg border border-border-dark px-3 py-1 text-xs font-semibold text-white",onClick:()=>l(B.id),children:"Edit capabilities"})]}),e.jsxs("div",{className:"mt-4 grid grid-cols-2 gap-4 text-xs",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-text-secondary",children:"Backup types"}),e.jsx("p",{className:"text-sm text-white",children:B.backup_types.join(", ")})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-text-secondary",children:"Pending push"}),e.jsx("p",{className:"text-sm text-white",children:B.pending_backup_types?.length?B.pending_backup_types.join(", "):"None"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-text-secondary",children:"Last seen"}),e.jsx("p",{className:"text-sm text-white",children:Ev(B.last_seen)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-text-secondary",children:"Registered by"}),e.jsx("p",{className:"text-sm text-white",children:B.registered_by})]})]}),e.jsxs("div",{className:"mt-4 space-y-2 text-xs",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-text-secondary",children:"Capability history"}),e.jsxs("ul",{className:"space-y-1",children:[B.capability_history?.slice(0,3).map(g=>e.jsxs("li",{className:"flex justify-between text-white",children:[e.jsxs("span",{children:[g.source.toUpperCase()," • ",g.backup_types.join(", ")]}),e.jsx("span",{className:"text-text-secondary",children:Ev(g.requested_at)})]},`${B.id}-${g.requested_at}`)),!B.capability_history?.length&&e.jsx("li",{className:"text-text-secondary",children:"No history yet."})]})]})]},B.id))})]})}function ZS(){const[r,t]=Ce.useState([]),[s,n]=Ce.useState(""),[o,l]=Ce.useState(!1),[d,c]=Ce.useState("system"),u=Ce.useRef(null),h=Ce.useRef(null);Ce.useEffect(()=>{u.current&&(u.current.scrollTop=u.current.scrollHeight)},[r]),Ce.useEffect(()=>{h.current&&h.current.focus()},[]);const m=ft({mutationFn:async N=>(await ze.post("/system/execute",{command:N,service:d})).data,onSuccess:(N,B)=>{t(g=>[...g,{command:B,output:N.output||N.error||"Command executed",timestamp:new Date,error:!!N.error,service:d}]),n(""),l(!1),setTimeout(()=>{h.current&&h.current.focus()},100)},onError:N=>{t(B=>[...B,{command:s,output:N?.response?.data?.error||N?.response?.data?.output||N.message||"Error executing command",timestamp:new Date,error:!0,service:d}]),n(""),l(!1),setTimeout(()=>{h.current&&h.current.focus()},100)}}),x=N=>{N.preventDefault();const B=s.trim();!B||o||(l(!0),m.mutate(B))},y=N=>{N.ctrlKey&&N.key==="l"&&(N.preventDefault(),confirm("Clear terminal history?")&&t([])),N.key==="ArrowUp"&&N.preventDefault()},p=()=>{confirm("Clear terminal history?")&&t([])},v=N=>({system:["ls -la","df -h","free -h","systemctl status scst","scstadmin -list_target","scstadmin -list_device","ip addr show","journalctl -u calypso-api -n 50","ps aux | grep calypso","netstat -tulpn | grep 8080"],scst:["scstadmin -list_target","scstadmin -list_device","scstadmin -list_handler","scstadmin -list_driver","scstadmin -list_group","scstadmin -list","cat /etc/scst.conf","systemctl status scst","systemctl status iscsi-scst"],storage:["zfs list","zpool status","zpool list","lsblk","df -h","zfs get all","zpool get all"],backup:['bconsole -c "list jobs"','bconsole -c "list clients"','bconsole -c "list pools"',"systemctl status bacula-director","systemctl status bacula-sd","systemctl status bacula-fd"],tape:["lsscsi -g","mtx -f /dev/sgX status","sg_inq /dev/sgX","systemctl status mhvtl"]})[N]||[];return e.jsx("div",{className:"flex-1 overflow-y-auto p-8",children:e.jsxs("div",{className:"max-w-[1400px] mx-auto flex flex-col gap-6 h-full",children:[e.jsxs("div",{className:"flex flex-wrap justify-between items-end gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("h1",{className:"text-white text-3xl font-extrabold leading-tight tracking-tight flex items-center gap-3",children:[e.jsx(Uh,{className:"text-primary",size:32}),"Terminal Console"]}),e.jsx("p",{className:"text-text-secondary text-base font-normal",children:"Execute shell commands and manage all appliance services"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(ct,{variant:"outline",onClick:p,className:"flex items-center gap-2",children:[e.jsx(es,{size:16}),e.jsx("span",{children:"Clear"})]})})]}),e.jsxs("div",{className:"flex items-center gap-4 p-4 bg-card-dark border border-border-dark rounded-lg",children:[e.jsx("span",{className:"text-text-secondary text-sm font-medium",children:"Service:"}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:["system","scst","storage","backup","tape"].map(N=>e.jsx("button",{onClick:()=>c(N),className:`px-3 py-1.5 rounded-lg text-xs font-medium transition-colors ${d===N?"bg-primary text-white":"bg-[#0f161d] text-text-secondary hover:text-white hover:bg-white/5"}`,children:N.charAt(0).toUpperCase()+N.slice(1)},N))})]}),e.jsxs("div",{className:"flex-1 flex flex-col bg-[#0a0f14] border border-border-dark rounded-lg overflow-hidden min-h-[600px]",children:[e.jsxs("div",{ref:u,className:"flex-1 overflow-y-auto p-4 custom-scrollbar",style:{minHeight:"400px"},children:[r.length===0?e.jsxs("div",{className:"text-text-secondary",children:[e.jsxs("div",{className:"mb-4 flex items-center gap-2",children:[e.jsx(Uh,{className:"text-primary",size:20}),e.jsx("span",{className:"text-white font-semibold",children:"Terminal Console"}),e.jsx("span",{className:"text-xs px-2 py-0.5 bg-primary/20 text-primary rounded",children:d})]}),e.jsx("div",{className:"mb-2",children:"Type commands below to execute shell commands"}),e.jsxs("div",{className:"text-xs opacity-70 mt-4",children:[e.jsxs("div",{className:"font-semibold mb-2",children:["Common commands for ",d,":"]}),e.jsx("div",{className:"ml-4 space-y-1",children:v(d).map((N,B)=>e.jsxs("div",{children:["• ",e.jsx("span",{className:"text-primary font-mono",children:N})]},B))})]})]}):r.map((N,B)=>e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"text-primary mb-2 font-mono text-sm flex items-center gap-2",children:[e.jsx("span",{className:"text-text-secondary",children:"$"}),e.jsx("span",{className:"text-white",children:N.command}),N.service&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 bg-primary/20 text-primary rounded",children:N.service}),e.jsx("span",{className:"text-text-secondary text-xs ml-auto",children:new Date(N.timestamp).toLocaleTimeString()})]}),e.jsx("div",{className:`font-mono text-xs leading-relaxed whitespace-pre overflow-x-auto ${N.error?"text-red-400":"text-green-400"}`,style:{fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace',lineHeight:"1.6",tabSize:2},children:N.output})]},B)),o&&e.jsxs("div",{className:"text-text-secondary flex items-center gap-2",children:[e.jsx(Cn,{size:16,className:"animate-spin"}),e.jsx("span",{children:"Executing command..."})]})]}),e.jsx("div",{className:"flex-none border-t border-border-dark bg-[#161f29]",children:e.jsxs("form",{onSubmit:x,className:"flex items-center",children:[e.jsxs("div",{className:"px-4 flex items-center gap-2",children:[e.jsx("span",{className:"text-primary font-mono text-sm",children:"$"}),e.jsx("span",{className:"text-xs text-text-secondary px-1.5 py-0.5 bg-primary/20 text-primary rounded",children:d})]}),e.jsx("input",{ref:h,type:"text",value:s,onChange:N=>n(N.target.value),onKeyDown:y,disabled:o,placeholder:`Enter ${d} command...`,className:"flex-1 bg-transparent text-white font-mono text-sm py-3 focus:outline-none disabled:opacity-50"}),e.jsx("button",{type:"submit",disabled:!s.trim()||o,className:"px-4 py-3 text-primary hover:text-white disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:e.jsx(C6,{size:16,className:o?"animate-spin":""})})]})})]}),e.jsxs("div",{className:"flex-none px-6 py-3 border-t border-border-dark bg-[#141d26] flex items-center justify-between text-xs text-text-secondary",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("span",{children:"Terminal Console - Command Execution"}),e.jsxs("span",{children:["• ",r.length," commands executed"]})]}),e.jsxs("div",{children:["Press ",e.jsx("kbd",{className:"px-1.5 py-0.5 bg-[#0a0f14] border border-border-dark rounded text-xs",children:"Ctrl+L"})," to clear"]})]})]})})}const rg={listShares:async()=>(await ze.get("/shares")).data.shares||[],getShare:async r=>(await ze.get(`/shares/${r}`)).data,createShare:async r=>(await ze.post("/shares",r)).data,updateShare:async(r,t)=>(await ze.put(`/shares/${r}`,t)).data,deleteShare:async r=>{await ze.delete(`/shares/${r}`)}};function $S(){const r=Nr(),[t,s]=Ce.useState(null),[n,o]=Ce.useState(""),[l,d]=Ce.useState(!1),[c,u]=Ce.useState("configuration"),[h,m]=Ce.useState(!1),[x,y]=Ce.useState({dataset_id:"",nfs_enabled:!1,nfs_options:"rw,sync,no_subtree_check",nfs_clients:[],smb_enabled:!1,smb_share_name:"",smb_comment:"",smb_guest_ok:!1,smb_read_only:!1,smb_browseable:!0}),[p,v]=Ce.useState(""),{data:N=[],isLoading:B}=dt({queryKey:["shares"],queryFn:rg.listShares,refetchInterval:5e3,staleTime:0}),{data:g=[]}=dt({queryKey:["storage","zfs","pools"],queryFn:sn.listPools}),[j,_]=Ce.useState([]);Ce.useEffect(()=>{const U=async()=>{const q=[];for(const F of g)try{const ae=(await sn.listDatasets(F.id)).filter(se=>se.type==="filesystem");q.push(...ae)}catch(le){console.error(`Failed to fetch datasets for pool ${F.id}:`,le)}_(q)};g.length>0&&U()},[g]);const w=ft({mutationFn:rg.createShare,onSuccess:()=>{r.invalidateQueries({queryKey:["shares"]}),d(!1),y({dataset_id:"",nfs_enabled:!1,nfs_options:"rw,sync,no_subtree_check",nfs_clients:[],smb_enabled:!1,smb_share_name:"",smb_comment:"",smb_guest_ok:!1,smb_read_only:!1,smb_browseable:!0}),alert("Share created successfully!")},onError:U=>{const q=U?.response?.data?.error||U?.message||"Failed to create share";alert(`Error: ${q}`),console.error("Failed to create share:",U)}}),L=ft({mutationFn:({id:U,data:q})=>rg.updateShare(U,q),onSuccess:()=>{r.invalidateQueries({queryKey:["shares"]})}}),K=N.filter(U=>U.dataset_name.toLowerCase().includes(n.toLowerCase())||U.mount_point.toLowerCase().includes(n.toLowerCase())),M=U=>{if(U?.preventDefault(),U?.stopPropagation(),console.log("Creating share with data:",x),!x.dataset_id){alert("Please select a dataset");return}if(!x.nfs_enabled&&!x.smb_enabled){alert("At least one protocol (NFS or SMB) must be enabled");return}const q={dataset_id:x.dataset_id,nfs_enabled:x.nfs_enabled,smb_enabled:x.smb_enabled};x.nfs_enabled&&(q.nfs_options=x.nfs_options||"rw,sync,no_subtree_check",q.nfs_clients=x.nfs_clients||[]),x.smb_enabled&&(q.smb_share_name=x.smb_share_name||"",q.smb_comment=x.smb_comment||"",q.smb_guest_ok=x.smb_guest_ok||!1,q.smb_read_only=x.smb_read_only||!1,q.smb_browseable=x.smb_browseable!==void 0?x.smb_browseable:!0),console.log("Submitting share data:",q),w.mutate(q)},V=U=>{L.mutate({id:U.id,data:{nfs_enabled:!U.nfs_enabled}})},T=U=>{L.mutate({id:U.id,data:{smb_enabled:!U.smb_enabled}})},ne=U=>{if(!p.trim())return;const q=[...U.nfs_clients||[],p.trim()];L.mutate({id:U.id,data:{nfs_clients:q}}),v("")},Z=(U,q)=>{const F=(U.nfs_clients||[]).filter(le=>le!==q);L.mutate({id:U.id,data:{nfs_clients:F}})};return e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col bg-background-dark",children:[e.jsx("div",{className:"flex-shrink-0 border-b border-border-dark bg-background-dark/95 backdrop-blur z-10",children:e.jsxs("div",{className:"flex flex-col gap-4 p-6 pb-4",children:[e.jsxs("div",{className:"flex flex-wrap justify-between gap-3 items-center",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("h2",{className:"text-white text-3xl font-black leading-tight tracking-[-0.033em]",children:"Shares Management"}),e.jsxs("div",{className:"flex items-center gap-2 text-text-secondary text-sm",children:[e.jsx("span",{children:"Storage"}),e.jsx(Ka,{size:14}),e.jsx("span",{children:"Shares"}),e.jsx(Ka,{size:14}),e.jsx("span",{className:"text-white",children:"Overview"})]})]}),e.jsxs(ct,{onClick:()=>d(!0),className:"flex items-center gap-2 px-4 h-10 rounded-lg bg-primary hover:bg-blue-600 text-white text-sm font-bold",children:[e.jsx(Ks,{size:20}),e.jsx("span",{children:"Create New Share"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mt-2",children:[e.jsxs("div",{className:"flex flex-col gap-1 rounded-lg p-4 border border-border-dark bg-surface-dark/50",children:[e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsx("p",{className:"text-text-secondary text-xs font-bold uppercase tracking-wider",children:"SMB Service"}),e.jsx("div",{className:"size-2 rounded-full bg-emerald-500 shadow-[0_0_8px_rgba(16,185,129,0.5)]"})]}),e.jsx("p",{className:"text-white text-xl font-bold leading-tight",children:"Running"}),e.jsx("p",{className:"text-emerald-500 text-xs mt-1",children:"Port 445 Active"})]}),e.jsxs("div",{className:"flex flex-col gap-1 rounded-lg p-4 border border-border-dark bg-surface-dark/50",children:[e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsx("p",{className:"text-text-secondary text-xs font-bold uppercase tracking-wider",children:"NFS Service"}),e.jsx("div",{className:"size-2 rounded-full bg-emerald-500 shadow-[0_0_8px_rgba(16,185,129,0.5)]"})]}),e.jsx("p",{className:"text-white text-xl font-bold leading-tight",children:"Running"}),e.jsx("p",{className:"text-emerald-500 text-xs mt-1",children:"Port 2049 Active"})]}),e.jsxs("div",{className:"flex flex-col gap-1 rounded-lg p-4 border border-border-dark bg-surface-dark/50",children:[e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsx("p",{className:"text-text-secondary text-xs font-bold uppercase tracking-wider",children:"Throughput"}),e.jsx(S6,{className:"text-text-secondary",size:20})]}),e.jsx("p",{className:"text-white text-xl font-bold leading-tight",children:"565 MB/s"}),e.jsx("p",{className:"text-text-secondary text-xs mt-1",children:"14 Clients Connected"})]})]})]})}),e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[e.jsxs("div",{className:"w-full lg:w-[400px] flex flex-col border-r border-border-dark bg-background-dark flex-shrink-0",children:[e.jsx("div",{className:"p-4 border-b border-border-dark bg-background-dark sticky top-0 z-10",children:e.jsxs("div",{className:"relative",children:[e.jsx(io,{className:"absolute left-3 top-2.5 text-text-secondary",size:18}),e.jsx("input",{className:"w-full bg-surface-dark border border-border-dark rounded-lg pl-10 pr-4 py-2.5 text-sm text-white focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary placeholder-text-secondary",placeholder:"Filter shares...",value:n,onChange:U=>o(U.target.value)})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:B?e.jsx("div",{className:"p-4 text-center text-text-secondary text-sm",children:"Loading shares..."}):K.length===0?e.jsx("div",{className:"p-4 text-center text-text-secondary text-sm",children:"No shares found"}):K.map(U=>e.jsx("div",{onClick:()=>s(U),className:`group flex flex-col border-b border-border-dark/50 cursor-pointer transition-colors ${t?.id===U.id?"bg-primary/10 border-l-4 border-l-primary":"hover:bg-surface-dark"}`,children:e.jsxs("div",{className:`px-4 py-3 flex items-start gap-3 ${t?.id===U.id?"pl-3":""}`,children:[t?.id===U.id?e.jsx(Tb,{className:"text-primary mt-1",size:20}):e.jsx(au,{className:"text-text-secondary mt-1",size:20}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex justify-between items-center mb-1",children:e.jsx("h3",{className:`text-sm truncate ${t?.id===U.id?"font-bold text-white":"font-medium text-white"}`,children:U.dataset_name})}),e.jsx("p",{className:`text-xs truncate mb-2 ${t?.id===U.id?"text-primary/80":"text-text-secondary"}`,children:U.mount_point||"No mount point"}),e.jsxs("div",{className:"flex gap-2",children:[U.smb_enabled?e.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-bold border ${t?.id===U.id?"bg-surface-dark text-text-secondary border-border-dark":"bg-emerald-500/10 text-emerald-500 border-emerald-500/20"}`,children:"SMB"}):null,U.nfs_enabled&&e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-bold bg-emerald-500/10 text-emerald-500 border border-emerald-500/20",children:"NFS"})]})]}),t?.id!==U.id&&e.jsx(Ka,{className:"text-text-secondary text-[18px]",size:18})]})},U.id))}),e.jsx("div",{className:"p-4 border-t border-border-dark bg-background-dark text-center",children:e.jsxs("p",{className:"text-xs text-text-secondary",children:["Showing ",K.length," of ",N.length," shares"]})})]}),e.jsx("div",{className:"flex-1 flex flex-col overflow-hidden bg-background-light dark:bg-[#0d141c]",children:t?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"p-6 pb-0 flex flex-col gap-6",children:[e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsx("div",{children:e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"bg-primary p-2 rounded-lg text-white",children:e.jsx(Tb,{size:20})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-white",children:t.dataset_name.split("/").pop()||t.dataset_name}),e.jsx("p",{className:"text-text-secondary text-sm font-mono",children:t.dataset_name})]})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(ct,{variant:"outline",className:"flex items-center justify-center rounded-lg h-9 px-4 border border-border-dark text-white text-sm font-medium hover:bg-surface-dark transition-colors",children:[e.jsx(hp,{size:18,className:"mr-2"}),"Revert"]}),e.jsxs(ct,{className:"flex items-center justify-center rounded-lg h-9 px-4 bg-primary text-white text-sm font-bold shadow-lg shadow-primary/20 hover:bg-blue-600 transition-colors",children:[e.jsx(up,{size:18,className:"mr-2"}),"Save Changes"]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsxs("div",{className:`flex items-center justify-between p-4 rounded-xl border ${t.smb_enabled?"border-primary/50 bg-primary/5":"border-border-dark bg-surface-dark/40"}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`p-2 rounded-lg ${t.smb_enabled?"bg-primary/20 text-primary":"bg-surface-dark text-text-secondary"}`,children:e.jsx(Ib,{size:20})}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-sm font-bold text-white",children:"SMB Protocol"}),e.jsx("span",{className:"text-xs text-text-secondary",children:"Windows File Sharing"})]})]}),e.jsxs("button",{onClick:()=>T(t),className:`relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 focus:ring-offset-background-dark ${t.smb_enabled?"bg-primary":"bg-slate-700"}`,children:[e.jsx("span",{className:"sr-only",children:"Use setting"}),e.jsx("span",{className:`pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out ${t.smb_enabled?"translate-x-5":"translate-x-0"}`})]})]}),e.jsxs("div",{className:`flex items-center justify-between p-4 rounded-xl border ${t.nfs_enabled?"border-primary/50 bg-primary/5":"border-border-dark bg-surface-dark/40"}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`p-2 rounded-lg ${t.nfs_enabled?"bg-primary/20 text-primary":"bg-surface-dark text-text-secondary"}`,children:e.jsx(_6,{size:20})}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-sm font-bold text-white",children:"NFS Protocol"}),e.jsx("span",{className:"text-xs text-text-secondary",children:"Unix/Linux File Sharing"})]})]}),e.jsxs("button",{onClick:()=>V(t),className:`relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 focus:ring-offset-background-dark ${t.nfs_enabled?"bg-primary":"bg-slate-700"}`,children:[e.jsx("span",{className:"sr-only",children:"Use setting"}),e.jsx("span",{className:`pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out ${t.nfs_enabled?"translate-x-5":"translate-x-0"}`})]})]})]}),e.jsx("div",{className:"border-b border-border-dark mt-2",children:e.jsxs("div",{className:"flex gap-6",children:[e.jsxs("button",{onClick:()=>u("configuration"),className:`pb-3 border-b-2 text-sm flex items-center gap-2 transition-colors ${c==="configuration"?"border-primary text-primary font-bold":"border-transparent text-text-secondary hover:text-white font-medium"}`,children:[e.jsx(vc,{size:18}),"Configuration"]}),e.jsxs("button",{onClick:()=>u("permissions"),className:`pb-3 border-b-2 text-sm flex items-center gap-2 transition-colors ${c==="permissions"?"border-primary text-primary font-bold":"border-transparent text-text-secondary hover:text-white font-medium"}`,children:[e.jsx(Xm,{size:18}),"Permissions (ACL)"]}),e.jsxs("button",{onClick:()=>u("clients"),className:`pb-3 border-b-2 text-sm flex items-center gap-2 transition-colors ${c==="clients"?"border-primary text-primary font-bold":"border-transparent text-text-secondary hover:text-white font-medium"}`,children:[e.jsx(ya,{size:18}),"Connected Clients",e.jsx("span",{className:"bg-surface-dark text-white text-[10px] px-1.5 py-0.5 rounded-full ml-1",children:"8"})]})]})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:e.jsxs("div",{className:"max-w-4xl flex flex-col gap-6",children:[c==="configuration"&&e.jsxs(e.Fragment,{children:[t.nfs_enabled&&e.jsxs("div",{className:"rounded-xl border border-border-dark bg-surface-dark overflow-hidden",children:[e.jsxs("div",{className:"px-5 py-4 border-b border-border-dark flex justify-between items-center bg-[#1c2a39]",children:[e.jsxs("h3",{className:"text-sm font-bold text-white flex items-center gap-2",children:[e.jsx(ya,{className:"text-primary",size:20}),"NFS Configuration"]}),e.jsx("span",{className:"text-xs text-emerald-500 font-medium px-2 py-1 bg-emerald-500/10 rounded border border-emerald-500/20",children:"Active"})]}),e.jsxs("div",{className:"p-5 flex flex-col gap-5",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-5",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-xs font-semibold text-text-secondary uppercase",children:"Allowed Subnets / IPs"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{className:"flex-1 bg-background-dark border border-border-dark rounded-lg px-3 py-2 text-sm text-white focus:border-primary focus:ring-1 focus:ring-primary font-mono",type:"text",placeholder:"192.168.10.0/24",value:p,onChange:U=>v(U.target.value),onKeyPress:U=>{U.key==="Enter"&&ne(t)}}),e.jsx("button",{onClick:()=>ne(t),className:"p-2 bg-surface-dark hover:bg-border-dark border border-border-dark rounded-lg text-white",children:e.jsx(Ks,{size:18})})]}),e.jsx("p",{className:"text-xs text-text-secondary",children:"CIDR notation supported. Use comma for multiple entries."}),t.nfs_clients&&t.nfs_clients.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:t.nfs_clients.map(U=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-primary/20 text-primary text-xs rounded border border-primary/30",children:[U,e.jsx("button",{onClick:()=>Z(t,U),className:"hover:text-red-400",children:e.jsx(Zs,{size:14})})]},U))})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-xs font-semibold text-text-secondary uppercase",children:"Map Root User"}),e.jsxs("div",{className:"relative",children:[e.jsxs("select",{className:"w-full bg-background-dark border border-border-dark rounded-lg px-3 py-2 text-sm text-white focus:border-primary focus:ring-1 focus:ring-primary appearance-none",children:[e.jsx("option",{children:"root (User ID 0)"}),e.jsx("option",{children:"admin"}),e.jsx("option",{children:"nobody"})]}),e.jsx(wh,{className:"absolute right-3 top-2.5 text-text-secondary pointer-events-none",size:18})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-5",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-xs font-semibold text-text-secondary uppercase",children:"Security Profile"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("label",{className:"flex items-center gap-2 px-3 py-2 rounded-lg border border-border-dark bg-background-dark cursor-pointer flex-1",children:[e.jsx("input",{checked:!0,className:"text-primary focus:ring-primary bg-surface-dark border-border-dark",name:"sec",type:"radio"}),e.jsx("span",{className:"text-sm text-white",children:"sys (Default)"})]}),e.jsxs("label",{className:"flex items-center gap-2 px-3 py-2 rounded-lg border border-border-dark bg-background-dark cursor-pointer flex-1",children:[e.jsx("input",{className:"text-primary focus:ring-primary bg-surface-dark border-border-dark",name:"sec",type:"radio"}),e.jsx("span",{className:"text-sm text-white",children:"krb5"})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-xs font-semibold text-text-secondary uppercase",children:"Sync Mode"}),e.jsxs("div",{className:"relative",children:[e.jsxs("select",{className:"w-full bg-background-dark border border-border-dark rounded-lg px-3 py-2 text-sm text-white focus:border-primary focus:ring-1 focus:ring-primary appearance-none",children:[e.jsx("option",{children:"Standard"}),e.jsx("option",{children:"Always Sync"}),e.jsx("option",{children:"Disabled (Async)"})]}),e.jsx(wh,{className:"absolute right-3 top-2.5 text-text-secondary pointer-events-none",size:18})]})]})]})]})]}),t.smb_enabled&&e.jsxs("div",{className:"rounded-xl border border-border-dark bg-surface-dark overflow-hidden",children:[e.jsxs("div",{className:"px-5 py-4 border-b border-border-dark flex justify-between items-center bg-[#1c2a39]",children:[e.jsxs("h3",{className:"text-sm font-bold text-white flex items-center gap-2",children:[e.jsx(Ib,{className:"text-primary",size:20}),"SMB Configuration"]}),e.jsx("span",{className:"text-xs text-emerald-500 font-medium px-2 py-1 bg-emerald-500/10 rounded border border-emerald-500/20",children:"Active"})]}),e.jsxs("div",{className:"p-5 flex flex-col gap-5",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-5",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-xs font-semibold text-text-secondary uppercase",children:"Share Name"}),e.jsx("input",{className:"w-full bg-background-dark border border-border-dark rounded-lg px-3 py-2 text-sm text-white focus:border-primary focus:ring-1 focus:ring-primary",type:"text",value:t.smb_share_name||"",onChange:U=>{L.mutate({id:t.id,data:{smb_share_name:U.target.value}})}})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-xs font-semibold text-text-secondary uppercase",children:"Path"}),e.jsx("input",{className:"w-full bg-background-dark border border-border-dark rounded-lg px-3 py-2 text-sm text-white focus:border-primary focus:ring-1 focus:ring-primary font-mono",type:"text",value:t.smb_path||t.mount_point||"",readOnly:!0})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-xs font-semibold text-text-secondary uppercase",children:"Comment"}),e.jsx("input",{className:"w-full bg-background-dark border border-border-dark rounded-lg px-3 py-2 text-sm text-white focus:border-primary focus:ring-1 focus:ring-primary",type:"text",value:t.smb_comment||"",onChange:U=>{L.mutate({id:t.id,data:{smb_comment:U.target.value}})}})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t.smb_guest_ok,onChange:U=>{L.mutate({id:t.id,data:{smb_guest_ok:U.target.checked}})},className:"rounded border-border-dark bg-background-dark text-primary focus:ring-primary h-4 w-4"}),e.jsx("span",{className:"text-sm text-white",children:"Allow Guest Access"})]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t.smb_read_only,onChange:U=>{L.mutate({id:t.id,data:{smb_read_only:U.target.checked}})},className:"rounded border-border-dark bg-background-dark text-primary focus:ring-primary h-4 w-4"}),e.jsx("span",{className:"text-sm text-white",children:"Read Only"})]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t.smb_browseable,onChange:U=>{L.mutate({id:t.id,data:{smb_browseable:U.target.checked}})},className:"rounded border-border-dark bg-background-dark text-primary focus:ring-primary h-4 w-4"}),e.jsx("span",{className:"text-sm text-white",children:"Browseable"})]})]})]})]}),e.jsxs("div",{className:"rounded-xl border border-border-dark bg-surface-dark overflow-hidden",children:[e.jsxs("button",{onClick:()=>m(!h),className:"w-full px-5 py-4 flex justify-between items-center hover:bg-[#1c2a39] transition-colors text-left",children:[e.jsxs("h3",{className:"text-sm font-bold text-white flex items-center gap-2",children:[e.jsx(vc,{className:"text-text-secondary",size:20}),"Advanced Attributes"]}),e.jsx(wh,{className:`text-text-secondary transition-transform ${h?"rotate-180":""}`,size:20})]}),h&&e.jsxs("div",{className:"p-5 border-t border-border-dark flex flex-wrap gap-4",children:[e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",className:"rounded border-border-dark bg-background-dark text-primary focus:ring-primary h-4 w-4"}),e.jsx("span",{className:"text-sm text-white",children:"Read Only"})]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{checked:!0,type:"checkbox",className:"rounded border-border-dark bg-background-dark text-primary focus:ring-primary h-4 w-4"}),e.jsx("span",{className:"text-sm text-white",children:"Enable Compression (LZ4)"})]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",className:"rounded border-border-dark bg-background-dark text-primary focus:ring-primary h-4 w-4"}),e.jsx("span",{className:"text-sm text-white",children:"Enable Deduplication"})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex justify-between items-end",children:[e.jsx("h3",{className:"text-base font-bold text-white",children:"Top Active Clients"}),e.jsx("a",{className:"text-sm text-primary hover:text-blue-400 font-medium cursor-pointer",href:"#",children:"View all clients"})]}),e.jsx("div",{className:"rounded-lg border border-border-dark overflow-hidden bg-surface-dark",children:e.jsxs("table",{className:"w-full text-sm text-left",children:[e.jsx("thead",{className:"bg-background-dark text-text-secondary font-medium border-b border-border-dark",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3",children:"IP Address"}),e.jsx("th",{className:"px-4 py-3",children:"User"}),e.jsx("th",{className:"px-4 py-3",children:"Protocol"}),e.jsx("th",{className:"px-4 py-3 text-right",children:"Throughput"}),e.jsx("th",{className:"px-4 py-3 text-right",children:"Action"})]})}),e.jsxs("tbody",{className:"text-white divide-y divide-border-dark",children:[e.jsxs("tr",{children:[e.jsx("td",{className:"px-4 py-3 font-mono",children:"192.168.10.105"}),e.jsx("td",{className:"px-4 py-3",children:"esxi-host-01"}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"bg-primary/20 text-primary px-1.5 py-0.5 rounded text-xs font-bold",children:"NFS"})}),e.jsx("td",{className:"px-4 py-3 text-right font-mono text-text-secondary",children:"420 MB/s"}),e.jsx("td",{className:"px-4 py-3 text-right",children:e.jsx("button",{className:"text-text-secondary hover:text-red-400",title:"Disconnect",children:e.jsx(zf,{size:18})})})]}),e.jsxs("tr",{children:[e.jsx("td",{className:"px-4 py-3 font-mono",children:"192.168.10.106"}),e.jsx("td",{className:"px-4 py-3",children:"esxi-host-02"}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"bg-primary/20 text-primary px-1.5 py-0.5 rounded text-xs font-bold",children:"NFS"})}),e.jsx("td",{className:"px-4 py-3 text-right font-mono text-text-secondary",children:"105 MB/s"}),e.jsx("td",{className:"px-4 py-3 text-right",children:e.jsx("button",{className:"text-text-secondary hover:text-red-400",title:"Disconnect",children:e.jsx(zf,{size:18})})})]})]})]})})]})]}),c==="permissions"&&e.jsxs("div",{className:"rounded-xl border border-border-dark bg-surface-dark p-8 text-center",children:[e.jsx(Xm,{className:"mx-auto mb-4 text-text-secondary",size:48}),e.jsx("p",{className:"text-text-secondary text-sm",children:"Permissions (ACL) configuration coming soon"})]}),c==="clients"&&e.jsxs("div",{className:"rounded-xl border border-border-dark bg-surface-dark overflow-hidden",children:[e.jsx("div",{className:"px-5 py-4 border-b border-border-dark flex justify-between items-center bg-[#1c2a39]",children:e.jsxs("h3",{className:"text-sm font-bold text-white flex items-center gap-2",children:[e.jsx(ya,{className:"text-primary",size:20}),"Connected Clients"]})}),e.jsx("div",{className:"p-5",children:e.jsx("div",{className:"rounded-lg border border-border-dark overflow-hidden bg-surface-dark",children:e.jsxs("table",{className:"w-full text-sm text-left",children:[e.jsx("thead",{className:"bg-background-dark text-text-secondary font-medium border-b border-border-dark",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3",children:"IP Address"}),e.jsx("th",{className:"px-4 py-3",children:"User"}),e.jsx("th",{className:"px-4 py-3",children:"Protocol"}),e.jsx("th",{className:"px-4 py-3 text-right",children:"Throughput"}),e.jsx("th",{className:"px-4 py-3 text-right",children:"Action"})]})}),e.jsxs("tbody",{className:"text-white divide-y divide-border-dark",children:[e.jsxs("tr",{children:[e.jsx("td",{className:"px-4 py-3 font-mono",children:"192.168.10.105"}),e.jsx("td",{className:"px-4 py-3",children:"esxi-host-01"}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"bg-primary/20 text-primary px-1.5 py-0.5 rounded text-xs font-bold",children:"NFS"})}),e.jsx("td",{className:"px-4 py-3 text-right font-mono text-text-secondary",children:"420 MB/s"}),e.jsx("td",{className:"px-4 py-3 text-right",children:e.jsx("button",{className:"text-text-secondary hover:text-red-400",title:"Disconnect",children:e.jsx(zf,{size:18})})})]}),e.jsxs("tr",{children:[e.jsx("td",{className:"px-4 py-3 font-mono",children:"192.168.10.106"}),e.jsx("td",{className:"px-4 py-3",children:"esxi-host-02"}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"bg-primary/20 text-primary px-1.5 py-0.5 rounded text-xs font-bold",children:"NFS"})}),e.jsx("td",{className:"px-4 py-3 text-right font-mono text-text-secondary",children:"105 MB/s"}),e.jsx("td",{className:"px-4 py-3 text-right",children:e.jsx("button",{className:"text-text-secondary hover:text-red-400",title:"Disconnect",children:e.jsx(zf,{size:18})})})]})]})]})})})]})]})})]}):e.jsx("div",{className:"flex-1 flex items-center justify-center text-text-secondary",children:e.jsxs("div",{className:"text-center",children:[e.jsx(au,{className:"mx-auto mb-4 text-text-secondary",size:48}),e.jsx("p",{className:"text-sm",children:"Select a share to view details"})]})})})]}),l&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>d(!1),children:e.jsxs("div",{className:"bg-surface-dark rounded-xl border border-border-dark max-w-2xl w-full max-h-[90vh] overflow-y-auto",onClick:U=>U.stopPropagation(),children:[e.jsxs("div",{className:"p-6 border-b border-border-dark flex justify-between items-center",children:[e.jsx("h3",{className:"text-lg font-bold text-white",children:"Create New Share"}),e.jsx("button",{onClick:()=>d(!1),className:"text-text-secondary hover:text-white",children:e.jsx(Zs,{size:20})})]}),e.jsxs("div",{className:"p-6 flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-semibold text-white",children:"Dataset"}),e.jsxs("select",{className:"w-full bg-background-dark border border-border-dark rounded-lg px-3 py-2 text-sm text-white focus:border-primary focus:ring-1 focus:ring-primary",value:x.dataset_id,onChange:U=>y({...x,dataset_id:U.target.value}),children:[e.jsx("option",{value:"",children:"Select a dataset"}),j.map(U=>e.jsxs("option",{value:U.id,children:[U.name," ",U.mount_point&&U.mount_point!=="none"?`(${U.mount_point})`:""]},U.id))]})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-xl border border-border-dark bg-surface-dark/40",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ya,{className:"text-text-secondary",size:20}),e.jsx("div",{className:"flex flex-col",children:e.jsx("span",{className:"text-sm font-bold text-white",children:"Enable NFS"})})]}),e.jsx("input",{type:"checkbox",checked:x.nfs_enabled,onChange:U=>y({...x,nfs_enabled:U.target.checked}),className:"h-4 w-4 rounded border-border-dark bg-background-dark text-primary focus:ring-primary"})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-xl border border-border-dark bg-surface-dark/40",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(k6,{className:"text-text-secondary",size:20}),e.jsx("div",{className:"flex flex-col",children:e.jsx("span",{className:"text-sm font-bold text-white",children:"Enable SMB"})})]}),e.jsx("input",{type:"checkbox",checked:x.smb_enabled,onChange:U=>y({...x,smb_enabled:U.target.checked}),className:"h-4 w-4 rounded border-border-dark bg-background-dark text-primary focus:ring-primary"})]})]}),x.nfs_enabled&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-semibold text-white",children:"NFS Options"}),e.jsx("input",{className:"w-full bg-background-dark border border-border-dark rounded-lg px-3 py-2 text-sm text-white focus:border-primary focus:ring-1 focus:ring-primary font-mono",type:"text",value:x.nfs_options,onChange:U=>y({...x,nfs_options:U.target.value})})]}),x.smb_enabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-semibold text-white",children:"SMB Share Name"}),e.jsx("input",{className:"w-full bg-background-dark border border-border-dark rounded-lg px-3 py-2 text-sm text-white focus:border-primary focus:ring-1 focus:ring-primary",type:"text",value:x.smb_share_name,onChange:U=>y({...x,smb_share_name:U.target.value})})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-semibold text-white",children:"Comment"}),e.jsx("input",{className:"w-full bg-background-dark border border-border-dark rounded-lg px-3 py-2 text-sm text-white focus:border-primary focus:ring-1 focus:ring-primary",type:"text",value:x.smb_comment,onChange:U=>y({...x,smb_comment:U.target.value})})]})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[e.jsx(ct,{onClick:()=>d(!1),variant:"outline",className:"px-4 h-10",children:"Cancel"}),e.jsx(ct,{type:"button",onClick:M,disabled:w.isPending,className:"px-4 h-10 bg-primary hover:bg-blue-600",children:w.isPending?"Creating...":"Create Share"})]})]})]})})]})}const Zr={listUsers:async()=>(await ze.get("/iam/users")).data.users||[],getUser:async r=>(await ze.get(`/iam/users/${r}`)).data,createUser:async r=>(await ze.post("/iam/users",r)).data,updateUser:async(r,t)=>{await ze.put(`/iam/users/${r}`,t)},deleteUser:async r=>{await ze.delete(`/iam/users/${r}`)},listGroups:async()=>(await ze.get("/iam/groups")).data.groups||[],getGroup:async r=>(await ze.get(`/iam/groups/${r}`)).data,createGroup:async r=>(await ze.post("/iam/groups",r)).data,updateGroup:async(r,t)=>{await ze.put(`/iam/groups/${r}`,t)},deleteGroup:async r=>{await ze.delete(`/iam/groups/${r}`)},addUserToGroup:async(r,t)=>{await ze.post(`/iam/groups/${r}/users`,{user_id:t})},removeUserFromGroup:async(r,t)=>{await ze.delete(`/iam/groups/${r}/users/${t}`)},assignRoleToUser:async(r,t)=>{await ze.post(`/iam/users/${r}/roles`,{role_name:t})},removeRoleFromUser:async(r,t)=>{await ze.delete(`/iam/users/${r}/roles?role_name=${encodeURIComponent(t)}`)},assignGroupToUser:async(r,t)=>{await ze.post(`/iam/users/${r}/groups`,{group_name:t})},removeGroupFromUser:async(r,t)=>{await ze.delete(`/iam/users/${r}/groups?group_name=${encodeURIComponent(t)}`)},listRoles:async()=>(await ze.get("/iam/roles")).data.roles,getRole:async r=>(await ze.get(`/iam/roles/${r}`)).data,createRole:async r=>(await ze.post("/iam/roles",r)).data,updateRole:async(r,t)=>{await ze.put(`/iam/roles/${r}`,t)},deleteRole:async r=>{await ze.delete(`/iam/roles/${r}`)},getRolePermissions:async r=>(await ze.get(`/iam/roles/${r}/permissions`)).data.permissions,assignPermissionToRole:async(r,t)=>{await ze.post(`/iam/roles/${r}/permissions`,{permission_name:t})},removePermissionFromRole:async(r,t)=>{await ze.delete(`/iam/roles/${r}/permissions?permission_name=${encodeURIComponent(t)}`)},listPermissions:async()=>(await ze.get("/iam/permissions")).data.permissions};function e_(){const[r,t]=Ce.useState("users"),[s,n]=Ce.useState(""),[o,l]=Ce.useState(!1),[d,c]=Ce.useState(!1),[u,h]=Ce.useState(null),[m,x]=Ce.useState(null),y=Nr(),{data:p,isLoading:v,error:N}=dt({queryKey:["iam-users"],queryFn:Zr.listUsers,refetchOnWindowFocus:!0});N&&console.error("Failed to load users:",N);const B=(p||[]).filter(K=>K.username.toLowerCase().includes(s.toLowerCase())||K.full_name&&K.full_name.toLowerCase().includes(s.toLowerCase())||K.email&&K.email.toLowerCase().includes(s.toLowerCase())||K.roles&&K.roles.some(M=>M.toLowerCase().includes(s.toLowerCase()))||K.groups&&K.groups.some(M=>M.toLowerCase().includes(s.toLowerCase()))),g=K=>{if(!K||K.length===0)return{bg:"bg-slate-700",text:"text-slate-300",border:"border-slate-600",icon:Bn,Icon:Bn,label:"No Role"};const M=K[0],T={admin:{bg:"bg-purple-500/10",text:"text-purple-400",border:"border-purple-500/20",icon:E6,label:"Admin"},operator:{bg:"bg-blue-500/10",text:"text-blue-400",border:"border-blue-500/20",icon:F6,label:"Operator"},auditor:{bg:"bg-yellow-500/10",text:"text-yellow-500",border:"border-yellow-500/20",icon:Db,label:"Auditor"},storage_admin:{bg:"bg-teal-500/10",text:"text-teal-500",border:"border-teal-500/20",icon:Ul,label:"Storage Admin"},service:{bg:"bg-slate-700",text:"text-slate-300",border:"border-slate-600",icon:Bn,label:"Service"}}[M.toLowerCase()]||{bg:"bg-slate-700",text:"text-slate-300",border:"border-slate-600",icon:Bn,label:M},ne=T.icon;return{...T,Icon:ne}},j=K=>K.toLowerCase()==="admin"?"bg-gradient-to-br from-blue-500 to-indigo-600":"bg-slate-700",_=ft({mutationFn:Zr.deleteUser,onSuccess:()=>{y.invalidateQueries({queryKey:["iam-users"]}),y.refetchQueries({queryKey:["iam-users"]})},onError:K=>{console.error("Failed to delete user:",K);const M=K.response?.data?.error||K.message||"Failed to delete user";alert(M)}}),w=K=>{_.mutate(K)},L=K=>{if(!K)return"Never";const M=new Date(K),T=new Date().getTime()-M.getTime(),ne=Math.floor(T/6e4),Z=Math.floor(T/36e5),U=Math.floor(T/864e5);return ne<1?"Just now":ne<60?`${ne} minute${ne>1?"s":""} ago`:Z<24?`${Z} hour${Z>1?"s":""} ago`:U<7?`${U} day${U>1?"s":""} ago`:M.toLocaleDateString()};return e.jsx("div",{className:"flex-1 overflow-y-auto custom-scrollbar h-full",children:e.jsxs("div",{className:"max-w-[1200px] mx-auto w-full p-8 flex flex-col gap-6",children:[e.jsxs("header",{className:"flex flex-wrap justify-between items-end gap-4 border-b border-border-dark pb-6",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("nav",{className:"flex items-center gap-2 text-sm text-text-secondary mb-1",children:[e.jsx("span",{children:"System"}),e.jsx(Ka,{size:16}),e.jsx("span",{className:"text-white",children:"Access Control"})]}),e.jsx("h1",{className:"text-3xl font-black text-white leading-tight",children:"User & Access Management"}),e.jsx("p",{className:"text-text-secondary text-base max-w-2xl",children:"Manage local accounts, define RBAC roles, and configure directory services (LDAP/AD) integration."})]}),e.jsx("div",{className:"flex gap-3",children:e.jsxs(ct,{variant:"outline",className:"flex items-center justify-center gap-2 px-4 py-2 bg-card-dark border border-border-dark rounded-lg text-white hover:bg-border-dark transition-colors font-semibold",children:[e.jsx(hp,{size:20}),e.jsx("span",{children:"Audit Log"})]})})]}),e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsxs("div",{className:"flex border-b border-border-dark gap-8",children:[e.jsxs("button",{onClick:()=>t("users"),className:`flex items-center gap-2 pb-3 border-b-[3px] transition-colors ${r==="users"?"border-primary text-white":"border-transparent text-text-secondary hover:text-white hover:border-slate-600"}`,children:[e.jsx(Bn,{size:20}),e.jsx("span",{className:"text-sm font-bold",children:"Local Users"})]}),e.jsxs("button",{onClick:()=>t("groups"),className:`flex items-center gap-2 pb-3 border-b-[3px] transition-colors ${r==="groups"?"border-primary text-white":"border-transparent text-text-secondary hover:text-white hover:border-slate-600"}`,children:[e.jsx(ya,{size:20}),e.jsx("span",{className:"text-sm font-bold",children:"Groups"})]}),e.jsxs("button",{onClick:()=>t("roles"),className:`flex items-center gap-2 pb-3 border-b-[3px] transition-colors ${r==="roles"?"border-primary text-white":"border-transparent text-text-secondary hover:text-white hover:border-slate-600"}`,children:[e.jsx(Bn,{size:20}),e.jsx("span",{className:"text-sm font-bold",children:"Roles"})]}),e.jsxs("button",{onClick:()=>t("directory"),className:`flex items-center gap-2 pb-3 border-b-[3px] transition-colors ${r==="directory"?"border-primary text-white":"border-transparent text-text-secondary hover:text-white hover:border-slate-600"}`,children:[e.jsx(ya,{size:20}),e.jsx("span",{className:"text-sm font-bold",children:"Directory Services"})]}),e.jsxs("button",{onClick:()=>t("auth"),className:`flex items-center gap-2 pb-3 border-b-[3px] transition-colors ${r==="auth"?"border-primary text-white":"border-transparent text-text-secondary hover:text-white hover:border-slate-600"}`,children:[e.jsx(Xm,{size:20}),e.jsx("span",{className:"text-sm font-bold",children:"Authentication & SSO"})]})]}),r==="users"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap gap-4 items-center justify-between",children:[e.jsxs("div",{className:"flex flex-1 max-w-xl gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(io,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-text-secondary",size:20}),e.jsx("input",{type:"text",placeholder:"Search users by name, role, or group...",value:s,onChange:K=>n(K.target.value),className:"w-full bg-card-dark border border-border-dark rounded-lg pl-10 pr-4 py-2.5 text-white placeholder-text-secondary/50 focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent text-sm"})]}),e.jsxs(ct,{variant:"outline",className:"flex items-center gap-2 px-4 py-2.5 bg-card-dark border border-border-dark rounded-lg text-text-secondary hover:text-white hover:border-slate-500 transition-colors",children:[e.jsx(fp,{size:20}),e.jsx("span",{className:"text-sm font-medium",children:"Filter"})]})]}),e.jsxs(ct,{onClick:()=>l(!0),className:"flex items-center gap-2 bg-primary hover:bg-blue-600 text-white px-5 py-2.5 rounded-lg font-bold shadow-lg shadow-blue-500/20 transition-all",children:[e.jsx(mp,{size:20}),e.jsx("span",{children:"Create User"})]})]}),e.jsxs("div",{className:"rounded-xl border border-border-dark bg-[#111a22] overflow-hidden shadow-sm",children:[e.jsx("div",{className:"overflow-x-auto custom-scrollbar",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-card-dark border-b border-border-dark text-left",children:[e.jsx("th",{className:"px-6 py-4 text-xs font-bold text-text-secondary uppercase tracking-wider w-24",children:"Status"}),e.jsx("th",{className:"px-6 py-4 text-xs font-bold text-text-secondary uppercase tracking-wider",children:"Username"}),e.jsx("th",{className:"px-6 py-4 text-xs font-bold text-text-secondary uppercase tracking-wider",children:"Full Name"}),e.jsx("th",{className:"px-6 py-4 text-xs font-bold text-text-secondary uppercase tracking-wider",children:"Role"}),e.jsx("th",{className:"px-6 py-4 text-xs font-bold text-text-secondary uppercase tracking-wider",children:"Groups"}),e.jsx("th",{className:"px-6 py-4 text-xs font-bold text-text-secondary uppercase tracking-wider",children:"Last Login"}),e.jsx("th",{className:"px-6 py-4 text-xs font-bold text-text-secondary uppercase tracking-wider text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-border-dark",children:v?e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-6 py-8 text-center text-text-secondary",children:"Loading users..."})}):N?e.jsx("tr",{children:e.jsxs("td",{colSpan:7,className:"px-6 py-8 text-center text-red-400",children:["Error loading users: ",N instanceof Error?N.message:"Unknown error"]})}):B.length>0?B.map(K=>{const M=g(K.roles),V=M.Icon,T=K.full_name?K.full_name.split(" ").map(ne=>ne[0]).join("").substring(0,2).toUpperCase():K.username.substring(0,2).toUpperCase();return e.jsxs("tr",{className:"group hover:bg-card-dark transition-colors",children:[e.jsx("td",{className:"px-6 py-4",children:K.is_active?e.jsxs("div",{className:"inline-flex items-center gap-2 px-2.5 py-1 rounded-full bg-green-500/10 text-green-500 text-xs font-bold border border-green-500/20",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500"}),"Active"]}):e.jsxs("div",{className:"inline-flex items-center gap-2 px-2.5 py-1 rounded-full bg-red-500/10 text-red-500 text-xs font-bold border border-red-500/20",children:[e.jsx(Xm,{size:14}),"Locked"]})}),e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`w-8 h-8 rounded-full ${j(K.username)} flex items-center justify-center text-white text-xs font-bold`,children:T}),e.jsx("span",{className:"text-white font-medium",children:K.username})]})}),e.jsx("td",{className:"px-6 py-4 text-text-secondary text-sm",children:K.full_name||"-"}),e.jsx("td",{className:"px-6 py-4",children:K.roles&&K.roles.length>0?e.jsxs("span",{className:`inline-flex items-center gap-1.5 text-xs font-medium px-2.5 py-1 rounded-md ${M.bg} ${M.text} border ${M.border}`,children:[e.jsx(V,{size:14}),M.label]}):e.jsx("span",{className:"text-text-secondary text-xs",children:"No role"})}),e.jsx("td",{className:"px-6 py-4 text-text-secondary text-sm",children:K.groups&&K.groups.length>0?K.groups.join(", "):"-"}),e.jsx("td",{className:"px-6 py-4 text-text-secondary text-sm",children:L(K.last_login_at)}),e.jsx("td",{className:"px-6 py-4 text-right",children:e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:ne=>{ne.stopPropagation(),x(m===K.id?null:K.id)},className:"p-2 text-text-secondary hover:text-white hover:bg-border-dark rounded-lg transition-colors",children:e.jsx(pp,{size:20})}),m===K.id&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>x(null)}),e.jsx("div",{className:"absolute right-0 mt-1 w-48 bg-card-dark border border-border-dark rounded-lg shadow-xl z-20",children:e.jsxs("div",{className:"py-1",children:[e.jsxs("button",{onClick:ne=>{ne.stopPropagation(),h(K),c(!0),x(null)},className:"w-full px-4 py-2 text-left text-sm text-white hover:bg-[#233648] flex items-center gap-2 transition-colors",children:[e.jsx(Wd,{size:16}),"Edit User"]}),e.jsxs("button",{onClick:ne=>{ne.stopPropagation(),window.location.href=`/profile/${K.id}`},className:"w-full px-4 py-2 text-left text-sm text-white hover:bg-[#233648] flex items-center gap-2 transition-colors",children:[e.jsx(o4,{size:16}),"View Profile"]}),!K.is_system&&e.jsxs("button",{onClick:ne=>{ne.stopPropagation(),confirm(`Are you sure you want to delete user "${K.username}"? This action cannot be undone.`)&&w(K.id),x(null)},className:"w-full px-4 py-2 text-left text-sm text-red-400 hover:bg-red-500/10 flex items-center gap-2 transition-colors",children:[e.jsx(es,{size:16}),"Delete User"]})]})})]})]})})]},K.id)}):e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-6 py-8 text-center text-text-secondary",children:"No users found"})})})]})}),e.jsxs("div",{className:"px-6 py-4 border-t border-border-dark flex items-center justify-between bg-card-dark",children:[e.jsxs("span",{className:"text-sm text-text-secondary",children:["Showing ",e.jsxs("span",{className:"font-bold text-white",children:["1-",B.length]})," of"," ",e.jsx("span",{className:"font-bold text-white",children:B.length})," users"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{className:"p-2 rounded-lg text-text-secondary hover:bg-border-dark hover:text-white disabled:opacity-50 disabled:cursor-not-allowed",children:e.jsx(Sy,{size:20})}),e.jsx("button",{className:"p-2 rounded-lg text-text-secondary hover:bg-border-dark hover:text-white",children:e.jsx(Ka,{size:20})})]})]})]})]}),o&&e.jsx(t_,{onClose:()=>l(!1),onSuccess:async()=>{l(!1),y.invalidateQueries({queryKey:["iam-users"]}),await y.refetchQueries({queryKey:["iam-users"]})}}),d&&u&&e.jsx(r_,{user:u,onClose:()=>{c(!1),h(null)},onSuccess:async()=>{c(!1),h(null),y.invalidateQueries({queryKey:["iam-users"]}),await y.refetchQueries({queryKey:["iam-users"]})}}),r==="groups"&&e.jsx(s_,{}),r==="roles"&&e.jsx(n_,{}),r!=="users"&&r!=="groups"&&e.jsxs("div",{className:"p-8 text-center text-text-secondary",children:[r==="directory"&&"Directory Services tab coming soon",r==="auth"&&"Authentication & SSO tab coming soon"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 mt-2",children:[e.jsxs("div",{className:"bg-[#111a22] p-5 rounded-xl border border-border-dark flex flex-col gap-4",children:[e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-slate-800 rounded-lg text-text-secondary",children:e.jsx(ya,{size:20})}),e.jsx("h3",{className:"text-white font-bold",children:"Directory Service"})]}),e.jsx("span",{className:"px-2 py-1 rounded text-xs font-bold bg-slate-800 text-text-secondary border border-slate-700",children:"Inactive"})]}),e.jsx("p",{className:"text-sm text-text-secondary",children:"No LDAP or Active Directory server is currently connected. Local authentication is being used."}),e.jsx("div",{className:"mt-auto pt-2",children:e.jsxs("button",{className:"text-primary text-sm font-bold hover:underline flex items-center gap-1",children:["Configure Directory",e.jsx(xv,{size:16})]})})]}),e.jsxs("div",{className:"bg-[#111a22] p-5 rounded-xl border border-border-dark flex flex-col gap-4",children:[e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-orange-500/10 rounded-lg text-orange-500",children:e.jsx(Bn,{size:20})}),e.jsx("h3",{className:"text-white font-bold",children:"Security Policy"})]}),e.jsx("span",{className:"px-2 py-1 rounded text-xs font-bold bg-green-500/10 text-green-500 border border-green-500/20",children:"Good"})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex justify-between items-center text-sm",children:[e.jsx("span",{className:"text-text-secondary",children:"Multi-Factor Auth"}),e.jsx("span",{className:"text-green-500 font-medium",children:"Enforced"})]}),e.jsxs("div",{className:"flex justify-between items-center text-sm",children:[e.jsx("span",{className:"text-text-secondary",children:"Password Rotation"}),e.jsx("span",{className:"text-white font-medium",children:"90 Days"})]})]}),e.jsx("div",{className:"mt-auto pt-2",children:e.jsxs("button",{className:"text-primary text-sm font-bold hover:underline flex items-center gap-1",children:["Manage Policies",e.jsx(xv,{size:16})]})})]})]})]})]})})}function t_({onClose:r,onSuccess:t}){const[s,n]=Ce.useState(""),[o,l]=Ce.useState(""),[d,c]=Ce.useState(""),[u,h]=Ce.useState(""),m=ft({mutationFn:Zr.createUser,onSuccess:async()=>{await new Promise(y=>setTimeout(y,300)),t()},onError:y=>{console.error("Failed to create user:",y);const p=y.response?.data?.error||y.message||"Failed to create user";alert(p)}}),x=y=>{if(y.preventDefault(),!s.trim()||!o.trim()||!d.trim()){alert("Username, email, and password are required");return}const p={username:s.trim(),email:o.trim(),password:d,full_name:u.trim()||void 0};console.log("Creating user:",{...p,password:"***"}),m.mutate(p)};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",children:e.jsxs("div",{className:"bg-card-dark border border-border-dark rounded-xl shadow-2xl w-full max-w-2xl mx-4 max-h-[90vh] overflow-y-auto custom-scrollbar",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-border-dark bg-[#1e2832]",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-white",children:"Create User"}),e.jsx("p",{className:"text-sm text-text-secondary mt-1",children:"Create a new user account"})]}),e.jsx("button",{onClick:r,className:"text-white/70 hover:text-white transition-colors p-2 hover:bg-[#233648] rounded-lg",children:e.jsx(Zs,{size:20})})]}),e.jsxs("form",{onSubmit:x,className:"p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"user-username",className:"block text-sm font-medium text-white mb-2",children:["Username ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx("input",{id:"user-username",type:"text",value:s,onChange:y=>n(y.target.value),placeholder:"johndoe",className:"w-full px-4 py-3 bg-[#0f161d] border border-border-dark rounded-lg text-white text-sm placeholder-text-secondary/50 focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent transition-colors",required:!0})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"user-email",className:"block text-sm font-medium text-white mb-2",children:["Email ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx("input",{id:"user-email",type:"email",value:o,onChange:y=>l(y.target.value),placeholder:"john.doe@example.com",className:"w-full px-4 py-3 bg-[#0f161d] border border-border-dark rounded-lg text-white text-sm placeholder-text-secondary/50 focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent transition-colors",required:!0})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"user-password",className:"block text-sm font-medium text-white mb-2",children:["Password ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx("input",{id:"user-password",type:"password",value:d,onChange:y=>c(y.target.value),placeholder:"Enter password",className:"w-full px-4 py-3 bg-[#0f161d] border border-border-dark rounded-lg text-white text-sm placeholder-text-secondary/50 focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent transition-colors",required:!0,minLength:8}),e.jsx("p",{className:"text-xs text-text-secondary mt-1",children:"Minimum 8 characters"})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"user-fullname",className:"block text-sm font-medium text-white mb-2",children:["Full Name ",e.jsx("span",{className:"text-text-secondary text-xs",children:"(Optional)"})]}),e.jsx("input",{id:"user-fullname",type:"text",value:u,onChange:y=>h(y.target.value),placeholder:"John Doe",className:"w-full px-4 py-3 bg-[#0f161d] border border-border-dark rounded-lg text-white text-sm placeholder-text-secondary/50 focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent transition-colors"})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t border-border-dark",children:[e.jsx(ct,{type:"button",variant:"outline",onClick:r,className:"px-6",children:"Cancel"}),e.jsx(ct,{type:"submit",disabled:m.isPending,className:"px-6 bg-primary hover:bg-blue-600",children:m.isPending?"Creating...":"Create User"})]})]})]})})}function r_({user:r,onClose:t,onSuccess:s}){const[n,o]=Ce.useState(r.email||""),[l,d]=Ce.useState(r.full_name||""),[c,u]=Ce.useState(r.is_active),[h,m]=Ce.useState(r.roles||[]),[x,y]=Ce.useState(r.groups||[]),[p,v]=Ce.useState(""),[N,B]=Ce.useState(""),g=Nr(),j=Ce.useRef(h),_=Ce.useRef(x);Ce.useEffect(()=>{j.current=h,console.log("useEffect userRoles - state updated:",h)},[h]),Ce.useEffect(()=>{_.current=x,console.log("useEffect userGroups - state updated:",x)},[x]),Ce.useEffect(()=>{console.log("EditUserForm - userRoles state changed:",h)},[h]),Ce.useEffect(()=>{console.log("EditUserForm - userGroups state changed:",x)},[x]);const{data:w=[]}=dt({queryKey:["iam-roles"],queryFn:Zr.listRoles}),{data:L=[]}=dt({queryKey:["iam-groups"],queryFn:Zr.listGroups}),K=w.filter(F=>!h.includes(F.name)),M=L.filter(F=>!x.includes(F.name)),V=ft({mutationFn:F=>Zr.updateUser(r.id,F),onSuccess:async()=>{s(),g.invalidateQueries({queryKey:["iam-users"]}),g.invalidateQueries({queryKey:["iam-user",r.id]}),g.invalidateQueries({queryKey:["iam-roles"]}),g.invalidateQueries({queryKey:["iam-groups"]}),await g.refetchQueries({queryKey:["iam-users"]}),await g.refetchQueries({queryKey:["iam-user",r.id]}),await g.refetchQueries({queryKey:["iam-roles"]}),await g.refetchQueries({queryKey:["iam-groups"]})},onError:F=>{console.error("Failed to update user:",F);const le=F.response?.data?.error||F.message||"Failed to update user";alert(le)}}),T=ft({mutationFn:F=>Zr.assignRoleToUser(r.id,F),onMutate:async F=>{console.log("assignRoleMutation onMutate - BEFORE update, current userRoles:",j.current),m(le=>{const ae=le.includes(F)?le:[...le,F];return console.log("assignRoleMutation onMutate - prev:",le,"roleName:",F,"newRoles:",ae),j.current=ae,ae}),v(""),console.log("assignRoleMutation onMutate - AFTER update, ref should be:",j.current)},onSuccess:async(F,le)=>{g.invalidateQueries({queryKey:["iam-users"]}),g.invalidateQueries({queryKey:["iam-user",r.id]}),g.invalidateQueries({queryKey:["iam-roles"]}),await g.refetchQueries({queryKey:["iam-roles"]}),m(ae=>(console.log("assignRoleMutation onSuccess - roleName:",le,"current userRoles:",ae),ae))},onError:(F,le)=>{console.error("Failed to assign role:",F,le),m(ae=>ae.filter(se=>se!==le)),alert(F.response?.data?.error||F.message||"Failed to assign role")}}),ne=ft({mutationFn:F=>Zr.removeRoleFromUser(r.id,F),onMutate:async F=>{const le=h;return m(ae=>ae.filter(se=>se!==F)),{previousRoles:le}},onSuccess:async(F,le)=>{g.invalidateQueries({queryKey:["iam-users"]}),g.invalidateQueries({queryKey:["iam-user",r.id]}),g.invalidateQueries({queryKey:["iam-roles"]}),await g.refetchQueries({queryKey:["iam-roles"]}),console.log("Role removed successfully:",le,"Current userRoles:",h)},onError:(F,le,ae)=>{console.error("Failed to remove role:",F),ae?.previousRoles&&m(ae.previousRoles),alert(F.response?.data?.error||F.message||"Failed to remove role")}}),Z=ft({mutationFn:F=>Zr.assignGroupToUser(r.id,F),onMutate:async F=>{console.log("assignGroupMutation onMutate - BEFORE update, current userGroups:",_.current),y(le=>{const ae=le.includes(F)?le:[...le,F];return console.log("assignGroupMutation onMutate - prev:",le,"groupName:",F,"newGroups:",ae),_.current=ae,ae}),B(""),console.log("assignGroupMutation onMutate - AFTER update, ref should be:",_.current)},onSuccess:async(F,le)=>{g.invalidateQueries({queryKey:["iam-users"]}),g.invalidateQueries({queryKey:["iam-user",r.id]}),g.invalidateQueries({queryKey:["iam-groups"]}),await g.refetchQueries({queryKey:["iam-groups"]}),y(ae=>(console.log("assignGroupMutation onSuccess - groupName:",le,"current userGroups:",ae),ae))},onError:(F,le)=>{console.error("Failed to assign group:",F,le),y(ae=>ae.filter(se=>se!==le)),alert(F.response?.data?.error||F.message||"Failed to assign group")}}),U=ft({mutationFn:F=>Zr.removeGroupFromUser(r.id,F),onMutate:async F=>{const le=x;return y(ae=>ae.filter(se=>se!==F)),{previousGroups:le}},onSuccess:async(F,le)=>{g.invalidateQueries({queryKey:["iam-users"]}),g.invalidateQueries({queryKey:["iam-user",r.id]}),g.invalidateQueries({queryKey:["iam-groups"]}),await g.refetchQueries({queryKey:["iam-groups"]}),console.log("Group removed successfully:",le,"Current userGroups:",x)},onError:(F,le,ae)=>{console.error("Failed to remove group:",F),ae?.previousGroups&&y(ae.previousGroups),alert(F.response?.data?.error||F.message||"Failed to remove group")}}),q=F=>{F.preventDefault();const le=j.current,ae=_.current,se={email:n.trim(),full_name:l.trim()||void 0,is_active:c,roles:le,groups:ae};console.log("EditUserForm - Submitting payload:",se),console.log("EditUserForm - currentRoles from ref:",le),console.log("EditUserForm - currentGroups from ref:",ae),console.log("EditUserForm - userRoles from state:",h),console.log("EditUserForm - userGroups from state:",x),V.mutate(se)};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",children:e.jsxs("div",{className:"bg-card-dark border border-border-dark rounded-xl shadow-2xl w-full max-w-2xl mx-4 max-h-[90vh] overflow-y-auto custom-scrollbar",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-border-dark bg-[#1e2832]",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-white",children:"Edit User"}),e.jsxs("p",{className:"text-sm text-text-secondary mt-1",children:["Edit user account: ",r.username]})]}),e.jsx("button",{onClick:t,className:"text-white/70 hover:text-white transition-colors p-2 hover:bg-[#233648] rounded-lg",children:e.jsx(Zs,{size:20})})]}),e.jsxs("form",{onSubmit:q,className:"p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"edit-username",className:"block text-sm font-medium text-white mb-2",children:"Username"}),e.jsx("input",{id:"edit-username",type:"text",value:r.username,disabled:!0,className:"w-full px-4 py-3 bg-[#0a0f14] border border-border-dark rounded-lg text-text-secondary text-sm cursor-not-allowed"}),e.jsx("p",{className:"text-xs text-text-secondary mt-1",children:"Username cannot be changed"})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"edit-email",className:"block text-sm font-medium text-white mb-2",children:["Email ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx("input",{id:"edit-email",type:"email",value:n,onChange:F=>o(F.target.value),placeholder:"john.doe@example.com",className:"w-full px-4 py-3 bg-[#0f161d] border border-border-dark rounded-lg text-white text-sm placeholder-text-secondary/50 focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent transition-colors",required:!0})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"edit-fullname",className:"block text-sm font-medium text-white mb-2",children:["Full Name ",e.jsx("span",{className:"text-text-secondary text-xs",children:"(Optional)"})]}),e.jsx("input",{id:"edit-fullname",type:"text",value:l,onChange:F=>d(F.target.value),placeholder:"John Doe",className:"w-full px-4 py-3 bg-[#0f161d] border border-border-dark rounded-lg text-white text-sm placeholder-text-secondary/50 focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent transition-colors"})]}),e.jsxs("div",{className:"border-t border-border-dark pt-6",children:[e.jsx("label",{className:"block text-sm font-medium text-white mb-3",children:"Roles"}),e.jsxs("div",{className:"flex gap-2 mb-3",children:[e.jsxs("select",{value:p,onChange:F=>v(F.target.value),className:"flex-1 px-4 py-2 bg-[#0f161d] border border-border-dark rounded-lg text-white text-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent",children:[e.jsx("option",{value:"",children:"Select a role..."}),K.map(F=>e.jsxs("option",{value:F.name,children:[F.name," ",F.description?`- ${F.description}`:""]},F.name))]}),e.jsx(ct,{type:"button",onClick:()=>{p&&T.mutate(p)},disabled:!p||T.isPending,className:"px-4 bg-primary hover:bg-blue-600",children:e.jsx(Ks,{size:16})})]}),e.jsx("div",{className:"space-y-2",children:h.length>0?h.map(F=>e.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-[#0f161d] border border-border-dark rounded-lg",children:[e.jsx("span",{className:"text-white text-sm font-medium",children:F}),e.jsx("button",{type:"button",onClick:()=>ne.mutate(F),disabled:ne.isPending,className:"text-red-400 hover:text-red-300 transition-colors",children:e.jsx(es,{size:16})})]},F)):e.jsx("p",{className:"text-text-secondary text-sm text-center py-2",children:"No roles assigned"})})]}),e.jsxs("div",{className:"border-t border-border-dark pt-6",children:[e.jsx("label",{className:"block text-sm font-medium text-white mb-3",children:"Groups"}),e.jsxs("div",{className:"flex gap-2 mb-3",children:[e.jsxs("select",{value:N,onChange:F=>B(F.target.value),className:"flex-1 px-4 py-2 bg-[#0f161d] border border-border-dark rounded-lg text-white text-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent",children:[e.jsx("option",{value:"",children:"Select a group..."}),M.map(F=>e.jsxs("option",{value:F.name,children:[F.name," ",F.description?`- ${F.description}`:""]},F.id))]}),e.jsx(ct,{type:"button",onClick:()=>{N&&Z.mutate(N)},disabled:!N||Z.isPending,className:"px-4 bg-primary hover:bg-blue-600",children:e.jsx(Ks,{size:16})})]}),e.jsx("div",{className:"space-y-2",children:x.length>0?x.map(F=>e.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-[#0f161d] border border-border-dark rounded-lg",children:[e.jsx("span",{className:"text-white text-sm font-medium",children:F}),e.jsx("button",{type:"button",onClick:()=>U.mutate(F),disabled:U.isPending,className:"text-red-400 hover:text-red-300 transition-colors",children:e.jsx(es,{size:16})})]},F)):e.jsx("p",{className:"text-text-secondary text-sm text-center py-2",children:"No groups assigned"})})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:c,onChange:F=>u(F.target.checked),className:"w-4 h-4 rounded bg-[#0f161d] border-border-dark text-primary focus:ring-2 focus:ring-primary"}),e.jsx("span",{className:"text-sm font-medium text-white",children:"Active Account"})]}),e.jsx("p",{className:"text-xs text-text-secondary mt-1 ml-7",children:c?"User can log in and access the system":"User account is disabled"})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t border-border-dark",children:[e.jsx(ct,{type:"button",variant:"outline",onClick:t,className:"px-6",children:"Cancel"}),e.jsx(ct,{type:"submit",disabled:V.isPending,className:"px-6 bg-primary hover:bg-blue-600",children:V.isPending?"Saving...":"Save Changes"})]})]})]})})}function s_(){const r=Nr(),[t,s]=Ce.useState(""),[n,o]=Ce.useState(!1),[l,d]=Ce.useState(!1),[c,u]=Ce.useState(null),[h,m]=Ce.useState(null),{data:x,isLoading:y}=dt({queryKey:["iam-groups"],queryFn:Zr.listGroups}),p=x?.filter(B=>B.name.toLowerCase().includes(t.toLowerCase())||B.description&&B.description.toLowerCase().includes(t.toLowerCase()))||[],v=ft({mutationFn:Zr.deleteGroup,onSuccess:async()=>{r.invalidateQueries({queryKey:["iam-groups"]}),await r.refetchQueries({queryKey:["iam-groups"]}),r.invalidateQueries({queryKey:["iam-users"]}),await r.refetchQueries({queryKey:["iam-users"]}),alert("Group deleted successfully!")},onError:B=>{console.error("Failed to delete group:",B),alert(B.response?.data?.error||B.message||"Failed to delete group")}}),N=(B,g)=>{confirm(`Are you sure you want to delete group "${g}"? This action cannot be undone.`)&&v.mutate(B)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap gap-4 items-center justify-between",children:[e.jsxs("div",{className:"flex flex-1 max-w-xl gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(io,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-text-secondary",size:20}),e.jsx("input",{type:"text",placeholder:"Search groups by name or description...",value:t,onChange:B=>s(B.target.value),className:"w-full bg-card-dark border border-border-dark rounded-lg pl-10 pr-4 py-2.5 text-white placeholder-text-secondary/50 focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent text-sm"})]}),e.jsxs(ct,{variant:"outline",className:"flex items-center gap-2 px-4 py-2.5 bg-card-dark border border-border-dark rounded-lg text-text-secondary hover:text-white hover:border-slate-500 transition-colors",children:[e.jsx(fp,{size:20}),e.jsx("span",{className:"text-sm font-medium",children:"Filter"})]})]}),e.jsxs(ct,{onClick:()=>o(!0),className:"flex items-center gap-2 bg-primary hover:bg-blue-600 text-white px-5 py-2.5 rounded-lg font-bold shadow-lg shadow-blue-500/20 transition-all",children:[e.jsx(mp,{size:20}),e.jsx("span",{children:"Create Group"})]})]}),e.jsxs("div",{className:"rounded-xl border border-border-dark bg-[#111a22] overflow-hidden shadow-sm",children:[e.jsx("div",{className:"overflow-x-auto custom-scrollbar",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-card-dark border-b border-border-dark text-left",children:[e.jsx("th",{className:"px-6 py-4 text-xs font-bold text-text-secondary uppercase tracking-wider",children:"Name"}),e.jsx("th",{className:"px-6 py-4 text-xs font-bold text-text-secondary uppercase tracking-wider",children:"Description"}),e.jsx("th",{className:"px-6 py-4 text-xs font-bold text-text-secondary uppercase tracking-wider",children:"Users"}),e.jsx("th",{className:"px-6 py-4 text-xs font-bold text-text-secondary uppercase tracking-wider",children:"Roles"}),e.jsx("th",{className:"px-6 py-4 text-xs font-bold text-text-secondary uppercase tracking-wider",children:"Type"}),e.jsx("th",{className:"px-6 py-4 text-xs font-bold text-text-secondary uppercase tracking-wider text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-border-dark",children:y?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-6 py-8 text-center text-text-secondary",children:"Loading groups..."})}):p.length>0?p.map(B=>e.jsxs("tr",{className:"group hover:bg-card-dark transition-colors",children:[e.jsx("td",{className:"px-6 py-4",children:e.jsx("span",{className:"text-white font-medium",children:B.name})}),e.jsx("td",{className:"px-6 py-4 text-text-secondary text-sm",children:B.description||"-"}),e.jsx("td",{className:"px-6 py-4 text-text-secondary text-sm",children:B.user_count}),e.jsx("td",{className:"px-6 py-4 text-text-secondary text-sm",children:B.role_count}),e.jsx("td",{className:"px-6 py-4",children:B.is_system?e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md bg-purple-500/10 text-purple-400 text-xs font-medium border border-purple-500/20",children:[e.jsx(Bn,{size:12}),"System"]}):e.jsx("span",{className:"text-text-secondary text-xs",children:"Custom"})}),e.jsx("td",{className:"px-6 py-4 text-right",children:e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:g=>{g.stopPropagation(),m(h===B.id?null:B.id)},className:"p-2 text-text-secondary hover:text-white hover:bg-border-dark rounded-lg transition-colors",children:e.jsx(pp,{size:20})}),h===B.id&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>m(null)}),e.jsx("div",{className:"absolute right-0 mt-1 w-48 bg-card-dark border border-border-dark rounded-lg shadow-xl z-20",children:e.jsxs("div",{className:"py-1",children:[e.jsxs("button",{onClick:g=>{g.stopPropagation(),u(B),d(!0),m(null)},disabled:B.is_system,className:"w-full px-4 py-2 text-left text-sm text-white hover:bg-[#233648] flex items-center gap-2 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx(Wd,{size:16}),"Edit Group"]}),e.jsxs("button",{onClick:g=>{g.stopPropagation(),N(B.id,B.name),m(null)},disabled:B.is_system||v.isPending,className:"w-full px-4 py-2 text-left text-sm text-red-400 hover:bg-red-500/10 flex items-center gap-2 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx(es,{size:16}),"Delete Group"]})]})})]})]})})]},B.id)):e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-6 py-8 text-center text-text-secondary",children:"No groups found"})})})]})}),e.jsxs("div",{className:"px-6 py-4 border-t border-border-dark flex items-center justify-between bg-card-dark",children:[e.jsxs("span",{className:"text-sm text-text-secondary",children:["Showing ",e.jsxs("span",{className:"font-bold text-white",children:["1-",p.length]})," of"," ",e.jsx("span",{className:"font-bold text-white",children:p.length})," groups"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{className:"p-2 rounded-lg text-text-secondary hover:bg-border-dark hover:text-white disabled:opacity-50 disabled:cursor-not-allowed",children:e.jsx(Sy,{size:20})}),e.jsx("button",{className:"p-2 rounded-lg text-text-secondary hover:bg-border-dark hover:text-white",children:e.jsx(Ka,{size:20})})]})]})]}),n&&e.jsx(a_,{onClose:()=>o(!1),onSuccess:async()=>{o(!1),r.invalidateQueries({queryKey:["iam-groups"]}),await r.refetchQueries({queryKey:["iam-groups"]})}}),l&&c&&e.jsx(l_,{group:c,onClose:()=>{d(!1),u(null)},onSuccess:async()=>{d(!1),u(null),r.invalidateQueries({queryKey:["iam-groups"]}),await r.refetchQueries({queryKey:["iam-groups"]}),r.invalidateQueries({queryKey:["iam-users"]}),await r.refetchQueries({queryKey:["iam-users"]})}})]})}function a_({onClose:r,onSuccess:t}){const[s,n]=Ce.useState(""),[o,l]=Ce.useState(""),d=ft({mutationFn:Zr.createGroup,onSuccess:()=>{t()},onError:u=>{console.error("Failed to create group:",u);const h=u.response?.data?.error||u.message||"Failed to create group";alert(h)}}),c=u=>{if(u.preventDefault(),!s.trim()){alert("Name is required");return}const h={name:s.trim(),description:o.trim()||""};console.log("Creating group:",h),d.mutate(h)};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",children:e.jsxs("div",{className:"bg-card-dark border border-border-dark rounded-xl shadow-2xl w-full max-w-2xl mx-4 max-h-[90vh] overflow-y-auto custom-scrollbar",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-border-dark bg-[#1e2832]",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-white",children:"Create Group"}),e.jsx("p",{className:"text-sm text-text-secondary mt-1",children:"Create a new user group"})]}),e.jsx("button",{onClick:r,className:"text-white/70 hover:text-white transition-colors p-2 hover:bg-[#233648] rounded-lg",children:e.jsx(Zs,{size:20})})]}),e.jsxs("form",{onSubmit:c,className:"p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"group-name",className:"block text-sm font-medium text-white mb-2",children:["Group Name ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx("input",{id:"group-name",type:"text",value:s,onChange:u=>n(u.target.value),placeholder:"operators",className:"w-full px-4 py-3 bg-[#0f161d] border border-border-dark rounded-lg text-white text-sm placeholder-text-secondary/50 focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent transition-colors",required:!0})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"group-description",className:"block text-sm font-medium text-white mb-2",children:["Description ",e.jsx("span",{className:"text-text-secondary text-xs",children:"(Optional)"})]}),e.jsx("textarea",{id:"group-description",value:o,onChange:u=>l(u.target.value),placeholder:"Group description",className:"w-full px-4 py-3 bg-[#0f161d] border border-border-dark rounded-lg text-white text-sm placeholder-text-secondary/50 focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent transition-colors resize-none",rows:4})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t border-border-dark",children:[e.jsx(ct,{type:"button",variant:"outline",onClick:r,className:"px-6",children:"Cancel"}),e.jsx(ct,{type:"submit",disabled:d.isPending,className:"px-6 bg-primary hover:bg-blue-600",children:d.isPending?"Creating...":"Create Group"})]})]})]})})}function n_(){const r=Nr(),[t,s]=Ce.useState(""),[n,o]=Ce.useState(!1),[l,d]=Ce.useState(!1),[c,u]=Ce.useState(null),{data:h,isLoading:m}=dt({queryKey:["iam-roles"],queryFn:Zr.listRoles}),x=h?.filter(v=>v.name.toLowerCase().includes(t.toLowerCase())||v.description&&v.description.toLowerCase().includes(t.toLowerCase()))||[],y=ft({mutationFn:Zr.deleteRole,onSuccess:async()=>{r.invalidateQueries({queryKey:["iam-roles"]}),await r.refetchQueries({queryKey:["iam-roles"]}),r.invalidateQueries({queryKey:["iam-users"]}),await r.refetchQueries({queryKey:["iam-users"]}),alert("Role deleted successfully!")},onError:v=>{console.error("Failed to delete role:",v),alert(v.response?.data?.error||v.message||"Failed to delete role")}}),p=v=>{confirm("Are you sure you want to delete this role? This action cannot be undone.")&&y.mutate(v)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap gap-4 items-center justify-between",children:[e.jsxs("div",{className:"flex flex-1 max-w-xl gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(io,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-text-secondary",size:20}),e.jsx("input",{type:"text",placeholder:"Search roles by name or description...",value:t,onChange:v=>s(v.target.value),className:"w-full bg-card-dark border border-border-dark rounded-lg pl-10 pr-4 py-2.5 text-white placeholder-text-secondary/50 focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent text-sm"})]}),e.jsxs(ct,{variant:"outline",className:"flex items-center gap-2 px-4 py-2.5 bg-card-dark border border-border-dark rounded-lg text-text-secondary hover:text-white hover:border-slate-500 transition-colors",children:[e.jsx(fp,{size:20}),e.jsx("span",{className:"text-sm font-medium",children:"Filter"})]})]}),e.jsxs(ct,{onClick:()=>o(!0),className:"flex items-center gap-2 bg-primary hover:bg-blue-600 text-white px-5 py-2.5 rounded-lg font-bold shadow-lg shadow-blue-500/20 transition-all",children:[e.jsx(mp,{size:20}),e.jsx("span",{children:"Create Role"})]})]}),e.jsx("div",{className:"rounded-xl border border-border-dark bg-[#111a22] overflow-hidden shadow-sm",children:e.jsx("div",{className:"overflow-x-auto custom-scrollbar",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-card-dark border-b border-border-dark text-left",children:[e.jsx("th",{className:"px-6 py-4 text-xs font-bold text-text-secondary uppercase tracking-wider",children:"Name"}),e.jsx("th",{className:"px-6 py-4 text-xs font-bold text-text-secondary uppercase tracking-wider",children:"Description"}),e.jsx("th",{className:"px-6 py-4 text-xs font-bold text-text-secondary uppercase tracking-wider",children:"Users"}),e.jsx("th",{className:"px-6 py-4 text-xs font-bold text-text-secondary uppercase tracking-wider",children:"Type"}),e.jsx("th",{className:"px-6 py-4 text-xs font-bold text-text-secondary uppercase tracking-wider text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-border-dark",children:m?e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"px-6 py-8 text-center text-text-secondary",children:"Loading roles..."})}):x.length>0?x.map(v=>e.jsxs("tr",{className:"group hover:bg-card-dark transition-colors",children:[e.jsx("td",{className:"px-6 py-4",children:e.jsx("span",{className:"text-white font-medium",children:v.name})}),e.jsx("td",{className:"px-6 py-4 text-text-secondary text-sm",children:v.description||"-"}),e.jsx("td",{className:"px-6 py-4 text-text-secondary text-sm",children:v.user_count||0}),e.jsx("td",{className:"px-6 py-4",children:v.is_system?e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md bg-purple-500/10 text-purple-400 text-xs font-medium border border-purple-500/20",children:[e.jsx(Bn,{size:12}),"System"]}):e.jsx("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md bg-blue-500/10 text-blue-400 text-xs font-medium border border-blue-500/20",children:"Custom"})}),e.jsx("td",{className:"px-6 py-4 text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{onClick:()=>{u(v),d(!0)},className:"p-2 text-text-secondary hover:text-white hover:bg-border-dark rounded-lg transition-colors",title:"Edit role",children:e.jsx(Wd,{size:16})}),!v.is_system&&e.jsx("button",{onClick:()=>p(v.id),disabled:y.isPending,className:"p-2 text-red-400 hover:text-red-300 hover:bg-red-500/10 rounded-lg transition-colors",title:"Delete role",children:e.jsx(es,{size:16})})]})})]},v.id)):e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"px-6 py-8 text-center text-text-secondary",children:"No roles found"})})})]})})}),n&&e.jsx(i_,{onClose:()=>o(!1),onSuccess:async()=>{o(!1),r.invalidateQueries({queryKey:["iam-roles"]}),await r.refetchQueries({queryKey:["iam-roles"]})}}),l&&c&&e.jsx(o_,{role:c,onClose:()=>{d(!1),u(null)},onSuccess:async()=>{d(!1),u(null),r.invalidateQueries({queryKey:["iam-roles"]}),await r.refetchQueries({queryKey:["iam-roles"]}),r.invalidateQueries({queryKey:["iam-users"]}),await r.refetchQueries({queryKey:["iam-users"]})}})]})}function i_({onClose:r,onSuccess:t}){const[s,n]=Ce.useState(""),[o,l]=Ce.useState(""),d=ft({mutationFn:u=>Zr.createRole(u),onSuccess:()=>{t()},onError:u=>{console.error("Failed to create role:",u);const h=u.response?.data?.error||u.message||"Failed to create role";alert(h)}}),c=u=>{u.preventDefault(),d.mutate({name:s.trim(),description:o.trim()||void 0})};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4",children:e.jsxs("div",{className:"bg-card-dark border border-border-dark rounded-xl shadow-2xl w-full max-w-2xl mx-4 max-h-[90vh] overflow-y-auto custom-scrollbar",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-border-dark bg-[#1e2832]",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-white",children:"Create Role"}),e.jsx("p",{className:"text-sm text-text-secondary mt-1",children:"Create a new role for access control"})]}),e.jsx("button",{onClick:r,className:"text-white/70 hover:text-white transition-colors p-2 hover:bg-[#233648] rounded-lg",children:e.jsx(Zs,{size:24})})]}),e.jsxs("form",{onSubmit:c,className:"p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"role-name",className:"block text-sm font-medium text-white mb-2",children:["Role Name ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx("input",{id:"role-name",type:"text",value:s,onChange:u=>n(u.target.value),placeholder:"e.g., operator, auditor",className:"w-full px-4 py-3 bg-[#0f161d] border border-border-dark rounded-lg text-white text-sm placeholder-text-secondary/50 focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent transition-colors",required:!0})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"role-description",className:"block text-sm font-medium text-white mb-2",children:["Description ",e.jsx("span",{className:"text-text-secondary text-xs",children:"(Optional)"})]}),e.jsx("textarea",{id:"role-description",value:o,onChange:u=>l(u.target.value),placeholder:"Describe the role's purpose and permissions",rows:3,className:"w-full px-4 py-3 bg-[#0f161d] border border-border-dark rounded-lg text-white text-sm placeholder-text-secondary/50 focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent transition-colors resize-none"})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t border-border-dark",children:[e.jsx(ct,{type:"button",variant:"outline",onClick:r,className:"px-6",children:"Cancel"}),e.jsx(ct,{type:"submit",disabled:d.isPending,className:"px-6 bg-primary hover:bg-blue-600",children:d.isPending?"Creating...":"Create Role"})]})]})]})})}function o_({role:r,onClose:t,onSuccess:s}){const[n,o]=Ce.useState(r.name),[l,d]=Ce.useState(r.description||""),[c,u]=Ce.useState([]),[h,m]=Ce.useState(""),x=Nr(),{data:y=[]}=dt({queryKey:["iam-role-permissions",r.id],queryFn:()=>Zr.getRolePermissions(r.id)});Ce.useEffect(()=>{y&&u(y)},[y]);const{data:p=[]}=dt({queryKey:["iam-permissions"],queryFn:Zr.listPermissions}),v=p.filter(_=>!c.includes(_.name)),N=ft({mutationFn:_=>Zr.updateRole(r.id,_),onSuccess:()=>{s()},onError:_=>{console.error("Failed to update role:",_);const w=_.response?.data?.error||_.message||"Failed to update role";alert(w)}}),B=ft({mutationFn:_=>Zr.assignPermissionToRole(r.id,_),onSuccess:async()=>{const _=await Zr.getRolePermissions(r.id);u(_),x.invalidateQueries({queryKey:["iam-role-permissions",r.id]}),await x.refetchQueries({queryKey:["iam-role-permissions",r.id]}),x.invalidateQueries({queryKey:["iam-users"]}),await x.refetchQueries({queryKey:["iam-users"]}),m("")},onError:_=>{console.error("Failed to assign permission:",_),alert(_.response?.data?.error||_.message||"Failed to assign permission")}}),g=ft({mutationFn:_=>Zr.removePermissionFromRole(r.id,_),onSuccess:async()=>{const _=await Zr.getRolePermissions(r.id);u(_),x.invalidateQueries({queryKey:["iam-role-permissions",r.id]}),await x.refetchQueries({queryKey:["iam-role-permissions",r.id]}),x.invalidateQueries({queryKey:["iam-users"]}),await x.refetchQueries({queryKey:["iam-users"]})},onError:_=>{console.error("Failed to remove permission:",_),alert(_.response?.data?.error||_.message||"Failed to remove permission")}}),j=_=>{_.preventDefault(),N.mutate({name:n.trim(),description:l.trim()||void 0})};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4",children:e.jsxs("div",{className:"bg-card-dark border border-border-dark rounded-xl shadow-2xl w-full max-w-2xl mx-4 max-h-[90vh] overflow-y-auto custom-scrollbar",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-border-dark bg-[#1e2832]",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-2xl font-bold text-white",children:["Edit Role: ",r.name]}),e.jsx("p",{className:"text-sm text-text-secondary mt-1",children:"Modify role details"})]}),e.jsx("button",{onClick:t,className:"text-white/70 hover:text-white transition-colors p-2 hover:bg-[#233648] rounded-lg",children:e.jsx(Zs,{size:24})})]}),e.jsxs("form",{onSubmit:j,className:"p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"edit-role-name",className:"block text-sm font-medium text-white mb-2",children:["Role Name ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx("input",{id:"edit-role-name",type:"text",value:n,onChange:_=>o(_.target.value),disabled:r.is_system,className:`w-full px-4 py-3 bg-[#0f161d] border border-border-dark rounded-lg text-white text-sm placeholder-text-secondary/50 focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent transition-colors ${r.is_system?"cursor-not-allowed opacity-50":""}`,required:!0}),r.is_system&&e.jsx("p",{className:"text-xs text-text-secondary mt-1",children:"System roles cannot be renamed"})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"edit-role-description",className:"block text-sm font-medium text-white mb-2",children:["Description ",e.jsx("span",{className:"text-text-secondary text-xs",children:"(Optional)"})]}),e.jsx("textarea",{id:"edit-role-description",value:l,onChange:_=>d(_.target.value),placeholder:"Describe the role's purpose and permissions",rows:3,className:"w-full px-4 py-3 bg-[#0f161d] border border-border-dark rounded-lg text-white text-sm placeholder-text-secondary/50 focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent transition-colors resize-none"})]}),e.jsxs("div",{className:"border-t border-border-dark pt-6",children:[e.jsx("label",{className:"block text-sm font-medium text-white mb-3",children:"Permissions"}),e.jsxs("div",{className:"flex gap-2 mb-3",children:[e.jsxs("select",{value:h,onChange:_=>m(_.target.value),className:"flex-1 px-4 py-2 bg-[#0f161d] border border-border-dark rounded-lg text-white text-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent",children:[e.jsx("option",{value:"",children:"Select a permission..."}),v.map(_=>e.jsxs("option",{value:_.name,children:[_.name," ",_.description?`- ${_.description}`:`(${_.resource}:${_.action})`]},_.id))]}),e.jsx(ct,{type:"button",onClick:()=>{h&&B.mutate(h)},disabled:!h||B.isPending,className:"px-4 bg-primary hover:bg-blue-600",children:e.jsx(Ks,{size:16})})]}),e.jsx("div",{className:"space-y-2 max-h-64 overflow-y-auto custom-scrollbar",children:c.length>0?c.map(_=>{const w=p.find(L=>L.name===_);return e.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-[#0f161d] border border-border-dark rounded-lg",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-white text-sm font-medium",children:_}),w&&e.jsxs("span",{className:"text-text-secondary text-xs",children:[w.resource,":",w.action,w.description&&` - ${w.description}`]})]}),e.jsx("button",{type:"button",onClick:()=>g.mutate(_),disabled:g.isPending,className:"text-red-400 hover:text-red-300 transition-colors",children:e.jsx(es,{size:16})})]},_)}):e.jsx("p",{className:"text-text-secondary text-sm text-center py-2",children:"No permissions assigned"})})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t border-border-dark",children:[e.jsx(ct,{type:"button",variant:"outline",onClick:t,className:"px-6",children:"Cancel"}),e.jsx(ct,{type:"submit",disabled:N.isPending||r.is_system,className:"px-6 bg-primary hover:bg-blue-600",children:N.isPending?"Saving...":"Save Changes"})]})]})]})})}function l_({group:r,onClose:t,onSuccess:s}){const[n,o]=Ce.useState(r.name),[l,d]=Ce.useState(r.description||""),c=ft({mutationFn:h=>Zr.updateGroup(r.id,h),onSuccess:()=>{s()},onError:h=>{console.error("Failed to update group:",h);const m=h.response?.data?.error||h.message||"Failed to update group";alert(m)}}),u=h=>{h.preventDefault(),c.mutate({name:n.trim(),description:l.trim()||void 0})};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4",children:e.jsxs("div",{className:"bg-card-dark border border-border-dark rounded-xl shadow-2xl w-full max-w-2xl mx-4 max-h-[90vh] overflow-y-auto custom-scrollbar",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-border-dark bg-[#1e2832]",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-2xl font-bold text-white",children:["Edit Group: ",r.name]}),e.jsx("p",{className:"text-sm text-text-secondary mt-1",children:"Modify group details"})]}),e.jsx("button",{onClick:t,className:"text-white/70 hover:text-white transition-colors p-2 hover:bg-[#233648] rounded-lg",children:e.jsx(Zs,{size:24})})]}),e.jsxs("form",{onSubmit:u,className:"p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"edit-group-name",className:"block text-sm font-medium text-white mb-2",children:["Group Name ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx("input",{id:"edit-group-name",type:"text",value:n,onChange:h=>o(h.target.value),disabled:r.is_system,className:`w-full px-4 py-3 bg-[#0f161d] border border-border-dark rounded-lg text-white text-sm placeholder-text-secondary/50 focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent transition-colors ${r.is_system?"cursor-not-allowed opacity-50":""}`,required:!0}),r.is_system&&e.jsx("p",{className:"text-xs text-text-secondary mt-1",children:"System groups cannot be renamed"})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"edit-group-description",className:"block text-sm font-medium text-white mb-2",children:["Description ",e.jsx("span",{className:"text-text-secondary text-xs",children:"(Optional)"})]}),e.jsx("textarea",{id:"edit-group-description",value:l,onChange:h=>d(h.target.value),placeholder:"Describe the group's purpose",rows:3,className:"w-full px-4 py-3 bg-[#0f161d] border border-border-dark rounded-lg text-white text-sm placeholder-text-secondary/50 focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent transition-colors resize-none"})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t border-border-dark",children:[e.jsx(ct,{type:"button",variant:"outline",onClick:t,className:"px-6",children:"Cancel"}),e.jsx(ct,{type:"submit",disabled:c.isPending||r.is_system,className:"px-6 bg-primary hover:bg-blue-600",children:c.isPending?"Saving...":"Save Changes"})]})]})]})})}function Uv(){const{id:r}=jy(),t=Ph(),{user:s}=hu(),n=Nr(),[o,l]=Ce.useState(!1),[d,c]=Ce.useState({email:"",full_name:""}),[u,h]=Ce.useState(null),m=r||s?.id,x=!!s&&!!m&&(m===s.id||s.roles.includes("admin")),{data:y,isLoading:p}=dt({queryKey:["iam-user",m],queryFn:()=>Zr.getUser(m),enabled:x}),v=ft({mutationFn:M=>Zr.updateUser(m,M),onSuccess:()=>{n.invalidateQueries({queryKey:["iam-user",m]}),n.invalidateQueries({queryKey:["iam-users"]}),l(!1),m===s?.id&&n.invalidateQueries({queryKey:["auth-me"]})}});if(Ce.useEffect(()=>{if(y){c({email:y.email||"",full_name:y.full_name||""});const M=localStorage.getItem(`avatar_${y.id}`);M&&h(M)}},[y]),!x)return e.jsx("div",{className:"flex-1 overflow-y-auto p-8",children:e.jsx("div",{className:"max-w-[1200px] mx-auto",children:e.jsxs("div",{className:"bg-red-500/10 border border-red-500/20 rounded-lg p-6 text-center",children:[e.jsx("p",{className:"text-red-400 font-semibold",children:"Access Denied"}),e.jsx("p",{className:"text-text-secondary text-sm mt-2",children:"You don't have permission to view this profile."}),e.jsxs(ct,{variant:"outline",onClick:()=>t(-1),className:"mt-4",children:[e.jsx(wc,{className:"h-4 w-4 mr-2"}),"Go Back"]})]})})});if(p)return e.jsx("div",{className:"flex-1 overflow-y-auto p-8",children:e.jsx("div",{className:"max-w-[1200px] mx-auto",children:e.jsx("p",{className:"text-text-secondary",children:"Loading profile..."})})});if(!y)return e.jsx("div",{className:"flex-1 overflow-y-auto p-8",children:e.jsx("div",{className:"max-w-[1200px] mx-auto",children:e.jsxs("div",{className:"bg-card-dark border border-border-dark rounded-lg p-6 text-center",children:[e.jsx("p",{className:"text-text-secondary",children:"User not found"}),e.jsxs(ct,{variant:"outline",onClick:()=>t(-1),className:"mt-4",children:[e.jsx(wc,{className:"h-4 w-4 mr-2"}),"Go Back"]})]})})});const N=m===s?.id,B=N||s?.roles.includes("admin"),g=()=>{v.mutate({email:d.email,full_name:d.full_name}),u&&y&&(localStorage.setItem(`avatar_${y.id}`,u),window.dispatchEvent(new Event("avatar-updated")))},j=M=>{const V=M.target.files?.[0];if(V){if(!V.type.startsWith("image/")){alert("Please select an image file");return}if(V.size>2*1024*1024){alert("Image size must be less than 2MB");return}const T=new FileReader;T.onloadend=()=>{h(T.result)},T.readAsDataURL(V)}},_=()=>{h(null),y&&(localStorage.removeItem(`avatar_${y.id}`),window.dispatchEvent(new Event("avatar-updated")))},w=M=>new Date(M).toLocaleString(),L=M=>M?w(M):"Never",K=()=>y?.full_name?y.full_name.split(" ").map(M=>M[0]).join("").substring(0,2).toUpperCase():y?.username?.substring(0,2).toUpperCase()||"U";return e.jsx("div",{className:"flex-1 overflow-y-auto p-8",children:e.jsxs("div",{className:"max-w-[1200px] mx-auto flex flex-col gap-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(ct,{variant:"ghost",size:"sm",onClick:()=>t(-1),className:"text-text-secondary hover:text-white",children:[e.jsx(wc,{className:"h-4 w-4 mr-2"}),"Back"]}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-black text-white leading-tight",children:"User Profile"}),e.jsx("p",{className:"text-text-secondary text-sm mt-1",children:N?"Your profile information":`Viewing profile for ${y.username}`})]})]}),B&&e.jsx("div",{className:"flex gap-2",children:o?e.jsxs(e.Fragment,{children:[e.jsxs(ct,{variant:"outline",onClick:()=>{l(!1),c({email:y.email||"",full_name:y.full_name||""})},children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Cancel"]}),e.jsxs(ct,{onClick:g,disabled:v.isPending,children:[e.jsx(up,{className:"h-4 w-4 mr-2"}),v.isPending?"Saving...":"Save Changes"]})]}):e.jsxs(ct,{onClick:()=>l(!0),children:[e.jsx(gv,{className:"h-4 w-4 mr-2"}),"Edit Profile"]})})]}),e.jsxs("div",{className:"bg-card-dark border border-border-dark rounded-xl overflow-hidden",children:[e.jsx("div",{className:"bg-gradient-to-r from-primary/20 to-blue-600/20 p-8 border-b border-border-dark",children:e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"w-24 h-24 rounded-full bg-gradient-to-br from-blue-500 to-indigo-600 flex items-center justify-center text-white text-3xl font-bold overflow-hidden",children:[u?e.jsx("img",{src:u,alt:y.full_name||y.username,className:"w-full h-full object-cover",onError:M=>{const V=M.target;V.style.display="none";const T=V.nextElementSibling;T&&(T.style.display="flex")}}):null,e.jsx("span",{className:u?"hidden":"",children:K()})]}),B&&e.jsx("div",{className:"absolute bottom-0 right-0",children:e.jsxs("label",{className:"cursor-pointer bg-primary hover:bg-primary/90 rounded-full p-2 border-2 border-background-dark flex items-center justify-center transition-colors",children:[e.jsx(gv,{className:"h-4 w-4 text-white"}),e.jsx("input",{type:"file",accept:"image/*",onChange:j,className:"hidden"})]})}),B&&u&&e.jsx("button",{onClick:_,className:"absolute top-0 right-0 bg-red-500 hover:bg-red-600 rounded-full p-1.5 border-2 border-background-dark flex items-center justify-center transition-colors",title:"Remove avatar",children:e.jsx(Zs,{className:"h-3 w-3 text-white"})})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{className:"text-2xl font-bold text-white",children:y.full_name||y.username}),e.jsxs("p",{className:"text-text-secondary mt-1",children:["@",y.username]}),e.jsxs("div",{className:"flex items-center gap-4 mt-3",children:[e.jsxs("div",{className:`inline-flex items-center gap-2 px-3 py-1 rounded-full text-xs font-bold ${y.is_active?"bg-green-500/10 text-green-400 border border-green-500/20":"bg-red-500/10 text-red-400 border border-red-500/20"}`,children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${y.is_active?"bg-green-400":"bg-red-400"}`}),y.is_active?"Active":"Inactive"]}),y.is_system&&e.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-1 rounded-full text-xs font-bold bg-purple-500/10 text-purple-400 border border-purple-500/20",children:[e.jsx(Bn,{size:12}),"System User"]})]})]})]})}),e.jsx("div",{className:"p-8",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{children:[e.jsxs("h3",{className:"text-lg font-bold text-white mb-4 flex items-center gap-2",children:[e.jsx(o4,{className:"h-5 w-5 text-primary"}),"Basic Information"]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-text-secondary uppercase tracking-wider mb-2",children:"Username"}),e.jsx("div",{className:"bg-[#0f161d] border border-border-dark rounded-lg px-4 py-3 text-white font-mono",children:y.username}),e.jsx("p",{className:"text-xs text-text-secondary mt-1",children:"Username cannot be changed"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-text-secondary uppercase tracking-wider mb-2",children:"Email Address"}),o?e.jsx("input",{type:"email",value:d.email,onChange:M=>c({...d,email:M.target.value}),className:"w-full bg-[#0f161d] border border-border-dark rounded-lg px-4 py-3 text-white focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent",placeholder:"email@example.com"}):e.jsxs("div",{className:"bg-[#0f161d] border border-border-dark rounded-lg px-4 py-3 text-white flex items-center gap-2",children:[e.jsx(U6,{className:"h-4 w-4 text-text-secondary"}),y.email||"-"]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-text-secondary uppercase tracking-wider mb-2",children:"Full Name"}),o?e.jsx("input",{type:"text",value:d.full_name,onChange:M=>c({...d,full_name:M.target.value}),className:"w-full bg-[#0f161d] border border-border-dark rounded-lg px-4 py-3 text-white focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent",placeholder:"Full Name"}):e.jsx("div",{className:"bg-[#0f161d] border border-border-dark rounded-lg px-4 py-3 text-white",children:y.full_name||"-"})]})]})]})}),e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{children:[e.jsxs("h3",{className:"text-lg font-bold text-white mb-4 flex items-center gap-2",children:[e.jsx(Bn,{className:"h-5 w-5 text-primary"}),"Account Details"]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-text-secondary uppercase tracking-wider mb-2",children:"Roles"}),e.jsx("div",{className:"bg-[#0f161d] border border-border-dark rounded-lg px-4 py-3",children:y.roles&&y.roles.length>0?e.jsx("div",{className:"flex flex-wrap gap-2",children:y.roles.map(M=>e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md bg-primary/10 text-primary text-xs font-medium border border-primary/20",children:[e.jsx(Bn,{size:12}),M]},M))}):e.jsx("span",{className:"text-text-secondary text-sm",children:"No roles assigned"})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-text-secondary uppercase tracking-wider mb-2",children:"Permissions"}),e.jsx("div",{className:"bg-[#0f161d] border border-border-dark rounded-lg px-4 py-3",children:y.permissions&&y.permissions.length>0?e.jsx("div",{className:"flex flex-wrap gap-2",children:y.permissions.map(M=>e.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded-md bg-slate-700 text-slate-300 text-xs font-medium",children:M},M))}):e.jsx("span",{className:"text-text-secondary text-sm",children:"No permissions assigned"})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-text-secondary uppercase tracking-wider mb-2",children:"Last Login"}),e.jsxs("div",{className:"bg-[#0f161d] border border-border-dark rounded-lg px-4 py-3 text-white flex items-center gap-2",children:[e.jsx(Ec,{className:"h-4 w-4 text-text-secondary"}),L(y.last_login_at)]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-text-secondary uppercase tracking-wider mb-2",children:"Account Created"}),e.jsxs("div",{className:"bg-[#0f161d] border border-border-dark rounded-lg px-4 py-3 text-white flex items-center gap-2",children:[e.jsx(l4,{className:"h-4 w-4 text-text-secondary"}),w(y.created_at)]})]})]})]})})]})})]})]})})}const Qv=[{id:"1",name:"Daily Backup: VM-Cluster-01",type:"Replication",progress:45,speed:"145 MB/s",status:"running",eta:"1h 12m"},{id:"2",name:"ZFS Scrub: Pool-01",type:"Maintenance",progress:78,speed:"1.2 GB/s",status:"running"}];function A_(){const[r,t]=Ce.useState("jobs"),[s,n]=Ce.useState(""),o=5,{data:l,isLoading:d}=dt({queryKey:["monitoring-metrics"],queryFn:Cc.getMetrics,refetchInterval:o*1e3}),{data:c=[],isLoading:u}=dt({queryKey:["monitoring-logs"],queryFn:()=>ao.getSystemLogs(50),refetchInterval:10*1e3}),{data:h=[]}=dt({queryKey:["monitoring-network"],queryFn:()=>ao.getNetworkThroughput("15m"),refetchInterval:o*1e3}),{data:m=[]}=dt({queryKey:["monitoring-pools"],queryFn:sn.listPools,refetchInterval:30*1e3}),{data:x}=dt({queryKey:["monitoring-alerts"],queryFn:()=>Cc.listAlerts({limit:20}),refetchInterval:10*1e3}),y=w=>{const L=Math.floor(w/86400),K=Math.floor(w%86400/3600),M=Math.floor(w%3600/60);return`${L}d ${K}h ${M}m`},p=m.length>0?m[0]:null,v=p?.health_status==="online"?"Online":"Degraded",N=p?.health_status==="online",B=c.filter(w=>w.message.toLowerCase().includes(s.toLowerCase())||w.source.toLowerCase().includes(s.toLowerCase())),g=w=>{const L=w.toUpperCase();return L==="INFO"||L==="DEBUG"?"text-emerald-500":L==="WARN"||L==="WARNING"?"text-yellow-500":L==="ERROR"||L==="CRITICAL"||L==="FATAL"?"text-red-500":"text-text-secondary"},j=h.length>0?Math.max(...h.map(w=>Math.max(w.inbound,w.outbound))):0,_=h.length>0?((h[h.length-1].inbound+h[h.length-1].outbound)/1e3).toFixed(1):"0.0";return e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col bg-background-dark",children:[e.jsx("header",{className:"flex-none px-6 py-5 border-b border-border-dark bg-background-dark/95 backdrop-blur z-10",children:e.jsxs("div",{className:"flex flex-wrap justify-between items-end gap-3 max-w-[1600px] mx-auto",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("h2",{className:"text-white text-3xl font-black tracking-tight",children:"System Monitor"}),e.jsx("p",{className:"text-text-secondary text-sm",children:"Real-time telemetry, ZFS health, and system event logs"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-card-dark rounded-lg border border-border-dark",children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-emerald-500"})]}),e.jsx("span",{className:"text-xs font-medium text-emerald-400",children:"System Healthy"})]}),e.jsxs("button",{className:"flex items-center gap-2 h-10 px-4 bg-card-dark hover:bg-[#233648] border border-border-dark text-white text-sm font-bold rounded-lg transition-colors",children:[e.jsx(Cn,{size:18}),e.jsxs("span",{children:["Refresh: ",o,"s"]})]})]})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto custom-scrollbar p-6",children:e.jsxs("div",{className:"flex flex-col gap-6 max-w-[1600px] mx-auto pb-10",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2 rounded-xl p-5 border border-border-dark bg-card-dark",children:[e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsx("p",{className:"text-text-secondary text-sm font-medium",children:"CPU Load"}),e.jsx(e4,{className:"text-text-secondary",size:20})]}),e.jsxs("div",{className:"flex items-end gap-3 mt-1",children:[e.jsx("p",{className:"text-white text-3xl font-bold",children:d?"...":`${l?.system?.cpu_usage_percent?.toFixed(0)||0}%`}),e.jsxs("span",{className:"text-emerald-500 text-sm font-medium mb-1 flex items-center",children:[e.jsx(t4,{size:16,className:"mr-1"}),"2%"]})]}),e.jsx("div",{className:"h-1.5 w-full bg-[#233648] rounded-full mt-3 overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary rounded-full transition-all",style:{width:`${l?.system?.cpu_usage_percent||0}%`}})})]}),e.jsxs("div",{className:"flex flex-col gap-2 rounded-xl p-5 border border-border-dark bg-card-dark",children:[e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsx("p",{className:"text-text-secondary text-sm font-medium",children:"RAM Usage"}),e.jsx(r4,{className:"text-text-secondary",size:20})]}),e.jsxs("div",{className:"flex items-end gap-3 mt-1",children:[e.jsx("p",{className:"text-white text-3xl font-bold",children:d?"...":fr(l?.system?.memory_used_bytes||0)}),e.jsxs("span",{className:"text-text-secondary text-xs mb-2",children:["/ ",fr(l?.system?.memory_total_bytes||0)]})]}),e.jsx("div",{className:"h-1.5 w-full bg-[#233648] rounded-full mt-3 overflow-hidden",children:e.jsx("div",{className:"h-full bg-emerald-500 rounded-full transition-all",style:{width:`${l?.system?.memory_usage_percent||0}%`}})})]}),e.jsxs("div",{className:"flex flex-col gap-2 rounded-xl p-5 border border-border-dark bg-card-dark",children:[e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsx("p",{className:"text-text-secondary text-sm font-medium",children:"ZFS Pool Status"}),e.jsx(su,{className:N?"text-emerald-500":"text-yellow-500",size:20})]}),e.jsxs("div",{className:"flex items-end gap-3 mt-1",children:[e.jsx("p",{className:"text-white text-3xl font-bold",children:v}),e.jsx("span",{className:"text-text-secondary text-sm font-medium mb-1",children:"No Errors"})]}),e.jsx("div",{className:"flex gap-1 mt-3",children:[1,2,3,4].map(w=>e.jsx("div",{className:`h-1.5 flex-1 rounded-full ${w===1?"rounded-l-full":w===4?"rounded-r-full":""} ${N?"bg-emerald-500":"bg-yellow-500"}`},w))})]}),e.jsxs("div",{className:"flex flex-col gap-2 rounded-xl p-5 border border-border-dark bg-card-dark",children:[e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsx("p",{className:"text-text-secondary text-sm font-medium",children:"System Uptime"}),e.jsx(Ec,{className:"text-text-secondary",size:20})]}),e.jsx("div",{className:"mt-1",children:e.jsx("p",{className:"text-white text-3xl font-bold",children:d?"...":y(l?.system?.uptime_seconds||0)})}),e.jsx("p",{className:"text-text-secondary text-xs mt-3",children:"Last reboot: Manual Patching"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"xl:col-span-2 flex flex-col gap-6",children:[e.jsxs("div",{className:"bg-card-dark border border-border-dark rounded-xl p-6 shadow-sm",children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-white text-lg font-bold",children:"Network Throughput"}),e.jsx("p",{className:"text-text-secondary text-sm",children:"Inbound vs Outbound (eth0)"})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"text-white text-2xl font-bold leading-tight",children:[_," Gbps"]}),e.jsxs("p",{className:"text-emerald-500 text-sm",children:["Peak: ",(j/1e3).toFixed(1)," Gbps"]})]})]}),e.jsx("div",{className:"h-[200px] w-full",children:h.length>0?e.jsx(Cl,{width:"100%",height:"100%",children:e.jsxs(f4,{data:h.map(w=>({time:new Date(w.time).toLocaleTimeString(),inbound:w.inbound,outbound:w.outbound})),children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"gradientPrimary",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#137fec",stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:"#137fec",stopOpacity:0})]})}),e.jsx(Nc,{strokeDasharray:"3 3",stroke:"#324d67"}),e.jsx(Bc,{dataKey:"time",stroke:"#92adc9",style:{fontSize:"12px"}}),e.jsx(jc,{stroke:"#92adc9",style:{fontSize:"12px"}}),e.jsx(Sl,{contentStyle:{backgroundColor:"#1a2632",border:"1px solid #324d67",borderRadius:"0.5rem"}}),e.jsx(Qh,{}),e.jsx(vh,{type:"monotone",dataKey:"outbound",stroke:"#92adc9",strokeDasharray:"5 5",strokeWidth:2,fill:"none"}),e.jsx(vh,{type:"monotone",dataKey:"inbound",stroke:"#137fec",strokeWidth:3,fill:"url(#gradientPrimary)"})]})}):e.jsx("div",{className:"h-full flex items-center justify-center text-text-secondary",children:"Loading network data..."})})]}),e.jsxs("div",{className:"bg-card-dark border border-border-dark rounded-xl p-6 shadow-sm",children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-white text-lg font-bold",children:"ZFS ARC Hit Ratio"}),e.jsx("p",{className:"text-text-secondary text-sm",children:"Cache efficiency"})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-white text-2xl font-bold leading-tight",children:"94%"}),e.jsx("p",{className:"text-text-secondary text-sm",children:"Target: >90%"})]})]}),e.jsxs("div",{className:"h-[150px] w-full relative",children:[e.jsx(Cl,{width:"100%",height:"100%",children:e.jsxs(ky,{data:[{time:"10:00",ratio:95},{time:"10:15",ratio:94},{time:"10:30",ratio:96},{time:"10:45",ratio:93},{time:"11:00",ratio:94}],children:[e.jsx(Nc,{strokeDasharray:"3 3",stroke:"#324d67"}),e.jsx(Bc,{dataKey:"time",stroke:"#92adc9",style:{fontSize:"12px"}}),e.jsx(jc,{stroke:"#92adc9",domain:[90,100],style:{fontSize:"12px"}}),e.jsx(Sl,{contentStyle:{backgroundColor:"#1a2632",border:"1px solid #324d67",borderRadius:"0.5rem"}}),e.jsx(Lh,{type:"monotone",dataKey:"ratio",stroke:"#10b981",strokeWidth:2,dot:!1})]})}),e.jsx("div",{className:"w-full h-[1px] bg-border-dark absolute top-[20%]"}),e.jsx("div",{className:"absolute top-[20%] right-0 text-xs text-text-secondary -mt-5",children:"95%"})]})]})]}),e.jsx("div",{className:"flex flex-col gap-6",children:e.jsxs("div",{className:"bg-card-dark border border-border-dark rounded-xl p-6 h-full shadow-sm flex flex-col",children:[e.jsxs("div",{className:"flex justify-between items-center mb-4",children:[e.jsx("h3",{className:"text-white text-lg font-bold",children:"Disk Health"}),e.jsx("span",{className:"bg-[#233648] text-white text-xs px-2 py-1 rounded border border-border-dark",children:"Pool 1"})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-3 flex-1 content-start",children:[[0,1,2,3,4,5,6,7].map(w=>e.jsxs("div",{className:`aspect-square border rounded flex flex-col items-center justify-center ${w===5?"bg-[#332a18] border-yellow-700/50":"bg-[#1a2e22] border-emerald-800"}`,children:[w===5?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"absolute top-1 right-1 h-2 w-2 rounded-full bg-yellow-500 animate-pulse"}),e.jsx(Eh,{className:"text-yellow-500",size:20})]}):e.jsx(Ul,{className:"text-emerald-500",size:20}),e.jsxs("span",{className:`text-[10px] font-mono mt-1 ${w===5?"text-yellow-500":"text-emerald-500"}`,children:["da",w]})]},w)),[8,9,10,11].map(w=>e.jsx("div",{className:"aspect-square bg-[#161f29] border border-border-dark border-dashed rounded flex flex-col items-center justify-center opacity-50",children:e.jsx("span",{className:"text-[10px] text-text-secondary font-mono",children:"Empty"})},w))]}),e.jsxs("div",{className:"mt-4 pt-4 border-t border-border-dark",children:[e.jsxs("div",{className:"flex justify-between text-sm text-text-secondary",children:[e.jsx("span",{children:"Total Capacity"}),e.jsx("span",{className:"text-white font-bold",children:fr(l?.storage?.total_capacity_bytes||0)})]}),e.jsx("div",{className:"w-full bg-[#233648] h-2 rounded-full mt-2 overflow-hidden",children:e.jsx("div",{className:"bg-primary h-full transition-all",style:{width:`${l?.storage?.total_capacity_bytes?l.storage.used_capacity_bytes/l.storage.total_capacity_bytes*100:0}%`}})}),e.jsxs("div",{className:"flex justify-between text-xs text-text-secondary mt-1",children:[e.jsxs("span",{children:["Used: ",fr(l?.storage?.used_capacity_bytes||0)]}),e.jsxs("span",{children:["Free: ",fr((l?.storage?.total_capacity_bytes||0)-(l?.storage?.used_capacity_bytes||0))]})]})]})]})})]}),e.jsxs("div",{className:"bg-card-dark border border-border-dark rounded-xl shadow-sm overflow-hidden flex flex-col h-[400px]",children:[e.jsxs("div",{className:"flex border-b border-border-dark bg-[#161f29]",children:[e.jsxs("button",{onClick:()=>t("jobs"),className:`px-6 py-4 text-sm font-bold flex items-center transition-colors ${r==="jobs"?"text-primary border-b-2 border-primary bg-card-dark":"text-text-secondary hover:text-white"}`,children:["Active Jobs"," ",e.jsx("span",{className:"ml-2 bg-primary/20 text-primary px-1.5 py-0.5 rounded text-xs",children:Qv.length})]}),e.jsx("button",{onClick:()=>t("logs"),className:`px-6 py-4 text-sm transition-colors ${r==="logs"?"text-primary border-b-2 border-primary bg-card-dark font-bold":"text-text-secondary hover:text-white font-medium"}`,children:"System Logs"}),e.jsx("button",{onClick:()=>t("alerts"),className:`px-6 py-4 text-sm transition-colors ${r==="alerts"?"text-primary border-b-2 border-primary bg-card-dark font-bold":"text-text-secondary hover:text-white font-medium"}`,children:"Alerts History"}),e.jsx("div",{className:"flex-1 flex justify-end items-center px-4",children:e.jsxs("div",{className:"relative",children:[e.jsx(io,{className:"absolute left-2 top-1.5 text-text-secondary",size:18}),e.jsx("input",{className:"bg-[#111a22] border border-border-dark rounded-md py-1 pl-8 pr-3 text-sm text-white focus:outline-none focus:border-primary w-48 transition-all",placeholder:"Search logs...",type:"text",value:s,onChange:w=>n(w.target.value)})]})})]}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[r==="jobs"&&e.jsx("div",{className:"p-0 overflow-y-auto custom-scrollbar",children:e.jsxs("table",{className:"w-full text-left border-collapse",children:[e.jsx("thead",{className:"bg-[#1a2632] text-xs uppercase text-text-secondary font-medium sticky top-0 z-10",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-3 border-b border-border-dark",children:"Job Name"}),e.jsx("th",{className:"px-6 py-3 border-b border-border-dark",children:"Type"}),e.jsx("th",{className:"px-6 py-3 border-b border-border-dark w-1/3",children:"Progress"}),e.jsx("th",{className:"px-6 py-3 border-b border-border-dark",children:"Speed"}),e.jsx("th",{className:"px-6 py-3 border-b border-border-dark",children:"Status"})]})}),e.jsx("tbody",{className:"text-sm divide-y divide-border-dark",children:Qv.map(w=>e.jsxs("tr",{className:"group hover:bg-[#233648] transition-colors",children:[e.jsx("td",{className:"px-6 py-4 font-medium text-white",children:w.name}),e.jsx("td",{className:"px-6 py-4 text-text-secondary",children:w.type}),e.jsxs("td",{className:"px-6 py-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-full bg-[#111a22] rounded-full h-2 overflow-hidden",children:e.jsx("div",{className:"bg-primary h-full rounded-full relative overflow-hidden",style:{width:`${w.progress}%`},children:e.jsx("div",{className:"absolute inset-0 bg-white/20 animate-pulse"})})}),e.jsxs("span",{className:"text-xs font-mono text-white",children:[w.progress,"%"]})]}),w.eta&&e.jsxs("p",{className:"text-[10px] text-text-secondary mt-1",children:["ETA: ",w.eta]})]}),e.jsx("td",{className:"px-6 py-4 text-text-secondary font-mono",children:w.speed}),e.jsx("td",{className:"px-6 py-4",children:e.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded text-xs font-medium bg-primary/20 text-primary",children:"Running"})})]},w.id))})]})}),r==="logs"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-6 py-2 bg-[#161f29] border-y border-border-dark flex items-center justify-between",children:[e.jsx("h4",{className:"text-xs uppercase text-text-secondary font-bold tracking-wider",children:"Recent System Events"}),e.jsx("button",{className:"text-xs text-primary hover:text-white transition-colors",children:"View All Logs"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto custom-scrollbar bg-[#111a22]",children:e.jsx("table",{className:"w-full text-left border-collapse",children:e.jsx("tbody",{className:"text-sm font-mono divide-y divide-border-dark/50",children:u?e.jsx("tr",{children:e.jsx("td",{colSpan:4,className:"px-6 py-4 text-center text-text-secondary",children:"Loading logs..."})}):B.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:4,className:"px-6 py-4 text-center text-text-secondary",children:"No logs found"})}):B.map((w,L)=>e.jsxs("tr",{className:"group hover:bg-[#233648] transition-colors",children:[e.jsx("td",{className:"px-6 py-2 text-text-secondary w-32 whitespace-nowrap",children:new Date(w.time).toLocaleTimeString()}),e.jsx("td",{className:"px-6 py-2 w-24",children:e.jsx("span",{className:g(w.level),children:w.level})}),e.jsx("td",{className:"px-6 py-2 w-32 text-white",children:w.source}),e.jsx("td",{className:"px-6 py-2 text-text-secondary truncate max-w-lg",children:w.message})]},L))})})})]}),r==="alerts"&&e.jsx("div",{className:"flex-1 overflow-y-auto custom-scrollbar bg-[#111a22] p-6",children:x?.alerts&&x.alerts.length>0?e.jsx("div",{className:"space-y-3",children:x.alerts.map(w=>e.jsx("div",{className:"bg-[#1a2632] border border-border-dark rounded-lg p-4 hover:bg-[#233648] transition-colors",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[w.severity==="critical"?e.jsx(_l,{className:"text-red-500 mt-1",size:20}):w.severity==="warning"?e.jsx(Eh,{className:"text-yellow-500 mt-1",size:20}):e.jsx(a4,{className:"text-blue-500 mt-1",size:20}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-white font-medium",children:w.title}),e.jsx("p",{className:"text-text-secondary text-sm mt-1",children:w.message}),e.jsx("p",{className:"text-text-secondary text-xs mt-2",children:new Date(w.created_at).toLocaleString()})]})]}),e.jsx("span",{className:`px-2 py-1 rounded text-xs font-medium ${w.severity==="critical"?"bg-red-500/20 text-red-400":w.severity==="warning"?"bg-yellow-500/20 text-yellow-400":"bg-blue-500/20 text-blue-400"}`,children:w.severity.toUpperCase()})]})},w.id))}):e.jsx("div",{className:"text-center text-text-secondary py-8",children:"No alerts"})})]})]})]})})]})}const Ea={listBuckets:async()=>(await ze.get("/object-storage/buckets")).data.buckets||[],getBucket:async r=>(await ze.get(`/object-storage/buckets/${encodeURIComponent(r)}`)).data,createBucket:async r=>{await ze.post("/object-storage/buckets",{name:r})},deleteBucket:async r=>{await ze.delete(`/object-storage/buckets/${encodeURIComponent(r)}`)},getAvailableDatasets:async()=>(await ze.get("/object-storage/setup/datasets")).data.pools||[],getCurrentSetup:async()=>{const r=await ze.get("/object-storage/setup/current");return!r.data.configured||!r.data.setup?null:{dataset_path:r.data.setup.dataset_path,mount_point:r.data.setup.mount_point}},setupObjectStorage:async(r,t,s)=>(await ze.post("/object-storage/setup",{pool_name:r,dataset_name:t,create_new:s})).data,updateObjectStorage:async(r,t,s)=>(await ze.put("/object-storage/setup",{pool_name:r,dataset_name:t,create_new:s})).data,listUsers:async()=>(await ze.get("/object-storage/users")).data.users||[],createUser:async r=>{await ze.post("/object-storage/users",r)},deleteUser:async r=>{await ze.delete(`/object-storage/users/${encodeURIComponent(r)}`)},listServiceAccounts:async()=>(await ze.get("/object-storage/service-accounts")).data.service_accounts||[],createServiceAccount:async r=>(await ze.post("/object-storage/service-accounts",r)).data,deleteServiceAccount:async r=>{await ze.delete(`/object-storage/service-accounts/${encodeURIComponent(r)}`)},listObjects:async(r,t)=>{const s=t?`?prefix=${encodeURIComponent(t)}`:"";return(await ze.get(`/object-storage/buckets/${encodeURIComponent(r)}/objects${s}`)).data.objects||[]}};function c_({S3_ENDPOINT:r}){const[t,s]=Ce.useState("users"),[n,o]=Ce.useState(!1),[l,d]=Ce.useState(""),[c,u]=Ce.useState(""),[h,m]=Ce.useState(!1),[x,y]=Ce.useState(""),[p,v]=Ce.useState(""),[N,B]=Ce.useState(""),[g,j]=Ce.useState(null),[_,w]=Ce.useState(!1),[L,K]=Ce.useState(null),[M,V]=Ce.useState(null),[T,ne]=Ce.useState(!1),[Z,U]=Ce.useState(!1),q=Nr(),{data:F=[],isLoading:le}=dt({queryKey:["object-storage-users"],queryFn:Ea.listUsers,refetchInterval:1e4}),{data:ae=[],isLoading:se}=dt({queryKey:["object-storage-service-accounts"],queryFn:Ea.listServiceAccounts,refetchInterval:1e4}),fe=ft({mutationFn:J=>Ea.createUser(J),onMutate:async J=>{await q.cancelQueries({queryKey:["object-storage-users"]});const O=q.getQueryData(["object-storage-users"]);return q.setQueryData(["object-storage-users"],(H=[])=>{const re={access_key:J.access_key,status:"enabled",created_at:new Date().toISOString()};return[...H,re]}),o(!1),d(""),u(""),{previousUsers:O}},onError:(J,O,H)=>{H?.previousUsers&&q.setQueryData(["object-storage-users"],H.previousUsers),o(!0),alert(J.response?.data?.error||"Failed to create user")},onSuccess:()=>{q.invalidateQueries({queryKey:["object-storage-users"]}),alert("User created successfully!")},onSettled:()=>{q.invalidateQueries({queryKey:["object-storage-users"]})}}),ye=ft({mutationFn:J=>Ea.deleteUser(J),onMutate:async J=>{await q.cancelQueries({queryKey:["object-storage-users"]});const O=q.getQueryData(["object-storage-users"]);return q.setQueryData(["object-storage-users"],(H=[])=>H.filter(re=>re.access_key!==J)),{previousUsers:O}},onError:(J,O,H)=>{H?.previousUsers&&q.setQueryData(["object-storage-users"],H.previousUsers),alert(J.response?.data?.error||"Failed to delete user")},onSuccess:()=>{q.invalidateQueries({queryKey:["object-storage-users"]})},onSettled:()=>{q.invalidateQueries({queryKey:["object-storage-users"]})}}),_e=ft({mutationFn:J=>Ea.createServiceAccount(J),onMutate:async J=>{await q.cancelQueries({queryKey:["object-storage-service-accounts"]});const O=q.getQueryData(["object-storage-service-accounts"]);return m(!1),y(""),v(""),B(""),{previousAccounts:O}},onError:(J,O,H)=>{H?.previousAccounts&&q.setQueryData(["object-storage-service-accounts"],H.previousAccounts),m(!0),alert(J.response?.data?.error||"Failed to create access key")},onSuccess:J=>{q.setQueryData(["object-storage-service-accounts"],(O=[])=>[...O,J]),j(J),q.invalidateQueries({queryKey:["object-storage-service-accounts"]})},onSettled:()=>{q.invalidateQueries({queryKey:["object-storage-service-accounts"]})}}),xe=ft({mutationFn:J=>Ea.deleteServiceAccount(J),onMutate:async J=>{await q.cancelQueries({queryKey:["object-storage-service-accounts"]});const O=q.getQueryData(["object-storage-service-accounts"]);return q.setQueryData(["object-storage-service-accounts"],(H=[])=>H.filter(re=>re.access_key!==J)),{previousAccounts:O}},onError:(J,O,H)=>{H?.previousAccounts&&q.setQueryData(["object-storage-service-accounts"],H.previousAccounts),alert(J.response?.data?.error||"Failed to delete access key")},onSuccess:()=>{q.invalidateQueries({queryKey:["object-storage-service-accounts"]})},onSettled:()=>{q.invalidateQueries({queryKey:["object-storage-service-accounts"]})}}),D=async()=>{ne(!0);try{await q.invalidateQueries({queryKey:["object-storage-users"]}),await q.refetchQueries({queryKey:["object-storage-users"]}),setTimeout(()=>{alert("Users refreshed successfully!")},300)}catch{alert("Failed to refresh users")}finally{ne(!1)}},$=async()=>{U(!0);try{await q.invalidateQueries({queryKey:["object-storage-service-accounts"]}),await q.refetchQueries({queryKey:["object-storage-service-accounts"]}),setTimeout(()=>{alert("Access keys refreshed successfully!")},300)}catch{alert("Failed to refresh access keys")}finally{U(!1)}},X=J=>new Date(J).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),te=async(J,O)=>{try{await navigator.clipboard.writeText(J),alert(`${O} copied to clipboard!`)}catch(H){console.error("Failed to copy:",H);const re=document.createElement("textarea");re.value=J,re.style.position="fixed",re.style.left="-999999px",document.body.appendChild(re),re.select();try{document.execCommand("copy"),alert(`${O} copied to clipboard!`)}catch{alert(`Failed to copy. ${O}: ${J}`)}document.body.removeChild(re)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-border-dark",children:[e.jsx("button",{onClick:()=>s("users"),className:`px-4 py-2 text-sm font-medium transition-colors ${t==="users"?"text-primary border-b-2 border-primary":"text-text-secondary hover:text-white"}`,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Vd,{size:18}),e.jsxs("span",{children:["Users (",F.length,")"]})]})}),e.jsx("button",{onClick:()=>s("keys"),className:`px-4 py-2 text-sm font-medium transition-colors ${t==="keys"?"text-primary border-b-2 border-primary":"text-text-secondary hover:text-white"}`,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Wx,{size:18}),e.jsxs("span",{children:["Access Keys (",ae.length,")"]})]})})]}),t==="users"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-white text-xl font-bold",children:"IAM Users"}),e.jsx("p",{className:"text-text-secondary text-sm mt-1",children:"Manage MinIO IAM users for accessing object storage"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:D,disabled:T,className:"px-4 py-2 bg-[#233648] hover:bg-[#2b4055] text-white text-sm font-medium rounded-lg border border-border-dark transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2",children:[e.jsx(Cn,{size:16,className:T?"animate-spin":""}),T?"Refreshing...":"Refresh"]}),e.jsxs("button",{onClick:()=>o(!0),className:"px-4 py-2 bg-primary hover:bg-blue-600 text-white text-sm font-medium rounded-lg transition-colors flex items-center gap-2",children:[e.jsx(mp,{size:16}),"Create User"]})]})]}),le?e.jsx("div",{className:"bg-[#1c2936] border border-border-dark rounded-lg p-8 text-center",children:e.jsx("p",{className:"text-text-secondary text-sm",children:"Loading users..."})}):F.length===0?e.jsxs("div",{className:"bg-[#1c2936] border border-border-dark rounded-lg p-8 text-center",children:[e.jsx(Vd,{className:"mx-auto mb-4 text-text-secondary",size:48}),e.jsx("p",{className:"text-text-secondary text-sm mb-4",children:"No users found"}),e.jsx("button",{onClick:()=>o(!0),className:"px-4 py-2 bg-primary hover:bg-blue-600 text-white text-sm font-medium rounded-lg transition-colors",children:"Create First User"})]}):e.jsx("div",{className:"bg-[#1c2936] border border-border-dark rounded-lg overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"bg-[#16202a] border-b border-border-dark",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-text-secondary uppercase tracking-wider",children:"Access Key"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-text-secondary uppercase tracking-wider",children:"Status"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-text-secondary uppercase tracking-wider",children:"Created"}),e.jsx("th",{className:"px-6 py-3 text-right text-xs font-medium text-text-secondary uppercase tracking-wider",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-border-dark",children:F.map(J=>e.jsxs("tr",{className:"hover:bg-[#233648] transition-colors",children:[e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Vd,{size:16,className:"text-primary"}),e.jsx("span",{className:"text-white font-mono text-sm",children:J.access_key})]})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("span",{className:`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ${J.status==="enabled"?"bg-green-500/10 text-green-500 border border-green-500/20":"bg-red-500/10 text-red-500 border border-red-500/20"}`,children:J.status==="enabled"?e.jsxs(e.Fragment,{children:[e.jsx(su,{size:12,className:"mr-1"}),"Enabled"]}):"Disabled"})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-text-secondary text-sm",children:X(J.created_at)}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsxs("button",{onClick:async()=>{await te(J.access_key,"Access Key")},className:"px-3 py-1.5 text-xs font-medium text-white bg-[#233648] hover:bg-[#2b4055] border border-border-dark rounded-lg transition-colors flex items-center gap-1.5",title:"Copy Access Key",children:[e.jsx(so,{size:14}),"Copy"]}),e.jsxs("button",{onClick:()=>K(J.access_key),disabled:ye.isPending,className:"px-3 py-1.5 text-xs font-medium text-red-400 bg-red-500/10 hover:bg-red-500/20 border border-red-500/20 rounded-lg transition-colors flex items-center gap-1.5 disabled:opacity-50 disabled:cursor-not-allowed",title:"Delete User",children:[e.jsx(es,{size:14}),"Delete"]})]})})]},J.access_key))})]})})})]}),t==="keys"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-white text-xl font-bold",children:"Access Keys"}),e.jsx("p",{className:"text-text-secondary text-sm mt-1",children:"Manage service account access keys for programmatic access"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:$,disabled:Z,className:"px-4 py-2 bg-[#233648] hover:bg-[#2b4055] text-white text-sm font-medium rounded-lg border border-border-dark transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2",children:[e.jsx(Cn,{size:16,className:Z?"animate-spin":""}),Z?"Refreshing...":"Refresh"]}),e.jsxs("button",{onClick:()=>{if(F.length===0){alert("Please create at least one user before creating access keys"),s("users");return}m(!0)},className:"px-4 py-2 bg-primary hover:bg-blue-600 text-white text-sm font-medium rounded-lg transition-colors flex items-center gap-2",children:[e.jsx(Q6,{size:16}),"Create Access Key"]})]})]}),se?e.jsx("div",{className:"bg-[#1c2936] border border-border-dark rounded-lg p-8 text-center",children:e.jsx("p",{className:"text-text-secondary text-sm",children:"Loading access keys..."})}):ae.length===0?e.jsxs("div",{className:"bg-[#1c2936] border border-border-dark rounded-lg p-8 text-center",children:[e.jsx(Wx,{className:"mx-auto mb-4 text-text-secondary",size:48}),e.jsx("p",{className:"text-text-secondary text-sm mb-4",children:"No access keys found"}),e.jsx("button",{onClick:()=>{if(F.length===0){alert("Please create at least one user before creating access keys"),s("users");return}m(!0)},className:"px-4 py-2 bg-primary hover:bg-blue-600 text-white text-sm font-medium rounded-lg transition-colors",children:"Create First Access Key"})]}):e.jsx("div",{className:"bg-[#1c2936] border border-border-dark rounded-lg overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"bg-[#16202a] border-b border-border-dark",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-text-secondary uppercase tracking-wider",children:"Access Key"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-text-secondary uppercase tracking-wider",children:"Parent User"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-text-secondary uppercase tracking-wider",children:"Expiration"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-text-secondary uppercase tracking-wider",children:"Created"}),e.jsx("th",{className:"px-6 py-3 text-right text-xs font-medium text-text-secondary uppercase tracking-wider",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-border-dark",children:ae.map(J=>e.jsxs("tr",{className:"hover:bg-[#233648] transition-colors",children:[e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Wx,{size:16,className:"text-primary"}),e.jsx("span",{className:"text-white font-mono text-sm",children:J.access_key})]})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-text-secondary text-sm",children:J.parent_user}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-text-secondary text-sm",children:J.expiration?X(J.expiration):"Never"}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-text-secondary text-sm",children:X(J.created_at)}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsxs("button",{onClick:async()=>{await te(J.access_key,"Access Key")},className:"px-3 py-1.5 text-xs font-medium text-white bg-[#233648] hover:bg-[#2b4055] border border-border-dark rounded-lg transition-colors flex items-center gap-1.5",title:"Copy Access Key",children:[e.jsx(so,{size:14}),"Copy"]}),e.jsxs("button",{onClick:()=>V(J.access_key),disabled:xe.isPending,className:"px-3 py-1.5 text-xs font-medium text-red-400 bg-red-500/10 hover:bg-red-500/20 border border-red-500/20 rounded-lg transition-colors flex items-center gap-1.5 disabled:opacity-50 disabled:cursor-not-allowed",title:"Delete Access Key",children:[e.jsx(es,{size:14}),"Delete"]})]})})]},J.access_key))})]})})})]}),n&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-[#1c2936] border border-border-dark rounded-lg p-6 max-w-md w-full mx-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h2",{className:"text-white text-xl font-bold",children:"Create IAM User"}),e.jsx("button",{onClick:()=>{o(!1),d(""),u("")},className:"text-text-secondary hover:text-white transition-colors",children:"✕"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-white text-sm font-medium mb-2",children:"Access Key"}),e.jsx("input",{type:"text",value:l,onChange:J=>d(J.target.value),placeholder:"e.g., myuser",className:"w-full bg-[#233648] border border-border-dark rounded-lg px-4 py-2 text-white text-sm focus:ring-1 focus:ring-primary focus:border-primary outline-none font-mono",autoFocus:!0}),e.jsx("p",{className:"text-text-secondary text-xs mt-2",children:"Access key must be unique and follow MinIO naming conventions"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-white text-sm font-medium mb-2",children:"Secret Key"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:_?"text":"password",value:c,onChange:J=>u(J.target.value),placeholder:"Enter secret key",className:"w-full bg-[#233648] border border-border-dark rounded-lg px-4 py-2 pr-10 text-white text-sm focus:ring-1 focus:ring-primary focus:border-primary outline-none font-mono"}),e.jsx("button",{type:"button",onClick:()=>w(!_),className:"absolute right-3 top-1/2 -translate-y-1/2 text-text-secondary hover:text-white",children:_?e.jsx(bv,{size:18}):e.jsx(Db,{size:18})})]}),e.jsx("p",{className:"text-text-secondary text-xs mt-2",children:"Secret key must be at least 8 characters long"})]}),e.jsxs("div",{className:"flex gap-3 justify-end pt-4",children:[e.jsx("button",{onClick:()=>{o(!1),d(""),u("")},className:"px-4 py-2 text-white text-sm font-medium rounded-lg border border-border-dark hover:bg-[#233648] transition-colors",children:"Cancel"}),e.jsx("button",{onClick:()=>{if(!l.trim()){alert("Please enter an access key");return}if(!c.trim()||c.length<8){alert("Please enter a secret key (minimum 8 characters)");return}fe.mutate({access_key:l.trim(),secret_key:c})},disabled:fe.isPending||!l.trim()||!c.trim(),className:"px-4 py-2 bg-primary hover:bg-blue-600 text-white text-sm font-medium rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:fe.isPending?"Creating...":"Create User"})]})]})]})}),h&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-[#1c2936] border border-border-dark rounded-lg p-6 max-w-md w-full mx-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h2",{className:"text-white text-xl font-bold",children:"Create Access Key"}),e.jsx("button",{onClick:()=>{m(!1),y(""),v(""),B("")},className:"text-text-secondary hover:text-white transition-colors",children:"✕"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-white text-sm font-medium mb-2",children:"Parent User"}),e.jsxs("select",{value:x,onChange:J=>y(J.target.value),className:"w-full bg-[#233648] border border-border-dark rounded-lg px-4 py-2 text-white text-sm focus:ring-1 focus:ring-primary focus:border-primary outline-none",autoFocus:!0,children:[e.jsx("option",{value:"",children:"-- Select User --"}),F.map(J=>e.jsx("option",{value:J.access_key,children:J.access_key},J.access_key))]}),e.jsx("p",{className:"text-text-secondary text-xs mt-2",children:"Select the IAM user this access key will belong to"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-white text-sm font-medium mb-2",children:"Policy (Optional)"}),e.jsx("textarea",{value:p,onChange:J=>v(J.target.value),placeholder:'{"Version":"2012-10-17","Statement":[...]}',rows:4,className:"w-full bg-[#233648] border border-border-dark rounded-lg px-4 py-2 text-white text-sm focus:ring-1 focus:ring-primary focus:border-primary outline-none font-mono"}),e.jsx("p",{className:"text-text-secondary text-xs mt-2",children:"JSON policy document (leave empty for default permissions)"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-white text-sm font-medium mb-2",children:"Expiration (Optional)"}),e.jsx("input",{type:"datetime-local",value:N,onChange:J=>B(J.target.value),className:"w-full bg-[#233648] border border-border-dark rounded-lg px-4 py-2 text-white text-sm focus:ring-1 focus:ring-primary focus:border-primary outline-none"}),e.jsx("p",{className:"text-text-secondary text-xs mt-2",children:"Leave empty for no expiration"})]}),e.jsxs("div",{className:"flex gap-3 justify-end pt-4",children:[e.jsx("button",{onClick:()=>{m(!1),y(""),v(""),B("")},className:"px-4 py-2 text-white text-sm font-medium rounded-lg border border-border-dark hover:bg-[#233648] transition-colors",children:"Cancel"}),e.jsx("button",{onClick:()=>{if(!x.trim()){alert("Please select a parent user");return}_e.mutate({parent_user:x.trim(),policy:p.trim()||void 0,expiration:N?new Date(N).toISOString():void 0})},disabled:_e.isPending||!x.trim(),className:"px-4 py-2 bg-primary hover:bg-blue-600 text-white text-sm font-medium rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:_e.isPending?"Creating...":"Create Access Key"})]})]})]})}),L&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-[#1c2936] border border-border-dark rounded-lg p-6 max-w-md w-full mx-4",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"p-2 bg-red-500/10 rounded-lg",children:e.jsx(_l,{className:"text-red-400",size:24})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-white text-lg font-bold",children:"Delete User"}),e.jsx("p",{className:"text-text-secondary text-sm",children:"This action cannot be undone"})]})]}),e.jsxs("div",{className:"mb-6",children:[e.jsxs("p",{className:"text-white text-sm mb-2",children:["Are you sure you want to delete user ",e.jsx("span",{className:"font-mono font-semibold text-primary",children:L}),"?"]}),e.jsx("p",{className:"text-text-secondary text-xs",children:"All access keys associated with this user will also be deleted. This action cannot be undone."})]}),e.jsxs("div",{className:"flex gap-3 justify-end",children:[e.jsx("button",{onClick:()=>K(null),className:"px-4 py-2 text-white text-sm font-medium rounded-lg border border-border-dark hover:bg-[#233648] transition-colors",children:"Cancel"}),e.jsxs("button",{onClick:()=>{ye.mutate(L),K(null)},disabled:ye.isPending,className:"px-4 py-2 bg-red-500 hover:bg-red-600 text-white text-sm font-medium rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2",children:[e.jsx(es,{size:16}),ye.isPending?"Deleting...":"Delete User"]})]})]})}),M&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-[#1c2936] border border-border-dark rounded-lg p-6 max-w-md w-full mx-4",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"p-2 bg-red-500/10 rounded-lg",children:e.jsx(_l,{className:"text-red-400",size:24})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-white text-lg font-bold",children:"Delete Access Key"}),e.jsx("p",{className:"text-text-secondary text-sm",children:"This action cannot be undone"})]})]}),e.jsxs("div",{className:"mb-6",children:[e.jsxs("p",{className:"text-white text-sm mb-2",children:["Are you sure you want to delete access key ",e.jsx("span",{className:"font-mono font-semibold text-primary",children:M}),"?"]}),e.jsx("p",{className:"text-text-secondary text-xs",children:"Applications using this access key will lose access immediately. This action cannot be undone."})]}),e.jsxs("div",{className:"flex gap-3 justify-end",children:[e.jsx("button",{onClick:()=>V(null),className:"px-4 py-2 text-white text-sm font-medium rounded-lg border border-border-dark hover:bg-[#233648] transition-colors",children:"Cancel"}),e.jsxs("button",{onClick:()=>{xe.mutate(M),V(null)},disabled:xe.isPending,className:"px-4 py-2 bg-red-500 hover:bg-red-600 text-white text-sm font-medium rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2",children:[e.jsx(es,{size:16}),xe.isPending?"Deleting...":"Delete Key"]})]})]})}),g&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-[#1c2936] border border-border-dark rounded-lg p-6 max-w-lg w-full mx-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h2",{className:"text-white text-xl font-bold",children:"Access Key Created"}),e.jsx("button",{onClick:()=>{j(null),w(!1)},className:"text-text-secondary hover:text-white transition-colors",children:"✕"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"bg-orange-500/10 border border-orange-500/20 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(_l,{className:"text-orange-400 mt-0.5",size:20}),e.jsxs("div",{children:[e.jsx("p",{className:"text-orange-400 text-sm font-medium mb-1",children:"Important"}),e.jsx("p",{className:"text-orange-300 text-xs",children:"Save these credentials now. The secret key will not be shown again."})]})]})}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-white text-sm font-medium mb-2",children:"Access Key"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",value:g.access_key,readOnly:!0,className:"flex-1 bg-[#233648] border border-border-dark rounded-lg px-4 py-2 text-white text-sm font-mono"}),e.jsx("button",{onClick:()=>te(g.access_key,"Access Key"),className:"px-3 py-2 bg-[#233648] hover:bg-[#2b4055] border border-border-dark rounded-lg text-white text-sm transition-colors",children:e.jsx(so,{size:16})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-white text-sm font-medium mb-2",children:"Secret Key"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx("input",{type:_?"text":"password",value:g.secret_key||"",readOnly:!0,className:"w-full bg-[#233648] border border-border-dark rounded-lg px-4 py-2 pr-10 text-white text-sm font-mono"}),e.jsx("button",{type:"button",onClick:()=>w(!_),className:"absolute right-3 top-1/2 -translate-y-1/2 text-text-secondary hover:text-white",children:_?e.jsx(bv,{size:18}):e.jsx(Db,{size:18})})]}),e.jsx("button",{onClick:()=>te(g.secret_key||"","Secret Key"),className:"px-3 py-2 bg-[#233648] hover:bg-[#2b4055] border border-border-dark rounded-lg text-white text-sm transition-colors",children:e.jsx(so,{size:16})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-white text-sm font-medium mb-2",children:"Endpoint"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",value:r,readOnly:!0,className:"flex-1 bg-[#233648] border border-border-dark rounded-lg px-4 py-2 text-white text-sm font-mono"}),e.jsx("button",{onClick:()=>te(r,"Endpoint"),className:"px-3 py-2 bg-[#233648] hover:bg-[#2b4055] border border-border-dark rounded-lg text-white text-sm transition-colors",children:e.jsx(so,{size:16})})]})]}),e.jsx("div",{className:"flex gap-3 justify-end pt-4",children:e.jsx("button",{onClick:()=>{j(null),w(!1)},className:"px-4 py-2 bg-primary hover:bg-blue-600 text-white text-sm font-medium rounded-lg transition-colors",children:"I've Saved These Credentials"})})]})]})})]})}const d_=9e3;function u_(){const[r,t]=Ce.useState("buckets"),[s,n]=Ce.useState(""),[o,l]=Ce.useState(1),[d,c]=Ce.useState(!1),[u,h]=Ce.useState(""),[m,x]=Ce.useState(""),[y,p]=Ce.useState(!1),[v,N]=Ce.useState(""),[B,g]=Ce.useState(!1),[j,_]=Ce.useState(!1),[w,L]=Ce.useState(""),[K,M]=Ce.useState(null),V=10,T=Nr(),{data:ne="localhost"}=dt({queryKey:["system-management-ip"],queryFn:ao.getManagementIPAddress,staleTime:300*1e3,retry:2}),Z=`http://${ne}:${d_}`,{data:U=[],isLoading:q}=dt({queryKey:["object-storage-buckets"],queryFn:Ea.listBuckets,refetchInterval:5e3,staleTime:0}),{data:F=[]}=dt({queryKey:["object-storage-setup-datasets"],queryFn:Ea.getAvailableDatasets,enabled:d}),{data:le}=dt({queryKey:["object-storage-current-setup"],queryFn:Ea.getCurrentSetup}),ae=ft({mutationFn:({poolName:re,datasetName:Ae,createNew:oe})=>le?Ea.updateObjectStorage(re,Ae,oe):Ea.setupObjectStorage(re,Ae,oe),onSuccess:re=>{T.invalidateQueries({queryKey:["object-storage-current-setup"]}),T.invalidateQueries({queryKey:["object-storage-buckets"]}),c(!1),alert(le?`Object storage dataset updated successfully! ${re.message} ⚠️ IMPORTANT: Existing data in the previous dataset is NOT automatically migrated. You may need to manually migrate data or restart MinIO service to use the new dataset.`:"Object storage setup completed successfully!")},onError:re=>{alert(re.response?.data?.error||`Failed to ${le?"update":"setup"} object storage`)}}),se=ft({mutationFn:re=>Ea.createBucket(re),onMutate:async re=>{await T.cancelQueries({queryKey:["object-storage-buckets"]});const Ae=T.getQueryData(["object-storage-buckets"]);return T.setQueryData(["object-storage-buckets"],(oe=[])=>{const ce={name:re,creation_date:new Date().toISOString(),size:0,objects:0,access_policy:"private"};return[...oe,ce]}),_(!1),L(""),{previousBuckets:Ae}},onError:(re,Ae,oe)=>{oe?.previousBuckets&&T.setQueryData(["object-storage-buckets"],oe.previousBuckets),_(!0),alert(re.response?.data?.error||"Failed to create bucket")},onSuccess:()=>{T.invalidateQueries({queryKey:["object-storage-buckets"]}),alert("Bucket created successfully!")},onSettled:()=>{T.invalidateQueries({queryKey:["object-storage-buckets"]})}}),fe=ft({mutationFn:re=>Ea.deleteBucket(re),onSuccess:()=>{T.invalidateQueries({queryKey:["object-storage-buckets"]}),M(null),alert("Bucket deleted successfully!")},onError:re=>{alert(re.response?.data?.error||"Failed to delete bucket")}}),ye=U.map(re=>({...re,usage:re.size||0,objects:re.objects||0,accessPolicy:re.access_policy||"private"})),_e=ye.filter(re=>re.name.toLowerCase().includes(s.toLowerCase())),xe=Math.ceil(_e.length/V),D=_e.slice((o-1)*V,o*V),$=ye.reduce((re,Ae)=>re+Ae.usage,0),X=ye.reduce((re,Ae)=>re+Ae.objects,0),te=re=>re.accessPolicy==="public-read"||re.accessPolicy==="public-read-write"?e.jsx(u4,{className:"text-orange-500",size:20}):e.jsx(h4,{className:"text-purple-500",size:20}),J=re=>re==="public-read-write"?e.jsx("span",{className:"inline-flex items-center rounded-full bg-red-500/10 px-2.5 py-0.5 text-xs font-medium text-red-500 border border-red-500/20",children:"Public Read/Write"}):re==="public-read"?e.jsx("span",{className:"inline-flex items-center rounded-full bg-orange-500/10 px-2.5 py-0.5 text-xs font-medium text-orange-500 border border-orange-500/20",children:"Public Read"}):e.jsx("span",{className:"inline-flex items-center rounded-full bg-green-500/10 px-2.5 py-0.5 text-xs font-medium text-green-500 border border-green-500/20",children:"Private"}),O=re=>new Date(re).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),H=async(re,Ae)=>{try{await navigator.clipboard.writeText(re),alert(`${Ae} copied to clipboard!`)}catch(oe){console.error(`Failed to copy ${Ae}:`,oe);const ce=document.createElement("textarea");ce.value=re,ce.style.position="fixed",ce.style.left="-999999px",document.body.appendChild(ce),ce.select();try{document.execCommand("copy"),alert(`${Ae} copied to clipboard!`)}catch{alert(`Failed to copy. ${Ae}: ${re}`)}document.body.removeChild(ce)}};return e.jsxs("div",{className:"flex flex-col h-full bg-[#0f1720]",children:[e.jsx("main",{className:"flex-1 flex flex-col overflow-y-auto relative scroll-smooth",children:e.jsxs("div",{className:"flex flex-col max-w-[1200px] w-full mx-auto p-6 md:p-8 lg:p-12 gap-8",children:[e.jsxs("div",{className:"flex flex-wrap justify-between items-start gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("h1",{className:"text-white tracking-tight text-[32px] font-bold leading-tight",children:"Object Storage Service"}),e.jsx("p",{className:"text-text-secondary text-sm font-normal max-w-xl",children:"Manage S3-compatible buckets, configure access policies, and monitor real-time object storage performance."})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("button",{onClick:async()=>{g(!0);try{await T.invalidateQueries({queryKey:["object-storage-buckets"]}),await T.refetchQueries({queryKey:["object-storage-buckets"]}),await new Promise(re=>setTimeout(re,300)),alert("Buckets refreshed successfully!")}catch(re){console.error("Failed to refresh buckets:",re),alert("Failed to refresh buckets. Please try again.")}finally{g(!1)}},disabled:q||B,className:"flex h-10 items-center justify-center rounded-lg border border-border-dark px-4 text-white text-sm font-medium hover:bg-[#233648] transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:"Refresh buckets list",children:[e.jsx(Cn,{className:`mr-2 ${B?"animate-spin":""}`,size:20}),B?"Refreshing...":"Refresh Buckets"]}),le?e.jsxs("button",{onClick:()=>c(!0),className:"flex h-10 items-center justify-center rounded-lg bg-orange-500 px-4 text-white text-sm font-medium hover:bg-orange-600 transition-colors",children:[e.jsx(vc,{className:"mr-2",size:20}),"Change Dataset"]}):e.jsxs("button",{onClick:()=>c(!0),className:"flex h-10 items-center justify-center rounded-lg bg-primary px-4 text-white text-sm font-medium hover:bg-blue-600 transition-colors",children:[e.jsx(Ks,{className:"mr-2",size:20}),"Setup Object Storage"]}),e.jsxs("button",{className:"flex h-10 items-center justify-center rounded-lg border border-border-dark px-4 text-white text-sm font-medium hover:bg-[#233648] transition-colors",children:[e.jsx(A4,{className:"mr-2",size:20}),"Documentation"]}),e.jsxs("button",{className:"flex h-10 items-center justify-center rounded-lg bg-[#233648] px-4 text-white text-sm font-medium hover:bg-[#2b4055] transition-colors border border-border-dark",children:[e.jsx(vc,{className:"mr-2",size:20}),"Config"]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2 rounded-lg p-5 border border-border-dark bg-[#1c2936]",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-text-secondary text-sm font-medium",children:"Service Status"}),e.jsx(su,{className:"text-[#0bda5b]",size:20})]}),e.jsx("p",{className:"text-white tracking-tight text-2xl font-bold",children:"Running"}),e.jsx("p",{className:"text-text-secondary text-xs",children:"Port 9000 (TLS Enabled)"})]}),e.jsxs("div",{className:"flex flex-col gap-2 rounded-lg p-5 border border-border-dark bg-[#1c2936]",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-text-secondary text-sm font-medium",children:"Total Usage"}),e.jsx(Ul,{className:"text-primary",size:20})]}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("p",{className:"text-white tracking-tight text-2xl font-bold",children:fr($,1)}),e.jsx("p",{className:"text-[#0bda5b] text-sm font-medium",children:"+2.1%"})]}),e.jsx("div",{className:"w-full bg-[#233648] rounded-full h-1.5 mt-1",children:e.jsx("div",{className:"bg-primary h-1.5 rounded-full",style:{width:"45%"}})})]}),e.jsxs("div",{className:"flex flex-col gap-2 rounded-lg p-5 border border-border-dark bg-[#1c2936]",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-text-secondary text-sm font-medium",children:"Object Count"}),e.jsx(_y,{className:"text-blue-400",size:20})]}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsxs("p",{className:"text-white tracking-tight text-2xl font-bold",children:[(X/1e6).toFixed(1),"M"]}),e.jsx("p",{className:"text-[#0bda5b] text-sm font-medium",children:"+0.5%"})]}),e.jsx("p",{className:"text-text-secondary text-xs",children:"Total objects across all buckets"})]}),e.jsxs("div",{className:"flex flex-col gap-2 rounded-lg p-5 border border-border-dark bg-[#1c2936]",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-text-secondary text-sm font-medium",children:"Uptime"}),e.jsx(Ec,{className:"text-green-400",size:20})]}),e.jsx("p",{className:"text-white tracking-tight text-2xl font-bold",children:"99.9%"}),e.jsx("p",{className:"text-text-secondary text-xs",children:"Last 30 days"})]})]}),e.jsx("div",{className:"border-b border-border-dark",children:e.jsxs("div",{className:"flex gap-8 px-2",children:[e.jsxs("button",{onClick:()=>t("buckets"),className:`flex items-center gap-2 border-b-2 pb-3 pt-2 transition-colors ${r==="buckets"?"border-primary text-white":"border-transparent text-text-secondary hover:text-white"}`,children:[e.jsx(c4,{size:20}),e.jsx("span",{className:"text-sm font-bold",children:"Buckets"})]}),e.jsxs("button",{onClick:()=>t("browse"),className:`flex items-center gap-2 border-b-2 pb-3 pt-2 transition-colors ${r==="browse"?"border-primary text-white":"border-transparent text-text-secondary hover:text-white"}`,children:[e.jsx(au,{size:20}),e.jsx("span",{className:"text-sm font-bold",children:"Browse"})]}),e.jsxs("button",{onClick:()=>t("users"),className:`flex items-center gap-2 border-b-2 pb-3 pt-2 transition-colors ${r==="users"?"border-primary text-white":"border-transparent text-text-secondary hover:text-white"}`,children:[e.jsx(Vd,{size:20}),e.jsx("span",{className:"text-sm font-bold",children:"Users & Keys"})]}),e.jsxs("button",{onClick:()=>t("monitoring"),className:`flex items-center gap-2 border-b-2 pb-3 pt-2 transition-colors ${r==="monitoring"?"border-primary text-white":"border-transparent text-text-secondary hover:text-white"}`,children:[e.jsx(Wm,{size:20}),e.jsx("span",{className:"text-sm font-bold",children:"Monitoring"})]}),e.jsxs("button",{onClick:()=>t("settings"),className:`flex items-center gap-2 border-b-2 pb-3 pt-2 transition-colors ${r==="settings"?"border-primary text-white":"border-transparent text-text-secondary hover:text-white"}`,children:[e.jsx(fp,{size:20}),e.jsx("span",{className:"text-sm font-bold",children:"Settings"})]})]})}),r==="browse"&&e.jsx(h_,{S3_ENDPOINT:Z}),r==="buckets"&&e.jsx(e.Fragment,{children:e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 items-start sm:items-center justify-between",children:[e.jsxs("div",{className:"relative flex-1 max-w-md",children:[e.jsx(io,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-text-secondary",size:18}),e.jsx("input",{type:"text",placeholder:"Filter buckets...",value:s,onChange:re=>{n(re.target.value),l(1)},className:"w-full pl-10 pr-4 py-2 bg-[#1c2936] border border-border-dark rounded-lg text-white placeholder-text-secondary focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent"})]}),e.jsxs("button",{onClick:()=>_(!0),className:"flex items-center gap-2 px-4 py-2 bg-primary text-white rounded-lg hover:bg-blue-600 transition-colors font-medium",children:[e.jsx(Ks,{size:18}),"Create Bucket"]})]}),e.jsxs("div",{className:"rounded-lg border border-border-dark bg-[#1c2936] overflow-hidden",children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"bg-[#233648] border-b border-border-dark",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-text-secondary uppercase tracking-wider",children:"Name"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-text-secondary uppercase tracking-wider",children:"Usage"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-text-secondary uppercase tracking-wider",children:"Objects"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-text-secondary uppercase tracking-wider",children:"Access Policy"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-text-secondary uppercase tracking-wider",children:"Created"}),e.jsx("th",{className:"px-6 py-3 text-right text-xs font-medium text-text-secondary uppercase tracking-wider",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-border-dark",children:q?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-6 py-8 text-center text-text-secondary",children:"Loading buckets..."})}):D.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-6 py-8 text-center text-text-secondary",children:s?"No buckets found matching your search.":"No buckets yet. Create your first bucket to get started."})}):D.map(re=>e.jsxs("tr",{className:"hover:bg-[#233648] transition-colors",children:[e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[te(re),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-white font-medium",children:re.name}),e.jsx("span",{className:"text-text-secondary text-xs",children:"standard"})]})]})}),e.jsx("td",{className:"px-6 py-4 text-white",children:fr(re.usage,1)}),e.jsx("td",{className:"px-6 py-4 text-white",children:re.objects}),e.jsx("td",{className:"px-6 py-4",children:J(re.accessPolicy)}),e.jsx("td",{className:"px-6 py-4 text-text-secondary",children:O(re.creation_date)}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsxs("button",{onClick:()=>H(re.name,"Bucket Name"),className:"px-3 py-1.5 text-xs font-medium text-white bg-[#233648] hover:bg-[#2b4055] border border-border-dark rounded-lg transition-colors flex items-center gap-1.5",title:"Copy Bucket Name",children:[e.jsx(so,{size:14}),"Copy Name"]}),e.jsxs("button",{onClick:()=>H(`${Z}/${re.name}`,"Bucket Endpoint"),className:"px-3 py-1.5 text-xs font-medium text-white bg-[#233648] hover:bg-[#2b4055] border border-border-dark rounded-lg transition-colors flex items-center gap-1.5",title:"Copy Bucket Endpoint",children:[e.jsx(d4,{size:14}),"Copy Endpoint"]}),e.jsxs("button",{onClick:()=>M(re.name),disabled:fe.isPending,className:"px-3 py-1.5 text-xs font-medium text-red-400 hover:bg-red-500/10 border border-red-500/20 rounded-lg transition-colors flex items-center gap-1.5 disabled:opacity-50",title:"Delete Bucket",children:[e.jsx(es,{size:14}),fe.isPending?"Deleting...":"Delete"]})]})})]},re.name))})]})}),xe>1&&e.jsxs("div",{className:"px-6 py-4 border-t border-border-dark flex items-center justify-between",children:[e.jsxs("div",{className:"text-sm text-text-secondary",children:["Showing ",(o-1)*V+1," to ",Math.min(o*V,_e.length)," of ",_e.length," buckets"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>l(re=>Math.max(1,re-1)),disabled:o===1,className:"px-3 py-1.5 text-sm text-white bg-[#233648] hover:bg-[#2b4055] border border-border-dark rounded-lg disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Previous"}),e.jsx("button",{onClick:()=>l(re=>Math.min(xe,re+1)),disabled:o===xe,className:"px-3 py-1.5 text-sm text-white bg-[#233648] hover:bg-[#2b4055] border border-border-dark rounded-lg disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Next"})]})]})]})]})}),r==="users"&&e.jsx(c_,{S3_ENDPOINT:Z}),r==="monitoring"&&e.jsxs("div",{className:"bg-[#1c2936] border border-border-dark rounded-lg p-8 text-center",children:[e.jsx(Wm,{className:"mx-auto mb-4 text-text-secondary",size:48}),e.jsx("p",{className:"text-text-secondary text-sm",children:"Monitoring dashboard coming soon"})]}),r==="settings"&&e.jsxs("div",{className:"bg-[#1c2936] border border-border-dark rounded-lg p-8 text-center",children:[e.jsx(vc,{className:"mx-auto mb-4 text-text-secondary",size:48}),e.jsx("p",{className:"text-text-secondary text-sm",children:"Settings configuration coming soon"})]})]})}),j&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-[#1c2936] border border-border-dark rounded-lg p-6 max-w-md w-full mx-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h2",{className:"text-white text-xl font-bold",children:"Create New Bucket"}),e.jsx("button",{onClick:()=>{_(!1),L("")},className:"text-text-secondary hover:text-white transition-colors",children:"✕"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Bucket Name"}),e.jsx("input",{type:"text",value:w,onChange:re=>L(re.target.value),placeholder:"Enter bucket name",className:"w-full px-4 py-2 bg-[#233648] border border-border-dark rounded-lg text-white placeholder-text-secondary focus:outline-none focus:ring-2 focus:ring-primary",onKeyDown:re=>{re.key==="Enter"&&w.trim()&&se.mutate(w.trim())}}),e.jsx("p",{className:"mt-1 text-xs text-text-secondary",children:"Bucket names must be unique and follow S3 naming conventions"})]}),e.jsxs("div",{className:"flex gap-3 justify-end pt-4",children:[e.jsx("button",{onClick:()=>{_(!1),L("")},className:"px-4 py-2 text-white text-sm font-medium rounded-lg border border-border-dark hover:bg-[#233648] transition-colors",children:"Cancel"}),e.jsx("button",{onClick:()=>{w.trim()&&se.mutate(w.trim())},disabled:!w.trim()||se.isPending,className:"px-4 py-2 bg-primary hover:bg-blue-600 text-white text-sm font-medium rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:se.isPending?"Creating...":"Create Bucket"})]})]})]})}),K&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-[#1c2936] border border-border-dark rounded-lg p-6 max-w-md w-full mx-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h2",{className:"text-white text-xl font-bold",children:"Confirm Delete Bucket"}),e.jsx("button",{onClick:()=>M(null),className:"text-text-secondary hover:text-white transition-colors",children:"✕"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"bg-red-500/10 border border-red-500/20 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(_l,{className:"text-red-400 mt-0.5",size:20}),e.jsxs("div",{children:[e.jsx("p",{className:"text-red-400 text-sm font-medium mb-1",children:"Warning"}),e.jsxs("p",{className:"text-red-300 text-xs",children:['This action cannot be undone. All objects within the bucket "',K,'" will be permanently deleted.']})]})]})}),e.jsxs("div",{className:"flex gap-3 justify-end pt-4",children:[e.jsx("button",{onClick:()=>M(null),className:"px-4 py-2 text-white text-sm font-medium rounded-lg border border-border-dark hover:bg-[#233648] transition-colors",children:"Cancel"}),e.jsx("button",{onClick:()=>{fe.mutate(K),M(null)},disabled:fe.isPending,className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white text-sm font-medium rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:fe.isPending?"Deleting...":"Delete Bucket"})]})]})]})}),d&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-[#1c2936] border border-border-dark rounded-lg p-6 max-w-2xl w-full mx-4 max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h2",{className:"text-white text-xl font-bold",children:le?"Change Object Storage Dataset":"Setup Object Storage"}),e.jsx("button",{onClick:()=>c(!1),className:"text-text-secondary hover:text-white transition-colors",children:"✕"})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Select Pool"}),e.jsxs("select",{value:u,onChange:re=>{h(re.target.value),x("")},className:"w-full px-4 py-2 bg-[#233648] border border-border-dark rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-primary",children:[e.jsx("option",{value:"",children:"Select a pool..."}),F.map(re=>e.jsx("option",{value:re.pool_id,children:re.pool_name},re.pool_id))]})]}),u&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Select Dataset"}),e.jsxs("div",{className:"space-y-2 mb-3",children:[e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",checked:!y,onChange:()=>{p(!1),N("")},className:"text-primary"}),e.jsx("span",{className:"text-white text-sm",children:"Use existing dataset"})]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",checked:y,onChange:()=>p(!0),className:"text-primary"}),e.jsx("span",{className:"text-white text-sm",children:"Create new dataset"})]})]}),y?e.jsx("input",{type:"text",value:v,onChange:re=>N(re.target.value),placeholder:"Enter new dataset name",className:"w-full px-4 py-2 bg-[#233648] border border-border-dark rounded-lg text-white placeholder-text-secondary focus:outline-none focus:ring-2 focus:ring-primary"}):e.jsxs("select",{value:m,onChange:re=>x(re.target.value),className:"w-full px-4 py-2 bg-[#233648] border border-border-dark rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-primary",children:[e.jsx("option",{value:"",children:"Select a dataset..."}),F.find(re=>re.pool_id===u)?.datasets.map(re=>e.jsxs("option",{value:re.name,children:[re.name," ",re.mount_point&&`(${re.mount_point})`]},re.id))]})]}),e.jsxs("div",{className:"flex gap-3 justify-end pt-4",children:[e.jsx("button",{onClick:()=>c(!1),className:"px-4 py-2 text-white text-sm font-medium rounded-lg border border-border-dark hover:bg-[#233648] transition-colors",children:"Cancel"}),e.jsx("button",{onClick:()=>{const re=F.find(oe=>oe.pool_id===u);if(!re)return;const Ae=y?v:m;if(!Ae.trim()){alert("Please select or enter a dataset name");return}ae.mutate({poolName:re.pool_name,datasetName:Ae.trim(),createNew:y})},disabled:!u||!y&&!m||y&&!v.trim()||ae.isPending,className:"px-4 py-2 bg-primary hover:bg-blue-600 text-white text-sm font-medium rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:ae.isPending?"Setting up...":le?"Update Configuration":"Setup Object Storage"})]})]})]})})]})}function h_({S3_ENDPOINT:r}){const[t,s]=Ce.useState(null),[n,o]=Ce.useState(""),l=Nr(),{data:d=[]}=dt({queryKey:["object-storage-buckets"],queryFn:Ea.listBuckets,refetchInterval:5e3,staleTime:0}),{data:c=[],isLoading:u}=dt({queryKey:["object-storage-objects",t,n],queryFn:()=>t?Ea.listObjects(t,n||void 0):Promise.resolve([]),enabled:!!t,refetchInterval:5e3,staleTime:0}),h=v=>{o(v)},m=()=>{if(!n){s(null);return}const v=n.split("/").filter(N=>N);v.length>0?(v.pop(),o(v.length>0?v.join("/")+"/":"")):o("")},x=()=>{const v=[{name:t||"",path:""}];if(n){const N=n.split("/").filter(g=>g);let B="";N.forEach(g=>{B+=g+"/",v.push({name:g,path:B})})}return v},y=v=>v?new Date(v).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"}):"-";if(!t)return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsx("h2",{className:"text-white text-xl font-semibold",children:"Select a Bucket to Browse"})}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:d.map(v=>e.jsxs("button",{onClick:()=>s(v.name),className:"flex flex-col gap-3 p-6 rounded-lg border border-border-dark bg-[#1c2936] hover:bg-[#233648] transition-colors text-left",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(au,{className:"text-primary",size:24}),e.jsx("span",{className:"text-white font-medium",children:v.name})]}),v.access_policy==="public-read"||v.access_policy==="public-read-write"?e.jsx(u4,{className:"text-orange-500",size:18}):e.jsx(h4,{className:"text-purple-500",size:18})]}),e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-text-secondary",children:fr(v.size,1)}),e.jsxs("span",{className:"text-text-secondary",children:[v.objects," objects"]})]})]},v.name))}),d.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(au,{className:"mx-auto text-text-secondary mb-4",size:48}),e.jsx("p",{className:"text-text-secondary",children:"No buckets available"})]})]});const p=x();return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("button",{onClick:()=>{s(null),o("")},className:"flex items-center gap-2 px-3 py-1.5 text-sm text-text-secondary hover:text-white transition-colors rounded-lg hover:bg-[#233648]",children:[e.jsx(wc,{size:16}),"Back to Buckets"]}),e.jsx(Ka,{className:"text-text-secondary",size:16}),p.map((v,N)=>e.jsxs("div",{className:"flex items-center gap-2",children:[N>0&&e.jsx(Ka,{className:"text-text-secondary",size:16}),e.jsx("button",{onClick:()=>{o(N===0?"":v.path)},className:`px-3 py-1.5 text-sm rounded-lg transition-colors ${N===p.length-1?"text-white bg-[#233648]":"text-text-secondary hover:text-white hover:bg-[#233648]"}`,children:v.name||"root"})]},N))]}),e.jsxs("button",{onClick:()=>{l.invalidateQueries({queryKey:["object-storage-objects",t,n]})},className:"flex items-center gap-2 px-4 py-2 text-sm text-white bg-[#233648] hover:bg-[#2b4055] border border-border-dark rounded-lg transition-colors",children:[e.jsx(Cn,{size:16}),"Refresh"]})]}),e.jsx("div",{className:"rounded-lg border border-border-dark bg-[#1c2936] overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"bg-[#233648] border-b border-border-dark",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-text-secondary uppercase tracking-wider",children:"Name"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-text-secondary uppercase tracking-wider",children:"Size"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-text-secondary uppercase tracking-wider",children:"Last Modified"}),e.jsx("th",{className:"px-6 py-3 text-right text-xs font-medium text-text-secondary uppercase tracking-wider",children:"Actions"})]})}),e.jsxs("tbody",{className:"divide-y divide-border-dark",children:[n&&e.jsxs("tr",{className:"hover:bg-[#233648] transition-colors",children:[e.jsx("td",{className:"px-6 py-4",children:e.jsxs("button",{onClick:m,className:"flex items-center gap-2 text-white hover:text-primary transition-colors",children:[e.jsx(wc,{size:16}),e.jsx("span",{children:".."})]})}),e.jsx("td",{className:"px-6 py-4 text-text-secondary",children:"-"}),e.jsx("td",{className:"px-6 py-4 text-text-secondary",children:"-"}),e.jsx("td",{className:"px-6 py-4"})]}),u?e.jsx("tr",{children:e.jsx("td",{colSpan:4,className:"px-6 py-8 text-center text-text-secondary",children:"Loading..."})}):c.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:4,className:"px-6 py-8 text-center text-text-secondary",children:n?"This folder is empty":"This bucket is empty"})}):c.map(v=>e.jsxs("tr",{className:"hover:bg-[#233648] transition-colors",children:[e.jsx("td",{className:"px-6 py-4",children:v.is_dir?e.jsxs("button",{onClick:()=>h(v.key),className:"flex items-center gap-2 text-white hover:text-primary transition-colors",children:[e.jsx(c4,{className:"text-primary",size:18}),e.jsx("span",{children:v.name})]}):e.jsxs("div",{className:"flex items-center gap-2 text-white",children:[e.jsx(L6,{className:"text-text-secondary",size:18}),e.jsx("span",{children:v.name})]})}),e.jsx("td",{className:"px-6 py-4 text-text-secondary",children:v.is_dir?"-":fr(v.size,1)}),e.jsx("td",{className:"px-6 py-4 text-text-secondary",children:y(v.last_modified)}),e.jsx("td",{className:"px-6 py-4 text-right",children:!v.is_dir&&e.jsx("div",{className:"flex items-center justify-end gap-2",children:e.jsxs("button",{onClick:()=>{const N=`${r}/${t}/${v.key}`;f_(N,"Object URL")},className:"px-3 py-1.5 text-xs font-medium text-white bg-[#233648] hover:bg-[#2b4055] border border-border-dark rounded-lg transition-colors flex items-center gap-1.5",title:"Copy URL",children:[e.jsx(d4,{size:14}),"Copy URL"]})})})]},v.key))]})]})})})]})}function f_(r,t){navigator.clipboard.writeText(r).then(()=>{alert(`${t} copied to clipboard!`)}).catch(()=>{alert(`Failed to copy. ${t}: ${r}`)})}function m_(){const[r,t]=Ce.useState("snapshots"),[s,n]=Ce.useState(""),[o,l]=Ce.useState(1),[d,c]=Ce.useState(!1),[u,h]=Ce.useState(!1),[m,x]=Ce.useState(!1),[y,p]=Ce.useState(null),[v,N]=Ce.useState({dataset:"",name:"",recursive:!1}),[B,g]=Ce.useState({name:"",dataset:"",snapshot_name_template:"auto-%Y-%m-%d-%H%M",schedule_type:"daily",schedule_config:{time:"00:00"},recursive:!1}),[j,_]=Ce.useState(""),[w,L]=Ce.useState(null),[K,M]=Ce.useState(null),V=10,T=Nr(),[ne,Z]=Ce.useState({name:"",direction:"outbound",source_dataset:"",target_host:"",target_port:22,target_user:"root",target_dataset:"",source_host:"",source_port:22,source_user:"root",local_dataset:"",schedule_type:"daily",schedule_config:{time:"00:00"},compression:"lz4",recursive:!1,incremental:!0,auto_snapshot:!0,encryption:!1,enabled:!0}),[U,q]=Ce.useState(null),{data:F=[]}=dt({queryKey:["replication-pools"],queryFn:sn.listPools}),{data:le=[],isLoading:ae,refetch:se}=dt({queryKey:["snapshots",j],queryFn:()=>$u.listSnapshots(j||void 0),refetchInterval:5e3,staleTime:0}),{data:fe=[],isLoading:ye,refetch:_e}=dt({queryKey:["snapshot-schedules"],queryFn:eh.listSchedules,refetchInterval:5e3,staleTime:0}),{data:xe=[],isLoading:D,refetch:$}=dt({queryKey:["replication-tasks"],queryFn:()=>th.listTasks(),refetchInterval:5e3,staleTime:0}),X=xe.filter(k=>k.direction==="outbound"),te=xe.filter(k=>k.direction==="inbound"),[J,O]=Ce.useState([]),H=async k=>{try{const G=F.find(Ue=>Ue.name===k||Ue.id===k);if(!G||J.find(Ue=>Ue.pool===k||Ue.pool===G.id||Ue.pool===G.name))return;const be=await sn.listDatasets(G.id);O(Ue=>[...Ue.filter(He=>He.pool!==k&&He.pool!==G.id&&He.pool!==G.name),{pool:G.name,datasets:be}])}catch(G){console.error("Failed to fetch datasets:",G)}},re=async()=>{if(F.length!==0)for(const k of F)try{if(J.find(be=>be.pool===k.name||be.pool===k.id))continue;const me=await sn.listDatasets(k.id);O(be=>[...be.filter(Re=>Re.pool!==k.name&&Re.pool!==k.id),{pool:k.name,datasets:me}])}catch(G){console.error(`Failed to fetch datasets for pool ${k.name}:`,G)}};Ce.useEffect(()=>{u&&F.length>0&&re()},[u,F.length]),Ce.useEffect(()=>{m&&F.length>0&&re()},[m,F.length]),Ce.useEffect(()=>{y?g({name:y.name,dataset:y.dataset,snapshot_name_template:y.snapshot_name_template,schedule_type:y.schedule_type,schedule_config:y.schedule_config,recursive:y.recursive,retention_count:y.retention_count,retention_days:y.retention_days}):m||g({name:"",dataset:"",snapshot_name_template:"auto-%Y-%m-%d-%H%M",schedule_type:"daily",schedule_config:{time:"00:00"},recursive:!1})},[y,m]);const Ae=ft({mutationFn:k=>$u.createSnapshot(k),onSuccess:async()=>{h(!1),N({dataset:"",name:"",recursive:!1}),await T.invalidateQueries({queryKey:["snapshots"]}),await se(),alert("Snapshot created successfully!")},onError:k=>{alert(k.response?.data?.error||"Failed to create snapshot")}}),oe=ft({mutationFn:({name:k,recursive:G})=>$u.deleteSnapshot(k,G),onSuccess:()=>{T.invalidateQueries({queryKey:["snapshots"]}),L(null),alert("Snapshot deleted successfully!")},onError:k=>{alert(k.response?.data?.error||"Failed to delete snapshot")}}),ce=ft({mutationFn:({name:k,force:G})=>$u.rollbackSnapshot(k,G),onSuccess:()=>{T.invalidateQueries({queryKey:["snapshots"]}),M(null),alert("Snapshot rollback completed successfully!")},onError:k=>{alert(k.response?.data?.error||"Failed to rollback snapshot")}}),Se=le.filter(k=>k.name.toLowerCase().includes(s.toLowerCase())||k.dataset.toLowerCase().includes(s.toLowerCase())||k.snapshot_name.toLowerCase().includes(s.toLowerCase())),z=Math.ceil(Se.length/V),ie=Se.slice((o-1)*V,o*V),W=le.length,Q=le.reduce((k,G)=>k+G.referenced,0),I=k=>new Date(k).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"});return e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col bg-background-dark",children:[e.jsxs("header",{className:"flex items-center justify-between px-8 py-5 border-b border-[#233648] bg-background-dark shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ba,{to:"/storage",className:"text-text-secondary hover:text-white text-sm font-medium transition-colors",children:"Storage"}),e.jsx(Ka,{className:"text-[#536b85]",size:16}),e.jsx(ba,{to:"/storage",className:"text-text-secondary hover:text-white text-sm font-medium transition-colors",children:"Pools"}),e.jsx(Ka,{className:"text-[#536b85]",size:16}),e.jsx("span",{className:"text-white text-sm font-bold bg-[#1e2936] px-2 py-1 rounded",children:"Data Protection"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("button",{className:"flex items-center justify-center w-8 h-8 rounded-full hover:bg-[#1e2936] text-text-secondary transition-colors relative",children:[e.jsx(_l,{size:20}),e.jsx("span",{className:"absolute top-1.5 right-1.5 w-2 h-2 bg-red-500 rounded-full border border-background-dark"})]}),e.jsx("button",{className:"flex items-center justify-center w-8 h-8 rounded-full hover:bg-[#1e2936] text-text-secondary transition-colors",children:e.jsx(pp,{size:20})})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-8 custom-scrollbar",children:e.jsxs("div",{className:"mx-auto max-w-[1200px] flex flex-col gap-8",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-end justify-between gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("h1",{className:"text-white text-3xl font-extrabold tracking-tight",children:"Snapshots & Replication"}),e.jsx("p",{className:"text-text-secondary text-base font-normal max-w-2xl",children:"Manage local ZFS snapshots and configure remote replication tasks to ensure data redundancy and disaster recovery."})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("button",{className:"px-4 py-2 bg-[#1e2936] hover:bg-[#2a3b4d] text-white text-sm font-bold rounded-lg border border-[#324d67] transition-all flex items-center gap-2",children:[e.jsx(hp,{size:18}),"View Logs"]}),e.jsxs("button",{onClick:()=>{r==="replication"?c(!0):r==="schedules"?(p(null),x(!0)):h(!0)},className:"px-4 py-2 bg-primary hover:bg-blue-600 text-white text-sm font-bold rounded-lg shadow-[0_4px_12px_rgba(19,127,236,0.3)] transition-all flex items-center gap-2",children:[e.jsx(Ks,{size:18}),r==="replication"?"Create Replication":r==="schedules"?"Create Schedule":"Create Snapshot"]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-1 rounded-xl p-5 bg-[#18232e] border border-[#2a3b4d] relative overflow-hidden group",children:[e.jsx("div",{className:"absolute top-0 right-0 p-4 opacity-10 group-hover:opacity-20 transition-opacity",children:e.jsx(Tm,{className:"text-6xl text-primary"})}),e.jsx("p",{className:"text-text-secondary text-sm font-medium uppercase tracking-wider",children:"Total Snapshots"}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx("p",{className:"text-white text-3xl font-bold tracking-tight",children:W.toLocaleString()}),e.jsxs("span",{className:"text-emerald-400 text-sm font-medium mb-1 flex items-center",children:[e.jsx(T6,{size:14,className:"mr-0.5"}),"+12 today"]})]}),e.jsxs("p",{className:"text-[#536b85] text-xs font-medium mt-1",children:[fr(Q,1)," Reclaimable Space"]})]}),e.jsxs("div",{className:"flex flex-col gap-1 rounded-xl p-5 bg-[#18232e] border border-[#2a3b4d] relative overflow-hidden group",children:[e.jsx("div",{className:"absolute top-0 right-0 p-4 opacity-10 group-hover:opacity-20 transition-opacity",children:e.jsx(Cn,{className:"text-6xl text-emerald-500"})}),e.jsx("p",{className:"text-text-secondary text-sm font-medium uppercase tracking-wider",children:"Last Replication"}),e.jsx("div",{className:"flex items-end gap-2",children:e.jsx("p",{className:"text-white text-3xl font-bold tracking-tight",children:"Success"})}),e.jsx("p",{className:"text-[#536b85] text-xs font-medium mt-1",children:"15 mins ago • tank/backup"})]}),e.jsxs("div",{className:"flex flex-col gap-1 rounded-xl p-5 bg-[#18232e] border border-[#2a3b4d] relative overflow-hidden group",children:[e.jsx("div",{className:"absolute top-0 right-0 p-4 opacity-10 group-hover:opacity-20 transition-opacity",children:e.jsx(Ec,{className:"text-6xl text-purple-500"})}),e.jsx("p",{className:"text-text-secondary text-sm font-medium uppercase tracking-wider",children:"Next Scheduled"}),e.jsx("div",{className:"flex items-end gap-2",children:e.jsx("p",{className:"text-white text-3xl font-bold tracking-tight",children:"10:00 PM"})}),e.jsx("p",{className:"text-[#536b85] text-xs font-medium mt-1",children:"Daily Offsite Backup"})]})]}),e.jsxs("div",{className:"flex flex-col bg-[#18232e] border border-[#2a3b4d] rounded-xl overflow-hidden shadow-sm",children:[e.jsxs("div",{className:"flex border-b border-[#2a3b4d] bg-[#151f29]",children:[e.jsxs("button",{onClick:()=>t("snapshots"),className:`px-6 py-4 text-sm font-bold flex items-center gap-2 transition-colors ${r==="snapshots"?"text-white border-b-2 border-primary bg-[#18232e]":"text-text-secondary hover:text-white border-b-2 border-transparent hover:bg-[#18232e]"}`,children:[e.jsx(Tm,{size:20}),"Snapshots"]}),e.jsxs("button",{onClick:()=>t("schedules"),className:`px-6 py-4 text-sm font-bold flex items-center gap-2 transition-colors ${r==="schedules"?"text-white border-b-2 border-primary bg-[#18232e]":"text-text-secondary hover:text-white border-b-2 border-transparent hover:bg-[#18232e]"}`,children:[e.jsx(Ec,{size:20}),"Schedules",fe.length>0&&e.jsx("span",{className:"ml-1 bg-[#2a3b4d] text-white text-[10px] px-1.5 py-0.5 rounded-full",children:fe.length})]}),e.jsxs("button",{onClick:()=>t("replication"),className:`px-6 py-4 text-sm font-bold flex items-center gap-2 transition-colors ${r==="replication"?"text-white border-b-2 border-primary bg-[#18232e]":"text-text-secondary hover:text-white border-b-2 border-transparent hover:bg-[#18232e]"}`,children:[e.jsx(Xx,{size:20}),"Replication Tasks",xe.length>0&&e.jsx("span",{className:"ml-1 bg-[#2a3b4d] text-white text-[10px] px-1.5 py-0.5 rounded-full",children:xe.length})]}),e.jsxs("button",{onClick:()=>t("restore"),className:`px-6 py-4 text-sm font-bold flex items-center gap-2 transition-colors ${r==="restore"?"text-white border-b-2 border-primary bg-[#18232e]":"text-text-secondary hover:text-white border-b-2 border-transparent hover:bg-[#18232e]"}`,children:[e.jsx(Im,{size:20}),"Restore Points"]})]}),e.jsxs("div",{className:"p-4 flex flex-col sm:flex-row gap-4 justify-between items-center border-b border-[#2a3b4d] bg-[#18232e]",children:[e.jsxs("div",{className:"relative w-full sm:w-96 group",children:[e.jsx(io,{className:"absolute left-3 top-2.5 text-[#536b85] group-focus-within:text-primary transition-colors",size:20}),e.jsx("input",{className:"w-full bg-[#111a22] border border-[#2a3b4d] text-white text-sm rounded-lg pl-10 pr-4 py-2.5 focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary transition-all placeholder-[#536b85]",placeholder:"Search snapshot name or dataset...",type:"text",value:s,onChange:k=>n(k.target.value)})]}),e.jsxs("div",{className:"flex gap-3 w-full sm:w-auto",children:[e.jsx("div",{className:"relative group",children:e.jsxs("select",{className:"flex items-center gap-2 px-4 py-2.5 bg-[#111a22] border border-[#2a3b4d] rounded-lg text-sm font-medium text-text-secondary hover:text-white hover:border-[#536b85] transition-all appearance-none cursor-pointer",value:j,onChange:k=>{_(k.target.value),l(1)},children:[e.jsx("option",{value:"",children:"Dataset: All"}),Array.from(new Set(le.map(k=>k.dataset))).map(k=>e.jsx("option",{value:k,children:k},k))]})}),e.jsx("div",{className:"relative group",children:e.jsxs("button",{className:"flex items-center gap-2 px-4 py-2.5 bg-[#111a22] border border-[#2a3b4d] rounded-lg text-sm font-medium text-text-secondary hover:text-white hover:border-[#536b85] transition-all",children:[e.jsx(l4,{size:18}),"Date Range"]})})]})]}),r==="snapshots"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left border-collapse",children:[e.jsx("thead",{className:"bg-[#151f29] text-text-secondary",children:e.jsxs("tr",{children:[e.jsx("th",{className:"p-4 border-b border-[#2a3b4d] w-[50px]",children:e.jsx("input",{className:"w-4 h-4 rounded border-[#324d67] bg-[#111a22] text-primary focus:ring-offset-[#111a22]",type:"checkbox"})}),e.jsx("th",{className:"p-4 border-b border-[#2a3b4d] text-xs font-bold uppercase tracking-wider",children:"Snapshot Name"}),e.jsx("th",{className:"p-4 border-b border-[#2a3b4d] text-xs font-bold uppercase tracking-wider",children:"Dataset"}),e.jsx("th",{className:"p-4 border-b border-[#2a3b4d] text-xs font-bold uppercase tracking-wider",children:"Created"}),e.jsx("th",{className:"p-4 border-b border-[#2a3b4d] text-xs font-bold uppercase tracking-wider",children:"Referenced"}),e.jsx("th",{className:"p-4 border-b border-[#2a3b4d] text-xs font-bold uppercase tracking-wider text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"text-sm",children:ae?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"p-8 text-center text-text-secondary",children:"Loading snapshots..."})}):ie.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"p-8 text-center text-text-secondary",children:s?"No snapshots found matching your search.":"No snapshots yet. Create your first snapshot to get started."})}):ie.map(k=>e.jsxs("tr",{className:"group hover:bg-[#1e2936] transition-colors border-b border-[#2a3b4d]",children:[e.jsx("td",{className:"p-4",children:e.jsx("input",{className:"w-4 h-4 rounded border-[#324d67] bg-[#111a22] text-primary focus:ring-offset-[#111a22]",type:"checkbox"})}),e.jsx("td",{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Tm,{className:"text-[#536b85]",size:20}),e.jsx("span",{className:"text-white font-medium",children:k.snapshot_name}),k.is_latest&&e.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-bold bg-primary/20 text-primary border border-primary/20",children:"LATEST"})]})}),e.jsx("td",{className:"p-4",children:e.jsx("span",{className:"text-text-secondary",children:k.dataset})}),e.jsx("td",{className:"p-4",children:e.jsx("span",{className:"text-text-secondary",children:I(k.created)})}),e.jsx("td",{className:"p-4",children:e.jsx("span",{className:"text-white font-mono",children:fr(k.referenced)})}),e.jsx("td",{className:"p-4 text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx("button",{onClick:()=>M(k.name),className:"p-1.5 hover:bg-[#2a3b4d] rounded text-text-secondary hover:text-white",title:"Rollback",children:e.jsx(Im,{size:20})}),e.jsx("button",{onClick:()=>{const G=prompt(`Enter clone dataset name for ${k.snapshot_name}:`);G&&$u.cloneSnapshot(k.name,{clone_name:G}).then(()=>{T.invalidateQueries({queryKey:["snapshots"]}),alert("Snapshot cloned successfully!")}).catch(me=>{alert(me.response?.data?.error||"Failed to clone snapshot")})},className:"p-1.5 hover:bg-[#2a3b4d] rounded text-text-secondary hover:text-white",title:"Clone",children:e.jsx(so,{size:20})}),e.jsx("button",{onClick:()=>L(k.name),className:"p-1.5 hover:bg-red-500/20 rounded text-text-secondary hover:text-red-500",title:"Delete",children:e.jsx(es,{size:20})})]})})]},k.id))})]})}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-[#18232e]",children:[e.jsxs("p",{className:"text-text-secondary text-sm",children:["Showing ",e.jsxs("span",{className:"text-white font-bold",children:["1-",ie.length]})," of"," ",e.jsx("span",{className:"text-white font-bold",children:Se.length})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>l(k=>Math.max(1,k-1)),disabled:o===1,className:"px-3 py-1 text-sm rounded border border-[#2a3b4d] text-text-secondary hover:bg-[#2a3b4d] hover:text-white disabled:opacity-50",children:"Previous"}),Array.from({length:Math.min(3,z)},(k,G)=>G+1).map(k=>e.jsx("button",{onClick:()=>l(k),className:`px-3 py-1 text-sm rounded border border-[#2a3b4d] ${o===k?"text-white bg-[#2a3b4d]":"text-text-secondary hover:bg-[#2a3b4d] hover:text-white"}`,children:k},k)),z>3&&e.jsx("span",{className:"text-text-secondary",children:"..."}),e.jsx("button",{onClick:()=>l(k=>Math.min(z,k+1)),disabled:o===z,className:"px-3 py-1 text-sm rounded border border-[#2a3b4d] text-text-secondary hover:bg-[#2a3b4d] hover:text-white disabled:opacity-50",children:"Next"})]})]})]}),r==="schedules"&&e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex justify-between items-center mb-4",children:[e.jsx("h3",{className:"text-white text-lg font-bold",children:"Snapshot Schedules"}),e.jsxs("button",{onClick:()=>{p(null),x(!0)},className:"flex items-center gap-2 px-4 py-2 bg-primary hover:bg-blue-600 text-white text-sm font-bold rounded-lg transition-colors",children:[e.jsx(Ks,{size:18}),"Create Schedule"]})]}),ye?e.jsx("div",{className:"text-center py-8 text-text-secondary",children:"Loading schedules..."}):fe.length===0?e.jsx("div",{className:"text-center py-8 text-text-secondary",children:"No schedules configured. Create your first schedule to automate snapshot creation."}):e.jsx("div",{className:"space-y-3",children:fe.map(k=>e.jsxs("div",{className:"flex items-center gap-4 bg-[#111a22] p-4 rounded-lg border border-[#2a3b4d] hover:bg-[#1e2936] transition-colors",children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${k.enabled?"bg-emerald-500":"bg-gray-500"}`}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-white text-sm font-medium",children:k.name}),e.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-bold bg-[#2a3b4d] text-text-secondary",children:k.schedule_type})]}),e.jsxs("p",{className:"text-[#536b85] text-xs mt-1",children:["Dataset: ",k.dataset," • Template: ",k.snapshot_name_template]}),k.next_run_at&&e.jsxs("p",{className:"text-[#536b85] text-xs mt-1",children:["Next run: ",new Date(k.next_run_at).toLocaleString()]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:async()=>{try{await eh.toggleSchedule(k.id,!k.enabled),await T.invalidateQueries({queryKey:["snapshot-schedules"]}),await _e(),alert(`Schedule ${k.enabled?"disabled":"enabled"} successfully`)}catch(G){alert(G.response?.data?.error||"Failed to toggle schedule")}},className:`px-3 py-1 text-xs font-medium rounded transition-colors ${k.enabled?"bg-emerald-500/20 text-emerald-400 hover:bg-emerald-500/30":"bg-gray-500/20 text-gray-400 hover:bg-gray-500/30"}`,children:k.enabled?"Enabled":"Disabled"}),e.jsxs("button",{onClick:()=>{p(k),x(!0)},className:"flex items-center gap-1.5 px-3 py-1.5 hover:bg-[#2a3b4d] rounded text-text-secondary hover:text-white transition-colors border border-[#2a3b4d] hover:border-primary",title:"Edit Schedule",children:[e.jsx(Wd,{size:16}),e.jsx("span",{className:"text-xs font-medium",children:"Edit"})]}),e.jsx("button",{onClick:async()=>{if(confirm(`Delete schedule "${k.name}"?`))try{await eh.deleteSchedule(k.id),await T.invalidateQueries({queryKey:["snapshot-schedules"]}),await _e(),alert("Schedule deleted successfully")}catch(G){alert(G.response?.data?.error||"Failed to delete schedule")}},className:"p-1.5 hover:bg-red-500/20 rounded text-text-secondary hover:text-red-500 transition-colors",title:"Delete Schedule",children:e.jsx(es,{size:18})})]})]},k.id))})]}),r==="replication"&&e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h3",{className:"text-white text-lg font-bold",children:"Replication Tasks"}),e.jsxs("button",{onClick:()=>{q(null),Z({name:"",direction:"outbound",source_dataset:"",target_host:"",target_port:22,target_user:"root",target_dataset:"",source_host:"",source_port:22,source_user:"root",local_dataset:"",schedule_type:"daily",schedule_config:{time:"00:00"},compression:"lz4",recursive:!1,incremental:!0,auto_snapshot:!0,encryption:!1,enabled:!0}),c(!0)},className:"flex items-center gap-2 px-4 py-2 bg-primary hover:bg-blue-600 text-white text-sm font-bold rounded-lg transition-colors",children:[e.jsx(Ks,{size:18}),"Create Replication"]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(Xx,{size:20,className:"text-primary"}),e.jsx("h4",{className:"text-white text-base font-bold",children:"Outbound Replication"}),e.jsx("span",{className:"text-text-secondary text-sm",children:"(Sending to remote)"})]}),D?e.jsx("div",{className:"text-center py-8 text-text-secondary",children:"Loading replication tasks..."}):X.length===0?e.jsx("div",{className:"text-center py-8 text-text-secondary bg-[#111a22] rounded-lg border border-[#2a3b4d]",children:"No outbound replication tasks configured."}):e.jsx("div",{className:"space-y-3",children:X.map(k=>e.jsxs("div",{className:"flex items-center gap-4 bg-[#111a22] p-4 rounded-lg border border-[#2a3b4d] hover:bg-[#1e2936] transition-colors",children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${k.status==="running"?"bg-primary animate-pulse":k.status==="failed"?"bg-red-500":"bg-emerald-500"}`}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-white text-sm font-medium",children:k.name}),!k.enabled&&e.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-bold bg-gray-500/20 text-gray-400",children:"Disabled"})]}),e.jsxs("p",{className:"text-[#536b85] text-xs mt-1",children:["Source: ",k.source_dataset," → Target: ",k.target_host,":",k.target_port," (",k.target_dataset,")"]}),k.last_run_at&&e.jsxs("p",{className:"text-[#536b85] text-xs mt-1",children:["Last run: ",new Date(k.last_run_at).toLocaleString(),k.last_run_status&&e.jsxs("span",{className:`ml-2 ${k.last_run_status==="success"?"text-emerald-400":"text-red-400"}`,children:["(",k.last_run_status,")"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{q(k),Z({name:k.name,direction:k.direction,source_dataset:k.source_dataset,target_host:k.target_host,target_port:k.target_port,target_user:k.target_user,target_dataset:k.target_dataset,source_host:k.source_host,source_port:k.source_port,source_user:k.source_user,local_dataset:k.local_dataset,schedule_type:k.schedule_type,schedule_config:k.schedule_config,compression:k.compression,recursive:k.recursive,incremental:k.incremental,auto_snapshot:k.auto_snapshot,encryption:k.encryption,enabled:k.enabled}),c(!0)},className:"p-1.5 hover:bg-[#2a3b4d] rounded text-text-secondary hover:text-white transition-colors",title:"Edit",children:e.jsx(Wd,{size:18})}),e.jsx("button",{onClick:async()=>{if(confirm(`Delete replication task "${k.name}"?`))try{await th.deleteTask(k.id),await T.invalidateQueries({queryKey:["replication-tasks"]}),await $(),alert("Replication task deleted successfully")}catch(G){alert(G.response?.data?.error||"Failed to delete replication task")}},className:"p-1.5 hover:bg-red-500/20 rounded text-text-secondary hover:text-red-500 transition-colors",title:"Delete",children:e.jsx(es,{size:18})})]})]},k.id))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(Xx,{size:20,className:"text-emerald-500"}),e.jsx("h4",{className:"text-white text-base font-bold",children:"Inbound Replication"}),e.jsx("span",{className:"text-text-secondary text-sm",children:"(Receiving from remote)"})]}),D?e.jsx("div",{className:"text-center py-8 text-text-secondary",children:"Loading replication tasks..."}):te.length===0?e.jsx("div",{className:"text-center py-8 text-text-secondary bg-[#111a22] rounded-lg border border-[#2a3b4d]",children:"No inbound replication tasks configured."}):e.jsx("div",{className:"space-y-3",children:te.map(k=>e.jsxs("div",{className:"flex items-center gap-4 bg-[#111a22] p-4 rounded-lg border border-[#2a3b4d] hover:bg-[#1e2936] transition-colors",children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${k.status==="running"?"bg-primary animate-pulse":k.status==="failed"?"bg-red-500":"bg-emerald-500"}`}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-white text-sm font-medium",children:k.name}),!k.enabled&&e.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-bold bg-gray-500/20 text-gray-400",children:"Disabled"})]}),e.jsxs("p",{className:"text-[#536b85] text-xs mt-1",children:["Source: ",k.source_host,":",k.source_port," (",k.source_dataset,") → Local: ",k.local_dataset]}),k.last_run_at&&e.jsxs("p",{className:"text-[#536b85] text-xs mt-1",children:["Last run: ",new Date(k.last_run_at).toLocaleString(),k.last_run_status&&e.jsxs("span",{className:`ml-2 ${k.last_run_status==="success"?"text-emerald-400":"text-red-400"}`,children:["(",k.last_run_status,")"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{q(k),Z({name:k.name,direction:k.direction,source_dataset:k.source_dataset,target_host:k.target_host,target_port:k.target_port,target_user:k.target_user,target_dataset:k.target_dataset,source_host:k.source_host,source_port:k.source_port,source_user:k.source_user,local_dataset:k.local_dataset,schedule_type:k.schedule_type,schedule_config:k.schedule_config,compression:k.compression,recursive:k.recursive,incremental:k.incremental,auto_snapshot:k.auto_snapshot,encryption:k.encryption,enabled:k.enabled}),c(!0)},className:"p-1.5 hover:bg-[#2a3b4d] rounded text-text-secondary hover:text-white transition-colors",title:"Edit",children:e.jsx(Wd,{size:18})}),e.jsx("button",{onClick:async()=>{if(confirm(`Delete replication task "${k.name}"?`))try{await th.deleteTask(k.id),await T.invalidateQueries({queryKey:["replication-tasks"]}),await $(),alert("Replication task deleted successfully")}catch(G){alert(G.response?.data?.error||"Failed to delete replication task")}},className:"p-1.5 hover:bg-red-500/20 rounded text-text-secondary hover:text-red-500 transition-colors",title:"Delete",children:e.jsx(es,{size:18})})]})]},k.id))})]})]}),r==="restore"&&e.jsxs("div",{className:"p-8 text-center",children:[e.jsx(Im,{className:"mx-auto mb-4 text-text-secondary",size:48}),e.jsx("p",{className:"text-text-secondary text-sm",children:"Restore points coming soon"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"bg-[#18232e] border border-[#2a3b4d] rounded-xl p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-white font-bold text-lg",children:"Replication Status"}),e.jsx("a",{className:"text-primary text-sm font-bold hover:underline",href:"#",children:"Manage All"})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[xe.slice(0,3).map(k=>e.jsxs("div",{className:"flex items-center gap-4 bg-[#111a22] p-3 rounded-lg border border-[#2a3b4d]",children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${k.status==="running"?"bg-primary animate-pulse":k.status==="failed"?"bg-red-500":"bg-emerald-500"}`}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-white text-sm font-medium",children:k.name}),e.jsx("p",{className:"text-[#536b85] text-xs",children:k.direction==="outbound"?`Target: ${k.target_host}:${k.target_port}`:`Source: ${k.source_host}:${k.source_port}`})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:`text-sm ${k.status==="running"?"text-primary font-bold":"text-text-secondary"}`,children:k.status==="running"?"Running":k.status}),k.last_run_at&&e.jsx("p",{className:"text-[#536b85] text-xs",children:new Date(k.last_run_at).toLocaleString()})]})]},k.id)),xe.length===0&&e.jsx("p",{className:"text-text-secondary text-sm text-center py-4",children:"No replication tasks"})]})]}),e.jsxs("div",{className:"bg-[#18232e] border border-[#2a3b4d] rounded-xl p-6 flex flex-col justify-center items-center text-center",children:[e.jsx("div",{className:"w-12 h-12 bg-primary/10 rounded-full flex items-center justify-center mb-3",children:e.jsx(_l,{className:"text-primary text-2xl"})}),e.jsx("h3",{className:"text-white font-bold text-lg",children:"Snapshot Retention"}),e.jsx("p",{className:"text-text-secondary text-sm mt-1 mb-4",children:"You have 14 snapshots marked for expiration in the next 24 hours."}),e.jsx("button",{className:"text-white bg-[#2a3b4d] hover:bg-[#324d67] px-4 py-2 rounded-lg text-sm font-medium transition-colors",children:"Review Expiration Policy"})]})]})]})}),d&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>c(!1),children:e.jsxs("div",{className:"bg-[#18232e] rounded-xl border border-[#2a3b4d] max-w-2xl w-full max-h-[90vh] overflow-y-auto",onClick:k=>k.stopPropagation(),children:[e.jsxs("div",{className:"p-6 border-b border-[#2a3b4d] flex justify-between items-center",children:[e.jsx("h3",{className:"text-lg font-bold text-white",children:U?"Edit Replication Task":"Create Replication Task"}),e.jsx("button",{onClick:()=>{c(!1),q(null),Z({name:"",direction:"outbound",source_dataset:"",target_host:"",target_port:22,target_user:"root",target_dataset:"",source_host:"",source_port:22,source_user:"root",local_dataset:"",schedule_type:"daily",schedule_config:{time:"00:00"},compression:"lz4",recursive:!1,incremental:!0,auto_snapshot:!0,encryption:!1,enabled:!0})},className:"text-text-secondary hover:text-white",children:e.jsx(Zs,{size:20})})]}),e.jsxs("div",{className:"p-6 flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-semibold text-white",children:"Task Name"}),e.jsx("input",{className:"w-full bg-[#111a22] border border-[#2a3b4d] rounded-lg px-3 py-2 text-sm text-white focus:border-primary focus:ring-1 focus:ring-primary outline-none",type:"text",placeholder:"Daily Offsite Backup",value:ne.name,onChange:k=>Z({...ne,name:k.target.value})})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-semibold text-white",children:"Direction"}),e.jsxs("select",{className:"w-full bg-[#111a22] border border-[#2a3b4d] rounded-lg px-3 py-2 text-sm text-white focus:border-primary focus:ring-1 focus:ring-primary outline-none appearance-none",value:ne.direction,onChange:k=>Z({...ne,direction:k.target.value}),children:[e.jsx("option",{value:"outbound",children:"Outbound (Sending to remote)"}),e.jsx("option",{value:"inbound",children:"Inbound (Receiving from remote)"})]})]}),ne.direction==="outbound"&&e.jsx(e.Fragment,{children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-semibold text-white",children:"Source Dataset"}),e.jsxs("select",{className:"w-full bg-[#111a22] border border-[#2a3b4d] rounded-lg px-3 py-2 text-sm text-white focus:border-primary focus:ring-1 focus:ring-primary outline-none appearance-none",value:ne.source_dataset||"",onChange:k=>{Z({...ne,source_dataset:k.target.value||void 0});const G=k.target.value.split("/")[0];G&&H(G)},children:[e.jsx("option",{value:"",children:"Select a dataset"}),F.map(k=>e.jsx("optgroup",{label:k.name,children:J.find(G=>G.pool===k.name)?.datasets.filter(G=>G.type==="filesystem").map(G=>e.jsx("option",{value:G.name,children:G.name},G.id))},k.id))]})]})}),ne.direction==="inbound"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-semibold text-white",children:"Source Host"}),e.jsx("input",{className:"w-full bg-[#111a22] border border-[#2a3b4d] rounded-lg px-3 py-2 text-sm text-white focus:border-primary focus:ring-1 focus:ring-primary outline-none font-mono",type:"text",placeholder:"192.168.20.5",value:ne.source_host||"",onChange:k=>Z({...ne,source_host:k.target.value||void 0})})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-semibold text-white",children:"Source Dataset (on remote)"}),e.jsx("input",{className:"w-full bg-[#111a22] border border-[#2a3b4d] rounded-lg px-3 py-2 text-sm text-white focus:border-primary focus:ring-1 focus:ring-primary outline-none font-mono",type:"text",placeholder:"tank/backup",value:ne.source_dataset||"",onChange:k=>Z({...ne,source_dataset:k.target.value||void 0})})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-semibold text-white",children:"Local Dataset"}),e.jsxs("select",{className:"w-full bg-[#111a22] border border-[#2a3b4d] rounded-lg px-3 py-2 text-sm text-white focus:border-primary focus:ring-1 focus:ring-primary outline-none appearance-none",value:ne.local_dataset||"",onChange:k=>{Z({...ne,local_dataset:k.target.value||void 0});const G=k.target.value.split("/")[0];G&&H(G)},children:[e.jsx("option",{value:"",children:"Select a dataset"}),F.map(k=>e.jsx("optgroup",{label:k.name,children:J.find(G=>G.pool===k.name)?.datasets.filter(G=>G.type==="filesystem").map(G=>e.jsx("option",{value:G.name,children:G.name},G.id))},k.id))]})]})]}),ne.direction==="outbound"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-semibold text-white",children:"Target Host"}),e.jsx("input",{className:"w-full bg-[#111a22] border border-[#2a3b4d] rounded-lg px-3 py-2 text-sm text-white focus:border-primary focus:ring-1 focus:ring-primary outline-none font-mono",type:"text",placeholder:"192.168.20.5",value:ne.target_host||"",onChange:k=>Z({...ne,target_host:k.target.value||void 0})})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-semibold text-white",children:"SSH Port"}),e.jsx("input",{className:"w-full bg-[#111a22] border border-[#2a3b4d] rounded-lg px-3 py-2 text-sm text-white focus:border-primary focus:ring-1 focus:ring-primary outline-none font-mono",type:"number",placeholder:"22",value:ne.target_port||22,onChange:k=>Z({...ne,target_port:parseInt(k.target.value)||22})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-semibold text-white",children:"Target User"}),e.jsx("input",{className:"w-full bg-[#111a22] border border-[#2a3b4d] rounded-lg px-3 py-2 text-sm text-white focus:border-primary focus:ring-1 focus:ring-primary outline-none",type:"text",placeholder:"root",value:ne.target_user||"root",onChange:k=>Z({...ne,target_user:k.target.value||void 0})})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-semibold text-white",children:"Target Dataset"}),e.jsx("input",{className:"w-full bg-[#111a22] border border-[#2a3b4d] rounded-lg px-3 py-2 text-sm text-white focus:border-primary focus:ring-1 focus:ring-primary outline-none font-mono",type:"text",placeholder:"tank/backup",value:ne.target_dataset||"",onChange:k=>Z({...ne,target_dataset:k.target.value||void 0})})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-semibold text-white",children:"Schedule"}),e.jsxs("select",{className:"w-full bg-[#111a22] border border-[#2a3b4d] rounded-lg px-3 py-2 text-sm text-white focus:border-primary focus:ring-1 focus:ring-primary outline-none appearance-none",value:ne.schedule_type||"daily",onChange:k=>Z({...ne,schedule_type:k.target.value||void 0}),children:[e.jsx("option",{value:"hourly",children:"Hourly"}),e.jsx("option",{value:"daily",children:"Daily"}),e.jsx("option",{value:"weekly",children:"Weekly"}),e.jsx("option",{value:"monthly",children:"Monthly"}),e.jsx("option",{value:"cron",children:"Custom (Cron)"})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-semibold text-white",children:"Time"}),e.jsx("input",{className:"w-full bg-[#111a22] border border-[#2a3b4d] rounded-lg px-3 py-2 text-sm text-white focus:border-primary focus:ring-1 focus:ring-primary outline-none font-mono",type:"time",value:ne.schedule_config?.time||"00:00",onChange:k=>Z({...ne,schedule_config:{...ne.schedule_config,time:k.target.value}})})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-semibold text-white",children:"Compression"}),e.jsxs("select",{className:"w-full bg-[#111a22] border border-[#2a3b4d] rounded-lg px-3 py-2 text-sm text-white focus:border-primary focus:ring-1 focus:ring-primary outline-none appearance-none",value:ne.compression,onChange:k=>Z({...ne,compression:k.target.value}),children:[e.jsx("option",{value:"off",children:"Off"}),e.jsx("option",{value:"lz4",children:"LZ4 (Fast)"}),e.jsx("option",{value:"gzip",children:"GZIP"}),e.jsx("option",{value:"zstd",children:"ZSTD"})]})]}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:ne.recursive,onChange:k=>Z({...ne,recursive:k.target.checked}),className:"rounded border-[#324d67] bg-[#111a22] text-primary focus:ring-primary h-4 w-4"}),e.jsx("span",{className:"text-sm text-white",children:"Recursive (include child datasets)"})]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:ne.auto_snapshot||!1,onChange:k=>Z({...ne,auto_snapshot:k.target.checked}),className:"rounded border-[#324d67] bg-[#111a22] text-primary focus:ring-primary h-4 w-4"}),e.jsx("span",{className:"text-sm text-white",children:"Auto-create snapshot before replication"})]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:ne.encryption,onChange:k=>Z({...ne,encryption:k.target.checked}),className:"rounded border-[#324d67] bg-[#111a22] text-primary focus:ring-primary h-4 w-4"}),e.jsx("span",{className:"text-sm text-white",children:"Enable encryption (SSH tunnel)"})]})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t border-[#2a3b4d]",children:[e.jsx(ct,{onClick:()=>c(!1),variant:"outline",className:"px-4 h-10 border-[#2a3b4d] text-white hover:bg-[#2a3b4d]",children:"Cancel"}),e.jsxs(ct,{onClick:async()=>{try{U?(await th.updateTask(U.id,ne),alert("Replication task updated successfully!")):(await th.createTask(ne),alert("Replication task created successfully!")),await T.invalidateQueries({queryKey:["replication-tasks"]}),await $(),c(!1),q(null),Z({name:"",direction:"outbound",source_dataset:"",target_host:"",target_port:22,target_user:"root",target_dataset:"",source_host:"",source_port:22,source_user:"root",local_dataset:"",schedule_type:"daily",schedule_config:{time:"00:00"},compression:"lz4",recursive:!1,incremental:!0,auto_snapshot:!0,encryption:!1,enabled:!0})}catch(k){alert(k.response?.data?.error||"Failed to save replication task")}},className:"px-4 h-10 bg-primary hover:bg-blue-600",children:[e.jsx(up,{size:18,className:"mr-2"}),U?"Update Replication":"Create Replication"]})]})]})]})}),u&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>{h(!1),N({dataset:"",name:"",recursive:!1})},children:e.jsxs("div",{className:"bg-[#18232e] rounded-xl border border-[#2a3b4d] max-w-lg w-full",onClick:k=>k.stopPropagation(),children:[e.jsxs("div",{className:"p-6 border-b border-[#2a3b4d] flex justify-between items-center",children:[e.jsx("h3",{className:"text-lg font-bold text-white",children:"Create Snapshot"}),e.jsx("button",{onClick:()=>{h(!1),N({dataset:"",name:"",recursive:!1})},className:"text-text-secondary hover:text-white",children:e.jsx(Zs,{size:20})})]}),e.jsxs("div",{className:"p-6 flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-semibold text-white",children:"Dataset"}),e.jsxs("select",{className:"w-full bg-[#111a22] border border-[#2a3b4d] rounded-lg px-3 py-2 text-sm text-white focus:border-primary focus:ring-1 focus:ring-primary outline-none",value:v.dataset,onChange:k=>{N({...v,dataset:k.target.value})},onFocus:()=>{J.length===0&&re()},children:[e.jsx("option",{value:"",children:"Select a dataset"}),F.map(k=>{const G=J.find(me=>me.pool===k.name||me.pool===k.id);return!G||G.datasets.length===0?e.jsx("optgroup",{label:k.name,children:e.jsx("option",{value:"",disabled:!0,children:"Loading datasets..."})},k.id):e.jsx("optgroup",{label:k.name,children:G.datasets.filter(me=>me.type==="filesystem").map(me=>e.jsx("option",{value:me.name,children:me.name},me.id))},k.id)})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-semibold text-white",children:"Snapshot Name"}),e.jsx("input",{className:"w-full bg-[#111a22] border border-[#2a3b4d] rounded-lg px-3 py-2 text-sm text-white focus:border-primary focus:ring-1 focus:ring-primary outline-none",type:"text",placeholder:"manual-backup-2024",value:v.name,onChange:k=>N({...v,name:k.target.value})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",className:"w-4 h-4 rounded border-[#324d67] bg-[#111a22] text-primary",checked:v.recursive,onChange:k=>N({...v,recursive:k.target.checked})}),e.jsx("label",{className:"text-sm text-white",children:"Recursive (include child datasets)"})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[e.jsx(ct,{onClick:()=>{h(!1),N({dataset:"",name:"",recursive:!1})},variant:"outline",className:"px-4 h-10 border-[#2a3b4d] text-white hover:bg-[#2a3b4d]",children:"Cancel"}),e.jsx(ct,{onClick:()=>{if(!v.dataset||!v.name){alert("Please fill in all required fields");return}Ae.mutate({dataset:v.dataset,name:v.name,recursive:v.recursive})},disabled:Ae.isPending||!v.dataset||!v.name,className:"px-4 h-10 bg-primary hover:bg-blue-600 disabled:opacity-50",children:Ae.isPending?"Creating...":"Create Snapshot"})]})]})]})}),w&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-[#18232e] border border-[#2a3b4d] rounded-lg p-6 max-w-md w-full mx-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h2",{className:"text-white text-xl font-bold",children:"Confirm Delete Snapshot"}),e.jsx("button",{onClick:()=>L(null),className:"text-text-secondary hover:text-white transition-colors",children:"✕"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"bg-red-500/10 border border-red-500/20 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(_l,{className:"text-red-400 mt-0.5",size:20}),e.jsxs("div",{children:[e.jsx("p",{className:"text-red-400 text-sm font-medium mb-1",children:"Warning"}),e.jsxs("p",{className:"text-red-300 text-xs",children:['This action cannot be undone. Snapshot "',w,'" will be permanently deleted.']})]})]})}),e.jsxs("div",{className:"flex gap-3 justify-end pt-4",children:[e.jsx("button",{onClick:()=>L(null),className:"px-4 py-2 text-white text-sm font-medium rounded-lg border border-[#2a3b4d] hover:bg-[#111a22] transition-colors",children:"Cancel"}),e.jsx("button",{onClick:()=>{oe.mutate({name:w,recursive:!1})},disabled:oe.isPending,className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white text-sm font-medium rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:oe.isPending?"Deleting...":"Delete Snapshot"})]})]})]})}),K&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-[#18232e] border border-[#2a3b4d] rounded-lg p-6 max-w-md w-full mx-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h2",{className:"text-white text-xl font-bold",children:"Confirm Rollback to Snapshot"}),e.jsx("button",{onClick:()=>M(null),className:"text-text-secondary hover:text-white transition-colors",children:"✕"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"bg-orange-500/10 border border-orange-500/20 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(_l,{className:"text-orange-400 mt-0.5",size:20}),e.jsxs("div",{children:[e.jsx("p",{className:"text-orange-400 text-sm font-medium mb-1",children:"Warning"}),e.jsxs("p",{className:"text-orange-300 text-xs",children:['Rolling back to snapshot "',K,'" will destroy all changes made after this snapshot was created. This action cannot be undone.']})]})]})}),e.jsxs("div",{className:"flex gap-3 justify-end pt-4",children:[e.jsx("button",{onClick:()=>M(null),className:"px-4 py-2 text-white text-sm font-medium rounded-lg border border-[#2a3b4d] hover:bg-[#111a22] transition-colors",children:"Cancel"}),e.jsx("button",{onClick:()=>{ce.mutate({name:K,force:!1})},disabled:ce.isPending,className:"px-4 py-2 bg-orange-600 hover:bg-orange-700 text-white text-sm font-medium rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:ce.isPending?"Rolling back...":"Rollback to Snapshot"})]})]})]})}),m&&e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-[#18232e] border border-[#2a3b4d] rounded-xl shadow-xl w-full max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx("div",{className:"p-6 border-b border-[#2a3b4d]",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-white text-xl font-bold",children:y?"Edit Schedule":"Create Snapshot Schedule"}),e.jsx("button",{onClick:()=>{x(!1),p(null),g({name:"",dataset:"",snapshot_name_template:"auto-%Y-%m-%d-%H%M",schedule_type:"daily",schedule_config:{time:"00:00"},recursive:!1})},className:"text-text-secondary hover:text-white transition-colors",children:e.jsx(Zs,{size:24})})]})}),e.jsxs("div",{className:"p-6 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-semibold text-white mb-2 block",children:"Schedule Name"}),e.jsx("input",{type:"text",value:B.name,onChange:k=>g({...B,name:k.target.value}),placeholder:"e.g., Daily Backup",className:"w-full px-4 py-2 bg-[#111a22] border border-[#2a3b4d] rounded-lg text-white placeholder-text-secondary focus:outline-none focus:border-primary"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-semibold text-white mb-2 block",children:"Dataset"}),e.jsxs("select",{value:B.dataset,onChange:k=>g({...B,dataset:k.target.value}),className:"w-full px-4 py-2 bg-[#111a22] border border-[#2a3b4d] rounded-lg text-white focus:outline-none focus:border-primary",children:[e.jsx("option",{value:"",children:"Select dataset..."}),J.flatMap(k=>k.datasets.map(G=>e.jsx("option",{value:G.name,children:G.name},G.name)))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-semibold text-white mb-2 block",children:"Snapshot Name Template"}),e.jsx("input",{type:"text",value:B.snapshot_name_template,onChange:k=>g({...B,snapshot_name_template:k.target.value}),placeholder:"e.g., auto-%Y-%m-%d-%H%M or daily-backup",className:"w-full px-4 py-2 bg-[#111a22] border border-[#2a3b4d] rounded-lg text-white placeholder-text-secondary focus:outline-none focus:border-primary"}),e.jsx("p",{className:"text-[#536b85] text-xs mt-1",children:"Use %Y, %m, %d, %H, %M for date/time formatting (e.g., %Y-%m-%d-%H%M)"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-semibold text-white mb-2 block",children:"Schedule Type"}),e.jsxs("select",{value:B.schedule_type,onChange:k=>{const G=k.target.value;let me={};G==="daily"||G==="weekly"||G==="monthly"?(me={time:B.schedule_config?.time||"00:00"},G==="weekly"?me.day=B.schedule_config?.day||0:G==="monthly"&&(me.day=B.schedule_config?.day||1)):G==="cron"&&(me={cron:B.schedule_config?.cron||"0 0 * * *"}),g({...B,schedule_type:G,schedule_config:me})},className:"w-full px-4 py-2 bg-[#111a22] border border-[#2a3b4d] rounded-lg text-white focus:outline-none focus:border-primary",children:[e.jsx("option",{value:"hourly",children:"Hourly"}),e.jsx("option",{value:"daily",children:"Daily"}),e.jsx("option",{value:"weekly",children:"Weekly"}),e.jsx("option",{value:"monthly",children:"Monthly"}),e.jsx("option",{value:"cron",children:"Custom (Cron)"})]})]}),B.schedule_type==="daily"&&e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-semibold text-white mb-2 block",children:"Time (HH:MM)"}),e.jsx("input",{type:"time",value:B.schedule_config?.time||"00:00",onChange:k=>g({...B,schedule_config:{...B.schedule_config,time:k.target.value}}),className:"w-full px-4 py-2 bg-[#111a22] border border-[#2a3b4d] rounded-lg text-white focus:outline-none focus:border-primary"})]}),B.schedule_type==="weekly"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-semibold text-white mb-2 block",children:"Day of Week"}),e.jsxs("select",{value:B.schedule_config?.day||0,onChange:k=>g({...B,schedule_config:{...B.schedule_config,day:parseInt(k.target.value)}}),className:"w-full px-4 py-2 bg-[#111a22] border border-[#2a3b4d] rounded-lg text-white focus:outline-none focus:border-primary",children:[e.jsx("option",{value:0,children:"Sunday"}),e.jsx("option",{value:1,children:"Monday"}),e.jsx("option",{value:2,children:"Tuesday"}),e.jsx("option",{value:3,children:"Wednesday"}),e.jsx("option",{value:4,children:"Thursday"}),e.jsx("option",{value:5,children:"Friday"}),e.jsx("option",{value:6,children:"Saturday"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-semibold text-white mb-2 block",children:"Time (HH:MM)"}),e.jsx("input",{type:"time",value:B.schedule_config?.time||"00:00",onChange:k=>g({...B,schedule_config:{...B.schedule_config,time:k.target.value}}),className:"w-full px-4 py-2 bg-[#111a22] border border-[#2a3b4d] rounded-lg text-white focus:outline-none focus:border-primary"})]})]}),B.schedule_type==="monthly"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-semibold text-white mb-2 block",children:"Day of Month (1-31)"}),e.jsx("input",{type:"number",min:"1",max:"31",value:B.schedule_config?.day||1,onChange:k=>g({...B,schedule_config:{...B.schedule_config,day:parseInt(k.target.value)}}),className:"w-full px-4 py-2 bg-[#111a22] border border-[#2a3b4d] rounded-lg text-white focus:outline-none focus:border-primary"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-semibold text-white mb-2 block",children:"Time (HH:MM)"}),e.jsx("input",{type:"time",value:B.schedule_config?.time||"00:00",onChange:k=>g({...B,schedule_config:{...B.schedule_config,time:k.target.value}}),className:"w-full px-4 py-2 bg-[#111a22] border border-[#2a3b4d] rounded-lg text-white focus:outline-none focus:border-primary"})]})]}),B.schedule_type==="cron"&&e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-semibold text-white mb-2 block",children:"Cron Expression"}),e.jsx("input",{type:"text",value:B.schedule_config?.cron||"0 0 * * *",onChange:k=>g({...B,schedule_config:{...B.schedule_config,cron:k.target.value}}),placeholder:"0 0 * * *",className:"w-full px-4 py-2 bg-[#111a22] border border-[#2a3b4d] rounded-lg text-white placeholder-text-secondary focus:outline-none focus:border-primary"}),e.jsx("p",{className:"text-[#536b85] text-xs mt-1",children:"Format: minute hour day month weekday"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",id:"recursive",checked:B.recursive,onChange:k=>g({...B,recursive:k.target.checked}),className:"w-4 h-4 rounded border-[#2a3b4d] bg-[#111a22] text-primary focus:ring-primary"}),e.jsx("label",{htmlFor:"recursive",className:"text-sm text-white",children:"Recursive (include child datasets)"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-semibold text-white mb-2 block",children:"Retention Count (optional)"}),e.jsx("input",{type:"number",min:"1",value:B.retention_count||"",onChange:k=>g({...B,retention_count:k.target.value?parseInt(k.target.value):void 0}),placeholder:"Keep last N snapshots (leave empty for unlimited)",className:"w-full px-4 py-2 bg-[#111a22] border border-[#2a3b4d] rounded-lg text-white placeholder-text-secondary focus:outline-none focus:border-primary"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-semibold text-white mb-2 block",children:"Retention Days (optional)"}),e.jsx("input",{type:"number",min:"1",value:B.retention_days||"",onChange:k=>g({...B,retention_days:k.target.value?parseInt(k.target.value):void 0}),placeholder:"Keep snapshots for N days (leave empty for unlimited)",className:"w-full px-4 py-2 bg-[#111a22] border border-[#2a3b4d] rounded-lg text-white placeholder-text-secondary focus:outline-none focus:border-primary"})]}),e.jsxs("div",{className:"flex gap-3 justify-end pt-4",children:[e.jsx("button",{onClick:()=>{x(!1),p(null),g({name:"",dataset:"",snapshot_name_template:"auto-%Y-%m-%d-%H%M",schedule_type:"daily",schedule_config:{time:"00:00"},recursive:!1})},className:"px-4 py-2 text-white text-sm font-medium rounded-lg border border-[#2a3b4d] hover:bg-[#111a22] transition-colors",children:"Cancel"}),e.jsx("button",{onClick:async()=>{if(!B.name||!B.dataset||!B.snapshot_name_template){alert("Please fill in all required fields");return}try{y?(await eh.updateSchedule(y.id,B),alert("Schedule updated successfully!")):(await eh.createSchedule(B),alert("Schedule created successfully!")),await T.invalidateQueries({queryKey:["snapshot-schedules"]}),await _e(),x(!1),p(null),g({name:"",dataset:"",snapshot_name_template:"auto-%Y-%m-%d-%H%M",schedule_type:"daily",schedule_config:{time:"00:00"},recursive:!1})}catch(k){alert(k.response?.data?.error||"Failed to save schedule")}},className:"px-4 py-2 bg-primary hover:bg-blue-600 text-white text-sm font-medium rounded-lg transition-colors",children:y?"Update Schedule":"Create Schedule"})]})]})]})})]})}const rh=[{id:"1",filename:"invoice_2024.pdf.exe",path:"/mnt/pool0/users/finance/",threat:"Win.Trojan.Agent-1",threatLevel:"high",date:"2024-10-24T10:42:00Z"},{id:"2",filename:"keygen_v2.zip",path:"/mnt/pool0/public/software/",threat:"PUA.Win.Tool.Keygen",threatLevel:"medium",date:"2024-10-22T20:15:00Z"},{id:"3",filename:"script_final.sh",path:"/root/downloads/",threat:"Unix.Malware.Agent",threatLevel:"high",date:"2024-10-20T02:30:00Z"}],p_=[{id:"1",name:"Daily Full System",target:"/",frequency:"Every day at 02:00",lastRun:"Yesterday 02:00",status:"success"},{id:"2",name:"Weekly Pool Scan",target:"/mnt/pool0",frequency:"Sundays at 04:00",lastRun:"3 days ago",status:"success"}];function x_(){const[r,t]=Ce.useState(!0),[s,n]=Ce.useState("/mnt/pool0/data"),[o,l]=Ce.useState(!0),[d,c]=Ce.useState(!1),[u,h]=Ce.useState(!1),[m,x]=Ce.useState([]),y=B=>new Date(B).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}),p=B=>B==="high"?"bg-red-500/10 text-red-400 border-red-500/20":"bg-amber-500/10 text-amber-400 border-amber-500/20",v=()=>{m.length===rh.length?x([]):x(rh.map(B=>B.id))},N=B=>{m.includes(B)?x(m.filter(g=>g!==B)):x([...m,B])};return e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col bg-background-dark",children:[e.jsx("header",{className:"sticky top-0 z-20 bg-background-dark/95 backdrop-blur border-b border-border-dark px-6 py-4 lg:px-10",children:e.jsx("div",{className:"max-w-7xl mx-auto w-full",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(ba,{to:"/system",className:"text-text-secondary hover:text-primary transition-colors",children:"System"}),e.jsx(Ka,{className:"text-text-secondary",size:16}),e.jsx(ba,{to:"/system",className:"text-text-secondary hover:text-primary transition-colors",children:"Security"}),e.jsx(Ka,{className:"text-text-secondary",size:16}),e.jsx("span",{className:"text-white font-medium",children:"Share Shield System"})]}),e.jsxs("div",{className:"flex flex-wrap justify-between items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-white text-3xl font-black tracking-tight mb-1",children:"Share Shield System"}),e.jsx("p",{className:"text-text-secondary text-sm lg:text-base max-w-2xl",children:"Manage virus definitions, on-demand scans, and quarantine settings for your storage pools."})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("button",{className:"flex items-center gap-2 px-4 py-2 bg-[#233648] hover:bg-[#2c445a] text-white text-sm font-medium rounded-lg border border-border-dark transition-all",children:[e.jsx(hp,{size:16}),"Scan History"]}),e.jsxs("button",{className:"flex items-center gap-2 px-4 py-2 bg-primary hover:bg-blue-600 text-white text-sm font-bold rounded-lg shadow-lg shadow-blue-500/20 transition-all",children:[e.jsx(Cn,{size:16}),"Update Definitions"]})]})]})]})})}),e.jsx("div",{className:"flex-1 p-6 lg:px-10 py-8 overflow-y-auto",children:e.jsxs("div",{className:"max-w-7xl mx-auto w-full flex flex-col gap-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"xl:col-span-2 rounded-xl border border-border-dark bg-card-dark p-5 flex items-center justify-between shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-emerald-500/10 border border-emerald-500/20",children:e.jsx(Bn,{className:"text-emerald-500",size:32})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-white text-base font-bold",children:"Share Shield Service"}),e.jsxs("p",{className:"text-emerald-400 text-sm font-medium flex items-center gap-1.5",children:[e.jsx("span",{className:"size-1.5 rounded-full bg-emerald-400 animate-pulse"}),"Active & Protecting"]})]})]}),e.jsxs("label",{className:"relative flex h-[28px] w-[48px] cursor-pointer items-center rounded-full border-none bg-[#233648] p-0.5 transition-colors duration-300 has-[:checked]:justify-end has-[:checked]:bg-primary",children:[e.jsx("div",{className:"h-[24px] w-[24px] rounded-full bg-white shadow-sm"}),e.jsx("input",{checked:r,onChange:B=>t(B.target.checked),className:"invisible absolute",type:"checkbox"})]})]}),e.jsxs("div",{className:"rounded-xl border border-border-dark bg-card-dark p-5 flex flex-col justify-between shadow-sm",children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsx("span",{className:"text-text-secondary text-sm font-medium",children:"Virus Definitions"}),e.jsx(_y,{className:"text-text-secondary",size:20})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-white text-2xl font-bold tracking-tight",children:"v26500"}),e.jsx("p",{className:"text-text-secondary text-xs mt-1",children:"Updated: 2 hours ago"})]})]}),e.jsxs("div",{className:"rounded-xl border border-border-dark bg-card-dark p-5 flex flex-col justify-between shadow-sm",children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsx("span",{className:"text-text-secondary text-sm font-medium",children:"Quarantined Files"}),e.jsx(Eh,{className:"text-amber-500",size:20})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("p",{className:"text-white text-2xl font-bold tracking-tight",children:"12"}),e.jsx("span",{className:"text-emerald-500 text-xs font-bold bg-emerald-500/10 px-1.5 py-0.5 rounded",children:"+2 new"})]}),e.jsx("p",{className:"text-text-secondary text-xs mt-1",children:"Since last reboot"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-3 gap-6",children:[e.jsx("div",{className:"flex flex-col gap-6 xl:col-span-1",children:e.jsxs("div",{className:"rounded-xl border border-border-dark bg-card-dark overflow-hidden flex flex-col",children:[e.jsx("div",{className:"p-5 border-b border-border-dark bg-[#16202a]",children:e.jsxs("h3",{className:"text-white font-bold text-lg flex items-center gap-2",children:[e.jsx(I6,{className:"text-primary",size:20}),"On-Demand Scanner"]})}),e.jsxs("div",{className:"p-5 flex flex-col gap-5",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-medium text-text-secondary",children:"Target Directory"}),e.jsxs("div",{className:"flex",children:[e.jsx("input",{className:"flex-1 bg-[#111a22] border border-border-dark text-white text-sm rounded-l-lg px-3 py-2.5 focus:ring-1 focus:ring-primary focus:border-primary outline-none placeholder-gray-600",placeholder:"/path/to/scan",type:"text",value:s,onChange:B=>n(B.target.value)}),e.jsx("button",{className:"bg-[#233648] hover:bg-[#2c445a] text-white px-3 border-y border-r border-border-dark rounded-r-lg transition-colors",children:e.jsx(au,{size:18})})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("label",{className:"flex items-center gap-3 cursor-pointer group",children:[e.jsx("input",{checked:o,onChange:B=>l(B.target.checked),className:"rounded border-border-dark bg-[#233648] text-primary focus:ring-offset-[#111a22] focus:ring-primary size-4",type:"checkbox"}),e.jsx("span",{className:"text-sm text-gray-300 group-hover:text-white transition-colors",children:"Recursive Scan"})]}),e.jsxs("label",{className:"flex items-center gap-3 cursor-pointer group",children:[e.jsx("input",{checked:d,onChange:B=>c(B.target.checked),className:"rounded border-border-dark bg-[#233648] text-primary focus:ring-offset-[#111a22] focus:ring-primary size-4",type:"checkbox"}),e.jsx("span",{className:"text-sm text-gray-300 group-hover:text-white transition-colors",children:"Scan Archives (zip, rar)"})]}),e.jsxs("label",{className:"flex items-center gap-3 cursor-pointer group",children:[e.jsx("input",{checked:u,onChange:B=>h(B.target.checked),className:"rounded border-border-dark bg-[#233648] text-primary focus:ring-offset-[#111a22] focus:ring-primary size-4",type:"checkbox"}),e.jsx("span",{className:"text-sm text-gray-300 group-hover:text-white transition-colors",children:"Remove Threats Automatically"})]})]}),e.jsxs("div",{className:"pt-2 border-t border-border-dark/50 flex flex-col gap-3",children:[e.jsxs("button",{className:"w-full py-2.5 bg-primary hover:bg-blue-600 text-white font-bold rounded-lg shadow-lg shadow-blue-500/20 transition-all flex justify-center items-center gap-2",children:[e.jsx(i4,{size:18}),"Start Scan"]}),e.jsxs("button",{className:"w-full py-2.5 bg-[#233648] hover:bg-[#2c445a] text-text-secondary hover:text-white font-medium rounded-lg border border-border-dark transition-all flex justify-center items-center gap-2",children:[e.jsx(Ec,{size:18}),"Schedule Scan"]})]})]})]})}),e.jsx("div",{className:"xl:col-span-2 flex flex-col gap-6",children:e.jsxs("div",{className:"rounded-xl border border-border-dark bg-card-dark overflow-hidden flex flex-col h-full",children:[e.jsxs("div",{className:"p-5 border-b border-border-dark bg-[#16202a] flex justify-between items-center",children:[e.jsxs("h3",{className:"text-white font-bold text-lg flex items-center gap-2",children:[e.jsx(D6,{className:"text-amber-500",size:20}),"Quarantine Manager"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:v,className:"text-xs font-medium text-text-secondary hover:text-white px-3 py-1.5 rounded-md hover:bg-[#233648] transition-colors border border-transparent hover:border-border-dark",children:"Select All"}),e.jsx("button",{className:"text-xs font-medium text-red-400 hover:text-red-300 px-3 py-1.5 rounded-md hover:bg-red-400/10 transition-colors border border-transparent hover:border-red-400/20",children:"Delete Selected"})]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left text-sm",children:[e.jsx("thead",{className:"bg-[#16202a] text-text-secondary font-medium",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-5 py-3 w-10",children:e.jsx("input",{checked:m.length===rh.length,onChange:v,className:"rounded border-border-dark bg-[#233648] text-primary focus:ring-offset-[#111a22] focus:ring-primary size-4",type:"checkbox"})}),e.jsx("th",{className:"px-5 py-3",children:"Filename"}),e.jsx("th",{className:"px-5 py-3",children:"Threat Detected"}),e.jsx("th",{className:"px-5 py-3",children:"Date"}),e.jsx("th",{className:"px-5 py-3 text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-border-dark",children:rh.map(B=>e.jsxs("tr",{className:"group hover:bg-[#233648]/30 transition-colors",children:[e.jsx("td",{className:"px-5 py-4",children:e.jsx("input",{checked:m.includes(B.id),onChange:()=>N(B.id),className:"rounded border-border-dark bg-[#233648] text-primary focus:ring-offset-[#111a22] focus:ring-primary size-4",type:"checkbox"})}),e.jsx("td",{className:"px-5 py-4",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-white font-medium",children:B.filename}),e.jsx("span",{className:"text-xs text-text-secondary font-mono",children:B.path})]})}),e.jsx("td",{className:"px-5 py-4",children:e.jsx("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border ${p(B.threatLevel)}`,children:B.threat})}),e.jsx("td",{className:"px-5 py-4 text-text-secondary",children:y(B.date)}),e.jsx("td",{className:"px-5 py-4 text-right",children:e.jsxs("div",{className:"flex justify-end gap-2 opacity-60 group-hover:opacity-100 transition-opacity",children:[e.jsx("button",{className:"p-1.5 text-text-secondary hover:text-emerald-400 hover:bg-emerald-400/10 rounded-md transition-colors",title:"Restore",children:e.jsx(Im,{size:20})}),e.jsx("button",{className:"p-1.5 text-text-secondary hover:text-red-400 hover:bg-red-400/10 rounded-md transition-colors",title:"Delete Permanently",children:e.jsx(es,{size:20})})]})})]},B.id))})]})}),e.jsxs("div",{className:"p-4 border-t border-border-dark bg-[#16202a] text-xs text-text-secondary flex justify-center",children:["Showing ",rh.length," of 12 quarantined items"]})]})})]}),e.jsxs("div",{className:"rounded-xl border border-border-dark bg-card-dark overflow-hidden mt-2",children:[e.jsxs("div",{className:"p-5 border-b border-border-dark bg-[#16202a] flex justify-between items-center",children:[e.jsx("h3",{className:"text-white font-bold text-lg",children:"Scheduled Scans"}),e.jsxs("button",{className:"text-primary hover:text-blue-400 text-sm font-bold flex items-center gap-1",children:[e.jsx(Ks,{size:18}),"Add Schedule"]})]}),e.jsx("div",{className:"p-0 overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left text-sm",children:[e.jsx("thead",{className:"text-text-secondary font-medium border-b border-border-dark",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-3 font-medium",children:"Name"}),e.jsx("th",{className:"px-6 py-3 font-medium",children:"Target"}),e.jsx("th",{className:"px-6 py-3 font-medium",children:"Frequency"}),e.jsx("th",{className:"px-6 py-3 font-medium",children:"Last Run"}),e.jsx("th",{className:"px-6 py-3 font-medium",children:"Status"}),e.jsx("th",{className:"px-6 py-3 font-medium text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-border-dark",children:p_.map(B=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-6 py-4 text-white font-medium",children:B.name}),e.jsx("td",{className:"px-6 py-4 text-text-secondary font-mono text-xs",children:B.target}),e.jsx("td",{className:"px-6 py-4 text-text-secondary",children:B.frequency}),e.jsx("td",{className:"px-6 py-4 text-text-secondary",children:B.lastRun}),e.jsx("td",{className:"px-6 py-4",children:e.jsxs("span",{className:"text-emerald-400 flex items-center gap-1",children:[e.jsx(su,{size:16}),"Success"]})}),e.jsx("td",{className:"px-6 py-4 text-right",children:e.jsx("button",{className:"text-text-secondary hover:text-white",children:e.jsx(pp,{size:18})})})]},B.id))})]})})]})]})})]})}const g_="modulepreload",b_=function(r){return"/"+r},Lv={},sg=function(t,s,n){let o=Promise.resolve();if(s&&s.length>0){let u=function(h){return Promise.all(h.map(m=>Promise.resolve(m).then(x=>({status:"fulfilled",value:x}),x=>({status:"rejected",reason:x}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),c=d?.nonce||d?.getAttribute("nonce");o=u(s.map(h=>{if(h=b_(h),h in Lv)return;Lv[h]=!0;const m=h.endsWith(".css"),x=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${x}`))return;const y=document.createElement("link");if(y.rel=m?"stylesheet":g_,m||(y.as="script"),y.crossOrigin="",y.href=h,c&&y.setAttribute("nonce",c),document.head.appendChild(y),m)return new Promise((p,v)=>{y.addEventListener("load",p),y.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${h}`)))})}))}function l(d){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=d,window.dispatchEvent(c),!c.defaultPrevented)throw d}return o.then(d=>{for(const c of d||[])c.status==="rejected"&&l(c.reason);return t().catch(l)})};var no=Uint8Array,Wn=Uint16Array,Fy=Int32Array,Ey=new no([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Uy=new no([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Tv=new no([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),p4=function(r,t){for(var s=new Wn(31),n=0;n<31;++n)s[n]=t+=1<>1|(os&21845)<<1;pA=(pA&52428)>>2|(pA&13107)<<2,pA=(pA&61680)>>4|(pA&3855)<<4,Ob[os]=((pA&65280)>>8|(pA&255)<<8)>>1}var Nh=(function(r,t,s){for(var n=r.length,o=0,l=new Wn(t);o>u]=h}else for(c=new Wn(n),o=0;o>15-r[o]);return c}),Uc=new no(288);for(var os=0;os<144;++os)Uc[os]=8;for(var os=144;os<256;++os)Uc[os]=9;for(var os=256;os<280;++os)Uc[os]=7;for(var os=280;os<288;++os)Uc[os]=8;var Jm=new no(32);for(var os=0;os<32;++os)Jm[os]=5;var v_=Nh(Uc,9,0),N_=Nh(Jm,5,0),g4=function(r){return(r+7)/8|0},B_=function(r,t,s){return(s==null||s>r.length)&&(s=r.length),new no(r.subarray(t,s))},bl=function(r,t,s){s<<=t&7;var n=t/8|0;r[n]|=s,r[n+1]|=s>>8},sh=function(r,t,s){s<<=t&7;var n=t/8|0;r[n]|=s,r[n+1]|=s>>8,r[n+2]|=s>>16},ag=function(r,t){for(var s=[],n=0;ny&&(y=l[n].s);var p=new Wn(y+1),v=Hb(s[m-1],p,0);if(v>t){var n=0,N=0,B=v-t,g=1<t)N+=g-(1<>=B;N>0;){var _=l[n].s;p[_]=0&&N;--n){var w=l[n].s;p[w]==t&&(--p[w],++N)}v=t}return{t:new no(p),l:v}},Hb=function(r,t,s){return r.s==-1?Math.max(Hb(r.l,t,s+1),Hb(r.r,t,s+1)):t[r.s]=s},Dv=function(r){for(var t=r.length;t&&!r[--t];);for(var s=new Wn(++t),n=0,o=r[0],l=1,d=function(u){s[n++]=u},c=1;c<=t;++c)if(r[c]==o&&c!=t)++l;else{if(!o&&l>2){for(;l>138;l-=138)d(32754);l>2&&(d(l>10?l-11<<5|28690:l-3<<5|12305),l=0)}else if(l>3){for(d(o),--l;l>6;l-=6)d(8304);l>2&&(d(l-3<<5|8208),l=0)}for(;l--;)d(o);l=1,o=r[c]}return{c:s.subarray(0,n),n:t}},ah=function(r,t){for(var s=0,n=0;n>8,r[o+2]=r[o]^255,r[o+3]=r[o+1]^255;for(var l=0;l4&&!ne[Tv[U-1]];--U);var q=h+5<<3,F=ah(o,Uc)+ah(l,Jm)+d,le=ah(o,y)+ah(l,N)+d+14+3*U+ah(M,ne)+2*M[16]+3*M[17]+7*M[18];if(u>=0&&q<=F&&q<=le)return b4(t,m,r.subarray(u,u+h));var ae,se,fe,ye;if(bl(t,m,1+(le15&&(bl(t,m,$[V]>>5&127),m+=$[V]>>12)}}else ae=v_,se=Uc,fe=N_,ye=Jm;for(var V=0;V255){var X=te>>18&31;sh(t,m,ae[X+257]),m+=se[X+257],X>7&&(bl(t,m,te>>23&31),m+=Ey[X]);var J=te&31;sh(t,m,fe[J]),m+=ye[J],J>3&&(sh(t,m,te>>5&8191),m+=Uy[J])}else sh(t,m,ae[te]),m+=se[te]}return sh(t,m,ae[256]),m+se[256]},j_=new Fy([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),y4=new no(0),C_=function(r,t,s,n,o,l){var d=l.z||r.length,c=new no(n+d+5*(1+Math.ceil(d/7e3))+o),u=c.subarray(n,c.length-o),h=l.l,m=(l.r||0)&7;if(t){m&&(u[0]=l.r>>3);for(var x=j_[t-1],y=x>>13,p=x&8191,v=(1<7e3||ne>24576)&&(ae>423||!h)){m=Rv(r,u,0,w,L,K,V,ne,U,T-U,m),ne=M=V=0,U=T;for(var se=0;se<286;++se)L[se]=0;for(var se=0;se<30;++se)K[se]=0}var fe=2,ye=0,_e=p,xe=F-le&32767;if(ae>2&&q==_(T-xe))for(var D=Math.min(y,ae)-1,$=Math.min(32767,T),X=Math.min(258,ae);xe<=$&&--_e&&F!=le;){if(r[T+fe]==r[T+fe-xe]){for(var te=0;tefe){if(fe=te,ye=xe,te>D)break;for(var J=Math.min(xe,te-2),O=0,se=0;seO&&(O=Ae,le=H)}}}F=le,le=N[F],xe+=F-le&32767}if(ye){w[ne++]=268435456|Rb[fe]<<18|Iv[ye];var oe=Rb[fe]&31,ce=Iv[ye]&31;V+=Ey[oe]+Uy[ce],++L[257+oe],++K[ce],Z=T+fe,++M}else w[ne++]=r[T],++L[r[T]]}}for(T=Math.max(T,Z);T=d&&(u[m/8|0]=h,Se=d),m=b4(u,m+1,r.subarray(T,Se))}l.i=d}return B_(c,0,n+g4(m)+o)},w4=function(){var r=1,t=0;return{p:function(s){for(var n=r,o=t,l=s.length|0,d=0;d!=l;){for(var c=Math.min(d+2655,l);d>16),o=(o&65535)+15*(o>>16)}r=n,t=o},d:function(){return r%=65521,t%=65521,(r&255)<<24|(r&65280)<<8|(t&255)<<8|t>>8}}},S_=function(r,t,s,n,o){if(!o&&(o={l:1},t.dictionary)){var l=t.dictionary.subarray(-32768),d=new no(l.length+r.length);d.set(l),d.set(r,l.length),r=d,o.w=l.length}return C_(r,t.level==null?6:t.level,t.mem==null?o.l?Math.ceil(Math.max(8,Math.min(13,Math.log(r.length)))*1.5):20:12+t.mem,s,n,o)},v4=function(r,t,s){for(;s;++t)r[t]=s,s>>>=8},__=function(r,t){var s=t.level,n=s==0?0:s<6?1:s==9?3:2;if(r[0]=120,r[1]=n<<6|(t.dictionary&&32),r[1]|=31-(r[0]<<8|r[1])%31,t.dictionary){var o=w4();o.p(t.dictionary),v4(r,2,o.d())}};function Mb(r,t){t||(t={});var s=w4();s.p(r);var n=S_(r,t,t.dictionary?6:2,4);return __(n,t),v4(n,n.length-4,s.d()),n}var k_=typeof TextDecoder<"u"&&new TextDecoder,F_=0;try{k_.decode(y4,{stream:!0}),F_=1}catch{}function E_(r){if(Array.isArray(r))return r}function U_(r,t){var s=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(s!=null){var n,o,l,d,c=[],u=!0,h=!1;try{if(l=(s=s.call(r)).next,t!==0)for(;!(u=(n=l.call(s)).done)&&(c.push(n.value),c.length!==t);u=!0);}catch(m){h=!0,o=m}finally{try{if(!u&&s.return!=null&&(d=s.return(),Object(d)!==d))return}finally{if(h)throw o}}return c}}function Q_(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ov(r,t){return E_(r)||U_(r,t)||y6(r,t)||Q_()}function Hv(r,t="utf8"){return new TextDecoder(t).decode(r)}const L_=new TextEncoder;function T_(r){return L_.encode(r)}const I_=1024*8,D_=(()=>{const r=new Uint8Array(4),t=new Uint32Array(r.buffer);return!((t[0]=1)&r[0])})(),ng={int8:globalThis.Int8Array,uint8:globalThis.Uint8Array,int16:globalThis.Int16Array,uint16:globalThis.Uint16Array,int32:globalThis.Int32Array,uint32:globalThis.Uint32Array,uint64:globalThis.BigUint64Array,int64:globalThis.BigInt64Array,float32:globalThis.Float32Array,float64:globalThis.Float64Array};class Qy{buffer;byteLength;byteOffset;length;offset;lastWrittenByte;littleEndian;_data;_mark;_marks;constructor(t=I_,s={}){let n=!1;typeof t=="number"?t=new ArrayBuffer(t):(n=!0,this.lastWrittenByte=t.byteLength);const o=s.offset?s.offset>>>0:0,l=t.byteLength-o;let d=o;(ArrayBuffer.isView(t)||t instanceof Qy)&&(t.byteLength!==t.buffer.byteLength&&(d=t.byteOffset+o),t=t.buffer),n?this.lastWrittenByte=l:this.lastWrittenByte=0,this.buffer=t,this.length=l,this.byteLength=l,this.byteOffset=d,this.offset=0,this.littleEndian=!0,this._data=new DataView(this.buffer,d,l),this._mark=0,this._marks=[]}available(t=1){return this.offset+t<=this.length}isLittleEndian(){return this.littleEndian}setLittleEndian(){return this.littleEndian=!0,this}isBigEndian(){return!this.littleEndian}setBigEndian(){return this.littleEndian=!1,this}skip(t=1){return this.offset+=t,this}back(t=1){return this.offset-=t,this}seek(t){return this.offset=t,this}mark(){return this._mark=this.offset,this}reset(){return this.offset=this._mark,this}pushMark(){return this._marks.push(this.offset),this}popMark(){const t=this._marks.pop();if(t===void 0)throw new Error("Mark stack empty");return this.seek(t),this}rewind(){return this.offset=0,this}ensureAvailable(t=1){if(!this.available(t)){const n=(this.offset+t)*2,o=new Uint8Array(n);o.set(new Uint8Array(this.buffer)),this.buffer=o.buffer,this.length=n,this.byteLength=n,this._data=new DataView(this.buffer)}return this}readBoolean(){return this.readUint8()!==0}readInt8(){return this._data.getInt8(this.offset++)}readUint8(){return this._data.getUint8(this.offset++)}readByte(){return this.readUint8()}readBytes(t=1){return this.readArray(t,"uint8")}readArray(t,s){const n=ng[s].BYTES_PER_ELEMENT*t,o=this.byteOffset+this.offset,l=this.buffer.slice(o,o+n);if(this.littleEndian===D_&&s!=="uint8"&&s!=="int8"){const c=new Uint8Array(this.buffer.slice(o,o+n));c.reverse();const u=new ng[s](c.buffer);return this.offset+=n,u.reverse(),u}const d=new ng[s](l);return this.offset+=n,d}readInt16(){const t=this._data.getInt16(this.offset,this.littleEndian);return this.offset+=2,t}readUint16(){const t=this._data.getUint16(this.offset,this.littleEndian);return this.offset+=2,t}readInt32(){const t=this._data.getInt32(this.offset,this.littleEndian);return this.offset+=4,t}readUint32(){const t=this._data.getUint32(this.offset,this.littleEndian);return this.offset+=4,t}readFloat32(){const t=this._data.getFloat32(this.offset,this.littleEndian);return this.offset+=4,t}readFloat64(){const t=this._data.getFloat64(this.offset,this.littleEndian);return this.offset+=8,t}readBigInt64(){const t=this._data.getBigInt64(this.offset,this.littleEndian);return this.offset+=8,t}readBigUint64(){const t=this._data.getBigUint64(this.offset,this.littleEndian);return this.offset+=8,t}readChar(){return String.fromCharCode(this.readInt8())}readChars(t=1){let s="";for(let n=0;nthis.lastWrittenByte&&(this.lastWrittenByte=this.offset)}}function fu(r){let t=r.length;for(;--t>=0;)r[t]=0}const R_=3,O_=258,N4=29,H_=256,M_=H_+1+N4,B4=30,P_=512,K_=new Array((M_+2)*2);fu(K_);const z_=new Array(B4*2);fu(z_);const q_=new Array(P_);fu(q_);const G_=new Array(O_-R_+1);fu(G_);const V_=new Array(N4);fu(V_);const W_=new Array(B4);fu(W_);const X_=(r,t,s,n)=>{let o=r&65535|0,l=r>>>16&65535|0,d=0;for(;s!==0;){d=s>2e3?2e3:s,s-=d;do o=o+t[n++]|0,l=l+o|0;while(--d);o%=65521,l%=65521}return o|l<<16|0};var Pb=X_;const Y_=()=>{let r,t=[];for(var s=0;s<256;s++){r=s;for(var n=0;n<8;n++)r=r&1?3988292384^r>>>1:r>>>1;t[s]=r}return t},J_=new Uint32Array(Y_()),Z_=(r,t,s,n)=>{const o=J_,l=n+s;r^=-1;for(let d=n;d>>8^o[(r^t[d])&255];return r^-1};var Eo=Z_,Kb={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},j4={Z_NO_FLUSH:0,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_DEFLATED:8};const $_=(r,t)=>Object.prototype.hasOwnProperty.call(r,t);var ek=function(r){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const s=t.shift();if(s){if(typeof s!="object")throw new TypeError(s+"must be non-object");for(const n in s)$_(s,n)&&(r[n]=s[n])}}return r},tk=r=>{let t=0;for(let n=0,o=r.length;n=252?6:r>=248?5:r>=240?4:r>=224?3:r>=192?2:1;Ih[254]=Ih[254]=1;var rk=r=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(r);let t,s,n,o,l,d=r.length,c=0;for(o=0;o>>6,t[l++]=128|s&63):s<65536?(t[l++]=224|s>>>12,t[l++]=128|s>>>6&63,t[l++]=128|s&63):(t[l++]=240|s>>>18,t[l++]=128|s>>>12&63,t[l++]=128|s>>>6&63,t[l++]=128|s&63);return t};const sk=(r,t)=>{if(t<65534&&r.subarray&&S4)return String.fromCharCode.apply(null,r.length===t?r:r.subarray(0,t));let s="";for(let n=0;n{const s=t||r.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(r.subarray(0,t));let n,o;const l=new Array(s*2);for(o=0,n=0;n4){l[o++]=65533,n+=c-1;continue}for(d&=c===2?31:c===3?15:7;c>1&&n1){l[o++]=65533;continue}d<65536?l[o++]=d:(d-=65536,l[o++]=55296|d>>10&1023,l[o++]=56320|d&1023)}return sk(l,o)},nk=(r,t)=>{t=t||r.length,t>r.length&&(t=r.length);let s=t-1;for(;s>=0&&(r[s]&192)===128;)s--;return s<0||s===0?t:s+Ih[r[s]]>t?s:t},zb={string2buf:rk,buf2string:ak,utf8border:nk};function ik(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var ok=ik;const qf=16209,lk=16191;var Ak=function(t,s){let n,o,l,d,c,u,h,m,x,y,p,v,N,B,g,j,_,w,L,K,M,V,T,ne;const Z=t.state;n=t.next_in,T=t.input,o=n+(t.avail_in-5),l=t.next_out,ne=t.output,d=l-(s-t.avail_out),c=l+(t.avail_out-257),u=Z.dmax,h=Z.wsize,m=Z.whave,x=Z.wnext,y=Z.window,p=Z.hold,v=Z.bits,N=Z.lencode,B=Z.distcode,g=(1<>>24,p>>>=w,v-=w,w=_>>>16&255,w===0)ne[l++]=_&65535;else if(w&16){L=_&65535,w&=15,w&&(v>>=w,v-=w),v<15&&(p+=T[n++]<>>24,p>>>=w,v-=w,w=_>>>16&255,w&16){if(K=_&65535,w&=15,vu){t.msg="invalid distance too far back",Z.mode=qf;break e}if(p>>>=w,v-=w,w=l-d,K>w){if(w=K-w,w>m&&Z.sane){t.msg="invalid distance too far back",Z.mode=qf;break e}if(M=0,V=y,x===0){if(M+=h-w,w2;)ne[l++]=V[M++],ne[l++]=V[M++],ne[l++]=V[M++],L-=3;L&&(ne[l++]=V[M++],L>1&&(ne[l++]=V[M++]))}else{M=l-K;do ne[l++]=ne[M++],ne[l++]=ne[M++],ne[l++]=ne[M++],L-=3;while(L>2);L&&(ne[l++]=ne[M++],L>1&&(ne[l++]=ne[M++]))}}else if((w&64)===0){_=B[(_&65535)+(p&(1<>3,n-=L,v-=L<<3,p&=(1<{const u=c.bits;let h=0,m=0,x=0,y=0,p=0,v=0,N=0,B=0,g=0,j=0,_,w,L,K,M,V=null,T;const ne=new Uint16Array(kd+1),Z=new Uint16Array(kd+1);let U=null,q,F,le;for(h=0;h<=kd;h++)ne[h]=0;for(m=0;m=1&&ne[y]===0;y--);if(p>y&&(p=y),y===0)return o[l++]=1<<24|64<<16|0,o[l++]=1<<24|64<<16|0,c.bits=1,0;for(x=1;x0&&(r===Kv||y!==1))return-1;for(Z[1]=0,h=1;hMv||r===zv&&g>Pv)return 1;for(;;){q=h-N,d[m]+1=T?(F=U[d[m]-T],le=V[d[m]-T]):(F=96,le=0),_=1<>N)+w]=q<<24|F<<16|le|0;while(w!==0);for(_=1<>=1;if(_!==0?(j&=_-1,j+=_):j=0,m++,--ne[h]===0){if(h===y)break;h=t[s+d[m]]}if(h>p&&(j&K)!==L){for(N===0&&(N=p),M+=x,v=h-N,B=1<Mv||r===zv&&g>Pv)return 1;L=j&K,o[L]=p<<24|v<<16|M-l|0}}return j!==0&&(o[M+j]=h-N<<24|64<<16|0),c.bits=p,0};var Bh=fk;const mk=0,_4=1,k4=2,{Z_FINISH:qv,Z_BLOCK:pk,Z_TREES:Gf,Z_OK:Qc,Z_STREAM_END:xk,Z_NEED_DICT:gk,Z_STREAM_ERROR:ji,Z_DATA_ERROR:F4,Z_MEM_ERROR:E4,Z_BUF_ERROR:bk,Z_DEFLATED:Gv}=j4,xp=16180,Vv=16181,Wv=16182,Xv=16183,Yv=16184,Jv=16185,Zv=16186,$v=16187,e2=16188,t2=16189,Zm=16190,yl=16191,og=16192,r2=16193,lg=16194,s2=16195,a2=16196,n2=16197,i2=16198,Vf=16199,Wf=16200,o2=16201,l2=16202,A2=16203,c2=16204,d2=16205,Ag=16206,u2=16207,h2=16208,us=16209,U4=16210,Q4=16211,yk=852,wk=592,vk=15,Nk=vk,f2=r=>(r>>>24&255)+(r>>>8&65280)+((r&65280)<<8)+((r&255)<<24);function Bk(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Tc=r=>{if(!r)return 1;const t=r.state;return!t||t.strm!==r||t.modeQ4?1:0},L4=r=>{if(Tc(r))return ji;const t=r.state;return r.total_in=r.total_out=t.total=0,r.msg="",t.wrap&&(r.adler=t.wrap&1),t.mode=xp,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(yk),t.distcode=t.distdyn=new Int32Array(wk),t.sane=1,t.back=-1,Qc},T4=r=>{if(Tc(r))return ji;const t=r.state;return t.wsize=0,t.whave=0,t.wnext=0,L4(r)},I4=(r,t)=>{let s;if(Tc(r))return ji;const n=r.state;return t<0?(s=0,t=-t):(s=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15)?ji:(n.window!==null&&n.wbits!==t&&(n.window=null),n.wrap=s,n.wbits=t,T4(r))},D4=(r,t)=>{if(!r)return ji;const s=new Bk;r.state=s,s.strm=r,s.window=null,s.mode=xp;const n=I4(r,t);return n!==Qc&&(r.state=null),n},jk=r=>D4(r,Nk);let m2=!0,cg,dg;const Ck=r=>{if(m2){cg=new Int32Array(512),dg=new Int32Array(32);let t=0;for(;t<144;)r.lens[t++]=8;for(;t<256;)r.lens[t++]=9;for(;t<280;)r.lens[t++]=7;for(;t<288;)r.lens[t++]=8;for(Bh(_4,r.lens,0,288,cg,0,r.work,{bits:9}),t=0;t<32;)r.lens[t++]=5;Bh(k4,r.lens,0,32,dg,0,r.work,{bits:5}),m2=!1}r.lencode=cg,r.lenbits=9,r.distcode=dg,r.distbits=5},R4=(r,t,s,n)=>{let o;const l=r.state;return l.window===null&&(l.wsize=1<=l.wsize?(l.window.set(t.subarray(s-l.wsize,s),0),l.wnext=0,l.whave=l.wsize):(o=l.wsize-l.wnext,o>n&&(o=n),l.window.set(t.subarray(s-n,s-n+o),l.wnext),n-=o,n?(l.window.set(t.subarray(s-n,s),0),l.wnext=n,l.whave=l.wsize):(l.wnext+=o,l.wnext===l.wsize&&(l.wnext=0),l.whave{let s,n,o,l,d,c,u,h,m,x,y,p,v,N,B=0,g,j,_,w,L,K,M,V;const T=new Uint8Array(4);let ne,Z;const U=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Tc(r)||!r.output||!r.input&&r.avail_in!==0)return ji;s=r.state,s.mode===yl&&(s.mode=og),d=r.next_out,o=r.output,u=r.avail_out,l=r.next_in,n=r.input,c=r.avail_in,h=s.hold,m=s.bits,x=c,y=u,V=Qc;e:for(;;)switch(s.mode){case xp:if(s.wrap===0){s.mode=og;break}for(;m<16;){if(c===0)break e;c--,h+=n[l++]<>>8&255,s.check=Eo(s.check,T,2,0),h=0,m=0,s.mode=Vv;break}if(s.head&&(s.head.done=!1),!(s.wrap&1)||(((h&255)<<8)+(h>>8))%31){r.msg="incorrect header check",s.mode=us;break}if((h&15)!==Gv){r.msg="unknown compression method",s.mode=us;break}if(h>>>=4,m-=4,M=(h&15)+8,s.wbits===0&&(s.wbits=M),M>15||M>s.wbits){r.msg="invalid window size",s.mode=us;break}s.dmax=1<>8&1),s.flags&512&&s.wrap&4&&(T[0]=h&255,T[1]=h>>>8&255,s.check=Eo(s.check,T,2,0)),h=0,m=0,s.mode=Wv;case Wv:for(;m<32;){if(c===0)break e;c--,h+=n[l++]<>>8&255,T[2]=h>>>16&255,T[3]=h>>>24&255,s.check=Eo(s.check,T,4,0)),h=0,m=0,s.mode=Xv;case Xv:for(;m<16;){if(c===0)break e;c--,h+=n[l++]<>8),s.flags&512&&s.wrap&4&&(T[0]=h&255,T[1]=h>>>8&255,s.check=Eo(s.check,T,2,0)),h=0,m=0,s.mode=Yv;case Yv:if(s.flags&1024){for(;m<16;){if(c===0)break e;c--,h+=n[l++]<>>8&255,s.check=Eo(s.check,T,2,0)),h=0,m=0}else s.head&&(s.head.extra=null);s.mode=Jv;case Jv:if(s.flags&1024&&(p=s.length,p>c&&(p=c),p&&(s.head&&(M=s.head.extra_len-s.length,s.head.extra||(s.head.extra=new Uint8Array(s.head.extra_len)),s.head.extra.set(n.subarray(l,l+p),M)),s.flags&512&&s.wrap&4&&(s.check=Eo(s.check,n,p,l)),c-=p,l+=p,s.length-=p),s.length))break e;s.length=0,s.mode=Zv;case Zv:if(s.flags&2048){if(c===0)break e;p=0;do M=n[l+p++],s.head&&M&&s.length<65536&&(s.head.name+=String.fromCharCode(M));while(M&&p>9&1,s.head.done=!0),r.adler=s.check=0,s.mode=yl;break;case t2:for(;m<32;){if(c===0)break e;c--,h+=n[l++]<>>=m&7,m-=m&7,s.mode=Ag;break}for(;m<3;){if(c===0)break e;c--,h+=n[l++]<>>=1,m-=1,h&3){case 0:s.mode=r2;break;case 1:if(Ck(s),s.mode=Vf,t===Gf){h>>>=2,m-=2;break e}break;case 2:s.mode=a2;break;case 3:r.msg="invalid block type",s.mode=us}h>>>=2,m-=2;break;case r2:for(h>>>=m&7,m-=m&7;m<32;){if(c===0)break e;c--,h+=n[l++]<>>16^65535)){r.msg="invalid stored block lengths",s.mode=us;break}if(s.length=h&65535,h=0,m=0,s.mode=lg,t===Gf)break e;case lg:s.mode=s2;case s2:if(p=s.length,p){if(p>c&&(p=c),p>u&&(p=u),p===0)break e;o.set(n.subarray(l,l+p),d),c-=p,l+=p,u-=p,d+=p,s.length-=p;break}s.mode=yl;break;case a2:for(;m<14;){if(c===0)break e;c--,h+=n[l++]<>>=5,m-=5,s.ndist=(h&31)+1,h>>>=5,m-=5,s.ncode=(h&15)+4,h>>>=4,m-=4,s.nlen>286||s.ndist>30){r.msg="too many length or distance symbols",s.mode=us;break}s.have=0,s.mode=n2;case n2:for(;s.have>>=3,m-=3}for(;s.have<19;)s.lens[U[s.have++]]=0;if(s.lencode=s.lendyn,s.lenbits=7,ne={bits:s.lenbits},V=Bh(mk,s.lens,0,19,s.lencode,0,s.work,ne),s.lenbits=ne.bits,V){r.msg="invalid code lengths set",s.mode=us;break}s.have=0,s.mode=i2;case i2:for(;s.have>>24,j=B>>>16&255,_=B&65535,!(g<=m);){if(c===0)break e;c--,h+=n[l++]<>>=g,m-=g,s.lens[s.have++]=_;else{if(_===16){for(Z=g+2;m>>=g,m-=g,s.have===0){r.msg="invalid bit length repeat",s.mode=us;break}M=s.lens[s.have-1],p=3+(h&3),h>>>=2,m-=2}else if(_===17){for(Z=g+3;m>>=g,m-=g,M=0,p=3+(h&7),h>>>=3,m-=3}else{for(Z=g+7;m>>=g,m-=g,M=0,p=11+(h&127),h>>>=7,m-=7}if(s.have+p>s.nlen+s.ndist){r.msg="invalid bit length repeat",s.mode=us;break}for(;p--;)s.lens[s.have++]=M}}if(s.mode===us)break;if(s.lens[256]===0){r.msg="invalid code -- missing end-of-block",s.mode=us;break}if(s.lenbits=9,ne={bits:s.lenbits},V=Bh(_4,s.lens,0,s.nlen,s.lencode,0,s.work,ne),s.lenbits=ne.bits,V){r.msg="invalid literal/lengths set",s.mode=us;break}if(s.distbits=6,s.distcode=s.distdyn,ne={bits:s.distbits},V=Bh(k4,s.lens,s.nlen,s.ndist,s.distcode,0,s.work,ne),s.distbits=ne.bits,V){r.msg="invalid distances set",s.mode=us;break}if(s.mode=Vf,t===Gf)break e;case Vf:s.mode=Wf;case Wf:if(c>=6&&u>=258){r.next_out=d,r.avail_out=u,r.next_in=l,r.avail_in=c,s.hold=h,s.bits=m,Ak(r,y),d=r.next_out,o=r.output,u=r.avail_out,l=r.next_in,n=r.input,c=r.avail_in,h=s.hold,m=s.bits,s.mode===yl&&(s.back=-1);break}for(s.back=0;B=s.lencode[h&(1<>>24,j=B>>>16&255,_=B&65535,!(g<=m);){if(c===0)break e;c--,h+=n[l++]<>w)],g=B>>>24,j=B>>>16&255,_=B&65535,!(w+g<=m);){if(c===0)break e;c--,h+=n[l++]<>>=w,m-=w,s.back+=w}if(h>>>=g,m-=g,s.back+=g,s.length=_,j===0){s.mode=d2;break}if(j&32){s.back=-1,s.mode=yl;break}if(j&64){r.msg="invalid literal/length code",s.mode=us;break}s.extra=j&15,s.mode=o2;case o2:if(s.extra){for(Z=s.extra;m>>=s.extra,m-=s.extra,s.back+=s.extra}s.was=s.length,s.mode=l2;case l2:for(;B=s.distcode[h&(1<>>24,j=B>>>16&255,_=B&65535,!(g<=m);){if(c===0)break e;c--,h+=n[l++]<>w)],g=B>>>24,j=B>>>16&255,_=B&65535,!(w+g<=m);){if(c===0)break e;c--,h+=n[l++]<>>=w,m-=w,s.back+=w}if(h>>>=g,m-=g,s.back+=g,j&64){r.msg="invalid distance code",s.mode=us;break}s.offset=_,s.extra=j&15,s.mode=A2;case A2:if(s.extra){for(Z=s.extra;m>>=s.extra,m-=s.extra,s.back+=s.extra}if(s.offset>s.dmax){r.msg="invalid distance too far back",s.mode=us;break}s.mode=c2;case c2:if(u===0)break e;if(p=y-u,s.offset>p){if(p=s.offset-p,p>s.whave&&s.sane){r.msg="invalid distance too far back",s.mode=us;break}p>s.wnext?(p-=s.wnext,v=s.wsize-p):v=s.wnext-p,p>s.length&&(p=s.length),N=s.window}else N=o,v=d-s.offset,p=s.length;p>u&&(p=u),u-=p,s.length-=p;do o[d++]=N[v++];while(--p);s.length===0&&(s.mode=Wf);break;case d2:if(u===0)break e;o[d++]=s.length,u--,s.mode=Wf;break;case Ag:if(s.wrap){for(;m<32;){if(c===0)break e;c--,h|=n[l++]<{if(Tc(r))return ji;let t=r.state;return t.window&&(t.window=null),r.state=null,Qc},kk=(r,t)=>{if(Tc(r))return ji;const s=r.state;return(s.wrap&2)===0?ji:(s.head=t,t.done=!1,Qc)},Fk=(r,t)=>{const s=t.length;let n,o,l;return Tc(r)||(n=r.state,n.wrap!==0&&n.mode!==Zm)?ji:n.mode===Zm&&(o=1,o=Pb(o,t,s,0),o!==n.check)?F4:(l=R4(r,t,s,s),l?(n.mode=U4,E4):(n.havedict=1,Qc))};var Ek=T4,Uk=I4,Qk=L4,Lk=jk,Tk=D4,Ik=Sk,Dk=_k,Rk=kk,Ok=Fk,Hk="pako inflate (from Nodeca project)",jl={inflateReset:Ek,inflateReset2:Uk,inflateResetKeep:Qk,inflateInit:Lk,inflateInit2:Tk,inflate:Ik,inflateEnd:Dk,inflateGetHeader:Rk,inflateSetDictionary:Ok,inflateInfo:Hk};function Mk(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var Pk=Mk;const O4=Object.prototype.toString,{Z_NO_FLUSH:Kk,Z_FINISH:zk,Z_OK:Dh,Z_STREAM_END:ug,Z_NEED_DICT:hg,Z_STREAM_ERROR:qk,Z_DATA_ERROR:p2,Z_MEM_ERROR:Gk}=j4;function Kh(r){this.options=C4.assign({chunkSize:1024*64,windowBits:15,to:""},r||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(r&&r.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15)===0&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new ok,this.strm.avail_out=0;let s=jl.inflateInit2(this.strm,t.windowBits);if(s!==Dh)throw new Error(Kb[s]);if(this.header=new Pk,jl.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=zb.string2buf(t.dictionary):O4.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(s=jl.inflateSetDictionary(this.strm,t.dictionary),s!==Dh)))throw new Error(Kb[s])}Kh.prototype.push=function(r,t){const s=this.strm,n=this.options.chunkSize,o=this.options.dictionary;let l,d,c;if(this.ended)return!1;for(t===~~t?d=t:d=t===!0?zk:Kk,O4.call(r)==="[object ArrayBuffer]"?s.input=new Uint8Array(r):s.input=r,s.next_in=0,s.avail_in=s.input.length;;){for(s.avail_out===0&&(s.output=new Uint8Array(n),s.next_out=0,s.avail_out=n),l=jl.inflate(s,d),l===hg&&o&&(l=jl.inflateSetDictionary(s,o),l===Dh?l=jl.inflate(s,d):l===p2&&(l=hg));s.avail_in>0&&l===ug&&s.state.wrap>0&&r[s.next_in]!==0;)jl.inflateReset(s),l=jl.inflate(s,d);switch(l){case qk:case p2:case hg:case Gk:return this.onEnd(l),this.ended=!0,!1}if(c=s.avail_out,s.next_out&&(s.avail_out===0||l===ug))if(this.options.to==="string"){let u=zb.utf8border(s.output,s.next_out),h=s.next_out-u,m=zb.buf2string(s.output,u);s.next_out=h,s.avail_out=n-h,h&&s.output.set(s.output.subarray(u,u+h),0),this.onData(m)}else this.onData(s.output.length===s.next_out?s.output:s.output.subarray(0,s.next_out));if(!(l===Dh&&c===0)){if(l===ug)return l=jl.inflateEnd(this.strm),this.onEnd(l),this.ended=!0,!0;if(s.avail_in===0)break}}return!0};Kh.prototype.onData=function(r){this.chunks.push(r)};Kh.prototype.onEnd=function(r){r===Dh&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=C4.flattenChunks(this.chunks)),this.chunks=[],this.err=r,this.msg=this.strm.msg};function Vk(r,t){const s=new Kh(t);if(s.push(r),s.err)throw s.msg||Kb[s.err];return s.result}var Wk=Kh,Xk=Vk,Yk={Inflate:Wk,inflate:Xk};const{Inflate:Jk,inflate:Zk}=Yk;var x2=Jk,$k=Zk;const H4=[];for(let r=0;r<256;r++){let t=r;for(let s=0;s<8;s++)t&1?t=3988292384^t>>>1:t=t>>>1;H4[r]=t}const g2=4294967295;function eF(r,t,s){let n=r;for(let o=0;o>>8;return n}function tF(r,t){return(eF(g2,r,t)^g2)>>>0}function b2(r,t,s){const n=r.readUint32(),o=tF(new Uint8Array(r.buffer,r.byteOffset+r.offset-t-4,t),t);if(o!==n)throw new Error(`CRC mismatch for chunk ${s}. Expected ${n}, found ${o}`)}function M4(r,t,s){for(let n=0;n>1)&255}else{for(;l>1)&255;for(;l>1)&255}}function q4(r,t,s,n,o){let l=0;if(s.length===0){for(;l=s||K>=n))for(let M=0;M>8&255}const AF=new Uint16Array([255]),cF=new Uint8Array(AF.buffer),dF=cF[0]===255,uF=new Uint8Array(0);function y2(r){const{data:t,width:s,height:n,channels:o,depth:l}=r,d=Math.ceil(l/8)*o,c=Math.ceil(l/8*o*s),u=new Uint8Array(n*c);let h=uF,m=0,x,y;for(let p=0;p>8&255}const Dm=Uint8Array.of(137,80,78,71,13,10,26,10);function w2(r){if(!fF(r.readBytes(Dm.length)))throw new Error("wrong PNG signature")}function fF(r){if(r.length79)throw new Error("keyword length must be between 1 and 79")}const gF=/^[\u0000-\u00FF]*$/;function bF(r){if(!gF.test(r))throw new Error("invalid latin1 text")}function yF(r,t,s){const n=V4(t);r[n]=wF(t,s-n.length-1)}function V4(r){for(r.mark();r.readByte()!==pF;);const t=r.offset;r.reset();const s=G4.decode(r.readBytes(t-r.offset-1));return r.skip(1),xF(s),s}function wF(r,t){return G4.decode(r.readBytes(t))}const Gn={UNKNOWN:-1,GREYSCALE:0,TRUECOLOUR:2,INDEXED_COLOUR:3,GREYSCALE_ALPHA:4,TRUECOLOUR_ALPHA:6},fg={UNKNOWN:-1,DEFLATE:0},v2={UNKNOWN:-1,ADAPTIVE:0},mg={UNKNOWN:-1,NO_INTERLACE:0,ADAM7:1},Xf={NONE:0,BACKGROUND:1,PREVIOUS:2},pg={SOURCE:0,OVER:1};class vF extends Qy{_checkCrc;_inflator;_png;_apng;_end;_hasPalette;_palette;_hasTransparency;_transparency;_compressionMethod;_filterMethod;_interlaceMethod;_colorType;_isAnimated;_numberOfFrames;_numberOfPlays;_frames;_writingDataChunks;constructor(t,s={}){super(t);const{checkCrc:n=!1}=s;this._checkCrc=n,this._inflator=new x2,this._png={width:-1,height:-1,channels:-1,data:new Uint8Array(0),depth:1,text:{}},this._apng={width:-1,height:-1,channels:-1,depth:1,numberOfFrames:1,numberOfPlays:0,text:{},frames:[]},this._end=!1,this._hasPalette=!1,this._palette=[],this._hasTransparency=!1,this._transparency=new Uint16Array(0),this._compressionMethod=fg.UNKNOWN,this._filterMethod=v2.UNKNOWN,this._interlaceMethod=mg.UNKNOWN,this._colorType=Gn.UNKNOWN,this._isAnimated=!1,this._numberOfFrames=1,this._numberOfPlays=0,this._frames=[],this._writingDataChunks=!1,this.setBigEndian()}decode(){for(w2(this);!this._end;){const t=this.readUint32(),s=this.readChars(4);this.decodeChunk(t,s)}return this.decodeImage(),this._png}decodeApng(){for(w2(this);!this._end;){const t=this.readUint32(),s=this.readChars(4);this.decodeApngChunk(t,s)}return this.decodeApngImage(),this._apng}decodeChunk(t,s){const n=this.offset;switch(s){case"IHDR":this.decodeIHDR();break;case"PLTE":this.decodePLTE(t);break;case"IDAT":this.decodeIDAT(t);break;case"IEND":this._end=!0;break;case"tRNS":this.decodetRNS(t);break;case"iCCP":this.decodeiCCP(t);break;case mF:yF(this._png.text,this,t);break;case"pHYs":this.decodepHYs();break;default:this.skip(t);break}if(this.offset-n!==t)throw new Error(`Length mismatch while decoding chunk ${s}`);this._checkCrc?b2(this,t+4,s):this.skip(4)}decodeApngChunk(t,s){const n=this.offset;switch(s!=="fdAT"&&s!=="IDAT"&&this._writingDataChunks&&this.pushDataToFrame(),s){case"acTL":this.decodeACTL();break;case"fcTL":this.decodeFCTL();break;case"fdAT":this.decodeFDAT(t);break;default:this.decodeChunk(t,s),this.offset=n+t;break}if(this.offset-n!==t)throw new Error(`Length mismatch while decoding chunk ${s}`);this._checkCrc?b2(this,t+4,s):this.skip(4)}decodeIHDR(){const t=this._png;t.width=this.readUint32(),t.height=this.readUint32(),t.depth=NF(this.readUint8());const s=this.readUint8();this._colorType=s;let n;switch(s){case Gn.GREYSCALE:n=1;break;case Gn.TRUECOLOUR:n=3;break;case Gn.INDEXED_COLOUR:n=1;break;case Gn.GREYSCALE_ALPHA:n=2;break;case Gn.TRUECOLOUR_ALPHA:n=4;break;case Gn.UNKNOWN:default:throw new Error(`Unknown color type: ${s}`)}if(this._png.channels=n,this._compressionMethod=this.readUint8(),this._compressionMethod!==fg.DEFLATE)throw new Error(`Unsupported compression method: ${this._compressionMethod}`);this._filterMethod=this.readUint8(),this._interlaceMethod=this.readUint8()}decodeACTL(){this._numberOfFrames=this.readUint32(),this._numberOfPlays=this.readUint32(),this._isAnimated=!0}decodeFCTL(){const t={sequenceNumber:this.readUint32(),width:this.readUint32(),height:this.readUint32(),xOffset:this.readUint32(),yOffset:this.readUint32(),delayNumber:this.readUint16(),delayDenominator:this.readUint16(),disposeOp:this.readUint8(),blendOp:this.readUint8(),data:new Uint8Array(0)};this._frames.push(t)}decodePLTE(t){if(t%3!==0)throw new RangeError(`PLTE field length must be a multiple of 3. Got ${t}`);const s=t/3;this._hasPalette=!0;const n=[];this._palette=n;for(let o=0;othis._png.width*this._png.height)throw new Error(`tRNS chunk contains more alpha values than there are pixels (${t/2} vs ${this._png.width*this._png.height})`);this._hasTransparency=!0,this._transparency=new Uint16Array(t/2);for(let s=0;sthis._palette.length)throw new Error(`tRNS chunk contains more alpha values than there are palette colors (${t} vs ${this._palette.length})`);let s=0;for(;s{const c=((l+s.yOffset)*this._png.width+s.xOffset+d)*this._png.channels,u=(l*s.width+d)*this._png.channels;return{index:c,frameIndex:u}};switch(s.blendOp){case pg.SOURCE:for(let l=0;l=200&&t.status<=299}function Yf(r){try{r.dispatchEvent(new MouseEvent("click"))}catch{var t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),r.dispatchEvent(t)}}var mc=Wt.saveAs||((typeof window>"u"?"undefined":Yr(window))!=="object"||window!==Wt?function(){}:typeof HTMLAnchorElement<"u"&&"download"in HTMLAnchorElement.prototype?function(r,t,s){var n=Wt.URL||Wt.webkitURL,o=document.createElement("a");t=t||r.name||"download",o.download=t,o.rel="noopener",typeof r=="string"?(o.href=r,o.origin!==location.origin?B2(o.href)?gg(r,t,s):Yf(o,o.target="_blank"):Yf(o)):(o.href=n.createObjectURL(r),setTimeout(function(){n.revokeObjectURL(o.href)},4e4),setTimeout(function(){Yf(o)},0))}:"msSaveOrOpenBlob"in navigator?function(r,t,s){if(t=t||r.name||"download",typeof r=="string")if(B2(r))gg(r,t,s);else{var n=document.createElement("a");n.href=r,n.target="_blank",setTimeout(function(){Yf(n)})}else navigator.msSaveOrOpenBlob((function(o,l){return l===void 0?l={autoBom:!1}:Yr(l)!=="object"&&(Xr.warn("Deprecated: Expected third argument to be a object"),l={autoBom:!l}),l.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(o.type)?new Blob(["\uFEFF",o],{type:o.type}):o})(r,s),t)}:function(r,t,s,n){if((n=n||open("","_blank"))&&(n.document.title=n.document.body.innerText="downloading..."),typeof r=="string")return gg(r,t,s);var o=r.type==="application/octet-stream",l=/constructor/i.test(Wt.HTMLElement)||Wt.safari,d=/CriOS\/[\d]+/.test(navigator.userAgent);if((d||o&&l)&&(typeof FileReader>"u"?"undefined":Yr(FileReader))==="object"){var c=new FileReader;c.onloadend=function(){var m=c.result;m=d?m:m.replace(/^data:[^;]*;/,"data:attachment/file;"),n?n.location.href=m:location=m,n=null},c.readAsDataURL(r)}else{var u=Wt.URL||Wt.webkitURL,h=u.createObjectURL(r);n?n.location=h:location.href=h,n=null,setTimeout(function(){u.revokeObjectURL(h)},4e4)}});function W4(r){var t;r=r||"",this.ok=!1,r.charAt(0)=="#"&&(r=r.substr(1,6)),r={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dodgerblue:"1e90ff",feldspar:"d19275",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgrey:"d3d3d3",lightgreen:"90ee90",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslateblue:"8470ff",lightslategray:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370d8",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"d87093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",violetred:"d02090",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"}[r=(r=r.replace(/ /g,"")).toLowerCase()]||r;for(var s=[{re:/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,example:["rgb(123, 234, 45)","rgb(255,234,245)"],process:function(c){return[parseInt(c[1]),parseInt(c[2]),parseInt(c[3])]}},{re:/^(\w{2})(\w{2})(\w{2})$/,example:["#00ff00","336699"],process:function(c){return[parseInt(c[1],16),parseInt(c[2],16),parseInt(c[3],16)]}},{re:/^(\w{1})(\w{1})(\w{1})$/,example:["#fb0","f0f"],process:function(c){return[parseInt(c[1]+c[1],16),parseInt(c[2]+c[2],16),parseInt(c[3]+c[3],16)]}}],n=0;n255?255:this.r,this.g=this.g<0||isNaN(this.g)?0:this.g>255?255:this.g,this.b=this.b<0||isNaN(this.b)?0:this.b>255?255:this.b,this.toRGB=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"},this.toHex=function(){var c=this.r.toString(16),u=this.g.toString(16),h=this.b.toString(16);return c.length==1&&(c="0"+c),u.length==1&&(u="0"+u),h.length==1&&(h="0"+h),"#"+c+u+h}}var Rm=Wt.atob.bind(Wt),j2=Wt.btoa.bind(Wt);function bg(r,t){var s=r[0],n=r[1],o=r[2],l=r[3];s=Da(s,n,o,l,t[0],7,-680876936),l=Da(l,s,n,o,t[1],12,-389564586),o=Da(o,l,s,n,t[2],17,606105819),n=Da(n,o,l,s,t[3],22,-1044525330),s=Da(s,n,o,l,t[4],7,-176418897),l=Da(l,s,n,o,t[5],12,1200080426),o=Da(o,l,s,n,t[6],17,-1473231341),n=Da(n,o,l,s,t[7],22,-45705983),s=Da(s,n,o,l,t[8],7,1770035416),l=Da(l,s,n,o,t[9],12,-1958414417),o=Da(o,l,s,n,t[10],17,-42063),n=Da(n,o,l,s,t[11],22,-1990404162),s=Da(s,n,o,l,t[12],7,1804603682),l=Da(l,s,n,o,t[13],12,-40341101),o=Da(o,l,s,n,t[14],17,-1502002290),s=Ra(s,n=Da(n,o,l,s,t[15],22,1236535329),o,l,t[1],5,-165796510),l=Ra(l,s,n,o,t[6],9,-1069501632),o=Ra(o,l,s,n,t[11],14,643717713),n=Ra(n,o,l,s,t[0],20,-373897302),s=Ra(s,n,o,l,t[5],5,-701558691),l=Ra(l,s,n,o,t[10],9,38016083),o=Ra(o,l,s,n,t[15],14,-660478335),n=Ra(n,o,l,s,t[4],20,-405537848),s=Ra(s,n,o,l,t[9],5,568446438),l=Ra(l,s,n,o,t[14],9,-1019803690),o=Ra(o,l,s,n,t[3],14,-187363961),n=Ra(n,o,l,s,t[8],20,1163531501),s=Ra(s,n,o,l,t[13],5,-1444681467),l=Ra(l,s,n,o,t[2],9,-51403784),o=Ra(o,l,s,n,t[7],14,1735328473),s=Oa(s,n=Ra(n,o,l,s,t[12],20,-1926607734),o,l,t[5],4,-378558),l=Oa(l,s,n,o,t[8],11,-2022574463),o=Oa(o,l,s,n,t[11],16,1839030562),n=Oa(n,o,l,s,t[14],23,-35309556),s=Oa(s,n,o,l,t[1],4,-1530992060),l=Oa(l,s,n,o,t[4],11,1272893353),o=Oa(o,l,s,n,t[7],16,-155497632),n=Oa(n,o,l,s,t[10],23,-1094730640),s=Oa(s,n,o,l,t[13],4,681279174),l=Oa(l,s,n,o,t[0],11,-358537222),o=Oa(o,l,s,n,t[3],16,-722521979),n=Oa(n,o,l,s,t[6],23,76029189),s=Oa(s,n,o,l,t[9],4,-640364487),l=Oa(l,s,n,o,t[12],11,-421815835),o=Oa(o,l,s,n,t[15],16,530742520),s=Ha(s,n=Oa(n,o,l,s,t[2],23,-995338651),o,l,t[0],6,-198630844),l=Ha(l,s,n,o,t[7],10,1126891415),o=Ha(o,l,s,n,t[14],15,-1416354905),n=Ha(n,o,l,s,t[5],21,-57434055),s=Ha(s,n,o,l,t[12],6,1700485571),l=Ha(l,s,n,o,t[3],10,-1894986606),o=Ha(o,l,s,n,t[10],15,-1051523),n=Ha(n,o,l,s,t[1],21,-2054922799),s=Ha(s,n,o,l,t[8],6,1873313359),l=Ha(l,s,n,o,t[15],10,-30611744),o=Ha(o,l,s,n,t[6],15,-1560198380),n=Ha(n,o,l,s,t[13],21,1309151649),s=Ha(s,n,o,l,t[4],6,-145523070),l=Ha(l,s,n,o,t[11],10,-1120210379),o=Ha(o,l,s,n,t[2],15,718787259),n=Ha(n,o,l,s,t[9],21,-343485551),r[0]=wA(s,r[0]),r[1]=wA(n,r[1]),r[2]=wA(o,r[2]),r[3]=wA(l,r[3])}function gp(r,t,s,n,o,l){return t=wA(wA(t,r),wA(n,l)),wA(t<>>32-o,s)}function Da(r,t,s,n,o,l,d){return gp(t&s|~t&n,r,t,o,l,d)}function Ra(r,t,s,n,o,l,d){return gp(t&n|s&~n,r,t,o,l,d)}function Oa(r,t,s,n,o,l,d){return gp(t^s^n,r,t,o,l,d)}function Ha(r,t,s,n,o,l,d){return gp(s^(t|~n),r,t,o,l,d)}function X4(r){var t,s=r.length,n=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=r.length;t+=64)bg(n,jF(r.substring(t-64,t)));r=r.substring(t-64);var o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t>2]|=r.charCodeAt(t)<<(t%4<<3);if(o[t>>2]|=128<<(t%4<<3),t>55)for(bg(n,o),t=0;t<16;t++)o[t]=0;return o[14]=8*s,bg(n,o),n}function jF(r){var t,s=[];for(t=0;t<64;t+=4)s[t>>2]=r.charCodeAt(t)+(r.charCodeAt(t+1)<<8)+(r.charCodeAt(t+2)<<16)+(r.charCodeAt(t+3)<<24);return s}var C2="0123456789abcdef".split("");function CF(r){for(var t="",s=0;s<4;s++)t+=C2[r>>8*s+4&15]+C2[r>>8*s&15];return t}function SF(r){return String.fromCharCode(255&r,(65280&r)>>8,(16711680&r)>>16,(4278190080&r)>>24)}function qb(r){return X4(r).map(SF).join("")}var _F=(function(r){for(var t=0;t>16)+(t>>16)+(s>>16)<<16|65535&s}return r+t&4294967295}function Gb(r,t){var s,n,o,l;if(r!==s){for(var d=(o=r,l=1+(256/r.length|0),new Array(l+1).join(o)),c=[],u=0;u<256;u++)c[u]=u;var h=0;for(u=0;u<256;u++){var m=c[u];h=(h+m+d.charCodeAt(u))%256,c[u]=c[h],c[h]=m}s=r,n=c}else c=n;var x=t.length,y=0,p=0,v="";for(u=0;u€/\f©þdSiz";var l=(t+this.padding).substr(0,32),d=(s+this.padding).substr(0,32);this.O=this.processOwnerPassword(l,d),this.P=-(1+(255^o)),this.encryptionKey=qb(l+this.O+this.lsbFirstWord(this.P)+this.hexToBytes(n)).substr(0,5),this.U=Gb(this.encryptionKey,this.padding)}function Md(r){if(/[^\u0000-\u00ff]/.test(r))throw new Error("Invalid PDF Name Object: "+r+", Only accept ASCII characters.");for(var t="",s=r.length,n=0;n126?"#"+("0"+o.toString(16)).slice(-2):r[n]}return t}function _2(r){if(Yr(r)!=="object")throw new Error("Invalid Context passed to initialize PubSub (jsPDF-module)");var t={};this.subscribe=function(s,n,o){if(o=o||!1,typeof s!="string"||typeof n!="function"||typeof o!="boolean")throw new Error("Invalid arguments passed to PubSub.subscribe (jsPDF-module)");t.hasOwnProperty(s)||(t[s]={});var l=Math.random().toString(35);return t[s][l]=[n,!!o],l},this.unsubscribe=function(s){for(var n in t)if(t[n][s])return delete t[n][s],Object.keys(t[n]).length===0&&delete t[n],!0;return!1},this.publish=function(s){if(t.hasOwnProperty(s)){var n=Array.prototype.slice.call(arguments,1),o=[];for(var l in t[s]){var d=t[s][l];try{d[0].apply(r,n)}catch(c){Wt.console&&Xr.error("jsPDF PubSub Error",c.message,c)}d[1]&&o.push(l)}o.length&&o.forEach(this.unsubscribe)}},this.getTopics=function(){return t}}function $m(r){if(!(this instanceof $m))return new $m(r);var t="opacity,stroke-opacity".split(",");for(var s in r)r.hasOwnProperty(s)&&t.indexOf(s)>=0&&(this[s]=r[s]);this.id="",this.objectNumber=-1}function Y4(r,t){this.gState=r,this.matrix=t,this.id="",this.objectNumber=-1}function pc(r,t,s,n,o){if(!(this instanceof pc))return new pc(r,t,s,n,o);this.type=r==="axial"?2:3,this.coords=t,this.colors=s,Y4.call(this,n,o)}function qd(r,t,s,n,o){if(!(this instanceof qd))return new qd(r,t,s,n,o);this.boundingBox=r,this.xStep=t,this.yStep=s,this.stream="",this.cloneIndex=0,Y4.call(this,n,o)}function Ft(r){var t,s=typeof arguments[0]=="string"?arguments[0]:"p",n=arguments[1],o=arguments[2],l=arguments[3],d=[],c=1,u=16,h="S",m=null;Yr(r=r||{})==="object"&&(s=r.orientation,n=r.unit||n,o=r.format||o,l=r.compress||r.compressPdf||l,(m=r.encryption||null)!==null&&(m.userPassword=m.userPassword||"",m.ownerPassword=m.ownerPassword||"",m.userPermissions=m.userPermissions||[]),c=typeof r.userUnit=="number"?Math.abs(r.userUnit):1,r.precision!==void 0&&(t=r.precision),r.floatPrecision!==void 0&&(u=r.floatPrecision),h=r.defaultPathOperation||"S"),d=r.filters||(l===!0?["FlateEncode"]:d),n=n||"mm",s=(""+(s||"P")).toLowerCase();var x=r.putOnlyUsedFonts||!1,y={},p={internal:{},__private__:{}};p.__private__.PubSub=_2;var v="1.3",N=p.__private__.getPdfVersion=function(){return v};p.__private__.setPdfVersion=function(R){v=R};var B={a0:[2383.94,3370.39],a1:[1683.78,2383.94],a2:[1190.55,1683.78],a3:[841.89,1190.55],a4:[595.28,841.89],a5:[419.53,595.28],a6:[297.64,419.53],a7:[209.76,297.64],a8:[147.4,209.76],a9:[104.88,147.4],a10:[73.7,104.88],b0:[2834.65,4008.19],b1:[2004.09,2834.65],b2:[1417.32,2004.09],b3:[1000.63,1417.32],b4:[708.66,1000.63],b5:[498.9,708.66],b6:[354.33,498.9],b7:[249.45,354.33],b8:[175.75,249.45],b9:[124.72,175.75],b10:[87.87,124.72],c0:[2599.37,3676.54],c1:[1836.85,2599.37],c2:[1298.27,1836.85],c3:[918.43,1298.27],c4:[649.13,918.43],c5:[459.21,649.13],c6:[323.15,459.21],c7:[229.61,323.15],c8:[161.57,229.61],c9:[113.39,161.57],c10:[79.37,113.39],dl:[311.81,623.62],letter:[612,792],"government-letter":[576,756],legal:[612,1008],"junior-legal":[576,360],ledger:[1224,792],tabloid:[792,1224],"credit-card":[153,243]};p.__private__.getPageFormats=function(){return B};var g=p.__private__.getPageFormat=function(R){return B[R]};o=o||"a4";var j="compat",_="advanced",w=j;function L(){this.saveGraphicsState(),ie(new Et(Tt,0,0,-Tt,0,Ti()*Tt).toString()+" cm"),this.setFontSize(this.getFontSize()/Tt),h="n",w=_}function K(){this.restoreGraphicsState(),h="S",w=j}var M=p.__private__.combineFontStyleAndFontWeight=function(R,de){if(R=="bold"&&de=="normal"||R=="bold"&&de==400||R=="normal"&&de=="italic"||R=="bold"&&de=="italic")throw new Error("Invalid Combination of fontweight and fontstyle");return de&&(R=de==400||de==="normal"?R==="italic"?"italic":"normal":de!=700&&de!=="bold"||R!=="normal"?(de==700?"bold":de)+""+R:"bold"),R};p.advancedAPI=function(R){var de=w===j;return de&&L.call(this),typeof R!="function"||(R(this),de&&K.call(this)),this},p.compatAPI=function(R){var de=w===_;return de&&K.call(this),typeof R!="function"||(R(this),de&&L.call(this)),this},p.isAdvancedAPI=function(){return w===_};var V,T=function(R){if(w!==_)throw new Error(R+" is only available in 'advanced' API mode. You need to call advancedAPI() first.")},ne=p.roundToPrecision=p.__private__.roundToPrecision=function(R,de){var je=t||de;if(isNaN(R)||isNaN(je))throw new Error("Invalid argument passed to jsPDF.roundToPrecision");return R.toFixed(je).replace(/0+$/,"")};V=p.hpf=p.__private__.hpf=typeof u=="number"?function(R){if(isNaN(R))throw new Error("Invalid argument passed to jsPDF.hpf");return ne(R,u)}:u==="smart"?function(R){if(isNaN(R))throw new Error("Invalid argument passed to jsPDF.hpf");return ne(R,R>-1&&R<1?16:5)}:function(R){if(isNaN(R))throw new Error("Invalid argument passed to jsPDF.hpf");return ne(R,16)};var Z=p.f2=p.__private__.f2=function(R){if(isNaN(R))throw new Error("Invalid argument passed to jsPDF.f2");return ne(R,2)},U=p.__private__.f3=function(R){if(isNaN(R))throw new Error("Invalid argument passed to jsPDF.f3");return ne(R,3)},q=p.scale=p.__private__.scale=function(R){if(isNaN(R))throw new Error("Invalid argument passed to jsPDF.scale");return w===j?R*Tt:w===_?R:void 0},F=function(R){return q((function(de){return w===j?Ti()-de:w===_?de:void 0})(R))};p.__private__.setPrecision=p.setPrecision=function(R){typeof parseInt(R,10)=="number"&&(t=parseInt(R,10))};var le,ae="00000000000000000000000000000000",se=p.__private__.getFileId=function(){return ae},fe=p.__private__.setFileId=function(R){return ae=R!==void 0&&/^[a-fA-F0-9]{32}$/.test(R)?R.toUpperCase():ae.split("").map(function(){return"ABCDEF0123456789".charAt(Math.floor(16*Math.random()))}).join(""),m!==null&&(Ls=new Hd(m.userPermissions,m.userPassword,m.ownerPassword,ae)),ae};p.setFileId=function(R){return fe(R),this},p.getFileId=function(){return se()};var ye=p.__private__.convertDateToPDFDate=function(R){var de=R.getTimezoneOffset(),je=de<0?"+":"-",Fe=Math.floor(Math.abs(de/60)),Te=Math.abs(de%60),Je=[je,X(Fe),"'",X(Te),"'"].join("");return["D:",R.getFullYear(),X(R.getMonth()+1),X(R.getDate()),X(R.getHours()),X(R.getMinutes()),X(R.getSeconds()),Je].join("")},_e=p.__private__.convertPDFDateToDate=function(R){var de=parseInt(R.substr(2,4),10),je=parseInt(R.substr(6,2),10)-1,Fe=parseInt(R.substr(8,2),10),Te=parseInt(R.substr(10,2),10),Je=parseInt(R.substr(12,2),10),at=parseInt(R.substr(14,2),10);return new Date(de,je,Fe,Te,Je,at,0)},xe=p.__private__.setCreationDate=function(R){var de;if(R===void 0&&(R=new Date),R instanceof Date)de=ye(R);else{if(!/^D:(20[0-2][0-9]|203[0-7]|19[7-9][0-9])(0[0-9]|1[0-2])([0-2][0-9]|3[0-1])(0[0-9]|1[0-9]|2[0-3])(0[0-9]|[1-5][0-9])(0[0-9]|[1-5][0-9])(\+0[0-9]|\+1[0-4]|-0[0-9]|-1[0-1])'(0[0-9]|[1-5][0-9])'?$/.test(R))throw new Error("Invalid argument passed to jsPDF.setCreationDate");de=R}return le=de},D=p.__private__.getCreationDate=function(R){var de=le;return R==="jsDate"&&(de=_e(le)),de};p.setCreationDate=function(R){return xe(R),this},p.getCreationDate=function(R){return D(R)};var $,X=p.__private__.padd2=function(R){return("0"+parseInt(R)).slice(-2)},te=p.__private__.padd2Hex=function(R){return("00"+(R=R.toString())).substr(R.length)},J=0,O=[],H=[],re=0,Ae=[],oe=[],ce=!1,Se=H;p.__private__.setCustomOutputDestination=function(R){ce=!0,Se=R};var z=function(R){ce||(Se=R)};p.__private__.resetCustomOutputDestination=function(){ce=!1,Se=H};var ie=p.__private__.out=function(R){return R=R.toString(),re+=R.length+1,Se.push(R),Se},W=p.__private__.write=function(R){return ie(arguments.length===1?R.toString():Array.prototype.join.call(arguments," "))},Q=p.__private__.getArrayBuffer=function(R){for(var de=R.length,je=new ArrayBuffer(de),Fe=new Uint8Array(je);de--;)Fe[de]=R.charCodeAt(de);return je},I=[["Helvetica","helvetica","normal","WinAnsiEncoding"],["Helvetica-Bold","helvetica","bold","WinAnsiEncoding"],["Helvetica-Oblique","helvetica","italic","WinAnsiEncoding"],["Helvetica-BoldOblique","helvetica","bolditalic","WinAnsiEncoding"],["Courier","courier","normal","WinAnsiEncoding"],["Courier-Bold","courier","bold","WinAnsiEncoding"],["Courier-Oblique","courier","italic","WinAnsiEncoding"],["Courier-BoldOblique","courier","bolditalic","WinAnsiEncoding"],["Times-Roman","times","normal","WinAnsiEncoding"],["Times-Bold","times","bold","WinAnsiEncoding"],["Times-Italic","times","italic","WinAnsiEncoding"],["Times-BoldItalic","times","bolditalic","WinAnsiEncoding"],["ZapfDingbats","zapfdingbats","normal",null],["Symbol","symbol","normal",null]];p.__private__.getStandardFonts=function(){return I};var k=r.fontSize||16;p.__private__.setFontSize=p.setFontSize=function(R){return k=w===_?R/Tt:R,this};var G,me=p.__private__.getFontSize=p.getFontSize=function(){return w===j?k:k*Tt},be=r.R2L||!1;p.__private__.setR2L=p.setR2L=function(R){return be=R,this},p.__private__.getR2L=p.getR2L=function(){return be};var Ue,Re=p.__private__.setZoomMode=function(R){if(/^(?:\d+\.\d*|\d*\.\d+|\d+)%$/.test(R))G=R;else if(isNaN(R)){if([void 0,null,"fullwidth","fullheight","fullpage","original"].indexOf(R)===-1)throw new Error('zoom must be Integer (e.g. 2), a percentage Value (e.g. 300%) or fullwidth, fullheight, fullpage, original. "'+R+'" is not recognized.');G=R}else G=parseInt(R,10)};p.__private__.getZoomMode=function(){return G};var He,Ve=p.__private__.setPageMode=function(R){if([void 0,null,"UseNone","UseOutlines","UseThumbs","FullScreen"].indexOf(R)==-1)throw new Error('Page mode must be one of UseNone, UseOutlines, UseThumbs, or FullScreen. "'+R+'" is not recognized.');Ue=R};p.__private__.getPageMode=function(){return Ue};var it=p.__private__.setLayoutMode=function(R){if([void 0,null,"continuous","single","twoleft","tworight","two"].indexOf(R)==-1)throw new Error('Layout mode must be one of continuous, single, twoleft, tworight. "'+R+'" is not recognized.');He=R};p.__private__.getLayoutMode=function(){return He},p.__private__.setDisplayMode=p.setDisplayMode=function(R,de,je){return Re(R),it(de),Ve(je),this};var lt={title:"",subject:"",author:"",keywords:"",creator:""};p.__private__.getDocumentProperty=function(R){if(Object.keys(lt).indexOf(R)===-1)throw new Error("Invalid argument passed to jsPDF.getDocumentProperty");return lt[R]},p.__private__.getDocumentProperties=function(){return lt},p.__private__.setDocumentProperties=p.setProperties=p.setDocumentProperties=function(R){for(var de in lt)lt.hasOwnProperty(de)&&R[de]&&(lt[de]=R[de]);return this},p.__private__.setDocumentProperty=function(R,de){if(Object.keys(lt).indexOf(R)===-1)throw new Error("Invalid arguments passed to jsPDF.setDocumentProperty");return lt[R]=de};var ut,Tt,mt,Ur,jt,_t={},Dt={},Gt=[],kt={},Fr={},It={},Pt={},Br=null,zt=0,Bt=[],cr=new _2(p),_n=r.hotfixes||[],Aa={},Xn={},an=[],Et=function R(de,je,Fe,Te,Je,at){if(!(this instanceof R))return new R(de,je,Fe,Te,Je,at);isNaN(de)&&(de=1),isNaN(je)&&(je=0),isNaN(Fe)&&(Fe=0),isNaN(Te)&&(Te=1),isNaN(Je)&&(Je=0),isNaN(at)&&(at=0),this._matrix=[de,je,Fe,Te,Je,at]};Object.defineProperty(Et.prototype,"sx",{get:function(){return this._matrix[0]},set:function(R){this._matrix[0]=R}}),Object.defineProperty(Et.prototype,"shy",{get:function(){return this._matrix[1]},set:function(R){this._matrix[1]=R}}),Object.defineProperty(Et.prototype,"shx",{get:function(){return this._matrix[2]},set:function(R){this._matrix[2]=R}}),Object.defineProperty(Et.prototype,"sy",{get:function(){return this._matrix[3]},set:function(R){this._matrix[3]=R}}),Object.defineProperty(Et.prototype,"tx",{get:function(){return this._matrix[4]},set:function(R){this._matrix[4]=R}}),Object.defineProperty(Et.prototype,"ty",{get:function(){return this._matrix[5]},set:function(R){this._matrix[5]=R}}),Object.defineProperty(Et.prototype,"a",{get:function(){return this._matrix[0]},set:function(R){this._matrix[0]=R}}),Object.defineProperty(Et.prototype,"b",{get:function(){return this._matrix[1]},set:function(R){this._matrix[1]=R}}),Object.defineProperty(Et.prototype,"c",{get:function(){return this._matrix[2]},set:function(R){this._matrix[2]=R}}),Object.defineProperty(Et.prototype,"d",{get:function(){return this._matrix[3]},set:function(R){this._matrix[3]=R}}),Object.defineProperty(Et.prototype,"e",{get:function(){return this._matrix[4]},set:function(R){this._matrix[4]=R}}),Object.defineProperty(Et.prototype,"f",{get:function(){return this._matrix[5]},set:function(R){this._matrix[5]=R}}),Object.defineProperty(Et.prototype,"rotation",{get:function(){return Math.atan2(this.shx,this.sx)}}),Object.defineProperty(Et.prototype,"scaleX",{get:function(){return this.decompose().scale.sx}}),Object.defineProperty(Et.prototype,"scaleY",{get:function(){return this.decompose().scale.sy}}),Object.defineProperty(Et.prototype,"isIdentity",{get:function(){return this.sx===1&&this.shy===0&&this.shx===0&&this.sy===1&&this.tx===0&&this.ty===0}}),Et.prototype.join=function(R){return[this.sx,this.shy,this.shx,this.sy,this.tx,this.ty].map(V).join(R)},Et.prototype.multiply=function(R){var de=R.sx*this.sx+R.shy*this.shx,je=R.sx*this.shy+R.shy*this.sy,Fe=R.shx*this.sx+R.sy*this.shx,Te=R.shx*this.shy+R.sy*this.sy,Je=R.tx*this.sx+R.ty*this.shx+this.tx,at=R.tx*this.shy+R.ty*this.sy+this.ty;return new Et(de,je,Fe,Te,Je,at)},Et.prototype.decompose=function(){var R=this.sx,de=this.shy,je=this.shx,Fe=this.sy,Te=this.tx,Je=this.ty,at=Math.sqrt(R*R+de*de),yt=(R/=at)*je+(de/=at)*Fe;je-=R*yt,Fe-=de*yt;var Ct=Math.sqrt(je*je+Fe*Fe);return yt/=Ct,R*(Fe/=Ct)>16&255,Fe=Ct>>8&255,Te=255&Ct}if(Fe===void 0||Je===void 0&&je===Fe&&Fe===Te)de=typeof je=="string"?je+" "+at[0]:R.precision===2?Z(je/255)+" "+at[0]:U(je/255)+" "+at[0];else if(Je===void 0||Yr(Je)==="object"){if(Je&&!isNaN(Je.a)&&Je.a===0)return["1.","1.","1.",at[1]].join(" ");de=typeof je=="string"?[je,Fe,Te,at[1]].join(" "):R.precision===2?[Z(je/255),Z(Fe/255),Z(Te/255),at[1]].join(" "):[U(je/255),U(Fe/255),U(Te/255),at[1]].join(" ")}else de=typeof je=="string"?[je,Fe,Te,Je,at[2]].join(" "):R.precision===2?[Z(je),Z(Fe),Z(Te),Z(Je),at[2]].join(" "):[U(je),U(Fe),U(Te),U(Je),at[2]].join(" ");return de},Va=p.__private__.getFilters=function(){return d},nn=p.__private__.putStream=function(R){var de=(R=R||{}).data||"",je=R.filters||Va(),Fe=R.alreadyAppliedFilters||[],Te=R.addLength1||!1,Je=de.length,at=R.objectId,yt=function(Ts){return Ts};if(m!==null&&at===void 0)throw new Error("ObjectId must be passed to putStream for file encryption");m!==null&&(yt=Ls.encryptor(at,0));var Ct={};je===!0&&(je=["FlateEncode"]);var Kt=R.additionalKeyValues||[],Yt=(Ct=Ft.API.processDataByFilters!==void 0?Ft.API.processDataByFilters(de,je):{data:de,reverseChain:[]}).reverseChain+(Array.isArray(Fe)?Fe.join(" "):Fe.toString());if(Ct.data.length!==0&&(Kt.push({key:"Length",value:Ct.data.length}),Te===!0&&Kt.push({key:"Length1",value:Je})),Yt.length!=0)if(Yt.split("/").length-1==1)Kt.push({key:"Filter",value:Yt});else{Kt.push({key:"Filter",value:"["+Yt+"]"});for(var dr=0;dr>"),Ct.data.length!==0&&(ie("stream"),ie(yt(Ct.data)),ie("endstream"))},qo=p.__private__.putPage=function(R){var de=R.number,je=R.data,Fe=R.objId,Te=R.contentsObjId;qs(Fe,!0),ie("<>"),ie("endobj");var Je=je.join(` `);return w===_&&(Je+=` Q`),qs(Te,!0),nn({data:Je,filters:Va(),objectId:Te}),ie("endobj"),Fe},kn=p.__private__.putPages=function(){var R,de,je=[];for(R=1;R<=zt;R++)Bt[R].objId=ws(),Bt[R].contentsObjId=ws();for(R=1;R<=zt;R++)je.push(qo({number:R,data:oe[R],objId:Bt[R].objId,contentsObjId:Bt[R].contentsObjId,mediaBox:Bt[R].mediaBox,cropBox:Bt[R].cropBox,bleedBox:Bt[R].bleedBox,trimBox:Bt[R].trimBox,artBox:Bt[R].artBox,userUnit:Bt[R].userUnit,rootDictionaryObjId:wa,resourceDictionaryObjId:Qr}));qs(wa,!0),ie("<>"),ie("endobj"),cr.publish("postPutPages")},Fn=function(R){cr.publish("putFont",{font:R,out:ie,newObject:Jr,putStream:nn}),R.isAlreadyPutted!==!0&&(R.objectNumber=Jr(),ie("<<"),ie("/Type /Font"),ie("/BaseFont /"+Md(R.postScriptName)),ie("/Subtype /Type1"),typeof R.encoding=="string"&&ie("/Encoding /"+R.encoding),ie("/FirstChar 32"),ie("/LastChar 255"),ie(">>"),ie("endobj"))},uo=function(R){R.objectNumber=Jr();var de=[];de.push({key:"Type",value:"/XObject"}),de.push({key:"Subtype",value:"/Form"}),de.push({key:"BBox",value:"["+[V(R.x),V(R.y),V(R.x+R.width),V(R.y+R.height)].join(" ")+"]"}),de.push({key:"Matrix",value:"["+R.matrix.toString()+"]"});var je=R.pages[1].join(` `);nn({data:je,additionalKeyValues:de,objectId:R.objectNumber}),ie("endobj")},En=function(R,de){de||(de=21);var je=Jr(),Fe=(function(at,yt){var Ct,Kt=[],Yt=1/(yt-1);for(Ct=0;Ct<1;Ct+=Yt)Kt.push(Ct);if(Kt.push(1),at[0].offset!=0){var dr={offset:0,color:at[0].color};at.unshift(dr)}if(at[at.length-1].offset!=1){var rs={offset:1,color:at[at.length-1].color};at.push(rs)}for(var ms="",Dr=0,Ts=0;Tsat[Dr+1].offset;)Dr++;var Ns=at[Dr].offset,ea=(Ct-Ns)/(at[Dr+1].offset-Ns),Ii=at[Dr].color,Dn=at[Dr+1].color;ms+=te(Math.round((1-ea)*Ii[0]+ea*Dn[0]).toString(16))+te(Math.round((1-ea)*Ii[1]+ea*Dn[1]).toString(16))+te(Math.round((1-ea)*Ii[2]+ea*Dn[2]).toString(16))}return ms.trim()})(R.colors,de),Te=[];Te.push({key:"FunctionType",value:"0"}),Te.push({key:"Domain",value:"[0.0 1.0]"}),Te.push({key:"Size",value:"["+de+"]"}),Te.push({key:"BitsPerSample",value:"8"}),Te.push({key:"Range",value:"[0.0 1.0 0.0 1.0 0.0 1.0]"}),Te.push({key:"Decode",value:"[0.0 1.0 0.0 1.0 0.0 1.0]"}),nn({data:Fe,additionalKeyValues:Te,alreadyAppliedFilters:["/ASCIIHexDecode"],objectId:je}),ie("endobj"),R.objectNumber=Jr(),ie("<< /ShadingType "+R.type),ie("/ColorSpace /DeviceRGB");var Je="/Coords ["+V(parseFloat(R.coords[0]))+" "+V(parseFloat(R.coords[1]))+" ";R.type===2?Je+=V(parseFloat(R.coords[2]))+" "+V(parseFloat(R.coords[3])):Je+=V(parseFloat(R.coords[2]))+" "+V(parseFloat(R.coords[3]))+" "+V(parseFloat(R.coords[4]))+" "+V(parseFloat(R.coords[5])),ie(Je+="]"),R.matrix&&ie("/Matrix ["+R.matrix.toString()+"]"),ie("/Function "+je+" 0 R"),ie("/Extend [true true]"),ie(">>"),ie("endobj")},Un=function(R,de){var je=ws(),Fe=Jr();de.push({resourcesOid:je,objectOid:Fe}),R.objectNumber=Fe;var Te=[];Te.push({key:"Type",value:"/Pattern"}),Te.push({key:"PatternType",value:"1"}),Te.push({key:"PaintType",value:"1"}),Te.push({key:"TilingType",value:"1"}),Te.push({key:"BBox",value:"["+R.boundingBox.map(V).join(" ")+"]"}),Te.push({key:"XStep",value:V(R.xStep)}),Te.push({key:"YStep",value:V(R.yStep)}),Te.push({key:"Resources",value:je+" 0 R"}),R.matrix&&Te.push({key:"Matrix",value:"["+R.matrix.toString()+"]"}),nn({data:R.stream,additionalKeyValues:Te,objectId:R.objectNumber}),ie("endobj")},Go=function(R){for(var de in R.objectNumber=Jr(),ie("<<"),R)switch(de){case"opacity":ie("/ca "+Z(R[de]));break;case"stroke-opacity":ie("/CA "+Z(R[de]))}ie(">>"),ie("endobj")},Jn=function(R){qs(R.resourcesOid,!0),ie("<<"),ie("/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]"),(function(){for(var de in ie("/Font <<"),_t)_t.hasOwnProperty(de)&&(x===!1||x===!0&&y.hasOwnProperty(de))&&ie("/"+de+" "+_t[de].objectNumber+" 0 R");ie(">>")})(),(function(){if(Object.keys(kt).length>0){for(var de in ie("/Shading <<"),kt)kt.hasOwnProperty(de)&&kt[de]instanceof pc&&kt[de].objectNumber>=0&&ie("/"+de+" "+kt[de].objectNumber+" 0 R");cr.publish("putShadingPatternDict"),ie(">>")}})(),(function(de){if(Object.keys(kt).length>0){for(var je in ie("/Pattern <<"),kt)kt.hasOwnProperty(je)&&kt[je]instanceof p.TilingPattern&&kt[je].objectNumber>=0&&kt[je].objectNumber>")}})(R.objectOid),(function(){if(Object.keys(It).length>0){var de;for(de in ie("/ExtGState <<"),It)It.hasOwnProperty(de)&&It[de].objectNumber>=0&&ie("/"+de+" "+It[de].objectNumber+" 0 R");cr.publish("putGStateDict"),ie(">>")}})(),(function(){for(var de in ie("/XObject <<"),Aa)Aa.hasOwnProperty(de)&&Aa[de].objectNumber>=0&&ie("/"+de+" "+Aa[de].objectNumber+" 0 R");cr.publish("putXobjectDict"),ie(">>")})(),ie(">>"),ie("endobj")},fs=function(R){Dt[R.fontName]=Dt[R.fontName]||{},Dt[R.fontName][R.fontStyle]=R.id},UA=function(R,de,je,Fe,Te){var Je={id:"F"+(Object.keys(_t).length+1).toString(10),postScriptName:R,fontName:de,fontStyle:je,encoding:Fe,isStandardFont:Te||!1,metadata:{}};return cr.publish("addFont",{font:Je,instance:this}),_t[Je.id]=Je,fs(Je),Je.id},Wa=p.__private__.pdfEscape=p.pdfEscape=function(R,de){return(function(je,Fe){var Te,Je,at,yt,Ct,Kt,Yt,dr,rs;if(at=(Fe=Fe||{}).sourceEncoding||"Unicode",Ct=Fe.outputEncoding,(Fe.autoencode||Ct)&&_t[ut].metadata&&_t[ut].metadata[at]&&_t[ut].metadata[at].encoding&&(yt=_t[ut].metadata[at].encoding,!Ct&&_t[ut].encoding&&(Ct=_t[ut].encoding),!Ct&&yt.codePages&&(Ct=yt.codePages[0]),typeof Ct=="string"&&(Ct=yt[Ct]),Ct)){for(Yt=!1,Kt=[],Te=0,Je=je.length;Te>8&&(Yt=!0);je=Kt.join("")}for(Te=je.length;Yt===void 0&&Te!==0;)je.charCodeAt(Te-1)>>8&&(Yt=!0),Te--;if(!Yt)return je;for(Kt=Fe.noBOM?[]:[254,255],Te=0,Je=je.length;Te>8)>>8)throw new Error("Character at position "+Te+" of string '"+je+"' exceeds 16bits. Cannot be encoded into UCS-2 BE");Kt.push(rs),Kt.push(dr-(rs<<8))}return String.fromCharCode.apply(void 0,Kt)})(R,de).replace(/\\/g,"\\\\").replace(/\(/g,"\\(").replace(/\)/g,"\\)")},Qn=p.__private__.beginPage=function(R){oe[++zt]=[],Bt[zt]={objId:0,contentsObjId:0,userUnit:Number(c),artBox:null,bleedBox:null,cropBox:null,trimBox:null,mediaBox:{bottomLeftX:0,bottomLeftY:0,topRightX:Number(R[0]),topRightY:Number(R[1])}},LA(zt),z(oe[$])},Si=function(R,de){var je,Fe,Te;switch(s=de||s,typeof R=="string"&&(je=g(R.toLowerCase()),Array.isArray(je)&&(Fe=je[0],Te=je[1])),Array.isArray(R)&&(Fe=R[0]*Tt,Te=R[1]*Tt),isNaN(Fe)&&(Fe=o[0],Te=o[1]),(Fe>14400||Te>14400)&&(Xr.warn("A page in a PDF can not be wider or taller than 14400 userUnit. jsPDF limits the width/height to 14400"),Fe=Math.min(14400,Fe),Te=Math.min(14400,Te)),o=[Fe,Te],s.substr(0,1)){case"l":Te>Fe&&(o=[Te,Fe]);break;case"p":Fe>Te&&(o=[Te,Fe])}Qn(o),Rt(Wo),ie(Ja),Rl!==0&&ie(Rl+" J"),Gs!==0&&ie(Gs+" j"),cr.publish("addPage",{pageNumber:zt})},QA=function(R){R>0&&R<=zt&&(oe.splice(R,1),Bt.splice(R,1),zt--,$>zt&&($=zt),this.setPage($))},LA=function(R){R>0&&R<=zt&&($=R)},TA=p.__private__.getNumberOfPages=p.getNumberOfPages=function(){return oe.length-1},Oc=function(R,de,je){var Fe,Te=void 0;return je=je||{},R=R!==void 0?R:_t[ut].fontName,de=de!==void 0?de:_t[ut].fontStyle,Fe=R.toLowerCase(),Dt[Fe]!==void 0&&Dt[Fe][de]!==void 0?Te=Dt[Fe][de]:Dt[R]!==void 0&&Dt[R][de]!==void 0?Te=Dt[R][de]:je.disableWarning===!1&&Xr.warn("Unable to look up font label for font '"+R+"', '"+de+"'. Refer to getFontList() for available fonts."),Te||je.noFallback||(Te=Dt.times[de])==null&&(Te=Dt.times.normal),Te},Xa=p.__private__.putInfo=function(){var R=Jr(),de=function(Fe){return Fe};for(var je in m!==null&&(de=Ls.encryptor(R,0)),ie("<<"),ie("/Producer ("+Wa(de("jsPDF "+Ft.version))+")"),lt)lt.hasOwnProperty(je)&<[je]&&ie("/"+je.substr(0,1).toUpperCase()+je.substr(1)+" ("+Wa(de(lt[je]))+")");ie("/CreationDate ("+Wa(de(le))+")"),ie(">>"),ie("endobj")},_i=p.__private__.putCatalog=function(R){var de=(R=R||{}).rootDictionaryObjId||wa;switch(Jr(),ie("<<"),ie("/Type /Catalog"),ie("/Pages "+de+" 0 R"),G||(G="fullwidth"),G){case"fullwidth":ie("/OpenAction [3 0 R /FitH null]");break;case"fullheight":ie("/OpenAction [3 0 R /FitV null]");break;case"fullpage":ie("/OpenAction [3 0 R /Fit]");break;case"original":ie("/OpenAction [3 0 R /XYZ null null 1]");break;default:var je=""+G;je.substr(je.length-1)==="%"&&(G=parseInt(G)/100),typeof G=="number"&&ie("/OpenAction [3 0 R /XYZ null null "+Z(G)+"]")}switch(He||(He="continuous"),He){case"continuous":ie("/PageLayout /OneColumn");break;case"single":ie("/PageLayout /SinglePage");break;case"two":case"twoleft":ie("/PageLayout /TwoColumnLeft");break;case"tworight":ie("/PageLayout /TwoColumnRight")}Ue&&ie("/PageMode /"+Ue),cr.publish("putCatalog"),ie(">>"),ie("endobj")},Ln=p.__private__.putTrailer=function(){ie("trailer"),ie("<<"),ie("/Size "+(J+1)),ie("/Root "+J+" 0 R"),ie("/Info "+(J-1)+" 0 R"),m!==null&&ie("/Encrypt "+Ls.oid+" 0 R"),ie("/ID [ <"+ae+"> <"+ae+"> ]"),ie(">>")},yr=p.__private__.putHeader=function(){ie("%PDF-"+v),ie("%ºß¬à")},IA=p.__private__.putXRef=function(){var R="0000000000";ie("xref"),ie("0 "+(J+1)),ie("0000000000 65535 f ");for(var de=1;de<=J;de++)typeof O[de]=="function"?ie((R+O[de]()).slice(-10)+" 00000 n "):O[de]!==void 0?ie((R+O[de]).slice(-10)+" 00000 n "):ie("0000000000 00000 n ")},Zn=p.__private__.buildDocument=function(){var R;J=0,re=0,H=[],O=[],Ae=[],wa=ws(),Qr=ws(),z(H),cr.publish("buildDocument"),yr(),kn(),(function(){cr.publish("putAdditionalObjects");for(var je=0;je"),ie("/O <"+Ls.toHexString(Ls.O)+">"),ie("/P "+Ls.P),ie(">>"),ie("endobj")),Xa(),_i();var de=re;return IA(),Ln(),ie("startxref"),ie(""+de),ie("%%EOF"),z(oe[$]),H.join(` `)},ho=p.__private__.getBlob=function(R){return new Blob([Q(R)],{type:"application/pdf"})},DA=p.output=p.__private__.output=(Ga=function(R,de){switch(typeof(de=de||{})=="string"?de={filename:de}:de.filename=de.filename||"generated.pdf",R){case void 0:return Zn();case"save":p.save(de.filename);break;case"arraybuffer":return Q(Zn());case"blob":return ho(Zn());case"bloburi":case"bloburl":if(Wt.URL!==void 0&&typeof Wt.URL.createObjectURL=="function")return Wt.URL&&Wt.URL.createObjectURL(ho(Zn()))||void 0;Xr.warn("bloburl is not supported by your system, because URL.createObjectURL is not supported by your browser.");break;case"datauristring":case"dataurlstring":var je="",Fe=Zn();try{je=j2(Fe)}catch{je=j2(unescape(encodeURIComponent(Fe)))}return"data:application/pdf;filename="+de.filename+";base64,"+je;case"pdfobjectnewwindow":if(Object.prototype.toString.call(Wt)==="[object Window]"){var Te="https://cdnjs.cloudflare.com/ajax/libs/pdfobject/2.1.1/pdfobject.min.js",Je=' integrity="sha512-4ze/a9/4jqu+tX9dfOqJYSvyYd5M6qum/3HpCLr+/Jqf0whc37VUbkpNGHR7/8pSnCFw47T1fmIpwBV7UySh3g==" crossorigin="anonymous"';de.pdfObjectUrl&&(Te=de.pdfObjectUrl,Je="");var at='