libre-webui 0.46.0 → 0.46.1

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.
Files changed (68) hide show
  1. package/backend/package.json +1 -1
  2. package/frontend/dist/artifact-runtime/.build-fingerprint +1 -1
  3. package/frontend/dist/assets/index-CoUBuPQV.js +22 -0
  4. package/frontend/dist/index.html +20 -20
  5. package/frontend/dist/js/{ArtifactContainer-BaacvZ8q.js → ArtifactContainer-BJcZu1hG.js} +1 -1
  6. package/frontend/dist/js/{ArtifactDemoPage-D6pgt8_p.js → ArtifactDemoPage-CEDmVq5I.js} +1 -1
  7. package/frontend/dist/js/{ArtifactSandboxFrame-BqfRwsQa.js → ArtifactSandboxFrame-iQ9iHO6_.js} +1 -1
  8. package/frontend/dist/js/{ArtifactSlideOutPanel-BUFb1QaC.js → ArtifactSlideOutPanel-DbfUsCO5.js} +1 -1
  9. package/frontend/dist/js/{AutomationModal-a9rx93qd.js → AutomationModal-B7im0l4E.js} +1 -1
  10. package/frontend/dist/js/{AutomationsPage-Bhzy71Cq.js → AutomationsPage-Dr-r5D8f.js} +1 -1
  11. package/frontend/dist/js/{AvatarUpload-BHHUA-GH.js → AvatarUpload-C3Qy8TkH.js} +1 -1
  12. package/frontend/dist/js/{CalendarPage-DIlOEXA9.js → CalendarPage-B-wEyqL9.js} +1 -1
  13. package/frontend/dist/js/{ChannelsPage-BRVs-Kp-.js → ChannelsPage-D3zDMyuU.js} +1 -1
  14. package/frontend/dist/js/{ChatPage-DqEa_l2u.js → ChatPage-WCWH7j7x.js} +1 -1
  15. package/frontend/dist/js/{ConnectModels-dimFaMkn.js → ConnectModels-BGp65ytJ.js} +1 -1
  16. package/frontend/dist/js/{EvaluationsPage-BKVxoUaS.js → EvaluationsPage-BruiPXWA.js} +1 -1
  17. package/frontend/dist/js/{FirstTimeSetup-MLU3EUOv.js → FirstTimeSetup-pQ-MjnV4.js} +1 -1
  18. package/frontend/dist/js/{GalleryPage-BqhTNi2p.js → GalleryPage-BIplR7z2.js} +1 -1
  19. package/frontend/dist/js/{HomePage-B_HbAwgO.js → HomePage-DTtLoltD.js} +1 -1
  20. package/frontend/dist/js/{LanguageSwitcher-gij6QsCJ.js → LanguageSwitcher-BkXPcNb2.js} +1 -1
  21. package/frontend/dist/js/{ModelManagerModals-CfcrXIm5.js → ModelManagerModals-DsatvqGr.js} +1 -1
  22. package/frontend/dist/js/{NotesPage-6qb7awMu.js → NotesPage-CMRTIRbO.js} +1 -1
  23. package/frontend/dist/js/{PasswordStrengthMeter-MkydwQ8j.js → PasswordStrengthMeter-arTXSwnR.js} +1 -1
  24. package/frontend/dist/js/{PersonasPage-KRnYk61s.js → PersonasPage-DJy7cCqu.js} +1 -1
  25. package/frontend/dist/js/{PluginUsagePage-Bm2WXYM5.js → PluginUsagePage-DdX4daCa.js} +1 -1
  26. package/frontend/dist/js/{RichMessageContent-fyjhRYjT.js → RichMessageContent-BPUCydw1.js} +1 -1
  27. package/frontend/dist/js/{RichMessageContent-C5hmCcK6.js → RichMessageContent-cM5Pw4o8.js} +1 -1
  28. package/frontend/dist/js/{SettingsModal-CgtaiEwd.js → SettingsModal-Cx8tQ7zn.js} +3 -3
  29. package/frontend/dist/js/{ShareDialog-lkQnQmeI.js → ShareDialog-yVjcJ0jy.js} +1 -1
  30. package/frontend/dist/js/{StrandsPage-sPvcnqzA.js → StrandsPage-C_waoiMS.js} +1 -1
  31. package/frontend/dist/js/{SystemPage-DwL4p4Rm.js → SystemPage-DaD_JM8S.js} +1 -1
  32. package/frontend/dist/js/{UserManagementPanel-Dz8Q_Nv7.js → UserManagementPanel-25s9fB6P.js} +1 -1
  33. package/frontend/dist/js/{WhatsNewModal-CSYCRxyb.js → WhatsNewModal-BZyBsxQZ.js} +1 -1
  34. package/frontend/dist/js/{WorkPage-zNqtL6D7.js → WorkPage-lCLLCn8L.js} +1 -1
  35. package/frontend/dist/js/api-BJuWvfL0.js +1 -0
  36. package/frontend/dist/js/{api-B8EjExUU.js → api-__EtZkwT.js} +1 -1
  37. package/frontend/dist/js/{appNavigation-C0lNX2LE.js → appNavigation-DtGGxIz_.js} +1 -1
  38. package/frontend/dist/js/{appStore-BEjqPvpR.js → appStore-xMQ42B4m.js} +2 -2
  39. package/frontend/dist/js/appVersion-Cx_TO0aQ.js +1 -0
  40. package/frontend/dist/js/ar-iaqJGlG8.js +2 -0
  41. package/frontend/dist/js/authStore-BAzfDKkW.js +1 -0
  42. package/frontend/dist/js/{authStore-BOFcWqii.js → authStore-VeRUWwzv.js} +3 -3
  43. package/frontend/dist/js/{chatStore-C3c3r8iB.js → chatStore-DM7NfNs8.js} +3 -3
  44. package/frontend/dist/js/{client-CQZUgw7R.js → client-DBMImFzz.js} +2 -2
  45. package/frontend/dist/js/{config-Dz__g4tp.js → config-CfmQhxhj.js} +1 -1
  46. package/frontend/dist/js/de-DrWNHRFs.js +2 -0
  47. package/frontend/dist/js/{decisionsApi-DWyjcL8B.js → decisionsApi-1EPksZmY.js} +1 -1
  48. package/frontend/dist/js/decisionsApi-C7Juo1Av.js +1 -0
  49. package/frontend/dist/js/{evaluationsApi-BE2P4V0I.js → evaluationsApi-BomOD9nq.js} +1 -1
  50. package/frontend/dist/js/{messageCodeStyles-QRyNUcEv.js → messageCodeStyles-C4KLlfl_.js} +1 -1
  51. package/frontend/dist/js/{modelPresentation-BqdYlMRq.js → modelPresentation-Jp0roUnl.js} +1 -1
  52. package/frontend/dist/js/{strandsApi-EFMF0J0x.js → strandsApi-oOCOwXJJ.js} +1 -1
  53. package/frontend/dist/js/{teamEventStream-aQGd68I4.js → teamEventStream-BGsxBKrP.js} +1 -1
  54. package/frontend/dist/js/{ui-CKcr9ReZ.js → ui-D5Ws30mx.js} +2 -2
  55. package/frontend/dist/js/{ui-vendor-BanHlKMb.js → ui-vendor-CmYUVVjB.js} +1 -1
  56. package/frontend/dist/js/{useChat-DFozXoci.js → useChat-B3oRF8Vk.js} +1 -1
  57. package/frontend/dist/js/{useDictation-D9lyoqUR.js → useDictation-DzQ0p1L7.js} +1 -1
  58. package/frontend/dist/js/{workApi-C2R6IiSd.js → workApi-B2IWKsfe.js} +1 -1
  59. package/frontend/dist/js/workApi-BVxaDn6b.js +1 -0
  60. package/package.json +1 -1
  61. package/frontend/dist/assets/index-CjeHi5JU.js +0 -76
  62. package/frontend/dist/js/api-CCDH67RO.js +0 -1
  63. package/frontend/dist/js/appVersion-Dv97-qD1.js +0 -1
  64. package/frontend/dist/js/ar-BM7CvBiJ.js +0 -2
  65. package/frontend/dist/js/authStore-BNu5iRKd.js +0 -1
  66. package/frontend/dist/js/de-DtSkfuOa.js +0 -2
  67. package/frontend/dist/js/decisionsApi-DJWWXd5m.js +0 -1
  68. package/frontend/dist/js/workApi-CNDPo0bG.js +0 -1
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,t as n}from"./react-vendor-C1iE8mnY.js";import{t as r}from"./useTranslation-Bu0AxynE.js";import{C as i,t as a}from"./useQuery-B-RslgPA.js";import{E as o,G as s,Hn as c,I as l,Nt as u,Or as d,Q as f,Qn as p,R as m,St as h,T as g,c as _,d as v,er as y,f as b,j as x,q as S,s as C,st as w,tt as ee,v as T,vt as E,yt as D}from"./ui-vendor-BanHlKMb.js";import{t as O}from"./authStore-BOFcWqii.js";import{C as k,I as A,P as j,R as M,d as N,s as P,w as F,y as I,z as L}from"./api-B8EjExUU.js";import{g as R,h as z,l as B,p as V}from"./ui-CKcr9ReZ.js";import{t as H}from"./PasswordStrengthMeter-MkydwQ8j.js";import{t as U}from"./Button-DeV-GhQr.js";import{t as W}from"./SettingsToggle-XpuugbHi.js";import{t as te}from"./chatStore-C3c3r8iB.js";import{t as G}from"./strandsApi-EFMF0J0x.js";import{c as K,t as ne}from"./appStore-BEjqPvpR.js";import{t as q}from"./utils-DhBboyBg.js";import{a as re}from"./logger-DAQsBb8I.js";import{n as J,t as ie}from"./client-CQZUgw7R.js";import{t as ae}from"./decisionsApi-DWyjcL8B.js";import{t as oe}from"./confirmStore-CKkUtP9c.js";import{t as Y}from"./workApi-C2R6IiSd.js";var X=e(t(),1),Z=n(),se=`h-11 w-full rounded-xl border border-line bg-surface-raised px-3 text-sm text-ink focus:outline-hidden focus:ring-2 focus:ring-primary-500 disabled:cursor-not-allowed disabled:opacity-60`;function ce(e,t){return e?.response?.data?.message||(e instanceof Error?e.message:t)||t}function le({user:e,currentUserId:t,onClose:n,onSaved:i}){let{t:a}=r(),[o,s]=(0,X.useState)({username:e?.username??``,email:e?.email??``,password:``,role:e?.role??`user`}),[c,l]=(0,X.useState)(!1),u=(0,X.useRef)(!1),[f,p]=(0,X.useState)(``),m=e?.id===t,h=()=>{u.current||n()};return(0,Z.jsx)(R,{titleId:`user-form-title`,title:a(e?`userManager.form.title.edit`:`userManager.form.title.create`),subtitle:e?(0,Z.jsx)(`span`,{className:`break-all`,children:e.username}):a(`userManager.subtitle`),onClose:h,testId:`user-form-dialog`,children:(0,Z.jsxs)(`form`,{onSubmit:async t=>{if(t.preventDefault(),u.current)return;u.current=!0,l(!0),p(``);let n=a(e?`userManager.form.updateFailed`:`userManager.form.createFailed`);try{let t={username:o.username.trim(),email:o.email.trim()||null,role:m?e.role:o.role};o.password&&(t.password=o.password);let r=e?await M.updateUser(e.id,t):await M.createUser({...o,username:o.username.trim(),email:o.email.trim()});if(!r.success||!r.data)throw Error(r.message||n);i(r.data),d.success(a(e?`userManager.form.updateSuccess`:`userManager.form.createSuccess`))}catch(e){p(ce(e,n))}finally{u.current=!1,l(!1)}},className:`space-y-5`,"aria-busy":c,children:[(0,Z.jsxs)(`fieldset`,{disabled:c,className:`min-w-0 space-y-4`,children:[(0,Z.jsx)(z,{id:`user-form-username`,label:a(`userManager.form.username`),autoFocus:!0,autoComplete:`off`,value:o.username,onChange:e=>s({...o,username:e.target.value}),required:!0}),(0,Z.jsx)(z,{id:`user-form-email`,label:`${a(`userManager.form.email`)}${e?` (${a(`common.optional`)})`:``}`,type:`email`,dir:`ltr`,autoComplete:`off`,value:o.email,onChange:e=>s({...o,email:e.target.value}),required:!e}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(z,{id:`user-form-password`,label:`${a(`userManager.form.password`)}${e?` (${a(`common.optional`)})`:``}`,type:`password`,autoComplete:`new-password`,value:o.password,onChange:e=>s({...o,password:e.target.value}),required:!e,helper:e?a(`userManager.form.passwordHint`):void 0}),(0,Z.jsx)(H,{password:o.password})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(B,{htmlFor:`user-form-role`,children:a(`userManager.form.role`)}),(0,Z.jsxs)(`select`,{id:`user-form-role`,value:o.role,onChange:e=>s({...o,role:e.target.value}),disabled:m,"aria-describedby":m?`user-form-role-hint`:void 0,className:se,children:[(0,Z.jsx)(`option`,{value:`user`,children:a(`userManager.roles.user`)}),(0,Z.jsx)(`option`,{value:`admin`,children:a(`userManager.roles.admin`)})]}),m&&(0,Z.jsx)(`p`,{id:`user-form-role-hint`,className:`text-xs text-ink-muted`,children:a(`userManager.directory.editSelfRole`)})]})]}),f&&(0,Z.jsx)(`p`,{role:`alert`,className:`text-sm text-error-600 dark:text-error-400`,children:f}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2 border-t border-line pt-4`,children:[(0,Z.jsx)(U,{type:`button`,variant:`outline`,onClick:h,disabled:c,className:`min-h-11`,children:a(`common.cancel`)}),(0,Z.jsx)(U,{type:`submit`,loading:c,disabled:!o.username.trim(),className:`min-h-11`,children:a(c?e?`userManager.form.updating`:`userManager.form.creating`:e?`userManager.form.updateButton`:`userManager.form.createButton`)})]})]})})}var ue=()=>{let{t:e,i18n:t}=r(),n=i(),o=O(e=>e.user),u=O(e=>e.setUser),[p,h]=(0,X.useState)(null),[g,v]=(0,X.useState)(``),[y,S]=(0,X.useState)(`all`),[w,E]=(0,X.useState)(null),[D,k]=(0,X.useState)(``),[A,j]=(0,X.useState)(null),N=(0,X.useRef)(!1),{data:P=[],isLoading:F,isError:I,isFetching:L,refetch:V}=a({queryKey:[`users`],queryFn:async()=>{let t=await M.getUsers();if(!t.success||!t.data)throw Error(e(`userManager.directory.loadFailed`));return t.data}}),H=()=>{n.invalidateQueries({queryKey:[`users`]})},W=e=>{n.setQueryData([`users`],(t=[])=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e]),e.id===o?.id&&u(e),h(null),H()},te=g.trim().toLocaleLowerCase(t.language),G=P.filter(e=>(y===`all`||e.role===y)&&`${e.username} ${e.email??``}`.toLocaleLowerCase(t.language).includes(te)),K=G.filter(e=>e.status===`pending`),ne=G.filter(e=>e.status!==`pending`),q=P.filter(e=>e.status===`pending`).length,re=P.length-q,J=!!(g||y!==`all`),ie=()=>{v(``),S(`all`)},ae=async t=>{if(!N.current){N.current=!0,j(t.id);try{let n=await M.approveUser(t.id);if(!n.success||!n.data)throw Error(n.message||e(`userManager.approval.failed`));W(n.data),d.success(e(`userManager.approval.approved`,{name:t.username}))}catch(t){d.error(ce(t,e(`userManager.approval.failed`)))}finally{N.current=!1,j(null)}}},oe=async()=>{if(!w||N.current||w.kind===`delete`&&w.user.id===o?.id)return;N.current=!0,j(w.user.id),k(``);let t=e(w.kind===`delete`?`userManager.deleteFailed`:`userManager.mfaResetFailed`);try{if(w.kind===`delete`){let r=await M.deleteUser(w.user.id);if(!r.success)throw Error(r.message||t);n.setQueryData([`users`],(e=[])=>e.filter(e=>e.id!==w.user.id)),H(),d.success(e(`userManager.deleteSuccess`))}else{let n=await M.resetUserMfa(w.user.id);if(!n.success)throw Error(n.message||t);d.success(e(n.data?.removed?`userManager.mfaResetSuccess`:`userManager.mfaResetNothing`,{name:w.user.username}))}E(null)}catch(e){k(ce(e,t))}finally{N.current=!1,j(null)}},Y=(e,t)=>{k(``),E({kind:e,user:t})},ue=n=>(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Z.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-surface-subtle text-ink-muted`,"aria-hidden":`true`,children:n.status===`pending`?(0,Z.jsx)(c,{size:18}):n.role===`admin`?(0,Z.jsx)(l,{size:18}):(0,Z.jsx)(_,{size:18})}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,Z.jsx)(`h3`,{className:`min-w-0 break-all text-sm font-medium text-ink`,children:(0,Z.jsx)(`bdi`,{children:n.username})}),n.id===o?.id&&(0,Z.jsxs)(`span`,{className:`text-xs text-ink-muted`,children:[`(`,e(`chatMessage.you`),`)`]}),(0,Z.jsx)(`span`,{className:`rounded-md border border-line px-1.5 py-0.5 text-xs text-ink-muted`,children:e(n.role===`admin`?`userManager.roles.admin`:`userManager.roles.user`)})]}),(0,Z.jsx)(`p`,{className:`mt-1 break-all text-sm text-ink-muted`,children:(0,Z.jsx)(`bdi`,{children:n.email||e(`userManager.noEmail`)})}),(0,Z.jsxs)(`p`,{className:`mt-1 text-xs text-ink-subtle`,children:[e(n.status===`pending`?`userManager.approval.registered`:`userManager.columns.created`),`: `,new Date(n.createdAt).toLocaleDateString(t.language)]})]})]}),de=e=>(0,Z.jsxs)(`div`,{className:`px-4 py-8 text-center`,children:[(0,Z.jsx)(C,{size:24,className:`mx-auto mb-3 text-ink-subtle`,"aria-hidden":`true`}),(0,Z.jsx)(`p`,{className:`text-sm text-ink-muted`,children:e})]});return(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-5`,"data-testid":`user-directory`,children:[(0,Z.jsxs)(`div`,{className:`rounded-2xl border border-line bg-surface p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`div`,{className:`relative min-w-0 basis-full sm:flex-1 sm:basis-48`,children:[(0,Z.jsx)(s,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute inset-s-3.5 top-3.5 text-ink-subtle`}),(0,Z.jsx)(z,{type:`search`,"aria-label":e(`userManager.search`),placeholder:e(`userManager.search`),value:g,onChange:e=>v(e.target.value),className:`ps-10`})]}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 sm:max-w-36`,children:[(0,Z.jsx)(B,{htmlFor:`user-role-filter`,className:`sr-only`,children:e(`userManager.columns.role`)}),(0,Z.jsxs)(`select`,{id:`user-role-filter`,value:y,onChange:e=>S(e.target.value),className:se,children:[(0,Z.jsx)(`option`,{value:`all`,children:e(`userManager.directory.allRoles`)}),(0,Z.jsx)(`option`,{value:`admin`,children:e(`userManager.roles.admin`)}),(0,Z.jsx)(`option`,{value:`user`,children:e(`userManager.roles.user`)})]})]}),(0,Z.jsx)(U,{type:`button`,variant:`outline`,onClick:()=>void V(),disabled:L,className:`min-h-11 min-w-11 px-3`,"aria-label":e(`common.refresh`),title:e(`common.refresh`),children:(0,Z.jsx)(f,{size:16,"aria-hidden":`true`,className:L?`animate-spin motion-reduce:animate-none`:void 0})}),(0,Z.jsxs)(U,{type:`button`,onClick:()=>h(`create`),disabled:!!A,className:`min-h-11`,children:[(0,Z.jsx)(ee,{size:16,"aria-hidden":`true`}),e(`userManager.createUser`)]})]}),(0,Z.jsxs)(`div`,{className:`mt-3 flex min-h-5 flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsx)(`p`,{role:`status`,className:`text-xs text-ink-muted`,children:F?e(`userManager.loading`):e(`userManager.directory.results`,{visible:G.length,total:P.length})}),J&&(0,Z.jsx)(U,{type:`button`,size:`sm`,variant:`ghost`,onClick:ie,className:`min-h-11 sm:min-h-8`,children:e(`userManager.directory.clearFilters`)})]})]}),I&&(0,Z.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center justify-between gap-3 rounded-xl border border-error-500/30 p-4`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-ink`,children:e(`userManager.directory.loadFailed`)}),(0,Z.jsx)(U,{type:`button`,variant:`outline`,onClick:()=>void V(),disabled:L,children:e(`common.retry`)})]}),!F&&(!I||P.length>0)&&(0,Z.jsxs)(Z.Fragment,{children:[q>0&&(0,Z.jsxs)(`section`,{"data-testid":`pending-user-approvals`,"aria-labelledby":`pending-users-title`,className:`overflow-hidden rounded-2xl border border-warning-500/30 bg-surface`,children:[(0,Z.jsxs)(`div`,{className:`border-b border-line bg-warning-500/6 p-4`,children:[(0,Z.jsxs)(`h3`,{id:`pending-users-title`,className:`flex items-center gap-2 text-sm font-semibold text-ink`,children:[(0,Z.jsx)(c,{size:16,"aria-hidden":`true`,className:`text-warning-700 dark:text-warning-400`}),e(`userManager.approval.title`),` `,(0,Z.jsxs)(`span`,{className:`text-ink-muted`,children:[`(`,q,`)`]})]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-ink-muted`,children:e(`userManager.approval.description`)})]}),(0,Z.jsxs)(`div`,{className:`divide-y divide-line`,children:[K.map(t=>(0,Z.jsxs)(`div`,{"data-testid":`pending-user-row`,className:`flex flex-col gap-3 p-4 xl:flex-row xl:items-center xl:justify-between`,children:[ue(t),(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[(0,Z.jsxs)(U,{type:`button`,size:`sm`,"data-testid":`approve-user-button`,onClick:()=>void ae(t),disabled:!!A,loading:A===t.id,className:`min-h-11 sm:min-h-9`,children:[(0,Z.jsx)(b,{size:16,"aria-hidden":`true`}),e(`userManager.approval.activate`)]}),(0,Z.jsx)(U,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>Y(`delete`,t),disabled:!!A,className:`min-h-11 sm:min-h-9`,children:e(`userManager.approval.reject`)})]})]},t.id)),K.length===0&&de(e(`userManager.noUsersMatching`))]})]}),(0,Z.jsxs)(`section`,{"aria-labelledby":`active-users-title`,className:`overflow-hidden rounded-2xl border border-line bg-surface`,children:[(0,Z.jsx)(`div`,{className:`border-b border-line px-4 py-3`,children:(0,Z.jsxs)(`h3`,{id:`active-users-title`,className:`text-sm font-semibold text-ink`,children:[e(`userManager.directory.title`),` `,(0,Z.jsxs)(`span`,{className:`text-ink-muted`,children:[`(`,re,`)`]})]})}),(0,Z.jsxs)(`div`,{className:`divide-y divide-line`,children:[ne.map(t=>(0,Z.jsxs)(`div`,{"data-testid":`user-row`,className:`flex flex-col gap-3 p-4 sm:flex-row sm:items-center sm:justify-between`,children:[ue(t),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,Z.jsxs)(U,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>h(t),disabled:!!A,"aria-label":`${e(`common.edit`)}: ${t.username}`,className:`min-h-11 sm:min-h-9`,children:[(0,Z.jsx)(x,{size:15,"aria-hidden":`true`}),e(`common.edit`)]}),(0,Z.jsx)(U,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`reset-mfa-button`,"aria-label":`${e(`userManager.mfaReset`)}: ${t.username}`,title:e(`userManager.mfaReset`),onClick:()=>Y(`reset`,t),disabled:!!A,className:`min-h-11 min-w-11 sm:min-h-9 sm:min-w-9 px-2`,children:(0,Z.jsx)(m,{size:16,"aria-hidden":`true`})}),(0,Z.jsx)(U,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":`${e(`common.delete`)}: ${t.username}`,title:t.id===o?.id?e(`userManager.cannotDeleteSelf`):e(`common.delete`),onClick:()=>Y(`delete`,t),disabled:t.id===o?.id||!!A,className:`min-h-11 min-w-11 sm:min-h-9 sm:min-w-9 px-2 text-error-600 dark:text-error-400`,children:(0,Z.jsx)(T,{size:16,"aria-hidden":`true`})})]})]},t.id)),ne.length===0&&de(e(J?`userManager.noUsersMatching`:`userManager.directory.empty`))]})]})]}),p&&(0,Z.jsx)(le,{user:p===`create`?null:p,currentUserId:o?.id,onClose:()=>h(null),onSaved:W},p===`create`?`create`:p.id),w&&(0,Z.jsxs)(R,{titleId:`user-action-title`,title:e(w.kind===`reset`?`userManager.mfaReset`:w.user.status===`pending`?`userManager.approval.reject`:`userManager.directory.deleteTitle`),onClose:()=>{N.current||E(null)},testId:`user-action-dialog`,children:[(0,Z.jsx)(`p`,{className:`wrap-break-word text-sm leading-relaxed text-ink-muted`,children:e(w.kind===`delete`?`userManager.deleteConfirm`:`userManager.mfaResetConfirm`,{name:w.user.username})}),D&&(0,Z.jsx)(`p`,{role:`alert`,className:`text-sm text-error-600 dark:text-error-400`,children:D}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2 border-t border-line pt-4`,children:[(0,Z.jsx)(U,{type:`button`,variant:`outline`,onClick:()=>E(null),disabled:!!A,className:`min-h-11`,children:e(`common.cancel`)}),(0,Z.jsx)(U,{type:`button`,variant:`danger`,loading:!!A,onClick:()=>void oe(),className:`min-h-11`,children:e(w.kind===`delete`?`common.delete`:`userManager.mfaReset`)})]})]})]})},de=()=>{let{t:e}=r(),t=(0,X.useId)(),n=O(e=>e.systemInfo),i=O(e=>e.setSystemInfo),a=te(e=>e.loadModels),[o,s]=(0,X.useState)(null),[c,l]=(0,X.useState)(!1),[u,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(!1),[h,g]=(0,X.useState)(0),_=`userManager.agentCliAccess`;return(0,X.useEffect)(()=>{let e=!1;return L.getAccess().then(t=>{e||(t.success&&t.data?(s(t.data.enabled),l(t.data.lockedByEnv)):m(!0))}).catch(()=>{e||m(!0)}),()=>{e=!0}},[h]),(0,Z.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,"data-testid":`agent-cli-access-settings`,children:(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{id:t,className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`${_}.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`${_}.description`)}),c&&(0,Z.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400 mt-1`,children:e(`${_}.lockedByEnv`)})]}),o===null&&p?(0,Z.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>{m(!1),g(e=>e+1)},children:e(`common.retry`)}):(0,Z.jsx)(W,{"aria-labelledby":t,checked:o===!0,onChange:async t=>{f(!0);try{let r=await L.setAccess(t);if(!r.success||!r.data)throw Error(r.error||`Agent access update failed.`);s(r.data.enabled),n&&i({...n,agentCliModelsEnabled:r.data.enabled}),await a({quiet:!0}),d.success(e(`userManager.agentCliAccess.saved`))}catch{d.error(e(`userManager.agentCliAccess.saveFailed`))}finally{f(!1)}},disabled:u||o===null||c})]})})},fe=[`disabled`,`admins`,`all-users`],pe=()=>{let{t:e}=r(),t=O(e=>e.systemInfo),n=O(e=>e.setSystemInfo),i=te(e=>e.loadModels),[a,o]=(0,X.useState)(null),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(!1),[f,p]=(0,X.useState)(!1),[m,h]=(0,X.useState)(0);(0,X.useEffect)(()=>{let e=!1;return G.getAccess().then(t=>{e||(t.success&&t.data?(o(t.data.mode),c(t.data.lockedByEnv)):p(!0))}).catch(()=>{e||p(!0)}),()=>{e=!0}},[m]);let g=async r=>{u(!0);try{let a=await G.setAccess(r);if(!a.success||!a.data)throw Error(a.error||`Strands access update failed.`);o(a.data.mode),t&&n({...t,strandsAccess:a.data.mode}),await i({quiet:!0}),d.success(e(`userManager.strandsAccess.saved`))}catch{d.error(e(`userManager.strandsAccess.saveFailed`))}finally{u(!1)}};return(0,Z.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,"data-testid":`strands-access-settings`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.strandsAccess.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.strandsAccess.description`)}),s&&(0,Z.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400 mt-1`,children:e(`userManager.strandsAccess.lockedByEnv`)})]}),a===null&&f?(0,Z.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>{p(!1),h(e=>e+1)},children:e(`common.retry`)}):(0,Z.jsx)(`div`,{className:`w-44`,children:(0,Z.jsx)(V,{"data-testid":`strands-access-mode`,"aria-label":e(`userManager.strandsAccess.title`),value:a??`disabled`,disabled:l||a===null||s,onChange:e=>void g(e.target.value),options:fe.map(t=>({value:t,label:e(`userManager.strandsAccess.modes.${t}`)}))})})]})})},me=[{mode:`light`,icon:o,key:`settings.appearance.theme.light`},{mode:`dark`,icon:E,key:`settings.appearance.theme.dark`},{mode:`amoled`,icon:D,key:`settings.appearance.theme.amoled`},{mode:`celestial`,icon:g,key:`settings.appearance.theme.celestial`}],he=()=>{let{t:e}=r(),t=O(e=>e.systemInfo),n=O(e=>e.setSystemInfo),i=ne(e=>e.applyInstanceTheme),[a,o]=(0,X.useState)(null),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(!1),[f,p]=(0,X.useState)(0);(0,X.useEffect)(()=>{let e=!1;return P.getDefaultTheme().then(t=>{e||(t.success&&t.data?o(K(t.data.theme)):u(!0))}).catch(()=>{e||u(!0)}),()=>{e=!0}},[f]);let m=async r=>{if(a&&a.mode!==r){c(!0);try{let s=await P.setDefaultTheme({...a,mode:r});if(!s.success||!s.data)throw Error(s.error||`Default theme update failed.`);let c=K(s.data.theme);o(c),t&&n({...t,defaultTheme:c}),i(c),d.success(e(`userManager.defaultTheme.saved`))}catch{d.error(e(`userManager.defaultTheme.saveFailed`))}finally{c(!1)}}};return(0,Z.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-[1_1_18rem]`,children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.defaultTheme.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.defaultTheme.description`)})]}),a===null&&l?(0,Z.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>{u(!1),p(e=>e+1)},children:e(`common.retry`)}):(0,Z.jsx)(`div`,{role:`radiogroup`,"aria-label":e(`userManager.defaultTheme.title`),className:`flex max-w-full flex-wrap gap-2`,children:me.map(({mode:t,icon:n,key:r})=>{let i=a?.mode===t;return(0,Z.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":i,disabled:s||a===null,onClick:()=>void m(t),className:q(`flex min-h-11 max-w-full items-center gap-2 rounded-lg border px-3 py-2 text-sm text-ink transition-colors focus:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-500/40 disabled:cursor-not-allowed disabled:opacity-60`,i?`border-line-strong bg-surface-subtle`:`border-line hover:bg-interactive-hover`),children:[(0,Z.jsx)(n,{className:`h-4 w-4`,"aria-hidden":`true`}),e(r)]},t)})})]})})},ge=()=>{let{t:e}=r(),t=(0,X.useId)(),[n,i]=(0,X.useState)(null),[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(!1),[f,p]=(0,X.useState)(0);return(0,X.useEffect)(()=>{let e=!1;return N.getAccessMode().then(t=>{e||(t.success&&t.data?(i(t.data.mode),o(t.data.lockedByEnv)):u(!0))}).catch(()=>{e||u(!0)}),()=>{e=!0}},[f]),(0,Z.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{id:t,className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.tools.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.tools.description`)}),a&&(0,Z.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400 mt-1`,children:e(`userManager.tools.lockedByEnv`)})]}),n===null&&l?(0,Z.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>{u(!1),p(e=>e+1)},children:e(`common.retry`)}):(0,Z.jsx)(W,{"aria-labelledby":t,checked:n===`all-users`,onChange:async t=>{let n=t?`all-users`:`admins`;c(!0);try{let t=await N.setAccessMode(n);if(!t.success)throw Error(t.error||`Tool access update failed.`);i(n),d.success(e(`userManager.tools.saved`))}catch{d.error(e(`userManager.tools.saveFailed`))}finally{c(!1)}},disabled:s||n===null||a})]})})},_e={stt:{mode:`all-users`,lockedByEnv:!1},tts:{mode:`all-users`,lockedByEnv:!1},"voice-mode":{mode:`all-users`,lockedByEnv:!1},"voice-cloning":{mode:`all-users`,lockedByEnv:!1}},ve={getModes:async()=>re()?J(_e):(await ie.get(`/voice-access`)).data,setMode:async(e,t)=>re()?J({feature:e,mode:t}):(await ie.put(`/voice-access/${encodeURIComponent(e)}`,{mode:t})).data},ye=[{key:`stt`,labelKey:`userManager.voice.features.stt`},{key:`tts`,labelKey:`userManager.voice.features.tts`},{key:`voice-mode`,labelKey:`userManager.voice.features.voiceMode`},{key:`voice-cloning`,labelKey:`userManager.voice.features.voiceCloning`}],be=()=>{let{t:e}=r(),t=(0,X.useId)(),[n,i]=(0,X.useState)(null),[a,o]=(0,X.useState)(null),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(0);(0,X.useEffect)(()=>{let e=!1;return ve.getModes().then(t=>{e||(t.success&&t.data?i(t.data):c(!0))}).catch(()=>{e||c(!0)}),()=>{e=!0}},[l]);let f=async(t,n)=>{let r=n?`all-users`:`admins`;o(t);try{let n=await ve.setMode(t,r);if(!n.success)throw Error(n.error||`Voice access update failed.`);i(e=>e&&{...e,[t]:{...e[t],mode:r}}),d.success(e(`userManager.voice.saved`))}catch{d.error(e(`userManager.voice.saveFailed`))}finally{o(null)}};return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.voice.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.voice.description`)})]}),n===null&&s&&(0,Z.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>{c(!1),u(e=>e+1)},children:e(`common.retry`)})]}),(0,Z.jsx)(`div`,{className:`mt-3 space-y-2`,children:ye.map(r=>{let i=n?.[r.key];return(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{id:`${t}-${r.key}`,className:`text-xs text-gray-700 dark:text-gray-300`,children:e(r.labelKey)}),i?.lockedByEnv&&(0,Z.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400`,children:e(`userManager.voice.lockedByEnv`)})]}),(0,Z.jsx)(W,{"aria-labelledby":`${t}-${r.key}`,checked:i?.mode===`all-users`,onChange:e=>f(r.key,e),disabled:i===void 0||a===r.key||i.lockedByEnv})]},r.key)})})]})},xe=()=>{let{t:e}=r(),t=(0,X.useId)(),[n,i]=(0,X.useState)(null),[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(0);(0,X.useEffect)(()=>{let e=!1;return ae.getAccess().then(t=>{e||(t.success&&t.data?i(t.data):c(!0))}).catch(()=>{e||c(!0)}),()=>{e=!0}},[l]);let f=async t=>{let n=t?`all-users`:`admins`;o(!0);try{if(!(await ae.setAccessMode(n)).success)throw Error(`Decision models access update failed.`);i(e=>e&&{...e,mode:n}),d.success(e(`userManager.decisionAccess.saved`))}catch{d.error(e(`userManager.decisionAccess.saveFailed`))}finally{o(!1)}};return(0,Z.jsx)(`div`,{"data-testid":`decision-access-settings`,className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{id:t,className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.decisionAccess.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.decisionAccess.description`)}),n?.lockedByEnv&&(0,Z.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400 mt-1`,children:e(`userManager.decisionAccess.lockedByEnv`)})]}),n===null&&s?(0,Z.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>{c(!1),u(e=>e+1)},children:e(`common.retry`)}):(0,Z.jsx)(W,{"aria-labelledby":t,checked:n?.mode===`all-users`,onChange:e=>void f(e),disabled:a||n===null||n.lockedByEnv})]})})},Se=[`starttls`,`tls`,`none`],Ce=e=>e.replace(/<head>/i,`<head><meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; img-src data:; base-uri 'none'; form-action 'none'"><style>img { display: none; }</style>`),we=e=>({host:e.host??``,port:e.port?String(e.port):``,security:e.security??`starttls`,username:e.username??``,password:``,from:e.from??``,appUrl:e.appUrl??``,rejectUnauthorized:e.rejectUnauthorized!==!1,emailTheme:e.emailTheme??`light`}),Te=()=>{let{t:e,i18n:t}=r(),n=(0,X.useId)(),i=(0,X.useId)(),[a,o]=(0,X.useState)(null),[s,c]=(0,X.useState)(null),[l,f]=(0,X.useState)(``),[p,m]=(0,X.useState)(!1),[h,g]=(0,X.useState)(!1),[_,v]=(0,X.useState)(!1),[y,b]=(0,X.useState)(!1),[x,S]=(0,X.useState)(0),[C,w]=(0,X.useState)(null),[ee,T]=(0,X.useState)(0),E=s?.emailTheme,D=E?`${E}:${ee}:${t.resolvedLanguage}`:null,O=C?.key===D?C:null,A=O?.html===null;(0,X.useEffect)(()=>{if(!E||!D)return;let t=!1;return k.preview({emailTheme:E,heading:e(`userManager.emailNotifications.previewHeading`),lines:[e(`userManager.emailNotifications.previewIntro`)],markdown:e(`userManager.emailNotifications.previewMarkdown`),linkLabel:e(`userManager.emailNotifications.previewLinkLabel`)}).then(e=>{t||(e.success&&e.data?w({key:D,html:e.data.html}):w({key:D,html:null}))}).catch(()=>{t||w({key:D,html:null})}),()=>{t=!0}},[E,D,e]),(0,X.useEffect)(()=>{let e=!1;return k.getSettings().then(t=>{e||(t.success&&t.data?(o(t.data),c(we(t.data)),f(t.data.recipient??``)):b(!0))}).catch(()=>{e||b(!0)}),()=>{e=!0}},[x]);let j=e=>{o(e),c(we(e)),v(!1)},M=(e,t)=>{let n=e.response?.data;return n?.error?n.error:n?.message?n.message:e instanceof Error&&e.message?e.message:t},N=async()=>{if(s){m(!0);try{let t=await k.updateSettings({host:s.host.trim(),port:s.port.trim(),security:s.security,username:s.username.trim(),from:s.from.trim(),appUrl:s.appUrl.trim(),rejectUnauthorized:s.rejectUnauthorized,emailTheme:s.emailTheme,...s.password?{password:s.password}:_?{password:``}:{}});if(!t.success||!t.data)throw Error(t.error||e(`userManager.emailNotifications.saveFailed`));j(t.data),d.success(e(`userManager.emailNotifications.saved`))}catch(t){d.error(M(t,e(`userManager.emailNotifications.saveFailed`)))}finally{m(!1)}}},P=async t=>{m(!0);try{let n=await k.updateSettings({enabled:t});if(!n.success||!n.data)throw Error(n.error||e(`userManager.emailNotifications.saveFailed`));j(n.data),d.success(e(t?`userManager.emailNotifications.enabledToast`:`userManager.emailNotifications.disabledToast`))}catch(t){d.error(M(t,e(`userManager.emailNotifications.saveFailed`)))}finally{m(!1)}},F=async()=>{g(!0);try{let t=await k.test(l.trim()||void 0);if(!t.success||!t.data?.ok)throw Error(t.error||e(`userManager.emailNotifications.testFailed`));d.success(t.data.sentTo?e(`userManager.emailNotifications.testSent`,{address:t.data.sentTo}):e(`userManager.emailNotifications.testConnected`))}catch(t){d.error(M(t,e(`userManager.emailNotifications.testFailed`)))}finally{g(!1)}},I=(e,t)=>c(n=>n&&{...n,[e]:t}),L=t=>a?.sources?.[t]===`env`?e(`userManager.emailNotifications.fromEnvironment`):null,R=a!==null&&s!==null&&(JSON.stringify(we(a))!==JSON.stringify({...s,password:``})||s.password.length>0||_),B=`mb-1 block text-sm font-medium text-gray-900 dark:text-gray-100`,H=`mb-2 block text-xs text-gray-500 dark:text-gray-400`;return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4 space-y-4`,"data-testid":`email-notification-settings`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`h3`,{id:n,className:`flex items-center gap-2 text-sm font-semibold text-gray-900 dark:text-gray-100`,children:[(0,Z.jsx)(u,{className:`h-4 w-4 text-primary-500`}),e(`userManager.emailNotifications.title`)]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-gray-400`,children:e(`userManager.emailNotifications.description`)})]}),(0,Z.jsx)(`div`,{"data-testid":`email-notifications-enabled`,children:(0,Z.jsx)(W,{"aria-labelledby":n,checked:a?.enabled===!0,onChange:e=>void P(e),disabled:p||a===null||!a.enabled&&!a.configured})})]}),y&&(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-800 dark:border-amber-900/60 dark:bg-amber-950/40 dark:text-amber-200`,children:[(0,Z.jsx)(`span`,{children:e(`userManager.emailNotifications.loadFailed`)}),(0,Z.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>{b(!1),S(e=>e+1)},children:e(`common.retry`)})]}),s&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[2fr_1fr]`,children:[(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsx)(`span`,{className:B,children:e(`userManager.emailNotifications.hostLabel`)}),(0,Z.jsx)(`span`,{className:H,children:L(`host`)??e(`userManager.emailNotifications.hostHint`)}),(0,Z.jsx)(z,{value:s.host,onChange:e=>I(`host`,e.target.value),placeholder:`smtp.example.com`,spellCheck:!1,dir:`ltr`,"data-testid":`email-smtp-host`})]}),(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsx)(`span`,{className:B,children:e(`userManager.emailNotifications.portLabel`)}),(0,Z.jsx)(`span`,{className:H,children:L(`port`)??e(`userManager.emailNotifications.portHint`)}),(0,Z.jsx)(z,{type:`number`,min:1,max:65535,value:s.port,onChange:e=>I(`port`,e.target.value),placeholder:s.security===`tls`?`465`:`587`,dir:`ltr`,"data-testid":`email-smtp-port`})]})]}),(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsx)(`span`,{className:B,children:e(`userManager.emailNotifications.securityLabel`)}),(0,Z.jsx)(`span`,{className:H,children:L(`security`)??e(`userManager.emailNotifications.securityHint`)}),(0,Z.jsx)(V,{value:s.security,onChange:e=>I(`security`,e.target.value),options:Se.map(t=>({value:t,label:e(`userManager.emailNotifications.security.${t}`)})),"data-testid":`email-smtp-security`})]}),(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-4 sm:pt-1`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`span`,{id:i,className:B,children:e(`userManager.emailNotifications.verifyLabel`)}),(0,Z.jsx)(`span`,{className:`block text-xs text-gray-500 dark:text-gray-400`,children:e(`userManager.emailNotifications.verifyHint`)})]}),(0,Z.jsx)(W,{"aria-labelledby":i,checked:s.rejectUnauthorized,onChange:e=>I(`rejectUnauthorized`,e),disabled:p||s.security===`none`})]})]}),(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsx)(`span`,{className:B,children:e(`userManager.emailNotifications.usernameLabel`)}),(0,Z.jsx)(`span`,{className:H,children:L(`username`)??e(`userManager.emailNotifications.usernameHint`)}),(0,Z.jsx)(z,{value:s.username,onChange:e=>I(`username`,e.target.value),autoComplete:`off`,spellCheck:!1,dir:`ltr`,"data-testid":`email-smtp-username`})]}),(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsx)(`span`,{className:B,children:e(`userManager.emailNotifications.passwordLabel`)}),(0,Z.jsx)(`span`,{className:H,children:L(`password`)??(a?.passwordConfigured?e(`userManager.emailNotifications.passwordStored`):e(`userManager.emailNotifications.passwordHint`))}),(0,Z.jsx)(z,{type:`password`,value:s.password,onChange:e=>{I(`password`,e.target.value),e.target.value&&v(!1)},autoComplete:`new-password`,placeholder:a?.passwordConfigured?`••••••••`:``,dir:`ltr`,"data-testid":`email-smtp-password`}),a?.passwordConfigured&&a.sources?.password===`stored`&&!s.password&&(0,Z.jsxs)(`label`,{className:`mt-2 flex items-center gap-2 text-xs text-gray-500 dark:text-gray-400`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:_,onChange:e=>v(e.target.checked)}),e(`userManager.emailNotifications.clearPassword`)]})]})]}),(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsx)(`span`,{className:B,children:e(`userManager.emailNotifications.fromLabel`)}),(0,Z.jsx)(`span`,{className:H,children:L(`from`)??e(`userManager.emailNotifications.fromHint`)}),(0,Z.jsx)(z,{value:s.from,onChange:e=>I(`from`,e.target.value),placeholder:`Libre WebUI <notifications@example.com>`,spellCheck:!1,dir:`ltr`,"data-testid":`email-smtp-from`})]}),(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsx)(`span`,{className:B,children:e(`userManager.emailNotifications.appUrlLabel`)}),(0,Z.jsx)(`span`,{className:H,children:L(`appUrl`)??e(`userManager.emailNotifications.appUrlHint`)}),(0,Z.jsx)(z,{value:s.appUrl,onChange:e=>I(`appUrl`,e.target.value),placeholder:`https://chat.example.com`,spellCheck:!1,dir:`ltr`,"data-testid":`email-app-url`})]})]}),(0,Z.jsxs)(`fieldset`,{className:`border-t border-gray-200 dark:border-dark-300 pt-3 space-y-3`,children:[(0,Z.jsx)(`legend`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:e(`userManager.emailNotifications.templateTitle`)}),(0,Z.jsx)(`p`,{className:H,children:e(`userManager.emailNotifications.templateHint`)}),(0,Z.jsxs)(`label`,{className:`block sm:max-w-xs`,children:[(0,Z.jsx)(`span`,{className:B,children:e(`userManager.emailNotifications.themeLabel`)}),(0,Z.jsx)(V,{value:s.emailTheme,onChange:e=>I(`emailTheme`,e.target.value),disabled:p,"data-testid":`email-template-theme`,options:[{value:`light`,label:e(`userManager.emailNotifications.themeLight`)},{value:`dark`,label:e(`userManager.emailNotifications.themeDark`)}]})]}),(0,Z.jsxs)(`div`,{"aria-busy":!O,children:[(0,Z.jsx)(`h4`,{className:B,children:e(`userManager.emailNotifications.previewTitle`)}),A?(0,Z.jsxs)(`div`,{role:`status`,className:`flex items-center gap-3`,children:[(0,Z.jsx)(`p`,{className:H,children:e(`userManager.emailNotifications.previewFailed`)}),(0,Z.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>T(e=>e+1),children:e(`common.retry`)})]}):O?.html?(0,Z.jsx)(`iframe`,{title:e(`userManager.emailNotifications.previewTitle`),srcDoc:Ce(O.html),sandbox:``,referrerPolicy:`no-referrer`,className:`h-96 w-full rounded-lg border border-gray-200 dark:border-dark-300 bg-white`,"data-testid":`email-template-preview`}):(0,Z.jsx)(`p`,{role:`status`,className:H,children:e(`userManager.emailNotifications.previewLoading`)})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 border-t border-gray-200 dark:border-dark-300 pt-3 sm:flex-row sm:items-end sm:justify-between`,children:[(0,Z.jsxs)(`label`,{className:`block sm:max-w-xs sm:flex-1`,children:[(0,Z.jsx)(`span`,{className:B,children:e(`userManager.emailNotifications.testRecipientLabel`)}),(0,Z.jsx)(`span`,{className:H,children:e(`userManager.emailNotifications.testRecipientHint`)}),(0,Z.jsx)(z,{type:`email`,value:l,onChange:e=>f(e.target.value),placeholder:`you@example.com`,spellCheck:!1,dir:`ltr`,"data-testid":`email-test-recipient`})]}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Z.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>void F(),disabled:h||p||!a?.configured||R,title:R?e(`userManager.emailNotifications.saveBeforeTest`):void 0,"data-testid":`email-test-button`,children:e(h?`userManager.emailNotifications.testing`:`userManager.emailNotifications.test`)}),(0,Z.jsx)(U,{size:`sm`,onClick:()=>void N(),disabled:p||!R,"data-testid":`email-save-button`,children:e(p?`userManager.emailNotifications.saving`:`userManager.emailNotifications.save`)})]})]})]})]})},Ee=()=>{let{t:e}=r(),t=(0,X.useId)(),[n,i]=(0,X.useState)(null),[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(0);return(0,X.useEffect)(()=>{let e=!1;return A.getMfaPolicy().then(t=>{e||(t.success&&t.data?i(t.data):c(!0))}).catch(()=>{e||c(!0)}),()=>{e=!0}},[l]),(0,Z.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.mfaPolicy.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.mfaPolicy.description`)})]}),n===null&&s&&(0,Z.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>{c(!1),u(e=>e+1)},children:e(`common.retry`)})]}),(0,Z.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{id:t,className:`text-sm text-gray-900 dark:text-gray-100`,children:e(`userManager.mfaPolicy.requireAll`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:n?.locked?e(`userManager.mfaPolicy.lockedByEnv`):e(`userManager.mfaPolicy.requireAllHint`)})]}),(0,Z.jsx)(W,{"aria-labelledby":t,checked:n?.mode===`required`,disabled:n===null||n.locked||a,onChange:async t=>{let n=t?`required`:`optional`;o(!0);try{let t=await A.setMfaPolicy(n);if(!t.success||!t.data)throw Error(t.error||`MFA policy update failed.`);i(t.data),d.success(e(`userManager.mfaPolicy.saved`))}catch{d.error(e(`userManager.mfaPolicy.saveFailed`))}finally{o(!1)}}})]})]})},De=()=>{let{t:e,i18n:t}=r(),[n,i]=(0,X.useState)([]),[a,o]=(0,X.useState)([]),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(!0),[f,m]=(0,X.useState)(!1),[h,g]=(0,X.useState)(``),[_,b]=(0,X.useState)(``),[x,S]=(0,X.useState)(!1),[w,E]=(0,X.useState)(null),[D,O]=(0,X.useState)(``),[k,A]=(0,X.useState)(null),[N,P]=(0,X.useState)(``),[F,I]=(0,X.useState)(null),[L,R]=(0,X.useState)(!1),B=(0,X.useMemo)(()=>{let e=new Map;return a.forEach(t=>e.set(t.id,t.username)),e},[a]),H=(0,X.useCallback)(async()=>{u(!0),c(!1);try{let[t,n]=await Promise.all([j.getGroups(),M.getUsers()]);if(!t.success||!t.data)throw Error(t.error||e(`userManager.groups.loadFailed`));i(t.data),n.success&&n.data&&o(n.data)}catch{c(!0)}finally{u(!1)}},[e]);(0,X.useEffect)(()=>{let e=setTimeout(()=>void H(),0);return()=>clearTimeout(e)},[H]);let W=async t=>{if(t.preventDefault(),!h.trim())d.error(e(`userManager.groups.nameRequired`,`Give the group a name.`));else{S(!0);try{let t=await j.createGroup({name:h.trim(),description:_.trim()||void 0});if(!t.success)throw Error(t.error||e(`userManager.groups.createFailed`));g(``),b(``),m(!1),d.success(e(`userManager.groups.created`,`Group created.`)),await H()}catch(t){d.error(t instanceof Error&&t.message?t.message:e(`userManager.groups.createFailed`,`The group could not be created.`))}finally{S(!1)}}},te=async t=>{if(await oe({title:e(`userManager.groups.deleteConfirmTitle`,{name:t.name}),description:e(`userManager.groups.deleteConfirmDescription`),confirmLabel:e(`userManager.groups.deleteGroup`),destructive:!0})){A(t.id);try{let n=await j.deleteGroup(t.id);if(!n.success)throw Error(n.error||e(`userManager.groups.deleteFailed`));d.success(e(`userManager.groups.deleted`,`Group deleted.`)),w===t.id&&E(null),await H()}catch(t){d.error(t instanceof Error&&t.message?t.message:e(`userManager.groups.deleteFailed`,`The group could not be deleted.`))}finally{A(null)}}},G=async t=>{if(D){A(t.id);try{let n=await j.addGroupMember(t.id,D);if(!n.success)throw Error(n.error||e(`userManager.groups.memberAddFailed`));O(``),d.success(e(`userManager.groups.memberAdded`,`Member added.`)),await H()}catch(t){d.error(t instanceof Error&&t.message?t.message:e(`userManager.groups.memberAddFailed`,`The member could not be added.`))}finally{A(null)}}},K=async(t,n)=>{A(t.id);try{let r=await j.removeGroupMember(t.id,n);if(!r.success)throw Error(r.error||e(`userManager.groups.memberRemoveFailed`));d.success(e(`userManager.groups.memberRemoved`,`Member removed.`)),await H()}catch(t){d.error(t instanceof Error&&t.message?t.message:e(`userManager.groups.memberRemoveFailed`,`The member could not be removed.`))}finally{A(null)}},ne=async t=>{if(P(t),I(null),t){R(!0);try{let n=await j.getEffectiveAccess(t);if(!n.success||!n.data)throw Error(n.error||e(`userManager.groups.accessLookupFailed`));I(n.data)}catch(t){d.error(t instanceof Error&&t.message?t.message:e(`userManager.groups.accessLookupFailed`,`The effective access could not be loaded.`))}finally{R(!1)}}},q=e=>e.map(e=>({value:e.id,label:e.username}));return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`h4`,{className:`flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-gray-100`,children:[(0,Z.jsx)(C,{className:`h-4 w-4 text-primary-500`}),e(`userManager.groups.title`,`Groups`)]}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.groups.description`,`Group accounts to manage shared access, and inspect what any account can effectively do.`)})]}),s?(0,Z.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>void H(),children:e(`common.retry`)}):(0,Z.jsxs)(U,{size:`sm`,variant:`outline`,onClick:()=>m(e=>!e),className:`gap-1.5`,children:[(0,Z.jsx)(ee,{size:14}),e(`userManager.groups.newGroup`,`New group`)]})]}),f&&(0,Z.jsxs)(`form`,{onSubmit:W,className:`mt-4 rounded-lg border border-gray-200 dark:border-dark-300 bg-gray-50 dark:bg-dark-50 p-4 space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsx)(`span`,{className:`mb-1 block text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.groups.nameLabel`,`Name`)}),(0,Z.jsx)(z,{value:h,onChange:e=>g(e.target.value)})]}),(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsx)(`span`,{className:`mb-1 block text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.groups.descriptionLabel`,`Description (optional)`)}),(0,Z.jsx)(z,{value:_,onChange:e=>b(e.target.value)})]})]}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Z.jsx)(U,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>m(!1),children:e(`common.cancel`)}),(0,Z.jsx)(U,{type:`submit`,size:`sm`,disabled:x,children:x?e(`userManager.groups.creating`,`Creating…`):e(`userManager.groups.create`,`Create group`)})]})]}),(0,Z.jsx)(`div`,{className:`mt-4 space-y-3`,children:l?(0,Z.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`common.loading`)}):s?(0,Z.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`userManager.groups.loadFailed`,`The groups could not be loaded.`)}):n.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`userManager.groups.empty`,`No groups yet.`)}):n.map(n=>{let r=w===n.id,i=new Set(n.members.map(e=>e.user_id)),o=a.filter(e=>!i.has(e.id));return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-gray-50 dark:bg-dark-100`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 p-4`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-2 text-start`,onClick:()=>{E(r?null:n.id),O(``)},"aria-expanded":r,children:[r?(0,Z.jsx)(y,{className:`h-4 w-4 shrink-0 text-gray-500 dark:text-gray-400`}):(0,Z.jsx)(p,{className:`h-4 w-4 shrink-0 text-gray-500 dark:text-gray-400`}),(0,Z.jsxs)(`span`,{className:`min-w-0`,children:[(0,Z.jsxs)(`span`,{className:`block truncate text-sm font-medium text-gray-900 dark:text-gray-100`,children:[n.name,(0,Z.jsx)(`span`,{className:`ms-2 text-xs font-normal text-gray-500 dark:text-gray-400`,children:e(`userManager.groups.memberCount`,{count:n.members.length,defaultValue:`Members: {{count}}`})})]}),n.description&&(0,Z.jsx)(`span`,{className:`block truncate text-xs text-gray-500 dark:text-gray-400`,children:n.description})]})]}),(0,Z.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>void te(n),disabled:k===n.id,"aria-label":e(`userManager.groups.deleteGroup`,`Delete group`),className:`text-error-700 hover:border-error-500/40 hover:bg-error-500/10 hover:text-error-800 dark:text-error-400 dark:hover:text-error-300`,children:(0,Z.jsx)(T,{size:16})})]}),r&&(0,Z.jsxs)(`div`,{className:`border-t border-gray-200 dark:border-dark-300 p-4 space-y-3`,children:[n.members.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`userManager.groups.noMembers`,`No members yet.`)}):(0,Z.jsx)(`div`,{className:`space-y-2`,children:n.members.map(r=>(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-50 px-3 py-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`p`,{className:`truncate text-sm text-gray-900 dark:text-gray-100`,children:B.get(r.user_id)||r.user_id}),(0,Z.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[e(`userManager.groups.addedAt`,`Added`),`:`,` `,new Date(r.added_at).toLocaleDateString(t.language)]})]}),(0,Z.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>void K(n,r.user_id),disabled:k===n.id,"aria-label":e(`userManager.groups.removeMember`,`Remove member`),children:(0,Z.jsx)(v,{size:16})})]},r.user_id))}),o.length>0&&(0,Z.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,Z.jsx)(`div`,{className:`flex-1`,children:(0,Z.jsx)(V,{label:e(`userManager.groups.addMember`,`Add member`),value:D,onChange:e=>O(e.target.value),options:[{value:``,label:e(`userManager.groups.selectUser`,`Select a user…`)},...q(o)]})}),(0,Z.jsx)(U,{size:`sm`,onClick:()=>void G(n),disabled:!D||k===n.id,className:`mb-0.5`,children:e(`userManager.groups.add`,`Add`)})]})]})]},n.id)})}),(0,Z.jsxs)(`div`,{className:`mt-6 border-t border-gray-200 dark:border-dark-300 pt-4 space-y-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.groups.effectiveTitle`,`Effective access`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.groups.effectiveDescription`,`Pick an account to see the access it ends up with across role, groups, and grants.`)})]}),(0,Z.jsx)(V,{"aria-label":e(`userManager.groups.effectiveTitle`,`Effective access`),value:N,onChange:e=>void ne(e.target.value),options:[{value:``,label:e(`userManager.groups.selectUser`,`Select a user…`)},...q(a)]}),L&&(0,Z.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`common.loading`)}),F&&!L&&(0,Z.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-gray-50 dark:bg-dark-50 p-4 space-y-3`,children:[(0,Z.jsxs)(`p`,{className:`text-sm text-gray-900 dark:text-gray-100`,children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:F.username}),(0,Z.jsxs)(`span`,{className:`text-gray-500 dark:text-gray-400`,children:[` · `,e(`userManager.groups.roleLabel`,`Role`),`:`,` `,e(`userManager.roles.${F.role}`,{defaultValue:F.role}),` · `,e(`userManager.groups.statusLabel`,`Status`),`:`,` `,e(`userManager.groups.statuses.${F.status}`,{defaultValue:F.status})]})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`mb-1 text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`userManager.groups.memberOf`,`Groups`)}),F.groups.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`common.none`)}):(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:F.groups.map(e=>(0,Z.jsx)(`span`,{className:`rounded-full bg-primary-100 dark:bg-primary-900/30 px-2 py-0.5 text-xs text-primary-700 dark:text-primary-300`,children:e.name},e.id))})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`mb-1 text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`userManager.groups.featuresLabel`,`Feature access`)}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Object.entries(F.features).map(([t,n])=>(0,Z.jsxs)(`span`,{className:n?`rounded-full bg-success-100 px-2 py-0.5 text-xs text-success-800 dark:bg-success-900/30 dark:text-success-300`:`rounded-full bg-surface-subtle px-2 py-0.5 text-xs text-ink-muted`,children:[e(`userManager.groups.features.${t}`,{defaultValue:t}),`: `,e(n?`common.yes`:`common.no`)]},t))})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`mb-1 text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`userManager.groups.grantsLabel`,`Grants`)}),F.grants.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`common.none`)}):(0,Z.jsx)(`div`,{className:`space-y-1`,children:F.grants.map(t=>(0,Z.jsxs)(`p`,{className:`text-xs text-gray-700 dark:text-gray-300`,children:[t.resourceType,`/`,t.resourceId,` ·`,` `,t.permission,` `,(0,Z.jsxs)(`span`,{className:`text-gray-500 dark:text-gray-400`,children:[`(`,e(`userManager.groups.grantVia`,`via`),` `,e(`userManager.groups.grantViaKinds.${t.via}`,{defaultValue:t.via}),`)`]})]},t.id))})]})]})]})]})},Oe={success:`bg-success-100 text-success-800 dark:bg-success-900/30 dark:text-success-300`,denied:`bg-warning-500/15 text-ink`,failure:`bg-error-100 text-error-800 dark:bg-error-900/30 dark:text-error-200`},ke=()=>{let{t:e,i18n:t}=r(),n=(0,X.useId)(),[i,a]=(0,X.useState)([]),[o,s]=(0,X.useState)(!0),[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(null),[m,h]=(0,X.useState)(``),[g,_]=(0,X.useState)(``),[v,b]=(0,X.useState)(`50`),x=(0,X.useCallback)(async()=>{s(!0),l(!1);try{let t=Number(v),n=await j.getAuditEvents({action:m.trim()||void 0,result:g||void 0,limit:Number.isInteger(t)&&t>0?t:void 0});if(!n.success||!n.data)throw Error(n.error||e(`userManager.audit.loadFailed`));a(n.data)}catch{l(!0)}finally{s(!1)}},[m,g,v,e]);(0,X.useEffect)(()=>{let e=setTimeout(()=>void x(),0);return()=>clearTimeout(e)},[]);let C=t=>{switch(t){case`success`:return e(`userManager.audit.resultSuccess`,`Success`);case`denied`:return e(`userManager.audit.resultDenied`,`Denied`);case`failure`:return e(`userManager.audit.resultFailure`,`Failure`);default:return t}};return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`h4`,{className:`flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-gray-100`,children:[(0,Z.jsx)(S,{className:`h-4 w-4 text-primary-500`}),e(`userManager.audit.title`,`Security audit log`)]}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.audit.description`,`Recent sign-ins, permission checks, and administrative changes on this instance.`)})]}),(0,Z.jsxs)(U,{size:`sm`,variant:`outline`,type:`submit`,form:n,disabled:o,className:`gap-1.5`,children:[(0,Z.jsx)(f,{size:14,className:o?`animate-spin`:void 0}),e(`common.refresh`)]})]}),(0,Z.jsxs)(`form`,{id:n,onSubmit:e=>{e.preventDefault(),x()},className:`mt-4 grid gap-3 sm:grid-cols-3`,children:[(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsx)(`span`,{className:`mb-1 block text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`userManager.audit.actionFilter`,`Action`)}),(0,Z.jsx)(z,{value:m,onChange:e=>h(e.target.value),placeholder:e(`userManager.audit.actionPlaceholder`,`e.g. auth.login`),spellCheck:!1,dir:`ltr`})]}),(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsx)(`span`,{className:`mb-1 block text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`userManager.audit.resultFilter`,`Result`)}),(0,Z.jsx)(V,{value:g,onChange:e=>_(e.target.value),options:[{value:``,label:e(`common.all`)},{value:`success`,label:e(`userManager.audit.resultSuccess`,`Success`)},{value:`denied`,label:e(`userManager.audit.resultDenied`,`Denied`)},{value:`failure`,label:e(`userManager.audit.resultFailure`,`Failure`)}]})]}),(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsx)(`span`,{className:`mb-1 block text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`userManager.audit.limitFilter`,`Limit`)}),(0,Z.jsx)(z,{type:`number`,min:1,max:500,value:v,onChange:e=>b(e.target.value),dir:`ltr`})]})]}),(0,Z.jsx)(`div`,{className:`mt-4 space-y-2`,children:o?(0,Z.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`common.loading`)}):c?(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`userManager.audit.loadFailed`,`The audit log could not be loaded.`)}),(0,Z.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>void x(),children:e(`common.retry`)})]}):i.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`userManager.audit.empty`,`No audit events recorded yet.`)}):i.map(n=>{let r=u===n.id,i=n.details&&Object.keys(n.details).length>0;return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-gray-50 dark:bg-dark-50`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-3 px-3 py-2 text-start`,onClick:()=>d(r?null:n.id),"aria-expanded":r,children:[i?r?(0,Z.jsx)(y,{className:`h-4 w-4 shrink-0 text-gray-500 dark:text-gray-400`}):(0,Z.jsx)(p,{className:`h-4 w-4 shrink-0 text-gray-500 dark:text-gray-400`}):(0,Z.jsx)(`span`,{className:`h-4 w-4 shrink-0`}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:n.action}),(0,Z.jsx)(`span`,{className:`rounded-full px-2 py-0.5 text-xs font-medium ${Oe[n.result]||`bg-surface-subtle text-ink-muted`}`,children:C(n.result)})]}),(0,Z.jsxs)(`span`,{className:`mt-0.5 block truncate text-xs text-gray-500 dark:text-gray-400`,children:[new Date(n.occurredAt).toLocaleString(t.language),` · `,e(`userManager.audit.actor`,`Actor`),`:`,` `,n.actorUserId||n.actorKind,n.targetType&&(0,Z.jsxs)(Z.Fragment,{children:[` · `,e(`userManager.audit.target`,`Target`),`:`,` `,n.targetType,n.targetId?`/${n.targetId}`:``]})]})]})]}),r&&i&&(0,Z.jsx)(`pre`,{dir:`ltr`,className:`mx-3 mb-3 overflow-x-auto rounded-md bg-white dark:bg-dark-100 border border-gray-200 dark:border-dark-300 p-3 text-xs text-gray-700 dark:text-gray-300`,children:JSON.stringify(n.details,null,2)})]},n.id)})})]})},Ae=()=>{let{t:e}=r(),t=(0,X.useId)(),[n,i]=(0,X.useState)(null),[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(0);return(0,X.useEffect)(()=>{let e=!1;return I.getModelAccess().then(t=>{e||(t.success&&t.data?i(t.data.mode):c(!0))}).catch(()=>{e||c(!0)}),()=>{e=!0}},[l]),(0,Z.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{id:t,className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.modelAccess.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.modelAccess.description`)})]}),n===null&&s?(0,Z.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>{c(!1),u(e=>e+1)},children:e(`common.retry`)}):(0,Z.jsx)(W,{"aria-labelledby":t,checked:n===`all-users`,onChange:async t=>{let n=t?`all-users`:`admins`;o(!0);try{if(!(await I.setModelAccess(n)).success)throw Error(`Model download access update failed.`);i(n),d.success(e(`userManager.modelAccess.saved`))}catch{d.error(e(`userManager.modelAccess.saveFailed`))}finally{o(!1)}},disabled:a||n===null})]})})},je=()=>{let{t:e}=r(),t=(0,X.useId)(),[n,i]=(0,X.useState)(null),[a,o]=(0,X.useState)(``),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(!1),[f,p]=(0,X.useState)(0);(0,X.useEffect)(()=>{let e=!1;return I.getSettings().then(t=>{e||(t.success&&t.data?(i(t.data),o(t.data.baseUrl)):u(!0))}).catch(()=>{e||u(!0)}),()=>{e=!0}},[f]);let m=async t=>{c(!0);try{let n=await I.updateSettings(t);if(!n.success||!n.data)throw Error(n.message||`update failed`);i(n.data),o(n.data.baseUrl),d.success(e(`userManager.ollamaProvider.saved`))}catch{d.error(e(`userManager.ollamaProvider.saveFailed`))}finally{c(!1)}},h=n!==null&&a.trim()!==n.baseUrl;return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{id:t,className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.ollamaProvider.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.ollamaProvider.description`)})]}),n===null&&l?(0,Z.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>{u(!1),p(e=>e+1)},children:e(`common.retry`)}):(0,Z.jsx)(W,{"aria-labelledby":t,checked:n?.enabled===!0,onChange:e=>void m({enabled:e}),disabled:s||n===null})]}),n!==null&&(0,Z.jsxs)(`div`,{className:`mt-3 flex items-center gap-2`,children:[(0,Z.jsx)(`input`,{className:`min-w-0 flex-1 rounded-lg border border-gray-200 bg-white px-3 py-1.5 font-mono text-xs text-gray-900 focus:border-primary-400 focus:outline-hidden dark:border-dark-300 dark:bg-dark-50 dark:text-gray-100`,value:a,onChange:e=>o(e.target.value),placeholder:`http://localhost:11434`,spellCheck:!1,"aria-label":e(`userManager.ollamaProvider.baseUrlLabel`)}),(0,Z.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>void m({baseUrl:a.trim()}),disabled:s||!h||!a.trim(),children:e(`common.save`)})]})]})},Me=()=>{let{t:e}=r(),t=(0,X.useId)(),[n,i]=(0,X.useState)(null),[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(0);return(0,X.useEffect)(()=>{let e=!1;return F.getAccess().then(t=>{e||(t.success&&t.data?i(t.data.mode):c(!0))}).catch(()=>{e||c(!0)}),()=>{e=!0}},[l]),(0,Z.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{id:t,className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.webSearchAccess.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.webSearchAccess.description`)})]}),n===null&&s?(0,Z.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>{c(!1),u(e=>e+1)},children:e(`common.retry`)}):(0,Z.jsx)(W,{"aria-labelledby":t,checked:n===`all-users`,onChange:async t=>{let n=t?`all-users`:`admins`;o(!0);try{if(!(await F.setAccess(n)).success)throw Error(`Web search access update failed.`);i(n),d.success(e(`userManager.webSearchAccess.saved`))}catch{d.error(e(`userManager.webSearchAccess.saveFailed`))}finally{o(!1)}},disabled:a||n===null})]})})},Ne=()=>{let{t:e}=r(),t=(0,X.useId)(),n=O(e=>e.refreshWorkAccess),[i,a]=(0,X.useState)(null),[o,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(!1),[u,f]=(0,X.useState)(0);return(0,X.useEffect)(()=>{let e=!1;return Y.access().then(t=>{e||(t.success&&t.data?a(t.data.mode):l(!0))}).catch(()=>{e||l(!0)}),()=>{e=!0}},[u]),(0,Z.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{id:t,className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.workAccess.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.workAccess.description`)})]}),i===null&&c?(0,Z.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>{l(!1),f(e=>e+1)},children:e(`common.retry`)}):(0,Z.jsx)(W,{"aria-labelledby":t,checked:i===`all-users`,onChange:async t=>{let r=t?`all-users`:`admins`;s(!0);try{if(!(await Y.setAccess(r)).success)throw Error(`Work access update failed.`);a(r),await n(),d.success(e(`userManager.workAccess.saved`))}catch{d.error(e(`userManager.workAccess.saveFailed`))}finally{s(!1)}},disabled:o||i===null})]})})},Pe=[`disabled`,`admins`,`all-users`],Fe=()=>{let{t:e}=r(),[t,n]=(0,X.useState)(null),[i,a]=(0,X.useState)(!1),[o,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(!1),[u,f]=(0,X.useState)(0);(0,X.useEffect)(()=>{let e=!1;return Y.agentAccess().then(t=>{e||(t.success&&t.data?(n(t.data.mode),a(t.data.lockedByEnv)):l(!0))}).catch(()=>{e||l(!0)}),()=>{e=!0}},[u]);let p=async t=>{s(!0);try{let r=await Y.setAgentAccess(t);if(!r.success||!r.data)throw Error(r.error||`Agent access update failed.`);n(r.data.mode),d.success(e(`userManager.workAgentAccess.saved`))}catch{d.error(e(`userManager.workAgentAccess.saveFailed`))}finally{s(!1)}};return(0,Z.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,"data-testid":`work-agent-access-settings`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.workAgentAccess.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.workAgentAccess.description`)}),i&&(0,Z.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400 mt-1`,children:e(`userManager.workAgentAccess.lockedByEnv`)})]}),t===null&&c?(0,Z.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>{l(!1),f(e=>e+1)},children:e(`common.retry`)}):(0,Z.jsx)(`div`,{className:`w-44`,children:(0,Z.jsx)(V,{"data-testid":`work-agent-access-mode`,"aria-label":e(`userManager.workAgentAccess.title`),value:t??`disabled`,disabled:o||t===null||i,onChange:e=>void p(e.target.value),options:Pe.map(t=>({value:t,label:e(`userManager.workAgentAccess.modes.${t}`)}))})})]})})},Q={name:``,image:``,memoryLimit:``,cpuLimit:``,pidsLimit:``,workspaceSize:``,idleMinutes:``,networkDefault:`inherit`,guiEnabled:!1,takeoverEnabled:!0,approvalsRequired:!1},Ie={...Q,name:`Work Computer`,image:`libre-work-computer:latest`,memoryLimit:`4g`,networkDefault:`on`,guiEnabled:!0},Le=e=>({name:e.name,guiEnabled:e.guiEnabled===!0,takeoverEnabled:e.takeoverEnabled!==!1,approvalsRequired:e.approvalsRequired===!0,image:e.image??``,memoryLimit:e.memoryLimit??``,cpuLimit:e.cpuLimit??``,pidsLimit:e.pidsLimit===void 0?``:String(e.pidsLimit),workspaceSize:e.workspaceSize??``,idleMinutes:e.idleTimeoutMs===void 0?``:String(e.idleTimeoutMs/6e4),networkDefault:e.networkDefault===void 0?`inherit`:e.networkDefault?`on`:`off`}),Re=e=>[e.pidsLimit,e.idleMinutes].some(e=>e.trim()!==``&&!Number.isFinite(Number(e))),ze=e=>({name:e.name.trim(),image:e.image.trim()||null,memoryLimit:e.memoryLimit.trim()||null,cpuLimit:e.cpuLimit.trim()||null,pidsLimit:e.pidsLimit.trim()?Number(e.pidsLimit):null,workspaceSize:e.workspaceSize.trim()||null,idleTimeoutMs:e.idleMinutes.trim()?Math.round(Number(e.idleMinutes)*6e4):null,networkDefault:e.networkDefault===`inherit`?null:e.networkDefault===`on`,guiEnabled:e.guiEnabled?!0:null,takeoverEnabled:e.takeoverEnabled?null:!1,approvalsRequired:e.approvalsRequired?!0:null}),Be=()=>{let{t:e}=r(),[t,n]=(0,X.useState)([]),[i,a]=(0,X.useState)(null),[o,s]=(0,X.useState)(Q),[c,l]=(0,X.useState)(!1),u=async()=>{try{let e=await Y.listPolicies();e.success&&e.data&&n(e.data)}catch{}};(0,X.useEffect)(()=>{let e=!1;return Y.listPolicies().then(t=>{!e&&t.success&&t.data&&n(t.data)}).catch(()=>{}),()=>{e=!0}},[]);let f=e=>({value:o[e],onChange:t=>s(n=>({...n,[e]:t.target.value}))}),p=async()=>{if(Re(o))d.error(e(`userManager.workPolicies.invalidNumber`));else{l(!0);try{let t=ze(o),n=i===`new`?await Y.createPolicy(t):await Y.updatePolicy(i,t);if(!n.success)throw Error(n.error||`Policy save failed.`);d.success(e(`userManager.workPolicies.saved`)),a(null),s(Q),await u()}catch(t){d.error(t instanceof Error&&t.message?t.message:e(`userManager.workPolicies.failed`))}finally{l(!1)}}},m=async t=>{if(window.confirm(e(`userManager.workPolicies.deleteConfirm`)))try{let n=await Y.deletePolicy(t.id);if(!n.success)throw Error(n.error||`Policy delete failed.`);d.success(e(`userManager.workPolicies.deleted`)),await u()}catch(t){d.error(t instanceof Error&&t.message?t.message:e(`userManager.workPolicies.failed`))}},g=(e,t,n)=>(0,Z.jsxs)(`label`,{className:`block text-xs`,children:[(0,Z.jsx)(`span`,{className:`mb-1 block font-medium text-gray-700 dark:text-gray-300`,children:t}),(0,Z.jsx)(`input`,{...f(e),placeholder:n,spellCheck:!1,className:`w-full rounded-lg border border-gray-200 bg-white px-2.5 py-1.5 text-sm text-gray-900 outline-hidden focus:border-primary-500 dark:border-dark-300 dark:bg-dark-50 dark:text-gray-100`})]});return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.workPolicies.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.workPolicies.description`)})]}),i===null&&(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Z.jsxs)(U,{size:`sm`,variant:`outline`,className:`whitespace-nowrap`,"data-testid":`work-policy-computer-preset`,onClick:()=>{s(Ie),a(`new`)},children:[(0,Z.jsx)(h,{size:14,className:`shrink-0`}),(0,Z.jsx)(`span`,{className:`ms-1.5`,children:e(`userManager.workPolicies.computerPreset`)})]}),(0,Z.jsxs)(U,{size:`sm`,variant:`outline`,className:`whitespace-nowrap`,onClick:()=>{s(Q),a(`new`)},children:[(0,Z.jsx)(ee,{size:14,className:`shrink-0`}),(0,Z.jsx)(`span`,{className:`ms-1.5`,children:e(`userManager.workPolicies.add`)})]})]})]}),t.length===0&&i===null&&(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-gray-500 dark:text-gray-400`,children:e(`userManager.workPolicies.empty`)}),t.length>0&&(0,Z.jsx)(`ul`,{className:`mt-3 divide-y divide-gray-100 dark:divide-dark-300`,children:t.map(t=>(0,Z.jsxs)(`li`,{className:`flex items-center justify-between gap-3 py-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:t.name}),(0,Z.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[11px] text-gray-500 dark:text-gray-400`,children:[t.memoryLimit,t.cpuLimit&&`cpu ${t.cpuLimit}`,t.pidsLimit&&`pids ${t.pidsLimit}`,t.workspaceSize,t.idleTimeoutMs!==void 0&&`idle ${Math.round(t.idleTimeoutMs/6e4)}m`,t.networkDefault!==void 0&&`net ${t.networkDefault?`on`:`off`}`,t.image].filter(Boolean).join(` · `)||`—`})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,Z.jsx)(U,{size:`sm`,variant:`ghost`,"aria-label":e(`userManager.workPolicies.edit`),onClick:()=>{s(Le(t)),a(t.id)},children:(0,Z.jsx)(w,{size:14})}),(0,Z.jsx)(U,{size:`sm`,variant:`ghost`,"aria-label":e(`userManager.workPolicies.delete`),onClick:()=>void m(t),children:(0,Z.jsx)(T,{size:14})})]})]},t.id))}),i!==null&&(0,Z.jsxs)(`div`,{className:`mt-4 rounded-lg border border-gray-200 p-3 dark:border-dark-300`,children:[(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[g(`name`,e(`userManager.workPolicies.name`),`heavy`),g(`memoryLimit`,e(`userManager.workPolicies.memory`),`4g`),g(`cpuLimit`,e(`userManager.workPolicies.cpu`),`4`),g(`pidsLimit`,e(`userManager.workPolicies.pids`),`512`),g(`workspaceSize`,e(`userManager.workPolicies.workspaceSize`),`20Gi`),g(`idleMinutes`,e(`userManager.workPolicies.idleMinutes`),`30`),(0,Z.jsxs)(`label`,{className:`block text-xs`,children:[(0,Z.jsx)(`span`,{className:`mb-1 block font-medium text-gray-700 dark:text-gray-300`,children:e(`userManager.workPolicies.networkDefault`)}),(0,Z.jsxs)(`select`,{...f(`networkDefault`),className:`w-full rounded-lg border border-gray-200 bg-white px-2.5 py-1.5 text-sm text-gray-900 outline-hidden focus:border-primary-500 dark:border-dark-300 dark:bg-dark-50 dark:text-gray-100`,children:[(0,Z.jsx)(`option`,{value:`inherit`,children:e(`userManager.workPolicies.networkInherit`)}),(0,Z.jsx)(`option`,{value:`on`,children:e(`userManager.workPolicies.networkOn`)}),(0,Z.jsx)(`option`,{value:`off`,children:e(`userManager.workPolicies.networkOff`)})]})]}),(0,Z.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,"data-testid":`work-policy-gui`,checked:o.guiEnabled,onChange:e=>s(t=>({...t,guiEnabled:e.target.checked})),className:`h-3.5 w-3.5 rounded-sm border-gray-300 text-primary-600 focus:ring-primary-500`}),(0,Z.jsx)(`span`,{className:`font-medium text-gray-700 dark:text-gray-300`,children:e(`userManager.workPolicies.guiEnabled`)})]}),o.guiEnabled&&(0,Z.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,"data-testid":`work-policy-takeover`,checked:o.takeoverEnabled,onChange:e=>s(t=>({...t,takeoverEnabled:e.target.checked})),className:`h-3.5 w-3.5 rounded-sm border-gray-300 text-primary-600 focus:ring-primary-500`}),(0,Z.jsx)(`span`,{className:`font-medium text-gray-700 dark:text-gray-300`,children:e(`userManager.workPolicies.takeoverEnabled`)})]}),(0,Z.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,"data-testid":`work-policy-approvals`,checked:o.approvalsRequired,onChange:e=>s(t=>({...t,approvalsRequired:e.target.checked})),className:`h-3.5 w-3.5 rounded-sm border-gray-300 text-primary-600 focus:ring-primary-500`}),(0,Z.jsx)(`span`,{className:`font-medium text-gray-700 dark:text-gray-300`,children:e(`userManager.workPolicies.approvalsRequired`)})]}),g(`image`,e(`userManager.workPolicies.image`),`node:22-bookworm@sha256:…`)]}),o.guiEnabled&&(0,Z.jsx)(`p`,{className:`mt-2 text-[11px] text-gray-500 dark:text-gray-400`,children:e(`userManager.workPolicies.computerPresetHint`)}),(0,Z.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,Z.jsx)(U,{size:`sm`,variant:`ghost`,disabled:c,onClick:()=>{a(null),s(Q)},children:e(`userManager.workPolicies.cancel`)}),(0,Z.jsx)(U,{size:`sm`,disabled:c||!o.name.trim(),onClick:()=>void p(),children:e(`userManager.workPolicies.save`)})]})]})]})},$=[{id:`users`,label:`userManager.sections.users`},{id:`groups`,label:`userManager.groups.title`},{id:`access`,label:`userManager.sections.access`},{id:`security`,label:`userManager.sections.security`},{id:`defaults`,label:`userManager.sections.defaults`}],Ve=e=>{switch(e){case`users`:return(0,Z.jsx)(ue,{});case`groups`:return(0,Z.jsx)(De,{});case`access`:return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(Ne,{}),(0,Z.jsx)(Be,{}),(0,Z.jsx)(je,{}),(0,Z.jsx)(Ae,{}),(0,Z.jsx)(Me,{}),(0,Z.jsx)(de,{}),(0,Z.jsx)(pe,{}),(0,Z.jsx)(Fe,{}),(0,Z.jsx)(ge,{}),(0,Z.jsx)(be,{}),(0,Z.jsx)(xe,{}),(0,Z.jsx)(Te,{})]});case`security`:return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(Ee,{}),(0,Z.jsx)(ke,{})]});case`defaults`:return(0,Z.jsx)(he,{})}},He=()=>{let{t:e}=r(),t=(0,X.useId)(),n=(0,X.useRef)({}),[i,a]=(0,X.useState)(`users`),[o,s]=(0,X.useState)([`users`]),c=e=>{a(e),s(t=>t.includes(e)?t:[...t,e])},l=(e,t)=>{let r=getComputedStyle(e.currentTarget).direction===`rtl`,i=$.findIndex(e=>e.id===t),a;switch(e.key){case`Home`:a=0;break;case`End`:a=$.length-1;break;case`ArrowRight`:a=i+(r?-1:1);break;case`ArrowLeft`:a=i+(r?1:-1);break;default:return}e.preventDefault();let o=$[(a+$.length)%$.length].id;c(o),n.current[o]?.focus()};return(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-5`,children:[(0,Z.jsx)(`div`,{role:`tablist`,"aria-label":e(`userManager.title`),"aria-orientation":`horizontal`,className:`-mx-1 flex gap-1 overflow-x-auto border-b border-line px-1 pb-3 pt-1 scrollbar-thin`,children:$.map(r=>(0,Z.jsx)(`button`,{ref:e=>{n.current[r.id]=e},type:`button`,role:`tab`,id:`${t}-tab-${r.id}`,"aria-controls":`${t}-panel-${r.id}`,"aria-selected":i===r.id,tabIndex:i===r.id?0:-1,onClick:()=>c(r.id),onKeyDown:e=>l(e,r.id),className:q(`min-h-11 shrink-0 rounded-xl border px-3 py-2 text-sm font-medium outline-hidden transition-colors duration-150 focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 focus-visible:ring-offset-surface motion-reduce:transition-none`,i===r.id?`border-line bg-nav-active text-ink`:`border-transparent text-ink-muted hover:bg-hover-solid hover:text-ink`),children:e(r.label)},r.id))}),$.map(e=>(0,Z.jsx)(`div`,{id:`${t}-panel-${e.id}`,role:`tabpanel`,"aria-labelledby":`${t}-tab-${e.id}`,hidden:i!==e.id,children:o.includes(e.id)&&Ve(e.id)},e.id))]})};export{He as UserManagementPanel,He as default};
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,t as n}from"./react-vendor-C1iE8mnY.js";import{t as r}from"./useTranslation-Bu0AxynE.js";import{C as i,t as a}from"./useQuery-B-RslgPA.js";import{E as o,G as s,Hn as c,I as l,Nt as u,Or as d,Q as f,Qn as p,R as m,St as h,T as g,c as _,d as v,er as y,f as b,j as x,q as S,s as C,st as w,tt as ee,v as T,vt as E,yt as D}from"./ui-vendor-CmYUVVjB.js";import{t as O}from"./authStore-VeRUWwzv.js";import{C as k,I as A,P as j,R as M,d as N,s as P,w as F,y as I,z as L}from"./api-__EtZkwT.js";import{g as R,h as z,l as B,p as V}from"./ui-D5Ws30mx.js";import{t as H}from"./PasswordStrengthMeter-arTXSwnR.js";import{t as U}from"./Button-DeV-GhQr.js";import{t as W}from"./SettingsToggle-XpuugbHi.js";import{t as te}from"./chatStore-DM7NfNs8.js";import{t as G}from"./strandsApi-oOCOwXJJ.js";import{c as K,t as ne}from"./appStore-xMQ42B4m.js";import{t as q}from"./utils-DhBboyBg.js";import{a as re}from"./logger-DAQsBb8I.js";import{n as J,t as ie}from"./client-DBMImFzz.js";import{t as ae}from"./decisionsApi-1EPksZmY.js";import{t as oe}from"./confirmStore-CKkUtP9c.js";import{t as Y}from"./workApi-B2IWKsfe.js";var X=e(t(),1),Z=n(),se=`h-11 w-full rounded-xl border border-line bg-surface-raised px-3 text-sm text-ink focus:outline-hidden focus:ring-2 focus:ring-primary-500 disabled:cursor-not-allowed disabled:opacity-60`;function ce(e,t){return e?.response?.data?.message||(e instanceof Error?e.message:t)||t}function le({user:e,currentUserId:t,onClose:n,onSaved:i}){let{t:a}=r(),[o,s]=(0,X.useState)({username:e?.username??``,email:e?.email??``,password:``,role:e?.role??`user`}),[c,l]=(0,X.useState)(!1),u=(0,X.useRef)(!1),[f,p]=(0,X.useState)(``),m=e?.id===t,h=()=>{u.current||n()};return(0,Z.jsx)(R,{titleId:`user-form-title`,title:a(e?`userManager.form.title.edit`:`userManager.form.title.create`),subtitle:e?(0,Z.jsx)(`span`,{className:`break-all`,children:e.username}):a(`userManager.subtitle`),onClose:h,testId:`user-form-dialog`,children:(0,Z.jsxs)(`form`,{onSubmit:async t=>{if(t.preventDefault(),u.current)return;u.current=!0,l(!0),p(``);let n=a(e?`userManager.form.updateFailed`:`userManager.form.createFailed`);try{let t={username:o.username.trim(),email:o.email.trim()||null,role:m?e.role:o.role};o.password&&(t.password=o.password);let r=e?await M.updateUser(e.id,t):await M.createUser({...o,username:o.username.trim(),email:o.email.trim()});if(!r.success||!r.data)throw Error(r.message||n);i(r.data),d.success(a(e?`userManager.form.updateSuccess`:`userManager.form.createSuccess`))}catch(e){p(ce(e,n))}finally{u.current=!1,l(!1)}},className:`space-y-5`,"aria-busy":c,children:[(0,Z.jsxs)(`fieldset`,{disabled:c,className:`min-w-0 space-y-4`,children:[(0,Z.jsx)(z,{id:`user-form-username`,label:a(`userManager.form.username`),autoFocus:!0,autoComplete:`off`,value:o.username,onChange:e=>s({...o,username:e.target.value}),required:!0}),(0,Z.jsx)(z,{id:`user-form-email`,label:`${a(`userManager.form.email`)}${e?` (${a(`common.optional`)})`:``}`,type:`email`,dir:`ltr`,autoComplete:`off`,value:o.email,onChange:e=>s({...o,email:e.target.value}),required:!e}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(z,{id:`user-form-password`,label:`${a(`userManager.form.password`)}${e?` (${a(`common.optional`)})`:``}`,type:`password`,autoComplete:`new-password`,value:o.password,onChange:e=>s({...o,password:e.target.value}),required:!e,helper:e?a(`userManager.form.passwordHint`):void 0}),(0,Z.jsx)(H,{password:o.password})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(B,{htmlFor:`user-form-role`,children:a(`userManager.form.role`)}),(0,Z.jsxs)(`select`,{id:`user-form-role`,value:o.role,onChange:e=>s({...o,role:e.target.value}),disabled:m,"aria-describedby":m?`user-form-role-hint`:void 0,className:se,children:[(0,Z.jsx)(`option`,{value:`user`,children:a(`userManager.roles.user`)}),(0,Z.jsx)(`option`,{value:`admin`,children:a(`userManager.roles.admin`)})]}),m&&(0,Z.jsx)(`p`,{id:`user-form-role-hint`,className:`text-xs text-ink-muted`,children:a(`userManager.directory.editSelfRole`)})]})]}),f&&(0,Z.jsx)(`p`,{role:`alert`,className:`text-sm text-error-600 dark:text-error-400`,children:f}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2 border-t border-line pt-4`,children:[(0,Z.jsx)(U,{type:`button`,variant:`outline`,onClick:h,disabled:c,className:`min-h-11`,children:a(`common.cancel`)}),(0,Z.jsx)(U,{type:`submit`,loading:c,disabled:!o.username.trim(),className:`min-h-11`,children:a(c?e?`userManager.form.updating`:`userManager.form.creating`:e?`userManager.form.updateButton`:`userManager.form.createButton`)})]})]})})}var ue=()=>{let{t:e,i18n:t}=r(),n=i(),o=O(e=>e.user),u=O(e=>e.setUser),[p,h]=(0,X.useState)(null),[g,v]=(0,X.useState)(``),[y,S]=(0,X.useState)(`all`),[w,E]=(0,X.useState)(null),[D,k]=(0,X.useState)(``),[A,j]=(0,X.useState)(null),N=(0,X.useRef)(!1),{data:P=[],isLoading:F,isError:I,isFetching:L,refetch:V}=a({queryKey:[`users`],queryFn:async()=>{let t=await M.getUsers();if(!t.success||!t.data)throw Error(e(`userManager.directory.loadFailed`));return t.data}}),H=()=>{n.invalidateQueries({queryKey:[`users`]})},W=e=>{n.setQueryData([`users`],(t=[])=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e]),e.id===o?.id&&u(e),h(null),H()},te=g.trim().toLocaleLowerCase(t.language),G=P.filter(e=>(y===`all`||e.role===y)&&`${e.username} ${e.email??``}`.toLocaleLowerCase(t.language).includes(te)),K=G.filter(e=>e.status===`pending`),ne=G.filter(e=>e.status!==`pending`),q=P.filter(e=>e.status===`pending`).length,re=P.length-q,J=!!(g||y!==`all`),ie=()=>{v(``),S(`all`)},ae=async t=>{if(!N.current){N.current=!0,j(t.id);try{let n=await M.approveUser(t.id);if(!n.success||!n.data)throw Error(n.message||e(`userManager.approval.failed`));W(n.data),d.success(e(`userManager.approval.approved`,{name:t.username}))}catch(t){d.error(ce(t,e(`userManager.approval.failed`)))}finally{N.current=!1,j(null)}}},oe=async()=>{if(!w||N.current||w.kind===`delete`&&w.user.id===o?.id)return;N.current=!0,j(w.user.id),k(``);let t=e(w.kind===`delete`?`userManager.deleteFailed`:`userManager.mfaResetFailed`);try{if(w.kind===`delete`){let r=await M.deleteUser(w.user.id);if(!r.success)throw Error(r.message||t);n.setQueryData([`users`],(e=[])=>e.filter(e=>e.id!==w.user.id)),H(),d.success(e(`userManager.deleteSuccess`))}else{let n=await M.resetUserMfa(w.user.id);if(!n.success)throw Error(n.message||t);d.success(e(n.data?.removed?`userManager.mfaResetSuccess`:`userManager.mfaResetNothing`,{name:w.user.username}))}E(null)}catch(e){k(ce(e,t))}finally{N.current=!1,j(null)}},Y=(e,t)=>{k(``),E({kind:e,user:t})},ue=n=>(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Z.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-surface-subtle text-ink-muted`,"aria-hidden":`true`,children:n.status===`pending`?(0,Z.jsx)(c,{size:18}):n.role===`admin`?(0,Z.jsx)(l,{size:18}):(0,Z.jsx)(_,{size:18})}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,Z.jsx)(`h3`,{className:`min-w-0 break-all text-sm font-medium text-ink`,children:(0,Z.jsx)(`bdi`,{children:n.username})}),n.id===o?.id&&(0,Z.jsxs)(`span`,{className:`text-xs text-ink-muted`,children:[`(`,e(`chatMessage.you`),`)`]}),(0,Z.jsx)(`span`,{className:`rounded-md border border-line px-1.5 py-0.5 text-xs text-ink-muted`,children:e(n.role===`admin`?`userManager.roles.admin`:`userManager.roles.user`)})]}),(0,Z.jsx)(`p`,{className:`mt-1 break-all text-sm text-ink-muted`,children:(0,Z.jsx)(`bdi`,{children:n.email||e(`userManager.noEmail`)})}),(0,Z.jsxs)(`p`,{className:`mt-1 text-xs text-ink-subtle`,children:[e(n.status===`pending`?`userManager.approval.registered`:`userManager.columns.created`),`: `,new Date(n.createdAt).toLocaleDateString(t.language)]})]})]}),de=e=>(0,Z.jsxs)(`div`,{className:`px-4 py-8 text-center`,children:[(0,Z.jsx)(C,{size:24,className:`mx-auto mb-3 text-ink-subtle`,"aria-hidden":`true`}),(0,Z.jsx)(`p`,{className:`text-sm text-ink-muted`,children:e})]});return(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-5`,"data-testid":`user-directory`,children:[(0,Z.jsxs)(`div`,{className:`rounded-2xl border border-line bg-surface p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`div`,{className:`relative min-w-0 basis-full sm:flex-1 sm:basis-48`,children:[(0,Z.jsx)(s,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute inset-s-3.5 top-3.5 text-ink-subtle`}),(0,Z.jsx)(z,{type:`search`,"aria-label":e(`userManager.search`),placeholder:e(`userManager.search`),value:g,onChange:e=>v(e.target.value),className:`ps-10`})]}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 sm:max-w-36`,children:[(0,Z.jsx)(B,{htmlFor:`user-role-filter`,className:`sr-only`,children:e(`userManager.columns.role`)}),(0,Z.jsxs)(`select`,{id:`user-role-filter`,value:y,onChange:e=>S(e.target.value),className:se,children:[(0,Z.jsx)(`option`,{value:`all`,children:e(`userManager.directory.allRoles`)}),(0,Z.jsx)(`option`,{value:`admin`,children:e(`userManager.roles.admin`)}),(0,Z.jsx)(`option`,{value:`user`,children:e(`userManager.roles.user`)})]})]}),(0,Z.jsx)(U,{type:`button`,variant:`outline`,onClick:()=>void V(),disabled:L,className:`min-h-11 min-w-11 px-3`,"aria-label":e(`common.refresh`),title:e(`common.refresh`),children:(0,Z.jsx)(f,{size:16,"aria-hidden":`true`,className:L?`animate-spin motion-reduce:animate-none`:void 0})}),(0,Z.jsxs)(U,{type:`button`,onClick:()=>h(`create`),disabled:!!A,className:`min-h-11`,children:[(0,Z.jsx)(ee,{size:16,"aria-hidden":`true`}),e(`userManager.createUser`)]})]}),(0,Z.jsxs)(`div`,{className:`mt-3 flex min-h-5 flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsx)(`p`,{role:`status`,className:`text-xs text-ink-muted`,children:F?e(`userManager.loading`):e(`userManager.directory.results`,{visible:G.length,total:P.length})}),J&&(0,Z.jsx)(U,{type:`button`,size:`sm`,variant:`ghost`,onClick:ie,className:`min-h-11 sm:min-h-8`,children:e(`userManager.directory.clearFilters`)})]})]}),I&&(0,Z.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center justify-between gap-3 rounded-xl border border-error-500/30 p-4`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-ink`,children:e(`userManager.directory.loadFailed`)}),(0,Z.jsx)(U,{type:`button`,variant:`outline`,onClick:()=>void V(),disabled:L,children:e(`common.retry`)})]}),!F&&(!I||P.length>0)&&(0,Z.jsxs)(Z.Fragment,{children:[q>0&&(0,Z.jsxs)(`section`,{"data-testid":`pending-user-approvals`,"aria-labelledby":`pending-users-title`,className:`overflow-hidden rounded-2xl border border-warning-500/30 bg-surface`,children:[(0,Z.jsxs)(`div`,{className:`border-b border-line bg-warning-500/6 p-4`,children:[(0,Z.jsxs)(`h3`,{id:`pending-users-title`,className:`flex items-center gap-2 text-sm font-semibold text-ink`,children:[(0,Z.jsx)(c,{size:16,"aria-hidden":`true`,className:`text-warning-700 dark:text-warning-400`}),e(`userManager.approval.title`),` `,(0,Z.jsxs)(`span`,{className:`text-ink-muted`,children:[`(`,q,`)`]})]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-ink-muted`,children:e(`userManager.approval.description`)})]}),(0,Z.jsxs)(`div`,{className:`divide-y divide-line`,children:[K.map(t=>(0,Z.jsxs)(`div`,{"data-testid":`pending-user-row`,className:`flex flex-col gap-3 p-4 xl:flex-row xl:items-center xl:justify-between`,children:[ue(t),(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[(0,Z.jsxs)(U,{type:`button`,size:`sm`,"data-testid":`approve-user-button`,onClick:()=>void ae(t),disabled:!!A,loading:A===t.id,className:`min-h-11 sm:min-h-9`,children:[(0,Z.jsx)(b,{size:16,"aria-hidden":`true`}),e(`userManager.approval.activate`)]}),(0,Z.jsx)(U,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>Y(`delete`,t),disabled:!!A,className:`min-h-11 sm:min-h-9`,children:e(`userManager.approval.reject`)})]})]},t.id)),K.length===0&&de(e(`userManager.noUsersMatching`))]})]}),(0,Z.jsxs)(`section`,{"aria-labelledby":`active-users-title`,className:`overflow-hidden rounded-2xl border border-line bg-surface`,children:[(0,Z.jsx)(`div`,{className:`border-b border-line px-4 py-3`,children:(0,Z.jsxs)(`h3`,{id:`active-users-title`,className:`text-sm font-semibold text-ink`,children:[e(`userManager.directory.title`),` `,(0,Z.jsxs)(`span`,{className:`text-ink-muted`,children:[`(`,re,`)`]})]})}),(0,Z.jsxs)(`div`,{className:`divide-y divide-line`,children:[ne.map(t=>(0,Z.jsxs)(`div`,{"data-testid":`user-row`,className:`flex flex-col gap-3 p-4 sm:flex-row sm:items-center sm:justify-between`,children:[ue(t),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,Z.jsxs)(U,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>h(t),disabled:!!A,"aria-label":`${e(`common.edit`)}: ${t.username}`,className:`min-h-11 sm:min-h-9`,children:[(0,Z.jsx)(x,{size:15,"aria-hidden":`true`}),e(`common.edit`)]}),(0,Z.jsx)(U,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`reset-mfa-button`,"aria-label":`${e(`userManager.mfaReset`)}: ${t.username}`,title:e(`userManager.mfaReset`),onClick:()=>Y(`reset`,t),disabled:!!A,className:`min-h-11 min-w-11 sm:min-h-9 sm:min-w-9 px-2`,children:(0,Z.jsx)(m,{size:16,"aria-hidden":`true`})}),(0,Z.jsx)(U,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":`${e(`common.delete`)}: ${t.username}`,title:t.id===o?.id?e(`userManager.cannotDeleteSelf`):e(`common.delete`),onClick:()=>Y(`delete`,t),disabled:t.id===o?.id||!!A,className:`min-h-11 min-w-11 sm:min-h-9 sm:min-w-9 px-2 text-error-600 dark:text-error-400`,children:(0,Z.jsx)(T,{size:16,"aria-hidden":`true`})})]})]},t.id)),ne.length===0&&de(e(J?`userManager.noUsersMatching`:`userManager.directory.empty`))]})]})]}),p&&(0,Z.jsx)(le,{user:p===`create`?null:p,currentUserId:o?.id,onClose:()=>h(null),onSaved:W},p===`create`?`create`:p.id),w&&(0,Z.jsxs)(R,{titleId:`user-action-title`,title:e(w.kind===`reset`?`userManager.mfaReset`:w.user.status===`pending`?`userManager.approval.reject`:`userManager.directory.deleteTitle`),onClose:()=>{N.current||E(null)},testId:`user-action-dialog`,children:[(0,Z.jsx)(`p`,{className:`wrap-break-word text-sm leading-relaxed text-ink-muted`,children:e(w.kind===`delete`?`userManager.deleteConfirm`:`userManager.mfaResetConfirm`,{name:w.user.username})}),D&&(0,Z.jsx)(`p`,{role:`alert`,className:`text-sm text-error-600 dark:text-error-400`,children:D}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2 border-t border-line pt-4`,children:[(0,Z.jsx)(U,{type:`button`,variant:`outline`,onClick:()=>E(null),disabled:!!A,className:`min-h-11`,children:e(`common.cancel`)}),(0,Z.jsx)(U,{type:`button`,variant:`danger`,loading:!!A,onClick:()=>void oe(),className:`min-h-11`,children:e(w.kind===`delete`?`common.delete`:`userManager.mfaReset`)})]})]})]})},de=()=>{let{t:e}=r(),t=(0,X.useId)(),n=O(e=>e.systemInfo),i=O(e=>e.setSystemInfo),a=te(e=>e.loadModels),[o,s]=(0,X.useState)(null),[c,l]=(0,X.useState)(!1),[u,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(!1),[h,g]=(0,X.useState)(0),_=`userManager.agentCliAccess`;return(0,X.useEffect)(()=>{let e=!1;return L.getAccess().then(t=>{e||(t.success&&t.data?(s(t.data.enabled),l(t.data.lockedByEnv)):m(!0))}).catch(()=>{e||m(!0)}),()=>{e=!0}},[h]),(0,Z.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,"data-testid":`agent-cli-access-settings`,children:(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{id:t,className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`${_}.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`${_}.description`)}),c&&(0,Z.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400 mt-1`,children:e(`${_}.lockedByEnv`)})]}),o===null&&p?(0,Z.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>{m(!1),g(e=>e+1)},children:e(`common.retry`)}):(0,Z.jsx)(W,{"aria-labelledby":t,checked:o===!0,onChange:async t=>{f(!0);try{let r=await L.setAccess(t);if(!r.success||!r.data)throw Error(r.error||`Agent access update failed.`);s(r.data.enabled),n&&i({...n,agentCliModelsEnabled:r.data.enabled}),await a({quiet:!0}),d.success(e(`userManager.agentCliAccess.saved`))}catch{d.error(e(`userManager.agentCliAccess.saveFailed`))}finally{f(!1)}},disabled:u||o===null||c})]})})},fe=[`disabled`,`admins`,`all-users`],pe=()=>{let{t:e}=r(),t=O(e=>e.systemInfo),n=O(e=>e.setSystemInfo),i=te(e=>e.loadModels),[a,o]=(0,X.useState)(null),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(!1),[f,p]=(0,X.useState)(!1),[m,h]=(0,X.useState)(0);(0,X.useEffect)(()=>{let e=!1;return G.getAccess().then(t=>{e||(t.success&&t.data?(o(t.data.mode),c(t.data.lockedByEnv)):p(!0))}).catch(()=>{e||p(!0)}),()=>{e=!0}},[m]);let g=async r=>{u(!0);try{let a=await G.setAccess(r);if(!a.success||!a.data)throw Error(a.error||`Strands access update failed.`);o(a.data.mode),t&&n({...t,strandsAccess:a.data.mode}),await i({quiet:!0}),d.success(e(`userManager.strandsAccess.saved`))}catch{d.error(e(`userManager.strandsAccess.saveFailed`))}finally{u(!1)}};return(0,Z.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,"data-testid":`strands-access-settings`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.strandsAccess.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.strandsAccess.description`)}),s&&(0,Z.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400 mt-1`,children:e(`userManager.strandsAccess.lockedByEnv`)})]}),a===null&&f?(0,Z.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>{p(!1),h(e=>e+1)},children:e(`common.retry`)}):(0,Z.jsx)(`div`,{className:`w-44`,children:(0,Z.jsx)(V,{"data-testid":`strands-access-mode`,"aria-label":e(`userManager.strandsAccess.title`),value:a??`disabled`,disabled:l||a===null||s,onChange:e=>void g(e.target.value),options:fe.map(t=>({value:t,label:e(`userManager.strandsAccess.modes.${t}`)}))})})]})})},me=[{mode:`light`,icon:o,key:`settings.appearance.theme.light`},{mode:`dark`,icon:E,key:`settings.appearance.theme.dark`},{mode:`amoled`,icon:D,key:`settings.appearance.theme.amoled`},{mode:`celestial`,icon:g,key:`settings.appearance.theme.celestial`}],he=()=>{let{t:e}=r(),t=O(e=>e.systemInfo),n=O(e=>e.setSystemInfo),i=ne(e=>e.applyInstanceTheme),[a,o]=(0,X.useState)(null),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(!1),[f,p]=(0,X.useState)(0);(0,X.useEffect)(()=>{let e=!1;return P.getDefaultTheme().then(t=>{e||(t.success&&t.data?o(K(t.data.theme)):u(!0))}).catch(()=>{e||u(!0)}),()=>{e=!0}},[f]);let m=async r=>{if(a&&a.mode!==r){c(!0);try{let s=await P.setDefaultTheme({...a,mode:r});if(!s.success||!s.data)throw Error(s.error||`Default theme update failed.`);let c=K(s.data.theme);o(c),t&&n({...t,defaultTheme:c}),i(c),d.success(e(`userManager.defaultTheme.saved`))}catch{d.error(e(`userManager.defaultTheme.saveFailed`))}finally{c(!1)}}};return(0,Z.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-[1_1_18rem]`,children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.defaultTheme.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.defaultTheme.description`)})]}),a===null&&l?(0,Z.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>{u(!1),p(e=>e+1)},children:e(`common.retry`)}):(0,Z.jsx)(`div`,{role:`radiogroup`,"aria-label":e(`userManager.defaultTheme.title`),className:`flex max-w-full flex-wrap gap-2`,children:me.map(({mode:t,icon:n,key:r})=>{let i=a?.mode===t;return(0,Z.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":i,disabled:s||a===null,onClick:()=>void m(t),className:q(`flex min-h-11 max-w-full items-center gap-2 rounded-lg border px-3 py-2 text-sm text-ink transition-colors focus:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-500/40 disabled:cursor-not-allowed disabled:opacity-60`,i?`border-line-strong bg-surface-subtle`:`border-line hover:bg-interactive-hover`),children:[(0,Z.jsx)(n,{className:`h-4 w-4`,"aria-hidden":`true`}),e(r)]},t)})})]})})},ge=()=>{let{t:e}=r(),t=(0,X.useId)(),[n,i]=(0,X.useState)(null),[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(!1),[f,p]=(0,X.useState)(0);return(0,X.useEffect)(()=>{let e=!1;return N.getAccessMode().then(t=>{e||(t.success&&t.data?(i(t.data.mode),o(t.data.lockedByEnv)):u(!0))}).catch(()=>{e||u(!0)}),()=>{e=!0}},[f]),(0,Z.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{id:t,className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.tools.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.tools.description`)}),a&&(0,Z.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400 mt-1`,children:e(`userManager.tools.lockedByEnv`)})]}),n===null&&l?(0,Z.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>{u(!1),p(e=>e+1)},children:e(`common.retry`)}):(0,Z.jsx)(W,{"aria-labelledby":t,checked:n===`all-users`,onChange:async t=>{let n=t?`all-users`:`admins`;c(!0);try{let t=await N.setAccessMode(n);if(!t.success)throw Error(t.error||`Tool access update failed.`);i(n),d.success(e(`userManager.tools.saved`))}catch{d.error(e(`userManager.tools.saveFailed`))}finally{c(!1)}},disabled:s||n===null||a})]})})},_e={stt:{mode:`all-users`,lockedByEnv:!1},tts:{mode:`all-users`,lockedByEnv:!1},"voice-mode":{mode:`all-users`,lockedByEnv:!1},"voice-cloning":{mode:`all-users`,lockedByEnv:!1}},ve={getModes:async()=>re()?J(_e):(await ie.get(`/voice-access`)).data,setMode:async(e,t)=>re()?J({feature:e,mode:t}):(await ie.put(`/voice-access/${encodeURIComponent(e)}`,{mode:t})).data},ye=[{key:`stt`,labelKey:`userManager.voice.features.stt`},{key:`tts`,labelKey:`userManager.voice.features.tts`},{key:`voice-mode`,labelKey:`userManager.voice.features.voiceMode`},{key:`voice-cloning`,labelKey:`userManager.voice.features.voiceCloning`}],be=()=>{let{t:e}=r(),t=(0,X.useId)(),[n,i]=(0,X.useState)(null),[a,o]=(0,X.useState)(null),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(0);(0,X.useEffect)(()=>{let e=!1;return ve.getModes().then(t=>{e||(t.success&&t.data?i(t.data):c(!0))}).catch(()=>{e||c(!0)}),()=>{e=!0}},[l]);let f=async(t,n)=>{let r=n?`all-users`:`admins`;o(t);try{let n=await ve.setMode(t,r);if(!n.success)throw Error(n.error||`Voice access update failed.`);i(e=>e&&{...e,[t]:{...e[t],mode:r}}),d.success(e(`userManager.voice.saved`))}catch{d.error(e(`userManager.voice.saveFailed`))}finally{o(null)}};return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.voice.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.voice.description`)})]}),n===null&&s&&(0,Z.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>{c(!1),u(e=>e+1)},children:e(`common.retry`)})]}),(0,Z.jsx)(`div`,{className:`mt-3 space-y-2`,children:ye.map(r=>{let i=n?.[r.key];return(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{id:`${t}-${r.key}`,className:`text-xs text-gray-700 dark:text-gray-300`,children:e(r.labelKey)}),i?.lockedByEnv&&(0,Z.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400`,children:e(`userManager.voice.lockedByEnv`)})]}),(0,Z.jsx)(W,{"aria-labelledby":`${t}-${r.key}`,checked:i?.mode===`all-users`,onChange:e=>f(r.key,e),disabled:i===void 0||a===r.key||i.lockedByEnv})]},r.key)})})]})},xe=()=>{let{t:e}=r(),t=(0,X.useId)(),[n,i]=(0,X.useState)(null),[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(0);(0,X.useEffect)(()=>{let e=!1;return ae.getAccess().then(t=>{e||(t.success&&t.data?i(t.data):c(!0))}).catch(()=>{e||c(!0)}),()=>{e=!0}},[l]);let f=async t=>{let n=t?`all-users`:`admins`;o(!0);try{if(!(await ae.setAccessMode(n)).success)throw Error(`Decision models access update failed.`);i(e=>e&&{...e,mode:n}),d.success(e(`userManager.decisionAccess.saved`))}catch{d.error(e(`userManager.decisionAccess.saveFailed`))}finally{o(!1)}};return(0,Z.jsx)(`div`,{"data-testid":`decision-access-settings`,className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{id:t,className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.decisionAccess.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.decisionAccess.description`)}),n?.lockedByEnv&&(0,Z.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400 mt-1`,children:e(`userManager.decisionAccess.lockedByEnv`)})]}),n===null&&s?(0,Z.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>{c(!1),u(e=>e+1)},children:e(`common.retry`)}):(0,Z.jsx)(W,{"aria-labelledby":t,checked:n?.mode===`all-users`,onChange:e=>void f(e),disabled:a||n===null||n.lockedByEnv})]})})},Se=[`starttls`,`tls`,`none`],Ce=e=>e.replace(/<head>/i,`<head><meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; img-src data:; base-uri 'none'; form-action 'none'"><style>img { display: none; }</style>`),we=e=>({host:e.host??``,port:e.port?String(e.port):``,security:e.security??`starttls`,username:e.username??``,password:``,from:e.from??``,appUrl:e.appUrl??``,rejectUnauthorized:e.rejectUnauthorized!==!1,emailTheme:e.emailTheme??`light`}),Te=()=>{let{t:e,i18n:t}=r(),n=(0,X.useId)(),i=(0,X.useId)(),[a,o]=(0,X.useState)(null),[s,c]=(0,X.useState)(null),[l,f]=(0,X.useState)(``),[p,m]=(0,X.useState)(!1),[h,g]=(0,X.useState)(!1),[_,v]=(0,X.useState)(!1),[y,b]=(0,X.useState)(!1),[x,S]=(0,X.useState)(0),[C,w]=(0,X.useState)(null),[ee,T]=(0,X.useState)(0),E=s?.emailTheme,D=E?`${E}:${ee}:${t.resolvedLanguage}`:null,O=C?.key===D?C:null,A=O?.html===null;(0,X.useEffect)(()=>{if(!E||!D)return;let t=!1;return k.preview({emailTheme:E,heading:e(`userManager.emailNotifications.previewHeading`),lines:[e(`userManager.emailNotifications.previewIntro`)],markdown:e(`userManager.emailNotifications.previewMarkdown`),linkLabel:e(`userManager.emailNotifications.previewLinkLabel`)}).then(e=>{t||(e.success&&e.data?w({key:D,html:e.data.html}):w({key:D,html:null}))}).catch(()=>{t||w({key:D,html:null})}),()=>{t=!0}},[E,D,e]),(0,X.useEffect)(()=>{let e=!1;return k.getSettings().then(t=>{e||(t.success&&t.data?(o(t.data),c(we(t.data)),f(t.data.recipient??``)):b(!0))}).catch(()=>{e||b(!0)}),()=>{e=!0}},[x]);let j=e=>{o(e),c(we(e)),v(!1)},M=(e,t)=>{let n=e.response?.data;return n?.error?n.error:n?.message?n.message:e instanceof Error&&e.message?e.message:t},N=async()=>{if(s){m(!0);try{let t=await k.updateSettings({host:s.host.trim(),port:s.port.trim(),security:s.security,username:s.username.trim(),from:s.from.trim(),appUrl:s.appUrl.trim(),rejectUnauthorized:s.rejectUnauthorized,emailTheme:s.emailTheme,...s.password?{password:s.password}:_?{password:``}:{}});if(!t.success||!t.data)throw Error(t.error||e(`userManager.emailNotifications.saveFailed`));j(t.data),d.success(e(`userManager.emailNotifications.saved`))}catch(t){d.error(M(t,e(`userManager.emailNotifications.saveFailed`)))}finally{m(!1)}}},P=async t=>{m(!0);try{let n=await k.updateSettings({enabled:t});if(!n.success||!n.data)throw Error(n.error||e(`userManager.emailNotifications.saveFailed`));j(n.data),d.success(e(t?`userManager.emailNotifications.enabledToast`:`userManager.emailNotifications.disabledToast`))}catch(t){d.error(M(t,e(`userManager.emailNotifications.saveFailed`)))}finally{m(!1)}},F=async()=>{g(!0);try{let t=await k.test(l.trim()||void 0);if(!t.success||!t.data?.ok)throw Error(t.error||e(`userManager.emailNotifications.testFailed`));d.success(t.data.sentTo?e(`userManager.emailNotifications.testSent`,{address:t.data.sentTo}):e(`userManager.emailNotifications.testConnected`))}catch(t){d.error(M(t,e(`userManager.emailNotifications.testFailed`)))}finally{g(!1)}},I=(e,t)=>c(n=>n&&{...n,[e]:t}),L=t=>a?.sources?.[t]===`env`?e(`userManager.emailNotifications.fromEnvironment`):null,R=a!==null&&s!==null&&(JSON.stringify(we(a))!==JSON.stringify({...s,password:``})||s.password.length>0||_),B=`mb-1 block text-sm font-medium text-gray-900 dark:text-gray-100`,H=`mb-2 block text-xs text-gray-500 dark:text-gray-400`;return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4 space-y-4`,"data-testid":`email-notification-settings`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`h3`,{id:n,className:`flex items-center gap-2 text-sm font-semibold text-gray-900 dark:text-gray-100`,children:[(0,Z.jsx)(u,{className:`h-4 w-4 text-primary-500`}),e(`userManager.emailNotifications.title`)]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-gray-400`,children:e(`userManager.emailNotifications.description`)})]}),(0,Z.jsx)(`div`,{"data-testid":`email-notifications-enabled`,children:(0,Z.jsx)(W,{"aria-labelledby":n,checked:a?.enabled===!0,onChange:e=>void P(e),disabled:p||a===null||!a.enabled&&!a.configured})})]}),y&&(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-800 dark:border-amber-900/60 dark:bg-amber-950/40 dark:text-amber-200`,children:[(0,Z.jsx)(`span`,{children:e(`userManager.emailNotifications.loadFailed`)}),(0,Z.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>{b(!1),S(e=>e+1)},children:e(`common.retry`)})]}),s&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[2fr_1fr]`,children:[(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsx)(`span`,{className:B,children:e(`userManager.emailNotifications.hostLabel`)}),(0,Z.jsx)(`span`,{className:H,children:L(`host`)??e(`userManager.emailNotifications.hostHint`)}),(0,Z.jsx)(z,{value:s.host,onChange:e=>I(`host`,e.target.value),placeholder:`smtp.example.com`,spellCheck:!1,dir:`ltr`,"data-testid":`email-smtp-host`})]}),(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsx)(`span`,{className:B,children:e(`userManager.emailNotifications.portLabel`)}),(0,Z.jsx)(`span`,{className:H,children:L(`port`)??e(`userManager.emailNotifications.portHint`)}),(0,Z.jsx)(z,{type:`number`,min:1,max:65535,value:s.port,onChange:e=>I(`port`,e.target.value),placeholder:s.security===`tls`?`465`:`587`,dir:`ltr`,"data-testid":`email-smtp-port`})]})]}),(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsx)(`span`,{className:B,children:e(`userManager.emailNotifications.securityLabel`)}),(0,Z.jsx)(`span`,{className:H,children:L(`security`)??e(`userManager.emailNotifications.securityHint`)}),(0,Z.jsx)(V,{value:s.security,onChange:e=>I(`security`,e.target.value),options:Se.map(t=>({value:t,label:e(`userManager.emailNotifications.security.${t}`)})),"data-testid":`email-smtp-security`})]}),(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-4 sm:pt-1`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`span`,{id:i,className:B,children:e(`userManager.emailNotifications.verifyLabel`)}),(0,Z.jsx)(`span`,{className:`block text-xs text-gray-500 dark:text-gray-400`,children:e(`userManager.emailNotifications.verifyHint`)})]}),(0,Z.jsx)(W,{"aria-labelledby":i,checked:s.rejectUnauthorized,onChange:e=>I(`rejectUnauthorized`,e),disabled:p||s.security===`none`})]})]}),(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsx)(`span`,{className:B,children:e(`userManager.emailNotifications.usernameLabel`)}),(0,Z.jsx)(`span`,{className:H,children:L(`username`)??e(`userManager.emailNotifications.usernameHint`)}),(0,Z.jsx)(z,{value:s.username,onChange:e=>I(`username`,e.target.value),autoComplete:`off`,spellCheck:!1,dir:`ltr`,"data-testid":`email-smtp-username`})]}),(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsx)(`span`,{className:B,children:e(`userManager.emailNotifications.passwordLabel`)}),(0,Z.jsx)(`span`,{className:H,children:L(`password`)??(a?.passwordConfigured?e(`userManager.emailNotifications.passwordStored`):e(`userManager.emailNotifications.passwordHint`))}),(0,Z.jsx)(z,{type:`password`,value:s.password,onChange:e=>{I(`password`,e.target.value),e.target.value&&v(!1)},autoComplete:`new-password`,placeholder:a?.passwordConfigured?`••••••••`:``,dir:`ltr`,"data-testid":`email-smtp-password`}),a?.passwordConfigured&&a.sources?.password===`stored`&&!s.password&&(0,Z.jsxs)(`label`,{className:`mt-2 flex items-center gap-2 text-xs text-gray-500 dark:text-gray-400`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:_,onChange:e=>v(e.target.checked)}),e(`userManager.emailNotifications.clearPassword`)]})]})]}),(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsx)(`span`,{className:B,children:e(`userManager.emailNotifications.fromLabel`)}),(0,Z.jsx)(`span`,{className:H,children:L(`from`)??e(`userManager.emailNotifications.fromHint`)}),(0,Z.jsx)(z,{value:s.from,onChange:e=>I(`from`,e.target.value),placeholder:`Libre WebUI <notifications@example.com>`,spellCheck:!1,dir:`ltr`,"data-testid":`email-smtp-from`})]}),(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsx)(`span`,{className:B,children:e(`userManager.emailNotifications.appUrlLabel`)}),(0,Z.jsx)(`span`,{className:H,children:L(`appUrl`)??e(`userManager.emailNotifications.appUrlHint`)}),(0,Z.jsx)(z,{value:s.appUrl,onChange:e=>I(`appUrl`,e.target.value),placeholder:`https://chat.example.com`,spellCheck:!1,dir:`ltr`,"data-testid":`email-app-url`})]})]}),(0,Z.jsxs)(`fieldset`,{className:`border-t border-gray-200 dark:border-dark-300 pt-3 space-y-3`,children:[(0,Z.jsx)(`legend`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:e(`userManager.emailNotifications.templateTitle`)}),(0,Z.jsx)(`p`,{className:H,children:e(`userManager.emailNotifications.templateHint`)}),(0,Z.jsxs)(`label`,{className:`block sm:max-w-xs`,children:[(0,Z.jsx)(`span`,{className:B,children:e(`userManager.emailNotifications.themeLabel`)}),(0,Z.jsx)(V,{value:s.emailTheme,onChange:e=>I(`emailTheme`,e.target.value),disabled:p,"data-testid":`email-template-theme`,options:[{value:`light`,label:e(`userManager.emailNotifications.themeLight`)},{value:`dark`,label:e(`userManager.emailNotifications.themeDark`)}]})]}),(0,Z.jsxs)(`div`,{"aria-busy":!O,children:[(0,Z.jsx)(`h4`,{className:B,children:e(`userManager.emailNotifications.previewTitle`)}),A?(0,Z.jsxs)(`div`,{role:`status`,className:`flex items-center gap-3`,children:[(0,Z.jsx)(`p`,{className:H,children:e(`userManager.emailNotifications.previewFailed`)}),(0,Z.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>T(e=>e+1),children:e(`common.retry`)})]}):O?.html?(0,Z.jsx)(`iframe`,{title:e(`userManager.emailNotifications.previewTitle`),srcDoc:Ce(O.html),sandbox:``,referrerPolicy:`no-referrer`,className:`h-96 w-full rounded-lg border border-gray-200 dark:border-dark-300 bg-white`,"data-testid":`email-template-preview`}):(0,Z.jsx)(`p`,{role:`status`,className:H,children:e(`userManager.emailNotifications.previewLoading`)})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 border-t border-gray-200 dark:border-dark-300 pt-3 sm:flex-row sm:items-end sm:justify-between`,children:[(0,Z.jsxs)(`label`,{className:`block sm:max-w-xs sm:flex-1`,children:[(0,Z.jsx)(`span`,{className:B,children:e(`userManager.emailNotifications.testRecipientLabel`)}),(0,Z.jsx)(`span`,{className:H,children:e(`userManager.emailNotifications.testRecipientHint`)}),(0,Z.jsx)(z,{type:`email`,value:l,onChange:e=>f(e.target.value),placeholder:`you@example.com`,spellCheck:!1,dir:`ltr`,"data-testid":`email-test-recipient`})]}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Z.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>void F(),disabled:h||p||!a?.configured||R,title:R?e(`userManager.emailNotifications.saveBeforeTest`):void 0,"data-testid":`email-test-button`,children:e(h?`userManager.emailNotifications.testing`:`userManager.emailNotifications.test`)}),(0,Z.jsx)(U,{size:`sm`,onClick:()=>void N(),disabled:p||!R,"data-testid":`email-save-button`,children:e(p?`userManager.emailNotifications.saving`:`userManager.emailNotifications.save`)})]})]})]})]})},Ee=()=>{let{t:e}=r(),t=(0,X.useId)(),[n,i]=(0,X.useState)(null),[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(0);return(0,X.useEffect)(()=>{let e=!1;return A.getMfaPolicy().then(t=>{e||(t.success&&t.data?i(t.data):c(!0))}).catch(()=>{e||c(!0)}),()=>{e=!0}},[l]),(0,Z.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.mfaPolicy.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.mfaPolicy.description`)})]}),n===null&&s&&(0,Z.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>{c(!1),u(e=>e+1)},children:e(`common.retry`)})]}),(0,Z.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{id:t,className:`text-sm text-gray-900 dark:text-gray-100`,children:e(`userManager.mfaPolicy.requireAll`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:n?.locked?e(`userManager.mfaPolicy.lockedByEnv`):e(`userManager.mfaPolicy.requireAllHint`)})]}),(0,Z.jsx)(W,{"aria-labelledby":t,checked:n?.mode===`required`,disabled:n===null||n.locked||a,onChange:async t=>{let n=t?`required`:`optional`;o(!0);try{let t=await A.setMfaPolicy(n);if(!t.success||!t.data)throw Error(t.error||`MFA policy update failed.`);i(t.data),d.success(e(`userManager.mfaPolicy.saved`))}catch{d.error(e(`userManager.mfaPolicy.saveFailed`))}finally{o(!1)}}})]})]})},De=()=>{let{t:e,i18n:t}=r(),[n,i]=(0,X.useState)([]),[a,o]=(0,X.useState)([]),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(!0),[f,m]=(0,X.useState)(!1),[h,g]=(0,X.useState)(``),[_,b]=(0,X.useState)(``),[x,S]=(0,X.useState)(!1),[w,E]=(0,X.useState)(null),[D,O]=(0,X.useState)(``),[k,A]=(0,X.useState)(null),[N,P]=(0,X.useState)(``),[F,I]=(0,X.useState)(null),[L,R]=(0,X.useState)(!1),B=(0,X.useMemo)(()=>{let e=new Map;return a.forEach(t=>e.set(t.id,t.username)),e},[a]),H=(0,X.useCallback)(async()=>{u(!0),c(!1);try{let[t,n]=await Promise.all([j.getGroups(),M.getUsers()]);if(!t.success||!t.data)throw Error(t.error||e(`userManager.groups.loadFailed`));i(t.data),n.success&&n.data&&o(n.data)}catch{c(!0)}finally{u(!1)}},[e]);(0,X.useEffect)(()=>{let e=setTimeout(()=>void H(),0);return()=>clearTimeout(e)},[H]);let W=async t=>{if(t.preventDefault(),!h.trim())d.error(e(`userManager.groups.nameRequired`,`Give the group a name.`));else{S(!0);try{let t=await j.createGroup({name:h.trim(),description:_.trim()||void 0});if(!t.success)throw Error(t.error||e(`userManager.groups.createFailed`));g(``),b(``),m(!1),d.success(e(`userManager.groups.created`,`Group created.`)),await H()}catch(t){d.error(t instanceof Error&&t.message?t.message:e(`userManager.groups.createFailed`,`The group could not be created.`))}finally{S(!1)}}},te=async t=>{if(await oe({title:e(`userManager.groups.deleteConfirmTitle`,{name:t.name}),description:e(`userManager.groups.deleteConfirmDescription`),confirmLabel:e(`userManager.groups.deleteGroup`),destructive:!0})){A(t.id);try{let n=await j.deleteGroup(t.id);if(!n.success)throw Error(n.error||e(`userManager.groups.deleteFailed`));d.success(e(`userManager.groups.deleted`,`Group deleted.`)),w===t.id&&E(null),await H()}catch(t){d.error(t instanceof Error&&t.message?t.message:e(`userManager.groups.deleteFailed`,`The group could not be deleted.`))}finally{A(null)}}},G=async t=>{if(D){A(t.id);try{let n=await j.addGroupMember(t.id,D);if(!n.success)throw Error(n.error||e(`userManager.groups.memberAddFailed`));O(``),d.success(e(`userManager.groups.memberAdded`,`Member added.`)),await H()}catch(t){d.error(t instanceof Error&&t.message?t.message:e(`userManager.groups.memberAddFailed`,`The member could not be added.`))}finally{A(null)}}},K=async(t,n)=>{A(t.id);try{let r=await j.removeGroupMember(t.id,n);if(!r.success)throw Error(r.error||e(`userManager.groups.memberRemoveFailed`));d.success(e(`userManager.groups.memberRemoved`,`Member removed.`)),await H()}catch(t){d.error(t instanceof Error&&t.message?t.message:e(`userManager.groups.memberRemoveFailed`,`The member could not be removed.`))}finally{A(null)}},ne=async t=>{if(P(t),I(null),t){R(!0);try{let n=await j.getEffectiveAccess(t);if(!n.success||!n.data)throw Error(n.error||e(`userManager.groups.accessLookupFailed`));I(n.data)}catch(t){d.error(t instanceof Error&&t.message?t.message:e(`userManager.groups.accessLookupFailed`,`The effective access could not be loaded.`))}finally{R(!1)}}},q=e=>e.map(e=>({value:e.id,label:e.username}));return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`h4`,{className:`flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-gray-100`,children:[(0,Z.jsx)(C,{className:`h-4 w-4 text-primary-500`}),e(`userManager.groups.title`,`Groups`)]}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.groups.description`,`Group accounts to manage shared access, and inspect what any account can effectively do.`)})]}),s?(0,Z.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>void H(),children:e(`common.retry`)}):(0,Z.jsxs)(U,{size:`sm`,variant:`outline`,onClick:()=>m(e=>!e),className:`gap-1.5`,children:[(0,Z.jsx)(ee,{size:14}),e(`userManager.groups.newGroup`,`New group`)]})]}),f&&(0,Z.jsxs)(`form`,{onSubmit:W,className:`mt-4 rounded-lg border border-gray-200 dark:border-dark-300 bg-gray-50 dark:bg-dark-50 p-4 space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsx)(`span`,{className:`mb-1 block text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.groups.nameLabel`,`Name`)}),(0,Z.jsx)(z,{value:h,onChange:e=>g(e.target.value)})]}),(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsx)(`span`,{className:`mb-1 block text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.groups.descriptionLabel`,`Description (optional)`)}),(0,Z.jsx)(z,{value:_,onChange:e=>b(e.target.value)})]})]}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Z.jsx)(U,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>m(!1),children:e(`common.cancel`)}),(0,Z.jsx)(U,{type:`submit`,size:`sm`,disabled:x,children:x?e(`userManager.groups.creating`,`Creating…`):e(`userManager.groups.create`,`Create group`)})]})]}),(0,Z.jsx)(`div`,{className:`mt-4 space-y-3`,children:l?(0,Z.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`common.loading`)}):s?(0,Z.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`userManager.groups.loadFailed`,`The groups could not be loaded.`)}):n.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`userManager.groups.empty`,`No groups yet.`)}):n.map(n=>{let r=w===n.id,i=new Set(n.members.map(e=>e.user_id)),o=a.filter(e=>!i.has(e.id));return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-gray-50 dark:bg-dark-100`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 p-4`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-2 text-start`,onClick:()=>{E(r?null:n.id),O(``)},"aria-expanded":r,children:[r?(0,Z.jsx)(y,{className:`h-4 w-4 shrink-0 text-gray-500 dark:text-gray-400`}):(0,Z.jsx)(p,{className:`h-4 w-4 shrink-0 text-gray-500 dark:text-gray-400`}),(0,Z.jsxs)(`span`,{className:`min-w-0`,children:[(0,Z.jsxs)(`span`,{className:`block truncate text-sm font-medium text-gray-900 dark:text-gray-100`,children:[n.name,(0,Z.jsx)(`span`,{className:`ms-2 text-xs font-normal text-gray-500 dark:text-gray-400`,children:e(`userManager.groups.memberCount`,{count:n.members.length,defaultValue:`Members: {{count}}`})})]}),n.description&&(0,Z.jsx)(`span`,{className:`block truncate text-xs text-gray-500 dark:text-gray-400`,children:n.description})]})]}),(0,Z.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>void te(n),disabled:k===n.id,"aria-label":e(`userManager.groups.deleteGroup`,`Delete group`),className:`text-error-700 hover:border-error-500/40 hover:bg-error-500/10 hover:text-error-800 dark:text-error-400 dark:hover:text-error-300`,children:(0,Z.jsx)(T,{size:16})})]}),r&&(0,Z.jsxs)(`div`,{className:`border-t border-gray-200 dark:border-dark-300 p-4 space-y-3`,children:[n.members.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`userManager.groups.noMembers`,`No members yet.`)}):(0,Z.jsx)(`div`,{className:`space-y-2`,children:n.members.map(r=>(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-50 px-3 py-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`p`,{className:`truncate text-sm text-gray-900 dark:text-gray-100`,children:B.get(r.user_id)||r.user_id}),(0,Z.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[e(`userManager.groups.addedAt`,`Added`),`:`,` `,new Date(r.added_at).toLocaleDateString(t.language)]})]}),(0,Z.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>void K(n,r.user_id),disabled:k===n.id,"aria-label":e(`userManager.groups.removeMember`,`Remove member`),children:(0,Z.jsx)(v,{size:16})})]},r.user_id))}),o.length>0&&(0,Z.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,Z.jsx)(`div`,{className:`flex-1`,children:(0,Z.jsx)(V,{label:e(`userManager.groups.addMember`,`Add member`),value:D,onChange:e=>O(e.target.value),options:[{value:``,label:e(`userManager.groups.selectUser`,`Select a user…`)},...q(o)]})}),(0,Z.jsx)(U,{size:`sm`,onClick:()=>void G(n),disabled:!D||k===n.id,className:`mb-0.5`,children:e(`userManager.groups.add`,`Add`)})]})]})]},n.id)})}),(0,Z.jsxs)(`div`,{className:`mt-6 border-t border-gray-200 dark:border-dark-300 pt-4 space-y-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.groups.effectiveTitle`,`Effective access`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.groups.effectiveDescription`,`Pick an account to see the access it ends up with across role, groups, and grants.`)})]}),(0,Z.jsx)(V,{"aria-label":e(`userManager.groups.effectiveTitle`,`Effective access`),value:N,onChange:e=>void ne(e.target.value),options:[{value:``,label:e(`userManager.groups.selectUser`,`Select a user…`)},...q(a)]}),L&&(0,Z.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`common.loading`)}),F&&!L&&(0,Z.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-gray-50 dark:bg-dark-50 p-4 space-y-3`,children:[(0,Z.jsxs)(`p`,{className:`text-sm text-gray-900 dark:text-gray-100`,children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:F.username}),(0,Z.jsxs)(`span`,{className:`text-gray-500 dark:text-gray-400`,children:[` · `,e(`userManager.groups.roleLabel`,`Role`),`:`,` `,e(`userManager.roles.${F.role}`,{defaultValue:F.role}),` · `,e(`userManager.groups.statusLabel`,`Status`),`:`,` `,e(`userManager.groups.statuses.${F.status}`,{defaultValue:F.status})]})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`mb-1 text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`userManager.groups.memberOf`,`Groups`)}),F.groups.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`common.none`)}):(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:F.groups.map(e=>(0,Z.jsx)(`span`,{className:`rounded-full bg-primary-100 dark:bg-primary-900/30 px-2 py-0.5 text-xs text-primary-700 dark:text-primary-300`,children:e.name},e.id))})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`mb-1 text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`userManager.groups.featuresLabel`,`Feature access`)}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Object.entries(F.features).map(([t,n])=>(0,Z.jsxs)(`span`,{className:n?`rounded-full bg-success-100 px-2 py-0.5 text-xs text-success-800 dark:bg-success-900/30 dark:text-success-300`:`rounded-full bg-surface-subtle px-2 py-0.5 text-xs text-ink-muted`,children:[e(`userManager.groups.features.${t}`,{defaultValue:t}),`: `,e(n?`common.yes`:`common.no`)]},t))})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`mb-1 text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`userManager.groups.grantsLabel`,`Grants`)}),F.grants.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`common.none`)}):(0,Z.jsx)(`div`,{className:`space-y-1`,children:F.grants.map(t=>(0,Z.jsxs)(`p`,{className:`text-xs text-gray-700 dark:text-gray-300`,children:[t.resourceType,`/`,t.resourceId,` ·`,` `,t.permission,` `,(0,Z.jsxs)(`span`,{className:`text-gray-500 dark:text-gray-400`,children:[`(`,e(`userManager.groups.grantVia`,`via`),` `,e(`userManager.groups.grantViaKinds.${t.via}`,{defaultValue:t.via}),`)`]})]},t.id))})]})]})]})]})},Oe={success:`bg-success-100 text-success-800 dark:bg-success-900/30 dark:text-success-300`,denied:`bg-warning-500/15 text-ink`,failure:`bg-error-100 text-error-800 dark:bg-error-900/30 dark:text-error-200`},ke=()=>{let{t:e,i18n:t}=r(),n=(0,X.useId)(),[i,a]=(0,X.useState)([]),[o,s]=(0,X.useState)(!0),[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(null),[m,h]=(0,X.useState)(``),[g,_]=(0,X.useState)(``),[v,b]=(0,X.useState)(`50`),x=(0,X.useCallback)(async()=>{s(!0),l(!1);try{let t=Number(v),n=await j.getAuditEvents({action:m.trim()||void 0,result:g||void 0,limit:Number.isInteger(t)&&t>0?t:void 0});if(!n.success||!n.data)throw Error(n.error||e(`userManager.audit.loadFailed`));a(n.data)}catch{l(!0)}finally{s(!1)}},[m,g,v,e]);(0,X.useEffect)(()=>{let e=setTimeout(()=>void x(),0);return()=>clearTimeout(e)},[]);let C=t=>{switch(t){case`success`:return e(`userManager.audit.resultSuccess`,`Success`);case`denied`:return e(`userManager.audit.resultDenied`,`Denied`);case`failure`:return e(`userManager.audit.resultFailure`,`Failure`);default:return t}};return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`h4`,{className:`flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-gray-100`,children:[(0,Z.jsx)(S,{className:`h-4 w-4 text-primary-500`}),e(`userManager.audit.title`,`Security audit log`)]}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.audit.description`,`Recent sign-ins, permission checks, and administrative changes on this instance.`)})]}),(0,Z.jsxs)(U,{size:`sm`,variant:`outline`,type:`submit`,form:n,disabled:o,className:`gap-1.5`,children:[(0,Z.jsx)(f,{size:14,className:o?`animate-spin`:void 0}),e(`common.refresh`)]})]}),(0,Z.jsxs)(`form`,{id:n,onSubmit:e=>{e.preventDefault(),x()},className:`mt-4 grid gap-3 sm:grid-cols-3`,children:[(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsx)(`span`,{className:`mb-1 block text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`userManager.audit.actionFilter`,`Action`)}),(0,Z.jsx)(z,{value:m,onChange:e=>h(e.target.value),placeholder:e(`userManager.audit.actionPlaceholder`,`e.g. auth.login`),spellCheck:!1,dir:`ltr`})]}),(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsx)(`span`,{className:`mb-1 block text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`userManager.audit.resultFilter`,`Result`)}),(0,Z.jsx)(V,{value:g,onChange:e=>_(e.target.value),options:[{value:``,label:e(`common.all`)},{value:`success`,label:e(`userManager.audit.resultSuccess`,`Success`)},{value:`denied`,label:e(`userManager.audit.resultDenied`,`Denied`)},{value:`failure`,label:e(`userManager.audit.resultFailure`,`Failure`)}]})]}),(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsx)(`span`,{className:`mb-1 block text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`userManager.audit.limitFilter`,`Limit`)}),(0,Z.jsx)(z,{type:`number`,min:1,max:500,value:v,onChange:e=>b(e.target.value),dir:`ltr`})]})]}),(0,Z.jsx)(`div`,{className:`mt-4 space-y-2`,children:o?(0,Z.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`common.loading`)}):c?(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`userManager.audit.loadFailed`,`The audit log could not be loaded.`)}),(0,Z.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>void x(),children:e(`common.retry`)})]}):i.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`userManager.audit.empty`,`No audit events recorded yet.`)}):i.map(n=>{let r=u===n.id,i=n.details&&Object.keys(n.details).length>0;return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-gray-50 dark:bg-dark-50`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-3 px-3 py-2 text-start`,onClick:()=>d(r?null:n.id),"aria-expanded":r,children:[i?r?(0,Z.jsx)(y,{className:`h-4 w-4 shrink-0 text-gray-500 dark:text-gray-400`}):(0,Z.jsx)(p,{className:`h-4 w-4 shrink-0 text-gray-500 dark:text-gray-400`}):(0,Z.jsx)(`span`,{className:`h-4 w-4 shrink-0`}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:n.action}),(0,Z.jsx)(`span`,{className:`rounded-full px-2 py-0.5 text-xs font-medium ${Oe[n.result]||`bg-surface-subtle text-ink-muted`}`,children:C(n.result)})]}),(0,Z.jsxs)(`span`,{className:`mt-0.5 block truncate text-xs text-gray-500 dark:text-gray-400`,children:[new Date(n.occurredAt).toLocaleString(t.language),` · `,e(`userManager.audit.actor`,`Actor`),`:`,` `,n.actorUserId||n.actorKind,n.targetType&&(0,Z.jsxs)(Z.Fragment,{children:[` · `,e(`userManager.audit.target`,`Target`),`:`,` `,n.targetType,n.targetId?`/${n.targetId}`:``]})]})]})]}),r&&i&&(0,Z.jsx)(`pre`,{dir:`ltr`,className:`mx-3 mb-3 overflow-x-auto rounded-md bg-white dark:bg-dark-100 border border-gray-200 dark:border-dark-300 p-3 text-xs text-gray-700 dark:text-gray-300`,children:JSON.stringify(n.details,null,2)})]},n.id)})})]})},Ae=()=>{let{t:e}=r(),t=(0,X.useId)(),[n,i]=(0,X.useState)(null),[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(0);return(0,X.useEffect)(()=>{let e=!1;return I.getModelAccess().then(t=>{e||(t.success&&t.data?i(t.data.mode):c(!0))}).catch(()=>{e||c(!0)}),()=>{e=!0}},[l]),(0,Z.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{id:t,className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.modelAccess.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.modelAccess.description`)})]}),n===null&&s?(0,Z.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>{c(!1),u(e=>e+1)},children:e(`common.retry`)}):(0,Z.jsx)(W,{"aria-labelledby":t,checked:n===`all-users`,onChange:async t=>{let n=t?`all-users`:`admins`;o(!0);try{if(!(await I.setModelAccess(n)).success)throw Error(`Model download access update failed.`);i(n),d.success(e(`userManager.modelAccess.saved`))}catch{d.error(e(`userManager.modelAccess.saveFailed`))}finally{o(!1)}},disabled:a||n===null})]})})},je=()=>{let{t:e}=r(),t=(0,X.useId)(),[n,i]=(0,X.useState)(null),[a,o]=(0,X.useState)(``),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(!1),[f,p]=(0,X.useState)(0);(0,X.useEffect)(()=>{let e=!1;return I.getSettings().then(t=>{e||(t.success&&t.data?(i(t.data),o(t.data.baseUrl)):u(!0))}).catch(()=>{e||u(!0)}),()=>{e=!0}},[f]);let m=async t=>{c(!0);try{let n=await I.updateSettings(t);if(!n.success||!n.data)throw Error(n.message||`update failed`);i(n.data),o(n.data.baseUrl),d.success(e(`userManager.ollamaProvider.saved`))}catch{d.error(e(`userManager.ollamaProvider.saveFailed`))}finally{c(!1)}},h=n!==null&&a.trim()!==n.baseUrl;return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{id:t,className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.ollamaProvider.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.ollamaProvider.description`)})]}),n===null&&l?(0,Z.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>{u(!1),p(e=>e+1)},children:e(`common.retry`)}):(0,Z.jsx)(W,{"aria-labelledby":t,checked:n?.enabled===!0,onChange:e=>void m({enabled:e}),disabled:s||n===null})]}),n!==null&&(0,Z.jsxs)(`div`,{className:`mt-3 flex items-center gap-2`,children:[(0,Z.jsx)(`input`,{className:`min-w-0 flex-1 rounded-lg border border-gray-200 bg-white px-3 py-1.5 font-mono text-xs text-gray-900 focus:border-primary-400 focus:outline-hidden dark:border-dark-300 dark:bg-dark-50 dark:text-gray-100`,value:a,onChange:e=>o(e.target.value),placeholder:`http://localhost:11434`,spellCheck:!1,"aria-label":e(`userManager.ollamaProvider.baseUrlLabel`)}),(0,Z.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>void m({baseUrl:a.trim()}),disabled:s||!h||!a.trim(),children:e(`common.save`)})]})]})},Me=()=>{let{t:e}=r(),t=(0,X.useId)(),[n,i]=(0,X.useState)(null),[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(0);return(0,X.useEffect)(()=>{let e=!1;return F.getAccess().then(t=>{e||(t.success&&t.data?i(t.data.mode):c(!0))}).catch(()=>{e||c(!0)}),()=>{e=!0}},[l]),(0,Z.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{id:t,className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.webSearchAccess.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.webSearchAccess.description`)})]}),n===null&&s?(0,Z.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>{c(!1),u(e=>e+1)},children:e(`common.retry`)}):(0,Z.jsx)(W,{"aria-labelledby":t,checked:n===`all-users`,onChange:async t=>{let n=t?`all-users`:`admins`;o(!0);try{if(!(await F.setAccess(n)).success)throw Error(`Web search access update failed.`);i(n),d.success(e(`userManager.webSearchAccess.saved`))}catch{d.error(e(`userManager.webSearchAccess.saveFailed`))}finally{o(!1)}},disabled:a||n===null})]})})},Ne=()=>{let{t:e}=r(),t=(0,X.useId)(),n=O(e=>e.refreshWorkAccess),[i,a]=(0,X.useState)(null),[o,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(!1),[u,f]=(0,X.useState)(0);return(0,X.useEffect)(()=>{let e=!1;return Y.access().then(t=>{e||(t.success&&t.data?a(t.data.mode):l(!0))}).catch(()=>{e||l(!0)}),()=>{e=!0}},[u]),(0,Z.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{id:t,className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.workAccess.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.workAccess.description`)})]}),i===null&&c?(0,Z.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>{l(!1),f(e=>e+1)},children:e(`common.retry`)}):(0,Z.jsx)(W,{"aria-labelledby":t,checked:i===`all-users`,onChange:async t=>{let r=t?`all-users`:`admins`;s(!0);try{if(!(await Y.setAccess(r)).success)throw Error(`Work access update failed.`);a(r),await n(),d.success(e(`userManager.workAccess.saved`))}catch{d.error(e(`userManager.workAccess.saveFailed`))}finally{s(!1)}},disabled:o||i===null})]})})},Pe=[`disabled`,`admins`,`all-users`],Fe=()=>{let{t:e}=r(),[t,n]=(0,X.useState)(null),[i,a]=(0,X.useState)(!1),[o,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(!1),[u,f]=(0,X.useState)(0);(0,X.useEffect)(()=>{let e=!1;return Y.agentAccess().then(t=>{e||(t.success&&t.data?(n(t.data.mode),a(t.data.lockedByEnv)):l(!0))}).catch(()=>{e||l(!0)}),()=>{e=!0}},[u]);let p=async t=>{s(!0);try{let r=await Y.setAgentAccess(t);if(!r.success||!r.data)throw Error(r.error||`Agent access update failed.`);n(r.data.mode),d.success(e(`userManager.workAgentAccess.saved`))}catch{d.error(e(`userManager.workAgentAccess.saveFailed`))}finally{s(!1)}};return(0,Z.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,"data-testid":`work-agent-access-settings`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.workAgentAccess.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.workAgentAccess.description`)}),i&&(0,Z.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400 mt-1`,children:e(`userManager.workAgentAccess.lockedByEnv`)})]}),t===null&&c?(0,Z.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>{l(!1),f(e=>e+1)},children:e(`common.retry`)}):(0,Z.jsx)(`div`,{className:`w-44`,children:(0,Z.jsx)(V,{"data-testid":`work-agent-access-mode`,"aria-label":e(`userManager.workAgentAccess.title`),value:t??`disabled`,disabled:o||t===null||i,onChange:e=>void p(e.target.value),options:Pe.map(t=>({value:t,label:e(`userManager.workAgentAccess.modes.${t}`)}))})})]})})},Q={name:``,image:``,memoryLimit:``,cpuLimit:``,pidsLimit:``,workspaceSize:``,idleMinutes:``,networkDefault:`inherit`,guiEnabled:!1,takeoverEnabled:!0,approvalsRequired:!1},Ie={...Q,name:`Work Computer`,image:`libre-work-computer:latest`,memoryLimit:`4g`,networkDefault:`on`,guiEnabled:!0},Le=e=>({name:e.name,guiEnabled:e.guiEnabled===!0,takeoverEnabled:e.takeoverEnabled!==!1,approvalsRequired:e.approvalsRequired===!0,image:e.image??``,memoryLimit:e.memoryLimit??``,cpuLimit:e.cpuLimit??``,pidsLimit:e.pidsLimit===void 0?``:String(e.pidsLimit),workspaceSize:e.workspaceSize??``,idleMinutes:e.idleTimeoutMs===void 0?``:String(e.idleTimeoutMs/6e4),networkDefault:e.networkDefault===void 0?`inherit`:e.networkDefault?`on`:`off`}),Re=e=>[e.pidsLimit,e.idleMinutes].some(e=>e.trim()!==``&&!Number.isFinite(Number(e))),ze=e=>({name:e.name.trim(),image:e.image.trim()||null,memoryLimit:e.memoryLimit.trim()||null,cpuLimit:e.cpuLimit.trim()||null,pidsLimit:e.pidsLimit.trim()?Number(e.pidsLimit):null,workspaceSize:e.workspaceSize.trim()||null,idleTimeoutMs:e.idleMinutes.trim()?Math.round(Number(e.idleMinutes)*6e4):null,networkDefault:e.networkDefault===`inherit`?null:e.networkDefault===`on`,guiEnabled:e.guiEnabled?!0:null,takeoverEnabled:e.takeoverEnabled?null:!1,approvalsRequired:e.approvalsRequired?!0:null}),Be=()=>{let{t:e}=r(),[t,n]=(0,X.useState)([]),[i,a]=(0,X.useState)(null),[o,s]=(0,X.useState)(Q),[c,l]=(0,X.useState)(!1),u=async()=>{try{let e=await Y.listPolicies();e.success&&e.data&&n(e.data)}catch{}};(0,X.useEffect)(()=>{let e=!1;return Y.listPolicies().then(t=>{!e&&t.success&&t.data&&n(t.data)}).catch(()=>{}),()=>{e=!0}},[]);let f=e=>({value:o[e],onChange:t=>s(n=>({...n,[e]:t.target.value}))}),p=async()=>{if(Re(o))d.error(e(`userManager.workPolicies.invalidNumber`));else{l(!0);try{let t=ze(o),n=i===`new`?await Y.createPolicy(t):await Y.updatePolicy(i,t);if(!n.success)throw Error(n.error||`Policy save failed.`);d.success(e(`userManager.workPolicies.saved`)),a(null),s(Q),await u()}catch(t){d.error(t instanceof Error&&t.message?t.message:e(`userManager.workPolicies.failed`))}finally{l(!1)}}},m=async t=>{if(window.confirm(e(`userManager.workPolicies.deleteConfirm`)))try{let n=await Y.deletePolicy(t.id);if(!n.success)throw Error(n.error||`Policy delete failed.`);d.success(e(`userManager.workPolicies.deleted`)),await u()}catch(t){d.error(t instanceof Error&&t.message?t.message:e(`userManager.workPolicies.failed`))}},g=(e,t,n)=>(0,Z.jsxs)(`label`,{className:`block text-xs`,children:[(0,Z.jsx)(`span`,{className:`mb-1 block font-medium text-gray-700 dark:text-gray-300`,children:t}),(0,Z.jsx)(`input`,{...f(e),placeholder:n,spellCheck:!1,className:`w-full rounded-lg border border-gray-200 bg-white px-2.5 py-1.5 text-sm text-gray-900 outline-hidden focus:border-primary-500 dark:border-dark-300 dark:bg-dark-50 dark:text-gray-100`})]});return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.workPolicies.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.workPolicies.description`)})]}),i===null&&(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Z.jsxs)(U,{size:`sm`,variant:`outline`,className:`whitespace-nowrap`,"data-testid":`work-policy-computer-preset`,onClick:()=>{s(Ie),a(`new`)},children:[(0,Z.jsx)(h,{size:14,className:`shrink-0`}),(0,Z.jsx)(`span`,{className:`ms-1.5`,children:e(`userManager.workPolicies.computerPreset`)})]}),(0,Z.jsxs)(U,{size:`sm`,variant:`outline`,className:`whitespace-nowrap`,onClick:()=>{s(Q),a(`new`)},children:[(0,Z.jsx)(ee,{size:14,className:`shrink-0`}),(0,Z.jsx)(`span`,{className:`ms-1.5`,children:e(`userManager.workPolicies.add`)})]})]})]}),t.length===0&&i===null&&(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-gray-500 dark:text-gray-400`,children:e(`userManager.workPolicies.empty`)}),t.length>0&&(0,Z.jsx)(`ul`,{className:`mt-3 divide-y divide-gray-100 dark:divide-dark-300`,children:t.map(t=>(0,Z.jsxs)(`li`,{className:`flex items-center justify-between gap-3 py-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:t.name}),(0,Z.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[11px] text-gray-500 dark:text-gray-400`,children:[t.memoryLimit,t.cpuLimit&&`cpu ${t.cpuLimit}`,t.pidsLimit&&`pids ${t.pidsLimit}`,t.workspaceSize,t.idleTimeoutMs!==void 0&&`idle ${Math.round(t.idleTimeoutMs/6e4)}m`,t.networkDefault!==void 0&&`net ${t.networkDefault?`on`:`off`}`,t.image].filter(Boolean).join(` · `)||`—`})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,Z.jsx)(U,{size:`sm`,variant:`ghost`,"aria-label":e(`userManager.workPolicies.edit`),onClick:()=>{s(Le(t)),a(t.id)},children:(0,Z.jsx)(w,{size:14})}),(0,Z.jsx)(U,{size:`sm`,variant:`ghost`,"aria-label":e(`userManager.workPolicies.delete`),onClick:()=>void m(t),children:(0,Z.jsx)(T,{size:14})})]})]},t.id))}),i!==null&&(0,Z.jsxs)(`div`,{className:`mt-4 rounded-lg border border-gray-200 p-3 dark:border-dark-300`,children:[(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[g(`name`,e(`userManager.workPolicies.name`),`heavy`),g(`memoryLimit`,e(`userManager.workPolicies.memory`),`4g`),g(`cpuLimit`,e(`userManager.workPolicies.cpu`),`4`),g(`pidsLimit`,e(`userManager.workPolicies.pids`),`512`),g(`workspaceSize`,e(`userManager.workPolicies.workspaceSize`),`20Gi`),g(`idleMinutes`,e(`userManager.workPolicies.idleMinutes`),`30`),(0,Z.jsxs)(`label`,{className:`block text-xs`,children:[(0,Z.jsx)(`span`,{className:`mb-1 block font-medium text-gray-700 dark:text-gray-300`,children:e(`userManager.workPolicies.networkDefault`)}),(0,Z.jsxs)(`select`,{...f(`networkDefault`),className:`w-full rounded-lg border border-gray-200 bg-white px-2.5 py-1.5 text-sm text-gray-900 outline-hidden focus:border-primary-500 dark:border-dark-300 dark:bg-dark-50 dark:text-gray-100`,children:[(0,Z.jsx)(`option`,{value:`inherit`,children:e(`userManager.workPolicies.networkInherit`)}),(0,Z.jsx)(`option`,{value:`on`,children:e(`userManager.workPolicies.networkOn`)}),(0,Z.jsx)(`option`,{value:`off`,children:e(`userManager.workPolicies.networkOff`)})]})]}),(0,Z.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,"data-testid":`work-policy-gui`,checked:o.guiEnabled,onChange:e=>s(t=>({...t,guiEnabled:e.target.checked})),className:`h-3.5 w-3.5 rounded-sm border-gray-300 text-primary-600 focus:ring-primary-500`}),(0,Z.jsx)(`span`,{className:`font-medium text-gray-700 dark:text-gray-300`,children:e(`userManager.workPolicies.guiEnabled`)})]}),o.guiEnabled&&(0,Z.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,"data-testid":`work-policy-takeover`,checked:o.takeoverEnabled,onChange:e=>s(t=>({...t,takeoverEnabled:e.target.checked})),className:`h-3.5 w-3.5 rounded-sm border-gray-300 text-primary-600 focus:ring-primary-500`}),(0,Z.jsx)(`span`,{className:`font-medium text-gray-700 dark:text-gray-300`,children:e(`userManager.workPolicies.takeoverEnabled`)})]}),(0,Z.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,"data-testid":`work-policy-approvals`,checked:o.approvalsRequired,onChange:e=>s(t=>({...t,approvalsRequired:e.target.checked})),className:`h-3.5 w-3.5 rounded-sm border-gray-300 text-primary-600 focus:ring-primary-500`}),(0,Z.jsx)(`span`,{className:`font-medium text-gray-700 dark:text-gray-300`,children:e(`userManager.workPolicies.approvalsRequired`)})]}),g(`image`,e(`userManager.workPolicies.image`),`node:22-bookworm@sha256:…`)]}),o.guiEnabled&&(0,Z.jsx)(`p`,{className:`mt-2 text-[11px] text-gray-500 dark:text-gray-400`,children:e(`userManager.workPolicies.computerPresetHint`)}),(0,Z.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,Z.jsx)(U,{size:`sm`,variant:`ghost`,disabled:c,onClick:()=>{a(null),s(Q)},children:e(`userManager.workPolicies.cancel`)}),(0,Z.jsx)(U,{size:`sm`,disabled:c||!o.name.trim(),onClick:()=>void p(),children:e(`userManager.workPolicies.save`)})]})]})]})},$=[{id:`users`,label:`userManager.sections.users`},{id:`groups`,label:`userManager.groups.title`},{id:`access`,label:`userManager.sections.access`},{id:`security`,label:`userManager.sections.security`},{id:`defaults`,label:`userManager.sections.defaults`}],Ve=e=>{switch(e){case`users`:return(0,Z.jsx)(ue,{});case`groups`:return(0,Z.jsx)(De,{});case`access`:return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(Ne,{}),(0,Z.jsx)(Be,{}),(0,Z.jsx)(je,{}),(0,Z.jsx)(Ae,{}),(0,Z.jsx)(Me,{}),(0,Z.jsx)(de,{}),(0,Z.jsx)(pe,{}),(0,Z.jsx)(Fe,{}),(0,Z.jsx)(ge,{}),(0,Z.jsx)(be,{}),(0,Z.jsx)(xe,{}),(0,Z.jsx)(Te,{})]});case`security`:return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(Ee,{}),(0,Z.jsx)(ke,{})]});case`defaults`:return(0,Z.jsx)(he,{})}},He=()=>{let{t:e}=r(),t=(0,X.useId)(),n=(0,X.useRef)({}),[i,a]=(0,X.useState)(`users`),[o,s]=(0,X.useState)([`users`]),c=e=>{a(e),s(t=>t.includes(e)?t:[...t,e])},l=(e,t)=>{let r=getComputedStyle(e.currentTarget).direction===`rtl`,i=$.findIndex(e=>e.id===t),a;switch(e.key){case`Home`:a=0;break;case`End`:a=$.length-1;break;case`ArrowRight`:a=i+(r?-1:1);break;case`ArrowLeft`:a=i+(r?1:-1);break;default:return}e.preventDefault();let o=$[(a+$.length)%$.length].id;c(o),n.current[o]?.focus()};return(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-5`,children:[(0,Z.jsx)(`div`,{role:`tablist`,"aria-label":e(`userManager.title`),"aria-orientation":`horizontal`,className:`-mx-1 flex gap-1 overflow-x-auto border-b border-line px-1 pb-3 pt-1 scrollbar-thin`,children:$.map(r=>(0,Z.jsx)(`button`,{ref:e=>{n.current[r.id]=e},type:`button`,role:`tab`,id:`${t}-tab-${r.id}`,"aria-controls":`${t}-panel-${r.id}`,"aria-selected":i===r.id,tabIndex:i===r.id?0:-1,onClick:()=>c(r.id),onKeyDown:e=>l(e,r.id),className:q(`min-h-11 shrink-0 rounded-xl border px-3 py-2 text-sm font-medium outline-hidden transition-colors duration-150 focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 focus-visible:ring-offset-surface motion-reduce:transition-none`,i===r.id?`border-line bg-nav-active text-ink`:`border-transparent text-ink-muted hover:bg-hover-solid hover:text-ink`),children:e(r.label)},r.id))}),$.map(e=>(0,Z.jsx)(`div`,{id:`${t}-panel-${e.id}`,role:`tabpanel`,"aria-labelledby":`${t}-tab-${e.id}`,hidden:i!==e.id,children:o.includes(e.id)&&Ve(e.id)},e.id))]})};export{He as UserManagementPanel,He as default};
@@ -1 +1 @@
1
- import"./rolldown-runtime-XKyaHtl9.js";import{i as e,t}from"./react-vendor-C1iE8mnY.js";import{s as n}from"./markdown-core-CGWDtd6X.js";import{t as r}from"./useTranslation-Bu0AxynE.js";import{t as i}from"./Button-DeV-GhQr.js";import{D as a,n as o}from"./ui-vendor-BanHlKMb.js";import"./ui-CKcr9ReZ.js";e();var s=t(),c=({notes:e,onDismiss:t})=>{let{t:c}=r();return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`div`,{className:`fixed inset-0 z-60 bg-black/55 backdrop-blur-sm transition-opacity duration-200`,onClick:t}),(0,s.jsx)(`div`,{className:`fixed inset-0 z-60 flex items-center justify-center p-4`,role:`dialog`,"aria-modal":`true`,"aria-label":c(`whatsNew.title`),onMouseDown:e=>{e.target===e.currentTarget&&t()},children:(0,s.jsxs)(`div`,{className:`flex max-h-[82vh] w-full max-w-2xl flex-col rounded-3xl border border-gray-200/80 bg-surface/95 shadow-2xl backdrop-blur-xl animate-scale-in dark:border-white/10 dark:bg-dark-25/95`,children:[(0,s.jsxs)(`div`,{className:`flex items-start justify-between px-6 pb-3 pt-6`,children:[(0,s.jsxs)(`div`,{children:[(0,s.jsx)(`h2`,{className:`text-xl font-semibold tracking-[-0.02em] text-gray-950 dark:text-dark-950`,children:c(`whatsNew.title`)}),(0,s.jsxs)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:[c(`whatsNew.releaseNotes`),` · v`,e.version,` · `,e.date]})]}),(0,s.jsx)(`button`,{onClick:t,className:`rounded-full p-2 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-900 dark:text-dark-600 dark:hover:bg-white/6 dark:hover:text-dark-900`,title:c(`common.close`),children:(0,s.jsx)(o,{className:`h-4 w-4`})})]}),(0,s.jsx)(`div`,{className:`scroll-region min-h-0 flex-1 overflow-y-auto px-6 py-3 scrollbar-thin`,children:(0,s.jsx)(n,{components:{h3:({children:e})=>(0,s.jsx)(`h3`,{className:`mb-2 mt-5 text-[11px] font-semibold uppercase tracking-widest text-primary-600 first:mt-0 dark:text-primary-400`,children:e}),ul:({children:e})=>(0,s.jsx)(`ul`,{className:`space-y-2.5`,children:e}),li:({children:e})=>(0,s.jsxs)(`li`,{className:`flex gap-2 text-[13.5px] leading-relaxed text-gray-700 dark:text-dark-700`,children:[(0,s.jsx)(`span`,{className:`mt-[7px] h-1 w-1 shrink-0 rounded-full bg-gray-300 dark:bg-dark-400`}),(0,s.jsx)(`span`,{className:`min-w-0`,children:e})]}),strong:({children:e})=>(0,s.jsx)(`strong`,{className:`font-semibold text-gray-900 dark:text-dark-900`,children:e}),a:({children:e,href:t})=>(0,s.jsx)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`text-primary-600 underline decoration-primary-300 underline-offset-2 hover:text-primary-700 dark:text-primary-400`,children:e}),code:({children:e})=>(0,s.jsx)(`code`,{className:`rounded-md border border-gray-200 bg-gray-100 px-1 py-0.5 font-mono text-[0.85em] text-gray-800 dark:border-dark-300 dark:bg-dark-200 dark:text-dark-800`,children:e}),p:({children:e})=>(0,s.jsx)(`p`,{className:`mb-2 text-[13.5px] leading-relaxed text-gray-700 dark:text-dark-700`,children:e})},children:e.body})}),(0,s.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-t border-gray-200/70 px-6 py-4 dark:border-white/8`,children:[(0,s.jsxs)(`a`,{href:`https://github.com/libre-webui/libre-webui`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex min-w-0 items-center gap-1.5 text-xs text-gray-500 transition-colors hover:text-gray-900 dark:text-dark-500 dark:hover:text-dark-900`,children:[(0,s.jsx)(a,{className:`h-3.5 w-3.5 shrink-0`}),(0,s.jsx)(`span`,{className:`truncate`,children:c(`whatsNew.starAsk`)})]}),(0,s.jsx)(i,{onClick:t,size:`sm`,children:c(`whatsNew.cta`)})]})]})})]})};export{c as WhatsNewModal};
1
+ import"./rolldown-runtime-XKyaHtl9.js";import{i as e,t}from"./react-vendor-C1iE8mnY.js";import{s as n}from"./markdown-core-CGWDtd6X.js";import{t as r}from"./useTranslation-Bu0AxynE.js";import{t as i}from"./Button-DeV-GhQr.js";import{D as a,n as o}from"./ui-vendor-CmYUVVjB.js";import"./ui-D5Ws30mx.js";e();var s=t(),c=({notes:e,onDismiss:t})=>{let{t:c}=r();return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`div`,{className:`fixed inset-0 z-60 bg-black/55 backdrop-blur-sm transition-opacity duration-200`,onClick:t}),(0,s.jsx)(`div`,{className:`fixed inset-0 z-60 flex items-center justify-center p-4`,role:`dialog`,"aria-modal":`true`,"aria-label":c(`whatsNew.title`),onMouseDown:e=>{e.target===e.currentTarget&&t()},children:(0,s.jsxs)(`div`,{className:`flex max-h-[82vh] w-full max-w-2xl flex-col rounded-3xl border border-gray-200/80 bg-surface/95 shadow-2xl backdrop-blur-xl animate-scale-in dark:border-white/10 dark:bg-dark-25/95`,children:[(0,s.jsxs)(`div`,{className:`flex items-start justify-between px-6 pb-3 pt-6`,children:[(0,s.jsxs)(`div`,{children:[(0,s.jsx)(`h2`,{className:`text-xl font-semibold tracking-[-0.02em] text-gray-950 dark:text-dark-950`,children:c(`whatsNew.title`)}),(0,s.jsxs)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:[c(`whatsNew.releaseNotes`),` · v`,e.version,` · `,e.date]})]}),(0,s.jsx)(`button`,{onClick:t,className:`rounded-full p-2 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-900 dark:text-dark-600 dark:hover:bg-white/6 dark:hover:text-dark-900`,title:c(`common.close`),children:(0,s.jsx)(o,{className:`h-4 w-4`})})]}),(0,s.jsx)(`div`,{className:`scroll-region min-h-0 flex-1 overflow-y-auto px-6 py-3 scrollbar-thin`,children:(0,s.jsx)(n,{components:{h3:({children:e})=>(0,s.jsx)(`h3`,{className:`mb-2 mt-5 text-[11px] font-semibold uppercase tracking-widest text-primary-600 first:mt-0 dark:text-primary-400`,children:e}),ul:({children:e})=>(0,s.jsx)(`ul`,{className:`space-y-2.5`,children:e}),li:({children:e})=>(0,s.jsxs)(`li`,{className:`flex gap-2 text-[13.5px] leading-relaxed text-gray-700 dark:text-dark-700`,children:[(0,s.jsx)(`span`,{className:`mt-[7px] h-1 w-1 shrink-0 rounded-full bg-gray-300 dark:bg-dark-400`}),(0,s.jsx)(`span`,{className:`min-w-0`,children:e})]}),strong:({children:e})=>(0,s.jsx)(`strong`,{className:`font-semibold text-gray-900 dark:text-dark-900`,children:e}),a:({children:e,href:t})=>(0,s.jsx)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`text-primary-600 underline decoration-primary-300 underline-offset-2 hover:text-primary-700 dark:text-primary-400`,children:e}),code:({children:e})=>(0,s.jsx)(`code`,{className:`rounded-md border border-gray-200 bg-gray-100 px-1 py-0.5 font-mono text-[0.85em] text-gray-800 dark:border-dark-300 dark:bg-dark-200 dark:text-dark-800`,children:e}),p:({children:e})=>(0,s.jsx)(`p`,{className:`mb-2 text-[13.5px] leading-relaxed text-gray-700 dark:text-dark-700`,children:e})},children:e.body})}),(0,s.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-t border-gray-200/70 px-6 py-4 dark:border-white/8`,children:[(0,s.jsxs)(`a`,{href:`https://github.com/libre-webui/libre-webui`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex min-w-0 items-center gap-1.5 text-xs text-gray-500 transition-colors hover:text-gray-900 dark:text-dark-500 dark:hover:text-dark-900`,children:[(0,s.jsx)(a,{className:`h-3.5 w-3.5 shrink-0`}),(0,s.jsx)(`span`,{className:`truncate`,children:c(`whatsNew.starAsk`)})]}),(0,s.jsx)(i,{onClick:t,size:`sm`,children:c(`whatsNew.cta`)})]})]})})]})};export{c as WhatsNewModal};