libre-webui 0.32.0 → 0.33.0

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 (107) hide show
  1. package/backend/dist/middleware/staticAssets.d.ts.map +1 -1
  2. package/backend/dist/middleware/staticAssets.js +21 -5
  3. package/backend/dist/middleware/staticAssets.js.map +1 -1
  4. package/backend/dist/services/appearanceSettingsService.d.ts +1 -1
  5. package/backend/dist/services/appearanceSettingsService.d.ts.map +1 -1
  6. package/backend/dist/services/appearanceSettingsService.js +1 -1
  7. package/backend/dist/services/appearanceSettingsService.js.map +1 -1
  8. package/backend/dist/types/index.d.ts +1 -1
  9. package/backend/dist/types/index.d.ts.map +1 -1
  10. package/backend/package.json +1 -1
  11. package/frontend/dist/artifact-runtime/.build-fingerprint +1 -1
  12. package/frontend/dist/assets/index-DegYzMyw.js +70 -0
  13. package/frontend/dist/assets/{index-DtfJNUat.css → index-gKj8Y1JB.css} +1 -1
  14. package/frontend/dist/index.html +34 -22
  15. package/frontend/dist/js/{ArtifactContainer-DG-qigOa.js → ArtifactContainer-BB6A8cT5.js} +1 -1
  16. package/frontend/dist/js/{ArtifactDemoPage-Cr_bMx_v.js → ArtifactDemoPage-Bf1dW5Z3.js} +1 -1
  17. package/frontend/dist/js/{ArtifactSandboxFrame-2WyuCg4w.js → ArtifactSandboxFrame-DsZW0Axy.js} +1 -1
  18. package/frontend/dist/js/{ArtifactSlideOutPanel-zizbFUzW.js → ArtifactSlideOutPanel-Cartcixp.js} +1 -1
  19. package/frontend/dist/js/{AutomationModal-Dgk1PzNx.js → AutomationModal-BI_3nFeg.js} +1 -1
  20. package/frontend/dist/js/{AutomationsPage-CuDSh_W2.js → AutomationsPage-ChMXj4UG.js} +1 -1
  21. package/frontend/dist/js/{AvatarUpload-D_nSLum9.js → AvatarUpload-gfZ9QWR3.js} +1 -1
  22. package/frontend/dist/js/CalendarPage-Ce1ud5St.js +1 -0
  23. package/frontend/dist/js/ChannelsPage-kl8zJ2HA.js +1 -0
  24. package/frontend/dist/js/ChatPage-Bj98c6rc.js +14 -0
  25. package/frontend/dist/js/ConnectModels-CPftHmE3.js +1 -0
  26. package/frontend/dist/js/{EvaluationsPage-C6NHj9KF.js → EvaluationsPage-Cydglp6R.js} +2 -2
  27. package/frontend/dist/js/{FirstTimeSetup-BVOPC4uh.js → FirstTimeSetup-C5cc-bc9.js} +1 -1
  28. package/frontend/dist/js/GalleryPage-Dvq2GVoH.js +1 -0
  29. package/frontend/dist/js/{HomePage-B9nkyAdS.js → HomePage-zVjADRoX.js} +1 -1
  30. package/frontend/dist/js/LibreClawPage-x0Qmtcnc.js +1 -0
  31. package/frontend/dist/js/{ModelManagerModals-B4NTpNr2.js → ModelManagerModals-K1oiXMTv.js} +1 -1
  32. package/frontend/dist/js/NotesPage-BnqBv-n1.js +3 -0
  33. package/frontend/dist/js/{PasswordStrengthMeter-CNgHwIkW.js → PasswordStrengthMeter-DVFLKG_-.js} +1 -1
  34. package/frontend/dist/js/PersonasPage-DK9-SDZQ.js +13 -0
  35. package/frontend/dist/js/{PluginUsagePage-QGOo5MZj.js → PluginUsagePage-DX9uxdRr.js} +1 -1
  36. package/frontend/dist/js/RichMessageContent-BzfhfzQ4.js +1 -0
  37. package/frontend/dist/js/{RichMessageContent-Cm7kRv3f.js → RichMessageContent-XMkRvBen.js} +1 -1
  38. package/frontend/dist/js/SettingsModal-CMOwEhkG.js +19 -0
  39. package/frontend/dist/js/{ShareDialog-CeHMOTrA.js → ShareDialog-CZpU1itx.js} +1 -1
  40. package/frontend/dist/js/{SystemPage-B1bDpa9g.js → SystemPage-BVaaKTRs.js} +1 -1
  41. package/frontend/dist/js/UserManagementPage-DdpcN4-Q.js +1 -0
  42. package/frontend/dist/js/UserManagementPanel-BxAvybHj.js +1 -0
  43. package/frontend/dist/js/{WhatsNewModal-CKkWbbNI.js → WhatsNewModal-CoFCdUpf.js} +1 -1
  44. package/frontend/dist/js/WorkPage-Du6llCSU.js +7 -0
  45. package/frontend/dist/js/api-CatP45JH.js +1 -0
  46. package/frontend/dist/js/api-DQdJeQjd.js +14 -0
  47. package/frontend/dist/js/{appNavigation-B_QjduzS.js → appNavigation-DRM2Jr4r.js} +1 -1
  48. package/frontend/dist/js/appStore-BXbVcTeo.js +2 -0
  49. package/frontend/dist/js/appVersion-BUroqcki.js +1 -0
  50. package/frontend/dist/js/{ar-DFOuR5-K.js → ar-C8Izi_rT.js} +1 -1
  51. package/frontend/dist/js/{authStore-Bl7S8bPg.js → authStore-DkqtNSYP.js} +3 -3
  52. package/frontend/dist/js/authStore-bqAN5v4N.js +1 -0
  53. package/frontend/dist/js/{bn-BqS1yarc.js → bn-BJJgi-6Q.js} +1 -1
  54. package/frontend/dist/js/{chatStore-DW0LsT5X.js → chatStore-8jYk48hC.js} +3 -3
  55. package/frontend/dist/js/{config-nmgpdBW-.js → config-D4dduT3C.js} +1 -1
  56. package/frontend/dist/js/{cs-C84vh9-u.js → cs-DheVrMUl.js} +1 -1
  57. package/frontend/dist/js/{da-JlIGisjC.js → da-BLszIs3a.js} +1 -1
  58. package/frontend/dist/js/{de-ChxuvrTF.js → de-BvWdcr7T.js} +1 -1
  59. package/frontend/dist/js/{es-Dz-DZUqm.js → es-CQ8Yauda.js} +1 -1
  60. package/frontend/dist/js/{evaluationsApi-B3fvoXgD.js → evaluationsApi-CBKjxZUn.js} +1 -1
  61. package/frontend/dist/js/{fr-xjmr6UIb.js → fr-BD5h-w8z.js} +1 -1
  62. package/frontend/dist/js/{hi-CJoQdoJi.js → hi-IlRhC5IE.js} +1 -1
  63. package/frontend/dist/js/{id-ABrUdDxu.js → id-DalGMQEJ.js} +1 -1
  64. package/frontend/dist/js/{is-DnBvEw5D.js → is-DuQqmHeS.js} +1 -1
  65. package/frontend/dist/js/{it-BG1zJjTU.js → it-DDaqAdB1.js} +1 -1
  66. package/frontend/dist/js/{ja-DtZswh64.js → ja-CYCu9F9Y.js} +1 -1
  67. package/frontend/dist/js/{ko-BKhTnqlM.js → ko-P3JZPOXE.js} +1 -1
  68. package/frontend/dist/js/{messageCodeStyles-CCM1VmjP.js → messageCodeStyles-0_YpQDk4.js} +2 -2
  69. package/frontend/dist/js/{ms-BdRgdch9.js → ms-B3ZIqlUn.js} +1 -1
  70. package/frontend/dist/js/{nl-B3sv2F01.js → nl-1Qpsmmz1.js} +1 -1
  71. package/frontend/dist/js/{pl-CLAO9d2t.js → pl-ErrMri3_.js} +1 -1
  72. package/frontend/dist/js/{pt-BV3z1x11.js → pt-0T0R9AtX.js} +1 -1
  73. package/frontend/dist/js/{ru-CUSOQ4d9.js → ru-B34INyPg.js} +1 -1
  74. package/frontend/dist/js/{sv-nPJsBtOC.js → sv-BSqDwAur.js} +1 -1
  75. package/frontend/dist/js/{teamEventStream-BBNlg5Wd.js → teamEventStream-RoMYo102.js} +1 -1
  76. package/frontend/dist/js/{th-DqM7Arld.js → th-DK9M4-Iy.js} +1 -1
  77. package/frontend/dist/js/{tr-8kvS8u7c.js → tr-DUrkEwr1.js} +1 -1
  78. package/frontend/dist/js/{ui-BZOjqAJH.js → ui-UU79S5lB.js} +2 -2
  79. package/frontend/dist/js/{ui-vendor-DvJV-69N.js → ui-vendor-6y6qiSk5.js} +1 -1
  80. package/frontend/dist/js/{uk-3o761Mgn.js → uk-B5DYTi0e.js} +1 -1
  81. package/frontend/dist/js/{useChat-Bgdsccuz.js → useChat-ImXXcy0q.js} +1 -1
  82. package/frontend/dist/js/useDictation-eMIAncoT.js +1 -0
  83. package/frontend/dist/js/{vi-CT74KJ9a.js → vi-CrtPQUIM.js} +1 -1
  84. package/frontend/dist/js/workApi-BM8qVq_w.js +1 -0
  85. package/frontend/dist/js/{workApi-CqIVWrXF.js → workApi-xhF57amo.js} +2 -2
  86. package/frontend/dist/js/{zh-Bhmpu3gT.js → zh-gbOKajYe.js} +1 -1
  87. package/package.json +1 -1
  88. package/frontend/dist/assets/index-DsrrGy09.js +0 -73
  89. package/frontend/dist/js/CalendarPage-D71tcbA3.js +0 -1
  90. package/frontend/dist/js/ChannelsPage-BFkTp2cp.js +0 -1
  91. package/frontend/dist/js/ChatPage-DRdVuXt2.js +0 -14
  92. package/frontend/dist/js/ConnectModels-CKLUofc6.js +0 -1
  93. package/frontend/dist/js/GalleryPage-CkpikP93.js +0 -1
  94. package/frontend/dist/js/LibreClawPage-CKtbq8am.js +0 -1
  95. package/frontend/dist/js/NotesPage-1TG04re5.js +0 -3
  96. package/frontend/dist/js/PersonasPage-DZ4GBVkJ.js +0 -13
  97. package/frontend/dist/js/RichMessageContent-BxxKwFmA.js +0 -1
  98. package/frontend/dist/js/SettingsModal-Cl5eVfDM.js +0 -19
  99. package/frontend/dist/js/UserManagementPage-CBA-O0bM.js +0 -1
  100. package/frontend/dist/js/WorkPage-BEJ98OxR.js +0 -7
  101. package/frontend/dist/js/api-BMB8tnVI.js +0 -1
  102. package/frontend/dist/js/api-T6SWjL0K.js +0 -14
  103. package/frontend/dist/js/appStore-BonCvc8Q.js +0 -2
  104. package/frontend/dist/js/appVersion-B6Jl_X3L.js +0 -1
  105. package/frontend/dist/js/authStore-C2kI1Q9M.js +0 -1
  106. package/frontend/dist/js/useDictation-AXMLg9HP.js +0 -1
  107. package/frontend/dist/js/workApi-CUSjVilK.js +0 -1
@@ -1,73 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/SettingsModal-Cl5eVfDM.js","js/rolldown-runtime-hePW80VL.js","js/react-vendor-D0Ec-185.js","js/useQuery-BKulzCS7.js","js/logger-DnuT4jgB.js","js/useTranslation-D0mJ4NnO.js","js/utils-Bn0RE9_8.js","js/utils-vendor-BbPbaAuC.js","js/chatStore-DW0LsT5X.js","js/i18next-ChipS_AK.js","js/ui-vendor-DvJV-69N.js","js/goober.modern-BaHbaW3_.js","js/api-T6SWjL0K.js","js/config-nmgpdBW-.js","js/workApi-CqIVWrXF.js","js/imageGenModels-Dx_QMLJQ.js","js/authStore-Bl7S8bPg.js","js/appStore-BonCvc8Q.js","js/messageCodeStyles-CCM1VmjP.js","js/Button-BQ5JnUVj.js","js/ui-BZOjqAJH.js","js/Logo-BlcOFpac.js","js/LogoMark-CNeQ6eO9.js","js/ShareDialog-CeHMOTrA.js","js/ttsBatching-kFVEE3Ip.js","js/webauthnClient-CPSq528Q.js","js/appVersion-B6Jl_X3L.js","js/SettingsToggle-B7UynBmZ.js","js/thinking-DwlkTfPX.js","js/axios-CYkJpKn8.js","js/HomePage-B9nkyAdS.js","js/router-vendor-CMbYTGdh.js","js/workStatus-CcO9Fg41.js","js/appNavigation-B_QjduzS.js","js/welcomePrompts-to5mv_gx.js","js/work-DVgm81bJ.js","js/ChatPage-DRdVuXt2.js","js/useChat-Bgdsccuz.js","js/artifactHtml-DDmfpcB0.js","js/ConnectModels-CKLUofc6.js","js/ArtifactContainer-DG-qigOa.js","js/OptimizedSyntaxHighlighter-CtQ_FGCX.js","js/syntax-highlight-DTWfgxYh.js","js/markdown-core-D067gSd8.js","js/ArtifactSandboxFrame-2WyuCg4w.js","js/evaluationsApi-B3fvoXgD.js","js/useDictation-AXMLg9HP.js","js/WhatsNewModal-CKkWbbNI.js","js/PersonasPage-DZ4GBVkJ.js","js/AvatarUpload-D_nSLum9.js","js/GalleryPage-CkpikP93.js","js/NotesPage-1TG04re5.js","js/RichMessageContent-Cm7kRv3f.js","js/CalendarPage-D71tcbA3.js","js/calendarDates-Co3o_05Y.js","js/AutomationsPage-CuDSh_W2.js","js/AutomationModal-Dgk1PzNx.js","js/LibreClawPage-CKtbq8am.js","js/ChannelsPage-BFkTp2cp.js","js/teamEventStream-BBNlg5Wd.js","js/WorkPage-BEJ98OxR.js","js/UserManagementPage-CBA-O0bM.js","js/PasswordStrengthMeter-CNgHwIkW.js","js/PluginUsagePage-QGOo5MZj.js","js/EvaluationsPage-C6NHj9KF.js","js/SystemPage-B1bDpa9g.js","js/ArtifactDemoPage-Cr_bMx_v.js","js/ArtifactSlideOutPanel-zizbFUzW.js","js/FirstTimeSetup-BVOPC4uh.js","js/TurnstileWidget-CEJst9eS.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"../js/rolldown-runtime-hePW80VL.js";import{i as t,n,r,t as i}from"../js/react-vendor-D0Ec-185.js";import{S as a,_ as o,b as s,c,d as l,f as u,g as d,h as f,i as p,l as m,m as h,p as g,s as _,t as v,u as y,v as b,x,y as S}from"../js/useQuery-BKulzCS7.js";import{a as C,c as w,d as T,m as E,n as D,o as O,p as k,r as A,s as j,t as M,u as ee}from"../js/router-vendor-CMbYTGdh.js";import{a as N,o as P,t as F}from"../js/logger-DnuT4jgB.js";import{t as I}from"../js/useTranslation-D0mJ4NnO.js";import{a as te,r as ne,s as L,t as R}from"../js/utils-Bn0RE9_8.js";import{S as z,T as B,d as re,m as ie,t as ae,w as oe}from"../js/chatStore-DW0LsT5X.js";import{$n as V,A as se,At as ce,Bt as le,Ct as ue,D as H,Jn as U,Kn as de,Kt as W,L as fe,Nt as pe,P as me,Pn as he,Pt as ge,Q as _e,R as ve,Sn as G,U as ye,Ut as be,V as xe,Wn as Se,Xn as Ce,Y as we,Yn as Te,Yt as Ee,Zn as De,_r as Oe,_t as ke,an as Ae,ar as je,at as Me,bn as Ne,c as Pe,ct as Fe,dt as Ie,fn as Le,ft as Re,g as ze,h as Be,ht as Ve,ir as He,kt as Ue,lt as We,mr as Ge,n as K,nn as Ke,nr as qe,nt as Je,qn as Ye,r as Xe,rt as Ze,s as Qe,sn as $e,sr as et,t as tt,tn as nt,u as rt,v as it,vn as at,vr as q,w as ot,wn as st,wt as ct,yn as lt,yr as ut,z as dt,zt as ft}from"../js/ui-vendor-DvJV-69N.js";import{a as pt,i as mt,t as ht}from"../js/utils-vendor-BbPbaAuC.js";import{t as gt}from"../js/config-nmgpdBW-.js";import{E as _t,I as J,L as vt,R as yt,T as bt,_ as xt,g as St,h as Ct,v as wt,w as Tt,y as Et}from"../js/api-T6SWjL0K.js";import{d as Dt,n as Ot,s as kt,t as Y,u as At}from"../js/authStore-Bl7S8bPg.js";import{a as jt,t as Mt}from"../js/appStore-BonCvc8Q.js";import{n as Nt}from"../js/welcomePrompts-to5mv_gx.js";import{l as Pt}from"../js/messageCodeStyles-CCM1VmjP.js";import{t as X}from"../js/Button-BQ5JnUVj.js";import{v as Ft}from"../js/ui-BZOjqAJH.js";import{t as It}from"../js/AvatarUpload-D_nSLum9.js";import{t as Lt}from"../js/Logo-BlcOFpac.js";import{t as Rt}from"../js/LogoMark-CNeQ6eO9.js";import{t as zt}from"../js/ShareDialog-CeHMOTrA.js";import{t as Bt}from"../js/teamEventStream-BBNlg5Wd.js";import{t as Vt}from"../js/workStatus-CcO9Fg41.js";import{t as Ht}from"../js/useChat-Bgdsccuz.js";import{n as Ut,r as Wt,t as Gt}from"../js/appNavigation-B_QjduzS.js";import{n as Kt}from"../js/ttsBatching-kFVEE3Ip.js";import{n as qt,r as Jt}from"../js/webauthnClient-CPSq528Q.js";import{t as Yt}from"../js/TurnstileWidget-CEJst9eS.js";import{n as Xt,t as Zt}from"../js/PasswordStrengthMeter-CNgHwIkW.js";import{t as Qt}from"../js/appVersion-B6Jl_X3L.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var $t=class extends _{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||en(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??(this.state.status===`pending`?this.execute(this.state.variables):Promise.resolve())}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey},r=this.#r=c({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)}),i=this.state.status===`pending`,a=!r.canStart();try{if(i)t();else{this.#i({type:`pending`,variables:e,isPaused:a}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:a})}let o=await r.start();return await this.#n.config.onSuccess?.(o,e,this.state.context,this,n),await this.options.onSuccess?.(o,e,this.state.context,n),await this.#n.config.onSettled?.(o,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(o,null,e,this.state.context,n),this.#i({type:`success`,data:o}),o}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#r===r&&(this.#r=void 0),this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),y.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function en(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var tn=class extends u{#e;#t;#n;constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}build(e,t,n){let r=new $t({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=nn(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=nn(e);if(typeof t==`string`){let n=this.#t.get(t);if(n){if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=nn(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}return!0}runNext(e){let t=nn(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){y.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>d(t,e))}findAll(e={}){return this.getAll().filter(t=>d(e,t))}notify(e){y.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return y.batch(()=>Promise.all(e.map(e=>e.continue().catch(b))))}};function nn(e){return e.options.scope?.id}var rn=class extends u{#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,t,n){let r=t.queryKey,i=t.queryHash??f(r,t),a=this.get(i);return a||(a=new p({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){y.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>o(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>o(e,t)):t}notify(e){y.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){y.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){y.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},an=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new rn,this.#t=e.mutationCache||new tn,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=l.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=m.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(s(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=g(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return y.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;y.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return y.batch(()=>{let r=n.findAll(e),i=new Set(r);return r.forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,predicate:e=>i.has(e)},t)})}cancelQueries(e,t={}){let n={revert:!0,...t},r=y.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(b).catch(b)}invalidateQueries(e,t={}){return y.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=y.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(b)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(b)}async query(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t),r=n.isStaleByTime(s(t.staleTime,n))?await n.fetch(t):n.state.data,i=t.select;return i?i(r):r}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(s(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(b).catch(b)}infiniteQuery(e){return e._type=`infinite`,this.query(e)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(b).catch(b)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return m.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(h(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{S(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(h(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{S(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=f(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===x&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},Z=e(t(),1),on=e(n(),1),Q=i(),sn={id:`home`,kind:`home`,path:`/`},cn=[`/calendar`,`/automations`,`/channels`,`/personas`,`/gallery`,`/agents`,`/users`,`/usage`,`/system`,`/artifacts`],ln=e=>{if(e===`/`||e===`/home`)return sn;if(e===`/chat`)return{id:`chat:new`,kind:`chat`,path:`/chat`};let t=e.match(/^\/c\/([^/]+)$/);if(t)return{id:`chat:${t[1]}`,kind:`chat`,path:e};if(e===`/work`)return{id:`work:new`,kind:`work`,path:`/work`};let n=e.match(/^\/work\/([^/]+)$/);return n?{id:`work:${n[1]}`,kind:`work`,path:e}:cn.includes(e)?{id:`page:${e}`,kind:`page`,path:e}:null},un=e=>[sn,...e.filter(e=>e.id!==sn.id)],dn=pt()(ht((e,t)=>({tabs:[sn],activeTabId:sn.id,syncWithPath:t=>{let n=ln(t);n&&e(e=>{let t=un(e.tabs),r=t.find(e=>e.id===n.id);if(r)return{tabs:t,activeTabId:r.id};let i=t.find(t=>t.id===e.activeTabId);return i&&i.kind===n.kind&&i.id.endsWith(`:new`)&&!n.id.endsWith(`:new`)?{tabs:t.map(e=>e.id===i.id?n:e),activeTabId:n.id}:{tabs:[...t,n],activeTabId:n.id}})},closeTab:e=>t().closeTabs([e]),closeTabs:(n,r)=>{let i=t(),a=un(i.tabs),o=new Set(n.filter(e=>e!==sn.id&&a.some(t=>t.id===e)));if(o.size===0)return null;let s=a.findIndex(e=>e.id===i.activeTabId),c=a.filter(e=>!o.has(e.id));if(!o.has(i.activeTabId))return e({tabs:c}),null;let l=r?c.find(e=>e.id===r):void 0,u=a.slice(0,Math.max(0,s)).reverse().find(e=>!o.has(e.id)),d=l??u??c[0]??sn;return e({tabs:c,activeTabId:d.id}),d},reset:()=>e({tabs:[sn],activeTabId:sn.id})}),{name:`libre-webui-tabs`,merge:(e,t)=>{let n=e??{},r=Array.isArray(n.tabs)?un(n.tabs.filter(e=>!!e&&typeof e.id==`string`&&typeof e.path==`string`&&ln(e.path)?.id===e.id)):t.tabs,i=r.some(e=>e.id===n.activeTabId)?n.activeTabId:sn.id;return{...t,tabs:r,activeTabId:i}}})),fn=r();function pn({open:e,value:t,saving:n,onChange:r,onClose:i,onSave:a}){let{t:o}=I();return e?(0,fn.createPortal)((0,Q.jsx)(`div`,{className:`fixed inset-0 z-[2147483647] flex items-center justify-center bg-gray-950/55 p-4 backdrop-blur-md`,onClick:i,children:(0,Q.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`avatar-modal-title`,className:`bg-white dark:bg-dark-25 rounded-3xl shadow-[0_24px_80px_rgba(0,0,0,0.24)] p-6 w-full max-w-md border border-black/[0.07] dark:border-white/[0.08] animate-scale-in`,onClick:e=>e.stopPropagation(),children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,Q.jsx)(`h3`,{id:`avatar-modal-title`,className:`text-lg font-medium tracking-[-0.02em] text-gray-950 dark:text-dark-950`,children:o(`user.avatar.title`)}),(0,Q.jsx)(`button`,{onClick:i,className:`p-2 hover:bg-gray-100 dark:hover:bg-dark-200 rounded-xl transition-colors`,children:(0,Q.jsx)(K,{size:20,className:`text-gray-500`})})]}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(It,{value:t,onChange:r}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-3 pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`button`,{onClick:i,className:`px-4 py-2 text-sm font-medium text-gray-700 dark:text-dark-700 hover:bg-gray-100 dark:hover:bg-dark-200 rounded-xl transition-colors`,children:o(`common.cancel`)}),(0,Q.jsx)(`button`,{onClick:a,disabled:n,className:`px-4 py-2 text-sm font-medium text-white bg-gray-950 hover:bg-gray-800 dark:bg-white dark:text-gray-950 dark:hover:bg-gray-100 disabled:opacity-50 disabled:cursor-not-allowed rounded-xl transition-colors`,children:o(n?`common.saving`:`common.save`)})]})]})]})}),document.body):null}var mn=`h-4 w-4 text-ink-muted transition-colors duration-150 group-hover:text-ink motion-reduce:transition-none`,hn={light:ot,dark:Ve,amoled:ke},gn={light:`light`,dark:`dark`,amoled:`pure black`},_n=()=>{let{theme:e,toggleTheme:t}=Mt(),n=jt(e.mode),r=hn[n],i=`Switch to ${gn[n]} mode`;return(0,Q.jsx)(X,{variant:`ghost`,size:`sm`,onClick:t,className:`h-9 w-9 rounded-full p-0`,"aria-label":i,title:`${i} (⌘D)`,children:(0,Q.jsx)(r,{className:mn,strokeWidth:1.75,"aria-hidden":`true`})})};function vn({sidebarCompact:e,isElectron:t,showWork:n,activeMode:r,selectedModel:i,modelCount:a,onToggleCompact:o,onStartWork:s,onCreateSession:c}){let{t:l}=I(),u=!i||a===0,d=u?l(`chat.model.noModelsTooltip`):``,f=`flex h-9 w-9 items-center justify-center rounded-full text-ink transition-colors hover:bg-interactive-hover outline-none focus-visible:ring-2 focus-visible:ring-primary-500/30 touch-manipulation`;return e?(0,Q.jsxs)(`div`,{className:R(`flex flex-col items-center gap-3 px-2 pt-4 pb-2`,t&&`pt-10`),children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:o,className:R(f,`group`),title:l(`sidebar.expandSidebar`),"aria-label":l(`sidebar.expandSidebar`),"data-testid":`sidebar-rail-expand`,children:[(0,Q.jsx)(Rt,{size:`sm`,label:null,className:`h-6 w-6 p-0 text-ink group-hover:hidden`}),(0,Q.jsx)(We,{className:`hidden h-[18px] w-[18px] group-hover:block rtl:rotate-180`})]}),(0,Q.jsx)(`button`,{type:`button`,onClick:c,disabled:u,className:R(f,u&&`opacity-40`),title:u?d:l(`chat.session.chat`),"aria-label":l(`chat.session.chat`),"aria-pressed":r===`chat`,"data-testid":`sidebar-chat-button`,children:(0,Q.jsx)(ct,{className:`h-[18px] w-[18px]`})}),n&&(0,Q.jsx)(`button`,{type:`button`,onClick:s,className:f,title:l(`chat.session.work`),"aria-label":l(`chat.session.work`),"aria-pressed":r===`work`,"data-testid":`sidebar-work-button`,children:(0,Q.jsx)(V,{className:`h-[18px] w-[18px]`})}),(0,Q.jsx)(`button`,{type:`button`,"data-testid":`sidebar-search-button`,onClick:()=>window.dispatchEvent(new Event(`libre:open-palette`)),title:l(`palette.search`,`Search`),"aria-label":l(`palette.search`,`Search`),className:f,children:(0,Q.jsx)(ye,{className:`h-[18px] w-[18px]`})})]}):(0,Q.jsxs)(`div`,{className:R(`px-3 pb-2 pt-2`,t&&`pt-10`),children:[(0,Q.jsxs)(`div`,{className:`mb-2 flex h-[52px] min-w-0 items-center justify-between ps-1`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-ink`,children:[(0,Q.jsx)(Rt,{size:`sm`,label:null}),(0,Q.jsx)(Lt,{size:`sm`,className:`tracking-[-0.035em]`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,Q.jsx)(`div`,{className:`hidden sm:block`,children:(0,Q.jsx)(_n,{})}),(0,Q.jsx)(`button`,{type:`button`,onClick:o,className:`flex h-7 w-7 items-center justify-center rounded-full text-ink-muted transition-colors hover:bg-interactive-hover hover:text-ink outline-none focus-visible:ring-2 focus-visible:ring-primary-500/30 touch-manipulation`,title:l(`sidebar.toggleSize`),"aria-label":l(`sidebar.toggleSize`),"data-testid":`sidebar-toggle-size`,children:(0,Q.jsx)(We,{className:`h-4 w-4 rtl:rotate-180`})})]})]}),(0,Q.jsxs)(`div`,{className:R(`grid w-full gap-2`,!n&&`grid-cols-1`,n&&`grid-cols-2`),"data-testid":`sidebar-create-actions`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:c,disabled:u,className:R(`flex h-[38px] items-center justify-center gap-1.5 rounded-xl border text-sm font-medium transition-colors touch-manipulation outline-none focus-visible:ring-2 focus-visible:ring-primary-500/30`,r===`chat`?`border-transparent bg-nav-active text-ink`:`border-line bg-surface-raised text-ink hover:bg-hover-solid dark:border-white/[0.12] dark:bg-dark-25 dark:hover:bg-dark-300`,u&&`opacity-50`),title:u?d:l(`chat.session.chat`),"aria-label":l(`chat.session.chat`),"aria-pressed":r===`chat`,"data-testid":`sidebar-chat-button`,children:[(0,Q.jsx)(ct,{className:`h-4 w-4`}),l(`chat.session.chat`)]}),n&&(0,Q.jsxs)(`button`,{type:`button`,onClick:s,className:R(`flex h-[38px] items-center justify-center gap-1.5 rounded-xl border text-sm font-medium transition-colors touch-manipulation outline-none focus-visible:ring-2 focus-visible:ring-primary-500/30`,r===`work`?`border-transparent bg-nav-active text-ink`:`border-line bg-surface-raised text-ink hover:bg-hover-solid dark:border-white/[0.12] dark:bg-dark-25 dark:hover:bg-dark-300`),title:l(`chat.session.work`),"aria-label":l(`chat.session.work`),"aria-pressed":r===`work`,"data-testid":`sidebar-work-button`,children:[(0,Q.jsx)(V,{className:`h-4 w-4`}),l(`chat.session.work`)]})]}),(0,Q.jsxs)(`button`,{type:`button`,"data-testid":`sidebar-search-button`,onClick:()=>window.dispatchEvent(new Event(`libre:open-palette`)),title:l(`palette.search`,`Search`),"aria-label":l(`palette.search`,`Search`),className:`mt-1.5 flex h-[34px] w-full items-center gap-2 rounded-xl px-2.5 text-sm text-ink-muted transition-colors hover:bg-interactive-hover hover:text-ink outline-none focus-visible:ring-2 focus-visible:ring-primary-500/30 touch-manipulation`,children:[(0,Q.jsx)(ye,{className:`h-4 w-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`flex-1 text-start`,children:l(`palette.search`,`Search`)}),(0,Q.jsxs)(`span`,{className:`font-mono text-[10px] tracking-wide text-ink-subtle`,children:[te()?`⌘`:`Ctrl`,`K`]})]})]})}var yn=[{path:`/channels`,icon:ue,labelKey:`sidebar.navigation.channels`},{path:`/notes`,icon:Re,labelKey:`sidebar.navigation.notes`},{path:`/calendar`,icon:De,labelKey:`sidebar.navigation.calendar`},{path:`/automations`,icon:tt,labelKey:`sidebar.navigation.automations`},{path:`/personas`,icon:Pe,labelKey:`sidebar.navigation.personas`},{path:`/gallery`,icon:se,labelKey:`sidebar.navigation.imagine`},{path:`/agents`,icon:He,labelKey:`sidebar.navigation.agents`}];function bn({sidebarCompact:e,activePath:t,showAgents:n,unseenRunCount:r=0,onMobileNavigate:i}){let{t:a}=I();return(0,Q.jsx)(`div`,{className:R(`pb-3`,e?`px-2`:`px-3`),children:(0,Q.jsx)(`nav`,{"data-testid":`sidebar-navigation`,"aria-label":a(`sidebar.navigation.exploreLabel`,`Explore`),className:R(`flex gap-1`,e?`flex-col items-center`:`items-center`),children:yn.filter(e=>e.path!==`/agents`||n).map(({path:n,icon:o,labelKey:s})=>{let c=t===n,l=a(s);return(0,Q.jsxs)(M,{to:n,onClick:i,title:l,"aria-label":l,"aria-current":c?`page`:void 0,className:R(`relative flex items-center justify-center rounded-xl transition-colors duration-150 touch-manipulation outline-none focus-visible:ring-2 focus-visible:ring-primary-500/30`,e?`h-9 w-9`:`h-9 flex-1`,c?`bg-nav-active text-ink`:`text-ink-muted hover:bg-interactive-hover hover:text-ink`),children:[e&&c&&(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`absolute -start-2 h-5 w-0.5 rounded-full bg-primary-500 shadow-[0_0_12px_rgb(var(--color-primary-500)/0.55)]`}),(0,Q.jsx)(o,{className:`h-[18px] w-[18px] shrink-0`}),n===`/automations`&&r>0&&(0,Q.jsx)(`span`,{"data-testid":`automations-unseen-badge`,className:`absolute -end-0.5 -top-0.5 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-primary-500 px-0.5 text-[9px] font-semibold leading-none text-white`,children:r>9?`9+`:r})]},n)})})})}function xn({top:e,left:t,title:n,timestamp:r,children:i}){let{i18n:a}=I();return(0,fn.createPortal)((0,Q.jsxs)(`div`,{role:`tooltip`,className:`pointer-events-none fixed z-[70] hidden w-72 rounded-2xl border border-black/[0.07] bg-surface/95 p-3.5 shadow-[0_16px_48px_rgba(15,23,42,0.18)] backdrop-blur-xl animate-scale-in dark:border-white/[0.09] dark:bg-dark-100/95 md:block`,style:{top:Math.max(8,Math.min(e,window.innerHeight-220)),left:t},children:[(0,Q.jsx)(`p`,{className:`mb-1 truncate text-[13px] font-semibold text-gray-900 dark:text-dark-900`,children:n}),(0,Q.jsx)(`p`,{className:`mb-2 text-[10px] tabular-nums text-gray-400 dark:text-dark-500`,children:ne(r,a.language)}),i]}),document.body)}function Sn(e){let t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),r=864e5;return e>=n?`today`:e>=n-r?`yesterday`:e>=n-7*r?`previous7Days`:e>=n-30*r?`previous30Days`:`older`}var Cn=[`today`,`yesterday`,`previous7Days`,`previous30Days`,`older`];function wn({preview:e}){let{t}=I(),{session:n}=e,r=n.messages.find(e=>e.role===`user`&&e.content.trim()),i=n.messages.find(e=>e.role===`assistant`&&e.content.trim());return(0,Q.jsxs)(xn,{top:e.top,left:e.left,title:n.title,timestamp:n.updatedAt,children:[r&&(0,Q.jsx)(`div`,{className:`mb-1.5 flex justify-end`,children:(0,Q.jsx)(`p`,{dir:`auto`,className:`max-w-[85%] rounded-xl rounded-ee-sm bg-gray-900 px-2.5 py-1.5 text-[11px] leading-snug text-white dark:bg-dark-300`,children:L(r.content,110)})}),i&&(0,Q.jsx)(`p`,{dir:`auto`,className:`text-[11px] leading-snug text-gray-600 dark:text-dark-700`,children:L(i.content.replace(/\s+/g,` `),180)}),!r&&!i&&(0,Q.jsx)(`p`,{className:`text-[11px] italic text-gray-400 dark:text-dark-500`,children:t(`chat.session.noChats`)})]})}function Tn({sessions:e,personas:t,currentSessionId:n,generatingTitleForSession:r,sidebarCompact:i,editingSessionId:a,editingTitle:o,onEditingTitleChange:s,onSelectSession:c,onStartEditing:l,onSaveEdit:u,onCancelEdit:d,onDeleteSession:f,onArchiveSession:p,onTogglePinSession:m,folders:h=[],onCreateFolder:g,onRenameFolder:_,onDeleteFolder:v,onMoveSession:y,onExpandSidebar:b}){let{t:x,i18n:S}=I(),[C,w]=(0,Z.useState)(null),[T,E]=(0,Z.useState)(null),D=(0,Z.useRef)(null),O=T?e.find(e=>e.id===T)??null:null;(0,Z.useEffect)(()=>()=>{D.current!==null&&window.clearTimeout(D.current)},[]);let k=()=>{D.current!==null&&(window.clearTimeout(D.current),D.current=null),w(null)},A=(e,t)=>{let n=window.matchMedia(`(hover: hover) and (pointer: fine)`).matches;i||window.innerWidth<768||!n||(D.current!==null&&window.clearTimeout(D.current),D.current=window.setTimeout(()=>{let n=t.getBoundingClientRect();w({session:e,top:n.top,left:n.right+10})},500))},[j,M]=(0,Z.useState)(()=>new Set),[ee,N]=(0,Z.useState)(!1),[P,F]=(0,Z.useState)(``),[te,z]=(0,Z.useState)(null),[B,re]=(0,Z.useState)(null),[ie,ae]=(0,Z.useState)(null),oe=B?e.find(e=>e.id===B)??null:null,V=()=>{re(null),ae(null)},se=e=>{let t=oe;V(),!(!t||!y)&&(t.folderId??null)!==e&&y(t.id,e)},ce=(e,t)=>({onDragOver:t=>{B&&(t.preventDefault(),t.dataTransfer.dropEffect=`move`,ie!==e&&ae(e))},onDragLeave:()=>{ie===e&&ae(null)},onDrop:e=>{e.preventDefault(),se(t)}}),[le,ue]=(0,Z.useState)(null),[H,U]=(0,Z.useState)(null),W=H?e.find(e=>e.id===H.sessionId)??null:null;(0,Z.useEffect)(()=>{if(!H)return;let e=e=>{e.key===`Escape`&&U(null)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[H]);let fe=(e,t)=>{if(t.stopPropagation(),k(),H?.sessionId===e.id){U(null);return}let n=t.currentTarget.getBoundingClientRect();U({sessionId:e.id,top:Math.max(8,Math.min(n.bottom+6,window.innerHeight-340-8)),left:Math.max(8,Math.min(n.right-208,window.innerWidth-208-8))})},me=e=>{let t=window.location.protocol===`file:`?`${window.location.pathname}#/c/${e.id}`:`/c/${e.id}`;window.open(t,`_blank`,`noopener,noreferrer`)},he=e=>{M(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},ge=()=>{let e=P.trim();N(!1),F(``),e&&g&&g(e)},_e=e=>{let t=P.trim();z(null),F(``),t&&_&&_(e,t)},ye=new Set(h.map(e=>e.id)),be=e.filter(e=>e.pinned),xe=e.filter(e=>!e.pinned),Ce=xe.filter(e=>!e.folderId||!ye.has(e.folderId)),we=[...be.length>0?[{key:`pinned`,labelKey:`pinned`,sessions:be}]:[],...h.map(e=>({key:`folder:${e.id}`,folder:e,sessions:xe.filter(t=>t.folderId===e.id)})),...Cn.map(e=>({key:e,labelKey:e,sessions:Ce.filter(t=>Sn(t.updatedAt)===e)})).filter(e=>e.sessions.length>0)];return(0,Q.jsxs)(`div`,{"data-testid":`sidebar-session-scroll-region`,className:`scroll-region min-h-0 flex-1 scrollbar-thin border-t border-black/[0.05] dark:border-white/[0.05]`,style:{willChange:`scroll-position`},children:[(0,Q.jsxs)(`div`,{className:R(`px-3 py-3`,i&&`px-2`),children:[!i&&e.length>0&&(0,Q.jsxs)(`div`,{className:`mb-1 flex h-7 items-center justify-between px-1.5`,children:[(0,Q.jsx)(`h3`,{className:`text-xs font-medium text-ink-subtle`,children:x(`chat.session.chats`)}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[g&&(0,Q.jsx)(`button`,{onClick:()=>{N(!0),F(``)},className:`flex h-6 w-6 items-center justify-center rounded-md text-ink-subtle transition-colors hover:bg-interactive-hover hover:text-ink`,title:x(`chat.session.folder.new`),children:(0,Q.jsx)($e,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(`span`,{className:`text-[10px] tabular-nums text-ink-subtle font-medium`,children:e.length})]})]}),!i&&ee&&(0,Q.jsx)(`div`,{className:`mb-2 px-1`,children:(0,Q.jsx)(Ft,{value:P,onChange:e=>F(e.target.value),onKeyDown:e=>{e.key===`Enter`?ge():e.key===`Escape`&&(N(!1),F(``))},onBlur:ge,placeholder:x(`chat.session.folder.namePlaceholder`),className:`h-8 text-sm`,autoFocus:!0})}),i?(0,Q.jsx)(`div`,{className:`flex flex-col items-center gap-1`,children:(0,Q.jsxs)(`button`,{type:`button`,onClick:b,"data-testid":`sidebar-mobile-chats`,"aria-label":`${x(`chat.session.chats`)} (${e.length})`,title:x(`chat.session.chats`),className:`relative flex h-12 w-12 items-center justify-center rounded-xl text-gray-500 outline-none transition-colors hover:bg-white/70 hover:text-gray-950 focus-visible:ring-2 focus-visible:ring-primary-500/30 dark:text-dark-600 dark:hover:bg-dark-200 dark:hover:text-dark-950 md:hidden`,children:[(0,Q.jsx)(ct,{className:`h-[18px] w-[18px]`}),e.length>0&&(0,Q.jsx)(`span`,{className:`absolute -end-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-md bg-primary-500 px-1 text-[9px] font-semibold tabular-nums text-white shadow-sm`,children:e.length>99?`99+`:e.length})]})}):e.length===0?(0,Q.jsxs)(`div`,{className:R(`text-center py-8`,i?`px-1`:`px-2`),children:[(0,Q.jsx)(`div`,{className:R(`mx-auto mb-3 bg-white/70 dark:bg-dark-200 rounded-xl flex items-center justify-center ring-1 ring-black/[0.04] dark:ring-white/[0.05]`,i?`w-8 h-8`:`w-12 h-12`),children:(0,Q.jsx)(ct,{className:R(`text-gray-400 dark:text-gray-500`,i?`h-4 w-4`:`h-5 w-5`)})}),!i&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-gray-600 dark:text-dark-600`,children:x(`chat.session.noChats`)}),(0,Q.jsx)(`p`,{className:`text-xs mt-1 text-gray-400 dark:text-dark-500`,children:x(`chat.session.createFirst`)})]})]}):(0,Q.jsx)(`div`,{className:R(`space-y-2`,i&&`space-y-1`),children:we.map(e=>(0,Q.jsxs)(`div`,{children:[!i&&e.folder&&(0,Q.jsx)(`div`,{...ce(`folder:${e.folder.id}`,e.folder.id),className:R(`group/folder mb-0.5 flex h-[34px] items-center justify-between rounded-lg px-2 transition-colors hover:bg-interactive-hover`,ie===`folder:${e.folder.id}`&&`bg-primary-500/10 ring-1 ring-primary-500/40`),children:te===e.folder.id?(0,Q.jsx)(Ft,{value:P,onChange:e=>F(e.target.value),onKeyDown:t=>{t.key===`Enter`?_e(e.folder.id):t.key===`Escape`&&(z(null),F(``))},onBlur:()=>_e(e.folder.id),className:`h-7 text-sm`,autoFocus:!0}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`button`,{onClick:()=>he(e.folder.id),className:`flex min-w-0 flex-1 items-center gap-1.5 text-sm text-ink transition-colors`,"aria-expanded":!j.has(e.folder.id),children:[j.has(e.folder.id)?(0,Q.jsx)(Se,{className:`h-3.5 w-3.5 shrink-0 text-ink-subtle rtl:rotate-180`}):(0,Q.jsx)(de,{className:`h-3.5 w-3.5 shrink-0 text-ink-subtle`}),(0,Q.jsx)(Ae,{className:`h-4 w-4 shrink-0 text-ink-subtle`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.folder.name}),(0,Q.jsx)(`span`,{className:`text-[10px] font-medium tabular-nums text-ink-subtle`,children:e.sessions.length})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-0.5 opacity-0 transition-opacity group-hover/folder:opacity-100`,children:[_&&(0,Q.jsx)(`button`,{onClick:()=>{z(e.folder.id),F(e.folder.name)},className:`rounded-md p-0.5 text-gray-400 hover:text-gray-700 dark:text-dark-500 dark:hover:text-dark-800`,title:x(`chat.session.renameChat`),children:(0,Q.jsx)(Me,{className:`h-3 w-3`})}),v&&(0,Q.jsx)(`button`,{onClick:()=>{window.confirm(x(`chat.session.folder.deleteConfirm`))&&v(e.folder.id)},className:`rounded-md p-0.5 text-gray-400 hover:text-red-500 dark:text-dark-500 dark:hover:text-red-400`,title:x(`chat.session.folder.delete`),children:(0,Q.jsx)(it,{className:`h-3 w-3`})})]})]})}),!i&&!e.folder&&(0,Q.jsx)(`p`,{...ce(`group:${e.key}`,null),className:R(`mb-0.5 mt-1 rounded-md px-2 text-[11px] font-medium text-ink-subtle transition-colors`,ie===`group:${e.key}`&&oe?.folderId&&`bg-primary-500/10 ring-1 ring-primary-500/40 text-primary-600 dark:text-primary-400`),children:x(`chat.session.groups.${e.labelKey}`)}),e.folder&&j.has(e.folder.id)?null:(0,Q.jsx)(`div`,{className:R(`space-y-0.5`,i&&`space-y-1`),children:e.sessions.map(e=>{let t=n===e.id,l=H?.sessionId===e.id;return(0,Q.jsx)(`div`,{draggable:!i&&!!y&&a!==e.id,onDragStart:t=>{k(),U(null),re(e.id),t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,e.id)},onDragEnd:V,className:R(`group relative cursor-pointer transition-colors duration-150 touch-manipulation outline-none`,i?`rounded-xl p-1 flex items-center justify-center`:`rounded-lg px-2`,t?`bg-interactive-active`:`hover:bg-interactive-hover`,B===e.id&&`opacity-40`),onClick:()=>{k(),c(e)},onMouseEnter:t=>A(e,t.currentTarget),onMouseLeave:k,title:i?`${e.title} - ${e.model}`:void 0,children:i?(0,Q.jsx)(`div`,{className:`flex items-center justify-center w-full h-10`,children:(0,Q.jsx)(`div`,{className:R(`flex h-9 w-9 items-center justify-center rounded-xl text-[11px] font-semibold uppercase transition-colors`,r===e.id?`bg-white text-primary-600 animate-pulse dark:bg-dark-200 dark:text-primary-400`:t?`bg-gray-950 text-white dark:bg-white dark:text-gray-950`:`bg-white/70 text-gray-500 ring-1 ring-black/[0.04] dark:bg-dark-200/70 dark:text-dark-600 dark:ring-white/[0.05]`),children:e.title.trim().charAt(0)||`•`})}):a===e.id?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,onClick:e=>e.stopPropagation(),children:[(0,Q.jsx)(Ft,{value:o,onChange:e=>s(e.target.value),onKeyDown:t=>{t.key===`Enter`?u(e.id):t.key===`Escape`&&d()},className:`text-sm h-8`,autoFocus:!0}),(0,Q.jsx)(X,{variant:`ghost`,size:`sm`,onClick:()=>u(e.id),className:`h-8 w-8 p-0 shrink-0 hover:bg-gray-100 dark:hover:bg-dark-300 active:bg-gray-200 dark:active:bg-dark-400 touch-manipulation`,children:(0,Q.jsx)(Ye,{className:`h-3 w-3`})}),(0,Q.jsx)(X,{variant:`ghost`,size:`sm`,onClick:d,className:`h-8 w-8 p-0 shrink-0 hover:bg-gray-100 dark:hover:bg-dark-300 active:bg-gray-200 dark:active:bg-dark-400 touch-manipulation`,children:(0,Q.jsx)(K,{className:`h-3 w-3`})})]}):(0,Q.jsxs)(`div`,{className:`flex h-8 w-full items-center`,children:[(0,Q.jsx)(`h3`,{className:`min-w-0 flex-1 truncate text-sm leading-5 text-ink`,title:e.title,children:r===e.id?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,title:x(`chat.session.generatingTitle`),children:[(0,Q.jsx)(pe,{className:`h-3.5 w-3.5 shrink-0 animate-spin text-ink-subtle`}),(0,Q.jsx)(`span`,{className:`truncate`,children:L(e.title,40)})]}):L(e.title,40)}),(0,Q.jsx)(`span`,{dir:`auto`,className:R(`ms-2 shrink-0 text-xs leading-5 tabular-nums text-ink-subtle max-sm:hidden`,`sm:group-hover:hidden sm:group-focus-within:hidden`,l&&`sm:hidden`),children:ne(e.updatedAt,S.language)}),(0,Q.jsx)(X,{variant:`ghost`,size:`sm`,onClick:t=>{t.stopPropagation(),k(),E(e.id)},className:`h-8 w-8 shrink-0 rounded-lg p-0 touch-manipulation sm:hidden`,title:x(`palette.actions`),"aria-label":x(`palette.actions`),"data-testid":`sidebar-session-actions-mobile`,children:(0,Q.jsx)(G,{className:`h-4 w-4`})}),(0,Q.jsx)(`div`,{className:R(`hidden shrink-0`,`sm:group-hover:block sm:group-focus-within:block`,l&&`sm:block`),children:(0,Q.jsx)(X,{variant:`ghost`,size:`sm`,onClick:t=>fe(e,t),className:R(`h-6 w-6 rounded-md p-0 text-ink-subtle hover:text-ink hover:bg-transparent touch-manipulation`,l&&`text-ink`),title:x(`palette.actions`),"aria-label":x(`palette.actions`),"aria-haspopup":`menu`,"aria-expanded":l,"data-testid":`sidebar-session-actions`,children:(0,Q.jsx)(G,{className:`h-4 w-4`})})})]})},e.id)})})]},e.key))})]}),C&&(0,Q.jsx)(wn,{preview:C}),H&&W&&(0,fn.createPortal)((0,Q.jsxs)(`div`,{className:`fixed inset-0 z-[75] hidden sm:block`,children:[(0,Q.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-label":x(`common.close`),className:`absolute inset-0 cursor-default`,onClick:()=>U(null)}),(0,Q.jsxs)(`div`,{role:`menu`,"aria-label":W.title,"data-testid":`sidebar-session-menu`,className:`absolute overflow-y-auto rounded-xl border border-black/[0.04] bg-surface-overlay p-1 shadow-lv3 animate-scale-in dark:border-white/[0.06]`,style:{top:H.top,left:H.left,width:208,maxHeight:340},children:[(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{U(null),me(W)},className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-start text-[13px] text-ink hover:bg-interactive-hover`,children:[(0,Q.jsx)(Ne,{className:`h-3.5 w-3.5 shrink-0`}),x(`chat.session.openNewTab`)]}),(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:e=>{U(null),l(W,e)},className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-start text-[13px] text-ink hover:bg-interactive-hover`,children:[(0,Q.jsx)(Me,{className:`h-3.5 w-3.5 shrink-0`}),x(`chat.session.renameChat`)]}),m&&(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{U(null),m(W.id,!W.pinned)},className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-start text-[13px] text-ink hover:bg-interactive-hover`,children:[W.pinned?(0,Q.jsx)(Ze,{className:`h-3.5 w-3.5 shrink-0`}):(0,Q.jsx)(Je,{className:`h-3.5 w-3.5 shrink-0`}),W.pinned?x(`chat.session.unpinChat`):x(`chat.session.pinChat`)]}),!W.shared&&!W.isPrivate&&(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{U(null),ue(W)},className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-start text-[13px] text-ink hover:bg-interactive-hover`,"data-testid":`session-share`,children:[(0,Q.jsx)(ve,{className:`h-3.5 w-3.5 shrink-0`}),x(`chat.session.shareChat`)]}),p&&(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:e=>{U(null),p(W.id,e)},className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-start text-[13px] text-ink hover:bg-interactive-hover`,children:[(0,Q.jsx)(Ge,{className:`h-3.5 w-3.5 shrink-0`}),x(`chat.session.archiveChat`)]}),y&&h.length>0&&(0,Q.jsxs)(`div`,{className:`mt-1 border-t border-black/[0.06] pt-1 dark:border-white/[0.07]`,children:[(0,Q.jsx)(`p`,{className:`px-2.5 py-1 text-[10px] font-semibold uppercase tracking-[0.12em] text-gray-400 dark:text-dark-500 rtl:tracking-normal`,children:x(`chat.session.folder.move`)}),h.map(e=>(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{U(null),y(W.id,e.id)},className:R(`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-start text-[13px] text-ink hover:bg-interactive-hover`,W.folderId===e.id&&`text-primary-600 dark:text-primary-400`),children:[(0,Q.jsx)(Ae,{className:`h-3.5 w-3.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.name})]},e.id)),W.folderId&&(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{U(null),y(W.id,null)},className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-start text-[13px] text-ink-muted hover:bg-interactive-hover`,children:[(0,Q.jsx)(K,{className:`h-3.5 w-3.5 shrink-0`}),x(`chat.session.folder.remove`)]})]}),(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:e=>{U(null),f(W.id,e)},className:`mt-1 flex w-full items-center gap-2.5 rounded-lg border-t border-black/[0.06] px-2.5 py-2 text-start text-[13px] text-red-500 hover:bg-red-50 dark:border-white/[0.07] dark:hover:bg-red-900/20`,children:[(0,Q.jsx)(it,{className:`h-3.5 w-3.5 shrink-0`}),x(`chat.session.deleteChat`)]})]})]}),document.body),le&&(0,Q.jsx)(zt,{resourceType:`session`,resourceId:le.id,resourceLabel:le.title,onClose:()=>ue(null)}),O&&(0,fn.createPortal)((0,Q.jsxs)(`div`,{className:`fixed inset-0 z-[80] sm:hidden`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`absolute inset-0 bg-black/35 backdrop-blur-[2px]`,onClick:()=>E(null),"aria-label":x(`common.close`)}),(0,Q.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":x(`palette.actions`),className:`absolute inset-x-3 bottom-3 rounded-2xl border border-black/[0.08] bg-surface p-2 shadow-[0_20px_70px_rgba(0,0,0,0.3)] dark:border-white/[0.09] dark:bg-dark-100`,"data-testid":`sidebar-session-actions-sheet`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-2 pb-2 pt-1`,children:[(0,Q.jsx)(`p`,{className:`min-w-0 truncate text-sm font-semibold text-gray-900 dark:text-dark-900`,children:O.title}),(0,Q.jsx)(X,{variant:`ghost`,size:`sm`,onClick:()=>E(null),className:`h-9 w-9 shrink-0 rounded-xl p-0`,title:x(`common.close`),"aria-label":x(`common.close`),children:(0,Q.jsx)(K,{className:`h-4 w-4`})})]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:e=>{E(null),l(O,e)},className:`flex min-h-11 w-full items-center gap-3 rounded-xl px-3 py-2 text-start text-sm text-ink hover:bg-interactive-hover`,children:[(0,Q.jsx)(Me,{className:`h-4 w-4 shrink-0`}),x(`chat.session.renameChat`)]}),m&&(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{E(null),m(O.id,!O.pinned)},className:`flex min-h-11 w-full items-center gap-3 rounded-xl px-3 py-2 text-start text-sm text-ink hover:bg-interactive-hover`,children:[O.pinned?(0,Q.jsx)(Ze,{className:`h-4 w-4 shrink-0`}):(0,Q.jsx)(Je,{className:`h-4 w-4 shrink-0`}),O.pinned?x(`chat.session.unpinChat`):x(`chat.session.pinChat`)]}),p&&(0,Q.jsxs)(`button`,{type:`button`,onClick:e=>{E(null),p(O.id,e)},className:`flex min-h-11 w-full items-center gap-3 rounded-xl px-3 py-2 text-start text-sm text-ink hover:bg-interactive-hover`,children:[(0,Q.jsx)(Ge,{className:`h-4 w-4 shrink-0`}),x(`chat.session.archiveChat`)]}),y&&h.length>0&&(0,Q.jsxs)(`div`,{className:`mt-1 border-t border-black/[0.06] pt-1 dark:border-white/[0.07]`,children:[(0,Q.jsx)(`p`,{className:`px-3 py-1 text-[10px] font-semibold uppercase tracking-[0.12em] text-gray-400 dark:text-dark-500`,children:x(`chat.session.folder.move`)}),h.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{E(null),y(O.id,e.id)},className:R(`flex min-h-11 w-full items-center gap-3 rounded-xl px-3 py-2 text-start text-sm text-ink hover:bg-interactive-hover`,O.folderId===e.id&&`text-primary-600 dark:text-primary-400`),children:[(0,Q.jsx)(Ae,{className:`h-4 w-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.name})]},e.id)),O.folderId&&(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{E(null),y(O.id,null)},className:`flex min-h-11 w-full items-center gap-3 rounded-xl px-3 py-2 text-start text-sm text-gray-500 hover:bg-gray-100 dark:text-dark-600 dark:hover:bg-dark-200`,children:[(0,Q.jsx)(K,{className:`h-4 w-4 shrink-0`}),x(`chat.session.folder.remove`)]})]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:e=>{E(null),f(O.id,e)},className:`mt-1 flex min-h-11 w-full items-center gap-3 rounded-xl border-t border-black/[0.06] px-3 py-2 text-start text-sm text-red-500 hover:bg-red-50 dark:border-white/[0.07] dark:hover:bg-red-900/20`,children:[(0,Q.jsx)(it,{className:`h-4 w-4 shrink-0`}),x(`chat.session.deleteChat`)]})]})]}),document.body)]})}var En=[{id:`users`,to:`/users`,icon:Pe,labelKey:`user.menu.userManagement`},{id:`system`,to:`/system`,icon:xe,labelKey:`user.menu.system`},{id:`usage`,to:`/usage`,icon:Te,labelKey:`user.menu.usageAnalytics`},{id:`evaluations`,to:`/evaluations`,icon:Be,labelKey:`user.menu.evaluations`}];function Dn({user:e,size:t}){let n=t===`sm`?`w-7 h-7`:`w-8 h-8`,r=t===`sm`?`text-xs`:`text-sm`;return e.avatar?(0,Q.jsx)(`img`,{src:e.avatar,alt:e.username,className:`${n} rounded-full object-cover ring-1 ring-black/10 dark:ring-white/10`,title:`${e.username} (${e.role})`}):(0,Q.jsx)(`div`,{className:`${n} bg-gray-950 dark:bg-white rounded-full flex items-center justify-center`,title:`${e.username} (${e.role})`,children:(0,Q.jsx)(`span`,{className:`text-white dark:text-gray-950 ${r} font-medium`,children:e.username.charAt(0).toUpperCase()})})}function On({requiresAuth:e,user:t,isAdmin:n,pendingApprovalCount:r,sidebarCompact:i,userMenuOpen:a,userMenuRef:o,pinnedShortcuts:s,onToggleShortcutPin:c,onToggleUserMenu:l,onOpenSettings:u,onOpenAvatar:d,onLogout:f,onMobileNavigate:p,onCloseUserMenu:m}){let{t:h}=I();if(!e||!t)return null;let g=n?En.filter(e=>s.includes(e.id)):[],_=()=>n&&En.map(e=>{let t=s.includes(e.id),n=h(t?`user.menu.unpinShortcut`:`user.menu.pinShortcut`);return(0,Q.jsxs)(`div`,{className:`group/shortcut relative`,children:[(0,Q.jsxs)(M,{to:e.to,onClick:()=>{m(),p()},className:`flex w-full items-center gap-3 px-3 py-2.5 pe-9 text-[13px] text-ink transition-colors duration-150 hover:bg-interactive-hover`,children:[(0,Q.jsx)(e.icon,{className:`h-4 w-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 text-start`,children:h(e.labelKey)}),e.id===`users`&&r>0&&(0,Q.jsx)(`span`,{className:`rounded-md bg-error-500 px-1.5 py-0.5 text-[10px] font-semibold text-white`,children:r>99?`99+`:r})]}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>c(e.id),className:R(`absolute end-2 top-1/2 -translate-y-1/2 rounded-md p-1 text-ink-subtle transition-[color,opacity] hover:text-ink focus-visible:opacity-100`,t?`opacity-100 text-primary-600 dark:text-primary-400 hover:text-primary-500`:`opacity-0 group-hover/shortcut:opacity-100`),title:n,"aria-label":`${n}: ${h(e.labelKey)}`,"aria-pressed":t,"data-testid":`sidebar-shortcut-pin-${e.id}`,children:t?(0,Q.jsx)(Ze,{className:`h-3.5 w-3.5`}):(0,Q.jsx)(Je,{className:`h-3.5 w-3.5`})})]},e.id)});return(0,Q.jsx)(`div`,{className:R(`border-t border-black/[0.04] dark:border-white/[0.06]`,`p-2`),children:i?(0,Q.jsxs)(`div`,{className:`relative flex flex-col items-center gap-1`,ref:o,children:[g.map(e=>(0,Q.jsxs)(M,{to:e.to,onClick:p,className:`relative flex h-9 w-9 items-center justify-center rounded-full text-ink outline-none transition-colors hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-primary-500/30`,title:h(e.labelKey),"aria-label":h(e.labelKey),"data-testid":`sidebar-rail-pinned-${e.id}`,children:[(0,Q.jsx)(e.icon,{className:`h-[18px] w-[18px]`}),e.id===`users`&&r>0&&(0,Q.jsx)(`span`,{className:`absolute -end-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-md bg-error-500 px-1 text-[9px] font-semibold text-white shadow-sm`,children:r>99?`99+`:r})]},e.id)),(0,Q.jsx)(`button`,{type:`button`,onClick:u,className:`flex h-9 w-9 items-center justify-center rounded-full text-ink outline-none transition-colors hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-primary-500/30`,title:h(`user.menu.settings`),"aria-label":h(`user.menu.settings`),"data-testid":`sidebar-rail-settings-button`,children:(0,Q.jsx)(dt,{className:`h-[18px] w-[18px]`})}),(0,Q.jsxs)(`button`,{type:`button`,onClick:l,className:`relative flex h-9 w-9 items-center justify-center rounded-full outline-none transition-colors hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-primary-500/30`,"aria-label":t.username,"aria-expanded":a,title:t.username,"data-testid":`sidebar-rail-user-menu-button`,children:[(0,Q.jsx)(Dn,{user:t,size:`sm`}),r>0&&(0,Q.jsx)(`span`,{"data-testid":`pending-user-notification-badge`,className:`absolute -end-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-md bg-error-500 px-1 text-[9px] font-semibold text-white shadow-sm`,"aria-label":h(`userManager.approval.notificationBadge`,{count:r,defaultValue:`{{count}} pending user approvals`}),children:r>99?`99+`:r})]}),a&&(0,Q.jsxs)(`div`,{"data-testid":`sidebar-user-menu`,className:`scroll-region absolute bottom-0 start-full z-[70] ms-3 w-64 max-h-[calc(100dvh-1rem)] overflow-y-auto rounded-xl border border-black/[0.04] bg-surface-overlay py-1 shadow-lv3 animate-scale-in scrollbar-thin dark:border-white/[0.06]`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{d(t.avatar||``),m()},className:`flex w-full items-center gap-2.5 border-b border-gray-100 px-3 py-2.5 text-start transition-colors hover:bg-gray-100/70 dark:border-dark-200/50 dark:hover:bg-dark-200/70`,children:[(0,Q.jsx)(Dn,{user:t,size:`md`}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block truncate text-sm font-medium text-gray-900 dark:text-gray-100`,children:t.username}),(0,Q.jsx)(`span`,{className:`block truncate text-xs text-gray-500 dark:text-gray-400`,children:h(`user.menu.changePicture`)})]}),(0,Q.jsx)(Ce,{className:`h-4 w-4 shrink-0 text-gray-400`})]}),(0,Q.jsxs)(`div`,{className:`py-1`,children:[_(),(0,Q.jsx)(`div`,{className:`my-1 border-t border-gray-100 dark:border-dark-200/50`}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{u(),m()},className:`flex w-full items-center gap-3 px-3 py-2.5 text-start text-[13px] text-ink transition-colors hover:bg-interactive-hover`,children:[(0,Q.jsx)(dt,{className:`h-4 w-4 shrink-0`}),h(`user.menu.settings`)]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{f(),m()},className:`flex w-full items-center gap-3 px-3 py-2.5 text-start text-[13px] text-red-600 transition-colors hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-900/20`,children:[(0,Q.jsx)(Ue,{className:`h-4 w-4 shrink-0`}),h(`user.menu.logout`)]})]})]})]}):(0,Q.jsxs)(`div`,{className:`relative`,ref:o,children:[g.map(e=>(0,Q.jsxs)(M,{to:e.to,onClick:p,className:`flex h-[34px] w-full items-center gap-2 rounded-xl px-2.5 text-start text-sm text-ink transition-colors duration-150 hover:bg-interactive-hover touch-manipulation outline-none focus-visible:ring-2 focus-visible:ring-primary-500/30`,"data-testid":`sidebar-pinned-${e.id}`,children:[(0,Q.jsx)(e.icon,{className:`h-4 w-4 shrink-0 text-ink-muted`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:h(e.labelKey)}),e.id===`users`&&r>0&&(0,Q.jsx)(`span`,{className:`rounded-md bg-error-500 px-1.5 py-0.5 text-[10px] font-semibold text-white`,children:r>99?`99+`:r})]},e.id)),(0,Q.jsxs)(`button`,{type:`button`,onClick:u,className:`flex h-[34px] w-full items-center gap-2 rounded-xl px-2.5 text-start text-sm text-ink transition-colors duration-150 hover:bg-interactive-hover touch-manipulation outline-none focus-visible:ring-2 focus-visible:ring-primary-500/30`,"data-testid":`sidebar-settings-button`,children:[(0,Q.jsx)(dt,{className:`h-4 w-4 shrink-0 text-ink-muted`}),h(`user.menu.settings`)]}),(0,Q.jsxs)(`button`,{onClick:l,className:`relative h-[38px] w-full rounded-xl px-2.5 hover:bg-interactive-hover transition-colors duration-150 text-start touch-manipulation outline-none focus-visible:ring-2 focus-visible:ring-primary-500/30`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Dn,{user:t,size:`sm`}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[(0,Q.jsx)(`p`,{className:`truncate text-sm text-ink`,children:t.username}),t.role===`admin`&&(0,Q.jsx)(me,{size:11,className:`shrink-0 text-ink-subtle`})]}),(0,Q.jsx)(Se,{className:R(`h-4 w-4 text-ink-subtle transition-transform duration-150 rtl:rotate-180`,a&&`rotate-90 rtl:rotate-90`)})]}),n&&r>0&&(0,Q.jsx)(`span`,{"data-testid":`pending-user-notification-badge`,className:`absolute -end-1 -top-1 flex h-5 min-w-5 items-center justify-center rounded-full bg-error-500 px-1 text-[10px] font-semibold text-white shadow-subtle`,"aria-label":h(`userManager.approval.notificationBadge`,{count:r,defaultValue:`{{count}} pending user approvals`}),children:r>99?`99+`:r})]}),a&&(0,Q.jsxs)(`div`,{"data-testid":`sidebar-user-menu`,className:`scroll-region absolute bottom-full left-0 right-0 z-50 mb-2 max-h-[calc(100dvh-1rem)] rounded-xl border border-black/[0.04] bg-surface-overlay py-1 shadow-lv3 animate-scale-in scrollbar-thin dark:border-white/[0.06]`,children:[(0,Q.jsx)(`div`,{className:`px-3 py-2 border-b border-gray-100 dark:border-dark-200/50`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,Q.jsx)(Dn,{user:t,size:`md`}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:t.username}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 truncate`,children:t.email||h(`user.profile.noEmail`)})]})]})}),(0,Q.jsxs)(`div`,{className:`py-1`,children:[(0,Q.jsxs)(`button`,{onClick:()=>{d(t.avatar||``),m()},className:`w-full flex items-center gap-3 px-3 py-2.5 text-[13px] text-ink hover:bg-interactive-hover transition-colors duration-150 text-start`,children:[(0,Q.jsx)(Ce,{className:`h-4 w-4 shrink-0`}),h(`user.menu.changePicture`)]}),_(),(0,Q.jsx)(`div`,{className:`border-t border-gray-100 dark:border-dark-200/50 my-1`}),(0,Q.jsxs)(`button`,{onClick:()=>{u(),m()},className:`w-full flex items-center gap-3 px-3 py-2.5 text-[13px] text-ink hover:bg-interactive-hover transition-colors duration-150 text-start`,children:[(0,Q.jsx)(dt,{className:`h-4 w-4 shrink-0`}),h(`user.menu.settings`)]}),(0,Q.jsxs)(`button`,{onClick:()=>{f(),m()},className:`w-full flex items-center gap-3 px-3 py-2.5 text-[13px] text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors duration-150 text-start`,children:[(0,Q.jsx)(Ue,{className:`h-4 w-4 shrink-0`}),h(`user.menu.logout`)]})]})]})]})})}var kn=F(`notification-bell`),An=({sidebarCompact:e})=>{let{t,i18n:n}=I(),r=T(),[i,a]=(0,Z.useState)(0),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(null),u=(0,Z.useRef)(null),d=(0,Z.useCallback)(()=>{_t.unreadCount().then(e=>{e.success&&e.data&&a(e.data.count)}).catch(e=>kn.debug(`Unread poll failed:`,e))},[]);(0,Z.useEffect)(()=>{d();let e=window.setInterval(d,6e4),t=new AbortController;return Bt({path:`/notifications/events`,signal:t.signal,onEvent:()=>d()}),()=>{window.clearInterval(e),t.abort()}},[d]);let f=()=>{s(!0),_t.list({limit:50}).then(e=>{e.success&&e.data&&l(e.data)}).catch(e=>kn.error(`Failed to load notifications:`,e))},p=e=>{_t.markRead(e.id).then(d),s(!1),e.href&&r(e.href)};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>o?s(!1):f(),className:R(`relative flex items-center gap-2 rounded-lg text-[13px] text-gray-600 hover:bg-black/[0.04] dark:text-dark-700 dark:hover:bg-white/[0.06]`,e?`mx-auto h-9 w-9 justify-center`:`mx-2 px-2 py-1.5`),title:t(`notifications.title`),"aria-label":t(`notifications.title`),"data-testid":`notification-bell`,children:[(0,Q.jsx)(et,{className:`h-4 w-4 shrink-0`}),!e&&(0,Q.jsx)(`span`,{children:t(`notifications.title`)}),i>0&&(0,Q.jsx)(`span`,{className:R(`rounded-full bg-primary-500 px-1.5 text-[10px] font-semibold leading-4 text-white`,e&&`absolute -right-0.5 -top-0.5`),"data-testid":`notification-unread-badge`,children:i>99?`99+`:i})]}),o&&(0,fn.createPortal)((0,Q.jsx)(`div`,{className:`fixed inset-0 z-[2147483646]`,onClick:()=>s(!1),children:(0,Q.jsxs)(`div`,{ref:u,role:`dialog`,"aria-label":t(`notifications.title`),className:`absolute bottom-16 left-4 flex max-h-[70vh] w-80 flex-col overflow-hidden rounded-2xl border border-black/[0.08] bg-white shadow-[0_18px_60px_rgba(0,0,0,0.22)] dark:border-white/[0.1] dark:bg-dark-25`,onClick:e=>e.stopPropagation(),"data-testid":`notification-panel`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-black/[0.06] px-3 py-2 dark:border-white/[0.06]`,children:[(0,Q.jsx)(`span`,{className:`flex-1 text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-dark-600`,children:t(`notifications.title`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void _t.markAllRead().then(()=>{d(),l(e=>e&&e.map(e=>({...e,readAt:e.readAt??Date.now()})))}),className:`rounded-md p-1 text-gray-400 hover:text-gray-700 dark:hover:text-dark-800`,title:t(`notifications.markAllRead`),"data-testid":`notification-mark-all`,children:(0,Q.jsx)(U,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>s(!1),className:`rounded-md p-1 text-gray-400 hover:text-gray-700 dark:hover:text-dark-800`,children:(0,Q.jsx)(K,{className:`h-3.5 w-3.5`})})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto scrollbar-thin`,children:c===null?(0,Q.jsx)(pe,{className:`mx-auto my-6 h-4 w-4 animate-spin text-gray-400`}):c.length===0?(0,Q.jsx)(`p`,{className:`py-8 text-center text-xs text-gray-400 dark:text-dark-500`,children:t(`notifications.empty`)}):c.map(e=>(0,Q.jsxs)(`div`,{className:R(`group flex cursor-pointer items-start gap-2 border-b border-black/[0.04] px-3 py-2.5 last:border-b-0 hover:bg-black/[0.03] dark:border-white/[0.04] dark:hover:bg-white/[0.04]`,!e.readAt&&`bg-primary-500/[0.04]`),onClick:()=>p(e),"data-testid":`notification-item`,children:[(0,Q.jsx)(`span`,{className:R(`mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full`,e.readAt?`bg-transparent`:`bg-primary-500`)}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{className:`text-[13px] font-medium leading-snug text-gray-900 dark:text-dark-900`,children:e.title}),e.body&&(0,Q.jsx)(`p`,{className:`mt-0.5 truncate text-[12px] text-gray-500 dark:text-dark-600`,children:e.body}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-[11px] text-gray-400 dark:text-dark-500`,children:ne(e.createdAt,n.language)})]}),!e.readAt&&(0,Q.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),_t.markRead(e.id).then(()=>{d(),l(t=>t&&t.map(t=>t.id===e.id?{...t,readAt:Date.now()}:t))})},className:`hidden rounded p-1 text-gray-400 hover:text-emerald-600 group-hover:block`,title:t(`notifications.markRead`),"data-testid":`notification-mark-read`,children:(0,Q.jsx)(Ye,{className:`h-3.5 w-3.5`})})]},e.id))})]})}),document.body)]})};function jn(e,t){return e.isAgent===!0&&!t&&typeof e.lastSeenAt==`number`&&e.updatedAt>e.lastSeenAt&&(e.status===`completed`||e.status===`needs_input`||e.status===`failed`)}function Mn({preview:e}){let{t}=I(),{task:n}=e,r=Vt[n.status],i=t(r.labelKey,{defaultValue:r.label});return(0,Q.jsxs)(xn,{top:e.top,left:e.left,title:n.title||t(`work.tasks.untitled`,{defaultValue:`Untitled task`}),timestamp:n.updatedAt,children:[(0,Q.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[11px] leading-snug text-gray-600 dark:text-dark-700`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:R(`h-2 w-2 shrink-0 rounded-full`,r.animated&&`animate-pulse`),style:{backgroundColor:r.color}}),i]}),n.statusBlurb&&(0,Q.jsx)(`p`,{dir:`auto`,className:`mt-1.5 line-clamp-2 text-[11px] leading-snug text-gray-600 dark:text-dark-700`,children:n.statusBlurb}),(0,Q.jsx)(`p`,{className:`mt-1.5 truncate font-mono text-[10px] text-gray-400 dark:text-dark-500`,children:n.model}),n.hostPath&&(0,Q.jsx)(`p`,{className:`mt-1 truncate font-mono text-[10px] text-gray-400 dark:text-dark-500`,title:n.hostPath,children:n.hostPath})]})}var Nn=208,Pn=180;function Fn({tasks:e,personas:t,currentTaskId:n,loading:r,actionLoading:i,sidebarCompact:a,onSelectTask:o,onDeleteTask:s,onExpandSidebar:c}){let{t:l,i18n:u}=I(),d=e.filter(e=>e.isAgent===!0),f=e.filter(e=>e.isAgent!==!0),p=d,[m,h]=(0,Z.useState)(null),g=(0,Z.useRef)(null),[_,v]=(0,Z.useState)(null),y=_?e.find(e=>e.id===_)??null:null;(0,Z.useEffect)(()=>()=>{g.current!==null&&window.clearTimeout(g.current)},[]);let b=()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null),h(null)},x=(e,t)=>{let n=window.matchMedia(`(hover: hover) and (pointer: fine)`).matches;a||window.innerWidth<768||!n||(g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>{let n=t.getBoundingClientRect();h({task:e,top:n.top,left:n.right+10})},500))},[S,C]=(0,Z.useState)(null),w=S?e.find(e=>e.id===S.taskId)??null:null;(0,Z.useEffect)(()=>{if(!S)return;let e=e=>{e.key===`Escape`&&C(null)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[S]);let T=(e,t)=>{if(t.stopPropagation(),b(),S?.taskId===e.id){C(null);return}let n=t.currentTarget.getBoundingClientRect();C({taskId:e.id,top:Math.max(8,Math.min(n.bottom+6,window.innerHeight-Pn-8)),left:Math.max(8,Math.min(n.right-Nn,window.innerWidth-Nn-8))})},E=e=>{let t=window.location.protocol===`file:`?`${window.location.pathname}#/work/${e.id}`:`/work/${e.id}`;window.open(t,`_blank`,`noopener,noreferrer`)},D=e=>e.title||l(`work.tasks.untitled`,{defaultValue:`Untitled task`}),O=e=>{let r=n===e.id,i=Vt[e.status],a=l(i.labelKey,{defaultValue:i.label}),s=S?.taskId===e.id,c=e.isAgent===!0,d=c&&e.personaId?t[e.personaId]:void 0,f=jn(e,r),p=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{dir:`auto`,className:R(`ms-2 shrink-0 text-xs leading-5 tabular-nums text-ink-subtle max-sm:hidden`,`sm:group-hover:hidden sm:group-focus-within:hidden`,s&&`sm:hidden`),children:ne(e.updatedAt,u.language)}),(0,Q.jsx)(X,{variant:`ghost`,size:`sm`,onClick:t=>{t.stopPropagation(),b(),v(e.id)},className:`h-8 w-8 shrink-0 rounded-lg p-0 touch-manipulation sm:hidden`,title:l(`palette.actions`),"aria-label":l(`palette.actions`),"data-testid":`sidebar-work-task-actions-mobile`,children:(0,Q.jsx)(G,{className:`h-4 w-4`})}),(0,Q.jsx)(`div`,{className:R(`hidden shrink-0`,`sm:group-hover:block sm:group-focus-within:block`,s&&`sm:block`),children:(0,Q.jsx)(X,{variant:`ghost`,size:`sm`,onClick:t=>T(e,t),className:R(`h-6 w-6 rounded-md p-0 text-ink-subtle hover:text-ink hover:bg-transparent touch-manipulation`,s&&`text-ink`),title:l(`palette.actions`),"aria-label":l(`palette.actions`),"aria-haspopup":`menu`,"aria-expanded":s,"data-testid":`sidebar-work-task-actions`,children:(0,Q.jsx)(G,{className:`h-4 w-4`})})})]});return(0,Q.jsx)(`div`,{"data-testid":`sidebar-work-task-item`,"data-task-id":e.id,"data-agent":c?`true`:void 0,"aria-current":r?`page`:void 0,className:R(`group relative cursor-pointer rounded-lg px-2 transition-colors duration-150 outline-none touch-manipulation`,r?`bg-interactive-active`:`hover:bg-interactive-hover`),onClick:()=>{b(),o(e.id)},onMouseEnter:t=>x(e,t.currentTarget),onMouseLeave:b,children:c?(0,Q.jsxs)(`div`,{className:`flex w-full items-center gap-2.5 py-1.5`,children:[(0,Q.jsxs)(`span`,{className:`relative shrink-0`,children:[(0,Q.jsx)(`img`,{src:d?St(d,64):Ct(D(e),64),alt:``,"aria-hidden":`true`,"data-testid":`sidebar-work-agent-avatar`,onError:t=>xt(t.currentTarget,d?.name??D(e),64),className:`h-8 w-8 rounded-lg object-cover`}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,"data-testid":`sidebar-work-task-status`,"data-status-label":a,className:R(`absolute -bottom-0.5 -end-0.5 h-2.5 w-2.5 rounded-full border-2 border-gray-100 dark:border-dark-50`,i.animated&&`animate-pulse`,e.status===`idle`&&`ring-1 ring-black/20 dark:ring-white/20`),style:{backgroundColor:i.color}})]}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center`,children:[(0,Q.jsxs)(`h3`,{dir:`auto`,className:R(`min-w-0 flex-1 truncate text-sm leading-5 text-ink`,f&&`font-medium`),title:D(e),children:[L(D(e),34),(0,Q.jsx)(`span`,{className:`sr-only`,children:l(`work.tasks.status`,{defaultValue:`Status: {{status}}`,status:a})})]}),f&&(0,Q.jsx)(`span`,{"data-testid":`sidebar-work-agent-unread`,"aria-label":l(`work.agent.unread`,{defaultValue:`New activity`}),className:`ms-2 h-2 w-2 shrink-0 rounded-full bg-primary-500 shadow-[0_0_8px_rgb(var(--color-primary-500)/0.6)]`}),p]}),(0,Q.jsx)(`p`,{dir:`auto`,"data-testid":`sidebar-work-agent-blurb`,className:R(`truncate text-[11px] leading-4`,f?`text-ink-muted`:`text-ink-subtle`),title:e.statusBlurb||a,children:e.statusBlurb||a})]})]}):(0,Q.jsxs)(`div`,{className:`flex h-8 w-full items-center`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,"data-testid":`sidebar-work-task-status`,"data-status-label":a,className:R(`me-2 h-2 w-2 shrink-0 rounded-full`,i.animated&&`animate-pulse`,e.status===`idle`&&`ring-1 ring-black/20 dark:ring-white/20`),style:{backgroundColor:i.color}}),(0,Q.jsxs)(`h3`,{dir:`auto`,className:`min-w-0 flex-1 truncate text-sm leading-5 text-ink`,title:D(e),children:[L(D(e),40),(0,Q.jsx)(`span`,{className:`sr-only`,children:l(`work.tasks.status`,{defaultValue:`Status: {{status}}`,status:a})})]}),p]})},e.id)};return(0,Q.jsxs)(`div`,{"data-testid":`sidebar-work-task-scroll-region`,className:`scroll-region min-h-0 flex-1 border-t border-black/[0.05] scrollbar-thin dark:border-white/[0.05]`,style:{willChange:`scroll-position`},children:[(0,Q.jsxs)(`div`,{className:R(`px-3 py-3`,a&&`px-2`),children:[!a&&e.length>0&&(0,Q.jsxs)(`div`,{className:`mb-2 flex items-center justify-between px-1`,children:[(0,Q.jsx)(`h3`,{className:`text-xs font-medium text-ink-subtle`,children:d.length>0?l(`work.agents.title`,{defaultValue:`Agents`}):l(`work.tasks.title`,{defaultValue:`Work tasks`})}),(0,Q.jsx)(`span`,{className:`text-[10px] font-medium tabular-nums text-gray-400 dark:text-dark-500`,children:d.length>0?d.length:e.length})]}),a?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:c,"data-testid":`sidebar-mobile-work-tasks`,"aria-label":`${l(`work.tasks.title`,{defaultValue:`Work tasks`})} (${e.length})`,title:l(`work.tasks.title`,{defaultValue:`Work tasks`}),className:`relative flex h-12 w-12 items-center justify-center rounded-xl text-gray-500 outline-none transition-colors hover:bg-white/70 hover:text-gray-950 focus-visible:ring-2 focus-visible:ring-primary-500/30 dark:text-dark-600 dark:hover:bg-dark-200 dark:hover:text-dark-950 md:hidden`,children:[(0,Q.jsx)(V,{className:`h-[18px] w-[18px]`}),e.length>0&&(0,Q.jsx)(`span`,{className:`absolute -end-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-md bg-primary-500 px-1 text-[9px] font-semibold tabular-nums text-white shadow-sm`,children:e.length>99?`99+`:e.length})]}),(0,Q.jsx)(`div`,{"data-testid":`sidebar-compact-work-agent-list`,className:`flex w-full flex-col items-center gap-1`,children:p.map(e=>{let r=n===e.id,i=Vt[e.status],a=l(i.labelKey,{defaultValue:i.label}),s=D(e),c=e.personaId?t[e.personaId]:void 0,u=jn(e,r),d=[s,l(`work.tasks.status`,{defaultValue:`Status: {{status}}`,status:a}),u?l(`work.agent.unread`,{defaultValue:`New activity`}):null].filter(Boolean).join(`. `);return(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>o(e.id),"data-testid":`sidebar-compact-work-agent`,"data-task-id":e.id,"data-agent":`true`,"aria-current":r?`page`:void 0,"aria-label":d,title:d,className:R(`relative flex h-12 w-12 items-center justify-center rounded-xl outline-none transition-colors focus-visible:ring-2 focus-visible:ring-primary-500/30`,r?`bg-primary-500/10 text-primary-700 ring-1 ring-primary-500/10 dark:bg-primary-500/15 dark:text-primary-300 dark:ring-primary-400/10`:`text-gray-500 hover:bg-white/70 hover:text-gray-950 dark:text-dark-600 dark:hover:bg-dark-200 dark:hover:text-dark-950`),children:[r&&(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`absolute -start-2 h-5 w-0.5 rounded-full bg-primary-500 shadow-[0_0_12px_rgb(var(--color-primary-500)/0.55)]`}),(0,Q.jsx)(`img`,{src:c?St(c,64):Ct(s,64),alt:``,"aria-hidden":`true`,"data-testid":`sidebar-compact-work-agent-avatar`,onError:e=>xt(e.currentTarget,c?.name??s,64),className:`h-9 w-9 rounded-lg object-cover`}),u&&(0,Q.jsx)(`span`,{"aria-hidden":`true`,"data-testid":`sidebar-compact-work-agent-unread`,className:`absolute end-1.5 top-1.5 h-2 w-2 rounded-full bg-primary-500 ring-2 ring-gray-100 dark:ring-dark-50`}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,"data-testid":`sidebar-compact-work-agent-status`,"data-status":e.status,className:R(`absolute bottom-1.5 end-1.5 h-2 w-2 rounded-full border-2 border-gray-100 dark:border-dark-50`,i.animated&&`animate-pulse`,e.status===`idle`&&`ring-1 ring-black/20 dark:ring-white/20`),style:{backgroundColor:i.color}})]},e.id)})})]}):r&&e.length===0?(0,Q.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`flex items-center justify-center py-10 text-gray-400 dark:text-dark-500`,children:[(0,Q.jsx)(pe,{"aria-hidden":`true`,className:`h-5 w-5 animate-spin`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:l(`work.tasks.loading`,{defaultValue:`Loading Work tasks`})})]}):e.length===0?(0,Q.jsxs)(`div`,{className:R(`py-8 text-center`,a?`px-1`:`px-2`),children:[(0,Q.jsx)(`div`,{className:R(`mx-auto mb-3 flex items-center justify-center rounded-xl bg-white/70 ring-1 ring-black/[0.04] dark:bg-dark-200 dark:ring-white/[0.05]`,a?`h-8 w-8`:`h-12 w-12`),children:(0,Q.jsx)(V,{className:R(`text-gray-400 dark:text-gray-500`,a?`h-4 w-4`:`h-5 w-5`)})}),!a&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-gray-600 dark:text-dark-600`,children:l(`work.tasks.emptyTitle`,{defaultValue:`No Work tasks yet`})}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-gray-400 dark:text-dark-500`,children:l(`work.tasks.empty`,{defaultValue:`Your Work tasks will appear here after you send the first message.`})})]})]}):(0,Q.jsx)(`div`,{"data-testid":`sidebar-work-task-list`,className:`space-y-0.5`,children:d.length>0?(0,Q.jsxs)(Q.Fragment,{children:[d.map(O),f.length>0&&(0,Q.jsxs)(`div`,{className:`mb-1 mt-4 flex items-center justify-between px-1`,children:[(0,Q.jsx)(`h3`,{className:`text-xs font-medium text-ink-subtle`,children:l(`work.tasks.title`,{defaultValue:`Work tasks`})}),(0,Q.jsx)(`span`,{className:`text-[10px] font-medium tabular-nums text-gray-400 dark:text-dark-500`,children:f.length})]}),f.map(O)]}):e.map(O)})]}),m&&(0,Q.jsx)(Mn,{preview:m}),S&&w&&(0,fn.createPortal)((0,Q.jsxs)(`div`,{className:`fixed inset-0 z-[75] hidden sm:block`,children:[(0,Q.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-label":l(`common.close`),className:`absolute inset-0 cursor-default`,onClick:()=>C(null)}),(0,Q.jsxs)(`div`,{role:`menu`,"aria-label":D(w),"data-testid":`sidebar-work-task-menu`,className:`absolute overflow-y-auto rounded-xl border border-black/[0.04] bg-surface-overlay p-1 shadow-lv3 animate-scale-in dark:border-white/[0.06]`,style:{top:S.top,left:S.left,width:Nn,maxHeight:Pn},children:[(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{C(null),E(w)},className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-start text-[13px] text-ink hover:bg-interactive-hover`,children:[(0,Q.jsx)(Ne,{className:`h-3.5 w-3.5 shrink-0`}),l(`chat.session.openNewTab`)]}),(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,disabled:i,"data-testid":`sidebar-work-task-delete`,onClick:()=>{C(null),s(w)},className:`mt-1 flex w-full items-center gap-2.5 rounded-lg border-t border-black/[0.06] px-2.5 py-2 text-start text-[13px] text-red-500 hover:bg-red-50 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/[0.07] dark:hover:bg-red-900/20`,children:[(0,Q.jsx)(it,{className:`h-3.5 w-3.5 shrink-0`}),l(`work.tasks.delete`,{defaultValue:`Delete task`})]})]})]}),document.body),y&&(0,fn.createPortal)((0,Q.jsxs)(`div`,{className:`fixed inset-0 z-[80] sm:hidden`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`absolute inset-0 bg-black/35 backdrop-blur-[2px]`,onClick:()=>v(null),"aria-label":l(`common.close`)}),(0,Q.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":l(`palette.actions`),className:`absolute inset-x-3 bottom-3 rounded-2xl border border-black/[0.08] bg-surface p-2 shadow-[0_20px_70px_rgba(0,0,0,0.3)] dark:border-white/[0.09] dark:bg-dark-100`,"data-testid":`sidebar-work-task-actions-sheet`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-2 pb-2 pt-1`,children:[(0,Q.jsx)(`p`,{className:`min-w-0 truncate text-sm font-semibold text-gray-900 dark:text-dark-900`,children:D(y)}),(0,Q.jsx)(X,{variant:`ghost`,size:`sm`,onClick:()=>v(null),className:`h-9 w-9 shrink-0 rounded-xl p-0`,title:l(`common.close`),"aria-label":l(`common.close`),children:(0,Q.jsx)(K,{className:`h-4 w-4`})})]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{v(null),E(y)},className:`flex w-full items-center gap-3 rounded-xl px-3 py-3 text-start text-sm text-ink hover:bg-interactive-hover`,children:[(0,Q.jsx)(Ne,{className:`h-4 w-4 shrink-0`}),l(`chat.session.openNewTab`)]}),(0,Q.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>{v(null),s(y)},className:`flex w-full items-center gap-3 rounded-xl px-3 py-3 text-start text-sm text-red-500 hover:bg-red-50 disabled:cursor-not-allowed disabled:opacity-40 dark:hover:bg-red-900/20`,children:[(0,Q.jsx)(it,{className:`h-4 w-4 shrink-0`}),l(`work.tasks.delete`,{defaultValue:`Delete task`})]})]})]}),document.body)]})}function In(e){let{t}=I(),n=(0,Z.useRef)(null),r=v({queryKey:[`users`,`pending-approvals`],enabled:e,queryFn:async()=>{let e=await yt.getPendingApprovals();if(!e.success||!e.data)throw Error(e.message||`Could not load pending accounts`);return e.data},refetchInterval:6e4,refetchOnWindowFocus:!0});return(0,Z.useEffect)(()=>{if(!r.data)return;let e=n.current,i=e?!!(r.data.count>e.count||r.data.latestCreatedAt&&r.data.latestCreatedAt!==e.latestCreatedAt):r.data.count>0;n.current=r.data,i&&q(t(`userManager.approval.notification`,{count:r.data.count,defaultValue:`{{count}} registration(s) are waiting for your approval.`}),{icon:`👤`})},[r.data,t]),{...r,pendingApprovalCount:r.data?.count??0}}function Ln(e){let{t}=I(),n=(0,Z.useRef)(null),r=v({queryKey:[`automations`,`runs-summary`],enabled:e,queryFn:async()=>{let e=await bt.getRunsSummary();if(!e.success||!e.data)throw Error(e.error||`Could not load automation runs`);return e.data},refetchInterval:6e4,refetchOnWindowFocus:!0});return(0,Z.useEffect)(()=>{if(!r.data)return;let e=n.current,i=r.data.unseenCount;e!==null&&i>e&&q(t(`automations.finishedNotification`,{n:i}),{icon:`⚡`}),n.current=i},[r.data,t]),{...r,unseenRunCount:r.data?.unseenCount??0}}var Rn=F(`components:sidebar`),zn=Z.lazy(()=>P(()=>import(`../js/SettingsModal-Cl5eVfDM.js`).then(e=>({default:e.SettingsModal})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28]))),Bn=({isOpen:e,onClose:t,className:n})=>{let{t:r}=I(),i=ee(),a=T(),{sessions:o,deleteSession:s,updateSessionTitle:c,setSessionArchived:l,setSessionPinned:u,folders:d,loadFolders:f,createFolder:p,renameFolder:m,deleteFolder:h,moveSessionToFolder:g,selectedModel:_,models:v,currentSession:y,generatingTitleForSession:b,personas:x}=ae(),S=Dt(e=>e.tasks),C=Dt(e=>e.loadingTasks),w=Dt(e=>e.actionLoading),E=Dt(e=>e.deleteTask),{user:D,isAdmin:O,systemInfo:k,setUser:A,canUseWork:j,canUseAgents:M}=Y(),{backgroundImage:N,sidebarCompact:P,toggleSidebarCompact:F,isGenerating:te,pinnedAdminShortcuts:ne,toggleAdminShortcut:L}=Mt(),z=b??(te&&y&&Ht(y.title)?y.id:null),B=O(),{pendingApprovalCount:re}=In(!!(D&&B&&k?.requiresAuth)),{unseenRunCount:ie}=Ln(!!(D||k?.requiresAuth===!1)),[oe,V]=(0,Z.useState)(null),[se,ce]=(0,Z.useState)(``),[le,ue]=(0,Z.useState)(!1),[H,U]=(0,Z.useState)(!1),[de,W]=(0,Z.useState)(!1),[fe,pe]=(0,Z.useState)(``),[me,he]=(0,Z.useState)(!1),ge=(0,Z.useRef)(null),_e=(0,Z.useRef)(null),ve=i.pathname.match(/^\/c\/([^/]+)$/)?.[1]||y?.id,G=()=>{window.innerWidth<768&&!P&&F()},ye=()=>{Pt(`selection`),F()},be=()=>{let{setCurrentSession:e}=ae.getState();Nt(),e(null),sessionStorage.setItem(`forceWelcomeScreen`,`true`)};(0,Z.useEffect)(()=>{let e=e=>{ge.current&&!ge.current.contains(e.target)&&U(!1)};if(H)return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[H]),(0,Z.useEffect)(()=>{let t=t=>{_e.current&&!_e.current.contains(t.target)&&window.innerWidth<768&&e&&!P&&F()};if(e&&!P&&window.innerWidth<768)return document.addEventListener(`mousedown`,t),()=>document.removeEventListener(`mousedown`,t)},[e,P,F]);let xe=async()=>{he(!0);try{let e=await yt.updateMyAvatar(fe||null);e.success&&e.data?(A(e.data),q.success(r(`user.avatar.updated`)),W(!1)):q.error(e.message||r(`user.avatar.updateFailed`))}catch(e){Rn.error(`Failed to update avatar:`,e),q.error(r(`user.avatar.updateFailed`))}finally{he(!1)}},Se=()=>{Pt(`impact`),be(),a(`/chat`,{replace:!0}),G()},Ce=()=>{Pt(`impact`),Dt.getState().clearError(),a(`/work`),G()},we=e=>{Pt(`selection`),a(`/c/${e.id}`,{replace:!0}),G()},Te=e=>{Pt(`selection`),a(`/work/${e}`,{replace:!0}),G()},Ee=async e=>{if(window.confirm(r(`work.tasks.deleteConfirm`,{defaultValue:`Delete “{{title}}” and its workspace permanently?`,title:e.title||r(`work.tasks.untitled`,{defaultValue:`Untitled task`})}))){Pt(`warning`);try{await E(e.id),kt(e.id),dn.getState().closeTab(`work:${e.id}`),Re===e.id&&a(`/work`,{replace:!0,state:{deletedWorkTaskId:e.id}})}catch(e){Rn.error(`Failed to delete Work task:`,e),q.error(r(`work.toasts.deleteFailed`,{defaultValue:`Could not delete this Work task.`}))}}},De=async(e,t)=>{if(t.stopPropagation(),Rn.debug(`Delete session clicked:`,e),window.confirm(r(`chat.session.deleteConfirm`))){Pt(`warning`);try{Rn.debug(`Attempting to delete session:`,e);let t=ve===e;if(await s(e),Rn.debug(`Session deleted successfully`),dn.getState().closeTab(`chat:${e}`),t){let t=o.filter(t=>t.id!==e);t.length>0?a(`/c/${t[0].id}`,{replace:!0}):a(`/`,{replace:!0})}}catch(e){Rn.error(`Error deleting session:`,e)}}};(0,Z.useEffect)(()=>{f()},[f]);let Oe=async(e,t)=>{if(t.stopPropagation(),await l(e,!0),dn.getState().closeTab(`chat:${e}`),ve===e){let t=o.filter(t=>t.id!==e&&!t.archived);t.length>0?a(`/c/${t[0].id}`,{replace:!0}):a(`/`,{replace:!0})}},ke=(e,t)=>{u(e,t)},Ae=(e,t)=>{t.stopPropagation(),V(e.id),ce(e.title)},je=async e=>{se.trim()&&await c(e,se.trim()),V(null),ce(``)},Me=()=>{V(null),ce(``)},Ne=async()=>{try{await J.logout();let{logout:e}=Y.getState();e(),a(`/login`),q.success(r(`auth.logout.success`))}catch(e){Rn.error(`Logout error:`,e);let{logout:t}=Y.getState();t(),a(`/login`)}},Pe=()=>{ue(!0),G()},Fe=e=>{pe(e),W(!0)},Ie=window.location.protocol===`file:`,Le=i.pathname===`/work`||i.pathname.startsWith(`/work/`),Re=i.pathname.match(/^\/work\/([^/]+)$/)?.[1]||null,ze=i.pathname===`/`||i.pathname===`/chat`||i.pathname.startsWith(`/c/`),Be=j();return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{ref:_e,"data-testid":`sidebar`,className:R(`fixed inset-y-0 start-0 z-50 max-lg:border-e border-black/[0.04] dark:border-white/[0.06] transform transition-[width,transform,background-color] duration-200 ease-out shadow-[0_24px_80px_rgba(15,23,42,0.12)]`,P?`w-16`:`w-72 max-sm:w-[calc(100vw-4.5rem)] max-sm:max-w-80`,e?`translate-x-0`:`ltr:-translate-x-full rtl:translate-x-full`,`lg:shadow-none`,N?`bg-sidebar/75 backdrop-blur-xl`:`bg-sidebar`,`overscroll-behavior-contain`,n),style:{WebkitOverflowScrolling:`touch`},children:[Ie&&(0,Q.jsx)(`div`,{className:`absolute top-0 start-16 end-0 h-8 z-[60]`,style:{WebkitAppRegion:`drag`}}),(0,Q.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,Q.jsx)(vn,{sidebarCompact:P,isElectron:Ie,showWork:Be,activeMode:Le?`work`:ze?`chat`:null,selectedModel:_,modelCount:v.length,onToggleCompact:ye,onStartWork:Ce,onCreateSession:Se}),!P&&(0,Q.jsx)(bn,{sidebarCompact:P,activePath:i.pathname,showAgents:M(),unseenRunCount:ie,onMobileNavigate:G}),Le&&Be?(0,Q.jsx)(Fn,{tasks:S,personas:x,currentTaskId:Re,loading:C,actionLoading:w,sidebarCompact:P,onSelectTask:Te,onDeleteTask:e=>void Ee(e),onExpandSidebar:ye}):(0,Q.jsx)(Tn,{sessions:o.filter(e=>!e.archived),personas:x,currentSessionId:ve,generatingTitleForSession:z,sidebarCompact:P,editingSessionId:oe,editingTitle:se,onEditingTitleChange:ce,onSelectSession:we,onStartEditing:Ae,onSaveEdit:je,onCancelEdit:Me,onDeleteSession:De,onArchiveSession:Oe,onTogglePinSession:ke,folders:d,onCreateFolder:e=>void p(e),onRenameFolder:(e,t)=>void m(e,t),onDeleteFolder:e=>void h(e),onMoveSession:(e,t)=>void g(e,t),onExpandSidebar:ye}),(0,Q.jsx)(An,{sidebarCompact:P}),(0,Q.jsx)(On,{requiresAuth:k?.requiresAuth,user:D,isAdmin:B,pendingApprovalCount:re,sidebarCompact:P,userMenuOpen:H,userMenuRef:ge,pinnedShortcuts:ne,onToggleShortcutPin:L,onToggleUserMenu:()=>U(e=>!e),onOpenSettings:Pe,onOpenAvatar:Fe,onLogout:Ne,onMobileNavigate:G,onCloseUserMenu:()=>U(!1)})]})]}),le&&(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(zn,{isOpen:le,onClose:()=>ue(!1)})}),(0,Q.jsx)(pn,{open:de,value:fe,saving:me,onChange:pe,onClose:()=>W(!1),onSave:xe})]})},$=({children:e,requireAuth:t=!0,requireAdmin:n=!1,requireWork:r=!1,requireAgents:i=!1})=>{let{isAuthenticated:a,user:o,systemInfo:s,isLoading:c,canUseWork:l}=Y();return ee(),c?(0,Q.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gray-50 dark:bg-dark-50`,children:(0,Q.jsx)(`div`,{className:`w-8 h-8 border-4 border-gray-200 dark:border-dark-300 border-t-primary-500 dark:border-t-primary-400 rounded-full animate-spin`})}):i&&s?.agentsEnabled!==!0?(0,Q.jsx)(C,{to:`/`,replace:!0}):s&&!s.requiresAuth?(0,Q.jsx)(Q.Fragment,{children:e}):t&&!a?(0,Q.jsx)(C,{to:`/login`,replace:!0}):n&&(!o||o.role!==`admin`)||r&&!l()?(0,Q.jsx)(C,{to:`/`,replace:!0}):(0,Q.jsx)(Q.Fragment,{children:e})},Vn=F(`components:error-boundary`),Hn=({error:e})=>{let{t}=I();return(0,Q.jsx)(`div`,{className:`min-h-screen bg-gray-50 dark:bg-dark-50 flex items-center justify-center p-4 text-gray-900 dark:text-dark-800`,children:(0,Q.jsx)(`div`,{className:`w-full max-w-md rounded-2xl border border-gray-200 dark:border-dark-300 bg-white/95 dark:bg-dark-100/95 shadow-card backdrop-blur-sm`,children:(0,Q.jsxs)(`div`,{className:`p-6 text-center`,children:[(0,Q.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-2xl bg-primary-100 text-primary-700 dark:bg-primary-900/35 dark:text-primary-300 ring-1 ring-primary-200 dark:ring-primary-800/60`,children:(0,Q.jsx)(ze,{className:`h-6 w-6`})}),(0,Q.jsx)(`h1`,{className:`mb-2 text-xl font-semibold text-gray-950 dark:text-dark-950`,children:t(`errorBoundary.title`)}),(0,Q.jsx)(`p`,{className:`mb-5 text-sm leading-6 text-gray-600 dark:text-dark-600`,children:t(`errorBoundary.description`)}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:justify-center`,children:[(0,Q.jsxs)(`button`,{onClick:()=>window.location.reload(),className:`inline-flex items-center justify-center gap-2 rounded-xl bg-primary-600 px-4 py-2.5 text-sm font-medium text-white shadow-sm transition-all hover:bg-primary-700 hover:shadow-md focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 dark:focus:ring-offset-dark-100`,children:[(0,Q.jsx)(we,{className:`h-4 w-4`}),t(`errorBoundary.tryAgain`)]}),(0,Q.jsxs)(`button`,{onClick:()=>{window.location.assign(`/`)},className:`inline-flex items-center justify-center gap-2 rounded-xl border border-gray-200 bg-white px-4 py-2.5 text-sm font-medium text-gray-700 shadow-sm transition-all hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 dark:border-dark-300 dark:bg-dark-50 dark:text-dark-700 dark:hover:bg-dark-200 dark:focus:ring-offset-dark-100`,children:[(0,Q.jsx)(be,{className:`h-4 w-4`}),t(`common.home`,`Home`)]})]}),!1]})})})},Un=()=>{let e=k();(0,Z.useEffect)(()=>{Vn.error(`Route error screen caught an error:`,e)},[e]);let t=e instanceof Error?e:E(e)?Error(`${e.status} ${e.statusText}`):Error(String(e));return(0,Q.jsx)(Hn,{error:t})},Wn=class extends Z.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){Vn.error(`ErrorBoundary caught an error:`,e,t)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:(0,Q.jsx)(Hn,{error:this.state.error}):this.props.children}},Gn=`libre-webui:whats-new-seen`;function Kn(){let e={version:`0.32.0`,date:`2026-09-03`,body:`A quieter, faster release: administrators pick the theme the whole instance
3
- starts from, the theme toggle reaches Pure Black, long conversations stop
4
- stuttering while a reply streams, and the app arrives lighter and faster
5
- from a plain Docker install.
6
-
7
- ### ✨ New Features
8
-
9
- - **Instance default theme.** A new **Default theme** card on the Users page
10
- lets administrators choose Light, Dark, or Pure Black for the whole
11
- install. It paints the sign-in page before anyone signs in, seeds every new
12
- account, and applies in any browser that has not picked a theme of its own;
13
- a personal choice made in Settings always wins. The default is cached
14
- locally, so a returning visitor gets it before the first paint instead of a
15
- dark flash. Translated into all 25 languages.
16
- - **Three-way theme toggle.** The sun/moon button on the sign-in page and in
17
- the sidebar, \`Cmd/Ctrl + D\`, and the command palette now cycle Light, Dark,
18
- and Pure Black, and the icon shows where the next press goes.
19
-
20
- ### 🔧 Improvements
21
-
22
- - **Long chats stay smooth while a reply streams.** Streamed text used to
23
- re-render every message in the conversation on every animation frame, and
24
- none of the message components were memoized, so each finished message
25
- re-parsed its markdown sixty times a second. Messages, branches, and the
26
- content renderers are memoized, each message reads only the store slices
27
- it needs, streaming state reaches only the streaming turn, and off-screen
28
- turns skip layout and paint. Main-thread script time during one streamed
29
- reply in a 250-message chat drops from 3.1 s to 0.9 s.
30
- - **A lighter first paint.** Vite 8's Rolldown had folded React itself into
31
- the markdown chunk, so every page, including sign-in, preloaded a third of
32
- a megabyte of markdown machinery. Explicit chunk groups put React back in
33
- its own vendor chunk and the release-notes modal loads on demand; the
34
- initial payload drops from 367 KB to 269 KB gzipped.
35
- - **Math and raw HTML load on demand.** The KaTeX pipeline and rehype-raw's
36
- HTML parser are now lazy modules that a message loads only when it
37
- contains a \`$\` delimiter or raw HTML is allowed (notes). The shared
38
- markdown chunk shrinks from 88 KB to 47 KB gzipped.
39
- - **Compressed, cacheable assets from the built-in server.** Hashed bundles
40
- under \`/js/\` and \`/assets/\` are brotli- or gzip-compressed once per process
41
- and served with a one-year \`immutable\` cache lifetime, while \`index.html\`
42
- and the service worker are \`no-cache\` so a new release is picked up on the
43
- next load. Self-hosters without a compressing reverse proxy no longer
44
- download raw bytes on every visit, and the service worker now caches the
45
- \`/js/\` chunks it had been skipping.
46
- - **Cleaner production build.** The frontend targets ES2022, so noVNC's
47
- top-level \`await\` is emitted as-is without a build warning.
48
-
49
- ### 🐛 Bug Fixes
50
-
51
- - The tool picker in the composer stays inside the chat pane: it is capped to
52
- the space above its button, its option list scrolls, and the enable toggle
53
- and approval hint stay pinned. It previously ran off the top of the screen
54
- under the tab bar with a long tool list.
55
- - Artifact and Work preview sandboxes no longer emit a Content Security
56
- Policy source browsers reject (\`http://[::1]:*\` has no valid CSP form),
57
- which had logged an error on every render in development.
58
- - The three-replica team platform drill no longer fails when the gateway's
59
- round-robin cursor resets between issuing and consuming a WebSocket ticket.
60
-
61
- ### 🔒 Security
62
-
63
- - Dependency audit: \`qs\` 6.16.0 (array-limit bypass via bracket-key comma
64
- parsing) and \`@humanfs/node\` 0.16.8 (recursive copy following symlinks),
65
- plus the earlier \`postcss-selector-parser\` bump.
66
- - Ollama endpoint normalization uses a linear trailing-slash walk with URL
67
- length caps instead of a regular expression CodeQL flagged as polynomial.
68
-
69
- ### 📚 Documentation
70
-
71
- - Pro tips describe the instance default theme and the three-way toggle;
72
- the Docker guide notes that the server already compresses and caches the
73
- built frontend so a reverse proxy need not.`},[t,n]=(0,Z.useState)(()=>{if(!e||typeof window>`u`)return!1;try{return window.localStorage.getItem(Gn)!==e.version}catch{return!1}});return(0,Z.useEffect)(()=>{let e=()=>n(!0);return window.addEventListener(`libre:open-whats-new`,e),()=>window.removeEventListener(`libre:open-whats-new`,e)},[]),{open:t,dismiss:()=>{if(n(!1),e)try{window.localStorage.setItem(Gn,e.version)}catch{}},notes:e}}var qn=({message:e=`This is a demo version for presentation purposes only. The Ollama backend is not connected.`,onDismiss:t,className:n})=>{let[r,i]=(0,Z.useState)(!1),{t:a}=I();return r?null:(0,Q.jsx)(`div`,{className:R(`bg-gray-950 text-white dark:bg-white dark:text-gray-950`,`border-b border-black/10 dark:border-white/10`,`px-4 py-2`,n),children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between max-w-6xl mx-auto gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[(0,Q.jsx)(`div`,{className:`flex-shrink-0`,children:(0,Q.jsx)(le,{className:`h-4 w-4 text-white/65 dark:text-gray-950/60`})}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,Q.jsx)(`p`,{className:`shrink-0 text-xs font-semibold tracking-wide`,children:a(`demoMode.title`)}),(0,Q.jsx)(`p`,{className:`hidden truncate text-xs text-white/60 dark:text-gray-950/60 sm:block`,children:e})]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 ml-4`,children:[(0,Q.jsxs)(X,{variant:`ghost`,size:`sm`,className:`h-8 px-2 text-white/70 hover:bg-white/10 hover:text-white dark:text-gray-950/70 dark:hover:bg-black/[0.06] dark:hover:text-gray-950`,onClick:()=>window.open(`https://github.com/libre-webui/libre-webui`,`_blank`),title:`View on GitHub`,children:[(0,Q.jsx)(Ne,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`ml-1 hidden sm:inline`,children:a(`demoMode.github`)})]}),(0,Q.jsx)(X,{variant:`ghost`,size:`sm`,onClick:()=>{i(!0),t?.()},className:`h-8 w-8 p-0 text-white/70 hover:bg-white/10 hover:text-white dark:text-gray-950/70 dark:hover:bg-black/[0.06] dark:hover:text-gray-950`,title:`Dismiss`,children:(0,Q.jsx)(K,{className:`h-4 w-4`})})]})]})})},Jn=()=>{let{preferences:e,backgroundImage:t}=Mt(),n=e.backgroundSettings||{enabled:!1,imageUrl:``,blurAmount:10,opacity:.6},r=t||n.imageUrl;return!n.enabled||!r?null:(0,Q.jsx)(`div`,{"data-testid":`app-background`,className:`fixed inset-0 pointer-events-none z-0`,style:{backgroundImage:`url(${r})`,backgroundSize:`cover`,backgroundPosition:`center`,backgroundRepeat:`no-repeat`,filter:`blur(${n.blurAmount}px)`,opacity:n.opacity,transform:`scale(1.1)`}})},Yn={"/notes":{icon:Re,labelKey:`sidebar.navigation.notes`},"/calendar":{icon:De,labelKey:`sidebar.navigation.calendar`},"/automations":{icon:tt,labelKey:`sidebar.navigation.automations`},"/channels":{icon:ue,labelKey:`sidebar.navigation.channels`},"/personas":{icon:Pe,labelKey:`sidebar.navigation.personas`},"/gallery":{icon:se,labelKey:`sidebar.navigation.imagine`},"/agents":{icon:He,labelKey:`sidebar.navigation.agents`},"/users":{icon:Qe,labelKey:`sidebar.navigation.userManagement`},"/usage":{icon:Te,labelKey:`usageAnalytics.title`},"/system":{icon:xe,labelKey:`systemPage.title`},"/artifacts":{icon:Ie,labelKey:`tabs.artifacts`}},Xn=e=>e.kind===`home`?be:e.kind===`chat`?ct:e.kind===`work`?V:Yn[e.path]?.icon??Ie,Zn=()=>te()?`⌘`:`Ctrl`,Qn=new Set([`/agents`,`/users`,`/usage`,`/system`]),$n=(e,t)=>e.kind===`work`?!t:Qn.has(e.path),er=()=>{let{t:e}=I(),t=ee(),n=T(),r=dn(e=>e.tabs),i=dn(e=>e.activeTabId),a=dn(e=>e.syncWithPath),o=dn(e=>e.closeTab),s=dn(e=>e.closeTabs),c=ae(e=>e.sessions),l=ae(e=>e.currentSession),u=Dt(e=>e.tasks),{systemInfo:d,isAdmin:f,canUseWork:p,canUseAgents:m}=Y(),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(null),[y,b]=(0,Z.useState)(null),x=(0,Z.useRef)(null),S=(0,Z.useRef)(null),C=(0,Z.useRef)(null),w=(0,Z.useRef)(null),E=(0,Z.useRef)(null),D=f(),O=d?.requiresAuth===!1||D,k=p(),A=O?r:r.filter(e=>!$n(e,k));(0,Z.useEffect)(()=>{a(t.pathname)},[t.pathname,a]),(0,Z.useEffect)(()=>{(E.current?.querySelector(`[data-active="true"]`))?.scrollIntoView({block:`nearest`,inline:`nearest`})},[A.length,i]),(0,Z.useEffect)(()=>{if(!d||O)return;let e=r.filter(e=>$n(e,k)).map(e=>e.id);if(e.length===0)return;let t=s(e,`home`);t&&n(t.path,{replace:!0})},[s,n,O,k,d,r]),(0,Z.useEffect)(()=>{if(!h&&!y)return;let e=e=>{let t=e.target;!x.current?.contains(t)&&!S.current?.contains(t)&&!w.current?.contains(t)&&(g(!1),b(null))},t=e=>{e.key===`Escape`&&(g(!1),b(null))};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[y,h]),(0,Z.useEffect)(()=>{if(!h)return;let e=()=>{let e=C.current;if(!e)return;let t=e.getBoundingClientRect(),n=e.closest(`[data-testid="app-shell-content"]`)?.getBoundingClientRect(),r=n?.left??0,i=n?.right??window.innerWidth,a=r+8,o=i-8,s=Math.max(0,Math.min(224,o-a)),c=o-t.left>=s?t.left:t.right-s,l=Math.max(a,Math.min(c,o-s));v({left:l,top:t.bottom+4,width:s})};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[h]),(0,Z.useEffect)(()=>{y&&w.current?.querySelector(`[role="menuitem"]:not(:disabled)`)?.focus()},[y]);let j=t=>{if(t.kind===`home`)return e(`tabs.home`,`Home`);if(t.kind===`chat`){if(t.id===`chat:new`)return l?.isPrivate?e(`chat.session.incognito`,`Incognito Chat`):e(`tabs.newChat`,`New Chat`);let n=t.id.slice(5);return c.find(e=>e.id===n)?.title||e(`tabs.chat`,`Chat`)}if(t.kind===`work`){if(t.id===`work:new`)return e(`tabs.work`,`Work`);let n=t.id.slice(5);return u.find(e=>e.id===n)?.title||e(`tabs.work`,`Work`)}let n=Yn[t.path];return n?e(n.labelKey,t.path.slice(1)):t.path.slice(1)},M=(e,t)=>{e.stopPropagation(),e.preventDefault();let r=o(t.id);r&&n(r.path)},N=(e,t,n)=>{g(!1),b({tabId:e.id,x:Math.max(8,Math.min(t,window.innerWidth-224-8)),y:Math.max(8,Math.min(n,window.innerHeight-176-8))})},P=(e,t)=>{e.preventDefault(),e.stopPropagation(),N(t,e.clientX,e.clientY)},F=(e,t)=>{if(e.key!==`ContextMenu`&&!(e.shiftKey&&e.key===`F10`))return;e.preventDefault();let n=e.currentTarget.getBoundingClientRect();N(t,n.left+12,n.bottom+4)},te=e=>{let t=Array.from(w.current?.querySelectorAll(`[role="menuitem"]:not(:disabled)`)??[]);if(t.length===0)return;let n=t.indexOf(document.activeElement),r=n;if(e.key===`ArrowDown`)r=(n+1+t.length)%t.length;else if(e.key===`ArrowUp`)r=(n-1+t.length)%t.length;else if(e.key===`Home`)r=0;else if(e.key===`End`)r=t.length-1;else return;e.preventDefault(),t[r]?.focus()},ne=(e,t)=>{let r=s(e,t);b(null),r&&n(r.path)},L=[{key:`chat`,label:e(`tabs.newChat`,`New Chat`),icon:ct,shortcut:`${Zn()}⇧O`,action:()=>Ut(n)},{key:`incognito-chat`,label:e(`chat.session.incognito`,`Incognito Chat`),icon:Ke,action:()=>Gt(n)},...k?[{key:`work`,label:e(`tabs.newWork`,`New Work`),icon:V,shortcut:`${Zn()}⇧U`,action:()=>Wt(n)}]:[],...[`/channels`,`/notes`,`/calendar`,`/automations`,`/personas`,`/gallery`].map(t=>({key:t,label:e(Yn[t].labelKey,t.slice(1)),icon:Yn[t].icon,action:()=>n(t)})),...m()?[{key:`/agents`,label:e(Yn[`/agents`].labelKey,`Agents`),icon:Yn[`/agents`].icon,separatorBefore:!0,action:()=>n(`/agents`)}]:[],...D?[`/users`,`/system`,`/usage`].map(t=>({key:t,label:e(Yn[t].labelKey,t.slice(1)),icon:Yn[t].icon,action:()=>n(t)})):[]],z=y?A.find(e=>e.id===y.tabId):void 0,B=z?A.findIndex(e=>e.id===z.id):-1,re=z?A.filter(e=>e.id!==`home`&&e.id!==z.id).map(e=>e.id):[],ie=B>=0?A.slice(B+1).filter(e=>e.id!==`home`).map(e=>e.id):[],oe=A.filter(e=>e.id!==`home`).map(e=>e.id);return(0,Q.jsxs)(`div`,{"data-testid":`app-tab-bar`,className:`relative z-20 flex h-9 flex-none items-center gap-1 px-1 pb-1 lg:px-0`,children:[(0,Q.jsx)(`div`,{ref:E,role:`tablist`,"aria-label":e(`tabs.label`,`Open tabs`),className:`flex min-w-0 items-center gap-1 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,children:A.map(t=>{let r=t.id===`chat:new`&&l?.isPrivate?Ke:Xn(t),a=t.id===i;return(0,Q.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":a,"data-active":a||void 0,"data-tab-id":t.id,"data-testid":`app-tab`,title:j(t),onClick:()=>n(t.path),onContextMenu:e=>P(e,t),onKeyDown:e=>F(e,t),onAuxClick:e=>{e.button===1&&t.id!==`home`&&M(e,t)},className:R(`group flex h-7 min-w-0 flex-none items-center gap-1.5 rounded-lg border text-[13px] transition-colors duration-150 outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40`,t.id===`home`?`px-2.5`:`ps-2.5 pe-1`,a?`border-black/[0.06] bg-gray-50 text-gray-950 shadow-subtle dark:border-white/[0.07] dark:bg-dark-100 dark:text-dark-950`:`border-transparent text-gray-500 hover:bg-white/60 hover:text-gray-900 dark:text-dark-600 dark:hover:bg-dark-200/60 dark:hover:text-dark-900`),children:[(0,Q.jsx)(r,{className:`h-3.5 w-3.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`max-w-[9rem] truncate`,children:j(t)}),t.id!==`home`&&(0,Q.jsx)(`span`,{role:`button`,tabIndex:-1,"aria-label":e(`tabs.close`,`Close tab`),"data-testid":`app-tab-close`,onClick:e=>M(e,t),className:R(`flex h-5 w-5 shrink-0 items-center justify-center rounded-md text-gray-400 transition-opacity hover:bg-black/[0.06] hover:text-gray-700 dark:text-dark-500 dark:hover:bg-white/[0.08] dark:hover:text-dark-800`,a?`opacity-100`:`sm:opacity-0 sm:group-hover:opacity-100 sm:group-focus-visible:opacity-100`),children:(0,Q.jsx)(K,{className:`h-3 w-3`})})]},t.id)})}),y&&z&&(0,fn.createPortal)((0,Q.jsxs)(`div`,{ref:w,role:`menu`,"aria-label":e(`tabs.actions`,`Tab actions`),"data-testid":`app-tab-context-menu`,onContextMenu:e=>e.preventDefault(),onKeyDown:te,className:`fixed z-[100] w-56 rounded-xl border border-line bg-surface-overlay/95 p-1 shadow-overlay backdrop-blur-xl animate-fade-in motion-reduce:animate-none`,style:{left:y.x,top:y.y},children:[(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`app-tab-context-close`,disabled:z.id===`home`,onClick:()=>{let e=o(z.id);b(null),e&&n(e.path)},className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-[13px] text-ink-muted transition-colors hover:bg-black/[0.05] hover:text-ink disabled:cursor-not-allowed disabled:opacity-40 dark:hover:bg-white/[0.06]`,children:[(0,Q.jsx)(K,{className:`h-4 w-4 shrink-0`}),(0,Q.jsx)(`span`,{children:e(`tabs.close`,`Close tab`)})]}),(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`app-tab-context-close-others`,disabled:re.length===0,onClick:()=>ne(re,z.id),className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-[13px] text-ink-muted transition-colors hover:bg-black/[0.05] hover:text-ink disabled:cursor-not-allowed disabled:opacity-40 dark:hover:bg-white/[0.06]`,children:[(0,Q.jsx)(H,{className:`h-4 w-4 shrink-0`}),(0,Q.jsx)(`span`,{children:e(`tabs.closeOthers`,`Close other tabs`)})]}),(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`app-tab-context-close-right`,disabled:ie.length===0,onClick:()=>ne(ie,z.id),className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-[13px] text-ink-muted transition-colors hover:bg-black/[0.05] hover:text-ink disabled:cursor-not-allowed disabled:opacity-40 dark:hover:bg-white/[0.06]`,children:[(0,Q.jsx)(Fe,{className:`h-4 w-4 shrink-0`}),(0,Q.jsx)(`span`,{children:e(`tabs.closeRight`,`Close tabs to the right`)})]}),(0,Q.jsx)(`div`,{className:`mx-2 my-1 h-px bg-line`,role:`separator`}),(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`app-tab-context-close-all`,disabled:oe.length===0,onClick:()=>ne(oe,`home`),className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-[13px] text-ink-muted transition-colors hover:bg-black/[0.05] hover:text-ink disabled:cursor-not-allowed disabled:opacity-40 dark:hover:bg-white/[0.06]`,children:[(0,Q.jsx)(ge,{className:`h-4 w-4 shrink-0`}),(0,Q.jsx)(`span`,{children:e(`tabs.closeAll`,`Close all tabs`)})]})]}),document.body),(0,Q.jsxs)(`div`,{className:`relative flex-none`,ref:x,children:[(0,Q.jsx)(`button`,{ref:C,type:`button`,"aria-label":e(`tabs.new`,`New tab`),"aria-expanded":h,"data-testid":`app-tab-new`,onClick:()=>g(e=>!e),className:`flex h-7 w-7 items-center justify-center rounded-lg text-gray-500 transition-colors hover:bg-white/60 hover:text-gray-900 dark:text-dark-600 dark:hover:bg-dark-200/60 dark:hover:text-dark-900 outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40`,children:(0,Q.jsx)(_e,{className:`h-4 w-4`})}),h&&_&&(0,fn.createPortal)((0,Q.jsx)(`div`,{ref:S,role:`menu`,"data-testid":`app-tab-new-menu`,className:`fixed z-[100] max-h-[calc(100dvh-4rem)] overflow-y-auto rounded-xl border border-line bg-surface-overlay/95 p-1 shadow-overlay backdrop-blur-xl animate-fade-in motion-reduce:animate-none`,style:_,children:L.map(e=>(0,Q.jsxs)(Z.Fragment,{children:[e.separatorBefore&&(0,Q.jsx)(`div`,{className:`mx-2 my-1 h-px bg-line`,role:`separator`}),(0,Q.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{g(!1),e.action()},className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-[13px] text-ink-muted transition-colors hover:bg-black/[0.05] hover:text-ink dark:hover:bg-white/[0.06]`,children:[(0,Q.jsx)(e.icon,{className:`h-4 w-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-start`,children:e.label}),e.shortcut&&(0,Q.jsx)(`span`,{className:`font-mono text-[10px] tracking-wide text-ink-subtle`,children:e.shortcut})]})]},e.key))}),document.body)]})]})},tr=24;function nr(e,t){let n=e.toLowerCase(),r=t.toLowerCase();if(!n)return{score:0,ranges:[]};let i=r.indexOf(n);if(i!==-1)return{score:100+(i===0||/[\s\-_/.]/.test(r[i-1])?40:0)-Math.min(i,20)-Math.min(r.length-n.length,10)/10,ranges:[[i,i+n.length]]};let a=[],o=0,s=0;for(let e=0;e<n.length;e++){let t=r.indexOf(n[e],s);if(t===-1)return null;let i=a.length>0&&t===s,c=t===0||/[\s\-_/.]/.test(r[t-1]);o+=2+(i?4:0)+(c?6:0),i||(o-=Math.min(t-s,6)/2);let l=a[a.length-1];l&&l[1]===t?l[1]=t+1:a.push([t,t+1]),s=t+1}return{score:o,ranges:a}}function rr({text:e,ranges:t}){if(t.length===0)return(0,Q.jsx)(Q.Fragment,{children:e});let n=[],r=0;return t.forEach(([t,i],a)=>{t>r&&n.push(e.slice(r,t)),n.push((0,Q.jsx)(`span`,{className:`font-semibold text-ink`,children:e.slice(t,i)},a)),r=i}),r<e.length&&n.push(e.slice(r)),(0,Q.jsx)(Q.Fragment,{children:n})}var ir=({onOpenSettings:e,onOpenSettingsTab:t})=>{let{t:n,i18n:r}=I(),i=T(),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(0),d=(0,Z.useRef)(null),f=(0,Z.useRef)(null),p=ae(e=>e.sessions),m=Dt(e=>e.tasks),h=Mt(e=>e.toggleTheme),{canUseWork:g,canUseAgents:_}=Y(),v=g(),y=_(),b=te()?`⌘`:`Ctrl`;(0,Z.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`&&(e.preventDefault(),c(``),u(0),o(e=>!e))},t=()=>{c(``),u(0),o(!0)};return document.addEventListener(`keydown`,e,!0),window.addEventListener(`libre:open-palette`,t),()=>{document.removeEventListener(`keydown`,e,!0),window.removeEventListener(`libre:open-palette`,t)}},[]),(0,Z.useEffect)(()=>{if(!a)return;let e=window.requestAnimationFrame(()=>d.current?.focus());return()=>window.cancelAnimationFrame(e)},[a]);let x=(0,Z.useCallback)(()=>o(!1),[]),[S,C]=(0,Z.useState)(null);S!==null&&(!a||s.trim().length<3)&&C(null),(0,Z.useEffect)(()=>{let e=s.trim();if(!a||e.length<3)return;let t=!1,n=window.setTimeout(()=>{Tt.searchApp(e).then(e=>{!t&&e.success&&e.data&&C(e.data)}).catch(()=>{})},300);return()=>{t=!0,window.clearTimeout(n)}},[s,a]);let w=(0,Z.useMemo)(()=>{let a=n(`palette.actions`,`Actions`),o=[{id:`action:new-chat`,section:a,label:n(`tabs.newChat`,`New Chat`),icon:ct,hint:`${b}⇧O`,keywords:`new chat conversation start`,run:()=>Ut(i)},{id:`action:incognito-chat`,section:a,label:n(`chat.session.incognito`,`Incognito Chat`),icon:Ke,keywords:`incognito private temporary ghost`,run:()=>Gt(i)},...v?[{id:`action:new-work`,section:a,label:n(`tabs.newWork`,`New Work`),icon:V,hint:`${b}⇧U`,keywords:`new work task workspace`,run:()=>Wt(i)}]:[],{id:`action:home`,section:a,label:n(`tabs.home`,`Home`),icon:be,run:()=>i(`/`)},{id:`action:models`,section:a,label:n(`sidebar.navigation.models`,`Models`),icon:st,keywords:`models ollama providers llm`,run:()=>t(`model-manager`)},{id:`action:personas`,section:a,label:n(`sidebar.navigation.personas`,`Personas`),icon:Pe,run:()=>i(`/personas`)},{id:`action:gallery`,section:a,label:n(`sidebar.navigation.imagine`,`Imagine`),icon:se,keywords:`imagine images generation gallery pictures`,run:()=>i(`/gallery`)},{id:`action:calendar`,section:a,label:n(`sidebar.navigation.calendar`,`Calendar`),icon:De,keywords:`calendar events schedule agenda`,run:()=>i(`/calendar`)},{id:`action:channels`,section:a,label:n(`sidebar.navigation.channels`,`Channels`),icon:ue,keywords:`channels team messages dm direct chat rooms`,run:()=>i(`/channels`)},{id:`action:automations`,section:a,label:n(`sidebar.navigation.automations`,`Automations`),icon:tt,keywords:`automations schedule cron recurring routines`,run:()=>i(`/automations`)},{id:`action:prompts`,section:a,label:n(`sidebar.navigation.prompts`,`Prompts`),icon:je,keywords:`prompts templates slash snippets library`,run:()=>t(`prompts`)},{id:`action:skills`,section:a,label:n(`sidebar.navigation.skills`,`Skills`),icon:Ee,keywords:`skills instructions playbooks load_skill`,run:()=>t(`skills`)},{id:`action:tools`,section:a,label:n(`sidebar.navigation.tools`,`Tools`),icon:Xe,keywords:`tools servers mcp openapi integrations approvals`,run:()=>t(`tools`)},...y?[{id:`action:agents`,section:a,label:n(`sidebar.navigation.agents`,`Agents`),icon:He,run:()=>i(`/agents`)}]:[],{id:`action:settings`,section:a,label:n(`palette.settings`,`Settings`),icon:dt,hint:`${b},`,keywords:`settings preferences configuration options`,run:e},{id:`action:theme`,section:a,label:n(`palette.toggleTheme`,`Toggle theme`),icon:Ve,hint:`${b}D`,keywords:`theme dark light mode appearance`,run:h}],s=[...p].sort((e,t)=>t.updatedAt-e.updatedAt).map(e=>({id:`session:${e.id}`,section:n(`palette.chats`,`Chats`),label:e.title||n(`tabs.chat`,`Chat`),icon:ct,hint:ne(e.updatedAt,r.language),keywords:e.model,run:()=>i(`/c/${e.id}`)})),c=v?[...m].sort((e,t)=>new Date(t.updatedAt).getTime()-new Date(e.updatedAt).getTime()).map(e=>({id:`work:${e.id}`,section:n(`palette.work`,`Work`),label:e.title||n(`work.tasks.untitled`,`Untitled task`),icon:V,hint:e.status,run:()=>i(`/work/${e.id}`)})):[];return[...o,...s,...c]},[n,b,i,e,t,h,p,m,v,y,r.language]),E=(0,Z.useMemo)(()=>{let e=s.trim();if(!e){let e=w.filter(e=>e.id.startsWith(`action:`)),t=w.filter(e=>e.id.startsWith(`session:`)).slice(0,6),n=w.filter(e=>e.id.startsWith(`work:`)).slice(0,4);return[...e,...t,...n].map(e=>({item:e,ranges:[]}))}let r=w.flatMap(t=>{let n=nr(e,t.label);if(n)return[{item:t,...n}];let r=t.keywords?nr(e,t.keywords):null;return r?[{item:t,score:r.score-30,ranges:[]}]:[]}),a=new Map;r.forEach(({item:e,score:t})=>{let n=a.get(e.section);(n===void 0||t>n)&&a.set(e.section,t)});let o=r.sort((e,t)=>(a.get(t.item.section)??0)-(a.get(e.item.section)??0)||e.item.section.localeCompare(t.item.section)||t.score-e.score).slice(0,tr).map(({item:e,ranges:t})=>({item:e,ranges:t}));if(!S)return o;let c=new Set(o.filter(e=>e.item.id.startsWith(`session:`)).map(e=>e.item.id.slice(8))),l=[...S.sessions.filter(e=>!c.has(e.sessionId)).map(e=>({id:`deep-session:${e.sessionId}:${e.messageId}`,section:n(`palette.messages`,`Messages`),label:e.title||n(`tabs.chat`,`Chat`),icon:ct,hint:e.snippet,run:()=>i(`/c/${e.sessionId}`)})),...S.notes.map(e=>({id:`deep-note:${e.noteId}`,section:n(`palette.notes`,`Notes`),label:e.title||n(`notes.untitled`,`Untitled`),icon:Re,hint:e.snippet,run:()=>i(`/notes?note=${encodeURIComponent(e.noteId)}`)})),...S.documents.map(e=>({id:`deep-document:${e.documentId}`,section:n(`palette.documents`,`Documents`),label:e.filename,icon:Le,hint:e.snippet,run:()=>t(`documents`)}))];return[...o,...l.map(e=>({item:e,ranges:[]}))]},[w,s,S,n,i,t]);(0,Z.useEffect)(()=>{(f.current?.querySelector(`[data-selected="true"]`))?.scrollIntoView({block:`nearest`})},[l,E.length]);let D=e=>{e&&(x(),e.run())};return a?(0,fn.createPortal)((0,Q.jsx)(`div`,{"data-testid":`command-palette`,className:`fixed inset-0 z-[120] flex items-center justify-center bg-black/25 px-4 backdrop-blur-[2px] dark:bg-black/45`,onMouseDown:e=>{e.target===e.currentTarget&&x()},children:(0,Q.jsxs)(`div`,{className:`flex h-[min(34rem,76vh)] w-full max-w-2xl flex-col overflow-hidden rounded-2xl border border-line bg-surface-overlay/95 shadow-overlay backdrop-blur-xl animate-scale-in motion-reduce:animate-none`,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2.5 border-b border-line px-4`,children:[(0,Q.jsx)(ye,{className:`h-4 w-4 shrink-0 text-ink-subtle`}),(0,Q.jsx)(`input`,{ref:d,"data-testid":`command-palette-input`,value:s,onChange:e=>{c(e.target.value),u(0)},onKeyDown:e=>{e.key===`Escape`?(e.preventDefault(),x()):e.key===`ArrowDown`?(e.preventDefault(),u(e=>Math.min(E.length-1,e+1))):e.key===`ArrowUp`?(e.preventDefault(),u(e=>Math.max(0,e-1))):e.key===`Enter`&&(e.preventDefault(),D(E[l]?.item))},placeholder:n(`palette.placeholder`,`Search chats, Work, actions…`),className:`h-[3.25rem] w-full bg-transparent text-[15px] text-ink outline-none placeholder:text-ink-subtle`}),(0,Q.jsx)(`kbd`,{className:`shrink-0 rounded-md border border-line px-1.5 py-0.5 font-mono text-[10px] text-ink-subtle`,children:`esc`})]}),(0,Q.jsxs)(`div`,{ref:f,className:`min-h-0 flex-1 overflow-y-auto p-2 scrollbar-thin`,children:[E.length===0&&(0,Q.jsx)(`p`,{className:`px-3 py-6 text-center text-sm text-ink-subtle`,children:n(`palette.empty`,`No matches.`)}),E.map(({item:e,ranges:t},n)=>{let r=n===0||e.section!==E[n-1].item.section;return(0,Q.jsxs)(Z.Fragment,{children:[r&&(0,Q.jsx)(`p`,{className:`px-2.5 pb-1 pt-2.5 text-[10px] font-medium uppercase tracking-[0.08em] text-ink-subtle first:pt-1`,children:e.section}),(0,Q.jsxs)(`button`,{type:`button`,"data-selected":n===l||void 0,onMouseEnter:()=>u(n),onClick:()=>D(e),className:R(`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-start text-sm transition-colors`,n===l?`bg-black/[0.05] text-ink dark:bg-white/[0.07]`:`text-ink-muted`),children:[(0,Q.jsx)(e.icon,{className:`h-4 w-4 shrink-0 text-ink-subtle`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:(0,Q.jsx)(rr,{text:e.label,ranges:t})}),e.hint&&(0,Q.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-ink-subtle`,children:e.hint})]})]},e.id)})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 border-t border-line px-4 py-2 text-[10px] text-ink-subtle`,children:[(0,Q.jsx)(`span`,{className:`inline-flex items-center gap-1`,children:(0,Q.jsx)(`kbd`,{className:`rounded-md border border-line px-1.5 py-0.5 font-mono`,children:`↑↓`})}),(0,Q.jsx)(`span`,{className:`inline-flex items-center gap-1`,children:(0,Q.jsx)(`kbd`,{className:`rounded-md border border-line px-1.5 py-0.5 font-mono`,children:`↵`})}),(0,Q.jsx)(`span`,{className:`ms-auto inline-flex items-center gap-1`,children:(0,Q.jsx)(`kbd`,{className:`rounded-md border border-line px-1.5 py-0.5 font-mono`,children:`esc`})})]})]})}),document.body):null},ar=F(`user-service`),or=class{static async initializeAuth(){let{setLoading:e,setSystemInfo:t,login:n}=Y.getState();try{e(!0),ar.debug(`Starting auth initialization...`),ar.debug(`Fetching system info...`);let r=await J.getSystemInfo();ar.debug(`System info response:`,r),r.success&&r.data?(ar.debug(`Setting system info:`,r.data),t(r.data),Mt.getState().applyInstanceTheme(r.data.defaultTheme)):ar.error(`System info response failed:`,r);let i=localStorage.getItem(`auth-token`);if(i)try{let e=(await P(async()=>{let{default:e}=await import(`../js/axios-CYkJpKn8.js`);return{default:e}},__vite__mapDeps([29,7,1,2]))).default,t=e.defaults.headers.common;e.defaults.headers.common.Authorization=`Bearer ${i}`;let r=await J.verifyToken();if(r.success&&r.data){let e=Y.getState().systemInfo;e&&n(r.data,i,e)}e.defaults.headers.common=t}catch(e){ar.error(`Token verification failed:`,e),localStorage.removeItem(`auth-token`)}}catch(e){ar.error(`Auth initialization error:`,e)}finally{e(!1)}}};mt.interceptors.request.use(e=>{let t=localStorage.getItem(`auth-token`);return t&&(e.headers.Authorization=`Bearer ${t}`),e},e=>Promise.reject(e)),mt.interceptors.response.use(e=>e,e=>{if(e.response?.status===401){localStorage.removeItem(`auth-token`);let{logout:e}=Y.getState();e();let t=window.location.protocol===`file:`;window.location.href=t?`#/login`:`/login`}return Promise.reject(e)});var sr=F(`initialize`),cr=()=>{let{t:e}=I(),t=(0,Z.useRef)(!1),n=(0,Z.useRef)(!1),{loadSessions:r,loadModels:i,loadPreferences:a,setSelectedModel:o,models:s,ollamaConnected:c}=ae(),{loadPreferences:l}=Mt(),{loadPlugins:u,plugins:d}=At(),f=Y(e=>e.isAuthenticated);(0,Z.useEffect)(()=>{t.current||n.current||(async()=>{n.current=!0;try{sr.debug(`Initializing Libre WebUI...`),await or.initializeAuth();let n=Y.getState();if(n.requiresAuth()&&!n.isAuthenticated){sr.debug(`Authentication required; deferring protected app initialization`);return}try{!(await Et.checkHealth()).success&&!N()&&ut.error(e(`appInitialization.ollamaUnavailable`))}catch(t){sr.warn(`Ollama health check failed; continuing provider initialization:`,t),N()||ut.error(e(`appInitialization.ollamaUnavailable`))}await Promise.all([l(),a()]),await Promise.all([i(),r(),u()]),t.current=!0,sr.debug(`Libre WebUI initialized successfully`)}catch(n){N()?(await Promise.all([l(),a()]),await Promise.all([i(),r(),u()]),t.current=!0):(sr.error(`Failed to initialize app:`,n),ut.error(e(`appInitialization.backendConnectionFailed`)))}finally{n.current=!1}})()},[f,l,a,i,r,u,e]),(0,Z.useEffect)(()=>{if(s.length>0){let e=s.filter(e=>!e.name.includes(`embed`))[0]||s[0],{selectedModel:t,selectedProviderType:n,selectedProviderId:r}=ae.getState();if(t){if(!ie(s,{model:t,providerType:n,providerId:r})&&n!==`ollama`&&n!==`plugin`){let t=re(e);sr.debug(`Legacy selected model not available, falling back to:`,t.model),o(t.model,t.providerType,t.providerId)}}else{let t=re(e);sr.debug(`No model selected, using first available:`,t.model),o(t.model,t.providerType,t.providerId)}}},[s,o]),(0,Z.useEffect)(()=>{t.current&&(sr.debug(`Plugin availability changed, reloading models...`),i())},[d,i]),(0,Z.useEffect)(()=>{let e=0,t=()=>{if(document.visibilityState!==`visible`)return;let t=Y.getState();if(t.requiresAuth()&&!t.isAuthenticated)return;let n=Date.now();n-e<1e4||(e=n,t.refreshWorkAccess())};return window.addEventListener(`focus`,t),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`focus`,t),document.removeEventListener(`visibilitychange`,t)}},[]),(0,Z.useEffect)(()=>{let e=()=>{sr.debug(`Installed models changed, reloading models...`),i()};return window.addEventListener(wt,e),()=>window.removeEventListener(wt,e)},[i]),(0,Z.useEffect)(()=>{if(c)return;let e=Y.getState();if(e.requiresAuth()&&!e.isAuthenticated)return;let t=()=>{document.visibilityState===`visible`&&(sr.debug(`Provider offline at startup, re-checking availability...`),i({quiet:!0}))},n=s.some(e=>!e.isPersona)?void 0:window.setInterval(t,1e4);return window.addEventListener(`focus`,t),()=>{n!==void 0&&window.clearInterval(n),window.removeEventListener(`focus`,t)}},[c,s,i])},lr=(e,t=!0)=>{let n=(0,Z.useCallback)(n=>{if(!t)return;let r=n.target;if(r.tagName===`INPUT`||r.tagName===`TEXTAREA`||r.contentEditable===`true`||r.isContentEditable)return;if(n.key===`?`||n.key===`/`&&n.shiftKey){let t=e.find(e=>e.key===`?`);if(t){n.preventDefault(),n.stopPropagation(),t.action();return}}let i=e.find(e=>{let t=e.key.toLowerCase()===n.key.toLowerCase(),r=!!e.metaKey,i=n.metaKey||n.ctrlKey,a=!r||i,o=!e.ctrlKey||n.ctrlKey,s=!!e.shiftKey===n.shiftKey,c=!!e.altKey===n.altKey;return t&&a&&o&&s&&c});i&&(n.preventDefault(),n.stopPropagation(),i.action())},[e,t]);(0,Z.useEffect)(()=>{if(t)return document.addEventListener(`keydown`,n),()=>{document.removeEventListener(`keydown`,n)}},[n,t])},ur=F(`components:git-hub-auth-button`),dr=()=>{let{t:e}=I(),[t,n]=(0,Z.useState)(!1),[r,i]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{(async()=>{try{let e=await fetch(`${gt}/auth/oauth/github/status`,{method:`GET`,credentials:`include`});if(e.ok){let t=await e.json();i(t.configured||!1),ur.debug(`GitHub OAuth configured:`,t.configured)}else ur.debug(`GitHub OAuth status check failed`),i(!1)}catch(e){ur.debug(`GitHub OAuth not configured:`,e),i(!1)}})()},[]),r?(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{if(!r||t)return;n(!0);let e=`${gt}/auth/oauth/github`;window.location.href=e},disabled:t,className:`flex h-11 w-full items-center justify-center rounded-xl border border-line bg-surface-raised px-4 text-sm font-medium text-ink shadow-subtle transition-colors hover:border-line-strong hover:bg-surface-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 focus-visible:ring-offset-canvas disabled:cursor-not-allowed disabled:opacity-40 motion-reduce:transition-none`,children:t?(0,Q.jsxs)(`div`,{className:`flex items-center`,children:[(0,Q.jsx)(pe,{size:16,className:`me-2 animate-spin`}),e(`auth.oauth.connectingTo`,{provider:e(`auth.oauth.github`)})]}):(0,Q.jsxs)(`div`,{className:`flex items-center`,children:[(0,Q.jsx)(nt,{size:16,className:`me-2`}),e(`auth.oauth.continueWith`,{provider:e(`auth.oauth.github`)})]})}):null},fr=F(`components:hugging-face-auth-button`),pr=()=>{let{t:e}=I(),[t,n]=(0,Z.useState)(!1),[r,i]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{(async()=>{try{let e=await fetch(`${gt}/auth/oauth/huggingface/status`,{method:`GET`,credentials:`include`});if(e.ok){let t=await e.json();i(t.configured||!1),fr.debug(`Hugging Face OAuth configured:`,t.configured)}else fr.debug(`Hugging Face OAuth status check failed`),i(!1)}catch(e){fr.debug(`Hugging Face OAuth not configured:`,e),i(!1)}})()},[]),r?(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{if(!r||t)return;n(!0);let e=`${gt}/auth/oauth/huggingface`;window.location.href=e},disabled:t,className:`flex h-11 w-full items-center justify-center rounded-xl border border-line bg-surface-raised px-4 text-sm font-medium text-ink shadow-subtle transition-colors hover:border-line-strong hover:bg-surface-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 focus-visible:ring-offset-canvas disabled:cursor-not-allowed disabled:opacity-40 motion-reduce:transition-none`,children:t?(0,Q.jsxs)(`div`,{className:`flex items-center`,children:[(0,Q.jsx)(pe,{size:16,className:`me-2 animate-spin`}),e(`auth.oauth.connectingTo`,{provider:e(`auth.oauth.huggingFace`)})]}):(0,Q.jsxs)(`div`,{className:`flex items-center`,children:[(0,Q.jsx)(`span`,{className:`me-2 text-base`,children:`🤗`}),e(`auth.oauth.continueWith`,{provider:e(`auth.oauth.huggingFace`)})]})}):null},mr=({displayName:e})=>{let{t}=I(),[n,r]=(0,Z.useState)(!1),i=e||t(`auth.oidc.defaultProviderName`,`Single sign-on`);return(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{n||(r(!0),window.location.href=`${gt}/auth/oauth/oidc`)},disabled:n,className:`flex h-11 w-full items-center justify-center rounded-xl border border-line bg-surface-raised px-4 text-sm font-medium text-ink shadow-subtle transition-colors hover:border-line-strong hover:bg-surface-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 focus-visible:ring-offset-canvas disabled:cursor-not-allowed disabled:opacity-40 motion-reduce:transition-none`,children:n?(0,Q.jsxs)(`div`,{className:`flex items-center`,children:[(0,Q.jsx)(pe,{size:16,className:`me-2 animate-spin`}),t(`auth.oauth.connectingTo`,{provider:i})]}):(0,Q.jsxs)(`div`,{className:`flex items-center`,children:[(0,Q.jsx)(ft,{size:16,className:`me-2`}),t(`auth.oauth.continueWith`,{provider:i})]})})},hr=F(`hooks:oauth-providers`),gr=async e=>{try{let t=await fetch(`${gt}/auth/oauth/${e}/status`,{method:`GET`,credentials:`include`});if(!t.ok)return{configured:!1};let n=await t.json();return{configured:!!n.configured,displayName:typeof n.displayName==`string`?n.displayName:void 0}}catch(t){return hr.debug(`${e} OAuth not configured:`,t),{configured:!1}}},_r=()=>{let[e,t]=(0,Z.useState)({github:!1,huggingface:!1,oidc:!1}),[n,r]=(0,Z.useState)(void 0);return(0,Z.useEffect)(()=>{let e=!0;return Promise.all([gr(`github`),gr(`huggingface`),gr(`oidc`)]).then(([n,i,a])=>{e&&(t({github:n.configured,huggingface:i.configured,oidc:a.configured}),r(a.displayName))}),()=>{e=!1}},[]),{...e,oidcDisplayName:n,hasAny:e.github||e.huggingface||e.oidc}},vr=F(`components:login-form`),yr={username:`demo`,password:`demo`},br=({onLogin:e,onShowSignup:t,initialApprovalPending:n=!1,bare:r=!1})=>{let{t:i}=I(),a=N(),o=_r(),[s,c]=(0,Z.useState)(a?yr.username:``),[l,u]=(0,Z.useState)(a?yr.password:``),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(n),[_,v]=(0,Z.useState)(``),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(``),[C,w]=(0,Z.useState)(null),[E,D]=(0,Z.useState)(null),[O,k]=(0,Z.useState)(null),A=T(),{login:j,systemInfo:M}=Y(),ee=M?.turnstile?.siteKey,P=!!(M?.turnstile?.enabled&&ee&&!a),F=(0,Z.useCallback)(e=>{v(e)},[]),te=(0,Z.useMemo)(()=>p||P&&!_,[p,P,_]),ne=async t=>{t.preventDefault();let n=a?yr.username:s.trim(),r=a?yr.password:l;if(!n||!r){q.error(i(`auth.login.enterBoth`));return}if(P&&!_){q.error(i(`auth.login.verificationFailed`,`Security verification failed. Please refresh and try again.`));return}m(!0),g(!1);try{localStorage.removeItem(`auth-token`);let t=await J.login({username:n,password:r,turnstileToken:_});if(t.success&&t.data){if(vt(t.data)){if(b(t.data),S(``),t.data.requirement===`enroll`){let e=await J.mfaEnrollChallenge({challengeToken:t.data.challengeToken});e.success&&e.data?w(e.data):(q.error(e.message||i(`auth.mfa.enrollFailed`)),b(null))}return}j(t.data.user,t.data.token,t.data.systemInfo),q.success(i(`auth.login.loginSuccess`)),e?.(),A(`/`)}else q.error(t.message||i(`auth.login.loginFailed`))}catch(e){vr.error(`Login error:`,e);let t=e;t.response?.data?.code===`ACCOUNT_PENDING`?(g(!0),q.error(t.response.data.message||i(`auth.login.approvalPending`,`Your account is waiting for administrator approval.`))):q.error(i(`auth.login.checkCredentials`))}finally{v(``),m(!1)}},L=t=>{j(t.user,t.token,t.systemInfo),q.success(i(`auth.login.loginSuccess`)),e?.(),A(`/`)},z=async e=>{if(e.preventDefault(),!(!y||!x.trim())){m(!0);try{if(y.requirement===`enroll`){let e=await J.mfaActivateChallenge({challengeToken:y.challengeToken,code:x.trim()});if(e.success&&e.data){let{recoveryCodes:t,...n}=e.data;k(n),D(t)}else q.error(e.message||i(`auth.mfa.invalidCode`));return}let e=await J.mfaVerify({challengeToken:y.challengeToken,code:x.trim()});e.success&&e.data?L(e.data):q.error(e.message||i(`auth.mfa.invalidCode`))}catch(e){let t=e.response?.data?.message;t&&/challenge/i.test(t)?(q.error(i(`auth.mfa.challengeExpired`)),b(null),w(null)):q.error(t||i(`auth.mfa.invalidCode`))}finally{S(``),m(!1)}}},B=async()=>{m(!0);try{let e=await J.passkeyLoginOptions();if(!e.success||!e.data){q.error(e.message||i(`auth.passkeys.signInFailed`));return}let t=await qt(e.data.publicKey),n=await J.passkeyLogin({challengeToken:e.data.challengeToken,credential:t});n.success&&n.data?(localStorage.removeItem(`auth-token`),L(n.data)):q.error(n.message||i(`auth.passkeys.signInFailed`))}catch(e){let t=e;if(t.name===`NotAllowedError`||t.name===`AbortError`)return;let n=e;vr.error(`Passkey login error:`,e),q.error(n.response?.data?.message||i(`auth.passkeys.signInFailed`))}finally{m(!1)}},re=e=>{if(e.key===`Enter`){let t=e.currentTarget.form;t&&t.requestSubmit()}},ie=R(`mx-auto w-full max-w-md`,!r&&`rounded-3xl border border-line bg-surface-raised p-6 shadow-card sm:p-8`);if(E&&O)return(0,Q.jsxs)(`div`,{className:ie,"data-testid":`login-recovery-codes`,children:[(0,Q.jsxs)(`div`,{className:R(`mb-6`,r?`text-start`:`text-center`),children:[(0,Q.jsx)(`h1`,{className:`mb-2 text-2xl font-light tracking-[-0.04em] text-ink`,children:i(`auth.mfa.recoveryCodesTitle`)}),(0,Q.jsx)(`p`,{className:`text-sm leading-6 text-ink-muted`,children:i(`auth.mfa.recoveryCodesHint`)})]}),(0,Q.jsx)(`div`,{className:`mb-6 grid grid-cols-2 gap-2 rounded-xl border border-line bg-surface p-4 font-mono text-sm text-ink`,children:E.map(e=>(0,Q.jsx)(`span`,{dir:`ltr`,children:e},e))}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>L(O),className:`flex h-11 w-full items-center justify-center rounded-xl border border-transparent bg-ink px-4 text-sm font-medium text-ink-inverse shadow-subtle transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 disabled:cursor-not-allowed disabled:opacity-40 motion-reduce:transition-none`,children:i(`auth.mfa.recoveryCodesSaved`)})]});if(y){let e=y.requirement===`enroll`;return(0,Q.jsxs)(`div`,{className:ie,"data-testid":`login-mfa-step`,children:[(0,Q.jsxs)(`div`,{className:R(`mb-6`,r?`text-start`:`text-center`),children:[(0,Q.jsx)(`div`,{className:R(`mb-3 flex`,r?`justify-start`:`justify-center`),children:(0,Q.jsx)(fe,{"aria-hidden":`true`,className:`h-8 w-8 text-ink`})}),(0,Q.jsx)(`h1`,{className:`mb-2 text-2xl font-light tracking-[-0.04em] text-ink`,children:i(e?`auth.mfa.setupTitle`:`auth.mfa.verifyTitle`)}),(0,Q.jsx)(`p`,{className:`text-sm leading-6 text-ink-muted`,children:i(e?`auth.mfa.setupSubtitle`:`auth.mfa.verifyHint`)})]}),e&&C&&(0,Q.jsxs)(`div`,{className:`mb-5 space-y-3 rounded-xl border border-line bg-surface p-4 text-start`,children:[(0,Q.jsx)(`p`,{className:`text-xs leading-5 text-ink-muted`,children:i(`auth.mfa.secretHint`)}),(0,Q.jsx)(`code`,{dir:`ltr`,"data-testid":`mfa-enroll-secret`,className:`block break-all font-mono text-sm text-ink`,children:C.secret}),(0,Q.jsx)(`a`,{href:C.otpauthUrl,dir:`ltr`,className:`inline-block text-xs font-medium text-primary-600 hover:text-primary-700 dark:text-primary-400`,children:i(`auth.mfa.openAuthenticator`)})]}),(0,Q.jsxs)(`form`,{onSubmit:z,className:`space-y-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`mfa-code`,className:`mb-2 block text-sm font-medium text-ink`,children:i(e?`auth.mfa.codeLabel`:`auth.mfa.codeOrRecoveryLabel`)}),(0,Q.jsx)(`input`,{id:`mfa-code`,"data-testid":`mfa-code-input`,type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,autoFocus:!0,dir:`ltr`,value:x,onChange:e=>S(e.target.value),className:`h-11 w-full rounded-xl border border-line bg-surface px-3 text-sm text-ink shadow-subtle outline-none transition-[border-color,box-shadow,background-color] placeholder:text-ink-muted focus:border-line-strong focus:ring-2 focus:ring-primary-500/35 disabled:cursor-not-allowed disabled:bg-surface-subtle disabled:text-ink-muted motion-reduce:transition-none`,placeholder:i(`auth.mfa.codePlaceholder`),required:!0,disabled:p})]}),(0,Q.jsx)(`button`,{type:`submit`,disabled:p||!x.trim(),className:`flex h-11 w-full items-center justify-center rounded-xl border border-transparent bg-ink px-4 text-sm font-medium text-ink-inverse shadow-subtle transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 disabled:cursor-not-allowed disabled:opacity-40 motion-reduce:transition-none`,children:p?(0,Q.jsxs)(`div`,{className:`flex items-center`,children:[(0,Q.jsx)(`div`,{className:`me-2 h-4 w-4 animate-spin rounded-full border-b-2 border-current`}),i(`auth.login.signingIn`)]}):i(`auth.mfa.verifyButton`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{b(null),w(null),S(``)},className:`w-full text-center text-sm font-medium text-ink-muted transition-colors hover:text-ink`,children:i(`auth.mfa.backToSignIn`)})]})]})}return(0,Q.jsxs)(`div`,{className:R(`mx-auto w-full max-w-md`,!r&&`rounded-3xl border border-line bg-surface-raised p-6 shadow-card sm:p-8`),children:[(0,Q.jsxs)(`div`,{className:R(`mb-8`,r?`text-start`:`text-center`),children:[(0,Q.jsx)(`h1`,{className:`mb-2 text-3xl font-light tracking-[-0.04em] text-ink`,children:i(`auth.login.title`)}),(0,Q.jsx)(`p`,{className:`text-sm leading-6 text-ink-muted`,children:i(`auth.login.subtitle`)})]}),(0,Q.jsxs)(`form`,{onSubmit:ne,className:`space-y-5`,children:[h&&(0,Q.jsxs)(`div`,{"data-testid":`login-approval-pending`,role:`status`,className:`flex gap-3 rounded-xl border border-warning-500/30 bg-warning-500/10 p-3 text-start`,children:[(0,Q.jsx)(he,{"aria-hidden":`true`,className:`mt-0.5 h-4 w-4 shrink-0 text-warning-700 dark:text-warning-400`}),(0,Q.jsx)(`p`,{className:`text-xs leading-5 text-ink-muted`,children:i(`auth.login.approvalPending`,`Your account is waiting for administrator approval.`)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`username`,className:`mb-2 block text-sm font-medium text-ink`,children:i(`auth.login.username`)}),(0,Q.jsx)(`input`,{id:`username`,type:`text`,value:s,onChange:e=>c(e.target.value),onKeyDown:re,className:`h-11 w-full rounded-xl border border-line bg-surface px-3 text-sm text-ink shadow-subtle outline-none transition-[border-color,box-shadow,background-color] placeholder:text-ink-muted focus:border-line-strong focus:ring-2 focus:ring-primary-500/35 disabled:cursor-not-allowed disabled:bg-surface-subtle disabled:text-ink-muted motion-reduce:transition-none`,placeholder:i(`auth.login.usernamePlaceholder`),required:!0,disabled:p||a})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`password`,className:`mb-2 block text-sm font-medium text-ink`,children:i(`auth.login.password`)}),(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`input`,{id:`password`,type:d?`text`:`password`,value:l,onChange:e=>u(e.target.value),onKeyDown:re,className:`h-11 w-full rounded-xl border border-line bg-surface px-3 pe-11 text-sm text-ink shadow-subtle outline-none transition-[border-color,box-shadow,background-color] placeholder:text-ink-muted focus:border-line-strong focus:ring-2 focus:ring-primary-500/35 disabled:cursor-not-allowed disabled:bg-surface-subtle disabled:text-ink-muted motion-reduce:transition-none`,placeholder:i(`auth.login.passwordPlaceholder`),required:!0,disabled:p||a}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>f(!d),className:`absolute inset-y-0 end-0 flex items-center pe-3 text-ink-muted transition-colors hover:text-ink disabled:cursor-not-allowed disabled:opacity-50`,disabled:p||a,"aria-label":d?`Hide characters`:`Reveal characters`,children:d?(0,Q.jsx)(lt,{size:20}):(0,Q.jsx)(at,{size:20})})]})]}),P&&ee&&(0,Q.jsx)(Yt,{siteKey:ee,action:`login`,disabled:p,errorMessage:i(`auth.login.verificationFailed`,`Security verification failed. Please refresh and try again.`),onTokenChange:F}),(0,Q.jsx)(`button`,{type:`submit`,disabled:te,className:`flex h-11 w-full items-center justify-center rounded-xl border border-transparent bg-ink px-4 text-sm font-medium text-ink-inverse shadow-subtle transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 focus-visible:ring-offset-canvas disabled:cursor-not-allowed disabled:opacity-40 motion-reduce:transition-none`,children:p?(0,Q.jsxs)(`div`,{className:`flex items-center`,children:[(0,Q.jsx)(`div`,{className:`me-2 h-4 w-4 animate-spin rounded-full border-b-2 border-current`}),i(`auth.login.signingIn`)]}):(0,Q.jsxs)(`div`,{className:`flex items-center`,children:[(0,Q.jsx)(ce,{size:16,className:`me-2`}),i(`auth.login.signIn`)]})})]}),!a&&Jt()&&M?.passkeysInUse&&(0,Q.jsxs)(`button`,{type:`button`,"data-testid":`passkey-signin-button`,onClick:B,disabled:p,className:`mt-3 flex h-11 w-full items-center justify-center rounded-xl border border-line bg-surface px-4 text-sm font-medium text-ink shadow-subtle transition-colors hover:bg-surface-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 disabled:cursor-not-allowed disabled:opacity-40 motion-reduce:transition-none`,children:[(0,Q.jsx)(ft,{size:16,className:`me-2`}),i(`auth.passkeys.signInButton`)]}),!a&&(0,Q.jsxs)(Q.Fragment,{children:[o.hasAny&&(0,Q.jsxs)(`div`,{className:`mt-6`,children:[(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`div`,{className:`absolute inset-0 flex items-center`,children:(0,Q.jsx)(`div`,{className:`w-full border-t border-line`})}),(0,Q.jsx)(`div`,{className:`relative flex justify-center text-sm`,children:(0,Q.jsx)(`span`,{className:R(`px-2 text-ink-muted`,r?`bg-canvas`:`bg-surface-raised`),children:i(`common.or`)})})]}),(0,Q.jsxs)(`div`,{className:`mt-6 space-y-3`,children:[o.github&&(0,Q.jsx)(dr,{}),o.huggingface&&(0,Q.jsx)(pr,{}),o.oidc&&(0,Q.jsx)(mr,{displayName:o.oidcDisplayName})]})]}),t&&(0,Q.jsx)(`div`,{className:`mt-6 text-center`,children:(0,Q.jsxs)(`p`,{className:`text-sm text-ink-muted`,children:[i(`auth.login.noAccount`),` `,(0,Q.jsx)(`button`,{onClick:t,className:`font-medium text-primary-600 transition-colors hover:text-primary-700 dark:text-primary-400 dark:hover:text-primary-300`,children:i(`auth.login.signUpHere`)})]})})]})]})},xr=F(`components:signup-form`),Sr=({onSignup:e,onBackToLogin:t,bare:n=!1})=>{let{t:r}=I(),[i,a]=(0,Z.useState)(``),[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(``),S=T(),{login:C,systemInfo:w}=Y(),E=w?.turnstile?.siteKey,D=!!(w?.turnstile?.enabled&&E),O=(0,Z.useCallback)(e=>{x(e)},[]),k=(0,Z.useMemo)(()=>g||D&&!b,[g,D,b]),A=async t=>{if(t.preventDefault(),!i.trim()||!c.trim()){q.error(r(`auth.signup.usernameRequired`));return}if(c!==u){q.error(r(`auth.signup.passwordMismatch`));return}let n=Xt(c);if(n){q.error(n);return}if(D&&!b){q.error(r(`auth.signup.tryAgain`));return}_(!0);try{let t=await J.signup({username:i,password:c,email:o,turnstileToken:b});if(t.success&&t.data){if(!(`token`in t.data)){y(!0),q.success(r(`auth.signup.approvalPending`,`Registration received. An administrator must approve your account.`));return}C(t.data.user,t.data.token,t.data.systemInfo),q.success(r(`auth.signup.signupSuccess`)),e?.(),S(`/`)}else q.error(t.message||r(`auth.signup.signupFailed`))}catch(e){xr.error(`Signup error:`,e),q.error(r(`auth.signup.tryAgain`))}finally{x(``),_(!1)}},j=e=>{if(e.key===`Enter`){let t=e.currentTarget.form;t&&t.requestSubmit()}};return v?(0,Q.jsxs)(`div`,{"data-testid":`signup-approval-pending`,className:R(`mx-auto w-full max-w-md text-center`,!n&&`rounded-3xl border border-line bg-surface-raised p-6 shadow-card sm:p-8`),children:[(0,Q.jsx)(`div`,{className:`mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-warning-500/15 text-warning-700 dark:text-warning-400`,children:(0,Q.jsx)(he,{"aria-hidden":`true`,className:`h-6 w-6`})}),(0,Q.jsx)(`h1`,{className:`mt-5 text-3xl font-light tracking-[-0.04em] text-ink`,children:r(`auth.signup.awaitingApproval`,`Awaiting approval`)}),(0,Q.jsx)(`p`,{className:`mt-3 text-sm leading-6 text-ink-muted`,children:r(`auth.signup.awaitingApprovalDescription`,`Your account has been created, but an administrator must activate it before you can sign in.`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:t,className:`mt-6 inline-flex h-11 w-full items-center justify-center rounded-xl border border-line bg-surface px-4 text-sm font-medium text-ink shadow-subtle transition-colors hover:bg-surface-raised`,children:r(`auth.signup.backToSignIn`,`Back to sign in`)})]}):(0,Q.jsxs)(`div`,{className:R(`mx-auto w-full max-w-md`,!n&&`rounded-3xl border border-line bg-surface-raised p-6 shadow-card sm:p-8`),children:[(0,Q.jsxs)(`div`,{className:R(`mb-8`,n?`text-start`:`text-center`),children:[(0,Q.jsx)(`h1`,{className:`mb-2 text-3xl font-light tracking-[-0.04em] text-ink`,children:r(`auth.signup.title`)}),(0,Q.jsx)(`p`,{className:`text-sm leading-6 text-ink-muted`,children:r(`auth.signup.subtitle`)})]}),(0,Q.jsxs)(`form`,{onSubmit:A,className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`username`,className:`mb-2 block text-sm font-medium text-ink`,children:r(`auth.signup.username`)}),(0,Q.jsx)(`input`,{id:`username`,type:`text`,value:i,onChange:e=>a(e.target.value),onKeyDown:j,className:`h-11 w-full rounded-xl border border-line bg-surface px-3 text-sm text-ink shadow-subtle outline-none transition-[border-color,box-shadow,background-color] placeholder:text-ink-muted focus:border-line-strong focus:ring-2 focus:ring-primary-500/35 disabled:cursor-not-allowed disabled:opacity-50 motion-reduce:transition-none`,placeholder:r(`auth.signup.usernamePlaceholder`),required:!0,disabled:g})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`label`,{htmlFor:`email`,className:`mb-2 block text-sm font-medium text-ink`,children:[r(`auth.signup.email`),` `,(0,Q.jsxs)(`span`,{className:`text-ink-muted`,children:[`(`,r(`common.optional`),`)`]})]}),(0,Q.jsx)(`input`,{id:`email`,type:`email`,value:o,onChange:e=>s(e.target.value),onKeyDown:j,className:`h-11 w-full rounded-xl border border-line bg-surface px-3 text-sm text-ink shadow-subtle outline-none transition-[border-color,box-shadow,background-color] placeholder:text-ink-muted focus:border-line-strong focus:ring-2 focus:ring-primary-500/35 disabled:cursor-not-allowed disabled:opacity-50 motion-reduce:transition-none`,placeholder:r(`auth.signup.emailPlaceholder`),disabled:g})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`password`,className:`mb-2 block text-sm font-medium text-ink`,children:r(`auth.signup.password`)}),(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`input`,{id:`password`,type:f?`text`:`password`,value:c,onChange:e=>l(e.target.value),onKeyDown:j,className:`h-11 w-full rounded-xl border border-line bg-surface px-3 pe-11 text-sm text-ink shadow-subtle outline-none transition-[border-color,box-shadow,background-color] placeholder:text-ink-muted focus:border-line-strong focus:ring-2 focus:ring-primary-500/35 disabled:cursor-not-allowed disabled:opacity-50 motion-reduce:transition-none`,placeholder:r(`auth.signup.passwordPlaceholder`),required:!0,disabled:g}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>p(!f),className:`absolute inset-y-0 end-0 flex items-center pe-3 text-ink-muted transition-colors hover:text-ink disabled:cursor-not-allowed disabled:opacity-50`,disabled:g,"aria-label":f?`Hide characters`:`Reveal characters`,children:f?(0,Q.jsx)(lt,{size:20}):(0,Q.jsx)(at,{size:20})})]}),(0,Q.jsx)(Zt,{password:c})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`confirmPassword`,className:`mb-2 block text-sm font-medium text-ink`,children:r(`auth.signup.confirmPassword`)}),(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`input`,{id:`confirmPassword`,type:m?`text`:`password`,value:u,onChange:e=>d(e.target.value),onKeyDown:j,className:`h-11 w-full rounded-xl border border-line bg-surface px-3 pe-11 text-sm text-ink shadow-subtle outline-none transition-[border-color,box-shadow,background-color] placeholder:text-ink-muted focus:border-line-strong focus:ring-2 focus:ring-primary-500/35 disabled:cursor-not-allowed disabled:opacity-50 motion-reduce:transition-none`,placeholder:r(`auth.signup.confirmPasswordPlaceholder`),required:!0,disabled:g}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>h(!m),className:`absolute inset-y-0 end-0 flex items-center pe-3 text-ink-muted transition-colors hover:text-ink disabled:cursor-not-allowed disabled:opacity-50`,disabled:g,"aria-label":m?`Hide confirmation`:`Reveal confirmation`,children:m?(0,Q.jsx)(lt,{size:20}):(0,Q.jsx)(at,{size:20})})]})]}),D&&E&&(0,Q.jsx)(Yt,{siteKey:E,action:`signup`,disabled:g,errorMessage:r(`auth.signup.tryAgain`),onTokenChange:O}),(0,Q.jsx)(`button`,{type:`submit`,disabled:k,className:`flex h-11 w-full items-center justify-center rounded-xl border border-transparent bg-ink px-4 text-sm font-medium text-ink-inverse shadow-subtle transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 focus-visible:ring-offset-canvas disabled:cursor-not-allowed disabled:opacity-40 motion-reduce:transition-none`,children:g?(0,Q.jsxs)(`div`,{className:`flex items-center`,children:[(0,Q.jsx)(`div`,{className:`me-2 h-4 w-4 animate-spin rounded-full border-b-2 border-current`}),r(`auth.signup.creatingAccount`)]}):(0,Q.jsxs)(`div`,{className:`flex items-center`,children:[(0,Q.jsx)(rt,{size:16,className:`me-2`}),r(`auth.signup.createAccount`)]})})]}),(0,Q.jsx)(dr,{}),(0,Q.jsx)(`div`,{className:`mt-6 text-center`,children:(0,Q.jsxs)(`p`,{className:`text-sm text-ink-muted`,children:[r(`auth.signup.hasAccount`),` `,(0,Q.jsx)(`button`,{onClick:t,className:`font-medium text-primary-600 transition-colors hover:text-primary-700 dark:text-primary-400 dark:hover:text-primary-300`,children:r(`auth.signup.signInHere`)})]})})]})},Cr=()=>{let{t:e}=I(),t=T(),n=ee(),{isAuthenticated:r,requiresAuth:i,systemInfo:a}=Y(),[o,s]=(0,Z.useState)(!1),c=i(),l=a?.signupEnabled??!0,u=new URLSearchParams(n.search).get(`approval`)===`pending`;if((0,Z.useEffect)(()=>{(r||!c)&&t(`/`)},[c,r,t]),r||!c)return null;let d=[{icon:fe,title:e(`auth.highlights.local.title`,`Local first`),body:e(`auth.highlights.local.body`,`Your conversations and files stay on the machine you run this on.`)},{icon:qe,title:e(`auth.highlights.providers.title`,`Any provider`),body:e(`auth.highlights.providers.body`,`Local models through Ollama, plus the remote providers you choose to add.`)},{icon:W,title:e(`auth.highlights.work.title`,`Isolated Work`),body:e(`auth.highlights.work.body`,`Give a model a sandboxed workspace with files, a terminal, and a preview.`)}],f=Qt(a?.version);return(0,Q.jsxs)(`div`,{className:`relative min-h-screen overflow-y-auto bg-canvas text-ink`,children:[(0,Q.jsxs)(`header`,{className:`absolute inset-x-0 top-0 z-10 flex h-14 items-center justify-between px-5 sm:px-8`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-ink lg:invisible`,children:[(0,Q.jsx)(Rt,{size:`sm`,label:null}),(0,Q.jsx)(Lt,{size:`sm`})]}),(0,Q.jsx)(_n,{})]}),(0,Q.jsxs)(`main`,{className:`grid min-h-screen lg:grid-cols-2`,children:[(0,Q.jsxs)(`section`,{className:`relative hidden flex-col justify-between border-e border-line bg-surface px-10 py-12 lg:flex xl:px-16`,children:[(0,Q.jsxs)(`div`,{className:`relative z-10 flex items-center gap-3.5 text-ink`,children:[(0,Q.jsx)(Rt,{size:`lg`,label:null}),(0,Q.jsx)(Lt,{size:`lg`})]}),(0,Q.jsxs)(`div`,{className:`relative z-10 max-w-lg`,children:[(0,Q.jsx)(`p`,{className:`text-[2.6rem] font-light leading-[1.05] tracking-[-0.04em] text-ink xl:text-5xl`,children:e(`auth.tagline`,`Your AI stack should answer to you.`)}),(0,Q.jsx)(`ul`,{className:`mt-10 space-y-5`,children:d.map(e=>(0,Q.jsxs)(`li`,{className:`flex gap-3`,children:[(0,Q.jsx)(e.icon,{"aria-hidden":`true`,className:`mt-0.5 h-4 w-4 shrink-0 text-ink-subtle`}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`p`,{className:`text-[13px] font-medium text-ink`,children:e.title}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-[13px] leading-relaxed text-ink-muted`,children:e.body})]})]},e.title))})]}),(0,Q.jsxs)(`div`,{className:`relative z-10 space-y-1 font-mono text-[11px] text-ink-subtle`,children:[(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`a`,{href:`https://librewebui.org`,target:`_blank`,rel:`noopener noreferrer`,className:`transition-colors hover:text-ink`,children:`librewebui.org`}),` · `,(0,Q.jsx)(`a`,{href:`https://docs.librewebui.org`,target:`_blank`,rel:`noopener noreferrer`,className:`transition-colors hover:text-ink`,children:`docs.librewebui.org`})]}),(0,Q.jsxs)(`p`,{"data-testid":`app-version`,children:[f?`v${f}`:``,f?` · `:``,e(`auth.selfHosted`,`Self-hosted · Apache 2.0`),` · `,(0,Q.jsx)(`a`,{href:`https://kroonen.ai`,target:`_blank`,rel:`noopener noreferrer`,className:`transition-colors hover:text-ink`,children:`kroonen.ai`})]})]})]}),(0,Q.jsx)(`section`,{className:`flex items-center justify-center px-5 pb-12 pt-24 sm:px-8 lg:px-12 lg:py-12`,children:(0,Q.jsx)(`div`,{className:`w-full max-w-sm`,children:o&&l?(0,Q.jsx)(Sr,{bare:!0,onBackToLogin:()=>s(!1),onSignup:()=>s(!1)}):(0,Q.jsx)(br,{bare:!0,initialApprovalPending:u,onShowSignup:l?()=>s(!0):void 0})})})]})]})},wr=window.location.protocol===`file:`,Tr=()=>wr?(0,Q.jsx)(`div`,{className:`absolute top-0 left-0 right-0 h-8 z-50`,style:{WebkitAppRegion:`drag`}}):null,Er=F(`app`),Dr=Z.lazy(()=>P(()=>import(`../js/HomePage-B9nkyAdS.js`),__vite__mapDeps([30,1,2,31,4,5,6,7,8,9,10,11,12,13,14,16,17,32,33,34,26,35]))),Or=Z.lazy(()=>P(()=>import(`../js/ChatPage-DRdVuXt2.js`),__vite__mapDeps([36,1,2,31,4,5,6,7,8,9,10,11,12,13,14,16,17,34,18,19,20,22,37,38,24,39,28,40,41,42,43,44,45,46,3]))),kr=Z.lazy(()=>P(()=>import(`../js/WhatsNewModal-CKkWbbNI.js`).then(e=>({default:e.WhatsNewModal})),__vite__mapDeps([47,1,2,5,6,7,10,11,19,20,4,17,18,43]))),Ar=Z.lazy(()=>P(()=>import(`../js/PersonasPage-DZ4GBVkJ.js`),__vite__mapDeps([48,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17,19,20,18,49,23]))),jr=Z.lazy(()=>P(()=>import(`../js/GalleryPage-CkpikP93.js`),__vite__mapDeps([50,1,2,3,4,5,6,7,10,11,12,13,14,15,17,19,20,18]))),Mr=Z.lazy(()=>P(()=>import(`../js/NotesPage-1TG04re5.js`),__vite__mapDeps([51,1,2,31,4,5,6,7,8,9,10,11,12,13,14,19,20,17,18,52,43]))),Nr=Z.lazy(()=>P(()=>import(`../js/CalendarPage-D71tcbA3.js`),__vite__mapDeps([53,1,2,31,4,5,6,7,10,11,12,13,14,19,20,17,18,23,54]))),Pr=Z.lazy(()=>P(()=>import(`../js/AutomationsPage-CuDSh_W2.js`),__vite__mapDeps([55,1,2,31,4,5,6,7,8,9,10,11,12,13,14,19,20,17,18,56,54]))),Fr=Z.lazy(()=>P(()=>import(`../js/LibreClawPage-CKtbq8am.js`),__vite__mapDeps([57,1,2,4,9,5,6,7,10,11,12,13,14,19,20,17,18]))),Ir=Z.lazy(()=>P(()=>import(`../js/ChannelsPage-BFkTp2cp.js`),__vite__mapDeps([58,1,2,31,4,5,6,7,8,9,10,11,12,13,14,16,17,19,20,18,59]))),Lr=Z.lazy(()=>P(()=>import(`../js/WorkPage-BEJ98OxR.js`),__vite__mapDeps([60,1,2,31,4,5,6,7,8,9,10,11,12,13,14,16,17,19,20,18,22,32,52,43,56,54,46,3,35]))),Rr=Z.lazy(()=>P(()=>import(`../js/UserManagementPage-CBA-O0bM.js`),__vite__mapDeps([61,1,2,3,4,5,6,7,10,11,14,13,12,16,8,9,17,19,20,18,62,27]))),zr=Z.lazy(()=>P(()=>import(`../js/PluginUsagePage-QGOo5MZj.js`),__vite__mapDeps([63,1,2,3,5,6,7,10,11,14,4,13,12,19,20,17,18]))),Br=Z.lazy(()=>P(()=>import(`../js/EvaluationsPage-C6NHj9KF.js`),__vite__mapDeps([64,1,2,5,6,7,8,4,9,10,11,12,13,14,19,20,17,18,45]))),Vr=Z.lazy(()=>P(()=>import(`../js/SystemPage-B1bDpa9g.js`),__vite__mapDeps([65,1,2,3,5,6,7,10,11,14,4,13,12,16,8,9,17,19,20,18]))),Hr=Z.lazy(()=>P(()=>import(`../js/ArtifactDemoPage-Cr_bMx_v.js`),__vite__mapDeps([66,1,2,19,6,7,20,4,5,10,11,17,18,40,38,41,42,43,44,13]))),Ur=Z.lazy(()=>P(()=>import(`../js/SettingsModal-Cl5eVfDM.js`).then(e=>({default:e.SettingsModal})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28]))),Wr=Z.lazy(()=>P(()=>import(`../js/ArtifactSlideOutPanel-zizbFUzW.js`).then(e=>({default:e.ArtifactSlideOutPanel})),__vite__mapDeps([67,1,2,4,5,6,7,8,9,10,11,12,13,14,17,19,38,41,42,43,44]))),Gr=Z.lazy(()=>P(()=>import(`../js/FirstTimeSetup-BVOPC4uh.js`).then(e=>({default:e.FirstTimeSetup})),__vite__mapDeps([68,1,2,4,5,6,7,10,11,12,13,14,16,8,9,17,21,22,69,62,39,19,20,18]))),Kr=()=>{let{t:e}=I();return(0,Q.jsx)(`div`,{className:`flex h-full min-h-screen items-center justify-center bg-gray-50 dark:bg-dark-100`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[(0,Q.jsx)(`div`,{className:`h-8 w-8 rounded-full border-4 border-gray-200 border-t-primary-500 animate-spin dark:border-dark-300 dark:border-t-primary-400`}),(0,Q.jsx)(`div`,{className:`text-gray-600 dark:text-dark-600`,children:e(`common.loading`)})]})})},qr=({isOpen:e,compact:t})=>(0,Q.jsx)(`div`,{"aria-hidden":`true`,className:R(`hidden lg:block flex-shrink-0 transition-[width] duration-200 ease-out`,e?t?`w-16`:`w-72`:`w-0`)}),Jr=()=>{let{artifactPanelOpen:e,artifactPanelWidth:t,artifactPanelResizing:n}=Mt();return(0,Q.jsx)(`div`,{"aria-hidden":`true`,className:R(`hidden md:block flex-shrink-0`,!n&&`transition-[width] duration-300 ease-out`),style:{width:e?t:0}})},Yr=({hasBackground:e,sidebarOpen:t,sidebarCompact:n,onCloseSidebar:r,showDemoBanner:i,demoMessage:a,children:o})=>(0,Q.jsxs)(`div`,{className:R(`flex h-dvh min-h-0 text-ink relative overflow-hidden`,e?`bg-sidebar/60`:`bg-sidebar`),children:[(0,Q.jsx)(Tr,{}),(0,Q.jsx)(Jn,{}),(0,Q.jsx)(Bn,{isOpen:t,onClose:r}),(0,Q.jsx)(qr,{isOpen:t,compact:n}),(0,Q.jsxs)(`div`,{"data-testid":`app-shell-content`,className:R(`flex-1 basis-0 flex min-h-0 flex-col min-w-0 transition-[margin,background-color] duration-200 ease-out relative z-10 lg:pb-2 lg:pe-2`,wr?`pt-8`:`lg:pt-1.5`,t&&n?`max-lg:ms-16`:`max-lg:ms-0`,e?`bg-white/10 dark:bg-dark-50/10`:`bg-transparent`),children:[i&&(0,Q.jsx)(qn,{message:a}),(0,Q.jsx)(er,{}),(0,Q.jsx)(`main`,{className:R(`min-h-0 flex-1 overflow-hidden lg:rounded-[1.5rem] lg:border lg:border-black/[0.06] dark:lg:border-white/[0.07] lg:shadow-[0_1px_2px_rgba(0,0,0,0.03),0_18px_60px_rgba(15,23,42,0.04)]`,e?`bg-white/30 dark:bg-dark-50/35 backdrop-blur-sm`:`bg-canvas`),children:(0,Q.jsx)(Wn,{children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Kr,{}),children:o})})})]}),(0,Q.jsx)(Jr,{})]}),Xr=[{path:`*`,element:(0,Q.jsx)(()=>{let{t:e,i18n:t}=I(),n=T(),[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(void 0),[s,c]=(0,Z.useState)(0),[l,u]=(0,Z.useState)(!1),{sidebarOpen:d,sidebarCompact:f,setSidebarOpen:p,setSidebarCompact:m,toggleSidebar:h,toggleSidebarCompact:g,toggleTheme:_,backgroundImage:v,preferences:y,artifactPanelOpen:b,closeArtifactPanel:x}=Mt(),{systemInfo:S,isLoading:C,user:E,isAuthenticated:D}=Y(),{isDemoMode:k,demoConfig:A}=Mt(),j=S?.requiresAuth===!1||D,M=Kn();Z.useEffect(()=>{if(!(!y.ttsSettings?.enabled||!y.ttsSettings.autoPlay))return Kt()},[y.ttsSettings?.autoPlay,y.ttsSettings?.enabled]);let[ee,N]=Z.useState(!1),P=Z.useRef(!1);Z.useEffect(()=>{(async()=>{if(P.current){Er.debug(`OAuth already processing, skipping...`);return}if(Er.debug(`Starting OAuth callback processing...`),P.current=!0,new URLSearchParams(window.location.search).get(`auth`)===`success`){try{let t=await fetch(`${gt}/auth/oauth/exchange`,{method:`POST`,credentials:`include`});if(t.ok){let n=await t.json();if(n.success&&n.data){let{login:t}=Y.getState();t(n.data.user,n.data.token,n.data.systemInfo),Er.debug(`OAuth login successful`),ut.success(e(`auth.oauth.loginSuccess`))}else ut.error(e(`auth.oauth.completionFailed`))}else ut.error(e(`auth.oauth.verificationFailed`))}catch(t){Er.error(`OAuth processing error:`,t),ut.error(e(`auth.oauth.authenticationFailed`))}window.history.replaceState({},document.title,window.location.pathname)}Er.debug(`OAuth processing completed`),N(!0),P.current=!1})()},[e]),cr();let F=()=>{if(v)return!0;let e=y.backgroundSettings;return e?.enabled&&e?.imageUrl};lr([{key:`b`,metaKey:!0,action:()=>{window.innerWidth>=1024?d?g():(m(!1),h()):(!d&&f&&m(!1),h())},description:e(`keyboard.toggleSidebar`)},{key:`,`,metaKey:!0,action:()=>{o(void 0),i(!0)},description:e(`keyboard.openSettings`)},{key:`o`,metaKey:!0,shiftKey:!0,action:()=>Ut(n),description:e(`keyboard.newChat`)},{key:`u`,metaKey:!0,shiftKey:!0,action:()=>{Y.getState().canUseWork()&&Wt(n)},description:e(`keyboard.newWork`)},{key:`d`,metaKey:!0,action:_,description:e(`keyboard.toggleDarkMode`)},{key:`?`,action:()=>{o(`shortcuts`),i(!0)},description:e(`keyboard.showShortcuts`)},{key:`Escape`,action:()=>i(!1),description:e(`keyboard.closeModals`)}],j),Z.useEffect(()=>{if(j)return;let e=window.requestAnimationFrame(()=>{i(!1),x()});return()=>window.cancelAnimationFrame(e)},[x,j]),Z.useEffect(()=>{if(!j){Ot.disconnect();return}return Ot.connect().catch(Er.error),()=>{Ot.disconnect()}},[j]),Z.useEffect(()=>{if(!S&&!C&&s<15){let e=setTimeout(async()=>{c(e=>e+1);try{await or.initializeAuth()}catch{}},2e3);return()=>clearTimeout(e)}},[S,C,s]);let te=!l&&S?.requiresAuth===!0&&S?.hasUsers===!1;return C?(0,Q.jsxs)(`div`,{className:`min-h-screen bg-gray-50 dark:bg-dark-50 flex flex-col justify-center py-12 sm:px-6 lg:px-8`,children:[(0,Q.jsx)(`div`,{className:`sm:mx-auto sm:w-full sm:max-w-md`,children:(0,Q.jsx)(`div`,{className:`flex flex-col items-center`,children:(0,Q.jsx)(Rt,{size:`lg`,className:`text-gray-900 dark:text-gray-100`})})}),(0,Q.jsx)(`div`,{className:`mt-8 flex flex-col items-center gap-4`,children:(0,Q.jsx)(`div`,{className:`w-8 h-8 border-4 border-gray-300 dark:border-gray-600 border-t-primary-500 dark:border-t-primary-400 rounded-full animate-spin`})})]}):S?te&&!l?(0,Q.jsx)(Wn,{children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Kr,{}),children:(0,Q.jsx)(Gr,{onComplete:()=>{u(!0)}})})}):ee?(0,Q.jsxs)(Q.Fragment,{children:[S&&!S.requiresAuth?(0,Q.jsx)(Yr,{hasBackground:!!F(),sidebarOpen:d,sidebarCompact:f,onCloseSidebar:()=>p(!1),showDemoBanner:k&&A.showBanner,demoMessage:A.message,children:(0,Q.jsxs)(w,{children:[(0,Q.jsx)(O,{path:`/`,element:(0,Q.jsx)(Dr,{})}),(0,Q.jsx)(O,{path:`/chat`,element:(0,Q.jsx)(Or,{})}),(0,Q.jsx)(O,{path:`/c/:sessionId`,element:(0,Q.jsx)(Or,{})}),(0,Q.jsx)(O,{path:`/personas`,element:(0,Q.jsx)(Ar,{})}),(0,Q.jsx)(O,{path:`/gallery`,element:(0,Q.jsx)(jr,{})}),(0,Q.jsx)(O,{path:`/notes`,element:(0,Q.jsx)(Mr,{})}),(0,Q.jsx)(O,{path:`/calendar`,element:(0,Q.jsx)(Nr,{})}),(0,Q.jsx)(O,{path:`/automations`,element:(0,Q.jsx)(Pr,{})}),(0,Q.jsx)(O,{path:`/channels`,element:(0,Q.jsx)(Ir,{})}),(0,Q.jsx)(O,{path:`/work`,element:(0,Q.jsx)($,{requireWork:!0,children:(0,Q.jsx)(Lr,{})})}),(0,Q.jsx)(O,{path:`/work/:taskId`,element:(0,Q.jsx)($,{requireWork:!0,children:(0,Q.jsx)(Lr,{})})}),(0,Q.jsx)(O,{path:`/agents`,element:(0,Q.jsx)($,{requireAdmin:!0,requireAgents:!0,children:(0,Q.jsx)(Fr,{})})}),(0,Q.jsx)(O,{path:`/usage`,element:(0,Q.jsx)($,{requireAdmin:!0,children:(0,Q.jsx)(zr,{})})}),(0,Q.jsx)(O,{path:`/evaluations`,element:(0,Q.jsx)(Br,{})}),(0,Q.jsx)(O,{path:`/system`,element:(0,Q.jsx)($,{requireAdmin:!0,children:(0,Q.jsx)(Vr,{})})}),(0,Q.jsx)(O,{path:`/login`,element:(0,Q.jsx)(Cr,{})})]})}):(0,Q.jsxs)(w,{children:[(0,Q.jsx)(O,{path:`/login`,element:(0,Q.jsx)(Cr,{})}),(0,Q.jsx)(O,{path:`/*`,element:(0,Q.jsx)($,{children:(0,Q.jsx)(Yr,{hasBackground:!!F(),sidebarOpen:d,sidebarCompact:f,onCloseSidebar:()=>p(!1),showDemoBanner:k&&A.showBanner,demoMessage:A.message,children:(0,Q.jsxs)(w,{children:[(0,Q.jsx)(O,{path:`/`,element:(0,Q.jsx)(Dr,{})}),(0,Q.jsx)(O,{path:`/chat`,element:(0,Q.jsx)(Or,{})}),(0,Q.jsx)(O,{path:`/c/:sessionId`,element:(0,Q.jsx)(Or,{})}),(0,Q.jsx)(O,{path:`/personas`,element:(0,Q.jsx)(Ar,{})}),(0,Q.jsx)(O,{path:`/gallery`,element:(0,Q.jsx)(jr,{})}),(0,Q.jsx)(O,{path:`/notes`,element:(0,Q.jsx)(Mr,{})}),(0,Q.jsx)(O,{path:`/calendar`,element:(0,Q.jsx)(Nr,{})}),(0,Q.jsx)(O,{path:`/automations`,element:(0,Q.jsx)(Pr,{})}),(0,Q.jsx)(O,{path:`/channels`,element:(0,Q.jsx)(Ir,{})}),(0,Q.jsx)(O,{path:`/work`,element:(0,Q.jsx)($,{requireWork:!0,children:(0,Q.jsx)(Lr,{})})}),(0,Q.jsx)(O,{path:`/work/:taskId`,element:(0,Q.jsx)($,{requireWork:!0,children:(0,Q.jsx)(Lr,{})})}),(0,Q.jsx)(O,{path:`/agents`,element:(0,Q.jsx)($,{requireAdmin:!0,requireAgents:!0,children:(0,Q.jsx)(Fr,{})})}),(0,Q.jsx)(O,{path:`/artifacts`,element:(0,Q.jsx)(Hr,{})}),(0,Q.jsx)(O,{path:`/usage`,element:(0,Q.jsx)($,{requireAdmin:!0,children:(0,Q.jsx)(zr,{})})}),(0,Q.jsx)(O,{path:`/evaluations`,element:(0,Q.jsx)(Br,{})}),(0,Q.jsx)(O,{path:`/system`,element:(0,Q.jsx)($,{requireAdmin:!0,children:(0,Q.jsx)(Vr,{})})}),(0,Q.jsx)(O,{path:`/users`,element:(0,Q.jsx)($,{requireAdmin:!0,children:(0,Q.jsx)(Rr,{})})})]})})})})]}),j&&r&&(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(Ur,{isOpen:r,initialTab:a,onClose:()=>i(!1)})}),j&&M.open&&M.notes&&(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(kr,{notes:M.notes,onDismiss:M.dismiss})}),j&&b&&(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(Wr,{})}),(0,Q.jsx)(Oe,{position:B(t.language)?`top-left`:`top-right`,toastOptions:{duration:4e3,className:`animate-slide-up`,style:{background:`var(--toast-bg)`,color:`var(--toast-color)`,border:`1px solid var(--toast-border)`,borderRadius:`0.75rem`,boxShadow:`0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)`,cursor:`pointer`},success:{iconTheme:{primary:`rgb(var(--color-primary-600))`,secondary:`#ffffff`}},error:{iconTheme:{primary:`rgb(var(--color-primary-600))`,secondary:`#ffffff`}}},containerStyle:{top:80,insetInlineEnd:20}}),j&&(0,Q.jsx)(ir,{onOpenSettings:()=>{o(void 0),i(!0)},onOpenSettingsTab:e=>{o(e),i(!0)}})]}):(0,Q.jsx)(`div`,{className:`min-h-screen bg-gray-50 dark:bg-dark-50 flex items-center justify-center`,children:(0,Q.jsx)(`div`,{className:`w-8 h-8 border-4 border-gray-300 dark:border-gray-600 border-t-primary-500 dark:border-t-primary-400 rounded-full animate-spin`})}):(0,Q.jsx)(`div`,{className:`min-h-screen bg-gray-50 dark:bg-dark-50 flex items-center justify-center p-4`,children:(0,Q.jsxs)(`div`,{className:`text-center`,children:[(0,Q.jsx)(`div`,{className:`mb-8`,children:(0,Q.jsx)(Rt,{size:`lg`,className:`mx-auto text-gray-900 dark:text-white`})}),(0,Q.jsx)(`div`,{className:`flex justify-center mb-4`,children:(0,Q.jsx)(`div`,{className:`w-8 h-8 border-4 border-gray-300 dark:border-dark-300 border-t-primary-500 dark:border-t-primary-400 rounded-full animate-spin`})}),(0,Q.jsx)(`p`,{className:`text-gray-600 dark:text-dark-600 text-sm`,children:s>0?`Connecting to backend... (${s}/15)`:`Starting up...`})]})})},{}),errorElement:(0,Q.jsx)(Un,{})}],Zr=wr?A(Xr):D(Xr),Qr=()=>(0,Q.jsx)(Wn,{children:(0,Q.jsx)(j,{router:Zr})}),$r=new an({defaultOptions:{queries:{staleTime:3e4,refetchOnWindowFocus:!1,retry:1}}});oe.catch(()=>{z(`en`)}).then(()=>{on.createRoot(document.getElementById(`root`)).render((0,Q.jsx)(Z.StrictMode,{children:(0,Q.jsx)(a,{client:$r,children:(0,Q.jsx)(Qr,{})})}))}),window.addEventListener(`vite:preloadError`,e=>{let t=`libre:chunk-reload`;sessionStorage.getItem(t)||(e.preventDefault(),sessionStorage.setItem(t,String(Date.now())),window.location.reload())}),window.setTimeout(()=>{sessionStorage.removeItem(`libre:chunk-reload`)},6e4),`serviceWorker`in navigator&&window.addEventListener(`load`,()=>{navigator.serviceWorker.register(`/sw.js?v=0.32.0`).catch(()=>{})});
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,r as n,t as r}from"./react-vendor-D0Ec-185.js";import{d as i}from"./router-vendor-CMbYTGdh.js";import{t as a}from"./logger-DnuT4jgB.js";import{t as o}from"./useTranslation-D0mJ4NnO.js";import{t as s}from"./utils-Bn0RE9_8.js";import{Cn as c,Gn as l,Q as u,R as d,Wn as f,n as p,p as m,v as h,yr as g}from"./ui-vendor-DvJV-69N.js";import{O as _,T as v}from"./api-T6SWjL0K.js";import{t as y}from"./Button-BQ5JnUVj.js";import"./ui-BZOjqAJH.js";import{t as b}from"./ShareDialog-CeHMOTrA.js";import{a as x,c as S,d as C,i as w,l as T,n as E,o as D,r as O,s as k,t as A,u as j}from"./calendarDates-Co3o_05Y.js";var M=e(t(),1),N=r(),P={event:`bg-primary-500/15 text-primary-700 hover:bg-primary-500/25 dark:text-primary-300`,automation:`bg-amber-500/15 text-amber-700 hover:bg-amber-500/25 dark:text-amber-300`,runSucceeded:`bg-emerald-500/15 text-emerald-700 hover:bg-emerald-500/25 dark:text-emerald-300`,runFailed:`bg-red-500/15 text-red-700 hover:bg-red-500/25 dark:text-red-300`};function F({event:e,label:t,onClick:n}){return(0,N.jsx)(`button`,{type:`button`,"data-testid":`calendar-event-chip`,"data-variant":e.variant??`event`,title:e.title,onClick:e=>{e.stopPropagation(),n()},className:s(`w-full truncate rounded-md px-1.5 py-0.5 text-start text-[11px] leading-4 transition-colors`,P[e.variant??`event`],e.baseEventId&&`opacity-75`),children:t})}var I=3;function L({year:e,monthIndex:t,events:n,onDayClick:r,onEventClick:i}){let{t:a,i18n:c}=o(),l=(0,M.useMemo)(()=>O(e,t),[e,t]),u=new Date,d=(0,M.useMemo)(()=>{let e=new Map;for(let t of n){let n=new Date(t.startAt),r=`${n.getFullYear()}-${n.getMonth()}-${n.getDate()}`,i=e.get(r);i?i.push(t):e.set(r,[t])}return e},[n]),f=(0,M.useMemo)(()=>C(c.language),[c.language]);return(0,N.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"data-testid":`calendar-month-grid`,children:[(0,N.jsx)(`div`,{className:`grid grid-cols-7 border-b border-black/[0.06] dark:border-white/[0.07]`,children:f.map(e=>(0,N.jsx)(`div`,{className:`px-2 py-1.5 text-center text-[11px] font-medium uppercase tracking-wide text-gray-400 dark:text-dark-500`,children:e},e))}),(0,N.jsx)(`div`,{className:`grid min-h-0 flex-1 grid-cols-7 grid-rows-6`,children:l.map(e=>{let n=e.getMonth()===t,o=w(e,u),l=`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`,f=d.get(l)??[],p=f.length-I;return(0,N.jsxs)(`div`,{role:`gridcell`,"data-testid":`calendar-day-cell`,onClick:()=>r(e),className:s(`flex min-h-0 cursor-pointer flex-col gap-0.5 border-b border-e border-black/[0.04] p-1 transition-colors hover:bg-black/[0.02] dark:border-white/[0.04] dark:hover:bg-white/[0.03]`,!n&&`opacity-40`),children:[(0,N.jsx)(`span`,{className:s(`flex h-6 w-6 items-center justify-center rounded-full text-[12px]`,o?`bg-primary-500 font-semibold text-white`:`text-gray-600 dark:text-dark-600`),children:e.getDate()}),(0,N.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-0.5 overflow-hidden`,children:[f.slice(0,I).map(e=>(0,N.jsx)(F,{event:e,label:e.allDay?e.title:`${k(e.startAt,c.language)} ${e.title}`,onClick:()=>i(e)},e.id)),p>0&&(0,N.jsx)(`span`,{className:`px-1 text-[10px] text-gray-400 dark:text-dark-500`,children:a(`calendar.more`,{n:p})})]})]},l)})})]})}var R=48;function ee({anchor:e,events:t,dayCount:n=7,onDayClick:r,onEventClick:i}){let{i18n:a}=o(),c=(0,M.useMemo)(()=>n===1?[new Date(e.getFullYear(),e.getMonth(),e.getDate())]:j(e),[e,n]),l=new Date,u=(0,M.useMemo)(()=>new Intl.DateTimeFormat(a.language,{hour:`numeric`}),[a.language]),d=(0,M.useMemo)(()=>new Intl.DateTimeFormat(a.language,{weekday:`short`,day:`numeric`}),[a.language]),f=e=>t.filter(t=>t.allDay&&w(new Date(t.startAt),e)),p=e=>t.filter(t=>!t.allDay&&w(new Date(t.startAt),e));return(0,N.jsx)(`div`,{className:`scroll-region min-h-0 flex-1 overflow-y-auto scrollbar-thin`,"data-testid":`calendar-week-grid`,children:(0,N.jsxs)(`div`,{className:`grid grid-cols-[3.5rem_repeat(7,1fr)]`,children:[(0,N.jsx)(`div`,{className:`sticky top-0 z-10 border-b border-black/[0.06] bg-surface dark:border-white/[0.07]`}),c.map(e=>(0,N.jsxs)(`div`,{className:`sticky top-0 z-10 border-b border-e border-black/[0.06] bg-surface px-1 py-1.5 dark:border-white/[0.07]`,children:[(0,N.jsx)(`span`,{className:s(`block truncate text-center text-[11px] font-medium`,w(e,l)?`text-primary-600 dark:text-primary-400`:`text-gray-500 dark:text-dark-500`),children:d.format(e)}),(0,N.jsx)(`div`,{className:`mt-0.5 space-y-0.5`,children:f(e).map(e=>(0,N.jsx)(F,{event:e,label:e.title,onClick:()=>i(e)},e.id))})]},e.toISOString())),Array.from({length:24},(e,t)=>(0,N.jsxs)(M.Fragment,{children:[(0,N.jsx)(`div`,{className:`relative border-b border-black/[0.04] pe-1.5 text-end text-[10px] text-gray-400 dark:border-white/[0.04] dark:text-dark-500`,children:(0,N.jsx)(`span`,{className:`relative -top-1.5`,children:t>0?u.format(new Date(2024,0,1,t)):``})}),c.map(e=>{let n=p(e).filter(e=>new Date(e.startAt).getHours()===t);return(0,N.jsx)(`div`,{onClick:()=>r(e,t),style:{height:R},className:`cursor-pointer space-y-0.5 overflow-hidden border-b border-e border-black/[0.04] p-0.5 transition-colors hover:bg-black/[0.02] dark:border-white/[0.04] dark:hover:bg-white/[0.03]`,children:n.map(e=>(0,N.jsx)(F,{event:e,label:`${k(e.startAt,a.language)} ${e.title}`,onClick:()=>i(e)},e.id))},`${e.toISOString()}-${t}`)})]},t))]})})}var z=n(),B=e=>!e||e.kind===`once`||e.kind===`hourly`?`none`:e.kind,V=(e,t)=>{let n=new Date(t),r=n.getHours(),i=n.getMinutes();switch(e){case`daily`:return{kind:`daily`,hour:r,minute:i};case`weekly`:return{kind:`weekly`,dayOfWeek:n.getDay(),hour:r,minute:i};case`monthly`:return{kind:`monthly`,dayOfMonth:n.getDate(),hour:r,minute:i};case`yearly`:return{kind:`yearly`,month:n.getMonth()+1,dayOfMonth:n.getDate(),hour:r,minute:i};default:return null}},H=`w-full rounded-lg border border-black/[0.08] bg-white px-2.5 py-1.5 text-[13px] text-gray-900 focus:border-primary-500/40 focus:outline-none dark:border-white/[0.08] dark:bg-dark-100 dark:text-dark-900`,U=`mb-1 block text-[11px] font-medium uppercase tracking-wide text-gray-400 dark:text-dark-500`;function te({open:e,event:t,initialStartAt:n,calendars:r,saving:i,onClose:a,onSave:o,onDelete:s}){return e?(0,N.jsx)(W,{event:t,initialStartAt:n,calendars:r,saving:i,onClose:a,onSave:o,onDelete:s},`${t?.id??`new`}:${n}`):null}function W({event:e,initialStartAt:t,calendars:n,saving:r,onClose:i,onSave:a,onDelete:s}){let{t:c}=o(),l=e?.startAt??t,[u,d]=(0,M.useState)(e?.title??``),[f,m]=(0,M.useState)(e?.notes??``),[g,_]=(0,M.useState)(S(l)),[v,y]=(0,M.useState)(e?T(l):`09:00`),[b,x]=(0,M.useState)(e?.endAt===void 0?``:T(e.endAt)),[C,w]=(0,M.useState)(e?.allDay??!1),[D,O]=(0,M.useState)(B(e?.recurrence)),[k,A]=(0,M.useState)(e?.calendarId??``),[j,P]=(0,M.useState)(e?.reminderMinutes===void 0?``:String(e.reminderMinutes)),F=()=>{if(!u.trim()||!g)return;let e=E(g,C?``:v),t=!C&&b?E(g,b):null;a({title:u.trim(),notes:f.trim()?f.trim():void 0,startAt:e,endAt:t!==null&&t>e?t:null,allDay:C,recurrence:V(D,e),calendarId:k||null,reminderMinutes:j?Number(j):null})},I=[{value:``,label:c(`calendar.reminderNone`)},{value:`5`,label:c(`calendar.reminderMinutes`,{minutes:5})},{value:`15`,label:c(`calendar.reminderMinutes`,{minutes:15})},{value:`30`,label:c(`calendar.reminderMinutes`,{minutes:30})},{value:`60`,label:c(`calendar.reminderHour`)},{value:`1440`,label:c(`calendar.reminderDay`)}],L=[{value:`none`,label:c(`calendar.repeatNone`)},{value:`daily`,label:c(`calendar.repeatDaily`)},{value:`weekly`,label:c(`calendar.repeatWeekly`)},{value:`monthly`,label:c(`calendar.repeatMonthly`)},{value:`yearly`,label:c(`calendar.repeatYearly`)}];return(0,z.createPortal)((0,N.jsx)(`div`,{className:`fixed inset-0 z-[2147483647] flex items-center justify-center bg-gray-950/55 p-4 backdrop-blur-md`,onClick:i,children:(0,N.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`calendar-event-modal-title`,"data-testid":`calendar-event-modal`,className:`w-full max-w-md rounded-3xl border border-black/[0.07] bg-white p-6 shadow-[0_24px_80px_rgba(0,0,0,0.24)] animate-scale-in dark:border-white/[0.08] dark:bg-dark-25`,onClick:e=>e.stopPropagation(),children:[(0,N.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,N.jsx)(`h3`,{id:`calendar-event-modal-title`,className:`text-lg font-medium tracking-[-0.02em] text-gray-950 dark:text-dark-950`,children:c(e?`calendar.editEvent`:`calendar.newEvent`)}),(0,N.jsx)(`button`,{onClick:i,"aria-label":c(`common.close`),className:`rounded-xl p-2 transition-colors hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,N.jsx)(p,{size:20,className:`text-gray-500`})})]}),(0,N.jsxs)(`div`,{className:`space-y-3`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{htmlFor:`calendar-event-title`,className:U,children:c(`calendar.eventTitle`)}),(0,N.jsx)(`input`,{id:`calendar-event-title`,"data-testid":`calendar-event-title`,type:`text`,value:u,onChange:e=>d(e.target.value),placeholder:c(`calendar.titlePlaceholder`),className:H,maxLength:200,autoFocus:!0})]}),(0,N.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{htmlFor:`calendar-event-date`,className:U,children:c(`calendar.date`)}),(0,N.jsx)(`input`,{id:`calendar-event-date`,type:`date`,value:g,onChange:e=>_(e.target.value),className:H})]}),(0,N.jsx)(`div`,{className:`flex items-end pb-1.5`,children:(0,N.jsxs)(`label`,{className:`flex items-center gap-2 text-[13px] text-gray-700 dark:text-dark-700`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:C,onChange:e=>w(e.target.checked),className:`h-4 w-4 rounded accent-primary-500`}),c(`calendar.allDay`)]})})]}),!C&&(0,N.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{htmlFor:`calendar-event-start`,className:U,children:c(`calendar.start`)}),(0,N.jsx)(`input`,{id:`calendar-event-start`,type:`time`,value:v,onChange:e=>y(e.target.value),className:H})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{htmlFor:`calendar-event-end`,className:U,children:c(`calendar.end`)}),(0,N.jsx)(`input`,{id:`calendar-event-end`,type:`time`,value:b,onChange:e=>x(e.target.value),className:H})]})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{htmlFor:`calendar-event-repeat`,className:U,children:c(`calendar.repeat`)}),(0,N.jsx)(`select`,{id:`calendar-event-repeat`,value:D,onChange:e=>O(e.target.value),className:H,children:L.map(e=>(0,N.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{htmlFor:`calendar-event-notes`,className:U,children:c(`calendar.notes`)}),(0,N.jsx)(`textarea`,{id:`calendar-event-notes`,value:f,onChange:e=>m(e.target.value),rows:3,className:H,maxLength:1e4})]}),(0,N.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:U,children:c(`calendar.calendarLabel`)}),(0,N.jsxs)(`select`,{value:k,onChange:e=>A(e.target.value),className:H,"data-testid":`calendar-event-calendar`,children:[(0,N.jsx)(`option`,{value:``,children:c(`calendar.personalCalendar`)}),n.map(e=>(0,N.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:U,children:c(`calendar.reminderLabel`)}),(0,N.jsx)(`select`,{value:j,onChange:e=>P(e.target.value),className:H,"data-testid":`calendar-event-reminder`,children:I.map(e=>(0,N.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})]}),(0,N.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-t border-gray-200 pt-4 dark:border-dark-300`,children:[e&&s?(0,N.jsxs)(`button`,{onClick:s,"data-testid":`calendar-event-delete`,className:`flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium text-red-600 transition-colors hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-900/20`,children:[(0,N.jsx)(h,{className:`h-4 w-4`}),c(`common.delete`)]}):(0,N.jsx)(`span`,{}),(0,N.jsxs)(`div`,{className:`flex gap-3`,children:[(0,N.jsx)(`button`,{onClick:i,className:`rounded-xl px-4 py-2 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-100 dark:text-dark-700 dark:hover:bg-dark-200`,children:c(`common.cancel`)}),(0,N.jsx)(`button`,{onClick:F,disabled:r||!u.trim(),"data-testid":`calendar-event-save`,className:`rounded-xl bg-gray-950 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-gray-800 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-white dark:text-gray-950 dark:hover:bg-gray-100`,children:c(r?`common.saving`:`common.save`)})]})]})]})]})}),document.body)}var G=a(`pages:calendar`),K=()=>{let{t:e,i18n:t}=o(),n=i(),[r,a]=(0,M.useState)(`month`),[h,S]=(0,M.useState)(()=>new Date),[C,w]=(0,M.useState)([]),[T,E]=(0,M.useState)([]),[O,k]=(0,M.useState)(!1),[j,P]=(0,M.useState)(null),[F,I]=(0,M.useState)(()=>Date.now()),[R,z]=(0,M.useState)(!1),[B,V]=(0,M.useState)([]),[H,U]=(0,M.useState)(``),[W,K]=(0,M.useState)(null),q=M.useRef(null),J=(0,M.useMemo)(()=>{if(r===`month`){let e=new Date(h.getFullYear(),h.getMonth(),1),t=D(e);return{from:t.getTime(),to:A(t,42).getTime()}}if(r===`day`){let e=new Date(h.getFullYear(),h.getMonth(),h.getDate());return{from:e.getTime(),to:A(e,1).getTime()}}let e=D(h);return{from:e.getTime(),to:A(e,7).getTime()}},[h,r]),[Y,ne]=(0,M.useState)(0),X=(0,M.useCallback)(()=>ne(e=>e+1),[]);(0,M.useEffect)(()=>{_.getCalendars().then(e=>{e.success&&e.data&&V(e.data)}).catch(e=>G.error(`Failed to load calendars:`,e))},[Y]),(0,M.useEffect)(()=>{let t=!1;return _.getEvents(J.from,J.to).then(e=>{t||e.success&&e.data&&w(e.data)}).catch(n=>{t||(G.error(`Failed to load calendar events:`,n),g.error(e(`calendar.loadFailed`)))}),Promise.all([v.getOccurrences(J.from,J.to),v.getRuns({from:J.from,to:J.to}),v.getAutomations()]).then(([n,r,i])=>{if(t)return;let a=Date.now(),o=t=>i.data?.find(e=>e.id===t)?.name??e(`automations.deletedAutomation`),s=[];for(let e of n.data??[])e.at<=a||s.push({id:`automation:${e.automationId}:${e.at}`,title:e.name,startAt:e.at,allDay:!1,createdAt:e.at,updatedAt:e.at,variant:`automation`});for(let e of r.data??[])(e.status===`succeeded`||e.status===`failed`)&&s.push({id:`run:${e.id}`,title:o(e.automationId),startAt:e.scheduledFor,allDay:!1,createdAt:e.createdAt,updatedAt:e.createdAt,variant:e.status===`succeeded`?`runSucceeded`:`runFailed`,...e.sessionId?{sessionId:e.sessionId}:{}});E(s)}).catch(e=>{t||G.error(`Failed to project automations onto the calendar:`,e)}),()=>{t=!0}},[J.from,J.to,Y,e]);let Z=(0,M.useMemo)(()=>[...C,...T].sort((e,t)=>e.startAt-t.startAt),[C,T]),Q=e=>{S(t=>r===`month`?new Date(t.getFullYear(),t.getMonth()+e,1):A(t,e*(r===`day`?1:7)))},$=(e,t=9)=>{P(null),I(new Date(e.getFullYear(),e.getMonth(),e.getDate(),t,0).getTime()),k(!0)},re=t=>{if(t.variant===`runSucceeded`||t.variant===`runFailed`){t.sessionId?n(`/c/${t.sessionId}`):n(`/automations`);return}if(t.variant===`automation`){n(`/automations`);return}if(t.shared&&t.shared.permission!==`write`){g(e(`calendar.sharedReadOnly`));return}if(t.baseEventId){let e=C.find(e=>e.id===t.baseEventId);P(e??t)}else P(t);k(!0)},ie=async t=>{z(!0);try{let n=j?await _.updateEvent(j.id,t):await _.createEvent(t);n.success?(k(!1),X()):g.error(n.error||e(`calendar.saveFailed`))}catch(t){G.error(`Failed to save calendar event:`,t),g.error(e(`calendar.saveFailed`))}finally{z(!1)}},ae=async()=>{if(j){z(!0);try{let t=await _.deleteEvent(j.id);t.success?(k(!1),X()):g.error(t.error||e(`calendar.deleteFailed`))}catch(t){G.error(`Failed to delete calendar event:`,t),g.error(e(`calendar.deleteFailed`))}finally{z(!1)}}},oe=r===`month`?x(h.getFullYear(),h.getMonth(),t.language):new Intl.DateTimeFormat(t.language,{month:`long`,day:`numeric`,year:`numeric`}).format(r===`day`?h:D(h)),se=async()=>{let t=H.trim();t&&((await _.createCalendar({name:t}).catch(()=>void 0))?.success?(U(``),X()):g.error(e(`calendar.calendarSaveFailed`)))},ce=async t=>{try{let e=await _.exportIcs(t),n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=`calendar.ics`,r.click(),URL.revokeObjectURL(n)}catch(t){G.error(`Failed to export the calendar:`,t),g.error(e(`calendar.exportFailed`))}},le=async t=>{try{let n=await t.text(),r=await _.importIcs(n);r.success&&r.data?(g.success(e(`calendar.importResult`,{total:r.data.imported})),X()):g.error(r.error||e(`calendar.importFailed`))}catch(t){G.error(`Failed to import the calendar:`,t),g.error(e(`calendar.importFailed`))}};return(0,N.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,"data-testid":`calendar-page`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-b border-black/[0.06] px-4 py-3 dark:border-white/[0.07]`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`h1`,{className:`text-sm font-semibold text-gray-900 dark:text-dark-900`,children:e(`calendar.title`)}),(0,N.jsx)(`span`,{className:`text-sm text-gray-500 dark:text-dark-500`,"data-testid":`calendar-range-label`,children:oe})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`div`,{className:`flex items-center rounded-xl bg-black/[0.04] p-0.5 dark:bg-white/[0.06]`,children:[`month`,`week`,`day`].map(t=>(0,N.jsx)(`button`,{onClick:()=>a(t),"data-testid":`calendar-view-${t}`,className:s(`rounded-[10px] px-2.5 py-1 text-[12px] font-medium transition-colors`,r===t?`bg-white text-gray-900 shadow-sm dark:bg-dark-200 dark:text-dark-900`:`text-gray-500 hover:text-gray-800 dark:text-dark-500 dark:hover:text-dark-800`),children:e(`calendar.${t}`)},t))}),(0,N.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,N.jsx)(y,{size:`sm`,variant:`ghost`,onClick:()=>Q(-1),className:`h-7 w-7 p-0`,title:e(`calendar.previous`),children:(0,N.jsx)(l,{className:`h-4 w-4`})}),(0,N.jsx)(y,{size:`sm`,variant:`ghost`,onClick:()=>S(new Date),className:`h-7 px-2 text-[12px]`,children:e(`calendar.today`)}),(0,N.jsx)(y,{size:`sm`,variant:`ghost`,onClick:()=>Q(1),className:`h-7 w-7 p-0`,title:e(`calendar.next`),children:(0,N.jsx)(f,{className:`h-4 w-4`})})]}),(0,N.jsxs)(y,{size:`sm`,onClick:()=>$(h),"data-testid":`calendar-new-event`,className:`h-7 gap-1 px-2.5 text-[12px]`,children:[(0,N.jsx)(u,{className:`h-3.5 w-3.5`}),e(`calendar.newEvent`)]})]})]}),(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 border-b border-black/[0.06] px-4 py-2 dark:border-white/[0.07]`,children:[B.map(t=>(0,N.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full border border-black/[0.08] px-2.5 py-1 text-xs text-gray-700 dark:border-white/[0.1] dark:text-dark-800`,"data-testid":`calendar-chip`,children:[(0,N.jsx)(`span`,{className:`h-2 w-2 rounded-full`,style:{backgroundColor:t.color??`#8b8b8b`}}),t.name,t.shared?(0,N.jsx)(`span`,{className:`text-[10px] uppercase text-gray-400 dark:text-dark-500`,children:e(`calendar.sharedBadge`)}):(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`button`,{onClick:()=>K(t),className:`text-gray-400 hover:text-primary-500 dark:text-dark-500`,title:e(`calendar.shareCalendar`),"data-testid":`calendar-share`,children:(0,N.jsx)(d,{className:`h-3 w-3`})}),(0,N.jsx)(`button`,{onClick:()=>void _.deleteCalendar(t.id).then(X),className:`text-gray-400 hover:text-red-500 dark:text-dark-500`,title:e(`common.delete`),children:(0,N.jsx)(p,{className:`h-3 w-3`})})]})]},t.id)),(0,N.jsx)(`input`,{type:`text`,value:H,onChange:e=>U(e.target.value),onKeyDown:e=>{e.key===`Enter`&&se()},placeholder:e(`calendar.newCalendarPlaceholder`),className:`w-36 rounded-full border border-dashed border-black/[0.12] bg-transparent px-2.5 py-1 text-xs text-gray-700 placeholder:text-gray-400 focus:outline-none dark:border-white/[0.16] dark:text-dark-800`,"data-testid":`calendar-new-calendar`}),(0,N.jsxs)(`div`,{className:`ms-auto flex items-center gap-1`,children:[(0,N.jsx)(`input`,{ref:q,type:`file`,accept:`.ics,text/calendar`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&le(t),e.target.value=``}}),(0,N.jsxs)(y,{size:`sm`,variant:`ghost`,onClick:()=>q.current?.click(),className:`h-7 gap-1 px-2 text-[12px]`,"data-testid":`calendar-import`,children:[(0,N.jsx)(m,{className:`h-3.5 w-3.5`}),e(`calendar.importIcs`)]}),(0,N.jsxs)(y,{size:`sm`,variant:`ghost`,onClick:()=>void ce(),className:`h-7 gap-1 px-2 text-[12px]`,"data-testid":`calendar-export`,children:[(0,N.jsx)(c,{className:`h-3.5 w-3.5`}),e(`calendar.exportIcs`)]})]})]}),r===`month`?(0,N.jsx)(L,{year:h.getFullYear(),monthIndex:h.getMonth(),events:Z,onDayClick:e=>$(e),onEventClick:re}):(0,N.jsx)(ee,{anchor:h,events:Z,dayCount:r===`day`?1:7,onDayClick:(e,t)=>$(e,t),onEventClick:re}),W&&(0,N.jsx)(b,{resourceType:`calendar`,resourceId:W.id,resourceLabel:W.name,onClose:()=>K(null)}),(0,N.jsx)(te,{open:O,event:j,initialStartAt:F,calendars:B.filter(e=>!e.shared||e.shared.permission===`write`),saving:R,onClose:()=>k(!1),onSave:e=>void ie(e),onDelete:()=>void ae()})]})};export{K as default};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-vendor-D0Ec-185.js";import{i as r}from"./router-vendor-CMbYTGdh.js";import{t as i}from"./logger-DnuT4jgB.js";import{t as a}from"./useTranslation-D0mJ4NnO.js";import{r as o,t as s}from"./utils-Bn0RE9_8.js";import{t as c}from"./chatStore-DW0LsT5X.js";import{B as l,Et as u,Gt as d,H as f,Nt as p,On as m,Q as h,Tt as g,_n as ee,fr as _,ir as te,it as ne,jt as v,n as y,nt as b,qn as re,s as x,st as S,v as ie,yr as C}from"./ui-vendor-DvJV-69N.js";import{D as w}from"./api-T6SWjL0K.js";import{t as ae}from"./authStore-Bl7S8bPg.js";import{t as T}from"./Button-BQ5JnUVj.js";import{i as E,n as D,r as O}from"./ui-BZOjqAJH.js";import{t as oe}from"./teamEventStream-BBNlg5Wd.js";var k=e(t(),1),A=n(),se=[`👍`,`🎉`,`❤️`,`😄`,`👀`,`🚀`],ce=({message:e,currentUserId:t,canModerate:n,actions:r,compact:i=!1})=>{let{t:c,i18n:l}=a(),[u,d]=(0,k.useState)(!1),[f,m]=(0,k.useState)(e.content),[h,_]=(0,k.useState)(!1),v=e.authorKind===`model`,x=!v&&e.author?.userId===t&&!e.deleted,C=v?e.model??c(`channels.modelAuthor`):e.author?.username??c(`channels.unknownAuthor`);return(0,A.jsxs)(`div`,{className:s(`group relative rounded-xl px-2.5 py-1.5 hover:bg-black/[0.025] dark:hover:bg-white/[0.03]`,i&&`px-2 py-1`),"data-testid":`channel-message`,children:[(0,A.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[v&&(0,A.jsx)(te,{className:`h-3.5 w-3.5 shrink-0 self-center text-primary-500`}),(0,A.jsx)(`span`,{className:s(`shrink-0 text-[13px] font-semibold`,v?`text-primary-600 dark:text-primary-400`:`text-gray-900 dark:text-dark-900`),children:C}),(0,A.jsx)(`span`,{className:`shrink-0 text-[11px] text-gray-400 dark:text-dark-500`,children:o(e.createdAt,l.language)}),e.editedAt&&!e.deleted&&(0,A.jsx)(`span`,{className:`shrink-0 text-[10px] text-gray-400 dark:text-dark-500`,children:c(`channels.edited`)}),e.pinnedAt&&(0,A.jsx)(b,{className:`h-3 w-3 shrink-0 text-amber-500`})]}),e.deleted?(0,A.jsx)(`p`,{className:`text-[13px] italic text-gray-400 dark:text-dark-500`,children:c(`channels.deletedMessage`)}):u?(0,A.jsxs)(`div`,{className:`mt-1 flex items-end gap-1.5`,children:[(0,A.jsx)(`textarea`,{value:f,onChange:e=>m(e.target.value),rows:2,className:`min-w-0 flex-1 resize-none rounded-lg border border-black/[0.08] bg-transparent px-2 py-1 text-[13px] focus:outline-none dark:border-white/[0.1] dark:text-dark-900`,"data-testid":`channel-message-edit`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>{r.onEdit(e,f),d(!1)},className:`rounded-md p-1.5 text-emerald-600 hover:bg-emerald-50 dark:hover:bg-emerald-900/20`,children:(0,A.jsx)(re,{className:`h-3.5 w-3.5`})}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>d(!1),className:`rounded-md p-1.5 text-gray-400 hover:bg-black/[0.04] dark:hover:bg-white/[0.06]`,children:(0,A.jsx)(y,{className:`h-3.5 w-3.5`})})]}):(0,A.jsxs)(A.Fragment,{children:[e.pending?(0,A.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[13px] text-gray-400 dark:text-dark-500`,children:[(0,A.jsx)(p,{className:`h-3.5 w-3.5 animate-spin`}),c(`channels.modelThinking`)]}):e.error?(0,A.jsx)(`p`,{className:`text-[13px] text-red-500`,children:e.error}):(0,A.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-[13px] leading-relaxed text-gray-800 dark:text-dark-800`,children:e.content}),(e.attachments?.length??0)>0&&(0,A.jsx)(`div`,{className:`mt-1 space-y-1`,children:e.attachments.map(e=>(0,A.jsxs)(`button`,{type:`button`,onClick:()=>void r.onDownload(e.id,e.filename),className:`flex items-center gap-1.5 rounded-lg border border-black/[0.06] px-2 py-1 text-[12px] text-gray-600 hover:bg-black/[0.03] dark:border-white/[0.08] dark:text-dark-700 dark:hover:bg-white/[0.04]`,"data-testid":`channel-attachment`,children:[(0,A.jsx)(S,{className:`h-3 w-3`}),(0,A.jsx)(`span`,{className:`min-w-0 truncate`,children:e.filename})]},e.id))})]}),(e.reactions?.length??0)>0&&(0,A.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:e.reactions.map(t=>(0,A.jsxs)(`button`,{type:`button`,onClick:()=>void r.onReact(e,t.emoji,t.mine),className:s(`rounded-full border px-1.5 py-0.5 text-[11px]`,t.mine?`border-primary-400/50 bg-primary-500/10 text-primary-600 dark:text-primary-400`:`border-black/[0.08] text-gray-600 hover:bg-black/[0.03] dark:border-white/[0.1] dark:text-dark-700`),"data-testid":`channel-reaction`,children:[t.emoji,` `,t.count]},t.emoji))}),!i&&(e.replyCount??0)>0&&r.onReply&&(0,A.jsxs)(`button`,{type:`button`,onClick:()=>r.onReply(e),className:`mt-1 flex items-center gap-1 text-[11px] font-medium text-primary-600 hover:underline dark:text-primary-400`,"data-testid":`channel-reply-count`,children:[(0,A.jsx)(g,{className:`h-3 w-3`}),c(`channels.replyCount`,{total:e.replyCount})]}),!e.deleted&&!u&&(0,A.jsxs)(`div`,{className:`absolute -top-2.5 right-2 hidden items-center gap-0.5 rounded-lg border border-black/[0.08] bg-white px-1 py-0.5 shadow-sm group-hover:flex dark:border-white/[0.1] dark:bg-dark-50`,children:[(0,A.jsxs)(`div`,{className:`relative`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>_(e=>!e),className:`rounded p-1 text-gray-400 hover:text-gray-700 dark:hover:text-dark-800`,title:c(`channels.react`),"data-testid":`channel-react`,children:(0,A.jsx)(ee,{className:`h-3.5 w-3.5`})}),h&&(0,A.jsx)(`div`,{className:`absolute right-0 top-6 z-10 flex gap-0.5 rounded-lg border border-black/[0.08] bg-white p-1 shadow-md dark:border-white/[0.1] dark:bg-dark-50`,children:se.map(t=>(0,A.jsx)(`button`,{type:`button`,onClick:()=>{let n=!!e.reactions?.find(e=>e.emoji===t)?.mine;r.onReact(e,t,n),_(!1)},className:`rounded p-0.5 text-sm hover:bg-black/[0.05] dark:hover:bg-white/[0.08]`,children:t},t))})]}),r.onReply&&!e.parentId&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>r.onReply(e),className:`rounded p-1 text-gray-400 hover:text-gray-700 dark:hover:text-dark-800`,title:c(`channels.reply`),"data-testid":`channel-reply`,children:(0,A.jsx)(g,{className:`h-3.5 w-3.5`})}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>void r.onPin(e),className:`rounded p-1 text-gray-400 hover:text-amber-500`,title:e.pinnedAt?c(`channels.unpin`):c(`channels.pin`),"data-testid":`channel-pin`,children:(0,A.jsx)(b,{className:`h-3.5 w-3.5`})}),x&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>{m(e.content),d(!0)},className:`rounded p-1 text-gray-400 hover:text-gray-700 dark:hover:text-dark-800`,title:c(`channels.edit`),"data-testid":`channel-edit`,children:(0,A.jsx)(ne,{className:`h-3.5 w-3.5`})}),(x||n)&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>void r.onDelete(e),className:`rounded p-1 text-gray-400 hover:text-red-500`,title:c(`channels.deleteMessage`),"data-testid":`channel-delete-message`,children:(0,A.jsx)(ie,{className:`h-3.5 w-3.5`})})]})]})},j=i(`pages:channels`),le=e=>e.type===`dm`?(0,A.jsx)(u,{className:`h-3.5 w-3.5 shrink-0`}):e.type===`private`?(0,A.jsx)(v,{className:`h-3.5 w-3.5 shrink-0`}):(0,A.jsx)(d,{className:`h-3.5 w-3.5 shrink-0`}),ue=e=>e.type===`dm`?e.dmPeer?.username??`…`:e.name,de=()=>{let{t:e}=a(),t=ae(e=>e.user),n=c(e=>e.models),[i,o]=(0,k.useState)([]),[d,ee]=(0,k.useState)(null),[ne,v]=(0,k.useState)(!1),[re,ie]=(0,k.useState)(!0),[E,D]=(0,k.useState)(null),[O,se]=(0,k.useState)(null),[de,M]=(0,k.useState)([]),[ge,_e]=(0,k.useState)([]),[N,P]=(0,k.useState)(null),[F,I]=(0,k.useState)(null),[ve,L]=(0,k.useState)([]),[R,ye]=(0,k.useState)(``),[z,be]=(0,k.useState)(``),[B,xe]=(0,k.useState)(!1),[V,H]=(0,k.useState)(null),[Se,U]=(0,k.useState)(!1),[Ce,W]=(0,k.useState)(!1),[G,we]=(0,k.useState)(``),[Te,K]=(0,k.useState)(!1),Ee=(0,k.useRef)(null),De=(0,k.useRef)(null),[Oe,ke]=r(),q=(0,k.useMemo)(()=>i.find(e=>e.id===E)??null,[i,E]),[Ae,je]=(0,k.useState)(null);E!==Ae&&(je(E),se(null),I(null),P(null));let J=q?.role===`owner`,Y=(0,k.useCallback)(()=>{w.listMine().then(e=>{e.success&&e.data&&o(e.data)}).catch(e=>j.error(`Failed to load channels:`,e)).finally(()=>ie(!1))},[]);(0,k.useEffect)(()=>{Y();let e=window.setInterval(Y,3e4);return()=>window.clearInterval(e)},[Y]);let X=Oe.get(`channel`);X&&E!==X&&D(X),(0,k.useEffect)(()=>{X&&ke({},{replace:!0})},[X,ke]);let Z=(0,k.useCallback)(e=>{w.listMessages(e,{limit:100}).then(e=>{e.success&&e.data&&se(e.data)}).catch(e=>j.error(`Failed to load messages:`,e))},[]),Me=(0,k.useRef)(null);(0,k.useEffect)(()=>{Me.current=F},[F]);let Ne=(0,k.useCallback)(e=>{Z(e),w.markRead(e);let t=Me.current;t&&w.thread(t).then(e=>{e.success&&e.data&&L(e.data)})},[Z]);(0,k.useEffect)(()=>{if(!E)return;Z(E),w.markRead(E).then(Y);let e=new AbortController;return oe({path:`/channels/${E}/events`,signal:e.signal,onEvent:()=>Ne(E)}),()=>e.abort()},[E,Z,Y,Ne]);let Pe=O?.length??0;(0,k.useEffect)(()=>{let e=De.current;e&&(e.scrollTop=e.scrollHeight)},[Pe,E]),(0,k.useEffect)(()=>{!E||!N||(N===`members`?w.listMembers(E).then(e=>{e.success&&e.data&&M(e.data)}):w.listPins(E).then(e=>{e.success&&e.data&&_e(e.data)}))},[E,N]),(0,k.useEffect)(()=>{F&&w.thread(F).then(e=>{e.success&&e.data&&L(e.data)})},[F]);let Fe=()=>{v(!0),w.listPublic().then(e=>{e.success&&e.data&&ee(e.data)})},Q=async t=>{if(!E||B)return;let n=R.trim();if(!(!n&&!V)){xe(!0);try{let r=await w.postMessage(E,{content:n,...t?{parentId:t}:{},...V?{attachmentIds:[V.id]}:{},...z?{mentionModel:z}:{}});if(r.success){if(ye(``),H(null),be(``),Z(E),t){let e=await w.thread(t);e.success&&e.data&&L(e.data)}}else C.error(r.error||e(`channels.sendFailed`))}catch(t){j.error(`Failed to send message:`,t),C.error(e(`channels.sendFailed`))}finally{xe(!1)}}},Ie=async t=>{if(E)try{let n=await w.uploadAttachment(E,t);n.success&&n.data?H({id:n.data.id,filename:n.data.filename}):C.error(n.error||e(`channels.uploadFailed`))}catch(t){j.error(`Failed to upload attachment:`,t),C.error(e(`channels.uploadFailed`))}},Le=async()=>{if(!(!E||!G.trim())){if((await w.addMember(E,G.trim()).catch(()=>void 0))?.success){we(``);let t=await w.listMembers(E);t.success&&t.data&&M(t.data),C.success(e(`channels.memberAdded`))}else C.error(e(`channels.memberAddFailed`))}},Re={onReply:e=>I(e.id),onEdit:async(e,t)=>{(await w.editMessage(e.id,t).catch(()=>void 0))?.success&&E&&Z(E)},onDelete:async e=>{(await w.deleteMessage(e.id).catch(()=>void 0))?.success&&E&&Z(E)},onPin:async e=>{await w.setPinned(e.id,!e.pinnedAt).catch(()=>void 0),E&&Z(E)},onReact:async(e,t,n)=>{n?await w.removeReaction(e.id,t).catch(()=>void 0):await w.addReaction(e.id,t).catch(()=>void 0),E&&Z(E)},onDownload:async(e,t)=>{try{let n=await w.downloadAttachment(e),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=t,i.click(),URL.revokeObjectURL(r)}catch(e){j.error(`Failed to download attachment:`,e)}}},$=ve[0];return(0,A.jsxs)(`div`,{className:`flex h-full min-h-0`,children:[(0,A.jsxs)(`aside`,{className:s(`flex w-64 shrink-0 flex-col border-r border-black/[0.06] dark:border-white/[0.06]`,E?`hidden md:flex`:`flex`),"data-testid":`channel-rail`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-1 px-3 py-2.5`,children:[(0,A.jsx)(`h1`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-gray-900 dark:text-dark-900`,children:e(`channels.title`)}),(0,A.jsx)(`button`,{type:`button`,onClick:Fe,title:e(`channels.browsePublic`),className:`rounded-md p-1.5 text-gray-500 hover:bg-black/[0.04] dark:text-dark-600 dark:hover:bg-white/[0.06]`,"data-testid":`channels-browse`,children:(0,A.jsx)(m,{className:`h-4 w-4`})}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>W(!0),title:e(`channels.newDm`),className:`rounded-md p-1.5 text-gray-500 hover:bg-black/[0.04] dark:text-dark-600 dark:hover:bg-white/[0.06]`,"data-testid":`channels-new-dm`,children:(0,A.jsx)(u,{className:`h-4 w-4`})}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>U(!0),title:e(`channels.newChannel`),className:`rounded-md p-1.5 text-gray-500 hover:bg-black/[0.04] dark:text-dark-600 dark:hover:bg-white/[0.06]`,"data-testid":`channels-new`,children:(0,A.jsx)(h,{className:`h-4 w-4`})})]}),(0,A.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-2 pb-3 scrollbar-thin`,children:re?(0,A.jsx)(p,{className:`mx-auto mt-6 h-4 w-4 animate-spin text-gray-400`}):i.length===0?(0,A.jsx)(`p`,{className:`px-2 pt-6 text-center text-xs text-gray-400 dark:text-dark-500`,children:e(`channels.empty`)}):i.map(e=>(0,A.jsxs)(`button`,{type:`button`,onClick:()=>D(e.id),className:s(`flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left text-[13px]`,E===e.id?`bg-black/[0.05] text-gray-900 dark:bg-white/[0.08] dark:text-dark-900`:`text-gray-600 hover:bg-black/[0.03] dark:text-dark-700 dark:hover:bg-white/[0.04]`),"data-testid":`channel-item`,children:[le(e),(0,A.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:ue(e)}),(e.unreadCount??0)>0&&(0,A.jsx)(`span`,{className:`rounded-full bg-primary-500 px-1.5 text-[10px] font-semibold leading-4 text-white`,"data-testid":`channel-unread`,children:e.unreadCount})]},e.id))})]}),(0,A.jsx)(`main`,{className:`flex min-w-0 flex-1 flex-col`,children:q?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-black/[0.06] px-4 py-2.5 dark:border-white/[0.06]`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>D(null),className:`rounded-md p-1 text-gray-500 hover:bg-black/[0.04] md:hidden dark:text-dark-600`,children:(0,A.jsx)(_,{className:`h-4 w-4`})}),le(q),(0,A.jsx)(`h2`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-gray-900 dark:text-dark-900`,"data-testid":`channel-title`,children:ue(q)}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>P(N===`pins`?null:`pins`),title:e(`channels.pins`),className:`rounded-md p-1.5 text-gray-500 hover:bg-black/[0.04] dark:text-dark-600 dark:hover:bg-white/[0.06]`,"data-testid":`channel-pins-toggle`,children:(0,A.jsx)(b,{className:`h-4 w-4`})}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>P(N===`members`?null:`members`),title:e(`channels.members`),className:`rounded-md p-1.5 text-gray-500 hover:bg-black/[0.04] dark:text-dark-600 dark:hover:bg-white/[0.06]`,"data-testid":`channel-members-toggle`,children:(0,A.jsx)(x,{className:`h-4 w-4`})}),J&&q.type!==`dm`&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>K(!0),title:e(`channels.settings`),className:`rounded-md p-1.5 text-gray-500 hover:bg-black/[0.04] dark:text-dark-600 dark:hover:bg-white/[0.06]`,"data-testid":`channel-settings`,children:(0,A.jsx)(l,{className:`h-4 w-4`})})]}),(0,A.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,A.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,A.jsx)(`div`,{ref:De,className:`min-h-0 flex-1 space-y-1 overflow-y-auto px-4 py-3 scrollbar-thin`,"data-testid":`channel-timeline`,children:O===null?(0,A.jsx)(p,{className:`mx-auto mt-6 h-4 w-4 animate-spin text-gray-400`}):O.length===0?(0,A.jsx)(`p`,{className:`pt-8 text-center text-xs text-gray-400 dark:text-dark-500`,children:e(`channels.noMessages`)}):O.map(e=>(0,A.jsx)(ce,{message:e,currentUserId:t?.id,canModerate:J,actions:Re},e.id))}),(0,A.jsxs)(`div`,{className:`border-t border-black/[0.06] p-3 dark:border-white/[0.06]`,children:[V&&(0,A.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 rounded-lg border border-black/[0.06] px-2.5 py-1.5 text-xs text-gray-600 dark:border-white/[0.08] dark:text-dark-700`,children:[(0,A.jsx)(S,{className:`h-3.5 w-3.5`}),(0,A.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:V.filename}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>H(null),className:`text-gray-400 hover:text-red-500`,children:(0,A.jsx)(y,{className:`h-3.5 w-3.5`})})]}),(0,A.jsxs)(`div`,{className:`flex items-end gap-1.5`,children:[(0,A.jsx)(`input`,{ref:Ee,type:`file`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&Ie(t),e.target.value=``}}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>Ee.current?.click(),title:e(`channels.attach`),className:`rounded-md p-2 text-gray-500 hover:bg-black/[0.04] dark:text-dark-600 dark:hover:bg-white/[0.06]`,"data-testid":`channel-attach`,children:(0,A.jsx)(S,{className:`h-4 w-4`})}),(0,A.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,A.jsx)(te,{className:s(`h-4 w-4`,z?`text-primary-500`:`text-gray-400 dark:text-dark-500`)}),(0,A.jsxs)(`select`,{value:z,onChange:e=>be(e.target.value),className:`max-w-[130px] rounded-md border border-black/[0.08] bg-transparent px-1 py-1 text-[11px] text-gray-600 focus:outline-none dark:border-white/[0.1] dark:bg-dark-100 dark:text-dark-700`,title:e(`channels.askModel`),"data-testid":`channel-mention-model`,children:[(0,A.jsx)(`option`,{value:``,children:e(`channels.noModel`)}),n.map(e=>(0,A.jsx)(`option`,{value:e.name,children:e.name},e.name))]})]}),(0,A.jsx)(`textarea`,{value:R,onChange:e=>ye(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),Q())},rows:1,placeholder:e(`channels.composerPlaceholder`),className:`max-h-32 min-w-0 flex-1 resize-none rounded-xl border border-black/[0.08] bg-transparent px-3 py-2 text-[13px] text-gray-900 placeholder:text-gray-400 focus:border-primary-500/40 focus:outline-none dark:border-white/[0.1] dark:text-dark-900`,"data-testid":`channel-composer`}),(0,A.jsx)(T,{size:`sm`,disabled:B||!R.trim()&&!V,onClick:()=>void Q(),"data-testid":`channel-send`,children:B?(0,A.jsx)(p,{className:`h-4 w-4 animate-spin`}):(0,A.jsx)(f,{className:`h-4 w-4`})})]})]})]}),F&&(0,A.jsxs)(`aside`,{className:`flex w-80 shrink-0 flex-col border-l border-black/[0.06] dark:border-white/[0.06]`,"data-testid":`channel-thread`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-black/[0.06] px-3 py-2 dark:border-white/[0.06]`,children:[(0,A.jsx)(`span`,{className:`flex-1 text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-dark-600`,children:e(`channels.thread`)}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>I(null),className:`rounded-md p-1 text-gray-400 hover:bg-black/[0.04] dark:hover:bg-white/[0.06]`,children:(0,A.jsx)(y,{className:`h-3.5 w-3.5`})})]}),(0,A.jsx)(`div`,{className:`min-h-0 flex-1 space-y-1 overflow-y-auto px-3 py-2 scrollbar-thin`,children:ve.map(e=>(0,A.jsx)(ce,{message:e,currentUserId:t?.id,canModerate:J,actions:{...Re,onReply:void 0},compact:!0},e.id))}),(0,A.jsxs)(`div`,{className:`flex items-end gap-1.5 border-t border-black/[0.06] p-2 dark:border-white/[0.06]`,children:[(0,A.jsx)(`textarea`,{value:R,onChange:e=>ye(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),$&&Q($.id))},rows:1,placeholder:e(`channels.replyPlaceholder`),className:`min-w-0 flex-1 resize-none rounded-lg border border-black/[0.08] bg-transparent px-2.5 py-1.5 text-[13px] text-gray-900 focus:outline-none dark:border-white/[0.1] dark:text-dark-900`,"data-testid":`channel-thread-composer`}),(0,A.jsx)(T,{size:`sm`,disabled:B||!R.trim(),onClick:()=>$&&void Q($.id),children:(0,A.jsx)(f,{className:`h-3.5 w-3.5`})})]})]}),N&&(0,A.jsxs)(`aside`,{className:`flex w-72 shrink-0 flex-col border-l border-black/[0.06] dark:border-white/[0.06]`,"data-testid":`channel-${N}-panel`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-black/[0.06] px-3 py-2 dark:border-white/[0.06]`,children:[(0,A.jsx)(`span`,{className:`flex-1 text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-dark-600`,children:e(N===`members`?`channels.members`:`channels.pins`)}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>P(null),className:`rounded-md p-1 text-gray-400 hover:bg-black/[0.04] dark:hover:bg-white/[0.06]`,children:(0,A.jsx)(y,{className:`h-3.5 w-3.5`})})]}),(0,A.jsx)(`div`,{className:`min-h-0 flex-1 space-y-1.5 overflow-y-auto px-3 py-2 scrollbar-thin`,children:N===`members`?(0,A.jsxs)(A.Fragment,{children:[J&&q.type===`private`&&(0,A.jsxs)(`div`,{className:`mb-2 flex gap-1.5`,children:[(0,A.jsx)(`input`,{type:`text`,value:G,onChange:e=>we(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Le()},placeholder:e(`channels.invitePlaceholder`),className:`min-w-0 flex-1 rounded-lg border border-black/[0.08] bg-transparent px-2 py-1 text-xs focus:outline-none dark:border-white/[0.1] dark:text-dark-800`,"data-testid":`channel-invite-name`}),(0,A.jsx)(T,{size:`sm`,disabled:!G.trim(),onClick:()=>void Le(),"data-testid":`channel-invite-submit`,children:(0,A.jsx)(h,{className:`h-3.5 w-3.5`})})]}),de.map(n=>(0,A.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg px-2 py-1.5 text-[13px] text-gray-700 dark:text-dark-800`,"data-testid":`channel-member`,children:[(0,A.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n.username}),(0,A.jsx)(`span`,{className:`text-[10px] uppercase text-gray-400 dark:text-dark-500`,children:n.role===`owner`?e(`channels.roleOwner`):``}),J&&n.userId!==t?.id&&q.type!==`dm`&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>void w.removeMember(q.id,n.userId).then(()=>M(e=>e.filter(e=>e.userId!==n.userId))),className:`rounded p-0.5 text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,title:e(`channels.removeMember`),children:(0,A.jsx)(y,{className:`h-3 w-3`})})]},n.userId)),!J&&q.type!==`dm`&&(0,A.jsx)(T,{size:`sm`,variant:`ghost`,className:`mt-2 w-full text-red-500`,onClick:()=>void w.removeMember(q.id,t?.id??``).then(()=>{D(null),Y()}),"data-testid":`channel-leave`,children:e(`channels.leave`)})]}):ge.length===0?(0,A.jsx)(`p`,{className:`pt-4 text-center text-xs text-gray-400 dark:text-dark-500`,children:e(`channels.noPins`)}):ge.map(e=>(0,A.jsx)(ce,{message:e,currentUserId:t?.id,canModerate:J,actions:Re,compact:!0},e.id))})]})]})]}):(0,A.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-2 text-gray-400 dark:text-dark-500`,children:[(0,A.jsx)(g,{className:`h-8 w-8`}),(0,A.jsx)(`p`,{className:`text-sm`,children:e(`channels.selectPrompt`)})]})}),Se&&(0,A.jsx)(fe,{onClose:()=>U(!1),onCreated:e=>{U(!1),Y(),D(e.id)}}),Ce&&(0,A.jsx)(pe,{onClose:()=>W(!1),onOpened:e=>{W(!1),Y(),D(e.id)}}),ne&&(0,A.jsx)(me,{channels:d,onClose:()=>v(!1),onJoined:e=>{v(!1),Y(),D(e)}}),Te&&q&&(0,A.jsx)(he,{channel:q,onClose:()=>K(!1),onChanged:()=>{K(!1),Y()},onDeleted:()=>{K(!1),D(null),Y()}})]})},fe=({onClose:e,onCreated:t})=>{let{t:n}=a(),[r,i]=(0,k.useState)(``),[o,s]=(0,k.useState)(`public`),[c,l]=(0,k.useState)(``),[u,d]=(0,k.useState)(!1);return(0,A.jsxs)(D,{titleId:`create-channel-title`,title:n(`channels.newChannel`),onClose:e,testId:`create-channel-modal`,footer:(0,A.jsx)(T,{size:`sm`,disabled:u||!r.trim(),onClick:()=>{d(!0),w.create({type:o,name:r.trim(),...c.trim()?{description:c.trim()}:{}}).then(e=>{e.success&&e.data?t(e.data):C.error(e.error||n(`channels.createFailed`))}).catch(()=>C.error(n(`channels.createFailed`))).finally(()=>d(!1))},"data-testid":`create-channel-submit`,children:n(`channels.create`)}),children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:E,children:n(`channels.nameLabel`)}),(0,A.jsx)(`input`,{className:O,value:r,onChange:e=>i(e.target.value),"data-testid":`create-channel-name`})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:E,children:n(`channels.typeLabel`)}),(0,A.jsxs)(`select`,{className:O,value:o,onChange:e=>s(e.target.value),"data-testid":`create-channel-type`,children:[(0,A.jsx)(`option`,{value:`public`,children:n(`channels.typePublic`)}),(0,A.jsx)(`option`,{value:`private`,children:n(`channels.typePrivate`)})]})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:E,children:n(`channels.descriptionLabel`)}),(0,A.jsx)(`textarea`,{className:O,rows:2,value:c,onChange:e=>l(e.target.value)})]})]})},pe=({onClose:e,onOpened:t})=>{let{t:n}=a(),[r,i]=(0,k.useState)(``),[o,s]=(0,k.useState)(!1),c=()=>{r.trim()&&(s(!0),w.openDm(r.trim()).then(e=>{e.success&&e.data?t(e.data):C.error(e.error||n(`channels.dmFailed`))}).catch(()=>C.error(n(`channels.dmFailed`))).finally(()=>s(!1)))};return(0,A.jsx)(D,{titleId:`open-dm-title`,title:n(`channels.newDm`),subtitle:n(`channels.dmHint`),onClose:e,testId:`open-dm-modal`,footer:(0,A.jsx)(T,{size:`sm`,disabled:o||!r.trim(),onClick:c,"data-testid":`open-dm-submit`,children:n(`channels.openDm`)}),children:(0,A.jsx)(`input`,{className:O,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&c()},placeholder:n(`channels.dmPlaceholder`),"data-testid":`open-dm-username`})})},me=({channels:e,onClose:t,onJoined:n})=>{let{t:r}=a();return(0,A.jsx)(D,{titleId:`browse-channels-title`,title:r(`channels.browsePublic`),onClose:t,testId:`browse-channels-modal`,children:e===null?(0,A.jsx)(p,{className:`mx-auto h-4 w-4 animate-spin text-gray-400`}):e.length===0?(0,A.jsx)(`p`,{className:`text-center text-xs text-gray-400 dark:text-dark-500`,children:r(`channels.noPublic`)}):e.map(e=>(0,A.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-black/[0.06] px-3 py-2 dark:border-white/[0.08]`,"data-testid":`browse-channel-item`,children:[(0,A.jsx)(d,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`}),(0,A.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] text-gray-800 dark:text-dark-800`,children:e.name}),e.isMember?(0,A.jsx)(`span`,{className:`text-[11px] text-gray-400`,children:r(`channels.joined`)}):(0,A.jsx)(T,{size:`sm`,onClick:()=>void w.join(e.id).then(()=>n(e.id)),"data-testid":`browse-channel-join`,children:r(`channels.join`)})]},e.id))})},he=({channel:e,onClose:t,onChanged:n,onDeleted:r})=>{let{t:i}=a(),[o,s]=(0,k.useState)(e.name),[c,l]=(0,k.useState)(e.description??``),[u,d]=(0,k.useState)(!1);return(0,A.jsxs)(D,{titleId:`channel-settings-title`,title:i(`channels.settings`),onClose:t,testId:`channel-settings-modal`,footer:(0,A.jsxs)(`div`,{className:`flex w-full items-center justify-between`,children:[(0,A.jsx)(T,{size:`sm`,variant:`ghost`,className:`text-red-500`,onClick:()=>void w.delete(e.id).then(e=>{e.success&&r()}),"data-testid":`channel-delete`,children:i(`channels.delete`)}),(0,A.jsx)(T,{size:`sm`,disabled:u||!o.trim(),onClick:()=>{d(!0),w.update(e.id,{name:o.trim(),description:c.trim()}).then(e=>{e.success&&n()}).finally(()=>d(!1))},"data-testid":`channel-settings-save`,children:i(`channels.save`)})]}),children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:E,children:i(`channels.nameLabel`)}),(0,A.jsx)(`input`,{className:O,value:o,onChange:e=>s(e.target.value)})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:E,children:i(`channels.descriptionLabel`)}),(0,A.jsx)(`textarea`,{className:O,rows:2,value:c,onChange:e=>l(e.target.value)})]})]})};export{de as default};