"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[669],{27325:function(e,t,s){s.d(t,{Z:function(){return r}});/**
 * @license lucide-react v0.407.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */let r=(0,s(60998).Z)("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]])},81260:function(e,t,s){s.d(t,{Z:function(){return r}});/**
 * @license lucide-react v0.407.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */let r=(0,s(60998).Z)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},47603:function(e,t,s){s.d(t,{Z:function(){return r}});/**
 * @license lucide-react v0.407.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */let r=(0,s(60998).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},1812:function(e,t,s){s.d(t,{X:function(){return l}});var r=s(85893),n=s(67294);let a=e=>{if(!(null==e?void 0:e.message))return"An unexpected error occurred.";let t=e.message;return t.includes("failed:")&&(t=t.split("failed:")[1].trim()),t},l=e=>{let{error:t,title:s="Error",onDismiss:l}=e,[o,i]=(0,n.useState)(!1);if((0,n.useEffect)(()=>{t&&i(!1)},[t]),!t||o)return null;let c="string"==typeof t?t:a(t);return(0,r.jsx)("div",{className:"bg-red-50 border border-red-200 rounded-md p-3 mb-4",children:(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("div",{className:"flex-shrink-0",children:(0,r.jsx)("svg",{className:"h-5 w-5 text-red-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})})}),(0,r.jsx)("div",{className:"ml-3",children:(0,r.jsxs)("div",{className:"text-sm text-red-800",children:[(0,r.jsxs)("strong",{children:[s,":"]})," ",c]})})]}),(0,r.jsx)("button",{onClick:()=>{i(!0),l&&l()},className:"flex-shrink-0 ml-4 text-red-400 hover:text-red-600 focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2 focus:ring-offset-red-50 rounded","aria-label":"Dismiss error",children:(0,r.jsx)("svg",{className:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]})})}},27669:function(e,t,s){s.r(t),s.d(t,{Users:function(){return W}});var r=s(85893),n=s(67294),a=s(45697),l=s.n(a),o=s(55739),i=s(41664),c=s.n(i),u=s(11163),d=s(30803),m=s(68764),x=s(53081),h=s(23266),p=s(68969),f=s(6378),g=s(36856),b=s(51214),j=s(94545),y=s(470),v=s(60998);/**
 * @license lucide-react v0.407.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */let w=(0,v.Z)("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]);var N=s(13626),C=s(81260);/**
 * @license lucide-react v0.407.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */let k=(0,v.Z)("EyeOff",[["path",{d:"M9.88 9.88a3 3 0 1 0 4.24 4.24",key:"1jxqfv"}],["path",{d:"M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68",key:"9wicm4"}],["path",{d:"M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61",key:"1jreej"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]),_=(0,v.Z)("Eye",[["path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z",key:"rwhkz3"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);var S=s(16826),E=s(70282),R=s(43767);/**
 * @license lucide-react v0.407.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */let D=(0,v.Z)("Pen",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]),T=(0,v.Z)("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);var I=s(47603),L=s(27325);s(33872);var Z=s(23001),P=s(29071),U=s(37673),A=s(47145),F=s(91360),M=s(1812),O=s(9243),z=s(10546);let q=new Set(O.statusGroups.active),V=[{label:"Name",value:"name"},{label:"GPU",value:"gpu type"},{label:"Infra",value:"infra"},{label:"User ID",value:"user id"},{label:"Role",value:"role"}],B=(e,t)=>{if(!e)return 0;let s=e;if("string"==typeof e)try{let t=e.replace(/'/g,'"').replace(/None/g,"null");s=JSON.parse(t)}catch(t){return console.error("Failed to parse accelerators string:",e,t),0}if("object"==typeof s&&null!==s){let e=Object.entries(s);return 0===e.length?0:(e.length>1&&console.warn("".concat(t," has ").concat(e.length," accelerator entries:"),s),Number(e[0][1])||0)}return 0},K=async()=>{let[e,t]=await Promise.allSettled([f.ZP.get(h.getClusters),f.ZP.get(p.getManagedJobs,[{allUsers:!0,skipFinished:!0}])]),s="fulfilled"===e.status&&e.value||[],r="fulfilled"===t.status&&t.value||{jobs:[]};return"rejected"===e.status&&console.error("Error fetching clusters:",e.reason),"rejected"===t.status&&console.error("Error fetching managed jobs:",t.reason),{clustersData:s,jobsResponse:r}},G=(e,t)=>e&&e.includes("@")?e.split("@")[0]:e||"N/A",J=(e,t)=>e&&e.includes("@")?e:t||"-",$=b.nb.REFRESH_INTERVAL,H=e=>{let{message:t,onDismiss:s}=e;return t?(0,r.jsx)("div",{className:"bg-green-50 border border-green-200 rounded p-4 mb-6",children:(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)("div",{className:"flex-shrink-0",children:(0,r.jsx)("svg",{className:"h-5 w-5 text-green-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})})}),(0,r.jsx)("div",{className:"ml-3",children:(0,r.jsx)("p",{className:"text-sm font-medium text-green-800",children:t})})]}),s&&(0,r.jsx)("div",{className:"ml-auto pl-3",children:(0,r.jsx)("div",{className:"-mx-1.5 -my-1.5",children:(0,r.jsxs)("button",{type:"button",onClick:s,className:"inline-flex rounded-md bg-green-50 p-1.5 text-green-500 hover:bg-green-100 focus:outline-none focus:ring-2 focus:ring-green-600 focus:ring-offset-2 focus:ring-offset-green-50",children:[(0,r.jsx)("span",{className:"sr-only",children:"Dismiss"}),(0,r.jsx)("svg",{className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})]})})})]})}):null};function W(){let e=(0,u.useRouter)(),{userEmail:t}=(0,P.Ap)(),[s,a]=(0,n.useState)(!1),l=(0,n.useRef)(null),i=(0,Z.X)(),[c,m]=(0,n.useState)(!1),[g,b]=(0,n.useState)({username:"",password:"",role:"user"}),[j,v]=(0,n.useState)(!1),[E,R]=(0,n.useState)({open:!1,message:"",userName:""}),[D,T]=(0,n.useState)(null),[I,L]=(0,n.useState)(!1),[U,O]=(0,n.useState)(!1),[q,B]=(0,n.useState)(!1),[K,G]=(0,n.useState)(null),[J,W]=(0,n.useState)(!1),[Y,ee]=(0,n.useState)(null),[et,es]=(0,n.useState)("import"),[er,en]=(0,n.useState)(!1),[ea,el]=(0,n.useState)(null),[eo,ei]=(0,n.useState)(""),[ec,eu]=(0,n.useState)(!1),[ed,em]=(0,n.useState)(null),[ex,eh]=(0,n.useState)(!1),[ep,ef]=(0,n.useState)(null),[eg,eb]=(0,n.useState)(null),[ej,ey]=(0,n.useState)(!1),[ev,ew]=(0,n.useState)(null),[eN,eC]=(0,n.useState)(null),[ek,e_]=(0,n.useState)(void 0),[eS,eE]=(0,n.useState)(void 0),[eR,eD]=(0,n.useState)(void 0),[eT,eI]=(0,n.useState)(void 0),[eL,eZ]=(0,n.useState)(!0),[eP,eU]=(0,n.useState)("users"),[eA,eF]=(0,n.useState)(!1),[eM,eO]=(0,n.useState)(!1),[ez,eq]=(0,n.useState)(null),[eV,eB]=(0,n.useState)(!1),[eK,eG]=(0,n.useState)(""),[eJ,e$]=(0,n.useState)(""),[eH,eW]=(0,n.useState)([]),[eX,eQ]=(0,n.useState)({name:[],"user id":[],role:[],"gpu type":[],infra:[]}),[eY,e0]=(0,n.useState)(null),[e1,e2]=(0,n.useState)(()=>{if(e.isReady){let t=e.query.deduplicate;if(void 0!==t)return"true"===t}return!0});(0,n.useEffect)(()=>{if(e.isReady){let s=e.query.deduplicate;if(void 0===s)e4(!t);else{let e="true"===s;e1!==e&&e2(e)}}},[e.isReady,e.query.deduplicate,t]);let e4=t=>{let s={...e.query};s.deduplicate=t.toString(),e.replace({pathname:e.pathname,query:s},void 0,{shallow:!0})},e3=t=>{(0,z.eG)(e,t)},e5=new Map([["name","Name"],["user id","User ID"],["role","Role"],["gpu type","GPU"],["infra","Infra"]]);(0,n.useEffect)(()=>{if(e.isReady&&"users"===eP){let t=(0,z.Fu)(e,e5);t.length>0&&eW(t)}},[e.isReady,eP]),(0,n.useEffect)(()=>{e.isReady&&("service-accounts"===e.query.tab&&eS?eU("service-accounts"):eU("users"))},[e.isReady,e.query.tab,eS]),(0,n.useEffect)(()=>{(async function(){eZ(!0);try{let e=await A.x.get("/api/health");if(e.ok){let t=await e.json();e_(!!t.basic_auth_enabled),eE(!!t.service_account_token_enabled),eD(!!t.ingress_basic_auth_enabled),eI(!!t.external_proxy_auth_enabled)}else e_(!1),eE(!1),eD(!1),eI(!1)}catch(e){e_(!1),eE(!1),eD(!1),eI(!1)}finally{eZ(!1)}})()},[]);let e6=(0,n.useCallback)(async()=>{if(D&&Date.now()-D.timestamp<3e5)return D;L(!0);try{let e=await A.x.get("/users/role");if(!e.ok){let t=await e.json();throw Error(t.detail||"Failed to get user role")}let t=await e.json(),s={role:t.role,name:t.name,id:t.id,timestamp:Date.now()};return T(s),L(!1),s}catch(e){throw L(!1),e}},[D]);(0,n.useEffect)(()=>{e6().catch(()=>{console.error("Failed to get user role")})},[e6]);let e7=async(e,t)=>{try{let s=await e6();if("admin"!==s.role)return R({open:!0,message:e,userName:s.name.toLowerCase()}),!1;return t(),!0}catch(e){return console.error("Failed to check user role:",e),R({open:!0,message:"Error: ".concat(e.message),userName:""}),!1}},e8=()=>{f.ZP.invalidate(x.R),f.ZP.invalidate(h.getClusters),f.ZP.invalidate(p.getManagedJobs,[{allUsers:!0,skipFinished:!0}]),l.current&&l.current()};(0,n.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&"r"===e.key&&(e.preventDefault(),e.stopPropagation(),e8())};return document.addEventListener("keydown",e,!0),()=>{document.removeEventListener("keydown",e,!0)}},[]);let e9=async()=>{if(!g.username||!g.password){eC(Error("Username and password are required.")),m(!1);return}v(!0),eC(null),ew(null);try{let e=await A.x.post("/users/create",g);if(!e.ok){let t=await e.json();throw Error(t.detail||"Failed to create user")}ew('User "'.concat(g.username,'" created successfully!')),m(!1),b({username:"",password:"",role:"user"}),e8()}catch(e){eC(e),m(!1),b({username:"",password:"",role:"user"})}finally{v(!1)}},te=async e=>{let t=e.target.files[0];t&&(G(t),ee(null))},tt=async()=>{if(!K){alert("Please select a CSV file first.");return}W(!0);try{let e=new FileReader;e.onload=async e=>{try{let t=e.target.result,s=await A.x.post("/users/import",{csv_content:t});if(!s.ok){let e=await s.json();throw Error(e.detail||"Failed to import users")}let r=await s.json(),n="Import completed. ".concat(r.success_count," users created successfully.");r.error_count>0&&(n+="\n".concat(r.error_count," failed."),r.creation_errors.length>0&&(n+="\nErrors: ".concat(r.creation_errors.slice(0,3).join(", ")),r.creation_errors.length>3&&(n+=" and ".concat(r.creation_errors.length-3," more...")))),ee({message:n}),r.success_count>0&&e8()}catch(e){alert("Error importing users: ".concat(e.message))}finally{W(!1)}},e.readAsText(K)}catch(e){alert("Error reading file: ".concat(e.message)),W(!1)}},ts=async e=>{el(e),ei(""),en(!0)},tr=async()=>{if(!eo){eC(Error("Please enter a new password."));return}eu(!0),em(null);try{let e=await A.x.post("/users/update",{user_id:ea.userId,password:eo});if(!e.ok){let t=await e.json();throw Error(t.detail||"Failed to reset password")}ew('Password reset successfully for user "'.concat(ea.usernameDisplay,'"!')),en(!1),el(null),ei("")}catch(e){en(!1),el(null),ei(""),em(null),eC(e)}finally{eu(!1)}},tn=async()=>{if(ep){ey(!0),eb(null);try{let e=await A.x.post("/users/delete",{user_id:ep.userId});if(!e.ok){let t=await e.json();throw Error(t.detail||"Failed to delete user")}ew('User "'.concat(ep.usernameDisplay,'" deleted successfully!')),eh(!1),ef(null),e8()}catch(e){eh(!1),ef(null),eb(null),eC(e)}finally{ey(!1)}}},ta=()=>{eh(!1),ef(null)},tl=()=>{en(!1),el(null),ei("")};return eL?(0,r.jsxs)("div",{className:"flex justify-center items-center h-64",children:[(0,r.jsx)(o.Z,{}),(0,r.jsx)("span",{className:"ml-2 text-gray-500",children:"Loading..."})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,r.jsxs)("div",{className:"text-base flex items-center",children:[(0,r.jsx)("button",{className:eS?"leading-none mr-6 pb-2 px-2 border-b-2 ".concat("users"===eP?"text-sky-blue border-sky-500":"text-gray-500 hover:text-gray-700 border-transparent"):"leading-none mr-6 pb-2 px-2",onClick:()=>{eU("users"),e.push("/users",void 0,{shallow:!0})},children:"Users"}),eS&&(0,r.jsx)("button",{className:"leading-none pb-2 px-2 border-b-2 ".concat("service-accounts"===eP?"text-sky-blue border-sky-500":"text-gray-500 hover:text-gray-700 border-transparent"),onClick:()=>{eU("service-accounts"),e.push("/users?tab=service-accounts",void 0,{shallow:!0})},children:"Service Accounts"})]}),(0,r.jsxs)("div",{className:"flex items-center",children:[s&&(0,r.jsxs)("div",{className:"flex items-center mr-2",children:[(0,r.jsx)(o.Z,{size:15,className:"mt-0"}),(0,r.jsx)("span",{className:"ml-2 text-gray-500",children:"Loading..."})]}),"users"===eP&&ek&&(null==D?void 0:D.role)==="admin"&&(0,r.jsx)("button",{onClick:async()=>{await e7("cannot create users",()=>{m(!0)})},className:"text-sky-blue hover:text-sky-blue-bright flex items-center rounded px-2 py-1 mr-2",title:"Create New User",children:"+ New User"}),"users"===eP&&ek&&(null==D?void 0:D.role)==="admin"&&(0,r.jsxs)("button",{onClick:async()=>{await e7("cannot import users",()=>{B(!0)})},className:"text-sky-blue hover:text-sky-blue-bright flex items-center rounded px-2 py-1 mr-2",title:"Import/Export Users",children:[(0,r.jsx)(w,{className:"h-4 w-4 mr-1"}),"Import/Export"]}),!s&&eY&&(0,r.jsx)(y.$3,{timestamp:eY,className:"mr-2"}),(0,r.jsxs)("button",{onClick:e8,disabled:s,className:"text-sky-blue hover:text-sky-blue-bright flex items-center",children:[(0,r.jsx)(N.Z,{className:"h-4 w-4 mr-1.5"}),!i&&(0,r.jsx)("span",{children:"Refresh"})]})]})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:["users"===eP?(0,r.jsx)("div",{className:"w-full sm:w-auto max-w-md",children:(0,r.jsx)(z.ML,{propertyList:V,valueList:eX,setFilters:eW,updateURLParams:e3,placeholder:"Filter users"})}):(0,r.jsxs)("div",{className:"relative flex-1 max-w-md",children:[(0,r.jsx)("input",{type:"text",placeholder:"Search by service account name, or created by",value:eJ,onChange:e=>{e$(e.target.value)},className:"h-8 w-full px-3 pr-8 text-sm border border-gray-300 rounded-md focus:ring-1 focus:ring-sky-500 focus:border-sky-500 outline-none"}),eJ&&(0,r.jsx)("button",{onClick:()=>{e$("")},className:"absolute right-2 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-gray-600",title:"Clear search",children:(0,r.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),"users"===eP&&!t&&(0,r.jsxs)("label",{className:"flex items-center cursor-pointer ml-4",children:[(0,r.jsx)("input",{type:"checkbox",checked:e1,onChange:e=>{let t=e.target.checked;e2(t),e4(t)},className:"sr-only"}),(0,r.jsx)("div",{className:"relative inline-flex h-5 w-9 items-center rounded-full transition-colors ".concat(e1?"bg-sky-600":"bg-gray-300"),children:(0,r.jsx)("span",{className:"inline-block h-3 w-3 transform rounded-full bg-white transition-transform ".concat(e1?"translate-x-5":"translate-x-1")})}),(0,r.jsx)("span",{className:"ml-2 text-sm text-gray-700",children:"Deduplicate users"})]}),"service-accounts"===eP&&eS&&(0,r.jsxs)("button",{onClick:()=>{e7("cannot create service account tokens",()=>{eF(!0)})},className:"ml-4 bg-sky-600 hover:bg-sky-700 text-white flex items-center rounded-md px-3 py-1 text-sm font-medium transition-colors duration-200",title:"Create Service Account",children:[(0,r.jsx)(C.Z,{className:"h-4 w-4 mr-2"}),"Create Service Account"]})]}),"users"===eP&&(0,r.jsx)(z.x$,{filters:eH,setFilters:eW,updateURLParams:e3}),(0,r.jsxs)("div",{className:"fixed top-20 right-4 z-[9999] max-w-md",children:[(0,r.jsx)(H,{message:ev,onDismiss:()=>ew(null)}),(0,r.jsx)(M.X,{error:eN,title:"Error",onDismiss:()=>eC(null)})]}),"users"===eP?(0,r.jsx)(X,{refreshInterval:$,setLoading:a,refreshDataRef:l,checkPermissionAndAct:e7,roleLoading:I,onResetPassword:ts,onDeleteUser:e=>{e7("cannot delete users",()=>{ef(e),eh(!0)})},basicAuthEnabled:ek,ingressBasicAuthEnabled:eR,externalProxyAuthEnabled:eT,currentUserRole:null==D?void 0:D.role,currentUserId:null==D?void 0:D.id,filters:eH,setValueList:eQ,deduplicateUsers:e1,setLastFetchedTime:e0}):eS&&(0,r.jsx)(Q,{checkPermissionAndAct:e7,userRoleCache:D,setCreateSuccess:ew,setCreateError:eC,showCreateDialog:eA,setShowCreateDialog:eF,showRotateDialog:eM,setShowRotateDialog:eO,tokenToRotate:ez,setTokenToRotate:eq,rotating:eV,setRotating:eB,searchQuery:eJ,setSearchQuery:e$}),(0,r.jsx)(F.Vq,{open:c,onOpenChange:e=>{m(e),e||eC(null)},children:(0,r.jsxs)(F.cZ,{className:"sm:max-w-md",children:[(0,r.jsx)(F.fK,{children:(0,r.jsx)(F.$N,{children:"Create User"})}),(0,r.jsxs)("div",{className:"flex flex-col gap-4 py-4",children:[(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"Username"}),(0,r.jsx)("input",{className:"border rounded px-3 py-2 w-full",placeholder:"Username",value:g.username,onChange:e=>b({...g,username:e.target.value})})]}),(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"Password"}),(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("input",{className:"border rounded px-3 py-2 w-full pr-10",placeholder:"Password",type:U?"text":"password",value:g.password,onChange:e=>b({...g,password:e.target.value})}),(0,r.jsx)("button",{type:"button",className:"absolute inset-y-0 right-0 pr-3 flex items-center text-gray-400 hover:text-gray-600",onClick:()=>O(!U),children:U?(0,r.jsx)(k,{className:"h-4 w-4"}):(0,r.jsx)(_,{className:"h-4 w-4"})})]})]}),(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"Role"}),(0,r.jsxs)("select",{className:"border rounded px-3 py-2 w-full",value:g.role,onChange:e=>b({...g,role:e.target.value}),children:[(0,r.jsx)("option",{value:"user",children:"User"}),(0,r.jsx)("option",{value:"admin",children:"Admin"})]})]})]}),(0,r.jsxs)(F.cN,{children:[(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-10 px-4 py-2",onClick:()=>m(!1),disabled:j,children:"Cancel"}),(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-sky-600 text-white hover:bg-sky-700 h-10 px-4 py-2",onClick:e9,disabled:j,children:j?"Creating...":"Create"})]})]})}),(0,r.jsx)(F.Vq,{open:E.open,onOpenChange:e=>{R(t=>({...t,open:e})),e||eC(null)},children:(0,r.jsxs)(F.cZ,{className:"sm:max-w-md transition-all duration-200 ease-in-out",children:[(0,r.jsxs)(F.fK,{children:[(0,r.jsx)(F.$N,{children:"Permission Denied"}),(0,r.jsx)(F.Be,{children:I?(0,r.jsxs)("div",{className:"flex items-center py-2",children:[(0,r.jsx)(o.Z,{size:16,className:"mr-2"}),(0,r.jsx)("span",{children:"Checking permissions..."})]}):(0,r.jsx)(r.Fragment,{children:E.userName?(0,r.jsxs)(r.Fragment,{children:[E.userName," is logged in as non-admin and ",E.message,"."]}):E.message})})]}),(0,r.jsx)(F.cN,{children:(0,r.jsx)(d.z,{variant:"outline",onClick:()=>R(e=>({...e,open:!1})),disabled:I,children:"OK"})})]})}),(0,r.jsx)(F.Vq,{open:q,onOpenChange:e=>{B(e),e||eC(null)},children:(0,r.jsxs)(F.cZ,{className:"sm:max-w-lg",children:[(0,r.jsx)(F.fK,{children:(0,r.jsx)(F.$N,{children:"Import/Export Users"})}),(0,r.jsxs)("div",{className:"flex border-b border-gray-200 mb-4",children:[(0,r.jsx)("button",{className:"px-4 py-2 text-sm font-medium ".concat("import"===et?"border-b-2 border-sky-500 text-sky-600":"text-gray-500 hover:text-gray-700"),onClick:()=>es("import"),children:"Import"}),(0,r.jsx)("button",{className:"px-4 py-2 text-sm font-medium ".concat("export"===et?"border-b-2 border-sky-500 text-sky-600":"text-gray-500 hover:text-gray-700"),onClick:()=>es("export"),children:"Export"})]}),(0,r.jsx)("div",{className:"flex flex-col gap-4 py-4",children:"import"===et?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"CSV File"}),(0,r.jsx)("input",{type:"file",accept:".csv",onChange:te,className:"border rounded px-3 py-2 w-full"}),(0,r.jsxs)("p",{className:"text-xs text-gray-500",children:["CSV should have columns: username, password, role",(0,r.jsx)("br",{}),"Supports both plain text passwords and exported password hashes."]})]}),Y&&(0,r.jsx)("div",{className:"p-3 bg-green-50 border border-green-200 rounded text-green-700 text-sm",children:Y.message})]}):(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"Export Users to CSV"}),(0,r.jsx)("p",{className:"text-xs text-gray-500",children:"Download all users as a CSV file with password hashes."}),(0,r.jsxs)("div",{className:"p-3 bg-amber-50 border border-amber-200 rounded",children:[(0,r.jsx)("p",{className:"text-sm text-amber-700",children:"⚠️ This will export all users with columns: username, password (hashed), role"}),(0,r.jsx)("p",{className:"text-xs text-amber-600 mt-1",children:"Password hashes can be imported directly for system backups."})]})]})})}),(0,r.jsxs)(F.cN,{children:[(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-10 px-4 py-2",onClick:()=>B(!1),disabled:J,children:"Cancel"}),"import"===et?(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-sky-600 text-white hover:bg-sky-700 h-10 px-4 py-2",onClick:tt,disabled:J||!K,children:J?"Importing...":"Import"}):(0,r.jsxs)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-sky-600 text-white hover:bg-sky-700 h-10 px-4 py-2",onClick:async()=>{try{let e=await A.x.get("/users/export");if(!e.ok){let t=await e.json();throw Error(t.detail||"Failed to export users")}let t=await e.json(),s=t.csv_content,r=new Blob([s],{type:"text/csv;charset=utf-8;"}),n=URL.createObjectURL(r),a=document.createElement("a");a.href=n;let l=new Date,o=e=>String(e).padStart(2,"0"),i=l.getFullYear(),c=o(l.getMonth()+1),u=o(l.getDate()),d=o(l.getHours()),m=o(l.getMinutes()),x=o(l.getSeconds());a.download="users_export_".concat(i,"-").concat(c,"-").concat(u,"-").concat(d,"-").concat(m,"-").concat(x,".csv"),a.click(),URL.revokeObjectURL(n),alert("Successfully exported ".concat(t.user_count," users to CSV file."))}catch(e){alert("Error exporting users: ".concat(e.message))}},children:[(0,r.jsx)(S.Z,{className:"h-4 w-4 mr-1"}),"Export"]})]})]})}),(0,r.jsx)(F.Vq,{open:er,onOpenChange:e=>{e||(tl(),eC(null))},children:(0,r.jsxs)(F.cZ,{className:"sm:max-w-md",children:[(0,r.jsxs)(F.fK,{children:[(0,r.jsx)(F.$N,{children:"Reset Password"}),(0,r.jsxs)(F.Be,{children:["Enter a new password for"," ",(null==ea?void 0:ea.usernameDisplay)||"this user","."]})]}),(0,r.jsx)("div",{className:"flex flex-col gap-4 py-4",children:(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"New Password"}),(0,r.jsx)("input",{type:"password",className:"border rounded px-3 py-2 w-full",placeholder:"Enter new password",value:eo,onChange:e=>ei(e.target.value),autoFocus:!0})]})}),(0,r.jsxs)(F.cN,{children:[(0,r.jsx)(d.z,{variant:"outline",onClick:tl,disabled:ec,children:"Cancel"}),(0,r.jsx)(d.z,{variant:"default",onClick:tr,disabled:ec||!eo,className:"bg-sky-600 text-white hover:bg-sky-700",children:ec?"Resetting...":"Reset Password"})]})]})}),(0,r.jsx)(F.Vq,{open:ex,onOpenChange:e=>{e||(ta(),eC(null))},children:(0,r.jsxs)(F.cZ,{className:"sm:max-w-md",children:[(0,r.jsxs)(F.fK,{children:[(0,r.jsx)(F.$N,{children:"Delete User"}),(0,r.jsxs)(F.Be,{children:['Are you sure you want to delete user "',(null==ep?void 0:ep.usernameDisplay)||"this user",'"? This action cannot be undone.']})]}),(0,r.jsxs)(F.cN,{children:[(0,r.jsx)(d.z,{variant:"outline",onClick:ta,disabled:ej,children:"Cancel"}),(0,r.jsx)(d.z,{variant:"destructive",onClick:tn,disabled:ej,children:ej?"Deleting...":"Delete"})]})]})})]})}function X(e){let{refreshInterval:t,setLoading:s,refreshDataRef:a,checkPermissionAndAct:l,roleLoading:i,onResetPassword:u,onDeleteUser:d,basicAuthEnabled:h,ingressBasicAuthEnabled:p,externalProxyAuthEnabled:b,currentUserRole:v,currentUserId:w,filters:N,setValueList:C,deduplicateUsers:k,setLastFetchedTime:_}=e,[S,L]=(0,n.useState)([]),[Z,P]=(0,n.useState)(!0),[F,M]=(0,n.useState)(!1),[O,V]=(0,n.useState)({key:"username",direction:"ascending"}),[$,H]=(0,n.useState)(null),[W,X]=(0,n.useState)(""),[Q,Y]=(0,n.useState)({}),[ee,et]=(0,n.useState)(!1),es=(0,n.useCallback)(async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];s&&e&&s(!0),e&&P(!0),et(!1);try{let t=await f.ZP.get(x.R),r=(t||[]).map(e=>({...e,usernameDisplay:G(e.username,e.userId),fullEmailID:J(e.username,e.userId),clusterCount:-1,jobCount:-1,gpuCount:-1}));L(r),M(!0),s&&e&&s(!1),e&&P(!1);let{clustersData:n,jobsResponse:a}=await K(),l=a.jobs||[],o={},i=e=>{if(!e)return null;let t=e;if("string"==typeof e)try{let s=e.replace(/'/g,'"').replace(/None/g,"null");t=JSON.parse(s)}catch(e){return null}if("object"==typeof t&&null!==t){let e=Object.entries(t);if(e.length>0)return e[0][0]}return null},c=(e,t,s,r,n,a)=>{e&&t&&(o[e]||(o[e]={}),o[e][t]||(o[e][t]={}),o[e].Total||(o[e].Total={}),o[e][t].Total||(o[e][t].Total={clusterCount:0,jobCount:0,gpuCount:0}),o[e][t].Total.clusterCount+=r,o[e][t].Total.jobCount+=n,o[e][t].Total.gpuCount+=a,s&&(o[e][t][s]||(o[e][t][s]={clusterCount:0,jobCount:0,gpuCount:0}),o[e][t][s].clusterCount+=r,o[e][t][s].jobCount+=n,o[e][t][s].gpuCount+=a,o[e].Total[s]||(o[e].Total[s]={clusterCount:0,jobCount:0,gpuCount:0}),o[e].Total[s].clusterCount+=r,o[e].Total[s].jobCount+=n,o[e].Total[s].gpuCount+=a))};for(let e of n||[]){let t=e.user_hash;if(!t)continue;let s=i(e.gpus),r=e.infra,n=0;if("STOPPED"!==e.status&&"TERMINATED"!==e.status){let t=B(e.gpus,"Cluster ".concat(e.cluster)),s=e.num_nodes||1;n=t*s}c(t,r,s,1,0,n)}let u=e=>{if(!e||"string"!=typeof e)return 1;let t=e.match(/^(\d+)x/);return t?parseInt(t[1],10):1};for(let e of l||[]){if(!q.has(e.status))continue;let t=e.user_hash;if(!t)continue;let s=i(e.accelerators),r=e.infra,n=B(e.accelerators,"Job ".concat(e.job_id)),a=u(e.resources_str_full),l=n*a;c(t,r,s,0,1,l)}Y(o),et(!0);let d=(t||[]).map(e=>{let t=0,s=0,r=0,a=0;for(let r of n||[])if(r.user_hash===e.userId&&(t++,"STOPPED"!==r.status&&"TERMINATED"!==r.status)){let e=B(r.gpus,"Cluster ".concat(r.cluster)),t=r.num_nodes||1;s+=e*t}for(let t of l||[])if(t.user_hash===e.userId&&q.has(t.status)){r++;let e=B(t.accelerators,"Job ".concat(t.job_id)),s=u(t.resources_str_full);a+=e*s}return{...e,usernameDisplay:G(e.username,e.userId),fullEmailID:J(e.username,e.userId),clusterCount:t,jobCount:r,gpuCount:s+a}}),m=new Set,h=new Set;for(let e of Object.values(o)){for(let t of Object.keys(e))"Total"!==t&&m.add(t);if(e.Total)for(let t of Object.keys(e.Total))h.add(t)}let p=new Set,g=new Set,b=new Set;d.forEach(e=>{e.usernameDisplay&&p.add(e.usernameDisplay),e.userId&&g.add(e.userId),e.role&&b.add(e.role)}),C({name:Array.from(p).sort(),"user id":Array.from(g).sort(),role:Array.from(b).sort(),"gpu type":Array.from(h).sort(),infra:Array.from(m).sort()}),L(d)}catch(t){console.error("Failed to fetch or process user data:",t),L([]),M(!0),s&&e&&s(!1),e&&P(!1)}finally{_&&_(new Date)}},[s,_]);(0,n.useEffect)(()=>{a&&(a.current=()=>es(!0))},[a,es]),(0,n.useEffect)(()=>{(async()=>{M(!1),P(!0),await g.ZP.preloadForPage("users"),es(!0)})();let e=setInterval(()=>{"visible"===window.document.visibilityState&&es(!1)},t);return()=>clearInterval(e)},[es,t]);let er=(0,n.useMemo)(()=>{let e=S,t=N.filter(e=>"GPU"!==e.property&&"Infra"!==e.property),s=N.filter(e=>"GPU"===e.property),r=N.filter(e=>"Infra"===e.property);t.length>0&&(e=(0,z.cm)(S.map(e=>({...e,name:e.usernameDisplay,"user id":e.userId})),t));let n=(e,t,s)=>{let r=0,n=0,a=0,l=Q[e];if(!l)return{clusterCount:0,jobCount:0,gpuCount:0};let o=t.map(e=>e.toLowerCase()),i=s.map(e=>e.toLowerCase()),c=o.length>0,u=i.length>0;if(c&&u){for(let e of i)for(let[t,s]of Object.entries(l))if("Total"!==t&&t.toLowerCase()===e)for(let e of o)for(let[t,l]of Object.entries(s))"Total"!==t&&t.toLowerCase()===e&&(r+=l.clusterCount,n+=l.jobCount,a+=l.gpuCount)}else if(u){for(let e of i)for(let[t,s]of Object.entries(l))if("Total"!==t&&t.toLowerCase()===e&&s.Total){let e=s.Total;r+=e.clusterCount,n+=e.jobCount,a+=e.gpuCount}}else if(c&&l.Total)for(let e of o)for(let[t,s]of Object.entries(l.Total))t.toLowerCase()===e&&(r+=s.clusterCount,n+=s.jobCount,a+=s.gpuCount);return{clusterCount:r,jobCount:n,gpuCount:a}},a=s.length>0,l=r.length>0;if(a||l){let t=s.map(e=>e.value).filter(Boolean),o=r.map(e=>e.value).filter(Boolean),i=t.map(e=>e.toLowerCase()),c=o.map(e=>e.toLowerCase());e=(e=e.filter(e=>{let t=Q[e.userId];if(!t)return!1;if(a&&l){for(let e of c)for(let[s,r]of Object.entries(t))if("Total"!==s&&s.toLowerCase()===e){for(let e of i)for(let t of Object.keys(r))if("Total"!==t&&t.toLowerCase()===e)return!0}}else if(l){for(let e of c)for(let s of Object.keys(t))if("Total"!==s&&s.toLowerCase()===e)return!0}else if(a&&t.Total){for(let e of i)for(let s of Object.keys(t.Total))if(s.toLowerCase()===e)return!0}return!1})).map(e=>{let s=n(e.userId,t,o);return{...e,clusterCount:s.clusterCount,jobCount:s.jobCount,gpuCount:s.gpuCount}})}if(k){let t={};e.forEach(e=>{let s=e.usernameDisplay;t[s]?(t[s].userIds.push(e.userId),-1!==e.clusterCount&&(-1===t[s].clusterCount?t[s].clusterCount=e.clusterCount:t[s].clusterCount+=e.clusterCount),-1!==e.jobCount&&(-1===t[s].jobCount?t[s].jobCount=e.jobCount:t[s].jobCount+=e.jobCount),-1!==e.gpuCount&&(-1===t[s].gpuCount?t[s].gpuCount=e.gpuCount:t[s].gpuCount+=e.gpuCount),e.created_at&&(!t[s].created_at||e.created_at<t[s].created_at)&&(t[s].created_at=e.created_at)):t[s]={...e,userIds:[e.userId],clusterCount:e.clusterCount,jobCount:e.jobCount,gpuCount:e.gpuCount,created_at:e.created_at}}),e=Object.values(t)}return(0,j.R0)(e,O.key,O.direction)},[S,O,N,k,Q]),en=e=>{let t="ascending";O.key===e&&"ascending"===O.direction&&(t="descending"),V({key:e,direction:t})},ea=e=>O.key===e?"ascending"===O.direction?" ↑":" ↓":"",el=async(e,t)=>{await l("cannot edit user role",()=>{H(e),X(t)})},eo=()=>{H(null),X("")},ei=async e=>{if(!e||!W){console.error("User ID or role is missing."),alert("Error: User ID or role is missing.");return}P(!0);try{let t=await A.x.post("/users/update",{user_id:e,role:W});if(!t.ok){let e=await t.json();throw Error(e.detail||"Failed to update role")}f.ZP.invalidate(x.R),await es(!0),eo()}catch(e){console.error("Failed to update user role:",e),alert("Error updating role: ".concat(e.message))}finally{P(!1)}};return Z&&0===S.length&&!F?(0,r.jsx)("div",{className:"flex justify-center items-center h-64",children:(0,r.jsx)(o.Z,{})}):F?N.some(e=>"GPU"===e.property||"Infra"===e.property)&&!ee?(0,r.jsxs)("div",{className:"flex justify-center items-center h-64",children:[(0,r.jsx)(o.Z,{}),(0,r.jsx)("span",{className:"ml-2 text-gray-500",children:"Loading filtered data..."})]}):er&&0!==er.length?(0,r.jsx)(U.Zb,{children:(0,r.jsx)("div",{className:"overflow-x-auto rounded-lg",children:(0,r.jsxs)(m.iA,{className:"min-w-full",children:[(0,r.jsx)(m.xD,{children:(0,r.jsxs)(m.SC,{children:[(0,r.jsxs)(m.ss,{onClick:()=>en("usernameDisplay"),className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50 w-1/6",children:["Name",ea("usernameDisplay")]}),!k&&(0,r.jsxs)(m.ss,{onClick:()=>en("fullEmailID"),className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50 w-1/6",children:["User ID",ea("fullEmailID")]}),!k&&!p&&(0,r.jsxs)(m.ss,{onClick:()=>en("role"),className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50 w-1/6",children:["Role",ea("role")]}),!k&&!p&&!b&&(0,r.jsxs)(m.ss,{onClick:()=>en("userType"),className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50 w-1/6",children:["Type",ea("userType")]}),(0,r.jsxs)(m.ss,{onClick:()=>en("created_at"),className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50 w-1/6",children:["Joined",ea("created_at")]}),(0,r.jsxs)(m.ss,{onClick:()=>en("gpuCount"),className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50 w-1/6",children:["GPUs",ea("gpuCount")]}),(0,r.jsxs)(m.ss,{onClick:()=>en("clusterCount"),className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50 w-1/6",children:["Clusters",ea("clusterCount")]}),(0,r.jsxs)(m.ss,{onClick:()=>en("jobCount"),className:"sortable whitespace-nowrap cursor-pointer hover:bg-gray-50 w-1/6",children:["Jobs",ea("jobCount")]}),!k&&(h||"admin"===v)&&(0,r.jsx)(m.ss,{className:"whitespace-nowrap w-1/7",children:"Actions"})]})}),(0,r.jsx)(m.RM,{children:er.map(e=>{let t="system"===e.userType,s="basic"===e.userType,n=s&&("admin"===v||e.userId===w);return(0,r.jsxs)(m.SC,{children:[(0,r.jsx)(m.pj,{className:"truncate",title:e.username,children:e.usernameDisplay}),!k&&(0,r.jsx)(m.pj,{className:"truncate",title:e.fullEmailID,children:e.fullEmailID}),!k&&!p&&(0,r.jsx)(m.pj,{className:"truncate",title:e.role,children:(0,r.jsx)("div",{className:"flex items-center gap-2",children:$===e.userId?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("select",{value:W,onChange:e=>X(e.target.value),className:"block w-auto p-1 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-sky-blue focus:border-sky-blue sm:text-sm",children:[(0,r.jsx)("option",{value:"admin",children:"Admin"}),(0,r.jsx)("option",{value:"user",children:"User"})]}),(0,r.jsx)("button",{onClick:()=>ei(e.userId),className:"text-green-600 hover:text-green-800 p-1",title:"Save",children:(0,r.jsx)(E.Z,{className:"h-4 w-4"})}),(0,r.jsx)("button",{onClick:eo,className:"text-gray-500 hover:text-gray-700 p-1",title:"Cancel",children:(0,r.jsx)(R.Z,{className:"h-4 w-4"})})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"capitalize",children:e.role}),"admin"===v&&(0,r.jsx)("button",{onClick:t?void 0:()=>el(e.userId,e.role),className:t?"text-gray-300 cursor-not-allowed p-1":"text-blue-600 hover:text-blue-700 p-1",title:t?"Cannot edit role for system users":"Edit role",disabled:t,children:(0,r.jsx)(D,{className:"h-3 w-3"})})]})})}),!k&&!p&&!b&&(0,r.jsx)(m.pj,{className:"truncate",title:e.userType,children:(0,r.jsx)("span",{className:"capitalize",children:"sso"===e.userType?"SSO":e.userType})}),(0,r.jsx)(m.pj,{className:"truncate",children:e.created_at?(0,r.jsx)(y.Zg,{date:new Date(1e3*e.created_at)}):"-"}),(0,r.jsx)(m.pj,{children:-1===e.gpuCount?(0,r.jsx)("span",{className:"px-2 py-0.5 bg-gray-100 text-gray-500 rounded text-xs font-medium",children:(0,r.jsx)(o.Z,{size:12})}):(0,r.jsx)("span",{className:"px-2 py-0.5 rounded text-xs font-medium ".concat(e.gpuCount>0?"bg-purple-100 text-purple-600":"bg-gray-100 text-gray-500"),title:"Total GPUs: ".concat(e.gpuCount),children:e.gpuCount})}),(0,r.jsx)(m.pj,{children:-1===e.clusterCount?(0,r.jsx)("span",{className:"px-2 py-0.5 bg-gray-100 text-gray-500 rounded text-xs font-medium",children:(0,r.jsx)(o.Z,{size:12})}):(0,r.jsx)(c(),{href:"/clusters?property=user&operator=%3A&value=".concat(encodeURIComponent(e.username)),className:"px-2 py-0.5 rounded text-xs font-medium transition-colors duration-200 cursor-pointer inline-block ".concat(e.clusterCount>0?"bg-blue-100 text-blue-600 hover:bg-blue-200 hover:text-blue-700":"bg-gray-100 text-gray-500 hover:bg-gray-200 hover:text-gray-700"),title:"View ".concat(e.clusterCount," cluster").concat(1!==e.clusterCount?"s":""," for ").concat(e.usernameDisplay),children:e.clusterCount})}),(0,r.jsx)(m.pj,{children:-1===e.jobCount?(0,r.jsx)("span",{className:"px-2 py-0.5 bg-gray-100 text-gray-500 rounded text-xs font-medium",children:(0,r.jsx)(o.Z,{size:12})}):(0,r.jsx)(c(),{href:"/jobs?property=user&operator=%3A&value=".concat(encodeURIComponent(e.username)),className:"px-2 py-0.5 rounded text-xs font-medium transition-colors duration-200 cursor-pointer inline-block ".concat(e.jobCount>0?"bg-green-100 text-green-600 hover:bg-green-200 hover:text-green-700":"bg-gray-100 text-gray-500 hover:bg-gray-200 hover:text-gray-700"),title:"View ".concat(e.jobCount," active job").concat(1!==e.jobCount?"s":""," for ").concat(e.usernameDisplay),children:e.jobCount})}),!k&&(h||"admin"===v)&&(0,r.jsx)(m.pj,{className:"relative",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[h&&(0,r.jsx)("button",{onClick:n?async()=>{u(e)}:void 0,className:n?"text-blue-600 hover:text-blue-700 p-1":"text-gray-300 cursor-not-allowed p-1",title:s?n?"Reset Password":"You can only reset your own password":"Password reset only available for basic auth users",disabled:!n,children:(0,r.jsx)(T,{className:"h-4 w-4"})}),"admin"===v&&(0,r.jsx)("button",{onClick:t?void 0:()=>d(e),className:t?"text-gray-300 cursor-not-allowed p-1":"text-red-600 hover:text-red-700 p-1",title:t?"Cannot delete system users":"Delete User",disabled:t,children:(0,r.jsx)(I.Z,{className:"h-4 w-4"})})]})})]},e.userId)})})]})})}):(0,r.jsxs)("div",{className:"text-center py-12",children:[(0,r.jsx)("p",{className:"text-lg font-semibold text-gray-500",children:N.length>0?"No users match your filters.":"No users found."}),(0,r.jsx)("p",{className:"text-sm text-gray-400 mt-1",children:N.length>0?"Try adjusting your filter criteria.":"There are currently no users to display."})]}):(0,r.jsxs)("div",{className:"flex justify-center items-center h-64",children:[(0,r.jsx)(o.Z,{}),(0,r.jsx)("span",{className:"ml-2 text-gray-500",children:"Loading users..."})]})}function Q(e){var t;let{checkPermissionAndAct:s,userRoleCache:a,setCreateSuccess:l,setCreateError:i,showCreateDialog:u,setShowCreateDialog:d,showRotateDialog:h,setShowRotateDialog:p,tokenToRotate:g,setTokenToRotate:b,rotating:j,setRotating:v,searchQuery:w,setSearchQuery:C}=e,[k,_]=(0,n.useState)([]),[S,Z]=(0,n.useState)(!0),[P,M]=(0,n.useState)(!1),[O,z]=(0,n.useState)(null),[V,G]=(0,n.useState)(null),[J,$]=(0,n.useState)({token_name:"",expires_in_days:30}),[H,W]=(0,n.useState)(""),[X,Q]=(0,n.useState)(!1),[Y,ee]=(0,n.useState)(!1),[et,es]=(0,n.useState)(""),[er,en]=(0,n.useState)(null),[ea,el]=(0,n.useState)(null),[eo,ei]=(0,n.useState)(null),[ec,eu]=(0,n.useState)(""),[ed,em]=(0,n.useState)([]),ex=async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];try{Z(!0),e&&f.ZP.invalidate(x.i);let t=await f.ZP.get(x.i);_(t||[]);let{clustersData:s,jobsResponse:r}=await K(),n=(null==r?void 0:r.jobs)||[],a=(t||[]).map(e=>{let t=e.service_account_user_id,r=0,a=0,l=0,o=0;for(let e of s)e.user_hash===t&&(r++,"STOPPED"!==e.status&&"TERMINATED"!==e.status&&(a+=B(e.gpus,"Cluster ".concat(e.cluster))));for(let e of n)e.user_hash===t&&q.has(e.status)&&(l++,o+=B(e.accelerators,"Job ".concat(e.job_name||e.job_id)));return{...e,clusterCount:r,jobCount:l,gpuCount:a+o,primaryRole:e.service_account_roles&&e.service_account_roles.length>0?e.service_account_roles[0]:"user"}});em(a)}catch(e){console.error("Error fetching tokens and counts:",e),_([]),em([])}finally{Z(!1)}};(0,n.useEffect)(()=>{ex()},[]);let eh=async(e,t)=>{await s("cannot edit service account role",()=>{ei(e),eu(t)})},ep=()=>{ei(null),eu("")},ef=async e=>{if(!e||!ec){console.error("Token ID or role is missing."),i(Error("Token ID or role is missing."));return}Z(!0);try{let t=await A.x.post("/users/service-account-tokens/update-role",{token_id:e,role:ec});if(!t.ok){let e=await t.json();throw Error(e.detail||"Failed to update role")}l("Service account role updated successfully!"),await ex(!0),ep()}catch(e){console.error("Failed to update service account role:",e),i(e)}finally{Z(!1)}},eg=async e=>{try{await navigator.clipboard.writeText(e),es("Copied!"),setTimeout(()=>es(""),2e3)}catch(e){console.error("Failed to copy:",e)}},eb=async()=>{if(!J.token_name.trim()){i(Error("Token name is required"));return}Q(!0);try{let e={token_name:J.token_name.trim(),expires_in_days:""===J.expires_in_days?null:J.expires_in_days},t=await A.x.post("/users/service-account-tokens",e);if(t.ok){let e=await t.json();en(e.token),$({token_name:"",expires_in_days:30}),await ex(!0)}else{let e=await t.json();throw Error(e.detail||"Failed to create token")}}catch(e){i(e)}finally{Q(!1)}},ej=async()=>{if(O){ee(!0),G(null);try{let e=await A.x.post("/users/service-account-tokens/delete",{token_id:O.token_id});if(e.ok)l('Service account "'.concat(O.token_name,'" deleted successfully!')),M(!1),z(null),G(null),await ex(!0);else{let t=await e.json();throw Error(t.detail||"Failed to delete service account")}}catch(e){M(!1),z(null),G(null),i(e)}finally{ee(!1)}}},ey=async()=>{if(g){v(!0);try{let e={token_id:g.token_id,expires_in_days:""===H?null:parseInt(H)},t=await A.x.post("/users/service-account-tokens/rotate",e);if(t.ok){let e=await t.json();el(e.token),await ex(!0)}else{let e=await t.json();throw Error(e.detail||"Failed to rotate token")}}catch(e){i(e)}finally{v(!1)}}},ev=ed.filter(e=>{var t,s,r,n;if(!(null==w?void 0:w.trim()))return!0;let a=w.toLowerCase();return(null===(t=e.token_name)||void 0===t?void 0:t.toLowerCase().includes(a))||(null===(s=e.creator_name)||void 0===s?void 0:s.toLowerCase().includes(a))||(null===(r=e.service_account_name)||void 0===r?void 0:r.toLowerCase().includes(a))||(null===(n=e.primaryRole)||void 0===n?void 0:n.toLowerCase().includes(a))});return S&&0===ed.length?(0,r.jsxs)("div",{className:"flex items-center justify-center py-8",children:[(0,r.jsx)(o.Z,{size:32}),(0,r.jsx)("span",{className:"ml-3",children:"Loading tokens..."})]}):(0,r.jsxs)(r.Fragment,{children:[0===ev.length?(0,r.jsxs)("div",{className:"text-center py-12",children:[(0,r.jsx)(T,{className:"mx-auto h-12 w-12 text-gray-400"}),(0,r.jsx)("h3",{className:"mt-2 text-sm font-medium text-gray-900",children:(null==w?void 0:w.trim())?"No tokens match your search":"No service accounts"}),(0,r.jsx)("p",{className:"mt-1 text-sm text-gray-500",children:(null==w?void 0:w.trim())?"Try adjusting your search terms.":"No service accounts have been created yet."})]}):(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(U.Zb,{children:(0,r.jsxs)(m.iA,{children:[(0,r.jsx)(m.xD,{children:(0,r.jsxs)(m.SC,{children:[(0,r.jsx)(m.ss,{children:"Name"}),(0,r.jsx)(m.ss,{children:"Created by"}),(0,r.jsx)(m.ss,{children:"Role"}),(0,r.jsx)(m.ss,{children:"Clusters"}),(0,r.jsx)(m.ss,{children:"Jobs"}),(0,r.jsx)(m.ss,{children:"GPUs"}),(0,r.jsx)(m.ss,{children:"Created"}),(0,r.jsx)(m.ss,{children:"Last used"}),(0,r.jsx)(m.ss,{children:"Expires"}),(0,r.jsx)(m.ss,{children:"Actions"})]})}),(0,r.jsx)(m.RM,{children:ev.map(e=>(0,r.jsxs)(m.SC,{children:[(0,r.jsx)(m.pj,{className:"truncate",title:e.token_name,children:e.token_name}),(0,r.jsx)(m.pj,{className:"truncate",children:(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)("span",{children:e.creator_name||"Unknown"}),e.creator_user_hash!==(null==a?void 0:a.id)&&(0,r.jsx)("span",{className:"ml-2 px-1.5 py-0.5 text-xs bg-gray-100 text-gray-600 rounded",children:"Other"})]})}),(0,r.jsx)(m.pj,{className:"truncate",children:(0,r.jsx)("div",{className:"flex items-center gap-2",children:eo===e.token_id?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("select",{value:ec,onChange:e=>eu(e.target.value),className:"block w-auto p-1 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-sky-blue focus:border-sky-blue sm:text-sm",children:[(0,r.jsx)("option",{value:"admin",children:"Admin"}),(0,r.jsx)("option",{value:"user",children:"User"})]}),(0,r.jsx)("button",{onClick:()=>ef(e.token_id),className:"text-green-600 hover:text-green-800 p-1",title:"Save",children:(0,r.jsx)(E.Z,{className:"h-4 w-4"})}),(0,r.jsx)("button",{onClick:ep,className:"text-gray-500 hover:text-gray-700 p-1",title:"Cancel",children:(0,r.jsx)(R.Z,{className:"h-4 w-4"})})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"capitalize",children:e.primaryRole}),((null==a?void 0:a.role)==="admin"||e.creator_user_hash===(null==a?void 0:a.id))&&(0,r.jsx)("button",{onClick:()=>eh(e.token_id,e.primaryRole),className:"text-blue-600 hover:text-blue-700 p-1",title:"Edit role",children:(0,r.jsx)(D,{className:"h-3 w-3"})})]})})}),(0,r.jsx)(m.pj,{children:(0,r.jsx)(c(),{href:"/clusters?property=user&operator=%3A&value=".concat(encodeURIComponent(e.service_account_name)),className:"px-2 py-0.5 rounded text-xs font-medium transition-colors duration-200 cursor-pointer inline-block ".concat(e.clusterCount>0?"bg-blue-100 text-blue-600 hover:bg-blue-200 hover:text-blue-700":"bg-gray-100 text-gray-500 hover:bg-gray-200 hover:text-gray-700"),title:"View ".concat(e.clusterCount," cluster").concat(1!==e.clusterCount?"s":""," for ").concat(e.token_name),children:e.clusterCount})}),(0,r.jsx)(m.pj,{children:(0,r.jsx)(c(),{href:"/jobs?property=user&operator=%3A&value=".concat(encodeURIComponent(e.service_account_name)),className:"px-2 py-0.5 rounded text-xs font-medium transition-colors duration-200 cursor-pointer inline-block ".concat(e.jobCount>0?"bg-green-100 text-green-600 hover:bg-green-200 hover:text-green-700":"bg-gray-100 text-gray-500 hover:bg-gray-200 hover:text-gray-700"),title:"View ".concat(e.jobCount," active job").concat(1!==e.jobCount?"s":""," for ").concat(e.token_name),children:e.jobCount})}),(0,r.jsx)(m.pj,{children:(0,r.jsx)("span",{className:"px-2 py-0.5 rounded text-xs font-medium ".concat(e.gpuCount>0?"bg-purple-100 text-purple-600":"bg-gray-100 text-gray-500"),title:"Total GPUs: ".concat(e.gpuCount),children:e.gpuCount})}),(0,r.jsx)(m.pj,{className:"truncate",children:e.created_at?(0,r.jsx)(y.Zg,{date:new Date(1e3*e.created_at)}):"Never"}),(0,r.jsx)(m.pj,{className:"truncate",children:e.last_used_at?(0,r.jsx)(y.Zg,{date:new Date(1e3*e.last_used_at)}):"Never"}),(0,r.jsx)(m.pj,{className:"truncate",children:e.expires_at?new Date(1e3*e.expires_at)<new Date?(0,r.jsx)("span",{className:"text-red-600",children:"Expired"}):(0,r.jsx)(y.Zg,{date:new Date(1e3*e.expires_at)}):"Never"}),(0,r.jsx)(m.pj,{children:(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[((null==a?void 0:a.role)==="admin"||e.creator_user_hash===(null==a?void 0:a.id))&&(0,r.jsx)(y.WH,{content:"Rotate token",className:"capitalize text-sm text-muted-foreground",children:(0,r.jsx)("button",{onClick:()=>{s("cannot rotate service account tokens",()=>{b(e),p(!0)})},className:"text-sky-blue hover:text-sky-blue-bright font-medium inline-flex items-center",children:(0,r.jsx)(N.Z,{className:"h-4 w-4"})})}),((null==a?void 0:a.role)==="admin"||e.creator_user_hash===(null==a?void 0:a.id))&&(0,r.jsx)(y.WH,{content:"Delete ".concat(e.token_name),className:"capitalize text-sm text-muted-foreground",children:(0,r.jsx)("button",{onClick:()=>{s("cannot delete service account tokens",()=>{z(e),M(!0)})},className:"text-red-600 hover:text-red-800 font-medium inline-flex items-center",children:(0,r.jsx)(I.Z,{className:"h-4 w-4"})})})]})})]},e.token_id))})]})})}),(0,r.jsx)(F.Vq,{open:u,onOpenChange:e=>{d(e),e||(en(null),i(null))},children:(0,r.jsxs)(F.cZ,{className:"sm:max-w-2xl",children:[(0,r.jsxs)(F.fK,{children:[(0,r.jsx)(F.$N,{children:"Create Service Account"}),(0,r.jsx)(F.Be,{children:"Create a new service account with an API token for programmatic access to SkyPilot."})]}),(0,r.jsx)("div",{className:"flex flex-col gap-4 py-4",children:er?(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"p-4 bg-green-50 border border-green-200 rounded-lg",children:[(0,r.jsxs)("div",{className:"flex items-center mb-3",children:[(0,r.jsx)("h4",{className:"text-sm font-medium text-green-900",children:"⚠️ Service account created successfully - save this token now!"}),(0,r.jsx)(y.WH,{content:et?"Copied!":"Copy token",className:"text-muted-foreground",children:(0,r.jsx)("button",{onClick:()=>eg(er),className:"flex items-center text-green-600 hover:text-green-800 transition-colors duration-200 p-1 ml-2",children:et?(0,r.jsx)(E.Z,{className:"w-4 h-4"}):(0,r.jsx)(L.Z,{className:"w-4 h-4"})})})]}),(0,r.jsx)("p",{className:"text-sm text-green-700 mb-3",children:"This service account token will not be shown again. Please copy and store it securely."}),(0,r.jsx)("div",{className:"bg-white border border-green-300 rounded-md p-3",children:(0,r.jsx)("code",{className:"text-sm text-gray-800 font-mono break-all block",children:er})})]})}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"Service Account Name"}),(0,r.jsx)("input",{className:"border rounded px-3 py-2 w-full",placeholder:"e.g., ci-pipeline, monitoring-system",value:J.token_name,onChange:e=>$({...J,token_name:e.target.value})})]}),(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"Expiration (days)"}),(0,r.jsx)("input",{type:"number",className:"border rounded px-3 py-2 w-full",placeholder:"e.g., 30",min:"0",max:"365",value:null!==(t=J.expires_in_days)&&void 0!==t?t:"",onChange:e=>$({...J,expires_in_days:e.target.value?parseInt(e.target.value):null})}),(0,r.jsx)("p",{className:"text-xs text-gray-500",children:"Leave empty or enter 0 to never expire. Maximum 365 days."})]})]})}),(0,r.jsx)(F.cN,{children:er?(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-sky-600 text-white hover:bg-sky-700 h-10 px-4 py-2",onClick:()=>{d(!1),en(null)},children:"Close"}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-10 px-4 py-2",onClick:()=>{d(!1),en(null)},disabled:X,children:"Cancel"}),(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-sky-600 text-white hover:bg-sky-700 h-10 px-4 py-2",onClick:eb,disabled:X||!J.token_name.trim(),children:X?"Creating...":"Create Token"})]})})]})}),(0,r.jsx)(F.Vq,{open:P,onOpenChange:e=>{M(e),e||(z(null),i(null))},children:(0,r.jsxs)(F.cZ,{className:"sm:max-w-md",children:[(0,r.jsxs)(F.fK,{children:[(0,r.jsx)(F.$N,{children:"Delete Service Account Token"}),(0,r.jsxs)(F.Be,{children:['Are you sure you want to delete the service account "',null==O?void 0:O.token_name,'"',(null==O?void 0:O.creator_user_hash)!==(null==a?void 0:a.id)&&(null==a?void 0:a.role)==="admin"?" owned by ".concat(null==O?void 0:O.creator_name):"","? This action cannot be undone and will immediately revoke access for any systems using this token."]})]}),(0,r.jsxs)(F.cN,{children:[(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-10 px-4 py-2",onClick:()=>{M(!1),z(null)},disabled:Y,children:"Cancel"}),(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-red-600 text-white hover:bg-red-700 h-10 px-4 py-2",onClick:ej,disabled:Y,children:Y?"Deleting...":"Delete Token"})]})]})}),(0,r.jsx)(F.Vq,{open:h,onOpenChange:e=>{p(e),e||(b(null),W(""),el(null),i(null))},children:(0,r.jsxs)(F.cZ,{className:"sm:max-w-2xl",children:[(0,r.jsxs)(F.fK,{children:[(0,r.jsx)(F.$N,{children:"Rotate Service Account Token"}),(0,r.jsxs)(F.Be,{children:['Rotate the service account token "',null==g?void 0:g.token_name,'"',(null==g?void 0:g.creator_user_hash)!==(null==a?void 0:a.id)&&(null==a?void 0:a.role)==="admin"?" owned by ".concat(null==g?void 0:g.creator_name):"",". This will generate a new token value and invalidate the current one."]})]}),(0,r.jsx)("div",{className:"flex flex-col gap-4 py-4",children:ea?(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"p-4 bg-green-50 border border-green-200 rounded-lg",children:[(0,r.jsxs)("div",{className:"flex items-center mb-3",children:[(0,r.jsx)("h4",{className:"text-sm font-medium text-green-900",children:"\uD83D\uDD04 Service account token rotated successfully - save this new token now!"}),(0,r.jsx)(y.WH,{content:et?"Copied!":"Copy token",className:"text-muted-foreground",children:(0,r.jsx)("button",{onClick:()=>eg(ea),className:"flex items-center text-green-600 hover:text-green-800 transition-colors duration-200 p-1 ml-2",children:et?(0,r.jsx)(E.Z,{className:"w-4 h-4"}):(0,r.jsx)(L.Z,{className:"w-4 h-4"})})})]}),(0,r.jsx)("p",{className:"text-sm text-green-700 mb-3",children:"This new token replaces the old one. Please copy and store it securely. The old token is now invalid."}),(0,r.jsx)("div",{className:"bg-white border border-green-300 rounded-md p-3",children:(0,r.jsx)("code",{className:"text-sm text-gray-800 font-mono break-all block",children:ea})})]})}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium text-gray-700",children:"New Expiration (days)"}),(0,r.jsx)("input",{type:"number",className:"border rounded px-3 py-2 w-full",placeholder:"Leave empty to preserve current expiration",min:"0",max:"365",value:H,onChange:e=>W(e.target.value)}),(0,r.jsx)("p",{className:"text-xs text-gray-500",children:"Leave empty to preserve current expiration. Enter number of days for new expiration, or enter 0 to set to never expire. Maximum 365 days."})]}),(0,r.jsx)("div",{className:"p-3 bg-amber-50 border border-amber-200 rounded",children:(0,r.jsx)("p",{className:"text-sm text-amber-700",children:"⚠️ Any systems using the current token will need to be updated with the new token."})})]})}),(0,r.jsx)(F.cN,{children:ea?(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-green-600 text-white hover:bg-green-700 h-10 px-4 py-2",onClick:()=>{p(!1),b(null),W(""),el(null)},children:"Close"}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-10 px-4 py-2",onClick:()=>{p(!1),b(null),W(""),el(null)},disabled:j,children:"Cancel"}),(0,r.jsx)("button",{className:"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-sky-600 text-white hover:bg-sky-700 h-10 px-4 py-2",onClick:ey,disabled:j,children:j?"Rotating...":"Rotate Token"})]})})]})})]})}X.propTypes={refreshInterval:l().number.isRequired,setLoading:l().func.isRequired,refreshDataRef:l().shape({current:l().func}).isRequired,checkPermissionAndAct:l().func.isRequired,roleLoading:l().bool.isRequired,onResetPassword:l().func.isRequired,onDeleteUser:l().func.isRequired,basicAuthEnabled:l().bool,ingressBasicAuthEnabled:l().bool,externalProxyAuthEnabled:l().bool,currentUserRole:l().string,currentUserId:l().string,setLastFetchedTime:l().func}}}]);