@superdangerous/app-framework 4.16.25 → 4.16.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdangerous/app-framework",
|
|
3
|
-
"version": "4.16.
|
|
3
|
+
"version": "4.16.29",
|
|
4
4
|
"description": "Opinionated TypeScript framework for structured vibecoding - building internal web and desktop apps with batteries included",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -225,7 +225,7 @@ export function DataTable<T>({
|
|
|
225
225
|
onClick={() => onSort(col.sortKey!)}
|
|
226
226
|
className={cn(
|
|
227
227
|
'flex items-center gap-1 hover:text-foreground transition-colors',
|
|
228
|
-
sortField === col.sortKey && 'text-
|
|
228
|
+
sortField === col.sortKey && 'text-foreground font-medium'
|
|
229
229
|
)}
|
|
230
230
|
>
|
|
231
231
|
{col.header}
|
|
@@ -241,7 +241,7 @@ export function DataTable<T>({
|
|
|
241
241
|
<TooltipProvider>
|
|
242
242
|
<>
|
|
243
243
|
{/* Table with scroll container and border - supports both horizontal and vertical scroll with sticky header */}
|
|
244
|
-
<div className="overflow-auto border rounded-lg
|
|
244
|
+
<div className="overflow-auto border rounded-lg h-full">
|
|
245
245
|
<Table
|
|
246
246
|
style={getTableStyle()}
|
|
247
247
|
className={cn('resizable-table sticky-actions-table', className)}
|
|
@@ -295,6 +295,7 @@ export function DataTable<T>({
|
|
|
295
295
|
{/* Actions column header */}
|
|
296
296
|
{actionsColumn && (
|
|
297
297
|
<TableHead
|
|
298
|
+
key="actions"
|
|
298
299
|
className="sticky right-0 z-20 bg-muted text-center relative before:absolute before:left-0 before:top-0 before:bottom-0 before:w-px before:bg-border"
|
|
299
300
|
style={{ width: actionsColumnWidth, minWidth: actionsColumnWidth, maxWidth: actionsColumnWidth }}
|
|
300
301
|
>
|
|
@@ -390,6 +391,7 @@ export function DataTable<T>({
|
|
|
390
391
|
{/* Actions cell */}
|
|
391
392
|
{actionsColumn && (
|
|
392
393
|
<TableCell
|
|
394
|
+
key="actions"
|
|
393
395
|
className={cn(
|
|
394
396
|
'sticky right-0 z-10 text-center relative before:absolute before:left-0 before:top-0 before:bottom-0 before:w-px before:bg-border',
|
|
395
397
|
'bg-background group-hover:bg-muted',
|
package/ui/dist/index.js
CHANGED
|
@@ -58,7 +58,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
58
58
|
[data-state="expanded"] .bg-primary {
|
|
59
59
|
background-color: ${f};
|
|
60
60
|
}
|
|
61
|
-
`})]})}var e6={active:{bg:"bg-green-500",ring:"ring-green-400"},success:{bg:"bg-emerald-500",ring:"ring-emerald-400"},inactive:{bg:"bg-gray-400",ring:"ring-gray-300"},warning:{bg:"bg-yellow-500",ring:"ring-yellow-400"},error:{bg:"bg-red-500",ring:"ring-red-400"}},t6={xs:"h-2 w-2",sm:"h-3 w-3",md:"h-4 w-4",lg:"h-5 w-5"};function fb({status:e,size:t="sm",animate:r=true,label:n,className:o}){let a=e6[e],i=r&&(e==="active"||e==="warning"||e==="error");return jsxRuntime.jsxs("div",{className:N("inline-flex items-center gap-2",o),children:[jsxRuntime.jsxs("span",{className:"relative inline-flex",children:[i&&jsxRuntime.jsx("span",{className:N("absolute inline-flex h-full w-full rounded-full opacity-75",a.bg,e==="active"&&"animate-ping",e==="warning"&&"animate-pulse",e==="error"&&"animate-pulse")}),jsxRuntime.jsx("span",{className:N("relative inline-flex rounded-full",t6[t],a.bg,i&&"ring-1",i&&a.ring)})]}),n&&jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:n})]})}function bb({data:e,width:t=100,height:r=30,color:n="#10b981",strokeWidth:o=2,fill:a=false,className:i}){let s=Ne.useMemo(()=>{if(!e||e.length===0)return "";let c=Math.max(...e),u=Math.min(...e),d=c-u||1;return e.map((g,p)=>{let f=p/(e.length-1)*t,m=r-(g-u)/d*r;return `${f},${m}`}).join(" ")},[e,t,r]);if(!e||e.length===0)return jsxRuntime.jsx("svg",{width:t,height:r,className:i,children:jsxRuntime.jsx("line",{x1:"0",y1:r/2,x2:t,y2:r/2,stroke:"#e5e7eb",strokeWidth:1})});let l=s?`0,${r} ${s} ${t},${r}`:"";return jsxRuntime.jsxs("svg",{width:t,height:r,className:i,children:[a&&s&&jsxRuntime.jsx("polygon",{points:l,fill:n,fillOpacity:.1}),s&&jsxRuntime.jsx("polyline",{points:s,fill:"none",stroke:n,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),e.length>0&&jsxRuntime.jsx("circle",{cx:t,cy:r-(e[e.length-1]-Math.min(...e))/(Math.max(...e)-Math.min(...e)||1)*r,r:o,fill:n})]})}function a6({data:e,columns:t,keyField:r,title:n,description:o,showActivity:a=false,activityField:i="activity",activityDecay:s=1e3,showSparkline:l=false,sparklineField:c="value",sparklineHistory:u,sparklineColor:d="#10b981",showStatus:g=false,statusField:p="status",statusConfig:f,expandable:m=false,childrenField:b="children",defaultExpanded:h=false,className:w,striped:k=false,hover:R=true,compact:C=false,onRowClick:S,onRefresh:O}){let[D,A]=Ne.useState(new Set),[E,z]=Ne.useState(new Map);Ne.useEffect(()=>{if(h&&m){let L=e.map(B=>B[r]);A(new Set(L));}},[h,m,e,r]),Ne.useEffect(()=>{if(a){let L=new Map;e.forEach(B=>{let q=B[r],Y=B[i];Y&&Y!=="inactive"&&(L.set(q,Y),setTimeout(()=>{z(ne=>{let Q=new Map(ne);return Q.delete(q),Q});},s));}),z(B=>new Map([...B,...L]));}},[e,a,r,i,s]);let I=Ne.useCallback(L=>{A(B=>{let q=new Set(B);return q.has(L)?q.delete(L):q.add(L),q});},[]),P=(L,B=0)=>{let q=L[r],Y=D.has(q),ne=m&&L[b]&&L[b].length>0,Q=E.get(q)||"inactive";return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(xr,{className:N(R&&"hover:bg-gray-50 transition-colors",S&&"cursor-pointer",B>0&&"bg-gray-50/50"),onClick:()=>S?.(L),children:t.map((v,U)=>jsxRuntime.jsx(vr,{className:N(v.align==="center"&&"text-center",v.align==="right"&&"text-right",C&&"py-2",U===0&&B>0&&`pl-${4+B*4}`),style:{width:v.width},children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[U===0&&ne&&jsxRuntime.jsx("button",{onClick:ee=>{ee.stopPropagation(),I(q);},className:"p-0.5 hover:bg-gray-200 rounded",children:Y?"\u25BC":"\u25B6"}),U===0&&a&&jsxRuntime.jsx(fb,{status:Q,size:"sm"}),v.render?v.render(v.accessor(L),L):v.accessor(L),v.key===p&&g&&f&&jsxRuntime.jsxs(it,{variant:f[L[p]]?.variant||"default",children:[f[L[p]]?.icon,f[L[p]]?.label||L[p]]}),v.key===c&&l&&u&&jsxRuntime.jsx(bb,{data:u.get(q)||[],color:d,width:60,height:20})]})},v.key))},q),Y&&ne&&L[b].map(v=>P(v,B+1))]})};return jsxRuntime.jsxs(Re,{className:w,children:[(n||o)&&jsxRuntime.jsxs("div",{className:"p-4 border-b",children:[n&&jsxRuntime.jsx("h3",{className:"font-semibold text-lg",children:n}),o&&jsxRuntime.jsx("p",{className:"text-sm text-gray-600 mt-1",children:o})]}),jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsxs(po,{children:[jsxRuntime.jsx(go,{children:jsxRuntime.jsx(xr,{children:t.map(L=>jsxRuntime.jsx(rn,{className:N(L.align==="center"&&"text-center",L.align==="right"&&"text-right"),style:{width:L.width},children:L.label},L.key))})}),jsxRuntime.jsx(mo,{children:e.length===0?jsxRuntime.jsx(xr,{children:jsxRuntime.jsx(vr,{colSpan:t.length,className:"text-center py-8 text-gray-500",children:"No data available"})}):e.map(L=>P(L))})]})})]})}function s6({stats:e,columns:t=4,className:r}){let n={1:"grid-cols-1",2:"grid-cols-1 md:grid-cols-2",3:"grid-cols-1 md:grid-cols-2 lg:grid-cols-3",4:"grid-cols-1 md:grid-cols-2 lg:grid-cols-4",5:"grid-cols-1 md:grid-cols-2 lg:grid-cols-5",6:"grid-cols-1 md:grid-cols-3 lg:grid-cols-6"},o={default:"",primary:"border-blue-200 bg-blue-50/50",success:"border-green-200 bg-green-50/50",warning:"border-yellow-200 bg-yellow-50/50",danger:"border-red-200 bg-red-50/50"},a={default:"text-gray-600",primary:"text-blue-600",success:"text-green-600",warning:"text-yellow-600",danger:"text-red-600"};return jsxRuntime.jsx("div",{className:N(`grid gap-4 ${n[t]}`,r),children:e.map((i,s)=>{let l=i.icon,c=i.color||"default";return jsxRuntime.jsx(Re,{className:N("p-4 transition-all hover:shadow-md",o[c],i.className),children:jsxRuntime.jsx("div",{className:"flex items-start justify-between",children:jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[l&&jsxRuntime.jsx(l,{className:N("h-4 w-4",a[c])}),jsxRuntime.jsx("p",{className:"text-sm font-medium text-gray-600",children:i.label})]}),jsxRuntime.jsxs("div",{className:"mt-2",children:[jsxRuntime.jsx("p",{className:"text-2xl font-bold",children:i.value}),i.description&&jsxRuntime.jsx("p",{className:"text-xs text-gray-500 mt-1",children:i.description}),i.trend&&jsxRuntime.jsxs("div",{className:"flex items-center gap-1 mt-2",children:[jsxRuntime.jsxs("span",{className:N("text-xs font-medium",i.trend.positive?"text-green-600":"text-red-600"),children:[i.trend.positive?"\u2191":"\u2193",Math.abs(i.trend.value),"%"]}),i.trend.label&&jsxRuntime.jsx("span",{className:"text-xs text-gray-500",children:i.trend.label})]})]})]})})},s)})})}function l6({label:e,value:t,icon:r,trend:n,className:o}){return jsxRuntime.jsxs("div",{className:N("flex items-center justify-between p-3 bg-white rounded-lg border",o),children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[r&&jsxRuntime.jsx("div",{className:"p-2 bg-gray-100 rounded",children:jsxRuntime.jsx(r,{className:"h-4 w-4 text-gray-600"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{className:"text-xs text-gray-600",children:e}),jsxRuntime.jsx("p",{className:"font-semibold",children:t})]})]}),n!==void 0&&jsxRuntime.jsxs("span",{className:N("text-xs font-medium",n>=0?"text-green-600":"text-red-600"),children:[n>=0?"\u2191":"\u2193"," ",Math.abs(n),"%"]})]})}function c6({stats:e}){if(!e)return null;let{total:t,error:r,warn:n,info:o,debug:a,fileSize:i,oldestEntry:s,newestEntry:l}=e;return jsxRuntime.jsxs(Re,{className:"p-4 mb-4",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-6 gap-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Total"}),jsxRuntime.jsx("div",{className:"text-xl font-semibold",children:t??0})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Errors"}),jsxRuntime.jsx(it,{variant:"destructive",children:r??0})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Warnings"}),jsxRuntime.jsx(it,{variant:"secondary",children:n??0})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Info"}),jsxRuntime.jsx(it,{variant:"outline",children:o??0})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Debug"}),jsxRuntime.jsx(it,{variant:"outline",children:a??0})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"File Size"}),jsxRuntime.jsx("div",{className:"text-xl font-semibold",children:String(i??"-")})]})]}),(s||l)&&jsxRuntime.jsxs("div",{className:"mt-3 text-xs text-muted-foreground",children:[s&&jsxRuntime.jsxs("span",{children:["Oldest: ",s," "]}),l&&jsxRuntime.jsxs("span",{children:["Newest: ",l]})]})]})}function m6({categories:e,onSave:t,onLoad:r,onValidate:n,onRestartRequired:o,title:a="Settings",description:i="Configure application preferences",showResetButton:s=true,showUndoButton:l=true,customFields:c={},renderCategory:u,renderSetting:d,autoSave:g=false,autoSaveDelay:p=3e3,confirmReset:f=true,persistState:m=true,className:b,containerClassName:h,categoryClassName:w,settingClassName:k,height:R="calc(100vh - 200px)",maxContentWidth:C="800px"}){let[S,O]=Ne.useState({}),[D,A]=Ne.useState({}),[E,z]=Ne.useState({}),[I,P]=Ne.useState(true),[L,B]=Ne.useState(false),[q,Y]=Ne.useState(e?.[0]?.id||""),[ne,Q]=Ne.useState({}),[v,U]=Ne.useState(false),[ee,T]=Ne.useState(false),[ve,Te]=Ne.useState(null),$e=()=>{let _={};return e.forEach(Z=>{(Z.settings||[]).forEach(ue=>{_[ue.key]=ue.defaultValue;});}),_};Ne.useEffect(()=>{(async()=>{P(true);try{let Z=r?await r():$e();if(O(Z),A(Z),m){let ue=localStorage.getItem("settings-active-category");ue&&e.find(Oe=>Oe.id===ue)&&Y(ue);}}catch(Z){console.error("Failed to load settings:",Z),O($e()),A($e());}finally{P(false);}})();},[]),Ne.useEffect(()=>{let _=JSON.stringify(S)!==JSON.stringify(D);T(_);},[S,D]),Ne.useEffect(()=>{if(!g||!ee)return;let _=setTimeout(()=>{et();},p);return ()=>clearTimeout(_)},[S,g,p,ee]),Ne.useEffect(()=>{m&&localStorage.setItem("settings-active-category",q);},[q,m]);let _e=(_,Z)=>_.validation?_.validation(Z):null,Se=()=>{let _={},Z=false;if(e.forEach(ue=>{(ue.settings||[]).forEach(Oe=>{let at=_e(Oe,S[Oe.key]);at&&(_[Oe.key]=at,Z=true);});}),n){let ue=n(S);ue&&(Object.assign(_,ue),Z=true);}return z(_),!Z},et=async()=>{if(Se()){B(true);try{let Z=Object.keys(S).filter(ue=>S[ue]!==D[ue]).filter(ue=>e.flatMap(at=>at.settings||[]).find(at=>at.key===ue)?.requiresRestart);Z.length>0&&(U(!0),o?.(Z)),await t(S),A(S);}catch(_){console.error("Failed to save settings:",_),Te(_ instanceof Error?_.message:"Failed to save settings. Please try again.");}finally{B(false);}}},Ue=()=>{if(f&&!confirm("Reset all settings to defaults? This will override your current configuration."))return;let _=$e();O(_);},lt=()=>{O(D);},ot=(_,Z)=>{O(ue=>({...ue,[_]:Z})),E[_]&&z(ue=>{let Oe={...ue};return delete Oe[_],Oe}),ve&&Te(null);},$=_=>{if(_.hidden)return null;let Z=S[_.key]??_.defaultValue,ue=E[_.key],Oe=ne[_.key];if(_.showIf&&!_.showIf(S))return null;let at=_.inputWidth==="small"?"max-w-[180px]":_.inputWidth==="large"?"w-full max-w-xl":"max-w-sm";if(_.type==="custom"||_.customComponent){let Fe=_.customComponent||c[_.type];if(Fe)return jsxRuntime.jsx(Fe,{value:Z,onChange:Zr=>ot(_.key,Zr),error:ue,disabled:L,setting:_})}let or=c[_.type];if(or)return jsxRuntime.jsx(or,{value:Z,onChange:Fe=>ot(_.key,Fe),error:ue,disabled:L,setting:_});switch(_.type){case "string":case "text":case "password":return jsxRuntime.jsxs("div",{className:N("flex items-center gap-2",at),children:[jsxRuntime.jsx(Et,{id:_.key,type:_.type==="password"&&!Oe?"password":"text",value:Z||"",onChange:Fe=>ot(_.key,Fe.target.value),className:N(ue&&"border-red-500",at),placeholder:_.placeholder||(_.type==="password"?"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022":void 0),disabled:L}),_.suffix&&jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:_.suffix})]});case "number":return jsxRuntime.jsxs("div",{className:N("flex items-center gap-2",at),children:[jsxRuntime.jsx(Et,{id:_.key,type:"number",value:Z??"",onChange:Fe=>ot(_.key,parseFloat(Fe.target.value)||0),className:N(ue&&"border-red-500",at),placeholder:_.placeholder,disabled:L,step:_.step,min:_.min,max:_.max}),_.suffix&&jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:_.suffix})]});case "boolean":return jsxRuntime.jsx(zt,{id:_.key,checked:Z||false,onCheckedChange:Fe=>ot(_.key,Fe),disabled:L});case "select":return jsxRuntime.jsxs(Tt,{value:String(Z||_.defaultValue),onValueChange:Fe=>ot(_.key,Fe),disabled:L,children:[jsxRuntime.jsx(ft,{id:_.key,className:N(ue&&"border-red-500"),children:jsxRuntime.jsx(At,{})}),jsxRuntime.jsx(bt,{children:_.options?.map(Fe=>jsxRuntime.jsx(Be,{value:String(Fe.value),children:Fe.label},Fe.value))})]});default:return null}},oe=e.find(_=>_.id===q);return jsxRuntime.jsxs("div",{className:N("flex flex-col",b),style:{height:R},children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-6 shrink-0",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h1",{className:"text-3xl font-bold",children:a}),jsxRuntime.jsx("p",{className:"text-muted-foreground",children:i})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[l&&ee&&jsxRuntime.jsxs(j,{variant:"outline",onClick:lt,disabled:L,children:[jsxRuntime.jsx(lucideReact.Undo,{className:"h-4 w-4 mr-2"}),"Undo"]}),s&&jsxRuntime.jsxs(j,{variant:"outline",onClick:Ue,disabled:L,children:[jsxRuntime.jsx(lucideReact.RotateCcw,{className:"h-4 w-4 mr-2"}),"Defaults"]}),jsxRuntime.jsx(j,{onClick:et,disabled:!ee||L,className:N("transition-all",ee&&"ring-2 ring-primary/20"),children:L?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(lucideReact.RefreshCw,{className:"h-4 w-4 mr-2 animate-spin"}),"Saving..."]}):ee?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(lucideReact.Save,{className:"h-4 w-4 mr-2"}),"Save"]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(lucideReact.Check,{className:"h-4 w-4 mr-2"}),"Saved"]})})]})]}),ve&&jsxRuntime.jsxs(ct,{variant:"destructive",className:"mb-6 shrink-0",children:[jsxRuntime.jsx(lucideReact.AlertCircle,{className:"h-4 w-4"}),jsxRuntime.jsx(ut,{children:ve})]}),jsxRuntime.jsxs("div",{className:N("flex gap-6 flex-1 min-h-0",h),children:[jsxRuntime.jsxs(Re,{className:"w-56 shrink-0 flex flex-col min-h-0",children:[jsxRuntime.jsx("div",{className:"p-4 border-b shrink-0",children:jsxRuntime.jsx("h3",{className:"font-semibold",children:"Categories"})}),jsxRuntime.jsx("div",{className:"flex-1 overflow-y-auto p-2 min-h-0",children:jsxRuntime.jsx("div",{className:"space-y-1",children:e.map(_=>{let Z=_.icon;return jsxRuntime.jsxs("button",{onClick:()=>Y(_.id),className:N("w-full flex items-center gap-3 px-3 py-2 rounded-md text-sm transition-colors",q===_.id?"bg-primary text-primary-foreground":"hover:bg-muted",w),children:[Z&&jsxRuntime.jsx(Z,{className:"h-4 w-4 shrink-0"}),jsxRuntime.jsx("span",{className:"text-left truncate",children:_.label})]},_.id)})})})]}),jsxRuntime.jsx("div",{className:"flex-1 min-h-0 flex flex-col",children:I?jsxRuntime.jsx(Re,{className:"p-8",children:jsxRuntime.jsx("div",{className:"flex items-center justify-center",children:jsxRuntime.jsx(lucideReact.RefreshCw,{className:"h-8 w-8 animate-spin text-muted-foreground"})})}):oe?.component?jsxRuntime.jsxs(Re,{className:"p-6 flex-1 min-h-0 flex flex-col overflow-hidden",children:[jsxRuntime.jsxs("div",{className:"mb-6 flex-shrink-0",children:[jsxRuntime.jsx("h2",{className:"text-xl font-semibold",children:oe.label}),oe.description&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:oe.description})]}),jsxRuntime.jsx("div",{className:"flex-1 min-h-0",children:jsxRuntime.jsx(oe.component,{category:oe})})]}):oe?jsxRuntime.jsx(Re,{className:"p-6 flex-1 min-h-0 overflow-y-auto",children:jsxRuntime.jsx("div",{style:{maxWidth:C},children:u?u(oe,jsxRuntime.jsx("div",{className:"space-y-6",children:(oe.settings||[]).map(_=>{let Z=$(_);if(!Z)return null;let ue=jsxRuntime.jsxs("div",{className:N("space-y-2",k),children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsxs(gt,{htmlFor:_.key,className:"text-sm font-medium",children:[_.label,_.requiresRestart&&jsxRuntime.jsx("span",{className:"ml-2 text-xs text-amber-600 dark:text-amber-400",children:"(Requires restart)"})]}),_.help&&jsxRuntime.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground transition-colors",title:_.help,children:jsxRuntime.jsx(lucideReact.Info,{className:"h-3 w-3"})})]}),_.type==="password"&&S[_.key]&&jsxRuntime.jsx(j,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-2",onClick:()=>Q(Oe=>({...Oe,[_.key]:!Oe[_.key]})),children:ne[_.key]?jsxRuntime.jsx(lucideReact.EyeOff,{className:"h-3 w-3"}):jsxRuntime.jsx(lucideReact.Eye,{className:"h-3 w-3"})})]}),_.description&&jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:_.description}),_.hint&&jsxRuntime.jsx("p",{className:"text-[11px] text-muted-foreground",children:_.hint}),Z,E[_.key]&&jsxRuntime.jsx("p",{className:"text-xs text-red-500",children:E[_.key]})]},_.key);return d?d(_,ue):ue})})):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"mb-6",children:[jsxRuntime.jsx("h2",{className:"text-xl font-semibold",children:oe.label}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:oe.description})]}),jsxRuntime.jsx("div",{className:"space-y-6",children:(oe.settings||[]).map(_=>{let Z=$(_);if(!Z)return null;let ue=jsxRuntime.jsxs("div",{className:N("space-y-2",k),children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsxs(gt,{htmlFor:_.key,className:"text-sm font-medium",children:[_.label,_.requiresRestart&&jsxRuntime.jsx("span",{className:"ml-2 text-xs text-amber-600 dark:text-amber-400",children:"(Requires restart)"})]}),_.help&&jsxRuntime.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground transition-colors",title:_.help,children:jsxRuntime.jsx(lucideReact.Info,{className:"h-3 w-3"})})]}),_.type==="password"&&S[_.key]&&jsxRuntime.jsx(j,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-2",onClick:()=>Q(Oe=>({...Oe,[_.key]:!Oe[_.key]})),children:ne[_.key]?jsxRuntime.jsx(lucideReact.EyeOff,{className:"h-3 w-3"}):jsxRuntime.jsx(lucideReact.Eye,{className:"h-3 w-3"})})]}),_.description&&jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:_.description}),Z,E[_.key]&&jsxRuntime.jsx("p",{className:"text-xs text-red-500",children:E[_.key]})]},_.key);return d?d(_,ue):ue})})]})})}):jsxRuntime.jsx(Re,{className:"p-8",children:jsxRuntime.jsxs(ct,{children:[jsxRuntime.jsx(lucideReact.AlertCircle,{className:"h-4 w-4"}),jsxRuntime.jsx(ut,{children:"No settings available for this category"})]})})})]}),v&&jsxRuntime.jsxs(ct,{className:"border-amber-500",children:[jsxRuntime.jsx(lucideReact.AlertCircle,{className:"h-4 w-4 text-amber-600"}),jsxRuntime.jsx(ut,{children:"Some settings require a restart to take effect."})]})]})}function f6({onFetchLogs:e,onClearLogs:t,autoRefreshMs:r=3e3,height:n="100%"}){return jsxRuntime.jsx(on,{mode:"logs",showHeader:false,onFetchLogs:e,onClearLogs:t,enableAutoScroll:true,autoRefreshMs:r,enableSearch:true,enableFilter:true,enableExport:true,enableClear:!!t,height:n})}function b6({onFetchArchives:e,onDownloadArchive:t,onDeleteArchive:r,height:n="100%"}){return jsxRuntime.jsx(on,{mode:"archives",showHeader:false,onFetchArchives:e,onDownloadArchive:t,onDeleteArchive:r,height:n})}function h6({onFetchLogs:e,onFetchArchives:t,onClearLogs:r,onDownloadArchive:n,onDeleteArchive:o,autoRefreshMs:a=3e3,height:i="100%"}){return jsxRuntime.jsx(on,{mode:"full",showHeader:false,onFetchLogs:e,onFetchArchives:t,onClearLogs:r,onDownloadArchive:n,onDeleteArchive:o,enableAutoScroll:true,autoRefreshMs:a,enableSearch:true,enableFilter:true,enableExport:true,enableClear:!!r,showArchives:!!t,height:i})}var Ms={colors:{primary:{DEFAULT:"#3b82f6",hover:"#2563eb",light:"#60a5fa",dark:"#1d4ed8"},dark:{bg:{primary:"#0a0a0a",secondary:"#141414",tertiary:"#1a1a1a",elevated:"#242424"},border:{DEFAULT:"#2a2a2a",subtle:"#1f1f1f",strong:"#3a3a3a"}},light:{bg:{primary:"#ffffff",secondary:"#f8f9fa",tertiary:"#f3f4f6",elevated:"#ffffff"},border:{DEFAULT:"#e5e7eb",subtle:"#f3f4f6",strong:"#d1d5db"}},success:{DEFAULT:"#10b981",light:"#34d399",dark:"#059669"},warning:{DEFAULT:"#f59e0b",light:"#fbbf24",dark:"#d97706"},error:{DEFAULT:"#ef4444",light:"#f87171",dark:"#dc2626"},info:{DEFAULT:"#3b82f6",light:"#60a5fa",dark:"#2563eb"},intelligent:{DEFAULT:"#8b5cf6",light:"#a78bfa",dark:"#7c3aed"},activity:{read:"#10b981",write:"#3b82f6",inactive:"#6b7280"}},gradients:{subtle:"linear-gradient(180deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0) 100%)",card:"linear-gradient(135deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.05) 100%)",glow:"radial-gradient(circle at 50% 0%, rgba(226,19,80,0.15) 0%, transparent 70%)",intelligent:"linear-gradient(135deg, rgba(139,92,246,0.1) 0%, rgba(139,92,246,0.05) 100%)"},shadows:{sm:"0 1px 2px 0 rgba(0, 0, 0, 0.05)",DEFAULT:"0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)",md:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",lg:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",xl:"0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)",glow:"0 0 20px rgba(226,19,80,0.3)","glow-intelligent":"0 0 20px rgba(139,92,246,0.3)"},radius:{sm:"0.25rem",DEFAULT:"0.375rem",md:"0.5rem",lg:"0.75rem",xl:"1rem","2xl":"1.5rem",full:"9999px"},spacing:{xs:"0.5rem",sm:"0.75rem",DEFAULT:"1rem",md:"1.5rem",lg:"2rem",xl:"3rem","2xl":"4rem"},typography:{fonts:{sans:'Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',mono:'"JetBrains Mono", "SF Mono", Monaco, Consolas, "Liberation Mono", "Courier New", monospace'},sizes:{xs:"0.75rem",sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","3xl":"1.875rem","4xl":"2.25rem"},weights:{light:"300",normal:"400",medium:"500",semibold:"600",bold:"700"}},transitions:{fast:"150ms",DEFAULT:"200ms",slow:"300ms",timing:"cubic-bezier(0.4, 0, 0.2, 1)"},zIndex:{base:0,elevated:10,dropdown:20,sticky:30,fixed:40,modal:50,popover:60,tooltip:70},opacity:{hover:.8,disabled:.5,backdrop:.7,subtle:.1}},Que=(e=false)=>{let t=e?Ms.colors.dark:Ms.colors.light;return {"--color-bg-primary":t.bg.primary,"--color-bg-secondary":t.bg.secondary,"--color-bg-tertiary":t.bg.tertiary,"--color-bg-elevated":t.bg.elevated,"--color-border":t.border.DEFAULT,"--color-border-subtle":t.border.subtle,"--color-border-strong":t.border.strong,"--color-text":e?"#ffffff":"#000000","--color-text-secondary":e?"#a1a1aa":"#6b7280","--color-text-tertiary":e?"#71717a":"#9ca3af"}};var zO=Ne.createContext(void 0);function k6({children:e,defaultMode:t="system",theme:r=Ms,customColors:n,persistPreference:o=true}){let[a,i]=Ne.useState({mode:t,theme:r,customColors:n}),[s,l]=Ne.useState(false);Ne.useEffect(()=>{if(o){let g=localStorage.getItem("theme-mode");g&&i(p=>({...p,mode:g}));}},[o]),Ne.useEffect(()=>{let g=document.documentElement;if(a.mode==="system"){let p=window.matchMedia("(prefers-color-scheme: dark)"),f=p.matches;l(f),g.classList.toggle("dark",f);let m=b=>{let h=b.matches;l(h),g.classList.toggle("dark",h);};return p.addEventListener("change",m),()=>{p.removeEventListener("change",m);}}else {let p=a.mode==="dark";l(p),g.classList.toggle("dark",p);return}},[a.mode]),Ne.useEffect(()=>{if(n){let g=document.documentElement;if(n.primary){let p=kb(n.primary);g.style.setProperty("--primary",p);}if(n.secondary){let p=kb(n.secondary);g.style.setProperty("--secondary",p);}if(n.accent){let p=kb(n.accent);g.style.setProperty("--accent",p);}}},[n]);let c=g=>{i(p=>({...p,mode:g})),o&&localStorage.setItem("theme-mode",g);},d={themeConfig:a,setThemeMode:c,toggleTheme:()=>{c(s?"light":"dark");},isDark:s};return jsxRuntime.jsx(zO.Provider,{value:d,children:e})}function Ps(){let e=Ne.useContext(zO);if(!e)throw new Error("useTheme must be used within a ThemeProvider");return e}function kb(e){e=e.replace("#","");let t=parseInt(e.substr(0,2),16)/255,r=parseInt(e.substr(2,2),16)/255,n=parseInt(e.substr(4,2),16)/255,o=Math.max(t,r,n),a=Math.min(t,r,n),i=0,s=0,l=(o+a)/2;if(o!==a){let c=o-a;switch(s=l>.5?c/(2-o-a):c/(o+a),o){case t:i=((r-n)/c+(r<n?6:0))/6;break;case r:i=((n-t)/c+2)/6;break;case n:i=((t-r)/c+4)/6;break}}return `${Math.round(i*360)} ${Math.round(s*100)}% ${Math.round(l*100)}%`}function w6({className:e,showLabel:t=true,variant:r="select"}){let{themeConfig:n,setThemeMode:o,toggleTheme:a,isDark:i}=Ps();return r==="button"?jsxRuntime.jsxs("div",{className:N("flex items-center gap-2",e),children:[t&&jsxRuntime.jsx(gt,{children:"Theme"}),jsxRuntime.jsx(j,{variant:"outline",size:"icon",onClick:a,className:"w-10 h-10",children:i?jsxRuntime.jsx(lucideReact.Sun,{className:"h-4 w-4"}):jsxRuntime.jsx(lucideReact.Moon,{className:"h-4 w-4"})})]}):jsxRuntime.jsxs("div",{className:N("flex flex-col gap-2",e),children:[t&&jsxRuntime.jsx(gt,{htmlFor:"theme-select",children:"Theme"}),jsxRuntime.jsxs(Tt,{value:n.mode,onValueChange:s=>o(s),children:[jsxRuntime.jsx(ft,{id:"theme-select",className:"w-[180px]",children:jsxRuntime.jsx(At,{placeholder:"Select theme"})}),jsxRuntime.jsxs(bt,{children:[jsxRuntime.jsx(Be,{value:"light",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(lucideReact.Sun,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:"Light"})]})}),jsxRuntime.jsx(Be,{value:"dark",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(lucideReact.Moon,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:"Dark"})]})}),jsxRuntime.jsx(Be,{value:"system",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(lucideReact.Monitor,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:"System"})]})})]})]})]})}function E6({className:e}){let{toggleTheme:t,isDark:r}=Ps();return jsxRuntime.jsx(j,{variant:"ghost",size:"icon",onClick:t,className:N("w-8 h-8",e),title:`Switch to ${r?"light":"dark"} theme`,children:r?jsxRuntime.jsx(lucideReact.Sun,{className:"h-4 w-4"}):jsxRuntime.jsx(lucideReact.Moon,{className:"h-4 w-4"})})}var I6=[{id:"general",label:"General",description:"Basic application settings",icon:jsxRuntime.jsx(lucideReact.Settings,{className:"h-4 w-4"}),settings:[]},{id:"network",label:"Network",description:"Network and connectivity",icon:jsxRuntime.jsx(lucideReact.Network,{className:"h-4 w-4"}),settings:[]},{id:"logging",label:"Logging",description:"Logging configuration",icon:jsxRuntime.jsx(lucideReact.FileText,{className:"h-4 w-4"}),settings:[]},{id:"security",label:"Security",description:"Security settings",icon:jsxRuntime.jsx(lucideReact.Shield,{className:"h-4 w-4"}),settings:[]},{id:"notifications",label:"Notifications",description:"Email and alerts",icon:jsxRuntime.jsx(lucideReact.Mail,{className:"h-4 w-4"}),settings:[]},{id:"appearance",label:"Appearance",description:"UI preferences",icon:jsxRuntime.jsx(lucideReact.Palette,{className:"h-4 w-4"}),settings:[]},{id:"advanced",label:"Advanced",description:"Advanced settings",icon:jsxRuntime.jsx(lucideReact.Activity,{className:"h-4 w-4"}),settings:[]}];function _6(e,t,r,n){return {id:e,label:t,description:n,icon:O6[r]||jsxRuntime.jsx(lucideReact.Settings,{className:"h-4 w-4"})}}var O6={Server:jsxRuntime.jsx(lucideReact.Server,{className:"h-4 w-4"}),Network:jsxRuntime.jsx(lucideReact.Network,{className:"h-4 w-4"}),FileText:jsxRuntime.jsx(lucideReact.FileText,{className:"h-4 w-4"}),Shield:jsxRuntime.jsx(lucideReact.Shield,{className:"h-4 w-4"}),Mail:jsxRuntime.jsx(lucideReact.Mail,{className:"h-4 w-4"}),Settings:jsxRuntime.jsx(lucideReact.Settings,{className:"h-4 w-4"}),Database:jsxRuntime.jsx(lucideReact.Database,{className:"h-4 w-4"}),Bell:jsxRuntime.jsx(lucideReact.Bell,{className:"h-4 w-4"}),Users:jsxRuntime.jsx(lucideReact.Users,{className:"h-4 w-4"}),Palette:jsxRuntime.jsx(lucideReact.Palette,{className:"h-4 w-4"}),Globe:jsxRuntime.jsx(lucideReact.Globe,{className:"h-4 w-4"}),Activity:jsxRuntime.jsx(lucideReact.Activity,{className:"h-4 w-4"})};function P6({apiUrl:e="/api/updates",checkInterval:t=36e5,onDownload:r}){let[n,o]=Ne.useState(null),[a,i]=Ne.useState(false),[s,l]=Ne.useState(false),[c,u]=Ne.useState(false);Ne.useEffect(()=>{d();let f=setInterval(d,t);return ()=>clearInterval(f)},[t]);let d=async(f=false)=>{i(true);try{let m=await fetch(`${e}/check${f?"?force=true":""}`);if(m.ok){let b=await m.json();o(b),b.updateAvailable&&s&&localStorage.getItem("dismissedUpdateVersion")!==b.latestRelease?.version&&l(!1);}}catch(m){console.error("Failed to check for updates:",m);}finally{i(false);}},g=()=>{l(true),n?.latestRelease&&localStorage.setItem("dismissedUpdateVersion",n.latestRelease.version);},p=async()=>{if(r&&n)r(n);else try{let f=await fetch(`${e}/download-url`);if(f.ok){let{url:m}=await f.json();window.open(m,"_blank");}}catch{n?.latestRelease?.url&&window.open(n.latestRelease.url,"_blank");}};return !n?.updateAvailable||s?null:jsxRuntime.jsx("div",{className:"fixed bottom-4 right-4 z-50 max-w-md animate-in slide-in-from-bottom-2",children:jsxRuntime.jsxs(ct,{className:"border-green-500 bg-green-50 dark:bg-green-950/20",children:[jsxRuntime.jsx(lucideReact.Download,{className:"h-4 w-4 text-green-600 dark:text-green-400"}),jsxRuntime.jsxs(ut,{className:"pr-8",children:[jsxRuntime.jsxs("div",{className:"font-semibold text-green-800 dark:text-green-200 mb-1",children:["Update Available: v",n.latestRelease?.version]}),jsxRuntime.jsx("div",{className:"text-sm text-green-700 dark:text-green-300 mb-3",children:n.latestRelease?.name||"A new version is available"}),c&&n.latestRelease?.body&&jsxRuntime.jsx("div",{className:"mt-3 p-2 bg-white/50 dark:bg-black/20 rounded text-xs",children:jsxRuntime.jsx("pre",{className:"whitespace-pre-wrap font-sans",children:n.latestRelease.body})}),jsxRuntime.jsxs("div",{className:"flex gap-2 mt-3",children:[jsxRuntime.jsxs(j,{size:"sm",variant:"default",onClick:p,className:"bg-green-600 hover:bg-green-700",children:[jsxRuntime.jsx(lucideReact.Download,{className:"h-3 w-3 mr-1"}),"Download"]}),jsxRuntime.jsxs(j,{size:"sm",variant:"outline",onClick:()=>u(!c),children:[c?"Hide":"Show"," Changes"]}),jsxRuntime.jsx(j,{size:"sm",variant:"ghost",onClick:()=>window.open(n.latestRelease?.url,"_blank"),children:jsxRuntime.jsx(lucideReact.ExternalLink,{className:"h-3 w-3"})})]})]}),jsxRuntime.jsx(j,{size:"sm",variant:"ghost",className:"absolute top-2 right-2 h-6 w-6 p-0",onClick:g,children:jsxRuntime.jsx(lucideReact.X,{className:"h-4 w-4"})})]})})}function z6(e,t){let[r,n]=Ne.useState(e);return Ne.useEffect(()=>{let o=setTimeout(()=>{n(e);},t);return ()=>{clearTimeout(o);}},[e,t]),r}function U6(e){let[t,r]=So(e);return {connected:t.connected,connecting:t.connecting,transport:t.transport,error:t.error,retryCount:t.retryCount,reconnect:r.reconnect}}var Eb=class{constructor(t={}){this.config={loginEndpoint:t.loginEndpoint||"/api/login",logoutEndpoint:t.logoutEndpoint||"/api/logout",refreshEndpoint:t.refreshEndpoint||"/api/refresh",tokenKey:t.tokenKey||"auth_token",authKey:t.authKey||"authenticated",tokenExpiry:t.tokenExpiry||36e5};}async login(t,r){try{let n=await fetch(this.config.loginEndpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:t,password:r})}),o=await n.json();return n.ok&&o.success?(localStorage.setItem(this.config.authKey,"true"),o.token&&(localStorage.setItem(this.config.tokenKey,o.token),this.scheduleTokenRefresh(o.expiresIn||this.config.tokenExpiry)),o.user&&localStorage.setItem("user",JSON.stringify(o.user)),{success:!0,token:o.token,user:o.user,expiresIn:o.expiresIn}):{success:!1,error:o.error||"Invalid credentials"}}catch(n){return console.error("Login error:",n),{success:false,error:"Login failed. Please try again."}}}async logout(){try{let t=this.getToken();t&&await fetch(this.config.logoutEndpoint,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`}});}catch(t){console.error("Logout error:",t);}finally{localStorage.removeItem(this.config.authKey),localStorage.removeItem(this.config.tokenKey),localStorage.removeItem("user"),this.refreshTimer&&clearTimeout(this.refreshTimer);}}isAuthenticated(){return localStorage.getItem(this.config.authKey)==="true"}getToken(){return localStorage.getItem(this.config.tokenKey)}getUser(){let t=localStorage.getItem("user");if(t)try{return JSON.parse(t)}catch{return null}return null}async refreshToken(){try{let t=this.getToken();if(!t)return !1;let r=await fetch(this.config.refreshEndpoint,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`}});if(r.ok){let n=await r.json();if(n.token)return localStorage.setItem(this.config.tokenKey,n.token),this.scheduleTokenRefresh(n.expiresIn||this.config.tokenExpiry),!0}return !1}catch(t){return console.error("Token refresh error:",t),false}}scheduleTokenRefresh(t){this.refreshTimer&&clearTimeout(this.refreshTimer);let r=Math.max(0,t-3e5);this.refreshTimer=setTimeout(()=>{this.refreshToken();},r);}async authenticatedFetch(t,r={}){let n=this.getToken(),o=new Headers(r.headers);n&&o.set("Authorization",`Bearer ${n}`);let a=await fetch(t,{...r,headers:o});if(a.status===401&&await this.refreshToken()){let s=this.getToken();return s&&o.set("Authorization",`Bearer ${s}`),fetch(t,{...r,headers:o})}return a}requireAuth(t="/login"){return this.isAuthenticated()?true:(window.location.href=t,false)}},H6=new Eb;var Rde={base:"transition-all duration-200",interactive:"hover:shadow-md hover:border-gray-300 dark:hover:border-gray-700 cursor-pointer",elevation:"shadow-sm"},Ide={primary:"gap-2",icon:"h-4 w-4"},_de={container:"flex flex-col items-center justify-center py-12 text-center",icon:"h-12 w-12 text-muted-foreground mb-4",title:"text-lg font-medium mb-2",description:"text-sm text-muted-foreground max-w-sm"},Ode={led:"w-2 h-2 rounded-full transition-all duration-200",pulse:"animate-pulse",colors:{read:"bg-green-500",write:"bg-blue-500",inactive:"bg-gray-400",error:"bg-red-500"}},Lde={badge:{success:"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",warning:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200",error:"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200",info:"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",default:"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-200"}};var $6=25,q6=[10,25,50,100];function Zo({data:e,pageSize:t=$6,storageKey:r}){let[n,o]=Ne.useState(()=>{if(r)try{let h=localStorage.getItem(`pagination-${r}`);if(h)return {page:1,pageSize:JSON.parse(h).pageSize||t}}catch{}return {page:1,pageSize:t}}),{page:a,pageSize:i}=n,s=Ne.useMemo(()=>Math.max(1,Math.ceil(e.length/i)),[e.length,i]);Ne.useEffect(()=>{a>s&&o(h=>({...h,page:Math.max(1,s)}));},[s,a]),Ne.useEffect(()=>{if(r)try{localStorage.setItem(`pagination-${r}`,JSON.stringify({pageSize:i}));}catch{}},[i,r]);let l=(a-1)*i,c=Math.min(l+i,e.length),u=Ne.useMemo(()=>e.slice(l,c),[e,l,c]),d=Ne.useCallback(h=>{o(w=>({...w,page:Math.max(1,Math.min(h,s))}));},[s]),g=Ne.useCallback(h=>{o({page:1,pageSize:h});},[]),p=Ne.useCallback(()=>{d(a+1);},[a,d]),f=Ne.useCallback(()=>{d(a-1);},[a,d]),m=Ne.useCallback(()=>{d(1);},[d]),b=Ne.useCallback(()=>{d(s);},[s,d]);return {paginatedData:u,page:a,pageSize:i,totalPages:s,totalItems:e.length,setPage:d,setPageSize:g,nextPage:p,prevPage:f,firstPage:m,lastPage:b,startIndex:l+1,endIndex:c,canGoNext:a<s,canGoPrev:a>1,pageSizeOptions:q6}}function Qo({columns:e,storageKey:t}){let r=`column-visibility-${t}`,[n,o]=Ne.useState(()=>{let c={};if(e.forEach(u=>{c[u.id]=u.defaultVisible!==false;}),typeof window>"u")return c;try{let u=localStorage.getItem(r);if(u){let d=JSON.parse(u),g={};return e.forEach(p=>{p.locked?g[p.id]=!0:d[p.id]!==void 0?g[p.id]=d[p.id]:g[p.id]=p.defaultVisible!==!1;}),g}}catch(u){console.error("Error loading column visibility state:",u);}return c});Ne.useEffect(()=>{if(!(typeof window>"u"))try{localStorage.setItem(r,JSON.stringify(n));}catch(c){console.error("Error saving column visibility state:",c);}},[n,r]);let a=Ne.useCallback(c=>e.find(d=>d.id===c)?.locked?true:n[c]!==false,[n,e]),i=Ne.useCallback(c=>{e.find(d=>d.id===c)?.locked||o(d=>({...d,[c]:!d[c]}));},[e]),s=Ne.useCallback(()=>{let c={};e.forEach(u=>{c[u.id]=true;}),o(c);},[e]),l=Ne.useCallback(()=>{let c={};e.forEach(u=>{c[u.id]=u.locked===true;}),o(c);},[e]);return {visibleColumns:n,isColumnVisible:a,toggleColumn:i,showAllColumns:s,hideAllColumns:l,columns:e}}var KO=50,Us=150,Y6=3;function Jo({tableId:e,columns:t,storageKey:r}){let n=r||`table-columns-${e}`,o=Ne.useCallback(()=>t.reduce((C,S)=>(C[S.key]=S.defaultWidth||Us,C),{}),[t]),[a,i]=Ne.useState(()=>{try{let C=localStorage.getItem(n);if(C){let S=JSON.parse(C);return {widths:{...o(),...S},isResizing:!1,resizingColumn:null}}}catch{}return {widths:o(),isResizing:false,resizingColumn:null}}),s=Ne.useRef(0),l=Ne.useRef(0),c=Ne.useRef(null),u=Ne.useRef(false),d=Ne.useRef(t);Ne.useEffect(()=>{d.current=t;},[t]);let g=Ne.useCallback(C=>d.current.find(S=>S.key===C),[]);Ne.useEffect(()=>{try{localStorage.setItem(n,JSON.stringify(a.widths));}catch{}},[a.widths,n]);let p=Ne.useRef(null);p.current||(p.current={onPointerMove:C=>{if(!c.current)return;let S=C.clientX-s.current;if(!u.current){if(Math.abs(S)<Y6)return;u.current=true,i(z=>({...z,isResizing:true,resizingColumn:c.current})),document.body.style.cursor="col-resize",document.body.style.userSelect="none";}let O=g(c.current),D=O?.minWidth||KO,A=O?.maxWidth,E=Math.max(D,l.current+S);A&&(E=Math.min(A,E)),i(z=>({...z,widths:{...z.widths,[c.current]:E}}));},onPointerUp:()=>{c.current=null,u.current=false,i(C=>({...C,isResizing:false,resizingColumn:null})),document.removeEventListener("pointermove",p.current.onPointerMove),document.removeEventListener("pointerup",p.current.onPointerUp),document.removeEventListener("pointercancel",p.current.onPointerUp),document.body.style.cursor="",document.body.style.userSelect="";}}),Ne.useEffect(()=>()=>{p.current&&(document.removeEventListener("pointermove",p.current.onPointerMove),document.removeEventListener("pointerup",p.current.onPointerUp),document.removeEventListener("pointercancel",p.current.onPointerUp)),document.body.style.cursor="",document.body.style.userSelect="";},[]);let f=Ne.useRef(a.widths);Ne.useEffect(()=>{f.current=a.widths;},[a.widths]);let m=Ne.useCallback((C,S)=>{s.current=S,l.current=f.current[C]||Us,c.current=C,u.current=false,document.addEventListener("pointermove",p.current.onPointerMove),document.addEventListener("pointerup",p.current.onPointerUp),document.addEventListener("pointercancel",p.current.onPointerUp);},[]),b=Ne.useCallback(C=>({onPointerDown:S=>{S.preventDefault(),S.stopPropagation(),m(C,S.clientX);},onMouseDown:S=>{S.preventDefault(),S.stopPropagation();},draggable:false,onDragStart:S=>{S.preventDefault(),S.stopPropagation();},className:"resize-handle","data-resizing":a.resizingColumn===C}),[m,a.resizingColumn]),h=Ne.useCallback(C=>{let S=a.widths[C]||Us,D=g(C)?.minWidth||KO;return {width:S,minWidth:D,position:"relative"}},[a.widths,g]),w=t.reduce((C,S)=>C+(a.widths[S.key]||S.defaultWidth||Us),0),k=Ne.useCallback(()=>({minWidth:w}),[w]),R=Ne.useCallback(()=>{i(C=>({...C,widths:o()}));},[o]);return {widths:a.widths,isResizing:a.isResizing,totalWidth:w,getResizeHandleProps:b,getColumnStyle:h,getTableStyle:k,resetToDefaults:R}}function ea({storageKey:e,defaultOrder:t}){let[r,n]=Ne.useState(()=>{try{let l=localStorage.getItem(e);if(l){let c=JSON.parse(l),u=new Set(c),d=new Set(t),g=c.filter(f=>d.has(f)),p=t.filter(f=>!u.has(f));if(p.length>0){let f=[...g];for(let m of p){let b=t.indexOf(m),h=f.length;for(let w=0;w<f.length;w++)if(t.indexOf(f[w])>b){h=w;break}f.splice(h,0,m);}return f}return g.length>0?g:t}}catch(l){console.warn("Failed to load column order from localStorage:",l);}return t});Ne.useEffect(()=>{try{localStorage.setItem(e,JSON.stringify(r));}catch(l){console.warn("Failed to save column order to localStorage:",l);}},[e,r]);let o=Ne.useCallback((l,c)=>{l!==c&&n(u=>{let d=[...u],[g]=d.splice(l,1);return g!==void 0&&d.splice(c,0,g),d});},[]),a=Ne.useCallback((l,c)=>{n(u=>{let d=u.indexOf(l);if(d===-1)return u;let g=c==="left"?Math.max(0,d-1):Math.min(u.length-1,d+1);if(d===g)return u;let p=[...u],[f]=p.splice(d,1);return f!==void 0&&p.splice(g,0,f),p});},[]),i=Ne.useCallback(()=>{n(t);},[t]),s=Ne.useCallback(l=>{let c=new Map(l.map(u=>[u.id,u]));return r.map(u=>c.get(u)).filter(u=>u!==void 0)},[r]);return {columnOrder:r,moveColumn:o,moveColumnById:a,resetOrder:i,getOrderedColumns:s}}function ta(e,t,r=[]){let[n,o]=Ne.useState({isDragging:false,draggedId:null,dropIndex:null}),a=Ne.useCallback(d=>{r.includes(d)||o({isDragging:true,draggedId:d,dropIndex:null});},[r]),i=Ne.useCallback((d,g)=>{if(r.includes(d))return;let p=e.indexOf(d);if(p===-1)return;let f=g.currentTarget.getBoundingClientRect(),m=f.left+f.width/2,b=g.clientX<m?p:p+1;o(h=>({...h,dropIndex:b}));},[r,e]),s=Ne.useCallback(()=>{if(!n.draggedId||n.dropIndex===null){o({isDragging:false,draggedId:null,dropIndex:null});return}let d=e.indexOf(n.draggedId),g=n.dropIndex;d<g&&(g=g-1),d!==-1&&g!==-1&&d!==g&&t(d,g),o({isDragging:false,draggedId:null,dropIndex:null});},[n.draggedId,n.dropIndex,e,t]),l=Ne.useCallback(()=>{o({isDragging:false,draggedId:null,dropIndex:null});},[]),c=Ne.useCallback(d=>({draggable:!r.includes(d),onDragStart:g=>{if(r.includes(d)){g.preventDefault();return}g.dataTransfer.effectAllowed="move",a(d);},onDragOver:g=>{g.preventDefault(),g.dataTransfer.dropEffect="move",i(d,g);},onDrop:g=>{g.preventDefault(),s();},onDragEnd:l}),[r,a,i,s,l]),u=Ne.useCallback(d=>!n.isDragging||n.dropIndex===null?false:e.indexOf(d)===n.dropIndex,[n.isDragging,n.dropIndex,e]);return {dragState:n,getDragHandleProps:c,showDropIndicator:u}}function ra({page:e,pageSize:t,totalPages:r,totalItems:n,startIndex:o,endIndex:a,canGoNext:i,canGoPrev:s,pageSizeOptions:l,onPageChange:c,onPageSizeChange:u,onNextPage:d,onPrevPage:g,onFirstPage:p,onLastPage:f,className:m}){let b=()=>{let h=[],k=Math.floor(2.5),R=Math.max(1,e-k),C=Math.min(r,e+k);e<=k&&(C=Math.min(r,5)),e>r-k&&(R=Math.max(1,r-5+1)),R>1&&(h.push(1),R>2&&h.push("ellipsis"));for(let S=R;S<=C;S++)S!==1&&S!==r&&h.push(S);return C<r&&(C<r-1&&h.push("ellipsis"),h.push(r)),h};return n===0?null:jsxRuntime.jsxs("div",{className:N("flex flex-col sm:flex-row items-center justify-between gap-4 px-2 py-3",m),children:[jsxRuntime.jsxs("div",{className:"text-sm text-muted-foreground",children:["Showing ",o," to ",a," of ",n," items"]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-sm text-muted-foreground",children:"Per page:"}),jsxRuntime.jsxs(Tt,{value:String(t),onValueChange:h=>u(Number(h)),children:[jsxRuntime.jsx(ft,{className:"w-20 h-8",children:jsxRuntime.jsx(At,{})}),jsxRuntime.jsx(bt,{children:l.map(h=>jsxRuntime.jsx(Be,{value:String(h),children:h},h))})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx(j,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:p,disabled:!s,title:"First page",children:jsxRuntime.jsx(lucideReact.ChevronsLeft,{className:"h-4 w-4"})}),jsxRuntime.jsx(j,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:g,disabled:!s,title:"Previous page",children:jsxRuntime.jsx(lucideReact.ChevronLeft,{className:"h-4 w-4"})}),jsxRuntime.jsx("div",{className:"flex items-center gap-1",children:b().map((h,w)=>h==="ellipsis"?jsxRuntime.jsx("span",{className:"px-2 text-muted-foreground",children:"..."},`ellipsis-${w}`):jsxRuntime.jsx(j,{variant:e===h?"default":"outline",size:"icon",className:"h-8 w-8",onClick:()=>c(h),children:h},h))}),jsxRuntime.jsx(j,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:d,disabled:!i,title:"Next page",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"h-4 w-4"})}),jsxRuntime.jsx(j,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:f,disabled:!i,title:"Last page",children:jsxRuntime.jsx(lucideReact.ChevronsRight,{className:"h-4 w-4"})})]})]})]})}function Tb({data:e,columns:t,storageKey:r,getRowId:n,selectable:o=false,selectedIds:a,onSelectionChange:i,onRowClick:s,onRowContextMenu:l,sortField:c,sortOrder:u,onSort:d,actionsColumn:g,actionsColumnWidth:p=80,pageSize:f=25,pagination:m,hidePagination:b=false,className:h,rowClassName:w,enableHeaderContextMenu:k=true,lockedColumns:R=[],defaultColumnOrder:C,loading:S=false,emptyState:O}){let D=Ne.useMemo(()=>{let $=[];return o&&$.push({key:"select",defaultWidth:40,minWidth:40}),t.forEach(oe=>{$.push({key:oe.id,defaultWidth:oe.width?.default??150,minWidth:oe.width?.min??80,maxWidth:oe.width?.max});}),g&&$.push({key:"actions",defaultWidth:p,minWidth:60}),$},[t,o,g,p]),A=Ne.useMemo(()=>t.map($=>({id:$.id,label:typeof $.header=="string"?$.header:$.id,defaultVisible:$.visibility?.default??true,locked:$.visibility?.locked})),[t]),E=Ne.useMemo(()=>{if(C)return C;let $=[];return o&&$.push("select"),t.forEach(oe=>$.push(oe.id)),g&&$.push("actions"),$},[C,t,o,g]),{getResizeHandleProps:z,getColumnStyle:I,getTableStyle:P}=Jo({tableId:r,columns:D}),L=Qo({columns:A,storageKey:r}),{columnOrder:B,moveColumn:q}=ea({storageKey:`${r}-order`,defaultOrder:E}),{dragState:Y,getDragHandleProps:ne,showDropIndicator:Q}=ta(B,q,[...R,"select","actions"]),v=Zo({data:e,pageSize:f,storageKey:r}),U=m||v,[ee,T]=Ne.useState(null),ve=Ne.useCallback($=>{k&&($.preventDefault(),T({x:$.clientX,y:$.clientY}));},[k]);Ne.useEffect(()=>{if(!ee)return;let $=()=>T(null);return window.addEventListener("click",$),()=>{window.removeEventListener("click",$);}},[ee]);let Te=Ne.useMemo(()=>!o||!a||U.paginatedData.length===0?false:U.paginatedData.every($=>a.has(n($))),[o,a,U.paginatedData,n]),$e=Ne.useMemo(()=>{if(!o||!a)return false;let $=U.paginatedData.filter(oe=>a.has(n(oe)));return $.length>0&&$.length<U.paginatedData.length},[o,a,U.paginatedData,n]),_e=Ne.useCallback($=>{if(!i||!a)return;let oe=new Set(a);oe.has($)?oe.delete($):oe.add($),i(oe);},[a,i]),Se=Ne.useCallback(()=>{if(!i)return;let $=new Set(U.paginatedData.map(n));i($);},[U.paginatedData,n,i]),et=Ne.useCallback(()=>{i&&i(new Set);},[i]),Ue=Ne.useCallback($=>c!==$?jsxRuntime.jsx(lucideReact.ArrowUpDown,{className:"h-3.5 w-3.5 text-muted-foreground"}):u==="asc"?jsxRuntime.jsx(lucideReact.ChevronUp,{className:"h-3.5 w-3.5"}):jsxRuntime.jsx(lucideReact.ChevronDown,{className:"h-3.5 w-3.5"}),[c,u]),lt=Ne.useCallback($=>t.find(oe=>oe.id===$),[t]),ot=Ne.useCallback($=>{let oe={columnId:$.id,isSorted:c===$.sortKey,sortDirection:c===$.sortKey?u:void 0};return typeof $.header=="function"?$.header(oe):$.sortKey&&d?jsxRuntime.jsxs("button",{onClick:()=>d($.sortKey),className:N("flex items-center gap-1 hover:text-foreground transition-colors",c===$.sortKey&&"text-primary font-medium"),children:[$.header,Ue($.sortKey)]}):$.header},[c,u,d,Ue]);return jsxRuntime.jsx(pa,{children:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"overflow-auto border rounded-lg max-h-[calc(100vh-16rem)]",children:jsxRuntime.jsxs(po,{style:P(),className:N("resizable-table sticky-actions-table",h),children:[jsxRuntime.jsx(go,{className:"sticky top-0 z-20 bg-muted",children:jsxRuntime.jsxs(xr,{onContextMenu:ve,className:"border-t-0",children:[B.map($=>{if($==="select"&&o)return jsxRuntime.jsx(rn,{className:"sticky-select-header w-10 sticky left-0 z-20 bg-muted relative after:absolute after:right-0 after:top-0 after:bottom-0 after:w-px after:bg-border",children:jsxRuntime.jsx("input",{type:"checkbox",checked:Te,ref:_=>{_&&(_.indeterminate=$e);},onChange:_=>_.target.checked?Se():et(),className:"h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary cursor-pointer",title:Te?"Deselect all":"Select all visible"})},"select");let oe=lt($);return !oe||!L.isColumnVisible($)?null:jsxRuntime.jsxs(rn,{style:I($),...ne($),className:N("cursor-grab relative",Y.draggedId===$&&"column-dragging opacity-50",Q($)&&"drop-indicator"),children:[ot(oe),jsxRuntime.jsx("div",{...z($)})]},$)}),g&&jsxRuntime.jsx(rn,{className:"sticky right-0 z-20 bg-muted text-center relative before:absolute before:left-0 before:top-0 before:bottom-0 before:w-px before:bg-border",style:{width:p,minWidth:p,maxWidth:p},children:"Actions"})]})}),jsxRuntime.jsx(mo,{children:S?jsxRuntime.jsx(xr,{children:jsxRuntime.jsx(vr,{colSpan:B.length+(g?1:0),className:"!p-0 h-32",children:jsxRuntime.jsx("div",{className:"sticky left-0 w-screen max-w-full h-full bg-background flex justify-center items-center",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[jsxRuntime.jsx(lucideReact.Loader2,{className:"h-5 w-5 animate-spin"}),"Loading..."]})})})}):U.paginatedData.length===0?null:U.paginatedData.map($=>{let oe=n($),_=a?.has(oe)??false;return jsxRuntime.jsxs(xr,{className:N("group cursor-pointer bg-background hover:bg-muted transition-none",_&&"bg-primary/5",w?.($)),onClick:()=>s?.($),onContextMenu:Z=>{l&&(Z.preventDefault(),l($,{x:Z.clientX,y:Z.clientY}));},children:[B.map(Z=>{if(Z==="select"&&o)return jsxRuntime.jsx(vr,{className:N("sticky-select-cell w-10 sticky left-0 z-10 relative after:absolute after:right-0 after:top-0 after:bottom-0 after:w-px after:bg-border","bg-background group-hover:bg-muted",_&&"bg-primary/5 group-hover:bg-primary/10"),onClick:at=>at.stopPropagation(),children:jsxRuntime.jsx("input",{type:"checkbox",checked:_,onChange:()=>_e(oe),className:"h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary cursor-pointer"})},"select");let ue=lt(Z);if(!ue||!L.isColumnVisible(Z))return null;let Oe={columnId:Z,isDragging:Y.draggedId===Z};return jsxRuntime.jsx(vr,{style:I(Z),className:N(ue.className,Y.draggedId===Z&&"column-dragging"),children:ue.cell($,Oe)},Z)}),g&&jsxRuntime.jsx(vr,{className:N("sticky right-0 z-10 text-center relative before:absolute before:left-0 before:top-0 before:bottom-0 before:w-px before:bg-border","bg-background group-hover:bg-muted",_&&"bg-primary/5 group-hover:bg-primary/10"),style:{width:p,minWidth:p,maxWidth:p},onClick:Z=>Z.stopPropagation(),children:g($)})]},oe)})})]})}),!S&&U.paginatedData.length===0&&jsxRuntime.jsx("div",{className:"empty-state-container flex-1 flex items-center justify-center bg-background",children:O||jsxRuntime.jsx("span",{className:"block text-center text-muted-foreground py-8",children:"No data"})}),!b&&!S&&U.totalPages>1&&jsxRuntime.jsx(ra,{page:U.page,pageSize:U.pageSize,totalItems:U.totalItems,totalPages:U.totalPages,startIndex:U.startIndex,endIndex:U.endIndex,canGoPrev:U.canGoPrev,canGoNext:U.canGoNext,onPageChange:U.setPage,onPageSizeChange:U.setPageSize,onNextPage:U.nextPage,onPrevPage:U.prevPage,onFirstPage:"firstPage"in U?U.firstPage:()=>U.setPage(1),onLastPage:"lastPage"in U?U.lastPage:()=>U.setPage(U.totalPages),pageSizeOptions:U.pageSizeOptions}),ee&&jsxRuntime.jsxs("div",{className:"fixed z-50 min-w-[200px] overflow-y-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95",style:{top:ee.y,left:ee.x,maxHeight:`calc(100vh - ${ee.y}px - 20px)`},onClick:$=>$.stopPropagation(),children:[jsxRuntime.jsx("div",{className:"px-2 py-1.5 text-xs font-medium text-muted-foreground",children:"Toggle columns"}),jsxRuntime.jsx("div",{className:"h-px bg-border my-1"}),L.columns.map($=>{let oe=L.isColumnVisible($.id),_=$.locked===true;return jsxRuntime.jsxs("button",{onClick:()=>!_&&L.toggleColumn($.id),disabled:_,className:N("flex items-center gap-2 w-full px-2 py-1.5 text-sm rounded-sm hover:bg-accent",_&&"opacity-50 cursor-not-allowed"),children:[jsxRuntime.jsx("div",{className:"w-4 h-4 flex items-center justify-center",children:oe&&jsxRuntime.jsx(lucideReact.Check,{className:"h-3.5 w-3.5 text-primary"})}),jsxRuntime.jsx("span",{className:"flex-1 text-left",children:$.label}),_&&jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"Required"})]},$.id)}),jsxRuntime.jsx("div",{className:"h-px bg-border my-1"}),jsxRuntime.jsxs("button",{onClick:()=>L.showAllColumns(),className:"flex items-center gap-2 w-full px-2 py-1.5 text-sm rounded-sm hover:bg-accent",children:[jsxRuntime.jsx(lucideReact.Eye,{className:"h-4 w-4"}),"Show All"]}),jsxRuntime.jsxs("button",{onClick:()=>L.hideAllColumns(),className:"flex items-center gap-2 w-full px-2 py-1.5 text-sm rounded-sm hover:bg-accent",children:[jsxRuntime.jsx(lucideReact.EyeOff,{className:"h-4 w-4"}),"Hide Optional"]})]})]})})}function oa({page:e,pageSize:t,totalPages:r,totalItems:n,startIndex:o,endIndex:a,canGoNext:i,canGoPrev:s,pageSizeOptions:l,setPage:c,setPageSize:u,nextPage:d,prevPage:g,className:p}){return n===0?null:jsxRuntime.jsxs("div",{className:N("flex items-center gap-3 text-sm",p),children:[jsxRuntime.jsxs("div",{className:"hidden md:flex items-center gap-1.5",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground hidden lg:inline",children:"Rows:"}),jsxRuntime.jsxs(Tt,{value:String(t),onValueChange:f=>u(Number(f)),children:[jsxRuntime.jsx(ft,{className:"w-16 h-8 text-xs",children:jsxRuntime.jsx(At,{})}),jsxRuntime.jsx(bt,{children:l.map(f=>jsxRuntime.jsx(Be,{value:String(f),children:f},f))})]})]}),r>1&&jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx(j,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:g,disabled:!s,title:"Previous page",children:jsxRuntime.jsx(lucideReact.ChevronLeft,{className:"h-4 w-4"})}),jsxRuntime.jsxs("span",{className:"hidden sm:inline px-2 text-muted-foreground tabular-nums min-w-[60px] text-center",children:[e," / ",r]}),jsxRuntime.jsx(j,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:d,disabled:!i,title:"Next page",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"h-4 w-4"})})]}),jsxRuntime.jsxs("span",{className:"text-muted-foreground whitespace-nowrap hidden lg:inline",children:["Showing ",o,"\u2013",a," of ",n]})]})}function Ab({title:e,description:t,search:r,onSearchChange:n,searchPlaceholder:o="Search...",filters:a,activeFilterCount:i=0,onClearFilters:s,pagination:l,actions:c,beforeTable:u,children:d,className:g,loading:p,loadingComponent:f}){let m=l&&l.totalItems>0;return jsxRuntime.jsxs("div",{className:N("flex flex-col h-full",g),children:[jsxRuntime.jsxs("div",{className:"data-table-page-header flex-shrink-0 space-y-4 pb-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h1",{className:"text-3xl font-bold",children:e}),t&&jsxRuntime.jsx("p",{className:"text-muted-foreground",children:t})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[n!==void 0&&jsxRuntime.jsxs("div",{className:"relative w-full sm:w-auto sm:min-w-[200px] sm:max-w-xs",children:[jsxRuntime.jsx(lucideReact.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none z-10"}),jsxRuntime.jsx(Et,{placeholder:o,value:r||"",onChange:b=>n(b.target.value),className:"pl-9 h-9"}),r&&jsxRuntime.jsx("button",{type:"button",onClick:()=>n(""),className:"absolute right-2 top-1/2 transform -translate-y-1/2 p-1 rounded-sm hover:bg-muted",children:jsxRuntime.jsx(lucideReact.X,{className:"h-3 w-3 text-muted-foreground"})})]}),a&&a.length>0&&jsxRuntime.jsxs(Lr,{children:[jsxRuntime.jsx(Dr,{asChild:true,children:jsxRuntime.jsxs(j,{variant:"outline",size:"sm",className:"gap-2 h-9",children:[jsxRuntime.jsx(lucideReact.Filter,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{className:"hidden sm:inline",children:"Filters"}),i>0&&jsxRuntime.jsx("span",{className:"rounded-full bg-primary text-primary-foreground px-2 py-0.5 text-xs font-medium",children:i})]})}),jsxRuntime.jsx(hr,{className:"w-80 overflow-y-auto",align:"start",collisionPadding:16,style:{maxHeight:"var(--radix-popover-content-available-height)"},children:jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("h4",{className:"font-medium text-sm",children:"Filters"}),i>0&&s&&jsxRuntime.jsx(j,{variant:"ghost",size:"sm",onClick:s,className:"h-auto p-0 text-xs text-destructive hover:text-destructive",children:"Clear all"})]}),jsxRuntime.jsx("div",{className:"space-y-3",children:a.map(b=>jsxRuntime.jsxs("div",{className:"space-y-1.5",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:b.label}),b.render()]},b.id))})]})})]}),i>0&&s&&jsxRuntime.jsxs(j,{variant:"ghost",size:"sm",onClick:s,className:"h-9 gap-1.5 text-muted-foreground hover:text-foreground",title:"Clear filters",children:[jsxRuntime.jsx(lucideReact.X,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{className:"hidden sm:inline",children:"Clear"})]}),m&&jsxRuntime.jsx(oa,{...l}),jsxRuntime.jsx("div",{className:"flex-1"}),c&&jsxRuntime.jsx("div",{className:"flex items-center gap-2 flex-shrink-0",children:c})]})]}),u&&jsxRuntime.jsx("div",{className:"px-6 pb-2",children:u}),jsxRuntime.jsx("div",{className:"relative flex-1 min-h-0",children:jsxRuntime.jsx("div",{className:"data-table-scroll-container h-full",children:p?f||jsxRuntime.jsx("div",{className:"flex items-center justify-center h-full",children:jsxRuntime.jsx("div",{className:"text-muted-foreground",children:"Loading..."})}):d})})]})}function Nb({selectedCount:e,onClear:t,children:r,itemLabel:n,className:o}){if(e===0)return null;let a=n??(e===1?"item":"items");return jsxRuntime.jsx(Re,{className:N("p-3 bg-primary/5 border-primary/20",o),children:jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsxs("span",{className:"font-medium text-sm",role:"status","aria-live":"polite",children:[e," ",a," selected"]}),jsxRuntime.jsxs(j,{variant:"ghost",size:"sm",onClick:t,"aria-label":"Clear selection",children:[jsxRuntime.jsx(lucideReact.X,{className:"h-4 w-4 mr-1","aria-hidden":"true"}),"Clear"]})]}),jsxRuntime.jsx("div",{className:"flex items-center gap-2",role:"group","aria-label":"Batch actions",children:r})]})})}function Rb({columns:e,isColumnVisible:t,toggleColumn:r,showAllColumns:n,hideAllColumns:o}){let a=e.filter(s=>t(s.id)).length,i=e.filter(s=>!s.locked);return jsxRuntime.jsxs(Pb,{children:[jsxRuntime.jsx(Fb,{asChild:true,children:jsxRuntime.jsxs(j,{variant:"outline",size:"sm",className:"gap-2",children:[jsxRuntime.jsx(lucideReact.Columns3,{className:"h-4 w-4"}),"Columns",jsxRuntime.jsxs("span",{className:"text-muted-foreground text-xs",children:["(",a,"/",e.length,")"]})]})}),jsxRuntime.jsxs(Qs,{align:"end",className:"w-48",children:[jsxRuntime.jsx(Js,{className:"font-normal text-xs text-muted-foreground",children:"Toggle columns"}),jsxRuntime.jsx(ua,{}),e.map(s=>{let l=t(s.id),c=s.locked===true;return jsxRuntime.jsxs(io,{onClick:u=>{u.preventDefault(),c||r(s.id);},className:N("gap-2 cursor-pointer",c&&"opacity-50 cursor-not-allowed"),disabled:c,children:[jsxRuntime.jsx("div",{className:"w-4 h-4 flex items-center justify-center",children:l?jsxRuntime.jsx(lucideReact.Check,{className:"h-3.5 w-3.5 text-primary"}):jsxRuntime.jsx("div",{className:"h-3.5 w-3.5"})}),jsxRuntime.jsx("span",{className:"flex-1",children:s.label}),c&&jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"Required"})]},s.id)}),i.length>1&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ua,{}),jsxRuntime.jsxs(io,{onClick:s=>{s.preventDefault(),n();},className:"gap-2 cursor-pointer",children:[jsxRuntime.jsx(lucideReact.Eye,{className:"h-4 w-4"}),"Show All"]}),jsxRuntime.jsxs(io,{onClick:s=>{s.preventDefault(),o();},className:"gap-2 cursor-pointer",children:[jsxRuntime.jsx(lucideReact.EyeOff,{className:"h-4 w-4"}),"Hide Optional"]})]})]})]})}function Ib({search:e,onSearchChange:t,searchPlaceholder:r="Search...",filters:n,activeFilterCount:o=0,onClearFilters:a,className:i,children:s}){let c=n?.some(u=>u.type==="multi")?"w-[420px]":"w-80";return jsxRuntime.jsxs("div",{className:N("flex items-center gap-3 flex-wrap",i),children:[t!==void 0&&jsxRuntime.jsxs("div",{className:"relative flex-1 min-w-[200px] max-w-xs",children:[jsxRuntime.jsx(lucideReact.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none z-10"}),jsxRuntime.jsx(Et,{placeholder:r,value:e||"",onChange:u=>t(u.target.value),className:"pl-9 h-9"}),e&&jsxRuntime.jsx("button",{type:"button",onClick:()=>t(""),className:"absolute right-2 top-1/2 transform -translate-y-1/2 p-1 rounded-sm hover:bg-muted",children:jsxRuntime.jsx(lucideReact.X,{className:"h-3 w-3 text-muted-foreground"})})]}),n&&n.length>0&&jsxRuntime.jsxs(Lr,{children:[jsxRuntime.jsx(Dr,{asChild:true,children:jsxRuntime.jsxs(j,{variant:"outline",size:"sm",className:"gap-2 h-9",children:[jsxRuntime.jsx(lucideReact.Filter,{className:"h-4 w-4"}),"Filters",o>0&&jsxRuntime.jsx("span",{className:"ml-1 rounded-full bg-primary text-primary-foreground px-2 py-0.5 text-xs font-medium",children:o})]})}),jsxRuntime.jsx(hr,{className:N(c,"overflow-y-auto"),align:"start",collisionPadding:16,style:{maxHeight:"var(--radix-popover-content-available-height)"},children:jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("h4",{className:"font-medium text-sm",children:"Filters"}),o>0&&a&&jsxRuntime.jsx(j,{variant:"ghost",size:"sm",onClick:a,className:"h-auto p-0 text-xs text-destructive hover:text-destructive",children:"Clear all"})]}),jsxRuntime.jsx("div",{className:"space-y-4",children:n.map(u=>jsxRuntime.jsxs("div",{className:"space-y-1.5",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:u.label}),u.render()]},u.id))})]})})]}),o>0&&a&&jsxRuntime.jsxs(j,{variant:"ghost",size:"sm",onClick:a,className:"h-9 gap-1.5 text-muted-foreground hover:text-foreground",children:[jsxRuntime.jsx(lucideReact.X,{className:"h-4 w-4"}),"Clear"]}),jsxRuntime.jsx("div",{className:"flex-1"}),s]})}function _b({options:e,selected:t,onChange:r,maxHeight:n=200,columns:o=2,showBulkActions:a=true,className:i}){let s=p=>{let f=new Set(t);f.has(p)?f.delete(p):f.add(p),r(f);},l=()=>{r(new Set(e.map(p=>p.value)));},c=()=>{r(new Set);},u={1:"grid-cols-1",2:"grid-cols-2",3:"grid-cols-3"},d=e.length>0&&t.size===e.length,g=t.size===0;return jsxRuntime.jsxs("div",{className:N("space-y-2",i),children:[a&&e.length>3&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[jsxRuntime.jsx(j,{type:"button",variant:"ghost",size:"sm",onClick:l,disabled:d,className:"h-6 px-2 text-xs text-muted-foreground hover:text-foreground",children:"Select all"}),jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"\xB7"}),jsxRuntime.jsx(j,{type:"button",variant:"ghost",size:"sm",onClick:c,disabled:g,className:"h-6 px-2 text-xs text-muted-foreground hover:text-foreground",children:"Clear"}),t.size>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"\xB7"}),jsxRuntime.jsxs("span",{className:"text-muted-foreground",children:[t.size," selected"]})]})]}),jsxRuntime.jsx("div",{className:N("overflow-y-auto",e.length>6&&"pr-1"),style:{maxHeight:`${n}px`},children:jsxRuntime.jsx("div",{className:N("grid gap-1",u[o]),children:e.map(p=>jsxRuntime.jsxs("label",{className:N("flex items-center gap-2 px-2 py-1.5 rounded-md cursor-pointer","hover:bg-muted/50 transition-colors",t.has(p.value)&&"bg-muted/30"),children:[jsxRuntime.jsx(Xs,{checked:t.has(p.value),onCheckedChange:()=>s(p.value),className:"h-3.5 w-3.5"}),p.render?jsxRuntime.jsx("span",{className:"flex items-center gap-1.5 text-sm truncate",children:p.render()}):jsxRuntime.jsx("span",{className:"text-sm truncate",children:p.label})]},p.value))})}),e.length===0&&jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground text-center py-2",children:"No options available"})]})}/*! Bundled license information:
|
|
61
|
+
`})]})}var e6={active:{bg:"bg-green-500",ring:"ring-green-400"},success:{bg:"bg-emerald-500",ring:"ring-emerald-400"},inactive:{bg:"bg-gray-400",ring:"ring-gray-300"},warning:{bg:"bg-yellow-500",ring:"ring-yellow-400"},error:{bg:"bg-red-500",ring:"ring-red-400"}},t6={xs:"h-2 w-2",sm:"h-3 w-3",md:"h-4 w-4",lg:"h-5 w-5"};function fb({status:e,size:t="sm",animate:r=true,label:n,className:o}){let a=e6[e],i=r&&(e==="active"||e==="warning"||e==="error");return jsxRuntime.jsxs("div",{className:N("inline-flex items-center gap-2",o),children:[jsxRuntime.jsxs("span",{className:"relative inline-flex",children:[i&&jsxRuntime.jsx("span",{className:N("absolute inline-flex h-full w-full rounded-full opacity-75",a.bg,e==="active"&&"animate-ping",e==="warning"&&"animate-pulse",e==="error"&&"animate-pulse")}),jsxRuntime.jsx("span",{className:N("relative inline-flex rounded-full",t6[t],a.bg,i&&"ring-1",i&&a.ring)})]}),n&&jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:n})]})}function bb({data:e,width:t=100,height:r=30,color:n="#10b981",strokeWidth:o=2,fill:a=false,className:i}){let s=Ne.useMemo(()=>{if(!e||e.length===0)return "";let c=Math.max(...e),u=Math.min(...e),d=c-u||1;return e.map((g,p)=>{let f=p/(e.length-1)*t,m=r-(g-u)/d*r;return `${f},${m}`}).join(" ")},[e,t,r]);if(!e||e.length===0)return jsxRuntime.jsx("svg",{width:t,height:r,className:i,children:jsxRuntime.jsx("line",{x1:"0",y1:r/2,x2:t,y2:r/2,stroke:"#e5e7eb",strokeWidth:1})});let l=s?`0,${r} ${s} ${t},${r}`:"";return jsxRuntime.jsxs("svg",{width:t,height:r,className:i,children:[a&&s&&jsxRuntime.jsx("polygon",{points:l,fill:n,fillOpacity:.1}),s&&jsxRuntime.jsx("polyline",{points:s,fill:"none",stroke:n,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),e.length>0&&jsxRuntime.jsx("circle",{cx:t,cy:r-(e[e.length-1]-Math.min(...e))/(Math.max(...e)-Math.min(...e)||1)*r,r:o,fill:n})]})}function a6({data:e,columns:t,keyField:r,title:n,description:o,showActivity:a=false,activityField:i="activity",activityDecay:s=1e3,showSparkline:l=false,sparklineField:c="value",sparklineHistory:u,sparklineColor:d="#10b981",showStatus:g=false,statusField:p="status",statusConfig:f,expandable:m=false,childrenField:b="children",defaultExpanded:h=false,className:w,striped:k=false,hover:R=true,compact:C=false,onRowClick:S,onRefresh:O}){let[D,A]=Ne.useState(new Set),[E,z]=Ne.useState(new Map);Ne.useEffect(()=>{if(h&&m){let L=e.map(B=>B[r]);A(new Set(L));}},[h,m,e,r]),Ne.useEffect(()=>{if(a){let L=new Map;e.forEach(B=>{let q=B[r],Y=B[i];Y&&Y!=="inactive"&&(L.set(q,Y),setTimeout(()=>{z(ne=>{let Q=new Map(ne);return Q.delete(q),Q});},s));}),z(B=>new Map([...B,...L]));}},[e,a,r,i,s]);let I=Ne.useCallback(L=>{A(B=>{let q=new Set(B);return q.has(L)?q.delete(L):q.add(L),q});},[]),P=(L,B=0)=>{let q=L[r],Y=D.has(q),ne=m&&L[b]&&L[b].length>0,Q=E.get(q)||"inactive";return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(xr,{className:N(R&&"hover:bg-gray-50 transition-colors",S&&"cursor-pointer",B>0&&"bg-gray-50/50"),onClick:()=>S?.(L),children:t.map((v,U)=>jsxRuntime.jsx(vr,{className:N(v.align==="center"&&"text-center",v.align==="right"&&"text-right",C&&"py-2",U===0&&B>0&&`pl-${4+B*4}`),style:{width:v.width},children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[U===0&&ne&&jsxRuntime.jsx("button",{onClick:ee=>{ee.stopPropagation(),I(q);},className:"p-0.5 hover:bg-gray-200 rounded",children:Y?"\u25BC":"\u25B6"}),U===0&&a&&jsxRuntime.jsx(fb,{status:Q,size:"sm"}),v.render?v.render(v.accessor(L),L):v.accessor(L),v.key===p&&g&&f&&jsxRuntime.jsxs(it,{variant:f[L[p]]?.variant||"default",children:[f[L[p]]?.icon,f[L[p]]?.label||L[p]]}),v.key===c&&l&&u&&jsxRuntime.jsx(bb,{data:u.get(q)||[],color:d,width:60,height:20})]})},v.key))},q),Y&&ne&&L[b].map(v=>P(v,B+1))]})};return jsxRuntime.jsxs(Re,{className:w,children:[(n||o)&&jsxRuntime.jsxs("div",{className:"p-4 border-b",children:[n&&jsxRuntime.jsx("h3",{className:"font-semibold text-lg",children:n}),o&&jsxRuntime.jsx("p",{className:"text-sm text-gray-600 mt-1",children:o})]}),jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsxs(po,{children:[jsxRuntime.jsx(go,{children:jsxRuntime.jsx(xr,{children:t.map(L=>jsxRuntime.jsx(rn,{className:N(L.align==="center"&&"text-center",L.align==="right"&&"text-right"),style:{width:L.width},children:L.label},L.key))})}),jsxRuntime.jsx(mo,{children:e.length===0?jsxRuntime.jsx(xr,{children:jsxRuntime.jsx(vr,{colSpan:t.length,className:"text-center py-8 text-gray-500",children:"No data available"})}):e.map(L=>P(L))})]})})]})}function s6({stats:e,columns:t=4,className:r}){let n={1:"grid-cols-1",2:"grid-cols-1 md:grid-cols-2",3:"grid-cols-1 md:grid-cols-2 lg:grid-cols-3",4:"grid-cols-1 md:grid-cols-2 lg:grid-cols-4",5:"grid-cols-1 md:grid-cols-2 lg:grid-cols-5",6:"grid-cols-1 md:grid-cols-3 lg:grid-cols-6"},o={default:"",primary:"border-blue-200 bg-blue-50/50",success:"border-green-200 bg-green-50/50",warning:"border-yellow-200 bg-yellow-50/50",danger:"border-red-200 bg-red-50/50"},a={default:"text-gray-600",primary:"text-blue-600",success:"text-green-600",warning:"text-yellow-600",danger:"text-red-600"};return jsxRuntime.jsx("div",{className:N(`grid gap-4 ${n[t]}`,r),children:e.map((i,s)=>{let l=i.icon,c=i.color||"default";return jsxRuntime.jsx(Re,{className:N("p-4 transition-all hover:shadow-md",o[c],i.className),children:jsxRuntime.jsx("div",{className:"flex items-start justify-between",children:jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[l&&jsxRuntime.jsx(l,{className:N("h-4 w-4",a[c])}),jsxRuntime.jsx("p",{className:"text-sm font-medium text-gray-600",children:i.label})]}),jsxRuntime.jsxs("div",{className:"mt-2",children:[jsxRuntime.jsx("p",{className:"text-2xl font-bold",children:i.value}),i.description&&jsxRuntime.jsx("p",{className:"text-xs text-gray-500 mt-1",children:i.description}),i.trend&&jsxRuntime.jsxs("div",{className:"flex items-center gap-1 mt-2",children:[jsxRuntime.jsxs("span",{className:N("text-xs font-medium",i.trend.positive?"text-green-600":"text-red-600"),children:[i.trend.positive?"\u2191":"\u2193",Math.abs(i.trend.value),"%"]}),i.trend.label&&jsxRuntime.jsx("span",{className:"text-xs text-gray-500",children:i.trend.label})]})]})]})})},s)})})}function l6({label:e,value:t,icon:r,trend:n,className:o}){return jsxRuntime.jsxs("div",{className:N("flex items-center justify-between p-3 bg-white rounded-lg border",o),children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[r&&jsxRuntime.jsx("div",{className:"p-2 bg-gray-100 rounded",children:jsxRuntime.jsx(r,{className:"h-4 w-4 text-gray-600"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{className:"text-xs text-gray-600",children:e}),jsxRuntime.jsx("p",{className:"font-semibold",children:t})]})]}),n!==void 0&&jsxRuntime.jsxs("span",{className:N("text-xs font-medium",n>=0?"text-green-600":"text-red-600"),children:[n>=0?"\u2191":"\u2193"," ",Math.abs(n),"%"]})]})}function c6({stats:e}){if(!e)return null;let{total:t,error:r,warn:n,info:o,debug:a,fileSize:i,oldestEntry:s,newestEntry:l}=e;return jsxRuntime.jsxs(Re,{className:"p-4 mb-4",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-6 gap-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Total"}),jsxRuntime.jsx("div",{className:"text-xl font-semibold",children:t??0})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Errors"}),jsxRuntime.jsx(it,{variant:"destructive",children:r??0})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Warnings"}),jsxRuntime.jsx(it,{variant:"secondary",children:n??0})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Info"}),jsxRuntime.jsx(it,{variant:"outline",children:o??0})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Debug"}),jsxRuntime.jsx(it,{variant:"outline",children:a??0})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"File Size"}),jsxRuntime.jsx("div",{className:"text-xl font-semibold",children:String(i??"-")})]})]}),(s||l)&&jsxRuntime.jsxs("div",{className:"mt-3 text-xs text-muted-foreground",children:[s&&jsxRuntime.jsxs("span",{children:["Oldest: ",s," "]}),l&&jsxRuntime.jsxs("span",{children:["Newest: ",l]})]})]})}function m6({categories:e,onSave:t,onLoad:r,onValidate:n,onRestartRequired:o,title:a="Settings",description:i="Configure application preferences",showResetButton:s=true,showUndoButton:l=true,customFields:c={},renderCategory:u,renderSetting:d,autoSave:g=false,autoSaveDelay:p=3e3,confirmReset:f=true,persistState:m=true,className:b,containerClassName:h,categoryClassName:w,settingClassName:k,height:R="calc(100vh - 200px)",maxContentWidth:C="800px"}){let[S,O]=Ne.useState({}),[D,A]=Ne.useState({}),[E,z]=Ne.useState({}),[I,P]=Ne.useState(true),[L,B]=Ne.useState(false),[q,Y]=Ne.useState(e?.[0]?.id||""),[ne,Q]=Ne.useState({}),[v,U]=Ne.useState(false),[ee,T]=Ne.useState(false),[ve,Te]=Ne.useState(null),$e=()=>{let _={};return e.forEach(Z=>{(Z.settings||[]).forEach(ue=>{_[ue.key]=ue.defaultValue;});}),_};Ne.useEffect(()=>{(async()=>{P(true);try{let Z=r?await r():$e();if(O(Z),A(Z),m){let ue=localStorage.getItem("settings-active-category");ue&&e.find(Oe=>Oe.id===ue)&&Y(ue);}}catch(Z){console.error("Failed to load settings:",Z),O($e()),A($e());}finally{P(false);}})();},[]),Ne.useEffect(()=>{let _=JSON.stringify(S)!==JSON.stringify(D);T(_);},[S,D]),Ne.useEffect(()=>{if(!g||!ee)return;let _=setTimeout(()=>{et();},p);return ()=>clearTimeout(_)},[S,g,p,ee]),Ne.useEffect(()=>{m&&localStorage.setItem("settings-active-category",q);},[q,m]);let _e=(_,Z)=>_.validation?_.validation(Z):null,Se=()=>{let _={},Z=false;if(e.forEach(ue=>{(ue.settings||[]).forEach(Oe=>{let at=_e(Oe,S[Oe.key]);at&&(_[Oe.key]=at,Z=true);});}),n){let ue=n(S);ue&&(Object.assign(_,ue),Z=true);}return z(_),!Z},et=async()=>{if(Se()){B(true);try{let Z=Object.keys(S).filter(ue=>S[ue]!==D[ue]).filter(ue=>e.flatMap(at=>at.settings||[]).find(at=>at.key===ue)?.requiresRestart);Z.length>0&&(U(!0),o?.(Z)),await t(S),A(S);}catch(_){console.error("Failed to save settings:",_),Te(_ instanceof Error?_.message:"Failed to save settings. Please try again.");}finally{B(false);}}},Ue=()=>{if(f&&!confirm("Reset all settings to defaults? This will override your current configuration."))return;let _=$e();O(_);},lt=()=>{O(D);},ot=(_,Z)=>{O(ue=>({...ue,[_]:Z})),E[_]&&z(ue=>{let Oe={...ue};return delete Oe[_],Oe}),ve&&Te(null);},$=_=>{if(_.hidden)return null;let Z=S[_.key]??_.defaultValue,ue=E[_.key],Oe=ne[_.key];if(_.showIf&&!_.showIf(S))return null;let at=_.inputWidth==="small"?"max-w-[180px]":_.inputWidth==="large"?"w-full max-w-xl":"max-w-sm";if(_.type==="custom"||_.customComponent){let Fe=_.customComponent||c[_.type];if(Fe)return jsxRuntime.jsx(Fe,{value:Z,onChange:Zr=>ot(_.key,Zr),error:ue,disabled:L,setting:_})}let or=c[_.type];if(or)return jsxRuntime.jsx(or,{value:Z,onChange:Fe=>ot(_.key,Fe),error:ue,disabled:L,setting:_});switch(_.type){case "string":case "text":case "password":return jsxRuntime.jsxs("div",{className:N("flex items-center gap-2",at),children:[jsxRuntime.jsx(Et,{id:_.key,type:_.type==="password"&&!Oe?"password":"text",value:Z||"",onChange:Fe=>ot(_.key,Fe.target.value),className:N(ue&&"border-red-500",at),placeholder:_.placeholder||(_.type==="password"?"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022":void 0),disabled:L}),_.suffix&&jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:_.suffix})]});case "number":return jsxRuntime.jsxs("div",{className:N("flex items-center gap-2",at),children:[jsxRuntime.jsx(Et,{id:_.key,type:"number",value:Z??"",onChange:Fe=>ot(_.key,parseFloat(Fe.target.value)||0),className:N(ue&&"border-red-500",at),placeholder:_.placeholder,disabled:L,step:_.step,min:_.min,max:_.max}),_.suffix&&jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:_.suffix})]});case "boolean":return jsxRuntime.jsx(zt,{id:_.key,checked:Z||false,onCheckedChange:Fe=>ot(_.key,Fe),disabled:L});case "select":return jsxRuntime.jsxs(Tt,{value:String(Z||_.defaultValue),onValueChange:Fe=>ot(_.key,Fe),disabled:L,children:[jsxRuntime.jsx(ft,{id:_.key,className:N(ue&&"border-red-500"),children:jsxRuntime.jsx(At,{})}),jsxRuntime.jsx(bt,{children:_.options?.map(Fe=>jsxRuntime.jsx(Be,{value:String(Fe.value),children:Fe.label},Fe.value))})]});default:return null}},oe=e.find(_=>_.id===q);return jsxRuntime.jsxs("div",{className:N("flex flex-col",b),style:{height:R},children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-6 shrink-0",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h1",{className:"text-3xl font-bold",children:a}),jsxRuntime.jsx("p",{className:"text-muted-foreground",children:i})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[l&&ee&&jsxRuntime.jsxs(j,{variant:"outline",onClick:lt,disabled:L,children:[jsxRuntime.jsx(lucideReact.Undo,{className:"h-4 w-4 mr-2"}),"Undo"]}),s&&jsxRuntime.jsxs(j,{variant:"outline",onClick:Ue,disabled:L,children:[jsxRuntime.jsx(lucideReact.RotateCcw,{className:"h-4 w-4 mr-2"}),"Defaults"]}),jsxRuntime.jsx(j,{onClick:et,disabled:!ee||L,className:N("transition-all",ee&&"ring-2 ring-primary/20"),children:L?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(lucideReact.RefreshCw,{className:"h-4 w-4 mr-2 animate-spin"}),"Saving..."]}):ee?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(lucideReact.Save,{className:"h-4 w-4 mr-2"}),"Save"]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(lucideReact.Check,{className:"h-4 w-4 mr-2"}),"Saved"]})})]})]}),ve&&jsxRuntime.jsxs(ct,{variant:"destructive",className:"mb-6 shrink-0",children:[jsxRuntime.jsx(lucideReact.AlertCircle,{className:"h-4 w-4"}),jsxRuntime.jsx(ut,{children:ve})]}),jsxRuntime.jsxs("div",{className:N("flex gap-6 flex-1 min-h-0",h),children:[jsxRuntime.jsxs(Re,{className:"w-56 shrink-0 flex flex-col min-h-0",children:[jsxRuntime.jsx("div",{className:"p-4 border-b shrink-0",children:jsxRuntime.jsx("h3",{className:"font-semibold",children:"Categories"})}),jsxRuntime.jsx("div",{className:"flex-1 overflow-y-auto p-2 min-h-0",children:jsxRuntime.jsx("div",{className:"space-y-1",children:e.map(_=>{let Z=_.icon;return jsxRuntime.jsxs("button",{onClick:()=>Y(_.id),className:N("w-full flex items-center gap-3 px-3 py-2 rounded-md text-sm transition-colors",q===_.id?"bg-primary text-primary-foreground":"hover:bg-muted",w),children:[Z&&jsxRuntime.jsx(Z,{className:"h-4 w-4 shrink-0"}),jsxRuntime.jsx("span",{className:"text-left truncate",children:_.label})]},_.id)})})})]}),jsxRuntime.jsx("div",{className:"flex-1 min-h-0 flex flex-col",children:I?jsxRuntime.jsx(Re,{className:"p-8",children:jsxRuntime.jsx("div",{className:"flex items-center justify-center",children:jsxRuntime.jsx(lucideReact.RefreshCw,{className:"h-8 w-8 animate-spin text-muted-foreground"})})}):oe?.component?jsxRuntime.jsxs(Re,{className:"p-6 flex-1 min-h-0 flex flex-col overflow-hidden",children:[jsxRuntime.jsxs("div",{className:"mb-6 flex-shrink-0",children:[jsxRuntime.jsx("h2",{className:"text-xl font-semibold",children:oe.label}),oe.description&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:oe.description})]}),jsxRuntime.jsx("div",{className:"flex-1 min-h-0",children:jsxRuntime.jsx(oe.component,{category:oe})})]}):oe?jsxRuntime.jsx(Re,{className:"p-6 flex-1 min-h-0 overflow-y-auto",children:jsxRuntime.jsx("div",{style:{maxWidth:C},children:u?u(oe,jsxRuntime.jsx("div",{className:"space-y-6",children:(oe.settings||[]).map(_=>{let Z=$(_);if(!Z)return null;let ue=jsxRuntime.jsxs("div",{className:N("space-y-2",k),children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsxs(gt,{htmlFor:_.key,className:"text-sm font-medium",children:[_.label,_.requiresRestart&&jsxRuntime.jsx("span",{className:"ml-2 text-xs text-amber-600 dark:text-amber-400",children:"(Requires restart)"})]}),_.help&&jsxRuntime.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground transition-colors",title:_.help,children:jsxRuntime.jsx(lucideReact.Info,{className:"h-3 w-3"})})]}),_.type==="password"&&S[_.key]&&jsxRuntime.jsx(j,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-2",onClick:()=>Q(Oe=>({...Oe,[_.key]:!Oe[_.key]})),children:ne[_.key]?jsxRuntime.jsx(lucideReact.EyeOff,{className:"h-3 w-3"}):jsxRuntime.jsx(lucideReact.Eye,{className:"h-3 w-3"})})]}),_.description&&jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:_.description}),_.hint&&jsxRuntime.jsx("p",{className:"text-[11px] text-muted-foreground",children:_.hint}),Z,E[_.key]&&jsxRuntime.jsx("p",{className:"text-xs text-red-500",children:E[_.key]})]},_.key);return d?d(_,ue):ue})})):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"mb-6",children:[jsxRuntime.jsx("h2",{className:"text-xl font-semibold",children:oe.label}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:oe.description})]}),jsxRuntime.jsx("div",{className:"space-y-6",children:(oe.settings||[]).map(_=>{let Z=$(_);if(!Z)return null;let ue=jsxRuntime.jsxs("div",{className:N("space-y-2",k),children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsxs(gt,{htmlFor:_.key,className:"text-sm font-medium",children:[_.label,_.requiresRestart&&jsxRuntime.jsx("span",{className:"ml-2 text-xs text-amber-600 dark:text-amber-400",children:"(Requires restart)"})]}),_.help&&jsxRuntime.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground transition-colors",title:_.help,children:jsxRuntime.jsx(lucideReact.Info,{className:"h-3 w-3"})})]}),_.type==="password"&&S[_.key]&&jsxRuntime.jsx(j,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-2",onClick:()=>Q(Oe=>({...Oe,[_.key]:!Oe[_.key]})),children:ne[_.key]?jsxRuntime.jsx(lucideReact.EyeOff,{className:"h-3 w-3"}):jsxRuntime.jsx(lucideReact.Eye,{className:"h-3 w-3"})})]}),_.description&&jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:_.description}),Z,E[_.key]&&jsxRuntime.jsx("p",{className:"text-xs text-red-500",children:E[_.key]})]},_.key);return d?d(_,ue):ue})})]})})}):jsxRuntime.jsx(Re,{className:"p-8",children:jsxRuntime.jsxs(ct,{children:[jsxRuntime.jsx(lucideReact.AlertCircle,{className:"h-4 w-4"}),jsxRuntime.jsx(ut,{children:"No settings available for this category"})]})})})]}),v&&jsxRuntime.jsxs(ct,{className:"border-amber-500",children:[jsxRuntime.jsx(lucideReact.AlertCircle,{className:"h-4 w-4 text-amber-600"}),jsxRuntime.jsx(ut,{children:"Some settings require a restart to take effect."})]})]})}function f6({onFetchLogs:e,onClearLogs:t,autoRefreshMs:r=3e3,height:n="100%"}){return jsxRuntime.jsx(on,{mode:"logs",showHeader:false,onFetchLogs:e,onClearLogs:t,enableAutoScroll:true,autoRefreshMs:r,enableSearch:true,enableFilter:true,enableExport:true,enableClear:!!t,height:n})}function b6({onFetchArchives:e,onDownloadArchive:t,onDeleteArchive:r,height:n="100%"}){return jsxRuntime.jsx(on,{mode:"archives",showHeader:false,onFetchArchives:e,onDownloadArchive:t,onDeleteArchive:r,height:n})}function h6({onFetchLogs:e,onFetchArchives:t,onClearLogs:r,onDownloadArchive:n,onDeleteArchive:o,autoRefreshMs:a=3e3,height:i="100%"}){return jsxRuntime.jsx(on,{mode:"full",showHeader:false,onFetchLogs:e,onFetchArchives:t,onClearLogs:r,onDownloadArchive:n,onDeleteArchive:o,enableAutoScroll:true,autoRefreshMs:a,enableSearch:true,enableFilter:true,enableExport:true,enableClear:!!r,showArchives:!!t,height:i})}var Ms={colors:{primary:{DEFAULT:"#3b82f6",hover:"#2563eb",light:"#60a5fa",dark:"#1d4ed8"},dark:{bg:{primary:"#0a0a0a",secondary:"#141414",tertiary:"#1a1a1a",elevated:"#242424"},border:{DEFAULT:"#2a2a2a",subtle:"#1f1f1f",strong:"#3a3a3a"}},light:{bg:{primary:"#ffffff",secondary:"#f8f9fa",tertiary:"#f3f4f6",elevated:"#ffffff"},border:{DEFAULT:"#e5e7eb",subtle:"#f3f4f6",strong:"#d1d5db"}},success:{DEFAULT:"#10b981",light:"#34d399",dark:"#059669"},warning:{DEFAULT:"#f59e0b",light:"#fbbf24",dark:"#d97706"},error:{DEFAULT:"#ef4444",light:"#f87171",dark:"#dc2626"},info:{DEFAULT:"#3b82f6",light:"#60a5fa",dark:"#2563eb"},intelligent:{DEFAULT:"#8b5cf6",light:"#a78bfa",dark:"#7c3aed"},activity:{read:"#10b981",write:"#3b82f6",inactive:"#6b7280"}},gradients:{subtle:"linear-gradient(180deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0) 100%)",card:"linear-gradient(135deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.05) 100%)",glow:"radial-gradient(circle at 50% 0%, rgba(226,19,80,0.15) 0%, transparent 70%)",intelligent:"linear-gradient(135deg, rgba(139,92,246,0.1) 0%, rgba(139,92,246,0.05) 100%)"},shadows:{sm:"0 1px 2px 0 rgba(0, 0, 0, 0.05)",DEFAULT:"0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)",md:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",lg:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",xl:"0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)",glow:"0 0 20px rgba(226,19,80,0.3)","glow-intelligent":"0 0 20px rgba(139,92,246,0.3)"},radius:{sm:"0.25rem",DEFAULT:"0.375rem",md:"0.5rem",lg:"0.75rem",xl:"1rem","2xl":"1.5rem",full:"9999px"},spacing:{xs:"0.5rem",sm:"0.75rem",DEFAULT:"1rem",md:"1.5rem",lg:"2rem",xl:"3rem","2xl":"4rem"},typography:{fonts:{sans:'Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',mono:'"JetBrains Mono", "SF Mono", Monaco, Consolas, "Liberation Mono", "Courier New", monospace'},sizes:{xs:"0.75rem",sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","3xl":"1.875rem","4xl":"2.25rem"},weights:{light:"300",normal:"400",medium:"500",semibold:"600",bold:"700"}},transitions:{fast:"150ms",DEFAULT:"200ms",slow:"300ms",timing:"cubic-bezier(0.4, 0, 0.2, 1)"},zIndex:{base:0,elevated:10,dropdown:20,sticky:30,fixed:40,modal:50,popover:60,tooltip:70},opacity:{hover:.8,disabled:.5,backdrop:.7,subtle:.1}},Que=(e=false)=>{let t=e?Ms.colors.dark:Ms.colors.light;return {"--color-bg-primary":t.bg.primary,"--color-bg-secondary":t.bg.secondary,"--color-bg-tertiary":t.bg.tertiary,"--color-bg-elevated":t.bg.elevated,"--color-border":t.border.DEFAULT,"--color-border-subtle":t.border.subtle,"--color-border-strong":t.border.strong,"--color-text":e?"#ffffff":"#000000","--color-text-secondary":e?"#a1a1aa":"#6b7280","--color-text-tertiary":e?"#71717a":"#9ca3af"}};var zO=Ne.createContext(void 0);function k6({children:e,defaultMode:t="system",theme:r=Ms,customColors:n,persistPreference:o=true}){let[a,i]=Ne.useState({mode:t,theme:r,customColors:n}),[s,l]=Ne.useState(false);Ne.useEffect(()=>{if(o){let g=localStorage.getItem("theme-mode");g&&i(p=>({...p,mode:g}));}},[o]),Ne.useEffect(()=>{let g=document.documentElement;if(a.mode==="system"){let p=window.matchMedia("(prefers-color-scheme: dark)"),f=p.matches;l(f),g.classList.toggle("dark",f);let m=b=>{let h=b.matches;l(h),g.classList.toggle("dark",h);};return p.addEventListener("change",m),()=>{p.removeEventListener("change",m);}}else {let p=a.mode==="dark";l(p),g.classList.toggle("dark",p);return}},[a.mode]),Ne.useEffect(()=>{if(n){let g=document.documentElement;if(n.primary){let p=kb(n.primary);g.style.setProperty("--primary",p);}if(n.secondary){let p=kb(n.secondary);g.style.setProperty("--secondary",p);}if(n.accent){let p=kb(n.accent);g.style.setProperty("--accent",p);}}},[n]);let c=g=>{i(p=>({...p,mode:g})),o&&localStorage.setItem("theme-mode",g);},d={themeConfig:a,setThemeMode:c,toggleTheme:()=>{c(s?"light":"dark");},isDark:s};return jsxRuntime.jsx(zO.Provider,{value:d,children:e})}function Ps(){let e=Ne.useContext(zO);if(!e)throw new Error("useTheme must be used within a ThemeProvider");return e}function kb(e){e=e.replace("#","");let t=parseInt(e.substr(0,2),16)/255,r=parseInt(e.substr(2,2),16)/255,n=parseInt(e.substr(4,2),16)/255,o=Math.max(t,r,n),a=Math.min(t,r,n),i=0,s=0,l=(o+a)/2;if(o!==a){let c=o-a;switch(s=l>.5?c/(2-o-a):c/(o+a),o){case t:i=((r-n)/c+(r<n?6:0))/6;break;case r:i=((n-t)/c+2)/6;break;case n:i=((t-r)/c+4)/6;break}}return `${Math.round(i*360)} ${Math.round(s*100)}% ${Math.round(l*100)}%`}function w6({className:e,showLabel:t=true,variant:r="select"}){let{themeConfig:n,setThemeMode:o,toggleTheme:a,isDark:i}=Ps();return r==="button"?jsxRuntime.jsxs("div",{className:N("flex items-center gap-2",e),children:[t&&jsxRuntime.jsx(gt,{children:"Theme"}),jsxRuntime.jsx(j,{variant:"outline",size:"icon",onClick:a,className:"w-10 h-10",children:i?jsxRuntime.jsx(lucideReact.Sun,{className:"h-4 w-4"}):jsxRuntime.jsx(lucideReact.Moon,{className:"h-4 w-4"})})]}):jsxRuntime.jsxs("div",{className:N("flex flex-col gap-2",e),children:[t&&jsxRuntime.jsx(gt,{htmlFor:"theme-select",children:"Theme"}),jsxRuntime.jsxs(Tt,{value:n.mode,onValueChange:s=>o(s),children:[jsxRuntime.jsx(ft,{id:"theme-select",className:"w-[180px]",children:jsxRuntime.jsx(At,{placeholder:"Select theme"})}),jsxRuntime.jsxs(bt,{children:[jsxRuntime.jsx(Be,{value:"light",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(lucideReact.Sun,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:"Light"})]})}),jsxRuntime.jsx(Be,{value:"dark",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(lucideReact.Moon,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:"Dark"})]})}),jsxRuntime.jsx(Be,{value:"system",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(lucideReact.Monitor,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:"System"})]})})]})]})]})}function E6({className:e}){let{toggleTheme:t,isDark:r}=Ps();return jsxRuntime.jsx(j,{variant:"ghost",size:"icon",onClick:t,className:N("w-8 h-8",e),title:`Switch to ${r?"light":"dark"} theme`,children:r?jsxRuntime.jsx(lucideReact.Sun,{className:"h-4 w-4"}):jsxRuntime.jsx(lucideReact.Moon,{className:"h-4 w-4"})})}var I6=[{id:"general",label:"General",description:"Basic application settings",icon:jsxRuntime.jsx(lucideReact.Settings,{className:"h-4 w-4"}),settings:[]},{id:"network",label:"Network",description:"Network and connectivity",icon:jsxRuntime.jsx(lucideReact.Network,{className:"h-4 w-4"}),settings:[]},{id:"logging",label:"Logging",description:"Logging configuration",icon:jsxRuntime.jsx(lucideReact.FileText,{className:"h-4 w-4"}),settings:[]},{id:"security",label:"Security",description:"Security settings",icon:jsxRuntime.jsx(lucideReact.Shield,{className:"h-4 w-4"}),settings:[]},{id:"notifications",label:"Notifications",description:"Email and alerts",icon:jsxRuntime.jsx(lucideReact.Mail,{className:"h-4 w-4"}),settings:[]},{id:"appearance",label:"Appearance",description:"UI preferences",icon:jsxRuntime.jsx(lucideReact.Palette,{className:"h-4 w-4"}),settings:[]},{id:"advanced",label:"Advanced",description:"Advanced settings",icon:jsxRuntime.jsx(lucideReact.Activity,{className:"h-4 w-4"}),settings:[]}];function _6(e,t,r,n){return {id:e,label:t,description:n,icon:O6[r]||jsxRuntime.jsx(lucideReact.Settings,{className:"h-4 w-4"})}}var O6={Server:jsxRuntime.jsx(lucideReact.Server,{className:"h-4 w-4"}),Network:jsxRuntime.jsx(lucideReact.Network,{className:"h-4 w-4"}),FileText:jsxRuntime.jsx(lucideReact.FileText,{className:"h-4 w-4"}),Shield:jsxRuntime.jsx(lucideReact.Shield,{className:"h-4 w-4"}),Mail:jsxRuntime.jsx(lucideReact.Mail,{className:"h-4 w-4"}),Settings:jsxRuntime.jsx(lucideReact.Settings,{className:"h-4 w-4"}),Database:jsxRuntime.jsx(lucideReact.Database,{className:"h-4 w-4"}),Bell:jsxRuntime.jsx(lucideReact.Bell,{className:"h-4 w-4"}),Users:jsxRuntime.jsx(lucideReact.Users,{className:"h-4 w-4"}),Palette:jsxRuntime.jsx(lucideReact.Palette,{className:"h-4 w-4"}),Globe:jsxRuntime.jsx(lucideReact.Globe,{className:"h-4 w-4"}),Activity:jsxRuntime.jsx(lucideReact.Activity,{className:"h-4 w-4"})};function P6({apiUrl:e="/api/updates",checkInterval:t=36e5,onDownload:r}){let[n,o]=Ne.useState(null),[a,i]=Ne.useState(false),[s,l]=Ne.useState(false),[c,u]=Ne.useState(false);Ne.useEffect(()=>{d();let f=setInterval(d,t);return ()=>clearInterval(f)},[t]);let d=async(f=false)=>{i(true);try{let m=await fetch(`${e}/check${f?"?force=true":""}`);if(m.ok){let b=await m.json();o(b),b.updateAvailable&&s&&localStorage.getItem("dismissedUpdateVersion")!==b.latestRelease?.version&&l(!1);}}catch(m){console.error("Failed to check for updates:",m);}finally{i(false);}},g=()=>{l(true),n?.latestRelease&&localStorage.setItem("dismissedUpdateVersion",n.latestRelease.version);},p=async()=>{if(r&&n)r(n);else try{let f=await fetch(`${e}/download-url`);if(f.ok){let{url:m}=await f.json();window.open(m,"_blank");}}catch{n?.latestRelease?.url&&window.open(n.latestRelease.url,"_blank");}};return !n?.updateAvailable||s?null:jsxRuntime.jsx("div",{className:"fixed bottom-4 right-4 z-50 max-w-md animate-in slide-in-from-bottom-2",children:jsxRuntime.jsxs(ct,{className:"border-green-500 bg-green-50 dark:bg-green-950/20",children:[jsxRuntime.jsx(lucideReact.Download,{className:"h-4 w-4 text-green-600 dark:text-green-400"}),jsxRuntime.jsxs(ut,{className:"pr-8",children:[jsxRuntime.jsxs("div",{className:"font-semibold text-green-800 dark:text-green-200 mb-1",children:["Update Available: v",n.latestRelease?.version]}),jsxRuntime.jsx("div",{className:"text-sm text-green-700 dark:text-green-300 mb-3",children:n.latestRelease?.name||"A new version is available"}),c&&n.latestRelease?.body&&jsxRuntime.jsx("div",{className:"mt-3 p-2 bg-white/50 dark:bg-black/20 rounded text-xs",children:jsxRuntime.jsx("pre",{className:"whitespace-pre-wrap font-sans",children:n.latestRelease.body})}),jsxRuntime.jsxs("div",{className:"flex gap-2 mt-3",children:[jsxRuntime.jsxs(j,{size:"sm",variant:"default",onClick:p,className:"bg-green-600 hover:bg-green-700",children:[jsxRuntime.jsx(lucideReact.Download,{className:"h-3 w-3 mr-1"}),"Download"]}),jsxRuntime.jsxs(j,{size:"sm",variant:"outline",onClick:()=>u(!c),children:[c?"Hide":"Show"," Changes"]}),jsxRuntime.jsx(j,{size:"sm",variant:"ghost",onClick:()=>window.open(n.latestRelease?.url,"_blank"),children:jsxRuntime.jsx(lucideReact.ExternalLink,{className:"h-3 w-3"})})]})]}),jsxRuntime.jsx(j,{size:"sm",variant:"ghost",className:"absolute top-2 right-2 h-6 w-6 p-0",onClick:g,children:jsxRuntime.jsx(lucideReact.X,{className:"h-4 w-4"})})]})})}function z6(e,t){let[r,n]=Ne.useState(e);return Ne.useEffect(()=>{let o=setTimeout(()=>{n(e);},t);return ()=>{clearTimeout(o);}},[e,t]),r}function U6(e){let[t,r]=So(e);return {connected:t.connected,connecting:t.connecting,transport:t.transport,error:t.error,retryCount:t.retryCount,reconnect:r.reconnect}}var Eb=class{constructor(t={}){this.config={loginEndpoint:t.loginEndpoint||"/api/login",logoutEndpoint:t.logoutEndpoint||"/api/logout",refreshEndpoint:t.refreshEndpoint||"/api/refresh",tokenKey:t.tokenKey||"auth_token",authKey:t.authKey||"authenticated",tokenExpiry:t.tokenExpiry||36e5};}async login(t,r){try{let n=await fetch(this.config.loginEndpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:t,password:r})}),o=await n.json();return n.ok&&o.success?(localStorage.setItem(this.config.authKey,"true"),o.token&&(localStorage.setItem(this.config.tokenKey,o.token),this.scheduleTokenRefresh(o.expiresIn||this.config.tokenExpiry)),o.user&&localStorage.setItem("user",JSON.stringify(o.user)),{success:!0,token:o.token,user:o.user,expiresIn:o.expiresIn}):{success:!1,error:o.error||"Invalid credentials"}}catch(n){return console.error("Login error:",n),{success:false,error:"Login failed. Please try again."}}}async logout(){try{let t=this.getToken();t&&await fetch(this.config.logoutEndpoint,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`}});}catch(t){console.error("Logout error:",t);}finally{localStorage.removeItem(this.config.authKey),localStorage.removeItem(this.config.tokenKey),localStorage.removeItem("user"),this.refreshTimer&&clearTimeout(this.refreshTimer);}}isAuthenticated(){return localStorage.getItem(this.config.authKey)==="true"}getToken(){return localStorage.getItem(this.config.tokenKey)}getUser(){let t=localStorage.getItem("user");if(t)try{return JSON.parse(t)}catch{return null}return null}async refreshToken(){try{let t=this.getToken();if(!t)return !1;let r=await fetch(this.config.refreshEndpoint,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`}});if(r.ok){let n=await r.json();if(n.token)return localStorage.setItem(this.config.tokenKey,n.token),this.scheduleTokenRefresh(n.expiresIn||this.config.tokenExpiry),!0}return !1}catch(t){return console.error("Token refresh error:",t),false}}scheduleTokenRefresh(t){this.refreshTimer&&clearTimeout(this.refreshTimer);let r=Math.max(0,t-3e5);this.refreshTimer=setTimeout(()=>{this.refreshToken();},r);}async authenticatedFetch(t,r={}){let n=this.getToken(),o=new Headers(r.headers);n&&o.set("Authorization",`Bearer ${n}`);let a=await fetch(t,{...r,headers:o});if(a.status===401&&await this.refreshToken()){let s=this.getToken();return s&&o.set("Authorization",`Bearer ${s}`),fetch(t,{...r,headers:o})}return a}requireAuth(t="/login"){return this.isAuthenticated()?true:(window.location.href=t,false)}},H6=new Eb;var Rde={base:"transition-all duration-200",interactive:"hover:shadow-md hover:border-gray-300 dark:hover:border-gray-700 cursor-pointer",elevation:"shadow-sm"},Ide={primary:"gap-2",icon:"h-4 w-4"},_de={container:"flex flex-col items-center justify-center py-12 text-center",icon:"h-12 w-12 text-muted-foreground mb-4",title:"text-lg font-medium mb-2",description:"text-sm text-muted-foreground max-w-sm"},Ode={led:"w-2 h-2 rounded-full transition-all duration-200",pulse:"animate-pulse",colors:{read:"bg-green-500",write:"bg-blue-500",inactive:"bg-gray-400",error:"bg-red-500"}},Lde={badge:{success:"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",warning:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200",error:"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200",info:"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",default:"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-200"}};var $6=25,q6=[10,25,50,100];function Zo({data:e,pageSize:t=$6,storageKey:r}){let[n,o]=Ne.useState(()=>{if(r)try{let h=localStorage.getItem(`pagination-${r}`);if(h)return {page:1,pageSize:JSON.parse(h).pageSize||t}}catch{}return {page:1,pageSize:t}}),{page:a,pageSize:i}=n,s=Ne.useMemo(()=>Math.max(1,Math.ceil(e.length/i)),[e.length,i]);Ne.useEffect(()=>{a>s&&o(h=>({...h,page:Math.max(1,s)}));},[s,a]),Ne.useEffect(()=>{if(r)try{localStorage.setItem(`pagination-${r}`,JSON.stringify({pageSize:i}));}catch{}},[i,r]);let l=(a-1)*i,c=Math.min(l+i,e.length),u=Ne.useMemo(()=>e.slice(l,c),[e,l,c]),d=Ne.useCallback(h=>{o(w=>({...w,page:Math.max(1,Math.min(h,s))}));},[s]),g=Ne.useCallback(h=>{o({page:1,pageSize:h});},[]),p=Ne.useCallback(()=>{d(a+1);},[a,d]),f=Ne.useCallback(()=>{d(a-1);},[a,d]),m=Ne.useCallback(()=>{d(1);},[d]),b=Ne.useCallback(()=>{d(s);},[s,d]);return {paginatedData:u,page:a,pageSize:i,totalPages:s,totalItems:e.length,setPage:d,setPageSize:g,nextPage:p,prevPage:f,firstPage:m,lastPage:b,startIndex:l+1,endIndex:c,canGoNext:a<s,canGoPrev:a>1,pageSizeOptions:q6}}function Qo({columns:e,storageKey:t}){let r=`column-visibility-${t}`,[n,o]=Ne.useState(()=>{let c={};if(e.forEach(u=>{c[u.id]=u.defaultVisible!==false;}),typeof window>"u")return c;try{let u=localStorage.getItem(r);if(u){let d=JSON.parse(u),g={};return e.forEach(p=>{p.locked?g[p.id]=!0:d[p.id]!==void 0?g[p.id]=d[p.id]:g[p.id]=p.defaultVisible!==!1;}),g}}catch(u){console.error("Error loading column visibility state:",u);}return c});Ne.useEffect(()=>{if(!(typeof window>"u"))try{localStorage.setItem(r,JSON.stringify(n));}catch(c){console.error("Error saving column visibility state:",c);}},[n,r]);let a=Ne.useCallback(c=>e.find(d=>d.id===c)?.locked?true:n[c]!==false,[n,e]),i=Ne.useCallback(c=>{e.find(d=>d.id===c)?.locked||o(d=>({...d,[c]:!d[c]}));},[e]),s=Ne.useCallback(()=>{let c={};e.forEach(u=>{c[u.id]=true;}),o(c);},[e]),l=Ne.useCallback(()=>{let c={};e.forEach(u=>{c[u.id]=u.locked===true;}),o(c);},[e]);return {visibleColumns:n,isColumnVisible:a,toggleColumn:i,showAllColumns:s,hideAllColumns:l,columns:e}}var KO=50,Us=150,Y6=3;function Jo({tableId:e,columns:t,storageKey:r}){let n=r||`table-columns-${e}`,o=Ne.useCallback(()=>t.reduce((C,S)=>(C[S.key]=S.defaultWidth||Us,C),{}),[t]),[a,i]=Ne.useState(()=>{try{let C=localStorage.getItem(n);if(C){let S=JSON.parse(C);return {widths:{...o(),...S},isResizing:!1,resizingColumn:null}}}catch{}return {widths:o(),isResizing:false,resizingColumn:null}}),s=Ne.useRef(0),l=Ne.useRef(0),c=Ne.useRef(null),u=Ne.useRef(false),d=Ne.useRef(t);Ne.useEffect(()=>{d.current=t;},[t]);let g=Ne.useCallback(C=>d.current.find(S=>S.key===C),[]);Ne.useEffect(()=>{try{localStorage.setItem(n,JSON.stringify(a.widths));}catch{}},[a.widths,n]);let p=Ne.useRef(null);p.current||(p.current={onPointerMove:C=>{if(!c.current)return;let S=C.clientX-s.current;if(!u.current){if(Math.abs(S)<Y6)return;u.current=true,i(z=>({...z,isResizing:true,resizingColumn:c.current})),document.body.style.cursor="col-resize",document.body.style.userSelect="none";}let O=g(c.current),D=O?.minWidth||KO,A=O?.maxWidth,E=Math.max(D,l.current+S);A&&(E=Math.min(A,E)),i(z=>({...z,widths:{...z.widths,[c.current]:E}}));},onPointerUp:()=>{c.current=null,u.current=false,i(C=>({...C,isResizing:false,resizingColumn:null})),document.removeEventListener("pointermove",p.current.onPointerMove),document.removeEventListener("pointerup",p.current.onPointerUp),document.removeEventListener("pointercancel",p.current.onPointerUp),document.body.style.cursor="",document.body.style.userSelect="";}}),Ne.useEffect(()=>()=>{p.current&&(document.removeEventListener("pointermove",p.current.onPointerMove),document.removeEventListener("pointerup",p.current.onPointerUp),document.removeEventListener("pointercancel",p.current.onPointerUp)),document.body.style.cursor="",document.body.style.userSelect="";},[]);let f=Ne.useRef(a.widths);Ne.useEffect(()=>{f.current=a.widths;},[a.widths]);let m=Ne.useCallback((C,S)=>{s.current=S,l.current=f.current[C]||Us,c.current=C,u.current=false,document.addEventListener("pointermove",p.current.onPointerMove),document.addEventListener("pointerup",p.current.onPointerUp),document.addEventListener("pointercancel",p.current.onPointerUp);},[]),b=Ne.useCallback(C=>({onPointerDown:S=>{S.preventDefault(),S.stopPropagation(),m(C,S.clientX);},onMouseDown:S=>{S.preventDefault(),S.stopPropagation();},draggable:false,onDragStart:S=>{S.preventDefault(),S.stopPropagation();},className:"resize-handle","data-resizing":a.resizingColumn===C}),[m,a.resizingColumn]),h=Ne.useCallback(C=>{let S=a.widths[C]||Us,D=g(C)?.minWidth||KO;return {width:S,minWidth:D,position:"relative"}},[a.widths,g]),w=t.reduce((C,S)=>C+(a.widths[S.key]||S.defaultWidth||Us),0),k=Ne.useCallback(()=>({minWidth:w}),[w]),R=Ne.useCallback(()=>{i(C=>({...C,widths:o()}));},[o]);return {widths:a.widths,isResizing:a.isResizing,totalWidth:w,getResizeHandleProps:b,getColumnStyle:h,getTableStyle:k,resetToDefaults:R}}function ea({storageKey:e,defaultOrder:t}){let[r,n]=Ne.useState(()=>{try{let l=localStorage.getItem(e);if(l){let c=JSON.parse(l),u=new Set(c),d=new Set(t),g=c.filter(f=>d.has(f)),p=t.filter(f=>!u.has(f));if(p.length>0){let f=[...g];for(let m of p){let b=t.indexOf(m),h=f.length;for(let w=0;w<f.length;w++)if(t.indexOf(f[w])>b){h=w;break}f.splice(h,0,m);}return f}return g.length>0?g:t}}catch(l){console.warn("Failed to load column order from localStorage:",l);}return t});Ne.useEffect(()=>{try{localStorage.setItem(e,JSON.stringify(r));}catch(l){console.warn("Failed to save column order to localStorage:",l);}},[e,r]);let o=Ne.useCallback((l,c)=>{l!==c&&n(u=>{let d=[...u],[g]=d.splice(l,1);return g!==void 0&&d.splice(c,0,g),d});},[]),a=Ne.useCallback((l,c)=>{n(u=>{let d=u.indexOf(l);if(d===-1)return u;let g=c==="left"?Math.max(0,d-1):Math.min(u.length-1,d+1);if(d===g)return u;let p=[...u],[f]=p.splice(d,1);return f!==void 0&&p.splice(g,0,f),p});},[]),i=Ne.useCallback(()=>{n(t);},[t]),s=Ne.useCallback(l=>{let c=new Map(l.map(u=>[u.id,u]));return r.map(u=>c.get(u)).filter(u=>u!==void 0)},[r]);return {columnOrder:r,moveColumn:o,moveColumnById:a,resetOrder:i,getOrderedColumns:s}}function ta(e,t,r=[]){let[n,o]=Ne.useState({isDragging:false,draggedId:null,dropIndex:null}),a=Ne.useCallback(d=>{r.includes(d)||o({isDragging:true,draggedId:d,dropIndex:null});},[r]),i=Ne.useCallback((d,g)=>{if(r.includes(d))return;let p=e.indexOf(d);if(p===-1)return;let f=g.currentTarget.getBoundingClientRect(),m=f.left+f.width/2,b=g.clientX<m?p:p+1;o(h=>({...h,dropIndex:b}));},[r,e]),s=Ne.useCallback(()=>{if(!n.draggedId||n.dropIndex===null){o({isDragging:false,draggedId:null,dropIndex:null});return}let d=e.indexOf(n.draggedId),g=n.dropIndex;d<g&&(g=g-1),d!==-1&&g!==-1&&d!==g&&t(d,g),o({isDragging:false,draggedId:null,dropIndex:null});},[n.draggedId,n.dropIndex,e,t]),l=Ne.useCallback(()=>{o({isDragging:false,draggedId:null,dropIndex:null});},[]),c=Ne.useCallback(d=>({draggable:!r.includes(d),onDragStart:g=>{if(r.includes(d)){g.preventDefault();return}g.dataTransfer.effectAllowed="move",a(d);},onDragOver:g=>{g.preventDefault(),g.dataTransfer.dropEffect="move",i(d,g);},onDrop:g=>{g.preventDefault(),s();},onDragEnd:l}),[r,a,i,s,l]),u=Ne.useCallback(d=>!n.isDragging||n.dropIndex===null?false:e.indexOf(d)===n.dropIndex,[n.isDragging,n.dropIndex,e]);return {dragState:n,getDragHandleProps:c,showDropIndicator:u}}function ra({page:e,pageSize:t,totalPages:r,totalItems:n,startIndex:o,endIndex:a,canGoNext:i,canGoPrev:s,pageSizeOptions:l,onPageChange:c,onPageSizeChange:u,onNextPage:d,onPrevPage:g,onFirstPage:p,onLastPage:f,className:m}){let b=()=>{let h=[],k=Math.floor(2.5),R=Math.max(1,e-k),C=Math.min(r,e+k);e<=k&&(C=Math.min(r,5)),e>r-k&&(R=Math.max(1,r-5+1)),R>1&&(h.push(1),R>2&&h.push("ellipsis"));for(let S=R;S<=C;S++)S!==1&&S!==r&&h.push(S);return C<r&&(C<r-1&&h.push("ellipsis"),h.push(r)),h};return n===0?null:jsxRuntime.jsxs("div",{className:N("flex flex-col sm:flex-row items-center justify-between gap-4 px-2 py-3",m),children:[jsxRuntime.jsxs("div",{className:"text-sm text-muted-foreground",children:["Showing ",o," to ",a," of ",n," items"]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-sm text-muted-foreground",children:"Per page:"}),jsxRuntime.jsxs(Tt,{value:String(t),onValueChange:h=>u(Number(h)),children:[jsxRuntime.jsx(ft,{className:"w-20 h-8",children:jsxRuntime.jsx(At,{})}),jsxRuntime.jsx(bt,{children:l.map(h=>jsxRuntime.jsx(Be,{value:String(h),children:h},h))})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx(j,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:p,disabled:!s,title:"First page",children:jsxRuntime.jsx(lucideReact.ChevronsLeft,{className:"h-4 w-4"})}),jsxRuntime.jsx(j,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:g,disabled:!s,title:"Previous page",children:jsxRuntime.jsx(lucideReact.ChevronLeft,{className:"h-4 w-4"})}),jsxRuntime.jsx("div",{className:"flex items-center gap-1",children:b().map((h,w)=>h==="ellipsis"?jsxRuntime.jsx("span",{className:"px-2 text-muted-foreground",children:"..."},`ellipsis-${w}`):jsxRuntime.jsx(j,{variant:e===h?"default":"outline",size:"icon",className:"h-8 w-8",onClick:()=>c(h),children:h},h))}),jsxRuntime.jsx(j,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:d,disabled:!i,title:"Next page",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"h-4 w-4"})}),jsxRuntime.jsx(j,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:f,disabled:!i,title:"Last page",children:jsxRuntime.jsx(lucideReact.ChevronsRight,{className:"h-4 w-4"})})]})]})]})}function Tb({data:e,columns:t,storageKey:r,getRowId:n,selectable:o=false,selectedIds:a,onSelectionChange:i,onRowClick:s,onRowContextMenu:l,sortField:c,sortOrder:u,onSort:d,actionsColumn:g,actionsColumnWidth:p=80,pageSize:f=25,pagination:m,hidePagination:b=false,className:h,rowClassName:w,enableHeaderContextMenu:k=true,lockedColumns:R=[],defaultColumnOrder:C,loading:S=false,emptyState:O}){let D=Ne.useMemo(()=>{let $=[];return o&&$.push({key:"select",defaultWidth:40,minWidth:40}),t.forEach(oe=>{$.push({key:oe.id,defaultWidth:oe.width?.default??150,minWidth:oe.width?.min??80,maxWidth:oe.width?.max});}),g&&$.push({key:"actions",defaultWidth:p,minWidth:60}),$},[t,o,g,p]),A=Ne.useMemo(()=>t.map($=>({id:$.id,label:typeof $.header=="string"?$.header:$.id,defaultVisible:$.visibility?.default??true,locked:$.visibility?.locked})),[t]),E=Ne.useMemo(()=>{if(C)return C;let $=[];return o&&$.push("select"),t.forEach(oe=>$.push(oe.id)),g&&$.push("actions"),$},[C,t,o,g]),{getResizeHandleProps:z,getColumnStyle:I,getTableStyle:P}=Jo({tableId:r,columns:D}),L=Qo({columns:A,storageKey:r}),{columnOrder:B,moveColumn:q}=ea({storageKey:`${r}-order`,defaultOrder:E}),{dragState:Y,getDragHandleProps:ne,showDropIndicator:Q}=ta(B,q,[...R,"select","actions"]),v=Zo({data:e,pageSize:f,storageKey:r}),U=m||v,[ee,T]=Ne.useState(null),ve=Ne.useCallback($=>{k&&($.preventDefault(),T({x:$.clientX,y:$.clientY}));},[k]);Ne.useEffect(()=>{if(!ee)return;let $=()=>T(null);return window.addEventListener("click",$),()=>{window.removeEventListener("click",$);}},[ee]);let Te=Ne.useMemo(()=>!o||!a||U.paginatedData.length===0?false:U.paginatedData.every($=>a.has(n($))),[o,a,U.paginatedData,n]),$e=Ne.useMemo(()=>{if(!o||!a)return false;let $=U.paginatedData.filter(oe=>a.has(n(oe)));return $.length>0&&$.length<U.paginatedData.length},[o,a,U.paginatedData,n]),_e=Ne.useCallback($=>{if(!i||!a)return;let oe=new Set(a);oe.has($)?oe.delete($):oe.add($),i(oe);},[a,i]),Se=Ne.useCallback(()=>{if(!i)return;let $=new Set(U.paginatedData.map(n));i($);},[U.paginatedData,n,i]),et=Ne.useCallback(()=>{i&&i(new Set);},[i]),Ue=Ne.useCallback($=>c!==$?jsxRuntime.jsx(lucideReact.ArrowUpDown,{className:"h-3.5 w-3.5 text-muted-foreground"}):u==="asc"?jsxRuntime.jsx(lucideReact.ChevronUp,{className:"h-3.5 w-3.5"}):jsxRuntime.jsx(lucideReact.ChevronDown,{className:"h-3.5 w-3.5"}),[c,u]),lt=Ne.useCallback($=>t.find(oe=>oe.id===$),[t]),ot=Ne.useCallback($=>{let oe={columnId:$.id,isSorted:c===$.sortKey,sortDirection:c===$.sortKey?u:void 0};return typeof $.header=="function"?$.header(oe):$.sortKey&&d?jsxRuntime.jsxs("button",{onClick:()=>d($.sortKey),className:N("flex items-center gap-1 hover:text-foreground transition-colors",c===$.sortKey&&"text-foreground font-medium"),children:[$.header,Ue($.sortKey)]}):$.header},[c,u,d,Ue]);return jsxRuntime.jsx(pa,{children:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"overflow-auto border rounded-lg h-full",children:jsxRuntime.jsxs(po,{style:P(),className:N("resizable-table sticky-actions-table",h),children:[jsxRuntime.jsx(go,{className:"sticky top-0 z-20 bg-muted",children:jsxRuntime.jsxs(xr,{onContextMenu:ve,className:"border-t-0",children:[B.map($=>{if($==="select"&&o)return jsxRuntime.jsx(rn,{className:"sticky-select-header w-10 sticky left-0 z-20 bg-muted relative after:absolute after:right-0 after:top-0 after:bottom-0 after:w-px after:bg-border",children:jsxRuntime.jsx("input",{type:"checkbox",checked:Te,ref:_=>{_&&(_.indeterminate=$e);},onChange:_=>_.target.checked?Se():et(),className:"h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary cursor-pointer",title:Te?"Deselect all":"Select all visible"})},"select");let oe=lt($);return !oe||!L.isColumnVisible($)?null:jsxRuntime.jsxs(rn,{style:I($),...ne($),className:N("cursor-grab relative",Y.draggedId===$&&"column-dragging opacity-50",Q($)&&"drop-indicator"),children:[ot(oe),jsxRuntime.jsx("div",{...z($)})]},$)}),g&&jsxRuntime.jsx(rn,{className:"sticky right-0 z-20 bg-muted text-center relative before:absolute before:left-0 before:top-0 before:bottom-0 before:w-px before:bg-border",style:{width:p,minWidth:p,maxWidth:p},children:"Actions"},"actions")]})}),jsxRuntime.jsx(mo,{children:S?jsxRuntime.jsx(xr,{children:jsxRuntime.jsx(vr,{colSpan:B.length+(g?1:0),className:"!p-0 h-32",children:jsxRuntime.jsx("div",{className:"sticky left-0 w-screen max-w-full h-full bg-background flex justify-center items-center",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[jsxRuntime.jsx(lucideReact.Loader2,{className:"h-5 w-5 animate-spin"}),"Loading..."]})})})}):U.paginatedData.length===0?null:U.paginatedData.map($=>{let oe=n($),_=a?.has(oe)??false;return jsxRuntime.jsxs(xr,{className:N("group cursor-pointer bg-background hover:bg-muted transition-none",_&&"bg-primary/5",w?.($)),onClick:()=>s?.($),onContextMenu:Z=>{l&&(Z.preventDefault(),l($,{x:Z.clientX,y:Z.clientY}));},children:[B.map(Z=>{if(Z==="select"&&o)return jsxRuntime.jsx(vr,{className:N("sticky-select-cell w-10 sticky left-0 z-10 relative after:absolute after:right-0 after:top-0 after:bottom-0 after:w-px after:bg-border","bg-background group-hover:bg-muted",_&&"bg-primary/5 group-hover:bg-primary/10"),onClick:at=>at.stopPropagation(),children:jsxRuntime.jsx("input",{type:"checkbox",checked:_,onChange:()=>_e(oe),className:"h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary cursor-pointer"})},"select");let ue=lt(Z);if(!ue||!L.isColumnVisible(Z))return null;let Oe={columnId:Z,isDragging:Y.draggedId===Z};return jsxRuntime.jsx(vr,{style:I(Z),className:N(ue.className,Y.draggedId===Z&&"column-dragging"),children:ue.cell($,Oe)},Z)}),g&&jsxRuntime.jsx(vr,{className:N("sticky right-0 z-10 text-center relative before:absolute before:left-0 before:top-0 before:bottom-0 before:w-px before:bg-border","bg-background group-hover:bg-muted",_&&"bg-primary/5 group-hover:bg-primary/10"),style:{width:p,minWidth:p,maxWidth:p},onClick:Z=>Z.stopPropagation(),children:g($)},"actions")]},oe)})})]})}),!S&&U.paginatedData.length===0&&jsxRuntime.jsx("div",{className:"empty-state-container flex-1 flex items-center justify-center bg-background",children:O||jsxRuntime.jsx("span",{className:"block text-center text-muted-foreground py-8",children:"No data"})}),!b&&!S&&U.totalPages>1&&jsxRuntime.jsx(ra,{page:U.page,pageSize:U.pageSize,totalItems:U.totalItems,totalPages:U.totalPages,startIndex:U.startIndex,endIndex:U.endIndex,canGoPrev:U.canGoPrev,canGoNext:U.canGoNext,onPageChange:U.setPage,onPageSizeChange:U.setPageSize,onNextPage:U.nextPage,onPrevPage:U.prevPage,onFirstPage:"firstPage"in U?U.firstPage:()=>U.setPage(1),onLastPage:"lastPage"in U?U.lastPage:()=>U.setPage(U.totalPages),pageSizeOptions:U.pageSizeOptions}),ee&&jsxRuntime.jsxs("div",{className:"fixed z-50 min-w-[200px] overflow-y-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95",style:{top:ee.y,left:ee.x,maxHeight:`calc(100vh - ${ee.y}px - 20px)`},onClick:$=>$.stopPropagation(),children:[jsxRuntime.jsx("div",{className:"px-2 py-1.5 text-xs font-medium text-muted-foreground",children:"Toggle columns"}),jsxRuntime.jsx("div",{className:"h-px bg-border my-1"}),L.columns.map($=>{let oe=L.isColumnVisible($.id),_=$.locked===true;return jsxRuntime.jsxs("button",{onClick:()=>!_&&L.toggleColumn($.id),disabled:_,className:N("flex items-center gap-2 w-full px-2 py-1.5 text-sm rounded-sm hover:bg-accent",_&&"opacity-50 cursor-not-allowed"),children:[jsxRuntime.jsx("div",{className:"w-4 h-4 flex items-center justify-center",children:oe&&jsxRuntime.jsx(lucideReact.Check,{className:"h-3.5 w-3.5 text-primary"})}),jsxRuntime.jsx("span",{className:"flex-1 text-left",children:$.label}),_&&jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"Required"})]},$.id)}),jsxRuntime.jsx("div",{className:"h-px bg-border my-1"}),jsxRuntime.jsxs("button",{onClick:()=>L.showAllColumns(),className:"flex items-center gap-2 w-full px-2 py-1.5 text-sm rounded-sm hover:bg-accent",children:[jsxRuntime.jsx(lucideReact.Eye,{className:"h-4 w-4"}),"Show All"]}),jsxRuntime.jsxs("button",{onClick:()=>L.hideAllColumns(),className:"flex items-center gap-2 w-full px-2 py-1.5 text-sm rounded-sm hover:bg-accent",children:[jsxRuntime.jsx(lucideReact.EyeOff,{className:"h-4 w-4"}),"Hide Optional"]})]})]})})}function oa({page:e,pageSize:t,totalPages:r,totalItems:n,startIndex:o,endIndex:a,canGoNext:i,canGoPrev:s,pageSizeOptions:l,setPage:c,setPageSize:u,nextPage:d,prevPage:g,className:p}){return n===0?null:jsxRuntime.jsxs("div",{className:N("flex items-center gap-3 text-sm",p),children:[jsxRuntime.jsxs("div",{className:"hidden md:flex items-center gap-1.5",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground hidden lg:inline",children:"Rows:"}),jsxRuntime.jsxs(Tt,{value:String(t),onValueChange:f=>u(Number(f)),children:[jsxRuntime.jsx(ft,{className:"w-16 h-8 text-xs",children:jsxRuntime.jsx(At,{})}),jsxRuntime.jsx(bt,{children:l.map(f=>jsxRuntime.jsx(Be,{value:String(f),children:f},f))})]})]}),r>1&&jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx(j,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:g,disabled:!s,title:"Previous page",children:jsxRuntime.jsx(lucideReact.ChevronLeft,{className:"h-4 w-4"})}),jsxRuntime.jsxs("span",{className:"hidden sm:inline px-2 text-muted-foreground tabular-nums min-w-[60px] text-center",children:[e," / ",r]}),jsxRuntime.jsx(j,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:d,disabled:!i,title:"Next page",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"h-4 w-4"})})]}),jsxRuntime.jsxs("span",{className:"text-muted-foreground whitespace-nowrap hidden lg:inline",children:["Showing ",o,"\u2013",a," of ",n]})]})}function Ab({title:e,description:t,search:r,onSearchChange:n,searchPlaceholder:o="Search...",filters:a,activeFilterCount:i=0,onClearFilters:s,pagination:l,actions:c,beforeTable:u,children:d,className:g,loading:p,loadingComponent:f}){let m=l&&l.totalItems>0;return jsxRuntime.jsxs("div",{className:N("flex flex-col h-full",g),children:[jsxRuntime.jsxs("div",{className:"data-table-page-header flex-shrink-0 space-y-4 pb-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h1",{className:"text-3xl font-bold",children:e}),t&&jsxRuntime.jsx("p",{className:"text-muted-foreground",children:t})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[n!==void 0&&jsxRuntime.jsxs("div",{className:"relative w-full sm:w-auto sm:min-w-[200px] sm:max-w-xs",children:[jsxRuntime.jsx(lucideReact.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none z-10"}),jsxRuntime.jsx(Et,{placeholder:o,value:r||"",onChange:b=>n(b.target.value),className:"pl-9 h-9"}),r&&jsxRuntime.jsx("button",{type:"button",onClick:()=>n(""),className:"absolute right-2 top-1/2 transform -translate-y-1/2 p-1 rounded-sm hover:bg-muted",children:jsxRuntime.jsx(lucideReact.X,{className:"h-3 w-3 text-muted-foreground"})})]}),a&&a.length>0&&jsxRuntime.jsxs(Lr,{children:[jsxRuntime.jsx(Dr,{asChild:true,children:jsxRuntime.jsxs(j,{variant:"outline",size:"sm",className:"gap-2 h-9",children:[jsxRuntime.jsx(lucideReact.Filter,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{className:"hidden sm:inline",children:"Filters"}),i>0&&jsxRuntime.jsx("span",{className:"rounded-full bg-primary text-primary-foreground px-2 py-0.5 text-xs font-medium",children:i})]})}),jsxRuntime.jsx(hr,{className:"w-80 overflow-y-auto",align:"start",collisionPadding:16,style:{maxHeight:"var(--radix-popover-content-available-height)"},children:jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("h4",{className:"font-medium text-sm",children:"Filters"}),i>0&&s&&jsxRuntime.jsx(j,{variant:"ghost",size:"sm",onClick:s,className:"h-auto p-0 text-xs text-destructive hover:text-destructive",children:"Clear all"})]}),jsxRuntime.jsx("div",{className:"space-y-3",children:a.map(b=>jsxRuntime.jsxs("div",{className:"space-y-1.5",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:b.label}),b.render()]},b.id))})]})})]}),i>0&&s&&jsxRuntime.jsxs(j,{variant:"ghost",size:"sm",onClick:s,className:"h-9 gap-1.5 text-muted-foreground hover:text-foreground",title:"Clear filters",children:[jsxRuntime.jsx(lucideReact.X,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{className:"hidden sm:inline",children:"Clear"})]}),m&&jsxRuntime.jsx(oa,{...l}),jsxRuntime.jsx("div",{className:"flex-1"}),c&&jsxRuntime.jsx("div",{className:"flex items-center gap-2 flex-shrink-0",children:c})]})]}),u&&jsxRuntime.jsx("div",{className:"px-6 pb-2",children:u}),jsxRuntime.jsx("div",{className:"relative flex-1 min-h-0",children:jsxRuntime.jsx("div",{className:"data-table-scroll-container h-full",children:p?f||jsxRuntime.jsx("div",{className:"flex items-center justify-center h-full",children:jsxRuntime.jsx("div",{className:"text-muted-foreground",children:"Loading..."})}):d})})]})}function Nb({selectedCount:e,onClear:t,children:r,itemLabel:n,className:o}){if(e===0)return null;let a=n??(e===1?"item":"items");return jsxRuntime.jsx(Re,{className:N("p-3 bg-primary/5 border-primary/20",o),children:jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsxs("span",{className:"font-medium text-sm",role:"status","aria-live":"polite",children:[e," ",a," selected"]}),jsxRuntime.jsxs(j,{variant:"ghost",size:"sm",onClick:t,"aria-label":"Clear selection",children:[jsxRuntime.jsx(lucideReact.X,{className:"h-4 w-4 mr-1","aria-hidden":"true"}),"Clear"]})]}),jsxRuntime.jsx("div",{className:"flex items-center gap-2",role:"group","aria-label":"Batch actions",children:r})]})})}function Rb({columns:e,isColumnVisible:t,toggleColumn:r,showAllColumns:n,hideAllColumns:o}){let a=e.filter(s=>t(s.id)).length,i=e.filter(s=>!s.locked);return jsxRuntime.jsxs(Pb,{children:[jsxRuntime.jsx(Fb,{asChild:true,children:jsxRuntime.jsxs(j,{variant:"outline",size:"sm",className:"gap-2",children:[jsxRuntime.jsx(lucideReact.Columns3,{className:"h-4 w-4"}),"Columns",jsxRuntime.jsxs("span",{className:"text-muted-foreground text-xs",children:["(",a,"/",e.length,")"]})]})}),jsxRuntime.jsxs(Qs,{align:"end",className:"w-48",children:[jsxRuntime.jsx(Js,{className:"font-normal text-xs text-muted-foreground",children:"Toggle columns"}),jsxRuntime.jsx(ua,{}),e.map(s=>{let l=t(s.id),c=s.locked===true;return jsxRuntime.jsxs(io,{onClick:u=>{u.preventDefault(),c||r(s.id);},className:N("gap-2 cursor-pointer",c&&"opacity-50 cursor-not-allowed"),disabled:c,children:[jsxRuntime.jsx("div",{className:"w-4 h-4 flex items-center justify-center",children:l?jsxRuntime.jsx(lucideReact.Check,{className:"h-3.5 w-3.5 text-primary"}):jsxRuntime.jsx("div",{className:"h-3.5 w-3.5"})}),jsxRuntime.jsx("span",{className:"flex-1",children:s.label}),c&&jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"Required"})]},s.id)}),i.length>1&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ua,{}),jsxRuntime.jsxs(io,{onClick:s=>{s.preventDefault(),n();},className:"gap-2 cursor-pointer",children:[jsxRuntime.jsx(lucideReact.Eye,{className:"h-4 w-4"}),"Show All"]}),jsxRuntime.jsxs(io,{onClick:s=>{s.preventDefault(),o();},className:"gap-2 cursor-pointer",children:[jsxRuntime.jsx(lucideReact.EyeOff,{className:"h-4 w-4"}),"Hide Optional"]})]})]})]})}function Ib({search:e,onSearchChange:t,searchPlaceholder:r="Search...",filters:n,activeFilterCount:o=0,onClearFilters:a,className:i,children:s}){let c=n?.some(u=>u.type==="multi")?"w-[420px]":"w-80";return jsxRuntime.jsxs("div",{className:N("flex items-center gap-3 flex-wrap",i),children:[t!==void 0&&jsxRuntime.jsxs("div",{className:"relative flex-1 min-w-[200px] max-w-xs",children:[jsxRuntime.jsx(lucideReact.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none z-10"}),jsxRuntime.jsx(Et,{placeholder:r,value:e||"",onChange:u=>t(u.target.value),className:"pl-9 h-9"}),e&&jsxRuntime.jsx("button",{type:"button",onClick:()=>t(""),className:"absolute right-2 top-1/2 transform -translate-y-1/2 p-1 rounded-sm hover:bg-muted",children:jsxRuntime.jsx(lucideReact.X,{className:"h-3 w-3 text-muted-foreground"})})]}),n&&n.length>0&&jsxRuntime.jsxs(Lr,{children:[jsxRuntime.jsx(Dr,{asChild:true,children:jsxRuntime.jsxs(j,{variant:"outline",size:"sm",className:"gap-2 h-9",children:[jsxRuntime.jsx(lucideReact.Filter,{className:"h-4 w-4"}),"Filters",o>0&&jsxRuntime.jsx("span",{className:"ml-1 rounded-full bg-primary text-primary-foreground px-2 py-0.5 text-xs font-medium",children:o})]})}),jsxRuntime.jsx(hr,{className:N(c,"overflow-y-auto"),align:"start",collisionPadding:16,style:{maxHeight:"var(--radix-popover-content-available-height)"},children:jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("h4",{className:"font-medium text-sm",children:"Filters"}),o>0&&a&&jsxRuntime.jsx(j,{variant:"ghost",size:"sm",onClick:a,className:"h-auto p-0 text-xs text-destructive hover:text-destructive",children:"Clear all"})]}),jsxRuntime.jsx("div",{className:"space-y-4",children:n.map(u=>jsxRuntime.jsxs("div",{className:"space-y-1.5",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:u.label}),u.render()]},u.id))})]})})]}),o>0&&a&&jsxRuntime.jsxs(j,{variant:"ghost",size:"sm",onClick:a,className:"h-9 gap-1.5 text-muted-foreground hover:text-foreground",children:[jsxRuntime.jsx(lucideReact.X,{className:"h-4 w-4"}),"Clear"]}),jsxRuntime.jsx("div",{className:"flex-1"}),s]})}function _b({options:e,selected:t,onChange:r,maxHeight:n=200,columns:o=2,showBulkActions:a=true,className:i}){let s=p=>{let f=new Set(t);f.has(p)?f.delete(p):f.add(p),r(f);},l=()=>{r(new Set(e.map(p=>p.value)));},c=()=>{r(new Set);},u={1:"grid-cols-1",2:"grid-cols-2",3:"grid-cols-3"},d=e.length>0&&t.size===e.length,g=t.size===0;return jsxRuntime.jsxs("div",{className:N("space-y-2",i),children:[a&&e.length>3&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[jsxRuntime.jsx(j,{type:"button",variant:"ghost",size:"sm",onClick:l,disabled:d,className:"h-6 px-2 text-xs text-muted-foreground hover:text-foreground",children:"Select all"}),jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"\xB7"}),jsxRuntime.jsx(j,{type:"button",variant:"ghost",size:"sm",onClick:c,disabled:g,className:"h-6 px-2 text-xs text-muted-foreground hover:text-foreground",children:"Clear"}),t.size>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"\xB7"}),jsxRuntime.jsxs("span",{className:"text-muted-foreground",children:[t.size," selected"]})]})]}),jsxRuntime.jsx("div",{className:N("overflow-y-auto",e.length>6&&"pr-1"),style:{maxHeight:`${n}px`},children:jsxRuntime.jsx("div",{className:N("grid gap-1",u[o]),children:e.map(p=>jsxRuntime.jsxs("label",{className:N("flex items-center gap-2 px-2 py-1.5 rounded-md cursor-pointer","hover:bg-muted/50 transition-colors",t.has(p.value)&&"bg-muted/30"),children:[jsxRuntime.jsx(Xs,{checked:t.has(p.value),onCheckedChange:()=>s(p.value),className:"h-3.5 w-3.5"}),p.render?jsxRuntime.jsx("span",{className:"flex items-center gap-1.5 text-sm truncate",children:p.render()}):jsxRuntime.jsx("span",{className:"text-sm truncate",children:p.label})]},p.value))})}),e.length===0&&jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground text-center py-2",children:"No options available"})]})}/*! Bundled license information:
|
|
62
62
|
|
|
63
63
|
prismjs/components/prism-core.js:
|
|
64
64
|
(**
|