libre-webui 0.45.0 → 0.45.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/backend/dist/utils/decisionProtocol.d.ts.map +1 -1
  2. package/backend/dist/utils/decisionProtocol.js +3 -1
  3. package/backend/dist/utils/decisionProtocol.js.map +1 -1
  4. package/backend/package.json +1 -1
  5. package/frontend/dist/artifact-runtime/.build-fingerprint +1 -1
  6. package/frontend/dist/assets/index-MveXWX7i.js +15 -0
  7. package/frontend/dist/index.html +20 -20
  8. package/frontend/dist/js/{ArtifactContainer-DCCcjK16.js → ArtifactContainer-BiGwAZkv.js} +1 -1
  9. package/frontend/dist/js/{ArtifactDemoPage-C-1acgxJ.js → ArtifactDemoPage-Dk6bf2fr.js} +1 -1
  10. package/frontend/dist/js/{ArtifactSandboxFrame-BXWNhmtI.js → ArtifactSandboxFrame-BMQXP8E8.js} +1 -1
  11. package/frontend/dist/js/{ArtifactSlideOutPanel-CvfdP_o2.js → ArtifactSlideOutPanel-CNLSDJAJ.js} +1 -1
  12. package/frontend/dist/js/{AutomationModal-D7qiRMhj.js → AutomationModal-VMrwN5y4.js} +1 -1
  13. package/frontend/dist/js/{AutomationsPage-v98Ucl9p.js → AutomationsPage-wb5royf_.js} +1 -1
  14. package/frontend/dist/js/{AvatarUpload-W41SCHKE.js → AvatarUpload-DpeJzlyv.js} +1 -1
  15. package/frontend/dist/js/{CalendarPage-DkAa61Pa.js → CalendarPage-DeMdx8BD.js} +1 -1
  16. package/frontend/dist/js/{ChannelsPage-0Vnfpgdr.js → ChannelsPage-DJj_kG1m.js} +1 -1
  17. package/frontend/dist/js/{ChatPage-iyMY-uoE.js → ChatPage-tJ5_eAbV.js} +2 -2
  18. package/frontend/dist/js/{ConnectModels-CpWO6ALS.js → ConnectModels-7E_zzkFc.js} +1 -1
  19. package/frontend/dist/js/{EvaluationsPage-C7WHA1MJ.js → EvaluationsPage-_jLiPYYc.js} +1 -1
  20. package/frontend/dist/js/{FirstTimeSetup-B8wcelBc.js → FirstTimeSetup-BzSil7F7.js} +1 -1
  21. package/frontend/dist/js/{GalleryPage-u7dYKl3q.js → GalleryPage-CKpQMmd7.js} +1 -1
  22. package/frontend/dist/js/{HomePage-Cjlt3b9n.js → HomePage-Dr8mrmo7.js} +1 -1
  23. package/frontend/dist/js/{LanguageSwitcher-gbTZY15P.js → LanguageSwitcher-BPwDwNez.js} +1 -1
  24. package/frontend/dist/js/{ModelManagerModals-12hL-b-U.js → ModelManagerModals-eAwih0CC.js} +1 -1
  25. package/frontend/dist/js/{NotesPage-BQWBA5li.js → NotesPage-DDagHzg0.js} +1 -1
  26. package/frontend/dist/js/{PasswordStrengthMeter-DdqX0FXA.js → PasswordStrengthMeter-BwgYbk3r.js} +1 -1
  27. package/frontend/dist/js/{PersonasPage-B8mFdWcX.js → PersonasPage-uFr0Yzes.js} +1 -1
  28. package/frontend/dist/js/{PluginUsagePage-Uz6aHPIp.js → PluginUsagePage-BfIQuqIV.js} +1 -1
  29. package/frontend/dist/js/{RichMessageContent-CVk-fp0N.js → RichMessageContent-BY1I7d9d.js} +1 -1
  30. package/frontend/dist/js/{RichMessageContent-DwMoWuR_.js → RichMessageContent-otmciPPz.js} +1 -1
  31. package/frontend/dist/js/SettingsModal-D2x0muLa.js +19 -0
  32. package/frontend/dist/js/{ShareDialog-NwirTDLR.js → ShareDialog-DgVAGGOp.js} +1 -1
  33. package/frontend/dist/js/{StrandsPage-ddHNdb6J.js → StrandsPage-9UVviZ58.js} +1 -1
  34. package/frontend/dist/js/{SystemPage-C_1exwI7.js → SystemPage-ChJ8O0MR.js} +1 -1
  35. package/frontend/dist/js/{UserManagementPanel-hg7ztEtL.js → UserManagementPanel-CYuTltw4.js} +1 -1
  36. package/frontend/dist/js/{WhatsNewModal-yYk7N4KY.js → WhatsNewModal-DyK_LXtM.js} +1 -1
  37. package/frontend/dist/js/{WorkPage-i7yYRAuj.js → WorkPage-CdfTyNv_.js} +1 -1
  38. package/frontend/dist/js/{api-Dasm8tVY.js → api-BPTwf2O4.js} +1 -1
  39. package/frontend/dist/js/api-Lutao9vm.js +1 -0
  40. package/frontend/dist/js/{appNavigation-DqP7fTWU.js → appNavigation-DYXehtYu.js} +1 -1
  41. package/frontend/dist/js/{appStore-DCIUnT8X.js → appStore-C_SBNGJT.js} +2 -2
  42. package/frontend/dist/js/appVersion-C5-Afzj1.js +1 -0
  43. package/frontend/dist/js/{ar-CsCftCVF.js → ar-CMnK2iUi.js} +1 -1
  44. package/frontend/dist/js/authStore-6cAmoXEk.js +1 -0
  45. package/frontend/dist/js/{authStore-ac5-hjOH.js → authStore-Tu09JYbR.js} +3 -3
  46. package/frontend/dist/js/{bn-CvxUTZ9a.js → bn-B_6kDlG3.js} +1 -1
  47. package/frontend/dist/js/{chatStore-GhucyjJu.js → chatStore-wi8VDo6B.js} +3 -3
  48. package/frontend/dist/js/{client-DxPoTB_C.js → client-Czyqg89i.js} +2 -2
  49. package/frontend/dist/js/{config-CQJEcQtz.js → config-DWmMmE_t.js} +1 -1
  50. package/frontend/dist/js/{cs-BovmMwcD.js → cs-DN4IeMBM.js} +1 -1
  51. package/frontend/dist/js/{da-Dof1gmsv.js → da-Cx-BiRSz.js} +1 -1
  52. package/frontend/dist/js/{de-CF9CXojW.js → de-Cwlx8oC5.js} +1 -1
  53. package/frontend/dist/js/{decisionsApi-BWB64EGn.js → decisionsApi-CftWDIPz.js} +1 -1
  54. package/frontend/dist/js/decisionsApi-Dneh1e4n.js +1 -0
  55. package/frontend/dist/js/{es-BXCt50HZ.js → es-DGOk1LTg.js} +1 -1
  56. package/frontend/dist/js/{evaluationsApi-CBqKkjmI.js → evaluationsApi-C5DC-61t.js} +1 -1
  57. package/frontend/dist/js/{fr-B5QcCDIw.js → fr-DsjFEubC.js} +1 -1
  58. package/frontend/dist/js/{hi-BXYwSyKl.js → hi-YoyZTSWi.js} +1 -1
  59. package/frontend/dist/js/{id-BV3mY5L7.js → id-D7ObCsR9.js} +1 -1
  60. package/frontend/dist/js/{is-BDK4LrQC.js → is-DRfnKDHX.js} +1 -1
  61. package/frontend/dist/js/{it-DAeWl1Fm.js → it-Cb4C73dp.js} +1 -1
  62. package/frontend/dist/js/{ja-DIJV01rA.js → ja-DsDfWEWn.js} +1 -1
  63. package/frontend/dist/js/{ko-Btr9-64X.js → ko-J9IK9O8f.js} +1 -1
  64. package/frontend/dist/js/{messageCodeStyles-BugWE4s5.js → messageCodeStyles-DbG-nHEj.js} +1 -1
  65. package/frontend/dist/js/modelPresentation-4QU9r-Pl.js +1 -0
  66. package/frontend/dist/js/{ms-DgVmv5zF.js → ms-DVZBQWu-.js} +1 -1
  67. package/frontend/dist/js/{nl-Dz5HpdLi.js → nl-CotrV0Lb.js} +1 -1
  68. package/frontend/dist/js/{pl-CIATY2b0.js → pl-DlsgTT5q.js} +1 -1
  69. package/frontend/dist/js/{pt-lrDXX76Y.js → pt-B8F-CAdb.js} +1 -1
  70. package/frontend/dist/js/{ru-_zovUYcg.js → ru-B7H_WJLM.js} +1 -1
  71. package/frontend/dist/js/{strandsApi-Ck7FrcHH.js → strandsApi-c_sLVTzl.js} +1 -1
  72. package/frontend/dist/js/{sv-TkRDWCb8.js → sv-iYQWY_4T.js} +1 -1
  73. package/frontend/dist/js/{teamEventStream-O3qGbUZz.js → teamEventStream-Bnna_p2v.js} +1 -1
  74. package/frontend/dist/js/{th-CQyavDiP.js → th-BIlkYCg9.js} +1 -1
  75. package/frontend/dist/js/{tr-CBcFl4_Z.js → tr-Cb0GxFvG.js} +1 -1
  76. package/frontend/dist/js/{ui-DxaHE9GD.js → ui-Byzdw4-Y.js} +2 -2
  77. package/frontend/dist/js/{ui-vendor-DsURZnZt.js → ui-vendor-C7v9zeJX.js} +1 -1
  78. package/frontend/dist/js/{uk-BNn1cUt8.js → uk-BH7Ojiob.js} +1 -1
  79. package/frontend/dist/js/{useChat-1HyAPpCk.js → useChat-DGCDsOOs.js} +1 -1
  80. package/frontend/dist/js/useDictation-BGys860H.js +1 -0
  81. package/frontend/dist/js/{vi-Be8GO7e_.js → vi-BKN3n9CC.js} +1 -1
  82. package/frontend/dist/js/{workApi-BNGRSv7q.js → workApi-BTdJF6o5.js} +1 -1
  83. package/frontend/dist/js/workApi-DvXvzA8C.js +1 -0
  84. package/frontend/dist/js/{zh-9CUKyYw5.js → zh-CbiVZpr_.js} +1 -1
  85. package/package.json +1 -1
  86. package/frontend/dist/assets/index-C2A5Ko4-.js +0 -59
  87. package/frontend/dist/js/SettingsModal-CfjxNSmJ.js +0 -19
  88. package/frontend/dist/js/api-BU13N8gU.js +0 -1
  89. package/frontend/dist/js/appVersion-PJGaVilS.js +0 -1
  90. package/frontend/dist/js/authStore-Bp17zKvS.js +0 -1
  91. package/frontend/dist/js/decisionsApi-CoJtg4PZ.js +0 -1
  92. package/frontend/dist/js/thinking-DwlkTfPX.js +0 -1
  93. package/frontend/dist/js/useDictation-B3vNgs5D.js +0 -1
  94. package/frontend/dist/js/workApi-C5jw1ra6.js +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "libre-webui",
3
- "version": "0.45.0",
3
+ "version": "0.45.1",
4
4
  "description": "A local-first workspace for chat, private knowledge, artifacts, and isolated model-driven work.",
5
5
  "bin": {
6
6
  "libre-webui": "bin/cli.js"
@@ -1,59 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/SettingsModal-CfjxNSmJ.js","js/rolldown-runtime-XKyaHtl9.js","js/react-vendor-C1iE8mnY.js","js/useQuery-Cs76KYuP.js","js/ui-vendor-DsURZnZt.js","js/appStore-DCIUnT8X.js","js/logger-DAQsBb8I.js","js/utils-vendor-B4bGLP5p.js","js/ui-DxaHE9GD.js","js/Button-D6d7HYoa.js","js/utils-BXRzbHJC.js","js/messageCodeStyles-BugWE4s5.js","js/useTranslation-CKqEdZ8j.js","js/useDialogFocus-DpTun-ZV.js","js/Logo-DhV6D_3q.js","js/LogoMark-CmF1lHXT.js","js/SettingsToggle-CNUeo6DO.js","js/LanguageSwitcher-gbTZY15P.js","js/chatStore-GhucyjJu.js","js/api-Dasm8tVY.js","js/client-DxPoTB_C.js","js/config-CQJEcQtz.js","js/strandsApi-Ck7FrcHH.js","js/workApi-BNGRSv7q.js","js/authStore-ac5-hjOH.js","js/imageGenModels-Dx_QMLJQ.js","js/ShareDialog-NwirTDLR.js","js/thinking-DwlkTfPX.js","js/confirmStore-CKkUtP9c.js","js/ttsBatching-yVvnRS5S.js","js/appVersion-PJGaVilS.js","js/HomePage-Cjlt3b9n.js","js/router-vendor-DLHZHk4K.js","js/appNavigation-DqP7fTWU.js","js/welcomePrompts-to5mv_gx.js","js/work-BP_ujNmK.js","js/ChatPage-iyMY-uoE.js","js/ArtifactContainer-DCCcjK16.js","js/OptimizedSyntaxHighlighter-B8vbflQA.js","js/syntax-highlight-CemL-n1v.js","js/markdown-core-CGWDtd6X.js","js/ArtifactSandboxFrame-BXWNhmtI.js","js/artifactHtml-DDmfpcB0.js","js/useChat-1HyAPpCk.js","js/liveAnnouncerStore-B6mS-JWC.js","js/evaluationsApi-CBqKkjmI.js","js/useDictation-B3vNgs5D.js","js/composerStyles-BEx0XAp6.js","js/ConnectModels-CpWO6ALS.js","js/WhatsNewModal-yYk7N4KY.js","js/PersonasPage-B8mFdWcX.js","js/AvatarUpload-W41SCHKE.js","js/GalleryPage-u7dYKl3q.js","js/NotesPage-BQWBA5li.js","js/RichMessageContent-DwMoWuR_.js","js/CalendarPage-DkAa61Pa.js","js/calendarDates-Co3o_05Y.js","js/AutomationsPage-v98Ucl9p.js","js/AutomationModal-D7qiRMhj.js","js/StrandsPage-ddHNdb6J.js","js/ChannelsPage-0Vnfpgdr.js","js/teamEventStream-O3qGbUZz.js","js/WorkPage-i7yYRAuj.js","js/workAnnouncements--WBYN99v.js","js/UserManagementPage-BrogyZDQ.js","js/PluginUsagePage-Uz6aHPIp.js","js/EvaluationsPage-C7WHA1MJ.js","js/SystemPage-C_1exwI7.js","js/ArtifactDemoPage-C-1acgxJ.js","js/ArtifactSlideOutPanel-CvfdP_o2.js","js/FirstTimeSetup-B8wcelBc.js","js/TurnstileWidget-B_dl1YjT.js","js/PasswordStrengthMeter-DdqX0FXA.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"../js/rolldown-runtime-XKyaHtl9.js";import{i as t,n,r,t as i}from"../js/react-vendor-C1iE8mnY.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-Cs76KYuP.js";import{a as C,c as w,d as ee,m as T,n as E,o as D,p as O,r as k,s as A,t as j,u as M}from"../js/router-vendor-DLHZHk4K.js";import{C as N,E as P,T as F,d as I,h as te,t as L}from"../js/chatStore-GhucyjJu.js";import{t as R}from"../js/useTranslation-CKqEdZ8j.js";import{$n as ne,$t as re,B as z,Dn as ie,Dr as B,Dt as V,E as ae,En as oe,Er as se,Et as H,Fn as ce,Ft as U,I as le,K as W,Kt as ue,M as G,Or as de,Pt as fe,Q as pe,Rt as K,T as me,Tn as he,Tr as ge,U as _e,V as ve,Vn as ye,Xt as be,Zn as xe,at as Se,c as Ce,cn as we,ct as Te,dr as Ee,dt as De,er as Oe,fn as ke,fr as Ae,ft as je,g as Me,h as Ne,ht as Pe,ir as Fe,jn as Ie,k as Le,kn as Re,ln as ze,lr as Be,mn as Ve,mr as He,mt as Ue,n as We,nn as Ge,nr as Ke,or as qe,ot as Je,qt as Ye,r as Xe,rr as Ze,t as Qe,tr as $e,tt as et,u as tt,v as nt,vt as rt,wr as it,xr as at,yn as ot,yt as st,z as ct,zt as lt}from"../js/ui-vendor-DsURZnZt.js";import{t as q}from"../js/Button-D6d7HYoa.js";import{f as ut,g as dt,h as ft}from"../js/ui-DxaHE9GD.js";import{a as pt,i as mt,n as ht,r as gt}from"../js/confirmStore-CKkUtP9c.js";import{n as _t,r as vt,t as yt}from"../js/liveAnnouncerStore-B6mS-JWC.js";import{d as bt,n as xt,s as St,t as J,u as Ct}from"../js/authStore-ac5-hjOH.js";import{n as wt,t as Tt}from"../js/utils-vendor-B4bGLP5p.js";import{f as Et,l as Dt,n as Ot,o as kt,t as Y,u as At}from"../js/appStore-DCIUnT8X.js";import{i as jt,l as Mt,o as Nt,t as X}from"../js/utils-BXRzbHJC.js";import{E as Pt,I as Ft,L as It,R as Lt,T as Rt,_ as zt,g as Bt,h as Vt,v as Ht,w as Ut,y as Wt}from"../js/api-Dasm8tVY.js";import{a as Gt,o as Z,t as Kt}from"../js/logger-DAQsBb8I.js";import{n as qt}from"../js/welcomePrompts-to5mv_gx.js";import{l as Jt}from"../js/messageCodeStyles-BugWE4s5.js";import{t as Yt}from"../js/AvatarUpload-W41SCHKE.js";import{t as Xt}from"../js/Logo-DhV6D_3q.js";import{t as Zt}from"../js/LogoMark-CmF1lHXT.js";import{t as Qt}from"../js/ShareDialog-NwirTDLR.js";import{t as $t}from"../js/useDialogFocus-DpTun-ZV.js";import{t as en}from"../js/teamEventStream-O3qGbUZz.js";import{a as tn,r as nn}from"../js/work-BP_ujNmK.js";import{i as rn,n as an,t as on}from"../js/workAnnouncements--WBYN99v.js";import{t as sn}from"../js/useChat-1HyAPpCk.js";import{t as cn}from"../js/config-CQJEcQtz.js";import{a as ln,c as un,i as dn,o as fn,r as pn,t as mn}from"../js/LanguageSwitcher-gbTZY15P.js";import{n as hn,r as gn,t as _n}from"../js/appNavigation-DqP7fTWU.js";import{n as vn}from"../js/ttsBatching-yVvnRS5S.js";import{t as yn}from"../js/TurnstileWidget-B_dl1YjT.js";import{n as bn,t as xn}from"../js/PasswordStrengthMeter-DdqX0FXA.js";import{t as Sn}from"../js/appVersion-PJGaVilS.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 Cn=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||wn(),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})}this.state.isPaused&&r.canStart()&&t();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 wn(){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 Cn({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=En(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=En(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=En(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=En(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){y.batch(()=>{let e=this.getAll();this.#e.clear(),this.#t.clear(),e.forEach(e=>{this.notify({type:`removed`,mutation:e})})})}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 En(e){return e.options.scope?.id}var Dn=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){this.#e.get(e.queryHash)===e&&(e.destroy(),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()})})}},On=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new Dn,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),r=e.state.fetchStatus===`paused`;return(!n.throwOnError||r)&&(t=t.catch(b)),r?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()}},kn=e(n(),1),Q=e(t(),1),$=i(),An=()=>{let e=(0,Q.useSyncExternalStore)(pt,ht,ht),{pathname:t}=M();return(0,Q.useEffect)(()=>gt,[t]),e?(0,$.jsx)(jn,{request:e},e.id):null},jn=({request:e})=>{let{t}=R(),n=(0,Q.useId)(),r=e.confirmLabel??(e.destructive?t(`common.delete`):t(`common.confirm`));return(0,$.jsx)(dt,{titleId:n,title:e.title,subtitle:e.description,onClose:()=>mt(!1),widthClassName:`max-w-md`,testId:`confirm-dialog`,footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{type:`button`,variant:`secondary`,onClick:()=>mt(!1),"data-testid":`confirm-dialog-cancel`,children:e.cancelLabel??t(`common.cancel`)}),(0,$.jsx)(q,{type:`button`,variant:e.destructive?`danger`:`primary`,onClick:()=>mt(!0),"data-testid":`confirm-dialog-confirm`,children:r})]})})},Mn=50,Nn=({announcement:e,politeness:t,testId:n})=>{let[r,i]=(0,Q.useState)(``),a=(0,Q.useRef)(e.id);return(0,Q.useEffect)(()=>{if(e.id===a.current)return;a.current=e.id,i(``);let t=window.setTimeout(()=>i(e.message),Mn),n=window.setTimeout(()=>i(``),10050);return()=>{window.clearTimeout(t),window.clearTimeout(n)}},[e]),(0,$.jsx)(`div`,{role:t===`polite`?`status`:`alert`,"aria-live":t,"aria-atomic":`true`,className:`sr-only`,"data-testid":n,children:r})},Pn=()=>{let e=(0,Q.useSyncExternalStore)(vt,_t,_t);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Nn,{announcement:e.polite,politeness:`polite`,testId:`live-announcer-polite`}),(0,$.jsx)(Nn,{announcement:e.assertive,politeness:`assertive`,testId:`live-announcer-assertive`})]})},Fn={id:`home`,kind:`home`,path:`/`},In=[`/calendar`,`/automations`,`/channels`,`/personas`,`/gallery`,`/strands`,`/usage`,`/system`,`/artifacts`],Ln=e=>{if(e===`/`||e===`/home`)return Fn;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}:In.includes(e)?{id:`page:${e}`,kind:`page`,path:e}:null},Rn=e=>[Fn,...e.filter(e=>e.id!==Fn.id)],zn=wt()(Tt((e,t)=>({tabs:[Fn],activeTabId:Fn.id,syncWithPath:t=>{let n=Ln(t);n&&e(e=>{let t=Rn(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=Rn(i.tabs),o=new Set(n.filter(e=>e!==Fn.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]??Fn;return e({tabs:c,activeTabId:d.id}),d},reset:()=>e({tabs:[Fn],activeTabId:Fn.id})}),{name:`libre-webui-tabs`,merge:(e,t)=>{let n=e??{},r=Array.isArray(n.tabs)?Rn(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:Fn.id;return{...t,tabs:r,activeTabId:i}}}));function Bn({open:e,value:t,saving:n,onChange:r,onClose:i,onSave:a}){let{t:o}=R();return e?(0,$.jsx)(dt,{titleId:`avatar-modal-title`,title:o(`user.avatar.title`),widthClassName:`max-w-md`,onClose:i,footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{type:`button`,variant:`ghost`,onClick:i,children:o(`common.cancel`)}),(0,$.jsx)(q,{type:`button`,onClick:a,disabled:n,children:o(n?`common.saving`:`common.save`)})]}),children:(0,$.jsx)(Yt,{value:t,onChange:r})}):null}var Vn=`h-4 w-4 text-ink-muted transition-colors duration-150 group-hover:text-ink motion-reduce:transition-none`,Hn={light:ae,dark:st,amoled:rt,celestial:me},Un={light:`themeToggle.switchToLight`,dark:`themeToggle.switchToDark`,amoled:`themeToggle.switchToAmoled`,celestial:`themeToggle.switchToCelestial`},Wn=()=>{let{t:e}=R(),{theme:t,toggleTheme:n}=Y(),r=kt(t.mode),i=Hn[r],a=e(Un[r]),o=Nt()?`⌘D`:`Ctrl+D`;return(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:n,className:`h-9 w-9 rounded-full p-0`,"aria-label":a,title:`${a} (${o})`,children:(0,$.jsx)(i,{className:Vn,strokeWidth:1.75,"aria-hidden":`true`})})},Gn=`relative flex h-[44px] w-[44px] shrink-0 items-center justify-center rounded-full text-ink transition-colors duration-150 hover:bg-interactive-hover outline-hidden focus-visible:ring-2 focus-visible:ring-primary-500/30 touch-manipulation motion-reduce:transition-none`;function Kn(){let{t:e}=R();return(0,$.jsx)(`div`,{className:`flex shrink-0 justify-center px-2`,children:(0,$.jsx)(`button`,{type:`button`,"data-testid":`sidebar-search-button`,onClick:()=>window.dispatchEvent(new Event(`libre:open-palette`)),title:e(`palette.search`,`Search`),"aria-label":e(`palette.search`,`Search`),className:Gn,children:(0,$.jsx)(W,{"aria-hidden":`true`,className:`h-[18px] w-[18px]`})})})}function qn({sidebarCompact:e,isElectron:t,showWork:n,activeMode:r,selectedModel:i,modelCount:a,onToggleCompact:o,onStartWork:s,onCreateSession:c}){let{t:l}=R(),u=!i||a===0,d=u?l(`chat.model.noModelsTooltip`):``;return e?(0,$.jsxs)(`div`,{className:X(`flex shrink-0 flex-col items-center gap-[4px] px-2 pt-[8px]`,t&&`pt-10`),children:[(0,$.jsxs)(`button`,{type:`button`,onClick:o,className:X(Gn,`group`),title:l(`sidebar.expandSidebar`),"aria-label":l(`sidebar.expandSidebar`),"data-testid":`sidebar-rail-expand`,children:[(0,$.jsx)(Zt,{size:`sm`,label:null,className:`h-6 w-6 p-0 text-ink group-hover:hidden`}),(0,$.jsx)(je,{className:`hidden h-[18px] w-[18px] group-hover:block rtl:rotate-180`})]}),(0,$.jsx)(`button`,{type:`button`,onClick:c,disabled:u,className:X(Gn,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,$.jsx)(V,{className:`h-[18px] w-[18px]`})}),n&&(0,$.jsx)(`button`,{type:`button`,onClick:s,className:`relative flex h-[44px] w-[44px] shrink-0 items-center justify-center rounded-full text-ink transition-colors duration-150 hover:bg-interactive-hover outline-hidden focus-visible:ring-2 focus-visible:ring-primary-500/30 touch-manipulation motion-reduce:transition-none`,title:l(`chat.session.work`),"aria-label":l(`chat.session.work`),"aria-pressed":r===`work`,"data-testid":`sidebar-work-button`,children:(0,$.jsx)(qe,{className:`h-[18px] w-[18px]`})})]}):(0,$.jsxs)(`div`,{className:X(`px-3 pb-2 pt-2`,t&&`pt-10`),children:[(0,$.jsxs)(`div`,{className:`mb-2 flex h-[52px] min-w-0 items-center justify-between ps-1`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-ink`,children:[(0,$.jsx)(Zt,{size:`sm`,label:null}),(0,$.jsx)(Xt,{size:`sm`,className:`tracking-[-0.035em]`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,$.jsx)(`div`,{className:`hidden sm:block`,children:(0,$.jsx)(Wn,{})}),(0,$.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-hidden 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,$.jsx)(je,{className:`h-4 w-4 rtl:rotate-180`})})]})]}),(0,$.jsxs)(`div`,{className:X(`grid w-full gap-2`,!n&&`grid-cols-1`,n&&`grid-cols-2`),"data-testid":`sidebar-create-actions`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:c,disabled:u,className:X(`flex h-[38px] items-center justify-center gap-1.5 rounded-xl border text-sm font-medium transition-colors touch-manipulation outline-hidden 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/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,$.jsx)(V,{className:`h-4 w-4`}),l(`chat.session.chat`)]}),n&&(0,$.jsxs)(`button`,{type:`button`,onClick:s,className:X(`flex h-[38px] items-center justify-center gap-1.5 rounded-xl border text-sm font-medium transition-colors touch-manipulation outline-hidden 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/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,$.jsx)(qe,{className:`h-4 w-4`}),l(`chat.session.work`)]})]}),(0,$.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-hidden focus-visible:ring-2 focus-visible:ring-primary-500/30 touch-manipulation`,children:[(0,$.jsx)(W,{className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1 text-start`,children:l(`palette.search`,`Search`)}),(0,$.jsxs)(`span`,{className:`font-mono text-[10px] tracking-wide text-ink-subtle`,children:[Nt()?`⌘`:`Ctrl`,`K`]})]})]})}var Jn=[{path:`/channels`,icon:H,labelKey:`sidebar.navigation.channels`},{path:`/notes`,icon:Pe,labelKey:`sidebar.navigation.notes`},{path:`/calendar`,icon:Fe,labelKey:`sidebar.navigation.calendar`},{path:`/automations`,icon:Qe,labelKey:`sidebar.navigation.automations`},{path:`/personas`,icon:Ce,labelKey:`sidebar.navigation.personas`},{path:`/gallery`,icon:G,labelKey:`sidebar.navigation.imagine`},{path:`/strands`,icon:Ee,labelKey:`sidebar.navigation.strands`}];function Yn({sidebarCompact:e,activePath:t,showStrands:n,unseenRunCount:r=0,onMobileNavigate:i}){let{t:a}=R();return(0,$.jsx)(`div`,{className:X(`shrink-0`,e?`px-2`:`px-3 pb-3`),children:(0,$.jsx)(`nav`,{"data-testid":`sidebar-navigation`,"aria-label":a(`sidebar.navigation.exploreLabel`,`Explore`),className:X(`flex`,e?`flex-col items-center gap-[4px]`:`items-center gap-1`),children:Jn.filter(e=>e.path!==`/strands`||n).map(({path:n,icon:o,labelKey:s})=>{let c=t===n||t.startsWith(`${n}/`),l=a(s);return(0,$.jsxs)(j,{to:n,onClick:i,title:l,"aria-label":l,"aria-current":c?`page`:void 0,className:X(e?Gn:`relative flex h-9 flex-1 items-center justify-center rounded-xl transition-colors duration-150 touch-manipulation outline-hidden focus-visible:ring-2 focus-visible:ring-primary-500/30`,c?`bg-nav-active text-ink`:!e&&`text-ink-muted hover:bg-interactive-hover hover:text-ink`),children:[(0,$.jsx)(o,{"aria-hidden":`true`,className:`h-[18px] w-[18px] shrink-0`}),n===`/automations`&&r>0&&(0,$.jsx)(`span`,{"data-testid":`automations-unseen-badge`,className:`absolute -inset-e-0.5 -top-0.5 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-primary-600 px-0.5 text-[9px] font-semibold leading-none text-white`,children:r>9?`9+`:r})]},n)})})})}var Xn=r();function Zn({top:e,left:t,title:n,timestamp:r,children:i}){let{i18n:a}=R();return(0,Xn.createPortal)((0,$.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/9 dark:bg-dark-100/95 md:block`,style:{top:Math.max(8,Math.min(e,window.innerHeight-220)),left:t},children:[(0,$.jsx)(`p`,{className:`mb-1 truncate text-[13px] font-semibold text-gray-900 dark:text-dark-900`,children:n}),(0,$.jsx)(`p`,{className:`mb-2 text-[10px] tabular-nums text-gray-400 dark:text-dark-500`,children:jt(r,a.language)}),i]}),document.body)}function Qn({children:e,"data-testid":t,compact:n=!1,compactClassName:r}){let i=(0,Q.useRef)(null),a=(0,Q.useRef)(null);return(0,Q.useLayoutEffect)(()=>{if(n)return;let e=i.current,t=a.current;if(!e||!t)return;let r=null,o=()=>{r=null;let{scrollTop:t,scrollHeight:n,clientHeight:i}=e,a=n-i-t;e.style.setProperty(`--sidebar-fade-top`,`${Math.min(24,Math.max(0,t))}px`),e.style.setProperty(`--sidebar-fade-bottom`,`${Math.min(24,Math.max(0,a))}px`)},s=()=>{r===null&&(r=requestAnimationFrame(o))};o(),e.addEventListener(`scroll`,s,{passive:!0});let c=new ResizeObserver(s);return c.observe(e),c.observe(t),()=>{e.removeEventListener(`scroll`,s),c.disconnect(),r!==null&&cancelAnimationFrame(r),e.style.removeProperty(`--sidebar-fade-top`),e.style.removeProperty(`--sidebar-fade-bottom`)}},[n]),(0,$.jsx)(`div`,{className:n?X(`shrink-0`,r):`flex min-h-0 flex-1 flex-col border-t border-black/5 dark:border-white/5`,children:(0,$.jsx)(`div`,{ref:i,"data-testid":t,className:n?void 0:`sidebar-scroll-fade scroll-region min-h-0 flex-1 scrollbar-thin`,children:(0,$.jsx)(`div`,{ref:a,children:e})})})}function $n({onClose:e,children:t,...n}){let r=(0,Q.useRef)(null);return $t(r,{onClose:e}),(0,$.jsx)(`div`,{ref:r,tabIndex:-1,role:`dialog`,"aria-modal":`true`,...n,children:t})}function er(e,t){let n=(0,Q.useRef)(null),r=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(!e)return;let t=n.current,i=r.current;return t?.querySelector(`[role="menuitem"]:not(:disabled)`)?.focus(),()=>{(document.activeElement===document.body||t?.contains(document.activeElement))&&i?.focus()}},[e]);let i=()=>{e&&r.current?.focus(),t()};return{menuRef:n,setTrigger:e=>{r.current=e},onKeyDown:e=>{if(e.key===`Escape`||e.key===`Tab`){e.key===`Escape`&&e.preventDefault(),e.stopPropagation(),i();return}let t=Array.from(n.current?.querySelectorAll(`[role="menuitem"]:not(:disabled)`)??[]);if(!t.length)return;let r=t.indexOf(document.activeElement),a;switch(e.key){case`ArrowDown`:a=(r+1)%t.length;break;case`ArrowUp`:a=(r-1+t.length)%t.length;break;case`Home`:a=0;break;case`End`:a=t.length-1;break;default:return}e.preventDefault(),e.stopPropagation(),t[a].focus()},closeMenu:i}}function tr(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 nr=[`today`,`yesterday`,`previous7Days`,`previous30Days`,`older`];function rr({preview:e}){let{t}=R(),{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,$.jsxs)(Zn,{top:e.top,left:e.left,title:n.title,timestamp:n.updatedAt,children:[r&&(0,$.jsx)(`div`,{className:`mb-1.5 flex justify-end`,children:(0,$.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:Mt(r.content,110)})}),i&&(0,$.jsx)(`p`,{dir:`auto`,className:`text-[11px] leading-snug text-gray-600 dark:text-dark-700`,children:Mt(i.content.replace(/\s+/g,` `),180)}),!r&&!i&&(0,$.jsx)(`p`,{className:`text-[11px] italic text-gray-400 dark:text-dark-500`,children:t(`chat.session.noChats`)})]})}function ir({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}=R(),[C,w]=(0,Q.useState)(null),[ee,T]=(0,Q.useState)(null),E=(0,Q.useRef)(null),D=ee?e.find(e=>e.id===ee)??null:null;(0,Q.useEffect)(()=>()=>{E.current!==null&&window.clearTimeout(E.current)},[]);let O=()=>{E.current!==null&&(window.clearTimeout(E.current),E.current=null),w(null)},k=(e,t)=>{let n=window.matchMedia(`(hover: hover) and (pointer: fine)`).matches;i||window.innerWidth<768||!n||(E.current!==null&&window.clearTimeout(E.current),E.current=window.setTimeout(()=>{let n=t.getBoundingClientRect();w({session:e,top:n.top,left:n.right+10})},500))},[A,j]=(0,Q.useState)(()=>new Set),[M,N]=(0,Q.useState)(!1),[P,F]=(0,Q.useState)(``),[I,te]=(0,Q.useState)(null),[L,re]=(0,Q.useState)(null),[B,ae]=(0,Q.useState)(null),oe=L?e.find(e=>e.id===L)??null:null,se=()=>{re(null),ae(null)},H=e=>{let t=oe;se(),t&&y&&(t.folderId??null)!==e&&y(t.id,e)},ce=(e,t)=>({onDragOver:t=>{L&&(t.preventDefault(),t.dataTransfer.dropEffect=`move`,B!==e&&ae(e))},onDragLeave:()=>{B===e&&ae(null)},onDrop:e=>{e.preventDefault(),H(t)}}),[U,le]=(0,Q.useState)(null),[W,ue]=(0,Q.useState)(null),G=W?e.find(e=>e.id===W.sessionId)??null:null,{menuRef:de,setTrigger:fe,onKeyDown:pe,closeMenu:K}=er(W?.sessionId,()=>ue(null)),me=(e,t)=>{if(t.stopPropagation(),O(),W?.sessionId===e.id){K();return}fe(t.currentTarget);let n=t.currentTarget.getBoundingClientRect();ue({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))})},he=e=>{let t=window.location.protocol===`file:`?`${window.location.pathname}#/c/${e.id}`:`/c/${e.id}`;window.open(t,`_blank`,`noopener,noreferrer`)},ge=e=>{j(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},_e=()=>{let e=P.trim();N(!1),F(``),e&&g&&g(e)},ve=e=>{let t=P.trim();te(null),F(``),t&&_&&_(e,t)},ye=new Set(h.map(e=>e.id)),be=e.filter(e=>e.pinned),Ce=e.filter(e=>!e.pinned),we=Ce.filter(e=>!e.folderId||!ye.has(e.folderId)),Ee=[...be.length>0?[{key:`pinned`,labelKey:`pinned`,sessions:be}]:[],...h.map(e=>({key:`folder:${e.id}`,folder:e,sessions:Ce.filter(t=>t.folderId===e.id)})),...nr.map(e=>({key:e,labelKey:e,sessions:we.filter(t=>tr(t.updatedAt)===e)})).filter(e=>e.sessions.length>0)];return(0,$.jsxs)(Qn,{"data-testid":`sidebar-session-scroll-region`,compact:i,compactClassName:`md:hidden`,children:[(0,$.jsxs)(`div`,{className:i?`p-0`:`px-3 py-3`,children:[!i&&e.length>0&&(0,$.jsxs)(`div`,{className:`mb-1 flex h-7 items-center justify-between px-1.5`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-medium text-ink-subtle`,children:x(`chat.session.chats`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[g&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>{N(!0),F(``)},className:`flex items-center justify-center rounded-md p-1.5 text-ink-muted transition-colors hover:bg-interactive-hover hover:text-ink`,title:x(`chat.session.folder.new`),"aria-label":x(`chat.session.folder.new`),children:(0,$.jsx)(Ve,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`span`,{className:`text-[10px] tabular-nums text-ink-subtle font-medium`,children:e.length})]})]}),!i&&M&&(0,$.jsx)(`div`,{className:`mb-2 px-1`,children:(0,$.jsx)(ft,{value:P,onChange:e=>F(e.target.value),onKeyDown:e=>{e.key===`Enter`?_e():e.key===`Escape`&&(N(!1),F(``))},onBlur:_e,placeholder:x(`chat.session.folder.namePlaceholder`),className:`h-8 text-sm`,autoFocus:!0})}),i?(0,$.jsx)(`div`,{className:`flex flex-col items-center gap-[4px]`,children:(0,$.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:X(Gn,`relative md:hidden`),children:[(0,$.jsx)(V,{className:`h-[18px] w-[18px]`}),e.length>0&&(0,$.jsx)(`span`,{className:`absolute -inset-e-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-md bg-primary-600 px-1 text-[9px] font-semibold tabular-nums text-white shadow-xs`,children:e.length>99?`99+`:e.length})]})}):e.length===0?(0,$.jsxs)(`div`,{className:`text-center py-8 px-2`,children:[(0,$.jsx)(`div`,{className:`mx-auto mb-3 bg-white/70 dark:bg-dark-200 rounded-xl flex items-center justify-center ring-1 ring-black/4 dark:ring-white/5 w-12 h-12`,children:(0,$.jsx)(V,{className:`text-gray-400 dark:text-gray-500 h-5 w-5`})}),(0,$.jsx)(`p`,{className:`text-sm font-medium text-gray-600 dark:text-dark-600`,children:x(`chat.session.noChats`)}),(0,$.jsx)(`p`,{className:`text-xs mt-1 text-gray-400 dark:text-dark-500`,children:x(`chat.session.createFirst`)})]}):(0,$.jsx)(`div`,{className:`space-y-2`,children:Ee.map(e=>(0,$.jsxs)(`div`,{children:[!i&&e.folder&&(0,$.jsx)(`div`,{...ce(`folder:${e.folder.id}`,e.folder.id),className:X(`group/folder mb-0.5 flex h-[34px] items-center justify-between rounded-lg px-2 transition-colors hover:bg-interactive-hover`,B===`folder:${e.folder.id}`&&`bg-primary-500/10 ring-1 ring-primary-500/40`),children:I===e.folder.id?(0,$.jsx)(ft,{value:P,onChange:e=>F(e.target.value),onKeyDown:t=>{t.key===`Enter`?ve(e.folder.id):t.key===`Escape`&&(te(null),F(``))},onBlur:()=>ve(e.folder.id),className:`h-7 text-sm`,autoFocus:!0}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>ge(e.folder.id),className:`flex min-w-0 flex-1 items-center gap-1.5 text-sm text-ink transition-colors`,"aria-expanded":!A.has(e.folder.id),children:[A.has(e.folder.id)?(0,$.jsx)(xe,{className:`h-3.5 w-3.5 shrink-0 text-ink-subtle rtl:rotate-180`}):(0,$.jsx)(ne,{className:`h-3.5 w-3.5 shrink-0 text-ink-subtle`}),(0,$.jsx)(ke,{className:`h-4 w-4 shrink-0 text-ink-subtle`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.folder.name}),(0,$.jsx)(`span`,{className:`text-[10px] font-medium tabular-nums text-ink-subtle`,children:e.sessions.length})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5 transition-opacity sm:opacity-0 sm:group-hover/folder:opacity-100 sm:group-focus-within/folder:opacity-100 [@media(hover:none)]:opacity-100`,children:[_&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>{te(e.folder.id),F(e.folder.name)},className:`rounded-md p-1.5 text-ink-muted hover:text-ink`,title:x(`chat.session.folder.rename`),"aria-label":x(`chat.session.folder.rename`),children:(0,$.jsx)(Te,{className:`h-3 w-3`})}),v&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>{window.confirm(x(`chat.session.folder.deleteConfirm`))&&v(e.folder.id)},className:`rounded-md p-1.5 text-ink-muted hover:text-error-600 dark:hover:text-error-400`,title:x(`chat.session.folder.delete`),"aria-label":x(`chat.session.folder.delete`),children:(0,$.jsx)(nt,{className:`h-3 w-3`})})]})]})}),!i&&!e.folder&&(0,$.jsx)(`p`,{...ce(`group:${e.key}`,null),className:X(`mb-0.5 mt-1 rounded-md px-2 text-[11px] font-medium text-ink-subtle transition-colors`,B===`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&&A.has(e.folder.id)?null:(0,$.jsx)(`div`,{className:X(`space-y-0.5`,i&&`space-y-1`),children:e.sessions.map(e=>{let t=n===e.id,l=W?.sessionId===e.id;return(0,$.jsx)(`div`,{draggable:!i&&!!y&&a!==e.id,onDragStart:t=>{O(),K(),re(e.id),t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,e.id)},onDragEnd:se,className:X(`group relative cursor-pointer transition-colors duration-150 touch-manipulation outline-hidden`,i?`rounded-xl p-1 flex items-center justify-center`:`rounded-lg px-2`,t?`bg-interactive-active`:`hover:bg-interactive-hover`,L===e.id&&`opacity-40`),onClick:()=>{O(),c(e)},onMouseEnter:t=>k(e,t.currentTarget),onMouseLeave:O,title:i?`${e.title} - ${e.model}`:void 0,children:i?(0,$.jsx)(`div`,{className:`flex items-center justify-center w-full h-10`,children:(0,$.jsx)(`div`,{className:X(`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/4 dark:bg-dark-200/70 dark:text-dark-600 dark:ring-white/5`),children:e.title.trim().charAt(0)||`•`})}):a===e.id?(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,onClick:e=>e.stopPropagation(),children:[(0,$.jsx)(ft,{value:o,"aria-label":x(`chat.session.renameChat`),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,$.jsx)(q,{variant:`ghost`,size:`sm`,"aria-label":x(`common.save`),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,$.jsx)(Oe,{className:`h-3 w-3`})}),(0,$.jsx)(q,{variant:`ghost`,size:`sm`,"aria-label":x(`common.cancel`),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,$.jsx)(We,{className:`h-3 w-3`})})]}):(0,$.jsxs)(`div`,{className:`flex h-8 w-full items-center`,children:[(0,$.jsx)(`button`,{type:`button`,className:`min-w-0 flex-1 truncate rounded-md py-1 text-start text-sm leading-5 text-ink outline-hidden focus-visible:ring-2 focus-visible:ring-primary-500/30`,title:e.title,"aria-label":e.title,"aria-current":t?`page`:void 0,children:r===e.id?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,title:x(`chat.session.generatingTitle`),children:[(0,$.jsx)(ut,{}),(0,$.jsx)(`span`,{className:`truncate`,children:Mt(e.title,40)})]}):Mt(e.title,40)}),(0,$.jsx)(`span`,{dir:`auto`,className:X(`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:jt(e.updatedAt,S.language)}),(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:t=>{t.stopPropagation(),O(),T(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,$.jsx)(Re,{className:`h-4 w-4`})}),(0,$.jsx)(`div`,{className:X(`hidden shrink-0`,`sm:group-hover:block sm:group-focus-within:block`,l&&`sm:block`),children:(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:t=>me(e,t),className:X(`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,$.jsx)(Re,{className:`h-4 w-4`})})})]})},e.id)})})]},e.key))})]}),C&&(0,$.jsx)(rr,{preview:C}),W&&G&&(0,Xn.createPortal)((0,$.jsxs)(`div`,{className:`fixed inset-0 z-75 hidden sm:block`,children:[(0,$.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-label":x(`common.close`),className:`absolute inset-0 cursor-default`,onClick:()=>K()}),(0,$.jsxs)(`div`,{ref:de,onKeyDown:pe,role:`menu`,"aria-label":G.title,"data-testid":`sidebar-session-menu`,className:`absolute overflow-y-auto rounded-xl border border-black/4 bg-surface-overlay p-1 shadow-lv3 animate-scale-in dark:border-white/6`,style:{top:W.top,left:W.left,width:208,maxHeight:340},children:[(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{K(),he(G)},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,$.jsx)(ie,{className:`h-3.5 w-3.5 shrink-0`}),x(`chat.session.openNewTab`)]}),(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:e=>{K(),l(G,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,$.jsx)(Te,{className:`h-3.5 w-3.5 shrink-0`}),x(`chat.session.renameChat`)]}),m&&(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{K(),m(G.id,!G.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:[G.pinned?(0,$.jsx)(Je,{className:`h-3.5 w-3.5 shrink-0`}):(0,$.jsx)(Se,{className:`h-3.5 w-3.5 shrink-0`}),G.pinned?x(`chat.session.unpinChat`):x(`chat.session.pinChat`)]}),!G.shared&&!G.isPrivate&&(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{K(),le(G)},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,$.jsx)(z,{className:`h-3.5 w-3.5 shrink-0`}),x(`chat.session.shareChat`)]}),p&&(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:e=>{K(),p(G.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,$.jsx)(at,{className:`h-3.5 w-3.5 shrink-0`}),x(`chat.session.archiveChat`)]}),y&&h.length>0&&(0,$.jsxs)(`div`,{className:`mt-1 border-t border-black/6 pt-1 dark:border-white/[0.07]`,children:[(0,$.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,$.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{K(),y(G.id,e.id)},className:X(`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`,G.folderId===e.id&&`text-primary-600 dark:text-primary-400`),children:[(0,$.jsx)(ke,{className:`h-3.5 w-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.name})]},e.id)),G.folderId&&(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{K(),y(G.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,$.jsx)(We,{className:`h-3.5 w-3.5 shrink-0`}),x(`chat.session.folder.remove`)]})]}),(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:e=>{K(),f(G.id,e)},className:`mt-1 flex w-full items-center gap-2.5 rounded-lg border-t border-black/6 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,$.jsx)(nt,{className:`h-3.5 w-3.5 shrink-0`}),x(`chat.session.deleteChat`)]})]})]}),document.body),U&&(0,$.jsx)(Qt,{resourceType:`session`,resourceId:U.id,resourceLabel:U.title,onClose:()=>le(null)}),D&&(0,Xn.createPortal)((0,$.jsxs)(`div`,{className:`fixed inset-0 z-80 sm:hidden`,children:[(0,$.jsx)(`button`,{type:`button`,className:`absolute inset-0 bg-black/35 backdrop-blur-xs`,onClick:()=>T(null),"aria-label":x(`common.close`)}),(0,$.jsxs)($n,{onClose:()=>T(null),"aria-label":x(`palette.actions`),className:`absolute inset-x-3 bottom-3 rounded-2xl border border-black/8 bg-surface p-2 shadow-[0_20px_70px_rgba(0,0,0,0.3)] dark:border-white/9 dark:bg-dark-100`,"data-testid":`sidebar-session-actions-sheet`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-2 pb-2 pt-1`,children:[(0,$.jsx)(`p`,{className:`min-w-0 truncate text-sm font-semibold text-gray-900 dark:text-dark-900`,children:D.title}),(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>T(null),className:`h-9 w-9 shrink-0 rounded-xl p-0`,title:x(`common.close`),"aria-label":x(`common.close`),children:(0,$.jsx)(We,{className:`h-4 w-4`})})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:e=>{T(null),l(D,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,$.jsx)(Te,{className:`h-4 w-4 shrink-0`}),x(`chat.session.renameChat`)]}),m&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{T(null),m(D.id,!D.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:[D.pinned?(0,$.jsx)(Je,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Se,{className:`h-4 w-4 shrink-0`}),D.pinned?x(`chat.session.unpinChat`):x(`chat.session.pinChat`)]}),p&&(0,$.jsxs)(`button`,{type:`button`,onClick:e=>{T(null),p(D.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,$.jsx)(at,{className:`h-4 w-4 shrink-0`}),x(`chat.session.archiveChat`)]}),y&&h.length>0&&(0,$.jsxs)(`div`,{className:`mt-1 border-t border-black/6 pt-1 dark:border-white/[0.07]`,children:[(0,$.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,$.jsxs)(`button`,{type:`button`,onClick:()=>{T(null),y(D.id,e.id)},className:X(`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`,D.folderId===e.id&&`text-primary-600 dark:text-primary-400`),children:[(0,$.jsx)(ke,{className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.name})]},e.id)),D.folderId&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{T(null),y(D.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,$.jsx)(We,{className:`h-4 w-4 shrink-0`}),x(`chat.session.folder.remove`)]})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:e=>{T(null),f(D.id,e)},className:`mt-1 flex min-h-11 w-full items-center gap-3 rounded-xl border-t border-black/6 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,$.jsx)(nt,{className:`h-4 w-4 shrink-0`}),x(`chat.session.deleteChat`)]})]})]}),document.body)]})}var ar=[{id:`system`,to:`/system`,icon:_e,labelKey:`user.menu.system`},{id:`usage`,to:`/usage`,icon:Ke,labelKey:`user.menu.usageAnalytics`},{id:`evaluations`,to:`/evaluations`,icon:Ne,labelKey:`user.menu.evaluations`}];function or({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,$.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,$.jsx)(`div`,{className:`${n} bg-gray-950 dark:bg-white rounded-full flex items-center justify-center`,title:`${e.username} (${e.role})`,children:(0,$.jsx)(`span`,{className:`text-white dark:text-gray-950 ${r} font-medium`,children:e.username.charAt(0).toUpperCase()})})}function sr({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}=R(),g=(0,Q.useRef)(null),_=(0,Q.useRef)(null),v=`a[href], button:not(:disabled)`;(0,Q.useEffect)(()=>{a&&g.current?.querySelector(v)?.focus()},[a]);let y=e=>{if(!a)return;if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),_.current?.focus(),m();return}let t=g.current;if(!t||!t.contains(e.target))return;let n=Array.from(t.querySelectorAll(v));if(!n.length)return;let r=n.indexOf(document.activeElement),i;switch(e.key){case`ArrowDown`:i=(r+1)%n.length;break;case`ArrowUp`:i=(r-1+n.length)%n.length;break;case`Home`:i=0;break;case`End`:i=n.length-1;break;default:return}e.preventDefault(),n[i].focus()};if(!e||!t)return null;let b=r>0?h(`userManager.approval.notificationBadge`,{count:r}):null,x=b?`${t.username}, ${b}`:t.username,S=n?ar.filter(e=>s.includes(e.id)):[],C=()=>n&&ar.map(e=>{let t=s.includes(e.id),n=h(t?`user.menu.unpinShortcut`:`user.menu.pinShortcut`);return(0,$.jsxs)(`div`,{className:`group/shortcut relative`,children:[(0,$.jsxs)(j,{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,$.jsx)(e.icon,{className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-start`,children:h(e.labelKey)})]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>c(e.id),className:X(`absolute inset-e-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,$.jsx)(Je,{className:`h-3.5 w-3.5`}):(0,$.jsx)(Se,{className:`h-3.5 w-3.5`})})]},e.id)});return(0,$.jsx)(`div`,{className:X(`border-t border-black/4 dark:border-white/6`,`p-2`),children:i?(0,$.jsxs)(`div`,{className:`relative flex flex-col items-center gap-1`,ref:o,onKeyDown:y,children:[S.map(e=>(0,$.jsx)(j,{to:e.to,onClick:p,className:`relative flex h-9 w-9 items-center justify-center rounded-full text-ink outline-hidden 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,$.jsx)(e.icon,{className:`h-[18px] w-[18px]`})},e.id)),(0,$.jsx)(`button`,{type:`button`,onClick:u,className:`flex h-9 w-9 items-center justify-center rounded-full text-ink outline-hidden 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,$.jsx)(ve,{className:`h-[18px] w-[18px]`})}),(0,$.jsxs)(`button`,{ref:_,type:`button`,onClick:l,className:`relative flex h-9 w-9 items-center justify-center rounded-full outline-hidden transition-colors hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-primary-500`,"aria-label":x,"aria-expanded":a,"aria-haspopup":`true`,title:x,"data-testid":`sidebar-rail-user-menu-button`,children:[(0,$.jsx)(or,{user:t,size:`sm`}),r>0&&(0,$.jsx)(`span`,{"data-testid":`pending-user-notification-badge`,className:`absolute -inset-e-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-xs`,"aria-hidden":`true`,children:r>99?`99+`:r})]}),a&&(0,$.jsxs)(`div`,{ref:g,"data-testid":`sidebar-user-menu`,className:`scroll-region absolute bottom-0 inset-s-full z-70 ms-3 w-64 max-h-[calc(100dvh-1rem)] overflow-y-auto rounded-xl border border-black/4 bg-surface-overlay py-1 shadow-lv3 animate-scale-in scrollbar-thin dark:border-white/6`,children:[(0,$.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,$.jsx)(or,{user:t,size:`md`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium text-gray-900 dark:text-gray-100`,children:t.username}),(0,$.jsx)(`span`,{className:`block truncate text-xs text-gray-500 dark:text-gray-400`,children:h(`user.menu.changePicture`)})]}),(0,$.jsx)(Ze,{className:`h-4 w-4 shrink-0 text-gray-400`})]}),(0,$.jsxs)(`div`,{className:`py-1`,children:[C(),(0,$.jsx)(`div`,{className:`my-1 border-t border-gray-100 dark:border-dark-200/50`}),(0,$.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,$.jsx)(ve,{className:`h-4 w-4 shrink-0`}),h(`user.menu.settings`)]}),(0,$.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,$.jsx)(fe,{className:`h-4 w-4 shrink-0`}),h(`user.menu.logout`)]})]})]})]}):(0,$.jsxs)(`div`,{className:`relative`,ref:o,onKeyDown:y,children:[S.map(e=>(0,$.jsxs)(j,{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-hidden focus-visible:ring-2 focus-visible:ring-primary-500/30`,"data-testid":`sidebar-pinned-${e.id}`,children:[(0,$.jsx)(e.icon,{className:`h-4 w-4 shrink-0 text-ink-muted`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:h(e.labelKey)})]},e.id)),(0,$.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-hidden focus-visible:ring-2 focus-visible:ring-primary-500/30`,"data-testid":`sidebar-settings-button`,children:[(0,$.jsx)(ve,{className:`h-4 w-4 shrink-0 text-ink-muted`}),h(`user.menu.settings`)]}),(0,$.jsxs)(`button`,{ref:_,type:`button`,onClick:l,"aria-label":n?x:t.username,"aria-expanded":a,"aria-haspopup":`true`,className:`relative h-[38px] w-full rounded-xl px-2.5 hover:bg-interactive-hover transition-colors duration-150 text-start touch-manipulation outline-hidden focus-visible:ring-2 focus-visible:ring-primary-500`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(or,{user:t,size:`sm`}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[(0,$.jsx)(`p`,{className:`truncate text-sm text-ink`,children:t.username}),t.role===`admin`&&(0,$.jsx)(le,{size:11,className:`shrink-0 text-ink-subtle`})]}),(0,$.jsx)(xe,{className:X(`h-4 w-4 text-ink-subtle transition-transform duration-150 rtl:rotate-180`,a&&`rotate-90 rtl:rotate-90`)})]}),n&&r>0&&(0,$.jsx)(`span`,{"data-testid":`pending-user-notification-badge`,className:`absolute -inset-e-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-hidden":`true`,children:r>99?`99+`:r})]}),a&&(0,$.jsxs)(`div`,{ref:g,"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/4 bg-surface-overlay py-1 shadow-lv3 animate-scale-in scrollbar-thin dark:border-white/6`,children:[(0,$.jsx)(`div`,{className:`px-3 py-2 border-b border-gray-100 dark:border-dark-200/50`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(or,{user:t,size:`md`}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:t.username}),(0,$.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 truncate`,children:t.email||h(`user.profile.noEmail`)})]})]})}),(0,$.jsxs)(`div`,{className:`py-1`,children:[(0,$.jsxs)(`button`,{type:`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,$.jsx)(Ze,{className:`h-4 w-4 shrink-0`}),h(`user.menu.changePicture`)]}),C(),(0,$.jsx)(`div`,{className:`border-t border-gray-100 dark:border-dark-200/50 my-1`}),(0,$.jsxs)(`button`,{type:`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,$.jsx)(ve,{className:`h-4 w-4 shrink-0`}),h(`user.menu.settings`)]}),(0,$.jsxs)(`button`,{type:`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,$.jsx)(fe,{className:`h-4 w-4 shrink-0`}),h(`user.menu.logout`)]})]})]})]})})}var cr=Kt(`notification-bell`),lr=({items:e,loadFailed:t,onRetry:n,onClose:r,onOpenItem:i,onMarkRead:a,onMarkAllRead:o})=>{let{t:s,i18n:c}=R(),l=(0,Q.useRef)(null);return $t(l,{onClose:r}),(0,$.jsx)(`div`,{className:`fixed inset-0 z-2147483646`,onClick:r,children:(0,$.jsxs)(`div`,{ref:l,role:`dialog`,"aria-modal":`true`,"aria-label":s(`notifications.title`),tabIndex:-1,className:`absolute bottom-16 inset-s-4 flex max-h-[70vh] w-80 flex-col overflow-hidden rounded-2xl border border-black/8 bg-white shadow-[0_18px_60px_rgba(0,0,0,0.22)] dark:border-white/10 dark:bg-dark-25`,onClick:e=>e.stopPropagation(),"data-testid":`notification-panel`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-black/6 px-3 py-2 dark:border-white/6`,children:[(0,$.jsx)(`span`,{className:`flex-1 text-xs font-semibold uppercase tracking-wide text-ink-muted`,children:s(`notifications.title`)}),(0,$.jsx)(`button`,{type:`button`,onClick:o,className:`rounded-md p-1 text-ink-muted hover:text-ink`,title:s(`notifications.markAllRead`),"aria-label":s(`notifications.markAllRead`),"data-testid":`notification-mark-all`,children:(0,$.jsx)($e,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`button`,{type:`button`,onClick:r,className:`rounded-md p-1 text-ink-muted hover:text-ink`,title:s(`common.close`),"aria-label":s(`common.close`),children:(0,$.jsx)(We,{className:`h-3.5 w-3.5`})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto scrollbar-thin`,children:t&&e===null?(0,$.jsxs)(`div`,{role:`alert`,className:`px-4 py-6 text-center`,children:[(0,$.jsx)(`p`,{className:`text-xs text-ink-muted`,children:s(`notifications.loadFailed`)}),(0,$.jsx)(`button`,{type:`button`,onClick:n,className:`mt-2 rounded-md px-2 py-1 text-xs font-medium text-ink underline underline-offset-2 hover:bg-black/4 dark:hover:bg-white/6`,"data-testid":`notification-retry`,children:s(`common.retry`)})]}):e===null?(0,$.jsxs)(`div`,{role:`status`,className:`py-6`,children:[(0,$.jsx)(K,{className:`mx-auto h-4 w-4 animate-spin text-ink-muted motion-reduce:animate-none`}),(0,$.jsx)(`span`,{className:`sr-only`,children:s(`common.loading`)})]}):e.length===0?(0,$.jsx)(`p`,{className:`py-8 text-center text-xs text-ink-muted`,children:s(`notifications.empty`)}):e.map(e=>(0,$.jsxs)(`div`,{className:X(`group flex items-start border-b border-black/4 last:border-b-0 hover:bg-black/3 dark:border-white/4 dark:hover:bg-white/4`,!e.readAt&&`bg-primary-500/4`),"data-testid":`notification-item`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>i(e),className:`flex min-w-0 flex-1 items-start gap-2 px-3 py-2.5 text-start`,children:[(0,$.jsx)(`span`,{className:X(`mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full`,e.readAt?`bg-transparent`:`bg-primary-500`),"aria-hidden":`true`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[!e.readAt&&(0,$.jsx)(`span`,{className:`sr-only`,children:s(`notifications.unread`)}),(0,$.jsx)(`span`,{className:`block text-[13px] font-medium leading-snug text-ink`,children:e.title}),e.body&&(0,$.jsx)(`span`,{className:`mt-0.5 block truncate text-[12px] text-ink-muted`,children:e.body}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-[11px] text-ink-muted`,children:jt(e.createdAt,c.language)})]})]}),!e.readAt&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>a(e),className:`me-2 mt-1.5 hidden rounded-sm p-1.5 text-ink-muted hover:text-success-700 focus-visible:block group-focus-within:block group-hover:block pointer-coarse:block dark:hover:text-success-400`,title:s(`notifications.markRead`),"aria-label":s(`notifications.markRead`),"data-testid":`notification-mark-read`,children:(0,$.jsx)(Oe,{className:`h-3.5 w-3.5`})})]},e.id))})]})})},ur=({sidebarCompact:e})=>{let{t}=R(),n=ee(),[r,i]=(0,Q.useState)(0),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(!1),d=(0,Q.useCallback)(()=>{Pt.unreadCount().then(e=>{e.success&&e.data&&i(e.data.count)}).catch(e=>cr.debug(`Unread poll failed:`,e))},[]);(0,Q.useEffect)(()=>{d();let e=window.setInterval(d,6e4),t=new AbortController;return en({path:`/notifications/events`,signal:t.signal,onEvent:()=>d()}),()=>{window.clearInterval(e),t.abort()}},[d]);let f=()=>{u(!1),Pt.list({limit:50}).then(e=>{e.success&&e.data?c(e.data):u(!0)}).catch(e=>{cr.error(`Failed to load notifications:`,e),u(!0)})},p=()=>{o(!0),f()},m=e=>{Pt.markRead(e.id).then(d),o(!1),e.href&&n(e.href)},h=e=>{Pt.markRead(e.id).then(()=>{d(),c(t=>t&&t.map(t=>t.id===e.id?{...t,readAt:Date.now()}:t))})},g=()=>{Pt.markAllRead().then(()=>{d(),c(e=>e&&e.map(e=>({...e,readAt:e.readAt??Date.now()})))})},_=r>0?t(`notifications.titleWithUnread`,{unread:r}):t(`notifications.title`);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>a?o(!1):p(),"aria-expanded":a,className:X(`relative flex items-center gap-2 rounded-lg text-[13px] text-gray-600 hover:bg-black/4 dark:text-dark-700 dark:hover:bg-white/6`,e?`mx-auto h-9 w-9 justify-center`:`mx-2 px-2 py-1.5`),title:_,"aria-label":_,"data-testid":`notification-bell`,children:[(0,$.jsx)(He,{className:`h-4 w-4 shrink-0`}),!e&&(0,$.jsx)(`span`,{children:t(`notifications.title`)}),r>0&&(0,$.jsx)(`span`,{className:X(`rounded-full bg-primary-600 px-1.5 text-[10px] font-semibold leading-4 text-white`,e&&`absolute -inset-e-0.5 -top-0.5`),"data-testid":`notification-unread-badge`,"aria-hidden":`true`,children:r>99?`99+`:r})]}),a&&(0,Xn.createPortal)((0,$.jsx)(lr,{items:s,loadFailed:l,onRetry:f,onClose:()=>o(!1),onOpenItem:m,onMarkRead:h,onMarkAllRead:g}),document.body)]})};function dr(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 fr({preview:e}){let{t}=R(),{task:n}=e,r=tn[n.status],i=t(r.labelKey,{defaultValue:r.label});return(0,$.jsxs)(Zn,{top:e.top,left:e.left,title:n.title||t(`work.tasks.untitled`,{defaultValue:`Untitled task`}),timestamp:n.updatedAt,children:[(0,$.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[11px] leading-snug text-gray-600 dark:text-dark-700`,children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,className:X(`h-2 w-2 shrink-0 rounded-full`,r.animated&&`animate-pulse`),style:{backgroundColor:r.color}}),i]}),n.statusBlurb&&(0,$.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,$.jsx)(`p`,{className:`mt-1.5 truncate font-mono text-[10px] text-gray-400 dark:text-dark-500`,children:rn(n.model,n.providerType)}),n.hostPath&&(0,$.jsx)(`p`,{className:`mt-1 truncate font-mono text-[10px] text-gray-400 dark:text-dark-500`,title:n.hostPath,children:n.hostPath})]})}var pr=208,mr=180;function hr({tasks:e,personas:t,currentTaskId:n,loading:r,actionLoading:i,sidebarCompact:a,onSelectTask:o,onDeleteTask:s,onExpandSidebar:c}){let{t:l,i18n:u}=R(),d=e.filter(e=>e.isAgent===!0),f=e.filter(e=>e.isAgent!==!0),p=d,[m,h]=(0,Q.useState)(null),g=(0,Q.useRef)(null),[_,v]=(0,Q.useState)(null),y=_?e.find(e=>e.id===_)??null:null;(0,Q.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,Q.useState)(null),w=S?e.find(e=>e.id===S.taskId)??null:null,{menuRef:ee,setTrigger:T,onKeyDown:E,closeMenu:D}=er(S?.taskId,()=>C(null)),O=(e,t)=>{if(t.stopPropagation(),b(),S?.taskId===e.id){D();return}T(t.currentTarget);let n=t.currentTarget.getBoundingClientRect();C({taskId:e.id,top:Math.max(8,Math.min(n.bottom+6,window.innerHeight-mr-8)),left:Math.max(8,Math.min(n.right-pr,window.innerWidth-pr-8))})},k=e=>{let t=window.location.protocol===`file:`?`${window.location.pathname}#/work/${e.id}`:`/work/${e.id}`;window.open(t,`_blank`,`noopener,noreferrer`)},A=e=>e.title||l(`work.tasks.untitled`,{defaultValue:`Untitled task`}),j=e=>{let r=n===e.id,i=tn[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=dr(e,r),p=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{dir:`auto`,className:X(`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:jt(e.updatedAt,u.language)}),(0,$.jsx)(q,{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,$.jsx)(Re,{className:`h-4 w-4`})}),(0,$.jsx)(`div`,{className:X(`hidden shrink-0`,`sm:group-hover:block sm:group-focus-within:block`,s&&`sm:block`),children:(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:t=>O(e,t),className:X(`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,$.jsx)(Re,{className:`h-4 w-4`})})})]});return(0,$.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:X(`group relative cursor-pointer rounded-lg px-2 transition-colors duration-150 outline-hidden 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,$.jsxs)(`div`,{className:`flex w-full items-center gap-2.5 py-1.5`,children:[(0,$.jsxs)(`span`,{className:`relative shrink-0`,children:[(0,$.jsx)(`img`,{src:d?Bt(d,64):Vt(A(e),64),alt:``,"aria-hidden":`true`,"data-testid":`sidebar-work-agent-avatar`,onError:t=>zt(t.currentTarget,d?.name??A(e),64),className:`h-8 w-8 rounded-lg object-cover`}),(0,$.jsx)(`span`,{"aria-hidden":`true`,"data-testid":`sidebar-work-task-status`,"data-status-label":a,title:a,className:X(`absolute -bottom-0.5 -inset-e-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,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsxs)(`button`,{type:`button`,dir:`auto`,className:X(`min-w-0 flex-1 truncate rounded-md text-start text-sm leading-5 text-ink outline-hidden focus-visible:ring-2 focus-visible:ring-primary-500/30`,f&&`font-medium`),title:A(e),"aria-current":r?`page`:void 0,children:[A(e),(0,$.jsx)(`span`,{className:`sr-only`,children:l(`work.tasks.status`,{defaultValue:`Status: {{status}}`,status:a})})]}),f&&(0,$.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,$.jsx)(`p`,{dir:`auto`,"data-testid":`sidebar-work-agent-blurb`,className:X(`truncate text-[11px] leading-4`,f?`text-ink-muted`:`text-ink-subtle`),title:e.statusBlurb||a,children:e.statusBlurb||a})]})]}):(0,$.jsxs)(`div`,{className:`flex h-8 w-full items-center`,children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,"data-testid":`sidebar-work-task-status`,"data-status-label":a,title:a,className:X(`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,$.jsxs)(`button`,{type:`button`,dir:`auto`,className:`min-w-0 flex-1 truncate rounded-md py-1 text-start text-sm leading-5 text-ink outline-hidden focus-visible:ring-2 focus-visible:ring-primary-500/30`,title:A(e),"aria-current":r?`page`:void 0,children:[A(e),(0,$.jsx)(`span`,{className:`sr-only`,children:l(`work.tasks.status`,{defaultValue:`Status: {{status}}`,status:a})})]}),p]})},e.id)};return(0,$.jsxs)(Qn,{"data-testid":`sidebar-work-task-scroll-region`,compact:a,compactClassName:p.length===0?`md:hidden`:void 0,children:[(0,$.jsxs)(`div`,{className:a?`p-0`:`px-3 py-3`,children:[!a&&e.length>0&&(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between px-1`,children:[(0,$.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,$.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,$.jsxs)(`div`,{className:`flex flex-col items-center gap-[4px]`,children:[(0,$.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:X(Gn,`relative md:hidden`),children:[(0,$.jsx)(qe,{className:`h-[18px] w-[18px]`}),e.length>0&&(0,$.jsx)(`span`,{className:`absolute -inset-e-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-md bg-primary-600 px-1 text-[9px] font-semibold tabular-nums text-white shadow-xs`,children:e.length>99?`99+`:e.length})]}),(0,$.jsx)(`div`,{"data-testid":`sidebar-compact-work-agent-list`,className:`flex w-full flex-col items-center gap-[4px] empty:hidden`,children:p.map(e=>{let r=n===e.id,i=tn[e.status],a=l(i.labelKey,{defaultValue:i.label}),s=A(e),c=e.personaId?t[e.personaId]:void 0,u=dr(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,$.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:X(Gn,`relative`,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`:void 0),children:[r&&(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`absolute -inset-s-2 h-5 w-0.5 rounded-full bg-primary-500 shadow-[0_0_12px_rgb(var(--color-primary-500)/0.55)]`}),(0,$.jsx)(`img`,{src:c?Bt(c,64):Vt(s,64),alt:``,"aria-hidden":`true`,"data-testid":`sidebar-compact-work-agent-avatar`,onError:e=>zt(e.currentTarget,c?.name??s,64),className:`h-9 w-9 rounded-lg object-cover`}),u&&(0,$.jsx)(`span`,{"aria-hidden":`true`,"data-testid":`sidebar-compact-work-agent-unread`,className:`absolute inset-e-1.5 top-1.5 h-2 w-2 rounded-full bg-primary-500 ring-2 ring-gray-100 dark:ring-dark-50`}),(0,$.jsx)(`span`,{"aria-hidden":`true`,"data-testid":`sidebar-compact-work-agent-status`,"data-status":e.status,className:X(`absolute bottom-1.5 inset-e-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,$.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`flex items-center justify-center py-10 text-gray-400 dark:text-dark-500`,children:[(0,$.jsx)(K,{"aria-hidden":`true`,className:`h-5 w-5 animate-spin`}),(0,$.jsx)(`span`,{className:`sr-only`,children:l(`work.tasks.loading`,{defaultValue:`Loading Work tasks`})})]}):e.length===0?(0,$.jsxs)(`div`,{className:`py-8 text-center px-2`,children:[(0,$.jsx)(`div`,{className:`mx-auto mb-3 flex items-center justify-center rounded-xl bg-white/70 ring-1 ring-black/4 dark:bg-dark-200 dark:ring-white/5 h-12 w-12`,children:(0,$.jsx)(qe,{className:`text-gray-400 dark:text-gray-500 h-5 w-5`})}),(0,$.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,$.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,$.jsx)(`div`,{"data-testid":`sidebar-work-task-list`,className:`space-y-0.5`,children:d.length>0?(0,$.jsxs)($.Fragment,{children:[d.map(j),f.length>0&&(0,$.jsxs)(`div`,{className:`mb-1 mt-4! flex items-center justify-between px-1`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-medium text-ink-subtle`,children:l(`work.tasks.title`,{defaultValue:`Work tasks`})}),(0,$.jsx)(`span`,{className:`text-[10px] font-medium tabular-nums text-gray-400 dark:text-dark-500`,children:f.length})]}),f.map(j)]}):e.map(j)})]}),m&&(0,$.jsx)(fr,{preview:m}),S&&w&&(0,Xn.createPortal)((0,$.jsxs)(`div`,{className:`fixed inset-0 z-75 hidden sm:block`,children:[(0,$.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-label":l(`common.close`),className:`absolute inset-0 cursor-default`,onClick:()=>D()}),(0,$.jsxs)(`div`,{ref:ee,onKeyDown:E,role:`menu`,"aria-label":A(w),"data-testid":`sidebar-work-task-menu`,className:`absolute overflow-y-auto rounded-xl border border-black/4 bg-surface-overlay p-1 shadow-lv3 animate-scale-in dark:border-white/6`,style:{top:S.top,left:S.left,width:pr,maxHeight:mr},children:[(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{D(),k(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,$.jsx)(ie,{className:`h-3.5 w-3.5 shrink-0`}),l(`chat.session.openNewTab`)]}),(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,disabled:i,"data-testid":`sidebar-work-task-delete`,onClick:()=>{D(),s(w)},className:`mt-1 flex w-full items-center gap-2.5 rounded-lg border-t border-black/6 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,$.jsx)(nt,{className:`h-3.5 w-3.5 shrink-0`}),l(`work.tasks.delete`,{defaultValue:`Delete task`})]})]})]}),document.body),y&&(0,Xn.createPortal)((0,$.jsxs)(`div`,{className:`fixed inset-0 z-80 sm:hidden`,children:[(0,$.jsx)(`button`,{type:`button`,className:`absolute inset-0 bg-black/35 backdrop-blur-xs`,onClick:()=>v(null),"aria-label":l(`common.close`)}),(0,$.jsxs)($n,{onClose:()=>v(null),"aria-label":l(`palette.actions`),className:`absolute inset-x-3 bottom-3 rounded-2xl border border-black/8 bg-surface p-2 shadow-[0_20px_70px_rgba(0,0,0,0.3)] dark:border-white/9 dark:bg-dark-100`,"data-testid":`sidebar-work-task-actions-sheet`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-2 pb-2 pt-1`,children:[(0,$.jsx)(`p`,{className:`min-w-0 truncate text-sm font-semibold text-gray-900 dark:text-dark-900`,children:A(y)}),(0,$.jsx)(q,{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,$.jsx)(We,{className:`h-4 w-4`})})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{v(null),k(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,$.jsx)(ie,{className:`h-4 w-4 shrink-0`}),l(`chat.session.openNewTab`)]}),(0,$.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,$.jsx)(nt,{className:`h-4 w-4 shrink-0`}),l(`work.tasks.delete`,{defaultValue:`Delete task`})]})]})]}),document.body)]})}function gr(e){let{t}=R(),n=(0,Q.useRef)(null),r=v({queryKey:[`users`,`pending-approvals`],enabled:e,queryFn:async()=>{let e=await Lt.getPendingApprovals();if(!e.success||!e.data)throw Error(e.message||`Could not load pending accounts`);return e.data},refetchInterval:6e4,refetchOnWindowFocus:!0});return(0,Q.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&&B(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 _r(e){let{t}=R(),n=(0,Q.useRef)(null),r=v({queryKey:[`automations`,`runs-summary`],enabled:e,queryFn:async()=>{let e=await Rt.getRunsSummary();if(!e.success||!e.data)throw Error(e.error||`Could not load automation runs`);return e.data},refetchInterval:6e4,refetchOnWindowFocus:!0});return(0,Q.useEffect)(()=>{if(!r.data)return;let e=n.current,i=r.data.unseenCount;e!==null&&i>e&&B(t(`automations.finishedNotification`,{n:i}),{icon:`⚡`}),n.current=i},[r.data,t]),{...r,unseenRunCount:r.data?.unseenCount??0}}var vr=e=>typeof e==`string`&&e.startsWith(`/`)&&!e.startsWith(`//`)&&!e.includes(`\\`),yr=!1,br=()=>{yr=!0},xr=()=>yr,Sr=()=>{yr=!1},Cr=e=>{if(yr)return`/`;let t=e?.from;if(!t||!vr(t.pathname)||t.pathname===`/login`)return`/`;let n=typeof t.search==`string`?t.search:``,r=typeof t.hash==`string`?t.hash:``;return`${t.pathname}${n}${r}`},wr=Kt(`components:sidebar`),Tr=Q.lazy(()=>Z(()=>import(`../js/SettingsModal-CfjxNSmJ.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,29,30]))),Er=({isOpen:e,onClose:t,className:n})=>{let{t:r}=R(),i=M(),a=ee(),{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}=L(),S=bt(e=>e.tasks),C=bt(e=>e.loadingTasks),w=bt(e=>e.actionLoading),T=bt(e=>e.deleteTask),{user:E,isAdmin:D,systemInfo:O,setUser:k,canUseWork:A,canUseStrands:j}=J(),{theme:N,sidebarCompact:P,toggleSidebarCompact:F,isGenerating:I,pinnedAdminShortcuts:te,toggleAdminShortcut:ne}=Y(),re=b??(I&&y&&sn(y.title)?y.id:null),z=D(),{pendingApprovalCount:ie}=gr(!!(E&&z&&O?.requiresAuth)),{unseenRunCount:V}=_r(!!(E||O?.requiresAuth===!1)),[ae,oe]=(0,Q.useState)(null),[se,H]=(0,Q.useState)(``),[ce,U]=(0,Q.useState)(!1),[le,W]=(0,Q.useState)(!1),[ue,G]=(0,Q.useState)(!1),[de,fe]=(0,Q.useState)(``),[pe,K]=(0,Q.useState)(!1),me=(0,Q.useRef)(null),he=(0,Q.useRef)(null),ge=i.pathname.match(/^\/c\/([^/]+)$/)?.[1]||y?.id,_e=()=>{window.innerWidth<768&&!P&&F()},ve=()=>{Jt(`selection`),F()},ye=()=>{let{setCurrentSession:e}=L.getState();qt(),e(null),sessionStorage.setItem(`forceWelcomeScreen`,`true`)};(0,Q.useEffect)(()=>{let e=e=>{me.current&&!me.current.contains(e.target)&&W(!1)};if(le)return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[le]),(0,Q.useEffect)(()=>{let t=t=>{he.current&&!he.current.contains(t.target)&&window.innerWidth<768&&e&&!P&&F()},n=e=>{e.key!==`Escape`||e.defaultPrevented||document.querySelector(`[role="dialog"][aria-modal="true"]`)||F()};if(e&&!P&&window.innerWidth<768)return document.addEventListener(`mousedown`,t),document.addEventListener(`keydown`,n),()=>{document.removeEventListener(`mousedown`,t),document.removeEventListener(`keydown`,n)}},[e,P,F]);let be=async()=>{K(!0);try{let e=await Lt.updateMyAvatar(de||null);e.success&&e.data?(k(e.data),B.success(r(`user.avatar.updated`)),G(!1)):B.error(e.message||r(`user.avatar.updateFailed`))}catch(e){wr.error(`Failed to update avatar:`,e),B.error(r(`user.avatar.updateFailed`))}finally{K(!1)}},xe=()=>{Jt(`impact`),ye(),a(`/chat`,{replace:!0}),_e()},Se=()=>{Jt(`impact`),bt.getState().clearError(),a(`/work`),_e()},Ce=e=>{Jt(`selection`),a(`/c/${e.id}`,{replace:!0}),_e()},we=e=>{Jt(`selection`),a(`/work/${e}`,{replace:!0}),_e()},Te=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`})}))){Jt(`warning`);try{await T(e.id),St(e.id),zn.getState().closeTab(`work:${e.id}`),Le===e.id&&a(`/work`,{replace:!0,state:{deletedWorkTaskId:e.id}})}catch(e){wr.error(`Failed to delete Work task:`,e),B.error(r(`work.toasts.deleteFailed`,{defaultValue:`Could not delete this Work task.`}))}}},Ee=async(e,t)=>{if(t.stopPropagation(),wr.debug(`Delete session clicked:`,e),window.confirm(r(`chat.session.deleteConfirm`))){Jt(`warning`);try{wr.debug(`Attempting to delete session:`,e);let t=ge===e;if(await s(e),L.getState().sessions.some(t=>t.id===e))return;if(wr.debug(`Session deleted successfully`),zn.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){wr.error(`Error deleting session:`,e),B.error(r(`chat.toasts.deleteFailed`))}}};(0,Q.useEffect)(()=>{f()},[f]);let De=async(e,t)=>{t.stopPropagation();try{if(await l(e,!0),!L.getState().sessions.find(t=>t.id===e)?.archived){B.error(r(`chat.toasts.archiveFailed`));return}if(zn.getState().closeTab(`chat:${e}`),ge===e){let t=o.filter(t=>t.id!==e&&!t.archived);t.length>0?a(`/c/${t[0].id}`,{replace:!0}):a(`/`,{replace:!0})}}catch(e){wr.error(`Error archiving session:`,e),B.error(r(`chat.toasts.archiveFailed`))}},Oe=(e,t)=>{u(e,t)},ke=(e,t)=>{t.stopPropagation(),oe(e.id),H(e.title)},Ae=async e=>{se.trim()&&await c(e,se.trim()),oe(null),H(``)},je=()=>{oe(null),H(``)},Me=async()=>{br();try{await Ft.logout();let{logout:e}=J.getState();e(),a(`/login`),B.success(r(`auth.logout.success`))}catch(e){wr.error(`Logout error:`,e);let{logout:t}=J.getState();t(),a(`/login`)}},Ne=()=>{U(!0),_e()},Pe=e=>{fe(e),G(!0)},Fe=window.location.protocol===`file:`,Ie=i.pathname===`/work`||i.pathname.startsWith(`/work/`),Le=i.pathname.match(/^\/work\/([^/]+)$/)?.[1]||null,Re=i.pathname===`/`||i.pathname===`/chat`||i.pathname.startsWith(`/c/`),ze=A();return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`aside`,{ref:he,"aria-label":r(`sidebar.ariaLabel`),inert:!e,"data-testid":`sidebar`,"data-app-sidebar":``,className:X(`fixed inset-y-0 inset-s-0 z-50 border-0 [box-shadow:none] transform transition-[width,transform,background-color] duration-200 ease-out motion-reduce:transition-none`,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`,N.mode===`celestial`?`bg-sidebar/30 backdrop-blur-xl md:bg-transparent md:backdrop-filter-none`:`bg-sidebar`,`overscroll-behavior-contain`,n),style:{WebkitOverflowScrolling:`touch`},children:[Fe&&(0,$.jsx)(`div`,{className:`absolute top-0 inset-s-16 inset-e-0 h-8 z-60`,style:{WebkitAppRegion:`drag`}}),(0,$.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,$.jsxs)(`div`,{"data-testid":`sidebar-browse-scroll-region`,className:X(`min-h-0 flex-1 *:transition-none`,P?`scroll-region flex flex-col gap-[4px] pb-[8px] scrollbar-none [&::-webkit-scrollbar]:hidden *:w-16`:`flex flex-col overflow-hidden *:w-72 max-sm:*:w-[calc(100vw-4.5rem)] max-sm:*:max-w-80`),children:[(0,$.jsx)(qn,{sidebarCompact:P,isElectron:Fe,showWork:ze,activeMode:Ie?`work`:Re?`chat`:null,selectedModel:_,modelCount:v.length,onToggleCompact:ve,onStartWork:Se,onCreateSession:xe}),(0,$.jsx)(Yn,{sidebarCompact:P,activePath:i.pathname,showStrands:j(),unseenRunCount:V,onMobileNavigate:_e}),Ie&&ze?(0,$.jsx)(hr,{tasks:S,personas:x,currentTaskId:Le,loading:C,actionLoading:w,sidebarCompact:P,onSelectTask:we,onDeleteTask:e=>void Te(e),onExpandSidebar:ve}):(0,$.jsx)(ir,{sessions:o.filter(e=>!e.archived),personas:x,currentSessionId:ge,generatingTitleForSession:re,sidebarCompact:P,editingSessionId:ae,editingTitle:se,onEditingTitleChange:H,onSelectSession:Ce,onStartEditing:ke,onSaveEdit:Ae,onCancelEdit:je,onDeleteSession:Ee,onArchiveSession:De,onTogglePinSession:Oe,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:ve}),P&&(0,$.jsx)(Kn,{})]}),(0,$.jsxs)(`div`,{className:X(`shrink-0 transition-none`,P&&`w-16`),children:[(0,$.jsx)(ur,{sidebarCompact:P}),(0,$.jsx)(sr,{requiresAuth:O?.requiresAuth,user:E,isAdmin:z,pendingApprovalCount:ie,sidebarCompact:P,userMenuOpen:le,userMenuRef:me,pinnedShortcuts:te,onToggleShortcutPin:ne,onToggleUserMenu:()=>W(e=>!e),onOpenSettings:Ne,onOpenAvatar:Pe,onLogout:Me,onMobileNavigate:_e,onCloseUserMenu:()=>W(!1)})]})]})]}),ce&&(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Tr,{isOpen:ce,onClose:()=>U(!1)})}),(0,$.jsx)(Bn,{open:ue,value:de,saving:pe,onChange:fe,onClose:()=>G(!1),onSave:be})]})},Dr=({children:e,requireAuth:t=!0,requireAdmin:n=!1,requireWork:r=!1,requireStrands:i=!1})=>{let{isAuthenticated:a,user:o,systemInfo:s,isLoading:c,canUseWork:l,canUseStrands:u}=J(),d=M(),{t:f}=R();return c?(0,$.jsxs)(`div`,{role:`status`,className:`min-h-screen flex items-center justify-center bg-gray-50 dark:bg-dark-50`,children:[(0,$.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 motion-reduce:animate-none`}),(0,$.jsx)(`span`,{className:`sr-only`,children:f(`common.loading`)})]}):i&&!u()?(0,$.jsx)(C,{to:`/`,replace:!0}):s&&!s.requiresAuth?(0,$.jsx)($.Fragment,{children:e}):t&&!a?(0,$.jsx)(C,{to:`/login`,replace:!0,state:xr()?void 0:{from:d}}):n&&(!o||o.role!==`admin`)||r&&!l()?(0,$.jsx)(C,{to:`/`,replace:!0}):(0,$.jsx)($.Fragment,{children:e})},Or=Kt(`components:error-boundary`),kr=({error:e})=>{let{t}=R();return(0,$.jsx)(`div`,{className:`flex h-full min-h-[60vh] items-center justify-center p-4 text-ink`,children:(0,$.jsx)(`div`,{role:`alert`,className:`w-full max-w-md rounded-xl border border-line bg-surface-raised shadow-card`,children:(0,$.jsxs)(`div`,{className:`p-6 text-center`,children:[(0,$.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-xl bg-error-500/10 text-error-600 dark:text-error-400`,children:(0,$.jsx)(Me,{className:`h-6 w-6`})}),(0,$.jsx)(`h1`,{className:`mb-2 text-xl font-semibold text-ink`,children:t(`errorBoundary.title`)}),(0,$.jsx)(`p`,{className:`mb-5 text-sm leading-6 text-ink-muted`,children:t(`errorBoundary.description`)}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:justify-center`,children:[(0,$.jsxs)(q,{type:`button`,onClick:()=>window.location.reload(),children:[(0,$.jsx)(pe,{className:`h-4 w-4`}),t(`errorBoundary.tryAgain`)]}),(0,$.jsxs)(q,{type:`button`,variant:`secondary`,onClick:()=>{window.location.protocol===`file:`?(window.location.hash=`#/`,window.location.reload()):window.location.assign(`/`)},children:[(0,$.jsx)(be,{className:`h-4 w-4`}),t(`errorBoundary.goHome`)]})]}),!1]})})})},Ar=()=>{let e=O();(0,Q.useEffect)(()=>{Or.error(`Route error screen caught an error:`,e)},[e]);let t=e instanceof Error?e:T(e)?Error(`${e.status} ${e.statusText}`):Error(String(e));return(0,$.jsx)(kr,{error:t})},jr=class extends Q.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidUpdate(e){this.state.hasError&&e.resetKey!==this.props.resetKey&&this.setState({hasError:!1,error:void 0})}componentDidCatch(e,t){Or.error(`ErrorBoundary caught an error:`,e,t)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:(0,$.jsx)(kr,{error:this.state.error}):this.props.children}},Mr=`libre-webui:whats-new-seen`;function Nr(){let e={version:`0.45.0`,date:`2026-11-16`,body:`Decision models arrive: typed yes/no, choice, and score answers with
3
- probabilities from Ollama, llama.cpp, Baseten, OpenRouter, OpenAI, and Gemini,
4
- in Chat and through a new Decisions API. parse5 picks up nineteen security
5
- fixes for the web page reader.
6
-
7
- ### ✨ New Features
8
-
9
- - **Decision models**: models that answer questions about an input with
10
- probabilities instead of writing text now work in Libre WebUI. It finds them
11
- on Ollama (installed models with the \`decision\` capability, such as Nimble,
12
- Tev, Clef, and Kev), llama.cpp, Baseten, OpenRouter, OpenAI
13
- (\`gpt-6-luna-decisions\`), and Gemini (\`gemini-decision-1\`), and talks to each
14
- through its own API: System One, OpenAI Decisions, or Gemini Decisions. They
15
- carry a **Decision** badge in the model picker, the Ollama library has a
16
- **Decision** category, and provider keys you already saved work for them.
17
- - **Decision questions in Chat**: pick a decision model, click **Set
18
- questions**, and add yes/no, choice, or score questions. Each message is then
19
- judged against them, and the reply shows every answer with its probability
20
- and the full spread. Models that read images can judge an attached image.
21
- Without questions, a chat works like \`ollama run\`: the first message is the
22
- state, each line after it is a yes/no question, and \`/clear\` starts over.
23
- The questions are saved with the chat.
24
- - **Decisions API**: \`POST /api/decisions\` answers one request for scripts and
25
- API tokens with the \`chat\` scope, in the same answer shape from every
26
- provider, and \`GET /api/decisions/models\` lists the decision models an
27
- account can reach.
28
- - **Decision models access**: decision models are for administrators until an
29
- administrator opens them to everyone with the **Decision models** card in
30
- User Management. \`DECISION_MODELS_ACCESS_MODE\` pins the choice. Provider
31
- decision calls appear on the Provider Usage page with their tokens.
32
-
33
- ### 🔧 Improvements
34
-
35
- - **Decision chats stay simple**: web search, tools, thinking, and model
36
- comparison are hidden while a decision model is selected, and titles,
37
- follow-up suggestions, and context compaction never call one.
38
-
39
- ### 🐛 Bug Fixes
40
-
41
- - **Chat lists without decision-only models**: OpenRouter and llama.cpp model
42
- lists no longer offer models that only make decisions as chat models, which
43
- failed when picked.
44
-
45
- ### 🔒 Security
46
-
47
- - **Dependency updates**: parse5 8.1.1, which reads fetched web pages, fixes
48
- nineteen issues in its HTML parser, including crashes and runaway parse time
49
- from a few bytes of input. i18next 27, react-i18next 18, the Strands harness
50
- 0.4, Vite 8.3.8, zustand 5.1, framer-motion, TanStack Query, lucide-react,
51
- Tailwind CSS 4.3.5, better-sqlite3 13.1, ws 8.23, and the AWS SDK are also
52
- current, and \`npm audit\` reports no vulnerabilities.
53
-
54
- ### 📚 Documentation
55
-
56
- - **Decision Models**: a new page covers where decision models come from,
57
- using them in Chat, the Decisions API, access, and limits. Provider
58
- Connections, Plugin Architecture, Environment Variables, and Public API
59
- mention them.`},[t,n]=(0,Q.useState)(()=>{if(!e||typeof window>`u`)return!1;try{return window.localStorage.getItem(Mr)!==e.version}catch{return!1}});return(0,Q.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(Mr,e.version)}catch{}},notes:e}}var Pr=({message:e,onDismiss:t,className:n})=>{let[r,i]=(0,Q.useState)(!1),{t:a}=R(),o=e??a(`demoMode.defaultMessage`);return r?null:(0,$.jsx)(`div`,{className:X(`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,$.jsxs)(`div`,{className:`flex items-center justify-between max-w-6xl mx-auto gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[(0,$.jsx)(`div`,{className:`shrink-0`,children:(0,$.jsx)(Ye,{className:`h-4 w-4 text-white/65 dark:text-gray-950/60`})}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col sm:flex-row sm:items-baseline sm:gap-2`,children:[(0,$.jsx)(`p`,{className:`shrink-0 text-xs font-semibold tracking-wide`,children:a(`demoMode.title`)}),(0,$.jsx)(`p`,{title:o,className:`line-clamp-2 text-xs text-white/70 dark:text-gray-950/70 sm:truncate`,children:o})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 ms-4`,children:[(0,$.jsxs)(q,{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/6 dark:hover:text-gray-950`,onClick:()=>window.open(`https://github.com/libre-webui/libre-webui`,`_blank`,`noopener,noreferrer`),title:a(`demoMode.viewOnGithub`),children:[(0,$.jsx)(ie,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only sm:not-sr-only sm:ms-1`,children:a(`demoMode.github`)})]}),(0,$.jsx)(q,{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/6 dark:hover:text-gray-950`,title:a(`demoMode.dismiss`),"aria-label":a(`demoMode.dismiss`),children:(0,$.jsx)(We,{className:`h-4 w-4`})})]})]})})},Fr=110,Ir=48,Lr=5e3,Rr=()=>{let e=7,t=()=>(e=(e*9301+49297)%233280,e/233280);return Array.from({length:Fr},(e,n)=>({id:n,x:t()*100,y:t()*78,size:1.2+t()*2.2,delay:t()*7,period:2.5+t()*4.5,bright:t()>.82}))},zr=[{id:`a`,top:16,left:-14,width:46,height:20,depth:22,drift:120,delay:0},{id:`b`,top:30,left:38,width:40,height:16,depth:16,drift:150,delay:-50},{id:`c`,top:9,left:66,width:32,height:14,depth:28,drift:95,delay:-70},{id:`d`,top:46,left:8,width:30,height:12,depth:12,drift:170,delay:-20},{id:`e`,top:22,left:84,width:26,height:12,depth:34,drift:80,delay:-110}],Br=()=>{let e=21,t=()=>(e=(e*9301+49297)%233280,e/233280);return Array.from({length:Ir},(e,n)=>({id:n,x:t()*100,size:2+t()*4,delay:-t()*14,period:9+t()*9,sway:10+t()*30}))},Vr=()=>{let e=At(e=>e.palette),t=At(e=>e.scene),n=At(e=>e.previewMinutes),r=Y(e=>e.isGenerating),i=(0,Q.useRef)(null),a=(0,Q.useMemo)(()=>Rr(),[]),o=(0,Q.useMemo)(()=>Br(),[]),[s,c]=(0,Q.useState)([]),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(()=>typeof window<`u`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches),[p,m]=(0,Q.useState)(()=>typeof document>`u`||document.visibilityState===`visible`),h=e!==null&&t!==null,g=e?.night??0,_=h&&!d&&p,v=g>0;(0,Q.useEffect)(()=>{let e=window.matchMedia(`(prefers-reduced-motion: reduce)`),t=()=>f(e.matches),n=()=>m(document.visibilityState===`visible`);return e.addEventListener(`change`,t),document.addEventListener(`visibilitychange`,n),()=>{e.removeEventListener(`change`,t),document.removeEventListener(`visibilitychange`,n)}},[]),(0,Q.useEffect)(()=>{if(!_||typeof window>`u`)return;let e=i.current;if(!e)return;let t=document.documentElement,n=0,r=0,a=0,o=0,s=50,c=50,l,u,d=()=>{n=0,e.style.setProperty(`--sky-px`,r.toFixed(3)),e.style.setProperty(`--sky-py`,a.toFixed(3)),e.style.setProperty(`--sky-scroll`,o.toFixed(2)),v&&(t.style.setProperty(`--lamp-x`,`${s.toFixed(2)}%`),t.style.setProperty(`--lamp-y`,`${c.toFixed(2)}%`))},f=()=>{n||=window.requestAnimationFrame(d)},p=e=>{let{innerWidth:t,innerHeight:n}=window;r=(e.clientX/t-.5)*2,a=(e.clientY/n-.5)*2,s=e.clientX/t*100,c=e.clientY/n*100,f()},m=e=>{let t=e.target;t&&typeof t.scrollTop==`number`&&(o=Math.max(-1,Math.min(1,t.scrollTop%2400/2400)),f())},h=()=>{t.removeAttribute(`data-composing`)},g=e=>{v&&(t.style.setProperty(`--lamp-pulse`,`1`),l&&clearTimeout(l),l=setTimeout(()=>t.style.setProperty(`--lamp-pulse`,`0`),320));let n=e.target;n&&n.tagName===`TEXTAREA`&&(t.setAttribute(`data-composing`,`true`),u&&clearTimeout(u),u=setTimeout(h,Lr))},y=e=>{let t=e.target;t&&t.tagName===`TEXTAREA`&&h()};return window.addEventListener(`pointermove`,p,{passive:!0}),window.addEventListener(`keydown`,g,{passive:!0}),window.addEventListener(`scroll`,m,{passive:!0,capture:!0}),document.addEventListener(`focusout`,y),()=>{window.removeEventListener(`pointermove`,p),window.removeEventListener(`keydown`,g),window.removeEventListener(`scroll`,m,{capture:!0}),document.removeEventListener(`focusout`,y),n&&window.cancelAnimationFrame(n),l&&clearTimeout(l),u&&clearTimeout(u),h();for(let t of[`--sky-px`,`--sky-py`,`--sky-scroll`])e.style.removeProperty(t);for(let e of[`--lamp-x`,`--lamp-y`,`--lamp-pulse`])t.style.removeProperty(e)}},[_,v]);let y=_&&g>=.4;(0,Q.useEffect)(()=>{if(!y)return;let e,t=new Set,n=0,i=()=>{let a={id:n+=1,x:10+Math.random()*70,y:4+Math.random()*36,angle:20+Math.random()*30,length:120+Math.random()*140};c(e=>[...e.slice(-2),a]);let o=setTimeout(()=>{t.delete(o),c(e=>e.filter(e=>e.id!==a.id))},1600);t.add(o),e=setTimeout(i,(r?6e3:2e4)+Math.random()*3e4)};return e=setTimeout(i,4e3+Math.random()*8e3),()=>{e&&clearTimeout(e),t.forEach(clearTimeout),c([])}},[y,r]);let b=t?.thunder??!1;if((0,Q.useEffect)(()=>{if(!_||!b)return;let e,t,n=()=>{u(!0),t=setTimeout(()=>u(!1),180+Math.random()*160),e=setTimeout(n,9e3+Math.random()*25e3)};return e=setTimeout(n,3e3+Math.random()*6e3),()=>{e&&clearTimeout(e),t&&clearTimeout(t),u(!1)}},[_,b]),!e||!t)return null;let x=t.moon.phase,S=(x<.5?1-x*2:-(x*2-1))*92,C=t.sun.visible?t.sun.warmth:0;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{ref:i,"data-testid":`celestial-sky`,"data-night":g>.5?`true`:`false`,"data-preview":n===null?`false`:`true`,"data-generating":r?`true`:`false`,"data-motion":_?`active`:`paused`,"data-weather":t.weatherKind,"data-flash":_&&l?`true`:`false`,"aria-hidden":`true`,className:`celestial-sky pointer-events-none fixed inset-0 z-0`,style:{"--wind":t.wind},children:(0,$.jsxs)(`div`,{className:`celestial-sky__layers absolute inset-0 overflow-hidden`,children:[(0,$.jsx)(`div`,{className:`celestial-sky__gradient`}),(0,$.jsx)(`div`,{className:`celestial-sky__stars`,style:{opacity:t.stars},"data-testid":`celestial-stars`,children:a.map(e=>(0,$.jsx)(`span`,{className:e.bright?`celestial-sky__star celestial-sky__star--bright`:`celestial-sky__star`,style:{left:`${e.x}%`,top:`${e.y}%`,width:e.size,height:e.size,animationDelay:`${e.delay}s`,animationDuration:`${e.period}s`}},e.id))}),y&&s.map(e=>(0,$.jsx)(`span`,{className:`celestial-sky__meteor`,style:{left:`${e.x}%`,top:`${e.y}%`,width:e.length,transform:`rotate(${e.angle}deg)`}},e.id)),(0,$.jsx)(`div`,{className:`celestial-sky__aurora`}),(0,$.jsx)(`div`,{className:`celestial-sky__sun`,"data-testid":`celestial-sun`,style:{opacity:t.sun.visible?t.sun.dim:0,"--body-x":t.sun.x,"--body-y":t.sun.y,"--sun-warmth":t.sun.warmth}}),(0,$.jsx)(`div`,{className:`celestial-sky__moon`,"data-testid":`celestial-moon`,style:{opacity:t.moon.visible?t.moon.dim:0,"--body-x":t.moon.x,"--body-y":t.moon.y},children:(0,$.jsx)(`span`,{className:`celestial-sky__moon-shadow`,style:{transform:`translateX(${S}%)`}})}),zr.map(e=>(0,$.jsx)(`div`,{className:`celestial-sky__cloud`,style:{top:`${e.top}%`,left:`${e.left}%`,width:`${e.width}vw`,height:`${e.height}vh`,background:t.cloudTint,opacity:t.cloudOpacity,animationDuration:`${e.drift/t.wind}s`,animationDelay:`${e.delay}s`,"--cloud-depth":`${e.depth}px`}},e.id)),(0,$.jsx)(`div`,{className:`celestial-sky__horizon-glow`,style:{"--body-x":t.sun.x,opacity:C,background:`radial-gradient(60vw 34vh at 50% 100%, ${e.sky.horizon} 0%, transparent 70%)`}}),(0,$.jsx)(`div`,{className:`celestial-sky__haze`,style:{opacity:Math.min(1,.3+t.haze*.45)}}),t.fog>0&&(0,$.jsx)(`div`,{className:`celestial-sky__fog`,style:{opacity:t.fog}}),t.rain>0&&(0,$.jsx)(`div`,{className:`celestial-sky__rain`,"data-testid":`celestial-rain`,style:{opacity:.25+t.rain*.5}}),t.snow>0&&(0,$.jsx)(`div`,{className:`celestial-sky__snow`,"data-testid":`celestial-snow`,style:{opacity:t.snow},children:o.map(e=>(0,$.jsx)(`span`,{className:`celestial-sky__flake`,style:{left:`${e.x}%`,width:e.size,height:e.size,animationDelay:`${e.delay}s`,animationDuration:`${e.period/t.wind}s`,"--sway":`${e.sway}px`}},e.id))}),(0,$.jsx)(`div`,{className:`celestial-sky__flash`}),(0,$.jsx)(`div`,{className:`celestial-sky__grain`})]})}),(0,$.jsx)(`div`,{className:`celestial-sky__lamp`,"data-motion":_?`active`:`paused`,"aria-hidden":`true`})]})};function Hr(e,t){let n=window.visualViewport,r=n?.offsetLeft??0,i=n?.offsetTop??0,a=n?.width??window.innerWidth,o=n?.height??window.innerHeight,s=Math.min(8,Math.max(0,(o-44)/2)),c=Math.min(336,Math.max(0,a-24)),l=document.documentElement.dir===`rtl`?e.left:e.right-c,u=Math.max(r+8,Math.min(l,r+a-c-8)),d=Math.max(0,o-2*s),f=Math.min(t,d),p=Math.max(0,Math.min(d,i+o-s-e.bottom-8)),m=Math.max(0,Math.min(d,e.top-8-i-s)),h,g;return Math.max(m,p)<Math.min(f,160)?(h=i+s,g=d):p>=f||m<f&&p>=m?(h=e.bottom+8,g=p):(g=m,h=e.top-8-Math.min(t,g)),{top:h,left:u,width:c,maxHeight:g,paddingBlock:Math.max(0,Math.min(16,(g-42)/2))}}function Ur(){let{t:e}=R(),t=M(),n=Y(e=>e.theme.mode===`celestial`),r=At(e=>e.palette),i=At(e=>e.previewMinutes),a=(0,Q.useRef)(null),o=(0,Q.useRef)(null),s=(0,Q.useRef)(!1),c=(0,Q.useId)(),l=(0,Q.useId)(),[u,d]=(0,Q.useState)(null),f=u!==null,p=n&&r!==null,m=(0,Q.useCallback)((e=!1)=>{s.current&&(s.current=!1,d(null),Dt(null),e&&a.current?.focus())},[]);if((0,Q.useEffect)(()=>{m()},[p,t.key,m]),(0,Q.useEffect)(()=>()=>{s.current&&Dt(null)},[]),(0,Q.useLayoutEffect)(()=>{if(!f)return;let e=o.current,t=a.current;if(!e||!t)return;let n=()=>{if(!s.current)return;let n=getComputedStyle(e),r=e.scrollHeight+parseFloat(n.borderTopWidth)+parseFloat(n.borderBottomWidth),i=Hr(t.getBoundingClientRect(),r);d(e=>!e||e.top===i.top&&e.left===i.left&&e.width===i.width&&e.maxHeight===i.maxHeight&&e.paddingBlock===i.paddingBlock?e:i)};n();let r=new ResizeObserver(n);return r.observe(e),e.lastElementChild&&r.observe(e.lastElementChild),()=>r.disconnect()},[f]),(0,Q.useEffect)(()=>{if(!f)return;let e=e=>e instanceof Node&&(a.current?.contains(e)||o.current?.contains(e)),t=t=>{e(t.target)||m()},n=e=>{let t=e.target;e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),m(!0)):!e.ctrlKey&&!e.metaKey||e.key!==`,`||e.shiftKey||e.altKey||t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.contentEditable===`true`||t.isContentEditable||m()},r=()=>m(),i=requestAnimationFrame(()=>{o.current?.querySelector(`input[type="range"]`)?.focus()});return document.addEventListener(`pointerdown`,t,!0),document.addEventListener(`focusin`,t),document.addEventListener(`keydown`,n,!0),window.addEventListener(`resize`,r),window.visualViewport?.addEventListener(`resize`,r),window.visualViewport?.addEventListener(`scroll`,r),()=>{cancelAnimationFrame(i),document.removeEventListener(`pointerdown`,t,!0),document.removeEventListener(`focusin`,t),document.removeEventListener(`keydown`,n,!0),window.removeEventListener(`resize`,r),window.visualViewport?.removeEventListener(`resize`,r),window.visualViewport?.removeEventListener(`scroll`,r)}},[f,m]),!p||!r)return null;let h=Et(r.solar.minutes),g=e(`settings.appearance.celestial.title`),_=e(i===null?`settings.appearance.celestial.live`:`settings.appearance.celestial.preview`),v=r.solar.isDay?ae:st;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{ref:a,type:`button`,className:`celestial-clock-trigger`,"data-testid":`celestial-clock-trigger`,"aria-label":`${g}: ${h}`,"aria-describedby":l,title:`${g}: ${h} · ${_}`,"aria-haspopup":`dialog`,"aria-expanded":f,"aria-controls":c,onClick:()=>{if(f){m();return}let e=a.current?.getBoundingClientRect();e&&(s.current=!0,d(Hr(e,1/0)))},children:(0,$.jsxs)(`span`,{dir:`ltr`,"data-testid":`celestial-clock-time`,className:`inline-flex items-center gap-1.5`,children:[(0,$.jsx)(v,{className:`h-4 w-4`,strokeWidth:1.75,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`hidden tabular-nums sm:inline`,children:h})]})}),(0,$.jsx)(`span`,{id:l,className:`sr-only`,children:_}),u&&(0,Xn.createPortal)((0,$.jsxs)(`div`,{ref:o,id:c,role:`dialog`,"aria-label":g,className:`celestial-day-popover`,"data-testid":`celestial-day-popover`,"data-scroll-fade":``,style:{position:`fixed`,overflowY:`auto`,...u},children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":e(`common.close`),title:e(`common.close`),onClick:()=>m(!0),className:`absolute inset-e-2 top-2 flex h-8 w-8 items-center justify-center rounded-full text-ink-muted hover:bg-interactive-hover hover:text-ink focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-500/40`,children:(0,$.jsx)(We,{className:`h-4 w-4`,"aria-hidden":`true`})}),(0,$.jsx)(ln,{})]}),document.body)]})}var Wr={"/notes":{icon:Pe,labelKey:`sidebar.navigation.notes`},"/calendar":{icon:Fe,labelKey:`sidebar.navigation.calendar`},"/automations":{icon:Qe,labelKey:`sidebar.navigation.automations`},"/channels":{icon:H,labelKey:`sidebar.navigation.channels`},"/personas":{icon:Ce,labelKey:`sidebar.navigation.personas`},"/gallery":{icon:G,labelKey:`sidebar.navigation.imagine`},"/strands":{icon:Ee,labelKey:`sidebar.navigation.strands`},"/usage":{icon:Ke,labelKey:`usageAnalytics.title`},"/system":{icon:_e,labelKey:`systemPage.title`},"/artifacts":{icon:Ue,labelKey:`tabs.artifacts`}},Gr=e=>e.kind===`home`?be:e.kind===`chat`?V:e.kind===`work`?qe:Wr[e.path]?.icon??Ue,Kr=()=>Nt()?`⌘`:`Ctrl`,qr=new Set([`/usage`,`/system`]),Jr=(e,t)=>e.kind===`work`?!t.work:e.path===`/strands`?!t.strands:qr.has(e.path),Yr=()=>{let{t:e,i18n:t}=R(),n=M(),r=ee(),i=zn(e=>e.tabs),a=zn(e=>e.activeTabId),o=zn(e=>e.syncWithPath),s=zn(e=>e.closeTab),c=zn(e=>e.closeTabs),l=L(e=>e.sessions),u=L(e=>e.currentSession),d=bt(e=>e.tasks),{systemInfo:f,isAdmin:p,canUseWork:m,canUseStrands:h}=J(),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(null),S=(0,Q.useRef)(null),C=(0,Q.useRef)(null),w=(0,Q.useRef)(null),T=(0,Q.useRef)(null),E=(0,Q.useRef)(null),D=(0,Q.useRef)(new Map),O=(0,Q.useRef)(null),k=p(),A=f?.requiresAuth===!1||k,j=m(),N=h(),P=(0,Q.useMemo)(()=>({work:j,strands:N}),[N,j]),F=A?i:i.filter(e=>!Jr(e,P));(0,Q.useEffect)(()=>{o(n.pathname)},[n.pathname,o]),(0,Q.useLayoutEffect)(()=>{let e=E.current;if(!e)return;let t=null,n=()=>{t=null;let n=Math.max(0,e.scrollWidth-e.clientWidth),r=getComputedStyle(e).direction===`rtl`?n+e.scrollLeft:e.scrollLeft,i=n-r;e.style.setProperty(`--tab-fade-left`,`${r<=1?0:Math.min(24,r)}px`),e.style.setProperty(`--tab-fade-right`,`${i<=1?0:Math.min(24,i)}px`)},r=()=>{t===null&&(t=requestAnimationFrame(n))};n(),e.addEventListener(`scroll`,r,{passive:!0});let i=new ResizeObserver(r);i.observe(e);for(let t of e.children)i.observe(t);return()=>{e.removeEventListener(`scroll`,r),i.disconnect(),t!==null&&cancelAnimationFrame(t)}},[F.length,t.resolvedLanguage,i]),(0,Q.useLayoutEffect)(()=>{let e=E.current,t=O.current,n=t?D.current.get(t):null;n?(O.current=null,n.focus({preventScroll:!0}),n.closest(`[data-tab-item]`)?.scrollIntoView({block:`nearest`,inline:`nearest`})):(e?.querySelector(`[data-active="true"]`))?.closest(`[data-tab-item]`)?.scrollIntoView({block:`nearest`,inline:`nearest`})},[F.length,a]),(0,Q.useEffect)(()=>{if(!f||A)return;let e=i.filter(e=>Jr(e,P)).map(e=>e.id);if(e.length===0)return;let t=c(e,`home`);t&&r(t.path,{replace:!0})},[c,r,A,f,P,i]),(0,Q.useEffect)(()=>{if(!g&&!b)return;let e=e=>{let t=e.target;S.current?.contains(t)||C.current?.contains(t)||T.current?.contains(t)||(_(!1),x(null))},t=e=>{e.key===`Escape`&&(g&&w.current?.focus(),_(!1),x(null))};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[b,g]),(0,Q.useEffect)(()=>{if(!g)return;let e=()=>{let e=w.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));y({left:l,top:t.bottom+4,width:s})};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[g]),(0,Q.useEffect)(()=>{b&&T.current?.querySelector(`[role="menuitem"]:not(:disabled)`)?.focus()},[b]);let I=g&&v!==null;(0,Q.useEffect)(()=>{I&&C.current?.querySelector(`[role="menuitem"]:not(:disabled)`)?.focus()},[I]);let te=t=>{if(t.kind===`home`)return e(`tabs.home`,`Home`);if(t.kind===`chat`){if(t.id===`chat:new`)return u?.isPrivate?e(`chat.session.incognito`,`Incognito Chat`):e(`tabs.newChat`,`New Chat`);let n=t.id.slice(5);return l.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 d.find(e=>e.id===n)?.title||e(`tabs.work`,`Work`)}let n=Wr[t.path];return n?e(n.labelKey,t.path.slice(1)):t.path.slice(1)},ne=F.find(e=>e.id===a),re=ne?ne.kind===`chat`?u?.isPrivate?e(`chat.session.incognito`,`Incognito Chat`):e(`tabs.chat`,`Chat`):ne.kind===`work`?e(`tabs.work`,`Work`):te(ne):``;(0,Q.useEffect)(()=>{let e=`Libre WebUI`;return document.title=re&&re!==e?`${re} · ${e}`:e,()=>{document.title=e}},[re]);let z=(e,t)=>{let n=F.findIndex(t=>t.id===e.id);t&&(O.current=F[n+1]?.id??F[n-1]?.id??`home`);let i=s(e.id);t&&i&&(O.current=i.id),i&&r(i.path)},ie=(e,t)=>{e.stopPropagation(),e.preventDefault();let n=e.currentTarget.closest(`[data-tab-item]`);z(t,t.id===a||e.detail===0||!!n?.contains(document.activeElement))},B=(e,t,n)=>{_(!1),x({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))})},ae=(e,t)=>{e.preventDefault(),e.stopPropagation(),B(t,e.clientX,e.clientY)},oe=(e,t)=>{if(e.key!==`ContextMenu`&&!(e.shiftKey&&e.key===`F10`))return;e.preventDefault();let n=e.currentTarget.getBoundingClientRect();B(t,n.left+12,n.bottom+4)},se=e=>{let t=Array.from(e.currentTarget.querySelectorAll(`[role="menuitem"]:not(:disabled)`)??[]);if(t.length===0)return;let n=t.indexOf(document.activeElement),r;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()},H=(e,t)=>{O.current=t??a;let n=c(e,t);n&&(O.current=n.id),x(null),n&&r(n.path)},ce=[{key:`chat`,label:e(`tabs.newChat`,`New Chat`),icon:V,shortcut:`${Kr()}⇧O`,action:()=>hn(r)},{key:`incognito-chat`,label:e(`chat.session.incognito`,`Incognito Chat`),icon:ze,action:()=>_n(r)},...j?[{key:`work`,label:e(`tabs.newWork`,`New Work`),icon:qe,shortcut:`${Kr()}⇧U`,action:()=>gn(r)}]:[],...[`/channels`,`/notes`,`/calendar`,`/automations`,`/personas`,`/gallery`].map(t=>({key:t,label:e(Wr[t].labelKey,t.slice(1)),icon:Wr[t].icon,action:()=>r(t)})),...N?[{key:`/strands`,label:e(Wr[`/strands`].labelKey,`Strands`),icon:Wr[`/strands`].icon,separatorBefore:!0,action:()=>r(`/strands`)}]:[],...k?[`/system`,`/usage`].map(t=>({key:t,label:e(Wr[t].labelKey,t.slice(1)),icon:Wr[t].icon,action:()=>r(t)})):[]],U=b?F.find(e=>e.id===b.tabId):void 0,le=U?F.findIndex(e=>e.id===U.id):-1,W=U?F.filter(e=>e.id!==`home`&&e.id!==U.id).map(e=>e.id):[],ue=le>=0?F.slice(le+1).filter(e=>e.id!==`home`).map(e=>e.id):[],G=F.filter(e=>e.id!==`home`).map(e=>e.id);return(0,$.jsxs)(`div`,{"data-testid":`app-tab-bar`,"data-app-tabbar":``,className:`relative z-20 flex h-9 flex-none items-center gap-1 px-1 pb-1 lg:px-0`,children:[(0,$.jsx)(`div`,{ref:E,role:`tablist`,"aria-label":e(`tabs.label`,`Open tabs`),className:`tab-scroll-fade flex min-w-0 items-center gap-1 overflow-x-auto p-0.5 scrollbar-none [&::-webkit-scrollbar]:hidden`,children:F.map(t=>{let n=t.id===`chat:new`&&u?.isPrivate?ze:Gr(t),i=t.id===a;return(0,$.jsxs)(`div`,{"data-tab-item":t.id,"data-testid":`app-tab-item`,onContextMenu:e=>ae(e,t),onMouseDown:e=>{e.button===1&&e.preventDefault()},onAuxClick:e=>{e.button===1&&t.id!==`home`&&ie(e,t)},className:X(`group flex h-7 min-w-0 flex-none items-center gap-1.5 rounded-lg border text-[13px] transition-colors duration-150`,t.id!==`home`&&`pe-1`,i?`border-black/6 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,$.jsxs)(`button`,{ref:e=>{e?D.current.set(t.id,e):D.current.delete(t.id)},type:`button`,role:`tab`,tabIndex:0,"aria-selected":i,"data-active":i||void 0,"data-tab-id":t.id,"data-testid":`app-tab`,title:te(t),onClick:()=>{o(t.path),r(t.path)},onKeyDown:e=>oe(e,t),className:X(`flex h-full min-w-0 items-center gap-1.5 rounded-md ps-2.5 outline-hidden focus-visible:ring-2 focus-visible:ring-primary-500`,t.id===`home`&&`pe-2.5`),children:[(0,$.jsx)(n,{className:`h-3.5 w-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`max-w-36 truncate`,children:te(t)})]}),t.id!==`home`&&(0,$.jsx)(`button`,{type:`button`,tabIndex:0,"aria-label":e(`tabs.close`,`Close tab`),"data-testid":`app-tab-close`,onClick:e=>ie(e,t),onKeyDown:e=>oe(e,t),className:X(`flex h-5 w-5 shrink-0 items-center justify-center rounded-md text-gray-400 transition-opacity hover:bg-black/6 hover:text-gray-700 focus-visible:ring-2 focus-visible:ring-primary-500 dark:text-dark-500 dark:hover:bg-white/8 dark:hover:text-dark-800`,i?`opacity-100`:`sm:opacity-0 sm:group-hover:opacity-100 sm:group-focus-within:opacity-100`),children:(0,$.jsx)(We,{className:`h-3 w-3`})})]},t.id)})}),b&&U&&(0,Xn.createPortal)((0,$.jsxs)(`div`,{ref:T,role:`menu`,"aria-label":e(`tabs.actions`,`Tab actions`),"data-testid":`app-tab-context-menu`,onContextMenu:e=>e.preventDefault(),onKeyDown:se,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:b.x,top:b.y},children:[(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`app-tab-context-close`,disabled:U.id===`home`,onClick:()=>{z(U,!0),x(null)},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/5 hover:text-ink disabled:cursor-not-allowed disabled:opacity-40 dark:hover:bg-white/6`,children:[(0,$.jsx)(We,{className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{children:e(`tabs.close`,`Close tab`)})]}),(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`app-tab-context-close-others`,disabled:W.length===0,onClick:()=>H(W,U.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/5 hover:text-ink disabled:cursor-not-allowed disabled:opacity-40 dark:hover:bg-white/6`,children:[(0,$.jsx)(Le,{className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{children:e(`tabs.closeOthers`,`Close other tabs`)})]}),(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`app-tab-context-close-right`,disabled:ue.length===0,onClick:()=>H(ue,U.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/5 hover:text-ink disabled:cursor-not-allowed disabled:opacity-40 dark:hover:bg-white/6`,children:[(0,$.jsx)(De,{className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{children:e(`tabs.closeRight`,`Close tabs to the right`)})]}),(0,$.jsx)(`div`,{className:`mx-2 my-1 h-px bg-line`,role:`separator`}),(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`app-tab-context-close-all`,disabled:G.length===0,onClick:()=>H(G,`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/5 hover:text-ink disabled:cursor-not-allowed disabled:opacity-40 dark:hover:bg-white/6`,children:[(0,$.jsx)(lt,{className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{children:e(`tabs.closeAll`,`Close all tabs`)})]})]}),document.body),(0,$.jsxs)(`div`,{className:`relative flex-none`,ref:S,children:[(0,$.jsx)(`button`,{ref:w,type:`button`,"aria-label":e(`tabs.new`,`New tab`),"aria-expanded":g,"aria-haspopup":`menu`,"data-testid":`app-tab-new`,onClick:()=>_(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-hidden focus-visible:ring-2 focus-visible:ring-primary-500`,children:(0,$.jsx)(et,{className:`h-4 w-4`})}),g&&v&&(0,Xn.createPortal)((0,$.jsx)(`div`,{ref:C,role:`menu`,"aria-label":e(`tabs.new`,`New tab`),"data-testid":`app-tab-new-menu`,onKeyDown:e=>{e.key===`Tab`?(w.current?.focus(),_(!1)):se(e)},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:v,children:ce.map(e=>(0,$.jsxs)(Q.Fragment,{children:[e.separatorBefore&&(0,$.jsx)(`div`,{className:`mx-2 my-1 h-px bg-line`,role:`separator`}),(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{_(!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/5 hover:text-ink dark:hover:bg-white/6`,children:[(0,$.jsx)(e.icon,{className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-start`,children:e.label}),e.shortcut&&(0,$.jsx)(`span`,{className:`font-mono text-[10px] tracking-wide text-ink-subtle`,children:e.shortcut})]})]},e.key))}),document.body)]}),(0,$.jsx)(Ur,{})]})},Xr=24;function Zr(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 Qr({text:e,ranges:t}){if(t.length===0)return(0,$.jsx)($.Fragment,{children:e});let n=[],r=0;return t.forEach(([t,i],a)=>{t>r&&n.push(e.slice(r,t)),n.push((0,$.jsx)(`span`,{className:`font-semibold text-ink`,children:e.slice(t,i)},a)),r=i}),r<e.length&&n.push(e.slice(r)),(0,$.jsx)($.Fragment,{children:n})}var $r=({onOpenSettings:e,onOpenSettingsTab:t})=>{let{t:n,i18n:r}=R(),i=ee(),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(0),d=(0,Q.useRef)(null),f=(0,Q.useRef)(null),p=(0,Q.useId)(),m=L(e=>e.sessions),h=bt(e=>e.tasks),g=Y(e=>e.toggleTheme),{canUseWork:_,canUseStrands:v}=J(),y=_(),b=v(),x=Nt()?`⌘`:`Ctrl`;(0,Q.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)}},[]);let S=(0,Q.useCallback)(()=>o(!1),[]);$t(d,{onClose:S,enabled:a});let[C,w]=(0,Q.useState)(null),T=a&&s.trim().length>=3,[E,D]=(0,Q.useState)(null);T||C===null&&E===null||(w(null),D(null));let O=T&&E?.query!==s.trim(),k=T&&E?.query===s.trim()&&E.failed;(0,Q.useEffect)(()=>{let e=s.trim();if(!a||e.length<3)return;let t=!1,n=window.setTimeout(()=>{Ut.searchApp(e).then(n=>{t||(n.success&&n.data?(w(n.data),D({query:e,failed:!1})):D({query:e,failed:!0}))}).catch(()=>{t||D({query:e,failed:!0})})},300);return()=>{t=!0,window.clearTimeout(n)}},[s,a]);let A=(0,Q.useMemo)(()=>{let a=n(`palette.actions`,`Actions`),o=[{id:`action:new-chat`,section:a,label:n(`tabs.newChat`,`New Chat`),icon:V,hint:`${x}⇧O`,keywords:`new chat conversation start`,run:()=>hn(i)},{id:`action:incognito-chat`,section:a,label:n(`chat.session.incognito`,`Incognito Chat`),icon:ze,keywords:`incognito private temporary ghost`,run:()=>_n(i)},...y?[{id:`action:new-work`,section:a,label:n(`tabs.newWork`,`New Work`),icon:qe,hint:`${x}⇧U`,keywords:`new work task workspace`,run:()=>gn(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:Ie,keywords:`models ollama providers llm`,run:()=>t(`model-manager`)},{id:`action:personas`,section:a,label:n(`sidebar.navigation.personas`,`Personas`),icon:Ce,run:()=>i(`/personas`)},{id:`action:gallery`,section:a,label:n(`sidebar.navigation.imagine`,`Imagine`),icon:G,keywords:`imagine images generation gallery pictures`,run:()=>i(`/gallery`)},{id:`action:calendar`,section:a,label:n(`sidebar.navigation.calendar`,`Calendar`),icon:Fe,keywords:`calendar events schedule agenda`,run:()=>i(`/calendar`)},{id:`action:channels`,section:a,label:n(`sidebar.navigation.channels`,`Channels`),icon:H,keywords:`channels team messages dm direct chat rooms`,run:()=>i(`/channels`)},{id:`action:automations`,section:a,label:n(`sidebar.navigation.automations`,`Automations`),icon:Qe,keywords:`automations schedule cron recurring routines`,run:()=>i(`/automations`)},{id:`action:prompts`,section:a,label:n(`sidebar.navigation.prompts`,`Prompts`),icon:Ae,keywords:`prompts templates slash snippets library`,run:()=>t(`prompts`)},{id:`action:skills`,section:a,label:n(`sidebar.navigation.skills`,`Skills`),icon:Ge,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`)},...b?[{id:`action:strands`,section:a,label:n(`sidebar.navigation.strands`,`Strands`),icon:Ee,run:()=>i(`/strands`)}]:[],{id:`action:settings`,section:a,label:n(`palette.settings`,`Settings`),icon:ve,hint:`${x},`,keywords:`settings preferences configuration options`,run:e},{id:`action:theme`,section:a,label:n(`palette.toggleTheme`,`Toggle theme`),icon:st,hint:`${x}D`,keywords:`theme dark light mode appearance`,run:g}],s=[...m].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:V,hint:jt(e.updatedAt,r.language),keywords:e.model,run:()=>i(`/c/${e.id}`)})),c=y?[...h].sort((e,t)=>new Date(t.updatedAt).getTime()-new Date(e.updatedAt).getTime()).map(e=>{let t=nn(e.status);return{id:`work:${e.id}`,section:n(`palette.work`,`Work`),label:e.title||n(`work.tasks.untitled`,`Untitled task`),icon:qe,hint:t?n(t.labelKey,{defaultValue:t.label}):e.status,run:()=>i(`/work/${e.id}`)}}):[];return[...o,...s,...c]},[n,x,i,e,t,g,m,h,y,b,r.language]),j=(0,Q.useMemo)(()=>{let e=s.trim();if(!e){let e=A.filter(e=>e.id.startsWith(`action:`)),t=A.filter(e=>e.id.startsWith(`session:`)).slice(0,6),n=A.filter(e=>e.id.startsWith(`work:`)).slice(0,4);return[...e,...t,...n].map(e=>({item:e,ranges:[]}))}let r=A.flatMap(t=>{let n=Zr(e,t.label);if(n)return[{item:t,...n}];let r=t.keywords?Zr(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,Xr).map(({item:e,ranges:t})=>({item:e,ranges:t}));if(!C)return o;let c=new Set(o.filter(e=>e.item.id.startsWith(`session:`)).map(e=>e.item.id.slice(8))),l=[...C.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:V,hint:e.snippet,run:()=>i(`/c/${e.sessionId}`)})),...C.notes.map(e=>({id:`deep-note:${e.noteId}`,section:n(`palette.notes`,`Notes`),label:e.title||n(`notes.untitled`,`Untitled`),icon:Pe,hint:e.snippet,run:()=>i(`/notes?note=${encodeURIComponent(e.noteId)}`)})),...C.documents.map(e=>({id:`deep-document:${e.documentId}`,section:n(`palette.documents`,`Documents`),label:e.filename,icon:ot,hint:e.snippet,run:()=>t(`documents`)}))];return[...o,...l.map(e=>({item:e,ranges:[]}))]},[A,s,C,n,i,t]),M=Math.min(l,j.length-1),N=e=>`${p}-option-${e}`;(0,Q.useEffect)(()=>{(f.current?.querySelector(`[data-selected="true"]`))?.scrollIntoView({block:`nearest`})},[l,j.length]);let P=(0,Q.useMemo)(()=>{let e=[];return j.forEach(({item:t,ranges:n},r)=>{let i=e[e.length-1];i&&i.name===t.section?i.entries.push({item:t,ranges:n,index:r}):e.push({name:t.section,entries:[{item:t,ranges:n,index:r}]})}),e},[j]),F=j.length===0?O?n(`palette.searching`):k?n(`palette.searchFailed`):n(`palette.empty`,`No matches.`):k?n(`palette.searchFailed`):``,I=e=>{e&&(S(),e.run())};return a?(0,Xn.createPortal)((0,$.jsx)(`div`,{"data-testid":`command-palette`,className:`fixed inset-0 z-2147483647 flex items-center justify-center bg-black/25 px-4 backdrop-blur-xs dark:bg-black/45`,onMouseDown:e=>{e.target===e.currentTarget&&S()},children:(0,$.jsxs)(`div`,{ref:d,role:`dialog`,"aria-modal":`true`,"aria-label":n(`palette.search`,`Search`),tabIndex:-1,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,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2.5 border-b border-line px-4`,children:[(0,$.jsx)(W,{className:`h-4 w-4 shrink-0 text-ink-muted`}),(0,$.jsx)(`input`,{"data-testid":`command-palette-input`,role:`combobox`,"aria-expanded":j.length>0,"aria-controls":p,"aria-autocomplete":`list`,"aria-activedescendant":j.length>0?N(M):void 0,"aria-label":n(`palette.placeholder`,`Search chats, Work, actions…`),value:s,onChange:e=>{c(e.target.value),u(0)},onKeyDown:e=>{e.nativeEvent.isComposing||(e.key===`ArrowDown`?(e.preventDefault(),u(Math.min(j.length-1,M+1))):e.key===`ArrowUp`?(e.preventDefault(),u(Math.max(0,M-1))):e.key===`Enter`&&(e.preventDefault(),I(j[M]?.item)))},placeholder:n(`palette.placeholder`,`Search chats, Work, actions…`),className:`h-13 w-full bg-transparent text-[15px] text-ink outline-hidden placeholder:text-ink-muted`}),(0,$.jsx)(`kbd`,{"aria-hidden":`true`,className:`shrink-0 rounded-md border border-line px-1.5 py-0.5 font-mono text-[10px] text-ink-muted`,children:n(`palette.escKey`)})]}),(0,$.jsxs)(`div`,{ref:f,className:`min-h-0 flex-1 overflow-y-auto p-2 scrollbar-thin`,children:[(0,$.jsx)(`div`,{id:p,role:`listbox`,"aria-label":n(`palette.results`),children:P.map(e=>(0,$.jsxs)(`div`,{role:`group`,"aria-labelledby":`${p}-section-${e.entries[0].index}`,children:[(0,$.jsx)(`p`,{id:`${p}-section-${e.entries[0].index}`,role:`presentation`,className:`px-2.5 pb-1 pt-2.5 text-[10px] font-medium uppercase tracking-[0.08em] text-ink-muted`,children:e.name}),e.entries.map(({item:e,ranges:t,index:n})=>(0,$.jsxs)(`div`,{id:N(n),role:`option`,"aria-selected":n===M,"data-selected":n===M||void 0,onMouseEnter:()=>u(n),onClick:()=>I(e),className:X(`flex w-full cursor-pointer items-center gap-2.5 rounded-lg px-2.5 py-2 text-start text-sm transition-colors`,n===M?`bg-interactive-active text-ink ring-1 ring-inset ring-line-strong`:`text-ink-muted`),children:[(0,$.jsx)(e.icon,{className:`h-4 w-4 shrink-0 text-ink-muted`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:(0,$.jsx)(Qr,{text:e.label,ranges:t})}),e.hint&&(0,$.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-ink-muted`,children:e.hint})]},e.id))]},e.name))}),(0,$.jsx)(`div`,{role:`status`,className:X(F&&(j.length===0?`px-3 py-6 text-center text-sm text-ink-muted`:`px-3 py-2 text-center text-xs text-ink-muted`)),children:F})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 border-t border-line px-4 py-2 text-[10px] text-ink-muted`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(`kbd`,{"aria-hidden":`true`,className:`rounded-md border border-line px-1.5 py-0.5 font-mono`,children:`↑↓`}),n(`palette.hintNavigate`)]}),(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(`kbd`,{"aria-hidden":`true`,className:`rounded-md border border-line px-1.5 py-0.5 font-mono`,children:`↵`}),n(`palette.hintOpen`)]}),(0,$.jsxs)(`span`,{className:`ms-auto inline-flex items-center gap-1`,children:[(0,$.jsx)(`kbd`,{"aria-hidden":`true`,className:`rounded-md border border-line px-1.5 py-0.5 font-mono`,children:n(`palette.escKey`)}),n(`palette.hintClose`)]})]})]})}),document.body):null},ei=Kt(`user-service`),ti=class{static async initializeAuth(){let{setLoading:e,setSystemInfo:t,login:n}=J.getState();try{e(!0),ei.debug(`Starting auth initialization...`),ei.debug(`Fetching system info...`);let r=await Ft.getSystemInfo();ei.debug(`System info response:`,r),r.success&&r.data?(ei.debug(`Setting system info:`,r.data),t(r.data),Y.getState().applyInstanceTheme(r.data.defaultTheme)):ei.error(`System info response failed:`,r);let i=localStorage.getItem(`auth-token`);if(i)try{let e=await Ft.verifyToken();if(e.success&&e.data){let t=J.getState().systemInfo;t&&n(e.data,i,t)}}catch(e){ei.error(`Token verification failed:`,e),localStorage.removeItem(`auth-token`)}}catch(e){ei.error(`Auth initialization error:`,e)}finally{e(!1)}}},ni=Kt(`initialize`),ri=()=>{let{t:e}=R(),t=(0,Q.useRef)(!1),n=(0,Q.useRef)(!1),{loadSessions:r,loadModels:i,loadPreferences:a,setSelectedModel:o,models:s,ollamaConnected:c}=L(),{loadPreferences:l}=Y(),{loadPlugins:u,plugins:d}=Ct(),f=J(e=>e.isAuthenticated);(0,Q.useEffect)(()=>{t.current||n.current||(async()=>{n.current=!0;try{ni.debug(`Initializing Libre WebUI...`),await ti.initializeAuth();let n=J.getState();if(n.requiresAuth()&&!n.isAuthenticated){ni.debug(`Authentication required; deferring protected app initialization`);return}try{!(await Wt.checkHealth()).success&&!Gt()&&de.error(e(`appInitialization.ollamaUnavailable`))}catch(t){ni.warn(`Ollama health check failed; continuing provider initialization:`,t),Gt()||de.error(e(`appInitialization.ollamaUnavailable`))}await Promise.all([l(),a()]),await Promise.all([i(),r(),u()]),t.current=!0,ni.debug(`Libre WebUI initialized successfully`)}catch(n){Gt()?(await Promise.all([l(),a()]),await Promise.all([i(),r(),u()]),t.current=!0):(ni.error(`Failed to initialize app:`,n),de.error(e(`appInitialization.backendConnectionFailed`)))}finally{n.current=!1}})()},[f,l,a,i,r,u,e]),(0,Q.useEffect)(()=>{if(s.length>0){let e=s.filter(e=>!e.name.includes(`embed`))[0]||s[0],{selectedModel:t,selectedProviderType:n,selectedProviderId:r}=L.getState();if(t){if(!te(s,{model:t,providerType:n,providerId:r})&&n!==`ollama`&&n!==`plugin`&&n!==`agent`){let t=I(e);ni.debug(`Legacy selected model not available, falling back to:`,t.model),o(t.model,t.providerType,t.providerId)}}else{let t=I(e);ni.debug(`No model selected, using first available:`,t.model),o(t.model,t.providerType,t.providerId)}}},[s,o]),(0,Q.useEffect)(()=>{t.current&&(ni.debug(`Plugin availability changed, reloading models...`),i())},[d,i]),(0,Q.useEffect)(()=>{let e=0,t=()=>{if(document.visibilityState!==`visible`)return;let t=J.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,Q.useEffect)(()=>{let e=()=>{ni.debug(`Installed models changed, reloading models...`),i()};return window.addEventListener(Ht,e),()=>window.removeEventListener(Ht,e)},[i]),(0,Q.useEffect)(()=>{if(c)return;let e=J.getState();if(e.requiresAuth()&&!e.isAuthenticated)return;let t=()=>{document.visibilityState===`visible`&&(ni.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])},ii=`.scroll-region, [class*="overflow-y-auto"], [class*="overflow-x-auto"], [class*="overflow-auto"], [data-scroll-fade]`,ai=`input, textarea, [contenteditable="true"], [data-scroll-fade="off"], .sidebar-scroll-fade, .tab-scroll-fade`,oi=[`top`,`bottom`,`left`,`right`];function si(){(0,Q.useEffect)(()=>{let e=new Map,t=new Set,n=new Set,r=null,i=!1,a=e=>{let t=getComputedStyle(e),n=e=>/^(auto|scroll)$/.test(e),r=n(t.overflowY)?Math.max(0,e.scrollHeight-e.clientHeight):0,i=n(t.overflowX)?Math.max(0,e.scrollWidth-e.clientWidth):0,a=Math.max(0,Math.min(r,e.scrollTop)),o=Math.max(0,Math.min(i,t.direction===`rtl`?i+e.scrollLeft:e.scrollLeft)),s=[a,r-a,o,i-o];oi.forEach((t,n)=>{let r=s[n],i=Number.parseFloat(e.getAttribute(`data-scroll-fade-${t}`)??``),a=`${r<=1?0:Math.min(Number.isFinite(i)&&i>=0?i:24,r)}px`,o=`--scroll-fade-${t}`;e.style.getPropertyValue(o)!==a&&e.style.setProperty(o,a)}),e.toggleAttribute(`data-scroll-fade-active`,e.clientWidth>0&&e.clientHeight>0&&(r>1||i>1))},o=r=>{e.get(r)?.observer.disconnect(),e.delete(r),t.delete(r),n.delete(r),r.removeAttribute(`data-scroll-fade-active`),r.removeAttribute(`data-scroll-fade-keyboard`),oi.forEach(e=>r.style.removeProperty(`--scroll-fade-${e}`))},s=()=>{r=null;for(let t of e.keys())t.isConnected||o(t);for(let e of t)a(e);t.clear()},c=n=>{e.has(n)&&(t.add(n),r===null&&(r=requestAnimationFrame(s)))},l=t=>{let n=e.get(t);if(!n)return;let r=new Set(t.children);for(let e of n.children)r.has(e)||n.observer.unobserve(e);for(let e of r)n.children.has(e)||n.observer.observe(e);n.children=r},u=t=>{if(t instanceof HTMLElement){if(t.matches(ai)||t.closest(`[contenteditable="true"], [data-scroll-fade="off"]`)||!t.matches(ii))e.has(t)&&o(t);else{if(!e.has(t)){let n=new ResizeObserver(()=>c(t));e.set(t,{observer:n,children:new Set}),n.observe(t)}l(t),c(t)}}},d=e=>{u(e),e.querySelectorAll(ii).forEach(u)},f=t=>{let n=t instanceof HTMLElement?t:t.parentElement;for(;n;)e.has(n)&&(l(n),c(n)),n=n.parentElement},p=()=>e.forEach((e,t)=>c(t)),m=()=>{for(let e of n)e.removeAttribute(`data-scroll-fade-keyboard`);if(n.clear(),!i)return;let t=document.activeElement;for(;t instanceof HTMLElement;)e.has(t)&&(t.setAttribute(`data-scroll-fade-keyboard`,``),n.add(t)),t=t.parentElement},h=e=>{[`Tab`,`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Home`,`End`,`PageUp`,`PageDown`].includes(e.key)&&(i=!0,m())},g=()=>{i=!1,m()},_=t=>{t.target instanceof HTMLElement&&e.has(t.target)&&c(t.target)};d(document.body);let v=new MutationObserver(e=>{for(let t of e){t.type===`attributes`&&t.target instanceof Element&&(u(t.target),t.target.querySelectorAll(ii).forEach(u));for(let e of t.addedNodes)e instanceof Element&&d(e);f(t.target)}r===null&&(r=requestAnimationFrame(s)),m()});return v.observe(document.documentElement,{subtree:!0,childList:!0,characterData:!0,attributes:!0,attributeFilter:[`class`,`dir`,`data-scroll-fade`,...oi.map(e=>`data-scroll-fade-${e}`)]}),document.addEventListener(`scroll`,_,!0),document.addEventListener(`keydown`,h,!0),document.addEventListener(`focusin`,m),document.addEventListener(`pointerdown`,g,!0),document.addEventListener(`wheel`,g,{passive:!0,capture:!0}),window.addEventListener(`resize`,p),()=>{v.disconnect(),e.forEach((e,t)=>o(t)),r!==null&&cancelAnimationFrame(r),document.removeEventListener(`scroll`,_,!0),document.removeEventListener(`keydown`,h,!0),document.removeEventListener(`focusin`,m),document.removeEventListener(`pointerdown`,g,!0),document.removeEventListener(`wheel`,g,!0),window.removeEventListener(`resize`,p)}},[])}var ci=5e3,li=e=>{let t=/^\/work\/([^/]+)/.exec(e);if(!t)return null;try{return decodeURIComponent(t[1])}catch{return t[1]}};function ui(e){let{t}=R(),{pathname:n}=M(),r=bt(e=>e.tasks),i=bt(e=>e.loadTasks),a=(0,Q.useRef)(null),o=n===`/work`||n.startsWith(`/work/`),s=li(n),c=an(r);(0,Q.useEffect)(()=>{if(!e){a.current=null;return}let{announcements:n,statuses:i}=on(a.current??new Map,r,s);a.current=i;for(let e of n)yt(t(e.key,{title:e.title||t(`work.announce.untitledTask`)}),e.politeness)},[e,s,t,r]),(0,Q.useEffect)(()=>{if(!e||o||!c)return;let t,n=!1,r=()=>{n||document.hidden||(t=setTimeout(async()=>{t=void 0,await i(!0).catch(()=>void 0),r()},ci))},a=()=>{document.hidden?(t&&clearTimeout(t),t=void 0):t||r()};return document.addEventListener(`visibilitychange`,a),r(),()=>{n=!0,t&&clearTimeout(t),document.removeEventListener(`visibilitychange`,a)}},[c,e,i,o])}var di=(e,t=!0)=>{let n=(0,Q.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,Q.useEffect)(()=>{if(t)return document.addEventListener(`keydown`,n),()=>{document.removeEventListener(`keydown`,n)}},[n,t])},fi=Kt(`components:git-hub-auth-button`),pi=()=>{let{t:e}=R(),[t,n]=(0,Q.useState)(!1),[r,i]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{(async()=>{try{let e=await fetch(`${cn}/auth/oauth/github/status`,{method:`GET`,credentials:`include`});if(e.ok){let t=await e.json();i(t.configured||!1),fi.debug(`GitHub OAuth configured:`,t.configured)}else fi.debug(`GitHub OAuth status check failed`),i(!1)}catch(e){fi.debug(`GitHub OAuth not configured:`,e),i(!1)}})()},[]),r?(0,$.jsx)(`button`,{type:`button`,onClick:()=>{if(!r||t)return;n(!0);let e=`${cn}/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-hidden 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,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(K,{size:16,className:`me-2 animate-spin`}),e(`auth.oauth.connectingTo`,{provider:e(`auth.oauth.github`)})]}):(0,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(we,{size:16,className:`me-2`}),e(`auth.oauth.continueWith`,{provider:e(`auth.oauth.github`)})]})}):null},mi=Kt(`components:hugging-face-auth-button`),hi=()=>{let{t:e}=R(),[t,n]=(0,Q.useState)(!1),[r,i]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{(async()=>{try{let e=await fetch(`${cn}/auth/oauth/huggingface/status`,{method:`GET`,credentials:`include`});if(e.ok){let t=await e.json();i(t.configured||!1),mi.debug(`Hugging Face OAuth configured:`,t.configured)}else mi.debug(`Hugging Face OAuth status check failed`),i(!1)}catch(e){mi.debug(`Hugging Face OAuth not configured:`,e),i(!1)}})()},[]),r?(0,$.jsx)(`button`,{type:`button`,onClick:()=>{if(!r||t)return;n(!0);let e=`${cn}/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-hidden 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,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(K,{size:16,className:`me-2 animate-spin`}),e(`auth.oauth.connectingTo`,{provider:e(`auth.oauth.huggingFace`)})]}):(0,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(`span`,{className:`me-2 text-base`,children:`🤗`}),e(`auth.oauth.continueWith`,{provider:e(`auth.oauth.huggingFace`)})]})}):null},gi=({displayName:e})=>{let{t}=R(),[n,r]=(0,Q.useState)(!1),i=e||t(`auth.oidc.defaultProviderName`,`Single sign-on`);return(0,$.jsx)(`button`,{type:`button`,onClick:()=>{n||(r(!0),window.location.href=`${cn}/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-hidden 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,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(K,{size:16,className:`me-2 animate-spin`}),t(`auth.oauth.connectingTo`,{provider:i})]}):(0,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(ue,{size:16,className:`me-2`}),t(`auth.oauth.continueWith`,{provider:i})]})})},_i=Kt(`hooks:oauth-providers`),vi=async e=>{try{let t=await fetch(`${cn}/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 _i.debug(`${e} OAuth not configured:`,t),{configured:!1}}},yi=()=>{let[e,t]=(0,Q.useState)({github:!1,huggingface:!1,oidc:!1}),[n,r]=(0,Q.useState)(void 0);return(0,Q.useEffect)(()=>{let e=!0;return Promise.all([vi(`github`),vi(`huggingface`),vi(`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}},bi=Kt(`components:login-form`),xi={username:`demo`,password:`demo`},Si=({onLogin:e,onShowSignup:t,initialApprovalPending:n=!1,bare:r=!1})=>{let{t:i}=R(),a=Gt(),o=yi(),[s,c]=(0,Q.useState)(a?xi.username:``),[l,u]=(0,Q.useState)(a?xi.password:``),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(n),[_,v]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(null),[x,S]=(0,Q.useState)(``),[C,w]=(0,Q.useState)(null),[T,E]=(0,Q.useState)(null),[D,O]=(0,Q.useState)(null),[k,A]=(0,Q.useState)(null),j=ee(),N=M(),P=()=>{let e=Cr(N.state);Sr(),j(e)},{login:F,systemInfo:I}=J(),te=I?.turnstile?.siteKey,L=!!(I?.turnstile?.enabled&&te&&!a),ne=(0,Q.useCallback)(e=>{v(e)},[]),re=(0,Q.useMemo)(()=>p||L&&!_,[p,L,_]),z=(e,t=null)=>{A({message:e,field:t}),B.error(e)},ie=(...e)=>A(t=>t&&e.includes(t.field)?null:t),V=e=>k&&(k.field===e||k.field===`credentials`&&e!==`mfaCode`)?{"aria-invalid":!0,"aria-describedby":`login-error`}:{},ae=k&&(0,$.jsx)(`p`,{id:`login-error`,role:`alert`,"data-testid":`login-error`,className:`rounded-xl border border-error-700/30 bg-error-500/10 px-3 py-2 text-start text-sm text-error-700 dark:text-error-400`,children:k.message}),se=async t=>{t.preventDefault(),A(null);let n=a?xi.username:s.trim(),r=a?xi.password:l;if(!n||!r)z(i(`auth.login.enterBoth`),n?`password`:`username`);else if(L&&!_)z(i(`auth.login.verificationFailed`,`Security verification failed. Please refresh and try again.`));else{m(!0),g(!1);try{localStorage.removeItem(`auth-token`);let t=await Ft.login({username:n,password:r,turnstileToken:_});if(t.success&&t.data){if(It(t.data)){if(b(t.data),S(``),t.data.requirement===`enroll`){let e=await Ft.mfaEnrollChallenge({challengeToken:t.data.challengeToken});e.success&&e.data?w(e.data):(z(e.message||i(`auth.mfa.enrollFailed`)),b(null))}return}F(t.data.user,t.data.token,t.data.systemInfo),B.success(i(`auth.login.loginSuccess`)),e?.(),P()}else z(t.message||i(`auth.login.loginFailed`),`credentials`)}catch(e){bi.error(`Login error:`,e);let t=e;t.response?.data?.code===`ACCOUNT_PENDING`?(g(!0),B.error(t.response.data.message||i(`auth.login.approvalPending`,`Your account is waiting for administrator approval.`))):z(i(`auth.login.checkCredentials`),`credentials`)}finally{v(``),m(!1)}}},H=t=>{F(t.user,t.token,t.systemInfo),B.success(i(`auth.login.loginSuccess`)),e?.(),P()},ce=async e=>{if(e.preventDefault(),y&&x.trim()){m(!0);try{if(y.requirement===`enroll`){let e=await Ft.mfaActivateChallenge({challengeToken:y.challengeToken,code:x.trim()});if(e.success&&e.data){let{recoveryCodes:t,...n}=e.data;O(n),E(t)}else z(e.message||i(`auth.mfa.invalidCode`),`mfaCode`);return}let e=await Ft.mfaVerify({challengeToken:y.challengeToken,code:x.trim()});e.success&&e.data?H(e.data):z(e.message||i(`auth.mfa.invalidCode`),`mfaCode`)}catch(e){let t=e.response?.data?.message;t&&/challenge/i.test(t)?(z(i(`auth.mfa.challengeExpired`)),b(null),w(null)):z(t||i(`auth.mfa.invalidCode`),`mfaCode`)}finally{S(``),m(!1)}}},le=async()=>{m(!0);try{let e=await Ft.passkeyLoginOptions();if(!e.success||!e.data){z(e.message||i(`auth.passkeys.signInFailed`));return}let t=await pn(e.data.publicKey),n=await Ft.passkeyLogin({challengeToken:e.data.challengeToken,credential:t});n.success&&n.data?(localStorage.removeItem(`auth-token`),H(n.data)):z(n.message||i(`auth.passkeys.signInFailed`))}catch(e){let t=e;if(t.name===`NotAllowedError`||t.name===`AbortError`)return;let n=e;bi.error(`Passkey login error:`,e),z(n.response?.data?.message||i(`auth.passkeys.signInFailed`))}finally{m(!1)}},W=e=>{if(e.key===`Enter`){let t=e.currentTarget.form;t&&t.requestSubmit()}},G=X(`mx-auto w-full max-w-md`,!r&&`rounded-3xl border border-line bg-surface-raised p-6 shadow-card sm:p-8`);if(T&&D)return(0,$.jsxs)(`div`,{className:G,"data-testid":`login-recovery-codes`,children:[(0,$.jsxs)(`div`,{className:X(`mb-6`,r?`text-start`:`text-center`),children:[(0,$.jsx)(`h1`,{className:`mb-2 text-2xl font-light tracking-[-0.04em] text-ink`,children:i(`auth.mfa.recoveryCodesTitle`)}),(0,$.jsx)(`p`,{className:`text-sm leading-6 text-ink-muted`,children:i(`auth.mfa.recoveryCodesHint`)})]}),(0,$.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:T.map(e=>(0,$.jsx)(`span`,{dir:`ltr`,children:e},e))}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>H(D),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-hidden 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,$.jsxs)(`div`,{className:G,"data-testid":`login-mfa-step`,children:[(0,$.jsxs)(`div`,{className:X(`mb-6`,r?`text-start`:`text-center`),children:[(0,$.jsx)(`div`,{className:X(`mb-3 flex`,r?`justify-start`:`justify-center`),children:(0,$.jsx)(ct,{"aria-hidden":`true`,className:`h-8 w-8 text-ink`})}),(0,$.jsx)(`h1`,{className:`mb-2 text-2xl font-light tracking-[-0.04em] text-ink`,children:i(e?`auth.mfa.setupTitle`:`auth.mfa.verifyTitle`)}),(0,$.jsx)(`p`,{className:`text-sm leading-6 text-ink-muted`,children:i(e?`auth.mfa.setupSubtitle`:`auth.mfa.verifyHint`)})]}),e&&C&&(0,$.jsxs)(`div`,{className:`mb-5 space-y-3 rounded-xl border border-line bg-surface p-4 text-start`,children:[(0,$.jsx)(`p`,{className:`text-xs leading-5 text-ink-muted`,children:i(`auth.mfa.secretHint`)}),(0,$.jsx)(`code`,{dir:`ltr`,"data-testid":`mfa-enroll-secret`,className:`block break-all font-mono text-sm text-ink`,children:C.secret}),(0,$.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,$.jsxs)(`form`,{onSubmit:ce,className:`space-y-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.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,$.jsx)(`input`,{id:`mfa-code`,"data-testid":`mfa-code-input`,type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,autoFocus:!0,dir:`ltr`,...V(`mfaCode`),value:x,onChange:e=>{S(e.target.value),ie(`mfaCode`)},className:`h-11 w-full rounded-xl border border-line bg-surface px-3 text-sm text-ink shadow-subtle outline-hidden transition-[border-color,box-shadow,background-color] placeholder:text-ink-muted focus:border-primary-500 focus:ring-2 focus:ring-primary-500/30 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,$.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-hidden focus-visible:ring-2 focus-visible:ring-primary-500 disabled:cursor-not-allowed disabled:opacity-40 motion-reduce:transition-none`,children:p?(0,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.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`)}),ae,(0,$.jsx)(`button`,{type:`button`,onClick:()=>{b(null),w(null),S(``),A(null)},className:`w-full text-center text-sm font-medium text-ink-muted transition-colors hover:text-ink`,children:i(`auth.mfa.backToSignIn`)})]})]})}return(0,$.jsxs)(`div`,{className:X(`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,$.jsxs)(`div`,{className:X(`mb-8`,r?`text-start`:`text-center`),children:[(0,$.jsx)(`h1`,{className:`mb-2 text-3xl font-light tracking-[-0.04em] text-ink`,children:i(`auth.login.title`)}),(0,$.jsx)(`p`,{className:`text-sm leading-6 text-ink-muted`,children:i(`auth.login.subtitle`)})]}),(0,$.jsxs)(`form`,{onSubmit:se,className:`space-y-5`,children:[h&&(0,$.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,$.jsx)(ye,{"aria-hidden":`true`,className:`mt-0.5 h-4 w-4 shrink-0 text-warning-700 dark:text-warning-400`}),(0,$.jsx)(`p`,{className:`text-xs leading-5 text-ink-muted`,children:i(`auth.login.approvalPending`,`Your account is waiting for administrator approval.`)})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{htmlFor:`username`,className:`mb-2 block text-sm font-medium text-ink`,children:i(`auth.login.username`)}),(0,$.jsx)(`input`,{id:`username`,type:`text`,autoComplete:`username`,autoCapitalize:`none`,spellCheck:!1,...V(`username`),value:s,onChange:e=>{c(e.target.value),ie(`username`,`credentials`)},onKeyDown:W,className:`h-11 w-full rounded-xl border border-line bg-surface px-3 text-sm text-ink shadow-subtle outline-hidden transition-[border-color,box-shadow,background-color] placeholder:text-ink-muted focus:border-primary-500 focus:ring-2 focus:ring-primary-500/30 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,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{htmlFor:`password`,className:`mb-2 block text-sm font-medium text-ink`,children:i(`auth.login.password`)}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`input`,{id:`password`,type:d?`text`:`password`,autoComplete:`current-password`,...V(`password`),value:l,onChange:e=>{u(e.target.value),ie(`password`,`credentials`)},onKeyDown:W,className:`h-11 w-full rounded-xl border border-line bg-surface px-3 pe-11 text-sm text-ink shadow-subtle outline-hidden transition-[border-color,box-shadow,background-color] placeholder:text-ink-muted focus:border-primary-500 focus:ring-2 focus:ring-primary-500/30 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,$.jsx)(`button`,{type:`button`,onClick:()=>f(!d),className:`absolute inset-y-0 inset-e-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":i(d?`auth.password.hide`:`auth.password.show`),"aria-pressed":d,children:d?(0,$.jsx)(he,{size:20}):(0,$.jsx)(oe,{size:20})})]})]}),L&&te&&(0,$.jsx)(yn,{siteKey:te,action:`login`,disabled:p,errorMessage:i(`auth.login.verificationFailed`,`Security verification failed. Please refresh and try again.`),onTokenChange:ne}),(0,$.jsx)(`button`,{type:`submit`,disabled:re,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-hidden 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,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(`div`,{className:`me-2 h-4 w-4 animate-spin rounded-full border-b-2 border-current`}),i(`auth.login.signingIn`)]}):(0,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(U,{size:16,className:`me-2`}),i(`auth.login.signIn`)]})}),ae]}),!a&&dn()&&I?.passkeysInUse&&(0,$.jsxs)(`button`,{type:`button`,"data-testid":`passkey-signin-button`,onClick:le,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-hidden focus-visible:ring-2 focus-visible:ring-primary-500 disabled:cursor-not-allowed disabled:opacity-40 motion-reduce:transition-none`,children:[(0,$.jsx)(ue,{size:16,className:`me-2`}),i(`auth.passkeys.signInButton`)]}),!a&&(0,$.jsxs)($.Fragment,{children:[o.hasAny&&(0,$.jsxs)(`div`,{className:`mt-6`,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`div`,{className:`absolute inset-0 flex items-center`,children:(0,$.jsx)(`div`,{className:`w-full border-t border-line`})}),(0,$.jsx)(`div`,{className:`relative flex justify-center text-sm`,children:(0,$.jsx)(`span`,{className:X(`px-2 text-ink-muted`,r?`bg-canvas`:`bg-surface-raised`),children:i(`common.or`)})})]}),(0,$.jsxs)(`div`,{className:`mt-6 space-y-3`,children:[o.github&&(0,$.jsx)(pi,{}),o.huggingface&&(0,$.jsx)(hi,{}),o.oidc&&(0,$.jsx)(gi,{displayName:o.oidcDisplayName})]})]}),t&&(0,$.jsx)(`div`,{className:`mt-6 text-center`,children:(0,$.jsxs)(`p`,{className:`text-sm text-ink-muted`,children:[i(`auth.login.noAccount`),` `,(0,$.jsx)(`button`,{type:`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`)})]})})]})]})},Ci=Kt(`components:signup-form`),wi=({onSignup:e,onBackToLogin:t,bare:n=!1})=>{let{t:r}=R(),[i,a]=(0,Q.useState)(``),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(``),[S,C]=(0,Q.useState)(null),w=ee(),{login:T,systemInfo:E}=J(),D=E?.turnstile?.siteKey,O=!!(E?.turnstile?.enabled&&D),k=(0,Q.useCallback)(e=>{x(e)},[]),A=(0,Q.useMemo)(()=>g||O&&!b,[g,O,b]),j=(e,t=null)=>{C({message:e,field:t}),B.error(e)},M=e=>C(t=>t?.field===e?null:t),N=e=>S?.field===e?{"aria-invalid":!0,"aria-describedby":`signup-error`}:{},P=async t=>{if(t.preventDefault(),C(null),!i.trim()||!c.trim()){j(r(`auth.signup.usernameRequired`),i.trim()?`password`:`username`);return}if(c!==u){j(r(`auth.signup.passwordMismatch`),`confirmPassword`);return}let n=bn(c);if(n)j(r(n),`password`);else if(O&&!b)j(r(`auth.signup.tryAgain`));else{_(!0);try{let t=await Ft.signup({username:i,password:c,email:o,turnstileToken:b});if(t.success&&t.data){if(!(`token`in t.data)){y(!0),B.success(r(`auth.signup.approvalPending`,`Registration received. An administrator must approve your account.`));return}T(t.data.user,t.data.token,t.data.systemInfo),B.success(r(`auth.signup.signupSuccess`)),e?.(),w(`/`)}else j(t.message||r(`auth.signup.signupFailed`))}catch(e){Ci.error(`Signup error:`,e),j(r(`auth.signup.tryAgain`))}finally{x(``),_(!1)}}},F=e=>{if(e.key===`Enter`){let t=e.currentTarget.form;t&&t.requestSubmit()}};return v?(0,$.jsxs)(`div`,{"data-testid":`signup-approval-pending`,className:X(`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,$.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,$.jsx)(ye,{"aria-hidden":`true`,className:`h-6 w-6`})}),(0,$.jsx)(`h1`,{className:`mt-5 text-3xl font-light tracking-[-0.04em] text-ink`,children:r(`auth.signup.awaitingApproval`,`Awaiting approval`)}),(0,$.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,$.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,$.jsxs)(`div`,{className:X(`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,$.jsxs)(`div`,{className:X(`mb-8`,n?`text-start`:`text-center`),children:[(0,$.jsx)(`h1`,{className:`mb-2 text-3xl font-light tracking-[-0.04em] text-ink`,children:r(`auth.signup.title`)}),(0,$.jsx)(`p`,{className:`text-sm leading-6 text-ink-muted`,children:r(`auth.signup.subtitle`)})]}),(0,$.jsxs)(`form`,{onSubmit:P,className:`space-y-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{htmlFor:`username`,className:`mb-2 block text-sm font-medium text-ink`,children:r(`auth.signup.username`)}),(0,$.jsx)(`input`,{id:`username`,type:`text`,autoComplete:`username`,autoCapitalize:`none`,spellCheck:!1,...N(`username`),value:i,onChange:e=>{a(e.target.value),M(`username`)},onKeyDown:F,className:`h-11 w-full rounded-xl border border-line bg-surface px-3 text-sm text-ink shadow-subtle outline-hidden transition-[border-color,box-shadow,background-color] placeholder:text-ink-muted focus:border-primary-500 focus:ring-2 focus:ring-primary-500/30 disabled:cursor-not-allowed disabled:opacity-50 motion-reduce:transition-none`,placeholder:r(`auth.signup.usernamePlaceholder`),required:!0,disabled:g})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`label`,{htmlFor:`email`,className:`mb-2 block text-sm font-medium text-ink`,children:[r(`auth.signup.email`),` `,(0,$.jsxs)(`span`,{className:`text-ink-muted`,children:[`(`,r(`common.optional`),`)`]})]}),(0,$.jsx)(`input`,{id:`email`,type:`email`,autoComplete:`email`,value:o,onChange:e=>s(e.target.value),onKeyDown:F,className:`h-11 w-full rounded-xl border border-line bg-surface px-3 text-sm text-ink shadow-subtle outline-hidden transition-[border-color,box-shadow,background-color] placeholder:text-ink-muted focus:border-primary-500 focus:ring-2 focus:ring-primary-500/30 disabled:cursor-not-allowed disabled:opacity-50 motion-reduce:transition-none`,placeholder:r(`auth.signup.emailPlaceholder`),disabled:g})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{htmlFor:`password`,className:`mb-2 block text-sm font-medium text-ink`,children:r(`auth.signup.password`)}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`input`,{id:`password`,type:f?`text`:`password`,autoComplete:`new-password`,...N(`password`),value:c,onChange:e=>{l(e.target.value),M(`password`)},onKeyDown:F,className:`h-11 w-full rounded-xl border border-line bg-surface px-3 pe-11 text-sm text-ink shadow-subtle outline-hidden transition-[border-color,box-shadow,background-color] placeholder:text-ink-muted focus:border-primary-500 focus:ring-2 focus:ring-primary-500/30 disabled:cursor-not-allowed disabled:opacity-50 motion-reduce:transition-none`,placeholder:r(`auth.signup.passwordPlaceholder`),required:!0,disabled:g}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>p(!f),className:`absolute inset-y-0 inset-e-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":r(f?`auth.password.hide`:`auth.password.show`),"aria-pressed":f,children:f?(0,$.jsx)(he,{size:20}):(0,$.jsx)(oe,{size:20})})]}),(0,$.jsx)(xn,{password:c})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{htmlFor:`confirmPassword`,className:`mb-2 block text-sm font-medium text-ink`,children:r(`auth.signup.confirmPassword`)}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`input`,{id:`confirmPassword`,type:m?`text`:`password`,autoComplete:`new-password`,...N(`confirmPassword`),value:u,onChange:e=>{d(e.target.value),M(`confirmPassword`)},onKeyDown:F,className:`h-11 w-full rounded-xl border border-line bg-surface px-3 pe-11 text-sm text-ink shadow-subtle outline-hidden transition-[border-color,box-shadow,background-color] placeholder:text-ink-muted focus:border-primary-500 focus:ring-2 focus:ring-primary-500/30 disabled:cursor-not-allowed disabled:opacity-50 motion-reduce:transition-none`,placeholder:r(`auth.signup.confirmPasswordPlaceholder`),required:!0,disabled:g}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>h(!m),className:`absolute inset-y-0 inset-e-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":r(m?`auth.password.hideConfirmation`:`auth.password.showConfirmation`),"aria-pressed":m,children:m?(0,$.jsx)(he,{size:20}):(0,$.jsx)(oe,{size:20})})]})]}),O&&D&&(0,$.jsx)(yn,{siteKey:D,action:`signup`,disabled:g,errorMessage:r(`auth.signup.tryAgain`),onTokenChange:k}),(0,$.jsx)(`button`,{type:`submit`,disabled:A,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-hidden 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,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(`div`,{className:`me-2 h-4 w-4 animate-spin rounded-full border-b-2 border-current`}),r(`auth.signup.creatingAccount`)]}):(0,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(tt,{size:16,className:`me-2`}),r(`auth.signup.createAccount`)]})}),S&&(0,$.jsx)(`p`,{id:`signup-error`,role:`alert`,className:`rounded-xl border border-error-700/30 bg-error-500/10 px-3 py-2 text-sm text-error-700 dark:text-error-400`,children:S.message})]}),(0,$.jsx)(pi,{}),(0,$.jsx)(`div`,{className:`mt-6 text-center`,children:(0,$.jsxs)(`p`,{className:`text-sm text-ink-muted`,children:[r(`auth.signup.hasAccount`),` `,(0,$.jsx)(`button`,{type:`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`)})]})})]})},Ti=()=>{let{t:e}=R(),t=M(),{isAuthenticated:n,requiresAuth:r,systemInfo:i}=J(),[a,o]=(0,Q.useState)(!1),s=r(),c=i?.signupEnabled??!0,l=new URLSearchParams(t.search).get(`approval`)===`pending`;if(n||!s)return(0,$.jsx)(C,{to:Cr(t.state),replace:!0});let u=[{icon:ct,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:Be,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:re,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.`)}],d=Sn(i?.version);return(0,$.jsxs)(`div`,{className:`relative min-h-dvh overflow-y-auto bg-canvas text-ink`,"data-celestial-canvas":``,children:[(0,$.jsx)(Vr,{}),(0,$.jsxs)(`header`,{className:`absolute inset-x-0 top-0 z-20 flex h-14 items-center justify-between px-5 sm:px-8`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-ink lg:invisible`,children:[(0,$.jsx)(Zt,{size:`sm`,label:null}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:(0,$.jsx)(Xt,{size:`sm`})})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(mn,{compact:!0}),(0,$.jsx)(Wn,{})]})]}),(0,$.jsxs)(`main`,{className:`relative z-10 grid min-h-dvh lg:grid-cols-2`,children:[(0,$.jsxs)(`section`,{className:`relative hidden flex-col justify-between border-e border-line bg-surface px-10 py-12 lg:flex xl:px-16`,"data-celestial-surface":``,children:[(0,$.jsxs)(`div`,{className:`relative z-10 flex items-center gap-3.5 text-ink`,children:[(0,$.jsx)(Zt,{size:`lg`,label:null}),(0,$.jsx)(Xt,{size:`lg`})]}),(0,$.jsxs)(`div`,{className:`relative z-10 max-w-lg`,children:[(0,$.jsx)(`p`,{className:`text-[2.6rem] font-light leading-[1.05] tracking-[-0.04em] text-ink xl:text-5xl xl:leading-none`,children:e(`auth.tagline`,`Your AI stack should answer to you.`)}),(0,$.jsx)(`ul`,{className:`mt-10 space-y-5`,children:u.map(e=>(0,$.jsxs)(`li`,{className:`flex gap-3`,children:[(0,$.jsx)(e.icon,{"aria-hidden":`true`,className:`mt-0.5 h-4 w-4 shrink-0 text-ink-subtle`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-[13px] font-medium text-ink`,children:e.title}),(0,$.jsx)(`p`,{className:`mt-0.5 text-[13px] leading-relaxed text-ink-muted`,children:e.body})]})]},e.title))})]}),(0,$.jsxs)(`div`,{className:`relative z-10 space-y-1 font-mono text-[11px] text-ink-muted`,children:[(0,$.jsxs)(`p`,{children:[(0,$.jsx)(`a`,{href:`https://librewebui.org`,target:`_blank`,rel:`noopener noreferrer`,className:`transition-colors hover:text-ink`,children:`librewebui.org`}),` · `,(0,$.jsx)(`a`,{href:`https://docs.librewebui.org`,target:`_blank`,rel:`noopener noreferrer`,className:`transition-colors hover:text-ink`,children:`docs.librewebui.org`})]}),(0,$.jsxs)(`p`,{"data-testid":`app-version`,children:[d?`v${d}`:``,d?` · `:``,e(`auth.selfHosted`,`Self-hosted · Apache 2.0`),` · `,(0,$.jsx)(`a`,{href:`https://kroonen.ai`,target:`_blank`,rel:`noopener noreferrer`,className:`transition-colors hover:text-ink`,children:`kroonen.ai`})]})]})]}),(0,$.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,$.jsx)(`div`,{className:`w-full max-w-sm`,children:a&&c?(0,$.jsx)(wi,{bare:!0,onBackToLogin:()=>o(!1),onSignup:()=>o(!1)}):(0,$.jsx)(Si,{bare:!0,initialApprovalPending:l,onShowSignup:c?()=>o(!0):void 0})})})]})]})},Ei=()=>{let{t:e}=R();return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center p-6`,children:(0,$.jsxs)(`div`,{className:`max-w-sm text-center`,"data-testid":`not-found-page`,children:[(0,$.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-xl bg-surface-subtle text-ink-muted`,children:(0,$.jsx)(ce,{className:`h-6 w-6`})}),(0,$.jsx)(`h1`,{className:`mb-2 text-xl font-semibold text-ink`,children:e(`notFound.title`)}),(0,$.jsx)(`p`,{className:`mb-5 text-sm leading-6 text-ink-muted`,children:e(`notFound.description`)}),(0,$.jsx)(j,{to:`/`,className:`inline-flex h-10 items-center justify-center rounded-xl bg-ink px-4 text-sm font-medium text-ink-inverse shadow-subtle transition-opacity duration-150 hover:opacity-90`,children:e(`errorBoundary.goHome`)})]})})},Di=window.location.protocol===`file:`,Oi=()=>Di?(0,$.jsx)(`div`,{className:`absolute top-0 left-0 right-0 h-8 z-50`,style:{WebkitAppRegion:`drag`}}):null,ki=Kt(`app`),Ai=Q.lazy(()=>Z(()=>import(`../js/HomePage-Cjlt3b9n.js`),__vite__mapDeps([31,1,2,32,12,10,7,4,5,6,24,18,19,20,21,22,23,33,34,35,30]))),ji=Q.lazy(()=>Z(()=>import(`../js/ChatPage-iyMY-uoE.js`),__vite__mapDeps([36,1,2,32,12,10,7,4,5,6,8,9,11,13,37,38,39,40,41,42,21,19,20,22,23,29,43,18,24,44,15,45,46,3,27,47,48,34]))),Mi=Q.lazy(()=>Z(()=>import(`../js/WhatsNewModal-yYk7N4KY.js`).then(e=>({default:e.WhatsNewModal})),__vite__mapDeps([49,1,2,40,12,10,7,9,4,5,6,8,11,13]))),Ni=Q.lazy(()=>Z(()=>import(`../js/PersonasPage-B8mFdWcX.js`),__vite__mapDeps([50,1,2,12,10,7,3,4,5,6,9,8,11,13,19,20,21,22,23,26,18,51]))),Pi=Q.lazy(()=>Z(()=>import(`../js/GalleryPage-u7dYKl3q.js`),__vite__mapDeps([52,1,2,12,10,7,4,5,6,8,9,11,13,19,20,21,22,23,3,28,25]))),Fi=Q.lazy(()=>Z(()=>import(`../js/NotesPage-BQWBA5li.js`),__vite__mapDeps([53,1,2,32,12,10,7,4,5,6,54,40,11,8,9,13,19,20,21,22,23,28,18]))),Ii=Q.lazy(()=>Z(()=>import(`../js/CalendarPage-DkAa61Pa.js`),__vite__mapDeps([55,1,2,32,12,10,7,4,5,6,8,9,11,13,28,56,19,20,21,22,23,26]))),Li=Q.lazy(()=>Z(()=>import(`../js/AutomationsPage-v98Ucl9p.js`),__vite__mapDeps([57,1,2,32,12,10,7,4,5,6,8,9,11,13,28,58,19,20,21,22,23,56,18]))),Ri=Q.lazy(()=>Z(()=>import(`../js/StrandsPage-ddHNdb6J.js`),__vite__mapDeps([59,1,2,12,10,7,4,5,6,8,9,11,13,47,22,21,20]))),zi=Q.lazy(()=>Z(()=>import(`../js/ChannelsPage-0Vnfpgdr.js`),__vite__mapDeps([60,1,2,32,12,10,7,4,5,6,8,9,11,13,28,19,20,21,22,23,61,24,18]))),Bi=Q.lazy(()=>Z(()=>import(`../js/WorkPage-i7yYRAuj.js`),__vite__mapDeps([62,1,4,2,5,6,7,12,10,32,46,3,18,19,20,21,22,23,9,8,11,13,24,27,47,35,63,54,40,15,58,56,44]))),Vi=Q.lazy(()=>Z(()=>import(`../js/UserManagementPage-BrogyZDQ.js`),__vite__mapDeps([64,1,2,32]))),Hi=Q.lazy(()=>Z(()=>import(`../js/PluginUsagePage-Uz6aHPIp.js`),__vite__mapDeps([65,1,2,3,12,10,7,4,5,6,8,9,11,13,20,21,19,22,23]))),Ui=Q.lazy(()=>Z(()=>import(`../js/EvaluationsPage-C7WHA1MJ.js`),__vite__mapDeps([66,1,2,12,10,7,4,5,6,8,9,11,13,28,18,19,20,21,22,23,45]))),Wi=Q.lazy(()=>Z(()=>import(`../js/SystemPage-C_1exwI7.js`),__vite__mapDeps([67,1,2,3,12,10,7,4,5,6,8,9,11,13,19,20,21,22,23,24,18]))),Gi=Q.lazy(()=>Z(()=>import(`../js/ArtifactDemoPage-C-1acgxJ.js`),__vite__mapDeps([68,1,2,37,12,10,7,4,5,6,9,38,39,40,41,42,21,8,11,13]))),Ki=Q.lazy(()=>Z(()=>import(`../js/SettingsModal-CfjxNSmJ.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,29,30]))),qi=Q.lazy(()=>Z(()=>import(`../js/ArtifactSlideOutPanel-CvfdP_o2.js`).then(e=>({default:e.ArtifactSlideOutPanel})),__vite__mapDeps([69,1,2,12,10,7,4,5,6,9,38,39,40,41,42,21,18,19,20,22,23]))),Ji=Q.lazy(()=>Z(()=>import(`../js/FirstTimeSetup-B8wcelBc.js`).then(e=>({default:e.FirstTimeSetup})),__vite__mapDeps([70,1,2,4,5,6,7,12,10,24,18,19,20,21,22,23,14,15,48,8,9,11,13,71,72]))),Yi=15,Xi=()=>{let{t:e}=R();return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{role:`status`,className:`flex flex-col items-center gap-3`,children:[(0,$.jsx)(`div`,{"aria-hidden":`true`,className:`h-8 w-8 rounded-full border-4 border-line border-t-primary-500 animate-spin dark:border-t-primary-400`}),(0,$.jsx)(`div`,{className:`text-sm text-ink-muted`,children:e(`common.loading`)})]})})},Zi=({isOpen:e,compact:t})=>(0,$.jsx)(`div`,{"aria-hidden":`true`,"data-sidebar-layout-spacer":``,className:X(`hidden md:block shrink-0 transition-[width] duration-200 ease-out motion-reduce:transition-none`,e?t?`w-16`:`w-72`:`w-0`)}),Qi=()=>{let{artifactPanelOpen:e,artifactPanelWidth:t,artifactPanelResizing:n}=Y();return(0,$.jsx)(`div`,{"aria-hidden":`true`,className:X(`hidden md:block shrink-0`,!n&&`transition-[width] duration-300 ease-out`),style:{width:e?t:0}})},$i=({sidebarOpen:e,sidebarCompact:t,onCloseSidebar:n,showDemoBanner:r,demoMessage:i,children:a})=>{let{t:o}=R(),{pathname:s}=M();ui(J(e=>e.canUseWork()));let c=Y(e=>e.preferences.backgroundSettings),l=Y(e=>e.backgroundImage),u=Ot(c),d=un(s)&&u.enabled&&u.opacity>0&&!!(l??u.imageUrl);return(0,$.jsxs)(`div`,{className:`relative flex h-dvh min-h-0 overflow-hidden bg-sidebar text-ink`,"data-app-shell":``,children:[(0,$.jsx)(`a`,{href:`#app-main`,className:`sr-only focus:not-sr-only focus:fixed focus:inset-s-3 focus:top-3 focus:z-2147483647 focus:rounded-xl focus:bg-ink focus:px-4 focus:py-2.5 focus:text-sm focus:font-medium focus:text-ink-inverse focus:shadow-overlay`,children:o(`common.skipToContent`)}),(0,$.jsx)(Oi,{}),(0,$.jsx)(Vr,{}),(0,$.jsx)(Er,{isOpen:e,onClose:n}),(0,$.jsx)(Zi,{isOpen:e,compact:t}),(0,$.jsxs)(`div`,{"data-testid":`app-shell-content`,className:X(`relative z-10 flex min-h-0 min-w-0 flex-1 basis-0 flex-col bg-transparent transition-[margin,background-color] duration-200 ease-out motion-reduce:transition-none lg:pb-2 lg:pe-2`,Di?`pt-8`:`lg:pt-1.5`,e?`max-md:ms-16`:`max-md:ms-0`),children:[r&&(0,$.jsx)(Pr,{message:i}),(0,$.jsx)(Yr,{}),(0,$.jsxs)(`main`,{id:`app-main`,tabIndex:-1,"data-app-main":``,"data-wallpaper":d?`true`:void 0,className:`relative isolate min-h-0 flex-1 overflow-hidden bg-canvas focus:outline-hidden lg:rounded-3xl lg:border lg:border-black/6 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)]`,children:[(0,$.jsx)(fn,{active:d}),(0,$.jsx)(`div`,{className:`relative z-10 h-full min-h-0`,"data-wallpaper-content":``,children:(0,$.jsx)(jr,{resetKey:s,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(Xi,{}),children:a})})})]})]}),(0,$.jsx)(Qi,{})]})},ea=[{path:`*`,element:(0,$.jsx)(()=>{let{t:e,i18n:t}=R(),n=ee(),[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(void 0),s=(0,Q.useCallback)(()=>{o(`users`),i(!0)},[]),[c,l]=(0,Q.useState)(0),[u,d]=(0,Q.useState)(!1),{sidebarOpen:f,sidebarCompact:p,setSidebarOpen:m,setSidebarCompact:h,toggleSidebar:g,toggleSidebarCompact:_,toggleTheme:v,preferences:y,artifactPanelOpen:b,closeArtifactPanel:x}=Y(),{systemInfo:S,isLoading:C,isAuthenticated:T}=J(),{isDemoMode:E,demoConfig:O}=Y(),k=S?.requiresAuth===!1||T,A=Nr();Q.useEffect(()=>{if(y.ttsSettings?.enabled&&y.ttsSettings.autoPlay)return vn()},[y.ttsSettings?.autoPlay,y.ttsSettings?.enabled]);let[j,M]=Q.useState(!1),N=Q.useRef(!1);Q.useEffect(()=>{(async()=>{if(N.current)ki.debug(`OAuth already processing, skipping...`);else{if(ki.debug(`Starting OAuth callback processing...`),N.current=!0,new URLSearchParams(window.location.search).get(`auth`)===`success`){try{let t=await fetch(`${cn}/auth/oauth/exchange`,{method:`POST`,credentials:`include`});if(t.ok){let n=await t.json();if(n.success&&n.data){let{login:t}=J.getState();t(n.data.user,n.data.token,n.data.systemInfo),ki.debug(`OAuth login successful`),de.success(e(`auth.oauth.loginSuccess`))}else de.error(e(`auth.oauth.completionFailed`))}else de.error(e(`auth.oauth.verificationFailed`))}catch(t){ki.error(`OAuth processing error:`,t),de.error(e(`auth.oauth.authenticationFailed`))}window.history.replaceState({},document.title,window.location.pathname)}ki.debug(`OAuth processing completed`),M(!0),N.current=!1}})()},[e]),ri(),si(),di([{key:`b`,metaKey:!0,action:()=>{window.innerWidth>=1024?f?_():(h(!1),g()):(!f&&p&&h(!1),g())},description:e(`keyboard.toggleSidebar`)},{key:`,`,metaKey:!0,action:()=>{o(void 0),i(!0)},description:e(`keyboard.openSettings`)},{key:`o`,metaKey:!0,shiftKey:!0,action:()=>hn(n),description:e(`keyboard.newChat`)},{key:`u`,metaKey:!0,shiftKey:!0,action:()=>{J.getState().canUseWork()&&gn(n)},description:e(`keyboard.newWork`)},{key:`d`,metaKey:!0,action:v,description:e(`keyboard.toggleDarkMode`)},{key:`?`,action:()=>{o(`shortcuts`),i(!0)},description:e(`keyboard.showShortcuts`)}],k),Q.useEffect(()=>{if(k)return;let e=window.requestAnimationFrame(()=>{i(!1),x()});return()=>window.cancelAnimationFrame(e)},[x,k]),Q.useEffect(()=>{if(!k)xt.disconnect();else return xt.connect().catch(ki.error),()=>{xt.disconnect()}},[k]),Q.useEffect(()=>{if(!S&&!C&&c<Yi){let e=setTimeout(async()=>{l(e=>e+1);try{await ti.initializeAuth()}catch{}},2e3);return()=>clearTimeout(e)}},[S,C,c]);let F=c>=Yi,I=!u&&S?.requiresAuth===!0&&S?.hasUsers===!1;return C?(0,$.jsxs)(`div`,{className:`min-h-dvh bg-canvas flex flex-col justify-center py-12 sm:px-6 lg:px-8`,children:[(0,$.jsx)(`div`,{className:`sm:mx-auto sm:w-full sm:max-w-md`,children:(0,$.jsx)(`div`,{className:`flex flex-col items-center`,children:(0,$.jsx)(Zt,{size:`lg`,className:`text-ink`})})}),(0,$.jsxs)(`div`,{role:`status`,className:`mt-8 flex flex-col items-center gap-4`,children:[(0,$.jsx)(`div`,{"aria-hidden":`true`,className:`w-8 h-8 border-4 border-line border-t-primary-500 dark:border-t-primary-400 rounded-full animate-spin`}),(0,$.jsx)(`span`,{className:`sr-only`,children:e(`common.loading`)})]})]}):S?I&&!u?(0,$.jsx)(jr,{children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(Xi,{}),children:(0,$.jsx)(Ji,{onComplete:()=>{d(!0)}})})}):j?(0,$.jsxs)($.Fragment,{children:[S.requiresAuth?(0,$.jsxs)(w,{children:[(0,$.jsx)(D,{path:`/login`,element:(0,$.jsx)(Ti,{})}),(0,$.jsx)(D,{path:`/*`,element:(0,$.jsx)(Dr,{children:(0,$.jsx)($i,{sidebarOpen:f,sidebarCompact:p,onCloseSidebar:()=>m(!1),showDemoBanner:E&&O.showBanner,demoMessage:O.message,children:(0,$.jsxs)(w,{children:[(0,$.jsx)(D,{path:`/`,element:(0,$.jsx)(Ai,{})}),(0,$.jsx)(D,{path:`/chat`,element:(0,$.jsx)(ji,{})}),(0,$.jsx)(D,{path:`/c/:sessionId`,element:(0,$.jsx)(ji,{})}),(0,$.jsx)(D,{path:`/personas`,element:(0,$.jsx)(Ni,{})}),(0,$.jsx)(D,{path:`/gallery`,element:(0,$.jsx)(Pi,{})}),(0,$.jsx)(D,{path:`/notes`,element:(0,$.jsx)(Fi,{})}),(0,$.jsx)(D,{path:`/calendar`,element:(0,$.jsx)(Ii,{})}),(0,$.jsx)(D,{path:`/automations`,element:(0,$.jsx)(Li,{})}),(0,$.jsx)(D,{path:`/channels`,element:(0,$.jsx)(zi,{})}),(0,$.jsx)(D,{path:`/work`,element:(0,$.jsx)(Dr,{requireWork:!0,children:(0,$.jsx)(Bi,{})})}),(0,$.jsx)(D,{path:`/work/:taskId`,element:(0,$.jsx)(Dr,{requireWork:!0,children:(0,$.jsx)(Bi,{})})}),(0,$.jsx)(D,{path:`/strands`,element:(0,$.jsx)(Dr,{requireStrands:!0,children:(0,$.jsx)(Ri,{})})}),(0,$.jsx)(D,{path:`/artifacts`,element:(0,$.jsx)(Gi,{})}),(0,$.jsx)(D,{path:`/usage`,element:(0,$.jsx)(Dr,{requireAdmin:!0,children:(0,$.jsx)(Hi,{})})}),(0,$.jsx)(D,{path:`/evaluations`,element:(0,$.jsx)(Ui,{})}),(0,$.jsx)(D,{path:`/system`,element:(0,$.jsx)(Dr,{requireAdmin:!0,children:(0,$.jsx)(Wi,{})})}),(0,$.jsx)(D,{path:`/users`,element:(0,$.jsx)(Dr,{requireAdmin:!0,children:(0,$.jsx)(Vi,{onOpen:s})})}),(0,$.jsx)(D,{path:`*`,element:(0,$.jsx)(Ei,{})})]})})})})]}):(0,$.jsx)($i,{sidebarOpen:f,sidebarCompact:p,onCloseSidebar:()=>m(!1),showDemoBanner:E&&O.showBanner,demoMessage:O.message,children:(0,$.jsxs)(w,{children:[(0,$.jsx)(D,{path:`/`,element:(0,$.jsx)(Ai,{})}),(0,$.jsx)(D,{path:`/chat`,element:(0,$.jsx)(ji,{})}),(0,$.jsx)(D,{path:`/c/:sessionId`,element:(0,$.jsx)(ji,{})}),(0,$.jsx)(D,{path:`/personas`,element:(0,$.jsx)(Ni,{})}),(0,$.jsx)(D,{path:`/gallery`,element:(0,$.jsx)(Pi,{})}),(0,$.jsx)(D,{path:`/notes`,element:(0,$.jsx)(Fi,{})}),(0,$.jsx)(D,{path:`/calendar`,element:(0,$.jsx)(Ii,{})}),(0,$.jsx)(D,{path:`/automations`,element:(0,$.jsx)(Li,{})}),(0,$.jsx)(D,{path:`/channels`,element:(0,$.jsx)(zi,{})}),(0,$.jsx)(D,{path:`/work`,element:(0,$.jsx)(Dr,{requireWork:!0,children:(0,$.jsx)(Bi,{})})}),(0,$.jsx)(D,{path:`/work/:taskId`,element:(0,$.jsx)(Dr,{requireWork:!0,children:(0,$.jsx)(Bi,{})})}),(0,$.jsx)(D,{path:`/strands`,element:(0,$.jsx)(Dr,{requireStrands:!0,children:(0,$.jsx)(Ri,{})})}),(0,$.jsx)(D,{path:`/usage`,element:(0,$.jsx)(Dr,{requireAdmin:!0,children:(0,$.jsx)(Hi,{})})}),(0,$.jsx)(D,{path:`/evaluations`,element:(0,$.jsx)(Ui,{})}),(0,$.jsx)(D,{path:`/system`,element:(0,$.jsx)(Dr,{requireAdmin:!0,children:(0,$.jsx)(Wi,{})})}),(0,$.jsx)(D,{path:`/artifacts`,element:(0,$.jsx)(Gi,{})}),(0,$.jsx)(D,{path:`/login`,element:(0,$.jsx)(Ti,{})}),(0,$.jsx)(D,{path:`*`,element:(0,$.jsx)(Ei,{})})]})}),k&&r&&(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Ki,{isOpen:r,initialTab:a,onClose:()=>i(!1)})}),k&&A.open&&A.notes&&(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Mi,{notes:A.notes,onDismiss:A.dismiss})}),k&&b&&(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(qi,{})}),(0,$.jsx)(An,{}),(0,$.jsx)(Pn,{}),(0,$.jsx)(it,{position:P(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)`},success:{iconTheme:{primary:`rgb(var(--color-primary-600))`,secondary:`#ffffff`}},error:{duration:7e3,iconTheme:{primary:`#ef4444`,secondary:`#ffffff`}}},containerStyle:{top:80,insetInlineEnd:20},children:t=>t.type===`custom`?(0,$.jsx)($.Fragment,{children:se(t.message,t)}):(0,$.jsx)(ge,{toast:t.type===`error`?{...t,ariaProps:{role:`alert`,"aria-live":`assertive`}}:t,children:({icon:n,message:r})=>(0,$.jsxs)($.Fragment,{children:[n,r,(0,$.jsx)(q,{type:`button`,variant:`ghost`,tabIndex:0,className:`h-11 w-11 shrink-0 p-0`,"aria-label":e(`common.close`),title:e(`common.close`),"data-testid":`toast-dismiss-button`,onClick:()=>de.dismiss(t.id),children:(0,$.jsx)(We,{className:`h-4 w-4`,"aria-hidden":`true`})})]})})}),k&&(0,$.jsx)($r,{onOpenSettings:()=>{o(void 0),i(!0)},onOpenSettingsTab:e=>{o(e),i(!0)}})]}):(0,$.jsxs)(`div`,{role:`status`,className:`min-h-dvh bg-canvas flex items-center justify-center`,children:[(0,$.jsx)(`div`,{"aria-hidden":`true`,className:`w-8 h-8 border-4 border-line border-t-primary-500 dark:border-t-primary-400 rounded-full animate-spin`}),(0,$.jsx)(`span`,{className:`sr-only`,children:e(`common.loading`)})]}):(0,$.jsx)(`div`,{className:`min-h-dvh bg-canvas flex items-center justify-center p-4`,children:(0,$.jsxs)(`div`,{className:`max-w-sm text-center`,children:[(0,$.jsx)(`div`,{className:`mb-8`,children:(0,$.jsx)(Zt,{size:`lg`,className:`mx-auto text-ink`})}),F?(0,$.jsxs)(`div`,{role:`alert`,className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-ink`,children:e(`appInitialization.backendConnectionFailed`)}),(0,$.jsx)(`p`,{className:`text-sm text-ink-muted`,children:e(`appInitialization.backendUnreachableHint`)}),(0,$.jsxs)(q,{type:`button`,onClick:()=>l(0),children:[(0,$.jsx)(pe,{className:`h-4 w-4`}),e(`common.retry`)]})]}):(0,$.jsxs)(`div`,{role:`status`,children:[(0,$.jsx)(`div`,{className:`flex justify-center mb-4`,children:(0,$.jsx)(`div`,{"aria-hidden":`true`,className:`w-8 h-8 border-4 border-line border-t-primary-500 dark:border-t-primary-400 rounded-full animate-spin`})}),(0,$.jsx)(`p`,{className:`text-ink-muted text-sm`,children:c>0?e(`appInitialization.connecting`,{attempt:c,total:Yi}):e(`appInitialization.startingUp`)})]})]})})},{}),errorElement:(0,$.jsx)(Ar,{})}],ta=Di?k(ea):E(ea),na=()=>(0,$.jsx)(jr,{children:(0,$.jsx)(A,{router:ta})}),ra=new On({defaultOptions:{queries:{staleTime:3e4,refetchOnWindowFocus:!1,retry:1}}});F.catch(()=>{N(`en`)}).then(()=>{kn.createRoot(document.getElementById(`root`)).render((0,$.jsx)(Q.StrictMode,{children:(0,$.jsx)(a,{client:ra,children:(0,$.jsx)(na,{})})}))}),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.45.0`).catch(()=>{})});